If you have asked yourself, “Do I have a 64-bit processor?”, then here are several ways to find out:
uname
# uname -p
x86_64
cpuinfo
# cat /proc/cpuinfo
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr
pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm
pbe syscall lm constant_tsc arch_perfmon pebs bts rep_good pni
dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm lahf_lm tpr_shadow
bogomips : 4255.87
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
The “lm” flag stands for Long Mode.
You can read more in this file:
/usr/src/kernels/#.#.#-#.#.fc11.x86_64/arch/x86/include/asm/cpufeature.h
#define X86_FEATURE_LM (1*32+29) /* Long Mode (x86-64) */
lshw
# lshw
*-cpu
description: CPU
product: Intel(R) Core(TM)2 CPU 6420 @ 2.13GHz
width: 64 bits
From the lshw manpage:
lshw is a small tool to extract detailed information on the hardware configuration of the machine. It can report exact memory configuration, firmware version, mainboard configuration, CPU version and speed, cache configuration, bus speed, etc. on DMI-capable x86 or IA-64 systems and on some PowerPC machines (PowerMac G4 is known to work).
The iNove theme gives your wordpress blog a Mac-ish look and feel. However, the sidebar has some ugly built-in widgets. Here’s how to remove them.
In themes/inove/sidebar.php, remove everything between these lines:
<!-- sidebar north END -->
...
delete everything here
...
<!-- sidebar south END -->
Done!
Slow Query Example
SELECT
widget_id
, widget_name
, COUNT(DISTINCT type) AS num_types
FROM widget
GROUP BY type
ORDER BY num_types DESC
With lots (>100K) of rows, this query will get slow because it orders on an aggregate COUNT DISTINCT function. Remove the ORDER BY to make this fast again.
This is how to convert seconds into HH:MM:SS in bash:
$ date -d '1970-01-01 100 sec' +'%H:%M:%S'
00:01:40
To fix this error:
# nslookup mydomain.com
nslookup: error while loading shared libraries: liblwres.so.50: cannot open shared object file: No such file or directory
Do this:
# ldconfig
# dig mydomain.com
; <<>> DiG 9.6.1-RedHat-9.6.1-2.fc11 <<>> mydomain.com
...
From the ldconfig manpage:
ldconfig creates the necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories (/lib and /usr/lib). The cache is used by the run-time linker, ld.so or ld-linux.so. ldconfig checks the header and filenames of the libraries it encounters when determining which versions should have their links updated.
When optimizing a query, the order of fields matter in a multi-field index.
In general, you should use the most selective fields first.
For example, in a hypothetical location index, use zip, city, state, rather than the reverse.
Source: MySQL Forums, Jay Pipes, Performance Tuning Best Practices Presentation
If your SSH public key authentication is failing with errors like this:
$ ssh -vvv myhost.com
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/kitamura/.ssh/id_dsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
…try these permissions on the server:
server$ chmod go-w ~/ (same as 755)
server$ chmod 700 ~/.ssh
server$ chmod 600 ~/.ssh/authorized_keys
more troubleshooting tips
- Use UNSIGNED INT (or BIGINT if needed) for primary key, since you don’t need negative primary keys.
- Don’t use ON DELETE CASCADE, since you might delete rows you wanted to keep. Explicitly delete rows in your code.
- Don’t use ON UPDATE CASCADE, since you might want to change the ID in the parent table of the row being referenced, without changing the ID of the child row.
- Always use foreign keys to constrain your data and require that foreign keys reference rows that actually exist.
- Use UNIQUE KEYS where necessary and where they conceptually make sense. All fields in the UNIQUE KEY must be NOT NULL for the key to be effective.
- Use singular table names, unless a row represents a plural object. (A table of chairs would be called “chair”, unless a row represented a set of “chairs”). This makes code generation easier (esp. for tables named “category”, “specialty”, “country”, etc)
Update:
Keep data types as small as possible for what you need
• Don’t use BIGINT unless you have to! Waste of space.
• Especially true on indexed columns
• Fundamental principle: The smaller your data types, the more records will fit into the index blocks. The more records fit in each block, the fewer reads are needed to find your records.
Source: Jay Pipes, MySQL Presentation, Index Coding Optimization
- Smaller is better – use the smallest data type necessary. When in doubt, use the smallest one you don’t think you’ll exceed.
- Avoid NULL if possible – Nullable columns make indexes, stats, and value comparisons more complicated.
- Use simpler data types when possible – use integers for IP addresses
- For storage and computation, INT(1) and INT(20) are equivalent. The numeric is for display purposes only for applications such as the command line client.
- Use FLOAT over DECIMAL for speed – the CPU performs the computations natively, as opposed to the server making the DECIMAL calculation
Source: O’Reilly High Performance MySQL
How to Automatically Install CPAN Dependencies without having to answer “yes” to each question:
export PERL_MM_USE_DEFAULT=1
# rpm -ql mysql-devel
/usr/include/mysql
/usr/include/mysql/chardefs.h
/usr/include/mysql/decimal.h
/usr/include/mysql/errmsg.h
...
Here’s how to monitor multiple cores on Linux:
# mpstat -P ALL
Example:
Monitor all CPU’s in 1 second intervals forever
# mpstat -P ALL 1
If Synergy fails for you with this error: “Server refused client with name XXX”, then your IP might conflict with another machine on the same network.
Here’s how to renew your IP on Linux:
### Release your current IP
$ sudo dhclient -r
### Request a new IP
$ sudo dhclient
- Go through the usual setup at Samba.org or use YUM (yum install -y samba)
- By default, the smb.conf allows sharing of home directories.
- Add a Samba user (smbpasswd -a myusername)
- On Fedora, run SELinux Administration
- On the left menu, click “Boolean”.
- Scroll down to “samba”, and check the box next to “Allow samba to share users home directories”.
- Also on Fedora, make sure your Firewall allows the Samba ports 139 and 445.
- On Windows Vista, now map the network drive.
Sample smb.conf:
[homes]
comment = Home Directories
browseable = no
writable = yes
; valid users = %S
; valid users = MYDOMAIN\%S
UPDATE: Roxio has made it harder to disable “Media Manager Services” now.
In Windows Vista:
- Click the Start button, type “msconfig” and hit enter.
- When the small “User Account Control” window pops up, click continue.
- Click the Startup tab
- Look for “CommonSDK” in the Startup items in the left column.
- Check the Command column, which should say “RoxWatchTray9.exe”
- Uncheck the box for that row.
- Restart your machine.
ALTERNATE OLDER VERSION:
After installing Roxio Creator, you might have a system tray icon that you can’t seem to get rid of.
Here’s how to turn off the Media Manager Services icon:
- Start Roxio Creator
- On the left side, click Audio.
- Then click Audio CD
- On the left bottom, click Settings
- Uncheck Watch Folders at Startup
- Then click OK
Add this to LocalSettings.php:
$wgGroupPermissions['*']['edit'] = false;
February 17th, 2009
Masao
The new short way:
$ date -d '1 day ago' +'%Y/%m/%d'
2009/07/21
Or the longer way:
Yesterday in epoch seconds
$ yesterday=$((`date +'%s'` - 86400))
Get default formatted yesterday's date
$ date -d "1970-01-01 $yesterday sec"
Tue Feb 17 01:27:32 PST 2009
Same thing in YY-MM-DD
$ date -d "1970-01-01 $yesterday sec" +"%Y-%m-%d"
2009-02-17
February 12th, 2009
Masao
- Create a label in Google Bookmarks with all the bookmarks you want to centralize.
- Then, create a live bookmark in Firefox with the following URL, replacing the label name with the one you created:
http://www.google.com/bookmarks/lookup?hl=en&sort=title&output=rss&q=label:live
February 10th, 2009
Masao
Instead of:
ALTER TABLE my_table ADD KEY `key1` (`apple`);
ALTER TABLE my_table ADD KEY `key2` (`banana`);
do this:
ALTER TABLE my_table
ADD KEY `key1` (`apple`),
ADD KEY `key2` (`banana`);
On the destination server, remove the known_hosts file:
rm ~/.ssh/known_hosts
Also, try this in your /etc/hosts.allow file
/etc/hosts.allow:
SSHD: ALL
Recent Comments