adventures in tmux

i know. I KNOW. Varsity right? I can’t take credit, well I sorta can. I was crazy excited after accidentally hitting command+D and splitting the pane, not realizing it only duplicated. This led Max to suggest I go discover the multiplexing god that is tmux.

But like most things I’m finding, most of the forums and wikis and tutorials assume a certain level of knowledge and fail to mention the EXTREMELY IMPORTANT basics.

What i was trying to do- uhm. split a pane. the, like, FIRST thing you should be able to do.

The problem- The prefix (as i learned later it was called) CTL+B and the ” key weren’t working.

The solution- the plus symbols means “at the same time” while the <“> means directly following it.

So yeah, while ALT+SHIFT+TAB is insanely common in pane management, they go and decide it’s now 2 separate commands and don’t bother explaining it ANYWHERE.

This is what makes learning this shit from scratch so infuriating.

It says <Prefix + %>, do i type that whole thing?

or not the <> part?

is “prefix” part of the code or does it means something that i need to input?

and why does it sometimes say CTL+B and sometimes CTL-B?





the lesson- you better have friends, a computer science degree or an insane amount of patience.


/tmp lesson learned the hard way

As my friend Max so elegantly said when I  made my first big fuck up “most programs make it so you can’t shoot yourself in the foot too badly, working in the terminal there’s no such thing”

So for reasons I can’t figure out, I had to save files to the tmp folder when connected to my company’s database server. Which, w/e makes no different to me.

Until I waited 2 patient days for a query to finish running then restarted my computer…

turns out /tmp is nothing like Desktop/temp and everything gets deleted when you shut down.

the bright side- Having no alternatives but to make the query run faster I learned the black magic that is indexing.

Having only an average understanding of database engineering, I thought indexes worked differently than they actually do.

What i thought they did- Act like a table of contents in a book. So if i only need my query to pull stuff out of Chapter 3, it prevents it from looking through the whole book. This makes total sense if you have repeated data like male/female etc. But what if every record is unique? What’s the point of indexing on, say, the primary key?

What it actually does- Using my book analogy again, indexes can also be a table of contents filled with just page numbers, so it can jump right to the page without scanning the entire book for it.

The query then ran in 16 seconds. Which made me decide it’s sorcery…


OSX nuances suck out the better part of the day

If you were wondering what triggered this journey, it was all about my breakup with excel.

I was asked to do some  analysis on a data set with 6 million rows, basically determining a US state for each row, using crap data, requiring an irriratingly long Case When statement in SQL and/or IF statement in excel. First I needed to join to tables that didn’t exist (like a table of US Zip codes) which required me to learn setting up local databases.

And when sql pro couldn’t export a query  that size,  I had to learn how to do everything from the command line. Which brings us to the story of how I earned my right to ask questions (or more appropriately, convinced people I’ve done the grunt work before I come to you for help).

It was a simple journey into the world of sed. Sed being one of the most useful first things people learn. Sed being a way to find and replace without opening a file. quite useful when your file is 6 million rows.

But of course what I wanted to do wasn’t simple and I found only a single post that explained this little trick.

What I was trying to do: Change a file from tab delimited (how mysql outputs a file) into comma delimited (how mysql needs it to import it). (And while i’m at it, why does mysql default it to tab delimited anyway when it’s just going to want it in CSV later? asshole.)

The problem: Figuring out why all the code that said ‘s/TAB/,/g’ didn’t work.

The solution: that code is for windows. if you’re on a mac (which i don’t know why you wouldn’t be), you have to replicate the Tab key with the keyboard shortcuts CTL+v Then CTL+i.

The bright side is, i learned a lot about the smart way to test errors, the head command, and became a lot better and quickly creating, editing and moving files around.

The lesson- Prefix all google searches with “OSX terminal” from now on.


Asking questions when you know nothing (John Snow)

So I was well on my way in the terminal, listing directories, CHANGING directories (omg CD), viewing files, creating files. So exciting! Fuck you Word and excel, I do everything from the command line now. Your inferior “UI” is useless to me.

