View devise_random_password_generator.rb
module Devise
def self.generate_password
SecureRandom.hex(1).upcase << SecureRandom.hex(DEVISE_PASSWORD_MIN)
end
end
View gist:c01fb211a03e35121f908183eccbc071
ls *1600x900_scrot.png | xargs -P 5 -I img pngcrush -brute img 1600x900/img
View README
I've had a rough understanding of xargs for some time (allows you to do
_something_ with the output of a previous command), but never understood it
well enough to instinctively reach for it while working on the command line.
So, I decided I'd put a little demo together in order to learn more about it.
The demo is, admittedly, very basic but it was enough to help me get a better
understanding of what xargs can do and when you might want to use it.
Roughly, the demo does the following:
1.) pipe a list of images to xargs
View cast-blame.rb
require 'active_support/core_ext/hash/conversions'
require 'nokogiri'
require "open-uri"
open("https://www.senate.gov/legislative/LIS/roll_call_votes/vote1151/vote_115_1_00209.xml") { |f|
File.open("votes.xml","wb") { |file|
file.puts f.read
}
}
votes = File.open("votes.xml") { |f| Nokogiri::XML(f) }
View README.md
View add_collection_associations_to_factory_girl_factories.rb
# Goal: Allow addition of instances to a collection in a factory-built object
# when those instances require references to the parent.
# Typically occurs in Rails when one model has_many instances of another
# See more at:
# http://stackoverflow.com/questions/2937326/populating-an-association-with-children-in-factory-girl
# Usage
# Foo has_many :bar
#
View just_two_args.hs
parseArgs :: [a] -> Maybe (a, a)
parseArgs [x, xx] = Just (x, xx)
parseArgs _ = Nothing
main = do
print $ parseArgs [1, 2] -- Just (1, 2)
print $ parseArgs [1, 2, 3] -- Nothing
View seeyouspacecowboy.cr
# Crystal fork of "SEE YOU SPACE COWBOY by DANIEL REHN (danielrehn.com)"
# by @ethagnawl
# Displays a timeless message in your terminal with cosmic color effects
# Usage:
# - build with `crystal build -o ~/seeyouspacecowboy seeyouspacecowboy.cr`
# - add `~/seeyouspacecowboy; sleep 2` to ~/.bash_logout
# (adjust the sleep variable to display the message for more seconds)
class String
View coupon-codes.txt
# source: https://www.slideshare.net/CouponFollow/top-100-most-common-coupon-code-phrases
fall
twitter
black
MEMORIAL
TWEET20
FREESHIP
earlybird
MONDAY
holidays