Skip to content

Instantly share code, notes, and snippets.

View leehambley's full-sized avatar

Lee Hambley leehambley

View GitHub Profile
@ralph
ralph / ruby test_test.rb
Created November 2, 2011 16:12
Ruby 1.9.3 sample test case to try out the parallel test runner
Run options:
# Running tests:
..
Finished tests in 0.000774s, 2583.9793 tests/s, 2583.9793 assertions/s.
2 tests, 2 assertions, 0 failures, 0 errors, 0 skips
@nov
nov / fb_graph_open_graph.rb
Created October 24, 2011 13:50
FbGraph OpenGraph Sample
app = FbGraph::Application.new(APP_ID)
me = FbGraph::User.me(ACCESS_TOKEN)
## Play (pre-configured for Game apps)
# Fetch activities
actions = me.og_actions "games.plays"
# Publish an activity
@paukul
paukul / query_builder_helper.rb
Created September 26, 2011 12:25
solr query sanitizer using a statemachine (like a baws!)
# the only dependencies are http://rubygems.org/gems/transitions
# and I think active support
module Search
module QueryBuilderHelper
def sanitize_field_for_solr_query(query)
if query.is_a?(Hash)
query.inject({}) do |result, query_component|
result[query_component.first] = query_component.first == '*' ? query_component.last : QueryField.sanitize(query_component.last)
result
@jasoncodes
jasoncodes / gist:1223731
Created September 17, 2011 07:45
Installing Ruby 1.9.3 with rbenv on OS X
# The latest version of this script is now available at
# https://github.com/jasoncodes/dotfiles/blob/master/aliases/rbenv.sh
VERSION=1.9.3-p286
brew update
brew install rbenv ruby-build rbenv-vars readline ctags
if [ -n "${ZSH_VERSION:-}" ]; then
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
else
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile
@aaronshaf
aaronshaf / es.sh
Created September 3, 2011 03:53
Install ElasticSearch on Ubuntu 11.04
cd ~
sudo apt-get update
sudo apt-get install unzip curl python-software-properties -y
#sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jre sun-java6-plugin -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.18.7.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
mysql> select * from obscenity;
+----------------+
| phrase |
+----------------+
| arse |
| arsehole |
| asshole |
| autopooch |
| autopooched |
| bastard |
@alkema
alkema / elasticsearch.sh
Created August 11, 2011 16:49
install elasticsearch on ubuntu
sudo apt-get install unzip
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.17.4.zip
unzip elasticsearch-0.17.4.zip
sudo apt-get install python-software-properties
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
sudo apt-get install sun-java6-jre sun-java6-plugin
sudo mv elasticsearch-0.17.4 /usr/local/share
cd elasticsearch-servicewrapper
sudo mv service /usr/local/share/elasticsearch-0.17.4/bin
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
+search(:users, "action:remove") do |rm_user|
+ user rm_user['id'] do
+ action :remove
+ end
+end
sysadmin_group = Array.new
-search(:users, 'groups:sysadmin') do |u|
+search(:users, 'groups:sysadmin NOT action:remove') do |u|
@seven1m
seven1m / templates.js.coffee.erb
Created May 24, 2011 22:24
Render ERB JS templates with Underscore.js and Sprockets and Tilt in Rails 3.1
# creates a global JST object containing all the templates
# 1. install Tilt in your Gemspec
# 2. Paste this in a file at app/assets/javascripts/templates.js.coffee.erb
# 3. `require` the templates file from your main js include file.
# 4. Put your templates at app/views/whatever/my_template.html.jst
window.JST =
<% Dir[Rails.root.join('app/views/**/*.jst')].each do |path| %>
<%= path.match(%r{/([^/]+)\.html\.jst$})[1] %>: _.template(<%= File.read(path).inspect.gsub(/\r?\n/, '') %>)
<% end %>