Skip to content

Instantly share code, notes, and snippets.

@elikem
elikem / httparty.rb
Created March 11, 2014 06:31 — forked from runemadsen/httparty.rb
HTTParty
class Github
include HTTParty
base_uri 'https://api.github.com'
end
Github.post("/user/repos", :query => {
:access_token => @token
},
:body => {
:name => name,
@elikem
elikem / github-api-practice.rb
Created March 11, 2014 06:40 — forked from juno/github-api-practice.rb
Github API Practice
require 'json'
require 'httparty'
class Github
include HTTParty
base_uri 'http://github.com/api/v2/json'
# @param [String] username GitHub username
# @param [String] password Password or API token
def initialize(username, password)
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@elikem
elikem / workers.rake
Created May 11, 2014 11:20 — forked from karmi/workers.rake
Launching and Killing Resque worker processes
# Rake task to launch multiple Resque workers in development/production with simple management included
require 'resque/tasks' # Require Resque tasks
namespace :workers do
# = $ rake workers:start
#
# Launch multiple Resque workers with the Rails environment loaded,
# so they have access to your models, etc.
@elikem
elikem / capybara cheat sheet
Created May 12, 2014 21:05 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)

true and false vs. "truthy" and "falsey" (or "falsy")

Update

Hi! I'm Jesse. I co-founded Dev Bootcamp in 2012 with Shereef Bishay and Dave Hoover, but left recently to work on a new project. If you're reading this, you're probably interested in learning how to program. I'm working on something new that might just be up your alley. Shoot me an email at jesse@20bits.com if you're interested.

Back to our regularly-scheduled programming

Many programming languages, including Ruby, have native boolean (true and false) data types. In Ruby they're called true and false. In Python, for example, they're written as True and False.

Exposing an API

APIs are becoming an essential feature of modern web applications. Rails does a good job of helping your application provide an API using the same MVC structure you're accustomed to.

In the Controller

Let's work with the following example controller:

class ArticlesController < ApplicationController
#!/bin/sh
echo Install all AppStore Apps at first!
# no solution to automate AppStore installs
read -p "Press any key to continue... " -n1 -s
echo '\n'
# install wallpaper cli
sudo gem install desktop
echo Install Homebrew, Postgres, wget and cask
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
@elikem
elikem / .pryrc
Created July 30, 2014 11:33 — forked from bespokoid/.pryrc
# === EDITOR ===
Pry.editor = 'vim'
# == Pry-Nav - Using pry as a debugger ==
Pry.commands.alias_command 'c', 'continue' rescue nil
Pry.commands.alias_command 's', 'step' rescue nil
Pry.commands.alias_command 'n', 'next' rescue nil
Pry.commands.alias_command 'r!', 'reload!' rescue nil
Pry.config.color = true