Skip to content

Instantly share code, notes, and snippets.

@pietrop
pietrop / modern_js.md
Created June 4, 2021 18:20 — forked from gaearon/modern_js.md
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav
@pietrop
pietrop / The Technical Interview Cheat Sheet.md
Created May 11, 2021 21:29 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

@pietrop
pietrop / ffmpeg.md
Created February 5, 2021 18:27 — forked from dvlden/ffmpeg.md
Convert video files to MP4 through FFMPEG

This is my personal list of functions that I wrote for converting mov files to mp4!

Command Flags

Flag Options Description
-codec:a libfaac, libfdk_aac, libvorbis Audio Codec
-quality best, good, realtime Video Quality
-b:a 128k, 192k, 256k, 320k Audio Bitrate
-codec:v mpeg4, libx264, libvpx-vp9 Video Codec
@pietrop
pietrop / getMediaType.js
Created February 2, 2021 01:21
Check the media type using the file extension of a url, works client side
import path from 'path';
const getMediaType = (mediaUrl) => {
const clipExt = path.extname(mediaUrl);
let tmpMediaType = 'video';
if (clipExt === '.wav' || clipExt === '.mp3' || clipExt === '.m4a' || clipExt === '.flac' || clipExt === '.aiff') {
tmpMediaType = 'audio';
}
return tmpMediaType;
};
@pietrop
pietrop / wordsTsvSerializer.js
Last active November 12, 2020 14:09
serialize and de-serialize array of words into a tsv string
/**
* Helper functions to serialize and de-serialize array of words into a tsv string
example words list
```
[
{
"id": 0,
"start": 1.4,
"end": 3.9,
"text": "Can"

Pluck Unique Values from Array of Javascript Objects

Implementation

const pluck = key => array => Array.from(new Set(array.map(obj => obj[key])));

Usage

/*
* CSS Responsive media queries
*/
/*
* Extra large devices
* large laptops and desktops, 1200px and up
*/
/* @media (min-width: 1200px) {
@pietrop
pietrop / github-pr.md
Created January 27, 2020 01:27
To checkout a PR from another repo. Eg you fork a repo you don’t own, or are not a member of. Someone else makes a PR to the original repo and you want to evaluate it locally in your fork.

To checkout a PR from another repo. Eg you fork a repo you don’t own, or are not a member of. Someone else makes a PR to the original repo and you want to evaluate it locally in your fork.

Add a remote upstream repository

git remote add UPSTREAM git@github.com/USERNAME:REPONAME

Check that it has been added - optional

@pietrop
pietrop / wordDuration.js
Created January 16, 2020 18:18
heuristic to estimate duration of a word, based on looking across a number of transcripts
// Chris Baume BBC R&D heuristic to estimate duration of a word, based on looking across a number of transcripts.
// from https://github.com/chrisbaume/webaligner/blob/9458df57d854e9df64a54bc23a7f0856de49730f/webaligner.js#L7
// estimates the duration of a word, in seconds
function wordDuration(word) {
return 0.08475 + (0.05379 * word.length);
}