Skip to content

Instantly share code, notes, and snippets.

@mislav
mislav / geoip_service.rb
Created September 3, 2012 11:48
Simple GeoIP service class using freegeoip.net and Faraday
require 'faraday_middleware'
require 'hashie/mash'
# Public: GeoIP service using freegeoip.net
#
# See https://github.com/fiorix/freegeoip#readme
#
# Examples
#
# res = GeoipService.new.call '173.194.64.19'
@roidrage
roidrage / ebooks.md
Created December 2, 2011 15:15
Self-published and awesome
@madrobby
madrobby / i18n.coffee
Created November 14, 2011 15:45
Backbone i18n with CoffeeScript
# before this file is loaded, a locale should be set:
#
# In a browser environment, you can use:
# ```<script>__locale='en';</script>```
#
# In a server environment (specifically node.js):
# ```global.__locale = 'en';```
# normalize in-app locale string to "en" or "de-AT"
parts = @__locale.split('-')
@dandean
dandean / example-use.js
Created June 3, 2011 21:52
Model infrastructure for riak-js
var User = require("lib/models/user-model");
User.find("dandean", function(e, user) {
user.email = "rad@radical.com";
user.save();
});
/*
Uses http://jsonselect.org/ to select fields from a riak object
*/
function map_jsonselect(values, keydata, arg) {
var data = Riak.mapValuesJson(values)[0];
if(typeof arg == "string") {
return JSONSelect.match(arg, data);
} else if(typeof arg == "object") {
var accum = {}
@roidrage
roidrage / oauth.coffee
Created May 23, 2011 08:21
Example of using Express and node-oauth to do OAuth with Twitter
express = require "express"
sys = require "sys"
util = require "util"
oauth = require "oauth"
fs = require "fs"
app = module.exports = express.createServer()
app.configure('development', () ->
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }))
// Backbone.history with HTML5 support
(function() {
var loc = window.location,
pushSupport = !!(window.history && window.history.pushState),
hashStrip = /^#*/;
// add HTML5 support to Backbone.history, drop the old IE stuff
_.extend(Backbone.History.prototype, {
getFragment : function(l) {
@technoweenie
technoweenie / step.coffee
Created August 26, 2010 22:26
Step.js ported to coffeescript, with fewer features
# Step(
# () -> redis.select 15, @
# () -> redis.flushdb @
# () -> redis.rpush 'fakelist', '1', @
# () -> redis.rpush 'fakelist', '2', @
# () -> redis.rpush 'fakelist', '3', @
# () -> redis.lrange 'fakelist', 0, 1, @
# (err, arr) ->
# console.log arr.length
# console.log arr[0].toString()