Tuesday 17 December 2013

installing iLife through Apple Remote Desktop Task Server

So, I need to install iLife '09 through ARD Task Server on 17 machines. When install the iLife '09.mpkg file from my machine straight to one machine it works fine. If I give it the option to use the task server it comes up with:
Completed but failed on 1 package ""

In console on that machine I found this line:

17/12/2013 16:03:26.476 com.apple.RemoteDesktop.agent: iLife09.mpkg/Contents/Installers/iPhoto.mpkg/Contents/Installers/iPhotoContent.pkg/Contents/Archive.pax.gz: (Empty error message)


I tried renaming the mpkg file so as not to have the '09 but did not effect it.

I'm now trying it from the command line. The plan is to just send some commands to the machine to mount the server share, and run the installer:

mkdir /Volumes/YourTMPFolder
mount -t afp afp://admin:yourPassword@your.server.here/YourShare /Volumes/YourTMPFolder
installer -package /Volumes//Volumes/YourTMPFolder/iLife09.mpkg -target /
umount /Volumes/YourTMPFolder

Works perfectly!


Friday 6 December 2013

Apple Mac bootcamp reimaging with Windows 7 Blue Screen

We've been testing out a new re-imaging process for our Apple macs specifically to re-image them with Windows 7. It means that the imaging process is the same for all Windows 7 machines.

The trouble we are having is that after about 10 mins or less, the windows 7 machine, both iMacs and Mac Pro's, blue screen.

Unfortunately, the blue screen itself does not provide any answers. I haven't had a good look at the dmp files.

I did a google search and found this and this. Both of these forums are looking at an AppleMNT.sys problem, associated with mounting HFS volumes. I shall give this a go.

Wednesday 16 October 2013

Problems with Administrator login for 10.7 imaged macs

In the computer suites with 10.7 image machines I'm having a problem with the administrator account. When I login as the local administrator UID 501 I have no access to any of this users home folders, inluding the ~/Library folder. Having a look at the permissions shows that administrator is the owner with read-write permissions. Typing in the command:
sudo chown -R $USER ~$USER

Comes up with:
Folder does not exist

but typing in:
sudo chown -R $USER ~/Users/administrator


Administrators-iMac-49:~ administrator$ id -u $USER
501
Administrators-iMac-49:~ administrator$ ls -Al
total 64
-rw-------   1 administrator  staff      3  5 Jul  2012 .CFUserTextEncoding
-rw-r--r--@  1 administrator  staff  12292 10 Jul  2012 .DS_Store
drwxr-xr-x   4 administrator  staff    136  6 Jul  2012 .adobe
-rw-------   1 administrator  staff   3357 12 Jul  2012 .bash_history
-rwxrwxrwx@  1 administrator  staff     30  6 Jul  2012 .fgufohsrc
-rw-r--r--@  1 administrator  staff     17  6 Jul  2012 .sewtzsfn
drwxr-xr-x   2 administrator  staff     68  6 Jul  2012 Applications
drwx------+  5 administrator  staff    170 15 Oct 15:40 Desktop
drwx------+  7 administrator  staff    238  9 Jul  2012 Documents
drwx------+  6 administrator  staff    204 10 Jul  2012 Downloads
drwx------+ 39 administrator  staff   1326  9 Jul  2012 Library
drwx------+  3 administrator  staff    102  5 Jul  2012 Movies
drwx------+  4 administrator  staff    136  9 Jul  2012 Music
drwx------+  5 administrator  staff    170  6 Jul  2012 Pictures
drwxr-xr-x+  5 administrator  staff    170  5 Jul  2012 Public
lrwxr-xr-x   1 administrator  staff     63 12 Jul  2012 Send Registration -> /Users/administrator/Library/Assistants/Send Registration.setup
Administrators-iMac-49:~ administrator$ sudo chown -R $USER ~
Password:
Administrators-iMac-49:~ administrator$ ls -Al
total 64
-rw-------   1 administrator  staff      3  5 Jul  2012 .CFUserTextEncoding
-rw-r--r--@  1 administrator  staff  12292 10 Jul  2012 .DS_Store
drwxr-xr-x   4 administrator  staff    136  6 Jul  2012 .adobe
-rw-------   1 administrator  staff   3357 12 Jul  2012 .bash_history
-rwxrwxrwx@  1 administrator  staff     30  6 Jul  2012 .fgufohsrc
-rw-r--r--@  1 administrator  staff     17  6 Jul  2012 .sewtzsfn
drwxr-xr-x   2 administrator  staff     68  6 Jul  2012 Applications
drwx------+  5 administrator  staff    170 15 Oct 15:40 Desktop
drwx------+  7 administrator  staff    238  9 Jul  2012 Documents
drwx------+  6 administrator  staff    204 10 Jul  2012 Downloads
drwx------@ 39 administrator  staff   1326  9 Jul  2012 Library
drwx------+  3 administrator  staff    102  5 Jul  2012 Movies
drwx------+  4 administrator  staff    136  9 Jul  2012 Music
drwx------+  5 administrator  staff    170  6 Jul  2012 Pictures
drwxr-xr-x+  5 administrator  staff    170  5 Jul  2012 Public
lrwxr-xr-x   1 administrator  staff     63 12 Jul  2012 Send Registration -> /Users/administrator/Library/Assistants/Send Registration.setup


