Skip to content

Instantly share code, notes, and snippets.

@ns408
ns408 / README.md
Created March 14, 2018 07:31 — forked from magnetikonline/README.md
Bash internal field separator (IFS) usage.

Bash internal field separator (IFS) usage

The IFS internal variable is used to determine what characters Bash defines as word/item boundaries when processing character strings. By default set to whitespace characters of space, tab, and newline.

Running the example ifs.sh, comparing the difference between the default and setting only newline as a boundary we get the following output:

/path/to/first
file
/path/to/second
file
/path/to/third
@ns408
ns408 / get_latest_release.sh
Created March 15, 2018 05:56 — forked from lukechilds/get_latest_release.sh
Shell - Get latest release from GitHub
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
# Usage
# $ get_latest_release "creationix/nvm"
# v0.31.4
<?
/////////////////////
// slack2html
// by @levelsio
/////////////////////
//
/////////////////////
// WHAT DOES THIS DO?
/////////////////////
//
@ns408
ns408 / Mac SSH Autocomplete
Created March 20, 2018 02:05 — forked from aliang/Mac SSH Autocomplete
Add auto complete to your ssh, put into your .bash_profile
_complete_ssh_hosts ()
{
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
comp_ssh_hosts=`cat ~/.ssh/known_hosts | \
cut -f 1 -d ' ' | \
sed -e s/,.*//g | \
grep -v ^# | \
uniq | \
grep -v "\[" ;
@ns408
ns408 / README.md
Created March 29, 2018 07:44 — forked from yorkxin/README.md
Amazon S3 Redirect Rules Generator

Amazon S3 Redirect Rules Generator

A Ruby script to generate simple Amazon S3 Redirection Rules XML file.

Update: There is an app for that now! Use Amazon S3 Redirector (Web app) and you can generate the XML without any knowledge about Ruby. Thanks to @rainforestapp. BTW, It's open source too.

Dependencies

  • Nokogiri
@ns408
ns408 / minecraft_do.yml
Created March 29, 2018 11:44 — forked from rdhyee/minecraft_do.yml
Ansible playbook to launch a digitalocean droplet and then configure it to run Minecraft based on instructions from https://www.digitalocean.com/community/articles/how-to-set-up-a-minecraft-server-on-linux Note that some things are hardwired: the name of the droplet, the version of minecraft
# http://www.ansibleworks.com/docs/modules.html#digital-ocean
# Create a new Droplet
# Will return the droplet details including the droplet id (used for idempotence)
- name: launch DO droplet
hosts: local
gather_facts: False
tasks:
- name: pwd
'''
USAGE:
Use python3
Place addresses to track, one per line, in addresses.txt
Place assetchains to track, one per line, in assets.txt
Adjust balance_threshold and send_amount as needed
If you need to specify an alternative komodo_cli location, either pass it as the first argument
when invoking the script, or change the komodo_cli variable.
'''
import unicodedata
with open("steam_crash.txt", 'rb') as myfile:
message = myfile.read()
print('Length of message in bytes: ' + str(len(message)))
message = message.decode('utf-8')
print('Number of characters in message: ' + str(len(message)))
@ns408
ns408 / git-commit-author-rewrite.md
Created April 14, 2018 09:37 — forked from trey/git-commit-author-rewrite.md
Change the email address for a git commit.

Change the email address for a git commit.

$ git commit --amend --author="Author Name <[email protected]>"

or

$ git commit --amend --reset-author
@ns408
ns408 / gist:9cfd6370aa7d5660ff3be35d646485b6
Created April 23, 2018 16:29 — forked from dustismo/gist:6203329
How to install leveldb on ubuntu
sudo apt-get install libsnappy-dev
wget https://leveldb.googlecode.com/files/leveldb-1.9.0.tar.gz
tar -xzf leveldb-1.9.0.tar.gz
cd leveldb-1.9.0
make
sudo mv libleveldb.* /usr/local/lib
cd include
sudo cp -R leveldb /usr/local/include