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
#!/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 / 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');
{
"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 / 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 / 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);
import moment from 'moment';
/**
* A business needs to know the hours in which it operates.
*
* Import `getBusinessHours` and get access to:
* - isCurrentlyOPen() - bool on wether or not the cafe is currently open
* - todaysWeekInt() - todays week number. Zero-based (Sunday=0)
* - getDayMeta(int) - returns the given days business hour meta as an object
*
@bkeating
bkeating / cafedb.js
Last active September 28, 2018 16:11
A cafe menu in the form of a js object
module.exports = {
category: [
{ id: 1, title: 'Breakfast', slug: 'breakfast', description: 'Changes Regularly - Febuary 1, 2016', },
{ id: 2, title: 'Lunch', slug: 'lunch', description: 'Changes Regularly - Febuary 1, 2016', },
{ id: 3, title: 'Evening', slug: 'evening', description: 'from 4pm - 8pm Tues. - Sat.', },
{ id: 4, title: 'Wine, Beer, Cocktails', },
{ id: 5, title: 'Sparkling', },
{ id: 6, title: 'Rose', },
{ id: 7, title: 'White', },
{ id: 8, title: 'Red', },
@bkeating
bkeating / index.html
Created September 6, 2018 17:25
React + JSX + LESSCSS in a single HTML file. No precompiling or bundler necessary. A poor man's JSBin.
<!DOCTYPE html>
<html lang="en">
<head>
<title>React + JSX + LESSCSS</title>
<!-- LESS style must come before the actual loading of less.js -->
<style type="text/less">
.container {
width: 90%;
@bkeating
bkeating / index.html
Last active September 6, 2018 17:23
React + JSX + LESSCSS in a single HTML file. No precompiling or bundler necessary.
<!DOCTYPE html>
<html lang="en">
<head>
<title>React + JSX + LESSCSS</title>
<!-- LESS style must come before the actual loading of less.js -->
<style type="text/less">
.container {
width: 90%;
@bkeating
bkeating / userprofile2mailchimp.py
Created January 3, 2012 23:26
Push Django UserProfile data to an existing MailChimp list
"""Iterate over User Profiles and push some fields to MailChimp.
This script assumes you already have a (lenghty) list setup on
mailchimp.com. It also assumes that you have a Django project utilizing
the Auth app and the User object's UserProfile (MemberProfile here).
It's all too custom to drop in and go, but have a look. This is how I
managed to push our Membership data into MailChimp. Learned a bunch of
stuff in the process.