Skip to content

Instantly share code, notes, and snippets.

@SergiuB
SergiuB / Functional backtracking: eight queens.markdown
Created March 5, 2016 16:31
Functional backtracking: eight queens
@SergiuB
SergiuB / Functional backtracking: coin combinations amounting to sum.markdown
Created March 5, 2016 16:30
Functional backtracking: coin combinations amounting to sum
@SergiuB
SergiuB / Backtracking engine using ES6 generators.markdown
Last active March 5, 2016 16:28
Backtracking engine using ES6 generators
@SergiuB
SergiuB / index.jsx
Created February 12, 2016 08:37
Force layout using d3 and React
import React from 'react'
import ReactDOM from 'react-dom'
import d3 from 'd3'
class Chart extends React.Component {
render() {
let style = {width: this.props.width, height: this.props.height}
return <svg style={style}>
{this.props.children}
</svg>
@SergiuB
SergiuB / atom
Last active December 12, 2015 19:51
automatic update by http://atom.io/packages/sync-settings
atom
@SergiuB
SergiuB / web_crawler.go
Created October 24, 2014 16:56
paralellized web crawler in Go - exercise from Tour of Go
package main
import (
"fmt"
"sync"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.
@SergiuB
SergiuB / equiv_bin_tree.go
Created October 24, 2014 15:23
equivalent binary trees test in Go - exercise from Tour of Go
package main
import (
"code.google.com/p/go-tour/tree"
"fmt"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
@SergiuB
SergiuB / prodcons.go
Created October 24, 2014 14:15
producer/consumer problem in Go
package main
import (
"fmt"
"sync"
"time"
)
func main() {
var wg sync.WaitGroup
@SergiuB
SergiuB / gist:8089002
Created December 22, 2013 22:01
NodeJS exercise to parse a file containing float values and output them to the console. read module is used as a trick to wait for the Enter key before execution process.stdin.resume(); prevents the process from exiting to allow finishing the async operation (you have to hit Ctrl+c to exit)
var Lazy = require("lazy"),
Q = require("q"),
fs = require("fs");
// elevationsFileName is the name of a file containing one float value per line
var readElevations = function(elevationsFileName) {
var deferred = Q.defer(),
elevations = [];
new Lazy(fs.createReadStream(elevationsFileName))