Skip to content

Instantly share code, notes, and snippets.

@mbrehin
mbrehin / gitconfig.ini
Last active October 11, 2024 04:31 — forked from tdd/gitconfig.ini
Nice, useful global Git configuration
# Put this in your ~/.gitconfig or ~/.config/git/config
# Windows users: "~" is your profile's home directory, e.g. C:\Users\<YourName>
[user]
name = Your Full Name
email = your@email.tld
[color]
# Enable colors in color-supporting terminals
ui = auto
[alias]
aliases = !git config --get-regexp alias | sed -re 's/alias\\.(\\S*)\\s(.*)$/\\1 = \\2/g'
@mbrehin
mbrehin / prosemirror.js
Created January 26, 2018 08:59
Prosemirror example: replacing form textareas
import { EditorState } from 'prosemirror-state'
import { EditorView } from 'prosemirror-view'
import {
defaultMarkdownParser,
defaultMarkdownSerializer,
schema,
} from 'prosemirror-markdown'
import { exampleSetup } from 'prosemirror-example-setup'
import 'prosemirror-view/style/prosemirror.css'
@mbrehin
mbrehin / update
Last active November 24, 2017 13:43
Git `update` hook (server side)
#!/usr/bin/ruby
# Enforce custom commit message format
def check_message_format(refname, oldrev, newrev)
message_format_regex = /\[ref: (\d+)\]/
# You would probably have to adjust the way you're retrieving user identity.
# You can also load user identity from each analysed commit.
user = ENV['USER']
# Initialize empty map to store errors
errors = []

I was looking model generic custom validations. I ended up with something that I thought could be shared, including generic tests.

First, set up the concern app/models/concern/my_concern.rb. Please note that we don't define the validate_my_field into a ClassMethods module.

module MyConcern
  extend ActiveSupport::Concern
@mbrehin
mbrehin / pre-commit
Last active January 31, 2019 08:53
Git hooks: pre-commit
#! /bin/bash
# If you encounter any error like `declare: -A: invalid option`
# then you'll have to upgrade bash version to v4.
# For Mac OS, see http://clubmate.fi/upgrade-to-bash-4-in-mac-os-x/
# Hash using its key as a search Regex, and its value as associated error message
declare -A PATTERNS;
PATTERNS['^[<>|=]{4,}']="You've got leftover conflict markers";
PATTERNS['focus:\s*true']="You've got a focused spec";
@mbrehin
mbrehin / msoffice_ooffice_pdf_diffs_with_git.md
Last active November 23, 2023 12:55
Microsoft Office, Open Office, PDF diffs with Git

Sometimes when working with Git you'd like to commit binary files.
But those files won't have clean comparisons with Git standard diff command.
Fortunately Git is a great tool that comes with a lot of possibilities…

MS Office

If, as a developer, you are under company constraints and must use MS Office,
you'll encounter some issues when trying to diff MS Office files.

Maybe you're asking yourself: what's the problem with that?

@mbrehin
mbrehin / schedule.png
Last active December 11, 2015 15:26
Rails SimpleForm custom input for schedule with materialize.css
schedule.png
@mbrehin
mbrehin / pricing_grid.png
Last active January 3, 2021 18:22
Rails SimpleForm custom input for pricing grids with materialize.css
pricing_grid.png