Skip to content

Instantly share code, notes, and snippets.

@eeropic
Last active November 2, 2016 18:57
Show Gist options
  • Save eeropic/209bf8126150f9fb8ca8027c3ac7e69f to your computer and use it in GitHub Desktop.
Save eeropic/209bf8126150f9fb8ca8027c3ac7e69f to your computer and use it in GitHub Desktop.
gistid="209bf8126150f9fb8ca8027c3ac7e69f";
//Query Github with selected gist id
$.ajax({
url: 'https://api.github.com/gists/'+gistid,
type: 'GET',
dataType: 'jsonp'
}).success( function(gistdata) {
console.log(gistdata.data.files)
var content = gistdata.data.files["appendGistToSketch.js"].content;
appendCode(content)
}).error( function(e) {console.log('ajax error')});
//Insert the gist to the Ace editor in sketch.paperjs.org
function appendCode(data){
source = $('.source');
editor = ace.edit(source.find('.editor')[0]);
var session = editor.session;
session.insert({row: session.getLength(),column: 0},
"\n" + data)
// editor.getValue()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment