Skip to content

Instantly share code, notes, and snippets.

View thomasnield's full-sized avatar

Thomas Nield thomasnield

  • Frisco, Texas (United States)
View GitHub Profile
/* Include these Gradle dependencies
compile 'no.tornado:tornadofx:1.5.4'
compile 'com.github.thomasnield:rxkotlinfx:0.1.4'
compile 'io.reactivex:rxkotlin:0.60.0'
*/
class MyView : View() {
val items = FXCollections.observableArrayList("Alpha","Beta","Gamma",
"Delta","Epsilon","Zeta","Eta")
@thomasnield
thomasnield / rxjava_javafx_autcomplete.txt
Last active September 8, 2016 02:52
RxJava and JavaFX Autocomplete test
/* Include these Gradle dependencies
compile 'no.tornado:tornadofx:1.5.4'
compile 'com.github.thomasnield:rxkotlinfx:0.1.4'
compile 'io.reactivex:rxkotlin:0.60.0'
*/
import javafx.scene.input.KeyEvent
import rx.javafx.kt.events
import rx.javafx.kt.observeOnFx
import rx.lang.kotlin.toObservable
from rx import Observable, Observer
from collections import defaultdict
users = [
{ "id" : 0, "name" : "Hero" },
{ "id" : 1, "name" : "Dunn" },
{ "id" : 2, "name" : "Sue" },
{ "id" : 3, "name" : "Chi" },
{ "id" : 4, "name" : "Thor" },
{ "id" : 5, "name" : "Clive" },
import org.apache.spark.SparkConf
import org.apache.spark.api.java.JavaSparkContext
import kotlin.reflect.KClass
//collecting useful Kotlin extension functions for Spark
fun SparkConf.registerKryoClasses(vararg args: KClass<*>) = registerKryoClasses(args.map { it.java }.toTypedArray())
@thomasnield
thomasnield / us_states.txt
Last active November 14, 2016 02:40
us_states
Alabama
Alaska
Arizona
Arkansas
California
Colorado
Connecticut
Delaware
Florida
Georgia
@thomasnield
thomasnield / reactivex_live_twitter_stream.py
Created November 14, 2016 02:41
ReactiveX Live Twitter Feed Using RxPy
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
import json
from rx import Observable
#Variables that contains the user credentials to access Twitter API
#Create your own at https://apps.twitter.com/
access_token = "CONFIDENTIAL"
@thomasnield
thomasnield / rxpy_word_counter.py
Last active November 19, 2016 03:48
Scheduled Reactive Word Counter using RxPy
# Schedules a reactive process that counts the words in a text file every three seconds,
# but only prints it as a dict if it has changed
from rx import Observable
import re
import signal
def word_counter(file_name):
file = open(file_name)
@thomasnield
thomasnield / countdownlatch_rxjava.java
Created January 14, 2017 02:22
Using CountDownLatch with RxJava
import io.reactivex.Observable;
import io.reactivex.schedulers.Schedulers;
import java.util.concurrent.CountDownLatch;
public class Launcher {
public static void main(String[] args) {
Observable<Integer> source = Observable.range(1,10);
CountDownLatch latch = new CountDownLatch(1);
@thomasnield
thomasnield / rxpy_iterating_and_filtering_files_recursively.py
Last active February 21, 2017 00:24
Iterating Files Recursively with RxPy
from rx import Observable
import os
def recursive_files_in_directory(folder):
def emit_files_recursively(observer):
for root, directories, filenames in os.walk(folder):
for directory in directories:
observer.on_next(os.path.join(root, directory))
@thomasnield
thomasnield / rxjava2_backpressure_demo.java
Created March 2, 2017 20:46
rxjava2_backpressure_demo
import io.reactivex.Flowable;
import io.reactivex.Observable;
import io.reactivex.schedulers.Schedulers;
import java.util.concurrent.CountDownLatch;
public class Launcher {
public static void main(String[] args) {
final CountDownLatch latch = new CountDownLatch(1);