Skip to content

Instantly share code, notes, and snippets.

View etoxin's full-sized avatar

Adam Lusted etoxin

View GitHub Profile
@etoxin
etoxin / preventDefaultDebugger.md
Last active September 17, 2018 00:28
event.preventDefault debugger

How to use

preventDefaultDebugger.js

Add this to your devtools console.

var oldEPD = Event.prototype.preventDefault;
Event.prototype.preventDefault = function() {
 debugger;
@etoxin
etoxin / Map.js
Last active October 8, 2018 03:33
Map and Set basics
let members = new Map([["Sam", 56], ["Sandy", 86]]);
let youngestMemberAge = Math.min(...members.values()) // 86
let Over60s = new Map(
[...members].filter(([name, age]) => 60 < age)
);
let Over60sUserNames = new Map(
[...members].map(([name, age]) => {
@etoxin
etoxin / Render.js
Last active October 25, 2018 02:50
Recursive react render for dom or cms
RenderModal(settings) {
const { modalIsOpen, targetDomNode } = settings;
const closeModal = () => {
this.RenderModal(
Object.assign(settings, {
modalIsOpen: false
})
);
};
@etoxin
etoxin / service.js
Created November 19, 2018 04:09
Nice small clean Service
/**
* API Service
* @async
* @returns {Promise<Object>}
*/
async function Service() {
let response = await fetch('/api.json');
if (response.ok) return await response.json();
throw new Error(response.statusText);
}
function getEncoder(encoding) {
const encoder = encoding === "utf8" ? new UTF8Encoder()
: encoding === "utf16le" ? new UTF16Encoder(false)
: encoding === "utf16be" ? new UTF16Encoder(true)
: throw new Error("Unsupported encoding");
}
@etoxin
etoxin / README.md
Last active July 17, 2024 23:16
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")
@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.
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 / SSH over USB on a Raspberry Pi.md
Last active December 26, 2025 12:32
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:

@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 {