Skip to content

Instantly share code, notes, and snippets.

@garciadanny
garciadanny / example.rb
Created November 30, 2013 19:42
example using the gistify gem
def example
puts 'using gistify'
end
@garciadanny
garciadanny / using_gistify.md
Created November 30, 2013 06:30
A quick description of gistify

Gistify

Easily create gists from the command line.

This gist was created using Gistify.

See documentation here

@garciadanny
garciadanny / http_rest.md
Last active October 12, 2016 09:21
A beginners guide to HTTP and REST. Notes taken from codecademy.com

#HTTP and REST

Hypertext Transfer Protocal

  • Whenever you navigate a site though links, you're making a state transition, bringing you to the next page. Representing the next state of the application.
Client sends request to server, server returns a response.
  • In order for a client and a server to speak to each other, they follow a set of principles called REST (Representational State Transer).

API

Typing a number before a motion or operator repeats it nth times

Motions

w - Move to the beginning of each word.

e - Move to the end of each word.

0 - Move to the beginning of the line (zero).

require 'active_support/core_ext/array'
class Garden
attr_reader :layout, :for_student, :students
def initialize(layout, students = Garden.default_students)
@students = students
@layout = parse(layout)
@for_student = group_by_student
define_student_lookups
body {
width: 100%;
height: 500px;
margin: 0;
padding: 0;
text-align: center;
}
body:before {
display: inline-block;
content: ' ';

Redis and Resque

What this guide will cover: the code you will need in order to include Redis and Resque in your Rails app, and the process of creating a background job with Resque.

What this guide will not cover: installing Ruby, Rails, or Redis.

Note: As of this writing I am still using Ruby 1.9.3p374, Rails 3.2.13, Redis 2.6.11, and Resque 1.24.1. I use SQLite in development and Postgres in production.

Background jobs are frustrating if you've never dealt with them before. Over the past few weeks I've had to incorporate Redis and Resque into my projects in various ways and every bit of progress I made was very painful. There are many 'gotchas' when it comes to background workers, and documentation tends to be outdated or scattered at best.

Installing Ruby 2.0.0

  1. $ rvm get stable

NOTE: The reason why I brew installed the following packages is because running $ rvm install ruby-2.0.0 didn't seem to work for me. It broke when trying to install these packages, so I installed them manually then installed Ruby.

# in spec/support/omniauth_macros.rb
module OmniauthMacros
def mock_auth_hash
# The mock_auth configuration allows you to set per-provider (or default)
# authentication hashes to return during integration testing.
OmniAuth.config.mock_auth[:twitter] = {
'provider' => 'twitter',
'uid' => '123545',
'user_info' => {
'name' => 'mockuser',