Skip to content

Instantly share code, notes, and snippets.

@redtower
redtower / 0_reuse_code.js
Last active August 29, 2015 14:13
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@redtower
redtower / count.pl
Created March 10, 2012 08:37
iTunesライブラリファイルを読み込んで再生回数が0回の曲数をカウントする ref: http://qiita.com/items/3107
#!/usr/bin/env perl
use strict;
use warnings;
use Mac::iTunes::Library;
use Mac::iTunes::Library::XML;
my $library = Mac::iTunes::Library::XML->parse( 'iTunes Library.xml' );
my $count=0;
my %items = $library->items();
$ guid.exe
4b1d4ca7f22b49e284753a034e673629
@redtower
redtower / gist:1520367
Created December 26, 2011 01:43
Google位置情報サービスから住所を取得するスクリプト
#!/bin/bash
# http://blog.indonesiancoder.com/google-gears-wifi-geolocation-api-query
# http://www.guilz.org/2011/11/28/google位置情報サービスから住所を取得する/
if [ $# != 2 ]; then
echo "# Google Gears WiFi Geolocation API query by ShadowHat=esYou"
echo "# Shadow@SquatThis.net"
echo "#"
echo "# Use: $0 MAC1 MAC2"
@redtower
redtower / cal.js
Created March 9, 2011 05:08
カレンダー
dt = new Date();
y = dt.getYear() + 1900;
m = dt.getMonth() + 1;
document.write("<table>");
document.write("<tr><td align=center colspan=7>");
document.write(y + "/");
if (m < 10) { document.write("&nbsp;"); }
document.write(m);
document.write("</td></tr>");
@redtower
redtower / 50_weblogger.el
Created March 3, 2011 06:56
wp-emacs(weblogger)の設定
;;=======================================================================
;; @ wp-emacs(weblogger)
;;=======================================================================
(require 'weblogger)
(global-set-key "\C-c\C-w" 'weblogger-start-entry) ; weblogger起動(C-c C-w)
(defun my-weblogger-send-entry (&optional arg)
(interactive)
(save-buffer)
(set-buffer-modified-p t)
@redtower
redtower / artist1.pl
Created March 2, 2011 02:19
Yahoo MusicからArtistを検索しIDを取得する。
#!/usr/bin/perl
use strict;
use warnings;
use Web::Scraper;
use URI;
use Encode;
my $word = $ARGV[0] ? decode('utf-8', $ARGV[0]) : "weezer";
my $uri = create_uri($word);
@redtower
redtower / anonymous_array_or_hash.pl
Created January 13, 2011 15:10
サブルーチンの戻り値でハッシュを返却する。
use strict;
# 配列
my @array = ('dog', 'pochi', 2);
print $array[1] . "\n"; # pochi
# 無名配列(Anonymous Array)
my $array_ref = ['dog', 'pochi', 2];
print $array_ref->[1] . "\n"; # pochi
@redtower
redtower / class-accesser.pl
Created January 13, 2011 15:06
オブジェクト指向とMooseとClass::Accesser
package Class;
use base qw(Class::Accessor);
__PACKAGE__->mk_accessors(qw(X Y));
1;
package Main;
my $o = Class->new({X => 20});
print $o->X() . "/" . $o->Y() . "\n"; # 20/
$o = Class->new({X => 40, Y => 50});
@redtower
redtower / input_password.pl
Created January 13, 2011 15:03
パスワードを入力する
sub input_password() {
my $pass;
while (!$pass) {
print "Password --> ";
system "stty -echo";
chomp($pass = <STDIN>);
print "\n";
system "stty echo";
}