Skip to content

Instantly share code, notes, and snippets.

View jay-johnson's full-sized avatar

Jay jay-johnson

View GitHub Profile
@jay-johnson
jay-johnson / Restart Docker Engine
Created July 15, 2016 06:18
Restart Docker Engine
sudo service docker restart
@jay-johnson
jay-johnson / iterm2-profile.json
Last active October 7, 2018 15:15
iterm2 profile
{
"Use Non-ASCII Font" : false,
"Tags" : [
],
"Ansi 12 Color" : {
"Red Component" : 0,
"Color Space" : "sRGB",
"Blue Component" : 0.985260009765625,
"Alpha Component" : 1,
@jay-johnson
jay-johnson / .vimrc
Created September 22, 2018 20:59
vimrc file for python
"2016-11-10 v1 - start"
" set tabstop=4
" set shiftwidth=4
" set smartindent
" set pastetoggle=<F10>
"2016-11-10 v1 - end"
"2016-11-10 v2 - start"
set pastetoggle=<F10>
set autoindent " always set autoindenting on"
@jay-johnson
jay-johnson / vim-prepare.sh
Last active September 22, 2018 20:39
vim prepare steps with vundle and you complete me
#!/bin/bash
on_darwin=$(uname -s | grep -i darwin | wc -l)
test_brew_exists=$(which brew | wc -l)
if [[ "${test_brew_exists}" != "0" ]]; then
brew install cmake
fi
mkdir ~/.vim
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
@jay-johnson
jay-johnson / ip_vs.conf
Last active September 2, 2018 20:21
kube-proxy kernel modules for kubernetes on Centos 7 - add these lines to /etc/modules-load.d/ip_vs.conf - testing proposed values from https://github.com/kubernetes/kubernetes/issues/60869 with docs https://github.com/kubernetes/kubernetes/tree/master/pkg/proxy/ipvs#run-kube-proxy-in-ipvs-mode
ip_vs
ip_vs_rr
ip_vs_wrr
ip_vs_sh
nf_conntrack_ipv4
@jay-johnson
jay-johnson / start-vm.sh
Last active September 2, 2018 19:49
KVM - virt-install to start a vm - with cpu + memory + bridge network settings - and commented out how to seed a file to the vm on startup
virt-install \
–-name master1 \
–-vcpus 2 \
–-ram 1024 \
–-network bridge=br0 \
# –-connect qemu:///system \
# –-disk pool=master1,size=20,bus=virtio,sparse=false \
# -–location http://us.archive.ubuntu.com/ubuntu/dists/trusty/main/installer-amd64/ \
# -–initrd-inject=preseeds/preseed.cfg \
# -–extra-args="locale=en_US.UTF-8 console-setup/ask_detect=false keyboard-configuration/layoutcode=us file=file:/preseed.cfg vga=788 quiet console=tty0 utf8 console=ttyS0,115200" \
@jay-johnson
jay-johnson / Python 2 vs Python 3 - Understanding Unicode Strings.md
Last active July 26, 2018 03:20
Python 2 vs Python 3 - Understanding Unicode Strings

Porting to Python 3 - git diff

Here's an example of porting changes when trying to deal with binary strings which are nothing more than serialized dictionaries (response.rendered_content). In python 2 json.loads(response.rendered_content) works just fine, but in python 3 I had to add .decode("utf-8"):

         # save to log
         try:
-            self.request.log.response = json.loads(response.rendered_content)
+            self.request.log.response = response.rendered_content.decode("utf-8")
         except Exception as w:
@jay-johnson
jay-johnson / splunk_send_json_fields_over_tcp.py
Last active July 4, 2018 03:33
Send Logs with JSON Fields to Splunk over TCP with sourcetype set to _json
#!/usr/bin/env python
import os
import sys
import json
import socket
import datetime
import time
@jay-johnson
jay-johnson / convert_to_numeric_csv.py
Created July 2, 2018 21:33
Pandas - convert a csv to categorical numeric values
#!/usr/bin/env python
import pandas as pd
cur_file = './test.csv'
df = pd.read_csv(cur_file)
org_cols = df.columns.values
cols = {}
for c in org_cols:
print('categorizing column: {}'.format(c))
@jay-johnson
jay-johnson / Installing OCP with Virtual Box.md
Last active June 25, 2018 04:12
Installing OCP with Virtual Box
imagetouse=/home/jay/Documents/ocp-3.9.ova
vmname=ocp
nicname=enp7s0

vboxmanage controlvm ${vmname} poweroff
vboxmanage unregistervm ${vmname} --delete
vboxmanage import ${imagetouse} --options keepallmacs --vsys 0 --cpus 4 --vsys 0 --memory 16000 --vmname ${vmname}
vboxmanage modifyvm ${vmname} --nic1 nat
vboxmanage modifyvm ${vmname} --nic1 bridged --bridgeadapter1 ${nicname}