Skip to content

Instantly share code, notes, and snippets.

View mjot's full-sized avatar

Martin Jäcke mjot

View GitHub Profile
@mjot
mjot / JS - Viewport Aspect Ratio Helper
Created August 22, 2023 08:15
This JavaScript snippet provides utility to determine and log the aspect ratio of the current browser viewport. Key functionalities include: Greatest Common Divisor (GCD) Calculation: A helper function to determine the GCD of two numbers, which aids in simplifying the aspect ratio. Aspect Ratio Determination: Computes the simple aspect ratio (e.…
(function() {
/**
* Calculate the greatest common divisor (GCD) of two numbers.
* @param {number} a - First number
* @param {number} b - Second number
* @returns {number} - The GCD of the two numbers
*/
function gcd(a, b) {
return (b === 0) ? a : gcd(b, a % b);
}
#!/bin/sh -e
# dont echo anything, comment out if needed
echo() { :; }
# DB settings
USER="user"
DATABASE="db"
HOST="127.0.0.1"
DIRECTORY="dumps"
@mjot
mjot / update-plugins.sh
Last active April 10, 2019 07:46
update each wordpress plugin with wp-cli and commit each update with plugin name and version in commit message
#!/usr/bin/env bash
wp () {
command /usr/local/bin/php7.2.11-cli ~/wp-cli/wp-cli.phar "$@"
}
for plugins in $(wp plugin list --path='../html/' --update=available --fields=name,version,update_version --format=csv);
do
IFS=', ' read -r -a plugin <<< "$plugins"
@mjot
mjot / functions.php
Last active November 27, 2018 20:18 — forked from hitautodestruct/readme.md
Generate a custom structure for Wordpress menus.
function wecGenerateMenu($menu_name) {
$menu = wp_get_nav_menu_object($menu_name);
$locations = get_nav_menu_locations();
$menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
$menuitems = wp_get_nav_menu_items( $menu->term_id, array( 'order' => 'DESC' ) );
$count = 0;
$content_ = "";
$submenu = false;
@mjot
mjot / Gulpfile.js
Last active October 25, 2017 08:35 — forked from shyim/Gulpfile.js
Gulp Shopware with browser-sync
function basename(path) {
return path.split('/').reverse()[0];
}
var gulp = require('gulp'),
less = require('gulp-less'),
sourcemaps = require('gulp-sourcemaps');
concat = require('gulp-concat'),
rename = require('gulp-rename'),
path = require('path'),
<?php
namespace ShyimCron;
use Shopware\Components\Plugin;
use Shopware\Components\Plugin\Context\InstallContext;
use Shopware\Components\Plugin\Context\UninstallContext;
class ShyimCron extends Plugin {
public static function getSubscribedEvents()
{
return [
'Shopware_CronJob_MyCoolCron' => 'MyCoolCronRun'
@mjot
mjot / Wordpress - WYSIWYG custom classes
Created November 17, 2016 10:10
Add Custom Classes to the styleselect Dropdown from the WYSIWYG Editor
/**
* Custom Classes for the wordpress WYSIWYG editor
*/
add_filter( 'tiny_mce_before_init', 'custom_mce_before_init' );
function custom_mce_before_init( $settings ) {
$style_formats = array(
array(
'title' => 'Title for style',
'selector' => 'li',
@mjot
mjot / Wordpress - Hide Add Media Button
Last active November 17, 2016 10:06 — forked from jfcode/Hide Add Media Button
Hide WYSIWYG - Add Media Button
/**
* Remove Add Media Button from the WYSIWYG editor
*/
function RemoveAddMediaButtons(){
remove_action( 'media_buttons', 'media_buttons' );
}
add_action('admin_head', 'RemoveAddMediaButtons');