Skip to content

Instantly share code, notes, and snippets.

View matthewlehner's full-sized avatar
👻

Matthew Lehner matthewlehner

👻
View GitHub Profile
@matthewlehner
matthewlehner / machine.js
Last active February 16, 2021 20:18
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@matthewlehner
matthewlehner / machine.js
Last active March 2, 2020 21:14
Generated by XState Viz: https://xstate.js.org/viz
const voteMachine = Machine({
id: "Phone Voting",
initial: "idle",
context: {},
states: {
idle: {
on: {
CALL_ANSWERED: "greetingMsg"
}
},
@matthewlehner
matthewlehner / tmux.conf
Last active February 1, 2019 23:01
Get italics and full colour support in vim in tux. tmuxcolours.sh installs the other two files with arcane neckbeard magic.
set -g default-terminal "tmux-256color"
@matthewlehner
matthewlehner / Brewfile
Last active February 9, 2023 11:27
Install PHP with asdf
# run `brew bundle --file=path/to/this/Brewfile` to install these deps for PHP
brew "bison"
brew "icu4c"
brew "libiconv"
brew "openssl"
brew "libpq"
brew "zlib"
@matthewlehner
matthewlehner / index.jsx
Last active March 20, 2017 20:33
Apollo with React
import React from "react";
import { render } from "react-dom";
import { ApolloClient, ApolloProvider } from "react-apollo";
import UserProfile from "user-profile"
const client = new ApolloClient();
const reactRoot = document.getElementById("react-root");
// Wrap components at the top level with ApolloProvider - this allows us
@matthewlehner
matthewlehner / homebrew-postgres-9.6-upgrade.sh
Created November 24, 2016 21:44
Upgrades Homebrew Postgres installation from 9.5 to 9.6
brew services stop postgresql
initdb /usr/local/var/postgres9.6 -E utf8
pg_upgrade -d /usr/local/var/postgres -D /usr/local/var/postgres9.6 -b /usr/local/Cellar/postgresql/9.5.5/bin -B /usr/local/Cellar/postgresql/9.6.1/bin -v
mv /usr/local/var/postgres /usr/local/var/postgres9.5
mv /usr/local/var/postgres9.6 /usr/local/var/postgres
brew services start postgresql
class LetsEncryptResponse
ACME_ENDPOINT_REGEX = /\A\/\.well-known\/acme-challenge\/(?<challenge>.*)\z/
def initialize(app)
@app = app
end
def call(env)
request = Rack::Request.new env
if request.path.start_with?("/.well-known/acme-challenge/")
match = request.path.match ACME_ENDPOINT_REGEX
@matthewlehner
matthewlehner / .powconfig
Created March 31, 2016 22:40
Use Pow with nginx
export POW_DST_PORT=19999
@matthewlehner
matthewlehner / Guardfile
Created March 22, 2016 21:41
Guardfile for RSpec Config in Rails
guard :rspec, cmd: 'bundle exec rspec', all_on_start: false, all_after_pass: false do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch(%r{spec/(spec|rails)_helper.rb}) { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb", "spec/requests/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
@matthewlehner
matthewlehner / reducer_spec.js
Created January 7, 2016 18:44
Writing tests for redux reducers
import { expect } from "chai";
import reducer from "../../src/reducers/workspace";
import { EDIT_ITEM } from "../../src/actions/workspace";
describe("workspace reducer", () => {
it("handles EDIT_ITEM", () => {
const initialState = {};
const action = {
type: EDIT_ITEM,
itemIndex: 1