How to figure out what processes are using IO on MacOS / debugging mysterious performance problems
This blog post is a loose documentation of some problems I've had with my mac lately and how I maybe diagnosed them, for my own documentation and maybe some of it will prove useful to people who find it when searching.
Lately I've been having mysterious problems on and off with my Mac laptop. Sometimes it almost seems like a . . .
The New S3 is Magic!
I recently tweeted
in between seasons, Star Trek writers freelance as persistence system marketers
And it blew up and created wild controversy across the internet (not really, it got zero likes).
What I mean by this is "no impact" is doing a lot of . . .
How to have xargs use its input in an arbitrary invocation
Here's a common pedestrian use of xargs:
ls *.rb | xargs echo
What this does is invoke echo
on a big list of all the files found by ls *.rb
But let's say you want to use the output of ls *.rb
in a more complicated way? You don't want the entire list to just be tacked onto the end of whatever command you give . . .
How to use xargs to invoke an executable once for each argument
You might have used xargs before like this:
ls *.rb | xargs echo
This will invoke echo
once, with all the files passed in.
But what if you want to invoke echo
one time for each file? The answer is very easy and not very clearly described in the docs. From man xargs
-n number
Set the maximum number . . .
How to show the current TotalSpaces space name in the menu bar
TotalSpaces is great! One flaw is you can't put the name of the current space in the menu bar. Only the number. Here's a workaround, possible because it has an API!
- Install the ruby gem
sudo gem install totalspaces2
- Install TextBar
- Set up a TextBar menu item
ruby -r'totalspaces2' -e . . .
Is there a name for this code design principle?
It's the #1 thing I want to convince my coworkers of
Bad
class Animal
initialize(type)
@type = type
end
def bark
return unless 'dog' == @type
puts "woof!"
end
def meow
return unless 'cat' == @type
puts "meow."
end
end
Good
class Dog
def bark
puts "woof!"
end . . .
Linux flock does not provide fair locking
The problem I’m trying to solve: 1 machine with X amount of ram. I have to run N tasks on it, each of which take more than X/N memory. So, they can’t run at the same time. Luckily, the time they run is not particularlyimportant, as long as they run regularly.
Via a suggestion from the whenever gem for ruby, I discovered linux lock. . . .