Skip to content

Instantly share code, notes, and snippets.

View reorx's full-sized avatar
YOLO

Xiao Meng reorx

YOLO
View GitHub Profile
########################################################################
# A library for calling callables with runtime-defined parameters.
#
# Copyright 2005-2011 True Blade Systems, Inc.
#
# 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
#!/bin/bash
#wait for internet connection up to 15 seconds
host=baidu.com
CONNECTED=$(ping -w5 -c1 $host > /dev/null 2>&1 && echo "up" || echo "down")
STOPWATCH=0
while [ "$CONNECTED" = "down" ] && [ $STOPWATCH -lt 15 ]; do
sleep 1;
CONNECTED=$(ping -w5 -c1 $host > /dev/null 2>&1 && echo "up" || echo "down")
let STOPWATCH++
window.onload = function () {
if (window.FileReader) {
var input = document.getElementById("file");
var result = document.getElementById("result");
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
var img = document.getElementById("img");
var width = 100;
canvas.width = width;
input.onchange = function () {
#!/usr/bin/env python
# encoding=utf-8
import sys
from PIL import Image
# char_map = ['#', '@', 'v', '"', '_', '.', ' ']
char_map = ['#', '#', '#', '_', '.', '.', ' ']
; Copyright ?Microsoft Corp.
[Theme]
; Windows 7 - IDS_THEME_DISPLAYNAME_AERO
DisplayName=Bing Dynamic
; Computer - SHIDI_SERVER
[CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\DefaultIcon]
DefaultValue=%SystemRoot%\System32\imageres.dll,-109
document.addEventListener('touchmove', function (e) {
e.preventDefault()
})
var c = document.getElementsByTagName('canvas')[0],
x = c.getContext('2d'),
pr = window.devicePixelRatio || 1,
w = window.innerWidth,
h = window.innerHeight,
f = 90,
q,
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from tornado.ioloop import IOLoop
from tornado.httpclient import AsyncHTTPClient
io_loop = IOLoop.instance()
def handle_resp(resp):
import os
import sys
BASE_PATH = os.path.dirname(__file__)
from django.conf import settings
from django.conf.urls import patterns, url
from django.core.management import execute_from_command_line
from django.shortcuts import render
>>> def foo():
... a = 1
... def foo_a():
... a = 2
... print 'foo_a a:', a
... foo_a()
... print 'foo a:', a
...
>>> foo()
foo_a a: 2
#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid