Skip to content

Instantly share code, notes, and snippets.

@wtnabe
wtnabe / simple_webtasks_rakefile.rb
Created October 19, 2009 22:50
A Rakefile for simple web site creation and maintenance
# -*- mode: ruby; coding: utf-8 -*-
#
# Require:
# * xoxo gem
# * lftp binary
# * linkchecker binary
# * html tidy binary
# * svn or hg or git
# * htpasswd binary
@wtnabe
wtnabe / rtm-printplanner-scraper.rb
Created October 26, 2009 09:32
RTM `printplanner' scraper
#! /usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
#
# RTM `printplanner' scraper
#
#TARGET = 'http://www.rememberthemilk.com/printplanner/USER/'
@wtnabe
wtnabe / strip_tags.rb
Created November 4, 2009 22:44
A Ruby version of PHP's strip_tags() function
require 'rubygems'
require 'hpricot'
$KCODE = 'u'
def strip_tags( html )
Hpricot( html ).inner_text.gsub( /(?:\xc2\xa0| #  
\xe3\x80\x80| # fullwidth
[\s])+/x, ' ' ).strip
end
@wtnabe
wtnabe / instant_mechanize_page.rb
Created November 11, 2009 22:43
create Mechanize::Page object quickly from HTTP resource or local file
def mechanize_page( uri, base_uri = nil )
require 'kconv'
require 'rubygems'
require 'mechanize'
require 'hpricot'
WWW::Mechanize.html_parser = Hpricot
if ( URI( uri ).is_a?( URI::HTTP ) )
WWW::Mechanize.new.get( uri )
elsif ( File.exist?( uri ) )
base_uri = 'http://example.com/' if base_uri.nil?
@wtnabe
wtnabe / twitter.user.css
Created December 2, 2009 05:49
A user css for twitter since 2009-12-02
@-moz-document url-prefix("http://twitter.com/") {
body {
font-size: x-small !important;
}
div#new_results_notification {
display: none !important;
}
ol.statuses {
font-size: small !important;
}
@wtnabe
wtnabe / rm_r.php
Created December 20, 2009 13:46
`rm -r` command, PHP implementation
<?php
/**
* `rm -r` command, PHP implementation
*
* @since 2009-12-20
* @license two-clause BSD
*/
function rm_r( $path ) {
if ( is_dir( $path ) and $dh = opendir( $path ) ) {
while ( ($entry = readdir( $dh )) !== false ) {
OK
RECEIVE: PASS
RECEIVE: NICK wtnabe maxlimit=30
RECEIVE: USER wtnabe 8 * :wtnabe
-----
NG
diff --git a/examples/tig.rb b/examples/tig.rb
index c828a5f..9d69bef 100755
--- a/examples/tig.rb
+++ b/examples/tig.rb
@@ -2148,7 +2148,7 @@ class TwitterIrcGateway < Net::IRC::Server::Session
if uri.is_a? URI::HTTPS
http.use_ssl = true
http.cert_store = @cert_store
- http.verify_mode = OpenSSL::SSL::VERIFY_PEER
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
@wtnabe
wtnabe / god_delayed_start.rb
Created January 19, 2010 02:02
God's delayed start example
# -*- mode: ruby -*-
God.watch do |w|
w.name = 'wig.rb'
w.interval = 5.seconds
w.start = 'wig.rb -h 127.0.0.1'
# delay wig.rb
w.autostart = false
w.behavior( :clean_pid_file )
@wtnabe
wtnabe / howto_convert_image_density
Created January 20, 2010 05:53
How-to convert image density with ImageMagick
# for paper
convert INFILE -size SRC_SIZE -scale TARGET_SIZE -density 350x350 -units PixelsPerInch OUTFILE