Skip to content

Instantly share code, notes, and snippets.

@puffnfresh
puffnfresh / Partiality.hs
Created August 13, 2013 16:11
Partiality monad in Haskell using Free Maybe.
module Partiality where
import Control.Monad.Free
type Partiality = Free Maybe
never :: Partiality a
never = Free $ Just never
bad :: Partiality a
@carlj
carlj / rsa-encryption.md
Last active February 28, 2020 07:01
RSA large File En- and Decryption

RSA File De- and Encryption

Docu for encrypt and decrypt a large file with AES and RSA

Keypairs

Generate RSA Keypairs

//generates a private Key with 8196 Bit. 
openssl genrsa -out private.pem 8196
@menugget
menugget / plot.stream.4.R
Last active February 25, 2019 18:46
Stream plot.
#plot.stream makes a "stream plot" where each y series is plotted
#as stacked filled polygons on alternating sides of a baseline.
#
#Arguments include:
#'x' - a vector of values
#'y' - a matrix of data series (columns) corresponding to x
#'order.method' = c("as.is", "max", "first")
# "as.is" - plot in order of y column
# "max" - plot in order of when each y series reaches maximum value
# "first" - plot in order of when each y series first value > 0
@nickjacob
nickjacob / systemd-prblm.service
Last active March 17, 2023 16:11
execute arbitrary bash code/variable substitution in systemd units
[Unit]
Description=Demonstrate Bash
[Service]
ExecStartPre=/usr/bin/bash -c "/usr/bin/systemctl set-environment MYVAR=$(( 2 + 2 ))"
ExecStart=/usr/bin/echo "2 + 2 = ${MYVAR}"
@hlissner
hlissner / replace.sh
Last active September 11, 2023 10:14
Bulk search & replace with ag (the_silver_searcher)
# ag <https://github.com/ggreer/the_silver_searcher>
# usage: ag-replace.sh [search] [replace]
# caveats: will choke if either arguments contain a forward slash
# notes: will back up changed files to *.bak files
ag -0 -l $1 | xargs -0 perl -pi.bak -e "s/$1/$2/g"
# or if you prefer sed's regex syntax:
ag -0 -l $1 | xargs -0 sed -ri.bak -e "s/$1/$2/g"
@timjstewart
timjstewart / cabal-init
Last active August 29, 2015 14:10
Quickly create a scratch cabal sandbox and project complete with hspec/QuickCheck tests.
#! /bin/bash
package_name=$(basename `pwd`)
log_file=./cabal-init.log
function fatal() {
echo "$1. Examine ${log_file} for more information." 2>&1
exit 1
}
@zmoazeni
zmoazeni / gist:a035f72f0c9d0931f471
Last active August 29, 2015 14:10
Run interpreter and REPL using cabal sandbox packages
cabal exec -- ghci # starts ghci with cabal sandbox set
cabal exec -- runghc ... # runs runghc with cabal sandbox set
@jkominek
jkominek / updatestars.py
Last active March 26, 2022 15:21
Maintain a mirror of all your Github stars.
#!/usr/bin/python
#################
# NOTE
# Now at https://github.com/jkominek/updatestars
#################
import requests
import json
import re
@TheBB
TheBB / loading.org
Last active June 22, 2023 11:53
Loading in Spacemacs

Emacs packages, features, files, layers, extensions, auto-loading, require, provide, use-package… All these terms getting you confused? Let’s clear up a few things.

Files

Emacs files contains code that can be evaluated. When evaluated, the functions, macros and modes defined in that file become available to the current Emacs session. Henceforth, this will be termed as loading a file.

One major problem is to ensure that all the correct files are loaded, and in the

@spaceCamel
spaceCamel / NOTES.md
Last active March 20, 2020 17:20
PulseAudio + Bluetooth Headset

After updating the configuration

nixos-rebuild switch

I had to restart the system for pulseaudio to load the bluetooth module.

pactl list should show the bluetooth module.

As I'm not using a desktop-manager I've configured the device from the command line following ArchLinux instructions