pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
11,784,072 | 0 | <p>If you don't have to use recursion, here's a much more efficient check for palindrome:</p> <pre><code>public boolean isPalindrome3(String input) { for (int start = 0, end = input.length() - 1; start < end; ) { if (input.charAt(start++) != input.charAt(end--)) { return false; } } return true; } </code></pre> |
4,171,112 | 0 | <p>You seem to be writing a makefile in GNUMake style, but actually running some other version of Make. If it's not obvious what autoreconf is calling, you could insert a rule in the makefile:</p> <pre><code>dummy: @echo using $(MAKE) $(MAKE) -v </code></pre> <p>If this theory proves correct, you can either persuade autoconf to use GNUMake, or write for the version it's using.</p> |
36,379,765 | 0 | <p>It is a <a href="http://developer.android.com/reference/android/support/design/widget/CollapsingToolbarLayout.html" rel="nofollow">CollapsingToolbarLayout</a>. </p> <p>Here is an example extracted from <a href="http://antonioleiva.com/collapsing-toolbar-layout/" rel="nofollow">this link</a>:</p> <pre><code><android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <android.support.design.widget.AppBarLayout android:id="@+id/app_bar_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" android:fitsSystemWindows="true"> <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/collapsing_toolbar" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_scrollFlags="scroll|exitUntilCollapsed" app:contentScrim="?attr/colorPrimary" app:expandedTitleMarginStart="48dp" app:expandedTitleMarginEnd="64dp" android:fitsSystemWindows="true"> <com.antonioleiva.materializeyourapp.SquareImageView android:id="@+id/image" android:layout_width="match_parent" android:layout_height="wrap_content" android:scaleType="centerCrop" android:fitsSystemWindows="true" app:layout_collapseMode="parallax"/> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" app:layout_collapseMode="pin" /> </android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.AppBarLayout> </android.support.design.widget.CoordinatorLayout> </code></pre> |
8,581,785 | 0 | <p>Here is a Class that I wrote and used at several places look thru the methods to see what you can use.. </p> <pre><code>using System; using System.Text; using System.Collections; using System.DirectoryServices; using System.Diagnostics; using System.Data.Common; namespace Vertex_VVIS.SourceCode { public class LdapAuthentication { private String _path; private String _filterAttribute; public LdapAuthentication(String path) { _path = path; } public bool IsAuthenticated(String domain, String username, String pwd) { String domainAndUsername = domain + @"\" + username; DirectoryEntry entry = new DirectoryEntry(_path, domainAndUsername, pwd); try { //Bind to the native AdsObject to force authentication. // Object obj = entry.NativeObject; DirectorySearcher search = new DirectorySearcher(entry); search.Filter = "(SAMAccountName=" + username + ")"; search.PropertiesToLoad.Add("cn"); SearchResult result = search.FindOne(); if (null == result) { return false; } //Update the new path to the user in the directory. _path = result.Path; _filterAttribute = (String)result.Properties["cn"][0]; } catch (Exception ex) { throw new Exception("Error authenticating user. " + ex.Message); } return true; } public String GetName(string username) { String thename = null; try { DirectoryEntry de = new DirectoryEntry(_path); DirectorySearcher ds = new DirectorySearcher(de); ds.Filter = String.Format("(SAMAccountName={0})", username); ds.PropertiesToLoad.Add("displayName"); SearchResult result = ds.FindOne(); if (result.Properties["displayName"].Count > 0) { thename = result.Properties["displayName"][0].ToString(); } else { thename = "NA"; } } catch (Exception ex) { throw new Exception("Error Getting Name. " + ex.Message); } return thename.ToString(); } public String GetEmailAddress(string username) { String theaddress = null; try { DirectoryEntry de = new DirectoryEntry(_path); DirectorySearcher ds = new DirectorySearcher(de); ds.Filter = String.Format("(SAMAccountName={0})", username); ds.PropertiesToLoad.Add("mail"); SearchResult result = ds.FindOne(); theaddress = result.Properties["mail"][0].ToString(); de.Close(); } catch (Exception ex) { throw new Exception("Error Getting Email Address. " + ex.Message); } return theaddress.ToString(); } public String GetTitle(string username) { String thetitle = null; try { DirectoryEntry de = new DirectoryEntry(_path); DirectorySearcher ds = new DirectorySearcher(de); ds.Filter = String.Format("(SAMAccountName={0})", username); ds.PropertiesToLoad.Add("title"); SearchResult result = ds.FindOne(); result.GetDirectoryEntry(); if (result.Properties["title"].Count > 0) { thetitle = result.Properties["title"][0].ToString(); } else { thetitle = "NA"; } } catch (Exception ex) { throw new Exception("Error Getting the Title. " + ex.Message); } return thetitle.ToString(); } public String GetPhone(string username) { String thephone = null; try { DirectoryEntry de = new DirectoryEntry(_path); DirectorySearcher ds = new DirectorySearcher(de); ds.Filter = String.Format("(SAMAccountName={0})", username); ds.PropertiesToLoad.Add("mobile"); SearchResult result = ds.FindOne(); result.GetDirectoryEntry(); if (result.Properties["mobile"].Count > 0) { thephone = result.Properties["mobile"][0].ToString(); } else { thephone = "NA"; } } catch (Exception ex) { throw new Exception("Error Getting Phone Number. " + ex.Message); } return thephone.ToString(); } public String GetGroups() { DirectorySearcher search = new DirectorySearcher(_path); search.Filter = "(cn=" + _filterAttribute + ")"; search.PropertiesToLoad.Add("memberOf"); StringBuilder groupNames = new StringBuilder(); try { SearchResult result = search.FindOne(); int propertyCount = result.Properties["memberOf"].Count; String dn; int equalsIndex, commaIndex; for (int propertyCounter = 0; propertyCounter < propertyCount; propertyCounter++) { dn = (String)result.Properties["memberOf"][propertyCounter]; equalsIndex = dn.IndexOf("=", 1); commaIndex = dn.IndexOf(",", 1); if (-1 == equalsIndex) { return null; } groupNames.Append(dn.Substring((equalsIndex + 1), (commaIndex - equalsIndex) - 1)); groupNames.Append("|"); } } catch (Exception ex) { throw new Exception("Error obtaining group names. " + ex.Message); } return groupNames.ToString(); } public bool IsUserGroupMember(string strUserName, string strGroupString) { bool bMemberOf = false; ResultPropertyValueCollection rpvcResult = null; try { DirectoryEntry de = new DirectoryEntry(_path); DirectorySearcher ds = new DirectorySearcher(de); ds.Filter = String.Format("(SAMAccountName={0})", strUserName); ds.PropertiesToLoad.Add("memberOf"); SearchResult result = ds.FindOne(); string propertyName = "memberOf"; rpvcResult = result.Properties[propertyName]; foreach (Object propertyValue in rpvcResult) { if (propertyValue.ToString().ToUpper() == strGroupString.ToUpper()) { bMemberOf = true; break; } } } catch (Exception ex) { throw new Exception("Error Getting member of. " + ex.Message); } return bMemberOf; } } } </code></pre> |
489,674 | 0 | <p>This doesn't sound right. To test it out, I wrote a simple app, that creates a DataTable and adds some data to it. On the button1 click it binds the table to the DataGridView. Then, I added a second button, which when clicked, adds another column to the underlying DataTable. When I tested it, and I clicked the second button, the grid immedialtey reflected the update. To test the reverse, I added a third button which pops up a dialog with a DataGridView that gets bound to the same datatable. At runtime, I then added some values to the first datagridview, and when I clicked the button to bring up the dialog, the changes were reflected.</p> <p>My point is, they are supposed to stay concurrent. Mark may be right when he suggested you check if AutoGenerateColumns is set to true. You don't need to call DataBind though, that's only for a GridView on the web. Maybe you can post of what you're doing, because this SHOULD work.</p> <p>How I tested it:</p> <pre><code> DataTable table = new DataTable(); public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { table.Columns.Add("Name"); table.Columns.Add("Age", typeof(int)); table.Rows.Add("Alex", 26); table.Rows.Add("Jim", 36); table.Rows.Add("Bob", 34); table.Rows.Add("Mike", 47); table.Rows.Add("Joe", 61); this.dataGridView1.DataSource = table; } private void button2_Click(object sender, EventArgs e) { table.Columns.Add("Height", typeof(int)); foreach (DataRow row in table.Rows) { row["Height"] = 100; } } private void button3_Click(object sender, EventArgs e) { GridViewer g = new GridViewer { DataSource = table }; g.ShowDialog(); } public partial class GridViewer : Form //just has a DataGridView on it { public GridViewer() { InitializeComponent(); } public object DataSource { get { return this.dataGridView1.DataSource; } set { this.dataGridView1.DataSource = value; } } } </code></pre> |
35,584,973 | 0 | <p>The drawing setup is quite involved, but the actual calls required to draw are fairly straightforward. From the <code>tri.c</code> (which draws a 2D triangle):</p> <pre><code>// ... vkCmdBeginRenderPass(demo->draw_cmd, &rp_begin, VK_SUBPASS_CONTENTS_INLINE); vkCmdBindPipeline(demo->draw_cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, demo->pipeline); vkCmdBindDescriptorSets(demo->draw_cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, demo->pipeline_layout, 0, 1, & demo->desc_set, 0, NULL); VkViewport viewport = {}; viewport.height = (float) demo->height; viewport.width = (float) demo->width; viewport.minDepth = (float) 0.0f; viewport.maxDepth = (float) 1.0f; vkCmdSetViewport(demo->draw_cmd, 0, 1, &viewport); VkRect2D scissor = {}; scissor.extent.width = demo->width; scissor.extent.height = demo->height; scissor.offset.x = 0; scissor.offset.y = 0; vkCmdSetScissor(demo->draw_cmd, 0, 1, &scissor); VkDeviceSize offsets[1] = {0}; vkCmdBindVertexBuffers(demo->draw_cmd, VERTEX_BUFFER_BIND_ID, 1, &demo->vertices.buf, offsets); vkCmdDraw(demo->draw_cmd, 3, 1, 0, 0); vkCmdEndRenderPass(demo->draw_cmd); // ... </code></pre> <p>This snippet assumes that you've already gotten the <code>VkPipeline</code> (which include shaders, etc.), <code>VkBuffer</code> (for the vertex buffer), and the <code>VkCommandBuffer</code> in appropriate states. It's the <code>vkCmdDraw</code> that actually issues the command to draw, once the containing <code>VkCommandBuffer</code> is executed.</p> |
13,906,998 | 0 | Send attachment on Custom made SMTP server <p>I am currently working on my own SMTP server and I can successfully send email arounds from various programs and web pages such as Outlook, PHP and Pear Mail. </p> <p>The next stage I need to do is to try and send an attachment via my SMTP server. I have tried doing a LAN trace of my server while sending an attachment via PHP to another SMTP server and I can see I get the follwing from the client:</p> <pre><code>DATA fragment, 661 bytes </code></pre> <p>I'm not sure if this is related to the attachment or not. </p> <p>If it is, is this just telling the SMTP server how long the file is and then I should just write a base 64 encoded string onto the network stream and write it to a file to be used for sending the email on. </p> <p>Thanks for any help you can provide. </p> |
20,111,305 | 0 | <p>The regex you can use is like this: </p> <pre><code>/SIP\/(\d+)@PBX/ </code></pre> <p>This finds:</p> <pre><code>text SIP followed by a / (which is escaped so it isn't interpreted as the end of the regex) followed by one or more digits (captured in a group delineated with parens) followed by the text @PBX </code></pre> <p>And, then you pull out the first matched group if there's a match.</p> <p>And, if you have nothing else to go on other than it's in a <code><td></code> in your page, then you can use this generic code that looks at all <code><td></code> elements in the page. Ideally, you would use the structure of the page to more clearly target the appropriate <code><td></code> cells.</p> <pre><code>var tds = document.getElementsByTagName("td"); var regex = /SIP\/(\d+)@PBX/; for (var i = 0; i < tds.length; i++) { var matches = tds[i].innerHTML.match(regex); if (matches) { var number = parseInt(matches[1], 10); // process the number here } } </code></pre> <p>Working demo: <a href="http://jsfiddle.net/jfriend00/vDwfs/" rel="nofollow">http://jsfiddle.net/jfriend00/vDwfs/</a></p> <hr> <p>If the HTML is not in your page, but in a string, then you can just use the same regex to search for it in the HTML string. You could bracket it with <code><td></code> and <code></td></code> if that seems wise based on your context.</p> <pre><code>var matches, number; var regex = /SIP\/(\d+)@PBX/g; while (matches = regex.exec(htmlString)) { number = parseInt(matches[1], 10); // process the number here } </code></pre> |
23,764,334 | 0 | Xcode compiler flag to draw view edges <p>I'm working with Auto Layout in code and I am unsure where some edges are falling. I know there is a way to draw yellow lines for all view edges, but I can't find it.</p> <p>Does anyone here know compiler flag/build environment variable that can be set to draw an outline for all views, or point me to a reference that contains this? </p> |
9,323,308 | 0 | <p>When a assembly' s AssemblyVersion is changed, If it has strong name, the referencing assemblies need to be recompiled, otherwise the assembly does not load! If it does not have strong name, if not explicitly added to project file, it will not be copied to output directory when build so you may miss depending assemblies, especially after cleaning the output directory. </p> |
19,048,256 | 0 | <p>How about every ajax call has an id (which you should document in some way if you have a lot of them) and all the handlers are in one file with a huge ass switch case loop.Or if it's gonna be a big file maybe organise them in a few files - id 3001, 3002, 3003 form submits go to formHandler.php id 4001 400n go to layout system and so on.</p> |
28,034,416 | 0 | <p>Here's what you need to do.</p> <ol> <li>Find the directory in which your script.py is.</li> <li>Move your setup.py to this directory and please keep this window open.</li> <li>Hold shift, right click this directory, and open command window here.</li> <li>In the command window type: <code>C:\Python34\python.exe setup.py py2exe</code></li> </ol> |
36,983,958 | 0 | Reply to a selected or opened mail in outlook using excel macro <p>I have made a code in excel which creates a mail using excel envelop. But this code creates a new email, instead, I want to reply to a particular mail which is selected or opened in my outlook. There is no fixed pattern in my emails to which I want to reply such as a particular subject or sender. So I want to reply/replyall to mail only which I select or open in outlook. Where should I make changes in my code? Please Help!! `</p> <pre><code>'Option Explicit Private Sub Generate_Ticket_Email_Click() 'varCap = Generate_Ticket_Email.Caption 'Generate_Ticket_Email.Caption = "DiscardMail" On Error GoTo ErrHandler 'SET Outlook APPLICATION OBJECT. Dim objOutlook As Object Set objOutlook = CreateObject("Outlook.Application") ' CREATE EMAIL OBJECT. Dim objEmail As Object Set objEmail = objOutlook.CreateItem(olMailItem) ActiveSheet.Range("B7:D31").Select If Generate_Ticket_Email.Caption <> "Generate E-mail" Then Generate_Ticket_Email.Caption = "Generate E-mail" ActiveWorkbook.EnvelopeVisible = False GoTo ErrHandler End If ActiveWorkbook.EnvelopeVisible = True 'ActiveWorkbook.EnvelopeVisible = False 'End If With ActiveSheet.MailEnvelope .Item.To = Range("J16") .Item.CC = Range("J17") .Item.Subject = Range("F18") End With Generate_Ticket_Email.Caption = "Discard E-mail" ' CLEAR. Set objEmail = Nothing: Set objOutlook = Nothing ErrHandler: ' End Sub </code></pre> |
21,427,745 | 0 | <p>I solved the same issue with UIViewController categories that is in the common included file. So each UIviewController in its init function calls [self setMyColor]. </p> <p>This is my code:</p> <pre><code>@interface ColorViewController : UIViewController - (void) setMyColor; @end </code></pre> |
12,483,066 | 0 | <p>I've been using <code>async</code> in production for a couple of years. There are a few core "best practices" that I recommend:</p> <ol> <li><a href="http://nitoprograms.blogspot.com/2012/07/dont-block-on-async-code.html" rel="nofollow">Don't block on <code>async</code> code</a>. Use <code>async</code> "all the way down". (Corollary: prefer <code>async Task</code> to <code>async void</code> unless you <em>have</em> to use <code>async void</code>).</li> <li>Use <code>ConfigureAwait(false)</code> wherever possible in your "library" methods.</li> </ol> <p>You've already figured out the "<code>async</code> all the way down" part, and you're at the point that <code>ConfigureAwait(false)</code> becomes useful.</p> <p>Say you have an <code>async</code> method <code>A</code> that calls another <code>async</code> method <code>B</code>. <code>A</code> updates the UI with the results of <code>B</code>, but <code>B</code> doesn't depend on the UI. So we have:</p> <pre><code>async Task A() { var result = await B(); myUIElement.Text = result; } async Task<string> B() { var rawString = await SomeOtherStuff(); var result = DoProcessingOnRawString(rawString); return result; } </code></pre> <p>In this example, I would call <code>B</code> a "library" method since it doesn't really need to run in the UI context. Right now, <code>B</code> <em>does</em> run in the UI thread, so <code>DoProcessingOnRawString</code> is causing responsiveness issues.</p> <p>So, add a <code>ConfigureAwait(false)</code> to every <code>await</code> in <code>B</code>:</p> <pre><code>async Task<string> B() { var rawString = await SomeOtherStuff().ConfigureAwait(false); var result = DoProcessingOnRawString(rawString); return result; } </code></pre> <p>Now, when <code>B</code> resumes after <code>await</code>ing <code>SomeOtherStuff</code> (assuming it did actually have to <code>await</code>), it will resume on a thread pool thread instead of the UI context. When <code>B</code> completes, even though it's running on the thread pool, <code>A</code> will resume on the UI context.</p> <p>You can't add <code>ConfigureAwait(false)</code> to <code>A</code> because <code>A</code> depends on the UI context.</p> <p>You also have the option of explicitly queueing tasks to the thread pool (<code>await Task.Run(..)</code>), and you <em>should</em> do this if you have particular CPU-intensive functionality. But if your performance is suffering from "thousands of paper cuts", you can use <code>ConfigureAwait(false)</code> to offload a lot of the <code>async</code> "housekeeping" onto the thread pool.</p> <p>You may find my <a href="http://nitoprograms.blogspot.com/2012/02/async-and-await.html" rel="nofollow">intro post helpful</a> (it goes into more of the "why's"), and the <a href="http://blogs.msdn.com/b/pfxteam/archive/2012/04/12/10293335.aspx" rel="nofollow"><code>async</code> FAQ</a> also has lots of great references.</p> |
27,015,318 | 0 | How to set order of SQL-response? <p>I've got a mule flow that queries a SQL-server database and then converts the response to JSON and then writes the JSON comma separated to file.</p> <p>My problem is that the order of the column in the written file doesn't match the order of the fields in the query. How tho define the order of columns in a query answer?</p> <p>The JSON to CSV conversion is like this:</p> <pre><code> public class Bean2CSV { /** * @param args * @throws JSONException */ public String conv2csv(Object input) throws JSONException { if (!input.equals(null)){ String inputstr = (String)input; JSONArray jsonArr = new JSONArray(inputstr); String csv = CDL.toString(jsonArr); csv = csv.replace(',', ';'); System.out.println(inputstr); //csv System.out.println(csv); //csv return csv; } else return "";} } </code></pre> <p>and here is the flow</p> <hr> <pre><code><?xml version="1.0" encoding="UTF-8"?> <mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.mulesoft.org/schema/mule/jdbc" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" version="CE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule- http.xsd http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.mulesoft.org/schema/mule/jdbc http://www.mulesoft.org/schema/mule/jdbc/current/mule-jdbc.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring- beans-current.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd"> <context:property-placeholder location="classpath:cognos_import.properties" ignore-resource-not-found="true"/> <spring:beans> <spring:bean id="dataSource" name="dataSource" class="org.enhydra.jdbc.standard.StandardDataSource" destroy-method="shutdown"> <spring:property name="driverName" value="net.sourceforge.jtds.jdbc.Driver"/> <spring:property name="user" value="${dbusername}"/> <spring:property name="password" value="${dbpassword}"/> </spring:bean> <spring:bean id="changeDB" class="ChangeDatabase"> <spring:property name="serverip" value="${dbserverip}"/> <spring:property name="serverport" value="${dbserverport}"/> <spring:property name="dbprefix" value="${dbprefix}"/> </spring:bean> </spring:beans> <jdbc:connector name="db_conn" dataSource-ref="dataSource" validateConnections="false" pollingFrequency="5000" doc:name="Database"> <jdbc:query key="readbal" value="SELECT #[header:INBOUND:company] as company, AcNo as Konto , R2 as Avd, #[header:INBOUND:period] as Period, sum(AcAm) as Saldo FROM AcTr WHERE (AcYrPr &lt;= #[header:INBOUND:period]) and (AcNo &lt; 3000) GROUP BY AcNo,R2 ORDER BY AcNo,R2;"/> <jdbc:query key="readres" value="SELECT #[header:INBOUND:company] as company, AcNo as Konto , R2 as Avd, #[header:INBOUND:period] as Period, sum(AcAm) as Saldo FROM AcTr WHERE (AcYrPr &lt;= #[header:INBOUND:period]) and (AcYrPr &gt;= #[header:INBOUND:starttid]) and (AcNo &gt;= 3000) GROUP BY AcNo,R2 ORDER BY AcNo,R2"/> <jdbc:query key="readiclr" value="SELECT #[header:INBOUND:company] as company, AcTr.AcNo as Konto , AcTr.R2 as Avd, #[header:INBOUND:period] as Period, sum(AcTr.AcAm) as Saldo,sum(AcTr.CurAm) as ValutaBel, AcTr.Cur as Valuta, AcTr.R1 as FtgID FROM AcTr LEFT JOIN Actor ON AcTr.R1=Actor.R1 WHERE (AcTr.AcYrPr &lt;= #[header:INBOUND:period]) and (AcTr.AcYrPr &gt;= #[header:INBOUND:starttid]) and Actor.SAcSet=2 and (AcTr.AcNo=3019 or AcTr.AcNo=3099 or AcTr.AcNo=3199 or AcTr.AcNo=3299 or AcTr.AcNo=3499 or AcTr.AcNo=3519 or AcTr.AcNo=3599 or AcTr.AcNo=3699 or AcTr.AcNo=3799 or AcTr.AcNo=3919 or AcTr.AcNo=3999 or AcTr.AcNo=4299 or AcTr.AcNo=4399 or AcTr.AcNo=4599 or AcTr.AcNo=4699 or AcTr.AcNo=4799 or AcTr.AcNo=5099 or AcTr.AcNo=5299 or AcTr.AcNo=5499 or AcTr.AcNo=5699 or AcTr.AcNo=5799 or AcTr.AcNo=5999 or AcTr.AcNo=6099 or AcTr.AcNo=6399 or AcTr.AcNo=6499 or AcTr.AcNo=6999 or AcTr.AcNo=7999 or AcTr.AcNo=8399 or AcTr.AcNo=8499) and AcTr.Sup&lt;&gt;0 GROUP BY AcTr.AcNo,AcTr.R2,AcTr.R1,AcTr.Cur"/> <jdbc:query key="readickr" value="SELECT #[header:INBOUND:company] as company, AcTr.AcNo as Konto , AcTr.R2 as Avd, #[header:INBOUND:period] as Period, sum(AcTr.AcAm) as Saldo,sum(AcTr.CurAm) as ValutaBel, AcTr.Cur as Valuta, AcTr.R1 as FtgID FROM AcTr LEFT JOIN Actor ON AcTr.R1=Actor.R1 WHERE (AcTr.AcYrPr &lt;= #[header:INBOUND:period]) and (AcTr.AcYrPr &gt;= #[header:INBOUND:starttid]) and Actor.CAcSet=2 and (AcTr.AcNo=3019 or AcTr.AcNo=3099 or AcTr.AcNo=3199 or AcTr.AcNo=3299 or AcTr.AcNo=3499 or AcTr.AcNo=3519 or AcTr.AcNo=3599 or AcTr.AcNo=3699 or AcTr.AcNo=3799 or AcTr.AcNo=3919 or AcTr.AcNo=3999 or AcTr.AcNo=4299 or AcTr.AcNo=4399 or AcTr.AcNo=4599 or AcTr.AcNo=4699 or AcTr.AcNo=4799 or AcTr.AcNo=5099 or AcTr.AcNo=5299 or AcTr.AcNo=5499 or AcTr.AcNo=5699 or AcTr.AcNo=5799 or AcTr.AcNo=5999 or AcTr.AcNo=6099 or AcTr.AcNo=6399 or AcTr.AcNo=6499 or AcTr.AcNo=6999 or AcTr.AcNo=7999 or AcTr.AcNo=8399 or AcTr.AcNo=8499) and AcTr.Cust&lt;&gt;0 GROUP BY AcTr.AcNo,AcTr.R2,AcTr.R1,AcTr.Cur"/> <jdbc:query key="readiclb" value="SELECT #[header:INBOUND:company] as company, AcTr.AcNo as Konto, AcTr.R2 as Avd, #[header:INBOUND:period] as Period, sum(AcTr.AcAm) as Saldo, sum(AcTr.CurAm) as ValutaBel, AcTr.Cur as Valuta, AcTr.R1 as FtgID FROM AcTr LEFT JOIN Actor ON AcTr.R1=Actor.R1 WHERE (AcTr.AcYrPr &lt;= #[header:INBOUND:period]) and Actor.SAcSet=2 and AcTr.Sup&lt;&gt;0 and (AcTr.AcNo=1511 or AcTr.AcNo=2441) GROUP BY AcTr.AcNo,AcTr.R2,AcTr.R1,AcTr.Cur"/> <jdbc:query key="readickb" value="SELECT #[header:INBOUND:company] as company, AcTr.AcNo as Konto, AcTr.R2 as Avd, #[header:INBOUND:period] as Period, sum(AcTr.AcAm) as Saldo, sum(AcTr.CurAm) as ValutaBel, AcTr.Cur as Valuta, AcTr.R1 as FtgID FROM AcTr LEFT JOIN Actor ON AcTr.R1=Actor.R1 WHERE (AcTr.AcYrPr &lt;= #[header:INBOUND:period]) and Actor.CAcSet=2 and AcTr.Cust&lt;&gt;0 and (AcTr.AcNo=1511 or AcTr.AcNo=2441) GROUP BY AcTr.AcNo,AcTr.R2,AcTr.R1,AcTr.Cur"/> </jdbc:connector> <file:connector name="output" outputPattern=" #[function:datestamp:dd-MM-yy-hh-mm-ss]#[header:INBOUND:company].txt" autoDelete="false" outputAppend="true" streaming="false" validateConnections="false" doc:name="File"/> <message-properties-transformer name="delete-content-type-header" doc:name="Message Properties"> <delete-message-property key="Content-type"/> </message-properties-transformer> <message-properties-transformer name="add-csv-content-type-header" doc:name="Message Properties"> <add-message-property key="Content-Type" value="text/csv"/> </message-properties-transformer> <message-properties-transformer name="add-filename" doc:name="Message Properties"> <add-message-property key="Content-Disposition" value="attachment; filename=testfil.txt"/> </message-properties-transformer> <flow name="CD-test1Flow1" doc:name="CD-test1Flow1"> <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" doc:name="HTTP"/> <not-filter doc:name="Not"> <wildcard-filter pattern="*favicon*" caseSensitive="true"/> </not-filter> <logger message="Log1 #[message.getPayload()]! " level="INFO" doc:name="Logger1"/> <http:body-to-parameter-map-transformer doc:name="Body to Parameter Map"/> <component class="ValidationService3x" doc:name="Java"/> <echo-component doc:name="Echo"/> <set-variable variableName="Filename" value=" #[function:datestamp:dd-MM-yy-hh-mm-ss]-#[header:INBOUND:company]-#[header:INBOUND:period]" doc:name="FilenameVar"/> <component doc:name="Java"> <spring-object bean="changeDB"/> </component> <all doc:name="All"> <processor-chain> <jdbc:outbound-endpoint exchange-pattern="request-response" queryKey="readbal" connector-ref="db_conn" doc:name="DB"/> <expression-filter expression="payload.size() &gt; 0" doc:name="not empty"/> <json:object-to-json-transformer doc:name="Object to JSON"/> <component class="Bean2CSV" doc:name="Java"/> <echo-component doc:name="Echo"/> <file:outbound-endpoint path="${outputfolder}" outputPattern="#[flowVars['Filename']]-bal.csv" connector-ref="output" doc:name="File"/> </processor-chain> <processor-chain> <jdbc:outbound-endpoint exchange-pattern="request-response" queryKey="readres" connector-ref="db_conn" doc:name="DB100-ickr"/> <expression-filter expression="payload.size() &gt; 0" doc:name="not empty"/> <json:object-to-json-transformer doc:name="Object to JSON"/> <component class="Bean2CSV" doc:name="Java"/> <echo-component doc:name="Echo"/> <file:outbound-endpoint path="${outputfolder}" outputPattern="#[flowVars['Filename']]-res.csv" connector-ref="output" doc:name="File"/> </processor-chain> <processor-chain> <jdbc:outbound-endpoint exchange-pattern="request-response" queryKey="readiclb" connector-ref="db_conn" doc:name="DB100-ickr"/> <expression-filter expression="payload.size() &gt; 0" doc:name="not empty"/> <json:object-to-json-transformer doc:name="Object to JSON"/> <component class="Bean2CSV" doc:name="Java"/> <echo-component doc:name="Echo"/> <file:outbound-endpoint path="${outputfolder}" outputPattern="#[flowVars['Filename']]-icb.csv" connector-ref="output" doc:name="File"/> </processor-chain> <processor-chain> <jdbc:outbound-endpoint exchange-pattern="request-response" queryKey="readickb" connector-ref="db_conn" doc:name="DB100-ickr"/> <expression-filter expression="payload.size() &gt; 0" doc:name="not empty"/> <json:object-to-json-transformer doc:name="Object to JSON"/> <component class="Bean2CSVnotfirstline" doc:name="Java"/> <echo-component doc:name="Echo"/> <file:outbound-endpoint path="${outputfolder}" outputPattern="#[flowVars['Filename']]-icb.csv" connector-ref="output" doc:name="File"/> </processor-chain> <processor-chain> <jdbc:outbound-endpoint exchange-pattern="request-response" queryKey="readiclr" connector-ref="db_conn" doc:name="DB100-ickr"/> <expression-filter expression="payload.size() &gt; 0" doc:name="not empty"/> <json:object-to-json-transformer doc:name="Object to JSON"/> <component class="Bean2CSV" doc:name="Java"/> <echo-component doc:name="Echo"/> <file:outbound-endpoint path="${outputfolder}" outputPattern="#[flowVars['Filename']]-icr.csv" connector-ref="output" doc:name="File"/> </processor-chain> <processor-chain> <jdbc:outbound-endpoint exchange-pattern="request-response" queryKey="readickr" connector-ref="db_conn" doc:name="DB100-ickr"/> <expression-filter expression="payload.size() &gt; 0" doc:name="not empty"/> <json:object-to-json-transformer doc:name="Object to JSON"/> <component class="Bean2CSVnotfirstline" doc:name="Java"/> <echo-component doc:name="Echo"/> <file:outbound-endpoint path="${outputfolder}" outputPattern="#[flowVars['Filename']]-icr.csv" connector-ref="output" doc:name="File"/> </processor-chain> </all> <set-payload value="Nu är 100 tankat till #[flowVars['Filename']] " doc:name="Set Payload"/> <http:response-builder doc:name="HTTP Response Builder"/> </flow> </code></pre> <p></p> |
17,481,890 | 0 | How to write a stored procedure in phpMyAdmin? <p>I am not able to find where to write the stored procedure in phpMyAdmin and how to call it using MVC architecture.</p> |
5,358,263 | 0 | Google_maps_API::Custom_image <p>I have been googling for quite some time now, and have yet to find a viable solution to using your own map images with the google maps API. <a href="http://vigetlabs.github.com/jmapping/" rel="nofollow">Jmapping</a> was <em>exactly</em> what I needed, but did not allow for your own background images.</p> <p>Other than the 'ground overlay' option within the google maps API documentation, I've got no leads left.</p> <p>Is there a sensible way to use your own map/background images with google maps?</p> |
24,365,117 | 0 | <p>Using this simple method, I was able to call stored procedures in MVC application </p> <pre><code>public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText, SqlParameter[] commandParameters) { using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); using (SqlCommand command = new SqlCommand()) { command.Connection = connection; command.CommandTimeout = 0; command.CommandType = commandType; command.CommandText = commandText; if (commandParameters != null && commandParameters.Length > 0) command.Parameters.AddRange(commandParameters); return FillData(command, connection); } } } </code></pre> |
7,014,444 | 0 | <p><strong>data</strong> will contain a result string returned by create.php and that is entirely up to you. What does create.php do at the moment?</p> |
12,418,140 | 0 | New Activity issuing nullpointerexception <p>I am trying to start a new activity to display a list of results from a search. I have been through the android dev stuff and androidhive and through similar posts here dealing with populating a listview with an arraylist in a new activity and I just cant seem to get this to work. I would really appreciate any help, been battling with this for a few days now. </p> <p>Here are the relevants parts of my main activity.</p> <pre><code>Intent intent = new Intent(this, DisplayResultsActivity.class); ArrayList<String> myCommonFilms = new ArrayList<String>(commonFilms.getCommonFilms(titleOne, titleTwo)); Log.d("myCommonFilms", myCommonFilms.toString()); intent.putStringArrayListExtra("myCommonFilmsList", myCommonFilms); startActivity(intent); </code></pre> <p>Here is the new activity:</p> <pre><code>public class DisplayResultsActivity extends Activity { private ListView listView; public void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_display_results); listView = (ListView) findViewById(android.R.id.list); Intent intent = getIntent(); ArrayList<String> myCommonFilms = intent.getStringArrayListExtra("myCommonFilms"); Log.d("myCommonFilms in display", myCommonFilms.toString()); Log.d("ArrayListContents", myCommonFilms.toString()); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.expandable_list_content, myCommonFilms); Log.d("ArrayAdapterContents", arrayAdapter.toString()); listView.setAdapter(arrayAdapter); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_display_results, menu); return true; } } </code></pre> <p>Here is my manifest in case something is up there:</p> <pre><code><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.tot.tipofthetongue" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /> <uses-permission android:name="android.permission.INTERNET" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > <activity android:name=".Main" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".DisplayResultsActivity" android:label="@string/title_activity_display_results" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> </code></pre> <p>Here is my main activity layout:</p> <pre><code><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/home_screen_bg" > <EditText android:id="@+id/searchOne" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="182dp" android:background="@drawable/home_screen_edittext" android:ems="10" android:inputType="textPersonName" /> <Button android:id="@+id/findMovies" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginBottom="32dp" android:text="@string/buttonText" android:onClick="displayResults" /> </RelativeLayout> </code></pre> <p>and lastly the layout of my new activity for displaying the results</p> <pre><code><?xml version="1.0" encoding="utf-8"?> <ListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@id/android:list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/results_bg" android:padding="10dip" android:textSize="16dip" android:textStyle="bold" > </ListView> </code></pre> <p>and here is the error log: 09-13 22:42:00.127: W/dalvikvm(1168): threadid=1: thread exiting with uncaught exception (group=0x4001d800) 09-13 22:42:00.137: E/AndroidRuntime(1168): FATAL EXCEPTION: main 09-13 22:42:00.137: E/AndroidRuntime(1168): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tot.tipofthetongue/com.tot.tipofthetongue.DisplayResultsActivity}: java.lang.NullPointerException 09-13 22:42:00.137: E/AndroidRuntime(1168): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) 09-13 22:42:00.137: E/AndroidRuntime(1168): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 09-13 22:42:00.137: E/AndroidRuntime(1168): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 09-13 22:42:00.137: E/AndroidRuntime(1168): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 09-13 22:42:00.137: E/AndroidRuntime(1168): at android.os.Handler.dispatchMessage(Handler.java:99) 09-13 22:42:00.137: E/AndroidRuntime(1168): at android.os.Looper.loop(Looper.java:123) 09-13 22:42:00.137: E/AndroidRuntime(1168): at android.app.ActivityThread.main(ActivityThread.java:4627) 09-13 22:42:00.137: E/AndroidRuntime(1168): at java.lang.reflect.Method.invokeNative(Native Method) 09-13 22:42:00.137: E/AndroidRuntime(1168): at java.lang.reflect.Method.invoke(Method.java:521) 09-13 22:42:00.137: E/AndroidRuntime(1168): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 09-13 22:42:00.137: E/AndroidRuntime(1168): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 09-13 22:42:00.137: E/AndroidRuntime(1168): at dalvik.system.NativeStart.main(Native Method) 09-13 22:42:00.137: E/AndroidRuntime(1168): Caused by: java.lang.NullPointerException 09-13 22:42:00.137: E/AndroidRuntime(1168): at com.tot.tipofthetongue.DisplayResultsActivity.onCreate(DisplayResultsActivity.java:30) 09-13 22:42:00.137: E/AndroidRuntime(1168): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 09-13 22:42:00.137: E/AndroidRuntime(1168): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 09-13 22:42:00.137: E/AndroidRuntime(1168): ... 11 more</p> |
21,016,762 | 0 | <p>There is a workaround to this problem. Consider the following implementation:</p> <pre><code>int corePoolSize = 40; int maximumPoolSize = 40; ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(corePoolSize, maximumPoolSize, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()); threadPoolExecutor.allowCoreThreadTimeOut(true); </code></pre> <p>By setting the <a href="http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ThreadPoolExecutor.html#allowCoreThreadTimeOut%28boolean%29" rel="nofollow">allowCoreThreadTimeOut()</a> to <code>true</code>, the threads in the pool are allowed to terminate after the specified timeout (60 seconds in this example). With this solution, it is the <code>corePoolSize</code> constructor argument that determines the maximum pool size in practice, because the thread pool will grow up to the <code>corePoolSize</code>, and then start adding jobs to the queue. It is likely that the pool may never grow bigger than that, because the pool will not spawn new threads until the queue is full (which, given that the <code>LinkedBlockingQueue</code> has an <code>Integer.MAX_VALUE</code> capacity may never happen). Consequently, there is little point in setting <code>maximumPoolSize</code> to a larger value than <code>corePoolSize</code>.</p> <p>Consideration: The thread pool have 0 idle threads after the timeout has expired, which means that there will be some latency before the threads are created (normally, you would always have <code>corePoolSize</code> threads available).</p> <p>More details can be found in the JavaDoc of <a href="http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ThreadPoolExecutor.html" rel="nofollow">ThreadPoolExecutor</a>.</p> |
28,600,233 | 0 | How to insert a panel in webpage using chrome extension? <p>I m making an extension for gmail and trying to add a side panel when the user opens his mail( The place where contact information of the sender is shown). I searched and only found out that i can modify the css only. By modifying the css i m able to make space for the panel. Its just empty space there. How can i insert a html page in that empty space??</p> |
32,504,135 | 0 | <p>So this is how sourcemaps work in Gulp: Each element you select via <code>gulp.src</code> gets transferred into a virtual file object, consisting of the contents in a Buffer, as well as the original file name. Those are piped through your stream, where the contents get transformed.</p> <p>If you add sourcemaps, you add one more property to those virtual file objects, namely the sourcemap. With each transformation, the sourcemap gets also transformed. So, if you initialize the sourcemaps after concat and before uglify, the sourcemaps stores the transformations from that particular step. The sourcemap "thinks" that the original files are the output from concat, and the only transformation step that took place is the uglify step. So when you open them in your browser, nothing will match.</p> <p>It's better that you place sourcemaps directly after globbing, and save them directly before saving your results. <strong>Gulp sourcemaps will interpolate between transformations, so that you keep track of every change that happened</strong>. The original source files will be the ones you selected, and the sourcemap will track back to those origins.</p> <p>This is your stream:</p> <pre><code> return gulp.src(sourceFiles) .pipe(sourcemaps.init()) .pipe(plumber()) .pipe(concat(filenameRoot + '.js')) .pipe(gulp.dest(destinationFolder)) // save .js .pipe(uglify({ preserveComments: 'license' })) .pipe(rename({ extname: '.min.js' })) .pipe(sourcemaps.write('maps')) .pipe(gulp.dest(destinationFolder)) // save .min.js </code></pre> <p><code>sourcemaps.write</code> does not actually write sourcemaps, it just tells Gulp to materialize them into a physical file when you call <code>gulp.dest</code>. </p> <p>The very same sourcemap plugin will be included in Gulp 4 natively: <a href="http://fettblog.eu/gulp-4-sourcemaps/">http://fettblog.eu/gulp-4-sourcemaps/</a> -- If you want to have more details on how sourcemaps work internally with Gulp, they are in Chapter 6 of my Gulp book: <a href="http://www.manning.com/baumgartner">http://www.manning.com/baumgartner</a></p> |
887,993 | 0 | <p>According to <a href="http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp" rel="nofollow noreferrer">this page</a>, the default stack size depends on the OS.</p> <p><strong>Sparc:</strong> 512</p> <p><strong>Solaris x86:</strong> 320 (was 256 prior in 5.0 and earlier) <em>(update: According to <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4689767" rel="nofollow noreferrer">this page</a>, the size of the main thread stack comes from the ulimit. The main thread stack is artificially reduced by the vm to the -Xss value)</em></p> <p><strong>Sparc 64 bit:</strong> 1024</p> <p><strong>Linux amd64:</strong> 1024 (was 0 in 5.0 and earlier) <em>(update: The default size comes from ulimit, but I can be reduced with -Xss)</em></p> <p><strong>Windows:</strong> 256 (also <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4689767" rel="nofollow noreferrer">here</a>) </p> <p>You can change the default setting with the <strong>-Xss</strong> flag. For example:</p> <pre><code>java ... -Xss1024k ... <classname> </code></pre> <p>would set the default stack size to 1Mb.</p> |
4,218,266 | 0 | <p>If the readonly and readwrite entities do not share relationships, the easiest solution is to put each group in their own configuration and then have separate stores. That way, updating is just a matter of swapping out the readonly persistent store file. </p> <p>If they do have relationships, then your only option is delete all the existing readonly and repopulate by building new objects on the fly. </p> <p>If you are designing from scratch the first option is usually best for pre-populated material. You can use objectIDs and/or fetched relationships to form pseudo-relationships across stores. </p> |
28,968,367 | 0 | Wireless wlan0 management <p>I implemented a function in order to connect my device to an access point which contains :</p> <pre><code>iw mlan0 connect $SSID udhcpc -i mlan0 while : ; do echo "Pausing until connection established" mlan0_ip=`/sbin/ifconfig mlan0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'` if [ -z "$mlan0_ip" ] then sleep 1 else break fi done </code></pre> <p>I don't understand why the iw mlan0 connect $SSID command keep the prompt. Indeed, it is blocked on </p> <pre><code>[ 6231.764960] wlan: SCAN COMPLETED: scanned AP count=9 [ 6231.798636] wlan: Connected to bssid 1a:XX:XX:XX:52:66 successfully [ 6231.808511] IPv6: ADDRCONF(NETDEV_CHANGE): mlan0: link becomes ready udhcpc (v1.22.1) started Sending discover... Sending discover... Sending discover... [ 6241.126472] ADDBA RSP: Failed(1a:XX:XX:XX:52:66 tid=6) Sending discover... [ 6264.263093] ADDBA RSP: Failed(1a:XX:XX:XX:52:66 tid=6) Sending select for 192.168.50.33... [ 6264.497054] ADDBA RSP: Failed(1a:XX:XX:XX:52:66 tid=6) Lease of 192.168.50.33 obtained, lease time 43200 </code></pre> <p>Basically I never enter into the while loop.. I would like to execute some others command after network configuration </p> |
21,025,965 | 0 | Is there a way to stop a url redirecting using javascript or Jquery? <p>for example when you click on this flickr url: <a href="http://www.flickr.com/photos/caterpiya/5716797477/sizes/h/" rel="nofollow">http://www.flickr.com/photos/caterpiya/5716797477/sizes/h/</a></p> <p>The /sizes/h/ changes to /sizes/l/ how can I stop it from making this change and be given an alert through Jquery or javascript if it goes to a 404?</p> <pre><code><script> function yo(){ var href = "http://www.flickr.com/photos/caterpiya/5716797477/" href = href+"sizes/h/"; window.open(href); } </script> <button onclick="yo()">open</button> </code></pre> |
12,685,784 | 0 | <p>Your analysis is definitely correct about where the click event is trying to bind.</p> <p>There are two approaches I generally take:</p> <ol> <li>Use ItemClick on the List</li> <li>Continuing using Click but do some redirection on the ViewModel side.</li> </ol> <hr> <p>So...1</p> <p>The <a href="https://github.com/slodge/MvvmCross/blob/master/Sample%20-%20Tutorial/Tutorial/Tutorial.Core/ViewModels/MainMenuViewModel.cs">Main Menu</a> in the tutorial has a ViewModel a bit like:</p> <pre><code>public class MainMenuViewModel : MvxViewModel { public List<T> Items { get; set; } public IMvxCommand ShowItemCommand { get { return new MvxRelayCommand<T>((item) => /* do action with item */ ); } } } </code></pre> <p>This is used in axml as:</p> <pre><code><Mvx.MvxBindableListView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:local="http://schemas.android.com/apk/res/Tutorial.UI.Droid" android:layout_width="fill_parent" android:layout_height="fill_parent" local:MvxBind="{'ItemsSource':{'Path':'Items'},'ItemClick':{'Path':'ShowItemCommand'}}" local:MvxItemTemplate="@layout/listitem_viewmodel" /> </code></pre> <p>This approach can only be done for ItemClick on the whole list item - not on individual subviews within the list items.</p> <hr> <p>Or...2</p> <p>Since we don't have any <code>RelativeSource</code> binding instructions in mvx, this type of redirection can be done in the ViewModel/Model code.</p> <p>This can be done by presenting a behaviour-enabled wrapper of the Model object rather than the Model object itself - e.g. using a <code>List<ActiveArticle></code>:</p> <pre><code>public ActiveArticle { Article _article; ArticleViewModel _parent; public WrappedArticle(Article article, ArticleViewModel parent) { /* assignment */ } public IMvxCommand TheCommand { get { return MvxRelayCommand(() -> _parent.DoStuff(_article)); } } public Article TheArticle { get { return _article; } } } </code></pre> <p>Your axml would then have to use bindings like:</p> <pre><code> <TextView ... local:MvxBind="{'Text':{'Path':'TheArticle.Label'}}" /> </code></pre> <p>and</p> <pre><code> <ImageButton ... local:MvxBind="{'Click':{'Path':'TheCommand.MyTest'}}" /> </code></pre> <p>One example of this approach is the Conference sample which uses <a href="https://github.com/slodge/MvvmCross/blob/master/Sample%20-%20CirriousConference/Cirrious.Conference.Core/ViewModels/Helpers/WithCommand.cs">WithCommand</a></p> <p>However... please note that when using <code>WithCommand<T></code> we discovered a memory leak - basically the GarbageCollection refused to collect the embedded <code>MvxRelayCommand</code> - which is why <code>WithCommand<T></code> is <code>IDisposable</code> and why <a href="https://github.com/slodge/MvvmCross/blob/master/Sample%20-%20CirriousConference/Cirrious.Conference.Core/ViewModels/SessionLists/BaseSessionListViewModel.cs">BaseSessionListViewModel</a> clears the list and disposes the WithCommand elements when views are detached. </p> <hr> <p><strong>Update after comment:</strong></p> <p>If your data list is large - and your data is fixed (your articles are models without PropertyChanged) and you don't want to incur the overhead of creating a large <code>List<WrappedArticle></code> then one way around this might be to use a <code>WrappingList<T></code> class.</p> <p>This is very similar to the approach taken in Microsoft code - e.g. in virtualizing lists in WP7/Silverlight - <a href="http://shawnoster.com/blog/post/Improving-ListBox-Performance-in-Silverlight-for-Windows-Phone-7-Data-Virtualization.aspx">http://shawnoster.com/blog/post/Improving-ListBox-Performance-in-Silverlight-for-Windows-Phone-7-Data-Virtualization.aspx</a></p> <p>For your articles this might be:</p> <pre><code>public class ArticleViewModel: MvxViewModel { public WrappingList<Article> Articles; // normal members... } public class Article { public string Label { get; set; } public string Remark { get; set; } } public class WrappingList<T> : IList<WrappingList<T>.Wrapped> { public class Wrapped { public IMvxCommand Command1 { get; set; } public IMvxCommand Command2 { get; set; } public IMvxCommand Command3 { get; set; } public IMvxCommand Command4 { get; set; } public T TheItem { get; set; } } private readonly List<T> _realList; private readonly Action<T>[] _realAction1; private readonly Action<T>[] _realAction2; private readonly Action<T>[] _realAction3; private readonly Action<T>[] _realAction4; public WrappingList(List<T> realList, Action<T> realAction) { _realList = realList; _realAction = realAction; } private Wrapped Wrap(T item) { return new Wrapped() { Command1 = new MvxRelayCommand(() => _realAction1(item)), Command2 = new MvxRelayCommand(() => _realAction2(item)), Command3 = new MvxRelayCommand(() => _realAction3(item)), Command4 = new MvxRelayCommand(() => _realAction4(item)), TheItem = item }; } #region Implementation of Key required methods public int Count { get { return _realList.Count; } } public Wrapped this[int index] { get { return Wrap(_realList[index]); } set { throw new NotImplementedException(); } } #endregion #region NonImplementation of other methods public IEnumerator<Wrapped> GetEnumerator() { throw new NotImplementedException(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } public void Add(Wrapped item) { throw new NotImplementedException(); } public void Clear() { throw new NotImplementedException(); } public bool Contains(Wrapped item) { throw new NotImplementedException(); } public void CopyTo(Wrapped[] array, int arrayIndex) { throw new NotImplementedException(); } public bool Remove(Wrapped item) { throw new NotImplementedException(); } public bool IsReadOnly { get; private set; } #endregion #region Implementation of IList<DateFilter> public int IndexOf(Wrapped item) { throw new NotImplementedException(); } public void Insert(int index, Wrapped item) { throw new NotImplementedException(); } public void RemoveAt(int index) { throw new NotImplementedException(); } #endregion } </code></pre> |
36,506,445 | 0 | <p>You need to use some semicolons. Otherwise the statements get blended.</p> <p>Why I think this is happening is that the function that calls <code>test</code> isn't getting called at all, but it's being passed to <code>test2</code> as the first argument.</p> <p>You can see that behavior here: <a href="https://jsfiddle.net/ssgagr3k/" rel="nofollow">https://jsfiddle.net/ssgagr3k/</a></p> |
29,888,785 | 0 | How to write helper class for different select operation? <p>Guys i want different "select" operation as per my needs, but i just need one helper function for all select operation , How do i get it??</p> <p>This is my helper class Database.php</p> <pre><code><?php class Database { public $server = "localhost"; public $user = "root"; public $password = ""; public $database_name = "employee_application"; public $table_name = ""; public $database_connection = ""; public $class_name = "Database"; public $function_name = ""; //constructor public function __construct(){ //establishes connection to database $this->database_connection = new mysqli($this->server, $this->user, $this->password, $this->database_name); if($this->database_connection->connect_error) die ("Connection failed".$this->database_connection->connect_error); } //destructor public function __destruct(){ //closes database connection if(mysqli_close($this->database_connection)) { $this->database_connection = null; } else echo "couldn't close"; } public function run_query($sql_query) { $this->function_name = "run_query"; try{ if($this->database_connection){ $output = $this->database_connection->query($sql_query); if($output){ $result["status"] = 1; $result["array"] = $output; } else{ $result["status"] = 0; $result["message"] = "Syntax error in query"; } } else{ throw new Exception ("Database connection error"); } } catch (Exception $error){ $result["status"] = 0; $result["message"] = $error->getMessage(); $this->error_table($this->class_name, $this->function_name, "connection error", date('Y-m-d H:i:s')); } return $result; } public function get_table($start_from, $per_page){ $this->function_name = "get_table"; $sql_query = "select * from $this->table_name LIMIT $start_from, $per_page"; return $this->run_query($sql_query); } } ?> </code></pre> <p>In the above code get_table function performs basic select operation.... Now i want get_table function to perform all this below operations,</p> <pre><code>$sql_query = "select e.id, e.employee_name, e.salary, dept.department_name, desi.designation_name, e.department, e.designation from employees e LEFT OUTER JOIN designations desi ON e.designation = desi.id LEFT OUTER JOIN departments dept ON e.department = dept.id ORDER BY e.employee_name LIMIT $start_from, $per_page"; $sql_query = "select id, designation_name from designations ORDER BY designation_name"; $sql_query = "select * from departments"; $sql_query = "select * from departments Limit 15,10"; </code></pre> <p>So how to overcome this issue, can anyone help me out?</p> |
14,955,557 | 0 | <p>Try to use ob_start() at the start of script, and exit(); after header("Location: contact.php");</p> <p>smth like this ...</p> <pre><code><?php ob_start(); $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; &contact = $_POST['contact']; $formcontent="From: $name \n Message: $message"; $recipient = "[email protected]"; $subject = "Contact form message"; $mailheader = "From: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); header("Location: contact.php"); exit(); ?> </code></pre> |
23,884,293 | 0 | <p>If i'm not wrong. see below can help you up or not.</p> <pre><code><script type="text/javascript"> function Confirmation() { var rowQuestion = confirm("Are you sure you want to confirm?"); if (rowQuestion == false) { return false; } return true; } </script> </code></pre> <p>and the aspx will be:</p> <pre><code><asp:Button Text="Confirm Training" OnClientClick="return Confirmation();" ID="btnConfirm" OnClick="btnConfirm_Click" runat="server" /> </code></pre> <p>confirm at the javascript "confirmation" first, then, only call the btnConfirm_click code behind.</p> |
23,381,822 | 0 | Parsing a language using scala parser combinators <p>I have the following template:</p> <pre><code>#foo(args)# // START CONTAINER1 #foo(foo <- foos)(args)# // BLOCK STARTS HERE (`args` can be on either side of `block`) #bar(args)# // START CONTAINER2 #.bar# // END CONTAINER2 #.foo# // END BLOCK #.foo# // END CONTAINER1 </code></pre> <p>*notice how <code>#.foo#</code> closes each container/block</p> <p>The trouble I see here is that there's no unique <code>id</code> of some sort to represent each block so I have to keep track of how many container openers/closers there are (<code>#foo#</code>/<code>#.foo#</code>) so that a block with an inside container's <code>END CONTAINER</code> hash won't confuse the parser as ending the block.</p> <p><strong>How would I use Scala's parsers to parse blocks in a language like this?</strong></p> <hr> <p>I started off with this:</p> <pre><code>def maybeBlockMaybeJustContainer:Content = { (openingHash ~ identifier ~ opt(args) ~> opt(blockName) <~ opt(args) ~ closingHash) ~ opt(content) ~ openHash ~ dot ~ identifier ~ closingHash ^^ ... } </code></pre> <p>I'm also thinking about preprocessing it but not sure where to start.</p> |
2,107,300 | 0 | <p>you ever find an answer for this? i'm having the same issues</p> <p>EDIT: this delay is only experienced when debugging on the phone. the plugin attempts to load and there is a large delay before the youtube view pops up in the webview. if you unplug the phone from xcode (disabling the remote debugger) it immediately loads the webview</p> |
32,066,647 | 0 | <p>I tried replacing the path of the input and output by one <strong>without any space</strong> and it now works ! Here is the code I ended up using :</p> <pre><code>using Ghostscript.NET.Rasterizer; private void button6_Click(object sender, EventArgs e) { int desired_x_dpi = 96; int desired_y_dpi = 96; string inputPdfPath = @"D:\Public\temp\rasterizer\FOS.pdf"; string outputPath = @"D:\Public\temp\rasterizer\output\"; using (var rasterizer = new GhostscriptRasterizer()) { rasterizer.Open(inputPdfPath); for (var pageNumber = 1; pageNumber <= rasterizer.PageCount; pageNumber++) { var pageFilePath = Path.Combine(outputPath, string.Format("Page-{0}.png", pageNumber)); var img = rasterizer.GetPage(desired_x_dpi, desired_y_dpi, pageNumber); img.Save(pageFilePath + "ImageFormat.Png"); } } } </code></pre> |
24,248,853 | 0 | Netbeans Maven project from cloned GitHub Java (with jni and C) repository <p>I cloned the git repository <a href="https://github.com/s-u/rJava" rel="nofollow">here</a> and I would like to add it as a <code>Maven</code> or <code>NetBeans</code> <code>Java</code> project in <code>NetBeans</code>so I can use it as dependency for other application and to also be able to contribute to the repository.</p> <p>The problem is that after cloning it <code>NetBeans</code> does not allow me to add it as a project. I'm guessing this is because it does not follow the structure of neither Maven, nor Netbeans projects.</p> <p>Is there any way I can add it as a project in <code>NetBeans</code> and still have it liked to the <code>GitHub</code> repository so I can commit and push changes? The project is using <code>Java</code>, jni with <code>C</code> and <code>R</code> (I think).</p> |
16,319,702 | 0 | <p>While <a href="http://stackoverflow.com/a/16317950/887149">two</a> other <a href="http://stackoverflow.com/a/16317947/887149">answers</a> are ok, here is another way to do it.</p> <p>You can use </p> <pre><code>Item_properties.keys.push($(this).val()); </code></pre> <p>Instead of </p> <pre><code>this.keys.push($(this).val()); </code></pre> |
20,739,122 | 0 | <p><code>async: false</code> is bad idea because ajax isn't meant to be blocking. Without <code>async: false</code> you cannot stop the function from returning. A better solution would be using <code>Deferred</code> object. You code can be improved like this.</p> <pre><code>function processData(data) { return data; } function test() { // what is being returned here is a deferred object // see http://api.jquery.com/deferred.then/ return $.ajax().then(function (data) { return $.ajax().then(function (data) { return processData(data); }); }); } function main() { // you can't stop test from returning, but you can used the return Deferred object test().done(function (finalData) { // processData(data) in test will be available as `finalData` here }); } </code></pre> |
23,492,287 | 0 | Problems with upgrading Jekyll <p>I want to upgrade Jekyll to 1.5.1 in order to get some of the latest features, but I'm running into some trouble.</p> <p>My current version is 1.2.1 and <code>which jekyll</code> returns <code>/usr/bin/jekyll</code>. Rubygems is at <code>2.2.2</code>. I'm on OSX 10.9.2.</p> <p>When I simply run <code>gem update jekyll</code> it tells me that there is nothing to update. When I run <code>gem uninstall jekyll</code> it returns nothing, even with <code>-V</code> on. <code>which jekyll</code> keeps pointing at <code>usr/bin/jekyll</code> and <code>gem install -v 1.5.1</code> then gives me compile errors, I guess because there is still an old copy of Jekyll installed.</p> <p>The following is the output of <code>gem list</code>:</p> <pre><code>*** LOCAL GEMS *** actionmailer (4.0.0, 3.2.12) actionpack (4.0.0, 3.2.12) activeadmin (0.6.0) activemodel (4.0.0, 3.2.12) activerecord (4.0.0, 3.2.12) activerecord-deprecated_finders (1.0.3) activeresource (3.2.12) activesupport (4.0.0, 3.2.12) arbre (1.0.1) archive-tar-minitar (0.5.2) arel (4.0.1, 3.0.2) atomic (1.1.14) bcrypt-ruby (3.0.1) bourbon (3.1.8) builder (3.1.4, 3.0.4) bundler (1.3.5) CFPropertyList (2.2.0) coffee-rails (4.0.1, 3.2.2) coffee-script (2.2.0) coffee-script-source (1.6.3, 1.6.2) commander (4.1.5) country-select (1.1.1) devise (2.2.4) erubis (2.7.0) execjs (2.0.2, 1.4.0) faraday (0.8.7) fastercsv (1.5.5) fb-channel-file (0.0.2) formtastic (2.2.1) has_scope (0.5.1) hashie (2.0.5) highline (1.6.20) hike (1.2.3) httpauth (0.2.0) httpclient (2.3.4.1) i18n (0.6.5, 0.6.4) inherited_resources (1.4.0) jbuilder (1.5.2) journey (1.0.4) jquery-rails (3.0.4, 3.0.1, 2.3.0) json (1.8.1, 1.8.0) jwt (0.1.8) kaminari (0.14.1) kgio (2.8.1, 2.8.0) libxml-ruby (2.6.0) liquid (2.5.5) mail (2.5.4, 2.4.4) meta_search (1.1.3) mime-types (1.25, 1.24, 1.23) minitest (4.7.5) multi_json (1.8.2, 1.7.9, 1.7.7, 1.7.6) multipart-post (1.2.0) net-ssh (2.7.0) net-ssh-gateway (1.2.0) net-ssh-multi (1.2.0) newrelic_rpm (3.6.8.168) nokogiri (1.5.10, 1.5.6) oauth2 (0.8.1) omniauth (1.1.4) omniauth-facebook (1.4.1) omniauth-oauth2 (1.1.1) open4 (1.3.0) orm_adapter (0.4.0) pg (0.17.0, 0.14.1) polyamorous (0.5.0) polyglot (0.3.3) rack (1.5.2, 1.4.5) rack-cache (1.2) rack-ssl (1.3.3) rack-test (0.6.2) rails (4.0.0, 3.2.12) rails_12factor (0.0.2) rails_serve_static_assets (0.0.1) rails_stdout_logging (0.0.3) railties (4.0.0, 3.2.12) raindrops (0.12.0, 0.11.0) rake (10.1.0, 10.0.4) rdoc (3.12.2) responders (0.9.3) rhc (1.15.6) rubygems-update (2.2.2) sass (3.2.12, 3.2.10, 3.2.9) sass-rails (4.0.1, 3.2.6) sdoc (0.3.20) sitemap_generator (4.3.1) sprockets (2.10.0, 2.2.2) sprockets-rails (2.0.1) sqlite3 (1.3.8, 1.3.7) thor (0.18.1) thread_safe (0.1.3) tilt (1.4.1) treetop (1.4.15, 1.4.14) turbolinks (1.3.0) tzinfo (0.3.38, 0.3.37) uglifier (2.3.0, 2.1.2, 2.1.1) unicorn (4.6.3, 4.6.2) warden (1.2.1) </code></pre> <p>This is the error I get when trying to run <code>sudo gem install jekyll</code> after deleting <code>/usr/bin/jekyll</code>:</p> <pre><code>Building native extensions. This could take a while... /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb creating Makefile make "DESTDIR=" clean make "DESTDIR=" compiling porter.c porter.c:359:27: warning: '&&' within '||' [-Wlogical-op-parentheses] if (a > 1 || a == 1 && !cvc(z, z->k - 1)) z->k--; ~~ ~~~~~~~^~~~~~~~~~~~~~~~~~~~ porter.c:359:27: note: place parentheses around the '&&' expression to silence this warning if (a > 1 || a == 1 && !cvc(z, z->k - 1)) z->k--; ^ ( ) 1 warning generated. compiling porter_wrap.c linking shared-object stemmer.bundle clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future] clang: note: this will be a hard error (cannot be downgraded to a warning) in the future make: *** [stemmer.bundle] Error 1 ERROR: Error installing jekyll: ERROR: Failed to build gem native extension. </code></pre> <p>Any ideas?</p> |
32,600,403 | 0 | <p>Pass that particular id in your remote url like <code>remote: "../admin/checkEmail.php?data=email&id=23"</code> say your particular id be 23</p> <p>and in your checkEmail.php you can write query like</p> <pre><code>"SELECT email FROM table_name WHERE email='".$_GET['email']."' AND id!='".$_GET['id']."'" </code></pre> <p>same way you can do for username also</p> |
35,549,098 | 0 | <p>Have you tried to install from composer? it's the preferred way to install yii</p> |
12,584,026 | 0 | @media queries - why does css rule overrule another? <p>im using a media query for <code>max-width: 768px;</code> and have put the css rule for an element as <code>left: 80px;</code></p> <p>then BENEATH this i have another media query targeting max width of 800px and in that i have the same element set to <code>left: 94px;</code></p> <p>However when i change the screen size to the smaller 768 and check with firebug the rule of <code>left: 80px;</code> is crossed out and the <code>left: 94px;</code> is being followed.</p> <p>Any ideas why?</p> |
32,454,908 | 1 | Remove duplicate data from an array in python <p>I have this array of data</p> <pre><code>data = [20001202.05, 20001202.05, 20001202.50, 20001215.75, 20021215.75] </code></pre> <p>I remove the duplicate data with <code>list(set(data))</code>, which gives me </p> <pre><code>data = [20001202.05, 20001202.50, 20001215.75, 20021215.75] </code></pre> <p>But I would like to remove the duplicate data, based on the numbers before the "period"; for instance, if there is <code>20001202.05</code> and <code>20001202.50</code>, I want to keep one of them in my array.</p> |
20,558,780 | 0 | Integrating NetLogo and Java : when should we think about this integration as a good option? <p>I just came to know about this excellent tutorials</p> <p><a href="http://scientificgems.wordpress.com/2013/12/11/integrating-netlogo-and-java-part-1/" rel="nofollow">http://scientificgems.wordpress.com/2013/12/11/integrating-netlogo-and-java-part-1/</a> <a href="http://scientificgems.wordpress.com/2013/12/12/integrating-netlogo-and-java-2/" rel="nofollow">http://scientificgems.wordpress.com/2013/12/12/integrating-netlogo-and-java-2/</a> <a href="http://scientificgems.wordpress.com/2013/12/13/integrating-netlogo-and-java-3/" rel="nofollow">http://scientificgems.wordpress.com/2013/12/13/integrating-netlogo-and-java-3/</a></p> <p>Their example concerns about computation needed for patch diffusion and shows how to access patch variable from java and change them in netlogo.</p> <p>I was wondering if anyone has any idea or comments on when we should think of writing an extension to make our model work better? I am new to netlogo itself, but I think it's good to know what are the options that I might not be aware of :) </p> |
36,245,819 | 0 | <p>In general it depends on the target. On small targets (i.e. microcontrollers like AVR) you don't have that complex programs running. Additionally, you need to access the hardware directly (f.e. a UART). High level languages like Java don't support accessing the hardware directly, so you usually end up with C. </p> <p>In the case of C versus Java there's a major difference:</p> <p>With C you compile the code and get a binary that runs on the target. It <em>directly</em> runs on the target.</p> <p>Java instead creates Java Bytecode. The target CPU cannot process that. Instead it requires running another program: the Java runtime environment. That translates the Java Bytecode to actual machine code. Obviously this is more work and thus requires more processing power. While this isn't much of a concern for standard PCs it is for small embedded devices. (Note: some CPUs do actually have support for running Java bytecode directly. Those are exceptions though.)</p> <p>Generally speaking, the compile step isn't the issue -- the limited resources and special requirements of the target device are.</p> |
27,050,536 | 0 | <p>Try changing one of your href to <code>about.php</code> and see if it works. Example:</p> <pre><code> <ul class="dropdown-menu" data-role="dropdown"> <li><a href="about.php">About</a></li> //etc </code></pre> <p>As it stands your hyperlinks go to your <code>index.php</code>, which gives that same value to the <code>PHP_SELF</code> super, thus never agreeing with <code>about.php</code>. At least that what I can see by this limited code sample. If that doesn't work, please edit your question to include the output of <code>$_SERVER['PHP_SELF']</code>, which should give you the clue anyway.</p> <p>Moreover there's no reason to use <code>strpos</code> when comparing strings; use the <a href="http://stackoverflow.com/a/80649/2194007"><code>===</code></a> operator instead, which checks if arguments are of the same <em>type</em> as well as if they have the same value.</p> |
36,760,435 | 0 | <p>I have started messenger development 2 days ago.I was able to access localhost from any where over internet by using ngrok <a href="http://ngrok.com" rel="nofollow">http://ngrok.com</a> give it a try .</p> |
8,233,275 | 0 | How to properly InsertAllOnSubmit() and is that better than looping InsertOnSubmit()? <p>Say I have:</p> <pre><code>using (SomeDataContext db = new SomeDataContext()) { foreach(Item i in Items) { DbItem d = new DbItem; d.value = i.value; //.... etc ... db.InsertOnSubmit(d); } db.SubmitChanges(); } </code></pre> <p>Is it possible and/or better (worse?) to do:</p> <pre><code>using (SomeDataContext db = new SomeDataContext()) { IEnumerable<DbItem> dbItems = //???? possible? foreach(Item i in Items) { DbItem d = new DbItem; d.value = i.value; //.... etc ... dbItems.Add(d); // ???? again, somehow possible? } db.InsertAllOnSubmit(dbItems); db.SubmitChanges(); } </code></pre> |
31,085,940 | 0 | <p>Assuming that you are looking to set all elements for each row until the last negative element to be set to zero (as per the expected output listed in the question for a sample case), two approaches could be suggested here.</p> <p><strong>Approach #1</strong></p> <p>This one is based on <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.cumsum.html"><code>np.cumsum</code></a> to generate a mask of elements to be set to zeros as listed next -</p> <pre><code># Get boolean mask with TRUEs for each row starting at the first element and # ending at the last negative element mask = (np.cumsum(A2[:,::-1]<0,1)>0)[:,::-1] # Use mask to set all such al TRUEs to zeros as per the expected output in OP A2[mask] = 0 </code></pre> <p>Sample run -</p> <pre><code>In [280]: A2 = np.random.randint(-4,10,(6,7)) # Random input 2D array In [281]: A2 Out[281]: array([[-2, 9, 8, -3, 2, 0, 5], [-1, 9, 5, 1, -3, -3, -2], [ 3, -3, 3, 5, 5, 2, 9], [ 4, 6, -1, 6, 1, 2, 2], [ 4, 4, 6, -3, 7, -3, -3], [ 0, 2, -2, -3, 9, 4, 3]]) In [282]: A2[(np.cumsum(A2[:,::-1]<0,1)>0)[:,::-1]] = 0 # Use mask to set zeros In [283]: A2 Out[283]: array([[0, 0, 0, 0, 2, 0, 5], [0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 5, 5, 2, 9], [0, 0, 0, 6, 1, 2, 2], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 9, 4, 3]]) </code></pre> <p><strong>Approach #2</strong></p> <p>This one starts with the idea of finding the last negative element indices from <a href="http://stackoverflow.com/a/31084951/3293881"><code>@tom10's answer</code></a> and develops into a mask finding method using <a href="http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html"><code>broadcasting</code></a> to get us the desired output, similar to <code>approach #1</code>.</p> <pre><code># Find last negative index for each row last_idx = A2.shape[1] - 1 - np.argmax(A2[:,::-1]<0, axis=1) # Find the invalid indices (rows with no negative indices) invalid_idx = A2[np.arange(A2.shape[0]),last_idx]>=0 # Set the indices for invalid ones to "-1" last_idx[invalid_idx] = -1 # Boolean mask with each row starting with TRUE as the first element # and ending at the last negative element mask = np.arange(A2.shape[1]) < (last_idx[:,None] + 1) # Set masked elements to zeros, for the desired output A2[mask] = 0 </code></pre> <hr> <p>Runtime tests -</p> <p>Function defintions:</p> <pre><code>def broadcasting_based(A2): last_idx = A2.shape[1] - 1 - np.argmax(A2[:,::-1]<0, axis=1) last_idx[A2[np.arange(A2.shape[0]),last_idx]>=0] = -1 A2[np.arange(A2.shape[1]) < (last_idx[:,None] + 1)] = 0 return A2 def cumsum_based(A2): A2[(np.cumsum(A2[:,::-1]<0,1)>0)[:,::-1]] = 0 return A2 </code></pre> <p>Runtimes:</p> <pre><code>In [379]: A2 = np.random.randint(-4,10,(100000,100)) ...: A2c = A2.copy() ...: In [380]: %timeit broadcasting_based(A2) 10 loops, best of 3: 106 ms per loop In [381]: %timeit cumsum_based(A2c) 1 loops, best of 3: 167 ms per loop </code></pre> <p>Verify results -</p> <pre><code>In [384]: A2 = np.random.randint(-4,10,(100000,100)) ...: A2c = A2.copy() ...: In [385]: np.array_equal(broadcasting_based(A2),cumsum_based(A2c)) Out[385]: True </code></pre> |
29,800,942 | 0 | <p>query is empty because you are checking </p> <pre><code>`if (isset($_POST['EntryId1']))` instead of `if (isset($_POST['search']) && $_POST['search']=='EntryId1')` and switch case would be b`enter code here`etter in this scenario. </code></pre> |
577,809 | 0 | <p>Is the layout of structs defined by the C++ standard? I would suppose that it is compiler dependent.</p> |
22,339,059 | 0 | <p>When you update the div, for instance:</p> <pre><code>$("selector for the div").html("the updated markup"); </code></pre> <p>...the next line of code doesn't run until the div has been updated. At that point, the DOM updates have been completed. Normally that's good enough. If you want to be sure that those updates have been <em>rendered</em> (shown to the user), you can yield back to the browser using <code>setTimeout</code>, like this:</p> <pre><code>// ...do the updates... setTimeout(function() { // They've almost certainly been rendered. }, 0); </code></pre> <p>The delay won't be 0ms, but it'll be very brief. That gives the browser a moment to repaint (if it needs it, which varies by browser).</p> |
19,797,770 | 0 | facebook android sdk -user email returns null <p>I am having the following code that signin the user to facebook through my app. I am getting user.getproperty("email") as null first time. when i run the app second time i am getting the value. below is my code.</p> <p>private void loginToFb() {</p> <pre><code> final Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest( LandingPageActivity.this, Arrays.asList( "user_location", "user_birthday", "user_likes", "email")); Session.openActiveSession(this, true, new Session.StatusCallback() { // callback when session changes state @Override public void call(Session session, SessionState state, Exception exception) { if (session.isOpened()) { session.requestNewReadPermissions(newPermissionsRequest); // make request to the /me API Request request = Request.newMeRequest(session, new Request.GraphUserCallback() { // callback after Graph API response with user // object @Override public void onCompleted(GraphUser user, Response response) { if (user != null) { fetchUserFbDetails(user); } } }); Request.executeBatchAsync(request); } } }); } </code></pre> |
28,494,181 | 0 | <p>This is probably related to a known issue in ui-router since angular 1.3.4 or so. See here for workarounds: <a href="https://github.com/angular-ui/ui-router/issues/600" rel="nofollow">https://github.com/angular-ui/ui-router/issues/600</a></p> <p>I also had this issue, and could fix it by using the other version of .otherwise which takes a function:</p> <p>replace: </p> <pre><code>$urlRouterProvider.otherwise("/home"); </code></pre> <p>with: </p> <pre><code>$urlRouterProvider.otherwise( function($injector, $location) { var $state = $injector.get("$state"); $state.go("home"); }); </code></pre> |
30,939,010 | 0 | JQuery Click Event Not Firing on button <p>I've got a JQuery click event that doesn't seems to be firing at all. If I am missing something I'm almost certain it's something trivial. I've tried debugging the code via Chrome but the button click on the Filter button is not even hitting the breakpoint.</p> <pre><code>$('#filter').click(function () { var dataurl; var visit = $('#visitFilter').val; var dns = $('#dnsFilter').val; var visitdate = $('#visitDateFilter').val; var entrypage = $('#entryPageFilter').val; var timeOnSite = $('#timeOnSiteFilter').val; var timeonsiteselector = $('#timeOnSiteSelector').val; var pages = $('#pagesFilter').val; var cost = $('#costFilter').val; var city = $('#cityFilter').val; var country = $('#countryFilter').val; var keywords = $('#keywordsFilter').val; var referrer = $('#referrerFilter').val; dataurl = "http://localhost:56971/VisitListFilter/28/" + visit + "/" + dns + "/" + visitdate + "/" + entrypage + "/" + timeOnSite + "/" + timeonsiteselector + "/" + pages + "/" + cost + "/" + city + "/" + country + "/" + keywords + "/" + referrer + "/" + "?format=json"; $('#VisitListTable').bootstrapTable('refresh', {url: dataurl}); }); </code></pre> <p>I've also created a fiddle here with the full code: <a href="https://jsfiddle.net/W3R3W0LF666/epu54yc4/1/" rel="nofollow">https://jsfiddle.net/W3R3W0LF666/epu54yc4/1/</a> </p> |
39,940,672 | 0 | Redoing a extra merge and a accidental contribution from the wrong user <p>I have the following git history that I would like to sort out a bit:</p> <p><a href="https://i.stack.imgur.com/9CoeS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9CoeS.png" alt="Git History"></a></p> <p>The issue occurred by using a remote editor fixed to a different git account but that had permissions for mine. Thus there are two contributors but they are both me. I then tried to fix that issue and got the red and black overlap looking commit instead. Then somehow I managed to pull and do a merge duplicating the results with a merge (the actual merge). The merge says that no changes occurred. Is there anyway I can clean this up and reassign credit just to black user not red user? I'm sure I'm skipping over details but I am not sure what else is relevant. Thanks! </p> |
38,734,065 | 0 | <pre><code>brew install automake </code></pre> <p>Than you can use aclocal</p> |
294,842 | 0 | <p><a href="http://sourceforge.net/projects/clojure-contrib" rel="nofollow noreferrer">clojure-contrib</a> has an sql library which is a thin wrapper around JDBC (java.sql.DriverManager). The test file that comes with it has some examples of its usage.</p> |
18,681,545 | 0 | How to save photos to phones library/album? <p>In my app i am having one image view which is containing the profile picture of a user and on this image view i am having one another image view which contains the picture of product. So the is basically try product yourself kind a app.I am able to do all this stuff but finally when the user is done with trying that product and if he want to save that final picture containing applied product, he will click the save button.I don't know how to save this final picture which will contain images from two image views. Please guide me through this..Thanks in advance.</p> |
5,213,154 | 0 | Intent.getAction() is throwing Null + Android <p>I have written BroadcastReceiver for sort of Alarm application. In onReceive method I am reading Intent.getAction(). <strong>It is running well in all of the versions *<em>except in SDK version 1.5 where it throws null pointer exception</em>*</strong>. I am setting the action in another activity where I am calling broadcastReceiver. Please help me out with this. Below is the code snippet for both receiver and activity classes,</p> <p><strong>ProfileActivity.java</strong></p> <hr> <pre><code>public static final String STARTALARMACTION = "android.intent.driodaceapps.action.STARTPROFILE"; public static final String STOPALARMACTION = "android.intent.driodaceapps.action.STOPPROFILE"; AlarmManager alarmMan = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Intent startIntent = new Intent(this,AlarmReceiver.class); startIntent.setAction(STARTALARMACTION); Intent stopIntent = new Intent(this,AlarmReceiver.class); stopIntent.setAction(STOPALARMACTION+intentposition); </code></pre> <h2><strong>AlarmReceiver.java</strong></h2> <pre><code>@Override public void onReceive(Context context,Intent intent){ String intentAction = intent.getAction(); Log.d(TAG,"Intent:"+intentAction); **//throwing null** </code></pre> <p>After getting the error I tried my luck by giving the actions in of .manifest file. But no use. </p> <p>Please help me.</p> <p>Thanks.</p> |
14,234,307 | 0 | <p>Superficially, it looks as though you need:</p> <pre><code>sed -n '/^IA\/\([NM][0-9][0-9]*\) \([01]\)$/ s//\1;\2/p' test.txt </code></pre> <p>The <code>-n</code> means do not print lines by default. The search pattern looks for lines that match (very exactly) <code>IA/</code> followed by N or M and one or more digits, a space, and a digit 0 or 1 and end of line. The letter and digit string is captured with <code>\(...\)</code>, as is the final digit; the replacement follows the example separating the fields with a semicolon rather than a comma as stated in the question; clearly, to output a comma as stated but not shown is trivial. The line is printed (the trailing <code>p</code>) only when it matches.</p> <p>As well as the comma versus semicolon issue, this answer assumes that the required output is accurate and the NTST line should not appear. However, the wording in the question implies that maybe the NTST line should appear as well. If so, you can simplify the regex by allowing any number of non-blank characters after the N or M:</p> <pre><code>sed -n '/^IA\/\([NM][^]*\) \([01]\)$/ s//\1;\2/p' test.txt </code></pre> <p>It is not clear from that question what should happen to lines such as:</p> <pre><code>IA/N 0 IA/N Z 0 </code></pre> |
24,411,541 | 0 | JSF Navigation using h:SelectOneMenu <p>Morning everyone, I have a question in regards to JSF navigation and using for navigation. My navigation was working fine until I put a three .xhtml files into subfolders. I have Home.xhtml, A.xhtml, B.xhtml, and C.xhtml all in the same folder. Upon putting A,B,and C.xhtml into subfolders A,B, and C, and then navigating from Home.xhtml, to A.xhtml, then to B.xhtml, I get this error: "/A/B/B.xhtml Not Found in ExternalContext as a Resource". Obviously the pages are stacking in the URL, but I'm not sure why.</p> <p>My Bean:</p> <pre><code>@ManagedBean(name="company") @SessionScoped public class CompanyBean implements Serializable { private static Map<String, Object> companyValue; public String value; boolean temp; public static Map<String, Object> getCompanyValues() { return companyValue; } public boolean getTemp() { if (Env.isProd()==true) { return true; } return false; } public void setTemp() { temp=Env.isProd(); } public static void setCompanyValues(Map<String, Object> companyValues) { CompanyBean.companyValue = companyValues; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } public CompanyBean() { companyValue=new LinkedHashMap<String, Object>(); companyValue.put("Select Company", "choose"); companyValue.put("AE", "AE/AE.xhtml"); companyValue.put("BP", "BP/BP.xhtml"); companyValue.put("CBK", "CBK/CBK.xhtml"); } public Map<String,Object> getCompanyValue() { return companyValue; } public void navigate(ValueChangeEvent event) { String page= event.getNewValue().toString(); try { FacesContext.getCurrentInstance().getExternalContext().redirect(page); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } </code></pre> <p>}</p> <p>My jsf code:</p> <pre><code><h:form> <h:selectOneMenu value="#{company.value}" valueChangeListener="#{company.navigate}" onchange="this.form.submit()"> <f:selectItems value="#{company.companyValue}" /> </h:selectOneMenu> </h:form> </code></pre> <p>Sorry if this has been answered as it is morning and I am half awake.</p> |
22,506,713 | 0 | <p>A jQuery selector will never return null, so you have recursion until the stack overflows. Try this instead:</p> <pre><code>if (selector.next().length) { </code></pre> |
22,108,374 | 0 | <p>Usually this means you have a character that is illegal. For instance using øæå will cause json_decode to return null.</p> <pre><code>Returns the value encoded in json in appropriate PHP type. Values true, false and null (case-insensitive) are returned as TRUE, FALSE and NULL respectively. NULL is returned if the json cannot be decoded or if the encoded data is deeper than the recursion limit. </code></pre> <p><a href="http://dk1.php.net/json_decode" rel="nofollow">http://dk1.php.net/json_decode</a></p> |
13,562,983 | 0 | <p>Try to disable the redis daemonize.</p> <p>In your redis.conf:</p> <pre><code># By default Redis does not run as a daemon. Use 'yes' if you need it. # Note that Redis will write a pid file in /var/run/redis.pid when daemonized. daemonize yes </code></pre> <p>Change <code>daemonize yes</code> to <code>daemonize no</code> may solve the problem.</p> |
7,640,436 | 0 | <p>In Pascal, <code>:=</code> is the assignment operator. Replace it with <code>=</code> on the line that reads <code>IF x mod 2:= 0 THEN BEGIN</code>.</p> <p>Also, remove the <code>BEGIN</code>. The result should read:</p> <pre><code>IF x mod 2 = 0 THEN </code></pre> |
39,925,524 | 0 | <p>I have several test cases in a test suite and before I was running the test suite in the Mac Terminal like this: </p> <pre><code>python LoginSuite.py </code></pre> <p>Running the command this way my directory was being populated with .pyc files. I tried the below stated method and it solved the issue:</p> <pre><code>python -B LoginSuite.py </code></pre> <p>This method works if you are importing test cases into the test suite and running the suite on the command line. </p> |
8,036,805 | 0 | T4 Code template trigger generation on: other file save / xml change (VS 2010) <p>I have a t4 template, that loops over an xml file in the project and genrate the code.<br> Is it possible to make the T4 to run when a certain file has bee saved, or when I build the project?<br> VS 2010 </p> <p>Thanks</p> |
23,523,793 | 0 | <p>Unzip your sdk zip somewhere, copy entire contents of tools directory, replace it with your actual sdk tools folder contents.</p> <p>Restart eclipse if required.</p> |
8,070,712 | 0 | <p>Magento-Debug to navigate Magento's modules and layouts: <a href="https://github.com/madalinoprea/magneto-debug" rel="nofollow">https://github.com/madalinoprea/magneto-debug</a></p> |
22,971,679 | 0 | <ol> <li>Decide if you want to use <a href="http://subclipse.tigris.org/" rel="nofollow">Subclipse</a> or <a href="http://www.eclipse.org/subversive/" rel="nofollow">Subversive</a> and download a zipped updated site for the version you want to use.</li> <li>Decide if you want to use the <a href="http://help.eclipse.org/indigo/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/p2_director.html" rel="nofollow">command line</a> or the gui. To install via gui go to Help-install New software and drag the zipped updated site onto the window and drop it there. The remaining steps are equal to an installation from an internet update site.</li> </ol> |
31,437,454 | 0 | <p>You specify the edition after the name of the DB:</p> <pre><code>SqlCommand cmd2 = new SqlCommand(string.Format("CREATE DATABASE [{0:S}] (SERVICE_OBJECTIVE = 'basic');", databaseName), conn); </code></pre> <p>The documentation for the syntax can be found <a href="https://msdn.microsoft.com/en-us/library/dn268335.aspx" rel="nofollow">here</a></p> |
14,277,212 | 0 | <p>try something like this.Working <a href="http://jsfiddle.net/bKZ2a/" rel="nofollow">fiddle</a></p> <pre><code> $(function(){ $('.menuHolder li a').click(function (e) { $('.menuHolder li a').removeClass('active'); $(this).addClass('active'); }); }); </code></pre> |
14,737,669 | 0 | Conditional HyperLink in GridView? <p>I have a gridview with a hyperlink:</p> <pre><code><asp:GridView ID="gvEmployees" runat="server" AutoGenerateColumns="False" CssClass="table table-hover table-striped" GridLines="None" > <Columns> <asp:TemplateField HeaderText="Name" SortExpression="EmployeName"> <ItemTemplate> <asp:HyperLink ID="HyperLink1" runat="server" Text='<%# Bind("EmployeName") %>' ></asp:HyperLink> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="ID" SortExpression="EmployeID" Visible="False"> <ItemTemplate> <asp:Label ID="lblID" runat="server" Text='<%# Bind("EmployeID") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </code></pre> <p>However, it should only appear as a hyperlink if the employeeID is that of the logged in employee.</p> <p>I can do all that, but what I do not know is how to make the hyperlink look like a Label. It's easy to have it not link anywhere, but I do not know how to make it look like a label.</p> <p>Thanks</p> |
32,295,700 | 0 | <p>SQLite uses a more general dynamic type system. Please look at the storage classes that must have each value stored in a SQLite database: <a href="https://www.sqlite.org/lang.html" rel="nofollow">https://www.sqlite.org/lang.html</a> 1. onCreate</p> <blockquote> <p>"CREATE TABLE" + SENSORS_TABLE_NAME + "(" + SENSORS_COLUMN_ID + "INTEGER PRIMARY KEY AUTO INCREMENT," +</p> </blockquote> <p>look at: creat table --> column-def --> column-constraint AUTOINCREMENT is only one key-word</p> <blockquote> <p>SENSORS_COLUMN_NAME + "STRING" + SENSORS_COLUMN_1 + "STRING," +</p> </blockquote> <p><a href="https://www.sqlite.org/datatype3.html" rel="nofollow">https://www.sqlite.org/datatype3.html</a> There is no datatype STRING and also not, if you look at the affinity name examples. Take TEXT, or, if you wan't to give the length, VARCHAR(length)</p> <blockquote> <p>SENSORS_COLUMN_2 + "FLOAT," + SENSORS_COLUMN_3 + "FLOAT," + SENSORS_COLUMN_4 + "FLOAT," +</p> </blockquote> <p>"FLOAT" is all right and it converted into "REAL"</p> <blockquote> <p>SENSORS_COLUMN_STATUS + "BOOLEAN)"</p> </blockquote> <p>SQLite does not have a separate Boolean storage class. Instead, Boolean values are stored as integers 0 (false) and 1 (true).(1.1 Boolean Datatype) I think, your statement may be:</p> <pre><code>db.execSQL("CREATE TABLE" + SENSORS_TABLE_NAME + "(" + SENSORS_COLUMN_ID + "INTEGER PRIMARY KEY AUTOINCREMENT," + SENSORS_COLUMN_NAME + "TEXT" + SENSORS_COLUMN_1 + "TEXT," + SENSORS_COLUMN_2 + "FLOAT," + SENSORS_COLUMN_3 + "FLOAT," + SENSORS_COLUMN_4 + "FLOAT," + SENSORS_COLUMN_STATUS + "INTEGER )" ); </code></pre> <ol start="2"> <li><p>"setVersion" and "setLocale" in onCreate I do not know if that's necessary. In the constructor you have giver the version 1: super(context, DATABASE_NAME, null, 1); Please look at reference/android/database/sqlite/SQLiteOpenHelper Better is to take a string for the version, becourse an upgrate was taken when you have a new version. </p> <p>public static final int DB_VERSION = 1;</p></li> </ol> <p>And than:</p> <pre><code>super(context, DATABASE_NAME, null, DB_VERSION); </code></pre> |
32,745,603 | 0 | <p>If your app uses multiple controllers then you could define a parent controller that gets extended by all your other controllers. Within the parent controller's constructor you can retrieve the settings data and store it in a class property which will be available to all of the child controller classes. Your child controllers can simply pass this data to the view.</p> |
30,935,504 | 0 | <p>Check this line in your onCreate() method:</p> <pre><code>loadAllProducts.execute(String.valueOf(lista)); </code></pre> <p>you can not get the string value of a ListView! If you want to get the value of a textView IN the listView, you could add an OnItemClick event to your listView and get the value of the textView in the selected list item like this:</p> <pre><code>//a variable, you could use from all the methods, that will have as a value the value of the selected TextView private String selectedValue; @Override protected void onListItemClick(ListView l, View v, int position, long id) { View view = (View)v.getParent(); TextView textYouNeed = (TextView) view.findViewById(R.id.textViewId); selectedValue = textYouNeed.getText(); } </code></pre> <p>and then use this variable in the line I told about above:</p> <pre><code>loadAllProducts.execute(selectedValue); </code></pre> |
5,597,225 | 0 | <p>There are no C++ libraries for what you're trying to do (unless you're going to link with a half of Mozilla or WebKit), but you can consider using Java with <a href="http://htmlunit.sourceforge.net/" rel="nofollow">HTMLUnit</a>.</p> <p>And for those suggesting regular expressions, an obligatory <a href="http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454">reference</a>. </p> |
3,512,465 | 0 | How to use Filter in Google Search? <p>I have converted a textbox search to Google Search using :</p> <pre><code>location.href = "http://images.google.com/search?q=" + val; </code></pre> <p>But, I want options of Web Search, Image Search, Local Search & News Search.</p> <p>I do have :</p> <pre><code><tr height="40"> <td width="80%" align="center" ><input id="searchText" type="text" size="100"/></td> <td class="searchbox" width="20%" align="center"><a href="#" onclick="startSearch()">Search</a></td> <td width="0%"></td> </tr> <td align="center"> <input type="radio" name="searchType" value="true"/> Web <input type="radio" name="searchType" value="false"/> Image <input type="radio" name="searchType" value="false"/> News <input type="radio" name="searchType" value="false"/> Local </td> </code></pre> <p>How do I filter this optiong using the same above link.</p> |
18,738,103 | 0 | <p>You need to pass a javascript element. Not a jquery element. Try </p> <pre><code>'map': map[0] </code></pre> |
38,243,599 | 1 | Python openpyxl comment shape property <p>I'm trying to set properties of comments (mainly the shape) in excel by openpyxl, but I cannot find examples. I'd like to set it with something like:</p> <pre><code>ws.cell(column = x, row = y).comment.NEEDED_METHOD_HERE = ... </code></pre> <p>If you have good examples or any idea what is the exact method, please share it with me, thank you in advance!</p> |
15,410,129 | 0 | <p><code>id</code> is a global field, just do this:</p> <pre><code>document.getElementById("lat").innerHTML = "31"; document.getElementById("lon").innerHTML = "71"; </code></pre> <p>instead of what you have written.</p> |
249,029 | 0 | <p><strong>C++</strong>:</p> <p>Sometimes you need to introduce an extra brace level of scope to reuse variable names when it makes sense to do so:</p> <pre><code>switch (x) { case 0: int i = 0; foo(i); break; case 1: int i = 1; bar(i); break; } </code></pre> <p>The code above doesn't compile. You need to make it:</p> <pre><code>switch (x) { case 0: { int i = 0; foo(i); } break; case 1: { int i = 1; bar(i); } break; } </code></pre> |
604,438 | 0 | <p>Don't use the basic_ifstream as it requires specializtion.</p> <p>Using a static buffer:</p> <pre><code>linux ~ $ cat test_read.cpp #include <fstream> #include <iostream> #include <vector> #include <string> using namespace std; int main( void ) { string filename("file"); size_t bytesAvailable = 128; ifstream inf( filename.c_str() ); if( inf ) { unsigned char mDataBuffer[ bytesAvailable ]; inf.read( (char*)( &mDataBuffer[0] ), bytesAvailable ) ; size_t counted = inf.gcount(); cout << counted << endl; } return 0; } linux ~ $ g++ test_read.cpp linux ~ $ echo "123456" > file linux ~ $ ./a.out 7 </code></pre> <p>using a vector:</p> <pre><code>linux ~ $ cat test_read.cpp #include <fstream> #include <iostream> #include <vector> #include <string> using namespace std; int main( void ) { string filename("file"); size_t bytesAvailable = 128; size_t toRead = 128; ifstream inf( filename.c_str() ); if( inf ) { vector<unsigned char> mDataBuffer; mDataBuffer.resize( bytesAvailable ) ; inf.read( (char*)( &mDataBuffer[0]), toRead ) ; size_t counted = inf.gcount(); cout << counted << " size=" << mDataBuffer.size() << endl; mDataBuffer.resize( counted ) ; cout << counted << " size=" << mDataBuffer.size() << endl; } return 0; } linux ~ $ g++ test_read.cpp -Wall -o test_read linux ~ $ ./test_read 7 size=128 7 size=7 </code></pre> <p>using reserve instead of resize in first call:</p> <pre><code>linux ~ $ cat test_read.cpp #include <fstream> #include <iostream> #include <vector> #include <string> using namespace std; int main( void ) { string filename("file"); size_t bytesAvailable = 128; size_t toRead = 128; ifstream inf( filename.c_str() ); if( inf ) { vector<unsigned char> mDataBuffer; mDataBuffer.reserve( bytesAvailable ) ; inf.read( (char*)( &mDataBuffer[0]), toRead ) ; size_t counted = inf.gcount(); cout << counted << " size=" << mDataBuffer.size() << endl; mDataBuffer.resize( counted ) ; cout << counted << " size=" << mDataBuffer.size() << endl; } return 0; } linux ~ $ g++ test_read.cpp -Wall -o test_read linux ~ $ ./test_read 7 size=0 7 size=7 </code></pre> <p>As you can see, without the call to .resize( counted ), the size of the vector will be wrong. Please keep that in mind. it is a common to use casting see <a href="http://www.cppreference.com/wiki/io/read" rel="nofollow noreferrer">cppReference</a></p> |
34,141,633 | 0 | <p>Roslyn is two things:</p> <ol> <li>An API that lets you see "compiler things" like syntax trees and symbols.</li> <li>A new csc.exe that is implemented atop #1.</li> </ol> <p>If you want to make <em>changes</em> to the compiler and use that to build, take a look at <a href="https://github.com/dotnet/roslyn/blob/master/docs/contributing/Building,%20Debugging,%20and%20Testing%20on%20Windows.md">these instructions</a> if you haven't already. There's a few different ways you can make your own version of csc.exe and then use that to build something. But there's no "choice" dialog like you're looking for.</p> |
26,153,930 | 0 | Can we assign an attribute name for a Class even that attribute is a column in a different table? <p>Ok, here is my DB</p> <pre> Member Table memberID- Name -... 1 - Tom 2 - Mary ... Event table eventID - address 1 - 122NY... 2 - 23 Cali ... PaidMember table orderNumber - eventID - memberID 1 - 1 - 2 1 - 1 - 3 .. </pre> <p>Note: each Event can have many members and each members can be in many event. However, only PaidMember is allowed to participate an event.</p> <p>SO, here is how I design classes:</p> <pre><code>public class Member{ private String name; private int memberID; //all Set and Get methods here } public class Event{ private int eventID; private String address; //all set and get methods here } </code></pre> <p>My question is that, can I put <code>private int orderNumber</code> into Member? but the <code>orderNumber</code> is depended on a particular event</p> <pre><code> public class Member{ private String name; private int memberID; private int orderNumber; //all Set and Get methods here } </code></pre> <p>or should I create PaidMember class? I am thinking to do like this but not sure if it is ok</p> <pre><code> public class PaidMember{ private Member member; private Event event; private int orderNumber; //all Set and Get methods here } </code></pre> |
35,148,710 | 0 | <p>You cannot use Image datatype in Group by clause.</p> <p><a href="https://msdn.microsoft.com/en-us/library/ms177673.aspx" rel="nofollow">MSDN</a> says:</p> <blockquote> <p>Columns of type text, ntext, <strong>and image</strong> cannot be used in group_by_expression.</p> </blockquote> <p>You can try like this by CAST<em>ing</em> it to VARBINARY like</p> <pre><code>select pc.categoryName, pc.Short_Desc, CAST(pc.categoryImage as Varbinary), COUNT(p.categoryCodeId)as Total from tbl_product as p, tbl_productCategory as pc where p.categoryCodeId=pc.categoryCodeId group by p.categoryCodeId, pc.categoryName,pc.Short_Desc, CAST(pc.categoryImage as Varbinary) order by pc.categoryName </code></pre> |
9,888,669 | 0 | <pre><code>$this->html = preg_replace('~//\s*?<!\[CDATA\[\s*|\s*//\]\]>~', '', $this->html); </code></pre> <p>should work but haven't really tested it.</p> |
13,050,131 | 0 | <p>Finally resolved the issue. The program is handling everything correctly.</p> <p>On the sending side:</p> <pre><code>compression: gzip -c secret.txt -9 > compressed.txt.gz encryption: openssl enc -aes-256-cbc -a -salt -in compressed.txt.gz -out encrypted.txt </code></pre> <p>The compression output (gz) is given as an input for encryption which outputs a text file. The resulting output is purely ascii.</p> <p>On the receiving side:</p> <pre><code>decryption: openssl enc -d -aes-256-cbc -a -in decryptme.txt -out decrypted.txt.gz decompression: gunzip -c decrypted.txt.gz > message.txt </code></pre> |
35,274,038 | 0 | <p>A few important differences:</p> <ul> <li>partially <strong>reversible</strong> (<code>CountVectorizer</code>) <strong>vs irreversible</strong> (<code>HashingTF</code>) - since hashing is not reversible you cannot restore original input from a hash vector. From the other hand count vector with model (index) can be used to restore unordered input. As a consequence models created using hashed input can be much harder to interpret and monitor.</li> <li><strong>memory and computational overhead</strong> - <code>HashingTF</code> requires only a single data scan and no additional memory beyond original input and vector. <code>CountVectorizer</code> requires additional scan over the data to build a model and additional memory to store vocabulary (index). In case of unigram language model it is usually not a problem but in case of higher n-grams it can be prohibitively expensive or not feasible.</li> <li>hashing <strong>depends on</strong> a size of the vector , hashing function and a document. Counting depends on a size of the vector, training corpus and a document. </li> <li><strong>a source of the information loss</strong> - in case of <code>HashingTF</code> it is dimensionality reduction with possible collisions. <code>CountVectorizer</code> discards infrequent tokens. How it affects downstream models depends on a particular use case and data.</li> </ul> |
34,941,431 | 0 | Ble pairing failed <p>I was involved an Android APP which does BLE connection and pairing with our company Bt chip. The APP is as BLE central role, while the Bt chip is as BLE peripheral role.</p> <p>When the APP runs on Android 4.4 or 5.0 smart phone, the BLE connection and pairing works well. When the APP runs on Android 5.1 or the latest version 6.0, BLE pairing is terminated by error code (error code: 13), while BLE connection is succeed. Here is the air log:</p> <pre><code>4,148 0x50654c1d 0x0000 1 LL_VERSION_IND 24 2015/12/3 14:13:39.600368 4,160 0x50654c1d 0x0001 2 LL_VERSION_IND 24 00:00:00.048473 2015/12/3 14:13:39.648841 4,163 0x50654c1d 0x0002 1 LL_FEATURE_REQ 27 00:00:00.048522 2015/12/3 14:13:39.697363 4,169 0x50654c1d 0x0003 2 LL_FEATURE_RSP 27 00:00:00.049066 2015/12/3 14:13:39.746429 4,179 0x50654c1d 0x0004 1 LL_CONNECTION_UPDATE_REQ 0x000a 30 00:00:00.048436 2015/12/3 14:13:39.794865 4,234 0x50654c1d 0x000b 1 LL_ENC_REQ 41 00:00:00.303755 2015/12/3 14:13:40.098620 4,237 0x50654c1d 0x000c 2 LL_ENC_RSP 31 00:00:00.007727 2015/12/3 14:13:40.106347 4,244 0x50654c1d 0x000d 2 LL_START_ENC_REQ 19 00:00:00.007500 2015/12/3 14:13:40.113847 4,245 0x50654c1d 0x000e M LL_START_ENC_RSP 23 00:00:00.007273 2015/12/3 14:13:40.121120 4,248 0x50654c1d 0x000f S LL_START_ENC_RSP 23 00:00:00.007726 2015/12/3 14:13:40.128846 4,392 0x50654c1d 0x004a M LL_CONNECTION_UPDATE_REQ 0x0050 34 00:00:00.442275 2015/12/3 14:13:40.571121 4,794 0x50654c1d 0x008c M LL_CHANNEL_MAP_REQ 0x0093 30 00:00:03.002545 2015/12/3 14:13:43.573666 7,168 0x50654c1d 0x0131 M LL_CHANNEL_MAP_REQ 0x0138 30 00:00:08.043797 2015/12/3 14:13:51.617463 10,065 0x50654c1d 0x0261 M LL_CHANNEL_MAP_REQ 0x0268 30 00:00:14.820121 2015/12/3 14:14:06.437584 10,449 0x50654c1d 0x029d M LL_TERMINATE_IND 24 00:00:02.925044 2015/12/3 14:14:09.362628 </code></pre> <p>My Bt host program (based on Bt chip) received <code>CONNECTION_PARAMETER_UPDATE_COMP_IND</code> event, and then received <code>LE_DEVICE_DISCONNECT_COMP_IND</code> event. I guess the operation of disconnect <code>BLE</code> is done by Android Bt stack.</p> <p>In Android 4.4 or 5.0, There is no <code>CONNECTION_PARAMETER_UPDATE_COMP_IND</code> event received, So what's the matter about it, how could I make BLE pairing success on Android 5.1 or 6.0. Any help will be appreciated.</p> |
17,142,695 | 0 | Remove common indexes of array <p>I have some indexes that I need to remove from main array. For example:</p> <pre><code>$removeIndex=array(1,3,6); $mainArray=array('1'=>'a','2'=>'b','3'=>'c','4'=>'d','5'=>'e','6'=>'f'); </code></pre> <p>I want end result like:</p> <pre><code> $mainArray=array('2'=>'b','4'=>'d','5'=>'e'); </code></pre> <p>I know we have <code>array_slice</code> function in PHP, which can be run in loop, but I have very huge data and I want to avoid looping here.</p> |
6,358,707 | 0 | <p>That's not how tab view controllers work. You can implement this method in your app delegate (after making it the delegate for the UITabeBarController)....</p> <pre><code>- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController </code></pre> <p>Then call a reset method (or similar) on your view controller to pop back to the root view controller.</p> <p>This is not how you normally work with UITabBarControllers however....</p> |
8,979,217 | 0 | <p>Don't think of it as evaluating a String. It's still just a chain of properties.</p> <p>So the practical answer to your question is:</p> <pre><code>var o:Object = {}; o["array"] = []; //we do have to insantiate the array first o["array"][0] = 4; </code></pre> |
29,545,868 | 0 | <p>Firstly, there is no requirement that joins be made using keys. Sure, that's usually how they're done, but you can join on anything (that's one of the big positives of a relational database).</p> <p>Simply join tableC to the other two tables using the attribute columns to create your insertion data:</p> <pre><code>insert into tableNew select keyC, keyA, keyB, atrC1, atrC2 from tableC c join tableA a on a.atrA1 = c.atrA1 and a.atrA2 = c.atrA2 join tableB b on b.atrB1 = c.atrB1 </code></pre> |
21,716,093 | 0 | <p>Use this to stop at the first closing curly bracket.</p> <pre><code>var html = a.replace(/img{([^}]*)}/g, '<img src="$1" class="image">'); </code></pre> |
4,609,319 | 0 | MySQL replication from Linux to MySQL on Windows over SSH? <p>Is it possible to perform MySQL replication from the master database on Linux to a slave database running on Windows?</p> <p>Also, an SSH connection must be established between the 2 servers; I'd like to be able to have a script on the slave Windows machine that would run periodically, establish the connection, wait for the replication to finish, and then drop the connection. So, pull from the client rather than push from the master. Is this possible/reasonable/difficult?</p> |
34,530,487 | 0 | ListView also made a call to find the original index of the selected element <p>There are two static ArrayList located in the main activity. I put this data in the ListView to fragment and search procedures would apply. But refreshing the index s search results. How can I get the original index of the selected element? Thank you </p> <pre><code> adapter = new ArrayAdapter<String>(getActivity(), R.layout.list_item, R.id.product_name, SimpleTabsActivity.name_man); lv.setAdapter(adapter); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(getActivity(),SimpleTabsActivity.mean_man.get(position),Toast.LENGTH_LONG).show(); } }); inputSearch.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) { // When user changed the Text adapter.getFilter().filter(cs); adapter.notifyDataSetChanged(); } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable arg0) { // TODO Auto-generated method stub } }); </code></pre> |
37,433,646 | 0 | <p>You can some changes in your css</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.tablep{ float:left; width:20%; } .bg{ background-color:grey; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code> <div class="tablep bg">Code #</div><div class="tablep bg">Product Name</div><div class="tablep bg">Date</div><div class="tablep bg">Amount</div><br> <div class="tablep">Id1</div><div class="tablep">product1</div><div class="tablep">2015</div><div class="tablep">100USD</div></code></pre> </div> </div> </p> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.