Skip to content

Instantly share code, notes, and snippets.

View lancevo's full-sized avatar

Lance Vo lancevo

View GitHub Profile
@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 / ubuntu_nginx_nvm.md
Last active January 15, 2019 22:03
ubuntu nginx nvm
@lancevo
lancevo / init.vim
Created September 12, 2018 13:55 — forked from celso/init.vim
Neovim setup for OSX users
syntax on
set ruler " Show the line and column numbers of the cursor.
set formatoptions+=o " Continue comment marker in new lines.
set textwidth=0 " Hard-wrap long lines as you type them.
set modeline " Enable modeline.
set esckeys " Cursor keys in insert mode.
set linespace=0 " Set line-spacing to minimum.
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
" More natural splits
set splitbelow " Horizontal split below current.
@lancevo
lancevo / auth.service.ts
Created October 31, 2018 15:19 — forked from codediodeio/auth.service.ts
Angular4 Firebase authentication service using OAuth, Anonymous, and Email/Password. Designed specifically for changes introduced in AngularFire2 4.0.0
import { Injectable } from '@angular/core';
import { AngularFireDatabaseModule, AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
import { AngularFireAuth } from 'angularfire2/auth';
import { Router } from "@angular/router";
import * as firebase from 'firebase';
@Injectable()
export class AuthService {
@lancevo
lancevo / common-regex-patterns.js
Last active November 1, 2018 13:23
Some of the common regex patterns
// Separate numbers to a group of 3 and add a comma
'123456'.replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"); // output: 123,456
@lancevo
lancevo / atob.js
Created December 14, 2018 03:29 — forked from jmshal/atob.js
Node.js ponyfill for atob and btoa encoding functions
module.exports = function atob(a) {
return new Buffer(a, 'base64').toString('binary');
};
@lancevo
lancevo / nginxproxy.md
Created January 15, 2019 20:44 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@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;
@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 = [