Skip to content

Instantly share code, notes, and snippets.

View ssimeonov's full-sized avatar

Simeon Simeonov ssimeonov

View GitHub Profile
@ssimeonov
ssimeonov / google_ad_delivery.html
Created April 17, 2013 05:02
Anatomy of an online ad: Google/DoubleClick ad delivery
<!-- Template Id = 13,901 Template Name = Banner Creative (Flash) - In Page Multiples - [DFA] -->
<!-- Copyright 2006 DoubleClick Inc., All rights reserved. -->
<!-- Utilities for using Flash -->
<script src="http://s0.2mdn.net/879366/flashwrite_1_2.js">
</script>
<!-- Script to active Flash ad unit -->
<SCRIPT LANGUAGE="JavaScript">
<!--
@ssimeonov
ssimeonov / google_ad_delivery_script.js
Created April 17, 2013 04:06
Anatomy of an online ad: Google ad delivery script
document.write('\x3c!-- Template Id \x3d 13,901 Template Name \x3d Banner Creative (Flash) - In Page Multiples - [DFA] --\x3e\n\x3c!-- Copyright 2006 DoubleClick Inc., All rights reserved. --\x3e\x3cscript src\x3d\x22http://s0.2mdn.net/879366/flashwrite_1_2.js\x22\x3e\x3c/script\x3e\n\x3cSCRIPT LANGUAGE\x3d\x22JavaScript\x22\x3e\n\x3c!--\nfunction DCFlash(id,pVM){\nvar swf \x3d \x22http://s0.2mdn.net/877848/CLB012__Hiking_728x90.swf\x22;\nvar gif \x3d \x22http://s0.2mdn.net/877848/Celebrex_728x90_Unbranded_Backup.3.11.13_1.gif\x22;\nvar minV \x3d 8;\nvar FWH \x3d \x27 width\x3d\x22728\x22 height\x3d\x2290\x22 \x27;\nvar url \x3d escape(\x22http://adclick.g.doubleclick.net/aclk?sa\x3dL\x26ai\x3dBkkTr1ABuUYnfKOz56AHh_4HQCbOj0YsDAAAAEAEgADgAUIC6g9b______wFYs4bGy0xgyYb2iISk7A-CARdjYS1wdWItNjc2MDQyMjg4NTEzMDEyMrIBGHd3dy5kY2xrLWRlZmF1bHQtcmVmLmNvbboBCWdmcF9pbWFnZcgBCdoBIGh0dHA6Ly93d3cuZGNsay1kZWZhdWx0LXJlZi5jb20vmAKIpAHAAgLgAgDqAi00Nzg4L2huLnVzLmhtbnloLmRpci54LngueC9DZWxlYnJleF9BcnRocml0aXP4AoHSHpAD4AOYA-ADqAMB4AQ
@ssimeonov
ssimeonov / yahoo_ad_delivery_script.js
Created April 17, 2013 02:52
Anatomy of an online ad: ad delivery script
// This sets up AdChoice notice
document.write("<style type=\"text/css\">\n");
// AdChoice image: http://s.yimg.com/hl/a/optimized/adchoice_1.png
document.write(".can_ad_slug {font-family:arial;font-size:11px;color:#999;text-decoration:none;background-image:url(\'http://s.yimg.com/hl/a/optimized/adchoice_1.png\');background-repeat:no-repeat;background-position:right;padding:0px 14px 0px 1px !important;margin:1px 0px 1px 0;cursor:hand;height:12px;display:block;line-height:12px;}\n");
document.write(".ad_slug_table a {text-decoration:none;}\n");
document.write(".ad_slug_table div.CAN_marker { display:none }\n");
document.write("</style>\n");
document.write("<div class=\"CAN_ad\">\n");
document.write("<table class=\"ad_slug_table\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n");
@ssimeonov
ssimeonov / tracking_pixel_delivery_script.js
Created April 17, 2013 02:21
Anatomy of an online ad: tracking pixel delivery script
document.write("<!-- gd2-status-2 --><!-- SpaceID=96843138 loc=FSRVY noad -->\n");
document.write("<img style=\"display:none\" width=0 height=0 alt=\"\" src=\"http://us.bc.yahoo.com/b?P=s4i.Bjc2LjFQGJ6UTYvtUx1LMTczLlFt_1n__8MU&T=18f3d55it%2fX%3d1366163289%2fE%3d96843138%2fR%3dhe%2fK%3d5%2fV%3d8.1%2fW%3d0%2fY%3dYAHOO%2fF%3d4264990850%2fH%3dYWRjdmVyPSI2LjQuNCIgc2VydmVJZD0iczRpLkJqYzJMakZRR0o2VVRZdnRVeDFMTVRjekxsRnRfMW5fXzhNVSIgc2l0ZUlkPSI0NDUzMDUxIiB0U3RtcD0iMTM2NjE2MzI4OTI1ODA1NyIg%2fQ%3d-1%2fS%3d1%2fJ%3d69060D4C&U=12d690f6l%2fN%3dlv51DmKImng-%2fC%3d-1%2fD%3dFSRVY%2fB%3d-1%2fV%3d0\"><!--QYZ CMS_NONE_SELECTED,,98.139.227.232;;FSRVY;96843138;2;-->");
@ssimeonov
ssimeonov / original_yahoo_response.html
Last active December 16, 2015 07:49
Anatomy of an online ad: initial response
<!-- Leaderboard slot on Yahoo!'s health network -->
<div id="yahoohealth-n-leaderboard-ad" style="border:0;margin-top:0;">
<div style="margin-bottom:9px;text-align:center">
<!-- Ad unit delivery script if scripting is available -->
<script language="JavaScript" type="text/javascript" src="http://us.adserver.yahoo.com/a?f=96843138&amp;p=health&amp;l=N&amp;c=r&amp;rs=cnp:healthline&amp;at=hlids%3Dx%26hlk1%3D8234384%26hlk2%3D8317112%26hlkwa%3D2790905%20refurl%3D%22%22">
</script>
<center>
<!-- Yahoo 1x1 tracking pixel delivery script -->
<script language="JavaScript" type="text/javascript" src="http://us.adserver.yahoo.com/a?f=96843138&amp;p=health&amp;l=FSRVY&amp;c=sr">
</script>
@ssimeonov
ssimeonov / gist:4752473
Created February 11, 2013 03:57
I've found that test-driven development is the fastest way for me to learn a new language. There is no better way to bootstrap the learning process than by figuring out how to cobble together a minimal expectation-based testing framework in the new language. The following is the result of my first hour with Lua.
-- #t behaves strangely with hashtables & nil values
function table_length(t)
local count = 0
for _ in pairs(t) do count = count + 1 end
return count
end
function Test(test, expectation)
return {
test = test,
@ssimeonov
ssimeonov / my_data.r
Created September 7, 2012 01:56
RSpec hierarchical data structure evolution
=begin
Allows for a data structure to be safely evolved hierarchically during testing
Example:
context "with one try" do
with_data tries: 1
describe "with suppressed exceptions" do
with_data raise_on_fail: false
specify { retry_raise_hell(1, my_data).should be_nil }
@ssimeonov
ssimeonov / test_that_util.r
Created August 24, 2012 06:47
test_that matcher utilities
# Find expression that created a variable
find_expr <- testthat:::find_expr
includes <- function(x, included) {
if (length(included) > 0) {
if (is.list(included)) {
for (name in names(included)) {
if (!all(x[[name]] == included[[name]])) {
return(FALSE)
@ssimeonov
ssimeonov / proto_store_test.r
Created August 23, 2012 03:32
Storing & retrieving proto objects from MongoDB
add = function(., name, p) {
data <- list(name=name, type=p$..Name, data=as.list(p))
.$collection()$insert(data)
},
get = function(., name) {
doc <- .$collection()$query_one(name=name)
if (!is.null(doc)) {
factory <- base:::get(doc$type, pos=1)
do.call(factory$new, doc$data)
@ssimeonov
ssimeonov / readme.md
Created June 20, 2012 01:25
Proto environment confusion with do.call()

Environment confusion in proto

Problem Description

This gist demonstrates a strange behavior in the proto package for R when functions are dynamically invoked via do.call. When do.call is invoked inside a proto object, variables that belong to a function's closure are not visible, even though a naive navigation of the environment chain shows these variables to be present. This problem does not occur when do.call is used outside of proto.

Reproducibility

The problem is isolated to a testthat test in test-cmd.r.