Skip to content

Instantly share code, notes, and snippets.

@johnlinvc
johnlinvc / arrayPassByValue.playground
Last active May 7, 2018 03:19
Demo how to pass array by reference in swift
//: Playground - noun: a place where people can play
import UIKit
class Foo {
class ArrayWrapper{
var array:[Bool] = [false]
subscript(index: Int) ->Bool {
get{
return array[index]
# Git pre-commit hook to check all staged Ruby (*.rb/haml/coffee) files
# for Pry binding references
#
# Installation
#
# ln -s /path/to/pre-commit.sh /path/to/project/.git/hooks/pre-commit
#
# Based on
#
# http://codeinthehole.com/writing/tips-for-using-a-git-pre-commit-hook/
@johnlinvc
johnlinvc / gist:6077375
Last active December 20, 2015 05:19 — forked from jtescher/gist:1487555
capistrano task for optimize images after asset:precompile using optipng and jpegoptim
namespace :image_compression do
desc 'Optimize images with optipng and jpegoptim'
task :process do
# Check for optipng
if (!`which optipng`.empty? rescue false) # rescue on environments without `which` (windows)
# Crush all .png files inplace
run "find #{shared_path}/assets/ -type f -name '*.png' -print0 | xargs -0 optipng -quiet -o7 "
else
private class Rect{
public int x,y,width,height;
public Rect(int _x,int _y,int _width,int _height){
x=_x;y=_y;width=_width;height=_height;
}
}
private LinkedList<Rect> queue;
private boolean isMoving;
private boolean isInc;
public void setup(){
typedef struct {
int x,
int y,
int width,
int height
} rect;
static int count = 1;
void spiltAndMerge(rect rec){
if(count >= 272) return ;
@johnlinvc
johnlinvc / simian_ant.xml
Created February 8, 2012 08:06
Ant of simian for obj-c
<project>
<taskdef resource="simiantask.properties" classpath="simian.jar"/>
<target name="simian_obj_c">
<simian>
<fileset dir="./" includes="**/*.m"/>
<fileset dir="./" includes="**/*.h"/>
<formatter type="xml" toFile="simian.xml"/>
</simian>
</target>
</project>