Skip to content

Instantly share code, notes, and snippets.

View lancevo's full-sized avatar

Lance Vo lancevo

View GitHub Profile
@lancevo
lancevo / blurstack.js
Created August 15, 2013 23:04
Blur Canvas
/*
StackBlur - a fast almost Gaussian Blur For Canvas
Version: 0.5
Author: Mario Klingemann
Contact: [email protected]
Website: http://www.quasimondo.com/StackBlurForCanvas
Twitter: @quasimondo
/**
* jQuery.support.cssProperty
* To verify that a CSS property is supported (or any of its browser-specific implementations)
*
* @param string p - css property name
* [@param] bool rp - optional, if set to true, the css property name will be returned, instead of a boolean support indicator
*
* @Author: Axel Jack Fuchs (Cologne, Germany)
* @Date: 08-29-2010 18:43
*
@lancevo
lancevo / index.html
Created July 31, 2013 14:43
A CodePen by Chris Coyier. Slider like Yahoo Weather App
<div class="slider-wrap">
<div class="slider" id="slider">
<div class="holder">
<div class="slide" id="slide-0"><span class="temp">74°</span></div>
<div class="slide" id="slide-1"><span class="temp">64°</span></div>
<div class="slide" id="slide-2"><span class="temp">82°</span></div>
</div>
</div>
<nav class="slider-nav">
<a href="#slide-0" class="active">Slide 0</a>
@lancevo
lancevo / numberize.js
Created July 16, 2013 16:10
numberize() convert numbers in string format to float
// Convert number from string type to number type
// It's a shallow convertion only 1 level deep
// param {object|array|string|number} o variable to be converted
// return {object|array|string|number} converted variable
function numberize(o) {
if (typeof o === "string" || typeof o === "number") {
if (!isNaN(o)) {
o = parseFloat(o);
}
} else if (Object.prototype.toString.call(o) === '[object Array]') {
@lancevo
lancevo / FV.js
Created July 16, 2013 16:06
Calculate FV Same formula as Excel FV()
/*
Calculate FV.
Exact same Excel FV function
Rate is the interest rate per period.
Nper is the total number of payment periods in an annuity.
Pmt is the payment made each period; it cannot change over the life of the annuity. Pmt must be entered as a negative number.
Pv is the present value, or the lump-sum amount that a series of future payments is worth right now. If pv is omitted, it is assumed to be 0 (zero). PV must be entered as a negative number.
Type is the number 0 or 1 and indicates when payments are due. If type is omitted, it is assumed to be 0 which represents at the end of the period. If payments are due at the beginning of the period, type should be 1.
*/
@lancevo
lancevo / expand-transition.html
Last active December 19, 2015 15:49
Expand and collapse content with css transition
<h3>expand content with css3</h3>
<div class="content">
<ol>
<li>Morbi in sem quis dui placerat ornare. Pellentesque odio nisi, euismod in, pharetra a, ultricies in, diam. Sed arcu. Cras consequat.</li>
<li>Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus.</li>
<li>Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer ligula vulputate sem tristique cursus. Nam nulla quam, gravida non, commodo a, sodales sit amet, nisi.</li>
<li>Pellentesque fermentum dolor. Aliquam quam lectus, facilisis auctor, ultrices ut, elementum vulputate, nunc.</li>
<li>Morbi in sem quis dui placerat ornare. Pellentesque odio nisi, euismod in, pharetra a, ultricies in, diam. Sed arcu. Cras consequat.</li>
<li>Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliqua
@lancevo
lancevo / requestAnimationFrame.js
Created July 11, 2013 20:39
requestAnimationFrame and cancel polyfill
// Source: http://eightmedia.github.io/hammer.js/examples/carousel.html
/**
* requestAnimationFrame and cancel polyfill
*/
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
window.cancelAnimationFrame =
@lancevo
lancevo / redirect port.sh
Created July 11, 2013 19:44
iptables: redirect port shell script on *nix. Ex: redirect port 80 to 3000
sudo iptables -t nat -A PREROUTING -p tcp -port 80 -j REDIRECT --to-ports 3000
@lancevo
lancevo / object-property.js
Last active December 19, 2015 13:59
Custom object property
var obj = {
x : 5,
y : 10
};
// defineProperty doesn't work on IE < 9, IE8 only when it's a DOM element
Object.defineProperty(obj, 'sum', {
get: function(){
return this.x + this.y
}
@lancevo
lancevo / autoHeight.angular.directive.js
Last active December 17, 2015 08:18
it calculates the header, footer, and offset parameter to return a desirable height for responsive design
/*
author: Lance Vo
License: MIT
autoHeight directive
--------------------
it calculates the remaining height (px) after substracting header/footer/offset.
Useful for responsive design content.
examples: