Skip to content

Instantly share code, notes, and snippets.

@keisei1092
keisei1092 / data.js
Created February 5, 2017 13:13
hatenablog2017-02-05a
var $cdTitle = $('<div></div>');
$cdTitle.append($('<p></p>').text('ミライトアルマチ詩恩'));
$cdTitle.append($('<p></p>').text('keisei feat. 初音ミク'));
var $tracks = $('<div></div>');
$tracks.append($('<li class="song pointer blink" data-sound-source="yumeupload"></li>').text('ゆめアップロード'));
$tracks.append($('<li class="song pointer" data-sound-source="birthday"></li>').text('birthday'));
$tracks.append($('<li class="song pointer" data-sound-source="sakulife"></li>').text('saku*life (shion mix)'));
import UIKit
import PlaygroundSupport
struct Item {
let id: Int
let name: String
}
class ViewController: UITableViewController {
let items: [Item] = [
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
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
youtube-dl -x --audio-format mp3 <URL>
brew install youtube-dl
@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

NO Alamofire BUT URLSession

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

Examples

enum JSONError: String, ErrorType {
    case NoData = "ERROR: no data"
@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)

In your shell,

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

In Gemfile, add following to end