Skip to content

Instantly share code, notes, and snippets.

@morad7
morad7 / commatodot.txt
Created July 28, 2019 10:26
Replace comma with dot php/mysql
//php
$num = (int) "10";
$num = (double) "10.12"; // same as (float) "10.12";
//mysql
update table
set myColumn = replace(myColumn, ',', '.')
where myColumn like '%,%'
@morad7
morad7 / import-arabic-data.txt
Created July 15, 2018 12:05
Import arabic data to Phpmyadmin from Excel
STEP 1
convert excel to sql with https://sqlizer.io
STEP 2
Add before sql code:
SET NAMES 'utf8';
SET CHARACTER SET utf8;
STEP 3
past the code to phpmyadmin or save/import it as an sql file
@morad7
morad7 / gist:33d8866cca0f23a60d715009575cbf72
Created April 20, 2018 09:08 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@morad7
morad7 / remove-phpmyadmin.txt
Created October 19, 2017 14:49
Remove phpmyadmin
sudo dpkg -P phpmyadmin
sudo rm -f /etc/apache2/conf.d/phpmyadmin.conf
sudo service apache2 restart
@morad7
morad7 / turnicate-cache-drupal-tables.sql
Created October 17, 2017 11:07
Turnicate big drupal database
SELECT TABLE_NAME, table_rows, data_length, index_length,
round(((data_length + index_length) / 1024 / 1024),2) "Size in MB"
FROM information_schema.TABLES WHERE table_schema = "fpkdb1"
ORDER BY (data_length + index_length) DESC;
TRUNCATE TABLE table_name;
@morad7
morad7 / remove-temp-files.txt
Created October 16, 2017 13:13
Remove temp files - Ubuntu
//Try the below command to remove temp files,
sudo rm -rf /tmp/*
apt-get autoremove //will remove automatically all unused packages.
@morad7
morad7 / form-to-file.php
Created September 27, 2017 21:18
Form to file php code
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form action=<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?> method="POST">
<input name="field1" type="text" />
<input name="field2" type="text" />
<input type="submit" name="submit" value="Save Data">
@morad7
morad7 / drupal-permessions.txt
Created January 16, 2017 16:21
Drupal permissions
# Create a new example user.
useradd -s /bin/bash -m example;
# Now add that user to the Apache group. On Ubuntu/Debian this group is usually
# called www-data, on CentOS it's usually apache.
usermod -a -G www-data example;
# Set up a password for this user.
passwd example;
)
@morad7
morad7 / delete-nodes-of-types.txt
Created December 20, 2016 20:04
Drupal: Delete all nodes of a given content type
$result= db_query("SELECT nid FROM {node} AS n WHERE n.type = 'TYPE'");
foreach ($result as $record) {
node_delete($record->nid);
}
@morad7
morad7 / install-chrome-ubuntu-16-04.txt
Created October 5, 2016 20:26
Install chrome on Ubuntu 16.04
Simple steps:
Search for and install Gdebi Package Installer from the ubuntu Software Center.
Download google chrome https://www.google.com/chrome/browser/desktop/
Right click the downloaded Google Chrome .deb file and select 'Open with' and then click 'Gdebi Package Installer'
Done! :-)
Gdebi will automatically fetch the missing dependencies for you.