This file contains 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
/* | |
* sor_iteration.c | |
* | |
* Created on: Jul 7, 2014 | |
* Author: du | |
*/ | |
#include <stdio.h> | |
#include <string.h> | |
#include <math.h> |
This file contains 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
#!/usr/bin/env pypy | |
# -*- coding: utf-8 -*- | |
''' | |
Created on 2013/09/03 | |
@author: Shiqiao Du | |
run | |
cat <input> | ./mapred.py -m mapper | sort | ./mapred.py -m reducer | |
''' |
This file contains 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
$ conda remove readline | |
$ pip install readline |
This file contains 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
# postgresユーザーのパスワードを変更 | |
sudo passwd postgres | |
# 新しいユーザーを作成 | |
sudo -u postgres createuser du -P --interactive | |
# DBの作成 | |
create databese test_db owner du |
This file contains 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 pandas as pd | |
import sqlalchemy | |
from sklearn import datasets | |
# create iris dataframe | |
iris = datasets.load_iris() | |
iris_data = pd.DataFrame(iris.data) | |
iris_data.columns = ["sep_length", "sepal_width","petal_length","petal_width" ] | |
iris_data["species"] = map(lambda i:iris.target_names[i], iris.target) |
This file contains 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
from gdata.spreadsheet import service, text_db | |
client = text_db.DatabaseClient(username=user, password=password) | |
db = client.GetDatabases(name=spreadsheet_name)[0] | |
table = db.GetTables(name=worksheet_name)[0] | |
# notice that even if it is shown as some thing like "DD/MM/YY" in the table, timestamp or date should be YYYY-MM-DD | |
for row in table.FindRecords("timestamp > 2014-10-01"): | |
print row.content |
This file contains 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
# -*- coding: utf-8 -*- | |
import datetime | |
from numpy import asarray, ceil | |
import pandas | |
import rpy2.robjects as robjects | |
def stl(data, ns, np=None, nt=None, nl=None, isdeg=0, itdeg=1, ildeg=1, | |
nsjump=None, ntjump=None, nljump=None, ni=2, no=0, fulloutput=False): |
This file contains 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
%matplotlib inline | |
import numpy as np | |
import pandas as pd | |
from matplotlib import pyplot as plt | |
plt.style.use("ggplot") | |
plt.rcParams["font.size"] = 14 | |
plt.rcParams["figure.figsize"] = 10, 6 |
This file contains 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
$(function () { | |
$(document).ready(function () { | |
// Build the chart | |
Highcharts.setOptions({ | |
colors: ['#4572A7', '#AA4643', '#89A54E', '#80699B', '#3D96AE', '#DB843D', '#92A8CD', '#A47D7C', '#B5CA92', '#0000cd', '#dda0dd'] | |
}); | |
$('#container').highcharts({ |
This file contains 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 colorHist(img): | |
size = img.size / 3.0 | |
ret = {} | |
color = ('b','g','r') | |
for i,col in enumerate(color): | |
histr = cv2.calcHist([img],[i],None,[100],[0,256]) | |
ret[col] = histr.flatten() / size | |
return ret |
OlderNewer