Skip to content

Instantly share code, notes, and snippets.

@wangyangkobe
wangyangkobe / Fibonacci.py
Created March 2, 2017 01:05
Python斐波那契数列的实现
def fabinacci(n):
x,y = 0,1
for index in range(n):
x,y = x+y, x
return x
def cache(fun):
_cache = {}
def _inner(n):
if n in _cache:
@wangyangkobe
wangyangkobe / parallel_accumulate.cpp
Created December 15, 2016 05:44
a parallel version of std::accumulate.
#include <thread>
#include <iostream>
#include <memory>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std;
template<typename Iterator, typename T>
@wangyangkobe
wangyangkobe / foo.log
Created September 8, 2016 04:47 — forked from ibeex/foo.log
Flask logging example
A warning occurred (42 apples)
An error occurred
@wangyangkobe
wangyangkobe / main.cpp
Created July 14, 2016 00:29
Akuna Capital (Shanghai) C++ Coding Challenge For Regular Program
#include <iostream>
#include <fstream>
#include <stdint.h>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
#pragma pack(push)
@wangyangkobe
wangyangkobe / daemon.py
Created February 29, 2016 07:41 — forked from jamiesun/daemon.py
一个python守护进程的例子
#! /usr/bin/env python2.7
#encoding:utf-8
#@description:一个python守护进程的例子
#@tags:python,daemon
import sys
import os
import time
import atexit
from signal import SIGTERM
@wangyangkobe
wangyangkobe / tcp_server.erl
Created September 6, 2015 09:05
The tcp server of Erlang.
-module(tcp_server).
-compile(export_all).
start(Port) ->
Pid = spawn_link(fun()->
{ok, ListenSocket} = gen_tcp:listen(Port, [binary, {active, false}]),
spawn(fun() -> acceptor(ListenSocket) end),
timer:sleep(infinity)
@wangyangkobe
wangyangkobe / waterline_mongo.js
Last active August 29, 2015 14:25
How to use waterline for MongoDB.
var express = require('express');
var app = express();
var Waterline = require('waterline');
var sailsMongoAdapter = require('sails-mongo');
var orm = new Waterline();
var bodyParser = require('body-parser');
var bcrypt = require('bcrypt');
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json())
@wangyangkobe
wangyangkobe / cba_build_package
Last active August 29, 2015 14:18
cba_build_package
#!/vobs/ims/common/tools_root/cdfrt/dist/unitprep/TDP-Python-CXS1040058-R2A01/contained/DT_Python/bin/python
import os
from subprocess import Popen, PIPE
import traceback
import threading
import time
import sys
AIT_DIR = r"/vobs/ims/sbg/src/delivery/sgcPSR/SiteConfigurationPackage/AIT"
@wangyangkobe
wangyangkobe / extract.js
Last active August 29, 2015 14:16
extract *.tar.gz for SBG code.
var path = require('path');
var fs = require('fs');
var tarball = require('tarball-extract');
var rimraf = require("rimraf");
var srcDir = "C:\\Users\\elqstux\\Desktop"
var dstDir = "C:\\Users\\elqstux\\Desktop\\SBG Code\\src";
var files = ["SOM_CRA1190221.tar.gz", "SYF_CRA1190070.tar.gz", "auto.tar.gz", "SGC_CRA1190962.tar.gz"];
@wangyangkobe
wangyangkobe / Pmw.EntryField.py
Last active August 29, 2015 14:15
The exercise for Pmw.EntryField.
from Tkinter import *
import time, string
import Pmw
class EntryValidation:
def __init__(self, master):
now = time.localtime(time.time())
self._date = Pmw.EntryField(master, labelpos='w', label_text='Date (mm/dd/yy):', value = "%d%d%d" % (now[1], now[2], now[0]),
validate={'validator':'date', 'format':'mdy', 'separator':'/'})