Awnist

Category: Uncategorized

Zend Framework: Listing contents of Zend_Registry

$registry = Zend_Registry::getInstance(); foreach ($registry as $index => $value) { echo "Registry index $index contains:\n"; var_dump($value); }

Apache: Force SSL by redirecting everything to https from .htaccess

RewriteEngine On RewriteCond %{HTTPS} off RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]  

Adding init.d Dropbox service in Ubuntu/Debian

### BEGIN INIT INFO # Provides: dropbox # Required-Start: $local_fs $remote_fs $network $syslog $named # Required-Stop: $local_fs $remote_fs $network $syslog $named # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # X-Interactive: false # Short-Description: dropbox service ### END INIT INFO #!/bin/sh # dropbox service DROPBOX_USER="dev" DAEMON=/opt/bitnami/dropbox/dropbox start() { echo "Starting dropbox…" if [...]

Creating color swatches with Imagemagick and bash

#!/bin/bash if [ ! -d colors ]; then mkdir colors fi for color in “$@” do convert -size 100×100 xc:$color colors/$color.jpg done Run with: ./colors.sh blue black green purple Add a hash # in front of $color to generate by hex.  

apache2: Could not reliably determine the server’s fully qualified domain name, using xx.xx.xx.xx for ServerName

If Apache is bugging you with apache2: Could not reliably determine the server’s fully qualified domain name, using xx.xx.xx.xx for ServerName Get your hostname $ hostname production and tell Apache by putting ServerName production in /etc/apache2/apache2.conf You can also do this in one line: $ sudo echo “ServerName “`hostname` >> /etc/apache2/apache2.conf  

Magento – Downloader: Failed to download within preferred state “beta”, latest release is version x.x.x, stability “alpha”, use “channel://…” to install PEAR ERROR: install failed

When installing a Magento extension with Downloader, you may see this message: Failed to download magento-community/xxxx within preferred state “beta”, latest release is version x.x.x, stability “alpha”, use “channel://connect.magentocommerce.com/community/xxx” to install PEAR ERROR: install failed Following instructions, you may try and download using the method suggested and see: Invalid package identifier provided: channel://connect.magentocommerce.com/community/xxx Magento Connect [...]

Magento – Downloader error: Invalid file permissions, could not save configuration

If you see Invalid file permissions, could not save configuration in Magento’s downloader, usually when making changes to Settings such as Preferred state, make sure this file: (magento root)/downloader/config.ini is writeable by the webserver. If you don’t know how to do this properly, chmod 777 (magento root)/downloader/config.ini should fix your problems.

Restrict access to Magento admin based on IP

Add this to .htaccess after “RewriteBase /”: # Restrict admin access RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123 RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123 RewriteCond %{REQUEST_URI} admin [NC] RewriteRule ^(.*)$ / [F,L]

Get a list of the most active IPs based on specific urls in Apache logs

grep KEYWORD access.log | grep KEYWORD2 | awk ‘{print $1}’ | sort -n | uniq -c | sort -rn

Migrating WP users to WPMU

This technique will migrate: Usernames Email Password It does not concern itself with User meta Anything else It assumes Admin on WPMU has already been created. Admin on original WP install is user id #1 All new users are subscribers on blog #1 in WPMU Firstly, run this sql in your mysql install: select concat('Array(', [...]