Skip to content

Instantly share code, notes, and snippets.

View quephird's full-sized avatar

danielle quephird

View GitHub Profile

OK... this has very weak support for the %f format specification, but it works:

module IO.Printf

toOctal : Int -> String
toOctal n = let (q, r) = (div n 8, mod n 8) in
            case q == 0 of
              True => show r
              False => toOctal q ++ show r
Torus[r1_, r2_, c_] :=
(* Produces a torus with major radius r1 and minor radius r2,
with surface color c and parallel with the xy plane. *)
ParametricPlot3D[
{Cos[t] (r1 + r2 Cos[u]), Sin[t] (r1 + r2 Cos[u]), Sin[u]},
{t, 0, 2 Pi}, {u, 0, 2 Pi},
ColorFunction -> (c &),
Mesh -> None,
PlotPoints -> 10,
PlotRange -> {{-3, 3}, {-3, 3}, {-3, 3}}]

Finding long running queries in Postgres

There have been a few times in the last several months at $DAY_JOB during which the following query, or some slight variation of it, has been used to identify long-running and potentially problematic queries:

select  pid,
        now() - query_start as duration,
        query,
class Lexer
KEYWORDS = ["def", "class", "if", "true", "false", "nil"]
IDENTIFIER_REGEX = /\A([a-z]\w*)/
CONSTANT_REGEX = /\A([A-Z]\w*)/
NUMBER_REGEX = /\A([0-9]+)/
STRING_REGEX = /\A"([^"]*)"/
NEW_BLOCK_REGEX = /\A\:\n( +)/m
INDENT_REGEX = /\A\n( *)/m
OPERATOR_REGEX = /\A(\|\||&&|==|!=|<=|>=)/
Sound[
{{"A", 0.3}, {"G", 0.3}, {"F", 0.3}, {"G", 0.3}, {"A", 0.3}, {"A", 0.3}, {"A", 0.6},
{"G", 0.3}, {"G", 0.3}, {"G", 0.6}, {"A", 0.3}, {"C5", 0.3}, {"C5", 0.6},
{"A", 0.3}, {"G", 0.3}, {"F", 0.3}, {"G", 0.3}, {"A", 0.3}, {"A", 0.3},
{"A", 0.6}, {"G", 0.3}, {"G", 0.3}, {"A", 0.3}, {"G", 0.3}, {"F", 0.6}}
/. {p_, d_} :>
SoundNote[{p}, d, "Harpsichord"]]
#version 3.7;
global_settings {
assumed_gamma 1.0
}
#include "colors.inc"
#include "functions.inc"
#include "shapes.inc"
#include "shapes2.inc"
#include "stones.inc"
@quephird
quephird / Add button.purs
Last active February 16, 2017 23:51
Just a silly experiment with `purescript-dom` to create a button and add it to the document body.
import Prelude
import Data.Maybe
import Data.Nullable
import DOM.HTML as h
import DOM.HTML.Document as hd
import DOM.HTML.Types as ht
import DOM.HTML.Window as w
import DOM.Node.Document as nd
import DOM.Node.Node as n
import DOM.Node.Types as nt
@quephird
quephird / Keyboard shortcuts.txt
Last active February 15, 2018 21:46
VERY IMPORTANT DOCUMENT! DO NOT ERASE!
bettyboop ꒰❛◑.◑❜꒱
blushh ꒰✿ᵕ‿ᵕ✿꒱
blusshh ꒰🔴ᵕ‿ᵕ🔴꒱
cryy ༼ ༎ຶ ෴ ༎ຶ༽
davidcaruso (•_•)( •_•)>⌐■-■ (⌐■_■)
derpp ◴_◶
drooll :Q____     |_____ |______
facepalmdouble (ლ̂‸ლ̂)
facepalmm (-‸ლ)
flipp (╯°□°)╯︵

Now that Homebrew (as of this writing) downloads version 4.03 of OCaml, that ultimately breaks installation of Emily using this tap. Eventually, you'll encounter an error involving sedlex, namely that the version needed for Emily is incompatible with OCaml 4.03.0, and only works with a 4.02.x version. So... you need to manually download, compile, and install a bunch of things.

Install OCaml

The first thing you need to do is get a hold of OCaml 4.02.3 here because you can't get earlier versions of things via Homebrew. Once downloaded, move into that directory and run the following:

./configure
@quephird
quephird / gears.frag
Created March 15, 2016 05:23
Fragment shader for displaying four interlocking, rotating gears with different colors. Code still needs improvement.
uniform vec2 u_resolution;
uniform float u_time;
#define PI 3.1415926
#define GEAR_COUNT 4
#define GEAR_TEETH 10
#define GEAR_INNER_RADIUS 0.2
#define GEAR_OUTER_RADIUS 0.3
#define GEAR_TOOTH_LENGTH 0.1