Install ruby from source
Install rvm (ruby version manager)
Nginx Rails Origin header didn’t match request.base_url
Category: Programming
-
Python
- How to install Python 10 on CentOS 7
- Install Python 3.8 on CentOS 6 from source
- Install python 3.6 on CentOS 7
- Install Python 2.7 on CentOS 6
- pip
- Install jupyter notebook
- virtualenv
- Running Web Server with python SimpleHTTPServer
- https://colab.research.google.com/
Python framework
Hosting Python Application in Production
Python Errors
- error: Python.h: No such file or directory
- pip install mysqlclient mysql_config: not found
- ERROR: Failed building wheel for mysqlclient
- Python mechanize HTTP Error 403 request disallowed by robots.txt
- This version of ChromeDriver only supports Chrome version
- ModuleNotFoundError: No module named ‘PIL’
-
Magento 1.9 store login not working in Chrome
On a site running Magento 1.9, user login is not working on Google Chrome.
The problem is due to cookie setting in Magento. Login to Magento Admin, go to
Admin > System > configuration > web > Session and Cookie Management
Put your domain name in “Cookie Domain” text box and click Save Config.
-
Laravel
- Laravel Database Migration Error Key too long
- How to find Laravel Framework Version
- How to clear Laravel cache
- Laravel supported ciphers are AES-128-CBC and AES-256-CBC
- Nginx Config for Laravel Application in sub folder
- https://filamentphp.com – Build admin panel easily.
Create a project using the latest Laravel
composer create-project laravel/laravel blog
Create a project using a specific version of Laravel.
composer create-project laravel/laravel=5.1.33 --prefer-dist blog
You can see available Laravel versions on the site
https://packagist.org/packages/laravel/laravel
Clear Laravel application cache
rm -rf bootstrap/cache/*
or
php artisan cache:clear
Back to PHP
-
Laravel Database Migration Error Key too long
When doing a database migration on Laravel, I get the following error
$ php artisan migrate [Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`)) [PDOException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes $
This is because MariaDB uses a different UTF8 format.
To fix, edit file
vi ./app/Providers/AppServiceProvider.php
Inside, find
public function boot() { // }
Replace with
public function boot() { Schema::defaultStringLength(191); }
You will also need to add
use Illuminate\Support\Facades\Schema;
here is what my file looks like after editing.
$ cat ./app/Providers/AppServiceProvider.php <?php namespace App\Providers; use Illuminate\Support\Facades\Schema; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { /** * Bootstrap any application services. * * @return void */ public function boot() { Schema::defaultStringLength(191); } /** * Register any application services. * * @return void */ public function register() { // } } $
Back to Laravel
-
nodemon
Node.js applications when you run with nodejs command, need to restart when a change is made to the source code of the application.
nodemon will watch your application source code for changes, and restart if a change is detected.
To install nodemon, run
npm install -g nodemon
Example
nodemon app.js 3000
-
pm2 process manager for node.js
Auto Start pm2 on boot
How to host static site using pm2pm2 is a process manager for node.js applications. It is similar to forever.
First you need to install npm, on Ubuntu/Debian, run
apt install npm
To install pm2, run
npm install pm2 -g
Start an Application
pm2 start app.js
Start an Application with name
pm2 start app.js -n "app-name-here"
Start npm
pm2 start npm --name my-app -- run start
Start the Application in Cluster mode with
pm2 start app.js -n "app-name-here" -i 5
To Scale a clustered application, run
pm2 scale app-name-here 2
Start the processes on reboot
pm2 save pm2 startup
List running applications
pm2 ls
Controlling running application
pm2 stop pm2 restart pm2 delete
Restart all running applications
pm2 restart all
-
Check if PHP session is working
To check if PHP session is working, upload following script
Access the file, refresh the page in browser, if you see number increase with every refresh, PHP session is working properly on server.
-
Ruby On Rails
To create a ruby on rails project, run
rails new
-
PHP Script to List Enabled Extensions
Create a php script with following content
"; foreach (get_loaded_extensions() as $extn) { echo $extn . "\n"; }
See php
-
nodejs
Install
- Install Node.js on CentOS
- Install Node.js on Debian/Ubuntu
- How to Install Yarn Package Manager on Ubuntu
Node.Js Version Manager
Node.js Tips
Next.js
Errors
-
node version manager
n is the node version manager. To install, run
npm install n -g
To list versions of node.js available, run
n ls
To see all available node versions, run
n lsr
To install the latest stable node.js
n stable
To install a specific version of node.js
boby@sok-01:~$ n lsr Listing remote... Displaying 20 matches (use --all to see all). 18.10.0 18.9.1 18.9.0 18.8.0 18.7.0 18.6.0 18.5.0 18.4.0 18.3.0 18.2.0 18.1.0 18.0.0 17.9.1 17.9.0 17.8.0 17.7.2 17.7.1 17.7.0 17.6.0 17.5.0 boby@sok-01:~$ sudo n 18.10.0 installing : node-v18.10.0 mkdir : /usr/local/n/versions/node/18.10.0 fetch : https://nodejs.org/dist/v18.10.0/node-v18.10.0-linux-x64.tar.xz copying : node/18.10.0 installed : v18.10.0 (with npm 8.19.2) boby@sok-01:~$ node --version v18.10.0 boby@sok-01:~$ n ls node/12.18.4 node/18.10.0 boby@sok-01:~$
To change the Node.js version, run
sudo n
It will show a text-based menu to select the node version you need.
You can see all installed node.js versions in the folder
/usr/local/n/versions/node