Skip to content

Instantly share code, notes, and snippets.

@circAssimilate
circAssimilate / Optimizely Poll For Delayed Content
Last active February 29, 2016 19:10
The pollForDelayedContent() helper function is an alternative solution to some of the approaches listed here: https://help.optimizely.com/hc/en-us/articles/200457495. Look below for more info.
/**
* OPTIMIZELY POLL FOR DELAYED CONTENT:
*
* The pollForDelayedContent() helper function is an alternative solution to some of the approaches listed here: https://help.optimizely.com/hc/en-us/articles/200457495.
* It will be able to be used as many times as it's needed within an experiment or variation. When the Optimizely snippet is implemented correctly, it should provide a way to eliminate all content flashing.
* The function allows for a an "options" element, to allow for more flexibility as well.
* Feel free to file a ticket at optimizely.com/support with any feedback or questions - as the comments on this page will not be responded to.
*
* SIMPLE USAGE EXAMPLE: this does not use the optional options object to specify selectorToHide, timeoutInSeconds, or intervalInMilliseconds, causing them to default to hide the no timeout and 50 milliseconds.
*
@circAssimilate
circAssimilate / pollForDelayedContent_v2.js
Last active October 14, 2016 22:28
The pollForDelayedContent() v2 helper function (with Truthy option) is an alternative solution to some of the approaches listed here: https://help.optimizely.com/hc/en-us/articles/200457495. Look below for more info.
/*
* OPTIMIZELY POLL FOR DELAYED CONTENT v2 (with Truthy option):
*
* The pollForDelayedContent() helper function is an alternative solution to some of the approaches listed here: https://help.optimizely.com/hc/en-us/articles/200457495.
* It will be able to be used as many times as it's needed within an experiment or variation. When the Optimizely snippet is implemented correctly, it should provide a way to eliminate all content flashing.
* The function allows for a an "options" element, to allow for more flexibility as well.
* Feel free to file a ticket at optimizely.com/support with any feedback or questions - as the comments on this page will not be responded to.
*
* SIMPLE USAGE EXAMPLE: this does not use the optional options object to specify selectorToHide, timeoutInSeconds, or intervalInMilliseconds, causing them to default to hide the no timeout and 50 milliseconds.
*
@circAssimilate
circAssimilate / sort_by_immutable_key.js
Created November 14, 2017 00:00
Sort by Immutable JS Key
/**
* sortByImmutableKey: sort given an Immutable List, key, and ascending/descending
*
*
* @param immutableList(Immutable.List)
* @param sortKey(string)
* @param ascending(boolean)
*/
export const sortByImmutableKey(immutableList, sortKey, ascending=false) {
if (__DEV__ && typeof immutableList === 'undefined') {
// SECRETS!! ACTUAL VALUES SHOULD BE OMMITTED FROM GIST
var ACCOUNT_PASSWORD = 'SECRET';
var ACCOUNT_API_TOKEN = 'SECRET';
/**
* Gist link: https://gist.github.com/circAssimilate/31d7ea6a24a22532b50fcd2b6af2ffb3
*
* OWNERS:
* - derek@optimizely.com
* - siddhartha.kakarla@optimizely.com
@circAssimilate
circAssimilate / formik.js
Created July 10, 2020 21:00
Two options for Formik method additions based off of existing Formik code
function deleteField(obj: any, path: string) {
let res = clone(obj); // this keeps inheritance when obj is a class
let resVal = res;
let i = 0;
let pathArray = toPath(path);
for (; i < pathArray.length - 1; i++) {
var currentPath = pathArray[i];
let currentObj = get(obj, pathArray.slice(0, i + 1));
@circAssimilate
circAssimilate / page_component.js
Last active September 21, 2020 21:13
Used to develop for Full Stack Metrics and Events Component at p13n/sections/manager_fullstack/pages/metrics/page_component.js
/**
* ATTN: This file will NOT be merged. It's just for manually testing this via the existing Full Stack Experiment manager
*/
import React from 'react';
import PropTypes from 'prop-types';
import { Button, Container, Row, Col, EmptyDashboard } from 'optimizely-oui';
import ui from 'core/ui';
import Immutable, { toImmutable, toJS } from 'optly/immutable';
@circAssimilate
circAssimilate / cloudSettings
Last active January 22, 2021 19:57
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-01-22T19:56:55.940Z","extensionVersion":"v3.4.3"}
/**
* @see https://stackoverflow.com/questions/14962018/detecting-and-fixing-circular-references-in-javascript
*/
export function isCyclic(obj: Record<string, unknown>): boolean {
const seenObjects: unknown[] = [];
function detect(objToDetect: unknown) {
if (objToDetect && typeof objToDetect === 'object') {
if (seenObjects.includes(objToDetect)) {
return true;
}
@circAssimilate
circAssimilate / context-utils-with-use-selectors.ts
Created August 12, 2021 23:20
Context Utils With Use Selectors
/* eslint-disable @typescript-eslint/no-explicit-any */
import {
Context,
createContext,
useContextSelector,
} from '@fluentui/react-context-selector';
type CreateNamedContextReturn<T> = [
Provider: React.Provider<T>,
useContext: <V = T>() => V,
@circAssimilate
circAssimilate / VS Codeish.idekeybindings
Created January 19, 2022 05:55
~/Library/Developer/Xcode/UserData/KeyBindings/VS\ Codeish.idekeybindings
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Menu Key Bindings</key>
<dict>
<key>Key Bindings</key>
<array>
<dict>
<key>Action</key>