Go to content Go to menu

pharoGapi1.png While working on a project which uses some Google API’s I came across Googles API registry. Under https://www.googleapis.com/discovery/v1/apis/ all API’s for Google services like Google Drive or Gmail are described. More infos can be found at the Google APIs Discovery Service page. From the API registry a client could discover services and automatically build proxy classes and methods based on the provided metadata. Thats what I have done for Pharo Smalltalk. Other companies like Microsoft also provide some form of service discovery for their service API’s (see https://msdn.microsoft.com/en-us/office/office365/api/discovery-service-rest-operations)

[Read More…]

If you are using one of FitBit’s fitness tracker devices like the ‘One’ for some time you create a lot of data. When you synchronize your tracker all recorded data is sent to FitBit’s servers. The FitBit portal provides some features for graphically displaying and analyzing your data. It’s also possible to export it manually as CSV to process it further. But what if you want your data locally available without manual export to make own statistics. This is what the ‘fitbit_dumper’ is for.

Update: Since 2016 FitBit uses OAuth2. See this blog post for an update.

[Read More…]

cli_mirror.jpgGoogle’s Mirror API is, beside native GDK apps, one way to communicate with Google Glass. It is based on a range of OAuth authenticated web-service methods. The default way to use the Mirror API is to present the user a Web application where he could first register his Glass using a Google account. After this step the app or service is able to send info’s like text messages, contacts, images etc. to the users Glass device. But what if you just want to make a quick test and don’t want to develop even a simple web app or you need a way to quickly send info’s from a cron job every hour?
This is where cli_mirror comes in handy.

[Read More…]

Large service providers like Google are already offering two way authentication for their services. Others like Microsoft will follow. This authentication mechanism is based on One Time Passwords OTP combined with a timing factor resulting in Timebased One Time Passwords TOTP specified in RFC-6238.

But it’s also possible to provide two factor authentication for self written services. The provided package can be found in the following repositiory:

MCHttpRepository
	location: 'http://www.min.at/prinz/repo/totp'
	user: ''
	password: ''

It provides a simple way to create and validate TOTP’s for a given time or a time window.

" Enter the shared secret here. This is for example "
" the secret you will get if  you change your Gmail "
" account to two way authentication "
key := TOTP decodeBase32: 'qqmholtfsmddokpy'.

" Instantiate a new tokenprovider with a 30 seconds "
" time window "
tp := TOTP createWithSecret: key StepSeconds: 30.

" Calculates a new one time password which "
" changes every #StepSeconds seconds "
token := tp calculateOneTimePassword.

" Validate a token "
valid := TOTP verifyOneTimePassword: token Secret: key.

The larger the StepSeconds parameter the longer the generated tokens won’t change and the greater the time difference between client and server can be. The algorithm uses UTC for client and server times. 30 Seconds time step means that a new token is generated every 30 seconds and that a token is considered valid 30 seconds before and 30 seconds after the point in time it was created.

So change your Google account today and use Pharo to calculate the tokens.

Playing around with Zinc’s streaming entities I looked for a source of streaming data. A never ending streaming source are video streams. So I implemented a very simple Motion JPEG reader using Pharo Smalltalk. It does not use any plugins. Just plain smalltalk and a stock pharo image.

Use your pharos monticello browser to add the following repository and open it.

MCHttpRepository
   location: 'http://www.min.at/prinz/repo/mjpeg'
   user: ''
   password: ''

Update:
Some people have reported hat they cannot load the package into their image. Opening a monticello browser, adding a new http repository with +Repository and pasting the code snippet above and then opening the repository works as expected. Alternatively you can download the package using this link and open it from a local directory repository.

Update 2:
As noted by Sven Van Caekenberghe the mime type for .mcz monticello archives is now set to application/x-monticello in the webserver response. So now there should not be any format errors. Thanks for this hint.

Update 3:
Cédrick Béler modified the source to work under Pharo 7. Thanks for that. The new version can be found in the repo.

It consists of just one class Mjpeg.

| cam |

" Create a new MJPEG stream from a given url "
cam := Mjpeg 
   fromUrl: 'http://218.219.210.174:86/mjpg/video.mjpg?camera=1'.

" Start reading the stream and displaying it in a window "
cam start. 

" Start capturing the stream frame by frame to disk "
cam startCapture: 'c:/temp/test'.

" Returns true if the stream is started (reading or "
" capturing), false otherwise "
cam isRunning.

" Stop reading the stream and close the camera window "
cam stop.

" Stop capturing "
cam stopCapture.

There are two example class methods availabe.

" Sample of a webcam stream from Tokyo "
Mjpeg exampleTokyo.

" Webcam from Vienna "
Mjpeg exampleVienna.

Performance of this simple implementation is quite good. The Tokyo example used the stream available at http://218.219.210.174:86/mjpg/video.mjpg?camera=1. Playing this stream with Pharo has no impact on CPU usage whereas playing the same stream with Chrome has a noticeable effect on CPU usage.