Skip to content

Instantly share code, notes, and snippets.

View crhallberg's full-sized avatar
💜
Happy to be here

Chris Hallberg crhallberg

💜
Happy to be here
View GitHub Profile
@crhallberg
crhallberg / css.js
Created July 1, 2016 14:25
Automated sass compression for VuFind's grunt file
grunt.registerMultiTask('css', function (arg1, arg2) {
var fs = require('fs')
, path = require('path')
, options = (arguments.length > 0 && this.data[arg1] && this.data[arg1].options)
? this.data[arg1].options
: this.data.dist.options
, theme = (arguments.length > 1) ? arg2 : null
, themeFolder = this.data.options.themeFolder || 'themes'
, themeList = fs.readdirSync(path.resolve(themeFolder))
, sassConfig = {}
@crhallberg
crhallberg / insetup.js
Created January 8, 2017 14:57
Spike Test
void setup() {
// ...
setTimeout(function() {
bounceSound.amp(.3);
bounceSound.play();
}, 1000);
setTimeout(function() {
bounceSound.amp(.3);
bounceSound.play();
bounceSound.play();
@crhallberg
crhallberg / markdown_publish.js
Last active February 12, 2018 16:32
Publish markdown to html, ignores files that start with _ as drafts.
const marky = require('marky-markdown'),
touch = require('touch'),
fs = require('fs');
const template = fs.readFileSync('./template.html', 'utf8');
function reportCard(name, mtime) {
const fileCol = name + Array(33).join(' ').slice(name.length);
const date = mtime.toDateString(); // mtime.getFullYear() + '-' + mtime.getMonth() + '-' + mtime.getDate();
console.log(' $ ' + fileCol + date);
@crhallberg
crhallberg / save-load-benchmark.js
Created February 8, 2019 15:18
QuadTree Save/Load Benchmark
// package.json dependency:
// "ct-quadtree": "git://github.com/crhallberg/QuadTree.git#save-load"
const { QuadTree, Rectangle, Point } = require("ct-quadtree");
function benchmark(msg, func) {
const NS_PER_SEC = 1e9;
console.log(msg);
const start = process.hrtime();
let ret = func();
const diff = process.hrtime(start);
@crhallberg
crhallberg / JS-Intro.js
Last active June 14, 2023 16:53
Falvey 2023: Intro to Javascript
console.log("Hello, Falvey!!");
// JS will ignore this
let MULCH = 2;
let INCHES_IN_A_YARD = 36 * 36 * 36;
function doCalculations(garden) {
// We want 2 inches of mulch
garden.mulchDepth = MULCH;
garden.compostDepth = garden.fillDepth - MULCH;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<main>
<h1>Villanova University</h1>
print("Hello, world!")
# Python will ignore this
PPI = 400
def calc_width(book):
paper_width = book["pages"] / PPI # inches
cover_width = 0
if book["binding"] == "Hardcover":
@crhallberg
crhallberg / garden-project.js
Last active July 13, 2023 19:00
Javascript - Working with Files - Starting Point
// Set some useful values at the top (Constants)
let MULCH = 2;
let INCHES_IN_A_YARD = 36 * 36 * 36;
// Make Variables to add up all of the yards.
let mulchTotal = 0;
let compostTotal = 0;
// Create a Function to calculate the yards of compost and mulch.
// This Function allows us to reuse the code within whenever we want.