Skip to content

Instantly share code, notes, and snippets.

View geminorum's full-sized avatar
🏠
Working from home

Nasser Rafie geminorum

🏠
Working from home
View GitHub Profile
@theodorejb
theodorejb / convert_array_access_braces.php
Last active August 12, 2024 05:07
Migrate deprecated curly brace array access syntax to bracket syntax. Requires PHP 7.4.
<?php
error_reporting(E_ALL);
$opts = getopt('f:d:rb:', ['ext:', 'php:', 'diff::']);
if ((int)isset($opts['d']) + (int)isset($opts['f']) !== 1) {
$self = basename(__FILE__);
echo <<<EOF
Usage:
php $self -f<php_script> [-b] [--php <path_to_php>] [ --diff [<file>]]
@rmpel
rmpel / wp-499-up-fix-csv-upload.php
Last active January 2, 2022 15:01
A filter (an mu-plugin) to restore CSV upload functionality to WordPress 4.9.9 and up.
<?php
/**
* Restore CSV upload functionality for WordPress 4.9.9 and up
*/
add_filter('wp_check_filetype_and_ext', function($values, $file, $filename, $mimes) {
if ( extension_loaded( 'fileinfo' ) ) {
// with the php-extension, a CSV file is issues type text/plain so we fix that back to
// text/csv by trusting the file extension.
$finfo = finfo_open( FILEINFO_MIME_TYPE );
$real_mime = finfo_file( $finfo, $file );
@man4toman
man4toman / blob2utf8.sql
Created October 16, 2018 13:12
Convert blob strings to utf8
#Note: This commands convert pure blob strings to utf8, if you use this commands on mixed strings, they didn't works as expected
alter table sending_info change message message LONGTEXT CHARACTER SET latin1;
alter table sending_info change message message LONGBLOB;
alter table sending_info change message message LONGTEXT CHARACTER SET utf8;
@man4toman
man4toman / utf-correction.php
Last active July 31, 2019 08:47
Mixed encoding and make everything UTF-8
<?php
/*
* @exampple: echo utf_correction('محتوای میکس شده و بخش سالم');
* @link: https://stackoverflow.com/questions/48948340/mixed-encoding-and-make-everything-utf-8
**/
function utf_correction(''){
$str_hex = bin2hex($str);
$str = hex2bin($str_hex);
$fixed = preg_replace_callback(
'/\\P{Arabic}+/u',
@gaearon
gaearon / modern_js.md
Last active April 14, 2025 19:22
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav
@mattez
mattez / bootstrap-4-sass-mixins-cheat-sheet.scss
Last active November 29, 2019 06:15
Bootstrap 4 Sass Mixins [Cheat sheet with examples] #BS4
/* -------------------------------------------------------------------------- */
// All Bootstrap 4 Sass Mixins [Cheat sheet]
// @author http://anschaef.de
// @see https://github.com/twbs/bootstrap/tree/v4-dev/scss/mixins
/* -------------------------------------------------------------------------- */
// Grid variables
$grid-columns: 12 !default;
$grid-gutter-width: 30px !default;
@kylekatarnls
kylekatarnls / roadmap.md
Last active March 8, 2019 13:13
Carbon 2 proposal

Carbon 2 (Draft)

Complete set of PHP Date classes extensions:

class extends comment
Carbon DateTime
CarbonImmutable DateTimeImmutable new
CarbonInterface DateTimeInterface new
CarbonTimeZone DateTimeZone new

The PATH is an important concept when working on the command line. It's a list of directories that tell your operating system where to look for programs, so that you can just write script instead of /home/me/bin/script or C:\Users\Me\bin\script. But different operating systems have different ways to add a new directory to it:

Windows

  1. The first step depends which version of Windows you're using:
  • If you're using Windows 8 or 10, press the Windows key, then search for and
@treehousetim
treehousetim / TextTable.php
Last active April 18, 2019 21:04 — forked from dapepe/TextTable.php
Class to generate a Markdown-style table from a PHP array
<?php
//https://gist.github.com/dapepe/9956717
/**
* Creates a markdown document based on the parsed documentation
*
* @author Peter-Christoph Haider <[email protected]>
* @package Apidoc
* @version 1.00 (2014-04-04)
* @license GNU Lesser Public License
*/