Skip to content

Instantly share code, notes, and snippets.

View akmamun's full-sized avatar
🎯
Focusing

Al Mamun Khan akmamun

🎯
Focusing
View GitHub Profile
@akmamun
akmamun / camera.py
Created February 7, 2019 10:31
Camera Live Streaming with Flask and Open-CV
import cv2
camera = cv2.VideoCapture(0) # use 0 for web camera
# for cctv camera'rtsp://username:password@ip_address:554/user=username_password='password'_channel=channel_number_stream=0.sdp'
def camera_stream():
while True:
# Capture frame-by-frame
success, frame = camera.read()
if not success:
break
@akmamun
akmamun / Webcam.js
Created February 13, 2019 07:49
React JS (ES6 Function) Camera Stream
if (navigator.getUserMedia) { // navigator.getUserMedia pass three arguments
navigator.getUserMedia({video: true}, //if want audio can be true
stream => {
let camera = document.getElementById('camera'); //class or id for load stream on html
camera.srcObject = stream; //src of stream
camera.onloadedmetadata = () => {
camera.play();
}
}, err => {
console.log(err)
@akmamun
akmamun / create-a-host
Created February 13, 2019 08:35
Create a Host for Php Laravel Project (always run project without artisan serve)
# Create a host for your project
- Do not need run 'php artisan serve' anymore in your laravel project.
# 1. Go to linux terminal and type
```php
cd /etc/apache2/sites-available
```
# 2. Now create a file name like
```php
@akmamun
akmamun / base64_to_image.py
Created February 13, 2019 12:42
Base 64 to Image Convert in Python
import os
SAVE_DIR = os.path.dirname(os.path.abspath(__file__))
def base64_to_image(filename):
path = os.path.join(SAVE_DIR, 'images/')
if not os.path.isdir(path):
os.mkdir(path)
data = base64.b64decode(filename)
filename = 'frame' + str(datetime.datetime.now().microsecond) + '.jpg'
destination = "/".join([path, filename])
@akmamun
akmamun / protobuf3-on-ubuntu
Created February 17, 2019 20:07
Install protobuf 3 on Ubuntu
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.7.0rc2/protoc-3.7.0-rc-2-linux-x86_64.zip
# Unzip
unzip protoc-3.7.0-rc-2-linux-x86_64.zip -d protoc3
# Move protoc to /usr/local/bin/
sudo mv protoc3/bin/* /usr/local/bin/
# Move protoc3/include to /usr/local/include/
@akmamun
akmamun / GOPATH Set
Last active May 6, 2019 09:18
Set Go Lang Path
#add those in bashrc
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
@akmamun
akmamun / compile.py
Created March 27, 2019 09:51
Protecting Python and Flask App Sources With Cython
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
from Cython.Build import cythonize
ext_modules = [
Extension("test", ["test.py"]),
]
@akmamun
akmamun / mongo_export_data
Created April 20, 2019 11:37
Mongo DB export command line
mongoexport --db meghna --collection recognitions --out recognitions.csv
@akmamun
akmamun / docker
Created April 22, 2019 09:09
Python flask app dockerize
from alpine:latest
RUN apk add --no-cache python3-dev \
&& pip3 install --upgrade pip
WORKDIR /app
COPY . /app
RUN pip3 --no-cache-dir install -r requirements.txt
@akmamun
akmamun / date_time.js
Created May 19, 2019 08:29
JS Date Time
const options = {
year: 'numeric',
month: 'numeric',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric'
}
new Intl.DateTimeFormat('en-US', options).format(date) //"7/22/2018, 7:22:13 AM"