Skip to content

Instantly share code, notes, and snippets.

@shiningabdul
shiningabdul / gist:8634264
Last active January 4, 2016 14:28
Xcode Bot Archive Post-Build Script to Upload Automatically to HockeyApp. Updated from here to use Hockey App: http://developmentseed.org/blog/2011/sep/02/automating-development-uploads-testflight-xcode/.
# Valid and working as of 04/21/2014
# Xcode 5.0.1, XCode Server
#
#Settings
API_TOKEN="This can be found here: https://rink.hockeyapp.net/manage/auth_tokens"
DISTRIBUTION_LISTS="This is a comma seperated list of tags found under App -> Users -> "
PROVISIONING_PROFILE="You will have to manually copy your profile to /Library/Server/Xcode/Data/ProvisioningProfiles/<profile>.mobileprovision"
#EXAMPLE:"/Library/Server/Xcode/Data/ProvisioningProfiles/DocLink_InHouse_2013.mobileprovision"
NOTIFY="1"
@shiningabdul
shiningabdul / routes.js
Last active August 27, 2017 21:59
Sample route setup with middleware
module.exports = function(app, express) {
var router = express.Router(); // get an instance of the express Router
// middleware to use for all requests
router.use(function(req, res, next) {
console.log('Incoming request');
console.log('Body:');
console.log(req.body);
console.log('Url:');
console.log(req.url);
const secretForJWT = "thisIsAReallyGoodSecretNo";
const jwtExpireTimeInSeconds = 60*60;
generate_jwt = function(tokenData) {
return jwt.sign(tokenData, secretForJWT, {
expiresIn: jwtExpireTimeInSeconds
});
};
verify_jwt = function(token) {
read_a_user = function(req, res) {
var userId = [req.params.id];
// decodedToken is gotten by jwt.verify(token, config.secretForJWT);
// assume the original object that was passed when creating the user had an id
if (req.decodedToken.id === userId) {
// get the user and do anything else needed
}
};
import Foundation
protocol Transmittable : Codable {
}
extension Transmittable {
func encode() -> Data {
var data:Data = Data()
try? data = JSONEncoder().encode(self)
import Foundation
final class APICaller {
private let baseUrl:String = "http://localhost:8080/"
static let sharedInstance = APICaller()
private init() {}
func performCallToEndpoint<T : Transmittable>(_ endpoint:String, using method:String, body:Transmittable?, responseType: T.Type, completion: @escaping (_ error:Error?, _ serverError:ServerError?, _ response:T?) -> Void) {
class User : Transmittable {
var id:String?
}
// Turning a user into JSON data
let user = User()
user.id = "123"
let data = user.encode()
let user = User()
user.id = "233"
APICaller.sharedInstance.performCallToEndpoint("/users", using: "POST",
body: user, responseType:User.self) { (error, serverError, response) -> () in
if let response = response {
print(response)
}
}
import UIKit
import Stripe
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
import UIKit
import PassKit
import Stripe
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.