Skip to content

Instantly share code, notes, and snippets.

@hitode909
hitode909 / mix_noun.rb
Created April 1, 2012 02:06
文を2つ入力して最初の文の名詞以外と2つめの文の名詞だけを使って文章を作るやつ
# -*- coding: utf-8 -*-
require 'open-uri'
require 'nokogiri'
require 'MeCab'
class WordsArray < Array
def nouns
select{ |w|
w.is_noun
}
# -*- coding: utf-8 -*-
require 'httpclient'
require 'nokogiri'
def get text
endpoint = 'http://jlp.yahooapis.jp/MAService/V1/parse'
appid = 'RZv4ed6xg67n15cyyGFF8Io0r3i.o0uwISXfrFOZYyMghbdeNA10_M6KemHLqz0laQ--'
params = {
:appid => appid,
:sentence => text,
@hitode909
hitode909 / perl_auto_semicolon.rb
Created March 17, 2012 07:21
Perlのソースコードに自動でセミコロンつけるやつ
#! /usr/bin/env ruby
file = ARGV.first
code = open(file).read
def append_semicolon(code, time)
code.split(/\n/).enum_with_index.map{|line, num|
time[num] == 1 ? line + ";" : line
}.join("\n")
end
module PrintSelf
def inspect
args = self.method(:initialize).parameters.map{ |param|
self.instance_variable_get("@#{param[1]}".to_sym).inspect
}
"#{self.class}.new(#{args.join(", ")})"
end
end
@hitode909
hitode909 / debounce.coffee
Created February 11, 2012 03:31
jQuery Deferred, throttle, debounce
debounce = (delay) ->
lastd = $.Deferred()
->
lastd.reject()
d = $.Deferred()
lastd = d
args = arguments
setTimeout ->
d.resolve args
, delay || 100
@hitode909
hitode909 / reverse_animation_gif.rb
Created February 1, 2012 11:41
アニメーションGIF逆再生するやつ
# -*- coding: utf-8 -*-
require 'rubygems'
require 'RMagick'
filename = ARGV.first
unless filename
warn "usage: #{$0} <ANIMATION GIF FILE>"
exit 1
end
@hitode909
hitode909 / sin_is_god.txt
Created February 1, 2012 06:20 — forked from kimoto/sin_is_god.txt
sin関数の使い方についてメモ
sin関数の魅力に迫る!
これは超ハイテンションでsin関数の魅力に迫るという文章です
sin関数は入力された角度(ラジアン)を元に、-1から1までのあいだの値を返却します
sin関数は周期的な特徴があって入力する値を増やしていくと...
-----------------
sin(0) = 0
sin(1) = 0.1
sin(2) = 0.14
...
later = (func) ->
setTimeout func, 0
executeByQueue = do ->
queue = []
timer = null
(func) ->
if timer
queue.push func
return
@hitode909
hitode909 / shuffle_animation_gif.rb
Created January 14, 2012 07:12
shuffle_animation_gif.rb
# -*- coding: utf-8 -*-
require 'rubygems'
require 'RMagick'
filename = ARGV.first
unless filename
warn "usage: #{$0} <ANIMATION GIF FILE>"
exit 1
end
@hitode909
hitode909 / a.css
Created January 8, 2012 09:49
hitode909の日記のCSS
/* <system section="theme" selected="aero2"> */
@import "/css/theme/aero2/aero2.css";
/* </system> */
/* <system section="background" selected="e83254"> */
body{background:#e83254;}
/* </system> */
#google_afc_user {
height:0px;