AccessibleFormBuilder has just been pushed out the door.
UPDATE This is the example ;)
<% a_form_for :user, :url => users_path, :legend => "Login Details" do |f| %>
<%= f.text_field :login, :label => "Username", :note => "This is visible to other users", :required => true %>
<%= f.password_field :password, :label => "Password", :required => true %>
<%= f.password_field :password_confirmation, :label => "Confirm Password", :required => true %>
<%= f.separator "Personal Details" %>
<%= f.text_field :firstname, :label => "First name", :required => true %>
<%= f.text_field :lastname, :label => "Last name", :required => true %>
<%= f.text_field :email, :label => "E-Mail", :required => true %>
<%= f.separator "Location Details" %>
<%= f.text_field :address, :label => "Location", :note => "(eg. New York, 90210, SE1 3SR)", :required => true %>
<%= f.submit "Sign up" %>
<% end %>
UPDATE Added HTML output
<form action="/users" class="aFrm" method="post"><div style="margin:0;padding:0"><input name="authenticity_token" type="hidden" value="e39d055ff60d1b5388fcf9864ffd1fa568160b9a" /></div><fieldset><legend>Login Details</legend><ol>
<li><label for="user_login">Username:</label><input id="user_login" name="user[login]" size="30" type="text" /><span class="requiredField">*</span><em> This is visible to other users</em></li>
<li><label for="user_password">Password:</label><input id="user_password" name="user[password]" size="30" type="password" /><span class="requiredField">*</span></li>
<li><label for="user_password_confirmation">Confirm Password:</label><input id="user_password_confirmation" name="user[password_confirmation]" size="30" type="password" /><span class="requiredField">*</span></li>
</ol>
</fieldset>
<fieldset><legend>Personal Details</legend>
<ol>
<li><label for="user_firstname">First name:</label><input id="user_firstname" name="user[firstname]" size="30" type="text" /><span class="requiredField">*</span></li>
<li><label for="user_lastname">Last name:</label><input id="user_lastname" name="user[lastname]" size="30" type="text" /><span class="requiredField">*</span></li>
<li><label for="user_email">E-Mail:</label><input id="user_email" name="user[email]" size="30" type="text" /><span class="requiredField">*</span></li>
</ol>
</fieldset>
<fieldset><legend>Location Details</legend>
<ol>
<li><label for="user_address">Location:</label><input id="user_address" name="user[address]" size="30" type="text" /><span class="requiredField">*</span><em> (eg. New York, 90210, SE1 3SR)</em></li>
<li><input name="commit" type="submit" value="Sign up" /></li>
</ol></fieldset></form>
Install with
git clone git://github.com/shift/accessible_form_builder.git vendor/plugins/accessible_form_builder
While looking for the holy grail in home automation protocols, I made a little discovery, a bit of kit called a Connect ME made by Digi. What this bit of hardware does is give you an over-sized RJ45 plug (or wireless antenna) and built into it is an embedded OS with development kit, now your probably asking “And?”, well here’s the thing in home automation, most of it can be interfaced via serial/RS-232, which is one of the things the Connect ME has connectivity for (as well as GPOs), so that “Service Port” on the back of your TV/AV Amp may just have another use, X10 / DMX / 1-Wire are some of other protocols made accessible.
So what do you do once you’ve hacked up all of the hardware needed to control everything? Start writing the software to interface with it should be a good start, now you don’t really wanna mess this up as your going to be doing it for lots of different devices, but all with the same hardware constraints, so no nice flashy web interface for this little device, course there is, make the web front-end a back-end, make it a web service and provide an interface that uses it, across all of your home automation devices. Hook the devices up with Zeroconf and they can be auto-detected by your interface, plug and play automation, once you build it and code it.
Now I know you could setup something like this using SNMP but come on where’s the fun in that?
So I guess the title of this should have been “Serial has gone 2.0”?
Installing Sphinx on Joyent is relatively straight forward, I use PostgreSQL over MySQL so some bits may not be relevant.
$ wget http://www.sphinxsearch.com/downloads/sphinx-0.9.8-svn-r1112.tar.gz $ tar xfvz sphinx-0.9.8-svn-r1112.tar.gz $ cd sphinx-0.9.8-svn-r1112 $ export PATH=$PATH:/usr/xpg4/bin $ ./configure --prefix=/opt/csw --without-mysql --with-pgsql && make && sudo make install
One on of our older machines accelerators we needed to adjust the ld paths a little for the PostgreSQL support, meaning the following
$ sudo crle -l /lib:/usr/lib:/opt/csw/lib:/opt/csw/postgresql/libBefore
$ crle Configuration file [version 4]: /var/ld/ld.config Platform: 32-bit LSB 80386 Default Library Path (ELF): /lib:/usr/lib:/opt/csw/lib:/opt/csw/postgresql/lib Trusted Directories (ELF): /lib/secure:/usr/lib/secure (system default)After
$ crle Configuration file [version 4]: /var/ld/ld.config Platform: 32-bit LSB 80386 Default Library Path (ELF): /lib:/usr/lib:/opt/csw/lib Trusted Directories (ELF): /lib/secure:/usr/lib/secure (system default)
And you’ll now find sphinx installed in /opt/csw/bin
Comments welcome, Enjoy.
Last night a friend and I wall mounted my TV it was simple, put bracket onto wall, put other half of bracket onto TV, lift it up to the wall and put the two bits back together, oh and take the normal stand off… that was the pain right there, 4 screws, four evil little screws that wouldn’t budge even tho unscrewed, as if held in with magic, we tried magnetic screwdrivers and even turning the TV horizontal and shaking it, not an easy job with a TV that weighs more then a large dog and is over a meter wide.
Got there in the end tho (took about one and half hours).
I’m enjoying the NAS + XBOX360 with HD-DVD drive + TV setup, now if only the NAS + XBOX supported controllers then I could use my phone to change video.
Now what to do for the cables running down the wall.
The Mephisto team has recently released 0.8 on the way to one point-oh adding
Along with more, checkout the change log from git
git clone git://activereload.net/mephisto.git mephisto cd mephisto; less CHANGELOG
Happy Blogging.
This one is a Symbian S60 application that “pings” the web server with your location at a user-defined duration or not all (for people with horrible mobile providers that charge by the KB), it’s currently a closed beta as they’re only accepting people with GPS (internal eg. Nokia N95 or Bluetooth) until they’ve mapped more cell towers to make it useful for people without it.
Now you know what it is, heres the name Locatik and my profile (for the stalkers).
<rant>
I placed my order with Forbidden Planet for a Nabaztag/tag on 9/Dec/2007, the order confirmation e-mail they sent out said “Please allow 21 days from date of order before checking non arrivals.”, so on 23/Jan/2007 I e-mailed there sales team asking about the status of my order.
On the 18th of Jan I return home from work to find a DHL card on the mat, not knowing what was dispatched I log into my online banking to find that Forbidden Planet have debited my account.
Today I got an e-mail from my e-mail sent on the 23/Jan stating “I can confirm that your order is in the process of being despatched and should arrive within the next 10-14 days.”, I get the package picked up, open it and find a… Marvel 1/12th Scale Metal Statue – Wolverine clearly not what I ordered, box addressed in print to someone else, DHL sticker put on it delivering it to me.
So I’ve e-mailed them as no one answered the phone number in the sales e-mail and on the invoice asking them to sort the problem.
What I can’t understand is how a company like this can still be in business, first they don’t have stock listing on the website (something I hadn’t noticed when I placed the order), second there was no correspondence to say the order was being debited or dispatched, thirdly someone’s managed to read a woman’s name and address in the other end of the UK and affix my delivery sticker to it. Fourthly and worst of all is the fact that they don’t seem to think they’ve dispatched my order.
</rant>
I like gadgets, probably too much, I also like integrating everything with everything else, so on rolls HA or Home Automation.
I’ve already had a X10 setup for a while that allows me to control lights, I’ve integrated this with Asterisk (with help from Adhearsion) which allows me to control lights from any phone, I also hooked Asterisk up with Amarok.
Well today I ordered some 1-Wire hardware to play with, I didn’t fancy running more cables for the 1-Wire setup and found HA7Net which is a Ethernet to 1-Wire gateway basically, the only problem with it seems to be you need to scrape the embedded web server as it doesn’t provide any kind of web service. I also ordered a 1-Wire temperature sensor to mess around with, and help me make a Ruby gem for the HA7Net.
I’ll try and get around to documenting what hardware I’ve got setup, as I can never remember what’s where and providing what (from VoIP phones, NAS, embedded machines, servers, consoles to a Nabaztag).
Consider this, your browsing the web on your phone with your unlimited data plan and a site requires you to register or login, whats easier to type on the phone? http://rwvhp.com or 07714110660 (my old mobile number), I know different people will prefer one over the other.
It is possible and heres how, VoIP uses ENUM and e.164 to work out the domain name from the phone number. This could also be used to work out the OpenID of the user with very little work and as far as I can tell is just as secure as OpenID as both can suffer from attacks via DNS.
I’m basically just throwing this out there to get some feedback and as a note to myself.
Mojo is now in a public beta, if your reading this there is a 99% probability that your in the Ruby world so if you want to get started wreaking havoc at work making all of the phones ring you can
gem install mojo
Congrats to the guys at Mojo for a great job.
The following is just to claim the blog on its new URL with Technorati by linking to my Technorati Profile
I got bored of the old domain name, so I figured I’d get a vanity domain for my blog, vanity you say, how does RWVHP.COM have anything to do with my name. Well Vincent.com is already registered, VincentPalmer.com is also already registered so I thought, I know I’ll get a small(ish) domain name that means something to me in some way, So I picked my initials R(obert) W(illiam) V(incent) H(anley) P(almer). Yes, yes, I know, my father didn’t know when to stop with the names.
How onto the host part, the old blog was hosted on a server I was sysadmin of, but the company that was running it recently decided to shut it doors so I was in need of a new host so this blog is hosted on its very own slice at slicehost, nice to see theres currently no waiting list, I hit order and this slice was being built, very impressive.
So on with the party, what have I been upto recently
Avahi/Zeroconf or Rendezvous as your Mac would know it, can be used in published DNS records (unicast) as well as the normal LAN type setup (multicast), its already a standard why don’t we use this for discovering RESTful resources?
All this would require would be a service type registered eg. rest.tcp and a flag in the TXT record naming your resources eg. “resources=/users /articles /articles/comments”.
I brought this up (quite randomly) during a talk at my local Ruby Group (ncl.rb).
Gimme your feedback?
UPDATE Forgot to add from the initial post use the :resource/new to get an empty object (to_xml or whatever)
An example of discovering unicast Zeroconf services isshift@carbon:~# avahi-browse -a -d 0pointer.de + n/a n/a Lennart’s Blog _http-rss._tcp 0pointer.de + n/a n/a tango SSH Remote Terminal 0pointer.de + n/a n/a dt115 SSH Remote Terminal 0pointer.de + n/a n/a ring2 SSH Remote Terminal 0pointer.de + n/a n/a PulseAudio Web Site Web Site 0pointer.de + n/a n/a Avahi Web Site Web Site 0pointer.de + n/a n/a Lennart's Blog Web Site 0pointer.de + n/a n/a Lennart's Photos Web Site 0pointer.de + n/a n/a Lennart's Homepage Web Site 0pointer.de
This isn’t so much a blog post as somewhere convenient to put some information for ncl.rb.
My Apache 2.2 + modproxybalancer virtualhost config
<VirtualHost *:80>
ServerName yourapp.com
DocumentRoot /home/web/yourapp.com/current/public/
<Directory "/home/web/yourapp.com/current/public">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
# Configure the cluster member proxy
<Proxy balancer://your_app_cluster>
BalancerMember http://127.0.0.1:3000
BalancerMember http://127.0.0.1:3001
BalancerMember http://127.0.0.1:3002
BalancerMember http://127.0.0.1:3003
</Proxy>
RewriteEngine On
# If there is a maintenence.html file in your
# public dir all requests will get rerouted to
# this file. This is for use with capistrano
RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /maintenance.html [L]
# Rewrite index to check for static index.html
RewriteRule ^/$ /index.html [QSA]
# Rewrite to check for Rails cached pages with .html extentions
RewriteRule ^([^.]+)$ $1.html [QSA]
# All dynamic requests get sent to the cluster
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://your_app_cluster%{REQUEST_URI} [P,QSA,L]
# Deflate for clients that support it.
AddOutputFilterByType DEFLATE text/html text/plain text/xml
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Error and access logs.
ErrorLog /var/log/apache/app_error.log
CustomLog /var/log/apache/app_access.log combined
</VirtualHost>
Now if you take the above example it’ll send all requests to your pack of mongrels, but say you want to have more then one application running on your domain (say beast).
You’ll need to create another proxy balancer
<Proxy balancer://your_second_app_cluster>
BalancerMember http://127.0.0.1:3004
BalancerMember http://127.0.0.1:3005
BalancerMember http://127.0.0.1:3006
BalancerMember http://127.0.0.1:3007
</Proxy>
And then add the RewriteRule for it
RewriteRule ^/forums/(.*)$ balancer://your_second_app_cluster%{REQUEST_URI} [P,QSA,L]
Now anything going to / that isn’t /forums/.* will goto yourappcluster and anything with /forums/.* will goto yoursecondapp_cluster
<VirtualHost *:80>
ServerName yourapp.com
DocumentRoot /home/web/yourapp.com/current/public/
<Directory "/home/web/yourapp.com/current/public">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
# Configure the cluster member proxy
<Proxy balancer://your_app_cluster>
BalancerMember http://127.0.0.1:3000
BalancerMember http://127.0.0.1:3001
BalancerMember http://127.0.0.1:3002
BalancerMember http://127.0.0.1:3003
</Proxy>
<Proxy balancer://your_second_app_cluster>
BalancerMember http://127.0.0.1:3004
BalancerMember http://127.0.0.1:3005
BalancerMember http://127.0.0.1:3006
BalancerMember http://127.0.0.1:3007
</Proxy>
RewriteEngine On
# If there is a maintenence.html file in your
# public dir all requests will get rerouted to
# this file. This is for use with capistrano
RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /maintenance.html [L]
# Rewrite index to check for static index.html
RewriteRule ^/$ /index.html [QSA]
# Rewrite to check for Rails cached pages with .html extentions
RewriteRule ^([^.]+)$ $1.html [QSA]
# All dynamic requests get sent to the cluster
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/forums/(.*)$ balancer://your_second_app_cluster%{REQUEST_URI} [P,QSA,L]
RewriteRule ^/(.*)$ balancer://your_app_cluster%{REQUEST_URI} [P,QSA,L]
# Deflate for clients that support it.
AddOutputFilterByType DEFLATE text/html text/plain text/xml
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Error and access logs.
ErrorLog /var/log/apache/app_error.log
CustomLog /var/log/apache/app_access.log combined
</VirtualHost>
yourappcluster mongrel_cluster.yml
--- port: "3000" environment: production address: 127.0.0.1 pid_file: log/mongrel.pid servers: 4 yoursecondappcluster mongrelcluster.yml --- port: "3004" environment: production address: 127.0.0.1 pid_file: log/mongrel.pid servers: 4
Hope that made sense, as its off the top of the head apart from the base apache 2.2 vhost config
UPDATE If your running a Rails app under a path remember to set
ActionController::AbstractRequest.relative_url_root = '/path'
In your environment.rb or your links will be wrong
The if statement, sometimes you don’t want to type
if user.password == user.username
# do something
end
Sometimes you might just want to simply check that the value set isn’t nil
user.password ||= 'default_password'
Thats the same as writing
if user.password == nil
user.password = 'default_password'
end
A slight variation of that would be
user.password = params[:password] || 'default_password'
Which would be the same as
if params[:password] != nil
user.password = params[:password]
else
user.password = 'default_password'
end
Theres probably more ways of doing things like this that I haven’t came across yet, if you know of others leave a comment.
Vincent is a self-confessed geek, who's day job is as a Rails developer, outside of work he likes to play with home automation gadgets. He resides in Newcastle upon Tyne.