Skip to content

Instantly share code, notes, and snippets.

View Bartuz's full-sized avatar
⛑️

Filip Bartuzi Bartuz

⛑️
View GitHub Profile
@Bartuz
Bartuz / component.jsx
Last active July 7, 2020 06:16
helper to test https://github.com/sarneeh/reaptcha How to unit test Reaptcha invisible recaptcha google jest enzyme
const Component = ({ onSuccess, onError, onExpire }) => {
const recapchaRef = useRef(null);
return (
<Reaptcha
ref={recapchaRef}
sitekey={RECAPTCHA_SITEKEY}
size="invisible"
badge="inline"
onRender={() => recapchaRef.current.execute()}
@victornpb
victornpb / deleteDiscordMessages.js
Last active April 16, 2024 09:32
Delete all your messages from DM or Channel in Discord
/*
This file is now hosted here:
https://github.com/victornpb/undiscord
*/
# do poczytania
https://zachholman.com/posts/fuck-your-90-day-exercise-window/
https://www.benkuhn.net/options
https://gist.github.com/yossorion/4965df74fd6da6cdc280ec57e83a202d
https://hackernoon.com/why-i-will-not-exercise-my-gitlab-stock-options-bf6f3dda62e
http://yosefk.com/blog/stock-options-a-balanced-approach.html
https://blog.alexmaccaw.com/an-engineers-guide-to-stock-options
https://www.nceo.org/articles/stock-options-restricted-phantom-sars-espps
http://robertheaton.com/2015/11/02/how-to-value-your-startup-stock-options/
@marcotc
marcotc / sidekiq_retry_time.csv
Created February 14, 2017 18:16
Sidekiq retry exponential backoff formula times
Retry count Retry Time Total Cumulative Time Total Cumulative Days
0 0:00:00 0:00:00 0.0
1 0:00:16 0:00:16 0.0
2 0:00:31 0:00:47 0.0
3 0:01:36 0:02:23 0.0
4 0:04:31 0:06:54 0.0
5 0:10:40 0:17:34 0.0
6 0:21:51 0:39:25 0.0
7 0:40:16 1:19:41 0.1
8 1:08:31 2:28:12 0.1
@khamidou
khamidou / verify.rb
Last active September 28, 2021 13:20
Verifying Nylas webhooks using Ruby
require 'openssl'
# verify_webhook: check that a webhook was sent by a Nylas server.
# params:
# - request: the request object you get from Rails,
# - nylas_app_secret: your app secret.
def verify_webhook(request, nylas_app_secret)
digest = OpenSSL::Digest.new('sha256')
data = request.body.read
digest = OpenSSL::HMAC.hexdigest(digest, nylas_app_secret, data)
@solnic
solnic / am_dry_validation_1.rb
Last active May 21, 2022 13:42
dry-validation vs activemodel
require 'benchmark/ips'
require 'active_model'
require 'virtus'
require 'dry-validation'
require 'dry/validation/schema/form'
class User
include ActiveModel::Validations
include Virtus.model
@Bartuz
Bartuz / alias_matchers.md
Created November 9, 2015 11:29 — forked from JunichiIto/alias_matchers.md
List of alias matchers in RSpec 3

This list is based on aliases_spec.rb.

You can see also Module: RSpec::Matchers API.

matcher aliased to description
a_truthy_value be_truthy a truthy value
a_falsey_value be_falsey a falsey value
be_falsy be_falsey be falsy
a_falsy_value be_falsey a falsy value
@Bartuz
Bartuz / application_controller_spec.rb
Created October 23, 2015 16:37
before/after filters/actions rspec testing. Credits to: http://stackoverflow.com/a/20776916/2047418
# spec/controllers/application_controller_spec.rb
require 'spec_helper'
describe ApplicationController do
describe 'class' do
it { has_before_filters(:authenticate_user) }
end
end
@yesvods
yesvods / gist:51af798dd1e7058625f4
Created August 15, 2015 11:13
Merge Arrays in one with ES6 Array spread
const arr1 = [1,2,3]
const arr2 = [4,5,6]
const arr3 = [...arr1, ...arr2] //arr3 ==> [1,2,3,4,5,6]
@paneq
paneq / bench.rb
Last active December 11, 2016 13:00
cost of using exceptions for control flow compared to one SQL statement (ruby 2.1.4, rails 4.1.7, sqlite) for rails-refactoring.com . Development mode executed in rails console.
require 'benchmark'
ActiveRecord::Base.logger = nil
Benchmark.bmbm do |bench|
bench.report("SQL query") do
1000.times { Whatever.count }
end
bench.report("exception hit") do