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
respond_to do |format| | |
format.json { render json: @model_instance, :only => [:id, :name] } | |
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
def make_slug(str) | |
return if str.blank? or !str.instance_of? String | |
s = str | |
s.downcase! | |
s.strip! | |
s.gsub!(/[^a-z0-9\s-]/, '') # Remove non-word characters | |
s.gsub!(/\s+/, '-') # Convert whitespaces to dashes | |
s.gsub!(/-\z/, '') # Remove trailing dashes | |
s.gsub!(/-+/, '-') # get rid of double-dashes | |
s.to_s |
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
#!/bin/bash | |
# | |
url="$1"; [ ${url} == "" ] && exit 1; | |
# | |
[[ "$(echo ${url} | egrep '^http[s]?\:\/\/\w+(\.\w+)?(\.\w+)?')" == "" ]] && exit 1; | |
# | |
bad_list='(http|www|org|com|edu|in|io|can|like|to|in|of|de|em|para)'; | |
# | |
name_list=$(echo ${url} | \ | |
sed -r "s/^http[s]?\:\/\///" | \ |