Skip to content

Instantly share code, notes, and snippets.

View leobm's full-sized avatar

Felix Wittmann leobm

  • Hamburg, Germany
View GitHub Profile
@leobm
leobm / main.gleam
Last active November 3, 2023 11:35
import writer
import string_writer
pub fn main() {
string_writer.create()
|> writer.write("Text1")
|> writer.write("Text2")
|> string_writer.print()
}
@leobm
leobm / my_app.ex
Created January 4, 2023 21:35 — forked from alanpeabody/my_app.ex
Websockets in Elixir with Cowboy and Plug
defmodule MyApp do
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
Plug.Adapters.Cowboy.child_spec(:http, MyApp.Router, [], [
dispatch: dispatch
])
@leobm
leobm / ruby-fmt.clj
Created December 19, 2022 01:44 — forked from fogus/ruby-fmt.clj
Ruby-like string interpolation in Clojure
; Ruby has an awesome feature -- string interpolation. Read about it on the internet.
; On the other hand, Clojure only has cumbersome Java string formatting, which can not be
; used without pain after you've tried Ruby.
; So here's this simple macro that basically allows you to do most things you could do
; with Ruby string interpolation in Clojure.
(ns eis.stuff
(:require [clojure.string]))
@leobm
leobm / gist:6061734
Created July 23, 2013 11:41
break point in clojure - A macro from 《the joy of clojure》 for debugging:
(defn contextual-eval [ctx expr]
(eval
`(let [~@(mapcat (fn [[k v]] [k `'~v]) ctx)]
~expr)))
(defmacro local-context []
(let [symbols (keys &env)]
(zipmap (map (fn [sym] `(quote ~sym)) symbols) symbols)))
(defn readr [prompt exit-code]
(let [input (clojure.main/repl-read prompt exit-code)]
(if (= input ::tl)
@leobm
leobm / youtube_comments_deleter.js
Last active July 29, 2021 10:33
Delete youtube comments activity
// ==UserScript==
// @name Delete youtube comments activity
// @version 1
// @grant none
// @include https://myactivity.google.com/page*
// ==/UserScript==
const DELETE_MAX_ENTRIES_AFTER_PAGE_RELOAD = 1;
(function(d) {
@leobm
leobm / echo-ws-server.pl
Created June 21, 2020 15:52 — forked from willprice/echo-ws-server.pl
SWI-Prolog echo server with some JSON manipulation using websockets.
% INSTRUCTIONS
% =swipl echo-server.pl=
% =:- start_server.=
%
% Then navigate to http://localhost:3000 in your browser
:- module(echo_server,
[ start_server/0,
stop_server/0
module Main where
import Prelude
import Control.Monad.Reader (Reader, runReader, ReaderT(..), runReaderT, ask, class MonadAsk)
import Effect (Effect)
import Effect.Class (class MonadEffect, liftEffect)
import Effect.Console (log)
---------------------------------------------------------
@leobm
leobm / generic-deriving.purs
Created December 14, 2020 13:41 — forked from dlants/generic-deriving.purs
Generic deriving with purescript
-- an example of how to derive a show instance for a Maybe type
-- not totally sure why `derive instance showMyMaybe :: (Show a) => Show (MyMaybe a)` errors with...
-- error: CannotDerive :
-- Cannot derive a type class instance for Data.Show.Show (MyMaybe a) since instances of this type class are not derivable.
module Main where
import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, log)
@leobm
leobm / json.hs
Created December 14, 2020 13:32 — forked from fero23/json.hs
JSON Parser with Haskell's Parsec
import Text.ParserCombinators.Parsec
import Data.List
type Args = [String]
type Body = [String]
type Label = String
data JSONProp = JSONProp Label JSON deriving Show
data JSON = JSONObject [JSONProp]
| JSONNumber Double
@leobm
leobm / JSONParser.hs
Created December 14, 2020 13:31 — forked from zearen/JSONParser.hs
A simple haskell demonstation showing parsing JSON with Parsec
{-
Zachary Weaver <zaw6@pitt.edu>
JSONParser.hs
Version 0.1.1
A simple example of parsing JSON with Parsec in haskell. Note that
since the primary point of this excersize is demonstration,
Text.Parsec.Token was avoided to expose more of the grammar. Also,
complicated optimizations and shorcuts were avoided (mostly).