Skip to content

Instantly share code, notes, and snippets.

@andershaig
andershaig / refresh.js
Created May 26, 2012 02:37
Force Refresh Page after AJAX
$(document).bind('didRefreshWidgetContent', function () {
top.location.href = top.location.href;
});
@andershaig
andershaig / autofill.liquid
Created May 23, 2012 22:28
LinkedIn Autofill
<script type="text/javascript">
function onLinkedInAuth() {
$('#linkedin_section').hide();
IN.API.Profile("me")
.fields("id","first-name","last-name","location","public-profile-url")
.result( function(me) {
var user_id = me.values[0].id;
var fname = me.values[0].firstName;
var lname = me.values[0].lastName;
@andershaig
andershaig / tweet.liquid
Created May 22, 2012 18:08
Twitter Intents with Rawtext
<button id="tweet_button">Click to Tweet</button>
<script type="text/javascript">
{% plugin rawtext tweet_url %}
{% plugin rawtext tweet_text %}
{% plugin rawtext tweet_hashtags %}
var params = {};
// Note: until we get support for escaping single quotes, they can't be used in the message.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JSON to CSV</title>
<script src="scripts/json.js" type="text/javascript"></script>
<script type="text/javascript">
var json3 = { "d": "[{\"Id\":1,\"UserName\":\"Sam Smith\"},{\"Id\":2,\"UserName\":\"Fred Frankly\"},{\"Id\":1,\"UserName\":\"Zachary Zupers\"}]" }
DownloadJSON2CSV(json3.d);
@andershaig
andershaig / sharing.liquid
Created May 15, 2012 14:36
Sharing Popup using Facebook's Share Method
<script type="text/javascript">
$(document).ready( function () {
var url = encodeURIComponent('https://www.youtube.com/watch?v=ya7OVaIu7Yg');
var title = encodeURIComponent('This is my super awesome title');
var full_url = 'http://www.facebook.com/sharer.php?u=' + url + '&t=' + title;
$('#fb_share').click( function (e) {
e.preventDefault();
window.open(full_url);
});
@andershaig
andershaig / img2canvas.js
Created May 2, 2012 22:51
Image to Canvas with CORS
var img = document.createElement('img');
img.onload = function(e) {
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
var url = canvas.toDataURL(); // Succeeds. Canvas won't be dirty.
};
img.crossOrigin = 'anonymous';
img.src = 'http://other-domain.com/image.jpg';
@andershaig
andershaig / pulse.css
Created April 24, 2012 17:53
Animated Pulse
#backlight {
position:absolute;
top:150px;
left:150px;
width:0;
height:0;
-webkit-border-radius: 150px;
-moz-border-radius: 150px;
border-radius: 150px;
-webkit-box-shadow:0 -15px 90px 35px rgba(0,255,255,0.5),
@andershaig
andershaig / CSS3_Full.jsx
Created April 17, 2012 21:44
Create CSS3 code from Photoshop layers
/* Copyright 2012 - Minim Group - http://minim.co/ */
// Enable double-clicking from Finder/Explorer
#target photoshop
app.bringToFront();
// ### Document Variables
var doc_layers = app.activeDocument.layers;
var num_layers = doc_layers.length;
@andershaig
andershaig / widget.js
Last active October 1, 2015 07:08
Widget Refresh Completed
$(document).on('didRefreshWidgetContent', function () {
// Do something
});
@andershaig
andershaig / xml.js
Created February 28, 2012 01:50
XML Generator
function xmlgen(name, data) {
var xml;
if (!data) {
xml = '<' + name + '/>';
} else {
xml = '<'+ name + '>' + data + '</' + name + '>';
}
return xml;