Skip to content

Instantly share code, notes, and snippets.

@yaakaito
yaakaito / gist:1366449
Created November 15, 2011 08:22
.emacs.el
;シフトで範囲選択
(pc-selection-mode 1)
;バックアップ作らない
(setq make-backup-files nil)
;オートセーブしない
(setq auto-save-default nil)
;スタート画面を表示しない
(setq inhibit-startup-message t)
;ツールバーを隠す
@yaakaito
yaakaito / gist:1366452
Created November 15, 2011 08:24
.zshenv
alias ls="ls -v"
export LANG=ja_JP.UTF-8
alias emacs="/Applications/Emacs.app/Contents/MacOS/Emacs"
export PATH=/opt/local/bin/:/opt/local/sbin/:$PATH
export PATH=/usr/local/ActivePerl-5.10/bin/:/usr/local/bin/:$PATH
alias perl=perl5.10.0
alias pstop="ps aux | grep top"
(function(){var w = $(window).width(), h = $(window).height();getMouseX = function(e){return e.x;};getMouseY = function(e){return e.y;};setInterval(function(){for(var x = 0; x < w; x+=10){for(var y = 0; y < h; y+=10){onMouseDown({x:x,y:y});}}}, 3000);})()
@yaakaito
yaakaito / UserAgent.m
Created April 3, 2012 23:53
iOSアプリでUAが知りたかったけど、見つからなかったので力技で出すコード 4.3~ (対応してないのはそれっぽいのが出るようになってる)
#import "UserAgent.h"
@implementation UserAgent
// iOS4.3 later
+ (NSString *)defaultUserAgent {
// shared
static dispatch_once_t pred = 0;
__strong static NSMutableDictionary *userAgentTable;
dispatch_once(&pred, ^{
userAgentTable = [[NSMutableDictionary alloc] init];
@yaakaito
yaakaito / UserAgent.h
Created April 5, 2012 04:36
gist: 2296450 の続き、文字列マッチだるいのでローカルファイル読み込んでUIWebViewからjs経由で教えてもらう -> 読み込む必要すらなかった
#import <Foundation/Foundation.h>
@interface UserAgent : NSObject<UIWebViewDelegate>
@property BOOL loaded;
+ (NSString *)defaultUserAgent;
@end
@yaakaito
yaakaito / quickcheck.js
Created May 14, 2012 16:21 — forked from VoQn/quickcheck.js
prototyping quickcheck for js
var TestEnvironment = (function(){
return {
seed: 1,
count: 100,
current: {
args: [],
isPassed: false,
isSkipped: false,
set: function( args, prop ){
@yaakaito
yaakaito / gist:2703804
Created May 15, 2012 18:06
quickcheckこんな感じかのぉ
- (BOOL)propAdd:(NSInteger)a b:(NSInteger)b {
return [Hoge add:a b:b] == a + b;
}
- (void)testAdd {
NLTQuickCheckTests *testCase = [NLTQuickCheckTest testWithName:@"exsample"
propSelector:@selector(propAdd:b:)
arbitrarys:[NSArray arrayWithObjects:[NLTQuickCheckArbitrary intArbitray],
[NLTQuickCheckArbitrary intArbitray], nil]];
require 'formula'
class Emacs < Formula
url 'http://ftp.gnu.org/pub/gnu/emacs/emacs-24.1.tar.gz'
md5 '368d79b0dbb4aef9886bd8d6ba08ed77'
homepage 'http://www.gnu.org/software/emacs/'
if ARGV.include? "--use-git-head"
head 'git://git.sv.gnu.org/emacs.git'
else
@yaakaito
yaakaito / gist:3159976
Created July 22, 2012 15:21 — forked from tikitikipoo/gist:1812562
UIBarButtonItemのtintColorはios5からなのでios4でも同様なことができるように
// 出所:http://wizard.st/blog/archives/156
//   :http://fredandrandall.com/blog/2011/03/31/how-to-change-the-color-of-a-uibarbuttonitem/
UIBarButtonItem *item = nil;
if ([[[UIDevice currentDevice] systemVersion] floatValue] > 4.9) {
item = [[UIBarButtonItem alloc] initWithTitle:title
style:useStyle
target:self
action:@selector(toolBarButtonTapped:)];
@yaakaito
yaakaito / gist:3162142
Created July 23, 2012 05:50
CustomUIBarButton/なんかこんな感じにしてUIButtonのdrawRectでよしなに調整したらいけるんとちゃうか
UIBarButtonItem *item = nil;
UIImage *image = [UIImage imageNamed:@"navigation_bar_back_button"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setBackgroundImage:image forState:UIControlStateNormal];
[button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"ほげ" forState:UIControlStateNormal];
button.titleLabel.textColor = [UIColor whiteColor];
button.titleLabel.textAlignment = UITextAlignmentCenter;
button.titleLabel.font = [UIFont boldSystemFontOfSize:12];
button.frame = CGRectMake(0, 0, image.size.width, image.size.height);