Skip to content

Instantly share code, notes, and snippets.

@akgupta
akgupta / event_source_connection_actor_handling.java
Last active April 18, 2020 09:38
Use of Play’s EventSource API to accept an incoming connection in the application controller and assigning it to be managed by an Akka Actor
// Client A connects to the server and is assigned connectionIdA
public Result listen() {
return ok(EventSource.whenConnected(eventSource -> {
String connectionId = UUID.randomUUID().toString();
// construct an Akka Actor with the new EventSource connection identified by a random connection identifier
Akka.system().actorOf(
ClientConnectionActor.props(connectionId, eventSource),
connectionId);
}));
}
XLNT.getBucket('mobile.endorsements.profilepromo', 'memberId:23', function(err, bucket) {
if(bucket === 'action_promo') {
// serve view based JSON for action_promo
} else if(bucket === 'hero_promo') {
// serve view based JSON for hero_promo
} else {
// no call to action
}
}
mobile.endorsements.profilepromo
osName == "Android"
action_promo: 20%
hero_promo: 20%
control: 60%
Lix.getBucket('mobile.endorsements.profilepromo', 'memberId:23', function(err, bucket) {
if(bucket === 'action_promo') {
// serve view based JSON for action_promo
} else if(bucket === 'hero_promo') {
// serve view based JSON for hero_promo
} else {
// no call to action
}
}
{
articleContent: {
description: "Your employees are spreading the word...",
firstSharedDate: 1390140317640,
id: "7271986887870350868",
resolvedUrl: "http://www.forbes.com/...",
title: "Your Emloyees & Word-of-Mouth Marketing",
isRead: false
...
}
config: {
latencyProfiling: {
enabled: true
},
paginatedWVMP: {
enabled: false
},
premiumBranding: {
enabled: false
},
@akgupta
akgupta / abiHero.js
Last active December 16, 2015 05:29
{
vType: "hero2",
text: "See who you already know on LinkedIn",
pictureLogo: "abi_hero_1",
link: {
type: "abi"
}
}
{
vType : "hero1",
pictureUrl : "http://m3.licdn.com/news.png"
text : "Top Stories For You",
detailText : "Your Emloyees & Word-of-Mouth Marketing",
pictureLogo : "news",
link : {
type : "newsHeroCell",
resourcePath : "/li/v2/news/TOP_NEWS_TODAY",
}
X-EVAL-CONTEXT : '{\
"carrier":"AT&T",\
"orientation":"P",\
"locale":"en-us",\
"language":"en",\
"osVersion":"6.1.2",\
"model":"iphone5_1",\
"osName":"iPhone OS",\
"appId":"com.linkedin.LinkedIn",\
"clientVersion":"6.0"\
var editEnabledOnIPhone = (req.buckets['profile.mobile.edit.iphone'] === 'enabled')
&& isClient(req, 'iphone', '5.0.9', '>=');
// profile edit on android has problems on Android OS versions below 3.0 for client versions < 2.5.4
var editEnabledOnAndroid = ((req.buckets['profile.mobile.edit.android'] === 'enabled') &&
(isClient(req, 'android', '2.5.1', '>=', "3.0", ">=") ||
isClient(req, 'android', '2.5.4', '>='))) ;
var editEnabledOnTouch = (req.buckets['profile.mobile.edit'] === 'enabled') &&
isClient(req, 'touch');