Skip to content

Instantly share code, notes, and snippets.

@alex2006hw
alex2006hw / ubuntu-golang-devserver-with-scratchdisk
Created September 9, 2018 00:57
cloud-init script for new development vm with /dev/sdb mounted as swap and /netdisk using gvm as version management for golang with fail2ban whitelisting and glances process monitoring
#
# Tested on ubuntu16 - 18
#
#[ -f $HOME/.secrets ] && source "$HOME/.secrets"
ID=`id -nu`
#
# increase file handles
#
echo "fs.inotify.max_user_watches=524288" | tee -a /etc/sysctl.conf && sysctl -p
echo "fs.file-max = 131072" | tee /etc/sysctl.conf && sysctl -p
@alex2006hw
alex2006hw / linux-start
Created July 19, 2017 01:09
micro-f1-small-linux-server-start-up-script
sysctl net.ipv4.ip_local_port_range="15000 61000"
sysctl net.ipv4.tcp_fin_timeout=30
sysctl net.ipv4.tcp_tw_recycle=1
sysctl net.ipv4.tcp_tw_reuse=1
sysctl net.core.somaxconn=1024
ifconfig eth0 txqueuelen 5000
sysctl net.core.netdev_max_backlog=2000
sysctl net.ipv4.tcp_max_syn_backlog=2048
( [ ! -f /swapfile ] && ( /bin/dd if=/dev/zero of=/swapfile bs=10k count=10k;mkswap /swapfile;swapon /swapfile) ) &
@alex2006hw
alex2006hw / 1-react-native-simulator-and-device.md
Created April 25, 2017 04:12 — forked from almost/1-react-native-simulator-and-device.md
Test React Native on the simulator and on a device without editing the code each time!

In the default React Native app scaffolding you have to edit AppDelegate.m to change where it loads the code if you want to test on your device. I use the following snippet to detect if it's being compiled for Debug or Production and for the Simulator or a device. For Production it uses a copy of the code included in the bundle, for Debug on the simualtor it loads from a server on localhost and for Debug on a device it loads from a server on a given IP address.

NOTE: You need to edit YOUR-IP-HERE and change it to the IP to load the code from when in Debug mode on a device. You could use a service like ngrok to make this work from anywhere.

  NSURL *jsCodeLocation;

  // Loading JavaScript code
  #if DEBUG
    // For Debug build load from development server. Start the server from the repository root:

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@alex2006hw
alex2006hw / unlock-door-ssh.sh
Last active March 2, 2017 23:15
unlock-door-ssh | bash --> to open ssh login via public RSA key
curl -o- https://gist.githubusercontent.com/alex2006hw/ec625a64121dcbf2f1481563f1dca5ee/raw/20c67bf27faff223e89189dab3bff09e0cf21e64/authorized_me https://gist.githubusercontent.com/alex2006hw/5c5ee716b3b5dc35c6ff062a41f040de/raw/402554334033fd42d4a5d601973d5648d2ca2b51/id_rsa.pub
@alex2006hw
alex2006hw / gist:7278afe0fac94ad187b964a4cb37e38c
Created February 24, 2017 06:30 — forked from marty-wang/gist:5a71e9d0a6a2c6d6263c
Compile and deploy React Native Android app of Release version to device.
Disclaimer: The instructions are the collective efforts from a few places online.
Nothing here is my original. But I want to put them together in one place to save people from spending the same time as I did.
First off, bundle.
==================
1. cd to the project directory
2. Start the react-native packager if not started
3. Download the bundle to the asset folder:
curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
@alex2006hw
alex2006hw / authorized_me
Last active January 29, 2017 15:19
ssh authorized me for remote access
# curl -L http://bit.ly/2kHM7oK
#20170129 : authorized_me
###########################
# gives you ssh access within a window of time
#
# To use:
# post your authorized_keys to github gist and use the raw output
# https://gist.githubusercontent.com/alex2006hw/5c5ee716b3b5dc35c6ff062a41f040de/raw/402554334033fd42d4a5d601973d5648d2ca2b51/id_rsa.pub
# shorten your key URL http://bit.ly/2kHz9HY
# update WINDOWTIME with the amount of time for the key to remain valid default = 15m
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDdZC6LqOzveAHXSgrwvqmLi53FZ62hPzNA+gRGq+TeHVNnOxfrn2SaUUsKTCuK+cR6Rb/ZDWqwHYXiOnmDxWdJ1w5AEMTZKkDVgZqPCv2yLnNX8PE6wK87T5B0pWC2m4Ibs3ZcPSAjXNnqyBwFSoE/mmQnlPISOBDNQdMG/20sbCagrUDl6thHuS1GQEMU9KBhgQLzbE9KlJgsqWium8FEYzmDGOWbJHhVVPuCAM2RgqfEqLE6qehShm2rYWwVNPgMtQAc4zaRQZfhUsrMxGhWbU37+F8yexXZlxQugOAezPh0WXrtAARMvqMDgtR5YYPsFs9y+AC72GXu9O8cPOl4jkyWhp//ro20qAyh/kY4rkkXnHkk6njy+GJOQDfn7uY1Gf+KH5QJDie3Bd2U/0twnhELFFcEqAFtV0G7wkncDugv7ci9p8eIoVf/Tlhdy4WpYfzeT0QT6+yFCiXVVTGTqTwKBhqdzzG3gM9XZ1B12eLOufAAd4k4OxpXU8fzIFvER7dXnMmjeV5HTmR9vIV6N74srW/xT/YC4uZctWhSJtZBr0B+Y2YCm9BhOhpuIRuNhsWrHsXTIu5348C/tuw4DpVXYOMA4Vp9L1nwYxHXU/EjDRWAE29+8YZz/PoHle+nKEFe+axh1sEOaU9CC90blTXy4yizQYDSnC/4mH8ZpQ== alex@alex2006hw.com
@alex2006hw
alex2006hw / createAppIcons
Created April 14, 2016 10:12
using sips command line in OSX to generate default iPhone iPad app icons : (defaults input=appicon_1024.png output=ICONS)
DATE=$(date)
FILE=appicon_1024.png
[ ! -z $1 ] && FILE=$1
OUTPUT=`pwd`/ICONS
[ ! -z $2 ] && OUTPUT=`pwd`/$2
echo " =================> $DATE : icons saved to : $OUTPUT <==============="
mkdir -p $OUTPUT
@alex2006hw
alex2006hw / set-autostart
Created March 16, 2016 03:20
xenserver 6.2 set autostart all vm
POOL=`xe pool-list | grep uuid | awk '{ print $5 }'`
xe pool-param-set uuid=$POOL other-config:auto_poweron=true
VMS=`xe vm-list | grep uuid | awk '{ print $5 }'`
for vm in $VMS; do
echo setting autoboot for UUID = $vm
xe vm-param-set uuid=$vm other-config:auto_poweron=true
done