Skip to content

Instantly share code, notes, and snippets.

View lancevo's full-sized avatar

Lance Vo lancevo

View GitHub Profile
// social share
$(".social-share").on('click','a', function(e){
var url = $(this).attr('href');
if (!url.match(/^mailto/)) {
e.preventDefault();
window.open(url,"SocialShare","location=no,menu=no,toolbar=no");
}
});
@lancevo
lancevo / demo.html
Last active August 29, 2015 14:09
equalHeight jquery plug-in
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.9.1.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style>
div { width:150px;border:10px solid #ccc;
display:inline-block;
@lancevo
lancevo / Opacity-Animation-for-updating-list.markdown
Last active August 29, 2015 14:15
Opacity Animation for updating list

Opacity Animation for updating list

Smooth transition when updating the list, all hidden items don't display as blank in layout. It animates at the parent level (ul/ol) rather than the individual level (li), to overcome several challenges:

  1. Use height:0 transition will hide the item smoothly, but it presents several issues: a) to show the item, you must provide exact pixel for height, and each item height is different so it's not possible with css alone. b) another way to get around this is when before showing the item, remove the previous hide class, it will reset the height to original, however it jerks the layout, because the height is restored before the transition.
  2. Use display:none in animation doesn't work, so putting in the last keyframe doesn't do anything.
  3. Use scale, transition, position:absolute to remove from the layout, it has the same issue as 1b. Also with position:absolute, when animating before opacity:0, the contents overlap each other,
@lancevo
lancevo / isNearBottom.js
Created March 5, 2015 22:28
check an element to see if it nears the bottom of the view port
function isNearBottom(element, marginPx){
marginPx = marginPx || 100;
var elementOffsetTop = $(element).offset().top,
nearBottomMargin = $(window).scrollTop() + $(window).height() - elementOffsetTop;
return Math.abs(nearBottomMargin) <= marginPx;
}
@lancevo
lancevo / ios-standalone-mode.js
Created March 11, 2015 17:53
check to see if the webpage open from iOS home screen (web app)
var standaloneMode = window.navigator.userAgent.indexOf('iPhone') != -1 && window.navigator.standalone == true;
// get weekday in Chicago CST
console.log( (new Date()).toLocaleDateString('en-US',{ timeZone: 'America/Chicago', weekday: 'long'}) );
// get time in Chicago CST
consoe.log( (new Date()).toLocaleTimeString('en-US',{ timeZone: 'America/Chicago', hour12: true}) )

Before you start

Make sure you have python, OpenFace and dlib installed. You can either install them manually or use a preconfigured docker image that has everying already installed:

docker pull bamos/openface
docker run -p 9000:9000 -p 8000:8000 -t -i bamos/openface /bin/bash
cd /root/openface
@lancevo
lancevo / validate-number-range.validator.ts
Last active August 4, 2016 19:49
A validator to validator range of number
import {AbstractControl, ValidatorFn} from '@angular/forms';
export function validateNumberRange(min: number, max:number): ValidatorFn {
return (control: AbstractControl): { [key:string]: any } => {
var value = parseInt(control.value,10);
return (isNaN(value) || (value < min) || (value > max)) ?
{'numberRange' : {'min': min, 'max':max, 'actualValue': value}} :
null
}
}
@lancevo
lancevo / contribute.md
Last active February 20, 2017 14:03
Contribution Git Rebase Etc

New Issues are for bug reports or feature requests only!! Questions on how to use the grid should be posted to Stack Overflow or Gitter https://gitter.im/angular-ui/ui-grid.

Contributing to UI Grid

Please take a moment to review this document in order to make the contribution process easy and effective for everyone involved.

Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, they should reciprocate that respect in addressing your issue or assessing

@lancevo
lancevo / pms-pi3.md
Created March 4, 2017 14:17
Setup Plex Media Server on Raspberry Pi 3

Requires:

  • at least 8GB class 10 SD card for fast reading/writing
  • large powered external USB hard drive to store media, powered USB hard drive is more reliable, and it doesn't put more work on RPI to provide it power
  • recommend to user Ethernet over wifi to connect RPI

#Setup Raspian There are many OS images available for RPI, but the easiest is NOOBS. Download NOOBS and and follow instruction to set it up on a SD Card