Skip to content

Instantly share code, notes, and snippets.

View bredfern's full-sized avatar

Brian Redfern bredfern

View GitHub Profile
@bredfern
bredfern / Flattening an arbitrarily complex list with Ruby
Last active October 7, 2016 04:21
The polish method is used to take a really messy array of arbitrarily complex nested items and produce a simple array of integers as a result. You can statically call this from the module, SmoothArray.polish(my_complex_array).
module SmoothArray
# Sample usage:
# require SmoothArray
# ugly_array = [[1,2,[3]],4]
# result = []
# result = SmoothArray.polish(ugly_array)
# result.each do |i|
# puts i.to_s
# end
@bredfern
bredfern / tf_beam_decoder.py
Created November 7, 2016 19:41 — forked from nikitakit/tf_beam_decoder.py
Tensorflow Beam Search
"""
Beam decoder for tensorflow
Sample usage:
```
beam_decoder = BeamDecoder(NUM_CLASSES, beam_size=10, max_len=MAX_LEN)
_, final_state = tf.nn.seq2seq.rnn_decoder(
[beam_decoder.wrap_input(initial_input)] + [None] * (MAX_LEN - 1),
@bredfern
bredfern / gist.md
Last active November 28, 2016 02:09

Bloc Gists

Javascript

With Javascript we have to learn to think in functions. You got it partly right with the way you attach your behavior to the button click.

But we need a named function to wrap your code to get it behave as expected.

This is how your code needs to be changed into order to work correctly:

@bredfern
bredfern / css-5-steps-progress-bar.markdown
Created December 5, 2016 21:30
CSS 5 steps progress bar
@bredfern
bredfern / index.html
Last active December 7, 2016 07:40
Sortable Circle on the end of a Div
<div id="content">
<ul id="tasks">
<li>
<div class="outer-circle">
<div class="inner-circle orange-bg">
<span class="inside-content"></span>
</div>
Broken Iphone <i class="material-icons right gray">rss_feed</i>
</div>
@bredfern
bredfern / index.js
Created January 30, 2017 23:59 — forked from Fedia/index.js
🌀 Eddy: Static Websites For The Rest of Us
//- polyfills
'use strict';
(function (p) {
if (!p.matches) p.matches = p.webkitMatchesSelector || p.mozMatchesSelector || p.msMatchesSelector;
})(Element.prototype);
if (typeof window.CustomEvent !== 'function') {
window.CustomEvent = function (name, p) {
p = p || {};
@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);
@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 / 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 / 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 ! \