Skip to content

Instantly share code, notes, and snippets.

View matsuda's full-sized avatar

Kosuke Matsuda matsuda

  • Tokyo, Japan
View GitHub Profile
@cockscomb
cockscomb / growlichat.scpt
Created October 4, 2011 11:02
Growl when new message arrived.
using terms from application "iChat"
on message received this_message from this_buddy for this_chat
(*EXAMPLE: this routine automatically sends a random response to messages from specified buddies
set this_name to the name of this_buddy
if the name of this_buddy is in {"Johnny Appleseed"} then
set canned_responses to {"Oh, I know!", "I was just thinking about that.", "Maybe tomorrow.", "Seems logical."}
set this_response to some item of the canned_responses
send this_response to this_chat
end if
*)
@cockscomb
cockscomb / growlmail.scpt
Created October 4, 2011 03:28
Growl when new messages arrived.
using terms from application "Mail"
on perform mail action with messages these_messages for rule this_rule
tell application "Mail"
set the message_count to the count of these_messages
repeat with i from 1 to the message_count
set this_message to item i of these_messages
-- GET THE SENDER OF THIS MESSAGE
set this_sender to the sender of this_message
-- GET SUBJECT OF MESSAGE
@azalea
azalea / gist:1223667
Created September 17, 2011 05:50 — forked from imathis/gist:1104557
FIX for Lion's posix_spawn_ext.bundle: [BUG] Segmentation fault

The segfault problem with posix_spawn is indeed caused by Lion's compiler being LLVM and not GCC by default. However, when I installed RVM, the notes suggested that on Lion you need to add export CC=/usr/bin/gcc-4.2 to your shell startup file (.bashrc or .zshrc as appropriate). I did that, but it seems that's what caused problems: while ruby 1.9.2 needs you to use GCC to install it, using the same compiler for the gems apparently causes breakage.

First, you need to install XCode 4.x, which is now a free (though hefty!) download from the Mac App Store. Without that, you have no gcc, so you won't get anywhere ;-)

Next, what you need to do is clear out your rvm ruby and the associated gems (make sure you are cd'd into your octopress repository then do:

rvm remove ruby-1.9.2 --gems --archive

which will clear everything out so that you can start from scratch. Obviously, if you have other stuff you've installed for other purposes using RVM, be careful with this. If you previously had the export CC li

@mikeyk
mikeyk / (deprecated)UINotificationKeyboardHeight.m
Created September 8, 2011 23:31
Get keyboard height from an NSNotification
@implementation NSNotification (KeyboardHeight)
- (CGFloat)keyboardHeight {
CGRect bounds;
NSValue *boundsValue = [self.userInfo objectForKey:UIKeyboardBoundsUserInfoKey];
if (boundsValue) {
[boundsValue getValue:&bounds];
return bounds.size.height;
} else {
return 0;
@javan
javan / gist:1168475
Created August 24, 2011 16:32
Fix iPhone home button
Found this tip in comment here: http://www.tipb.com/2011/01/04/tipb-bug-home-button-working-iphone/
1.) Open any application
2.) Press and hold the power button until the slide to shutdown swipe bar appears.
3.) Release Power button
4.) Press and hold Home button Lightly
until screen returns to icon screen
@monkeydom
monkeydom / CompareMacro.h
Created August 24, 2011 10:33
Objective-C Compare Macro for your convenience
#if !defined(COMPARE)
#define COMPARE(A,B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? NSOrderedAscending : (__a > __b ? NSOrderedDescending : NSOrderedSame); })
#endif
@yashigani
yashigani / MyPickerView.h
Last active June 28, 2017 01:48
MyPickerView
#import <UIKit/UIKit.h>
@interface MyPickerView : UIView
<UIPickerViewDataSource, UIPickerViewDelegate>
{
UIToolbar *toolbar;
UIPickerView *picker;
void (^completion)(NSString *selected);
#!/usr/bin/env ruby
#
# A quick script to dump an overview of all the open issues in all my github projects
#
require 'octokit'
require 'awesome_print'
require 'rainbow'
@jugyo
jugyo / gist:919046
Created April 14, 2011 07:14
TextMate command to convert CoffeeScript to JavaScript
#!/bin/bash
coffee -scp --bare | sed 's/</\&lt;/g' | sed 's/>/\&gt;/g'
# original: https://github.com/jashkenas/coffee-script-tmbundle/blob/master/Commands/Compile%20and%20Display%20JS.tmCommand
@juno
juno / gemref
Created April 9, 2011 17:23
display runtime gem information in ./Gemfile
#!/usr/bin/env ruby
require 'ansi/code'
require 'bundler'
require 'json'
require 'open-uri'
class Integer
def to_currency
self.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\1,').reverse
end