Skip to content

Instantly share code, notes, and snippets.

--ignore-file=ext:map
--ignore-file=ext:sql
--ignore-file=ext:log
--ignore-dir=dist
--ignore-dir=public
--ignore-dir=bower_components
--ignore-dir=node_modules
--ignore-dir=tmp
--ignore-dir=vendor
syntax on
set nocompatible
set number
set tabstop=2
set shiftwidth=2
set expandtab
set swapfile
set dir=~/tmp
set hlsearch
filetype indent plugin on
@zelaznik
zelaznik / gist:d8bf76097990b42c8f5a0b424dce3f36
Created July 3, 2018 12:20
Javascript Event Loop Notes
# Jake Archibald In The Loop:
Does this create cause the element to flash for a brief millisecond?
```js
document.body.appendChild(el);
el.style.display = none'
```
No. There's no race condition. All this code takes place before a rendering is ever triggered.

Jake Archibald In The Loop:

Does this create cause the element to flash for a brief millisecond?

document.body.appendChild(el);
el.style.display = none'

No. There's no race condition. All this code takes place before a rendering is ever triggered.

@zelaznik
zelaznik / details_summary.md
Created July 31, 2018 14:58
Details Summary

Details Summary

  • A this allows people to comment on pull requests and include long snippets of code without making the discussion a mile and a half long.
Click here for a ridiculously long snippet of javascript...
import Ember from 'ember';
import { task } from 'ember-concurrency';
function* fetchStuff() {
console.log('In fetchStuff');
yield *fetchMoreStuffGeneratorFn();
// fetchMoreStuff();
}
function* fetchMoreStuffGeneratorFn() {
#!/usr/bin/python
import sys
import re
name = sys.argv[1]
def classify(name):
names = []
@zelaznik
zelaznik / components.location-picker\.js
Last active April 27, 2020 18:36
Actions And Glimmer Components
import GlimmerComponent from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import EmberComponent from '@ember/component';
import { action } from '@ember/object';
import { guidFor } from '@ember/object/internals';
import { addObserver } from '@ember/object/observers';
function myAction(_target, _name, descriptor) {
const original = descriptor.value;
@zelaznik
zelaznik / emumerable.js
Last active December 5, 2020 16:04
Implement Ruby's Enumerable.Lazy in Javascript
/*
This is an attempt to implement the behavior of Ruby's
lazy enumerator, but in javascript. The main reason for
the exercise was to see if I could make an object that would
work with the [...someCustomObject] pattern.
*/
function* enumerate(context) {
let index = 0;
for (const value of context) {
@zelaznik
zelaznik / json_to_csv
Last active October 20, 2021 16:32
Convert JSON to CSV in Python
#!/usr/bin/python3
import csv
import io
import json
import pdb
import sys
from collections import OrderedDict