Skip to content

Instantly share code, notes, and snippets.

View georgkreimer's full-sized avatar
☠️
Hack the planet!

Georg Kreimer georgkreimer

☠️
Hack the planet!
View GitHub Profile
@mikhailov
mikhailov / redis_usage.rb
Created January 18, 2010 06:52
Rails on Redis - is all about high performance
# app/controllers/posts_controller.rb
class PostsController < ApplicationController
def index
@posts.all_cached # Retrive only at once by every 5 minutes
expires_in 5.minutes, :private => false, :public => true
end
end
# app/models/post.rb
Class Post
@georgkreimer
georgkreimer / gist:537794
Created August 19, 2010 12:44
pretty print json in ruby
require 'json'
my_json = { :array => [1, 2, 3, { :sample => "hash"} ], :foo => "bar" }
puts JSON.pretty_generate(my_json)
Which gets you...
{
"array": [
1,
2,
3,
#!/usr/bin/env ruby
require 'ftools'
require 'fileutils'
require 'rubygems'
require 'RMagick'
include Magick
require 'open3'
def merge( files = [] )

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

@toto
toto / google_user_location.rb
Created April 22, 2011 13:14
Gets your location using the google wifi location service (also used by Firefox) using the Mac OS X CoreWLAN framework on Snow Leopard. Also compare to the CoreLocation based version https://gist.github.com/266916
require 'pp'
require 'net/http'
require 'net/https'
require 'rubygems'
require 'json'
def bssid_to_api(bssidstr)
bssidstr.gsub(':', '-').gsub(/(\-|\A)(\d)(\-|\Z)/) {|match| "#{match[0]}0#{match[1]}#{match[2]}"}
end
@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@marcel
marcel / gist:2100703
Created March 19, 2012 07:24
giftube – Generates an animated gif from a YouTube url.
#!/usr/bin/env ruby
# giftube – Generates an animated gif from a YouTube url.
#
# Usage:
#
# giftube [youtube url] [minute:second] [duration]
#
# ex.
#
@alexstubbs
alexstubbs / sphinx.rb
Created April 17, 2012 10:28
Brew formula for install sphinx 0.9.8.1 based on homebrew formula sphinx 2.0.4 git checkout 8dbb32e /usr/local/Library/Formula/sphinx.rb
require 'formula'
class Libstemmer < Formula
# upstream is constantly changing the tarball,
# so doing checksum verification here would require
# constant, rapid updates to this formula.
head 'http://snowball.tartarus.org/dist/libstemmer_c.tgz'
homepage 'http://snowball.tartarus.org/'
end
@sowawa
sowawa / sinachiku.rb
Created June 18, 2012 07:00 — forked from mattn/sinachiku.rb
sinatra on mruby
require 'HTTP'
require 'UV'
module Sinachiku
@routes = { 'GET' => [], 'POST' => [] }
def self.route(method, path, opts, &block)
@routes[method] << [path, opts, block]
end
def self.do(r)
@routes[r.method].each {|path|
user jessed staff;
worker_processes 2;
events {
worker_connections 1024;
}
http {
include mime.types;