pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
18,164,838
0
<p>How about this?</p> <pre><code>&gt;&gt;&gt; re.sub('(\d+)', 'sub\g&lt;1&gt;', "C7H19N3") 'Csub7Hsub19Nsub3' </code></pre> <p><code>(\d+)</code> is a <a href="http://www.regular-expressions.info/brackets.html" rel="nofollow">capturing group</a> that matches 1 or more digits. <code>\g&lt;1&gt;</code> is a way of referring to the saved group in the substitute string.</p>
2,452,744
1
Encrypting XML database in python <p>i am using XML as my backend for the application...</p> <p>LXML is used to parse the xml.</p> <p>How can i encrypt this xml file to make sure that the data is protected......</p> <p>thanks in advance.</p>
29,329,306
0
JS HTML5 Validate on "display:none" required input elements <p>I have a form which is a multi-div meaning: I fill some fields, then I click next and current div gets to display css proprerty set as "none".</p> <p>All the fields in this form are required, below is a snippet of the situation:</p> <pre><code>&lt;form action="" method="post"&gt; &lt;div id="div1" style="display:none"&gt; &lt;input name="input1" type"text" required /&gt; &lt;input name="input2" type"text" required /&gt; &lt;/div&gt; &lt;div id="div2" style="display:block"&gt; &lt;input name="input3" type"text" required /&gt; &lt;input name="input4" type"text" required /&gt; &lt;input type"submit" value="submit" /&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>Now the problem is that, when I submit the form, if one field of the first div is not filled up, it won't submit and Chrome gives me the following error in the Console</p> <pre><code>An invalid form control with name='input1' is not focusable. </code></pre> <p>I would like to know how can I solve this situation.I've thought about catching the error and then showing the first div, but i haven't figured out how to do it.</p> <p>Thank you</p>
731,213
0
<p>You are coupling classes too tightly and mixing values and references. You should either consider checking reference equality for one of the classes or make them aware of each other (by providing an <code>internal</code> specialized <code>Equals</code> method for the specific class or manually checking value equality of the other class). This shouldn't be a big deal since your requirements explicitly ask for this coupling so you are not introducing one by doing this.</p>
38,995,235
0
<p>solved with this plugin: <a href="https://datatables.net/examples/api/multi_filter.html" rel="nofollow">https://datatables.net/examples/api/multi_filter.html</a> Thanks everybody</p>
15,543,478
0
<p>not that slow but will show you folders size: du -sh /* > total.size.files.txt</p>
11,939,073
0
<p>Does query like this work for you <code>q=id:(id1 OR id2 OR id3) OR id:yy*</code><br> You can use <code>id:(id1 OR id2 OR id3)</code> to search for ids in the id field and <code>id:yy*</code> for the prefix query to check for ids starting with yy</p>
32,878,450
0
node.js - infinite loop during JSONStream <p>I've got a node.js server that is freezing in production, and it appears to be caused by an infinite loop inside of JSONStream. Here's a stack trace captured from a core dump from a frozen server:</p> <pre><code>1: toString [buffer.js:~392] (this=0x1e28fb6d25c9 &lt;a Buffer&gt;#1#,encoding=0x266ee104121 &lt;undefined&gt;,start=0x266ee104121 &lt;undefined&gt;,end=0x266ee104121 &lt;undefined&gt;) 2: arguments adaptor frame: 0-&gt;3 3: write [/home/deploy/node_modules/JSONStream/node_modules/jsonparse/jsonparse.js:136] (this=0x32cc8dd5a999 &lt;a Parser&gt;#2#,buffer=0x32cc8dd5aa49 &lt;a Buffer&gt;#3#) 4: /* anonymous */ [/home/deploy/node_modules/JSONStream/index.js:~17] (this=0x32cc8dd5ab11 &lt;a Stream&gt;#4#,chunk=0x32cc8dd5aa49 &lt;a Buffer&gt;#3#) 5: write [/home/deploy/node_modules/JSONStream/node_modules/through/index.js:~24] (this=0x32cc8dd5ab11 &lt;a Stream&gt;#4#,data=0x32cc8dd5aa49 &lt;a Buffer&gt;#3#) 6: write [_stream_readable.js:~582] (this=0x266ee106c91 &lt;JS Global Object&gt;#5#,dest=0x32cc8dd5ab11 &lt;a Stream&gt;#4#,i=0,list=0x266ee104101 &lt;null&gt;) 7: flow [_stream_readable.js:592] (this=0x266ee106c91 &lt;JS Global Object&gt;#5#,src=0x32cc8dd5ac69 &lt;an IncomingMessage&gt;#6#) 8: /* anonymous */ [_stream_readable.js:560] (this=0x266ee106c91 &lt;JS Global Object&gt;#5#) 9: _tickCallback [node.js:415] (this=0x29e7331bb2a1 &lt;a process&gt;#7#) </code></pre> <p>How can I find the source of this infinite loop?</p> <p>Unfortunately the servers are running in production and are processing many thousands of requests, so it's difficult to give any additional context. The basic function of the servers is to make outbound HTTP requests for other services.</p> <p>It's worth noting that I don't believe this is caused by a memory leak. The server's memory usage remains constant (and low) during these freeze events, while the CPU spikes to 99%</p> <p>Another piece of evidence towards the conclusion of an infinite loop is that the event loop itself seems to have stopped. When I put a console.log inside of a setInterval, the server will stop outputting as soon as it freezes.</p> <p>We have verified that the problem is not caused by expired/corrupted socket connections, by setting the number of max connections to Infinity (which disables their reuse in node.js)</p> <p>We're using JSONStream 0.7.1 (which includes a default jsonparse version of 0.0.5). We found <a href="https://github.com/creationix/jsonparse/pull/22" rel="nofollow">this issue</a> on the JSONStream repo, and tried forking JSONParse and only updating to the newest jsonparse version. It did NOT fix the issue.</p>
29,430,890
0
<p>IMHO there are three reasonable scenarios for <code>Optional</code>:</p> <ul> <li>Do something if there is a value</li> <li>Provide a default value otherwise</li> <li>The absence of a value is an error condition, in which case you want to fail fast</li> </ul> <p>Your scenario falls into the last category so I would simply write:</p> <pre><code> MyDao oq = myOptional.orElseThrow(() -&gt; new RuntimeException("Entity was not found"); if(!oq.getReferenceId().equals(objToUpdate.getId())) throw new RuntimeException("Bad Move!"); oq.setAttribute(objToUpdate.getAttribute()); </code></pre> <p>Of course, it's appealing to use methods like <code>ifPresent</code>, <code>filter</code> or <code>map</code>, but in your case, why would you want to continue when the application is in a faulty state. Now if you wouldn't throw an exception if the entity wasn't found, then the situation would be different.</p> <p>Something like <code>oq.checkMove(objToUpdate.getId())</code> could make sense. That would eliminate the <code>if</code> and make the code more expressive.</p>
39,571,267
0
<p>If the lines are selected by line numbers which follow a consistent pattern, use <a href="https://docs.python.org/3.6/library/itertools.html#itertools.islice" rel="nofollow"><code>itertools.islice</code></a>.</p> <p>E.g. To select every second line from line 3 up to but not including line 10:</p> <pre><code>import itertools with open('my_file.txt') as f: for line in itertools.islice(f, 3, 10, 2): print(line) </code></pre>
12,917,515
0
page redirecting <p>Based on certain condition in my controller, I want to direct the user to an error page, which I am doing now. </p> <p>when error page is displayed to user, I want the user to be then redirected to a specific retry page. </p> <p>Is this the right way to do it using:</p> <pre><code>&lt;meta http-equiv="refresh" content="3; url=http://www.somewhere.com/" /&gt; </code></pre> <p>or should i use javascript to do the redirect based on timer?</p> <p>To get the right url I could put the url in flash scope and read them and place in above string</p>
804,328
0
<p>I think what you're looking for is the "many-to-one" element. (This goes inside your class element for SupportTicket)</p> <pre><code>&lt;many-to-one name="SupportTicketCategory" column="SupportTicketCategoryId" update="false" insert="false" /&gt; </code></pre>
33,339,482
0
<p>You can implement Model-View-Controller pattern in ASP.NET Webforms applications.</p> <p>Following are the MSDN links for your reference:</p> <p>1) <a href="https://msdn.microsoft.com/en-us/library/ff649643.aspx" rel="nofollow">Model-View-Controller</a></p> <p>2) <a href="https://msdn.microsoft.com/en-us/library/ff647462.aspx" rel="nofollow">Implementing Model-View-Controller in ASP.NET</a></p> <p><a href="http://stackoverflow.com/questions/9119657/how-do-gang-of-four-design-patterns-fit-into-the-mvc-paradigm">This SO</a> provide some variations to consider.</p>
24,159,098
0
Feature Construction for Text Classification using Autoencoders <p>Autoencoders can be used to reduce dimensionallity in feature vectors - as far as I understand. In text classification a feature vector is normally constructed via a dictionary - which tends to be extremely large. I have no experience in using autoencoders, so my questions are:</p> <ol> <li>Could autoencoders be used to reduce dimensionallity in text classification? (Why? / Why not?)</li> <li>Has anyone already done this? A source would be nice, if so.</li> </ol>
28,568,162
0
<p>I think this is not working because the columns returned by both select must have the same names, so please try this</p> <pre><code>SELECT "dba"."Room"."ID" ID, "dba"."Room"."RoomNumName" RoomNumName from "dba"."Room" WHERE DeptID = 8225 EXCEPT SELECT "dba"."vwResultInspection_iDashboards"."roomID" ID, "dba"."vwResultInspection_iDashboards"."RoomNumName" RoomNumName FROM "dba"."vwResultInspection_iDashboards" where "dba"."vwResultInspection_iDashboards"."ClosedDate" &gt; '2015-01-01' AND "dba"."vwResultInspection_iDashboards"."ClosedDate" &lt; '2015-01-31 23:59:59.000' and DEPTID = 8225 </code></pre>
2,251,602
0
LINQ Stored Procedure DATETIME NULL <p>I got this errormessage when I use Linq and and stored procedure as follow. I got this message when the DateTime parameter is NULL. How will I do to solve this?</p> <p>Errormessage Serverfel i tillämpningsprogrammet. SqlDateTime-spill: Det måste vara mellan 1/1/1753 12:00:00 AM och 12/31/9999 11:59:59 PM. </p> <p>Codeblock in C#</p> <pre><code>protected void ButtonSearch_Click(object sender, EventArgs e) { Postit p = new Postit(); DateTime? dt; if(TextBoxDate.Text=="") { dt=null; } else { dt=System.Convert.ToDateTime(TextBoxDate.Text); } GridView1.DataSource = p.SearchPostit(TextBoxMessage.Text, TextBoxWriter.Text, TextBoxMailto.Text, System.Convert.ToDateTime(dt)); GridView1.DataBind(); } public ISingleResult&lt;Entities.SearchPostitResult&gt; SearchPostit([Parameter (DbType="VarChar(1000)")] string message, [Parameter(DbType="VarChar(50)")] string writer, [Parameter(DbType="VarChar(100)")] string mailto, [Parameter(DbType="DateTime")] System.Nullable&lt;System.DateTime&gt; date) { IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), message, writer, mailto, date); return ((ISingleResult&lt;Entities.SearchPostitResult&gt;)(result.ReturnValue)); Procedure ALTER PROCEDURE [dbo].[SearchPostit] ( @message varchar(1000)='', @writer varchar(50)='', @mailto varchar(100)='', @date Datetime=null ) AS SELECT P.Message AS Postit, P.Mailto AS 'Mailad till', P.[Date] AS Datum , U.UserName AS Användare FROM PostIt P INNER JOIN [User] U ON P.UserId=U.UserId WHERE P.message LIKE '%'+@message+'%' AND P.Mailto LIKE '%'+@mailto+'%' AND ( @date IS NULL OR P.Date = @date ) AND U.UserName LIKE '%'+@writer+'%' GROUP BY P.Message, P.Mailto, P.[Date], U.UserName } </code></pre>
10,388,532
0
<p>Well, I know this post is antique, but here's my 2 cents:</p> <p>I don't think this:</p> <pre><code>if(!$this-&gt;descriptions-&gt;insert($new_description)) </code></pre> <p>will work, cause the insert function from CI active record always returns TRUE (succeeding or not). If you are using debug mode, CI will stop on error and throw a screen message to the user, but insert function will still returns TRUE.</p> <p>So, if you're willing to control transactions "manualy" with CI, you'll have to use something like this:</p> <pre><code>... $this-&gt;db-&gt;trans_begin(); $this-&gt;db-&gt;insert('FOO'); if ($this-&gt;db-&gt;trans_status() === FALSE){ $this-&gt;db-&gt;trans_rollback(); }else{ $this-&gt;db-&gt;trans_commit(); } </code></pre> <p>Hope this helps someone...sometime....somewhere</p>
27,074,899
0
Upgrade Oracle 10g to its higher version <p>I need to upgrade Oracle 10.1.0 to its higher version 10.1.0.3 Is there any patch file to do this upgradation other than the fresh installation of the higher version?</p>
32,149,368
0
Grails "Unparseable Date" Error <p>I've seen some Unparseable Date errors on here before, but mine doesn't seem to make any sense. I'm uploading a CSV file, which is going to be displayed in a table on a webpage (that much I know and is easy) and I'm trying to find a way to take the date in a cell and convert it from it's native string format to a date.</p> <p>Here's the code:</p> <pre><code> def line = f.inputStream.toCsvReader(['skipLines':1]).eachLine{fields -&gt; List list = new List() list.item = fields[0].trim() String checkedOut = fields[1].trim() String returned = fields[2].trim() Date c = Date.parse('E MM/dd/yy', checkedOut) Date r = Date.parse('E MM/dd/yy', returned) list.lastCheckedOut = c list.lastReturned = r list.checkedOutBy = fields[4].trim() list.save flush: true return } </code></pre> <p>Here's the stacktrace </p> <pre><code>Error 2015-08-21 16:13:38,936 [http-bio-8080-exec-7] ERROR errors.GrailsExceptionResolver - ParseException occurred when processing request: [POST] /inventory/list/upload - parameters: upload: Upload Unparseable date: "9/22/94". Stacktrace follows: Message: Unparseable date: "9/22/94" Line | Method -&gt;&gt; 357 | parse in java.text.DateFormat - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 27 | doCall in org.ListController$_upload_closure1$$EPM22klU | 34 | eachLine in org.grails.plugins.csv.CSVReaderUtils | 126 | doCall in CsvGrailsPlugin$_closure4$_closure8 | 22 | upload . in org.ListController$$EPM22klU | 198 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter | 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter | 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor | 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker ^ 745 | run in java.lang.Thread </code></pre> <p>The date held in "fields[1]" is 9/22/94, I'm not entirely sure what the issue here is, everything I've read seems to show that this should work.</p>
10,300,723
0
<p>You had your parentheses in the wrong place:</p> <pre><code>function equal(n1, n2){ var bool = (n1 ^ n2) &gt;= 0 ? true : false; document.write("&lt;div&gt;" + bool + " (" + (n1^n2) + ")&lt;/div&gt;"); } </code></pre> <p>Here's an <a href="http://jsfiddle.net/qSwFt/1/" rel="nofollow">updated fiddle</a> with results matching what you expect.</p> <p>This is important in this case because all of the bitwise operators are of <a href="https://developer.mozilla.org/en/JavaScript/Reference/Operators/Operator_Precedence" rel="nofollow">lower precedence</a> than the relational comparison operators. Also note that the conditional operator (<code>?:</code>) is of lower precedence than all of the bitwise operators, so there's no need for another set of parentheses around the entire condition.</p>
28,047,424
0
Android Google Maps API v2 check land or water <p>I'm working with Android Google Maps API v2. Is it possible to check if point (LatLng) is in water or land?</p>
21,920,302
0
<p>You can try some like this basic structure</p> <pre><code>INSERT INTO temp_table (Value1,Value2,Value3) SELECT field1, field2, field3 FROM the_table WHERE condition_value = some_value </code></pre> <p>Remember have the same number of fields in your <code>INSERT INTO</code> and your <code>SELECT</code>. </p>
35,812,759
0
<p>Just because <code>A</code> is the base class of <code>B</code> doesn't change that <code>A</code> isn't <code>B</code>. It's <code>B</code> who's <code>A</code>.</p> <p>For example, you're a mix of your dad and you mother, but you're not your dad or your mother. If the police gets you doing something wrong with your car, would the police ask for your dad's or mom's driving license?</p> <p>You can compare the <em>police</em> with the compiler. The compiler won't accept that you set an instance of <code>A</code> in a reference typed as <code>B</code>, because they're different types.</p> <p>What compiler can accept is that an instance of <code>B</code> upcasted to <code>A</code> could be set to a reference of <code>A</code>:</p> <pre><code>B b = new B(); A a = b; b = (B)a; </code></pre>
31,211,557
0
<p>"Is this possible in SQL?"</p> <p>Yes</p> <p>I would suggest having 2 rows with each value (one for the Date, one for the Integer).</p> <p>What you would need is the following: a trigger for insertions that adds the NOW() value to a field. Then concat the Integer to that Date.</p> <p>And another trigger to reset the Integer value at the change of day (the hour you chose)</p>
1,043,705
0
<p>This is one way:</p> <pre><code>$metabasePath = "IIS://Localhost/W3SVC" $iisNumber = "12345" $site = new-object System.DirectoryServices.DirectoryEntry("$metabasePath/$iisNumber/root") $site.psbase.Properties["DefaultDoc"].Value = "newdefdoc.htm," + $site.psbase.Properties["DefaultDoc"].Value $site.psbase.CommitChanges() </code></pre> <p>The value returned in <code>$site.psbase.Properties["DefaultDoc"].Value</code> is a comma separated list of documents so you may need to re-jig the order to suit your case. The example above just adds a new default document (<code>newdefdoc.htm</code>) to the top of the list.</p>
3,081,942
0
<p>I am exploring possiblities of <a href="https://bespin.mozillalabs.com/" rel="nofollow noreferrer">https://bespin.mozillalabs.com/</a> for my web development. Looks quite promising. an editor and a version control system. fully online. try it for once and see if you like it. </p>
2,003,626
0
<p>Here's how it works with <a href="http://joda-time.sourceforge.net" rel="nofollow noreferrer">Joda time</a>:</p> <pre><code>DateTime startTime, endTime; Period p = new Period(startTime, endTime); int hours = p.getHours(); int minutes = p.getMinutes(); </code></pre> <p>You could format with Joda's formatters, e.g., PeriodFormat, but I'd suggest using Java's. See <a href="http://stackoverflow.com/questions/275711/add-leading-zeroes-in-java">this question</a> for more details.</p>
7,298,831
0
<p>Marquee is problematic. When TextView (or the Window containing the TextView)loses focus the marquee is stopped and reset (see the sources for TextView). I guess you have 3 possible solutions here:</p> <ol> <li>You can set <code>android:focusable="false"</code> in all other Views in your layout. That way your TextView shouldn't lose focus. But that's probably not the solution you want. </li> <li>You can subclass TextView and change <code>onFocusChanged()</code> and <code>onWindowFocusChanged()</code> to prevent marquee from being stopped and reset.</li> <li>Create your own implementation of marquee.</li> </ol>
2,160,702
0
<p>I dont get it, it <em>is</em> exactly one python <code>for loop</code> there. What is the question? Do you want the <code>j</code> declaration inside the loop declaration like in c++? Check Prasson'S answer for the closest python equivalent. But why have a j variable in the first place? <code>j=i+3</code> seems to always be true, so why not this?</p> <pre><code>for i in range(100): print i, " j: ", i+3 </code></pre>
12,903,066
0
<p>You never place any content in your <code>StringBuffer</code> <code>buffer</code>, so it is empty when you write it to file:</p> <pre><code>bw.write(buffer.toString()); </code></pre> <p><code>buffer</code> could potentially consume a large amount of memory here.</p> <p>A better approach to writing the data to file would be to write the data as you read it from the database:</p> <pre><code>while (rs.next()) { sampleIddisp = rs.getString(1); ... bw.write(....); } </code></pre>
37,105,723
0
Using class-local type aliases in a template base class list <p>In this code:</p> <pre><code>template &lt;typename Pair&gt; struct EdgeRange : public std::pair&lt;decltype(valueIter(std::declval&lt;Pair&gt;().first)), decltype(valueIter(std::declval&lt;Pair&gt;().second))&gt; { using EntryFirst = decltype(valueIter(std::declval&lt;Pair&gt;().first)); using EntrySecond = decltype(valueIter(std::declval&lt;Pair&gt;().second)); EdgeRange(const Pair&amp; p): std::pair&lt;EntryFirst, EntrySecond&gt;(valueIter(p.first), valueIter(p.second)) {} }; </code></pre> <p>The <code>decltype</code> types are mentioned twice each. How can I eliminate this duplication without moving the types outside the class?</p>
29,096,042
0
Add a Class and style to a dropdownlist rails <p>I have this code </p> <pre><code> &lt;%= f.select "banker_assignment[banker_assignment_status_id]", options_from_collection_for_select(@banker_assignment_statuses, :id, :assignment_status, @banker_assignment.banker_assignment_status.id), data: { selected: @banker_assignment.banker_assignment_status.id }, { :class =&gt; 'form-control single-select' }, { :style =&gt; 'float: right' } %&gt; </code></pre> <p>I want to add the following class and style to the dropdownlist but i always get an error </p> <pre><code>syntax error, unexpected ',', expecting =&gt; ...'form-control single-select' }, { :style =&gt; 'float: right' }... ... ^ </code></pre> <p>How do i get rid of this error?</p> <p>Thanks </p>
30,151,235
0
<p>What you can do is use the neko program found here <a href="https://github.com/jasononeil/haxelib-xml-to-json" rel="nofollow">https://github.com/jasononeil/haxelib-xml-to-json</a> to change your xml server response to json then use the haxe.Json class to change that into a Dynamic typed object. The program in the link loads in .xml files and exports .json so you'll have to save what you get from the server to file first then load it again. You can probably cut out the middle man if you just write a class to handle the conversion using the link above as a guide.</p>
24,137,956
0
<p>I am assuming you are not using JSON.NET. If this the case, then you can try it.</p> <p>It has the following features -</p> <p>LINQ to JSON The JsonSerializer for quickly converting your .NET objects to JSON and back again Json.NET can optionally produce well formatted, indented JSON for debugging or display Attributes like JsonIgnore and JsonProperty can be added to a class to customize how a class is serialized Ability to convert JSON to and from XML Supports multiple platforms: .NET, Silverlight and the Compact Framework Look at the example below. </p> <p>In this <a href="http://james.newtonking.com/json" rel="nofollow">example</a>, JsonConvert object is used to convert an object to and from JSON. It has two static methods for this purpose. They are SerializeObject(Object obj) and DeserializeObject(String json) -</p> <pre><code>Product product = new Product(); product.Name = "Apple"; product.Expiry = new DateTime(2008, 12, 28); product.Price = 3.99M; product.Sizes = new string[] { "Small", "Medium", "Large" }; string json = JsonConvert.SerializeObject(product); //{ // "Name": "Apple", // "Expiry": "2008-12-28T00:00:00", // "Price": 3.99, // "Sizes": [ // "Small", // "Medium", // "Large" // ] //} </code></pre> <p>Product deserializedProduct = JsonConvert.DeserializeObject(json);</p>
8,483,307
0
<p>There is no %2C in your string, so it just continually iterates till it reaches the end of the string then is trying to read more and failing because it is already at the end of the string. </p> <p>You should add something like:</p> <pre><code>if ($pos&gt;strlen($haystack)) { return false; } </code></pre> <p>Into your loop. </p> <p>Also $haystack[$pos] is only one character while $endDelimiter is more than one character so that will never match unless your $endDelimiter is only a single character. </p>
40,474,243
0
<p>Use a <code>QToolButton</code> instead of a <code>QPushButton</code> and clear its maximum size.</p> <p>You may need to set the vertical size-policy to "Preferred" so that it to has the same height as the other buttons. To get a flat button, check the "autoRaise" property.</p> <p>A quick way to change the button class is to right-click it and select "Morph Into" from the context menu.</p>
39,707,374
0
Default AppCompatButton not writing in all caps <p>I have the support library added as a dependency</p> <p><code>compile 'com.android.support:appcompat-v7:24.2.1'</code></p> <p>My styles.xml looks like this:</p> <pre><code>&lt;resources xmlns:android="http://schemas.android.com/tools"&gt; &lt;!-- Base application theme. --&gt; &lt;style name="AppTheme" parent="Theme.AppCompat"&gt; &lt;!-- Customize your theme here. --&gt; &lt;item name="colorPrimary"&gt;@color/colorPrimary&lt;/item&gt; &lt;item name="colorPrimaryDark"&gt;@color/colorPrimaryDark&lt;/item&gt; &lt;item name="colorAccent"&gt;@color/colorAccent&lt;/item&gt; &lt;/style&gt; &lt;/resources&gt; </code></pre> <p>and my buttons themselves:</p> <pre><code>&lt;android.support.v7.widget.AppCompatButton android:layout_width="88dp" android:layout_height="48dp" android:layout_marginBottom="16dp" android:layout_marginEnd="16dp" android:layout_marginStart="75dp" android:layout_marginTop="82dp" android:text="RETURN" android:textSize="14sp"/&gt; </code></pre> <p>The button currently looks like this: <a href="https://i.stack.imgur.com/slL12.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/slL12.png" alt="enter image description here"></a></p> <p>Also note how I have set the text to all caps but it's getting overwritten with normal lettering. Is the style being overridden somewhere?</p> <p>I have tried adding: </p> <p><code>style="@style/Widget.AppCompat.Button"</code> to the button but nothing has happened. Where am I going wrong?</p>
24,899,415
0
<p>OK, as you are dealing with authentication, let's improve your code a little.</p> <pre><code>&lt;?php // Do not connect using root, especially when not setting a password: $con=mysqli_connect("localhost","projectuser","password","project"); if(mysqli_connect_errno()) { echo "failed".mysqli_connect_errno(); } $uid = $_GET['username']; $pass = $_GET['password']; // This is the main problem, there was a typo: $sql = "SELECT * FROM login"; // Directly ask the DB if the credentials are correct. // Then you do not need the loop below. // BUT: Do not forget to escape the data in this case! $sql .= " WHERE uid = '" . mysqli_real_escape_string($uid) . "' AND pass = '" . mysqli_real_escape_string($pass) . "'"; $result=mysqli_query($con,$sql); if ($result-&gt;num_rows === 1) { header('location:http://localhost/mam.html'); } else { header('location:http://localhost/error/index.html'); } mysqli_close($con); ?&gt; </code></pre> <p>A further improvement would be to hash (and salt) the password in the database.</p> <p>Also, as VMai pointed out, the use of prepared statements would be appropriate.</p>
8,124,255
0
JSON - Return Property Count <p><strong>JSON structure:</strong></p> <pre><code>{ "codes":[ { "id":"1", "code":{ "fname":"S", "lname":"K" } }, { "id":"2", "code":{ "fname":"M", "lname":"D" } } ] } </code></pre> <p><strong>I want to loop through each code and alert the number of properties within each code</strong></p> <pre><code> success: function(data){ var x, count=0; for (x = 0; x &lt; data.codes.length; x++){ for (property in data.codes[x].code) { count++; alert(count); } } } </code></pre> <p><strong>The above works BUT it returns 4 as the <code>count</code>. It should return 2 for each <code>code</code>.</strong></p>
18,632,968
0
MQTT Android not connecting to ActiveMq <p>I'm trying to connect an Android application to an ActiveMQ server. I'm using ActiveMQ because my server already talks to the ActiveMQ server using JMS so it will be very beneficial for me to connect the android client to the JMS broker.</p> <p>I've enabled MQTT in ActiveMQ following this page: <a href="http://activemq.apache.org/mqtt.html" rel="nofollow">http://activemq.apache.org/mqtt.html</a> and I had a small problem with any of the MQTT clients (IBM MQTT client or Paho MQTT Client) I've downloaded didn't recognize "mqtt://" url prefix so I tried to use tcp instead. This is how the configuration looks like in activemq.xml: </p> <pre><code>&lt;transportConnectors&gt; &lt;transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;amp;wireformat.maxFrameSize=104857600"/&gt; &lt;transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;amp;wireformat.maxFrameSize=104857600"/&gt; &lt;transportConnector name="mqtt" uri="tcp://0.0.0.0:1883"/&gt; &lt;/transportConnectors&gt; </code></pre> <p>When I try to connect using any mqtt client example such as this one: <a href="http://mosquitto.org/2011/11/android-mqtt-example-project/" rel="nofollow">http://mosquitto.org/2011/11/android-mqtt-example-project/</a> I'm unable to connect to the ActiveMQ and I get an error on the server side:</p> <pre><code>2013-09-05 12:34:17,550 | WARN | Transport Connection to: tcp://192.168.0.111:42148 failed: java.io.IOException: Unknown data type: 77 | org.apache.activemq.broker.TransportConnection.Transport | ActiveMQ Transport: tcp:///192.168.0.111:42148@1883 </code></pre> <p>Any suggestions? Thanks!</p>
16,778,818
0
<p>T-SQL supports some procedural statement like IF. PostgreSQL doesn't support it, so you cannot rewrite your query to postgres simply. Sometime you can use Igor's solution, sometime you can use plpgsql (functions) and sometime you have to modify your application and move procedural code from server to client. </p>
32,345,367
0
<p>You need to compile a version of your custom control that targets the TFS 2015 binaries in order for your control to load in VS 2015.</p>
5,003,315
0
<p>It seems to me, on the contrary, that neither actor has its output redirected, since <code>withOut</code> will have finished executing long before <code>println("II")</code> is called. Since this is all based on <code>DynamicVariable</code>, however, I'm not willing to bet on it. :-) The absence of working code precludes any testing as well.</p>
12,580,007
0
<p>I was struggling with same exception and <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.servicecontractattribute.protectionlevel.aspx" rel="nofollow">found this</a>:</p> <blockquote> <p>When there is no protection level explicitly specified on the contract and the underlying binding supports security (whether at the transport or message level), the effective protection level for the whole contract is ProtectionLevel.EncryptAndSign. If the binding does not support security (such as BasicHttpBinding), the effective System.Net.Security.ProtectionLevel is ProtectionLevel.None for the whole contract. The result is that depending upon the endpoint binding, clients can require different message or transport level security protection even when the contract specifies ProtectionLevel.None.</p> </blockquote> <p>So, if you don't specify ProtectionLevel in ServiceContract attribute, WCF will define ProtectionLevel based on your web.config. If you're using for example Ws2007 and BasicHttpBinding, BasicHttpBinding will fail with your exception. Then you have 3 options:</p> <ol> <li>Remove all secured bindings for your contract and leave just BasicHttpBinding.</li> <li><p>Set protection level on contract that is exposed through BasicHttpBinding as this:</p> <p>[ServiceContract(ProtectionLevel = ProtectionLevel.None)]</p></li> <li>Provide some security for BasicHttpBinding.</li> </ol>
30,029,321
0
<p>Have you set your storyboard/xib files backward compatible?</p> <p><img src="https://i.stack.imgur.com/ytoMn.png" alt="enter image description here"></p>
19,888,968
1
NameError in Python interpreter <p>Here is my init:</p> <pre><code>import os, sys sys.path.append(os.path.abspath("..")) from myModule import * </code></pre> <p>Then in command line, same directory:</p> <pre><code>Python 2.7.4 (default, Sep 26 2013, 03:20:26) [GCC 4.7.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; c = myClass Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; NameError: name 'myClass' is not defined </code></pre>
33,687,723
0
<p>Here is my solution. use unsafeBitCast to avoid cast fail warning.</p> <pre><code>extension Object { func toDictionary() -&gt; [String:AnyObject] { let properties = self.objectSchema.properties.map { $0.name } var dicProps = [String:AnyObject]() for (key, value) in self.dictionaryWithValuesForKeys(properties) { if let value = value as? ListBase { dicProps[key] = value.toArray() } else if let value = value as? Object { dicProps[key] = value.toDictionary() } else { dicProps[key] = value } } return dicProps } } extension ListBase { func toArray() -&gt; [AnyObject] { var _toArray = [AnyObject]() for i in 0..&lt;self._rlmArray.count { let obj = unsafeBitCast(self._rlmArray[i], Object.self) _toArray.append(obj.toDictionary()) } return _toArray } } </code></pre>
31,838,746
0
<p>Are you actually typing <code>heroku certs:add PEM KEY</code>? </p> <p>If so you need to replace the words PEM KEY with the filename of your PEM key...</p> <p>e.g.</p> <p><code>heroku certs:add my-site.pem</code></p> <p>The PEM key file is a certificate generated by you or a certificate authority.</p>
20,461,089
0
How can I control the source port of a TCP packet? <p>To test my implementation of a NAT, I want to send TCP packets from one internal host to two different external hosts, and make sure that the source port for both streams of packets that leave the NAT have the same source port. How can I control the source port? wget uses different source ports for separate TCP connections.</p>
5,686,902
0
<p>It is a formatted string where <code>%s</code> is a placeholder. I suspect that $sql is handed to <a href="http://php.net/sprintf">sprintf</a> to transform it into a real query. Example:</p> <pre><code>$name = 'posts'; $sql = "SELECT * FROM page_table WHERE page_name = '%s' LIMIT 1"; $formattedSql = sprintf($sql, $name); </code></pre> <p>This will generate a query looking like:</p> <pre><code>SELECT * FROM page_table WHERE page_name = 'posts' LIMIT 1 </code></pre> <p>This is very useful when you don't want to fiddle around with quotes and doublequotes.</p>
18,109,569
0
<p>I'd use <code>find</code> + <code>egrep</code> to filter, then <code>sed</code> to build the name of the destination directory. </p> <pre><code>cd /src IMAGES=`find . -type f -name '*.png' -print | egrep '^./[0-9]{4}-[0-9]{2}-[0-9]{2}-.+.png$'` for IMG in $IMAGES; do # optimize here DIR=`echo $IMG | sed -E 's/^\.\/([0-9]{4})-([0-9]{2})-[0-9]{2}-.+.png/\1\/\2/'` mkdir -p /dest/$DIR mv /src/$IMG /dest/$DIR/ done </code></pre>
38,877,689
0
<p>Starting from Outlook 2013 you can reorder folders however you like and Outlook would remember the order. The key property is <code>PR_SORT_POSITION</code>. Here’s the definition:</p> <blockquote> <h1>define PR_SORT_POSITION PROP_TAG( PT_BINARY, 0x3020)</h1> </blockquote> <p>Outlook will use this property as part of it’s sort order when requesting folders from a provider, so it’s important that your provider can handle sorting on a binary property – or can fake it when asked to sort by this property. Outlook will also use this property directly when deciding where to insert nodes in the visible tree, so it’s also important that your provider can return this property when Outlook looks for it on a folder.</p> <p>There’s a second property Outlook will use for custom sort ordering:</p> <blockquote> <h1>define PR_SORT_PARENTID PROP_TAG( PT_BINARY, 0x3021)</h1> </blockquote> <p>As the name suggests, this property stores an entry ID which can be used to sort a folder under a different node than it’s natural parent. Normally, a folder will be sorted under the folder represented by <code>PR_PARENT_ENTRYID</code>. This property allows you to suggest a different parent for display.</p> <p>By presetting these properties appropriately, you can direct Outlook in how you wish your provider’s folders to be sorted. And if you allow Outlook to write to these properties, you can preserve whatever sort order your users desire.</p> <p>So, theoretically you can set these properties from VBA. The <a href="https://msdn.microsoft.com/en-us/library/office/ff869735.aspx?f=255&amp;MSPPError=-2147217396" rel="nofollow">PropertyAccessor</a> class can help you with such tasks. Also you may consider using a low-level code if you face with any restrictions from OOM, so any wrappers around Extended MAPI allows to bridge the gap (for example, Redemption).</p>
17,258,945
0
Using Auth with Endpoints <p>I defined a simple API using Google Cloud Endpoints:</p> <pre><code>@Api(name = "realestate", version = "v1", clientIds = { com.google.api.server.spi.Constant.API_EXPLORER_CLIENT_ID }, scopes = { "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile" }) public class RealEstatePropertyV1 { @ApiMethod(name = "create", path = "properties", httpMethod = HttpMethod.POST) public void create(RealEstateProperty property, User user) throws UnauthorizedException { if (user == null) { throw new UnauthorizedException("Must log in"); } System.out.println(user.getEmail()); } } </code></pre> <p>Then I try to test it using the <code>API explorer</code>. I activated OAuth 2.0. But when I execute the request, the <code>User</code> object is <code>null</code>.</p> <pre><code>Jun 23, 2013 10:21:50 AM com.google.appengine.tools.development.DevAppServerImpl start INFO: Dev App Server is now running Jun 23, 2013 10:22:42 AM com.google.api.server.spi.SystemServiceServlet init INFO: SPI restricted: true Jun 23, 2013 10:22:43 AM com.google.api.server.spi.WebApisUserService getCurrentUser WARNING: getCurrentUser: clientId not allowed Jun 23, 2013 10:22:43 AM com.google.api.server.spi.SystemService invokeServiceMethod INFO: cause={0} com.google.api.server.spi.response.UnauthorizedException: Must log in at com.realestate.api.v1.RealEstatePropertyV1.create(RealEstatePropertyV1.java:44) </code></pre>
31,306,470
0
Show PleaseWait Popup in Catel Orchestra + MahApps.Metro <p>I am trying to show a PleaseWait popup in a Orchestra app the same way it is shown in Catel without Orchestra but im unable to do so. I know that the PleaseWaitService shows the progress and text in a status bar on the bottom of the window, but is does orchestra have something similar to what Catel has?</p>
32,434,893
0
<p>I agree with the comment from Korri above, in that you could benefit from taking inspiration from existing frameworks.</p> <p>Personally, this sort of directory structure feels right, to me.</p> <pre><code>. |-- composer.json |-- gulpfile.js |-- package.json |-- changelog.md |-- readme.md |-- /src (This is the API code that *I'm* responsible for, and that I *own*.). | |-- /app | | |-- /controllers | | |-- /models | | `-- &lt;other_framework_stuff&gt; | /public (Keeping this outside of the src dir, means that you can give this to your front-end devs without needing to have the entire codebase). | | |-- /styles | | |-- /images | | |-- /js | /config (Put all configuration files outside of the src scope, so you can keep it outside of source control) | /build (CI build related configuration) | | |--phpcs.xml | | |--phpdocx.xml |-- /tests (separating out your tests in this way can help you run tests separately, more easily) | | |--acceptance | | |--integration | | |--unit |-- /vendor (Depenedencies installed via Composer) </code></pre> <p>Really, there's no community driven correct answer to your question. The correct answer is specific to <em>your</em> business, the team <em>you</em> work in, and the project itself. </p> <p>I'd never put the <code>/vendor</code> directory within your <code>/src</code> directory - because you don't <em>own</em> it. You're not responsible for the changes to the code within your project's dependencies, so it should be left in its own scope outside of your projects walls.</p> <p>With <a href="http://www.php-fig.org/psr/psr-4/" rel="nofollow">PSR-4</a> autoloading, it really doesn't matter too much about your directory structure, it can be changed easily at any time, with no impact on your code. So, experiment and see what <em>feels</em> right for you.</p>
17,473,607
0
<p>This should work for you. Add this in your .htaccess file.</p> <pre><code>RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+) /?action=$1&amp;%{QUERY_STRING} [L] </code></pre>
3,331,940
0
<p>Thanks to the commenters for teasing out the answer details.</p> <p>MVC's default EditorFor "master" template, Object.ascx, has an if statement in place to prevent this from happening.</p> <p>To change this behavior you need to replace the base /EditorTemplates/Object.ascx template with your own. This is a good replica of the template baked into MVC:</p> <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %&gt; &lt;% if (Model == null) { %&gt; &lt;%= ViewData.ModelMetadata.NullDisplayText %&gt; &lt;% } else if (ViewData.TemplateInfo.TemplateDepth &gt; 1) { %&gt; &lt;%= ViewData.ModelMetadata.SimpleDisplayText %&gt; &lt;% } else { %&gt; &lt;table cellpadding="0" cellspacing="0" border="0"&gt; &lt;% foreach (var prop in ViewData.ModelMetadata.Properties.Where(pm =&gt; pm.ShowForDisplay &amp;&amp; !ViewData.TemplateInfo.Visited(pm))) { %&gt; &lt;% if (prop.HideSurroundingHtml) { %&gt; &lt;%= Html.Display(prop.PropertyName) %&gt; &lt;% } else { %&gt; &lt;tr&gt; &lt;td&gt; &lt;div class="display-label" style="text-align: right;"&gt; &lt;%= prop.GetDisplayName() %&gt; &lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div class="display-field"&gt; &lt;%= Html.Display(prop.PropertyName) %&gt; &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;% } %&gt; &lt;% } %&gt; &lt;/table&gt; &lt;% } %&gt; </code></pre> <p>This line:</p> <pre><code>&lt;% } else if (ViewData.TemplateInfo.TemplateDepth &gt; 1) { %&gt; </code></pre> <p>tell the template to only go down a single level of your object graph. Simply replace the 1 with 2 or remove it entirely to change how far MVC will drill down.</p> <p>More details about this template can be found here: <a href="http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-4-custom-object-templates.html" rel="nofollow noreferrer">http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-4-custom-object-templates.html</a></p> <p>( man, I should create a macro to linking to Brad Wilson's stuff, I do it all the time ) ;)</p>
3,658,926
0
<p>On way to ensure that your entities are not cached is to clear the session with <code>ISession.Clear()</code>. Also you can evict individual entities by calling <code>ISession.Evict(object entity)</code>.</p> <p>If you not sure of what is happening in your application, consider a profiling tool such as <a href="http://nhprof.com/" rel="nofollow noreferrer">nhprof</a>.</p> <p><em>Quick note: using a session for the lifetime of a dialog can be handy in small applications with no concurrency problems, but you will get in trouble on the long run. A session should be opened late, and closed early.</em></p>
40,039,403
0
<p>Run <code>list</code> to show all the jobs, then use the jobID/applicationID in the appropriate command.</p> <p>Kill mapred jobs:</p> <pre><code>mapred job -list mapred job -kill &lt;jobId&gt; </code></pre> <p>Kill yarn jobs:</p> <pre><code>yarn application -list yarn application -kill &lt;ApplicationId&gt; </code></pre>
8,749,705
0
Facebook: where is location of photo in graph <p>Since we can now add location to individual photo in Facebook, does anyone know how to access that piece of information on the graph?</p> <p>For example, at this link: <a href="https://developers.facebook.com/docs/reference/api/" rel="nofollow">https://developers.facebook.com/docs/reference/api/</a> if I look at my News Feed graph, I see the recent photos I've uploaded with location.</p> <p>But if I look at Photo Tags or the Photo API, nothing is said about the location.</p> <p>1.) Can someone explain to me why is that?</p> <p>2.) How do I get all my geo-referenced photos then? </p>
39,433,144
0
<p>Firs of all you will need to add a <strong>Clicklistener</strong> for every object inside for ReRecyclerView . </p> <p>you will need to add this code in your adapters :</p> <pre><code>private static MyClickListener myClickListener; . . public void setOnItemClickListener(MyClickListener myClickListenerHolder) { myClickListener = myClickListenerHolder; } . . public interface MyClickListener { void onItemClick(int position, View v); } </code></pre> <p>and in your <strong>cardView</strong> ClickListener add :</p> <pre><code>holder.mCardView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // removes the cardviews that was updated from the myClickListener.onItemClick(position,view); } }); </code></pre> <p>now at <strong>MainActivity.java</strong> you can control your objects clicks by adding them in <strong>onResume</strong> at your main .</p> <p>example: </p> <pre><code>RecyclerView.Adapter SecondAdapter, displayRecyclerAdapter; RecyclerView displayRecyclerView= (RecyclerView) findViewById(R.id.my_recycler_view); . . @Override protected void onResume() { super.onResume(); ((AnswerRecyclerViewAdapter) SecondAdapter).setOnItemClickListener(new AnswerRecyclerViewAdapter .MyClickListener() { @Override public void onItemClick(int position, View v) { //from here you can send data to your other RecyclerView like this displayRecyclerAdapter = new displayRecyclerAdapterClass(Context,SomeString); displayRecyclerView.setAdapter(displayRecyclerAdapter); } }); } </code></pre> <p>i hope this could help you ^_^</p>
28,858,281
0
<p>Include <code>email</code> in your list of OAuth scopes. Then, in the token you get back, there will be a <code>hd</code> attribute if it's a Google Apps account. If the <code>hd</code> attribute is not present, its' a consumer account. Be aware that it's possible to create a consumer account that has an address of something other than @gmail.com or @googlemail.com. For example, I can create a consumer account with the address [email protected] or [email protected] as long as I can get email to those addresses. Thus the need to check <code>hd</code> instead of depending on the domain name.</p>
35,500,985
0
Allow .SDcols to vary with grouping variable in data.table <p>Is it allowable to have <code>.SDcols</code> vary with the <code>by</code> grouping variable? I have the following situation, where I would like to change <code>.SDcols</code> to different columns for each year. The values for the <code>.SDcols</code> are in one data.table, while I am trying to apply a function to the <code>.SD</code> in another table using these values.</p> <p>Quite likely I am missing the obvious approach and doing this wrong, but this is what I was attempting,</p> <pre><code>## Contains the .SDcols applicable to each year dat1 &lt;- data.table( year = 1:4, vals = lapply(1:4, function(i) letters[1:i]) ) ## Make the sample data (with NAs) set.seed(1775) dat2 &lt;- data.table( year = sample(1:4, 10, TRUE) ) dat2[, letters[1:4] := replicate(4, sample(c(NA, 1:5), 10, TRUE), simplify=FALSE)] ## Goal: Sum up the columns in the corresponding .SDcols for each year ## Attempt, doesn't work -- I think b/c .SDcols must be fixed? dat2[, SUM := rowSums(.SD, na.rm=TRUE), by=year, .SDcols=unlist(dat1[year == .BY[[1]], vals])] ## Desired result, by simply iterating through each possible year for (i in 1:4) { dat2[year==i, SUM := rowSums(.SD, na.rm=TRUE), .SDcols=unlist(dat1[year == i, vals])] } dat2[] # year a b c d SUM # 1: 1 3 1 5 1 3 # 2: 2 1 3 3 1 4 # 3: 1 5 4 3 NA 5 # 4: 4 1 NA 4 5 10 # 5: 2 2 2 2 NA 4 # 6: 2 NA 3 3 NA 3 # 7: 4 2 3 2 NA 7 # 8: 1 2 NA 5 4 2 # 9: 2 3 3 5 1 6 # 10: 3 NA 4 2 NA 6 </code></pre>
10,946,587
0
<p>Debugging C++ in Eclipse: </p> <p><a href="http://www.youtube.com/watch?v=azInZkPP56Q" rel="nofollow">http://www.youtube.com/watch?v=azInZkPP56Q</a></p>
21,477,408
0
<p><code>llvm-config</code> is not adding the link option for the <code>Terminfo</code> library. Add</p> <pre><code>-ltinfo </code></pre> <p>To link in the library and all should be well.</p>
16,497,020
0
.Net MVC binding dynamic Type to a Model at runtime <p>I have a slightly long conceptual question I'm wondering if somebody could help me out with. </p> <p>In MVC I've built a website which builds grids using <a href="http://demos.kendoui.com/web/grid/index.html" rel="nofollow">kendoui's framework</a>. </p> <p>All the grids on my website are constructed exactly the same except for the model they use and the CRUD methods that need to be implemented for each model. I set things up where each Model implement an interface for CRUD methods like below to get the logic all in one place.</p> <pre><code>//Actual interface has variables getting passed public interface IKendoModelInterface { void Save(); void Read(); void Delete(); } public class Model1: IKendoModelInterface { [Key] public int IdProperty1 { get; set; } public int SomeProperty2 { get; set; } public string SomeProperty3 { get; set; } public void Save(){ //Implement Save } public void Read(){ //Implement Read } public void Delete(){ //Implement Delete } } </code></pre> <p>Then to speed up the writing of all the scaffolding Action methods needed to get the grids to work I created an abstract Controller that can call the interface methods of the Model that gets passed into it. </p> <pre><code> //Implement the AJAX methods called by the grid public abstract class KendoGridImplController&lt;T&gt; : Controller where T : class, IKendoModelInterface { // Method called from kendo grid public virtual ActionResult Create([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable&lt;T&gt; createdRecords) { //Invoke Create Method for Model and return results } public virtual ActionResult Read([DataSourceRequest]DataSourceRequest request, int Id) { //Invoke read method for model and return results } //Update and Delete also implemented.. } </code></pre> <p>Then I just need a Controller per model that implements the abstract controller above passing in the type of Model being used.</p> <pre><code> public class ResponsibilityMatrixController : KendoGridImplController&lt;Model1&gt; { //Set up the page the grid will be on public ActionResult Index(int id) { return View("SharedGridView", id); } //Can override abstract methods if needed but usually won't need to } </code></pre> <p>I'm wondering if I can take this one step further or if I've reached the end of the road. To me it just seems like more repeated code if I have to create a controller per Model that does nothing but pass in the type to the abstract controller and calls the same View. </p> <p>I attempted for quite a while yesterday to figure out if I could dynamically assign the type to the abstract controller. I setup something where I was sending back the type of model via strings and I could still invoke the methods needed. Where it failed, was that the mapping could no longer be done on any of the controller actions by default since the type isn't known at compile time. eg </p> <pre><code>public virtual ActionResult Create([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable&lt;T&gt; createdRecords) </code></pre> <p>createdRecords can't be bound like this if T that's passed in is an interface and not the Model itself and I've found no real way to map the form data to an instance of a type that isn't known at compile time. </p> <p>I'm wondering if there's an easy way to do this mapping between an instance of the type of object getting passed in that I can figure out at runtime, if there's some other way to set this up that I'm overlooking or if both those things are going to be way too much work and I should just not attempt something like this and build a controller per model like I do now? </p>
34,853,838
0
<p>Use node.js and execute your script using Runtime.exec(). you would run node on this or you can go for Rhino scripting engine to envoke methods in .js file from within a java class. Hope that helped.</p>
3,751,567
0
<p>I find <a href="http://colorpowered.com/colorbox/" rel="nofollow noreferrer">ColorBox</a> to be the best jQuery extension for this.</p>
17,197,644
0
How to determine original folder in SVN. <p>I just realized that I accidentally copied a folder from one place to another. My problem is that I dont remember which folder is the original and which is they copy. I mucked around in both folders since then, so I cant use the date modified. How can I use svn to figure out which folder is the original?</p>
30,353,771
0
<pre><code>class Parent1(object): def on_start(self): print('do something') class Parent2(object): def on_start(self): print('do something else') class Child(Parent1, Parent2): def on_start(self): super(Child, self).on_start() super(Parent1, self).on_start() c = Child() c.on_start() do something do something else </code></pre> <p>Or without super:</p> <pre><code>class Child(Parent1, Parent2): def on_start(self): Parent1.on_start(self) Parent2.on_start(self) </code></pre>
20,711,262
0
How to ignore the focus of a cell in gridfieldmanager? <p>i just made this example for the sake of my question.</p> <pre class="lang-java prettyprint-override"><code>public MyScreen() { setTitle("GridFieldManager"); GridFieldManager grid2 = new GridFieldManager(1,2,GridFieldManager.FIXED_SIZE); add(grid2); String[] choice={"1","2","0"}; ObjectChoiceField menu=new ObjectChoiceField(null,choice); //grid.add(lol); grid2.add(new LabelField("Productos_",NON_FOCUSABLE)); grid2.add(menu); } </code></pre> <p>For some reason i still can focus the labelfield even when i said it was non focusable (<code>Field.NON_FOCUSABLE</code>). </p> <p>Note: Just to let you know, i'm using a label + objectchoicefield so i can have total control of the properties of that label, since i found troublesome changing the color and font from the label that objectchoicefield has.</p> <p>In this picture you can see how the focus is on the <code>LabelField</code>. i just want to focus the objectchoicefield list.</p> <p><img src="https://i.stack.imgur.com/qXIjt.png" alt="enter image description here"></p>
16,162,881
0
WPF: Drawing normalized polygons that resize to fit their container <p>I'm trying to create a usercontrol that is capable of drawing polygons on the screen. These polygons have points all between 0,0 and 1,1 (normalized). When drawing, the polygon should fill the space given to it. As such, a value of 1,1 would correspond to width,height in the container.</p> <p>I've tried applying renderTransforms, but that results in the line widths getting scaled as well. The line widths should be the same (this is vectorized polygon information I'm trying to display).</p> <p>Can anyone think of the best way to go about doing this?</p> <p>Thanks</p>
10,707,425
0
<p>Found it,</p> <p>The answer is no :( it's not possible...</p> <p>The only work around I did, is to create new MyWishClass and pass myDynamicClass, to him, so he is basically warping him.</p>
28,745,120
0
unable to watch java local class instance in eclipse <p>Here is a small sample:</p> <pre><code>public class LocalClassSample { public static void main(String[] args) { class Utils { public void printHello(String name) { System.out.println("Hello " + name); } public String outHello(String name) { return "hello " + name; } } Utils util = new Utils(); util.printHello("World"); } } </code></pre> <p>I put a break point at the last line. I am able to view util in the Variables window...</p> <p><img src="https://i.stack.imgur.com/xPM3O.png" alt="enter image description here"></p> <p>I try to view the same variable in the expressions window...it is unable to evaluate:</p> <p><img src="https://i.stack.imgur.com/216fJ.png" alt="enter image description here"> Update:</p> <p>Even tried inspecting the variable in the Display View...it does not evaluate: <img src="https://i.stack.imgur.com/RG3ty.png" alt="enter image description here"></p>
27,113,944
0
NDK: Native method not found <p>I'm using Android NDK for the first time. What I want is to get a string from a native C++ method and use it as text in a textview. I have no idea where is the problem..</p> <p><strong>My code</strong></p> <p>Java: package: package com.example.nativetest;</p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); init(); this.textView.setText(stringFromJNI()); } public native String stringFromJNI(); static { System.loadLibrary("CascadeClassifier"); } </code></pre> <p>C++:</p> <pre><code>#include &lt;string.h&gt; #include &lt;jni.h&gt; extern "C" { JNIEXPORT jstring JNICALL Java_com_example_nativetest_MainActivity_stringFromJNI (JNIEnv *env, jobject obj) { return env-&gt;NewStringUTF("Hello from C++ over JNI!"); } } </code></pre> <p><strong>LogCat</strong></p> <pre><code>11-24 22:41:58.646: E/AndroidRuntime(12950): FATAL EXCEPTION: main 11-24 22:41:58.646: E/AndroidRuntime(12950): java.lang.UnsatisfiedLinkError: Native method not found: com.example.nativetest.MainActivity.stringFromJNI:()Ljava/lang/String; 11-24 22:41:58.646: E/AndroidRuntime(12950): at com.example.nativetest.MainActivity.stringFromJNI(Native Method) 11-24 22:41:58.646: E/AndroidRuntime(12950): at com.example.nativetest.MainActivity.onCreate(MainActivity.java:31) 11-24 22:41:58.646: E/AndroidRuntime(12950): at android.app.Activity.performCreate(Activity.java:5133) 11-24 22:41:58.646: E/AndroidRuntime(12950): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 11-24 22:41:58.646: E/AndroidRuntime(12950): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2225) 11-24 22:41:58.646: E/AndroidRuntime(12950): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2311) 11-24 22:41:58.646: E/AndroidRuntime(12950): at android.app.ActivityThread.access$600(ActivityThread.java:149) 11-24 22:41:58.646: E/AndroidRuntime(12950): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1293) 11-24 22:41:58.646: E/AndroidRuntime(12950): at android.os.Handler.dispatchMessage(Handler.java:99) 11-24 22:41:58.646: E/AndroidRuntime(12950): at android.os.Looper.loop(Looper.java:137) 11-24 22:41:58.646: E/AndroidRuntime(12950): at android.app.ActivityThread.main(ActivityThread.java:5214) 11-24 22:41:58.646: E/AndroidRuntime(12950): at java.lang.reflect.Method.invokeNative(Native Method) 11-24 22:41:58.646: E/AndroidRuntime(12950): at java.lang.reflect.Method.invoke(Method.java:525) 11-24 22:41:58.646: E/AndroidRuntime(12950): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739) 11-24 22:41:58.646: E/AndroidRuntime(12950): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555) 11-24 22:41:58.646: E/AndroidRuntime(12950): at dalvik.system.NativeStart.main(Native Method) </code></pre>
19,716,212
0
<p>Is this an Air app? Because if so you can use this:</p> <pre><code>var path:File = new File("c:\kdc\kdc.exe"); path.openWithDefaultApplication(); </code></pre> <p>If I helped please mark as answered!</p>
6,675,402
0
<p><code>if data["location"] &amp;&amp; data["location"]["country"] &amp;&amp; data["location"]["country"]["code]</code></p> <p>Ruby's <code>&amp;&amp;</code> operator is a short circut operator, so if the first operand is false, it will stop processing the rest of the condition. In addition. Any object that is not <code>nil</code>, is (for boolean purposes) <code>true</code>, so if the key exists, then it is <code>true</code></p>
29,030,889
0
Rounding a variable to an integer <p>I have a calculation like this: 3 * 12300 / 160. The result is: 230.625. But I just want the integer part, 230.</p> <p>In C, this can be done using something like this: <code>int MyVar = (int)3*12300/160;</code> </p> <p>Is there a way in VBA (With MS-Access) for force the result to be an integer? </p>
8,426,291
0
Android-World Clock Widget analog <p>I am planning to create a world clock widget in android. The clock should show the selected country's time as an analog clock widget. But I'm feeling difficulties as I'm a beginner in android. </p> <p>My widget.xml file contains the following:-</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/Widget" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="8dip" android:background="@drawable/myshape" &gt; &lt;AnalogClock android:id="@+id/AnalogClock" android:layout_width="wrap_content" android:layout_height="wrap_content" android:dial="@drawable/widgetdial" android:hand_hour="@drawable/widgethour" android:hand_minute="@drawable/widgetminute"/&gt; </code></pre> <h2> </h2> <p>I am using the following configuration activity for my widget:- (To display the city list) package nEx.Software.Tutorials.Widgets.AnalogClock;</p> <pre><code>import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Calendar; import android.app.Activity; import android.app.PendingIntent; import android.app.ProgressDialog; import android.appwidget.AppWidgetManager; import android.content.Intent; import android.os.Bundle; import android.content.Context; import android.content.SharedPreferences; import android.util.Log; import android.view.View; import android.view.ViewGroup.LayoutParams; import android.widget.AdapterView; import android.widget.AnalogClock; import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.RemoteViews; import android.widget.TextView; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class ConfigureApp extends Activity { DateFormat df; private ListView cityList; public static String[][] citylist = new String[1242][10]; String[] cities = new String[1242]; String field[] = new String[20]; String list[][] = new String[1242][10]; String country = ""; String line = null; int row = 0; int col = 0; // Variables for list view population String city = ""; int position = 0; public int[] listArray = new int[1242]; public static int len = 0; public String[][] adapterCityList = new String[1242][3]; // Variables for passing intent data public static final String citieslist = "com.world.citieslist"; AppWidgetManager awm; Context c; int awID; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // Set the result to CANCELED. This will cause the widget host to cancel // out of the widget placement if they press the back button. setResult(RESULT_CANCELED); try { citylist = getCityList(); } catch (IOException e) { Log.e("Loading CityList", e.getMessage()); } for (int i = 0; i &lt; 1242; i++) { cities[i] = citylist[i][0]; } // Set the view layout resource to use. setContentView(R.layout.configure); c = ConfigureApp.this; Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { awID = extras.getInt( AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); } else{ finish(); } awm = AppWidgetManager.getInstance(c); cityList=(ListView)findViewById(R.id.CityList); // By using setAdpater method in listview we an add string array in list. cityList.setAdapter(new ArrayAdapter&lt;String&gt; (this,android.R.layout.simple_list_item_1, cities)); // cityList.setOnItemClickListener(cityListListener); cityList.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; av, View v, int pos, long id) { df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); String str = ((TextView) v).getText().toString(); RemoteViews remoteViews = new RemoteViews(c.getPackageName(), R.layout.widget); remoteViews.setTextViewText(R.id.mytext, str); remoteViews.setTextViewText(R.id.date, df.format(new Date())); Intent in = new Intent(c,clock.class); PendingIntent pi = PendingIntent.getActivity(c, 0, in, 0); remoteViews.setOnClickPendingIntent(R.id.Widget, pi); awm.updateAppWidget(awID, remoteViews); Intent result = new Intent(); result.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,awID); setResult(RESULT_OK, result); finish(); } }); } private String[][] getCityList() throws IOException { Context context = getApplicationContext(); InputStream instream = context.getResources().openRawResource(R.raw.cities_final); // if file the available for reading if (instream != null) { // prepare the file for reading InputStreamReader inputreader = new InputStreamReader(instream); BufferedReader buffreader = new BufferedReader(inputreader); while ((line = buffreader.readLine()) != null) { field = line.split(","); for (String x : field) { list[row][col] = x; col++; if (x != null) { country = x; } } list[row][2] = country; row++; col = 0; } for (int i = 0; (i &lt; list.length); i++) { for (int j = 0; (j &lt; 3); j++) { if (j == 1) { list[i][j] = list[i][j].substring(0, 6); } } } } return list; } </code></pre> <p>}</p> <p>Can I use my own custom view in the widget, apart from analog clock? Or is there any other way to show the clock? like use the Imageview as the clock face and to draw the dial according to the time? </p> <p>Please help me regarding this.!!!:(</p>
15,850,568
0
<p>Have you tried giving the full path to the mysqldump executable?</p>
21,807,011
0
<p>This is a standard way of traversing a <a href="http://en.wikipedia.org/wiki/Linked_list" rel="nofollow">linked list</a>. The loop terminates when p evaluates to false. In C anything that is not 0 evaluates to true. P is a pointer to a node of a linked list, it will become false when it is NULL. You can re-write this in a more clear fashion like this:</p> <pre><code>process_t *p; for(p = j-&gt;first_process; p != NULL; p = p-&gt;next) { ... } </code></pre>
24,479,427
0
<p>In this code you always display your query (you have echo at the beginning).</p> <p>In my opinion there are only 2 options:</p> <ol> <li><p>You use some type of PHP cache. If you do, you probably won't see <code>SELECT MAX(version) as version FROM stats</code> every time you refresh the page</p></li> <li><p>You don't display $v value right after this code is being executed. <code>$v</code> variable is for example used often in loops so it's quite possible you change the value in some other part of your code and that's why it's always 10.</p></li> </ol> <p>So what you should do you should :</p> <pre><code>echo $sql = "SELECT MAX(version) as version FROM stats"; $result = mysql_query($sql); $rr=mysql_fetch_array($result); $v = $rr["version"]; echo $v; </code></pre> <p>And make sure you see messages each time you refresh your page. If it's not displayed it means you use cache, otherwise you should see correct value here.</p> <p>Of course, you also shouldn't use <code>mysql</code> functions any more because mysql extendsion is deprecated. You should use mysqli or PDO instead.</p>
28,328,309
0
<pre><code>&lt;div ng-repeat="notMe in conversation.participants | filter:{user: { username: user.username } }"&gt; </code></pre> <p>Removed the [ ] and it works. </p>
19,052,308
0
<p>You cannot make change event just by setting value from javascript. Here is a sample by using trigger.</p> <pre><code> &lt;script&gt; $(document).ready(function () { $(".tbAdd_Sowner").on('change', function () { var owner = $('.tbAdd_Sowner').val(); $('.tbAdd_Sphone').val(owner); }); $(".aGetID").on('click', function () { var tbOwner = $('.tbAdd_Sowner'); var hidden1 = $('.Hidden1'); var hidden2 = $('.Hidden2'); var hidden3 = $('.Hidden3'); GalModalTOCCDialog(hidden1, tbOwner, hidden2, hidden3); }); function GalModalTOCCDialog(Hidden1, tbAdd_Sowner, Hidden2, Hidden3) { $(tbAdd_Sowner).val(' ').trigger('change'); } $('.tbAdd_Sowner').change(function () { $(this).removeAttr('disabled'); }); }); &lt;/script&gt; </code></pre> <p>Here is your code, removing those validators</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td align="right"&gt;Secondary Owner &lt;/td&gt; &lt;td&gt; &lt;input id="Hidden1" type="hidden" value="1" class="Hidden1" /&gt; &lt;asp:TextBox ID="tbAdd_Sowner" OnTextChanged="tbAdd_Sowner_TextChanged" CssClass="tbAdd_Sowner" AutoPostBack="true" runat="server" Enabled="false" &gt;&lt;/asp:TextBox&gt; &lt;input id="Hidden2" type="hidden" class="Hidden2" /&gt; &lt;input id="Hidden3" type="hidden" class="Hidden3" /&gt; &lt;a href="javascript:void(0)" id="aGetID" class="aGetID" &gt;Get User ID&lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="right"&gt;Secondary Owners&lt;/td&gt; &lt;td&gt; &lt;asp:TextBox ID="tbAdd_Sphone" runat="server" CssClass="tbAdd_Sphone" &gt;&lt;/asp:TextBox&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>Server side. </p> <pre><code>protected void tbAdd_Sowner_TextChanged(object sender, EventArgs e) { tbAdd_Sowner.Text = "123"; } </code></pre>
13,640,379
0
<p>Why wont you override a method like this:</p> <pre><code>class ListIteratingSystem { execute() { this.executeOnStart(); }; private executeOnStart() { throw new Error('This method is abstract'); }; }; class MySystem extends ListIteratingSystem { constructor (/*...*/) { super(); } private executeOnStart() { alert("derived"); }; } </code></pre> <p>execution of <code>new MySystem().execute();</code> displays alert.</p> <p>Unfortunately there is no nice way to make <code>executeOnStart</code> method <code>protected abstract</code> yet. This is a little bit counterintuitive but remember that visibility accessors are only for compilator and intelisence.</p>
30,845,227
0
How to get simple ForeignKey model working? (a list of class in another class) <p>I tried to figure this out on my own :( couldn't quite get there. Pls take pity. . .</p> <p>I'm trying to represent exercise data (a start time an end time and many--an undetermined number of-- heart rates)</p> <p>this is the model I have set up:</p> <pre><code>class HeartRate(models.Model): timestamp = models.DateTimeField('Date and time recorded') heartrate = models.PositiveIntegerField(default=0) def __str__(self): return prettyDate(self.timestamp) class Exercise(models.Model): start_timestamp = models.DateTimeField('Starting time') finishing_timestamp = models.DateTimeField('Finishing time') heartrate = models.ForeignKey(HeartRate) </code></pre> <p>I know from working with the admin that it seems only one HeartRate is selected for each Exercise so maybe my approach is all wrong. How do I correctly model this? And once modeled correctly how do I query all heart rates for each (all) Exercises. I know this is a noob move but I really tried for hours getting this to work and can't quite get a handle on the documentation. Thanks in advance.</p>
27,380,903
0
<p>Create a function which tries to find your text, and instead of raising an error, returns a string error message.</p> <pre><code>def safe_find(element, text, error_message): try: return element.find(text=re.compile(text)) except: return error_message </code></pre> <p>Then you can use this function to retrieve possibly missing fields, without any inline try-except clauses.</p> <pre><code>address = safe_find(house, '[0-9]{4}[ ]?[azAZ]{2}', "ERR No Address") </code></pre> <hr> <p>Edit: you could make the function slightly more extensible, accepting any parameter that <code>find</code> could take:</p> <pre><code>def safe_find(element, error_message, *args, **kargs): try: return element.find(*args, **kargs) except: return error_message safe_find(house, "ERR No Address", text=re.compile('[0-9]{4}[ ]?[azAZ]{2}')) safe_find(house, "ERR no street", "a", class_='object-street') safe_find(house, "ERR no street", "a", class_='object-street') safe_find(house, "ERR no number", 'span', title=re.compile('Number of')) safe_find(house, "ERR no WaitingFor", "span", title="WaitingFor") </code></pre> <p>... But you wouldn't be able to use this to access any attributes, such as <code>text</code> or <code>attrs['href']</code>.</p> <hr> <p>Edit edit: you could create a special object that has an error message for all the attributes you might possibly want to access.</p> <pre><code>import collections def safe_find(element, error_message, *args, **kargs): class FakeResult: def __init__(self, err): self.attrs = collections.defaultdict(lambda: err) self.text = err #todo: add other attributes here, like: #self.whatever = err try: return element.find(*args, **kargs) except: return FakeResult(error_message) safe_find(house, "ERR no street", "a", class_='object-street').text safe_find(house, "ERR no street", "a", class_='object-street').attrs['href'] safe_find(house, "ERR no number", 'span', title=re.compile('Number of')).text safe_find(house, "ERR no WaitingFor", "span", title="WaitingFor").text </code></pre> <p>However, this <em>only</em> works if you're going to access the <code>text</code> or <code>attrs</code> attributes. <code>safe_find(house, "ERR No Address", text=re.compile('[0-9]{4}[ ]?[azAZ]{2}'))</code> with no <code>.text</code> or <code>.attrs["stuff"]</code> following it will give you a FakeResult instance instead of a string.</p>
7,696,520
0
Why Javascript implementation of Bubble sort much faster than others sorting algorithms? <p>I have done some <a href="http://jsperf.com/sorting-algorithm-comparison" rel="nofollow">research</a> about Javascript sorting algorithms performance comparison, and found unexpected results. Bubble sort provided much better performance than others such as Shell sort, Quick sort and a native Javascript functionality. Why does this happen? Maybe I'm wrong in my performance testing method?</p> <p>You can find my research results <a href="http://jsperf.com/sorting-algorithm-comparison" rel="nofollow">here</a>.</p> <p>Here are some algorithm implementation examples:</p> <pre><code> /** * Bubble sort(optimized) */ Array.prototype.bubbleSort = function () { var n = this.length; do { var swapped = false; for (var i = 1; i &lt; n; i++ ) { if (this[i - 1] &gt; this[i]) { var tmp = this[i-1]; this[i-1] = this[i]; this[i] = tmp; swapped = true; } } } while (swapped); } /** * Quick sort */ Array.prototype.quickSort = function () { if (this.length &lt;= 1) return this; var pivot = this[Math.round(this.length / 2)]; return this.filter(function (x) { return x &lt; pivot }).quickSort().concat( this.filter(function (x) { return x == pivot })).concat( this.filter(function (x) { return x &gt; pivot }).quickSort()); } </code></pre>
28,385,256
0
<p>Thanks guys for the quick replies..Gabriel response gave me a good insight. However I stuck to Raphael Santos response. ...However, if Gabriel could kindly elaborate the point a bit more please...ok here is the fixed code</p> <pre><code>typedef struct rem_info { char ufrag[80]; char pwd[80]; unsigned comp_cnt; pj_sockaddr def_addr[PJ_ICE_MAX_COMP]; unsigned cand_cnt; pj_ice_sess_cand cand[PJ_ICE_ST_MAX_CAND]; }rem_info; void reset_rem_info(rem_info *prem) { pj_bzero(prem, sizeof(rem_info)); } int main() { rem_info prem; reset_rem_info(&amp;prem); return 0; } </code></pre> <p>The change got rid of the warnings and the segmentation dump...</p> <p>THANKS A LOT GUYSSS</p>
28,447,009
0
<p>The <code>OutOfMemoryException</code> is almost certainly coming from the JSON serialization of your <code>Customer</code> object. As such, the issue isn't one of NEST or Elasticsearch functionality, but of JSON.NET functionality.</p> <p>You could handle this in one of two ways:</p> <p><strong>1. Serialize the large object selectively</strong></p> <p><a href="http://james.newtonking.com/archive/2009/10/23/efficient-json-with-json-net-reducing-serialized-json-size" rel="nofollow">This article</a> by the author of JSON.NET discusses reducing the size of objects. You might furnish properties with the <a href="http://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_JsonIgnoreAttribute.htm" rel="nofollow">JsonIgnoreAttribute property</a> to instruct the serializer to ignore certain properties. Or an implementation of <a href="http://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_Serialization_IContractResolver.htm" rel="nofollow">IContractResolver</a> may be less intrusive on the definitions of your EF objects (especially given that they're database-first generated), but I'm not sure whether this can be used in conjunction with the NEST dependency on JSON.NET.</p> <p>If you're out of options for dealing with NEST's dependency on JSON.NET, you could always find another way to serialize your object and "go raw" by using the Elasticsearch.NET syntax instead of NEST (which essentially builds on-top of Elasticsearch.NET). So instead of a call to <code>ElasticClient.Index(..)</code>, make a call to <code>ElasticClient.Raw.Index(..)</code>, where the <code>body</code> parameter is a JSON string representation (of your own construction) of the object you wish to index.</p> <p><strong>2. Project the large object to a smaller data transfer object</strong></p> <p>Instead of indexing a <code>Customer</code> object, map only the properties you want to index into a data transfer object (DTO) that targets your Elasticsearch schema / document type.</p> <pre><code>foreach (Customer c in db.Customer.Where(a =&gt; a.Active == true)) client.Index(new MyElasticsearchTypes.Customer() { CustomerId = c.CustomerId, CustomerName = c.CustomerName, Description = c.Description }); </code></pre> <p>In C#, you've got a lot of options for how to handle creation of such a DTO, including:</p> <ol> <li>Explicitly typed objects with manual mapping (like my example).</li> <li>Explicitly typed objects with a mapping tool like <a href="https://www.nuget.org/packages/AutoMapper/" rel="nofollow">AutoMapper</a>.</li> <li>Dynamic objects.</li> </ol> <p><strong>Flat by design</strong></p> <p>Be aware that using Elasticsearch isn't a case of simply throwing your data into "the index". You need to start thinking in terms of "documents", and come to terms with what that means when you're trying to index data that has come from a relational database. The Elasticsearch guide article <a href="http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/data-in-data-out.html" rel="nofollow">Data In, Data Out</a> is a good place to start reading. Another article called <a href="http://www.elasticsearch.org/blog/managing-relations-inside-elasticsearch/" rel="nofollow">Managing relations inside Elasticsearch</a> is particularly relevant to your situation:</p> <blockquote> <p>At it's heart, Elasticsearch is a flat hierarchy and trying to force relational data into it can be very challenging. Sometimes the best solution is to judiciously choose which data to denormalize, and where a second query to retrieve children is acceptable</p> </blockquote>
7,595,632
0
VS11 Dev Preview Unit Test Explorer doesn’t show Unit Tests <p>I wonder has anyone come across with this issue where the MSTest Unit Test doesn’t show up in the new Unit Test Explorer.</p> <p>I’m running Windows 7 (32bit). I downloaded the VS11 Developer Preview from the link below. <a href="http://www.microsoft.com/download/en/details.aspx?id=27543">http://www.microsoft.com/download/en/details.aspx?id=27543</a></p> <p>I created a sample C# Console App, and add the Test Library from the MSTest project template. Then I created a sample Unit Test, and rebuild the solution. When I open the Test Explorer (View->OtherWindows->UnitTest Explorer) I do not see any tests loaded.</p> <p>I only see a message saying… “No test discovered. Please build your project and ensure the appropriate test framework adapter is installed”.</p> <p>I assume the MSTest adapter is automatically installed. If not I’m not even sure how to install an adapter. </p> <p>I could be missing something here but I cannot figure it out. Has anyone experiencing this issue?</p>
24,671,738
0
<p>To set the composer autoloader you can create a target as:</p> <pre><code>&lt;target name="require.autoload"&gt; &lt;adhoc&gt;&lt;![CDATA[ require_once 'lib/composer/autoload.php'; ]]&gt;&lt;/adhoc&gt; &lt;/target&gt; </code></pre> <p>Then all the targets that need autoloader, has this requirement</p> <pre><code> &lt;target name="test.coverage.html" depends="require.autoload"&gt; </code></pre> <p>Note: require once the file placed in</p> <pre><code>"config": { "vendor-dir": "lib/composer" </code></pre>
23,352,587
0
<p>This is a <strong>ViewEngine</strong> Pattern. Both webforms as sjf use xhtml tags that render the html content in result</p>
26,692,442
0
<p>To quote <a href="http://dev.mysql.com/doc/refman/5.5/en/case-sensitivity.html" rel="nofollow">the documentation</a>:</p> <blockquote> <p>The default character set and collation are latin1 and latin1_swedish_ci, so nonbinary string comparisons are case insensitive by default. This means that if you search with col_name LIKE 'a%', you get all column values that start with A or a. To make this search case sensitive, make sure that one of the operands has a case sensitive or binary collation. For example, if you are comparing a column and a string that both have the latin1 character set, you can use the COLLATE operator to cause either operand to have the latin1_general_cs or latin1_bin collation</p> </blockquote> <p>You can overcome this by explicitly using a case sensitive collation:</p> <pre><code>select * from names where name='Bill' COLLATE latin1_general_cs </code></pre>
1,856,992
0
<p>Hey, someone has implemented a module to do this, and it works in Netbeans 6.5.1 - perfect for you. I'm hanging out to see an equivalent for 6.7.1. Maybe they should add it to 6.8!</p> <p><a href="http://wiki.netbeans.org/JavaGoToImplementation" rel="nofollow noreferrer">http://wiki.netbeans.org/JavaGoToImplementation</a></p> <p>Go To Implementation is built in for recent versions of NetBeans. Look in the Navigate context menu.</p>
13,996,296
0
<p>Alternatively, if your implementation of <code>grep</code> supports it, you could use</p> <pre><code>grep -m 10 PATTERN FILE </code></pre> <p>Partial description from: <code>man grep</code> on Ubuntu 12.04</p> <pre><code>-m NUM, --max-count=NUM Stop reading a file after NUM matching lines. </code></pre> <p>This option was also available on my Red Hat 5.8 box where I was having a similar issue.</p>
5,635,065
0
<p>Without knowing exactly how this should work I can say that you write outside of the <code>p</code> vector on </p> <pre><code> for (i=0; i &lt; rptr-&gt;n; i++) { lptr-&gt;keys[lptr-&gt;n + 1 + i] = rptr-&gt;keys[i]; // When you delete key 84, rptr-&gt;n is 4 at one point which takes you outside // p[M] lptr-&gt;p[lptr-&gt;n + 2 + i] = rptr-&gt;p[i+1]; } </code></pre> <p>Valgrind is a good tool to use, and I found this problem by <code>valgrind -v --leak-check=full &lt;your executable&gt;</code></p>
19,059,223
0
<p>The error occurs because when the class body executes the Bid class object has not yet been created.</p> <p>You cannot have a model class contain a substructure of the same class -- it would result in infinite space. A StructuredProperty <em>physically</em> includes the fields of another model in the current model.</p> <p>So I recommend deleting the StructuredProperty line.</p> <p>You will then get a similar error on the KeyProperty line, but for KeyProperty it can be fixed by using a string ('Bid') instead of a direct class reference (Bid).</p> <p>You'll have to use outbyd_by_key.get() to access the bid's contents.</p>
31,927,790
0
Unable to Open/Install Git on Windows 10 <p>When I open the file I downloaded from <a href="https://git-scm.com/download" rel="nofollow">https://git-scm.com/download</a> and then Windows, nothing happens. I've tried running it as a normal user and administrator but nothing happens. Not even a processor in the Task Manager opens.</p> <p>What could cause this? Is it because Git hasn't been updated for Windows 10 yet, or is it something else? I just did a clean install of Windows 10.</p>
4,441,276
0
How do you make tooltip show up for longer in IE <p>i got the following</p> <pre><code>&lt;span id="pageLink" style="cursor:pointer;" onClick="...." title="&lt;%=pHelper.getNameToolTip()%&gt;"&gt; </code></pre> <p>in firefox the tooltip stays there until the mouse is moved, but in IE it only stays there for about 5seconds and disappears.</p> <p>is there a way to make it last longer?</p>