mono gtk threads and timers

So, Yeah. I know it has been like 4-ever since I have posted anything. Well, the fact of the matter is I am NDA’ed on all the great stuff I work on. So that means I am not allowed to talk about it. That being said, I did put together this little DEMOnstration of some Mono C# Gtk examples of working with threads and timers. I can’t tell you what I’ve actually done with this, but I can tell you that the examples on the Mono do not work out of the box with the current version of Mono Develop. I don’t quite understand why their documentation is so out of date, or maybe they just assume people are smart enough to apply their examples to real working scenarios…. well THESE ARE WORKING. You can pull this repo, straight from github and build and run them to see how they tick. Please do not comment on the blog. As you can tell from my last post, I do not maintain it well. So post any comments on github. CHEERS!

jquery form validation with cakephp model validation

I am currently working on a project in CakePHP and have used the jQuery form validation plugin from Jorn Zaefferer on other non-cake projects. So I had a thought… wouldn’t it be nice to do the field validation right from the cake model validation rules. So this is what I came up with.

[Warning Rough Draft!]

In my default layout I added the includes to load jQuery, jQuery Validate, and metadata. (Mine are inside an if condition that I activate on a per view basis, but this would be for application wide use.

echo $this->Html->script('jquery');
echo $this->Html->script('jquery-validate/jquery.validate.min');
echo $this->Html->script('jquery-validate/lib/jquery.metadata');

In the User model (/app/models/user.php) file I added a rule and made sure that it was working:

var $validate = array(
	    'firstName' => array(
	        'rule' => '/^[a-zA-Z\x27]{2,}$/i', //2 letters or '
	        'message' => 'First Name must only contain letters, and be at least two characters.'
	    'lastName' => array(
	        'rule' => '/^[a-zA-Z\x27]{2,}$/i', //2 letters or '
	        'message' => 'First Name must only contain letters, and be at least two characters.'

In the controller (/app/controllers/users_controller.php) I added the request handler componet. As well as the function ajax_validate. The function tries to create a new instance of the User model with the data provided. It then calls $this->User->validates() to see if it passes validation. If not the cake model error will be returned and added to the error label for user feedback.

var $helpers = array('Html','Ajax','Javascript'); //these are the helpers I am using
var $components = array('RequestHandler');

	function ajax_validate(){
		Configure::write('debug', 0); 
		$this->autoRender = false;
		$ret = "false";
		$this->data = $_GET['data'];
		if ($this->RequestHandler->isAjax()) {
		// If we have data, process it. If not send back an error.
				// $this->cleanUpFields();
				// Validate the User, if it's ok, show no errors. If not ok, show errors
				if ($this->User->validates()){
	                		$ret = true;
	            		} else {
	            			$errors = $this->User->invalidFields();
	            			// grab the error message from the array
	            			$ret = '';
	            			foreach($errors as $error){
	            				$ret .= $error;
			echo json_encode($ret);
		} else {
			echo 'not_ajax';

In the view (/app/views/users/index.ctp) I added the form validation jQuery initialization code as well as a form for the user to edit their settings. I am using the form meta plug-in to grab the validation rule out of the class parameter on the form field. So in the class, I add a remote remote:’users/ajax_validate’, so that jQuery will look to the controller function ajax_validate() to validate the field.

<div class="users form">
<?php echo $this->Form->create('User');?>
 		<legend><?php __('My Settings'); ?>Form->input('id');
		echo $this->Form->input('userName', array('label' => 'Username', 'disabled'=>'disabled'));// (not edit-able) 
		<?php echo $this->Form->input('firstName', array('class' => "{validate:{required:true,remote:'users/ajax_validate'}}"));?>
		<p class="subtle ml10 mbl1em">( your first name)</p>
		<?php echo $this->Form->input('lastName', array('class' => "{validate:{required:true,remote:'users/ajax_validate'}}")); ?>
		<p class="subtle ml10 mbl1em">( your last name)</p>
		<?php echo $form->submit('Save');?>

<?php //extra javascript for this view
echo $javascript->codeBlock('

$(document).ready(function() { 
    	onsubmit: false, //otherwise it will do all the remote calls when the user hits submit
    	meta: "validate"


Hope this is helpful to someone. Someday-maybe I’ll post an update when I clean it all up. A next step could be to handle the entire form onsubmit, but cake already does that with the model validation that we just added.



jQuery –
jQuery Form Validation and meta plugin:

X10 Switch Turns Off But Not On, Oh Bother

I have a funny story for you (funny like ha ha)

So I just got done troubleshooting a strange issue. As the winter days were approaching and it got dark sooner and sooner I noticed that the outside light that I have on an X10 controller was turning off but not on automatically. I upgraded to FC10 recently, so I checked to make sure the program (heyu) was working by looking at the verbose messages. Nothing obvious in there. It just seemed really odd that I could turn it off but not on. I tested the controlled with a plug-in X10 module, and it worked like a champ. So tonight I was determined to fix it and did some google searching and found this page:

So I started thinking about what was “new” at my house since it stopped working and un-plugged these items one at a time until….. I determined it was a used computer I bought off a buddy. I was able to 100% determine it was this computer by turning it off and on, and the problem comes and goes. I just found this interesting and wanted to share the story with everyone.

I wonder what is so different about the power supply in this computer, I have it plugged into the the same outlet that I have had other computers before it plugged in. Oh well, at least I know know! I have a spare power supply, so I may just swap it out and see what is so special about the one that is in it. Anyone want to buy this great power supply with built-in X10 filtering?


Counting items with mysql and regex in the group by statement

Yesterday I needed to do a little report for the boss but the data that I needed to group together wasn’t exactly the same. I hit up the “Goog” for ways to use regular expressions in a count query, but that is kinda tricky to find so this is what I was able to come up with….

So let’s say you had a table where you were attaching the landing url a site visiting is entering your website on, and you wanted to track that landing url the whole way to the end of some web based procedure. Of course certain urls will be different but some could be common for the purpose of counting them together on a report. In a practical example, lets say you are doing pay-per-click traffic with Google and Yahoo. Both of these providers use unique ids in the url to help distinguish between multiple clicks from the same person (so you end up with many urls that are different but mean the same thing). And of course you were a good little developer when you decided to send Google traffic to /google/ and Yahoo to /yahoo/!
Continue reading ‘Counting items with mysql and regex in the group by statement’

And we are back.

So it has been quite some time since I posted on here.  It has been rough lately. Not sure what kind of funk I’ve been in… but actively trying to get out of it. Hoping getting back in tune with the tubes will help. (Twitter is probably the biggest reason not to post on here…damn you Twitter)

While I have been gone I have been doing some work with CakePHP, FAI – fully automatic linux installations, VirtualBox & VMware, Magento, etc. So I have been keeping pretty busy.

I also found a nice little hardware project that has just come into my radar. This is something that I have been wanting to work on in my *cough* free time. However my vision would be to use a host computer for all the logic and user control, and the controller board used for simple I/O. Anyone interested in this, drop a comment and let me know.

Happy Holidays from ProspectMX

The company I work for has decided to do a charity benefit of $10,000 in services to the organization that answers the question on their site or blog: “How can internet marketing benefit your organization?” For further details visit the post charity internet marketing

How To Setup Yubikey SSH On Fedora

Here is a short ten minute video tutorial and howto directions. This is how to setup Yubikey authentication on Red Hat Fedora with PAM authentication. You can configure SSH to restrict access to your Linux box so that only Yubikeys you authorize can gain access. Therefore restricting access to anyone who does not.

# build libyubikey
tar -zxf libyubikey-1.1.tar.gz
cd libyubikey-1.1
make install
cd ../

# build pam yubikey
tar -zxf pam_yubico-1.8.tar.gz
cd pam_yubico-1.8
make install
cp libs/ /lib/security/

# Setup keyfile
mkdir /root/.yubico/
vi /root/.yubico/authorized_yubikeys
root:{12char key}

# SSHD Config
PasswordAuthentication yes
ChallengeResponseAuthentication yes
UsePAM yes

# Pam module
vi /etc/pam.d/sshd
auth sufficient id=16 debug

The Opening of the Yubikey

Greetings! Finally got the first impromptu video up on the inter-webs. This is just a rough video of me opening my package from Yubico. I talk a little bit about what the device is and then plug it into my computer for the first time.
Also, I attempt to gain access to Yubico’s restricted user forum. Enjoy!

The YubiKey Has Arrived

Just a quick note out that I just received my Yubico Yubikeys! I normally tear into packages like presents on Christmas morning, but I am trying to restrain myself. I have decided to do a video blog-casting series, detailing the entire life-cycle of my experiences with the YubiKey. So hopefully video shooting goes well. It is already 10pm, so we’ll seen how quickly I can wrap this up.

Just Ordered Yubico YubiKey

One of the great things I learned about at CPOSC this past Sunday was the Yubico YubiKey. I had not heard of this little device, granted I had heard of the RSA SecurID. (If you are wondering what a SecurID is, it is a portable device that allows you to add an extra layer of authentication and security to a computer system or interface.) It was interesting that I had just had a conversation with a colleague about the want to find an alternative to the RSA commercial solution. So I was at the conference and the one speaker mentions the Yubikey, and invites interested parties in joining him for a demo of the little devices over lunch. I was so amazed that I just ordered two devices. I will blog more as I learn more about them and what I do with them.

Have you had any experience with any secure token based authentication systems? Please drop a comment and let us know.