Skip to content

Instantly share code, notes, and snippets.

View widoyo's full-sized avatar

Widoyo widoyo

View GitHub Profile
@widoyo
widoyo / kas.py
Created October 16, 2012 07:42
Generating PDF using Flask & ReportLab
from flask import make_response
from reportlab.pdfgen import canvas
# ...
@app.route('/pdf')
def pdf():
import cStringIO
output = cStringIO.StringIO()
@widoyo
widoyo / gist:4133590
Created November 23, 2012 01:24
Baca Email RMR
>>> import re
>>> # mencari RMR Number pada Subject email
>>> "Re: RMR Number 121127-I01-07-1".rsplit(" ", 1)[1]
121127-I01-07-1
>>> inputs = ["Re: RMR Number 121127-I01-07-1", "RMR Number 121127-I01-07-1", "Re: RMR NUmber 121127-I08-PP-1"]
>>>
>>> for a in inputs:
... m = re.match(r'.*RMR Number.*(?P<rmr>\d{6}-\w{1}\d{2}-.*-\d{1})', a, re.I)
... if m:
... m.groupdict()['rmr']
@widoyo
widoyo / sms_event.sh
Created December 8, 2012 06:27
SMS Tools ke Postgresql
#!/bin/sh
if [ "$1" != "RECEIVED" ]; then exit; fi;
#DB parameter
SQL_HOST=localhost
SQL_USER=enterprisedb
SQL_PASSWORD=
SQL_DATABASE=MitraLunas
@widoyo
widoyo / models.py
Created December 28, 2012 03:28
Model Ideal
from django.db import models
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
from django.db.models import signals
class ModuleRef(models.Model):
"""
Referensi Module, Part Number
@widoyo
widoyo / nginx.conf
Created December 29, 2012 10:48
Deploy Django nGinx uwsgi di Webfaction
Deploy Django-Nginx-uwsgi pada web faction
referensi: http://community.webfaction.com/questions/10242/installing-nginx-uwsgi
APPNAME="tracker"
/home/narayana/webapps/tracker
bin
start
stop
@widoyo
widoyo / gist:4449813
Created January 4, 2013 04:03
Senam Mata
Senam Mata
Posisi Kepala tegak
1. Gerakkan bola mata ke atas-bawah 5 - 10 kali
2. Gerakkan bola mata ke kiri-kanan 5 - 10 kali, seolah mau lihat telinga
3. Gerakkan bola mata ke atas, lalu kiri-kanan 5 - 10 kali
4. Gerakkan bola mata ke bawah, lalu ke kanan-kiri
5. Gerakkan bola mata ke atas-bawah dengan sudut mata saling menjauhi
6. Putar bola mata searah jarum jam, dari kiri, dan sebaliknya 5 - 10 kali
@widoyo
widoyo / clear_session.php
Last active December 10, 2015 17:08
Facebook App Video Upload
<?php
session_start();
$found_session = false;
foreach ( array_keys($_SESSION) as $key ) {
if ( preg_match('/code/', $key) or preg_match('/user_id/', $key) or preg_match('/access_token/', $key) ) {
$found_session = true;
}
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
@widoyo
widoyo / app.css
Last active December 11, 2015 20:08 — forked from yogaswara/mdd.html
/* Artfully masterminded by ZURB */
/* --------------------------------------------------
Table of Contents
-----------------------------------------------------
:: Shared Styles
:: Page Name 1
:: Page Name 2
*/
# HW 5.2
db.zips.aggregate([
{$match: {$and : [{"state": {$in: ['CA', 'NY']}}]}},
{$group: {_id: "$city", total: {$sum: "$pop"}}},
{$match: {"total": {$gt: 25000}}}, {$group: {_id: 'kota', rerata: {$avg: "$total"}}}
])
{
"_id" : ObjectID(),
"name": "",