convert

Convert Lat/Longs to X/Y Co-ordinates

匿名 (未验证) 提交于 2019-12-03 02:14:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have the Lat/Long value of New York City, NY; 40.7560540,-73.9869510 and a flat image of the earth, 1000px × 446px. I would like to be able to convert, using Javascript, the Lat/Long to an X,Y coordinate where the point would reflect the location. So the X,Y coordinate form the Top-Left corner of the image would be; 289, 111 Things to note: don't worry about issues of what projection to use, make your own assumption or go with what you know might work X,Y can be form any corner of the image Bonus points for the same solution in PHP (but I

How to convert milliseconds to date in SQLite

匿名 (未验证) 提交于 2019-12-03 02:14:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I store date from Calendar.getTimeInMilliseconds() in SQLite DB. I need to mark first rows by every month in SELECT statement, so I need convert time in milliseconds into any date format using SQLite function only. How can I avoid this? 回答1: One of SQLite's supported date/time formats is Unix timestamps, i.e., seconds since 1970. To convert milliseconds to that, just divide by 1000. Then use some date/time function to get the year and the month: SELECT strftime('%Y-%m', MillisField / 1000, 'unixepoch') FROM MyTable 回答2: Datetime expects

Convert pem key to ssh-rsa format

匿名 (未验证) 提交于 2019-12-03 02:14:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a certificate in der format, from it with this command I generate a public key: openssl x509 - inform der - in ejbcacert . cer - noout - pubkey > pub1key . pub Which results in this: ----- BEGIN PUBLIC KEY ----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC7vbqajDw4o6gJy8UtmIbkcpnk O3Kwc4qsEnSZp / TR + fQi62F79RHWmwKOtFmwteURgLbj7D / WGuNLGOfa / 2vse3G2 eHnHl5CB8ruRX9fBl / KgwCVr2JaEuUm66bBQeP5XeBotdR4cvX38uPYivCDdPjJ1 QWPdspTBKcxeFbccDwIDAQAB ----- END PUBLIC KEY ----- How can I obtain a public key like this? Either from

Javamail Could not convert socket to TLS GMail

匿名 (未验证) 提交于 2019-12-03 02:13:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to send an email using JavaMail through gmails SMTP Server. however this code. final String username = "mygmail@gmail.com"; final String password = "mygmailpassword"; Properties props = new Properties(); props.put("mail.smtp.auth", true); props.put("mail.smtp.starttls.enable", true); props.put("mail.smtp.host", "smtp.gmail.com"); props.put("mail.smtp.port", "587"); Session session = Session.getInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new

Best way to convert IList or IEnumerable to Array

匿名 (未验证) 提交于 2019-12-03 02:13:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a HQL query that can generate either an IList of results, or an IEnumerable of results. However, I want it to return an array of the Entity that I'm selecting, what would be the best way of accomplishing that? I can either enumerate through it and build the array, or use CopyTo() a defined array. Is there any better way? I went with the CopyTo-approach. 回答1: Which version of .NET are you using? If it's .NET 3.5, I'd just call ToArray() and be done with it. If you only have a non-generic IEnumerable, do something like this: IEnumerable

How can I convert my device token (NSData) into an NSString?

匿名 (未验证) 提交于 2019-12-03 02:13:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am implementing push notifications. I'd like to save my APNS Token as a String. - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)newDeviceToken { NSString *tokenString = [NSString stringWithUTF8String:[newDeviceToken bytes]]; //[[NSString alloc]initWithData:newDeviceToken encoding:NSUTF8StringEncoding]; NSLog(@"%@", tokenString); NSLog(@"%@", newDeviceToken); } The first line of code prints null. the second prints the token. How can I get my newDeviceToken as an NSString? 回答1: use

How do I convert an integer to binary in JavaScript?

匿名 (未验证) 提交于 2019-12-03 02:13:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I’d like to see integers, positive or negative, in binary. Rather like this question , but for JavaScript. 回答1: This answer attempts to address integers with absolute values between Number.MAX_SAFE_INTEGER (or 2**53-1 ) and 2**31 . The current solutions only address signed integers within 32 bits, but this solution will output in 64-bit two's complement form using float64ToInt64Binary() : // IIFE to scope internal variables var float64ToInt64Binary = (function () { // create union var flt64 = new Float64Array(1) var uint16 = new Uint16Array

How can I convert a string from windows-1252 to utf-8 in Ruby?

匿名 (未验证) 提交于 2019-12-03 02:13:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm migrating some data from MS Access 2003 to MySQL 5.0 using Ruby 1.8.6 on Windows XP (writing a Rake task to do this). Turns out the Windows string data is encoded as windows-1252 and Rails and MySQL are both assuming utf-8 input so some of the characters, such as apostrophes, are getting mangled. They wind up as "a"s with an accent over them and stuff like that. Does anyone know of a tool, library, system, methodology, ritual, spell, or incantation to convert a windows-1252 string to utf-8? 回答1: For Ruby 1.8.6, it appears you can use

Convert hex to float

匿名 (未验证) 提交于 2019-12-03 02:13:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How to convert the following hex string to float (single precision 32-bit) in Python? "41973333" -> 1.88999996185302734375E1 "41995C29" -> 1.91700000762939453125E1 "470FC614" -> 3.6806078125E4 回答1: >>> import struct >>> struct.unpack('!f', '41973333'.decode('hex'))[0] 18.899999618530273 >>> struct.unpack('!f', '41995C29'.decode('hex'))[0] 19.170000076293945 >>> struct.unpack('!f', '470FC614'.decode('hex'))[0] 36806.078125 Update: see comment on how to do this in Python 3. 回答2: I recommend using the ctypes module which basically lets you work

Convert multidimensional objects to array

匿名 (未验证) 提交于 2019-12-03 02:13:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using amazon product advertising api. Values are returned as a multidimensional objects. It looks like this: object(AmazonProduct_Result)#222 (5) { ["_code":protected]=> int(200) ["_data":protected]=> string(16538) array(2) { ["IsValid"]=> string(4) "True" ["Items"]=> array(1) { [0]=> object(AmazonProduct_Item)#19 (1) { ["_values":protected]=> array(11) { ["ASIN"]=> string(10) "B005HNF01O" ["ParentASIN"]=> string(10) "B008RKEIZ8" ["DetailPageURL"]=> string(120) "http://rads.stackoverflow.com/amzn/click/B005HNF01O" ["ItemLinks"]=> array(7