Skip to content

Instantly share code, notes, and snippets.

Kuniaki IGARASHI igaiga

Block or report user

Report or block igaiga

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@igaiga
igaiga / ruby-gsub.el
Created Feb 16, 2010
replace region using ruby regexp
View ruby-gsub.el
; 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)
)
)
@igaiga
igaiga / get_twitter_using_hash
Created Mar 4, 2010
get_twitter_using_hash
View get_twitter_using_hash
#! 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|
View twitter dm sender
#! 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)
View utf-8 to utf-32
#!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)
}
View gist:371037
; 画面の大きさにあわせてウィンドウ高さ調整
; 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)
View 月日の正当性判断.rb
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
View Japanese Public Holidays 2010 from Google Calendar .js
<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>'];
View create_png_for_iphone.rb
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
View gist:418989
/*
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]
View open_safari.m
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 {
You can’t perform that action at this time.