Skip to content

Instantly share code, notes, and snippets.

@lcmen
lcmen / script.sh
Last active April 7, 2017 11:26
[Generate CSR for SSL] Shows how to generate CSR for SSL certificate. #tags: shell
openssl req -new -newkey rsa:2048 -nodes -keyout example.key -out example.csr
# For common name enter full domain, for wildcard use *.example.com format
# If you received bundle separately from root then you need to combine them:
cat domain.crt domain.sa-bundle >> domain-bundle.crt
# Verify cert
openssl s_client -connect foo.example.com:443 < /dev/null | openssl x509 -text
@lcmen
lcmen / rich_domain_models2.md
Created November 14, 2015 13:30 — forked from vsavkin/rich_domain_models2.md
Building Rich Domain Models in Rails (revision 2)

Building Rich Domain Models in Rails.

Part 1. Decoupling Persistence.

Abstract

Domain model is an effective tool for software development. It can be used to express really complex business logic, and to verify and validate the understanding of the domain among stakeholders. Building rich domain models in Rails is hard. Primarily, because of Active Record, which doesn't play well with the domain model approach.

One way to deal with this problem is to use an ORM implementing the data mapper pattern. Unfortunately, there is no production ready ORM doing that for Ruby. DataMapper 2 is going to be the first one.

Another way is to use Active Record just as a persistence mechanism and build a rich domain model on top of it. That's what I'm going to talk about in this article.

@lcmen
lcmen / yymmdd.rb
Last active June 26, 2017 17:46 — forked from sshaw/yymmdd.rb
[Ruby: DSL extension for date parsing] Small DSL for idiomatic date parsing and formatting in Ruby. tags: ruby
require "date"
# Usage:
#
# include YYMMDD
# date = Date.today
#
# puts yy/mm
# puts ymd(411207)
# puts yyyy.mm.dd(date)
@lcmen
lcmen / capybara cheat sheet.rb
Last active June 26, 2017 17:48 — forked from zhengjia/capybara cheat sheet
[Capybara: cheatsheet] All possible methods to interact with page using Capybara. #tags: ruby, rails
# Navigating
visit('/projects')
visit(post_comments_path(post))
# Clicking links and buttons
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@lcmen
lcmen / controller.js
Last active June 27, 2017 11:28
[Backbone: base Marionette controller] Base controller that I use in my marionette.js applications. #tags: backbone.js
Controller.Base = function() {
function Controller(options) {
options = options || {};
this.region = options.region;
Marionette.Controller.call(this, options);
}
Controller.extend = Marionette.Controller.extend;
_.extend(Controller.prototype, Marionette.Controller.prototype);