Skip to content

Instantly share code, notes, and snippets.

View sdeering's full-sized avatar

Sam Deering sdeering

View GitHub Profile
curl http://localhost:4200/assets/settings/collections.json | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["data"]'
@sdeering
sdeering / generate xml sitemap using bash script and jq to fetch remote json
Last active August 9, 2019 04:34
generate xml sitemap using bash script and jq to fetch remote json
#!/bin/bash
# Bash script to generate a sitemap.xml from external json data
# Author: Sam Deering
# POSIX variable reset in case getopts has been used previously
OPTIND=1
# Initialize our own variables:
URL='http://localhost:4200/items.json'
@sdeering
sdeering / Drupal 8 Custom Block Access Plugin
Created August 28, 2019 01:48
Adds a new tab in the block settings to control the block visibility based on a custom field
<?php
namespace Drupal\slq_blocks\Plugin\Condition;
use Drupal\Core\Condition\ConditionPluginBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Provides a 'Site Theme' condition.
*
<?php
/**
* @file
* DB post-updates for blocks.
*/
use Drupal\block_content\Entity\BlockContent;
/**
/**
* Send Google analytics tracking event.
*
* @param mixed $action
* Event action.
*/
public function sendGoogleTrackingEvent($action) {
if (!$this->isProduction()) return;
$googleAnalyticsUA = 'UA-XXXXXXXX-XX';
@sdeering
sdeering / gist:9bf9bb2ea879ac760cf0dfa19621dbbb
Last active September 12, 2023 06:51
Connect to Sorare API Using PHP + GraphQL
// This script connects to Sorare API to get perform GraphQL queries using PHP
// Playground: https://api.sorare.com/federation/graphql/playground
/*
Steps:
1. Get user salt from Sorare
2. Hash password with salt
3. Get JWT token with email, password hash & aud from Sorare
4. Perform GraphQL query
*/