Skip to content

Instantly share code, notes, and snippets.

View moehandi's full-sized avatar
:octocat:

M. Andi Saputra moehandi

:octocat:
  • Jakarta, Indonesia
View GitHub Profile
curl -H "Content-Type:application/json" "Authorization:key=SERVER_KEY"
-X POST https://iid.googleapis.com/iid/v1:batchRemove
-d '{
"to": "/topics/sakit_perut",
"registration_tokens":[
"DeviceTokenFromUser"
]
}'
@moehandi
moehandi / reflection.go
Created April 30, 2017 20:21 — forked from drewolson/reflection.go
Golang Reflection Example
package main
import (
"fmt"
"reflect"
)
type Foo struct {
FirstName string `tag_name:"tag 1"`
LastName string `tag_name:"tag 2"`
@moehandi
moehandi / multipart_upload.go
Created May 24, 2017 01:59 — forked from mattetti/multipart_upload.go
Example of doing a multipart upload in Go (golang)
package main
import (
"bytes"
"fmt"
"io"
"log"
"mime/multipart"
"net/http"
"os"
@moehandi
moehandi / main.go
Created July 28, 2017 03:06
Go API versioning
package main
import (
"fmt"
"net/http"
"github.com/gorilla/mux"
)
// AnotherHandlerLatest is the newest version of AnotherHandler
@moehandi
moehandi / EncodingResponseInterceptor.java
Created September 23, 2017 16:21
an android okhttp3 interceptor for set encoding response from server
class EncodingResponseInterceptor implements Interceptor {
@Override
public okhttp3.Response intercept(Chain chain) throws IOException {
Request request = chain.request();
okhttp3.Response response = chain.proceed(request);
BufferedSource source = response.body().source();
source.request(Long.MAX_VALUE); // Buffer the entire body.
Buffer buffer = source.buffer();
@moehandi
moehandi / main.go
Created October 22, 2017 00:40 — forked from manishtpatel/main.go
GoLang Encrypt string to base64 and vice versa using AES encryption.
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
"fmt"
"io"
)
@moehandi
moehandi / nginxproxy.md
Created November 2, 2017 04:23 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@moehandi
moehandi / verify.js
Created November 2, 2017 09:43 — forked from evanhalley/verify.js
Using JavaScript / Node.js to do server side IAB signature verification
var crypto = require('crypto');
// the Base64 encoded Google Play license key / Base64-encoded RSA public key from the Google Play Dev Console
var publicKey = "ABCEDF1234....";
/** sample
{
"orderId":"12999763169054705758.1371079406387615",
"packageName":"com.example.app",
"productId":"exampleSku",
@moehandi
moehandi / gist:807d4bed13bc85fb70f0dd58588b401f
Created December 3, 2017 02:21 — forked from kapkaev/gist:4619127
MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error. Resque
$ redis-cli
> config set stop-writes-on-bgsave-error no
@moehandi
moehandi / gist:638cfc74bd7481ce5711e04ad1cb4ec9
Created January 20, 2018 01:25
solve ubuntu expired key server
Update all expired keys from Ubuntu key server in one command:
sudo apt-key list | \
grep "expired: " | \
sed -ne 's|pub .*/\([^ ]*\) .*|\1|gp' | \
xargs -n1 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys
Command explanation: