alias sleepless="pmset -g assertions | egrep '(PreventUserIdleSystemSleep|PreventUserIdleDisplaySleep)'"
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
# frozen_string_literal: true | |
module Whenever | |
class JobList | |
attr_reader :roles | |
def self.respond_to?(name, include_private = false) | |
@set_variables&.has_key?(name) || super | |
end | |
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
# frozen_string_literal: true | |
class ExampleResource < Avo::BaseResource | |
include ResourceExtensions | |
field :id, as: :id | |
field :name, as: :text | |
index do | |
field :some_field, as: :text |
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 bash | |
# shellcheck disable=SC2059 | |
set -euo pipefail | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
NO_COLOR='\033[0m' | |
CLEAR_LINE='\r\033[K' |
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
The credentials are stored in the "credentials.yml.enc" file, encrypted. | |
To decrypt the credentials file, you need a master key that is set on either: | |
* config/master.key file (for local development) | |
* ENV["RAILS_MASTER_KEY"] (for deployed environments) | |
What should you commit? | |
* The file config/master.key should be ignored in gitignore (you should not commit the master key) | |
* The file credentials.yml.enc should be commited along with the codebase (but don't worry, only those who have the master key can decrypt it) |
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
Overview | |
-------- | |
Consider the commands given to be examples, not to necessarily be precisely | |
what you will use. They were based on my circumstances, in which | |
* my local platform is macOS, | |
* where Homebrew is the de facto package manager; | |
* my laptop (and the server) are managing Ruby with rbenv; | |
* vim is my remote editor of choice, and an acceptable local editor; and |
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
# Mina Deploy | |
# =========== | |
# | |
# Adapted from Creative deploy stack in Manabalss v4, Mar.2015, updated to support staging on Jun.2015 | |
# On first deploy do: mina setup --verbose | |
# Then do : mina deploy[initialize] --trace | |
# | |
# Usage examples: | |
# mina deploy[soft,seed,compile] to=staging # deploy task with all options | a simple `mina deploy` will deploy to production | |
# mina rake[db:seed] # for multi-argument tasks # mina 'rake[payments:refund[arg1\,arg2]]' |
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
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query | |
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails | |
#payload: [{"kind"=>"person"}] | |
Segment.where("payload @> ?", [{kind: "person"}].to_json) | |
#data: {"interest"=>["music", "movies", "programming"]} | |
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json) | |
Segment.where("data #>> '{interest, 1}' = 'movies' ") | |
Segment.where("jsonb_array_length(data->'interest') > 1") |
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 | |
# bundler exec ruby gems_homepages.rb | |
# based on http://stackoverflow.com/questions/5177634/list-of-installed-gems | |
require 'rubygems' | |
def local_gems | |
Gem::Specification.sort_by{ |g| [g.name.downcase, g.version] }.group_by{ |g| g.name } | |
end | |
puts local_gems.map{ |name, specs| |
Salvaged from Google Cache of http://www.lps-it.fr/blog/20151218-signal-handling-and-ruby.html
December 18, 2015
Linux Ruby
Since version 2.0.0, signal handling in Ruby can be tricky. I bet if you're here, it's because you've seen this error message :