Misalkan ada suatu percobaan yang independent . Setiap kali percobaan itu akan memiliki kemungkinan sukses (probabilitas) sebesar p. Jika X
Memperbesar ukuran upload file Apache2
File konfigurasi yang perlu di edit adalah php.ini yang letaknya bisa berbeda tergantung modul php yang digunakan, antara lain:
- /etc/php/7.4/apache/php.ini
- /etc/php/7.4/fpm/php.ini
Versi php dapat disesuaikan
Parameter yang perlu diatur adalah :
post_max_size = 100M
upload_max_filesize = 100M
Besar ukuran dapat diubah sesuai kebutuhan
Jangan lupa setelah itu, web server Apache perlu di restart
$ sudo service apache2 restart
Enlightlite bugs resolve
Moodle specification:
Version 3.9.x, 3.10.x
Theme: Enlightlite
changing in enlightlite/classes/core/course_renderer.php
search: top_course_menu
$sql = "SELECT a.category , a.cnt from ( SELECT category , count(category) as cnt FROM {course} C";
$sql .= " INNER JOIN {course_categories} cc ON cc.id = c.category WHERE category != 0 and c.visible <>1 and cc.visible<>1 group by category ) as a order by a.cnt desc ";
Custom Moodle User Profile Page
Follow these steps to customize the user profile page.
1. Go to theme/config.php file and find this code.
// My public page.
‘mypublic’ => array(
‘file’ => ‘columns2.php’,
‘regions’ => array(‘side-pre’),
‘defaultregion’ => ‘side-pre’,
),
2. Create your custom layout file in layout folder and replace it like below
// My public page.
‘mypublic’ => array(
‘file’ => ‘yourcustomlayout.php’,
‘regions’ => array(‘side-pre’),
‘defaultregion’ => ‘side-pre’,
),3. Create a template file(yourcustom.mustache) in templates folder in theme.
4. in your custom layout php file get all user information and render it on .mustache file like below
echo $OUTPUT->render_from_template(‘theme_custom/mypublic’, $templatecontext);
Reference:
https://moodle.org/mod/forum/discuss.php?d=370809
MySQL: Duplicate table
Duplikasi struktur table nya saja tanpa data
CREATE TABLE new_table LIKE original_table;
Perintah di atas akan membuat duplikat struktur table new_table yang sama persis dengan original_table.
Untk menyalin datanya dapat menggunakan perintah sebagai berikut:
INSERT INTO new_table SELECT * FROM original_table;
Reference: https://popsql.com/learn-sql/mysql/how-to-duplicate-a-table-in-mysql
Insert MySQL Table from *.csv file
Setup local infile
Sebelum dapat melakukan load data secara local ke dalam database, maka perlu memastikan bahwa load infile dalam kondisi aktif
Periksa status local infile
mysql> show global variables like 'local_infile';
Akan memberikan informasi seperti di bawah ini:
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| local_infile | OFF |
+---------------+-------+
1 row in set (0.00 sec)
Untuk mengaktifkan gunakan perintah berikut:
mysql> set global local_infile=true;
Setelah itu silahkan connect ke database dengan parameter local infile
mysql --local_infile=1 -u root -ppassword DB_name
Dan lakukan load data local, seperti:
mysql> load data local infile 'path/file_name.extention' into table table_name;
INSERT
Misalkan kita memiliki table berikut ini:
mysql> desc temp_user_info_data;
+------------+------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+------------+------+-----+---------+----------------+
| id | bigint(10) | NO | PRI | NULL | auto_increment |
| userid | bigint(10) | NO | MUL | 0 | |
| fieldid | bigint(10) | NO | | 0 | |
| data | longtext | NO | | NULL | |
| dataformat | tinyint(2) | NO | | 0 | |
+------------+------------+------+-----+---------+----------------+
Catatan: untuk melihat info lebih detail tentang table dan bagaimana table tersebut di buat, Anda dapat menggunakan perintah:
mysql> desc namatable
atau
mysql> show create table namatable;
Kemudian file data kita diletakkan di /root dengan nama file data *.csv: contoh.csv seperti berikut:
5791,23,11
19766,23,11
Lalu lakukan load data:
mysql> load data local infile '/root/contoh.csv' into table temp_user_info_data fields terminated by ',' (userid,fieldid,data);
Query OK, 2 rows affected (0.01 sec)
Records: 2 Deleted: 0 Skipped: 0 Warnings: 0
Jika data Anda memiliki satu baris pertama yang berisi nama kolom, maka berikan ignore 1 lines seperti berikut:
mysql> load data local infile '/root/contoh.csv' into table temp_user_info_data fields terminated by ',' ignore 1 lines (userid,fieldid,data);
Switch php version
Berikut adalah untuk switch dari satu versi php ke versi lainnya
sudo update-alternatives --config php
Setelah itu akan muncul pilihan sebagai berikut (tergantung php version yang sudah/pernah di install):
There are 5 choices for the alternative php (providing /usr/bin/php).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/php8.1 81 auto mode
1 /usr/bin/php7.1 71 manual mode
2 /usr/bin/php7.2 72 manual mode
* 3 /usr/bin/php7.4 74 manual mode
4 /usr/bin/php8.0 80 manual mode
5 /usr/bin/php8.1 81 manual mode
Press <enter> to keep the current choice[*], or type selection number:
Reference: https://php.tutorials24x7.com/blog/how-to-switch-php-version-on-ubuntu-20-04-lts