But like most things I set out to do, I jumped in head first and tried to solve a very complicated problem.

What I tried to do: Open a list of URLs and save a PDF of the content.

Why this was more challenging than expected: They’re internal encrypted websites requiring a login.

What I tried (found on google) : Bypassing the browser completely and using a HTML to PDF converter called wkhtmltopdf

Now, in theory, I understand the problem and why the solution could work. What I got stuck on was even more retarded. And thus again, the point of this blog.

So what is wkhtmltopdf? It’s an open source LGPL command line tool… k… great. so I type in the code that people are referencing in various forums, no luck. Everntually i figure out you have to like… download something.

So I work out my own somewhat accurate metaphor. Linux (or unix, still unclear on the difference) has basically a dictionary, and to do other cool stuff you need to kinda download other dictionaries. Then you can use the words in those dictionaries. What makes things more confusing to a noob is most people download these dictionaries by first downloading a dictionary called Homebrew. Then you can use the word brew. but not til you download it. a;lskdjf

The instructions on the site are naturally crystal clear:

  1. Download a precompiled binary or build from source

Instead of googling what a precomipled binary is or try and decipher what they mean by the irritatingly innocuous “source,”  decide it would be faster to “ASK AN ENGINEER!” and that’s when the lolz began.

I trek across the office to the land of Hershel backpacks and imported Japanese tea. And attempt to ask my question. it sounded something like this:

“So. I need help… uhm “installing” like a … “tool” maybe? or “client” i’ve seen it called also… or like something about a binary something…. or a kit? Basically i need to make use commands that i can’t use now… uh work.”

After a pause, he proceeded to install homebrew, download the tool/kit/client and dumb it down for me in a very gentle, kind way.

The lesson-

Linux has a list of words, commands are like verbs and i haven’t mapped out the rest of the syntax yet. To use the verb “install” in order to download something, you first need to install homebrew (or a similar program) that’s kind of like an excel add-on.

The epilogue- Apparantly you can’t bypass a browser if you need to login and can’t replicate the cookies (thanks Max for spending an evening helping me try) and I settled for an applescript which did the job just fine.


Scripting and Louboutins- The inaugural post

The requisite explanation entry, which no one ever reads, assuming you’ve done a good job naming your blog.

However, there’s a few different angles this could be coming from, so I’ll attempt to give this little project a well-deserved introduction.

I’m a girl. and i’m learning to code. and there aren’t a ton of people trying to learn this stuff from scratch. and it’s hilarious. and i need a place to vent. and completely geek out. and my friends (most of whom are programmers) find my little “rants” amusing. so maybe there are people out there afraid to ask really really dumb questions to really really smart people. i’m not one of those people. and i really really enjoy going against the hipster grain. asking a car full of people what song is playing, and then following up by asking what else Mumford and Sons have done.

maybe moving to Seattle after of college was a culture shock of people pretending to know things they didn’t know. and i relished the friendships spawned from a “thank you for asking, i had no idea what they were talking about either.”

and now that i’m a financial analyst for a start up in Silicon Valley, I’ve found a new breed of hipsters; the engineer. The overworked, too smart for his own good, well-dressed, bikes to work, built his own wireless stereo system in his cement-walled Soma Loft, knows more about Sushi than you, engineer.

But being a girl has one important advantage. Anything technical I do is disproportionately impressive . and I can milk the “aw she wants to learn linux” out of my friends for at least the next few years.

and so, i’m starting a blog because you too should be frustrated when stackedoverload doesn’t clearly explain which part is the code and which part you have to fill in your own variables for. and you too should giggle the first time you make your computer talk to you. and you too should realize that shitty part of your job can probably be automated.

It’s worth mentioning that I’m writing this inaugural post at work on a Friday, watching tmux tutorials in a polka dot dress, pearls and Christian Louboutins, killin an hour because i wrote a script that runs every query i need for the next week.