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
module S6 | |
module Searchable | |
def self.included(base) | |
base.extend ClassMethods | |
end | |
module ClassMethods | |
def make_searchable(opts={}) |
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
# To extend AR models with general instance and class methods that are needed through the Span6 project | |
# Simply call the class method #general_helpers in the AR model | |
module S6 | |
module GeneralHelpers | |
def self.included(base) | |
base.extend ClassMethods | |
end | |
module ClassMethods |
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 = ">>>>>" ? |
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
# 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
def require_ssl | |
if request.protocol != SECURE_PROTOCOL | |
redirect_to :protocol => SECURE_PROTOCOL | |
else # development or test | |
logger.info "redirected to ssl" | |
end | |
end |
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
COMMANDS I KNOW/USE AND YOU WILL LIKELY WANT TO KNOW | |
tail with -n option | |
more, less, and cat | |
grep | |
curl | |
which | |
ps | |
top | |
kill |
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
class Hangman | |
LIST = ["canada", "england", "australia", "japan"] | |
attr_accessor :word, :chances, :board, :list, :guesses, :answer | |
class InvalidGuessException < Exception | |
end | |
def initialize() | |
@chances = 8 | |
@guesses = [] |
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
require "socket" | |
@channel = "#bitmaker" | |
@greeting_prefix = "privmsg #bitmaker :" | |
@greeting = "hello" | |
def connect_to_server | |
server = "chat.freenode.net" | |
port = "6667" | |
nick = "HelloBot" |
OlderNewer