Comma Separated List of Array – Good idea for Ruby on Rails?

I feel like there should be a rails function for doing a comma separated list from an array. Here’s how to do it explicitly:

<% search_tags.each_with_index do |tag, index| %>
  <% if index < search_tags.size - 1 %>
    <%= "#{tag}, " %>
  <% else %>
    <%= "#{tag}" %>
  <% end %>
<% end %>

…maybe `render_comma_separated_list(array)` or something.

An example array would like this = [“one”, “two”, “three”]

render_comma_separated_list(array)

=> one, two, three

Does something like this exist already?

Is this worth the effort of making a PR to Ruby on Rails?

Gardnerville Skateboard Park

I think the Gardnerville skateboard park is the best skate park in Nevada. If you want directions, Google has this map. Here are some photos:

This is bigger than it looks.

For a post skateboard drink, it’s fun to visit Nevada’s oldest bar. Since you’re all the way out in Gardnerville, you might as well check out this gem.

Credit Card Processing Fees – Why 2.9%?

What is the reasoning behind the 2.9% market floor for credit card processing fees?

Last year we spent enough on credit card processing fees to have purchased a car with cash. This seems like a good deal for the invoicing companies, but not the best deal for everyone else. I’d rather utilize that money myself.

We have services to send money to people for free. Venmo, Zelle and all the online payment companies in different countries work perfectly well. It’s not impossible to receive money without paying the intermediary…

Dear credit card companies,

What is the reasoning behind this? Is it to offset the cost of fraud protection and server expenses for the credit card companies? Is this just a systematized way for technologists to get rich?

I’d love to know.

Roses are Rad – 2019

The above video is my submission to the Roses are Rad 2019 film festival. This is my second year submitting a film to the event.

The video I submitted last year took second place.

With this years video, I decided to take out all the talking and the extra map drawing stuff. My theory is that the judges might appreciate the pure powder riding.

This is in contrast to my video from last year, which was attempting to do a bit of story telling.

This video was shot over the course of many excellent ski days. My sisters are probably the stars of the show as they took the time to go skiing with me quite often. I would often make short videos of specific days which I would add to instagram and to this blog (here).

Roses are Rad 2019

Technical Production Notes

The video was shot with the GoPro7 almost exclusively. I had trouble with it initially because no video editing software that I use can work with the 240 fps files that are outputted by the GoPro7. The stabilization at 60 fps is just as good as the GoPro6. For that reason, I don’t see anything that makes the 7 better than the 6. If I were buying a new GoPro today, I would save some money and get the 6.

The music is by a group called Glitch Mob. The song is called Drink the Sea. I clipped it in places to the song exactly three minutes long. The specifications for the competition require that the submission is between one and three minutes.

 

Radix Sort is Fun… but it’s Useless in JavaScript

I just spent an hour writing a Radix sort algorithm. It turns out that it is 25% the speed of the built in JavaScript `.sort()` function.

Apparently all this sorting has been figured out in the past. Strange that it’s part of learning to code these days…

const performance = require('perf_hooks').performance;


function getDigit(num, location) {
  let stringNum = num.toString();
  let resultNum = parseInt(stringNum[stringNum.length - 1 - location]);
  if (resultNum) {
    return resultNum;
  } else {
    return 0;
  }
}

function getDigitCount(num) {
  let digitCount =  Math.abs(num).toString().length;
  return digitCount;
}

function mostDigits(arr) {
  let maxDigits = -Infinity;
  for (var i = 0; i < arr.length; i += 1) {
    var digitCount = getDigitCount(arr[i])
    if (maxDigits < digitCount) {
      maxDigits = digitCount;
    }
  }
  return maxDigits;
}

function radixSort(list) {
  let numberOfDigitsTheLargestNumberHas = mostDigits(list);

  for (let i = 0; i < numberOfDigitsTheLargestNumberHas; i += 1) {
    let bucket = [[],[],[],[],[],[],[],[],[]];

    for (var j = 0; j < list.length; j += 1) {
      let number = list[j];
      bucket[getDigit(number, i)].push(number);
    }
    list = bucket.flat(2);
  }
  return list.flat();
}

function sum(a, b) {
  return a - b;
}

var ourBeautifulArray = [50000, 1200,1133, 44, 22, 1, 400000000];
var time1 = performance.now();
console.log(radixSort(ourBeautifulArray));
var time2 = performance.now();
console.log(`RadixSort took ${time2 - time1} to execute`);

var time3 = performance.now();
console.log(ourBeautifulArray.sort(sum));
var time4 = performance.now();
console.log(`Normal JS sort took ${time4 - time3} to execute`);

It’s possible that there is room for improvement in the way I’m executing this algorithm. Perhaps using .flat is causing this.

Either way, even if it’s not a useful thing to be able to do, I think it’s interesting. Once you figure out how it works, it’s neat because it sorts things in non-obvious ways.

I just wish it performed better. LoL

If you want to see the code I’m working with to deepen my knowledge of JavaScript, check out this repository.

Leslie Boards Rose 2019

This was a learn your new camera day for me and I don’t like what I learned.

GoPro7 advertises that it has 240 frames per second which seemed awesome to me. Unfortunatly, none of my three video editing suites (Adobe Premiere CS6, Screenflow nor OpenShot Video Editor) could read these files. So yeah. Big loss on the GoPro7. I’m unsure that it has anything over the GoPro6. Indeed, the wasted time means I wish I still had had that GoPro6….

Alas, I’ll keep experimenting….

Thanks to Leslie for going riding with me.