This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
require 'rubygems' | |
require 'mechanize' | |
require 'kconv' | |
require 'mysql' | |
require 'date' | |
require 'damerau-levenshtein' | |
require 'cgi' | |
load 'unicode.rb' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 初期化とログイン | |
Mechanize initialized. | |
connect to https://secure.nicovideo.jp/secure/login_form | |
Logged in Niconico. | |
#検索画面のスクレイピング | |
connect to http://www.nicovideo.jp/search/%E3%82%86%E3%81%A3%E3%81%8F%E3%82%8A%E5%AE%9F%E6%B3%81?page=1&sort=f&order=d | |
connect to http://www.nicovideo.jp/search/%E3%82%86%E3%81%A3%E3%81%8F%E3%82%8A%E5%AE%9F%E6%B3%81?page=2&sort=f&order=d | |
connect to http://www.nicovideo.jp/search/%E3%82%86%E3%81%A3%E3%81%8F%E3%82%8A%E5%AE%9F%E6%B3%81?page=3&sort=f&order=d | |
... | |
# 検索結果6ページの28番目の動画を取得する、という意味。なぜここから始まるかというと、 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
rm explorizer-[0-9.]*.js | |
version=$(head -n 1 version) | |
cd src | |
cat core.js >> code | |
cat util.js >> code | |
cat resizer.js >> code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# path | |
PATH=$PATH:$HOME/bin:/sbin:/usr/sbin:~/.nave | |
# alias | |
alias la="ls -a" | |
alias lf="ls -F" | |
alias ll="ls -l" | |
alias du="du -h" | |
alias df="df -h" | |
alias su="su -l" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var xhr = function(){ | |
var xhr = new XMLHttpRequest(); | |
return function( method, url, param, callback ){ | |
xhr.onreadystatechange = function(){ | |
if ( xhr.readyState === 4 ){ | |
callback( xhr.responseText ); | |
} | |
}; | |
xhr.open( method, url+(method==="get" ? "?"+param : ""), true ); | |
xhr.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function quickSort(array, start, end){ | |
var start = ( typeof start === "undefined" ? 0 : start), | |
end = ( typeof end === "undefined" ? array.length - 1 : end), | |
p, tmp, | |
L, R; | |
p = array[ Math.floor((end + start) / 2) ]; | |
L = start; | |
R = end; | |
while (true){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mergeSort(array){ | |
// | |
if( array.length <= 1 ) return; | |
// division phase | |
var leftSize = Math.floor(array.length / 2), | |
rightSize = array.length - leftSize, | |
left = array.slice(0, leftSize), | |
right = array.slice(leftSize); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind | |
if (!Function.prototype.bind) { | |
Function.prototype.bind = function (oThis) { | |
if (typeof this !== "function") // closest thing possible to the ECMAScript 5 internal IsCallable function | |
throw new TypeError("Function.prototype.bind - what is trying to be fBound is not callable"); | |
var aArgs = Array.prototype.slice.call(arguments, 1), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# Amazon EC2 / Amazon Linux 64bitでも起動 | |
cd ~ | |
# wget -O dropbox.tar.gz "http://www.dropbox.com/download/?plat=lnx.x86" | |
wget -O dropbox.tar.gz "http://www.dropbox.com/download/?plat=lnx.x86_64" | |
tar xvzf dropbox.tar.gz | |
rm dropbox.tar.gz | |
~/.dropbox-dist/dropboxd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var hdemon = hdemon || {}; | |
hdemon.getTweet = { | |
get : function(json) { | |
var displayTweet = function(){ hdemon.getTweet.display(json); } | |
window.addEventListener("load", displayTweet); | |
}, | |
OlderNewer