Skip to content

Instantly share code, notes, and snippets.

package org.specs2.mutable
import akka.testkit._
import akka.actor._
import akka.io.Tcp._
import scala.collection.immutable.Seq
import org.specs2._
import org.specs2.control._
import org.specs2.execute._
import org.specs2.main.ArgumentsShortcuts
package ru.nectarin.mediatron.utils.fsm
sealed class StateException(s: String) extends IllegalStateException(s)
trait Event
sealed abstract class State
sealed trait Source extends State
sealed trait Target extends State
http://www.jerf.org/iri/post/2908
http://mwotton.github.com/hs_gbu/
http://reddit.com/r/haskell/comments/y6i7d/do_we_have_real_world_examples_of_where_static/
http://reddit.com/r/haskell/comments/12e3a0/the_good_the_bad_and_the_ugly_haskell_in/
http://blog.codersbase.com/2010/09/composability-laziness-testing-and.html
https://www.fpcomplete.com/user/imalsogreg/functional-programming-elevator-pitch
http://evincarofautumn.blogspot.com/2012/07/so-i-write-compilers-for-living-now.html
http://www.reddit.com/r/haskell/comments/2gz7s1/please_point_me_at_an_eloquent_paper_or_post_on/
package utils
import java.io.InputStream
import net.jpountz.xxhash.XXHashFactory
object Hash {
private val seed = 0x9747b28c
private val xxhashFactory = XXHashFactory.fastestInstance
def xxhash(stream: InputStream): Int = {
@timothyklim
timothyklim / gist:900271
Created April 3, 2011 07:55
small expose
require 'active_support/all'
class Yeah
def initialize
@params = {"university_id" => 2, "id" => 3}
end
def method_missing(name, *args)
if name.to_s =~ /^find_([a-z]+)_id$/
find_id($1)
@timothyklim
timothyklim / gist:900292
Created April 3, 2011 08:31
application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery
def method_missing(method, *args)
if method.to_s =~ /^find_([a-z]+)_id$/
find_id($1)
elsif method.to_s =~ /^find_([a-z]+)$/
find_id($1, :search_name_only)
else
super
@timothyklim
timothyklim / oauth.rb
Created April 26, 2011 06:55
2-legged OAuth
def authorize
%w{HTTP_AUTHORIZATION X-HTTP_AUTHORIZATION X_HTTP_AUTHORIZATION}.each do |http_header|
@request = request.env[http_header] if request.env[http_header].present?
end
if @request.present?
@oauth_request = OAuth::Helper.parse_header @request
if @oauth_request["oauth_signature_method"] == "HMAC-SHA1"
require 'oauth'
URL = "http://localhost:9090/oauth/check"
CONSUMER_KEY = "c740398d919e199ff222be3f75b916e6" # App.first.consumer_key
CONSUMER_SECRET = "414e9edf0dd2f24fc78c6da47cbd2dd9" # App.first.consumer_secret
TOKEN_KEY = "4db6a2ce6f1dc173e9000002" # User.first.id
TOKEN_SECRET = "f8b3cb31ad6351af93e47f1a962f808a4e46038d" # User.first.tokens.first.secret
~/Projects/Work/parabola on master(2e2bb5d) exited 30
parabola:master! % ./parabola.rb -d "14.02.03 21:12-12.04.05"
Error: Last date less than start date
~/Projects/Work/parabola on master(2e2bb5d) exited 30
parabola:master! % ./parabola.rb -d "11.02.03 21:12-12.04.05"
2011-02-03 21:12:00 +0000
2012-04-05 23:59:59 +0000
~/Projects/Work/parabola on master(2e2bb5d)
require 'nokogiri'
require 'open-uri'
i = 0
heroes = []
descriptions = []
puts "Parsing..."
while i+=1