Skip to content

Instantly share code, notes, and snippets.

View lancevo's full-sized avatar

Lance Vo lancevo

View GitHub Profile
@lancevo
lancevo / jplaceholder.html
Created November 16, 2011 22:15
jplaceholder demo
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script src="https://raw.github.com/lvo811/jplaceholder/master/jplaceholder.js"></script>
<h2>Example 1</h2>
<p>
Placeholder text is hidden when input field is focusing
</p>
<form id="form1">
<label>
<input name="user" jplaceholder="User ID" />
<h1>Alert</h1>
<p>Bootstrap JS</p>
<div class="alert fade in">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>Holy guacamole!</strong> Best check yo self, you're not looking too good.
</div>
<p></p><a ng-click="alert=true">Open Alert (AngularJS)</a></p>
<div class="alert fade" ng-class="{in:alert}">
<button type="button" class="close" ng-click="alert=false">×</button>
@lancevo
lancevo / mac rvm
Created May 4, 2013 01:51
new mac setup: rvm, ruby, rails,
# install ruby and rails
\curl -L https://get.rvm.io | bash -s stable --autolibs=3 --rails
/*
* AVIM JavaScript Vietnamese Input Method Source File dated 28-07-2008
*
* Copyright (C) 2004-2008 Hieu Tran Dang <lt2hieu2004 (at) users (dot) sf (dot) net
* Website: http://noname00.com/hieu
*
* You are allowed to use this software in any way you want providing:
* 1. You must retain this copyright notice at all time
* 2. You must not claim that you or any other third party is the author
* of this software in any way.
#AVIMControl {
background-image: url('transparent.png');
padding: 2px;
border: 1px solid #5b958e;
position: absolute;
top: 5px;
left: 5px;
width: 320px;
}
@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:
@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 / 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 / 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 / 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