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 / 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 / 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 / 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 / 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 / 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 / layout_vars.rb
Created December 12, 2013 03:28
Load vars to be used in layout using Rails.
class ApplicationController < ActionController::Base
before_filter :load_vars
protected
def load_vars
#check if ajax call
unless request.xhr?
@SamSamskies
SamSamskies / git-bash-setup
Last active August 29, 2015 13:56
Bash git branch name with colors
BLACK="\[\033[0;30m\]"
RED="\[\033[0;31m\]"
GREEN="\[\033[0;32m\]"
YELLOW="\[\033[0;33m\]"
BLUE="\[\033[0;34m\]"
DEFAULT="\[\033[0;00m\]"
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "("${ref#refs/heads/}")"
{
"auto_complete_commit_on_tab": true,
"color_scheme": "Packages/Color Scheme - Default/Cobalt.tmTheme",
"font_size": 16.0,
"ignored_packages":
[
"Vintage"
],
"save_on_focus_lost": true,
"scroll_past_end": true,
@SamSamskies
SamSamskies / sublime-settings
Last active May 9, 2016 19:11
sublime settings
{
"auto_complete_commit_on_tab": true,
"color_scheme": "Packages/User/SublimeLinter/Monokai (SL).tmTheme",
"detect_slow_plugins": false,
"ensure_newline_at_eof_on_save": true,
"font_size": 18.0,
"ignored_packages":
[
"Vintage"
],
@SamSamskies
SamSamskies / scrolling-sample.js
Created September 1, 2014 07:20
scrolling sample
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<style>
body {
margin-top: 50px;
}