Skip to content

Instantly share code, notes, and snippets.

@zeero
zeero / debug_var.rb
Created March 7, 2011 05:04
Logger.debug_var
require 'logger'
class Logger
def debug_var(ctx, *vars)
# get Class name & decide method type
class_name = ctx.eval("self.class").to_s
if class_name != "Class"
sep = "#"
else
class_name = ctx.eval("self.name")
@zeero
zeero / xmlns_work.rb
Created March 24, 2011 09:46
find all xml namespaces with nokogiri
doc.xpath("//namespace::*").map{|ns|{ns.prefix => ns.href}}.uniq # => [{"xml"=>"http://www.w3.org/XML/1998/namespace"}, {nil=>"http://parts.com/"}, {nil=>"http://alicesautoparts.com/"}, {nil=>"http://bobsbikes.com/"}]
@zeero
zeero / tty_info.rb
Created March 30, 2011 14:08
detect tty width & height
# Determines if a shell command exists by searching for it in ENV['PATH'].
def command_exists?(command)
ENV['PATH'].split(File::PATH_SEPARATOR).any? {
|d| File.exists? File.join(d, command)
}
end
# Returns [width, height] of terminal when detected, nil if not detected.
def detect_terminal_size
@log.debug_var binding, "ENV['COLUMNS']", "ENV['LINES']"
@zeero
zeero / .vimperatorrc
Last active September 25, 2015 09:37
Firefox Vimperator Resource File
"2.2 (created: 2009/10/28 19:04:27)
set toolbars=addons,nobookmarks,menu,navigation,tabs
set hlsearch
set newtab=all
set runtimepath=$HOME\\vimperator
source! $HOME\\_vimperatorrc.local
" ページロード時にテキストボックスにフォーカスするのを防ぐ
set focuscontent
" :[tab]open の補完対象と順番
@zeero
zeero / ZeeroBlue.vimp
Created April 4, 2011 05:44
Firefox Vimperator Color Scheme
" ==Vimperator_Color_Scheme==
" name: ZeeroBlue
" ==Mono_Color_Scheme==
" Hint
hi Hint font-family: "Lucida Grande", "Segoe UI", sans-serif; font-size: 11px; font-weight: bold; background: -moz-linear-gradient(top, #6BA7EF, #3163AA); text-shadow: 0 1px #1D3C66; text-transform: uppercase; color: white; background-color: red; padding: 2px 5px; border-radius: 3px; border: 1px solid #3366AD;
"hi Hint color: #333333; background: White; font-size: 14px; font-family: Consolas, Osaka, monospace; font-weight: bold; padding: 0px 2px; border: 3px outset #ddd; opacity:0.80;
hi HintElem color: Black; background: PowderBlue;
hi HintActive color: White; background: SteelBlue;
require 'open-uri'
# check args
if ARGV[0] == nil || ARGV[0] == ""
exit
end
# main
url = URI.escape(ARGV[0])
api_url = "https://readitlaterlist.com/v2/add?username=zeero26&password=jirojiro&apikey=012A9b0Vd2431P3430paXy2Jh6Txx327&url=#{url}" # => "https://readitlaterlist.com/v2/add?username=zeero26&password=jirojiro&apikey=012A9b0Vd2431P3430paXy2Jh6Txx327&url=http://google.com"
@zeero
zeero / mobile_mailto.html
Created September 21, 2011 06:42
testing mailto link for mobile phone
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
</head>
<body>
<a href="mailto:?subject=test&body=testtest">件名と本文(ascii)</a><br><br>
</body>
</html>
<?xml version="1.0" encoding="Shift_JIS"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!--出力方法の指定-->
<xsl:output method="text" encoding="Shift_JIS"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
@zeero
zeero / cookie.html
Created July 2, 2013 10:53
HTML sample to set cookie by JavaScript.
@zeero
zeero / ug
Created January 15, 2014 12:51
#!/bin/bash
option="-no-empty -silent -buffer-name=grep -no-split -auto-preview"
if [ $1 ]
then
pattern="::$1"
fi
target="."