Skip to content

Instantly share code, notes, and snippets.

View Killavus's full-sized avatar

Marcin Grzywaczewski Killavus

  • Wrocław, Poland
View GitHub Profile
@Killavus
Killavus / abLh0cxH.rb
Created July 9, 2016 01:43
Created using code-blocks-to-gists.
def quux
:quux
end
@Killavus
Killavus / 6MdoJ2tk.ml
Created July 9, 2016 01:43
Created using code-blocks-to-gists.
let someArray = [1; 2; 3];;
let incremented = map (function x -> x + 1) someArray;;
@Killavus
Killavus / l3bavNsj.rb
Created July 9, 2016 01:43
Created using code-blocks-to-gists.
def interesting
[1, 2, 3].map { |x| x + 1 }
end
@Killavus
Killavus / nMjhlOAI.txt
Created July 9, 2016 01:43
Created using code-blocks-to-gists.
```ruby
def bar
:baz
end
```
@Killavus
Killavus / iCOiqnMr.rb
Created July 9, 2016 01:43
Created using code-blocks-to-gists.
class MarkdownCreator
def foo_bar
[1, 2, 3].each do |n|
puts n
end
end
end
@Killavus
Killavus / DyZiSo5C.js
Created July 9, 2016 01:43
Created using code-blocks-to-gists.
var x = 2;
var y = 2;
console.log(x + y);
dayOptions() {
const { date } = this.props;
const month = date.getMonth();
const year = date.getFullYear();
const possibleDays = makeRange(1, 31);
const actualDays = possibleDays.filter(day => {
// We take an advantage of the fact that if you
// specify the 'invalid' date like 31st of February
// it'll automatically switch to the next month.
// So new Date(2016, 1, 90) === Apr 30th 2016
class Customer < ActiveRecord::Base
after_create :send_welcome_email, unless: :auto_registered?
has_one :auto_created, dependent: :destroy
private
def send_welcome_email
CustomerMailer.welcome_email(self).deliver
end
def auto_registered?
class CustomersController < ApplicationController
# …
def create
@customer = Customer.new(customer_params)
respond_to do |format|
if @customer.save
format.html { redirect_to @customer,
notice: 'Customer was successfully created.' }
format.json { render :show, status: :created,
class Customer < ActiveRecord::Base
has_one :auto_created, dependent: :destroy
def self.register(params)
new(params).tap do |customer|
customer.save!
customer.send_welcome_email
end
end