Skip to content

Instantly share code, notes, and snippets.

View leehambley's full-sized avatar

Lee Hambley leehambley

View GitHub Profile
@mejibyte
mejibyte / gist:791105
Created January 22, 2011 12:56
Test Omniauth Callback Controllers in Devise
# encoding: utf-8
require 'test_helper'
class Users::OmniauthCallbacksControllerTest < ActionController::TestCase
context "Facebook callback" do
setup do
# This a Devise specific thing for functional tests. See https://github.com/plataformatec/devise/issues/closed#issue/608
request.env["devise.mapping"] = Devise.mappings[:user]
end
@patricksrobertson
patricksrobertson / cupid_button.sass
Created February 10, 2011 19:20
Sassifies the cupid-button done by GIANT ROBOTS. This is really a .scss . Github doesn't recognize it.
//Mixin that allows someone to define Cupid buttons outside of the green colors.
// $main-color: Primary button color.
// $btn-gradient: lighter color to blend with the main color.
// $bottom-border: Darker color for the bottom part of the button.
// $box-shadow: Color for the shadow.
// $text-shadow: Color for the text shadow.
// $text-color: Main color for the text.
@mixin cupid-button($main-color: #7fbf4d, $btn-gradient: #63a62f,
$bottom-border: #5b992b, $box-shadow: #96ca6d, $text-shadow: #4c9021,$text-color: #fff ) {
background: $main-color;
@koshigoe
koshigoe / mount-ram.sh
Created February 11, 2011 14:57
Like tmpfs in Mac OSX
#!/bin/sh
# This program has two feature.
#
# 1. Create a disk image on RAM.
# 2. Mount that disk image.
#
# Usage:
# $0 <dir> <size>
#
@grantr
grantr / searchable_model.rb
Created April 25, 2011 22:08
ActiveModel module for elasticsearch indexing
# class Person
# include SearchableModel
# include SearchableModel::SearchMethods
#
# ...
#
# end
module SearchableModel
@karmi
karmi / elastic_search_ngram_analyzer_for_urls.sh
Created May 24, 2011 15:32
NGram Analyzer in ElasticSearch
# ========================================
# Testing n-gram analysis in ElasticSearch
# ========================================
curl -X DELETE localhost:9200/ngram_test
curl -X PUT localhost:9200/ngram_test -d '
{
"settings" : {
"index" : {
"analysis" : {
@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 %>
+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|
/* 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%;
@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
mysql> select * from obscenity;
+----------------+
| phrase |
+----------------+
| arse |
| arsehole |
| asshole |
| autopooch |
| autopooched |
| bastard |