This file contains hidden or 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
# | |
# Executes commands at the start of an interactive session. | |
# | |
# Authors: | |
# Sorin Ionescu <[email protected]> | |
# | |
# Source Prezto. | |
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then | |
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" |
This file contains hidden or 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
#!/bin/env python | |
# -*- coding: utf-8 -*- | |
# This program is free software. It comes without any warranty, to | |
# the extent permitted by applicable law. You can redistribute it | |
# and/or modify it under the terms of the Do What The Fuck You Want | |
# To Public License, Version 2, as published by Sam Hocevar. See | |
# http://sam.zoy.org/wtfpl/COPYING for more details. | |
import asyncore |
This file contains hidden or 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
#!/bin/bash | |
menu( | |
{ | |
while [[ true ]]; do | |
echo Your Menu | |
if [[ option1 ]]; then | |
subroutine1() | |
fi | |
done |
This file contains hidden or 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
regex="[^,. ]{1,3}" | |
re.findall(regex,string) |
This file contains hidden or 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 __init__(self, filename, slice_length): | |
try: | |
self.file = open(filename, 'r') | |
self.slice_length = int(slice_length) | |
except IOError, e: | |
print "No such file:", sys.argv[1] | |
sys.exit() | |
except ValueError, e: | |
print "\"%s\" isn't a number." % sys.argv[2] | |
print "Usage: Segmentor.py <file> <slice length>" |
This file contains hidden or 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
else: | |
despereaux = Mouse(initial_cell) | |
done = False | |
visited_cells = [] | |
route = MazeRoute() | |
while (despereaux.can_travel() and | |
not despereaux.current_cell in visited_cells): | |
if despereaux.current_cell in self._cells: | |
visited_cells.append(despereaux.current_cell) | |
else: |
This file contains hidden or 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 prepare_line_list(line): | |
line_list = re.split("\s+", line) | |
# Use of re.split adds an empty element to the list | |
del line_list[len(line_list) - 1] | |
# Add empty field if we don't have a middle name | |
if len(line_list) is not 7: | |
line_list.insert(3, "") |
This file contains hidden or 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 | |
import fileinput | |
import re | |
import sys | |
def _prepare_line_list(line): | |
line_list = re.split("\s+", line) | |
# Use of re.split adds an empty element to the list | |
del line_list[len(line_list) - 1] |
This file contains hidden or 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 recurse(input_file): | |
"""Takes a file and recursively evaluates lines to get an answer.""" | |
children, value = split_line(input_file.read()) | |
# All operations we implement are binary, we should either have zero | |
# children or two. Anything else is an error. | |
if children == 0: | |
return float(value) | |
elif children == 2: | |
return operate(value, | |
recurse(input_file.read()), |
This file contains hidden or 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 evaluation(tree): | |
print tree.label | |
if len(tree.children) == 0: | |
return tree | |
else: | |
return apply_op(tree.label, evaluation(tree.children[0]), evaluation(tree.children[1])) |
OlderNewer