Skip to content

Instantly share code, notes, and snippets.

View nickplee's full-sized avatar
🎹

Nick Lee nickplee

🎹
View GitHub Profile

Keybase proof

I hereby claim:

  • I am nickplee on github.
  • I am nickplee (https://keybase.io/nickplee) on keybase.
  • I have a public key ASBqQhEp99B5vpH_t3ofz4NVxjSclPj-y6msG_CTjnpjEwo

To claim this, I am signing this object:

@nickplee
nickplee / dataToHex.swift
Created November 10, 2016 18:24
Converts Data objects to hex strings
extension Data {
var hexString: String {
return withUnsafeBytes { (b: UnsafePointer<UInt8>) -> String in
var output = ""
let end = b.advanced(by: count)
var ptr = b
while ptr < end {
let value = ptr[0]
output += String(format: "%02X", arguments: [value])
ptr = ptr.advanced(by: 1)
@nickplee
nickplee / detectDebug.swift
Last active November 10, 2016 18:26
Detects the type of provisioning profile embedded in your app's bundle
// Inspired by: http://stackoverflow.com/questions/16243855/how-to-detect-that-a-provisioning-profile-is-for-development-or-distribution-pr
static let isDebugBuild: Bool = {
#if (!arch(i386) && !arch(x86_64)) && os(iOS)
guard let profileURL = Bundle.main.url(forResource: "embedded", withExtension: "mobileprovision"), var profileString = try? String(contentsOf: profileURL, encoding: .ascii) else {
return false
}
profileString = profileString.components(separatedBy: .whitespacesAndNewlines).joined()
return profileString.range(of: "<key>get-task-allow</key><true/>") != nil
#else
@nickplee
nickplee / threadexample.cpp
Created May 10, 2016 20:43 — forked from phg1024/threadexample.cpp
a simple thread example to show thread-safe vector operation
#include <iostream>
#include <concurrent_vector.h>
#include <thread>
#include <algorithm>
#include <cstdlib>
#include <atomic>
#include <vector>
#include <mutex>
int counter = 0;