Skip to content

Instantly share code, notes, and snippets.

View khanhtran3005's full-sized avatar

Khanh Tran khanhtran3005

  • Inspectorio
  • Vietnam
View GitHub Profile
@khanhtran3005
khanhtran3005 / quote.md
Last active June 26, 2018 01:53
Quote the right way

Proper Quotes

glyph named entity numeric entity escaped unicode
“ “ \201C
” ” \201D
‘ ‘ \2018
’ ’ \2019
  • For normal bash shell

    sudo nano ~/.bashrc

  • For zsh

    sudo nano ~/.zshrc

  • Add any aliases you want:

e.g.

@khanhtran3005
khanhtran3005 / ignoreLocal.md
Last active August 29, 2015 14:23
Inorge files locally

Goto .git/info/exclude

Add files you want to ignore

If you already have unstaged changes you must then run: git update-index --assume-unchanged [...]

@khanhtran3005
khanhtran3005 / apache.conf
Last active August 29, 2015 14:11
Run NodeJS with Apache server
<VirtualHost *:80>
ServerName www.youserver.com
ProxyPass / http://localhost:1337/
ProxyPassReverse / http://localhost:1337/
SetEnvIf Request_URI "\.gif$|\.jpg$|\.png$|\.js$|\.css$|\.ico$" is_static
ErrorLog /home/vnrs_test/game/error.log
CustomLog /home/vnrs_test/game/access.log common env=!is_static
</VirtualHost>
@khanhtran3005
khanhtran3005 / php - nodejs
Last active September 14, 2021 04:14
Share session between PHP and NodeJS
http://stackoverflow.com/questions/24296212/php-nodejs-and-sessions#24303059
You can use memcached as your session storage handler in PHP. Memcached is a simple key value store that can be accessed via TCP; there is a memcached module available for Node.js.
PHP stores the session in memcached by using the session id as the key. The session data (value) stored in memcached is a serialized PHP object, with a slight twist. You can read more about this unusual serialization at the SO question "Parse PHP Session in Javascript". Luckily though, there is already an NPM module out there: php-unserialize.
Now for the How-To.
Assumptions
/* ---------------------------------------------------------------------------
Boilerplate CSS Media Queries
Encoding: UTF-8
Author: PaulUnd (http://www.paulund.co.uk/boilerplate-css-media-queries)
--------------------------------------------------------------------------- */
/* =Smartphones (portrait and landscape)
--------------------------------------------------------------------------- */
@media only screen
@khanhtran3005
khanhtran3005 / undefind validation | array + obj
Last active August 29, 2015 14:10
Check undefined for Javascript
/**
* Returns true if key is not a key in object or object[key] has
* value undefined. If key is a dot-delimited string of key names,
* object and its sub-objects are checked recursively.
*/
function isUndefinedKey(object, key) {
var keyChain = Array.isArray(key) ? key : key.split('.'),
objectHasKey = keyChain[0] in object,
keyHasValue = typeof object[keyChain[0]] !== 'undefined';
@khanhtran3005
khanhtran3005 / Meta template
Last active August 29, 2015 14:09
Meta tags for open graph
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<link rel="canonical" href="" />
<meta property="og:title" content="" />
@khanhtran3005
khanhtran3005 / rails_resources.md
Last active August 29, 2015 14:08 — forked from jookyboi/rails_resources.md
Rails-related Gems and guides to accelerate your web project.

Gems

  • Bundler - Bundler maintains a consistent environment for ruby applications. It tracks an application's code and the rubygems it needs to run, so that an application will always have the exact gems (and versions) that it needs to run.
  • rabl - General ruby templating with json, bson, xml, plist and msgpack support
  • Thin - Very fast and lightweight Ruby web server
  • Unicorn - Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency, high-bandwidth connections and take advantage of features in Unix/Unix-like kernels.
  • SimpleCov - SimpleCov is a code coverage analysis tool for Ruby 1.9.
  • Zeus - Zeus preloads your Rails app so that your normal development tasks such as console, server, generate, and specs/tests take less than one second.
  • [factory_girl](h
@khanhtran3005
khanhtran3005 / css_resources.md
Last active August 29, 2015 14:08 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides