Skip to content

Instantly share code, notes, and snippets.

View SamSamskies's full-sized avatar
🚀
vamos

Sam Samskies SamSamskies

🚀
vamos
  • Various
View GitHub Profile
@SamSamskies
SamSamskies / app.css
Last active December 30, 2015 15:29
Railsbridge Front-end Example
body {
height: 2000px;
}
.big {
font-size: 100px;
}
a {
font-size: 12px;
@SamSamskies
SamSamskies / challenge.rb
Last active December 27, 2015 03:29
Secret company challenge
# You need to have the HTTParty gem installed to run this
# https://github.com/jnunemaker/httparty
require 'httparty'
response = HTTParty.get 'http://letsrevolutionizetesting.com/challenge.json'
while response
puts response
follow_link = response['follow'].gsub('?', '.json?')
@SamSamskies
SamSamskies / git-sh-aliases.md
Last active December 25, 2015 04:59
aliases not working in git-sh

Got this tip from the master Myles Byrne (@quackingduck)

git-sh loads your bash config from ~/.bashrc not ~/.bash_profile

So one way to fix this (this is how my machine is set up) is to copy your ~/.bash_profile to ~/.bashrc and then change ~/.bash_profile to just have this line:

test -f ~/.bashrc && source ~/.bashrc

@SamSamskies
SamSamskies / ar-todo-overview.md
Last active May 11, 2017 02:32
AR Todo DBC phase 1 challenge overview

The purpose of this document is to go over a couple different solutions for the AR Todos challenge from phase 1. First, I'm going to present a solution where most of the code is done in a single file. Then I'm going to present a solution using MVC and hopefully you'll be able to see the benefits of taking the time to separate your concerns.

Example 1: Non-MVC Solution

Many beginner programmers would probably approach the AR Todos challenge in a manner somewhat like this example if they were not given specific instructions on how to implement the solution. This solution is easier to write because you can just tackle each task systematically without thinking about new classes, how to organize separate files, etc.

What if you made this program for your job and another person needed to add more functionality or fix a bug? Do you think it would be easy for them to understand what you did? They could probably figure it out, but it wouldn't be as easy as it could be. It's important to make your program as clea

@SamSamskies
SamSamskies / ar-todo-MVC.md
Last active December 24, 2015 17:09
ActiveRecord TODO MVC example

This is an example MVC solution of the ActiveRecord TODOs: Part 1 challenge. The purpose of this document is to walk you through my thought process in creating this solution.

As always, the first thing I did was break this down into smaller problems. I decided to setup the database and then start with the view because I wanted to make an MVP as quickly as possible. Here's what I started out with:

Initial View

require_relative 'config/application'

def display_menu
@SamSamskies
SamSamskies / html5-boilerplate.html
Created August 31, 2013 04:40
Simplest HTML5 Boilerplate template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Blank HTML 5 Template</title>
</head>
<body>
</body>
</html>
@SamSamskies
SamSamskies / app.css
Last active January 17, 2020 20:08
Google geocode example
#myMap {
width: 800px;
height: 500px;
}
@SamSamskies
SamSamskies / app.js
Created May 21, 2013 01:29
Behavior Drill: Grocery List
function List(listType) {
this.items = [];
this.total = 0;
this.listType = listType;
this.init = function() {
if (this.listType === 'store') {
this.makeItemsDraggable();
this.populateItems();
} else {

Testing Tips & Tricks

Run a single test

In a large application, running all the tests at once using rake spec can make it difficult to check the output of the test you're working on. Especially if you have many failing or pending tests. Run a single test by running rspec:

rspec spec/models/account.rb

You can be even more specific and run a specific example from a test file. For example, given the following tests:

11: describe "#deposit!" do
@SamSamskies
SamSamskies / rails_jquery_ajax.md
Last active October 5, 2017 17:51
Rails: jQuery & AJAX Tutorial

jQuery and jQuery-ujs

When using Rails 3.0 and later we already get jquery-rails for free. Look in the gemfile and you'll see:

gem "jquery-rails"

You can view the full documentation here: source: https://github.com/indirect/jquery-rails

If you take a look in APP_DIR/app/assets/javascripts/application.js, you'll notice the following lines of code: