Skip to content

Instantly share code, notes, and snippets.

View davidbarsky's full-sized avatar

David Barsky davidbarsky

View GitHub Profile
```bash
vagrant@vagrant-ubuntu-trusty-64 ~> ggen generate-graph
ggen: normal: Logging facility initialized
generate-graph:
Valid Options: output, rng
Methods:
gnp : the classical adjacency matrix method
gnm : selection of edges in the complete graph
@davidbarsky
davidbarsky / Output.txt
Created December 26, 2016 23:27
Graph DFS
[["a", "b", "e", "f", "g"], ["a", "b", "e", "h"], ["a", "b", "e", "f"], ["a", "b", "d"], ["a", "b", "e"], ["a", "b"], ["a", "c"], ["a"]]
# Experiment Failures
Fibonacci: `TopologicalSorter.mapToTaskList`
Cholesky: `graph.GGenGraph.parseAllGV`
Poisson: `graph.GGenGraph.parseAllGV`
Fork/Join: Done
SpraceLU: `graph.GGenGraph.parseAllGV`
`$ ggen static-graph fibonacci 1 5`
```
ggen: normal: Logging facility initialized
⟩ ggen dataflow-graph sparselu 4
ggen: normal: Logging facility initialized
ggen: normal: Configuring output
ggen: normal: Ouput configured
ggen: normal: Printing graph
digraph dag {
0 [kernel=lu];
1 [kernel=fwd];
0 -> 1 [x=0,
y=0];
@davidbarsky
davidbarsky / roughly.py
Created April 3, 2017 22:19
processing
while !lines.contains("character of interest"):
replace
seen = false
for line in file:
if line.contains("character of interest"):
seen = true
process(line)
@davidbarsky
davidbarsky / CracklePop.md
Last active April 13, 2017 19:17
CracklePop for the Recurse Center's Application

Let's say that we've got two files: our application code and our test code that are in the same package. Our application code looks like this:

object Functions {
  def cracklePop(a: Int): String = {
    (a % 3, a % 5) match {
      case (0, 0) => "CracklePop"
      case (0, _) => "Crackle"
      case (_, 0) => "Pop"
      case (_, _) => s"$a"
@davidbarsky
davidbarsky / Graphs.scala
Created May 6, 2017 17:38
For the Recurse Center pairing interview
object Main {
type Vertex = Int
type Graph = Map[Vertex, List[Vertex]]
type Traversal = (Vertex, Graph) => Stream[Vertex]
val graph = Map(
1 -> List(2, 3),
2 -> List(4, 5),
3 -> List(6, 7),
4 -> List(8, 9)
@davidbarsky
davidbarsky / dfs.scala
Last active May 9, 2017 17:29
recurse-pair, with set. fixed!
object Main {
// an n-arity tree, please have no cycles!
case class Rose(value: Int, children: List[Rose])
type Traversal = (Rose) => Seq[Int]
def depthFirstTraverse(rose: Rose): List[Int] = {
def go(r: Rose, visited: Set[Int]): Set[Int] = {
println(s"Visited: $visited")
// my original impementation didn't have this! by adding this, we don't see absurd stack calls.
$ cargo clippy
bin: basicaf
Compiling basicaf v0.1.0 (file:///Users/David/Developer/Rust/basicaf)
warning: unneeded return statement
--> src/parser/structs.rs:62:9
|
62 | / return match *self {
63 | | DBStmt::DEF {..} => "DEF",
64 | | DBStmt::DIM {..} => "DIM",
65 | | DBStmt::END {..} => "END",
#[macro_use]
extern crate failure;
extern crate futures;
extern crate hyper;
extern crate serde_json;
extern crate tokio;
extern crate tokio_timer;
use failure::Error;
use futures::future;