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
var | |
ZERGLING = 'Zergling', | |
ROACH = 'Roach', | |
HYDRALISK = 'Hydralisk', | |
BANELING = 'Baneling', | |
MARINE = 'Marine', | |
HELLION = 'Hellion', | |
MARAUDER = 'Marauder', | |
REAPER = 'Reaper', | |
TANK = 'Siege Tank', |
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/perl | |
my ($q, $n) = ("'", chr(10)); | |
my $s = '#!/usr/bin/perl%smy ($q, $n) = ("%s", chr(10));%smy $s = %s%s%s;%sprintf $s, $n, $q, $n, $q, $s, $q, $n, $n;%s'; | |
printf $s, $n, $q, $n, $q, $s, $q, $n, $n; |
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
// This work is licensed under the Creative Commons Attribution 3.0 United States License. To view | |
// a copy of this license, visit http://creativecommons.org/licenses/by/3.0/us/ or send a letter | |
// to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA. | |
// Copyright 2009 John Tantalo <john.tantalo@gmail.com> | |
(function () { | |
// get selection | |
var selection = window.getSelection ? window.getSelection() : | |
document.getSelection ? document.getSelection() : |
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
from random import random as rand | |
def reservoir1(stream): | |
i = 1 | |
choice = None | |
for value in stream: | |
if rand() * i < 1: | |
choice = value | |
i = i + 1 | |
return choice |
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
// http://aboutcode.net/2010/11/11/list-github-projects-using-javascript.html | |
jQuery.githubUser = function(username, callback) { | |
jQuery.getJSON("http://github.com/api/v1/json/" + username + "?callback=?", callback); | |
} | |
jQuery.fn.loadRepositores = function(username) { | |
this.html("<span>Querying GitHub for repositories...</span>"); | |
var target = this; |
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 perl | |
# | |
# Written by John Gruber, taken with permission from: | |
# http://daringfireball.net/2007/03/javascript_bookmarklet_builder | |
use strict; | |
use warnings; | |
use URI::Escape qw(uri_escape_utf8); | |
use open IO => ":utf8", # UTF8 by default | |
":std"; # Apply to STDIN/STDOUT/STDERR |
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/python | |
# -*- coding: utf-8 -*- | |
# (The MIT License) | |
# | |
# Copyright © 2009 John Tantalo | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy of | |
# this software and associated documentation files (the ‘Software’), to deal in | |
# the Software without restriction, including without limitation the rights to |
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/perl | |
my $url = "https://news.ycombinator.com/newcomments"; | |
sub html { | |
`curl get $url 2>/dev/null`; | |
} | |
printf "# %s", `date`; |
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
def catalan(): | |
"""Yields catalan numbers: 1 1 2 5 14 42 132...""" | |
n = 0 | |
c = 1 | |
while 1: | |
yield c | |
n = n+1 | |
c = c * 2 * (2*n-1) / (n+1) | |
# print the first ten catalan numbers |
NewerOlder