Skip to content

Instantly share code, notes, and snippets.

@joecorcoran
joecorcoran / block_exercises.rb
Last active August 29, 2015 14:13
Working with yield in Ruby
# Define a method named add_one that accepts
# a block and returns the return value of the
# block + 1, as follows.
# (Hint: yield gives you the return value of
# the block)
add_one do
2
end
# => 3
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin
$(function() {
//run the accordion plugin, set height of sections to height of content
$("#accordion").accordion({ autoHeight: false });
});
;(function($) {
//write new sammy application
var app = new Sammy.Application(function() {
with(this) {
//corresponds to routes such as #/section/1
get('#/section/:section_id', function() { with(this) {
//get first part of current url, without hash
var base_path = window.location.href.split("#")[0];
var real_id = 0;
var current_page;
;(function($) {
//create new sammy app
var app = new Sammy.Application(function() {
with(this) {
//corresponds to routes like #/slide/1
get('#/slide/:page_id', function() { with(this) {
var next_path;
var form_stages;
var check_a;
var check_s;
var prev_path;
var field_val;
;(function($) {
var app = new Sammy.Application(function() {
with(this) {
get('#/stage/:id', function() { with(this) {
// declare your variable
var clickedItem:String;
// clickable_mc can obviously be the
// instance name of anything you want
// the user to click
clickable_mc.onRelease = function() {
// set the variable to anything - this
// will be grabbed in mc_omn and assigned
require 'sinatra'
require 'pathname'
get "/" do
html = "<h1>Your files, sir.</h1>"
dir = "./files/"
Dir[dir+"*"].each do |file|
html+=file_link(file)
end
html
stop();
// this sets the component's pageName param to
// something we'll define in the next step
cmp_omn.pageName = _root.clickedItem;
// check it's working
trace(cmp_omn.pageName);
// this waits for 0.3 seconds and then calls the
<div xmlns:dc="http://purl.org/dc/elements/1.1/#" about="http://www.example.com/books/my_great_book.pdf">
<p>
<span property="dc:title">My Great Book</span> by
<span property="dc:creator">Joe Corcoran</span>, published
<span property="dc:date">2009-10-01</span>.
</p>
</div>