Skip to content

Instantly share code, notes, and snippets.

View mtsd's full-sized avatar

Kosuke Matsuda mtsd

  • Tokyo, Japan
View GitHub Profile
@mtsd
mtsd / gist:1922322
Created February 27, 2012 07:44
xxx.pngをxxx@2x.pngにファイル名を変更
#################################
# xxx.png → xxx@2x.png
#################################
$ for f in *.png; do mv $f ${f%.png}@2x.png; done
#
$ for f in *.png; do mv $f ${f%.png}; done
$ for f in *; do mv $f $f@2x.png; done
#################################
# xxx@2x.png → xxx.png
@mtsd
mtsd / gist:1939150
Created February 29, 2012 08:25
UIKitを使用してぼやける際の対処方法
/*
UIKitを使用してぼやける際の対処方法
http://novis.jimdo.com/2011/05/29/uiviewの表示ボケにcgrectintegralは使わないほうが良い/
*/
static CGRect KMIntegerRectMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height) {
return CGRectMake(floorf(x), floorf(y), ceilf(width), ceilf(height));
}
static CGRect KMRectInteger(CGRect rect) {
return KMIntegerRectMake( rect.origin.x, rect.origin.y, rect.size.width, rect.size.height );
@mtsd
mtsd / NSString_CoreAdditions.m
Last active October 17, 2015 04:24
Objective-C NSString snippets
@implementation NSString (CoreAdditions)
/*
URL encode
*/
- (NSString *)encodeURIComponent_NON_ARC
{
static NSString * const kLegalCharactersToBeEscaped = @"!*'();:@&=+$,/?%#[]";
return [(NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,
(CFStringRef)self,
@mtsd
mtsd / InfiniteCarouselView.h
Created May 18, 2012 03:26
UIScrollViewの無限スクロールサンプル
#import <UIKit/UIKit.h>
@protocol InfiniteCarouselViewDataSource;
@protocol InfiniteCarouselViewDelegate;
@interface InfiniteCarouselView : UIScrollView <UIScrollViewDelegate>
@property (nonatomic, assign) id<InfiniteCarouselViewDataSource> dataSource;
@property (nonatomic, assign) id<InfiniteCarouselViewDelegate> carouselDelegate;
@mtsd
mtsd / 1_install_postgresql.log
Created June 21, 2012 02:29
log of installing PostgreSQL with Homebrew
$ brew install postgresql
==> Installing postgresql dependency: readline
==> Downloading http://ftpmirror.gnu.org/readline/readline-6.2.tar.gz
######################################################################## 100.0%
==> Downloading patches
######################################################################## 100.0%
######################################################################## 100.0%
==> Patching
patching file vi_mode.c
patching file callback.c
@mtsd
mtsd / 1_install_mysql.log
Created July 27, 2012 06:19
log of installing MySQL with Homebrew
$ brew install mysql
==> Installing mysql dependency: readline
==> Downloading http://ftpmirror.gnu.org/readline/readline-6.2.tar.gz
######################################################################## 100.0%
==> Downloading patches
######################################################################## 100.0%
######################################################################## 100.0%
######################################################################## 100.0%
######################################################################## 100.0%
==> Patching
@mtsd
mtsd / gist:3547300
Created August 31, 2012 01:20
可逆的暗号化
# -*- coding: utf-8 -*-
require 'openssl'
require 'base64'
# https://gist.github.com/176169
module ReversibleEncryption
# extend ActiveSupport::Concern
ENCRYPTION_PRIVATE_KEY = 'secret_token'
def self.included(base)
@mtsd
mtsd / 1_install_homebrew
Created September 23, 2012 11:34
log of installing Homebrew
$ ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1
Press enter to continue
==> /usr/bin/sudo /bin/mkdir /usr/local
WARNING: Improper use of the sudo command could lead to data loss
@mtsd
mtsd / CookieUtilities.m
Created September 27, 2012 05:45
Objective-Cの通信関連コードスニペット
- (void)assignCookie:(NSArray *)cookies
{
NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
NSEnumerator *enumerator = [cookies objectEnumerator];
for (NSHTTPCookie *cookie in enumerator) {
[cookieStorage setCookie:cookie];
}
}
@mtsd
mtsd / 1_install_rbenv
Last active October 11, 2015 22:38
log of installing rbenv and ruby-build
$ brew install rbenv
==> Downloading https://github.com/sstephenson/rbenv/archive/v0.4.0.tar.gz
######################################################################## 100.0%
==> Caveats
To use Homebrew's directories rather than ~/.rbenv add to your profile:
export RBENV_ROOT=/usr/local/var/rbenv
To enable shims and autocompletion add to your profile:
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
==> Summary