Skip to content

Instantly share code, notes, and snippets.

View fakefarm's full-sized avatar
🐽
🦁🍎🐸🧄🐔🍐🐹🍑🐮 🐴🦆🥦🐙🐳F🦞🧅🐶 🦧👾A🦈🐋🍉K🌽 🐣🐎🦚🦩🦔🐿🦨🐉🥕 🐿🐾🐒🍊E🐈🐻🥥🐱 🐼🥑🐷🐓🍌🐖F🦃 🐑🚜🍋🐂A🐏🌾🤖🐀🦔 R🦜🦝🐈🦓🐠🦑🦂M🐜

Dave Woodall fakefarm

🐽
🦁🍎🐸🧄🐔🍐🐹🍑🐮 🐴🦆🥦🐙🐳F🦞🧅🐶 🦧👾A🦈🐋🍉K🌽 🐣🐎🦚🦩🦔🐿🦨🐉🥕 🐿🐾🐒🍊E🐈🐻🥥🐱 🐼🥑🐷🐓🍌🐖F🦃 🐑🚜🍋🐂A🐏🌾🤖🐀🦔 R🦜🦝🐈🦓🐠🦑🦂M🐜
View GitHub Profile
@fakefarm
fakefarm / delete_method.md
Last active December 28, 2015 21:49
Why won't you delete?

View

= link_to "delete profile", user_path(@user), method: :delete

Controller

def destroy
  @user = User.find(params[:id])

@user.destroy

@fakefarm
fakefarm / ajax.md
Last active December 29, 2015 14:19
Oh ajax...

show.slim

=link_to votes_path(type: 'Mix', id: @mix.id), method: :post, remote: true do

create.js.erb

alert('hi');

votes_controller.rb

@fakefarm
fakefarm / gem.rb
Created November 27, 2013 22:21
gem file
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
gem "railties"
gem 'jquery-rails'
gem 'filepicker-rails'
gem 'counter_culture', '~> 0.1.18'
gem 'neat'
@fakefarm
fakefarm / nokogiri
Created December 27, 2013 23:32
nokogiri nightmare
gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib
bundle config build.nokogiri --global --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib
@fakefarm
fakefarm / josh.js
Created April 20, 2014 01:18
remove anchor
var post = $('.wall-post-copy').first();
if (post.children().first().attr('target') == "_blank") {
post.children().first().css('display', 'none') }
@fakefarm
fakefarm / height.js
Last active August 29, 2015 14:02
Get the right height
// Get proper container height
function getContainerHeight(){
var myHeight = $('#my-header').outerHeight(),
var yourHeight = $('#deal-details').height(),
containerHeight = ( myHeight > yourHeight ? myHeight : yourHeight );
return containerHeight;
}
@fakefarm
fakefarm / meta.slim
Created June 12, 2014 21:59
meta data
= content_for :meta do
meta content=FACEBOOK['client_id'] property="fb:app_id" /
meta content=@user.url property="og:url" /
meta content=@user.short_title property="og:title" /
meta content=@user_sharing.facebook_data[:description] property="og:description" /
meta content=@user_sharing.facebook_data[:photo_url] property="og:image" /
meta content="summary" name="twitter:card" /
meta content="@lettucebooks" name="twitter:site"
meta content=@user.url name="twitter:url"
meta content=@user.short_title name="twitter:title"
@fakefarm
fakefarm / arguments_as_array.js
Last active August 29, 2015 14:04
Javascript Arguments act as array
// Arguments look like array's but are not. But you can add array functionality with prototype.
function Max(x,y,z) {
var args = Array.prototype.slice.call(arguments);
return args;
}
@fakefarm
fakefarm / indexOf.js
Last active August 29, 2015 14:04
indexOf
// Use index of to check contents of array.
// A function that takes a character (i.e. a string of length 1) and returns true if it is a vowel, false otherwise.
function isVowel(letter) {
vowels = ['a','e','i','o','u'];
var result = vowels.indexOf(letter)
if (result >= 0) {
return true;
}
else {
@fakefarm
fakefarm / sum.js
Created August 14, 2014 11:57
have some fun
function sum ( args ) {
var array, sum = 0; // Set vars
// Conditional to type check what the arguments are
if ( typeof args == 'number' ) { // If not an array, then convert it to one.
array = Array.prototype.slice.call(arguments, 0); // Gotcha, using the key word 'arguments', not the 'args' word. 'arguments' is a special word in javascript that looks like an array, but is not.
} else {
array = args;
}
for ( i in array ) { // I assume recursion could be used here if I knew how recursion worked.