Skip to content

Instantly share code, notes, and snippets.

View mathiasschopmans's full-sized avatar

Mathias Schopmans mathiasschopmans

View GitHub Profile
@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 / 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 / hue-api.md
Last active February 8, 2020 18:44
HUE Remote-API summary + buildlamp script
/*
* RGBa-Mixin with fallback (http://css-tricks.com/rgba-browser-support/)
*/
=transparent-backgound($color: #000, $value:0.5)
$start: "rgb("
$end: ")"
background: #{$start}red($color), green($color), blue($color)#{$end}
background: rgba($color, $value)
<?
/*
Plugin Name: Meta-Boxes
Plugin URI:
Description: Bilder, Fotos, Beiträge, etc.
Version: 2.0
Author: Rheinschafe - Mathias Schopmans
/* ----------------------------------------------*/
$new_meta_boxes =
@mathiasschopmans
mathiasschopmans / Wordpress: Get Latest Tweet by Username
Created October 1, 2010 17:14
A little Script that gets the latest Tweets and chaches it via Transient-API
/**
* Get the latest Tweet Text by Username
*
* @uses Transient - API for chaching
* @copyright Mathias Schopmans - 10/2010
*
* @param string $username: Twitter Username
*/
function get_last_tweet($username='nasenmann'){
javascript:var%20s=document.createElement('script');s.setAttribute('src',%20'http://jquery.com/src/jquery-latest.js');document.getElementsByTagName('body')[0].appendChild(s);alert('thank%20you%20for%20using%20jquery!');void(s);
@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"