Skip to content

Instantly share code, notes, and snippets.

@yairchu
yairchu / test.cpp
Last active May 3, 2021 11:53
operator<< for STL types
#include <iostream>
#include <map>
#include <vector>
// Adding forward declarations would make this compile
// template <typename K, typename V>
// std::ostream& operator<< (std::ostream&, const std::map<K, V>&);
// template <typename T>
@yairchu
yairchu / verboseprism.hs
Last active September 6, 2023 07:57
Prisms with error reporting
{-# LANGUAGE
RankNTypes,
TypeFamilies,
DeriveFunctor,
FlexibleContexts,
DefaultSignatures,
FlexibleInstances,
MultiParamTypeClasses
#-}
@yairchu
yairchu / ast-parsing-with-prisms.hs
Last active December 29, 2019 15:17
Parsing a simple AST with Prisms (without detailed syntax error reporting)
{-# LANGUAGE RankNTypes, TupleSections, TemplateHaskell, DeriveGeneric #-}
import Control.Applicative
import Control.Lens
import qualified Data.Char as Char
import GHC.Generics
import Test.QuickCheck
import Test.QuickCheck.Arbitrary.ADT
data Expr
@yairchu
yairchu / bug.c
Created August 5, 2018 15:49
IPP sqrt bug
#include <stdio.h>
#include "ipps.h"
int main()
{
float t;
(*(int*)&t) = 3116044;
printf ("%g %g\n", t, sqrtf (t));
IppStatus status = ippsSqrt_32f_I (&t, 1);
printf ("%g %d\n", t, status);
{-# LANGUAGE RankNTypes, StandaloneDeriving, TemplateHaskell, UndecidableInstances #-}
module Data.Tree.Diverse
( Node(..), _Node
, Children(..), overChildren
, Ann(..), ann, val
) where
import qualified Control.Lens as Lens
import Data.Functor.Const (Const(..))
infixr 4 %%@~, <%@~, %%~, <+~, <*~, <-~, <//~, <^~, <^^~, <**~
infix 4 %%@=, <%@=, %%=, <+=, <*=, <-=, <//=, <^=, <^^=, <**=
infixr 2 <<~
infixr 9 #.
infixl 8 .#
infixr 8 ^!, ^@!
infixl 1 &, <&>, ??
infixl 8 ^., ^@.
infixr 9 <.>, <., .>
infixr 4 %@~, .~, +~, *~, -~, //~, ^~, ^^~, **~, &&~, <>~, ||~, %~
@yairchu
yairchu / AltClick.cpp
Created November 20, 2017 13:20
AltClick class for JUCE (attempt)
#include "AltClick.h"
using namespace juce;
AltClick::AltClick()
{
coveredComponent_ = nullptr;
isAltClickEvent_ = false;
}
@yairchu
yairchu / PluginListManager.cpp
Last active February 13, 2017 15:15
PluginListManager for JUCE
#include "PluginListManager.h"
class PluginListManager::Window : public DocumentWindow
{
public:
Window (PluginListManager* manager)
: DocumentWindow (
"Available Plugins", Colours::white,
DocumentWindow::minimiseButton | DocumentWindow::closeButton)
, manager_ (manager)
@yairchu
yairchu / AudioProcessorParameterSlider.cpp
Last active November 23, 2016 10:57
AudioProcessorParameterSlider for JUCE
#include "AudioProcessorParameterSlider.h"
using namespace juce;
AudioProcessorParameterSlider::AudioProcessorParameterSlider()
{
initParameter(nullptr);
}
AudioProcessorParameterSlider::AudioProcessorParameterSlider (const AudioProcessorParameter* p)
@yairchu
yairchu / AudioProcessorUndoAttachment.cpp
Last active March 31, 2024 05:05
AudioProcessorUndoAttachment for JUCE
#include "AudioProcessorUndoAttachment.h"
using namespace juce;
class AudioProcessorUndoAttachment::ChangeAction : public UndoableAction
{
public:
ChangeAction (AudioProcessor*);
bool perform() override;