Skip to content

Instantly share code, notes, and snippets.

@uncreative
uncreative / OpenInEclipse.applescript
Created July 22, 2011 19:23
externally open a specific file in eclipse, and go to some line
(*
-------- WHAT THIS DOES --------
Enables you to externally open a specific file in eclipse, and go to some line
that is, makes a link with href of
openineclipse://open?url=file:///absolute/path/tofile.ext&line=5
open absolute/path/tofile.ext in eclipse
and go to line 5
@kmiyashiro
kmiyashiro / layout2.jade
Created August 11, 2011 18:50 — forked from monokrome/layout2.jade
HTML5 Boilerplate Conditional comments in Jade
!!! 5
//if lt IE 7
html(class="no-js ie6 oldie", lang="en")
//if IE 7
html(class="no-js ie7 oldie", lang="en")
//if IE 8
html(class="no-js ie8 oldie", lang="en")
// [if gt IE 8] <!
html(class="no-js", lang="en")
// <![endif]
@cowboy
cowboy / yield.rb
Created August 17, 2011 19:24
An example using "yield self if block_given?"
# No yielding
class NormPerson
attr_accessor :first, :last
def initialize(first = nil, last = nil)
@first = first
@last = last
end
def hello
puts "#{@first} #{@last} says hello!"
@listochkin
listochkin / gist:1200393
Created September 7, 2011 12:02
Algorithm for Area of a closed polygon.
@longlostnick
longlostnick / gist:1251339
Created September 29, 2011 17:24
Delete all empty/false elements from hash recursively
# (v.respond_to?(:empty?) ? v.empty? : !v) is basically rails' .blank? in plain ruby
class Hash
def delete_blank
delete_if do |k, v|
(v.respond_to?(:empty?) ? v.empty? : !v) or v.instance_of?(Hash) && v.delete_blank.empty?
end
end
end
@ryanlecompte
ryanlecompte / gist:1283413
Created October 13, 2011 04:50
Providing an ActiveRecord-like before_filter capability to arbitrary Ruby classes
# First the end result of what we want:
class Foo
before_hook :whoa
before_hook :amazing
def test
puts "This is kinda cool!"
end
@douglas
douglas / update_git_repos.sh
Created October 14, 2011 15:04
Update all git repositories under a base directory
#!/bin/bash
# store the current dir
CUR_DIR=$(pwd)
# Let the person running the script know what's going on.
echo "\n\033[1mPulling in latest changes for all repositories...\033[0m\n"
# Find all git repositories and update it to the master latest revision
for i in $(find . -name ".git" | cut -c 3-); do
@mkempe
mkempe / einbeinige.rb
Created October 19, 2011 16:33
Using ActiveRecord / Nokogiri for xml → database convert action
# encoding: utf-8
require 'active_record'
require 'mysql2'
require 'nokogiri'
require 'yaml'
ROOT = File.join(File.dirname(__FILE__), '..')
# ActiveRecord::Base.logger = Logger.new('log/debug.log')
@renyi
renyi / utils.py
Created October 20, 2011 04:11
My common python string utils
import array
def ilist_to_str(list):
'''Integer list to string.'''
return array.array('B', list).tostring()
def str_to_ilist(string):
'''String to integer list'''
return array.array('b', string).tolist()
@aziz781
aziz781 / gist:1336506
Created November 3, 2011 13:43
Spring JMS sample configuration applicationContext-jms.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:amq="http://activemq.apache.org/schema/core"