Skip to content

Instantly share code, notes, and snippets.

View roobie's full-sized avatar

Björn Roberg roobie

View GitHub Profile
@roobie
roobie / SmartMapper.cs
Created March 13, 2022 14:18
mapping things
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Reflection;
using Xunit;
namespace Shovel.Lib
{
@roobie
roobie / DTO.cs
Created March 11, 2022 00:50
make a dto via reflection
using System.Data;
using System.Reflection;
using System.Collections.Generic;
using System.Linq;
namespace Shovel.Lib;
public static class DataTableExtensions
{
public static IEnumerable<T> IntoDtos<T>(this DataRowCollection rows)
@roobie
roobie / Option.Extras.cs
Created March 18, 2021 23:25
.NET Option type re-using LINQ
using System;
namespace Option.Abstractions
{
public static class OptAbstractions
{
public static Option<T> ToOption<T>(this T value)
where T: class
{
if (value == null)
/* ==UserStyle==
@name don't kill my eyes, OLD reddit
@version 1.0.0
@description my old.reddit.com style
@author bjorn
@namespace bjorn
@updateURL https://gist.github.com/roobie/c8d28599acd3116363fc1b917c6737c0/raw/d57be0ee4a489315d868a8ad469f18b0ec7a2e08/old.reddit.com.user.css
@license CC-BY-NC-SA-4.0
==/UserStyle== */
@-moz-document domain("old.reddit.com") {
@roobie
roobie / bitsnbobs.lua
Created February 28, 2021 16:54
bitsnbobs
local bit = require("bit")
local function u8_ToBinaryRepresentation (u8)
local function AND (x, v)
local res = bit.band(x, v)
if res ~= 0 then
return 1
else
return 0
end
@roobie
roobie / red-tape.sh
Created June 9, 2020 13:58
app in docker as paas
#!/usr/bin/env bash
set -e
set -u
export BASEDIR="$HOME"
export APP=appname
export APPDIR="$BASEDIR/$APP"
export DOCKER_OPTS=""
unset GIT_DIR
@roobie
roobie / peg-exercises.janet
Created June 9, 2020 10:09 — forked from sogaiu/peg-exercises.janet
janet peg exercises
# find * and + to be confusing, trying to use sequence and choice instead
(def peg-simple
~{:main (capture (some :S))})
(peg/match peg-simple "hello") # @["hello"]
# from:
# https://janet-lang.org/docs/peg.html
(defn finder
@roobie
roobie / default-ldflags-with-runpath.janet
Created May 31, 2020 15:13
default-ldflags-with-runpath
(def *default-ldflags* "-s")
(def zlib {:path "/abc/zlib"})
(def libuv {:path "/abc/libuv"})
(defn default-ldflags-with-runpath [&keys collections]
(var to-join @[])
(each key (keys collections)
(let [prefix (string "/" key)
libs (in collections key)
extra (join-pkg-paths ":" prefix libs)]
(set to-join (array/concat to-join extra))))
@roobie
roobie / user-style.css
Last active May 30, 2020 23:40
generic Stylus user style for dark mode
:root { /* Borrowed from nim-lang.org */
--primary-background: #171921;
--secondary-background: #1e202a;
--third-background: #2b2e3b;
--border: #0e1014;
--text: #fff;
--anchor: #8be9fd;
--anchor-focus: #8be9fd;
--input-focus: #8be9fd;
--strong: #bd93f9;
(import ./testament/src/testament :as t)
(comment ```
this code is a crude implementation of a TAP style renderer.
I've tried a couple of formatters found here https://www.npmjs.com/package/tape#pretty-reporters,
Some of which work pretty good, whereas others are a bit weird.```)
(def space " ")