Skip to content

Instantly share code, notes, and snippets.

View scrobbleme's full-sized avatar

Adrian Mörchen scrobbleme

View GitHub Profile
@scrobbleme
scrobbleme / mailpoet_change_column_sizes.php
Created April 2, 2020 14:39
Mailpoet: Change column sizes
<?php
/**
* This will replace the default values with new ones, within the rendered content of newsletters
*/
add_filter( 'mailpoet_rendering_post_process', function ( $content ) {
$max_width = 900;
$width_mapping = [
660 => $max_width,
330 => abs( $max_width / 2 ),
220 => abs( $max_width / 3 ),
@scrobbleme
scrobbleme / nextgen_singlepic_replacement.php
Created September 6, 2016 08:38
A simple shortcode to replace NextGens singlepic shortcode. You still need to have the nextgen tables within your database.
<?php
/**
* This is a replacement for NextGens "singlepic" shortcode
*/
add_shortcode('singlepic', 'render_shortcode_nextgen_singlepic_replacement');
function render_shortcode_nextgen_singlepic_replacement($attributes = array()) {
/** @global wpdb $wpdb */
@scrobbleme
scrobbleme / wpml_get_link_for_language.php
Last active July 14, 2016 06:38
Shortcode to generate a link for a specific language for the given page
@scrobbleme
scrobbleme / wordpress_anonymize_users.sql
Last active May 25, 2021 11:53
A collection of database statemens to anomyze users within WordPress.
--
-- Requirements:
-- * Users won't get any emails, when doing some test
-- * We get all emails
--
START TRANSACTION;
-- You may set this to the correct value, if you get error #1267
-- SET collation_connection = 'utf8_general_ci';
@scrobbleme
scrobbleme / purge.groovy
Created November 6, 2014 10:05
Jenkins - Remove old builds from Jenkins from all Jobs
for(item in Jenkins.instance.items) {
println("Deleting builds of job "+item.name)
counter = 1
for(build in item.getBuilds()){
if(counter > 5){
println("Delete " + build.number)
try{
build.delete()
}catch(Exception e){
println(e.getMessage())
@scrobbleme
scrobbleme / fix_wordpress_table_prefix.sql
Created June 14, 2014 20:36
Fix WordPress table prefix within the database
-- Source: http://wordpress.org/support/topic/changed-table-prefix-got-insufficient-permissions-error#post-713055
UPDATE new_usermeta
SET meta_key = REPLACE(meta_key,'old_','new_');
UPDATE new_options
SET option_name = REPLACE(option_name,'old_','new_');
@scrobbleme
scrobbleme / Jenkins_-_git_gc.sh
Last active December 18, 2015 22:39
A script you can use on your CI to make a regularly "git gc"for i in `find ${WORKSPACE}/../../*/workspace -type d -maxdepth 1`; do if [ -d "$i/.git" ]; then cd $i git gc fi done
for i in `find ${WORKSPACE}/../../*/workspace -type d -maxdepth 1`; do
if [ -d "$i/.git" ]; then
cd $i
git gc
fi
done
@scrobbleme
scrobbleme / Jenkins_-_Upgrade_SVN.sh
Last active December 18, 2015 21:39
This script is usefull, if you upgraded your servers SVN version and need to upgrade all repositories of your Jenkins jobs.
for i in `find ${WORKSPACE}/../../*/workspace -type d -maxdepth 1`; do
cd $i || true
svn upgrade || true
done
@scrobbleme
scrobbleme / Jenkins - Wipe workspace.sh
Created June 13, 2013 09:45
Easiest way to clean all workspaces: Create a job for this and execute the command.
rm -r /opt/jenkins/home/jobs/*/workspace/*
@scrobbleme
scrobbleme / Jenkins - Set shallow clone on Git projects.groovy
Last active August 24, 2017 10:42
This snippets configures all your Jenkins jobs, which use Git as SCM to use shallow clones. This is usefull to save storage and speed up clone. You can execute this scripts with Jenkins build in Groovy console.
import jenkins.model.*
for(item in Jenkins.instance.items) {
if(item.scm instanceof hudson.plugins.git.GitSCM){
println("JOB : "+item.name)
print("useShallowClone: " + item.scm.useShallowClone)
item.scm.useShallowClone=true
println(" => "+item.scm.useShallowClone)
println("\n=======\n")
item.save()