Skip to content

Instantly share code, notes, and snippets.


Joan Arnaldich jarnaldich

View GitHub Profile
jarnaldich / my-match-lambda.rkt
Created Oct 24, 2014
Racket genericity with match-lambda clauses
View my-match-lambda.rkt
#lang racket
(provide my-match-lambda*
(struct-out my-match-lambda-procedure)
(struct-out exn:fail:my-match-lambda:no-match)
(struct-out exn:fail:my-match-lambda:no-match:next-clause)
jarnaldich / SumXmlField.hs
Created Mar 31, 2017
Add fields from a directory tree with XML files using lenses, Directory Tree
View SumXmlField.hs
#!/usr/bin/env stack
--resolver lts-4.2
--install-ghc runghc
--package xml-lens
--package directory-tree
{-# LANGUAGE OverloadedStrings #-}
module Main where
jarnaldich / tick.psm1
Created Jun 6, 2017
Sample Code for Blog Post on Porting Unix Philosophy To Windows
View tick.psm1
function Sample-Count-Files {
# The file pattern to count
# Name of the log file
jarnaldich / flightDates.hs
Created Nov 28, 2018
[Using Text.XML.Lens with namespaces] Example of using namespaces for Text.MXL.Lens #haskell #xml #stack #script
View flightDates.hs
#!/usr/bin/env stack
--install-ghc runghc
--package xml-lens
{-# LANGUAGE OverloadedStrings #-}
module Main where
import System.Environment (getArgs)
import Text.XML
jarnaldich / parCurl.hs
Created Nov 29, 2018
[Concurrent Curl in Haskell] Concurrency in Haskell #haskell #concurrency #parallel #network
View parCurl.hs
#!/usr/bin/env stack
{- stack --resolver lts-12.20 --install-ghc runghc
--package random --package async --package stm-chans --package wreq --package cassava
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE DeriveGeneric #-}
import Control.Exception
import Control.Concurrent.Async (mapConcurrently, concurrently)
jarnaldich / FileWatcher.ps1
Created Feb 6, 2019
Powershell File System Watcher #powershell #watch #filesystem
View FileWatcher.ps1
$w = New-Object System.IO.FileSystemWatcher
$w.Path= pwd
$w.Filter= "*.py"
$w.EnableRaisingEvents = $true
$action = { (&{ cls; $p = $Event.SourceEventArgs.FullPath; python $p }) 2>&1 | Write-Host }
$changed = Register-ObjectEvent $w "Changed" -Action $action
Unregister-Event $changed.Id
jarnaldich / Makefile
Created Feb 27, 2019
[sample makefile for image transformation] takes a directory of input files and performs 2 chained transformations #make #makefile
View Makefile
TXTS=$(shell CMD /C DIR /B Z:\mrsids\params)
OUTS=$(patsubst %.tif,$(OUT)%.tif,$(TXTS:.txt=.tif))
SIDS=$(patsubst %.sid,$(OUT)%.sid,$(TXTS:.txt=.sid))
target: $(SIDS)
$(OUT)%.tif : Z:\mrsids\params\%.txt
\\icgc.local\aplicacions\produccio\DFApplications\ICCImageOperationsGeocorrection\exe\ICCImageGeoTransformation.exe < $<
jarnaldich /
Last active Jul 15, 2019
[PrepareWSL] Prepare WSL for remote acess #wsl #zsh
sudo apt-get purge openssh-server
sudo apt-get install openssh-server
sudo apt install -y zsh
sh -c "$(curl -fsSL"
# Can change THEME to agnoster in .zshrc
curl -LO
chmod u+x nvim.appimage
jarnaldich /
Last active Feb 25, 2020
Start a F# Dotnet.Core Project
# To install dotnet on windows choco install -y dotnetcore-sdk
dotnet new console -lang F# -o $PRJ
cd $PRJ
dotnet add package FSharp.Data
# The only working one I could find...
dotnet add package -v 2.4.2 GDAL.Native
jarnaldich /
Last active Dec 12, 2019
Recuperar Backup Postgres #postgresql #backup #shell
DATE=`date +%Y%m%d`
PGPASSWORD=$SRCPASS /usr/lib/postgresql/9.5/bin/pg_dump -F c --file /mnt/d/public/lliscat_$DATE.backup --host --username postgres --format=c --blobs $SRC_DBNAME
PGPASSWORD=$DSTPASS psql -h phineas -U postgres <<END
SELECT pg_terminate_backend(pid)
FROM pg_stat_activity
WHERE pid <> pg_backend_pid() AND datname = '$TARGET_DBNAME';