Skip to content

Instantly share code, notes, and snippets.

View tshi0912's full-sized avatar

Tao Shi tshi0912

View GitHub Profile
@jakub-g
jakub-g / _1_"script async defer" blocks "load" event.md
Last active August 22, 2023 10:10
Beware of "script async defer" blocking HTML "load" event

Beware of <script async defer> blocking HTML "load" event

2015.10.07 t

On the importance of simulated latency testing, and bulletproofing your page from the third-party JS load failures

TL;DR

@akhoury
akhoury / handlebars-helper-x.js
Last active September 9, 2025 22:14
Handlebars random JavaScript expression execution, with an IF helper with whatever logical operands and whatever arguments, and few more goodies.
// for detailed comments and demo, see my SO answer here http://stackoverflow.com/questions/8853396/logical-operator-in-a-handlebars-js-if-conditional/21915381#21915381
/* a helper to execute an IF statement with any expression
USAGE:
-- Yes you NEED to properly escape the string literals, or just alternate single and double quotes
-- to access any global function or property you should use window.functionName() instead of just functionName()
-- this example assumes you passed this context to your handlebars template( {name: 'Sam', age: '20' } ), notice age is a string, just for so I can demo parseInt later
<p>
{{#xif " name == 'Sam' && age === '12' " }}
BOOM
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active October 26, 2025 08:45
A badass list of frontend development resources I collected over time.
@elijahmanor
elijahmanor / channels.js
Last active December 15, 2015 15:39
Angry Birds of JavaScript: Black Bird - Backbone.js
define( [ "postal" ], function( postal ) {
return {
bus: postal.channel({ channel: "main" })
};
});
@orip
orip / GsonHelper.java
Created September 5, 2012 11:22
Gson type adapter to serialize and deserialize byte arrays in base64
import java.lang.reflect.Type;
import android.util.Base64;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;

Routing in Ember

In Ember, the application's state manager handles routing. Let's take a look at a simple example:

App.stateManager = Ember.StateManager.create({
  start: Ember.State.extend({
    index: Ember.State.extend({
      route: "/",
@jstarrdewar
jstarrdewar / jsd.draggableIsotopeAtom.js
Created October 28, 2011 06:44
Extension of jQueryUI Draggable that works with Isotope
/**
* The purpose of this jQuery UI plugin is to account for the bug in Firefox that doesn't correctly report the positions
* of elements that are positioned with CSS transforms. Luckily, isotope keeps track of what the position should be, so
* we can calculate the correct offset.
*
* @author: John Starr Dewar
*/
(function($) {
// Arguments to .extend are returned object, merge object 1, merge object 2
$.widget('jsd.draggableIsotopeAtom', $.ui.draggable, {
@criminy
criminy / PageI.java
Created October 5, 2011 01:01
Initial MyBatis support for Spring-Data (specifically a sample repository and Pagination).
import java.util.Collection;
import java.util.List;
import java.util.ListIterator;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
/**
* Extension class between spring data commons and java.util.List that is
* required to get MyBatis to use it as a return value.