Skip to content

Instantly share code, notes, and snippets.

@matsuhisa
matsuhisa / file0.swift
Last active August 29, 2015 14:19
Swift で CoreData の必要な初期データー(マスターデータ)を用意する ref: http://qiita.com/matsuhisa@github/items/741d7b1c2541ea6fc68d
func initMasters() {
println("initMasters ------------")
// plist の読み込み
let path:NSString = NSBundle.mainBundle().pathForResource("Masterdata", ofType: "plist")!
var masterDataDictionary:NSDictionary = NSDictionary(contentsOfFile: path)
let app: AppDelegate = UIApplication.sharedApplication().delegate as AppDelegate
@matsuhisa
matsuhisa / AppDelegate.swift
Last active August 29, 2015 14:20
SugarRecord(Swift 1.2)を使ってCoreDataの操作を楽にしてみる ref: http://qiita.com/matsuhisa@github/items/499284a38733799117fa
import UIKit
import CoreData
import SugarRecord
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
@matsuhisa
matsuhisa / Article.swif
Last active August 29, 2015 14:20
Swift で Core Dataのリレーションシップ(1対多)を試す ref: http://qiita.com/matsuhisa@github/items/62978178278e4ff14a7d
import Foundation
import CoreData
class Article: NSManagedObject {
@NSManaged var title: String
@NSManaged var body: String
@NSManaged var blog: Blog!
}
@matsuhisa
matsuhisa / AddController.swift
Last active August 29, 2015 14:21
Swift でキーボードをタッチイベントで隠す ref: http://qiita.com/matsuhisa_h/items/2888cd0d4ce99805b247
@IBAction func tapScreen(sender: UITapGestureRecognizer) {
self.view.endEditing(true)
}
@matsuhisa
matsuhisa / pre-commit
Last active August 29, 2015 14:22
git commit する前にコンフリクトの残りがないかチェックする ref: http://qiita.com/matsuhisa_h/items/0b9de2ef534807065e54
#!/bin/sh
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# コンフリクトしたファイルを探す
if has('gui_macvim')
set showtabline=2
set imdisable // IMを無効化
#set transparency=5 // 透明度を指定
set transparency=50
// 最後のタブを閉じた時にMacVimを終了する
defaults write org.vim.MacVim MMTerminateAfterLastWindowClosed yes
// ファイルのドロップした時の動き
<html>
<head>
<title>js - test</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(function() {
var original_src = $("img.lazy_image").attr("src");
$("img.lazy_image").attr("src", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAMAAABHPGVmAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyhpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMDY3IDc5LjE1Nzc0NywgMjAxNS8wMy8zMC0yMzo0MDo0MiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTUgKE1hY2ludG9zaCkiIHhtcE1NOkl
@matsuhisa
matsuhisa / lazy_image.html
Created August 16, 2015 16:13
画像についてclassの指定がある画像について、あとで読み込む
<html>
<head>
<title>js - test</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(function() {
class_name = 'lazy_image';
var substitute_image = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAMAAABHPGVmAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyhpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMDY3IDc5LjE1Nzc0NywgMjAxNS8wMy8zMC0yMzo0MDo0MiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTUgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6Q0E5NjM5M
module.exports = (robot) ->
github = require('githubot')(robot)
robot.router.post '/github', (req, res) ->
room = 'general'
issue = req.body.issue ? req.body.pull_request
type = if req.body.pull_request then 'Pull Request' else 'issue'
assignee = if issue.assignee then issue.assignee.login else 'No Aassignee'
module.exports = (robot) ->
github = require('githubot')(robot)
robot.router.post '/github', (req, res) ->
room = 'general'
issue = req.body.issue ? req.body.pull_request
type = if req.body.pull_request then 'Pull Request' else 'issue'
if req.body.action in ['unlabeled']