Git: Find the branch that a given commit landed on

If you need to find the branch that a commit was checked in to use the following command:

git branch --contains 26495cfd4ab17d4d685d0d352ed333f73d6d1b96

This should show a list of branches, with the respective branched highlighted and preceed with an asterisk.

Leave A Reply

Git: Finding all commits that match a given line

If you need to show all the commits that modify a specific line you can use git log and the -G flag like this:

git log -G "version" docs/release_history.txt

This will show every commit that contains "version" in one of the modified lines anywhere the file /docs/release_history.txt

Leave A Reply

Chess notation sheet

This my favorite Chess notation sheet in PDF format.

Leave A Reply

Things we know about Benjels

https://www.youtube.com/watch?v=gdwchohlMjI

Things we know about Benjels:

  1. He's over there making the worst calls
  2. He's one of the players
  3. He's one of the coaches in the division
  4. If he passes through the series, then he'll be a hall of famer
  5. He's in charge
  6. He's not even at 480 yet
Leave A Reply

Tar: Auto detecting the compression type

The Linux tar command has a cool feature to auto-detect the file compression based on the archive suffix.

-a, --auto-compress

use archive suffix to determine the compression program

This allows you to change file compressions by just changing the archive suffix:

tar -cvpaf /tmp/backup.tar.gz ~/
tar -cvpaf /tmp/backup.tar.bz2 ~/
tar -cvpaf /tmp/backup.tar.xz ~/

This saves you having to specify -z -j or -J respectively.

Leave A Reply

Disabling an ethernet port via SNMP

Interacting with ethernet ports on an SNMP device is done primarily with two sections of the SNMP tree. IF-MIB::ifOperStatus is the current layer 1 status of the port (i.e. is the port linked or not) and IF-MIB::ifAdminStatus is whether the port is administratively shutdown.

If you want to shutdown an ethernet port on an SNMP enabled device you need to set IF-MIB::ifAdminStatus to integer 2 (down), and conversely setting it to integer 1 (up) will enable the port again.

snmpset -v 2c -c community 192.168.5.1 IF-MIB::ifAdminStatus.5 i 2
Leave A Reply

Books of 2017

List of books I read in 2017. Also see the list of 2016. The date indicated denotes the date I started reading the book.

2017-01-05 - American Gods - 592 pages
2017-01-14 - Different Seasons - 527 pages
2017-01-25 - The Three-Body Problem - 399 pages
2017-01-30 - Wolverine: Days of Future Past - 3 Comics
2017-01-31 - Rogue One: A Star Wars Story - 319 pages
2017-02-04 - Heroes Anonymous - 6 Comics
2017-02-06 - Funny Girl - 452 pages
2017-02-08 - Wolverine: Xisle - 5 Comics
2017-02-09 - All Star Superman - 12 Comics
2017-02-10 - Old Man Logan - 7 Comics
2017-02-11 - X-Men: Days of Future Past - 184 pages
2017-02-11 - Ultimate Iron Man - 5 Comics
2017-02-13 - Heaven Cent - 324 pages
2017-02-13 - Ultimate Wolverine vs. Hulk - 6 Comics
2017-02-19 - Pet Sematary - 374 pages
2017-02-19 - Marvel 1602 - 8 Comics
2017-02-28 - NOS4A2 - 692 pages
2017-03-13 - The Fifth Season - 468 pages
2017-03-17 - Infinity Gauntlet - 6 Comics
2017-03-22 - Bazaar of Bad Dreams - 495 pages
2017-03-28 - Wolverine & The X-Men - 43 Comics
2017-04-01 - The Obelisk Gate - 391 pages
2017-04-08 - Carrie - 199 pages
2017-04-12 - To Kill a Mockingbird - 323 pages
2017-04-19 - Homo Deus - 402 pages
2017-04-23 - Wolverine: Three Months To Die - Book One - 7 Comics
2017-04-26 - The Alchemists of Loom - 382 pages

Leave A Reply

Linux: Fedora 25 major package versions

Fedora 25 has these versions of some core packages:

Package Version
Apache 2.4.23
GCC 6.2.1
Kernel 4.8.6
Perl 5.24.0
PHP 7.0.12
Vim 7.4.1989
Leave A Reply

Speed of various computer components

A CPU cycle can be a quarter of a nanosecond.
A read from RAM is about 60 nanoseconds.
A read from a relatively fast modern SSD is 20 microseconds (20,000 nanoseconds).
A read from a slow disk is 10 milliseconds (10,000,000 nanoseconds).

Borrowed and summarized from Leah Hanson

Leave A Reply

Cisco: Monitor temperature via SNMP

I need to monitor the temperature of some Cisco equipment via SNMP. Using this guide as a reference I was able configure Nagios to monitor the ambient (inlet) temperature in our data center.

First you'll need to find the sensor's ID number based on the description here:

snmpwalk -v 2c -On -c public router.domain.com .1.3.6.1.2.1.47.1.1.1.1.2

You should get a long list of various parts of your router. The last section of the OID is the ID of that particular sensor. Usually they are in the thousands. After that you look at another section of the SNMP tree to gather the actual temperature:

snmpget -v 2c -On -c public router.domain.com .1.3.6.1.4.1.9.9.91.1.1.1.1.4.XXXX

or view all of the sensors:

snmpwalk -v 2c -On -c public router.domain.com .1.3.6.1.4.1.9.9.91.1.1.1.1.4
Leave A Reply

Linux: Remote desktop client

For a long time I have used rdesktop on Linux to connect to remote Windows boxes. Redhat is deprecating rdesktop because it does not the support modern encryption technologies that Window uses. Instead they are recommending that users switch to xfreerdp. Here is the syntax you'll need to use to connect to a remote Windows server:

xfreerdp /u:Administrator /v:10.1.8.93
Leave A Reply

Linux: Build a base VM image

When a new version of a distro comes out I like to build a base VM image that I can use later to turn up new VMs quicker. Here are the steps I use on a CentOS or Fedora VM image:

  1. Install minimal system via GUI
  2. Install default packages
  3. Setup Vim config
  4. Disable/remove SELinux
  5. Setup default bash prompt
  6. Remove SSH keys
    1. rm /etc/ssh/*key*
    2. New keys will be generated on boot
  7. Set generic hostname
  8. Remove mac address line from network config
  9. Remove chrony
  10. Install/enable NTP
  11. Set grub default boot time to two seconds
  12. Disable Firewalld
  13. Enable iptables
  14. Shutdown VM and archive the disk image
Leave A Reply

Linux: write a network image to an SD card

If you have a fast network connection you can read an ISO directly from the Internet and write to a flash drive, or SD card. Just pipe curl to dd (requires root) and you're done.

curl ftp://mirror.web-ster.com/centos/7.2.1511/isos/x86_64/CentOS-7-x86_64-NetInstall-1511.iso | sudo dd of=/dev/sde bs=1M
Leave A Reply

RSYSLOG: Check the configuration

If you want to verify the syntax of your rsyslog configuration before you restart the process use the following command.

rsyslogd -N1

You will get some textual output as well an appropriate exit code.

Leave A Reply

OpenSSL: Generate self-signed certificates

OpenSSL can generate self-signed SSL certificates easily. Just run the following command:

openssl req -x509 -nodes -sha256 -days 3650 -newkey rsa:2048 -keyout domain.key -out domain.crt
Leave A Reply