вторник, 25 апреля 2017 г.

MYSQL Optimize

Do Not ORDER BY RAND()

This is one of those tricks that sound cool at first, and many rookie programmers fall for this trap. You may not realize what kind of terrible bottleneck you can create once you start using this in your queries.

If you really need random rows out of your results, there are much better ways of doing it. Granted it takes additional code, but you will prevent a bottleneck that gets exponentially worse as your data grows. The problem is, MySQL will have to perform RAND() operation (which takes processing power) for every single row in the table before sorting it and giving you just 1 row.


// what NOT to do:
$r = mysql_query("SELECT username FROM user ORDER BY RAND() LIMIT 1");


// much better:

$r = mysql_query("SELECT count(*) FROM user");
$d = mysql_fetch_row($r);
$rand = mt_rand(0,$d[0] - 1);

$r = mysql_query("SELECT username FROM user LIMIT $rand, 1");
So you pick a random number less than the number of results and use that as the offset in your LIMIT clause.

Отблагодарить можно через форму справа "Donate" ... )

To reward you via the form on the right "Donate" ... )

:)

среда, 12 апреля 2017 г.

Подключение и настройка microMinimosd на базе MWOSD


Для прошивки microMinimosd

Скачиваем Arduino IDE
https://www.arduino.cc/en/main/software
Скачиваем MWOSD
http://www.mwosd.com/

Открываем в ардуино файл MW_OSD.ino
разкоменчиваем нужные строки в config (PIXHAWK, microMinimosd и т.д)
заливаем (с помощью программматора Usb-UART CP2102)
И заново настраиваем


Инструкции по подключению PIXHAWK / APM / MAVLINK OSD

See other guides for installing Arduino and uploading MWOSD:

https://github.com/ShikOfTheRa/scarab-osd/blob/master/OTHER/DOCUMENTATION/FirmwareFlashing.md

Step 1: prepare your config.h file

Select the GPS chip type by removing the comments:

//#define PIXHAWK
Select the aircraft type:

//#define ROTORCRAFT
//#define FIXEDWING
Step 2: Upload

https://github.com/ShikOfTheRa/scarab-osd/blob/master/OTHER/DOCUMENTATION/FirmwareFlashing.md

Step 3: Change GUI speed to match OSD - usually 57600

Step 4: Upload fontfile using GUI

Step 5: Configure OSD using GUI

Step 6: Configure the MAVLINK settings

Connect to Mission Planner
Go to config/tuning
Locate parameters in parameter list
Enter / verify the following parameters and save
If you are connecting OSD to telemetry 1 port

SERIAL1_BAUD, 57 (telemetry output at 57600)
SR1_EXT_STAT, 2 ( 2hz for waypoints, GPS raw, fence data, current waypoint, etc)
SR1_EXTRA1, 5 ( 5hz for attitude and simulation state)
SR1_EXTRA2, 2 ( 2hz for VFR_Hud data )
SR1_EXTRA3, 3 ( 3hz for AHRS, Hardware Status, Wind )
SR1_POSITION, 2 ( 2hz for location data )
SR1_RAW_SENS, 2 ( 2hz for raw imu sensor data )
SR1_RC_CHAN, 5 ( 5hz for radio input or radio output data )
If you are connecting OSD to telemetry 2 port:

SERIAL2_BAUD, 57 (telemetry output at 57600)
SR2_EXT_STAT, 2 ( 2hz for waypoints, GPS raw, fence data, current waypoint, etc)
SR2_EXTRA1, 5 ( 5hz for attitude and simulation state)
SR2_EXTRA2, 2 ( 2hz for VFR_Hud data )
SR2_EXTRA3, 3 ( 3hz for AHRS, Hardware Status, Wind )
SR2_POSITION, 2 ( 2hz for location data )
SR2_RAW_SENS, 2 ( 2hz for raw imu sensor data )
SR2_RC_CHAN, 5 ( 5hz for radio input or radio output data )
Notes:

57600 is default serial buad rate recommended when selecting APM / PIXHAWK in config.h
Baud rate in OSD and APM/PIXHAWK must match.
Always try 57600 and 115200 if no data
Use debug screen to verify: RX > 0 means there is data. PKT > 0 means there is valid data.
If no valid data, likely incorrect baud rate

Отблагодарить можно через форму справа "Donate" ... )

To reward you via the form on the right "Donate" ... )

:)

воскресенье, 2 апреля 2017 г.

друзья )

Сохраняйте и делитесь желаниями, и не забывайте о важных датах! парсинг центр