Skip to content

Instantly share code, notes, and snippets.

@efaisal
efaisal / muat_turun_waktu_solat_jakim.py
Last active December 11, 2015 09:59
Skrip untuk muat turun data waktu solat Jakim
#!/usr/bin/env python
"""
Muat turun data waktu solat Jakim
"""
import re
import requests
from lxml import etree
@efaisal
efaisal / papar_waktu_solat.sh
Created January 21, 2013 06:34
Papar jadual waktu solat untuk persekitaran berasas GTK. Jadual boleh di muatturun menggunakan skrip di https://gist.github.com/4583986.
#!/bin/sh
# Jadual terletak di $HOME/.solat/jadual
tarikh=`/bin/date +"%Y-%m-%d"`
jadual=`/usr/bin/awk -v t=$tarikh -F "|" '{ if ($1 == t) print $2; }' $HOME/.solat/jadual`
#echo $tarikh
#echo $jadual
@efaisal
efaisal / ngram_najmi.py
Last active December 14, 2015 19:09
N-Gram for Najmi
#!/usr/bin/env python
import os
from itertools import izip_longest
from collections import Counter
###############################################################################
INPUT_DIR = '../../GenericFeatureSelection/apireport'
OUTPUT_DIR = 'result/ngram'
NGRAMS = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
@efaisal
efaisal / buildbooklet.sh
Last active December 15, 2015 01:59
Given a PDF file with multiple A5 size pages, all with potrait orientation where the total of pages are a multiple of four. This shell script (requires bash) will output a new PDF file suitable for printing on A4 paper with landscape orientation, arranging the source pages so that the printed A4 output can nicely turn into an A5 booklet by simpl…
#!/bin/bash
# In PDF world potrait A4 is 595ptx842pt
[ -z "$1" ] && echo "Please specify input file" && exit 1
[ ! -f "$1" ] && echo "File not found" && exit 1
# Get total number of pages
total_pages=`gs -dNODISPLAY $1 -c quit | awk '/Page/ { print NR; }' | wc -l`
echo "Total number of pages is $total_pages."
@efaisal
efaisal / semakdmspr.py
Created December 3, 2013 03:28
Workaround the CSS Captcha to automate Semakan Pemilih Bagi Isi Rumah at http://daftarj.spr.gov.my/semakdm/ Output result in HTML, leaving you as an exercise to parse :)
#!/usr/bin/env python
import requests
import lxml.html
import tinycss
###############################################################################
url, form = 'http://daftarj.spr.gov.my/semakdm/', 'semakandm.asp'
form = url + form
###############################################################################
@efaisal
efaisal / sprpdf.py
Created January 23, 2014 07:35
Split PDF file given by SPR every quarterly according to Daerah Mengundi for people to check voters' movement.
#!/usr/bin/env python
"""
Split PDF given by SPR every quarterly according to Daerah Mengundi
Requires PyPDF2 https://github.com/mstamy2/PyPDF2
"""
import sys
import os
import re
from cStringIO import StringIO

Keybase proof

I hereby claim:

  • I am efaisal on github.
  • I am efaisal (https://keybase.io/efaisal) on keybase.
  • I have a public key whose fingerprint is E56E 520A 0A98 6199 35EA 9593 CC75 BBF9 BFFC 75D8

To claim this, I am signing this object:

@efaisal
efaisal / face.html
Created April 8, 2015 08:46
Draw my face using HTML
<pre style="font: 6px/3px monospace;"><span style="color: #95998b;"></span><span style="color: #969a8b;">#</span><span style="color: #979b8a;">#</span><span style="color: #989c8b;">#</span><span style="color: #979b8a;">#</span><span style="color: #979b8c;">#</span><span style="color: #979b8c;">#</span><span style="color: #989d89;">#</span><span style="color: #999e8a;">#</span><span style="color: #9a9f8b;">#</span><span style="color: #9a9e8d;">#</span><span style="color: #9a9f8b;">#</span><span style="color: #999e8a;">#</span><span style="color: #9a9d8c;">#</span><span style="color: #9a9d8c;">#</span><span style="color: #9a9c8e;">#</span><span style="color: #9a9c8e;">#</span><span style="color: #9b9d8f;">#</span><span style="color: #9b9e8d;">#</span><span style="color: #9b9e8d;">#</span><span style="color: #9b9e8d;">#</span><span style="color: #9a9d8c;">#</span><span style="color: #9a9d8c;">#</span><span style="color: #9b9d8f;">#</span><span style="color: #9b9e8d;">#</span><span style="color: #9a9d8c;">#</spa
@efaisal
efaisal / my.cnf
Created April 10, 2015 13:41
Minimal Galera MariaDB Multi Master Synchronous Replication
[mysql]
port = 3306
socket = /var/lib/mysql/mysql.sock
[mysqld]
# GENERAL #
user = mysql
default-storage-engine = InnoDB
socket = /var/lib/mysql/mysql.sock
pid-file = /var/lib/mysql/mysql.pid
@efaisal
efaisal / process_xml_eg.py
Created September 2, 2015 16:03
Example on how to process XML using lxml
#!/usr/bin/env python
"""
Sample taken from http://www.w3schools.com/xml/simple.xml
"""
from StringIO import StringIO
from lxml import etree
# Open XML file