forms - Dave's Blog

Search
My timeline on Mastodon

Data breakpoints in JavaScript

2016 Jun 17, 5:44

The other day I had to debug a JavaScript UWA that was failing when trying to use an undefined property. In a previous OS build this code would run and the property was defined. I wanted something similar to windbg/cdb's ba command that lets me set a breakpoint on read or writes to a memory location so I could see what was creating the object in the previous OS build and what that code was doing now in the current OS build. I couldn't find such a breakpoint mechanism in Visual Studio or F12 so I wrote a little script to approximate JavaScript data breakpoints.

The script creates a stub object with a getter and setter. It actually performs the get or set but also calls debugger; to break in the debugger. In order to handle my case of needing to break when window.object1.object2 was created or accessed, I further had it recursively set up such stub objects for the matching property names.

Its not perfect because it is an enumerable property and shows up in hasOwnProperty and likely other places. But for your average code that checks for the existence of a property via if (object.property) it works well.

PermalinkCommentsdebug debugging javascript

laughingsquid: Live Band Performs ‘Mario Kart’ Song as Man...

2015 May 27, 3:11


laughingsquid:

Live Band Performs ‘Mario Kart’ Song as Man Races Down the Video Game Track

PermalinkComments

laughingsquid: Live Band Performs ‘Mario Kart’ Song as Man...

2015 May 27, 3:11


laughingsquid:

Live Band Performs ‘Mario Kart’ Song as Man Races Down the Video Game Track

PermalinkComments

Gamers Messed With The Steam Sale, Then Valve Changed The Rules

2014 Jun 24, 3:51

Applied game theory 101: Valve’s Steam Summer Sale involves a meta game with teams of Steam users competing for daily prizes. On Reddit the players join together to take turns winning daily. Valve gets wise and performs an existential attack, changing the rules to make it harder for players to want to coordinate.

Still, that all the players joined together to game the system gives me hope for humanity. Its a self organized solution to a tragedy of the commons problem. Only in this case the tragedy is by design and is updated to be more tragic.

PermalinkCommentsgame video-game game-theory valve

mostlysignssomeportents: More than 90% of Americans believe...

2014 Jun 7, 9:55


mostlysignssomeportents:

More than 90% of Americans believe that the US government is unduly influenced by money, and the Mayday.US super PAC is raising $5M to fund the election campaigns of politicians who’ll pledge to dismantle super PACs and enact other campaign finance reforms. They raised more than $1M in 30 days last month, and this month, the goal is $5M. It’s the brainchild of Lawrence Lessig, who’s going to run prototype the project by running five electoral campaigns in 2014, and use the lessons of those projects to win enough anti-corruption seats in 2016 to effect real change.

Again, I’m not able to contribute to Mayday.US, because I’m a Canadian and Briton. But I ask my American friends to put in $10, and promise that I’ll put CAD1000 into any comparable Canadian effort and/or £1000 into a comparable UK effort. We all win when countries embrace evidence-based policy guided by doing what’s best for its citizens, rather than lining the pockets of corrupting multinationals.

Mayday.US

Please reblog!

PermalinkComments

URI functions in Windows Store Applications

2013 Jul 25, 1:00PermalinkCommentsc# c++ javascript technical uri windows windows-runtime windows-store

Shout Text Windows 8 App Development Notes

2013 Jun 27, 1:00

My first app for Windows 8 was Shout Text. You type into Shout Text, and your text is scaled up as large as possible while still fitting on the screen, as you type. It is the closest thing to a Hello World app as you'll find on the Windows Store that doesn't contain that phrase (by default) and I approached it as the simplest app I could make to learn about Windows modern app development and Windows Store app submission.

I rely on WinJS's default layout to use CSS transforms to scale up the user's text as they type. And they are typing into a simple content editable div.

The app was too simple for me to even consider using ads or charging for it which I learned more about in future apps.

