Skip to content

Instantly share code, notes, and snippets.

View patrickwhardy's full-sized avatar

Patrick Hardy patrickwhardy

  • Slack
  • Boulder, CO
View GitHub Profile

Introduction to Sinatra

1. What is the purpose of the server file (routing)?

###The server file contains http verbs that dictate how a page is rendered, what logic is executed and what will be sent back to the client.

2. How do you pass variables into the views?

###Pass a var to the server file. The server file uses ERB to translate a designated file in the views dir.

@patrickwhardy
patrickwhardy / cfu_crud_in_sinatra.markdown
Last active March 23, 2016 04:16 — forked from rwarbelow/cfu_crud_in_sinatra.markdown
CRUD in Sinatra -- Check for Understanding
  1. Define CRUD. Create, read, update, destroy - this is the base functionality that all applications should provide
  2. There are seven verb + path combinations that are necessary in a basic Sinatra app in order to provide full CRUD functionality. List each of the seven combinations, and explain what each is for. Get, /tasks - shows all tasks Get, /tasks/:id - shows one task Get, /tasks/new - shows form for task creation Post, /tasks - submits task content and creates object Get, /tasks/:id/edit - shows form to edit task info Put, /task/:id - submits changes to task info Delete, /task/:id - delets task
## Models, Databases, Relationships in Rails
#### What is the difference between a primary key and a foreign key? Where would we find a primary key? What would it be called by default? Where would we find a foreign key? What is the naming convention for a foreign key?
* Primary key lives on the one side of a one to many relationship. It is generally called tablename_id. The "many" object in the relationship holds on to a forieign key that uniqely identifies it's "one" association.
#### Write down one example of:
* a `one-to-one `relationship.
* Citizen to SSN
* One king to one kingdom
* a `one-to-many relationship`.
* One kingdom has many peasants
* concatenation takes the contents of multiple assets and puts them in to a single file i.e. "output/main.js.
Given
the file "input/a.js" contains
var a = 1;
And
the file "input/b.js" contains
var b = 2;
#Concatenate!
the file "output/main.js" should contain
/* Made by Computer Corp. LLC */
When and why would you rebase?
to squash commits
What are the steps to do a basic rebase via the command line?
git rebase
Our cart in Little Shop is not stored in the database. How does its state persist across requests?
sessions
Name two objects used in Rails that can be used to track state of the user across requests.
sessions, flashes
Draw the MVC model and the request response cycle through a rails app.
get ‘/tasks’, TasksController.index => redirect_to :index, render app/views/tasks/index.html.erb
@patrickwhardy
patrickwhardy / Lean Methodology
Created April 26, 2016 19:25
Lightning Talk Outline for 4/29
#Background
* Lean startup Eric Ries - encourages "business-hypothesis-driven experimentation"
* Prioritizes "verified learning" over market research
* Eliminating waste - minimize features created that don't get used
#MVP
* (MVP) is the "version of a new product which allows a team to collect the maximum amount of validated learning about customers with the least effort"
* does not account for scalability or viability - tests are there customers that want this product
*zappos founder buying shoes from retail stores
@patrickwhardy
patrickwhardy / gist:25f02b104fa8a2ae3dc06972220a2a7e
Last active June 24, 2016 17:03
Javascript Exercisms Comparison

##Leap My code: here

  • Responder #1 (Matt P) here
  • Looks like Matt implemented the same solution as me: checking if the year is divisible by for then an && statement to ensure the year isn't a century or that it can be every 4 centuries.
  • I don't like how nested this person's solution became. In fact - I wonder if this is actually passing because the last return false does not seem to be nested inside of a conditional and should always return.
  • I like the flexible chkMod method that this person wrote. Passing in the divisor as an argument is a creative solution

###Your experience implementing

  • I implemented Selenium in ideabox and it went much smoother than the last time I tried to do this. This doesn't mean that the setup is not quite cumbersome - it is. So many layers of dependence: selenium depends on firefox to run, it depends on capybara's driver to be set to selenium, it depends on wait for ajax methods to be set up properly, it depends on js: true being set, it depends on database cleaner to be specially configured and then it sometimes wont even properly trigger events as it should. What a pain!

###Were you successful?

  • I did atleast have some success. Ajax was executed and the responses properly executed and vereified in the test. The only reason I didn't get every javascript feature tested was because I ran into issues with SQLite3 - at this point

What is ES6?

  • ES6 is the (almost) newest version of the ECMAScript standard. It comes with a hole bunch of syntactic sugar that makes javascript so not 2009.

What is Transpilation and how does it relate to ES6?

  • Transpiling is the conversion of one language to another that's of the same level of abstraction. It's important for ES6 because many of the ES5 apps out there will want to transpile to ES6.

Looking at the ES6 Features link below, discuss one update from ES5 and if it seems useful/superfluous.

  • Classes? Wow - it's like I'm in Ruby again! I know it's just syntactic sugar but Class.prototype.method is totally ridiculous.
MIDI.org itself says “the Web-MIDI API is the most significant advancement of MIDI since… MIDI itself!”
- Why its awesome
Enabled by default in chrome - no software or setup needed
Works on all platforms and devices. Anything with a web browser can run a Web-MIDI app and use local MIDI hardware.
Works with your existing MIDI setup. If your MIDI gear is connected to your computer, tablet or phone (by a cable or even wirelessly) that same connection will connect your MIDI gear to your Web-MIDI enabled browser.
Updates are automatic. No need to install new versions, the latest version is always available at the website URL.
Accessible anywhere. Apps and data in “the Cloud” are available anywhere you have an internet connection.
Browsers make it easy to connect you and your music to other people via social media and on-line MIDI communities.