pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
14,790,223 | 0 | <p>You almost get the answer from <strong>Matthew</strong>, all you need to do is to add cast :</p> <pre><code>Select CAST(SUM(timediff(timeOut, timeIn)) as time) as totalhours FROM volHours WHERE username = 'skolcz' </code></pre> |
24,761,177 | 0 | <p>That's not gonna work. What I would do is creating a block in layout that should contain boxes and then embed the boxes in page1.twig and page2.twig.</p> <p>The embed tag works exactly like include with added benefit of allow extending the blocks defined in the embedded template. What you get after embedding doesn't contain blocks.</p> |
34,952,550 | 0 | Boost Spirit Qi : Is it suitable language/tool to analyse/cut a "multiline" data file? <p>I want to apply various operations to data files : algebra of sets, statistics, reporting, changes. But the format of the files is far from code examples and a bit weird. There are differents sorts of items, items type, and some of them are put together as a collection. There is a simplistic example below.<br> I'm new in boost::spirit and I have tried coding to split the items and get basic informations (name, version, date) required for most of treatments. Eventually it seems tricky for me. <em>Is the problem my lack of skills or boost::spirit is not suitable to this format?</em><br> Studying boost::spirit is not a waste of time, I am sure to use it later. But I didn't find examples of code like mine, I may not go the right way.</p> <pre><code>>>>process_type_A //name(typeA_1) //version(A.1.99) //date(2016.01.01) //property1 "pA11" //property2 "pA12" //etc_A_1 (thousand of lines - a lot are "multiline" and/or mulitline sub-records) <<<process_type_A >>>process_type_A //name(typeA_2) //version(A.2.99) //date(2016.01.02) //property1 "pA21" //property2 "pA22" //etc_A_2 (hundred or thousand of lines) <<<process_type_A >>>process_type_B //name(typeB_1) //version(B.1.99) //date(2016.02.01) //property1 "pB11" //property2 "pB12" //etc_B_1 (hundred or thousand of lines) <<<process_type_B >>>paramset_type_C //>>paramlist ////name(typeC_1) ////version(C.1.99) ////date(2016.03.01) ////property1 "pC11" ////property2 "pC12" ////etc_C_1 (hundred or thousand of lines) //<<paramlist //>>paramlist ////name(typeC_2) ////version(C.2.99) ////date(2016.04.01) ////property1 "pC21" ////property2 "pC22" ////etc_C_2 (hundred or thousand of lines) //<<paramlist <<<paramset_type_C </code></pre> <p>Code::Blocks<br> Boost 1.60.0<br> GCC Compiler on Windows and Linux</p> |
2,601,346 | 0 | <p><a href="http://hsqldb.org/web/hsqlFeatures.html" rel="nofollow noreferrer">HSQL</a> also provides support for interpreting csv files as <code>ResultSet</code>s.</p> |
24,099,151 | 0 | <p><a href="http://swift-lang.org/tryswift/" rel="nofollow">http://swift-lang.org/tryswift/</a> doesn't look like it's anything to do with Apple Swift. The "try Swift" page you're using is for <a href="https://en.wikipedia.org/wiki/Swift_%28parallel_scripting_language%29" rel="nofollow">Swift</a>, not <a href="https://en.wikipedia.org/wiki/Swift_%28Apple_programming_language%29" rel="nofollow">Swift</a>.</p> <p>Note that Apple's has the stylised <a href="https://en.wikipedia.org/wiki/Swift" rel="nofollow">swift</a> in its logo heading downwards; the parallel scripting language Swift is heading upwards :)</p> <p>To try Apple's Swift in a similar way, you'll need the Xcode 6 beta and a "playground" file.</p> |
13,219,045 | 0 | <p>Whether or no a thread can process a timer callback within its own context depends entirely on how the timer expiry can be communicated to the thread. The thread must call the callback itself upon the receipt of some inter-thread comms, (eg. a WM_TIMER message received by a Windows GUI thread when it is waiting on its Windows message queue input). If the thread is not waiting for input, it cannot handle any inter-thread comms from any kind of timer and so cannot call any timer-handler callback within its own context.</p> <p>Forms.Timer, the C++ builder Timer component and other such are ways of arranging for interval-based inter-thread notifications - if a thread does not actively wait for and handle those notifications, there can be no timer callback in the context of that thread.</p> |
2,239,266 | 0 | Unit Testing Machine Learning Code <p>I am writing a fairly complicated machine learning program for my thesis in computer vision. It's working fairly well, but I need to keep trying out new things out and adding new functionality. This is problematic because I sometimes introduce bugs when I am extending the code or trying to simplify an algorithm.</p> <p>Clearly the correct thing to do is to add unit tests, but it is not clear how to do this. Many components of my program produce a somewhat subjective answer, and I cannot automate sanity checks.</p> <p>For example, I had some code that approximated a curve with a lower-resolution curve, so that I could do computationally intensive work on the lower-resolution curve. I accidentally introduced a bug into this code, and only found it through a painstaking search when my the results of my entire program got slightly worse.</p> <p>But, when I tried to write a unit-test for it, it was unclear what I should do. If I make a simple curve that has a clearly correct lower-resolution version, then I'm not really testing out everything that could go wrong. If I make a simple curve and then perturb the points slightly, my code starts producing different answers, even though this particular piece of code really seems to work fine now.</p> |
35,875,484 | 0 | ember adapter url - find by id pattern - nested api resources <p>I've got an api with specific url structure. How do I pass the ID to the url string using an adapter or something? There's only one model, <code>patient</code> but I need to query each of these items plus more. I've seen where you can place the id at the end of the url, but I'm not sure how to build an additional string to a find query. Thanks!</p> <p>GET: <code>/api/v1/me/patients/{id}</code></p> <p>GET: <code>/api/v1/me/patients/{patient_id}/public_number</code></p> <p>This is what the model has in it:</p> <pre><code>/models/patient.js export default DS.Model.extend({ public_number: DS.attr('string') }); </code></pre> |
16,468,270 | 0 | <p>In Scala, a <code>List</code> is of immutable length. It can work like a <code>LIFO</code> (last in, first out) structure, but it cannot behave like a Java <code>ArrayList</code>.</p> <p>You are doing this:</p> <pre><code>val lst = List[Int]() </code></pre> <p>which gives your <code>lst</code> a size of <code>0</code>. It means you can't really do anything with it.</p> <p>For a mutable collection, use <code>ListBuffer</code>.</p> <p>Also, the <code>::</code> operator is right associative, which means it will be called on the object found on the right side of the operator.</p> <pre><code>val lst = ListBuffer[Int]() for (i <- 0 until 100) { lst += i // will add to the tail. } </code></pre> |
38,799,961 | 0 | <p>I recommend this. If you have a emulator preview connected first go inside Android Wear app to the emulator and choose FORGET.</p> <p>Later use the commands all are using</p> <pre><code>adb forward tcp:4444 localabstract:/adb-hub adb connect localhost:4444 </code></pre> <p>That work for me.</p> |
40,584,251 | 0 | Azure portal metrics weird numbers <p>I'm trying to view our peak bytes received/sec count for an eventhub in order to scale it properly. However, the portal is showing vastly different results from the "daily" view to the "hourly" view. This is the graph using the "hourly" view: <a href="https://i.stack.imgur.com/EU76Z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EU76Z.png" alt="enter image description here"></a></p> <p>From here, it looks like I'm peaking at around 2.5 MB/s. However, if I switch to the "daily" view, the numbers are vastly different: <a href="https://i.stack.imgur.com/S3YeP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S3YeP.png" alt="enter image description here"></a></p> <p>So I can't make sense of this. It's the exact same counter, showing vastly different results. Anyone know if the Azure portal performs any "adding" or similar? </p> <p>Edit: Notice that the counter is "bytes received per second". It shouldn't matter if I look at the hourly or daily view, the number of items per second shouldn't be affected by that (tho it clearly is).</p> |
2,452,979 | 0 | <p>I assume that on page load, you are setting up var sncro=1; and when some data changes, you adjust this value. Here is the quick check:</p> <pre><code>window.onbeforeunload = function (evt) { if (sncro != 1) { var message = 'Are you sure you want to leave, cause there are some unsaved changes?'; if (typeof evt == 'undefined') { evt = window.event; } if (evt ) { evt.returnValue = message; } return message; } } </code></pre> |
3,876,476 | 0 | Unit Testing in .Net with Endeca Objects <p>Most or all of Endeca's objects have internal constructors. I'm working on a good project that lacks great test coverage around the Endeca API, are there any good strategies to unit testing the interactions with Endeca?</p> <p>So far the best we have is kind of a poor man's adapter pattern:</p> <pre><code>public class DimValue : IDimValue { public DimValue(Dimension dim, DimVal dimValue) { Dimension = dim; Value = dimValue; } public virtual bool IsNavigable() { return Value.IsNavigable(); } public virtual long Id() { return Value.Id; } // and so on... } </code></pre> <p>We can then mock our own type, DimValue. Is this the best way to keep their API as testable as can be? Or is there another method that is preferred to this?</p> |
28,882,718 | 0 | <p>To get the next object, first filter to get all objects with a higher priority:</p> <pre><code>objects = MyObjects.objects.filter(priority__gt=12) </code></pre> <p>then order the results by priority:</p> <pre><code>objects = objects.order_by('priority') </code></pre> <p>finally select the first item in the queryset:</p> <pre><code>next_obj = objects.first() </code></pre> <p>Putting it together:</p> <pre><code>next_obj = MyObjects.objects.filter(priority__gt=12).order_by('priority').first() </code></pre> <p>Getting the previous object is similar, but you need to order in reverse:</p> <pre><code>prev_obj = MyObjects.objects.filter(priority__lt=12).order_by('-priority').first() </code></pre> <p>Note that <a href="https://docs.djangoproject.com/en/1.7/ref/models/querysets/#django.db.models.query.QuerySet.first" rel="nofollow"><code>first()</code></a> can return <code>None</code> if there are no objects in the queryset (in your case, that means the current object has the highest or lowest priority in the list). If the same priority can appear more than once, you might want to adjust the code to use <a href="https://docs.djangoproject.com/en/1.7/ref/models/querysets/#gte" rel="nofollow"><code>gte</code></a> and <a href="https://docs.djangoproject.com/en/1.7/ref/models/querysets/#lte" rel="nofollow"><code>lte</code></a>.</p> |
12,788,738 | 0 | <p>The h values need to be adjusted for the three cases prior to calculating the cos values dependent on them. i.e.:</p> <pre><code> if(h<(2.0f*pi/3.0f)){ y = in*( 1.0f + (s*cos(h) / cos(pi/3.0f-h)) ); b = x; r = y; g = z; }else if(h<(4.0f*pi/3.0f)){//&&2pi/3<=h h -= 2*pi/3; y = in*( 1.0f + (s*cos(h) / cos(pi/3.0f-h)) ); r = x; g = y; b = z; }else{ //less than 2pi && 4pi/3<=h h -= 4*pi/3; y = in*( 1.0f + (s*cos(h) / cos(pi/3.0f-h)) ); g = x; b = y; r = z; } </code></pre> <p>You will also need to make sure that none of the rr,gg,bb values end up outside the 0..255 interval:</p> <pre><code>if (rr < 0) rr = 0; if (rr > 255) rr = 255; </code></pre> <p>... etc</p> |
17,434,988 | 0 | <p>In your .htaccess, add the following for each type of file type:</p> <p><code>AddType application/zip .zip</code></p> <p>See: <a href="http://www.htaccess-guide.com/adding-mime-types/" rel="nofollow">http://www.htaccess-guide.com/adding-mime-types/</a> </p> |
17,126,869 | 0 | <p>Following on @Arun's comment, you can easily create a single data frame with another column indicating the party in question: </p> <pre><code>A = read.table(text="item Alice Bob apples 3 7 pears 1 2 cookies 10 4 grapes 238 483 watermelon 0 1", header=T) B = read.table(text="item Alice Bob grapes 13 26", header=T) C = read.table(text="item Alice Bob beef 1 3 rice 1 2 apples 1 0", header=T) Z = read.table(text="item Alice Bob rice 2 1 grapes 10 15 watermelon 1 0 beef 0 2", header=T) A$party = "A"; B$party = "B"; C$party = "C"; Z$party = "Z" dframe = rbind(A, B, C, Z) </code></pre> <p>From there, you can get functions of the columns without difficulty: </p> <pre><code>apply(dframe[,2:3], 2, sum) </code></pre> <p>If you wanted to deal with individual items, and they had duplicates between the parties, you could perform <a href="http://en.wikipedia.org/wiki/Join_%28SQL%29" rel="nofollow">joins</a> on the original data frames. There's an SO thread on doing this in R <a href="http://stackoverflow.com/questions/1299871/how-to-join-data-frames-in-r-inner-outer-left-right/1300618#1300618">here</a>. </p> |
4,842,429 | 0 | <p>You (probably) can't communicate in a <em>cross-platform</em> (and cross-browser) way from a web client to a local process, in any other way than you could with a web service.</p> <p>In other words, I think your main idea is the way to go - set up a local HTTP server that will serve the client, and then have that process also communicate with whatever remote services you may need. Perhaps you can find a lightweight Java-based HTTP server that can run your local process with GWT-RPC code inside it to minimize the changes to your current code.</p> |
780,863 | 0 | <p>The <a href="http://nhibernate.info" rel="nofollow noreferrer">nhibernate.info</a> website has lot of docs.</p> |
35,179,719 | 0 | <p>you need both <code>hidden.bs.collapse</code> and <code>shown.bs.collapse</code></p> <pre><code>$(document).ready(function() { function toggleChevron(e) { $(e.target) .prev('.panel-heading') .find("i") .toggleClass('fa-question fa-angle-up'); } $('#accordion').on('hidden.bs.collapse shown.bs.collapse', toggleChevron); }); </code></pre> <p><a href="https://jsfiddle.net/BG101/pmadwvpk/8/" rel="nofollow"><strong>FIDDLE</strong></a></p> |
16,732,621 | 0 | JSON Mapping in my Spring MVC 3.2 Application Works for Only One of My Methods <p>I am working on a Spring 3.2 MVC application. It's setup fairly typically, but my problem is that I am getting a 406 status error when I attempt to return a JSON object from my controller methods. </p> <p>The frustrating part is that I get that response from the server from all but one of my methods. The code I have included is a modified Spring MVC json example I found on the web. The sample's controller method with the path variable works as expected, but the additional methods that I added to the controller do not.</p> <p>The only other change I made to the sample code occurs in the pom. I upgraded the jackson dependency to the latest version.</p> <p>So what am I missing? I have the jackson mapper jars on my classpath. I'm using the <code><mvc:annotation-driven /></code> directive in my servlet and I'm using the <code>@ResponseBody</code> annotation with each of my controller methods.</p> <p>Any help would be greatly appreciated!</p> <p>Dispatcher servlet:</p> <pre><code> <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <context:component-scan base-package="uk.co.jeeni" /> <mvc:annotation-driven /> </beans> </code></pre> <p>pom.xml:</p> <pre><code> <?xml version="1.0" encoding="UTF-8"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <groupId>uk.co.jeeni</groupId> <artifactId>spring-json</artifactId> <version>1.0.0</version> <packaging>war</packaging> <name>Spring 3 MVC JSON Example</name> <properties> <spring.version>3.2.1.RELEASE</spring.version> </properties> <dependencies> <!-- Jackson mapper is used by spring to convert Java POJOs to JSON strings. --> <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-mapper-asl</artifactId> <version>1.9.12</version> </dependency> <!-- START: Spring web --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <!-- END: Spring web --> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.1</version> </plugin> </plugins> <finalName>spring-mvc-json</finalName> </build> </code></pre> <p></p> <p>Controller:</p> <pre><code> package uk.co.jeeni; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @Controller public class JsonService { private static Map<String, Person> data = new HashMap<String, Person>(); static{ data.put("ADAM", new Person("Adam", "Davies", 42)); data.put("JANE", new Person("Jane", "Harrison", 35)); } @RequestMapping(value="{name}", method = RequestMethod.GET) public @ResponseBody Person getPerson(@PathVariable String name){ Person p = new Person(name, name, 105);//data.get(name.toUpperCase()); return p; } @RequestMapping(value="/testJson.html", method=RequestMethod.GET) public @ResponseBody List<Person> testJson() { List<Person> people = new ArrayList<Person>(); for(int i=0;i<10;i++) { Person p = new Person("Firstname", "Lastname", i); people.add(p); } return people; } @ResponseBody @RequestMapping(value="testJsonPojo.html", method=RequestMethod.GET) public Person testJsonPojo() { Person individual = new Person("Firstname", "Lastname", 105); return individual; } } </code></pre> <p>Person.java:</p> <pre><code> package uk.co.jeeni; public class Person { private String firstName; private String lastName; private int age; public Person(String firstName, String lastName, int age) { this.firstName = firstName; this.lastName = lastName; this.age = age; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } } </code></pre> |
21,991,956 | 0 | <p>In your case, we decided to expose our web app functionality as web services, because of:</p> <ul> <li>The client code is easily generated by your favorite WS library</li> <li>The server code is just an annotated POJO and every stub is generated by the same library (say you can choose CXF for both things but there are plenty of options)</li> <li>Security and operations people agreeded instantly to our proposal since functionality was exposed to the exterior through the corporative https security (exactly the same as our web application was doing)</li> </ul> <p>The kind of web services you use depends on your requirements: people normally expose their API as a REST api, which is more or less an http CRUD wrapper over your application entities. You can use standard SOAP web services, which is more of a procedural point of view. </p> <p>Up to you to decide, I hope this was useful</p> |
15,538,626 | 0 | add column dynamically to handsontable <p>I am trying to dynamically add a column to a handsontable. I don't see a sample anywhere nor o i see a method to do so in the API. Has anyone figured out a way to overcome this or have some sample code that I can look at that would help. </p> <p>Thank you.</p> |
422,156 | 0 | What would be a good framework to develop a web application for guitar software? <p>I would love to design a web application for a guitar tablature editor. There are a few desktop apps such as Guitar Pro and Tuxguitar that are great. They basically allow you to load a tablature file, and then the software allows you to edit and play the tablature. What would be even better would be a web-based version of these programs.</p> <p>Tuxguitar is open source and would serve as a good frame of reference. It is designed in Java and uses SWT gui components. Would there be an ideal framework for developing a fairly complex web application using languages/technologies similar to these?</p> <p>Any caveats in terms of developing such a complex sound-based web application?</p> |
35,649,112 | 0 | <p>Since Android 6 there is a Backup API. See <a href="http://developer.android.com/training/backup/autosyncapi.html" rel="nofollow">http://developer.android.com/training/backup/autosyncapi.html</a></p> |
15,088,343 | 0 | <p><a href="http://msdn.microsoft.com/en-us/library/system.net.sockets.tcpclient.getstream.aspx" rel="nofollow">TcpClient.GetStream()</a> will throw an exception if the socket is not or no longer connected.</p> <p>Wrap the code in a try..catch block:</p> <pre><code>try { NetworkStream networkStream = clientSocket.GetStream(); networkStream.Read(bytesFrom, 0, 312); dataFromClient = Encoding.ASCII.GetString(bytesFrom); string hex = BitConverter.ToString(bytesFrom).Replace("-",""); Console.WriteLine("\n " + hex + "\n_______________()()()______________"); } catch (InvalidOperationException ioex) { // The TcpClient is not connected to a remote host. } catch (ObjectDisposedException odex) { // The TcpClient has been closed. } </code></pre> |
2,542,265 | 0 | <p>Ari,</p> <p>A good reference to how to accomplish "invisible" instance variable declarations can <a href="http://cocoawithlove.com/2010/03/dynamic-ivars-solving-fragile-base.html" rel="nofollow noreferrer">be found here</a> with credit respectfully given to Matt Gallagher.</p> <p>Hope it helps, Frank</p> |
40,379,264 | 0 | How to cancel replica request through softlayer API <p>I have setup of replication, where i have source volume at one site & replica at another site. Now i want to cancel the replica request through Softlayer python API.(not through portal) I have checked there are 2 services related to billing;</p> <pre><code>SoftLayer_Billing_Item::cancelItem SoftLayer_Billing_Item_Cancellation_Request::createObject </code></pre> <p>Which service i should use & how? Can someone please help me to get that API. </p> |
7,055,612 | 0 | functions in update panel <pre><code><asp:UpdatePanel ID="UpdatePanel10" runat="server"> <ContentTemplate> <center> <asp:GridView ID="gridInboxMessage" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="LinqDataSource1" OnSelectedIndexChanged="gridInboxMessage_SelectedIndexChanged" onrowdeleted="gridInboxMessage_RowDeleted" onrowdeleting="gridInboxMessage_RowDeleting"> <Columns> <asp:CommandField ShowSelectButton="True" SelectText="show text" /> <asp:TemplateField > <ItemTemplate> <asp:Button ID="btnDeleteInbox" Text="delete" OnClick="btnDeleteInbox_Click" runat="server" /> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="Row" HeaderText="row" ReadOnly="True" SortExpression="Row" /> <asp:TemplateField SortExpression="Body" HeaderText="متن"> <ItemTemplate> <asp:Label ID="MyBody" runat="server" Text='<%# TruncateText(Eval("Body"))%>'> </asp:Label> <asp:Label ID="fullBodyRecieve" Visible="false" runat="server" Text='<%# Eval("Body")%>'> </asp:Label> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> <asp:LinqDataSource ID="LinqDataSource1" AutoSort="true" runat="server" ContextTypeName="DataClassesDataContext" Select="new (Row,Title, Body, Sender, Date1)" TableName="PrivateMessages" Where="Receptor == @Receptor" ondeleted="LinqDataSource1_Deleted" ondeleting="LinqDataSource1_Deleting"> <WhereParameters> <asp:QueryStringParameter Name="Receptor" QueryStringField="idCompany" Type="String" /> </WhereParameters> </asp:LinqDataSource> </ContentTemplate> </asp:UpdatePanel> </code></pre> <hr> <pre><code> protected void btnDeleteInbox_Click(object sender, EventArgs e) { GridViewRow row = gridInboxMessage.SelectedRow; var inboxMessage = (from b in dc.PrivateMessages where b.Row.ToString() == row.Cells[0].Text select b).Single(); dc.PrivateMessages.DeleteOnSubmit(inboxMessage); dc.SubmitChanges(); } </code></pre> <p><code>btnDeleteInbox_Click</code> doe not work??This method is never executed</p> <pre><code>protected void gridInboxMessage_RowDeleted(object sender, GridViewDeletedEventArgs e) { GridViewRow row = gridInboxMessage.SelectedRow; var inboxMessage = (from b in dc.PrivateMessages where b.Row.ToString() == row.Cells[0].Text select b).Single(); dc.PrivateMessages.DeleteOnSubmit(inboxMessage); dc.SubmitChanges(); } </code></pre> <p><code>gridInboxMessage_RowDeleted</code> doe not work??This method is never executed</p> <pre><code>protected void gridInboxMessage_RowDeleting(object sender, GridViewDeleteEventArgs e) { GridViewRow row = gridInboxMessage.SelectedRow; var inboxMessage = (from b in dc.PrivateMessages where b.Row.ToString() == row.Cells[0].Text select b).Single(); dc.PrivateMessages.DeleteOnSubmit(inboxMessage); dc.SubmitChanges(); } </code></pre> <p><code>gridInboxMessage_RowDeleting</code> doe not work??This method is never executed</p> |
20,937,864 | 0 | How to do an accent insensitive grep? <p>Is there a way to do an accent insensitive search using grep, preferably keeping the --color option ? By this I mean <code>grep --secret-accent-insensitive-option aei</code> would match àei but also äēì and possibly æi.</p> <p>I know I can use <code>iconv -t ASCII//TRANSLIT</code> to remove accents from a text, but I don't see how I can use it to match since the text is transformed (it would work for grep -c or -l) </p> |
16,599,481 | 0 | <p>Since you want to update a part of the page you will need to use ajax to accomplish that. You have two options there:</p> <ol> <li><p>User @Ajax.ActionLink (<a href="http://stackoverflow.com/questions/7295835/how-can-i-load-partial-view-inside-the-view">How can i load Partial view inside the view</a>)</p></li> <li><p>You can write your own jquery ajax request that invokes your controller method and returns the partial view.</p></li> </ol> |
40,578,500 | 0 | <p>you can append text into slide item with images</p> <p>For example, slider item template:</p> <pre><code><div><!-- slide 1 --> <img src=""> <p>text</p> </div> <div><!-- slide 2 --> <img src=""> <p>text2</p> </div> </code></pre> <p>See on fiddle <a href="http://jsfiddle.net/uktry43n/4/" rel="nofollow noreferrer">http://jsfiddle.net/uktry43n/4/</a></p> |
36,921,291 | 0 | <p>You're writing the updated document text to <code>StreamWriter sw</code> but then not doing anything with it. You are then setting the session variable to your original, unedited byte array <code>memoryStream</code> (which is presumably why you're returning a document with no changes).</p> <p>You need to convert <code>sw</code> to a byte array and put that in <code>Session["ByteArray"]</code> instead.</p> <p>Also, a large byte array in a session variable does not seem like a terribly good idea.</p> |
22,185,121 | 0 | Are @@variables in a Ruby on Rails controller specific to the users session, or are all users going to see the same value? <p>I have a controller in which there is a "viewless" action. That controller is used to set a variable called <code>@@ComputedData={}</code>. But the data is computed based on a csv file a user of the application uploaded. Now are users going to see their specific data or will the <code>@@ComputeData</code> be the same for all users? Could someone explain me this concept? I'm really shaky on it. Thank you in advance and sorry for the noob question. </p> |
1,750,786 | 0 | In nHibernate, can I map an abstract base class to a collection? <p>I have a base class for content items in a CMS I'm building. It's currently marked abstract because I only want derived classes to be instantiated. Derived classes like BlogPost, Article, Photo, etc. are set up as a joined subclass to my ContentBase class in nHibernate.</p> <p>I'm trying to set up a many-to-many mapping between this class and a Tag class. I want to have a collection of Tags on the ContentBase class, and a collection of ContentBase items on the tag class.</p> <p>Will nHibernate allow me to map the abstract ContentBase class as a collection on the Tag class? I'm assuming not since it wouldn't be able to instantiate any instances of this class when reconstituting a Tag entity from the db. I really don't want to have to have to use a collection of content items per type (e.g. TaggedBlogPosts, TaggedArticles, etc.) on the Tag class.</p> <p>The whole reason I'm doing this is because logically, a content item can have many tags, and 1 tag can belong to multiple content items. in order for nHibernate to manage the relationships for me in a mapping table, I believe I have to set up a many-to-many association and add the Tag to the ContentBase.Tags collection and then the content item to the Tags.TaggedContentItems collection before the mapping table entry is created in nHibernate.</p> <p>Here are my mappings for reference:</p> <pre><code> <class name="CMS.Core.Model.Tag,CMS.Core" table="bp_Tags"> <id column="TagName" name="TagName" type="String" unsaved-value=""> <generator class="assigned" /> </id> <bag name="_taggedContentList" table="bp_Tags_Mappings" inverse="true" cascade="save-update" lazy="true"> <key column="TagName" /> <many-to-many class="CMS.Core.Model.ContentBase,CMS.Core" column="Target_Id" /> </bag> </class> <class name="CMS.Core.Model.ContentBase,CMS.Core" table="bp_Content"> <id name="Id" column="Id" type="Int32" unsaved-value="0"> <generator class="native"></generator> </id> <property name="SubmittedBy" column="SubmittedBy" type="string" length="256" not-null="true" /> <property name="SubmittedDate" column="SubmittedDate" type="datetime" not-null="true" /> <property name="PublishDate" column="PublishDate" type="datetime" not-null="true" /> <property name="State" column="State" type="CMS.Core.Model.ContentStates,CMS.Core" not-null="true" /> <property name="ContentType" column="ContentType" type="CMS.Core.Model.ContentTypes,CMS.Core" not-null="true" /> <bag name="_tagsList" table="bp_Tags_Mappings" lazy="false" cascade="save-update"> <key column="Target_Id" /> <many-to-many class="CMS.Core.Model.Tag,CMS.Core" column="TagName" lazy="false" /> </bag> ... <joined-subclass name="CMS.Core.Model.BlogPost,CMS.Core" table="bp_Content_BlogPosts" > <key column="Id" /> <property name="Body" type="string" column="Body" /> <property name="Title" type="string" column="Title" /> </joined-subclass> ... </code></pre> |
17,032,756 | 0 | <p>With a layout as shown in the example and the range in Sheet1 named <code>array</code> <code>=VLOOKUP(A2,array,2,FALSE)</code> should show in ColumnC the value from the Sheet1 cell immediately to the right of the value as specified in <code>A2</code> (of Sheet2). The same formula in <code>D2</code> with <code>,2,</code> replaced <code>,3,</code> should give the corresponding unit price, so appending <code>*B2</code> should give the Cost. Both formulae may be copied down to suit: </p> <p><img src="https://i.stack.imgur.com/Y38qX.gif" alt="enter image description here"> </p> |
6,760,105 | 0 | Does innodb_flush_method affects read operation? <p>If I set innodb_flush_method=O_DIRECT, will the read operation of innodb bypass the system cache? Thanks!</p> |
4,534,018 | 0 | Fluent Nhibernate fails during insert <p>I have problem using Fluent Nhibernate, I have following model. When I try to save Hotel with has new Geography I getting foreign key exception, looks like Nhibenate fails to save data in correct order, is it something I can correct via Fluent Nhibernate ?</p> <pre><code>public class Geography { public virtual int CityID { get; set; } public virtual string CountryCode { get; set; } } public class Hotel { public virtual int HotelID { get; set; } public virtual Geography City { get; set; } } </code></pre> <p>Mapping</p> <pre><code> public class HotelMap : ClassMap<Hotel> { public HotelMap() { Id(x => x.HotelID) .GeneratedBy .Identity(); References(x => x.City, "CityId") .Cascade.All(); } } public class GeographyMap : ClassMap<Geography> { public GeographyMap() { Id(x => x.CityID); Map(x => x.CountryCode); HasMany(a => a.Hotels) .Cascade.All(); } } </code></pre> <p>Added generated mappings</p> <pre><code><hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-access="property" auto-import="true" default-cascade="none" default-lazy="true"> <class xmlns="urn:nhibernate-mapping-2.2" mutable="true" name="Hotel" table="`Hotel`"> <id name="HotelID" type="System.Int32"> <column name="HotelID" /> <generator class="assigned" /> </id> <many-to-one cascade="all" class="Geography" foreign-key="HotelGeography" name="City"> <column name="CityId" /> </many-to-one> </class> </hibernate-mapping> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-access="property" auto-import="true" default-cascade="none" default-lazy="true"> <class xmlns="urn:nhibernate-mapping-2.2" mutable="true" name="Geography" table="`Geography`"> <id name="CityID" type="System.Int32"> <column name="CityID" /> <generator class="assigned" /> </id> <bag cascade="all" inverse="true" name="Hotels" mutable="true"> <key> <column name="HotelID" /> </key> <one-to-many class="Hotel" /> </bag> <property name="CountryCode" type="System.String"> <column name="CountryCode" /> </property> </class> </hibernate-mapping> </code></pre> |
38,577,055 | 0 | Custom Control Initialization exception <p>I have a custom windows control that inherits from <code>Window</code> class which I am trying to use in my other project. I have overwritten the <code>OnInitialized()</code> method inside my custom window class. My problem is <code>base.OnInitialized();</code> line, that's where I get <code>object reference not set to an instance of the of the object</code> exception. Here is my custom windows class:</p> <pre><code> public class MacWindow : Window { public HwndSource HwndSource { get { return _hwndSource; } } private HwndSource _hwndSource; MacWindowBehaviour behaviour; protected override void OnInitialized(EventArgs e) { SourceInitialized += OnSourceInitialized; base.OnInitialized(e); } private void OnSourceInitialized(object sender, EventArgs e) { _hwndSource = (HwndSource)PresentationSource.FromVisual(this); } static MacWindow() { //This is done so that the control automatically finds the fallback style in Generic.xaml DefaultStyleKeyProperty.OverrideMetadata(typeof(MacWindow), new FrameworkPropertyMetadata(typeof(MacWindow))); } public MacWindow() : base() { behaviour = new MacWindowBehaviour(this); PreviewMouseMove += behaviour.MacWindow_PreviewMouseMove; } public override void OnApplyTemplate() { //assigns the event handlers for Window panel buttons when windows is loaded Button minButton = GetTemplateChild("minimizeButton") as Button; Button restButton = GetTemplateChild("restoreButton") as Button; Button clButton = GetTemplateChild("closeButton") as Button; minButton.Click += behaviour.MinimizeClick; restButton.Click += behaviour.RestoreClick; clButton.Click += behaviour.CloseClick; Grid resizeGrid = GetTemplateChild("resizeGrid") as Grid; foreach (UIElement element in resizeGrid.Children) { Rectangle rect = element as Rectangle; rect.MouseMove += behaviour.rect_MouseMove; rect.MouseLeftButtonDown += behaviour.rect_MouseLeftButtonDown; } base.OnApplyTemplate(); } } </code></pre> |
25,659,084 | 0 | <p>The thing is that character classes treat characters inside them as individual characters, unless when using a range. So, what:</p> <pre><code>[2, 3, 4, 5, 8, 9, 10, 18, 19] </code></pre> <p>Will match is: <code>2</code>, <code>,</code>, , <code>3</code>, <code>,</code> (again), [...], <code>1</code>, <code>9</code>, <code>,</code> (again), , <code>1</code> (again), etc.</p> <p>What the regex has to look like is actually:</p> <pre><code>proxy.setFilterRegExp(QRegExp('^(2|3|4|5|8|9|10|18|19)$')) </code></pre> <p>Or shortened as much as possible:</p> <pre><code>proxy.setFilterRegExp(QRegExp('^([234589]|1[089])$')) </code></pre> <p>I guess you will have to change how <code>sourceModel.wantedNumbersList()</code> appears (some string manipulations) or input it manually.</p> <p>If you do it via string manipulation, I would suggest stripping the square brackets and replace the comma followed by space by a pipe <code>|</code>, then use <code>'^(%s)$'</code> for regex.</p> |
10,639,629 | 0 | proper way to start and interface with a service and statusbar/notification <p>I have a broadcast receiver that works fine but now I want to send send notifications to status bar. Since BroadcastReceiver cannot do it directly it looks like I need to create a service to do that for me correct?</p> <p>So I created a service using the examples provided at <a href="http://developer.android.com/reference/android/app/Service.html" rel="nofollow">http://developer.android.com/reference/android/app/Service.html</a></p> <p>Other than a few small tweaks it's that code. I start the service from the broadcast receiver with context.startService(new Intent(context, AlertUser.class));</p> <p>What happened is it did put out the msg in the status bar. then when I did a clear and had it generate a new msg the service code did not execute. Do I interact with he service differently once started? From what I read no if part of same process.</p> <p>Also how would I share information like a string from the the BroadcastReceiver to the service to that it is info to display in the notification?</p> <p>Thanks,</p> <p>Frank</p> |
35,238,331 | 0 | RegEx for css class name <p>I want to have a class <code>cX</code> where x is a number between 0 and 100. I could add <code>c0</code> to <code>c100</code> to my css. But well, I'd like to avoid that.</p> <p>I know there are ways to match element attributes like <code>h2[rel="external"]</code>. But is it also possible to match class names? Would it also possible to use the matched value within the rule?</p> <p>Example</p> <pre><code>.c[x] { height: x%; } </code></pre> |
1,987,518 | 0 | <p>Your problem is thinking of the state as being all the permutations of what people can see. In general you should just be thinking of the state as the facts of the situation, and calculate individual views of those facts as they are needed.</p> <pre><code>// pseudocode - make it properly object oriented for best results struct player { int teamNumber; bool hidden; }; bool is_friend(player other_guy) { return me.teamNumber == other_guy.teamNumber; } bool can_see(player other_guy) { return (is_friend(other_guy) || !other_guy.hidden); } </code></pre> <p>If one player (eg, A) cannot see another player (eg. B), then you just don't send player B's information to player A until the situation changes.</p> |
17,535,954 | 0 | <p>Have you tried setting up a TCP server on the device and then sending to the pc with the pc as a client?</p> |
9,465,404 | 0 | <p>Hope this helps</p> <pre><code>$url="http://www.gonzaga.edu/../../../../Files/ About/Images/300x200/baseball_panorama_hz.jpg" $url=str_replace('../','', $url); </code></pre> |
30,602,857 | 0 | <p>Move <code>ion-footer-bar</code> should be outside of <code>ion-content</code> will solve your issue.</p> <p><strong>Markup</strong></p> <pre><code><ion-popover-view> <ion-header-bar> <h1 class="title">Show Columns</h1> </ion-header-bar> <ion-content> ..content here </ion-content> <ion-footer-bar> <button ng-click="closePopover()">close</button> </ion-footer-bar> </ion-popover-view> </code></pre> <p><a href="http://plnkr.co/edit/Nuyxa09XtHmjFwMTTNXU?p=preview" rel="nofollow"><strong>Demo</strong></a></p> |
1,404,833 | 0 | <p>The answer suggested; [theTableView reload] definitely works fine. If you update the table every view seconds, however, your users will going to hate you and down-vote your app. No question.</p> <p>Try to capture the reloading data in a notification handler. In that handler, check if the updated data belongs somewhere between the currently visible cells, if so, update the currently visible view. If not, ignore the updated data (but do add it to your underlying model). If the user scrolls further, after your update, cellForIndexPath: is called and the updated data will be drawn automatically.</p> <p>reload is quite heavy to do every view seconds, certainly with a lot of data. drawing might get screwed up or worse..</p> |
40,229,606 | 0 | <p>I believe it's because you've written <code>#dialogmodal</code> when you meant to write <code>#dialog-modal</code> on the second line of your JS code.</p> |
23,146,775 | 0 | Unity Bootstrapper (Unity.Mvc), Unity 3, MVC 5, EF6 Receiving Error: Parameterless Public Constructor on Controller <p>Ok, after searching Google, here and several ASP/MVC forums I am bound to have to ask what the hell I am doing wrong here.</p> <p>I have a good start to my application, an ok understanding of DI, IoC and am using the Repository, Service and UnitOfWork patterns. When I attempt to load a controller that needs the DI from Unity, it's as if unity is not resolving any of the registered items, or that I have done it poorly. From all the examples I can see for this version (not the version that creates the Bootstrap.cs file that is then called from Global.asax) I am doing what others have done with no love from Unity.</p> <p>My core question is: Have I setup/configured Unity to inject the items into the controller constructor as needed or not. If I have, any ideas why it's not working like examples I have seen?</p> <p>I keep getting the error that the AssetController needs to have a parameterless public constructor. If I add one, then it uses it without the DI and if I don't add one, then it yells about not having it.</p> <p>Thanks, code below.</p> <p><strong>UnityConfig.cs</strong></p> <pre><code>namespace CARS.web.App_Start { /// <summary> /// Specifies the Unity configuration for the main container. /// </summary> public class UnityConfig { #region Unity Container private static Lazy<IUnityContainer> container = new Lazy<IUnityContainer>(() => { var container = new UnityContainer(); RegisterTypes(container); return container; }); /// <summary> /// Gets the configured Unity container. /// </summary> public static IUnityContainer GetConfiguredContainer() { return container.Value; } #endregion /// <summary>Registers the type mappings with the Unity container.</summary> /// <param name="container">The unity container to configure.</param> /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks> public static void RegisterTypes(IUnityContainer container) { // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements. // container.LoadConfiguration(); // TODO: Register your types here // container.RegisterType<IProductRepository, ProductRepository>(); container.RegisterType<IDataContext, CARSDEMOContext>(new PerRequestLifetimeManager()) .RegisterType<IAssetService, AssetService>() .RegisterType<IUnitOfWork, UnitOfWork>() .RegisterType<IRepository<Asset>, Repository<Asset>>(); //.RegisterType<AssetController>(new InjectionConstructor(typeof(IAssetService), typeof(IUnitOfWork))); } } } </code></pre> <p><strong>AssetController.cs</strong> (constructor portion where I am doing the injection params)</p> <pre><code>namespace CARS.web.Controllers { public class AssetController : Controller { private readonly IAssetService _assetService; private readonly IUnitOfWork _unitOfWork; public AssetController(IAssetService assetService, IUnitOfWork unitOfWork) { _assetService = assetService; _unitOfWork = unitOfWork; } //other methods for CRUD etc stripped for brevity } } </code></pre> <p><strong>IAssetService.cs</strong> (first param is the assetService )</p> <pre><code>namespace CARS.service { public interface IAssetService : IService<Asset> { Task<IEnumerable<Asset>> GetAsync(); Task<Asset> FindAsync(Guid id); Asset Add(Asset asset); Asset Update(Asset asset); void Remove(Guid id); } } </code></pre> <p><strong>AssetService.cs</strong> (concrete implementation for IAssetService interaction)</p> <pre><code>namespace CARS.service { public class AssetService : Service<Asset>, IAssetService { private readonly IRepositoryAsync<Asset> _repository; public AssetService(IRepositoryAsync<Asset> repository) : base(repository) { _repository = repository; } public Task<IEnumerable<Asset>> GetAsync() { //return _repository.Query().SelectAsync(); return _repository.Query().SelectAsync(); } public Task<Asset> FindAsync(Guid id) { return _repository.FindAsync(id); } public Asset Add(Asset asset) { _repository.Insert(asset); return asset; } public Asset Update(Asset asset) { _repository.Update(asset); return asset; } public void Remove(Guid id) { _repository.Delete(id); } } } </code></pre> <p><strong>IUnitOfWork.cs</strong> (this is from Long Le's Generic UofW and Repository - <a href="http://genericunitofworkandrepositories.codeplex.com/" rel="nofollow">http://genericunitofworkandrepositories.codeplex.com/</a>)</p> <pre><code>namespace Repository.Pattern.UnitOfWork { public interface IUnitOfWork : IDisposable { int SaveChanges(); Task<int> SaveChangesAsync(); void Dispose(bool disposing); IRepository<TEntity> Repository<TEntity>() where TEntity : IObjectState; void BeginTransaction(); bool Commit(); void Rollback(); } } </code></pre> <p><strong>UnitOfWork.cs</strong> (again from Long Le's framework)</p> <pre><code>namespace Repository.Pattern.Ef6 { public class UnitOfWork : IUnitOfWork, IUnitOfWorkAsync { #region Private Fields private readonly IDataContextAsync _dataContext; private bool _disposed; private ObjectContext _objectContext; private Dictionary<string, object> _repositories; private DbTransaction _transaction; #endregion Private Fields #region Constuctor/Dispose public UnitOfWork(IDataContextAsync dataContext) { _dataContext = dataContext; } public void Dispose() { if (_objectContext != null && _objectContext.Connection.State == ConnectionState.Open) _objectContext.Connection.Close(); Dispose(true); GC.SuppressFinalize(this); } public virtual void Dispose(bool disposing) { if (!_disposed && disposing) _dataContext.Dispose(); _disposed = true; } #endregion Constuctor/Dispose public int SaveChanges() { return _dataContext.SaveChanges(); } public IRepository<TEntity> Repository<TEntity>() where TEntity : IObjectState { return RepositoryAsync<TEntity>(); } public Task<int> SaveChangesAsync() { return _dataContext.SaveChangesAsync(); } public Task<int> SaveChangesAsync(CancellationToken cancellationToken) { return _dataContext.SaveChangesAsync(cancellationToken); } public IRepositoryAsync<TEntity> RepositoryAsync<TEntity>() where TEntity : IObjectState { if (_repositories == null) _repositories = new Dictionary<string, object>(); var type = typeof (TEntity).Name; if (_repositories.ContainsKey(type)) return (IRepositoryAsync<TEntity>) _repositories[type]; var repositoryType = typeof (Repository<>); _repositories.Add(type, Activator.CreateInstance(repositoryType.MakeGenericType(typeof (TEntity)), _dataContext, this)); return (IRepositoryAsync<TEntity>) _repositories[type]; } #region Unit of Work Transactions public void BeginTransaction() { _objectContext = ((IObjectContextAdapter) _dataContext).ObjectContext; if (_objectContext.Connection.State != ConnectionState.Open) { _objectContext.Connection.Open(); _transaction = _objectContext.Connection.BeginTransaction(); } } public bool Commit() { _transaction.Commit(); return true; } public void Rollback() { _transaction.Rollback(); ((DataContext)_dataContext).SyncObjectsStatePostCommit(); } #endregion // Uncomment, if rather have IRepositoryAsync<TEntity> IoC vs. Reflection Activation //public IRepositoryAsync<TEntity> RepositoryAsync<TEntity>() where TEntity : EntityBase //{ // return ServiceLocator.Current.GetInstance<IRepositoryAsync<TEntity>>(); //} } } </code></pre> <p><strong>Updated to include the SetResolver info from UnityMvcActivator.cs</strong></p> <pre><code>using System.Linq; using System.Web.Mvc; using Microsoft.Practices.Unity.Mvc; [assembly: WebActivatorEx.PreApplicationStartMethod(typeof(CARS.web.App_Start.UnityWebActivator), "Start")] namespace CARS.web.App_Start { /// <summary>Provides the bootstrapping for integrating Unity with ASP.NET MVC.</summary> public static class UnityWebActivator { /// <summary>Integrates Unity when the application starts.</summary> public static void Start() { var container = UnityConfig.GetConfiguredContainer(); FilterProviders.Providers.Remove(FilterProviders.Providers.OfType<FilterAttributeFilterProvider>().First()); FilterProviders.Providers.Add(new UnityFilterAttributeFilterProvider(container)); DependencyResolver.SetResolver(new UnityDependencyResolver(container)); // TODO: Uncomment if you want to use PerRequestLifetimeManager Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility.RegisterModule(typeof(UnityPerRequestHttpModule)); } } } </code></pre> <p>I have read/tried the following info/data and nothing has fixed it:</p> <p><a href="http://stackoverflow.com/questions/22846327/the-type-iuserstore1-does-not-have-an-accessible-constructor">The type IUserStore`1 does not have an accessible constructor</a></p> <p><a href="http://stackoverflow.com/questions/20023065/how-to-add-mvc-5-authentication-to-unity-ioc">How to add MVC 5 authentication to Unity IoC?</a></p> <p><a href="http://stackoverflow.com/questions/20489460/types-not-resolving-with-unity-mvc-5">Types not resolving with Unity [MVC 5]</a></p> <p>I have ready where one must write a ControllerFactory for Unity to be able to do this, but that seems quite a bit of work when all the examples I have found simply have the config registered, and the injection apparently happening on the controllers and other classes as need.</p> <p>And finally the error:</p> <pre><code>The following server error was encountered: An error occurred when trying to create a controller of type 'CARS.web.Controllers.AssetController'. Make sure that the controller has a parameterless public constructor.Details are: at System.Web.Mvc.DefaultControllerFactory.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) at System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) at System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionSte p.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) </code></pre> <p>Thanks</p> |
11,429,995 | 0 | what is difference between creating webservice in http and https <p>I am working on creating rest service in java using Jersey. I am new at this, so I am a bit confused about what is the difference between creating services in http and https.</p> <p>Do we need to take care of creating services. Please guide properly.</p> <p>Tutorial I followed for creating service is <a href="http://www.vogella.com/articles/REST/article.html" rel="nofollow">Click here for tutorial link</a></p> |
22,235,021 | 1 | How to avoid Pylint warnings for constructor of inherited class in Python 3? <p>In Python 3, I have the following code:</p> <pre><code>class A: def __init__(self): pass class B(A): def __init__(self): super().__init__() </code></pre> <p>This yields the Pylint warning:</p> <blockquote> <ul> <li>Old-style class defined. (old-style-class)</li> <li>Use of super on an old style class (super-on-old-class)</li> </ul> </blockquote> <p>In my understanding, in Python 3 there does not exist an old-style class anymore and this code is OK.</p> <p>Even if I explicitly use new-style classes with this code</p> <pre><code>class A(object): def __init__(self): pass class B(A): def __init__(self): super().__init__() </code></pre> <p>I get Pylint warning because of the different syntax to call the parent constructor in Python 3:</p> <blockquote> <ul> <li>Missing argument to super() (missing-super-argument)</li> </ul> </blockquote> <p>So, how can I tell Pylint that I want to check Python 3 code to avoid these messages (without disabling the Pylint check)?</p> |
26,863,454 | 0 | <p>Bootstrap datepicker (the first result from bootstrap datepickcer search) has a method to get the selected date.<br> <a href="http://bootstrap-datepicker.readthedocs.org/en/release/methods.html#getdate">http://bootstrap-datepicker.readthedocs.org/en/release/methods.html#getdate</a> </p> <p>getDate:<br> Returns a localized date object representing the internal date object of the first datepicker in the selection.<br> For multidate pickers, returns the latest date selected.</p> <pre><code>$('.datepicker').datepicker("getDate") </code></pre> <p>or</p> <pre><code>$('.datepicker').datepicker("getDate").valueOf() </code></pre> |
31,355,478 | 0 | <p>If you need to do AJAX request, turn-off the <strong>VerifyCsrfToken</strong> middleware on your <strong>Kernel.php</strong> file.</p> <p>You can also edit your <strong>VerifyCsrfToken.php</strong> middleware file to exclude certain URLs like this way:</p> <p><code>/** * The URIs that should be excluded from CSRF verification. * * @var array */ protected $except = [ 'ajax/*', 'api/*', ];</code></p> |
37,400,766 | 0 | <p>I sort of experienced the same problem and it let me to this SO post. I got sporadic SIGPIPE signals causing crashes of my fastcgi C program run by nginx. I tried to <code>signal(SIGPIPE, SIG_IGN);</code> without luck, it kept crashing.</p> <p>The reason was that nginx's temp dir had a permission problem. Fixing the permissions solved the SIGPIPE problem. <a href="http://derekneely.com/2009/06/nginx-failed-13-permission-denied-while-reading-upstream/" rel="nofollow">Details here on how to fix</a>.</p> |
8,134,485 | 0 | is IBM MQ Message Segmentation possible using JMS? <p>Is it possible to implement message segmentation using JMS as it is in using Native IBM API as <a href="http://www-01.ibm.com/support/docview.wss?uid=swg21405730" rel="nofollow">shown here</a>. One posible solution I have read is message grouping for JMS. is anyone using this an alternative solution to Segmentation, using JMS?</p> |
4,720,366 | 0 | <p>In the shell, use db.collection.stats(). If a collection is capped:</p> <pre><code>> db.my_collection.stats()["capped"] 1 </code></pre> <p>If a collection is not capped, the "capped" key will not be present.</p> <p>Below are example results from stats() for a capped collection:</p> <pre><code>> db.my_coll.stats() { "ns" : "my_db.my_coll", "count" : 221, "size" : 318556, "avgObjSize" : 1441.4298642533936, "storageSize" : 1000192, "numExtents" : 1, "nindexes" : 0, "lastExtentSize" : 1000192, "paddingFactor" : 1, "flags" : 0, "totalIndexSize" : 0, "indexSizes" : { }, "capped" : 1, "max" : 2147483647, "ok" : 1 } </code></pre> <p>This is with MongoDB 1.7.4.</p> |
27,029,136 | 0 | Spring security ldap connection management <p>I am using spring security to authenticate users logging into a webapp. Authentication is currently done with ldap.</p> <p>Between my webapp and my ldap server lies a firewall. After 50 minutes of inactivity, the firewall flushes idle ldap connections.</p> <p>Spring security sometimes reuses existing connections, but not always. If it picks a connection closed by my firewall, the login will fail. </p> <p>The exception I find in my Tomcat log is the following.</p> <pre><code>org.springframework.ldap.ServiceUnavailableException: ldap:389; socket closed; nested exception is javax.naming.ServiceUnavailableException </code></pre> <p>More specifically, connections causing issues are the ones used for search requests. They're not systematically closed by the framework. Bind requests are always made on a new connection that's closed at the end of the request.</p> <p>In my app a search request is issued after a bind because of a custom LdapAuthoritiesPopulator granting access only to users with particular roles. I have verified the default LdapAuthoritiesPopulator issues search requests in the same manner.</p> <p>Is it normal for search request connections to stay open almost indefinitely? If it is, is there a way I can change the way spring security manages its connections?</p> <p>I'm also interested to know if there is a better way than using a custom LdapAuthoritiesPopulator to enforce a role constraint during authentication.</p> <p>My problem persists after trying easy upgrades:</p> <ul> <li>spring-security 3.1.7 (up from 3.1.2) </li> <li>spring-ldap-core 2.0.2 (up from 1.3.0) </li> <li>spring-ldap 1.3.1 (up from 1.3.0)</li> </ul> <p>Thanks.</p> |
34,179,719 | 0 | <p>I came up with a similar solution, here's the general gist. (I've got a working example at the bottom too)</p> <pre><code>var year = [], yearWatch = 2015; Year[2015] = ["Jan", "Feb", "Sep", "Dec"]; Year[2016] = ["Apr", "May", "Oct", "Nov"]; disableFromVar = function() { $('#txtCalendar .month').removeClass('disabled'); $('#txtCalendar .month').each(function(i, v) { if (jQuery.inArray($(v).html(), Year[yearWatch]) > -1) { $(v).addClass('disabled'); } }); } </code></pre> <p><a href="http://jsfiddle.net/link2twenty/5psu9tf8/" rel="nofollow">http://jsfiddle.net/link2twenty/5psu9tf8/</a></p> |
33,974,711 | 0 | <p>Your thinking too hard, you should take it simple when programming. You don't need the type when calling a method, only do this when you declare it.</p> |
10,793,101 | 0 | <p>In the "Guide to Active Record Associations", I recommend reading section 2.8: Choosing Between has_many :through and has_and_belongs_to_many</p> <blockquote> <p>The simplest rule of thumb is that you should set up a has_many :through relationship if you need to work with the relationship model as an independent entity. If you don’t need to do anything with the relationship model, it may be simpler to set up a has_and_belongs_to_many relationship (though you’ll need to remember to create the joining table in the database).</p> <p>You should use has_many :through if you need validations, callbacks, or extra attributes on the join model.</p> </blockquote> <p><a href="http://guides.rubyonrails.org/association_basics.html#choosing-between-has_many-through-and-has_and_belongs_to_many" rel="nofollow">http://guides.rubyonrails.org/association_basics.html#choosing-between-has_many-through-and-has_and_belongs_to_many</a></p> |
24,467,231 | 0 | friend url on wildcard subdomains htacces, not working <p>i have wildcard subdomains sets already and works fine, now i wish have friends url for the content in thats subdomains, the structure of my site is if the user type subdomain.maindomain.com and the .htaccess redirect to </p> <pre><code>blogs/index.php?user=subdomain </code></pre> <p>where blogs/index.php receive the param and show the correct content</p> <p>now i try to make the url function like this </p> <pre><code>subdomain.maindoamin.com/24/title-of-content </code></pre> <p>and then .htaccess must result </p> <pre><code>blogs/index.php?id_content=24&title=title-of-content </code></pre> <p>i have the next .htaccess</p> <pre><code>Options +FollowSymLinks #this force to server the content always without www. RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.(.*)$ RewriteRule ^(.*)$ http://%1/$1 [R=301] #this is to pass the subdomain like param and show the right content of the user RewriteCond %{HTTP_HOST} !^www\.misite\.com [NC] RewriteCond %{HTTP_HOST} ^([a-z0-9]+)\.misite\.com RewriteRule ^(.*)$ blogs/index.php?url=%1 [QSA,L] #the next line i can't make work to make nice url RewriteRule ^/(.*)/(.*)$ blogs/index.php?idP=$1&name=$2 [L] </code></pre> <p>not working because when i make in index.php</p> <pre><code>echo $_SERVER['REQUEST_URI']; </code></pre> <p>don't show idP=24 show /24/title-of-content and i need $_GET(idP)</p> <p>i really apreciate some light on this stuff i am not expert on htaccess, thanks in advance to everybody. </p> |
22,030,053 | 0 | <p>The problem is that your <code>ORDER BY</code> clause is not in the correct place in the query. It should be after the closing bracket that closes the WHERE clause:</p> <pre><code>CONSTRUCT { ?s ?p ?o } WHERE { GRAPH ?g { ?s ?p ?o } ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://lod.isi.edu/ontology/syllabus/Homework> . ?s <http://lod.isi.edu/ontology/syllabus/hasEventDate> ?date . } ORDER BY ASC(?date) </code></pre> <p>Also note that several of the curly braces in your original query are, although not exactly wrong, superfluous.</p> |
7,971,178 | 0 | find out if text of JLabel exceeds label size <p>In Java when the text of the JLabel could not be displayed due to lack of space the text is truncated and "..." is added in the end.</p> <p>How can I easily find out if currently JLabel displays full text or the truncated?</p> <hr> <p>EDIT:</p> <p>I see that there is a way to find out the size of the text by using <code>FontMetrics</code>. However this solution doesn't fully answers the question. In the case the text of JLabel contains HTML decorations the <code>metrics.stringWidth()</code> would also calculate width of HTML tags. So it could happen that result of <code>metrics.stringWidth()</code> would be grater than JLabel's width but still the text would be displayed correctly.</p> <p>Is there a way know what decision took the JLabel itself while displaying the text. Has it decided to truncate the text or not.</p> |
39,472,199 | 0 | <pre><code>Banner.frame = CGRect(x:0.0, y:self.view.frame.size.height - Banner.frame.size.height, width:Banner.frame.size.width, height:Banner.frame.size.height) </code></pre> |
30,093,039 | 0 | <p>No need to join, use <code>LAG</code> function to track previous.<br> If you would like to know about Lag function. Please visit below link. <a href="http://www.techonthenet.com/oracle/functions/lag.php" rel="nofollow noreferrer">http://www.techonthenet.com/oracle/functions/lag.php</a>. I have taken below as input. <img src="https://i.stack.imgur.com/3CoAy.png" alt="enter image description here"></p> <p>and executed below query using lag which automatically tracks previous row.<br> <code> SELECT * FROM( SELECT ID,LAG(BALANCE) OVER (ORDER BY DATES) AS YESTERDAY_BALANCE,BALANCE AS TODAYS_BALANCE FROM ACCOUNTS) WHERE YESTERDAY_BALANCE IS NOT NULL;</code></p> <p>Output which I got is below. If you wont get data for today still it will display the row.<br> <img src="https://i.stack.imgur.com/0rRna.png" alt="enter image description here"></p> |
3,594,733 | 0 | <p>The answer is correct in a certain context, for simple select statements over a DB link, you'll get this error:</p> <blockquote> <p><strong>ORA-22992</strong>: cannot use LOB locators selected from remote tables.</p> </blockquote> <p>From the errors manual:</p> <blockquote> <p><strong>Cause</strong>: A remote LOB column cannot be referenced.<br> <strong>Action</strong>: Remove references to LOBs in remote tables.</p> </blockquote> <p>I also had trouble finding definitive documentation on this...but we just ran into the same issue in our data warehouse. However, there are several work-arounds available, <a href="http://jiri.wordpress.com/2010/06/04/query-clob-across-db-link-with-in-simple-view/" rel="nofollow noreferrer">pulling the data over or creating a view</a> for example.</p> |
23,129,832 | 0 | Find command not working <pre><code>find . ! -name . -prune -name "*.dat" -type f -cmin +60 </code></pre> <p>The command is working in one directory but not in another directory even if the <code>.dat</code> files are there in both directories. Also, this command is working with other file extensions in both directories but not in this directory.</p> |
22,823,794 | 0 | How do you close JOptionPane after a radiobutton has been selected? <p>I am new to programming and just started last week, so all the java mumbojumbo is quite confusing to me. I was able to create a option pane for my BMI program that asks which unit system(metric/imperial) with radiobuttons and this determines which calculation to perform when finding the BMI. this all works fine except the first optionpane doesn't close when an option is selected, how do i make it close when an option is seleceted. I want the jpane with radiobuttons to close in the do statement.</p> <pre><code>package javaapplication21; import java.text.DecimalFormat; import javax.swing.*; import java.*; public class JavaApplication21 { public static void main(String[] args) { JPanel jPanel = new JPanel(); ButtonGroup group = new ButtonGroup(); JRadioButton metricButton = new JRadioButton("Metric"); metricButton.setActionCommand("Metric"); JRadioButton imperialButton = new JRadioButton("Imperial"); imperialButton.setActionCommand("Imperial"); group.add(metricButton); group.add(imperialButton); jPanel.add(metricButton); jPanel.add(imperialButton); JOptionPane.showOptionDialog(null, "Please select prefered units", "BMI Calculator", JOptionPane.DEFAULT_OPTION,JOptionPane.QUESTION_MESSAGE, null, new Object[] { metricButton, imperialButton}, null); DecimalFormat oneDigit = new DecimalFormat("#,##0.0"); double bodyMassIndex, weight, height; String unitsWeight = "-1", unitsHeight = "-1"; do{ if (metricButton.isSelected()){ unitsWeight = " in kg."; unitsHeight = " in meters"; } else if (imperialButton.isSelected()){ unitsWeight = " in lbs"; unitsHeight = " in inches"; } } while ("-1".equals(unitsWeight)); String weightInput = JOptionPane.showInputDialog("Please enter your weight" + unitsWeight); String heightInput = JOptionPane.showInputDialog("Please enter your height" + unitsHeight); if (metricButton.isSelected()){ height = Double.parseDouble(heightInput); weight = Double.parseDouble(weightInput); bodyMassIndex = weight / (height * height); System.out.println("Your Body Mass Index(BMI) is " + oneDigit.format(bodyMassIndex) + "kg/m^2"); if (bodyMassIndex < 15) System.out.println("You are starving"); else if (bodyMassIndex < 18.5) System.out.println("You are underweight"); else if (bodyMassIndex < 25) System.out.println("You are healthy"); else if (bodyMassIndex < 30) System.out.println("You are obese"); else if (bodyMassIndex < 40) System.out.println("You are morbidly obese"); else System.out.println("You are at high risk of many health concerns"); } else if (imperialButton.isSelected()){ height = Double.parseDouble(heightInput); weight = Double.parseDouble(weightInput); bodyMassIndex = (weight * 703) / (height * height); System.out.println("Your Body Mass Index(BMI) is " + oneDigit.format(bodyMassIndex) + "kg/m^2"); if (bodyMassIndex < 15) System.out.println("You are starving"); else if (bodyMassIndex < 18.5) System.out.println("You are underweight"); else if (bodyMassIndex < 25) System.out.println("You are healthy"); else if (bodyMassIndex < 30) System.out.println("You are obese"); else if (bodyMassIndex < 40) System.out.println("You are morbidly obese"); else System.out.println("No more big macs!"); } } } </code></pre> |
22,093,549 | 0 | Can I download extension from my existing opencart website <p>Sorry if my question is not good.</p> <p><strong>Question :</strong> I install revolution slider extension in my opencart website. Now I need that slider in an other website of opencart. Can I download that slider extension from my existing website.</p> <p><strong>Note :</strong> In simply I mean, I want to export extension from one website and import it into another website..</p> |
22,289,419 | 0 | <pre><code>SELECT name, location, SUM(total_points) AS total_points FROM ( SELECT name, location, COALESCE(SUM(points), 0) AS total_points FROM players p LEFT JOIN games g ON p.name = g.player GROUP BY name, location UNION ALL SELECT name, location, COALESCE(SUM(points2), 0) FROM players p LEFT JOIN games g ON p.name = g.player2 GROUP BY name, location ) x GROUP BY name, location </code></pre> <p><a href="http://www.sqlfiddle.com/#!2/a0eb5/5" rel="nofollow">DEMO</a></p> |
23,811,305 | 0 | <p>you can use <a href="http://www.cplusplus.com/reference/algorithm/replace/" rel="nofollow"><code>std::replace</code></a> </p> <pre><code>std::replace (test.begin(), test.end(), "bird", "book"); </code></pre> |
30,081,195 | 0 | running NN software with my own data <p>New with Matlab.</p> <p>When I try to load my own date using the NN pattern recognition app window, I can load the source data, but not the target (it is never on the drop down list). Both source and target are in the same directory. Source is 5000 observations with 400 vars per observation and target can take on 10 different values (recognizing digits). Any Ideas?</p> |
35,285,501 | 0 | Mouse Leaving the window alert Pop-Up--Moodle <p>I have developed an online exam using the Moodle software which is written in PHP. Now I want to restrict the person who is taking the test without being able to navigate to other tabs or other windows by generating a mouserover pop-up.</p> <p>Following is the I have a code for the alert pop-up when the user leaves the window:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code><html> <head> <script type="text/javascript"> function addEvent(obj, evt, fn) { if (obj.addEventListener) { obj.addEventListener(evt, fn, false); } else if (obj.attachEvent) { obj.attachEvent("on" + evt, fn); } } addEvent(window,"load",function (e) { addEvent(document, "mouseout", function (e) { e = e ? e : window.event; var from = e.relatedTarget || e.toElement; if (!from || from.nodeName == "HTML") { // stop your drag event here // for now we can just use an alert alert("Your Test will close in 10 secs unless you return to the page "); } }); }); </script> </head> <body></body> </html></code></pre> </div> </div> </p> <p>Is there a possibility to restrict the user with this code and in that case where to append this code to the moodle's actual source code??</p> <p>Thanks.</p> |
4,387,695 | 0 | Getting equal symbol expected while using jstl <p>I am getting </p> <blockquote> <p>org.apache.jasper.JasperException: /WEB-INF/AllClientBatchDetails.jsp(54,103) equal symbol expected</p> </blockquote> <p>And here is the jsp</p> <pre><code><%@ page contentType="text/html;charset=UTF-8" language="java" import="java.util.*%> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <html:html xhtml="true"> <head> <title><bean:message key="progressReporter.successpage.title"/></title> <link rel="stylesheet" href="style.css"> <html:base/> </head> <body> <c:choose> <c:when test="${empty batchProgressMetricsList}"> <font color=<bean:message key="error.font.color" /> size=<bean:message key="error.font.size" />> <bean:message key="error.no.active.batch" /> </font> <br/> </c:when> <c:otherwise> <h4><bean:message key="table.header" /></h4> <table border=<bean:message key="table.border.size" />> <tr> <th><bean:message key="table.client.id.header" /></th> <th><bean:message key="table.total.session.used" /></th> <th><bean:message key="table.total.time.elapsed" /></th> <th><bean:message key="table.imnts.completed" /></th> <th><bean:message key="table.imnts.remaining" /></th> <th><bean:message key="table.cores.allocated" /></th> <th><bean:message key="table.time.remaining" /></th> </tr> <c:forEach var="aggregatedBatchProgressMetrics" items="${batchProgressMetricsList}"> <tr> <td class="tdcenter">${aggregatedBatchProgressMetrics["clientId"]}</td> <td class="tdcenter">${fn:substringBefore(aggregatedBatchProgressMetrics["sessionStats"]["sessionUsedTime"]/60000, '.')}mins${fn:substringBefore((aggregatedBatchProgressMetrics["sessionStats"]["sessionUsedTime"] % 60000)/1000, '.')}secs </td> <td class="tdcenter">${fn:substringBefore(aggregatedBatchProgressMetrics["sessionStats"]["totalElapsedTime"]/60000, '.')}mins${fn:substringBefore((aggregatedBatchProgressMetrics["sessionStats"]["totalElapsedTime"] % 60000)/1000, '.')}secs</td> <td class="tdcenter">${aggregatedBatchProgressMetrics["instrumentStats"]["totalImntsCompleted"]}</td> <td class="tdcenter">${aggregatedBatchProgressMetrics["instrumentStats"]["totalImntsRemaining"]}</td> <td class="tdcenter">${aggregatedBatchProgressMetrics["numberOfCores"]}</td> <td class="tdcenter">${fn:substringBefore(aggregatedBatchProgressMetrics["sessionStats"]["sessionRemainingTime"]/60000, '.')}mins${fn:substringBefore((aggregatedBatchProgressMetrics["sessionStats"]["sessionRemainingTime"] % 60000)/1000, '.')}secs</td> <br/> <table> <tr> <th>session Id</th> <th>taskId</th> <th>task start time</th> <th>task end time</th> </tr> ${aggregatedBatchProgressMetrics["batchMetricsList"][0]} ${aggregatedBatchProgressMetrics["batchMetricsList"][1]} ${aggregatedBatchProgressMetrics["batchMetricsList"][2]} <c:forEach var="batchProgressMetrics" items="${aggregatedBatchProgressMetrics["batchMetricsList"]}"> <tr> <td class="tdcenter">${batchProgressMetrics["taskStats"]["sessionId"]}</td> <td class="tdcenter">${batchProgressMetrics["taskStats"]["taskId"]}</td> <td class="tdcenter">${batchProgressMetrics["taskStats"]["taskStartTime"]}</td> <td class="tdcenter">${batchProgressMetrics["taskStats"]["taskEndTime"]}</td> </tr> </c:forEach> </table> <br/> </tr> </c:forEach> </table> </c:otherwise> </c:choose> <html:link page="/ProgressReporterForm.jsp">Go Back</html:link> </body> </html:html> </code></pre> <p>I have request attribute set to batchProgressMetricsList and its an array list of an object called. I have AggregatedBatchProgressMetrics. Inside <code>aggregatedBatchProgressMetrics</code> i have a method called <code>getBatchMetricsList</code> which return an arraylist of object called BatchProgressMetrics. If i run it without the nested <code>c:forEach</code> tag, it would just run fine, but if i include the nested one it just fails. Can somebody please help me?</p> <p>Thanks in advance. Almas</p> |
7,407,194 | 0 | <p>This loops through all items of an ASP combobox:</p> <pre><code>DataTable dt = (DataTable)comboBox1.DataSource; for(int i = 0; i < dt.Rows.Count; ++i) { string displayText = dt.Rows[i][comboBox1.DisplayMember].ToString(); string valueItem = dt.Rows[i][comboBox1.ValueMember].ToString(); } </code></pre> |
14,235,394 | 0 | Bluetooth connection with Android <p>In my App I need to connect a smartphone with an 4.0 low power Bluetooth-module. Then the module sends frequenly data to the phone.</p> <ul> <li>Do you know some good tutorials for programming Bluetooth connection with Android?</li> <li>Can you give me some links where the basics of Bluetooth are explained? (german if possible)</li> <li>How can I test it? (I have to programm the Bluetooth device too and it's not finished jet)</li> </ul> |
35,637,885 | 0 | <p>Hyperlink tag doesn't have a close tag <code></a></code>, if you want to close it make it like this:</p> <pre><code><a target="_blank" href="http://url.com" style="text-decoration: underline; color: #000001;"> Call To Action <img src="image/path/triangle.png" border="0" /> </a> </code></pre> <p>Reference:</p> <ul> <li><a href="https://www.w3.org/TR/html-markup/a.html" rel="nofollow">https://www.w3.org/TR/html-markup/a.html</a></li> <li><a href="https://www.w3.org/wiki/HTML/Elements/a" rel="nofollow">https://www.w3.org/wiki/HTML/Elements/a</a></li> </ul> <p>Also, I recommend you separate design from content.</p> |
6,005,801 | 0 | Setting up environment for C++/Boost libs (netbeans or eclipse) <p>I've followed so many tutorials now and I can't get this basic, fundamental thing right. I'm getting started with C++ and moving on from the standard intro stuff (after two books) and I'm working through "Beyond the C++ Standard Library ~ An Introduction to Boost" but I can't seem to get either Netbeans or Eclipse to compile and run my boost projects.</p> <p>I've looked at <a href="http://stackoverflow.com/questions/4293371/how-to-configure-boost-with-netbeans-6-9-on-ubuntu">How to configure Boost with Netbeans 6.9 on Ubuntu</a> <a href="http://www.fischerlaender.net/development/using-boost-c-libraries-with-gcc-g-under-windows" rel="nofollow">http://www.fischerlaender.net/development/using-boost-c-libraries-with-gcc-g-under-windows</a> and a few others but I can't seem to get it right. In Netbeans (my preference) I've gotten as far as specifying the additional include directories, and netbeans recognizes it to the extent where it provides auto completion when including anything from boost/* e.g #include is fine but when I try to compile it I get:</p> <pre><code>mkdir -p build/Debug/MinGW-Windows rm -f build/Debug/MinGW-Windows/main.o.d g++.exe -c -g -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp main.cpp:7:27: fatal error: boost/regex.hpp: No such file or directory compilation terminated. make[2]: *** [build/Debug/MinGW-Windows/main.o] Error 1 make[1]: *** [.build-conf] Error 2 make: *** [.build-impl] Error 2 make[2]: Leaving directory `/c/Users/Courtney/Documents/Projects/Desktop/HelloBoost' make[1]: Leaving directory `/c/Users/Courtney/Documents/Projects/Desktop/HelloBoost' </code></pre> <p>but I don't get why the file cannot be found... any help is much appreciated. <strong>UPDATE</strong> Set the include directory under Properties->C++ Compiler and chosen 32 bits as the architecture. The compile error's changed to :</p> <pre><code>"/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf make[1]: Entering directory `/c/Users/Courtney/Documents/Projects/Desktop/HelloBoost' "/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/helloboost.exe make[2]: Entering directory `/c/Users/Courtney/Documents/Projects/Desktop/HelloBoost' mkdir -p build/Debug/MinGW-Windows rm -f build/Debug/MinGW-Windows/main.o.d g++.exe -m32 -c -g -I/C/Program\ Files\ \(x86\)/boost/boost_1_46_1 -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp mkdir -p dist/Debug/MinGW-Windows g++.exe -m32 -o dist/Debug/MinGW-Windows/helloboost build/Debug/MinGW-Windows/main.o build/Debug/MinGW-Windows/main.o: In function `cpp_regex_traits_char_layer': c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/cpp_regex_traits.hpp:366: undefined reference to `boost::re_detail::cpp_regex_traits_char_layer<char>::init()' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/regex_raw_buffer.hpp:131: undefined reference to `boost::re_detail::raw_storage::resize(unsigned int)' build/Debug/MinGW-Windows/main.o: In function `save_state_init': c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/perl_matcher_non_recursive.hpp:107: undefined reference to `boost::re_detail::get_mem_block()' build/Debug/MinGW-Windows/main.o: In function `~save_state_init': c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/perl_matcher_non_recursive.hpp:115: undefined reference to `boost::re_detail::put_mem_block(void*)' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/perl_matcher_common.hpp:206: undefined reference to `boost::re_detail::verify_options(unsigned int, boost::regex_constants::_match_flags)' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/perl_matcher_non_recursive.hpp:1117: undefined reference to `boost::re_detail::put_mem_block(void*)' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/pattern_except.hpp:75: undefined reference to `boost::re_detail::raise_runtime_error(std::runtime_error const&)' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_parser.hpp:218: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_parser.hpp:219: undefined reference to `boost::regex_error::raise() const' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_parser.hpp:218: undefined reference to `boost::regex_error::~regex_error()' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_parser.hpp:218: undefined reference to `boost::regex_error::~regex_error()' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:795: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:796: undefined reference to `boost::regex_error::raise() const' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:795: undefined reference to `boost::regex_error::~regex_error()' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:877: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:878: undefined reference to `boost::regex_error::raise() const' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:877: undefined reference to `boost::regex_error::~regex_error()' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:795: undefined reference to `boost::regex_error::~regex_error()' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:877: undefined reference to `boost::regex_error::~regex_error()' make[2]: Leaving directory `/c/Users/Courtney/Documents/Projects/Desktop/HelloBoost' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:942: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)' make[1]: Leaving directory `/c/Users/Courtney/Documents/Projects/Desktop/HelloBoost' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:943: undefined reference to `boost::regex_error::raise() const' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:942: undefined reference to `boost::regex_error::~regex_error()' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:942: undefined reference to `boost::regex_error::~regex_error()' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:1133: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:1134: undefined reference to `boost::regex_error::raise() const' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:1133: undefined reference to `boost::regex_error::~regex_error()' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:1133: undefined reference to `boost::regex_error::~regex_error()' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/perl_matcher_non_recursive.hpp:213: undefined reference to `boost::re_detail::get_mem_block()' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/cpp_regex_traits.hpp:442: undefined reference to `boost::re_detail::get_default_error_string(boost::regex_constants::error_type)' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/cpp_regex_traits.hpp:444: undefined reference to `boost::re_detail::get_default_error_string(boost::regex_constants::error_type)' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:320: undefined reference to `boost::re_detail::raw_storage::insert(unsigned int, unsigned int)' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/pending/object_cache.hpp:66: undefined reference to `boost::scoped_static_mutex_lock::scoped_static_mutex_lock(boost::static_mutex&, bool)' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/pending/object_cache.hpp:66: undefined reference to `boost::scoped_static_mutex_lock::~scoped_static_mutex_lock()' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/pending/object_cache.hpp:66: undefined reference to `boost::scoped_static_mutex_lock::~scoped_static_mutex_lock()' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/cpp_regex_traits.hpp:625: undefined reference to `boost::re_detail::lookup_default_collate_name(std::string const&)' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/cpp_regex_traits.hpp:667: undefined reference to `boost::re_detail::raise_runtime_error(std::runtime_error const&)' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/cpp_regex_traits.hpp:682: undefined reference to `boost::re_detail::get_default_error_string(boost::regex_constants::error_type)' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/cpp_regex_traits.hpp:1051: undefined reference to `boost::scoped_static_mutex_lock::scoped_static_mutex_lock(boost::static_mutex&, bool)' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/cpp_regex_traits.hpp:1051: undefined reference to `boost::scoped_static_mutex_lock::~scoped_static_mutex_lock()' build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/cpp_regex_traits.hpp:1051: undefined reference to `boost::scoped_static_mutex_lock::~scoped_static_mutex_lock()' collect2: ld returned 1 exit status make[2]: *** [dist/Debug/MinGW-Windows/helloboost.exe] Error 1 make[1]: *** [.build-conf] Error 2 make: *** [.build-impl] Error 2 BUILD FAILED (exit value 2, total time: 31s) </code></pre> |
18,156,020 | 0 | <p>I'm not sure I understand fully what is happening in this scenario but here is a solution to your problem:</p> <pre><code>... casper.then(function() { casper.page.close(); casper.page = require('webpage').create(); }); casper.thenOpen('http://www.yahoo.com/', function(response) { this.wait(1000, function() { this.echo(this.getTitle()); }); }); ... </code></pre> <p>close() - "Close the page and releases the memory heap associated with it. Do not use the page instance after calling this." <- This is from the phantomjs documentation. You need to create a new page instance if you want to continue opening sites. Hope this helps!</p> |
33,575,749 | 0 | <p>Maybe like that? </p> <pre><code>start1 < end2 and start2 < end1 </code></pre> <p>This means: each of the two words begins <em>earlier</em> than the other word ends, so they do overlap </p> |
14,750,533 | 0 | <p>I have tidied up your query a little (although this won't make a massive amount of difference to performance, and there may be typos as I don't have VS to hand). From your edit it seems you are a little confused by deferred execution in LINQ. <code>callDetailsForNodes</code> does not represent your results - it is a query that will provide your results once it is executed.</p> <p>If you have to do all this querying in process I suggest you add a <code>ToList</code> after the first select and run that in isolation. Then add <code>ToList</code> to the <code>Where</code> clause. Calling <code>ToList</code> will force your query to execute and you will see where the delays are.</p> <p>One final note - you should pass your records directly to <code>ObservableCollection</code> constructor rather than calling <code>Add</code> for each item. Calling <code>Add</code> will (I think) cause the collection to raise a changed notification which is not a big deal for small lists but will slow things down for larger lists.</p> <pre><code>var callDetailsForNodes = dtRowForNode.AsEnumerable() .Select(dr => new { caller1 = StringComparer.CurrentCultureIgnoreCase.Compare(dr["F1"], dr["F2"]) < 0 ? dr["F1"] : dr["F2"], caller2 = StringComparer.CurrentCultureIgnoreCase.Compare(dr["F1"], dr["F2"]) < 0 ? dr["F2"] : dr["F1"], time = Convert.ToDateTime(dr["F3"]), filters = dr.Field<string>("F9")}) .Where(dr => (dtMin <= dr.time) && (dtMax >= dr.time) && (lstCallType.Contains(dr.filters)) && (dtMinTime <= dr.time.TimeOfDay) && (dtMaxTime >= dr.time.TimeOfDay) && caller1 == VerSelected || caller2 == VerSelected)) .GroupBy(drg => new { drg.caller1, drg.caller2 }) .Select(drg => new { drg.Key.caller1, drg.Key.caller2, count = drg.Count()); </code></pre> |
5,062,074 | 0 | How can I capture and stream video from the iPhone's camera? <p>What's the best, most convenient, and most Apple-permitted way of streaming video from the iPhone's camera to a server on the Internet (or local network)?</p> <p>uStream, Qik, Justin.tv, etc.. Are all able to do it, but I'm finding very little love from my searches. It seems that the traditional way of doing it was to use UIGetScreenImage(), but surely there is a more "modern" since video recording is now part of the API.</p> |
37,296,847 | 0 | Type definitions for JavaScript libraries <p>I tried to convert a simple React project from JavaScript to TypeScript, but somehow this doesn't seem to work.</p> <p>First VSCode shows me sometimes that <code>react</code> isn't a module, even if I installed it with typings and added the <code>typings/index.d.ts</code> to the <code>tsconfig.json</code> <code>files</code> list. When I restart VSCode it works after opening a few files, but it never seems to work right away.</p> <p>Then I use <code>history</code> and typings also found a history type definition and installed it, but when I try to import <code>history/lib/createBrowserHistory</code> TypeScript doesn't know anything about it and talks about missing modules again.</p> |
20,786,199 | 0 | <p>By keeping a circular buffer of runes, you can minimise allocations. Also note that reading a new key from a map returns the zero value (which for int is 0), which means the unknown key check in your code is redundant.</p> <pre><code>func Parse(text string, n int) map[string]int { chars := make([]rune, 2 * n) table := make(map[string]int) k := 0 for _, chars[k] = range strings.Join(strings.Fields(text), " ") + " " { chars[n + k] = chars[k] k = (k + 1) % n table[string(chars[k:k+n])]++ } return table } </code></pre> |
23,920,228 | 0 | <p>I found a solution that works, though I admit I am not sure exactly how it works. I added the line <code>context.Configuration.ProxyCreationEnabled = false;</code> to my method that returns the object collection and all my objects were returned. I got the code from the following <a href="http://stackoverflow.com/questions/8173524/webapi-with-ef-code-first-generates-error-when-having-parent-child-relation">SO Question - WebApi with EF Code First generates error when having parent child relation</a>.</p> <pre><code>public class ClientsController : ApiController { public IEnumerable<Client> GetAllClients() { using (var context = new MyClientModel.MyEntities()) { context.Configuration.ProxyCreationEnabled = false; // ** New code here ** var query = context.Clients.Where(c => c.State == "CA"); var customers = query.ToList(); return customers; } } } </code></pre> |
32,203,454 | 0 | <p>Implement a custom <code>XmlResolver</code> and use it for reading the XML. By default, the <code>XmlUrlResolver</code> is used, which automatically downloads the resolved references.</p> <pre><code>public class CustomResolver : XmlUrlResolver { public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn) { // base calls XmlUrlResolver.DownloadManager.GetStream(...) here } } </code></pre> <p>And use it like this:</p> <pre><code>var settings = new XmlReaderSettings { XmlResolver = new CustomResolver() }; var reader = XmlReader.Create(fileName, settings); var xDoc = XDocument.Load(reader); </code></pre> |
35,090,925 | 0 | <p>The code with completion block should like this:</p> <pre><code>func getSectionsFromData(completion: ([Sections]? -> Void)){ var sectionsArray = [Sections]() let animals = Sections(title: "Animals", objects: ["Cats", "Dogs", "Birds", "Lions"]) Alamofire.request(.GET, url).validate().responseJSON { response in switch response.result { case .Success: if let value = response.result.value { let json = JSON(value) for (_, subJson) in json { for (_, data) in subJson { for (title, objects) in data { sectionsArray.append(Sections(title: title, objects: objects.self.arrayValue.map { $0.string!})) } } } } sectionsArray.append(animals) completion(sectionsArry) case .Failure(let error): print(error) sectionsArray.append(animals) completion(nil) } } } </code></pre> <p>When you call the func:</p> <pre><code>var sections: [Sections] = [] SectionsData().getSectionsFromData({ sectionsArray in self.sections = sectionsArray //reload your table with sectionsArray }) </code></pre> |
12,561,167 | 0 | <blockquote> <p>When i click "Cook" it shows an alert "Error occurred [object Object]".</p> </blockquote> <p>The alert method can not display object structures, so you just get <code>[object Object]</code> in that debug attempt.</p> <p>Use <code>console.log(response.error)</code> instead, and then have a look into your browser’s JavaScript console to see what the actual error is.</p> |
16,822,378 | 0 | <p>I didn't understand your question, do you want dynamic columns? If so, you can do that on the XMLP report or cross table in crystal... Using peopletools, you will have to write a HTML area</p> |
28,987,529 | 0 | How to make a ListView in Windows Phone 8.1 where i can put a handler in each item i choose <p>I'm trying to create a ListView in XAML file by this example:</p> <pre><code><ListView x:Name="listView1" SelectionChanged="ListView_SelectionChanged"> <x:String>Item 1</x:String> <x:String>Item 2</x:String> </ListView> </code></pre> <p>But, how can I handle it if I click in Item 1 to go to other page?</p> |
12,864,532 | 0 | <p>Email address is accessible for the authenticated user as long as you request "r_emailaddress" permissions upon authorization.</p> <p>Take a look at the Oauth Login Dialog that's presented to the user to authorize the application. Notice how "email address" isn't presented as one of the profile fields that the application wants to access. You'll need to modify this line in your code:</p> <pre><code>var request = new RestRequest { Path = "requestToken?scope=r_basicprofile+r_emailaddress", }; </code></pre> <p>To this:</p> <pre><code>var request = new RestRequest { Path = "requestToken?scope=r_basicprofile%20r_emailaddress", }; </code></pre> <p>The space should be URL encoded in your request token path. </p> <p>Thanks, Kamyar Mohager</p> |
12,684,381 | 0 | <p><code>\</code> denotes the start of an escape sequence, so it has to be escaped with another <code>\</code>.</p> <p>To replace globally, you need to use regex, which requires even more character escaping:</p> <pre><code> > 'C:/TEST/'.replace(/\//g, '\\') "C:\TEST\" </code></pre> |
27,546,567 | 0 | What in this code is causing a Seg fault? <p>I am very new to Assembly programming and to learn NASM I decided to try and write a prime number testing. I wrote the code for the <code>is_prime</code> function in 32-bit elf NASM and wrote a wrapper in c++ that uses externs the NASM function. When I compiled both programs to <code>.o</code> files there were no errors, and when I linked the object files to make an executable it linked correctly. However when I try to run it I keep getting a <code>Segmentation Fault</code> error and I have no idea what this actually means or how to correct it. The code that I wrote in NASM looks like this:</p> <pre><code>section .bss n: resb 1 i: resb 1 m: resb 1 section .text global is_prime is_prime: push ebp mov ebp,esp mov eax,[ebp + 8] jmp main main: mov [n],eax mov byte [i],2 mov eax,[i] mov ebx,[n] cmp eax,ebx jge prime mov eax,[i] mov ebx,[n] call mod cmp byte [m],0 je comp jmp main mod: mov ecx,ebx xor edx,edx div ecx mov [m],edx ret comp: mov eax,0 jmp kill prime: mov eax,1 jmp kill kill: ret leave </code></pre> <p>My main question is, am I doing something wrong in my assembly program that is causing this error and if so, how do I fix this? Or is there something wrong in the way I am linking/compiling it? I am using a 64-bit Ubuntu but I used the <code>-m32</code> and <code>-f elf32</code> options while compiling. </p> |
3,655,236 | 0 | <p>After trying all of the other solutions here without success, I skeptically tried the solution found in <a href="http://www.thescube.com/blog/chrome-background-colour-image-not-showing/" rel="nofollow noreferrer">this article</a>, and got it to work.</p> <p>Essentially, it boils down to removing <code>@charset "utf-8";</code> from your CSS.</p> <p>This seems like a poor implementation in DreamWeaver - but it did fix the issue for me, regardless.</p> |
28,978,759 | 0 | Length check in a handlebars.js {{#if}} conditional <p>Is there a way in <a href="http://handlebarsjs.com/" rel="nofollow">handlebars</a> JS to check length of a value? Something like this:</p> <pre><code>{{#if value.length > 20} ..do something {{else}} ..do something {{/if}} </code></pre> |
10,277,663 | 0 | How to handle exception in wicket <p>my code:</p> <pre><code>try { LinkedDataForm form = webService.process(searchForm, path); add(new ExternalLink("url", form.getUrl(), form.getUrl())); } catch (Exception e) { add(new Label("error", e.getMessage())); } </code></pre> <p>where: </p> <pre><code>@SpringBean(name = "webService") WebService webService; </code></pre> <p>and my html page looks like:</p> <pre><code><a wicket:id="url">url</a> <p wicket:id="error"/> </code></pre> <p>the problem is in html page that I have url or error and then wicket return exception: <code>Unable to find component with id 'error' in ...</code> how I can solve this problem</p> |
11,571,834 | 0 | How to remove duplicate users from a list but amalgamate their roles <p>Say I have a list of People who have a name and a list of roles:</p> <p>Each item in the list is of type PersonDetails:</p> <pre><code>public class PersonDetails { public int Id { get; set; } public string Name { get; set; } public List<Role> Roles { get; set; } } public class Role { public string Name { get; set; } } </code></pre> <p>So in my list of these items I might have the following:</p> <ol> <li>Id 23 Eric whose roles contains a role with Role.Name = "Manager"</li> <li>Id 23 Eric whose roles contains a role with Role.Name = "CEO"</li> <li>Id 23 Eric whose roles contains a role with Role.Name = "CIO"</li> </ol> <p>so that is how it is currently but because it is the same person I want my list to be:</p> <ol> <li>Id 23 Eric whose roles contains "Manager", "CEO", "CIO"</li> </ol> <p>Can anyone tell me how to change my list of items to be like this?</p> |
16,929,265 | 0 | <p>You should just join tables <br></p> <pre><code>SELECT * FROM `affiliate_information` a_i LEFT JOIN `affiliate_tasks` a_t ON a_i.`username` = a_t.`username` WHERE a_i.`username` = 'SomeUsername' </code></pre> |
20,131,926 | 0 | <p>Here's a working example made from following <a href="https://developers.facebook.com/docs/plugins/like-button/" rel="nofollow">Facebooks developer guidelines for the Like button</a>. Place this right after the opening body tag: </p> <pre><code> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <div class="fb-like" data-href="https://www.facebook.com/MagnoliaRV" data-layout="standard" data-action="like"></div> </code></pre> |
23,091,328 | 0 | cannot find javax.swing.JPanel <p>I'm a novice in java coding. Just downloaded the JDK 8 and Eclipse java ee ide.</p> <p>eclipse cannot find JPanel.</p> <p>the error says the JPanel has an access restriction. </p> <p>how do I fix this?</p> <p>here is my program</p> <pre><code>import java.awt.*; import java.awt.event.*; import javax.swing.*; public class purcellm26try2 extends JPanel { public void paintComponent(Graphics g){ super.paintComponent(g); this.setBackground(Color.WHITE); g.setColor(Color.WHITE); } } </code></pre> <p>I can rephrase my question if users don't understand. Thank you</p> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.