Skip to content

Instantly share code, notes, and snippets.

View N-Molham's full-sized avatar
🇦🇮

Nabeel Molham N-Molham

🇦🇮
View GitHub Profile
@N-Molham
N-Molham / git-clean-branches.php
Last active July 13, 2021 16:41
A simple PHP script that deletes a git branches that don't have a corresponding branch remotely
<?php
$branches = '';
exec( 'git branch -vv', $branches );
foreach ( $branches as $branch ) {
if ( false === strpos( $branch, ': gone]' ) ) {
continue;
}
@N-Molham
N-Molham / freelance-advising-on-more-work
Last active May 21, 2021 09:28
What to say to ask the past client for an Additional Task - Advising on more work - Credit @codeablehq
Greetings (first name),
Long time no speak.
I wanted to drop you a note to say how much I enjoyed working together on the [project] last [month/time period].
I’m running a special this month on [insert task from IDEA BANK], for all my client’s I’ve worked with previously.
I’ve found batching tasks for clients helps me perform them more efficiently and allows me to offer a discount on my normal rate for that service…
@N-Molham
N-Molham / freelance-asking-for-more-work
Last active May 21, 2021 09:29
What to say to ask the past client for an Additional Task - Asking for more work - Credit @codeablehq
Greetings [first name],
Long time no speak.
I wanted to drop you a note to say how much I enjoyed working together on the [project] last [month/time period].
I’ll be blunt... I’d really like to work with you again.
If you have any exciting projects coming up, or you’d like to outsource some work you’d prefer someone else do, I’m here and eager to support you...
@N-Molham
N-Molham / singleton.php
Last active June 1, 2020 08:05
PHP Singleton Class
<?php
/**
* Singleton class
*/
class Singular {
/**
* Singular instance holder
*
* @var self
@N-Molham
N-Molham / functions.php
Last active March 19, 2019 11:35
WordPress: Allow Gutenberg for specific user roles
<?php
add_filter( 'use_block_editor_for_post', 'my_prefix_maybe_allow_block_editor', 20, 2 );
/**
* @see https://core.trac.wordpress.org/browser/tags/5.1.1/src/wp-admin/includes/post.php#L2093
*
* @param bool $use_block_editor
* @param string $post_type
*
* @return bool
@N-Molham
N-Molham / safe-password-generator.php
Last active March 13, 2019 12:59
Generate safe password check by "Have I been Pwned API"
<?php
/**
* Generate safe password check by "Have I been Pwned API"
*
* @see https://haveibeenpwned.com/API/v2#PwnedPasswords
*/
class Safe_Password_Generator {
/**
@N-Molham
N-Molham / query.sql
Last active February 25, 2018 13:02
Query posts within 2 km radius of a specific position
SELECT ID as id, post_title as name,
( 6371 * acos( cos( radians({$lat}) )
* cos( radians( lat.meta_value ) )
* cos( radians( lng.meta_value )
- radians({$lng}) )
+ sin( radians({$lat}) )
* sin( radians( lat.meta_value ) ) )
) AS distance FROM wp_posts
JOIN wp_postmeta as lat ON ID = lat.post_id AND lat.meta_key = 'ng_lat'
JOIN wp_postmeta as lng ON ID = lng.post_id AND lng.meta_key = 'ng_lng'
Verifying my Blockstack ID is secured with the address 1HuDixFbLfE52FchHYnhsfQNEVxxtb8qZu https://explorer.blockstack.org/address/1HuDixFbLfE52FchHYnhsfQNEVxxtb8qZu
@N-Molham
N-Molham / Gruntfile.js
Last active August 16, 2017 15:21
Grunt config file example
// requires
var filesystem = require( 'fs' );
/**
* Plugin base arguments
*
* @type {Object}
*/
var plugin_args = {
path : './', // plugin directory path
@N-Molham
N-Molham / admin.js
Created June 6, 2017 09:45
Set the closest field input value to the selected file URL
// select handler
var on_file_select = function ( $button ) {
return function () {
// fetch selected file
selected_file_url = file_frame.state().get( 'selection' ).first().toJSON().url;
// set linked field input new value
$button.closest( '.acf-input' ).find( '.acf-url input[type=url]' ).val( selected_file_url ).trigger( 'change' );
};
};