Tuesday, May 3, 2022

Wordpress move errors and fixes

Export wordpress blog from one domain to another


1. To move a wordpress installation just go and archive the files where wordpress is installed and make it a zip archive as cpanel can extract only zip files.

2. Open phpMyAdmin and export the database to export_file.sql
You are done on the old server.

Login to cpanel on new server.
Go to File Manager upload and extract archive to public_folder.

Create a new database and a username and associate the username to the database.
Open phpMyAdmin select the created database and import the export_file.sql


Next we have to change Site URL and Home Settings to point to the new domain.
Select wp_options table and edit first two rows : siteurl and home to the new domain name.

Optional you can add to wp-config.php the lines instead of edition the wp_options table, but this will grey out the url option in wordpress admin so i suggest to use the database table edit.
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');

Next edit wp-config.php and insert database name, username and password of the user associated to the database :

/** The name of the database for WordPress */
define('DB_NAME', 'database_name');

/** MySQL database username */
define('DB_USER', 'username');

/** MySQL database password */
define('DB_PASSWORD', '1234');

WP - Error establishing a database connection

Yousite.com/wp-admin/maint/repair.php


Press the Repair Database button:
The wp_options table is not okay. It is reporting the following error: Table is marked as crashed and last repair failed. WordPress will attempt to repair this table…

For this to work you must have this enabled:

 wp-config.php 

define('WP_ALLOW_REPAIR', true);

Also check in here that the corect database is selected, and you can also check with phpMyAdmin the database.

Fo security reasons you should disable it afterwards.

It can be done in multiple ways.

First is edit php.ini. Find error_reporting = E_ALL and add to it to look like this :
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED

then restart apache server.

If this does not work you can always go to your wordpress installation and edit wp-config.php and add this :

ini_set('log_errors','On');
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);


instead of  :
define('WP_DEBUG', false);

Refresh the page where you got the warnings and enjoy. ;)



Thursday, March 3, 2022

Linux Python

 To install a custom version of python, download and compile from here:

https://www.python.org/ftp/python/

MuEditor - requires python < 3.9 + install libsqlite3-dev before compiling 

python3.8 -m venv mu-editor              (create a virtual env in the mu-editor folder)
cd mu-edit/bin
source activate                                       (activates in console the virtual env)

pip install mu-editor


To install python apps you use pip

Pip aplications: https://pypi.org/project/mu-editor/

Make shorutcuts for python apps while in virtual env

pip install shortcut
shortcut mu-editor

Friday, February 11, 2022

Take a screenshot of an entire web page from chrome

 Open inspector mode - F12 or CTRL+SHIFT+I

then CTRL+SHIFT+P

and type screenshot - and select Capture ful size screenshot.



Friday, January 28, 2022

Video - vlc crash, reduce video size, resolutions, davinci on linux

Vlc crashes when taking a screenshot

I tried to take a screenshot from a .mkv video and it crashes every time though it works fine with normal mp4.

To fix it disable hardware acceleration in codecs.

Go to Preferences - Input/Codecs - Hardware-accelerated decoding - 

Change from Automatic to Disabled.

Try again. It worked for me.

How To Reduce a Video File Size

Download Handbrake : https://handbrake.fr/downloads.php

Install handbrake then follow the image instructions :

1. Select Source and put you video in or just drag the video over handbrake window.
2. Select Destination and type and name for the video.
3. Select the Video tab and drag Quality to the left up to 25 or even lower dont go lower then 30 as it gets bad, but you can test and see what you like.
4. Pres Start.

Resolutions compatible with full hd or 1920 x 1080

HD     720p   -- 1.77:1 (16:9)  /  1280x720
FHD 1080p -- 1.77:1 (16:9)  /  1920x1080
QHD                                        2560x1440
UHD 4k       -- 1.77:1 (16:9)  /  3840x2160

At under 100 ppi image gets pixalated from close up 20-30cm
For a PPI ~100
4k 3840x MAX 42 inch
QHD -  MAX 27 inch
FHD MAX 22 inch 

Run Davinci on Linux

Once you install DaVinci you  get a message that no suported video cards are detected and something about no media storage.
You need to install video and opencl drivers.


Wednesday, January 12, 2022

Install scanner in linux - Brother DCP-7030

Scanner in LINUX - SANE - Scanner Access Now Easy


sudo sane-find-scanner  *** list connected scanners
lsubs *** view usb connected devices ( sudo apt install usbutils )

scanimage -L  *** check if sane detects your scanner
SANE_DEBUG_DLL=3 scanimage -L
load: dlopen() failed (libusb-0.1.so.4: cannot open shared object file: No such file or directory)

To fix it:
apt search --names-only libusb-0.1
rezult: libusb-0.1-4/stable 2:0.1.12-32 amd64 
sudo apt install libusb-0.1-4 

Open the file -> /etc/sane.d/dll.conf 
and add one line with 
brother3
!!! note when you run scanimage -L it will check every record, so just delete all records and leave your printer name

Create a new file with your printer name and add it.
brother.conf
firmware /usr/lib64/sane/libsane-brother3.so.1.0.7
usb 0x04f9 0x01ea

!!! you get vendor id from lsusb or sane-find-scanner

You might just use the install package to install the rules file automaticly instead.
/etc/udev/rules.d/60-myprinter.rules
# Brother scanner
ATTRS{idVendor}=="04f9", MODE="0666", GROUP="scanner", ENV{libsane_matched}="yes"
!!! change idVendor - with your printer vendor id

Brother DCP-7030
udev rules -> brother-udev-rule-type1-1.0.2-0.all.deb
driver -> brscan3-0.2.13-1.amd64.deb

reboot
Things I did that i don't think are necesary:
sudo usermod -a -G myuser scanner
Copy the driver files under /usr/lib64/ to /usr/lib/.

For printing
Install cups, and brlaser (driver)
then go to localhost:631 - adminstration - add printer - done

Friday, September 10, 2021

Software management on linux

Debian has the largest package library of software.
It uses a package format .deb  that are installed by the dpkg app. 
In order to manage dependencies and download automatically there is apt (Advanced Packaging Tool).

Synaptic is a graphical package management tool based on GTK+ for apt.
Apt commands in the console.

apt installapt-get installInstalls a package
apt removeapt-get removeRemoves a package binaries
apt purgeapt-get purgeRemoves package with configuration and user data
apt autoremoveapt-get autoremoveRemoves unused dependencies
apt upgradeapt-get upgradeUpgrades all upgradable packages
apt updateapt-get updateRefreshes repository index / package list
apt full-upgradeapt-get dist-upgradeUpgrades packages with auto-handling of dependencies
apt searchapt-cache searchSearches for the program
apt showapt-cache showShows package details
apt listLists packages with criteria (installed, upgradable etc)
apt edit-sourcesEdits sources list

You can use synaptic  as a GUI for apt.

apt autoremove packagename --purge  - remove binaries, config, user data and dependencies - complete uninstall

apt list --installed | grep packagename - check if you have some package installed

Note: - purge only removes system wide configuration from the /etc folder.
It does not remove user profiles that are stored in the home folder .config and .cache folders

To remove 32 bit architecture packages and remove source repositories

sudo apt-get purge `dpkg --get-selections | grep ":i386" | awk '{print $1}'`
dpkg --remove-architecture i386
dpkg --print-foreign-architectures

https://ninite.com/ - package repository for windows.

Friday, May 21, 2021

3 PRONG ROCKER SWITCH

It has 3 legs marked 1, 2 (c - for common) and 3 (+/-) for light.

The rocker switch moves a metal arm between contact 2 and 1 on and off.
The 2 (c) is always on, only contact on pin 1 is on / off.

Pin 3 can be connected to the opposite polarity then what you chose to switch so the light turns on.

Note some have a led connected and same have a indicator glass bulb for 220v.

Saturday, January 9, 2021

Sharp GP2Y1014AU0F air quality with arduino

Pin 1 (sensor led) - 150ohm resistor to vcc 5v
Pin 6 - vcc 5v

Pin 2 - to gnd
Pin 4 - to gnd

Pin 3 - input led  - connect to a digital pin on arduino.
Note according to datasheet the input (drive) led is actually the base of a transistor connected to GND and not the actual led. So when we set the digital pin to HIGH we connect the led to GND and stop it.
To turn the led on we have to set the digital pin to LOW. 
Pin 5 - output- connect to analog pin on arduino A0-A5

Datasheet: https://global.sharp/products/device/lineup/data/pdf/datasheet/gp2y1010au_e.pdf

Connect Pin 3 lets say to DIGITAL 3.

