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 / gist:4232713
Created December 7, 2012 11:32 — forked from fearphage/gist:1902781
Revert Backbone 0.9.1 from optimistic to realistic (read: classic) functionality
(function(CollectionPrototype, ModelPrototype, slice) {
var monkeyPatch = function(prototype, name) {
var method = prototype[name];
prototype[name] = function() {
var
args = slice.call(arguments)
,length = args.length
,options = length && length >= method.length && args[args.length - 1]
;
@lgsunnyvale
lgsunnyvale / gist:4232063
Created December 7, 2012 09:22 — forked from mattheworiordan/gist:1037984
Backbone patch to defer update method requests when new create requests are not complete on a model
(function() {
Backbone.Model.prototype._save = Backbone.Model.prototype.save;
Backbone.Model.prototype.save = function(attrs, options) {
var that = this;
if (!options) { options = {}; }
if (this.savingNewRecord) {
// store or replace last PUT request with the latest version, we can safely replace old PUT requests with new ones
// but if there are callbacks from a previous PUT request, we need to make sure they are all called as well
_(['success','error']).each(function(event) {
// convert all callbacks to a single array of callbacks)
@lgsunnyvale
lgsunnyvale / gist:4229489
Created December 6, 2012 23:48 — forked from bruth/gist:2865951
Backbone Sync Queue
# Override `Backbone.ajax` to queue all requests.
# Cache Backbone ajax function, by default, just $.ajax
_ajax = Backbone.ajax
# Override Backbone.ajax to queue all requests to prevent
# lost updates.
Backbone.ajax = (options) ->
@ajax.queue options
@lgsunnyvale
lgsunnyvale / Default (Linux).sublime-keymap
Created November 27, 2012 03:56 — forked from coldnebo/Default (Linux).sublime-keymap
simple scripts to prettify your xml and json in sublime text 2
[
{ "keys": ["ctrl+shift+x"], "command": "tidy_xml" },
{ "keys": ["ctrl+shift+j"], "command": "prettify_json" }
]
@lgsunnyvale
lgsunnyvale / jquery.ba-tinypubsub.js
Created November 23, 2012 06:56 — forked from cowboy/HEY-YOU.md
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011
* http://benalman.com/
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function($) {
var o = $({});
$.subscribe = function() {
o.on.apply(o, arguments);
@lgsunnyvale
lgsunnyvale / feedback.md
Created November 20, 2012 22:15 — forked from zhuzhuaicoding/feedback.md
Feedback to "Async Javascript"

HI Trevor Burnham:

I'm a reader of your Async JavaScript book, I bought it on 23rd March and finished it on 26rd March, it is really a treasure to me, probably the best book about async programming in JavaScript I have ever read.

After finished this book, I found there are a few problems, as well as a set of my questions, exists, so I wrote this mail to you, expecting you could give a brief look.

Since I'm not a native English speaker, my English is really poor, so if there is any ambiguousness, please feedback to me so I could have a change to state it more clearly.

Fist of all, I would like to list 9 problems I found in this book, most of which are produced by the difference between our perspectives, so feel free is you don't think they are problems.