Skip to content

Instantly share code, notes, and snippets.

View trevor-atlas's full-sized avatar
👾
Variety is the spice of life, or something

Trevor Atlas trevor-atlas

👾
Variety is the spice of life, or something
View GitHub Profile
@trevor-atlas
trevor-atlas / collections.js
Last active October 3, 2022 22:56
benchmark various collection types in js
const set = new Set();
const map = new Map();
const obj = {};
const arr = [];
const values = [];
const getchar = n => String.fromCharCode(n);
const timed = (f) => (...args) => {
const start = performance.now();
f(...args);

A collapsible section with markdown

Click to expand!

Heading

  1. A numbered
  2. list
    • With some
    • Sub bullets
@trevor-atlas
trevor-atlas / partition.ts
Last active July 22, 2022 14:35
A typescript array partitioning helper, split one array into two based on a callback
export const partition = <T>(list: T[], callback: (item: T) => boolean): [T[], T[]] => {
const passed: T[] = [];
const failed: T[] = [];
if (!Array.isArray(list) || list.length === 0) {
return [passed, failed];
}
for (const item of list) {
if (!callback(item)) {
@trevor-atlas
trevor-atlas / ArrayLike.ts
Created November 1, 2021 18:00
Reimplement javascript arrays. You can not use an array internally to hold data.
class ArrayLike<T> implements Iterable<T> {
private _values: Record<number, T> = {};
private _size: number;
constructor(...values: T[]) {
this._values = {};
this._size = 0;
values.forEach(val => this.add(val));
}
@trevor-atlas
trevor-atlas / colors.js
Last active November 15, 2021 16:05
get a random icebreaker for standup
const colors = {
Reset: '\x1b[0m',
Bright: '\x1b[1m',
Dim: '\x1b[2m',
Underscore: '\x1b[4m',
Blink: '\x1b[5m',
Reverse: '\x1b[7m',
Hidden: '\x1b[8m',
FgBlack: '\x1b[30m',
@trevor-atlas
trevor-atlas / cloudSettings
Last active January 23, 2022 03:36
vscode settings
{"lastUpload":"2022-01-23T03:36:45.960Z","extensionVersion":"v3.4.3"}
@trevor-atlas
trevor-atlas / capslock-to-escape-ubuntu.md
Created July 26, 2019 12:59
How to map the Caps Lock key to Escape key
  1. Use setxkbmap to remap the key (does not require a daemon and is independent of your desktop environment or window manager). Don't forget to add the command before the exec gnome-session (or similar) line in your ~/.xinitrc or ~/.xsession:
setxkbmap -option caps:escape

setxkbmap can be found in package extra/xorg-setxkbmap.

  1. dconf-editor → org.gnome.desktop.input-sources.xkb-options → Add caps:escape to the aforementioned field.
  2. gnome-session-settings → Startup Programs → Add → Name=Remap caps lock to escape, command=setxkbmap -option caps:escape

FYI, I obtained the XKB rule by grepping /usr/share/X11/xkb/rules for caps and esc.

____ |~~~~~~~~~~~~~|
Y_,___|[]| | Ship it! |
{|_|_|_|##|==|_____________|
//●●---●●=●● OOO OOO
`. ___
__,' __`. _..----....____
__...--.'``;. ,. ;``--..__ .' ,-._ _.-'
_..-''-------' `' `' `' O ``-''._ (,;') _,'
,'________________ \`-._`-','
`._ ```````````------...___ '-.._'-:
```--.._ ,. ````--...__\-.
`.--. `-` Ship it! ____ | |`
`. `. ,'`````. ; ;`
`._`. __________ `. \'__/`
| | |
)_) )_) )_)
)___))___))___)\
)____)____)_____)\\
_____|____|____|____\\\__
---------\ Ship it! ~~~~~~ /---------
^^^^^ ^^^^^^^^^^^^^^^^^^^^^
^^^^ ^^^^ ^^^ ^^
^^^^ ^^^