Posts

Excel: Strikethrough Shortcut

Ctrl + 5 Easier than having to go into the Font -> Extended menu every time.

Google Chrome: Manage Flash Sites

Image
The HTML5 client for VMware is missing some functionality so I need to run the Flash client in Google Chrome. I normally run the Canary or Dev channels of Chrome and the ability to add or block a sites ability to run Flash seems to have disappeared from Settings -> Advanced -> Content Settings -> Flash. It is still there in the Stable channel. My default Flash setting in all is "Ask First", but nothing happens in  Canary and Dev As per the instructions on: https://support.google.com/chrome/answer/6258784?co=GENIE.Platform%3DDesktop&hl=en The site needs Flash to work If a website isn’t working, you might need to change your settings to allow Flash. To the left of the web address, click Lock   or Info  . At the bottom, click Site Settings. In the new tab, to the right of "Flash," click Allow. Go back to the site and reload the page.

Linux: Permanent CIFS/SMB mount

I needed to permanently mount a directory on a Windows server that had spaces in the path. I also wanted to use a credentials file so that the remote server username and password would not be in the world readable fstab file. The following was cobbled together from: Mount samba shares with utf8 encoding using cifs and: Mount password protected network folders Create a credentials file (as root) containing the username and password and restrict it's ability to be read by other users (/etc/fstab is world readable). vi /root/.smbcredentials username=someusername password=somepassword Save and exit the file. Change the file permissions to only be readable by root. chmod 600 /root/.smbcredentials Update the fstab file Add the following line to /etc/fstab (spaces are replaced with \040  or the mount will fail) // ip address / c$/Program\040Files/Microsoft\040SQL\040Server/ /var/backups/Server cifs credentials=/root/.smbcredentials,iocharset=utf8,sec=ntlm 0 0 Exit ...

FreeBSD: Increment the serial number of every zone file by 1

I needed to increment the serial number of every zone on a master server to trigger an update to a new slave. Since I know next to nothing about csh the easiest way was the following one liner in sh: for i in `ls -1 | xargs`; do j="`awk '$3 == "Serial"{print $1 + 1}' $i`"; sed -i "" "s/^[[:digit:]]\{10\}\([[:space:]]\;[[:space:]]Serial\)/$j\1/" $i; echo -n "$i "; rndc reload $i; sleep 2; done

Linux: Display Hard Drive Serial Number For Each Device

I needed to physically replace a drive in an array and to do that I needed the serial number of the drive. for i in $(awk '/sd[a-z]+$/ { print $4 }' /proc/partitions | sort); do printf "%-5s%s\n" $i "$(smartctl -i /dev/$i | grep Serial | sed 's/^[^:]\+:[[:space:]]\+\([[:alnum:]\-]\+\)/\1/')"; done sda  WD-WXL708065381 sdaa Z1F1HLJN sdb  Z1F0YPP2 sdc  Z1F136GZ sdd  Z1F0X9X7 sde  Z1F136DE sdf  Z1F1HM91 sdg  9WM66QZP sdh  9WM73LV3 sdi  9WM6JLJT sdj  9WM73600 sdk  9WM6Y6B5 sdl  Z1F1HLMY sdm  9XH024P1 sdn  9XH025HS sdo  9XH01Y60 sdp  9XH025PY sdq  9WM6KMP3 sdr  9WM6PESG sds  9WM6QFZP sdt  9WM66ZY9 sdu  9WM6SAL6 sdv  Z1F1LVP2 sdw  Z1F11NKT sdx  Z1F11LB7 sdy  Z1F11NVV sdz  Z1F11MEF

Postfix: Delete from queue by header content

Normally you can use mailq to delete by sender or receipient, but postfix doesn't really have any tools to delete based on any other content in the email. Following is a quick and nasty one liner that I came up with to help a customer out. One of the websites he hosted had been compromised and was being used to send out spam. The only thing the emails had in common was a header. X-PHP-Originating-Script: 33:index2Xv6C.php for i in $(mailq | tail -n +2 | awk 'BEGIN { RS = "" } $1 ~ /^[[:alnum:]]/ { print $1 } ' | tr -d '*!' ); do if [[ $(postcat -hq "$i" | grep index2Xv6C.php) ]] ; then postsuper -d $i; fi; done It wasn't particularly quick but it didn't cause much load either.

Cron jobs running in UTC timezone on Virtuozzo 4.0 containers

Symptoms / etc / crontab showed that cron . daily should be running at 05:08 in the morning, but a grep of the syslogs showed that it was running at 18:08 at night. # grep daily / etc / crontab 8 5 * * * root test -x / usr / sbin / anacron || ( cd / && run-parts --report / etc / cron . daily ) # grep daily / var /log/ syslog . 0 Mar 25 18:08:01 vps /USR/SBIN/CRON [ 8110]: (root) CMD (test -x / usr / sbin / anacron || ( cd / && run-parts --report / etc / cron . daily )) The 'date' command showed the right timezone. # date Tue Mar 26 16:56:00 NZDT 2013 Cause / etc / timezone was malformed by having the the local timezone  appended, instead of overwritten, in the final stages of customisation  by Virtuozzo, when the container was installed. # cat / etc / timezone   Etc /UTC Pacific/Auckland Solution Removing the bogus "Etc/UTC" line from / etc / timezone fixed the problem.