Skip to content

Instantly share code, notes, and snippets.

View zbarnes757's full-sized avatar

Zac zbarnes757

  • Ramp
  • McKinney, Tx
View GitHub Profile

Keybase proof

I hereby claim:

  • I am zbarnes757 on github.
  • I am zbarnes757 (https://keybase.io/zbarnes757) on keybase.
  • I have a public key ASA4qvQfya_29PwyXQCxVdeZUB7OsKjr9flyJ5TEINfKrgo

To claim this, I am signing this object:

@zbarnes757
zbarnes757 / destructure.js
Created April 25, 2019 19:43
default destructuring
function defaultName() {
return "name";
}
function handle({ name = defaultName() } = {}) {
console.log(name);
}
handle();
@zbarnes757
zbarnes757 / chunked_promises.js
Created January 14, 2019 19:00
How to chunk Promises with Bluebird
const Promise = require('bluebird');
const stocks = ['aapl', 'googl', 'f', 'gm'];
function getThings(things) {
// DOCS: http://bluebirdjs.com/docs/api/promise.map.html
return Promise.map(things, thing => Promise.resolve(thing), { concurrency: 2 });
}
getThings(stocks);
package main
import (
"fmt"
"time"
)
var chan1 = make(chan string)
var chan2 = make(chan string)
@zbarnes757
zbarnes757 / meat.js
Created April 29, 2018 20:00
How Much Meat to Serve
function GuysHowMuchMeatShouldIServe(guests) {
let totalMeat = 0;
guests.forEach(guest => {
if (guest.age >= 18 && guest.gender == 'male') {
totalMeat += 1;
} else if (guest.age >= 18 && guest.gender == 'female') {
totalMeat += 0.5;
} else if (guest.age < 18 && guest.nationality == 'Texas') {
totalMeat += 1;
@zbarnes757
zbarnes757 / clock.exs
Last active January 4, 2018 20:51
javascript clock
defmodule Clock do
def start do
time = {12, 0, 0}
print_time(time)
:timer.sleep(1_000)
increment_time(time)
end
defp increment_time(time) do
time = update_seconds(time)