Skip to content

Instantly share code, notes, and snippets.

@hussainweb
hussainweb / ssh-agent-on-cygwin.sh
Created June 12, 2015 16:22
Bash Profile script to setup ssh agent so that operations such as ssh and git don't ask for a password to decrypt public keys every time.
# Paste in ~/.bash_profile
#
# Load ssh-agent. Taken from
# http://blog.killtheradio.net/how-tos/ssh-agent-on-cygwin/
SSHAGENT=/usr/bin/ssh-agent
SSHAGENTARGS="-s"
if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then
eval `$SSHAGENT $SSHAGENTARGS`
trap "kill $SSH_AGENT_PID" 0
fi
@hussainweb
hussainweb / html.inc
Created May 23, 2016 14:01
HTML parsing support (primarily for Drupal migrate framework, but could be used generally)
<?php
/**
* @file
* HTML parsing support.
*/
class MigrateHtmlParser {
protected $html;
@hussainweb
hussainweb / XhprofMiddleware.php
Created November 23, 2016 05:20
This Laravel middleware allows developers to profile specific requests by appending `xhprof=true` to any query.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use XHProfRuns_Default;
/**
* Class XhprofMiddleware.
*
@hussainweb
hussainweb / composer.json
Created October 15, 2017 10:31
Drupal 7 composer.json created with hussainweb/drupal-composer-init
{
"name": "hw/drupal-composer",
"description": "My awesome Drupal 7 site",
"type": "project",
"require": {
"php": ">=5.2.5",
"ext-gd": "*",
"ext-xml": "*",
"ext-json": "*",
"ext-openssl": "*",
@hussainweb
hussainweb / composer.json
Created October 15, 2017 10:32
Drupal 8 composer.json created with hussainweb/drupal-composer-init
{
"name": "hw/drupal-composer",
"type": "project",
"require": {
"cweagans/composer-patches": "^1.6.0",
"hussainweb/drupal-composer-helper": "^1.0",
"drupal/core": "^8.4",
"drupal/console": "^1.0.1",
"drush/drush": "~8.0|^9.0",
"drupal/redirect": "^1.0@beta",
@hussainweb
hussainweb / TextAdsBlock.php
Last active September 28, 2018 07:23
A Drupal 8 block plugin which needs to be shown only on node pages (using route matcher)
<?php
namespace Drupal\my_module\Plugin\Block;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountInterface;
@hussainweb
hussainweb / main.js
Created December 12, 2018 18:43
Get a few statistics about episode duration on syntax.fm
const fs = require('fs');
const rssParser = require('rss-parser');
const stats = require("stats-lite");
(async () => {
const parser = new rssParser();
const feed = await parser.parseURL('https://feed.syntax.fm/rss');
// Or you can download the file manually with wget, like so:
// wget -O rss.rss https://feed.syntax.fm/rss

Keybase proof

I hereby claim:

  • I am hussainweb on github.
  • I am hussainweb (https://keybase.io/hussainweb) on keybase.
  • I have a public key whose fingerprint is 810B 0D86 29F3 A550 98AF 3015 E1CE 9844 7E2C 7887

To claim this, I am signing this object:

@hussainweb
hussainweb / .gitlab-ci.yml
Last active November 21, 2019 13:54
Gitlab CI definition for platform.sh deployment
stages:
- build
- test
- deploy
platformsh:
image: axelerant/platformsh-cli:latest
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
@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",