Skip to content

Instantly share code, notes, and snippets.

View fghibellini's full-sized avatar
🐻
It's complicated

Filippo Ghibellini fghibellini

🐻
It's complicated
View GitHub Profile
@fghibellini
fghibellini / steps.md
Last active April 17, 2021 18:37
Getting supercollider to work on Ubuntu 20.04 LTS
  1. pacmd suspend true
  2. open qjackctl
  3. click "Setup"
  4. set "Interface" to your output
  5. set "Frames/Period" to high enough value to avoid XRuns (can be lowered later on)
  6. click "Start"
  7. open Supercollider
  8. s.boot Ctrl+Enter
  9. {SinOsc.ar(1000)}.play Ctrl+Enter
@fghibellini
fghibellini / main.hs
Created November 11, 2019 20:48
HasCallStack with argument
{-# LANGUAGE RankNTypes #-}
import Control.Monad (forM_)
import GHC.Stack
httpCall :: HasCallStack => String -> IO ()
httpCall url = do
putStrLn $ prettyCallStack callStack
print $ "GET " <> url <> " resolved"
@fghibellini
fghibellini / main.hs
Created November 8, 2019 16:30
ghc stacktraces
{-# LANGUAGE RankNTypes #-}
import Control.Monad (forM_)
import GHC.Stack
httpCall :: HasCallStack => IO ()
httpCall = do
putStrLn $ prettyCallStack $ callStack
print "http resolved"
@fghibellini
fghibellini / shell.nix
Created September 19, 2019 07:28
shell.nix file that sets up a valid `bower_components` folder to build the project and deletes it when the shell is left
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
bowerComponents = pkgs.buildBowerComponents {
name = "bower-test";
generated = ./bower-generated.nix;
src = ./.;
};
-- | Can pattern match on nonempty lists
--
-- @
-- import Custom.NonEmpty (head, pattern NEL)
-- let arr = [1,2,3]
-- case arr of
-- NEL ne -> head ne
-- [] -> 42
-- @
--
@fghibellini
fghibellini / handler1.hs
Created November 3, 2018 14:15
Servant + postgresql-simple transactions (Handler vs. IO problem)
handler1 :: String -> Handler c
handler1 emailToken = liftIO $ withTransaction conn $ do
res1 <- findEmailTokenInDB emailToken :: IO a
if !foundToken(res1)
then (throwError $ err401) -- not an IO operation
else (do
deleteToken emailToken :: IO b
authenticateUser :: IO c
)
class Observable {
constructor(gen) {
this.gen = gen;
}
subscribe(o) {
const observer = (o instanceof Observer) ? o : new Observer(o);
const cancellationFn = this.gen(observer);
return cancellationFn;
class Observable {
constructor(gen) {
this.gen = gen;
}
subscribe(o) {
const observer = (o instanceof Observer) ? o : new Observer(o);
const cancellationFn = this.gen(observer);
return cancellationFn;
diff -C 4 -r clean/wso2am-2.1.0/repository/conf/api-manager.xml wso2am-2.1.0/repository/conf/api-manager.xml
*** clean/wso2am-2.1.0/repository/conf/api-manager.xml 2017-02-02 14:49:16.000000000 +0100
--- wso2am-2.1.0/repository/conf/api-manager.xml 2017-05-24 10:02:46.865844400 +0200
***************
*** 1,9 ****
<APIManager>
<!-- JNDI name of the data source to be used by the API publisher, API store and API
key manager. This data source should be defined in the master-datasources.xml file
in conf/datasources directory. -->
! <DataSourceName>jdbc/WSO2AM_DB</DataSourceName>