Skip to content

Instantly share code, notes, and snippets.

View ivzhao's full-sized avatar

Ivan Zhao ivzhao

View GitHub Profile
UIImage *createGrayCopy(UIImage *source)
{
int width = source.size.width;
int height = source.size.height;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
CGContextRef context = CGBitmapContextCreate (nil,
width,
height,
@ivzhao
ivzhao / gist:1035933
Created June 20, 2011 16:26
bash script for watching and recompiling node.js, and coffeescripts in multiple directories.
#!/bin/bash
# Usage: "./start.sh -e" to start watching the compass and coffeescripts changes,
# "./start.sh -s" to start node.js and restart server whenever the code changes.
trap 'kill $(jobs -p)' SIGUSR1
function startEnviroment {
echo 'Start Developing Enviroment'
compass watch ./static/style &
@ivzhao
ivzhao / gist:1124673
Created August 4, 2011 07:46
Backbone.Collection bug?
_prepareModel: function(model, options) {
if (!(model instanceof Backbone.Model)) {
var attrs = model;
// Bug? Do we forget to pass in options here?
model = new this.model(attrs, {collection: this});
// Proposed Fix:
//model = new this.model(attrs, _.extend(options, {collection: this}));
@ivzhao
ivzhao / blah.js
Last active January 3, 2020 13:19
Get Intercom tags count from your browser
// Step 1. Turn on this Chrome plugin to disable Content Security Policy https://chrome.google.com/webstore/detail/disable-content-security/ieelmcmcagommplceebfedjlakkhpden?hl=en
// Step 2. Change your Intercom App Id below.
// Step 3. Go to your Intercom Tags page.
// Step 4. Copy/paste this script in your Chrome console, it will download a .csv file once it's completed.
// Step 5 (Optional) Sometimes you have to toggle the ORIGIN below between .io or .com.
// Your Intercom App Id
var INTERCOM_APP_ID = "REPLACE_WITH_YOUR_ID"
// Origin. Change between https://app.intercom.com or https://app.intercom.io