macOS hostname config

macOS has no /etc/hostname, instead you have to use scutil (“Manage system configuration parameters”) to (permanently) change your hostname. There are three “preferences” settable via scutil (using descriptions from the man page): ComputerName: The user-friendly name for the system. LocalHostName: The local (Bonjour) host name. HostName: The name associated with hostname(1) and gethostname(3). ComputerName isn’t super interesting; I’m not sure where it comes up. It’s got whitespace and special characters, and by default looks something … continued

Cleaning AWS Marketplace AMIs

Running (e.g.) CentOS 7 on unapproved hardware The official CentOS 7 marketplace AMI incurs no extra fees and usually works just fine, but due to its product code and the associated marketplace metadata, AWS prohibits launching instance types not listed on that page. At the time of posting, it appears that all AWS instance types are approved for use with the current CentOS 7 AMI, but when I originally developed these instructions, the CentOS 7 … continued

New make

GNU Make is a fabulous, underrated tool. I use it a lot for documenting my data organization — sort of as a lab notebook. Even if I keep all the derived files in source control, it’s a handy way to keep track of where they came from, because shell history is relatively ephemeral (I wish it were less so, but that’s a topic for another day, and not the proper solution to documenting data provenance … continued

Vagrant

Vagrant quickstart reference: vagrant init → create Vagrantfile file in current directory. vagrant up → start up virtual box based on config from Vagrantfile in current directory or the nearest parent directory containing a Vagrantfile. vagrant destroy → shuts down the virtual box that was started with vagrant up. vagrant ssh → ssh into the box configured by the local Vagrantfile. vagrant reload --provision → stop the machine, rerun the provisioning script, and restart it. … continued

CSS resets, normalizations, opinions

CSS resets are, in general, a bad idea. They are designed to ensure that your page looks the same to absolutely everyone on every browser, but that’s very often overkill. For example, here is YUI’s reset.css (14 rules). It’s like saying to most of HTML, “I don’t need you or want you.” CSS normalizers are better. They try to bring all browsers to a baseline. For example, here is Necolas’s normalize.css (40 rules). It’s less … continued

Newline-delimited JSON

There are a couple of opinions on line-delimited JSON. There’s even an officious but totally [needs citation] Wikipedia article. Pretty much everybody agrees on how it’s done (the only difference there is LF vs. CR vs. CRLF), but not what to call it. Tools like jq handle this format already, by default, and it makes a lot of sense for most streaming purposes. Anyway, the main dispute is what MIME Type to use. Here are … continued

Canonical spelling reference

When case is sensitive, it’s useful to get it right. GitHub CrowdFlower Elasticsearch PostgreSQL MySQL DigitalOcean

Parsing

Basics of simple parsing. LR: left-to-right, rightmost derivation LL: left-to-right, leftmost derivation LALR: look-ahead left-to-right, rightmost derivation

Cleaning up macOS bloat

Freeing up disk space on macOS, particularly caches that usually never get purged. Development packaging caches Ruby ~/.gem contains gem-installed package information for each version of Ruby rm -rf ~/.gem Python ~/Library/Caches/pip contains packages cached by pip ~/Library/Caches/pipenv contains packages cached by pipenv Java ~/.m2/repository contains Java packages (.jar files) and Maven project information (.pom files) for dependencies installed by Maven or related package managers, such as Leiningen: rm -rf ~/.m2/repository/ Note that ~/.m2/settings.xml contains … continued

GitHub Pages

GitHub pages are great, but they will only serve files from a branch in your git repository named gh-pages. (I wish there was at least an option to say “Serve GitHub Pages from: [x] Master [ ] gh-pages”, but the last time I wished for something from GitHub they laughed in my face. For now I will be content that they don’t require using Jekyll to render your gh-pages.) Easy fix, though: s/master/gh-pages/. Git translation … continued

No substitute for taking lots of actions

Another great Quora questions: What are some lessons learned through playing StarCraft that are useful in real life? The highlight from Charlie Cheever’s answer: There’s no substitute for taking a lot of actions. The rest of his answer has many more gems.

ls output

ls results setuid bit. Denoted by s (directories) or S (files) in the permissions block of ls results, it only applies to executable files — it just specifies which user (u+s) / group (ug+g) the process should run as when executed. To clear this bit, simply run chmod -s yourfile.txt. sticky bit. Denoted by t or T (not s/S, due to setuid’s precedence), it’s usually used on directories to control a hierarchy of permissions. E.g., … continued

Sublime Text 2 - Spell Check

Want to default spell checking on in say, LaTeX files, but not other languages? Open a .tex document (to set the active syntax) Go to Preferences → Settings - More → Syntax Specific - User. Add this to the LaTeX.sublime-settings file that comes up (probably empty): {“spell_check”: true} Save. Reopen your .tex file.

Research Readability

Overheard in the [email protected] mailing list, which usually keeps it pretty technical, but I thought this was a nice comment: A poster’s paraphrase of a snippet from a lecture by Richard Hamming: When you’re beginning a research project, the first thing you should do is to draft the first page of the report in which you present the final results. Then ask yourself: “If I saw that paper in a journal with somebody else’s name … continued

Poverty (and abuse) of the commons

I really like Go’s full specification of dependencies (e.g., import ("github.com/golang-crypto/ssh")), but I fear linkrot, backward incompatibility, and visibility. Also, hard-coding access protocols to handle github.com, bitbucket.org, and code.google.com may be practical, but that doesn’t feel like the right solution. A central repository can offer archives, consistency, reliability, searchability, and popularity rankings. I prefer npm to Go’s distributed “package manager”, because I can search npm directly, and it’s not too hard to extend on the … continued

Node.js XML libraries

sax-js: This is @izs’s pure javascript parser. I don’t really like the weird mixture of trying to accommodate Node.js streams, function events, and traditional event listeners, the strange error handling and pausing, but it’s solid if you can work around those quirks. Many of the other pure JS XML libraries are layers on top of this. node-xml2js: Converts XML into plain JS objects. Doesn’t abide by any of the XML conversion conventions, but has several … continued

What are some things that cops know, but most people don't?

Cross-post of a fantastic Quora answer by a guy named Tim Fry. What are some things that cops know, but most people don’t? That unless you broke the law, you probably have the right to just walk away (and you probably should). I teach my kids and their friends that if a cop walks up to them and starts asking them questions, the only thing that should be coming out of their mouth is, “Am … continued

SSH Tunneling

ssh CLI flags: -N Do nothing (except connect) -f Fork to Background -q Suppress any output -v Verbose -p Specify port (defaults to 22) command effect ssh -D 5090 dark -N Start Socks proxy to dark on :5090 ssh dark -L 18053:localhost:8053 -N Tunnel from outgoing :18053 to dark’s outgoing :8053, and fork to bg ssh -q -o 'StrictHostKeyChecking no' jude exit Unquestioningly add jude’s host key to ~/.ssh/known_hosts and then quit ssh-copy-id -i local.id_rsa.pub … continued

Default locations

Firefox GreaseMonkey: cd ~/Library/'Application Support'/Firefox/Profiles/*/gm_scripts

Chrome extensions

How to add third-party extensions to Chrome, like from www.chromeextensions.org. $ open ~/Library/Preferences/com.google.Chrome.plist Add a Key at the root level called "ExtensionInstallSources", as an Array type. Expand its triangle and click the + button. Add "http://www.chromeextensions.org/*" to the list Then simply restart Chrome!

Nunberg simile

I just thought this quote from Geoff Nunberg was fun: It’s like hearing someone warn of grave domestic security threats and then learning that he’s mostly concerned about Canadian sturgeon-poaching on the US side of Lake Huron.

K-means++

So K-Means++ is just K-means, except instead of choosing initial centroids at random, you choose centroids that are furthest away from other centroids (sort of), iteratively. It’s a good idea, but it gets its own name, wikipedia page, etc.?

Tr

tr is a hard-to-search-for command, but very useful. Convert tsv to csv: cat names.tsv | tr '\t' ','

Flickr misplacement

I don’t know who this is, or what they’re referring to. http://www.flickr.com/photos/white_ribbons/5902656773/ But I kind of like the idea that this person is terminally ill. In that case, the way they are confronting their imminent demise is totally unrealistic.

$ ls sum

Sum everything that matches *.json: ls -l * | awk '{sum += $5}; END {print sum}'

Android

Just got an Android phone, HTC Evo V. It is a pile of frustrations. Did anybody actually design this thing? Anybody who actually maybe watched some people try to use it? I doubt it. I think it’s partly the shitty phone. But this Icecream Sandwich or whatever it’s called OS is really awful. Unintuitive, violating nearly every UX standard I’ve never really thought about before because these problems just don’t come up in iOS. And … continued

Javascript semicolons

Apparently (says mislav), semicolons are totally unnecessary except for one case: “When a line starts with parenthesis, prepend a semicolon” Mislav makes a lot of cool stuff, like magic Rails pagination, but also Zepto.js, which is a brilliant idea, but on my last try, leaked memory like crazy (in a situation where the same operation in jQuery was fine—I forget exactly what caused it, but it had to do with removing and adding DOM elements, … continued

Maxine

I’m on this listserve thing called “The Listserve” where it’s like 20K people and each day one person wins the listserve lottery and gets to email all the others. I haven’t won the lottery yet. I hope I will someday. Apparently you get 48 hours notice. Most of them are dull. Self-advertisement, give-me-a-job, that sort of thing. A good use for the listserve, not a good use of my time. But I really liked a … continued

Girls and Their Hair

Just launched my photography website: GirlsAndTheirHair.com My given name + last name + “photography” is dreadfully saturated on Google: www.google.com/search?q=Christopher+Brown+Photography So, I decided it should be about subject matter, not “me,” because the subject matter I choose is just as much my photographic identity as I am.

Monitoring

There’s a door here in Harpa that has a doorbell, one of those velcro wireless things. At least, that’s what it looks like. I think it’d be fun to move it down the hall a ways, and without their plethora of cameras, they’d probably never know. There is no way a wireless transmitter like that can know that its base is being moved, or goes out of reach. In a satellite system like that, the … continued

Postfix virtual everything

So I’m trying to get postfix to keep everything it gets sent and just store it in a file/database, whatever, for later processing. This falls under the category of not destined for existing user accounts, which means that neither the normal method of sending (directly to a Linux user account), or virtual aliasing (to a Linux user account) of a different name really work. I guess I could virtual alias everything to some user account, … continued

Usermod

I look this up probably once every two months: # Add the existing user "chbrown" to the existing group "sudo" usermod -a -G sudo chbrown

Git on CentOS

So CentOS is old and decrepit but if you have to use it and need git, here you go: sudo rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm sudo yum -y install --enablerepo=webtatic git And while you’re at it: sudo yum -y install vim-common vim-minimal

Mountain Lion DYLD_LIBRARY_PATH

Mountain Lion always complains whenever I use any sort of system executable, ps or sudo or whatever: dyld: DYLD_ environment variables being ignored because main executable (/bin/ps) is setuid or setgid I don’t have any DYLD_* variables visible running either env or set. What OS X ML means to say is, I don’t like your LD_LIBRARY_PATH env variable. And I do set LD_LIBRARY_PATH in my .bashrc file. I don’t remember why it’s in there, so … continued

Quora age envy

Interesting snippet from a Quora question on envy, by a guy Matthew Manning: You have ZERO idea what their personal lives are actually like, or if their outward appearance of success is total bullshit. Stop focusing outward, focus inward. A preoccupation with the success of others is taking time away from tending your own internal garden. Believing in common measures of success (money, position, family) is believing in a ready-made lunch box of meaning that … continued