Skip to content

Instantly share code, notes, and snippets.

View zwacky's full-sized avatar

Simon zwacky

View GitHub Profile
@DusanBrejka
DusanBrejka / ffmpeg-format-to-mimetype.js
Last active November 28, 2023 05:12
FFMPEG - map of formats to default mime types
// INCOMPLETE
// This command will give you list of available FFMPEG formats and their default Mime types
// ffmpeg -formats -hide_banner | tail -n +5 | cut -c5- | cut -d' ' -f1 | xargs -i{} ffmpeg -hide_banner -h demuxer={} | pcregrep -o2 -o4 -M '(Muxer (\w+) )|(Mime type:( .*).)'
// And then parse the output with regex to JSON format in JavaScript for example:
// str.match(/(.*)\n (.*)/gm).map(m => `"${m.replace(/\n /, '": "')}"`).join(',\n');
// Combine the output with MDN - Common MIME types
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
// And with IANA:
@tkrotoff
tkrotoff / FrontendFrameworksPopularity.md
Last active September 18, 2024 13:35
Front-end frameworks popularity (React, Vue, Angular and Svelte)
@euangoddard
euangoddard / alias.directive.spec.ts
Last active September 20, 2018 13:56
Alias directive for Angular
import { Component } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { AliasDirective } from './alias.directive';
describe('Alias directive', () => {
beforeEach(() =>
TestBed.configureTestingModule({
declarations: [AliasDirective, DoubleComponent, TripleComponent],
}));
@mlynch
mlynch / generate.js
Last active February 7, 2019 18:11
Stencil component generator
/*
To setup, place in scripts/generate.js and add
"st:generate": "node scripts/generate.js"
To your npm scripts.
To generate a component in src/components/ run
npm run st:generate component my-component
@deanrad
deanrad / _RxJSTesting.md
Last active May 3, 2018 18:34
Load testing with RxJS

rxjstests

This script spins up a number of agents (default 4), each with a certain average timeBetweenActions (default 400msec), and it uses a Poisson process in order to keep that average timeBetweenActions, but randomly distributed within that constraint. Think - popcorn popping!

This statistical trick is a valid model of random arrivals of users at a website, and will distribute load nicely. Thanks to the live-updating progress indicators of ascii-progress, and the awesome stream-fu provided by RxJS!

Here's a short video of my thoughts on the matter: https://www.youtube.com/watch?v=0GnB8FAJjfY

var str = 'class ಠ_ಠ extends Array {constructor(j = "a", ...c) {const q = (({u: e}) => {return { [`s${c}`]: Symbol(j) };})({});super(j, q, ...c);}}' +
'new Promise((f) => {const a = function* (){return "\u{20BB7}".match(/./u)[0].length === 2 || true;};for (let vre of a()) {' +
'const [uw, as, he, re] = [new Set(), new WeakSet(), new Map(), new WeakMap()];break;}f(new Proxy({}, {get: (han, h) => h in han ? han[h] ' +
': "42".repeat(0o10)}));}).then(bi => new ಠ_ಠ(bi.rd));';
try {
eval(str);
} catch(e) {
alert('Your browser does not support ES6!')
}
@ktheory
ktheory / Readme.md
Last active May 11, 2024 10:59
Easily make HTTPS requests that return promises w/ nodejs

Javascript request yak shave

I wanted to easily make HTTP requests (both GET & POST) with a simple interface that returns promises.

The popular request & request-promises package are good, but I wanted to figure out how to do it w/out using external dependencies.

The key features are:

  • the ability to set a timeout
  • non-200 responses are considered errors that reject the promise.
  • any errors at the TCP socker/DNS level reject the promise.
@mlafeldt
mlafeldt / postmortem.md
Last active March 27, 2024 09:23
Example Postmortem from SRE book, pp. 487-491

Shakespeare Sonnet++ Postmortem (incident #465)

Date

2015-10-21

Authors

  • jennifer
  • martym
@bcherny
bcherny / using-typescript-and-angular-1.x-in-the-real-world.md
Last active October 9, 2022 12:55
Using Typescript + Angular 1.x in the Real World

Work in progress!

A little while ago I started using Typescript with the Angular 1.5 app I'm working on, to help ease the migration path to Angular 2. Here's how I did it. We'll go example by example through migrating real world code living in a large, mostly non-Typescript codebase.

Let's start with a few of the basic angular building blocks, then we'll go through some of the higher level patterns we derived.

Filters

Javascript

// paste in your console
speechSynthesis.onvoiceschanged = function() {
var msg = new SpeechSynthesisUtterance();
msg.voice = this.getVoices().filter(v => v.name == 'Cellos')[0];
msg.text = Object.keys(window).join(' ');
this.speak(msg);
};