Rails: iOS version detection on mobile Safari in Production environment - regex

Edit: On mobile Safari I want to test for iOS version, say iOS 8.
Given request.user_agent returns:
Mozilla/5.0 (iPhone; CPU iPhone OS 8_1_2 like Mac OS X) ...
Do these methods look sufficient (edit: specifically, is the regex sound)?
def ios_device?
!!request.user_agent.match(/iphone|ipad|ipod/i)
end
def ios_8?
is_ios_device && !!request.user_agent.match(/OS 8_/)
end

In general, probably not. This is tricky (or impossible) to do reliably.
Here are some issues people have run into using the conventional useragent Ruby gem:
https://github.com/josh/useragent/issues/95
https://github.com/josh/useragent/issues/84
https://github.com/josh/useragent/issues/96
However in the specific case of iOS 3, that version of iOS is more limited than newer versions in how different kinds of requests may send different user agents, so perhaps your solution is adequate.

Related

Check what is the device(pc / tablet) in Windows 8

Does anyone here knows how to check which device is running an app in windows 8?
Preferably the Directx + Xaml version .
Thanks
When we developed Windows 8 we intentionally made it so that "tablet" and "PC" are one in the same. If you look at the new generation of hardware (UltraBooks that un-dock to become tablets, ARM-based laptops, etc) you'll see why it wouldn't be possible to guarantee to the app developer that a device is either a "tablet" or a "PC". You could string together a number of capabilities checks to take a guess but you run the risk of inadvertently causing a bad user experience for an unexpected use case.
Anticipating the "But Apple..." replies: This is different for the Apple ecosystem because their PC hardware runs a completely different OS than their tablet and their platform is only available on a small number known Apple devices. It's also different when you compare phones to tablets because a smartphone is essentially a tablet with a smaller screen. The intent of Windows is to run on a wide variety of devices from a wide variety of hardware makers. There are pluses and minuses with both scenarios.

Writing a 3D rendering browser plugin

I understand that it's possible to write a plugin for a browser which lets you render to the browser window, so you can effectively run a normal app within the browser. NOT using JS or client technology, but a plugin which basically wraps your application - in our case C++ which does 3D rendering using DirectX or OpenGL.
I know that we'd have to have versions for both IE and other browsers but how does this work - in Windows-speak do we get a HWND through the plugin architecture or is it more complex?
Do you have to write a version of the plugin compiled for each platform - Win/Mac/Linux, since a plugin is a binary I assume this is the case, so you have one version for IE and then multiple versions for FF, Chrome, Safari (which share the same plugin setup IIRC)
With FF - is this an example of a plugin or an extension specifically?
An example of what I mean is QuakeLive - proper 3D rendering within the browser. We're actually using Ogre (cross-platform C++) but this uses Direct3D/OpenGL so it's the same thing.
Things like QuakeLive can be done rather quite simply with Google's NativeClient SDK. It abstracts away the whole plugin architecture so that you can focus on writing your software, and provides support for nearly all plugin-capable browsers on Windows, Mac OS X, and Linux, portably. The user installs the NaCl plugin (which is included in some versions of Chrome and Chromium), and your software runs inside NaCl, seamlessly on all supported platforms, from a single binary.
Note that you can use OpenGL portably from within NaCl, but not DirectX. Future versions will also support ARM and x86_64 with technology from the LLVM project.
FireBreath is a great cross-platform, cross-browser library for developing C++ browser plugins.
Flash Player 11 provides true 3D support via Stage API over DirectX, OpenGL or whatever available at the device:
http://techzoom.org/adobe-flash-player-11-air-3-beta-stage3d-and-64bit-support-on-linux-mac-and-windows/
Its in beta now, so user needs to install it manually, but when Adobe release it then majority of browsers will provide true 3D support instantly. Latest Away3D beta already supports Stage API.
I have a need to get some of this done soon, so if anyone here is an expert on this please look me up.
Steve Bell
Archiform 3D animation studio

Is it possible to load a NPAPI plugin in Safari (Mac OS X)?

