Coding help and stuff
Wednesday, August 22, 2012
Monday, May 14, 2012
Finding intersection of two regression lines using R
Suppose m1 and m2 are 2 regression models created using lm() in R, then try
cm <- rbind(coef(m1),coef(m2)) # Coefficient matrix
c(-solve(cbind(cm[,2],-1)) %*% cm[,1])
which would give you the point of intersection.
Tuesday, March 6, 2012
protect(): protection stack overflow
Monday, March 5, 2012
Securing Mac's Single User Mode
Monday, February 27, 2012
Backup failed hard disk data on Mac
I recently encountered a Mac that would not boot properly. However, it did boot into single-user mode and allowed access to the file system via the command line interface. Since I had recently purchased an external, portable USB drive, I wanted to offload my important files to the USB drive before reformatting and reinstalling a fresh system. Here are the steps I took:
- Connect USB drive to Mac and boot into single-user mode (cmd-s)
- At prompt type:
/sbin/mount -uw /
then hit return
- At prompt type:
/sbin/fsck -fy
then hit return
- At prompt type:
ls /Volumes
then hit return. This should provide a list of mounted volumes. It’s likely that your USB drive will not show. If this is true, then you will need to create a sharepoint in the /Volumes directory. You do this by using this command (in this case, we are creating a directory called “usb”):
mkdir /Volumes/usb
then hit return
- Next we need to identify the disk number of the USB drive. This is done with this command:
ls /dev/disk*
then hit return. The system will list the disks like this:
In most cases, the USB drive will be the last disk number listed (in this case: disk0s3).
- Now, to mount this disk to your sharepoint, type the following command:
/sbin/mount_msdos /dev/disk0s3 /Volumes/usb
then hit return. NOTE: In this case, we are using disk0s3 since it is the last listed. Yours will likely be different. Also note that my Western Digital USB drive uses the msdos format. Yours may not.
- If this is mounted properly, you will be able to see the contents of your USB drive by using this command:
ls /Volumes/usb
then hit return
- If you have successfully mounted the USB drive, you may now copy files using thecpcommand. (In this example, I will copy a file named “testfile” and assume the Mac has a volume named MacHardDrive.) For example:
cp /Volumes/MacHardDrive/testfile /Volumes/usb/
then hit return.
You can use this method to copy entire directories from your ailing Mac to the USB drive. In my case, I copied the entire user account directory over to the USB drive so I would keep settings, mail, music, pictures, and files in my Documents directory.
Monday, August 22, 2011
Rapid Miner and R extension problem on Mac solved
Enter the following in either /etc/profile or ~/.bash_profile
PATH=$PATH:/Library/Frameworks/R.framework/Versions/2.12/Resources/bin:/Library/Frameworks/R.framework/Versions/2.12/Resources/library/rJava/jri
R_HOME=/Library/Frameworks/R.framework/Versions/2.12/Resources
export R_HOME
In the /Library/Frameworks/R.framework/Versions/2.12/Resources/library/rJava/jri/ folder, do the following:
1) Rename the JRI.jar to JRI.jar.original
2) make a copy of the libjri.jnilib and rename this copy to JRI.jar
This is because, by default it looks for JRI.jar
Once rapidminer is started, in the R preferences, change the rapid.miner.r.native lib file back to /Library/Frameworks/R.framework/Versions/2.12/Resources/library/rJava/jri/libjri.jnilib
Delete the JRI.jar (copied from libjri.jnilib)
Rename back JRI.jar.original to JRI.jar.
Wednesday, August 3, 2011
Download file from terminal MAC OSX versus Linux
curl -O ftp://abc.tar.gz &
On Linux, use:
wget ftp://abc.tar.gz &