Skip to content

Instantly share code, notes, and snippets.

mbrehin / prosemirror.js
Created Jan 26, 2018
Prosemirror example: replacing form textareas
View prosemirror.js
import { EditorState } from 'prosemirror-state'
import { EditorView } from 'prosemirror-view'
import {
} from 'prosemirror-markdown'
import { exampleSetup } from 'prosemirror-example-setup'
import 'prosemirror-view/style/prosemirror.css'
mbrehin / update
Last active Nov 24, 2017
Git `update` hook (server side)
View update
# 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 / pre-commit
Last active Jan 31, 2019
Git hooks: pre-commit
View 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
# 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 /
Last active Feb 23, 2022
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 / schedule.png
Last active Dec 11, 2015
Rails SimpleForm custom input for schedule with materialize.css
mbrehin / pricing_grid.png
Last active Jan 3, 2021
Rails SimpleForm custom input for pricing grids with materialize.css