Skip to content

Instantly share code, notes, and snippets.

@zmanji
zmanji / A.java
Created March 7, 2014 23:06
WAT.java
public class A {
Object a = this;
} // What the fuck.
@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 / 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 / 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 / gist:745637
Created December 17, 2010 20:18
Setting up a folder and virualenv
zmanji@zmanji-VirtualBox:~$ mkdir ~/zameermanji.com
zmanji@zmanji-VirtualBox:~$ mkdir ~/.virtualenvs
zmanji@zmanji-VirtualBox:~$ mkdir ~/.virtualenvs/zameermanji.com
zmanji@zmanji-VirtualBox:~$ virtualenv ~/.virtualenvs/zameermanji.com/ --no-site-packages
New python executable in /home/zmanji/.virtualenvs/zameermanji.com/bin/python
Installing distribute.................................................................................................................................................................................done.
zmanji@zmanji-VirtualBox:~$ source ~/.virtualenvs/zameermanji.com/bin/activate
(zameermanji.com)zmanji@zmanji-VirtualBox:~$ pip install werkzeug
Downloading/unpacking werkzeug
Downloading Werkzeug-0.6.2.tar.gz (1.7Mb): 1.7Mb downloaded
Running setup.py egg_info for package werkzeug
no previously-included directories found matching 'docs/_build/doctrees'
Installing collected packages: werkzeug
Running setup.py install for werkzeug
no previously-included directories found matching 'docs/_build/doctrees'
Successfully installed werkzeug
//This file implements the non restoring algorithm for division in binary
#include <stdio.h>
void binout_helper(int in, int left) {
if (left == 0) return;
binout_helper(in >> 1, left - 1);
printf("%d",in & 1);
}
@zmanji
zmanji / Makefile
Created January 10, 2012 17:00
Uwaterloo CS349 A1 Makefile
# This ensures that all of our shell commands are run with bash and not any other shell.
SHELL := /bin/bash
# This is the name of the compiler. If you have `clang` installed you can use that instead.
CXX = g++
# These are flags that are always sent to the compiler.
# -g generates debugging symbols for use in gdb and valgrind. This improves the
# output of those tools.
@zmanji
zmanji / main.c
Created March 1, 2012 06:55
Trying to get libalpm to work
#include <alpm.h>
#include <stdio.h>
int main(void)
{
enum _alpm_errno_t errno = 0;
alpm_handle_t* t = alpm_initialize("/", "/var/lib/pacman", &errno);
if(t == NULL)
@zmanji
zmanji / gist:2472962
Created April 23, 2012 18:39
brew install weechat
==> Downloading http://www.weechat.org/files/src/weechat-0.3.7.tar.bz2
Already downloaded: /Users/zmanji/Library/Caches/Homebrew/weechat-0.3.7.tar.bz2
/usr/bin/tar xf /Users/zmanji/Library/Caches/Homebrew/weechat-0.3.7.tar.bz2
==> cmake -DPREFIX=/usr/local/Cellar/weechat/0.3.7 -DENABLE_RUBY=OFF -DENABLE_PERL=OFF -DENABLE_PYTHON=OFF -DCMAKE_INSTALL_PREFIX='/usr/local/Cellar/weechat/0.3.7' -DCMAKE_BUILD_TYPE=None -Wno-dev .
cmake -DPREFIX=/usr/local/Cellar/weechat/0.3.7 -DENABLE_RUBY=OFF -DENABLE_PERL=OFF -DENABLE_PYTHON=OFF -DCMAKE_INSTALL_PREFIX='/usr/local/Cellar/weechat/0.3.7' -DCMAKE_BUILD_TYPE=None -Wno-dev .
-- The C compiler identification is Clang 3.1.0
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done