Skip to content

Instantly share code, notes, and snippets.

View raihansikder's full-sized avatar

Raihan Sikder raihansikder

View GitHub Profile
@raihansikder
raihansikder / my.cnf
Created April 14, 2022 08:14 — forked from fevangelou/my.cnf
Optimized my.cnf configuration for MySQL/MariaDB (on Ubuntu, CentOS, Almalinux etc. servers)
# === Optimized my.cnf configuration for MySQL/MariaDB (on Ubuntu, CentOS, Almalinux etc. servers) ===
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# ~ Updated December 2021 ~
#
#
# The settings provided below are a starting point for a 8-16 GB RAM server with 4-8 CPU cores.
# If you have different resources available you should adjust accordingly to save CPU, RAM & disk I/O usage.
#
@raihansikder
raihansikder / deploy.sh
Last active February 11, 2022 19:37 — forked from BenSampo/deploy.sh
Forge Laravel deploy script
# Change to the project directory
cd $FORGE_SITE_PATH
# Turn on maintenance mode
$FORGE_PHP artisan down || true
# Pull the latest changes from the git repository
# git reset --hard
# git clean -df
git pull origin $FORGE_SITE_BRANCH
@raihansikder
raihansikder / ChangeDbTableEngine.php
Created September 8, 2021 13:47
Change DB table engine to innoDB and set ROW_FORMAT = DYNAMIC
\\ Change to inno-db
class ChangeDbTableEngine extends Migration
{
public function up()
{
$items = Schema::getAllTables();
foreach ($items as $item) {
$dbName = config('database.connections.mysql.database');
@raihansikder
raihansikder / migration-to-make-fields-nullable.php
Last active April 5, 2016 11:50
This migration uses a separate database connection with name 'mysql-information-schema' to get table and field information from information_schema table of MySQL. This connection should be defined in app/config/database.php
<?php
// this is to get table related information from a different table
/*
'mysql-information-schema' => array(
'driver' => 'mysql',
'host' => '127.0.0.1',
'database' => 'information_schema',
'username' => 'root',
'password' => '',
@raihansikder
raihansikder / insertLog.php
Last active December 28, 2015 04:39
Function to insert an even as a log in log table
<?php
function insertLog($log_module, $log_event, $log_affected_table_name, $log_affected_table_primary_key_field, $log_affected_table_primary_key_value, $log_sql_query_string, $log_event_user_id, $log_information) {
$sql = "
INSERT INTO log(
log_module,
log_event,
log_affected_table_name,
log_affected_table_primary_key_field,
log_affected_table_primary_key_value,
log_sql_query_string,
@raihansikder
raihansikder / CompareDatetime.php
Created February 26, 2013 00:51
Compares two datetime
$exp_date = "2006-01-16";
$todays_date = date("Y-m-d");
$today = strtotime($todays_date);
$expiration_date = strtotime($exp_date);
if ($expiration_date > $today) {
$valid = "yes";
} else {
$valid = "no";
}
<?php
/*
* fetch multiple rows of data and return in a single array
*/
function mysql_fetch_rowsarr($result, $numass=MYSQL_BOTH) {
$i=0;
@$keys=array_keys(mysql_fetch_array($result, $numass));
@mysql_data_seek($result, 0);
while ($row = mysql_fetch_array($result, $numass)) {
foreach ($keys as $speckey) {