Saturday, 15 January 2011

Rails console/pry shows ActiveRecord has_many/belongs_to references in invalid state? -


मेरे पास दो मॉडलों में एक काफी सरल है I_many / belongs_to संबंध:

  class उपयोगकर्ता & lt ; ActiveRecord :: बेस है has_many: प्राधिकरण, आश्रित:: नष्ट ... अंत वर्ग प्राधिकरण & lt; ActiveRecord :: बेस is_to: user ... end  

... सभी अच्छा।

लेकिन जब मेरे पास मौजूदा प्राधिकरण वाले उपयोगकर्ता हैं, और रेल का उपयोग कंसोल (ध्यान दें कि मैं वास्तव में एक pry मणि का उपयोग कर रहा हूं - क्या यह प्राइ-संबंधी हो सकता है?) किसी अन्य प्राधिकरण को कुछ अन्य प्राधिकरणों को फिर से असाइन करने के लिए, जैसे:

<पूर्व> & gt; Some_auth = user_b.authorizations.first & gt; User_a & lt; & lt; Some_auth & gt; Some_auth.user = user_a & gt; Some_auth.save

... तो मुझे स्वामित्व के अजीब विरोधाभासी राज्य मिलते हैं:

  & gt; User_b.authorizations.count = & gt; 0 & gt; User_b.authorizations.first = & gt; # & Lt; प्राधिकरण आईडी: 7, यूज़र_आईडी: 9, ... & gt; & Gt; User_b.authorizations.first.user_id = & gt; 9 & gt; User_a.authorizations.first.user = & gt; # & Lt; उपयोगकर्ता आईडी: 7, ... & gt;  

पूरी तरह से अजीब, सही?

अब, मुझे लगता है कि मुझे दोनों करने की ज़रूरत नहीं है

  & gt; User_a & lt; & lt; Some_auth  

और

  & gt; Some_auth.user = user_a  

... लेकिन मैं उस रिडंडेंसी से इस व्यवहार की अपेक्षा नहीं करूँगा!

क्या कोई मेरी मदद कर सकता है यह समझने में कि क्या गलत हो रहा है? < / P>

ध्यान दें कि जब मैंने रेल को कंसोल छोड़ दिया और इसे फिर से शुरू किया, तो समस्या दूर जा रही है ...

अपने केस को हल करने के लिए आप अपने प्राधिकरण वर्ग के साथ : inverse_of विकल्प का उपयोग करना चाह सकते हैं। यह जैसा_आ: प्रयोक्ता, व्युत्क्रम_ऑफः: प्राधिकरण की तरह दिखेगा - और फिर यह काम करेगा जैसे आप इसे करने की अपेक्षा करते हैं।

आप "सेटिंग व्युत्क्रम" खंड में और अधिक पढ़ सकते हैं।


rest - Determine the number of records in a saleforce table without knowing the table's field names -


I'm using the Salesforce REST API to determine the number of records in each Salesforce table, ideally I The table will be able to do a query like this:

  SELECT COUNT (*) FROM & lt; Variable_table_name & gt; - or - SELECT COUNT () FROM & lt; Variable_table_name & gt;  

Unfortunately, SOQL does not support * select all without any code running COUNT () Either it does not work either.

My last resort is a two step process:

  1. Use the SOBJX field to get the name of the resource
  2. with that field name < Code> COUNT

This means that I would not like to do this for two tablets instead of just one of two network calls.

To use it, COUNT () thanks Salman without any fields The problem for me was that the web response to COUNT (Id) is different from the web response to COUNT () .

