Skip to content

Instantly share code, notes, and snippets.

Avatar

Mushfiq mushfiq

  • Berlin, Germany
View GitHub Profile
@mushfiq
mushfiq / client.py
Created Jan 31, 2019 — forked from yoavram/client.py
Example of uploading binary files programmatically in python, including both client and server code. Client implemented with the requests library and the server is implemented with the flask library.
View client.py
import requests
#http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file
url = "http://localhost:5000/"
fin = open('simple_table.pdf', 'rb')
files = {'file': fin}
try:
r = requests.post(url, files=files)
print r.text
@mushfiq
mushfiq / http_streaming.md
Created Aug 19, 2018 — forked from CMCDragonkai/http_streaming.md
HTTP Streaming (or Chunked vs Store & Forward)
View http_streaming.md

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on

View ip_blacklist.lua
-- a quick LUA access script for nginx to check IP addresses against an
-- `ip_blacklist` set in Redis, and if a match is found send a HTTP 403.
--
-- allows for a common blacklist to be shared between a bunch of nginx
-- web servers using a remote redis instance. lookups are cached for a
-- configurable period of time.
--
-- block an ip:
-- redis-cli SADD ip_blacklist 10.1.1.1
-- remove an ip:
View README.md

Backend web push service

To run the API, following settings need to be exported as env variables

  • VAPID email
  • VAPID private key path
  • VAPID public key path

Running the API

@mushfiq
mushfiq / binary_search.go
Created Dec 30, 2016
Binary search implementation using golang.
View binary_search.go
package main
import "fmt"
func elementExists(input_array []int, max_index int, min_index int, element int) bool {
middle_index := (min_index + max_index) / 2
found := false
if min_index > max_index {
return false
@mushfiq
mushfiq / loop_files_folders_recursively.go
Created May 6, 2016 — forked from francoishill/loop_files_folders_recursively.go
Loop through files and folders recursively in golang
View loop_files_folders_recursively.go
package main
import (
"fmt"
"os"
"path/filepath"
)
func main() ([]string, error) {
searchDir := "c:/path/to/dir"
@mushfiq
mushfiq / main
Last active Apr 3, 2016
Blank gist to keep the binary
@mushfiq
mushfiq / Dockerfile
Created Mar 6, 2016
Docker file for running DRF based µ-service.
View Dockerfile
FROM python:2.7
MAINTAINER Mushfiq
ENV PYTHONUNBUFFERED 1
RUN git clone https://github.com/mushfiq/djmsc.git djmsc
WORKDIR djmsc
@mushfiq
mushfiq / Dockerfile
Last active Apr 3, 2016
Docker file to run Golang based REST API.
View Dockerfile
FROM scratch
MAINTAINER Mushfiq
ADD https://gist.github.com/257c227b9ed0586b216e5f25f3f7e588.git main /
ENTRYPOINT ["/main"]
EXPOSE 8080
@mushfiq
mushfiq / main.go
Last active Apr 3, 2016
Golang based REST API deployed using Docker.
View main.go
package main
import (
"github.com/gin-gonic/gin"
"time"
)
func rootHandler(context *gin.Context) {
current_time := time.Now()
current_time.Format("20060102150405")