Skip to content

Instantly share code, notes, and snippets.

Benjamin Keating bkeating

Block or report user

Report or block bkeating

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
@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
/**
* propComparator - compare a list of objects by object property value
*
* USAGE: listOfPosts.sort(propComparator('publish_date'))
*/
export const propComparator = propName => (a, b) =>
a[propName] === b[propName] ? 0 : a[propName] < b[propName] ? -1 : 1;
/**
* Slufigy - slugifies a string, replacing non alpha-numeric chars into dashes
@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);
View getBusinessHours.js
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 / graphiql-dark-mode.css
Last active Oct 10, 2019
GraphiQL One Dark Alt (Dark Mode) theme by Ben Keating
View graphiql-dark-mode.css
<style>
/* GraphiQL One Dark Alt (Dark Mode) theme by Ben Keating[1]
* Colors taken from Atom's One Dark theme[2]. Add this file to the end of
* your <head> block[3] to override built-in default styling.
*
* [1]. https://twitter.com/flowpoke
* [2]. https://github.com/atom/atom/tree/master/packages/one-dark-ui
* [3]. e.g. `.../site-packages/graphene_django/templates/graphene/graphiql.html`
*/
@bkeating
bkeating / cafedb.js
Last active Sep 28, 2018
A cafe menu in the form of a js object
View cafedb.js
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 Sep 6, 2018
React + JSX + LESSCSS in a single HTML file. No precompiling or bundler necessary. A poor man's JSBin.
View index.html
<!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 Sep 6, 2018
React + JSX + LESSCSS in a single HTML file. No precompiling or bundler necessary.
View index.html
<!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%;
View merge.js
// This works... (returns a merged object)
const combinedFormSchema = this.state.session && _.merge(
this.state.session.building_list[0].schema,
this.state.session.building_list[1].schema
);
// This does not (returns an array of objects, not a merged object)
const combinedFormSchema = this.state.session && _.merge(
_.map(this.state.session.building_list, building => building.schema)
);
You can’t perform that action at this time.