WebResponse content

  {"totalize": 1, "done": true, "records": [{"attributes": {"type" : "Aggregate result"}, "exprode": 260}]  

COUNT web content

 {"totalSize ": 260," done ": true," records ": []}  

When using COUNT () , I should Records.expr0 to see property instead of totalSize


Interactive website for linux server -


Creating a website through which Linux server may be used and where some actions can execute scripts such as some Commandments need some expert guidance with some concepts. Let me guide how I can get it, I have gained many inability to achieve the right concepts or methods. Or is it even possible.

Did you experiment with lines like anything else? As JNWil pointed out, any of these methods would be infinitely more secure. Also, consider using things like Cron for scheduled jobs.

However, sometimes a webpage can be acceptable to run programs on a server such as the IOT project to do this, you will install an API page using the back-end language such as PHP ( Recommended if you are using Linux). In the back-end language you will check your user credentials and then run the command.

Some guidelines to do this:

  1. Never allow commands to complete the task by using controlled inputs like webpages, buttons only, selection boxes and sliders That is to say, a button to get an Ardino to close the gallery, or a slider to light a light bulb to a gallery, or to start a program for some index.
  2. None of these "command buttons" should do anything harmful either delete a folder or file.

regex - Perforce commands Regular Expressions -


मेरे पास कमांड एक्जीक्यूशन की लाइनें निम्नानुसार हैं:

  2806 I deep Sd_bordeaux 117: 02: 40 IDLE कोई नहीं 2807 मैं गहरी sd_bordeaux 17:02:40 आईडीले कोई नहीं 2808 मैं गहरी sd_coddeaux 117: 02: 40 IDLE सभी 2809 मैं rahul sd_coddeaux 117: 02: 40 IDLE सभी  
< P> मैंने कमांड को चलाने के लिए कमांड को चलाने के लिए कमांड को चलाने के लिए लिखा है और उसे सरणी @ लाइनों में संग्रहित करने और निर्दिष्ट परिस्थितियों को प्राप्त करने के लिए regex का उपयोग करना है। लेकिन मुझे वांछित परिणाम नहीं मिल रहा है

<पूर्व> मेरी $ command = qx | p4 मॉनिटर शो -अल | | मेरी $ kill_id; मेरे @lines = विभाजन ("\ n", $ आदेश); मेरी $ पंक्ति (@lines) के लिए {अगले अगर नहीं $ लाइन = ~ / (\ d +) \ s + /; मेरी $ आईडी = $ 1; अगर ($ line = ~ / sd_bordeaux \ s + (\ d +): \ d +: \ d + \ s + / और $ पंक्ति = ~ / आईडीएल \ s + none $ /) {my $ hours = $ 1; प्रिंट "$ घंटे"; प्रिंट "\ n"; }

}

मुझे कोई त्रुटि मिल रही है

  आरंभिक मान का उपयोग $ घंटे की स्ट्रिंग में ./p4.pl < / कोड>  

मुझे "2806" और "2807" संख्या $ आईडी के रूप में प्राप्त करने में दिलचस्पी है और पहले अंक "117" & amp; "17" के रूप में $ घंटे।

कृपया कुछ मदद कर सकते हैं जहां मैं गलत हो रहा हूं। धन्यवाद।

$ 1 इसमें सबसे हाल ही में सफल होने वाले पहले कब्जा से मिलान किया गया था Regex match।

जब आप त्रुटि प्राप्त करते हैं, तो सबसे हाल ही में सफल मिलान / IDLE \ s + none $ / के खिलाफ था, जिसमें कोई कैप्चर नहीं है।

निम्नलिखित समतुल्य होगा:

  यदि ($ line = ~ / sd_bordeaux \ s + (\ d +): \ d +: \ d + \ s + /) {my $ hours = $ 1; अगर ($ पंक्ति = ~ / आईडीईई \ s + कोई भी $ /) {प्रिंट "$ घंटे \ n"; }}  

लेकिन ऐसा लगता है कि आपको निम्न की आवश्यकता है:

  यदि ($ line = ~ / sd_bordeaux \ s + (\ d +): \ D +: \ d + \ s + IDLE \ s + कोई भी $ /) {my $ hours = $ 1; प्रिंट "$ घंटे \ n"; }  

यह समस्या बताता है और इसे कैसे हल किया जाए, लेकिन गैरी एक अधिक पढ़ें।


Alternative methods for coverting formulas to values in Excel using VBA -


I first want to make a process to pull data from Bloomberg and want to change all the sources based on their values. So far, I have come up with two approaches 1. Use BDH code to draw data first for the range of cells, and then paste all the data as values ​​after populated. 2. Use the BDH code to drag the data and paste the code as a value immediately before executing the next cell. The following is my code (I use another approach):

j = last - time = 6 for time active =. For kel (j, 1) i = 3, Colonel C ticker = ActiveSheat.Cell (2, I). Value ActiveSite Seals (J, I). Formula = "= BDH (" "" and "" ticker and "", "" last "", "" "" & Amp;; & amp; time and; "", "" and time and " "" Day = a "," "fill = p" ")" application Waiting (Now + Time Vila ("00:00: 03")) ActiveSheet.Cells (j, i) .Value = ActiveSheet.Cells (j, i) .Value Next Next

