Bluetooth Chinese/Apple keyboard power supply.

I’ve discovered that if I rig in a 3.3 volt doc power pack to my Apple lookalike keyboard, in place of the batteries, then it doesn’t go to sleep on me all the time.

I use the Bluetooth keyboard to write on my iPad mini all the time, sitting at the dining table. It was driving me nuts with it going to sleep all the time, the keyboard that is, and as the batteries run down it gets worse and worse.

So, I took the batteries out and wired in a 3.3v doc power supply, just replacing the batteries with two short bamboo sticks with the wires at each end. Just temporarily. But it works, and best of all, the keyboard no longer goes to sleep.

It’s great for using it with my iPad, and probably other stuff too, especially in that situation.

The next step is to actually put a proper little power socket in the edge of the keyboard, so I can hook it up easily just be pluging in the power supply.

Keyboard. £20. Battery pack £5. Socket for keyboard edge, 50p about, and a bit of wire to solder it all together, and presto, a non sleeping Bluetooth keyboard.

 

Posted in Default Category | Leave a comment

Making Shell Scripts Start at Login or System Startup

Making Shell Scripts Start at Login or System Startup

Now that you know how to write shell scripts and run them as commands, making them start when you log in to your account, or making them start when the system starts, is straightforward.

You’re already familiar with the Login preferences settings, and your ability to customize what programs start when you log in from it. An executable shell script is just another program as far as Unix is concerned, so you can configure scripts to start on login from there. If you’re going to be working from the command line with any frequency, you might want to consider adding a single shell script to your login preferences, and using that script to execute other scripts as necessary.

To add a shell script as an item that starts at system startup is also quite simple. Create a subdirectory for the script you want to run in the /System/Library/StartupItems/ folder, and place the script or a link to the script in the directory, giving it the same name as the directory. When the system starts, the script will execute. Remember that it’s not going to have a terminal attached, so if it does things such as echo data, the data will have nowhere to appear. In Chapter 20, “Command-Line Configuration and Administration,” we’ll cover the contents of the plist (properties list) file that you can add to the directory with your script to customize some of its behavior.

Posted in OSX | Comments Off

Testing PHP mail

How to test out php mail, especially if you are having issues on OS X.

Use THIS link

 

Watch out especially for gmail and others, as they will arbitrarily dump your messages.

Sending to a Gmail address, produced this.

 

 


This is the mail system at host localhost.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

                  The mail system

<racuk12@gmail.com>: host gmail-smtp-in.l.google.com[64.233.166.27] said:
   550-5.7.1 [5.70.82.197      12] Our system has detected that this message
   is 550-5.7.1 likely unsolicited mail. To reduce the amount of spam sent to
   Gmail, 550-5.7.1 this message has been blocked. Please visit 550-5.7.1
   http://support.google.com/mail/bin/answer.py?hl=en&answer=188131 for 550
   5.7.1 more information. gh3si1572871wib.2 - gsmtp (in reply to end of DATA
   command)
Reporting-MTA: dns; localhost
X-Postfix-Queue-ID: CE2FDB89C03
X-Postfix-Sender: rfc822; robert@localhost.localhost
Arrival-Date: Tue,  4 Nov 2014 15:35:43 +0000 (GMT)

Final-Recipient: rfc822; racuk12@gmail.com
Action: failed
Status: 5.7.1
Remote-MTA: dns; gmail-smtp-in.l.google.com
Diagnostic-Code: smtp; 550-5.7.1 [5.70.82.197      12] Our system has detected
that this message is 550-5.7.1 likely unsolicited mail. To
reduce the
amount of spam sent to Gmail, 550-5.7.1 this message has been blocked.
Please visit 550-5.7.1
http://support.google.com/mail/bin/answer.py?hl=en&answer=188131 for 550
5.7.1 more information. gh3si1572871wib.2 - gsmtp

To: racuk12@gmail.com
Subject: the subject
From: racuk12@gmail.com
Reply-To: webmaster@chalmers.com.au
Date: 4 November 2014 15:35:43 GMT


hello

However, sending to an address on my own server, robert@chalmers.com.au, using the local mail server here, it went through fine.

Posted in OSX | Comments Off

How to Setup Postfix for Mac OSX and WordPress PHP Mail

How to Setup Postfix for Mac OSX and WordPress PHP Mail

I have been running a self hosted website off of my own computer for awhile now and wanted to use the Fast Secure Contact Form Plugin for WordPress. The problem was while the Apache web server was up and running along with PHP and MySQL to handle the back end for WordPress, there was no Mail Server for FS Contact Form to make use of.

