diff --git a/README.md b/README.md index f8a370f..da4b698 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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) diff --git a/go/go-path-set.go b/go/go-path-set.go new file mode 100644 index 0000000..2ff38d9 --- /dev/null +++ b/go/go-path-set.go @@ -0,0 +1,4 @@ +// type command line +export GOROOT=/usr/local/go +export GOPATH=$HOME/go +export PATH=$PATH:$GOROOT/bin \ No newline at end of file diff --git a/python/camera.py b/python/camera.py new file mode 100644 index 0000000..5cc9ff8 --- /dev/null +++ b/python/camera.py @@ -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() \ No newline at end of file diff --git a/python/compile.py b/python/compile.py new file mode 100644 index 0000000..c97a2fe --- /dev/null +++ b/python/compile.py @@ -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 \ No newline at end of file diff --git a/react-js/fetch-axios.js b/react-js/fetch-axios.js new file mode 100644 index 0000000..f70ac7c --- /dev/null +++ b/react-js/fetch-axios.js @@ -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); \ No newline at end of file