Skip to content

Instantly share code, notes, and snippets.

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.

@meng-hui
meng-hui / gist:10335928
Created April 10, 2014 01:36
Convert doc file to markdown
brew install haskell-platform
# add cabal to PATH
export PATH=$HOME/.cabal/bin:$PATH
# or check if you already have it
echo $PATH
# install pandoc
cabal update
cabal install pandoc
@meng-hui
meng-hui / PerformBuild.cs
Last active June 13, 2024 15:16
Automated Unity Build from git repository to apk, xcode projects for use in conjunction with Jenkins. Contains Unity Editor script to collect the scenes, set the build settings, set the build location and an ant script to build the Unity project on the command line.
using UnityEditor;
using System.IO;
using System.Collections;
using UnityEngine;
using System.Collections.Generic;
class PerformBuild
{
private static string BUILD_LOCATION = "+buildlocation";
@meng-hui
meng-hui / resize_icons.rb
Last active November 14, 2017 15:17
Populate a Unity generated Xcode project with all icons for a Universal build from a single icon file. In the folder with the xcode project, execute this script and by default looks for a file named icon_1024x1024.png and places all the icons needed into Unity-iPhone/Images.xcassets/AppIcon.appiconset/ . Requires gd and fastimage_resize gem
#!/usr/bin/env ruby
# make sure you have gd and fastimage_resize
# brew install gd
# sudo gem install fastimage_resize
require 'fastimage_resize'
require 'optparse'
require 'json'
require 'fileutils'
require 'rubygems'
require 'mechanize'
FIRST_NAME = 'FIRST_NAME'
LAST_NAME = 'LAST_NAME'
PHONE = 'PHONE'
EMAIL = 'EMAIL@provider.com'
PARTY_SIZE = 2
SCHEDULE_RANGE = { :start_time => '19:00', :end_time => '20:30' }
@meng-hui
meng-hui / gist:3311578
Created August 10, 2012 06:03
Allow only numeric input in a windows form control
public static void AllowOnlyNumericInput (object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != '.')
{
e.Handled = true;
}
//only allow one decimal point
if (e.KeyChar == '.' && (sender as System.Windows.Forms.TextBox).Text.IndexOf('.') > -1)
{
@meng-hui
meng-hui / gist:3311509
Created August 10, 2012 05:56
Inno Setup Script starting point
; Starting point of creating an Inno Setup Script
; See the Inno Setup documentation at http://www.jrsoftware.org/
#define SourceFileDir ""
#define IncludeFramework true
#define IsExternal "external"
[setup]
;name of your application
AppName=
@meng-hui
meng-hui / gist:3282984
Created August 7, 2012 08:07
C# language features
/* A place to store what I have learned about advanced C# features over time
* a longer and better list available here http://stackoverflow.com/questions/9033/hidden-features-of-c
*/
/* abstract - use in a class declaration to indicate that a class is intended only to be a base class of other classes
* abstract - Members marked as abstract, or included in an abstract class, must be implemented by classes that derive from the abstract class.
* virtual - used to modify a method, property, indexer, or event declaration and allow for it to be overridden in a derived class
*/
// The as operator is like a cast operation. if the conversion is not possible, as returns null
@meng-hui
meng-hui / Unmanaged dll symbol export and import
Created August 7, 2012 02:23
Configuring a Visual Studio Project to create a managed no entry c++ dll wrapper of an unmanaged c++ dll
// defining what symbols to export or import
// more details here http://www.codeguru.com/cpp/cpp/cpp_managed/interop/article.php/c6867/Consuming-Unmanaged-C-Class-Libraries-from-NET-Clients.htm
#ifdef UNMANAGED_EXPORTS
#define UNMANAGED_API __declspec(dllexport)
#else
#define UNMANAGED_API __declspec(dllimport)
#endif