Skip to content

Instantly share code, notes, and snippets.

View MilosSimic's full-sized avatar

Milos MilosSimic

  • Faculty of technical sciences Novi Sad
  • Novi Sad
View GitHub Profile
@MilosSimic
MilosSimic / gist:8c223973e90220c4e05d3bb860b2d3fb
Created May 14, 2019 09:31 — forked from nickrussler/gist:7527851
Convert Date String to/from ISO 8601 respecting UTC in Java
public static String toISO8601UTC(Date date) {
TimeZone tz = TimeZone.getTimeZone("UTC");
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
df.setTimeZone(tz);
return df.format(date);
}
public static Date fromISO8601UTC(String dateStr) {
TimeZone tz = TimeZone.getTimeZone("UTC");
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
@MilosSimic
MilosSimic / clientbin.go
Last active September 22, 2022 11:00
tcp server/client in golang using binary data
package main
import (
"bytes"
"encoding/gob"
"fmt"
"net"
// "time"
)
@MilosSimic
MilosSimic / bloom-filter-calculator.rb
Created January 30, 2019 23:44 — forked from brandt/bloom-filter-calculator.rb
Calculate the required bloom filter size and optimal number of hashes from the expected number of items in the collection and acceptable false-positive rate
# Optimal bloom filter size and number of hashes
# Tips:
# 1. One byte per item in the input set gives about a 2% false positive rate.
# 2. The optimal number of hash functions is ~0.7x the number of bits per item.
# 3. The number of hashes dominates performance.
# Expected number of items in the collection
# n = (m * ln(2))/k;
n = 300_000
@MilosSimic
MilosSimic / udpserv.go
Created January 26, 2019 09:30 — forked from miekg/udpserv.go
Simple udp server in Go
package main
import (
"log"
"net"
)
func main() {
// listen to incoming udp packets
pc, err := net.ListenPacket("udp", ":1053")
@MilosSimic
MilosSimic / snappy.go
Created January 25, 2019 23:49 — forked from miguelmota/snappy.go
Golang snappy encode and decode example
package main
import (
"fmt"
"log"
"github.com/golang/snappy"
)
func main() {
@MilosSimic
MilosSimic / tcp_timeout.go
Created January 25, 2019 23:46 — forked from hongster/tcp_timeout.go
Golang example on handling TCP connection and setting timeout.
package main
import (
"fmt"
"net"
"time"
"bufio"
)
func handleConnection(conn net.Conn) {
package main
import (
"net"
"strings"
"fmt"
)
func handleConnection(conn net.Conn) {
// try to read data from the connection
@MilosSimic
MilosSimic / fnv_example.go
Created January 21, 2019 16:06 — forked from lenage/fnv_example.go
golang fnv example
package main
import (
"bufio"
"fmt"
"hash/fnv"
"io"
"os"
)
@MilosSimic
MilosSimic / README.md
Created December 17, 2018 13:35 — forked from suyash/README.md
mmap examples

identical mmap programs in C and go