Skip to content

Instantly share code, notes, and snippets.

View catm705's full-sized avatar

Cat Gelinas catm705

View GitHub Profile
@catm705
catm705 / gist:2778e238e9536a5afc21
Created May 20, 2014 20:20
AJAX API calls in RAILS
---------------------------------
---- searches_controller.rb -----
---------------------------------
def create
# 1.) js file
# 2.) click event to prevent default route to the controller from js with the url.
# get value from form
# ajax request to send form data
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"></script>
@catm705
catm705 / gist:11255842
Last active March 24, 2021 04:02
GIT with GROUPS
________________________________________________________________________
**** GIT HUB WITH GROUP PROJECTS ****
________________________________________________________________________
* git branch -d → Will delete the branch completely if it SUCKS.
* AlWAYS pull first before you start your work.
* git checkout develop → Never work on master branch.
- Your MASTER branch must always work.
________________________________________________________________________
** Beginning of Day: **
<!-- views/picture/index.html.erb -->
<% if flash[:msg] %>
<%= flash[:msg] %>
<% end %>
<br>
<%= link_to "create picture", new_picture_path(@picture) %>
<br>
<br>
<% @pictures.each do |picture| %>
<img src="<%= picture.image_url %>" alt="" width="300px"/>
@catm705
catm705 / gist:11047278
Last active August 29, 2015 14:00
Palindrome Rails App
----------------------------------------------------------
Palindrome.rb
----------------------------------------------------------
# In ActiveRecord docs as 'validates_with'
class ValidPalindrome < ActiveModel::Validator
def validate(record)
test_string = record.text
unless test_string == test_string.reverse
record.errors[:text] << 'This is not a Palindrome.'
@catm705
catm705 / gist:11009142
Last active August 29, 2015 14:00
Jasmine Set up in Spec Folder
1.) Add the gem 'jasmine' to your gemfile like so:
group :development, :test do
gem 'launchy'
gem 'capybara'
gem 'pry-rails'
gem 'selenium-webdriver'
gem 'rspec-rails', '~> 3.0.0.beta'
gem 'jasmine'
# gem 'guard'
# gem 'guard-rspec'
@catm705
catm705 / gist:10985104
Last active August 29, 2015 13:59
API - in Seed Data
###### seed.rb ###################
######################################
Complaint.delete_all
url = "http://data.cityofnewyork.us/resource/erm2-nwe9.json"
response = HTTParty.get(url)
response.each do |incident|
# c = Complaint.new
@catm705
catm705 / gist:10599928
Created April 13, 2014 20:00
partial forms
-------------------------------------------------------------
new.html.erb --> PARTIAL FORMS
-------------------------------------------------------------
<div id="main">
<h1><em>Wish U Were Here</em></h1>
<% if logged_in? %>
<p>Hi, <%= current_user.name %>!<br><br>
<img src=<%= current_user.image_url %> alt="User Profile Pic" />
<br>
<span class="tagline">Where would YOU rather be?</span>
@catm705
catm705 / gist:10547367
Last active August 29, 2015 13:59
API Parsing - Using Instagram
---------------------------------------------------------------------
user.rb
---------------------------------------------------------------------
# == Schema Information
# Table name: users
#
# id :integer not null, primary key
# name :string(255)
# email :string(255)
# password_digest :string(255)
@catm705
catm705 / gist:10420518
Created April 10, 2014 20:33
Procs, Methods, Blocks, Functions
# def log_before_doing()
# puts "About to do stuff in a block."
# yield
# yield
# end
# log_before_doing() { puts "Doin' stuff in a block."}
# def do_ten_times()
# 10.times { yield }