curb – PullMonkey Blog http://pullmonkey.com Fri, 27 Jul 2012 15:39:59 +0000 en-US hourly 1 https://wordpress.org/?v=5.6 Using Ruby to read from a MagTek USB Card Reader http://pullmonkey.com/2012/07/27/using-ruby-to-read-from-a-magtek-usb-card-reader/ Fri, 27 Jul 2012 15:39:59 +0000 http://pullmonkey.com/?p=57712 Been playing around with a lot of USB devices lately, to get them to play nicely with some of our touch screen Rails apps.
One of the devices is a card reader - specifically a MagTek reader, and the same code works for the ELO reader.

I've tried a billion different ways to ensure we're reading in all the data. At first, I was just asking the usb stream to present me with a certain number of characters, b/c that's how all the examples do it.
But we're using a lot of different cards with the readers, so that didn't work too well. So now I just read one character at a time until we find the new line.
Here's the code to find the device, open it, close it and read from it, all whilst finding and converting the data as required.

So using this code, we take the swiped data and send it to our server for storage.

]]>
Using HTTPI with Curb to do multipart file uploads with spnego http://pullmonkey.com/2012/07/25/using-httpi-with-curb-to-do-multipart-file-uploads-with-spnego/ http://pullmonkey.com/2012/07/25/using-httpi-with-curb-to-do-multipart-file-uploads-with-spnego/#comments Wed, 25 Jul 2012 22:25:11 +0000 http://pullmonkey.com/?p=57705 It took a while to find a library that handled spnego requests, as opposed to shelling out to a curl --negotiate. Found httpi to work well with the curb adapter.
The problem was that the documentation didn't really explain how to do file uploads withing the httpi request block.
Wasn't too much of a big deal, but I thought it may save someone else some time.

]]>
http://pullmonkey.com/2012/07/25/using-httpi-with-curb-to-do-multipart-file-uploads-with-spnego/feed/ 2