Skip to content

Instantly share code, notes, and snippets.

import UIKit
/*
A controller object that manages a simple model -- a collection of month names.
The controller serves as the data source for the page view controller; it therefore implements pageViewController:viewControllerBeforeViewController: and pageViewController:viewControllerAfterViewController:.
It also implements a custom method, viewControllerAtIndex: which is useful in the implementation of the data source methods, and in the initial configuration of the application.
There is no need to actually create view controllers for each page in advance -- indeed doing so incurs unnecessary overhead. Given the data model, these methods create, configure, and return a new view controller on demand.
*/
@keisei1092
keisei1092 / private.xml
Last active September 20, 2016 23:25
Karabiner private preference 20150806 - 20160921
<?xml version="1.0"?>
<root>
<item>
<name>Command+Ctrl+sで左のスクリーンへ移動</name>
<identifier>private.hogee1</identifier>
<autogen>
__KeyToKey__
KeyCode::S, ModifierFlag::COMMAND_R, ModifierFlag::CONTROL_L,
KeyCode::CURSOR_LEFT, ModifierFlag::CONTROL_L
</autogen>

コード進行について

  • 終止
    • 全終止
      • V Iと進行して展開がいったん落ち着くこと
      • コードの進みを落ち着かせるのに最もスタンダードな方法
    • 偽終止
      • VからIではなくIの代理コードに終止すること
      • Iが来るだろうというところに裏切りを与える効果がある
  • 適切に配置することで、単調だったコード進行に表情をつけることができ、ドラマを演出させるのにもうってつけ

In your shell,

$ mkdir doujin-circle-scrape
$ cd doujin-circle-scrape
$ bundle init
$ emacs Gemfile

In Gemfile, add following to end

@keisei1092
keisei1092 / playground-snippet.swift
Last active November 17, 2016 03:22
PlaygroundでパッとViewだすやつ
//: Playground - noun: a place where people can play
import UIKit
import PlaygroundSupport
let viewController = UIViewController()
viewController.view.backgroundColor = UIColor.white
let navigationController = UINavigationController(rootViewController: viewController)
navigationController.view.frame = CGRect(x: 0, y: 0, width: 320, height: 569)

NO Alamofire BUT URLSession

Alamofire、AlamofireObjectMapperおよびAlamofireImageは、依存性を増やしたり、融通がきかなくなるため使いません。
その代わりSwiftビルトインのクラスURLSessionを使います。(参考:

Examples

enum JSONError: String, ErrorType {
    case NoData = "ERROR: no data"
@keisei1092
keisei1092 / RxSwiftMinimalImplementation.swift
Last active December 19, 2016 07:48
RxSwift最小実装
//
// ViewController.swift
// rxpractive
//
// Created by SaitoKeisei on 2016/12/19.
// Copyright © 2016 keisei_1092. All rights reserved.
//
import UIKit
import RxSwift
youtube-dl -x --audio-format mp3 <URL>
var target = $('.yt-lockup-meta-info');
// top
$.each(target, function() {
var videoId = $(this).closest('.yt-lockup').data('context-item-id');
var element = '<li><a href="http://localhost:4568/youtube-dl/' + videoId + '" target="_blank">mp3</a>';
$(this).append(element);
});
// show
require 'sinatra'
set :port, 4568
get '/youtube-dl/:id' do
`youtube-dl -o '~/Desktop/%(title)s.%(ext)s' --add-metadata -x --audio-format mp3 'https://www.youtube.com/watch?v=#{params[:id]}'`
end