Skip to content

Instantly share code, notes, and snippets.

View cloverstd's full-sized avatar
🀄
Working for living

cloverstd cloverstd

🀄
Working for living
View GitHub Profile
@ldong
ldong / Vagrantfile_ubuntu
Created August 26, 2014 16:56
vagrant file for ubuntu
# -*- mode: ruby -*-
# vi: set ft=ruby :
file_location = '~/VMs/ubuntu/src'
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
#!/usr/bin/env python
# encoding: utf-8
"""
Usage:
fab deploy:appname
"""
from fabric.api import env, run, cd, local, put
env.hosts = ['myserver.com']
env.user = 'eric'
@taichunmin
taichunmin / aliyun.sources.list
Created February 11, 2015 08:17
阿里雲 Ubuntu 14.04 的 apt-get 設定 sources.list
# deb http://mirrors.aliyun.com/ubuntu trusty main restricted
# deb http://mirrors.aliyuncs.com/ubuntu trusty main restricted
# deb http://mirrors.aliyun.com/ubuntu trusty-updates main restricted
# deb http://mirrors.aliyuncs.com/ubuntu trusty-updates main restricted
# deb http://security.ubuntu.com/ubuntu trusty-security main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirrors.aliyun.com/ubuntu trusty main restricted
@tonyseek
tonyseek / contacts-notify.py
Created July 13, 2013 06:32
批量发短信通知同学更换号码
#-*- coding:utf-8 -*-
import time
import subprocess
"""
select last_name || "" || middle_name || "" || first_name as name, mobile_phone, other_phone from contacts where categories like "%通讯录%" and (mobile_phone <> '' or other_phone <> '')
"""
people = [
@kkung
kkung / app.py
Created May 27, 2011 09:34
Flask, session store in memcached
from flask import Flask, request, session, url_for, redirect, \
render_template, abort, g, flash
from werkzeug.contrib.sessions import Session, SessionStore
from cPickle import HIGHEST_PROTOCOL
from random import random
from flask import json
class MemcachedSessionStore(SessionStore):
def __init__(self, servers=None, key_prefix=None, default_timeout=300):
@YCF
YCF / sqlite2json.go
Created March 2, 2017 11:49
查询数据库输出为json的例子
package main
import (
"database/sql"
"encoding/json"
"fmt"
"net/http"
"strings"
"github.com/go-ini/ini"
@hustlzp
hustlzp / process_image.py
Last active January 21, 2018 12:10
将Flask中上传的图片居中裁剪为正方形、缩放、保存
import os
import uuid
from PIL import Image
from flask.ext.uploads import extension
def random_filename():
"""生成伪随机uuid字符串,用做文件名"""
return str(uuid.uuid4())
@bg5sbk
bg5sbk / http_timeout.go
Last active February 1, 2018 15:50
How to set timeout for http.Get() in golang.
//
// How to set timeout for http.Get() in golang
//
package main
import (
"io"
"io/ioutil"
"log"
"net"
@gnpkrish
gnpkrish / tornado_websocket_ee.py
Created January 15, 2014 12:23
Realtime Communicating with front-end using simple EventEmitter. With use of Tornado + Websocket.
"""
This is a simple example of WebSocket + Tornado + Simple EventEmitters usage.
Thanks to pyee by https://github.com/jesusabdullah
@Author:: Narayanaperumal G <gnperumal@gmail.com>
"""
import tornado.httpserver
import tornado.websocket
import tornado.ioloop
import tornado.web
from collections import defaultdict
@xianyunwuxin
xianyunwuxin / simple_websocket.py
Created December 7, 2011 01:54
Make Flask work with Tornado.websocket
from flask import Flask
app=Flask(__name__)
@app.route('/')
def index():
return """
<span id="now">loading<span>
<script type="text/javascript">
window.WebSocket=window.WebSocket || window.MozWebSocket || false;