Sets can be generalized as a function that takes an argument and returns
true
or false
.
For a specific set of numbers, you can write it as:
const mySetOfNumbers = num => [1,2,3,4,5].includes(num);
''' | |
You'll need to pip install some dependencies: | |
* python-dateutil | |
* requests | |
Also, populate your EMAIL and PASSWORD below. | |
''' | |
from xml.etree import ElementTree |
import moment from 'moment'; | |
/** | |
* XXX: Okay, so, no date library, other than moment, appears to currently | |
* support _formatting a date with a specified time offset_. That is, given the | |
* date string `2018-11-21T15:00:00+0100` (UTC+1:00), I want to format it as | |
* `3:00 PM`, regardless of the system's current local time. | |
* | |
* This seems like it should be easy, right? We don't need time zone data, | |
* because we're not specifying a time zone, just a UTC offset. All we need to |
React recently introduced an experimental profiler API. This page gives instructions on how to use this API in a production release of your app.
Table of Contents
React DOM automatically supports profiling in development mode for v16.5+, but since profiling adds some small additional overhead it is opt-in for production mode. This gist explains how to opt-in.
// EmailInput wraps an HTML `input` and adds some app-specific styling. | |
const EmailInput = React.forwardRef((props, ref) => ( | |
<input ref={ref} {...props} type="email" className="AppEmailInput" /> | |
)); | |
class App extends Component { | |
emailRef = React.createRef(); | |
render() { | |
return ( |
There are so many great GIFs out there and I want to have copies of them. Twitter makes that harder than it should be by converting them to MP4 and not providing access to the source material. To make it easier, I made a bash pipeline that takes a tweet URL and a filename, extracts the MP4 from that tweet and uses ffmpeg to convert back to GIF.
brew install ffmpeg
apt install ffmpeg
#!/usr/bin/env bash | |
# chrome-different-tz | |
# | |
# Use this script on OS X to launch a new instance of Google Chrome | |
# with its own empty cache, cookies, and user configuration. | |
# | |
# The first time you run this script, it will launch a new Google | |
# Chrome instance with a permanent user-data directory, which you can | |
# customize below. Perform any initial setup you want to keep on every |
// connect() is a function that injects Redux-related props into your component. | |
// You can inject data and callbacks that change that data by dispatching actions. | |
function connect(mapStateToProps, mapDispatchToProps) { | |
// It lets us inject component as the last step so people can use it as a decorator. | |
// Generally you don't need to worry about it. | |
return function (WrappedComponent) { | |
// It returns a component | |
return class extends React.Component { | |
render() { | |
return ( |
# Put this in your .zshrc or .bashrc file | |
# Install `tree` first — brew install tree | |
function t() { | |
# Defaults to 3 levels deep, do more with `t 5` or `t 1` | |
# pass additional args after | |
tree -I '.git|node_modules|bower_components|.DS_Store' --dirsfirst --filelimit 15 -L ${1:-3} -aC $2 | |
} |