Skip to content

Instantly share code, notes, and snippets.

View kimtrien's full-sized avatar

Nguyen Kim Trien kimtrien

View GitHub Profile
@kimtrien
kimtrien / fixed-scroll-up.html
Created July 22, 2017 04:30
Event scroll up and fixed header jquery
<header>
Header
</header>
<script>
$(document).ready(function () {
var lastScroll = 0;
$(window).scroll(function(event){
var st = $(this).scrollTop();
// Make sure they scroll more than delta
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
@kimtrien
kimtrien / tricks.css
Last active August 5, 2017 02:23
Tricks CSS
.text-overflow{
display: block;
display: -webkit-box;
-webkit-line-clamp: 2; // Line number
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
.list-column-wrapping {
@kimtrien
kimtrien / justify-menu.css
Created June 15, 2017 04:05
justify a horizontal menu
ul{
display: flex;
justify-content: space-between;
}
@kimtrien
kimtrien / num_forvietnamese.php
Last active June 13, 2017 02:59
Number for vietnamese PHP
<?php
function num_forvietnamese($num = false)
{
$str = '';
$num = trim($num);
$f = number_format($num);
$arr = str_split($f);
@kimtrien
kimtrien / meta-tags.md
Created June 7, 2017 09:46 — forked from whitingx/meta-tags.md
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta charset='UTF-8'>
<meta name='keywords' content='your, tags'>
<meta name='description' content='150 words'>
<meta name='subject' content='your website's subject'>
<meta name='copyright' content='company name'>
@kimtrien
kimtrien / getUrlVars.js
Last active June 9, 2017 07:49
Javascript get query from url
// Read a page's GET URL variables and return them as an associative array.
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
@kimtrien
kimtrien / nginx-mobile-redirect
Created May 24, 2017 06:39 — forked from dangayle/nginx-mobile-redirect
NGINX Mobile redirect
#with regex from http://detectmobilebrowsers.com/
#map suggestion via kolbyjack
#not tested
map $http_user_agent $mobile_agent{
default 0;
~* "android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino" 1;
~* "^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibr
@kimtrien
kimtrien / auto_restart_webserver.sh
Created November 4, 2016 03:19 — forked from xi4oh4o/auto_restart_webserver.sh
Auto restart phpfpm on 502 & 504 Error also save logs
#!/bin/bash
MY_URL="http://moefou.org" #change you website
RESULT_502=`curl -I $MY_URL|grep "HTTP/1.1 502"`
RESULT_504=`curl -I $MY_URL|grep "HTTP/1.1 504"`
if [ -n "$RESULT_502" ]; then
killall php-fpm;php-fpm
date>>/data/logs/web_error.log;echo "502 Bad Gateway">>/data/logs/web_error.log
elif [ -n "$RESULT_504" ]; then
killall php-fpm;php-fpm
date>>/data/logs/web_error.log;echo "504 Gateway Time-out">>/data/logs/web_error.log
@kimtrien
kimtrien / mobile.js
Created September 19, 2016 02:38
Detect Mobile Javascript
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
// some code..
}