Skip to content

Instantly share code, notes, and snippets.

💭
I may be slow to respond.

Anh Nguyen anhnt

💭
I may be slow to respond.
Block or report user

Report or block anhnt

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 keybase.md

Keybase proof

I hereby claim:

  • I am anhnt on github.
  • I am anhng (https://keybase.io/anhng) on keybase.
  • I have a public key ASB8CyLSz6AYRH-Vkyc-bNk6Vz8m5kY6J4-gBk_vZJyevQo

To claim this, I am signing this object:

View Mongodb restore and dump commands via json, bson and csv.md

NOTE -

  • Remove -h option if you are doing operation on same machine
  • Remove -u , -p option if your database don't have username and password

Binary

Import database

mongorestore -h IP:port -d DB_Name -u user_name -p password <input db directory>
View gist:2ba4705fe71895d124638afce75f67d3
sudo yum install libmpc-devel mpfr-devel gmp-devel
cd ~/Downloads
curl ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-4.9.2/gcc-4.9.2.tar.bz2 -O
tar xvfj gcc-4.9.2.tar.bz2
cd gcc-4.9.2
./configure --disable-multilib --enable-languages=c,c++
make -j 4
make install
View qrencode centos
On CentOS 6 (64-bit), I had trouble installing the qrencode dependency from source. Instead, I found it easier to install the packages qrencode and qrencode-devel from the RPMForge repo.
# Enable the rpmforge repo if you don't already have it
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
rpm -Uvh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
# Install qrencode and its libraries
yum install qrencode qrencode-devel
@anhnt
anhnt / DKIM_SPF_Sendmail
Created Jan 25, 2018 — forked from artmouse/DKIM_SPF_Sendmail
DKIM + SPF + Sendmail for multiple domains (Ubuntu)
View DKIM_SPF_Sendmail
DKIM is DomainKeys Identified Mail and is used in mail servers, such as Postfix or Sendmail to sign e-mails and thus authenticating the sender so that a forgery can be detected. It also reduces the possibility of an e-mail being flagged as spam, but it's not a definite prevention.
A much simpler method is using SPF (Sender Policy Framework) which, in a nutshell, verifies the sender IP address.
According to the internet, using both should result to ????, PROFIT !!!.
SPF does not need a specific configuration. Whitelisted servers are listed in a DNS record, TXT or SPF, and an example record is:
example.com. IN TXT "v=spf1 a mx ~all"
@anhnt
anhnt / reset-wsl.sh
Created Jan 12, 2018 — forked from ishu3101/reset-wsl.sh
Resetting your Windows Subsystem for Linux (WSL) Environment
View reset-wsl.sh
# Resetting your Windows Subsystem for Linux (WSL) Environment
lxrun.exe /uninstall /full
lxrun.exe /install
View override jquery form
<script>
/**
* Show error message
* @param {jQuery} form
* @param {Object} config
* @param {String|Array} message
*/
function showErrorMessage(form, config, message) {
config = getFormConfig(form, config);
View 1-restify-server-cheatsheet.js
// Restify Server CheatSheet.
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
var restify = require('restify');
View node-gyp fix
STEP 1
Perform full installation of C++ Build Tools 2015 (from: https://blogs.msdn.microsoft.com/vcblog/2016/03/31/announcing-the-official-release-of-the-visual-c-build-tools-2015/)
(I say full install because this is what I did, however I don't claim that the full install is necessary)
Note: this may take a while as the full program is over 4GB
STEP 2
Install Python 2.7.11 (from: https://www.python.org/)
Note: during installation select the "add to PATH" option (which is not selected by default)
STEP 3
@anhnt
anhnt / call-apply-bind-proxy.js
Created Jul 11, 2016 — forked from branneman/call-apply-bind-proxy.js
JavaScript call() vs apply() vs bind() vs $.proxy()
View call-apply-bind-proxy.js
var fn = function(arg1, arg2) {
var str = '<p>aap ' + this.noot + ' ' + arg1 + ' ' + arg2 + '</p>';
document.body.innerHTML += str;
};
var context = {
'noot': 'noot'
};
var args = ['mies', 'wim'];
// Calls a function with a given 'this' value and arguments provided individually.
You can’t perform that action at this time.