Skip to content

Instantly share code, notes, and snippets.

@sgf-dma
sgf-dma / home-deck-.var.mount
Created September 13, 2024 22:52
Systemd unit for steamdeck for mounting directory from sdcard on ~/.var . So, all flatpacks data will be on sdcard.
[Unit]
Description=Offload /home/deck/.var/app/
[email protected]
[email protected]
[Mount]
What=/run/media/mmcblk0p1/deck/.var/
Where=/home/deck/.var/
Type=none
Options=bind,nofail
[Install]
@sgf-dma
sgf-dma / cont.go
Created August 30, 2024 14:52
Haskell's Cont implementation in go with reversing slice as an example.
package main
import (
"fmt"
)
// newtype Cont r a = Cont ((a -> r) -> r)
type Cont[Result any, A any] func(func(A) Result) Result
@sgf-dma
sgf-dma / revCpsGen.go
Created August 26, 2024 17:44
revCps.go version with generics.
package main
import "fmt"
// Haskell: data R a = R (R a) | E a
type R [Result any] func() (R[Result], Result)
// Haskell: Cont (R Result) T
type Cont [T any, Result any] func(T) (R[Result], Result)
@sgf-dma
sgf-dma / revCps.go
Last active August 30, 2024 14:58
cps version of function reversing slice compared with Haskell's revCps.hs
package main
import "fmt"
// Haskell: data R a = R (R a) | E a
type R func() (R, []int)
// Haskell: Cont (R [a]) [a]
type Cont func([]int) (R, []int)
@sgf-dma
sgf-dma / revCps.hs
Created August 21, 2024 21:28
cps version of 'reverse' for comparison with Go version in revCps.go.
import Control.Monad.Trans.Cont
import Data.Function
data R a = R (R a) | E a
-- This function is called from 'shift' and 'shift' returns immediately
-- (without calling further continuation) because result is already here - 'R'
-- value. Continuation 'k' will be called later, when evaluation of returned
-- 'R' value is forced in 'run'.
package main
import (
"fmt"
"sync"
"net/http"
"bytes"
)
func worker(i int, ch <-chan interface{}) {
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <Windows.h>
using namespace std;
vector<string> splitToBlocks(const string& text, size_t blockSize) {
vector<string> blocks;
# cat /etc/systemd/system/test.timer
[Timer]
OnCalendar=
OnCalendar=*-*-* *:*:00
RandomizedDelaySec=0
Unit=test.target
[Install]
Also=test.target
import traceback
n = 6
# Рекурсия.
def summa_n1(x):
global n_calls
global max_stack
n_calls += 1
import dis
import cProfile
import timeit
def f1():
global y
global x
k = y / x