pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
902,941 | 0 | What's wrong with my ListView Callback retreiving subitems? <p>I'm trying to retrieve the SubItem in my ListView from another thread, but I keep getting the Item instead of the SubItem. I'm not sure how to code this properly. Below is the code I'm using:</p> <pre><code>Delegate Function lvExtractedCallback(ByVal x As Integer) As String Private Function lvExtracted(ByVal x As Integer) As String Static Dim lvName As String If Me.OptionsList.InvokeRequired Then Dim lvEC As New lvExtractedCallback(AddressOf lvExtracted) Me.Invoke(lvEC, (New Object() {x})) Else lvName = OptionsList.Items.Item(x).SubItems.Item(0).Text End If Return lvName End Function Private Sub GetSubItem() Dim subItemText as String For i as Integer = 0 to 15 subItemText = lvExtracted(x) Debug.Print subItemText Next End Sub </code></pre> <p>Any and all help appreciated!</p> <p>-JFV</p> |
39,994,037 | 0 | How to perform a POST request with session data to an endpoint within the server node js <p>I am working on <code>express</code> and I need to perform a POST request to an endpoint within the server. My code for this is :</p> <pre><code>request({ url : 'http://localhost:3000/api/oauth2/authorize', qs:{ transaction_id:req.oauth2.transactionID, user:req.user, client : req.oauth2.client }, headers:{ 'Authorization':auth, 'Content-Type':'application/x-www-form-urlencoded' }, method:'POST' },function(err,res,bo){ console.log("Got response with body :"+bo); }); </code></pre> <p><code>localhost</code> is the current server, this works properly but the session data is lost when i perform the POST request.<br> Is there any other way to perform a POST within the same server or to save the session data such that it is maintained after the POST?</p> |
33,444,158 | 0 | Codeigniter: specified word after url redirect to subfolfer <p>I have Codeigniter 3 project in root directory. I need to use it with kohana other project which is in subfolder (<code>admin</code>). I need to make redirect, when I will type <code>mysite.xyz/admin</code> that will redirect me to subfolder <code>admin</code>, where are kohana files: index.php etc.</p> <p>Now CodeIgniter think that <code>admin</code> is a controller.</p> <p>My .htacces file:</p> <pre><code><IfModule mod_rewrite.c> RewriteEngine On RewriteBase /projekty/folder/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L] RewriteRule admin/^(.*)$ /admin/ [L] </IfModule> <IfModule !mod_rewrite.c> ErrorDocument 404 /index.php </IfModule> </code></pre> <p>Have any ideas, how to solve that? I was trying to find some solutions, but no success.</p> <p>Here is Kohana .htaccess:</p> <pre><code>RewriteEngine On RewriteBase /projekty/folder/admin/ ###### Add trailing slash (optional) ###### RewriteCond %{REQUEST_METHOD} !POST RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [L,R=301,NE] RewriteCond %{REQUEST_METHOD} !POST RewriteRule ^(.*)home/u343855449/public_html/projekty/folder/admin/index.php/(.*)$ /$1$2 [R=301,L,NE] RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|media) RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ index.php?kohana_uri=$1 [L,QSA] </code></pre> |
13,906,894 | 0 | Checking then Adding items to QСompleter model <p>I am currently working on a code editor written in Qt,</p> <p>I have managed to implement most of the features which I desire, i.e. auto completion and syntax highlighting but there is one problem which I can't figure out.</p> <p>I have created a model for which the <code>QCompleter</code> uses, which is fine for things like html tags and c++ keywords such as <code>if else</code> etc.</p> <p>But I would like to add variables to the completer as they are entered by the user.</p> <p>So I created an event on the <code>QTextEdit</code> which will get the word (I know I need to check to make sure that it is a variable etc but I just want to get it working for now).</p> <pre><code>void TextEdit::checkWord() { //going to get the previous word and try to do something with it QTextCursor tc = textCursor(); tc.movePosition(QTextCursor::PreviousWord); tc.select(QTextCursor::WordUnderCursor); QString word = tc.selectedText(); //check to see it is in the model } </code></pre> <p>But now I want to work out how to check to see if that word is already in the <code>QCompleter</code>s model and if it isn't how do I add it?</p> <p>I have tried the following:</p> <pre><code>QAbstractItemModel *m = completer->model(); //dont know what to do with it now :( </code></pre> <p>Any help would be fantastic.</p> <p>Thank you.</p> |
28,842,405 | 0 | <p>This is an interesting problem because I googled for many, many hours, and found several people trying to do exactly the same thing as asked in the question.</p> <p>Most common responses:</p> <ul> <li>Why would you want to do that? </li> <li>You <strong>can not</strong> do that, you <strong>must</strong> fully qualify your objects names</li> </ul> <p>Luckily, I stumbled upon the answer, and it is brutally simple. I think part of the problem is, there are so many variations of it with different providers & connection strings, and there are so many things that could go wrong, and when one does, the error message is often not terribly enlightening.</p> <p>Regardless, here's how you do it:</p> <p>If you are using static SQL:</p> <pre><code>select * from OPENROWSET('SQLNCLI','Server=ServerName[\InstanceName];Database=AdventureWorks2012;Trusted_Connection=yes','select top 10 * from HumanResources.Department') </code></pre> <p>If you are using Dynamic SQL - since OPENROWSET does not accept variables as arguments, you can use an approach like this (just as a contrived example):</p> <pre><code>declare @sql nvarchar(4000) = N'select * from OPENROWSET(''SQLNCLI'',''Server=Server=ServerName[\InstanceName];Database=AdventureWorks2012;Trusted_Connection=yes'',''@zzz'')' set @sql = replace(@sql,'@zzz','select top 10 * from HumanResources.Department') EXEC sp_executesql @sql </code></pre> <p>Noteworthy: In case you think it would be nice to wrap this syntax up in a nice Table Valued function that accepts @ServerName, @DatabaseName, @SQL - you cannot, as TVF's resultset columns must be determinate at compile time. </p> <p>Relevant reading:</p> <p><a href="http://blogs.technet.com/b/wardpond/archive/2005/08/01/the-openrowset-trick-accessing-stored-procedure-output-in-a-select-statement.aspx" rel="nofollow">http://blogs.technet.com/b/wardpond/archive/2005/08/01/the-openrowset-trick-accessing-stored-procedure-output-in-a-select-statement.aspx</a></p> <p><a href="http://blogs.technet.com/b/wardpond/archive/2009/03/20/database-programming-the-openrowset-trick-revisited.aspx" rel="nofollow">http://blogs.technet.com/b/wardpond/archive/2009/03/20/database-programming-the-openrowset-trick-revisited.aspx</a></p> <p><strong>Conclusion:</strong><br> OPENROWSET is the only way that you can 100% avoid at least some full-qualification of object names; even with EXEC AT you still have to prefix objects with the database name.</p> <p>Extra tip: The prevalent opinion seems to be that OPENROWSET shouldn't be used "because it is a security risk" (without any details on the risk). My understanding is that the risk is only if you are using SQL Server Authentication, further details here:</p> <p><a href="https://technet.microsoft.com/en-us/library/ms187873%28v=sql.90%29.aspx?f=255&MSPPError=-2147217396" rel="nofollow">https://technet.microsoft.com/en-us/library/ms187873%28v=sql.90%29.aspx?f=255&MSPPError=-2147217396</a></p> <p><em>When connecting to another data source, SQL Server impersonates the login appropriately for Windows authenticated logins; however, SQL Server cannot impersonate SQL Server authenticated logins. Therefore, for SQL Server authenticated logins, SQL Server can access another data source, such as files, nonrelational data sources like Active Directory, by using the security context of the Windows account under which the SQL Server service is running. Doing this can potentially give such logins access to another data source for which they do not have permissions, but the account under which the SQL Server service is running does have permissions. This possibility should be considered when you are using SQL Server authenticated logins.</em> </p> |
20,262,402 | 0 | <p>Try this:</p> <pre><code>$title = explode('-', $title, 2); $title = trim($title[1]); </code></pre> <p>First you split the title in the two parts, than you keep only the last one removing all extra whitespaces.</p> <p>If you have at least <strong>PHP 5.4</strong>, you could do</p> <pre><code>$title = trim(explode('-', $title, 2)[1]); </code></pre> |
20,520,737 | 0 | <p>Although your device is capable of satisfying the usesdevice allocation, without a GPP or other ExecutableDevice, there is no place to run your component. There are two ways that allocation is performed when launching components:</p> <ul> <li>Satisfying usesdevice relationships</li> <li>Deciding on which device to deploy the executable</li> </ul> <p>Each implementation in the component's SPD has a list of dependencies that must be satisfied to run the entry point. Typically, for a C++ component, this will include the OS and processor type. Additional requirements can be defined based on the processing requirements of the component, such as memory or load average; these must be allocation properties known to the target device, just like with usesdevice. There is also an implicit requirement that the device selected for deployment should support the ExecutableDevice interface (there is slightly more nuance to it, but that's by far the most common case).</p> <p>When launching a waveform, the ApplicationFactory tries to allocate all required devices and select an implementation for each component in sequence. Each possible implementation is checked against all of the devices in the domain to see if there is a device that meets its dependencies. If so, the entry point for that implementation will be loaded onto the device and executed, and the ApplicationFactory moves on to the next component. If no suitable device can be found, it throws a CreateApplicationError, as you are seeing.</p> <p>For most cases, you can use the GPP device included with REDHAWK to support the execution of your components. You would usually only write your own ExecutableDevice if you have a specific type of hardware that does not work with GPP, like an FPGA. If you have installed from RPM, there should be a node tailored to your local system (e.g., processor type, Java and Python versions) in your $SDRROOT/dev/nodes directory. Otherwise you can create it yourself with the 'nodeconfig.py' script included with the GPP project; see the Ubuntu installation guide for an example (admittedly, somewhat buried in the REDHAWK Manual, Appendix E, Section 5).</p> |
24,520,610 | 0 | JavaScript upload multiple images <p>I have 2 upload buttons on same admin page (wordpress). Separately, they works perfect. But together, they don't work as it should. I'm sure it's from the JavaScript file because if I remove the code lines from one button, the other one works.</p> <pre><code>jQuery(document).ready(function($){ $('#upload_logo_button').click(function() { tb_show('Upload a logo', 'media-upload.php?referer=wptuts-settings&amp;type=image&amp;TB_iframe=true&amp;post_id=0', false); return false; }); window.send_to_editor = function(html) { var image_url = $('img',html).attr('src'); $('#logo_url').val(image_url); tb_remove(); $('#upload_logo_preview img').attr('src',image_url); $('#submit_options_form').trigger('click'); } $('#upload_banner_button').click(function() { tb_show('Upload a banner', 'media-upload.php?referer=wptuts-settings&amp;type=image&amp;TB_iframe=true&amp;post_id=0', false); return false; }); window.send_to_editor = function(html) { var img_url = $('img',html).attr('src'); $('#banner_url').val(img_url); tb_remove(); $('#upload_banner_preview img').attr('src',img_url); $('#submit_options_form').trigger('click'); } }); </code></pre> <p>Thanks!</p> |
18,781,633 | 0 | <p>Look at your AndroidManifest.xml file.</p> <p>In application: Remove android:theme="@style/AppTheme" </p> <p>In activity: Add android:screenOrientation ="landscape" or add android:screenOrientation ="portrait"</p> |
34,918,843 | 0 | <p>This error tells you that you do not have a user with an <code>id</code> of 8.</p> <p>Open your browser developer tools and clear the sessions/cookies and try again, in <strong>chrome</strong> you will find those under <strong>Resources</strong> tab.</p> |
736,981 | 0 | How do I deal with "Project Files" in my Qt application? <p>My Qt application should be able to create/open/save a single "Project" at once. What is the painless way to store project's settings in a file? Should it be XML or something less horrible?</p> <p>Of course data to be stored in a file is a subject to change over time.</p> <p>What I need is something like <code>QSettings</code> but bounded to a <strong>project</strong> in my application rather than to the whole application.</p> |
38,106,764 | 0 | <p>You can do this for clear cache : </p> <pre><code> CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeAllCookie(); CookieSyncManager.getInstance().sync(); mAuthContext.getCache().removeAll(); </code></pre> |
32,084,979 | 0 | <p>You can use either, but <code>fabric.api</code> is specifically the better option. This is because it's where the other fabric modules are imported for simplicity's sake. See here:</p> <pre><code>$ cat fabric/api.py (env: selenium) """ Non-init module for doing convenient * imports from. Necessary because if we did this in __init__, one would be unable to import anything else inside the package -- like, say, the version number used in setup.py -- without triggering loads of most of the code. Which doesn't work so well when you're using setup.py to install e.g. ssh! """ from fabric.context_managers import (cd, hide, settings, show, path, prefix, lcd, quiet, warn_only, remote_tunnel, shell_env) from fabric.decorators import (hosts, roles, runs_once, with_settings, task, serial, parallel) from fabric.operations import (require, prompt, put, get, run, sudo, local, reboot, open_shell) from fabric.state import env, output from fabric.utils import abort, warn, puts, fastprint from fabric.tasks import execute </code></pre> <p><code>fabric.api</code> is importing <code>fabric.operations.reboot</code> for you already.</p> |
17,609,748 | 0 | Import some csv column data into SQL Server 2008 R2 (programmatically) <p>I'd like to insert CSV data into a SQL Server database at one time. I know about <a href="http://stackoverflow.com/questions/14594072/importing-a-csv-file-using-bulk-insert-command-into-sql-server-table">BULK INSERT</a> but I <strong>need to select some fields only</strong>. So I try <code>INSERT INTO</code> like below -</p> <pre><code>try { OleDbConnection myOleDbConnection = new OleDbConnection("Provider=SQLOLEDB;Data Source=ServerName;Integrated Security=SSPI;Initial Catalog=DBName;User ID=sa;Password=password"); myOleDbConnection.Open(); string strSQL = null; strSQL = "INSERT INTO " + strTable + "(" + M_ItemCode + "," + M_ItemDesc + "," + M_UOM + ") " + "SELECT " + M_ItemCode + "," + M_ItemDesc + "," + M_UOM + " FROM [Text;DATABASE=E:\temp\\Item.csv]" ; OleDbCommand cmd = new OleDbCommand(strSQL, myOleDbConnection); return (cmd.ExecuteNonQuery() == 1); } catch (Exception ex) { Common.ShowMSGBox(ex.Message, Common.gCompanyTitle, Common.iconError); return false; } </code></pre> <p>I got the error </p> <blockquote> <p>Invalid object name 'Text;DATABASE=E:\temp\Item.csv'.</p> </blockquote> <p>Is my syntax wrong?</p> |
25,540,407 | 0 | Summarize a list of Haskell records <p>Let's say I have a list of records, and I want to summarize it by taking the median. More concretely, say I have</p> <pre><code>data Location = Location { x :: Double, y :: Double } </code></pre> <p>I have a list of measurements, and I want to summarize it into a median <code>Location</code>, so something like:</p> <pre><code>Location (median (map x measurements)) (median (map y measurements)) </code></pre> <p>That is fine, but what if I have something more nested, such as:</p> <pre><code>data CampusLocation = CampusLocation { firstBuilding :: Location ,secondBuilding :: Location } </code></pre> <p>I have a list of <code>CampusLocation</code>s and I want a summary <code>CampusLocation</code>, where the median is applied recursively to all fields. </p> <p>What is the cleanest way to do this in Haskell? Lenses? Uniplate?</p> <p>Edit: Bonus:</p> <p>What if instead of a record containing fields we want to summarize, we had an implicit list instead? For example:</p> <pre><code>data ComplexCampus = ComplexCampus { buildings :: [Location] } </code></pre> <p>How can we summarize a <code>[ComplexCampus]</code> into a <code>ComplexCampus</code>, assuming that each of the <code>buildings</code> is the same length?</p> |
6,764,030 | 1 | Using policykit+dbus instead of gksu to run graphical application <p>I'm searching for a command that does gksu or beesu job, but depends on policykit.</p> <p>The policykit and dbus documentation is somehow very complicated and not clear.</p> <p>I found "pkexec" but it shows errors when trying to run a graphical application</p> <pre><code>pkexec gedit </code></pre> <p>results:</p> <pre><code>(gedit:7243): Gtk-WARNING **: cannot open display: </code></pre> |
32,644,736 | 0 | PHP $_GET file not retrieving data from a mysql database <p>I have PHP scripts that are trying to read data from my mysql database. The first script called news.php reads data from some of the rows in my database and displays it in summary form. It also generates a unique hyperlink for each article that someone can click on and be taken to read the full article.</p> <p>This is the news.php that retrieves a summary from my database</p> <pre><code><?php // connection string constants define('DSN', 'mysql:dbname=mynewsdb;host=localhost'); define('USER', 'myadmin'); define('PASSWORD', 'pwd2015'); // pdo instance creation $pdo = new PDO(DSN, USER, PASSWORD); // query preparation $stmt = $pdo->query(" SELECT title, introtext, id, created, created_by, catid FROM mynews_items "); // fetching results $result = $stmt->fetchAll(PDO::FETCH_ASSOC); // if this returns 0 then it means no records are present echo count($result) . "\n"; // the loop should print valid table foreach ($result as $index => $row) { if ($index == 0) echo '<table>'; echo <<<HTM <tr> <td> <span class="post-date">{$row['created']}</span> </td> </tr> <tr> <td> <h2 class="blog-post-title">{$row['title']}</h2> </td> </tr> <tr> <td> <p> {$row['introtext']} </p> </td> </tr> <tr> <td> <p> <a href='read.php?id={$row['id']}'><input type="button" value="Read More" /></a> </p> </td> </tr> <tr> <td> <div class="blog-meta"> <img src="img/avatar.png" alt="Avatar" /> <h4 class="blog-meta-author">{$row['created_by']}</h4> <span>Category: {$row['catid']}</span> </div> </td> </tr> HTM; if ($index == (count($result)-1)) echo '</table>'; } </code></pre> <p>When you click on the hyperlink generated by <code><a href='read.php?id={$row['id']}'><input type="button" value="Read More" /></a></code> the read.php script should retrieve and show the full article from my database. The field storing the articles is named <code>fulltext</code></p> <p>This is the read.php file</p> <pre><code> <?php // connection string constants define('DSN', 'mysql:dbname=mynewsdb;host=localhost'); define('USER', 'myadmin'); define('PASSWORD', 'pwd2015'); // pdo instance creation $pdo = new PDO(DSN, USER, PASSWORD); // query preparation $stmt = $pdo->query(" SELECT fulltext FROM mynews_items "); echo htmlspecialchars($_GET["fulltext"]); ?> </code></pre> <p>Can someone point out the mistake I am making on my read.php file because it loads as a blank page without any data.</p> <p><strong>UPDATED read.php</strong> This is the updated file which is still returning a blank page. Can anyone point out any mistake?</p> <pre><code><?php $id = $_GET['id']; if(isset($_GET['id'])) // connection string constants define('DSN', 'mysql:dbname=mynewsdb;host=localhost'); define('USER', 'myadmin'); define('PASSWORD', 'pwd2015'); // pdo instance creation $pdo = new PDO(DSN, USER, PASSWORD); // query preparation // $stmt = $pdo->query("SELECT id, fulltext FROM fm16p_k2_items WHERE id='{$row['id']}'", PDO::FETCH_ASSOC); { $sql = mysql_query("SELECT fulltext * FROM fm16p_k2_items WHERE id = '{$id}'"); $row = mysql_fetch_object($sql); } echo $row->fulltext; ?> </code></pre> |
3,104,207 | 0 | <p>From ActionScript, </p> <pre><code>var result:String = ExternalInterface.call("eval", "navigator.userAgent"); </code></pre> <p>which gets the value for the browser name, stores it in result.</p> |
26,564,099 | 0 | <p>The bulk insert on row 4 includes a value NULL, but I think that SQL Server interprets this as string containing 'NULL'. You can try to change row 4 with that :</p> <pre><code>106|Sam Clark|52|11|VP Sales|06/14/88||275000.00|299912.00 </code></pre> <p>You will also have the same problem on row 7, your column <code>Quota</code> which expects a MONEY type, but a string containing NULL is provided.</p> |
22,014,214 | 0 | How to add captions to Youtube video with html5 programmatically? <p>I have an application and in that application there is a requirement to play videos using yuotube video player with html5.</p> <p>Can you please share any idea that would useful for me...?</p> <p>Thanks in advance....</p> |
23,691,507 | 0 | <p>figured it out with an apple example they wrap their add a tableViewController to a UIView by adding the tableViewController as a childViewController of the UIView or if you are using storyboard u can use the container view</p> |
11,320,499 | 0 | How to allow users to share videos on my website securely <p>Just finished an awesome book on Web App Security, and I've got a security question. I'd like to allow users to share videos on my website. I don't have a problem restricting them to youtube and vimeo embedding, saves me the storage anyways, but I don't want untrusted code running on site.</p> <p>So, what's the best way to do this?</p> <p>FYI, I'm using express.js on top of node.js and couchdb for a database.</p> |
78,899 | 0 | <p>One thing to keep in mind about using the same <strong>TDataSet</strong> between multiple threads is you can only read the current record at any given time. So if you are reading the record in one thread and then the other thread calls <strong>Next</strong> then you are in trouble.</p> |
708,461 | 0 | <p>Don't sell management on a particular approach; that's just going to be difficult and isn't really going to buy you much. Whether or not your management chain appreciates unit tested code doesn't matter. </p> <p>Sure, unit testing your code has a lot of benefits associated with it, but don't rely on management buy-off to write your tests. When people start seeing results, they'll flock towards The Right Thing. </p> |
37,222,388 | 0 | <p>(Disclaimer: This is a good question even for people that do not use Bluebird. I've posted a similar answer <a href="http://stackoverflow.com/a/37222332/558639">here</a>; this answer will work for people that aren't using Bluebird.)</p> <h3>with chai-as-promised</h3> <p>Here's how you can use chai-as-promised to test both <code>resolve</code> and <code>reject</code> cases for a Promise:</p> <pre><code>var chai = require('chai'); var expect = chai.expect; var chaiAsPromised = require("chai-as-promised"); chai.use(chaiAsPromised); ... it('resolves as promised', function() { return expect(Promise.resolve('woof')).to.eventually.equal('woof'); }); it('rejects as promised', function() { return expect(Promise.reject('caw')).to.be.rejectedWith('caw'); }); </code></pre> <h3>without chai-as-promised</h3> <p>You can accomplish the same without chai-as-promised like this:</p> <pre><code>it('resolves as promised', function() { return Promise.resolve("woof") .then(function(m) { expect(m).to.equal('woof'); }) .catch(function(m) { throw new Error('was not supposed to fail'); }) ; }); it('rejects as promised', function() { return Promise.reject("caw") .then(function(m) { throw new Error('was not supposed to succeed'); }) .catch(function(m) { expect(m).to.equal('caw'); }) ; }); </code></pre> |
38,335,316 | 0 | Can not convert RDD to sequence <p>I have a variable <code>rawData</code> of type <code>DataFrame</code>. I want to get all the elements of a column and convert them to a Scala <code>Seq</code>.</p> <pre><code>val res = rawData.map(x => x(0)).toSeq </code></pre> <p>However, I am getting the following error:</p> <pre><code>Error:(114, 40) value toSeq is not a member of org.apache.spark.rdd.RDD[Any] val res = rawData.map(x => x(0)).toSeq </code></pre> <p>So <code>rawData.map(x => x(0))</code> is of type <code>RDD[Any]</code>. How can I convert that to a <code>Seq</code>?</p> |
15,486,142 | 0 | How to iterate over a node list and get child elements? <p>I have some XML like this:</p> <pre><code><?xml version="1.0" encoding="UTF-8"?> <person> <version>1.1</version> <lname>xxxx</lname> <fname>yyyy</fname> <address> <city>zzzz</city> <state>ffff</state> <country>aaaa</country> <address> <dob>xx-xx-xxxx</dob> <familymembers> <father> <fname>bbbb</fname> <lname>dddd</lname> </father> <mother> <fname>zzzz</fname> <lname>aaaa</lname> </mother> <sibling> <fname>bbbb</fname> <lname>dddd</lname> </sibling> </familymembers> </person> </code></pre> <p>My requirement is that all child elements should be traversed and placed inside a map as key-value pairs like this:</p> <pre><code>persion.version --> 1.1 persion.lname --> xxxx persion.fname --> yyyy person.address.city --> zzzz person.address.state --> ffff person.address.country --> aaaa person.familymembers.father.fname --> bbbb person.familymembers.father.lname --> dddd person.familymembers.mother.fname --> zzzz person.familymembers.mother.lname --> aaaa person.familymembers.sibling.fname --> bbbb person.familymembers.sibling.lname --> dddd </code></pre> |
30,161,211 | 0 | <p>By clicking the delete button you need to call <code>delete(position);</code> and write your code like this.</p> <pre><code>public void delete(int position) { AlertDialog dialog = new AlertDialog.Builder(this) // .setIcon(R.drawable.mainicon) .setTitle("") .setMessage("Are You Sure You Want to Delete " + "?") .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { try { mDatabase.open(); mDatabase.delSecRec(ItemsList.get(position) .getItemID()); mDatabase.close(); refreshList(); } catch (Exception e) { } } }) .setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).show(); } </code></pre> <p>To refresh your adapter you need to call this method.</p> <pre><code>private void refreshList() { db.open(); ItemsList = db.getAllItems(); db.close(); if (ItemsList != null) { setAdapterList(); } else { ShowMessage.show(ViewMyThings.this, "No Record found yet !!!"); } mListView.setAdapter(mAdapter); } </code></pre> <p>Hope you will get idea from this code.</p> |
35,002,269 | 0 | Setting StatusCode in error.aspx triggers another Page_Load() <p>In <code>web.config</code>, the error page is set to <code>/errorpages/error.aspx</code></p> <pre><code><httpErrors errorMode="Custom" existingResponse="Replace" > <remove statusCode="500" subStatusCode="-1" /> <error statusCode="500" path="/errorpages/error.aspx" responseMode="ExecuteURL" /> </httpErrors> </code></pre> <p>But when the page <code>/errorpages/error.aspx</code> is loaded in the browser, the status code is 200. This results in various problems, like the fact that when I have a JS file that's in the wrong URL, instead of getting a specific error, I get a JS error like <code>unexpected <</code> (same logic is used for <code>404.aspx</code> page).</p> <p>So, to fix this, inside <code>error.aspx</code>, in <code>Page_Load()</code>, I set</p> <pre><code>Response.StatusCode = 500; </code></pre> <p>and the page is returned with 500 status code, which can be observed in the browser.</p> <p>The problem is that if I place a breakpoint inside <code>Page_Load()</code> in <code>/errorpages/error.aspx</code>, it is being hit twice. First time it enters the <code>StatusCode</code> is <code>200</code>, it sets it to <code>500</code>, so my suspicion is that IIS tries to handle that from <code>web.config</code>, it loads the page again. And again the <code>StatusCode</code> is <code>200</code>, and changes to <code>500</code>, but this time it doesn't trigger another execution.</p> <p>This is probably caused by the fact that the exceptions are being handled in Global.asax.cs, where after handling, this is executed:</p> <pre><code>Server.TransferRequest("/errorpages/error.aspx?someExceptionInfo=" + exceptionInfo); </code></pre> <p>So this diagram shows what I think is happening: <a href="https://i.stack.imgur.com/rmT2J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rmT2J.png" alt="error workflow"></a></p> <p>I <em>could</em> just set a status code instead of calling <code>TransferRequest</code>, and let IIS handle it, and pass the exception info via the Session. But I'm worried that at some point it might cause some kind of redirect loop or something on Production servers.</p> <p><strong>Question (one of them):</strong></p> <ul> <li>How do I ensure I won't get a redirect loop?</li> <li>How do I configure IIS to make error pages return a status code without actually writing <code>Response.StatusCode = ***</code>?</li> <li>How do I impede my application from repeating execution of the page when I set the <code>StatusCode</code>?</li> </ul> |
34,720,850 | 0 | <p><strong>Why I can't find the file on my device?</strong></p> <p>The file is created successfully but I can't find that on my device because the <code>dataDirectory</code> path which I indicates to create the file, is a private path and my device file manager doesn't have access to it (base on <a href="https://www.npmjs.com/package/cordova-plugin-file#android-file-system-layout">this table</a>). Actually <code>dataDirectory</code> is an <code>Internal Storage</code> option.</p> <blockquote> <p>Internal Storage: Store private data on the device memory.</p> <p>You can save files directly on the device's internal storage. By default, files saved to the internal storage are private to your application and other applications cannot access them (nor can the user). When the user uninstalls your application, these files are removed.(<a href="http://developer.android.com/guide/topics/data/data-storage.html#filesInternal">reference</a>)</p> </blockquote> <p><strong>How to create a public file?</strong> </p> <p>So, to create a file on my device that I can access it with the file manager, I have to use one of public path options like:<code>externalDataDirectory</code>. Before, I was thinking it is for storing files on an external SD Card that I had not on my phone, so I didn't test it. But testing it today, it creates the file on my internal device storage in <code>Android/data/<app-id>/files</code> path which is public and I can access it with device file manager.</p> <p>Actually the term <code>internal</code> and <code>external</code> was misleading for me while <code>external storage</code> can be a removable storage media (such as an SD card) or an internal (non-removable) storage(<a href="http://developer.android.com/guide/topics/data/data-storage.html#filesInternal">reference</a>).</p> |
33,391,234 | 0 | jQuery :has() equivalent using document.querySelector <p>As I wrote in the topic - I am looking for a jQuery :has() selector equivalent using document.querySelector.</p> <p>For example I would like to select all paragraphs that contains links:</p> <p>With jQuery it will be simple:</p> <pre><code>$("p:has(a)") </code></pre> <p>How to achieve that using javascript's document.querySelector?</p> <p>Thanks in advance.</p> |
26,498,760 | 0 | <p>The element doesn't necessarily have to have an ID.</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.getelementsbytagname(v=vs.110).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.getelementsbytagname(v=vs.110).aspx</a></p> <p>If that's the case, you should take a look at getting a collection via GetElementsByTagName and looping through - something along these lines:</p> <pre><code>Dim Elems As HtmlElementCollection Elems = WebBrowser1.Document.GetElementsByTagName("input") For Each elem As HtmlElement In Elems Dim nameValue As String = elem.GetAttribute("name") If nameValue.ToLower().Equals("email") Then elem.SetAttribute("value,", ID & "@hotmail.com") End If Next </code></pre> |
32,180,396 | 0 | <p>The example provided in the WebStorm help is for CoffeeScript compiler that has different command-line options. With TypeScript compiler use --sourceMap to generate source maps and --out to specify the output file. Here you can find information about TypeScript compiler and it's options: <a href="https://github.com/Microsoft/TypeScript/wiki/Compiler-Options" rel="nofollow">https://github.com/Microsoft/TypeScript/wiki/Compiler-Options</a> If you're using WebStorm 10, use a built-in TypeScript compiler instead of a file watcher.</p> |
28,361,845 | 0 | <p>You can do this with block approach,</p> <pre><code>let views: NSArray = scroller.subviews // 3 - remove all subviews views.enumerateObjectsUsingBlock { (object: AnyObject!, idx: Int, stop: UnsafeMutablePointer<ObjCBool>) -> Void in object.removeFromSuperview() } </code></pre> |
9,159,217 | 0 | <p>Use <code>__range</code>. You'll need to actually calculate the beginning and end of the week first:</p> <pre><code>import datetime date = datetime.date.today() start_week = date - datetime.timedelta(date.weekday()) end_week = start_week + datetime.timedelta(7) entries = Entry.objects.filter(created_at__range=[start_week, end_week]) </code></pre> |
40,384,993 | 0 | <p>Use the forecast package and use an ARIMAX function and specify the structure, it will be (1,0,0) in this case. The xreg argument will allow you to include additional covariates.</p> <p>It should look something like this..</p> <pre><code>library(forecast) fit <- Arima(y, order=c(1,0,0),xreg = x) </code></pre> |
32,796,895 | 0 | <p>This does sound like you're asking for opinion rather than a definitive answer - so....</p> <p>As someone who develops little fun apps and some work related tooling in VB6 (more of an interest/hobby, than anything else), my opinion is that it's perfectly fine to run in Win7 x64. I find it more convenient to run it on my main desktop than in a VM. However, I've also installed VB6 on a W2k3 VM as some more obscure bugs (often around MDAC) can't be fully tested/circumvented in Win7. </p> <p>Oh, and I always run the IDE As Administrator to avoid some other niggles</p> |
34,325,494 | 0 | Ionic app needs to hit server not localhost to login and to test on device <p>I need to test my ionic app on a device and I can't log in. </p> <p>I am using ionic view. <a href="http://view.ionic.io/" rel="nofollow">http://view.ionic.io/</a></p> <p>I can login with my app on the browser and on the emulator. I ran <code>ionic upload</code> and my app is now available to view on the app BUT I can't login. I get the alert messages I set up, "Invalid Credentials".</p> <p>I think the reason is because my API call to login is to the local server.</p> <p><code>Route::get('/api/login/{username}/{password}', 'ApiV2Controller@login_user_or_admin');</code></p> <p><strong>and on the browser...</strong> </p> <p><code>http://localhost/api/login/username/userpassword</code></p> <p><strong>and on my Ionic app this is what the $http get looks like..</strong></p> <pre><code>self.login = function(userLogin, userPw) { var deferred = $q.defer(); $http.get("http://localhost/api/login" + "/" + userLogin + "/" + userPw) .success(function(result) { console.log(result); if (!result.result) { deferred.resolve(false); return false; } UserService.save(result.data); console.log("Login Credentials Submitted Succesfully!"); deferred.resolve(true); return true; }).error(function(data) { alert('Something went wrong'); deferred.resolve(data); }) return deferred.promise; }; //login() </code></pre> <p>I think that's the code in need of updates or what I need to reference so that someone can help me out.</p> <p>How do I approach this issue? What gets fixed first? The route in the API from local host to the actual website address?</p> <p>I would appreciate some pointers as to what I need to know or how to approach this issue and perhaps what needs to be added or refactored. </p> <p>P.S. could this be related to my issue? <a href="http://blog.ionic.io/handling-cors-issues-in-ionic/" rel="nofollow">http://blog.ionic.io/handling-cors-issues-in-ionic/</a></p> |
26,721,875 | 0 | <p>CMD is not very flexible regarding data that it can operate on. Newlines fall under the category of special characters that are difficult to work with.</p> <p>This could be accomplished with PowerShell, which should be available on any recent version of Windows. There <em>is</em> an escape character in PoSH that could be used for this purpose (`n is a newline).</p> <pre><code>C:\> PowerShell -ExecutionPolicy Bypass -NoProfile -Command "perl sub.pl -param1 -param2 """-param3`n^""" -param4" '-param1' '-param2' '-param3 ' '-param4' </code></pre> <p>I don't have myprog.exe, so I used <code>sub.pl</code>:</p> <pre><code>print("'".join("'\n'",@ARGV)."'"); </code></pre> |
2,005,954 | 0 | Center a position:fixed element <p>I would like to make a <code>position: fixed;</code> popup box centered to the screen with a dynamic width and height. I used <code>margin: 5% auto;</code> for this. Without <code>position: fixed;</code> it centers fine horizontally, but not vertically. After adding <code>position: fixed;</code>, it's even not centering horizontally.</p> <p>Here's the complete set:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.jqbox_innerhtml { position: fixed; width: 500px; height: 200px; margin: 5% auto; padding: 10px; border: 5px solid #ccc; background-color: #fff; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code><div class="jqbox_innerhtml"> This should be inside a horizontally and vertically centered box. </div></code></pre> </div> </div> </p> <p>How do I center this box in screen with CSS?</p> |
634,013 | 0 | <p>If you are trying to return the script name, try:</p> <pre><code>Request.CurrentExecutionFilePath </code></pre> <p>and if you just wanted the script name without the path, you could use:</p> <pre><code>Path.GetFileName(Request.CurrentExecutionFilePath) </code></pre> <p><em>Path.GetFileName() requires the System.IO namespace</em></p> |
9,423,299 | 0 | <p>Guy's answer above seems to fix the problem compiling Ruby in RVM with XCode 4.2 installed completely, and removed for me to install GCC from <a href="https://github.com/kennethreitz/osx-gcc-installer" rel="nofollow">https://github.com/kennethreitz/osx-gcc-installer</a> . This is preferable for users needing to have both RVM and XCode 4.2 installed.</p> |
33,799,101 | 0 | <p>You don't have to save the modified object.</p> <p>Once setProperty has been called, your node property has been set in the current Transaction.</p> <p>The only thing you are missing here is to close the Transaction, check this (from <a href="http://neo4j.com/docs/stable/javadocs/" rel="nofollow">Neo4j Javadoc</a>) about <code>Transaction.close()</code>:</p> <blockquote> <p>Commits or marks this transaction for rollback, depending on whether success() or failure() has been previously invoked. All ResourceIterables that where returned from operations executed inside this transaction will be automatically closed by this method. This method comes from AutoCloseable so that a Transaction can participate in try-with-resource statements. It will not throw any declared exception. Invoking this method (which is unnecessary when in try-with-resource statement) or finish() has the exact same effect.</p> </blockquote> |
16,879,702 | 0 | <p>I think you have to Override this two Methods in <strong>GameFragment</strong> </p> <pre><code> @Override public void onAttach(Activity activity) { super.onAttach(activity); if (activity instanceof Listener ) { mListener = (Listener) activity; } else { throw new ClassCastException(activity.toString() + " must implemenet GameFragment.Listener"); } } @Override public void onDetach() { super.onDetach(); mListener= null; } </code></pre> <p>for more detail Read this <a href="http://www.vogella.com/articles/AndroidFragments/article.html" rel="nofollow">Tutorial</a></p> <p><strong>EDIT</strong></p> <p>And Don't Forget to Initialize Fragment in Activity</p> <blockquote> <pre><code> // Create an instance of GameFragment GameFragment mGameFragment= new GameFragment(); // Add the fragment to the 'fragment_container' Layout getSupportFragmentManager().beginTransaction() .add(R.id.fragment_container, mGameFragment).commit(); </code></pre> </blockquote> |
1,413,226 | 0 | <p>I'd do this:</p> <pre><code><script type="text/javascript"> $(document).ready(function(){ $('.box').hide(); $('#dropdown').change(function() { $('.box').hide(); $('#div' + $(this).val()).show(); }); }); </script> <form> <select id="dropdown" name="dropdown"> <option value="0">Choose</option> <option value="area1">DIV Area 1</option> <option value="area2">DIV Area 2</option> <option value="area3">DIV Area 3</option> </select> </form> <div id="divarea1" class="box">DIV Area 1</div> <div id="divarea2" class="box">DIV Area 2</div> <div id="divarea3" class="box">DIV Area 3</div> </code></pre> |
12,826,909 | 0 | Hiding Etag to use cache-control in jboss for static content <p>I need to disable Etag header in response so that I can set the cache-control to a large value for static content for a web app which does not get updated say in 6 months. I am using jboss. I found a way to create filter to add the cache-control header. is there a way to not set the etag, a setting in configuration file or using filter.</p> |
30,310,467 | 0 | <p>I was getting a similar error when the file used to create the output stream already had data. If you are looking to <strong>append</strong> data to the file, you must indicate so in the file output stream object:</p> <pre><code>FileOutputStream out = new FileOutputStream("/Users/muratcanpinar/Downloads/KNVBJ/build/classes/knvbj/ClubInformation.xlsx", true); </code></pre> <p>When you do this, <code>wb.write(out)</code> should work as expected.</p> |
35,507,868 | 0 | <p>GCM notifications work perfectly with debug APKs.</p> <p>There is something wrong in the client code or the server code.</p> <p>If you are getting a success response from Google server AND if you are able to see the logcat logs of the received GCM message in your GCM intent service then your server side code is working well and there is probably an error in the client code. If you receive a failure message from the the Google server or do not see logs, then the issue is in your server code.</p> <p>Note: You need to use the server key.</p> <p>You can use this <a href="http://techzog.com/development/gcm-notification-test-tool-android/" rel="nofollow">GCM Test Tool</a> as the server to test if your client is working or not.</p> |
15,236,773 | 0 | How do I prevent the CSS :after pseudo-element from overlapping other content? <p>I have a thumbnail gallery that I am trying to lay out using display:inline-block instead of floats so that I can use the :after pseudo to include a caption via attr(). The layout works but the :after "object" overlaps items "below" it.</p> <p>Here is my HTML:</p> <pre><code><div id="bg"> <div class="thumbs"> <a href="img.png" style="background-image:url('img.png')" title="This is the outside of the house." /></a> <a href="img.png" style="background-image:url('img.png')" title="This is another example of a description. This is another example of a description. This is another example of a description. This is another example of a description." /></a> <a href="img.png" style="background-image:url('img.png')" title="Here is yet another description." /></a> <a href="img.png" style="background-image:url('img.png')" title="Image 001" /></a> <a href="img.png" style="background-image:url('img.png')" title="Image 001" /></a> <a href="img.png" style="background-image:url('img.png')" title="Image 001" /></a> <a href="img.png" style="background-image:url('img.png')" title="Image 001" /></a> <a href="img.png" style="background-image:url('img.png')" title="Image 001" /></a> <a href="img.png" style="background-image:url('img.png')" title="Image 001" /></a> <a href="img.png" style="background-image:url('img.png')" title="Image 001" /></a> <a href="img.png" style="background-image:url('img.png')" title="Image 001" /></a> <a href="img.png" style="background-image:url('img.png')" title="Image 001" /></a> <a href="img.png" style="background-image:url('img.png')" title="Image 001" /></a> <a href="img.png" style="background-image:url('img.png')" title="Image 001" /></a> <a href="img.png" style="background-image:url('img.png')" title="Image 001" /></a> </div> </code></pre> <p>Here is my CSS:</p> <pre><code>.thumbs a{ width:120px; height:120px; display:inline-block; border:7px solid #303030; box-shadow:0 1px 3px rgba(0,0,0,0.5); border-radius:4px; margin: 6px 6px 40px; position:relative; text-decoration:none; background-position:center center; background-repeat: no-repeat; background-size:cover; -moz-background-size:cover; -webkit-background-size:cover; vertical-align:top; } .thumbs a:after{ background-color: #303030; border-radius: 7px; bottom: -136px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); color: #FFFFFF; content: attr(title); display: inline-block; font-size: 10px; max-width: 90px; overflow: auto; padding: 2px 10px; position: relative; text-align: center; white-space: no-wrap; } </code></pre> <p>Here is a fiddle showing an example: <a href="http://jsfiddle.net/befxe/9/" rel="nofollow">http://jsfiddle.net/befxe/9/</a></p> <p>As you can see, the second description overlaps the thumbnail that is below it. Is it possible to make it "push" the second row down (towards the bottom of the screen) automatically depending on the size of the :after content? I've tried setting both ".thumbs a" and ".thumbs a:after" to various display types (inline-block, block, etc.) and changing the positioning to no avail. I also tried to wrap the whole "a" in a div and changing the div's display types, but that didn't work either.</p> <p>Pseudo-elements like :before and :after seem like a great way to handle minor content additions like this, but their functionality in terms of layout is really confusing me as they don't seem to "work" like other DOM objects. (And for good reason, I suppose, as they aren't really DOM objects. :P)</p> <p>Any suggestions?</p> |
33,917,269 | 0 | Robots.txt Query String - Couldn't Disallow <p>I have url </p> <p><a href="http://www.website.com/shopping/books/?b=9" rel="nofollow">http://www.website.com/shopping/books/?b=9</a></p> <p>I have disallow /?b=9 from robots.txt</p> <p>as</p> <p>User-agent: * Disallow: /?b=9</p> <p>But when i test this from Google Webmaster Robots.txt Test Tools. </p> <p>Showing allowed while it should be display disallowed...</p> <p>Please tell any wrong with my robots.txt</p> <p>URL - <a href="http://www.website.com/shopping/books/?b=9" rel="nofollow">http://www.website.com/shopping/books/?b=9</a></p> <p>User-agent: * Disallow: /?b=9</p> <hr> <p>Also </p> <p>there /?b=9 this will be same in all cases and /shopping/books/ will be change with different category.</p> <p>How to Block this types of string ?</p> <p>Disallow: /?b=9 </p> <p>Is it correct ?</p> |
1,776,316 | 0 | <p>(big edit...) Playing with the code a bit more this seems to work:</p> <pre><code>import java.util.ArrayList; import java.util.List; public class Main { public static void main(final String[] argv) { final int startValue; final int iterations; final List<String> list; startValue = Integer.parseInt(argv[0]); iterations = Integer.parseInt(argv[1]); list = encodeAll(startValue, iterations); System.out.println(list); } private static List<String> encodeAll(final int startValue, final int iterations) { final List<String> allEncodings; allEncodings = new ArrayList<String>(); for(int i = 0; i < iterations; i++) { try { final int value; final String str; final String encoding; value = i + startValue; str = String.format("%06d", value); encoding = encoding(str); allEncodings.add(encoding); } catch(final BadNumberException ex) { // do nothing } } return allEncodings; } public static String encoding(String str) throws BadNumberException { final int[] digit; final StringBuilder s; digit = new int[10]; for(int i = 0; i < 6; i++) { digit[i] = Integer.parseInt(String.valueOf(str.charAt(i))); } digit[6] = ((4*digit[0])+(10*digit[1])+(9*digit[2])+(2*digit[3])+(digit[4])+(7*digit[5])) % 11; digit[7] = ((7*digit[0])+(8*digit[1])+(7*digit[2])+(digit[3])+(9*digit[4])+(6*digit[5])) % 11; digit[8] = ((9*digit[0])+(digit[1])+(7*digit[2])+(8*digit[3])+(7*digit[4])+(7*digit[5])) % 11; digit[9] = ((digit[0])+(2*digit[1])+(9*digit[2])+(10*digit[3])+(4*digit[4])+(digit[5])) % 11; // Insert Parity Checking method (Vandermonde Matrix) s = new StringBuilder(); for(int i = 0; i < 9; i++) { s.append(Integer.toString(digit[i])); } if(digit[6] == 10 || digit[7] == 10 || digit[8] == 10 || digit[9] == 10) { throw new BadNumberException(str); } return (s.toString()); } } class BadNumberException extends Exception { public BadNumberException(final String str) { super(str + " cannot be encoded"); } } </code></pre> <p>I prefer throwing the exception rather than returning a special string. In this case I ignore the exception which normally I would say is bad practice, but for this case I think it is what you want.</p> |
34,650,796 | 0 | nth not supported on this type exception setting up Elastisch connection <p>I'm trying to work through the [Elastisch tutorial] to create some test data in an ElasticSearch instance running on a VM.</p> <p>I am running this code:</p> <pre><code>(ns content-rendering.core (:require [clojurewerkz.elastisch.native :as esr] [clojurewerkz.elastisch.native.index :as esi])) (defn populate-test-data [] (let [conn (esr/connect "http://10.10.10.101:9200")] (esi/create conn "test"))) (populate-test-data) </code></pre> <p>And I am seeing the following exception when I try and execute the code in the namespace using either Cider in emacs or from a Leiningen repl:</p> <pre><code>Caused by java.lang.UnsupportedOperationException nth not supported on this type: Character RT.java: 933 clojure.lang.RT/nthFrom RT.java: 883 clojure.lang.RT/nth native.clj: 266 clojurewerkz.elastisch.native/connect core.clj: 7 content-rendering.core/populate-test-data core.clj: 10 content-rendering.core/eval5078 </code></pre> <p>If I require the Elastisch namespaces into a repl and run something like the following, it works fine:</p> <pre><code>(def conn (esr/connect "http://10.10.10.101:9200")) (esi/create conn "test") ; {:acknowledged true} </code></pre> <p>Any ideas what I'm missing here?</p> |
23,557,108 | 0 | <p>for non GNU sed (or with <code>--posix</code> option) where <code>|</code> is not available</p> <p>If TGG is not occuring or could be included</p> <pre><code>sed 's/T[AG][AG]$//' YourFile </code></pre> <p>if not</p> <pre><code>sed 's/T[AG]A$//;s/TAA$//' YourFile </code></pre> |
2,239,089 | 0 | create personal MySQL Database <p>What's a good way to approaching this? I would like to create a local database, just on my laptop (for now), so that I can teach myself some PHP and how to interact with databases.</p> <p>... preferably a free approach...</p> |
2,586,663 | 0 | Lablayout and Linairlayout <p>I am trying to make a app with the tuotrail of the developerspage, then I would like to display a main.xml in a tabview, instead the textview, wich in the tuotrail,is in the activity. How do I tell my tab in activity do display the main.xml?</p> <p>Thanks!</p> |
18,748,770 | 0 | <p>If you have a huge amount of "if" or if you want to put this information in a settings file then I would suggest you create a class to store this information.</p> <pre><code>Class FromTime ToTime Value values.Add(New Class(0, 499, .75)); values.Add(New Class(500, 999, .85)); values.Add(New Class(1000, 9999, 1)); </code></pre> <p>Then you loop each items in the collection</p> <pre><code>if(object.Time >= curItem.FromTime && object.Time <= curItem.ToTime) rate = curItem.Value; </code></pre> <p>You could always have nullable values or set -1 as infinite.</p> <pre><code>values.Add(New Class(-1, 0, 0)); values.Add(New Class(0, 499, .75)); values.Add(New Class(500, 999, .85)); values.Add(New Class(1000, -1, 1)); if((object.Time >= curItem.FromTime || curItem.FromTime == -1) && (object.Time <= curItem.ToTime || curItem.ToTime == -1)) rate = curItem.Value; </code></pre> |
9,312,322 | 0 | <p>You need to annotate the collection with <code>DataMember</code> or it will not get serialized at all. You will also need to annotate the <code>DataContract</code> with <code>KnownType(typeof(ChildCollection))</code> as otherwise it doesn't know what type of "thing" the <code>ICollection</code> is and therefore how to serialize it</p> <p>Similarly you will need to add <code>[DataMember]</code> to <code>Child_A</code> <code>Name</code> property or it will not get serialized</p> |
36,940,466 | 0 | <p>I faced the same situation and simply restarted Eclipse and no more 404 afterward</p> |
17,924,614 | 0 | <p>I'm pretty sure the problem is calling 'glGetString(GL_EXTENSIONS)' which has been deprecated in OpenGL 3.0 and removed in core profile 3.1. The correct approach is to (<a href="http://www.opengl.org/discussion_boards/showthread.php/165539-GL_EXTENSIONS-replacement">From OpenGL Forum</a>):</p> <pre><code>GLint n, i; glGetIntegerv(GL_NUM_EXTENSIONS, &n); for (i = 0; i < n; i++) { printf("%s\n", glGetStringi(GL_EXTENSIONS, i); } </code></pre> |
37,567,465 | 0 | Howe to delete table rows with text content <p>I try to delete each table row where td has class=feldtyp1 and the text content is <code><p>News</p></code>.</p> <p>I am already come so far that the whole row is deleted. Now I still need the query whether the cell with the class feldtyp1 containing textual content News</p> <p>Could someone help me?</p> <p><strong>Part of my source XML</strong></p> <pre><code><table class="feldtyp"> <tr> <td class="feldtyp1"><p>Feldtyp</p></td> <td class="feldtyp2"><p>Text</p></td> </tr> <tr> <td class="feldtyp1"><p>News</p></td> <td class="feldtyp2"><p>Text</p></td> </tr> </table> </code></pre> <p><strong>My current XLS deletes all rows</strong></p> <pre><code><xsl:output omit-xml-declaration="yes"/> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="tr|td[@class='feldtyp1']"/> <xsl:template match="tr|td[@class='feldtyp2']"/> </xsl:stylesheet> </code></pre> <p><strong>The desired result should look like this</strong></p> <pre><code><table class="feldtyp"> <tr> <td class="feldtyp1"><p>Feldtyp</p></td> <td class="feldtyp2"><p>Text</p></td> </tr> </table> </code></pre> |
17,015,812 | 0 | <p>Do you mean something like this?</p> <pre><code>List<Cabbage> = new ArrayList<Cabbage>(); // an arraylist that holds cabbages (good or otherwise) N_GOOD_CABBAGES = 10 //in a separate interface for(int j = 0; j < N_GOOD_CABBAGES; j++){ Cabbage good = new GoodCabbage(); // make a good cabbage cabbages.add(good); // add it to the list } </code></pre> |
32,874,108 | 1 | How to save photos using instagram API and python <p>I'm using the Instagram API to obtain photos taken at a particular location using the python 3 code below:</p> <pre><code>import urllib.request wp = urllib.request.urlopen("https://api.instagram.com/v1/media/search?lat=48.858844&lng=2.294351&access_token="ACCESS TOKEN") pw = wp.read() print(pw) </code></pre> <p>This allows me to retrieve all the photos. I wanted to know how I can save these on my computer. </p> <p>An additional question I have is, is there any limit to the number of images returned by running the above? Thanks!</p> |
1,916,758 | 0 | tomcat oracle datasource <p>I have apache tomcat 5.5.28 on my windows box and I am trying to deploy a web application (WAR) which works fine on other servers.</p> <p>However I am having trouble creating a datasource. I am not sure of the format. The db is oracle.</p> <p>Here is what I have in server.xml.</p> <pre><code> <GlobalNamingResources> <Environment name="simpleValue" type="java.lang.Integer" value="30"/> <Resource name="tomdb11" type="oracle.jdbc.pool.OracleDataSource" maxActive="4" maxIdle="2" username="tomdb11" maxWait="5000" driverClassName="oracle.jdbc.driver.OracleDriver" validationQuery="select * from dual" password="remotedb11" url="jdbc:oracle:thin:@dbserver:1521:orcl"/> <Resource auth="Container" description="User database that can be updated and saved" name="UserDatabase" type="org.apache.catalina.UserDatabase" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml"/> </GlobalNamingResources> </code></pre> <p>How do I access this in the web.xml where usually what I have which works in other servers is</p> <pre><code><context-param> <param-name>databaseUser</param-name> <param-value>tomdb11</param-value> </context-param> <context-param> <param-name>databasePassword</param-name> <param-value>tomdb11</param-value> </context-param> <context-param> <param-name>databaseSchema</param-name> <param-value>TOMDBADMINN11</param-value> </context-param> </code></pre> <p>Also am I missing something?</p> <p><strong>Edit</strong>: I get the following exception:</p> <pre><code>javax.naming.NameNotFoundException: Name tomdb11 is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:770) at org.apache.naming.NamingContext.lookup(NamingContext.java:153) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137) at javax.naming.InitialContext.lookup(Unknown Source) at com.taw.database.DatabaseService.<init>(DatabaseService.java:19) at com.taw.database.DatabaseServices.init(DatabaseServices.java:40) </code></pre> |
4,471,044 | 0 | <p>The 3.5 version of the Framework is sufficient. However, you will need the Crystal viewer control to view any Crystal report (assuming you are displaying Crystal reports to a user via a WinForms).</p> |
29,513,234 | 0 | PDE development: How to find out where a plugin from my target platform originates from? <p>In my eclipse project I have set a target platform via target definition file.</p> <p>I've noticed that a specific plug-in is present in two different versions: 1.7.9 and 1.7.2. I checked this by doing "Window -> Show View -> Plug-in Development -> Target Platform State" and search for the plug-in name.</p> <p>Both versions appear and they are located in <code>.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins</code></p> <p>I want to get rid of 1.7.2, but when I open the target definition file it does only refer to the 1.7.9 version:</p> <pre><code><unit id="slf4j.api" version="1.7.9"/> </code></pre> <p>How can I find out where the plug-in originates from, in order to get rid of it?</p> |
30,855,626 | 0 | <p>There are a couple problems with your flow.</p> <ol> <li><p>the Function node is not passing through the message object it received - it is returning a new message object with just the payload. This means the original request/response objects provided by the HTTP In node are not being passed through to the HTTP Response node. This means the flow cannot reply to the original request.</p></li> <li><p>the Template node is trying to insert <code>{{ msg.payload }}</code>. As per the examples in the sidebar help for the node, it should just be <code>{{ payload }}</code>.</p></li> </ol> |
15,471,056 | 0 | Extracting from the right of a string in objective C <p>This seems to be what I'm looking for but in reverse. I would like the <code>string</code> to extract from the right not from the left. The example extracting from the left is given:</p> <pre><code>NSString *source = @"0123456789"; NSString *firstFour = [source substringToIndex:4]; Output: "0123" </code></pre> <p>I'm looking for a version of the below that works from the right (what is below doesn't work)</p> <pre><code>NSString *source = @"0123456789"; NSString *lastFour = [source substringToIndex:-4]; Output: "6789" </code></pre> <p>the <code>[source substringFromIndex:6];</code> won't work because sometimes I will get an answer that is 000123456789 or 456789 or 6789. In all cases I just need the last 4 characters from the string so that I can convert it to a number.</p> <p>there must be a better way than a bunch of if else statements?</p> |
39,237,567 | 0 | <p>Well according to the <a href="https://www.lua.org/manual/5.2/manual.html#pdf-package.searchers" rel="nofollow">Lua documentation on the require call</a> (using Lua 5.2 here), there are a few places the loader looks for these loadable modules.</p> <p>It seems that <code>require()</code> uses what are called "searchers" (docs linked to in above) to determine where to find these modules. There are four searchers in total. From the docs:</p> <blockquote> <p>The first searcher simply looks for a loader in the package.preload table.</p> <p>The second searcher looks for a loader as a Lua library, using the path stored at package.path. The search is done as described in function package.searchpath.</p> <p>The third searcher looks for a loader as a C library, using the path given by the variable package.cpath. Again, the search is done as described in function package.searchpath. For instance, if the C path is the string <code>"./?.so;./?.dll;/usr/local/?/init.so"</code> the searcher for module foo will try to open the files <code>./foo.so</code>, <code>./foo.dll</code>, and <code>/usr/local/foo/init.so</code>, in that order. Once it finds a C library, this searcher first uses a dynamic link facility to link the application with the library. Then it tries to find a C function inside the library to be used as the loader. The name of this C function is the string "luaopen_" concatenated with a copy of the module name where each dot is replaced by an underscore. Moreover, if the module name has a hyphen, its prefix up to (and including) the first hyphen is removed. For instance, if the module name is a.v1-b.c, the function name will be luaopen_b_c.</p> <p>The fourth searcher tries an all-in-one loader. It searches the C path for a library for the root name of the given module. For instance, when requiring a.b.c, it will search for a C library for a. If found, it looks into it for an open function for the submodule; in our example, that would be luaopen_a_b_c. With this facility, a package can pack several C submodules into one single library, with each submodule keeping its original open function.</p> </blockquote> <p>The searcher of use to us is the third one: it is used for any shared libraries (.dll or .so) which is generally how our custom C modules are built.</p> <p>Using the <em>template</em> string (the one with the question marks), the searcher will look in each of the specified paths, substituting the argument of <code>require()</code> in place of the question mark. In order to specify the path for this third searcher, one must set (or append to) <a href="https://www.lua.org/manual/5.2/manual.html#pdf-package.cpath" rel="nofollow"><code>package.cpath</code></a> and then call <code>require()</code>.</p> <p>So perhaps you have a directory structure as</p> <pre><code>- ROOT |-lua |-bin </code></pre> <p>where <code>lua</code> contains <code>script.lua</code> and <code>bin</code> contains <code>mylib.so</code></p> <p>To load <code>mylib.so</code>, you just need these two lines of code in <code>script.lua</code>:</p> <pre><code>package.cpath = '/ROOT/bin/?.so;' .. package.cpath libfuncs = require('mylib') </code></pre> <p>NOTE: Notice the semicolon. If you append (as opposed to the prepending above), make sure to lead with the semicolon on your added path. It is not there buy default. Otherwise your new path will be merged to the current default cpath, which is just <code>./?.so</code>.</p> |
11,431,333 | 0 | <p>Here is an example. Suppose we have 2 classes:</p> <pre><code>class A { public String getName() { return "A"; } } class B extends A { public String getName() { return "B"; } } </code></pre> <p>If we now do the following:</p> <pre><code>public static void main(String[] args) { A myA = new B(); System.out.println(myA.getName()); } </code></pre> <p>we get the result</p> <pre><code>B </code></pre> <p>If Java didn't have <code>virtual method invocation</code>, it would determine at compile time that the <code>getName()</code> to be called is the one that belongs to the <code>A</code> class. Since it doesn't, but determines this at runtime depending on the actual class that <code>myA</code> points to, we get the above result.</p> <p><strong>[EDIT to add (slightly contrived) example]</strong><br> You could use this feature to write a method that takes any number of <code>Object</code>s as argument and prints them like this:</p> <pre><code>public void printObjects(Object... objects) { for (Object o: objects) { System.out.println(o.toString()); } } </code></pre> <p>This will work for any mix of Objects. If Java didn't have <code>virtual method invocation</code>, all Objects would be printed using Object´s <code>toString()</code> which isn't very readable. Now instead, the <code>toString()</code> of each actual class will be used, meaning that the printout will usually be much more readable.</p> |
24,010,124 | 0 | How to make a dummy security-domain in JBoss EAP 6.2? <p>We are using the JBoss supplied generic resource adapter to connect to JMS queues on Tibco EMS server. We don't use any authentication to connect to Tibo EMS, that is we connect without username and password. However, the configuration of the resource adapter requires a recovery element (for XA recovery) that specifies some kind of authentication, see [1].</p> <p>Someone mentioned that we might be able to define a custom security domain that always authenticates or returns empty username and passwords. (Specifying empty username or password directly in the recover element is not allowed)</p> <p>Does anyone know how to make such a dummy security-domain?</p> <p>We're running JBoss EAP 6.2.2.</p> <p>[1] <a href="https://access.redhat.com/site/solutions/361463" rel="nofollow">https://access.redhat.com/site/solutions/361463</a></p> |
24,891,432 | 0 | AngularJS Leaflet getMap() doesn't work <p>After adding Leaflet to my AngularJS app:</p> <pre><code><leaflet id="map" defaults="defaults" center="center" bounds="bounds" controls="controls" event-broadcast="events"></leaflet> </code></pre> <p>And setting it up:</p> <pre><code>// Initialise the feature group to store editable layers var drawnItems = new L.FeatureGroup(); // Initialise the draw control var drawControl = new L.Control.Draw({ position: 'topright', edit: { featureGroup: drawnItems } }); // Configure Leaflet angular.extend($scope, { defaults: { zoomControlPosition: 'topright', minZoom: 3, tileLayerOptions: { detectRetina: true, reuseTiles: true, attribution: '<a href="http://osm.org">OpenStreetMaps</a>' } }, center: {}, controls: { custom: [drawControl] }, events: { map: { enable: ['click'] } } }); </code></pre> <p>Following this code it doesn't get evaluated (no error shown though):</p> <pre><code>leafletData.getMap().then( function (map) { alert('I have accessed the map.'); } ); </code></pre> <p>This should show me an alert straight away, although nothing happens.</p> <p>If I delay this previous code, for example, running it in a function on a button click, it works!</p> <p>Does anyone knows what could be a problem?</p> <p>Seeing example, it should work: <a href="https://github.com/tombatossals/angular-leaflet-directive/blob/master/examples/control-draw-example.html" rel="nofollow">https://github.com/tombatossals/angular-leaflet-directive/blob/master/examples/control-draw-example.html</a></p> <h1>PARTLY SOLVED</h1> <p>Removing ID from <code>leaflet</code> HTML tag solved the problem. Must be a bug.</p> |
2,267,608 | 0 | <p>In SQL 2005 and earlier, you could not modify an existing column to become an identity column. I deem it very very unlikely that MS changed that in 2008.</p> |
13,823,871 | 0 | php - escape string <p>I'm busy with a PHP project that has to work in different languages, so I made a system with strings that are read from files, but when I want to read a file like this:</p> <p>Username/ \n password wrong</p> <p>It shows the \n instead of escaping it to a newline. How can I let PHP do this?</p> <p>Thans already, DirkWillem</p> |
38,831,791 | 0 | Codeigniter URI issue...No URI present. Default controller set <p>I have an issue with my codeigniter application deployed on an EC2 instance on Amazon.</p> <pre><code>$config['base_url'] = 'http://XX.XX.XXX.107/'; $config['index_page'] = 'index.php'; </code></pre> <p>This is my route.php (without any particular rule)</p> <pre><code>$route['default_controller'] = 'home'; $route['404_override'] = ''; $route['translate_uri_dashes'] = FALSE; </code></pre> <p>Actually if I call <a href="http://xx.xx.xxx.107/" rel="nofollow">http://xx.xx.xxx.107/</a> it correctly show my first page (it loads my default controller Home.php and shows home.php view). But if I call for example <a href="http://52.59.107.107/index.php/Home/sign_in_form" rel="nofollow">http://52.59.107.107/index.php/Home/sign_in_form</a>, instead of showing sign_in form view, it shows again home view.</p> <p>I enabled log, and this is what I get</p> <pre><code>INFO - 2016-08-08 15:43:25 --> Config Class Initialized INFO - 2016-08-08 15:43:25 --> Hooks Class Initialized DEBUG - 2016-08-08 15:43:25 --> UTF-8 Support Enabled INFO - 2016-08-08 15:43:25 --> Utf8 Class Initialized INFO - 2016-08-08 15:43:25 --> URI Class Initialized DEBUG - 2016-08-08 15:43:25 --> No URI present. Default controller set. INFO - 2016-08-08 15:43:25 --> Router Class Initialized INFO - 2016-08-08 15:43:25 --> Output Class Initialized INFO - 2016-08-08 15:43:25 --> Security Class Initialized DEBUG - 2016-08-08 15:43:25 --> Global POST, GET and COOKIE data sanitized INFO - 2016-08-08 15:43:25 --> Input Class Initialized INFO - 2016-08-08 15:43:25 --> Language Class Initialized INFO - 2016-08-08 15:43:25 --> Loader Class Initialized INFO - 2016-08-08 15:43:25 --> Helper loaded: file_helper INFO - 2016-08-08 15:43:25 --> Helper loaded: form_helper INFO - 2016-08-08 15:43:25 --> Helper loaded: url_helper INFO - 2016-08-08 15:43:25 --> Database Driver Class Initialized INFO - 2016-08-08 15:43:25 --> Database Driver Class Initialized INFO - 2016-08-08 15:43:25 --> Session: Class initialized using 'files' driver. INFO - 2016-08-08 15:43:25 --> XML-RPC Class Initialized INFO - 2016-08-08 15:43:25 --> Controller Class Initialized INFO - 2016-08-08 15:43:25 --> Model Class Initialized INFO - 2016-08-08 15:43:25 --> Model Class Initialized INFO - 2016-08-08 15:43:25 --> Model Class Initialized INFO - 2016-08-08 15:43:25 --> Model Class Initialized INFO - 2016-08-08 15:43:25 --> Form Validation Class Initialized DEBUG - 2016-08-08 15:43:25 --> Session class already loaded. Second attempt ignored. INFO - 2016-08-08 15:43:25 --> File loaded: /var/www/core_ci/application/views/header.php INFO - 2016-08-08 15:43:25 --> File loaded: /var/www/core_ci/application/views/home.php INFO - 2016-08-08 15:43:25 --> File loaded: /var/www/core_ci/application/views/footer.php INFO - 2016-08-08 15:43:25 --> Final output sent to browser DEBUG - 2016-08-08 15:43:25 --> Total execution time: 0.1061 </code></pre> <p>As you can see in the log, I'm getting <strong>DEBUG - 2016-08-08 15:43:25 --> No URI present. Default controller set</strong>., even if I'm calling this url <a href="http://xx.xx.xxx.107/index.php/Home/sign_in_form" rel="nofollow">http://xx.xx.xxx.107/index.php/Home/sign_in_form</a> </p> <p>Here some data about my server:</p> <pre><code>PHP Version 5.5.35 System Linux ip-xx-x-x-xxx 4.4.8-20.46.amzn1.x86_64 #1 SMP Wed Apr 27 19:28:52 UTC 2016 x86_64 Build Date May 2 2016 23:29:10 Server API FPM/FastCGI </code></pre> <p>Here the vhost Apache file:</p> <pre><code><VirtualHost *:80> # Leave this alone. This setting tells Apache that # this vhost should be used as the default if nothing # more appropriate is available. ServerName default:80 # REQUIRED. Set this to the directory you want to use for # your “default” site files. DocumentRoot /var/www/html # Optional. Uncomment this and set it to your admin email # address, if you have one. If there is a server error, # this is the address that Apache will show to users. #ServerAdmin [email protected] # Optional. Uncomment this if you want to specify # a different error log file than the default. You will # need to create the error file first. #ErrorLog /var/www/vhosts/logs/error_log <Directory /var/www/html> AllowOverride All </Directory> ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/$1 DirectoryIndex /index.php index.php </VirtualHost> </code></pre> <p>Is there anyone that can tell me where I'm failing?</p> <p>Thanks in advance.</p> <p><strong>UPDATED</strong></p> <p>Home.php</p> <pre><code><?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Home extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('Home_model'); $this->load->model('Users_model'); $this->load->model('Credit_model'); $this->load->library('form_validation'); $this->load->library('language'); $this->load->library('alerts'); $this->load->library('session'); $this->load->helper('url'); // $this->load->helper('captcha'); } public function test() { print_r('my test method'); } </code></pre> <p>As you can see I prepared for simplicity a test method in Home controller. If I call <a href="http://xx.xx.xxx.107/index.php/Home/test" rel="nofollow">http://xx.xx.xxx.107/index.php/Home/test</a> I get the same log sequence and it shows the home view instead of printing my raw data.</p> <p>It seems that as it is not able to get correct URi, it run default controller.</p> |
2,399,610 | 0 | <p><a href="http://msdn.microsoft.com/en-us/library/yy2ykkab.aspx" rel="nofollow noreferrer">ASP.NET Site Maps</a></p> <blockquote> <p>The simplest way to create a site map is to create an XML file named Web.sitemap that organizes the pages in the site hierarchically. This site map is automatically picked up by the default site-map provider for ASP.NET.</p> </blockquote> |
2,379,563 | 0 | OpenCMS Content Type - when editing, it doesn't show the names of the fields <p>I created a custom content type FaqEntry in OpenCMS (three fields - title, question, answer) and registered it. When I create a new file of that type and want to edit it, it shows the three fields there, but it doesn't show their label, i.e. "Title", "Question", "Answer". Do you have any idea as to why?</p> |
12,149,337 | 0 | <p><code>double[]</code> array is object. So, you get address and entire array is added at index 0.</p> <p>You may use <code>Arrays.toString(x.get(0))</code> to get readable array print.</p> <p>toString() for an array is to print [, followed by a character representing the data type of the array's elements, followed by @ then the memory address.</p> |
23,620,321 | 0 | Convert IPython 2.0 notebook to html from the 'file' menu <p>I am trying to convert my notebook to html from the file menu (nice feature added in 2.0), but when I do this I get a 500 : Internal Server Error screen with the text:</p> <pre><code>nbconvert failed: Pandoc wasn't found. Please check that pandoc is installed: http://johnmacfarlane.net/pandoc/installing.html </code></pre> <p>I've installed Pandoc from the link using the windows installer but keep getting the same error. Any suggestions on how to fix this? Where do I need to put the Pandoc folder or pandoc.exe that I just downloaded to make this work?</p> |
8,722,072 | 0 | <p>After fighting for 3 hours and trying out every solution on forums, I found out that the simple trick was to remove the quotes while specifying the <strong>path of the Xdebug dll</strong> in <strong>zend_extension</strong> in <strong>php.ini</strong>. I am using XAMPP (PHP 5.3.6 + Apache 2.2)+ Eclipse Indigo + PDT + Xdebug 2.1.2 on Windows Vista.</p> <p>Here is the exact configuration that worked for me -</p> <pre><code>zend_extension=C:\xampp\php\ext\php_xdebug-2.1.2-5.3-vc6.dll #Note that the path above is not in quotes xdebug.remote_enable=true xdebug.remote_host=localhost xdebug.remote_port=9001 xdebug.remote_handler=dbgp xdebug.profiler_enable=1 xdebug.profiler_output_dir=C:\xampp\tmp </code></pre> <p>I have used port 9001 so that it does not clash with 9000 in case that's already used by another program. Make sure this matches the port in Eclipse > Preferences > PHP > Debug > Xdebug too. Also, restart apache after editing php.ini.</p> <p>Once I added this to php.ini, everything worked like ice cream.</p> |
24,294,881 | 0 | <p>This is just complicated code for no reason..</p> <pre><code>public class Sort { public static void calc(ArrayList<Book> bookList) { for (i = 0 ; i < bookList.size() ; i++) { for (j = i+1; j < bookList.size() ; j++) { if (bookList.get(i).getRating() > bookList.get(j).getRating()) { Collections.swap(bookList, i, j); } System.out.println(bookList.get(out).getTitle() + " " + bookList.get(out).getRating()); } } } } </code></pre> <p>Hope that helps</p> |
11,703,715 | 0 | <p>I'd suggest:</p> <pre><code>var link = 'http://www.example.com/directory1/directory2/directory3/directory4/index.html'; console.log(link.split('/')[5]); </code></pre> <p><a href="http://jsfiddle.net/Eubmg/" rel="nofollow">JS Fiddle demo</a>.</p> <p>The reason we're using <code>[5]</code> not <code>[4]</code> is because of the two slashes at the beginning of the URL, and because JavaScript arrays are zero-based.</p> |
30,627,194 | 1 | Understanding control flow of recursive function that uses splicing <p>I seem to be unable to understand why it is, that once the terminating base condition is met in a recursive function, the function continues to call itself and go back up the call stack. </p> <p>Here's an example recursive function written in Python 2.7:</p> <pre><code>text = "hello" def reverse_string(text): if len(text) <= 1: return text return reverse_string(text[1:]) + text[0] </code></pre> <p>Using the <a href="http://www.pythontutor.com/visualize.html#mode=edit" rel="nofollow">Python visualizer</a>, I understand how as the function calls itself with <code>reverse_string(text[1:])</code> and each frame is created as follows: </p> <pre><code>Frames Global frame text "hello" reverse_string reverse_string text "hello" reverse_string text "ello" reverse_string text "llo" reverse_string text "lo" reverse_string text "o" Return value "o" </code></pre> <p>My question is this: why when the base condition is met (when <code>text = "o"</code>) does that trigger text[0] to start operating? I was thinking that all the code on that return statement/line would be working together at the same time, not understanding why <code>reverse_string(text[1:])</code> happens first, then <code>text[0]</code> — and again, why is <code>text[0]</code> activated when the base conditional is met?</p> |
15,253,144 | 0 | <p>If you're using Java, you may want to check out <a href="http://code.google.com/p/sikuli-api/" rel="nofollow" title="Sikuli-API on Google Code">Sikuli-API</a> instead. It tries to be more of a standard Java library.</p> <p>Sikuli-API uses <a href="http://www.slf4j.org" rel="nofollow" title="SLF4J">SLF4J</a>, so you just connect it to whatever logging framework you use (I like <a href="http://logback.qos.ch/" rel="nofollow" title="Logback">Logback</a> a lot), and it will use that configuration.</p> |
29,121,962 | 0 | opendir sleeps or infinite loop the program <p>I'm making a simple LS command in C in a program, when I open the directory for the first time and read it, it works perfectly, but when I call the function a second time, <code>opendir()</code> seems to sleep or loop infinitely:</p> <pre><code>int server_list(t_server_data *sd) { DIR *dir; struct dirent *entry; printf("In list()\n"); printf("Open directory\n"); if ((dir = opendir("./")) == NULL) perror("Error: opendir()"); printf("Directory opened\n"); while ((entry = readdir(dir)) != NULL) { printf("Reading dir...\n"); /* code */ } closedir(dir); return (0); } </code></pre> <p>Then this is the output I get: </p> <pre class="lang-none prettyprint-override"><code>In list() Open directory </code></pre> <p>And the program does nothing (waits).</p> |
40,879,405 | 0 | Why does netstat report lesser number of open ports than lsof <p>I have storm running on 2 machines.</p> <p>Each machine runs nimbus process (fancy for master process) and worker processes.</p> <p>And I wanted to see the communication between them - what ports are open and how they connect to each other.</p> <pre><code>$ netstat -tulpn | grep -w 10669 tcp 0 0 :::6700 :::* LISTEN 10669/java udp 0 0 :::42405 :::* 10669/java $ lsof -i :6700 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME java 10669 storm 25u IPv6 57830 0t0 TCP host1:50778->host2:6700 (ESTABLISHED) java 10669 storm 26u IPv6 57831 0t0 TCP host1:6700->host2:57339 (ESTABLISHED) java 10669 storm 29u IPv6 57843 0t0 TCP host1:6700->host1:50847 (ESTABLISHED) java 10669 storm 53u IPv6 57811 0t0 TCP *:6700 (LISTEN) java 10681 storm 53u IPv6 57841 0t0 TCP host1:50780->host2:6700 (ESTABLISHED) java 10681 storm 54u IPv6 57842 0t0 TCP host1:50847->host1:6700 (ESTABLISHED) </code></pre> <p>What I dont understand from the above output is that why netstat does not show port 50778 being open in the process with PID=10669 where as <code>lsof</code> clearly shows that the same process has an established connection as <code>host1:50778->host2:6700</code></p> |
24,260,180 | 0 | How to login to facebook in android , using simplest method <p>I am building a facebook application in which i will sign in with facebook account, now i want to get/store the session variable, and to use it for further purposes like to get the basic, and other information of the user, where a session variable is necessary to pass it in request. I am using this code for getting session variable but its not working. please refer me any tutorial or code which i will use for facebook sign in</p> <pre><code> //Setting Face Book Id facebook = new Facebook(APP_ID); mAsyncRunner = new AsyncFacebookRunner(facebook); Session s=facebook.getSession(); </code></pre> |
2,557,207 | 0 | Selectively replacing words outside of tags using regular expressions in PHP? <p>I have a paragraph of text and i want to replace some words using PHP (preg_replace). Here's a sample piece of text:</p> <p><code>This lesson addresses rhyming [one]words and ways[/one] that students may learn to identify these words. Topics include learning that rhyming words sound alike and these sounds all come from the [two]ending of the words[/two]. This can be accomplished by having students repeat sets of rhyming words so that they can say them and hear them. The students will also participate in a variety of rhyming word activities. In order to demonstrate mastery the students will listen to [three]sets of words[/three] and tell the teacher if the words rhyme or not.</code></p> <p>If you notice there are many occurances of the word 'words'. I want to replace all the occurances that <strong>don't</strong> occur inside any of the tags with the word 'birds'. So it looks like this:</p> <p><code>This lesson addresses rhyming [one]words and ways[/one] that students may learn to identify these birds. Topics include learning that rhyming birds sound alike and these sounds all come from the [two]ending of the words[/two]. This can be accomplished by having students repeat sets of rhyming birds so that they can say them and hear them. The students will also participate in a variety of rhyming word activities. In order to demonstrate mastery the students will listen to [three]sets of words[/three] and tell the teacher if the birds rhyme or not.</code></p> <p>Would you use regular expressions to accomplish this?<br> <em>Can</em> a regular expression accomplish this?</p> |
25,386,942 | 0 | <p>I have used linked servers as a way of sharing data between mysql and SqlServer and then have triggers from the sqlServer to the mysql linked server.</p> <p>if the triggers will not work for you, the other better option will be to setup replication between the sqlserver and the mysql linked server.</p> <p><a href="http://www.ideaexcursion.com/2009/02/25/howto-setup-sql-server-linked-server-to-mysql/" rel="nofollow">http://www.ideaexcursion.com/2009/02/25/howto-setup-sql-server-linked-server-to-mysql/</a></p> <p><a href="http://dbperf.wordpress.com/2010/07/22/link-mysql-to-ms-sql-server2008/" rel="nofollow">http://dbperf.wordpress.com/2010/07/22/link-mysql-to-ms-sql-server2008/</a></p> |
4,719,134 | 0 | <p>Sure. You can use the magic constant <code>__FILE__</code> which contains the path to the file that you use it in:</p> <pre><code>class MyClass def initialize puts File.read(__FILE__) end end </code></pre> <p>This will print the contents of the file containing the definition of <code>MyClass</code> every time you create a <code>MyClass</code> object.</p> |
26,582,458 | 0 | <p>i think you are using $routeProvider for your angular app. but in your example angular app is using $stateProvider.so you have to install angular-ui-router.js and give reference to it to the index.html . and also you have to put dependency 'ui.router' in to app.js </p> |
16,375,887 | 0 | Unable to start main activity which has build by maven <p>I had three proejct: parent, source and a library project. My problem is the following: after successful mvn install android:deploy android:run the application get`s crash with the following message:</p> <pre><code>05-04 17:22:10.564: E/AndroidRuntime(6574): FATAL EXCEPTION: main 05-04 17:22:10.564: E/AndroidRuntime(6574): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.fruit.apple/com.fruit.apple.SplashScreenActivity}: java.lang.ClassNotFoundException: com.fruit.apple.SplashScreenActivity in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/mnt/asec/com.fruit.apple-1/pkg.apk] </code></pre> <p>Actually I don`t know what should be there problem, I really appreciate your help.</p> <p>Thanks, Karoly</p> <p>PS part of pom.xml</p> <pre><code><plugin> <groupId>com.jayway.maven.plugins.android.generation2</groupId> <artifactId>android-maven-plugin</artifactId> <version>3.2.0</version> <configuration> <sign> <debug>true</debug> </sign> <androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile> <assetsDirectory>${project.basedir}/assets</assetsDirectory> <resourceDirectory>${project.basedir}/res</resourceDirectory> <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory> <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory> <sdk> <path>${android.sdk.path}</path> <platform>17</platform> </sdk> <deleteConflictingFiles>true</deleteConflictingFiles> <undeployBeforeDeploy>false</undeployBeforeDeploy> </configuration> <extensions>true</extensions> </plugin> </code></pre> |
13,312,846 | 0 | <p>You're defining a function prototype with a reference as the return value. The function returns a reference to an integer. As such its return value can be set to another value.</p> |
8,285,424 | 0 | <p>Add unique constraint on both columns:</p> <pre><code>CREATE UNIQUE INDEX ui_tab ON tab (x, y); </code></pre> |
7,735,251 | 0 | <p>You are not initializing p. It's an uninitialized pointer that you are writing to.</p> <p>Since you are writing this in C++, not C, I'd suggest using <code>std::string</code> and <a href="http://www.cplusplus.com/reference/algorithm/reverse/"><code>std::reverse</code></a>:</p> <pre><code>#include <string> #include <algorithm> #include <iostream> int main() { std::string str = "Saw my reflection in snow covered hills"; std::reverse(str.begin(), str.end()); std::cout << str; return 0; } </code></pre> <p>Output:</p> <pre> sllih derevoc wons ni noitcelfer ym waS </pre> <p>See it working online at <a href="http://ideone.com/iMb1B">ideone</a></p> |
24,542,886 | 0 | Starting eclipse from Command Prompt different than double clicking <p>My university wipes their public computers every time someone logs off, so I have decided to write a .bat file that copies my eclipse from a flash drive to their desktop with all my code intact. The file currently looks like this:</p> <pre><code>@echo off mkdir C:\Users\lib-pac-olin-ppc\Desktop\eclipse xcopy eclipse C:\Users\lib-pac-olin-ppc\Desktop\eclipse /S /E C:\Users\lib-pac-olin-ppc\Desktop\eclipse\eclipse.exe </code></pre> <p>When I run this, eclipse starts up but behaves as if it has been launched for the first time. It does not adopt the default workspace settings and it flashes up the welcome screen. However, when I launch eclipse by directly double clicking it, it goes to my workspace and pulls up my code. It also launches a lot faster. Why is this happening?</p> <p>For the person that asked, here is the .ini file:</p> <pre><code>-startup plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar --launcher.library plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20140603-1326 -product org.eclipse.epp.package.standard.product --launcher.defaultAction openFile --launcher.XXMaxPermSize 256M -showsplash org.eclipse.platform --launcher.XXMaxPermSize 256m --launcher.defaultAction openFile --launcher.appendVmargs -vmargs -Dosgi.requiredJavaVersion=1.7 -Xms40m -Xmx512m </code></pre> <p>I should note that the JVM was placed in a folder called jre within the eclipse directory, which is where eclipse looks for it by default.</p> |
13,829,295 | 0 | <p>You cannot perform append operation on array. Try the following. </p> <p><code>String[] list = new String[6];</code><br> <code>list[0] = "One";</code><br> <code>list[1] = "Two";</code><br> <code>list[2] = "Three";</code><br> <code>list[3] = "Four";</code><br> <code>list[4] = "Five";</code><br> <code>list[5] = "Six";</code><br> <code>String[] list2 = new String[list.length / 2];</code><br> <code>for (int i = 0, j = 0; i < list.length; i++, j++)</code><br> <code>{</code><br> <code>list2[j] = list[i] + list[++i];</code><br> <code>}</code> </p> |
13,231,790 | 0 | How to toggle “Use Physical Keyboard” <p>I am trying to solve the same thing as the following post posts:</p> <p><a href="http://stackoverflow.com/questions/11878153/how-to-toggle-use-physical-keyboard/13231368#13231368">How to toggle "Use Physical Keyboard".</a> and <a href="http://stackoverflow.com/questions/9244816/switch-from-physical-to-software-keyboard/13231306#13231306">Switch from physical to software keyboard</a></p> <p>Basicaly I want to toggle the native option from android to turn the physical keyboard on or off. However, I want to create this button through code.</p> <p>None of those links have one good answer. Can anyone help me?</p> |
11,665,548 | 0 | Implementation details of MPI collective operations on a multi core machine <p>In MPI, each rank has a unique address space and communication between them happens via message passing. I want to know how MPI works in a multicore machine which has a shared memory. If the ranks are on two different machines with no shared memory, then MPI has to use messages for communication. But if ranks are on the same physical machine (but still each rank has a different address space), will the MPI calls take advantage of the shared memory. Say for example I'm issuing an ALLREDUCE call. I have two machines M1 & M2 each with 2 cores. Rank R1, R2 are on core1 & core2 of machine M1 and R3&R4 are on C1&C2 of machine M2. How would the ALLREDUCE happen. Will there be more than 1 message transmitted? Ideally I would expect R1&R2 to do a reduce using the shared memory available to them (similarly R3&R4) followed by message exchange between M1 & M2. Is there any documentation where I can read about the implementation details of the collective operations in MPI?</p> |
15,503,651 | 0 | <p>You want to detect an invalid situation, so you should check for it even before calling your solver. Your solver on itself will not create invalid solutions...</p> |
33,395,503 | 0 | PHP get keys in nested array using array_keys( ) <p>I have a $results array produced from a query and I would like to output a table in html. I would like the header to be "id", "length" and "sample_id". Since the header changes every time, so I used</p> <pre><code>$keys = array_keys($results[0]); </code></pre> <p>I got "array_keys() expects parameter 1 to be array" error. If the nested part is not an array, how should I get the keys?</p> <pre><code>array:59 [▼ 0 => {#160 ▼ +"id": 204 +"length": 233 +"sample_id": "ad3" } 1 => {#161 ▼ +"id": 205 +"length": 733.5 +"sample_id": "bt7r" } 2 => {#162 ▶} 3 => {#163 ▶} 4 => {#164 ▶} 5 => {#165 ▶} </code></pre> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.