Skip to content

Instantly share code, notes, and snippets.

View satomixx's full-sized avatar

Satomi Suyama satomixx

View GitHub Profile
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let rootViewController = MainTableViewController()
@satomixx
satomixx / file2.swift
Created August 13, 2015 02:55
[Swift] Storyboardを使わずに画面遷移をすると、遷移先が黒画面になるときやstoryboard doesn't contain a view controller with identifier 'って言われるとき。 ref: http://qiita.com/tsumekoara/items/c8cb6f815e6dc0b6beba
let storyboard = UIStoryboard(name: "STORYBOARD_NAME", bundle: nil)
let nextVC = storyboard.instantiateViewControllerWithIdentifier("STORYBOARD_ID_OF_VC_CLASS") as! UIViewController
navigationController?.pushViewController(nextVC, animated: true)
@satomixx
satomixx / file0.swift
Last active August 29, 2015 14:24
[Swift] AlamofireでApiを叩いて、SwiftyJSONでレスポンスデータを展開する ref: http://qiita.com/tsumekoara/items/9bbb429f41e40c76882c
import UIKit
import Alamofire
import SwiftyJSON
    ・
    ・
    ・
Alamofire.request(.GET, "http://foo.com/api/v1/bar/1", parameters: ["foo": "bar"])
.response { (request, response, data, error) in
println(request)
println(response)
@satomixx
satomixx / file0.txt
Created May 13, 2015 01:55
[Rails] config/routes.rbでのnamespaceとscopeの違い ref: http://qiita.com/tsumekoara/items/90b7439c787817df953f
namespace :api do
get '/test' => 'tests#index'
end
=>
GET /api/test(.:format) api/tests#index
@satomixx
satomixx / file1.txt
Last active August 29, 2015 14:21
RailsでJSON APIのバックエンドを作っていたら、Deviseの認証周りで422 Unprocessable Entityエラーを吐いてしまった場合 ref: http://qiita.com/tsumekoara/items/9a6da4a495af863bebf5
$ curl -H "Content-Type: application/json" -d '{"user":{"email":"hoge@hoge.hoge","password":"12345678"}}' -X POST http://localhost:3000/api/v1/users
@satomixx
satomixx / file0.txt
Created May 12, 2015 09:25
RailsでJSON API用のバックエンドを作っていたら、ActiveAdminが 401を吐いた場合 ref: http://qiita.com/tsumekoara/items/48f0b6d1230d5d704c06
Started GET "/admin" for ::1 at 2015-05-12 18:06:23 +0900
Processing by Admin::DashboardController#index as HTML
Completed 401 Unauthorized in 0ms
@satomixx
satomixx / file0.js
Last active August 29, 2015 14:19
[ionic入門] その1: プロジェクトを作って、localhost や ios simulator や herokuにあげてみる ref: http://qiita.com/tsumekoara/items/8a0604ba2ebab4c12d53
$ npm install -g cordova ionic
@satomixx
satomixx / file0.txt
Last active August 29, 2015 14:18
Git push がやたら落ちていると思ったら、ファイルサイズ・数がやたら多かった場合 ref: http://qiita.com/tsumekoara/items/bc2cd32b6cd0ea626f36
$ git push origin master
Counting objects: 26593, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (24906/24906), done.
Writing objects: 100% (26593/26593), 157.41 MiB | 160.00 KiB/s, done.
Total 26593 (delta 4255), reused 0 (delta 0)
remote: error: GH001: Large files detected.
remote: error: Trace:
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File vendor/bundle/ruby/2.2.0/gems/libv8-3.16.14.7-x86_64-darwin-14/vendor/v8/out/x64.release/libv8_base.a is 150.14 MB; this exceeds GitHub's file size limit of 100 MB
@satomixx
satomixx / file0.txt
Last active August 29, 2015 14:18
[Ruby] コードを短くする為の論理和と論理積(と排他的論理和)のおさらい ref: http://qiita.com/tsumekoara/items/51b756e3b22ad99cbc4b
def check
true if hoge.present? && fuga.present?
end
@satomixx
satomixx / example.rb
Created March 31, 2015 03:03
[Rails 4.x] Linuxで、wkhtmltoimage(wkhtmltopdf) を利用して WebサイトのScreenshot を取る ref: http://qiita.com/tsumekoara/items/b683bcc3564fcef8d3af
# encoding: utf-8
namespace :screenshot do
desc "get screenshot from official_url and save tmp/screenshots/"
task :get => :environment do
quality = 100
aspect_width = 4
aspect_height = 3 # height : width = 4 : 3
width = 1200
height = width * 3 /4