Skip to content

Instantly share code, notes, and snippets.

@tmiz
tmiz / myonetime
Last active December 30, 2016 07:21
One time pass word
#!/usr/bin/env python
import shelve
import sys,os
import onetimepass as otp
def usage():
print "myonetime <domain> <secret> : register secret"
print "myonetime <domain> : create one time password"
@tmiz
tmiz / test.py
Created December 25, 2015 18:08
import json
import numpy as np
from sets import Set
with open("BusinessSpending.json") as f:
data = json.load(f, 'latin-1')
entries = data["raw_data"]
keys = []
for entry in entries:
keys = entry.keys()
from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods.posts import NewPost
from wordpress_xmlrpc.methods import posts
import os.path
import sys
def read_config(filepath):
with open(filepath) as f:
lines = f.readlines()
return lines[0:3]
@tmiz
tmiz / gist:9d1b36d1e62ac5c9841f
Created April 9, 2015 02:36
Avoid file name collisions for machine learning or other use cases
for FILE in *.JPG; do mv $FILE `sha1sum $FILE | sed -e "s/ /_/g"`; done
@tmiz
tmiz / Perceptron.cpp
Last active August 29, 2015 14:12
Perceptron
#include <stdio.h>
#include <stdlib.h>
#include "Perceptron.h"
#include <math.h>
const float c = 0.01;
Perceptron::Perceptron(int n) {
weights = new float[n];
@tmiz
tmiz / MeanAndStddev
Created June 26, 2014 14:09
Mean And Stddev
import math
class MeanAndStddev:
def __init__(self):
self.values = [];
def append(self, val):
self.values.append(val * 1.0)
def mean(self):
sumValue = 0
for a in self.values:
morse = {".-":"A","-...":"B","-.-.":"C","-..":"D",".":"E","..-.":"F","--.":"G","....":"H","..":"I",".---":"J","-.-":"K",".-..":"L","--":"M","-.":"N","---":"O",".--.":"P","--.-":"Q",".-.":"R","...":"S","-":"T","..-":"U","...-":"V",".--":"W","-..-":"X","-.--":"Y","--..":"Z",".----":"1","..---":"2","...--":"3","....-":"4",".....":"5","-....":"6","--...":"7","---..":"8","----.":"9","-----":"0"}
$(function(){
function startRotate() {
$("#reload").css("-webkit-animation-name", "loadingRotate");
$("#reload").css("-webkit-animation-duration", "1s");
$("#reload").css("-webkit-animation-iteration-count","infinite");
$("#reload").css("-webkit-animation-play-state", "running");
}
function stopRotate() {
$("#reload").css("-webkit-animation-play-state", "paused");
@tmiz
tmiz / st
Last active December 11, 2015 14:58
I use Sublime Text through st command.
#!/bin/bash
if ! [ -f $1]
then
touch $1
fi
open -a /Applications/Sublime\ Text\ 2.app $1
@tmiz
tmiz / gist:4353968
Created December 21, 2012 16:49
How to build the specified revision of Chromium.
At first, install xcode.
And execute following commands.
XXXXXX is revision number.
$ svn co http://src.chromium.org/svn/trunk/tools/depot_tools
$ export PATH=$PATH:`pwd`/depot_tools
$ gclient config http://src.chromium.org/svn/trunk/src
$ gclient sync --revision src@XXXXXX
$ cd src/
$ GYP_GENERATORS=make GYP_DEFINES=mac_sdk=10.7 ./build/gyp_chromium