Skip to content

Instantly share code, notes, and snippets.

@za
za / ola.txt
Created July 25, 2013 03:29
Ola
Konnichiwa!
@za
za / requirements-stamps.txt
Created March 5, 2014 03:09
Stamps and Zocko requirements.txt
django==1.6.2
django-extensions==1.3.0
django-model-utils==1.3.0
redis==2.6.2
South==0.8.4
django-compressor==1.3
BeautifulSoup==3.2.1
easy-thumbnails==1.4
rq==0.3.8
django-rq==0.5.1
@za
za / gist:9871a5315dd54375fa40
Created July 15, 2014 04:57
mechanize to automate (programmatic) stateful web browsing
11:47 < za> sugiana: cara otomasi akses info (query) ke ib mandiri gimana?
11:48 < sugiana> pakai mechanize
11:48 < sugiana> browser by script
11:49 < sugiana> situ pakai debian ?
11:50 < za> sugiana: 'situ' mengacu siapa? :B
11:50 < za> ini ya mas https://pypi.python.org/pypi/mechanize/ ?
11:50 < sugiana> iya, situ is last except me
11:52 < za> saya ada mesin debian/ubuntu :B
11:53 < sugiana> buat /etc/apt/sources.list.d/rab.list isinya: deb http://debian.rab.co.id/custom ./
11:53 < sugiana> apt-get update; apt-get install internet-banking
@za
za / tests.py
Last active June 27, 2018 17:09
django-testing: mock datetime.datetime.now()
import mock
from django.test import TestCase, Client
import datetime
class StubDate(datetime.datetime):
pass
class TestApp(TestCase):
@mock.patch('app.views.datetime.datetime', StubDate) #app is the $django_application_name
@za
za / python3-pandas-ipython3.md
Last active August 29, 2015 14:24
Setting Up Python3 Pandas and IPython3 on Ubuntu

Search for python3 pandas package

$ apt-cache search pandas

python-pandas - data structures for "relational" or "labeled" data
python-pandas-lib - low-level implementations and bindings for pandas
python3-pandas - data structures for "relational" or "labeled" data - Python 3
python3-pandas-lib - low-level implementations and bindings for pandas - Python3
@za
za / venv-python3-pandas-ipython3.md
Last active August 29, 2015 14:24
Python3 Pandas and IPython3 in a Virtual Environment

Instead of installing in a system-wide environment, we can setup in a localidzed, separated environment.

Create new virtualenv:

$ virtualenv --python=`which python3` open-data-crunch

Activate open-data-crunch virtualenv

@za
za / reverse.py
Created July 15, 2015 03:58
Python2 reverse string with for loop
a = 'Newton'
for i in range(1, len(a)+1):
print a[-i]
@za
za / python3-reverse.py
Last active August 29, 2015 14:24
Python 3 Reverse String with Loop
a = 'Newton'
for i in range(1, len(a)+1):
print(a[-i], end="")