Skip to content

Instantly share code, notes, and snippets.

View AmitaiB's full-sized avatar

Amitai Blickstein AmitaiB

View GitHub Profile
@ohkawa
ohkawa / UIImage+PixelColor.swift
Last active July 13, 2018 20:20
[Swift] 画像の特定のピクセルの色を調べる ref: http://qiita.com/ohkawa/items/71db370b5a6b75bae517
import UIKit
let pixelDataByteSize = 4
extension UIImage {
func getColor(pos: CGPoint) -> UIColor {
let imageData = CGDataProviderCopyData(CGImageGetDataProvider(self.CGImage))
let data : UnsafePointer = CFDataGetBytePtr(imageData)
@mwaterfall
mwaterfall / StringExtensionHTML.swift
Last active May 6, 2024 10:14
Decoding HTML Entities in Swift
// Very slightly adapted from http://stackoverflow.com/a/30141700/106244
// 99.99% Credit to Martin R!
// Mapping from XML/HTML character entity reference to character
// From http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
private let characterEntities : [String: Character] = [
// XML predefined entities:
""" : "\"",
"&" : "&",
@CanTheAlmighty
CanTheAlmighty / DictionaryTwoWay.swift
Last active August 25, 2021 07:58
Two-Way Dictionary in Swift
struct DictionaryTwoWay<S:Hashable,T:Hashable> : DictionaryLiteralConvertible
{
// Literal convertible
typealias Key = S
typealias Value = T
// Real storage
private var st : [S : T] = [:]
private var ts : [T : S] = [:]
@JaviLorbada
JaviLorbada / FRP iOS Learning resources.md
Last active May 24, 2024 10:10
The best FRP iOS resources.

Videos

@lukeredpath
lukeredpath / ReactiveLocation.m
Last active August 29, 2015 14:14
Display location on map when authorised
if ([CLLocationManager locationServicesEnabled]) {
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
RACSignal *locationAuthorizationStatus = [[RACSignal
concat:@[
[RACSignal return:@([CLLocationManager authorizationStatus])],
[[self rac_signalForSelector:@selector(locationManager:didChangeAuthorizationStatus:) fromProtocol:@protocol(CLLocationManagerDelegate)] map:^id(RACTuple *arguments) {
return arguments.second;
}]
@YGeorge
YGeorge / CLLocationManagerStartKit.m
Last active August 29, 2015 14:14
CLLocationManager startkit iOS 7,8
// didFinishLaunchingWithOptions or viewDidLoad:
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
NSLog(@"authorizationStatus: %d", status);
if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined &&
@dniswhite
dniswhite / delegate.h
Last active May 3, 2017 07:16
simple implementation for a delegate on a view controller
#import <UIKit/UIKit.h>
@class SomeViewController;
@protocol SomeViewControllerDelegate <NSObject>
-(void)delegateMethodName: (SomeViewController *) controller;
@end
@interface SomeViewController : UIViewController
@dduan
dduan / NSAttributedString+SimpleHTMLTag.swift
Created December 7, 2014 05:59
Convert Simple Text With HTML Tags to NSAttributedString
extension NSAttributedString {
func replaceHTMLTag(tag: String, withAttributes attributes: [String: AnyObject]) -> NSAttributedString {
let openTag = "<\(tag)>"
let closeTag = "</\(tag)>"
let resultingText: NSMutableAttributedString = self.mutableCopy() as NSMutableAttributedString
while true {
let plainString = resultingText.string as NSString
let openTagRange = plainString.rangeOfString(openTag)
if openTagRange.length == 0 {
@loganwright
loganwright / IntrospectionExtensions.swift
Created November 24, 2014 20:31
Get properties from a swift object -- NSObject extension
extension NSObject {
class var propertyNames: [String] {
get {
var count: UInt32 = 0
let properties: UnsafeMutablePointer<objc_property_t> = class_copyPropertyList(self.classForCoder(), &count)
var propertyNames: [String] = []
for i in 0..<count {
let property: objc_property_t = properties[Int(i)]
if let name = String(UTF8String: property_getName(property)) {
propertyNames += [name]
@calebhicks
calebhicks / ParseAccountViewController
Created July 30, 2014 05:37
Parse Login/Signup View Controller Sample
//
// WIAccountTableViewController.m
// Wired In
//
// Created by Caleb Hicks on 7/17/14.
// Copyright (c) 2014 We Are Wired In. All rights reserved.
//
#import "WIAccountTableViewController.h"
#import <Parse/Parse.h>