Posts

macOS get IP address at command line

Wireless: ipconfig getifaddr en0

Pit Barrel Cooker(PBC) tips

This is meant to be a short tips and tricks for working with a PBC. I'm assuming you have already followed the directions for lighting your PBC and are trying to troubleshoot some issues with temperatures. They don't discuss monitoring temperatures in their videos but it's something I started doing with my Weber kettle and I've continued that with my PBC. I'm glad I did because some of my early cook saw temperatures in my PBC spike to nearly 500 and temperatures settling in the upper 300s. I'd read about it running down in the 275-325 range and wanted to get mine to cool off a bit. I use Kingsford Professional which is not something they recommend but I prefer to use 100% natural charcoal and no lighter fluid as I spread the spent ashes on my yard to help my yard and reduce the amount of trash I create. If you really want to learn a LOT about cooking with a PBC, join The Pit over at Amazing Ribs and checkout the dedicated PBC forum . There is also a lot of g...

Install psycopg2 on a Greenplum system

If you try to install psycopg2 on a Greenplum system using pip you may run into this error: ... Error: pg_config executable not found.       Please add the directory containing pg_config to the PATH     or specify the full executable path with the option:         python setup.py build_ext --pg-config /path/to/pg_config build ...     or with the pg_config option in 'setup.cfg'. ... The solution is to add the path to the Greenplum bin directory to your environment PATH. export PATH=$PATH:/path/to/greenplum-db/bin/ Then run pip install psycopg2 and all should be good.

Google Fiber remote lag

The lag in my Google Fiber remote was driving me crazy. Figured out how to disable bluetooth & go back to IR only on the remote. Lag problem solved.

Show file in git at specific commit

I wanted to double check what a script looked like two commits ago. git log path/to/file Get the commit number from the version I want to see, get the first 4 to 6 characters. git show commit#:path/to/file Credit goes here

List of PIDs only

I wanted a list of pids only so I could run them through a while loop for processing. To get just a list of pids on Linux I used: ps --no-headers -o pid -C processname

Get filename without path, filename without extension, extension of filename in Bash

SOURCE Get filename without path basefilename=$(basename /full/path/to/file.txt) Get filename without extension filewoext="${basefilename%.*}" Get extension of file fileext="${basefilename##*.}"

Arrays in Bash

#!/usr/bin/env bash # Create the array myarray = () # Add items to the array # Add a sequence of numbers from 1 to 16 #for item in {0..16} cd ~/Documents/ # Add a list of files to the array # List all *.txt files in the ~/Documents directory and grab the three oldest # To grab the 3 most recent files use ls -rt. Order by time in reverse with most recent listed last for item in $( ls -t *.txt  | tail -3 ) do   myarray+ = (" ${item} ") done # Iterate over the array and print out items for item in ${myarray[ @ ]} do   printf " Item: ${item}\n " done # Print out the number of elements in the array printf " ${#myarray[ @ ]}\n "

Fedora 23 netinstall URL

Not sure why I found this so challenging, maybe because I haven't done a netinstall in ages. Anyway, finally figured out how to setup the Installation Source your selected mirror/path/to/installation/end with os/ So for me it was: http://fedora.mirrors.tds.net/fedora/releases/23/Server/x86_64/os/ Key was to end it with os/.

Move directory in one git repository to another repository

I've been looking for a way to move a directory in a git repository to a new repository and preserve the history. We are reorganizing some code at work so that's what prompted me to start looking. The scenario is I have a repository and structure that looks like the following: repoA/  file1  file2  file3  directory1/   file1a   file1b   file1c  directory2/   file2a   file2b I want to move directory1 and all of the files in that directory(file1a, file1b, file1c) to a new git repository and preserve the change history. I want to end up with the following: repoB/  directory1/   file1a   file1b   file1c The  solution is here . I started with  this solution  but with the second solution I ended up with the files from my directory1 in the root of the repo. By the time I moved the files into a new directory1 the change history was stored in the root directory of the new repo so if I was i...

Get PID from running process

pgrep -f processname(i.e. vim, emacs, postgres, etc.)

Too many files for ls

Using ls you receive the error that there are too many arguments: Example: find /path/to/files/ -name "*.ZIP" -exec basename {} \;

Get path to current script in Python

import os os . path . dirname ( os . path . realpath ( __file__ ))   Source

Python string formatting in print statements

#!/usr/bin/env python # Format using a dictionary print '%(language)s has %(number)03d quote types.' % { "language" : "Python" , "number" : 2 } # Format using a list print '%s has %03d quote types.' % ( "Python" , 2 ) # Best method print '{} has {} quote types.'.format ( "Python" , 2 ) Planning to post more code snippets this year to remind me of how to do various things in Python. Source: Pyformat

Use rsync to copy a directory structure

To copy the directory structure only without copying any files: rsync -a -f"+ */" -f"- *" source destination/ If you don't put the trailing / on source you'll get the source directory created in destination. If you put the trailing / after source, you'll get all of the subdirectories of source created in destination without the top source directory. Source

Getting a list of databases from PostgreSQL at the command line

psql -Alxt|grep 'Name'|cut -d '|' -f 2

VMware CentOS guest and bad terminal fonts

Gnome terminal fonts are all messed up on an initial install of CentOS 6. Install dejavu-sans-mono-fonts via yum to fix. Solution provided here

Python quick bits

Just random Python quick bits to jar my memory List mylist=['item1','item2','3'] Index starts at 0 for myitem in mylist:  code here methods: append() pop() extend() # append list of items ['item4','item5'] insert(position,"item6)remote("item2") Dictionary mydictionary={'tag1':'item1','tag2':'item2'} Reference items by keys for mykey in mydictionary.keys()  code here Object types in Python: int, dict, list, str Testing for object type:  isinstance(variable,type)  var1='foo'   isinstance(var1,str) User input from the command line:  import sys  variable=raw_input("Enter user question here: ") Length of list: len(list) Strings To work with strings: import string mystring.split() # default delimeter is spaces with multiple spaces treated as one for item in list:   do something with item for piece in string:   do somethign with piece Working ...

VMware Fusion CentOS guest console resolution

Edit /etc/grub.conf and add vga=791 or vga=788 option to the end of the kernel line for your relevant kernel. vga options here

Command line restart of dsmcad service on OS X

From here To start the client acceptor daemon use the following command: sudo /sbin/SystemStarter start dsmcad To restart the client acceptor daemon use the following command: sudo /sbin/SystemStarter restart dsmcad To stop the client acceptor daemon use the following command: sudo /sbin/SystemStarter stop dsmcad