Sunday, June 06, 2010

"Exception: Unknown project extension: Library" error when running fdbuild (flashDevelop) from the command line

This happens to me each time I install a fresh copy of flashDevelop.

Each time It takes me some time to figure out why this happens.

next time I will have my blog to remind it happens because:
Because the location of the FLEX SDK is not set in the flash develop setting dialog.

Thursday, May 27, 2010

Hell is other people's CSS rules

A significant part of the JavaScript code I wrote in the last few years is intended to run as part of HTML pages developed by other people.

Now consider the following:

Lets say your JavaScript has a function called "AddButton" that takes a background color, a text color, some text for the button itself and a callback function to call when the button is pressed. and it renders the HTML and CSS that will show this button on the client's page. (Of course in real life this is much more complicated bu this should do to make the point).

You create perfect code, test it on FF,Chrome,IE,Safari,iPhone,iPad and what not, and it looks perfect and works great.

Now your customers/clients start to use your wonderful code and it turns out that one of them has a CSS rule that says "DIV {left-margin:5px}" which causes the texts on your perfect button not to be centered on his site.

So you go and change you code to rended style tags on all your divs saying that their left-margin (and right and top and bottom) are 0px, so your good now.

But then it turns out that another client has "Div {border:1px solid white}" ....
and so on (and of course this is not limited to divs...

How "defensive" should you be "against" the CSS ruls of the hosting page? and what can you do assuming that you don't want to start adding all the possible CSS attributes to every tag you render ?

How would you go about handling this?

Oh... and IFRAMEs are not a valid solution. Well, actually some times they are but lets assume this is not one of those times - why ?

1) Performance
2) Your generated html is required "flow" as part of the hosing page.

Any JavaScript / HTML /CSS lover out there would care to share his thoughts on this ?

Eyal

Sunday, January 03, 2010

Using PSCX from multiple users on same machine

I was having a problem with an automation script I was working on,
It used PowerShell and PowerShell community extensions (PSCX) and it worked fine of for me, but when other people used the same machine - it did not work.

after some looking around - the problem was that PSCX was installed from my user so it was automatically loaded on from my profile.

The resolution:

$pscxInstalled = $false;
$pscxLoaded = $false;
$registeredPSSnapins = Get-PSSnapin -registered
foreach ($registeredPSSnapin in $registeredPSSnapins) {
if ($registeredPSSnapin.Name -eq 'Pscx') {
write-host "PowerShell Community Extensions Found on system" -ForegroundColor green -BackgroundColor black
$pscxInstalled=$true;
$loadedPSSnapins = Get-PSSnapin
foreach ($loadedPSSnapin in $loadedPSSnapins) {
if ($loadedPSSnapin.Name -eq 'Pscx') {
$pscxLoaded=$true
write-host "PowerShell Community Extensions are loaded" -ForegroundColor green -BackgroundColor black
}
}
if (-not $pscxLoaded) {
write-host "Loading PowerShell Community Extensions from registered PSSnapin" -ForegroundColor green -BackgroundColor black
Add-PSSnapin Pscx

}
}
}

Sunday, December 06, 2009

single and double quotes in PowerShell (PoSh)

I was dealing with converting a batch to PoSh and had to create some wired mixture of double and single quotes. I was searching the net and got to this page http://www.vistax64.com/powershell/23546-mix-single-double-quotes.html where he used the following notation:

# $XY$X

so it hit me:
instead of odd things like
write-host '$X'"Y"'$X'

I can do:

$DQ = '"'
$SQ = "'"

and then
write-host '$X$SQ$DQY$DQ$SQ$X'

I guess there might clearer strings to read but at least it works.

maybe
$_DQ_ = '"'
$_SQ_ = "'"

write-host '$X$_SQ_$_DQ_Y$_DQ_$_SQ_$X'

Friday, November 06, 2009

Tim Harford's "Marriage supermarket" from "The logic of life"

I have read Tim's "Undercover Economist" (In its Hebrew translation) and enjoyed it very much so I was happy to find (again the Hebrew translation of) "The Logic of Life" at the book store.

NOTE: In some of what I am about to write I am translating back to English from the Hebrew translation of the book, I hope it will not be far from the original.

I am still reading it and I just read the part about the "marriage supermarket" in chapter 3.

In this part Tim describes the following scenario:
20 single males and 20 single females are in a room, the "marriage supermarket", each pair that decides to "get married" gets paid 100 Pounds. (They don't actually get married they only pair up and are not required to do anything else).
Tim goes on and explains that when there is an equal number singles from both genders We should expect the money to be divided 50%-50%. (This does sound reasonable).

But then Tim Harford goes on and asks what will happen if on one night on of the males does not show for some reason. Tim's analysis suggest that after 19 pairs will be formed the last woman that could currently expect to get 0 Pounds (because she does not have someone to "get married to" should/will suggest to one of the males that he abandons his current "wife" and take her instead, for this she will promise him that she would be satisfied with receiving only 40 pounds. This would leave another woman at a disadvantage and cause he to make a similar suggestion, a process that will continue until 19 of the females will get 1 penny and the 20th will go home even without that single penny when the man will each get 99.99 Pounds each.

Well, I think that this will not be what will actually happen.
If you assume that all the females know what they are doing the 20th should talk to the other 19 and tell them something along the following lines:
"Listen Girls, We can either start a bidding war and end up with a penny each or we can split the 19*50 we can get from the males and share it among us leaving us each with 47.5 pounds each".

I believe this will/should be the stable solution and it s a much better one for the females involved.

More that that - If this was not the case - then it would be a good idea for the group of man to decide to leave one of them at home to begin with (hopeing that the women did not think about it as well).

The only reason to accept Tim's solution IMHO would be if this kind of money sharing among the women would just not be allowed in the "GAME".

 
Clicky Web Analytics