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 logging.handlers import RotatingFileHandler | |
from flask import Flask | |
import logging | |
from logging import Formatter | |
app = Flask(__name__) | |
logger = logging.getLogger('your-logger-name') | |
file_handler = RotatingFileHandler('test.log', maxBytes=10000, backupCount=1) |
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
$> brew install openssl | |
$> brew install swig | |
$> env LDFLAGS="-L$(brew --prefix openssl)/lib" \ | |
CFLAGS="-I$(brew --prefix openssl)/include" \ | |
SWIG_FEATURES="-cpperraswarn -includeall -I$(brew --prefix openssl)/include" \ | |
pip install m2crypto |
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 base64 | |
from M2Crypto import RSA, BIO | |
key = open('/path/public_key.pem', 'r').read() | |
pubkey = str(key).encode('utf8') | |
bio = BIO.MemoryBuffer(pubkey) | |
rsa = RSA.load_pub_key_bio(bio) | |
encrypted = rsa.public_encrypt('hello', RSA.pkcs1_oaep_padding) | |
print 'encrypted text ', encrypted.encode('base64') |
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 csv | |
import requests | |
f = open('station.csv', 'rb') | |
reader = csv.reader(f) | |
def _generate_header(): | |
return {'Content-type': 'application/json'} |
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 urllib | |
query_param = urllib.quote('+6281908765') | |
url = 'http://localhost:8080/test?phone=%s' % query_param | |
print 'clean url ', url |
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
trs = [1, 2, 3, 4, 5, 6] | |
xyz = [1, 6, 9, 13] | |
gen = [tr for tr in trs if tr not in xyz] | |
for p in gen: | |
print p |
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
defaultConfig { | |
... | |
vectorDrawables.useSupportLibrary = 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
$ export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/VERSION/bin/ | |
$ pip install psycopg2 |
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
{ | |
"data": [ | |
{ | |
"id": 8, | |
"from_country_id": 101, | |
"from_country": "Indonesia", | |
"image": { | |
"original": "https://gibby.id/uploads/countries/101/14955144531007008508.jpg", | |
"@3x": "https://gibby.id/uploads/countries/101/[email protected]", | |
"@2x": "https://gibby.id/uploads/countries/101/[email protected]", |
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
http://gibby.id/api/requests-offer/{request_id}/trip/{trip_id}?api_key=198bc4240396814a3c8fb73b52b451b0 | |
{ | |
"data" : { | |
"request_id": 1, | |
"has_offered": true, // false if blom pernah offer | |
"price" : 2000, | |
"gibby_fee" : 500, | |
"gibby_prosen" : 1700, | |
"price_to_pay" : 70000, |
OlderNewer