Skip to content

Instantly share code, notes, and snippets.

View btc's full-sized avatar
🍃

brian tiger chow btc

🍃
View GitHub Profile
@btc
btc / gist:1171361
Created August 25, 2011 18:21
this code works
// GDAL_WARPTEST.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include "gdal_priv.h"
#include <iostream>
using namespace std;
//#include "cpl_conv.h" // for CPLMalloc()
//#include <stdio.h>
int _tmain(int argc, _TCHAR* argv[])
{
@btc
btc / gist:1181415
Created August 30, 2011 17:22
Working code!
vector<string> argArraytest;
argArraytest.push_back("");
argArraytest.push_back("-of");
argArraytest.push_back("GTiff");
argArraytest.push_back("C:\\Users\\Will\\Desktop\\Lena.bmp");
argArraytest.push_back("C:\\Users\\Will\\Desktop\\Lena_IS_NOW_A_GTIFF_BITCH.tif");
vector<char*> argumentPointers( argArraytest.size() );
for ( size_t i = 0; i < argArraytest.size(); i++)
@btc
btc / hack.sh
Created March 31, 2012 10:45 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@btc
btc / mkfrags.py
Created April 9, 2012 21:04
Creates file of test fragments for cs107/assn1
import string
import random
def mkfrag(N):
body = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(N))
return "#" + body + "#"
if __name__ == '__main__':
nfrags = input('how many frags? ')
fraglength = input('frag length: ')
@btc
btc / cs142p2unitTest.rb
Created April 16, 2012 18:01
cs142 project 2 unit test
require "./squared.rb"
require "./sort.rb"
require "./filter.rb"
require "./group.rb"
require "./adder.rb"
require "test/unit"
class TestSquared < Test::Unit::TestCase
def test_squared
for i in (0..10) do
namespace.views.MyWizard = Backbone.Views.extend({
initialize: function() {
_.bindAll(this, 'render', 'wizardMethod');
}
render: function() {
this.wizardMethod();
return this;
},
@btc
btc / gist:3288410
Created August 7, 2012 19:01
subdomain/locale controller, view issue
=begin
I've run into an architectural challenge. I'm hoping some second opinions will help me organize this logic.
My sites naked and www domains serve as entrypoints to numerous subdomains through which users interact with the site.
=end
models/region.rb
class Region < ActiveRecord::Base
...
end
@btc
btc / locale.rb
Created August 7, 2012 21:16
not overriding new properly
class Locale
# must provide session and request options
def self.new(options = {})
initialize_region(options) || NullLocale.new
end
# return the region object associated with this Locale
def region_name
@region.name
@btc
btc / cp.py
Created September 18, 2012 08:41
copy files with rules
import difflib
import datetime
import os
import shutil
# where log is written
logFilename = 'log.txt'
# where torrents are located
torrentSource = 'C:\Users\Tchow\Downloads'
# where torrents need to go
require 'fiber'
# Call create to get a new fiber
class ReaderProcessor
def self.create(notifier)
Fiber.new do
while notifier.no_data_yet do
puts "Reader has no data yet"
Fiber.yield
end