Skip to content

Instantly share code, notes, and snippets.

View lancevo's full-sized avatar

Lance Vo lancevo

View GitHub Profile
@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 / 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 / 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>
/**
* 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 / 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
@lancevo
lancevo / index.html
Created August 20, 2013 13:11
A CodePen by Lance Vo.
<div id="slides">
<nav class="slide">
<ol>
<li> Item </li>
<li> Item </li>
<li> Item </li>
<li> Item </li>
<li> Item </li>
<li> Item </li>
@lancevo
lancevo / offcanvas.html
Created August 20, 2013 16:29
solved transition flickering when transition to the top of 2nd page. Both panels are positioned absolute, and using translate3d to move the panel. Each panel has its own overflow setting, so it doesn't impact other panel. Padding-bottom is added to the parent panel (#panels), so it'll hide the toolbars (tested on iOS 6, may not work on iOS 7)
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, user-scalable=no initial-scale=1.0">
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<style>
html, body {
height: 100%;
}
@lancevo
lancevo / index.html
Created August 23, 2013 14:04
A Pen by Lance Vo.
<div id="slides" class="">
<div id="slide1" class="slide">
<button class="menu-btn">Close</button>
<ol>
<li> Item </li>
<li> Item </li>
<li> Item </li>
<li> Item </li>
<li> Item </li>
<li> Item </li>
@lancevo
lancevo / splitStringToArray.js
Created October 10, 2013 15:03
clean up spaces and split into array
str.trim(str).replace(/\s{2,}/g,' ').split(' ')
//+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com/classes/bignumber [rev. #4]
BigNumber = function(n, p, r){
var o = this, i;
if(n instanceof BigNumber){
for(i in {precision: 0, roundType: 0, _s: 0, _f: 0}) o[i] = n[i];
o._d = n._d.slice();
return;
}