Skip to content

Instantly share code, notes, and snippets.

%s/.*"name":"\([-a-z0-9A-Z.]*\)".*/\1/g
Convert {"host":{"name":"host.domain.com","id":348,"hostgroup_id":null,"operatingsystem_id":5}}, to list of hostnames.
@inhumantsar
inhumantsar / gist:42707c9598bc993243b5
Created September 10, 2014 19:05
Extract substring from grep matches
grep openvpn::client dev.pp | sed -e "s/\s*openvpn::client\s*{ '\([a-zA-Z]*\)':/\"\1\",/g"
takes
openvpn::client { 'serged':
openvpn::client { 'danielc':
openvpn::client { 'nigelg':
and converts it to
"serged",
"danielc",
"nigelg",
@inhumantsar
inhumantsar / multiargs.md
Created October 22, 2014 19:54
Bash Snippets
@inhumantsar
inhumantsar / docker-cp
Created October 31, 2014 05:57
Copy a file from the host to a running Docker container
#!/bin/bash
cp $1 /var/lib/docker/aufs/mnt/`docker inspect -f '{{.Id}}' $2`/
#!/bin/bash
if ! which wget > /dev/null; then
yum install -y wget
fi
export DOCKER_VERSION=1.3.0
pushd /tmp
if [ ! -f /usr/bin/docker ]; then
@inhumantsar
inhumantsar / linuxcheatsheet.md
Created January 22, 2015 18:44
Linux Cheat Sheet

To free pagecache, dentries and inodes:

  • free && sync && echo 3 > /proc/sys/vm/drop_caches && free
Stop/restart watching for changes in a file:
git update-index --assume-unchanged <file>
git update-index --no-assume-unchanged <file>
13:41 <alisdair> 6000 keystrokes per hour
13:41 <alisdair> that seems high
13:43 <cheeseprocedure> 100 words per minute is 6000 words per hour, yes? 6000 keystrokes should be pretty easy
13:43 <cheeseprocedure> it does seem like a bizarre metric though
13:43 <cheeseprocedure> oh, data entry
13:44 <cheeseprocedure> so probably more like punching digits into a numpad mindlessly?
14:42 <Lefty> I could probaby type 6000 keystrokes per hour using only my buttcheeks
14:42 <Lefty> in fact I'm going to apply just to attempt that
14:42 <cheeseprocedure> i look forward to your after-action report
14:42 <cheeseprocedure> also, i hope they have spare keyboards
@inhumantsar
inhumantsar / nb.py
Last active September 18, 2017 17:23
nationbuilder python exercises
#!pip install rauth
from rauth import OAuth2Service
import json
# init work
NATION_SLUG = 'somenation'
SITE_SLUG = 'somesite'
OAUTH_ID = 'someid'
OAUTH_SECRET = 'somesecret'
@inhumantsar
inhumantsar / github-create
Created January 18, 2019 19:54
github-create: create github repos from the command line, supports 2FA.
# github-create
# this function will create a new GitHub repo using credentials, including 2FA codes, supplied by the user.
# you can copy this entire file into your `~/.bashrc` or similar, or you can copy everything between the outermost
# curly braces into its own script and save that somewhere on your PATH.
# to use it, simply run `github-create` from within a local git repo.
github-create() {
HELP="""Creates a GitHub repo, sets it as the remote 'origin' for the local git repo, pushes.