Skip to content

Instantly share code, notes, and snippets.

View renaehodgkins's full-sized avatar

Renae Hodgkins renaehodgkins

View GitHub Profile
#social_header
line-height: 12px
float: right
font-family: "MuseoSans300"
font-size: 12px
color: #dee5e8
.social_hover
float: left
padding: 0px 2px
@renaehodgkins
renaehodgkins / cookie_fail
Created February 24, 2012 18:57
Cookie Fail
#protip
add 'new-session' to your .tmux.conf -- then add 'tmux attach' to the end of your .bashrc/.profile/.zshrc or whatever to automatically connect or create a new session.
It's fucking rad.
https://img.skitch.com/20120320-drb6wifhbmy3n2137s2chymrn1.jpg
var paper = Raphael(10, 50, 320, 200); // this line of code will generate a canvas at position x: 10, y: 50 with width 320, height 200
var paper = Raphael(element, 200, 100); // this will create canvas inside the html element
var paper = Raphael('container', 200, 100); // suppose you have a html element with id 'container'
var rect = paper.rect(0, 0, 50, 50); // creat a rect with position and size, the coorrdinates are relative to the container
rect.attr({fill: '#333'}); // set the background color of the rect
var rect = paper.rect(0, 0, 50, 50).rect.attr({fill: '#333'});
var c = paper.path("M10 10L90 90"); // 'M10 10' means move our path draw pen to potision 10,10, 'L90 90' means draw a line from current position to (90, 90), this coordinate is relative to (10, 10)
paper = new Raphael(@el, 1000, 750) # init paper on the @el element which is passed from Backbone Views
paper.rect(0, 0, 1000, 750, 10).attr({stroke: 'none', fill: '#fff'}) # create canvas
paper.text(20, 20, "Chrome Browser Percentage World").attr({'text-anchor': 'start', 'font-size': '20px'}) # add chart title
paper.setStart() # set point to start add element to a set which is a container that can include elements
_.each _.keys(@worldmap.shapes), (country_iso_code)=> # @worldmap.shapes is brought by world.js which contains paths of countries
path = paper.path(@worldmap.shapes[country_iso_code]).attr({stroke: "#fff", fill: @colorOfCountry(country_iso_code), "stroke-opacity": 0.25}) # draw country path, fill the color based on the percentage value
@bindHoverToCountry(paper, country_iso_code, path)
bindHoverToCountry: (paper, country_iso_code, path)->
that = this
path.hover(
(e)->
# when mouse hover the country, we build fill the country path with highlight color and display a tooltip around the mouse position
name = that.worldmap.names[country_iso_code]
desc = "#{that.data[name]} %"
this.tipSet = that.drawCountryTooltip(paper, e.offsetX, e.offsetY, name, desc)
this.c = this.c || this.attr("fill")
this.stop().animate({fill: "#C13A27"}, 500)
paper = new Raphael(@el, 1000, 750) # init paper on the @el element which is passed from Backbone Views
paper.rect(0, 0, 1000, 750, 10).attr({stroke: 'none', fill: '#fff'}) # create canvas
paper.text(20, 20, "Chrome Browser Percentage World").attr({'text-anchor': 'start', 'font-size': '20px'}) # add chart title
paper.setStart() # set point to start add element to a set which is a container that can include elements
_.each _.keys(@worldmap.shapes), (country_iso_code)=> # @worldmap.shapes is brought by world.js which contains paths of countries
path = paper.path(@worldmap.shapes[country_iso_code]).attr({stroke: "#fff", fill: @colorOfCountry(country_iso_code), "stroke-opacity": 0.25}) # draw country path, fill the color based on the percentage value
@bindHoverToCountry(paper, country_iso_code, path)