Skip to content

Instantly share code, notes, and snippets.

View nkmrh's full-sized avatar
🐧

Hajime Nakamura nkmrh

🐧
View GitHub Profile
@kylefox
kylefox / color.m
Created January 27, 2012 17:45
Generate a random color (UIColor) in Objective-C
/*
Distributed under The MIT License:
http://opensource.org/licenses/mit-license.php
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
@alco
alco / ripple.frag
Created July 8, 2012 11:52
Ripple effect for GLSL
// simple fragment shader
// 'time' contains seconds since the program was linked.
uniform float time;
uniform sampler2D tex;
uniform sampler2D tex2;
float radius = .5;
@miminashi
miminashi / gist:5217195
Last active December 15, 2015 06:29
Storyboardでmerge conflictが発生した場合の対処方法

うまくいったのがあったら追記していきます。

inferredMetricsTieBreakersの中でconflictしていた場合

storyboardの末尾のほうにある以下の様な部分のお話ですね。

<inferredMetricsTieBreakers>
    <segue reference="YUa-1a-iG8"/>
    <segue reference="nKl-EP-JoK"/>
 
@saiday
saiday / gist:7394795
Created November 10, 2013 06:58
UITabBarController disable Title, Image align center
.h
@interface TabViewController : UITabBarController
.m
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
@JaviLorbada
JaviLorbada / FRP iOS Learning resources.md
Last active June 17, 2024 06:08
The best FRP iOS resources.

Videos

@josephg
josephg / 0dedict.py
Last active April 28, 2024 14:07
Apple dictionaries
# Thanks to commenters for providing the base of this much nicer implementation!
# Save and run with $ python 0dedict.py
# You may need to hunt down the dictionary files yourself and change the awful path string below.
# This works for me on MacOS 10.14 Mohave
from struct import unpack
from zlib import decompress
import re
filename = '/System/Library/Assets/com_apple_MobileAsset_DictionaryServices_dictionaryOSX/9f5862030e8f00af171924ebbc23ebfd6e91af78.asset/AssetData/Oxford Dictionary of English.dictionary/Contents/Resources/Body.data'
f = open(filename, 'rb')
@nacyot
nacyot / LookUp.APPLESCRIPT
Last active March 2, 2022 15:10
OSX Dictionary Lookup History Service
on run {input, parameters}
set logPath to "Dropbox/Dictionary/words.txt"
set lookUpWord to quoted form of (input as string)
tell application "System Events" to tell (process 1 where frontmost is true)
set windowTitle to name
try
set windowTitle to windowTitle
set titleBar to name of window 1
end try
@freak4pc
freak4pc / MKMultiPoint+Ext.swift
Last active April 25, 2024 04:38
Get a list of coordinates from a MKPolyline / MKRoute
public extension MKMultiPoint {
var coordinates: [CLLocationCoordinate2D] {
var coords = [CLLocationCoordinate2D](repeating: kCLLocationCoordinate2DInvalid,
count: pointCount)
getCoordinates(&coords, range: NSRange(location: 0, length: pointCount))
return coords
}
}
@RuiNelson
RuiNelson / Levenshtein.swift
Last active August 2, 2023 03:50
Levenshtein distance between two String for Swift 4.x
import Foundation
extension String {
subscript(index: Int) -> Character {
return self[self.index(self.startIndex, offsetBy: index)]
}
}
extension String {
public func levenshtein(_ other: String) -> Int {
@lattner
lattner / async_swift_proposal.md
Last active April 21, 2024 09:43 — forked from oleganza/async_swift_proposal.md
Concrete proposal for async semantics in Swift

Async/Await for Swift

Introduction

Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.

This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.