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 / install_pms.sh
Created April 4, 2017 02:57
Install Plex on Ubuntu
echo deb https://downloads.plex.tv/repo/deb/ public main | sudo tee /etc/apt/sources.list.d/plexmediaserver.list
curl https://downloads.plex.tv/plex-keys/PlexSign.key | sudo apt-key add -
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install plexmediaserver
@lancevo
lancevo / child.component.ts
Created August 17, 2017 19:45
Mock Child Component
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'app-child',
templateUrl: '<ul><li *ngFor="let i of numbers">{{i}}</li></ul>',
styleUrls: ['./child.component.css']
})
export class ChildComponent implements OnInit {
@Input() numbers: number[];
@lancevo
lancevo / letsencrypt.md
Created June 2, 2021 17:09
Set up letsencrypt with nginx and node
@lancevo
lancevo / mysql-docker.sh
Created September 26, 2019 21:45 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@lancevo
lancevo / filterarrayinplace.js
Created August 13, 2019 14:12
Filter array in place
function filterInPlace(array, condition) {
let iOut = 0;
for (let i = 0; i < array.length; i++) {
if (condition(array[i])) {
array[iOut++] = array[i];
}
}
array.length = iOut;
}
@lancevo
lancevo / README.md
Created June 3, 2019 19:23 — forked from egucciar/README.md
Shadow Dom Commands

ShadowDom

Quick Start

In the index.js or the root file of your cypress/support folder,

@lancevo
lancevo / generate_mac.bash
Created May 20, 2019 18:03
change MAC address on Mac
function changeMac() {
local mac=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//')
sudo ifconfig en0 ether $mac
sudo ifconfig en0 down
sudo ifconfig en0 up
echo "Your new physical address is $mac"
}
@lancevo
lancevo / README.md
Created January 24, 2019 05:19
Sort Objects

Objects Sorter:

Sort objects by property name. It detects property type such as number, string, and date and sort them properly.

Usage

var models = [
@lancevo
lancevo / getQuery.js
Created January 21, 2019 15:29
extracts and parses url query string
(function(window){
'use strict';
function getQuery(query){
var args = decodeURIComponent(location.search).substring(1).split('&');
var argsParsed = {};
var i, arg, kvp, key, value;
for (i=0; i < args.length; i++) {
arg = args[i];
if (-1 === arg.indexOf('=')) {
argsParsed[decodeURIComponent(arg).trim()] = true;