Skip to content

Instantly share code, notes, and snippets.

View tung-dang's full-sized avatar
💭
I may be slow to respond.

Tung Dang tung-dang

💭
I may be slow to respond.
View GitHub Profile
// Exclude all node modules except hex-rgb and another-package
/node_modules\/(?![hex\-rgb|another\-package])/
@tung-dang
tung-dang / git_repo_helpers.sh
Last active December 7, 2018 10:54
Global functions to open git repo quickly.
#!/bin/sh
#############################################
# Some public functions in Open Bitbucket Cloud, Bitbucket Server or Github repo quickly:
# - git_create_pr
# - git_open_repo
# - git_view_current_commit_in_web
#############################################
// bad
function anAsyncCall() {
var promise = doSomethingAsync();
promise.then(function() {
somethingComplicated();
});
return promise;
}
@tung-dang
tung-dang / OSGI manifest instruction.xml
Last active March 20, 2016 22:03
Config atlas plugin
<project>
<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-***-plugin</artifactId> <!-- *** is the name of the application (product) you're using -->
<version>3.2.3</version>
<extensions>true</extensions>
<configuration>
<productVersion>${product.version}</productVersion>
var selectFromElementToElement = function(startSelection, endSelection) {
rng = dom.createRng();
rng.setStartBefore(startSelection);
rng.setEndAfter(endSelection);
sel.setRng(rng);
ed.nodeChanged();
};
@tung-dang
tung-dang / check_dir_exist.sh
Last active August 29, 2015 14:16
bash collections
# check if a directory exists in a shell script you can use the following:
if [ -d "$DIRECTORY" ]; then
# Control will enter here if $DIRECTORY exists.
fi
#Or to check if a directory doesn't exist:
if [ ! -d "$DIRECTORY" ]; then
# Control will enter here if $DIRECTORY doesn't exist.
fi
@tung-dang
tung-dang / resize.js
Created September 23, 2013 16:44
JS Mobile
//Ref: http://www.paulirish.com/2009/throttled-smartresize-jquery-event-handler/
(function($,sr){
// debouncing function from John Hann
// http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
var debounce = function (func, threshold, execAsap) {
var timeout;
return function debounced () {
// Listen for orientation changes
window.addEventListener("orientationchange", function() {
// Announce the new orientation number
console.log(window.orientation);
// 0 means portrait, 90 means landscape rotated to the left, -90 means landscape rotated to the right
}, false);
@tung-dang
tung-dang / template.php
Last active December 21, 2015 00:18
Wordpress
1. Include template
get_template_part('/partials/footer/globalFooterScript');
2. Get link of cat by cat name
<?php echo get_category_link( get_cat_ID( 'liên hệ' ) ) ?>