Skip to content

Instantly share code, notes, and snippets.


Milos MilosSimic

  • Faculty of technical sciences Novi Sad
  • Novi Sad
View GitHub Profile
MilosSimic /
Created Jun 1, 2020 — forked from alphamu/
Gist showing the use case of a headless Fragment to check if internet is available
public class NetworkHelper extends Fragment {
public static final String TAG = "NetworkHelper";
public static final String CHECK_INTERNET = "network_connection";
private Activity mActivity;
AlertDialog mAlertDialog = null;
private BroadcastReceiver onNotice = new BroadcastReceiver() {
MilosSimic /
Created Mar 24, 2020 — forked from naufraghi/
Move and zoom image with Gestures in and android View
package com.develer.circularsliderule;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
MilosSimic /
Created Dec 25, 2019 — forked from pcgeek86/
Install Go Lang on Raspberry Pi
cd $HOME
sudo tar -C /usr/local -xvf $FileName
cat >> ~/.bashrc << 'EOF'
export GOPATH=$HOME/go
export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin
source ~/.bashrc
MilosSimic / ctx_middleware_chain.go
Created Nov 26, 2019 — forked from cep21/ctx_middleware_chain.go
Example of using context.Value() as a middleware chain
View ctx_middleware_chain.go
package goexperiments
import (
type HandlerMiddleware interface {
HandleHTTPC(ctx context.Context, rw http.ResponseWriter, req *http.Request, next http.Handler)
MilosSimic / 1_http_hello.go
Created Nov 22, 2019 — forked from jmervine/1_http_hello.go
Golang - Hello PATH HTTP Server Example
View 1_http_hello.go
package main
import (
func Log(handler http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
MilosSimic / timeout_and_tick.go
Created Oct 26, 2019 — forked from ngauthier/timeout_and_tick.go
Golang timeout and tick loop
View timeout_and_tick.go
// keepDoingSomething will keep trying to doSomething() until either
// we get a result from doSomething() or the timeout expires
func keepDoingSomething() (bool, error) {
timeout := time.After(5 * time.Second)
tick := time.Tick(500 * time.Millisecond)
// Keep trying until we're timed out or got a result or got an error
for {
select {
// Got a timeout! fail with a timeout error
case <-timeout:
MilosSimic / assetlinks.json
Created Oct 18, 2019 — forked from adewale/assetlinks.json
Example assetlinks.json
View assetlinks.json
MilosSimic /
Created May 14, 2019 — forked from utsengar/
Encode a file to base64 binary in 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 / 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'");
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'");
You can’t perform that action at this time.