Skip to content

Instantly share code, notes, and snippets.

View scottmessinger's full-sized avatar

Scott Ames-Messinger scottmessinger

View GitHub Profile
@kamilogorek
kamilogorek / _screenshot.md
Last active May 2, 2024 13:48
Clutter-free VS Code Setup
image
@caspg
caspg / 1_searchbar_live.ex
Last active May 2, 2024 12:40
Example of real-time search bar implementation in Phoenix LiveView and Tailwind. Working example on https://travelermap.net/parks/usa
defmodule TravelerWeb.SearchbarLive do
use TravelerWeb, :live_view
alias Phoenix.LiveView.JS
alias Traveler.Places
def mount(_params, _session, socket) do
socket = assign(socket, places: [])
{:ok, socket, layout: false}
end
@brentjanderson
brentjanderson / README.md
Created June 14, 2022 15:53
Elixir runtime-controlled supervision tree using feature flags (circuit breaker)

These snippets provide a foundation for starting and stopping supervision trees at runtime using feature flags (e.g. Launch Darkly).

Some things to note when adapting these snippets:

  1. application.ex needs to be adapted into an existing application. The important part is that each child spec provided is compliant, and that there is a feature flag (ld_key) specified.
  2. As written, if a feature flag fails for some reason, it defaults to starting all children. There is room for adaptation here as needed.
  3. This implementation will still require a FeatureFlags module to be available that implements is_on?/2. Adjust as needed to accomodate your own feature flag setup.
@jackcoldrick90
jackcoldrick90 / associateContactToCompany.js
Last active March 27, 2024 08:28
This custom code snippet can be used to associate a contact to a company based on the company name property that is stored at a contact level. It's particularly useful if your customers are using a freemail address and aren't supplying a company website - just the name of their company. If no company is found a new record will be created in the …
// Import the Hubspot NodeJS Client Library - this will allow us to use the HubSpot APIs
const hubspot = require('@hubspot/api-client');
/*
This function is called when the custom code action is executed. It takes 2 arguements. The first is the event object which contains information on the currently enrolled object.
The second is the callback function which is used to pass data back to the workflow.
*/
exports.main = (event, callback) => {
// Instantiate a new HubSpot API client using the HAPI key (secret)
@krisselden
krisselden / webpack.config.js
Last active March 31, 2021 03:14
Embroider App Webpack Dev Server Config
/* eslint-env node */
const { Webpack } = require("@embroider/webpack");
const variant = {
name: "dev",
runtime: "browser",
optimizeForProduction: false,
};
const webpack = new Webpack(
__dirname,
__dirname + "/dist",
@pichfl
pichfl / example.hbs
Last active October 4, 2022 19:01
Media query helper for Ember.js
{{#if (match-media "(max-width:800px)")}}
MediaQuery matches
{{ else}}
MediaQuery doesn't match
{{/if}}
@lifeart
lifeart / StateManager.js
Last active March 19, 2021 07:19
state manager, based on ember-concurrency
import {
timeout,
task
} from 'ember-concurrency';
export class StateManager {
constructor() {
this.startExecution();
}
// UPDATE: don't use this. when it re-partitions the list when time moves forward, it does not correctly keep hashes
// Use a real merkle tree instead: https://gist.github.com/jlongster/f431b6d75ef29c1a2ed000715aef9c8c
import Timestamp from './timestamp';
// This is a compact data structure that keeps track of a list of
// hashes (representing messages) over a range of time in order to
// figure out what has changed between clients, kinda like a Merkle
// tree. It creates "buckets" that represent different time ranges,
// and divides time into smaller buckets the more recent they are. The
@developit
developit / hydra-alias.md
Last active February 27, 2020 01:54
Alias to invoke Chrome Canary w/ tracing, for IRHydra

An Alias to run Chrome with tracing enabled

For Chrome Canary:

alias hydra='/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary --no-sandbox --js-flags="--user-data-dir=/tmp/profile --trace-hydrogen --trace-phase=Z --trace-deopt --code-comments --hydrogen-track-positions --redirect-code-traces"'

For regular ol' Chrome:

@mrezentes
mrezentes / MapMaker.md
Last active March 1, 2024 12:35
Convert a nested struct to a map

Problem: Convert nested structs or nested encoded maps into a decoded map and remove keys with nil values.

Solution: Walk the structure and convert all structures to decoded map.

Before (nested struct):

%TopLevelStuct{
      _type: "Purchase",
      account_key: "ZBmrcY7sv47nCaZOx5TXBTJuazy"