Rails 3: How to store screen resolution? - ruby

I want to store user's screen resolution in database when user login. How to detect and store it to database when user login?

Read it with JavaScript (browsers don't send screen resolution information by default, so it isn't available to Ruby or anything else server side unless you make it so), then generate a hidden input, set the name and value based on the data you've gathered, then add it to the form containing the username and password inputs.
Oh, and you might find the window size more useful than the screen resolution. Not everybody maximizes their windows.

Related

How to check textual user input in a PowerPoint presentation?

Is it possible to check textual user input in a PowerPoint presentation?
I would like to create some kind of password field that users need the fill in correctly, before they can move on to the next slide.
To be clear: This is while the presentation is running, not in the edit mode.
An ActiveX text box can receive user input while the presentation is in slideshow view and has a Password Character property which, if set, displays the chosen character instead of whatever the user is typing; keeps the password safe from prying eyes.

Is there a way to create an image that flips to another side (another page) when tapped or clicked?

A user has a business card with two sides. It has the front side with primary information and the backside with secondary details. She wants that when she sends her business card to her contacts, they should see the front side of it only. And after clicking on it, it should flip to another side. The image should just be a gif or any other image format independent of any program.
All I can think of creating a gif which after an interval changes to the other side which does not fulfill her requirement of changing only when clicked.
I thought of ImageMap with hotspots but that too will require linking the other side (page) on the web which defies the independence of the image.
Any help in this regard is highly appreciated.
The GIF89a standard (the one we use today) includes the so-called User Input flag that was designed exactly for this.
That flag, being set on a certain frame, should tell a GIF decoder not to show the next frame until either the timeout expires or the user interacts with the current one.
Zero timeout coupled with nonzero User Input means that the decoder should wait for an interaction indefinitely.
Quote from the standard:
v) User Input Flag - Indicates whether or not user input is
expected before continuing. If the flag is set, processing will
continue when user input is entered. The nature of the User input
is determined by the application (Carriage Return, Mouse Button
Click, etc.).
Values : 0 - User input is not expected.
1 - User input is expected.
When a Delay Time is used and the User Input Flag is set,
processing will continue when user input is received or when the
delay time expires, whichever occurs first.
Unfortunately, no GIF decoders I know of even bother to handle this flag properly — so I guess your best bet is to give both frames reasonable timeouts, 10±5 seconds or so.

Uniquely identifying an NSScreen

I'm working on a project which has settings for each display. I want my application to support a display being removed and later re-added, possibly with another display used in between, with the original settings for each display being applied when the display is seen again.
As far as I can tell there is no way, through NSScreen, to uniquely identify one outside of the context of the current display configuration. I can't just use screen dimensions/properties as the user could have multiple displays of the same model in different locations; this problem applies to all persistent properties of a screen as far as I can tell.
Is there a good, known way to do this?
Thanks for your time. Any help is greatly appreciated.
The documentation to -[NSScreen deviceDescription] talks about getting the CGDirectDisplayID and the documentation about the CGDirectDisplayID says:
When a monitor is attached, Quartz assigns a unique display identifier (ID). A display ID can persist across processes and system reboot, and typically remains constant as long as certain display parameters do not change.
When assigning a display ID, Quartz considers the following parameters:
Vendor
Model
Serial number
Position in the I/O Kit registry
This sounds pretty close to what you are looking for.

replicating mouse motion using ajax

I want to implement an application on my website where once the users are connected, they share a text editor. If one user enters anything on
the text editor available on his screen, the same text appears on the second user’s
screen at the same coordinates.
Same thing goes for the other user. Also there would be pointer shaped images on both user’s screens to represent mouse pointers.
When user A moves his mouse pointer, the image on user B’s screen should be
moved according to the movement of user A’s mouse and similarly, when user B
moves his mouse, the image on user A’s screen should be moved accordingly.
The problem is I am using database to store the coordinates of each user. And this approach results in the a lot of lag and delay. What should I use in place of the database?? Please Help !
You probably don't want to request the updates but push them to your clients: http://en.wikipedia.org/wiki/Comet_%28programming%29 . This reduces the delay between an update from your client to the server and other clients again checking for updates.
how abt using Redis : http://code.google.com/p/redis/
an example of a similar collaborative text editor using this : http://www.web2media.net/laktek/2010/05/25/real-time-collaborative-editing-with-websockets-node-js-redis/

Is it possible to "trick" PrintScreen, swap out the contents of my form with something else before capture?

