Skip to content

Instantly share code, notes, and snippets.

@wangyangkobe
wangyangkobe / Fibonacci.py
Created Mar 2, 2017
Python斐波那契数列的实现
View Fibonacci.py
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 Dec 15, 2016
a parallel version of std::accumulate.
View parallel_accumulate.cpp
#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 Sep 8, 2016 — forked from ibeex/foo.log
Flask logging example
View foo.log
A warning occurred (42 apples)
An error occurred
@wangyangkobe
wangyangkobe / main.cpp
Created Jul 14, 2016
Akuna Capital (Shanghai) C++ Coding Challenge For Regular Program
View main.cpp
#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 Feb 29, 2016 — forked from jamiesun/daemon.py
一个python守护进程的例子
View daemon.py
#! /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 Sep 6, 2015
The tcp server of Erlang.
View tcp_server.erl
-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 Aug 29, 2015
How to use waterline for MongoDB.
View waterline_mongo.js
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())
View 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 Aug 29, 2015
extract *.tar.gz for SBG code.
View extract.js
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 Aug 29, 2015
The exercise for Pmw.EntryField.
View Pmw.EntryField.py
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':'/'})