pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
3,359,264
0
<p><strong>Java has a facility built specifically for this purpose - Properties.</strong> Here is very good article about it </p> <p><a href="http://download-llnw.oracle.com/javase/tutorial/essential/environment/properties.html" rel="nofollow noreferrer">http://download-llnw.oracle.com/javase/tutorial/essential/environment/properties.html</a></p>
11,813,152
0
<p>Why not just grab all the right information in one query from the start along the lines of something like this:</p> <pre><code>select a.exID, examples.someField, examples.someOtherField from examples join ( SELECT exID FROM examples WHERE concept='$concept' ORDER BY RAND() limit 5 ) a on a.exID=examples.exID </code></pre> <p>Then you just just pop them into an array (or better yet object) that has all the pertinent information in one row each time.</p>
18,404,377
0
<p>I do not understand why writing a <code>MODULE</code> would not work, but have you considered <code>CONTAINS</code>? Everything above the <code>CONTAINS</code> declaration is visible to the subroutines below the <code>CONTAINS</code>:</p> <pre><code>PROGRAM call_both INTEGER,DIMENSION(2) :: a, b a = 1 b = 2 PRINT *,"main sees", a, b CALL subA CALL subB CONTAINS SUBROUTINE subA PRINT *,"subA sees",a,b END SUBROUTINE subA SUBROUTINE subB PRINT *,"subB sees",a,b END SUBROUTINE subB END PROGRAM call_both </code></pre> <p>The output would be</p> <pre><code>main sees 1 1 2 2 subA sees 1 1 2 2 subB sees 1 1 2 2 </code></pre> <p>This works with <code>ALLOCATABLE</code> arrays as well.</p>
30,604,979
0
<p>as @nkjt pointed out: </p> <p>Do you know the difference between <code>/</code> and <code>./</code></p> <p>If you want to divide pointwise, you have to use the <code>./</code>, otherwise you will get the result of the vector</p> <p><strong>(1+(x/2))</strong> divided by <strong>(1+(x/2))</strong></p> <p>What you want is:</p> <p><code>x = linspace(0,3); y1 = (1+(x/2))./(1-(x/2)); figure, plot(x,y1)</code></p>
25,896,993
0
<p>If you <strong>update</strong> your <strong>google play services</strong> you need to <strong>update your res/values tag</strong> too.</p>
37,510,478
0
CodeIgniter error 403 <p>I'm a complete beginner in CodeIgniter, Frameworks in general, and I tried Laravel and CakePHP but both are very complex to install (for me) so now I've downloaded CI and it looks pretty simple except for this access denied error.</p> <p>The error is the default Firefox 403(access denied) error. It says: <code>You don't have permission to access the requested object. It's either read-protected or not readable by the server.</code></p> <p>This happens when I go to <code>localhost/codeigniter/application</code></p> <p>My base URL: <code>http://localhost/codeigniter/application</code>. I don't know why I set it like that but it seemed logical.</p> <p><strong>UPDATE:</strong> After I edit the htaccess file to make it look like this: ` RewriteEngine On</p> <pre><code>RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.PHP/$1 [L] </code></pre> <p>, it gave me another 403 error (which isn't the default Firefox error) and it simply says "Directory access is forbidden".</p>
28,732,981
0
<p>I think that's what you looking for </p> <pre><code>return Redirect::back(); </code></pre>
29,812,375
0
<p>You didn't specify what version of SQL you are using so I am doing this example in SQL Server where @cost_1 is a variable. You can adapt it to the syntax for whatever SQL variant you are using. The following will give you the counts you want as a SQL result set:</p> <pre><code>SELECT start_dsgn, COUNT(CASE WHEN min_cost_1 &lt;= @cost_1 OR min_cost_2 &lt;= @cost_2 THEN end_dsng END) as Cnt FROM table GROUP BY start_dsgn </code></pre> <p>Once you have that, it's up to you to convert that into whatever format you want in whichever language you are using to query the database. You also didn't specify what language you are using, but it looks like you want a dictionary where start_dsgn is the key. </p> <p>Most languages would return a list or array of either lists, tuples or dictionaries depending on what you use. From there it's pretty easy to convert them into any other form, at least in Python. Strongly typed languages like C#, Java and Swift are a little trickier.</p>
35,608,521
0
Using CBC DES encryption in java card <p>I am trying to encrypt data using Cipher class . I want to specify the initial vector so I use the following functions : </p> <pre><code>try { cipherCBC = Cipher.getInstance(Cipher.ALG_DES_CBC_NOPAD, false); cipherCBC.init(k, Cipher.MODE_ENCRYPT,INITVECTOR,(short)0,(short)8); cipherCBC.doFinal(data, (short) 0, (short) data.length, result, (short) 0); } catch (Exception e) { ISOException.throwIt(ISO7816.SW_CONDITIONS_NOT_SATISFIED); } </code></pre> <p>with the byte array INITVECTOR initialised by a 8-byte array.</p> <p>The problem is that I get always an exception caught when I use the init function.</p> <p><strong>EXTRA INFO:</strong></p> <p>The key is build here :</p> <pre><code>octetsLus = (byte) (apdu.setIncomingAndReceive()); if (octetsLus != 16) { ISOException.throwIt(ISO7816.SW_WRONG_LENGTH); } // build host crypto Util.arrayCopy(buffer, (short)(ISO7816.OFFSET_CDATA+4), message, (short) 0,(short) 4); Util.arrayCopy(buffer, (short)(ISO7816.OFFSET_CDATA+8), message, (short) 4,(short) 4); Util.arrayCopy(buffer, (short)(ISO7816.OFFSET_CDATA), message, (short) 8,(short) 4); Util.arrayCopy(buffer, (short)(ISO7816.OFFSET_CDATA+12), message, (short) 12,(short) 4); // GENERATE SESSION KEYS encrypt_DES(ENC_key, message,(byte) 0x01); Util.arrayCopy(result,(short) 0, ENC_SESS_KEY, (short) 0,(short) 16); encrypt_DES(MAC_key, message,(byte) 0x01); Util.arrayCopy(result,(short) 0, MAC_SESS_KEY, (short) 0,(short) 16); ENC_key = (DESKey) KeyBuilder.buildKey(KeyBuilder.TYPE_DES, KeyBuilder.LENGTH_DES3_2KEY, false); ENC_key.setKey(ENC_SESS_KEY, (short) 0); MAC_key = (DESKey) KeyBuilder.buildKey(KeyBuilder.TYPE_DES, KeyBuilder.LENGTH_DES3_2KEY, false); MAC_key.setKey(MAC_SESS_KEY, (short) 0); Util.arrayCopy(buffer, (short)(ISO7816.OFFSET_CDATA), message, (short) 0,(short) 8); Util.arrayCopy(buffer, (short)(ISO7816.OFFSET_CDATA+8), message, (short) 8,(short) 8); for(i=0;i&lt;8;i++) message[(short)(16+i)]=(byte)PADDING[i]; </code></pre> <p>Concerning the initial vector, even if I use the following initialization, I get the same problem :</p> <pre><code>INITVECTOR =new byte[]{(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00}; </code></pre> <p>On the other hand, when I use the init function which use default initialization parameters the encrypt function works well:</p> <pre><code>cipherCBC.init(k, Cipher.MODE_ENCRYPT); </code></pre>
22,391,425
0
Javamelody report sort <p>i use javamelody to export report. i want the report to be downloaded with times being sorted by the Highest mean time above so that it is easier to make sense of what is taking more time during execution. is there any available configuration to enable report PDF downloaded with one of the columns having sorted values?</p>
15,803,851
0
<p>You've got a query. Therefore this call is inappropriate:</p> <pre><code>OIMScmd.ExecuteNonQuery(); </code></pre> <p>Instead, you should be using <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.executescalar.aspx" rel="nofollow"><code>ExecuteScalar()</code></a>:</p> <pre><code>int count = (int) OIMScmd.ExecuteScalar(); </code></pre> <p>(It's possible that it'll return a <code>long</code> rather than an <code>int</code> - I'm not sure offhand.)</p> <p>Additionally, you should use a <code>using</code> statement for the <code>SqlCommand</code> and create a new connection for each operation:</p> <pre><code>using (var connection = new SqlConnection(...)) { connection.Open(); using (var command = new SqlCommand(query, connection)) { int count = (int) command.ExecuteScalar(); // Now use the count } } </code></pre> <p>It's also not clear what kind of app this is - if it's in a local GUI (WinForms or WPF) you should <em>not</em> be performing database access on the UI thread. The UI will be frozen while the database access occurs. (If this is in a web application, it's even more important that you create a new database connection each time... you don't want two separate requests trying to use the same connection at the same time.)</p>
37,021,006
0
<p>Try following way with highest reading priority value, </p> <pre><code>&lt;receiver android:name=".SmsListener" android:enabled="true" android:exported="true" android:permission="android.permission.READ_SMS"&gt; &lt;intent-filter android:priority="2147483647"&gt; &lt;action android:name="android.provider.Telephony.SMS_RECEIVED"/&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; </code></pre> <p>This will surely solve out your problem.</p> <p>Update from below comment, </p> <p>Since you are checking on Android version 6.0.1 just follow these steps, </p> <ol> <li>Go to Settings, </li> <li>Go to Apps</li> <li>Select your Application</li> <li>Choose Permissions Option</li> <li>Enable SMS permission</li> </ol>
30,235,240
0
<p>Use this:</p> <pre><code>docker inspect --format='{{.HostConfig.Binds}}' &lt;container id&gt; </code></pre>
6,356,860
0
Eclipse vs. CVS: Same Modules, Multiple Branches/Tags <p>I work on two products, each residing in its own CVS module; call them B (Base) and D (Dependent). D is dependent on B; B can exist on its own. Typically I want to have them together in my IDE environment so that I can e.g. follow API calls from D to B in the editor and debugger. These products are on distinct release schedules; a given branch/tag of D is dependent on a specific branch/tag of B. At any given time, I may be working on several different B/D branch/tag combinations.</p> <p>I'm an Eclipse noob, but I believe what we are talking about here is multiple workspaces, one for each B/D combination, and each with projects for B and D. I need to be able to create these workspaces relatively quickly, without starting completely over each time, and in such a way that the environment does not vary across the workspaces, except of course for the fact that the branch/tags are different.</p> <p>So: What do I have to do in Eclipse to accomplish my goals here? Thanks in advance...</p> <p>Mark</p>
1,858,359
0
Should I put my output files in source control? <p>I've been asked to put every single file in my project under source control, including the database file (not the schema, the complete file).</p> <p>This seems wrong to me, but I can't explain it. Every resource I find about source control tells me not to put generated output files in a source control system. And I understand, it's not "source" files. </p> <p>However, I've been presented with the following reasoning:</p> <ul> <li>Who cares? We have plenty of bandwidth.</li> <li>I don't mind having to resolve a conflict each time I get the latest revision, it's just one click</li> <li>It's so much more convenient than having to think about good ignore files <ul> <li>Also, if I have to add an external DLL file in the bin folder now, I can't forget to put it in source control, as the bin folder is not being ignored now.</li> </ul></li> </ul> <p>The simple solution for the last bullet-point is to add the file in a libraries folder and reference it from the project.</p> <p>Please explain if and why putting generated output files under source control is wrong.</p>
16,954,405
0
<p>SELECT c1.cat_id as childID, c1.cat_name ChildName, c2.cat_name as ParentName from category c1 LEFT OUTER JOIN category c2 ON c1.parent = c2.cat_id</p>
30,327,851
0
<p>You should use <code>$("#&lt;%=UploadButton.ClientID%&gt;")</code> instead of <code>$('UploadButton')</code> because <code>asp:Button</code> elements generates not in element with just id <code>UploadButton</code></p> <pre><code>function ConfirmSendData() { var r = confirm("Êtes vous bien: " + document.getElementById("&lt;%=DDL_LaveurLA.ClientID%&gt;").options[document.getElementById("&lt;%=DDL_LaveurLA.ClientID%&gt;").selectedIndex].text + " sinon veuillez changer dans le champ spécifié 'Laveur'"); if (r == true) { var clickButton = document.getElementById("&lt;%= UploadButton.ClientID %&gt;"); clickButton.click(); // alternative variant for jquery // $("#&lt;%=UploadButton.ClientID%&gt;").click(); } } </code></pre> <p>also another thing that function <code>ConfirmSendData</code> needs to <code>return false</code> to prevent the submitting data by first button</p>
10,071,288
0
<p>when there is a relationship between two entities and you expect to use it, use JPA relationship annotations. One of the main advantages exactly is to not have to manually make extra queries when there is a relationship between entities.</p>
5,006,094
0
Why does WebImage.Resize strip out PNG transparency <p>Using <a href="http://msdn.microsoft.com/en-us/library/system.web.helpers.webimage(v=vs.99).aspx" rel="nofollow noreferrer">WebImage</a> from the MVC3/WebMatrix release. Loading the following image from a file path:</p> <p><img src="https://i.stack.imgur.com/CUJHZ.png" alt="Sample Image"> - or - <img src="https://i.stack.imgur.com/7iORI.png" alt="enter image description here"></p> <p>Running the following code against it:</p> <pre><code>return new WebImage(path) .Resize(120, 265) .GetBytes("Png"); </code></pre> <p>Results in an image with the transparency stripped out and black used in place:</p> <p><img src="https://i.stack.imgur.com/a1S4e.png" alt="Blacked out transparency"></p> <p>The same happens with RotateRight(), RotateLeft() and FlipHorizantal() However if I don't call the .Resize() method:</p> <pre><code>return new WebImage(path) .GetBytes("Png"); </code></pre> <p>The image is returned without an issue.</p>
34,725,412
0
Unable to connect to remote Oracle database from a machine that does not have oracle client <p>I have a dot net executable (build in Visual Studio 2008) that attempts to connect to remote oracle database from a machine that does not have oracle client installed. The error I am getting is</p> <p>"ORA-12154 TNS Could not resolve the connect identifier specified"</p> <p>from what I have read so far I needed to add reference Oracle.DataAccess.dll. Oracle.DataAccess was not available for adding under my VS 2008, so I went ahead and got a copy of MSI package (ODTwithODAC1020221.exe from Oracle site) to add the suggested DLL file (I am not sure if there is compatibility issue between my version of VS/.NET 3.5 SP1 and the download). After I have successfully added the reference, i get the above error.</p> <p>I can successfully do a TNSPING on a local machine that has oracle client. I have also validated database descriptions from TNSNAMES.ORA file.</p> <p>Here is the code I am using to connect to oracle:</p> <pre><code>Imports System.IO Imports System.Xml Imports System.Net Imports System.Xml.Schema Imports System.Text Imports System.Data.Common.DataAdapter Imports System.Data.Common.DbDataAdapter Imports System.Net.Mail Imports System.Threading.Thread Imports System.Data.OleDb Imports System.Data.SqlClient Imports System.ServiceProcess Imports System.Management Imports System Imports Oracle.DataAccess Imports Oracle.DataAccess.Client Module Module1 Public Sub Main() Dim sql As String Dim sql2 As String Dim DATABASENAME1 As String = "Data Source=(DESCRIPTION =" _ + " (ADDRESS = (PROTOCOL = TCP)(HOST=Server.Host.com)(PORT=1540))" _ + ")" _ + "(CONNECT_DATA = " _ + "(SID=DATABASENAME1)));" _ + "User Id=user;Password=password1;" Dim conn1 As New OracleConnection() conn1.ConnectionString = DATABASENAME1 '%%%%% Connect to database Try conn1.Open() Console.WriteLine("Connection to Oracle database established!") MsgBox("Connection to Oracle database established!") Console.WriteLine(" ") Catch ex As Exception MsgBox("Not Connected" &amp; ex.Message) Console.WriteLine(ex.Message) End End Try END SUB END MODULE </code></pre>
3,966,904
1
How to determine when input is alphabetic? <p>I been trying to solve this one for a while and can't seem to make it work right.. here is my current work </p> <pre><code>while True: guess = int(raw_input('What is your number?')) if 100 &lt; guess or guess &lt; 1: print '\ninvalid' else: .....continue on </code></pre> <p>Right now I have made it so when a user input a number higher than 100 or lower than 1, it prints out "invalid". BUT what if i want to make it so when a user input a string that is not a number(alphabetic, punctuation, etc.) it also returns this "invalid" message?</p> <p>I have thought about using if not ...isdigit(), but it won't work since I get the guess as an integer in order for the above range to work. Try/except is another option I thought about, but still haven't figured out how to implement it in correctly.</p>
39,950,042
1
Get unique entries in list of lists by an item <p>This seems like a fairly straightforward problem but I can't seem to find an efficient way to do it. I have a list of lists like this:</p> <pre><code>list = [['abc','def','123'],['abc','xyz','123'],['ghi','jqk','456']] </code></pre> <p>I want to get a list of unique entries by the third item in each child list (the 'id'), i.e. the end result should be</p> <pre><code>unique_entries = [['abc','def','123'],['ghi','jqk','456']] </code></pre> <p>What is the most efficient way to do this? I know I can use set to get the unique ids, and then loop through the whole list again. However, there are more than 2 million entries in my list and this is taking too long. Appreciate any pointers you can offer! Thanks. </p>
6,703,663
0
Lattice Reduction <p>I have two matrices A and B with same number of rows. Consider a Lattice generated by the rows of B. I want to reduce B and during the reduction change A accordingly. That is if i-th row and j-th row of B interchanges, need to sweep i-th row and j-th row of A also, similarly other elementary row operations. How can I do these?</p> <p>Also is there very simple C or C++-implementation of the <a href="http://mathworld.wolfram.com/LLLAlgorithm.html" rel="nofollow">LLL algorithm</a>?</p>
22,414,635
0
<p>You should use the <a href="https://api.jquery.com/contains-selector/" rel="nofollow"><code>:contains()</code> filter</a> instead of <a href="https://api.jquery.com/jQuery.contains/" rel="nofollow"><code>.contains()</code> method</a>. Also to add a link <em>after</em> the link, use <code>.after()</code> instead of <code>.append()</code> (which appends to innerHTML).</p> <pre><code>$(".links a:contains('append after me')").after("&lt;a href=''&gt;new link&lt;/a&gt;"); </code></pre>
21,937,975
0
Chartboost test scene not working in unity <p>I made an app for android with unity3d, and want to include chartboost into it. I imported the plugin for unity, and added an app as well as a campaign on chartboost. I also made sure that the signature and app name were put into the strings.xml file. When I tried running the demo scene, the buttons appeared, but when I tried to click them, nothing happens, not even a message in the console. What am I doing wrong?</p> <p>Thanks for the help in advance!</p> <p>Lagidigu</p>
20,354,133
0
<p>"These pattern match variables are scalars and, as such, will only hold a single value. That value is whatever the capturing parentheses matched <strong>last</strong>."</p> <p><a href="http://blogs.perl.org/users/sirhc/2012/05/repeated-capturing-and-parsing.html" rel="nofollow">http://blogs.perl.org/users/sirhc/2012/05/repeated-capturing-and-parsing.html</a></p> <p>In you example, <code>$1</code> matches <code>1.2.3</code>. As the pattern repeats, <code>$2</code> would be set to <code>.2</code> until the final match of <code>.3</code></p>
36,127,931
0
<p><a href="http://www.eclipse.org/mat/" rel="nofollow" title="Eclipse Memory Analyzer Home">Eclipse Memory Analyzer</a> is an excellent tool for analyzing the core*.dmp (and portable heap dumps, i.e. .phd files, too). To read those Websphere Dumps an additional plugin called <a href="http://www.ibm.com/developerworks/java/jdk/tools/dtfj.html" rel="nofollow" title="IBM Diagnostic Tool Framework for Java">IBM Diagnostic Tool Framework for Java</a> needs to be installed (<a href="http://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/runtimes/tools/dtfj/" rel="nofollow" title="Plugin Update Site">Update Site</a>).</p> <p>Before even trying to open big dumps remember to increase the tool's heap size by modifying the <code>MemoryAnalyzer.ini</code> and adding/modifying the line</p> <p><code>-Xmx4096m</code></p> <p>Adjust this number to your needs.</p>
27,405,219
0
<p>Please check the name of the file and the linux server is case sensitive.</p> <p>SelfServStyle.css Vs selfserverstyles.css</p> <pre><code>&lt;link href="http://www.insightdirect.com/SelfServStyle.css" rel="stylesheet" type="text/css"&gt; &lt;link href="http://www.insightdirect.com/selfServstyle.css" rel="stylesheet" type="text/css"&gt; </code></pre> <p>Carefully look the format of the file names. This two file are different in server.</p>
12,715,291
0
<p>Add your reload data call to yet another NSOperation, which has as its dependencies (see <code>addDependency:</code>) the other five operations. It will then not be executed until the others are complete. </p> <p>Be sure to wrap your UI calls in a GCD dispatch to the main thread. </p> <p>From the NSOperation reference:</p> <blockquote> <p>Dependencies are a convenient way to execute operations in a specific order. You can add and remove dependencies for an operation using the addDependency: and removeDependency: methods. By default, an operation object that has dependencies is not considered ready until all of its dependent operation objects have finished executing. Once the last dependent operation finishes, however, the operation object becomes ready and able to execute.</p> </blockquote>
13,006,402
0
Gridview: Many controls in same row cell <p>I have many controls in same gridview cell. I am using the following code. But i want them to be displayed vertically instead of horizontally, because with the following code it assigns them in the same line. Any help?</p> <pre><code>RadioButton rd1 = new RadioButton(); rd1.Text = "Test1"; RadioButton rd2 = new RadioButton(); rd2.Text = "Test2"; grdRSM.Rows[0].Cells[2].Controls.Add(rd1); grdRSM.Rows[0].Cells[2].Controls.Add(rd2); </code></pre>
16,887,940
0
<p>Replace all the <code>=</code> with <code>==</code> and you should be fine (because = is used for assignment, while == is used to test for equality, which seems to be what you want to do)</p>
25,881,949
0
<p>Try to run </p> <pre><code>chkconfig autofs on </code></pre> <p>that will enable autofs service to start on boot.</p>
16,625,850
0
Printing a value makes the program work? <pre><code>#include &lt;iostream&gt; #include &lt;cstdio&gt; using namespace std; bool numar(unsigned long long n) { return (n &gt; 99) &amp;&amp; ((n % 100) == 25); } int main() { freopen("numere.in", "r", stdin); freopen("numere.out", "w", stdout); int cnt = 0; unsigned long long n, a, Nblabla, N; while (scanf("%d", &amp;n) == 1) { if (numar(n)) { a = (n - 25) / 100; cout &lt;&lt; a; // This son of a *****. for (N = 1; true; N++) { Nblabla = N * (N + 1); if (Nblabla &gt; a) break; else if (Nblabla == a) { cnt++; } } } } printf("%d", cnt); return 0; } </code></pre> <p>Simply, if I comment that line (<code>cout &lt;&lt; a;</code>), the program stops working. If I leave it there, it works.<br> I'm using Code::Blocks, GNU GCC.</p> <p>This just checks if a number is the square of a number that ends with the digit <code>5</code>. (Base 10) (I am not allowed to use square roots) </p> <p>Before asking, no, this isn't homework. This is my submission to a subject of an online contest. </p> <p>Can anyone tell me why is this happening? </p>
21,685,219
0
Trying to setOnClickListener for TextView not in main layout <p>I have a TextView that I am turning into a button. The TextView actually lives on a secondary layout.</p> <pre><code> protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.history); </code></pre> <p>this is the main layout here "R.layout.history"</p> <p>That loads a bunch of results in a ListAdapter and each result is displayed using R.layout.card_background</p> <p>I am trying to initialize and set the setOnClickListener for a TextView located on R.Layout.card_background but I am getting a nullPointerException.</p> <pre><code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.history); Typeface tf = Typeface.createFromAsset(getAssets(),"Roboto-Light.ttf"); ListView listContent = (ListView) findViewById(android.R.id.list); TextView history = (TextView) findViewById(R.id.history); history.setTypeface(tf); Cursor cursor = db.getAllLogs(); Log.d("history.java", "finished Cursor cursor = db.getAllLogs();"); String[] from = {"_id", "dd", "gg", "ppg", "odo"}; int[] to = {deleteVal, R.id.cardDate, R.id.cardG, R.id.cardP, R.id.cardM}; ListAdapter adapter = new SimpleCursorAdapter(this, R.layout.card_background, cursor, from, to); listContent.setAdapter(adapter); TextView cardDelete = (TextView) findViewById(R.id.cardDelete); cardDelete.setOnClickListener(new OnClickListener() { @Override public void onClick(View v){ } }); } </code></pre> <p>Any idea how I can set that and stop getting the NPE?</p> <p>Thanks</p>
6,539,696
0
<p>The Problem was the <code>git clean</code> <code>git clean</code> removes <strong>any</strong> untracked file from the current working tree.</p> <p>You could set up <code>.gitignore</code> files for the untracked files and leave the <code>-x</code> flag away. You should have a look at the <em>manpage</em> for <code>git-clean</code>. If you don't have a unix system: <a href="http://linux.die.net/man/1/git-clean" rel="nofollow">http://linux.die.net/man/1/git-clean</a></p>
7,757,424
0
GIT_WORK_TREE not only updating 1 file <p>I have set up a two bare git repository's on my server with file paths like so:</p> <p>/git/project.git/ <br> /git/project2.git/</p> <p>I then have added two branches dev and live. I then added the following post-receive hook to each project</p> <pre><code>` #!/bin/sh while read oldrev newrev refname do echo "STARTING [$oldrev $newrev $refname]" if [ "$refname" == 'refs/heads/dev' ] then GIT_WORK_TREE=/var/www/vhosts/devwebsite.com/httpdocs/ git checkout -f elif [ "$refname" == 'refs/heads/live' ] then GIT_WORK_TREE=/var/www/vhosts/livewebsite.com/httpdocs/ git checkout -f fi done` </code></pre> <p>This works on 1 project but not the other. On the second project it only seems to work with my first file I pushed which happens to be a .gitignore file.</p> <p>So in short this file is the only file that will be updated when I push.</p> <p>Thanks in a advance for any help you can give.</p>
36,640,321
0
Will Postgres' DISTINCT function always return null as the first element? <p>I'm selecting distinct values from tables thru Java's JDBC connector and it seems that NULL value (if there's any) is always the first row in the ResultSet.</p> <p>I need to remove this NULL from the List where I load this ResultSet. The logic looks only at the first element and if it's null then ignores it.</p> <p>I'm not using any ORDER BY in the query, can I still trust that logic? I can't find any reference in Postgres' documentation about this.</p>
2,702,589
0
<h1>Python (86 chars)</h1> <pre><code>r=input() l=len(str(r)) while 1: x=str(r*r) y=(len(x)-l)/2 r=int(x[y:y+l]) print r </code></pre> <p>Produces infinite sequence on stdout. Note that backtick trick won't work at least on older versions with <code>long</code> type because of the ending <code>L</code> in representation. Python 3 <code>print</code> as function would add 1 more char for closing paren.</p>
34,541,193
0
How to check either email address exist or not using android? <p><strong>I want to register email in application from the form. I want to check that either email address exist or not. Please help me to solve this problem. Thanks.</strong></p>
22,665,940
0
<p>Take a look at this other answer. It uses the same approach that you do.</p> <p><a href="http://stackoverflow.com/questions/22663599/creating-constant-string-for-a-postgres-entire-database">Creating constant string for a Postgres entire database</a></p>
12,328,374
0
<p>PHP is run on a server, Your browser is a client. Once the server sends all the info to the client, nothing can be done on the server until another request is made.</p> <p>To make another request without refreshing the page you are going to have to look into ajax. Look into jQuery as it makes ajax requests easy</p>
34,420,129
0
Iphone Testing App on Xcode <p>Is it possible to test your iPhone app on Xcode, not on the simulator, but on your actual phone before releasing it on the app store. </p>
30,940,092
0
<p>Incidentally, if less typing (well 20 characters) and better performance is your thing then consider the following:</p> <pre><code>SELECT u.name , SUM(t.minutesSpent) Total FROM users u LEFT JOIN times t ON u.id = t.user_id AND t.date BETWEEN '2015-06-03 00:00:00' AND '2015-06-03 23:59:59' GROUP BY u.name; </code></pre>
15,310,343
0
<p>That all sounds fine - though I'd opt for something more granular: something that would allow access to other people's records on an access-control-list basis, but that's more complicated.</p> <p>The only thing I'd change in what you've written is the "redirection" to an access-denied page. <strong>Never perform redirections to error pages</strong> - instead return the error message in the original response. You can do this in ASP.NET WebForms by using <code>Server.Transfer</code>, or by clearing the response buffer (if necessary) and setting the page content to an ASCX with the right message. Don't forget to set the HTTP status to 403.</p>
10,670,722
0
<p>I tend to launch Eclipse and STS from the command line. I create a bunch of shell scripts, one for each variant of Eclipse/STS that I run. This ensures that every launch has precisely the arguments that I need.</p> <p>For example, I have a bunch of scripts like this:</p> <pre><code>[21:09] ~/Eclipse $ more eclipse_42.sh Installations/Eclipse4.2.M6/Eclipse -data \ "/users/Andrew/Eclipse/Workspaces/workspace_42" \ -vmargs -Xmx1024M -XX:PermSize=64M -XX:MaxPermSize=256M </code></pre> <p>I like running from a terminal so that you can see what gets sent to sysout. And this could also be launched from a Finder window. </p> <p>I run on Mac, but you could do something similar on Linux or Windows.</p>
36,340,806
0
<p>Here are a few alternatives to passing a reference to the function:</p> <ul> <li><p>Have the child component broadcast a public event using the <code>EventAggregator</code> singleton instance and have the parent component react to the event</p></li> <li><p>Have the child component broadcast a private event using a private <code>EventAggregator</code> instance and have the parent component react to the event</p></li> <li><p>Have the child component broadcast a DOM event and bind it to the parent with <code>delete.call</code> like this <code>&lt;project-item repeat.for="project of projects" project.bind="project" delete.call="deleteProject($even t)"&gt;&lt;/project-item&gt;</code></p></li> </ul> <p>My personal preference is the third option. It feels more like "Web Components" to me.</p>
4,179,845
0
<p>Add a "-" before any command in a Makefile tells make to not quit if the command returns a non-zero status. Basically it's a "I don't care if it fails".</p>
33,695,919
0
error: expected expression before ‘if’ <p>Here is my code, I don't know where I'm wrong and what is "expression"?</p> <pre><code>#define m(smth) (if(sizeof(smth) == sizeof(int)) {printf("%d", (int) smth);} else{puts((char*)smth);}) int main(void) { m("smth"); } </code></pre> <p>here is output:</p> <pre><code>/home/roroco/Dropbox/rbs/ro_sites/c/ex/ex2.c: In function ‘main’: /home/roroco/Dropbox/rbs/ro_sites/c/ex/ex2.c:18:18: error: expected expression before ‘if’ #define m(smth) (if(sizeof(smth) == sizeof(int)) {printf("%d", (int) smth);} else{puts((char*)smth);}) ^ /home/roroco/Dropbox/rbs/ro_sites/c/ex/ex2.c:21:5: note: in expansion of macro ‘m’ m("smth"); ^ make[3]: *** [ex/CMakeFiles/ex2.dir/ex2.c.o] Error 1 make[2]: *** [ex/CMakeFiles/ex2.dir/all] Error 2 make[1]: *** [ex/CMakeFiles/ex2.dir/rule] Error 2 make: *** [ex2] Error 2 </code></pre>
10,502,016
0
<p>As hakre said in the comments and as it's stated <a href="http://docs.kohanaphp.com/general/libraries" rel="nofollow" title="Libraries">here</a> "Library class names and file names begin with a capitalized letter"</p> <p>I changed the file and class to start with C and that fixed the problem.</p> <p>When I moved the project to Ubuntu I changed every file name to lower case, in the case of Libraries that was wrong.</p> <p>Thanks to all and I hope this helps anyone in the future.</p>
6,959,236
0
<p>Try <code>man dbopen</code> for the C level API which describes these flags, as <code>DB_file</code> is really a very thin wrapper around that. </p> <p>The meaning of this flag differs according to which method you use it on, when used with <code>put</code> this means that a value is replaced (rather than added before or after) and needs to be used after an existing search, i.e., after using the <code>seq</code> function at the C level. </p>
11,343,305
0
<p>so can you try analyzing with solr.KeywordTokenizerFactory ?</p>
29,555,343
0
<pre><code>#ifndef Debug #define Debug 1 #endif #if Debug # define DebugLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); #else # define DebugLog(...) #endif </code></pre> <p>Set Debug to 1 for enabling the log and 0 for disabling it.</p>
38,045,693
0
Adding a border around the first row in a table (and other styling)? <p>I'm trying to style the first row of a table, which is supposed to serve as a heading-row. Unfortunately, I can't seem to get a visible border around this row.</p> <p>I went about this by trying to use the first:child pseudo class. I managed to successfully get a background gradient added to this row. The code for that looks like...</p> <pre><code>tr:first-child { background-color: rgb(116, 195, 80); -webkit-background:linear-gradient(rgb(116, 195, 80), rgb(160, 219, 132)); </code></pre> <p>So now I'm trying to add a border around this row... And none of my code seems to really work. What's making it even more obnoxious for me is the fact that I have plenty of working border code in other parts of this css file... And none of it seems to give a visible border for this row. I actually don't want the border to span for the entire row. I am okay with the border simply going around each column/element within the row.</p> <p>Right now my code is....</p> <pre><code>border-style: groove; border-color: blue; border-height: 5px; border-radius: 4px; </code></pre> <p>There must be something I'm not understanding about table styling... I am not allowed to alter the original html5 file. Here is an example table I'm trying to imitate.</p> <p><a href="https://i.stack.imgur.com/NNzA4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NNzA4.png" alt="Example table heading"></a></p>
20,635,706
0
I have a minor issue with my dropdown menu when switching pages <p>I have a small issue with my dropdown menu when switching to another page. When I press my menu label button, the navigation bar slides down and when I then proceed to another page the dropdown menu acts if it was open but it is not so when I press the menu label button again the navigation bar slides up instead of down and after that it works normally. </p> <p><strong>What do I do to make the slide bar return to normal state when I switch pages?</strong> I hope you understand what I mean, otherwise I will try to clarify</p> <p><strong>HTML</strong></p> <pre><code>&lt;nav id="navBar"&gt; &lt;ul id="mainNav"&gt; &lt;li class="hem"&gt;&lt;a href="index.html"&gt;Hem&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="kontakt.html"&gt;Kontakt&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="om.html"&gt;Om&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/nav&gt; </code></pre> <p><strong>CSS</strong></p> <pre><code>#navBar { display:none; position:relative; } #navBar.active{ display:block; height:auto; } #mainNav { background:#202020; } #mainNav li { padding:6px 0; } #mainNav a { color:white; font-weight:bold; } #mainNav li:hover { background-color:#f3ba32; } </code></pre> <p><strong>JQUERY</strong></p> <pre><code>$("#menulabel").click(function() { $("#navBar").toggleClass("active").slideToggle(300); }); </code></pre>
21,010,024
0
Hashed/Sharded ActionBlocks <p>I have a constant flow of certain items that I need to process in parallel so I'm using <code>TPL Dataflow</code>. The catch is that the items that share the same key (similar to a Dictionary) should be processed in a FIFO order and not be parallel to each other (they can be parallel to other items with different values).</p> <p>The work being done is very CPU bound with minimal asynchronous locks so my solution was to create an array of <code>ActionBlock&lt;T&gt;</code>s the size of <code>Environment.ProcessorCount</code> with no parallelism and post to them according to the key's <code>GetHashCode</code> value.</p> <p>Creation:</p> <pre><code>_actionBlocks = new ActionBlock&lt;Item&gt;[Environment.ProcessorCount]; for (int i = 0; i &lt; _actionBlocks.Length; i++) { _actionBlocks[i] = new ActionBlock&lt;Item&gt;(_ =&gt; ProcessItemAsync(_)); } </code></pre> <p>Usage:</p> <pre><code>bool ProcessItem(Key key, Item item) { var actionBlock = _actionBlocks[(uint)key.GetHashCode() % _actionBlocks.Length]; return actionBlock.Post(item); } </code></pre> <p>So, my question is, is this the best solution to my problem? Am I hurting performance/scalability? Am I missing something?</p>
34,154,699
0
<p><em>I will try to put it simple, assuming you are familiar with SSIS and Script Components</em></p> <p>Main problem is that your column contains leading 0's that makes it harder to parse the value to float.</p> <p><strong>Solution 1</strong></p> <p>You will first need to get rid of the leading 0's using a Derived Column component with fitting expression (could be complex)</p> <p>Then pass that column through a data conversion component and set the data type to float</p> <p><strong>Solution 2</strong></p> <p>Pass original column through a script transform component, remove leading 0's and parse it to a new float column in the ProcessInputRow method using .NET</p> <p><strong>C# Example:</strong></p> <pre><code>Row.new_column = float.Parse(Row.Quantite.TrimStart('0')); </code></pre>
17,296,813
0
<p>in the event that you want to 're-use' an existing <code>JdbcCursorItemReader</code> (or one of the other Spring Batch Jdbc*ItemReaders), you can switch the SQL dynamically by leveraging the step scope. Below is an example of a configuration that switches the SQL based on the <code>sqlKey</code> property from the <code>JobParameters</code>. the source of the statements is a simple map.</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:batch="http://www.springframework.org/schema/batch" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd"&gt; &lt;batch:job id="switchSQL"&gt; &lt;batch:step id="switchSQL.step1"&gt; &lt;batch:tasklet&gt; &lt;batch:chunk reader="sqlItemReader" writer="outItemWriter" commit-interval="10"/&gt; &lt;/batch:tasklet&gt; &lt;/batch:step&gt; &lt;/batch:job&gt; &lt;bean id="sqlItemReader" class="org.springframework.batch.item.database.JdbcCursorItemReader" scope="step"&gt; &lt;property name="dataSource" ref="dataSource"/&gt; &lt;property name="sql" value="#{@sqlStatements[jobParameters['sqlKey']]}"/&gt; &lt;property name="rowMapper"&gt; &lt;bean class="de.incompleteco.spring.batch.data.ColumnRowMapper"/&gt; &lt;/property&gt; &lt;/bean&gt; &lt;util:map id="sqlStatements"&gt; &lt;entry key="sql1" value="select * from table_one"/&gt; &lt;entry key="sql2" value="select * from table_two"/&gt; &lt;/util:map&gt; &lt;bean id="outItemWriter" class="org.springframework.batch.item.adapter.ItemWriterAdapter"&gt; &lt;property name="targetObject" ref="outWriter"/&gt; &lt;property name="targetMethod" value="write"/&gt; &lt;/bean&gt; &lt;bean id="outWriter" class="de.incompleteco.spring.batch.item.SystemOutItemWriter"/&gt; &lt;/beans&gt; </code></pre> <p>here are the supporting classes;</p> <p>(a simple itemwriter)</p> <pre><code>package de.incompleteco.spring.batch.item; public class SystemOutItemWriter { public void write(Object object) { System.out.println(object); } } </code></pre> <p>(and a simple rowmapper)</p> <pre><code>package de.incompleteco.spring.batch.data; import java.sql.ResultSet; import java.sql.SQLException; import org.springframework.jdbc.core.RowMapper; public class ColumnRowMapper implements RowMapper&lt;String&gt; { public String mapRow(ResultSet rs, int rowNum) throws SQLException { return rs.getString(1); } } </code></pre> <p>and here's the remaining config</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"&gt; &lt;bean id="jobRepository" class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean"/&gt; &lt;bean id="jobExplorer" class="org.springframework.batch.core.explore.support.MapJobExplorerFactoryBean"&gt; &lt;property name="repositoryFactory" ref="&amp;amp;jobRepository"/&gt; &lt;/bean&gt; &lt;bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher"&gt; &lt;property name="jobRepository" ref="jobRepository"/&gt; &lt;/bean&gt; &lt;bean id="transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager"&gt; &lt;/bean&gt; &lt;bean class="org.springframework.batch.core.scope.StepScope"/&gt; &lt;/beans&gt; </code></pre> <p>and</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd"&gt; &lt;jdbc:embedded-database id="dataSource" type="H2"&gt; &lt;jdbc:script location="classpath:/META-INF/sql/schema-h2.sql"/&gt; &lt;jdbc:script location="classpath:/META-INF/sql/insert-h2.sql"/&gt; &lt;/jdbc:embedded-database&gt; &lt;bean id="dataSourceTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt; &lt;property name="dataSource" ref="dataSource"/&gt; &lt;/bean&gt; &lt;/beans&gt; </code></pre> <p>and the sql stuff</p> <pre><code>create table table_one ( column_a varchar(50) ); create table table_two ( column_a varchar(50) ); --table one insert into table_one (column_a) values ('hello'); insert into table_one (column_a) values ('world'); --table two insert into table_two (column_a) values ('hey'); </code></pre> <p>now finally a unit test</p> <pre><code>package de.incompleteco.spring; import static org.junit.Assert.assertFalse; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.core.Job; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.JobParametersBuilder; import org.springframework.batch.core.explore.JobExplorer; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration({"classpath:/META-INF/spring/*-context.xml"}) public class SwitchSQLIntegrationTest { @Autowired private Job job; @Autowired private JobLauncher jobLauncher; @Autowired private JobExplorer jobExplorer; @Test public void test() throws Exception { //setup the parameters JobParameters parameters = new JobParametersBuilder().addLong("runtime",System.currentTimeMillis()) .addString("sqlKey", "sql1").toJobParameters(); //run JobExecution execution = jobLauncher.run(job,parameters); //test while (jobExplorer.getJobExecution(execution.getId()).isRunning()) { Thread.sleep(100); }//end while //load execution = jobExplorer.getJobExecution(execution.getId()); //test assertFalse(execution.getStatus().isUnsuccessful()); //run it again parameters = new JobParametersBuilder().addLong("runtime",System.currentTimeMillis()) .addString("sqlKey", "sql2").toJobParameters(); //run execution = jobLauncher.run(job,parameters); //test while (jobExplorer.getJobExecution(execution.getId()).isRunning()) { Thread.sleep(100); }//end while //load execution = jobExplorer.getJobExecution(execution.getId()); //test assertFalse(execution.getStatus().isUnsuccessful()); } } </code></pre>
10,184,630
0
What would setting a getter do? <p>First, some context: while answering questions on SO, I came across a post wherein the author had been trying to set a getter with syntax similar to <code>[self.propertyGetter:newValue];</code>. For some reason, this compiles, and I thought to myself, "this would constitute a call to nil, wouldn't it?". So, my question is, why in the heck does this 'work'? (to be perfectly clear, the poster was complaining that this had no effect, so by 'work', I mean compile).</p>
29,676,210
0
<p>As it was <a href="http://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.27.4" rel="nofollow">already pointed out</a>, the actual behavior is not specified by the JLS, a future version is allowed to derive from the current implementation as long as the JLS remains fullfilled.</p> <p><strong>Here is what happens in a current version of HotSpot:</strong></p> <p>Any lambda expression is bound via an <em>invokedynamic</em> call site. This call site requests a bootstrap method to bind a factory for an instance that implements the functional interface of the lambda expression. As arguments, any variables that are required to execute the lambda expression are handed to the factory. The body of the lambda expression is instead copied into a method inside of the class. </p> <p>For your example, the desuggared version would look like the following code snipped with the <em>invokedynamic</em> instruction in angle brackets:</p> <pre><code>class Foo { public static Object o = new Object(); public static Callable x1() { Object x = o; return Bootstrap.&lt;makeCallable&gt;(x); } private static Object lambda$x1(Object x) { return x; } public static Callable x2() { return Bootstrap.&lt;makeCallable&gt;(); } private static void lambda$x2() { return Foo.o; } } </code></pre> <p>The boostrap method (which is actually located in <code>java.lang.invoke.LambdaMetafactory</code>) is then asked to bind the call site on its first invocation. For lambda expressions, this binding will never change, the bootstrap method is therefore only called once. In order to being able to bind a class that implements the functional interface, the bootstrap method must first create a class at runtime which look like the following for example:</p> <pre><code>class Lambda$x1 implements Callable { private static Callable make(Object x) { return new Lambda$x1(x); } private final Object x; // constructor omitted @Override public Object call() { return x; } } class Lambda$x2 implements Callable { @Override public Object call() { return Foo.o; } } </code></pre> <p>After creating these classes, the <em>invokedynamic</em> instruction is bound to invoke the factory method that is defined by the first class to the call site. For the second class, no factory is created as the class is fully stateless. Therefore, the bootstrap method creates a singleton instance of the class and binds the instance directly to the call site (using a constant <code>MethodHandle</code>).</p> <p>In order to invoke static methods from another class, an anonymous class loader is used for loading the lambda classes. If you want to know more, I recently <a href="http://mydailyjava.blogspot.no/2015/03/dismantling-invokedynamic.html" rel="nofollow">summarized my findings on lambda expressions</a>. </p> <p>But again, <strong>always code against the spec, not the implementation</strong>. This can change!</p>
13,355,381
0
<p><strong>Just this</strong>:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:x="http://www.w3.org/1999/xhtml" exclude-result-prefixes="x"&gt; &lt;xsl:output omit-xml-declaration="yes" indent="yes"/&gt; &lt;xsl:strip-space elements="*"/&gt; &lt;xsl:template match="/*"&gt; &lt;document&gt; &lt;xsl:apply-templates/&gt; &lt;/document&gt; &lt;/xsl:template&gt; &lt;xsl:template match="x:div"&gt; &lt;section&gt;&lt;xsl:apply-templates/&gt;&lt;/section&gt; &lt;/xsl:template&gt; &lt;xsl:template match="x:p"&gt; &lt;paragraph&gt;&lt;xsl:apply-templates/&gt;&lt;/paragraph&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>When this transformation is applied on the provided XML document:</strong></p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;title/&gt; &lt;meta/&gt; &lt;/head&gt; &lt;body link="#000000" bgcolor="#FFFFFF" leftmargin="0"&gt; &lt;div&gt; &lt;p&gt;Here is a paragraph&lt;/p&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>the wanted, correct result is produced</strong>:</p> <pre><code>&lt;document&gt; &lt;section&gt; &lt;paragraph&gt;Here is a paragraph&lt;/paragraph&gt; &lt;/section&gt; &lt;/document&gt; </code></pre>
22,879,377
0
<pre><code>#include &lt;stdio.h&gt; #include &lt;time.h&gt; #include &lt;stdlib.h&gt; #define ROW 3 #define COL 5 int main(){ int array[ROW][COL]; int practice_array; int i, row, col, max, min, sum, avg; srand(time(NULL)); for ( row = 0; row &lt; ROW; row = row + 1){ for ( col = 0; col &lt; COL; col = col +1){ array[row][col] = rand()%(10000+1); practice_array = array[row][col]; sum += practice_array; printf("The value in row %d col %d is %d\n",row, col,practice_array); } } avg = sum / (ROW*COL);//unused int *pv = &amp;array[0][0]; max = min = 0; for (i = 1; i &lt; ROW*COL; ++i){ if (pv[i] &gt; pv[max]) max =i; if (pv[i] &lt; pv[min]) min = i; } printf("The max value is %d in row %d, col %d\n", pv[max], max/COL, max%COL); printf("The min value is %d in row %d, col %d\n", pv[min], min/COL, min%COL); return 0; } </code></pre>
36,169,673
0
Select in select query cakephp <p>I have 2 table </p> <pre> 1. feeds => id,name 2. feed_locations => id, feed_id, latitude,longitude,location_name </pre> <p>This is my cakephp code</p> <pre><code> $radious = '10'; $this->paginate = array( 'joins' => array( array('table' => 'feed_locations', 'alias' => 'FeedLocation', 'type' => 'LEFT', 'conditions' => array( 'FeedLocation.feed_id = Feed.id', ) ) ), 'limit' => 10, 'fields' => array('id','name','(3959 * acos (cos ( radians('.$lat.') ) * cos( radians( FeedLocation.latitude ) ) * cos( radians( FeedLocation.longitude ) - radians('.$lng.') ) + sin ( radians('.$lat.') ) * sin( radians( FeedLocation.latitude )))) AS `distance`'), 'recursive' => -1, 'order' => 'distance ASC', 'group' => 'Feed.id HAVING distance &lt;'.$radious ); </code> </pre> <p>It give me output query as</p> <pre><code>SELECT `Feed`.`id`, `Feed`.`name`, (3959 * acos (cos ( radians(40.7127837) ) * cos( radians( FeedLocation.latitude ) ) * cos( radians( FeedLocation.longitude ) - radians(-74.00594130000002) ) + sin ( radians(40.7127837) ) * sin( radians( FeedLocation.latitude )))) AS `distance`, (Select COUNT(id) FROM feed_locations WHERE feed_id = `Feed`.`id`) AS `location_count` FROM `feeds` AS `Feed` LEFT JOIN `feed_locations` AS `FeedLocation` ON (`FeedLocation`.`feed_id` = `Feed`.`id`) GROUP BY `Feed`.`id` HAVING distance &lt; 10 ORDER BY `distance` ASC </code></pre> <p>My query is working but issue it that :</p> <p>Like if a single feed have 10 location like 1m,2m,3m,4m,5m,10m,100m distance. and i want to find 5m distance all feed then it works but it shows me that this feed have 5m. distance from me but result should be 1m distance. <br/> I want to implement this mysql query in cakephp syntax</p> <pre><code>SELECT a.id, a.name, a.distance, a.location_count FROM (SELECT `Feed`.`id`, `Feed`.`name`, (3959 * acos (cos ( radians(40.7127837) ) * cos( radians( FeedLocation.latitude ) ) * cos( radians( FeedLocation.longitude ) - radians(-74.00594130000002) ) + sin ( radians(40.7127837) ) * sin( radians( FeedLocation.latitude )))) AS `distance`, (Select COUNT(id) FROM feed_locations WHERE feed_id = `Feed`.`id`) AS `location_count` FROM `feeds` AS `Feed` LEFT JOIN `feed_locations` AS `FeedLocation` ON (`FeedLocation`.`feed_id` = `Feed`.`id`) ORDER BY `distance` ASC) AS a GROUP BY a.id HAVING distance &lt; 10; </code></pre> <p>This query give me exact result. please let me know how can i use this query in cakephp</p>
23,153,353
0
<p>Ok after some trial and error I appear to have solved this issue now. </p> <p>I have changed the drawMatches method to swap the "roiImg" and key points with "compare" and key points.</p> <pre><code>drawMatches(compare, keypoints_scene, roiImg, keypoints_object, good_NNmatches, img_matches, Scalar::all(-1), Scalar::all(-1), vector&lt;char&gt;(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS ); </code></pre> <p>This stopped the assertion error. But due to swapping the values around when it came to retrieving the key points I also had to make some changes. trainIdx and queryIdx have also been swapped to account for the previous changes made.</p> <pre><code>obj.push_back( keypoints_object[ good_NNmatches[i].trainIdx ].pt ); scene.push_back( keypoints_scene[ good_NNmatches[i].queryIdx ].pt ); </code></pre>
8,645,438
0
<p>below is a slice of my routine and it works fine : </p> <pre><code>var data = 'post_type=' + post_type.val() + '&amp;page_id=' + page_id.val() + '&amp;home_page=' + home_page.attr('checked') + '&amp;archive_page=' + archive_page.attr('checked') + '&amp;search_page=' + search_page.attr('checked'); //start the ajax $.ajax({ //this is the php file that processes the data and send mail url: "?service=set_data", //GET method is used type: "GET", //pass the data data: data, //Do not cache the page cache: true, //success success: function (html) { $(".no-items").hide("slow"); $("#list_table").append(html).hide().slideDown('slow'); } }); </code></pre>
29,993,697
0
Leaflet map in ionic/angular map displays grey tiles <p>I'm working on a mapping app using ionic and leaflet. Note that I am not using the leaflet angular directive, I am using straight JS for the leaflet map (I know, I know...).</p> <p>The initial state in my app loads the leaflet map just fine. If I switch to another state and back to the map everything is also fine. However, if I launch the app, switch to a different state and open a modal window in that state, then return to the original state, the map is broken and displays a number of grey tiles. The map will not update until the browser window resizes or the orientation of the mobile device is changed.</p> <p>Here's a demo on Plunker: <a href="http://plnkr.co/edit/w67K2b?p=preview" rel="nofollow">http://plnkr.co/edit/w67K2b?p=preview</a>. To reproduce:</p> <ol> <li>Click the button at the right side of the navbar which will take you to a different state.</li> <li>Click the 'Back to map' button to go back to the original state. The map looks just fine.</li> <li>Click the button in the navbar again.</li> <li>Click the 'Open modal' button and then close the modal.</li> <li>Click the 'Back to map' button and you will see that the map is now broken.</li> </ol> <p>I've seen other people report issues with grey tiles, which typically can be resolved with a call to:</p> <pre><code>map.invalidateSize() </code></pre> <p>Unfortunately this does not resolve my issue. I'm pretty much a newb, but I think the problem is that when the modal opens, the invalidateSize() method in the leaflet source code is run, since the map div is not visible, the 'size' gets set to x:0, y:0 which ends up breaking the map when I transition back to the original state.</p> <p>I'm not really sure where to go from here. Perhaps I can use JS to dynamically resize the div and trick leaflet into thinking a resize event has occurred? How would I do this? Any other thoughts?</p> <p>Thanks!</p>
3,678,424
0
<p>This is really poorly explained in the documentation, but actually gyp is already present if you've done an ordinary checkout of breakpad. Open a command prompt and place yourself in the root ( google-breakpad-read-only if you're going by the instructions ). Then just do: </p> <p>src\tools\gyp\gyp.bat src\client\windows\breakpad_client.gyp</p> <p>This will generate visual studio sln files for you.</p>
10,809,533
0
jTables Filtering for PHP <p>jTable (www.jtable.org) has great references to Filtering on its website, but its for ASP.NET. I require it to use for PHP, but sadly the documentation made no mention of the APIs for filtering except for the sample ASP.NET server side file. </p> <p>Anyway, jTables uses:</p> <pre><code>//Re-load records when user click 'load records' button. $('#LoadRecordsButton').click(function (e) { e.preventDefault(); $('#PeopleTableContainer').jtable('load', { Name: $('#Name').val(), Branch: $('#Branch').val() }); }); </code></pre> <p>I can see that I can pass values to the server using the Name and branch, but I don't know how to catch that on the PHP code so I can do a <code>WHERE</code> on my mysql code. </p>
9,443,294
0
<p>The plugin works the same as the <a href="http://maven.apache.org/" rel="nofollow">Maven</a> command line progam mvn.</p> <p>Assuming your project's POM and Maven settings file does not change the default repository settings Maven will download files from Maven Central</p> <p><a href="http://repo1.maven.org/maven2/" rel="nofollow">http://repo1.maven.org/maven2/</a></p> <p>So taking a dependency as follows:</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;log4j&lt;/groupId&gt; &lt;artifactId&gt;log4j&lt;/artifactId&gt; &lt;version&gt;1.2.16&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>Maven will use the following URL convention (Maven2 repository layout):</p> <pre><code>&lt;Repository URL&gt;/&lt;groupId&gt;/&lt;artifactId&gt;/&lt;version&gt;/&lt;artifactId&gt;-&lt;version&gt;.&lt;packaging&gt; </code></pre> <p>To download 2 files:</p> <ol> <li><a href="http://repo1.maven.org/maven2/log4j/log4j/1.2.16/log4j-1.2.16.pom" rel="nofollow">http://repo1.maven.org/maven2/log4j/log4j/1.2.16/log4j-1.2.16.pom</a></li> <li><a href="http://repo1.maven.org/maven2/log4j/log4j/1.2.16/log4j-1.2.16.jar" rel="nofollow">http://repo1.maven.org/maven2/log4j/log4j/1.2.16/log4j-1.2.16.jar</a></li> </ol> <p>The first is the module POM, whose <strong>packaging</strong> element will indicate the file name extension to use when downloading the second file (defaults to "jar").</p> <p>Finally Maven will recursively read the POM files associated with other dependencies listed in the POM and decide which other modules to download (Dependencies of Dependencies)</p>
6,401,336
0
Find element not directly in dom path <p>I have a dom structure that looks something like (although a lot more complex)</p> <pre><code>&lt;div&gt; &lt;div&gt; &lt;div&gt; &lt;div class="remaining"&gt;132&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div&gt; &lt;button&gt;clicky&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;div&gt; &lt;div&gt; &lt;div&gt; &lt;div class="remaining"&gt;142&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div&gt; &lt;button&gt;clicky&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;div&gt; &lt;div&gt; &lt;div&gt; &lt;div class="remaining"&gt;152&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div&gt; &lt;button&gt;clicky&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>As you can see the divs with class <code>remaining</code> arn't directly in the dom path of the relative buttons.</p> <p>How can I when the button is clicked, increment the relative <code>remaining</code> div by 1?</p>
25,910,666
0
Opening a unit test in Microsoft Test Manager <p>I have a simple unit test project on Visual Studio 2012 Professional. I want to open this unit test using Microsoft Test Manager and run it. Is this possible? How do I do this? Thank you.</p>
2,332,533
0
<p>I used "eclipse -refresh". Apparently it hangs on refresh something, the lower right corner tells you, what it's doing. For me it was refreshing the gwt runtime in a specific project, maybe trying to find an update or something. If you don't want to reimport your whole workspace, try -refresh or move this project temporarily out of the way.</p>
5,149,580
0
<p>Consider a few points:</p> <ul> <li><p>Keep your blacklist (business logic) checking in your application, and perform the comparison in your application. That's where it most belongs, and you'll likely have richer programming languages to implement that logic.</p></li> <li><p>Load your half million records into your application, and store it in a cache of some kind. On each signup, perform your check against the cache. This will avoid hitting your table on each signup. It'll be all in-memory in your application, and will be much more performant.</p></li> <li><p>Ensure <code>myEnteredUserName</code> doesn't have a blacklisted word at the beginning, end, and anywhere in between. Your question specifically had a begins-with check, but ensure that you don't miss out on <code>123_BadWord999</code>.</p></li> <li><p>Caching bring its own set of new challenges; consider reloading from the database everyday n minutes, or at a certain time or event. This will allow new blacklisted words to be loaded, and old ones to be thrown out. </p></li> </ul>
28,639,829
0
<p>I'm not sure if that's what you're looking for, but just as a quick example without having looked at the actual code but using the CSS from the Stackoverflow tag elements - you can just retrieve the value of the input on <code>change()</code>, create an element, append the value of input and an additional element to remove the created and appended element on <code>click()</code>. As the new tag is appended and not already in the DOM when the page is loaded, you can use <code>on()</code> to delegate this <code>click()</code> event from a parent element. Instead of <code>document</code> any parent element can be used to delegate the event. </p> <p>For reference: <a href="http://api.jquery.com/on/" rel="nofollow">http://api.jquery.com/on/</a></p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>$(".taginput").on("change", function () { var tagval = $(this).val(); var tagelement = $("&lt;a&gt;"); var remove = $("&lt;span class='remove'&gt;x&lt;/span&gt;") $(tagelement).append(tagval).append(remove).addClass("tag"); $("body").append(tagelement); $(".taginput").remove(); }); $(document).on("click", ".remove", function () { $(this).parent().remove(); });</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>.tag { background: none repeat scroll 0 0 #e4edf4; border: 1px solid #e4edf4; border-radius: 0; color: #3e6d8e; display: inline-block; font-size: 12px; line-height: 1; margin: 2px 2px 2px 0; padding: 0.4em 0.5em; text-align: center; text-decoration: none; white-space: nowrap; } .remove { padding-left:10px; position:relative; top:-2px; } .remove:hover { cursor:pointer; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt; &lt;input class="taginput" type="text"/&gt;</code></pre> </div> </div> </p>
1,037,897
0
<p>I think you're thinking at too low of a level. XML is not so much "binary" as it is an abstraction on top of binary. If you want to replace snippets of XML as they come across your line, you'll have to poke into the payload portion of the packets and look for patterns of XML.. a simple way is to use a regular expression after rebuilding the bytes into content temporarily.</p> <p>Once you have this search and you have matched what you want, you can replace what you want to replace and re-send.</p> <p>The hard part of this is that you will likely need to cache some input before it leaves your machine so that you are able to find the beginning and end of what it is you are searching for. What makes this difficult is that often times, you don't know what constitutes the "beginning" and the "end" of a data payload.</p>
28,970,996
0
<p>All methods of which I am aware to return an array from a function have weaknesses and strengths.</p> <p>Wrapping in a struc avoids the overhead of allocating and freeing memory, as well as avoids remembering to free. You have those problems on any solution that uses malloc, calloc, and realloc. On the other hand, wrapping in a struct requires knowing the maximum possible size of the array, and is decidedly wasteful of memory and execution time for large arrays (for example, loading a file into memory and passing the file contents around from function to function by copying).</p>
35,362,467
0
<p>Payload for iOS is bit different. The structure should be following format</p> <pre><code>{ "content_available":true, "to":"gcm_token_of_the_device", "priority":"high", "notification": { "body":"anything", "title":"any title" } } </code></pre> <p><strong>Note:</strong> Content_available should be true and priority should be high then only u recevied the notification. when your app is in closed state</p>
19,771,800
0
Arduino Ethernet web server problems <p>I got some problems with my Arduino code i made a Arduino Ethernet SD web server its task is to get a comand and light a Power switch and show if the switch is on or off Everything works perfect. But the problem is that i can connect to arduino web server a couple of times then something happens and i cant connect to it then i have to restart it to be able to connect to it again. Could any one pls help me?</p> <pre><code>#include &lt;SPI.h&gt; #include &lt;Ethernet.h&gt; #include &lt;SD.h&gt; #include &lt;RemoteTransmitter.h&gt; // size of buffer used to capture HTTP requests #define REQ_BUF_SZ 60 // MAC address from Ethernet shield sticker under board byte mac[] = { 0x90, 0xA2, 0xDA, 0x0E, 0x95, 0x2F }; IPAddress ip(192, 168, 1, 200); // IP address, may need to change depending on network EthernetServer server(80); // create a server at port 80 File webFile; // the web page file on the SD card char HTTP_req[REQ_BUF_SZ] = {0}; // buffered HTTP request stored as null terminated string char req_index = 0; // index into HTTP_req buffer boolean LED_state[3] = {0}; // stores the states of the LEDs ActionTransmitter actionTransmitter(9); void setup() { // Everything resets to Off if arduino is reseted actionTransmitter.sendSignal(1,'A',false); actionTransmitter.sendSignal(1,'B',false); actionTransmitter.sendSignal(1,'C',false); // disable Ethernet chip pinMode(10, OUTPUT); digitalWrite(10, HIGH); Serial.begin(9600); // for debugging // initialize SD card Serial.println("Initializing SD card..."); if (!SD.begin(4)) { Serial.println("ERROR - SD card initialization failed!"); return; // init failed } Serial.println("SUCCESS - SD card initialized."); // check for index.htm file if (!SD.exists("index.htm")) { Serial.println("ERROR - Can't find index.htm file!"); return; // can't find index file } Serial.println("SUCCESS - Found index.htm file."); Ethernet.begin(mac, ip); // initialize Ethernet device server.begin(); // start to listen for clients } void loop() { EthernetClient client = server.available(); // try to get client if (client) { // got client? boolean currentLineIsBlank = true; while (client.connected()) { if (client.available()) { // client data available to read char c = client.read(); // read 1 byte (character) from client // limit the size of the stored received HTTP request // buffer first part of HTTP request in HTTP_req array (string) // leave last element in array as 0 to null terminate string (REQ_BUF_SZ - 1) if (req_index &lt; (REQ_BUF_SZ - 1)) { HTTP_req[req_index] = c; // save HTTP request character req_index++; } // last line of client request is blank and ends with \n // respond to client only after last line received if (c == '\n' &amp;&amp; currentLineIsBlank) { // send a standard http response header client.println("HTTP/1.1 200 OK"); // remainder of header follows below, depending on if // web page or XML page is requested // Ajax request - send XML file if (StrContains(HTTP_req, "ajax_inputs")) { // send rest of HTTP header client.println("Content-Type: text/xml"); client.println("Connection: keep-alive"); client.println(); SetLEDs(); // send XML file containing input states XML_response(client); } else { // web page request // send rest of HTTP header client.println("Content-Type: text/html"); client.println("Connection: keep-alive"); client.println(); // send web page webFile = SD.open("index.htm"); // open web page file if (webFile) { while(webFile.available()) { client.write(webFile.read()); // send web page to client } webFile.close(); } } // display received HTTP request on serial port Serial.print(HTTP_req); // reset buffer index and all buffer elements to 0 req_index = 0; StrClear(HTTP_req, REQ_BUF_SZ); break; } // every line of text received from the client ends with \r\n if (c == '\n') { // last character on line of received text // starting new line with next character read currentLineIsBlank = true; } else if (c != '\r') { // a text character was received from client currentLineIsBlank = false; } } // end if (client.available()) } // end while (client.connected()) delay(1); // give the web browser time to receive the data client.stop(); // close the connection } // end if (client) } // checks if received HTTP request is switching on/off LEDs // also saves the state of the LEDs void SetLEDs(void) { // LED 3 (pin 8) if (StrContains(HTTP_req, "LED1=1")) { LED_state[0] = 1; // save LED state actionTransmitter.sendSignal(1,'A',true); Serial.print("button 1 on "); } else if (StrContains(HTTP_req, "LED1=0")) { LED_state[0] = 0; // save LED state actionTransmitter.sendSignal(1,'A',false); Serial.print("button 1 off"); } // LED 4 (pin 9) if (StrContains(HTTP_req, "LED2=1")) { LED_state[1] = 1; // save LED state actionTransmitter.sendSignal(1,'B',true); } else if (StrContains(HTTP_req, "LED2=0")) { LED_state[1] = 0; // save LED state actionTransmitter.sendSignal(1,'B',false); } if (StrContains(HTTP_req, "LED3=1")) { LED_state[2] = 1; // save LED state actionTransmitter.sendSignal(1,'C',true); } else if (StrContains(HTTP_req, "LED3=0")) { LED_state[2] = 0; // save LED state actionTransmitter.sendSignal(1,'C',false); } } // send the XML file with analog values, switch status // and LED status void XML_response(EthernetClient cl) { int analog_val; // stores value read from analog inputs int count; // used by 'for' loops cl.print("&lt;?xml version = \"1.0\" ?&gt;"); cl.print("&lt;inputs&gt;"); // button LED states // LED3 cl.print("&lt;LED&gt;"); if (LED_state[0]) { cl.print("on"); } else { cl.print("off"); } cl.println("&lt;/LED&gt;"); // LED4 cl.print("&lt;LED&gt;"); if (LED_state[1]) { cl.print("on"); } else { cl.print("off"); } cl.println("&lt;/LED&gt;"); // new led cl.print("&lt;LED&gt;"); if (LED_state[2]) { cl.print("on"); } else { cl.print("off"); } cl.println("&lt;/LED&gt;"); cl.print("&lt;/inputs&gt;"); } // sets every element of str to 0 (clears array) void StrClear(char *str, char length) { for (int i = 0; i &lt; length; i++) { str[i] = 0; } } // searches for the string sfind in the string str // returns 1 if string found // returns 0 if string not found char StrContains(char *str, char *sfind) { char found = 0; char index = 0; char len; len = strlen(str); if (strlen(sfind) &gt; len) { return 0; } while (index &lt; len) { if (str[index] == sfind[found]) { found++; if (strlen(sfind) == found) { return 1; } } else { found = 0; } index++; } return 0; } </code></pre>
32,596,993
0
Best way to convert an already-existing ArcGIS Javascript Map Application to an Offline Windows Application <p>I currently have a working ArcGIS JavaScript map application with a lot of functionality with it. I found out that some of our engineers who will be using the web map in the field will sometimes not have internet access and I have been asked to look into ways to create an offline version of the application. I know this is possible using ArcGIS SDK methods, but I do not know those languages and how I would go from JavaScript to those languages. I am wondering what the best way to convert an ArcGIS JavaScript application to an Offline Windows Application would be if there is one. If anyone has experience doing this, advice would be extremely appreciated! Thanks.</p>
4,187,054
0
<p>Using a template for loop? You may try this using:</p> <blockquote> <p>forloop.counter</p> </blockquote> <p>see the docs here: <a href="http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs" rel="nofollow">http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs</a> </p> <p>Implementation:</p> <pre><code>{% for s in list%} {% for subject in s%} {% for sub in subject %} &lt;div id="{{ sub| getid:forloop.counter+(forloop.parentloop.counter - 1)*total_iterations_inner_loop+(forloop.parentloop.parentloop.counter-1)*total_iterations_mid_loop*total_iterations_inner_loop }}"&gt;&lt;/div&gt; {% endfor %} {% endfor %} {% endfor %} </code></pre>
19,534,477
0
Animate image icon from touch place to right-top corner? <p>I am working on Android onlineShopping application.I have to apply some animation.</p> <ol> <li>cart image is displays on Right-top corner of the screen.</li> <li>List of items are on screen each item with "Add to cart" button.</li> <li>When user press this button I have to play animation.</li> <li>I have one fix image which should animate from touch position to cart-image placed on right-top corner of the screen.</li> </ol> <p>Please help me out.</p> <p>Thanks in advance.</p> <p>Update :</p> <p>I Tried this to move image from one place to another.</p> <pre><code>TranslateAnimation anim = new TranslateAnimation(0,0,200,200); anim.setDuration(3000); img.startAnimation(anim); </code></pre> <p>This image I want to animate from touch position to right-top corner. <img src="https://i.stack.imgur.com/fErsF.png" alt="enter image description here"></p>
5,071,693
0
<p>What type of cache do you use?</p> <p>This sequence works fine for me:</p> <pre><code>child.setParent(parent); parent.getChildren().add(child); session.saveOrUpdate(child); session.flush(); </code></pre> <p>Also, make sure that you REALLY need that cache. In my experience, 2-nd level cache rarely accelerates real applications and yet creates a lot of problems.</p>
12,111,036
0
<p>would this work:</p> <pre><code>&lt;table&gt; @for (int i = 0; i &lt;= Model.checkItems.Count; i++) { if (i % 6 == 0) { &lt;tr&gt; &lt;td&gt; &lt;input type="checkbox" id="chk_@(Model.checkItems[i].DisplayText)" name="chk" nameVal = "@Model.checkItems[i].DisplayText" value="@Model.checkItems[i].Value"/&gt; &lt;label for="chkGroup_@(Model.checkItems[i].DisplayText)"&gt;@Model.checkItems[i].DisplayText &lt;/td&gt; &lt;/tr&gt; } } &lt;/table&gt; </code></pre>
11,595,147
0
<p>You probably want to just use Attributes to specify your validation rules. This is the namespace where all the basic validations exist: <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.aspx" rel="nofollow">ComonpentModel.DataAnnotations</a>. If you want to get fancier, this NuGet package gives you lots of extra attributes: <a href="http://dataannotationsextensions.org/" rel="nofollow">Data Annotation Extensions</a>. Both of these support client side validation with ASP.NET's MVC unobtrusive validation.</p>
35,535,018
0
<p>Like other aggregate functions, <a href="http://docs.oracle.com/cd/E11882_01/server.112/e41084/functions089.htm#SQLRF30030" rel="nofollow"><code>listagg</code> also supports analytic functions</a>. So, we can partition it by values. <code>floor(rownum/50)</code> gives the same value for 50 consecutive rows.</p> <pre><code>select distinct '^.*(' || listagg(id, '|') within group (order by id) over (partition by floor(rownum / 50)) || ')' regex from mytable </code></pre>
26,509,285
0
Multiple modules with same build type <p>I have a gradle android project with two modules:</p> <ul> <li>Wear</li> <li>App (which is the phone app)</li> </ul> <p>In my gradle configuration I have different build types. The defaults (debug and release, each with custom settings), and dev and beta build type (also with custom signing, custom proguard and custom applicationIdSuffix.</p> <p>What I now want to do is to build the app package with for example the buildType beta (gradle clean assembleBeta). That starts building the app in beta, sees that it has a dependency to wear, and starts building wear. BUT here's the problem. The wear module is being built with the release build type instead of the same beta-build-type I used to initiate the build.</p> <p>The custom build type configuration is exactly the same on the two modules, and thus manually building the wear module with beta build type does work. But having a wear module built with beta and packaged inside the app module also built with beta does not work.</p> <p>Any ideas how I can achieve that?</p>
27,047,590
0
<blockquote> <p>JUnit's assertEquals() and such - good for tests, but can't use in main code</p> </blockquote> <p>Nothing technically prevents you from using JUnit assetions (and/or Hamcrest matchers) in your main code. Just include the Junit jar in your classpath. It's usually not done but that's more of a convention than any technical limitation.</p> <p>Java 7 also introduced <code>Objects.requireNotNull(obj, message)</code> and similar methods although not as full featured as JUnit assertions. </p> <p>but I think if you want to go with a more standardized approach Guava's preconditions is probably best.</p>
29,561,751
1
NTPLib Time Difference + Python <p>while using ntp time, (UK) it always returns one hour less than the actual time. Eg: now time is 13.35 But when I say date, it returns 12.35. Any suggestions ?</p> <pre><code> try: c = ntplib.NTPClient() response = c.request('uk.pool.ntp.org', version=3) except: print "Error At Time Sync: Let Me Check!" </code></pre>
7,438,712
0
<p>The idea behind this assert is to check if first row after added ones was correctly moved. If there are some rows after inserted ones, then their data are compared. If there aren't any, your model should both in the line</p> <pre><code>c.next = model-&gt;data ( model-&gt;index ( start, 0, parent ) ); </code></pre> <p>and in</p> <pre><code>Q_ASSERT ( c.next == model-&gt;data ( model-&gt;index ( end + 1, 0, c.parent ) ) ); </code></pre> <p>should return invalid (empty) QVariant. If both return empty QVariant (as they should) assertion succedes, thus providing some level of error-checking even in case of no rows after currently inserted.</p>
2,862,469
0
iPhone SDK Objective-C __DATE__ (compile date) can't be converted to an NSDate <pre><code>//NSString *compileDate = [NSString stringWithFormat:@"%s", __DATE__]; NSString *compileDate = [NSString stringWithUTF8String:__DATE__]; NSDateFormatter *df = [[[NSDateFormatter alloc] init] autorelease]; [df setDateFormat:@"MMM d yyyy"]; //[df setDateFormat:@"MMM dd yyyy"]; NSDate *aDate = [df dateFromString:compileDate]; </code></pre> <p>Ok, I give up. Why would aDate sometimes return as nil?</p> <p>Should it matter if I use the commented-out lines... or their matching replacement lines?</p>
37,370,903
0
random value assign with the class combination <p>Here is the case I have got a spell class </p> <pre><code> public abstract class Spell { public abstract void Castspell (); } public class Heal:Spell { Dictionary&lt;string, int&gt; heals = new Dictionary&lt;string,int&gt; (); public Heal() { heals.Add ("less heal", 1); heals.Add ("medium heal", 2); heals.Add (" large heal", 3); } public override void Castspell() { } } </code></pre> <p>ignore the Castspell(), and there is another class called student</p> <pre><code> public class student { public enum spells { lessheal, mediumheal, highheal } List&lt;Spell&gt; _skillist = new List&lt;Spell&gt;(); public student() { //... } public void learnskills() { _skillist.Clear (); Spell newspell = new Spell (); _skillist.Add (newspell); } </code></pre> <p>what I am trying to do here is I wanna make learn skill method, each time I Call It will randomly add a heal spell into the _skillist.(it could be less, medium or high). how could I achieve it? please give me some advices about it.thanks</p>
33,845,898
0
<p>According to the stacktrace, angular didn't found the module <code>ngAnimate</code>. You probably forgot to link angular-animate script from your <em>index.html</em> page.</p> <p><strong>index.html</strong></p> <pre><code>&lt;script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js"&gt;&lt;/script&gt; &lt;script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular-animate.js"&gt;&lt;/script&gt; &lt;script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.14.3.js"&gt;&lt;/script&gt; </code></pre>
8,177,540
0
<p>Precede your list name by a star:</p> <pre><code>def foo(a, b, c): print(a, b, c) a = [1,2,3] foo(*a) # 1 2 3 </code></pre> <p>The star unpacks the list, which gives 3 separate values.</p>
34,829,171
0
How to resize canvas and its background image while somehow maintaining the co-ordinate scale? <p>I want my canvas and background image to scale to any browser size which I have learnt is possible through this.</p> <pre><code>&lt;canvas id="canvas" style="width:100%; height:100%; background-size:100% 100%; left:0px; top: 0px;"&gt; </code></pre> <p>Setting the width and height using percentages causes whatever I draw on top to come out blurred. The reason for this I read is that it comes out blurry because the width and height of canvas set using css is different.</p> <p>It is absolutely imperative that I keep track of the co-ordinates since I have written a collision detection logic using the original size of the image.</p> <p>Is it possible to dynamically change the canvas size to fill the screen, redraw it and ensure that the collision logic works perfectly without blurry drawing on top?</p> <p>Lets take an example here. The image floor.jpg that I want as the background of the canvas is 1200X700. I want the canvas to be 100% of the page width and height. My animated player that moves on top of it requires collision detection with walls which I have coded keeping in mind the 1200x700 image. </p> <p>I have gone through the various similar question on this site, but can't seem to figure it out.</p>
32,136,165
0
<p>That should be an update query instead of an insert query:</p> <pre><code>mysql_query("UPDATE users SET profile = '$file' WHERE id = '$var'"); </code></pre> <p>Also note that:</p> <ul> <li>You're using a deprecated API. Consider switching to the <code>mysqli_*</code> functions or using PDO.</li> <li>You're wide open to SQL injection attacks. Consider using prepared statements.</li> </ul>
18,860,799
0
Modify File Contents based on starting element/string <p>I have a HL7 File like:</p> <pre><code>MSH|^~\&amp;|ABC|000|ABC|ABC|0000||ABC|000|A|00 PID|1|000|||ABC||000|A|||||||||| OBR|1|||00||00|00|||||||||||ABC|00|0|0||||A|||||00||ABC|7ABC||ABC OBX|1|ABC|ABC|1|SGVsbG8= OBX|2|ABC|ABC|1|XYTA OBX|3|ABC|ABC|1|UYYA </code></pre> <p>I have to read only OBX segments and get the text after 5th pipe (|).</p> <p>Currently I am doing this with:</p> <pre><code> StreamReader reader = new StreamReader(@"C:\Users\vemarajs\Desktop\HL7\Ministry\HSHS.txt"); string strTest = reader.ReadToEnd(); string OBX1 = strTest.Split('\n')[3]; File.AppendAllText(@"C:\Users\vemarajs\Desktop\Test\OBX.txt", OBX1 + Environment.NewLine); List&lt;string&gt; list = new List&lt;string&gt;(); using (reader) { string line; while ((line = reader.ReadLine()) != null) { list.Add(line); if (line.StartsWith("OBX|") == true) { string txt = line.Split('|')[5]; File.AppendAllText(@"C:\Users\vemarajs\Desktop\Test\test.txt", txt+Environment.NewLine); } else { //string x = line + Environment.NewLine + OBX1.Distinct(); File.AppendAllText(@"C:\Users\vemarajs\Desktop\Test\newtest.txt", line + Environment.NewLine); } </code></pre> <p>File.AppendAllText(@"C:\Users\vemarajs\Desktop\Test\newtest.txt", OBX1.Distinct().ToList() + Environment.NewLine);</p> <p>This extracts the contents of each OBX segment at element 5 (after 5 pipes) and writes out a file called test.text, in my else statement I am trying to modify the original HL7 file by deleting OBX|2 and OBX|3 to have only One OBX|1 as we expect the number of OBX segments inside the HL7 file to reach 40 or more and we don't wan't to keep those many while returning the message to its messagebox.</p> <p>How do I get the first occurrence of OBX|1 without saying the line number is 4, this might change.</p> <p>This is the working code:</p> <pre><code> StreamReader reader = new StreamReader(@"C:\Users\vemarajs\Desktop\HL7\Ministry\HSHS.txt"); string strTest = reader.ReadToEnd(); reader.DiscardBufferedData(); reader.BaseStream.Seek(0, SeekOrigin.Begin); reader.BaseStream.Position = 0; string OBXstr = string.Empty; string x = null; string fileName = Guid.NewGuid().ToString() + ".txt"; StringBuilder sb = new StringBuilder(); List&lt;string&gt; list = new List&lt;string&gt;(); using (reader) { string line; while ((line = reader.ReadLine()) != null) { list.Add(line); if (line.StartsWith("OBX|") == true) { string txt = line.Split('|')[5]; File.AppendAllText(@"C:\Users\vemarajs\Desktop\Test\"+fileName, txt + Environment.NewLine); } else { sb.AppendLine(line); } } int obx1Index = 0; int obx2Index = 0; var obx1IDR = "\r" + "OBX" + "|" + "1"; var obx1IDN = "\n" + "OBX" + "|" + "1"; var obx2IDR = "\r" + "OBX" + "|" + "2"; var obx2IDN = "\n" + "OBX" + "|" + "2"; obx1Index = strTest.IndexOf(obx1IDN); if (obx1Index &lt; 1) obx1Index = strTest.IndexOf(obx1IDR); obx2Index = strTest.IndexOf(obx2IDN); if (obx2Index &lt; 1) obx2Index = strTest.IndexOf(obx2IDR); if (obx1Index &gt; 0) { OBXstr = strTest.Substring(obx1Index, obx2Index - obx1Index - 1); OBXstr = OBXstr.Replace(strTest.Substring(obx1Index, obx2Index - obx1Index - 1).Split('|')[5], fileName); } } sb.Append(OBXstr); x = sb.ToString(); File.WriteAllText(@"C:\Users\vemarajs\Desktop\Test\newtest.txt", x); reader.Close(); </code></pre>
21,802,196
0
<p>If you want to treat this as a 1d array, you must declare it as so:</p> <pre><code>void data(int i,int arr[],int size) { </code></pre> <p>Or:</p> <pre><code>void data(int i,int *arr,int size) { </code></pre> <p>The reason is that otherwise, <code>arr[i]</code> is interpreted as an array of 2 integers, which decays into a pointer to the first element (and that's the address that is printed).</p> <p>Declaring it as a 1-dimensional array will make sure that <code>arr[i]</code> is seen as an <code>int</code>.</p> <p>Note that whoever calls this function cannot pass a 2D array anymore, or, put another way, cannot make that obvious to the compiler. Instead, you have to pass it a pointer to the first element, as in:</p> <pre><code>data(0, &amp;arr[0][0], 4); </code></pre> <p>Or, equivalently:</p> <pre><code>data(0, arr[0], 4); </code></pre> <p>This just affects the first call, the recursive call is correct, of course.</p> <p>In other words, the code should work, you just need to change the declaration of the parameter <code>arr</code></p>
22,968,065
0
<p>It looks like it's saying it can't get to your database. The database may only be allowing access from certain machines.</p> <p>This isn't an error from Django; it's from the <code>sqlserver_ado</code> Python module you have installed. Check its documentation for a "Provider cannot be found" error.</p>
20,539,780
0
The Web Application Project is configured to use IIS. The Web server could not be found <p>An ASP.NET web project loads with up the solution, but I get this error</p> <p>The Web Application Project Module Example is configured to use IIS. The Web Server '<a href="http://dnndev.me/desktopmodules/Module_Example" rel="nofollow">http://dnndev.me/desktopmodules/Module_Example</a>' could not be found.</p>
15,702,981
0
<p>You can quite easily achieve this with a single query:</p> <pre><code>UPDATE `Members` SET `fullname` = CONCAT(`fname`, ' ', `lname`) WHERE `member_id` = '".$_SESSION['SESS_MEMBER_ID']."' AND `fullname` = 0 LIMIT 1; </code></pre>
26,058,568
0
<p>Hi may be I am late but I have a good news for you.</p> <p>Apple provide a new feature in IOS 7 and we can lock the user to single mode without user permission(Lock and unlock mode) here is the apple documentation link</p> <p><a href="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIKitFunctionReference/#//apple_ref/c/func/UIAccessibilityRequestGuidedAccessSession" rel="nofollow">https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIKitFunctionReference/#//apple_ref/c/func/UIAccessibilityRequestGuidedAccessSession</a></p> <p>the other way is to install the profile config profile like is</p> <p><a href="http://ipadhire.co.nz/lockdown.mobileconfig" rel="nofollow">http://ipadhire.co.nz/lockdown.mobileconfig</a></p> <p>it lock the home button of IPhone and enable single mode</p>