Skip to content

Instantly share code, notes, and snippets.

View ezodude's full-sized avatar
🦙
Orchestrating agent workflows!

Ezo Saleh ezodude

🦙
Orchestrating agent workflows!
View GitHub Profile
# Hook our MongoMapper model into Solr
module MongoAdapter
class InstanceAdapter < Sunspot::Adapters::InstanceAdapter
def id
@instance.id
end
end
class DataAccessor < Sunspot::Adapters::DataAccessor
def load(id)
class Product
include MongoMapper::Document
include MongoMapper::Sunspot
belongs_to :crawl
many :inventories
key :product_no, Integer
key :price_in_cents, Integer
# gem install sunspot_rails
class Foo
include MongoMapper::Document
include Sunspot::Rails::Searchable
key :title, String
searchable do
text :title
end
@ezodude
ezodude / example vhost
Created October 15, 2010 05:54
nginx vhost example
server {
access_log /opt/nginx/logs/test_server.access.log main buffer=32k;
error_log /opt/nginx/logs/test_server.error.log info;
expires 6h;
listen 2300 default rcvbuf=64k backlog=128;
root /opt/apps/test_server/current/public;
server_name test_server.com www.test_server.com;
passenger_enabled on;
}
@ezodude
ezodude / basic monitrc
Created October 15, 2010 06:00
basic monitrc
set daemon 60
set logfile syslog facility log_daemon
set mailserver localhost
set mail-format { from: monit@example.comm }
set alert root@localhost
set httpd port 2812 and
allow admin:test
include /etc/monit.d/*
@njh
njh / bbc_episodes_for_brand.rb
Created May 3, 2011 15:47
Ruby code to get all the episode PIDs for a BBC Brand
#!/usr/bin/env ruby
require 'rubygems'
require 'rdf'
require 'rdf/rdfxml'
PROGRAMMES_URL = 'http://www.bbc.co.uk/programmes'
PO = RDF::Vocabulary.new("http://purl.org/ontology/po/")
brand_pid = 'b0081dq5'
@retr0h
retr0h / gist:1001477
Created May 31, 2011 23:14
RVM + HomeBrew + Nokogiri
BREW_HOME=$HOME/.homebrew
$ brew install libxml2
$ brew link libxml2
$ brew install https://github.com/adamv/homebrew-alt/raw/master/duplicates/libxslt.rb
$ brew link libxslt
$ brew install libiconv
$ brew link libiconv
$ gem install nokogiri -- --with-xml2-dir=$BREW_HOME/Cellar/libxml2/2.7.8 --with-xslt-dir=$BREW_HOME/Cellar/libxslt/1.1.26 --with-iconv-dir=$BREW_HOME/Cellar/libiconv/1.13.1/
@tlync
tlync / jquery-doubletap.js
Created June 9, 2011 03:45
jquery double tap plugin - Bind an event handler to the "double tap" JavaScript event.
(function($){
var hasTouch = /android|iphone|ipad/i.test(navigator.userAgent.toLowerCase()),
eventName = hasTouch ? 'touchend' : 'click';
/**
* Bind an event handler to the "double tap" JavaScript event.
* @param {function} doubleTapHandler
* @param {number} [delay=300]
*/
@jasonwyatt
jasonwyatt / MySingleton.js
Created July 26, 2011 15:09
Singleton Pattern with Require JS
define(function(){
var instance = null;
function MySingleton(){
if(instance !== null){
throw new Error("Cannot instantiate more than one MySingleton, use MySingleton.getInstance()");
}
this.initialize();
}
@dhoerl
dhoerl / KeychainItemWrapper.h
Last active April 4, 2023 08:15
KeychainItemWrapper ARCified. Added the ability to manage a dictionary in place of just a string - the #define PASSWORD_USES_DATA in the .m file switches the mode.
/*
File: KeychainItemWrapper.h
Abstract:
Objective-C wrapper for accessing a single keychain item.
Version: 1.2 - ARCified
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of