Skip to content

Instantly share code, notes, and snippets.

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"}
@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:
@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 / 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 / rdf
Created December 1, 2010 09:52
Show diff between current and specified revision's one on Subversion
#!/bin/bash
TEMPFILE=/var/tmp/tmptxt
DIFF=diffmerge
if [ $# -ne 2 ]; then
echo "usage:"$0" <REVISION> <FILE>" 1>&2
exit 1
fi
@tmiz
tmiz / cpuvender.c
Created December 9, 2010 12:07
Get x86 CPU Vender and Brand Name
//!(C)tmiz.net
#include <stdio.h>
#define X86_VENDERNAME_ARRAY_LENGTH 13
#define X86_BRANDNAME_ARRAY_LENGTH 49
extern void GetX86CPUVenderName(char*outVendername);
extern void GetX86CPUBrandName(char*brandname);
int main() {
char vender[X86_VENDERNAME_ARRAY_LENGTH];
@tmiz
tmiz / YouTubeAutoRec.scpt
Created February 19, 2011 03:18
Sample Apple Script for SimplyRec + ChromeLauncherWithExtraAudio with Google Chrome
-- Sample Apple Script for SimplyRec + ChromeLauncherWithExtraAudio with Google Chrome
-- SimplyRec http://tg.tmiz.net/softwares/sr/index-e.html
-- ChromeLauncherWithExtraAudio http://tg.tmiz.net/softwares/clwea/
-- Google Chrome for Mac http://www.google.co.jp/chrome/
-- SoundFlower http://code.google.com/p/soundflower/
-- This scirpt can be executed by iCal and Automator, Apple Script Editor
-- Please select input device "SoundFlower" on SimplyRec before executing.
tell application "ChromeLauncherWithExtraAudio"
@tmiz
tmiz / C_quiz_1.c
Created March 8, 2011 08:01
C QUIZ 001_01
#include <stdio.h>
#define ELEMENTSNUM (sizeof(array) / sizeof(array[0]))
int array[] = {10,20,30,40,50,60,70};
int main()
{
int d;
for(d=-1;d <= (ELEMENTSNUM-2);d++)
printf("%d\n",array[d+1]);
return 0;
}
@tmiz
tmiz / c_quiz.c
Created March 8, 2011 07:52
C Quiz 001
#include <stdio.h>
int main() {
if ((int) -1 < (unsigned int) 5) {
printf("(A)\n");
} else {
printf("(B)\n");
}
return 0;
}
// Which is output?
@tmiz
tmiz / addday.c
Created April 16, 2011 15:23
n日後
#include <stdio.h>
#include <time.h>
struct mydate { int year,month,day; };
int addDay(struct mydate *d, int n)
{
struct tm birthday = {0,0,0,d->day,d->month,d->year-1900,0,0,0,0,NULL};
time_t birthday_sec = mktime(&birthday);
birthday_sec += (n*24*60*60);
struct tm *pHA = localtime( &birthday_sec );