AppleScript Date Calculations

Calculations for determining the week of the year in AppleScript.

Taken from Dates & Times in AppleScripts

The following AppleScript subroutine can be used to help calculate the week of the year. It returns the number of weeks that have elapsed since date "1/1/0001":

on getDatesWeekNum(theDate)
set {dDate, dDateNum} to {"1/1/1000", 364878}
return ((theDate - (date dDate)) div days + dDateNum) div 7 + 1
end getDatesWeekNum

Technology:

Customize Terminal

Hate how OS X's Terminal.app doesn't respond to page-up, page-down and other keystrokes the same way a Linux shell does? Here's how to tweak it.

Window Settings -> Keyboard

Page Up/Down
Select Page Down and click the Edit button. Change the Action to send string to shell. The \033 is entered by pressing the ESC key. The string to enter is:

\033[6~    (page down)
\033[5~    (page up)

Beginning and end-of-line

\033[1~   (beginning-of-line)
\033[4~   (end-of-line)

Forward/Back a word
Edit both ~/.inputrc and Terminal preferences to get this to work in Vim.

Technology:

Using Input Filters

CentOS 4 and older megaraid driver

Getting a Dell PowerEdge 4300 with a PERC2 card to function under Centos 4.

http://www.tuxyturvy.com/blog/index.php?/archives/4-Installing-RHEL4-on-Systems-with-Legacy-Megaraid-Drivers.html

Dell PowerEdge 4300 server.
CentOS 4.4 (because that one has a single server CD installer).
Compiling the megaraid driver
Install the appropriate kernel-devel for your installation media. In the case of CentOS 4.4, that was 2.6.9-42. This machine was also a multiprocessor model, so the smp version was needed. CentOS needs 586 versions for the installer but needs 686 versions in order to run, so both will need to be compiled.

Cool Drupal sites

Authenticate Drupal to OS X Server's Open Directory

Your Drupal website can authenticate users stored in OS X Server's databse, Open Directory.

These settings worked for OS X Server 10.3 (Panther). Not sure how compatible they are with Tiger and Leopard.

LDAP Integration settings
LDAP Port: 389
Base DN: cn=users,dc=yourdomain,dc=com
UserName attribute: uid

LDAP Groups settings
Groups exist as LDAP entries where a multivalued attribute contains the members' CNs
Nodes containing groups (one per line): cn=groups,dc=,dc=com
Attribute holding group members: memberUid

Shell Script Snippets

Rename multiple files:

for i in *.avi
do
j=`echo $i | sed 's/find/replace/g'`
mv "$i" "$j"
done

Can also be written on a single line as

for i in *.avi; do j=`echo $i | sed 's/find/replace/g'`; mv "$i" "$j"; done

Finding Multiple Files in a directory
Find and count how many files were modified more than 365 days ago:

Technology:

Bootcamp on an already partitioned drive

New MacBook at work with OS X 10.5 (Leopard) on it. However, due to compatibility issues with some software, the machine will probably need to run OS X 10.4 instead. While I have the thing, figured I'd also install Windows XP on it so I could experiment with my Windows deployment guide.

Technology:

VNC Server

How to install and enable a VNC server on your Centos box.

Edit the config file /etc/sysconfig/vncserver

VNCSERVERS="2:root"
VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd"

Set a VNC password:

vncpasswd

Enable automatic startup of the daemon:

chkconfig --levels 345 vncserver on

Start the daemon:

service vncserver start

Technology:

Create a patch file

How to create your own patch files.

Creating a patch
For a directory of files:

diff -Naur olddir newdir > new-patch

or for a single file:

diff -Naur oldfile newfile >new-patch

Applying a patch

patch -p0 < /path/to/new-patch
patch -p1 < /path/to/new-patch

Which one of the above patch commands you use depends on your current working directory.
The -p option will optionally strip off directory levels from the patchfile. For Ex: if you have a patchfile with a header as such:

Technology:

Pages

Subscribe to Production Monkeys RSS

Recent Updates

  • 3 weeks 6 days ago
  • 3 weeks 6 days ago
  • 1 month 9 min ago
    php 8.x
  • 1 month 1 day ago
    10.6.7
  • 1 month 2 days ago
    Drop Centos 5/6 stuff