This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {PropTypes, Component} from 'react' | |
import pureRender from 'pure-render-decorator' | |
import {Table, Column} from 'fixed-data-table' | |
import DataCellEditable from './data-cell-editable/' | |
import {List} from 'immutable' | |
import classnames from 'classnames' | |
import styles from './index.css' | |
@pureRender | |
export default class DataTableEditable extends Component { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {default as React, PropTypes} from 'react' | |
const namespace = 'sampleComponent' | |
export default class SampleComponent extends React.Component { | |
getInitialState() { | |
return {value: ''} | |
} | |
handleInput(event) { | |
console.log('setting state to ', event.target.value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Tic Tac Toe</title> | |
<style> | |
#container{ | |
width:330px; | |
height:330px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Creating a Backbone Model | |
var Person = Backbone.Model.extend({ | |
// default attributes | |
urlRoot:'http://gdibb.herokuapp.com/people', // Is this where the URL goes? | |
defaults: { | |
role: 'hater', | |
imgUrl: 'http://uproxx.files.wordpress.com/2012/09/grumpy-cat-03.jpg', | |
firstName: 'Grumpy', | |
lastName: 'Cat' | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Map.prototype.toggleMarkerColor = function(listingId){ // this is not running | |
alert("The map heard the click event!"); | |
var idx = this.markerMap[listingId]; | |
this.geoJson[idx].properties["marker-color"] = "#ffffff"; | |
this.markerLayer.setGeoJson(this.geoJson); | |
this.markerLayer.addTo(this.map); | |
}; | |
// Under Listings view... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Working code for Facebook's OAuth using Flask-OAuth library | |
from flask import session as flask_session | |
from flask_oauth import OAuth | |
oauth = OAuth() | |
facebook = oauth.remote_app('facebook', | |
base_url='https://graph.facebook.com/', | |
request_token_url=None, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In my javascript... | |
$.get('/get_all_bikes', function(data){ | |
// All these print statements are all what I expect... | |
console.log("response from server:", data); | |
console.log("First item:", data['response'][0]); | |
console.log("Latitude is:", data['response'][0].latitude); | |
// But for loop is not running |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Flask function: | |
@app.route("/") | |
def home_page(): | |
# Get first 10 bikes from database | |
bikes = model.session.query(model.Bike).limit(10).all() | |
return render_template("index.html", bikes=bikes) | |
// In Jinja template: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// AJAX post to add listing to database | |
$.post("/addlisting", { | |
price: price, | |
comments: comments, | |
latitude: latitude, | |
longitude: longitude | |
}, | |
function(bike_id){ // returning bike_id with server response | |
window.location.href = "/listing/" + bike_id; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def omg_unicode(some_input): | |
""" | |
Decode input immediately, work internally with unicode, encode at the end | |
Remember: Bytes in --> unicode everywhere --> bytes out | |
""" | |
# Decode your input (convert from <type 'str'> to <type 'unicode'>) | |
unicode_string = some_input.decode('utf8','ignore') | |
# Unicode all the things! (i.e. precede text with u and refer to non-ascii characters by their unicode code point) |