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
# Verifies that date elements (year, month, day) exist on the current page | |
# with the specified values. You can optionally restrict the search to a specific | |
# date's elements by assigning <tt>options[:from]</tt> the value of the date's | |
# label. Selects all the date elements with date provided. The date provided may | |
# be a string or a Date/Time object. | |
# | |
# Rail's convention is used for detecting the date elements. All elements | |
# are assumed to have a shared prefix. You may also specify the prefix | |
# by assigning <tt>options[:id_prefix]</tt>. | |
# |
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
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | grep 'xvda' | awk '{ print $5 " (" $4 ") Left " }' |
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: This will take the request object and update the relevant model | |
def self.handle_defensio_callback(request) | |
query_params = CGI::parse(request.query_string) | |
defender_model = query_params['model'].first.strip | |
if defender_model.empty? | |
raise DefenderError, 'Incorrect url structure; missing callback url param' | |
else | |
begin | |
document = document_from_defensio_callback(request) | |
unless document.nil? |
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
→ rvm install 1.9.3 --trace | |
1.9.3 --trace | |
rvm 1.16.18 (stable) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/] | |
+ [[ -n '' ]] | |
+ set -o errtrace | |
+ export 'PS4=+ ${BASH_SOURCE##${rvm_path:-}} : ${FUNCNAME[0]:+${FUNCNAME[0]}()} ${LINENO} > ' | |
+ PS4='+ ${BASH_SOURCE##${rvm_path:-}} : ${FUNCNAME[0]:+${FUNCNAME[0]}()} ${LINENO} > ' | |
+ /scripts/cli : __rvm_parse_args() 716 > [[ -z install ]] |
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 StockManager | |
def initialize(cart_item) | |
@cart_item = cart_item | |
end | |
def save_and_update_stock | |
if @cart_item.quantity_changed? | |
ActiveRecord::Base.transaction do | |
new_quantity = @cart_item.product.quantity | |
if @cart_item.quantity_was.to_i > @cart_item.quantity |
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
# (concern) e.g. for Post model | |
module UserTrackable | |
extend ActiveSupport::Concern | |
included do | |
before_create :set_created_by | |
before_save :set_updated_by | |
belongs_to :created_by, class_name: 'User', foreign_key: 'created_by_id' |
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 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'colorize' | |
end | |
class MatcherInterface | |
def initialize(some_object) | |
@some_object = some_object |
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
<!-- Amend the uk mac variants in /usr/share/X11/xkb/rules/evdev.xml --> | |
... | |
<variant> | |
<configItem> | |
<name>mac</name> | |
<description>English (UK, Macintosh)</description> | |
</configItem> | |
</variant> | |
<!-- START OF ADDITION --> | |
<variant> |
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
format = """ | |
[](bg:#33658A fg:#282727)\ | |
[](bg:#349a73 fg:#33658A)\ | |
$hostname\ | |
[](bg:#9A348E fg:#349a73)\ | |
$directory\ | |
[](bg:#DA627D fg:#9A348E)\ | |
$ruby\ | |
[](fg:#DA627D bg:#869ED8)\ | |
$kubernetes\ |