Skip to content

Instantly share code, notes, and snippets.

@romansklenar
romansklenar / tollers-sk.txt
Created December 15, 2023 22:41
List of tollers born in and imported to 🇸🇰
Abby's Ninja Cole z Jesenicke smecky
Abby's Ninja Jay z Jesenicke smecky
Alexa Cherubic Soul
Alfie Amadeus Cherubic Soul
Alice Tipota Red Fox
Aliya Cherubic Soul
Amalia Cherubic Soul
Amalka Tipota Red Fox
Amalka z Kotarskych luk
Amber Cherubic Soul
@romansklenar
romansklenar / README.md
Last active July 11, 2023 23:12
Rails concerns

What is it?

Collection of concerns for your Rails application

Installation

Copy to your app/models/concerns directory

@romansklenar
romansklenar / Inflector.php
Created December 11, 2009 21:42
Ruby on Rails Inflector port to PHP
<?php
/**
* The Inflector transforms words from singular to plural, class names to table names, modularized class names to ones without, and class names to foreign keys.
* This solution is partitionaly based on Ruby on Rails ActiveSupport::Inflector (c) David Heinemeier Hansson. (http://rubyonrails.org), MIT license
* @see http://api.rubyonrails.org/classes/Inflector.html
*
* @author Roman Sklenář
* @copyright Copyright (c) 2009 Roman Sklenář (http://romansklenar.cz)
@romansklenar
romansklenar / crosstab.sql
Last active February 1, 2023 18:46
PostgreSQL "pivot table" example using tablefunc extension
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 / dependent_select.js.coffee
Last active June 25, 2020 00:05
Unobtrusive RESTful dynamic/dependent select menus for Ruby on Rails 3 and jQuery
# Unobtrusive RESTful dynamic/dependent select menus for Ruby on Rails 3 and jQuery
#
# USAGE (with Formtastic):
#
# match = form.object
# seasons = Season.all
# rounds = match.season.nil? ? Array.new : match.season.rounds
#
# form.input :season, :as => :select, :collection => seasons, :include_blank => false, :prompt => true, :input_html => { :id => :season_id }
# form.input :round, :as => :select, :collection => rounds, :include_blank => false, :prompt => true, :input_html => { :id => :round_id,
@romansklenar
romansklenar / REAME.md
Last active February 19, 2020 14:14
How to set up your VPS with Chef Solo

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.

@romansklenar
romansklenar / gwi.puml
Created December 18, 2019 19:28
GWI puml definition
!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 April 1, 2015 18:08
Useful rake task for maintain PostgreSQL databases
# 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 / Blob.php
Created August 15, 2010 03:36
Doctrine 2, BLOB datatype implementation
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
@romansklenar
romansklenar / rails_proficiency.txt
Created December 4, 2013 20:11
Proficiency requirements for Rails developer
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