Skip to content

Instantly share code, notes, and snippets.

nhducit nhducit

  • Ho Chi Minh
Block or report user

Report or block nhducit

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

intellij javascript live templates

Just a dump of handy live templates I use with IntelliJ. They should also work with WebStorm.

How to

  • Go to settings.
  • Search for live templates.
  • Under the javascript section you should be able to manage your templates.
nhducit / Javascript Natural Sort Algorithm With Unicode Support
Last active Aug 29, 2015
Javascript Natural Sort Algorithm With Unicode Support
View Javascript Natural Sort Algorithm With Unicode Support
* Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license
* Author: Jim Palmer (based on chunking idea from Dave Koelle)
* Reference:
function naturalSort (a, b) {
var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi,
sre = /(^[ ]*|[ ]*$)/g,
dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,
hre = /^0x[0-9a-f]+$/i,
View regex-weburl.js
// Regular Expression for URL validation
// Author: Diego Perini
// Updated: 2010/12/05
// License: MIT
// Copyright (c) 2010-2013 Diego Perini (
// Permission is hereby granted, free of charge, to any person
nhducit / checkDuplicateID
Last active Aug 29, 2015
Javascript snippet to check duplicated ID in html page
View checkDuplicateID
Select all below snippet => drag and drop in browser bookmark bar
=> click on bookmark which you have just add => check the browser console
javascript:(function(){var e={};$("[id]").each(function(){var t=$('[id="''"]');if(t.length>1&&t[0]===this){;e.obj=this;e.obj2=t[0]}});console.warn("Duplicate ID:",,e.obj,e.obj2)})();
View replace.js
var myString = 'EXAMPLEstring';
var myNewString = myString.replace(/[A-Z]/g, '0');
function replaceFunc (a, b, c) {
console.log(a, b, c);
return a.toLowerCase();
var myOtherString = myString.replace(/[A-Z]/g, replaceFunc);
nhducit /
Created Oct 2, 2015 — forked from staltz/
The introduction to Reactive Programming you've been missing
View remove array item by index
Array.prototype.remove = function(from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
nhducit /
Created Jul 13, 2016 — forked from agnoster/
My ZSH Theme


A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

For Mac users, I highly recommend iTerm 2 + Solarized Dark

View GoogleApi.js
export const GoogleApi = function(opts) {
opts = opts || {}
const apiKey = opts.apiKey;
const libraries = opts.libraries || [];
const client = opts.client;
const URL = '';
const googleVersion = '3.22';
let script = null;
nhducit / Child.js
Created Aug 27, 2016 — forked from eyesofkids/Child.js
Simple React Lifecycle methods test
View Child.js
import React from 'react'
var Child = React.createClass({
getInitialState: function(){
console.log('Child getInitialState');
return { value: 'start'}
getDefaultProps: function(){
console.log('Child getDefaultProps');
You can’t perform that action at this time.