Skip to content

Instantly share code, notes, and snippets.

@a-h
a-h / dft.go
Created August 6, 2024 09:13 — forked from r9y9/dft.go
Discrete Fourier Transform in Go
package main
import "math"
import "fmt"
func DFT_naive (input []float64) ([]float64, []float64) {
real := make([]float64, len(input))
imag := make([]float64, len(input))
arg := -2.0*math.Pi/float64(len(input))
for k := 0; k < len(input); k++ {
@a-h
a-h / main.templ
Created August 1, 2024 19:36
Example of server side DataTables usage
package main
import (
"encoding/json"
"fmt"
"net/http"
)
templ page() {
<!DOCTYPE html>
@a-h
a-h / main.templ
Created August 1, 2024 19:27
Example of server-side passing data via attribute
package main
import (
"fmt"
"net/http"
)
templ page(data any) {
<!DOCTYPE html>
<html>
@a-h
a-h / two-cols-header.vue
Last active November 22, 2023 10:57
slidev two columns with header layout
<!--
Usage:
```md
---
layout: two-cols-header
---
This shows up across both
::left::
# Left
This shows on the left
@a-h
a-h / README.md
Created September 11, 2022 15:49 — forked from wpiekutowski/README.md
Apple Virtualization NixOS ISO

Run NixOS ISO using Apple Virtualization framework (for example UTM or vftool)

  • download or build ISO: nix-build -A iso_minimal_new_kernel.aarch64-linux '<nixpkgs/nixos/release.nix>'
  • copy ISO: scp "ip_addr:result/iso/*" .
  • mount: hdiutil *.iso
  • copy kernel and initrd: cp /Volumes/nixos-minimal-21/boot/Image /Volumes/nixos-minimal-21/boot/initrd .
  • find and copy kernel params: less /Volumes/nixos-minimal-21/EFI/boot/grub.cfg
  • append console=hvc0 to params
@a-h
a-h / stepper_motor_test.ino
Created July 3, 2021 19:01
Stepper motor test code (Arduino)
int ccw = LOW;
int step = D5;
int dir = D6;
int startDelay = 1000;
int speed = 10;
int targetDelay = 350;
void setup()
{
pinMode(step, OUTPUT);
@a-h
a-h / keyboard.json
Created July 12, 2020 20:28
Anne Pro 2 keyboard layout
{"name":"Current","device":1,"model":5,"type":"layout","data":{"layer0":[41,30,31,32,33,34,35,36,37,38,39,45,46,42,43,20,26,8,21,23,28,24,12,18,19,47,48,49,192,4,22,7,9,10,11,13,14,15,51,52,40,225,29,27,6,25,5,17,16,54,55,56,82,193,224,227,44,226,80,81,79],"layer1":[53,58,59,60,61,62,63,64,65,66,67,68,69,76,0,0,82,0,0,0,0,0,82,0,70,74,77,0,192,80,81,79,0,0,0,80,81,79,75,78,0,0,53,0,0,0,0,0,0,0,73,76,75,193,224,227,0,226,74,78,77],"layer2":[0,200,201,202,203,0,0,0,0,241,240,244,243,76,0,0,82,0,0,0,0,0,82,0,70,74,77,0,192,80,81,79,0,0,0,80,81,79,75,78,0,0,53,0,0,0,0,0,0,0,73,76,75,193,224,227,0,230,74,78,77],"taps":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,82,0,0,0,0,0,80,81,79]},"crc":"40377b03"}
@a-h
a-h / 01-data.tsv
Last active August 17, 2020 20:39
Importing data into DynamoDB - code for blog post
ngram year match_count page_count volume_count
# 1574 1 1 1
# 1584 6 6 1
# 1614 1 1 1
# 1631 115 100 1
# 1632 3 3 1
# 1635 1 1 1
# 1640 1 1 1
# 1641 1 1 1
1935 2 2 1
@a-h
a-h / App.js
Created April 13, 2020 09:51
Firebase Test
import React, {useEffect} from 'react';
import {AppState, Linking} from 'react-native';
import {Provider as PaperProvider} from 'react-native-paper';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
@a-h
a-h / main.go
Created April 13, 2020 08:26
Raspberry Pi LCD without i2c
package main
import (
"fmt"
"os"
"time"
"github.com/stianeikeland/go-rpio"
)