Skip to content

Instantly share code, notes, and snippets.

View lgsunnyvale's full-sized avatar

Josh Guo lgsunnyvale

  • Bay Area, California
View GitHub Profile
<snippet>
<content><![CDATA[
#ifndef ${TM_FILEPATH/(([A-Za-z]+)\/src\/)|./\U(?1:$2_)\E/g}${TM_FILENAME/(([A-Z])([A-Z][a-z]))|(([a-z])([A-Z]))|([a-z])|(\.)/\U(?1:$2_$3)(?4:$5_$6)$7(?8:_)\E/g}
#define ${TM_FILEPATH/(([A-Za-z]+)\/src\/)|./\U(?1:$2_)\E/g}${TM_FILENAME/(([A-Z])([A-Z][a-z]))|(([a-z])([A-Z]))|([a-z])|(\.)/\U(?1:$2_$3)(?4:$5_$6)$7(?8:_)\E/g}
$0
#endif
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
@lgsunnyvale
lgsunnyvale / SQL_Quiz
Last active August 29, 2015 14:07 — forked from ylyhlh/SQL_Quiz
These quizs are very interesting and helpful. It's for query and data manipulation. Two small databases used to demonstrate basic query syntax, various subquery syntax and some DML.
POPULATION_SIZE = 24
NUM_BITS = 64
NUM_GENERATIONS = 1000
CROSSOVER_RATE = 0.7
MUTATION_RATE = 0.001
class Chromosome
attr_accessor :genes
/*
highlight v3 !! Modified by Jon Raasch (http://jonraasch.com) to fix IE6 bug !!
Highlights arbitrary terms.
<http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html>
MIT license.
@lgsunnyvale
lgsunnyvale / router.js
Created May 1, 2013 00:55
backbone view and collection wire up
var TestView = Backbone.View.extend({
initialize: function() {
console.log(this.collection)
this.collection.bind("reset", this.render);
this.collection.fetch({reset: true});
},
render: function() {
@lgsunnyvale
lgsunnyvale / members.csv
Created February 19, 2013 09:44
members.csv
Name Email Points
Ahsan, Sanjida sahsan@unm.edu 805
Al-Jarry, Zaidoon zaljarry@unm.edu 334
Anderson, Jeffrey jander22@unm.edu 681
Barlas, Ghazanfar gbarlas@unm.edu 959
Barraza, Pamela pbarraza@salud.unm.edu 812
Beers, Kay kaybeers@unm.edu 80
Bodmer, Miles bassnps@unm.edu 698
Buddenborg, Sarah sbuddenb@unm.edu 473
Cornelius, Grace gcor@unm.edu 603
@lgsunnyvale
lgsunnyvale / migrate.rb
Created February 19, 2013 09:35
migrate customer database
require 'CSV'
require 'curb'
def migrate(uuid)
index = 0
CSV.foreach("members.csv") do |row|
if index==0
continue
end
Curl.get "http://loyalty.500friends.com/api/record.gif?uuid=#{uuid}&email=#{row[1]}&
value=#{row[2]}"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Rewards - Shoebuy.com - Free Shipping & Return Shipping</title>
<meta name="keywords" content="">
<meta name="description" content="">
<script type="text/javascript" src="http://i.shoebuy.com/jscript/facebook.js"></script>
<meta property='fb:app_id' content='146327295405912'/>
<meta property='og:title' content='Rewards'/>
@lgsunnyvale
lgsunnyvale / mockjax.js
Created January 18, 2013 08:51
mockjax
$.mockjax({
url: "/restful/fortune",
responseTime: 750,
contentType: "text/json",
responseText: [{
a:'a'
},{
a:'b'
},{
a:'c'
@lgsunnyvale
lgsunnyvale / gist:4411632
Created December 30, 2012 08:33
from array to nested
$(function() {
var placeArray = function(array, target) {
array.forEach(function(item) {
target = placeObj(item, target);
});
return target;
};
var placeObj = function(obj, target) {