pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
10,004,738 | 0 | Entity Framework: Get Model with Linked Models in Many to Many Relationship <p>I'm coming from TSQL + C# land and have been trying to adapt to linq and EF. Many-to-many relationships have been tripping me up. I have models with many-to-many relationships that I want to query from a database. Such as:</p> <pre><code> class Product{ public int ID {get;set;} public string ProductName {get;set;} public virtual ICollection<Tag> Tags {get;set;} } class Tag { public int ID {get;set;} public string TagName {get;set;} public virtual ICollection<Product> Products {get;set;} } </code></pre> <p>I'm able to get a product itself out of the DbContext, and then later fetch it's associated Tags like this:</p> <pre><code>// product exists in memory as a Product with an empty product.Tags var query = from p in db.Product from t in db.Tags where p.ID == product.ID select p.Tags; </code></pre> <p>Then I can assign the product.Tags with the fetched Tags. Obviously, this is very inefficient when dealing with multiple products if I have to query for every product.</p> <p>With linq and EF, I want to be able to get a Product with all of its associated Tags in one round trip to the database. Also, I want to be able to get all Products and their associated Tags (or a filtered list of Products). How do would the linq look?</p> <p>Edit:</p> <p>Ok, after some more fiddling around, I've got this:</p> <pre><code>var query = db.Product.Include("Tags") .Where(p => p.Tags.Any(t => t.Products.Select(m => m.ID).Contains(p.ID))); </code></pre> <p>This is almost what I need. The results are all products with tags. Missing are the products that don't have tags. I think of this as the equivalent of a SQL inner join. I want to left outer join the tags to the product, and return all products with tags optional. How to get all products with their associated tags without excluding products that have no tags?</p> <p>Edit:</p> <p>This was easier than I thought.</p> <pre><code>var query2 = db.Product.Include("Tags").DefaultIfEmpty(); </code></pre> <p>This gets all the products and their respective tags, including products without tags. Hopefully it works for the right reasons...</p> |
37,522,010 | 0 | Difference between ChildProcess close, exit events <p>When spawning child processes via <code>spawn()/exec()/...</code> in Node.js, there is a <code>'close'</code> and an <code>'exit'</code> event on child processes.</p> <p>What is the difference between those two and when do you need to use what?</p> |
16,886,701 | 0 | <p>You have both the option. You could stream data directly from Amazon S3 or first copy it to HDFS and then process it locally. The first way is good if you only intend to read the data once. And if your plan is to query the same input data multiple times, then you'd probably want to copy it to HDFS first.</p> <p>And yes, by using S3 as an input to MapReduce you lose the data locality optimization. Also, if your plan is to use S3 as a replacement for HDFS, I would recommend you to go with <code>S3 Block FileSystem</code> instead of <code>S3 Native FileSystem</code> as it imposes a limit of 5GB on file size.</p> <p>HTH</p> |
24,801,216 | 0 | Error: [$rootScope:inprog] $digest already in progress using angular.copy <p>I have an input field with a ng-blur function. My blur function uses Restangular to do a customPUT to the server and then does an angular.copy. It seems the line that causes the error is the angular.copy.</p> <p>Input field:</p> <pre><code><input type="text" ng-model="le.instance.from" ng-blur="blurField(le.instance.from, $event)"> </code></pre> <p>Blur handler</p> <pre><code>$scope.blurField = function (fieldNewValue, event) { $scope.le.instance.customPUT({markSaved: true}).then(function(){ angular.copy($scope.le.instance, $scope.leSaved); }); }; </code></pre> <p>The line causing the problem is the angular.copy one. I understand what is this problem but I can't see why doing an angular copy causes another digest to be run... I'm just copying my model object to another object. </p> <p>Also on my controller I'm not using any call to $apply or $digest.</p> <p>Any tips to understand / debug this?</p> |
388,509 | 0 | <pre><code>protected void MyListView_DataBind(object sender, ListViewItemEventArgs e){ if(e.Item.ItemType == ListViewItemType.DataItem){ MyObject p = (MyObject)((ListViewDataItem)e.Item).DataItem; } } </code></pre> <p>You'll want to do the type check so that you don't try and do a cast when you're working on say, the header item.</p> |
24,864,133 | 0 | how to mark a portion of a TextField as readonly in javafx? <p>i wanted to mark a part of the <code>TextField</code> as readonly. Is it possible to do in JavaFX? Basically for a xml editor i want to make xml tags values to be editable but not the tags itself. So wanted to know how to make the a part of the <code>TextField</code> as readonly.</p> |
16,117,683 | 0 | Before onCreateView starts <p>In PageFragment; I inflate a layout in onCreateView. But I want to inflate this layout before onCreateView loads. It could be inflated one time / or for every fragment; not important. </p> <p>How can I achieve it ?</p> <pre><code>public class PageFragment extends Fragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.page_quiz, container, false); tv = (TextView) view.findViewById(R.id.Text); LinearLayout ll = (LinearLayout) view.findViewById(R.id.questionList); return view; } } </code></pre> |
13,129,797 | 0 | <pre><code>SELECT company_name,count(*) as cnt FROM works GROUP BY company_name ORDER BY cnt DESC </code></pre> |
4,854,695 | 0 | <p>You need to pass your key in the HTTP Header. You can check out this material, which talks about how to talk to Azure storage via the REST API, including updating the header value: <a href="http://msdn.microsoft.com/en-us/library/dd179428.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/dd179428.aspx</a></p> <p>If interested in some .NET code samples, use Reflector on the Microsoft.WindowsAzure.StorageClient assembly that comes with the Windows Azure SDK to see how they are doing it.</p> |
28,583,669 | 0 | <p>You will run into the same problem when using a Bootstrap theme beside the one in Extlib / BS4XPages plugin. In that case I don't use the minified CSS and edit it, commenting out the part where the glyphicons generally are defined (references to the font resources). As the icons are the same in every theme you can get this won't do any harm and the icons keep working. Some themes don't have the Glyphicon stuff in it and contain just additional CSS information for colors etc. In that case there is no problem with icons.</p> |
7,772,630 | 0 | Preventing browser loop <p>I've created an app that opens when clicking a specific URL. Obviously I've got something like this:</p> <pre><code> <intent-filter> <data android:scheme="http" android:host="example.com"/> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.BROWSABLE"/> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </code></pre> <p>So that's all great, whenever somebody clicks a link with <a href="http://example.com/whatever/stuff" rel="nofollow">http://example.com/whatever/stuff</a>... it'll open my app. However, within my app, after doing some stuff, I want to send the suer back to the default browser (or whichever browser/web view they were using when they clicked the link to begin with). My problem is that I end up creating a loop:</p> <ol> <li>User clicks link <a href="http://example.com/xxx" rel="nofollow">http://example.com/xxx</a> and my app opens.</li> <li>My app does stuff, and now wants to send the user to a different URL, eg. <a href="http://example.com/yyy" rel="nofollow">http://example.com/yyy</a></li> <li><p>The intent that my app sends, ends up just going back to itself (my app).</p> <pre><code>Intent httpIntent = new Intent(Intent.ACTION_VIEW); String theNewURL = http://example.com/yyy; httpIntent.setData(Uri.parse(theNewURL)); startActivity(httpIntent); </code></pre></li> </ol> <p>How can I get my <code>httpIntent</code> to use the default browser (or wherever the user came from to begin with) instead of calling my app again?</p> <p>Edit: I've been able to solve the problem in a make-shift way, by making a CNAME record of one of my own domains (as a sort of alias) that goes to the same spot as <a href="http://example.com" rel="nofollow">http://example.com</a>. It sucks because the user now sees a different URL, but it still works in that it doesn't invoke the intent. (Am I even using the right language when I talk about intents?)</p> |
29,833,538 | 0 | Convert 12 hour character time to 24 hour <p>I have a data set with the time in character format. I’m attempting to covert this from a 12 hour format to 24. I have done some searching, but everything I have found seems to assume the characters are already in 24 hour format. Here is an example of the times I'm working with.</p> <pre><code>times <- c("9:06 AM", "4:42 PM", "3:05 PM", "12:00 PM", "3:38 AM") </code></pre> |
27,160,225 | 0 | <p>That's how <code>$.extend()</code> works: it always modifies the first object in the argument list. If you don't want that, then:</p> <pre><code>var var3 = $.extend({}, var1, var2); </code></pre> |
18,265,067 | 0 | <blockquote> <p>But why does writing to the index of "b" change the id.</p> </blockquote> <p>Because they're different things now. If you were to check <code>a</code>, <code>a[0]</code> is still <code>1</code> rather than <code>99</code> because <code>b</code> was a copy. If you didn't want this behavior, you wouldn't do the copy:</p> <pre><code>>>> a = [1,2,3] >>> b = a >>> b[0] = 99 >>> a[0] 99 </code></pre> <p>instead, you have this:</p> <pre><code>>>> a = [1,2,3] >>> b = a[:] >>> b[0] = 99 >>> a[0] 1 </code></pre> <p>Since you tagged <code>deepcopy</code>...it's something that only matters if your lists themselves contain mutable arguments. Say, for instance, you had:</p> <pre><code>>>> from copy import deepcopy >>> a = [[1,2],[3,4]] >>> b = a >>> c = a[:] >>> d = deepcopy(a) </code></pre> <p>So <code>a</code> is <code>b</code>, <code>c</code> is a shallow copy, and <code>d</code> is a deep copy.</p> <pre><code>>>> b[0] = 3 >>> a [3, [3,4]] >>> c [[1,2], [3,4]] >>> d [[1,2], [3,4]] </code></pre> <p><code>b</code> is the same as <code>a</code>, but the copies were unaffected.</p> <pre><code>>>> c[1][1] = 'hi' >>> a [3, [3, 'hi']] >>> c [[1, 2], [3, 'hi']] </code></pre> <p>If you replace the entries of <code>c</code>, <code>a</code> is unaffected. But if you still have the original lists <em>within</em> the entries, modifying one still shows up in the other. The nested lists are still the same.</p> <pre><code>>>> d[1][1] = 10 >>> a [3, [3, 'hi']] >>> d [[1, 2], [3, 10]] </code></pre> <p>Since <code>d</code> was a deep copy, it copied the list as well as its nested lists, so we can modify it <em>and its elements</em> at will without worry about messing up the other copies.</p> |
15,679,604 | 0 | <p>your codes looks fine.... but i think your are missing the <code>document.ready</code> function</p> <p>try this</p> <pre><code>jQuery(function(){ //ready function jQuery('nav').on('click', 'a', function(event){ console.log(jQuery(this)); }); }); </code></pre> |
30,044,955 | 0 | <p>check the entries in the solr.xml file. it should have the entries like </p> <pre><code> <core name="core0" instanceDir="./"/> <core name="core1" instanceDir="./"/> </code></pre> <p>please refer the links below </p> <p><a href="http://docs.ckan.org/en/ckan-2.2/appendices/solr-multicore.html" rel="nofollow">http://docs.ckan.org/en/ckan-2.2/appendices/solr-multicore.html</a><br> <a href="http://docs.ckan.org/en/ckan-2.2/appendices/solr-multicore.html#creating-another-solr-core" rel="nofollow">http://docs.ckan.org/en/ckan-2.2/appendices/solr-multicore.html#creating-another-solr-core</a></p> <p><a href="https://wiki.apache.org/solr/CoreAdmin" rel="nofollow">https://wiki.apache.org/solr/CoreAdmin</a></p> |
4,965,093 | 0 | <p>In your app delegate, look for this line:</p> <pre><code>EAGLView *glView = [EAGLView viewWithFrame:[window bounds] pixelFormat:kEAGLColorFormatRGB565 // kEAGLColorFormatRGBA8 depthFormat:0 // GL_DEPTH_COMPONENT16_OES ]; </code></pre> <p>or search for </p> <pre><code>EAGLView *glView </code></pre> <p>and you will find it..</p> |
23,752,112 | 0 | <p>If you want to limit only one dimension then just do not limit the other:</p> <pre><code> component.setMaximumSize( new Dimension( Integer.MAX_VALUE, requiredMaxHeigth ) ); </code></pre> |
37,703,654 | 0 | <p>Fabio, you were right about _Click eventhandler. But it did not solve my problem. My problem are causing groupboxes on my winform. Why, I don't know. This is my workaround for <strong>CheckStateChanged</strong> event that works like charm:</p> <pre><code> private void My_checkBox_CheckStateChanged(object sender, EventArgs e) { if (_addnew == true) { CheckBox my_cb = (CheckBox)sender; if ((my_cb.CheckState == CheckState.Indeterminate) && (my_cb.Text == "Da")) { my_cb.Checked = false; my_cb.Text = "Ne"; } } } </code></pre> |
32,350,274 | 0 | <p>The data you get back is clearly not a UTF-8 string containing JSON. We can see this because the string appears to be set to </p> <pre><code>Current character set: utf8 NULL </code></pre> <p>when the error message is printed out.</p> <p>I'd start by issuing the URL request from an ordinary web browser to make sure that the response is what you expect. </p> |
2,495,912 | 0 | <p>This is supported in .NET 4.0 but not earlier.</p> <p><a href="http://msdn.microsoft.com/en-us/library/dd799517%28VS.100%29.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/dd799517%28VS.100%29.aspx</a></p> |
2,122,151 | 0 | Haxe PHP vs PHP - what language is better for creating Plugins for WordPress? <p>I want to create a WP plugin with use of WP DB tables and costume ones, Ajax requests Rss feeds reading and writing and media storing and Google maps. Such a crazy plugin it will be... </p> <p>So Haxe PHP or normal PHP - what language is better for creating Plugins for WordPress?</p> <p>BTW books blog articles and docs are appreciated as proofs for your answer… </p> |
866,020 | 0 | <p>You are attaching additional event handlers every time you call <code>.click</code>. That is why it is duplicating.</p> <pre><code>$('a.close-trigger').click(function(){ alert(test); $('#dialog').dialog('close'); }); </code></pre> <p>Pull that code out onto the same level as the other event binding and it should work as expected.</p> |
8,290,218 | 0 | <p>You need to use a delegated handler as the input doesn't have class <code>input2</code> at the time the handler is applied.</p> <pre><code>$(document).on('focus','input.input1, textarea.input1', function() { $(this).addClass('input2').removeClass('input1'); }); $(document).on('blur','input.input2, textarea.input2', function() { $(this).addClass('input1').removeClass('input2'); }); </code></pre> <p>There are probably better ways to do this, however. I'd suggest using a third class to mark the inputs that need the class toggled, then just toggle the classes when the event occurs.</p> <pre><code>$('.needsToggle').on('focus blur', function() { $(this).toggleClass('input1 input2'); }); </code></pre> <p>If they always have class <code>input1</code> to start, you could use that instead of <code>needsToggle</code>.</p> |
29,552,603 | 0 | <p>If i understand correctly you are trying to implement event based actions. Yes node.js has got some excellent web socket libraries such as <a href="https://github.com/Automattic/socket.io" rel="nofollow">socket.io</a> and <a href="https://github.com/sockjs/sockjs-client" rel="nofollow">sack.js</a></p> <p>You need to understand nodejs <a href="https://developer.yahoo.com/blogs/ydn/part-1-understanding-event-loops-writing-great-code-11401.html" rel="nofollow">event driven</a> pattern.</p> <p>Websocket protocol helps maintain full duplex connection between server and client. You can notify clients when any action happens in server and similar you can notify server when any action happens in client. Libraries provide flexibility to broadcast event to all connected client or selected ones. </p> <p>So it is basically <strong>emit</strong> and <strong>on</strong> that you will be using often. Go through the documentation, it will not take much time to learn. Let me know if you need any help.</p> |
14,098,294 | 0 | How to edit order without create a new order in magento 1.7 <p>Is there any way to edit an order in Magento without creating a new order from Magento admin? How can I accomplish that?</p> |
7,116,644 | 0 | <p>Like most programming techniques, nested functions should be used when and only when they are appropriate.</p> <p>You aren't forced to use this aspect, but if you want, nested functions reduce the need to pass parameters by directly accessing their containing function's local variables. That's convenient. Careful use of "invisible" parameters can improve readability. Careless use can make code much more opaque.</p> <p>Avoiding some or all parameters makes it harder to reuse a nested function elsewhere because any new containing function would have to declare those same variables. Reuse is usually good, but many functions will never be reused so it often doesn't matter.</p> <p>Since a variable's type is inherited along with its name, reusing nested functions can give you inexpensive polymorphism, like a limited and primitive version of templates.</p> <p>Using nested functions also introduces the danger of bugs if a function unintentionally accesses or changes one of its container's variables. Imagine a for loop containing a call to a nested function containing a for loop using the same index without a local declaration. If I were designing a language, I would include nested functions but require an "inherit x" or "inherit const x" declaration to make it more obvious what's happening and to avoid unintended inheritance and modification.</p> <p>There are several other uses, but maybe the most important thing nested functions do is allow internal helper functions that are not visible externally, an extension to C's and C++'s static not extern functions or to C++'s private not public functions. Having two levels of encapsulation is better than one. It also allows local overloading of function names, so you don't need long names describing what type each one works on.</p> <p>There are internal complications when a containing function stores a pointer to a contained function, and when multiple levels of nesting are allowed, but compiler writers have been dealing with those issues for over half a century. There are no technical issues making it harder to add to C++ than to C, but the benefits are less.</p> <p>Portability is important, but gcc is available in many environments, and at least one other family of compilers supports nested functions - IBM's xlc available on AIX, Linux on PowerPC, Linux on BlueGene, Linux on Cell, and z/OS. See <a href="http://publib.boulder.ibm.com/infocenter/comphelp/v8v101index.jsp?topic=%2Fcom.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Fnested_functions.htm" rel="nofollow">http://publib.boulder.ibm.com/infocenter/comphelp/v8v101index.jsp?topic=%2Fcom.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Fnested_functions.htm</a></p> <p>Nested functions are available in some new (eg, Python) and many more traditional languages, including Ada, Pascal, Fortran, PL/I, PL/IX, Algol and COBOL. C++ even has two restricted versions - methods in a local class can access its containing function's static (but not auto) variables, and methods in any class can access static class data members and methods. The upcoming C++ standard has lamda functions, which are really anonymous nested functions. So the programming world has lots of experience pro and con with them.</p> <p>Nested functions are useful but take care. Always use any features and tools where they help, not where they hurt.</p> |
20,852,111 | 0 | <p>Providing debug level output for the build process helped to work around the problem:</p> <pre><code>Tools->Options->Projects and Solutions->Build and Run->MSBuild project build output verbosity </code></pre> |
21,291,451 | 1 | Slicing multiple rows by single index <p>I have the following slicing problem in numpy.</p> <pre><code>a = np.arange(36).reshape(-1,4) a array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15], [16, 17, 18, 19], [20, 21, 22, 23], [24, 25, 26, 27], [28, 29, 30, 31], [32, 33, 34, 35]]) </code></pre> <p>In my problem always three rows represent one sample, in my case coordinates.</p> <p>I want to access this matrix in a way that if I use a[0:2] to get the following:</p> <pre><code>array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15], [16, 17, 18, 19], [20, 21, 22, 23]] </code></pre> <p>These are the first two coordinate samples. I have to extract a large amount of these coordinate sets from an array.</p> <p>Thanks</p> <p>Based on <a href="http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks-in-python">How do you split a list into evenly sized chunks in Python?</a>, I found the following solution, which gives me the desired result.</p> <pre><code>def chunks(l, n, indices): return np.vstack([l[idx*n:idx*n+n] for idx in indices]) chunks(a,3,[0,2]) array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [24, 25, 26, 27], [28, 29, 30, 31], [32, 33, 34, 35]]) </code></pre> <p>Probably this solution could be improved and somebody won't need the stacking.</p> |
6,009,226 | 0 | Omnibox API | Open specific window on specific keyword <p>I'm trying to create an omnibox shortcut, so when a user types <code>cp command</code> or <code>cp command 2</code> it will open either window 1, or window 2, but instead it opens both windows on "cp" or "cp {anything here}".</p> <p>Have I missed something from the API?</p> <p><strong>background.html</strong></p> <pre class="lang-java prettyprint-override"><code><script> chrome.omnibox.onInputChanged.addListener( function sharePage(tweet, suggest) { suggest([ {content: "tweet", description: "Share on Twitter"} ]); }); // chrome.omnibox.onInputEntered.addListener( function sharePage(tweet) { chrome.tabs.getSelected(null, function (tab) { var url = "https://twitter.com/home?status=Check%20out%20" + encodeURIComponent(tab.url) + "%20via @Chromeplete" chrome.tabs.create ({"url": url}); }); }); </script> <script> chrome.omnibox.onInputChanged.addListener( function sharePage(post, suggest) { suggest([ {content: "post", description: "Share on Facebook"} ]); }); // chrome.omnibox.onInputEntered.addListener( function sharePage(post) { chrome.tabs.getSelected(null, function (tab) { var url = "https://www.facebook.com/sharer.php?u" + encodeURIComponent(tab.url) + "&appid=127651283979691" chrome.tabs.create ({"url": url}); }); }); </script> </code></pre> |
40,061,612 | 0 | <p>Executing shell commands in programs isn't very nice in my opinion so what you can do is to inspect the file programmatically.</p> <p>Take this example, we'll fill classNames with the list of all Java classes contained inside a jar file at <code>/path/to/jar/file.jar.</code></p> <pre><code>List<String> classNames = new ArrayList<String>(); ZipInputStream zip = new ZipInputStream(new FileInputStream("/path/to/jar/file.jar")); for (ZipEntry entry = zip.getNextEntry(); entry != null; entry = zip.getNextEntry()) { if (!entry.isDirectory() && entry.getName().endsWith(".class")) { // This ZipEntry represents a class. Now, what class does it represent? String className = entry.getName().replace('/', '.').replace('$',''); // including ".class" classNames.add(className.substring(0, className.length() - ".class".length())); } } </code></pre> <p>Credit: <a href="http://stackoverflow.com/questions/15720822/how-to-get-names-of-classes-inside-a-jar-file">Here</a></p> |
6,620,555 | 0 | Socket programming: The Server <p>Ok so I've been trying to teach myself some socket programming. I wrote myself a little C# application with an async server and I understand most of it, except for the following:</p> <p>So the server has a port it listens on for connections then when it receives a connection it creates a different socket to do the communication on. This it what I dont understand... How does the communication happen between the client and the server when in theory the client has no idea what port has been elected for this new connection?</p> <p>Thanks for all your answers</p> <p>Edit: As far as I understand the listening thread listens on the default port, but all messages are then handled on a different socket for each client?</p> <p>Edit Again: Some how you guys are misunderstanding my question. I understand normal socket communication. My problem is with an async server where the listening socket is different from the connecting socket. Ie. </p> <ol> <li>Server listens on default port</li> <li>Client attrmpts to connect.</li> <li>Server receiver request.</li> <li><strong>Server then creates a communication socket between client and server and continues listening on the default port.</strong></li> </ol> <p>My problem is at the last step. How does the client now know how to communicate on the new socket? Here is some sample code <a href="http://msdn.microsoft.com/en-us/library/5w7b7x5f.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/5w7b7x5f.aspx</a></p> |
8,876,398 | 0 | <p>You're not specific in terms of libraries you use.</p> <p>For example if you use CXF (Jax-WS in general) you can do the following:</p> <pre><code>// change endpoint URL ((BindingProvider)service).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "new url"); // new username. password will be provided by WS callback ((BindingProvider)service).getRequestContext().put(SecurityConstants.USERNAME, "username"); </code></pre> <p>If you're using Spring for the infrastructure you can autowire all proxies with one statement:</p> <pre><code>@Autowired private Map<String, ServiceInterface> interfaces; </code></pre> <p>If you want to <em>add web services dynamically</em> you have to decide whether this <em>dynamically</em> means <em>at any time</em> or <em>at application startup</em> - this however has nothing to do with web services - it's general programming model of autodiscovery (you can use database, one single remote source of available services, etc.)</p> |
15,109,460 | 0 | rails json api is returning 406 http error when used from an outside page (backbone and phonegap) <p>I've build a rails 3 application. This application has a json API. I've developed a html+javascript Backbone UI (Jquery ajax) that calls the API. Everything works fine.</p> <p>Now, I wan't to use this html+js in Phone Gap. When I test the application using chrome, with no security (chromium-browser --allow-file-access-from-files --disable-web-security) I get an 406 error from the API.</p> <p>I've performed some tests, and the problem is solved when I add ".json" to the url, however, this is not easy to manage inside backbone.</p> <p>Any one has experienced the same error?</p> <p>UPDATE solution found at: <a href="http://stackoverflow.com/questions/9241045/backbone-client-with-a-remote-rails-server">BackBone client with a remote Rails Server</a></p> |
31,988,812 | 0 | <pre><code>try this if your's application is only access that .xml file 1. Create a Object globally object lockData = new object(); 2.Use than object to lock statement where you save and load xml lock(lockData ) { doc.Load("test.xml"); } lock(lockData ) { doc.Save("test.xml"); } </code></pre> |
1,298,836 | 0 | VS2008 on Windows 7 RTM with x64 compiler broken <p>I am having trouble getting x64 compilation to work on Windows 7 RTM (64-bit) with Visual Studio 2008 Professional (both with and without SP1). I have not installed the Windows 7 SDK, as <a href="http://blogs.msdn.com/windowssdk/archive/2009/06/15/installing-win-7-sdk-rc-and-vs2008-rtm-can-disable-vc-configuration-platform-choices.aspx" rel="nofollow noreferrer">Microsoft suggests might be the issue</a>. The problem is that there are no x64/64-bit choices in the Configuration Manager of Visual Studio. </p> <p>I do not have the "Microsoft Visual C++ Compilers 2008 Standard Edition" suggested in the link above installed on my computer. Any ideas what might fix this?</p> <p>I have checked that I have the x64 compiler and tools installed with Visual Studio.</p> <p><strong>Solution found</strong>: Uninstall VS completely and reinstall. Issue resolved after SP1 installed (again). Very strange.</p> |
37,508,854 | 0 | <p><code>replace()</code> will return a new <code>String</code> where ALL occurrences of a particular character are changed, not just a character at a particular position. So your problem is that the repeated <code>replace()</code> statements are effectively modifying the values back and forth.</p> <p>Because a <code>String</code> is immutable, you cannot simply replace its characters with others dynamically. So, convert your code to use a <code>StringBuilder</code> instead.</p> <pre><code>StringBuilder buildSample = new StringBuilder(); buildSample.append(sample); </code></pre> <p>Now you can use <code>setCharAt()</code> instead of <code>replace()</code> to change the character at one position at a time.</p> <pre><code>buildSample.setCharAt(i, 'A'); </code></pre> <p>At the end, you can return <code>buildSample.toString()</code>.</p> <p>As for changing each letter A to F to its complement, if only these six letters are required, a hard-coded function with a <code>switch</code> statement would do. Otherwise you can use a function like <code>complementaryLetter()</code> below, which returns the complement after checking the ASCII value of the character. This will work for all characters. You can add code to handle invalid cases, for non-character input.</p> <p><strong>A complete working code:</strong></p> <pre><code>public class Replace { public static void main(String[] args) { String s1 = "ABCDEFA"; System.out.println(s1); s1 = changeSample(s1); System.out.println(s1); } public static char complementaryLetter(char letter) { char retChar = 'A'; if ((int) letter % 2 == 0) retChar = (char) ((int)letter - 1); else retChar = (char) ((int) letter + 1); return retChar; } public static String changeSample(String sample) { StringBuilder buildSample = new StringBuilder(); buildSample.append(sample); for (int i = 0; i < sample.length(); i++) { buildSample.setCharAt(i, complementaryLetter(sample.charAt(i))); } return buildSample.toString(); } } </code></pre> |
12,982,499 | 0 | Windows Phone 7.5 App download <p>Do I need active phone connection to download app from the Windows Market Place?</p> <p>When I try to install the App from MarKet Place, I receive a error</p> <blockquote> <p>we tried sending a download request to your phone but we did not reeive a response.</p> </blockquote> <p>I gave continue to send the email on re-install. </p> <p>Received re-install email, clicked on the link, and it goes back to same screen and the same error occurs again.</p> |
1,125,281 | 0 | <p>Grab it once and cache it on your side.</p> |
11,299,312 | 0 | Leaked IntentReceiver in Google Cloud Messaging <p>I have implemented GCM in my app and I am using <a href="http://developer.android.com/guide/google/gcm/client-javadoc/index.html" rel="nofollow">GSMRegistrar</a> as suggested <a href="http://pages.citebite.com/e2n7j5s5mxct" rel="nofollow">here</a>. No I am getting an error in logcat</p> <pre><code>7-02 23:35:15.830: E/ActivityThread(10442): Activity com.abc.xyz.mnp has leaked IntentReceiver com.google.android.gcm.GCMBroadcastReceiver@44f8fb68 that was originally registered here. Are you missing a call to unregisterReceiver()? </code></pre> <p>What I can understand from this and looking at the code for <code>GSMRegistrar</code> is I need to to call <code>GSMRegistrar.onDestroy(this)</code> but I could not understand where should I call this? Calling in <code>onDestroy()</code> of activity <code>mnp</code> causes it to stop retrying for <code>GSM Registartion</code></p> |
3,488,578 | 0 | Is SMS data 8 bits until transmitted? <p>A lot of what I have recently read about SMS uses a specification of 140 octet characters, where most uses of SMS I am aware of use 160 septet characters. A UDH is 5 octets long, meaning if I want to send concatenated SMS I would only have 135 octet characters for my message data. This would allow me 154 septet characters after the UDH. </p> <p>Do I take a 154 octet character message, append it to the 5 octet UDH, and send this to the modem as the message text, or do I have to encode my 154 message octet characters into a 7 bit character string, encode the UDH as a 7 bit string, concatenate the two, and send that text to the modem?</p> |
5,367,067 | 0 | Do share buttons (facebook, stumbleupon, twitter, etc) incur a page-load penalty from Google? <p><strong>Our site saw traffic from Google drop significantly yesterday (only 5% traffic left in overnight)</strong>. I asked around. People say that site loading performance could caused the issue.</p> <p>I've looked at the performance. Site is loading in 1 or 2 seconds if no external links such as Google ads or share button. I cannot improve the Google Ads.</p> <p>For the share button, if you view the site <strong>Multiple Share buttons</strong> are loaded and it takes long time to load all of them. But, <strong>All of them are loaded in iframe</strong> (iframe page to different page but in same domain) to avoid slowing down page load.</p> <p>I think users are OK with this because all pages are loaded fast except the share buttons which come from each service site.</p> <p>But, my concern is that if <strong>Google care about all site loading including those in iframe</strong>, then it's big problem since it takes 10 seconds. If not, I will keep those share buttons.</p> <p><strong>Should I keep the share buttons or need to get rid of those?</strong> (I used addthis, it's super slow. And I added each buttons myself)</p> |
6,255,558 | 0 | Why whenever I'm sending a mock GPS signal the emulator crashes? <p>Hey guys. Just like the title - whenever I'm trying to send a mock signal with DDMS in Eclipse it's crashing. Can someone provide me some guidance on that? Here's what I'm getting from the LogCat console:</p> <pre><code> 06-06 17:47:25.986: DEBUG/dalvikvm(123): GC_EXPLICIT freed 155K, 52% free 2716K/5639K, external 2110K/2137K, paused 71ms 06-06 17:47:27.366: INFO/DEBUG(30): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 06-06 17:47:27.366: INFO/DEBUG(30): Build fingerprint: 'generic/google_sdk/generic:2.3.1/GSI11/93351:eng/test-keys' 06-06 17:47:27.366: INFO/DEBUG(30): pid: 60, tid: 138 >>> system_server <<< 06-06 17:47:27.366: INFO/DEBUG(30): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000 06-06 17:47:27.376: INFO/DEBUG(30): r0 00000000 r1 406bf150 r2 41adfab4 r3 4643dc74 06-06 17:47:27.376: INFO/DEBUG(30): r4 00000130 r5 00000000 r6 406bf150 r7 41adfab4 06-06 17:47:27.376: INFO/DEBUG(30): r8 84301321 r9 84302240 10 00100000 fp 00000001 06-06 17:47:27.376: INFO/DEBUG(30): ip 82f0e7d4 sp 4643dc60 lr 82f0ab37 pc 82f07d0e cpsr 00000030 06-06 17:47:27.666: INFO/DEBUG(30): #00 pc 00007d0e /system/lib/libandroid_servers.so 06-06 17:47:27.666: INFO/DEBUG(30): #01 pc 0000ab32 /system/lib/libandroid_servers.so 06-06 17:47:27.666: INFO/DEBUG(30): #02 pc 000012ca /system/lib/hw/gps.goldfish.so 06-06 17:47:27.676: INFO/DEBUG(30): #03 pc 000014ae /system/lib/hw/gps.goldfish.so 06-06 17:47:27.676: INFO/DEBUG(30): #04 pc 00011a7c /system/lib/libc.so 06-06 17:47:27.686: INFO/DEBUG(30): #05 pc 00011640 /system/lib/libc.so 06-06 17:47:27.686: INFO/DEBUG(30): code around pc: 06-06 17:47:27.686: INFO/DEBUG(30): 82f07cec ab04b082 9301cb04 6f646804 b00247a0 06-06 17:47:27.686: INFO/DEBUG(30): 82f07cfc bc08bc10 4718b002 b510b40c ab04b082 06-06 17:47:27.686: INFO/DEBUG(30): 82f07d0c 6804cb04 34f89301 47a06824 bc10b002 06-06 17:47:27.686: INFO/DEBUG(30): 82f07d1c b002bc08 46c04718 b510b40c ab04b082 06-06 17:47:27.686: INFO/DEBUG(30): 82f07d2c 9301cb04 34986804 47a06824 bc10b002 06-06 17:47:27.696: INFO/DEBUG(30): code around lr: 06-06 17:47:27.696: INFO/DEBUG(30): 82f0ab14 91099008 f7fb6aa0 900aeb14 1c3a910b 06-06 17:47:27.696: INFO/DEBUG(30): 82f0ab24 6b646b23 930c1c28 1c31940d f7fd9b0f 06-06 17:47:27.696: INFO/DEBUG(30): 82f0ab34 4906f8e7 44791c28 f7ff3150 b011fe1d 06-06 17:47:27.696: INFO/DEBUG(30): 82f0ab44 46c0bdf0 0000454c 000042c8 00000786 06-06 17:47:27.696: INFO/DEBUG(30): 82f0ab54 f7fbb510 bd10ec7c 4802b510 f7fb4478 06-06 17:47:27.696: INFO/DEBUG(30): stack: 06-06 17:47:27.696: INFO/DEBUG(30): 4643dc20 d97f62b7 06-06 17:47:27.696: INFO/DEBUG(30): 4643dc24 40c7d685 06-06 17:47:27.696: INFO/DEBUG(30): 4643dc28 0000000a 06-06 17:47:27.706: INFO/DEBUG(30): 4643dc2c 00000000 06-06 17:47:27.706: INFO/DEBUG(30): 4643dc30 0000ab90 [heap] 06-06 17:47:27.706: INFO/DEBUG(30): 4643dc34 81d48bd3 /system/lib/libdvm.so 06-06 17:47:27.706: INFO/DEBUG(30): 4643dc38 0000ab90 [heap] 06-06 17:47:27.706: INFO/DEBUG(30): 4643dc3c 4643dc6c 06-06 17:47:27.706: INFO/DEBUG(30): 4643dc40 00010004 [heap] 06-06 17:47:27.706: INFO/DEBUG(30): 4643dc44 81d3761b /system/lib/libdvm.so 06-06 17:47:27.706: INFO/DEBUG(30): 4643dc48 00000000 06-06 17:47:27.706: INFO/DEBUG(30): 4643dc4c afd0dcc4 /system/lib/libc.so 06-06 17:47:27.716: INFO/DEBUG(30): 4643dc50 00000000 06-06 17:47:27.716: INFO/DEBUG(30): 4643dc54 4643de00 06-06 17:47:27.716: INFO/DEBUG(30): 4643dc58 df002777 06-06 17:47:27.716: INFO/DEBUG(30): 4643dc5c e3a070ad 06-06 17:47:27.716: INFO/DEBUG(30): #00 4643dc60 00000001 06-06 17:47:27.716: INFO/DEBUG(30): 4643dc64 8053bf25 /system/lib/libandroid_runtime.so 06-06 17:47:27.716: INFO/DEBUG(30): 4643dc68 00000130 06-06 17:47:27.716: INFO/DEBUG(30): 4643dc6c 82f0ab37 /system/lib/libandroid_servers.so 06-06 17:47:27.716: INFO/DEBUG(30): 4643dc70 41adfab4 /dev/ashmem/dalvik-LinearAlloc (deleted) 06-06 17:47:27.716: INFO/DEBUG(30): 4643dc74 00000003 06-06 17:47:27.726: INFO/DEBUG(30): #01 4643dc78 4284dfce /data/dalvik-cache/system@[email protected]@classes.dex 06-06 17:47:27.726: INFO/DEBUG(30): 4643dc7c 4042b604 /dev/ashmem/dalvik-heap (deleted) 06-06 17:47:27.726: INFO/DEBUG(30): 4643dc80 cffeb075 06-06 17:47:27.726: INFO/DEBUG(30): 4643dc84 c05e8561 06-06 17:47:27.726: INFO/DEBUG(30): 4643dc88 00000000 06-06 17:47:27.726: INFO/DEBUG(30): 4643dc8c 00000000 06-06 17:47:27.726: INFO/DEBUG(30): 4643dc90 00000000 06-06 17:47:27.726: INFO/DEBUG(30): 4643dc94 00000000 06-06 17:47:27.726: INFO/DEBUG(30): 4643dc98 00000000 06-06 17:47:27.736: INFO/DEBUG(30): 4643dc9c 00000000 06-06 17:47:27.736: INFO/DEBUG(30): 4643dca0 00000000 06-06 17:47:27.736: INFO/DEBUG(30): 4643dca4 00000000 06-06 17:47:27.736: INFO/DEBUG(30): 4643dca8 61d1d700 06-06 17:47:27.736: INFO/DEBUG(30): 4643dcac 00000130 06-06 17:47:27.736: INFO/DEBUG(30): 4643dcb0 4643de56 06-06 17:47:27.736: INFO/DEBUG(30): 4643dcb4 00000003 06-06 17:47:27.736: INFO/DEBUG(30): 4643dcb8 0000000a 06-06 17:47:27.736: INFO/DEBUG(30): 4643dcbc 4643dde8 06-06 17:47:27.736: INFO/DEBUG(30): 4643dcc0 00000000 06-06 17:47:27.747: INFO/DEBUG(30): 4643dcc4 4643de6c 06-06 17:47:27.747: INFO/DEBUG(30): 4643dcc8 00000001 06-06 17:47:27.747: INFO/DEBUG(30): 4643dccc 843012cd /system/lib/hw/gps.goldfish.so 06-06 17:47:31.136: DEBUG/skia(122): purging 6K from font cache [1 entries] 06-06 17:47:31.347: DEBUG/dalvikvm(122): GC_EXPLICIT freed 207K, 50% free 2920K/5767K, external 1625K/2137K, paused 205ms 06-06 17:47:36.146: DEBUG/skia(376): purging 340K from font cache [44 entries] 06-06 17:47:36.276: DEBUG/dalvikvm(376): GC_EXPLICIT freed 598K, 52% free 3354K/6855K, external 2859K/3559K, paused 130ms 06-06 17:47:41.156: DEBUG/skia(60): purging 135K from font cache [14 entries] 06-06 17:47:41.336: DEBUG/dalvikvm(60): GC_EXPLICIT freed 146K, 49% free 4533K/8775K, external 4373K/5573K, paused 182ms 06-06 17:47:42.577: DEBUG/Zygote(32): Process 60 terminated by signal (11) 06-06 17:47:42.577: INFO/Zygote(32): Exit zygote because system server (60) has terminated 06-06 17:47:42.676: INFO/ServiceManager(27): service 'SurfaceFlinger' died 06-06 17:47:42.676: INFO/ServiceManager(27): service 'sensorservice' died 06-06 17:47:42.676: INFO/ServiceManager(27): service 'entropy' died 06-06 17:47:42.676: INFO/ServiceManager(27): service 'power' died 06-06 17:47:42.676: INFO/ServiceManager(27): service 'batteryinfo' died 06-06 17:47:42.676: INFO/ServiceManager(27): service 'telephony.registry' died 06-06 17:47:42.676: INFO/ServiceManager(27): service 'usagestats' died 06-06 17:47:42.676: INFO/ServiceManager(27): service 'account' died 06-06 17:47:42.676: INFO/ServiceManager(27): service 'package' died 06-06 17:47:42.676: INFO/ServiceManager(27): service 'activity' died 06-06 17:47:42.676: INFO/ServiceManager(27): service 'meminfo' died 06-06 17:47:42.676: INFO/ServiceManager(27): service 'cpuinfo' died 06-06 17:47:42.676: INFO/ServiceManager(27): service 'permission' died 06-06 17:47:42.676: INFO/ServiceManager(27): service 'content' died 06-06 17:47:42.676: INFO/ServiceManager(27): service 'hardware' died 06-06 17:47:42.676: INFO/ServiceManager(27): service 'battery' died 06-06 17:47:42.676: INFO/ServiceManager(27): service 'vibrator' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'alarm' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'window' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'device_policy' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'statusbar' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'clipboard' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'network_management' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'input_method' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'netstat' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'wifi' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'connectivity' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'throttle' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'accessibility' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'mount' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'notification' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'devicestoragemonitor' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'location' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'search' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'dropbox' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'wallpaper' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'audio' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'uimode' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'backup' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'appwidget' died 06-06 17:47:42.697: INFO/ServiceManager(27): service 'diskstats' died 06-06 17:47:42.716: ERROR/installd(34): eof 06-06 17:47:42.716: ERROR/installd(34): failed to read size 06-06 17:47:42.716: INFO/installd(34): closing connection 06-06 17:47:42.716: DEBUG/qemud(37): fdhandler_event: disconnect on fd 11 06-06 17:47:42.786: INFO/ServiceManager(27): service 'media.audio_flinger' died 06-06 17:47:42.786: INFO/ServiceManager(27): service 'media.audio_policy' died 06-06 17:47:42.786: INFO/ServiceManager(27): service 'media.player' died 06-06 17:47:42.786: INFO/ServiceManager(27): service 'media.camera' died 06-06 17:47:42.816: INFO/ServiceManager(27): service 'isms' died 06-06 17:47:42.816: INFO/ServiceManager(27): service 'simphonebook' died 06-06 17:47:42.816: INFO/ServiceManager(27): service 'iphonesubinfo' died 06-06 17:47:42.816: INFO/ServiceManager(27): service 'phone' died 06-06 17:47:42.946: INFO/Netd(449): Netd 1.0 starting 06-06 17:47:44.016: DEBUG/AndroidRuntime(450): >>>>>> AndroidRuntime START com.android.internal.os.ZygoteInit <<<<<< 06-06 17:47:44.026: DEBUG/AndroidRuntime(450): CheckJNI is ON 06-06 17:47:44.497: INFO/(448): ServiceManager: 0xad50 06-06 17:47:44.497: DEBUG/AudioHardwareInterface(448): setMode(NORMAL) 06-06 17:47:44.517: INFO/CameraService(448): CameraService started (pid=448) 06-06 17:47:44.547: INFO/AudioFlinger(448): AudioFlinger's thread 0xc650 ready to run 06-06 17:47:45.326: INFO/SamplingProfilerIntegration(450): Profiler is disabled. 06-06 17:47:45.407: INFO/Zygote(450): Preloading classes... </code></pre> <p>Thanks in advance.</p> |
1,825,316 | 0 | <p>If you want the page to count down every second, rather than only on refresh, you should use JavaScript. There are many <a href="http://scripts.franciscocharrua.com/countdown-clock.php" rel="nofollow noreferrer">examples</a> out there, and others can be found using google by searching for Javascript Countdown</p> <p>If you wanted to do it in PHP, the best way is to use <a href="http://uk.php.net/mktime" rel="nofollow noreferrer">mktime()</a> to get the unix timestamp of when the time ends, and the value from <a href="http://uk.php.net/time" rel="nofollow noreferrer">time()</a>.</p> <p>Find the difference, and then you can calculate the time left:</p> <pre><code>$diff = mktime(...) - time(); $days = floor($diff/60/60/24); $hours = floor(($diff - $days*60*60*24)/60/60); </code></pre> <p>etc.</p> <p><strong>EDIT</strong> </p> <p>Javascript...</p> <p>Basic idea of the <a href="http://www.w3schools.com/jsref/jsref_obj_date.asp" rel="nofollow noreferrer">date object</a></p> <pre><code>var date = new Date(); //gets now var weekday = date.getDay(); //gets the current day //0 is Sunday. 6 is Saturday if ( weekday == 0 ){ date.setTime()(date.getTime()+60*60*24); //increase time by a day } if ( weekday == 6 ){ date.setTime()(date.getTime()+60*60*24*2); //increase time by two days } //need to check if we have already passed 16:30, if ( ( date.getHours() == 16 && date.getMinutes() > 30 ) || date.getHours() > 16){ //if we have, increase the day date.setTime()(date.getTime()+60*60*24) } date.setHours(16); date.setMinutes(30); //now the date is the time we want to count down to, which we can use with a jquery plugin </code></pre> |
663,391 | 0 | <p>I think the closest collection you'll get from the framework is the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/SortedMap.html" rel="nofollow noreferrer">SortedMap</a></p> |
25,918,029 | 0 | Populateing text field and value field of listbox time from SQL <p>I have a SQL database table that has two columns; 'ID' and 'Names'. I want to read this data from database and add it into a ListBox with the 'Name' as the new Items text field and the 'ID' as the value field.</p> <p>This is what I have so far:</p> <pre><code> using (SqlConnection conn = new SqlConnection("ConnectionString)) { conn.Open(); using (SqlCommand cmd = new SqlCommand("SELECT ID, Name FROM Buildings", conn)) { using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { for (int i = 0; i < reader.FieldCount; i++) { ........................ } } } </code></pre> <p>Any help would be appreciated.</p> |
5,010,509 | 0 | <p>As a simple example, let's say you have two columns, A and B.</p> <pre><code>A B 1 100 2 100 3 100 </code></pre> <p>There are three distinct A values, but only one distinct B value. It would be impossible for <code>COUNT(DISTINCT *)</code> to return a single, meaningful value. That is why that syntax cannot work.</p> |
32,760,142 | 0 | <pre><code>$url="https://api.themoviedb.org/3/movie/popular?api_key=52385ff92cb9105e52d86c4786293ce8&page=1"; </code></pre> <p><strong>Using <a href="http://php.net/manual/pt_BR/book.curl.php" rel="nofollow">cURL</a></strong></p> <pre><code>// Initiate curl $ch = curl_init(); // Disable SSL verification curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Will return the response, if false it print the response curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Set the url curl_setopt($ch, CURLOPT_URL,$url); // Execute $result=curl_exec($ch); // Closing curl_close($ch); // Will dump json data var_dump(json_decode($result, true)); </code></pre> <p><strong>Using <a href="http://php.net/manual/pt_BR/function.file-get-contents.php" rel="nofollow">file_get_contents</a></strong> </p> <pre><code>$result = file_get_contents($url); // Will dump json data var_dump(json_decode($result, true)); </code></pre> |
10,383,742 | 0 | <p>glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT) saves all the client side states for all vertex array attributes. So everything you set with the glEnableClientState/glDisableClientState and gl*Pointer functions. It won't copy the actual data. It also won't save anything set with glBindBuffer/glBufferData because those would be server side states. There's probably an enum for glPushAttrib for that in normal OpenGL (no glPushAttrib in OpenGL ES either).</p> <p>I'm guessing that the difference between VBO and vertex array here is that VBOs have their actual data in graphics memory, while vertex arrays have to be streamed to the graphics card when you draw them. Pointers and enabled flags will still be saved with glPushClientAttrib when you are using VBOs, though.</p> <p>For OpenGL ES you have to keep track of the states yourself if you want to return to the last state. Or better, set everything to default values after you are finished with it (calling glDisableClient for all enabled vertex arrays should be enough).</p> |
16,508,202 | 0 | <p><a href="http://www.yiiframework.com/extension/yii-user/" rel="nofollow">Yii User</a> is not meant for adding roles to users, it only handles user account management.</p> <p>You may install an additional extension like rights, auth or srbac (see <a href="http://www.yiiframework.com/extensions/?category=1&sort=rating.desc" rel="nofollow">list</a>) which provides a web-interface for this task.</p> |
19,310,344 | 0 | <p>I suggest doing your publishing via TFS Build, that way you can ensure that people aren't publishing code that you don't have in Source Control, and it's easy to setup email notification on Build Completion (using TFS Alerts).</p> |
7,539,998 | 0 | <p>Try </p> <pre><code>SHOW ERRORS FUNCTION custord </code></pre> <p>Your <code>custord</code> function was created with compilation errors, so there is something wrong with it. This is why you're getting the <code>object CIS605.CUSTORD is invalid</code> error.</p> |
38,323,504 | 0 | <p>You can try something like this:</p> <pre><code>/** * @When /^The document should open in a new tab$/ */ public function documentShouldOpenInNewTab() { $session = $this->getSession(); $windowNames = $session->getWindowNames(); if(sizeof($windowNames) < 2){ throw new \ErrorException("Expected to see at least 2 windows opened"); } //You can even switch to that window $session->switchToWindow($windowNames[1]); } </code></pre> <p><em>NOTE:</em> Probably windows can open with some delay and in that case you need to wait for it:</p> <pre><code> $ttw = 40; while ((sizeof($session->getWindowNames()) < 2 && $ttw > 0) == true) { $session->wait(1000); $ttw--; } </code></pre> |
15,892,873 | 0 | <p>No Activity is defined to handle intent. It could be because you are not initiating your intent correctly in your onCreate. Try something like this </p> <pre><code>Intent intent = new Intent(Main.this,Menu.class) Main.this.startActivity(intent); </code></pre> <p>EDIT: Also I'm bound to ask have you declared your activity in manifest?</p> |
2,611,191 | 0 | <p>Total guess:</p> <pre><code>select v1.Value1 - v2.Value2 from (Select Max(Value) as [Value1] from History WHERE Datetime ='2010-1-1 10:10' and tagname ='tag1') as v1 CROSS JOIN ( (Select Max(Value) as [Value2] from History WHERE Datetime ='2010-1-1 10:12' and Tagname ='tag2') as v2) </code></pre> |
40,293,016 | 0 | <p>This below config worked for me. Add the plugin in both the parent and child pom. </p> <p><strong>Parent :</strong> </p> <pre><code><build> <plugins> <plugin> <artifactId>maven-jar-plugin</artifactId> <inherited>true</inherited> <executions> <execution> <phase>integration-test</phase> <goals> <goal>jar</goal> </goals> </execution> </executions> <configuration> <skip>true</skip> </configuration> </plugin> </plugins> </build> </code></pre> <p><strong>Child</strong></p> <pre><code><build> <plugins> <plugin> <artifactId>maven-jar-plugin</artifactId> <inherited>false</inherited> <executions> <execution> <phase>integration-test</phase> <goals> <goal>jar</goal> </goals> </execution> </executions> <configuration> <skip>false</skip> </configuration> </plugin> </plugins> </build> </code></pre> |
27,053,500 | 0 | <p>You're using a character that falls outside the normal ASCII range of ordinals 0 -> 255.</p> <p>Put the following 2 lines at the top of your python files:</p> <pre><code>#!/usr/bin/env python # -*- coding: utf-8 -*- </code></pre> <p>and the error should go away.</p> <p>If not, email their support, or go to their <a href="http://forum.jetbrains.com/forum/PyCharm" rel="nofollow">forums</a>.</p> |
11,120,752 | 0 | <p>Someone gave me the wonderful answer of:</p> <pre><code>var filters = new List<Func<f_results, bool>>(); if (comparePrices) filters.add((p => (double)p.Price >= priceFrom && (double)p.Price <= priceTo); if (productQuery) filters.add(p => p.sku == productSku); result = query.find (p => filters.All(filter => filter(p))); </code></pre> |
3,917,598 | 0 | <p>Try this:</p> <pre><code>./textfile.txt </code></pre> |
32,152,081 | 0 | Changin input class on angular model property changes <p>I have one input of text type, and I need that this input become on span depending of the value of a property of my model. So, the jquery function that I have for become a input in span is:</p> <pre><code>$('.read').replaceWith(function(){ return '<span class='+this.className+'>'+this.value+'</span>' }); </code></pre> <p>And the ng directive that I have used is: <strong>ng-change</strong>:</p> <pre><code><input id="1" type="text" ng-model="src.ViewModel.Model.DataA" ng-change="src.search(src.ViewModel.Model.DataA)"/> </code></pre> <p>The method is:</p> <pre><code>theController.prototype.search = function(data){ if (data == 1) { theModel.DataA = data; $('.read').replaceWith(function(){ return '<span class='+this.className+'>'+this.value+'</span>'; }); } }; </code></pre> <p>And the input that must changes is:</p> <pre><code><input type="text" ng-model="src.ViewModel.Model.DataB" ng-class="{'read': src.ViewModel.Model.DataA == 1}" /> </code></pre> <p>But it does not works, so, how I can solve that ??</p> <p>Here is my Fiddle: <a href="http://jsfiddle.net/fcastelblanco/3n8o3ud7/2/" rel="nofollow">Fiddle</a></p> <p>Any help or suggestion, please ...</p> |
33,083,800 | 0 | <p>A varbinary isn't displayed with an odd number of digits. The value contains a specific number of bytes, and each byte is displayed as two digits.</p> <p>(You can write a binary literal with an odd number of digits, for example <code>0x123</code>, but then it means the same things as <code>0x0123</code>.)</p> <p>As you copy a value that has 43679 digits, it's not a correct value from the database. Most likely it's because it gets concatenated, either when it is displayed or when you copy it.</p> |
25,691,060 | 0 | <p>This is probably the wisest way to do what you're asking:</p> <pre><code>var query = from product in products select new { product, finishedCategories = product.categories.Where(c => c.is_finished) }; </code></pre> <p>This creates an anonymous type that has the data you're looking for. Note that if you access <code>.product.categories</code> you'll still get all of that product's categories (lazily-loaded). But if you use <code>.finishedCategories</code> you'll just get the categories that were finished.</p> |
1,492,736 | 0 | XSLT 1.0: replace new line character with _ <p>I am having this below variable</p> <pre><code> <xsl:variable name="testvar"> d e d </xsl:variable> </code></pre> <p>and I have this function: </p> <pre><code> <xsl:choose> <xsl:when test="not($str-input)"> <func:result select="false()"/> </xsl:when> <xsl:otherwise> <func:result select="translate($str-input,$new-line,'_')"/> </xsl:otherwise> </xsl:choose> </func:function> </code></pre> <p>And when I tested the function I saw my result is like this: <strong>_ d _ e _ d_</strong> and I want my result to be only</p> <p><strong>d _ e _ d</strong></p> |
9,677,802 | 0 | Do I need a particular type of Paypal button to initiate an IPN? <p>I am very much a newbie with Paypal, but with much effort and help, I feel as though I have got 90% of the set up complete, I just can't get an IPN response back from Paypal.</p> <p>When I go into the sandbox testing tools and do a simulated IPN, I get green checks indicating everything works.</p> <p>I have a sandbox merchant, and a sandbox buyer. I've created sandbox "subscribe" buttons. When I click the button, I'm taken to the sandbox Paypal site, I enter my sandbox buyer information, and the payment gets processed.</p> <p>Everything seems to work fine, but that's where it ends. I'm left on a page that says the payment is complete. Nowhere in this process does Paypal seem to send any kind of request to my specified IPN landing page.</p> <p>At the top of the PHP code where I receive the IPN, I have a simple mail() function, just for testing to let me know the code has been triggered. I know it works because if I just run it directly in the browser, I get the mail. I do not get the mail when I go through the Paypal sandbox transaction.</p> <p>All indications are that I have not set up Paypal correctly so that it knows I want it to send an IPN notification during the transaction.</p> <p>Do I need a particular button (none of them explicitly say "IPN capable" or anything like that, so my default assumption was that any of them would work.)?</p> <p>In my profile I've specified the page to go to for the IPN message, but perhaps there is another setting that also needs to be configured?</p> <hr> <p><em><strong>Update:</em></strong></p> <p>Here is the code for my button. Note I pretty much just used what was generated for me. I am coming to understand that there are supposed to be extra parameters, but it's not at all clear how I'm supposed to know what additional parameters to include or where to get them.</p> <pre><code><form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="XXXXXXXXXXXXXXXXX"> <input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> </code></pre> |
24,488,931 | 0 | Getting the number of unique values of a query <p>I have some documents with the following structure:</p> <pre><code>{ "_id": "53ad76d70ddd13e015c0aed1", "action": "login", "actor": { "name": "John", "id": 21337037 } } </code></pre> <p>How can I make a query in Node.js that will return the number of the unique actors that have done a specific action. For example if I have a activity stream log, that shows all the actions done by the actors, and a actorscan make a specific action multiple times, how can I get the number of all the unique actors that have done the "login" action. The actors are identified by actor.id </p> |
7,260,467 | 0 | <p>Yes it is valid to enter the same critical section while already inside it. From <a href="http://msdn.microsoft.com/en-us/library/ms682608.aspx">the docs</a>:</p> <blockquote> <p>After a thread has ownership of a critical section, it can make additional calls to EnterCriticalSection or TryEnterCriticalSection without blocking its execution. This prevents a thread from deadlocking itself while waiting for a critical section that it already owns. The thread enters the critical section each time EnterCriticalSection and TryEnterCriticalSection succeed. A thread must call LeaveCriticalSection once for each time that it entered the critical section.</p> </blockquote> |
27,519,382 | 0 | <pre><code>dict={} x1=fileobject.read() for line in x1.splitlines(): if line.split()[1] in dict.keys(): dict[line.split()[0]]=line.split()[1]+" "+dict[line.split()[1]] else: dict[line.split()[0]]=line.split()[1] print dict </code></pre> <p>This way you can have a dictionary of object with keys as you want.</p> <p>Output:<code>{'k3': 'v3', 'k2': 'v2', 'k1': 'v1', 'k5': 'k4 k1 v1', 'k4': 'k1 v1'}</code></p> |
7,150,906 | 0 | PHP mail() function causing slow page loads <p>I've been writing a number of PHP pages that involve using mail(). For the most part, it works well. However, occasionally (I'd say about 10-20% of the time), the mail() function causes the page to load exceptionally slowly, if at all. </p> <p>I haven't been able to find a similar problem on forums anywere. Just to reiterate, the mail() function works fine and sends mail, but when calling scripts with the mail() function in it, it occasionally causes slow page load times.</p> <p>Here's the important bits of what the pages look like. And for the record, we are using Microsoft Exchange Server 2007.</p> <pre><code><html> <head> <?php if ($_POST['submit'] == 'submit'){ //execute some php code. mail($to, $subj, $body, $headers, "O DeliveryMode=b"); } ?> <meta http-equiv="refresh" content="0"> <?php } </head> <body> <form action=<?php echo $_SERVER['PHP-SELF']?>> <!--Form Data--> <input type='submit' name='submit' value='submit'/> </form> </body> </html> </code></pre> |
12,015,918 | 0 | <p>To represent the character you can use Universal Character Names (UCNs). The character 'ф' has the Unicode value U+0444 and so in C++ you could write it '\u0444' or '\U00000444'. Also if the source code encoding supports this character then you can just write it literally in your source code.</p> <pre><code>// both of these assume that the character can be represented with // a single char in the execution encoding char b = '\u0444'; char a = 'ф'; // this line additionally assumes that the source character encoding supports this character </code></pre> <p>Printing such characters out depends on what you're printing to. If you're printing to a Unix terminal emulator, the terminal emulator is using an encoding that supports this character, and that encoding matches the compiler's execution encoding, then you can do the following:</p> <pre><code>#include <iostream> int main() { std::cout << "Hello, ф or \u0444!\n"; } </code></pre> <p>This program <em>does not</em> require that 'ф' can be represented in a single char. On OS X and most any modern Linux install this will work just fine, because the source, execution, and console encodings will all be UTF-8 (which supports all Unicode characters).</p> <p>Things are harder with Windows and there are different possibilities with different tradeoffs.</p> <p>Probably the best, if you don't need portable code (you'll be using wchar_t, which should really be avoided on every other platform), is to set the mode of the output file handle to take only UTF-16 data.</p> <pre><code>#include <iostream> #include <io.h> #include <fcntl.h> int main() { _setmode(_fileno(stdout), _O_U16TEXT); std::wcout << L"Hello, \u0444!\n"; } </code></pre> <p>Portable code is more difficult.</p> |
9,004,089 | 0 | <p>If you access property like this</p> <pre><code>self.property=@""; </code></pre> <p>you are in fact using setter method( which is auto-created thanks to @synthesize). So, in this case, the old object is released and new one is assigned and retained.</p> <p>If you synthesized your property using</p> <pre><code>@synthesize property= _property; </code></pre> <p>then if you call</p> <pre><code>_property=@""; </code></pre> <p>then you just assign new value to the property. Nothing is being released then.</p> <p>So, in your <code>dealloc</code> method you have some choices:</p> <pre><code>-(void)dealloc { self.property=@"";//old value released, new value is @"" self.property=nil;//old value released, new value is nil [_property release]; //old value released [super dealloc]; } </code></pre> |
30,966,823 | 0 | <p>You can get the total heap consumption and other stats via <a href="http://hackage.haskell.org/package/base/docs/GHC-Stats.html#v:getGCStats"><code>getGCStats</code></a> in module GHC.Stats, at least if you run your program with <code>+RTS -T</code>.</p> |
23,726,414 | 0 | <p>Figured it out. Define stuff in onViewCreated() instead of in onCreate().</p> <p>Search programmatically adding adding preferences to preference fragment. Here's one example <a href="http://stackoverflow.com/questions/17255383/how-do-i-programmatically-add-edittextpreferences-to-my-preferencefragment">How do I programmatically add EditTextPreferences to my PreferenceFragment?</a></p> |
33,650,015 | 0 | <p>You say that you need to access <code>getHeight()</code> to calculate <code>desiredWidth</code> inside the <code>onMeasure()</code> method and also that <code>getHeight()</code> is not ready.</p> <p>Yes, <code>getHeight()</code> or <code>getWidth()</code> can't be accessed from <code>onMeasure()</code> because these <code>height</code> and <code>width</code> are set in <code>onMeasure()</code> method. In your <code>onMeause()</code> method, you need to call <code>setMeasuredDimension()</code>. You have done that in your code.</p> <pre><code> setMeasuredDimension(width, height); </code></pre> <p>This <code>width</code> is what you will get when you call <code>getWidth()</code> and this <code>height</code> is what you will get when you call <code>getHeight()</code>. </p> <p>So if you want to access <code>getHeight()</code>, then use <code>height</code> instead.</p> |
10,107,686 | 0 | Programming Android App using Ceylon <p>Can I create android app using Ceylon? Since Ceylon can run of any JVM, the implementation of Ceylon to create android app should be pretty simple as far as I understand. Is it like Scala where the size of App becomes considerably larger and have to use proguard or SBT-android plugin? How viable is it? Can Ceylon be good option for this? If yes, can somebody point me to the proper direction?</p> |
17,553,087 | 0 | <p>Yes, to develop a CKAN extension you have to install CKAN from source.</p> <p>We're working on a new tutorial for writing CKAN extensions, you can see the draft version of the tutorial here: <a href="https://github.com/okfn/ckan/pull/943" rel="nofollow">https://github.com/okfn/ckan/pull/943</a></p> |
6,458,285 | 0 | C# - InstallUtil - Service failing to launch <p>I have a service in C#, that seems to fail to startup, I have created a screenshot below:</p> <p>Is it the case that the service returns (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN) that it is not loading up?</p> <p><a href="http://i.imgur.com/aG7F7.png" rel="nofollow">http://i.imgur.com/aG7F7.png</a></p> |
1,875,294 | 0 | What might cause IDirectDraw::GetCaps returns DDERR_INVALIDPARAMS? <p>I have this little snippet of code with IDirectDraw::GetCaps returning <code>DDERR_INVALIDPARAMS</code> (a.k.a. <code>E_INVALIDARG</code>, a.k.a. 0x80070057).</p> <p>The loaded dll is ddraw.dll 5.03.2600.5512 (xpsp.080413-0845)</p> <p>I need to check whether the display hardware has 3D acceleration (DDCAPS_3D).</p> <p>I have no idea to solve the problem, the snippet is so simple, am I missing something?</p> <p>Thank you very much.</p> <p>Alessandro</p> <pre><code>#include <ddraw.h> #include <iostream> #define TEST_HR(hr) if(hr!=DD_OK){ std::cout << "Error 0x" << std::hex << static_cast<unsigned long>(hr) << " at line: " << std::dec << __LINE__; return __LINE__;} int main(int argc, char* argv[]) { ::CoInitialize( 0 ); IDirectDraw* dd; TEST_HR( ::DirectDrawCreate( 0, &dd, 0 ) ); DDCAPS hel_caps, hw_caps; ::ZeroMemory( &hel_caps, sizeof( DDCAPS ) ); ::ZeroMemory( &hw_caps, sizeof( DDCAPS ) ); TEST_HR( dd->GetCaps( &hw_caps, &hel_caps ) ); ::CoUninitialize(); return 0; } </code></pre> |
10,108,810 | 0 | RTC source control icons <p>What is the difference between these two RTC source control icons ? Is it identifying which workspace is loaded by which component ? Is there a reference that explains each of the RTC source control icons ?</p> <p><img src="https://i.stack.imgur.com/4fSQW.png" alt="enter image description here"></p> <p><img src="https://i.stack.imgur.com/ZmbID.png" alt=""></p> |
6,233,799 | 0 | libqxt installation problem - features.path warning <p>I use Qt SDK 1.1.1 (everything installed exept experimental category) on Windows 7 and I'm trying to set up libqxt libaries for this enviroment. I downloaded and unpacked libqxt tip and ran configure.bat file using Qt for Desktop command line with -static -debug_and_release properties as administrator.</p> <pre><code>Testing for qmake... Testing for mingw32-make...Using mingw32-make. Testing for optional external libraries. If tests fail, some features will not be available. Testing for Berkeley DB... Berkeley DB disabled. Testing for Zero Conf... Zero Conf disabled. Configuration successful. Generating makefiles... WARNING: c:\QtSDK\Desktop\Qt\4.7.1\mingw\mkspecs\default\qmake.conf:108: Unescap ed backslashes are deprecated. WARNING: features.path is not defined: install target not created Makefiles generated. Run mingw32-make now. </code></pre> <p>And so mingw32-make command do nothing... What should I do to compile it properly. I tried to use diffrent parameters but nothing changes...</p> |
20,631,324 | 0 | <p>Gems can configure their host apps by providing a <a href="http://api.rubyonrails.org/classes/Rails/Railtie.html">Railtie</a>.</p> <p>For example, here is a shortened version of how the <a href="https://github.com/charliesome/better_errors/blob/master/lib/better_errors/rails.rb">BetterErrors gem</a> does it:</p> <pre><code>module BetterErrors class Railtie < Rails::Railtie initializer "better_errors.configure_rails_initialization" do Rails.application.middleware.use BetterErrors::Middleware end end end </code></pre> |
32,247,869 | 0 | After call a php function by ajax how to apply its result for to check another submission <p>If user not banned, user can comment here. So I have a php function to check banned user. In case of comment form submitting, a ajax call 1st check this user is banned or not. If not: comment will be submit else display a massage.</p> <p>Here, I cannot submit any comment if banned or not, Page refresh if I try to submit. In cannot also understand how to apply my <code>banneduser()</code> response to check form submitting.</p> <p>php function: (I dont want change it, because I used it many more case)</p> <pre><code>//user name banned by user function Banned($user){ global $db; if(!get_magic_quotes_gpc()){ $touser = addslashes($user); } $byuser = $_SESSION['user']; $result = mysqli_query($db,"SELECT * FROM blocking WHERE byname = '$byuser' AND toname = '$touser'") or die(mysqli_error($db)); return (mysqli_num_rows($result) > 0); } </code></pre> <p>Ajax: </p> <pre><code>// check banned user function banneduser(){ var Bauthor = $("#author").attr("value"); $.ajax({ type: "POST", url: "../common", data: "action=Banned&user="+ Bauthor, success: function(data){ // How to play with this data if(data){ return false; } } }); return false; } //comment submit if user not banned $(".reply").on("click",function(){ if(banneduser()){ // make form submission } else { // You are banned} }); </code></pre> |
36,993,563 | 0 | <p>It's fine to return a reference as long as the object referred to is not destroyed before control leaves the function (<em>i.e.</em>, an automatic local variable or parameter, or a temporary created inside the function).</p> <p>In this case, you are potentially returning a reference to the temporary <code>Foo()</code> in the <em>calling</em> context, which is fine because that temporary is guaranteed to survive until the end of the full-expression containing the call. However, the reference would become dangling after the full-expression, <em>i.e.</em>, the lifetime of the <code>Foo()</code> temporary is not extended, so care must be taken not to access it again after that point.</p> |
24,152,286 | 0 | <p>For some reason, this (the presence of <code>[email protected]</code>) is the obscure method Apple uses to determine if your app supports a 4" display.</p> |
32,475,978 | 0 | Promise chain continues before inner promise is resolved <p>Similar question to <a href="http://stackoverflow.com/questions/29699372/promise-resolve-before-inner-promise-resolved">Promise resolve before inner promise resolved</a> but I can't get it to work nontheless.</p> <p>Every time I think I understand promises, I prove myself wrong!</p> <p>I have functions that are written like this</p> <pre><code>function getFileBinaryData () { var promise = new RSVP.Promise(function(resolve, reject){ var executorBody = { url: rootSite + sourceRelativeUrl + "/_api/web/GetFileByServerRelativeUrl('" + fileUrl + "')/$value", method: "GET", binaryStringResponseBody: true, success: function (fileData) { resolve(fileData.body); }, error: function (argument) { alert("could not get file binary body") } } sourceExecutor.executeAsync(executorBody); }); return promise; } function copyFileAction (fileBinaryData) { var promise = new RSVP.Promise(function(resolve, reject){ var executorBody = { url: rootSite + targetWebRelativeUrl + "/_api/web/GetFolderByServerRelativeUrl('" + targetList + "')/Files/Add(url='" + fileName + "." + fileExt + "', overwrite=true)", method: "POST", headers: { "Accept": "application/json; odata=verbose" }, contentType: "application/json;odata=verbose", binaryStringRequestBody: true, body: fileBinaryData, success: function (copyFileData) { resolve(); }, error: function (sender, args) { } } targetExecutor.executeAsync(executorBody); }); return promise; } </code></pre> <p>that I try to chain like this</p> <pre><code>$.getScript("/_layouts/15/SP.RequestExecutor.js") .then(patchRequestExecutor) .then(function(){ sourceExecutor = new SP.RequestExecutor(sourceFullUrl); targetExecutor = new SP.RequestExecutor(targetList); }) .then(getFileInformation) .then(getFileBinaryData) .then(copyFileAction) .then(getTargetListItem) .then(updateTargetListItem) .catch(function (sender, args) { }); </code></pre> <p>or like this</p> <pre><code>$.getScript("/_layouts/15/SP.RequestExecutor.js") .then(patchRequestExecutor) .then(function(){ sourceExecutor = new SP.RequestExecutor(sourceFullUrl); targetExecutor = new SP.RequestExecutor(targetList); }) .then(function(){ return getFileInformation(); }) .then(function(){ return getFileBinaryData(); }) .then(function(binaryData){ return copyFileAction(binaryData) }) .then(function(){ return getTargetListItem(); }) .then(function(listItem){ return updateTargetListItem(listItem); }); </code></pre> <p>The problem though is that even if I return new promises, the execution continues down the chain before any of the inner promises are resolved. How come? Shouldn't it wait until the asynchronous request has succeeded and <code>resolve()</code> is called in the <code>success</code> callback?</p> |
30,459,659 | 0 | With 1.4 version of AngularJS, is it possible to create persistent cookies with $cookies? <p>With 1.4 version of AngularJS, is it possible to create persistent cookies with <code>$cookies</code>? </p> <p>I want data to be stored once I login, for 7 days say. In version 1.3.X, it is not possible to set Expiration date even. But with 1.4, they have deprecated <code>$cookieStore</code> and set an option in <code>$cookies</code> for expiration date. </p> <p>I want to know whether this one creates cookies for desired longer periods rather than I close the browser and everything is gone. </p> |
20,997,020 | 0 | Not displaying image in viewpager <p>I want to load four image in view pager, i am actually loading images from drawable folder but i am not able to load these,</p> <p>below is the code</p> <pre><code> <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <android.support.v4.view.ViewPager android:id="@id/pager1" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="horizontal" > <ImageView android:id="@+id/img1" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:src="@drawable/ncard1" /> <ImageView android:id="@+id/img2" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:src="@drawable/tncard2" /> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="horizontal" > <ImageView android:id="@+id/img3" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:src="@drawable/tncard3" /> <ImageView android:id="@+id/img4" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/tncard4" /> </LinearLayout> </LinearLayout> </android.support.v4.view.ViewPager> </code></pre> <p></p> <p>Look i am displaying images from drawable but i am getting blank view pager</p> <p>please help me</p> |
34,277,100 | 0 | <p>There is no limit other than the number of socket descriptors. Some platforms have underlying limits, but NIO works around them with multiple OS selectors per <code>Selector.</code></p> <blockquote> <p>Should use a number of threads and have a selector in each for handling a specific number of sockets?</p> </blockquote> <p>It's possible, but I don't really see why you should. Maybe the peers might get more regular service that way, it depends what your code has to do with every request.</p> |
5,815,954 | 0 | Independent format for a string representation of date/time value, for MS SQL server? <p>I have a question about MS SQL Server string-to-datetime implicit conversion.</p> <p>Specifically, can I be sure that a string in the 'yyyy-mm-dd hh:mm:ss' (e.g '2011-04-28 13:01:45') format, inserted into the datetime column, will always be automatically converted to a datetime type, no matter what regional or language settings are used on the server?</p> <p>If no, does there exist such an independent string format for date time?</p> <p>Does it depend on MSSQL server version and how?</p> <p>thank you in advance</p> |
856,569 | 0 | <p>My tests show that <code>z-index: 2147483647</code> is the maximum value, tested on FF 3.0.1 for OS X. I discovered a integer overflow bug: if you type <code>z-index: 2147483648</code> (which is 2147483647 + 1) the element just goes behind all other elements. At least the browser doesn't crash.</p> <p>And the lesson to learn is that you should beware of entering too large values for the <code>z-index</code> property because they wrap around.</p> |
20,143,323 | 0 | Add php variable to ajax call <p>I have a form on <strong>page 1</strong> and I want to parse its variables to ajax call on <strong>page 2</strong>. The ajax call is triggered by on onload event.</p> <p>Scenario:</p> <p><strong>Page1</strong></p> <pre><code><form id="form1"method="GET" action="page2">//send the variables to page 2 <input type="text" name="Place" value="city"> <input type="text" name="Type" value="room"> <input type="submit"></form> </code></pre> <p><strong>page 2</strong></p> <pre><code><form name="myform2" id="myform2" method="GET"> <input type="text" name="Place" value="<?php echo $_GET[Place] ?>">// <input type="text" name="type" value="<?php echo $_GET[Type] ?>"> <button id="submit2"type="submit" value="submit2" name="submit2" onclick="return ss()"> </code></pre> <p>js1</p> <pre><code>$(document).ready(function(){ // load file.php on document ready function sssssss2(page){ var form2 = document.myform2; var dataString1 = $(form2).serialize() + '&page=' + page; ({ type: "GET", url: "file.php",// data: dataString1, success: function(ccc){ $("#search_results").html(ccc); }});} sssssss2(1) ; $('#search_results .pagination li.active').live('click',function(){ var page = $(this).attr('p'); sssssss2(page); }); }); </code></pre> <p>js2 </p> <pre><code>function sss() {//serialize the form each time submitted. var form2 = document.myform2; var dataString1 = $(form2).serialize(); $.ajax({ type:'GET', url: "file.php", cache: false, data: dataString1, success: function(data){ $('#search_results').html(data); } }); return false; } </code></pre> <p>The problem is the <strong>file.php doens't take the variable "city" and "room"</strong>.I would like to parse the 2 variable to file.php when page2 load first time.</p> <p>Hw to parse those variable on document load page2?</p> |
14,840,719 | 0 | Enumerating domains in a forest (windows networks) <p>I looking for an API method that retrieve the info that "net view /domain" does. namely, I'm looking for a way to enumerate the visible domains within a forest, using win32api (in C environment) </p> <p>thanks.</p> <p><strong>Update:</strong> it seems that <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms675976%28v=vs.85%29.aspx" rel="nofollow">DsEnumerateDomainTrusts</a> can do what I need, however, it doesn't looks like net.exe importing it, so I'd still like to know of other options.</p> <p><strong>Update2:</strong> as it's name imply, the function only enumerate trusted domain, even when DS_DOMAIN_IN_FOREST is specified, so I'm in square 1.</p> |
5,905,513 | 0 | <p>On Mac OS X, you can't use <code>\|</code> in a basic regular expression, which is what <code>find</code> uses by default.</p> <p><a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man7/re_format.7.html#//apple_ref/doc/man/7/re_format">re_format man page</a></p> <blockquote> <p>[basic] regular expressions differ in several respects. | is an ordinary character and there is no equivalent for its functionality.</p> </blockquote> <p>The easiest fix in this case is to change <code>\(m\|h\)</code> to <code>[mh]</code>, e.g.</p> <pre><code>find ./ -regex '.*[mh]$' </code></pre> <p>Or you could add the <code>-E</code> option to tell find to use extended regular expressions instead.</p> <pre><code>find -E ./ -regex '.*(m|h)$' </code></pre> <p>Unfortunately <code>-E</code> isn't portable.</p> <p>Also note that if you only want to list files ending in <code>.m</code> or <code>.h</code>, you have to escape the dot, e.g.</p> <pre><code>find ./ -regex '.*\.[mh]$' </code></pre> <p>If you find this confusing (me too), there's a great reference table that shows which features are supported on which systems.</p> <p><a href="http://www.greenend.org.uk/rjk/2002/06/regexp.html">Regex Syntax Summary</a> [<a href="http://webcache.googleusercontent.com/search?q=cache%3ahttp://www.greenend.org.uk/rjk/2002/06/regexp.html">Google Cache</a>]</p> |
26,977,190 | 0 | <p>The following script would do the work for you</p> <pre><code>for file in *.inp do dir=$(echo $file | sed -r 's/[^0-9]+0([0-9]+).*/\1/g') mv $file $dir/mech.dat done </code></pre> |
14,768,134 | 0 | Stratergies to collect analytics and error in windows 8 metro app <p>I have build a metro app using javascript, i have written around 6000 lines of codes.</p> <p>I am ooking for ways to collect 2 things</p> <ol> <li>What users is doing, user action analytics</li> <li>Error that users may be facing, collecting a log file or some other strategy.</li> </ol> <p>What are the available options and what are the available strategies to do that.</p> |
8,104,825 | 0 | <p>Just a note, when using .mask() function, you have to call it to a DOM element, which means you should use it either with</p> <pre><code>Ext.get('yourDomElementId').mask(); </code></pre> <p>or</p> <pre><code>Ext.getCmp('yourExtComponentId').el.mask(); //this gets the dom //element attached to the component </code></pre> <p>I've never used it with .body</p> |
39,050,173 | 0 | Saving large amount of data from Firebase <p>I actually sizeable amount of data that I retrieve the entire data from <code>Firebase</code> when the user log into the app, or to the different view controllers which require the data from Firebase. </p> <p><a href="https://i.stack.imgur.com/no0SO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/no0SO.png" alt="JSON Data"></a></p> <p>However, I find it meaningless to continuously retrieving the same data as the user navigates through the app. Is there a way for me to save all the data to the phone upon first retrieval after log in and just refer to the local data whenever I need it?</p> <p>I have used <code>NSUserDefaults</code> for small amount of data but I don't think that it is the right option for my situation. </p> <p>For these data, I would also require to search them by key when necessary. </p> |
21,348,281 | 0 | <p>I don't have access to an Oracle environment at the moment so I can't verify, but the following does work in SQL Server and will delete from the Orders table. If you want to delete from Order_Item, reverse the tables.</p> <pre><code>DELETE o FROM Orders o JOIN Order_Item oi ON o.order_id = oi.order_id WHERE [filter condition] </code></pre> |
4,199,657 | 0 | Stop browser loading indicator iframe <p>is it possible to stop the browser indicator on a iframe src. In this case its pointing to a different domain happens after page load so don't want to show the indicator</p> |
8,924,973 | 0 | <p>Many of the answers have mentioned using a static readonly lock.</p> <p>However, you really should try to avoid this static lock. It would be easy to create a deadlock where multiple threads are using the static lock.</p> <p>What you could use instead is one of the .net 4 concurrent collections, these do provide some thread synchronisation on your behalf, so that you do not need to use the locking.</p> <p>Take a look at the <code>System.collections.Concurrent</code> namespace. For this example, you could use the <code>ConcurrentBag<T></code> class.</p> |
20,539,520 | 0 | <p>You don't replace the whole string with <code>\0</code>, just the pattern match, which is <code>This</code>. In other words, you replace <code>This</code> with <code>This</code>.</p> <p>To replace the whole line with <code>This</code>, you can do:</p> <pre><code>echo "This is a test string" | sed '/This/s/.*/This/' </code></pre> <p>It looks for a line matching <code>This</code>, and replaces the whole line with <code>This</code>. In this case (since there is only one line) you can also do:</p> <pre><code>echo "This is a test string" | sed 's/.*/This/' </code></pre> <p>If you want to reuse the match, then you can do</p> <pre><code>echo "This is a test string" | sed 's/.*\(This\).*/\1/' </code></pre> <p><code>\(</code> and <code>\)</code> are used to remember the match inside them. It can be referenced as <code>\1</code> (if you have more than one pair of <code>\(</code> and <code>\)</code>, then you can also use <code>\2</code>, <code>\3</code>, ...).</p> <p>In the example above this is not very helpful, since we know that inside <code>\(</code> and <code>\)</code> is the word <code>This</code>, but if we have a regex inside the parentheses that can match different words, this can be very helpful.</p> |
Subsets and Splits