Skip to content

Instantly share code, notes, and snippets.

View dashawk's full-sized avatar

Jason Panugaling dashawk

  • Cebu City, Philippines
View GitHub Profile
@dashawk
dashawk / Laravel PHP7 LEMP AWS.md
Created January 26, 2018 04:15 — forked from santoshachari/Laravel PHP7 LEMP AWS.md
Laravel 5.x on Ubuntu 16.x, PHP 7.x, Nginx 1.9.x

#Steps to install latest Laravel, LEMP on AWS Ubuntu 16.4 version. This tutorial is the improvised verision of this tutorial on Digitalocean based on my experience.

Install PHP 7 on Ubuntu

Run the following commands in sequence.

sudo apt-get install -y language-pack-en-base
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install zip unzip
@dashawk
dashawk / gist:2b508f35f9820df0f6e312bcff8cb521
Created December 14, 2017 00:49 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
//region Get the Margin
var cost = 5;
var sell = 10;
var margin = 0;
// Original Formula
margin = ((sell - cost) / sell) * 100;
console.log('[Original]Margin', margin);
// Shorthand Formula
@dashawk
dashawk / guid-generator.js
Created October 18, 2017 01:11
Generate a GUID String
/**
* Generates a GUID string.
* @returns {String} The generated GUID.
* @example af8a8416-6e18-a307-bd9c-f2c947bbb3aa
* @author Slavik Meltser (slavik@meltser.info).
* @link http://slavik.meltser.info/?p=142
*/
function guid() {
function _p8(s) {
var p = (Math.random().toString(16)+"000000000").substr(2,8);
@dashawk
dashawk / sample-nginx.conf
Created August 7, 2017 07:28 — forked from cjus/sample-nginx.conf
AngularJS Nginx and html5Mode
server {
server_name yoursite.com;
root /usr/share/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}
@dashawk
dashawk / math.js
Created July 26, 2017 08:38
Fun with Math
function round(number, decimalPlaces) {
return +(Math.round(number + 'e+' + decimalPlaces) + 'e-' + decimalPlaces);
}
@dashawk
dashawk / dates.js
Last active July 26, 2017 07:01
Manipulate Dates in Javascript
/**
* Returns the hour difference between two dates
*/
function getHours(startDate, endDate) {
return Math.floor(Math.abs(startDate - endDate) / 3.6e6);
}
/**
* Returns the current hour in 12-hours format
*/
@dashawk
dashawk / node-deploy-as-upstart-service.md
Created July 3, 2017 11:53 — forked from learncodeacademy/node-deploy-as-upstart-service.md
Deploy Node.js app on Ubuntu as Upstart Service - instead of using Forever

Deploying a node app with Forever is great...until your server restarts unexpectedly. Then your app stops running and you have to re-deploy.

To get around this, we're going to run our node app as an Upstart service. Upstart services are great, because, once started, the system auto-restarts them if they fail, or if the server restarts.

###Step 1: Create a service for your node app

  • ssh in as root ssh root@youripaddress
  • Create a node-app.conf file in /etc/init
    IMPORTANT: whatever filename you pick is what you will use to start|stop|restart your service i.e. service node-app start
@dashawk
dashawk / .bashrc
Created June 29, 2017 02:12
My Windows .bashrc
#!/bin/bash
# Make .bashrc available to non interactive shells (.sh scripts)
export BASH_ENV=~/.bashrc
env=~/.ssh/agent.env
loadEnv () {
test -f "$env" && . "$env" >| /dev/null ;
}
@dashawk
dashawk / walksync.js
Created June 23, 2017 16:47 — forked from kethinov/walksync.js
List all files in a directory in Node.js recursively in a synchronous fashion
// List all files in a directory in Node.js recursively in a synchronous fashion
var walkSync = function(dir, filelist) {
var fs = fs || require('fs'),
files = fs.readdirSync(dir);
filelist = filelist || [];
files.forEach(function(file) {
if (fs.statSync(dir + file).isDirectory()) {
filelist = walkSync(dir + file + '/', filelist);
}
else {