Skip to content

Instantly share code, notes, and snippets.

View dcode's full-sized avatar
💭
Hack the 🌎!

Derek Ditch dcode

💭
Hack the 🌎!
View GitHub Profile
@dcode
dcode / reset_root_pw_el7.md
Created February 25, 2016 17:43
How to reset root password on EL7 hosts.

The official training for RHSCA 7 describes the “change root password” procedure as below:

Append “rd.break” to the kernel command line that starts with linux16 (this will break just before control is handed from the initramfs to the actual system) (sometimes it is needed to delete also everything after “…mapper/rhel-root ro” and append here)

mount -o remount,rw /sysroot
chroot /sysroot
passwd
touch /.autorelabel
exit
@dcode
dcode / archive_and_compress_current_dir.sh
Last active February 29, 2016 17:02
I use this to archive an entire directory (by subdirectory) and compress with 7zip. I run this occasionally on my "projects" dir to cleanup old space.
#!/bin/bash
for item in $(find . -type d -depth 1 | grep -Ev 'dir|names|toexclude'); do
tar cvf - ${item} | 7za a -si ${item}.tar.7z;
rm -rf ${item};
done
@dcode
dcode / kafka.service
Created March 3, 2016 01:39
Service files for kafka and zookeeper
[Unit]
Description=Kafka distributed logging server
Requires=zookeeper.service
After=zookeeper.service
[Service]
User=kafka
Group=kafka
SyslogIdentifier=kafka
Environment="KAFKA_LOG4J_OPTS=-Dlog4j.configuration=file:/opt/kafka/config/log4j.properties"
@dcode
dcode / gist:95ddfa916ded1c57baa856dc526a290e
Last active July 1, 2016 02:18
Customize gnome-terminal and bash for Solarized Dark
# Set dircolors for bash `ls` friendly for a dark solarized terminal
curl -o ~/.dircolors -L https://raw.github.com/seebi/dircolors-solarized/master/dircolors.ansi-dark
eval `dircolors ~/.dircolors`
# Checkout gnome-terminal solarized config
cd /tmp
git clone https://github.com/Anthony25/gnome-terminal-colors-solarized.git
cd gnome-terminal-colors-solarized
./set_dark.sh
cd /tmp; rm -rf gnome-terminal-colors-solarized
@dcode
dcode / purge_openstack_net_infra.sh
Created May 19, 2016 20:48
Uses the openstack client tools/API to enumerate and purge all router, subnet, and network objects. Not sure well this works when VMs are running
### Purge all networks & routers
# Clear all gateways
neutron router-list -f value | \
awk '{ print $1 }' | \
xargs -n1 neutron router-gateway-clear
# Delete all router ports
neutron router-list -f value | \
@dcode
dcode / http_gauss_browse.py
Last active June 1, 2016 14:07
Takes in a list of CSV ordered by (rank,domain) (from Alexa, for instance) and browses the highest ranking more often.
#!/usr/bin/env python2
from multiprocessing import Pool
from time import sleep
from random import randint, gauss
import os, sys
import requests
## TODO
# . recursively download linked resources:
# . images
@dcode
dcode / defeat_itunes.md
Last active June 23, 2016 05:43
I _HATE_ iTunes opening up at random just to say "Heeellooooo". I've taken matters into my own hands. Eat it, Apple.
$ cd /Applications/iTunes.app/Contents/MacOS
$ sudo chmod -x iTunes iTunesASUHelper
$ ls -lhdO iTunes iTunesASUHelper
-rw-r--r--  1 root  wheel  compressed   30M Jun  2 14:39 iTunes
-rw-r--r--  1 root  wheel  compressed   18K Jun  2 14:39 iTunesASUHelper
$ sudo chflags schg,uchg iTunes iTunesASUHelper
$ sudo chmod +x iTunes
chmod: Unable to change file mode on iTunes: Operation not permitted
$ ls -lhdO iTunes iTunesASUHelper
@dcode
dcode / set_proxy.sh
Created July 12, 2016 17:06
Sets environment variables to use curl and other command line utilities w/ a proxy.
# /usr/local/bin/set_proxy.sh
# Sets proxy env vars.
# To use, source this into your shell:
#
# . /usr/local/bin/set_proxy.sh
PROXY_HOST=my-company-proxy.example.com
PROXY_PORT=3128
read -p "Enter your username: " PROXY_USER
@dcode
dcode / install_katello_3.0_on_centos7.sh
Last active July 15, 2016 20:23
Steps to install katello 3.0 on CentOS 7.x
yum -y localinstall http://fedorapeople.org/groups/katello/releases/yum/3.0/katello/el7/x86_64/katello-repos-latest.rpm
yum -y localinstall http://yum.theforeman.org/releases/1.11/el7/x86_64/foreman-release.rpm
yum -y localinstall http://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm
yum -y localinstall http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install foreman-release-scl sclo-ror42 centos-release-scl
yum -y install katello
[local]
name=Locally built packages
baseurl=file:///vagrant/repo/all
gpgcheck=0
enabled=1