Skip to content

Instantly share code, notes, and snippets.

# http://python.web.id/angka-terbilang-pada-python/#.VQpS8s2sXQo
satuan = ['', 'satu', 'dua', 'tiga', 'empat', 'lima', 'enam', 'tujuh',
'delapan', 'sembilan', 'sepuluh', 'sebelas']
def terbilang_(n):
n = int(n)
if n >= 0 and n <= 11:
hasil = [satuan[n]]
elif n >= 12 and n <= 19:
@sugiana
sugiana / datatables.py
Created September 29, 2014 11:14
Bug fixed for multi relationship sqlalchemy-datatables 0.1.6
# -*- coding: utf-8 -*-
from sqlalchemy.sql.expression import asc, desc
from sqlalchemy.sql import or_, and_
from sqlalchemy.orm.properties import RelationshipProperty
from sqlalchemy.sql.expression import cast
from sqlalchemy import String
from collections import namedtuple
ColumnTuple = namedtuple('ColumnDT', ['column_name', 'mData', 'search_like', 'filter'])
#!/usr/bin/python
import sys
import subprocess
cmd = ['/usr/sbin/adduser'] + sys.argv[1:]
subprocess.call(cmd)
if sys.argv[1:]:
username = sys.argv[1]
from sqlalchemy import (
Table,
MetaData,
)
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from sqlalchemy.schema import PrimaryKeyConstraint
Base = declarative_base()
import string
def clean(s):
r = ''
for ch in s:
if ch not in string.printable:
ch = ' '
r += ch
return r
from sqlalchemy import create_engine
db_url = 'oracle://user:pass@ip/db'
engine = create_engine(db_url)
sql = """INSERT INTO sync_sppt_ora2pg (kd_propinsi, kd_dati2,
kd_kecamatan, kd_kelurahan, kd_blok, no_urut, kd_jns_op,
thn_pajak_sppt, jns_sinkron) VALUES ('36','76','052', '004',
'007', '3522', '0', '2014', '2')"""
from sqlalchemy import (create_engine, Column, Integer, String, ForeignKey,
UniqueConstraint)
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
Base = declarative_base()
class User(Base):
import os
import sys
from optparse import OptionParser
from sqlalchemy import create_engine
from time import sleep
import signal
import commands
import conf
@sugiana
sugiana / table2csv.py
Created March 8, 2014 06:28
Export table to CSV
import sqlalchemy as sa
import csv
import sys
tablename = sys.argv[1]
filename = '%s.csv' % tablename
url = 'postgresql://user:pass@host/dbname'
eng = sa.create_engine(url)
q = eng.execute("SELECT * FROM %s" % tablename)
@sugiana
sugiana / voucher-generator.py
Created February 5, 2014 09:08
Voucher Generator
import string
from random import choice
chars = string.ascii_uppercase + string.digits
count = 1000
digit_count = 9
digit_loop = range(digit_count)
keys = []
i = 0
while i < count: