Skip to content

Instantly share code, notes, and snippets.

View markthethomas's full-sized avatar

Mark Thomas markthethomas

View GitHub Profile
@markthethomas
markthethomas / gist:6b114f5fd7d55d29eca3
Created May 31, 2014 19:28
Roots gruntfile with imagemin and autoprefixer
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: [
'Gruntfile.js',
@markthethomas
markthethomas / index.html
Created June 16, 2014 17:26
Re-center google map on window resize
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html {
height: 100%
}
body {
@markthethomas
markthethomas / gruntfile.js
Created June 27, 2014 17:48
Quick grunt-spritesmith config
//..........
sprite: {
all: {
src: 'app/images/FILE_PATH_HERE/*.png',
destImg: 'app/images/spritesheet.png',
destCSS: 'app/styles/_sprites.scss',
'padding': 5,
'cssFormat': 'css',
// OPTIONAL: Map variable of each sprite
@markthethomas
markthethomas / jquery.spin.js
Created July 10, 2014 19:01
jquery.spin.js modification
//lines 100-113 of jquery.spin.js
lines: 13, // The number of lines to draw
length: 0, // The length of each line
width: 8, // The line thickness
radius: 30, // The radius of the inner circle
corners: 1, // Corner roundness (0..1)
rotate: 34, // The rotation offset
direction: 1, // 1: clockwise, -1: counterclockwise
color: '#68d274', // #rgb or #rrggbb or array of colors
speed: 0.8, // Rounds per second
@markthethomas
markthethomas / keybase.md
Created August 25, 2014 23:24
Keybase.md

Keybase proof

I hereby claim:

  • I am markthethomas on github.
  • I am markthomas (https://keybase.io/markthomas) on keybase.
  • I have a public key whose fingerprint is 1320 1145 D2B8 3FA3 C0B6 576F 008D AAF5 7667 40DC

To claim this, I am signing this object:

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

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.

@markthethomas
markthethomas / callSite.js
Created July 13, 2015 22:00
Name example -- calbacks
'use strict';
require('babel/register');
var ourModule = require('./example'),
chalk = require('chalk');
ourModule('Mark', function(err, message) {
if (err) {
console.error(err);
@markthethomas
markthethomas / Dockerfile
Last active October 10, 2015 16:01
Example node dockerfile
#using debian:jessie for it's smaller size over ubuntu
FROM debian:jessie
# Replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# Set environment variables
ENV appDir /var/www/app/current
# Run updates and install deps
@markthethomas
markthethomas / count.js
Created September 24, 2015 15:56
Counting Arrays one-liner(s)
function count(array) {
return array.reduce((accumulator, current) => {
accumulator[current] = ++accumulator[current] || 1;
return accumulator;
}, {});
}
// Explanation: takes in an array and iterates over it with the reduce function. A callback is fired on each
// item in the array, with an accumulator and current value as args. The key thing is seeing that the default value of
// the accumulator is set to an object that we can write to ({}). Then, as we iterate through the values,
@markthethomas
markthethomas / favorites.json
Created November 1, 2015 23:33
Npm Favorites
{
"global": {
"devDependencies": {
"babel": "^6.0.14",
"eslint": "^1.8.0",
"mocha": "^2.3.3",
"pm2": "^0.15.8",
"bluebird": "^3.0.5"
},
"dependencies": {