Sendmail and Postfix are installed by default on a Mac OSX distribution although disabled by Apple. There are a variety of setup examples on the net; some useful, some not so. It took some tinkering, more than it should have in fact, so hopefully this process that I went through will help someone else.

Postfix will require some setup and one of the better instructions for doing that comes from Brett Hutley’s Blog. So armed with that I fired up the Terminal and went about editing ‘/etc/postfix/main.cf‘.

sudo nano /etc/postfix/main.cf

I use nano or pico (same thing) on occasion and am comfortable with them, but if you prefer emacs or vi go for it, but I mostly use the command line tool for TextWrangler named ‘edit‘. If you download and install TextWrangler.app (free and excellent text & code Editor with syntax coloring for the Mac) and install the command line tools with it, then ‘sudo edit filename‘ will open the file in TextWrangler so you can do your edits there. Way Cool.

I then put all of the following including comments for future reference at the End of /etc/postfix/main.cf:

######
# sudo nano /etc/postfix/smtp_sasl_passwords
# add ‘smtp.gmail.com:587 your.name@gmail.com:your.password’
# save and run ‘sudo postmap /etc/postfix/smtp_sasl_passwords’
# start postfix with ‘sudo postfix start’ 

# Minimum Postfix-specific configurations
relayhost = smtp.gmail.com:587

# Enable SASL authentication in the Postfix SMTP client.
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/smtp_sasl_passwords
smtp_sasl_security_options =

smtp_sasl_local_domain = diverge.blogdns.com
broken_sasl_auth_clients = yes
smtpd_pw_server_security_options = noanonymous

# Enable Transport Layer Security (TLS), i.e. SSL.
smtp_use_tls = yes
smtp_tls_security_level = encrypt
tls_random_source = dev:/dev/urandom

So far so good, and after following Brett’s instructions for generating the sasl_passwd and setting permissions, I launched PostFix:

sudo postfix start

… and the Console.app mail.log was filled with missing directories in the /private/var/spool directory. I tried creating these as they appeared and then permission errors were encountered. Attempts to set owner and groups got a little farther, but no joy, until after more research I discovered the following:

sudo postfix upgrade-configuration
sudo postfix set-permissions

Well, well. All necessary directories in place and properly configured and a test gave expected results.

telnet localhost 25

This showed access, but then the connection was dropped as my ISP blocks port 25 for SMTP.

date | mail -s ‘test email’ my@email.addy

This worked as expected and it was forwarded to my GMail account as the instructions in /etc/postfix/main.cf had dictated.

The next thing was to make this permanent between reboots and we need to:

sudo cp /System/Library/LaunchDaemons/org.postfix.master.plist /Library/LaunchDaemons/org.postfix.master.plist
cd /Library/LaunchDaemons/

We copy the file out of the System folder as we really shouldn’t be editing anything in the System Folder as System Updates can and will overwrite them.

Next we ‘sudo edit /Library/LaunchDaemons/org.postfix.master.plist‘ and add the following just before the closing ‘/dict‘ tag:

<key>RunAtLoad</key>
<false />
<key>KeepAlive</key>
<false />

I don’t require Postfix to be running all the time; only when the Contact Form on my website is used so I chose these options. You can of course change either to ‘true’ depending upon your requirements. We can then start this up by either rebooting or using ‘launchd‘ with:

sudo launchctl
launchd% load org.postfix.master.plist
launchd% quit

Back to WordPress and the FS Contact Form plugin. Test emails with that on my site were now giving errors and after more research the specific error was ‘Could not instantiate mail function’ and the Mail.log in Console.app was complaining about needing a -t switch for email Recipients or else Recipients must be issued from the command line. FS Contact form was passing information to sendmail correctly it seemed, and command line use was out of the question so more digging revealed PHP ‘mail’ needed one final change to ‘sudo edit /usr/local/php5/lib/php.ini‘.

Edit the php.ini file and search for ‘sendmail_path‘. Change the line that is there by adding the -t switch so that the final line looks like this:

sendmail_path = /usr/sbin/sendmail -t

Save the changes and now we need to restart the web server with:

sudo apachectl restart

And FINALLY … a test mail sent with the FS Contact Form plugin within WordPress running off of my web site hit gold!

Posted in Default Category | Comments Off

Upgrade to PHP 5.6 or 5.5 on Mac OSX 10.10 Yosemite

Too easy. Follow the links and so on found here.

