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
require 'webrick' | |
h,s,o={},WEBrick::HTTPServer.new(:Port=>3333),[*?a..?z] | |
s.mount_proc('/'){|q,b|t,r=h[q.unparsed_uri[1..-1]],((0..4).map{o[rand(26)]}.*'') | |
q.request_method=='GET'?b.set_redirect(WEBrick::HTTPStatus::Found,t):(h[r]=q.body)&&b.body="http://localhost:3333/#{r}"} | |
s.start |
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
require 'webrick' | |
h, s, o = {}, WEBrick::HTTPServer.new(:Port => URI.parse('http://localhost:3333/').port), [('a'..'z'), ('A'..'Z'), ('0'..'9')].map { |i| i.to_a }.flatten | |
for url in ARGV | |
h[(0...5).map { o[rand(o.length)] }.join] = url | |
end | |
p h | |
s.mount_proc('/'){|req, res| res.set_redirect(WEBrick::HTTPStatus::Found, h[req.unparsed_uri[1..-1]]) } | |
s.start |
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
require 'webrick' | |
url_hash = {} | |
sv = WEBrick::HTTPServer.new(:Port => URI.parse('http://localhost:3333/').port) | |
o = [('a'..'z'), ('A'..'Z'), ('0'..'9')].map { |i| i.to_a }.flatten | |
for url in ARGV | |
url_hash[(0...5).map { o[rand(o.length)] }.join] = url | |
end | |
p url_hash | |
sv.mount_proc('/'){|req, res| | |
res.set_redirect(WEBrick::HTTPStatus::Found, url_hash[req.unparsed_uri[1..-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
require 'etc' | |
p Etc.getlogin | |
p s= File::stat("/Users/hoge/fuga.rb").uid | |
p Etc.getpwuid(s).name |
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
# coding: utf-8 | |
require "twitter" | |
require 'pp' | |
YOUR_CONSUMER_KEY = "hoge" | |
YOUR_CONSUMER_SECRET = "hoge" | |
YOUR_OAUTH_TOKEN = "hoge" | |
YOUR_OAUTH_TOKEN_SECRET = "hoge" | |
Twitter.configure do |config| |
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
set nocompatible " be iMproved | |
filetype off | |
if has('vim_starting') | |
set runtimepath+=~/.vim/bundle/neobundle.vim | |
call neobundle#rc(expand('~/.vim/bundle/')) | |
endif | |
" originalrepos on github | |
NeoBundle 'Shougo/neobundle.vim' | |
NeoBundle 'Shougo/vimproc', { |
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
#! ruby -Ks | |
# -*- coding: sjis -*- | |
require 'win32ole' | |
module Worksheet | |
def [] y,x | |
cell = self.Cells.Item(y,x) | |
if cell.MergeCells | |
cell.MergeArea.Item(1,1).Value |
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 printf(format){ | |
for(var i = 1; i < arguments.length; i++){ | |
var pattern = /\{\w\}/; | |
//var pattern = new RegExp('\\{' + (i -1) + '\\}', 'g'); | |
format = format.replace(pattern, arguments[i]); | |
} | |
document.writeln(format); | |
} |
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
<html> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" /> | |
<title>Hello World ! </title> | |
</head> | |
<body> | |
<script> | |
var data = []; | |
if (typeof data == 'object' & data instanceof Array) { | |
document.writeln("It's Array!!"); |
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
#encode :utf-8 | |
Encoding.default_external = 'utf-8' | |
i = 1 | |
befline = "" | |
open("test.log").each do |line| | |
line = befline + line | |
line.gsub!(/test/im, 'nya-') | |
#line.gsub!(/te.st/im, 'Pr\noj') | |
open("result.txt", "a"){|f| f.write line} | |
i = i + 1 |
NewerOlder