Skip to content

Instantly share code, notes, and snippets.

@VitalGit
VitalGit / with_backoff.sh
Created July 25, 2018 13:24 — forked from fernandoacorreia/with_backoff.sh
Retries a command a with backoff
#!/bin/bash
set -o nounset -o errexit -o pipefail
# Retries a command a with backoff.
# Based on https://stackoverflow.com/a/8351489/376366
# and https://gist.github.com/fernandoacorreia/b4fa9ae88c67fa6759d271b743e96063
#
# The retry count is given by ATTEMPTS (default 7), the
# initial backoff timeout is given by TIMEOUT in seconds
# (default 1). With default settings, it will try for about 1 minute.

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@VitalGit
VitalGit / README.md
Created March 6, 2017 15:59 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@VitalGit
VitalGit / optparse-template.rb
Created February 22, 2016 14:25 — forked from rtomayko/optparse-template.rb
Ruby optparse template
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"
@VitalGit
VitalGit / 01-truthy-and-falsey-ruby.md
Created February 3, 2016 16:29 — forked from jfarmer/01-truthy-and-falsey-ruby.md
True and False vs. "Truthy" and "Falsey" (or "Falsy") in Ruby, Python, and JavaScript

true and false vs. "truthy" and "falsey" (or "falsy") in Ruby, Python, and JavaScript

Many programming languages, including Ruby, have native boolean (true and false) data types. In Ruby they're called true and false. In Python, for example, they're written as True and False. But oftentimes we want to use a non-boolean value (integers, strings, arrays, etc.) in a boolean context (if statement, &&, ||, etc.).

This outlines how this works in Ruby, with some basic examples from Python and JavaScript, too. The idea is much more general than any of these specific languages, though. It's really a question of how the people designing a programming language wants booleans and conditionals to work.

If you want to use or share this material, please see the license file, below.

Update

// URL for Jira's REST API for issues
var getIssueURL = "https://[Your Jira host]/rest/api/2/issue/";
// Personally I prefer the script to handle request failures, hence muteHTTPExceptions = true
var fetchArgs = {
contentType: "application/json",
headers: {"Authorization":"Basic [Your BASE64 Encoded user:pass]"},
muteHttpExceptions : true
};
@VitalGit
VitalGit / packages.pp
Created December 17, 2014 14:54
Mongo Package Upgrade
# $add_pkg=["mongodb-org","mongodb-org-server","mongodb-org-shell","mongodb-org-mongos","mongodb-org-tools"],
class mongo::packages(
$base_url="http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/",
$version = "2.4.10",
$a='mongodb-org,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools',
$add_pkg = split($a, ',')
){
if versioncmp($version,'2.4.10') == 1 {
$pkg_shim = "db-org"
@VitalGit
VitalGit / untitled
Created December 4, 2014 18:57
Passenger installation output pcre is yum installed but unclear on what module required it
** [out :: 192.168.100.100] Debug: /Stage[main]/Nginx::Nginx/Rvm_gem[passenger]: The container Class[Nginx::Nginx] will propagate my refresh event
** [out :: 192.168.100.100] Debug: Exec[passenger-install-nginx](provider=posix): Executing check 'test -d /usr/local/nginx'
** [out :: 192.168.100.100] Debug: Executing 'test -d /usr/local/nginx'
** [out :: 192.168.100.100] Debug: Exec[passenger-install-nginx](provider=posix): Executing '/usr/local/rvm/bin/rvm ruby-2.1.1 exec passenger-install-nginx-module --auto --prefix=/usr/local/nginx --auto-download'
** [out :: 192.168.100.100] Debug: Executing '/usr/local/rvm/bin/rvm ruby-2.1.1 exec passenger-install-nginx-module --auto --prefix=/usr/local/nginx --auto-download'
** [out :: 192.168.100.100] Notice: /Stage[main]/Nginx::Nginx/Exec[passenger-install-nginx]/returns: Welcome to the Phusion Passenger Nginx module installer, v4.0.40.
** [out :: 192.168.100.100] Notice: /Stage[main]/Nginx::Nginx/Exec[passenger-install-nginx]/returns:
** [out :: 192.168.100.10
@VitalGit
VitalGit / Error Output
Last active August 29, 2015 14:10
puppet apply output for master.pp
Warning: The use of 'import' is deprecated at /etc/puppet/manifests/site.pp:4. See http://links.puppetlabs.com/puppet-import-deprecation
(at /usr/lib/ruby/site_ruby/1.8/puppet/parser/parser_support.rb:110:in `import'; grammar.ra:610:in `_reduce_190'; grammar.ra:609:in `each'; grammar.ra:609:in `_reduce_190'; /usr/lib/ruby/site_ruby/1.8/puppet/util/autoload.rb:62:in `_racc_yyparse_c'; /usr/lib/ruby/site_ruby/1.8/puppet/util/autoload.rb:62:in `catch'; /usr/lib/ruby/site_ruby/1.8/puppet/util/autoload.rb:62:in `_racc_yyparse_c'; /usr/lib/ruby/site_ruby/1.8/puppet/parser/lexer.rb:501:in `scan'; /usr/lib/ruby/1.8/racc/parser.rb:152:in `_racc_yyparse_c'; /usr/lib/ruby/1.8/racc/parser.rb:152:in `__send__'; /usr/lib/ruby/1.8/racc/parser.rb:152:in `yyparse'; /usr/lib/ruby/site_ruby/1.8/puppet/parser/parser_support.rb:168:in `parse'; /usr/lib/ruby/site_ruby/1.8/puppet/node/environment.rb:568:in `perform_initial_import'; /usr/lib/ruby/site_ruby/1.8/puppet/node/environment.rb:276:in `known_resource_types'; /usr/lib/rub