Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

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 November 22, 2020 21:18
React Hooks - Async Stripe Provider
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 April 16, 2024 22:32
m3u8 stream to mp4 using ffmpeg

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 March 12, 2024 16:41
Encoding video for the web

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
@chantastic
chantastic / on-jsx.markdown
Last active March 20, 2024 01:03
JSX, a year in

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 September 24, 2013 16:37
Easy AngularJS Directive for Google Places Autocomplete
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 17:21
Cease fire! The war is over? (Hack and Tell Round 17: Wrap up!)

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 December 10, 2009 07:13
HTML5 MP3 Audio detection
/**
* 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 {