Skip to content

Instantly share code, notes, and snippets.

View adammendoza's full-sized avatar

Adam J. Mendoza adammendoza

  • San Francisco, Calif.
View GitHub Profile
const serviceValues = [ 2, 3, 4 ];
// convert values array into a stream of individual values: Obs[...num]
return Observable.of(serviceValues)
// call service on each value and get Observable in return: Obs[Obs[newValFromService]]
.map(val => serviceApi(val))
// convert stream of observables into a stream of a single array of observables Obs[ [Obs[newVal]] ]
.toArray()
// trigger all the service calls with maximum concurrenct
.switchMap((serviceCalls) => Observable.combineLatest(serviceCalls))
.subscribe(newVals => console.log('new values from server: ', newVals)) // [...{id: 2, ...data}, {id: 3, ...dat}]
@PhilippLgh
PhilippLgh / Bot.js
Created April 18, 2016 13:15
A Telegram Speech-To-Text bot that uses Watson
var Bot = require('node-telegram-bot-api')
var watson = require('watson-developer-cloud');
var request = require('request');
var config = require('./config');
var speech_to_text = watson.speech_to_text({
username: config.watson.username,
password: config.watson.password,
version: 'v1',
url: 'https://stream.watsonplatform.net/speech-to-text/api'
@Ashton-W
Ashton-W / ExpectationDelegateProxy.h
Last active October 10, 2017 15:37
Implementation of an XCTestExpectation for delegate calls. More here http://www.ashton-w.net/2016/01/23/Asynchronous-Testing.html
#import <Foundation/Foundation.h>
#import <XCTest/XCTest.h>
NS_ASSUME_NONNULL_BEGIN
@interface ExpectationDelegateProxy : NSProxy
@property (nonatomic) SEL selector;
@property (nonatomic) Protocol *protocol;
@property (nonatomic) XCTestExpectation *expectation;
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import os
def computeCost(X, y, theta):
inner = np.power(((X * theta.T) - y), 2)
return np.sum(inner) / (2 * len(X))
def gradientDescent(X, y, theta, alpha, iters):
@lolzballs
lolzballs / HelloWorld.java
Created March 22, 2015 00:21
Hello World Enterprise Edition
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
public class HelloWorld{
private static HelloWorld instance;
public static void main(String[] args){
instantiateHelloWorldMainClassAndRun();
@TiagoGouvea
TiagoGouvea / CardContainer.java
Last active June 9, 2016 00:29
Like and Unlike alpha view effect - kikoso/Swipeable-Cards
@Override
public boolean onTouchEvent(MotionEvent event) {
if (mTopCard == null) {
return false;
}
if (mGestureDetector.onTouchEvent(event)) {
return true;
}
Log.d("Touch Event", MotionEvent.actionToString(event.getActionMasked()) + " ");
final int pointerIndex;
@jeancarl
jeancarl / gist:a3eb3c9932d8c9eaa05a
Last active August 29, 2015 14:16
DQuid PHP library
<?php
/**
* DQuid Library
*
* Retrieves values from a Bay Tek Game machine given the serial number.
* /
class Dquid
{
var $serial_number;
@pmuellr
pmuellr / flattened-callbacks.js
Created January 9, 2015 13:57
another way to flatten your JavaScript callback pyramids
// another kind of flattening; see: http://blog.vullum.io/javascript-flow-callback-hell-vs-async-vs-highland/
var express = require('express')
var fs = require('fs')
var app = express()
app.post('/process-file', onProcessFile)
function onProcessFile(req, res) {
var inputFile = 'input.txt'
// Node.js CheatSheet.
// Download the Node.js source code or a pre-built installer for your platform, and start developing today.
// Download: http://nodejs.org/download/
// More: http://nodejs.org/api/all.html
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@chrisdone
chrisdone / AnIntro.md
Last active March 24, 2024 21:13
Statically Typed Lisp

Basic unit type:

λ> replTy "()"
() :: ()

Basic functions: