Skip to content

Instantly share code, notes, and snippets.

View gchiam's full-sized avatar

Gordon Chiam gchiam

View GitHub Profile
"""Testing chromote library.
https://github.com/iiSeymour/chromote
"""
from __future__ import print_function
import itertools
import time
from chromote import Chromote
In [1]: from itertools import zip_longest
In [2]: size = 500
In [3]: parts = 16
In [4]: ranges = list(range(0, size, size // parts))
In [5]: ranges
Out[5]:
@gchiam
gchiam / ubuntu_setup.sh
Last active November 3, 2016 04:24
ubuntu set
sudo apt-get update
sudo apt-get dist-upgrade -y
sudo apt-get install -y openssh-server
sudo apt-get install -y git
sudo apt-get install -y build-essential
sudo apt-get install -y python-dev python3-dev
sudo apt-get install -u libtool libtool-bin autoconf automake cmake g++ pkg-config unzip gperf
@gchiam
gchiam / gist:7f8f302cd460d8a300db333e55445654
Created April 19, 2016 03:15 — forked from dedy-purwanto/gist:11312110
Bulk remove iTerm2 color schemes.
# There was a day where I have too many color schemes in iTerm2 and I want to remove them all.
# iTerm2 doesn't have "bulk remove" and it was literally painful to delete them one-by-one.
# iTerm2 save it's preference in ~/Library/Preferences/com.googlecode.iterm2.plist in a binary format
# What you need to do is basically copy that somewhere, convert to xml and remove color schemes in the xml files.
$ cd /tmp/
$ cp ~/Library/Preferences/com.googlecode.iterm2.plist .
$ plutil -convert xml1 com.googlecode.iterm2.plist
$ vi com.googlecode.iterm2.plist
from __future__ import print_function
import abc
import functools
class BaseContextDecorator(object):
__metaclass__ = abc.ABCMeta
def __call__(self, func):
@gchiam
gchiam / item2_italics.sh
Last active February 7, 2017 04:26
Italics in Item2
infocmp xterm-256color > /tmp/xterm-256color.terminfo
cp /tmp/xterm-256color.terminfo /tmp/xterm-256color.terminfo.origial # backup
printf '\tsitm=\\E[3m, ritm=\\E[23m,\n' >> /tmp/xterm-256color.terminfo
tic /tmp/xterm-256color.terminfo
infocmp screen-256color > /tmp/screen-256color.terminfo
cp /tmp/screen-256color.terminfo /tmp/screen-256color.terminfo.origial # backup
printf '\tsitm=\\E[3m, ritm=\\E[23m,\n' >> /tmp/screen-256color.terminfo
tic /tmp/screen-256color.terminfo
@gchiam
gchiam / singleton.py
Last active February 9, 2017 03:01
Singleton metaclass
class Singleton(type):
"""A singleton metaclass.
Usage:
class Foo(object):
__metaclass__ = Singleton
assert Foo() is Foo()
"""
from itertools import izip_longest
def get_chunks(size, parts):
ranges = list(range(0, size, size // (parts - 1)))
return list(izip_longest(ranges, ranges[1:], fillvalue=size))
if __name__ == '__main__':
size = 500
@gchiam
gchiam / keybase.md
Created March 1, 2017 04:32
keybase.md

Keybase proof

I hereby claim:

  • I am gchiam on github.
  • I am gchiam (https://keybase.io/gchiam) on keybase.
  • I have a public key whose fingerprint is 7628 D70D 2B68 1304 86DB B346 BAE1 0BD7 51A0 125E

To claim this, I am signing this object:

class Root(object):
def setup(self):
print 'Root.setup'
class Base(Root):
def setup(self):
print 'Base.setup'
super(Base, self).setup()