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
pyg = 'ay' | |
original = raw_input('Enter a word:') | |
if len(original) > 0 and original.isalpha(): | |
word = original.lower() | |
first = word[0] | |
if first == "a" or "e" or "i" or "o" or "u": | |
print "vowel" | |
else: |
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 Data.List | |
import Data.Tree | |
combinationsTree xs = unfoldTree next ([], xs) | |
where next (path, xs) = (path, map (appendTo path . splitAt 1) $ init $ tails xs) | |
appendTo path (x, ys) = (path ++ x, ys) | |
depth 0 node = Node{rootLabel=(rootLabel node), subForest=[]} | |
depth n node = node{subForest=(map (depth (n - 1)) (subForest node))} |
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 sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |
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
jQuery.cleanData = _.wrap jQuery.cleanData, (cleanData, elems) -> | |
for elem in elems | |
$(elem).data('view')?.dispose() | |
cleanData.apply @, arguments |
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 sys import argv, exit | |
from random import choice | |
from string import ascii_letters, digits | |
if len(argv) < 2: | |
print "usage: %s length [quantity]" % (argv[0]) | |
exit(1) | |
length, quantity = int(argv[1]), 1 | |
if len(argv) == 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
from sys import argv, exit | |
types = { | |
'simple': lambda capital, rate, time: capital * (1 + (rate * time)), | |
'compound': lambda capital, rate, time: capital * ((1 + rate) ** time) | |
} | |
if len(argv) != 5 or argv[1] not in types: | |
print "usage: %s <%s> capital rate time" % (argv[0], '|'.join(types)) | |
exit(1) |
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 python | |
lower, upper = 1, 100 | |
print "Guess a number between %s and %s (inclusive)." % (lower, upper) | |
while lower < upper: | |
mid = (lower + upper) / 2 | |
guess = raw_input("Is your number higher than %s? (y/n): " % (mid)) | |
if guess == 'y': |
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 python | |
from string import printable, maketrans | |
from random import seed, shuffle | |
def cipher_alphabet(key): | |
alphabet = [c for c in printable] | |
seed(hash(key)) | |
shuffle(alphabet) | |
return ''.join(alphabet) |
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
caesar_encode = caesar_decode = lambda m: m.encode('rot13') |
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 python | |
from urllib import urlopen | |
word_list = urlopen('http://pastebin.com/raw.php?i=jSD873gL').read().split() | |
scrambled_words = ['mkeart', 'sleewa', 'edcudls', 'iragoge', 'usrlsle', | |
'nalraoci', 'nsdeuto', 'amrhat', 'inknsy', 'iferkna'] | |
for scrambled in sorted(scrambled_words, key=len): | |
matches = [word for word in word_list if sorted(scrambled) == sorted(word)] |
NewerOlder