Tuesday, 15 January 2013

ruby on rails - Active Admin and instantiating a new object -


I have two tables: events and images

  Events: date name of id name Images: event file captions event_id  

There are several images in an event and an image is related to an event.

My ultimate goal is to upload multiple images simultaneously in the active admin. I have read many other posts suggesting that I do the following:

  class event & Lt; ActiveRecord :: Base has_many: Accepts images: _nested_attributes_for: images mount_uploader: file, avatar tooler end class image & lt; ActiveRecord :: Base is_to: event mount_uploader: File AvatarUploader end  

Then, in my admin / event.rb, I have the following:

  Form Do | F | F.inputs "Event Details" f.input: name f.input: location f.input: date f.has_many: images do | P | P.input: file, as in: = & gt; : File, for: = & gt; [Image. Uncredited] End of End f.actions  

I am able to get visually many image upload fields, the problem is that when I save, the picture is not actually saved Are there. I believe this is because I am not creating any new image on file upload (image.) Is there any way to do this in active admin?

thanks


vb.net - All elements of an array cannot be accessed from a for loop in monthCalendar Control - Visual Basic -


I have an issue here with Month Calendar Controller in Visual Basic. I have a calendar and text box in what is happening in the program. The user selects a date on the calendar, then in the component of the lessons presses the type of information, then the add button. From there, the add button sets a parallel array where the string added from the selected date and text box is a way to add planner information for each date. Then every time such an increase has increased, the date has been bolded for this.

From there, you understand that to click on each bold date and see the information you added. This issue only works on the previous date. For some reason this only reads the last element added in the array. I have a loop below, I do not understand why I can not choose any bold date and add text. I have the option tough so I know that there is no data loss. I also know that the date is being selected and every time when a date is selected on the calendar, the string is placed in it because I am displaying it on the label every time what is the problem. Is this a logical error that I am not holding or is it something else?

  The Public Sub Month Calendar Calendar for 1DateChanged Integer = 0 for 1_DateChanged (As System. Sender, System as E-mail and System.AventRG) Index for Index IntSizeOf Selected Date - 1 strSelectedDay = CStr (Month Calendar Calendar Select Start.) 'Keep the selected date in a string lblError.Text = strSelectedDay lblError.Visible = True Dim strAryDate string = ary as selected date (index) ArySelectedDates (index) = StrSelectedDay) then lblInstruc Tions.Text = strSelectedDay lbl Date selected. Text = aryTextForDates (index) index = intSizeOf selected selected array - 1 end if the next end sub  


windows phone 8 - How To add file to <Assets> folder on WP8 or WP8.1 -


I want to add that file to the folder, after that I added that file, I add that file to the Assets folder In the attempted solution, but unsuccessful, it shows an error box:

  The desired name of "D: \ ....." is invalid  
< P> However I can not add it to the resolved folder.

Do I have to add some stuff to * .xaml first? What is the correct way to add a file to that WP pack it in the last app?

Thank you.

In Solution Explorer, right-click on the Asset folder and select Add.Existing item ... menu option Please. Find the file you want to add and it will be copied to the Assets folder in the solution.

To ensure that it is packed with the app, select the properties of the item in the Solution Explorer and make sure the build action is "content". This will be the default for the common C beginners type (.png, .jpg, etc.) but you have to set it explicitly for other content types.

If you do not want to add a blinded file, you can edit it directly, create a project file or a mapping file and package itself to make the file itself with the Visual Studio instead of the package with the MixPack .


How to unit test pseudo elements? -


I have been told from unit testing that CSS has been implemented properly on my element

However CSS refers to these pseudo elements and as far as I know that they are not part of DOM, there is no access to Javascript and therefore I can not test them.

If this was a system test - I could do a CSS regression test with resemblejs, though I need a unit test implementation

How can I apply it with karma? Am + jasmine + angular combo?

David Walsh is a very good answer for this use

Window.getComputedStyle (domElement, ': first') .getPropertyValue (propertyName);


c# - Need to Include() related entities but no option to do so -


I'm not sure how the title of this question will be, let me explain. I need to select a unit type from my database. It is used to select related institutions, but at the same time select the entities where the unit identifier is equal to one of the IDs in the string array.

My code is as follows:

  list & lt; TSR category & gt; Optional = new list & lt; TSRcategory & gt; (); Foreach (var i.elelectives in client.plit ('& amp;')) {int id = int32.Parse (i); Electives.Add (db.TSRCategories.Find (ID)); }  