fixes the problem. Logging out and back in again randomly recreates the problem. It's as though there are two administrators with different UID's and it's random which one it logs in with. There is the possibility that there is a networked account. Next I shall switch off networked accounts and log in.

Just used the ls command which lists the UID instead of username:
ls -n
total 8
drwxr-xr-x   2 1414341556  20    68  6 Jul  2012 Applications
drwx------+  5 1414341556  20   170 15 Oct 15:40 Desktop
drwx------+  7 1414341556  20   238  9 Jul  2012 Documents
drwx------+  6 1414341556  20   204 10 Jul  2012 Downloads
drwx------+ 39 1414341556  20  1326  9 Jul  2012 Library
drwx------+  3 1414341556  20   102  5 Jul  2012 Movies
drwx------+  4 1414341556  20   136  9 Jul  2012 Music
drwx------+  5 1414341556  20   170  6 Jul  2012 Pictures
drwxr-xr-x+  5 1414341556  20   170  5 Jul  2012 Public
lrwxr-xr-x   1 1414341556  20    63 12 Jul  2012 Send Registration -> /Users/administrator/Library/Assistants/Send Registration.setup
Administrators-iMac-75:~ administrator$

Sorted, it simply thinks that there is an administrator account with UID 1414341556


Administrators-iMac-75:~ administrator$ id -u $USER
501
Administrators-iMac-75:~ administrator$

I have now run the command:
chown -R 501 /Users/administrator

I have yet to find a re-occurrence.

------------------- march 2014

well, I found a re-occurrence. I ended up renaming the administrator account to:

administratorb

Cheers

Tuesday 15 October 2013

Deleting 'forced' local home folders created from OS X 10.7 Active Directory Logins

When users log in to the apple macs at the college it creates a local home on the machine to save preferences and files, and mounts their home drive too.

After a year these fill up. After a few searches and researches, looks like the easiest way is to write a script which deletes all folders except certain ones. Looks like you can use the 'find' command. Found a good example here:


find . -maxdepth 1 -not -name 'filename.gif' -iname '*.gif' -delete

Here's the man page for find

So, I don't want to delete the folders:
Guest
Shared
administrator
media

So:
find . -maxdepth 1 -not -name 'Guest' -not -name 'Shared' -not -name 'administrator' -not -name 'media' -name '*' -delete
I tried '*.*' but it only then deletes files with '.' in them, not folders. '*' selects everything including folders

Actually, I found here that the slightly better way to do it was to use the -exec rm instead of -delete. This then tells you which directories were actually deleted:
find /Users/Shared -maxdepth 1 -mindepth 1 -not -name 'administrator' -not -name 'Guest' -not -name 'Shared' -not -name 'media' -exec rm -Rvf {} \;
The -mindepth 1 option makes sure it doesn't delete the parent directory.

A longer term solution would be to delete these folders on logout, so the students and staff could get used to not relying on these folders.

Friday 11 October 2013

Windows 7 connecting to Xserver OS X 10.4 probs

Whenever I try to connect to the smb share on the xserver from a windows 7 computer I am unable to authenticate. But I can from Windows XP and Windows 8!

After a quick look I found this helpful post page, specifically the 'Setspn' command. Digging more into it, there is a link which I think is to this page (outdated links). Do a search on this page for "Setspn" and you'll find it detailed there.

It looks like an authentication issue with Kerberos, where it then looks at using NTLMv2 to authenticate.

To solve the problem looks like you need to change the protocol Windows vista and 7 use back to either Kerberos or NTLMv1. To do this, type from the machine:

  1. Click Start.
  2. Type secpol.msc in the search box and press Enter.
  3. Windows Vista will display a warning message; click Continue.
  4. Windows Vista's Local Security Policy console will appear. Highlight Local Policies.
  5. Double-click Security Options.
  6. Scroll down to the Network Security: LAN Manager Authentication Level policy entry and double-click it.
  7. Change the value from the default setting of Send NTLMv2 Response Only to Send LM & NTLM -- Use NTLMv2 Session Security If Negotiated, then click OK. (Figure J).
  8. Close the Local Security Policy console.
I have yet to try this. But will do in the near future.

Or follow this:
C:\ setpn -L yourserver
This gets you a list of the service principals assigned to that computer record:
  • xgrid/yourserver.example.com
  • vpn/yourserver.example.com
  • ipp/yourserver.example.com
  • xmpp/yourserver.example.com
  • cifs/yourserver.example.com
  • host/yourserver.example.com
  • smtp/yourserver.example.com
  • HTTP/yourserver.example.com
  • pop/yourserver.example.com
  • imap/yourserver.example.com
  • ftp/yourserver.example.com
  • afpserver/yourserver.example.com
