Skip to content

Instantly share code, notes, and snippets.

@dezfowler
dezfowler / Clock.jsx
Last active December 13, 2018 19:17
rxified Clock
const Clock = rxify((initialProps, prop$) => {
return prop$
.pipe(
filter(pd => pd.differences.includes('running')),
map(pd => pd.next.running),
switchMap(running => running ? interval(0, 1000) : empty()),
startWith(1),
map(_ => (<span className="time">{new Date().toLocaleTimeString()}</span>))
)
});
@dezfowler
dezfowler / BlockingCollectionExample.cs
Created January 9, 2018 23:36
Throttling with BlockingCollection example
using System;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace myApp
{
class Program
@dezfowler
dezfowler / jsonapi-homepage-example.json
Created February 17, 2017 22:31
json:api examples
{
"links": {
"self": "http://example.com/articles",
"next": "http://example.com/articles?page[offset]=2",
"last": "http://example.com/articles?page[offset]=10"
},
"data": [{
"type": "articles",
"id": "1",
"attributes": {
@dezfowler
dezfowler / Sequence.cs
Created May 15, 2010 23:53
Allows Silverlight UI and code operations to be executed sequentially.
/// <summary>
/// Allows UI and code operations to be executed sequentially.
/// </summary>
public class Sequence
{
private Sequence _start;
private Sequence _next;
private bool _alreadyRun = false;
public Sequence()
@dezfowler
dezfowler / Currying in C# with implicit.cs
Created April 13, 2010 14:05
Attempt at some currying with C#
using System;
using System.Collections.Generic;
public class MyClass
{
public static void RunSnippet()
{
// http://blog.robustsoftware.co.uk/2010/04/currying-with-c.html
// http://gist.github.com/360105
@dezfowler
dezfowler / Chromecast.xml
Created July 5, 2015 23:11
Edited version of standard Plex Chromecast profile which sets the music transcode target to WAV/PCM instead of MP3. Lossless files like FLAC will transcode in full quality (unless they have higher bit depth than 16bit due to s16le profile).
<?xml version="1.0" encoding="utf-8"?>
<Client name="Chromecast">
<!-- Author: Derek Fowler. -->
<TranscodeTargets>
<VideoProfile protocol="http" container="mkv" codec="h264" audioCodec="aac" context="streaming">
<Setting name="VideoEncodeFlags" value="-x264opts bframes=3:cabac=1" />
</VideoProfile>
<MusicProfile container="wav" codec="pcm_s16le"/>
<PhotoProfile container="jpeg" />
<SubtitleProfile container="ass" codec="ass" />