Skip to content

Instantly share code, notes, and snippets.

View igneus's full-sized avatar

Jakub Pavlík igneus

View GitHub Profile
@jodosha
jodosha / Gemfile
Last active December 9, 2020 15:09
Full stack Lotus application example
source 'https://rubygems.org'
gem 'rake'
gem 'lotus-router'
gem 'lotus-controller'
gem 'lotus-view'
group :test do
gem 'rspec'
gem 'capybara'
@demisx
demisx / active_record_objects_autosave.md
Last active April 29, 2024 09:02
When Active Record Child Objects are Autosaved in Rails

belongs_to:

  1. Assigning an object to a belongs_to association does not automatically save the object. It does not save the associated object either.

has_one:

  1. When you assign an object to a has_one association, that object is automatically saved (in order to update its foreign key).
  2. In addition, any object being replaced is also automatically saved, because its foreign key will change too
  3. If either of these saves fails due to validation errors, then the assignment statement returns false and the assignment itself is cancelled.
  4. If the parent object (the one declaring the has_one association) is unsaved (that is, new_record? returns true) then the child objects are not saved. They will automatically when the parent object is saved.
@staltz
staltz / introrx.md
Last active May 20, 2024 14:59
The introduction to Reactive Programming you've been missing
@profh
profh / decode_session_cookie.rb
Last active June 23, 2021 13:25
A simple script to decode Rails 4 session cookies
@cortesben
cortesben / hg-commands.md
Last active January 9, 2024 14:53
Mercurial command cheat sheet

Mercurial Commands

Commands Description
hg pull get latest changes like git pull use flags like -u IDK why yet
hg add only for new files
hg commit add changes to commit with -m for message just like git
hg addremove adds new files and removes file not in your file system
hg incoming see changes commited by others
hg outgoing see local commits
@liverbool
liverbool / bootstrap_4_layout.html.twig
Created March 22, 2016 09:32
bootstrap_4_layout.html.twig
{% use "form_div_layout.html.twig" %}
{# Widgets #}
{% block form_widget_simple -%}
{% if type is not defined or 'file' != type %}
{%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) -%}
{% endif %}
{{- parent() -}}
{%- endblock form_widget_simple %}
@liverbool
liverbool / bootstrap_4_horizontal_layout.html.twig
Created March 22, 2016 09:32
bootstrap_4_horizontal_layout.html.twig
{% use "web:Form:bootstrap_4_layout.html.twig" %}
{# Labels #}
{% block form_label -%}
{% if label is same as(false) %}
<div class="{{ block('form_label_class') }}"></div>
{% else %}
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ block('form_label_class'))|trim}) %}
{{- parent() -}}
@linxlad
linxlad / FormErrorsSerializer.php
Last active August 18, 2023 11:20 — forked from Graceas/FormErrorsSerializer.php
Symfony 2 Form Error Serializer. May be used for AJAX form validation. Allows tree and flat array styles for errors.
<?php
namespace OpenObjects\Bundle\CoreBundle\Service;
use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapper;
use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormError;
use Symfony\Component\Validator\ConstraintViolation;
/**
@jeetsukumaran
jeetsukumaran / test1.tex
Created September 2, 2016 14:31
BibLaTeX customizations (emphasize author name when rendering bibliography, etc.)
%% emphasize author name when rendering bibliography
% Note: requires: \usepackagage{biblatex}
\newcommand{\emphasizeAuthorName}[1]{%
\DeclareNameFormat{author}{%
\edef\tempname{{#1}}%
\ifnumequal{\value{listcount}}{1}
{\ifnumequal{\value{liststop}}{1}
{\expandafter\ifstrequal\tempname{##1}{\textbf{##1\addcomma\addspace ##4\isdot}}{##1\addcomma\addspace ##4\addcomma\isdot}}
{\expandafter\ifstrequal\tempname{##1}{\textbf{##1\addcomma\addspace ##4\isdot}}{##1\addcomma\addspace ##4}}}
@glowinthedark
glowinthedark / pyqt5_pdf_viewer.py
Last active May 7, 2024 01:41
Python simple PDF viewer using PyQt5 and mozilla's pdf.js
#!/usr/bin/env python3
import sys
from pathlib import Path
from PyQt5.QtCore import *
from PyQt5.QtWebEngineWidgets import *
from PyQt5.QtWidgets import *
# REQUIREMENTS