Skip to content

Instantly share code, notes, and snippets.

View trevorwang's full-sized avatar
:octocat:
Focusing

Trevor Wang trevorwang

:octocat:
Focusing
View GitHub Profile
@trevorwang
trevorwang / README.md
Created August 24, 2017 15:13 — forked from rsmoorthy/README.md
sails-hook-extmodel: Sails.js hook for extending Models

fw Extended Models

This hook extends the models, its definition and its behaviour.

For now, various features will get added in this hook. And we will migrate them to proper ones, as we go by.

Extended enum support

This feature extends the values of enum from other sources. Other sources could be:

@trevorwang
trevorwang / parse_ipa.py
Created August 10, 2017 07:02 — forked from noamtm/parse_ipa.py
Python: Parse Info.plist from IPA on OSX
#!/usr/bin/env python
from Foundation import NSData, NSPropertyListSerialization
import fnmatch
import sys
from zipfile import ZipFile
# TODO: Add error checking.
def parse_plist(info_plist_string):
@trevorwang
trevorwang / README.md
Created July 13, 2017 02:52 — forked from polbins/README.md
Android Response Caching using Retrofit 1.9 + OkHttp 2.2

Android REST Controller with Cache-Control

Android REST Controller with Simple Cache Control Headers using Retrofit 1.9.0 + OkHttp 2.2.0

@trevorwang
trevorwang / pngquant_all
Created December 6, 2016 08:14 — forked from rvillas/pngquant_all
pngquant an entire folder
find . -name '*.png' -exec pngquant --ext .png --force {} \;
@trevorwang
trevorwang / addContact.swift
Created October 18, 2016 01:13 — forked from samuelbeek/addContact.swift
Add contact to address book in swift
func addUserToAddressBook(contact: User){
let stat = ABAddressBookGetAuthorizationStatus()
switch stat {
case .Denied, .Restricted:
println("no access to addressbook")
case .Authorized, .NotDetermined:
var err : Unmanaged<CFError>? = nil
var adbk : ABAddressBook? = ABAddressBookCreateWithOptions(nil, &err).takeRetainedValue()
if adbk == nil {
println(err)
@trevorwang
trevorwang / NSDateFormatter cheat sheet
Created January 26, 2016 08:58 — forked from romaonthego/NSDateFormatter cheat sheet
Date Formats for NSDateFormatter
a: AM/PM
A: 0~86399999 (Millisecond of Day)
c/cc: 1~7 (Day of Week)
ccc: Sun/Mon/Tue/Wed/Thu/Fri/Sat
cccc: Sunday/Monday/Tuesday/Wednesday/Thursday/Friday/Saturday
d: 1~31 (0 padded Day of Month)
D: 1~366 (0 padded Day of Year)
/*
* Copyright (C) 2014 skyfish.jy@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
#!/bin/bash
HOST=$(hostname)
function install_postfix() {
echo | sudo debconf-set-selections <<__EOF
postfix postfix/root_address string
postfix postfix/rfc1035_violation boolean false
postfix postfix/mydomain_warning boolean
postfix postfix/mynetworks string 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
# from http://stackoverflow.com/questions/6499654/is-there-an-asynchronous-logging-library-for-ruby/6527134#6527134
require 'thread'
require 'singleton'
require 'delegate'
require 'monitor'
class Async
include Singleton
require 'mongoid'
Mongoid::Config.instance.from_hash({"database" => "oid"})
class Tweeter
include Mongoid::Document
field :user
embeds_many :tweets
end