Skip to content

Instantly share code, notes, and snippets.

Avatar

Maxime Bréhin mbrehin

View GitHub Profile
@mbrehin
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 {
defaultMarkdownParser,
defaultMarkdownSerializer,
schema,
} from 'prosemirror-markdown'
import { exampleSetup } from 'prosemirror-example-setup'
import 'prosemirror-view/style/prosemirror.css'
@mbrehin
mbrehin / update
Last active Nov 24, 2017
Git `update` hook (server side)
View update
#!/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 = []
View rails_concern_custom_validation.md

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 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 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 May 21, 2020
Microsoft Office, Open Office, PDF diffs with Git
View msoffice_ooffice_pdf_diffs_with_git.md

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 Dec 11, 2015
Rails SimpleForm custom input for schedule with materialize.css
@mbrehin
mbrehin / pricing_grid.png
Last active Dec 11, 2015
Rails SimpleForm custom input for pricing grids with materialize.css
You can’t perform that action at this time.