Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am everdark on github.
  • I am kyle9 (https://keybase.io/kyle9) on keybase.
  • I have a public key ASA5zrGmEZcGHpilcsWqBhUFrDvbcIDnfXLtlPE5b-w3Two

To claim this, I am signing this object:

@everdark
everdark / WSL-ssh-server.md
Created September 9, 2018 16:48 — forked from dentechy/WSL-ssh-server.md
A step by step tutorial on how to automatically start ssh server on boot on the Windows Subsystem for Linux

How to automatically start ssh server on boot on Windows Subsystem for Linux

Microsoft partnered with Canonical to create Bash on Ubuntu on Windows, running through a technology called the Windows Subsystem for Linux. Below are instructions on how to set up the ssh server to run automatically at boot.

  1. Uninstall and reinstall the ssh server using the following commands:
    1. sudo apt remove openssh-server
    2. sudo apt install openssh-server
  2. Edit the /etc/ssh/sshd_config file by running the command sudo vi /etc/ssh/sshd_config and do the following
    1. Change Port to 2222 (or any other port above 1000)
  3. Change UsePrivilegeSeparation to no
@everdark
everdark / mxnet_lstm_toy.R
Last active March 26, 2017 07:17
mxnet character-level lstm model: toy example
#!/usr/bin/env Rscript
# kylechung 2017-03-25
# refernece: http://mxnet.io/tutorials/r/charRnnModel.html
library(mxnet)
library(magrittr)
library(data.table)
# get the text data
@everdark
everdark / do.sh
Last active December 3, 2015 15:20
A helper script for backup operation on wordpress in docker
#!/usr/bin/env bash
usage() {
echo ""
echo "Usage: $0 command"
echo ""
echo "commands:"
echo " -b, --backup : backup the current data volume of MySQL container"
echo " -r, --restore : restore the data volume of MySQL container from a backup"
echo " -s, --sync : sync every local and remote file for whichever is newer"
@everdark
everdark / logstash_on_pi.sh
Created November 20, 2015 17:14
solve logstash jruby issue on raspberry pi 2
# reference:
# https://github.com/elastic/logstash/issues/1916
# https://github.com/jruby/jruby/issues/1561#issuecomment-67953147
cd /tmp
git clone https://github.com/jnr/jffi.git
cd jffi
ant jar # sudo apt-get install ant
# replace libjffi-1.2.so with the one build on pi
@everdark
everdark / argparse.scala
Last active October 19, 2015 06:35
command line parser for various language
object ParseArg {
val usage = "Usage: argparse --s1 v1 --s2 v2 --f opt"
def main(args: Array[String]) = {
if (args.length == 0) {System.err.println(usage); System.exit(1)}
def parseArg(argparsed: Map[Symbol,Any], arglist: List[String]): Option[Map[Symbol,Any]] = {
arglist match {
@everdark
everdark / ssh_tunnel.sh
Last active August 29, 2015 14:06
open/close ssh tunnel
#!/bin/bash
[ $# -eq 0 ] && {
echo "Usage: $0 [run|kill]"
exit 0
}
[ "$1" == "run" ] && {
ssh -NfD 8888 <SERVERIP>
echo start ssh tunneling via my server over socks proxy
@everdark
everdark / play_with_cmdline_arg.sh
Last active August 29, 2015 14:06
shell scripting playground: command line arguments
#!/bin/bash
[ $# -eq 0 ] && {
echo give me some arguments!
exit 0
}
echo $0 $1 ${2:-default_value} ${3:+and a third arg exists!}
echo total number of arguments passed: $#
echo all arguments: $*
@everdark
everdark / ping_batch.sh
Created May 17, 2014 01:47
ping a range of ip and report positive only
#!/bin/bash
range=10.0.1.
for digit in $(seq 1 254);
do
ping -c1 -W100 $range$digit >/dev/null 2>&1
if [ "$?" -eq "0" ]; then
echo $range$digit
fi
done
@everdark
everdark / .screenrc
Last active May 17, 2020 04:10
Bash shell automation cheat sheet
# save as ~/.screenrc
startup_message off
caption always "%{=u .r} %-w%<%{=ub .Y}%n %t%{=u .r}%+w "
hardstatus alwaysignore
hardstatus alwayslastline "%{= .K} [%l]%<%=%{= .Y}$USER%{= .R}@%H %=%{= .m} %Y/%m/%d%{= .M} %0c "
defutf8 on
#caption always "%{= wk} %{= KY} [%n]%t @ %H %{-} %= %{= KR} %l %{-} | %{= KG} %Y-%m-%d %{-} "
#hardstatus alwayslastline " %-Lw%{= Bw}%n%f %t%{-}%+Lw %=| %0c:%s "
defscrollback 20480