Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Example run: ./optimize-images.sh -path /var/www/vhost/domain.nl -mtime 2
# Example run with exclude: ./optimize-images.sh -path /var/www/vhost/domain.nl -mtime 2 -exclude "*/exclude_dir/*"
mtime='2'
path=''
exclude=''
find_path="$(which find)"
optipng_path="$(which optipng)"
jpegoptim_path="$(which jpegoptim)"
@joeke
joeke / webp-convert.sh
Created August 10, 2022 12:13
webp-convert
#!/bin/bash
# Example run: ./webp-convert.sh /var/www/vhost/domain.nl/webroot
# cleanup, remove webp if jpg/png version does not exist or jpg/png is newer then webp version
echo -e "\033[0;34mCleaning up WEBP images\033[0m"
find $1 -type f -and -iname "*.webp" | while read webpFile; do
echo "Processing file '$webpFile'"
basename="${webpFile%.*}"
# Check if original file still exists.
@joeke
joeke / php-7-upgrade.txt
Created March 26, 2018 11:08
php 7.1 / 7.2 upgrade on Ubuntu 14.04 (apt)
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install
php7.2
php7.2-common
php7.2-cli
php7.2-fpm
php7.2-opcache
php7.2-mysql
php7.2-zip
@joeke
joeke / mysql-search.php
Created March 28, 2017 06:25
PHP search all mysql tables
<?php
function findAll($search_str, $database, $types = ['tinytext','blob','varchar','text','longblob']){
global $pdo;
foreach($types as &$t){
$t = "'" . $t . "'";
}
$types = implode(',',$types);
$s = $pdo->prepare("
@joeke
joeke / extjscombobox.js
Created September 28, 2016 11:17
extjs: custom tpl for combobox list option
{
xtype: 'modx-combo'
,width: 200
,name: "id"
,id: config.id + '-user-field'
,url: MODx.config.connectorUrl
,fields: ['id', 'firstname', 'lastname']
,tpl: '<tpl for="."><div class="x-combo-list-item" >{firstname} {lastname}</div></tpl>'
,displayField: 'firstname'
,baseParams: {
@joeke
joeke / parse-resource.php
Last active October 14, 2024 17:10
MODX Revo: Parse full contents of resource
<?php
/**
* Get full parsed HTML from resource
* (you already need to have the resource object available in $this->resource)
*
* @access public
* @return string $html The parsed html of the resource
*/
public function parseResource() {
@joeke
joeke / gist:783ed9b3b9a99182297a
Created February 20, 2016 22:38
Modx ExtJS: rearrange resource tabs
```
switch ($modx->event->name) {
case 'OnBeforeManagerPageInit':
$modx->controller->addHtml('
<script>
Ext.ComponentMgr.onAvailable("modx-resource-tabs", function() {
// Order of tabs
var tabs = {
"modx-panel-resource-tv": null,
"modx-page-settings": null,
@joeke
joeke / gist:2a588229caec7dcf15a6
Last active January 31, 2016 09:56
ExtJS: render tooltip only when specific value is set
, listeners: {
render: function(c) {
// first get count via ajax call
MODx.Ajax.request({
url: className.config.connectorUrl,
params: {
action: 'mgr/group/getlist'
},
listeners: {
'success': {
@joeke
joeke / gist:614bfa8c7841afed81a2
Created February 25, 2015 09:48
sublime text regex search replace
* Example: Replace dash (-) to underscore (_) in name attribute *
search:
name="([a-zA-Z]*)-([a-zA-Z]*)-([a-zA-Z]*)"
replace:
name="\1_\2_\3"
@joeke
joeke / css
Created August 13, 2014 11:00
CSS vertical centering
.parent {
float: left;
height: 200px;
width: 200px;
background: gray;
margin: 0 10px 0 0;
}
.children {
position: relative;
top: 50%;