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
type Meters = { meters: number }; | |
type Feet = { feet: number }; | |
type Distance = Meters | Feet; | |
function isMeters(distance: Distance): distance is Meters { | |
return typeof (distance as Meters).meters === 'number'; | |
} | |
function isFeet(distance: Distance): distance is Feet { | |
return typeof (distance as Feet).feet === 'number'; | |
} |
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 t.TeamName, ifnull(Wins, 0) Wins, ifnull(Total-Wins,0) Losses | |
from Team t | |
left join ( | |
select b.TeamID, count(*) Wins | |
from ( | |
select a.GameID, a.TeamID, max(Points) | |
from ( | |
select gf.GameID, gf.TeamID, sum(gf.FirstRoll + gf.SecondRoll) Points | |
from GameFrame gf | |
group by gf.GameID, gf.TeamID |
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 li = [5,6,4,9,3]; | |
function min(a, b) { | |
return a < b ? a : b; | |
} | |
// reduce is an awesome function. in this situation it's doing: | |
// min(5,6) -> 5... min(5,4) -> 4... min(4,9) -> 4... min(4,3) -> 3... done | |
// you provide a function that takes two arguments and it goes through the list, | |
// using the return value as one of the arguments and the next list element as the other. |
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
console.log(process.argv.slice(2) | |
.reduce(function(a, b) { | |
return Number(a) + Number(b) | |
})); | |
var total = 0; | |
for (var i = 2; i < process.argv.length; i++) { | |
total += parseInt(process.argv[i]); | |
} | |
console.log(total); |
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
console.log(process.argv.splice(2) | |
.reduce(function(a, b) { | |
return Number(a) + Number(b) | |
})); | |
var total = 0; | |
for (var i = 2; i < process.argv.length; i++) { | |
total += parseInt(process.argv[i]); | |
} | |
console.log(total); |
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
$filter1 = $data | |
->where(function($row) | |
{ | |
return $row['price'] > 90 && $row['price'] < 99; | |
}) | |
->orderByDescending(function($row) | |
{ | |
return $row['id']; | |
}); |
NewerOlder