Skip to content

Instantly share code, notes, and snippets.

View muukii's full-sized avatar
✈️
We live in a twilight world.

Hiroshi Kimura muukii

✈️
We live in a twilight world.
View GitHub Profile
@muukii
muukii / gist:1bc878babe2be43178f9
Last active August 29, 2015 14:04
先頭にアイコンを付けた文字列で、アイコンの縦位置がずれる場合の調整
[mutableAttributedString addAttribute:NSBaselineOffsetAttributeName
value:@(-1.)
range:NSMakeRange(0, 1)];
<!-- Code syntax highlight -->
<link href="http://static.tumblr.com/7ugkukk/n2bn9udeb/tomorrow-night.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript " src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js"></script>
<script type="text/javascript">
$(function(){
var code = $('code');
code.replaceWith('<pre>'+code.text()+'</pre>');
$('pre').css({
'overflow-x': 'scroll',
@muukii
muukii / gist:4c6322afdfe24e6adf96
Last active August 29, 2015 14:06
Swift NSFetchedResultsController
var fetchedResultsController: NSFetchedResultsController {
if _fetchedResultsController != nil {
return _fetchedResultsController!
}
let fetchRequest = NSFetchRequest()
// Edit the entity name as appropriate.
let entity = NSEntityDescription.entityForName(CPCommentObject.entityName(), inManagedObjectContext: NSManagedObjectContext.managedObjectContextForMainThread())
fetchRequest.entity = entity
private struct FavoritesModelConnectingType: RawOptionSetType {
private var value: UInt = 0
init(_ value: UInt) {
self.value = value
}
// MARK: RawOptionSetType
static func fromMask(raw: UInt) -> FavoritesModelConnectingType {
return self(raw)
}
@muukii
muukii / UserDefaults.swift
Created February 1, 2015 15:23
UserDefaults
// UserDefaults.swift
//
// Copyright (c) 2015 muukii
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@muukii
muukii / BaseViewController.swift
Last active December 24, 2016 13:44
BaseViewController.swift
// BaseViewController.swift
//
// Copyright (c) 2015 muukii
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@muukii
muukii / fixOrientation.swift
Created September 8, 2015 00:59
fix orientation
extension UIImage {
func fixOrientation () -> UIImage {
if self.imageOrientation == .Up {
return self
}
var transform = CGAffineTransformIdentity
let width = self.size.width
let height = self.size.height
switch (self.imageOrientation) {
@muukii
muukii / MTKCIImageView.swift
Created September 28, 2015 05:32
CIImageView (Using Metal)
//
// MTKCIImageView.swift
// Fil
//
// Created by Muukii on 9/27/15.
// Copyright © 2015 muukii. All rights reserved.
//
import Foundation
import Metal
@muukii
muukii / GLKCIImageView.swift
Created September 28, 2015 05:39
CIImageView (Using GLKit)
//
// GLKCIImageView.swift
// Fil
//
// Created by Muukii on 9/1/15.
// Copyright © 2015 muukii. All rights reserved.
//
import Foundation
import GLKit
extension Realm {
public var queue: NSOperationQueue {
get {
if let queue = objc_getAssociatedObject(self, &StoredPropaties.queue) as? NSOperationQueue {
return queue
}
let queue = self.createDefaultQueue()
self.queue = queue