Skip to content

Instantly share code, notes, and snippets.

View zs1621's full-sized avatar
💭
I may be slow to respond.

zs1621

💭
I may be slow to respond.
View GitHub Profile
@zs1621
zs1621 / papa.py
Created November 26, 2012 09:03
python save picture(papa)
#!/usr/bin/env python
#-*-coding="utf-8"-*-
#import MySQLdb
import httplib
import urllib
import simplejson
import time
import os
def papa(url):
/*!
* Connect - logger
* Copyright(c) 2010 Sencha Inc.
* Copyright(c) 2011 TJ Holowaychuk
* MIT Licensed
*/
/**
* Module dependencies.
*/
#!/usr/bin/env python
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
@zs1621
zs1621 / gist:6291586
Last active December 21, 2015 10:19
why the check_palin() function return 'None', not True or False
def check_palin(lister):
if len(lister) <= 1 :
print 'True'
return True
else:
if lister[0] == lister[-1]:
lister.pop()
del lister[0]
check_palin(lister)
else:
@zs1621
zs1621 / reset_myql_root_secret
Created October 15, 2013 06:18
重置mysql root 密码
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
# Check if user is root
if [ $(id -u) != "0" ]; then
printf "Error: You must be root to run this script!\n"
exit 1
fi
@zs1621
zs1621 / reident
Created November 12, 2013 07:46
reindent the python from spaces tab 8 to spaces tab 4
#! /usr/bin/env python
# Released to the public domain, by Tim Peters, 03 October 2000.
"""reindent [-d][-r][-v] [ path ... ]
-d (--dryrun) Dry run. Analyze, but don't make any changes to, files.
-r (--recurse) Recurse. Search for all .py files in subdirectories too.
-n (--nobackup) No backup. Does not make a ".bak" file before reindenting.
-v (--verbose) Verbose. Print informative msgs; else no output.
@zs1621
zs1621 / node_mongodb_pool.js
Created December 7, 2013 02:26
test node-pool module
var http = require('http');
var mongodb = require('mongodb');
var poolModule = require('generic-pool');
var pool = poolModule.Pool({
name: 'mongodb',
create: function(callback) {
mongodb.MongoClient.connect('mongodb://localhost/test', {server: {poolSize: 1}}, function(err, db) {
callback(err, db);
});
import unittest, os, os.path, sys, urllib
import tornado.database
import tornado.options
from tornado.options import options
from tornado.testing import AsyncHTTPTestCase
# add application root to sys.path
APP_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(os.path.join(APP_ROOT, '..'))
#!/bin/env python
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
import tornado.httpclient
import tornado.gen
from tornado.concurrent import run_on_executor
#if < python3.2 you need do `sudo pip install futures`
@zs1621
zs1621 / create_lat_lng.py
Created January 14, 2014 06:13
script create 200million lat-lng data to test
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#
# Author : Rhapsodyzs
# E-mail : zs1213yh@gmail.com
# Date : 14/01/08 11:01:17
# Desc :
#
import MySQLdb
import random