Skip to content

Instantly share code, notes, and snippets.


Zach Aysan zachaysan

View GitHub Profile
import pdb
import atexit
import os
import readline
from pathlib import Path
class Config(pdb.DefaultConfig):
sticky_by_default = True
View gist:8029e71fd212a31d7f58 Afghanistan, Kabul Aland Islands, Mariehamn Albania, Tirana Algeria, Annaba Anguilla, The Valley Antigua and Barbuda, Saint John's Argentina, Buenos Aires Armenia, Tsaghkadzor Aruba, Palm Beach Australia, New South Wales, Sydney (LOC1 S1)
View gist:28cd7971bd5a1dfc0c50
cities = ["Texas", "Amsterdam", "New York", "Toronto", "Phoenix", "Los Angeles"]
cities += ["San Francisco", "Miami", "Chicago", "Dallas", "Houston"]
while true
system("./ #{cities.sample}) &")
sleep rand * 12
system('killall ""')
rescue StandardError => e
puts "Error #{e}"

Rethinking CoffeeScript

CoffeeScript was written by Jeremy Ashkenas, a Ruby developer who was fed up with the quirks of JavaScript. It was an instant success in the Ruby community. Many people were tired of having to type === instead of ==, of JavaScript's crappy lexical scoping, of having to jump through hoops to set up even the most simple inheritance structure, of variables leaking into the global scope or having to worry about silly things like hoisting.

This was a time when web user interfaces were becoming more complex and backend developers had to spend more and more time writing JavaScript code. For a long time, coding in JavaScript meant you spent 100% of your time using jQuery. And what an epic mess that was!

At that time many people did not consider JavaScript to be a real programming language, because of it's oddities. So when CoffeeScript came along developers (especially Ruby developers) embraced it as a way to make coding in JavaScript suck less. I was one of those developers. I liked

View gist:8528535
setting ="Some default string")
setting[0] = "some string"
setting[1] = "some other string"
postLoginAction = 0
puts setting[postLoginAction]
postLoginAction = 1
puts setting[postLoginAction]
postLoginAction = 5
puts setting[postLoginAction]
View gist:7603526
Buffers Tools Python Help
import random
def flip(n):
on_tails = -1000 * 1000
if n == 0:
return 1
elif random.random() < 0.5:
return on_tails
View gist:7100458
jQuery.fn.extend insertAtCaret: (myValue) ->
@each (i) ->
if document.selection
sel = document.selection.createRange()
sel.text = myValue
else if @selectionStart or @selectionStart is "0"
startPos = @selectionStart
endPos = @selectionEnd
zachaysan /
Created Nov 17, 2012
Code to alter the original
def artistic_black_and_white(image, order=2):
pix = pixel_array(image)
draw = ImageDraw.Draw(image)
for y in range(image_height(image)):
for x in range(image_width(image)):
r,g,b = pix[x,y]
grey_value = (r + g + b)/3
adjusted_value = int(((grey_value / 255.0) ** (1 / float(order)) * grey_value))
r = adjusted_value
zachaysan /
Created Jul 13, 2012
Clean out distracting files
import os
def clean():
for root, dirs, files in os.walk(os.getcwd()):
for f in files:
p = os.path.join(root, f)
if p[-1] == "~" or p[-4:] == ".pyc":
if __name__ == '__main__':