Skip to content

Instantly share code, notes, and snippets.

View DoctorRyner's full-sized avatar
🏠
Working from home

Rainer Reinhardt DoctorRyner

🏠
Working from home
View GitHub Profile
@DoctorRyner
DoctorRyner / list.c
Created February 27, 2018 17:14 — forked from pseudomuto/list.c
Blog Code: Implementing a Generic Linked List in C
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "list.h"
void list_new(list *list, int elementSize, freeFunction freeFn)
{
assert(elementSize > 0);
list->logicalLength = 0;
#!/bin/sh
# run it instead of cabal
find . -maxdepth 2 -name package.yaml -exec hpack {} \;
exec cabal "$@"
@DoctorRyner
DoctorRyner / TestServer.hs
Last active September 8, 2019 18:22
JSaddle with statiс files serving
{-# LANGUAGE CPP #-}
module TestServer where
#ifndef ghcjs_HOST_OS
import Network.Wai.Handler.Warp
import Network.Wai.Middleware.Static
import Network.WebSockets (defaultConnectionOptions)
import Language.Javascript.JSaddle.Run (syncPoint)
@DoctorRyner
DoctorRyner / init.toml
Last active October 1, 2019 21:08
SpaceVim Config
# ~/.SpaceVim.d/init.toml
# All SpaceVim option below [option] section
[options]
# set spacevim theme. by default colorscheme layer is not loaded,
# if you want to use more colorscheme, please load the colorscheme
# layer
colorscheme = 'one'
colorscheme_bg = 'dark'
# Disable guicolors in basic mode, many terminal do not support 24bit
@DoctorRyner
DoctorRyner / Main.lua
Created January 17, 2020 16:40
main = log $ show 0
local ____modules = {}
local ____moduleCache = {}
local ____originalRequire = require
local function require(file)
if ____moduleCache[file] then
return ____moduleCache[file]
end
if ____modules[file] then
____moduleCache[file] = ____modules[file]()
@DoctorRyner
DoctorRyner / Main.lua
Created January 17, 2020 16:44
Optional type test
local ____modules = {}
local ____moduleCache = {}
local ____originalRequire = require
local function require(file)
if ____moduleCache[file] then
return ____moduleCache[file]
end
if ____modules[file] then
____moduleCache[file] = ____modules[file]()
module Babylon.Data.V where
import Data.Aeson
import GHC.Generics
import JS
data V2 = V2 { x, y :: Float } deriving (Show, Generic)
instance ToJSVal V2 where
toJSVal v = newb "Vector2" [v.x, v.y]
#=============================================================================
# dark_powered.toml --- dark powered configuration example for SpaceVim
# Copyright (c) 2016-2017 Wang Shidong & Contributors
# Author: Wang Shidong < wsdjeg at 163.com >
# URL: https://spacevim.org
# License: GPLv3
#=============================================================================
[options]
colorscheme = "one"
-- Something like this
$(gen "position" ''Mesh ''V3)
-- Should generate that
getPosition :: Mesh -> JSM V3
getPosition = get "position"
setPosition :: V3 -> Mesh -> JSM ()
setPosition = set "position"
const
mkEvent = <ActionType> (action: ActionType) => (dispatch: Dispatch<ActionType>) => () => dispatch (action)
, mkEventF = <A, ActionType> (f: (x: A) => ActionType) => (dispatch: Dispatch<ActionType>) => (x: A) => dispatch (f (x))