Saturday, September 19, 2015

Setting up ssh keys

UPDATE (15/09/2024):  Just found an even cleaner shell command on Ubuntu Documentation:

By default, the public key is saved in the file ~/.ssh/id_rsa.pub, while ~/.ssh/id_rsa is the private key. Now copy the id_rsa.pub file to the remote host and append it to ~/.ssh/authorized_keys by running:

ssh-copy-id username@remotehost

I keep forgetting this quick one-liner, so I thought I'd add it to my list of useful tricks.  I usually just Google it, but How-To Geek is an awesome resource (link)

ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub | ssh user@hostname 'cat >> .ssh/authorized_keys'


Thursday, April 9, 2015

Python Debugging Notes

So I had a great stackexchange comment that I referred left open in my Chromium tab forever, and I just realized that I lost it somehow.  I've searched my history and everything, it's gone in the many clicks of reddit, barstoolsports, etc.  So this is just going to be my ongoing blog post for debugging notes as I come across them as I need them.  So here goes:

Scipy Lecture on Debugging

Boltons

Starting Debugging on Error Discussion

Python Cookbook Discussion

The comment I lost, was someone explaining their process of navigating the Traceback using the commands:
list
up
down
Sorry, I can't find the comment so that I can cite his help.

This blog is an ongoing note for my own reference, so expect it to be updated here and there.

EDIT: And now I found the stackexchange comment, here:
http://stackoverflow.com/questions/16131500/py2app-error-in-find-needed-modules-typeerror-nonetype-object-has-no-attribu

Sunday, March 29, 2015

Remove all old linux kernels, headers and modules for Debian based systems

This has come up often for me with my linux machines, so I'll just blog a blog on the topic.  I came across two useful posts:

RemoveOldKernels

Ubuntu Cleanup: How to Remove All Unused Linux Kernel Headers, Images and Modules

The former is useful, but it only removes the kernels.  I want to remove all headers, etc. associated with them.  So, before I run the command from the latter blog post, I just want to confirm what I'm going to remove, as should you, with the following code (note, not as root just to be even more cautious):
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'
 Perfect, now I can just run the one-liner from that latter blog post:

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge

Boom, I just got rid of over 3 GB's of old linux kernels on my system.

Monday, March 16, 2015

Python String Format Cookbook

As I'm tutoring someone through their introductory Computer Science course, I keep finding myself getting caught up in the Python 3 string formatting.  His assignments seem to focus a lot on how to print out various formats, and I'm still stuck in handling how they worked in Python 2.7.  I keep googling, and googling, and I often just find myself coming back to this reference.

Python String Format Cookbook

I'm just putting this up so that I can keep going back to this reference as I still adjust from Python 2 to Python 3.

EDIT: Just saw this cool writeup on Reddit: PyFormat.info