Skip to content

Instantly share code, notes, and snippets.

View dacur's full-sized avatar

David Curtis dacur

  • Raleigh, North Carolina
View GitHub Profile
@dacur
dacur / flickr.js
Created July 5, 2014 18:09
Displaying photos from Flickr using their API.
$(document).ready(function() {
var flickerAPI = "http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?";
$('form').submit(function (evt) {
var $submitButton = $('#submit');
var $searchField = $('#search');
evt.preventDefault();
$searchField.prop("disabled",true);
@dacur
dacur / simple_form.css
Created July 9, 2014 13:07
Simple form layout with HTML and CSS. View here: http://codepen.io/dacur/pen/KJmxg
.wrap {
width: 250px;
clear: both;
margin:0 auto;
}
.form-wrap input {
width: 100px;
clear: both;
}
label{
@dacur
dacur / logo.css
Created July 14, 2014 19:24
Styling logo. Makes it clickable and uses the asset pipeline to get the logo.
.logo a {
margin:; 0.4em 0;
background: transparent url(asset_path(#{"logo-name"})) no-repeat center center ;
background-size: contain;
display: block;
height: 34px;
}
@dacur
dacur / truncate.css
Created July 14, 2014 19:46
Truncating text / handling overflowing text. Instead of pushing overflowing text into surrounding areas, it will be truncated and end with "...".
.truncate {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
@dacur
dacur / add
Last active August 29, 2015 14:04
How to make sure deleted files are no longer tracked, not added back to your project (git).
EDIT/UPDATE: git add --all (use this instead)
git add -u
@dacur
dacur / pg
Created September 3, 2014 13:21
How to solve PG install problems, especially for first time installs (i.e. on new machines).
DO NOT INSTALL PG USING THE PGAPP!!! INSTALL VIA BREW.
Then, from the command line, run:
ARCHFLAGS="-arch x86_64" gem install pg
@dacur
dacur / application_controller.rb
Created September 3, 2014 14:21
Chrome and/or other browsers may not allow cross communication between localhost development environments (i.e. localhost:3000 => localhost:3001) due to browser security features. The code below represents the totality of the application_controller.rb file, which will then 'fix' this browser bug.
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery
before_filter :cors_preflight_check
after_filter :cors_set_access_control_headers
@dacur
dacur / controller.rb
Created September 3, 2014 15:12
You have a search box where someone can enter a first OR last name. You need to search your database of all first names AND last names looking for the value entered. The code below is ActiveRecord's way of handling this search for you - no SQL required. See here for more info: http://stackoverflow.com/questions/3684311/rails-how-to-chain-scope-q…
@vendorsfound = Vendor.where("first like ? OR last like ?", "%" + params[:first] + "%", "%" + params[:first] + "%").order("LOWER(last) ASC, first")
@dacur
dacur / searchgif.js
Last active August 29, 2015 14:06
Adding a 'loading.gif' while something is happening on the page (e.g. waiting for search results).
$("#searchloading").html("<img src='/assets/loader.gif' alt='loading...' />");
// then:
$("#searchloading").css("display", "none");
Create a local .gitignore
If you create a file in your repository named .gitignore, Git uses it to determine which files and directories to ignore, before you make a commit.
A .gitignore file should be committed into your repository, in order to share the ignore rules with any other users that clone the repository.
GitHub maintains an official list of recommended .gitignore files for many popular operating systems, environments, and languages in the github/gitignore public repository.
In Terminal, navigate to the location of your Git repository.
Enter: touch .gitignore to create a .gitignore file.