This file contains hidden or 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
>> @article.slides[0].photo_crop_w | |
=> 479 | |
>> @article.slides[0].photo_crop_h | |
=> 319 |
This file contains hidden or 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
######## PARAMS | |
# DATABASE = :Orient | |
DATABASE = :Postgres | |
POSTGRES_PORT = '5432' | |
ORIENT_PATH = '/Users/stevenli/releases/orientdb' | |
ORIENT_BIN_PATH = "#{ORIENT_PATH}/bin" | |
ORIENT_DATABASE_PATH = "local:#{ORIENT_PATH}/databases/tags" |
This file contains hidden or 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
require 'pry' | |
##### PARAMS | |
# Select a database | |
# DATABASE = :Orient | |
DATABASE = :Postgres | |
POSTGRES_PORT = '5432' | |
ORIENT_PATH = '/Users/stevenli/releases/orientdb' |
This file contains hidden or 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
# Looks like List.foldr and List.foldl are delegated to erlang: | |
# https://github.com/elixir-lang/elixir/blob/v1.0.3/lib/elixir/lib/list.ex#L116L118 | |
# But if we wanted to implement these in elixir, seems like we can only write fold1, but not foldr | |
# Question: Can we define `foldr` without using high-level functions (ie. List.reverse) | |
# and using a recursive approach similar to `foldl`? I really can't think how but would be | |
# very interested if someone can show me a solution (if it exists). | |
defmodule MyList do | |
def foldl([], acc, _) do |
This file contains hidden or 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
// plain javascript | |
var Form = React.createClass({ ... }); | |
Form.Row = React.createClass({ ... }); | |
Form.Label = React.createClass({ ... }); | |
Form.Input = React.createClass({ ... }); | |
var App = ( | |
React.createElement(Form, null, | |
React.createElement(Form.Row, null, | |
React.createElement(Form.Label, null), |
This file contains hidden or 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
// you can interpolate basic variables | |
var name = "monkeyman" | |
var person = <Person name={name} />; | |
// you can interpolate javascript expressions | |
var person = <Person name={window.isLoggedIn ? window.name : ''} />; |
This file contains hidden or 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
// The simplest component is a Javascript function that takes `props` | |
// as an argument and returns a React element. This is called a | |
// "functional component" since, well, it's just a function! | |
function CommentBox(props) { | |
return <div>Hello, here is a comment: {props.content} </div>; | |
} | |
// If you're using ES 6, React components can be created | |
// by extending React.Component. | |
class CommentBox extends React.Component { |
This file contains hidden or 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
var CommentList = React.createClass({ | |
render: function() { | |
return ( | |
<div className="commentList"> | |
Hello, world! I am a CommentList. | |
</div> | |
); | |
} | |
}); |
This file contains hidden or 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
// Suppose our comment data to be given as an array of objects | |
var data = [ | |
{id: 1, author: "Hunter Thompson", text: "Where is my white powder?"}, | |
{id: 2, author: "Tom Wolfe", text: "Where is my white suit?"} | |
] | |
ReactDOM.render( | |
// The starting point for the data array of comments | |
// it's passed in as a property of <CommentBox> component | |
<CommentBox data={data} />, |
This file contains hidden or 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
ReactDOM.render( | |
<CommentBox url="/api/comments" />, | |
document.getElementById('content') | |
); |
OlderNewer