Skip to content

Instantly share code, notes, and snippets.

Anton Katunin antulik

Block or report user

Report or block antulik

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View controller.rb
class ProfilesController < ApplicationController
def index
@tracking_profiles = current_user.tracking_profiles
end
end
@antulik
antulik / README.md
Last active Dec 14, 2015
CampJS D3.JS Links
View README.md
@antulik
antulik / _.md
Created Feb 9, 2013
force_example
View _.md
@antulik
antulik / _.md
Created Feb 9, 2013
series_lines
View _.md
@antulik
antulik / _.md
Created Feb 9, 2013
mouse_circle
View _.md
View _.md
@antulik
antulik / data_conversion.js
Last active Dec 12, 2015
Convert csv to json string
View data_conversion.js
var csv_url = "/proj-pop-age-all-series-qld.csv";
d3.csv(csv_url, function(a) {
a.forEach(function(el){
el.year = parseInt(el.year)
el.age = parseInt(el.age)
el.low = parseInt(el.low)
el.medium = parseInt(el.medium)
el.high = parseInt(el.high)
})
View _.md
@antulik
antulik / pack.js
Created Nov 17, 2012
D3 Pack with links
View pack.js
var width = 960,
height = 960,
format = d3.format(",d");
var pack = d3.layout.pack()
.size([width - 4, height - 4])
.padding(10)
.value(function(d) { return d.size; });
var vis = d3.select("#chart").append("svg")
@antulik
antulik / README.md
Created Oct 12, 2012
Integration testing of google analytics/kissmetrics script.
View README.md

To easily explain, imaging you are developing google analytics or kissmetrics and you need to do integration testing of the javascript file. That's the file which people include on their website. Assume client also needs to push some events like signups to the web analytics tool (like kissmetrics) and javascript syntax would be _ga.push(['register', event, extra_data])

The challenge is that in you tests you can't run it from your application as it will share user session and it wouldn't test same origin policy.

Tools stack: Capybara, Webkit, Rspec, Sinatra

So the solution is to have a separate application which will act as a dummy client. I've chose sinatra as it fits perfectly for that role. One of the cool features that rack has is its ability to mount other rack applications inside it. So in run_dummy_client helper we mount sinatra application to /dummy_client path.

But that's not all. In order for this to work we need to run dummy client from different domain. That could be easily done through

You can’t perform that action at this time.