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
from sqlalchemy import Column, Integer, String | |
from sqlalchemy import create_engine | |
from sqlalchemy.orm import sessionmaker | |
from sqlalchemy.ext.declarative import declarative_base | |
import logging | |
logging.basicConfig() | |
Base = declarative_base() |
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 redis | |
r = redis.Redis() | |
i = 0 | |
chunk_size = 1000 | |
while True: | |
i, keys = r.scan(i, count=chunk_size) | |
if i == 0: | |
break | |
pipeline = r.pipeline() |
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
#!/bin/sh | |
SUFFIX="iconv-all-backup" | |
function convert() | |
{ | |
n_total=0 | |
n_error=0 | |
while read f; do | |
fb="$f.$SUFFIX" |
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
# Usage: | |
# Change profile when using ssh. | |
# You MUST define a profile named 'ForSSH' with diferent settings. | |
# I am using color schemes with different background color. | |
# Then: | |
# $ save as ~/.iterm2.zsh | |
# $ echo ". ~/.iterm2.zsh" >> ~/.zshrc | |
# iTerm2 window/tab color commands | |
# Requires iTerm2 >= Build 1.0.0.20110804 |
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
# Usage: | |
# source iterm2.zsh | |
# iTerm2 window/tab color commands | |
# Requires iTerm2 >= Build 1.0.0.20110804 | |
# http://code.google.com/p/iterm2/wiki/ProprietaryEscapeCodes | |
tab-color() { | |
echo -ne "\033]6;1;bg;red;brightness;$1\a" | |
echo -ne "\033]6;1;bg;green;brightness;$2\a" | |
echo -ne "\033]6;1;bg;blue;brightness;$3\a" |
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
#!/bin/sh | |
for f in "$@" | |
do | |
test ${f: -3} = ".gz" && c="zcat" || c="cat" | |
$c $f | |
done |
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
#!/bin/sh | |
if [ "$#" -lt 1 ]; then | |
echo "Usage: check_gzip <url>" | |
fi | |
b=$(curl "$1" --silent --write-out "%{size_download}\n" --output /dev/null) | |
a=$(curl "$1" --silent -H "Accept-Encoding: gzip,deflate" --write-out "%{size_download}\n" --output /dev/null) | |
if [ "$a" > "$b" ]; then | |
exit 0 |
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
./configure \ | |
--prefix=/data1 \ | |
--sysconfdir=/data1/etc/php \ | |
--with-config-file-path=/data1/etc/php \ | |
--with-config-file-scan-dir=/data1/etc/conf.d \ | |
--with-iconv \ | |
--enable-ftp \ | |
--enable-sockets \ | |
--enable-zip \ | |
--enable-shmop \ |
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
# encoding: utf-8 | |
import asyncore | |
import socket | |
import signal | |
class SignalDispatcher(asyncore.dispatcher): | |
def __init__(self): | |
asyncore.dispatcher.__init__(self) | |
# 0 for read, 1 for write | |
self.pipefd = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM, 0) |
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 | |
$mem = null; | |
$my = null; | |
/** | |
* Create tables | |
* @param array $tbl_num_list example: [100, 100, 100] | |
*/ | |
function create_tables ($tbl_num_list) { |
NewerOlder