Skip to content

Instantly share code, notes, and snippets.

Avatar

Toshiyuki Masui masui

View GitHub Profile
View jquery_test.js
(function($){
$.fn.test = function(){
this.on('mousedown',mousedown);
this.name = "NAMENAME";
}
var mousedown = function(e){
// ここで this.name の値を知るにはどうする?
}
})(jQuery);
View sample1.rb
require "hondana"
include Hondana
shelf = Shelf.new('増井')
shelf.books.each { |book|
puts book.isbn
puts book.title
}
View sample.rb
require 'rubygems'
require 'active_record'
#
ActiveRecord::Base.establish_connection(
:adapter => 'mysql',
:host => 'localhost',
:username => 'root',
:password => '',
:database => 'hondana',
:encoding => 'utf8'
View gyazofull.rb
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
#
# 全画面Gyazoると同時にファイル情報/アプリ情報のメタデータをアップする
#
require 'net/http'
require 'json'
require 'digest/md5'
@masui
masui / df.rb
Created Oct 10, 2012
dfをツイート
View df.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'tw'
require 'json'
data = {}
data['type'] = 'df'
data['time'] = Time.now
percent = 0
View enoshimawind.rb
require 'rubygems'
require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML(open('http://enoshima-yacht-harbor.jp/kishou.htm'))
tds=doc.xpath("//td")
as = tds[16].xpath(".//b").text.sub(/[^\d\.].*$/,'')
ad = tds[19].xpath(".//b").text
ms = tds[22].xpath(".//b").text.sub(/[^\d\.].*$/,'')
View gist:2793856
require 'rubygems'
require 'active_record'
#
# infinite-wave-43 (Crane)
#
ActiveRecord::Base.establish_connection(
:adapter => 'postgresql',
:encoding => 'unicode',
:pool => '5',
:database => 'd7kfs1aexxxxxx',
View gist:2733178
require 'rubygems'
require 're_expand'
'(ab)+'.expand { |a|
puts a[0]
}
View gist:2725277
require 'rubygems'
require 're_expand'
'(1|2|3|4)*'.expand(' 222 ',1) { |a|
puts a[0]
}
@masui
masui / gist:2725168
Created May 18, 2012
Using 're_expand'
View gist:2725168
require 'rubygems'
require 're_expand'
"(月|火|水|木|金)曜(1|2|3|4|5|6)限".expand { |a|
puts "#{a[0]} #{a[1]} #{a[2]}"
}
You can’t perform that action at this time.