Skip to content

Instantly share code, notes, and snippets.

View Dru1X's full-sized avatar

James Drew Dru1X

View GitHub Profile
@taion
taion / server.js
Last active March 11, 2024 10:20
GraphQL subscription server with Socket.IO, backed by Redis Pub/Sub
const redisClient = redis.createClient(REDIS_URL);
const listeners = Object.create(null);
function addListener(channel, listener) {
if (!listeners[channel]) {
listeners[channel] = [];
redisClient.subscribe(channel);
}
listeners[channel].push(listener);
@OlegIlyenko
OlegIlyenko / Event-stream based GraphQL subscriptions.md
Last active July 5, 2025 14:15
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.

@j42
j42 / gist:2aae5a360624ae2a43d7
Last active May 6, 2025 17:31
PHP Standalone MGRS/USNG <-> LatLng Converter (EFFICIENT)
<?php
/**
*
* Copyright (C) 2014 J42 (Julian Aceves)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
@basham
basham / css-units-best-practices.md
Last active October 26, 2025 18:37
CSS Units Best Practices

CSS units

Recommendations of unit types per media type:

Media Recommended Occasional use Infrequent use Not recommended
Screen em, rem, % px ch, ex, vw, vh, vmin, vmax cm, mm, in, pt, pc
Print em, rem, % cm, mm, in, pt, pc ch, ex px, vw, vh, vmin, vmax

Relative units

Relative units

@satsura
satsura / Doctrine.xml
Created February 26, 2013 07:54
PHPStorm Doctrine Command Line Tools
<?xml version="1.0" encoding="UTF-8"?>
<framework xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="schemas/frameworkDescriptionVersion1.1.3.xsd" name="Doctrine"
invoke="$PhpExecutable$ $ProjectFileDir$/application/doctrine-cli.php" alias="doctrine-cli" enabled="true"
version="2">
<command>
<name>help</name>
<help><![CDATA[Displays help for a command]]></help>
</command>
<command>
@digitaljhelms
digitaljhelms / gist:4287848
Last active October 30, 2025 16:39
Git/GitHub branching standards & conventions

Branching

Quick Legend

Description, Instructions, Notes
Instance Branch