This selects TSRCategories properly, which are part of the elective list of ID but does not include related entities. I was using this code:

TSR cognition = dbtrs Categories Include ("Capabilities Capabilities Skills"). ToList ();

But it does not select the selected electives only. What I'm ideally looking for is something like this:

  list & lt; TSRcategory & gt; Optional = new list & lt; TSRcategory & gt; (); Foreach (var i.elelectives in client.plit ('& amp;')) {int id = int32.Parse (i); Electives.Add (db.TSRCategories.Find (ID)); } TSRCategories = Electives. Include ("Competencies.CompetencySkills"). ToList ();  

But of course it can not be done for any reason (I really do not know why this can not be done online in case of searching!). Electives is a string that contains & amp; Separating the IDs in the form of delimiters involves competencies in the category of TSR, including competing skills. Is there really a way to do it effectively and in some lines?

You will find that the affiliate ID will result in a bad query display after a second You can get them once presenting the list (I have assumed the key name here: ElectiveId ):

  var selectiveIds = Client.Electives.Split ('& Amp; ') Select (i = & gt; Int32.Parse (i)) .oire (); Var optional = db.TSRCategories. Include (T = & gt; T. Competition. Select (C = & gt; C. Compensation Skills)). Where (SSR => electives: canteen (SSR.acciliid). Ollist ();  

But one thing to mention is that your id is associated with a delimiter in a string field that is a violation of database normalization instead, instead of using a new junction Create a table, e.g. ClientElectitions , which is a generalized fashion with optional clients associated with a client (ClientId, Elective ID) . It will also simplify your EF recovery code.

Edit

According to the examples, I should use . Select for depth specification of curious loading (no . Many selects or other extension methods).


cryptography - Why does the security of RSA depend on the non-factorability of the modulus n? -


Just wondering why RSA's security depends on the non-causality of the modulus?

Cheers!

Good ... The non-causality of the modulus n is not the whole story ..

As vlad has already told, if you know the factors of n, you can easily calculate personal exponent ...

(p-1) (Q-1) .. or in general ... If you know the main factor of p number [i], then you can calculate the product of all (pi [ii] - 1). Which is the PHI function ajar ... to know the number of mutual qualitative elements, nn

If you can factor to n, then this calculation becomes trivial. Yes ... if n consists only 2 large prime, and this coefficient is hard, it is not really trivial ...

However ... if you calculate PHI (N) Come up with any other idea ... the number of elements, which is a qualitative reciprocity ... the factorization wou Ld is probably not your problem anymore ...

Currently there are no other public There is no known method, such as the method of eels ... prod (p [i] - 1)

either PHI (n) To find a way to classify, or calculate in a different way, possibly going to be RSA breaker


c# - How to add 2 value of dictionary inside a list of an object -


मेरे पास एक ऐसा वर्ग है:

  वर्ग आइटम {सार्वजनिक इन्ट आईडी}; सेट; } सार्वजनिक शब्दकोश & lt; स्ट्रिंग, इंट & gt; डेटा {प्राप्त; सेट; }}  

और मेरे पास 2 लिस्ट में उस श्रेणी के ऑब्जेक्ट शामिल हैं:

  आइटम obj1 = new item (); Obj1.Id = 1; Obj1.Data = नया शब्दकोश & lt; स्ट्रिंग, int & gt; (); Obj1.Data.Add ("1", 11); Obj1.Data.Add ("2", 12); Obj1.Data.Add ("3", 13); आइटम obj2 = नया आइटम (); Obj2.Id = 2; Obj2.Data = नया शब्दकोश & lt; स्ट्रिंग, int & gt; (); Obj2.Data.Add ("1", 21); Obj2.Data.Add ("2", 22); Obj2.Data.Add ("3", 23); आइटम obj3 = नया आइटम (); Obj3.Id = 3; Obj3.Data = नया शब्दकोश & lt; स्ट्रिंग, int & gt; (); Obj3.डेटा। जोड़ें ("1", 31); Obj3.Data.Add ("2", 32); Obj3.डेटा। जोड़ें ("3", 33); आइटम obj4 = नया आइटम (); Obj4.Id = 1; Obj4.Data = नया शब्दकोश & lt; स्ट्रिंग, int & gt; (); Obj4.Data.Add ("1", 41); Obj4.Data.Add ("2", 42); Obj4.Data.Add ("3", 43); आइटम obj5 = नया आइटम (); Obj5.Id = 2; Obj5.Data = नया शब्दकोश & lt; स्ट्रिंग, int & gt; (); Obj5.Data.Add ("1", 51); Obj5.डेटा। जोड़ें ("2", 52); Obj5.Data.Add ("3", 53); आइटम obj6 = नया आइटम (); Obj6.Id = 3; Obj6.Data = नया शब्दकोश & lt; स्ट्रिंग, int & gt; (); Obj6.Data.Add ("1", 61); Obj6.Data.Add ("2", 62); Obj6.Data.Add ("3", 63); सूची के & lt; आइटम & gt; Lst1 = नई सूची & lt; आइटम & gt; (); lst1.Add (obj1); lst1.Add (obj2); lst1.Add (obj3); सूची के & lt; आइटम & gt; Lst2 = नई सूची & lt; item & gt; (); lst2.Add (obj4); lst2.Add (obj5); lst2.Add (obj6);  