To add the appropriate record:
C:\setpn -A cifs/yourserver yourserver
This gets you:
  • cifs/yourserver
  • xgrid/yourserver.example.com
  • vpn/yourserver.example.com
  • ipp/yourserver.example.com
  • xmpp/yourserver.example.com
  • cifs/yourserver.example.com
  • host/yourserver.example.com
  • smtp/yourserver.example.com
  • HTTP/yourserver.example.com
  • pop/yourserver.example.com
  • imap/yourserver.example.com
  • ftp/yourserver.example.com
  • afpserver/yourserver.example.com

Wednesday 9 October 2013

No Windows installed in this Computer Suite sign

Thought I'd share this with everyone. Change as you see fit.

No Windows. Windows is not installed in this computer suite
Here's a link to the pdf of it.

Let me know if you use it. Cheers!

Thursday 26 September 2013

Installing Wacom Bamboo Pen and Touch on OS X using ARD Apple Remote Desktop error

It's a long story, but I'll cut it short. Anyhow, I have 12 x Wacom Bamboo Pen and Touch model number CTH-470 and they need installing on all Mac Computers. No problem, except the installer looks like an .app file. If you view the package contents you find a couple of pkg files. The most important is the "Install Bamboo.pkg".

Running this installer locally installs the tablet minus the dock (I don't think it's important). So, next thing is to try via Apple Remote Desktop (ARD). This ends up coming up with an error:

"Install Bamboo.pkg" could not be installed. Error message: "running package scripts..."

Well, just like the last time I tried to install Wacom tablets through ARD, turns out this error message isn't really an error message. After a reboot the tablet works like a dream on the computer.

Hope this helps someone.

Tuesday 17 September 2013

Apple Remote Desktop 3 with OS X 10.7 probs

Seem to be having quite a few problems since moving onto 10.7 with remote desktop 3 and task server 3.4 (xserve OS X 10.4.8)

What I think it boils down to is accidentally upgrading to ARD 3.6. I since downgraded but required a bit of uninstallation which Macs don't do by default.

Found this info on uninstalling ARD:

sudo rm -rf /var/db/RemoteManagement
sudo rm /Library/Preferences/com.apple.RemoteDesktop.plist
rm ~/Library/Preferences/com.apple.RemoteDesktop.plist
 

For Apple Remote Desktop 3, run these commands in Terminal as well:

sudo rm -r /Library/Application\ Support/Apple/Remote\ Desktop/
rm -r ~/Library/Application\ Support/Remote\ Desktop/



To Remove Apple Remote Desktop, execute these commands in Terminal:

sudo rm -rf /System/Library/CoreServices/Menu\ Extras/RemoteDesktop.menu
sudo rm -rf /System/Library/CoreServices/RemoteManagement/
sudo rm -rf /System/Library/PreferencePanes/ARDPref.prefPane
sudo rm -rf /System/Library/StartupItems/RemoteDesktopAgent/
sudo rm /Library/Preferences/com.apple.ARDAgent.plist
sudo rm /Library/Preferences/com.apple.RemoteManagement.plist

I Then re-installed ARD 3.5.1 and clients 3.5.1

Because I've got so much save in ARD, I made a point to backup the ARD plist files in ~/Library/Preferences

This means I have all my saved scripts.

Installing Dell Color Laser 3110cn on Mac OS X 10.7 and later

We have a growing number of Apple Macs which are now on OS X 10.7 and up. Dell have only released PowerPC installer for their drivers which doesn't run on OS X 10.7 or later. Thankfully I found a nice forum where someone (Chezloi) has found the relavent files and put them in the new relavent folders.

1. unzip and put the Dell/ folder in 'Mac HD/Library/Printers/'
2. unzip and put DellJobAccount.plugin in 'Mac HD/Library/Printers/Dell/PDEs/'
3. unzip and put DellSecurePrint.plugin in 'Mac HD/Library/Printers/Dell/PDEs/'
4. unzip and put the en.lproj/ folder in 'Mac HD/Printers/PPDs/Contents/Resources/'

Hopefully this helps some more people. Think I'll write an installer for it.

Thursday 15 August 2013

Apple Keyboard and Windows 7 @ and " characters swapped over

Since putting bootcamp on Apple Macs we've always had a problem where the keys on the Keyboard in windows were never 'quite' right. Almost, but not. The most annoying one was the old @ key being swapped with " key.

