- Do some programming
- git add
- git status to see what files changed
- git status -s
- git diff [file] to see exactly what modified
- git diff --cached
| def algorithm_development(problem_spec): | |
| correct = False | |
| while not correct or not fast_enough(running.time): | |
| algorithm = devise_algorithm(problem_spec) | |
| correct = analyze_correct(algorithm) | |
| running.time = analyze_efficiency(algorithm) | |
| return algorithm |
| import requests | |
| renren_payload={'email': '', 'password':''} | |
| weibo_payload={'uname': '', 'pwd': ''} | |
| renren = requests.post('http://3g.renren.com', data=renren_payload) | |
| weibo = requests.post('http://m.weibo.cn', data=weibo_payload) |
| def test_gist(): | |
| if worked == True: | |
| print "It's cool!" | |
| else: | |
| print "Damn it!" | |
| if __name__ == '__main__': | |
| test_gist() |
| def factorial(n: Int) = { | |
| def factorial1(n: Int, multi: Int): Int = { | |
| if (n == 0) multi | |
| else factorial1(n-1, multi*n) | |
| } | |
| factorial1(n, 1) | |
| } | |
| def factorial(n: Int): Int = { | |
| if (n==0) 1 else n * factorial(n-1) | |
| } |
| class Rational(n: Int, d: Int) { | |
| require(d != 0) | |
| private val g = gcd(n.abs, d.abs) | |
| val number = n / g | |
| val denom = d / g | |
| def this(n: Int) = this(n, 1) // auxiliary constructor | |
| def + (that: Rational): Rational = |
| /** | |
| * place an asterisk after the type of the parameter | |
| */ | |
| def echo(args: String*) = | |
| for (arg <- args) printn(arg) | |
| echo("hello", "world") | |
| val arr = Array("What's", "up", "doc?") | |
| echo(arr: _*) |
| def sum(a: Int, b: Int, c: Int): Int = a + b + c | |
| val a = sum _ | |
| a(1,2,3) | |
| val b = sum(1, _: Int, 3) | |
| b(2) | |
| b(5) | |
| def curriedSum(x: Int)(y: int) = x + y | |
| curriedSum(1)(2) // 3 | |
| def first(x: Int) = (y: Int) => x + y | |
| val second = first(1) | |
| second(2) // 3 | |
| // use placeholder notation to use curriedSum in a partially applied function |