Skip to content

Instantly share code, notes, and snippets.

View petrjahoda's full-sized avatar

Petr Jahoda petrjahoda

View GitHub Profile
@petrjahoda
petrjahoda / go
Created October 1, 2023 07:10
read_data.go
var users []database.User
db.Find(&users)
FROM scratch
ARG TARGETOS
ARG TARGETARCH
ADD /${TARGETOS}/${TARGETARCH} /
ENTRYPOINT ["/system_service"]
@petrjahoda
petrjahoda / create.sh
Last active April 29, 2022 07:35
script
name=${PWD##*/}
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o linux/amd64/"$name"
GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -o linux/arm64/"$name"
upx --best --lzma linux/amd64/"$name"
upx --best --lzma linux/arm64/"$name"
docker rmi -f petrjahoda/"$name":latest
docker buildx build -t petrjahoda/"$name":latest --platform=linux/arm64,linux/amd64 . --push
global computerIsInUse, resetTime
on run
set computerIsInUse to true
set resetTime to (do shell script "date +%s") as integer
end run
on idle
set idleTime to (do shell script "ioreg -c IOHIDSystem | awk '/HIDIdleTime/ {print $NF; exit}'") as integer
if idleTime is greater than 7.4E+10 then
@petrjahoda
petrjahoda / main.go
Last active August 29, 2021 13:03
socket-client
package main
import (
"bufio"
"fmt"
"net"
"strconv"
"sync"
"time"
)
@petrjahoda
petrjahoda / main.go
Last active August 29, 2021 12:44
socket-server
package main
import (
"bufio"
"fmt"
"net"
"strconv"
"time"
)
@petrjahoda
petrjahoda / main.go
Created August 20, 2021 09:34
WebSocket Client
package main
import (
"context"
"fmt"
"github.com/gobwas/ws"
"github.com/gobwas/ws/wsutil"
"math/rand"
"os"
"strconv"
@petrjahoda
petrjahoda / main.go
Created August 20, 2021 09:31
WebSocket Server
package main
import (
"fmt"
"github.com/gobwas/ws"
"github.com/gobwas/ws/wsutil"
"math/rand"
"net/http"
"strconv"
)
@petrjahoda
petrjahoda / main.go
Created August 14, 2021 09:07
6. Changing the name with a method, passing a pointer and interface
package main
import "fmt"
type Car struct {
name string
}
type Truck struct {
name string
@petrjahoda
petrjahoda / main.go
Created August 14, 2021 08:50
5. Changing the name with a method, passing a pointer
package main
import "fmt"
type Car struct {
name string
}
type Truck struct {
name string