Skip to content

Instantly share code, notes, and snippets.

@wernersmit
wernersmit / curl-format.txt
Last active October 7, 2016 09:15
cURL display format times
\n
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
time_total: %{time_total}\n
\n
@wernersmit
wernersmit / input-placeholder-center.css
Created February 14, 2017 14:14
Center Align Input fields placeholder text
/*
* Source: http://stackoverflow.com/a/15378182
*/
::-webkit-input-placeholder {
text-align: center;
}
:-moz-placeholder { /* Firefox 18- */
text-align: center;
@wernersmit
wernersmit / accordion-open-next.js
Created February 19, 2017 15:55
Open next panel in jQuery accordion programatically
/*
* Source: http://stackoverflow.com/questions/11041420/how-to-programmatically-open-jquery-accordion-content-panel
*/
var $accordion = $("#accordion").accordion();
function openNextAccordionPanel() {
var current = $accordion.accordion("option","active"),
maximum = $accordion.find("h3").length,
next = current+1 === maximum ? 0 : current+1;
// $accordion.accordion("activate",next); // pre jQuery UI 1.10
@wernersmit
wernersmit / plesk-run-composer-in-php7-mode.sh
Created February 24, 2017 21:08
Plesk Run Composer using PHP7
#!/bin/bash
sudo -u mypleksuser /opt/plesk/php/7.0/bin/php /usr/lib64/plesk-9.0/composer.phar install
@wernersmit
wernersmit / plesk-get-all-domains.sh
Created February 26, 2017 20:22
Plesk get a list of all domains
#!/bin/bash
# Source: https://support.plesk.com/hc/en-us/articles/213368629--HOW-TO-Get-list-of-domains-and-their-IP-addresses-in-one-query-
MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin -Dpsa -e"SELECT dom.id, dom.name, ia.ipAddressId, iad.ip_address FROM domains dom LEFT JOIN DomainServices d ON (dom.id = d.dom_id AND d.type = 'web') LEFT JOIN IpAddressesCollections ia ON ia.ipCollectionId = d.ipCollectionId LEFT JOIN IP_Addresses iad ON iad.id = ia.ipAddressId"
@wernersmit
wernersmit / plesk-nginx-extra-reverse-proxy.conf
Created March 7, 2017 19:12
Plesk Nginx Extra Config for Custom Reverse Proxy - nodejs app or other host IP
## If someone enters two slashes, '//' combine them into one
merge_slashes on;
## Make sure everything is forwarded to https://
if ($scheme = http) {
return 301 http://$server_name$request_uri;
}
## Remove trailing slashes
@wernersmit
wernersmit / wp-config-snippet.php
Created March 7, 2017 21:09
Fix WP-Admin redirect loop after enabling SSL / HTTPS.
<?php
/*
* Source: http://wordpress.stackexchange.com/a/220896
* Used behind a varnish / nginx reverse proxy setup.
*/
/** SSL */
define('FORCE_SSL_ADMIN', true);
// in some setups HTTP_X_FORWARDED_PROTO might contain
// a comma-separated list e.g. http,https
@wernersmit
wernersmit / csv-to-array.php
Created March 11, 2017 13:09
Read CSV file and convert to array using fgetcsv
<?php
/*
* Source: http://www.codedevelopr.com/articles/reading-csv-files-into-php-array/
*/
function readCSV($csvFile){
$file_handle = fopen($csvFile, 'r');
while (!feof($file_handle) ) {
@wernersmit
wernersmit / imagemagic-compress-resample.sh
Created March 18, 2017 15:15
Find JPG images in current path upwards, compress to 45% and resample to 72dpi
#!/bin/bash
find . -name '*.jpg' -exec convert -verbose -strip -interlace Plane -quality 45% -density 72 {} {} \;
@wernersmit
wernersmit / wp-quick-edit.js
Created March 30, 2017 17:47
WP Bookmark - Quick Edit
javascript:top.location.href='/wp-admin/post.php?post=' + jQuery('[rel=shortlink]').attr('href').split('=')[1] + '&action=edit';