“So what language do you use?” – a pet peeve question

The title is meant to be catch your attention – and even I sometimes ask that question. It bothers me because people are so much more than just a programmer – but a solutions provider and go waaaaaay beyond technical know. Soft skills learned in the leadership masters degree for example, is primarily people related and affects the bottom line even more pronounced than the technical details. Similarly, when people ask “what language do you program in” . . . the answer is waaaaay beyond a specific one – but is is the solution provided that matters. Therefore the correct answer is “whatever language gets the job done and whatever it takes to glue things together … for you!”

Below is a personal experience with each language and it also lists the familiarity with them.

My mainstays seem to be php, .net (vb and c#) and Filemaker but lately I have done so much groovy and Java development that that is now second nature!

PHP – I can’t count how many thousands of lines I have coded. All my web development mainly uses this. This is a simple language understand and there are hundreds of people deeply embedded over the past 10+ years.

.net (vb and c#) was my mainstay while contracting to Telvent (now Schneider Electric) in their screen developement. Dozens of time saving stand-alone tools were developed as well as they main job- designing .net based screens to control pipelines and high power electrical systems (those were my tasks). Other .net jobs was the parent paging tool developed to integrate a check in system which is been in use since 2004. Lately a tool to interface with a counter-top inventory tracking system was developed in .net and runs nightly to scrape data and process material consumption via .net API and another to get customer data from another database.

Groovy – it took me a little time to get my head around groovy and a friend asked “so how do you like crawling again?” Within a week of forcing myself to learn it well – I was up and running. You can do so much in a few lines of groovy – it is I think an advanced language. Using Java (which groovy runs on) was so easy to learn as it is just like C. Advice is to learn it’s terminology through this great tutorial available at Oracle.

Java. Within a week I was as fluent with this as Cocoa, or .net. It is a very structured language with little room for making mistakes. A lot of custom code as been written for the Bonita platform and Java ties directly into it since Bonita is written in Java and uses groovy scripting to complete the rest.

Bonita. This can be considered a progamming language of sorts. Most of the flow is done visually. Most of the nitty gritty is done in groovy and/or Java.

Filemaker. I hve written extensive administration systems in Filemaker – hundred of scripts integrated with dos and unix scripts for doing things like ftp, xml manipulation etc. This is beyond thinking in terms of tables. You use the scripts to drive nagivation, decisions and to automate many tasks in Filemaker. It is a database system that anyone can understand.

C and C++. I have learned this when I was 14 – grabbed a book and started to go. I had to use object oriented concepts far after they were developed in 2004. The whole idea about asynchronous clicking by the user forces good programmers to think proactively about ‘what could go wrong’.

Cocoa – iOS and Mac OS X development. Steve Jobs was a genious (he invented it). This language is basically C++ but the structure is developed so that you can design fast. It is tricky but I am now in the cool club. A project for a dashboard app, a crossword puzzle, a secutity camera viewer app, a classroom coordinator app (a multimedia player over multiple machines) and a parent page viewer have all been developed using the Cocoa language.

Applescript – the most english language version of programming I have ever done. I have automated many processes to allow files to be transferred, things to be uploaded etc. Teen agers were able to do a whole secretaries job my moving this and that process ahead with automation. Many scripting languages use applescript and it fills the gap. Put this together with Automator and you can do just about anything.

VBA – One might think this is .net – it isn’t really. It counts since I have done THOUSANDS of apps and lines of code with this. Programming in Excel was the mainstay but also in powerpoint, Excel, Access etc. have been done

Excel . I would argue that there can be many times when Excel is eerily like a progammed language or a cascading series of custom formulas just like programming. Add a hint of VBA and MANY full blown applications result.

Javascript and Actionscript Everything on the web in the old days required checking – Javascript with HTML5 now also thrives on it. I have used this extensively as well. Now with jQuery as a hybrid version of web programming – Javascript is still an active language. In the world of flash – actionscript replaces javascript and many months of actionscript are also under my belt.

Perl – This was my first language that I replaced an entire administration position with staff at home over the internet. One can do almost anything with Perl and do it in such a way that no one can understand what you have done (including yourself if you go back to it in 6 months) – this is not what I have done but it shows what a powerful language it is. This is a language that glues things together and can do complex mathematical operations

Labview. Extensive automation was done with GPIB interfaced lab equipment. This is a language that you drew wires from one part to the other. Many lines were drawn to accomplish what most people do by typing.

Mathcad and Matlab. One is graphical, the other more like progamming. This was the main stay of my early career while taking my Engineering Masters at the University of Calgary and my undergraduate degree at the University of Waterloo.

Python was used for scripting on the XMBC video player as it has a python interpreter in it. This XBMC platform works on all sorts of platforms even with jailbroken apple devices so it was a perfect choice for the project. It used Python . . . so python was learned. It has a syntactically different structure with no { } but the # of tabs determines what code belongs with what. Neat.

Unix shell scripting like awk and sed. Are those languages? Sure. I have fought tenuously with XML and XSL and understand that now as well. Add Google map points with kml, facebook apps (Javascript and php), DOSSQL, wsh scripting and other proprietary languages and you will soon see – why I cannot and do not like to answer the question “so what language do you use?”

Online Booking System with special features not available on most online booking systems

One customer wanted a booking system that allowed 3 bookings at most at one time with a 15 minute buffer in between. So was born www.bookmedanno.com (you have to be old to get that joke). Coming is the ability to book and pay for a booking – but that aside …

The big challenge was all the time synchronizing and ability to recursively see all bookings overlapping and then calculating anything with a depth of 3 or more layers – needed to be unavailable to book. Here is the website link – don’t finish a booking – as it is live unless you book something for playalatte.ca in Calgary, Alberta canada for a mom/dad and their tot.

  • an SQL could not do this alone – first get all the information in a large time window (i.e. a day) via SQL
  • using recursion, look at all the return results against each other
  • calculate the depth at each start and stop of a booking and keep a tally array as you go along
  • go through that tally array and make a new array of when you go in and out of 3 bookings or more
  • THEN lastly make an inverse array of what is free and plot this visually and make a listing of bookings/times from this on pulldown lists

That was interesting and challenging – thought it might help someone else out on the web.

iPhone streaming viewer

One camera that sticks out to be more value than they charge for it is the Foscam FI8919 series. It has a web server built in and can stream in multiple formats. The config is super easy – and if Windows was the end use – could have multiple cameras all show up on one screen!  Each camera is $89 CDN – that is … “start the car!” …. a crazy low price and they work – and keep working (for over a year now – non-stop)! They answer emails in a flash too and there is lots of forums of people doing all sorts of things. The end destination is XBMC which is a superb piece of software which I wrote the just-use-the-filename plug in. It is used for viewing the video feeds from the security cameras which we cycle from camera to camera every 25 seconds but also the iPhone for parents to monitor what is going on in the nursery rooms.

What I have learned is that instead of using a browser to capture the image in iOS, is to use instead a UIImage and send MJPEG video format to it. WHat this format is is JPEGs sent in sequence to the UIImage View which can handle this no problem. It is much cheaper on memory which for handheld devices is much better. Here are the links I used to figure out how to get the tool working. Kudos to these guys who figured all this out so I could use it.

http://thinkflood.com/support/redeye/software/open-source-software/motion-jpeg-image-view-ios/

Now I just need to integrate it into an app that is bigger than just looking at various cameras at the non-profit organization but to make an app that will help parents connect with their kids with the curriculum provided at this organization.

Once I get a nice name for it – I will publish a link to the name. This is all being done on a volunteer basis – so it might take a while.

Setting up a CentOS 6.3 linux box as a RAID networked attached storage unit

One customer has been set up with Paragon backup software for a Windows 2008 SBS installation. Whis is frustrating about SBS is that the Server Backup tool taunts you to use it but MS states that it is not meant to be used on anything except R2 2008. It was a nightmare but we did get it running on a 2008 Enterprise installation after fixing the VSS shadow copy service. That took 5 hours of time – luckily it was for a friend and they did not pay for it.

OK back to a wonderful tool called Paragon which does work and restoration of files is MILES easier than restoration using Symantec’s Backup Exec. It too works – but it is a huge hassle to understand. The home edition works too but not necessarily for a server installation.

We set up a CentOS 6.3 box (I say we because it was a good friend of mine who taught me what he was doing). I have set up DOS partitions long ago and this is similar just super involved on Linux. Here is what we did

Made a RAID of 2 x 3TB drives partitioned to have 1 boot partition,1 temp/log partition 1 swap partition, 1 OS partition and another one for the /home. In short, the theory is that if the logs filled up a partition the whole box would not come crashing down. Most partitions were set up with RAID to mirror each other in  case of drive failure. Cent OS 6.x was needed for these larger drives – and CentOS 5.x failed miserably.

We took off all unnecessary tools and then I added VNC setup which is a whole article unto itself, smb which is still not working despite both of us working on it – one hint is that Selunix fights smb and there is a setting that you have to apply to get the home directories to be sharable. See Dan’s article here and look for the word selinux in the smb.conf file – sure enough it tells you why it is will not work without proper setup right in there. We are still working on why things mounted one day fine and not the next day. Mac or PC cannot connect via smb.

Netatalk was setup (Appletalk) so Macs could put their time machine backups on the large partition. See this article for Netatalk and this one for TimeMachine on a NAS.

Really common groovy and Java code for Bonita

I seem to use this code all the time so I published it for others to use.

Java Date to MySQL

[cc lang=”groovy”]
java.util.Date dt = new java.util.Date();
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);
String currentTime = sdf.format(dt);
[/cc]

date MySQL string to Java:

[cc lang=”groovy”]
import java.text.SimpleDateFormat;
import java.text.DateFormat;
String target = “2012-02-01 20:29:30”;
DateFormat df = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”, Locale.ENGLISH);
Date result = df.parse(target);
println result;
[/cc]

