Шпионам за чужой консолью

В стандартный состав FreeBSD входит замечательная программа watch(8), которая позволяет подсматривать за чужой консолью.

Всё, что ей для этого необходимо это snp модуль, который достаточно собрать из сурцов а программа сама его подгрузит:

# cd /usr/src/sys/modules/snp/
# make && make install

Теперь выбираем цель:

# w
9:16PM up 55 days, 52 mins, 2 users, load averages: 0.08, 0.06, 0.00
USER TTY FROM LOGIN@ IDLE WHAT
nlo1 p0 nlo.habr.ru 9:06PM - w
nlo2 p1 nlo.habr.ru 9:16PM - -bash (bash)

И подсматриваем за интересной нам консолью(TTY).

# watch p1

How do I reset (restore) a MySQL Password?

How to Reset a MySQL Password in 5 Easy Steps:

  1. Stop the mysqld daemon process
  2. Start the mysqld daemon process with the —skip-grant-tables option
  3. Start the mysql client with the -u root option
  4. Execute the UPDATE mysql.user SET Password=PASSWORD(‘password’) WHERE User=’root’;
  5. Execute the FLUSH PRIVILEGES; command

These steps reset the password for the «root» account to «password». To change the password for a different account, or to set a different password, just edit the variables in single-quotes in step 4.

If you know your existing MySQL root password, steps 1-3 are not necessary.

more here http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html

DOM events exposed! Record and explore.

With jQuery Event Showcase you can record DOM events and explore all of their properties. Events filter helps you focus on the event types you want to investigate.

Check it out!

Manufacturing flic.kr style photo URLs

Super quick note, hopefully sufficient info.

The format for the short photo URLs is:

flic.kr/p/{short-photo-id}

A short photo id is a base58 conversion of the photo id. Base58 is like base62 [0-9a-zA-Z] with some characters removed to make it less confusing when printed. (namely 0, O, I, and l).

So that leaves an alphabet of: 123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ

I’m including below a variation of the code we use to do base conversion. Note it doesn’t use modulus because PHP’s modulus operator overflows for large numbers (like photo ids)

function base_encode($num, $alphabet) {
	$base_count = strlen($alphabet);
	$encoded = '';

	while ($num >= $base_count) {
		$div = $num/$base_count;
		$mod = ($num-($base_count*intval($div)));
		$encoded = $alphabet[$mod] . $encoded;
		$num = intval($div);
	}

	if ($num) $encoded = $alphabet[$num] . $encoded;

	return $encoded;
}

function base_decode($num, $alphabet) {
	$decoded = 0;
	$multi = 1;

	while (strlen($num) > 0) {
		$digit = $num[strlen($num)-1];
		$decoded += $multi * strpos($alphabet, $digit);
		$multi = $multi * strlen($alphabet);
		$num = substr($num, 0, -1);
	}

	return $decoded;
}

grabbed from http://www.flickr.com/groups/api/discuss/72157616713786392/