Skip to content

Instantly share code, notes, and snippets.

View mingsai's full-sized avatar
🎯
Focusing

Tommie N. Carter, Jr. mingsai

🎯
Focusing
View GitHub Profile
@DejanEnspyra
DejanEnspyra / Obfuscator.swift
Created May 31, 2017 17:51
Obfuscation of hard-coded security-sensitive strings.
//
// Obfuscator.swift
//
// Created by Dejan Atanasov on 2017-05-31.
//
import Foundation
class Obfuscator: AnyObject {

Note

Apple will reject apps that are using private url schemes (Ugh, Apple....) if they are pretty much obvius. Some apps are rejected and others are not, so, be aware of this issue before implementing any of those URL's in your app as a feature.

Updates

  • [UPDATE 4] iOS 10 update: apparently settings now can be reached using App-Pref instead of prefs
  • [UPDATE 3] For now you just can use url schemes to open your apps's settings with Swift 3.0 (Xcode 8). I'll keep you informed when OS preferences can be reached
  • [UPDATE 2] The openURL() method of UIApplication is now deprecated. You should use application(_:open:options:) instead
  • [UPDATE 1] Not yet tested in iOS 10. It will fail because of policies changes in URL scheme handling.
@kevivforever
kevivforever / Cloud function
Last active May 30, 2019 06:15
Firebase cloud Function to read data change on one child. Join data from two childs and write to third child
//Read data change on your ref
exports.functionname = functions.database.ref('/Items/{itemid}')
.onWrite(event => {
const item = event.data.val();
// read data once from second node
const locationRef = event.data.adminRef.root.child('location').child(event.params.itemid);
locationRef.once('value').then(snapshot =>{
const location = snapshot.val();
const city = location.city;
// data node where you want to write data
@Gerst20051
Gerst20051 / copy_latest_simulator_app_to_desktop.sh
Created November 23, 2016 18:11
Copy Latest Simulator App To Desktop Bash Script
#!/bin/bash
DESTINATION_DIR="$HOME/Desktop"
APP_PATH=$(find ~/Library/Developer/CoreSimulator/Devices/*/data/Containers/Bundle/Application/*/*.app -type d -maxdepth 0 -print0 | xargs -0 ls -td | head -n1)
APP_DIRNAME=$(dirname "$APP_PATH")
APP_BASENAME=$(basename "$APP_PATH")
FILE_EXTENSION="${APP_BASENAME##*.}"
FILE_NAME="${APP_BASENAME%.*}"
cd "$APP_DIRNAME"
@benbahrenburg
benbahrenburg / Obfuscator.swift
Created September 19, 2016 00:38 — forked from MathieuWhite/Obfuscator.swift
Obfuscator for Swift
//
// Obfuscator.swift
// SwiftObfuscatorExample
//
// Created by Mathieu White on 2016-07-03.
// Copyright © 2016 Mathieu White. All rights reserved.
//
import Foundation
@T-Pham
T-Pham / AlamofireSwiftyJSONSerializer.swift
Last active March 15, 2017 15:02
Alamofire SwiftyJSON Serializer
//
// AlamofireSwiftyJSONSerializer.swift
//
// Created by Thanh Pham on 7/21/16.
//
import Alamofire
import SwiftyJSON
extension Request {
@drunknbass
drunknbass / EnvConfig.swift
Created June 17, 2016 04:05
Firebase stage + Prod config
import Foundation
@objc(EnvConfig)
class EnvConfig: NSObject {
#if ENVConfigStaging
class var isProduction:Bool {
return false
}
@spllr
spllr / cloudkit-request.js
Last active August 28, 2023 12:04
Setting up an authenticated CloudKit server-to-server request
/**
* Demonstrates how to use Apple's CloudKit server-to-server authentication
*
* Create private key with: `openssl ecparam -name prime256v1 -genkey -noout -out eckey.pem`
* Generate the public key to register at the CloudKit dashboard: `openssl ec -in eckey.pem -pubout`
*
* @see https://developer.apple.com/library/prerelease/ios/documentation/DataManagement/Conceptual/CloutKitWebServicesReference/SettingUpWebServices/SettingUpWebServices.html#//apple_ref/doc/uid/TP40015240-CH24-SW6
*
* @author @spllr
*/
@NSURLSession0
NSURLSession0 / cloudkit-server.php
Created February 7, 2016 21:36
CloudKit server-to-server in PHP
<?php
// Constants
$KEY_ID = 'YOUR_KEY_ID';
$CONTAINER = 'YOUR_CONTAINER';
$PRIVATE_PEM_LOCATION = 'eckey.pem'; // Store this file outside the public folder!
// Config
$url = 'https://api.apple-cloudkit.com/database/1/' . $CONTAINER . '/development/public/records/query';
$body = '{"query":{"recordType":"Articles"}}';
@jessedc
jessedc / index.js
Created February 7, 2016 20:28
Clout Kit Web Services using server to server token
(function() {
/**
* This is an example fetching /users/current from cloud kit with a server to server token without utilising aplpe's cloudkit.js
* https://developer.apple.com/library/ios/samplecode/CloudAtlas/Listings/Node_node_client_s2s_index_js.html#//apple_ref/doc/uid/TP40014599-Node_node_client_s2s_index_js-DontLinkElementID_22
*/
const https = require('https');
var fs = require('fs');
var crypto = require('crypto');