We set in void() function --> pinmode(3, OUTPUT);

// one read
digitalWrite(ledPin, LOW); // power on the LED
delayMicroseconds(280); // Wait 0.28ms according to datasheet
output_voltage = analogRead(3); // read output
delayMicroseconds(40); // wait 0.040 ms according to datasheet
digitalWrite(ledPin, HIGH); // turn the LED off
output_voltage = (3.33 / 4096) * output_voltage; // max 3.6v
delayMicroseconds(9760);

Note: i used a chinese clone from wavgate and althout it says it has an atmega 328p chip - the analog line read 4064 when connected to the 3.3v line - so that means a 12bit ads with 3.33v internal reference.
If you have the normal 5v 10bit 1024 resolution ads - change above to 3.33/4096 to 5/1204 .

If you are not sure what ads bits you have, connect the 3.3 and 5 lines to A0 for example and read with analogRead and see what result you get.

Next we have to convert the voltage to dust density according to the graph offered in the datasheet.

We have from the graph and datasheet info:
Output voltage at no dust 0.6v - 0 mg/m3 dust - given in the datasheet
And the graph intersect at 3.5v - 0.5 mg/m3 dust - you can see it on the graph clearly
With two points we can make a formula.

y-0.6 = x-0
3.5-0.6 = 0.5-0

y-0.6      3.5-0.6 
------- = ----------
x-0          0.5-0

x = 0.5(y-0.6) / (3.5-0.6)
x = (y-0.6)*0.5/2.9 = (y-0.6)*0.17 = 0.17*y - 0.6*0.17 = 0.17y-0.1

Note: the sensor it is not very exact, as in the datasheet it says voltage at no dust is typical 0.6V but can go from 0.1V to 1.1V

if(output_voltage>0.6) {
    dust_density = (0.1724 * output_voltage) - 0.1;
    dust_density *= 1000;
}

There you go.
Because the sensor output fluctuates a lot and it is not stable, i like to make an average of around 100 reads (129 in the code below) or about one second - one read takes 10ms - so the output its a bit more stable.
Next is full code that shows result on and a lcd screen or on the serial console.


#include "LiquidCrystal_I2C.h"
LiquidCrystal_I2C lcd(0x27,20,4);

#define dustPin A0
#define ledPin 2

void setup() {

lcd.init(); // initialize the lcd
lcd.backlight();
lcd.clear();

Serial.begin(115200);
while (!Serial) delay(100);

Serial.println("GP2Y1010AU0F Sensor demo");
pinMode(ledPin,OUTPUT);

}

int i =0;
float sum =0;

void loop() {

float output_voltage =0;
float dust_density = 0;

// 100 samples medie - 1 reading per second
// one read

digitalWrite(ledPin, LOW); // power on the LED
delayMicroseconds(280); // Wait 0.28ms according to DS
output_voltage = analogRead(dustPin);
delayMicroseconds(40);
digitalWrite(ledPin, HIGH); // turn the LED off
output_voltage = (3.33 / 4096) * output_voltage; // max 3.6v
delayMicroseconds(9760);

if(output_voltage>0.6) {
dust_density = (0.1724 * output_voltage) - 0.1;
dust_density *= 1000;
}
else dust_density = 0;

sum = sum + dust_density;
i++;
if(i==129*2) {
dust_density = sum / i;
i=0;
sum =0;
lcd.setCursor(0,0);
lcd.print("Dust: ");
lcd.setCursor(6,0);
lcd.print(dust_density);
lcd.print("ug/m3");

/*
Serial.print(",\tDust Density = ");
Serial.print(dust_density);
Serial.println(" ug/m3");
*/

}
}


Wednesday, November 4, 2020

ESP32 ARDUINO

 


Open Arduino IDE go to File -> Preferences and add the link

https://dl.espressif.com/dl/package_esp32_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json

Then go to boards, search and install esp32.

When you upload the code if you get 

Failed to connect to ESP32: Timed out waiting for packet header

just press/hold the boot button - when it shows connecting... ___ ..... ____ .....

ESP32 Pinout



Tuesday, August 25, 2020

HRV biofeedback

 Meditation and bio-feedback.

HRV - heart rate variability

On an ECG - electrocardiogram - you get the letters P Q R S T.
The time between two R, noted as R-R is HRV.

