Skip to content

Instantly share code, notes, and snippets.

View sofianhw's full-sized avatar
💭
I may be slow to respond.

Sofian Hadiwijaya sofianhw

💭
I may be slow to respond.
View GitHub Profile
@sofianhw
sofianhw / appify
Last active August 29, 2015 14:19 — forked from mathiasbynens/appify
#!/bin/bash
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then cat <<EOF
appify v3.0.1 for Mac OS X - http://mths.be/appify
Creates the simplest possible Mac app from a shell script.
Appify takes a shell script as its first argument:
`basename "$0"` my-script.sh
@sofianhw
sofianhw / hwinfo.sh
Last active September 14, 2015 18:23
show hw info
#!/bin/bash
# cpu information
cat /proc/cpuinfo
# memory information
cat /proc/meminfo
# kernel information
cat /proc/version
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import TextConverter, HTMLConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFPage
from cStringIO import StringIO
def convert_pdf_to_txt(path):
rsrcmgr = PDFResourceManager()
retstr = StringIO()
codec = 'utf-8'
@sofianhw
sofianhw / BS4ReadGzip.py
Created October 8, 2015 07:30
BS4ReadGzip
import sys
import re
import io
import gzip
from urllib.request import urlopen
from urllib.request import Request
from bs4 import BeautifulSoup
def getLinks(pageUrl):
bs = urlopen(Request(pageUrl, headers={"User-Agent": "Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11", "Accept-Encoding": "gzip"}) ).read()
@sofianhw
sofianhw / CardboardModeMgr.cs
Created October 11, 2015 08:29
Cardboard Mode Manager
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
using System.Collections.Generic;
using UnityEngine.UI;
public class CardboardModeMgr : MonoBehaviour {
// We need a reference to camera which
// is how we get to the cardboard components.
@sofianhw
sofianhw / fb_load_comments.py
Created October 13, 2015 01:54
Using Facebook Graph API the script "fb_load_comments.py" loads comments from an specific facebook object (e.g. posts, photos, etc).
#! /usr/bin/python
#
'''
Version : 0.1
Author : Arian Pasquali
Summary : This program loads comments from facebook object
'''
from facepy import GraphAPI
import json;
@sofianhw
sofianhw / sofian.hw
Last active November 7, 2015 03:26
Sofian ASCII
___ _ _
___ ___| _|_|___ ___| |_ _ _ _ ___ ___ _____
|_ -| . | _| | .'| | | | | |_| _| . | |
|___|___|_| |_|__,|_|_|_|_|_____|_|___|___|_|_|_|
https://github.com/may-day/olap
http://bkanuka.com/articles/python-connect-to-olap/
http://mondrian.pentaho.com/documentation/installation.php
https://github.com/olap4j/olap4j
http://stackoverflow.com/questions/3793215/query-olap-mondrian-mdx-xmla-with-a-python-interface
https://research.cip.cgiar.org/docs/mondrian/Tutorial_Mondrian.pdf
http://lists.pentaho.org/pipermail/mondrian/2014-October/004999.html
http://maxrohde.com/2011/04/27/large-war-file-cannot-be-deployed-in-tomcat-7/
http://pentaho.dlpage.phi-integration.com/mondrian/mysql-foodmart-database
https://github.com/ThoughtWorksInc/mondrian-xmla-spike
@sofianhw
sofianhw / nginx_image
Last active February 5, 2016 10:29
Nginx configuration for static content
server {
listen 80;
root /var/www/html/data;
location /images/ {
#Enabling the sendfile directive will eliminate the step of copying the data into the buffer and enables direct copying data from one file descriptor to anothers
sendfile on;
#To prevent one fast connection to entirely occupy the worker process, you can limit the amount of data transferred in a single sendfile() call by defining the sendfile_max_chunk directive
sendfile_max_chunk 1m;
#Use the tcp_nopush option together with sendfile on;. The option will enable NGINX to send HTTP response headers in one packet right after the chunk of data has been obtained by sendfile
@sofianhw
sofianhw / remotemd5.py
Created February 10, 2016 13:07 — forked from brianewing/remotemd5.py
Python MD5 of remote file (URL)
import os, hashlib, urllib2, optparse
def get_remote_md5_sum(url, max_file_size=100*1024*1024):
remote = urllib2.urlopen(url)
hash = hashlib.md5()
total_read = 0
while True:
data = remote.read(4096)
total_read += 4096