Skip to content

Instantly share code, notes, and snippets.

View RikkiGibson's full-sized avatar

Rikki Gibson RikkiGibson

View GitHub Profile
$filter1 = $data
->where(function($row)
{
return $row['price'] > 90 && $row['price'] < 99;
})
->orderByDescending(function($row)
{
return $row['id'];
});
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);
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);
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.
@RikkiGibson
RikkiGibson / gist:6d7dde5960d378a751b6
Created December 8, 2014 05:44
Given a bunch of data on how many pins the players on each team knocked down each frame of each game, determine the wins and losses for all the teams in the league.
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
@RikkiGibson
RikkiGibson / adt.ts
Created March 11, 2016 23:43
faking ADTs in TypeScript
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';
}
@RikkiGibson
RikkiGibson / adt.ts
Created March 11, 2016 23:44
Fake ADTs in TypeScript
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';
}
@RikkiGibson
RikkiGibson / gist:8085aad972750d3d3cb8
Created March 29, 2016 00:05
Stack level too deep with "brew search gcc"
The invocation that failed:
$ brew search gcc
Error: stack level too deep
Please report this bug:
https://git.io/brew-troubleshooting
/usr/local/Library/Homebrew/formulary.rb:21
----- brew config -----
HOMEBREW_VERSION: 0.9.5
interface Point {
row: number
column: number
someOtherShitThatAtomUses: idk
color: string
}
var doStuffWithPoint(point: { row: number, column: number}) {
...
}
! function(e, a) {
"object" == typeof exports && "undefined" != typeof module ? a(exports, require("ms-rest-azure-js"), require("ms-rest-js")) : "function" == typeof define && define.amd ? define(["exports", "ms-rest-azure-js", "ms-rest-js"], a) : a(e.ArmStorage20180301Preview = {}, e.msRestAzure, e.msRest)
}(this, function(e, a, t) {
"use strict";
var r = function(e, a) {
return (r = Object.setPrototypeOf || {
__proto__: []
}
instanceof Array && function(e, a) {
e.__proto__ = a