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
@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
@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|
@halfbyte
halfbyte / lednet.cpp
Created November 29, 2013 22:43
Arduino experiment to drive some DIODER from IKEA via OSC by using an Arduino and a small ruby script.
#include <SPI.h>
#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet.h>
#include <EthernetClient.h>
#include <EthernetServer.h>
#include <EthernetUdp.h>
#include <util.h>
// color swirl! connect an RGB LED to the PWM pins as indicated
@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
user jessed staff;
worker_processes 2;
events {
worker_connections 1024;
}
http {
include mime.types;
#!/usr/bin/env ruby
require 'ftools'
require 'fileutils'
require 'rubygems'
require 'RMagick'
include Magick
require 'open3'
def merge( files = [] )
@dnegstad
dnegstad / Brocfile.js
Last active January 2, 2019 17:50
Polymer WebComponents in ember-cli >= 0.0.41
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var pickFiles = require('broccoli-static-compiler');
var mergeTrees = require('broccoli-merge-trees');
var vulcanize = require('broccoli-vulcanize');
var app = new EmberApp();
var polymerVulcanize = vulcanize('app', {
input: 'elements.html',
output: 'assets/vulcanized.html',
@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.
#
@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,