Skip to content

Instantly share code, notes, and snippets.

@aont
aont / ssh_agent_substitute.sh
Created April 12, 2013 13:11
シェルスクリプト上でのSSH接続の再利用 ・パスワード入力は最初だけ ・鍵を作ってない人でも使えるはず(ssh-agentの代わりになる)
#!/bin/sh
echo start ssh session 1>&2
ssh -T -N -f -oControlMaster=yes -oControlPath=~/.ssh/master.$$.%r@%h:%p hoge.com
echo command execution on remote 1>&2
ssh -oControlMaster=no -oControlPath=~/.ssh/master.$$.%r@%h:%p hoge.com echo echo on remote
echo close connection 1>&2
ssh -O exit -oControlMaster=no -oControlPath=~/.ssh/master.$$.%r@%h:%p hoge.com
@aont
aont / gist:5410729
Created April 18, 2013 06:58
日本測地系に変換
a=6377.39715500
e=sqrt(0.006674372230614))
h=0
phi=34
lambda=130
N=a/sqrt(1-e*e*sin(phi)*sin(phi))
X=(N+h)*cos(phi)*cos(lambda)
Y=(N+h)*cos(phi)*sin(lambda)
@aont
aont / main.cpp
Created April 29, 2013 05:56
Double Pendulum
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unistd.h>
#include <vector>
const double length1 = 1;
const double length2 = 1;
@aont
aont / gpu_temp.sh
Created May 10, 2013 07:17
GPU temperature
#!/bin/sh
echo cat /nvidia_smi_log/gpu/temperature/gpu_temp/text\(\) | xmllint --shell =(nvidia-smi -q -x) | grep -v "^\/ >"
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'rubygems'
require 'twitter'
Twitter.configure do |config|
config.consumer_key = YOUR_CONSUMER_KEY
config.consumer_secret = YOUR_CONSUMER_SECRET
config.oauth_token = YOUR_OAUTH_TOKEN
@aont
aont / flatten.rb
Last active December 22, 2015 04:58
flatten directory
#!/usr/bin/ruby
require 'fileutils'
def flatten(path)
Dir::entries(path).each do |fn|
next if fn=="." || fn==".."
FileUtils::mv("#{path}/#{fn}", "#{path}__#{fn}")
end
FileUtils::rmdir(path)
@aont
aont / vmg2mbox.rb
Last active December 31, 2015 08:29
905SHのvMessage形式からmbox形式へ変換
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
$tel_self="09012345678"
$email_self="hoge@fuga.com"
def analyse_vcard(fin)
line = fin.gets
tel=nil
while line
@aont
aont / ipaddress_imap.rb
Created March 9, 2014 10:32
PR-400のIPアドレス変化通知メールをリアルタイム検知
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
require 'net/imap'
require 'kconv'
Net::IMAP::debug = true
imap = Net::IMAP.new('imap.gmail.com', 993, true)
imap.login('hoge@gmail.com', 'pass')
@aont
aont / ddns.rb
Last active August 29, 2015 13:57
PR-400NE,KIでWANアドレス監視
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'nokogiri'
require 'net/http'
require 'net/https'
$router_user = "hoge"
@aont
aont / binsel
Created March 19, 2014 07:45
binary selector
#!/bin/sh
platform="$(uname -s).$(uname -p)"
if [ -n "$1" ]; then
prog="$1"
shift
if [ -e "$prog.$platform" ]; then