Skip to content

Instantly share code, notes, and snippets.

View bennetthardwick's full-sized avatar

Bennett Hardwick bennetthardwick

View GitHub Profile
@bennetthardwick
bennetthardwick / app-name-generator-dictionary.json
Last active February 28, 2018 03:14
A dictionary of words used in my app-name-generator-app
{ "dictionary":
[
{ "type": "_activity", "word": "cleaning desks" },
{ "type": "_activity", "word": "opening the fridge several times slowly"},
{ "type": "_activity", "word": "spending too much time on the internet"},
{ "type": "_activity", "word": "typing really fast"},
{ "type": "_activity", "word": "using i3 window manager"},
{ "type": "_activity", "word": "awkwardly presenting to a crowd"},
{ "type": "_activity", "word": "forgetting your Twitter handle"},
{ "type": "_activity", "word": "blowing bubbles"},
@bennetthardwick
bennetthardwick / example-tsconfig.json
Created February 4, 2018 05:02
A tsconfig for my projects
{
"compilerOptions": {
"lib": ["es6"],
"module": "commonjs",
"target": "es5",
"moduleResolution": "node",
"declaration": true,
"rootDir": ".",
"outDir": "dist",
"types" : ["node"]
@bennetthardwick
bennetthardwick / binary_search.js
Created January 24, 2018 13:53
A binary search in JavaScript!
Array.prototype.bsearch = function(value) {
let array = this;
let low = 0;
let high = array.length - 1;
while (low <= high) {
let mid = Math.ceil((low + high) / 2);
@bennetthardwick
bennetthardwick / brisbane_area_suburbs.json
Created January 21, 2018 07:02
All of the suburbs in Brisbane and surrounding areas.
{
"City of Brisbane": {
"Inner suburbs": [
"Bowen Hills",
"Brisbane",
"East Brisbane",
"Fortitude Valley",
"Herston",
"Highgate Hill",
"Kangaroo Point",
@bennetthardwick
bennetthardwick / queensland_postcodes_and_suburbs.json
Created January 21, 2018 06:48
Postcodes and Suburb names of QLD
{
"4000": [
"Brisbane",
"Brisbane Adelaide Street",
"Brisbane Gpo",
"Brisbane-city",
"Parliament House",
"Petrie Terrace",
"Spring Hill"
],
@bennetthardwick
bennetthardwick / useful-array-prototypes.js
Last active January 7, 2018 13:06
Some Array prototypes that I often find useful.
// Find the range of a numerical array
// Array.range()
Array.prototype.range = function() { return this.reduce((a, b) => Math.max(a, b)) - this.reduce((a, b) => Math.min(a, b)); };
// Find the sum of a numerical array
// Array.sum()
Array.prototype.sum = function() { return this.reduce((a, b) => a + b); };
// Find the average of a numerical array
// Array.mean()
#include <stdio.h>
int a = 0;
int increment(){
return ++a;
}
int main(){
printf("%d and %d\n", 1, 2);
@bennetthardwick
bennetthardwick / stripe.js
Created December 18, 2017 05:34
Charge someone $9.99 with stripe in only 34 lines!
var stripe = require('stripe')('sk_test...');
var app = require('express')();
var bodyParser = require('body-parser');
var magic_seven_lines = '<form action="/charge" method="POST">\
<script\
src="https://checkout.stripe.com/checkout.js" class="stripe-button"\
data-key="pk_test..."\
data-amount="999"\
data-name="Test!"\
@bennetthardwick
bennetthardwick / mongoose-population.js
Created November 19, 2017 10:10
Using a $text search with mongoose population
var express = require('express');
var server = express();
var mongoose = require('mongoose');
var async = require('async');
var db = mongoose.connect('localhost:27017/text');
var ChildSchema = new mongoose.Schema({
text: String
})

Keybase proof

I hereby claim:

  • I am bennetthardwick on github.
  • I am bennetthardwick (https://keybase.io/bennetthardwick) on keybase.
  • I have a public key ASACy28IRn7SrsR-pHj1deFV51sTeBZVn3znY23ZCCy6zAo

To claim this, I am signing this object: