Skip to content

Instantly share code, notes, and snippets.

View yankchina's full-sized avatar
💭
Researching and Learning

yankchina yankchina

💭
Researching and Learning
View GitHub Profile
@suzumura-ss
suzumura-ss / peewee-example.py
Created November 12, 2015 08:45
peewee with BIGINT primary key.
#from peewee import *
#import pymysql
import peewee
# 'id' to 'BIGINT AUTO_INCREMENT'
peewee.MySQLDatabase.field_overrides['primary_key'] = 'BIGINT AUTO_INCREMENT'
db = peewee.MySQLDatabase(
database='peewee_development',
user='root',
password='',
@damozhang
damozhang / torndb.ex.py
Created January 28, 2015 20:06
Examples of that how to use Torndb.
import torndb
mysql_settings = {
'host': 'localhost:3306',
'user': 'user',
'password': 'password',
'database': 'database',
'time_zone': '-8:00',
'charset': 'utf8'
@zilongshanren
zilongshanren / generate-random
Last active April 8, 2016 07:56
a helper program to generate random numbers
import xlwt
import random
import numpy
import json
import statistics
ezxf = xlwt.easyxf
sampleCount = 10
import android,time
droid = android.Android()
def getPos(waitTime=15):
droid.startLocating()
time.sleep(waitTime)
loc = droid.readLocation().result
@kernelsmith
kernelsmith / proxy_helper.sh
Last active December 26, 2015 22:09
All-in-one CLI environment proxy helper
# Note, the local keyword is not strictly posix compliant but supported in
# most shells. You can remove them w/o affecting the scripts except those
# variables will still be in scope outside the function, which can cause some
# info leakage unless you clear them (and you'd want to also trap so they'd be
# cleared when the script is interrupted with something like ctl-c etc)
prox="http://proxy.check:8080"
alias proxyon="export http_proxy=$prox && export https_proxy=$prox"
alias proxyoff='unset http_proxy && unset https_proxy'
@LinuxDoku
LinuxDoku / gist:6500963
Created September 9, 2013 20:22
mysql encryption
CREATE TABLE `data` (
`name` varchar(255) DEFAULT NULL,
`value` blob
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
insert into crypt_test.data values("hello.world", AES_ENCRYPT("test", SHA2("ld", 512)));
select CONVERT(AES_DECRYPT(value, SHA2("ld", 512)) using UTF8) as d FROM crypt_test.data
@dmitric
dmitric / fun_orm.py
Last active June 21, 2018 11:16
A simple read-only ORM like functionality using python's __getattr__. Example uses tornado's torndb Connection and query
class Backend(object):
"""Allows access to backend and removes logic from handlers"""
def __init__(self):
"""Inititalize with the variables you need"""
self.__users_data = None
self.db = Connection(
options.db_host,
options.db,
user=options.db_user,
@shuuheyhey
shuuheyhey / capture.js
Created May 20, 2013 22:51
casperjs > capture.js
var screenshotUrl = 'http://example.com/'
var casper = require("casper").create({
viewportSize: {
width: 1280,
height: 1280
}
});
if (casper.cli.args.length < 1) {
@kaz29
kaz29 / build.xml
Last active December 14, 2015 16:38
(CakePHPとか)PHPのテストについての勉強会 - CakePHP2+Jenkinsで継続的インテグレーション
<?xml version="1.0" encoding="UTF-8"?>
<project name="name-of-project" default="build">
<target name="build" depends="prepare,lint,phploc,pdepend,phpcb,phpmd-ci,phpcs-ci,phpcpd,phpunit"/>
<target name="build-parallel" depends="prepare,lint,tools-parallel,phpunit"/>
<target name="tools-parallel" description="Run tools in parallel">
<parallel threadCount="3">
<sequential>
<antcall target="pdepend"/>
@petrblahos
petrblahos / gist:5050586
Created February 27, 2013 18:59
Small example of bottle.py usage.
import json
import bottle
@bottle.get("/text")
def text():
return "Returning text"
@bottle.get("/data/get")
def get_data():