Skip to content

Instantly share code, notes, and snippets.

View acaranta's full-sized avatar

Arthur Caranta acaranta

View GitHub Profile
@acaranta
acaranta / gist:ddf80e1f9be7b51216e2
Created September 9, 2014 14:16
Python am I running in a docker and if so what is its ID
#Determines if we run within a docker container
#Might not be truly cleany as a way to check but it works ;)
def dockerized():
if 'docker' in open('/proc/1/cgroup').read():
return True
def getowndockerid():
dockerid = ""
for line in open('/proc/1/cgroup'):
if "docker" in line:
@acaranta
acaranta / gist:e4fbfbbd25a9cd720ef0
Created September 10, 2014 10:07
get Terminal size in python 2.7
##Returns the terminal size WxH
#Found on http://stackoverflow.com/a/566752/2646228
def getTerminalSize():
import os
env = os.environ
def ioctl_GWINSZ(fd):
try:
import fcntl, termios, struct, os
cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ,
'1234'))
@acaranta
acaranta / gist:875ba285d4aa60c19141
Created September 11, 2014 09:28
Text Table ... nice display of data
import texttable
#create table
table = texttable.Texttable()
table.set_cols_align(["l", "l"])
table.set_cols_width(["12", "12"])
table.header(["Col 1", "Col 2"])
# Add Rows
table.add_row([vluevar, "hellow"])
@acaranta
acaranta / gist:771ff46d637819e83fae
Created September 16, 2014 17:01
simple pprint
import pprint
pp = pprint.PrettyPrinter(indent=4)
pp.pprint("<yourvar>")
#!/bin/bash
set -eu
shopt -s nullglob
readonly base_dir=/var/lib/docker/registry
readonly output_dir=$(mktemp -d -t trace-images-XXXX)
readonly jq=/usr/bin/jq
readonly repository_dir=$base_dir/repositories

Keybase proof

I hereby claim:

  • I am acaranta on github.
  • I am acaranta (https://keybase.io/acaranta) on keybase.
  • I have a public key whose fingerprint is 4E22 6615 9456 2A87 7DEE 9CD8 E2A2 C1E1 23E6 D257

To claim this, I am signing this object:

Verifying that +acaranta is my blockchain ID. https://onename.com/acaranta
### Keybase proof
I hereby claim:
* I am acaranta on github.
* I am acaranta (https://keybase.io/acaranta) on keybase.
* I have a public key ASANFLGfoPFTJz5jgYFGkHeyFJsCTAoIN8FKAxsngQ501Qo
To claim this, I am signing this object: