Skip to content

Instantly share code, notes, and snippets.

View flemdizzle's full-sized avatar

Steven Fleming flemdizzle

View GitHub Profile
require 'faker'
output = []
dates = []
20.times do
output << Faker::Commerce.product_name
end
20.times do
var FluffyRouter = Backbone.Router.extend({
routes: {
'seal panda bunny': 'update',
'*default': 'update'
},
update: function(){
var id = Backbone.history.fragment || 'bunny';
$('.view').hide();
$('#' + id).show();
this.navigate(id);
json.array!(@students) do |student|
json.extract! student, :id, :name, :email, :phone, :location, :employment
json.url student_url(student, format: :json)
end
var StudentListView = Backbone.View.extend({
tagName: 'div',
className: 'students-list',
template: _.template($('#students-list-template').html()),
initialize: function(){
this.listenTo(this.collection, 'sync', this.render);
},
events: {
'submit form': 'onSubmit'
},
/* CSS declarations go here */
body {
font-family: sans-serif;
background-color: #315481;
background-image: linear-gradient(to bottom, #315481, #918e82 100%);
background-attachment: fixed;
position: absolute;
top: 0;
bottom: 0;
def self.available_bikes(distance, id)
doc = Nokogiri::XML(open("http://www.capitalbikeshare.com/data/stations/bikeStations.xml"))
# spits out the number of bikes at a given station
doc.xpath('//station').each do |node|
if node.children[0].text == "#{id}"
latitude = node.children[4].text
distance = distance.round(2)
longitude = node.children[5].text
bikes = node.children[12].text
docks = node.children[13].text
@flemdizzle
flemdizzle / evaluation.js.jsx
Created February 5, 2017 16:56
Some JSX code to send to Jon
var Evaluation = React.createClass({
getInitialState: function() {
return {evaluation: this.props.evaluation};
},
updateData: function(form, data) {
var index = this.state.evaluation.indexOf(form);
var form_data = React.addons.update(this.state.evaluation[index].form,
{ $merge: data });
form.form = form_data;
- sentence_beginning:
- 'lazy'
- 'dog'
- text_section: 'The lazy dog'
part_of_speech: 'verb'
- text_section: 'over the brown fox. This little'
part_of_speech: 'type of animal'
validationPlaceholder() {
if (this.state.validation_error && this.state.validation_data.status === 'required') {
return 'REQUIRED';
}
},
toggleInput() {
if (this.props.edit) {
return (
<div>