Skip to content

Instantly share code, notes, and snippets.

View code-for-coffee's full-sized avatar

James code-for-coffee

  • Chicago, IL
View GitHub Profile
@code-for-coffee
code-for-coffee / ajax-get.js
Last active August 29, 2015 14:25
ajax-prep
var app = app || {};
app.getRequest = {
type: 'get',
url: 'http://ga-chicago.github.io/project1/data.json',
dataType: 'json',
success: function(data) {
console.log(data);
},
error: function(error) {
// http://stackoverflow.com/questions/20679135/convert-xml-to-jsonobject-using-javascript-jquery
// Changes XML to JSON
function xmlToJson(xml) {
// Create the return object
var obj = {};
if (xml.nodeType == 1) { // element
// do attributes
if (xml.attributes.length > 0) {
@code-for-coffee
code-for-coffee / Testing.rb
Created July 22, 2015 05:21
mixins with classes
module Testing
def about_self?
"(\##{self.object_id}): #{self.to_s}"
end
end
class Foo
@code-for-coffee
code-for-coffee / hi_underscore.js
Created July 24, 2015 13:53
Intro to Underscore.js
var woot = woot || {};
woot.log = function(key) {
console.log(key);
}
// mimics Collection.each
// http://underscorejs.org/#each
// args:
// _.each(list, iteratee, [context])
_.each(['Aldrin', 'Armstrong', 'Grissom', 'Hadfield'], woot.log);
@code-for-coffee
code-for-coffee / file.erb
Created July 24, 2015 17:30
Uisng getJSON on an ERB page on the same server
<section>
<h2>Thanks for visiting!</h2>
<p class='stuff'>
</p>
</section>
@code-for-coffee
code-for-coffee / story.md
Created August 8, 2015 03:09
Telling a Story through Markdown

Hi there!

Today we're going to tell a story using Markdown. It will be populated with a lot of links to things (also known as points of interest). This story will tell the journey that you are undertaking as it happens.

@code-for-coffee
code-for-coffee / exoplanet.md
Last active August 29, 2015 14:27
Exoplanet Data

Creating a Visual Graph of Exoplanet Data with Javascript

  1. Visit http://exoplanetarchive.ipac.caltech.edu/cgi-bin/TblView/nph-tblView?app=ExoTbls&config=planets
  2. Select only Planet Mass/Planet M*sin(i) (both are Jupiter Planet Mass)
  3. 'Download Table' => Download selected records and columns
  4. Use http://www.convertcsv.com/csv-to-json.htm to conver to JSON
  5. Inspect using Node; copy/paste to a variable assignment (ex: var epd = .. then copypaste)
  6. Check length - epd.length
  7. Inspect data source
  8. Each object in the JSON array is structured to display the planet number
@code-for-coffee
code-for-coffee / app.js
Created August 25, 2015 17:22
Backbone.js
var sms = sms || {};
var active = active || {};
sms.model = Backbone.Model.extend({
initialize: function() {
}
});
sms.collection = Backbone.Collection.extend({
initialize: function() {
@code-for-coffee
code-for-coffee / collectionRendering.js
Created August 31, 2015 18:55
Render a Collection bound from an API with Backbone.js
var app = app || {};
var active = active || {};
//blueprints
app.model = Backbone.Model.extend();
app.collection = Backbone.Collection.extend({
model: app.model,
url: '/api/people' // path to your API
});
app.modelView = Backbone.View.extend({
@code-for-coffee
code-for-coffee / intro_to_node_lab.md
Created September 1, 2015 17:55
Intro to Node Lab

GeneralAssemb.ly

Building Servers with Node

###WDI Darth Vader


Lab