Skip to content

Instantly share code, notes, and snippets.

View zachaysan's full-sized avatar
🏎️
🚗

Zach Aysan zachaysan

🏎️
🚗
View GitHub Profile
@zachaysan
zachaysan / node-and-npm-in-30-seconds.sh
Created May 5, 2011 16:18 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
printf '\nexport PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
@zachaysan
zachaysan / squarer.py
Created June 6, 2012 19:40
My version of the sq thing
class Point(object):
def __init__(self):
self.x = None
self.y = None
a = Point()
b = Point()
a.x = 20
a.y = 1
@zachaysan
zachaysan / cleaner.py
Created July 13, 2012 14:44
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":
os.remove(p)
if __name__ == '__main__':
@zachaysan
zachaysan / eric.py
Created November 17, 2012 17:35
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
zachaysan / gist:7100458
Created October 22, 2013 13:08
insertAtCaret
jQuery.fn.extend insertAtCaret: (myValue) ->
@each (i) ->
if document.selection
@focus()
sel = document.selection.createRange()
sel.text = myValue
@focus()
else if @selectionStart or @selectionStart is "0"
startPos = @selectionStart
endPos = @selectionEnd
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
else:
setting = Hash.new("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]
@zachaysan
zachaysan / notes.md
Last active August 29, 2015 14:15 — forked from monicao/notes.md

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

@zachaysan
zachaysan / FUCKING AWESOME OVER HERE
Created February 20, 2015 20:55
BEST GIST EVER
a = []
a[0] = a
cities = ["Texas", "Amsterdam", "New York", "Toronto", "Phoenix", "Los Angeles"]
cities += ["San Francisco", "Miami", "Chicago", "Dallas", "Houston"]
while true
begin
system("./hma-vpn.sh #{cities.sample}) &")
sleep rand * 12
system('killall "hma-vpn.sh"')
rescue StandardError => e
puts "Error #{e}"