This file contains hidden or 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 random | |
def get_wave_data(): | |
s = "52494646" # RIFF | |
s += "88580100" # subchunks. 88,200 in hex, little-endian | |
s += "57415645" # "WAVE" chunk identifier | |
s += "666d7420" # "fmt " chunk identifier | |
s += "10000000" # length of chunk, 16 | |
s += "0100" # format code (PCM) | |
s += "0200" # channel |
This file contains hidden or 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
<?php | |
// $db = new PDO($connection_string, $db_user, $db_password); | |
$plan_code = "PLAN_CODE"; | |
$product_status = 200; | |
$page = 1; | |
$fetch = 20; | |
$qry = "CALL `db_billing`.`odp_cm_get_products`('$plan_code', $product_status, $page, $fetch, @total_row_count)"; | |
$stm = $db->prepare($qry); | |
$stm->execute(); |
This file contains hidden or 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
sudo yum install epel-release -y | |
sudo yum install net-tools wget python34 python34-devel python-pip readline java-1.8.0-openjdk -y | |
sudo pip install virtualenvwrapper pip -U | |
echo source /usr/bin/virtualenvwrapper.sh >> ~/.bash_profile | |
mkvirtualenv py3 -p python3 | |
workon py3 | |
sudo pip install ipython |
This file contains hidden or 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
openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr |
This file contains hidden or 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/python | |
# 02/27/2015, Kenial | |
# Just simple scripts for instant use of SQLAlchemy. | |
import sqlalchemy as sa | |
sa.__version__ # '0.9.4' for me | |
# Sample DB connection string | |
# engine = sa.create_engine('postgresql://scott:tiger@localhost/mydatabase') |
This file contains hidden or 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 django | |
from django.contrib.gis.measure import D | |
from django.contrib.gis.geos import * | |
from django.contrib.gis import geos | |
pnt = geos.Point(-122.146, 37.458, srid=4326) | |
pnt.transform(900913) # in meter | |
area = geos.Polygon([ | |
(pnt.x-1, pnt.y-1), | |
(pnt.x+1, pnt.y-1), |
This file contains hidden or 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
-- Spatialite queries test (cached result, total records: 2,178,275) | |
.timer on | |
.header on | |
.separator \t | |
.mode list | |
-- Seems table scan - slowest |
This file contains hidden or 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/python3 | |
# Access in-memory SQLite3 DB asychronously, | |
# using concurrent.futures.thread.ThreadPoolExecutor | |
import datetime | |
import sqlite3 | |
import concurrent.futures | |
RECORD_COUNT = 50000 | |
e = concurrent.futures.thread.ThreadPoolExecutor(max_workers=2) |