Skip to content

Instantly share code, notes, and snippets.

Tony Dinh trungdq88

Block or report user

Report or block trungdq88

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View fix_mysqldump_single_quote_espace.js
// 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 = [];
@trungdq88
trungdq88 / elem2dict.py
Last active Dec 2, 2015 — forked from jacobian/elem2dict.py
Convert an lxml.etree node tree into an object.
View elem2dict.py
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>
@trungdq88
trungdq88 / calc.html
Created Oct 28, 2015
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.
View calc.html
<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>
View 20140702230000-1hour-return-20140702220000
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 / 1x1gif
Created Mar 12, 2014
1x1 GIF image URL data
View 1x1gif
data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
@trungdq88
trungdq88 / gist:7070431
Created Oct 20, 2013
Class for Javascript
View gist:7070431
//============================================================
// Register Namespace
//------------------------------------------------------------
var Shape = Shape||{};
//============================================================
// Constructor - MUST BE AT TOP OF FILE
//------------------------------------------------------------
Shape.Rectangle = function Shape_Rectangle(width, height, color){
this.Width = width;
You can’t perform that action at this time.