Skip to content

Instantly share code, notes, and snippets.

Alexander cutalion

Block or report user

Report or block cutalion

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:4b2860f3ab0f03d9ce92c09efb6ee7ad
# Пусть админы могут удалять комментарии
# и мы уведомляем кого-нибудь, что комментарий был удален
class DeleteComment
def call(comment)
transaction do
comment.delete!
user.decrement(:comments_count)
end
@cutalion
cutalion / Gemfile
Last active Mar 5, 2018
ROM sql-memory combine
View Gemfile
source "https://rubygems.org"
gem 'sqlite3'
gem 'dry-logic'
gem 'dry-types'
gem 'rom'
gem 'rom-sql'
gem 'pry'
View keybase.md

Keybase proof

I hereby claim:

  • I am cutalion on github.
  • I am cutalion (https://keybase.io/cutalion) on keybase.
  • I have a public key ASA_TnJvySK6SN95G7RdeuuJi2XAcunV37SabTXa2IwBcAo

To claim this, I am signing this object:

View test.rb
require 'rom'
require 'rom-repository'
require 'rom-sql'
require 'pry'
module Entity
end
config = ROM::Configuration.new(:sql, 'sqlite::memory')
conn = config.gateways[:default].connection
@cutalion
cutalion / Gemfile
Last active Sep 14, 2017
ROM issue with polymorphic association and aggregation
View Gemfile
source "https://rubygems.org"
gem 'sqlite3'
gem 'dry-logic', github: 'dry-rb/dry-logic', branch: 'master'
gem 'dry-types', github: 'dry-rb/dry-types', branch: 'master'
gem 'rom', github: 'rom-rb/rom', branch: 'master'
gem 'rom-sql', github: 'rom-rb/rom-sql', branch: 'master'
gem 'pry'
View main.go
package main
import (
"fmt"
"github.com/julienschmidt/httprouter"
"net/http"
"log"
"database/sql"
_ "github.com/lib/pq"
"encoding/json"
View curry.rb
class SuperCurry
def call(a, b)
puts "#{a} + #{b} = #{a + b}"
end
def curry(*args)
arity = method(:call).arity
curried_args = args
if curried_args.size == arity
View thread.rb
@start = false
t1 = Thread.new do
while !@start
sleep 0.001
end
puts 'started 1'
end
View monty_hall.rb
N = 10_000
matched1 = 0
matched2 = 0
N.times do
seq = [1, 0, 0].shuffle
guess = rand(3)
matched1 += 1 if seq[guess].eql?(1)
@cutalion
cutalion / .rspec
Last active Apr 7, 2016
Arduino formatter for rspec
View .rspec
--color
--require spec_helper
--format Fuubar
--format ArduinoFormatter
You can’t perform that action at this time.