The first interesting issue I ran into was that copying from and then pasting into the content editable div resulted in duplicates of the containing div with copied CSS appearing recursively inside of the content editable div. To fix this I had to catch the paste operation and remove the HTML data from the clipboard to ensure only the plain text data is pasted:

        function onPaste() {
var text;

if (window.clipboardData) {
text = window.clipboardData.getData("Text").toString();
window.clipboardData.clearData("Html");
window.clipboardData.setData("Text", util.normalizeContentEditableText(text));
}
}
shoutText.addEventListener("beforepaste", function () { return false; }, false);
shoutText.addEventListener("paste", onPaste, false);

I additionally found an issue in IE in which applying a CSS transform to a content editable div that has focus doesn't move the screen position of the user input caret - the text is scaled up or down but the caret remains the same size and in the same place on the screen. To fix this I made the following hack to reapply the current cursor position and text selection which resets the screen position of the user input caret.

        function resetCaret() {
setTimeout(function () {
var cursorPos = document.selection.createRange().duplicate();
cursorPos.select();
}, 200);
}

shoutText.attachEvent("onresize", function () { resetCaret(); }, true);
PermalinkCommentsdevelopment html javascript shout-text technical windows windows-store

Alternate IPv4 Forms - URI Host Syntax Notes

2012 Mar 14, 4:30

By the URI RFC there is only one way to represent a particular IPv4 address in the host of a URI. This is the standard dotted decimal notation of four bytes in decimal with no leading zeroes delimited by periods. And no leading zeros are allowed which means there's only one textual representation of a particular IPv4 address.

However as discussed in the URI RFC, there are other forms of IPv4 addresses that although not officially allowed are generally accepted. Many implementations used inet_aton to parse the address from the URI which accepts more than just dotted decimal. Instead of dotted decimal, each dot delimited part can be in decimal, octal (if preceded by a '0') or hex (if preceded by '0x' or '0X'). And that's each section individually - they don't have to match. And there need not be 4 parts: there can be between 1 and 4 (inclusive). In case of less than 4, the last part in the string represents all of the left over bytes, not just one.

For example the following are all equivalent:

192.168.1.1
Standard dotted decimal form
0300.0250.01.01
Octal
0xC0.0XA8.0x1.0X1
Hex
192.168.257
Fewer parts
0300.0XA8.257
All of the above

The bread and butter of URI related security issues is when one part of the system disagrees with another about the interpretation of the URI. So this non-standard, non-normal form syntax has been been a great source of security issues in the past. Its mostly well known now (CreateUri normalizes these non-normal forms to dotted decimal), but occasionally a good tool for bypassing naive URI blocking systems.

PermalinkCommentsurl inet_aton uri technical host programming ipv4

Amanda Palmer Performs The Popular Hits Of Radiohead On Her Magical Ukulele | Amanda Palmer

2010 Jul 21, 3:08"Amanda Palmer Performs The Popular Hits Of Radiohead On Her Magical Ukulele" "Immediate download of 7-track album in your choice of 320k mp3, FLAC, or just about any other format you could possibly desire. Buy Now $0.84 USD or more"PermalinkCommentsamanda-palmer audio download mp3 music radiohead ukulele

Amanda Palmer To Release an EP of Radiohead Covers & Debuts “Idioteque” as First Single « amanda palmer

2010 Jun 22, 3:24"On July 20th Amanda will be releasing an EP of Radiohead cover songs titled Amanda Palmer Performs The Popular Hits of Radiohead on Her Magical Ukulele." Includes her cover of Idioteque.

PermalinkCommentsamanda-palmer radiohead ukulele uke music

Tao Effect Blog » Blog Archive » Steve Jobs’ response on Section 3.3.1

2010 Apr 11, 2:16Lots of links, info, and thoughts on Apple's change to the iPhone SDK terms of service that now state "Applications must be originally written in Objective-C, C, C++, or JavaScript..." Means no other languages or third party platforms...PermalinkCommentssteve-jobs apple sdk api tos legal law iphone ipod ipad technical