Mod rewrite (part.1)
Mod Rewrite part.1
Mod_Rewrite memungkinkan Anda membuat URL khusus dan sederhana sesuai kebutuhan.
Tulisan ini akan membahas tentang bagaimana mengaktifkan Mod_Rewrite, Membuat dan Menggunakan halaman .htaccess yang diperlukan, dan menyiapkan penulisan ulang URL.
Before we begin generating the actual URL rewrites, we need to activate the apache mod_rewrite module that controls them.
sudo a2enmod rewrite
Perintah mengaktifkan modul atau—jika sudah diaktifkan, menampilkan kata-kata, “Module rewrite sudah diaktifkan”
Setelah modul diaktifkan, Anda dapat mengatur penulisan ulang URL dengan membuat file .htaccess di direktori situs web Anda.
File .htaccess adalah cara untuk mengonfigurasi detail situs web Anda tanpa perlu mengubah file konfigurasi server. Tanda titik yang meng’awali’ nama file akan membuat file ini tidak tampak secara default di dalam folder.
Selain itu, peletakan file .htaccess juga penting. Konfigurasi dalam file itu akan memengaruhi semua yang ada di direktori dan direktori di bawahnya.
Cara mengizinkan perubahan dalam file .htaccess
Untuk mengizinkan file .htaccess menimpa konfigurasi situs web standar, kita awali dengan dengan membuka file konfigurasi. Catatan: Anda memerlukan hak sudo untuk langkah ini.
sudo nano /etc/apache2/sites-available/default
Setelah berada di dalam file itu, temukan bagian berikut, dan ubah baris yang mengatakan AllowOverride dari None menjadi All. Bagian tersebut sekarang akan terlihat seperti ini:
<Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory>
Setelah Anda menyimpan dan keluar dari file itu, restart apache. File .htaccess sekarang akan tersedia untuk semua situs Anda.
sudo service apache2 restart
Refference: Digital Ocean: How To Set Up Mod_Rewrite
Netplan & DNS nameserver Ubuntu 18.04
Selama bertahun untuk setting nameserver kita cukup mengganti /etc/resolv.conf :
nameserver 8.8.4.4 nameserver 8.8.8.8
selain itu kita dapat merubah di /etc/network/interfaces menjadi
dns-addresses 8.8.4.4, 8.8.8.8
Lalu restart :
sudo systemctl restart networking
atau
sudo /etc/init.d/networking restart
Saat ini versi terbaru ubuntu mulai menggunakan Netplan.
Netplan adalah utilitas baris perintah untuk konfigurasi jaringan pada distribusi Linux tertentu. Netplan menggunakan file deskripsi YAML untuk mengkonfigurasi antarmuka jaringan dan, dari deskripsi tersebut, akan menghasilkan pilihan konfigurasi yang diinginkan untuk alat render (eg. network-manager).
File yang perlu kita setup adalah : /etc/netplan/01-*/yaml.
Sehingga kita perlu meletakkan code seperti berikut di dalamnya:
nameserver: addresses: [8.8.4.4, 8.8.8.8]
Fix Error #551 in phpMyAdmin 18.04
Error message containts :
Warning in ./libraries/plugin_interface.lib.php#551
count(): Parameter must be an array or an object that implements Countable
Solution:
You can also fix this by editing the library itself.
- Make a backup first
sudo cp /usr/share/phpmyadmin/libraries/plugininterface.lib.php /usr/share/phpmyadmin/libraries/plugininterface.lib.php.bak - Edit the library
sudo nano /usr/share/phpmyadmin/libraries/plugin_interface.lib.php - Search for “if (! is_null($options) && count($options) > 0) {”
or if not found then search for “if ($options != null && count($options) > 0) {”
Then replace it with “if ($options != null) {”
To search in Nano editor press CTRL and W
- Save the file (CTRL and O)
- Refresh the phpMyAdmin page and try agin.
Backup Stored Procedures and Routines
We need to specify --routines
to take backup of stored procedures with data and tables.
The following command will take backup of entire database including stored procedures. For example, your database name is “mydb”.
mysqldump -u root -p –routines mydb > mydb.sql
To take backup of only Stored Procedures and Triggers (Exclude table and data ) use the following command.
mysqldump –routines –no-create-info –no-data –no-create-db –skip-opt mydb > mydb.sql
Reference:
https://tecadmin.net