Skip to content

Instantly share code, notes, and snippets.

@hosszukalman
hosszukalman / send_events.sh
Created October 3, 2019 06:48
Randomised curl requests in bash.
#!/bin/bash
# The url to post.
url="http://example.com"
# Token for your user.
bearer=""
start_event_body() {
cat <<EOF
{
@hosszukalman
hosszukalman / regex_replace_content.sh
Created September 17, 2019 08:00
Replace files content based on regex
#!/bin/bash
find . -type f -regex '.*-romanian.html' -exec sed -i '' -e 's/language: en/language: ro/g' {} \;
find . -type f -regex '.*-romanian.html' -exec sed -i '' -e 's/-english/-romanian/g' {} \;
@hosszukalman
hosszukalman / regex_delete.sh
Created September 17, 2019 07:58
Delete files based on regex
#!/bin/bash
find . -type f -regex '.*cloudagents.*romanian.html' -delete
@hosszukalman
hosszukalman / regex_copy_rename.sh
Created September 17, 2019 07:57
Copy and rename files based on regex
#!/bin/bash
find . -type f | perl -pe 'print $_; s/-english.html/-romanian.html/' | xargs -n2 cp
@hosszukalman
hosszukalman / iota.go
Created September 12, 2019 14:51
Golang's iota
package main
import (
"fmt"
)
const zero = iota // Iota is the first in decalration scope, so it should be 0
const (
a = -2
@hosszukalman
hosszukalman / Caddyfile
Last active July 11, 2019 11:25
Monorepo with golang back-end, front-end and Caddy server
yourhost.dev:80 yourhost.dev:443 {
tls self_signed
proxy /api backend:8080 {
without /api
websocket
}
log stdout
errors stderr
@hosszukalman
hosszukalman / merge_structs.go
Created June 25, 2019 06:21
Permission based struct patch/merge
package main
import (
"encoding/json"
"fmt"
"reflect"
)
type User struct {
Permissions []string
@hosszukalman
hosszukalman / clear_struct.go
Created June 25, 2019 06:19
Permission based struct clearing
package main
import (
"fmt"
"reflect"
)
type User struct {
Permissions []string
}
package main
import (
"fmt"
"time"
)
func Start() (f Foo) {
fmt.Println("start with type")
return
package main
import (
"fmt"
"time"
)
func main() {
fmt.Println("Hello, playground")
start := time.Now()