Initially researched by HearthMath institute it has been now accepted and implmented by many.

During relaxation the parasympathetic nervous system dominates, heart bpm drops and HRV increases
During stress the sympathetic nervous system dominates, heart bpm increases and HRV decreases

If you are chronically stressed or injured etc the body will stay in a sympathetic mode to sustain recovery even while resting. This is consuming for the body and you should not do any stressful activities like training, tough decisions etc. that like overcome the body's ability to compensate and it will trow you out of balance and in a bad state of health.
Hence the need to read your morning HRV so you know how your body is doing and how you continue your day.

Sensors:

- HearthMath Inner Balance sensor: many reviews on amazon say the sensor's quality is not reflected by its price which is around 160$ + shipping
- Polar H7/H9 or H10 - H10 being the best for accuracy - most easy to find and buy locally ~ 100$
- CorSense from the maker of the app https://elitehrv.com/ - 165$ - but expensive outside of the US ( around 200$ in europe with added vat) - the most convenient one to use

Polar H7 and H9 vs Poalr H10

You can see in the above image, the H10 has the same metal rounded electrode that is crimped to the connector, but also another rectangular metal band behind it that acts as a shield connected to ground to prevent exterior interference.  

Note: i bought an spare chest strap from aliexpress that it is rated as a replacement for the H10 but it only has the main electrode and no shielding - so it is an equivalent to the H7/H9 soft strap.

“The extra interference-preventing electrodes on the strap make it extremely sensitive to your heart’s electrical signals, providing maximum precision for heart rate readings and eliminating interference.”


Saturday, November 30, 2019

Air quality PM sensors comparison for arduino

Best accuracy sensor:
( note that it works under 70% humidity depending on what weather conditions you have where you life)


The Nova SDS011 - also recommenced by the https://luftdaten.info/ project


Price: 17$
Official website: http://www.inovafitness.com/en/a/chanpinzhongxin/95.html
Buy from aliexpress: http://s.click.aliexpress.com/e/Nz5SXZBE

Connections for code:
-connect pin TXD on SDS011 to pin 2 in section (Digital PWM) on arduino (it will act as RX on arduino)
-connect pin RXD on SDS011 to pin 3 in section (Digital PWM) on arduino (it will act as TX on arduino)
-5v and gnd - same

Arduino Code: - it will print both to a i2c lcd display and serial console

#include "LiquidCrystal_I2C.h"
#include "SoftwareSerial.h"
SoftwareSerial mySerial(2, 3); 

// Global Variables
static unsigned char buf[7], buffSDS[25];
unsigned int PM2_5,PM10=0;

LiquidCrystal_I2C lcd(0x27,20,4); 

void setup() {
  // put your setup code here, to run once:
  lcd.init();                      // initialize the lcd 
  lcd.backlight();
  lcd.clear();

  
  // Read SDS011 on Serial 
  mySerial.begin(9600);  // 
  mySerial.setTimeout(200);
  //mySerial.readBytesUntil(0xAB,buffSDS,20); // read serial until 0xAB Char received

  // Serial Monitor
  Serial.begin(115200);  


}

void loop() {
  // put your main code here, to run repeatedly:
  // Read SDS011
  mySerial.readBytesUntil(0xAB,buffSDS,20);

  // Serial monitor, print the HEX bytes received in buffSDS
//Serial.write(buffSDS,10);

for ( int8_t i=0; i<10 ; i=i+1 )
  {
  Serial.print( buffSDS[i],HEX);
  Serial.print(" ");

  }
Serial.println("");

  
PM2_5 = ((buffSDS[3]*256)+buffSDS[2])/10; // extract PM2.5 value
Serial.print("PM2.5: ");
Serial.println(PM2_5);

lcd.setCursor(0,0);
lcd.print("PM2.5: ");
lcd.print(PM2_5);


PM10 = ((buffSDS[5]*256)+buffSDS[4])/10; // extract PM10 value
Serial.print("PM10: ");
Serial.println(PM10);
lcd.print((char)228);
lcd.print("g/m3");

lcd.setCursor(0,1);
lcd.print("PM10: ");
lcd.print(PM10);
lcd.print((char)228);
lcd.print("g/m3");


delay(500);
}

The sensor has 8000 hours of usage and outputs data every second. In order to use it for longer time you have to use the sleep and wake up vis serial.

