Skip to content

Instantly share code, notes, and snippets.

View brianfiszman's full-sized avatar

Brian Fiszman brianfiszman

View GitHub Profile
const {get} = require("axios");
const urls = [get("https://www.google.com"), get("https://www.yahoo.com"), get("https://www.facebook.com")];
async function processTasks() {
return urls.reduce(async (accPromise, u, i) => {
const acc = await accPromise;
const {data, ...r} = await u;
acc[i] = r.config.url;
return acc;
@brianfiszman
brianfiszman / groupByRepetitions.js
Last active September 5, 2019 03:36
Group by repetitions
const arr = [true, 'tset', 'test', 'test', 'tset', true, 1, 3, 1]
const group = arr.reduce(
(a, b) => ({
...a,
[b]: (a[b] || 0) + 1
}), {}
)
console.log(group)
@brianfiszman
brianfiszman / factorial.js
Created July 12, 2018 21:11
Get a factorial
/*
* Create the function factorial here
*/
const factorial = (n) => (1 < n && n <= 10) ? n * factorial(--n) : n;
@brianfiszman
brianfiszman / get-letter.js
Last active July 12, 2018 21:07
Obtain a letter if 's' match a regexp
const getLetter = s =>
s.match(/^[aeiou]/)
? "A"
: s.match(/^[bcdfg]/)
? "B"
: s.match(/^[hjklm]/)
? "C"
: "D";
@brianfiszman
brianfiszman / vowels-consonants.js
Last active July 12, 2018 21:08
Log vowels and then consonants of a string
/*
* Complete the vowelsAndConsonants function.
* Print your output using 'console.log()'.
*/
const vowelsAndConsonants = s =>
console.log(
s.match(/[aeiou]/gi).join("\n") +
"\n" +
s.match(/[^aeiou0-9_\W]/gi).join("\n")
);
@brianfiszman
brianfiszman / second-largest.js
Last active July 12, 2018 21:15
Get second largest number of an array
/**
* Return the second largest number in the array.
* @param {Number[]} nums - An array of numbers.
* @return {Number} The second largest number in the array.
**/
const getSecondLargest = nums =>
nums.length > 1
? (function secondLargest(sortedNums, n) {
return sortedNums[n] !== sortedNums[n - 1] || n === 1
? sortedNums[n - 1]
@brianfiszman
brianfiszman / make.conf
Created March 7, 2017 22:17
My Funtoo's make.conf
CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=ivybridge -O2 -pipe"
CXXFLAGS="${CFLAGS}"
CPU_FLAGS="avx mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3"
USE="X udev xorg xvfb glamor gallium zsh-completions egl nptl vaapi memcached mysql caps savedconfig json yaml
netbeans initramfs dri3 monolithic hwaccel threads usb cpudetection server pcap
pulseaudio openh264 gstreamer numa 10bit curl javascript cairo
startup-notification branding xfce libnotify ambiance truetype efiemu openssl
cscope d3d9 clang gpm lua luajit perl tcl vim-pager jpeg jpeg2k tiff fontconfig
@brianfiszman
brianfiszman / colorscheme
Last active February 24, 2017 05:34
My terminal colorscheme, its a mix of tango a base16_google.dark
0#0c0e10
1#FF0000
2#198844
3#fba922
4#3465a4
5#75507b
6#055b91
7#d3d7cf
8#555753
9#ef2929