Skip to content

Instantly share code, notes, and snippets.

View yamaya's full-sized avatar

Masayuki Yamaya yamaya

  • Sapporo, Hokkaido, Japan
View GitHub Profile
@ishikawa
ishikawa / MyTextView.h
Created November 8, 2008 10:28
Cocoa custom text view with managing marked text
#import <Cocoa/Cocoa.h>
@interface MyTextView : NSView <NSTextInput, NSTextInputClient> {
NSMutableAttributedString *_text;
NSRange _selectedRange;
NSRange _markedRange;
}
@end
if expand('%') =~# '_spec\.rb$'
syn keyword rubyRspec describe context it specify it_should_behave_like before after setup subject
endif
hi def link rubyRspec Function
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("www.tumblr.com"),
domain("www.tumblr-beta.com")
{
ol#posts li blockquote,
body.mceContentBody blockquote {
margin-left: 0 !important;
margin-right: 0 !important;
padding-left: 3px !important;
#!/usr/bin/env ruby
# vim: encoding=utf-8 filetype=ruby
require 'rubygems'
require 'optparse'
require 'yaml'
options = YAML.load(<<CONF)
color: true
verbose: false
@mdippery
mdippery / book.m
Created October 28, 2010 18:11
An example of using @dynamic properties in Objective-C
#import <Foundation/Foundation.h>
@interface Book : NSObject
{
NSMutableDictionary *data;
}
@property (retain) NSString *title;
@property (retain) NSString *author;
@end
@miku
miku / mysqldump2sqlite3.sh
Created December 14, 2010 20:28
Convert a mysql database dump into something sqlite3 understands.
#!/bin/sh
# ================================================================
#
# Convert a mysql database dump into something sqlite3 understands.
#
# Adapted from
# http://stackoverflow.com/questions/489277/script-to-convert-mysql-dump-sql-file-into-format-that-can-be-imported-into-sqlit
#
# (c) 2010 Martin Czygan <[email protected]>
@koyachi
koyachi / gist:765964
Created January 5, 2011 05:13
ビルドオプション毎(アクティブな構成, ターゲット, architecture等)にバージョン情報を変える
XCodeの'グループとファイル'画面でターゲット選択、新規ビルドフェーズ(新規スクリプト)を追加
スクリプトフェーズを最初に持ってくる('バンドルリソースをコピー'の前に持ってくる)
YourProject-Info.plistにVersionValueとVersionValueForDisplayキーを追加。VersionValueに\d+.\d+.\d+な文字列を入れる
スクリプトに以下を書く
VERSION=`cat ./YourProject-Info.plist | tr -d '\n\t' | perl -nle 'print ($_ =~ /^.*?<key>VersionValue<\/key><string>(\d+\.\d+\.\d+)<\/string>.*$/) ? $1 : ""'`
VERSION_FOR_DISPLAY=$VERSION-$CONFIGURATION-$ARCHS
/usr/libexec/PlistBuddy -c "Set :VersionValueForDisplay $VERSION_FOR_DISPLAY" ./YourProject-Info.plist
- (void)scan {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
ALAssetsGroupType sources = ALAssetsGroupLibrary | ALAssetsGroupSavedPhotos;
NSMutableArray *tags = [[NSMutableArray alloc] init];
ALAssetsGroupEnumerationResultsBlock assetsEnumerator = ^(ALAsset *result, NSUInteger index, BOOL *stop){
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if (result) {
if ([[result valueForProperty:ALAssetPropertyType] isEqual:ALAssetTypePhoto]) {
@j0sh
j0sh / Makefile
Created March 31, 2011 07:05
iOS static library cross-compile script.
# iOS builds for ARMv7 and simulator i386.
# Assumes any dependencies are in a local folder called libs and
# headers in a local folder called headers.
# Dependencies should already have been compiled for the target arch.
PROJ=untitled
ifeq ($(IOS), 1)
ARCH=armv7
DEVICE=OS
CC_FLAGS=-arch $(ARCH)
@mads-hartmann
mads-hartmann / Coffeescript ctags
Created April 7, 2011 07:44
ctags definitions for Coffeescript. Very basic for now. "> ctags -e -R source_folder" and then M-. to jump to the definition of any function or variable (if you're using emacs)
--langdef=coffee
--langmap=coffee:.coffee
--regex-coffee=/^[ \t]*([A-Za-z.]+)[ \t]+=.*->.*$/\1/f,function/
--regex-coffee=/^[ \t]*([A-Za-z.]+)[ \t]+=[^->\n]*$/\1/v,variable/