Skip to content

Instantly share code, notes, and snippets.

Avatar
🤙

Benjamin Keating bkeating

🤙
View GitHub Profile
@bkeating
bkeating / capture_screenshot.js
Last active Sep 15, 2021
Capture a full-page screeenshot of a URL. Taken from Abstractly's dja project.
View capture_screenshot.js
/**
* 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];
View getPiSerialNumber.js
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);
}
View settings.json
{
"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,
View GzipSimpleHttpServer.py
#!/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"
View vscode-settings.json
{
"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 Nov 8, 2019
Python's SimpleHttpServer, but w/Gzip support. 🤙
View GzipSimpleHttpServer.py
#!/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 Nov 6, 2019
My personal, ongoing list of useful JavaScript prototype polyfills ¯\_(ツ)_/¯
View polyfills.js
/**
* 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);
View utils.js
/**
* 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 Nov 5, 2019
nvAux - FIle System Storage Plugin
View index.js
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);