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
; replace region using ruby regexp | |
(defun ruby-gsub(regexp dst) | |
(interactive "sruby -p -e '$_.gsub!(/regexp/, 'dst')' regexp: \nsruby -p -e '$_.gsub!(/regexp/, 'dst')' [regexp: /%s/ ] dst:" ) | |
(let (( ruby_str (concat "ruby -p -e '$_.gsub!(/" regexp "/,%q`" dst "`)' "))) | |
; (message ruby_str) ;debug | |
(shell-command-on-region (region-beginning) (region-end) ruby_str t t) | |
) | |
) |
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 -Ku | |
# coding: utf-8 | |
require "rubygems" | |
require "twitter" # gem install twitter | |
tw_hash = 'igaiga' | |
page_max = 3 | |
(1..page_max).each do |page_num| |
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 -Ku | |
# -*- coding: utf-8 -*- | |
# twitter DM sender to any users. | |
# via http://cheebow.info/chemt/archives/2007/11/twitterdm.html | |
require 'net/http' | |
require 'kconv' | |
require 'yaml' | |
conf_file = ARGV.shift || 'default.yaml' | |
conf = YAML.load_file(conf_file) |
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 -Ku | |
# -*- coding: utf-8 -*- | |
require 'nkf' | |
#str_u8 = 'apple' | |
str_u8 = 'いがいが' | |
str_u32 = NKF.nkf('-w32B0 -W',str_u8) # out: UTF-32(non BOM), in: UTF-8(non BOM) | |
str_u32.each_byte{ |b| | |
p b.to_s(16) | |
} |
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
; 画面の大きさにあわせてウィンドウ高さ調整 | |
; mac でデュアルディスプレイにすると、 x-display-pixel-height が 2画面の和になる | |
(setq expected_height 30) ; default | |
(if (= (x-display-pixel-height) 2000) (setq expected_height 60)) | |
(if (= (x-display-pixel-height) 800) (setq expected_height 39)) | |
(set-frame-height nil expected_height) |
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 'Date' | |
def validate_date(year, month, day) | |
return false if month <= 0 || day <= 0 | |
return false if Date.valid_civil?(year, month, day).nil? | |
true | |
end | |
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
<h3>Japanese Public Holidays 2010</h3> | |
<div id="agenda"></div> | |
<script> | |
function listEvents(root) { | |
var feed = root.feed; | |
var entries = feed.entry || []; | |
var html = ['<ul>']; |
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
Dir.glob("./*") do |file| | |
next unless file =~ /\.png|\.jpg|\.gif/ | |
basename = File.basename(file, ".*") | |
basename += '_' if file =~ /\.png$/ | |
run_str = "convert -resize 240x320 -quality 90% #{file} #{basename}.png" | |
system run_str | |
end |
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
/* | |
Erica Sadun, http://ericasadun.com | |
iPhone Developer's Cookbook, 3.0 Edition | |
BSD License, Use at your own risk | |
*/ | |
#import <UIKit/UIKit.h> | |
#import <MediaPlayer/MediaPlayer.h> | |
#define COOKBOOK_PURPLE_COLOR [UIColor colorWithRed:0.20392f green:0.19607f blue:0.61176f alpha:1.0f] |
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
UIButton* button = [[[UIButton alloc] initWithFrame:CGRectMake(150, 240, 100, 30)] autorelease]; | |
[button setBackgroundImage:[UIImage imageNamed:@"btn.png"] | |
forState:UIControlStateNormal]; | |
[button setBackgroundImage:[UIImage imageNamed:@"btn_on.png"] | |
forState:UIControlStateHighlighted]; | |
[button addTarget:self action:@selector(button_pushed) forControlEvents:UIControlEventTouchUpInside]; | |
[self.view addSubview:button]; | |
- (IBAction) button_pushed { |
OlderNewer