Skip to content

Instantly share code, notes, and snippets.

@codecitizen
codecitizen / serverless.yml
Created November 22, 2018 20:42
A serverless.yml file configuring a AWS ElastiCache redis instance that is accessible by all AWS Lambda functions deployed by this serverless function.
service: my-service
provider:
name: aws
runtime: nodejs8.10
stage: ${opt:stage, 'dev'}
environment:
REDIS_HOST:
"Fn::GetAtt": [ElasticCacheCluster, RedisEndpoint.Address]
functions:
@nandorojo
nandorojo / segment-webflow.js
Created November 2, 2019 23:27
Segment.io Analytics.js usage on Webflow
// STEP 0:
// add the segment JS web snippet with your custom segment key to your header on webflow. this is found at your webflow project's dashboard -> custom code -> header.
// STEP 1:
// in the web flow editor, click any element you want to track when clicked, go to its settings, and add custom attributes that follow this pattern:
/*
~required~ you must add a data-analytics attribute
data-analytics="YOUR_EVENT_NAME_HERE"
@iDVB
iDVB / useScrollSpy.js
Created April 21, 2020 19:23
useScrollSpy similar to MUI docs https://bit.ly/3cArBBr
import { useState, useEffect, useRef, useCallback } from 'react';
import useThrottledOnScroll from './useThrottledOnScroll';
const useScrollSpy = ({ items = [], target = window } = {}) => {
const itemsWithNodeRef = useRef([]);
useEffect(() => {
itemsWithNodeRef.current = getItemsClient(items);
}, [items]);
const [activeState, setActiveState] = useState(null);