Skip to content

Instantly share code, notes, and snippets.

@zmanji
zmanji / wat.py
Created March 4, 2015 19:25
Closure creation in Python
[tw-mbp-zmanji ~]$ python
Python 2.7.8 (default, Dec 3 2014, 19:02:43)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import print_function
>>> names = ["a", "b", "c"]
>>> callables = []
>>> for n in names:
... callables.append(lambda: print(n))
...
@zmanji
zmanji / wtf-ruby.txt
Created July 3, 2014 00:59
What is wrong with Ruby?
Zameers-MacBook-Air:~ zmanji$ pry
[1] pry(main)> puts RUBY_VERSION
1.9.3
=> nil
[2] pry(main)> Date.methods.length
=> 104
[3] pry(main)> require "date"
=> true
[4] pry(main)> Date.methods.length
=> 135
@zmanji
zmanji / README.md
Created June 23, 2014 22:15
Downloading and Caching Task Binaries in Apache Aurora

Each task in Apache Aurora is started in an empty sandbox and a common first process for any task will be to fetch the binaries needed for the task. At Twitter binaries are fetched from an HDFS cluster similar to how Mesos executors are fetched from HDFS. If binaries for a task change rarely, this puts unnecessary stress on the HDFS cluster and ties task creation to the availability of the HDFS cluster. (See MESOS-336 for discussion on fetching Mesos executors).

The attached file package_cache.py serves to mitigate this problem by caching

@zmanji
zmanji / A.java
Created March 7, 2014 23:06
WAT.java
public class A {
Object a = this;
} // What the fuck.
@zmanji
zmanji / gist:6575133
Created September 15, 2013 23:15
Lol Scala.
Zameers-MacBook-Air:~ zmanji$ scala
Welcome to Scala version 2.10.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_17).
Type in expressions to have them evaluated.
Type :help for more information.
scala> null == null.asInstanceOf[Int]
<console>:8: warning: comparing values of types Null and Int using `==' will always yield false
null == null.asInstanceOf[Int]
^
res0: Boolean = true
Crashlog created at 2012-10-10 20:48:42 -0400
=== MESSAGE:
NoMethodError: undefined method `synchronize' for nil:NilClass
=== COMPILATION STACK:
- [item] /resume/ (rep default)
@zmanji
zmanji / sp.c
Created September 13, 2012 19:03
Printing the SP on x86_64
/* Tested on OSX with GCC 4.7 */
#include <stdint.h>
#include <stdio.h>
int main() {
uint64_t sp = 0;
asm("movq %%rsp,%0" : "=r"(sp));
printf("%016llX\n", sp);
return 0;
@zmanji
zmanji / __phutil_library_init__.php
Created July 25, 2012 21:55
Phabricator Event Development
<?php
phutil_register_library('disqus', __FILE__);
@zmanji
zmanji / gist:2554720
Created April 30, 2012 01:32
CMakeCache
# This is the CMakeCache file.
# For build in directory: /tmp/homebrew-weechat-0.3.7-C0HR/weechat-0.3.7
# It was generated by CMake: /usr/local/Cellar/cmake/2.8.8/bin/cmake
# You can edit this file to change values found and used by cmake.
# If you do not want to change any of the values, simply exit the editor.
# If you do want to change a value, simply edit, save, and exit the editor.
# The syntax for the file is as follows:
# KEY:TYPE=VALUE
# KEY is the name of a variable in the cache.
# TYPE is a hint to GUI's for the type of VALUE, DO NOT EDIT TYPE!.
# This is the CMakeCache file.
# For build in directory: /tmp/homebrew-weechat-0.3.7-H1kz/weechat-0.3.7
# It was generated by CMake: /usr/local/Cellar/cmake/2.8.8/bin/cmake
# You can edit this file to change values found and used by cmake.
# If you do not want to change any of the values, simply exit the editor.
# If you do want to change a value, simply edit, save, and exit the editor.
# The syntax for the file is as follows:
# KEY:TYPE=VALUE
# KEY is the name of a variable in the cache.
# TYPE is a hint to GUI's for the type of VALUE, DO NOT EDIT TYPE!.