View pm2run
./node_modules/pm2/bin/pm2 delete all; ./node_modules/pm2/bin/pm2 start ./{path to server js} --watch --node-args='--inspect' --no-daemon |
View dr-strange.html
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>JLT - Animated squares on top of a circle</title> | |
<style> | |
body{ | |
padding: 300px; | |
} | |
div{ | |
position: absolute; |
View n-ary-number-system.php
<?php | |
/** | |
* Given a decimal number and a base, convert the number to n-ary base number. Also find a way to perform arithmetic | |
* operations. The n is actually 36, however the principal is same. | |
* | |
* To perform arithmetic operations, we convert the number back to decimal, do the math, then convert back to the | |
* original base. | |
*/ | |
/** |
View handyregexes
find all console.log() | |
console\.log\((.*)\); |
View precommithookforphpandjson
#!/bin/bash | |
PROJECT=`php -r "echo dirname(dirname(dirname(realpath('$0'))));"` | |
STAGED_PHP_FILES=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php` | |
STAGED_JSON_FILES=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.json$` | |
# Determine if a file list is passed | |
if [ "$#" -eq 1 ] | |
then |
View server.js
var http = require('http'), //http server | |
urlparser = require('url'), //url parser & builder | |
host = 'sandbox', | |
port = 1337; | |
http.createServer(function (req, res) { | |
var response = 'Hello, World!\n', | |
url = urlparser.parse(req.url, true).pathname; | |
switch (url) { | |
case('/hello'): //check for path, alternatively strip the front slash | |
response = 'World!\n'; |
View server.js
var http = require('http'), //http server | |
urlparser = require('url'), //url parser & builder | |
host = 'sandbox', | |
port = 1337; | |
http.createServer(function (req, res) { | |
var response = 'Hello, World!\n', | |
url = urlparser.parse(req.url, true).pathname; | |
switch (url) { | |
case('/hello'): //check for path, alternatively strip the front slash | |
response = 'World!\n'; |
View bashrc
command_exists () { | |
type "$1" &> /dev/null ; | |
} | |
# grep always with color and line number | |
alias grep='grep -n --color=always' | |
# git | |
if command_exists git ; then | |
alias gitco='git checkout' |
View niginx.conf
server { | |
listen 80; | |
server_name helloworld; | |
location / { | |
rewrite ^/(.*)$ /$1 break; | |
proxy_set_header X-Real-IP $remote_addr; |
View virtual-host
<VirtualHost *:80> | |
#webmaster's email address | |
ServerAdmin webmaster@localhost | |
ServerName my-virtual-host | |
DocumentRoot /var/www/my-virtual-host/document/root/ | |
<Directory /> | |
Options FollowSymLinks | |
#Comment following to enable oveririding through .htaccess, e.g. mod_rewrite | |
AllowOverride None | |
</Directory> |
NewerOlder