Skip to content

Instantly share code, notes, and snippets.

View video_club_anagrams.py
import collections
from typing import Counter, List, Set, Tuple
def subanagrams(letters: Counter[str], words: Set[str], min_len=4) -> List[Tuple[str, Counter[str]]]:
anagrams = []
for word in words:
if len(word) < min_len: continue
rest = letters.copy()
@daviseford
daviseford / asyncStripeProvider.tsx
Last active Nov 22, 2020
React Hooks - Async Stripe Provider
View asyncStripeProvider.tsx
import React, { useState, useEffect, useRef } from 'react'
import { StripeProvider } from 'react-stripe-elements'
type TProvider = React.FC<{ apiKey: string }>
const AsyncStripeProvider: TProvider = props => {
const { apiKey, children } = props
const [stripe, setStripe] = useState<stripe.Stripe | null>(null)
const isMounted = useRef(false)
const unmountFn = () => {
@tzmartin
tzmartin / m3u8-to-mp4.md
Last active Nov 26, 2021
m3u8 stream to mp4 using ffmpeg
View m3u8-to-mp4.md

1. Copy m3u8 link

Alt text

2. Run command

echo "Enter m3u8 link:";read link;echo "Enter output filename:";read filename;ffmpeg -i "$link" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 $filename.mp4
@Vestride
Vestride / encoding-video.md
Last active Nov 23, 2021
Encoding video for the web
View encoding-video.md

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
View on-jsx.markdown

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't

@victorb
victorb / app.js
Created Sep 24, 2013
Easy AngularJS Directive for Google Places Autocomplete
View app.js
var myApp = angular.module('myApp', []);
myApp.directive('googleplace', function() {
return {
require: 'ngModel',
link: function(scope, element, attrs, model) {
var options = {
types: [],
componentRestrictions: {}
};
@apg
apg / round-17-wrapup.md
Created May 19, 2012
Cease fire! The war is over? (Hack and Tell Round 17: Wrap up!)
View round-17-wrapup.md

Subject: Cease fire! The war is over? (Round 17: Wrap up!)

(Turns out, I have no idea when the Germanian war that started in 17 AD ended, but if you happen to know, feel free to reach out.[0])

(Have a complaint about this email? Want to make it better, fix a typo, or add more info? Fork the gist on GitHub!)

Hello Hackers-

@westonruter
westonruter / canPlayAudioMP3.js
Created Dec 10, 2009
HTML5 MP3 Audio detection
View canPlayAudioMP3.js
/**
* Detect if the browser can play MP3 audio using native HTML5 Audio.
* Invokes the callack function with first parameter is the boolean success
* value; if that value is false, a second error parameter is passed. This error
* is either HTMLMediaError or some other DOMException or Error object.
* Note the callback is likely to be invoked asynchronously!
* @param {function(boolean, Object|undefined)} callback
*/
function canPlayAudioMP3(callback){
try {