अब मैं वस्तु के आईडी और शब्दकोश कुंजी के आधार पर शब्दकोश के मूल्य को जोड़ना चाहता हूँ। परिणाम इस तरह होगा:

  सूची & lt; आइटम & gt; परिणाम = नई सूची & lt; आइटम & gt; (); परिणाम [0] .आईडी = 1 का परिणाम [0] .डेटा ["1"] = 52 // obj1.डेटा [1] + obj4.Data [1] परिणाम [0] .डेटा ["2"] = 54 / / Obj1.Data [2] + obj4.Data [2] परिणाम [0] .डेटा ["3"] = 56 / obj1.डेटा [3] + obj4.Data [3] परिणाम [1] .Id = 2 परिणाम [1] .डेटा ["1"] = 72 / obj2.डेटा [1] + obj5.डेटा [1] परिणाम [1] .डेटा ["2"] = 74 / obj2.डेटा [2] + Obj5.Data [2] परिणाम [1] .डेटा ["3"] = 76 / obj2। डेटा [3] + obj5.डेटा [3] परिणाम [2] .आईडी = 3 परिणाम [2] .डेटा [" 1 "] = 92 / obj3.Data [1] + obj6.Data [1] परिणाम [2] .डेटा [" 2 "] = 94 / obj3.डेटा [2] + obj6.डेटा [2] परिणाम [ 2] .डेटा ["3"] = 96 / obj3.डेटा [3] + obj6.Data [3]  

यह परिणाम प्राप्त करने का सबसे अच्छा तरीका क्या है?

धन्यवाद

सबसे पहले, आप एक उदाहरण के रूप में दिखाया गया आउटपुट गलत है। उदाहरण के लिए, obj3.Data [1] + obj6.Data [1] बराबर 92 , 56 नहीं।

तो, यह यहां के साथ है LINQ के सभी सौंदर्य:

  var परिणाम = lst1.जोइंड (lst2, x = & gt; x.Id, y = & gt; y.Id, (x) , Y) = & gt; नया आइटम {आईडी = x.Id, डेटा = x.डेटा .जोइंड (y.Data, a = & gt; a.Key, b = & gt; बी.केए, (ए, बी) = & gt ; New {a.key, value = a.value + b.value})। ToDictionary (r = & gt; r.key, t = & gt; t.value}})। ToList ();  

आप चाहते हैं, परिणाम यह है:

  परिणाम [0] .आईडी = 1 परिणाम [0] .डेटा ["1"] = 52 // obj1.Data [1] + obj4.Data [1] परिणाम [0] .डेटा ["2"] = 54 / obj1.डेटा [2] + obj4.Data [2] परिणाम [0] .डेटा [ "3"] = 56 / obj1.Data [3] + obj4.Data [3] परिणाम [1] .आईडी = 2 परिणाम [1] .डेटा ["1"] = 72 / obj2.डेटा [1] + Obj5.Data [1] परिणाम [1] .डेटा ["2"] = 74 / obj2.डेटा [2] + obj5.डेटा [2] परिणाम [1] .डेटा ["3"] = 76 // Obj2.Data [3] + obj5.Data [3] परिणाम [2] .Id = 3 परिणाम [2] .डेटा ["1"] = 92 / obj3.डेटा [1] + obj6.डेटा [1] परिणाम [2] .डेटा ["2"] = 94 / obj3.डेटा [2] + obj6.डेटा [2] परिणाम [2] .डेटा ["3"] = 96 / obj3.डेटा [3] + obj6 .डेटा [3]