Skip to content

Instantly share code, notes, and snippets.

View remore's full-sized avatar

Kay(Kéi) Sawada remore

View GitHub Profile
@remore
remore / Dockerfile
Created September 8, 2015 02:29
A Dockerfile for antiboredom/audiogrep
FROM cellofellow/ffmpeg
RUN apt-get update
RUN apt-get install -y software-properties-common pocketsphinx-utils pocketsphinx-hmm-wsj1 pocketsphinx-lm-wsj git python python-pip
# Installing audiogrep
RUN git clone https://github.com/kevinhughes27/audiogrep.git
RUN cd audiogrep && pip install -r requirements.txt
RUN chmod +x audiogrep/audiogrep.py
RUN cp audiogrep/audiogrep.py /usr/bin/audiogrep
@remore
remore / Dockerfile
Created June 9, 2015 15:29
A Dockerfile to create grpc-common deployed ubuntu14.04 instance
FROM ubuntu:14.04
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN apt-get -y update
RUN apt-get -y dist-upgrade
RUN apt-get -y install python-software-properties software-properties-common git-core curl wget gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
RUN add-apt-repository -y ppa:brightbox/ruby-ng
RUN apt-get -y update
RUN apt-get -y install ruby2.1 ruby2.1-dev
#ENV PATH "/root/.rbenv/shims:~/.rbenv/bin:$PATH"
@remore
remore / parse.php
Last active August 29, 2015 14:03
toy scripts for ego search which support php >5.2 and up. usage: $./twitter_search.sh | php parse.php
<?php
$result = json_decode(file_get_contents('php://stdin'));
$dir = realpath(dirname(__FILE__));
// check if there is new tweet
if($result->statuses[0]->id != file_get_contents($dir.'/latest_tweet_id.dat')){
// record latest tweet id
file_put_contents($dir.'/latest_tweet_id.dat', $result->statuses[0]->id);
// iterate search result
$mail_body = "";
$date = new DateTime();
#!/bin/bash
curl -s -w "%{time_namelookup} %{time_connect} %{time_starttransfer} %{time_total}\n" -o /dev/null http://www.google.com/
@remore
remore / calc_delta.rb
Last active December 18, 2015 17:59
# usage: cat accumulated_number_data.ltsv | ruby calc_delta.rb
#!/usr/bin/env ruby
# usage: cat accumulated_number_data.ltsv | ruby calc_delta.rb
class LtsvDataLine
attr_accessor :data
def initialize(line)
@data = Hash.new
line.split("\t").each{|packet|
@data[packet.split(":")[0]] = packet.split(":")[1]
@remore
remore / check_disk_usage.sh
Created June 19, 2013 08:00
usage: check_disk_usage.sh <SERVER-NAME>
#!/bin/bash
# usage:
# check_disk_usage.sh <SERVER-NAME>
function check_disk_usage(){
local TOTAL=`snmpget -On -c public -v 1 "${1}" UCD-SNMP-MIB::dskTotal.1 | awk '{print $4}'`
local AVAIL=`snmpget -On -c public -v 1 "${1}" UCD-SNMP-MIB::dskAvail.1 | awk '{print $4}'`
local USED=`snmpget -On -c public -v 1 "${1}" UCD-SNMP-MIB::dskUsed.1 | awk '{print $4}'`
local PERCENT=`snmpget -On -c public -v 1 "${1}" UCD-SNMP-MIB::dskPercent.1 | awk '{print $4}'`
echo HDD of ${1} is ${PERCENT}% used - Total:${TOTAL}, Avail:${AVAIL}, Used:${USED}
@remore
remore / ltsv2csv.rb
Last active December 17, 2015 01:48
usage: ruby ltsv2csv.rb --file hoge.ltsv
#!/usr/bin/ruby
require 'optparse'
separator = ","
source = false
ARGV.clone.options do |opts|
opts.banner = "Usage: #{$0} [options]"
opts.on('-f', '--file=/path/to/file', String, 'Source file'){|v|
source = v
@remore
remore / add_ltsv_log_stackoverflow.rb
Last active December 16, 2015 22:09
usage: curl -s http://api.stackoverflow.com/1.1/tags | gunzip | ruby add_ltsv_log_stackoverflow.rb
# usage: curl -s http://api.stackoverflow.com/1.1/tags | gunzip | ruby add_ltsv_log_stackoverflow.rb
# note: works even with ruby 1.8.x
require 'SimpleJson_jp.rb' # downloaded from http://ruby-webapi.googlecode.com/svn/trunk/misc/SimpleJson/SimpleJson_jp.rb
src = ARGF.read
parser = JsonParser.new
json = parser.parse(src)
print Time.now.strftime("date:%Y-%m-%d\t")
json['tags'].each do |item|
@remore
remore / ControlCrontab.sh
Created November 26, 2012 06:40
Check and register crontab settings (just in case you are not allowed to add files under /etc/cron.d folder)
#!/bin/bash
# usage:
# ControlCrontab.sh [check|register]
if [ `echo $USER` != "hogehoge" ]; then
echo "you must be hogehoge!!!!"
exit 0
fi
if [ $# -eq 1 ] && [ $1 = "check" ]; then
@remore
remore / gist:4077337
Created November 15, 2012 08:12
Copy specific files from local storage to local storage with using folder names passed by pipe
#!/bin/bash
# usage:
# ls -R | grep FOLDER_NAME_TO_SEARCH | ./this_script.sh TARGET_FILE.html
# Verify if the # of passed parameter is only 1
if [ $# -ne 1 ]; then
echo "you must specify 1 parameter to grab file to be copied"
exit 0;
fi