Posts

Live engine important stuffs

Image
  How to configure reconnection timeout in LiveKit server? Use environment variable: Set the environment variable LIVEKIT_PARTICIPANT_RECONNECTION_TIMEOUT in your docker-compose file or Docker environment: services:   livekit:     image: livekit/livekit-server     environment:       - LIVEKIT_PARTICIPANT_RECONNECTION_TIMEOUT=120s  # default is 15 seconds     # other config To apply changes: cd /opt/livekit/ #Must go into this directory  docker-compose up -d --force-recreate livekit To Verify: docker exec -it $(docker ps -qf "name=livekit") printenv | grep LIVEKIT_PARTICIPANT_RECONNECTION_TIMEOUT sudo ufw allow 22/tcp sudo ufw allow 80/tcp sudo ufw allow 443/tcp sudo ufw allow 7881/tcp sudo ufw allow 443/udp sudo ufw allow 50000:60000/udp sudo ufw enable For separate Redis server: On Redis VPS sudo ufw allow 6379 For Livekit load balancing : On Livekit VPS ufw allow 7880 ufw allow 3478/udp sudo ufw allow 534...

Protect VPS from Disk space Eater

For Docker: nano /etc/docker/daemon.json Put: {   "log-driver": "json-file",   "log-opts": {     "max-size": "50m",     "max-file": "3"   } } sudo systemctl daemon-reload sudo systemctl restart docker Sometimes needed  After editing: docker-compose down docker-compose up -d To check validity: jq . /etc/docker/daemon.json Verify settings are active: docker info | grep -A3 "Logging Driver" You should see: Logging Driver: json-file ... For System Logs: nano  /etc/systemd/journald.conf Uncomment and make: ForwardToSyslog=no Then reload: sudo systemctl restart systemd-journald

How to create virtual environment in python

 python3.9 -m venv myenv Notes: Here specifying python 3.9 version source myenv/bin/activate pip install package_name Django Run: python3.9 manage.py runserver 0.0.0.0:8000 deactivate

Deploy nextjs in nginx with PM2

Step by Step In next.config.mjs comment // output: 'export' $ npm run build  In next.config.mjs Uncomment // output: 'export' $ npm run build Move nextjs directory to /var/www/ in VPS without node_modules (It's Big files) $ npm i $ cd /etc/nginx/sites-available server {     listen 80;     server_name proj.consultechbd.com;  # Replace with your actual domain name     location / {         #root   /var/www/nextjs-paikari/out;         #index  index.html;         proxy_pass http://localhost:3000;         proxy_http_version 1.1;         proxy_set_header Upgrade $http_upgrade;         proxy_set_header Connection $connection_upgrade;         proxy_set_header Host $host;         proxy_cache_bypass $http_upgrade;     }     location /_next/static/ { ...

Transfer file to Server and vice versa

Local to Server:   scp -P 2222 /absolute_path/source-folder/some-file user@example.com:/absolute_path/destination-folder Server to Local: scp -P 2222 u ser@example.com:/absolute_path/destination-folder /absolute_path/source-folder/some-file How do I extract tar.xz files in Linux? The syntax is: Install xz using the  dnf install xz  on a CentOS/RHEL/Fedora Linux. Debian/Ubuntu Linux users try  apt install xz-utils  command. Extract tar.xz using the  tar -xf  backup.tar.xz  command To decompress filename.tar.xz file run:  xz -d -v  filename.tar.xz

Timezone missing in mysql database (celery periodic task)

 Ref:  https://stackoverflow.com/questions/21351251/database-returned-an-invalid-value-in-queryset-dates#21571350 You have to load timezone tables into mysql ( http://dev.mysql.com/doc/refman/5.6/en/mysql-tzinfo-to-sql.html ). Try execute on your database server: mysql_tzinfo_to_sql / usr / share / zoneinfo | mysql - D mysql - u root - p And then run "flush tables" or "flush query cache", otherwise the problem may not disappear even though you've loaded the correct timezone data: mysql - u root - p - e "flush tables;" mysql

