Skip to content

Instantly share code, notes, and snippets.

View natp0ng's full-sized avatar
🐯

Nut natp0ng

🐯
  • 13:47 (UTC +07:00)
View GitHub Profile
@natp0ng
natp0ng / index.js
Last active January 23, 2018 04:50
Sample nodejs with es6
import http from 'http'
http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' })
res.end('Hello World\n')
}).listen(8000, '127.0.0.1')
console.log('Server running at http://127.0.0.1:8000/')
@natp0ng
natp0ng / app.js
Created January 23, 2018 05:28
Sample react + webpack
const React = require("react");
const ReactDOM = require("react-dom");
const $ = React.createElement;
ReactDOM.render(
$("div", null, <h1>Hello World</h1>),
document.getElementById("root")
);
@natp0ng
natp0ng / index.php
Created February 14, 2018 17:19
laravel change public folder to public_www
<?php
// add public_path to /public_html/index.php
function public_path($path = '')
{
return realpath(__DIR__)
.($path ? DIRECTORY_SEPARATOR.$path : $path);
}
...
function onTimezoneOffsetChange(changeHandler){
function getTimezoneOffset(){
const d = new Date()
return d.getTimezoneOffset()
}
function getHourOffset(){
const d = new Date()
return (1000*60*60) - (((d.getMinutes()*60) + d.getSeconds()) * 1000) + d.getMilliseconds()
@natp0ng
natp0ng / postgres-brew.md
Created March 23, 2018 10:25 — forked from sgnl/postgres-brew.md
Installing Postgres via Brew (OSX) (outdated see top most note)

Outdated note: the process is a lot easier now: after you brew install postgresql you can initialize or stop the daemon with these commands: brew services start postgresql or brew services stop postgresql.

new out put may look like

To have launchd start postgresql now and restart at login:
  brew services start postgresql
Or, if you don't want/need a background service you can just run:
  pg_ctl -D /usr/local/var/postgres start
@natp0ng
natp0ng / AdbCommands
Created March 28, 2018 07:48 — forked from Pulimet/AdbCommands
Adb useful commands list
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
== Shell
@natp0ng
natp0ng / IndexedDB101.js
Created April 12, 2018 07:20 — forked from JamesMessinger/IndexedDB101.js
Very Simple IndexedDB Example
// This works on all devices/browsers, and uses IndexedDBShim as a final fallback
var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB;
// Open (or create) the database
var open = indexedDB.open("MyDatabase", 1);
// Create the schema
open.onupgradeneeded = function() {
var db = open.result;
var store = db.createObjectStore("MyObjectStore", {keyPath: "id"});
@natp0ng
natp0ng / gist:ca55e627d1fca8a453d5961c520b0ab6
Created July 2, 2018 10:04 — forked from wikimatze/gist:9790374
Github Two-Factor Authentication Failed For HTTPS

I heard from GitHub Two-Factor Authentication](https://github.com/blog/1614-two-factor-authentication) nearly a couple of days ago when I was reading my RSS feed. I enabled it and couldn' push to any of my repositories anymore. Learn in this blog post how to fix it.

Two-Factor Authentication

"Is a process involving two stages to verify the identity of an entity trying to access services in a computer or in a network". Github solves this authentication with sending an SMS to a device which wants to push to their platform.

Enabling Two-Factor Authentication

@natp0ng
natp0ng / video_test.html
Created July 9, 2018 12:53
Video test on RPI3 b+
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<video class="media-video" height="270" width="480" autoplay loop muted="" controls></video>
@natp0ng
natp0ng / postgresql-debugger-install-macos
Created August 25, 2018 10:32 — forked from nathansgreen/postgresql-debugger-install-macos
Installing the PL/pgSQL Debugger Extension (pldbgapi) for pgAdmin III on PostgreSQL 9.4 and MacOS
# First install database
brew install postgres
# Clone and build the PL/pgSQL server-side debugger
cd /usr/local/src
git clone git://git.postgresql.org/git/pldebugger.git
cd pldebugger
export USE_PGXS=1