Oct 142014
 

So I became a commuter today (we moved to Brooklyn on Saturday, yay!), and although it’s only been a short time, I’ve already had a few ideas for apps that might make commuting better.

One such idea will require some data about the NYC Subway System. I debated using pup to scrape the data I want from Wikipedia or something, but then started looking at the vast list of NYC developer resources.

The NYC MTA developer resources are a bit of a mess, so this post serves to help those that find themselves lost.

There are two kinds of data that these guys offer:

1. Realtime feeds

Here’s a list of realtime feeds that they offer (note it’s limited to only a few lines, which I’m sure they’ll expand upon with time): http://datamine.mta.info/list-of-feeds

To use the realtime feeds you’ll need an API key, which you can register for here: http://datamine.mta.info/user/register

2. Static feeds

To get the basic line information, you can go here http://web.mta.info/developers/developer-data-terms.html, read the terms, and click the Yes, I agree to these terms and conditions. link to get access to all the static data (WITHOUT REGISTERING).

A word to the wise, the data is in GTFS format.

Also all of the official colors are here: http://web.mta.info/developers/resources/line_colors.htm

Happy developing

Oct 012014
 

Ever since I found out about pup I can’t stop using it. I absolutely love it. So why not post another use case?

I’ve had my eye on the CMJ Artists Lineup page and figured that’s a good enough use case:

curl -s http://www.cmj.com/marathon/cmj-2014-artists/ | pup .one-half .entry-title text{} | grep -v "Playing CMJ 2014"

VOILA!

https://gist.github.com/loisaidasam/624523054327cd819dc1

Can you tell that I’m super excited for CMJ?!

Sep 182014
 

Preface: we have a few Graphite-powered Grafana dashboards at work that I wanted to rotate through on a regular basis on our team’s display monitor to give us a better idea of what’s going on.

I don’t know much about Applescript, but I found this article that offers some Applescript to rotates through Safari tabs.

That worked, but fullscreen Safari didn’t look great with tabs, so we used this article to create a Chrome version as well.

Here are the code snippets: https://gist.github.com/loisaidasam/00b8bf0ec540718cf237

For those new to Applescript, open up Applescript Editor (you can find it using Spotlight) and try pasting the following code into the top pane and hitting the big green Run button:

display dialog "Hello world."

Voila!

There are plenty of Applescript tutorials out there, so feel free to dive in.

update Damian walked in and cued us into Grafana’s Playlist feature. Doh! Oh well, it was still a good learning experience.

Sep 172014
 

I just came across (via jdp) this awesome command line dealie called pup:

https://github.com/EricChiang/pup

Totally awesome! The HTML equivalent to jq, it allows you to parse HTML using CSS selectors from the command line.

For example, say I wanted to get the top 10 current headlines from Hacker News:

$ curl https://news.ycombinator.com | pup td.title a text{} | head -n 10
Artificial sweeteners induce glucose intolerance by altering the gut microbiota
Show HN: CleverDeck – I built the spaced repetition app I always wanted
I was asked to crack a program in a job interview
Stuff Goes Bad: Erlang in Anger
Suture – Supervisor Trees for Go
The Design and Implementation of the FreeBSD Operating System, 2nd ed.
Easel Is Shutting Down
Dremel Releases a Mass-Market 3D Printer
The Traveling Salesman with Simulated Annealing, R, and Shiny
The New Yahoo Developer Network

SO COOL!!!

How about another example: let’s grab all mentions of apple-related things on the first 5 pages of Hacker News to see how popular all of this insanity is these days:

$ for page in {1..5} ; do curl -s -S https://news.ycombinator.com/news?p=$page | pup td.title a text{} | awk '{print tolower($0)}' | egrep 'apple|ios|osx|swift|xcode|iphone' ; done ;
ios 8 reviewed
swype - ios 8 keyboard
stripe lands apple in quest for $720b in payments
ios8 adoption, hour by hour
ios 8 review
why apple didn't use sapphire for iphone screens
a history of misses for radioshack
predictive photo sharing with ios8
everything that went wrong while building the tumblr ios share extension
apple pay and nfc are obsolete: this is how payments could work in the future
the iphones 6
apple watch: initial thoughts and observations
build your own apple ibeacon with a raspberry pi
interactive iphone 6 experiment in webgl

So awesome!!! Thank you Eric Chiang!

Sep 032014
 

With that migration to Markdown, the rest of my old posts are kinda gonna look like shit – or are they?

Introducing Plugin Organizer, which allows you to enable plugins per-post, or even based on a wildcard URL! It’s kinda hard/nonintuitive to figure out/set up, but this question kinda explains how to use it for the purpose I want to: http://wordpress.org/support/topic/per-slug-or-per-category.

Old posts showing up in the post list view (http://blog.samsandberg.com) will still show up with Markdown-specific formatting, but for post-specific pages (such as http://blog.samsandberg.com/2013/11/06/ten-things/), I added a Plugin Filter to match things like “http://blog.samsandberg.com/2013/” (and clicked Also Affect Children) so that all posts from the year 2013 match, and then disabled my new Markdown plugin for those matching posts. I did this for 2012-2013, and then did month-specific ones for January of 2014 until last month.

:whew:

Sep 032014
 

MarkDown Notes

With all this buzz around Markdown lately, I decided to migrate my blog so that I can write it in Markdown, since it’s way easier for me to write.

According to this:

http://en.support.wordpress.com/markdown/

wordpress.com websites have MarkDown support, and supposedly it’s via this plugin:

http://michelf.ca/projects/php-markdown/extra/

testing this

so

that’s what’s up

Aug 042014
 

After this morning’s .nyc landgrab, I was curious to check in with the status of .pizza, for my eventual takeover of http://sam.pizza (not a thing yet, sadly)

Some references for those of you looking into the new gTLD ish:

Happy domain naming!

Jun 112014
 
Raspberry Pi Closeup

Raspberry Pi Closeup (Photo credit: GijsbertPeijs)

A quick one for this morning…

I’m sitting here, have my Raspberry Pi plugged in with an internet dongle, trying to figure out where it lives on my network.

I could type:

$ ping 10.0.1.2

and wait…

$ ping 10.0.1.3

and wait…

$ ping 10.0.1.4

and wait…

or I could just type:

$ arp -a

arp ftw!

Jun 042014
 

If you saw Hilary Parker‘s awesome post Sunsets in Google Calendar using R and got all excited about it, but have no idea how to use R, fear not. This post will help you go the distance!

First, install R. I myself use MacPorts

Susnset statue of Liberty

Susnset statue of Liberty (Photo credit: Adorenomis)

, so I did:

$ sudo port install R

which took a while and had a lot of dependencies, but whatevs, it eventually worked…

Next, save Hilary’s createsunsetcal.R file somewhere on your computer.

Open that up and modify it to use your own sunset location and lat/lon coordinates (I used Google Maps and looked at the lat/lon coordinates in the URL to fill in the data I wanted). Save it.

Now, in that same folder, open an R prompt like so and do the following:

$ R

> install.packages(“StreamMetabolism”)

… (follow the prompts here, choose a mirror, etc.)

> library(StreamMetabolism)

> source(“/path/to/downloaded/file/createsunsetcal.R”)

> createsunsetcal()

then <control> + d to exit your R session.

Congrats, you should now see a file called sunset.csv, hooray!

Thanks for the awesome write-up Hilary.

Enhanced by Zemanta