Skip to content

Instantly share code, notes, and snippets.

View jarnaldich's full-sized avatar

Joan Arnaldich jarnaldich

View GitHub Profile
jarnaldich / my-match-lambda.rkt
Created October 24, 2014 10:05
Racket genericity with match-lambda clauses
#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 March 31, 2017 12:21
Add fields from a directory tree with XML files using lenses, Directory Tree
#!/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 June 6, 2017 16:18
Sample Code for Blog Post on Porting Unix Philosophy To Windows
function Sample-Count-Files {
# The file pattern to count
# Name of the log file
jarnaldich / flightDates.hs
Created November 28, 2018 14:07
[Using Text.XML.Lens with namespaces] Example of using namespaces for Text.MXL.Lens #haskell #xml #stack #script
#!/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 November 29, 2018 13:37
[Concurrent Curl in Haskell] Concurrency in Haskell #haskell #concurrency #parallel #network
#!/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 February 6, 2019 07:52
Powershell File System Watcher #powershell #watch #filesystem
$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 February 27, 2019 06:31
[sample makefile for image transformation] takes a directory of input files and performs 2 chained transformations #make #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 July 15, 2019 06:54
[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 December 12, 2019 10:09
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';
jarnaldich / RGBIZE DSM with rio calc for use with nextzen DTM tiles
Created January 29, 2020 11:15
RGBIZE DSM with rio calc for use with nextzen DTM tiles #rasterio #rio #dsm #bash
rio calc --co COMPRESS=LZW --co BIGTIFF=YES -t uint8 "(asarray (/ (+ 3278 (read 1 1)) 256) (mod (+ 3278 (read 1 1)) 256) (* 256 (- (+ 3278 (read 1 1)) (floor (+ 3278 (read 1 1))))))" $SRC $DST