Skip to content

Instantly share code, notes, and snippets.

View samuraitruong's full-sized avatar

Truong Nguyen samuraitruong

View GitHub Profile
@samuraitruong
samuraitruong / .babelrc
Created July 18, 2017 11:02 — forked from c9s/.babelrc
webpack + babel + typescript + es6 - total solutions!
{
"presets": ["es2015"],
"plugins": ["transform-runtime"]
}
ORG=PRIVATE_ORG; PAGE=1;
curl "https://api.github.com/orgs/$ORG$/repos?page=1&per_page=100" |
grep -e 'ssh_url*' |
cut -d \" -f 4 |
xargs -L1 git clone
USER=USERNAME; PAGE=1;
curl "https://api.github.com/users/$USER$/repos?page=1&per_page=100" |
grep -e 'ssh_url*' |
#!/bin/bash
yum update -y
mkdir /var/www
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash
. ~/.nvm/nvm.sh
nvm install 8.6.0
node -e "console.log('Running Node.js ' + process.version)"
n=$(which which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local
#!/bin/bash
yum update -y
echo "Node Linux Installer by www.github.com/taaem"
echo "Need Root for installing NodeJS"
sudo su -c 'echo "Got Root!"'
echo "Get Latest Version Number..."
{
wget --output-document=node-updater.html https://nodejs.org/dist/latest/
rsync --no-perms --omit-dir-times --delete -vr -e "ssh -i /home/teamcity/.ssh/id_rsa_custom" --timeout=1000 --log-file=/tmp/rsyncd.log ./build/ ci@server:/var/www/build/
rsync --no-perms --omit-dir-times -vr -e "ssh -i /home/teamcity/.ssh/id_rsa_custom" --timeout=1000 --log-file=/tmp/rsyncd.log ./node_modules/ ci@server:/var/www/node_modules/
rm -f .env.production.local
cat >.env.production.local <<'EOL'
AAA=VVVV/
BBB=XXXX
EOL
cat .env.production.local
cd xxx
wget https://download.microsoft.com/download/5/F/0/5F0362BD-7D0A-4A9D-9BF9-022C6B15B04D/dotnet-runtime-2.0.0-linux-x64.tar.gz
sudo mkdir -p /opt/dotnet && sudo tar zxf dotnet-runtime-2.0.0-linux-x64.tar.gz -C /opt/dotnet
sudo ln -s /opt/dotnet/dotnet /usr/local/bin
echo off
Setlocal EnableDelayedExpansion
cls
SET "WWWROOT=C:\inetpub\wwwroot"
SET "SOURCES=deploy"
rem Using quotes around "var=value" in case the path may contain spaces
for /d %%a in ("%WWWROOT%\*") do (
echo Copying : from : %SOURCES%, Target: %%a
@samuraitruong
samuraitruong / 1) Install
Created January 10, 2018 22:46 — forked from nghuuphuoc/1) Install
Install Redis on Centos 6
// --- Compiling ---
$ wget http://download.redis.io/releases/redis-2.8.3.tar.gz
$ tar xzvf redis-2.8.3.tar.gz
$ cd redis-2.8.3
$ make
$ make install
// --- or using yum ---
$ rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
$ rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
@samuraitruong
samuraitruong / handler.py
Created January 11, 2018 22:45 — forked from patrickbrandt/handler.py
Restricting Lambda function by IP address
import json
import os
def ping(event, context):
ip1 = event['headers']['X-Forwarded-For'].split(',')[0]
ip2 = event['requestContext']['identity']['sourceIp']
print('two different referring IP address parsing techniques ip1: %s and ip2: %s') % (ip1, ip2)
referringIP = event['requestContext']['identity']['sourceIp']
#TODO: use a comma-delimited string to store multiple IP address values in the environment variable
@samuraitruong
samuraitruong / my-mailer.js
Created February 9, 2018 10:56 — forked from jonataswalker/my-mailer.js
Sending mail with Gmail (XOAuth2) and Nodemailer
'use strict';
var xoauth2 = require('xoauth2');
var nodemailer = require('nodemailer');
var smtp = require('nodemailer-smtp-transport');
var htmlToText = require('nodemailer-html-to-text').htmlToText;
// Sending mail with Gmail using XOAuth2
// http://masashi-k.blogspot.com.br/2013/06/sending-mail-with-gmail-using-xoauth2.html