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".

Saturday, August 29, 2009

position:fixed in IE7

I didn't know that but if you add

at the top of you page, it will convince IE7 to respect the semantics of position:fixed.

(I wander what does it break in return ...)

Thursday, August 13, 2009

DNS problem with gmail (404) - possible dns poisoning

Yesterday I had the weirdest phenomenon, my gmail stopped working.
It just returned a 404 error (page not found).

Why do I say it was weird ?

  • Because it happened only on one of the computers in my network, while the other machine had no problems getting to gmail.

  • Because it happened on both IE and FF so it did not seem to result from a browser specific issue.

  • Because it only effected gmail but on the same machine I had no problem accessing any other web site including other google services such as calendar.

  • Because pinging to gmail.com or mail.google.com or googlemail.l.google.com all returned addresses that seemed to be valid google IPs.

  • Because when using IE to try and get to gmail.com I got a windows authentication dialog (and I really don't think gmail is running on windows based machines).

  • Because it turned out that it was actually trying to access the local web server on my machine and when I configured it to return a page when asked for /mail it did return that page.

  • Because at some point a ping to gmail.com started returning 127.0.0.1 (localhost).

  • Because this happened at the same day to a friend that was running Vista. (we do have both linksys routers and use the same internet provider.)


Eventually this was fixed by calling ipconfig /flushdns - I guess a restart could also do the trick.

Why and how did this happen - I have no idea.

Has anyone else encountered such strange behavior ?

Wednesday, August 05, 2009

Actionscript 3's ApplicationDomain Oddities 1

I have beeing doing lots of work around ApplicationDomain recently,
And there is so little information about this class (other then the realy good but not sufficiant and somewhat old post by Roger Gonzalez ).

so here goes odditie 1:

trace(ApplicationDomain.currentDomain == ApplicationDomain.currentDomain)
and
trace(ApplicationDomain.currentDomain === ApplicationDomain.currentDomain)

both trace out false.


Well, I guess the reason is that each time you access ApplicationDomain.currentDomain it create a new object that represents the currentDomain and you can use each of them for getDefinition but WHY ?! is it so.

maybe Rogger or one of his friends would like to comment on this ?

remember :

"The definition of ApplicationDomain.currentDomain is the ApplicationDomain that contains the code that is calling ApplicationDomain.currentDomain."

Thursday, July 09, 2009

Google's new OS - how about "chromeOSome" or "chromeOSome G" ?

Google will make an OS based on chrome - the currently refer to it as Chrome OS - they should name it "chromeOSome" or "chromeOSome G".

Saturday, April 11, 2009

Google AppEngine (GAE) is case sensitive and my XP is not

I was just about to post the following "complaint"/request for help to the google appengine newsgroup:

Hi,
I created a GAE application using python.
well - that might be an overstatement, as this app is just a plain static html/js/css website.

It took a while to get it running on my dev environment but finally it does work.

I executed the update script and it seems to run o.k.

D:\DVLP\Dozi>"C:\program Files\Google\google_appengine/appcfg.py" update d:\dvlp\dozi
Scanning files on local disk.
Initiating update.
Cloning 111 static files.
Cloned 100 files.
Cloning 12 application files.
Uploading 2 files.
Deploying new version.
Checking if new version is ready to serve.
Will check again in 1 seconds.
Checking if new version is ready to serve.
Closing update: new version is ready to start serving.
Uploading index definitions.

and I even see it on my console as uploaded.

BUT - when i try to go to any of

http://dozi-arch.appspot.com
https://dozi-arch.appspot.com
http://ppp.doritz.com
http://2.latest.dozi-arch.appspot.com

which to my understanding should all lead to a working version of this site I only get a page saying
"Oops! This link appears broken." (404)

if i try accessing an image on this site:
e.g.
http://dozi-arch.appspot.com/img/leaves.jpg
it is properly served.


my app.yaml looks like this:


No, you are not missing the end.
it was at that point that I said to myself - well, if it servers the image - why wont it serve the .htm ??

the app.yaml looks like this:


application: dozi-arch
version: 2
runtime: python
api_version: 1

default_expiration: "1m"

skip_files:
- ^(.*/)?app\.yaml
- ^(.*/)?app\.yml
- ^(.*/)?index\.yaml
- ^(.*/)?index\.yml
- ^(.*/)?#.*#
- ^(.*/)?.*~
- ^(.*/)?.*\.py[co]
- ^(.*/)?.*/RCS/.*
- ^(.*/)?\..*
- ^(.*/)?.*\.bak$
- ^(.*/)?.*\.sln$
- ^(.*/)?.*\.suo$
- ^(.*/)?.*\.txt$
- ^(.*/)?.*\.bat$
- ^(.*/)?Thumbs.db$


handlers:
- url: /
static_files: static/default.htm
upload: static/default.htm

# All URLs beginning with /img are treated as paths to static files in
# the img/ directory. Note that static_dir handlers do not use a
# regular expression for the URL pattern, only a prefix.

- url: /(.*)
static_files: static/\1
upload: static/(.*)



so why won't it serve default.htm when I go to the root of my site ?

well as it turns out - it because the file is locally stored as Default.htm not default.htm - when running on my pc the filesystem does not care for case and serves it even when asked for default.htm.

changed app.yaml to say:

- url: /
static_files: static/Default.htm
upload: static/Default.htm


and ....
Shazam...!!!!!

b.t.w -
does anyone know how can i server a url such as
http://example.com/שם_בעברית.htm
as a file from GAE ?! (for the non-hebrew-speakers among you - the file name just say "a name in hebrew".

well - maybe when i have another free night to bang my head against the GAE.

Monday, March 30, 2009

wrong or missing querystring parameters when the url of the swf gets redirected (302)

A bug we just found with the IE flash player:
When you load a swf from a URL that does not return the actual swf but responds with a redirect (302) to another URL where the actual swf is, the swf is loaded but paramters from the querystring of the redirected-to URL are not available to the swf.

i.e.
if you go try to load a swf from "http://mydomain.com/path/redirect?swfid=123"
when redirects to "http://swfhosting.com/pathtoswf/myswf.swf?param=val¶m2=val2"

The swf will load but will not be able to access "param" or "param2" as you might expect.
instead it will be able to see "swfid".

note: This does not happen with the FF flash plugin.

feel free to vote for fixing this bug and another one which seems related:
https://bugs.adobe.com/jira/browse/FP-1823
https://bugs.adobe.com/jira/browse/FP-1612

 
Clicky Web Analytics