Skip to content

Instantly share code, notes, and snippets.

View McKinneyDigital's full-sized avatar

McKinneyDigital

View GitHub Profile
@McKinneyDigital
McKinneyDigital / share-linkedin.js
Created June 6, 2012 20:26
Share to Linkedin using Javascript
// Opens a pop-up with a Linkedin share dialog
var url = "http://google.com";
var title = "Replace this with a title.";
var text = "Replace this with your share copy.";
window.open('http://www.linkedin.com/shareArticle?mini=true&url='+encodeURIComponent(url), '', 'left=0,top=0,width=650,height=420,personalbar=0,toolbar=0,scrollbars=0,resizable=0');
@McKinneyDigital
McKinneyDigital / share-facebook.js
Created June 6, 2012 20:23
Share to Facebook using Javascript
// Opens window with facebook share dialog.
// Remember to include OpenGraph meta tags in the page with sharing copy.
var url = "http://google.com";
window.open('http://facebook.com/sharer/sharer.php?u='+encodeURIComponent(url), '', 'left=0,top=0,width=650,height=420,personalbar=0,toolbar=0,scrollbars=0,resizable=0');
@McKinneyDigital
McKinneyDigital / share-twitter.js
Created June 6, 2012 20:21
Share to Twitter from a link using Javascript
// Opens a pop-up with twitter sharing dialog
var url = "http://google.com";
var text = "Replace this with your text";
window.open('http://twitter.com/share?url='+encodeURIComponent(url)+'&text='+encodeURIComponent(text), '', 'left=0,top=0,width=550,height=450,personalbar=0,toolbar=0,scrollbars=0,resizable=0');
@McKinneyDigital
McKinneyDigital / ajax-csrf-rails.js
Created June 6, 2012 20:11
When using AJAX calls to rails methods, send CSRF token to validate the request
var csrf_token = $('meta[name=csrf-token]').attr('content');
$("body").bind("ajaxSend", function(elm, xhr, s){
if (s.type == "POST") {
xhr.setRequestHeader('X-CSRF-Token', csrf_token);
}
});
@McKinneyDigital
McKinneyDigital / as3-class-definition.as
Created June 6, 2012 19:58
Get the class definition of an object with Actionscript 3
function getClass(obj:Object):Class
{
return Class( getDefinitionByName( getQualifiedClassName(obj) ) );
}
@McKinneyDigital
McKinneyDigital / sql-csv-export.sql
Created June 6, 2012 19:56
Export a CSV of user info from database table in a single SQL Query
SELECT id,email FROM users INTO OUTFILE '/tmp/users.csv' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'
@McKinneyDigital
McKinneyDigital / gpluslink.html
Created May 25, 2012 18:25
Code for creating a google plus share link