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
@ichim-david
ichim-david / gulp-cjs-to-esm.md
Created July 27, 2022 18:18 — forked from noraj/gulp-cjs-to-esm.md
Moving gulpfile from CommonJS (CJS) to ECMAScript Modules (ESM)

Moving gulpfile from CommonJS (CJS) to ECMAScript Modules (ESM)

Context

del v7.0.0 moved to pure ESM (no dual support), which forced me to move my gulpfile to ESM to be able to continue to use del.

The author sindresorhus maintains a lot of npm packages and does not want to provides an upgrade guide for each package so he provided a generic guide. But this guide is a bit vague because it's generic and not helping for gulp, hence this guide.

Guide

@sindresorhus
sindresorhus / esm-package.md
Last active May 6, 2024 13:26
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@joshuabaker
joshuabaker / languages.json
Last active April 30, 2024 17:07
List of languages with ISO 639-1 Alpha-2 codes in JSON.
[
{
"code": "aa",
"name": "Afar",
"native": "Afar"
},
{
"code": "ab",
"name": "Abkhazian",
"native": "Аҧсуа"
@ivankristianto
ivankristianto / devDependencies.js
Created March 4, 2020 08:02
Webpack Config in WordPress
"devDependencies": {
"@babel/cli": "^7.5.0",
"@babel/core": "^7.5.4",
"@babel/plugin-syntax-dynamic-import": "^7.2",
"@babel/plugin-transform-runtime": "^7.6.0",
"@babel/polyfill": "^7.6.0",
"@babel/preset-env": "^7.6.0",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.4.4",
"@babel/traverse": "^7.5.5",
@ozknozsrt
ozknozsrt / app.js
Last active January 16, 2024 16:48 — forked from itzikbenh/app.js
WordPress API - how to fetch and paginate posts with Vue.js
import Vue from 'vue';
import posts from './components/posts.vue';
window.axios = require('axios');
window.Vue = Vue;
Vue.component('posts', posts);
const app = new Vue({
el: '#app',
@amirmojiry
amirmojiry / Convert like-Persian characters to Persian characters
Last active June 11, 2023 09:20
A PHP function for convert like-Persian characters to Persian characters
<?php
function convert_non_persian_chars_to_persian ($str) {
//main goal: arabic chars: from ؀ U+0600 (&#1536;) to ۿ U+06FF (&#1791;)
//source: https://unicode-table.com/en
$right_chars = array (
'ا',
'ب',
'پ',
'ت',
'ث',
@theodorejb
theodorejb / convert_array_access_braces.php
Last active March 27, 2024 18:22
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',