Skip to content

Instantly share code, notes, and snippets.

View mushfiq's full-sized avatar

Mushfiq mushfiq

View GitHub Profile
@mushfiq
mushfiq / client.py
Created January 31, 2019 21:23 — 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.
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 August 19, 2018 00:04 — forked from CMCDragonkai/http_streaming.md
HTTP Streaming (or Chunked vs Store & Forward)

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

-- 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:
@mushfiq
mushfiq / README.md
Last active October 28, 2020 14:48

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 December 30, 2016 00:13
Binary search implementation using golang.
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 13:48 — forked from francoishill/loop_files_folders_recursively.go
Loop through files and folders recursively in golang
package main
import (
"fmt"
"os"
"path/filepath"
)
func main() ([]string, error) {
searchDir := "c:/path/to/dir"
@mushfiq
mushfiq / main
Last active April 3, 2016 12:01
Blank gist to keep the binary
@mushfiq
mushfiq / Dockerfile
Created March 6, 2016 18:52
Docker file for running DRF based µ-service.
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 April 3, 2016 13:07
Docker file to run Golang based REST API.
FROM scratch
MAINTAINER Mushfiq
ADD https://gist.github.com/257c227b9ed0586b216e5f25f3f7e588.git main /
ENTRYPOINT ["/main"]
EXPOSE 8080
@mushfiq
mushfiq / main.go
Last active April 3, 2016 11:40
Golang based REST API deployed using Docker.
package main
import (
"github.com/gin-gonic/gin"
"time"
)
func rootHandler(context *gin.Context) {
current_time := time.Now()
current_time.Format("20060102150405")