-
Open Keychain Access.app and create new object using the host as a name (“example.com”), username with sudo rights (“user”) and it’s password.
-
Add a trigger for iTerm’s profile (‘Advanced‘ tab):
-
Regular Expression:
\$ sudo
-
Action: Run Coprocess…
-
Parameters:
/path/to/iterm_reply_with_keychain.rb user@example.com
-
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 | |
# | |
#/ Usage: app-env [[-e <DOTENV_FILE>]... ] [[-s <SOURCE_FILE>]... ] [--] <command> [<args>...] | |
#/ app-env [-h|--help] | |
#/ | |
#/ Executes a given command with environment variables loaded from dotenv files. | |
#/ Dotenv files are executed in current shell context, wrapped with `set -e'. | |
#/ Source files, which are set with the `-s' flag will be included after `set +e' | |
#/ It is possible to provide several files, just by using flags as many tymes as you need. | |
#/ |
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
# = Kernel#switch | |
# Provides alternative switch-case syntax. | |
# | |
# # support methods: | |
# value = [] | |
# switch value do | |
# on empty?: -> { "none" } | |
# on one?: -> { "one" } | |
# on many?: -> { "many" } | |
# 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 | |
require 'concurrent/atomic/atomic_reference' | |
module Dry | |
module Types | |
# Atomic types denote references in advance to target ones due to help achieve a cross-reference. | |
# | |
# @example | |
# module T |
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 | |
require 'dry/core/cache' | |
require 'dry/core/constants' | |
require 'dry/container' | |
require 'dry/types' | |
require 'dry/types/tuple' # → https://github.com/estum/dry-types-tuple | |
# External instance-level accessor wrapper in inverted control: | |
# once defined with an accessor name it could be used with different objects |
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 Dry | |
module Types | |
# @example | |
# Types::ServiceArgs = Types.Tuple( | |
# Types::Params::Symbol, # --- positional types | |
# [Types::Params::Integer | Types::Coercible::String] # --- [type for the rest items] | |
# ) | |
# Types::ServiceArgs[['thumb', '300', '300', 'sample']] |
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 refinement module helps to inspect a composed source of meta-generated methods, | |
# which were defined via Module#module_eval or Module#class_eval methods | |
# in strings with interpolations. | |
# | |
# Unless this refinement is using, looking up for an actual source of such | |
# kind of method will result with a raw string literal with no interpolation applied. | |
# | |
# It's monkey patch the Module#module_eval and Module#class_eval methods to | |
# write a source with applied interpolation into a temporary file per method owner and | |
# substitutes an evaluted located path & lineno for the string. |
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 MigrateHstoreToJson < ActiveRecord::Migration | |
def up | |
rename_column :posts, :data, :data_hstore | |
add_column :posts, :data, :jsonb, default: {}, null: false, index: { using: 'gin' } | |
execute 'UPDATE "posts" SET "data" = json_object(hstore_to_matrix("data_hstore"))::jsonb' | |
remove_column :posts, :data_hstore | |
end | |
def down | |
rename_column :posts, :data, :data_jsonb |
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
# @example Simple | |
# Osascript.new(<<~SCPT.freeze).() | |
# activate application "Finder" | |
# SCPT | |
# | |
# @example JSC with args | |
# # The script takes 2 arguments: directory path & image path | |
# # to set a folder icon to the given directory. | |
# script = Osascript.new(<<-JS.freeze, lang: 'JavaScript') | |
# ObjC.import("Cocoa"); |
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 | |
require 'dry/core/equalizer' | |
module Dry | |
# @api public | |
def self.Comparator(*keys, **options) | |
if keys.size == 0 && options.size > 0 | |
keys << options.dup | |
options.replace(keys[0].extract!(:immutable, :inspect, :compare)) |
NewerOlder