- plain ol' React
let state = initial
render(view(state), element)
view
is pure!
// When I was working on our React/Flummox app I got to the point where, per the docs, I had ~100 lines of code | |
// which were substantially predictable boilerplate, so I used some JS metaprogramming to condense them by 80%. | |
// Flummox docs: http://acdlite.github.io/flummox | |
// I use underscore.js below for utility but you can also just do a for loop. | |
class AppFlux extends Flux { | |
constructor() { |
import * as Ensure from '../../../../utils/lib/Ensure' | |
import markdownBlockDelimiter from './markdownBlockDelimiter' | |
import {BlockTypes, BlockTypeRegExps} from './Types' | |
import { | |
CharacterMetadata, | |
ContentState, | |
ContentBlock, | |
EditorState, | |
genKey, | |
} from 'draft-js' |
#!/bin/bash | |
# Args: input video file, start time in HH:MM:SS, duration in seconds, output | |
# gif file. | |
# Tmpdir | |
rm -rf /tmp/video2gif | |
mkdir /tmp/video2gif | |
mplayer -nosub -ao null -ss "$2" -endpos "$3" "$1" -vo jpeg:outdir=/tmp/video2gif:quality=100 |
const puppeteer = require('puppeteer') | |
const express = require('express') | |
const querystring = require('querystring') | |
const server = express() | |
/** | |
* Screenshot a url | |
* e.g. /screenshot?url=https://www.npmjs.com&width=800&height=600 | |
*/ | |
server.get('/screenshot', async (req, res) => { |
#!/usr/bin/env ruby | |
require 'base64' | |
require 'nokogiri' | |
require 'uri' | |
def main | |
html = Nokogiri::HTML($stdin.read) | |
inline_all_images(html) | |
inline_all_css(html) |
/** | |
* Ensure Public API Has Tests | |
* --------------------------- | |
* This demonstrates analyzing code to find methods and properties from the public | |
* api that don't appear in the tests. | |
* | |
* This is a very basic implementation... a better implementation would examine more | |
* aspects of the code (ex. are the return values properly checked?) and report | |
* statistics about the tests that possibly indicate how they could be improved (ex. | |
* "this test has a lot of overlap with these other tests"). The goal would be to |
node_modules | |
comments.json | |
comments.md |
Here's a neat trick.
I treat my git clones as disposable between computers, but keep my project-specific dotfiles (usually containing environment variables, individual configurations, and so on) synced across devices in iCloud. Then, this script is just a matter of adding symlinks for each of the dotfiles I've saved for each of my projects to each of their clones.
So if my dotfiles are saved like this:
$ tree -a ~/icloud-drive/dotfiles/project-dotfiles/
/Users/justin/icloud-drive/dotfiles/project-dotfiles/
├── searls
// give it a name so it reuses the same window | |
var win = window.open(null, "redux-devtools", "menubar=no,location=no,resizable=yes,scrollbars=no,status=no"); | |
// reload in case it's reusing the same window with the old content | |
win.location.reload(); | |
// wait a little bit for it to reload, then render | |
setTimeout(function() { | |
React.render( | |
<DebugPanel top right bottom left > |