Upgrade on Yosemite

Just substitute 5.6 in place of the 5.5 or 5.4 they mention.

Then also adjust your .profile, or .bash_profile to reflect the new path.

Of course – the next release of OSX 10.10 may just wipe out all your hard work … but hey, easy to fix again.

Posted in OSX | Comments Off

Postfix and Dovecot on Yosemite.

After spending ages working on the various setups related to Postfix and Dovecot, I just about have it into a neat tutorial, on how to set it up on Yosemite and be able to manage your own mail server, without having to install Apple’s Server. Which is nice, but has a lot of things the individual user will have no need of.
However, in the case where you may be hosting a number of Virtual Domains, and you need mail services for them, then it’s nice to be able to handle it On Site.

Updates.
For starters.

Postfix comes installed on Yosemite. So don’t go installing from macports or downloading sources until you know what you are doing. It could probably use updating, but leave it for now. It’s pretty straight forward, so should update naturally as Yosemite is updated. I hope? If you want the bleeding edge stuff – caveat utility… I haven’t put the download links for Postfix here, because I don’t want you to accidentally go and grab it by mistake.

It’s easy to find out your current version with:
$ postconf -d mail_version

gives you …
mail_version = 2.11.0 at least on my GM3 version of Yosemite. Be aware that updates to Yosemite may well wipe out all your hard work.

Handy Postfix Wikis…
Postfix main.cf configuration
Virtual Mail Server

Dovecot does NOT come installed on Yosemite. And if you want IMAP mailboxes, which most Apple mail clients seem to want by default, then you will need it. Download it here. If you are doing Virtual Mail Boxes for Web Hosting and so on, you will need it.
Stable releases. Try and get the latest one…. or at least a late one. Currently – macports is about 1.7. Way old… don’t use it.

Download v2.2.13 sources. [PGP signature] [changes].

and READ the Wiki for Dovecot.. IMPORTANT. Everything yo need to know about Dovecot is here.

And … In which case you will also need – because the doveconf mail and install won’t install unless you have it.

libiconv – which also does not come ready installed. Look at it here for downloading.

Expand it into it’s own directory in Downloads and do a
./configure
make
sudo make install

….. then go back to Dovecot, and do the same.
./configure
make
sudo make install

Now, you will want to know where everything is right.

$sudo find / -name “*dovecot*” -print

Will list out lots of stuff.

To start them up – you will need LaunchDaemons … I’ll do them later.

enough for now.

Posted in OSX | Comments Off

Now running Yosemite OS X 10.10 here

I am also trial running Mailserve for Yosemite, http://cutedgesystems.com/software/MailServeForMavericks/ and it’s working as well. Let me rephrase that. It runs on Mavericks – but still has issues on Yosemite – the map poor Dovecot part doesn’t seem to be handling the mail delivery.

or is it the Apple Mail.app – can’t work it out.

Mail goes and gets my gmail stuff. But, it won’t pick up mail for the local user on this machine. i.e.. me.

$mail robert
Subject: Sunday …
Hello world
.

$You have mail

works – but no way can I convince Mail to pick it up.

Posted in Default Category | Comments Off

Source Code now on sale

The source code for the iOS apps created by me, is now coming on sale. You will find it here at ShanghaiTimes

Posted in iOS | Comments Off

Old Felixstowe Weather Station. Arduino + Weather Display

The whole thing needs a bit of work still, but it is working. Weather Display software is commercial software, but the writer of the software has generously added Arduino weather station capability to it for us. weather-dsiplay.com will find that.

My weather station is here.
I’m pulling in the transmission from a LaCrosse TX13 outdoor transmitter station – Rain, Wind, Temp, and a BMP180 Pressure and indoor temp sensor set up on the ASK Weather Receiver board on the Freetronics Uno.
All the code is here on this site, and although I’ve had to tweak it a little from the original, for the rainfall bit, not much really has changed.
It compiles on either Windows or Mac.

Weather Display unfortunately only runs on Windows and Linux …
The Old Felixstowe Weather Station is here and should give you a good idea of what it’s doing.

Posted in Weather | Comments Off

Weather Display and Arduino USB Weather Station

Weather Display, here is now able to read Arduino weather based stations. It’s still ongoing work, but it’s working ok for me, based on a LaCross TX13 transmitter. Arduino Code available on this site, and some twiddling. Weather Display costs a fair few bucks, but it’s a fairly serious piece of work that recognises a lot of weather stations, so is probably worth it to the enthusiast.

Posted in Weather | Comments Off