Ubuntu: How To Setup ViewVC Via APT-GET

apt-get install -y apache2 viewvc libapache2-mod-python2.6
vim /etc/viewvc/viewvc.conf

Single Repository:

svn_roots = svn: /svn
root_as_url_component = 1

Multiple Repositories:

root_parents = /svn : svn
root_as_url_component = 1

Apache Virtualhost:

ServerName         your.domain.com
DocumentRoot /your/web/directory
ScriptAlias /viewvc "/usr/lib/cgi-bin/viewvc.cgi"

Browser:

http://your.domain.com/viewvc

Do not modify permissions of the SVN root (changing ownership OK)

Posted in Linux | Tagged , , , | Leave a comment

Linux: How To Setup SVN+SSH Repository And Server

Server:
SVNROOT=/home/svnroot
mkdir -p $SVNROOT
svnadmin create $SVNROOT
chown -R $USER: $SVNROOT
Client:
svn co svn+ssh://svn.cs.lmu.edu$SVNROOT
Posted in Linux | Tagged , , | Leave a comment

VIM: Open Files At The Same Line Where You Left Off Last

Add this to your .vimrc file:

au BufWinLeave * mkview
au BufWinEnter * silent loadview
Posted in Linux | Tagged , | Leave a comment

Bash: How To Get Absolute Value Using BASH

echo '-12' | nawk '{ print ($1 >= 0) ? $1 : 0 - $1}'
Posted in Languages, Linux | Tagged | 1 Comment

Bash: How To Do Floating Point Division in BASH Shell

# echo - | awk '{ print 3/9}'
0.333333
Posted in Linux | Tagged , , , | 1 Comment

Bash: Get File Size

#!/bin/bash
FILENAME=/home/heiko/dummy/packages.txt
FILESIZE=$(stat -c%s "$FILENAME")
echo "Size of $FILENAME = $FILESIZE bytes."
Posted in Linux | Tagged , , , | Leave a comment

MySQL: Disable AppArmor To Fix Permissions Problems

# mv /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/.usr.sbin.mysqld
# /etc/init.d/apparmor restart
# /etc/init.d/apparmor status
Posted in Databases | Tagged , | Leave a comment

Linux: How To Disable Debugfs

sudo mv /etc/init/ureadahead.conf /etc/init/ureadahead.conf.disable
Posted in Linux | Leave a comment

Linux: Automatically Remove Old Files And Directories

Remove files and directories older than 30 days old:

tmpreaper --mtime-dir --verbose 30d [directory]
Posted in Linux | Leave a comment

MySQL: How To Convert UTC to Local Time

mysql> select convert_tz( '2011-04-24 06:53:56', '+00:00', '-07:00');
+--------------------------------------------------------+
| convert_tz( '2011-04-24 06:53:56', '+00:00', '-07:00') |
+--------------------------------------------------------+
| 2011-04-23 23:53:56                                    |
+--------------------------------------------------------+
1 row in set (0.00 sec)

Also…

mysql> select convert_tz( '2011-04-24 06:53:56', '+00:00', 'SYSTEM');
+--------------------------------------------------------+
| convert_tz( '2011-04-24 06:53:56', '+00:00', 'SYSTEM') |
+--------------------------------------------------------+
| 2011-04-23 23:53:56                                    |
+--------------------------------------------------------+
1 row in set (0.00 sec)
Posted in Databases | Tagged , , , | 1 Comment

PHP: How To Convert UTC to Local Time

How to convert your MySQL timestamps from UTC to local time:

$gmdatetime = gmdate("Y-m-d H:i:s");
print "gmdatetime: $gmdatetime\n";
list($gmdate, $gmtime) = explode(' ', $gmdatetime);
list($gmyear, $gmmon, $gmday) = explode('-', $gmdate);
list($gmhour, $gmmin, $gmsec) = explode(':', $gmtime);
print "gmmktime($gmhour, $gmmin, $gmsec, $gmmon, $gmday, $gmyear)\n";
$gmepoch = gmmktime($gmhour, $gmmin, $gmsec, $gmmon, $gmday, $gmyear);
print "gmepoch: $gmepoch\n";

$timeOffset = date_offset_get(new DateTime('UTC'));

$localtime = $gmepoch + $timeOffset;
print "localtime: $localtime\n";

$datetime = date('Y-m-d H:i:s', $localtime);
print "datetime: $datetime\n";
Posted in Languages | Tagged , , , | Leave a comment

Firefox: How To Fix Broken Address Bar Search

When your firefox address bar search is broken, here’s how to fix it:

1. Type about:config and click ‘I Promise’.

2. Type keyword.URL in the Filter field and change the value to:

http://www.google.com/search?q=
Posted in Browsers | 1 Comment

Perltidy: Bareword “gensym” not allowed while “strict subs” in use at /usr/lib/perl/5.10/IO/Handle.pm

You are overwriting Symbol.pm somewhere in your $PERLLIB path.

Remove Symbol.pm and perltidy should work just fine.

Posted in Errors | Leave a comment

phpMyAdmin: Change Session Timeout

/etc/phpmyadmin/config.inc.php:
ini_set('session.gc_maxlifetime', 3600 * 3);
$cfg['LoginCookieValidity'] = 3600 * 3; 
Leave a comment

Perl: How To Use Dynamic Constructors

#!/usr/bin/perl

use strict;
use warnings;
use MyObject;
use Data::Dumper;

my $obj_name = "MyObject";
my $MyObject;
eval("\$MyObject = new $obj_name;");
print Dumper($MyObject);
Leave a comment

Perl: How To Write Dynamic Subroutines

Dynamic Functions in Perl

#!/usr/bin/perl
use strict;

{
no strict 'refs';

my $good_name = "foo";
*{ $good_name } = sub { print "Hi, how are you?\n" };

my $remote_name = "Some::Module::foo";
*{ $remote_name } = sub { print "Hi, are you from Maine?\n" };
}

foo();  # no problem
Some::Module::foo();  # no problem

Source: Mastering Perl by Brian D. Foy

Posted in Languages | 1 Comment

Ubuntu: How To Edit Menus via Command Line

All possible menu items exist here:

/usr/share/applications

Renaming a file will remove it from the menus (user must logout and log back in):

mv google-chrome.desktop google-chrome.desktop.orig
Leave a comment

Flash Install Error: NPSWF32.dll insufficient permission

  • Restart in Safe-mode (press F8 when booting)
  • Remove the Flash directory at C:\Windows\SysWOW64\Macromed
  • Works for Windows 7 64-bit
Posted in Flash, Windows | Leave a comment

Perl: How To Make Data::Dumper Sort Keys Numerically (Naturally)

use Data::Dumper::Perltidy;
use Sort::Naturally;
$Data::Dumper::Sortkeys = sub {
  my $hash = shift;
  return [ nsort( keys %$hash ) ];
};
Leave a comment

Perl/MySQL: How To Disable Foreign Key Checking

$dbh->do('SET FOREIGN_KEY_CHECKS=0');
Posted in Databases | Leave a comment