Skip to content

Instantly share code, notes, and snippets.

Avatar

Brendan Doherty bmdoherty

View GitHub Profile
View day6.js
const processInput = str => {
return str
.trim()
.split("\t")
.map(Number);
};
const spread = step => {
step = step.slice(0);
let max = step.reduce((a, b) => Math.max(a, b));
View day6.js
const processInput = str => {
return str
.trim()
.split("\t")
.map(Number);
};
const spread = step => {
step = step.slice(0);
let max = step.reduce((a, b) => Math.max(a, b));
View case.cfm
<cfscript>
var bodyDot = {};
bodyDot.grant_type = "authorization_code";
writeDump(bodyDot);
var bodyBracket = {};
bodyBracket['grant_type'] = "authorization_code";
writeDump(bodyBracket);
</cfscript>
View object_comparision.js
// object test for equality fails as object need to be pointing to same reference in memory
// primitives like strings and numbers are compared by their value
function greetFailing(person) {
if (person == { name: 'amy' }) {
return 'hey amy'
} else {
return 'hey arnold'
}
}
View birthday.cfm
<cfscript>
lines = [1,2,3,4];
lines.map(function(line){
var greeting = "you";
if(line eq 3){
greeting = "Roahl Dahl";
}
writeOutput( "Happy Birthday to " & greeting & "<br>");
});
View brendan_puzzler.cfm
<cfscript>
function f(bytes){
var hash = [];
var unit = 0;
var magnitude = '';
var sizes = [
{'unit':'B', size:1},
{'unit':'KB', size:1024},
{'unit':'MB', size:1024*1024},
View puzzle,cfm
<cfscript>
function smallestWholeNumberGreaterThanZero(prev, item){
if (prev eq 0){
return item;
}
if (item eq 0){
return prev;
}
View almostSorted.cfm
<cfscript>
tests = [
// sorted
[true,[1,2,3,4,5]]
,[true,[2,4,6,8,10]]
// 1 swap
,[true,[1,2,3,5,4]]
,[true,[5,2,3,4,1]]
,[true,[1,2,3,5,3]]
View gist:50adc9d04575dd5c58121d2511aac051
<cfscript>
tests = [
// sorted
[true,[1,2,3,4,5]]
,[true,[2,4,6,8,10]]
// 1 swap
,[true,[1,2,3,5,4]]
,[true,[5,2,3,4,1]]
,[true,[1,2,3,5,3]]
View gist:83cab22dfcd0b2171af3
<cffunction
name="REMatchGroup"
access="public"
returntype="array"
output="false"
hint="Gets the given group of a captured expression.">
<!--- Define arguments. --->
<cfargument
name="Pattern"