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
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
Created Jan 2, 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 to override built-in default styling.
*
* [1]. https://twitter.com/flowpoke
* [2]. https://github.com/atom/atom/tree/master/packages/one-dark-ui
*/
@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)
);
View string.json
// How do I go from this...
"{u'type': u'object', u'properties': {u'first_floor': u'open'}}"
// to a json object...
{"type": "object", "properties": { "first_floor": "open" }}
View story.js
import React from 'react';
import { storiesOf } from '@storybook/react';
import { withInfo } from '@storybook/addon-info';
import { withKnobs, select, boolean } from '@storybook/addon-knobs';
import RadialBarChart from '../components/RadialBarChart';
// I'd prefer to stick the prop payload elsewhere...
// import { mockVisualization } from './mockdata';
View conditionalComponent.js
{queries.map(query => ({
area: <Area key={query.id} name={query.name} {...query.definition} />,
bar: <Bar key={query.id} name={query.name} {...query.definition} />,
line: <Line key={query.id} name={query.name} {...query.definition} />
}[query.definition.cartesianType]))}
View atom stylesheet.less
// style the background and foreground colors on the atom-text-editor-element itself
atom-text-editor {
// color: white;
// background-color: hsl(180, 24%, 12%);
-webkit-font-smoothing: antialiased;
}
// To style other content in the text editor's shadow DOM, use the ::shadow expression
atom-text-editor.editor {
.syntax--storage.syntax--type.syntax--function.syntax--arrow, .syntax--operator {
You can’t perform that action at this time.