Skip to content

Instantly share code, notes, and snippets.

@satoshin2071
satoshin2071 / gist:5243543
Created March 26, 2013 06:34
ActiveRecordでgroup Byしてカウントをして、カウント数でorderする via 酒と泪とRubyとRailsと
#===sample
#
#MP3プレイヤーのProductのmaker名をレコード数の多い順に並べてその結果のハッシュのkeyであるmaker名を配列として取得
#
Product.where(category: "MP3 Player").group(:maker).order('count_maker desc').count('maker').keys
@satoshin2071
satoshin2071 / gist:5261187
Last active December 15, 2015 12:38
NSLogまとめ
//そのobjがどのクラスに属するか
NSLog(@"%@",NSStringFromClass([obj class]));
//frame
NSLog(@"%@",NSStringFromCGRect(startFrame));
//メソッド名とクラス名と行番号
NSLog(@"%s #%04d", __PRETTY_FUNCTION__, __LINE__);
//インスタンスのクラス名
@satoshin2071
satoshin2071 / gist:5261221
Last active December 15, 2015 12:38
xcode4でDEBUGのプリプロセッサマクロでDEBUGフラグの設定。とprefix.pchの設定。 ついでにRelease ビルドで NSLog() を無効化する
Build Settings > Apple LLVM compiler - Preprocessing > Preprocessor Macros
Debug: DEBUG=1
Release: (DEBUG未定義)
みたいな感じ設定
コード内で
// デバッグ用マクロ
@satoshin2071
satoshin2071 / gist:5465171
Created April 26, 2013 05:14
Install and Configure wget on OS X Mountain Lion 10.8 and fix SSL GNUTLS error
get Xcode
preferences -> download -> commandLintTools install
sudo mkdir /usr/local/src
sudo chmod 0777 /usr/local/src
cd /usr/local/src
curl -O http://ftp.gnu.org/gnu/wget/wget-1.14.tar.gz
tar -zxvf wget-1.14.tar.gz
@satoshin2071
satoshin2071 / markdown.md
Last active December 19, 2015 08:18 — forked from azu/markdown.md

Code - コードの挿入

puts 'The best way to log and share programmers knowledge.'

puts 'The best way to log and share programmers knowledge.'

また、コードをインライン表示することも可能です。

@satoshin2071
satoshin2071 / file0.txt
Created July 4, 2013 02:17
heroku コマンドでUnable to verify certificateエラーが出たら ref: http://qiita.com/satoshin2071/items/bcda0304ea0571b3c4eb
failed
! Heroku client internal error.
! Search for help at: https://help.heroku.com
! Or report a bug at: https://github.com/heroku/heroku/issues/new
Error: Unable to verify certificate, please set `Excon.defaults[:ssl_ca_path] = path_to_certs`, `Excon.defaults[:ssl_ca_file] = path_to_file`, or `Excon.defaults[:ssl_verify_peer] = false` (less secure). (Excon::Errors::SocketError)
Backtrace: /Users/name/.rvm/gems/ruby-1.9.3-p392/gems/excon-0.25.1/lib/excon/ssl_socket.rb:69:in `connect'
/Users/name/.rvm/gems/ruby-1.9.3-p392/gems/excon-0.25.1/lib/excon/ssl_socket.rb:69:in `initialize'
/Users/name/.rvm/gems/ruby-1.9.3-p392/gems/excon-0.25.1/lib/excon/connection.rb:365:in `new'
/Users/name/.rvm/gems/ruby-1.9.3-p392/gems/excon-0.25.1/lib/excon/connection.rb:365:in `socket'
@satoshin2071
satoshin2071 / gist:5973580
Created July 11, 2013 08:25
特定のVCまでpopするサンプル
- (void) popToBeforeHogeViewController
{
// HogeViewController のインデックスを探す
NSInteger targetIndex = -1;
for (int i = 0; i < self.viewControllers.count; i++)
{
if ([self.viewControllers[i] isKindOfClass:[HogeViewController class]])
{
targetIndex = i - 1;
break;
@satoshin2071
satoshin2071 / gist:5973583
Created July 11, 2013 08:25
objc url encode & decode
//encoding
NSString *escapedUrlString = (NSString *)CFURLCreateStringByAddingPercentEscapes(
NULL,
(CFStringRef)plainString,
NULL,
(CFStringRef)@"!*'();:@&=+$,/?%#[]",
kCFStringEncodingUTF8 );
//decoding
NSString *decodedUrlString = (NSString *) CFURLCreateStringByReplacingPercentEscapesUsingEncoding(
@satoshin2071
satoshin2071 / NSArray+quickSort.h
Created July 29, 2013 01:52
objective-C QuickSort
#import <Foundation/Foundation.h>
@interface NSArray (quickSort)
- (NSArray*)quickSort;
@end
@satoshin2071
satoshin2071 / NSArray+grep.h
Last active December 20, 2015 09:58
objective-c blocks Practice
#import <Foundation/Foundation.h>
@interface NSArray (grep)
- (NSArray *)grep:(BOOL(^)(id))block;
@end