Skip to content

Instantly share code, notes, and snippets.

require 'hpricot'
require 'open-uri'
require 'date'
class Post
attr_accessor :author, :title, :date, :tags, :comments
def initialize url
doc = Hpricot(open(url))
@author = doc.search("//author/name").fetch(1).inner_text
sub new {
my ($class) = @_;
my @owned_files = ();
#The 'shared' files are the files that a user can read but does not own
my @shared_files = ();
my $self = {
#$[0] is the class
_name => $_[1],
import curses
from curses.ascii import isdigit
import nltk
from nltk.corpus import cmudict
d = cmudict.dict()
def nsyl(word):
return [len(list(y for y in x if isdigit(y[-1]))) for x in d[word.lower()]]
@ChimeraCoder
ChimeraCoder / .screenrc
Created June 18, 2011 14:21
Screenrc
escape \000\040
bind n focus down
bind ^n focus down
bind p focus up
bind ^p focus up
bind k next
bind ^k next
bind j prev
bind ^j prev
@ChimeraCoder
ChimeraCoder / .gitconfig
Created June 18, 2011 19:40
Git config file
[color]
diff = auto
status = auto
branch = auto
interactive = auto
ui = true
pager = true
[color "branch"]
current = yellow reverse
@ChimeraCoder
ChimeraCoder / HomoiconicJava.java
Created February 1, 2012 03:58
HJava: Imagining a (more) homoiconic Java
//HJava (HomoiconicJava): Imagining a (more) homoiconic Java
//In Java, the unit is the *class*
//So in HJava we will pretend that everything is a class (or, at least, an instance of a class).
//Obviously this won't compile in Java, because Java doesn't actually support homoiconic structures.
//But HJava does!
public class HomoiconicJava {
@ChimeraCoder
ChimeraCoder / gist:3152820
Created July 20, 2012 19:45
npm (node.js) equivalent of Python's pip freeze?
#Please tell me there is a better way to do this
#(And by 'a better way', I don't mean incorporating the cut within the awk script)
npm ls | grep -E "^(├|└)─" | cut -d" " -f2 | awk '{FS = "@"; print "\""$1"\"", ":", "\""$2"\""}'
@ChimeraCoder
ChimeraCoder / gist:3156673
Created July 21, 2012 18:28
jitsu deploy errors
bash-4.2$ jitsu deploy
info: Welcome to Nodejitsu chimeracoder
info: It worked if it ends with Nodejitsu ok
info: Executing command deploy
info: Analyzing your application dependencies in app.js
warn: Local version appears to be old
warn: Your package.json version will be incremented for you automatically
warn: About to write /Users/aditya/programming/nodejs/wasp/package.json
data:
data: {
@ChimeraCoder
ChimeraCoder / gist:3404362
Created August 20, 2012 14:01
World's first WWW server
magnet:?xt=urn:btih:30cf16d23446f98217c67b3b8840fbdb21ba1c9e&dn=WWWDaemon-0.1%5F-0.2%5F-0.3&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80
@ChimeraCoder
ChimeraCoder / gist:3645946
Created September 5, 2012 22:07
Sample Racket Docstring Pseudocode
;;Basic format; will create definition normally and ignore docstring entirely
(define-syntax autodoc (syntax-rules (define) [(_ docstr (define (name arg ...) body ...)) (define (name arg ...) body ...)])
;;Simple expanded example; will create definition and also print docstring each time function is called
(define-syntax autodoc2 (syntax-rules (define) [(_ docstr (define (name arg ...) body ...)) (define (name arg ...) (begin (print docstr) body ...))]))
;; Function definition
(autodoc "Function that increments numbers"
(define (my-incr x)