Skip to content

Instantly share code, notes, and snippets.

@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>
typedef struct {
int x,
int y,
int width,
int height
} rect;
static int count = 1;
void spiltAndMerge(rect rec){
if(count >= 272) return ;
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(){
@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
# 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 / 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]
@johnlinvc
johnlinvc / buildlog.sh
Created December 30, 2015 16:36
swift-stdlib-macosx-x86_64 build fail log
Building the standard library for: swift-stdlib-macosx-x86_64
cmark: using standard linker
++ cmake_config_opt cmark
++ product=cmark
++ [[ Ninja == \X\c\o\d\e ]]
+ /usr/local/bin/cmake --build /Users/johnlinvc/Projs/swift-core-2/build/Ninja-DebugAssert/cmark-macosx-x86_64 -- -j8 all
ninja: no work to do.
llvm: using standard linker
++ cmake_config_opt llvm
@johnlinvc
johnlinvc / echo_server.rb
Created January 1, 2016 10:40
ruby rack echo server
require 'rack'
app = Proc.new do |env|
['200', {'Content-Type' => 'text/html'},
["hello #{env['rack.input'].read}"]]
end
Rack::Handler::WEBrick.run app
/*
Web Server
A simple web server that shows the value of the analog input pins.
using an Arduino Wiznet Ethernet shield.
Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
* Analog inputs attached to pins A0 through A5 (optional)