How to Import and Export MySQL Database Command line in Linux

************ TO EXPORT ************ 1. SSH login as root. 2. Run command   mysqldump -a -u ejobsolution_db_user --password= db_password ejobsolution_db > ejobsolution_db.sql Download ejobsolution_db.sql from root directory Reference:  https://webhostinggeeks.com/howto/import-and-export-mysql-database-command-line-in-linux/ Reference:  https://archive.virtualmin.com/node/6032 How to Export MySQL Database Command line in Linux 1. Syntax to Export: mysqldump -u USERNAME -p DATABASE_NAME > filename.sql How to Export MySQL Database Command line in Linux 2. Syntax to Import: mysql -u USERNAME -p DATABASE_NAME < filename.sql CREATE USER 'db_user'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON * . * TO 'db_user'@'localhost'; mysql -u db_user -p CREATE DATABASE db_name;

Laravel Stuffs

Create project with composer: composer create-project laravel/laravel example-app To run with IP address for Mobile app development: php artisan serve --host 0.0.0.0 --port 8000  To migrate: php artisan migrate Sqlite: touch database/database.sqlite User absolute path for sqlite: DB_CONNECTION=sqlite  DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=/media/than/8d3a469e-9421-470b-842e-26012f02dd47/than/dev_laravel/example-app/database/database.sqlite DB_USERNAME=root DB_PASSWORD= Reference:   https://laravel.com/docs/9.x/installation

JAVA_HOME setup and Integrate with Android Studio Project in Ubuntu

 $ whereis jvm      jvm: /usr/lib/jvm $ nano .bashrc Write :      JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64      export JAVA_HOME      PATH=$PATH:$JAVA_HOME/bin      export PATH Close Terminal and Re-open Terminal: $ echo $JAVA_HOME      /usr/lib/jvm/java-11-openjdk-amd64 Reference :  https://youtu.be/106uH7USwZ8 In Android Studio: Fire->Project Structure -> Need to update in SDK Location and Modules sections to java-11 Reference:  https://youtu.be/lv-jE2d4Aoc

Generate SHA-1 and SHA-256 for Debug and Release android app

Go to the Root directory of the project and generate on Terminal. Debug SHA-1 and SHA-256:      keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android Release SHA-1 and SHA-256: keytool -list -v -keystore /home/than/flutterProjects/PlayStoreKeystore/farm_to_retail.jks - alias key0

Ubuntu running slow? Check your CPU settings!

 https://thelinuxuser.com/ubuntu-running-slow/

Django Migration Problem Solution

* Delete table manually from DB * Delete migration file in migrations folder * User following example commands:         - python manage.py makemigrations         -  python manage.py migrate --fake core 0038_auto_20211003_2229         -  python manage.py migrate core 0039_customerbkashpayment (Note: 0039_customerbkashpayment is the recently migration file. 'core' is app name. 0038_auto_20211003_2229 is the previous on issue migrated file.)

Git Command line instructions (Git Lab)

Git Command line instructions Git global setup: git config --global user.name "Than Aung Kyow" git config --global user.email "thanaungkyow3@gmail.com" Create a new repository: git clone https://............directory.git cd directory git switch -c main touch README.md git add README.md git commit -m "add README" git push -u origin main Push an existing folder: cd existing_folder git init --initial-branch=main git remote add origin https://...........git git add . git commit -m "Initial commit" git push -u origin main Push an existing Git repository: cd existing_repo git remote rename origin old-origin git remote add origin https://.............git git push -u origin --all Fore to push: git push --force origin master If you really want to remove all of the repository, leaving only the working directory then it should be as simple as this. rm -rf .git  
  CKEditor 5  Math equations and chemical formulas (ReactJs) Math equations and chemical formulas: https://ckeditor.com/docs/ckeditor5/latest/features/math-equations.html Installing plugins: https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/installing-plugins.html#adding-a-plugin-to-a-build Import Customized Build into ReactJS: https://github.com/ckeditor/ckeditor5/issues/2072#issuecomment-534987536 Display Math equation from CKeditor5 in ReactJS: better-react-mathjax https://www.npmjs.com/package/better-react-mathjax Basic example with MathML: import React from "react" ; import { MathJax , MathJaxContext } from "better-react-mathjax" ; export default function App () { return ( < MathJaxContext > < h2 >Basic MathJax example with MathML</ h2 > < MathJax > < math > < mrow > < mrow > < mfrac > < mn >10...

