Skip to content

Instantly share code, notes, and snippets.

@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" />
@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 / 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 / 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 / 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 / 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 / Clock.jsx
Created December 14, 2018 19:00
Async Clock.jsx
class Clock extends React.Component {
constructor(props) {
super(props);
this.intervalId = undefined;
this.state = { time: new Date() };
}
componentWillUnmount() {
this.stopTick();
}
@dezfowler
dezfowler / Clock.jsx
Created December 14, 2018 19:04
Observable Clock.jsx
class Clock extends React.Component {
constructor(props) {
super(props);
console.log('new');
this.state = { time: new Date() };
}
componentDidMount() {
this.propsChangeSubject = new Subject();
this.subscription = this.propsChangeSubject
@dezfowler
dezfowler / Clock.jsx
Last active March 29, 2019 18:13
Simple rxified Clock
const { interval, empty } = require('rxjs');
const { switchMap, startWith, map } = require('rxjs/operators');
const Clock = rxify((initialProps, prop$) => {
return prop$
.pipe(
switchMap(props => props.running ? interval(0, 1000) : empty()),
startWith(1),
map(_ => (<span className="time">{new Date().toLocaleTimeString()}</span>))
)
@dezfowler
dezfowler / redux-obs-example.js
Created April 4, 2019 07:14
redux-observable simple example
import { ofType } from 'redux-observable';
const pingEpic = action$ => action$.pipe(
ofType('PING'),
delay(1000), // Asynchronously wait 1000ms then continue
mapTo({ type: 'PONG' })
);