Skip to content

Instantly share code, notes, and snippets.

View keiya's full-sized avatar

keiya keiya

View GitHub Profile
@keiya
keiya / gist:583900
Created September 17, 2010 08:02
Univ. of Tsukuba WLAN Auth Script
#!/usr/bin/perl
use strict;
use LWP::UserAgent;
use HTTP::Request::Common qw(POST);
# リクエストの生成
my $url = 'https://wlan-auth1.cc.tsukuba.ac.jp/login.html';
my %formdata = ('buttonClicked' => '4','username' => 'YOUR_ID', 'password' => 'YOUR_PASSWORD');
my $request = POST($url, [%formdata]);
@keiya
keiya / destroyTwitterPosts
Created September 17, 2010 08:09
Delete your twitter posts
#!/usr/bin/perl
# Cf. http://d.hatena.ne.jp/famnet/20100917/1284711061
use strict;
use warnings;
use lib './lib';
use LWP;
use LWP::ConnCache;
use Net::Twitter;
@keiya
keiya / brainfsck.rb
Created October 3, 2010 12:44
brainfsck, the compatible of brainfuck (ruby)
#!/usr/bin/ruby
# 言語仕様: http://wiki.keiyac.org/index.pl?page=Brainfsck
$KCODE = "UTF8"
$ptr = 0
$tkn_ptr = 0
$token = []
@keiya
keiya / rmbf
Created November 11, 2010 02:00
remove the backup(swap) files of vim, gedit / usage: rmbf -d
#!/usr/bin/perl
use strict;
use warnings;
use Cwd;
# rmbf version 1.0.1
# Remove backup files
# Written by Keiya CHINEN
@keiya
keiya / ini.conf
Created January 7, 2011 08:16
NMEA GPS Logger
Win32::SerialPort_Configuration_File -- DO NOT EDIT --
\\.\COM5
CFG_1,none
eol,10
clear,-@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@-
RCONST,0
istrip,0
CFG_2,none
XOFFCHAR,0
PARITY_EN,0
@keiya
keiya / youtube.pl
Created August 17, 2011 23:38
youtube downloader
#!/usr/bin/perl
#
# by Keiya Chinen
use strict;
use warnings;
use WWW::YouTube::Download;
my $video_id = shift || die "Usage: $0 [video_id|video_url]";
@keiya
keiya / gist:1190856
Created September 3, 2011 08:22
convert polar - cartesian
// thx tomy! http://www5.airnet.ne.jp/tomy/cpro/sslib12.htm
function cartesian2polar(x,y,z) {
var obj = new Object;
obj.r = Math.sqrt( x*x + y*y + z*z );
if (x != 0.0)
obj.phi = Math.atan2( y, x );
else {
if (y < 0.0)
@keiya
keiya / bitly.lua
Created September 15, 2011 14:08
bit.ly shortener function in Lua
function bitlyshorten(longurl)
local http = require('socket.http')
--please specify your account ID and API key
local r,c = http.request('http://api.bitly.com/shorten?login=YOUR_LOGINID&apiKey=YOUR_API_KEY&longUrl='..longurl)
local json = require('json')
local decjson = json.decode(r)
local shorturl
for k,v in pairs(decjson.results) do
@keiya
keiya / gist:1223397
Created September 16, 2011 23:31
Fibonacci in Assembly
.data
.align 4
res: .long 0,0,0,0,0,0,0,0,0,0,0
.text
.globl main
main:
mov $0,%eax #; temporary
mov $0,%esi #; counter (n)
mov %eax,res(,%esi,4) #; res[n] = 0
@keiya
keiya / gist:1223400
Created September 16, 2011 23:32
Multiplying without MUL
.data
.align 4
varx: .long 12
vary: .long 3
.text
.globl main
main:
mov (varx),%eax
mov (vary),%ebx