Skip to content

Instantly share code, notes, and snippets.

View hongymagic's full-sized avatar
🤪

David Hong hongymagic

🤪
View GitHub Profile
@hongymagic
hongymagic / TwoFace.js
Created April 17, 2012 04:52
TwoFace – Canvas based Image before/after comparison
function TwoFace(id, width, height) {
if (!(this instanceof TwoFace)) {
return new TwoFace(id, width, height);
}
var canvas = document.createElement('canvas'),
container = document.getElementById(id),
divide = 50;
this.ctx = canvas.getContext('2d');
@hongymagic
hongymagic / prefix.js
Created May 4, 2012 13:05
Determine the prefix of the browser: o, moz, webkit, ms
/*jslint devel: false, browser: true, sloppy: true, maxerr: 50, indent: 4 */
//
// `PREFIX` variable will most likely be one of the following:
// [o, moz, ms, webkit]
//
var PREFIX = (function (window, document) {
// Get computed styles from the document to assess names of the CSS properties
@hongymagic
hongymagic / tempted.js
Created May 14, 2012 04:31
Simple client-side only, data-less templating. Dependency on jQuery
// Very simple client-side only, data-less, templating system.
//
// Usage:
// <div data-view="footer" data-type="partial"></div>
// <div data-view="article" data-type="view"></div>
var tempted = function (context) {
if (!context) {
context = window.document;
}
@hongymagic
hongymagic / mask.js
Created June 3, 2012 06:22 — forked from bjouhier/hackGlobal.js
Masking eval, extracting FunctionBody – not really sure where it would be used.
// Extract FunctionBody as eval expects FunctionBody
Function.prototype.getBody = function() {
var m = this.toString().match(/\{([\s\S]*)\}/m)[1];
return m.replace(/^\s*\/\/.*$/mg,'');
};
var GLOBAL = "GLOBAL";
function foo () {
div, ul, li, a, span {
margin:0;
padding:0;
}
body { font:16px/16px Arial, Helvetica, Sans-serif; }
a {
color:#222;
text-decoration:none;
}
.sidebar {
@hongymagic
hongymagic / Backbone.PagedCollection.js
Created July 5, 2012 02:54
Backbone PagedCollection – HTTP Link aware Backbone Collection
//
// Backbone.PagedCollection
//
// A smarter way to consume list resources over HTTP. Call it Hypermedia, REST,
// whatever. There are other problems that we may wish to solve with the
// current implementation of PagedCollection:
//
// 1. Jumping between specific pages;
// 2. Web Linking works, however `per_page` paramter must be implemented;
// 3. Call to `fetch` is required to retreive Link field, which means bootstrapping is a problem; and
@hongymagic
hongymagic / Issue-159.md
Created July 20, 2012 05:29
EpicEditor TAB implementation

“Smart tabs” sound better, a quick look at configuration files for both vim and sublime text:

Vim 
---
noexpandtab
tabstop
smartindent
smarttab
@hongymagic
hongymagic / yeoman.sh
Created July 27, 2012 07:34
Check if yeoman is available for download
#!/bin/bash
while true; do
if curl --silent -IL get.yeoman.io | grep -i '200'; then
echo "yeoman looks to be available: visit http://yeoman.io"
echo "or simply try running the command:"
echo "$ curl -L get.yeoman.io | sh"
say "yeoman!"
fi
sleep 120
@hongymagic
hongymagic / .gitignore
Created August 2, 2012 05:11
HTMLPreElement extensions
# Other VCS
.svn/
.CVS/
.hg/
# Ignore these asset directories
psd/
# Node.js modules, use `npm install`
node_modules/
@hongymagic
hongymagic / README.md
Created August 13, 2012 03:48
Coding tunes