I've got some code that lies in a browser, and wrote C++ plugins for both IE (COM/ActiveX) and firefox (NPAPI).
I now have to get this code work on Mac OS X. I found some input on apple's site, but it's written in Objective C.
I also read about SIMBL, but it seems to deal with Objective C code only, isn't it?
So here are my questions:
Is it possible to code a pure C++ plugin for Safari (re-using my Firefox NPAPI plugin would be great)?
If it's not possible, is there a way to use an objective C plugin as a loader for some C++ code?
I'm a total noob on Mac OS, and don't even have a Mac Box to mess around, hence the very generic question.
Thanks
The NPAPI plugin mechanism is the standard mechanism for browser plugins on MacOS (and linux -- everything other than IE really) -- if you use the NPAPI your plugin will work on Safari, Firefox, and Opera. They will also work in both 32 and 64-bit Safari. Assuming your code makes no assumptions about what browser it's running in the same NPAPI-code should work in all browsers (i've seen "NPAPI" plugins that dynamically resolve XUL related functions in the blind faith that NPAPI is used only by Firefox, despite it being the standard plugin format for more or less every non-IE browser).
"Plugins" like SIMBL misuse MacOS APIs designed for a distinct (but important) purpose to arbitrarily inject their own code into the Safari address space -- when people use these (being mislead into believing it's safe) Safari becomes substantially less stable, and frequently stops working after major updates (in an extreme case the Leopard "blue screen of death" was because of logitech using APE to do something similar to SIMBL).

Porting C++ code from Windows to the Mac

I'm a long time Windows developer, and it looks like I'm going to be involved in porting a Windows app to the Mac.
We've decided to use Flex/Air for the gui for both sides, which looks really slick BTW.
My Windows application has a C++ DLL that controls network adapters (wired and wireless). This is written using the standard library and Boost, so most of it should work cross platform.
On the Mac, what IDE/complier do most folks use if they want to write C++? Also, can someone provide a pointer to whatever APIs the Mac has that can control WiFi adapters (associate, scan, disconnect, etc)?
Xcode is the IDE for Mac OS X, you can download the latest version by joining the Apple Developer Connection with a free Online membership.
I don't believe there are any supported APIs for controlling wireless networking adaptors. The closest thing would be the System Configuration framework, but I don't know if it will let you do everything you want.
Also, I would strongly recommend against trying to use Flex/Air for your application's user experience. It may look slick to you on Windows as a Windows developer, but when it comes to providing a full Macintosh user experience such technologies aren't always a great choice.
For one example, I think Air applications don't support the full range of Mac OS X text editing keystrokes. While not all Mac users will use all keystrokes, for those people used to them trying to type in a text field that doesn't handle (say) control-A and control-E to go to the beginning and end of field is like swimming through syrup.
For a new application that needs to be cross-platform, I'd strongly consider building the core logic in C++ while using Cocoa on the Mac and WPF on Windows to get the best user experience on each platform. Both Mac OS X and Windows have modern native user experience technologies that their respective users are getting used to, and also have good ways for C++ code to interoperate with these technologies.
The de-facto OS X IDE and compiler is Xcode. It comes with every Mac, you just install it from the OS X install CD.
Apple's developer site is the place to get more information on OS X APIs
Xcode and a custom GCC I believe...
xcode is the hotness, as people have already pointed out.
Having maintained a windows/mac codebase in the past, take a look at MVC.
So long as you keep the background logic distinct from the UI and from the platform-specific stuff (like file handling, networks, drawing to the screen, etc). That way, when you want to go to Linux in the future, you just have to write those platform specific components.
As for mac networking, are you on the level of connecting and so forth? Why not just let the OS handle that, and then you just see what connections are available? Why bother with whether or not the connection is wired or wireless? Because the OS has a lot of those tools already built in and users are used to making sure that the connection is there to do work, it seems odd to have an extra program to want to manipulate the network.
Xcode is used a lot, as far as I know the combination editor (e.g. Textmate), command line gcc is in fairly heavy use too. (that's what I do on OS X)
For all API needs head to Apple's developer site e.g. the networking API's

Entrek CodeSnitch with Windows Mobile 5/6

I have emailed Entrek and they seem to be asleep.
Does anyone else here use Entrek CodeSnitch? If so, have you found a way to use it with Windows Mobile 5, 6, or 6.1 ?
I really need to verify my application doesn't have any memory leaks, etc. And CodeSnitch does a great job of it. But only with Windows Mobile 2003. :/
Thanks.
What's not working? Is it a client connectivity issue?
The older version used PlatMan for a communications layer, which is problematic from a Visual Studio standpoint (which ships with CoreCon), but if you have any tool installed that has Platman (eVC, Platform Builder) then that should still work fine since WinMo 5.x and 6.x are still based on CE 5.0.
I do know that Entrek has a newer version in beta (I have it) so you might try pinging them again. They tend to be pretty busy, but I've always gotten responses (though I know them well and personally, so that might not be any indicator for you).
I also see that they have their phone number posted on their web page. I'd give them a call. I do recall them saying the new version is supposed to address WinMo issues (I rarely use WinMo proper) so it's definitely worth a try.
I've not used CodeSnitch. But I have had success using the Application Verifier Tool to identify my leaks in WM5 and 6.
Getting it up and running can be a bit of a pain. But I find it to be a good tool and the price is right.
Here's a tutorial to get you started.
I've used CodeSnitch on windows mobile 5, 6 and 6.1 devices with no problems.
Make sure you have the v1.4 installed and applied the v1.4 patch which is referenced here.
Like ctackle says, you need an older communications layer called CoreCon. I've also found CETK has CoreCon in it as well and it's not as big as eVC or Platform builder.
You need to setup the device connection settings to use ActiveSync (both transport and startup server), it does not seem to matter what the connection is called so something like Pocket PC will work fine.
The other gotcha I found is that you need to edit the codesnitch and procman shortcuts and add "/targetcpu:armv4i" to the command line arguments for them to work on WM devices.
I have also found them recently to be non-responsive to support emails as well :(