Skip to content

Instantly share code, notes, and snippets.

View aki-null's full-sized avatar

Akihiro Noguchi aki-null

View GitHub Profile
@aki-null
aki-null / gist:2490310
Created April 25, 2012 14:51 — forked from hajipy/gist:2490294
[NSDictionary objectForKeyWithoutNull]
@implementation NSDictionary (objectForKeyWithoutNull)
- (id)objectForKeyWithoutNull:(id)aKey
{
id value = [self objectForKey:aKey];
if (value == [NSNull null]) {
return nil;
}
else {
return value;
}
@aki-null
aki-null / hack.sh
Last active December 27, 2017 05:48 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2261536/hack.sh | sh
#
@aki-null
aki-null / gist:1497649
Created December 19, 2011 15:23
Core Text APIを使用した際に起こる行間の問題の回避
NSFont *normalFont = [NSFont systemFontOfSize:12];
CGRect renderFrame = CGRectMake(0, 0, 300, 50); // box to render the text into
static NSLayoutManager *layMan = nil;
if (!layMan) {
layMan = [NSLayoutManager new];
}
CGFloat lineHeight = [layMan defaultLineHeightForFont:normalFont]; // calculate the expected height of a line
NSDictionary *attrDict = [NSDictionary dictionaryWithObject:normalFont andKey:NSFontAttributeName];
@aki-null
aki-null / gist:1315641
Created October 26, 2011 06:52
Twitterの投稿
以下の内容をポストしようとすると、ポスト内容が改変されてポストされます。
@25Re t.coの短縮結果が元のURLよりも長い場合にも短縮されるようになったので、140文字以内だと思って投稿したら、URLが元より長くなって140文字以上になるという事が起こっています。だから、これからは文字をカウントするには、t.coの短縮結果を予測する必要があります。
@25Re http://t.co の短縮結果を予測する必要があります。
http://twitter.com/#!/aki_null/status/129087853127925760
@aki-null
aki-null / hashtag_regex
Created July 13, 2011 03:54
Hashtag Regex
(^|[^&/0-9\uff10-\uff19_a-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0100-\u024f\u0253\u0254\u0256\u0257\u0259\u025b\u0263\u0268\u026f\u0272\u0289\u028b\u02bb\u1e00-\u1eff\u0400-\u04ff\u0500-\u0527\u2de0-\u2dff\ua640-\ua69f\u0591-\u05bd\u05bf\u05c1-\u05c2\u05c4-\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f2\ufb1d-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufb4f\u0610-\u061a\u0620-\u065f\u066e-\u06d3\u06d5-\u06dc\u06de-\u06e8\u06ea-\u06ef\u06fa-\u06fc\u06ff\u0750-\u077f\u08a0\u08a2-\u08ac\u08e4-\u08fe\ufb50-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\u200c\u0e01-\u0e3a\u0e40-\u0e4e\u1100-\u11ff\u3130-\u3185\uA960-\uA97F\uAC00-\uD7AF\uD7B0-\uD7FF\u3040-\u309f\u30a0-\u30ff\u4e00-\u9fff\u3005\u303b\uff21-\uff3a\uff41-\uff5a\uff66-\uff9f\uffa1-\uffdc])(#|\uff03)([0-9\uff10-\uff19_a-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0100-\u024f\u0253\u0254\u0256\u0257\u0259\u025b\u0263\u0268\u026f\u0272\u0289\u028b\u02bb\u1e00-\u1eff\u0400-\u04ff\u0500-\u0527\u2de
@aki-null
aki-null / gist:973017
Created May 15, 2011 10:03
まどか☆マギカのエンド
git filter-branch --index-filter "find ./ -name "witch" -exec git rm -f {} \;"
git filter-branch --index-filter "find ./ -name "madoka_shikame" -exec git mv {} ./gods \;"
git push --force
// もしキャプチャーグループ1が空でない場合はそれをURLとする。
// そうでない場合はキャプチャーグループ0(全体)をURLとする。
(?<=[\[[\(({{⟨«‘“"'⦅⸨「「『〚⟦〔❲〘〈《⟪<<≪‹【〖])
[^\[[\(({{⟨«‘“"'⦅⸨「「『〚⟦〔❲〘〈《⟪<<≪‹【〖]*?
(https?://[^\s\]]\))}}⟩»’”"'⦆⸩」」』〛⟧〕❳〙〉》⟫>>≫›】〗]+)
(?=[\]]\))}}⟩»’”"'⦆⸩」」』〛⟧〕❳〙〉》⟫>>≫›】〗])
|https?://[^\s]+(?<![”])