on Friday 12th June, 2009
Gabe speculated thusly…
The following command will generate several passwords with the following properties:
- Length of 10 characters
- Contain a mixture of upper and lowercase characters
- Contain at least 1 number
- Completely random most likely not in the dictionary (expect by random luck)
- Pronounceable
This makes these passwords easier to remember but very difficult to brute force. They are ideal as passwords for logging in to machines, servers, routers, etc.
$ apg -m 10 -x 10 -a 0 -M NCL -t
Posted in Information, Linux, Server
No Comments »
on Thursday 4th June, 2009
Gabe speculated thusly…
I use SSHFS to mount remote drives locally. The remote computers don’t have Bzr installed, and it’s difficult to get them up to date enough to install the latest Bzr. Therefore, I execute Bzr on my local computer on the mounted filesystem. Using default mount options for SSHFS leads to errors in both Git and Bzr, this is because (I believe) SSHFS doesn’t directly support file renaming. It is possible to avoid these problems by using the -oworkaround=rename switch with the mount command.
As an example my mount command looks similar to this:
sshfs -oworkaround=rename user@computer1:/var/www /media/computer1
Posted in Bazaar, Git, Information, Linux, Operating System, Programming, Revision Control, Server
No Comments »
on Sunday 31st May, 2009
Gabe speculated thusly…
If you develop multiple sites and you need virtual hosting functionality, scroll down to the end of the /private/etc/apache2/httpd.conf file and uncomment the following:
# Include /private/etc/apache2/extra/httpd-vhosts.conf
Next, you’ll need to setup whatever virtual hosts you have in the virtual hosts file /private/etc/apache2/extra/httpd-vhosts.conf
You need to make an entry in the httpd-vhosts.conf file like so:
<virtualhost *:80>
ServerName beta-site-1.com
ServerAlias www.beta-site-1.com
ServerAdmin webmaster@beta-site-1.com
ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
DocumentRoot "/Library/WebServer/beta-site-1"
ScriptAlias /cgi-bin/ "/Library/WebServer/beta-site-1/cgi-bin"
Options FollowSymLinks MultiViews Includes
AllowOverride All
Order allow,deny
Allow from all
</virtualhost>
The examples provided by Apple in the vhosts file are slightly incorrect and if you use the CustomLog lines as is you will get errors the following errors if you run: apachectl -t -D DUMP_VHOSTS:
Syntax error on line 40 of /private/etc/apache2/extra/httpd-vhosts.conf:
CustomLog takes two or three arguments, a file name, a custom log format string or format name, and an optional "env=" clause (see docs)
This is because
CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log common
Should actually read:
CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
Posted in Development, Frameworks, HowTo, Information, Leopard, Linux, Operating System, OS X, PHP, Server, Ubuntu
2 Comments »
on Sunday 31st May, 2009
Gabe speculated thusly…
Installing MySQL on OS X has become infinately easier since you can now download an Apple DMG from the MySQL website which takes care of the fine detail.
However, one thing that changed with Leopard is the socket for Mysql. It moved to /private/tmp, so you may need to configure your php.ini file to point it to the new location.
To do so, open the file /private/etc/php.ini, (if no such file exists, then make a copy of /private/etc/php.ini.default and rename it to php.ini) and edit that.
You have two lines to modify:
mysql.default_socket =
becomes:
mysql.default_socket = /private/tmp/mysql.sock
and mysqli.default_socket =
becomes:
mysqli.default_socket = /private/tmp/mysql.sock
Posted in Information, Leopard, MySQL, Operating System, OS X
No Comments »
on Sunday 31st May, 2009
Gabe speculated thusly…
Go to terminal and type:
vim ~/.profile
Assuming you want to add the path /usr/local/bin make .profile look like this:
PATH=/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
Separating each item with a colon.
Posted in Information, Leopard, Operating System, OS X
No Comments »
on Sunday 31st May, 2009
Gabe speculated thusly…
Change default password:
$ mysqladmin -u root password NEWPASSWORD
Change existing password:
$ mysqladmin -u root -p'oldpassword' password newpass
Posted in MySQL
No Comments »
on Wednesday 27th May, 2009
Gabe speculated thusly…
Ensure that you have the package sun-java6-jre installed and then run the following command from a terminal:
sudo ln -s /usr/lib/jvm/java-6-sun/jre/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/firefox-3.0.10/plugins/
You will need to restart FireFox after this and Java should be working for FireFox now.
Posted in Information, Linux, Operating System, Ubuntu
No Comments »
on Wednesday 27th May, 2009
Gabe speculated thusly…
A few weeks back I tried out the Gnome sessions. Gnome should automatically restore the programs you were last using when you log back in. However, it did not work well at all and I turned it off. This is when the problem began – everytime I logged back a whole bunch of the same applications automatically launched causing all sorts of mischief. No matter what I tried I could not get Gnome to turn sessions off again.
In the beginning I clicked on System -> Preferences -> Startup Applications and then selected the Options tab. Here, you may check a box labelled “Automatically remember running applications when logging out”. This will activate Gnome sessions. In my case, however, deselecting this did not turn Gnome sessions off.
After much hunting around, with no help from the Internet, I finally found the files that needed deleting to stop Gnome launching various apps at startup. You need to open your home folder in Nautilus and press CTRL+H – this lets you view hidden files and folders (hidden files/folders begin with a dot “.”). Navigate the following path .config/gnome-session/saved-session and delete all the files there. You can move them to the trash can for safety. Having done this, the next time you login you should just get a blank desktop.
I’ve taken the time to write this in the hope that anyone else suffering from the same bug can solve it more quickly than I. This should be reported as a bug on launchpad.net if it isn’t already there.
Posted in Information, Linux, Operating System, Ubuntu
1 Comment »
on Sunday 24th May, 2009
Gabe speculated thusly…
I am making a note of this for ease of future reference. I can never quite remember whether a medium blob is 16MB or whatever it is, the capabilities are on the MySQL site but I am going to write it in plain english here so I don’t have to keep getting my calculator out to remind me what 2^24 is in terms I am more familiar with…
TinyInt: -128 to 127 (0 to 255 if unsigned).
SmallInt: -32768 to 32767 (0 to 65535 if unsigned).
MediumInt: -8588608 to 8388607 (0 to 16777215 if unsigned).
Int: -2147483648 to 2147483647 (0 to 4294967295 if unsigned).
BigInt: -9223372936854775808 to 9223372036854775807 (0 to18446744073709551615).
Float: 0 and +-1.175494351E-38 to +-3.402823466E+38.
Double: 0 and +-2.2250738585072014-308 to +-1.7976931348623157E+38.
Decimal[(M,D)]: As for DOUBLE but constrained by M and D.
Char(M): M may take any integer value from 0 to 255, with a CHAR(0) column able to store only two values: NULL and ” (empty string), which occupy a single bit.
VarChar(M): 1 to 255 (number of characters to store). Trailing spaces are stripped before storage.
Text type columns do case insensitive comparisons and sorts, whereas blobs are case sensitive.
TinyBlob/TinyText: Max. length 255 characters. Very similar to VarChar but trailing spaces are not stripped before storage.
Text/Blob: Max. length 65535 characters (65KB).
MediumBlob/MediumText: Max. length 6777215 characters (16.8MB).
LongBlob/LongText: Max. length 4294967295 characters (4.3GB).
Enum: One value chosen from up to 65535 possibilities.
Set: Up to 64 values in a given set column.
Date: ’1000-01-01′ to ’9999-12-31′, and ’0000-00-00′.
Time: ‘-838:59:59′ to ’838:59:59′.
DateTime: ’1000-01-01 00:00:00′ to ’9999-12-31 23:59:59′.
Year: 1901 to 2155, and 0000.
TimeStamp: 19700101000000 to sometime in 2037 on current systems.
Posted in Information, MySQL, Programming
No Comments »
on Wednesday 20th May, 2009
Gabe speculated thusly…
It is my opinion that CodeIgniter’s default img() function that comes in the HTML Helper could have been easier to use. As it is if you want to give your image a name css class you have to define an array consisting of these attributes.
That takes up space and makes the code less readable for non-PHP programmers. Since I work closely with a web designer who is good with HTML but gets lost in PHP I want to leverage the pragmatic power of PHP to automate repetitive tasks (like typing out an entire HTML image tag), but at the same time the result needs to be obvious to a non-programmer but also shorter than the HTML equivalent. I feel the img() helper in CodeIgniter falls short of both these requirements.
CodeIgniter’s img() helper also takes a second parameter, a boolean, this decides whether the index.php file is included in the image path, good if you are using a media controller. For 99.9% of my sites I don’t need these. Therefore I wrote my own helper.
The file is called MY_html_helper.php and lives inside the folder system/application/helpers. As with other extensions to the CI core the prefix MY_ is determined in your config file, so change MY_ to whatever it should be. Add the following code to the file:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
function img($imgName, $attrs=FALSE)
{
$CI =& get_instance();
if (strpos($imgName, 'http') === 0) return;
$imgPath = $CI->config->item('base_url');
if ( ! $imgDir = $CI->config->item('image_dir')) $imgDir = 'assets/images/';
$img = $imgPath.$imgDir.$imgName;
$str = '<img src="'.$img.'" ';
if ($attrs) $str .= $attrs." ";
$str .= "/>";
return $str;
}
All you have to make sure you do is load the html helper: $this->load->helper('html'); in your controller,
or put it in the array of helpers in system/application/config/autoload.php.
The helper assumes images live in the folder assets/images which lives alongside the system folder. If this is not where you put your images then you can specify an alternative directory in your config.php file. Simply add a line that looks like this to config.php: $config['image_dir'] = 'alternative/path/images/';. Don’t forget the trailing slash at the end. This alternative folder would live at the very top level of your application, alongside index.php.
Using the helper is easy and straightforward: <?=img('example.gif')?>
Will produce <img src="http://mysite.com/assets/images/example.gif" />.
Any additional attributes you want in the html tag can be written as per usual as the second parameter. For example if you want to give the image an alt attribute and class:
<?=img('example.gif', 'class="myclass" alt="Example Image"')?>
Will produce:
<img src="http://mysite.com/assets/images/example.gif" class="myclass" alt="Example Image" />
The only hard part about this is making sure you get the single and double quotes correct in the second parameter.
Cheers
Posted in CodeIgniter, Development, Frameworks, Information, Linux, Operating System, Programming, Server
1 Comment »