Skip to content

Instantly share code, notes, and snippets.

Avatar
⛑️

Filip Bartuzi Bartuz

⛑️
View GitHub Profile
@Bartuz
Bartuz / component.jsx
Last active Jul 7, 2020
helper to test https://github.com/sarneeh/reaptcha How to unit test Reaptcha invisible recaptcha google jest enzyme
View component.jsx
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 Nov 18, 2021
Delete all your messages from DM or Channel in Discord
View deleteDiscordMessages.js
/*
This file is now hosted here:
https://github.com/victornpb/deleteDiscordMessages
*/
View stock-options.txt
# 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/
@khamidou
khamidou / verify.rb
Last active Sep 28, 2021
Verifying Nylas webhooks using Ruby
View verify.rb
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 Jul 22, 2021
dry-validation vs activemodel
View am_dry_validation_1.rb
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 Nov 9, 2015 — forked from JunichiIto/alias_matchers.md
List of alias matchers in RSpec 3
View alias_matchers.md

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 Oct 23, 2015
before/after filters/actions rspec testing. Credits to: http://stackoverflow.com/a/20776916/2047418
View application_controller_spec.rb
# 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 Aug 15, 2015
Merge Arrays in one with ES6 Array spread
View gist:51af798dd1e7058625f4
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 Dec 11, 2016
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.
View bench.rb
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
View capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')