Skip to content

Instantly share code, notes, and snippets.

@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
#!/usr/bin/env ruby
# -*- coding: utf-8; -*-
#
# scraping nikkei.com for Kindle
#
require 'nokogiri'
require 'open-uri'
TOP = 'http://www.nikkei.com'
require 'rubygems'
require 'open-uri'
require 'nokogiri'
KCODE = 'euc-jp'
index_url = 'http://www.dmm.co.jp/digital/videoa/-/actress/=/keyword=%s/'
%w(a ka sa ta na ha ma ya ra wa).each do |w|
content = Nokogiri::HTML.parse(open(index_url % w).read)