Category: programming

Kenosha to Minneapolis

Sara and I made it back to Minneapolis. Thankfully there are some good stops along the way. First we swung by Madison, WI for Cheeba Hut. This is a must to anyone making the drive from Minneapolis to Milwaukee, Madison, Chicago, etc. They have the best sandwiches, and grabbing a goo-ball is a must.

Next up was Lacrosse. The Root Note in Lacrosse, WI is a really great coffee shop. It has a very distinct feel and delicious crepes.

The Root Note in Lacrosse, WI

Sadly we missed the crepes this time, so make sure to plan accordingly when making the trip. I had a nice iced chai (my usual) and sequestered some of the cold brew Sara ordered.

These stops really make the drive a lot more tolerable. Driving straight through is a lot of hours, but breaking it up into minor destinations is really helpful. Plus, good food.

The camera held up really well, but I still have a lot of learning to do. The shot above was taken in JPEG, not RAW. Whoops. Still usable, and highlights/shadows were still compressed nicely leaving room for editing.

Chicago Murder Rate and Leaflet for R

Recently got hooked on Leaflet for R which is an amazing library that allows for interactive Javascript maps to be generated within R. Still have a bit to explore, but the way it handles layering on a map is really nice. I plan on writing a few UI extensions as well, since there is some interactivity I would love to add (sliders without server calls being the biggest).

Chicago Murder Rate by Year
Chicago Murder Rate by Year

Everyone was talking about the Chicago crime rates, so I figured I would give the dataset a go, and came up with the above animation. Each frame was a subset of the murder rates for that frame’s year. Years go from 2001 – 2016, and I will open up the code once I improve the UI.

Find Minimum Distance Between List of Points

This is a neat little call I whipped up that returns the two x and y points from a list which have the shortest distance. It also returns the distance between those two points.

Pretty weird solution right? Seems to work though!

Flatten Data in R by Column Values

Not sure if this will help anyone, but I recently wrote a script that will let you flatten/widen a data set based on a dynamically set column name.

Animal Instances Instances Instances Instances
Puppy 47 77 97 25
Puppy 26 6 14 98
Kitten 38 50 5 73
Puppy 83 61 43 4
Kitten 78 30 57 8

…would turn into this

V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12
Puppy 47 77 97 25 26 6 14 98 83 61 43 4
Kitten 38 50 5 73 78 30 57 8

Breaks a vector into defined segment lengths

Another gist written for stack overflow. This breaks up a vector defined lengths and accounts for the remainder size. Great for splitting up a vector for saving into different files. It is a loop, but any performance issues should be minimal and increases readability/extendability.

Find Patterns in R Vector

Wrote this while providing a solution on Stack Overflow. Figured it might actually come in handy so I saved it. Not the most elegant, and not vectorized, but it might be useful to others as well.

Dynamically Set Accordion Navigation

One of my friends who works for a fairly large company (loooooots of internal links) needed a way to structure the left navigation in such a way that the links would take you to the page, but the list element/clickable element would keep you on the page and expand/contract the navigation. There weren’t any good solutions around that he could find, so I decided to help him out.

This solution is not only an accordion for the menu, but dynamically adds indicators to what list elements are a dropdown and since it makes the list element handle the navigation menu, any element in the list element (including ::before content) will let you expand or collapse the menu system. Clicking on a link will take you to the page, and cancel any accordion effects.

See the Pen VYraBx by Matt Sandy (@MattSandy) on CodePen.

Hopefully this helps someone else out there as well.

Threaded PHP Download

I wrote this code for my bandcamp download project which has since been retired. It breaks up a download into different chunks and saves them to chunk.part1, chunk.part2, etc. I was pretty happy since it sped up my downloads a lot.

Return a Date Range Array in PHP

I think this code might come in handy for me as well as other programmers. It lets you pass two dates and returns an array containing the range of dates between them. I had found code previously, but there was a glitch and so I decided to just write my own.