pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
21,306,235
0
<p>I suggest you use expressjs. Using <code>nodejs</code> to create web application is quite low-level. You have to install express via node <code>npm install express</code> and go from there.</p> <p><strong>Some code snipped to help</strong></p> <pre><code>var express = require('express'); var app = express(); app.use(express.bodyParser()); app.set('view engine', 'ejs'); app.register('.html', require('ejs')); app.get('/', function(req, res) { // Handle file reading in here and return object res.render('index.html', {obj: obj}); //where object is the obj is the object holding the arrays }); app.listen(8080, function() { console.log('Server running at http://127.0.0.1:8080/'); }); </code></pre> <p><strong>then in your index.html do .. inside script tags.</strong></p> <pre><code>&lt;script&gt; console.log(&lt;%= cordinates.obj %&gt;); &lt;/script&gt; </code></pre> <p>DISCLAIMER: I haven't tested this but it's just to help you on your way</p>
16,822,170
0
Convert Excel .xls to .csv, .xml or JSON in Javascript <p>Using <code>Javascript</code>, specifically <code>Google Apps Script</code> (GAS), I need to convert an <code>.xls</code> file to <code>JSON</code>; but I would settle for <code>.csv</code> or <code>.xml</code>.</p> <p>Does anyone know any way to do this? Some library, perhaps? Or a private script willing to share? (Note: GAS can not recognize <code>ActiveXObject</code>)</p> <h3>Prior research (does not apply)</h3> <p><a href="http://stackoverflow.com/questions/662859/converting-csv-xls-to-json">This</a> question does not apply because I am asking for a solution coded in Javascript (or a workaround for Google Apps Script). (The answers to the above question focus on a Java solution and other various .csv to JSON converters.)</p> <p>Yes, I know there is an open <a href="https://code.google.com/p/google-apps-script-issues/issues/detail?id=1019" rel="nofollow">issue</a> for GAS already in the works. But I was wondering if anyone has coded any .js workaround to do the job in the meantime?</p>
37,026,590
0
<p>if your text box coming dynamically then you should try </p> <pre><code>$(document).on("keyup", ".typeahead" , function() { getAllActiveUsers(); }); </code></pre> <p>try this and let us know if its works or not.</p>
34,817,983
0
<p>It doesn't violate IEEE-754, because IEEE-754 defers to languages on this point:</p> <blockquote> <p>A language standard should also define, and require implementations to provide, attributes that allow and disallow value-changing optimizations, separately or collectively, for a block. These optimizations might include, but are not limited to:</p> <p>...</p> <p>― Synthesis of a fusedMultiplyAdd operation from a multiplication and an addition.</p> </blockquote> <p>In standard C, the <code>STDC FP_CONTRACT</code> pragma provides the means to control this value-changing optimization. So GCC is licensed to perform the fusion by default, so long as it allows you to disable the optimization by setting <code>STDC FP_CONTRACT OFF</code>. Not supporting that means not adhering to the C standard.</p>
40,617,475
0
<p>I found this to be a difficult thing to figure out. I already had an HTML editor installed as part of Eclipse, but it wasn't getting loaded.</p> <p>Go to Preferences > General > Editors > File Association and click on *.html (and do the same for *.htm). If you have an HTML editor installed, you should see it in the list. Just click it and then click Default to make Eclipse open HTML files using the HTML editor.</p> <p>If you don't have an HTML editor installed, WTP is fine, per Rahul's suggestion. You may then need to do the above steps to make sure the HTML Editor is chosen when you edit an HTML file.</p>
13,313,304
0
I want to draw a line and fill it with a repeating image in Objective C <p>I don't need code, just a starting point. I have a drawing app on iPad where you draw a line from point a to point b. Between the 2 points the line is replaced with a repeating image.!</p>
21,740,108
0
ExtJS debugging "[E] Layout run failed" (in a custom component) <p>I have developed a <a href="https://github.com/rixo/GridPicker">custom kind of combo box</a> that uses a grid instead of the standard combo picker (mainly to benefit from buffered rendering with huge data sets). I am now trying to make it compatible with Ext 4.2.1 but I ran into this error:</p> <pre><code>[E] Layout run failed </code></pre> <p>Please, see the <a href="http://planysphere.fr/ext/GridPicker/examples/index-4.2.1">demo pages</a> for test cases. The error is raised once for each combo, but only the first time it is expanded.</p> <p>This error didn't happen with 4.2.0 (see <a href="http://planysphere.fr/ext/GridPicker/examples/">demo page with 4.2.0</a>). The breaking changes I had identified in 4.2.1 at the time were about the query filter, not rendering or layout... However, I have already been facing this error with 4.2.0 in a situation where the grid picker was sitting in a window, but it was in a code base with lots of overrides and that used the sandboxed version of Ext4... So I just hopped it was not coming from my component and silenced it (<a href="http://planysphere.fr/ext/GridPicker/examples/benchmark/">another demo page</a> proves that grid picker + window is not enough to trigger the error).</p> <p>The error doesn't seem to have any side effects, but it makes me feel bad.</p> <p>Does anyone know what is causing that or, even better, what must be done to prevent it?</p> <p>Or does someone understand Ext's layout engine well enough to give me some pieces of advice on how to track down this kind of error? Or at least give me reassurance that the error will remain harmless in any situation?</p>
17,684,938
0
<p>Something like this should give u all the filenames in the folder, for you to manipulate:</p> <pre><code>Dir["Tel/**/**/*.csv].each do |file| * update attribute of your model with the path of the file end </code></pre>
29,049,704
0
Constructing a JavaScript Array prototype method <p>I am new to constructing a JavaScript Array prototype. Please only paste previous links that are directly appropriate as I have been sourcing on SO and on w3school. <a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype" rel="nofollow">https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype</a></p> <p>I would like to create a method for an array that checks if the 'id' field within the object does not already exist in the array. If not, then 'push' object into the array, else do nothing.</p> <p>Each object has a unique 'id' field.</p> <pre><code>eg var array = [{ id: 001, title: 'some title'}, { id: 002, title: 'other title'}] var object = {id: 001, title: 'some title'} // if object.id does not exist in array... array.push(object) //else do nothing </code></pre> <p>I would like the function to take the 'id' field as an argument so this function has wider use.</p> <p>Are there any drawbacks to extending the array.Prototype? Otherwise I can do a for loop instead to do the check without the prototype constructor.</p>
39,677,844
0
<p>Its in your gradle file, and gets written to your manifest (if you aren't using gradle).</p>
35,980,651
0
<p>for start mod-rewire start from the your domain. then on localhost if you want your mod_rewrite work you should pass it to your project address, <br /> before all above thing, you should check your mode_Rewire be enable<br /> redirect:<br /> <code>http://localhost/ConnectMyProfile/ViewProfile.php?id=CMP26944</code> or <br /> <code>http://localhost/ConnectMyProfile/ViewProfile?id=CMP26944</code><br /> to <br /> <code>http://localhost/ConnectMyProfile/ViewProfile/CMP26944</code></p> <pre><code>RewriteEngine On RewriteBase /ConnectMyProfile/ # external redirect from actual URL to pretty one RewriteCond %{THE_REQUEST} /ViewProfile\.php\?id=([^\s&amp;]+) [NC] RewriteRule ^ ViewProfile/%1? [R=302,L] RewriteCond %{THE_REQUEST} /ViewProfile\?id=([^\s&amp;]+) [NC] RewriteRule ^ ViewProfile/%1? [R=302,L] # internally rewrites /ViewProfile/ABC123 to ViewProfile.php?id=ABC123 RewriteRule ^ViewProfile/([A-Z,0-9]+)$ ViewProfile.php?id=$1 [L,NC,QSA] # PHP hiding rule RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*)$ $1.php [L] </code></pre>
36,738,478
0
Searching a custom list view in android? <p>I am using a custom list view and I get unexpected results on search.I would ideally like to search on particular columns in the list for example I would like to search on a Invoice number or a contact number or by name of the person. The following is my code.</p> <pre><code> public void showJson(String json) { final Context billsctx = getActivity(); ParseBills pb = new ParseBills(json); pb.parseJSON(); bl = new BillsCustomList((Activity) billsctx, ParseBills.doc_no, ParseBills.date, ParseBills.cust_name, ParseBills.cust_number, ParseBills.item_count, ParseBills.total_wt, ParseBills.total,ParseBills.balance, ParseBills.bill_type); all_listView.setAdapter(bl); inputSearch.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { bl.getFilter().filter(s); } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (s.length()==0) { refreshFragment(); } } }); </code></pre> <p>}</p> <p>This is my adapter code.</p> <pre><code>public class BillsCustomList extends ArrayAdapter&lt;String&gt; { private String[] doc_no; private String[]date; private String[] cust_name; private String[] cust_number; private String[] item_count; private String[]total_wt; private String[]total; private String[]balance; private String[]bill_type; private Activity context; public BillsCustomList(Activity context, String[] doc_no, String[] date, String[] cust_name,String[] cust_number,String[] item_count,String[] total_wt,String[] total,String[] balance,String[] bill_type) { super(context, R.layout.bills_list_view, doc_no); this.context =context; this.doc_no=doc_no; this.date = date; this.cust_name = cust_name; this.cust_number = cust_number; this.item_count= item_count; this.total_wt = total_wt; this.total = total; this.balance = balance; this.bill_type = bill_type; } @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = context.getLayoutInflater(); View listViewItem = inflater.inflate(R.layout.bills_list_view, null, true); TextView textViewDocno = (TextView) listViewItem.findViewById(R.id.textViewInvNo); TextView textViewDt = (TextView) listViewItem.findViewById(R.id.textViewDt); TextView textViewName = (TextView) listViewItem.findViewById(R.id.textViewName); TextView textViewNumber = (TextView) listViewItem.findViewById(R.id.textViewNumber); TextView textViewCount = (TextView) listViewItem.findViewById(R.id.textViewCount); TextView textViewTotwt = (TextView) listViewItem.findViewById(R.id.textViewTotwt); TextView textViewTot = (TextView) listViewItem.findViewById(R.id.textViewTot); TextView textViewBal = (TextView) listViewItem.findViewById(R.id.textViewBalanace); TextView textViewBt = (TextView) listViewItem.findViewById(R.id.textViewBt); textViewDocno.setText(doc_no[position]); textViewDt.setText(date[position]); textViewName.setText(cust_name[position]); textViewNumber.setText(cust_number[position]); textViewCount.setText(item_count[position]); textViewTotwt.setText(total_wt[position]); textViewTot.setText(total[position]); textViewBal.setText(balance[position]); textViewBt.setText(bill_type[position]); return listViewItem; } } </code></pre> <p>How can I achieve it? Any suggestion or help is appreciated.Thank You.</p>
26,598,445
0
<p>Check this:</p> <pre><code>seq 12 | xargs -i echo "256 * 2 ^ ({} - 1)" | bc | xargs -i echo ./a.out {}.txt </code></pre> <p>If it's OK, then drop <code>echo</code> and add <code>&gt;&gt; output.txt</code></p> <pre><code>seq 12 | xargs -i echo "256 * 2 ^ ({} - 1)" | bc | xargs -i ./a.out {}.txt &gt;&gt; output.txt </code></pre>
1,202,039
0
<p>Two ways:</p> <pre><code>System.IO.FileInfo fileInfo = new System.IO.FileInfo(filePath); fileInfo.IsReadOnly = true/false; </code></pre> <p>or</p> <pre><code>// Careful! This will clear other file flags e.g. FileAttributes.Hidden File.SetAttributes(filePath, FileAttributes.ReadOnly/FileAttributes.Normal); </code></pre> <p>The IsReadOnly property on FileInfo essentially does the bit-flipping you would have to do manually in the second method.</p>
19,394,036
1
Django ModelForm - Allowing adds for ForeignKey <p>I'm trying to mimic the functionality from the Django Admin tool where it allows you to add objects for foreign keys (a little plus icon next to a dropdown). For example, let's say I have the following:</p> <pre><code>class Author(models.Model): first_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100) class Blog(models.Model): name = models.CharField(max_length=50) author = models.ForeignKey('Author') </code></pre> <p>When I go to add my first Blog using a ModelForm for Blog, it shows a dropdown next to Author. However, I have no Authors in the system so that dropdown is empty. In the admin tool, I believe it puts a little "+" icon next to the dropdown so you can quickly and efficiently add a record to the dropdown by opening up a popup.</p> <p>That is extremely useful, and so I'd like to mimic it in my own app using ModelForms. Is that also built into Django's ModelForms? If so, how do I use it? I can't seem to find anything in the documentation.</p>
38,458,655
0
How to make paths clickable in Visual Studio Code Terminal <p>I have VSCode vs. 1.3. and I would like to be able to click in any valid path showed inside the integrated Terminal and get the file opened. </p> <p>Do you know how can I achieve it?</p> <p>Thanks!</p>
3,434,906
0
<p>TWebBrowser is a wrapper around IE ActiveX interface. So, in the end,</p> <pre><code> TWebBrowser = Internet Explorer </code></pre>
8,226,513
0
<p>The solution to your problem greatly depends on your code. You should definitively include the relevant code bits in your SO questions if you want to get help.</p> <p>I'm going to make a guess and assume that your code looks similar to the MapView example:</p> <p><a href="http://developer.anscamobile.com/reference/index/nativenewmapview" rel="nofollow">http://developer.anscamobile.com/reference/index/nativenewmapview</a></p> <p>If that's the case, the problem is that the location is retrieved very late.</p> <pre><code>local function callMap() -- Fetch the user's current location -- Note: in XCode Simulator, the current location defaults to Apple headquarters in Cupertino, CA local currentLocation = myMap:getUserLocation() local currentLatitude = currentLocation.latitude local currentLongitude = currentLocation.longitude ... </code></pre> <p>What you want is that code executed earlier. Ideally, when the application starts. The user will get the "this application wants access to the GPS" message right away, so they will have more time to "approve" before seeing the mapview.</p> <p>Another thing you can do is using a cache. Store the latest known location somewhere (a config file or the database, depending on your setup). When the connection is lost, or not yet retrieved, show the last known location on the map.</p>
33,672,202
0
Xcode 7.1 certificate issue and invalid profiles <p>We are two devs working on the same ios project, using same developer id. When one of us runs app on device, xcode offers to fix a certificate issue. After agree, xcode kills all existing certificates and invalidates provisioning profiles. This kills each other provisioning profiles.</p> <p>Steps to Reproduce: 1. Create developer certificate and provisioning profile. 2. Share it with other developer. 3. Create new profile by xcode when it says "there is no profile to run on device" (and gets "Fix issue" button).</p> <p>Expected Results: Previously created provisioning profiles and developer certificates should remain valid.</p> <p>Actual Results: It invalidates existing developer certificates and provisioning profiles.</p> <p>Version: xcode 7.1</p> <p>How we can fix this issue?</p>
25,518,020
0
<p>Here is an additional option:</p> <p>The way I solved this problem for my app was to define the colors in values/color.xml. </p> <pre><code>&lt;resources&gt; &lt;color name="blue"&gt;#ff0099cc&lt;/color&gt; &lt;color name="dark_grey"&gt;#ff1d1d1d&lt;/color&gt; &lt;color name="white"&gt;#ffffffff&lt;/color&gt; ... &lt;color name="textview_background"&gt;@color/white&lt;/color&gt; &lt;/resources&gt; </code></pre> <p>In the layout the <code>TextView</code> has:</p> <pre><code>android:background="@color/textview_background" </code></pre> <p>If I want to get the background color in code I can just use:</p> <pre><code>getResources().getColor(R.color.textview_background) </code></pre> <p>This gives me a <code>Color</code> object directly without worrying about getting the color from a <code>Drawable</code>.</p>
12,005,022
0
<p>See the equal height function. <a href="http://www.catswhocode.com/blog/8-awesome-jquery-tips-and-tricks" rel="nofollow">http://www.catswhocode.com/blog/8-awesome-jquery-tips-and-tricks</a> Hope this help.</p> <pre><code>function equalHeight(group) { tallest = 0; group.each(function() { thisHeight = $(this).height(); if(thisHeight &gt; tallest) { tallest = thisHeight; } }); group.height(tallest); } $(document).ready(function() { equalHeight($(".recent-article")); equalHeight($(".footer-col")); }); </code></pre>
27,144,047
0
<p>Java (at least JavaEE 6) has an <a href="https://docs.oracle.com/javaee/6/tutorial/doc/gjddd.html" rel="nofollow">Expression Language</a> built-in.</p>
32,615,341
0
Why is R prompting me and failing on `update.packages()`? <p>I'm new to R and I've compiled it myself on Ubuntu 14.04.3 (x64). Note, I am up to date with the R source: </p> <pre><code>blong@work:~/Documents/Work/REPOS__svn/R/R-3-2-branch$ svn info |head -n 7 Path: . Working Copy Root Path: /home/blong/Documents/Work/REPOS__svn/R/R-3-2-branch URL: https://svn.r-project.org/R/branches/R-3-2-branch Relative URL: ^/branches/R-3-2-branch Repository Root: https://svn.r-project.org/R Repository UUID: 00db46b3-68df-0310-9c12-caf00c1e9a41 Revision: 69384 blong@work:~/Documents/Work/REPOS__svn/R/R-3-2-branch$ svn status -u Status against revision: 69392 </code></pre> <p>Running <code>configure</code> and <code>make</code> in R's 3.2.2 branch have completed successfully and I'm able to use a variety of packages within an R session. However, I'd like to check that all of my libraries are up to date. In R 3.2.2 , I'm invoking <code>update.packages()</code>. When the function is invoked, I'm prompted to select a CRAN mirror : </p> <p><a href="https://i.stack.imgur.com/0LKME.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0LKME.png" alt="CRAN mirror selection dialog"></a></p> <p>Assuming everything is fine and this is a non-issue, I select the main ("<code>O-Cloud [https]</code>") mirror from the dialog. The dialog closes and I'm returned to my R prompt with a duplicate message saying "<code>unsupported URL scheme</code>".</p> <p>Simultaneously, I receive an error in my R session upon invoking <code>update.packages()</code>: </p> <pre><code>&gt; getOption("repos") CRAN "@CRAN@" &gt; update.packages() --- Please select a CRAN mirror for use in this session --- Error in download.file(url, destfile = f, quiet = TRUE) : unsupported URL scheme Warning: unable to access index for repository https://cran.rstudio.com/src/contrib: unsupported URL scheme &gt; </code></pre> <p>Considering that perhaps this is an issue with HTTPS, I try a non-SSL mirror and similarly nothing happens (perhaps there are no updates, but I'd like a message that tells me this). However, this time I don't receive the second "unsupported URL scheme" message after the dialog closes : </p> <pre><code>&gt; update.packages() --- Please select a CRAN mirror for use in this session --- Error in download.file(url, destfile = f, quiet = TRUE) : unsupported URL scheme &gt; </code></pre> <p>It seems that under the hood, R uses a library called RCurl to do some of it's HTTP/S interaction. As far as I can tell, I'm using a supported version of curl / libcurl : </p> <pre><code>blong@work:~$ curl --version curl 7.35.0 (x86_64-pc-linux-gnu) libcurl/7.35.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 librtmp/2.3 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smtp smtps telnet tftp Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP </code></pre> <p>Any thoughts on this? It seems similar to this <a href="http://r.789695.n4.nabble.com/update-packages-behavior-td4711966.html" rel="nofollow noreferrer">mailing list discussion</a>, but I'm not sure if this is an issue or I'm doing something wrong.</p>
5,386,519
0
<p>There are four kinds of Class relationships</p> <ol> <li>Association: <strong>uses a</strong><br> Ex:a Class Man uses a Class Pen</li> <li>Aggregation: <strong>has a</strong><br> Ex:a Class Man has a Class Car ( Car is still there when Man die )</li> <li>Composition: <strong>owns a</strong><br> Ex:a Class Man owns a Class Heart ( When Man die, Heart die )</li> <li>Inheritance: <strong>is a</strong><br> Ex:a Class Man is a Class Human ( Man is a Human )</li> </ol> <p>A relationship between classes of objects </p> <p><strong>Inheritance>Composition>Aggregation>Association</strong></p>
19,587,903
0
<p>In a Terminal window type <code>man ld</code> and you'll get a description of the <code>ld</code> command and the arguments it takes. There you'll find <code>-F</code> specifies a directory to search for frameworks in. The Xcode generated command line contains:</p> <pre><code>-F/Users/thomaswickl/Development/Git\ Projects/quickquick2/QuickQuick2 -F\"/Users/thomaswickl/Development/Git\ Projects/quickquick2/QuickQuick2/..\" -F/Users/thomaswickl/Development/Git\ Projects/quickquick2 </code></pre> <p>The second entry is actually redundant - it is the same as the third (as <code>..</code> means parent) - but it looks like your problem is the way the path is escaped. To allow a space in a path you can either enclose it in quotes or precede the space with a backslash. Paths 1 &amp; 3 use the backslash method, path 2 uses both and so the backslash is presumably treated as a literal character (that is what would happen in Terminal) and therefore the path is incorrect... (cross-eyed yet? ;-))</p> <p>Maybe this double-escaping was introduced when the project was converted to Xcode 5. The paths are listed in your project's settings (sorry Xcode not to hand), hunt it out and remove it (as its a duplicate).</p> <p>HTH.</p>
6,967,136
1
Is there any good alternative for python's webkit module that works on windows? <p>Is there any official good alternative for webkit that works on windows?</p>
1,329,817
0
<p>.NET certainly allows you to use Visual Basic to write a Windows Service. I believe there is even a default project template to do so. Here is an tutorial as such: <a href="http://www.vbdotnetheaven.com/UploadFile/mahesh/Winservvb11172005233242PM/Winservvb.aspx" rel="nofollow noreferrer">http://www.vbdotnetheaven.com/UploadFile/mahesh/Winservvb11172005233242PM/Winservvb.aspx</a></p> <p>All .NET code is converted to an intermediary language that is executed, thus all .NET languages can be used to write a windows service.</p>
8,887,896
0
Why does my KISS FFT plot show duplicate peaks mirrored on the y-axis? <p>I'm a beginner with FFT concepts and so what I understand is that if I put in 1024 signals, I'll get 513 bins back ranging from 0hz to 22050Hz (in the case of a 44100Hz sampling rate). Using KISS FFT in Cinder the getBinSize function returns the expected 513 values for an input of 1024 signals. What I don't understand is why duplicate peaks show up. Running a test audio sample that goes through frequencies (in order) of 20Hz to 22000Hz I see two peaks the entire time. It looks something like:</p> <p><em><strong></em>__<em>_</em>__</strong>|<em><strong></em>__<em>_</em>__<em>_</em>__</strong>|<em><strong></em>__<em>_</em>__</strong></p> <p>As the audio plays, the peaks seem to move towards each other so the second peak really does seem to be a mirrored duplicate of the first. Every example I've been through seems to just go ahead and plot all 513 values and they don't seem to have this mirroring issue. I'm not sure what I'm missing.</p>
29,892,858
0
How to deep link an app from the Facebook App builtin browser? <p>I have a link that when clicked loads a dynamic webpage (which performs some operations on the server), and then redirect the user to an installed app. So far, opening the link in the following apps/browsers works fine:</p> <ul> <li>Android's default browser;</li> <li>Chrome - several versions</li> <li>Twitter app</li> </ul> <p>Something similar is also being done on iOS, and works fine.</p> <p>The following <strong>does not work</strong>, no matter what I try:</p> <ul> <li>Sharing the link on Facebook, and opening it from the Facebook App with Facebook's builtin browser on Android (on iOS this works fine). I get an error saying "Page can't be loaded".</li> </ul> <p><strong>What has been done/tried:</strong></p> <p>The app has the needed content filters and intent setup correctly, and the filters were set to handle both a custom protocol scheme ("example://") and HTTP ("http", "example.com") - one at a time and both at the same time.</p> <p>Using <a href="http://applinks.org/" rel="nofollow">App Links</a> tags or Open Graph tags (as suggested by some FB literature) did not solve the problem.</p> <p>Redirecting the user with an HTTP redirect, javascript or meta refresh tag does not work.</p> <p>Using an HTML link and taping it does not work.</p> <p>All of those methods work <em>everywhere</em> except when using the Android Facebook App's builtin browser.</p> <p>(this was tested with several Android versions, 2.3, 4.4 and 5.0)</p> <p>Is there any special syntax for this kind of links to work?</p> <p>Thanks, Jean</p>
18,294,547
0
<p>You should probably first check if it is not a case issue: STATS vs Stats ...?</p>
12,800,513
0
<p>You could do the fallowing...</p> <pre><code>var GroupSelectView = Backbone.View.extend({ el: $("select"), initialize: function() { var that = this; this.collection = new UserGroups(); this.collection.on( 'change', this.render, this ); // You could try this too, 1 is for 1 item is added, the other, when all items are changed // this.postCollection.on('add', this.addOne, this); // this.postCollection.on('reset', this.addAll, this); this.render(); }, render: function(){ _.each(this.collection.models, function(group){ $("&lt;option/&gt;", { value: group.get("Id"), text: group.get("Name")} ).appendTo(this.el) }, this); }, }); </code></pre>
34,371,935
0
How to have separate urls for the same app in Django 1.9 <p>I have an app that will have 2 kinds of urls, one that will be included in other apps and one will be included in the settings app. I want to have a way to include only part of the urls without creating a seperate file for it. </p> <pre><code># records app -- urls.py urlpatterns = [ url(r'^create/$', RecordCreate.as_view(), name="record-create"), url(r'^(?P&lt;pk&gt;\d+)/update/$', RecordUpdate.as_view(), name="record-update"), url(r'^(?P&lt;pk&gt;\d+)/delete/$', RecordDelete.as_view(), name="record-delete"), ] urlpatterns_types = [ url(r'^$', RecordTypeList.as_view(), name="record-type-list"), url(r'^(?P&lt;pk&gt;\d+)/$', RecordTypeDetail.as_view(), name="record-type-detail"), url(r'^create/$', RecordTypeCreate.as_view(), name="record-type-create"), url(r'^(?P&lt;pk&gt;\d+)/update/$', RecordTypeUpdate.as_view(), name="record-type-update"), url(r'^(?P&lt;pk&gt;\d+)/delete/$', RecordTypeDelete.as_view(), name="record-type-delete"), ] </code></pre> <p>Now in the settings app I want to include only the <code>urlpatterns_types</code> urls. However I tried to include them but I couldn't</p> <p>The only way that I found to create separate files and then include them as a module</p> <p>Here is an example of the expected result</p> <pre><code># player app -- urls.py from django.conf.urls import patterns, include, url from .views import * urlpatterns = [ # Records App Urls url(r'^(?P&lt;player_id&gt;\d+)/records/', include('records.urls')), ] # settings app -- urls.py from django.conf.urls import patterns, include, url from .views import * urlpatterns = [ # Records App Urls url(r'^(?P&lt;player_id&gt;\d+)/records/', include('records.urls.urlpatterns_types')), ] </code></pre> <hr> <p>Project Tree</p> <pre><code>-- soccer_game -- soccer_game -- settings.py -- urls.py -- players -- models.py -- urls.py -- views.py -- main_settings -- models.py -- urls.py -- views.py </code></pre>
18,560,341
0
Accessing Protected Variable Of An Instance Of A Class That Extends An Abstract Base Class? <p>I have an abstract class called MyAction which contains a protected enum variable. The class is defined as follows:</p> <pre><code>package mypackage; public abstract class MyAction { public enum ActionId { ACTION1, ACTION2; } protected ActionId actionId; // constructor public MyAction(ActionId actionId) { this.actionId = actionId; } public ActionId getActionId() { return actionId; } ... ... } </code></pre> <p>I created a specific action, MyAction1, that extends MyAction:</p> <pre><code>package mypackage; public class MyAction1 extends MyAction { public MyAction1() { super(ActionId.ACTION1); } ... ... } </code></pre> <p>I have a singleton utility class (in the same package) that creates an instance of MyAction1 and stores it in a HashMap:</p> <pre><code>package mypackage; public class MyActionFactory { private static MyActionFactory theInstance; private HashMap&lt;ActionId, MyAction&gt; actions; private MyActionFactory() { actions = new HashMap&lt;ActionId, MyAction&gt;(); MyAction1 myAction1 = new MyAction1(); actions.put(myAction1.actionId, myAction1); // able to access protected variable actionId } public static VsActionFactory getInstance() { if (theInstance == null) theInstance = new VsActionFactory(); return theInstance; } ... ... } </code></pre> <p>Note that in the method <em>actions.put(<strong>myAction1.actionId</strong>, myAction1)</em> I am able to access the protected member <em>actionId</em>.</p> <p>Why is it that I can access the protected member <em>actionId</em> (contained in the base class <em>MyAction</em>) of the instance of <em>MyAction1</em>? I thought protected members were only accessible to subclasses. </p> <p>Does it have anything to do with <em>MyActionFactory</em> being in the same package as the others?</p>
21,317,940
0
Performing calculations on Django database values: views.py, template or Javascript? <p>I have a Django project that interfaces with a PostgreSQL database; one of my tables is about 450 rows long and each row contains about a dozen columns.</p> <p>Each column's value must be put into a different formula to produce the final data I want to display in the template layer, but each row will be processed with the same set of calculations. (In other words, I want to perform 12 different calculations 450 times each.)</p> <p>My question is, of the following methods, which is the generally accepted method of doing so, and which is the best in terms of performance:</p> <p>A) Write each calculation as a model method in models.py, query all objects of interest (again, about 450 of them) in views.py and pass them directly to the template, and then use Django's template language to write things like:</p> <pre><code>&lt;table&gt; {% for item in list %} &lt;tr&gt; &lt;td&gt;{{item.name}}&lt;/td&gt; ... &lt;/tr&gt; {% endfor %} &lt;/table&gt; </code></pre> <p>(where <code>.name</code> is a model method)</p> <p>B) Peform the query <em>and</em> calculations in the views.py file and pass the results organized into one big dictionary or list or JSON to the template (and then parse it using template tags),</p> <p>C) Pass all of the objects of interest to the template as in A), but perform calculations on each object's fields using Javascript or jQuery,</p> <p>D) Combine B) and C) to perform all database queries in views.py and then pass the <em>raw</em> values as a big dictionary/list/JSON object to the template and perform calculations on those values using Javascript/jQuery.</p> <p>To my mind, method A) seems the least efficient as it requires you to hit the database a ton of times in the template layer. But it makes writing the view and template extremely simple (just requires you to write 12 different model methods). Method B) seems to follow the general tenet of performing as much logic as possible in your view, and simply passing along the final results to be displayed in the template. But it makes the view function long and ugly. Methods C) and D) put most of load on the end user's browser, which seems like it could really take a load off the server, but then obviously won't work if the user has JS turned off.</p> <p>But again, I'd like to know if there's an accepted best practice for this kind of situation, and whether that contradicts the <em>fastest</em> method from a computational standpoint.</p> <p>And obviously, if I've missed the best method of all, please let me know what it would be.</p>
5,733,800
0
<blockquote> <p>if the dialog gets wider, but stays the same height, the number of rows should lessen, while the number of columns increases. </p> </blockquote> <p><a href="http://tips4java.wordpress.com/2008/11/06/wrap-layout/" rel="nofollow">Wrap Layout</a> might be what you are looking for.</p>
5,209,918
0
<p>try </p> <pre><code>strtotime(now()) </code></pre> <p>And you should definitely use <code>timestamp</code> or <code>datetime</code> as a type for your column.</p>
24,024,605
0
<p>There seem to be spaces in the file path:</p> <pre><code> New%20folder%20(2) </code></pre>
23,019,966
0
<p>give it a try</p> <pre><code>window.location.href.split("?")[0] </code></pre>
13,781,982
0
<p>Why not just make evey different view a different site, ie give the ads in each view a different id. It is a little bit of a pain to set this up if you have several applications/or lots of views, but I think that it should work.</p>
4,840,534
0
<p>You can get straight into programming with ruby.</p> <p>In terms of generic things to know I suggest you read a book, so you get one consistent message explaining all the basics.</p> <p>This is a great book to teach you programming in general and it teaches you using ruby. <a href="http://pragprog.com/titles/ltp2/learn-to-program" rel="nofollow">http://pragprog.com/titles/ltp2/learn-to-program</a></p> <p>Also have a go with <a href="http://tryruby.org" rel="nofollow">http://tryruby.org</a> - Quick ruby tutorial in your browser</p> <p>Finally check out the hackety-hack project it's designed to help people learn to program, although version 1 is only just out. <a href="http://hackety-hack.com/" rel="nofollow">http://hackety-hack.com/</a></p>
16,839,452
0
<p>I solve it with ajax call. </p> <pre><code> &lt;script type="text/javascript"&gt; $(document).ready(function () { $("input[type = radio]").each(function (index, value) { $(value).click(function () { $.ajax({ type: "POST", url: "http://localhost:2782/TestPage.aspx/GetBank", data: "{id:" + value.defaultValue + "}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { $("#dvBankInfo").empty(); $("#dvBankInfo").append(data.d); } }); }); }); }); &lt;/script&gt; </code></pre>
6,305,711
0
<p>Wrap your content inside a ScrollView</p>
14,072,017
0
Iterating over records in an ExtJS store and filtering on a specific field <p>I am iterating over records in a store as they come in like so:</p> <pre><code>Ext.create('Ext.data.Store', { model: 'Message', storeId: 'Staging', proxy: { type: 'memory', reader: { type: 'json' } }, listeners: { add: function(store, records, index, eOpts){ if (!Ext.data.StoreManager.lookup('Historical').isLoading()) { this.each(function(item, index, count) { if(item.notificationType === 'INBOX'){ // populate inbox store // increment the unread inbox count console.log('inbox'); } else if (item.notificationType === 'NOTIFICATION') { // populate notifications store // increment the unread notification count } }); // no historical data should be held in memory for performance this.removeAll(); } } } }); </code></pre> <p>The <em>item.notificationType</em> property returns undefined.</p> <p>I have tried other properties but they also return undefined.</p> <p>I need to perform different actions when different types are encountered and thought this would do it!</p> <p>So the item is a record in the store which contains json in the structure as follows:</p> <pre><code> { "source":"2", "target":"1416529", "sourceType":"USER", "redirectUrl":null, "message":"cow's go...", "id":606, "targetType":"TEAM", "messageType":"TIBRR_WALL_MESSAGE", "notificationType":"INBOX", "sentDate":1356599137173, "parameters":null, "targetId":"1416529", "sourceId":"2", "dispatched":true, "read":false, "readDate":null, "dispatchedDate":1356599137377 } </code></pre>
36,278,026
0
Multithreading extended panel <p>I'm trying to allocate a <code>JPanel</code> that implements <code>Runnable</code> interface in a <code>JFrame</code>. I'd made this sample for interpret my idea. I want to add a multi-threading panel that shows a text as demo to a window with a <code>String</code> as parameter of a new instance. The panel should have independent process so I implemented <code>Runnable</code> interface. But when I try to create a new instance o panel with a new instance of my class, It doesn't work.</p> <p>What I am doing wrong?</p> <p>imagePanel Panel class:</p> <pre><code>public class imagePanel extends JPanel implements Runnable{ JLabel imageTest; public imagePanel(String textLabel) { this.setPreferredSize(new Dimension(300,300)); imageTest = new JLabel(textLabel); imageTest.setPreferredSize(this.getPreferredSize()); } public void setImageText(String newText){ imageTest.setText(newText); } public void run(){ this.add(imageTest); } } </code></pre> <p>Main class test class:</p> <pre><code>public class test { public static void main(){ JFrame frame = new JFrame("Test Window"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setPreferredSize(new Dimension(300,300)); JPanel panel = new imagePanel("Text label"); panel.setPreferredSize(frame.getPreferredSize()); frame.add(panel); frame.setVisible(true); } } </code></pre>
3,154,488
0
How do I iterate through the files in a directory in Java? <p>I need to get a list of all the files in a directory, including files in all the sub-directories. What is the standard way to accomplish directory iteration with Java?</p>
9,110,259
0
<p>I've never used swfobject but from what I'm seeing you've created a swf object and are asking it to be added to the videoDiv element. Are you sure you want this behaviour ?</p> <p>Because from where I'm standing I think you should have used the createSWF method and added the returned object to your html array.</p>
2,848,401
0
Selecting all tables with no records <p>I need to display all tables that have zero records.</p> <p>I tried,</p> <pre><code>select * from user_all_tables where (select count(*) from user_all_tables)=0; </code></pre> <p>But it doesn't seem to work. How should I go about redesigning this query? Thanks.</p>
33,824,549
0
<p>This is what you want:</p> <pre><code>echo "$line" | sed -E 's/(QA.|DEV.)(.*)/&lt;!-- \1\2 --&gt;/' </code></pre> <p>The <strong>first group</strong> could be prefixed by <code>QA</code> or <code>DEV</code> , use the <code>|</code> <em>or</em> operator.</p> <p>A <em>few</em> <strong>alternatives</strong>:</p> <pre><code>$ echo "QA2 ABCDEFGHI"|sed -E 's/(.*)/&lt;!-- \1 --&gt;/' &lt;!-- QA2 ABCDEFGHI --&gt; $ echo "QA2 ABCDEFGHI"|awk '{print "&lt;!-- "$0"--&gt;"}' &lt;!-- QA2 ABCDEFGHI--&gt; </code></pre>
3,429,523
0
What does this line of C/C++ preprocessor mean? <p>This is Line 519 of <code>WinNT.h</code> (BUILD Version: 0091)</p> <pre><code>#define DECLARE_HANDLE(name) struct name##__{int unused;}; typedef struct name##__ *name </code></pre> <p>Why do we need a pointer to an struct with a single int member with a weird name called <code>unused</code>?</p> <p>And will we ever need to use a line of code like this one?</p> <pre><code>HINSTANCE hInstance = new HINSTANCE__; </code></pre> <p>Overall declaring different data types with the same structures, doesn't make sense to me. What's the idea behind this?</p> <pre><code>DECLARE_HANDLE(HRGN); DECLARE_HANDLE(HRSRC); DECLARE_HANDLE(HSPRITE); DECLARE_HANDLE(HLSURF); DECLARE_HANDLE(HSTR); DECLARE_HANDLE(HTASK); DECLARE_HANDLE(HWINSTA); DECLARE_HANDLE(HKL); </code></pre>
18,600,509
0
<p>You need put the code bellow:</p> <pre><code> ClassicEngineBoot.getInstance().start(); </code></pre> <p>Inside your bootstrap. It's worked for me, in Grails.</p>
17,006,528
0
<p>You can configure IntelliJ to use a lot of different application containers, but each of them must be downloaded and installed separately. I currently have mine configured to serve via jetty, like eclipse, and also tomcat, tc-server, jboss, and node.js. It's pretty easy to set up.</p>
35,531,950
0
<p>Refer the sample <a href="https://jsfiddle.net/shashank2691/kx4s6pq0/2/" rel="nofollow">here</a>.</p> <p><strong>Code:</strong></p> <p><em>HTML:</em></p> <pre><code>&lt;div ng-app="app" ng-controller="test as vm"&gt; &lt;div test-dir="user" ng-repeat="user in vm.users"&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p><em>JS:</em></p> <pre><code>var app = angular.module('app', []); app.controller('test', function ($scope) { var vm = this; vm.users = [ { 'Name': 'Abc', 'Id': 1 }, { 'Name': 'Pqr', 'Id': 2 }, { 'Name': 'XYZ', 'Id': 3 } ]; $scope = vm; }); app.directive('testDir', function () { return { scope: { user: '=testDir' }, template: "&lt;div&gt;&lt;h4&gt;{{user.Id}}) {{user.Name}}&lt;/h4&gt;&lt;/div&gt;" } }); </code></pre>
31,255,971
0
<pre><code>func itemMutableArray() -&gt; NSMutableArray { return NSMutableArray(array: (item.allObjects as! [Item]).sorted{ $0.date.compare($1.date) == NSComparisonResult.OrderedAscending } ) } </code></pre>
33,020,711
0
Showing alert panel when inventory reaches critical <p>I'm trying to show when an inventory is lower than critical. It doesn't seem to get there when I debug the system </p> <p>This is my code behind </p> <pre><code>protected void Page_Load(object sender, EventArgs e) { GetInventory(); TotalCount(); CriticalItem(); Panel1.Visible = false; } void TotalCount() { con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "SELECT 'Total Count of Inventory ' + '(' + convert(nvarchar,SUM(Quantity)) + ')' AS TotalCount from Inventory"; SqlDataReader data = cmd.ExecuteReader(); if (data.HasRows) { while (data.Read()) { lblTotalCount.Text = data["TotalCount"].ToString(); } con.Close(); } else { con.Close(); Response.Redirect("Default.aspx"); } } void GetInventory() { con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "SELECT Inventory.InventoryID, Products.ProductName, " + "Supplier.SupplierName, Inventory.Quantity, Users.LastName + ', ' + Users.FirstName AS UserAccount, " + "SupplierProducts.CriticalLevel, Inventory.Status, Inventory.DateAdded, Inventory.DateModified, SupplierProducts.Price FROM Inventory " + "INNER JOIN SupplierProducts ON Inventory.ProductID = SupplierProducts.SupplierProductID " + "INNER JOIN Products ON SupplierProducts.ProductID = Products.ProductID " + "INNER JOIN Supplier ON Inventory.SupplierID = Supplier.SupplierID " + "INNER JOIN Users ON Inventory.UserID = Users.UserID"; SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds, "Inventory"); lvInventory.DataSource = ds; lvInventory.DataBind(); con.Close(); } void CriticalItem() { var intcheck = new DataTable(); using (var da = new SqlDataAdapter("SELECT * FROM Inventory", con)) { da.Fill(intcheck); } var critcheck = new DataTable(); using (var da = new SqlDataAdapter("SELECT * FROM SupplierProducts", con)) { da.Fill(critcheck); } int finalQuantity = Convert.ToInt32(intcheck.Rows[0]["Quantity"]); int criticalLevel = Convert.ToInt32(critcheck.Rows[0]["CriticalLevel"]); if (finalQuantity &gt; criticalLevel) { Panel1.Visible = true; criticalItem.Text = "Available"; } } </code></pre> <p>I want to criticalItem.text to tell the Inventory that is less than its critical level.</p>
9,192,507
0
analyzing sequences matlab <p>I am trying to write a short matlab function that will recieve a vector and will return me the index of the first element of the longest sequence of 1s (I can assume that the sequence consists of 1s and 0s). for example: </p> <blockquote> <blockquote> <p>IndexLargeSeq([110001111100000000001111111111110000000000000000000000000000000]) </p> </blockquote> </blockquote> <p>will return 21 - which is the index of the first 1 of the longest sequence of 1s.<br> thank you<br> ariel</p>
32,116,366
0
<p>The full method is pasted below. When calling JTable::getInstance you must pass $type as an argument. The getInstance method then uses $type to define $tableClass as you can see below. </p> <pre><code>// Sanitize and prepare the table class name. $type = preg_replace('/[^A-Z0-9_\.-]/i', '', $type); $tableClass = $prefix . ucfirst($type); </code></pre> <p>The method then proceeds to load (import) the class if it's not already and then finally calls return new $tableClass($db);</p> <p>So $tableClass is just a dynamic variable based on the $type argument. </p> <p>In your example above: </p> <pre><code>$row = JTable::getInstance('K2Item', 'Table'); </code></pre> <p>The $type and $prefix arguments are translated into the following:</p> <p>return new TableK2Item($db);</p> <p>So if you search for TableK2Item you should indeed find that class which has a hit() method.</p> <p>So $tableClass is actually defined in the getInstance method. </p> <p>Does this make sense?</p> <pre><code>/** * Static method to get an instance of a JTable class if it can be found in * the table include paths. To add include paths for searching for JTable * classes see JTable::addIncludePath(). * * @param string $type The type (name) of the JTable class to get an instance of. * @param string $prefix An optional prefix for the table class name. * @param array $config An optional array of configuration values for the JTable object. * * @return mixed A JTable object if found or boolean false if one could not be found. * * @link https://docs.joomla.org/JTable/getInstance * @since 11.1 */ public static function getInstance($type, $prefix = 'JTable', $config = array()) { // Sanitize and prepare the table class name. $type = preg_replace('/[^A-Z0-9_\.-]/i', '', $type); $tableClass = $prefix . ucfirst($type); // Only try to load the class if it doesn't already exist. if (!class_exists($tableClass)) { // Search for the class file in the JTable include paths. jimport('joomla.filesystem.path'); $paths = self::addIncludePath(); $pathIndex = 0; while (!class_exists($tableClass) &amp;&amp; $pathIndex &lt; count($paths)) { if ($tryThis = JPath::find($paths[$pathIndex++], strtolower($type) . '.php')) { // Import the class file. include_once $tryThis; } } if (!class_exists($tableClass)) { // If we were unable to find the class file in the JTable include paths, raise a warning and return false. JLog::add(JText::sprintf('JLIB_DATABASE_ERROR_NOT_SUPPORTED_FILE_NOT_FOUND', $type), JLog::WARNING, 'jerror'); return false; } } // If a database object was passed in the configuration array use it, otherwise get the global one from JFactory. $db = isset($config['dbo']) ? $config['dbo'] : JFactory::getDbo(); // Instantiate a new table class and return it. return new $tableClass($db); } </code></pre>
5,661,392
0
<p>You can't actually modify/save the image in javascript/jquery (as far as i know). You'll have to use server-side image manipulation libraries like gdlib (http://www.boutell.com/gd/) which is usually activated by default in php, or imagemagick (http://www.imagemagick.org/script/index.php)</p>
6,398,767
0
Is it possible to define the asset name in a custom XNA content processor? <p>Normally, when loading content using XNA's Content Pipeline, the compiled .xnb files are accessed using an assigned "Asset Name" that can be defined in the Visual Studio GUI. By default, this name is the same as the content's filename sans extension. As a result, you cannot normally load two files that have names differing only by extension as the generated .xnb files would have conflicting names. If you manually change the asset name of one of these files, the generated .xnb files no longer conflict.</p> <p>For a level loading system I am writing, I was hoping to have the setup of loading the texture data and collision data from two separate files with the same name (level1.png and level1.col) where the collision data is simply a text file. I have written a custom content processor to load the collision data using the Content Pipeline.</p> <p>It seems it is not possible to modify the asset name directly in normal game code, but I have been unable to determine if it can be done from within a custom content processor. Is this possible? Or must I modify all the asset names by hand in order to do this?</p> <p>I would ask this on the App Hub forums, but I am having a rather difficult time trying to log into that site without registering (and giving credit card information) for the developer package. I'm currently using XNA for a Windows platform game, and have no interest in developing for the X360 at this time.</p>
28,815,064
0
<p>My favorite method is to add a <code>text-align: center;</code> to the parent element, then use <code>display: inline-block;</code> instead of <code>float: left;</code></p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.thumbsPanel { border: thin black dashed; width: 800px; height: 500px; margin: 0 auto; text-align: center; } .thumbs { display: inline-block; width: 100px; height: 100px; border: 0; margin: 0 1em 1em 0; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="thumbsPanel"&gt; &lt;div class="thumbs"&gt;&lt;a href="1.html"&gt;&lt;img src="1.jpg"&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="thumbs"&gt;&lt;a href="2.html"&gt;&lt;img src="2.jpg"&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="thumbs"&gt;&lt;a href="3.html"&gt;&lt;img src="3.jpg"&gt;&lt;/a&gt;&lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
38,279,184
0
<p>I too faced same error today in my website where i use TCPDF Library to generate PDFs. It was working fine but suddenly i started to get the following error today </p> <pre><code>Severity: 8192 Message: Imagick::clone method is deprecated ..... </code></pre> <p>Might be the hosting provider updated PHP or Imagick. PHP - 5.4 and Imagick - 3.x</p> <p>So to get rid of this in my code, i set error_reporting as </p> <pre><code>error_reporting(E_ALL &amp; ~E_NOTICE &amp; ~E_STRICT &amp; ~E_DEPRECATED); </code></pre> <p>And this will show the errors but not the deprecated notices. Meanwhile I can change my code to support the new version of Imagick.</p>
26,055,668
0
<p>I would prefer to do like this:</p> <pre><code>if (window.onpopstate != undefined) { window.onpopstate = locate; } else { window.onhashchange = locate; } </code></pre> <p>so if "msie" add this functionality you do not depend on old code</p>
25,804,331
0
<p>You have an quite common mistake.</p> <p>In your collection, the field is named <code>listname</code> (note the lowercase) whereas in your query the field is name <code>listName</code> (note the camel case). Field names are case sensitive. so when adjusting the first query to</p> <pre><code>db.testcol.find({ "msgs.listname": { "$nin":[ "list1" ] } }).pretty() </code></pre> <p>you get the expected result.</p> <p><strong>EDIT</strong></p> <p>As @NeilLunn correctly pointed out in the comments, the better approach when ruling out a <strong>single</strong> value as per the question would be:</p> <pre><code>db.testcol.find({ "msgs.listname": { "$ne": "list1" } }) </code></pre> <p>This approach is both cleaner and faster when just a single value needs to be ruled out.</p> <p>All kudos to him.</p>
14,273,974
0
<p>If you want to save modified source as html you can use different aproaches, depends on what you want to mainupulate. Sadly with javascript saveing file is tricky and depends on many things, so you could use option to copy paste file source manually or write your browser and settings specific file saver. I would prefer javascript+php combo solution. Or if there is no need to manipulate someting with javascript i would do it entirely in php.</p> <p>Step 1 - open browser with console, in chrome and firefox CTRL+SHIFT+J And allow popups. Step 2 - open webpage you want Step 3 - Copy next code to console</p> <pre><code>//Script loading function function load_script( source ) { var new_script = document.createElement('script'); new_script.type = 'text/javascript'; new_script.src = source; new_script.className = 'MyInjectedScript'; document.getElementsByTagName('head')[0].appendChild(new_script); } function escapeHtml(unsafe) { return unsafe .replace(/&amp;/g, "&amp;amp;") .replace(/&lt;/g, "&amp;lt;") .replace(/&gt;/g, "&amp;gt;") .replace(/"/g, "&amp;quot;") .replace(/'/g, "&amp;#039;"); } //Load jQuery, if page do not have it by default if (typeof(jQuery) != 'function') load_script('http://code.jquery.com/jquery-latest.js'); </code></pre> <p>Step 4 - Do your manipulations in console</p> <p>Step 5 - Copy next code to console</p> <pre><code>//In the end remove your injected scripts $('.MyInjectedScript').remove(); //Or jquery script will be in source //get Document source var doc_source = $('html',document).html(); doc_source = '&lt;html&gt;'+doc_source+'&lt;/html&gt;'; var new_window = window.open('', '', 'scrollbars=yes,resizable=yes,location=yes,status=yes'); $(new_window.document.body).html('&lt;textarea id="MySource"&gt;'+escapeHtml(doc_source)+'&lt;/textarea&gt;'); </code></pre> <p>STEP 6 - copy paste code from opened window textarea</p> <p>If you want to do it with PHP you can easily download page with curl and manipulate content and save file as desired.</p>
29,623,000
0
Enable form based login in Jboss EAP 6.3 <p>Following the <a href="https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.3/html/Security_Guide/Enable_Form-based_Authentication.html" rel="nofollow">official tutorial</a> form-based auth is achieved by simply adding this to web.xml:</p> <pre><code>&lt;login-config&gt; &lt;auth-method&gt;FORM&lt;/auth-method&gt; &lt;form-login-config&gt; &lt;form-login-page&gt;/loginform.html&lt;/form-login-page&gt; &lt;form-error-page&gt;/loginerror.html&lt;/form-error-page&gt; &lt;/form-login-config&gt; &lt;/login-config&gt; </code></pre> <p>I did that, but web.xml gets ignored when deploying.</p> <pre><code>[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ig nored (webxml attribute is missing from war task, or ignoreWebxml attribute is specifi ed as 'true') </code></pre> <p>The loginForm.jsp is this:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;title&gt;loginForm.jsp&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h2&gt;Please login to add employees&lt;/h2&gt; &lt;form action="j_security_check" method=post&gt; &lt;p&gt;&lt;strong&gt;Username: &lt;/strong&gt; &lt;input type="text" name="j_username" size="25"&gt; &lt;p&gt;&lt;p&gt;&lt;strong&gt;Password: &lt;/strong&gt; &lt;input type="password" size="15" name="j_password"&gt; &lt;p&gt;&lt;p&gt; &lt;input type="submit" value="Submit"&gt; &lt;input type="reset" value="Reset"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Full web.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt; &lt;display-name&gt;form_auth&lt;/display-name&gt; &lt;login-config&gt; &lt;auth-method&gt;FORM&lt;/auth-method&gt; &lt;form-login-config&gt; &lt;form-login-page&gt;/loginform.html&lt;/form-login-page&gt; &lt;form-error-page&gt;/loginerror.html&lt;/form-error-page&gt; &lt;/form-login-config&gt; &lt;/login-config&gt; &lt;security-role&gt; &lt;role-name&gt;admin&lt;/role-name&gt; &lt;/security-role&gt; &lt;/web-app&gt; </code></pre> <p>How do I achieve form-based auth?</p>
35,938,700
0
<p>Pointers do not keep information whether they point to single objects or for example first elements of arrays.</p> <p>Consider the following code snippet</p> <pre><code>char *p; char c = 'A'; p = &amp;c; putchar( *p ); char s[] = "ABC"; p = s; putchar( *p ); </code></pre> <p>Thus you have to provide yourself the information about whether a pointer points to an element of an array.</p> <p>You can do this in two ways. The first one is to specify the number of elements in the sequence the first element of which is pointed to by the pointer. Or the sequence must to have a sentinel value as strings have.</p> <p>For example</p> <pre><code>int a[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; for ( int *p = a; p &lt; a + sizeof( a ) / sizeof( *a ); ++p ) ^^^^^^^^^^^^^^^^^^^^^^^^^^ { printf( "%d ", *p ); } printf( "\n" ); </code></pre> <p>Or</p> <pre><code>int a[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; int *p = a; do { printf( "%d ", *p ); } while ( *p++ != 0 ); ^^^^^^^^^ printf( "\n" ); </code></pre> <p>These code snippets can be written as functions</p> <pre><code>void f( int a[], size_t n ) { for ( int *p = a; p &lt; a + n; ++p ) { printf( "%d ", *p ); } printf( "\n" ); } </code></pre> <p>Or</p> <pre><code>void f( int a[] ) { int *p = a; do { printf( "%d ", *p ); } while ( *p++ != 0 ); printf( "\n" ); } </code></pre> <p>The same way an array of strings can be printed. Either you will report explicitly the number of elements in the array yourself. Or you can use a sentinel value as for example a null pointer or an empty string.</p> <p>For example</p> <pre><code>#include &lt;stdio.h&gt; void PrintStringArray( char *s[], size_t n ) { for ( char **p = s; p &lt; s + n; ++p ) { puts( *p ); } printf( "\n" ); } int main( void ) ^^^^^^^^^^^^^^^^ { char *list[] = { "Green", "Yellow", "Black", "White", "Purple", "Saphire" }; PrintStringArray( list, sizeof( list ) / sizeof( *list ) ); return 0; } </code></pre> <p>Or</p> <pre><code>#include &lt;stdio.h&gt; void PrintStringArray( char *s[] ) { char **p = s; while ( *p != NULL ) { puts( *p++ ); } printf( "\n" ); } int main( void ) ^^^^^^^^^^^^^^^^ { char *list[] = { "Green", "Yellow", "Black", "White", "Purple", "Saphire", NULL ^^^^ }; PrintStringArray( list ); return 0; } </code></pre>
3,445,157
0
<p>Give this version a shot:</p> <pre><code>public void onDrawFrame(GL10 gl) { gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gl.glLoadIdentity(); GLU.gluLookAt(gl, 0, 0, 100, 0, 0, 0, 0, 1, 0); for (int i = 0; i &lt; obj.size; i++) { // obj is an array of positions obj = mObj[i]; gl.glPushMatrix(); gl.glTranslatef(obj.position.x(), obj.position.y(), obj.position.z()); gl.glRotatef(obj.rotation.x(), 1f, 0f, 0f); gl.glRotatef(obj.rotation.y(), 0f, 1f, 0f); gl.glRotatef(obj.rotation.z(), 0f, 0f, 1f); obj.draw(gl); // the objects 'draw' themselves gl.glPopMatrix(); } } </code></pre>
5,599,010
0
Defining Trending Topics in a specific collection of tweets <p>Im doing a Java application where I'll have to determine what are the Trending Topics from a specific collection of tweets, obtained trough the Twitter Search. While searching in the web, I found out that the algorithm defines that a topic is trending, when it has a big number of mentions in a specific time, that is, in the exact moment. So there must be a decay calculation so that the topics change often. However, I have another doubt:</p> <p>How does twitter determines what specific terms in a tweet should be the TT? For example, I've observed that most TT's are hashtag or proper nouns. Does this make any sense? Or do they analyse all words and determine the frequency? </p> <p>I hope someone can help me! Thanks! </p>
13,959,172
0
Issue with JSON sending <p>Hey guys so I am trying to have a JSON send over a value to another page in wordpress to create a session once a image is clicked on. </p> <p>Here is the JSON code:</p> <pre><code>$('.item-post a').click(function() { var prodname = $('#hiddenpostitle'); $.post('/overviewcheck-515adfzx8522', { 'ProdName': prodname.val() }, function(response) { }, 'json' ); }); </code></pre> <p>The #hiddenposttitle is the following: <code>&lt;?php echo "&lt;input type='hidden' value='$title' id='hiddenpostitle' name='hiddenpostitle'/&gt; "?&gt;</code></p> <p>So this sends to the overviewcheck page, which then has a template that has the follow:</p> <pre><code>&lt;?php /* Template Name: overviewbackcheck */ session_start(); $prodname= $_POST['ProdName']; $_SESSION['overviewprod'] = $prodname; ?&gt; </code></pre> <p>Someone mentioned something about wordpress destroying sessions from calling session_start() but that's not the issue because I fixed that awhile ago, and have other sessions being made that work. It has to do something with the JSOn sending over and I am not to sure.</p> <p>From here the overview page is opened with the following:</p> <pre><code>$(function() { $('.item-post a').colorbox({opacity:0.3, href:"../overviewa512454dzdtfa"}); }); </code></pre> <p>This is the colorbox code that will open the file the within the file I have:</p> <pre><code>&lt;?php echo $_SESSION['overviewprod']; ?&gt; </code></pre> <p>to echo it out. </p> <p>Ultimately I am unable to echo out a session and it does not seem anything is being made.</p> <p>If you could help me out that would be awesome because I need this finished! :)</p>
23,753,604
0
Add "Rubber Band" effect in android while changing background of application <p>I am working on the application in which:</p> <p>User will have a control to change the background and text (multiples) by doing horizontal swipe for BG and vertical swipe for text. In this case, if I am changing BG, text should remain constant and if I am changing text then BG should remain constant. </p> <p>Also, I want to add <strong><code>Rubber Band effect</code></strong> like in iOS when user changes Text and BG.</p> <p>I am thinking of <a href="https://github.com/lucasr/twoway-view" rel="nofollow"><strong><code>twoway-view</code></strong></a> library to support for vertical and horizontal scrolling. But how to use this library in my case?</p> <p>Any idea/solution will be appreciated. </p>
40,997,145
0
Ruby hash access value from string array <p>I have an hash like below:</p> <pre><code>hash = {"a": [{"c": "d", "e": "f"}] } </code></pre> <p>Normally we can access it like <code>hash["a"][0]["c"]</code>.</p> <p>But, I have a string like:</p> <pre><code>string = "a[0]['c']" </code></pre> <p>(This can change depending upon user input)</p> <p>Is there any easy way to access hash using above string values?</p>
24,604,385
0
<p>You can prevent it by setting rule for semester_id as follows</p> <pre><code>$this-&gt;form_validation-&gt;set_rules('semester_id', 'input_name', 'trim|required|is_unique[TABLENAME.COLUMNNAME]'); </code></pre>
6,094,073
0
<p><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/replace" rel="nofollow">https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/replace</a></p> <p>You might use a regular expression with the "g" (global match) flag.</p> <pre><code>var entities = {'&lt;': '&amp;lt;', '&gt;': '&amp;gt;'}; '&lt;inputtext&gt;&lt;anotherinputext&gt;'.replace( /[&lt;&gt;]/g, function (s) { return entities[s]; } ); </code></pre>
32,301,294
0
<p>Here's another vectorized approach. It tries all permutations of rows of <code>B</code>, and produces the optimal row-permuted <code>B</code> in matrix <code>Bresult</code>.</p> <pre><code>[m, n] = size(A); ind = perms(1:m); % // all permutations of row indices BB = permute(reshape(B(ind.',:),m,[],n),[1 3 2]); %'// all row-permuted B matrices C = sum(sum(abs(bsxfun(@minus, A, BB)),2),1); % // compute the sum for each [minsum, imin] = min(C); % // minimize Bresult = B(ind(imin,:),:); % // output result </code></pre>
20,429,150
0
<h2>Regex</h2> <pre><code>^\&lt;[^\&gt;]+\&gt;.*$ </code></pre> <p><a href="http://regex101.com/r/iU2qX3" rel="nofollow">Demo</a></p> <p>Is what i'd switch to or</p> <pre><code>^\&lt;pstyle\:Chapter\&gt;.*$ </code></pre> <p><a href="http://regex101.com/r/aV0rH3" rel="nofollow">Demo</a></p> <p>or</p> <pre><code>^\&lt;pstyle\:Chapter\&gt;LXXI.*$ </code></pre> <p><a href="http://regex101.com/r/aI1zY5" rel="nofollow">Demo</a></p>
40,744,181
0
Client Credential Flow without Admin login <p>Following <a href="https://blogs.msdn.microsoft.com/exchangedev/2015/01/21/building-daemon-or-service-apps-with-office-365-mail-calendar-and-contacts-apis-oauth2-client-credential-flow/" rel="nofollow noreferrer">these</a> instructions on implementing client credential flow, using <a href="https://github.com/mattleib/o365api-as-apponly-webapp" rel="nofollow noreferrer">this</a> sample repo to test on, I got a running version of an app using client credential flow that can read email, calendar, contacts.</p> <p>However I need to sign in with my O365 tenant admin every time I run it and grant access to the application to read emails, calendar, etc. </p> <p>Isn't the whole point of Client Credential Flow (app-only) that I shouldn't need to enter any credentials to read data, since I've created a certificate that connects my AAD-app with my web-app. </p> <p>The only thing I can think of is that I have to sign in with the admin just once to set it up properly, but then it makes no sense that I get prompted to login as admin every time I run the application (running on localhost). </p>
10,844,111
0
<p>You specified <code>fill_parent</code> for both the <code>layout_width</code> and <code>layout_height</code> of your <code>RelativeLayout</code>, therefore it fills up it's parent view. By default, a relative layout arranges it's children to the top-left corner, regardless you use <code>fill_parent</code> for the size. </p> <p>You should achieve the desired aspect by taking advantage of the <code>RelativeLayout's</code> own attribute set, which helps you arrange the child views <strong>relatively</strong> to each other or to their parent:</p> <pre><code>&lt;ImageButton android:id="@+id/buttonLog" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:background="@drawable/log" android:onClick="log" /&gt; </code></pre> <p>Using the <code>android:layout_centerInParent</code> you can achieve this. This attribute if set true, centers this child horizontally and vertically within its parent.</p>
17,474,616
0
<p>There was nothing wrong with the angular directives it just that CHROME was seeing the request as the same therefore not executing it... and just binding the same data to every ajax request... </p>
8,264,627
1
How to deal with a Class generated exception from within Main <p>I'm having some trouble getting my head around how best to solve this situation (mostly due to lack of experience I think). I have written a couple of definitions in a single class that are called from a Main to perform certain tasks. It is assumed the Main could be written by anyone for a number of purposes, so killing the code in the class definition is not preferable. One basic rule of these definitions is, if def1 does its tasks successfully, def2 can be called. But if def1 fails, def2 must not be called as it will fail also.</p> <p>e.g. semi pseudo code, without exceptions:-</p> <pre><code># Test.py if __name__ == '__main__' # variables imported from a file var1 = a var2 = b class.def1(var1, var1) class.def2(var_from_def1) </code></pre> <p>Initially I just performed a sys.exit() in the def1 except:, but as mentioned previously, killing the whole program was undesirable and that it would be preferable to let the exception be thrown and let the Main control whether to call def2. </p> <p>From my understanding of exceptions (as limited as it is) this wouldn't work as the exception operation needs to have already been defined before it is raised. Unless it can be defined in Main, but I'd rather Main has an option to do that.</p> <p>A preferred solution would be for the Main to import the variables, pass them to def1, if def1 failed and Main was not set up to catch the exception the following call to def2 would be cleanly stopped (without killing the process or displaying a fail), no idea how to do that, or if the Main was catching exceptions it could stop the call to def2, load in another set of variables and try def1 again.</p> <p>Here is a conceptual view of the code which may help understand where I'm coming from.</p> <pre><code># Test.py if __name__ == '__main__' # variables imported from file var1 = a var2 = b while new variables to pull from file: try: class.def1(var1, var1) except: print 'def1 exception thrown' else: class.def2(var_from _def1) # class.py class class(object): def def1(self, var1, var2): try: do something potentially flawed except: # this is where I get stuck, not sure how or if I can pass an exception back to the main to decide what to do sys.stdout.write('didn't work') return something </code></pre> <p>Sorry, it does look messy, it's a combination of a few ideas for solutions I had, which probably shouldn't be mixed together.</p> <p>Any suggestions would be great. I have read a few books and forums regarding exceptions but just can't grasp how to best resolve this scenario.</p> <p>Thanks.</p>
17,219,355
0
<p>use the attributes['xxx'].value</p>
27,099,914
0
<p>I have face the same issue before but I do not understand that why this occur.But I have solve it by declaring variable using $ sign instead of var.</p> <pre><code> $('#numberOfItems').keyup(function(){ $items = $('#numberOfItems').val(); $weightitem = $('#weightitem').val(); $totalweight = $items * $weightitem; $('#totalweight').val($totalweight); }); </code></pre>
24,710,728
0
<p>you need to set these attributes of elements as as:</p> <pre><code>$(document).ready(function () { $('#group').on('click', '.add_subgroup', function () { var i = $('div.subgroup').length; var where = $('#group'); var subgroup = $('#subgroup_hidden').clone(); var j = i + 1; subgroup.attr({ 'id': 'subgroup_' + j, 'class': 'subgroup' }).appendTo(where); subgroup.find('input, select, textarea').each(function(){ $(this).attr({ name: '', value: '' }) if($(this).is('textarea')) $(this).text(''); }) i++; }); $('#group').on('click', '.remove_subgroup', function () { $(this).closest('.subgroup').remove(); }); }); </code></pre> <p><a href="http://jsfiddle.net/8wUg8/" rel="nofollow">working fiddle</a></p>
22,396,045
0
Post a image into facebook app using app id <p>I need to post the image using the image url in my facebook app is that possible? How to post image to Facebook on button click? I have stored imageUrl in variable image and the facebook URL in the variable shareUrl, </p> <pre><code>following is the complete facebook URL : "https://www.facebook.com/dialog/feed?app_id=843228839026054&amp;caption=example.com&amp;display=popup&amp;redirect_uri="+encodeURIComponent("http://www.facebook.com/")+"&amp;name=%title%&amp;description=%desc%&amp;picture=%image%". &lt;html&gt; &lt;head&gt; &lt;script&gt; var doShare = function(title, description) { if(title &amp;&amp; description) { image="http://www.sxc.hu/assets/182945/1829445627/small-flowers-1019552-m.jpg"; /* for readability i store the url like this, above this code u can find the complete facebook url. */ shareUrl = "https://www.facebook.com/dialog/feed?"; shareUrl += "app_id=843228839026054&amp;caption=example.com&amp;display=popup&amp;"; shareUrl += "redirect_uri="+encodeURIComponent("http://www.facebook.com/"); shareUrl += "&amp;name=%title%&amp;description=%desc%&amp;picture=%image%"; var url = shareUrl.replace(/%title%/g, encodeURIComponent(title)); url = url.replace(/%desc%/g, encodeURIComponent(description)); url = url.replace(/%image%/g, encodeURIComponent(image)); var isOpen = window.open(url); if(!isOpen) { console.log('Please turn off "Block pop up" setting to proceed further.'); } } }; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id='share'&gt; &lt;input type='button' onclick ='doShare("TITLE","DESCRIPTION")'&gt;Share&lt;/input&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
27,886,245
0
How to change the URL after a navigation using jQuery Mobile's $.mobile.navigate <p>I'm new to jQuery Mobile and I've been trying so hard (been googling for 2 days straight) to understand how the navigation to external pages works but finding it really hard so hopefully I can get a proper explanation here. From my searches I've found the <code>$.mobile.navigate</code> function but I haven't quite figured out how exactly to use it. </p> <p>Basically what I have is a <code>login.php</code> page, after you successfully logged in you should be taken to the <code>homepage.php</code>, I've managed to make it so that the <code>homepage.php</code>'s content is shown, but when it comes to the URL I can see for a split second that it changes to <code>homepage.php</code> but immidiately changes back to <code>login.php</code>. How can I make it so that it stays on <code>homepage.php</code>? </p> <p>I navigate to <code>homepage.php</code> with <code>$.mobile.navigate</code> like so:</p> <pre><code>&lt;input type="submit" form="login-form" name="submit_login" value="Logga in" id="submit-login"&gt; $('body').on('click', '#submit-login', function() { $.mobile.navigate('../../includes/pages/homepage.php'); }); </code></pre> <p>And currently my <code>homepage.php</code> file looks like this:</p> <pre><code>&lt;div data-role="page" data-url="homepage" data-theme="b" id="homepage"&gt; &lt;div data-role="header"&gt;Some content here&lt;/div&gt; &lt;div data-role="main"&gt;Some content here&lt;/div&gt; &lt;div data-role="footer"&gt;Some content here&lt;/div&gt; &lt;/div&gt; </code></pre> <p>I read somewhere that <code>data-url</code> is used for changing the url on navigation but I haven't been able to make any use of it from my attempts. </p>
5,553,782
0
<p>You'll need </p> <pre><code>XMLNode.InsertAfter(newChildNode,referenceChildNode) </code></pre> <p>This should kickstart you:</p> <p><a href="http://msdn.microsoft.com/en-US/library/system.xml.xmlnode.insertafter%28v=VS.80%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-US/library/system.xml.xmlnode.insertafter%28v=VS.80%29.aspx</a></p>
34,613,825
0
<p>I just had to close the assistant editor and the debug area and then it magically showed up. If you don't have the assistant editor open then all you need to do is open it, then close it again. That should fix it too.</p> <p>If you don't know what the assistant editor is I have highlighted it in red:</p> <p><a href="https://i.stack.imgur.com/aoIF1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aoIF1.png" alt="Assistant editor in red"></a></p> <p>Xcode 7.2</p>
40,260,171
0
Woocommerce Product Price change(free) based on warranty status <p>I want to set few woocommerce product price free based on warranty status.</p> <p>Products are: <code>$target_products = array('2917','1229','1277');</code></p> <p>for Example : <code>$warranty_status = 1</code> mean, valid for warranty .</p> <p>if a customer has a valid warranty status the price of selective product will be free. So I try bellow code and I'm sucked at how to get all <code>$target_products</code> price &amp; set their new value . I'm not sure which hook will work fine.</p> <pre><code>function warranty_free_price( $price, $product ) { global $current_user,$wpdb; $target_products = array('2917','1229','1277'); get_currentuserinfo(); $loggedin_user_id = $current_user-&gt;user_login ; //check for warranty status $warranty_status = $wpdb-&gt;get_var("SELECT warranty_stat FROM {$wpdb-&gt;prefix}wc_product_license_reg WHERE customer = '$loggedin_user_id'"); if(!$warranty_status == 1){ return; // 1 = valid for warranty }else{ if ( in_array ($product-&gt;product_id ,$target_products ) ) { foreach (----------){//help me to figure this out $price = $product-&gt;get_price(); }//end for each } // return warranty price return $price; } } add_filter('woocommerce_get_price_html', 'warranty_free_price', 10, 2); </code></pre> <p>Please help...</p>
12,575,402
0
Split jQuery cycle pager into divs <p>I have a jQuery cycle slider working fine, but the pager I need split into different places. The paging itself works, but the active slide is the same for each div - i.e. for the first slide, the first pager in each div will show as active. I'm having a hard figuring out how to solve this problem! </p> <p>An example of what I'm trying to achieve is the paging of this site <a href="http://www.cote-carmes.com/en-en/rooms.php" rel="nofollow">http://www.cote-carmes.com/en-en/rooms.php</a>.</p> <p>The idea of the markup is as follows:</p> <pre><code>&lt;div id="home-content"&gt; &lt;div class="home-sub first"&gt; &lt;ul class="slide-nav"&gt; &lt;li&gt;&lt;a href="#"&gt;Link&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Link&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Link&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div class="home-sub"&gt; &lt;ul class="slide-nav"&gt; &lt;li&gt;&lt;a href="#"&gt;Link&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Link&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Link&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div class="home-sub"&gt; &lt;ul class="slide-nav"&gt; &lt;li&gt;&lt;a href="#"&gt;Link&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Link&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Link&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>And the jQuery I have as follows:</p> <pre><code>$('#home-slider').cycle({ pager: '#home-content ul', pagerAnchorBuilder: function(idx, slide) { // return selector string for existing anchor return '#home-content li:eq(' + idx + ') a'; } }); </code></pre> <p>Please help!</p>
15,872,236
0
<p>Your code works fine for me. What error you might be having is in processFile function you are creating a file object from the fileName, which is not existing. Then might be trying to read the contents of the file which might be throwing you FileNotFoundException. just comment processFile function and your code will work. </p>
13,824,883
0
<p>I have a suggestion. You can use the Customer Groups feature in PrestaShop 1.5 and only allow logged in customers to see the prices. For every Customer that is grouped in Visitor, they would see your website in Catalog Mode. </p>
12,092,356
0
<p>A short perl script that should do what you need, explained in comments:</p> <pre><code>#!/usr/bin/perl -p $ast = '*' x 75; # Number of asterisks. if (m{//=+}) { # Beginning of a comment. $inside = 1; s{.*}{/$ast\\\nDescription:}; next; } if ($inside) { unless (m{^//}) { # End of a comment. undef $inside; print '\\', $ast, "/\n" ; } s{^//}{}; # Remove the comment sign for internal lines. } </code></pre>
12,299,543
0
<p>You can do multiple inserts like this though,</p> <pre><code> INSERT INTO LOCATIONS (Location_ID,Postal_Code,City,State_Province,Country) VALUES ('L0001','19121','Philadelphia','PA','USA'), ('L0002','08618','Trenton','NJ','USA'); </code></pre>
24,291,156
0
<p>I had a similar issue. In my case it was the client system that had a virus scanner installed. Those scanners sometimes have identity theft modules that intercept <code>POST</code>s, scan the body and then pass it on.</p> <p>In my case <code>BitDefender</code> cached about 5MB before passing it on.</p> <p>If the whole payload was less then the <code>POST</code> was delivered as non chunked fixed length request.</p>
31,709,865
0
<p>The code bloat they are talking about in the article (as it is about the out of memory issue in the IDE) is related to the generated DCUs and all the meta information that is held in the IDE. Every DCU contains all the used generics. Only when compiling your binary the linker will remove duplicates.</p> <p>That means if you have <code>Unit1.pas</code> and <code>Unit2.pas</code> and both are using <code>TList&lt;Integer&gt;</code> both <code>Unit1.dcu</code> and <code>Unit2.dcu</code> have the binary code for <code>TList&lt;Integer&gt;</code> compiled in.</p> <p>If you declare <code>TIntegerList = TList&lt;Integer&gt;</code> in <code>Unit3</code> and use that in <code>Unit1</code> and <code>Unit2</code> you might think this would only include the compiled <code>TList&lt;Integer&gt;</code> in <code>Unit3.dcu</code> but not in the other two. But unfortunately that is not the case.</p>
2,268,541
0
<p>When I try this: [MarshalAsAttribute(UnmanagedType.SafeArray, SafeArrayUserDefinedSubType = typeof(Inner))]</p> <p>I get: An unhandled exception of type 'System.ArgumentException' occurred in Driver.exe</p> <p>Additional information: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))</p>
24,242,932
0
<p>The <code>copy</code> method is defined in <code>NSObject</code>. If you custom class does not inherit from <code>NSObject</code>, <code>copy</code> won't be available.</p> <p>You can define <code>copy</code> for any object in the following way:</p> <pre><code>class MyRootClass { //create a copy if the object implements NSCopying, crash otherwise func copy() -&gt; AnyObject! { if let asCopying = ((self as AnyObject) as? NSCopying) { return asCopying.copyWithZone(nil) } else { assert(false, "This class doesn't implement NSCopying") return nil } } } class A : MyRootClass { } class B : MyRootClass, NSCopying { func copyWithZone(zone: NSZone) -&gt; AnyObject! { return B() } } var b = B() var a = A() b.copy() //will create a copy a.copy() //will fail </code></pre> <p>I guess that <code>copy</code> isn't really a pure Swift way of copying objects. In Swift it is probably a more common way to create a copy constructor (an initializer that takes an object of the same type).</p>
12,245,152
0
<p>The equality operator(==) checks the refernce of string first then checks value of string. While equals method checks the value first. So,in this case equals method should be used instead of equality operator.<code> String s="hello"; String s1="hello"; String s3=new String("hello")</code> In the above code snippet if you use <code>If(s==s1){System.out.print("Equal");}</code>it would print equal.But if you check <code>If(s==s3){System.out.print("unqual");}</code>it wouldn't print unequal. so,you can see that even strings s and s3 are equal,output is wrong.Therefore,in this scenario like program in question </p> <blockquote> <p>Equals method must be used.</p> </blockquote>
30,131,063
0
<p>The <code>myCar</code> variable is not visible in <code>displayMenu()</code> method. Try passing it in as parameter like:</p> <pre><code>public static void displayMenu(Car[] myCar) </code></pre> <p>Also, @ryekayo's suggestion will give you accurate results.</p> <p>Also make sure that <code>Car</code> class has a <code>toString()</code> method in order to print it.</p>
17,204,373
0
<p><a href="http://developer.apple.com/library/ios/#documentation/AssetsLibrary/Reference/ALAsset_Class/Reference/Reference.html#//apple_ref/occ/instm/ALAsset/valueForProperty">http://developer.apple.com/library/ios/#documentation/AssetsLibrary/Reference/ALAsset_Class/Reference/Reference.html#//apple_ref/occ/instm/ALAsset/valueForProperty</a>:</p> <p>i think best way is </p> <pre><code>if ([[asset valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]) { // asset is a video } </code></pre> <p><a href="http://developer.apple.com/library/ios/#documentation/AssetsLibrary/Reference/ALAsset_Class/Reference/Reference.html#//apple_ref/doc/constant_group/Asset_Types">http://developer.apple.com/library/ios/#documentation/AssetsLibrary/Reference/ALAsset_Class/Reference/Reference.html#//apple_ref/doc/constant_group/Asset_Types</a></p> <p>Asset Types</p> <p>Constants that specify the type of an asset.</p> <pre><code>NSString *const ALAssetTypePhoto; NSString *const ALAssetTypeVideo; NSString *const ALAssetTypeUnknown; </code></pre>
23,783,038
0
<p>its because the json you are using is not valid. and the parsing you are doing is not valid too</p> <p>here is a good link to start off with android json parsing</p> <p><a href="http://www.androidhive.info/2012/01/android-json-parsing-tutorial/" rel="nofollow">http://www.androidhive.info/2012/01/android-json-parsing-tutorial/</a></p>
21,555,653
0
Hiding <p> field in javascript <p>Here's my code for gathering titles/posts from reddit's api:</p> <pre><code> $.getJSON("http://www.reddit.com/search.json?q=" + query + "&amp;sort=" + val + "&amp;t=" + time, function (data) { var i = 0 $.each(data.data.children, function (i, item) { var title = item.data.title var url = item.data.url var id = item.data.id var subid = item.data.subreddit_id var selftext = item.data.selftext var selftextpost = '&lt;p id="post' + i + '"&gt;' + selftext + '&lt;/p&gt;&lt;br&gt;' var post = '&lt;div&gt;' + '&lt;a href="' + url + '"&gt;' + title + '&lt;/a&gt;' + '&lt;/div&gt;' results.append(post) results.append(selftextpost) i++ }); }); </code></pre> <p>Basically every post (selftext) is assigned a different paragraph id (post0, post1, post2, etc) for every result that's pulled. I'm also going to create a "hide" button that follows the same id scheme based on my i variable (submit0, submit1, submit2, etc). I want to write a function so that based on which button they click, it will hide the corresponding paragraph. I've tried doing an if statement that's like if("#hide" + i) is clicked, then hide the corresponding paragraph, but obviously that + i doesn't work. How else can I tackle this?</p>