convert

Convert date from milliseconds to ISODate object

匿名 (未验证) 提交于 2019-12-03 02:47:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to aggregate records in a MongoDB colloection by hour and need to convert date stored as timestamp (milliseconds) to ISODate so that I can use aggregate framework's built-in date operators ($hour, $month, etc.) Records are stored as { "data" : { "UserId" : "abc", "ProjId" : "xyz"}, "time" : NumberLong("1395140780706"), "_id" : ObjectId("532828ac338ed9c33aa8eca7") } I am trying to use an aggregate query of following type: db.events.aggregate( { $match : { "time" : { $gte : 1395186209804, $lte : 1395192902825 } } }, { $project : {

How do I convert an HttpRequest into an HttpRequestBase object?

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: My problem is the opposite of this: How do I convert an HttpRequestBase into an HttpRequest object? In my ASP.NET MVC application I have a method used by many controllers that receive an HttpRequestBase as argument. Now I have to call that method from another method, that is not an action (it's an nhibernate interceptor). In this second method I could access HttpContext.Current.Request, that is a HttpRequest and I cannot cast it to HttpRequestBase (I thought it was possibile due to the naming ...). Does someone know in what relationship are

Convert RDD to Dataframe in Spark/Scala

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: The RDD has been created in the format Array[Array[String]] and has the following values: Array[Array[String]] = Array(Array(4580056797, 0, 2015-07-29 10:38:42, 0, 1, 1), Array(4580056797, 0, 2015-07-29 10:38:42, 0, 1, 1), Array(4580056797, 0, 2015-07-29 10:38:42, 0, 1, 1), Array(4580057445, 0, 2015-07-29 10:40:37, 0, 1, 1), Array(4580057445, 0, 2015-07-29 10:40:37, 0, 1, 1)) I want to create a dataFrame with the schema : val schemaString = "callId oCallId callTime duration calltype swId" Next steps: scala> val rowRDD = rdd.map(p => Array(p

How to convert model data objects array to dataProvider

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Suppose I have model User which have many to many relation to itself named as friends . so $user->friends (or $model->friends in view) gives me an array of User objects. I wanted to display the friends as gridview. But CGridView data as dataProvider object. Googling for it found the way to convert array of model objects to dataProvider object as given below. $this->widget('zii.widgets.grid.CGridView', array( 'id' => 'gridUser', 'dataProvider' => new CArrayDataProvider($model->friends, array()), )); Now using this I get an error Property

Erlang ― How to convert a fun() object to a String

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is there a straightforward way to convert an Erlang fun to a string ? A call to io_lib:format only prints the function reference, e.g. something like "#Fun<erl_eval.20.67289768>" . For example, I'd like to be able to do this: 1> Fun = fun() -> atom_to_list('hello world') end. 2> FunStr = fun_to_str(Fun). "fun() -> atom_to_list('hello world') end." I'm looking for how to implement fun_to_str . In javascript, some interpreters have a .toSource() function that can be called on any object, including functions, that print their string

how to convert a cell to string in matlab

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Suppose I have a cell v = 'v' [576.5818] [3.0286] [576.9270] 'v' [576.5953] [3.1180] [576.8716] 'f' [ 56] [ 58] [ 52] 'f' [ 56] [ 58] [ 52] and I want to convert this to a cell array using a format string for each element: ' %.5f' How can I do this? I tried the following approach, but I get an error: f1 = @(x) sprintf(' %.5f',x); cellfun(f1, num2cell(v),'UniformOutput', false) I am getting an error as ??? Error using ==> sprintf Function is not defined for 'cell' inputs. Error in ==> @(x)sprintf(' %.5f',x) Can any one help me thanks in

How can I convert a string into a unicode character?

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In Javascript '\uXXXX' returns in a unicode character. But how can I get a unicode character when the XXXX part is a variable? For example: var input = '2122'; console.log('\\u' + input); // returns a string: "\u2122" console.log(new String('\\u' + input)); // returns a string: "\u2122" The only way I can think of to make it work, is to use eval ; yet I hope there's a better solution: 回答1: Use String.fromCharCode() like this: String.fromCharCode(parseInt(input,16)) . When you put a Unicode value in a string using \u , it is interpreted as a

How to convert a Vagrant box to a Docker image

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I saw that it's possible to convert a Docker image into a Vagrant box. Is there a way to convert a Vagrant box into a Docker image? 回答1: I replayed this with EC2 boxes and Virtualbox boxes in my Github project blacklabelops/centos . I have prepared a Vagrantfile with the necessary installation and you can try it yourself with your Vagrant boxes. EC2 boxes: Create and provision an AMI image with https://github.com/katzj/ami-creator - Skripts in my repository. Afterwards use Guestfish in order to extract the image into a tarball. - Skripts in

Convert base64 string to ArrayBuffer

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to convert a base64 encode string into an ArrayBuffer. The base64 strings are user input, they will be copy and pasted from an email, so they're not there when the page is loaded. I would like to do this in javascript without making an ajax call to the server if possible. I found those links interesting, but they didt'n help me: ArrayBuffer to base64 encoded string this is about the opposite conversion, from ArrayBuffer to base64, not the other way round http://jsperf.com/json-vs-base64/2 this looks good but i can't figure out how to

Convert 4 bytes char to int32 in C

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I first convert an int32 number to char[4] array, then convert the array back to int32 by (int *), but the number isn't the same as before: unsigned int num = 2130706432; unsigned int x; unsigned char a[4]; a[0] = (num>>24) & 0xFF; a[1] = (num>>16) & 0xFF; a[2] = (num>>8) & 0xFF; a[3] = num & 0xFF; x = *(int *)a; printf("%d\n", x); the output is 127. And if I set num = 127, the output is 2130706432. Does anyone have ideas? 回答1: Reverse the order of the a[] indexes, e.g,. a[0] -> a[3] I think you have the endianness in reverse. Try this: a[3]