I have a bit of a challenge.
In an earlier version of our product, we had an error message window (last resort, unhandled exception) that showed the exception message, type, stack trace + various bits and pieces of information.
This window was printscreen-friendly, in that if the user simply did a printscreen-capture, and emailed us the screenshot, we had almost everything we needed to start diagnosing the problem.
However, the form was deemed too technical and "scary" for normal users, so it was toned down to a more friendly one, still showing the error message, but not the stack trace and some of the more gory details that I'd still like to get. In addition, the form was added the capabilities of emailing us a text file containing everything we had before + lots of other technical details as well, basically everything we need.
However, users still use PrintScreen to capture the contents of the form and email that back to us, which means I now have a less than optimal amount of information to go on.
So I was wondering. Would it be possible for me to pre-render a bitmap the same size as my form, with everything I need on it, detect that PrintScreen was hit and quickly swap out the form contents with my bitmap before capture, and then back again afterwards?
And before you say "just educate the users", yes, that's not going to work. These are not out users, they're users at our customers place, so we really cannot tell them to wisen up all that much.
Or, barring this, is there a way for me to detect PrintScreen, tell Windows to ignore it, and instead react to it, by dumping the aformentioned prerendered bitmap onto the clipboard ready for placing into an email?
The code is C# 3.0 in .NET 3.5, if it matters, but pointers for something to look at/for is good enough.
Our error-reporting window has these capabilities:
Show a screenshot that was taken when the error occured (contains all the open windows of the program at the time, before the error dialog was shown)
Show a text file containing every gory detail we can think of (but no sensitive stuff)
Save the above two files to disk, for latter attaching to an email or whatnot by the user
Sending the above two files to us by email, either by opening a new support case, or entering an existing support case number to add more information to it
Ignore the problem and hope it goes away (return to app)
Exit the application (last resort)
We still get screenshots from some users. Not all, mind you, so my question is basically how I can make the PrintScreen button help us a bit more for those users that still use it.
One option: Put the stack trace and other scary stuff into the error screen using small, low-contrast type -- e.g. dark gray on light gray -- so that the user doesn't really even see it, but the Print Screen captures it.
But if you want to detect the PrintScreen and do your own thing, this looks like an example of what you want.
Wouldn't it be possible to disable the Print Screen button altogether when the error popup is active? Have it display a message along the lines of "Please use the clearly visible button in the middle of your screen to report the error" I agree it breaks expected functionality, but if your users are really that stupid, what can you do...
Alternatively, have it report errors automatically (or store the data locally, to be fetched later, if you can't send without asking for some reason), without asking the user. If you want to be able to connect print screened screenshots with detailed error data, have it send a unique ID with the data that's also displayed in the corner of the popup.
What about offering them a "Print Screen" button that performs these actions as well as performing the print screen? If you're locked into this method of having your customers send error details, this may be an easier route to take.
Lifted from my comment below for easier reference (looks helpful, perhaps):
codeproject.com/KB/cs/PrintScreen.aspx
This is in theory...the best way to deal with it I would think
Intercept a WM_PRINT message or inject one into your process... see this article here
Install a system-wide keyboard hook and intercept the print-screen key and swap it around with your contents prior to the capture. Now, I can point you to several places for this, here on CodeProject, and here also, keyboard spy, and finally, global Mouse and keyboard hook on CodeProject.
Now, once you intercept the print screen, invoke the WM_PRINT message by capturing the contents that you want to capture.
I know this is brief and short, but I hope this should get you going.
The only solution i came up with was to offer big, large, easy to read toolbar buttons that give the user every opportunity to save the contents of the error dialog:
Save
Copy to clipboard
Send using e-mail
Print
And after all that, i use the Windows function SetWindowDisplayAffinity in order to show the user a black box where the form should be:
This function and GetWindowDisplayAffinity are designed to support the window content protection feature that is new to Windows 7. This feature enables applications to protect their own onscreen window content from being captured or copied through a specific set of public operating system features and APIs. However, it works only when the Desktop Window Manager(DWM) is composing the desktop.
It is important to note that unlike a security feature or an implementation of Digital Rights Management (DRM), there is no guarantee that using SetWindowDisplayAffinity and GetWindowDisplayAffinity, and other necessary functions such as DwmIsCompositionEnabled, will strictly protect windowed content, for example where someone takes a photograph of the screen.
If their screenshots show a big black box, hopefully they'll get the hint.
I did add a defeat, if they hold down shift while clicking "show error details", i don't add the protection during form construction:
//Code released into public domain. No attribution required.
if (!IsShiftKeyPressed())
SetWindowDisplayAffinity(this.Handle, WDA_MONITOR); //Please don't screenshot the form, please e-mail me the contents!

Resources