MyFunnyDev

web, coding and beyond

Archive for the ‘Uncategorized’ Category

dfs in ruby :)

without comments

I wrote simple dfs in ruby:

def dfs(node, value, queue)
  return false if node.nil?	
  return true if node.data == value
 
  queue.push node.right unless node.right.nil?
  queue.push node.left unless node.left.nil?	
 
  dfs(queue.pop, value, queue)	
end

for node:

class Node
  attr_accessor :left, :right, :data
end

Written by Michał Kuklis

January 14th, 2010 at 12:38 am

Posted in Uncategorized

Academia vs. Business

without comments

Academia vs. Business

Written by Michał Kuklis

November 18th, 2009 at 12:05 pm

Posted in Uncategorized

Gemcutter & Jeweler

without comments

More about gemcutter & jeweler can be found here.

Here are the steps how to publish patched gem cloned from github:

1. Append username to gem name in .gemspec or if you use jeweler open Rakefile and edit Jeweler::Tasks section save it and run:

rake gemspec

2. Build gem with:

gem build

3. Push new gem to gemcutter

gem push

Written by Michał Kuklis

October 17th, 2009 at 1:03 am

Posted in Uncategorized

Tagged with

BDD with Cucumber by Ben Mabey

without comments

Written by Michał Kuklis

August 29th, 2009 at 12:16 pm

Posted in Uncategorized

auto escaping html in Rails to protect from XSS

with one comment

Tonight I found a plugin to auto escape html in order to protect from XSS attacks. I’m not sure why rails doesn’t do it out of the box (you have to use h() helper). Anyway the plugin is called xss_terminate and it can be found here. The cool thing about it is that now you can forget about h() :) .

Written by Michał Kuklis

July 29th, 2009 at 9:24 pm

Posted in Uncategorized

Tagged with

Cron in Ruby

without comments

Check out how Whenever gem can simplify cron configuration.

Written by Michał Kuklis

July 27th, 2009 at 2:10 am

Posted in Uncategorized

Tagged with ,

key-value store

without comments

Key/Value DB

Written by Michał Kuklis

July 26th, 2009 at 11:40 am

Posted in Uncategorized

daemon_controller + Thinking Sphinx

with 3 comments

I’ve created simple rails initiator in order to start Sphinx through daemon_controller based on the Thinking Sphinx configuration. I hope it will help somebody.

require 'daemon_controller'
 
def before_start
  if not ThinkingSphinx.define_indexes?
    config = ThinkingSphinx::Configuration.instance
    cmd = "#{config.bin_path}#{config.indexer_binary_name} --config \"#{config.config_file}\" --all"
    cmd << " --rotate" if ThinkingSphinx.sphinx_running?
    system cmd
  end
end
 
if defined?(ThinkingSphinx)
  if not ThinkingSphinx.sphinx_running? 
    conf_instance = ThinkingSphinx::Configuration.instance
    @controller = DaemonController.new(
      :identifier => 'Sphinx search server',
      :start_command => "#{conf_instance.bin_path}#{conf_instance.searchd_binary_name} --pidfile --config \"#{conf_instance.config_file}\"",
      :before_start => method(:before_start),
      :ping_command => lambda { TCPSocket.new(conf_instance.configuration.searchd.address, conf_instance.configuration.searchd.port) },
      :pid_file => conf_instance.configuration.searchd.pid_file,
      :log_file => conf_instance.configuration.searchd.log)
      @controller.start
  end
end

Written by Michał Kuklis

July 22nd, 2009 at 2:13 am

Posted in Uncategorized

Tagged with ,

The Rails Initialization Process

without comments

I found really nice description of rails initialization process here.

Written by Michał Kuklis

July 22nd, 2009 at 1:08 am

Posted in Uncategorized

Tagged with

capistrano recipes for ubuntu

without comments

Few nice capistrano recipes which may help you automate Ubuntu Server setup:

Written by Michał Kuklis

July 19th, 2009 at 8:25 pm

Posted in Uncategorized

Tagged with , ,