Skip to content

Instantly share code, notes, and snippets.

View lexrus's full-sized avatar
🏠
Working from home

Lex Tang lexrus

🏠
Working from home
View GitHub Profile
@stephenwilley
stephenwilley / async_process.py
Created November 16, 2011 16:24 — forked from pplante/tornado-async-process-mixin.py
Module type version of original with gen example
# Adapted from here: https://gist.github.com/489093
# Original credit goes to pplante and copyright notice pasted below
# Copyright (c) 2010, Philip Plante of EndlessPaths.com
#
# 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
@hiroshi
hiroshi / Makefile
Created December 1, 2011 04:59
Makefile for Testflight upload
# Testflight web interface doesn't allow input non-ASCII characters (e.g. Japanese) with Safari!
BROWSER = Google Chrome
TESTFLIGHT_TEAM_TOKEN_FILE = ./.testflight_team_token
TESTFLIGHT_TEAM_TOKEN_URL = https://testflightapp.com/dashboard/team/edit/?next=/api/doc/
TESTFLIGHT_TEAM_TOKEN = $(shell cat $(TESTFLIGHT_TEAM_TOKEN_FILE))
TESTFLIGHT_API_TOKEN_FILE = ~/.testflight_api_token
TESTFLIGHT_API_TOKEN_URL = https://testflightapp.com/account/\#api-token
TESTFLIGHT_API_TOKEN = $(shell cat $(TESTFLIGHT_API_TOKEN_FILE))
TESTFLIGHT_NOTES = 'This build was uploaded via the upload API'
#TESTFLIGHT_OTHER_OPTIONS = -F replace=True
@lexrus
lexrus / tc
Created March 15, 2012 03:43
Epoch / Unix Timestamp Converter
#!/bin/bash
# sudo chmod +x tc;sudo mv tc /usr/bin
if [[ -z "$1" ]]
then
printf %s "\
Nifty Timestamp Convertor by Lex Tang
tc 2012/12/12
tc 1355283413
"
exit
@burtlo
burtlo / universal-target.rb
Created March 25, 2012 23:31
Xcoder - Creating a Universal Target
require 'xcoder'
project_name = 'TestProject'
universal_framework_name = 'Library'
# All paths specified are the logical paths within the Xcode Project
source_filenames = [ 'TestProject/AppDelegate.m' ]
public_headerfilenames = [ 'TestProject/AppDelegate.h' ]
project_headerfilenames = [ 'TestProject/Supporting Files/TestProject-Prefix.pch' ]
@shawnwall
shawnwall / gist:2215212
Created March 27, 2012 11:41
Unit testing blocks with AFNetworking example
/*
* SenTestingKit does not wait for blocks to finish by default so your test would simply complete
* as successful. You need to use a semaphore and keep the run loop going in order for the test
* to properly run.
*/
- (void)testGetSpots {
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
CLLocation location = [[CLLocation alloc] initWithLatitude:70.0 longitude:50.0];
[Spot spotsWithURLString:@"/spots" near:location parameters:[NSDictionary dictionaryWithObject:@"128" forKey:@"per_page"] block:^(NSArray *records) {
//sample assert
@agassiyzh
agassiyzh / git-version.sh
Created March 30, 2012 10:20
xcode在编译时带上git版本信息
git_version=`git rev-parse --short HEAD`
app_version=`git describe --tags`
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $app_version" $PRODUCT_SETTINGS_PATH
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $git_version" $PRODUCT_SETTINGS_PATH
@dndx
dndx / xiami_decode.py
Created April 29, 2012 14:42
Xiami URL Decoder
import urllib2
def xiami_decode(s):
s = s.strip()
if not s:
return False
result = []
line = int(s[0])
rows = len(s[1:]) / line
extra = len(s[1:]) % line
@andrewgarn
andrewgarn / AGSynthesizeSingleton.h
Created May 4, 2012 08:53
Macro for creating objective-c singleton with custom accessor that supports both arc (GCD) and non arc environments
//
// AGSynthesizeSingleton.h
// Agnomical SDK
//
// Created by Andrew Garn on 22/03/2012.
// Copyright (c) 2012 Andrew Garn. All rights reserved.
//
/**
Singleton interface method macro
@foota
foota / googl.py
Created May 14, 2012 17:27
goo.gl URL shortener
import sys,re
from urllib2 import urlopen as U, Request as R
from json import loads as J
API,URL="https://www.googleapis.com/urlshortener/v1/url",sys.argv[1]
if re.match('http://goo\.gl/.+',URL):print J(U(API+'?shortUrl=%s'%URL).read())['longUrl']
else:print J(U(R(API,'{"longUrl":"%s"}'%URL,{'Content-Type':'application/json'})).read())['id']
@contaconta
contaconta / server.py
Created May 31, 2012 08:15
TornadoAuthServer
# -*- coding: utf-8 -*-
'''
User: ogata
Date: 5/31/12
Time: 2:10 PM
'''
__author__ = 'ogata'
import tornado.ioloop