Skip to content

Instantly share code, notes, and snippets.


Stephen Bussey sb8244

View GitHub Profile
sb8244 / chartkick.ex
Created May 16, 2021
This allows chartkick to be embedded in LiveViews
View chartkick.ex
defmodule Chartkick do
@moduledoc """
Adapted from to work with LiveView.
Works in conjunction with Phoenix LiveView hooks to render charts using Chartkick.js library.
require EEx
gen_chart_fn = fn chart_type ->
sb8244 / sso.json
Last active Jun 7, 2021
Clove SSO schema
View sso.json
"user": {
"id": "(Required) String: The ID of the user logging into Clove",
"email": "String: The email address of the user",
"name": "String: Full name of the user",
"given_name": "String: First name of the user",
"family_name": "String: Last name of the user",
"custom_data": "Map: Arbitrary data container for your application",
"organization": {
"id": "(Required if organization key present) String: The ID of the organization this user belongs to",
View embed.html
<!-- Note: un-minified source code available at clove-embed.js -->
<script type="text/javascript" src=""></script>
<script type="text/javascript">
View head.html
<script type="text/javascript">
if ( !== window.self) {
const msg = {
urlChange: {
pathname: window.location.pathname,
href: window.location.href
View intercom.html
{% if user %}
window.intercomSettings = {
app_id: "YOUR_APP_ID",
user_id: "{{ }}",
email: "{{ }}",
user_hash: "{{ | encrypt: "hmac", "YOUR_IDENTITY_VERIFICATION_SECRET" }}"
{% else %}
View fun_with_router.ex
defmodule TestRouter do
def build(routes) do
contents =
quote do
use Plug.Router
plug :match
plug :dispatch, fn %{match: match, assign: assign} ->
View contentful-import.json
"contentTypes": [
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "hq8sy8wk8n0y"
View troll.ex
defmodule SteveTrollsElixir.Private do
defmacro __using__(_) do
quote do
import unquote(__MODULE__)
@on_definition {unquote(__MODULE__), :on_priv_def}
defmacro private() do
quote do
View PushExClient.js
import { Pushex } from 'pushex'
import { getToken } from './tokenService'
const pushexOptions = {
getParams: () => getToken().then(({ token }) => Promise.resolve({ token })),
onConnectionError: pushex => {
sb8244 / cluster_loader_balancer.ex
Created Jul 30, 2019
ClusterLoadBalancer for balancing anything (WebSocket) across a cluster
View cluster_loader_balancer.ex
# We use this ClusterLoadBalancer to prevent hot nodes in our load balanced setup.
# The WebSockets are provided by Phoenix through the PushEx application
# The load balancer's `Worker` module is where the bulk of the cluster orchestration happens, using pg2 for cross node communication
defmodule ClusterLoadBalancer.Behavior do
@moduledoc """
Behavior for implementing a ClusterLoadBalancer compatible tool.
@callback count() :: number