Skip to content

Instantly share code, notes, and snippets.

View natp0ng's full-sized avatar
🐯

Nut natp0ng

🐯
  • 08:27 (UTC +07:00)
View GitHub Profile
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 / 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);
}
...
@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.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 / default
Created January 19, 2018 10:19 — forked from dtomasi/default
Brew Nginx PHP7
server {
listen 80;
server_name localhost;
root /Users/YOUR_USERNAME/Sites;
access_log /Library/Logs/default.access.log main;
location / {
include /usr/local/etc/nginx/conf.d/php-fpm;
}
@natp0ng
natp0ng / NginxRedirect.md
Created July 10, 2017 17:11 — forked from EmranAhmed/NginxRedirect.md
NGINX Redirect, Rewrite

Redirect: Temporary and Permanent

Source

What is an HTTP Redirect?

HTTP redirection, or URL redirection, is a technique of pointing one domain or address to another. There are many uses for redirection, and a few different kinds of redirection to consider.

As you create content and administrate servers, you will often find the need to redirect traffic from one place to another. This guide will discuss the different use-cases for these techniques, and how to accomplish them in Apache and Nginx.

@natp0ng
natp0ng / LaravelSecurity
Created March 21, 2017 18:00
Laravel framework file permission - Security
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
@natp0ng
natp0ng / main.js
Created January 17, 2017 07:09
Electron Remote Debugging via IP address
"use strict";
const electron = require('electron');
const app = electron.app;
app.commandLine.appendSwitch('remote-debugging-port', '8888');
// ref: https://github.com/nodejitsu/node-http-proxy
const http = require('http'),
httpProxy = require('http-proxy');
@natp0ng
natp0ng / webos-ss-client.js
Created August 18, 2016 04:41 — forked from jlai/webos-ss-client.js
Example nodejs code for connecting to a webOS Smart TV
/*
* Copyright (c) 2014 LG Electronics.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
const {desktopCapturer, remote, ipcRenderer} = require('electron');
const util = require('util');
import { getSignedRequest, uploadFileToS3 } from './helper';
var MediaStreamRecorder = require('msr');
var mediaRecorder;
var transactionId;
var uiSelectScreen, uiButtonCapture, uiPlayer, uiLinkViewer, uiPreview;
let desktopSharing = false;
var recordAndUpload = true;