Debugging to the Bonita Log

[cc lang=”groovy”]
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Logger LOGGER = LoggerFactory.getLogger(this.getClass());
LOGGER.error(“Your String Here”);
[/cc]

Groovy SQL in place of MySQL connector which is more of a hassle than a help

[cc lang=”groovy”]
import groovy.sql.Sql import java.sql.Connection;
import java.sql.DriverManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Logger LOGGER = LoggerFactory.getLogger(this.getClass());
sql = providedscripts.BonitaSql.newInstance(“jdbc:mysql://10.11.12.13:3306/grails”,”user”, “password”, new com.mysql.jdbc.Driver())
sql.eachRow(“select * from person”) { LOGGER.error(“Person = ”  + it.first_name + ” ” + it.last_name); }
[/cc]

Groovy web link encoding that works

[cc lang=”groovy”]

def gotoLink = configMap[‘wwwformspath’]+java.net.URLEncoder.encode(pdfFinalPdfWww).replaceAll(“\\+”, ‘%20’);
string=”Click to edit PDF Form“;

[/cc]

What the blog is about

This is a blog of sorts to discuss what types of interesting things one can do with technology. It is a resume of sorts, but it is also meant to inspire others that really interesting things can be done with the right tools. For each major type of platform, there will be a separate blog created. The intent is to explore and expose some items that can help the readers of this blog. You are not alone – and it can be done.

My major platforms that I will blog are

  • pure web tools and integration (php, javascript, mySQL),
  • Bonita BPM development (Bonita, Java, groovy, mySQL),
  • Filemaker integration (oh the things that can be done),
  • ZOHO development (online office suite) and
  • .net development
  • macros and scripting (Excel, Applescript, mouse control, scheduling etc.)
  • other platforms like integration into Facebook etc.

I will also have a shameless blog about the projects that we have worked on – a resume of sorts but more geared to let people know the depth and intensity if they are interested in knowing various aspects of my resume. If you want to see my resume, see it on linked-in.

Debugging Bonita – Tips and Tricks

To see the Bonita Engine Log for debugging issues:

  • Use Cygwin (a version of a unix shell in windows) http://cygwin.com/install.html
  • use the tail program with this line of code
    [groovy]
    tail /cygdrive/c/BOS-5.9/studio/workspace/.metadata/engine.log --lines=300 –follow
    [/groovy]

Insert an HTML widget for debugging

  • In the pool header – I have created a global map called “configMap” and there is an item ‘debug’
  • insert HTML widget into any page and have it shown conditionally upon configMap[‘debug’] having a true value

Writing to the Bonita Log

[groovy]

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;
Logger LOGGER = LoggerFactory.getLogger(this.getClass());
LOGGER.error("Your String Here");
[/groovy]

Debugging on the Server

Here is what I do know … there is hope and things are NOT the same as on a development  computer or situation

  • The debug output from System.out.printn from Java DOES go into 1 of 3 logs (will edit this when I get paths)
  • The output from the logging routine above goes to another log (will edit this when I get paths)
  • The output from the server hosting things like Tomcat goes to a 3rd log (will edit this when I get paths)

Windows Task Scheduler – a consistent way to execute exe files

A guaranteed way to make exe’s with parameters kick off is

aa) don’t run a scheduled task on a network share – if you get 0x1 as a result code .. copy everything to a local drive??? (latest update). Worked for me but is 2X work when source code changes.

