Skip to content

Instantly share code, notes, and snippets.

View kubakrzempek's full-sized avatar

Kuba Krzempek kubakrzempek

  • Wrocław, Poland
View GitHub Profile
@kubakrzempek
kubakrzempek / migration.rb
Last active August 29, 2015 14:18
Rails and postgresql extensions
# It doesn't work...
class InstallTrigramContribPackage < ActiveRecord::Migration
def up
execute 'CREATE EXTENSION pg_trgm'
end
def down
execute 'DROP EXTENSION pg_trgm'
end
end
@kubakrzempek
kubakrzempek / question_controller.coffee
Created April 16, 2015 12:58
angular & friendly urls
angular.module('merckUnite').controller 'questionCtrl', ($scope, $state, $stateParams, Questions) ->
$scope.id = $stateParams.id
Questions.single($scope.id).success (data) ->
$scope.question = data
if $scope.question.slug != $stateParams.slug
$state.go('question',
{
id : $scope.question.id,
# Storage service
angular.module('app').service 'Storage', ($rootScope) ->
$rootScope.storage = undefined
this.keep = (ctrl, func, params...) ->
$rootScope.storage = {
ctrl: ctrl,
func: func,
params: params
@kubakrzempek
kubakrzempek / trello-css-guide.md
Created December 29, 2015 22:06 — forked from bobbygrace/trello-css-guide.md
Trello CSS Guide

Trello CSS Guide

“I perfectly understand our CSS. I never have any issues with cascading rules. I never have to use !important or inline styles. Even though somebody else wrote this bit of CSS, I know exactly how it works and how to extend it. Fixes are easy! I have a hard time breaking our CSS. I know exactly where to put new CSS. We use all of our CSS and it’s pretty small overall. When I delete a template, I know the exact corresponding CSS file and I can delete it all at once. Nothing gets left behind.”

You often hear updog saying stuff like this. Who’s updog? Not much, who is up with you?

This is where any fun you might have been having ends. Now it’s time to get serious and talk about rules.

Writing CSS is hard. Even if you know all the intricacies of position and float and overflow and z-index, it’s easy to end up with spaghetti code where you need inline styles, !important rules, unused cruft, and general confusion. This guide provides some architecture for writing CSS so it stays clean and ma

module MarketForms
Create = Dry::Validation.Form do
key(:code).required
key(:name).required
key(:countries_id).required
key(:description).required
key(:organization_id).required
key(:active).required
rule(code_organization_uniq: [:code, :organization_id]) do |code, organization_id|
facts = [
{
fact_category: {
name: "Cars",
code: "cars",
protected: false,
enabled: true,
system: true,
fact_types: [
{
@kubakrzempek
kubakrzempek / ultimate-ut-cheat-sheet.md
Created September 29, 2017 07:26 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies