Skip to content

Instantly share code, notes, and snippets.

View rayh's full-sized avatar

Ray Yamamoto Hilton rayh

View GitHub Profile
# Import the Kozai Python library
import kozai.compute as kc
# Create a new cluster
cluster = kc.create_dask_cluster()
# Fetch the dask client
dask_client = cluster.client()
# Do some dask work
import kozai.compute as kc
cluster = kc.create_dask_cluster()
dask_client = cluster.client()
print(dask_client)
import dask.bag as db
import numpy as np
from dask.distributed import Client, progress
let myTable = MLDataTable(...)
// Fetch the price column (and all it's values)
let priceColumn = myTable["price"]
// Create a new column that contains values that are the result of
// price * bedroom for each row
let priceTimesBedroomsColumn = myTable["price"] * myTable["bedrooms"]
// Remove rows that contain less that 2 bedrooms
@rayh
rayh / example.js
Created October 8, 2015 00:44
Spawn binary from AWS Lambda
var fs = require('fs');
var Q = require('q');
var spawn = require('child_process').spawn;
var path = require('path');
// Make sure you append the path with the lambda deployment path, so you can
// execute your own binaries in, say, bin/
process.env["PATH"] = process.env["PATH"] + ":" + process.env["LAMBDA_TASK_ROOT"] + '/bin/';
function spawnCmd(cmd, args, opts) {
@rayh
rayh / application.js
Created September 21, 2015 03:57
Initial loading of TJVS app
App.onLaunch = function(options) {
new SimplePage('http://mytvservice.com/home.xml').load();
}
@rayh
rayh / example.js
Last active March 2, 2016 03:26
Example page loader for TVJS/TVML
var SimplePage = function(url) {
var self = this;
function onSelect(event) {
var ele = event.target
var href = ele.getAttribute("href")
if(href) {
new SimplePage(href).load();
}
@rayh
rayh / Example.swift
Created September 21, 2015 03:38
Setup console.log() for TVJS apps
func appController(appController: TVApplicationController, evaluateAppJavaScriptInContext jsContext: JSContext) {
jsContext.evaluateScript("var console = {log: function() { var message = ''; for(var i = 0; i < arguments.length; i++) { message += arguments[i] + ' ' }; console.print(message) } };")
let logFunction: @convention(block) (NSString!) -> Void = { (message:NSString!) in
print("JS: \(message)")
}
jsContext.objectForKeyedSubscript("console").setObject(unsafeBitCast(logFunction, AnyObject.self), forKeyedSubscript:"print")
}

Keybase proof

I hereby claim:

  • I am rayh on github.
  • I am rayh (https://keybase.io/rayh) on keybase.
  • I have a public key whose fingerprint is D532 D25D 30DF 75EF 6CD9 252B A27C 7177 CBBE A264

To claim this, I am signing this object:

@rayh
rayh / gist:994318
Created May 26, 2011 23:10
Adding KVO observation using blocks
// To add observation
self.label1Binding = [self.model addObserverForKeyPath:@"exampleValue1" block:^(NSDictionary *change) {
label1.text = [NSString stringWithFormat:@"%d", self.model.exampleValue1];
}];
// To remove observation
self.label1Binding = nil;