When I run this code on Bloomberg, paste the chip as T and they are still the code I think 3 seconds in the application. The wait is not enough, but I want to change my whole method and do not want to count how many seconds one price has to be populated. Does anyone have experience with this and can provide a fast way to populate prices from Bloomberg? Although the first approach I mentioned above is also an option, but I like to get the values ​​while popularizing the data. Thanks!

I actually came up with an answer to my problem .. but it still uses onetime There are other ways to make sure that

  for sub pulldata () = Jammu = last - for 6 time = ActiveSheet.Cells (j, 1) for i = 3 Lastcol 'starts with the Colonel C ticker = ActiveSheet.Cells (2, i) .Value ActiveSheet.Cells (j, i). Formula = "= BDH (" "" & "", "" Last_Price "", "" "and time and" "" "" and time and "", "" day = one "," P "") "Start a new sub time to eliminate the last macro all pestespicious () from time to time + timevilla (" 00: 00:03 ")," pastestyle "next next end sub. Intecol finalcol = ActiveSheet.Cells (1, ActiveSheet.Columns.Count) .end (xlToLeft) .color set myrange = category (ActiveSheet.Cells (final - 6, 3), ActiveSheet.Cells (last, lastcol)). My Category Values ​​= Diamonds Value End Sub  

html - max-width css property stops centered div from working in internet explorer? -


I have a navbar div inside a parent that is horizontally centered / re-shaped using the following CSS Giving:

 . Navbar- Basic-Cover {width: 100%; Margin: 0 auto; } .navbar-child-wrapper {Status: Completed; Correct: 0; Left: 0; Margins: Auto; Max-width: 1200px; Cushion Top: 10px; }  

Although the maximum-width property being centered in Internet Explorer appears to stop my navbar and floats it on the left (works on all other browsers). If I change the max-width to width, it works, but stops automatically resizing to be responsive.

Is there any work for this?

try it

  .navbar-child-wrapper {status: Relative; Margin: 0 auto; Max-width: 1200px; Cushion Top: 10px; }  

powershell - Handle output that can either be an array or a single string -


I have a script that receives data from the web service in XML format. Some elements can be there - or not - and it may contain one or more sub elements, so I get the value with it:

$ uid = $ changeRecord.newAttrs | Where {$ _. Name-EC 'UID'} | Choose - Expand Property Value | Selection Index 0

This works fine in most of the answer There is only one sub element in the part and even if not, then I am only interested in the first one, however, the last part | Select -index 0 generates silent warnings in the Windows Event Log (see also) if & lt; Values ​​& gt; Within there is only one element so I would like to get rid of the error.

That's why I'm looking for errors to get the same behavior without any errors - and possibly not just try- hold around.

Thank you!

// Update: As mentioned below, so far the answers do not solve the problem. So far the closest is

  ([array] ($ changeRecord.newAttrs | where {$ _ .name-eq 'uid'} | Select- ExpandPrafficity Value)) [0]  

This fails with any errors if there is no element in the array. With any thought it can be controlled even within a line?

Have you tried this: choose-object-first 1 ?

  $ uid = $ changeRecord.newAttrs | Where-object {$ _. Name-EC 'UID'} | Selection-object-ExpandProfility Value | Choose-Object-First 1