Skip to content

Instantly share code, notes, and snippets.

Avatar

Sriram Srinivasan sriram-srinivasan

View GitHub Profile
View Mumbai.csv
MONTH DAY YEAR TEMPERATURE
1 1 1995 71.8
1 2 1995 72.0
1 3 1995 70.3
1 4 1995 69.7
1 5 1995 71.3
1 6 1995 73.9
1 7 1995 72.9
1 8 1995 70.2
1 9 1995 68.4
View rcgraph.rs
use std::rc::Rc;
struct N {
id: i32,
edges: Vec<Rc<N>>
}
pub fn main() {
let mut x = Rc::new( N { id: 1, edges: vec!() });
View graph.rs
struct Node {
id: i32,
}
struct Edge<'a> {
from: &'a Node,
to: &'a Node,
}
pub fn main() {
@sriram-srinivasan
sriram-srinivasan / zebra.py
Created Apr 8, 2017
zebra puzzle; z3 based solution.
View zebra.py
#zebra puzzle.
#
#There are five houses.
#The Englishman lives in the red house.
#The Spaniard owns the dog.
#Coffee is drunk in the green house.
#The Ukrainian drinks tea.
#The green house is immediately to the right of the ivory house.
#The Old Gold smoker owns snails.
#Kools are smoked in the yellow house.
View gist:4ec57e9541b34ae390d1
package main
import (
"fmt"
"math/rand"
"sync/atomic"
"time"
//"runtime"
)
View gist:5e66e3787677f4fc7178
package main
import (
"fmt"
"math/rand"
"sync/atomic"
"time"
//"runtime"
)
@sriram-srinivasan
sriram-srinivasan / options.go
Last active Aug 29, 2015
Simple configuration in go: Map alternate pairs of keys and values to a struct.
View options.go
package main
import (
"errors"
"fmt"
"reflect"
)
func main() {
@sriram-srinivasan
sriram-srinivasan / arch.md
Created Apr 18, 2012
Dataflow arch notes
View arch.md

On targeting multiple language environments, and extracting maximum performance from each.

  • Bloom is a specification language, not meant for adhoc queries. Many of the techniques for datalog and db optimization do not apply to Bloom. We can go the distance in static analysis and type-driven optimization.

  • Tuples must be records with named fields, not arrays. In a static language with machine-primitive types, array-oriented tuples force primitive types to be boxed, which is horrible overhead. Also, tuples don't belong to a language for disorderly programming: array-oriented tuples are not self-explanatory, and make schema evolution painful. From now on, I'll use the term record instead of tuple, to avoid any expectation of positional indexing.

  • Specialized code and types preferred to a library-driven approach. In other words, instead of having generic Record, Table and Index types, there is merit in creating custom implementations for each, for a given Bloom program.

  • Consider a collection with s