Skip to content

Instantly share code, notes, and snippets.

Milos MilosSimic

  • Faculty of technical sciences Novi Sad
  • Novi Sad
Block or report user

Report or block MilosSimic

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@MilosSimic
MilosSimic / EncodeBased64Binary.java
Created May 14, 2019 — forked from utsengar/EncodeBased64Binary.java
Encode a file to base64 binary in Java
View EncodeBased64Binary.java
import org.apache.commons.codec.binary.Base64;
private String encodeFileToBase64Binary(String fileName)
throws IOException {
File file = new File(fileName);
byte[] bytes = loadFile(file);
byte[] encoded = Base64.encodeBase64(bytes);
String encodedString = new String(encoded);
@MilosSimic
MilosSimic / gist:8c223973e90220c4e05d3bb860b2d3fb
Created May 14, 2019 — forked from nickrussler/gist:7527851
Convert Date String to/from ISO 8601 respecting UTC in Java
View gist:8c223973e90220c4e05d3bb860b2d3fb
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 Feb 13, 2019
tcp server/client in golang using binary data
View clientbin.go
package main
import (
"bytes"
"encoding/gob"
"fmt"
"net"
// "time"
)
@MilosSimic
MilosSimic / bloom-filter-calculator.rb
Created Jan 30, 2019 — 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
View bloom-filter-calculator.rb
# 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 Jan 26, 2019 — forked from miekg/udpserv.go
Simple udp server in Go
View udpserv.go
package main
import (
"log"
"net"
)
func main() {
// listen to incoming udp packets
pc, err := net.ListenPacket("udp", ":1053")
@MilosSimic
MilosSimic / snappy.go
Created Jan 25, 2019 — forked from miguelmota/snappy.go
Golang snappy encode and decode example
View snappy.go
package main
import (
"fmt"
"log"
"github.com/golang/snappy"
)
func main() {
@MilosSimic
MilosSimic / tcp_timeout.go
Created Jan 25, 2019 — forked from hongster/tcp_timeout.go
Golang example on handling TCP connection and setting timeout.
View tcp_timeout.go
package main
import (
"fmt"
"net"
"time"
"bufio"
)
func handleConnection(conn net.Conn) {
View simple-tcp-server.go
package main
import (
"net"
"strings"
"fmt"
)
func handleConnection(conn net.Conn) {
// try to read data from the connection
@MilosSimic
MilosSimic / fnv_example.go
Created Jan 21, 2019 — forked from lenage/fnv_example.go
golang fnv example
View fnv_example.go
package main
import (
"bufio"
"fmt"
"hash/fnv"
"io"
"os"
)
You can’t perform that action at this time.