Skip to content

Instantly share code, notes, and snippets.

@staltz
staltz / introrx.md
Last active June 29, 2024 15:58
The introduction to Reactive Programming you've been missing
@alexr
alexr / GrammarEnumeration.fs
Created October 25, 2014 22:13
This is an F# implementation of the Omega monad as it appears, more or less, on http://hackage.haskell.org/package/control-monad-omega. Type annotations are for reading convenience.
(**
And of cause translation of the context free grammar enumeration example
from [Luke Palmer's post](http://lukepalmer.wordpress.com/2008/05/02/enumerating-a-context-free-language/)
which was my original inpiration to use Omega.
Notice the explicit addition of laziness to allow recursive use of
`symbol` literals in a list. Alternatively one can define, say:
```
type 'a symbol =
| Terminal of 'a
@thenickdude
thenickdude / sfinae.cpp
Created February 22, 2016 10:27
C++ SFINAE: Call a 2 argument constructor if it exists for a templated type, otherwise call the no-arg constructor
#include <iostream>
#include <type_traits>
#include <cstdint>
#include <cstddef>
// Or we can use enable_if from Boost:
template <bool, typename T = void>
struct enable_if {
};
@jonschlinkert
jonschlinkert / zip.js
Last active February 8, 2024 08:26
versatile JavaScript "zip" function. Works with objects, arrays, and yep - even strings.
function zip(a, b) {
var arr = [];
for (var key in a) arr.push([a[key], b[key]]);
return arr;
}
console.log(zip('foo', 'bar'));
//=> [ [ 'f', 'b' ], [ 'o', 'a' ], [ 'o', 'r' ] ]
console.log(zip(['a', 'b', 'c'], ['x', 'y', 'z']));
@cryzed
cryzed / fix-infinality.md
Last active June 24, 2024 02:24
A set of instructions on how to fix the harfbuzz + Infinality issue and restoring good-looking, Infinality-like font rendering.

Disclaimer: Please follow this guide being aware of the fact that I'm not an expert regarding the things outlined below, however I made my best attempt. A few people in IRC confirmed it worked for them and the results looked acceptable.

Attention: After following all the steps run gdk-pixbuf-query-loaders --update-cache as root, this prevents various gdk-related bugs that have been reported in the last few hours. Symptoms are varied, and for Cinnamon the DE fails to start entirely while for XFCE the icon theme seemingly can't be changed anymore etc.

Check the gist's comments for any further tips and instructions, especially if you are running into problems!

Screenshots

Results after following the guide as of 11.01.2017 13:08:

@luizcarraro
luizcarraro / open-external-link.js
Created July 27, 2017 11:37
ELECTRON: Open link in external default OS browser
@meskarune
meskarune / vimrc
Last active November 3, 2023 07:58
simple functional vim status line - jellybeans theme colors
" status bar colors
au InsertEnter * hi statusline guifg=black guibg=#d7afff ctermfg=black ctermbg=magenta
au InsertLeave * hi statusline guifg=black guibg=#8fbfdc ctermfg=black ctermbg=cyan
hi statusline guifg=black guibg=#8fbfdc ctermfg=black ctermbg=cyan
" Status line
" default: set statusline=%f\ %h%w%m%r\ %=%(%l,%c%V\ %=\ %P%)
" Status Line Custom
let g:currentmode={
@corpix
corpix / numbers.nix
Last active February 7, 2024 01:42
pow, decimal to hex, hex to decimal in nix language
{ lib }:
with lib; rec {
pow =
let
pow' = base: exponent: value:
# FIXME: It will silently overflow on values > 2**62 :(
# The value will become negative or zero in this case
if exponent == 0
then 1
else if exponent <= 1
@jahkeup
jahkeup / configuration.nix
Created April 21, 2018 22:17
NixOS qcow2 build
{ hostName, pkgs, ... }:
{
imports = [
./hardware.nix
];
networking.hostName = hostName;
time.timeZone = "America/Los_Angeles";
system.copySystemConfiguration = true;
@adisbladis
adisbladis / podman-shell.nix
Last active May 12, 2024 09:21
Use podman within a nix-shell
{ pkgs ? import <nixpkgs> {} }:
let
# To use this shell.nix on NixOS your user needs to be configured as such:
# users.extraUsers.adisbladis = {
# subUidRanges = [{ startUid = 100000; count = 65536; }];
# subGidRanges = [{ startGid = 100000; count = 65536; }];
# };