Skip to content

Instantly share code, notes, and snippets.

@mostlyfine
mostlyfine / gist:4618994
Created January 24, 2013 09:15
im.kayac.comにメッセージを送信するサンプル 同じディレクトリに以下の形式でconfig.plを用意する。 +{ username => 'USERNAME', password => 'PASSWORD', };
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Encode;
use LWP::UserAgent;
use JSON;
use Digest::SHA1 qw(sha1_hex);
@mostlyfine
mostlyfine / gist:2839901
Created May 31, 2012 00:42
Google's Favicon Serviceでリンクにfaviconを表示させる
$("a[href^='http']").each(function() {
$(this).css({
background: "url(<a href="http://www.google.com/s2/u/0/favicons?domain=" target="_blank" rel="noreferrer" style="cursor:help;display:inline !important;">http://www.google.com/s2/u/0/favicons?domain=</a>" + this.hostname +
") left center no-repeat",
"padding-left": "20px"
});
});
@mostlyfine
mostlyfine / gist:1852672
Created February 17, 2012 10:58
Mojolicious::Lite and AnyEvent::Twitter::Stream and WebSocket
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Mojolicious::Lite;
use Encode;
use EV;
use AnyEvent::Twitter::Stream;
@mostlyfine
mostlyfine / gist:1841062
Created February 16, 2012 02:23
AnyEvent::Twitter::Stream sample
use strict;
use warnings;
use utf8;
use AnyEvent::Twitter::Stream;
use Log::Minimal;
$Log::Minimal::AUTODUMP=1;
$Log::Minimal::COLOR=1;
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes"/>
<meta name="format-detection" content="telephone=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<link media="screen" rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css"/>
<link rel="apple-touch-icon" href="apple-touch-icon.png"/>
<script src="http://code.jquery.com/jquery.min.js"></script>
@mostlyfine
mostlyfine / gist:1500212
Created December 20, 2011 04:09
perl function references
sub test1 {
# reference
return [0, "error"];
}
sub test2 {
# array
return (0, "success");
}
@mostlyfine
mostlyfine / jQuery Plugin Sample3
Created December 7, 2011 07:10
プラグイン内のpublic method、protected attribute
//
// plugin呼び出し
//
$(function() {
$.sample2.hello("world");
});
//
// plugin本体
//
@mostlyfine
mostlyfine / jQuery Plugin Sample2
Created December 7, 2011 06:39
対象エレメントに対して作動する
//
// plugin呼び出し
//
$(function() {
$("#message").sample1("hello world").css("color","red");
});
//
// plugin本体
//
@mostlyfine
mostlyfine / jQuery Plugin Sample1
Created December 6, 2011 08:17
プラグインの単体呼び出し、オプションの指定
//
// プラグイン呼び出し
//
$(function() {
$.sample({debug:true});
});
//
// プラグイン本体
@mostlyfine
mostlyfine / gist:800053
Created January 28, 2011 09:48
含んでんの?広げてんの?どうなの?実際
module Hoge
def hello
puts "hello"
end
end
class Test
end