Skip to content

Instantly share code, notes, and snippets.

View smallfield's full-sized avatar

smallfield

  • Copenhagen, Denmark
View GitHub Profile
# misc
export LANG=ja_JP.UTF-8
alias ls='ls -Gl '
export PATH=/opt/local/bin:/opt/local/sbin/:$PATH
export MANPATH=/opt/local/man:$MANPATH
autoload -U compinit
compinit
@smallfield
smallfield / UpdateAll.js
Created June 24, 2012 11:14
Update all devices connected to iTunes(Windows)
var KIND_IPOD = 2;
var iTunesApp = WScript.CreateObject("iTunes.Application");
var sources = iTunesApp.Sources;
for(i=1; i <= sources.Count; i++){
item = sources.Item(i);
if (item.Kind == KIND_IPOD) {
item.UpdateIPod();
}
}
@smallfield
smallfield / animesub.rb
Last active December 16, 2015 04:59
しょぼいカレンダーの番組IDと話数から、サブタイトルをひっぱってくる奴
#!/usr/local/bin/ruby
# -*- encoding: utf-8 -*-
require "csv"
require "net/http"
require 'sqlite3'
db=SQLite3::Database.new("/tmp/subtitle.db")
sql = <<SQL
@smallfield
smallfield / delold.sh
Created June 8, 2013 01:13
dfでファイルシステムのusage監視して、古いファイル消していくやつ。
#!/bin/sh
targetdir=/tank/recorded/
targetfilesystem=tank
usage=`df | grep ^$targetfilesystem | awk '{print $5}' | sed 's/%//g'`
while [ $usage -gt 21 ]
do
rm -f "$targetdir`ls -t $targetdir | tail -n1`"
db.release.find().forEach(function(doc){ doc.date = new Date(doc.date);db.release.save(doc); })
#!/bin/sh
chinachu_home="/home/chinachu/chinachu/"
tuners="BSCS-1 BSCS-2 GR-1 GR-2"
tunercount=`echo ${tuners} | wc -w`
i=0
if [ $1 = "config" ]
then
cat <<'EOM'
graph_title Tuner lock
@smallfield
smallfield / productkey.js
Created November 28, 2013 01:54
Windowsのプロダクトキーを調べるJScript。
function windows_productkey(){
WshShell = new ActiveXObject( "WScript.Shell" );
ret = WshShell.RegRead('HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\DigitalProductId');
DigitalProductId = ret.toArray();
hexPid = DigitalProductId.slice( 52, 67 );
decodedChars = Array(24);
digits = Array("B","C","D","F","G","H","J","K","M","P","Q","R","T","V","W","X","Y","2","3","4","6","7","8","9");
for ( var i=1; i<30;i++ ){
if((i % 6) == 0 ){
decodedChars.push("-");
@smallfield
smallfield / wahootsv.awk
Last active January 7, 2024 14:55
Extract general information from Wahoo workout data(CSV).
#usage
# find %Dropbox%/Apps/Wahoo | grep csv$ | sort | awk -f wahoo2csv.awk
# Date, TotalDistance, Time, AverageSpeed
BEGIN {
FS=","
general_info_flg=0
distance=0
}
@smallfield
smallfield / workout.html
Last active January 3, 2016 16:19
workout visualize sample
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My workout stat</title>
<script src="//code.jquery.com/jquery-1.8.2.js"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<script type='text/javascript' src='//www.google.com/jsapi'></script>
#!c:/bin/ruby/bin/ruby
# -*- encoding: cp932 -*-
# file: tsv2sqlite3.rb
require 'optparse'
require 'rubygems'
require 'sqlite3'
opt = OptionParser.new