Git has a nice feature called bisect
that’s immensely useful for finding out where and when something broke.
For this example, we’ll use small integers for commit ids because they’re easier to reason about and orderly. In reality, they’ll be long SHA hashes.
Let’s say you have a commit history like this:
commit 12
Author: Joe
commit 11
Author: Scott
commit 10
Author: Scott
commit 9
Author: Scott
commit 8
Author: Miles
commit 7
Author: Joe
commit 6
Author: Dave
commit 5
Author: Bob
commit 4
Author: Joe
commit 3
Author: Dave
Pretend you’re Dave (your last commit was commit 6) and you do a git pull
and an ‘install-dev’ and see that the site’s busted, CSS all over the place, whatever. Git bisect to the rescue. First, tell git you’re ready to have it help you find the problem:
I found a fast way to add a new column to a table.
MySQL
-
Create the new table like the old table (
foo
), but with the new column you want in it. Make the new table with a different name (foo_new
): -
Add the records from the old table into the new table:
INSERT INTO foo_new (col1, col2, col3) SELECT col1, col2, col3 FROM foo
-
If you have a lot of records, you can disable index updates during insert:
I made these notes as a result of my experimentation with a Raspberry Pi. I kept messing up the software on the SD card and needed to start over, but it took a long time to go through all of the RPi setup steps. By copying the partitions, I was able to restore relatively quickly.
Get the info of each partition you want to copy on your SD card using diskutil
:
This little program uses currying to create a nested function reference that prints out a table with all possible permutations of the @states
array in as many columns as you like.
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
## Scott Wiersdorf
## Created: Sat Aug 18 14:29:03 MDT 2012
## permutation/truth table generator
my $inputs = shift @ARGV || 3; ## table columns
my @states = ('T', 'F', '-'); ## possible states
my $func = sub { say join "\t" => @_ };
for (1..$inputs) {
$func = loop_maker($func);
}
$func->();
exit;
sub loop_maker {
my $inner = shift;
return sub {
for my $state ( @states ) {
$inner->(@_, $state);
}
};
}
The output with an argument of ‘2’ looks like:
Some miscellaneous notes I may split out into separate posts later… don’t bookmark this one.
View open network connections on OS X
sudo lsof -lnP +M -i4
The options:
-l don't convert uids to login
-n dont' convert network numbers to to hostnames
-P don't convert port numbers to service names
+M enable portmapping
-i4 look for IPv4 connections
See also nettop
. 3rd party apps include Little Snitch and RubberNet.
I just spent about 3 hours trying to figure out why a Mojolicious daemon wasn’t permitting SSL connections. Here’s what I checked:
- the server was accessible (
iptables
, routing, etc.) - the port was accessible (I could set mojo’s
listen
tohttp://*:443
) and it would respond fine on my laptop - the entire
/usr/local
hierarchy,/etc
and/home/scott
were identical to my development environment (save the machine specific differences) and had the same permissions and ownership.
So basically at this point I narrowed it down to SSL. Something in the SSL setup wasn’t correct.
Here are a few notes I’ve made when using LaTeX:
Hyphens
For two literal hyphens, separate them with {}
, for example:
The \texttt{-{}-delete} flag should be set.
Underscores
Underscores are special; escape them if you want to use them literally:
Check the \texttt{authorized\_keys} file.
Working with Perl’s references can sometimes be confusing. This document illustrates several ways to efficiently take a slice of a hash reference.
Here is a hash reference and an array of keys called @order
:
my $row = { foo => 'bar',
baz => 'blech',
one => 'uno',
tres => 'three',
cuatro => 'four or so' };
my @order = qw(one tres cuatro baz foo);
Here is one way to get a list of values in the order of @order
:
Some notes about git
. As with all my technical posts, some or all of this may be out of date. Consider it, then, courage to believe that there may be a solution to your problem in terms you can understand.
I have a local repository I want to make into a remote repository
Here’s our local repository:
local $ git init .
local $ git add .
local $ git commit . -m "- initial commit"
Nice. Now make an empty repo on the remote server:
Some notes I kept when I was learning how to use yum
.
Installing a package that has been excluded
The file /etc/yum.conf
may contain an ’excludes’ line that will disallow updates of any of packages listed. To bypass this, you can comment out those packages in /etc/yum.conf
, or you can one-off it like this:
yum --disableexcludes all install gcc
Finding which repo has the file you need
yum provides '*apxs*'
You may need to add ‘–disableexcludes all’ too.