Skip to content

Instantly share code, notes, and snippets.

Avatar
🐶
Arf?

Ava Gaiety Wroten hergaiety

🐶
Arf?
View GitHub Profile
@hergaiety
hergaiety / avoidingLoopsWithMap.js
Created May 16, 2019 14:46
Avoiding Nested Loops with `new Map()`
View avoidingLoopsWithMap.js
let myHugeArray = [...Array(10000).keys()].map(id => { return {id}; });
let listIWant = [1010, 2020, 3030, 4040, 5050, 6060, 7070, 8080, 9090];
// INSTEAD OF:
myHugeArray.filter(obj => listIWant.includes(obj.id));
// TRY:
let mapIWant = new Map();
listIWant.forEach(id => mapIWant.set(id));
myHugeArray.filter(obj => mapIWant.has(obj.id));
@hergaiety
hergaiety / array_range.js
Created March 1, 2018 03:47
Array of 100 things, the smart ES6 way
View array_range.js
let arrayOf100Things = [...Array(100).keys()];
@hergaiety
hergaiety / keybindings.json
Created January 25, 2018 18:36
VS Code - Sane Tab Change Behavior
View keybindings.json
[
{
"key": "ctrl+tab",
"command": "-workbench.action.openNextRecentlyUsedEditorInGroup"
},
{
"key": "ctrl+shift+tab",
"command": "-workbench.action.openPreviousRecentlyUsedEditorInGroup"
},
{
@hergaiety
hergaiety / async-await-runloop-example.js
Created January 24, 2018 14:37
Leveraging async/await for the Ember runloop, simply.
View async-await-runloop-example.js
const emberRunloop = (queue = 'sync') => new Promise(resolve => {
scheduleOnce(queue, () => {
resolve();
});
});
export default Component.extend({
async _myFunction() {
await emberRunloop('afterRender');
// Do your stuff after above specified ember runloop
View netrw_toggle.vim
let DirProjectHome = getcwd()
function! ExploreToggle(bang)
if &ft ==# "netrw"
:exe "lcd " . g:DirProjectHome
:bd
else
if a:bang
:lcd %:p:h
:enew
@hergaiety
hergaiety / toWords.hs
Last active April 19, 2017 21:25
String To List Of Words
View toWords.hs
toWords :: String -> [String]
toWords x
| length x == 0 = []
| otherwise = takeWhile (/= ' ') x : toWords (drop 1 (dropWhile (/= ' ') x))
@hergaiety
hergaiety / dracula.styl
Created January 20, 2017 01:04
Dracula theme for Hexo's highlight converted to Stylus
View dracula.styl
/*
* Dracula Theme for Hexo
* Borrowed from https://github.com/isagalaev/highlight.js/blob/master/src/styles/dracula.css
* Converted to Stylus by SharpShark28 http://github.com/sharpshark28
* Original https://github.com/zenorocha/dracula-theme
*/
.highlight
.code
color: #f8f8f2
@hergaiety
hergaiety / userIsTypingStuff.js
Created December 26, 2016 05:58
Boolean for whether the user is focused on an input or textarea anywhere.
View userIsTypingStuff.js
let userIsTypingStuff = document.querySelectorAll('input:focus, textarea:focus').length !== 0;
View multi-line-spell.json
{
"casting_time": "test",
"classes": ["sorcerer"],
"components": {"raw": "test"},
"description": [
"**Wow!**",
"| First Header | Second Header |",
"| ------------- | ------------- |",
"| Content Cell | Content Cell |",
"| Content Cell | Content Cell |"
@hergaiety
hergaiety / hackmaster-spell-example.json
Created August 2, 2016 01:25
Example of a Hackmaster Spell
View hackmaster-spell-example.json
[
{
"casting_time": "1 segment",
"classes": [
"sorcerer",
"wizard"
],
"components": {
"raw": "V, S",
"material": false,