Skip to content

Instantly share code, notes, and snippets.

View buckbaskin's full-sized avatar
:octocat:
C++ 👨‍💻 and Python 🎉

Buck Baskin buckbaskin

:octocat:
C++ 👨‍💻 and Python 🎉
  • East of the Pacific
View GitHub Profile
@buckbaskin
buckbaskin / music_traverse.py
Created April 18, 2017 17:37
A Python script that traverses an organized iTunes Music directory and enumerates the artists and albums in the library.
import os
def traverse():
artists = None
for dirpath, dnames, fnames in os.walk("./Music/"):
if artists is None and len(dnames) > 0:
artists = {el:[] for el in dnames}
elif len(dnames) > 0:
head, tail = os.path.split(dirpath)
if tail not in artists:
@buckbaskin
buckbaskin / ssh-agent-forwarding-screen.md
Created February 26, 2017 22:29 — forked from martijnvermaat/ssh-agent-forwarding-screen.md
SSH agent forwarding and screen

SSH agent forwarding and screen

When connecting to a remote server via SSH it is often convenient to use SSH agent forwarding so that you don't need a separate keypair on that server for connecting to further servers.

This is enabled by adding the

ForwardAgent yes

option to any of your Host entries in ~/.ssh/config (or alternatively with the -A option). Don't set this option in a wildcard Host * section since any user on the remote server that can bypass file permissions can now als use keys loaded in your SSH agent. So only use this with hosts you trust.

@buckbaskin
buckbaskin / example_postgres.py
Created November 1, 2016 23:08
A simple example of using Postgres in Python
import psycopg2
# make a connection
try:
conn = psycopg2.connect(database='postgres', user='postgres', password='economicalchinchillacorndog', host='localhost')
cur = conn.cursor()
except:
print('Database Connection Failed')
raise
@buckbaskin
buckbaskin / Module_level_decorator.py
Created May 18, 2016 22:24
A simple decorator function that applies itself to all elements in a module. The example is modifying the math module to print a string for every function call.
def module_wrapper(module):
def print_wrap(subfunc):
def internal_func(*args, **kwargs):
print("I'm going to run this function")
return subfunc(*args, **kwargs)
return internal_func
for func_name in dir(module):
setattr(module, func_name, print_wrap(getattr(module, func_name)))
From 7e9c381043c9c33d594b66fad853bf69df044769 Mon Sep 17 00:00:00 2001
From: Paul Mathieu <pmathieu@willowgarage.com>
Date: Tue, 12 Mar 2013 13:28:23 -0700
Subject: [PATCH] fixed arm build
---
src/collada_urdf.cpp | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/collada_urdf.cpp b/src/collada_urdf.cpp
@buckbaskin
buckbaskin / odom_trace.py
Created January 5, 2016 03:34
Create a ros node for storing, replaying a robot's position
#!/usr/bin/env python
'''
Copyright 2016 William Baskin
/*****************************************
LICENSE SUMMARY
This package is licensed under the
MIT License. Please see the LICENSE.md
@buckbaskin
buckbaskin / preprocessor_fun.h
Last active August 29, 2015 14:26 — forked from aras-p/preprocessor_fun.h
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,