Skip to content

Instantly share code, notes, and snippets.

View apraga's full-sized avatar

Alexis Praga apraga

View GitHub Profile
@apraga
apraga / config.toml
Created January 23, 2022 15:20
Helix config file
theme = "onedark"
[keys.insert]
j = { k = "normal_mode" } # Maps `jk` to exit insert mode
@apraga
apraga / reddit_api.hs
Created February 22, 2021 16:23
Reddit API in haskell
{-# LANGUAGE OverloadedStrings #-}
module Main (main) where
import Control.Monad.IO.Class
import Data.Aeson
import Network.HTTP.Req
import qualified Text.URI as URI
import Data.Maybe (fromJust)
#!/usr/bin/env bash
# Convert SIDES conf from pdf to orgmode
# Needs some manual adujst sometimes
#
set -euo pipefail
echo $1
out=$(basename $1 ".pdf")".org"
pdftotext -layout $1 $out
sed -i 's/^\s* Q/** Q/' $out #Create subheadings
@apraga
apraga / om-helpers.el
Last active February 29, 2020 14:09
Some functions to manage org-mode files with om.el
(require 'om)
(defun mark-late-todo()
;; Marke special TODO (here LATE) as done in a subtree.
;; Update the buffer directly but you need the cursor on the top of the subtree.
;; Given
;; #+TODO: TODO(t) LATE(l) | DONE(d) CANCELLED(c)
;; * TODO Root node
;; ** LATE this node
@apraga
apraga / date-node.el
Last active January 7, 2020 13:11
Org-mode : moving date node around
;; We want to convert a line with a date like this
;;2019-10-01
;;To a new datetreenode with some text, like this
;; * 2019
;; ** 2019-10 October
;; *** 2019-10-10
;; **** Handstand
;; It will create the datetree if it does not already exists
;; But I could not figure how to work directly on a org node like tis
;; * 2019-10-01
@apraga
apraga / boursorama_to_ledger.sh
Last active September 22, 2019 16:15
Importing Boursorama account into ledger
#!/usr/bin/env bash
tmp=tmp.csv
cp $1 $tmp
# Decimal notation
sed -i 's/,/\./g' $tmp
# Switch to comma
sed -i 's/;/,/g' $tmp
# Remove header
sed -i '1d' $tmp
# Add cutsom header
@apraga
apraga / convert-date.el
Created June 9, 2019 15:59
Lisp : apply a function to regexp match (converts between 2 date formats)
;; Call this function with query-replace-regexp with \,(convert-date) as the replacement (with a backslash)
;; Example of search :
;; ^\(Sun\|Mon\|Tue\|Wed\|Thu\|Fri\|Sat\).*$
(defun convert-date ()
(setq dformat "* <%Y-%m-%d>")
(setq s (match-string-no-properties 0))
(format-time-string dformat (apply #'encode-time (parse-time-string s)))
)
@apraga
apraga / Main.hs
Last active August 20, 2018 15:23
main :: IO ()
main = hakyll $ do
match "notes/*.md" $ do
route $ setExtension "tex"
compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/latex.tex" defaultContext
>>= relativizeUrls
@apraga
apraga / kdtree.py
Last active June 25, 2017 22:08
Example of searching a KD Tree with Scipy
from scipy.spatial import KDTree
import numpy as np
import itertools
import matplotlib.pyplot as plt
import random
pos = np.zeros((10, 2))
for (i, j) in itertools.product(range(10), range(2)):
pos[i,j] = random.randint(0, 10)
@apraga
apraga / gist:22bff5d8e5681907e70a
Created February 20, 2016 19:40
rtorrent post
d.multicall=incomplete,d.stop=
d.multicall=incomplete,d.directory.set=test