Skip to content

Instantly share code, notes, and snippets.

import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.channelFlow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
private suspend fun <T> getChunk(channel: Channel<T>, maxChunkSize: Int): List<T> {
// suspend until there's an element in the buffer
@AWinterman
AWinterman / .vimrc
Created June 18, 2019 22:31
June 2019 my vimrc
call plug#begin('~/.vim/plugged')
Plug 'itchyny/lightline.vim'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'junegunn/vim-easy-align'
Plug 'https://github.com/sjl/gundo.vim.git'
Plug 'https://github.com/junegunn/vim-github-dashboard.git'
Plug 'https://github.com/junegunn/vim-github-dashboard.git'
Plug 'https://github.com/lifepillar/pgsql.vim.git'
@AWinterman
AWinterman / .vimrc
Created June 18, 2019 22:31
June 2019 my vimrc
call plug#begin('~/.vim/plugged')
Plug 'itchyny/lightline.vim'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'junegunn/vim-easy-align'
Plug 'https://github.com/sjl/gundo.vim.git'
Plug 'https://github.com/junegunn/vim-github-dashboard.git'
Plug 'https://github.com/junegunn/vim-github-dashboard.git'
Plug 'https://github.com/lifepillar/pgsql.vim.git'
@AWinterman
AWinterman / everything-is-terrible.md
Created January 30, 2019 01:26
Everything on the internet about using angular and django is terrible

Everyting on the internet about configuring angular and django to play nice together is garbage.

  1. Refer to the angular docs over any tutorial out there because everytyhing else is garbage.
  2. If anything mentions webpack, stop reading it, unless what you actually want is to learn about webpack.
  3. If anybody mentions turning off CORS or CSRF protections, screaming inside is encouraged, but if you let it you your non-technical coworkers will look at you funny.

What you need to know is the following. Angular's HTTP module will add the CSRF token if it was available. You just have to coordinate how your app will send it up with where angular looks for it. https://angular.io/guide/http#security-xsrf-protection

If you want to get the CSRF token from the webframework, (django in my case), you have to serve the front end from django. This is easy enough if you add the following to the JSON object at projects.your-dumb-project.architect.build.options:

@AWinterman
AWinterman / gist:0718e36868f20c8a09cb
Created March 1, 2015 05:10
grep "Finite" data/chapter/*
data/chapter/111.html:<p>"I need my wand to <em>Finite</em> her," Harry said aloud.</p>
data/chapter/111.html:<em>Finite Incantatem</em>, almost like the sped-up reverse of
data/chapter/23.html:<p>"<em>Aaahhhhh! Finite Incantatem! Aaaahhh!</em> "</p>
data/chapter/23.html:and left there. He'd put everything he had into the <em>Finite
data/chapter/23.html:<p>"<em>Finite Incantatem.</em>" Harry's voice came out rather
data/chapter/25.html:from Transfiguring the hinges <em>and</em> resist <em>Finite
data/chapter/28.html:hadn't <em>worked</em> actually, they could have just <em>Finite
data/chapter/28.html:<p>"<em>Finite Incantatem!</em> "</p>
data/chapter/28.html:<p>"<em>Finite Incantatem</em>," said Hermione. "Check with
data/chapter/58.html:would cast Finite on the oil immediately after, dispelling his own
@AWinterman
AWinterman / gist:ebc233162346226bd848
Created March 1, 2015 05:03
~/hpmor-analysis(branch:master*) » grep "Turner" data/chapter/*.html | sed "s:^: :g" | pbcopy
data/chapter/100.html:authorized to know about Time-Turners, had refused to allow
data/chapter/101.html:should have grabbed his Time-Turner the moment he saw the centaur.
data/chapter/101.html:<p>Harry's hand reached up toward his robes, for his Time-Turner,
data/chapter/101.html:departed. Professor McGonagall, who did not use a Time-Turner as
data/chapter/101.html:Time-Turner. You are the reason why I could not travel back to
data/chapter/103.html:Time-Turner to read through the first-year Defense book after being
data/chapter/104.html:the electives would have his own Time-Turner. Maybe Harry could try
data/chapter/104.html:Time-Turner, so it was possible.</p>
data/chapter/104.html:had arrived then Harry had arrived (via Time-Turner) then the
data/chapter/104.html:along the way to use his Time-Turner.</p>
@AWinterman
AWinterman / gist:0c704a915feea2d189b3
Created March 1, 2015 04:28
grep -A 5 -B 5 "Prophecy" data/chapter/*.html
data/chapter/108.html-intelligent conversation. After fifty years of being surrounded by
data/chapter/108.html-gibbering stupidity, I no longer cared whether my reaction might be
data/chapter/108.html-considered a literary cliche. I was not about to pass up on that
data/chapter/108.html-opportunity without thinking about it first. And then, you see, I
data/chapter/108.html-had a <em>clever idea</em>." Professor Quirrell sighed. "It
data/chapter/108.html:occurred to me how I might fulfill the Prophecy my own way, to my
data/chapter/108.html-own benefit. I would mark the baby as my equal by casting the old
data/chapter/108.html-horcrux spell in such fashion as to imprint my own spirit onto the
data/chapter/108.html-baby's blank slate; it would be a purer copy of myself, since there
data/chapter/108.html-would be no old self to mix with the new. In some years, when I had
@AWinterman
AWinterman / gist:62b664034228a1770452
Created March 1, 2015 04:16
grep -A 5 -B 5 "Transfiguration" data/chapter/*.html |
data/chapter/102.html-no mere animal could possess... to slay something innocent to save
data/chapter/102.html-oneself, that is a very grave sin.</em> Those two phrases, from
data/chapter/102.html-Professor McGonagall, from the centaur, had both run through
data/chapter/102.html-Harry's mind, over and over as the white unicorn had yawned, laid
data/chapter/102.html-down on the ground, and closed its eyes for what would be the last
data/chapter/102.html:time. The Transfiguration had lasted an hour, and Harry's eyes had
data/chapter/102.html-watered repeatedly as he worked. The unicorn's death might not have
data/chapter/102.html-come then, but it would come soon enough, and it was foreign to
data/chapter/102.html-Harry's nature to try to refuse responsibility of any kind. Harry
data/chapter/102.html-would just have to hope that, if you didn't kill the unicorn to
@AWinterman
AWinterman / gist:7a33a32962b84adde47c
Created March 1, 2015 04:15
grep -A 20 -B 20 "Transfiguration" data/chapter/*.html
data/chapter/102.html-for a day, then it <em>had</em> to be right to drink a unicorn's
data/chapter/102.html-blood in order to stave off death for weeks. You couldn't have it
data/chapter/102.html-both ways.</p>
data/chapter/102.html-<p>So Harry had gone into the Forbidden Forest wearing his Cloak.
data/chapter/102.html-He had searched the Grove of Unicorns until he saw her, a proud
data/chapter/102.html-creature with a pure white coat and violet hair, with three blue
data/chapter/102.html-blotches on her flank. Harry had gone over, and the sapphire eyes
data/chapter/102.html-had stared at him inquisitively. Harry had tapped out the sequence
data/chapter/102.html-1-2-3 on the ground several times with his shoes. The unicorn had
data/chapter/102.html-shown no sign of responding in kind. Harry had reached over, taken
@AWinterman
AWinterman / gist:50ce3b425df45fc45a7e
Last active August 29, 2015 14:16
grep -A 20 -B 20 "Free Transfiguration" data/chapter/*.html
data/chapter/15.html-steel. It cannot do the reverse, nor can it transform a desk into a
data/chapter/15.html-pig. The most general form of Transfiguration - free
data/chapter/15.html-Transfiguration, which you will be learning here - is capable of
data/chapter/15.html-transforming any subject into any target, at least so far as
data/chapter/15.html-physical form is concerned. For this reason, free Transfiguration
data/chapter/15.html-must be done wordlessly. Using Charms would require different words
data/chapter/15.html-for every different transformation between subject and target."</p>
data/chapter/15.html-<p>Professor McGonagall gave her students a sharp look.
data/chapter/15.html-"<em>Some</em> teachers begin with Transfiguration Charms and move
data/chapter/15.html-on to free Transfiguration afterwards. Yes, that would be much