Skip to content

Instantly share code, notes, and snippets.

View athiwatp's full-sized avatar
💭
I may be slow to respond.

athiwatp athiwatp

💭
I may be slow to respond.
View GitHub Profile
No 'Access-Control-Allow-Origin' header is present on the requested resource
Angular 2
chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security
@athiwatp
athiwatp / a_mongodb_to_s3_backup.sh
Created June 27, 2017 17:08 — forked from lazarofl/a_mongodb_to_s3_backup.sh
MongoDB Automatic Backup to Amazon S3 with Crontab and s3cmd. Red Hat Linux on Amazon EC2
#!/bin/bash
#Force file syncronization and lock writes
mongo admin --eval "printjson(db.fsyncLock())"
MONGODUMP_PATH="/usr/bin/mongodump"
MONGO_HOST="prod.example.com"
MONGO_PORT="27017"
MONGO_DATABASE="dbname"
@athiwatp
athiwatp / extend.js
Created August 10, 2017 17:02 — forked from katowulf/extend.js
A simple extend function for JavaScript
function extend(base) {
var parts = Array.prototype.slice.call(arguments, 1);
parts.forEach(function (p) {
if (p && typeof (p) === 'object') {
for (var k in p) {
if (p.hasOwnProperty(k)) {
base[k] = p[k];
}
}
}
@athiwatp
athiwatp / token-generator.js
Created August 16, 2017 19:16 — forked from ziluvatar/token-generator.js
Example of refreshing tokens with jwt
/**
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken
* It was requested to be introduced at as part of the jsonwebtoken library,
* since we feel it does not add too much value but it will add code to mantain
* we won't include it.
*
* I create this gist just to help those who want to auto-refresh JWTs.
*/
const jwt = require('jwt');
@athiwatp
athiwatp / _readme.md
Created August 30, 2017 15:17 — forked from pongstr/_readme.md
HTTP/2 Recipe: Nginx + Node.js

Imgur

Recipe

Install homebrew/services, this will be helpful, you'll see later. :D

$ brew tap homebrew/services 
@athiwatp
athiwatp / gist:e9e2c591f5180644a1b15b88286e6aae
Created August 31, 2017 04:42 — forked from yoitsro/gist:8693021
Node + Restify + Passport + Sessions + WebSockets
var restify = require('restify');
// Authentication
var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
var sessions = require("client-sessions");
var server = restify.createServer();
server.use(restify.queryParser());
server.use(restify.bodyParser());
@athiwatp
athiwatp / CRC16-CCITT.js
Created September 2, 2017 18:22 — forked from chitchcock/CRC16-CCITT.js
A quick and dirty copy of a C routine for generating a CRC16-CCITT with an intial value of 0xFFFF in Javascript
// Modified from http://automationwiki.com/index.php?title=CRC-16-CCITT
var crcTable = [0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5,
0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b,
0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210,
0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c,
0xf3ff, 0xe3de, 0x2462, 0x3443, 0x0420, 0x1401,
0x64e6, 0x74c7, 0x44a4, 0x5485, 0xa56a, 0xb54b,
0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
@athiwatp
athiwatp / install.sh
Created September 28, 2017 03:45 — forked from moshest/install.sh
AWS CodeDeploy with Node.js
#!/bin/bash
# usage: `curl --silent --location https://gist.githubusercontent.com/moshest/32b19e146bc5e1665708c885e535a631/raw/install.sh | bash -`
set -e
yum -y update
AWS_REGION=`curl http://169.254.169.254/latest/dynamic/instance-identity/document|grep region|awk -F\" '{print $4}'`
echo AWS Region: $AWS_REGION
# install CodeDeploy
@athiwatp
athiwatp / appspec.yml
Created September 28, 2017 03:45 — forked from moshest/appspec.yml
Node.js Project on AWS CodeDeploy CentOS
version: 0.0
os: linux
files:
- source: /
destination: /home/ec2-user/node
permissions:
- object: /home/ec2-user
owner: ec2-user
group: ec2-user
type:
@athiwatp
athiwatp / ffmpeg-cheatsheet.md
Created September 28, 2017 03:46 — forked from moshest/ffmpeg-cheatsheet.md
FFmpeg cheat sheet for 360 video

FFmpeg Cheat Sheet for 360º video

Brought to you by Headjack

 
FFmpeg is one of the most powerful tools for video transcoding and manipulation, but it's fairly complex and confusing to use. That's why I decided to create this cheat sheet which shows some of the most often used commands.

 
Let's start with some basics:

  • ffmpeg calls the FFmpeg application in the command line window, could also be the full path to the FFmpeg binary or .exe file