Tuesday, October 15, 2013

Compile LESS CSS files and compress/minify CSS and JS files using node.js

Here is what you need to do, in order to

- compile your LESS files into CSS whenever they are changed and also compress those CSS files into .min.css (*1)

- compress your JS files into .min.js whenever they are changed


The 2 scripts described here will automatically perform the above actions upon invocation and will then also set up a file-watcher on the specified directory.



But first:
- Download and install node.js from here.

- Download and install uglifyjs from here, using
npm install uglify-js --global
- Download and install LESS compiler from here, using
npm install less --global

Download this RAR file, which contains all the script files that I have modified, so all you need to do is adjust the contained sample batch file and off you go.


These scripts allow you to specify a source and a target directory.
For LESS/CSS, the LESS file is compiled into CSS in the same directory.
The CSS is then compressed into the target directory.

For JS, the js file is compressed into the target directory.

When you run the batch file, it will scan and process all matching files and then it will stay in the background, monitoring the source directory.


Many thanks to the guys that have created all of the above tools.
The original idea for this was from Jonathan Cheung's code here.



[Blatant plug! See my article about my album on Google Play.]

ps: Comments and/or links to this article are most welcome!

Sunday, September 1, 2013

Freepascal/Lazarus decimal rounding vs Excel rounding


I found this thread quite useful, regarding decimal rounding in freepascal/Lazarus.

This article also describes a unit somebody has written that handles decimal values more accurately (and also more like .net does (much as it hurts me to say this!))


ps: Comments and/or links to this article are most welcome!

Sunday, August 11, 2013

How to achieve shift-click (contiguous) select on a Lazarus TDBGrid


Please follow this link to my post in the Lazarus forum

ps: Comments and/or links to this article are most welcome!

Thursday, July 18, 2013

FortesReports: Misc info

This post will accumulate info on FortesReports, the reporting tool used in Lazarus/FreePascal.

Once enough info has been collected and cleaned up, it will be passed on to the Lazarus group.
------------------------

- Grouping and ORDER BY
Groups in a report do not force a sort by that field.
If you have a SELECT f1, f2 FROM dooda ORDER BY f2
and create a report which groups by f1, you will end with multiple breaks, as f1 changes values while moving through the recordset.
To avoid that, you will need to SELECT f1, f2 FROM dooda ORDER BY f1, f2



ps: Comments and/or links to this article are most welcome!

Saturday, May 25, 2013

FreePascal/Lazarus: How to use lookup combo in DBGrid

I recently worked on a project where I used FreePascal in order to create an app that consisted of a single EXE and which did not need to be installed (portable app).

I had some difficulty in getting a lookup column in the grid and, after lots of searches pointing to convoluted solutions, I came across the following 2 pages, which gave me the info I needed to solve the problem.

Defining a Lookup List Column

Defining a lookup field

In a nutshell, you need to create a lookup field in the TSqlQuery (or whatever query type you use).
You then add a new field in the grid control and link it to the lookup field you created in the query.

Using this method means that you must specify the UPDATE and INSERT SQL (just in case you used to rely on what FreePascal/Delphi generated).


For example, in this case, the CrewMembers table contains a CrewID but not the CrewName.

A lookup field is created in the CrewMembers query, as show below



I want to show the CrewName from the Crew table when I am editing the CrewMembers table.
The CrewMembers table contains only the CrewID, not the name.


LookupDataSet= A Dataset that loads data from the Crew table
LookupKeyField= The name of the key field in the Crew table that I will link to via my CrewID
keyFields=The name of the key field in my table/grid (in this case, CrewID)

This is a just a quick overview. Leave a comment if you'd like more info.

[Blatant plug! See my article about my album on Google Play.]


ps: Comments and/or links to this article are most welcome!

Thursday, March 21, 2013

Extensive comparison of rss/news readers

I recently found this page, containing a large number of rss/news readers and a features table comparison.

Now that Google Reader has been shot in the head, this page may just help you find a replacement.


ps: Comments and/or links to this article are most welcome!

Sunday, January 20, 2013

Win7 window-title double click does not maximise...

Somehow, I found myself double-clicking on the top border of a window in Win7 and...nothing happened.
I had rather hoped that the window would maximise vertically, as it had countless times before.

I blamed it on the extreme heat we've been having here in Melbourne (no, not the one in the US, I mean the real one), so I put up with it for a week or two.


Eventually my nerves couldn't take it any more, so I found this fix:
(This fix should also work in Vista. The best fix though is to ditch Vista, kick yourself for ever installing it on your computer and stay with Win7-64.
Also, there is no need to pay more money to Microsnuff. 
No, you don't need Win8!)

- Open Control Panel.
- Click on 'Ease of Access'
- Click on 'Make the Mouse easier to use'
(be warned, the computer will start talking to you. Don't worry, its just subliminal messages from Steve Balmer trying to make you:
   - Buy Win8
   - Switch from Google to Bing (Bing what???I hear you say)
   - repeat above 2 steps forever)

- Make sure the 'Prevent windows from being automatically arranged...' checkbox is *not* checked
- Done!



ps: Comments and/or links to this article are most welcome!