Skip to content

Instantly share code, notes, and snippets.

View phylliswong's full-sized avatar
💭
coding 👩🏻‍💻

Phyllis Wong phylliswong

💭
coding 👩🏻‍💻
  • San Francisco Bay Area
View GitHub Profile
/*
Running Variants locally without the editor
Authored by Richard Cowin
Disable content security policy with Resource Override
This will allow for local host
window.applyVariants(‘http://localhost:8000/t-and-c/’, [‘v1’]);
*/
window.applyVariants = function applyVariants(folder, variants, poll) {
@phylliswong
phylliswong / auth.js
Last active February 24, 2022 05:25
MP-demo-audience
module.exports = function () {
var section = $('.warranty-cta');
if (section) {
evolv.context.update({ service_section: "true" });
};
};
@phylliswong
phylliswong / eventEmit.js
Last active February 2, 2022 14:42
FragranceX Event Emit
function sendEvent(tag, url){
try {
window.evolv.client.emit(tag);
} catch (e) {
console.log(e);
}
}
function pageMatch(page) {
@phylliswong
phylliswong / index.js
Last active April 14, 2021 21:43
TruGreen GA Integration
module.exports = function () {
var Evolv=function(t){"use strict";var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,i)};function i(t,i){function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var n=function(){function t(t){void 0===t&&(t=5e3),this.maxWaitTime=t,this.queue=[],this.interval=50,this.activeCandidateEvents={confirmed:{},contaminated:{}},this.contaminations={},this.waitForAnalytics(),this.waitForEvolv(this.configureListeners.bind(this))}return t.prototype.configureListeners=function(){var t=this;window.evolv.client.on("confirmed",(function(e){t.sendMetricsForActiveCandidates(e)})),window.evolv.client.on("contaminated",(function(e){t.sendMetricsForActiveCandidates(e)})),window.evolv.client.on("event.emitted",(function(e,i){t.sendMetrics(i,{uid:window.evolv.context.uid})}))},t.prototype.sendMetricsForActiveCandidates=f
@phylliswong
phylliswong / index.js
Last active April 14, 2021 00:18
TruGreen Click to Call
module.exports = function() {
var url = window.location.href;
var nodes = document.querySelectorAll('[href^="tel"]');
var callBtns = Array.prototype.slice.call(nodes);
callBtns.forEach(function(btn) {
btn.addEventListener('click', function() {
evolv.client.emit('tap_to_call.clicked');
})
})
module.exports = function() {
var authenticated = window.localStorage.getItem('auth_token');
if (authenticated){
evolv.context.update({'auth':'true'})
} else {
evolv.context.update({'auth':'false'})
}
};
public func get<T>(key: String, defaultValue: T) -> Any {
let group = DispatchGroup()
var allocations = [JSON]()
var value = [JSON]()
if (futureAllocations == nil) { return defaultValue }
// This needs to be a blocking operation
let _ = self.futureAllocations?.done { (jsonArray) in
allocations = jsonArray
import Foundation
public class LRUCache<KeyType: Hashable> {
private let maxSize: Int
private var cache: [KeyType: Any] = [:]
private var priority: LinkedList<KeyType> = LinkedList<KeyType>()
private var key2node: [KeyType: LinkedList<KeyType>.LinkedListNode<KeyType>] = [:]
public init(_ maxSize: Int) {
self.maxSize = maxSize
<script>
// app ID
var intercomSettings = {
app_id: "r0j5pbsv"
};
// Verifies and cleans all GTM variables
function pushGTMVariablesToIntercom(gtmKey, gtmValue) {
if(gtmValue != null && gtmValue != "" && gtmValue != "undefined") {
if(typeof gtmValue == "string") {
@phylliswong
phylliswong / shopsTableView.swift
Created February 8, 2019 20:46
shopsTableview
extension ShopsViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let selectedShop = fetchedResultsController.object(at: indexPath)
let st = UIStoryboardname: "Main", bundle: Bundle.main)
let vc = st.instantiateViewController(withIdentifier: "EmployeeViewController") as! EmployeeViewController
vc.shop = selectedShop
self.navigationController?.pushViewController(vc, animated: true)
}