Skip to content

Instantly share code, notes, and snippets.

@Zhangerr
Zhangerr / diamond.js
Created October 4, 2014 19:46
Diamond generator
// *
// ***
// *****
// *******
// *********
// *******
// *****
// ***
// *
@Zhangerr
Zhangerr / doge
Created February 16, 2015 23:10
:( inheritance hell
/**
* Created by azhang on 2/16/15.
*/
class test {
public static void main(String[] args) {
Animal fido = new Dog();
fido.speak(fido);
fido.speak((Dog) fido);
((Dog) fido).speak(fido);
((Dog) fido).speak((Dog) fido);
@Zhangerr
Zhangerr / curious.py
Created March 4, 2015 05:38
interesting problem regarding frames
"""
What's the different in output between the following two functions?
HINT: look at environment diagram
"""
L = []
for i in range(10):
L.append(lambda: i)
for z in L:
@Zhangerr
Zhangerr / readme.md
Created March 4, 2015 05:45
twitter phone interview questions
2 D grid. city blocks
. S .
x x .
. E .
start, end == (x ,y), (x, y)
int shortestPath(map, start, end) {
Queue q = new Queue();
Branch[] branches = getAllPossible(start);
"Assume the following is input into the terminal:"
class A:
x = 5
def waka(self, x):
self.x = x
def p(self):
print("from p method")
print(self.x)
"Fill in the following blanks with what the interactive terminal would output. The answer may be an error; the effect of some lines may have affect subsequent lines"
@Zhangerr
Zhangerr / rnd.py
Created January 2, 2013 04:09
simple script for generating random numbers in python
#!/usr/bin/python
import sys
import getopt
n = 1
src = "urandom"
def Usage():
print """a simple script to generate random numbers. syntax is as follows:
""" + sys.argv[0]+ """ [options] <number of random numbers to print>
There are only 2 options:
@Zhangerr
Zhangerr / factorial.py
Created April 4, 2013 05:28
factorial functional style?
>>> g = lambda x: reduce(lambda y,z:y*z,range(x,0,-1))
>>> g(2)
2
>>> g(3)
6
>>> g(4)
24
>>> g(5)
120
>>> g(6)
@Zhangerr
Zhangerr / todo
Last active December 17, 2015 10:49
sc2
forward pylons/pylon spread
stay calm and a move to drops/counter attacks
macro & throw down production even while focusing on army
throw down a lot of gateways in late game
expand, counter attack, drop
probe production
avoid supply block, check supply & make pylons
rally points
chronoboost production
scout
@Zhangerr
Zhangerr / less
Created July 6, 2013 07:23
LESS frameworks
Lesshat - http://lesshat.com/
helpess - http://www.m6tt.com/2011/09/21/helpless-a-less-library
3L - http://mateuszkocz.github.io/3l/
preboot - http://markdotto.com/bootstrap/
clearless - http://clearleft.github.io/clearless/
lesselements - http://lesselements.com/
dss less - http://mrkrupski.github.io/LESS-Dynamic-Stylesheet/
bootstrap - http://twitter.github.io/bootstrap/