Skip to content

Instantly share code, notes, and snippets.

View Bartuz's full-sized avatar
⛑️

Filip Bartuzi Bartuz

⛑️
View GitHub Profile
@them0nk
them0nk / haml_cheatsheet.haml
Created March 25, 2012 08:39
haml cheatsheet
!!! strict
!!! XML
%html
-# Self closing tags
%img{:src => "happy.jpg"}/
%div.myclass
.myclass1
class NestedAttributesForStrategy
def association(runner)
runner.run
end
def result(evaluation)
evaluation.object.tap do |instance|
evaluation.notify(:after_build, instance)
return attributes(instance)
end
@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()}
@jandudulski
jandudulski / .vimrc
Last active August 10, 2020 10:31
How to configure your editor to automatically strip trailing whitespaces and keep new line at the end of file?
if has("autocmd")
" remove trailing white spaces
autocmd BufWritePre * :%s/\s\+$//e
endif
@myronmarston
myronmarston / explanation.md
Last active October 22, 2020 18:16
Explanation for why `its` will be removed from rspec-3

its isn't core to RSpec. One the of the focuses of RSpec is on the documentation aspects of tests. Unfortunately, its often leads to documentation output that is essentially lies. Consider this spec:

User = Struct.new(:name, :email)

describe User do
  subject { User.new("bob") }
  its(:name) { should == "bob" }
end
# 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/
@otaviomedeiros
otaviomedeiros / validate_with_matcher.rb
Created March 14, 2012 00:05
RSpec matcher for validates_with
# RSpec matcher for validates_with.
# https://gist.github.com/2032846
# Usage:
#
# describe User do
# it { should validate_with CustomValidator }
# end
RSpec::Matchers.define :validate_with do |validator|
match do |subject|
@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
@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]