aa1) UPDATE: If running bat files (tips from here)

  • run as highest privileges is checked
  • put the path of the bat file in the “start in” and a full path and bat file in the “Program/script” box
  • ensure there are no quotes in the Program/script and Start in boxes (not tested but I didn’t need them)
  • ensure all directories have “Ful Permissions” for the account you finally use to with’
  • test it with “r-mouse click” run. If it works there – it will worked with it logged on.

a) make a new Task Scheduler and make it it point to a bat file. You can try all sorts of other scenarios but  I have already spent hours – this works every time .

 

b) Now, lets take a look at that RunScriptNow.vbs.qualitysurfaces.bat file – I will copy the guts of it here:

[shell]
echo %date% %time% %username% qualitysurfaces >> c:\temp\test.txt
cd c:\Users\Administrator\Desktop\Moreaware
cscript //nologo //B RunScriptNow.vbs qualitysurfaces >>c:\temp\test.txt
echo %date% %time% >> c:\test.txt

[/shell]

It writes to a log file of your choice, then it mimicks the “Start in” by cd’ing to the directory where the executable file is

In this case, I wanted to run a .vbs file with parameters so I use cscript but this is not the focus on this step b). We put any output to the dos prompt from this .vbs process to the log file.

Lastly – to know that we made it to the end of the cscript line – we write again to the log.

