Skip to content

Instantly share code, notes, and snippets.

@adamawolf
adamawolf / Apple_mobile_device_types.txt
Last active July 5, 2024 18:23
List of Apple's mobile device codes types a.k.a. machine ids (e.g. `iPhone1,1`, `Watch1,1`, etc.) and their matching product names
i386 : iPhone Simulator
x86_64 : iPhone Simulator
arm64 : iPhone Simulator
iPhone1,1 : iPhone
iPhone1,2 : iPhone 3G
iPhone2,1 : iPhone 3GS
iPhone3,1 : iPhone 4
iPhone3,2 : iPhone 4 GSM Rev A
iPhone3,3 : iPhone 4 CDMA
iPhone4,1 : iPhone 4S
@hugooliveirad
hugooliveirad / nefToJpeg.sh
Last active February 24, 2021 00:29
Convert RAW images (.NEF) to jpeg and create shareble versions
#!/bin/bash
# create folders. Ensure your directory is writable
mkdir -p jpegs/share;
# loops .NEF files in this directory. Subdirectories aren't supported
for f in *.NEF;
do
# gets filename and inserts .jpg at the end
@santoshrajan
santoshrajan / JSONStringify.swift
Created October 12, 2014 05:36
JSON Stringify in Swift
// Author - Santosh Rajan
import Foundation
let jsonObject: [AnyObject] = [
["name": "John", "age": 21],
["name": "Bob", "age": 35],
]
func JSONStringify(value: AnyObject, prettyPrinted: Bool = false) -> String {
@MihaelIsaev
MihaelIsaev / HMAC.swift
Last active December 4, 2019 04:51
Easy to use Swift implementation of CommonCrypto HMAC. You can easily hash your String to: md5, sha1, sha224, sha256, sha384, sha512 with pure Swift.
//
// HMAC.swift
//
// Created by Mihael Isaev on 21.04.15.
// Copyright (c) 2014 Mihael Isaev inc. All rights reserved.
//
// ***********************************************************
//
// How to import CommonCrypto in Swift project without Obj-c briging header
//
@ValCanBuild
ValCanBuild / Podfile
Created March 3, 2016 11:39
Using variables in your Podfile
platform :ios, '9.0'
use_frameworks!
$rxVersion = '~> 2.2.0'
target 'MyProject' do
pod 'RxSwift', $rxVersion
pod 'RxCocoa', $rxVersion
end
@IanKeen
IanKeen / ObservableType+Weak.swift
Created April 6, 2016 18:36
Allow a more concise way to weakly subscribe to Observables using self.someFunction
//
// ObservableType+Weak.swift
//
// Created by Ian Keen on 6/04/2016.
// Copyright © 2016 Ian Keen. All rights reserved.
//
import Foundation
import RxSwift
@johndpope-karhoo
johndpope-karhoo / simulator_populator
Last active September 13, 2016 01:53 — forked from cabeca/simulator_populator
This script removes and recreates all simulators in Xcode 6.
gem install snapshot; snapshot reset_simulators
killall Xcode
sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService
rm -rf ~/Library/Developer/CoreSimulator/Devices
open /Applications/Xcode.app
ffmpeg -i data/video.mp4 -vcodec h264 -b:v 1000k -acodec mp2 data/output.mp4
@rnapier
rnapier / doOnce.swift
Last active April 20, 2022 16:12
A function that only executes once. Good Swift or over-clever?
// Swift3 gets rid of dispatch_once and recommends replacing it with a lazy global.
// That's very straightforward when dispach_once is used to initialize something, but
// isn't an exact match when you want something to execute once, and then become a noop
// in a thread-safe way.
// The following approach seems completely "correct" and I guess actually a bit elegant,
// if by "elegant" you mean "terse and not immediately obvious to the reader, which makes
// you look very clever."
var doOnce: () -> Void = {
@ptrkstr
ptrkstr / NSColor+Extended.swift
Last active December 19, 2016 22:54
NSColor extension
extension NSColor {
/// Creates a NSColor from "#XXXXXX"/"XXXXXX" format
convenience init(hex: String, alpha: CGFloat = 1) {
// TODO: Validate hex string is in the "#XXXXXX" or "XXXXXX" format
let scanner = Scanner(string: hex)
scanner.scanLocation = hex[hex.startIndex] == "#" ? 1 : 0
var rgb: UInt32 = 0