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
@mingsai
mingsai / osx-software-update-urls.txt
Created August 3, 2016 14:20 — forked from geoff-nixon/osx-software-update-urls.txt
URLs of the index files used by the software update client on OS X
10.3 (Panther):
https://swscan.apple.com/scanningpoints/scanningpointX.xml
10.4 (Tiger):
https://swscan.apple.com/content/catalogs/index.sucatalog
https://swscan.apple.com/content/catalogs/index-1.sucatalog
10.5 (Leopard):
https://swscan.apple.com/content/catalogs/others/index-leopard.merged-1.sucatalog
@mingsai
mingsai / cloudkit-request.js
Created May 12, 2016 21:57 — forked from spllr/cloudkit-request.js
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
*/
@mingsai
mingsai / cloudkit-server.php
Created May 12, 2016 21:56 — forked from NSURLSession0/cloudkit-server.php
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"}}';
@mingsai
mingsai / index.js
Created May 12, 2016 21:56 — forked from jessedc/index.js
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');
@mingsai
mingsai / MultiExporter.jsx
Created May 1, 2016 14:49 — forked from TomByrne/MultiExporter.jsx
An Illustrator script for exporting layers and/or artboards into separate files (PNG8 / PNG24 / EPS / PDF / SVG / JPG / FXG).See http://www.tbyrne.org/export-illustrator-layers-to-svg-files
// MultiExporter.jsx
// Version 0.1
// Version 0.2 Adds PNG and EPS exports
// Version 0.3 Adds support for exporting at different resolutions
// Version 0.4 Adds support for SVG, changed EPS behaviour to minimise output filesize
// Version 0.5 Fixed cropping issues
// Version 0.6 Added inner padding mode to prevent circular bounds clipping
//
// Copyright 2013 Tom Byrne
// Comments or suggestions to tom@tbyrne.org
@mingsai
mingsai / gist:9db593f182a11235d8c3
Created February 16, 2016 13:58 — forked from casademora/gist:d06e69288fb24c9ace6e
Extension to writeTo NSOutputStream
extension String
{
func writeTo(outputStream:NSOutputStream)
{
if let data = self.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
{
let bytes = ConstUnsafePointer<UInt8>(data.bytes)
outputStream.write(bytes, maxLength: data.length)
}
}
//
// OrdinalNumberFormatter.swift
// Tastify
//
// Created by Ian Grossberg on 10/1/15.
// Copyright © 2015 Noble Desktop. All rights reserved.
//
import Foundation
@mingsai
mingsai / Router.swift
Created February 15, 2016 10:56
Uploading a file with SWIFT via POST multipart/form-data (PHP)
import Foundation
import Alamofire
public enum Router:URLRequestConvertible {
public static let baseUrlString:String = "http://testapi.example.com"
case Upload(fieldName: String, fileName: String, mimeType: String, fileContents: NSData, boundaryConstant:String);
var method: Alamofire.Method {
switch self {
case Upload:
@mingsai
mingsai / unzip.swift
Created February 13, 2016 06:16 — forked from kristopherjohnson/unzip.swift
zip(), zip3(), unzip(), and unzip3() for Swift
// Given array of 2-tuples, return two arrays
func unzip<T, U>(array: [(T, U)]) -> ([T], [U]) {
var t = Array<T>()
var u = Array<U>()
for (a, b) in array {
t.append(a)
u.append(b)
}
return (t, u)
}
@mingsai
mingsai / NSObject+PublicClass.swift
Created February 12, 2016 19:44
Determine if a random NSObject subclass instance is a public or private framework (does not test for your objects)
import Foundation
extension NSObject {
var isPublicClass: Bool {
return self.dynamicType.isPublicClass
}
class var isPublicClass: Bool {
return _PUBLIC_IOS_CLASSES.contains(NSStringFromClass(self))
}