Skip to content

Instantly share code, notes, and snippets.

View florinpatrascu's full-sized avatar
💜
Alchemy

Ŧl๏гเภ florinpatrascu

💜
Alchemy
  • Toronto, CANADA
View GitHub Profile
@blakewatters
blakewatters / gist:1368819
Created November 16, 2011 00:00
sendData:toResourcePath:usingBlock
// 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;
@kevinold
kevinold / pragprog_magazines.sh
Created August 19, 2011 17:01
Quickly download all Pragprog magazines for this year
for i in 19 20 21 22 23 24 25 26; do wget "http://pragprog.com/magazines/download/$i.mobi"; done
install: --no-rdoc --no-ri
update: --no-rdoc --no-ri
@florinpatrascu
florinpatrascu / count_ips.rb
Created July 6, 2011 23:17
Count the occurrence of an IP address in a given list of IP addresses and resolve it to its hostname.
#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
@madrobby
madrobby / delayed_hover.js
Created July 5, 2011 19:45
Little Zepto "delayed hover" plugin, using this with backbone.js events
// (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;
@bradphelan
bradphelan / pageview.js.coffee
Created June 15, 2011 13:46
backbone based mobile page model
#=require haml
#=require backbone
class PageView extends Backbone.View
tag: "div"
class: "page"
classes: ->
[]
@omnifroodle
omnifroodle / solrrp.ru
Created May 25, 2011 22:28
Rackup file for limiting access to a reverse proxied solr instance (thinking ajax)
# 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
@wbailey
wbailey / databases.rake
Created February 11, 2011 08:58
ActiveRecord migrations outside of Rails
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)
# Include an anonymous module
#
# Useful for defining a class with a base module. So, instead of:
#
# class Foo
# module Base
# def bar
# # ...
# end
# end
@dominictarr
dominictarr / hello_sinatra.rb
Created September 9, 2010 14:20
get started testing sinatra with capybara
require 'rubygems'
require 'sinatra/base'
class Hello < Sinatra::Base
get '/' do
"hello world"
end
end