Skip to content

Instantly share code, notes, and snippets.

@maraigue
maraigue / TheTumblrThemeLikeATwitter.html
Created August 14, 2008 06:31 — forked from june29/TheTumblrThemeLikeATwitter.html
Fixed source of gist:4089 [Tumblr theme (design like Twitter)]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="alternate" type="application/rss+xml" title="RSS" href="/rss"/>
<link rel="shortcut icon" href="{Favicon}">
<link type="text/css" rel="stylesheet" media="screen" href="http://libelabo.jp/stylesheets/screen.css"/>
<title>{Title}</title>
<style type="text/css">
@maraigue
maraigue / tinyurl.rb
Created September 14, 2008 06:02
TinyURL library for Ruby
require 'net/http'
require 'cgi'
Net::HTTP.version_1_2
module TinyURL
module_function
# Makes a URL short via TinyURL.com.
# returned value is the key of TinyURL.com.
@maraigue
maraigue / toshigo.rb
Created January 16, 2009 09:46
年子平方数
class Integer
def toshigo?
# return nil if self <= 0
s = self.to_s
l = s.length
return false if l % 2 != 0
((s[0...(l/2)].to_i) - (s[(l/2)..-1].to_i)).abs == 1
end
@maraigue
maraigue / TumblrTheme[h-hiro.tumblr.com].html
Created January 19, 2009 05:03
h-hiro.tumblr.com で用いているテーマ
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<!-- DEFAULT COLORS -->
<meta name="color:Background" content="#fff"/>
<meta name="color:Title" content="#444"/>
<meta name="color:Description" content="#777"/>
<meta name="color:Post Title" content="#6498cc"/>
<meta name="color:Text" content="#444"/>
@maraigue
maraigue / URLencode-Ruby1.9.rb
Created January 28, 2009 05:36
Ruby1.9勉強中:URLエンコード
#!/usr/bin/env ruby1.9
# -*- coding: utf-8 -*-
def URLencode(str)
str.force_encoding("binary").gsub(/\W+/){ |x| x.unpack("C*").map{ |y| sprintf("%%%02X", y) }.join }
end
puts URLencode("ほげ")
@maraigue
maraigue / last-train-hokkaido_crontab
Created February 12, 2009 15:27
北海道のいくつかの駅の、最終列車の時刻をTwitterに自動投稿するためのcrontab(2009.02.16現在)
# $TWPOKE / $TWPOKE2 には、Twitterへ発言を投稿するスクリプトの名前が格納されている
# == Last train information
15 16 * * 1 $TWPOKE '[まもなく最終列車] 南斜里駅(釧網本線) 網走方面最終 16:19 [auto]' > /dev/null 2>&1
5 15 * * 2 $TWPOKE '[まもなく最終列車] 上幌延駅(宗谷本線) 稚内方面最終 15:09 [auto]' > /dev/null 2>&1
40 16 * * 3 $TWPOKE '[まもなく最終列車] 東山駅(函館本線) 函館方面最終 16:46 [auto]' > /dev/null 2>&1
40 16 * * 4 $TWPOKE '[まもなく最終列車] 羽帯駅(根室本線) 帯広方面最終 16:48 [auto]' > /dev/null 2>&1
0 7 * * 5 $TWPOKE '[まもなく最終列車] 上白滝駅(石北本線) 網走方面最終 07:04 [auto]' > /dev/null 2>&1
45 16 * * 6 $TWPOKE '[まもなく最終列車] 真布駅(留萌本線) 深川方面最終 16:52 [auto]' > /dev/null 2>&1
20 16 * * 7 $TWPOKE '[まもなく最終列車] 知内駅(津軽海峡線) 青森方面最終 16:27 [auto]' > /dev/null 2>&1
# == First train information
@maraigue
maraigue / remove-all-backup-files.sh
Created February 13, 2009 02:59
カレントディレクトリ以下のすべてのバックアップファイル("~"で終わるファイル)を削除するシェルスクリプト
#!/bin/sh
find -regex '.+~' -print -delete
@maraigue
maraigue / cmdrun.cpp
Created February 21, 2009 06:17
Windowsのコンソールプログラムを、コンソールを表示させずに実行するためのプログラム
// Windowsのコンソールプログラムを、コンソールを表示させずに実行するためのプログラム。
// > cmdrun.exe hogepiyo.bat
// のように利用する。
//
// VC++2003 + Windows Vista SP1で動作確認済み
//
// (C)2009 H.Hiro(Maraigue) http://hhiro.net/about/
// 利用条件: CC-BY-2.1-JA
// (http://creativecommons.org/licenses/by/2.1/jp/)
@maraigue
maraigue / localvariable.bat
Created March 12, 2009 10:13
Local Variable in MS-DOS batch file
@echo off
rem Info from http://ykr414.com/dos/dos05.html
echo %PATH%
setlocal
set PATH=HOGEPIYO
echo %PATH%
endlocal
echo %PATH%
@maraigue
maraigue / kabocha-miku.rb
Created March 14, 2009 06:58
かぼちゃミク
#!/usr/bin/env ruby
# ミク画像 "kabochamiku-src.png"
# (http://f.hatena.ne.jp/maraigue/20081012211841)を、
# かぼちゃミク
# (http://f.hatena.ne.jp/maraigue/20081221032946)に
# するコード。
#
# RMagickが必要
#