Skip to content

Instantly share code, notes, and snippets.

@iansinnott
iansinnott / rx-file-reader.js
Created June 5, 2017 19:36
A simple Rx abstraction over the FileReader API
/**
* Read the text contents of a File or Blob using the FileReader interface.
* This is an async interface so it makes sense to handle it with Rx.
* @param {blob} File | Blob
* @return Observable<string>
*/
const readFile = (blob) => Observable.create(obs => {
if (!(blob instanceof Blob)) {
obs.error(new Error('`blob` must be an instance of File or Blob.'));
return;
@staltz
staltz / introrx.md
Last active May 3, 2024 13:00
The introduction to Reactive Programming you've been missing
@hugorodgerbrown
hugorodgerbrown / md_to_rst.sh
Last active March 26, 2023 16:57
Shell script for converting a batch of *.md files into *.rst using pandoc.
# This script was created to convert a directory full
# of markdown files into rst equivalents. It uses
# pandoc to do the conversion.
#
# 1. Install pandoc from http://johnmacfarlane.net/pandoc/
# 2. Copy this script into the directory containing the .md files
# 3. Ensure that the script has execute permissions
# 4. Run the script
#
# By default this will keep the original .md file
@naholyr
naholyr / A_Sample.md
Last active December 14, 2015 11:48
A dumb event emitter service for Angular, primary usage is to allow transparent communication between controllers → http://jsfiddle.net/NuCjC/1/

Sample usage on JSFiddle

Disclaimer

This may be a dumb solution, you'd better use $rootScope.$on(event, handler) and $rootScope.$emit(event, args…) and not use a third-party service.

My solution will bring you:

  • support for off() if you really want to clean up your event handlers
  • maybe a conceptually better solution than using scopes, as with a service you make yourself independant from your view
@vojtajina
vojtajina / all-templates.html
Created August 15, 2012 00:00
AngularJS: load all templates in one file
<script type="text/ng-template" id="one.html">
<div>This is first template</div>
</script>
<script type="text/ng-template" id="two.html">
<div>This is second template</div>
</script>