Use this library : https://github.com/ricki-z/SDS011
It also has support for hardware serial connection for the esp32 which does not have software serial.

Check example in the library.


Plantower
Official website: http://www.plantower.com/en/content/?108.html

https://airly.eu/en/ - a project by Philips in witch they use the Plantower PMS5003
You can see the sensor and the insides of their sensor here:
https://www.youtube.com/watch?v=FREADCgdq2M

Plantower PMS5003

Buy the Plantower PMS5003 from aliexpress: http://s.click.aliexpress.com/e/tb2qOLXK
Price: 12-13$


Popular Pm monitors on the market and what sensors they use:

Laser Egg - uses Plantower PMS3003


AirVisual Node : proprietary PM sensorSenseAir S8 - for CO2




Additional resources:

http://aqicn.org/sensor/

https://www.mysensors.org/build/dust

Wednesday, November 20, 2019

Program Arduino Mini Pro 3.3/5V with Arduino Uno



Connect RST pin to GND on Arduino Uno - to bypass the UNO's bootloader

Connect 5V or 3.3V to VCC on Mini
Connect GND to GND on Mini
Connect TX to TX
Connect RX to RX

Select in the Arduino IDE -> Tools -> Board -> Arduino Pro or Pro Mini
Select in the Arduino IDE -> Tools -> Board -> Processor -> 3.3V 8Mhz or 5V 16Mhz
Select in the Arduino IDE -> Tools -> Port

Select File->Examples ->Basics->Blink and press Upload button
When uploading appears in the Arduino IDE press the RESET button on the mini.
When you press the RESET button you should see the rx,tx lights on the uno start to blink fast for a short time - the sketch it is being uploaded.

The led on the Mini Pro should start blinking at one second.
DONE. ENJOY.

Tuesday, November 19, 2019

Bosch BME280 sensor with arduino for temp humidity and pressure


Buy sensor for here: http://s.click.aliexpress.com/e/KY9P6WRm



Arduino Libraries Required:
Adafruit_Sensor.h
Adafruit_BME280.h

Go to Tools -> Manage Libraries :
search for bme280 and select the adafruit one, and install all.

Wire connections:
- 5V and GND to coresponding
- the marked ones SDA, SCL on the end of the digital pins
- or the analog pins A4 (SDA) A5 (SCL)

Arduino Code:

#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
Adafruit_BME280 bme; // I2C
void setup()
{
    bool status;
    status = bme.begin();
}
void loop() {
float temp = bme.readTemperature();   // celsius
  float humidity = bme.readHumidity();  // read humidity
  float altitude = bme.readAltitude(1013.25);// read altitude  SEA LEVEL PRESSURE_HPA (1013.25)
  float pressure = bme.readPressure() / 100.0F; // read pressure
delay(5000);

}

Display 2004A generic 4 line 20 characters display with PCF8574T expander



4 line display with PCF8574T -  I/O expander for I2C-bus -  two-wire bidirectional (serial clock (SCL), serial data (SDA))

Arduino Library required: LiquidCrystal_I2C.h
Put the files in Documents -> Arduino -> libraries

Tip: also buy a case for the display, it stands up and its easy to read: http://s.click.aliexpress.com/e/lqzxEDeo

Wire connections:
- 5V and GND to corresponding
- the marked ones SDA, SCL on the end of the digital pins
- or the analog pins A4 (SDA) A5 (SCL)

Arduino Code:

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27
void setup()
{
  lcd.init();                      // initialize the lcd
  lcd.backlight();
  lcd.clear();
 lcd.setCursor (0,3);   // first parameter its the line 0,1,2,3 - second character position 0-20
 lcd.print("Hello World");
}
void loop() {
}
 If you have more devices on the I2C buss you can change the address by soldering the A0, A1 OR A2 connection on the PCF8574T  board.


To display a special character : lcd.print((char)228);

Contract and Backlight
- In case you don't see nothing on the screen, use a screwdriver and adjust the blue potentiometer on the back.
- The backlight on/off is controlled by the jumper
- jumper in place: backlight on
- jumper removed: backlight off

The backlight can also be controlled with software.
Use  lcd.backlight(); to turn it on and lcd.noBacklight(); to turn it off.




Tuesday, July 17, 2018

Ergonomic bicycle saddle


Brooks leather saddles with springs - comfortable firm saddle - or buy a cheap Chinese copy.