Skip to content

Instantly share code, notes, and snippets.

@chaffeqa
chaffeqa / all_cached_model_concern.rb
Last active April 3, 2023 16:19
ActiveSupport::Concern and Sorbet RBI solution
# typed: true
module AllCachedModelConcern
extend ActiveSupport::Concern
included do
after_save(:clear_all_cached!)
after_destroy(:clear_all_cached!)
end
@chaffeqa
chaffeqa / 2019-nfl-reg-season.json
Created October 3, 2019 12:39
CBS Pool Settings Stats
{
"combined": {
"poolCount": 31751,
"maxEntriesPerUser": {
"1": 31751
},
"spreadType": {
"STRAIGHT_UP": 21916,
"CBS_SPREAD": 9835
},
@chaffeqa
chaffeqa / site.js
Created April 7, 2018 16:00
Example usage of custom DTM setup
window._satellite.pageBottom();
var dataLayer = {};
window._satellite.setVar('dataLayer', window.dataLayer);
// apply defaults that persist throughout session:
Object.assign(dataLayer, {
eVar1: '...',
channel: '...',
heir: '...',
});
@chaffeqa
chaffeqa / custom.js
Created April 7, 2018 15:47
Adobe DTM events custom code
var id, mbatcher = /event/, val, events = [], linkTrackEvents = [], s_code = arguments[1], dataLayer = s_code.w._satellite.data.customVars.dataLayer || s_code.w._satellite.getVar('dataLayer'), log = s_code.w._satellite.Logger.echo;
for ( id in dataLayer){
val = dataLayer[id]
if (mbatcher.test(id) && val) {
log('debug',"Event detected: " + id + '=' + val);
linkTrackEvents.push(id);
events.push(id);
}
}
s_code.events = events.join(',');
# Compiled source #
###################
*.class
*.dll
*.exe
*.o
*.so
# Packages #
############
@chaffeqa
chaffeqa / example.js
Created September 21, 2016 18:07
UI Redux Global Store
import { toggleElementAction, connect } from 'common';
function Dropdown({ uid, ui, dispatch }){
return (
<button type="button"
onClick={ dispatch(toggleElementAction('dropdown', uid)) }
className={ ui.dropdown == uid ? 'dropdown--toggled' : 'dropdown' }>
Toggle Dropdown: '{uid}'
</button>
)
@chaffeqa
chaffeqa / callbacks.js
Created April 15, 2016 02:33
Candidate Questions
function meth1(){
return 1;
}
function meth2(input){
return 2 + input;
}
function result(arg1, cb){
var result = typeof(cb) == "function" && cb(arg1)
return result
}
@chaffeqa
chaffeqa / 0_reuse_code.js
Created April 8, 2016 15:03
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@chaffeqa
chaffeqa / generateRunsFor.js
Created April 7, 2016 23:25
A helper function for NCAA Bracket Challenge
var _generateRunsFor = function( entry ){
debugGroupCollapsed('_generateRunsFor');
var
picks = entry.picks
,props = DataHandler.game.props
,key = ''
,propId, i, prop, pick
,runs = [], run, runI = 0
,longestI = -1, longestRunCnt = 0
,answerWithTie
// original s_code (AppMeasurements) use:
s.pageName="leaderboard"
s.heir="ncaa:bcg:leaderboard"
s.channel="ncaa|bcg|leaderboard"
s.eVar3="men"
s.eVar4="ncaa"
// ...more eVar / prop setting
s.t()
// This would fire a pixel with ?v3="men"&v4="ncaa"&p="leaderboard" ... ect