Skip to content

Instantly share code, notes, and snippets.

View beardedtim's full-sized avatar
💭
I may be slow to respond.

Tim Roberts beardedtim

💭
I may be slow to respond.
View GitHub Profile
@beardedtim
beardedtim / index.md
Created August 1, 2019 14:47
Basic Git Flow using GitHub as Origin

Overview

This document outlines how I use git in order to do development work. These are guidelines and not actual rules.

Step 1: Clone

The first thing we need to do is get the remote repo to be local. We do that by cloning the repo. As an example, if you wanted to do work on the beardedtim/my-little-nlp repo, you would run the following to clone it to a local folder:

@beardedtim
beardedtim / handlers.js
Created June 30, 2019 17:08
Querying graph data inside postgres
const { Router } = require('express')
const Step = new Router()
Step.get('/starting_at/:id', async (req, res) => {
const { rows } = await db.query(`
SELECT *
FROM nodes
WHERE
meta @> '{"starting_states": ["${req.params.id}"]}'
`)
@beardedtim
beardedtim / joins.sql
Created May 17, 2019 20:12
Left Joins for days
/* create some nodes to connect */
INSERT INTO nodes(title) VALUES
('Linux'),
('Operating System');
/* create a connection to connect nodes with */
INSERT INTO links(title) VALUES ('is_a');
/* And connect the two nodes created via the link */
INSERT INTO connections(node_a, link, node_b) VALUES
@beardedtim
beardedtim / monads.md
Last active January 4, 2025 11:55
Monads are like burritos...and trees...and clocks...and...

Monads and Why The Hell We Need Weird Words

Once you understand what monads are, and why they exist, you lose the ability to explain it to anybody.

Here's to hoping I don't understand them

Table of Contents

@beardedtim
beardedtim / metabase.js
Created May 16, 2019 13:40
Slice and Dice Metabase Data
// comes with node
const fs = require('fs')
// need to install via `npm i ramda` or `yarn ramda`
const R = require('ramda')
// This is the closed dataset from Metabase
// saved as a json file locally
const closed = require('./data/closed.json')
// Group By Points
const byStoryPoints = R.groupBy(R.prop("story_points"), closed)
@beardedtim
beardedtim / stemmer.py
Created May 5, 2019 17:29
A naive implementation of the Porter Stemmer in Python
#
# All work is based off this document
#
# http://snowball.tartarus.org/algorithms/porter/stemmer.html
#
# The first part of the algorithm talks about
# what a constant is. So let's encode that in
# python!
# The following are _always_ considered
@beardedtim
beardedtim / entry.jsx
Created April 24, 2019 12:27
Example of creating a hook instead of an HoC-type thing
import React, { useEffect, useState } from 'react'
import { render } from 'react-dom'
import { interval } from 'rxjs'
import { map } from 'rxjs/operators'
const getPusher = () => interval(500).pipe(
map(() => ({ message: 'New Pusher Message', time: new Date() }))
)
const usePusher = () => {
axios.post('/uri', {
title: 'Hello',
world: 'world'
})
const body = req.body
const data = JSON.parse(body)
console.log(data) // { title: 'Hello', world: 'world' }
@beardedtim
beardedtim / index.jsx
Created January 21, 2019 16:33
A basic form in React
import React, { Component } from 'react'
class Form extends Component {
constructor(props) {
super(props)
this.onSubmit = this.onSubmit.bind(this)
this.onChange = this.onChange.bind(this)
this.state = {}
@beardedtim
beardedtim / createPosts.js
Created January 1, 2019 20:11
Create Markdown Posts for All markdown files in directory
const fs = require('fs')
const path = require('path')
const cheerio = require('cheerio')
const markdown = require('markdown-it')
const highlightjs = require('highlight.js')
const metaMD = require('markdown-it-meta')
const parser = markdown({
highlight: function (str, lang) {
if (lang && highlightjs.getLanguage(lang)) {