Skip to content

Instantly share code, notes, and snippets.

@chiplay
chiplay / SomeView.js
Created May 14, 2014 19:17
Marionette 'Modal' Custom Region w/ Bootstrap
vent.trigger('app:modal:show', new PaymentModalView());
@chiplay
chiplay / app.js
Created May 14, 2014 19:24
Popover Custom Region w/ Bootstrap
/**
* Triggers a bootstrap popover with signin/register view
*/
vent.on('app:signin:popover', function ($parentEl, msg, fn) {
$parentEl.append('<div class="popover-region"></div>');
app.addRegions({
popover: {
selector: '.popover-region',
parentEl: $parentEl,
regionType: Marionette.Region.Popover
@chiplay
chiplay / get_color
Created May 29, 2012 16:43
Get Color by Percent
function get_color(start = "000000",end = "ffffff",percent = 50)
{
// start should always be darker
var sr = start.slice(0,2), sg = start.slice(2,2), sb = start.slice(4,2), er = end.slice(0,2), eg = end.slice(2,2), eb = end.slice(4,2);
var r = Math.ceil(((parseInt(er,16) - parseInt(sr,16))*percent)+parseInt(sr,16)), g = Math.ceil(((parseInt(eg,16) - parseInt(sg,16))*percent)+parseInt(sg,16)), b = Math.ceil(((parseInt(eb,16) - parseInt(sb,16))*percent)+parseInt(sb,16));
var hex = (r << 16) | (g << 8) | b;
return "#"+hex.toString(16);
}
@chiplay
chiplay / addthisBBInit
Created May 15, 2013 01:33
AddThis Backbone Init
initAddThis: function() {
var addthis_config =
{
data_track_clickback: true,
data_ga_property: 'UA-xxxxxxx-x',
data_ga_social : true
};
preg_match('/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex|^$/i', $_SERVER['HTTP_USER_AGENT'], $matches);
if (!$matches) {
$_SERVER['REQUEST_URI_PATH'] = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$segments = explode('/', $_SERVER['REQUEST_URI_PATH']);
}
?>
@chiplay
chiplay / maybemonad.js
Created August 13, 2013 11:37
JS Maybe Monad Patter
// from http://osteele.com/posts/2007/12/monads-on-the-cheap-i-the-maybe-monad
var locationCode = ((cartDelivery||{}).Location||{}).Code;
if (locationCode) {
var name = RF.Models.Cart.get('Delivery').Location.Name;
return name;
}
@chiplay
chiplay / app.js
Created October 24, 2013 23:53
RequireJS + Backbone + Marionette + Modules
define([
'config',
'underscore',
'backbone',
'marionette',
'vent'
],
function (config, _, Backbone, Marionette, vent) {
@chiplay
chiplay / DataExport.json
Created February 1, 2018 17:20
Data Export Sample
This file has been truncated, but you can view the full file.
[{"IndvId":5701385844686848,"UserId":5701385844686848,"SessionId":5629499534213120,"PageId":5707702298738688,"EventStart":"2018-01-31T00:00:10.786Z","EventType":"click","EventTargetText":"Read More","EventTargetSelectorTok":"html .wf%2Dactive .wf%2Dbrandongrotesque%2Di4%2Dactive .wf%2Dbrandongrotesque%2Dn1%2Dactive .wf%2Dbrandongrotesque%2Dn3%2Dactive .wf%2Dbrandongrotesque%2Dn4%2Dactive .wf%2Dbrandongrotesque%2Dn7%2Dactive .wf%2Dfreighttextpro%2Di3%2Dactive .wf%2Dfreighttextpro%2Dn3%2Dactive body div #root div .iHZvIS .sc%2DbdVaJa div .dQlMmi .sc%2DbdVaJa div .iHZvIS .jtWIOA .sc%2DbdVaJa .sc%2DhtpNat div .home__container .kPxSpc .sc%2DbdVaJa div .iHZvIS .jtWIOA .sc%2DbdVaJa .sc%2DhtpNat div .eCOwwR .recent%2Dposts .sc%2DbdVaJa div .post%2Dsummary a =href=warm%2Dcozy%2Dbaby%2Droom%2Dideas div .post%2Dsummary__bg div .post%2Dsummary__content div .post%2Dsummary__link","PageDuration":75592,"PageActiveDuration":25659,"PageUrl":"https://www.laybabylay.com/","PageRefererUrl":"https://search.yahoo.com/","PageIp":"1
@chiplay
chiplay / handler-selectize.js
Created November 1, 2013 21:17
Backbone.Stickit + Selectize.js Handler
define([
'jquery',
'backbone',
'underscore',
'backbone.stickit',
'selectize'
],
function ($, Backbone, _) {
@chiplay
chiplay / lottie_succession_animation.json
Created August 28, 2018 16:25
Success Animation (Lottie)
{
"v": "5.1.16",
"fr": 30,
"ip": 0,
"op": 131,
"w": 1920,
"h": 1080,
"nm": "Comp 1",
"ddd": 0,
"assets": [