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
''' inspired by http://journal.stuffwithstuff.com/2013/12/08/babys-first-garbage-collector/ ''' | |
INITIAL_GC_THRESHOLD = 8 | |
STACK_MAX = 256 | |
class PLObj(object): | |
def __init__(self): | |
self.marked = False | |
self.next = None | |
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
import random | |
neighborhood = 2 # cells on both sides | |
happy = 2 # at least this many cells are same | |
empty = .1 | |
red = .45 | |
blue = .45 | |
numcells = 80 |
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
import datetime | |
import operator | |
from dateutil.relativedelta import relativedelta # do a 'pip install python-dateutil' for this |
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
## approach 1 | |
def myfun(a, b, mode='<'): | |
valid_modes = ['<', '<=', '>', '>=', '==', '!='] | |
if mode not in valid_modes: | |
print 'Error!' | |
... # error handling code here | |
return | |
if mode == '<': | |
if a < b: |
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
<?xml version="1.0" encoding="utf-8"?> | |
<!-- Created by Leo (http://leoeditor.com/leo_toc.html) --> | |
<?xml-stylesheet ekr_test?> | |
<leo_file xmlns:leo="http://www.leo-editor.org/2011/leo" > | |
<leo_header file_format="2"/> | |
<vnodes> | |
<v t="peckj.20131009135732.3509"><vh>Body editor: light-dusk</vh> | |
<v t="peckj.20131009135732.3491"><vh>Colors</vh> | |
<v t="peckj.20131122130640.6165"><vh>Color definitions</vh> | |
<v t="peckj.20131122130640.6166"><vh>@color MistyRose1 = #FFE4E1</vh></v> |
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/python | |
# this script generates a random password of length 8, | |
# or whatever length is passed in on the command line | |
from string import ascii_letters, digits, punctuation | |
import sys, random | |
chars = ascii_letters + digits + punctuation | |
chars = chars.replace("\\", "") |
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
@echo off | |
:: A batch file which generates other batch files to run the Leo Editor, | |
:: adapted for the local machine. Optionally, it will also set the Windows | |
:: filetype and association so .leo files can be opened from Explorer. | |
:: | |
:: It needs to live in the same folder as "launchLeo.py" | |
:: | |
:: Open Source X/MIT License | |
:: initial version * 2012-Dec-13 * matt wilkie <[email protected]> | |
:: modified version * 2013-Jan-31 * jacob peck <[email protected]> |
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
// gridlines | |
// grid specific vars | |
// grid spacing in pixels | |
int GRID_MINOR_SPACING = 10; | |
int GRID_MAJOR_SPACING = 100; | |
// gridline colors | |
color GRID_MINOR_COLOR = color(147, 161, 247, 127); | |
color GRID_MAJOR_COLOR = color(0, 19, 137, 127); | |
// gridline weights in pixels |
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
a="hello" | |
b="world" | |
c=$a" there, isn't it a wonderful "$b"?" | |
echo $c |
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 io | |
Person := Object clone do( | |
pub ::= nil // "composed" key | |
priv ::= nil // private key | |
shared ::= nil // generated key | |
init := method( | |
self setPub(nil) | |
self setPriv(nil) |