This file contains 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
-- Stochatistic Gradient Descent in Haskell | |
-- | |
-- Based on Mark Reid's implementation in Clojure: | |
-- | |
-- http://github.com/mreid/injuce | |
-- | |
-- | |
-- Profiling | |
-- --------- | |
-- |
This file contains 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 "nokogiri" | |
require "uri" | |
module Rack | |
class KarmaChameleon | |
def initialize(app, options = {}) | |
@ext = options[:extension] || "aspx" | |
@ext_regexp = /\.#@ext$/ | |
@app = app |
This file contains 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 each Ruby module/class, we have Ruby methods on the left and the equivalent | |
Clojure functions and/or relevant notes are on the right. | |
For clojure functions, symbols indicate existing method definitions, in the | |
clojure namespace if none is explicitly given. clojure.contrib.*/* functions can | |
be obtained from http://github.com/kevinoneill/clojure-contrib/tree/master, | |
ruby-to-clojure.*/* functions can be obtained from the source files in this | |
gist. | |
If no method symbol is given, we use the following notation: |
This file contains 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
# 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 |
This file contains 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
class GetEventResult | |
@queue = :events | |
def self.perform(event_id, attempt=0) | |
event = Event.find(event_id) | |
Rails.logger.info "Fetching results for event ##{event.id} (#{event.name})..." | |
begin | |
results = EventImporter.new(event.datetime.to_date).get_results(event) | |
rescue OpenURI::HTTPError |
This file contains 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
#!/usr/bin/env ruby | |
# *** Important notification *** | |
# As xAuth is officially supported, we have to register | |
# your application needing xAuth, via e-mail. | |
# If not registered, 401 error will be returned. | |
# http://apiwiki.twitter.com/Twitter-REST-API-Method:-oauth-access_token-for-xAuth | |
# | |
# (*** 重要な告知 *** | |
# xAuthが公式にサポートされたのに伴い、xAuthの必要なアプリケーションは |
This file contains 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
# Author: Pieter Noordhuis | |
# Description: Simple demo to showcase Redis PubSub with EventMachine | |
# | |
# Requirements: | |
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby | |
# - a browser with WebSocket support | |
# | |
# Usage: | |
# ruby redis_pubsub_demo.rb | |
# |
This file contains 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
import re | |
# http://atomboy.isa-geek.com/plone/Members/acoil/programing/double-metaphone | |
from metaphone import dm as double_metaphone | |
# get the Redis connection | |
from jellybean.core import redis | |
import models | |
# Words which should not be indexed |
This file contains 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
var child_process = require('child_process'), | |
sys = require('sys'), | |
net = require('net'), | |
netBinding = process.binding('net'); | |
var fd = netBinding.socket('tcp4'); | |
netBinding.bind(fd, 8080); | |
netBinding.listen(fd, 128); | |
for (var i = 0; i < 4; i++) { |
This file contains 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
#!/usr/local/bin/node | |
var sys = require('sys'), | |
http = require('http'), | |
querystring = require('querystring'), | |
base64 = require('./lib/base64'), | |
Buffer = require('buffer').Buffer, | |
Irc = require('./vendor/IRC/lib/irc'); | |
var twitter_auth = { user: "<YOUR_TWITTER_USERNAME>", pass: "<YOUR_TWITTER_PASSWORD>"}; |
OlderNewer