Server Price Breakdown: DigitalOcean, Amazon AWS LightSail, Vultr, Linode, OVH, Hetzner, Scaleway/Online.net:
Permalink: git.io/vps
Provider | Type | RAM | Cores | Storage | Transfer | Network | Price |
---|
git branch | grep -v "master\|develop" | xargs git branch -D |
#!/bin/bash | |
# download and install latest geckodriver for linux or mac. | |
# required for selenium to drive a firefox browser. | |
install_dir="/usr/local/bin" | |
json=$(curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest) | |
if [[ $(uname) == "Darwin" ]]; then | |
url=$(echo "$json" | jq -r '.assets[].browser_download_url | select(contains("macos"))') | |
elif [[ $(uname) == "Linux" ]]; then | |
url=$(echo "$json" | jq -r '.assets[].browser_download_url | select(contains("linux64"))') |
Permalink: git.io/vps
Provider | Type | RAM | Cores | Storage | Transfer | Network | Price |
---|
First, add pry-rails to your Gemfile:
https://github.com/rweng/pry-rails
gem 'pry-rails', group: :development
Then you'll want to rebuild your Docker container to install the gems
$ rails c | |
Running via Spring preloader in process 7916 | |
/Users/edmac/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require': dlopen(/Users/edmac/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin14/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError) | |
Referenced from: /Users/edmac/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin14/readline.bundle | |
Reason: image not found - /Users/edmac/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin14/readline.bundle | |
Fixed with: | |
ln -s /usr/local/opt/readline/lib/libreadline.7.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib |
$ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
$ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
module FactoryGirl | |
def self.find_or_create(resource_name, attributes = {}, &block) | |
clazz = resource_name.to_s.classify.constantize | |
model = clazz.find_by(attributes) || FactoryGirl.build(resource_name, attributes) | |
yield(model) if block_given? && model.new_record? | |
model.tap(&:save) | |
end |
RSpec.configure do |config| | |
config.before(:suite) do | |
DatabaseCleaner.clean_with(:truncation) | |
end | |
config.before(:each) do | |
DatabaseCleaner.strategy = :transaction | |
end | |
config.before(:each, js: true) do |
I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.
If you want to roll up all of these into a single jQuery plugin check out Sharrre
Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.
class Luhn | |
def self.checksum(number) | |
digits = number.to_s.reverse.scan(/\d/).map { |x| x.to_i } | |
digits = digits.each_with_index.map { |d, i| | |
d *= 2 if i.even? | |
d > 9 ? d - 9 : d | |
} | |
sum = digits.inject(0) { |m, x| m + x } | |
mod = 10 - sum % 10 | |
mod==10 ? 0 : mod |