Skip to content

Instantly share code, notes, and snippets.

View grasses's full-sized avatar
🎯
Focusing

grasses

🎯
Focusing
View GitHub Profile
#!/usr/bin/python
# -*- coding:utf-8 -*-
from qiniu import *
from Queue import Queue
import pymysql, hashlib, threading, random, sys, json, time, logging
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from Queue import Queue
import threading, random, time
__author__ = 'homeway'
__version__ = '2015.10.01'
class producer(threading.Thread):
@grasses
grasses / AES-256
Created October 6, 2015 11:45
AES-256 for php, with php module mcrypt, for more see: http://php.net/manual/en/function.mcrypt-encrypt.php
<?php
class MCrypt {
private $hex_iv = '00000000000000000000000000000000'; // converted JAVA byte code in to HEX and placed it here
private $key = 'U1MjU1M0FDOUZ.Qz'; //Same as in JAVA
function __construct() {
$this->key = hash('sha256', $this->key, true);
}
function encrypt($str) {
@grasses
grasses / py-cache
Last active October 6, 2015 15:17
Sample python cache
#! /bin/python
# -*- coding: utf-8 -*-
import os, json, time, hashlib
class Cache(object):
def __init__(self, cache_path=None, cache_name=None, cache_extension="cache", expired=3600):
extension = cache_extension.lstrip(".") or "cache"
self.extension = "." + extension
@grasses
grasses / js-cookie-manage
Created November 4, 2015 08:47
js-cookie-manage
@grasses
grasses / nfs-server-for-centos
Last active November 11, 2015 02:56
An nfs install script for centos 6
#!/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
echo "Error: You must be root to run this script, please use root to install nfs"
exit 1
fi
@grasses
grasses / php-logger
Last active November 27, 2015 08:07
<?php
/**
* @package Logger
* @author grasses
* @link http://homeway.me/
* @copyright Copyright(c) 2014
* @version 14.11.20
**/
/**
@grasses
grasses / php.fpm
Last active December 11, 2015 03:33
php-fpm controller for mac, please confirm php-fpm is in your $PATH environment.
#!/bin/sh
param=$1
if [ $(id -u) != "0" ]; then
echo "Error: You must be root to run this script."
exit 1
fi
start()
@grasses
grasses / vimrc
Last active May 14, 2017 13:54
My vim configure
"关闭vim一致性原则
set nocompatible
"设置在编辑过程中右下角显示光标的行列信息
set ruler
"在状态栏显示正在输入的命令
set showcmd
"设置匹配模式
set showmatch
"设置C/C++方式自动对齐
set autoindent
@grasses
grasses / sklearn-decision-tree
Created April 15, 2017 09:24
decision tree test, reading from csv
#!/usr/bin/python
# -*- coding: utf-8 -*-
import pydotplus, csv
import numpy as np
from sklearn import tree, preprocessing
from sklearn.datasets import load_iris
from IPython.display import Image
import matplotlib.pyplot as plt