Skip to content

Instantly share code, notes, and snippets.

@hussainweb
hussainweb / download-zoom-recordings.py
Created November 2, 2024 16:17
Download recordings from Zoom... Only for archive use.
#!/usr/bin/env python3
from datetime import date, datetime
import json
from pathlib import Path
import os
import sys
from urllib.request import Request, urlopen, urlretrieve
@hussainweb
hussainweb / cloud-config.yaml
Created October 8, 2024 00:32
cloud-init config for a server with PHP 8.1 and MariaDB
#cloud-config
users:
- name: hw
shell: /bin/bash
sudo: ['ALL=(ALL) NOPASSWD:ALL']
ssh_import_id:
- gh:hussainweb
disable_root: true
package_update: true
package_upgrade: true
// ==UserScript==
// @name Suspend Disable-Devtool (simple approach)
// @namespace https://www.tampermonkey.net/
// @version 0.1
// @description suspend https://github.com/theajack/disable-devtool
// @author hussainweb
// @match {site}
// @icon https://www.google.com/s2/favicons?sz=64&domain=gist.github.com
// @grant none
// ==/UserScript==
@hussainweb
hussainweb / download-recordings.py
Last active June 10, 2021 17:42
Download Recordings from Zoom using a JWT token
#!/usr/bin/env python3
from datetime import date, datetime
import json
from pathlib import Path
import os
import sys
from urllib.request import Request, urlopen, urlretrieve
<?php
// in src/Form directory.
namespace Drupal\mymodule\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\system\Form\SiteInformationForm;
/**
@hussainweb
hussainweb / import-xhprof-to-xhgui.php
Last active July 15, 2021 09:49
Import XHProf runs into xhgui
<?php
// Run this as follows:
// php import-xhprof-to-xhgui.php -d /dir/to/xhprof/runs/
//
// Based on https://github.com/perftools/xhgui/blob/master/external/import.php
if (!defined('XHGUI_ROOT_DIR')) {
require __DIR__ . '/src/bootstrap.php';
}
@hussainweb
hussainweb / .gitlab-ci.yml
Created January 23, 2020 00:23
Gitlab CI DTT integration
drupal_tests:
image: hussainweb/drupal-base:php7.3
services:
- mariadb:10.3
stage: test
tags:
- autoscaler
variables:
SITE_BASE_URL: 'http://localhost'
MYSQL_DATABASE: "drupal"
@hussainweb
hussainweb / TextAdsBlock.php
Last active February 3, 2020 23:43
A Drupal 8 block plugin which needs to be shown only on node pages (using context)
<?php
namespace Drupal\my_module\Plugin\Block;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\node\NodeInterface;
use Drupal\my_module_lists\ProfilesService;
@hussainweb
hussainweb / TopicsSelection.php
Created December 12, 2019 23:43
/web/modules/custom/axl_ks_topics/src/Plugin/EntityReferenceSelection/TopicsSelection.php
<?php
namespace Drupal\axl_ks_topics\Plugin\EntityReferenceSelection;
use Drupal\Component\Utility\Html;
use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\Query\QueryInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
@hussainweb
hussainweb / clean-environments.php
Last active December 3, 2019 23:09
Find out what environments can be cleared from platform.sh
#!/usr/bin/env php
<?php
$environments = explode("\n", `platform environments --columns=title,status --format=tsv --no-header | grep -v "\tInactive" | awk "{print \\$1}"`);
$remote_branches = explode("\n", `git ls-remote --heads | awk "{ print \\$2 }" | sed 's/refs\\/heads\\///'`);
$environments = \array_diff($environments, [
"Master",
"develop",
"qa",