Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# encoding: utf-8
import os
import time
import logging
import hashlib
from sqlalchemy import create_engine, ForeignKey, Column, Integer, String, Text, DateTime,\
@swshan
swshan / exerices.000.py
Created August 16, 2016 08:31
实现一个装饰器
def simple_decorator(f):
def wrapper():
print "Entering Function"
f()
print "Exit"
return wrapper
@swshan
swshan / flask.url
Created August 17, 2016 08:56
flask 实现子域名
# -*- coding: utf-8 -*-
from flask import Flask, Blueprint, request
app = Flask(__name__)
app.config.DEBUG = True
#app.url_map.default_subdomain = 'www'
app.config['SERVER_NAME'] = 'example.com'
#coding: utf-8
__author__ = "swsend"
import json
import hashlib
import datetime
from flask import Flask, request, jsonify, Response, render_template
@swshan
swshan / Rectangle.java
Created February 15, 2017 09:00
Java 练习
package Rectangle;
class myRectangle {
double width = 1.0;
double height = 1.0;
myRectangle() {
}
@swshan
swshan / lg.java
Created March 6, 2017 09:38
算法4书本练习 1.1.14
import java.util.*;
// 给一个N的正帧数 返回不大于Log2N的最大整数
public class Log {
public static int lg(int N) {
double log2n = N / 2; // base is 2
int result = 1;
while ( result < log2n) {
package net;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.*;
public class Server {
package main
import (
"os/exec";
"fmt";
"bytes";
)
// 来自 http://xinqiu.me/2017/05/09/a-byte-of-go/ 的练习代码
package main
import "fmt"
func main() {
s := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
a := s[3:6]
b := a[1:2]
@swshan
swshan / heapSort.java
Created June 20, 2017 09:22
堆排序 摘自维基百科
package main;
import java.util.Arrays;
public class heapSort {
private int[] arr;
public HeapSort(int[] arr){
this.arr = arr;