This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Jawaban https://gist.github.com/iromli/3250cc6ab317fce7d856 | |
class Foo: | |
def __init__(self, a, b, c): | |
self.a = a | |
self.b = b | |
self.c = c | |
def run(self): | |
return self.a + self.b + self.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Countdown and do something. Before run install espeak (optional): | |
# | |
# apt-get install espeak | |
# | |
import os | |
import sys | |
from datetime import time, datetime, timedelta | |
from time import sleep | |
from optparse import OptionParser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from decimal import Decimal | |
def json_format(v): | |
if type(v) is Decimal: | |
return int(v) | |
return v | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import locale | |
locale.setlocale(locale.LC_ALL, 'id_ID.utf8') | |
def money(n): | |
return locale.format('%d', n, True) | |
if __name__ == '__main__': | |
print(money(12345)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlalchemy import create_engine | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy import Column, Integer, String | |
from sqlalchemy.orm import sessionmaker | |
Base = declarative_base() | |
class BaseModel(object): | |
id = Column(Integer, primary_key=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf8 -*- | |
# CRC CCITT | |
# | |
# comes in 3 flavous | |
# (XModem) starting value: 0x0000 | |
# starting value: 0xffff | |
# starting value: 0x1d0f | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def clean(s): | |
s = s.strip() | |
if s.find('http://') == 0: | |
s = s[7:] | |
if s.find('www.') == 0: | |
s = s[4:] | |
return s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import wx | |
class FormUtama(wx.Frame): | |
def __init__(self, parent=None): | |
super(FormUtama, self).__init__(parent) | |
self.edit_data = wx.TextCtrl(self, style=wx.TE_MULTILINE, size=(350,200)) | |
self.button_simpan = wx.Button(self, label='Simpan') | |
# Events |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Reference: | |
http://depa.usst.edu.cn/chenjq/www2/SDesign/JavaScript/CRCcalculation.htm | |
Input: | |
CRC Order: 32 | |
CRC Polynom: 4C11DB7 | |
Data Input: |
OlderNewer