Skip to content

Instantly share code, notes, and snippets.

View sdeering's full-sized avatar

Sam Deering sdeering

View GitHub Profile
@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
*/
/**
* Send Google analytics tracking event.
*
* @param mixed $action
* Event action.
*/
public function sendGoogleTrackingEvent($action) {
if (!$this->isProduction()) return;
$googleAnalyticsUA = 'UA-XXXXXXXX-XX';
<?php
/**
* @file
* DB post-updates for blocks.
*/
use Drupal\block_content\Entity\BlockContent;
/**
@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.
*
@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'
curl http://localhost:4200/assets/settings/collections.json | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["data"]'
@sdeering
sdeering / console-sass-version.json
Last active March 23, 2017 06:48
console-sass-version
{
"minimum_web_client_version": "master-1094"
}
@sdeering
sdeering / gist:4356baed3692d26ab778
Created August 11, 2014 15:14
injectorsauce with meta tag check
/**
* CSRF Token Security.
*/
(function() {
angular.module("app").config(['$httpProvider', function ($httpProvider) {
//check for token in meta tag
var csrf_token = $('meta[name=csrf-token]').attr('content');
@sdeering
sdeering / .htaccess
Created August 11, 2014 03:33
Laravel 4 with AngularJS Architecture Solution .htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect root requests
RewriteCond %{REQUEST_URI} ^/$
RewriteRule !^/ /back-end/public%{REQUEST_URI} [L]
@sdeering
sdeering / gist:11131879
Created April 21, 2014 04:01
node.js xhr with promises using q library
function _functionName(url) {
return Q.fcall(function () {
var deferred = Q.defer();
var options = {
url: url,
headers: {
'User-Agent': 'my-app'
},