This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Encode some arbitrary data and send it to the remote server. Object mapping will be performed on the results | |
- (RKObjectLoader *)sendData:(id)data toResourcePath:(NSString *)resourcePath usingBlock:(void (^)(RKObjectLoader *objectLoader))block { | |
RKObjectLoader* loader = [self objectLoaderWithResourcePath:resourcePath delegate:nil]; | |
id<RKParser> parser = [[RKParserRegistry sharedRegistry] parserForMIMEType:self.serializationMIMEType]; | |
NSString* string = [parser stringFromObject:serializedObject error:error]; | |
NSData* data = [string dataUsingEncoding:NSUTF8StringEncoding]; | |
loader.params = [RKRequestSerialization serializationWithData:data MIMEType:self.serializationMIMEType]; | |
loader.method = RKRequestMethodPOST; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in 19 20 21 22 23 24 25 26; do wget "http://pragprog.com/magazines/download/$i.mobi"; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install: --no-rdoc --no-ri | |
update: --no-rdoc --no-ri |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#require "rubygems" | |
require 'socket' | |
# Count the occurrence of an IP address in a given list of | |
# IP addresses and resolve it to its hostname. | |
# | |
# (c)2011 Florin T.PATRASCU | |
Socket.do_not_reverse_lookup = false | |
ip_addresses = Array.new DATA.read.split |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// (c) 2011 Thomas Fuchs | |
(function($){ | |
$.fn.delayedHover = function(){ | |
var timeout = null, hovering = false, element = this; | |
function enter(){ | |
element.trigger('delayed_hover:enter'); | |
timeout = null; | |
hovering = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#=require haml | |
#=require backbone | |
class PageView extends Backbone.View | |
tag: "div" | |
class: "page" | |
classes: -> | |
[] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config.ru for solr reverse_proxy | |
# test me with $ rackup solrrp.ru | |
# or just do most of this in you web sever config | |
require 'server' | |
require 'rack/reverse_proxy' | |
require 'my_custom_logger' | |
# catch and log requests | |
use MyCustomLogger # some code you wrote that logs info about results on the /search* endpoint |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'yaml' | |
require 'logger' | |
require 'active_record' | |
namespace :db do | |
def create_database config | |
options = {:charset => 'utf8', :collation => 'utf8_unicode_ci'} | |
create_db = lambda do |config| | |
ActiveRecord::Base.establish_connection config.merge('database' => nil) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Include an anonymous module | |
# | |
# Useful for defining a class with a base module. So, instead of: | |
# | |
# class Foo | |
# module Base | |
# def bar | |
# # ... | |
# end | |
# end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sinatra/base' | |
class Hello < Sinatra::Base | |
get '/' do | |
"hello world" | |
end | |
end |