Skip to content

Instantly share code, notes, and snippets.

@shnya
shnya / gist:67e9199e775b612ed7791491b8702872
Created November 13, 2016 05:53
jupyter notebook 初期設定
import matplotlib
import matplotlib.pyplot as plt
matplotlib.rc('font', family='MS Gothic')
%matplotlib inline
plt.plot([1,2,3,4])
plt.title(u'日本語')
plt.show()
# 利用可能なフォント一覧
@shnya
shnya / gist:3d4c1cb542f687619c65
Created June 11, 2015 03:27
Amazon S3 batch change script
#!/bin/bash
for FILE in `s3cmd ls -r s3://auone-search/spfeature/ | awk '{print $4}'`
do
echo $FILE
s3cmd modify --add-header=Cache-Control:max-age=2592000 $FILE
done
#!/usr/bin/python
import tempfile
import sys
import urllib2
import shutil
import json
import base64
def request(api_key, data):
@shnya
shnya / gist:4716334
Created February 5, 2013 18:02
既にブロック情報がない時にデータノードのブロックは削除されるかどうか。
DataNodeの挙動について
DataNode.java
DataNode#main
-> DataNode#secureMain
# BlockPoolManagerの初期化まで
-> DataNode#createDataNode
-> DataNode dn = DataNode#instantiateDataNode
@shnya
shnya / gist:1717433
Created February 1, 2012 15:04
SRM 327 Div2 Hard
int setbit(int x, int n){
return x | 1 << n;
}
bool testbit(int x, int n){
return (x & 1 << n) != 0;
}
void printbit(int x){
for(size_t i = 0; i < sizeof(int) * 8; i++){
@shnya
shnya / gist:1639951
Created January 19, 2012 12:57
SRM 156 SmartElevator
class SmartElevator {
vector<int> arrive,start,dest;
int rec(int pos, int t, vector<bool> &startVisited, vector<bool> &destVisited){
if(count(destVisited.begin(),destVisited.end(),true) == (int)dest.size()){
return t;
}
int minn = 1E+8;
for(size_t i = 0; i < start.size(); i++){
if(startVisited[i]) continue;
@shnya
shnya / gist:1626580
Created January 17, 2012 13:10
SRM453 Div1 Easy TheBasketballDivOne
class TheBasketballDivOne {
set<vector<int> > s;
int n,m;
void check_and_insert(vector<vector<bool> > &v){
vector<int> v2;
for(int i = 0; i < n; i++){
int cnt = 0;
for(int j = 0; j < 2*n; j++){
if(v[i][j]) cnt++;
@shnya
shnya / MagicWords.cpp
Created May 26, 2011 11:24
SRM 433 Div1 Easy
class MagicWords
{
void permute0(size_t i, vector<int> &used, vector<int> &path, const vector<int> &v, vector<vector<int> > &result){
if(i == v.size()){
result.push_back(path);
return;
}
for(int j = 0; j < int(v.size()); j++){
if(used[j] != 1){
used[j] = 1;
@shnya
shnya / debug.cc
Created May 25, 2011 19:37
debug
struct DDMY{ ostringstream o; template<class T>DDMY& operator,(const T &t){o<<t<<",";return *this;} string operator*(){ return o.str().substr(0,o.str().size()-1); } };
#define debug(args...) cout<<"("#args")=("<< *(DDMY(),args)<<") (L"<<__LINE__<<")"<<endl
template<class T> std::ostream &operator<<(std::ostream &o,const std::vector<T> &v)
{ o << "["; for(std::size_t i=0;i<v.size();i++) o << v[i] << (i < v.size()-1 ? ",":""); return o << "]"; }
template<class T,class U> std::ostream &operator<<(std::ostream &o,const std::pair<T,U> &v)
{ return o << v.first << ":" << v.second; }
template<class T,class U> std::ostream &operator<<(std::ostream &o,const std::map<T,U> &v)
{ o << "{"; typename std::map<T,U>::const_iterator i=v.begin(),j=i;++j;for(;i!=v.end();++i,++j) o << *i << (j!=v.end()? ",":""); return o << "}"; }
template<class T> std::ostream &operator<<(std::ostream &o,const std::set<T> &v)
{ o << "{"; typename std::set<T>::const_iterator i=v.begin(),j=i;++j;for(;i!=v.end();++i,++j) o << *i << (j!=v.end()? ",
@shnya
shnya / time.py
Created May 25, 2011 14:56
time.cgi
#!/usr/bin/env python
import math
def f(MP,t):
return MP * (0.3 + ((0.7 * 75.0 * 75.0) / (10.0 * t * t + 75.0 * 75.0)))
def check(y,SCORE,MP):
if SCORE > f(MP,y):
return True