Detect mobile browser [duplicate]

Have my user agent code: <?php /* USER-AGENTS ================================================== */ function check_user_agent ( $type = NULL ) { $user_agent = strtolower ( $_SERVER[‘HTTP_USER_AGENT’] ); if ( $type == ‘bot’ ) { // matches popular bots if ( preg_match ( “/googlebot|adsbot|yahooseeker|yahoobot|msnbot|watchmouse|pingdom\.com|feedfetcher-google/”, $user_agent ) ) { return true; // watchmouse|pingdom\.com are “uptime services” } } else if … Read more

How to determine artificial bold style ,artificial italic style and artificial outline style of a text using PDFBOX

The general procedure and a PDFBox issue In theory one should start this by deriving a class from PDFTextStripper and overriding its method: /** * Write a Java string to the output stream. The default implementation will ignore the <code>textPositions</code> * and just calls {@link #writeString(String)}. * * @param text The text to write to … Read more

iOS How to detect iPhone X, iPhone 6 plus, iPhone 6, iPhone 5, iPhone 4 by macro?

Swift import UIKit public enum DisplayType { case unknown case iphone4 case iphone5 case iphone6 case iphone6plus static let iphone7 = iphone6 static let iphone7plus = iphone6plus case iphoneX } public final class Display { class var width:CGFloat { return UIScreen.main.bounds.size.width } class var height:CGFloat { return UIScreen.main.bounds.size.height } class var maxLength:CGFloat { return max(width, … Read more

Detect if program is running with full administrator rights

Win9x: Everyone is “admin” NT4: OpenThreadToken/OpenProcessToken + GetTokenInformation(…,TokenGroups,…) on DOMAIN_ALIAS_RID_ADMINS SID in a loop 2000+: OpenThreadToken/OpenProcessToken + CheckTokenMembership on DOMAIN_ALIAS_RID_ADMINS SID Other alternatives are: IsUserAnAdmin or AccessCheck Checking the TOKEN_ELEVATION* stuff in the token is not required for testing the current process but it is useful if you need to find out if the user … Read more

Detecting network connection speed and bandwidth usage in C#

Try using the System.Net.NetworkInformation classes. In particular, System.Net.NetworkInformation.IPv4InterfaceStatistics ought to have some information along the lines of what you’re looking for. Specifically, you can check the bytesReceived property, wait a given interval, and then check the bytesReceived property again to get an idea of how many bytes/second your connection is processing. To get a good … Read more

Javascript: How to detect if a word is highlighted

The easiest way to do this is to detect mouseup and keyup events on the document and check whether any text is selected. The following will work in all major browsers. Example: function getSelectedText() { var text = “”; if (typeof window.getSelection != “undefined”) { text = window.getSelection().toString(); } else if (typeof document.selection != … Read more

Is it possible to detect Android app uninstall?

The GCM documentation explains this situation here: “An application can be automatically unregistered after it is uninstalled from the device. However, this process does not happens right away, as Android does not provide an uninstall callback.” Basically when GCM tries to send the next push notification, the device will tell GCM the receiving application … Read more