pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
1,960,584
0
Centering my Title DIV <p><a href="http://we-live.in/the_sierra" rel="nofollow noreferrer">http://we-live.in/the_sierra</a> - Towards the bottom of the page I have a div which contains an image of grass. How can I get the grass image to be centered horizontally on the page?</p> <blockquote> <p>ok i got it centered now i need to move it lower down on the page</p> </blockquote> <p>thanks</p>
36,328,576
0
Why my jquery code wont work if with ID but Class <p>I have html code like this.</p> <pre><code>&lt;input onkeyup="ave()" type="text" name="1" class = "ave" style="width: 60px"&gt;&lt;/td&gt; &lt;input onkeyup="ave()" type="text" name="2" class = "ave" style="width: 60px"&gt;&lt;/td&gt; &lt;input onkeyup="ave()" type="text" name="3" class = "ave" style="width: 60px"&gt;&lt;/td&gt; </code></pre> <p>The jQuery like this</p> <pre><code>function ave(){ $('.ave').keyup(function(){ var sum = 0; var ave = 0; $('.ave').each(function(){ sum += +$(this).val(); }); var ave = sum/3; $('.total').val(ave.toFixed(2)); }); } </code></pre> <p>If I change 'class' to 'ID' and <code>$('.ave')</code> to <code>$('#ave')</code> the code won't work!</p>
30,430,101
0
<p>As stated in the comments, the proper way to do this is with a <code>TextureView</code>.</p>
17,054,522
0
<p>As said, you're asking about regular expressions commonly called a "regex". Take a look at <a href="http://www.regular-expressions.info/reference.html" rel="nofollow"><strong>Regular-Expressions.info</strong></a> for tons of good information. The page you're probably most interested in is the <a href="http://www.regular-expressions.info/characters.html" rel="nofollow"><strong>Literal Characters and Special Characters</strong></a>, which largely answers your OP. A great site to test your regex is <a href="http://www.rubular.com/" rel="nofollow"><strong>Rubular.com</strong></a>. It's designed for Ruby, but works great for nearly anything I've thrown at it (sed expressions, C# replace, JS replace, etc.).</p> <p>HTH</p>
1,458,212
0
<p>My interpretation is that it will always interpret it in a format that <em>happens</em> to look a lot like C#, yes. So <code>.</code> for members-access, etc (the same as data-binding uses <code>.</code> for member-access, regardless of the caller's language). It is also a lot like the <code>string.Format</code> pattern, if you see the relationship (<code>"{0} - {1}"</code> etc).</p> <p>Of course, if the expression gets <em>too</em> complex you could consider a <a href="http://msdn.microsoft.com/en-us/library/d8eyd8zc.aspx" rel="nofollow noreferrer">debugger type proxy</a>.</p>
9,860,648
0
<p>It depends on what you are <em>actually</em> testing. Looking on the comments I would say <em>yes</em>, but by the way it's difficult to deduct looking on comments. Cleaning up the object you just inserted you, in practice, reset the state of the test. So if you cleanup, you begin to test from cleanup system.</p>
15,459,286
0
Compilation error : No match for overloaded operator <p>here is a part of my code, when i compile it, it says 1: no match for operator = 2: no known conversion for argument 1 from 'Matrix' to 'Matrix&amp;' but if i remove the operator + part it works where is the problem?! :|</p> <p>gcc errors: "no match for 'operator=' in 'z = Matrix::operator+(Matrix&amp;)((* &amp; y))' candidate is: atrix&amp; Matrix::operator=(Matrix&amp;) no known conversion for argument 1 from 'Matrix' to 'Matrix&amp;' "</p> <pre><code>class Matrix { //friend list: friend istream&amp; operator&gt;&gt;(istream&amp; in, Matrix&amp; m); friend ostream&amp; operator&lt;&lt;(ostream&amp; in, Matrix&amp; m); int** a; //2D array pointer int R, C; //num of rows and columns static int s1, s2, s3, s4, s5; public: Matrix(); Matrix(const Matrix&amp;); ~Matrix(); static void log(); Matrix operator+ (Matrix &amp;M){ if( R == M.R &amp;&amp; C == M.C ){ s4++; Matrix temp; temp.R = R; temp.C = C; temp.a = new int*[R]; for(int i=0; i&lt;R; i++) temp.a[i] = new int[C]; for(int i=0; i&lt;R; i++) for(int j=0; j&lt;C; j++) temp.a[i][j] = a[i][j] + M.a[i][j]; return temp; } } Matrix&amp; operator = (Matrix&amp; M){ s5++; if(a != NULL) { for(int i=0; i&lt;R; i++) delete [] a[i]; delete a; a = NULL; R = 0; C = 0; } R = M.R; C = M.C; a = new int*[R]; for(int i=0; i&lt;R; i++) a[i] = new int[C]; for(int i=0; i&lt;R; i++) for(int j=0; j&lt;C; j++) a[i][j] = M.a[i][j]; return *this; } </code></pre> <p>};</p>
4,728,422
0
<p>you can use the following</p> <pre><code>&lt;?php $timezone = 'Pacific/Nauru'; $time = new \DateTime('now', new DateTimeZone($timezone)); $timezoneOffset = $time-&gt;format('P'); ?&gt; </code></pre>
19,669,620
0
<p>COUNT is an aggregate function, you should use GROUP BY.</p> <p><a href="http://dev.mysql.com/doc/refman/5.1/en/group-by-functions.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.1/en/group-by-functions.html</a></p>
6,703,763
0
<p>Looking at the WSDL for the message is irrelevant because as you have said in a response to a comment you want this to be a REST based service and WSDL is a SOAP construct. On that basis you should remove a <code>&lt;serviceMetadata&gt;</code> behavior if you have one as this is about SOAP metadata. </p> <p>To diagnose problems like this you should turn on tracing in WCF (I have a short screencast <a href="http://www.rocksolidknowledge.com/Screencasts.mvc/Watch?video=WCFTracing.wmv" rel="nofollow">here</a> that shows you how to do it). This should highlight what the problem is in processing the message</p> <p>To wire up the REST plumbing without adding a section in the config for your service add the following to your config file under the system.serviceModel section</p> <pre><code>&lt;protocolMapping&gt; &lt;add scheme="http" binding="webHttpBinding"/&gt; &lt;/protocolMapping&gt; &lt;behaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior&gt; &lt;webHttp/&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;/behaviors&gt; </code></pre>
872,981
0
<p>Here you go:</p> <p><a href="http://codepen.io/vsync/pen/FyluI" rel="nofollow noreferrer"><strong>Example page - footer sticks to bottom</strong></a></p> <p>this will have the content right <br /> between the footer and the header. <br /> no overlapping.</p> <h2>HTML</h2> <pre><code>&lt;header&gt;HEADER&lt;/header&gt; &lt;article&gt; &lt;p&gt;some content here (might be very long)&lt;/p&gt; &lt;/article&gt; &lt;footer&gt;FOOTER&lt;/footer&gt; </code></pre> <h2>CSS</h2> <pre><code>html{ height:100%; } body{ min-height:100%; padding:0; margin:0; position:relative; } body:after{ content:''; display:block; height:100px; // compensate Footer's height } header{ height:50px; } footer{ position:absolute; bottom:0; width:100%; height:100px; // height of your Footer (unfortunately it must be defined) } </code></pre>
31,348,163
0
<p>You can use Mockito to mock out interface A.</p> <pre><code>@Test public void test () { //given: we have our expected and actual lists. List&lt;String&gt; expectedResult = Arrays.asList("id1","id2","id3"); //build our actual list of mocked interface A objects. A a1 = mock(A.class); when(a1.getId()).thenReturn("id1"); A a2 = mock(A.class); when(a2.getId()).thenReturn("id2"); A a3 = mock(A.class); when(a3.getId()).thenReturn("id3"); B b = mock(B.class); Collection&lt;A&gt; actualResult = Arrays.asList(a1, a2,a3); //when: we invoke the method we want to test. when(b.getCollection()).thenReturn(actualResult); //then: we should have the result we want. assertNotNull(actualResult); assertEquals(3, actualResult.size()); for (A a : actualResult) assertTrue(expectedResult.contains(a.getId())); } </code></pre>
17,119,796
0
<p>While there is a file system provider <code>s3fs</code> build on fuse. Is not always a good idea to try to mount it to the file system. Instead you should either use command line tools <code>s3cmd</code> or build in access to s3 into your filesystem.</p> <p>The reason why I would recommend against it is that s3 is not a block device while the rest of your file system is. Everything on s3 is treated as a complete object. You can't read or write to a block of the object.</p> <p>If all your are doing with the mount is copying files in its entirety to and from s3, a file system mount may work reasonably well. But you can't run anything that would expect block level acccess to files on that mount.</p>
6,848,474
0
If NSTemporaryDirectory returns nil <p>According to the documentation, <code>NSTemporaryDirectory()</code> can return nil. I need to save some temporary files in the device. What should I do if <code>NSTemporaryDirectory()</code> returns nil? Should I create a folder elsewhere? If yes, where? Or should I just show a message to the user?</p>
14,851,929
0
External JavaScript working on localhost but not in remote host? <p>This is the site: <a href="http://www.hfwebdesign.com/" rel="nofollow">http://www.hfwebdesign.com/</a></p> <p>I'm getting this error: <code>Uncaught TypeError: Object [object Object] has no method 'flexslider'</code></p> <p>But in my localhost it works perfectly.</p> <p>This is the <code>&lt;head&gt;</code> (where the script is being called):</p> <pre><code>&lt;head&gt; &lt;meta charset="&lt;?php bloginfo( 'charset' ); ?&gt;" /&gt; &lt;meta name="viewport" content="width=device-width" /&gt; &lt;title&gt;&lt;?php wp_title( '|', true, 'right' ); ?&gt;&lt;/title&gt; &lt;link rel="profile" href="http://gmpg.org/xfn/11" /&gt; &lt;link rel="pingback" href="&lt;?php bloginfo( 'pingback_url' ); ?&gt;" /&gt; &lt;link rel="stylesheet" type="text/css" media="all" href="&lt;?php bloginfo( 'template_url' ); ?&gt;/js/flexslider/flexslider.css" /&gt; &lt;link rel="icon" type="image/png" href="&lt;?php bloginfo( 'template_url' ); ?&gt;/favicon.ico" /&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="&lt;?php bloginfo( 'template_url' ); ?&gt;/js/flexslider/jquery.flexslider-min.js"&gt;&lt;/script&gt; &lt;?php // Loads HTML5 JavaScript file to add support for HTML5 elements in older IE versions. ?&gt; &lt;!--[if lt IE 9]&gt; &lt;script src="&lt;?php echo get_template_directory_uri(); ?&gt;/js/html5.js" type="text/javascript"&gt;&lt;/script&gt; &lt;![endif]--&gt; &lt;?php wp_head(); ?&gt; &lt;/head&gt; </code></pre> <p><strong>footer:</strong></p> <pre><code>&lt;script type="text/javascript"&gt; var $j = jQuery.noConflict(); $j(document).ready(function() { $j('.flexslider').flexslider({ animation: "slide" }); }); &lt;/script&gt; &lt;/body&gt; </code></pre> <p>Could it be that the code is breaking in the web server in the remote host and not in my localhost (e.g. they are different version of LAMP/APACHE?)</p>
27,599,177
0
<p>Try this:</p> <pre><code>$('.typeahead').typeahead({ source: function (query, process) { return $.get('data.php', { query: query }, function (data) { return process(data.options); }); } }); &lt;?php $mysqli = new mysqli("localhost", "root", "", "disbursements"); $query = 'SELECT payee_name FROM payees'; if (isset($_POST['query'])) { // Now set the WHERE clause with LIKE query $query.= ' WHERE payee_name LIKE "%' . $_POST['query'] . '%"'; } $return = array(); if ($result = $mysqli-&gt;query($query)) { // fetch object array while ($obj = $result-&gt;fetch_object()) { $return['options'][] = $obj-&gt;payee_name; } // free result set $result-&gt;close(); } // close connection $mysqli-&gt;close(); $json = json_encode($return); echo $json; ?&gt; </code></pre>
18,518,700
0
<p>You specify the size in your xml layout file using DP (DIP: Density Independent Pixels) instead of Pixels, you can also use wrap_content and match_parent.</p> <p>For more info, <a href="http://developer.android.com/guide/practices/screens_support.html" rel="nofollow">http://developer.android.com/guide/practices/screens_support.html</a></p>
16,191,928
0
<p>You don't need the IF statements.</p> <p>=MAX(A1:A4) > 350</p> <p>Gives you the same results.</p>
8,590,960
0
<p>When I added "::" before Hash class it starts working.</p> <pre><code>puts value.class puts value.is_a?(::Hash) </code></pre> <p>Output:</p> <pre><code>Hash true </code></pre>
35,549,114
0
<p>The problem is not that the class is a <code>partial</code> class. The problem is that you try to derive a <code>static</code> class from another one. There is no point in deriving a <code>static</code> class because you could not make use Polymorphism and other reasons for inheritance. </p> <p>If you want to define a <code>partial</code> class, create the class with the same name and access modifier. </p>
32,084,079
0
<p>Use "bind()":</p> <pre><code>var contacts = [{firstName: 'Stephen', lastName: 'Hawking'}, {firstName: 'Nicolas', lastName: 'Tesla'}, {firstName: 'Dean', lastName: 'Kamen'} ]; var getFullName = function() { return this.firstName + ' ' + this.lastName; }; for(var i = 0; i &lt; contacts.length; i++){ var contact = contacts[i]; contact.getFullName = getFullName.bind(contact); // Or: //contact['getFullName'] = getFullName.bind(contact); console.log(contact.getFullName()); } </code></pre>
5,724,589
0
<p>If you're getting your information from the VS debugger, I wouldn't trust what it is telling you for a Release DLL. The debugger can only be really trusted with Debug DLLs.</p> <p>If program output is telling you this, then that's different -- in that case, you're not providing enough information.</p>
24,416,099
0
What happens when you use page compression on a primary key in SQL Server? <p>Given that the primary key index is how the table is physically laid out, what effect if any is there by putting a WITH DATA_COMPRESSION on it?</p> <pre><code>CREATE TABLE [Search].[Property] ( [PropertyId] [BIGINT] NOT NULL CONSTRAINT PK_Property PRIMARY KEY WITH (DATA_COMPRESSION = PAGE), [Parcel] [GEOMETRY] NULL CHECK ([Parcel] IS NULL OR ([Parcel].STSrid = 3857 AND [Parcel].STIsValid() = 1 )), [StreetNumber] [VARCHAR](20) NULL, [StreetDir] [VARCHAR](2) NULL, [StreetName] [VARCHAR](50) NULL, [StreetType] [VARCHAR](4) NULL, [StreetPostDir] [VARCHAR](2) NULL ) WITH ( DATA_COMPRESSION = PAGE); GO </code></pre>
3,787,752
0
<p>I take what I previously said back. I think I may have a way to make this work in pure c/c++, albeit in a very messy way. You would need to pass a pointer into your functions...</p> <p>i.e. bool hello_world(std::string &amp; my_string, const std::string * const my_string_ptr) {</p> <p>bool hello_world(std::string my_string, const std::string * const my_string_ptr) {</p> <p>if you now tested</p> <p>if ( &amp;my_string == my_string_ptr )</p> <p>It would evaluate <strong>true</strong> if the var was passed by reference, and false if passed by <strong>value</strong>.</p> <p>Of course doubling your variables in all your functions probably isn't worth it...</p> <hr> <p>Johannes is right... not in pure c++. But you CAN do this. The trick is to cheat. Use an embedded scripting language like perl to search your source. Here's an embedded perl module:</p> <p><a href="http://perldoc.perl.org/perlembed.html" rel="nofollow">http://perldoc.perl.org/perlembed.html</a></p> <p>Pass it the function name, variable name, and source location and then use a regex to find the variable and check its type. Really this might be a better solution for your code in general, assuming you are always going to have a source handy. </p> <p>I will post a function for this basic approach in a bit... gotta take care of some morning work! :)</p> <p>Even if you don't want to distribute the source, you could create some sort of packed function/var data file that you could parse through @ runtime and get an equivalent result.</p> <hr> <p><strong>Edit 1</strong><br></p> <p>For example... using the <code># I32 match(SV *string, char *pattern)</code> function in the Perl Embed tutorial, you could do something like:</p> <pre><code>bool is_reference(const char * source_loc, const char * function_name, const char * variable_name) { std::ifstream my_reader; char my_string[256]; SV * perl_line_contents; bool ret_val = false; char my_pattern [400]=strcat("m/.*",function_name); my_pattern=strcat(my_pattern, ".*[,\s\t]*"); my_pattern=strcat(my_pattern, variable_name); my_pattern=strcat(my_pattern, "[\s\t]*[\(,].*$"); my_reader.open(source_loc.c_str()); while (!my_reader.eof()) { my_reader.getline(my_string,256); sv_setpv(perl_line_contents,my_string); if(match(perl_line_contents,my_pattern)) { ret_val= true; } } return ret_val; } </code></pre> <p>... there... two ways to do this (see above update).</p>
1,421,038
0
Textchanged event is not firing when using jscript <p>In my asp.net application, i am using a lookup to enter data to a textbox.For making lookup i have used jscript.I have a button for this lookup from which i am entering data to this textbox.so, i am not entering values directly to the textbox.After entering values to textbox, the textchanged event is not working.What could be the reason?</p>
35,821,657
0
<p>You can set a <code>background-color</code> on the <code>:before</code> element instead of a <code>border-top</code> to make it work. The pseudo-element can have a height of just <code>1px</code> and a <code>width: 100px;</code>.</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code> p { position: relative; margin: 50px auto; font-size: 1.5em; } p:before { content: ""; position: absolute; top: 50px; width: 100px; margin: 0 auto; height: 1px; background-color: black; /*Removed border, added background-color */ }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;p&gt; this is some text &lt;/p&gt;</code></pre> </div> </div> </p>
31,937,093
0
Table Is Not Deleted <p>i am trying to delete a table, and i followed this link <a href="http://www.techonthenet.com/sqlite/truncate.php" rel="nofollow">http://www.techonthenet.com/sqlite/truncate.php</a> as a tutorial. but when i execute the below code, for the first run, i expected the <code>sqliteFactory.getRowCount()</code> method will <code>return 0</code> rows as the method <code>sqliteFactory.deleteTable(SysConsts.SQLITE_DATABASE_TABLE_NAME);</code> was just called before it, but what i received is a <code>rowCount</code> which is not zero.</p> <p>in the second run of the same code, i expected the <code>sqliteFactory.CreateTable(SysConsts.SQLITE_DATABASE_TABLE_NAME);</code> to display <code>Log.i(TAG, "CreateTable", "table: ["+tableName+"] does not exist, will be created");</code> as the table should have been deleted, but i received <code>Log.i(TAG, "CreateTable", "table: ["+tableName+"] already exists.");</code></p> <p>kindly please let me know how why the table is not deleted? and should i do <code>commit</code> after deletion?</p> <p><strong>main code</strong>:</p> <pre><code>public static void main(String[] args) throws SQLException, ClassNotFoundException { SQLiteFactory sqliteFactory = new SQLiteFactory(); sqliteFactory.newSQLiteConn(SysConsts.SQLITE_DATABASE_NAME); sqliteFactory.CreateTable(SysConsts.SQLITE_DATABASE_TABLE_NAME); sqliteFactory.insertRecord(new Record("001", "55.07435", "8.79047", "c:\\bremen_0.xml")); Log.d(TAG, "main", "rowCount: "+sqliteFactory.getRowCount()); //sqliteFactory.selectAll(); //sqliteFactory.getNodeID("53.074415", "8.788047"); sqliteFactory.selectXMLPathFor("53.074415", "8.788047"); Log.d(TAG, "", ""+sqliteFactory.getRowCountLatLngFor("53.074415", "8.788047")); Log.d(TAG, "", ""+sqliteFactory.getRowCountNodeIDFor("001")); Log.d(TAG, "", ""+sqliteFactory.getRowCountXMLPathFor("c:\\brem_0.xml")); sqliteFactory.deleteTable(SysConsts.SQLITE_DATABASE_TABLE_NAME); Log.d(TAG, "main", "rowCount: "+sqliteFactory.getRowCount()); } </code></pre> <p><strong>CreateTable</strong>:</p> <pre><code>public void CreateTable(String tableName) throws SQLException, ClassNotFoundException { if (!this.isTableExists(tableName)) { Log.i(TAG, "CreateTable", "table: ["+tableName+"] does not exist, will be created"); Connection conn = this.getConnection(); Statement stmt = conn.createStatement(); stmt.executeUpdate(this.sqlTable); stmt.close(); conn.close(); } else { Log.i(TAG, "CreateTable", "table: ["+tableName+"] already exists."); return; } } </code></pre> <p><strong>isTableExists</strong>:</p> <pre><code>private boolean isTableExists(String tableName) throws ClassNotFoundException, SQLException { Connection conn = this.getConnection(); DatabaseMetaData dbMeta = conn.getMetaData(); ResultSet resSet = dbMeta.getTables(null, null, tableName, null); boolean exists = false; if (resSet.next()) { exists = true; } else { exists = false; } resSet.close(); conn.close(); return exists; } </code></pre> <p><strong>deleteTable</strong>:</p> <pre><code>public void deleteTable(String tableName) throws ClassNotFoundException, SQLException { if (this.isTableExists(tableName)) { Log.i(TAG, "deleteTable", "table: ["+tableName+"] already exists, and will be deleted."); Connection conn = this.getConnection(); PreparedStatement ps = conn.prepareStatement("delete from "+this.TABLE_NAME); ps.close(); conn.close(); } else { Log.i(TAG, "deleteTable", "table: ["+tableName+"] does not exist, can't be deleted."); return; } } </code></pre> <p><strong>getRowCount</strong>:</p> <pre><code>public int getRowCount() throws SQLException, ClassNotFoundException { Connection conn = this.getConnection(); Statement stmt= conn.createStatement(); ResultSet resSet = stmt.executeQuery("SELECT COUNT(*) AS rowCount FROM "+TABLE_NAME+";"); int cnt = resSet.getInt("rowCount"); resSet.close(); stmt.close(); conn.close(); return cnt; } </code></pre>
4,191,521
0
how to forbidden page cache on rails <p>i'm design a shopping cart,there are two web page,</p> <p>first is checkout page,and the second is order_success page</p> <p>if user use the go back button on webbrowser then it will go back to checkout page after user have go to order_success page.</p> <p>so i want to find some way to forbidden let use go back,</p> <p>is there some way on rails to archieve this?</p>
18,615,884
0
IE8 proxy CSS compatibility <p>I create a site that uses some css properties, specifically <code>display: inline-block</code>. The problem is, in IE8 when the proxy is enabled, the display page is loaded without the <code>display: inline-block</code> property. When the proxy is disabled the display is OK. The strange thing is, the browser didn't use proxy because the site is in local.</p> <p>I don't know what the problem is, have you an idea?</p>
28,810,189
0
JAVA: SomeStructure<E> to make it sorted by another type T? <p>I have a data class as following:</p> <pre><code>class MyData { private UUID id; private String data1; private String data2} </code></pre> <p>I store its instance in a map:</p> <pre><code>private Map&lt;UUID, MyData&gt; myData; </code></pre> <p>As all we know, I can get MyData instance by UUID:</p> <pre><code>MyData instance = myData.get(UUID); </code></pre> <p>But I also need to get MyData instance by index. What's more, the index is sorted by, say, MyData.data1 field. So I need a new data structure to store UUID according to index order, perhaps something like this:</p> <pre><code>private SomeStructure&lt;UUID&gt; myDataIndex; </code></pre> <p>What I want is this <code>SomeStructure</code> class. It should have a public method such as:</p> <pre><code>public UUID getUuidByIndex(int index); </code></pre> <p>And, it should sort UUID elements by MyData.data1 field.</p> <p>And, every time I put an item to <code>private Map&lt;UUID, MyData&gt; myData</code>, the item's UUID is also added to <code>private SomeStructure&lt;UUID&gt; myDataIndex</code>. I think this is a performance consideration, not generating an ArrayList or something else when I get element by index.</p> <p>Any ideas about this <code>SomeStructure</code>? I would appreciate more about a method that extends or implements known JAVA data structure. Of course, fully customized structure is also highly appreciated.</p> <p>To make you fully understand my question, I'd like to state my situation:</p> <ol> <li><p>why I have Map? I wanna get data by UUID.</p></li> <li><p>why I want SomeStructure? I wanna get data by index either.</p></li> </ol> <p>To make it simple: I want iterate my data through two different ways.</p> <p>Many thanks!</p>
1,495,880
0
<p>This usually means you are blocking the UI thread (e.g. running a long operation inside a button click handler). Instead of using the UI thread, you will generally need to offload long I/O operations to the <a href="http://msdn.microsoft.com/en-us/library/system.threading.threadpool.queueuserworkitem.aspx" rel="nofollow noreferrer">ThreadPool</a> or your own worker threads. This is not always easy to do and requires careful design and a good understanding of concurrency, etc.</p>
15,090,372
0
<p>I think you are looking for something like <a href="https://github.com/sephiroth74/AndroidWheel" rel="nofollow noreferrer">Android Wheel</a></p> <p><img src="https://i.stack.imgur.com/R9kiv.png" alt="enter image description here"></p>
1,520,985
0
What is a command line compiler? <p>What is a command line compiler?</p>
28,724,410
0
Emulator keep showing "Android" <p>I am new to android application. i have downloaded Android Studio from <a href="http://developer.android.com/" rel="nofollow noreferrer">http://developer.android.com/</a></p> <p>I just created one project and click on run button.</p> <p>but it just keep showing me from past 2 hours</p> <p>what should i do now ??</p> <p>is there any step by step instruction that i can follow?</p> <p><img src="https://i.stack.imgur.com/FGlsN.png" alt="jdkk"></p>
24,840,578
0
<p>You need to send the data out from the server code:</p> <pre><code>app.get('/content.json',function(req, res) { request("http://www.google.com", function(error, response, body) { res.send(body); }); }); </code></pre> <p><strong>Edit:</strong> As the JS client is expecting appication/json, you should set the response header sent from server as well:</p> <pre><code>res .header('Content-Type', 'application/json') .send(body); </code></pre>
10,496,625
0
<p>You should try creating "by hand" the missing folders into your newly created project, then you can use Import -> File system to add the missing files into the respective folders...</p>
5,638,175
0
<p>To stop the video from playing you need to make use of the keyboard commands the you tube player recognizes to control the player. They are limited...</p> <pre><code> Spacebar : Play / Pause Arrow Left : Jump back 10% in the current video Arrow Right: Jump ahead 10% in the current video Arrow Up : Volume up Arrow Down : Volume Down </code></pre> <p>So what you can do is use </p> <pre><code> SendMessage(FlashPlayer.Handle,WM_KEYDOWN,VK_SPACE,0); SendMessage(FlashPlayer.Handle,WM_KEYUP,VK_SPACE,0); </code></pre> <p>to fake a key press and get the youtube player to, in this example, pause or resume play.</p>
19,586,319
0
<p>Try this:</p> <pre><code>$("#divVZITab[tabindex='-1']").focus(); </code></pre>
5,246,782
0
<p>There is a simple way of doing this. </p> <ul> <li><p>if you have two different layouts for landscape and portrait then let the android handle all the stuff for you. i mean do not override methods onConfigurationChange() method unless strictly required and do not add android:configChanges="orientation". just make different folders for portrait mode and landscape mode. viz. layout and layout-land.... </p></li> <li><p>To save present state of views use bundle. whenever orientation changes android reload activity and call onCreate() method. This saved bundle is passed in onCreate() method. Now you can retrieve views' state from this bundle.</p></li> </ul> <p>now next question will be how to use this bundle. <a href="http://stackoverflow.com/questions/151777/how-do-i-save-an-android-applications-state">Then here is the quick example.</a> </p> <p>override onSavedInstanceState() method to save bundle. </p> <p>Thanks.</p>
15,765,640
0
search for files not accessed for x days <p>How can i find files in linux that was <strong>not</strong> accessed for X days?</p> <p>i found that command, but it will show fils that was views for the last x days</p> <pre><code>$ find /home/you -iname "*.pdf" -atime -60 -type -f </code></pre>
39,329,146
0
<p>When a server listens on a computer, it specifies a port it wants it's connections coming in from , so ports are important for setting up servers. This is useful as you can have multiple applications listening on different ports without the different applications accidentally talking to eachother. So you should decide on a port that isn't a standard( 80 is for HTTP for example) to exclusively use for you gameserver so the client knows which port to send the requests to.</p> <p>If you want to handle multiple connections at once the best thing to do is threading.</p>
19,518,717
0
<p>A simple way of generating a printable report from a Datagridview is to place the datagridview on a Panel object. It is possible to draw a bitmap of the panel.</p> <p>Here's how I do it.</p> <p>'create the bitmap with the dimentions of the Panel Dim bmp As New Bitmap(Panel1.Width, Panel1.Height)</p> <p>'draw the Panel to the bitmap "bmp" Panel1.DrawToBitmap(bmp, Panel1.ClientRectangle)</p> <p>I create a multi page tiff by "breaking my datagridview items into pages. this is how i detect the start of a new page:</p> <p>'i add the rows to my datagrid one at a time and then check if the scrollbar is active. 'if the scrollbar is active i save the row to a variable and then i remove it from the 'datagridview and roll back my counter integer by one(thus the next run will include this 'row.</p> <pre><code>Private Function VScrollBarVisible() As Boolean Dim ctrl As New Control For Each ctrl In DataGridView_Results.Controls If ctrl.GetType() Is GetType(VScrollBar) Then If ctrl.Visible = True Then Return True Else Return False End If End If Next Return Nothing End Function </code></pre> <p>I hope this helps</p>
6,235,398
0
DRY a large chunk of common code with two vastly different uses <p>I have a 'widget' that comprises an html/css block of code. It is a type of data layout, which I call the <b>'stack'</b>.</p> <p>The stack has bits of <code>.erb</code> (Ruby on Rails) embedded in it, which enters the data for each user.</p> <p>I need to include this stack in multiple places, where it needs to represent <b>different data from different models</b>.</p> <p>So, one stack might contain a field called <code>@company.name</code> and the other stack might contain <code>@project.name || "Unidentified Project"</code>.</p> <p>How does one refactor / organize this situation? Options that I can see:</p> <ol> <li>Have two separate <code>stacks</code>, which would introduce redundancy and inconsistency, but would be an obvious answer to the problem without limit to scenario-specific customization.</li> <li>Include <code>if</code> statements for every data point to test which circumstance the stack is being used for, but this is very code-ugly and unsustainably complicated for more than 2 stacks.</li> <li>Some unknown unknown.</li> </ol> <p>How would you tackle this?</p>
23,590,372
0
<p>Javascript doesn't support unicode properties in any way, you can't include "latin1 letter" in an expression directly and are bound to use ranges. <a href="http://en.wikipedia.org/wiki/Latin-1_Supplement_%28Unicode_block%29" rel="nofollow">Latin1-supplement block</a> contains letters in <code>C0-FF</code> except two math symbols at <code>D7</code> and <code>F7</code>, hence the expression is</p> <pre><code>/[A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]+/ </code></pre> <p>Note that this only supports west european letters. If you want to match any unicode letter, there's no way with JS regex other than manually enumerating all <code>Lu/Ll/Lm</code> ranges from the <a href="http://www.unicode.org/Public/UNIDATA/UnicodeData.txt" rel="nofollow">unicode database</a>.</p>
35,771,995
0
Page loads forever when using clusters with Nodejs / Expressjs <p>This is my application : app.js</p> <pre><code>/** Express **/ var express = require('express'); /** Create express application **/ var app = express(); /** Set application port **/ app.set('port', process.env.PORT || 3000); /** Set application view engine**/ var handlebars = require('express-handlebars').create({ defaultLayout: 'main', helpers: { section: function(name, options){ if(!this._sections) this._sections = {}; this._sections[name] = options.fn(this); return null; }, parrot: function(options){ return options.fn(this) + ' &lt;b&gt; parrot &lt;/b&gt;'; } } }); /*** Cluster Logger**/ app.use(function(req, res, next){ var cluster = require('cluster'); if(cluster.isWorker) console.log('CLUSTER: Worker %d received request.', cluster.worker.id); next(); }); /** home page**/ app.get('/', function(req, res){ res.send('Welcome !!'); }); /** about page**/ app.get('/about', function(req, res){ res.send('About us!'); }); /** contact page **/ app.get('/contact', function(req, res){ res.send('contact us here'); }); // startServer in export/direct mode function startServer(){ app.listen(app.get('port'), function(){ console.log('Parrot started in '+app.get('env')+' mode on http://localhost:'+ app.get('port')+ '; \n press Ctrl-C to terminate'); }); } if(require.main === module){ startServer(); }else{ module.exports = startServer; } </code></pre> <p>And this is parrot.js (with cluster include)</p> <pre><code>//import cluster var cluster = require('cluster'); //startWorker function startWorker(){ var worker = cluster.fork(); console.log('CLUSTER: Worker %d started', worker.id); } if(cluster.isMaster){ //in case the cluster is Master require('os').cpus().forEach(function(){ startWorker(); }); cluster.on('disconnect', function(worker){ console.log('CLUSTER: Worker %d disconnected from the cluster', worker.id); }); cluster.on('exit', function(worker, code, signal){ console.log('CLUSTER: Worker %d died with exit code %d (%s)', worker.id, code, signal); startWorker(); }); }else{ //in case cluster.isWorker (not master), run app directly require('./app.js')(); } </code></pre> <p>The problem, is that when I run <code>node app.js</code>, the app works just fine on <code>http://localhost:3000</code> ... and the page works great in the browser.</p> <p>When I run as a set of clusters (with <code>node parrot.js</code>), everything looks good in console:</p> <pre><code>CLUSTER: Worker 1 started CLUSTER: Worker 2 started Parrot started in development mode on http://localhost:3000; press Ctrl-C to terminate Parrot started in development mode on http://localhost:3000; press Ctrl-C to terminate </code></pre> <p>But, the page loads forever and nothing shows on the browser? I don't know what's the problem here. Sorry for my language for I'm a Node.js newbie.</p> <p>Thank you</p>
6,892,869
0
<p>I haven't found a way to do this that isn't a hack, but here's the simplest hack I could think of:</p> <pre><code>&lt;script type="text/javascript"&gt; function tweakWidthForScrollbar() { var db = document.body; var scrollBarWidth = db.scrollHeight &gt; db.clientHeight ? db.clientWidth - db.offsetWidth : 0; db.style.paddingRight = scrollBarWidth + "px"; } &lt;/script&gt; ... &lt;body onresize="tweakWidthForScrollbar()"&gt; </code></pre> <p>The idea is to detect whether the vertical scrollbar is in use, and if it is, calculate its width and allocate just enough extra padding for it.</p>
1,769,402
0
<ul> <li><p>you don't need to create a thread just to start timer in it. You can just start timer in your main thread. Its function will run on a thread from threadpool.</p></li> <li><p>I don't see why you need to create a thread for <code>start()</code> function. It needs to be run at least partially <em>before</em> your timer first work. So, you may execute <code>RegKeys = load.read(RegKeys);</code> (and probably other code from <code>start</code>) in main thread. if you insist on running it in separate thread, ensure that <code>RegKeys</code> is initialized. It can be done by, e.g. setting <code>ManualResetEvent</code> after initializing <code>RegKeys</code> and waiting for this <code>ManualResetEvent</code> in timer callback.</p></li> <li><p>You should stop timer on process exit.</p></li> <li><p>you need to wait for started thread's stopping using <code>Thread.Join</code> method or by waiting on some <code>WaitHandle</code> (<code>ManualResetEvent</code> e.g.) being set in thread on finish.</p></li> </ul>
31,918,497
0
How to verify a contextual condition when a method is called with Moq <p>I'm using Moq and I need to check a condition when a mock method is called. Into following example i try to read the Property1 property, but this could be any expression:</p> <pre><code>var fooMock = new Mock&lt;IFoo&gt;(); fooMock.Setup(f =&gt; f.Method1()) .Returns(null) .Check(f =&gt; f.Property1 == true) // Invented method .Verifiable(); </code></pre> <p>My final objective is to check if a condition is true when the method is called. How can I perform this?</p>
33,624,857
0
print png with zebra imz220 - android <p>I'm having an issue printing png assets to a zebra imz220 printer, its going to be used to print receipts from an android tablet and a logo is required to be printed at the top of the printout. when printing the image i get a string output instead of the image. I tried the following stackoverflow post as i cant seem to find any documentation on how to do it - <a href="http://stackoverflow.com/questions/26100430/print-image-via-bluetooth-printer-prints-string/29383314#">print image via bluetooth printer prints string</a> </p> <pre><code>package com.example.gareth.myzebraprinter; import android.content.res.AssetManager; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import com.zebra.sdk.comm.BluetoothConnection; import com.zebra.sdk.comm.Connection; import com.zebra.sdk.comm.ConnectionException; import com.zebra.sdk.graphics.ZebraImageFactory; import com.zebra.sdk.graphics.ZebraImageI; import com.zebra.sdk.printer.PrinterLanguage; import com.zebra.sdk.printer.ZebraPrinter; import com.zebra.sdk.printer.ZebraPrinterFactory; import com.zebra.sdk.printer.ZebraPrinterLanguageUnknownException; import com.zebra.sdk.util.internal.Base64; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; public class MainActivity extends AppCompatActivity { private ZebraPrinter zebraPrinter; private Connection connection; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); connect(); printTest(); } private void printTest(){ if(zebraPrinter != null){ try { InputStream inputStream = getAssets().open("ic_launcher.png"); ZebraImageI zebraImageI = ZebraImageFactory.getImage(BitmapFactory.decodeStream(inputStream)); zebraPrinter.printImage(zebraImageI,250,0,0,-1,false); } catch (IOException e) { e.printStackTrace(); } catch (ConnectionException e) { e.printStackTrace(); } // byte[] rcpt = "------------\n\r test test test".getBytes(); // try { // connection.write(rcpt); // } catch (ConnectionException e) { // Log.e("printTest",e.getMessage()); // } } } private void connect(){ connection = new BluetoothConnection("AC3FA41EF22E"); try { connection.open(); } catch (ConnectionException ex) { Log.e("connect","ConnectionException " + ex.getMessage()); mSleeper.sleep(1000); closeConnection(); } catch(Exception ex) { Log.e("connect","Exception "+ex.getMessage()); } try { zebraPrinter = ZebraPrinterFactory.getInstance(connection); PrinterLanguage pl = zebraPrinter.getPrinterControlLanguage(); Log.i("PrinterPanguage",pl.toString()); } catch (ConnectionException ex) { Log.e("connect","ConnectionException " + ex.getMessage()); zebraPrinter = null; mSleeper.sleep(1000); closeConnection(); } catch(Exception ex) { Log.e("connect","Exception " + ex.getMessage()); zebraPrinter = null; mSleeper.sleep(1000); closeConnection(); } } private void closeConnection(){ if(connection != null){ try { connection.close(); } catch (ConnectionException exx) { Log.e("closeConnection", exx.getMessage()); } } } } </code></pre>
10,068,013
0
Django-users is the user authentication api of Django.
8,822,764
0
Why will a Range not work when descending? <p>Why will <code>(1..5).each</code> iterate over <code>1,2,3,4,5</code>, but <code>(5..1)</code> will not? It returns the Range instead.</p> <pre><code>1.9.2p290 :007 &gt; (1..5).each do |i| puts i end 1 2 3 4 5 =&gt; 1..5 1.9.2p290 :008 &gt; (5..1).each do |i| puts i end =&gt; 5..1 </code></pre>
4,877,475
0
<p>Have a go with this:</p> <pre><code>$('&lt;span/&gt;', {'class': 'tt-icon-ent'}) .append( $('&lt;img/&gt;', {src: 'media/img/icon_ent_small_dark.png'}) ) .appendTo('tooltip-ent'); </code></pre>
2,561,300
0
<p><code>array_unique()</code> only supports multi-dimensional arrays in PHP 5.2.9 and higher.</p> <p>Instead, you can create a hash of the array and check it for unique-ness.</p> <pre><code>$hashes = array(); foreach($array as $val) { $hashes[md5(serialize($val))] = $val; } array_unique($hashes); </code></pre>
37,626,479
0
<p>I used Filype's answer and changed to a correct one as because it's showing error if you try to uncheck the last one. Here it is..</p> <pre><code>$(document).ready(function() { //append the total dollars display under activities and hide it until clicked var $TotalDollars = 0; var $TotalDollarsDisplay = $('&lt;div&gt;&lt;/div&gt;'); $('.activities').append($TotalDollarsDisplay); $($TotalDollarsDisplay).hide(); function updateTotal() { var total = $(".activities input:checkbox:checked"); if(total.length){ // Get the text from the parent total = total.map(function(idx, el) { return $(el).parent().text(); }) // convert the jquery object to an array .toArray() // extract the value from the string using regex .map(function(item) { var match = item.match(/\$(\d+)/); return parseInt(match[1]); }) // calculate the total with reduce .reduce(function(cur, next) { return cur + next; }); console.log(total); $TotalDollarsDisplay.text(total); $TotalDollarsDisplay.show(); } else{ $($TotalDollarsDisplay).hide(); } } //checkbox needs to show unique dates and times and disable duplicates $(".activities").find("input:checkbox").change(function() { //variables for activity input names var $jsFrameworks = $("input[name='js-frameworks']"); var $Express = $("input[name='express']"); var $jsLibs = $("input[name='js-libs']"); var $Node = $("input[name='node']"); var $MainConf = $("input[name='all']"); var $Npm = $("input[name='npm']"); var $BuildTools = $("input[name='build-tools']"); var $CheckedActivities = $(".activities").find('input:checkbox:checked').length; console.log($CheckedActivities); //Disable duplicate times scheduled if (($jsFrameworks).is(':checked')) { ($Express).prop('disabled', true); } else { ($Express).prop('disabled', false); } if (($Express).is(':checked')) { ($jsFrameworks).prop('disabled', true); } else { ($jsFrameworks).prop('disabled', false); } if (($jsLibs).is(':checked')) { ($Node).prop('disabled', true); } else { ($Node).prop('disabled', false); } if (($Node).is(':checked')) { ($jsLibs).prop('disabled', true); } else { ($jsLibs).prop('disabled', false); } //add up the total dollars for each activity //Adding the non duplicate workshops to the total updateTotal(); }); }); </code></pre>
34,540,856
0
<p>Length <em>is</em> taken into account, but not in the way you expect. In string comparison, the first characters of each string are compared to each other first. If they are equal, then the second characters are compared and so on. So in your example, the first characters to be compared are '1' and '8'. '8' is larger. </p> <p>If you had compared "10.72" against "1.87", the first characters would be equal, so the next thing would be to compare "0" against ".".</p> <p>If you want to compare numeric values, you have to convert the strings to their numeric representation, or else you would have to write your own comparator that would treat strings as numerics. I hope that sheds some light on it.</p>
27,831,529
0
<p>You need to find the <code>CrefSyntax</code> node that corresponds to the type name and then you can use <code>SemanticModel.GetSymbolInfo()</code> to get the <code>ISymbol</code> you want:</p> <pre><code>string code = @"namespace Foo { /// &lt;summary&gt;This is an xml doc comment &lt;see cref=""MyClass"" /&gt;&lt;/summary&gt; class MyClass {} }"; var tree = SyntaxFactory.ParseSyntaxTree(code); CrefSyntax cref = tree.GetRoot() .DescendantNodes(descendIntoTrivia: true) .OfType&lt;CrefSyntax&gt;() .FirstOrDefault(); var compliation = CSharpCompilation.Create("foo").AddSyntaxTrees(tree); var model = compliation.GetSemanticModel(tree); ISymbol symbol = model.GetSymbolInfo(cref).Symbol; </code></pre>
14,644,199
0
Multiple jQuery UI sliders updating the wrong values <p>I'm using the Wordpress Meta Box plug-in (<a href="https://github.com/rilwis/meta-box" rel="nofollow">https://github.com/rilwis/meta-box</a>) to place six jQuery UI sliders on a post page.</p> <p>Problem is that there must be an error in the jQuery that handles the sliders I can't find: everytime I put multiple sliders, it updates the value of the last slider in the page instead of the correct one. Works fine only with 1 slider in the page, or If I repeat the code six times (once for each class), which obviously I don't wanna do.</p> <p>Example:</p> <p>I move <strong>pm_slider_c1</strong> > Updates <strong>pm_rating_c6-label</strong> span</p> <p>Here's the JS code:</p> <pre><code>jQuery( document ).ready( function( $ ) { var id = null , el = null , input = null , label = null , format = null , value = null , update = null ; $( '.rwmb-slider' ).each( function( i, val ) { id = $( val ).attr( 'id' ); el = $( '#' + id ); input = $( '[name=' + id + ']' ); label = $( '[for=' + id + ']' ); format = $( el ).attr( 'rel' ); $( label ).append( ': &lt;span id="' + id + '-label"&gt;&lt;/span&gt;' ); update = $( '#' + id + '-label' ); if ( !$( input ).val() || 'undefined' === $( input ).val() || null === typeof $( input ).val() ) { $( input ).val( $( el ).slider( "values", 0 ) ); $( update ).text( "0" ); } else { value = $( input ).val(); $( update ).text( value ); } if ( 0 &lt; format.length ) $( update ).append( ' ' + format ); el.slider( { value: value, slide: function( event, ui ) { $( input ).val( ui.value ); $( update ).text( ui.value + ' ' + format ); } } ); } ); } ); </code></pre> <p>HTML OF A SINGLE SLIDER: </p> <pre><code>&lt;div class="rwmb-field rwmb-slider-wrapper"&gt; &lt;div class="rwmb-label"&gt; &lt;label for="pm_rating_c1"&gt;Rating: &lt;span id="pm_rating_c1-label"&gt;0&lt;/span&gt;&lt;!-- GENERATED FROM JS --&gt; &lt;/label&gt; &lt;/div&gt; &lt;div class="rwmb-input"&gt; &lt;div class="clearfix"&gt; &lt;div class="rwmb-slider" id="pm_rating_c1"&gt;&lt;/div&gt; &lt;input type="hidden" name="pm_rating_c1" value="0"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>It's four days I'm having a headache on this (I'm no jQuery expert), so any help would be much appreciated.</p> <p>Thanks guys</p>
16,916,663
0
<p>@igoru for your question in the comment use PHPDOC before function documentation </p> <pre><code> * @param {type} $variable {comment} **{@from body}** </code></pre> <p>that's <code>**{@from body}**</code> would make the variable sent by request body .</p> <p>if you wants to send it from php , use the following :</p> <pre><code>&lt;?php $data = array("name" =&gt; "Another", "email" =&gt; "[email protected]"); $data_string = json_encode($data); $ch = curl_init("http://restler3.luracast.com/examples/_007_crud/index.php/authors"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data_string)) ); $result = curl_exec($ch); echo($result); </code></pre>
19,073,297
0
String doesn't seem to overwrite .csv file. Why? <p>I've been writing a simple app drawing innitial values in from a .csv file, then adding to them and then trying to write the modified data back out to the same CSV file. The output in the terminal window suggests its working ok, but when I look at the file or access it from another boot (I'm testing this on Xcode's iPhone simulator), it doesn't seem to work. Can someone tell me where I'm going wrong? Here's my code: </p> <pre><code>-(IBAction)AddButtonPressed:(id)sender{ // Get the input from the input field and add it to the sum in the bank field float a = ([input.text floatValue]); float b = a+([earned.text floatValue]); // adding the old value of 'earned' text field to the value from the input field and update the interface earned.text = [[NSString alloc] initWithFormat:@"%4.2f",b]; // THIS IS THE BEGINNINGS OF THE CODE FOR WRITING OUT TO A .CSV FILE SO THAT DATA CAN BE USED LATER IN EXCEL NSString *path = [[NSBundle mainBundle] pathForResource:@"Income" ofType:@"csv"]; if ([[NSFileManager defaultManager] fileExistsAtPath:path]) { NSLog(@"found it"); NSString *contents = [[NSString alloc] initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil]; NSLog(@"string looks like this\: %@", contents); //set the contents of income to be the same as what's currently in income.csv [income setString:contents]; NSLog(@"income contains\: %@", income); //NEXT Apend income to add NSDATE, Textinput and the float value 'a' //Get the Date... NSDateComponents *components = [[NSCalendar currentCalendar] components: NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit fromDate:[NSDate date]]; NSInteger day = [components day]; NSInteger month = [components month]; NSInteger year = [components year]; //... And apend it into a readable string with a comma on the end NSString *theDate = [[NSString alloc] init]; theDate = [NSString stringWithFormat:@"%d.%d.%d", day,month,year]; NSLog(@"The Date is %@", theDate); //holder string till I get the text input wired up in the interface NSString *text = [[NSString alloc]init]; text = @"filler words"; //turn the float entered in the GUI to a string ready for adding to the 'income' mutable array NSString *amountAdded = [[NSString alloc]init]; amountAdded = [NSString stringWithFormat:@"%4.2f", a]; //format the final string and pass it to our 'income' NSMutable Array NSString *finalString = [[NSString alloc] init]; finalString = [NSString stringWithFormat:@"\n %@, %@, %@", theDate, text, amountAdded]; NSLog(@"final string is %@", finalString); [income appendString:finalString]; NSLog(@"income now reads %@", income); [income writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:nil]; NSLog(@"completed writing to income.csv which now reads %@", contents); } else{ NSLog(@"not a sausage"); } </code></pre>
32,811,819
0
<p>You can use <strong><a href="http://api.jquery.com/attr/" rel="nofollow"><code>attr()</code></a></strong> with callback to update inline css</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>$('#div1').attr('style', function(i, v) { return v.split(';') // split css value by `;` to get each property .filter(function(val) { // filtering values var str = $.trim(val.split(':')[1]); // getting property value and trimming to avoid spaces return !(str == 0 || str == 'none' || str == ''); // checking property value is 0, none or '' , based on this filtering is done }).join(';'); // joining splitted array and return back for updating style property });</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt; &lt;div id="div1" style="position: relative; font-size: 24px; left: 175px; width: 400px; height: 200px; top: 0; background-image: none; background-color: none; background-position: 50% 50%;"&gt;New Element&lt;/div&gt;</code></pre> </div> </div> </p>
2,185,157
0
<p>I'm not sure if this is the complete solution (what error are you getting?), but it's something that needs to be fixed: on the line <code>body :user =&gt; user</code>, the <code>user</code> variable is not defined. Do you mean to do <code>:user =&gt; @recipients</code>?</p>
509,083
0
<p>You don't even need to discuss it with management (though the situation you describe about it is far from ideal). It's like Design by Contract - I introduced it in previous code I worked in, just as part of the development process. Once it's in, and it works, trust me, noone will dare to remove it.</p> <p>Unit testing can also be seen as a <em>part</em> of development. Hence, if you have "20 days" for developing features A, B and C, you can typically include unit tests in your estimations for development itself.</p> <p>Making unit tests is surprisingly easy. Compared with multithreading problems or any sort of complex design, unit testing is very easy to grasp for any competent developer.</p> <p>You can read good literature about it (you have dozens of tutorials online) in, say, half a day, and start doing your first tests in the afternoon.</p> <p>Really - <strong>just do it!</strong></p>
26,972,115
0
<p>I tried to use <code>ShouldSerialize</code> in various ways and the best I could get to was <code>&lt;value /&gt;</code>, couldn't make him not serialize an array item basically.</p> <p>But using a custom property to filter out what you don't want would work.</p> <pre><code>[XmlIgnore] public List&lt;XmlPropertyValue&gt; Values { get; set; } [XmlElement("value")] public List&lt;XmlPropertyValue&gt; ValuesForSerialization { get { var bla = Values.Where(o =&gt; o.ShouldSerializeValue()).ToList(); return bla; } set { Values = value; } } </code></pre> <p>Tested, it works. It's not a neat solution and neither is anything that adds public members to your class (just like <code>ShouldSerializeValue</code>).</p> <p>According to some <a href="http://blogs.msdn.com/b/sowmy/archive/2008/10/04/serializing-internal-types-using-xmlserializer.aspx" rel="nofollow">sources</a> you could make <code>ValuesForSerialization</code> internal if you use <code>DataContractSerializer</code> instead of <code>XmlSerializer</code>.</p>
29,242,271
0
<p>You can either pass the object to the ng-click function:</p> <pre><code>&lt;div ng-repeat="record in records"&gt; &lt;button ng-click="play(record)"&gt;Play&lt;/button&gt; &lt;/div&gt; </code></pre> <p>or call a function on the record in the ng-click:</p> <pre><code>&lt;div ng-repeat="record in records"&gt; &lt;button ng-click="record.play()"&gt;Play&lt;/button&gt; &lt;/div&gt; </code></pre>
21,457,833
0
<p><strong>Spring 3.2 and newer provides support for session/request scoped beans for integration testing</strong></p> <pre><code>@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = TestConfig.class) @WebAppConfiguration public class SampleTest { @Autowired WebApplicationContext wac; @Autowired MockHttpServletRequest request; @Autowired MockHttpSession session; @Autowired MySessionBean mySessionBean; @Autowired MyRequestBean myRequestBean; @Test public void requestScope() throws Exception { assertThat(myRequestBean) .isSameAs(request.getAttribute("myRequestBean")); assertThat(myRequestBean) .isSameAs(wac.getBean("myRequestBean", MyRequestBean.class)); } @Test public void sessionScope() throws Exception { assertThat(mySessionBean) .isSameAs(session.getAttribute("mySessionBean")); assertThat(mySessionBean) .isSameAs(wac.getBean("mySessionBean", MySessionBean.class)); } } </code></pre> <p>References: </p> <ul> <li><a href="http://spring.io/blog/2012/11/07/spring-framework-3-2-rc1-new-testing-features/#request-and-session-scoped-beans">Request and Session Scoped Beans</a></li> <li><a href="https://jira.springsource.org/browse/SPR-4588">(SPR-4588)</a></li> <li><a href="http://stackoverflow.com/questions/2411343/request-scoped-beans-in-spring-testing">request scoped beans in spring testing</a></li> </ul>
8,315,444
0
<p>You are explicitly setting <code>receiver</code> to null inside <code>toggleButton.setOnClickListener</code> and in <code>onPause</code>:</p> <pre><code>receiver = null; </code></pre> <p>Try removing those lines and see if it fixes the issue</p>
40,096,751
0
<p>At JavaOne September 2016, the blog poster mentioned that there will be a supported Flight Recorder API in JDK 9, and that the unsupported API now available in JDK 8 will be removed. He also showed a slide with this text before his presentation:</p> <p>"The following is intended to outline our general product direction. It is intended for informational purposes only, and may not be included in any contract. It is not a commitment to deliver any material code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle's products remains at the sole discretion of Oracle."</p>
10,177,801
0
<p>You should try QT. It is pretty good framework for cross-platform development. The opensource version is free and very well maintained and has the LGPL license. That means you can sell your product as closed source but then you have to dynamically link to QT libraries. </p>
41,042,305
0
<p>Whenever I've faced this, the places to check are:</p> <ul> <li>Row Groups</li> <li>Column Groups</li> <li>Header text boxes for interactive sorting</li> </ul> <p>9 times out of 10 when I can't find it, it's in the interactive sorting on text boxes. <a href="https://i.stack.imgur.com/g1yUN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g1yUN.png" alt="Interactive Sorting"></a></p>
22,638,499
0
<p>simply use the Out-File cmd but DON'T forget to give an encoding type: -Encoding UTF8 so use it so:</p> <p>$log | Out-File -Append C:\as\whatever.csv -Encoding UTF8</p> <p>-Append is required if you want to write in the file more then once.</p>
29,543,966
0
<p>It could be as simple as that:</p> <pre><code>var openAccordionContent = function () { $('.accordion-content-button').on('click', function () { var $next_content = $(this).next('.accordion-content'); // Remove the class show from all the items, except the one // sitting next to the clicked one. $('.accordion-content').not($next_content).removeClass('show'); // Toggle the class show for the item which is sitting next // to the clicked one. $next_content.toggleClass('show'); }); }(); </code></pre> <p><a href="https://jsfiddle.net/MelanciaUK/vx2bguyp/12/" rel="nofollow">Demo</a></p>
11,501,002
0
django template content not showing up <p>In my views i have pointed my code to login.html >But the alert in the ready function or the content so f the body are not seen on the UI.What am i doing wrong here</p> <pre><code> {% extends "base/base.html" %} &lt;script&gt; $(document).ready(function() { alert('1'); }); &lt;/script&gt; some code here some code here some code here some code here some code here some code here &lt;b&gt;{{response_dict.yes}} testing and testing and testinf&lt;/b&gt; &lt;b&gt;{{a}}&lt;/b&gt; &lt;form action="/logon/" method="post" name="myform"&gt; {% csrf_token %} &lt;b&gt;Username&lt;/b&gt;&lt;input type="text" name="username" id="username"&gt;&lt;/input&gt; &lt;br&gt;&lt;b&gt;Password&lt;/b&gt;&lt;input type="password" name="password" id="password"&gt;&lt;/input&gt; &lt;b&gt;&lt;/b&gt;&lt;input type="submit" value="Submit"&gt;&lt;/input&gt; &lt;img src="/media/img/hi.png" alt="Hi!" /&gt; &lt;!-- This is working dude --&gt; &lt;img alt="Hi!" src="/opt/labs/lab_site/media/img/hi.png"&gt; &lt;/form&gt; </code></pre>
34,632,070
0
Kotlin documentation doesn't support tags like '<p>' well <p>I'm writing doc comments to describe a method.</p> <pre class="lang-css prettyprint-override"><code> /** * &lt;p&gt;necessary * &lt;p&gt;setType is to set the PendingIntend's request code&lt;/p&gt; */ </code></pre> <p>But it won't show the paragraphs. If I don't use the <code>&lt;p&gt;</code>, all the documentation is in a line without any break. It works in Java class but when it comes to Kotlin, I don't know how to deal with it.</p>
4,862,987
0
<p>No, this would allow to retrieve the contents of any URL, which would break some security policies. (This would be an equivalent of an ajax get request without same-domain checks.)</p> <p>However, since <code>foo.js</code> is on the same domain than the page you can fetch it with an ajax request. Example with jQuery:</p> <pre><code>$.get('foo.js', function(source_code) { alert('foo.js contains ' + source_code); }); </code></pre>
13,492,703
0
<p>Found the solution here works well: <a href="http://stackoverflow.com/questions/13032565/ios-6-address-book-empty-kabpersonphoneproperty">iOS 6 address book empty kABPersonPhoneProperty</a> "To retrieve all phone numbers you need to get all linked contacts and then look for phone numbers in that contacts."</p>
8,551,560
0
<p>I would suggest creating the CRUD operations from scratch rather than using scaffold. It'll improve your rails development skills and you don't have to worry about unnecessary generated code from the scaffold - create a sample scaffold if you like to give you a basis to work from.</p> <p>Alternatively you could 'destroy' the model and recreate in a scaffold, that wont take long at all.</p>
6,732,547
0
<p>Android 2.3, 2.3.1, 2.3.2 supports api 9. You are getting an error because you are using Android 2.1. Solution:- open AndroidManifest.xml file find and update line </p> <pre><code>&lt;uses-sdk android:minSdkVersion="9" /&gt; </code></pre> <p>to as shown below,</p> <pre><code> &lt;uses-sdk android:minSdkVersion="7" /&gt; </code></pre> <p>This will definitely solve your problem. </p>
23,979,407
1
Json module error for saving dictionary <p>I'm coding a program to oraganise my homework. I got an error while trying to save my dicts with json and i have no idea what to do. I'm really lost. Also I'm kind of a noob so don't post anything to complex if you can. Thanks Here's the error</p> <pre><code> Traceback (most recent call last): File "Homework.py", line 12, in &lt;module&gt; json.load(f1) File "F:\Software\Python\lib\json\__init__.py", line 268, in load parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw) File "F:\Software\Python\lib\json\__init__.py", line 318, in loads return _default_decoder.decode(s) File "F:\Software\Python\lib\json\decoder.py", line 343, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "F:\Software\Python\lib\json\decoder.py", line 361, in raw_decode raise ValueError(errmsg("Expecting value", s, err.value)) from None ValueError: Expecting value: line 1 column 1 (char 0) </code></pre> <p>If you want my whole code (not finished yet, it's missing a lot)</p> <pre><code>#insert date to rate urgency of the tasks #BLOCK 1:1 print("today's date, month(insert month number)") ThisMonth = input("&gt;&gt;&gt;") print("today's date, day(insert day number)") ThisDay = input("&gt;&gt;&gt;") #BLOCK 1:2 #import dictionaries import json with open('LessonOut.txt', 'r') as f1: json.load(f1) with open('ExercisesOut.txt', 'r') as f2: json.load(f2) with open('AssignmentOut.txt', 'r') as f3: json.load(f3) #BLOCK 1:5 #everything will be in a while true loop for it to run smoothly until stopped while True: Input = input('&gt;&gt;&gt;') #This is used to add a task #BLOCK 2:1 if Input == 'add': print('Name of task?') Name = input('&gt;&gt;&gt;') print('Description of task?') Desc = input('&gt;&gt;&gt;') print('Rate the time it takes you to do the task on a scale from 1 to 20') Time = input('&gt;&gt;&gt;') print('&gt;&gt;&gt;') Imp = input('&gt;&gt;&gt;') print("Rate how much you want to do it on a scale from 1 to 5 (1= want to do it, 5= don't want to") Want = input("&gt;&gt;&gt;") print("enter deadline (month)") TimeMonth = input("&gt;&gt;&gt;") print("enter deadline (day)") TimeDay = input("&gt;&gt;&gt;") print("what type of homework is it? (Lesson/Exercises/Assignment)") Type = input("&gt;&gt;&gt;") #determines what type of task it is and puts it in the right dictionary #BLOCK 2:2 #Used to calculate time left to finish assignment DayLeft = 0 if ThisMonth &gt; TimeMonth: TimeMonth = TimeMonth + 12 if ThisMonth == ( 1 or 3 or 5 or 7 or 8 or 10 or 12 ) and TimeDay &lt; ThisDay: ThisMonth = ThisMonth + 1 DayLeft = DayLeft + ( 31 - ThisDay ) elif ThisMonth == 1 or 3 or 5 or 7 or 8 or 10 or 12: ThisMonth = ThisMonth + 1 DayLeft = DayLeft + ( TimeDay - ThisDay ) #BLOCK 2:3 while ThisMonth &lt; TimeMonth: if ThisMonth == 1 or 3 or 5 or 7 or 8 or 10 or 12: ThisMonth = ThisMonth + 1 DayLeft = DayLeft + 31 elif ThisMonth == 4 or 6 or 9 or 11 or 16 or 18 or 21 or 23: ThisMonth = ThisMonth + 1 DayLeft = DayLeft + 30 elif ThisMonth== 2 or 14: ThisMonth = ThisMonth + 1 DayLeft = DayLeft + 28 #BLOCK 2:4 if Type == Lesson: Rating = Time + Imp + Want Lesson.update = {DayLeft:(Name,Desc,Rating,TimeDay,TimeMonth)} if Type == Exercises: Rating = Time + Imp + Want Exercises.update = {DayLeft:(Name,Desc,Rating,TimeDay,TimeMonth)} if Type == Assignment: Rating = Time + Imp + Want Assignment.update = {DayLeft:(Name,Desc,Rating,TimeDay,TimeMonth)} #BLOCK 5:1 if Input == 'quit': print ("are you sure you want to quit?") Input = input('&gt;&gt;&gt;') if Input == 'Yes' or 'yes' or 'y' or 'Y' or 'Yse' or 'yse': #BLOCK 5:2 #Save an output dictionaries with open('LessonOut.txt', 'w') as f1: json.dump(Lesson, f1) with open('ExercisesOut.txt', 'w') as f1: json.dump(Exercises, f1) with open('AssignmentOut.txt', 'w') as f1: json.dump(Assignment, f1) break break break </code></pre>
13,145,251
0
<p>Unhelpful jerks are a pleasure to work with. <a href="http://bobpowelldotnet.blogspot.fr/2012/10/monodroid-camera-preview-as-opengl.html" rel="nofollow">http://bobpowelldotnet.blogspot.fr/2012/10/monodroid-camera-preview-as-opengl.html</a></p>
2,131,769
0
using numbers in a string <p>Can I use numbers while using <code>String</code> data type?</p>
8,140,152
0
<p>It reminds me a little of the <a href="http://en.wikipedia.org/wiki/Knapsack_problem" rel="nofollow">http://en.wikipedia.org/wiki/Knapsack_problem</a> maybe that helps a bit.</p>
14,509,311
0
<p>This gets the job done visually:</p> <pre><code>&lt;Grid&gt; &lt;Image Source="{Binding MyImage}" /&gt; &lt;Image Source="{Binding MyWatermark}" /&gt; &lt;/Grid&gt; </code></pre> <p>Same answer as here: <a href="http://stackoverflow.com/a/14509282/265706">http://stackoverflow.com/a/14509282/265706</a></p>
37,862,569
0
DataTable row selection inside shiny module <p>I am trying to take this basic working shiny app and modularize it. This works:</p> <pre><code>shinyApp( ui = fluidPage( DT::dataTableOutput("testTable"), verbatimTextOutput("two") ), server = function(input,output) { output$testTable &lt;- DT::renderDataTable({ mtcars }, selection=list(mode="multiple",target="row")) output$two &lt;- renderPrint(input$testTable_rows_selected) } ) </code></pre> <p>I want to make this a module that will work for any data.frame</p> <pre><code># UI element of module for displaying datatable testUI &lt;- function(id) { ns &lt;- NS(id) DT::dataTableOutput(ns("testTable")) } # server element of module that takes a dataframe # creates all the server elements and returns # the rows selected test &lt;- function(input,output,session,data) { ns &lt;- session$ns output$testTable &lt;- DT::renderDataTable({ data() }, selection=list(mode="multiple",target="row")) return(input[[ns("testTable_rows_selected")]]) } shinyApp( ui = fluidPage( testUI("one"), verbatimTextOutput("two") ), server = function(input,output) { out &lt;- callModule(test,"one",reactive(mtcars)) output$two &lt;- renderPrint(out()) } ) </code></pre> <p>This gives me errors saying I am trying to use reactivity outside of a reactive environment. If I eliminate the return statement, it runs. Is there anyway to return the rows selected from a datatable in a shiny module? Any help would be appreciated.</p>
24,599,180
0
How to return the response from jQuery AJAX? <p>I am working with <code>bootstrapWizard</code> and need to submit a form each step.Submitting forms using ajax and validating the form in server.I need to pass the return value to <code>onNext</code> .But it is always return true.</p> <pre><code> $('#buyer_wizard').bootstrapWizard({ 'tabClass': 'form-wizard', onTabClick: function(tab, navigation, index) { return false; }, onNext: function(tab, navigation, index){ var url=$("#buyer_form_step"+index).attr('action'); var data=$("#buyer_form_step"+index).serialize(); $.ajax({ type: 'POST', url:url, data:data, async:false, success:function(data){ return data }, error: function(data) { // if error occured alert(JSON.stringify(data)); }, dataType:'json' }); } }); </code></pre> <p>onNext is true always and going to next screen even if the ajax return value is false. </p>
26,102,316
0
301 URL Redirection with value <p>I need help regarding URL redirection</p> <p>I want to set a affiliate url like <code>localhost/mysite/bussname/proname</code>, when a viewer will see this link and click it it will redirect to </p> <pre><code>localhost/mysite/mypage.php?bussinessname=bussname&amp;productname=proname </code></pre> <p>I already use this code </p> <pre><code>Redirect 301 localhost/mysite/bussname/pagname localhost/mysite/mypage.php?bussinessname=bussname&amp;productname=proname </code></pre> <p>It causes internal server URL.</p> <p>So, what will be the possible code in htaccess. Please help me, thanks in previous. </p>
17,690,872
0
My App Installs Two Applications - Android <p>Whenever I try to run my App, it installs two app in the emulator/device. I only want to Install my Main Activity, but the Splash Activity installs also. I know the problem is in the Manifest. Can anyone help me please? Here is my code:</p> <pre><code>&lt;activity android:name="com.android.upcurrents.launcher.SplashActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name="com.android.upcurrents.MainActivity" android:label="@string/app_name" /&gt; </code></pre>
9,728,807
0
<p>They should be, yes, because there is no more reference to that <code>channels</code> object nor the closure that contains it.</p> <p>GC is mostly dependent on the browser that implements it, though, so there's no guarantee it'll actually be done. <code>delete</code>ing each element is overkill, though.</p>
8,415,250
0
<p>did you check if you both server you can do this:</p> <pre><code>file_get_contents(__URL_AND_NOT_PATH_HERE__) </code></pre> <p>basically the first thing is to check an option called <strong>allow_url_fopen</strong></p>
20,667,445
0
<p>Well, as it turns out, if I insert a fake option group label it disables the truncating.</p> <p></p> <p><a href="http://stackoverflow.com/questions/19398154/how-to-fix-truncated-text-on-select-element-on-ios7">How to fix truncated text on &lt;select&gt; element on iOS7</a></p> <pre><code>&lt;select&gt; &lt;option selected="" disabled=""&gt;Select a value&lt;/option&gt; &lt;option&gt;Grumpy wizards make toxic brew for the evil Queen and Jack&lt;/option&gt; &lt;option&gt;Quirky spud boys can jam after zapping five worthy Polysixes&lt;/option&gt; &lt;option&gt;The wizard quickly jinxed the gnomes before they vaporized&lt;/option&gt; &lt;option&gt;All questions asked by five watched experts amaze the judge&lt;/option&gt; &lt;optgroup label=""&gt;&lt;/optgroup&gt; &lt;/select&gt; </code></pre>
10,185,405
0
<p>In jQuery,</p> <pre><code>$('#example').keypress(function(e) { var s = String.fromCharCode( e.which ); if ( s.toUpperCase() === s &amp;&amp; s.toLowerCase() !== s &amp;&amp; !e.shiftKey ) { alert('caps is on'); } }); </code></pre> <p>Avoid the mistake, like the backspace key, s.toLowerCase() !== s is needed.</p> <p><strong>You have try this code?</strong></p> <pre><code>function isCapslock(e){ e = (e) ? e : window.event; var charCode = false; if (e.which) { charCode = e.which; } else if (e.keyCode) { charCode = e.keyCode; } var shifton = false; if (e.shiftKey) { shifton = e.shiftKey; } else if (e.modifiers) { shifton = !!(e.modifiers &amp; 4); } if (charCode &gt;= 97 &amp;&amp; charCode &lt;= 122 &amp;&amp; shifton) { return true; } if (charCode &gt;= 65 &amp;&amp; charCode &lt;= 90 &amp;&amp; !shifton) { return true; } return false; } </code></pre>
18,088,595
0
<p>I think the main confusion here is the notion that that <code>main</code> is the first and last thing that happens in C++ program. Whilst it is [1] the first part of YOUR program, there is usually some code in the application that sets up a few things, parses command line arguments, opening/initialization of standard I/O (<code>cin</code>, <code>cout</code>, etc) and other such things, which happen BEFORE <code>main</code> is called. And <code>main</code> is essentially just another function, called by the C++ runtime functionality that does that "fix things up before <code>main</code>". </p> <p>So, when <code>main</code> returns, it goes back to the code that called it, which then cleans up the things that need cleaning up (closing standard I/O channels, and many other such things), before actually finishing up by calling some OS function to "terminate this process". As part of this "terminate this process" functionality is (in most OS's) a way to signal "success or failure" to the OS, so that some other process monitoring the application can determine "if all is well or not". This is where, eventually, the <code>0</code> (or <code>1</code> if you use <code>return 1;</code> in <code>main</code>) ends up. </p> <p>[1] If there are static objects with constructors that are part of the user's code, then these will be performed before any code in <code>main</code> [or at least, before any code in <code>main</code> that belongs to the user's application] is executed. </p>
25,212,096
1
Editing Original DataFrame After Making a Copy but Before Editing the Copy Changes the Copy <p>I am trying to understand how copying a pandas data frame works. When I assign a copy of an object in python I am not used to changes to the original object affecting copies of that object. For example:</p> <pre><code>x = 3 y = x x = 4 print(y) 3 </code></pre> <p>While <code>x</code> has subsequently been changed, y remains the same. In contrast, when I make changes to a pandas <code>df</code> after assigning it to a copy <code>df1</code> the copy is also affected by changes to the original DataFrame.</p> <pre><code>import pandas as pd import numpy as np def minusone(x): return int(x) - 1 df = pd.DataFrame({"A": [10,20,30,40,50], "B": [20, 30, 10, 40, 50], "C": [32, 234, 23, 23, 42523]}) df1 = df print(df1['A']) 0 10 1 20 2 30 3 40 4 50 Name: A, dtype: int64 df['A'] = np.vectorize(minusone)(df['A']) print(df1['A']) 0 9 1 19 2 29 3 39 4 49 Name: A, dtype: int64 </code></pre> <p>The solution appears to be making a deep copy with <code>copy.deepcopy()</code>, but because this behavior is different from the behavior I am used to in python I was wondering if someone could explain what the reasoning behind this difference is or if it is a bug.</p>
33,728,318
0
<p>The problem could be the browser. Do you use safari or another browser? Maybe updating the browser or trying it on a different iOS device will work? </p>
13,493,644
0
<p>Just an update for those coming here: I started to use LiteIDE X (x14.1) on Windows 7 and it works superbly. :-) Lightweight and efficient...</p>
11,488,045
0
<p>Not sure about Access but this is what I usually do in MySQL</p> <p><code>SELECT SUM(IF(handset_site_id IS NULL, 1, 0)) AS number_of_null_handsets</code> ...</p>
6,906,906
0
<p>Have you sniffed what is actually sent? I would expect the Apache code to escape the IAC, so you are really sending IAC-IAC-EL.</p> <p>You should be calling TelnetClient.sendCommand(EL).</p>
1,199,750
0
<p>I experienced this same situation a while back and created a small utility I called "InternalsVisibleToInjector". It uses ILDASM and ILASM to disassemble, modify, and reassemble and assembly with the assembly name of my selection added to the InternalsVisibleTo list for the target assembly. It worked quite well in my situation.</p> <p>I have posted the source code (VS 2008 C# WinForm) for the utility here:</p> <p><a href="http://www.schematrix.com/downloads/InternalsVisibleToInjector.zip" rel="nofollow noreferrer">http://www.schematrix.com/downloads/InternalsVisibleToInjector.zip</a></p> <p>This may not work if the assembly is signed. Please take all appropriate precautions (i.e. make a backup of the assembly before using this and ensure you are on solid legal ground, etc.) </p>
13,619,188
0
<p>You don't say precisely what you're trying to do, but I can say with a great deal of confidence you are doing it wrong. From your code, I'll guess that <code>emailTranscript.txt</code> contains a form letter and <code>nameAddresses.csv</code> contains the data to be substituted in. </p> <p>The biggest error, and the one I suspect is your problem, is that <code>-F</code> specifies the field separator. You want <code>-v</code>, to set a variable. </p>
40,880,537
0
How to transfer java Ajax Answer to my foreach loop <p><strong>AJAX</strong></p> <pre><code> &lt;script&gt; $(document).ready(function () { $('#selSclCatg').change(function () { var catId = $('#selSclCatg').val(); $.ajax({ type: 'post', url: 'CreateProCatFiltServlet', data: {datastr: catId}, success: function (pRotyp) { successmessage = 'Data was succesfully captured'; $("#successmessage").text(successmessage); }, error: function (e) { alert('Error: ' + e.message); } }); }); }); &lt;/script&gt; </code></pre> <p>How to transfer <code>function (pRotyp)</code> to <code>foreach</code> loop</p> <pre><code> &lt;p&gt; &lt;label for="SelSclName"&gt;Select Scale:&lt;/label&gt; &lt;select name="SelSclName" id="SelSclName"&gt; &lt;option&gt;Select Scale &lt;/option&gt; &lt;c:forEach items="${pRotyp}" var="at"&gt; &lt;option value="${at.protypid}"&gt;${at.protypnam}&lt;/option&gt; &lt;/c:forEach&gt; &lt;/select&gt; &lt;/p&gt; </code></pre>
24,701,038
0
<p>The standard way to send navigation parameters between pages in WP8 is to use</p> <pre><code>NavigationService.Navigate(new Uri("/MainPage.xaml?text=" + textBox1.Text, UriKind.Relative)); </code></pre> <p>Then check for the parameter on the OnNavigatedTo() Method on the page you have navigated to. </p> <pre><code>protected override void OnNavigatedTo(NavigationEventArgs e) { string settingsText = NavigationContext.QueryString["text"]; } </code></pre> <p>For Windows Phone 8.1 you no longer navigate using a URI. The approach is to use: </p> <pre><code>this.Frame.Navigate(typeof(MainPage), textBox1.Text); </code></pre> <p>Then on the loadstate for the page you are navigating to you can get the data by using:</p> <pre><code>private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { string text = e.NavigationParameter as string; } </code></pre> <p>Hope this helps.</p>