Skip to content

Instantly share code, notes, and snippets.

@romansklenar
romansklenar / gwi.puml
Created Dec 18, 2019
GWI puml definition
View gwi.puml
!define GWI_BG_COLOR #d4007b
!define GWI_BORDER_COLOR #abcdef
skinparam rectangle<<gwi_system>> {
StereotypeFontColor ELEMENT_FONT_COLOR
FontColor #ELEMENT_FONT_COLOR
BackgroundColor GWI_BG_COLOR
BorderColor GWI_BORDER_COLOR
}
@romansklenar
romansklenar / db.rake
Created Apr 1, 2015
Useful rake task for maintain PostgreSQL databases
View db.rake
# lib/tasks/db.rake
namespace :db do
desc 'Maintains database by running command as ANALYZE, VACUUM and REINDEX'
task maintain: :environment do
verbose = ENV['VERBOSE'].present?
connection = ActiveRecord::Base.connection
puts "Maintaining database #{connection.current_database} ..."
connection.execute("VACUUM FULL #{'VERBOSE' if verbose}")
@romansklenar
romansklenar / devise.cs.yml
Last active Aug 29, 2015 — forked from jnv/devise.cs.yml
Czech translation for Devise 3.4
View devise.cs.yml
# Additional translations at http://github.com/plataformatec/devise/wiki/I18n
cs:
errors:
messages:
already_confirmed: 'byl již potvrzen, prosím, zkuste se přihlásit'
confirmation_period_expired: 'musí být potvrzen během %{period}, požádejte prosím o nový'
expired: 'vypršel, požádejte prosím o nový'
not_found: 'nenalezen'
not_locked: 'nebyl uzamčen'
@romansklenar
romansklenar / commands.sh
Created Apr 26, 2014
Rails 4.1 application update diff
View commands.sh
rails _3.2.15_ new rails_update --database=postgresql --skip-bundle
rails _4.1.0_ new rails_update --database=postgresql --skip-bundle
View level_1.rb
class Player
def play_turn(warrior)
warrior.walk!
end
end
@romansklenar
romansklenar / crosstab.sql
Last active Sep 13, 2020
PostgreSQL "pivot table" example using tablefunc extension
View crosstab.sql
CREATE EXTENSION tablefunc;
CREATE TABLE sales(year int, month int, qty int);
INSERT INTO sales VALUES(2007, 1, 1000);
INSERT INTO sales VALUES(2007, 2, 1500);
INSERT INTO sales VALUES(2007, 7, 500);
INSERT INTO sales VALUES(2007, 11, 1500);
INSERT INTO sales VALUES(2007, 12, 2000);
INSERT INTO sales VALUES(2008, 1, 1000);
INSERT INTO sales VALUES(2009, 5, 2500);
@romansklenar
romansklenar / 20131118172653_create_transactional_items_view.rb
Last active Jul 3, 2017
Using PostgreSQL's materialized views as background for ActiveRecord models for flexible statistics
View 20131118172653_create_transactional_items_view.rb
# db/migrate/20131118172653_create_transactional_items_view.rb
class CreateTransactionalItemsView < ActiveRecord::Migration
def up
select_sql = File.open("#{Rails.root}/db/migrate/20131118172653_create_transactional_items_view.sql", 'r') { |f| f.read }
# for materialized view:
view_sql = "CREATE MATERIALIZED VIEW transactional_items AS (#{select_sql})"
# for normal view:
view_sql = "CREATE VIEW transactional_items AS (#{select_sql})"
@romansklenar
romansklenar / rails_proficiency.txt
Created Dec 4, 2013
Proficiency requirements for Rails developer
View rails_proficiency.txt
Senior (enterprise)
Analyse and profile an application for performance and memory issues
Analyses and profile an application for security issues
Understand database modeling and query analysis
Tune a production deployment (Passenger, Thin, Apache etc)
Understand and use Ruby metaprogramming
Mentoring skills
Communication skills
Planning and Estimation
@romansklenar
romansklenar / REAME.md
Last active Feb 19, 2020
How to set up your VPS with Chef Solo
View REAME.md

How to set up your VPS with Chef Solo

1. What is it?

There are many different provisioning tools out there, the most popular of which are Chef and Puppet. Chef uses Ruby, Puppet uses a DSL (Domain Specific Language), there are others that use simple bash too, but today we're going to focus on Chef Solo.

2. Dependencies

To get Chef working properly on your local machine you need a few things.

Make sure you use Ruby 1.9.x and not Ruby 2.x as you will get errors with the json 1.6.1 gem on 2.x. Use rbenv or RVM to manage several different Rubies on the one machine.

You can’t perform that action at this time.