Skip to content

Instantly share code, notes, and snippets.

// hook.io handling Stripe
var stripe = require('stripe');
var url = require('url');
var querystring = require('querystring');
module.exports = function (hook) {
var req = hook.req;
var res = hook.res;
@jamztang
jamztang / Each.h
Created January 21, 2016 14:26
Generic HOM for NSArray
#import <Foundation/Foundation.h>
@interface Each <Object> : NSObject
@property (nonatomic, strong) NSArray <Object> *array;
- (instancetype)initWithArray:(NSArray <Object> *)array;
@end
@jamztang
jamztang / LoggingTextView.swift
Last active August 29, 2015 14:15
Display logs with func logln()
// The MIT License (MIT)
//
// Copyright (c) 2015 James Tang ([email protected])
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@jamztang
jamztang / keypath.h
Created October 30, 2014 11:14
A simple @keypath marco
// usage: @keypath(arg)
// like how you use @selector(arg)
// For a full implementation, checkout https://github.com/jspahrsummers/libextobjc
#define keypath(PATH) \
(((\
NSStringFromSelector(@selector(PATH))\
), # PATH))
NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
[[NSUserDefaults standardUserDefaults] setObject:version
forKey:@"version_preference"];
NSString *build = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
[[NSUserDefaults standardUserDefaults] setObject:build
forKey:@"build_preference"];
NSString *githash = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"GITHash"];
[[NSUserDefaults standardUserDefaults] setObject:githash
@jamztang
jamztang / BaseCollectionViewCell.swift
Last active October 15, 2015 13:20
Fix UICollectionViewCell broken autolayout constraints in Xcode 6 GM + iOS 7.1
//
// Created by James Tang @jamztang
// https://gist.github.com/jamztang/68c3e16d071a01db81cf
//
// Credit goes to https://stackoverflow.com/questions/25753373/ios-8-gm-does-not-update-constraints-on-collection-views/25768375#25768375
//
import UIKit
class BaseCollectionViewCell: UICollectionViewCell {
@jamztang
jamztang / CSLoopingAnimationView.h
Created April 16, 2014 14:41
Use Canvas to loop animation forever (hacky way)
#import <UIKit/UIKit.h>
#import "CSAnimation.h"
#import "CSAnimationView.h"
@interface CSLoopingAnimationView : CSAnimationView
@end
@jamztang
jamztang / 1a-LiveCameraView.m
Last active July 7, 2024 09:01
My first hackathon experience - 12 hours of hacking and building the essentials. https://medium.com/p/3db44088db70
- (void)viewDidLoad {
[super viewDidLoad];
self.videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionFront];
self.videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
// self.avatarView is a non full screen GPUImageView instance
// created in Storyboard
[self.videoCamera addTarget:self.avatarView];
[self.videoCamera startCameraCapture];
@jamztang
jamztang / LICENSE
Last active December 25, 2015 03:59
Splitting an NSArray to several components
Copyright (c) 2013 Jamz Tang <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@jamztang
jamztang / LICENSE
Created October 10, 2013 04:54
Adding drop shadow on UINavigationBar (before iOS 6)
Copyright (c) 2013 Jamz Tang <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all