Skip to content

Instantly share code, notes, and snippets.

View HeyMehedi's full-sized avatar

Mehedi Hasan ⚡️ HeyMehedi

View GitHub Profile
@HeyMehedi
HeyMehedi / settings.json
Created November 21, 2022 01:22
Basic WordPress Settings for VSCode
{
"code-runner.saveFileBeforeRun": true,
"workbench.colorTheme": "One Dark Pro",
"editor.fontSize": 16,
"phpfmt.psr2": false,
"phpfmt.passes": [
"PSR2KeywordsLowerCase",
"PSR2LnAfterNamespace",
"PSR2ModifierVisibilityStaticOrder",
"ReindentSwitchBlocks",
@HeyMehedi
HeyMehedi / extract.php
Last active November 20, 2022 14:08
Email Files Directory to Email List for PHP
<?php
$dir = __DIR__ . '/emails';
$emails = scandir( $dir );
$output = fopen( 'output.csv', 'w' );
function extract_email( $text ) {
//String that recognizes an e-mail
$str = '/([a-z0-9_\.\-])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i';
preg_match_all( $str, $text, $out );
//return a blank array if not true otherwise insert the email in $out and return

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

@HeyMehedi
HeyMehedi / node_nginx_ssl.md
Created December 1, 2021 13:49 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

function remove_class_action ($action,$class,$method) {
global $wp_filter ;
if (isset($wp_filter[$action])) {
$len = strlen($method) ;
foreach ($wp_filter[$action] as $pri => $actions) {
foreach ($actions as $name => $def) {
if (substr($name,-$len) == $method) {
if (is_array($def['function'])) {
if (get_class($def['function'][0]) == $class) {
if (is_object($wp_filter[$action]) && isset($wp_filter[$action]->callbacks)) {
@HeyMehedi
HeyMehedi / Determine a post or page build with Elementor
Last active August 5, 2021 03:35
Determine a post or page build with Elementor
if ( \Elementor\Plugin::$instance->documents->get( get_the_ID() )->is_built_with_elementor() ) {
return false;
}
@HeyMehedi
HeyMehedi / admin-ssl-vesta.sh
Created June 22, 2020 14:47 — forked from hasinhayder/admin-ssl-vesta.sh
Install Admin Panel SSL Cert for VestaCP using LetsEncrypt
v-change-sys-hostname somedomain.com
v-add-letsencrypt-domain 'admin' $HOSTNAME '' 'yes'
v-update-host-certificate admin $HOSTNAME
echo "UPDATE_HOSTNAME_SSL='yes'" >> /usr/local/vesta/conf/vesta.conf
@HeyMehedi
HeyMehedi / Auto Play
Created October 25, 2019 16:21
Onload Audio Play
<iframe style="display: none;" src="HERE put URL of silence mp3"></iframe>
<audio id="myaudio" autoplay="autoplay" loop="loop" controls="controls">
<source src="HERE put URL of your background music" type="audio/mp3" />
</audio>
<script>
var audio = document.getElementById("myaudio");
audio.volume = 0.2;
</script>
function replace_texXt($text) {
$text = str_replace('goalkeeper', 'Portieri', $text);
$text = str_replace('defender', 'Difensori', $text);
$text = str_replace('midfielder', 'Centrocampisti', $text);
$text = str_replace('forward', 'Attaccanti', $text);
return $text;
}
add_filter('the_content', 'replace_texXt');