Skip to content

Instantly share code, notes, and snippets.

View jwietelmann's full-sized avatar

Joel Wietelmann jwietelmann

View GitHub Profile
@jwietelmann
jwietelmann / build_mac_plugin_installer.sh
Last active August 23, 2020 14:23
Build and notarize an installer for multiple DAW plugin formats
#!/bin/bash -e
# REQUIREMENTS
# * jq - Used to extract values from notary service JSON responses
# * curl - Used to query notary service
signing_identity="Developer ID Installer: Your Name (ID)"
username="user@example.com"
password="@keychain:where-you-stored-your-app-specific-password"
output_dir=~/your_output_directory
@jwietelmann
jwietelmann / licenses.ex
Created March 29, 2018 22:40
A mix task to list all your dependencies' licenses.
defmodule Mix.Tasks.Deps.Licenses do
alias Mix.Dep
use Mix.Task
@shell Mix.shell()
def run(_) do
Mix.Project.get!()
{with_licenses, without_licenses} =
@jwietelmann
jwietelmann / modalizer.js
Created October 20, 2016 16:00
A dumb thing I hacked up without testing. For helping make stupid modals in React.
import React, {Component, Children} from 'react'
import {connect} from 'react-redux'
const MODAL_CHANGE = 'MODAL_CHANGE'
// Maintain a single active modal identifier
export function modalReducer(state = {activeModalId: null}, {type, id}) {
if(type !== MODAL_CHANGE) {
return state
}
@jwietelmann
jwietelmann / reactUniqueId.js
Created October 4, 2016 16:20
React unique ID via context. Every render of the Provider resets the counter.
import React, {Component, PropTypes, Children, createElement} from 'react'
const CONTEXT_NAME = '__uniqueIDFunction__'
const CONTEXT_TYPES = {}
CONTEXT_TYPES[CONTEXT_NAME] = PropTypes.func
function createUniqueIDFunction() {
let counter = 0
return function() {
return ++counter
@jwietelmann
jwietelmann / walkReactComponentFiles.js
Created September 1, 2016 03:05
A hack to use `react-docgen` to iterate over all React component files in a directory tree.
'use strict'
const reactDocs = require('react-docgen')
const dir = require('node-dir')
export default function walkReactComponentFiles(path, pattern, handleFilename, done) {
const iterator = function(error, content, filename, next) {
if(error) {
throw error
}
@jwietelmann
jwietelmann / router.ex
Created August 31, 2016 17:00
A rough sketch of a Phoenix router that uses an independent rendering service to create HTML from JSON views.
# This plug takes HTML requests, forwards them to our controllers as JSON
# requests, takes the resulting JSON and POSTs it to a rendering service,
# then transforms the response back into HTML using the output from the
# rendering service.
#
# Which means we can write our probably-JavaScript/React view layer
# independently of Phoenix tooling.
defmodule ServiceRenderer do
# Base URL of render service goes here.
def init(url) do
@jwietelmann
jwietelmann / webpackProgrammaticConfig.js
Last active November 23, 2019 17:35
File that exports separate webpack configs for frontend and backend
var webpack = require('webpack');
var path = require('path');
var fs = require('fs');
var deepMerge = require('deep-merge');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
// BEGIN CONFIG TOOLS
// Set up config merging function.
var merge = deepMerge(function(target, source, key) {
// Stupid JavaScript and console tricks.
// Trap and record console things and errors.
function MosquitoNet() {}
MosquitoNet.history = [];
MosquitoNet.writeHistory = function(type, args) {
MosquitoNet.history.push({ type: type, args: args });
}
MosquitoNet.shadowConsoleFunction = function(name) {
var oldFn = console[name];
@jwietelmann
jwietelmann / rack_reverse_proxy_by_adam.rb
Created January 14, 2016 22:46
"keep in mind that there are a few things here that don't work super well: Jekyll dies if you're missing a trailing slash. it appears to handle that internally by always redirecting to a url with a trailing slash. presumably there's some regular expression or something that we could use to handle the cases, but I didn't have time to solve that p…
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module MyProject
class Application < Rails::Application
@jwietelmann
jwietelmann / wordpress_controller.rb
Created January 12, 2016 17:39
A hacky way to consume WP-API content and provide it to Rails views.
require 'faraday'
class WordpressController < ApplicationController
@@wp_client = Faraday.new(url: "http://#{ENV['WP_DOMAIN']}") do |builder|
builder.adapter Faraday.default_adapter
builder.headers = {'Content-Type' => 'application/json'}
builder.request :url_encoded
end