Skip to content

Instantly share code, notes, and snippets.

@dwaltrip
dwaltrip / tail_file.py
Last active Aug 24, 2018
"tail -f" in python
View tail_file.py
import sys
import time
import subprocess
import select
# Modified from: https://stackoverflow.com/a/12523371/111635
def tail_file(filename, process_line):
assert callable(process_line), '`process_line` should be a callable'
@dwaltrip
dwaltrip / wrapped-react-beautiful-dnd.js
Last active Apr 24, 2020
Wrapping react-beautiful-dnd components so that we can pass `onDragEnd` directly to each `Droppable`
View wrapped-react-beautiful-dnd.js
import {
DragDropContext as RealDragDropContext,
Droppable as RealDroppable,
Draggable
} from 'react-beautiful-dnd';
import React, { Component } from 'react';
const DroppableManager = {
_onDragEndLookup: {},
@dwaltrip
dwaltrip / differences-in-key-behavior.html
Last active May 2, 2017
Differences in `key` behavior between mithril v0.2.5 and mithril v1
View differences-in-key-behavior.html
<html lang="en">
<head>
<meta charset="utf-8">
<title>Mixing keyed and non-keyed Vnodes</title>
<!-- <script src="https://unpkg.com/mithril@0.2.5/mithril.js"></script> -->
<script src="https://unpkg.com/mithril@1.1.1/mithril.js"></script>
<style>
body { margin: 10px; }
@dwaltrip
dwaltrip / memory-leak-mithril-v.0.2.5.html
Created Apr 27, 2017
m.mount causing memory leaks in mithril v0.2.5
View memory-leak-mithril-v.0.2.5.html
<html lang="en">
<head>
<meta charset="utf-8">
<title>Memory Leak test</title>
<script src="mithril-v0.2.5.js"></script>
<style>
body { padding: 15px; margin: 0; }
#widget-container {
width: 340; height: 340; display: flex; flex-wrap: wrap; margin-top: 10px;
}
@dwaltrip
dwaltrip / memory-leak-mithril-v.1.1.1.html
Last active Apr 27, 2017
Testing for memory leaks in `m.mount` (in mithril.js v1.1.1)
View memory-leak-mithril-v.1.1.1.html
<html lang="en">
<head>
<meta charset="utf-8">
<title>Memory Leak test</title>
<script src="mithril-v1.1.1.js"></script>
<style>
body { padding: 15px; margin: 0; }
#widget-container {
width: 340; height: 340; display: flex; flex-wrap: wrap; margin-top: 10px;
}
View computed-properties.js
/****
Problem:
You are making some edits, and in one of the computed properties you make
the correct change to the function body, but forget to update the dependent keys.
You test the change (the basic case only), and it works great. However, the function now
has a bug that will need to be caught by QA or it will slip through to production.
Solution:
View movie-maven-basic-spec.md

Movie Maven

On the web server

  • Node.js app that is the web app (front-end, API, database, etc)
  • Python script that takes a list of filename text strings and processes it into a list of standardized movie names
  • Ruby script that uses the cleaned up movie names to fetch associated data from Rotten Tomato, Imdb, etc

On the user's computer

@dwaltrip
dwaltrip / merged-streams.js
Last active Aug 29, 2015
Code snippet that can take a set of ordered integer streams and return a merged, ordered stream
View merged-streams.js
// helper functions
// includes end points as possible return values
var randint = function(min, max) {
return (Math.floor(Math.random() * (max - min + 1)) + min);
}
// I was surprised to find out this is necessary to get a numerical sort
function sort_number(a,b) {
if (a < b)