Skip to content

Instantly share code, notes, and snippets.

View bredfern's full-sized avatar

Brian Redfern bredfern

View GitHub Profile
@bredfern
bredfern / GStreamer-1.0 some strings.sh
Created October 25, 2017 08:18 — forked from strezh/GStreamer-1.0 some strings.sh
GStreamer-1.0 personal cheat sheet
#!/bin/bash
# play YUV444 FULL HD file
gst-launch-1.0 -v filesrc location=size_1920x1080.yuv ! \
videoparse width=1920 height=1080 framerate=25/1 format=GST_VIDEO_FORMAT_Y444 ! \
videoconvert ! \
autovideosink
# play YUV422 FULL HD file
gst-launch-1.0 -v filesrc location=size_1920x1080.yuv ! \
@bredfern
bredfern / index.html
Created November 6, 2018 19:40
VU meter
<body layout="column stretch-stretch">
<svg class='defs-only'>
<defs>
<g id="JB">
<path id="jb-profil"
stroke="#000" fill="#fff" stroke-miterlimit="10" d="M258.9,94.3c1,0.8,1.199,2.6,0.699,6.4
c-0.699,5.6-0.3,6.2,4.801,7.3c2.5,0.5,3.1,1.1,3.1,3c0,2.6,2,3.1,5.8,1.5c1.7-0.7,1.8-0.3,1.601,4.1c-0.301,6.2,0.6,8.8,3.399,10.2
c2.601,1.3,10.2,2.9,17.2,3.7c9,1.1,13.2,2.6,16.6,6.1l3.2,3.3l-2.6,1c-1.5,0.6-2.7,1.5-2.7,2c0,2.1,6.5,8.3,11,10.6
c5.2,2.6,6.3,3.7,7.8,8c0.5,1.6,2.2,6.1,3.601,10c7,18.8,6.199,35.9-1.9,44.5c-1.3,1.4-2.5,3.9-2.8,5.6c-0.7,4.4-2,6.6-6.9,10.9
@bredfern
bredfern / gist:a63e5e6e8564991d22b50124965f5614
Created September 14, 2019 16:53
Flatting lists with reduce
While not every language uses the "reduce" keyword you find the concept of reduction in different languages that implement functional code features so in c# its called using the Aggregate keyword but the concept is similar.
So what is a reduction and how does it help us flatten multidimensional lists in general?
You basically get to call a function on every item in an array however you get some special tools to keep track of this array so you have an accumulator that is like a bag where all the values drop in after each array is iterated, you have a current value placeholder an index which tells you which item you're on in the array and you have the ability to set an initial value to send to the first callback call.
Here's an example of how reduce is used with a complex array to flatten it into a simple array:
function flattenDeep(arr1) {
return arr1.reduce((acc, val) => Array.isArray(val) ? acc.concat(flattenDeep(val)) : acc.concat(val), []);
}
@bredfern
bredfern / css-range-slider-vertical.markdown
Created October 19, 2018 21:38
CSS Range Slider vertical
@bredfern
bredfern / index.html
Created October 19, 2018 21:34
WaveSurfer.js - equalizer with volume slider
<h1>WaveSurfer.js - equalizer with volume slider</h1>
<h4>
<a target="_blank" href="https://github.com/entonbiba/examples/blob/master/wavesurfer/equalizer-with-volume-slider">Example reference on github.com</a>
</h4>
<div id="waveform"></div>
<div class="container" style="text-align: center">
<button onclick="wavesurfer.playPause()">
@bredfern
bredfern / html5-audio-visualizer.markdown
Created October 18, 2018 20:14
HTML5 Audio Visualizer
/*
Functional programming in C
```````````````````````````
This is an example of how to use executable memory to get partial function
application (i.e. bind1st()) in C. (Well, this actually only compiles as C++
since i'm using a varargs typedef, but there's no classes or templates.)
To proceed, we need to be comfortable with the cdecl and stdcall calling
conventions on x86, and just a little assembly.
@bredfern
bredfern / jquery.scrollToTop.js
Created July 13, 2017 03:02 — forked from monkeymonk/jquery.scrollToTop.js
ES6 jQuery plugin definition
import $ from 'jquery';
import plugin from './plugin';
class ScrollToTop {
constructor(element, options) {
const $element = $(element);
$(window).scroll(function () {
if ($(this).scrollTop() > options.offset) {
$element.fadeIn();
@bredfern
bredfern / index.html
Created July 6, 2017 18:27
Simple clock using requestAnimationFrame
<div id="clock"><span id="hours">00</span>:<span id="minutes">00</span>:<span id="seconds">00</span>.<span id="milliseconds">000</span></div>
@bredfern
bredfern / function_invocation.js
Created April 3, 2017 03:51 — forked from myshov/function_invocation.js
11 Ways to Invoke a Function
console.log(1);
(_ => console.log(2))();
eval('console.log(3);');
console.log.call(null, 4);
console.log.apply(null, [5]);
new Function('console.log(6)')();
Reflect.apply(console.log, null, [7])
Reflect.construct(function(){console.log(8)}, []);
Function.prototype.apply.call(console.log, null, [9]);
Function.prototype.call.call(console.log, null, 10);