This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This is the solution for the test | |
* https://oj.leetcode.com/problems/climbing-stairs/ | |
* It follows a cached Fibonacci startegy. | |
*/ | |
public class Solution { | |
public void Init(int n) | |
{ | |
nsteps = new int[n+1]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Fetch all the FOMC meeting dates(since 1936) from the official website of FOMC. | |
The dates are separated in two parts | |
- 2010 - 2016 on https://www.federalreserve.gov/monetarypolicy/fomccalendars.htm | |
- Before 2010 on https://www.federalreserve.gov/monetarypolicy/fomc_historical.htm, this part contains some code in javascript. | |
""" | |
from urllib import urlopen |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Plotting functions | |
""" | |
import plotly.plotly as py | |
import plotly.graph_objs as go | |
def plot_time_series(df, title=None): | |
trace = go.Scatter(x=df.index, y=df) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Numerical methods | |
""" | |
import numpy as np | |
from sklearn.datasets.samples_generator import make_regression | |
import pylab | |
from scipy import stats | |
def predict(x, theta): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Edited on 21 June, Alice Wang | |
## To build the docker image | |
## $ cd . | |
## $ docker build -t fc . | |
FROM debian:8.3 | |
RUN DEBIAN_FRONTEND=noninteractive apt-get update --fix-missing | |
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y python2.7 python2.7-dev pkg-config | |
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y libxml2-dev libxslt-dev python-lxml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def autocorr(x): | |
# auto correlation | |
# from http://tinyurl.com/afz57c4 | |
result = np.correlate(x, x, mode='full') | |
result = result / np.max(result) | |
return result[result.size / 2:] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
To transfer and fetch the data from server | |
""" | |
import os | |
import paramiko | |
class InternalSSHClient(object): | |
""" | |
Examples |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections | |
lst = [1, 3, 1, 4, 2, 5, 3, 4, 3] | |
cnt = collections.Counter(lst) | |
cnt.most_common(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# inheritance vs delegation | |
# http://www.jguru.com/faq/view.jsp?EID=27916 |
OlderNewer