Skip to content

Instantly share code, notes, and snippets.

View bkeating's full-sized avatar
🤙
Gettin’ SUM & CALCin’ out

Benjamin Keating bkeating

🤙
Gettin’ SUM & CALCin’ out
View GitHub Profile
@bkeating
bkeating / capture_screenshot.js
Last active September 15, 2021 16:07
Capture a full-page screeenshot of a URL. Taken from Abstractly's dja project.
/**
* Capture a screenshot of a given URL
*
* USAGE: $ node ./capture_screenshot.js my-page-slug 34sdg-252gsg-23dsg-2234 https://mysite.com/my-page-slug/
*
*/
const puppeteer = require("puppeteer");
let pageSlug = process.argv[2];
const getserial = () => {
const fs = require('fs');
const content = fs.readFileSync('/proc/cpuinfo', 'utf8');
const cont_array = content.split("\n");
const serial_line = cont_array[cont_array.length-2];
const serial = serial_line.split(":");
return serial[1].slice(1);
}
{
"editor.fontFamily": "OperatorMonoLig-Book",
"editor.fontLigatures": true,
"files.eol": "\n",
"workbench.colorTheme": "One Dark Pro",
"breadcrumbs.enabled": false,
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"indentRainbow.tabmixColor": "rgba(128,32,96,0.2)",
"workbench.tree.indent": 20,
#!/usr/bin/python
"""Simple HTTP Server.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
__version__ = "0.6"
{
"editor.fontFamily": "OperatorMonoLig-Book",
"editor.fontLigatures": true,
"eslint.autoFixOnSave": true,
"files.eol": "\n",
"workbench.colorTheme": "One Dark Pro",
"breadcrumbs.enabled": false,
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"indentRainbow.tabmixColor": "rgba(128,32,96,0.2)",
@bkeating
bkeating / GzipSimpleHttpServer.py
Created November 8, 2019 18:25
Python's SimpleHttpServer, but w/Gzip support. 🤙
#!/usr/bin/python
"""Simple HTTP Server.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
__version__ = "0.6"
@bkeating
bkeating / polyfills.js
Last active November 6, 2019 11:46
My personal, ongoing list of useful JavaScript prototype polyfills ¯\_(ツ)_/¯
/**
* String.capitalize - Capitalize the first character of a string.
*
* Example:
* const foo = "this is a headline"
* foo.capitalize()
* This is a headline
*/
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
@bkeating
bkeating / utils.js
Last active February 21, 2020 21:05
/**
* Find the average color of an image
*
* USAGE: getAvgColorOfImg('<url to image file>')
*/
getAvgColorOfImg = (u,i = new Image) => {
i.crossOrigin = '';
i.src = u;
i.onload = e => {
x = (c = document.createElement('canvas')).getContext('2d');
@bkeating
bkeating / index.js
Created November 5, 2019 15:54
nvAux - FIle System Storage Plugin
const chokidar = require('chokidar');
// Initialize watcher.
const watcher = chokidar.watch('/Users/kea1080/Documents/nmdiary', {
ignored: /(^|[\/\\])\../, // ignore dotfiles
persistent: true
});
// Something to use when events are received.
const log = console.log.bind(console);