Skip to content

Instantly share code, notes, and snippets.

@BenHall
BenHall / .gitignore
Created April 25, 2010 17:52
.gitignore
_ReSharper*
bin
obj
*.user
*.suo
*.cache
echo 'abc db.test(me) someting' | sed 's/.*\(db.test(.*)\).*/\1/g'
@BenHall
BenHall / Meta.rb
Created June 1, 2010 13:02
Ruby - Method with spaces
class Test
def x()
puts 'x'
end
define_method("this is a method") do |y|
puts 'called with >> ' + y.to_s
end
alias :msg :send
@BenHall
BenHall / Require_all_libs.rb
Created June 1, 2010 22:17
Ruby: Require all files in a directory
$: << 'lib'
Dir.glob(File.dirname(__FILE__) + '/lib/*') {|file| require file}
@BenHall
BenHall / Blocks.rb
Created June 9, 2010 23:50
Passing variables between blocks without parameters
def x(&block)
$t = 'TEST'
block.call
end
def y(v)
puts "Value passed in was #{v}"
end
x { y($t) } #=> Value passed in was TEST
@BenHall
BenHall / -e_IronRuby.rb
Created June 10, 2010 16:18
-e to replace contents of a file using cmd - IronRuby
config_file = 'app.config'
dns = 'ec2-127.0.0.1.amazon.com'
command = "require \'mscorlib\'; " +
"contents = System::IO::File.read_all_text(\'#{ config_file }\');" +
"contents = contents.replace(\'$(MACHINE_DNS)\', \'#{dns}\'); " +
"System::IO::File.write_all_text(\'#{ config_file }\', contents)"
ironruby_cmd = "C:\\TeamCityBuildTools\\ironruby\\1.0\\bin\\ir.exe -d -e \"#{command}\""
@BenHall
BenHall / CastleDictionaryAdapterExample.cs
Created July 22, 2010 21:20
Castle Dictionary Adapter Example
using System;
using System.Configuration;
using Castle.Components.DictionaryAdapter;
using Castle.MicroKernel.Registration;
using Castle.Windsor;
using Rhino.Mocks;
namespace CastleDictionaryAdapterExample
{
class Program
@BenHall
BenHall / DolphinDeploy_Rake_Example.rb
Created July 25, 2010 22:30
MeerPush \ DolphinDeploy Example
require 'meerpush'
task :deploy => [:delete, :create, :start]
desc "Delete Website"
delete_site :delete do |w|
w.name = 'Meerpush_Website'
end
desc "Create Website"
class Environment < some_class
end
extend Environment::DSL
{"size":1,"position":2,"status":"1.0","search_engine":"http://www.google.com/search?q=","theme":"GleeThemeDefault","bookmark_search":0,"scroll_animation":1,"tab_shortcut_status":1,"esp_status":1,"shortcut_key":"71.0","tab_shortcut_key":"190.0","hyper":"0.0","version":"1.6.2","disabledUrls":["mail.google.com","wave.google.com","mail.yahoo.com"],"scrapers":[],"espModifiers":[{"url":"google.com/search","selector":"h3:not(ol.nobr>li>h3),a:contains(Next)"},{"url":"bing.com/search","selector":"div.sb_tlst"},{"url":"github.com","selector":".message>a:not(a:contains(Compare)),a:contains(issue),code>a,a:contains(News Feed):not(.selected):not(.feed),a:contains(Your Actions):not(.selected),div.message>pre>a,a.issue_title,span:contains(started) + a,span:contains(created) + a"},{"url":"google.co.uk/search","selector":"h3:not(ol.nobr>li>h3),a:contains(Next)"}]}