Skip to content

Instantly share code, notes, and snippets.

View RobThree's full-sized avatar
🤙
Being awesome

Rob Janssen RobThree

🤙
Being awesome
View GitHub Profile
@RobThree
RobThree / introrx.md
Last active August 29, 2015 14:06 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Program
{
static void Main(string[] args)
{
var duplicates = new DirectoryInfo(@"G:\sampling")
@RobThree
RobThree / ratelimiter.php
Last active December 16, 2019 21:34
Simple, rude, rate limiter (using memcache).
<?php
/* Very simple, crude, rate limiter */
/*
Assumes _MEMCACHEDSITEPREFIX, _MEMCACHEDHOST and _MEMCACHEDPORT are `defined`:
define('_MEMCACHEDHOST', '127.0.0.1');
define('_MEMCACHEDPORT', 11211);
define('_MEMCACHEDSITEPREFIX', 'mysite');
*/
@RobThree
RobThree / exampleclassesandinterfaces.cs
Created November 1, 2013 10:50
An improvement upon http://stackoverflow.com/a/4100126/215042. This factory can be used as a generic factory. Improvements are, amongst others: • Generics • Being able to specify case(in)senstivity when resolving instances • Constructor overloads; the default will assume the Executing Assembly, other assemblies can be passed using an overload of…
public interface IFood
{
bool IsTasty { get; }
}
public class Hamburger : IFood
{
public bool IsTasty { get { return true; } }
}
using System;
using System.Linq;
using System.Text;
//Demonstrate usage
class Program
{
static void Main(string[] args)
{
var ww = new WhitespaceWatermarker();
@RobThree
RobThree / linqhelpers.cs
Last active April 8, 2023 21:39
Linq extensions: Diff, ToChunks and ExecuteChunked
using System;
using System.Linq;
using System.Collections.Generic;
//Sample program demonstrating the linq extensions (below Progam class)
class Program
{
static void Main(string[] args)
{
//Demonstrate Diff
@RobThree
RobThree / PhonenumberGrabber.cs
Last active December 13, 2015 16:58
Tries to grab phonenumbers from an active control (selected text) in an active window. Uses a TextSelectionReader internally (see https://gist.github.com/RobThree/4943725).
using System;
using System.Linq;
using System.Text.RegularExpressions;
/// <summary>
/// Tries to grab phonenumbers from an active control (selected text) in an active window. Uses
/// a <see cref="TextSelectionReader"/> internally.
/// </summary>
public class PhonenumberGrabber
{
@RobThree
RobThree / SoapClientEx.class.php
Created November 20, 2012 13:23
PHP SoapClient with timeout and authentication
<?php
//**NOTE**: This has *NOT* been tested yet; please provide feedback in the comments
//Drop-in replacement for PHP's SoapClient class supporting connect and response/transfer timeout and authentication
//Usage: Exactly as PHP's SoapClient class, except that some new options are available:
// timeout The response/transfer timeout in milliseconds; 0 == default SoapClient / CURL timeout
// connecttimeout The connection timeout; 0 == default SoapClient / CURL timeout
// sslverifypeer FALSE to stop SoapClient from verifying the peer's certificate
// sslversion The SSL version (2 or 3) to use. By default PHP will try to determine this itself, although in some cases this must be set manually
// sslverifyhost 1 to check the existence of a common name in the SSL peer certificate. 2 to check the existence of a common name and also verify that
@RobThree
RobThree / hotlinkchecker.class.php
Created August 30, 2012 22:15
PHP Hotlink checker
<?php
/*
* Class for checking if images are hotlink-protected
*/
class HotlinkChecker {
// You can set this property to any random domain; this will be sent
// as the referring domain to check the "hotlink protected" version
public $testhost = 'www.somerandomdomain.com';
// You can change (or add/remove) any cURL options through this property
@RobThree
RobThree / wavefilereader.class.php
Created August 29, 2012 17:22
PHP WAVE file reader / parser
<?php
/**
* WaveFileReader; a simple class to read/parse WAVE file
* (c)2012 Rob Janssen / https://github.com/RobThree
*
* Based on https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
*
* USAGE:
*
* $wav = WaveFileReader::ReadFile('/path/to/test.wav');