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
(defn add [a b] (+ a b)) | |
(def addTwo (partial add 2)) | |
(addTwo 5) | |
(map addTwo [1 2 3]) |
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
# Pattern matching DSL ideas | |
class Object | |
def method_missing method_name, *args, &block | |
if method_name.to_s == "_" | |
:default | |
else | |
super | |
end | |
end |
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
language: ruby | |
rvm: | |
- 1.9.3 | |
env: | |
- DB=sqlite | |
- DB=mysql | |
- DB=postgresql | |
script: | |
- RAILS_ENV=test bundle exec rake --trace db:migrate test | |
before_script: |
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/python3 | |
import socket, sys, threading | |
# Simple chat client that allows multiple connections via threads | |
PORT = 9876 # the port number to run our server on | |
__version__ = "0.0.1" | |
class ChatServer(threading.Thread): |
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 urllib2, urlparse | |
# Check a text file of urls to make sure they return a status 200 | |
class StatusChecker(object): | |
""" Check the status codes of multiple URLS """ | |
def __init__(self, url_file="urls.txt"): | |
self.url_file = url_file |
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 | |
def method_missing(meth, *args, &block) | |
if meth.to_s =~ /^run_(.+)$/ | |
system 'clear' | |
system "rake test:#{$1}" | |
else | |
super | |
end | |
end |
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/python3 | |
from urllib.request import * | |
import re | |
import shutil | |
import os | |
# Will look through all available databases and list them | |
# Can also pull down the database into your current directory if required |
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 shutil | |
import os | |
import sys | |
# Simple file zipper for concatenation of various files | |
class Zipper: | |
def __init__(self, path, *args, **kwargs): | |
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 Multimethod | |
attr_accessor :dispatch, :methods, :heirarchy, :default_method | |
class NoMatchingMethodError < StandardError | |
end | |
def initialize(&dispatch) | |
@dispatch = dispatch | |
@methods = [] | |
@heirarchy = {} | |
end |
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
type comparison = Less | Equal | Greater | |
module type ORDERED_TYPE = | |
sig | |
type t | |
val compare: t -> t -> comparison | |
end;; | |
module type ORDERED_TYPE = sig type t val compare : t -> t -> comparison end |