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 | |
# | |
# This script configures WordPress file permissions based on recommendations | |
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions | |
# | |
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org> | |
# | |
WP_OWNER=www-data # <-- wordpress owner | |
WP_GROUP=www-data # <-- wordpress group | |
WP_ROOT=/var/www/lucascaton_blog |
Resumo do vídeo "Crie sua Oferta Irresistível" do Conrado Adolpho.
Cliente ➙ Oferta ➙ Produto
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
%w(1 2).sort_by { |i| nil } | |
# => ["1", "2"] | |
# ... | |
%w(1 2 3 4 5 6).sort_by { |i| nil } | |
# => ["1", "2", "3", "4", "5", "6"] | |
### So far, so good... | |
### But look what happens when you have 7 or more elements: |
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
public extension Array { | |
public subscript(safe index: Int) -> Element? { | |
return self.indices ~= index ? self[index] : nil | |
} | |
} | |
// ... | |
let optionalResult = array[safe: 1] // returns nil instead of crashing |
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
(1..50).to_a.first # => 1 | |
(1..50).to_a.second # => 2 | |
(1..50).to_a.third # => 3 | |
(1..50).to_a.fourth # => 4 | |
(1..50).to_a.fifth # => 5 | |
(1..50).to_a.forty_two # => 42 |
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
#!/usr/bin/env ruby | |
begin | |
require 'bundler/inline' | |
rescue LoadError => e | |
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' | |
raise e | |
end | |
gemfile(true) do |
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 'RMagick' | |
require 'capybara' | |
require 'launchy' | |
module Capybara::Recording | |
def start_recording | |
system "rm -f tmp/*" | |
end | |
def save_recording |
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
#!/usr/bin/env ruby | |
if `git diff --cached spec` =~ /,\s?(:focus|focus:\s?true|:focus\s?=>\s?true)/ | |
puts "\e[31mPlease focus and remove your :focus tags before committing :)" | |
exit 1 | |
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
single quotes `1` x `0` double quotes | |
https://github.com/18F/C2/pull/705 ("enforce single quotes” PR ➙ merged!) | |
there’s also a good discussion here: https://github.com/bbatsov/ruby-style-guide/issues/96 | |
the most popular ruby style guide recommends single quotes: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals :stuck_out_tongue: |