Skip to content

Instantly share code, notes, and snippets.

💜
Happy to be here

Chris Hallberg crhallberg

💜
Happy to be here
Block or report user

Report or block crhallberg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@crhallberg
crhallberg / save-load-benchmark.js
Created Feb 8, 2019
QuadTree Save/Load Benchmark
View save-load-benchmark.js
// 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 / markdown_publish.js
Last active Feb 12, 2018
Publish markdown to html, ignores files that start with _ as drafts.
View markdown_publish.js
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 / clib.js
Created Aug 31, 2017
Send To Clipboard
View clib.js
// Thanks https://www.sharmaprakash.com.np/javascript/copying-value-from-variable-to-clipboard/
var sendToClipboard = (function Clib() {
var dummy;
var exec = function exec(txt) {
if (typeof dummy === 'undefined') {
dummy = $('<input>').css({'position': 'absolute', 'left': '-9999px' }).appendTo('body');
}
dummy.val(txt).select();
return document.execCommand('copy');
};
View insetup.js
void setup() {
// ...
setTimeout(function() {
bounceSound.amp(.3);
bounceSound.play();
}, 1000);
setTimeout(function() {
bounceSound.amp(.3);
bounceSound.play();
bounceSound.play();
@crhallberg
crhallberg / css.js
Created Jul 1, 2016
Automated sass compression for VuFind's grunt file
View css.js
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 / progress-bar.js
Created Feb 26, 2016
Custom node progress bar
View progress-bar.js
module.exports = function() {
this.ProgressBar = function(l, t) {
this.count = 0;
this.total = t;
this.label = l;
this.size = process.stdout.columns - this.label.length - 11; /*|: [] done! |*/
this.interval = t/this.size;
this.charm = require('charm')();
this.charm.pipe(process.stdout);
this.charm.down(1);
@crhallberg
crhallberg / icons-inline-svgs.json
Last active Jul 3, 2018
Font Awesome Inline SVGs
View icons-inline-svgs.json
{
"500px": "<svg width=\"14\" height=\"16\" class=\"icon icon-500px\" role=\"img\" version=\"1.1\" viewBox=\"0 0 1792 1792\" aria-hidden=\"true\"><path d=\"M1529 1547l-6 6q-113 114-259 175-154 64-317 64-165 0-317-64-148-63-259-175-113-112-175-258-42-103-54-189-4-28 48-36 51-8 56 20 1 1 1 4 18 90 46 159 50 124 152 226 98 98 226 152 132 56 276 56 143 0 276-56 128-55 225-152l6-6q10-10 25-6 12 3 33 22 36 37 17 58zm-472-615l-66 66 63 63q21 21-7 49-17 17-32 17-10 0-19-10l-62-61-66 66q-5 5-15 5-15 0-31-16l-2-2q-18-15-18-29 0-7 8-17l66-65-66-66q-16-16 14-45 18-18 31-18 6 0 13 5l65 66 65-65q18-17 48 13 27 27 11 44zm471 57q0 118-46 228-45 105-126 186-80 80-187 126t-228 46-228-46-187-126q-82-82-125-186-15-32-15-40h-1q-9-27 43-44 50-16 60 12 37 99 97 167h1v-341q3-136 102-232 105-103 253-103 147 0 251 103t104 249q0 147-104.5 251t-250.5 104q-58 0-112-16-28-11-13-61 16-51 44-43l14 3q14 3 32.5 6t30.5 3q104 0 176-71.5t72-174.5q0-101-72-171-71-71-175-71-107 0-178 80-64 72-64 160v413q110 67 242 67 96 0 185-36.5t156-103.5 103.5
@crhallberg
crhallberg / reboot.css
Last active Sep 24, 2018
Compiled bootstrap-reboot
View reboot.css
/*! normalize.css commit fe56763 | MIT License | github.com/necolas/normalize.css */
html {
box-sizing: border-box;
font-family: sans-serif;
font-size: 16px;
-ms-overflow-style: scrollbar;
-ms-text-size-adjust: 100%;
-webkit-tap-highlight-color: transparent;
-webkit-text-size-adjust: 100%; }
@crhallberg
crhallberg / Ways to Break
Last active Aug 29, 2015
Debugging Examples
View Ways to Break
// Errors
loadImage('./grandprismaticspring'); // local doesn't work in Chrome, host or use Firefox with both local
change variable name 'spring' to 'image' // variable name cannot be the name of a function or other variable
mispell mouseX as mousex
pixels[i] == b; // using comparison instead of saving
// Non-error bugs
replace || with && // Will do the opposite
switch mouseX with mouseY
switch fill(...) and rect(...) at the end
@crhallberg
crhallberg / README.md
Last active Nov 21, 2018
Pure JS Grid
View README.md

Having had so much fun making my pure CSS grid, I decided to make an even smaller solution in JS! Pass the function your class prefix, the number of columns you want, and where you want the responsive break-point to be.

Bootstrap 3 - G('col-sm-', 12, 768)

233 bytes


EDIT MAY 8

You can’t perform that action at this time.