Skip to content

Instantly share code, notes, and snippets.

View falexandrou's full-sized avatar

Fotis Alexandrou falexandrou

View GitHub Profile
@falexandrou
falexandrou / view-pdf.js
Last active August 29, 2015 13:57
Display PDF files inline
/**
* When browser supports inline pdfs
* There is no need to append a large jquery plugin that displays them inline.
*
* You can actually use an iframe (and style it appropriately)
* or a link whenever inline PDF viewing is not supported
*
* This function is fairly simple and it's only for demo purposes
*/
function appendPdf(id, url) {
@falexandrou
falexandrou / .htaccess
Created November 14, 2012 21:00
Rewrite to a separate Wordpress installation dir
# When installing wordpress on a separate dir inside your $_SERVER['DOCUMENT_ROOT']
# you may need to create a rewrite rule, otherwise wordpress will start complaining...
#
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wordpress-installation-dir/wordpress/$1 [L]
@falexandrou
falexandrou / gist:5529114
Last active December 17, 2015 01:29
Locked out of kloxo
# If you've been locked out of kloxo and you've tried everything google suggested for you
# then most likely it's a database problem. Please try the following at your own will
# and hit cmd+y (or ctrl+w) if you don't know the impact this will have on your system.
# Disclaimer: if you break your server it won't be my fault. you've been warned
#
# The "recommended" way to login to your kloxo installation is the following:
# as described in http://wiki.lxcenter.org/Change+Password+via+SSH
[root@server]$ sh /script/resetpassword master {newpassword}
# if this doesn't work try the following:
@falexandrou
falexandrou / jetpack.php
Created September 18, 2017 23:55
Reduce Database load caused by Jetpack
<?php
// Jetpack custom cron schedule to reduce cron load
// Add it in your site-speicic plugin or the theme's functions.php
add_filter( 'jetpack_sync_incremental_sync_interval', function() { return 'hourly'; } );
add_filter( 'jetpack_sync_full_sync_interval', function() { return 'daily'; } );
add_filter( 'jetpack_sync_listener_should_load', '__return_false' );
add_filter( 'jetpack_sync_sender_should_load', '__return_false' );
add_filter( 'pre_option_jetpack_sync_settings_sync_via_cron', '__return_zero' );
@falexandrou
falexandrou / stock_sales.sql
Created September 22, 2017 07:48
[WooCommerce] Get current values for a product's sales and stock quantity
SELECT
p.post_title AS "Product title",
t1.meta_value AS "Items Sold",
t2.meta_value AS "Current Stock Quantity",
NOW() AS "Current Date"
FROM
wp_posts p
LEFT JOIN (SELECT meta_value, post_id FROM wp_postmeta WHERE meta_key='total_sales') t1 ON t1.post_id=p.ID
LEFT JOIN (SELECT meta_value, post_id FROM wp_postmeta WHERE meta_key='_stock') t2 ON t2.post_id=p.ID
WHERE p.ID=102176;
[2017-11-13 13:00:03] production.DEBUG: now: 2017-11-13 13:00:03 start time 1: 2017-02-10 20:42:30 start time 2: 2017-02-10 21:12:30 [] []
[2017-11-13 13:00:03] production.DEBUG: now: 2017-11-13 13:00:03 end time 1: 2017-02-12 20:40:47 end time 2: 2017-02-12 21:10:47 [] []
[2017-11-13 13:00:03] production.DEBUG: Analyzing contest Siamo Alla Frutta [] []
[2017-11-13 13:00:03] production.DEBUG: now: 2017-11-13 13:00:03 start time 1: 2017-02-11 20:07:42 start time 2: 2017-02-11 20:37:42 [] []
[2017-11-13 13:00:03] production.DEBUG: now: 2017-11-13 13:00:03 end time 1: 2017-02-27 20:07:42 end time 2: 2017-02-27 20:37:42 [] []
[2017-11-13 13:00:03] production.DEBUG: Analyzing contest the beautiful contest ever [] []
[2017-11-13 13:00:03] production.DEBUG: now: 2017-11-13 13:00:03 start time 1: 2017-02-18 03:29:17 start time 2: 2017-02-18 03:59:17 [] []
[2017-11-13 13:00:03] production.DEBUG: now: 2017-11-13 13:00:03 end time 1: 2017-02-28 03:29:17 end time 2: 2017-02-28 03:59:17 [] []
[2017-11-13 13:00:03] product
@falexandrou
falexandrou / crop.util.css
Created February 12, 2018 14:25
Tiny utility for cropping text via css
.crop {
display: block;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
@falexandrou
falexandrou / gc.php
Last active April 5, 2018 14:19
PHP Force Garbage Collection
<?php
# If you've exceeded the number of inodes on your server,
# you could as well run `php -a` so you get the interactive shell running
# and then copy & paste the following lines into
# Make sure we're using files as a session save handler
ini_set('session.save_handler', 'files');
ini_set("session.save_path", "/var/lib/php/session");
# The probability of performing garbage cleanup is the ratio:
@falexandrou
falexandrou / keybase.md
Created April 25, 2018 16:55
keybase.md

Keybase proof

I hereby claim:

  • I am falexandrou on github.
  • I am falexandrou (https://keybase.io/falexandrou) on keybase.
  • I have a public key ASCkxsN8ltxAfUxD0WYm3WKADZ7aiVSq2up2MqF4stqKogo

To claim this, I am signing this object:

@falexandrou
falexandrou / varnish.php
Created May 7, 2018 14:23
varnish purge
<?php
/**
* Send data to Varnish
*
* @since 2.6.8
*
* @param string $url The URL to purge.
* @return void
*/
function rocket_varnish_http_purge( $url ) {