Skip to content

Commit

Permalink
add compile, camera, api fetch axios and doc update
Browse files Browse the repository at this point in the history
  • Loading branch information
akmamun committed Apr 4, 2019
1 parent 3c21956 commit 7122814
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 6 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
## JavaScript, React JS, Python (Flask), Php (Laravel) Code Snippets
## JavaScript, React JS, Python, Flask, Php (Laravel) Code Snippets

## JavaScript Code Snippets
## JavaScript
- [JavaScript Form Validation](js/form-validation.js)
- [Select Single Checkbox](js/single-checkbox-selection.js)
## React JS Code Snippets
## React JS
- [API Integration with Fetch and Axios](react-js/fetch-axios.js)
- [Array Interval Delay and Hide Previous Element](react-js/array-plus-delay.js)
- [Manual Delay](react-js/delay.js)
- [React Routes](react-js/routes.js)
- [React Web Camera Streaming](react-js/webcam.js)
## Python Code Snippets
## Python
- [Cython Compile File Generator](python/compile.py)
- [Camera Live Streaming with Flask and Open-CV](python/camera.py)
- [Image Cropping](python/image-cropping.py)
- [Base 64 to Image Convert and Save](python/base64_to_image.py)
- [Base 64 to Numpy Array](python/base64_to_numpy_array.py)
- [Multiple Image Upload](python/multiple-image-upload.py)
- [Another Directory Folder Add](python/another_directory_add.py)
## Php Laravel Code Snippets
## Php Laravel
- [Date Time Difference](laravel/date-time-difference.php)
- [Database Insertion Without Model](laravel/db-insert-without-model.php)
- [Database Table Seeder](laravel/db-seeder-table.php)
Expand All @@ -23,6 +26,7 @@
- [Multiple Image Upload](laravel/multiple-image-upload.php)
- [Partial Route](laravel/partial-route.php)
- [Create a Host](../../../create-a-host)

## Go Lang
- [Set Go Path](go/go-path-set.go)
## Other
- [Install Protobuf 3 on Ubuntu](https://gist.github.com/mrxmamun/c3afc8e9318135d5f79177ff528655a4)
4 changes: 4 additions & 0 deletions go/go-path-set.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// type command line
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin
14 changes: 14 additions & 0 deletions python/camera.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# pip install opencv-python
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
else:
ret, buffer = cv2.imencode('.jpg', frame) # or return cv2.imencode('.jpg', frame)[1].tobytes()
return buffer.tobytes()
21 changes: 21 additions & 0 deletions python/compile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pip install 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"]),
]

setup(
name='Test Compile',
cmdclass={'build_ext': build_ext},
ext_modules=cythonize(ext_modules,
compiler_directives={'always_allow_keywords': True}, # 'always_allow_keywords' for avoid flask error
)

)
# than call
# add a main.py where flask app is call and run main.py
9 changes: 9 additions & 0 deletions react-js/fetch-axios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// for csrf use axios , build in function fetch for axios install axios
const fetchTest = fetch("http://127.0.0.1:5000/api/v1/todos/")
.then((data)=> data.json());
console.log(fetchTest);
const axiosTest = axios({
method: 'get',
url: 'http://127.0.0.1:5000/api/v1/todos/'
});
console.log(axiosTest);

0 comments on commit 7122814

Please sign in to comment.