EricLaw's IEInternals : HTTP/HTTPS Port-Blocking in WinINET

2010 Mar 26, 5:16Interesting point that web browsers block HTML FORMs from submitting to some ports in order to avoid malicious servers from getting clients to do their dirty work. Of course it requires the host on the other side of that port to be able to interpret the HTTP request as something relevant to the protocol they actually expect.PermalinkCommentssecurity web browser ie http html form technical

Code: Flickr Developer Blog » A Chinese puzzle: Unicode and EXIF metadata parsing

2010 Jan 8, 2:08Flickr dev talks image metadata the various forms which to prefer and how to guess at their character encodings.PermalinkCommentsunicode charset flickr photo image exif programming reference xmp technical

Cheap Multiplayer Tricks for New Super Mario Bros. Wii

2010 Jan 5, 1:47

The New Super Mario Bros. Wii is a great game. Its the fun of old school Mario with the addition of great graphics and the kind of multiplayer I've wanted for Mario since playing the original as a child: its got up to four player simultaneous cooperative multiplayer. I recommend it to anyone who has enjoyed Mario in the past. Watch this amazing video of level 1-3 you can unlock in the game.

As noted elsewhere, multiple players attempting to navigate platforms, grab power ups, and throw turtle shells creates new challenges but along with that there's new ways to be incredibly cheap.

Jumping Higher
A second player means a head one can jump on to reach higher locations. Jump on your friend's head at the apex of their jump while holding down the jump button yourself for maximum jumping. In the game you can also grab other players and hold them over your head. This is useful for reaching the top of the flagpole at the end of levels. On that same line, if the player you grab has a flying cap you can now use them to fly in the same manner you would use a flying block which makes it easy to get two players to the top of the finish flagpole if only one of you has a flying cap.
Power-Ups
Normal power-up blocks now spawn enough power-ups for everyone. A mushroom is spawned for each small player and full power-ups for the rest, except in the case everyone is small: then one of the power-ups is a full power-up. If there's two players and you're both small, the full power-up always jumps out of the block to the right. Some hidden power-up blocks only give out one power-up and in that case its a mushroom or not based on the player who hits the block - so be sure that a big player hits that if you have one.
Death & Bubbles
When a player dies but at least one other player lives the dead player comes back in a limbo bubble from which they must be released before they may play again. Because of this, in a tough spot you can send one player in and leave a second behind. If the first dies you don't lose your place in the level and the first comes back in a bubble ready to try again. For instance, if you're trying to get the last star coin in 2-1 which sits just above the abyss, one player can just jump to their death for it and as long as another player lives you've collected the coin. However you need not sacrifice your life to do this: you can press down and 'a' to force yourself into a bubble saving yourself from death. This is true in general as long as you have enough time to see your death coming. This is also useful if one player runs ahead to the right. The screen will expand a bit but then it will just move to the right following the player in the lead. Players left behind walls or now forced into lava pits will die unless they use the bubble.
Misc.
  • If all players hit the ground at the same time from a ground pound it acts like hitting a pow block, killing the enemies on the screen.
  • If you hold a player who has a projectile power over your head they can still use their power.
  • Bubbles can be popped by hitting them with your fire or ice projectiles as well as thrown shells or blocks.
  • All players get the extra lives from anyone collecting 100 coins or finishing a level with more than 7 enemies on the screen.
PermalinkCommentsmultiplayer mario wii

Gibberish rock song written by Italian composer to sound like English Boing Boing

2009 Dec 17, 6:13"In this remarkable and fully rockin' video, an Italian singer performs a rock piece whose lyrics are gibberish intended to sound like English"PermalinkCommentsvideo language english italian rock music

Waooooooow, Ample SDK - <Glazblog/>

