This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let greetings = ["hi";"hello";] | |
let names = ["john";"micah";] | |
// trying to end up with ["hi john";"hi micah";"hello john"; "hello micah;"] | |
// cant use zip-- real life items arent same size | |
greetings | |
|> List.fold (fun(accum,greet) -> names |> List.map (fun (name)-> greet +" "+ name) |> List.append accum ) List.empty<string>;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PeopleDAL | |
{ | |
public DataSet Person_GetAll() | |
{ | |
//Returns a DataSet containing all people records in the database. | |
} | |
public DataSet Person_GetByPersonID(int personID) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PeopleRepository | |
{ | |
public List<PersonDTO> Get() | |
{ | |
//return a list of person data transfer objects here | |
} | |
public void Insert(PersonDTO person) | |
{ | |
//insert a person here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//select all divs | |
d3.selectAll('div') | |
//map some data to those divs, in order that they were found in the DOM | |
.data(["hello","world","hi"]) | |
//and now do something to the divs with that data | |
//perhaps, put the data in the divs | |
//so this function param "d" is actually the data for that div | |
.html(function(d) { | |
return d; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//grab all divs on the page | |
//and set their width to 300 | |
d3.selectAll('div') | |
.attr("width",300) | |
.attr("height",400); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>d3test</title> | |
<link href="bootstrap-1.1.0.min.css" type="text/css"></link> | |
<script src="d3.min.js" type="text/javascript"></script> | |
</head> | |
<body> | |
<div id="demo"> | |
<svg id="svgdemo"></svg> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//so there's two divs on the page for this to select | |
d3.select('body') | |
.selectAll('div') | |
.data(["hello","there","world"]) | |
//this will map "hello" and "there" to the only two divs | |
.html(function(d){return d;}) | |
//but theres 3 pieces of data...? | |
//this is why d3 has the enter() function | |
//think of it as "withTheLeftOverDataAfterMapping()" instead of "enter()" | |
.enter() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express=require('express'), | |
hogan=require('hogan.js'), | |
adapter=require('./hogan-express.js'), | |
app = express.createServer(); | |
app.configure(function(){ | |
app.use(express.static(__dirname + '/public')); | |
app.use(express.logger()); | |
app.use(express.bodyParser()); | |
app.use(express.cookieParser()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var HoganExpressAdapter=(function(){ | |
var init=function(hogan) { | |
var compile=function(source){ | |
return function(options) { | |
return hogan.compile(source).render(options); | |
}; | |
} | |
return {compile:compile}; | |
}; | |
return {init:init}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var product=function(list) { | |
var len=list.length, | |
sum=1, | |
i=0; | |
for(;i<len;i+=1) { | |
sum=sum*list[i]; | |
} | |
return sum; | |
} |
OlderNewer