Even after installing bootcamp drivers this problem persisted. It did turn quite interesting though:
I went into keyboard language setup and added "United Kingdom (Apple)", and deleted the bog standard "United Kingdom". After this, in some dialogue boxes the keyboard was behaving correctly (" and @ not swapped) and in everything else the @ and " keys were swapped around!

After trauling through google search results, I searched for Keyboard Regedit as I was sure something could be done here. After finding this article about changing keyboard regions I did the following steps:

  1. Opened Regedit
  2. went to  HKEY_CURRENT_USER\Keyboard Layout\Preload
  3. Took note of what was here
    1. there were two entries:
      1. 1.   a0000809
      2. 1.  00000809
  4. I next went to  HKEY_USERS\.DEFAULT\Keyboard Layout\Preload
  5. Took a note what was here
    1. there was only one entry
      1. 1.  00000809
  6. I thus deduced that the Apple keyboard was a0000809 and the normal (incorrect) keyboard was 00000809
  7. I deleted the HKEY_CURRENT_USER\Keyboard Layout\Preload\00000809 so there was only one entry here
  8. I edited the HKEY_USERS\.DEFAULT\Keyboard Layout\Preload entry so it read:
    1. 1.  a0000809
  9. I rebooted and it all worked!!!!!
So, the problem was that Windows was using the Normal UK language layout for the keyboard, and when I added the Apple UK language layout it only used it at times because there was two entries for my login. But when the computer initially loads up the Apple version wasn't there. Now time for a cuppa.

Thursday 1 August 2013

Re-imaging Windows 7 on Apple Macs

So, we are now trialing a newer system for deploying Windows 7 on to our Apple Macs. Previously we've used Deploystudio, but as our Apple Server is too old, it is no longer up to the task.

For the rest of the PC's we use the Microsoft Imaging technique (whatever this is), and we're trying it with our macs.

Here's a step by step of what to do with the installer disk:

  1. insert disk
  2. set the default boot disk to be Windows (assuming Windows was previously installed)
  3. reboot and hold ALT
  4. select the CD
  5. Press ANY KEY
  6. log in with own credentials
  7. Select task sequence
    1. to determine which volume to boot from you need to run DISKPART. Type:
      1. SELECT DISK 0
      2. LIST VOLUMES
      3. SELECT VOLUME (type the volume number)
      4. LIST PARTITIONS
  8. Select to install BootCamp drivers
  9. Put name, domain details in
  10. Go!

Friday 19 July 2013

Getting Mac Model Identifiers using Command Line and ARD

I remember a few years ago ARD used to tell me the Mac Model Indentifier e.g. iMac12 ,2

Apparently not any more. I found this forum where they've found a command line argument which prints it:

system_profiler SPHardwareDataType | grep "Model Identifier" | awk '{ print $3; }'

This worked, although the machines needed to be switched on to find it. I wonder why Apple never kept this feature in ARD?

Thursday 27 June 2013

Google maps overlays

I'm going to start a project which involves overlaying different maps from past, present and future maps. My primary thoughts involved utilising Google maps API for this.

Looks like there's quite a bit of info. Here's some links:

Notes:

Some limitations

Stated in the beginning there are limits to the free use of the API. This is 25000 map initialisations per day, which I consider very high.

Not sure how many overlays you can have, and hopefully control which ones are on and off using sliders and buttons. - Yep, above. "Showing and hiding Overlays"

Half way down the page on Info on Overlays theres a nice example of Animating Symbols

Thursday 30 May 2013

Google Chrome downloads are invisible to Finder on OS X

For some reason whenever I download a file using Google Chrome on OS X I cannot see the file in the downloads folder. The only thing I've done is changed the default download folder to another location. I have noticed that the file is actually there using the 'ls' in terminal. Also, I can open the file from within Google Chrome.

Very odd, but I've had a look into it and found the hidden chflag which hides files from the finder. It's used so that people don't see and interfere with files they're not ment to.

A quick fix (but which I don't like) is to make all hidden files viewable from Finder. To do this open terminal and type:
defaults write com.apple.finder AppleShowAllFiles TRUE

It's very ugly because all I want to do is see the downloads which are hidden, not every file. They're made invisible for a reason.

Looking more into it, it turns out that files can be flagged up as 'hidden'. This makes them invisible. So to make files hidden or not hidden in terminal you type:
chflags nohidden afilethatishiddenforexample.txt

or to make it hidden again:
chflags nohidden afilethatisnothiddenforexample.txt

Think I'll just have to log out and back in again to fix Google Chrome properly.

Saturday 11 May 2013

watermarking photos in Aperture 2

Well, it could have been easier. Found a good tutorial here.

Simply put, you just have to make a picture file of the watermark you want on your images. Then, go to Aperture > Presets > Export and it's down the bottom.

Then when you export versions, it puts the watermark image on.

Friday 3 May 2013

Joomla and google maps

Just adding a location page. Best thing is to put google maps in. Turns out there are lots of Joomla extensions for this.

I've just tried Googlemaps plugin. Worked brilliantly! Lots and lots of settings you can use as well. A nice tutorial here. Just use {mosmap} in an article!

Found this article with describes all the parameters you can put in.

I ended up using this:

{mosmap width='800px'|lat='53.264392'|lon='-1.440947'|zoom='15'|zoomType='Large'|zoomNew='1'|mapType='Hybrid'|showMaptype='1'|dir='5'|
overview='1'|text='
Chesterfield Panthers RUFC, 2012 Dunston Road, Chesterfield
'}

Wednesday 1 May 2013

Events Calendar for Joomla

So I want to put a page up where you can see what events there are.

I found this very good plugin called Scheduler. Works beautifully but is limited in one specific way. You can't seem to put it along side an article. To view the calendar you have to click the specific menu for it. I found a couple of forums here but mentioned again here concludes its' very hard to do (if impossible).

JEvents isn't working too well and I might just give up on it after 10 mins (I"m too impatient).

Might just stick to making articles which expire after so long, and just have them in a list ordered by expiry date

Contact forms in Joomla and loading modules inside of articles

So I'm wanting to put a contact form up on a page in Joomla in the main content area. The easiest way looks to involve installing a plugin.

Found this free plugin called Rapid Contact. Once installed it is a module.

To load the module up where the main content should go require a little tweaking. Found this article on it.

Basically you make an article which contains a module position:

{loadposition testposition1}


Make a menu item which loads this article.

Then you make the module have the position "testposition1" and make sure it's loaded with the right menus item.

Done


Just found an even better alternative with Joomla 3. Here's the tutorial. Basically:

  1. Create a Contact and make sure the contact form is set to Show.
  2. Create a menu item to link to that contact!

Saturday 20 April 2013

enabling and installing pureftpd on Mac OS X 10.7

So, my computer is also acting as a web development server. As such, I'd like to access the files from anywhere so I decided I'd like something like FTP setup. But reading the forums FTP is a big no-no. Which is probably why Apple switched it off for OS X 10.7.

So, what are the alternatives:
PureFTPd

But how to install? Well, it needs to be compiled and then installed. Found the process here on an Apple Forum 3rd one down. He states:

find /usr/local -type f -name 'pure-*' | tar -czf pure-ftpd_backup.tgz -T -

tar xzf pure-ftpd-1.0.32.tar.gz
cd pure-ftpd-1.0.32
./configure --with-everything --with-tls --with-certfile=/etc/pure-ftpd/ssl/pure-ftpd.pem --sysconfdir=/etc/pure-ftpd/ --with-sysquotas --mandir /usr/local/man --with-pam --with-virtualchroot  --with-peruserlimits --with-ldap --with-rfc2640
make
sudo make install-strip
cd ..
rm -r pure-ftpd-1.0.32.tar.gz pure-ftpd-1.0.32
After this you can install PureFTPd Manager which should provide you with a GUI, although it states it works for OS X 10.6. Apparently works for 10.7.

Seems to work alright, although I'll have to read up about changing ports and setting up sftp stuff

Saturday 13 April 2013

website widths

Whenever I start making a website I'm always looking up what the current standard is. Here is an example of some peoples opinions.

General consensus is that in 2012/13 min size screen is 1280, but people don't necesarily use full screen browsing. So perhaps 980px is fine.

Another person has posted up some more fluid designs alternatives:

These look good

Friday 12 April 2013

Social networking sites and joomla

Just looking into enabling login via other site logins. i.e. facebook, google etc.

Found quite a few in the joomla extensions.

The best one I think I've found is LoginRadius Social Login. It's got a nice tutorial on how to install. Only problem is that you make an account through them, so they sort of act as the middle men.

I shall add to this once I've done a bit more research and tried it out.

For complete site jomsocial looks good

also joomlapolis.

Facilitates member interaction.


Just reading this article on creating a social network and it recommends SocialEngine.

Wednesday 10 April 2013

Making test sites in a subdirectory of a live joomla site

So I want a website which is a front end, but I want to be able to develop websites in subdirectories of this front-end site.

I just found this tutorial of how to do the reverse. Mainly editing the configuration.php file.

Also found this documentation from Joomla on how to move sites around in directorys/sub-directories

So, after much trial and error I finally got it working:

  1. So, I changed MAMPs directory to my new setup website:
    1. /Applications/MAMP/htdocs/mynewwebsite
  2. I then moved other websites within its' directory structure
    1. moved /Applications/MAMP/htdocs/testsite1 to /Applications/MAMP/htdocs/mynewwebsite/testsite1
  3. edited the configuration.php file in testsite1
    1. I actually found it had changed itself! But just to note:
    2. public $log_path = '/Applications/MAMP/htdocs/mynewwebsite/testsite1/logs';
    3. public $tmp_path = '/Applications/MAMP/htdocs/mynewwebsite/testsite1/tmp';
This sort of worked. It worked on the localhost machine perfectly, but when browsing externally it came up with:
404 - Article not found joomla error
I had a quick search and found this forum topic about it. Turns out a temporary fix is to turn off "Search Engine Friendly URLs" under Administration > Global Configuration > Site:


Viewsonic VX 800 blinking/flashing green LED light

A strange problem is occuring with a Viewsonic VX 800 monitor. Whenever it is switched on the green LED flashes constantly (every 0.5 seconds) and nothing appears on screen. But, after a prolonged period, the blinking will slow to once every 7 seconds. Perhaps not even after a long period. It is attached to an apple mac and when it reboots the screen sometimes comes on. Quite random. I guess what I'm trying to say is that I've not fully tested the situations out.

I found a few mentions of stuff but not very helpful. I guess because the screens are quite old.

Here I found a service manual but it's not very helpful

Saturday 6 April 2013

Finding the gradient of a graph

Having installed Octave I now want to find gradients of gradients of gradients...... of gradients.

This is a note to remind me to do this.

So, turns out there is a function which does this:
gradient(F)

so, here's me plotting a sine wave, and then drawing gradients of that graph:


x=0:0.1:20
y=sin(x)

plot(y)
hold all
plot(gradient(y)*10)
hold all
plot(gradient(gradient(y))*100)
hold all
plot(gradient((gradient((gradient(y)*10))*10))*10)
plot(gradient((gradient((gradient((gradient(y)*10))*10))*10))*10)



Monday 1 April 2013

redirecting/dns setup with home machine and a bought domain name

So, I have a computer at home hosting a website and I wanted it to have a nice domain name (mynicedomainname.co.uk). So here's how I did it:

  1. Sign up to no-ip
  2. setup a Host/Redirect
  3. Host type "DNS Host (A)"
  4. get it to use the ip address of your home machine
    1. install the no-ip client
    2. and set it up
  5. do port forwarding on your rooter to get it to point to the right computer on your home network
  6. Buy a domain (I did with www.daily.co.uk)
  7. go to Domains > Manage DNS >
  8. Add a hostname > www
    1. type > CNAME
    2. data > your.no-ip.address.here
  9. Delete the www one that was already there
Sorted!

Just trying to revert it back now. Found this help page.

Thursday 28 March 2013

C Programming - converting a number to hexidecimal and other bases larger then 10

I'm in the middle of writing a program which converts normal base 10 numbers into any base. When you convert to a base larger then 10 it gets a little confusing how to represent those numbers larger than 10. In hexidecimal the numbers 10 through to 15 are represented as A through to F. Here's a function I have written which converts a number in this way, representing larger then 10 numbers into letters up to Z.


//prints a number in a base using symbols for numbers greater than 10
//similar to hexidecimal. Max base is 36
void printInBaseWithUniqueSymbols (int number, int base){
assert(base > 1);
//find out how many units is needed to make the number
//int numberOfUnits = 1;
int units = base;
while (units <= number) {
//numberOfUnits ++;
units = units * base;
}
    //make an array which contains symbols to use from 1 to base
//using a to z for numbers 10 to 36
    char numberArray [base];
for (int i=0; i
if (i<10) {
numberArray[i]=(48+i);
else {
numberArray[i]= (65 + (i-10));
}

}
//printf("%c", numberArray[1]);
//work out which how many of each unit
    //int i = 0;
    
int result = number;
while (units > 1) {
units = units / base;
int numberOfUnits = result / units;
//printf("%c", numberOfUnits);
char character = numberArray[numberOfUnits];
printf("%c", character);
result = result % units;
        //i++;
}

}

Results:

Type a starting number: Running…
1
Type an end number: 100
Type a base to count in: 16
1 = 1
2 = 2
3 = 3
4 = 4
5 = 5
6 = 6
7 = 7
8 = 8
9 = 9
10 = A
11 = B
12 = C
13 = D
14 = E
15 = F
16 = 10
17 = 11
18 = 12
19 = 13
20 = 14
21 = 15
22 = 16
23 = 17
24 = 18
25 = 19
26 = 1A
27 = 1B
28 = 1C
29 = 1D
30 = 1E
31 = 1F
32 = 20
33 = 21
34 = 22
35 = 23
36 = 24
37 = 25
38 = 26
39 = 27
40 = 28
41 = 29
42 = 2A
43 = 2B
44 = 2C
45 = 2D
46 = 2E
47 = 2F
48 = 30
49 = 31
50 = 32
51 = 33
52 = 34
53 = 35
54 = 36
55 = 37
56 = 38
57 = 39
58 = 3A
59 = 3B
60 = 3C
61 = 3D
62 = 3E
63 = 3F
64 = 40
65 = 41
66 = 42
67 = 43
68 = 44
69 = 45
70 = 46
71 = 47
72 = 48
73 = 49
74 = 4A
75 = 4B
76 = 4C
77 = 4D
78 = 4E
79 = 4F
80 = 50
81 = 51
82 = 52
83 = 53
84 = 54
85 = 55
86 = 56
87 = 57
88 = 58
89 = 59
90 = 5A
91 = 5B
92 = 5C
93 = 5D
94 = 5E
95 = 5F
96 = 60
97 = 61
98 = 62
99 = 63
100 = 64

Tuesday 26 March 2013

installing Octave on Mac OS X 10.6 and 10.7

So, just read the wiki here. As it's open source, they havent yet made a pkg installer for it. Apparently, the best thing to do is to use a Package Manager to install it for you.

I've just tried Fink but the website isn't working. Looks like they've moved their website to http://fink.thetis.ig42.org/. Apperantly there's no pkg installer for this either! Here's the download for the binary.

I gave up here and found that MacPorts have an installer.

Installed MacPorts alright, but when I tried to run the command:

sudo port install octave-devel +atlas+docs
It came up with the error not knowing what the command "port" was. I had to type in:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
One prerequisite is to have xcode installed.


Having done all this, still came up with an error:
Error: Port octave-devel not found

I think it's because we have a proxy server which looks like complicated to add to MacPorts!

Oh well, might just try Matlab! (student version £55!)


....... a little time later......

So I'm now trying at home on OS X 10.7.5

Installed MacPorts
trying to install octave but comes up with:
Error: Port octave not found
Turns out you have to selfupdate MacPort in order for it to sync something or other. Type:
sudo port -v selfupdate
This then came up with the error:
rsync: failed to connect to rsync.macports.org: Connection refused (61)
rsync error: error in socket IO (code 10) at /SourceCache/rsync/rsync-42/rsync/clientserver.c(105) [receiver=2.6.9]
Command failed: /usr/bin/rsync -rtzv --delete-after rsync://rsync.macports.org/release/tarballs/base.tar /opt/local/var/macports/sources/rsync.macports.org/release/tarballs
Exit code: 10
Error: /opt/local/bin/port: port selfupdate failed: Error synchronizing MacPorts sources: command execution failed
Doh! Just did a search and found this. Turns out I have PeerGuardian running. Turned it off and ran selfupdate again which worked fine. So, next I tried installing octave again:
sudo port install octave
--->  Computing dependencies for octave
Error: Dependency 'atlas' not found.
Doh! I read this article which tells how other people are having the same trouble. Looks like one of the sync files on a server must be wrong. selfupdating port at some point will fix it;
sudo port -v selfupdate
sudo port install octave +accelerate +gcc45
What do you know? It worked!!

HP Scanjet 4370 browse devices not found

I have a computer suite with 5 x HP Scanjet 4370's. One of them can't be found on the attached computer. I have moved it from machine to machine and no machines seem to find it. The other scanners work fine. So it is clearly something wrong with this one.

On plugging it in to the power it makes the usual noises. Also when you reboot the machine and it is connected to the USB port it works.

When you load up HP Scan and click browse it just says 0 Devices found:
When you load up HP Scan and click browse it just says 0 Devices found:
The only real obvious thing to suspect is the USB port. After opening the scanner up, I found no evidence of loose connections or shorted circuits.

Looks like this ones a gonna.

Friday 22 March 2013

Screen Recording Project - timelapsed

So, I would like to record a whole working week, or maybe more, of work at my computer, but how?

Well, first off I think I want it to be time-lapsed. I think I would like 1 working day compressed into 1 minute:

1 working day = 8.5 x 60 = 510 minutes = 30600 seconds
1 minute = 60 seconds = 60 x 24fps = 1440 frames
30600 / 1440 = 21.25 seconds between each frame

Well, Quicktime does come with screen recording capabilities, but these are a bit hefty on the old processor/ram/disk space.

What I will probably do is make an Automator workflow which takes a screenshot every 21 seconds. Here it is:
Automator workflow which takes a screenshot every 22 seconds
By default "Take a screenshot" saves a file in a location but calls it something. For the next screenshot it overwrites the first. I had to use variables to change this.

Firstly I got a location variable and this contained the folder to save it to. I then got the time variable. I then made a text variable and dragged both of these other variables in, with a "/" in between. I dragged this variable into  the "Save to:" box. It then saves it to the location folder, with the name of the time it was taken.

I think you also need the "Get Value of Variable" before so it updates the variable "time".

Each screenshot is about 1.7MB:

1.7MB x 1440 = 2448MB per day.

I converted this into a quicktime movie using MPEGStreamClip  and it made a 17MB file! (15fps). Sorted!

To anonymise reducing it by 1/3rd (600 x 400 px) seems to render the text unreadable!


After a while of running this I got slightly annoyed at the screencapture noise. To run it silently I figured changing the preferences for it would work. Nope. Next I found the plist file:
com.apple.screencapture

But firstly it didn't exist, and next I couldn't find full documentation of it! Just the simple stuff like file format and location.

The command line for it is:

screencapture -x filelocation/filename.png

So I modified the automator workflow to use this command line instead of the screencapture object. It took 5 mins to work out how to access the variables in Run Shell Script but here's how I did it:
Screencapture workflow with automator using command line argument and passing variable
To access variables I think the only way is to pass them into the run shell script. I found this helpful page on it

The main points were:

  1. Make sure you ignore the inputs unless you really need them.
    1. i.e. I only really needed the full path name and filename combined so this was only passed into the "Run Shell Script"
  2. To use the passed variable you type:
    1. "$@"
      1. I don't think you need the speech marks but I needed them in the shell script
Now I'm thinking about it I don't think I need the workflow at all, could just run it using a simple shell script. But I think Automator is a nice way of introducing people to programming.

Tuesday 19 March 2013

Set Automatic Proxy Configuration through Command line in OS X 10.7

It took me a while to find it, but to set the Automatic Proxy Configuration url and tick the box through command line I found this helpful post which describes a script on how to do it.

First you need to find which network interface you want to change:

networksetup -listallnetworkservices
Ethernet

Use this in the command:
networksetup -setautoproxyurl Ethernet http://wpad.your.path.here/wpad.dat
By adding a url it automatically switches it on. To check:
networksetup -getautoproxyurl Ethernet
Simples. Don't know why it took me so long to find it. Don't think it's in the man page for networksetup for some reason!

Monday 18 March 2013

C Programming - convert number to any base

Just to continue with my programming practice I decided to write a function which takes a number and a base and converts that number to that base.

Here's the function:

//takes a number and a base to work to. It converts (just prints) this number to said base
//base has to be greater then 1
void printInBase(int number, int base) {
    
    assert(base > 1);
    
//find out how many units is needed to make the number
//int numberOfUnits = 1;
int units = base;
while (units <= number) {
//numberOfUnits ++;
units = units * base;
}
    //make an array which will be printed out in the end
    //int numberArray [numberOfUnits];
//work out which how many of each unit
    //int i = 0;
    
int result = number;
while (units > 1) {
units = units / base;
printf("%d", result / units);
result = result % units;
        //i++;
}
 
//prints out array
    //for (int c = 0; c <= numberOfUnits ; c++) {
    //    printf("%d", numberArray[c]);
    //}
}
 Output:
Type a starting number: 1
Type an end number: 30
Type a base to count in: 7
1 = 1
2 = 2
3 = 3
4 = 4
5 = 5
6 = 6
7 = 10
8 = 11
9 = 12
10 = 13
11 = 14
12 = 15
13 = 16
14 = 20
15 = 21
16 = 22
17 = 23
18 = 24
19 = 25
20 = 26
21 = 30
22 = 31
23 = 32
24 = 33
25 = 34
26 = 35
27 = 36
28 = 40
29 = 41
30 = 42
The function fails at counting base 1, but it hurts my brain too much to think about it! Also, to count in a base larger then 10, it's best to put a comma between digits. e.g:

Type a starting number: 1
Type an end number: 30
Type a base to count in: 15
1 = 1,
2 = 2,
3 = 3,
4 = 4,
5 = 5,
6 = 6,
7 = 7,
8 = 8,
9 = 9,
10 = 10,
11 = 11,
12 = 12,
13 = 13,
14 = 14,
15 = 1,0,
16 = 1,1,
17 = 1,2,
18 = 1,3,
19 = 1,4,
20 = 1,5,
21 = 1,6,
22 = 1,7,
23 = 1,8,
24 = 1,9,
25 = 1,10,
26 = 1,11,
27 = 1,12,
28 = 1,13,
29 = 1,14,
30 = 2,0,
This way you can distinguish between the 10's and 20's etc. Might be worth putting this in the function. But also, I could make it convert to hexadecimal? Might require more brain hurt.

Monday 11 March 2013

converting numbers/primes into binary

I want to compare some different number systems together with respect to primes. Wanted to know how to convert to binary. Thought this would be in-built to the computers/language, as all numbers are already stored as binary?

Anyway, found this forum with lots of different answers. Smallest answer was:
#include
int main(void) {
  int i, target;
  printf("Enter a number: ");
  scanf("%d", &target);
  for(i = 32; i--;) {
    if(target & (1 << i))
      putc('1', stdout);
    else
      putc('0', stdout);
  }
  return 0;
}

although they suggest altering part of it to


for(i=(j-1);i >= 0; i--)
/* or 'for(i=j;i--; )' would also work but is a bit too cryptic for me to get my head round */
{
  if(target & (1 << i))
    putc('1', stdout);
  else
    putc('0', stdout);
}

I shall try this out.

I ended up doing it my own way, mostly so that I could practice programming. I used the divide by 2 way, and if there is remainers then print 1, else print 0:

#define BINARYARRAYSIZE 1000

//converts a number into Binary and prints with greatest bit first
void convertAndPrintBinary (int number) {
    //printf("converting to binary\n");
    
    
    int binaryArray [BINARYARRAYSIZE] = {0};
    int i = 0;
    for (int result = number; result > 0; result = result/2) {
        
        if (result % 2 == 0 ) {
            binaryArray[i]=0;
            //printf("0");
        else {
            binaryArray[i]=1;
            //printf("1");
        }
        
        i++;
    }
    
    //printf("%d\n", i );
    
    //prints out array in reverse
    for (int c = i-1; c >=0 ; c--) {
        printf("%d", binaryArray[c]);
    }
    
}

Worked really well in the end:

Type a starting number: 1
Type an end numbers: 20
1 = 1
2 = 10
3 = 11
4 = 100
5 = 101
6 = 110
7 = 111
8 = 1000
9 = 1001
10 = 1010
11 = 1011
12 = 1100
13 = 1101
14 = 1110
15 = 1111
16 = 10000
17 = 10001
18 = 10010
19 = 10011
20 = 10100

I used BINARYARRAYSIZE because I didn't want to run the first for loop twice; once to measure how big the array needed to be, and the second to fill it. When I didn't give the array a size to begin with, it kept erroring. But 1000 digits for binary is a large number!