Skip to content

Instantly share code, notes, and snippets.

@tsu-nera
tsu-nera / speech_recognition.py
Created August 25, 2018 13:09
音声認識スクリプト
import speech_recognition as sr
r = sr.Recognizer()
mic = sr.Microphone()
with mic as source:
r.adjust_for_ambient_noise(source)
audio = r.listen(source)
print(r.recognize_google(audio, language='ja-JP'))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tsu-nera
tsu-nera / xgb_tb.py
Created March 30, 2018 16:00
xgboost visualization with tensorboard
from sklearn.datasets import load_boston
import pandas as pd
import xgboost as xgb
from tensorboard_logger import configure, log_value
from sklearn.cross_validation import train_test_split
def logspy(env):
log_value("train", env.evaluation_result_list[0][1], step=env.iteration)
@tsu-nera
tsu-nera / google-home-jihou.py
Last active February 9, 2018 14:56
google-homeで時報
import pychromecast
def play_mp3(mp3_url):
cast.wait()
mc = cast.media_controller
mc.play_media(mp3_url, 'audio/mp3')
mc.block_until_active()
chromecast_name = "つーねらの部屋"
chromecasts = pychromecast.get_chromecasts()
#!/usr/bin/python2
import subprocess
import time
exec_path = "/home/tsu-nera/tmp/a.out"
core_path = "/home/tsu-nera/tmp/core"
bt_path = "/home/tsu-nera/tmp/backtrace"
core_time = subprocess.check_output(['ls', '-l', core_path]).split()
bt_time = subprocess.check_output(['ls', '-l', bt_path]).split()
#!/usr/bin/python2
import subprocess
import re
try:
res = subprocess.check_output(['ps', '-e'])
except:
print "Error."
lines = res.splitlines()[1:]
pidname = dict()
@tsu-nera
tsu-nera / rpart.ipynb
Last active October 8, 2017 03:22
kaggle titanic rpart gridsearch w/ mlr
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tsu-nera
tsu-nera / CommandSample3.java
Created September 16, 2017 10:34
Command Pattern with lambda
package gof.command;
import java.util.Stack;
class CommandSample3 {
////////////////////
// Command
////////////////////
abstract public static class Command {
@tsu-nera
tsu-nera / remote_ctl_pub.py
Created July 25, 2017 15:44
Mindstorms ev3 control with Leap Motion
import Leap, sys
import paho.mqtt.client as mqtt
from Leap import CircleGesture
client = mqtt.Client()
client.connect("localhost",1883,60)
class SampleListener(Leap.Listener):
def on_connect(self, controller):
controller.enable_gesture(Leap.Gesture.TYPE_CIRCLE);
@tsu-nera
tsu-nera / remote_ctl_pub.py
Last active July 25, 2017 12:46
mindstorms ev3 remote control with keyboard by using mqtt, watch this! https://youtu.be/kl_07BWGNWo
#!/usr/bin/env python3
import paho.mqtt.client as mqtt
from pynput.keyboard import Key, Listener
client = mqtt.Client()
client.connect("localhost",1883,60)
def on_press(key):
print("{} is pressed".format(key))