Skip to content

Instantly share code, notes, and snippets.

@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 Sample3
Created December 7, 2011 07:10
プラグイン内のpublic method、protected attribute
//
// plugin呼び出し
//
$(function() {
$.sample2.hello("world");
});
//
// plugin本体
//
@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");
}
<!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: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;
@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: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: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:4663684
Created January 29, 2013 11:48
IMAP振り分け
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'openssl'
require 'net/imap'
require 'yaml'
class Filter
def initialize(options={})
@imap = Net::IMAP.new(options[:host], options[:port] || 993, options[:ssl] || true)
@mostlyfine
mostlyfine / gist:5351678
Created April 10, 2013 03:55
2行だけのCSSグリッドフレームワーク http://www.vcarrer.com/2010/10/two-lines-css-framework.html
.row {
display:table; /* コンテナ全体にテーブルの表示スタイルを適用 */
width:960px; /* 全体の幅、サイズの変更をはじめ、単位を%, emにも変更可能 */
margin:0 auto /* 左右の中央に配置*/
}
.cell {
display:table-cell; /* 各カラムにテーブルのセルの表示スタイルを適用*/
vertical-align:top; /* 上端(top)揃え */
padding-left:10px /* カラム間の溝の幅 */
}