Django With ReactJs

  Solving CSRF issue on React With Django (Running on Django Server) npm install js-cookie --save import Cookies from 'js-cookie' const csrftoken = Cookies.get( 'csrftoken' ) // Cookies from Django Domain const loginRequest = async () => { await Axios({ method : "post" , url : `/api/api-auth/login/` , headers : { 'X-CSRFToken' : csrftoken }, data : {} }).then( ( res ) => { console .log(res.data); }) } Fetch CSRF Token from Django Server: django.middleware.csrf.get_token(request) Send emails with Django and Gmail , a better way : https://dev.to/abderrahmanemustapha/how-to-send-email-with-django-and-gmail-in-production-the-right-way-24ab

Solution to install 'Pyrebase' in python3.6 django framework

https://stackoverflow.com/questions/48047495/when-pip-install-pyrebase-i-got-error-unicodedecodeerror-cp949-codec-can

City Vehicles References

Make an Android App like Uber - YouTube Link:  https://www.youtube.com/playlist?list=PLxefhmF0pcPl6gcWvrpTbjGO7rcMWY1jT GeoLocation Library:  https://github.com/firebase/geofire-android Google Maps for Android in Urdu/Hindi - YouTube Link:  https://www.youtube.com/playlist?list=PLj76U7gxVixRiyR_fJlpPR-tAlK0Py7f4 https://android.googlesource.com/platform/packages/experimental/+/001472f/NotificationShowcase/src/com/android/example/notificationshowcase/NotificationShowcaseActivity.java Android Material Color System:  https://material.io/design/color/the-color-system.html#tools-for-picking-colors AutoCompleteTextView with a custom adapter: https://codinginflow.com/tutorials/android/custom-autocompletetextview/part-1-layouts-model-class https://codinginflow.com/tutorials/android/custom-autocompletetextview/part-2-adapter

Create a Music Player on Android

Create a Music Player on Android: Project Setup https://code.tutsplus.com/tutorials/create-a-music-player-on-android-project-setup--mobile-22764 Create a Music Player on Android: Song Playback https://code.tutsplus.com/tutorials/create-a-music-player-on-android-song-playback--mobile-22778 Create a Music Player on Android: User Controls https://code.tutsplus.com/tutorials/create-a-music-player-on-android-user-controls--mobile-22787 MediaPlayer overview (Google Guide) https://developer.android.com/guide/topics/media/mediaplayer.html#audiofocus A Step by Step Guide to Building an Android Audio Player App https://www.sitepoint.com/a-step-by-step-guide-to-building-an-android-audio-player-app/ Media streaming with ExoPlayer Media Streaming with Exoplayer: https://codelabs.developers.google.com/codelabs/exoplayer-intro Media streaming with ExoPlayer Media streaming with ExoPlayer

PHP and JQuery Stuff

Declaring non Existing object: In order to comply with  E_STRICT  standards prior to PHP 5.4, or the normal  E_WARNING  error level in PHP >= 5.4, assuming you are trying to create a generic object and assign the property  success , you need to declare  $res  as an object of  stdClass  in the global namespace: $res = new \stdClass (); $res -> success = false ; Jquery Email Regex: var userinput = $ ( this ). val (); var pattern = /^\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b$/ i if (! pattern . test ( userinput )) { alert ( 'not a valid e-mail address' ); }​ Jquery Session: https://www.w3schools.com/jsref/prop_win_localstorage.asp How to bind click event to dynamically created HTML elements in jQuery If you try to do something with the elements that are dynamically added to DOM using the jQuery  click()  method it will not work, because it bind the click event only to the elements that exist at the ...