Skip to content

Instantly share code, notes, and snippets.

@israelb
israelb / fix_NSCFConstantString_initialize.txt
Created May 17, 2023 15:16 — forked from zanetagebka/fix_NSCFConstantString_initialize.txt
Solve issue with objc[18501]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
# If you have issue with
# objc[18501]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
# objc[18501]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
# I had this problem when running `bin/rails c` on Mac M1 Pro. The solution for this is below
$ export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
$ export DISABLE_SPRING=true
This should help.
@israelb
israelb / curl.md
Created January 25, 2023 20:59 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@israelb
israelb / cucumber-rails.md
Created February 2, 2022 20:03 — forked from stepheneyer/cucumber-rails.md
BDD testing using Cucumber, Capybara, and Rails

#Cucumber and Capybara - Behavior Driven Development

##Overview

Cucumber allows software developers to describe how software should behave in plain text. The text is written in a business-readable, domain-specific language. This allows non-programmers to write specific feature requests that can be turned into automated tests that drive development of the project.

Capybara is the largest rodent known to man.

Interactor Gem (Service object)

It is based on the Command pattern, where each Command class/object represents a task and has one public method. Basically, something like:

PressButton.new(button).execute # or
PurchaseOrder.new(params).call # or even
Song::Create.(params) # or a proc
SendEmail.perform(email) # it could be a class method, why not?
@israelb
israelb / rfc regex
Created September 24, 2019 14:44 — forked from gerardorochin/rfc regex
Expresion regular para validar RFC
/^([A-Z,Ñ,&]{3,4}([0-9]{2})(0[1-9]|1[0-2])(0[1-9]|1[0-9]|2[0-9]|3[0-1])[A-Z|\d]{3})$/
@israelb
israelb / rubocop_pre_commit_hook
Created October 25, 2018 14:02 — forked from mpeteuil/rubocop_pre_commit_hook
Ruby style guide git pre-commit hook using Rubocop as the style guide checker. Only runs on staged ruby files that have been added and/or modified.
#!/usr/bin/env ruby
require 'english'
require 'rubocop'
ADDED_OR_MODIFIED = /A|AM|^M/.freeze
changed_files = `git status --porcelain`.split(/\n/).
select { |file_name_with_status|
file_name_with_status =~ ADDED_OR_MODIFIED
@israelb
israelb / who_is_my_mummy.sh
Created August 24, 2018 18:09 — forked from joechrysler/who_is_my_mummy.sh
Find the nearest parent branch of the current git branch
#!/usr/bin/env zsh
git show-branch -a \
| grep '\*' \
| grep -v `git rev-parse --abbrev-ref HEAD` \
| head -n1 \
| sed 's/.*\[\(.*\)\].*/\1/' \
| sed 's/[\^~].*//'
# How it works:
@israelb
israelb / dynamo_db_query_example.md
Created June 19, 2018 21:27 — forked from kenoir/dynamo_db_query_example.md
Prettied up some AWS Ruby SDK DynamoDB examples from @Integralist.

AWS query-instance_method docs

export AWS_ACCESS_KEY_ID=‘XXXX’
export AWS_SECRET_ACCESS_KEY=‘XXXX’
# ENV['AWS_ACCESS_KEY_ID']
# ENV['AWS_SECRET_ACCESS_KEY']
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
# 3. Clear 'Processed' and 'Failed' jobs