Skip to content

Instantly share code, notes, and snippets.

View elango's full-sized avatar

Elango elango

View GitHub Profile
@elango
elango / jwt-example.go
Created January 11, 2016 04:53 — forked from squiidz/jwt-example.go
JWT in Golang
package main
import (
"fmt"
"net/http"
"time"
"github.com/go-zoo/bone"
"github.com/go-zoo/claw"
mw "github.com/go-zoo/claw/middleware"
import Foundation
extension String
{
var length: Int {
get {
return countElements(self)
}
}
@elango
elango / 0_reuse_code.js
Last active August 29, 2015 14:27
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@elango
elango / gist:2786186
Created May 25, 2012 06:37 — forked from ksm/gist:1875946
CALayer shadowPath done the right way
/*
Source: Apple Developer - Understanding iOS View Compositing
*/
// setup the layer
CALayer *layer = view.layer;
layer.bounds = sublayer_bounds;
layer.backgroundColor = random_color();
// set the shadow properties on the layer
@interface ExtendedManagedObject : NSManagedObject {
BOOL traversed;
}
@property (nonatomic, assign) BOOL traversed;
- (NSDictionary*) toDictionary;
- (void) populateFromDictionary:(NSDictionary*)dict;
+ (ExtendedManagedObject*) createManagedObjectFromDictionary:(NSDictionary*)dict
inContext:(NSManagedObjectContext*)context;
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Code to run asynchronously
dispatch_async( dispatch_get_main_queue(), ^{
// Code to run on main thread
});
});
@elango
elango / SingletonInitializer.m
Created June 24, 2011 05:25 — forked from AlanQuatermain/SingletonInitializer.m
An implementation of a Singleton accessor routine. Provides a dispatch_once-based version and a plain version for pre-(10.6|4.0) systems, with load-time method swapping to install the dispatch version if libdispatch is available at runtime.
#import <libkern/OSAtomic.h>
#import <dispatch/dispatch.h>
#import <objc/runtime.h>
@implementation MySingleton
+ (void) load
{
// check for weak-linked libdispatch symbols
if ( dispatch_queue_create != 0 )
// testend on iOS
var win = Ti.UI.createWindow();
win.open();
// the desired image widths
var imageSizes = [1200,800,600,200];
function validateForm() {
var formIsValid = true;
function enforceTextFieldMinLength(field, minLength) {
if (!field.value || field.value.length < minLength) {
formIsValid = false;
}
}
function enforceLabelHasText(label) {
if (!label.text) {
formIsValid = false;
Ti.include( 'includes/tiframework.js' );
var $ = TiFramework;
var main_window = $('currentWin');
main_window.focus(function() {
// Create the label
var label = $('label')
// Set some options