Skip to content

Instantly share code, notes, and snippets.

@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
@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
}
@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"
@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}"
@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
@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
@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
@fawda123
fawda123 / gar_fun.r
Last active September 3, 2021 16:32
gar_fun
gar.fun<-function(out.var,mod.in,bar.plot=T,struct=NULL,x.lab=NULL,
y.lab=NULL, wts.only = F){
require(ggplot2)
require(plyr)
# function works with neural networks from neuralnet, nnet, and RSNNS package
# manual input vector of weights also okay
#sanity checks
@quchen
quchen / trolling_haskell
Last active February 24, 2024 01:30
Trolling #haskell
13:15 <xQuasar> | HASKELL IS FOR FUCKIN FAGGOTS. YOU'RE ALL A BUNCH OF
| FUCKIN PUSSIES
13:15 <xQuasar> | JAVASCRIPT FOR LIFE FAGS
13:16 <luite> | hello
13:16 <ChongLi> | somebody has a mental illness!
13:16 <merijn> | Wow...I suddenly see the error of my ways and feel
| compelled to write Node.js!
13:16 <genisage> | hi
13:16 <luite> | you might be pleased to learn that you can compile
| haskell to javascript now
@snoyberg
snoyberg / test.xml
Created February 11, 2013 16:52
xml-conduit + lens
<foo>
<bar>
<baz>
<bin/>
</baz>
</bar>
<bar/>
</foo>