Skip to content

Instantly share code, notes, and snippets.

View bclinkinbeard's full-sized avatar

Ben Clinkinbeard bclinkinbeard

View GitHub Profile
@bclinkinbeard
bclinkinbeard / release.sh
Created November 1, 2011 20:22
Bash script to automate the Git Flow tag/release process
#!/bin/bash
# current Git branch
branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
# v1.0.0, v1.5.2, etc.
versionLabel=v$1
# establish branch and tag name variables
devBranch=develop
{
"name": "literasee-editor",
"version": "1.0.0",
"description": "",
"scripts": {
"clean": "rimraf public",
"build:webpack": "webpack --config webpack.config.prod.js",
"build": "npm run clean && npm run build:webpack",
"postinstall": "npm run build",
"start": "nodemon server.js"
@bclinkinbeard
bclinkinbeard / referenced_mongo_json.md
Created March 15, 2013 16:56
Populating referenced collections in MongoDB from JSON files using Node.js and Mongoose

Populating referenced collections in MongoDB from JSON files using Node.js and Mongoose

I recently began working with Node and MongoDB for a small personal project, largely just to learn the technologies. One thing that is fairly simple but that I found far from obvious and lacking in concrete examples was how to populate the part of my database that used referenced collections from the sample JSON data I was starting with. This post attempts to fill that gap using the following code snippets, which are heavily commented inline. You will notice I am using the awesome Mongoose library which makes working with MongoDB very easy.

http.createServer( app ).listen( app.get( 'port' ), function() {

    mongoose.connect( 'mongodb://localhost/{YOUR_DB_NAME}' );

	var db = mongoose.connection;
module.exports = {
server: '.',
files: [
'*.html',
'src/*'
],
ui: false,
notify: false
};
@bclinkinbeard
bclinkinbeard / gist:2698389
Created May 15, 2012 01:15
D3.js scatterplot in CoffeeScript
dataset = []
w = 500
h = 400
padding = 30
dataset.push [ Math.random() * w, Math.random() * h ] for [0..50]
svg = d3.select("body")
.append("svg")
.attr("width", w)
const muteStorage = new Keyv(MONGODB_URI, { namespace: `${env}mute` })
const unmute = async () => {
client.guilds.cache.forEach((g) => {
const muted = g.members.cache.filter((m) => {
const roleNames = Array.from(
m.roles.cache.mapValues((r) => r.name).values(),
)
return roleNames.includes(ROLES.MUTED)
})
@bclinkinbeard
bclinkinbeard / atomic-habits-notes.md
Created August 19, 2020 14:29
Rough notes on Atomic Habits by James Clear

Atomic Habits

"Building habits in the present allows you to do what you want in the future."

The Four Steps of Habits

  1. Cue
  2. Craving
  3. Response
  4. Reward
console.log('hello')
@bclinkinbeard
bclinkinbeard / index.js
Created November 29, 2017 17:10
Extract all the non-png links from a directory of Markdown files
const markdownLinkExtractor = require('markdown-link-extractor')
const fs = require('fs')
const { join } = require('path')
const dir = join(__dirname, 'chapters')
const files = fs.readdirSync(dir)
const titles = files.map(
file => file.substr(0, file.lastIndexOf('.')).split(' - ')[1],
)
@bclinkinbeard
bclinkinbeard / .block
Created November 3, 2017 18:17
Stacked Bar Chart
license: gpl-3.0