2009 Dec 1, 5:55A cross browser javascript implementation of SVG, XUL, portions of HTML5 and more. Check out their demos. "Ample SDK, a must-see: cross-browser (Gecko, Webkit, Opera, Chrome, and even IE 5.5+ !!), XInclude 1.0, XML Events 1.0, XML Schema, SMIL 3.0, REX 1.0, XBL 2.0 (!), SVG, XUL (cross-browser !), HTML5, XForms, ..., superb demos (SVG-based @shepazu in IE, wow...), dual MIT/GPL licensing terms, open-source"PermalinkCommentstechnical browser svg xul webkit opera ie javascript web html5

Time/Date Conversion Tool

2009 Aug 28, 3:39

I built timestamp.exe, a Windows command line tool to convert between computer and human readable date/time formats mostly for working on the first run wizard for IE8. We commonly write out our dates in binary form to the registry and in order to test and debug my work it became useful to be able to determine to what date the binary value of a FILETIME or SYSTEMTIME corresponded or to produce my own binary value of a FILETIME and insert it into the registry.

For instance, to convert to a binary value:

[PS C:\] timestamp -inString 2009/08/28:10:18 -outHexValue -convert filetime
2009/08/28:10:18 as FILETIME: 00 7c c8 d1 c8 27 ca 01

Converting in the other direction, if you don't know what format the bytes are in, just feed them in and timestamp will try all conversions and list only the valid ones:

[PS C:\] timestamp -inHexValue  "40 52 1c 3b"
40 52 1c 3b as FILETIME: 1601-01-01:00:01:39.171
40 52 1c 3b as Unix Time: 2001-06-05:03:30:08.000
40 52 1c 3b as DOS Time: 2009-08-28:10:18:00.000
(it also supports OLE Dates, and SYSTEMTIME which aren't listed there because the hex value isn't valid for those types). Or use the guess option to get timestamp's best guess:
[PS C:\] timestamp -inHexValue  "40 52 1c 3b" -convert guess
40 52 1c 3b as DOS Time: 2009-08-28:10:18:00.000

When I first wrote this I had a bug in my function that parses the date-time value string in which I could parse 2009-07-02:10:18 just fine, but I wouldn't be able to parse 2009-09-02:10:18 correctly. This was my code:

success = swscanf_s(timeString, L"%hi%*[\\/- ,]%hi%*[\\/- ,]%hi%*[\\/- ,Tt:.]%hi%*[:.]%hi%*[:.]%hi%*[:.]%hi", 
&systemTime->wYear,
&systemTime->wMonth,
&systemTime->wDay,
&systemTime->wHour,
&systemTime->wMinute,
&systemTime->wSecond,
&systemTime->wMilliseconds) > 1;
See the problem?

To convert between these various forms yourself read The Old New Thing date conversion article or Josh Poley's date time article. I previously wrote about date formats I like and dislike.

PermalinkCommentsdate date-time technical time windows tool

JOHO -February 4, 2008

2009 Aug 26, 2:30"Being fair is not enough. In fact, sometimes what's fair is wrong precisely because it's fair. Oooh! A seeming paradox! One of the top three rhetorical forms for essays!"PermalinkCommentstechnical internet david-weinberger net-neutrality web fair

Creating Accelerators for Other People's Web Services

2009 Aug 18, 4:19

Before we shipped IE8 there were no Accelerators, so we had some fun making our own for our favorite web services. I've got a small set of tips for creating Accelerators for other people's web services. I was planning on writing this up as an IE blog post, but Jon wrote a post covering a similar area so rather than write a full and coherent blog post I'll just list a few points:

PermalinkCommentstechnical accelerator ie8 ie

Controlling DNS prefetching - MDC

2009 Jun 22, 2:53"Firefox 3.5 performs DNS prefetching. This is a feature by which Firefox proactively performs domain name resolution on both links that the user may choose to follow as well as URLs for items referenced by the document, including images, CSS, JavaScript, and so forth."PermalinkCommentsdns firefox mozilla networking performance dns-prefetching technical
Older Entries Creative Commons License Some rights reserved.