Skip to content

Instantly share code, notes, and snippets.

View tehmou's full-sized avatar

Timo Tuominen tehmou

  • London, United Kingdom
View GitHub Profile
@tehmou
tehmou / immutableUtils.js
Created July 31, 2017 20:00
Check a JS immutable object for plain mutable objects
import { Iterable } from 'immutable'
function checkIsImmutable(obj, path = '') {
if (Iterable.isIterable(obj)) {
obj.keySeq().forEach(key => {
checkIsImmutable(obj.get(key), path + '.' + key);
});
} else if (typeof obj === 'object' && obj !== null) {
console.warn(path + ' was not immutable');
} else {
@tehmou
tehmou / MainActivity.java
Created February 21, 2017 14:04
RxJava Android example of .withLatestFrom usage
package com.tehmou.book.chapter7coffeebreak;
import android.support.v4.util.Pair;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import com.jakewharton.rxbinding.view.RxView;
import com.jakewharton.rxbinding.widget.RxTextView;
@tehmou
tehmou / gist:143f2e056e3768d4549b
Created March 13, 2015 09:20
android-meetup-rxjava-challenge solution
package com.futurice.project;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import rx.Scheduler;
import rx.functions.Func1;
public class Solution {
@tehmou
tehmou / gist:fd44b6f78acee427a076
Created January 10, 2015 22:20
RxJava .concat lost observables riddle
Let's say we have this code that takes a list, makes the items asynchronous observables (i. e. network requests) and then concatenates the results:
final List<String> list = Arrays.asList("1", "2", "3", "4", "5", "6");
Log.d(TAG, "start: " + list);
Observable.concat(
Observable.from(list)
.map(s -> {
final Subject<String, String> subject = PublishSubject.create();
final int delay = (list.size() - list.indexOf(s)) * 100;
@tehmou
tehmou / adobe-illustrator-rasterize-script
Created January 9, 2013 09:53
Script for Adobe Illustrator that rasterizes all layers and groups the name of which starts with "rasterize". To run save as .jsx and open from File/Scripts/Other Script... or run with ExtendScript Toolkit.
var rasterizeOptions = new RasterizeOptions();
rasterizeOptions.transparency = true;
function process (item) {
$.writeln(item.name);
if (/^rasterize/.exec(item.name)) {
app.activeDocument.rasterize(item, null, rasterizeOptions);
} else {
if (item.layers) {
for (var i = 0; i < item.layers.length; i++) {