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
git fsck --unreachable | grep commit | cut -d\ -f3 | xargs git show | |
git stash apply <commit sha-1> |
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
for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done |
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
if ARGV.empty? | |
puts "\nPlease enter any two SEQUENTIAL random numbers separated by one space. i.e 16 21\n" | |
a, b = gets.strip.split(" ") | |
else | |
a, b = ARGV[0], ARGV[1] | |
end | |
if a.to_i > 0 && b.to_i == 0 | |
puts "Please give two numbers." | |
exit |
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 ActiveValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
# If the relationship exists and the related object is active | |
unless eval("record.#{attribute.to_s.gsub("_id", "")}") && eval("record.#{attribute.to_s.gsub("_id", "")}").active | |
record.errors.add(attribute, "must be an active #{attribute.to_s.gsub("_id", "")}") unless eval("record.#{attribute}.blank?") | |
end | |
end | |
end |