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 / spacemacs-cheatsheet.txt
Created November 2, 2020 23:19 — forked from k3yavi/spacemacs-cheatsheet.txt
Spacemacs cheatsheet
//from http://www.saltycrane.com/blog/2015/12/switching-emacs-vim-actually-spacemacs/
Useful Spacemacs commands
SPC q q - quit
SPC w / - split window vertically
SPC w - - split window horizontally
SPC 1 - switch to window 1
SPC 2 - switch to window 2
SPC w c - delete current window
@MilosSimic
MilosSimic / errgroup_withcontext.go
Created September 16, 2020 18:29 — forked from dragonsinth/errgroup_withcontext.go
Using errgroup.WithContext() in Golang server handlers
package main
import (
"context"
"encoding/json"
"fmt"
"io"
"log"
"sync/atomic"
"time"
@MilosSimic
MilosSimic / NetworkHelper.java
Created June 1, 2020 10:02 — forked from alphamu/NetworkHelper.java
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() {
@Override
@MilosSimic
MilosSimic / MyImageView.java
Created March 24, 2020 18:36 — forked from naufraghi/MyImageView.java
Move and zoom image with Gestures in and android View
package com.develer.circularsliderule;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
@MilosSimic
MilosSimic / install_go_pi.sh
Created December 25, 2019 15:23 — forked from pcgeek86/install_go_pi.sh
Install Go Lang on Raspberry Pi
cd $HOME
FileName='go1.13.4.linux-armv6l.tar.gz'
wget https://dl.google.com/go/$FileName
sudo tar -C /usr/local -xvf $FileName
cat >> ~/.bashrc << 'EOF'
export GOPATH=$HOME/go
export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin
EOF
source ~/.bashrc
@MilosSimic
MilosSimic / ctx_middleware_chain.go
Created November 26, 2019 22:32 — forked from cep21/ctx_middleware_chain.go
Example of using context.Value() as a middleware chain
package goexperiments
import (
"context"
"net/http"
)
type HandlerMiddleware interface {
HandleHTTPC(ctx context.Context, rw http.ResponseWriter, req *http.Request, next http.Handler)
}
@MilosSimic
MilosSimic / 1_http_hello.go
Created November 22, 2019 13:16 — forked from jmervine/1_http_hello.go
Golang - Hello PATH HTTP Server Example
package main
import (
"fmt"
"log"
"net/http"
)
func Log(handler http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@MilosSimic
MilosSimic / timeout_and_tick.go
Created October 26, 2019 20:39 — forked from ngauthier/timeout_and_tick.go
Golang timeout and tick loop
// 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
MilosSimic / assetlinks.json
Created October 18, 2019 16:49 — forked from adewale/assetlinks.json
Example assetlinks.json
@MilosSimic
MilosSimic / EncodeBased64Binary.java
Created May 14, 2019 09:53 — forked from utsengar/EncodeBased64Binary.java
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);