Skip to content

Instantly share code, notes, and snippets.

View endofunky's full-sized avatar
☎️
NO CARRIER

ef. endofunky

☎️
NO CARRIER
View GitHub Profile
@jodosha
jodosha / bench_results.txt
Created February 6, 2009 21:58
Lightweight implementation of ActiveSupport::Callbacks (no backward compatibilities)
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
test | old | new | boost
SymbolCallbackPerson | 0.418285131454468 | 0.198039770126343 | 2.11x
ProcCallbackPerson | 0.478709936141968 | 0.309146881103516 | 1.55x
MethodCallbackPerson | 0.298830032348633 | 0.114556074142456 | 2.60x
StringCallbackPerson | 0.782155990600586 | 0.653557062149048 | 1.97x
ObjectCallbackPerson | 0.49412202835083 | 0.30273699760437 | 1.63x
ConditionalPerson | 5.81794190406799 | 5.45951700210571 | 1.07x
;;; toggle-scala.el --- Toggle between test and implementation files.
;; Author: MIZUNO Hiroki<mzp.ppp_at_gmail.com>
;; Keywords: tools
;;; Usage:
;; Insert into your .emacs file the following line, (and eval it for
;; immediate usage:
;;
;; (require 'toggle-scala)
@fmela
fmela / stacktrace.cxx
Last active September 22, 2023 10:58
A C++ function that produces a stack backtrace with demangled function & method names.
/*
* Copyright (c) 2009-2017, Farooq Mela
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
@msimpson
msimpson / cfire
Created July 21, 2011 10:51
Curses based ASCII art fire animation.
#!/usr/bin/python
import curses, random
screen = curses.initscr()
width = screen.getmaxyx()[1]
height = screen.getmaxyx()[0]
size = width*height
char = [" ", ".", ":", "^", "*", "x", "s", "S", "#", "$"]
b = []
@mike-burns
mike-burns / io.rb
Created November 29, 2011 01:55
The IO data type, functor, and monad ... in Ruby
class InputOutput
def initialize(&action)
@action = action
end
private_class_method :new
# return :: (Monad m) => a -> m a
def self.unit(x)
new { x }
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.

@pithyless
pithyless / either.rb
Created March 27, 2012 14:44
Chaining Either for Ruby
# A chainable Either monad for Ruby
#
# Examples
#
# Either.right('s') >> proc { |s| Either.right(s + '-1') } >> proc { |s| Either.right(s + '-2') }
# #=> #<Either @left=nil, @right="s-1-2">
#
# Either.right('s') >> proc { |s| Either.left('error!') } >> proc { |s| Either.right(s + '-2') }
# #=> #<Either @left='error!', @right=nil>
#
@stonegao
stonegao / AkkaKafkaMailboxTest.scala
Created May 1, 2012 07:24 — forked from mardambey/AkkaKafkaMailboxTest.scala
Akka 2.0 actors with Kafka backed durable mailboxes.
import akka.actor.Actor
import akka.actor.ActorSystem
import akka.agent.Agent
import com.typesafe.config.ConfigFactory
import akka.event.Logging
import akka.actor.Props
import kafka.utils.Utils
import java.nio.ByteBuffer
@nono
nono / blowfish.rb
Created June 26, 2012 10:57
How to encrypt and decrypt Blowfish in Ruby 1.9 with https://github.com/drench/blowfish.js
#!/usr/bin/env ruby
require "openssl"
class BF < Struct.new(:key, :pad_with_spaces)
def encrypt(str)
cipher = OpenSSL::Cipher.new('bf-ecb').encrypt
if pad_with_spaces
str += " " until str.bytesize % 8 == 0
cipher.padding = 0
@metamorph
metamorph / gist:5003153
Created February 21, 2013 08:21
Tiny embryo for an IRC bot using Akka I/O
import akka.actor.ActorSystem
import akka.io.IO
import akka.io._
object Boot extends App {
import akka.io.Tcp._
implicit val sys = ActorSystem("io")
import akka.actor.{Actor, Props, ActorRef}