Skip to content

Instantly share code, notes, and snippets.

View leolabs's full-sized avatar
🚀
Hyped

Leo Bernard leolabs

🚀
Hyped
View GitHub Profile
@leolabs
leolabs / cumulative.js
Last active August 28, 2018 13:37
Convert arrays from normal to cumulative and back
// [2, 4, 3, 8] => [2, 6, 9, 17]
const convertToCumulative = points =>
points.reduce((acc, p, i) => acc.concat([
p + (acc.length > 0 ? acc[i - 1] : 0)
]), []);
// [2, 6, 9, 17] => [2, 4, 3, 8]
const convertToNormal = points =>
points.reduce((acc, p, i, ps) => acc.concat([
p - (i > 0 ? ps[i - 1] : 0)
@leolabs
leolabs / README.md
Created September 13, 2018 08:44
Extracting subtitles from a <video> element in JS

Extracting subtitles from a <video> element in JS

While watching today's Apple Keynote I got the idea to statistically analyze

@leolabs
leolabs / Applause Times.json
Created September 16, 2018 22:31
Extracted Data of Apple's September 2018 Keynote
[{
"start": 368.36733333333336,
"end": 375.7413333333334,
"duration": 7.374000000000024,
"text_before": "(Cheers and Applause).",
"text_after": "We love that so many customers"
}, {
"start": 415.1143333333334,
"end": 417.24933333333337,
"duration": 2.134999999999991,
{
"basics": {
"name": "Leo Bernard",
"label": "Software Engineer",
"picture": "https://secure.gravatar.com/avatar/483ab9eaf44f0c80139a4bd8cd24bc13?size=800",
"email": "[email protected]",
"phone": "+49 176 80705009",
"website": "https://leolabs.org",
"summary": "I am passionate about developing websites and web services that leverage the newest technologies to provide the best possible user experience.",
"location": {
@leolabs
leolabs / README.md
Last active June 16, 2020 10:55
Increasing performance of long lists in React using IntersectionObservers

Increasing performance of long lists in React using IntersectionObservers

This component provides a simple way to improve render performance of long lists in React. It's a simple alternative to solutions like react-window that still works well with animation libraries like react-spring or framer-motion.

Example usage:

const List = ({ items }) => (
 
type Falsy = false | 0 | '' | null | undefined;
type NonFalsy<T> = T extends Falsy ? never : T;
/**
* Filter out falsy entries in an array
*/
export function isTruthy<T>(value: T): value is NonFalsy<T> {
return Boolean(value);
}
@leolabs
leolabs / index.html
Created October 18, 2021 15:41
Electron Vibrancy
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Hello World!</title>
<style>
@leolabs
leolabs / Fix Empty Files.gs
Created May 8, 2022 21:22
This script tries to automatically fix empty files in a given Google Drive folder
/** Put the root folder ID here */
const ROOT_FOLDER_ID = "";
/** Set this to false to only see reports of fixed files and errors */
const VERBOSE = true;
/** Keeps track of how many files have been fixed */
let fixedFiles = 0;
/**