Skip to content

Instantly share code, notes, and snippets.

View roobie's full-sized avatar

Björn Roberg roobie

View GitHub Profile
@bert2
bert2 / Option.cs
Last active September 20, 2022 01:28
copy & paste: lightweight implementation of the famous `Maybe` monad/functor with async support
/**
* Lightweight implementation of the famous `Maybe` type that safely wraps
* optional values without using `null` references.
*
* Add this file to your project and get three new namespaces:
* - `Option`: the base type, factories, operators (map, bind, filter, tap,
* flatten), and means to get the contained value.
* - `Option.Extras`: some utility functions like `IEnumerable.FirstOrNone()`,
* combinators (and, or, ...), and maybe-ready `TryParse` functions.
* - `Option.Async`: async variants of the operators so you can bind against
@sogaiu
sogaiu / peg-exercises.janet
Last active November 11, 2022 00:27
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
@greggirwin
greggirwin / red-object-browser.red
Last active October 16, 2020 17:48
Red Object Browser
Red [
title: "Red Object Browser"
author: "Gregg Irwin"
needs: 'View
]
e.g.: :comment
map-ex: func [
"Evaluates a function for all values in a series and returns the results."
@mars888
mars888 / config.el
Last active July 3, 2017 22:17
Quick and dirty Spacemacs configuration layer for Tide and TypeScript
(spacemacs|defvar-company-backends typescript-mode)
@miebach
miebach / git-log-pretty
Last active May 28, 2024 11:31
pretty git log graph with coloured branches
# Visualizing branch topology in git on the commandline
git log --graph --oneline --full-history --all
git log --graph --full-history --all --pretty=format:"%h%x09%d%x20%s"
# With colors in Bash:
git log --graph --full-history --all --color --pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s"
var formatString = (function () {
/**
formatString
Expected arguments:
format[0]: <String> The format. It uses a specific interpolation notation.
data[1]: <Object|Array<Object>> The data to interpolate
Throws:
TypeError: If format is null or undefined
@nferrari
nferrari / strategy.py
Last active March 25, 2016 14:36
django-oscar french strategy
# myapp/partner/strategy.py
from decimal import Decimal as D
from oscar.apps.partner import strategy, prices
DEFAULT_RATE = D('0.196')
PRODUCT_CLASSES_RATES = {
'cours': 0,
@joladev
joladev / defer.js
Last active December 21, 2015 03:19
var defer = function () {
var value,
resolution,
handlers = {};
var fulfill = function () {
if (resolution) {
var handler = handlers[resolution];
if (handler) {
handler();
@plukevdh
plukevdh / leven.ex
Created November 28, 2012 18:17
Levenshtein in elixir
defmodule Levenshtein do
def first_letter_check(one_letter, two_letter) do
case one_letter == two_letter do
true -> 0
false -> 1
end
end
def distance(string_1, string_1), do: 0
def distance(string, ''), do: :string.len(string)
@yevgenko
yevgenko / .Xdefaults
Created August 24, 2011 02:58
URxvt settings with solarized theme
!-------------------------------------------------------------------------------
! Xft settings
!-------------------------------------------------------------------------------
Xft.dpi: 96
Xft.antialias: false
Xft.rgba: rgb
Xft.hinting: true
Xft.hintstyle: hintslight