This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<style> | |
body { | |
margin: 0px; | |
padding: 0px; | |
} | |
</style> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function average(list) { | |
var sum = 0; | |
for (var num in list) { | |
sum += list[num]; | |
} | |
return sum / list.length; | |
} | |
console.log(average([20, 21, 220, 54])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Lambdas, Proc.new, and Blocks - Bitmaker breakout session | |
# Friday March 8, 2013 | |
## LAMBDAS | |
# Basic Usage: | |
# Think of lambdas as methods that have no name and instead they can be assigned to a variable and thus be passed around. | |
l = lambda {"do or do not"} | |
puts l.call # returns => do or do not |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://stackoverflow.com/questions/6312448/how-to-disable-logging-of-asset-pipeline-sprockets-messages-in-rails-3-1 | |
# https://github.com/rails/rails/pull/4501 | |
# https://github.com/rails/rails/pull/4512 | |
if Rails.env.development? | |
#Rails.application.assets.logger = false #Logger.new('/dev/null') | |
Rails::Rack::Logger.class_eval do | |
def call_with_quiet_assets(env) | |
previous_level = Rails.logger.level | |
Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The controller method for the same is as below | |
def update_additional_details | |
@user = current_user | |
@user.profile.display_education_details(show_details_for_profile?(:education)) | |
@user.profile.display_experience_details(show_details_for_profile?(:experience)) | |
@user.profile.display_linkedin_details(show_details_for_profile?(:linkedin_profile)) | |
@user.profile.detail[:linkedin_profile][:data] = params[:linkedin_profile_data] | |
if @user.profile.save | |
redirect_to additional_details_user_path(@user), :notice => _("successfully_updated") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def url_valid | |
url = URI.parse(get_linkedin_profile) | |
unless %w( http https ).include?(url.scheme) && (url.hostname.include? "linkedin") && !url.path.blank? | |
errors.add(:detail, "Please Enter a Valid Linkedin Profile URL") | |
end | |
rescue URI::InvalidURIError => e | |
errors.add(:detail, "Please Enter a Valid Linkedin Profile URL") | |
end | |
#This method works fine but How can I better handle invalid string values like linkedin_url = ">>>>>" ? |