Skip to content

Instantly share code, notes, and snippets.

View mqanneh's full-sized avatar
:octocat:
Coding

Mohammad AlQanneh mqanneh

:octocat:
Coding
View GitHub Profile
@mqanneh
mqanneh / curl-crawler.sh
Last active August 4, 2024 02:35 — forked from oliveratgithub/curl-crawler.sh
Unix Shell-Script to crawl a list of website URLs using curl
#!/bin/sh
timezone="Europe/Zurich"
# List of valid timezones: wikipedia.org/wiki/List_of_tz_database_time_zones
script="${0##*/}"
rootdir=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)
logfile="$script.log"
log="$rootdir/$logfile"
now=$(TZ=":$timezone" date)
# Uncomment 'mailto=' (remove #) to enable emailing the log upon completion
#mailto="your@email.com"
@mqanneh
mqanneh / youtube_id_regex.php
Created September 22, 2023 00:48 — forked from ghalusa/youtube_id_regex.php
Extract the YouTube Video ID from a URL in PHP
<?php
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
// http://youtu.be/dQw4w9WgXcQ
// http://www.youtube.com/embed/dQw4w9WgXcQ
// http://www.youtube.com/watch?v=dQw4w9WgXcQ
// http://www.youtube.com/?v=dQw4w9WgXcQ
// http://www.youtube.com/v/dQw4w9WgXcQ
// http://www.youtube.com/e/dQw4w9WgXcQ
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ
// Enable Devel module and go to /devel/php
$nodes = \Drupal::entityQuery("node")
->condition('created', strtotime('-30 days'), '<=')
->execute();
$storage_handler = \Drupal::entityTypeManager()->getStorage("node");
// $entities = $storage_handler->loadMultiple(); // Delete ALL nodes.
$entities = $storage_handler->loadMultiple($nodes);
$storage_handler->delete($entities);
@mqanneh
mqanneh / Inflect.php
Last active August 4, 2024 02:34 — forked from tbrianjones/Inflect.php
A PHP Class for converting English words between Singular and Plural.
<?php
// original source: http://kuwamoto.org/2007/12/17/improved-pluralizing-in-php-actionscript-and-ror/
/*
The MIT License (MIT)
Copyright (c) 2015
@mqanneh
mqanneh / nicaragua.module
Created February 23, 2021 02:49 — forked from dinarcon/nicaragua.module
Conditional fields in Paragraphs using the Javascript States API for Drupal 8
/**
* @file
* Example code from http://agaric.com/blogs/conditional-fields-paragraphs-using-javascript-states-api-drupal-8.
*/
/**
* Implements hook_field_widget_WIDGET_TYPE_form_alter().
*
* Example of conditional fields in paragraphs for Drupal 8.
*/
@mqanneh
mqanneh / fn_str_random_lipsum.sql
Created December 3, 2020 21:04 — forked from zackad/fn_str_random_lipsum.sql
Function to generate random text of lorem ipsum in MySQL.
/**
* ALL CREDIT GOES TO ORIGINAL CREATOR
* @Ronald Speelman
* http://moinne.com/blog/ronald/mysql/mysql-lorum-ipsum-generator
*
* renamed function for simplicity
*/
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES';
@mqanneh
mqanneh / README.md
Created September 2, 2019 15:51 — forked from magnetikonline/README.md
List all Git repository objects by size.

List all Git repository objects by size

Summary

Bash script to:

  • Iterate all commits made within a Git repository.
  • List every object at each commit.
@mqanneh
mqanneh / drupal-views-share-global-text-field
Created April 12, 2019 11:12 — forked from chrisl8888/drupal-views-share-global-text-field
share url's for facebook, twitter, pinterest with just get variables
<ul>
<li class="share-text">Share this>/li>
<li class="share-tw"><a href="http://twitter.com/share?text=[title]"><span></span></a></li>
<li class="share-fb"><a href="http://www.facebook.com/sharer.php?u=/node/[nid]&p=[title]"><span></span></a></li>
<li class="share-pinterest"><a href="http://pinterest.com/pin/create/button/?url=/node/[nid]&description=[title]"><span></span></a></li>
</ul>
@mqanneh
mqanneh / README.md
Created March 19, 2019 22:24 — forked from jgoodall/README.md
Download flag css and convert to 3 char country codes

Download SVG country flags and css, then convert the codes from the iso 3166 two character codes to three character codes.

Usage

./get_flags.sh

Then copy the flag-icon.css file into public/css and the flags directory to public/.

@mqanneh
mqanneh / nodes of taxonomy.php
Created November 30, 2018 18:12 — forked from midnai/nodes of taxonomy.php
get nodes of taxonomy term(s) in drupal 8
function getNodesByTaxonomyTermIds($termIds){
$termIds = (array) $termIds;
if(empty($termIds)){
return NULL;
}
$query = \Drupal::database()->select('taxonomy_index', 'ti');
$query->fields('ti', array('nid'));
$query->condition('ti.tid', $termIds, 'IN');
$query->distinct(TRUE);