misc (#4)
Co-authored-by: Anish Lakhwara <anish+git@lakhwara.com> Reviewed-on: #4
This commit is contained in:
parent
d46d67830a
commit
176a81cc91
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*.sqlite
|
||||
mast
|
|
@ -7,7 +7,7 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
|
||||
"mast/db"
|
||||
mast "mast/db"
|
||||
|
||||
"github.com/charmbracelet/bubbles/textinput"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
|
@ -89,6 +89,8 @@ func (m *model) addTodo(todo string) {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
// TODO:
|
||||
// func sync_changes
|
||||
rows, err := m.db.Query("SELECT * FROM crsql_changes")
|
||||
if err != nil {
|
||||
log.Println("Error querying crsql_changes:", err)
|
46
server/test.go
Normal file
46
server/test.go
Normal file
|
@ -0,0 +1,46 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func decodeBase64ToIntArray(encodedString string) ([]int, error) {
|
||||
// Decode the base64 string
|
||||
decodedBytes, err := base64.StdEncoding.DecodeString(encodedString)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error decoding base64: %w", err)
|
||||
}
|
||||
|
||||
// Convert bytes to string
|
||||
decodedString := string(decodedBytes)
|
||||
|
||||
// Split the string by commas
|
||||
stringSlice := strings.Split(decodedString, ",")
|
||||
|
||||
// Convert each string to an integer
|
||||
intSlice := make([]int, len(stringSlice))
|
||||
for i, s := range stringSlice {
|
||||
num, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error converting string to int: %w", err)
|
||||
}
|
||||
intSlice[i] = num
|
||||
}
|
||||
|
||||
return intSlice, nil
|
||||
}
|
||||
|
||||
func main2() {
|
||||
encodedString := "MSwxMSwzMiw1MCw5OCw1Nyw1Myw1NywxMDIsNTAsNTQsNTIsNTYsMTAyLDEwMCwxMDAsOTksNTEsNTQsNTcsMTAwLDk3LDEwMCwxMDIsMTAxLDU0LDQ5LDUzLDk5LDQ4LDEwMCw0OSw1NCwxMDIsNTI="
|
||||
|
||||
intArray, err := decodeBase64ToIntArray(encodedString)
|
||||
if err != nil {
|
||||
fmt.Println("Error:", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println("Decoded integer array:", intArray)
|
||||
}
|
Loading…
Reference in a new issue