Delete fdupes duplicates by directory

24 May 2015

A quick script to process fdupes output and allow interactive selection of files to delete. Differs from the built-in fdupes prompts in that you can select directories to condemn.


Delete fdupes duplicates by directory - Comments

Fixing php5-fpm and Apache hanging with WordPress

23 March 2015

I had issues with Apache periodically hanging (failing to deliver a response body to any requests) on all my vhosts. This turned out to be solved by restarting php5-fpm. I enabled the slowlog in php5-fpm to try and find out which scripts were stalling:

sudo mkdir -p /var/log/php5-fpm
sudo vim /etc/php5/fpm/pool.d/www.conf
; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
slowlog = /var/log/php5-fpm/$pool.log.slow

; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
request_slowlog_timeout = 5s

After a day or so I read the logs and found lots of slow requests to xmlrpc.php for WordPress vhosts.

A crude but effective solution is to block requests to the XML-RPC and Trackback APIs. These features are sometimes targeted by bots for brute force login attempts. I do not use them so I don’t mind disabling them entirely.

Edit your Apache vhost configuration (or .htaccess if you don’t have access to this):

<FilesMatch "^(xmlrpc\.php|wp-trackback\.php)">
Order Deny,Allow
Deny from all
#Allow from x.x.x.x
</FilesMatch>

I noticed considerably lower latency when serving requests to PHP pages after this change.


Fixing php5-fpm and Apache hanging with WordPress - Comments

Block Facebook Trending News with µBlock

24 January 2015

To create a new filter:

  1. Open the µBlock dashboard by clicking the µBlock icon, then the header text that says ‘µBlock ’.
  • Click ‘My filters’
  • Add:
    www.facebook.com###pagelet_trending_tags_and_topics
    
  • Apply Changes.

Block Facebook Trending News with µBlock - Comments

Hide Facebook ‘Like’ News

2 September 2014

If you use Facebook, you’ve probably seen entries like this in your news feed.

facebook_like_news

They seem to just be popular posts from pages that your friends ’like’. I find them to generally be irrelevant, so I made a user script to hide them.

It was an interesting opportunity to poke around the Facebook frontend JavaScript code. I also tried out MutationObservers and built my knowledge of XPath, which is very powerful.

Code is in the Hide_Facebook_Like_News.user.js Gist, which also explains how to use it:


Hide Facebook ‘Like’ News - Comments

Passletters

1 July 2014

passletters is a tiny command line utility to read a password from stdin and echo it with letters enumerated (for entry into web prompts that demand random, individual letters). The terminal scrollback is cleared afterwards.

sudo pip install passletters

NB: sudo may be needed to install the passletters script somewhere in your PATH.

https://github.com/inversion/passletters

https://pypi.python.org/pypi/passletters


Passletters - Comments