Skip to content

Instantly share code, notes, and snippets.

View afcondon's full-sized avatar

Andrew Condon afcondon

View GitHub Profile
@afcondon
afcondon / morphagene_ableton.py
Created August 7, 2023 06:32 — forked from knandersen/morphagene_ableton.py
Allows you to use Ableton projects and exports as reels for the Make Noise Morphagene eurorack module. Since a few people have found the script not working or difficulty getting python to work, I have created a web-based tool: https://knandersen.github.io/morphaweb/
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
USAGE:
morphagene_ableton.py -w <inputwavfile> -l <inputlabels> -o <outputfile>'
Instructions in Ableton:
Insert locators as splice markers in your project (Create > Add Locator)
Export Audio/Video with
Sample Rate: 48000 Hz
@afcondon
afcondon / graph.json
Created May 2, 2021 14:38 — forked from eyaler/graph.json
Force-Directed Graph with Drag/Zoom/Pan/Center/Resize/Labels/Shapes/Filter/Highlight
{
"graph": [],
"links": [
{"source": 0, "target": 1},
{"source": 0, "target": 2},
{"source": 0, "target": 3},
{"source": 0, "target": 4},
{"source": 0, "target": 5},
{"source": 0, "target": 6},
{"source": 1, "target": 3},
@afcondon
afcondon / Main.purs
Last active July 8, 2020 10:56
Nested Maybes
module Main where
import Prelude (Unit, pure, bind, ($), show, class Show)
import Effect (Effect)
import Data.Maybe (Maybe(Just, Nothing))
import Data.Array (head)
import TryPureScript (p, text, render)
import Data.Foldable (fold)
@afcondon
afcondon / treemap.js
Created April 23, 2020 15:32
d3.join(enter, update, exit) with multiple elements
var chart = function (data) {
var root = treemap(data)
svg
.selectAll('g')
.data(root.leaves(), d => d.data.id)
.join(
enter => enterBoxAndName(enter),
update => updateBoxAndName(update)
)
@afcondon
afcondon / scale images preserving ratios.hs
Last active December 4, 2017 10:12
bones of image file rescaler to be fitted into Hakyll site
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeOperators #-}
module Main where
import Codec.Picture
import Codec.Picture.Types as M
import System.Environment (getArgs)
import System.FilePath (replaceExtension)
import qualified Codec.Picture.Metadata as M
@afcondon
afcondon / simple pickles.hs
Created October 28, 2017 09:32
tiny fragment showing so-simple-they're-not-documented HXT pickler examples
-- targeting this XML:
-- <label id="123">do</label>
xpLabel :: PU Label
xpLabel = xpElem "label" $
xpWrap ( uncurry Label
, \l -> (lid l, ltext l)
) $
xpPair (xpAttr "id" xpickle)
(xpXmlText)
module PackageData where
import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Exception (Error)
import D3.Base (D3)
import D3.ForceSimulation (GroupedForceLayout)
import Data.Array (zip, concatMap, (!!), (:), (..), nub, length)
import Data.Either (Either(Right, Left))
@afcondon
afcondon / ArgonautAlt.purs
Created October 26, 2016 07:42
Pulling a record (ie naked JSON object) of one of two types out of a JSON string using purescript-argonaut and Alt instance of Either
module Main where
import Prelude
import Control.Alt ((<|>))
import Data.Argonaut (Json, decodeJson, (.?))
import Data.Either (Either)
data Response = A { commandResponse :: String, value :: String }
| B { command :: String, value :: Int }
module Main where
import Control.Monad.Eff.Console (CONSOLE)
import D3.Base (PolyValue(SetByIndex), D3, Eff, Index, D3Element, Nodes, AttrSetter(..), DataBind(..), (..), (...))
import D3.Selection (text, style, attr, append, enter, dataBind, selectAll, getAttr, d3Select)
import D3.Tree (size, HierarchyNode, descendants, layoutTree, d3Hierarchy, d3Tree, hasChildren, parent)
import Data.Array (drop)
import Data.Maybe (Maybe(..))
import Prelude (show, pure, bind, (<>), Unit, unit, (-), ($), (/), (+), (<$>), negate)
module Main where
import Control.Monad.Eff.Console (CONSOLE)
import D3.Base (D3, Eff, D3Element, Index, Point, AttrSetter(..), DataBind(..), ListenerType(..), PolyValue(..), Typenames(..), (...), (..))
import D3.Drag (addDragListener, d3Drag, dragUpdate)
import D3.Scale (scaleBy, schemeCategory10, ScaleType(Category), d3Scale)
import D3.Selection (call, style, attr, append, enter, dataBind, selectAll, d3Select, selectElem)
import D3.Zoom (addZoomListener, scaleExtent, d3Zoom, getZoomEvent)
import Data.Maybe (Maybe(..))
import Prelude (Unit, unit, pure, bind)