Monday, November 26, 2012

MySQL Delete dupes

My favorite way of deleting dupes (taken from the honorable #mysql on freenode)

If you have a unique ID and the name may contain duplicates then

DELETE t1 FROM table1 AS t1 JOIN table1 AS t2 ON> AND;

If you have other fields that need to be taken into consideration extend the join as needed. If it fails on a myisam table see

Tuesday, August 21, 2012

phpMyAdmin - The plain HTTP request was sent to HTTPS port

So I tried getting phpMyAdmin to work with https again, turns out there was a solution posted back in 2008 on this blog.

His solution didn't quite work out for me, so I thought I'd update it with my working solution.

His version states add fastcgi_param HTTPS on which is correct, just at the wrong place.
location ~ \.php$ {
fastcgi_param HTTPS on;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
include /usr/local/nginx/conf/fastcgi_params;

What I need to do is the following:
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
include /usr/local/nginx/conf/fastcgi_params;
fastcgi_param HTTPS on;

Why? Simply cause in the conf/fastcgi_params file I had this:
fastcgi_param HTTPS $ssl_protocol;

Which doesn't seem to be good enough for good ol' phpMyAdmin, so we need to overwrite it after we include the conf file.


Sunday, February 19, 2012

Enabling Pure-ftpd TLS

Tell pure-ftpd to accept tls connections
echo 1 > /etc/pure-ftpd/conf/TLS

Setup your certificate

mkdir -p /etc/ssl/private

openssl req -x509 -nodes -newkey rsa:1024 -keyout \
/etc/ssl/private/pure-ftpd.pem \
-out /etc/ssl/private/pure-ftpd.pem

chmod 600 /etc/ssl/private/*.pem

Restart pure-ftpd

/etc/init.d/pure-ftpd restart


Friday, January 6, 2012

Remove unused kernels in Ubuntu

Update @20:th Aug 2015

The old dpkg trick was unstable and wanted to delete tons of unwanted things more than 50% of the time, so I found another useful command which has a higher success rate of doing what we want.

aptitude purge ~ilinux-image-\[0-9\]\(\!`uname -r`\)


Run the following command to see what the command will remove:

dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | xargs sudo apt-get --dry-run remove

And finally to actually remove the kernels use:

dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | xargs sudo apt-get -y purge


Wednesday, January 4, 2012

Enabling the Android "Move To SD Card"

By simply adding the following line to your manifest file, your app will get the ability to get moved/installed on the SD Card!

<manifest xmlns:android...>