Skip to content

Instantly share code, notes, and snippets.

View trungx's full-sized avatar
🚩
Go to 2022

trungx

🚩
Go to 2022
View GitHub Profile
@trungx
trungx / load_proper.js
Created July 22, 2019 05:36 — forked from ryanmcgrath/load_proper.js
How to properly branch loading of JS
/* Since script loading is dynamic, we take
a callback function with our loadScript call
that executes once the script is done downloading/parsing
on the page.
*/
var loadScript = function(src, callbackfn) {
var newScript = document.createElement("script");
newScript.type = "text/javascript";
newScript.setAttribute("async", "true");
newScript.setAttribute("src", src);
@trungx
trungx / nginx.conf
Created May 29, 2019 03:41 — forked from flatanimals/nginx.conf
Nginx server config for Laravel 4 and SimpleSamlphp
#
# Nginx host conf
#
# Allows Laravel 4 and SimpleSamlphp to exist together peacefully
#
# Laravel 4 -
# https://github.com/laravel/laravel
# SimpleSamlphp -
# https://github.com/simplesamlphp/simplesamlphp
#
@trungx
trungx / gist:9a6441aae59f2c2b89d0faaad545cac7
Created May 4, 2019 04:56 — forked from Mikodes/gist:be9b9ce42e46c3d4ccb6
All Media queries for resolutions
/* (320x480) iPhone (Original, 3G, 3GS) */
@media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
/* insert styles here */
}
/* (320x480) Smartphone, Portrait */
@media only screen and (device-width: 320px) and (orientation: portrait) {
/* insert styles here */
}
<!DOCTYPE html>
<html>
<head>
<meta chrset="UTF 8">
<title>Event Registration</title>
<script src="https://code.angularjs.org/1.6.9/angular.min.js"></script>
<script src="https://code.angularjs.org/1.6.9/angular-route.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js"></script>
</head>
@trungx
trungx / js_wordwrap.js
Created April 9, 2019 03:44
js_wordwrap
function wordwrap( str, width, brk, cut ) {
brk = brk || '\n';
width = width || 75;
cut = cut || false;
if (!str) { return str; }
var regex = '.{1,' +width+ '}(\\s|$)' + (cut ? '|.{' +width+ '}|.+$' : '|\\S+?(\\s|$)');
return str.match( RegExp(regex, 'g') ).join( brk );
@trungx
trungx / Install env OSX
Created April 9, 2019 03:09 — forked from pnlinh/Install env OSX
Install env for web develop with nginx, php, mysql, git...
# Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install git
# Zsh (can skip)
brew install zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
brew install nginx
<span style="display: none;">&nbsp;</span><span style="font-size:14px;"><meta http-equiv="Content-Type" content="text/html; charset=utf-8" style="margin-top:0;margin-bottom:0;margin-right:0;margin-left:0;padding-top:0;padding-bottom:0;padding-right:0;padding-left:0;font-size:100%;font-family:'Avenir Next', 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;line-height:1.65;" /><meta name="viewport" content="width=device-width" style="margin-top:0;margin-bottom:0;margin-right:0;margin-left:0;padding-top:0;padding-bottom:0;padding-right:0;padding-left:0;font-size:100%;font-family:'Avenir Next', 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;line-height:1.65;" />
<style style="margin-top:0;margin-bottom:0;margin-right:0;margin-left:0;padding-top:0;padding-bottom:0;padding-right:0;padding-left:0;font-size:100%;font-family:'Avenir Next', 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;line-height:1.65;" type="text/css">* { margin: 0; padding: 0; font-size: 100%; font-family: 'Aven
@trungx
trungx / mail.html
Created April 3, 2019 14:39
order email template - ecommerce
<head>
<style type="text/css">
@import url(https://fonts.googleapis.com/css?family=Roboto:400,300,500,700,700italic,900);
body {
font-family: 'Roboto', Arial, sans-serif !important;
}
a[href^="tel"] {
color: inherit;
// timestamp function
function getTimeStamp() {
var now = new Date();
var month = now.getMonth() + 1;
if(month < 10) { month = "0"+ month }
var date = now.getDate();
if(date < 10) {date = "0" + date }
var hour = now.getHours();
if(hour < 10) { hour = "0" + hour }
var minute = now.getMinutes();
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');