hunting for a random string

.. in a large (and completely undocumented) database, I’ve found the ways to get all tables that have a column name like ‘string’ and all rows that contain a string. A bit more optimized than my previous search&replace example.

select t.name as tname, SCHEMA_NAME(schema_id) as sname, c.name as cname
from sys.tables t join sys.columns c
on t.object_id=c.object_id
where c.name like '%dns%'
order by sname, tname
 
EXEC SearchTables @Tablenames = '%',@SearchStr = 'host%'

Continue reading “hunting for a random string”

move a centos / scientificlinux install to a new drive

While dd / partimage might work just fine, these steps detail exactly what data is where and how it got to the disk during install. Assuming old=sda new=sdb

  1. fdisk -ucl /dev/sda, create identical ones on sdb, I’ll assume just a small ext4 sdb1 for boot and LVM sdb2 that fills the disk
  2. pvdisplay && pvcreate /dev/sdb2
  3. vgdisplay && vgcreate rootvg /dev/sdb2 -s 32M
  4. lvdisplay &&  lvcreate -L 300G -n rootlv rootvg
  5. mkfs.ext4 /dev/sdb1
  6. mkfs.ext4 /dev/mapper/rootvg-rootlv
  7. optional tune2fs -c 0 -i 0 /dev/mapper/rootvg-rootlv
  8. mount /dev/sdb1 newboot && mount /dev/mapper/rootvg-rootlv newroot
  9. rsync -aADHvxX /boot/ newboot/
  10. rsync -aADHvxX / newroot/
  11. rsync -aADHvxX /dev/ newroot/dev/
  12. blkid /dev/sdb1, write the UUID in newroot/etc/fstab
  13. mkswap /dev/mapper/rootvg-swaplv
  14. edit fstab
  15. edit newboot/boot/grub.conf
  16. mount –bind newboot/ newroot/boot
  17. mount –bind /dev/ newroot/dev
  18. mount -t proc none newroot/proc
  19. mount -t sysfs none newroot/sys
  20. chroot newroot
  21. echo -e “rootnoverify (hd1,0)\nsetup (hd1)” | grub –batch
  22. sync && poweroff

CPU throttling on an Acer Aspire 3000

When running the default (retail) XP SP3 OS, this laptop runs at full CPU speed, and becomes worryingly hot in the process. Since Acer’s e* Management package doesn’t seem to actually do anything, the solution so far is to:

  1. Download RMClock
  2. Keep only two profiles, 4.0@0.975V and 8.0@1.175V
  3. Set profile to “Performance on demand” and “Use PST”

If you don’t run with administrator privileges by default,

  1. Install AdmiLink (yes, it’s in Russian)
  2. Point it to the full path to RMClock.exe, ShowWindow -d10 SHOWDEFAULT, link in AutoStart folder, delay enough seconds for the shell to load

Enabling “legacy” VNC auth on the Mac

  1. You won’t need this if you connect with Apple’s client or with Jolly’s FastVNC. Most other clients though (tightvnc) require an initial password instead of presenting OS X’s login window.
  2. From a root prompt:
    1. Turn Screen Sharing off:
      sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -stop
    2. cat > /Library/Preferences/com.apple.RemoteManagement.plist
      <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
      <plist version="1.0">
      <dict>
      <key>ARD_AllLocalUsers</key> <false/>
      <key>LoadRemoteManagementMenuExtra</key> <true/>
      <key>ScreenSharingReqPermEnabled</key> <true/>
      <key>VNCLegacyConnectionsEnabled</key> <true/>
      </dict>
      </plist>
    3. echo enabled >/Library/Preferences/com.apple.ScreenSharing.launchd
    4. Generate an encrypted password (actually it is not encrypted, only truncated to 8 characters and XORed with a fixed key):
      echo p4sv0rdd | perl -we 'BEGIN { @k = unpack "C*", pack "H*", "1734516E8BA8C5E2FF1C39567390ADCA"}; $_ = <>; chomp; s/^(.{8}).*/$1/; @p = unpack "C*", $_; foreach (@k) { printf "%02X", $_ ^ (shift @p || 0) }; print "\n"' | tee /Library/Preferences/com.apple.VNCSettings.txt
    5. Not sure why, but to start you must use stop again:
      sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -stop
      sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -users admin -privs -all -restart -agent

Referenced from here and here.

which java? (for applet security settings)

In Ubuntu:

update-alternatives --list java

the output should be something like

There are 2 choices for the alternative java (providing /usr/bin/java).
Selection    Path                       Priority   Status
------------------------------------------------------------
* 0            /usr/bin/java-j2re1.6-ibm   1200      auto mode
  1            /usr/bin/java-j2re1.6-ibm   1200      manual mode
  2            /usr/bin/java-j2sdk1.6-ibm  1200      manual mode

so JAVA_HOME is

/usr/lib/j2re1.6-ibm/jre

and the file to edit is

$JAVA_HOME/lib/security/java.policy

File syntax is something like

grant codeBase "http://somehost.com:80/*" {
  permission java.security.AllPermission;
};

Typing accented letters without switching keyboard layouts

Configure some less-used key (right win) as “compose key”. For Ubuntu/Gnome, this is in System->Preferences->Keyboard->Options. Typing RWin+a modifier then the letter will result in:

rw+’: a-á e-é i-í o-ó r-ŕ s-ś z-ź w-ẃ

rw+`: a-à e-è o-ò

rw+<: z-ž c-č

rw+key pressed twice: a-å o-° e-ə

.. and a lot of others, the full list of shortcuts available depends on the GTK implementations and can be checked in gtkimcontextsimpleseqs.h

Bad Behavior has blocked 122 access attempts in the last 7 days.