Skip to content

Instantly share code, notes, and snippets.

@mbie
mbie / step_1.rb
Created November 3, 2019 22:18
RRUG#24 - Refactoring complex condition classes
# Retry payment conditions:
# - feature flag is enabled
# - only credit card and bank payments
# - there is no other payment processing for that customer
module Payments
class Retry
def call(payment:)
return unless retry_payment?(payment)
payment.retry! # or @retry_service.call(payment: payment), etc
@mbie
mbie / 1.rb
Last active November 4, 2018 19:33
RRUG#16 Snippets
desc 'Rake task description'
task :name_of_task do
# Your code goes here
end
#> rake name_of_task
@mbie
mbie / twitter_stats.rb
Created April 4, 2017 20:59
Simple ruby script for getting stats for tweets
require 'twitter'
class TwitterClient
def self.client
Twitter::REST::Client.new do |config|
config.consumer_key = ""
config.consumer_secret = ""
config.access_token = ""
config.access_token_secret = ""
end
@mbie
mbie / anagram_ruby
Created February 10, 2017 13:48
Simple ruby script which creates anagram for words in a sentence.
string = "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program"
output = string.split.map do |word|
if word.length > 3
word[1..-2] = word[1..-2].chars.shuffle.join
end
word
end.join(" ")
puts output # Msot good paegrrmorms do pnimgormarg not bseuace they epcxet to get piad or get aaudliotn by the pbcilu, but buseace it is fun to praogrm
@mbie
mbie / rails_grils_sonic_pi_snippet
Created September 19, 2016 21:54
RailsGirls Rzeszów 2016 - SonicPi snippet
live_loop :beat do
index = tick
4.times do
sample :bd_klub, cutoff: 120
sleep 0.5
end
sample :drum_cymbal_soft if (index % 2).zero?
end
with_fx :distortion do
@mbie
mbie / sublime_preferences
Last active March 1, 2017 14:16
Sublime 3 user settings
{
"bold_folder_labels": true,
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"highlight_line": true,
"highlight_modified_tabs": true,
"ignored_packages":
[
"Vintage"
],