Skip to content

Instantly share code, notes, and snippets.

(*This folder action script is designed to keep your downloads folder organised *)
property image_extension_list : {"tif", "tiff", "gif", "png", "pict", "pct", "jpg"}
property media_extension_list : {"mp3", "avi", "mov", "mpg"}
property document_extension_list : {"doc", "pdf", "ps", "mpg"}
property archive_extension_list : {"zip", "sit", "dmg", "tar", "hqx", "toast", "rar"}
property torrent_extension_list : {"torrent"}
property image_foldername : "images"
@tanob
tanob / rlsp.rb
Created November 12, 2009 01:46 — forked from h0rs3r4dish/rlsp.rb
#!/usr/bin/ruby
RLSP_VERSION = "1.4.2"
class Lambda
attr_accessor :args, :body
def initialize(args=[],body="")
@args = (args.class == Array) ? args : [args]
@body = body
end
adriano@planck:~/Projects/pubsub_test1$ python pubsub_test1.py
DEBUG Loaded Plugin (XEP-0060) Publish-Subscribe
WARNING Deprecated add_handler used for <message><x xmlns='jabber:x:data' /></message>: <bound method xep_0004.handler_message_xform of <sleekxmpp.plugins.xep_0004.xep_0004 object at 0x1007ca310>>.
DEBUG Loaded Plugin (XEP-0004) Data Forms
WARNING Deprecated add_handler used for <iq type='get' xmlns='jabber:client'><query xmlns='http://jabber.org/protocol/disco#info' /></iq>: <bound method xep_0030.info_handler of <sleekxmpp.plugins.xep_0030.xep_0030 object at 0x1007ca510>>.
WARNING Deprecated add_handler used for <iq type='get' xmlns='jabber:client'><query xmlns='http://jabber.org/protocol/disco#items' /></iq>: <bound method xep_0030.item_handler of <sleekxmpp.plugins.xep_0030.xep_0030 object at 0x1007ca510>>.
DEBUG Loaded Plugin (XEP-0030) Service Discovery
DEBUG Did not supply (address, port) to connect to and no SRV support is installed (http://www.dnspython.org). Continuing to
def cached_result opts
puts opts
end
cached_result :for => 'bleh', :or => do 1+2 end
# Problem when executing:
#t.rb:5: syntax error, unexpected keyword_do_block
#cached_result :for => 'bleh', :or => do 1+2 end
# ^
@tanob
tanob / happy.hs
Created August 13, 2010 05:44
Determines if a number is happy
import Data.Char;h 1 _=1;h x m|any(==x)m=0;h x m=h(sum$map((^2).digitToInt)$show x)(x:m);main=print$h 7 []
@tanob
tanob / fizzbuzz.hs
Created November 27, 2010 18:35
Prints the first 100 fizzbuzz numbers, implemented in Haskell.
fizz n = n `mod` 3 == 0
buzz n = n `mod` 5 == 0
fizzbuzzFor n | fizz n && buzz n = "fizzbuzz"
| fizz n = "fizz"
| buzz n = "buzz"
| otherwise = show n
main = mapM_ (putStrLn . fizzbuzzFor) [1..100]
@tanob
tanob / gist:945821
Created April 28, 2011 04:46
AppleScript to open a new tab in iTerm2 from Finder
-- Stefan van den Oord, 2010-12-29
-- The "cd to" command for iTerm2
-- Original from: http://code.google.com/p/iterm2/wiki/AppleScript
-- Modified to open a new tab instead of a new window
tell application "Finder"
set _cwd to POSIX path of ((folder of (front window)) as alias)
end tell
tell application "iTerm"
@tanob
tanob / Error when running mirahc
Created August 5, 2011 02:31
Trying to write a macro
Parsing...
macro.mirah
Inferring types...
Inference Error:
Could not infer typing for nodes:
FunctionalCall(find_class)
Call(parent)
Field(call) at line 14 (child of LocalAssignment(name = class_node, scope = MethodDefinition(_expand), captured = false))
macro.mirah:12: Could not infer typing for nodes:
FunctionalCall(find_class)
-- Make: ghc --make groups.hs
-- Run: echo -e "[4,3,3,2]\n[5,3,2,1,1,3,5]\n[4,5]" | ./groups
import System.IO
import Data.List
isSameSolution f (s1,s2) = f == (s2,s1)
discardDuplicated = nubBy isSameSolution
uniqueSubsequences = filter ((/=0).length) . nub . subsequences
solutionsFor list = discardDuplicated solutions
@tanob
tanob / parser.rb
Created January 2, 2014 14:05
Uso: $ ../INPUTS/parser.rb ../INPUTS/TS_ESCOLA.map < TS_ESCOLA.TXT > indicadores_por_escola.csv
#!/usr/bin/env ruby
input_map = IO.readlines(ARGV[0]).inject({}) do |memo, line|
field_name, fstart, fend = line.match(/(\S+)\s+([0-9]+)-([0-9]+)/).captures
range = Range.new(fstart.to_i, fend.to_i)
memo.merge({field_name => range})
end
class Parser
attr_accessor :line