Skip to content

Instantly share code, notes, and snippets.

View mathiasschopmans's full-sized avatar

Mathias Schopmans mathiasschopmans

View GitHub Profile
@mathiasschopmans
mathiasschopmans / commit-msg
Last active March 23, 2023 07:37
Git commit hook using bash to validate the commit message against conventional commits
#!/bin/bash
# Get the commit message
commit_msg=$(cat $1)
# Define a regex pattern to match the conventional commit message format
pattern='^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([a-z]+\))?!?: .+$'
# Test if the commit message matches the pattern
if ! [[ $commit_msg =~ $pattern ]]; then
@mathiasschopmans
mathiasschopmans / pluckRecursive.ts
Created January 2, 2023 12:49
pluck recursive attribute with native methods
export function pluckRecursive(input: any, prop: string, collect = []) {
collect = collect || [];
if (!input) return collect;
if (Array.isArray(input)) {
input.forEach(function (value) {
pluckRecursive(value, prop, collect);
})
} else if (typeof input === 'object') {
@mathiasschopmans
mathiasschopmans / workflow.yml
Created July 30, 2021 08:14
GitHub Action to test, build, push & deploy PHP based application
name: CI
on:
push:
branches-ignore:
- 'dependabot/**'
tags:
- 'v*'
pull_request:
branches-ignore:
@mathiasschopmans
mathiasschopmans / ObjectSize.php
Created December 4, 2016 13:52
Sort various (clothing) sizes in an array
<?php
class ObjectSize {
protected static $sizes = [
'xxxxl',
'xxxl',
'xxl',
'xl',
'l',
@mathiasschopmans
mathiasschopmans / hue-api.md
Last active February 8, 2020 18:44
HUE Remote-API summary + buildlamp script
@mathiasschopmans
mathiasschopmans / capybara.rb
Created May 4, 2015 13:07
Ignore Capybara SSL verification (https errors) and add Capybara Screenshot functionality
Capybara.register_driver :webkit_ignore_ssl do |app|
Capybara::Webkit::Driver.new(app).tap {|d| d.browser.ignore_ssl_errors }
end
Capybara::Screenshot.register_driver(:webkit_ignore_ssl) do |driver, path|
driver.save_screenshot(path)
end
Capybara.javascript_driver = :webkit_ignore_ssl
Capybara.default_driver = :webkit_ignore_ssl
@mathiasschopmans
mathiasschopmans / neopixelring.ino
Created March 4, 2015 18:46
neopixel ring demo
#include <Adafruit_NeoPixel.h>
#include <avr/power.h>
#define PIN 0
Adafruit_NeoPixel strip = Adafruit_NeoPixel(24, PIN);
// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel. Avoid connecting
// on a live circuit...if you must, connect GND first.
@mathiasschopmans
mathiasschopmans / _formhelper.jade
Last active September 9, 2015 08:01
Jade form-helpers. Can be used with bootstrap
mixin input(label, options)
- var defaults = {"tag":"input", "type":"text", "labelClass":"form-label", "name":sanitize(label), "placeholder":null, "value":null, "id":sanitize(label).substring(0, 10) + "-" + randomString(), "tabindex":null}
- var input = extend({}, defaults, {"label":label, "required":attributes.required}, options, attributes)
- var baseClass = input.type == "hidden" ? null : "form-control"
- delete attributes.required
if input.placeholder === true
- input.placeholder = label
if input.type == "hidden"
@mathiasschopmans
mathiasschopmans / inline-sprites.sass
Created August 5, 2014 10:02
Try to use compass' inline-image() with generated sprites.
$default-sprite-dimensions: true
$default-sprite-base-class: ".is"
@import "images/sprites/default/*.png"
@include all-default-sprites($prefix:"is")
.is
background-image: inline-image($default-sprites)
+inline-block
+hide-text
<?
/*
Plugin Name: Meta-Boxes
Plugin URI:
Description: Bilder, Fotos, Beiträge, etc.
Version: 2.0
Author: Rheinschafe - Mathias Schopmans
/* ----------------------------------------------*/
$new_meta_boxes =