Skip to content

Instantly share code, notes, and snippets.

View trungdq88's full-sized avatar

Tony Dinh trungdq88

View GitHub Profile
@trungdq88
trungdq88 / gist:7070431
Created October 20, 2013 14:33
Class for Javascript
//============================================================
// Register Namespace
//------------------------------------------------------------
var Shape = Shape||{};
//============================================================
// Constructor - MUST BE AT TOP OF FILE
//------------------------------------------------------------
Shape.Rectangle = function Shape_Rectangle(width, height, color){
this.Width = width;
@trungdq88
trungdq88 / 1x1gif
Created March 12, 2014 08:36
1x1 GIF image URL data
data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
s='substring';
a=20140702230000+'';
d=new Date(a[s](0,4)+'-'+a[s](4,6)+'-'+a[s](6,8)+'T'+a[s](8,10)+':'+a[s](10,12)+':'+a[s](12,14)+'.000Z');
d=(new Date(d-3600000)).toISOString().split('-').join('').split('T').join('').split(':').join('').split('.')[0];
@trungdq88
trungdq88 / calc.html
Created October 28, 2015 13:27
calc(1)(2)(3)() = 6, calc(1)(1)(1)(1)() = 4, calc(a)(b)(c)...(z) = a + b + c + ... + z, find the calc function. Guys, let me know your solution.
<script>
var calc = function () {
var value = (this instanceof Number ? +this : 0);
if (!arguments.length) return value;
return calc.bind(arguments[0] + value);
}
console.log(calc(1)(8)(3)(99)());
</script>
@trungdq88
trungdq88 / elem2dict.py
Last active December 2, 2015 03:00 — forked from jacobian/elem2dict.py
Convert an lxml.etree node tree into an object.
def elem2dict(node):
"""
Convert an lxml.etree node tree into an object.
Notice: Since the xml and object (json) structure is not the same,
this utils will not work correctly if there is an xml element that
contains multiple duplicate child elements. For example:
<root>
<name>Hello</name>
<name>Is it me</name>
<hello>You looking for</hello>
// Fix this bug: http://bugs.mysql.com/bug.php?id=65941
// Usage:
// node fix_mysqldump_single_quote_espace.js data.sql > data_fixed.sql
const fs = require('fs')
const file = process.argv.pop();
const inputStream = fs.createReadStream(file, 'utf-8');
const outputStream = fs.createWriteStream('output', 'utf-8');
let backslashStack = [];
Hòa learn to code.
(function () {
String.prototype.padRight = function(l,c) {return this+Array(l-this.length+1).join(c||" ")};
// intersection
const intersect = xs => ys => {
const zs = createSet(ys);
return filter(x => zs.has(x)
? true
: false
) (xs);
@trungdq88
trungdq88 / Handling Page Transitions on Single Page Web Apps.md
Last active July 18, 2018 08:57
Handling Page Transitions on Single Page Web Apps

Handling Page Transitions on Single Page Web Apps

zoom

Real world application with a lot of pages (or "screens") have to deal with problem managing the pages' DOM and memory efficiently and at the same provide a nice smooth transition effect between pages. This is not a real problem when you do it in native apps since Android or iOS already handle the hard work for you, but when come to JavaScript, HTML, and CSS, running on mobile browsers, this is the real challenge.

There are 2 common approaches to solve this problem:

  • Approach 1: Keep all the pages in the DOM tree, use CSS (for example display) to transit between pages.
@trungdq88
trungdq88 / install-comodo-ssl-cert-for-nginx.rst
Created February 21, 2017 09:28 — forked from bradmontgomery/install-comodo-ssl-cert-for-nginx.rst
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert