Skip to content

Instantly share code, notes, and snippets.

View krisleech's full-sized avatar

Kris Leech krisleech

View GitHub Profile
@krisleech
krisleech / app.rb
Created January 14, 2019 09:32
Inline Ruby project with ActiveRecord
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'active_record'
gem 'sqlite3'
end
@paolocarrasco
paolocarrasco / README.md
Last active November 5, 2024 20:08
How to understand the `gpg failed to sign the data` problem in git

Problem

You have installed GPG, then tried to commit and suddenly you see this error message after it:

error: gpg failed to sign the data
fatal: failed to write commit object

Debug

@electron0zero
electron0zero / sentry_error_logger.rb
Last active April 21, 2022 02:09
Sidekiq Sentry Middleware
# Sidekiq Middleware to report all errors to sentry
# This is a server-side middleware that reports any exception from any job
# See more: https://github.com/mperham/sidekiq/wiki/Middleware
module Sidekiq::Middleware::Server
class SentryErrorLogger
def call(worker, job, queue)
begin
yield
rescue => error
Raven.capture_exception(error,
@mottalrd
mottalrd / event_sourcing_intro.rb
Last active November 2, 2023 21:47
An introduction to event sourcing, London Ruby User Group, 9th May 2018
module Commands
module Meeting
AcceptSchema = Dry::Validation.Schema do
required(:user_id).filled
required(:status).value(eql?: :scheduled)
end
class Accept < Command
def call
return validate if validate.failure?
@krisleech
krisleech / .my.cnf
Last active November 19, 2019 09:07
reset mysql root password
[client]
user=root
#host=127.0.0.1
socket=/var/run/mysqld/mysqld.sock
[server]
plugin-load-add = auth_socket.so
@cezaraugusto
cezaraugusto / gpg_fix.txt
Last active November 7, 2024 16:39
fixing `gpg failed to sign data` error on macOS
For troubleshooting, two things to first try:
run `git config --global gpg.program gpg2`, to make sure git uses gpg2 and not gpg
run `echo "test" | gpg2 --clearsign`, to make sure gpg2 itself is working
If that all looks all right, one next thing to try:
run `brew install pinentry` to ensure you have a good tool installed for passphrase entry
If after that install and you re-try git commit and still get the "failed to sign the data" error:
run `gpgconf --kill gpg-agent` to kill any running agent that might be hung
@reborg
reborg / rich-already-answered-that.md
Last active September 25, 2024 17:06
A curated collection of answers that Rich gave throughout the history of Clojure

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.

How to use:

  • The link in the table of content jumps at the copy of the answer on this page.
  • The link on the answer itself points back at the original post.

Table of Content

@ajsharma
ajsharma / rollbar.rql
Last active March 1, 2022 23:12
Rollbar RQL query to pull number of exceptions that have occurred in the last 60 days
SELECT body.trace.exception.class, count(*), sum(item.total_occurrences), min(timestamp), max(timestamp), level, environment, item.status
FROM item_occurrence
WHERE timestamp > unix_timestamp() - 60 * 60 * 24 * 77
AND item.status = 1
AND language = 'ruby'
AND item.level >= 40
AND environment = 'production'
GROUP BY body.trace.exception.class
LIMIT 500
@halberom
halberom / opt1_template.j2
Last active October 11, 2024 16:44
ansible - example of template if else
{# style 1 - long form #}
{% if filepath == '/var/opt/tomcat_1' %}
{% set tomcat_value = tomcat_1_value %}
{% else %}
{% set tomcat_value = tomcat_2_value %}
{% endif %}
{# style 2 - short form #}
{% set tomcat_value = tomcat_1_value if (filepath == '/var/opt/tomcat_1') else tomcat_2_value %}
module Wisper::EnlightenedPublisher
extend ActiveSupport::Concern
included do
include Wisper::Publisher
prepend PrependedMethods
end
def subscribe_to_listeners
self.class.wisper_listeners.each do |listener|