Skip to content

Instantly share code, notes, and snippets.

import random
import matplotlib.pyplot as plt
import numpy as np
import functools
import time
def trunc_gauss(mu, sigma, bottom, top):
a = random.gauss(mu,sigma)
while (bottom <= a <= top) == False:
@jankuo
jankuo / Dockerfile
Last active September 24, 2017 19:28
############################################################
# Dockerfile to build sandbox for executing user code
# Based on Ubuntu
############################################################
FROM chug/ubuntu14.04x64
MAINTAINER ASAD MEMON, OSMAN ALI
# Update the repository sources list
RUN echo "deb http://mirrors.163.com/ubuntu trusty main universe" > /etc/apt/sources.list
<?php
class Hex62
{
const base = 62;
const letters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
public static function decode( $str )
{
$ret = 0;
upstream easy-peasy{
server 127.0.0.1:8080;
}
server{
listen 80 default_server;
location / {
proxy_pass_header Server;
proxy_set_header Host $host;
proxy_redirect off;
/* ivan(a.t)mysqlab.net */
package main
import (
"syscall"
"os"
"log"
)
func daemon(nochdir, noclose int) int {
"""
tornado_static is a module for displaying static resources in a Tornado web
application.
It can take care of merging, compressing and giving URLs ideal renamings
suitable for aggressive HTTP caching.
(c) [email protected]
"""
"""
http://saepy.sinaapp.com/topic/24/Tornado%E4%B8%8A%E4%BC%A0%E6%96%87%E4%BB%B6%E7%A4%BA%E4%BE%8B
在bcore的开发过程中,涉及到上传文件有两个地方,一个是相册,一个是文章图文混排。这里作为一个备忘。罗列一些关键点:
文件上传的内容体在tornado.web.RequestHandler.request.files属性中,并且是以数组形式存放的。
使用临时文件存储时,在write完成后要记着把seek重置到文件头。要不然文件无法被读取。
再使用Image模块的thumbnail方法进行缩放时,resample=1作为重载渲染参数能够有效的使图片平滑,消除锯齿。
#! /usr/bin/env python
import sys
import os
import time
import atexit
from signal import SIGTERM
#!/bin/sh
#nginx pid
nginx_pid=`ps aux|grep -E 'nginx: master process' | grep -v 'grep' | awk '{print $2}'`
#日志文件存放目录
nginx_log_store_path="dir-where-log-file-place/"
#日志文件名(去除最后.log的)
nginx_log_basename="log-file-name"
#日志文件
nginx_log_file=${nginx_log_store_path}${nginx_log_basename}.log
package main
import (
"fmt"
"strings"
"database/sql"
)
const (
SQL_INSERT = "INSERT INTO %s (%s) VALUES (%s)"