Skip to content

Instantly share code, notes, and snippets.

View Bartuz's full-sized avatar
⛑️

Filip Bartuzi Bartuz

⛑️
View GitHub Profile
@Bartuz
Bartuz / rails_confirm.js.coffee
Created December 9, 2015 09:28 — forked from da4nik/rails_confirm.js.coffee
Change standart rails confirm dialog to custom
Call:
Set custom options:
= link_to talk, method: :delete, class: 'icon-close', data: {confirm: "Вы действительно хотите удалить всю переписку с данным пользователем?", confirm_options: {title: 'Удалить все сообщения', yes: 'Да', no: 'Нифига'}}, remote: true
or standart rails way
= link_to talk, method: :delete, class: 'icon-close', data: {confirm: "Вы действительно хотите удалить всю переписку с данным пользователем?"}, remote: true
@Bartuz
Bartuz / bench.rb
Created January 25, 2016 10:43 — forked from paneq/bench.rb
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
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:

Keybase proof

I hereby claim:

  • I am bartuz on github.
  • I am fbartuzi (https://keybase.io/fbartuzi) on keybase.
  • I have a public key whose fingerprint is 3434 16BB 7526 A36F 7B75 0DF1 22A4 EBE5 92DE FB89

To claim this, I am signing this object:

@Bartuz
Bartuz / service.rb
Created November 25, 2016 07:15
refactoring
#before
def initialize(options = {})
@type = options.fetch(:destination_type) { CARD_TO_CARD }
@options = options
end
#after
def initialize(destination_type: CARD_TO_CARD, **options)
@type = destination_type
@options = options
Jeśli:
1. Usuniesz klucz z web appki phraseappa
2. $ yarn phraseapp:push
3. Klucz pojawia sie ponownie we phareappie
Jeśli <— Prawdiłowe flow
1. Usuniesz klucz z phraseappa
2. $ yarn phraseapp:pull
3. $ yarn phraseapp:push
4. klucz znika z plików .json i z web appki phraseappa
@Bartuz
Bartuz / .Title
Created June 2, 2017 07:16 — forked from congjf/.Title
Using MongoDB in golang with mgo
Using MongoDB in golang with mgo
@Bartuz
Bartuz / test.rb
Created September 24, 2017 18:43
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
# Activate the gem you are reporting the issue against.
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()}