Skip to content

Instantly share code, notes, and snippets.

View example.js
const exampleSignals =
'acedgfb cdfbe gcdfa fbcad dab cefabd cdfgeb eafb cagedb ab';
const charCount = {};
for (const char of exampleSignals
.split('')
.filter((char) => /[a-g]/.test(char))) {
charCount[char] = (charCount[char] ?? 0) + 1;
}
@leyanlo
leyanlo / arrayDiff.js
Created Nov 30, 2020
cassidoo 11/29/2020
View arrayDiff.js
function arrayDiff(arr, target) {
const seen = {};
return arr.reduce((numPairs, n) => {
const targetsFromN = { [n + target]: null, [n - target]: null };
numPairs += Object.keys(targetsFromN).reduce(
(seenFromN, targetFromN) => seenFromN + (seen[targetFromN] || 0),
0
);
seen[n] = (seen[n] || 0) + 1;
return numPairs;
@leyanlo
leyanlo / babyLisp.js
Last active Oct 13, 2020
cassidoo 10/11/2020 O(n) solution with validation
View babyLisp.js
// cassidoo 10/11/2020 O(n) solution with validation
// https://buttondown.email/cassidoo/archive/4b882f72-2fc1-4b77-b574-0118a37f480c
function getValue(operator, a, b) {
switch (operator) {
case "add":
return a + b;
case "subtract":
return a - b;
case "multiply":
@leyanlo
leyanlo / webstorm-vs-vscode.md
Last active Dec 4, 2020
WebStorm vs VSCode
View webstorm-vs-vscode.md

WebStorm vs VSCode

Tradeoffs

VSCode pros

  • Popular
  • MDX support
  • Can jump to files from console, e.g. when running eslint

VSCode cons

  • Cannot look at tab title and tell if file is new, modified, unstaged, or has errors
  • Cannot advance to next file in git view
@leyanlo
leyanlo / index.html
Last active Feb 17, 2020
momwordcloud.svg
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Mom’s 70th</title>
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
@leyanlo
leyanlo / camelCase_to_snake_case.sh
Last active Aug 30, 2018
Script to convert camelCase filenames to snake_case
View camelCase_to_snake_case.sh
#!/bin/bash
# Recurse through subdirectories and convert camelCase filenames to snake_case
for file in */**/*.* ; do
mv "$file" "$(echo $file|gsed -e 's/\([A-Z]\)/_\1/g' -e 's/^.\/_//'|awk '{print tolower($0)}')"
done
@leyanlo
leyanlo / README.md
Last active Feb 2, 2018 — forked from quagliero/README.md
Installing cpuminer-multi on macOS 10.13.2 (High Sierra)
View README.md

Installing cpuminer-multi on macOS 10.13.2 (High Sierra)

This assumes you have brew installed and are comfortable using a terminal.

Following the guide on https://github.com/tpruvot/cpuminer-multi will likely lead to errors about invalid paths to OpenSSL, and neoscrypt errors to the tune of Undefined symbols for architecture x86_64 during the build. I managed to piece together different fixes into an installation that has worked for me. So I hope it works for you.

Requirements

Ensure a c compiler is installed. Type g++ in the terminal and continue with the xcode installation if necessary. If it prints clang: error: no input files, then you can proceed.

View keybase.md

Keybase proof

I hereby claim:

  • I am leyanlo on github.
  • I am leyanlo (https://keybase.io/leyanlo) on keybase.
  • I have a public key ASBdnEBzDJ--vDMLyxCy29JRMnh4nk86SOd-Pnyfa-kLygo

To claim this, I am signing this object:

View make-app.sh
#!/bin/sh
# Inspired by https://gist.github.com/demonbane/1065791
function pure_version() {
echo '0.1'
}
function version() {
echo "make-app $(pure_version)"
}