Skip to content

Instantly share code, notes, and snippets.

View etoxin's full-sized avatar

Adam Lusted etoxin

View GitHub Profile
@etoxin
etoxin / toWeirdCaes
Created November 19, 2019 05:22
CodeWars
let p =
"The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?";
function toWeirdCase(InputString) {
return InputString.split("")
.filter(l => l.match(/[a-zA-Z]/))
.map((l, i) => (i % 2 ? l.toLowerCase() : l.toUpperCase()))
.join("");
}
@etoxin
etoxin / machine.js
Created October 28, 2019 22:47
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@etoxin
etoxin / fun.js
Last active October 3, 2019 06:37
[...document.querySelectorAll("*")].reverse().forEach(async (n, t) => {
await setTimeout(() => n.remove(), t * 10);
});
@etoxin
etoxin / index.js
Last active September 4, 2019 13:47
const tf = require("@tensorflow/tfjs-node");
(async () => {
const model = tf.sequential({
layers: [tf.layers.dense({ inputShape: [1], units: 1 })]
});
model.compile({ optimizer: "sgd", loss: "meanSquaredError" });
// y = 2X - 1
@etoxin
etoxin / modify.scss
Last active September 4, 2019 01:25
Modify method for BEM
@mixin modify ($modifier) {
$class: quote(#{&});
$index: str-index($class, '__');
$parent: str-slice($class, 1, $index - 1);
@at-root #{selector-nest(#{$parent}--#{$modifier}, &)} {
@content;
}
}
.parent {
@etoxin
etoxin / SSH over USB on a Raspberry Pi.md
Last active March 28, 2024 11:16
SSH over USB on a Raspberry Pi

Our long term goal will be to use SSH over USB. This means that we have to configure Raspbian to treat the USB port like an ethernet port. Mount the micro SD card in a computer (not Pi Zero) and open it with Finder, or Windows Explorer, or whatever it is that you use.

The first thing that you want to do is open a file at the root of the mounted drive called config.txt. In this file you want to add the following line at the very bottom:

dtoverlay=dwc2

The above line will set us up for the next file that we alter. The next file we alter is cmdline.txt, but it is a bit different. Parameters in this file are not delimited by new lines or commas, they are delimited by space characters. In this file we want to add the following:

const sample = require("lodash/sample");
const flatMapDeep = require("lodash/flatMapDeep");
const lineCollection = [
{ symbol: "■", rarity: 25 },
{ symbol: "─", rarity: 25 },
{ symbol: "=", rarity: 20 },
{ symbol: "-=", rarity: 20 },
{ symbol: "✦", rarity: 20 },
{ symbol: "<>", rarity: 20 },
@etoxin
etoxin / Issues JIRA
Last active February 28, 2019 00:29
Templates: Issues, Pull Requests
*Expected Behaviour:*
*Current Behaviour:*
*Possible Solution:*
*Steps to Reproduce:*
1.
@etoxin
etoxin / README.md
Last active March 20, 2024 22:04
immediately invoked class expression (IICE)

immediately invoked class expression (IICE)

What would a Immediately Invoked Class Expression in JavaScript look like. This is the question I asked myself. I couldnt find anything online, so I created one.

Below we have a Immediately Invoked Class Expression. This could also be called a Self-Executing Anonymous Class.

void new class {
  constructor () {
 console.log("hello world")
function getEncoder(encoding) {
const encoder = encoding === "utf8" ? new UTF8Encoder()
: encoding === "utf16le" ? new UTF16Encoder(false)
: encoding === "utf16be" ? new UTF16Encoder(true)
: throw new Error("Unsupported encoding");
}