Tuesday, January 15, 2013

Seagate GoFlex Home running Arch Linux ARM from ext3 partition with ext3 NAS partition

After using the guide here to get the bootloader onto the GoFlex flash memory (it wipes the original boot sequence, so make sure you really want to do this—keep in mind it is great to do though!), I took the drive out of the casing and hooked it up directly to my linux machine (Linux Mint 14 Cinnamon) and wiped everything and made two partitions, one for linux and one for your data (this way you get almost all of the 3TB minus 4 GB for linux space). I did the following:
before I began, I downloaded the arch linux ARM files:  
wget http://archlinuxarm.org/os/ArchLinuxARM-armv5te-latest.tar.gz
sudo -s
parted /dev/sdj  (or whatever the device address is)
mklabel gpt
mkpart primary 1 4GB
mkpart primary 4GB -1 (-1 means fill the rest)
mke2fs -j /dev/sdj1 (gives partition ext3 format)
mke2fs -j /dev/sdj2 (if large partition, takes awhile)
mount /dev/sdj1 /media/alarm (you have to run mkdir /media/alarm if you don't have that folder
cp ArchLinuxARM-armv5te-latest.tar.gz /media/alarm/
tar -xvzf ArchLinuxARM-armv5te-latest.tar.gz
rm ArchLinuxARM-armv5te-latest.tar.gz
gdisk /dev/sdj
(follow guide below except for the type 0700 and 8300, i ignored that and still worked, don't even know what that is)
once followed, run pacman -Syu (upgrade system, answered yes to everything)
Problem step was adding UUID="theuuidforsda2" /media/NASdata ext3 defaults 0 0 to the fstab
On the next boot, I got a green light but no IP address to SSH to.

I installed gdisk then ran it. both partitions where type 0700 but the usb was 8300 so i used option 't' to change both partitions type code to 8300.

Then used option r for recovery and h for hybrid.

I put both partitions in the sequence, at 'Place EFI GPT partition first question I answered no. I used hex code 83 for both partitions giving the first the bootable flag and then answered no to the protect more patitions question. Then m for main menu and w to write.

Removed the usb and did reboot and the light flashed then went solid. ssh into the drive ok.

Check ensure system running

do a reboot (warm start):

shutdown -r now

and then later shutdown:

shutdown -h now

then power up (cold start)

Friday, March 2, 2012

Move the /Developer folder to an external usb/firewire harddrive or another partition

The installer for Xcode 4 does not allow you to switch the install locations if you just run the installer downloaded from the App Store. When it finishes installing, a directory called Developer will have been created the root of the harddrive. I own a Macbook Air with limited flash space. The developer directory is a pig and I don't really use it much on my laptop, but I wanted to install a few unix utilities from MacPorts. Here is how you do it:

Step 1: I used rsync to move the /Developer folder to my external usb harddrive. You might be able to copy it without rsync, but I used rsync + option "-a" for getting the permissions copied.
sudo rsync -az --progress /Developer /Volumes/USBDRIVE/

Step 2: I then created a symbolic link to the new folder on the usb drive.
sudo ln -s /Volumes/USBDRIVE/Developer /Developer

Step 3 (optional for MacPorts): Edit your macports.conf to include the new location of xcode. I used TextWrangler because it can handle the root access to edit the file. You could also use nano. Look for this line "developer_dir Developer/Applications/Xcode.app/Contents/Developer" and change the path to your path.
sudo open -a TextWrangler /opt/local/etc/macports/macports.conf
sudo nano /opt/local/etc/macports/macports.conf


Wednesday, February 29, 2012

Nifty Box - Add Finder Color Label to Untagged Files in Particular Folder AppleScript

This script will let you pick a color and a folder to scan. It will not color folders, just files. Its helpful in finding unneeded files. You can add a tag to important files and remove those files which are not needed.

--color selection
set theColors to {"blank", "orange", "red", "yellow", "blue", "purple", "green", "gray"}

set myColor to (choose from list theColors)
if (myColor is false) then error number -128
set myColor to item 1 of myColor

--this part finds out what theIndex (number) the label is.
set a to 1
repeat until ((item a of theColors) is myColor)
set a to (a + 1)
end repeat
set theIndex to a - 1

-- Or, in this case, simply:
-- tell application "Finder" to set label index of entire contents of mainFolder to theIndex

-----------------------end of color selection code
--i get the desired nifty box tagged items--ouput is posix path names in list "taggedList"
tell application "Nifty Box"
set tagged_items to nbitems
set taggedPosix to {}
repeat with x in tagged_items
set end of taggedPosix to item location of x
end repeat
end tell
tell application "Nifty Box"
set f to folder "test" -- top level folder
set taggedList to tagged nbitems of f
set taggedPosix to {}
repeat with i in taggedList
set end of taggedPosix to item location of i
end repeat
end tell
--i get files in folder which should be checked for tags--outout is posix path names--and put all files in list "filesList"
set myDir to (choose folder)

-- we have to remove the trailing / from the folder path so the
-- returned paths from the find command are correct
set posix_folder to text 1 thru -2 of (POSIX path of myDir) -- text 1 thru -2 of (POSIX path of myDir) to remove trailing forward slash

-- use find to quickly find the items in this_folder
-- also filter out invisible files and files in invisible folders
-- also filter files inside of package files like ".app" files
set allfilesPosix to paragraphs of (do shell script "find " & quoted form of posix_folder & " -name \"*.*\" ! -path \"*/.*\" ! -path \"*.app/*\" ! -path \"*.scptd/*\" ! -path \"*.rtfd/*\" ! -path \"*.xcodeproj/*\"") as list
--set allfilesPosix to allfilesPara as list
--i do the color labels

--this line marks the end of the POSIX code
--i convert both lists, taggedPosix->taggedList and allfilesPosix->allfilesList to AppleScript References
set taggedList to {}
repeat with i in taggedPosix
set end of taggedList to POSIX file i
end repeat

set allfilesList to {}
repeat with i in allfilesPosix
set end of allfilesList to POSIX file i
end repeat

set untaggedPosix to {}
repeat with theItem in allfilesPosix
if theItem is not in taggedPosix then set end of untaggedPosix to (contents of theItem)
end repeat
get untaggedPosix

set untaggedList to {}
repeat with i in untaggedPosix
set end of untaggedList to POSIX file i
end repeat
get untaggedList

tell application "Finder"
repeat with i in untaggedList
set label index of (item i) to theIndex
end repeat
end tell

Tuesday, February 28, 2012

Customizing Microsoft Word with AppleScript

Original HOWTO Document

Customizing Microsoft Word with AppleScript
The first step in doing anything in Microsoft Word or Microsoft Excel with AppleScript is to download the tutorials for MS Office 2004 from Microsoft.

I started using Xelatex for my linguistics papers and I decided that I didn’t really need to go that hardcore. I decided to write scripts to boss around MS Word and make it imitate the quality of my Xelatex papers (which are great, but you can’t just copy and paste them due to the nature of code).
Outline of my idea

Use Microsoft Excel to set variables
Use AppleScript to generate a plist from excel file stored in ~/Library/Preferences
Use AppleScript to retrieve those properties from the plist in ~/Library/Preferences and apply them to a Word Document.

The following is an example Excel Document with can be used to set various settings in a Microsoft Word Document.
Setting Value Type of Value Accepted Comments
boldHeading1 TRUE boolean
boldHeading2 TRUE boolean
boldHeading3 TRUE boolean
boldHeading4 TRUE boolean
boldHeading5 TRUE boolean
boldHeading6 TRUE boolean
boldHeading7 TRUE boolean
boldHeading8 TRUE boolean
boldHeading9 TRUE boolean
boldNormal FALSE boolean
footerLine TRUE boolean
headerLine TRUE boolean
italicsHeading1 FALSE boolean
italicsHeading1 FALSE boolean
italicsHeading2 FALSE boolean
italicsHeading3 FALSE boolean
italicsHeading4 FALSE boolean
italicsHeading5 FALSE boolean
italicsHeading6 FALSE boolean
italicsHeading7 FALSE boolean
italicsHeading8 FALSE boolean
italicsHeading9 FALSE boolean
italicsNormal FALSE boolean
sectionNumbering TRUE boolean number each heading
smallcapscaptionFigures TRUE boolean
smallcapscaptionTables TRUE boolean
coverdateAuto TRUE boolean if false, applescript tries to use the dateCustom field
coverPage TRUE boolean makes cover appear on new page
footerlineThickness 25 integer points
headerlineThickness 25 integer
sizeHeading1 15 integer font size
sizeNormal 12 integer
marginpageL 2 integer sets page margin
marginpageT 2 integer sets page margin
marginpageR 2 integer sets page margin
marginpageB 2 integer sets page margin
sizeHeading2 14 integer
sizeHeading3 13 integer
sizeHeading4 12 integer
sizeHeading5 12 integer
sizeHeading6 12 integer
sizeHeading7 12 integer
sizeHeading8 12 integer
sizeHeading9 12 integer
colorHeading1 black string
colorHeading2 black string color word
colorHeading3 black string color word
colorHeading4 black string color word
colorHeading5 black string color word
colorHeading6 black string color word
colorHeading7 black string color word
colorHeading8 black string color word
colorHeading9 black string color word
colorNormal black string color word
fontcaptionFigures CMU Serif Roman string system font name
fontHeading1 CMU Serif Roman string system font name
fontHeading2 CMU Serif Roman string system font name
fontHeading3 CMU Serif Roman string system font name
fontHeading4 CMU Serif Roman string system font name
fontHeading5 CMU Serif Roman string system font name
fontHeading6 CMU Serif Roman string system font name
fontHeading7 CMU Serif Roman string system font name
fontHeading8 CMU Serif Roman string system font name
fontHeading9 CMU Serif Roman string system font name
fontNormal CMU Serif Roman string "normal" style font
sectionnumberingType list template 5 of list gallery 3 string this refers to the list numbering menu in word
textfooterL 1 string sets text of footer left
textfooterM 1 string sets text of footer middle
textfooterR 1 string sets text of footer right
textheaderL 1 string sets text of header left
textheaderM 1 string sets text of header middle
textheaderR 1 string sets text of header right
fontcaptionTables CMU Serif Roman string
coverTitle 1 string
coverAuthor 1 string
coverdateCustom 1 string
coverDegree Master of Linguisics string
coverUniversity Universität Innsbruck string
coverPresentedto presented to the faculty of blah blah string if blank, not included

AppleScript to Read Excel to Plist file
The following script only needs to be run once. It will generate the property list file for the “Apply Settings to Word Document” script. If you make any changes to the settings, it will need to be run again to replace the old plist file.

set theFile to (choose file with prompt "Please select a Microsoft Excel file") as string

set theColumn to text returned of (display dialog "Please select a range" default answer "A2:C72")

set theRange to (theColumn) as string

tell application "Microsoft Excel"

open workbook workbook file name theFile

set aList to get value of range "A2:C72" of active sheet

end tell

--set up new plist file using the empty dictionary list item as contents

set userDir to (path to current user folder) as string

set plistfilePath to userDir & "Library:Preferences:msword.Academicsetup.plist"

tell application "System Events"

set the parent_dictionary to make new property list item with properties {kind:record}

set outFile to make new property list file with properties {contents:parent_dictionary, name:plistfilePath}

--add values to plist

tell outFile

repeat with i from 1 to (count of aList)

set keyName to (item 1 of (item i of aList) as string)

set keyValue to (item 2 of (item i of aList) as string)

set keyType to (item 3 of (item i of aList) as string)

if keyType is "boolean" then

make new property list item at end with properties ¬

{kind:boolean, name:keyName, value:keyValue}

end if

if keyType is "string" then

make new property list item at end with properties ¬

{kind:string, name:keyName, value:keyValue}

end if

if keyType is "integer" then

--important step to avoid real numbers (with decimals), coerse keyValue to be integer

-- create an integer entry

make new property list item at end with properties ¬

{kind:number, name:keyName, value:(keyValue as integer)}

end if

end repeat

end tell

end tell
say "Dieses Skript ist fertig!"
AppleScript to Apply Settings to Word Document


set userDir to (path to current user folder) as string

set plistfilePath to userDir & "Library:Preferences:msword.Academicsetup.plist"

global plistfilePath


tell application "Microsoft Word"

tell active document











end tell


end tell

on pL(theItem)

tell application "System Events"

set p_list to property list file (my plistfilePath)

value of property list item (theItem as string) of p_list

end tell

end pL

Saturday, February 25, 2012

Use Nifty Box to keep track of important files and folders on your Mac.

Free Downloads (by the way, Leap does the same thing as Nifty Box, but costs 60 dollars)
Nifty Box Download/
OpenMeta Exporter DownloadUPDATE: OpenMeta Exporter is no longer needed.

Step 1: Create an AppleScript droplet for adding Nifty Box tags to files easily.
on open (the_Droppings)
set theTags to text returned of (display dialog "Pick a tag! (you can add more than one tag by leaving a space between each word" default answer "")
if theTags is equal to "" then
display dialog "You must enter a tag"
exit repeat
set defaulDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to " "
set thelistofTags to text items of theTags
set AppleScript's text item delimiters to defaulDelims
tell application "Nifty Box"
set theFile to the_Droppings
set x to add path POSIX path of theFile
x add tags named thelistofTags
tags of x
end tell
end if
end open

Step 2: Add the Droplet to your Finder Window and drag files to it.

Step 3: Add some tags.

Step 4: This is the result in Nifty Box.

Step 5: Use Spotlight to find files using Nifty Box meta tags (Convert meta tags from Nifty Box to OpenMeta with the OpenMeta Exporter). UPDATE: The newer version of Nifty Box will auto export to Spotlight wihtout the need for OpenMeta Exporter. Tags even show up in the Finder>More Info window.

Friday, February 24, 2012

How to create Terminal aliases in Mac OS X Lion

How to make Mac OS X Terminal Aliases
#first create a file called .bash_profile in your home directory
touch ~/.bash_profile
#then add your aliases with the following
nano ~/.bash_profile
open -a TextEdit ~/.bash_profile
# add things like this
alias text="open -a TextEdit"
alias dt="cd ~/Desktop"