Skip to content

Instantly share code, notes, and snippets.

View marcprux's full-sized avatar
🔆

Marc Prud'hommeaux marcprux

🔆
  • New England
  • 16:01 (UTC -04:00)
View GitHub Profile
/// A calculation that holds a left term, a right term, and an operation
struct Calc<T> {
var lt: () -> T
var op: (T, T) -> T
var rt: () -> T
init(lt: () -> T, op: (T, T) -> T, rt: () -> T) {
self.lt = lt
self.op = op
self.rt = rt
@marcprux
marcprux / nilter.swift
Created July 23, 2014 17:53
Create array of instances by unwrapping optionals
/// converts an array of optionals to an array of non-optionals by filtering out nil
public func nilter<T>(var array: Array<Optional<T>>) -> Array<T> {
return array.filter { $0.getLogicValue() }.map { $0! }
}
@marcprux
marcprux / XCTAssertEqualOptional.swift
Created July 23, 2014 17:48
XCTAssertEqual that handles optional unwrapping
/// like XCTAssertEqual, but handles optional unwrapping
public func XCTAssertEqualOptional<T: Any where T: Equatable>(expression1: @auto_closure () -> T?, expression2: @auto_closure () -> T?, _ message: String? = nil, file: String = __FILE__, line: UInt = __LINE__) {
if let exp1 = expression1() {
if let exp2 = expression2() {
XCTAssertEqual(exp1, exp2, message ? message! : "", file: file, line: line)
} else {
XCTFail(message ? message! : "exp1 != nil, exp2 == nil", file: file, line: line)
}
} else if let exp2 = expression2() {
XCTFail(message ? message! : "exp1 == nil, exp2 != nil", file: file, line: line)
#!/bin/bash -e
GITBASE="[email protected]:mprudhom" # repository to clone
GITBRANCH="packagereorg" # branch name to place the rename in
test -d incubator-optiq || git clone ${GITBASE}/incubator-optiq.git
# clean out local repository to make sure we aren't referencing stale jars
# rmtrash ~/.m2/repository/net/hydromatic ~/.m2/repository/org/apache/optiq
cd incubator-optiq
@marcprux
marcprux / index.html
Created June 29, 2013 14:19
Dancing Treemap in Vega+D3+SVG
<!DOCTYPE html>
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Visualization</title>
<meta
charset="UTF-8" />
<meta
http-equiv="Content-type"
content="text/html;charset=UTF-8" />
@marcprux
marcprux / index.html
Last active December 18, 2015 01:49
Scatter Matrix in Vega+D3
<!DOCTYPE html>
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Visualization</title>
<meta
charset="UTF-8" />
<meta
http-equiv="Content-type"
content="text/html;charset=UTF-8" />
@marcprux
marcprux / index.html
Last active December 17, 2015 23:49
Extrema-highlighed animated bars in Vega+D3
<!DOCTYPE html>
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Visualization</title>
<meta
charset="UTF-8" />
<meta
http-equiv="Content-type"
content="text/html;charset=UTF-8" />
@marcprux
marcprux / README.md
Last active December 17, 2015 23:49
Highlighting the minimum and maximum values with vega+d3

This example demonstrates highlighting the minimum and maximum values of a bar chart by zipping the original data set together with the stats for the data and setting a color scale on a formula "isExtremum" value.

View this code at http://livecoding.io/5691859

@marcprux
marcprux / index.html
Created April 25, 2013 16:53
Resizable stacked bar chart using vega+d3+svg
<!DOCTYPE html>
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Visualization</title>
<meta
charset="UTF-8" />
<meta
http-equiv="Content-type"
content="text/html;charset=UTF-8" />
@marcprux
marcprux / index.html
Last active December 16, 2015 15:29
<html>
<head>
<title>Vega Object Constancy Issue Demo</title>
<script src="http://trifacta.github.com/vega/d3.v3.min.js"></script>
<script src="http://trifacta.github.com/vega/vega.js"></script>
</head>
<body>
<div id="vis"></div>
</body>
<script type="text/javascript">