pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
783,253
0
<p>This is why we have the REST (and SOAP) protocols.</p> <p>The desktop makes RESTful requests to your web application. Your web application receives the REST requests and does the real work.</p> <p>Your code exists in exactly one place -- the web.</p>
4,766,481
0
Xcode cannot find a java class which I'm trying to extend <p>I'm working on a Java project which was written by someone else. This person made a hierarchy of folders inside the 'src' folder. I've added a new java class into one of those folders and defined it as 'XmlFile.java'. Then, I'm trying to have it extend a previously written class 'GenericFile.java' by writing</p> <pre><code>package //Same package GenericFile is in public class XmlFile extends GenericFile { ... } </code></pre> <p>When I try to compile the project it gives me the error </p> <pre><code>Cannot find symbol </code></pre> <p>and refers me to the line </p> <pre><code>public class XmlFile extends GenericFile </code></pre> <p>if I take out </p> <pre><code>extends GenericFile </code></pre> <p>everything compiles great.</p> <p>I also notice after adding the new file (XmlFile.java) I cannot delete it (the option in Edit->Delete is not selectable for that file, or for any files/folders created by the person from whom I got the project).</p> <p>Is there some sort of permission issue here or some hidden scope issue caused by the permissions being strange or what?</p> <p>Please help me</p> <p>Cheers, WhiteTiger</p>
15,457,887
0
How to set up syntastic for vim? <p>So I git cloned the repository to <code>~/.vim/bundle</code> and had pathogen installed. I can be sure pathogen works fine since my other plugins in bundle are all working fine. After googling for a while, it seems that syntastic should work out of box for c code. I also checked that I have all the executables specified in <code>syntastic/syntax_checkers/c/</code>.</p> <p>Here is a part of my .vimrc file:</p> <pre><code>" syntastic let g:syntastic_auto_loc_list=1 let g:syntastic_disabled_filetypes=['html'] let g:syntastic_enable_signs=1 </code></pre> <p>When I open a *.c file and do <code>:SyntasticCheck</code>, nothing happens. There is no errors complaining command not found, so syntastic is loaded. However, even if the *.c file that's currently opened contains errors syntax error, syntastic is not showing anything. </p> <p>It is the first time I use syntastic so I don't really know the correct way to invoke it. </p> <p>I also tried <code>:SyntasticCheck [c]</code> and I get the following error message:</p> <pre><code>Error detected while processing function &lt;SNR&gt;_22_UpdateErrors..&lt;SNR&gt;22_CacheErrors: line 16: E121: Undefined variable: checkers E15: Invalid expression: checkers </code></pre> <p>Can someone tell me what I did wrong and how to invoke syntastic? Thanks!</p>
30,639,829
0
<p>Its pretty easy to be honest with the native_handle. That's how I solved it.</p> <pre><code>#include &lt;sys/ioctl.h&gt; .... :::Constructor::: { //config for my device serialPort.open(port); serialPort.set_option(serial_port::baud_rate(9600)); serialPort.set_option(serial_port::parity(serial_port::parity::even)); serialPort.set_option(serial_port::character_size(serial_port::character_size(8))); serialPort.set_option(serial_port::stop_bits(serial_port::stop_bits::one)); serialPort.set_option(serial_port::flow_control(serial_port::flow_control::none)); fd = serialPort.native_handle(); // fd is of typ int } void setRTS(bool enabled //int fd = serialPort.native_handle(); int data = TIOCM_RTS; if (!enabled) ioctl(fd, TIOCMBIC, &amp;data); else ioctl(fd, TIOCMBIS, &amp;data); } void setDTR(bool enabled) { //int fd = serialPort.native_handle(); int data = TIOCM_DTR; if (!enabled) ioctl(fd, TIOCMBIC, &amp;data); // Clears the RTS pin else ioctl(fd, TIOCMBIS, &amp;data); // Sets the RTS pin } </code></pre>
9,669,631
0
<p>In principle, you would only need to tunnel port 80 at every ssh.</p> <p>So, at every step: <code>ssh -L80:localhost:80 &lt;next-host&gt;</code>. </p> <p>However, you will not be able to tunnel port 80 (and all ports &lt; 1024) without root privileges, so you'll have to use a different port for this.</p>
33,480,864
0
How to make the parent view to handle all the OnClick events? <p>I have a Layout that has a button that shows another view, but only for 1 time, I mean, you click the button, it dissapear and the other view is shown, the second time you should click the parent view of that button and the other view (the one that was shown) should dissapear and the button should appear again. I am trying with <code>clickable:false</code> and <code>focusable:false</code> but it is not working. How can I achieve that?</p> <p><strong>Relevant Code</strong></p> <p>XML</p> <pre><code>&lt;LinearLayout android:id="@+id/item_tournament_header" android:background="@drawable/bg_card_tournament" android:layout_width="match_parent" android:layout_height="wrap_content" android:weightSum="15"&gt; &lt;RelativeLayout android:clickable="false" android:focusable="false" android:layout_weight="3" android:layout_width="0dp" android:layout_height="match_parent"&gt; &lt;com.github.siyamed.shapeimageview.CircularImageView android:id="@+id/item_friend_img_profile_pic" android:layout_height="48dp" android:layout_width="48dp" android:layout_centerInParent="true" android:scaleType="centerCrop" android:src="@drawable/ic_profile" app:siBorderColor="@color/white"/&gt; &lt;/RelativeLayout&gt; &lt;LinearLayout android:clickable="false" android:focusable="false" android:layout_weight="10" android:layout_width="0dp" android:orientation="vertical" android:layout_height="match_parent"&gt; &lt;TextView android:id="@+id/tournament_name" android:textSize="@dimen/text_h3" android:textStyle="bold" android:textColor="@color/white" android:layout_width="match_parent" android:layout_height="wrap_content" /&gt; &lt;TextView android:id="@+id/tournament_client" android:textSize="@dimen/text_p" android:textColor="@color/white" android:layout_width="match_parent" android:layout_height="wrap_content" /&gt; &lt;/LinearLayout&gt; &lt;RelativeLayout android:clickable="false" android:focusable="false" android:layout_weight="2" android:layout_width="0dp" android:orientation="vertical" android:layout_height="match_parent"&gt; &lt;ImageView android:id="@+id/btn_plus" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:src="@drawable/ic_plus_tournaments"/&gt; &lt;/RelativeLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>Java</p> <pre><code> btn_plus = (ImageView) findViewById(R.id.btn_plus); TournamentContent =(LinearLayout)findViewById(R.id.item_tournament_content); TournamentHeadaer =(LinearLayout)findViewById(R.id.item_tournament_header); btn_plus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { TournamentContent.setVisibility(View.VISIBLE); btn_plus.setVisibility(View.GONE); } }); TournamentHeadaer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if(btn_plus.getVisibility()==View.VISIBLE) { // It's not entering here!!! TournamentContent.setVisibility(View.GONE); btn_plus.setVisibility(View.VISIBLE); } } }); </code></pre>
18,799,786
0
<p>you can store the values into an array and use this </p> <pre><code>[datesArray sortUsingSelector:@selector(compare:)]; </code></pre> <p>it will sort u the time </p>
21,251,886
0
<p>There are several syntax errors in your code try the following code,</p> <pre><code>$(function() { $("#toggleSelect").on("change", function() { idToggler = $(this).attr("rel"); if ($("#" + idToggler).is(":disabled")) { $("#" + idToggler).prop("disabled", false); } else { $("#" + idToggler).prop("disabled", true); } }); }); </code></pre> <p><a href="http://jsfiddle.net/pranavcbalan/Tc56X/" rel="nofollow"><strong><em>Fiddle Demo</em></strong></a></p>
2,295,552
0
<pre><code>select TPNB, sum(AllocatedQty) as 'QTY' from ( SELECT TPND, TPNB FROM ProductLookup GROUP BY TPND, TPNB ) as PL inner join dbo.AllocatedStock as AStock on PL.TPND = AStock.TPND group by TPNB </code></pre>
22,985,403
0
Convert hexadecimal string to numeric IP Address in PHP <p>i want to convert this kind of address <strong>0xC0A8071B</strong> to a numeric Ip Address (ex: 192.168.96.55)</p> <p>How to do that in PHP?</p>
18,700,563
0
My ajax call is not working in Chrome and Firefox <p>Hi My ajax call is not working in chrome and firefox but it is in Safari. I am not able to figure it out as it is working on all browsers locally. My site is recently had SSl certificate.Is that something causing problem? I am not sure. For reference below is my Ajax function</p> <pre><code>&lt;script type="text/javascript"&gt; //&lt;![CDATA[ $(function () { $("#selectReport").hide(); $("select#countryId").change(function () { var manu = $("#manufacturerId option:selected").text(); $("#Manufacturer").val(manu); $("#selectReport").show(); }); $("select#reportId").change(function (e) { e.preventDefault(); var country = $("#countryId option:selected").text(); $("#CountryName").val(country); }); $("select#reportId").change(function (event) { event.preventDefault(); var reportName = $("#reportId option:selected").text(); var manufacturer = $("#Manufacturer").val(); var countryName = $("#CountryName").val(); var theUrl = "/Reports/GetReport/" + reportName + "/" + manufacturer + "/" + countryName; $.ajax({ url: theUrl, type: 'get', success: function (data) { alert("I am success"); $('#ajaxOptionalFields').html(data); }, error: function () { alert("an error occured here"); } }); }); }); //]]&gt; &lt;/script&gt; </code></pre>
3,094,575
0
<p>Since your function is going to return a vector, you will have to make a new vector (i.e. copy elements) in any case. In which case, <code>std::remove_copy_if</code> is fine, but you should use it correctly:</p> <pre><code>#include &lt;iostream&gt; #include &lt;vector&gt; #include &lt;set&gt; #include &lt;iterator&gt; #include &lt;algorithm&gt; #include &lt;functional&gt; std::vector&lt;int&gt; filter(const std::vector&lt;int&gt;&amp; all, const std::set&lt;int&gt;&amp; bad) { std::vector&lt;int&gt; result; remove_copy_if(all.begin(), all.end(), back_inserter(result), [&amp;bad](int i){return bad.count(i)==1;}); return result; } int main() { std::vector&lt;int&gt; all_items = {4,5,2,3,4,8,7,56,4,2,2,2,3}; std::set&lt;int&gt; bad_items = {2,8,4}; std::vector&lt;int&gt; filtered_items = filter(all_items, bad_items); copy(filtered_items.begin(), filtered_items.end(), std::ostream_iterator&lt;int&gt;(std::cout, " ")); std::cout &lt;&lt; std::endl; } </code></pre> <p>To do this in C++98, I guess you could use <code>mem_fun_ref</code> and <code>bind1st</code> to turn set::count into a functor in-line, but there are issues with that (which resulted in deprecation of bind1st in C++0x) which means depending on your compiler, you might end up using std::tr1::bind anyway:</p> <pre><code>remove_copy_if(all.begin(), all.end(), back_inserter(result), bind(&amp;std::set&lt;int&gt;::count, bad, std::tr1::placeholders::_1)); // or std::placeholders in C++0x </code></pre> <p>and in any case, an explicit function object would be more readable, I think:</p> <pre><code>struct IsMemberOf { const std::set&lt;int&gt;&amp; bad; IsMemberOf(const std::set&lt;int&gt;&amp; b) : bad(b) {} bool operator()(int i) const { return bad.count(i)==1;} }; std::vector&lt;int&gt; filter(const std::vector&lt;int&gt;&amp; all, const std::set&lt;int&gt;&amp; bad) { std::vector&lt;int&gt; result; remove_copy_if(all.begin(), all.end(), back_inserter(result), IsMemberOf(bad)); return result; } </code></pre>
35,615,251
0
<p>You just need to adjust the lookbehind to</p> <pre><code>(?&lt;!System\.)Windows\.Forms </code></pre> <p>Or with word boundary to be more precise:</p> <pre><code>(?&lt;!\bSystem\.)\bWindows\.Forms\b </code></pre> <p>See the <a href="http://regexstorm.net/tester?p=(%3F%3C!%5CbSystem%5C.)%5CbWindows%5C.Forms%5Cb&amp;i=I%20am%20using%20VS%20regex%20to%20try%20and%20delete%20the%20string%20Windows.Forms%20but%20not%20System.Windows.Forms&amp;r=" rel="nofollow">regex demo</a></p> <p>The lookbehind is checking the text <em>before</em> the current position meets some subpattern. So, the text you need to match and consume is <code>Windows.Forms</code>, but it should not be preceded with <code>System.</code>. Thus, the lookbehind (negative one) should only contain <code>System\.</code> (or <code>\bSystem\.</code>). </p> <p>Note that the dots must be escaped to match literal dots.</p>
40,851,473
0
I get a big Error when i want to run this program in eclipse <p>I can't run this program in Eclipse. Eclipse doesn't say anything's wrong, I just can't open it.</p> <p><a href="https://i.stack.imgur.com/fGd5u.jpg" rel="nofollow noreferrer">Screenshot of the error and my program</a></p>
39,730,618
0
<p>There is no issue on the code, it seems there is no matching row for the update condition.</p> <p><strong>Below is the tested code which works fine;</strong></p> <pre><code>using System; using System.Data; using System.Data.SqlClient; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace WindowsFormsApplication1 { public class SQLConnect { public SQLConnect(string startUp) { startupPath = startUp; connectionSuccesful = false; OpenConnection(); } public SqlConnection sqlConnect; public string startupPath { get; set; } public bool connectionSuccesful { get; set; } public bool temp { get; set; } public void IndtastBeløb(int beløb, string kategori) { DateTime time = DateTime.Now; int iBolig = 0; int iOther = 0; int iTransport = 0; int iLoan = 0; int iMad = 0; int iDiverse = 0; SqlCommand command = new SqlCommand("SELECT * FROM Entries WHERE dag = @day AND maned = @month AND ar = @year", sqlConnect); // command.Parameters.AddWithValue("@day", time.Day); command.Parameters.AddWithValue("@month", time.Month); command.Parameters.AddWithValue("@year", time.Year); /*command.Parameters.Add("@day", SqlDbType.Int); command.Parameters["@day"].Value = time.Day; command.Parameters.Add("@month", SqlDbType.Int); command.Parameters["@month"].Value = time.Month; command.Parameters.Add("@year", SqlDbType.Int); command.Parameters["@year"].Value = time.Year;*/ SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { //thing = reader["bolig"].ToString(); //int iBolig = reader.GetInt32(0); iBolig = (int)reader["bolig"]; iOther = (int)reader["ovrige"]; iTransport = (int)reader["transport"]; iLoan = (int)reader["gold"]; iMad = (int)reader["mad"]; iDiverse = (int)reader["diverse"]; switch (kategori) { case "Bolig": iBolig += beløb; break; case "ovrige": iOther += beløb; break; case "Transport": iTransport += beløb; break; case "gold": iLoan += beløb; break; case "mad": iMad += beløb; break; case "diverse": break; default: break; } } reader.Close(); SqlCommand changeRow = new SqlCommand("UPDATE Entries SET bolig=@bolig WHERE dag=@day", sqlConnect); //, øvrige=@øvrige, transport=@transport, gæld=@gæld, mad=@mad, diverse=@diverse " + "WHERE dag=@day AND måned=@month AND år=@year" changeRow.Parameters.AddWithValue("@bolig", iBolig); changeRow.Parameters.AddWithValue("@day", time.Day); /*changeRow.Parameters.AddWithValue("@øvrige", iOther); changeRow.Parameters.AddWithValue("@transport", iTransport); changeRow.Parameters.AddWithValue("@gæld", iLoan); changeRow.Parameters.AddWithValue("@mad", iMad); changeRow.Parameters.AddWithValue("@diverse", iDiverse); changeRow.Parameters.AddWithValue("@month", time.Month); changeRow.Parameters.AddWithValue("@year", time.Year);*/ int cc = changeRow.ExecuteNonQuery(); } else { temp = false; } } public void OpenConnection() { sqlConnect = new SqlConnection(@"initial catalog=StackOverflow;User Id=sa;password=xxxxxx;Server=.;"); //sqlConnect = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename='c:\users\simo8211\documents\visual studio 2015\Projects\LuksusFældenForms\LuksusFældenForms\bin\Debug\LuksusDatabase.mdf';Integrated Security=True"); try { sqlConnect.Open(); connectionSuccesful = true; } catch { connectionSuccesful = false; } } } } private void Form1_Load(object sender, EventArgs e) { SQLConnect ocon = new WindowsFormsApplication1.SQLConnect(Application.StartupPath); if(ocon.connectionSuccesful) { ocon.IndtastBeløb(1, "Bolig"); } } </code></pre> <p><strong>SQL Script;</strong></p> <pre><code>create table Entries (bolig int, dag int, maned int, ar int, ovrige int,transport int, gold int, mad int,diverse int) insert into Entries values(1,27,9,2016,1,2,3,4,5) -- after update select * from Entries </code></pre> <p><strong>Result</strong></p> <p><a href="https://i.stack.imgur.com/qLzv2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qLzv2.png" alt="enter image description here"></a></p>
12,345,689
0
Silverlight 4 Capture source is not stopped <p>I am working on a Silverlight project to record the audio on a web page.</p> <p>After I clicked the Pause button the code will always throw an exception:</p> <p><strong>Capture source is not stopped</strong></p> <p>If I put a break point on this line of code and wait there for 3-5 seconds then run the code, no exception will be threw.</p> <pre><code> if (audioSink.CaptureSource.State == CaptureState.Started) (break point is on this line) </code></pre> <p>Here is the code</p> <pre><code> private void Pause(object sender, RoutedEventArgs e) { //System.Threading.Thread.Sleep(TimeSpan.FromSeconds(5)); if (audioSink.CaptureSource.State == CaptureState.Started) { audioSink.CaptureSource.Stop(); this.btnPause.IsEnabled = false; this.btnRecord.IsEnabled = true; this.btnSave.IsEnabled = true; } } audioSink.CaptureSource.Stop(); (This is the line of code which throws the exception) </code></pre>
24,148,724
0
<p>I figured out why I was getting the error. In the list that was being returned, sometimes <code>id</code> was appearing before <code>high_score</code>, i.e. I was getting <code>"id": 10, "high_score": 180</code>, which is why the test ran OK. But at other times <code>high_score</code> was appearing before <code>id</code>, i.e. it was <code>"high_score": 180, "id": 10</code>, which is why the test was failing.</p>
34,950,063
0
<p>Bison macros (<code>$</code> and <code>@</code>) are only expanding <em>directly</em> in actions -- and this expansion happens as bison generates C code. C macros are expanded in later, when your C compiler runs on the output of bison. So if you want to use the bison macros in a C macro, you need to ensure that they appear directly in the action, generally as an argument to the macro:</p> <pre><code>#define SET_LOCATION(DEST, SRC) \ { DEST = SRC; \ .... } </code></pre> <p>used as</p> <pre><code>SET_LOCATION(@$, @n) </code></pre>
3,847,514
0
Google Checkout for peer-to-peer payments <p>I'm trying to figure out if I can use Google Checkout for peer-to-peer payments. It seems fairly straightforward to set it up between a vendor and customers, but I'm not sure if it works well (or at all) for p2p.</p> <p>Can I use Google Checkout to do peer to peer payments?</p>
33,536,397
0
<p>Please try the following:</p> <pre><code>for word in wn.words(): print word </code></pre> <p>This should work because <code>wn.words()</code> is actually an iterator that generates a sequence of strings, rather than a list of strings like <code>b.words</code>. The <code>for</code> loop causes the iterator to generate the words one at a time.</p>
10,269,674
0
<p>If you slice a string with a <em>negative</em> number, Python counts backward from the end.</p> <pre><code>complement = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A'} s = "AAAAAAAAAACCCCCCCCCCTTTTTTTTTTGGGGGGGGGG" "".join(complement[c] for c in s[-20:-10]) </code></pre> <hr> <p>EDIT:</p> <p>Your edit looks about right to me, yes. I am very bad at checking for <a href="http://en.wikipedia.org/wiki/Off-by-one_error" rel="nofollow">fencepost errors</a>, but you're better placed to see those than I am anyway!</p> <p>I've rewritten your code to be more Pythonic, but not changed anything substantial.</p> <pre><code>bc = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A', 'N':'N'} f = open('chr22.fa') l = ''.join(line.strip() for line in f) f.seek(0) for line in f: fields = line.split('\t') gene_ID, chr, strand = fields[:2] start = int(fields[3]) end = int(fields[4]) if strand == '-': start, end = -(start + 1), -(end + 1) geneseq = ''.join(bc[base.upper()] for base in l[start:end]) </code></pre>
17,320,883
0
right click save as pdf is not coming in embed tag <p>In my web page there is an Iframe and in this Iframe pdf is being generated by birt UI tool and working fine. But Problem is when I right click on the pdf and do save as its saving it as a html not as pdf.</p> <p>The structure of the dome element is like this</p> <pre><code>&lt;iframe&gt; #document &lt;html&gt; &lt;embed ..... &gt;&lt;/embed&gt; &lt;/html&gt; &lt;/iframe&gt; </code></pre> <p>Actually this link is being fired and which gives a form and after filling the form and submitting it the pdf file is coming </p> <p>The link is <code>http://localhost:9090/ui_dashboard/frameset?__report=reports/RPT5008.rptdesign&amp;__format=pdf&amp;</code></p> <p>this gives a form and the then after submitting it pdf is generated runtime. </p> <p>So in this embed the pdf is being generated and coming to browser.But when I right click it is considering it as a html element not as a pdf.</p> <p>Please help</p>
6,372,737
0
How to create indexes on MQT(materialized query table) in Db2? <p>How to create indexes on MQT(materialized query table) in Db2? I haven't found this information in documentation? Is index creation syntax the same as for common tables?</p>
18,102,804
0
<p>You must <code>hide()</code> before you can <code>fadeIn()</code>, try this: </p> <pre><code>$(document).ready(function () { $("table").css('color','green').hide().fadeIn(2000); }); </code></pre>
21,519,618
0
<p>The behavior you so beautifully demonstrated is by design (or lack of, if you will). You are right in part, the crazy_linker does resolve some of such issues (but not all of them). There is an easy but ugly workaround. Build a dummy <code>libfcn_defined.so</code> which only has <code>T someMethod</code> in its <strong>nm</strong>. Use it to link <code>libfnc_undefined.so</code>, using <code>LD_LIBS</code>. NDK will show a warning, but that's OK. LAoad the real <code>libfcn_defined.so</code> in your Java.</p>
2,686,876
0
How does the same origin policy apply to IP addresses <p>I have a server on our company intranet that runs JBoss. I want to send API calls to this server from my machine, also on the intranet, and get the resulting XML responses using JQuery. </p> <p>I read the entry on <a href="http://en.wikipedia.org/wiki/Same_origin_policy" rel="nofollow noreferrer">Wikipedia</a> but am confused how that applies to my situation, since our machines only have IP addresses, not domain names. </p> <p>I have</p> <ul> <li><strong>server URL</strong>: 10.2.200.3:8001/serviceroot/service</li> <li><strong>client IP address</strong>: 10.2.201.217</li> </ul> <p>My questions are:</p> <ol> <li>As far as I understand these are different domains, right? So I have to use a proxy to issue JQuery.ajax calls to the server</li> <li>If I want to avoid doing (2), can I install Apache on the server and server the page with JS code form there? But then the JS will be from 10.2.200.3 and the server is at 10.2.200.3:8001. Aren't these considered different domains according to policy?</li> </ol> <p>Thanks!</p>
32,001,655
0
Dummy Browser for Codename One <p>Is there a relatively simple way to create a dummy browser, as in a browser with only the display portion, no address bar, buttons, etc. in a Codename One app? I want to build an app that is using the equivalent of a mobile site for most of the content but still uses the conventional app features for some of its functionality.</p>
35,676,933
0
Laravel 4.2 / Mysql Json(Text) Column Elements Eager Load <p>I have 3 table matches, players , player_details</p> <p>Matches row is = <br></p> <h2>id(int) | game(varchar) <br></h2> <p>1 | computer<br></p> <p>Players row is = <br></p> <h2>id(int) | match_id(int) | players(text)(for json) <br></h2> <p>1 | 1 | [{id:100},{id:102},{103}]<br></p> <p>Players_Details row is = <br></p> <h2>id(int) | player_name <br></h2> <p>100 | leonardo <br> 102 | mark <br> 103 | david <br></p> <p>i want to eager loading with three table for example<br> Matches::with('players')->get();<br> <br> how can i get matches with players and players_details eager loading.</p> <hr> <p>i try too <br> Matches row is = <br></p> <h2>id(int) | game(varchar) | players(text)(for json) <br></h2> <p>1 | computer | [{id:100},{id:102},{103}]<br> Matches::with('players.id')->get();<br> but not working anywhere i need help.</p> <hr> <p>Sorry for my english i'm not english person, thanks for patience.</p>
15,008,246
0
<p>I use this code (<em>implmented before I learned about ndb tasklets</em>):</p> <pre><code> while rpcs: rpc = UserRPC.wait_any(rpcs) result = rpc.get_result() # process result here rpcs.remove(rpc) </code></pre>
15,220,424
0
<p>You can do that programmatically,</p> <pre><code>myFrameLayout.setDrawingCacheEnabled(true); myFrameLayout.buildDrawingCache(); Bitmap bitmap = myFrameLayout.getDrawingCache(); myAnotherLayout.setBackgroundDrawable(new BitmapDrawable(bitmap))); </code></pre>
37,726,390
0
Manually writing bmp image works for one resolution and is broken for other <p>I try to create bmp output image. According to bmp header structure this code looks correct. Bmp header structure was taking according to <a href="http://www.fastgraph.com/help/bmp_header_format.html" rel="nofollow">http://www.fastgraph.com/help/bmp_header_format.html</a> But it produced valid bmp image only for resolution 500x500px. Whats wrong with code?</p> <pre><code>#include &lt;cstdint&gt; #include &lt;fstream&gt; struct BmpHeader { uint32_t mFileSize; // Size of file in bytes uint32_t mReserved01; // 2x 2 reserved bytes uint32_t mDataOffset; // Offset in bytes where data can be found (54) uint32_t mHeaderSize; // 40B int mWidth; // Width in pixels int mHeight; // Height in pixels short m_colorPlates; // Must be 1 short mBitsPerPixel; // We use 24bpp uint32_t mCompression; // We use BI_RGB ~ 0, uncompressed uint32_t mImageSize; // mWidth x mHeight x 3B uint32_t mHorizRes; // Pixels per meter (75dpi ~ 2953ppm) uint32_t mVertRes; // Pixels per meter (75dpi ~ 2953ppm) uint32_t mPaletteColors; // Not using palette - 0 uint32_t mImportantColors; // 0 - all are important }; int main() { uint32_t width = 2; uint32_t height = 2; std::ofstream bmp("1.bmp", std::ios::binary); BmpHeader header; bmp.write("BM", 2); header.mFileSize = uint32_t(sizeof(BmpHeader) + 2) + width * height * 3; header.mReserved01 = 0; header.mDataOffset = uint32_t(sizeof(BmpHeader) + 2); header.mHeaderSize = 40; header.mWidth = width; header.mHeight = height; header.m_colorPlates = 1; header.mBitsPerPixel = 24; header.mCompression = 0; header.mImageSize = 0; header.mHorizRes = 2953; header.mVertRes = 2953; header.mPaletteColors = 0; header.mImportantColors = 0; bmp.write((char*)&amp;header, sizeof(header)); for (unsigned int y = 0; y&lt;height; y++) { for (unsigned int x = 0; x&lt;width; x++) { typedef unsigned char byte; byte bgrB[3]; bgrB[0] = 120; bgrB[1] = 120; bgrB[2] = 120; bmp.write((char*)&amp;bgrB, sizeof(bgrB)); } } } </code></pre>
36,227,877
0
<p>A typical way of doing this uses the ANSI standard window function<code>row_number()</code>:</p> <pre><code>select t.* from (select t.*, row_number() over (partition by idUser order by idUser) as seqnum from t ) t where seqnum = 1; </code></pre>
23,781,245
0
How to convert an element css to JSON? <p>I let my users to change any attribute(location, color, and ...) of every element in a page before printing.</p> <p>I'm looking for a way which user can store the new style sheet and restore it anytime later?</p> <p>I've tried to parse <code>element.style</code>, but it doesn't return an array! Also <code>$(element).css()</code> doesn't work without any argument! </p>
28,979,134
0
<p>Erm, i think i found a solution here, the file i downloaded from the internet is not password protected, it is just in protected mode.</p> <p>so the answer to this is basically to disable the protected mode in excel. thanks for the answer anyway. @Hao</p>
9,776,678
0
<p>Once you have your <code>JFrame</code> or <code>JPanel</code>, add a text field to it.</p> <p><code>JTextArea</code> is a good choice, because it's multiple lines. Once it is added, you can <code>.append('text');</code> to it instead of writing the <code>System.out.print();</code></p> <pre><code>JFrame jFrame = new JFrame(); JTextArea jTextArea = new JTextArea(); jTextArea.append( "Hello World." ); jFrame.add( jTextArea ); </code></pre>
1,325,866
0
<p>I download the latest version from SubSonic's <a href="http://github.com/subsonic/SubSonic-3.0-Templates/tree/master" rel="nofollow noreferrer">github</a> and everything is OK!</p> <p>The new version a new T4 file: <strong>Structs.tt</strong></p>
35,317,573
0
counts iteration in a nest for-loop <p>Here is the pseudo code:</p> <pre><code>for i=1 to n for j=1 to n for k=1 to j x = x+1 </code></pre> <p>and I have to calculate these two thing (i) count it precisely (ii) find it big-O</p> <p>in (i), my final answer is n^4+2n^3+5n^2+4n+2. in (ii), because there are three loop, so it's O(n^3);</p> <p>It seem that there must be an error either (i) or (ii) since (i) raise to the power 4, and the big-O is just 3.</p> <p>Here is my step when counting the iteration:</p> <pre><code>for(i=1; i &lt;=n; i++) </code></pre> <p>count as 1+(n+1)+n which is (2n+2).</p> <p>So, (2n+2)+n(2n+2)+n(4+6+8+...+2n+2)+n^2(1+2+3+...+n)(2) which finally come out with n^4(see the last term, sum of AS * n).</p>
29,295,593
0
<p>Here i Used Content Dialog Box.</p> <p>Button_Click Code</p> <pre><code>ContentDialog msg = new ContentDialog(); msg.Content = "Data Saved Successfully"; msg.ContentTemplate = Application.Current.Resources["ContentDialogContentTemplate"] as DataTemplate; msg.PrimaryButtonText = CommonDisplayMessages.DisplayMessage_Yes; </code></pre> <p>await msg.ShowAsync();</p>
37,755,323
0
<p>You can also use the <code>setAttribute()</code> function</p> <pre><code>function showElements(){ document.getElementsByClassName('blah')[0].setAttribute("data-symbol",document.getElementById('search').value); } </code></pre>
6,925,500
0
<p>finally i've come up the conclusion with the help of Naresh (thank you). Here the short summary: at the first run i was trying to copy my 1.6mb data.db file from assets to /data.../databases folder which one never existed. So </p> <pre><code>OutputStream os = new FileOutputStream(destPath); </code></pre> <p>line gave error. But after that line my dbhelper instance called getreadabledatabase which created the databases folder under specified path. Android put a db with same name but no useful data in it. In my copyDatabase method i updated it as follows:</p> <pre><code>InputStream is = getBaseContext().getAssets().open(assetsDB); //when there is no databases folder fileoutputstream gives error, //we have to make sure databases folder exists DbAdapter temp = new DbAdapter(getApplicationContext()); temp.open(); //gets readable database: creates databases folder containing DB_NAME db temp.close(); //since we don use this temp, we close //this wont give error: because path is now exists (databases folder exists) OutputStream os = new FileOutputStream(destPath); //copying 1K bytes at a time byte[] buff = new byte[1024]; </code></pre> <p>this is the solution i've come up with. By the way, former sdk's of 2.3 assets database size should be less than 1mb. This is anohter issue and found the solution <a href="http://ponystyle.com/blog/2010/03/26/dealing-with-asset-compression-in-android-apps/" rel="nofollow">here</a></p>
8,601,307
0
Widening and boxing with java <p>In Java programming language widen and boxing doesn't work, but how does it work in following example?</p> <pre><code>final short myshort = 10; Integer iRef5 = myshort; </code></pre> <p>Why does this work? Is this not the same as widen and then box?</p> <p>But if I write the following code:</p> <pre><code>final int myint = 10; Long myLONG = myint; </code></pre> <p>why it doesn't work?</p>
2,671,400
0
Why would some POST data go missing when using Uploadify? <p>I have been using Uploadify in my PHP application for the last couple months, and I've been trying to track down an elusive bug. I receive emails when fatal errors occur, and they provide me a good amount of details. I've received dozens of them. I have not, however, been able to reproduce the problem myself. Some users (like myself) experience no problem, while others do.</p> <p>Before I give details of the problem, here is the flow.</p> <ul> <li>User visits edit screen for a page in the CMS I am using.</li> <li>Record id for the page is put into a form as a hidden value.</li> <li>User clicks the Uploadify browse button and selects a file (only single file selection is allowed).</li> <li>User clicks Submit button for my form.</li> <li>jQuery intercepts the form submit action, triggers Uploadify to start uploading, and returns false for the submit action (manually cancelling the form submit event so that Uploadify can take over).</li> <li>Uploadify uploads to a custom process script.</li> <li>Uploadify finishes uploading and triggers the Javascript completion callback.</li> <li>The Javascript callback calls $('#myForm').submit() to submit the form.</li> </ul> <p>Now that's what SHOULD happen. I've received reports of the upload freezing at 100% and also others where "I/O Error" is displayed.</p> <p>What's happening is, the form is submitting with the completion callback, but some post parameters present in the form are simply not in the post data. The id for the page, which earlier I said is added to the form as a hidden field, is simply not there in the post data ($_POST)--there is no item for 'id' in the $_POST array. The strange thing is, the post data DOES contain values for some fields. For instance, I have an input of type text called "name" which is for the record name, and it does show up in the post data.</p> <p>Here is what I've gathered:</p> <ul> <li>This has been happening on Mac OSX 10.5 and 10.6, Windows XP, and Windows 7. I can post exact user agent strings if that helps.</li> <li>Users must use Flash 10.0.12 or later. We've made it so the form reverts to using a normal "file" field if they have &lt; 10.0.12.</li> </ul> <p>Does anyone have ANY ideas at all what the cause of this could be?</p>
40,409,502
0
How to read values from a text file and saving as the custom property[SOAP UI] <p>I have two values in the text file as follows:</p> <pre><code>12345 67895 </code></pre> <p>I want to save these two values as two custom properties so I can use it in my soap request. </p> <p>This is what I have so far but no luck:</p> <pre><code>def myTestCase = context.testCase // configure the path to your textfile here File tempFile = new File("C:\Users\cverma\Desktop\SOAPProject\testdata.txt") List lines = tempFile.readLines() </code></pre> <p>I am getting this error:</p> <blockquote> <p>org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script22.groovy: 4: unexpected char: '\' @ line 4, column 29. File tempFile = new File("C:\Users\cverma\Desktop\SOAPProject\testdata.txt") ^ org.codehaus.groovy.syntax.SyntaxException: unexpected char: '\' @ line 4, column 29. at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:135) at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:108) at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:236) at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:162) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:912) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:574) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:550) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:527) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:279) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:258) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:613) at groovy.lang.GroovyShell.parse(GroovyShell.java:625) at groovy.lang.GroovyShell.parse(GroovyShell.java:652) at groovy.lang.GroovyShell.parse(GroovyShell.java:643) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:138) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:89) at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:141) at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:250) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: Script22.groovy:4:29: unexpected char: '\' at org.codehaus.groovy.antlr.parser.GroovyLexer.mESC(GroovyLexer.java:2180) at org.codehaus.groovy.antlr.parser.GroovyLexer.mSTRING_CTOR_END(GroovyLexer.java:2226) at org.codehaus.groovy.antlr.parser.GroovyLexer.mSTRING_LITERAL(GroovyLexer.java:1985) at org.codehaus.groovy.antlr.parser.GroovyLexer.nextToken(GroovyLexer.java:468) at org.codehaus.groovy.antlr.parser.GroovyLexer$1.nextToken(GroovyLexer.java:258) at groovyjarjarantlr.TokenBuffer.fill(TokenBuffer.java:69) at groovyjarjarantlr.TokenBuffer.LA(TokenBuffer.java:80) at groovyjarjarantlr.LLkParser.LA(LLkParser.java:52) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.nls(GroovyRecognizer.java:796) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.newExpression(GroovyRecognizer.java:13525) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.primaryExpression(GroovyRecognizer.java:10993) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.pathExpression(GroovyRecognizer.java:11595) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.postfixExpression(GroovyRecognizer.java:13332) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.unaryExpressionNotPlusMinus(GroovyRecognizer.java:13301) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.powerExpressionNotPlusMinus(GroovyRecognizer.java:13005) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.multiplicativeExpression(GroovyRecognizer.java:12937) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.additiveExpression(GroovyRecognizer.java:12607) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.shiftExpression(GroovyRecognizer.java:9824) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.relationalExpression(GroovyRecognizer.java:12512) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.equalityExpression(GroovyRecognizer.java:12436) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.regexExpression(GroovyRecognizer.java:12384) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.andExpression(GroovyRecognizer.java:12352) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.exclusiveOrExpression(GroovyRecognizer.java:12320) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.inclusiveOrExpression(GroovyRecognizer.java:12288) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.logicalAndExpression(GroovyRecognizer.java:12256) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.logicalOrExpression(GroovyRecognizer.java:12224) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.conditionalExpression(GroovyRecognizer.java:4850) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.assignmentExpression(GroovyRecognizer.java:8027) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.expression(GroovyRecognizer.java:10001) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.expressionStatementNoCheck(GroovyRecognizer.java:8353) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.varInitializer(GroovyRecognizer.java:2682) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.variableDeclarator(GroovyRecognizer.java:7928) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.listOfVariables(GroovyRecognizer.java:7882) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.variableDefinitions(GroovyRecognizer.java:2278) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.declaration(GroovyRecognizer.java:2165) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.statement(GroovyRecognizer.java:1208) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.compilationUnit(GroovyRecognizer.java:757) at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:131) ... 20 more 1 error</p> </blockquote>
35,548,217
0
packaging options based on product flavor in gradle <p>I m using packaging options to exclude some libs. Is it possible to have packaging options based on product flavor. For example -</p> <pre><code>android { productFlavors { flavorDimensions 'models' S2 { flavorDimension 'models' minSdkVersion 22 .... } S6 { flavorDimension 'models' minsdkversion 22 .... } } packagingOptions { exclude 'lib/armeabi/libs2.so' exclude 'lib/arm64-v8a/libs6.so } } </code></pre> <p>Now in above code, I want to exclude only <code>'lib/armeabi/libs2.so'</code> in apk generated for <code>s6</code> flavor and want to exclude only <code>'lib/arm64-v8a/libs6.so'</code> in apk generated for <code>s2</code> flavor</p> <p>How can we achieve this. </p>
19,901,016
0
<p>The short answer is that you cannot have a zero sized array. Nor can you have an extent with a length of zero for any of its ranks. For better or worse that's just the way it is. C++ AMP assumes that any work passed to it is real work. Remember on the CPU there is no overhead for having a zero length loop or a zero length array. This may not be the case on the GPU, there is still a potential overhead for declaring the array on the accelerator and passing a kernel to the GPU via a DMA buffer. There may also be an underlying limitation in DirectX 11 (I've not had time to look).</p> <p>In this case (unless I'm misunderstanding the problem) work is being done but some of the input data (<code>myArray</code>) may be zero length, but <code>someExtent</code> is non-zero.</p> <p>If in fact <code>someExtent</code> is also zero then the simplest solution would simply be to wrap the code which calls the <code>parallel_for_each</code> in a conditional statement that skips the call entirely for zero values.</p> <p>If <code>someExtent</code> is always non-zero but you need to pass in a zero length <code>myArray</code> then I'd suggest adding one to the length of <code>myArray</code> and simply accounting for that in your calculation.</p> <p>In either case I think this works around the zero length array issue. If it doesn't then please provide more details.</p>
40,378,821
0
<p>Advantage of RxJava is asynchronous. You can't predict order of evaluation. I believe you should reach MainActivity from "onError" method. I see, that you use MVP pattern somehow. It should help. If you provide more info about classes relations I could say more.</p>
39,588,437
0
<p>I think the pins 12 and 24 (BOARD numberingscheme) are hardware PWM capable, hence more accurate.</p>
14,817,741
0
Posting data over web services using Java, Ajax and json is not working <p>Could somebody help me with this. This goes always to error, no error message though, just the console.log. Is there any good way to debug this or could you just see what's wrong in this?</p> <p>Thanks! Sami </p> <pre><code>function foo(){ alert('Button pressed'); var user={"id":10,"firstName":" Ted","lastName":"TESTING","age":69,"freeText":"55555","weight":55}; $.ajax({ type: "POST", contentType: "application/json", url: "http://localhost:8080/testSoft/webresources/entity.user/", dataType: "json", data: user, success: function(data){alert(data);}, error: function(data) { console.log('#####################error:################################'+data); alert('addUser error: ' + data.firstName); } }); }; </code></pre> <p>Web service:</p> <pre><code>@POST @Override @Consumes({"application/xml", "application/json"}) public void create(User entity) { super.create(entity); } </code></pre> <p>User</p> <pre><code>public class User implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Basic(optional = false) @Column(name = "id") private Integer id; @Size(max = 45) @Column(name = "firstName") private String firstName; @Size(max = 45) @Column(name = "lastName") private String lastName; @Column(name = "age") private Integer age; @Lob @Size(max = 65535) @Column(name = "freeText") private String freeText; @Column(name = "weight") private Integer weight; </code></pre>
14,133,215
0
Is there Any free FingerPrint identification SDK Available in .net? <p>I am working on a fingerprint identification system project,Is there any free sdk available for fingerprint identification system?</p>
13,635,179
0
c++ stl priority_queue with a custom comparator as function parameter <p>I want to use priority_queue and pass it to a function:</p> <pre><code>// compare points according their distance to some target point struct MyComparator { Point target; MyComparator(Point t) : target(t) {} bool operator() (const Point&amp; p1, const Point&amp; p2) { return distance(target, p1) &lt; distance(target, p2); } }; typedef priority_queue&lt;Point, vector&lt;Point&gt;, MyComparator&gt; myque; void myfunc(const Point&amp; target, myque&amp; que) { ... } // call myfunc Point target = ...; myque queue(MyComparator(target)); myfunc(target, queue); // error : no matching function for call to ‘myfunc(const Point&amp;, myque (&amp;)(MyComparator))’ </code></pre> <p>How can I resolve this error?</p> <p>Thanks. </p>
25,820,898
0
<p>Many device have different resolution, so problem in your code is marginleft and margintop. Due to them your button position is different in all device. Also android:layout_weight="0.50" should not be used in Relative layout. It will have no affect.</p>
19,154,549
0
<ul> <li>This $dbh is unset so it becomes $this->null->beginTransaction().</li> <li>beginTransaction() returns a bool so $stmt becomes bool not PDOStatement</li> </ul> <p>-</p> <pre><code>$stmt=$this-&gt;$dbh-&gt;beginTransaction(); </code></pre> <p>Should probably be something like</p> <pre><code>$this-&gt;dbh-&gt;beginTransaction(); $sql = ... $stmt = $this-&gt;dbh-&gt;prepare($sql); </code></pre> <p>Replace ... with your insert query.</p> <ul> <li>You don't need transactions for just one query.</li> </ul>
40,220,787
0
Prolog style loop does not overflow? <p>A typical loop code in Prolog is something like:</p> <pre><code>loop_test :- format('loop...~n'), loop_test. </code></pre> <p>as discussed in another question: <a href="http://stackoverflow.com/questions/22885622/how-can-i-simulate-a-while-loop-in-prolog-with-unchangeable-conditions">How Can I simulate a while loop in Prolog with unchangeable conditions?</a></p> <p>Here's my question: Is this recursive form safe against overflow? Typically such a recursive code of C,C++,Python would overflow as in each function call a new stack is added. I executed above <code>loop_test</code> under <code>trace</code>. It was something like:</p> <pre><code>?- trace. ?- loop_test. Call: (6) loop_test2 ? creep Call: (7) format('loop...~n') ? creep loop... Exit: (7) format('loop...~n') ? creep Call: (7) loop_test2 ? creep Call: (8) format('loop...~n') ? creep ... loop... Exit: (158) format('loop...~n') ? creep Call: (158) loop_test2 ? creep Call: (159) format('loop...~n') ? creep ... </code></pre> <p>Clearly the <strong>number</strong> is increasing. With this simple code, I couldn't find the memory increase; I executed <code>loop_test</code> for more than 5 min and tracked VmPeak (peak size of virtual memory) written in /proc/xxx/status, but no change was observed.</p> <p>I want to understand if the above code (<code>loop_test</code>) is really safe? and Why is it safe? (or safer way to implement loops in Prolog).</p> <p>Many thanks.</p>
11,494,961
0
<p>This sounds very similar to the problem we faced when starting out. The foundation we laid down when building out the QA team still exists today and is a keystone to the success of the release process.</p> <p>Some high level points on how we structure build release</p> <ul> <li><p>We must, at all times, know what is going in to the code and why. Track intent for changes in a bug tracking system of some sort.</p></li> <li><p>All code check-ins must reference a committed set of work. If it's a QOL enhancement, someone creates a ticket t reference. No unreferenced check-in's!</p></li> <li><p>Code is built from scratch at least once a day, multiple times a day is preferable. QA <strong>always</strong> tests from the latest build. </p></li> <li><p>Build failures are treated with the utmost urgency; fixed immediately.</p></li> <li><p>Builds must be stored on long-term storage of some sort, and used as a basis for delivery. Major milestones are tagged not only on source control but on the long-term storage machine. We use a machine called <em>BuildManager</em> for this purpose</p></li> <li><p>I personally do not believe in separating deployment from the QA team. I believe that each QA Engineer should know how to deploy the application and create necessary test data themselves. There are some trade-offs to this approach, I'm happy to discuss them further if interested</p></li> <li><p>Once code is deployed, a sanity test of some sort must be run. Whether it's a systems/configuration test, or an actual functional verification, you must do whatever you can to ensure this build is not going to waste anyone's time. Reducing the wall time between code check-in and knowing there's a solid build in place is one of the best automation investments you can make.</p></li> </ul> <p>From here, how QA is structured and how they work with other members of the team are as critical as the foundation just discussed.</p>
28,534,844
0
<p>Yes, you can basically do the same thing using package name <strong>com.facebook.katana</strong> with the same action (<code>ACTION_VIEW</code>) and using extra Intent.EXTRA_TEXT to set the text.</p>
145,419
0
<p>Sure, just add view-source: in front of the URL.</p> <pre><code>view-source:http://stackoverflow.com/posts/edit/145419 </code></pre> <p>Will show the source of this page for instance - try it in the address bar.</p>
26,043,472
0
Linq query on Xdocument returns "System.linq.Enumerable+WhereSelectEnumerableIterator'2[system.XML.Linq.Xelement,System.String] <p>I'm using the following XML:</p> <pre><code>&lt;?xml version="1.0" encoding="windows-1252"?&gt; &lt;hexML&gt; &lt;head&gt; &lt;title&gt;&lt;![CDATA[ ]]&gt;&lt;/title&gt; &lt;description&gt;&lt;![CDATA Releases XML]]&gt;&lt;/description&gt; &lt;flastmod date="2014-09-24T16:34:23 CET"/&gt; &lt;/head&gt; &lt;body&gt; &lt;press_releases&gt; &lt;press_release id="1796256" joint_id="383320" language="fr" type="5"&gt; &lt;published date="2014-06-19T11:55:09 CET"/&gt; &lt;categories&gt; &lt;category id="75" label="French" keywords="language"/&gt; &lt;/categories&gt; &lt;headline&gt;&lt;![CDATA[Test Release for Website 3]]&gt;&lt;/headline&gt; &lt;ingress&gt;&lt;/ingress&gt; &lt;location href="http://rthrthrthrtrt.com/test.xml"/&gt; &lt;/press_release&gt; &lt;/press_releases&gt; &lt;/body&gt; &lt;/hexML&gt; </code></pre> <p>I'm trying to get datas through this block of code: </p> <pre><code>cp[cpt, 0] = (from c in xdoc.Descendants("press_release") where (int)c.Attribute("id") == r select c.Element("headline").Value).Single(); cp[cpt, 1] = (from c in xdoc.Descendants("press_release") where (int)c.Attribute("id") == r select (c.Element("published").Attribute("date").Value)).ToString(); cp[cpt, 3] = (from c in xdoc.Descendants("press_release") where (int)c.Attribute("id") == r select c.Element("location").Attribute("href").Value).ToString(); </code></pre> <p>The first instruction returns correctly : Test Release for website 3. On the other hand , the 2 others returns "System.linq.Enumerable+WhereSelectEnumerableIterator'2[system.XML.Linq.Xelement,System.String]" instead.</p> <p>Thank for your help</p> <p>NB: I'm using .NET V3.5</p>
20,507,952
0
<p>This problem has been bugged me several times in past 3 years. Every time I met it and fixed it and then forgot to take a note. Next time it happened, I start scratching and search for solution one more time. So, let me record my solution here and share with whoever might deal with this problem. Follow the steps below and make sure your are using JQuery 1.8 or upper with .net framework 4.0 and it will work.</p> <ul> <li>In the behavior note under system.serviceModel note, set to webHttp:</li> </ul> <blockquote> <pre><code>&lt;behaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior name="webHttpBehavior"&gt; &lt;webHttp /&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;/behaviors&gt; </code></pre> </blockquote> <ul> <li>Define an JsonP binding:</li> </ul> <blockquote> <pre><code>&lt;bindings&gt; &lt;webHttpBinding&gt; &lt;binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true" /&gt; &lt;/webHttpBinding&gt; &lt;/bindings&gt; </code></pre> </blockquote> <ul> <li>set your service bindingConfiguration to the binding just defined</li> </ul> <blockquote> <pre><code>&lt;services&gt; &lt;service name="dpRestService.qcmmsService"&gt; &lt;endpoint address="" behaviorConfiguration="webHttpBehavior" binding="webHttpBinding" bindingConfiguration="webHttpBindingWithJsonP" contract="gwsRestService.qcmmsService" /&gt; &lt;/service&gt; &lt;/services&gt; </code></pre> </blockquote> <ul> <li>Add Jaon as response Format for ResponseFormat attribute</li> </ul> <blockquote> <p>[WebGet(UriTemplate = "<em>your service template</em>" , ResponseFormat = WebMessageFormat.Json)]</p> </blockquote> <ul> <li>Jquery request:</li> </ul> <blockquote> <p>$.ajax({ url: url, type: 'GET', //Type of ajax call data: {}, contentType: 'application/json', crossDomain: true, dataType: 'jsonp',<br> success: callBackFun, error: errorFun });</p> </blockquote> <p>I hope this will help.</p>
22,402,313
0
The basic component processes of Xcode Server, a continuous integration system for iOS and OS X development built by Apple. It is part of OS X Server.
3,144,418
0
Signal for Entire Row Selection in QTableWidget <p>Is there a signal for when an entire row in the QTableWidget has been selected by pressing the buttons that are stacked on the left? I would like that to enable some functionality, but am not sure how?</p> <p>Thank you in advance!</p>
10,019,832
0
<p>You could have Previous/Next buttons quite easily. I would place them outside the TabControl (so you're not duplicating them) and then have their handlers simply increment or decrement the SelectedIndex property of the TabControl.</p> <p>EDIT: Are you aware that you can make tabs not look like tabs? You can set the Appearance property to TabAppearance.Buttons, for instance, and the "tabs" will instead be rendered as buttons, which would make the tab row look more like a breadcrumb control.</p> <p>You can also use Panels overlapped on the Form, and call the BringToFront() method of the Panel representing the Page you want.</p>
36,497,766
0
<p>I didn't know that ognl created map can be used to do this...</p> <p><strong>The Solution:</strong></p> <pre class="lang-xml prettyprint-override"><code>&lt;s:iterator value="#{'val1':'abc','val2':'xyz'}" var="some"&gt; &lt;s:radio key="selectedId" list="#some" listKey="key" listValue="value"/&gt;&lt;br/&gt; &lt;/s:iterator &gt; </code></pre>
29,265,555
0
managed_file form element doesn't render correctly <p>I have a simple managed file form element that is the only element in my form. It looks like this:</p> <pre><code>$form['upload'] = array( '#type' =&gt; 'managed_file', '#title' =&gt; t('Select a YML file'), '#progress_message' =&gt; t('Please wait...'), '#progress_indicator' =&gt; 'bar', '#description' =&gt; t('Click "Browse..." to select a file to upload.'), '#required' =&gt; TRUE, '#upload_validators' =&gt; array('file_validate_extensions' =&gt; array('yml txt docx')), '#upload_location' =&gt; $upload_dest, ); </code></pre> <p>When I render the form using the drupal_get_form callback in hook_menu I get a perfectly formed managed_file upload field with the browse and upload buttons. Things change when I decide I want to add a table of information underneath the form. This requires building a table using theme functions then adding that to the form by rendering the form and appending the table. I create my table and add it to the form:</p> <pre><code>$rows = array(); foreach($yml_files as $yml_file){ $rows[] = array($yml_file-&gt;uri, $yml_file-&gt;filename); } $output = drupal_render($form['upload']); $output .= theme('table', array('header'=&gt;$header, 'rows'=&gt;$rows)); return $output; </code></pre> <p>When I generate the form using drupal_render, I get the nice help text, but no upload form. The table renders fine in both scenarios and I'm not seeing any errors.</p> <p>If Drupal uses drupal_render to render its forms why would the form look different in the second scnenario? Is there a way to get the entire form? I've tried a variety of ways of passing the form and using dpm to print the form at various stages and I'm not sure where to go from here.</p> <p>Standard file upload fields render correctly as do other form elements. It seems to be limited to the managed_file element.</p>
27,589,056
0
<p>I would use <a href="http://www.regular-expressions.info/lookaround.html" rel="nofollow">negative lookahead</a> like below,</p> <pre><code>&gt;&gt;&gt; re.sub(r'(?!-)\W', r' ', 'black-white') 'black-white' &gt;&gt;&gt; re.sub(r'(?!-)\W', r' ', 'black#white') 'black white' </code></pre> <p><code>(?!-)\W</code> the negative lookahead at the start asserts that the character we are going to match would be any from the <code>\W</code> (non-word character list) but not of hyphen <code>-</code> . It's like a kind of substraction, that is <code>\W - character present inside the negative lookahead</code> (ie. hyphen).</p> <p><a href="https://regex101.com/r/sS1qO8/2" rel="nofollow">DEMO</a></p>
8,367,052
0
<p>I think actually the answer for what you're trying to do is a 'git clone' of your github repository - the command for that is given to you on github above latest commits when you open that repository. Get your boss to run clone on his machine, then build/whatever in the usual way.</p> <p>Github pull requests are just a notification that you've changed something to get someone else on github (perhaps the project you initially forked, perhaps one that has forked you) to do a pull and review/merge/whatever.</p>
40,929,986
0
Uploading multiple files along with body using REST in the request <p>I am trying to send json data and multiple files in the request in spring rest controller. When sending through Advanced Rest Client, it is giving media type unsupported. Is the code below is correct in the controller side ? I have tried sending the body and multiple files in the Advanced Rest Client, is that way correct or any changes needed ? Where is the problem ? </p> <p>Rest controller code -</p> <pre><code>public @ResponseBody String handleMultiFileUpload(@RequestBody Object fullNameWithId,@RequestParam("file") MultipartFile[] files){ // code for manipulating data and uploading to server } </code></pre> <p>Below are the images what I am currently dealing with.</p> <p><a href="https://i.stack.imgur.com/YeKYZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YeKYZ.png" alt="enter image description here"></a></p> <p><a href="https://i.stack.imgur.com/dhZkF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dhZkF.png" alt="enter image description here"></a></p>
26,447,424
0
How to re-create jQuery data-table on ajax response? <p>I am creating a jQuery data-table based on some search criteria using ajax call &amp; response. I am able to create the table. But when I try to search again, I am getting the below error.</p> <blockquote> <p>DataTables warning: table id=sendBulkEmailTable - Cannot reinitialise DataTable. For more information about this error, please see <a href="http://datatables.net/tn/3" rel="nofollow">http://datatables.net/tn/3</a></p> </blockquote> <p>I guess I cannot re-create the data table again. Can somebody provide a solution to my problem, how can I refresh the data of my table on next search.</p> <p>jQuery ajax call I wrote is: </p> <pre><code> $("#tableId").dataTable({ "data": res.ajaxResult.data, "columns": [ { "data": "data1" }, { "data": "data2" }, { "data": "data3" }, { "data": "data4" }, { "data": "data5" } ] }); </code></pre>
6,950,609
0
<p>The <code>Sender</code> of the event is the button, so save the "appData" into button's tag (when you create it) and then in the mouse event use it, ie</p> <pre><code>procedure TForm3.CreateAppButton(sBtnCapt: string); ... begin AppData := TAppDetails.Create(sBtnCapt); with NewButton do begin Tag := NativeInt(AppData); ... end; //AppData.Free; // NB! do not free here! end; procedure TForm3.btnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState;X, Y: Integer); var AppData: TAppDetails; begin ... else if Button = mbRight then begin AppData := TAppDetails((Sender as TSpeedButton).Tag); // use the appData ShellExecute(self.Handle, 'open', PChar(AppData.Wiki), nil, nil, SW_SHOWNORMAL); //AppData.Free; // NB! do not free here! end; end; procedure TForm3.DeleteAppButton(aBtn: TSpeedButton); begin TAppDetails(aBtn.Tag).Free; aBtn.Free; end; </code></pre> <p>Note that you have to free the objects you saved into button's tag when the buttons are freed (unless the buttons are not freed until app terminates, then you don't have to worry about it althought it isn't good style).</p>
22,034,071
0
Does npm shrinkwrapping a module in npm do anything? <p>If I shrinkwrap a module I publish to npm, does that affect in any way the installation of modules that depend on that module? Or does npm simply ignore the shrinkwrap file of dependencies and only look at the package.json?</p>
795,921
0
Verifying a release builds <p>My projects reference static DLLs I've created. These projects are setup to make sure a corresponding build phase occurs. Meaning, if I build in simulator/debug, the static library will have an up to date simulator/debug build. I can verify my app works fine except for device/release. Is there a way to verify device/release? It's sort of like throwing it over the wall to Apple without any verification.</p>
4,453,285
0
<p>Okay here's what I wound up doing. It's not very elegant, but it works. I created a pre-build step that looks like this:</p> <pre><code>echo namespace Some.Namespace &gt; "$(ProjectDir)\CiInfo.cs" echo { &gt;&gt; "$(ProjectDir)\CiInfo.cs" echo ///^&lt;summary^&gt;Info about the continuous integration server build that produced this binary.^&lt;/summary^&gt; &gt;&gt; "$(ProjectDir)\CiInfo.cs" echo public static class CiInfo &gt;&gt; "$(ProjectDir)\CiInfo.cs" echo { &gt;&gt; "$(ProjectDir)\CiInfo.cs" echo ///^&lt;summary^&gt;The current build number, such as "153"^&lt;/summary^&gt; &gt;&gt; "$(ProjectDir)\CiInfo.cs" echo public const string BuildNumber = ("%BUILD_NUMBER%" == "" ? @"Unknown" : "%BUILD_NUMBER%"); &gt;&gt; "$(ProjectDir)\CiInfo.cs" echo ///^&lt;summary^&gt;String of the build number and build date/time, and other useful info.^&lt;/summary^&gt; &gt;&gt; "$(ProjectDir)\CiInfo.cs" echo public const string BuildTag = ("%BUILD_TAG%" == "" ? @"nohudson" : "%BUILD_TAG%") + " built: %DATE%-%TIME%"; &gt;&gt; "$(ProjectDir)\CiInfo.cs" echo } &gt;&gt; "$(ProjectDir)\CiInfo.cs" echo } &gt;&gt; "$(ProjectDir)\CiInfo.cs" </code></pre> <p>Then I added "CiInfo.cs" to the project, but ignored it from version control. That way I never have to edit it or commit it, and the project always has a constant available that is the latest build number and time.</p>
26,894,976
0
Taking Sample in SQL Query <p>I'm working on a problem which is something like this :</p> <p>I have a table with many columns but major are <code>DepartmentId</code> and <code>EmployeeIds</code></p> <pre><code>Employee Ids Department Ids ------------------------------ A 1 B 1 C 1 D 1 AA 2 BB 2 CC 2 A1 3 B1 3 C1 3 D1 3 </code></pre> <p>I want to write a SQL query such that I take out 2 sample <code>EmployeeIds</code> for each <code>DepartmentID</code>.</p> <p>like</p> <pre><code>Employee Id Dept Ids B 1 C 1 AA 2 CC 2 D1 3 A1 3 </code></pre> <p>Currently I am writing the query,</p> <pre><code>select EmployeeId, DeptIds, count(*) from table_name group by 1,2 sample 2 </code></pre> <p>but it gives me total two rows.</p> <p>Any help?</p>
33,504,736
0
<p>In this case yes indeed the <code>return false</code> is returning from the <code>switch</code> and not the entire function. What you wan to do is create a flag variable and when you want to return from the function after the switch, check the flag:</p> <pre><code>function EmptyFieldCheck( .. ) { var returnFlag = false; switch (category) { case 'Hardware': if(..) { ... returnFlag = true; } break; ... } if(returnFlag) return false; /* Other posting code here */ } </code></pre>
22,187,056
0
tween movement speed control <p>I'm using tween engine for smoothing paths of moving entities. To make interpolation you feed function like this: </p> <p><code>Tween.to(myObject, POSITION, 1.0f) .target(50, 70) .ease(Quad.INOUT) .start(myManager);</code> </p> <p>Last argument of <code>to()</code> function is duration. What i learned, if path is longer, the entities move quicker to the target. Shorter the path is, entities move slower. I have float variable called movementSpeed, in every entity, that should move entities 7 pixels per seconds. What is the way using my variable for tween's movement speed instead of having it specified once at factory constructor?</p> <p>My implementation:</p> <pre><code>Stack&lt;Vector2i&gt; stack = new Stack&lt;Vector2i&gt;(); /* ...pushing path points from last to first to the stack. */ Tween t = Tween.to(this, EntityAccessor.POS, 4.0f); for (int i = stack.size()-1; i &gt;= 0; i--) { Vector2i cur = stack.get(i); if (i == 0) { // if point is last then t.target(cur.getX(), cur.getY()); } else { t.waypoint(cur.getX(), cur.getY()); } } t.ease(Quad.INOUT); t.path(TweenPaths.catmullRom); t.delay(0.5f); t.start(game.tweenManager); </code></pre>
16,330,953
0
Pluginf for Different header image on every pages in wordpress <p>I need wordpress plugin for this kind of header image <a href="http://www.slb.com/services/drilling.aspx" rel="nofollow"><a href="http://www.slb.com/services/drilling.aspx" rel="nofollow">http://www.slb.com/services/drilling.aspx</a></a> like in this web site. And this image will not be slider but it's static image on perticular page and category and also different image for all categories and pages. </p>
37,998,032
0
<p>This is indeed expected behaviour – and it's due to the fact that an array in Swift (unlike <code>NSArray</code>) is a value type, meaning that it gets copied when passed about. Although as <a href="http://stackoverflow.com/a/37998340/2976878">@MartinR points out</a>, due to the copy-on-write behaviour of value types, the <em>actual</em> copy of the array will be done when you come to mutate it – although this is an optimisation that shouldn't affect how you think about value types.</p> <p>Therefore when you enumerate over an array, be it with <code>forEach()</code> or <code>for ... in</code> – you're actually iterating over a <em>copy</em> of that array. This works through using an <code>Iterator</code> (or <code>Generator</code> pre-Swift 3). What's happening behind the scenes when you iterate over a collection looks something like this:</p> <pre><code>let collection = [1, 2, 3, 4] var iterator = collection.makeIterator() // next() will return the next element, or nil if it's reached endIndex while let element = iterator.next() { // do something with the element } </code></pre> <p>In the case of an <code>Array</code>, an <code>IndexingIterator</code> is returned for <code>makeIterator()</code> – which will iterate through the elements by keeping track of an index, incrementing it each time you call <code>next()</code>, and returning the element at that given index – until you reach <code>endIndex</code>. (you can see its <a href="https://github.com/apple/swift/blob/master/stdlib/public/core/Collection.swift#L364" rel="nofollow">exact implementation here</a>).</p> <p>The array that you're iterating over is kept as a property of <code>IndexingIterator</code>, therefore ensuring that you're enumerating on a copy – but mutating the original. </p> <p>This therefore means that it's perfectly safe to mutate a value-typed collection while enumerating over it. The enumeration will iterate over the full length of the collection (as it works on the copy) – completely independant of any mutations you do to the original.</p>
19,749,569
0
Jquery DIV transition (or CSS) <p>I am currently looking for a way to slideDown or animate a div to transition from the top to the content height on the page load (undefined). Is this possible or can it only be done with a user event? It is okay if CSS is used in conjunction.</p>
13,078,547
0
<p>You want:</p> <pre><code>awk -F"-" '{ print $3 }' </code></pre> <p>With <code>-F</code> you specify the delimiter. In this case, <code>-</code>. The version number is the third field, so that's why you need <code>$3</code>.</p>
39,120,413
0
<p>Please add below line just above credentials and try if it will help:</p> <pre><code>smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; </code></pre>
28,169,943
0
JPA/Hibernate, Delete on ManyToMany doesn't delete join table records <p>this has been asked a number of other times, but I can't figure out an answer in my case. </p> <p>I have this class <a href="http://tinyurl.com/nrhbnna" rel="nofollow">http://tinyurl.com/nrhbnna</a>, having a ManyToMany relationship to OntologyEntry. Here it is a fragment:</p> <pre><code>@MappedSuperclass public abstract class FreeTextTerm extends Identifiable { ... @ManyToMany( targetEntity = OntologyEntry.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH } ) @JoinTable ( joinColumns = @JoinColumn ( name = "owner_id" ), inverseJoinColumns = @JoinColumn ( name = "oe_id" ) ) @SuppressWarnings ( "unchecked" ) public &lt;OE extends OntologyEntry&gt; Set&lt;OE&gt; getOntologyTerms () ... } </code></pre> <p>I don't have the symmetric side OntologyEntry.freeTextTerms(), cause I don't need it and they don't work well with polymorphism.</p> <p>Now, when I delete records from subclasses in HQL (eg, from ExperimentalPropertyValue, <a href="http://tinyurl.com/mydgnwr" rel="nofollow">http://tinyurl.com/mydgnwr</a>, or Unit, <a href="http://tinyurl.com/lu28sfu" rel="nofollow">http://tinyurl.com/lu28sfu</a>), Hibernate completely ignores records in the respective join tables (eg, it ignores unit_onto_entry, when I delete Unit instances, verified via logs), resulting in foreign key violations, if the current owner has such links.</p> <p>I already know this happens when you attempt to delete from the non-owner side of a many-to-many relation, but that's not the case here. Moreover, I don't think CascadeType.DELETE would help here, cause I do not want to delete children (ie, ontology entries), just the links to them.</p> <p>So, is Hibernate as crap as to ignore such links? (After years of experience, I really hate Hibernate). Do I have to use @PreRemove, as explained in <a href="http://tinyurl.com/kgpk92a" rel="nofollow">http://tinyurl.com/kgpk92a</a>, or is there a cleaner solution?</p> <p>Thanks in advance.</p>
34,001,616
0
<p><code>Select-AzureRmSubscription</code> does change the approach that Azure uses for authentication. I had the same pain points when I converted my scripts. </p> <p>The official way of approaching this via scripting is as follows - </p> <pre><code>$profile = Login-AzureRmAccount Save-AzureRMProfile -Profile $profile -path $path </code></pre> <p>You can then use <code>Select-AzureRmSubscription</code> to none-interactively load those saved profiles. </p> <p>Although ultimately I didn't go this route, I decided to add another layer of security and use a machine based certificate to encrypt / decrypt credentials to pass to <code>Login-AzureRmAccount</code> This way I could manage multiple sets of accounts and never have to be concerned about those tokens being exposed on vulnerable machines. </p>
15,848,901
0
<p>The whole point of using this plugin is to eliminate the need to generate images.</p> <p>Instead, you can use <a href="http://www.mathjax.org/" rel="nofollow">MathJax</a>, a free and open source JavaScript display engine to convert this formula back to an image.</p>
26,205,404
0
<p>use this</p> <pre><code>&lt;?php $name="19875379"; $url = "http://www.ikea.co.il/default.asp?strSearch=".$name; $ch = curl_init(); $timeout = 0; curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_HEADER, TRUE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $header = curl_exec($ch); $redir = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); //print_r($header); $x = preg_match("/&lt;script&gt;location.href=(.|\n)*?&lt;\/script&gt;/", $header, $matches); $script = $matches[0]; $redirect = str_replace("&lt;script&gt;location.href='", "", $script); $redirect = "http://www.ikea.co.il" . str_replace("';&lt;/script&gt;", "", $redirect); echo $redirect; ?&gt; </code></pre> <p><a href="http://stackoverflow.com/questions/20582717/get-the-last-redirected-url-in-curl-php">enter link description here</a></p>
8,832,790
0
Best practices for validating the configuration of a Spring web application <p>I would like that my Spring-based web application were able to <em>validate</em> its configuration during startup.</p> <p>This means for example:</p> <ul> <li>check if the <strong>required folders</strong> exist and are readable/writable</li> <li>check if the required <strong>configuration keys</strong> are set and consistent</li> <li>...</li> <li>check any other <strong>constraint</strong> that is required for the correct functioning</li> </ul> <p>How can you perform these checks and <strong>notify</strong> the system administrator if something is wrong?</p> <p>The goal is to reduce the risk that some critical error arises when the application is actually going to need those resources that are bound to the wrong configuration.</p> <p><strong>NOTE:</strong> my approach is to use a special <strong>EnvironmentValidation</strong> bean that checks if the configuration/folder structure is ok and if not it throws an exception</p>
8,984,537
0
<p>Yes, it does. The javadoc says:</p> <blockquote> <p>Closes this input stream and releases any system resources associated with the stream.</p> </blockquote> <p>And the wrapped stream is definitely such a system resource.</p> <p>Moreover, GZIPInputStream <em>is a</em> FilterInputStream, and the FilterInputStream javadoc says:</p> <blockquote> <p>Closes this input stream and releases any system resources associated with the stream. This method simply performs in.close().</p> </blockquote>
3,890,919
0
Reset globally set routing suffix in symfony routing.yml file <p><br> I am using Symfony 1.3 and I have the following problem:<br> I need a url in this format www.domain.com/folder (no suffix) however the application sets the default suffix to be .html<br> Is there a way to override the global suffix in the routing.yml file? I could use mod_rewrite but I would like this link to be able to work without relying on a non-app resource.</p> <p>Thanks</p>
12,549,601
0
Clickatell alternative SMS-Gateway? <p>We're just about to go live but Clickatell seems to be problematic. Billing AND Server issues!!</p> <p>A quick google search shows a long record of problems.</p> <p>They did however made good impression at first but now we're simply not sure - they don't seem to be stable!</p> <p>So, which <strong>reliable</strong> SMS gateway would allow me to send simple English SMS to Israel (programmatically through an HTTP API)?</p> <p>Saw so far:</p> <ul> <li><a href="http://www.bulksms.com/">http://www.bulksms.com/</a></li> </ul>
14,332,143
0
Spring MVC - How to display blank textbox when integer value is zero <p>Im using spring, hibernate, java, and jsp. My problem is that when the integer value is zero it displays <code>0</code> in my textbox. I want to display only empty string but Idk how to do it. Please help.</p> <p>In my jsp:</p> <pre><code>&lt;form:form method="POST" commandName="division"&gt; ... ... &lt;form:input path="number"/&gt; &lt;/form:form&gt; </code></pre> <p>In my domain:</p> <pre><code>/** * Get the number of the division. * @return The number. */ @Column(name = "NUMBER") public int getNumber() { return number; } /** * Set the number of the division. * @param number The division number. */ public void setNumber(int number) { this.number = number; } </code></pre>
15,745,084
0
Time driven function in Google script <p>I am trying to download the data from a website every hour using Google script. The code is shown as below. When I manually run the function CSV_sgj, I can receive the desired information in email. But when I set the function as time driven (every hour), what I get are all #VALUE!. </p> <p>I found a similar question and tried to change </p> <pre><code>var sheet = SpreadsheetApp.getActiveSheet(); </code></pre> <p>to</p> <pre><code>var sheet = SpreadsheetApp.openById("0AtAYfCLk3-h7dDBnckdSZkNXbkZBLXBHV200SGtuZnc"); </code></pre> <p>but it still does not work.</p> <p>Many thanks in advance for help!</p> <p>The full code is below.</p> <pre><code>function readRows() { var sheet = SpreadsheetApp.getActiveSheet(); var rows = sheet.getDataRange(); var numRows = rows.getNumRows(); var values = rows.getValues(); for (var i = 0; i &lt;= numRows - 1; i++) { var row = values[i]; Logger.log(row); } }; /** * Adds a custom menu to the active spreadsheet, containing a single menu item * for invoking the readRows() function specified above. * The onOpen() function, when defined, is automatically invoked whenever the * spreadsheet is opened. * For more information on using the Spreadsheet API, see * https://developers.google.com/apps-script/service_spreadsheet */ function CSV_sgj() { readRows(); var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:N32"); var data = range.getValues(); var csv = ""; for (var i = 0; i &lt; data.length; ++i) { csv += data[i].join(",") + "\r\n"; } var csvFiles = [{fileName:"PSI5.csv", content:csv}] MailApp.sendEmail("xxxxxx@gmail.com", "CSV", "", {attachments: csvFiles}); } </code></pre>
19,778,602
0
JAXPConfigurator is that some kind of a SAX parser? <p>Looking at some old code that uses JAXPConfigurator.configure(Reader, false) and not really sure what does it do; thanks.</p>
17,516,908
0
<p>You have to create provisioning profiles for adhoc and distribution. See <a href="http://developer.apple.com/library/ios/ipad/#documentation/ToolsLanguages/Conceptual/YourFirstAppStoreSubmission/TestYourApponManyDevicesandiOSVersions/TestYourApponManyDevicesandiOSVersions.html" rel="nofollow">http://developer.apple.com/library/ios/ipad/#documentation/ToolsLanguages/Conceptual/YourFirstAppStoreSubmission/TestYourApponManyDevicesandiOSVersions/TestYourApponManyDevicesandiOSVersions.html</a> Under 'create an AdHoc provisioning profile'</p>
4,924,945
0
<p>The key point is to loop thru the inputs and add their values.</p> <pre><code>var totalInput = 0; $("input").keyup(function () { //zero out the global var totalInput totalInput = 0; $("input").each(function(){ //for each input, add value to global totalInput totalInput += $(this).val() }); //setup price var item_price = parseFloat("50.25"); //display price times totalInput $("h3").text(totalInput * item_price); }); </code></pre>
22,764,343
0
Javascript not drawing on canvas <p>Over here, I am trying to paint image on a canvas (the image is a tile sheet). However, I have checked, the loop works just fine, the code is being executed, the cases are correct (I tested it by logging text to console) however, nothing is being painted on the console. The image is being loaded just fine.</p> <p>I really don't know what exactly causing this problem, there is no syntax error on the console. The following is my code, It might take a little time for anyone to analyse it, but any help is greatly appreciated.</p> <p>Here is the image "monsterTileSheet.png" as defined in the script below:</p> <p><img src="https://i.stack.imgur.com/dhkdO.png" alt="http://imgur.com/m0SY4UE"></p> <pre><code>var canvas = document.querySelector("canvas"); var drawingSurface = canvas.getContext("2d"); var image = new Image(); image.src = "monsterTileSheet.png"; image.addEventListener("load", loadHandler, false); var spaceInc = 0; // increment counter var inc = 5; // increment between the tiles var imgSize = 80; var map = [ [0, 0, 1, 0], [0, 0, 0, 0], [0, 0, 0, 0] ]; function adjustCanvas() { canvas.height = (map.length * imgSize) + (map.length * inc); canvas.width = (map[0].length * imgSize) + (map[0].length * inc); } var monster = { SIZE: 80, frames: 5, hiding: 0, jumping: 1, state: this.hiding, sourceX: 0, sourceY: 0, currentFrame: 0, COLUMNS: 3, start: function () { if (this.currentFrame &lt; this.frames) { this.sourceX = Math.floor(this.currentFrame % this.COLUMNS) * this.SIZE; this.sourceY = Math.floor(this.currentFrame / this.COLUMNS) * this.SIZE; this.currentFrame++; renderImage(); } else { window.clearInterval(interval); this.sourceX = 0; this.sourceY = 0; this.currentFrame = 0; } } }; var x = 0; var y = 0; function renderMap() { for (var i = 0; i &lt; map.length; i++) { for (var j = 0; j &lt; map[0].length; j++) { switch (map[i][j]) { case 0: drawingSurface.drawImage(image, 0, 0, monster.SIZE, monster.SIZE, (j * imgSize) + spaceInc, i * imgSize, imgSize, imgSize); if (spaceInc &gt;= (map[0].length - 1) * inc) { // reset increment spaceInc = 0; } else { spaceInc += inc; } console.log("Case 0"); break; case 1: x = map[i][j] * monster.SIZE y = map[j] * monster.SIZE; stGame(); console.log("Case 1"); break; default: console.log(j); break; } } } } function stGame() { interval = window.setInterval(function () { monster.start(); }, 300); } function loadHandler() { adjustCanvas(); renderMap(); } function renderImage() { drawingSurface.drawImage(image, monster.sourceX, monster.sourceY, monster.SIZE, monster.SIZE, x, y, monster.SIZE, monster.SIZE); } </code></pre>
1,150,483
0
<p>Disclaimer: I'm no <strong>real</strong> a Win32 master :)</p> <p>I never used Qt Creator, but does it create a proper manifest for the exe?<br> maybe the manifest is for a different version (SP1 for example) and you have only the RTM version.<br> Are you using Vista? you can try to run <a href="http://blogs.msdn.com/junfeng/archive/2006/04/14/576314.aspx" rel="nofollow noreferrer">SxsTrace</a> to diagnose side by side issues.</p>
16,568,470
0
<p>When using the command line, try escaping special characters like this:<br /> <code>!</code> ===> <code>\!</code></p>
7,934,774
0
Implementing $.when with $.ajax POST <p>I have an AJAX POST function. I want to obtain a successful callback then execute a function. I chose to achieve this with <code>$.when</code> as <a href="http://jsfiddle.net/smacky311/wYGj6/1/" rel="nofollow">follows</a></p> <pre><code>var url = '/echo/html/'; var json_text = ' '; var FireOrderCounter = 0; $.when( $.ajax({ type: 'POST', url: url, data: json_text, success: function () { FireOrderCounter++; alert('successfully completed Action ' + FireOrderCounter); var millisecondsToWait = 5000; setTimeout(function() { FireOrderCounter++; alert('Done Spinnin ' + FireOrderCounter); }, millisecondsToWait); }, dataType: 'html' }) ).then(openWindow()); function openWindow() { FireOrderCounter++; alert('opened window' + FireOrderCounter ); } </code></pre> <p><code>success</code> callback fires after <code>openWindow()</code>. Does this mean that <code>$.ajax</code> is somehow not deferred and <code>$.when</code> is simply <a href="http://api.jquery.com/jQuery.when/" rel="nofollow">assuming success</a> as described in the API?</p> <blockquote> <p>If a single argument is passed to jQuery.when and it is not a Deferred, it will be treated as a resolved</p> </blockquote> <p>This is a simplified test case. The production code fails similarly. I have to fire this event twice to obtain all the data. There is a race condition.</p> <p>I can insert a breakpoint to make the processing stop. The Function fires while I am still holding onto the debugger. So, its not waiting for a success callback. A short timeout (occurs after ~10 seconds)? How can I fix this?</p>
16,857,479
0
<p>There are multiple syntax errors in your query:</p> <ul> <li><code>let</code> clauses have to be part of a <em>FLWOR</em> expression, which always ends with a <code>return</code> clause.</li> <li><code>if</code> cannot be used without <code>then</code> and <code>else</code> and does not use curly braces.</li> <li>The opening tag <code>&lt;res&gt;</code> needs a matching closing tag <code>&lt;/res&gt;</code> at the end of the query.</li> </ul> <p>The corrected query looks like this:</p> <pre><code>declare variable $datesList := ( "2013-01-01-00.30.00", "2013-01-01-01.00.00", "2013-01-01-01.30.00", "2013-01-01-02.00.00", "2013-01-01-02.30.00", "2013-01-01-03.00.00", "2013-01-01-03.30.00", "2013-01-01-04.00.00" ); &lt;res&gt;{ let $mcId1 := count(//ZZQAD2UsageTransactionSVC/usagePeriods/usagePeriodsList/SQs/SQsList[1]/mL) let $mcId2 := count(//ZZQAD2UsageTransactionSVC/usagePeriods/usagePeriodsList/SQs/SQsList[2]/mL) return if($mcId1 = 8) then ( for $mlList in //ZZQAD2UsageTransactionSVC/usagePeriods/usagePeriodsList/SQs/SQsList[1]/intervals/mL return if($mcId1 &gt; $mcId2) then &lt;text&gt;true&lt;/text&gt; else &lt;text&gt;false&lt;/text&gt; ) else () }&lt;/res&gt; </code></pre>
29,946,806
0
How can I use powershell to retrieve AD distinguishedName from the employeeID only? <p>What I'm trying to do is run a script which compares employee IDs from a CSV file to AD, and if they're NOT in the CSV but ARE in AD they should: - be disabled - have a termination date comment added to the description - move to a different OU</p> <p>The script I'm using below disables the account and adds the comment, but I get an error when it tries to move to different OU. The error is: Move-ADObject : Cannot find an object with identity: 'name1test' ...</p> <p>I've tried a lot of things to adjust the script to get the samAccountName or distinguishedName using only the employeeID, but I've had no luck. Any ideas?</p> <pre><code>Import-Module ActiveDirectory $TargetOU = "ou=Term,ou=Logins,dc=domain,dc=com" $Date = Get-Date -Format MM-dd-yyyy $Users = Import-Csv c:\ADTerm.csv | Select-object -ExpandProperty EmployeeID $Terms = Get-ADUser -filter * -SearchBase "ou=Test,ou=Logins,dc=domain,dc=com" -Properties EmployeeID | Where-Object{$_.EmployeeID -and ($Users -notcontains $_.EmployeeID)} ForEach ($Term in $Terms) { # Retrieve user sAMAccountName. $Name = $Term.sAMAccountName # Disable the user. Set-ADUser -Identity $Name -Enabled $False -Description "Terminated - $Date" # Move the user. Move-ADObject -Identity $Name -TargetPath $TargetOU } </code></pre>
2,649,447
0
Using MembershipCreateStatus in MVC <p>How can I use the MembershipCreateStatus in my controller below to identify errors?</p> <p>My controller below creates a new user but I would like to catch any errors from CreateStatus and add the error to my modelstate.</p> <p>I keep getting errors for status below.</p> <pre><code> [HttpPost] public ActionResult CreateUser(user UserToCreate) { if (ModelState.IsValid) { // TODO: If the UserToCreate object is Valid we'll //Eventually want to save it in a database MembershipCreateStatus status; MembershipService newMembershipService = new MembershipService(); MembershipCreateStatus newUser = newMembershipService.CreateUser(UserToCreate.Username, UserToCreate.Password, UserToCreate.Email,out MembershipCreateStatus **status**); if (newUser == MembershipCreateStatus.Success) { return RedirectToAction("Index", "Home"); } else { ModelState.AddModelError(createStatus); return Redirect("/"); } } //Invalid - redisplay form with errors return View(UserToCreate); } </code></pre>
28,707,049
0
what are some techniques for DRY-ing up macros in Sweet.js? <p>let's say i have these two macros which are identical except for the macro name:</p> <pre><code>macro h1 { case {$name ($x (,) ...)} =&gt; { letstx $nameVal = [makeValue(unwrapSyntax(#{$name}), null)] return #{React.createElement($nameVal, $x (,) ...)} } } macro h2 { case {$name ($x (,) ...)} =&gt; { letstx $nameVal = [makeValue(unwrapSyntax(#{$name}), null)] return #{React.createElement($nameVal, $x (,) ...)} } } </code></pre> <p>what are my options for code reuse here? can i have a macro generate a macro? </p> <p>or could i minimally place the body portion (beginning with <code>letstx...</code>) in it's own 'internal' macro?:</p>