NOW WE KNOW FOR SURE THINGS WERE DONE! If gui items pop up from the command line – don’t expect to see them like with window 2003 – this is now all silent. Note I have a diff bat file for every parameter – substituting %1 in that bat file above for ‘quality surfaces’ in the script line DOES NOT WORK – neither does %%1.

c) For directly kicking off an exe – hmmm. I think I converted them all to .vbs but you simply put the exe file on the command line NOT fully qualified with a path since the cd line directly above it. Again – pipe the output (append or >> ) to the log file so you know what is going on.

d) here is the guts of the .vbs file which should speed things up for you. This is in leiu of me having a .exe example in c) 😉

[vbnet]
Dim myDate, myTimeS
Dim nowvar
Dim incust
Dim ArgsListExtra

‘ get the arguments from the command line – we only want the first one and put it incust
if WScript.Arguments.Count >= 1 Then
incust = WScript.Arguments.Item(0)

‘get the rest of the arguments – not sure why I left this in but it works with this in so lets leave it
ArgsListExtra = ""
if WScript.Arguments.Count >= 1 Then
For i = 1 to WScript.Arguments.Count
ArgsListExtra = ArgsListExtra & " " & WScript.Arguments.Item(i-1)

Next
End If

‘lets make the filename with a nice date and timestamp in the file name
nowvar =  Now()
myDate = FormatDateTime(nowvar, 2)
myTimeS = FormatDateTime(nowvar, 3)

myTimeS = replace(myTimeS, ":", "_", 1, -1, 1)
myTimeS = replace(myTimeS," ","",1,-1,1)

myDate = replace("0"&myDate,"/","_0",1,-1,1)
myDate = replace(myDate, "_0201", "201", 1, -1, 1)
myDate = replace(myDate, "_00", "0", 1, -1, 1)
myDate = replace(myDate, "_0", "0", 1, -1, 1)
myDate = replace(myDate,"_00","0",1,-1,1)
myDate = replace(myDate," ","",1,-1,1)

Dim finalstring
finalstring = myDate & "_" & myTimeS

‘ now assemble the command line we would normally type

Dim cmdstart
cmdstart = "cd ""C:\Users\Administrator\Desktop"" && "    ‘ look up what && does on the command line – it allows multi command line items on one line of text. Crazy

Dim command
command  = cmdstart & "JobMaterialCost.exe -c "&incust&" -u username -p password -fe c:\Users\Administrator\Desktop\"&incust&"_"&finalstring’& ArgsListExtra &" && pause"

‘ now execute it

if 0 Then
WScript.Echo(command) ‘ this is here in case you want to debug – this will NOT show up in the TaskScheduled version – but it might hang there until you press OK – except you cannot
‘  press ok …. cause you cannot see the windows although it will still wait for you  🙂
Else
Set oShell = CreateObject("WScript.Shell")
‘Launch a command shell …. "/K" &lt;- keeps it open   – we want —&gt; /C */ – read up a GREAT text at <a href="http://technet.microsoft.com/en-us/library/ee692837">http://technet.microsoft.com/en-us/library/ee692837</a>
oShell.Run "CMD /C " &amp;command, , True
End If

‘WScript.Echo("Done" &amp; incust)  ‘ again this might hang your Scheduled Tasks

Else

End If
[/vbnet]

Appendix:
If you are interested in what makes the command prompt wait or not for the next process etc. within vbs files – see these links and read them twice – it is REALLY IMPORTANT if you use .vbs to help you script things
– http://technet.microsoft.com/en-us/library/ee692837
– http://technet.microsoft.com/en-us/library/ee692836
– http://visualbasic.about.com/gi/dynamic/offsite.htm?site=http://msdn.microsoft.com/library/en-us/script56/html/wsoriObjects.asp
– http://visualbasic.about.com/gi/dynamic/offsite.htm?site=http://msdn.microsoft.com/library/en-us/script56/html/wsoriObjects.asp
– http://technet.microsoft.com/en-us/library/ee176904.aspx
– http://labmice.techtarget.com/scripting/WSH.htm

How to setup Netatalk or Appletalk on a CentOS 6.3 linux machine

I cannot take to much credit except a link. Do what this guys says and it .  . . works.

http://rathelm.wordpress.com/2012/02/03/cent-os6-2-and-netatalk-2-2-0/

Then all your macs can backup to time machine. Don’t forget to set up a sparse bundle with a fixed size, else it will engulf the whole hard drive choking others out.

I use this in concert with setting up Time Machine to see a network drive instead of a local drive.