Skip to content

Instantly share code, notes, and snippets.

tmiz / myonetime
Last active Dec 30, 2016
One time pass word
View myonetime
#!/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"
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 / gist:9d1b36d1e62ac5c9841f
Created Apr 9, 2015
Avoid file name collisions for machine learning or other use cases
View gist:9d1b36d1e62ac5c9841f
for FILE in *.JPG; do mv $FILE `sha1sum $FILE | sed -e "s/ /_/g"`; done
tmiz / Perceptron.cpp
Last active Aug 29, 2015
View Perceptron.cpp
#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 / MeanAndStddev
Created Jun 26, 2014
Mean And Stddev
View MeanAndStddev
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:
View morse
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"}
View expected behavior
function startRotate() {
$("#reload").css("-webkit-animation-name", "loadingRotate");
$("#reload").css("-webkit-animation-duration", "1s");
$("#reload").css("-webkit-animation-play-state", "running");
function stopRotate() {
$("#reload").css("-webkit-animation-play-state", "paused");
tmiz / st
Last active Dec 11, 2015
I use Sublime Text through st command.
View st
if ! [ -f $1]
touch $1
open -a /Applications/Sublime\ Text\ $1
tmiz / gist:4353968
Created Dec 21, 2012
How to build the specified revision of Chromium.
View gist:4353968
At first, install xcode.
And execute following commands.
XXXXXX is revision number.
$ svn co
$ export PATH=$PATH:`pwd`/depot_tools
$ gclient config
$ gclient sync --revision src@XXXXXX
$ cd src/
$ GYP_GENERATORS=make GYP_DEFINES=mac_sdk=10.7 ./build/gyp_chromium