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

Blackberry: How To Factory Reset a Blackberry Curve

Go to Options > Security > General > Press Menu > Wipe Handheld.

Posted in Smartphones | Leave a comment

Linux: Install NIS With No Interaction

How to install NIS silently, bypassing the NIS Domain prompt

On a test system, do the normal install of NIS

$ apt-get install nis

Then, install the debconf-utils package to read the variables it set during install

$ apt-get install debconf-utils
$ debconf-get-selections | grep nis

You will see a line in there similar to this

nis nis/domain string yourdomain.com

Now, on any system you want to install NIS on, copy that line, and put it in a file, like /tmp/nis.seed
Then run these commands

$ sudo debconf-set-selections /tmp/nis.seed
$ sudo apt-get install -y nis

It should not prompt anymore for a domain.

Posted in Linux | Leave a comment

Linux: How To Install Perltidy in VIM

# apt-get install -y perltidy
/home/user/.vimrc
map ^K :!perltidy -q -l=0 -i=2^M

Where ^K and ^M are control characters.

Leave a comment

Linux: How To Mount ISO File

mount -o loop -t iso9660 filename.iso /whatever/mount/point/dir
Posted in Linux | Leave a comment

Linux: df: /nfs/user: Stale NFS file handle

# umount /nfs/user
Posted in Errors, Linux | Leave a comment

Linux: How To Run A Service At Startup

# chkconfig sendmail on
Posted in Linux | Leave a comment

Linux: How To Scan For Rootkits

# apt-get install -y chkrootkit
# apt-get install -y rkhunter
Posted in Linux, Security | Leave a comment

Linux: How To Forward SSH Agent With Sudo

Edit your sudoers file:

# su
# /usr/sbin/visudo

Add this line:

Defaults    env_keep=SSH_AUTH_SOCK

Or for multiple variables:

Defaults    env_keep="SSH_AUTH_SOCK EDITOR"
Posted in Linux | 1 Comment

Subversion: svn: Can’t open file ‘txn-current-lock’: Permission denied

To solve this problem, run svnserve as root (or as the user who has permissions to your svn root dir):

# sudo bash
# svnserve -d --foreground -r /home/svn

OR

# chown -R subversion: /home/svn
# su - subversion
# svnserve -d --foreground -r /home/svn

OR

Delete your checkout and...
svn co svn+ssh://[username]@[svn.host]/path/to/project/repo
Posted in Errors, Linux | Leave a comment

Linux: How To Setup NIS

How To Setup NIS on Ubuntu Server 10.04.1

Follow the steps here:
https://help.ubuntu.com/community/SettingUpNISHowTo

Some additional notes:

Quick NIS Client Setup Script

#!/bin/bash
echo "+::::::" >> /etc/passwd
echo "+::::::::" >> /etc/shadow
echo "+:::" >> /etc/group
echo "ypserver my-nis-server.com" >> /etc/yp.conf

How To Allow Users To Change Their Own Passwords:
Run rpc.yppasswdd on the server.

# rpc.yppasswdd

Then, on the client, the user must run yppasswd:

$ yppasswd
Changing NIS account information for johndoe on nfs-server-name:
Please enter old password:
Changing NIS password for johndoe on nfs-server-name:
Please enter new password:
Please retype new password:

The NIS password has been changed on nfs-server-name.

How To Setup An NIS Slave:

# /usr/lib/yp/ypinit -s nis-master-server
# /etc/init.d/nis restart
 * Stopping NIS services  [ OK ]
 * Starting NIS services  [ OK ]
Posted in Linux | Leave a comment

OpenLDAP: failed init (bdb)

Find the bdb module:

# find /usr -name back_bdb.la
/usr/lib/ldap/back_bdb.la

Add this to your slapd.conf:

modulepath      /usr/lib/ldap
moduleload      back_bdb.la

Restart slapd:

# /etc/init.d/slapd restart
Stopping OpenLDAP: slapd.
Starting OpenLDAP: slapd.
Posted in Linux | 2 Comments

APT: not fully installed or removed

If you get an error like this:

apt-get remove slapd
...
The following packages will be REMOVED:
  slapd
0 upgraded, 0 newly installed, 1 to remove and 39 not upgraded.
1 not fully installed or removed.

Here’s how to fix it:

apt-get remove --purge slapd

Then, reinstall:

apt-get install -y slapd
Posted in Linux | Leave a comment

Linux: How To Setup Apache With SSL (HTTPS)

Here’s a quickstart basic setup of SSL on Apache running on Ubuntu Desktop 10.04.1:

Create your RSA Private Key:

$ openssl genrsa -rand file1:file2:file3 -out server.key 1024

Where file1, file2, and file3 are random data (zip files work well here for random data)

Create your Certificate Signing Request based on the RSA key:

$ openssl req -new -key server.key -out server.csr

Create your Self-Signed Certificate (for testing):

$ openssl x509 -req -in server.csr -signkey server.key -out server.crt

In Apache, create a new virtual host:

<VirtualHost *:443>
  ServerName www.my-domain.com
  DocumentRoot /var/www/my-document-root

  SSLEngine on
  SSLCertificateFile /etc/ssl/server.crt
  SSLCertificateKeyFile /etc/ssl/server.key
</VirtualHost>

Enable the SSL module for Apache

# a2enmod ssl

Restart Apache

# /etc/init.d/apache2 restart
 * Restarting web server apache2
... waiting     [ OK ]

Source: http://slacksite.com/apache/certificate.php

Posted in Linux | Tagged , , | Leave a comment