pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
11,775,590 | 0 | <p>I put your code on jsFiddle (with my correction): <a href="http://jsfiddle.net/odi86/6jvG4/" rel="nofollow">http://jsfiddle.net/odi86/6jvG4/</a></p> <p>You forgot to add the <code>from</code> clause to your filter, if you add it it works just fine:</p> <pre class="lang-js prettyprint-override"><code>if (filter === "UEU") { layer.setOptions({ query: { select: "'geometry'", from: '4756019', where: "'UEU' = '" + searchString + "'" } }); } else if (filter === "SUBUEU") { layer.setOptions({ query: { select: "'geometry'", from: '4756019', where: "'SUBUEU' = '" + searchString + "'" } }); } else if (filter === "CODIGO") { layer.setOptions({ query: { select: "'geometry'", from: '4756019', where: "'CODIGO' = '" + searchString + "'" } }); } </code></pre> <p>By the way: you can simplify your code a lot by just doing this (not if-else necessary):</p> <pre class="lang-js prettyprint-override"><code>layer.setOptions({ query: { select: "'geometry'", from: '4756019', where: "'" + filter + "' = '" + searchString + "'" } }); </code></pre> |
18,041,443 | 0 | <p>I changed a little my script, but it needs phone to be rooted</p> <p>%adb% shell "su root cp /data/data/%PACKAGE%/databases/%DB% /sdcard/my/%DB%"</p> <p>%adb% pull /sdcard/my/%DB% db</p> |
28,477,999 | 0 | <pre><code> var currentRows = $('.table tbody tr'); $.each(currentRows, function () { $(this).find(':checkbox').each(function () { if ($(this).is(':checked')) { console.log($(currentRows).eq(1).val()); } }); }); </code></pre> |
15,508,349 | 0 | <p>TFM:</p> <pre><code>CAIRO_FORMAT_RGB24 each pixel is a 32-bit quantity, with the upper 8 bits unused </code></pre> <p>TFM:</p> <pre><code>stride = cairo_format_stride_for_width (format, width); data = malloc (stride * height); </code></pre> <p>Hence, the correct index calculation is</p> <pre><code>data[y * stride + x * 4 + 0] = blue; data[y * stride + x * 4 + 1] = green; data[y * stride + x * 4 + 2] = red; /* yes, in this order */ </code></pre> <p>Also, masks are taken from the image and shifts are hard-coded, which makes absolutely no sense. Calculate the shifts from the masks.</p> |
21,939,411 | 0 | <p>can you check in the xib of your ViewController, select your tableView and click "size inspecto" in the right menu and you change in "iOS 6/7 Deltas": you can tape -20 in height</p> <p>i think the problem is in adaptation with ios7 and 6</p> |
30,380,054 | 0 | How do I iterate through a string contained in a vector? <p>For clarity, I am not asking how to iterate through a vector of strings (which is what all of my searches turn up), I want to iterate through a string contained in a vector of strings. I'm running into linker errors when trying to assign the string iterator a value from a string in a vector. </p> <p>The code below takes a reference to a const vector of strings. The purpose of the function is to reverse the order of the letters and the elements so if you passed in a vector of strings containing { "abc", "def", "ghi" } it would reorder them and return a vector of strings containing { "ihg", "fed", "cba" }. It should be noted that the function is declared as static in the header file. I'm running into a problem when I try to attempt to initialize the string iterator in the for loop. I get a linker error:</p> <pre><code>"No matching constructor for initialization of 'std::__1::__wrap_iter<char*>' </code></pre> <p>I thought accessing rbegin() through the -> from the vector iterator would work but... I'm stumped. Why does stringsVectorIterator->rend() cause a linker error when assigned to string::reverse_iterator rit?</p> <pre><code>vector<string> StringUtility::reverse(const vector<string> &strings) { // Create a vector of strings with the same size vector as the one being passed in. vector<string> returnValue( strings.size() ); vector<string>::const_reverse_iterator stringsVectorIterator; size_t returnVectorCounter; for (stringsVectorIterator = strings.rbegin(), returnVectorCounter = 0; stringsVectorIterator != strings.rend(); stringsVectorIterator++, returnVectorCounter++) { // the problem is in the initialization of the string iterator, it creates // a linker error. for (string::reverse_iterator rit = stringsVectorIterator->rbegin(); rit != stringsVectorIterator->rend(); ++rit) { returnValue[returnVectorCounter].push_back(*rit); } } return returnValue; }; </code></pre> |
3,430,188 | 0 | <p><code>NSString</code> has an instance method <code>intValue</code> that might make this more straightforward.</p> <pre><code>NSNumber *value = [NSNumber numerWithInt:[[params objectAtIndex:i] intValue]]; </code></pre> <p>Now insert that <code>value</code> into the array. If the string is always this simple, you really don't a number formatter.</p> |
25,653,504 | 0 | Stored Procedure Count <p>I am trying to get a dynamic count to print out but it is telling me @totalCAUUpdates needs a scalar value. Any thoughts?</p> <pre><code>declare @totalCAUUpdates as int = 0; declare @realTableName as varchar(100) = '[_TEMP_SubscriptionTransactionsForMosoPay09022014]' declare @updateSQL as varchar(1000) = 'select @totalCAUUpdates = count(*) from ' + @realTableName + ' where len(accountNumberUpdated) > 0 OR len(accountAccessoryUpdated) > 0;'; raiserror (@updateSQL, 0,1) with nowait; EXEC (@updateSQL); </code></pre> |
32,647,965 | 0 | How to display the menu name of a menu in wordpress <p>I have created a menu with the name <strong>"alggemeen"</strong> and added some items to it. </p> <p><a href="https://i.stack.imgur.com/tloDK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tloDK.png" alt="enter image description here"></a></p> <p>I have assigned the menu to the theme location Footer menu with the slug <strong>'footer-menu'</strong>.</p> <p><a href="https://i.stack.imgur.com/bJ3P9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bJ3P9.png" alt="enter image description here"></a></p> <p>Now I know how to display the content of menu and also the menu_location. But I want to display the name the wordpress admin will provide in backend for the menu, on my website.</p> <p>I would like to echo the name of the menu that has been allocated to the menu with a theme location of <code>'Footer Menu(slug = 'footer-menu')'</code>.</p> <p>So as shown above in the picture Currently alggemeen is the menu assigned to Footer Menu so my front end should echo algemeen.</p> |
12,679,013 | 1 | Python- 1 second plots continous presentation <p>I have a dictionary with data. For every entry I would like to display plots for 1 second and move to the next one. The plots to display are already coded in external scripts. I would like to do this automatically. So I loop through the dict, display first set of plots[0], close the plots[0], display plots[1] close plots[1] ... I would like to set up display time for let say 1 second and have the plot as full screen. The problem that during the presentation I don't want to touch the computer. </p> <pre><code>import pylab as pl import numpy as np x = np.arange(-np.pi, np.pi, 0.1) # only for the example purpose myDict = {"sin":np.sin(x), "cos":np.cos(x), "exp":np.exp(x)} for key in myDict: print myDict[key] pl.plt.plot(myDict[key]) # in origin coming from external function pl.plt.plot(x) # in origin coming from external function pl.plt.show() </code></pre> <p>Does anyone know what function should be used and how to modify above?</p> |
33,170,016 | 1 | How to use Django 1.8.5 ORM without creating a django project? <p>I've used Django ORM for one of my web-app and I'm very much comfortable with it. Now I've a new requirement which needs database but nothing else that Django offers. I don't want to invest more time in learning one more ORM like sqlalchemy.</p> <p>I think I can still do <br> <code>from django.db import models</code><br> and create models, but then without <code>manage.py</code> how would I do migration and syncing?</p> |
20,323,330 | 0 | Error while registering node in selenium grid <p>I am getting below error while starting node for selenium grid-</p> <pre><code>Default driver org.openqa.selenium.ie.InternetExplorerDriver registration is skipped: [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}] </code></pre> <p>does not match with current platform: MAC</p> <p>My local system that is hub contains MAC and FIREFOX</p> <p>Below the configuration of my node(VM).My scripts are on my local machine that is hub-</p> <pre><code> { "class": "org.openqa.grid.common.RegistrationRequest", "capabilities": [ { "seleniumProtocol": "WebDriver", "browserName": "firefox", "version": "25.0.1", "maxInstances": 1, "platform" : "LINUX" } ], } </code></pre> <p>Please suggest needful.</p> |
14,842,936 | 0 | regular expression to exclude a specific string <p>I am currently implementing an identity management solution that will provide users the ability to manage all of their endpoint accounts.</p> <p>Currently, our company password policy matches the default Windows requirements: must contain either a number or a special character, among others.</p> <p>Unfortunately, in the new system's password policy, we can require a number, a special, or both, but not "one of either." However, the new system allows validation by regular expression.</p> <p>Currently, we have this set to DISALLOW the following regex:</p> <pre><code>.*[pP][aA4][sS$]{2}[wW][oO0][rR][dD].* </code></pre> <p>This works pretty well. However, we would like to change this to ALLOW either a digit or a special, while also DISALLOWING the previous. Here is what I have tried:</p> <pre><code>((?=.*\d.*)|(?=.*[-'"!#$%&()*+,./:;<=>?@[\]\^_`{|}~\\].*))(?!.*[pP][aA4][sS$]{2}[wW][oO0][rR][dD].*) </code></pre> <p>However, I can't get this to work. The digit/special group works fine, however the word group does not. It does see if "password" or some variation is used at the END of the string, but not at the beginning...</p> <p>Any suggestions? The system uses standard (Perl-style) regular expressions.</p> |
36,389,339 | 0 | <p>In PHP 5.6+ you could do something like this:</p> <pre><code>function foo(Abc ...$args) { } foo(...$arr); </code></pre> <p><code>foo()</code> takes a variable amount of arguments of type <code>Abc</code>, and by calling <code>foo(...$arr)</code> you unpack <code>$arr</code> into a list of arguments. If <code>$arr</code> contains anything other than instances of <code>Abc</code> an error will be thrown.</p> <p>This is a little 'hacky', but it's the only way to get type hinting for an array in PHP, without putting down some extra code.</p> |
25,688,274 | 0 | <p>onkeypress you're using <code>return false</code> which is causing your code being not work.</p> <p>If you remove that, it starts working as you hope.</p> |
7,365,496 | 0 | <p>1) no, this should be a custom (not standard) <strong>popup()</strong> function.</p> <p>2) Your code uses someUrl to extract a value with <code>fmt:message</code> and then paste it into the popup.</p> <p>Following is an illustration on how <strong>fmt:message</strong> works:</p> <p>let's introduce the <code><fmt:message></code> action. If you really wanted to do the bare-bones amount of work necessary to build an internationalized application,is the only action that you'll need to consider. The action takes advantage of the LocalizationContext (which we talk about in the next section).By using the ,you can output values from your resource bundles as simply as:</p> <pre><code><fmt:message key="welcome"/> </code></pre> <p>The appropriate resource bundle will be used to look up the key "welcome" and the translated string will be provided. This is about as easy as it gets to incorporate international support into your application. The action also supports parameterized content, also called parametric replacement. For example, you can provide variables that will be used within the string used by the key attribute. Say we want to personalize our welcome page and pass the name of a user so that we can welcome them. To do this, we use the <code><fmt:param></code> subtag. We will talk about this in more detail later in this chapter, but as a quick example, so that you are familiar with the format, the action might look like:</p> <pre><code><fmt:message key="welcome"> <fmt:param value="${userNameString}"/> </fmt:message> </code></pre> <p>taken from <a href="http://www.javaranch.com/journal/2003/09/AnIntroductionToJstl.html" rel="nofollow">here</a></p> |
24,909,385 | 0 | <p><code>regexp_replace(string, '\s*(-\s*\d+|#+)$')</code><br> <a href="http://www.sqlfiddle.com/#!4/faa75/1" rel="nofollow">fiddle</a></p> |
6,680,595 | 0 | Java SQL Escape without using setString <p>Is there a built-in method to escape a string for SQL? I would use setString, but it happens I am using setString multiple times in the same combined SQL statement and it would be better performance (I think) if the escape happened only once instead of each time I say setString. If I had the escaped string in a variable, I could re-use it.</p> <p>Is there no way to do this in Java?</p> <p>Current method, multi-source search. In reality they are three entirely different where statements including joins, but for this example I will just show the same where for each table.</p> <pre><code>String q = '%' + request.getParameter("search") + '%'; PreparedStatement s = s("SELECT a,b,c FROM table1 where a = ? UNION select a,b,c from table2 where a = ? UNION select a,b,c FROM table3 where a = ?"); s.setString(1, q); s.setString(2, q); s.setString(3, q); ResultSet r = s.executeQuery(); </code></pre> <p>I know this is not a big deal, but I like to make things efficient and also there are situations where it is more readable to use <code>" + quote(s) + "</code> instead of <code>?</code> and then somewhere down the line you find <code>setString</code>.</p> |
17,090,094 | 0 | LINQ Left Outer Join with conditions <p>I have the below tables that are coming from my SQL Database with Entity Framework 5.</p> <p>What I want to do is select all users where tblUserBusiness.BUID equals a passed in value OR where the Users.IsSysAdmin equals True. If the Users.IsSysAdmin equals True there will be no relating tblUserBusiness records hence the Left Outer Join.</p> <p><img src="https://i.stack.imgur.com/UuoYY.png" alt="enter image description here"></p> <p>I started with the below LINQ query that filtered correctly but did not allow for the Outer Join</p> <pre><code> businessUsers = (From u In db.Users From bu In db.tblUserBusinesses Where bu.BUID.Equals(buID) Or u.IsSysAdmin.Equals(True) Select New Users With {.ID = u.ID, .Name = u.Name, .UserName = u.UserName}).ToList </code></pre> <p>Then I moved onto the below query which allows for the Outer Join but I have no idea how to implement the <code>Where bu.BUID.Equals(buID) Or u.IsSysAdmin.Equals(True)</code></p> <pre><code> businessUsers = (From u In db.Users Group Join bu In db.tblUserBusinesses On u Equals bu.User Into userList = Group Select New Users With {.ID = u.ID, .Name = u.Name, .UserName = u.UserName}).ToList </code></pre> <p>Basically what I am after is the LINQ equivalent to the below TSQL</p> <pre><code>SELECT Users.ID, Users.UserName, Users.Name FROM Users LEFT OUTER JOIN tblUserBusiness ON Users.ID = tblUserBusiness.UserID WHERE (Users.IsSysAdmin = 1) OR (tblUserBusiness.BUID = 5) </code></pre> |
11,225,165 | 0 | <p>Setting it to <code>nil</code> will work, assuming that no other object is holding on to (has <strong><em>strong</em></strong> reference to) the <code>NSDictionary</code>.</p> |
23,489,643 | 0 | <p>First you should check if <code>lbName.SelectionMode</code> is <code>ListSelectionMode.Multiple</code></p> <p>then you should the following </p> <pre><code>string names = reader["staffName"].ToString(); string[] selectedName = names.Split(','); lbName.SelectedIndex = -1; foreach (var name in selectedName) { lbName.Items.First(item => item.Value == name).Selected = true; } </code></pre> |
23,042,938 | 0 | <p>Update your selector to <code>element+element</code> selector as follows:</p> <pre><code>#wrapper button:active+#test { width: 0px; } </code></pre> <p><a href="http://jsfiddle.net/f3NeA/8/" rel="nofollow">http://jsfiddle.net/f3NeA/8/</a></p> |
5,185,513 | 0 | label inside input using jquery <p>my "label" is inside the input, so i want to empty the field when the user click and if its empty the "label" is back again </p> <pre><code> $('#name').focus(function() { if ($(this).val()=="Your name") { $(this).val(""); } }).blur(function() { if ($(this).val()=="") { $(this).val("Your name") } }); </code></pre> <p>and this would be done to 3 or more fields, there's any better aprouch? without using plugins, just jquery</p> |
37,946,509 | 0 | <p>If you want to sum of amount then go with this</p> <p>Example SQL query:</p> <pre><code>select sum(column_name) as total from your table_name </code></pre> <p>Then fetch the result in PHP</p> <pre><code>echo $fetched_data['total']; </code></pre> |
19,021,265 | 0 | <p>A very popular O(n log n) algorithm is merge sort. <a href="http://en.wikipedia.org/wiki/Merge_sort" rel="nofollow">http://en.wikipedia.org/wiki/Merge_sort</a> for example of the algorithm and pseudocode. The log n part of the algorithm is achieved through breaking down the problem into smaller subproblems, in which the height of the recursion tree is log n.</p> <p>A lot of sorting algortihms has the running time of O(n log n). Refer to <a href="http://en.wikipedia.org/wiki/Sorting_algorithm" rel="nofollow">http://en.wikipedia.org/wiki/Sorting_algorithm</a> for more examples.</p> |
27,402,446 | 0 | <blockquote> <p>I think what I do here is considered to be bad practice, isn't it?</p> </blockquote> <p>Yes, exposing mutable portions of your class through a getter may be misleading, because the data is not encapsulated well enough. There is nothing wrong with changing the data, it's just that it is done in a way that does not immediately stand out as modification.</p> <p>There is no universal rule to fix this. Generally, you should avoid returning mutable objects inside your class directly. Instead, provide getters and setters where appropriate, and do not give <code>List<B></code> to your caller:</p> <pre><code>class A { private List<B> bs = new ArrayList<B>; public void getSizeB() { return bs.size(); } public B getB(int i) { return bs.get(i); } public void setB(int i, B b) { bs.set(i, b); } public void addB(B b) { bs.add(B); } ... // Add more methods as needed } </code></pre> <p>The idea is to stay in control of what gets into your <code>List<B></code>: since there is no direct access, you can validate every <code>B</code> that gets into the list. The code that uses your class <code>A</code> must be explicit about all modifications that it makes, because it cannot get the list directly and do whatever it wants with it.</p> |
29,169,195 | 0 | <p>I fixed this problem by moving the project via AndroidStudio Refactoring.</p> <ol> <li>Open the project that you want to move.</li> <li>Change to <em>Project</em> view.</li> <li>From there you can Refactor, Move your project to your desired directory.</li> </ol> <p>AndroidStudio will take care of this path to long problem.</p> |
25,383,596 | 0 | <p>The <a href="http://en.wikipedia.org/wiki/Hough_transform" rel="nofollow">Hough Transform</a> is the most commonly used algorithm to find lines in an image. Once you run the transform and find lines, it's just a matter of sorting them by length and then crawling along the lines to check for the constraints your application might have.</p> <p><a href="http://en.wikipedia.org/wiki/RANSAC" rel="nofollow">RANSAC</a> is also a very quick and reliable solution for finding lines once you have the edge image.</p> <p>Both these algorithms are fairly easy to implement on your own if you don't want to use an external library.</p> |
262,392 | 0 | Is there a way to find the name of the calling function in actionscript2? <p>In an actionscript function (method) I have access to arguments.caller which returns a Function object but I can't find out the name of the function represented by this Function object. Its toString() simply returns [Function] and I can't find any other useful accessors that give me that... Help :-/</p> |
36,069,145 | 0 | How to be sure that files are saved in gallery for all Android devices? <p>According to user reviews, my app dosn't save on their phones (LG4, oneplus phones, android 5.1, Android 6.0)</p> <p>For Android 6.0 I have solved the problem by using the new permission system. But how can I be sure that the code actually works 100% on all devices? Is there any improvment that can be made?</p> <p><strong>This is the onClick method that is run, when the user clicks the save button But also ask for permission for Android 6 devices</strong></p> <pre><code>public void saveQuote(View v) { if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { //check if we have permissoin to WRITE_EXTERNAL_STORAGE if (PackageManager.PERMISSION_GRANTED == ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { //This method just create a bitmap of my edittext saveBitmap(); } else { //if permission is not granted, then we ask for it ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_WRITE_EXTERNAL_STORAGE); } } } </code></pre> <p><strong>This is the code that makes the saving operation:</strong></p> <pre><code>private void saveImageToExternalStorage(Bitmap finalBitmap) { String filename = "#" + pref_fileID.getInt(SAVE_ID, 0) + " Quote.JPEG"; //The directory in the gallery where the bitmaps are saved File myDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString() + "/QuoteCreator"); //The directory in the gallery where the bitmaps are saved File myDir = new File(root + "/QuoteCreator"); //creates the directory myDir. myDir.mkdirs(); File file = new File(myDir, filename); try { FileOutputStream out = new FileOutputStream(file); finalBitmap.compress(Bitmap.CompressFormat.JPEG, 100, out); out.flush(); out.close(); Toast.makeText(getApplicationContext(), R.string.savedToast, Toast.LENGTH_LONG).show(); } catch (Exception e) { e.printStackTrace(); } /* Tell the media scanner about the new file so that it is immediately available to the user. */ MediaScannerConnection.scanFile(this, new String[]{file.toString()}, null, new MediaScannerConnection.OnScanCompletedListener() { public void onScanCompleted(String path, Uri uri) { Log.i("ExternalStorage", "Scanned " + path + ":"); Log.i("ExternalStorage", "-> uri=" + uri); } }); } </code></pre> |
37,013,377 | 0 | <p>Create a calc column with the FIND function. </p> |
28,144,960 | 0 | 3 column responsive footer <p>I have a responsive grid layout for thumbnail images and a full width header. It is built using 'ul' and 'li' to make the grid. So basically I'm not using a responsive grid layout throughout. Although I would like to have a three column footer at the bottom that is responsive (stack on top of each other) </p> <p>I want the first column to align full left and the other two columns to align right. each column is only around 15% of the total width (so i couldn't just have all three width 33%) I want the functionality of a three column layout like in many of the themes like skeleton boilerplate, etc</p> <p>I am having trouble making a good css markup that will work, I have used...</p> <p>css</p> <pre><code>F1 { padding: 15px; width: 100px; margin: 0 0 0 20px; float: right; } .F2 { float: left; text-align: left; } .F3 { font-size: 13px; text-align: right; float: right; } </code></pre> <p>but that just separates the divs, and doesn't offer much control</p> <p>any help or references to help are greatly appreciated</p> |
2,994,053 | 0 | Netbeans render unrecognized files as html <p>I am using Netbeans and very happy with it. Unfortunately I am having a little problem with it that I cant seem to figure out. I am using Silverstripe CMS and it uses a templating system that syntactically is basically just a mix of php and html. These files however end in .ss and therefore netbeans doesnt format and highlight them at all. How do I make netbeans format and highlight all .ss files just as if they where normal html files?</p> <p>Kind Regards Nick</p> |
22,353,849 | 0 | Query for ranges in reactivemongo <p>How do I query for ranges using reactivemongo. Something equivalent to</p> <pre><code> db.collection.find( { field: { $gt: value1, $lt: value2 } } ); </code></pre> <p>Thanks.</p> |
1,647,681 | 0 | <p>Changing the image's printed dimensions fixed it. The button doesn't look at the pixel dimensions.</p> |
34,084,144 | 0 | <p>Yes, it's possible to do and it's very useful when you want to <strong>insert a entity to database</strong> and use <strong>the auto-generated id for the next insert or update</strong> </p> <pre><code>using (var context = new DbContext()) { using (var transaction = context.Database.BeginTransaction()) { var item = new Item(); context.Items.Insert(item); context.SaveChanges(); // temporary insert to db to get back the auto-generated id // do some other things var otherItem = context.OtherItems.First(); // use the inserted id otherItem.Message = $"You just insert item with id = {item.Id} to database"; transaction.Commit(); } } </code></pre> <p>Because your question also asked about a working pattern, here's my working code (with use of FluentApi, DbContext & Transaction). I was having the same issue as you :). Hope it helps you</p> <pre><code>public class FluentUnitOfWork : IDisposable { private DbContext Context { get; } private DbContextTransaction Transaction { get; set; } public FluentUnitOfWork(DbContext context) { Context = context; } public FluentUnitOfWork BeginTransaction() { Transaction = Context.Database.BeginTransaction(); return this; } public FluentUnitOfWork DoInsert<TEntity>(TEntity entity) where TEntity : class { Context.Set<TEntity>().Add(entity); return this; } public FluentUnitOfWork DoInsert<TEntity>(TEntity entity, out TEntity inserted) where TEntity : class { inserted = Context.Set<TEntity>().Add(entity); return this; } public FluentUnitOfWork DoUpdate<TEntity>(TEntity entity) where TEntity : class { Context.Entry(entity).State = EntityState.Modified; return this; } public FluentUnitOfWork SaveAndContinue() { try { Context.SaveChanges(); } catch (DbEntityValidationException dbEx) { // add your exception handling code here } return this; } public bool EndTransaction() { try { Context.SaveChanges(); Transaction.Commit(); } catch (DbEntityValidationException dbEx) { // add your exception handling code here } return true; } public void RollBack() { Transaction.Rollback(); Dispose(); } public void Dispose() { Transaction?.Dispose(); Context?.Dispose(); } } </code></pre> <p>Sample usage:</p> <pre><code>var status = BeginTransaction() // First Part .DoInsert(entity1) .DoInsert(entity2) .DoInsert(entity3) .DoInsert(entity4) .SaveAndContinue() // Second Part .DoInsert(statusMessage.SetPropertyValue(message => message.Message, $"Just got new message {entity1.Name}")) .EndTransaction(); </code></pre> |
20,187,194 | 0 | <p>You have two problems in getting your DIVIDE to work.</p> <p>In order of occurrence:</p> <p>You ACCEPT your AMOUNT. Your AMOUNT has an implied decimal place (the V in the PICture string), yet ACCEPT is going to, for your purpose, ignore this implied decimal. There will be no alignment with what the user types at the screen. There is more than one way to deal with this, perhaps the simplest for your purpose it to look at the Intrinsic FUNCTION NUMVAL.</p> <p>You, as @Magoo indicated, do not use decimal points in your literals, so they are treated as whole numbers, so effectively the figures you expect to be used for the currency conversion are multiplied by 10,000 and left-truncated.</p> <p>When reporting a problem it is a good idea to show the input data which gave you the problem, the result you actually achieved, and the expected result. If you can work out what is happening but are unsure how to correct it, that is a bonus.</p> <p>You have tagged Coding-Style. I think you might want to remove that by editing your question. The people interested in the Coding-Style tag are probably not too aware of COBOL. If you have a future Career as a COBOL programmer, your style is going to be more or less dictated by the site standards of where you work, and will change from site to site. You can, of course, develop your own style, but it develops, it isn't just given to you. Knowing the messes you can get into helps you develop style (technique) in avoiding getting there. You'll still need to know how things happen, because not all programmers take the time to develop anything in the way of style.</p> <p>Read through some of the questions here, and see if you get some ideas about common problems.</p> |
33,113,171 | 0 | <p>I think you are confusing assigning variables with aliases. assigning a variable means you store the result of the command in a variable what this command does</p> <pre><code>b=`pwd` </code></pre> <p>is running <code>pwd</code> and stores the answer in a variable b.</p> <p>and alias means giving some command a different name. so running <code>alias b pwd</code> will make it so whenever you run b, you will actually run <code>pwd</code></p> |
6,223,689 | 0 | <p>The keyword <code>static</code> unfortunately has a few different unrelated meanings in C++</p> <ol> <li><p>When used for data members it means that the data is <strong>allocated in the class</strong> and not in instances.</p></li> <li><p>When used for data inside a function it means that the data is allocated statically, <strong>initialized the first time the block is entered</strong> and lasts until the program quits. Also the variable is visible only inside the function. This special feature of local statics is often used to implement lazy construction of singletons.</p></li> <li><p>When used at a compilation unit level (module) it means that the variable is like a global (i.e. allocated and initialized before <code>main</code> is run and destroyed after <code>main</code> exits) but that <strong>the variable will not be accessible or visible in other compilation units</strong>.</p></li> </ol> <p>I added some emphasis on the part that is most important for each use. Use (3) is somewhat discouraged in favor of unnamed namespaces that also allows for un-exported class declarations.</p> <p>In your code the <code>static</code> keyword is used with the meaning number 2 and has nothing to do with classes or instances... it's a variable of the <strong>function</strong> and there will be only one copy of it.</p> <p>As correctly <strong>iammilind</strong> said however there could have been multiple instances of that variable if the function was a template function (because in that case indeed the function itself can be present in many different copies in the program). Even in that case of course classes and instances are irrelevant... see following example:</p> <pre><code>#include <stdio.h> template<int num> void bar() { static int baz; printf("bar<%i>::baz = %i\n", num, baz++); } int main() { bar<1>(); // Output will be 0 bar<2>(); // Output will be 0 bar<3>(); // Output will be 0 bar<1>(); // Output will be 1 bar<2>(); // Output will be 1 bar<3>(); // Output will be 1 bar<1>(); // Output will be 2 bar<2>(); // Output will be 2 bar<3>(); // Output will be 2 return 0; } </code></pre> |
27,453,949 | 0 | In a strongly typed view, how can you show a property of a seperate but related model? <p>If I have two entities like the following:</p> <p><img src="https://i.stack.imgur.com/xWct1.png" alt="enter image description here"></p> <p>...in a strongly typed Details view of BasicEntity, is there a way to show the related ListItem's Description using the navigation properties?</p> <p>Thank you.</p> |
17,164,641 | 0 | <p>The best way to do this would be to use <code>grep</code> to get the lines, and populate an array with the result using newline as the internal field separator:</p> <pre><code>#!/bin/bash # get just the desired lines results=$(grep "mypattern" mysourcefile.txt) # change the internal field separator to be a newline IFS=$'/n' # populate an array from the result lines lines=($results) # return the third result echo "${lines[2]}" </code></pre> <p>You could build a loop to iterate through the results of the array, but a more traditional and simple solution would just be to use bash's iteration:</p> <pre><code>for line in $lines; do echo "$line" done </code></pre> |
6,229,684 | 0 | <p>wow. I just asked it few minutes ago ... use search next time ;)</p> <p><a href="http://stackoverflow.com/questions/6228359/dynamic-favicon-when-im-proccessing-ajax-data">Dynamic favicon when I'm proccessing ajax data</a></p> <p><a href="http://stackoverflow.com/questions/824349/modify-the-url-without-reloading-the-page/3354511#3354511">Modify the URL without reloading the page</a></p> |
34,328,523 | 0 | is this a bug of ios safari? <p>recently, when using <code>display:flex</code> and <code>flex-grow</code>, i find a problem:<br> i write a demo about this question: <a href="http://output.jsbin.com/nijahifogu" rel="nofollow noreferrer">demo</a><br> i run the demo using mac chrome(emulate screen resolution: 320*480) <br> and ios (lastest) safari,<br> the result of chrome is what i expected<br> the screen shot of results below:<br> the result of safari:<br> <a href="https://i.stack.imgur.com/hpzFN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hpzFN.jpg" alt="enter image description here"></a><br> the result of chrome:<br> <a href="https://i.stack.imgur.com/HuLuX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HuLuX.jpg" alt="enter image description here"></a> <br><br><br><br> <hr> <strong>update:</strong> <hr> A new <a href="http://jsbin.com/kogijutiti/1" rel="nofollow noreferrer">demo</a> that the css property is prefixed by(<code>-webit-</code>),<br> but it don't work for me. <hr> <strong>update:</strong> <hr> the viewport need enough narrow to trigger the <code>text-overflow:ellipse</code>,<br>the bug would occur;</p> |
31,852,116 | 0 | Access bean using @AutoWire outside component scan <p>I have a Java Project which is written using Spring and am having trouble with <code>@Autowire</code> of a bean. The declaration of the bean</p> <pre><code><beans:bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> <beans:property name="basenames" value="classpath:messages"/> <beans:property name="defaultEncoding" value="UTF-8" /> </beans:bean> </code></pre> <p>The bean is being autowired without issue in my class <code>BaseController</code> which falls under the component-scan</p> <pre><code><context:component-scan base-package="com.myproj.webservice.controller" /> </code></pre> <p>I want to <code>@Autowire</code> in another class <code>MessageEnum</code> which does not fall under the <code>component-scan</code>. I have tried to add <code>autowire="byType"</code> and <code>autowire="byName"</code> to my bean declaration but the autowiring still did not work.</p> <p>Please find here also my code for the <code>MessageEnum</code> class</p> <pre><code>public enum MessageEnum{ ENUM1("someparam"), ENUM2("someparam2"); @Autorwire private MessageSource messageSource; private String param; //Constructors & getParam and setParam methods public MessageSource getMessageSource() { return messageSource; } } </code></pre> <p>What am I missing here for the <code>messageSource</code> to be autowired?</p> <p>EDIT</p> <p>I tried to create the <code>MessageEnum</code> as a bean as advised here. I created the default constructor <code>MessageEnum() {}</code></p> <p>and set the bean in my xml</p> <pre><code><beans:bean id="messageEnum" class="com.myproj.webservice.util.MessageEnum"> </code></pre> <p>but receive the error message</p> <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageEnum' defined in ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.myproj.webservice.util.MessageEnum]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.myproj.webservice.util.MessageEnum.<init>() </code></pre> |
32,594,007 | 0 | <p>You should be using the Google Places API:</p> <p>This request</p> <p><a href="https://maps.googleapis.com/maps/api/place/textsearch/json?query=1054+East+Commerce+Blvd+Slinger+WI+53086&key=INSERT_YOUR_API_KEY_HERE" rel="nofollow">https://maps.googleapis.com/maps/api/place/textsearch/json?query=1054+East+Commerce+Blvd+Slinger+WI+53086&key=INSERT_YOUR_API_KEY_HERE</a></p> <p>returns the following json for me:</p> <pre><code>{ "html_attributions" : [], "results" : [ { "formatted_address" : "1054 E Commerce Blvd, Slinger, WI 53086, USA", "geometry" : { "location" : { "lat" : 43.32459619999999, "lng" : -88.2700943 } }, "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png", "id" : "fff40888c14fb49758a87b06cfb567dc700f9c2f", "name" : "1054 E Commerce Blvd", "place_id" : "EiwxMDU0IEUgQ29tbWVyY2UgQmx2ZCwgU2xpbmdlciwgV0kgNTMwODYsIFVTQQ", "reference" : "CpQBigAAAJ9o9UeX-dpZYNA7UMTjNzdGfo2-hKh63_7FFlwohjIlTLw-SW9T55YvvaKqLek9w1wTTW1ruwUhZfDfsbMoC4n1Rk0oYbnyKEAsEPgtwuVf-vNgtYqBrHKpRxT5kECSh4O75_GmZzUaypjQqEAKut-ZCz0eMg5fKzgkCXQrUX2o-kLqlj22_hGGKGdApXJ80xIQtvry7J5ah_DxHh0Hv1SwpBoULWCqMnCH34vJY8WzMRD3pVjNS5o", "types" : [ "street_address" ] } ], "status" : "OK" } </code></pre> |
39,160,326 | 0 | <p>I encountered a similar problem. As well as being fixed, one of the inside elements had <code>transform:rotate</code> 90 deg and had a hover effect that changed its position slightly (pulled out from the side of the screen). The background color of this element and its sibling were the same, and both would flicker randomly when elements on the page were changed / rendered.</p> <p>I finally found a combination of styles that stopped the background colour flickering altogether.</p> <p>I added the following to the parent element from here: <a href="http://stackoverflow.com/a/27863860/6260201">http://stackoverflow.com/a/27863860/6260201</a> </p> <pre><code>-webkit-transform:translate3d(0,0,0); -webkit-transform-style: preserve-3d; </code></pre> <p>That stopped the flickering of the transformed/sliding element.</p> <p>And I added the following to the remaining element from here: <a href="http://stackoverflow.com/a/19817217/6260201">http://stackoverflow.com/a/19817217/6260201</a></p> <pre><code>-webkit-backface-visibility: hidden; </code></pre> <p>This then stopped the flickering of the background colour for the sibling element.</p> |
40,087,136 | 0 | <p>One solution would be to use :</p> <pre><code><Caption\b[^>]*>(.*?)<\/?Caption> ^ </code></pre> <p>But it's kind of ugly</p> |
26,947,543 | 0 | <p>Yes, this is correct. In your example <code>%PATH%</code> will be expanded to the current value of the PATH variable, so this command is effectively adding a new entry to the beginning of the PATH. </p> <p>Note that calling <code>set PATH</code> will only affect the current shell. If you want to make this change permanent for all shells, the simplest option is to set it as a user variable using the Environment Variables dialog box. </p> <p>On Windows 8 you can open this dialog by hitting Win+s and searching for 'environment variables'. On earlier versions of Windows you can right-click 'My Computer', choose Properties, then Advanced system settings, then Environment variables. You can create (or update) a PATH variable in the user variables section and add whatever entries you need. These will be appended to the existing system path. If you take this approach you will need to open a new cmd shell after updating the variables.</p> |
17,570,042 | 0 | <p>If you just do <code>br.title()</code> it will give you the unicode string of the special character.</p> <p><code>print</code> attempts to display the non-ASCII character by encoding the Unicode string.</p> |
25,627,174 | 0 | <p>I got a slightly messier answer by first converting your dynamic array to a known type:</p> <pre><code>IEnumerable<JToken> d2 = d.array; </code></pre> <p>Then you can use Any as an extension method.</p> <pre><code>if (d2.Any(p => p.ToString() == "1")) //etc. </code></pre> |
35,071,644 | 0 | <p>You just need to add the responsive class that tells the menu to be horizontal from medium and up, like so:</p> <pre class="lang-html prettyprint-override"><code><ul class="vertical medium-horizontal menu" data-responsive-menu="drilldown medium-dropdown"> </code></pre> <p><strong>Update</strong>: The <a href="https://github.com/zurb/foundation-sites/issues/7978" rel="nofollow"><strong>bugs</strong></a> related to the dropdown arrows and submenu fold out direction in the responsive menu have been fixed in the release of <strong><code>foundation-sites 6.2.0</code></strong>.</p> |
1,086,463 | 0 | <ol> <li>Probably you don't have environment variable ANT_HOME set properly</li> <li>It seems that you are calling Ant like this: "ant build..xml". If your ant script has name build.xml you need to specify only a target in command line. For example: "ant target1".</li> </ol> |
2,275,069 | 0 | <p>Here's a low-tech technique that keeps all the script in your page template: add a <code>$(document).ready()</code> function to the page that executes conditionally based on a page-level variable, like this ...</p> <pre><code>// In your button's click handler, set this.UserHasClicked to true var userHasClicked = '<%= this.UserHasClicked %>' == 'True'; $(document).ready(function() { if(userHasClicked) { $(labelSelector).delay(2000).fadeOut(1000); } }); </code></pre> |
38,956,600 | 0 | <p>This error message was introduced with SubGit version 3.2.1 and SVN Mirror add-on version 3.3.0.</p> <p>SubGit/SVN Mirror rejects push operation that would result into branch replacement in Subversion repository. There are basically two cases when Git changes may lead to replacements on SVN side:</p> <ol> <li><p>Force push.</p> <p>When one forcefully pushes non-fast-forward update, SubGit/SVN Mirror has nothing to do but delete current version of the branch and re-create it from some older revision, because this is exactly what non-fast-forward update does: continuing branch history from a commit other than the branch tip.</p></li> <li><p>Fast-forward merge from one branch into another.</p> <p>When one creates a new branch <code>foo</code> from <code>master</code>:</p> <pre><code>$ git checkout -b foo $ git commit -am 'fix foo' [foo ca3caf9] fix foo </code></pre> <p>then pushes that branch to SubGit mirror:</p> <pre><code>$ git push origin foo ... Sending commits to SVN repository: remote: ca3caf9 => r10 branches/foo </code></pre> <p>which gets <code>ca3caf9</code> mapped to <code>branches/foo@10</code>.</p> <p>Finally, one merges branch <code>foo</code> back to <code>master</code>:</p> <pre><code>$ git checkout master $ git merge foo Updating 0e39ad2..ca3caf9 Fast-forward </code></pre> <p>Noticed that <em>Updating ... Fast-forward</em> message? It means <code>git merge</code> found no new commits on <code>master</code>, hence there was no need to create a merge commit, i.e. <code>git merge</code> just moved the <code>master</code> pointer from older commit <code>0e39ad2</code> to a newer one <code>ca3caf9</code>.</p> <p>Now what happens when one pushes <code>master</code> to SubGit mirror:</p> <pre><code>$ git push origin master </code></pre> <p>SubGit finds out that <code>master</code> was updated from <code>0e39ad2</code> mapped to <code>trunk@9</code> to <code>ca3caf9</code> mapped to <code>branches/foo@10</code>. There's nothing SubGit can do but delete <code>trunk</code> and re-create it from <code>branches/foo@10</code> which obviously leads to replacement of <code>trunk</code>.</p></li> </ol> <p>And so we made sure that SubGit does not replace branches in these two scenarios unless SubGit administrator explicitly sets the following configuration option:</p> <pre><code>$ edit REPO/subgit/config ... [svn] allowBranchReplacement = true ... $ subgit install REPO </code></pre> <p>However, I'd recommend to keep <code>svn.allowBranchReplacement</code> set to <code>false</code> and follow these best practices to avoid the error message reported in the original question:</p> <ul> <li><p>Never force push anything; prefer to merge, revert of branch out changes rather than overwrite them.</p></li> <li><p>When merging one branch into another add <code>--no-ff</code> option: it forces <code>git merge</code> to create a merge commit when it would rather do a fast-forward update otherwise:</p> <pre><code>$ git merge --no-ff foo </code></pre></li> </ul> |
29,424,477 | 0 | How do I make a hotkey to activate a specific VMware Workstation VM? <p>I'm using the latest version of VMware Workstation (11.1.0) on Windows 7 x64 and I want to be able to do a keystroke of "Ctrl + 1" to go to VM #1, "Ctrl + 2" to go to VM #2, and "Ctrl + 3" to go to VM #3.</p> <p>Sounds simple right? It isn't.</p> <p>On Mac OS X, achieving this functionality is trivial with VMware Fusion in combination with Spaces / Mission Control - you can simply put each VM on a separate space and then define whatever space hotkeys you want. I'm migrating from OS X and want this same functionality.</p> <p>For reference, here are some potential solutions that I've tried and can verify that they don't work:</p> <p><strong>1) AutoHotkey</strong></p> <p>AutoHotkey can be used to make hotkeys like so:</p> <pre><code>^1::WinActivate, Win7(1) - VMware Workstation ^2::WinActivate, Win7(2) - VMware Workstation ^3::WinActivate, Win7(3) - VMware Workstation </code></pre> <p>These work to <strong>enter</strong> the VMs, but not to exit; Workstation will feed the "Ctrl + 1" to the VM and AutoHotkey does not take precedence, even if AutoHotkey is run as an administrator.</p> <p><strong>2) Suspend/Unsuspend with AutoHotkey</strong></p> <p>This promising post suggests that suspending and that unsuspending AutoHotkey while the VMware window is active will fix the problem:</p> <p><a href="http://superuser.com/questions/232762/autohotkey-script-to-exit-vmware-window">http://superuser.com/questions/232762/autohotkey-script-to-exit-vmware-window</a></p> <p>However, even after copying the exact code and making the necessary string modifications, I can't get it to work with Workstation.</p> <p><strong>3) Remote Desktop and/or VNC</strong></p> <p>One possible solution, if all 3 of the VMs in question were running Windows, would be to use Microsoft's Remote Desktop feature. However, one or more of the VMs that I intend to use will be running Linux.</p> <p>On Linux, it is possible to just use VNC. However, VNC has considerable drawbacks when compared to the native VMware Workstation console window: there is no sound, the resolution won't automatically scale, the performance will be bad, and so forth.</p> <p>Lastly, the VMs will be on 1) networks that won't be connected to the host via a bridged NIC (with the NIC disabled on the host) and 2) using a VPN without any split tunnel. So there will be no connectivity for either remote desktop or VNC in the first place.</p> <p><strong>3) A Windows Keyboard Hook</strong></p> <p>Liuk explains how to use a Windows hook to intercept keystrokes using C++: </p> <p><a href="http://polytimenerd.blogspot.com/2011/02/intercepting-keystrokes-in-any.html" rel="nofollow">http://polytimenerd.blogspot.com/2011/02/intercepting-keystrokes-in-any.html</a></p> <p>However, after testing with the demo program, it seems that this method does not intercept keystrokes sent to VMware Workstation.</p> <p><strong>4) FullScreenSwitch.directKey</strong></p> <p>It seems that in VMware Workstation used to have this kind of functionality built in, as documented in this SuperUser thread:</p> <p><a href="http://superuser.com/questions/71901/vmware-workstation-keyboard-shortcut">http://superuser.com/questions/71901/vmware-workstation-keyboard-shortcut</a></p> <p>However, VMware's documentations states that this is for VMware Workstation 5.0. I tried adding these strings to my VMX file and they had no effect, so the functionality must have been depreciated somewhere along the lines between Workstation 5 and 11.</p> <p><strong>5) PSExec</strong></p> <p>Wade Hatler mentions that he accomplishes this using PSExec to activate the appropriate AutoHotkey script on the host machine:</p> <p><a href="http://www.autohotkey.com/board/topic/64359-sending-keystrokes-to-vmware-player/" rel="nofollow">http://www.autohotkey.com/board/topic/64359-sending-keystrokes-to-vmware-player/</a></p> <p>This solution is questionable in that you have to keep the password of your host machine in plaintext in order to pass it to PSExec.</p> <p>Regardless, this solution will not work for the reasons also described in #2 above: the VMs in question will be on 1) networks that won't be connected to the host via a bridged NIC (with the NIC disabled on the host) and 2) using a VPN without any split tunnel. So there will not be guaranteed connectivity between the host and the guest.</p> <p><strong>6) Execute a "Host" keystroke between every "Ctrl + #" keystroke</strong></p> <p>This is problematic in that it doubles the amount of keystrokes involved and makes it impossible to "flip" through all of my VMs by holding down control and hitting 1 + 2 + 3 + 4 + 5, and so forth.</p> <p><strong>7) Use the "Host + Left/Right Arrow" hotkey and/or VMware-KVM.exe for cycling functionality</strong></p> <p>This is problematic in that when I have 10 or more VMs open at a time, rotating through all of them becomes incredibly cumbersome and inefficient.</p> |
33,316,525 | 0 | <p>Yes. I think <code>foo.string</code> will calulate each time until iteration satisfies <code>True</code>. So you can do this</p> <pre><code>foo_string=foo.string if any(name in foo_string for name in faa.names): </code></pre> |
20,736,643 | 0 | <p>CSS only solution</p> <pre><code>article { position: relative; } article:after { content: ''; position: absolute; width: 100%; height: 1px; // suit your need background: black; // suit your need top: 100%; left: 0; } </code></pre> |
29,957,556 | 0 | <p>Try using this query:</p> <pre><code>SELECT a.name, c.company, NVL(cp.profile_value, pd.profile_value) FROM employee a INNER JOIN company c ON a.comp_id = c.comp_id LEFT JOIN company_profile cp ON c.comp_id = cp.comp_id LEFT JOIN profile_defaults pd ON cp.profile_id = pd.profile_id </code></pre> <p>This solution assumes that you have columns <code>comp_id</code> in both the <code>company_profile</code> and default <code>profile_defaults</code> tables to which you can join a record for a given company. As @PM77-1 mentioned, I use <code>NVL()</code> to first check the <code>company_profile</code> table, and default to <code>profile_defaults</code> if nothing is found in the former.</p> |
38,192,003 | 0 | SQL Server : can't find the right 'join' formula for what I want <p>I'm trying to find the right way to achieve this. Suppose I have 3 tables A, B and C.</p> <p>I want my request to show some info from all 3 tables, but I want to show only one line by records that are in A.</p> <p>The problem, if I join tables, is that there is most of the time a lot of B records linked to one A record, even worse, there is a lot of C linked to one B, so sometimes, the same A record is shown over a hundred times...</p> <p>I tried <code>select top(1)</code> for B and <code>top(1)</code> again for C but still, it returns <code>top(1)</code> written on every 100 row of the same A, tried left join... inner join...</p> <p>I'm trying to figure out how to group by but still can't find the right grouping. I ended up making A LOT of nested select, in fact, my query contains more nested select then anything else... it works but it takes forever...</p> <ol> <li><p>Would it be faster if I find a way to remove most of my nested select ?</p></li> <li><p>Is that even possible? I mean, did someone ever manage to accomplish this one line for all 'A' records query?</p></li> </ol> |
39,935,119 | 0 | <p>This might work for you (GNU sed):</p> <pre><code>sed -r 's#.*#s/.*/&=\&/#;1s#$#;h#;1!s#.*#n;&;H#;$s#$#;x;s/^([^\\n]*)\\n(.*)/update.database.table set \\2 WHERE \\1;/;s/\\n/, /gp#' file | sed -nrf - log </code></pre> <p>Turn the file into a sed script then run it against the log.</p> |
14,246,815 | 0 | <p><code>clone</code> only does a shallow copy: so you get a new <code>Vector</code> with references to the same objects as the original. This is the expected behavior.</p> <p>If you want different behavior, you'll need to manually copy the inner <code>Vector</code>s yourself. (This is one of the many reasons why the use of <code>clone</code> is ill-advised.)</p> |
20,171,051 | 0 | <p>Fundamentally, your <code><ul></code> element is being padded to the left there, and nested <code><ul></code>'s get increasingly more padded. With this setup, I can't imagine theres a "one line solution" available.</p> <p>Instead, one, I would change that <code>padding-left</code> to exist on the <code><li></code> element itself. This will solve one problem (you'll notice your top level items will have their hover state appearing to be full width), but we still have one more change, and it may be significant.</p> <p>Update: Rather than appending class names to your list elements, I've updated the code to simply use descendent child selectors. This will allow you to use the same markup but generate the same affect.</p> <p><a href="http://jsfiddle.net/2hrtc/2/" rel="nofollow">Here's an example which solves the problem</a>.</p> <p>I've also made a couple simple updates. For one, you shouldn't need that <code>height: 14px</code> on each image, you can state that with CSS. Secondly, you probably will want to use <code>1em</code> rather than 14px, assuming your font size in the <code><li></code> is also 14px, as it will tie that icon size to the font size of the container. Easier maintainability.</p> <p>Additionally, commit to a kind of quote! You're using single quotes and double quotes - stick to one! I prefer double quotes as that was the legacy of XHTML.</p> <p>And finally, you should put that space <em>before</em> the span, rather than inside it. It makes a little more syntactical sense.</p> <p>Oh, and if you're using HTML5, there's no need for the self closing tag. HTML5 already knows how an <code><image></code> tag should work.</p> |
35,017,435 | 0 | conditional include for opencv2/photo/photo.hpp c++ depending on OpenCV version <p>I would like to create a conditional Include, depending on the OpenCV version. Actually I'm compiling in 2 different platforms the same source code. I'm developing in Ubuntu 14 and I want to run My application in a Raspberry PI. The problem I have is with the:</p> <pre><code>#include "opencv2/photo/photo.hpp" </code></pre> <p>In the raspberry I have OpenCV 2.4.1 and In Ubuntu the 2.4.8. Every time I compile I have to change the includes in several files which is annoying, That Why I would like to make a conditional Include, but no Idea how to this specific one.</p> <p>I read <a href="http://stackoverflow.com/questions/12314508/conditional-include-in-c">this</a> and a <a href="http://stackoverflow.com/questions/8930360/c-conditional-include-file-runtime">second</a> but I think is not the same problem. I also compile with CMAKE just in case I can create a variable or something to create the conditional include.</p> |
22,160,482 | 0 | <p>Yes there are plugins that offers this functionality, I think most of the drag and drop jQuery plugins has their own callback function that triggers once the dragging and dropping has finished. <a href="http://dragsort.codeplex.com/" rel="nofollow">jQuery List DragSort</a> is a plugin I've used in my project before, it's lightweight and easy to use.</p> <pre><code>$("menu").dragsort({dragEnd: showHiddenCells }); function showHiddenCells() { //triggers after the user drops the element } </code></pre> |
31,916,958 | 1 | Django 1.8: How do I use my first 3rd Party Fork with my current project? <p>I'm still very new to development...</p> <p>I would like to simplify <a href="https://github.com/revsys/django-friendship/" rel="nofollow">django-friendship</a> and add some different functionality. I've forked it on GitHub. I'm not sure what to do next.</p> <p>Where should the local copy of my <code>django-friendship</code> repo go? Should I integrate it into my current Django project as an app, or set it up as a separate project? In which case, how do I set my main Django project to use it as an app while developing it?</p> <p>Any guidance or other resources I can learn from here would be much appreciated.</p> <p>Thanks!</p> |
32,290,600 | 0 | <p>Check out <strong>Twitter Bootstrap</strong> - <a href="http://getbootstrap.com" rel="nofollow">http://getbootstrap.com</a> and <strong>Zurb Foundation</strong> - <a href="http://foundation.zurb.com" rel="nofollow">http://foundation.zurb.com</a>. These two are the most popular mobile responsive frameworks out right now. If you want lighter alternatives which are not as bloated, you can check out <strong>Skeleton</strong> - <a href="http://getskeleton.com" rel="nofollow">http://getskeleton.com</a></p> |
23,067,893 | 0 | <p>Since you've posted no logcat, I can't correct your code, but I can give you a working example:</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.belfast_map); ImageButton ib1,ib2,ib3,ib4,ib5; //change your image ID's here ib1= (ImageButton) findViewById(R.id.go_to_lagan_screen); ib2= (ImageButton) findViewById(R.id.go_to_city); ib3= (ImageButton) findViewById(R.id.go_to_university); ib4= (ImageButton) findViewById(R.id.go_to_icon_screen); ib5= (ImageButton) findViewById(R.id.map_to_home_screen); ib1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //change the action here, a toast in your example Toast.makeText(MainActivity.this, MainActivity.this.getResources().getString(R.string.my_resource_string), Toast.LENGTH_LONG); } } ); ib2.setOnClickListener((new View.OnClickListener() { @Override public void onClick(View v) { Intent intent1= new Intent (MapScreen.this, CityCentre.class); startActivity(intent1); //To change body of implemented methods use File | Settings | File Templates. } })); ib3.setOnClickListener((new View.OnClickListener() { @Override public void onClick(View v) { Intent intent2= new Intent (MapScreen.this, UniversityArea.class); startActivity(intent2); //To change body of implemented methods use File | Settings | File Templates. } })); ib4.setOnClickListener((new View.OnClickListener() { @Override public void onClick(View v) { Intent intent3= new Intent (MapScreen.this, TheIcons.class); startActivity(intent3); //To change body of implemented methods use File | Settings | File Templates. } })); ib5.setOnClickListener((new View.OnClickListener() { @Override public void onClick(View v) { Intent intent4= new Intent (MapScreen.this, MyActivity.class); startActivity(intent4); //To change body of implemented methods use File | Settings | File Templates. } })); } </code></pre> |
13,239,290 | 0 | <p>To get your cart total (assuming that the customer is log in or enter the shipping info)</p> <pre><code>$cart = Mage::getModel('checkout/session')->getQuote(); echo Mage::helper('core')->currency($cart->getGrandTotal(),true,false); </code></pre> <p>To get Shipping amount</p> <pre><code>$shippingMethod = $cart->getShippingAddress(); echo Mage::helper('core')->currency($shippingMethod['shipping_amount'],true,false); </code></pre> <p>Source <a href="http://www.magentocommerce.com/boards/viewthread/278544/" rel="nofollow">http://www.magentocommerce.com/boards/viewthread/278544/</a></p> |
7,619,273 | 0 | <ol> <li><code>flip elem listx</code> is equivalent to <code>(flip elem) listx</code>. </li> <li><code>(flip elem)</code> is the same as <code>elem</code>, but with the arguments in opposite order. This is what <code>flip</code> does.</li> <li><code>elem</code> is a function that takes an element and a list, and checks whether the element belongs to the list.</li> <li>So <code>flip elem</code> is a function that that takes a list and an element, and checks whether the element belongs to the list.</li> <li>Therefore <code>flip elem listx</code> is a function that that takes an element, and checks whether the element belongs to <code>listx</code>.</li> <li>Now <code>all</code> takes a predicate and a list, and checks whether all elements of the list satisfy the predicate.</li> <li><code>all (flip elem listx)</code> take a list, and checks whether all elements of the list satisfy <code>flip elem listx</code>. That is, whether they all belong to <code>listx</code>.</li> <li><code>all (flip elem listx) input</code> checks whether all elements of <code>input</code> belong to <code>listx</code>.</li> <li>Q.E.D.</li> </ol> |
36,819,972 | 0 | LC-3 Motor Program (Strange Outputs) <p>So the output to my LC-3 program is giving me very strange characters/symbols. The objective of this program is to ask a user to input a 0 or a 1. If the user inputs a 1, the motor moves 120 degrees clockwise and then 90 degrees counter clockwise. If the user inputs a 0, the motor moves 50 degrees counter clockwise. 360 degrees = 36 steps. What is a step? A step is 10 degrees. The output prints out each step. For example, the user inputs a 0 then the output should say:</p> <pre><code>The motor moved 10 degrees CCW The motor moved 10 degrees CCW The motor moved 10 degrees CCW The motor moved 10 degrees CCW The motor moved 10 degrees CCW </code></pre> <p>It's a pretty interesting task imo but I'm having trouble actually making it work. Attached is my code and a screenshot of my output. Thanks for your time!</p> <p>Can't embed picture since this account is new but the link of the screenshot of my output is below: <a href="http://i.stack.imgur.com/wZi29.png" rel="nofollow">http://tinypic.com/r/9roghf/9</a></p> <p>It also seems like the code didnt embedded correctly but please consider everything below as part of the code (Because it is!):</p> <pre><code>.ORIG x4000 ;Constants Prompt .STRINGZ "Enter '1' to move moter 120 degrees clockwise then 90 degrees counter clockwise or Enter '0' to move motor 50 degree counter clockwise" CW .STRINGZ "The motor rotated 10 degrees clockwise" CCW .STRINGZ "The motor rotated 10 degrees counterclockwise" RL ;Clear and Load Register 2 AND R2, R2, #0 ADD R2, R2, #12 ;Clear and Load Register 3 AND R3, R3, #0 ADD R3, R3, #3 ;Clear and Load Register 4 AND R4, R4, #0 ADD R4, R4, #2 ;Clear And Load Register 5 AND R5, R5, #0 ADD R5, R5, #1 LL0 ;user input LEA R0, Prompt PUTS ;Print String GETC ;Receive user input OUT ;Prints out user input BRz LL3 ;If user input 0 BRp LL1 ;If user input 1 ;beginning of '1' loop ;120 degree clockwise rotation LL1 LEA R0, CW ADD R2, R2, #-6 ;1 Bit Shift (Right) - 10 degree turn PUTS AND R0, R0, #0 ADD R0, R0, #10 OUT ADD R2, R2, #-3 ;1 Bit Shift (Right) - 10 degree turn PUTS AND R0, R0, #0 ADD R0, R0, #10 OUT ADD R2, R2, #6 ;1 Bit Shift (Right) - 10 degree turn PUTS AND R0, R0, #0 ADD R0, R0, #10 OUT ADD R2, R2, #3 ;1 Bit Shift (Right) - 10 degree turn PUTS AND R0, R0, #0 ADD R0, R0, #10 OUT ADD R3, R3, #-1 ;Decrement Loop (3x) BRp LL1 ;90 degree counter clockwise rotation LL2 LEA R0, CCW ADD R2, R2, #-3 ;1 Bit Shift (Left) - 10 degree turn PUTS AND R0, R0, #0 ADD R0, R0, #10 OUT BRz Stop ;After 90 degree turn ADD R2, R2, #-6 ;1 Bit Shift (Left) - 10 degree turn PUTS AND R0, R0, #0 ADD R0, R0, #10 OUT ADD R2, R2, #3 ;1 Bit Shift (Left) - 10 degree turn PUTS AND R0, R0, #0 ADD R0, R0, #10 OUT ADD R2, R2, #6 ;1 Bit Shift (Left) - 10 degree turn PUTS AND R0, R0, #0 ADD R0, R0, #10 OUT ADD R4, R4, #-1 ;Decrement Loop (2x) BRzp LL2 ;beginning of '0' loop ;50 degree counter clockwise LL3 LEA R0, CCW ADD R2, R2, #-3 ;1 Bit Shift (Left) - 10 degree turn PUTS AND R0, R0, #0 ADD R0, R0, #10 OUT BRz Stop ;After 50 degree turn ADD R2, R2, #-6 ;1 Bit Shift (Left) - 10 degree turn PUTS AND R0, R0, #0 ADD R0, R0, #10 OUT ADD R2, R2, #3 ;1 Bit Shift (Left) - 10 degree turn PUTS AND R0, R0, #0 ADD R0, R0, #10 OUT ADD R2, R2, #6 ;1 Bit Shift (Left) - 10 degree turn PUTS AND R0, R0, #0 ADD R0, R0, #10 OUT ADD R5, R5, #-1 ;Decrement Loop (1x) BRz LL3 Stop HALT .END </code></pre> |
34,618,413 | 0 | <p>I've found the cause of the problem. It's actually very simple but also pretty frustrating.</p> <p>When publishing the web app, you have the option to <code>Remove additional files at destination</code>. I have always left this checked because I don't like old files hanging around for no reason. </p> <p>You also have the option to <code>Exclude files from the App_Data folder</code> which I also always leave checked so that files from <code>App_Data</code> are not deleted based on the remove configuration above. I then usually configure things like NLog log files, ELMAH xml files etc to go into <code>App_Data</code> safe in the knowledge that anything in there won't be deleted.</p> <p>So the issue with Webjobs is that they're deployed into <code>App_Data</code>. So if the <code>Exclude files from App_Data folder</code> is checked then when the app is published, it's doing what it's told and ignoring <code>App_Data</code> and hence ignoring the changes to the Webjob. </p> <p>So the simple solution is to uncheck this option and the Webjob is deployed successfully. However the issue now is that all other files in <code>App_Data</code> will be deleted (log files etc). </p> <p>So you could uncheck the remove files config but that then potentially leaves other unwanted files lying around. Not ideal. </p> <p>The other option is to leave the remove config checked, click the Preview button within the Publish dialog prior to publishing, then manually unchecking every file you don't want deleted. However the publish process fails if any of the files you want to keep are within sub-folders within <code>App_Data</code> e.g. <code>App_Data/logs</code>.</p> <p>So the other option is to move all of the files within <code>App_Data</code> that you want to keep into the root of <code>App_Data</code>, then uncheck each of them within the Preview window prior to publishing. Not a huge deal when done once but becomes tedious when publishing lots of times.</p> <p>I realise I could move log files etc to Azure storage, SQL DBs etc but what if it's the case that other files are in <code>App_Data</code> which need to be kept? <code>App_Data</code> isn't solely intended for Webjobs but using Webjobs creates a bit of an awkward situation if you also use <code>App_Data</code> for other things. </p> <p>Be keen to know if I'm missing anything obvious here?</p> |
1,764,353 | 0 | <p>I've looked at the MSDN page... it said NtQuerySystemInformation() is an OS internal proc, and that we're not recommended to use it:</p> <blockquote> <p>The NtQuerySystemInformation function and the structures that it returns are internal to the operating system and subject to change from one release of Windows to another. To maintain the compatibility of your application, it is better to use the alternate functions previously mentioned instead.</p> </blockquote> |
19,736,891 | 0 | <p>The problem is exactly what the Traceback log says: <code>Could not convert string to float</code></p> <ul> <li>If you have a string with only numbers, python's smart enough to do what you're trying and converts the string to a float.</li> <li>If you have a string with non-numerical characters, the conversion will fail and give you the error that you were having.</li> </ul> <p>The way most people would approach this problem is with a <code>try/except</code> (see <a href="http://docs.python.org/3/tutorial/errors.html" rel="nofollow">here</a>), or using the <code>isdigit()</code> function (see <a href="http://www.tutorialspoint.com/python/string_isdigit.htm" rel="nofollow">here</a>).</p> <p><strong>Try/Except</strong></p> <pre><code>try: miles = float(input("How many miles can you walk?: ")) except: print("Please type in a number!") </code></pre> <p><strong>Isdigit()</strong></p> <pre><code>miles = input("How many miles can you walk?: ") if not miles.isdigit(): print("Please type a number!") </code></pre> <p>Note that the latter will still return false if there are decimal points in the string</p> <h2>EDIT</h2> <p>Okay, I won't be able to get back to you for a while, so I'll post the answer just in case.</p> <pre><code>while True: try: miles = float(input("How many miles can you walk?: ")) break except: print("Please type in a number!") #All of the ifs and stuff </code></pre> <p>The code's really simple:</p> <ul> <li>It will keep trying to convert the input to a float, looping back to the beginning if it fails.</li> <li>When eventually it succeeds, it'll break from the loop and go to the code you put lower down.</li> </ul> |
40,811,428 | 0 | <p>You can do this in a single redirect rule:</p> <pre><code>RewriteEngine On RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !=www.ourwebsite.co.uk RewriteRule ^ https://www.ourwebsite.co.uk%{REQUEST_URI} [R=301,L,NE] # rest of rules go below this </code></pre> <p>Make sure to clear your browser cache before testing this change.</p> |
1,357,579 | 0 | Does Intellij Idea 8.1.x install and run on Mac OSX 10.6? <p>Does Intellij Idea 8.1.x install and run on Mac OSX 10.6 (snow-leopard)?</p> <p>Are there any special steps needed to get it to work?</p> |
34,575,799 | 0 | <p>Solved - like this</p> <pre><code> var webApp = express(); var cors = require('cors'); webApp.use(cors()); webApp.use(kue.app); webApp.listen(); </code></pre> |
29,189,745 | 0 | In XSLT using XPath <p>if I have number like $999,999 I want to use a function to give me just 999999 without any other symbol.I tried substring(value,2) but that take of the $ how about the , Is there any idea to do that, </p> |
19,635,143 | 0 | PHP timthumb error with Joomla <p>I am using a Joomla template in my site. But It doesn't load any images in portfolio content. When I am opening the path of the image it opens a php file and this gives this error</p> <blockquote> <p>open_basedir restriction in effect. File(/usr/local/apache/htdocs) is not within the allowed path(s): (/home/:/usr/lib/php:/tmp) in <strong><em>serverpath</em></strong>/public_html/templates/ekho/lib/timthumb.php on line 867</p> </blockquote> <p>I need to know where is the problem? Please help in advance... Thanks</p> |
17,336,268 | 0 | How to get text from a textbox using javascript <p>i have developed a web application using mvc4.</p> <p>in this case i need to get a text box value(actually the text entered in the text box) using javascript.</p> <p>here is the code i am using</p> <pre><code> @model PortalModels.WholeSaleModelUser @using (Html.BeginForm("uploadFile", "WholeSaleTrade", FormMethod.Post, new { enctype = "multipart/form-data" })) { @Html.ValidationSummary(true) <fieldset> <legend>WholeSaleModelUser</legend> <table> <tr> <td> <div class="editor-label"> @Html.LabelFor(model => model.Name) </div> </td> <td> <div class="editor-field"> @Html.TextBoxFor(model => model.Name) @Html.ValidationMessageFor(model => model.Name) </div> </td> </tr> </table> <div id="partial"> <table> <tr> <td> <img id="blah" src="../../Images/no_image.jpg" alt="your image" height="200px" width="170px" /> </td> </tr> </table> <script type="text/javascript"> function loadUserImage() { var userImg = document.getElementById("blah"); var imgNm = $("#Name").value; userImg.src = "D:/FEISPortal/FortalApplication/Img/" + imgNm + ".png"; alert(imgNm); alert(userImg.src); } </script> </code></pre> <p>in that case alert gives the value as "undefined" and if do the following modification alert gives nothing.</p> <pre><code>var imgNm = document.getElementById("Name").value; </code></pre> <p>for</p> <pre><code>var imgNm = $("#Name").value; </code></pre> <p>how to get the text entered in the text box?</p> |
27,838,495 | 0 | Finding the difference between a time and the current time <p>So I'm writing an app that has similar functionality to an alarm clock. It asks for the user to input a time. But I've been stuck on how to figure this out for a while.</p> <p>The method needs to find the difference in minutes between the user selected time, and the current time. Assuming that the user will always put in a time that is AFTER the current time (otherwise it wouldn't make sense to use my app), the difference would just be (userTimeInMins - currTimeInMins), where both are calculated by ((hours * 60) + minutes).</p> <h2>BUT. Here's the problem:</h2> <p>Ex 1) If the current time is 10 PM, and the user enters in the time 2 AM. The above algorithm would say that the difference between the two times is (22 * 60 + 0) - (2 * 60 + 0), which is clearly incorrect because this would mean there is a difference of 20 hours between 10PM and 2 AM, when the difference is actually 4 hours. <br/> <br/> Ex 2) If the current time is 1PM, and the user enters in the time 2AM. The above algorithm would say that the difference between the two times is (13 * 60 + 0) - (2 * 60 + 0), which is again incorrect because this would mean there is a difference of 11 hours, when the difference is actually 13 hours.</p> <h2>What I have so far</h2> <p>I've realized that for example 1 and for example 2, the difference in minutes can be calculated with (((24 + userHours) * 60) + userMinutes) - currTimeInMins</p> <p>I'm struggling to come up with decision statements in the method to determine whether to use the first method or the second method to calculate the difference in minutes.</p> <h2>The Code</h2> <pre><code>// Listener for the time selection TimePickerDialog.OnTimeSetListener time = new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { String currAM_PM = ""; String userAM_PM = ""; // Get user AM/PM int hourToShow = 0; if (hourOfDay > 12){ hourToShow = hourOfDay - 12; userAM_PM = "PM" } else if (hourOfDay == 12){ hourToShow = hourOfDay; userAM_PM = "PM" } else{ hourToShow = hourOfDay; userAM_PM = "AM" } // Update the time field to show the selected time in 12-hr format EditText timeField = (EditText) findViewById(R.id.editTime); timeField.setText(hourToShow + ":" + minute + " " + userAM_PM); // Get current hour SimpleDateFormat sdf = new SimpleDateFormat("HH"); String cHour = sdf.format(new Date()); int currHour = Integer.parseInt(cHour); // Get current AM/PM if (currHour > 12){ currAM_PM = "PM" } else if (currHour == 12){ currAM_PM = "PM" } else{ currAM_PM = "AM" } // Calculate the time to use // If the selected hour is less than the current hour AND am_pm is "AM" // THIS IS THE WHERE I NEED HELP //-------------------------------------------------------------- if(currAM_PM == "PM" && userAM_PM == "AM" .... ??????) { //take 24, add the hour, use same minute. so that 3 am is 27:00. timeToUse = ((24 + hourOfDay) * 60) + minute; } else timeToUse = (hourOfDay * 60) + minute; } // timeToUse is then passed through an intent extra to the next activity // where the difference between it and the current time is calculated and used // for other purposes. }; </code></pre> <h2>Thanks for any help ahead of time.</h2> |
6,738,232 | 0 | SilverLight Service Deployment <p>I've written a silverlight app with a simple wcf service. Runs great on my computer, when I publish it to my web account it no longer works with the service. I tried editing the clintconfig file to set the endpoint to the new location, that did not fix it. So I downloaded this simple SilverLight App with WCF example setup for deploying, and it also works on my personal machine, but not when I publish it to my domain. My account supports asp.net, wcf, etc.. The link to the example I downloaded: <a href="http://www.codeproject.com/Articles/152778/Deploying-Silverlight-with-WCF-Services" rel="nofollow">http://www.codeproject.com/Articles/152778/Deploying-Silverlight-with-WCF-Services</a></p> <p>I'm new to this, so I'm wondering if this is something that should work without additional work, or if I'm missing something. I'm not getting any errors, I'm just not getting the message displayed on the screen from the service.</p> <p>Added following after Hatchets Comment: I'm trying to figure out how to find a error message. So far the only way I know it's not working is I don't see the message that is returned from the service. SilverLight displays the returned message, "Hello from My WCF Service". I see it on my machine, but not when I publish it to my domain. The app I downloaded, if I understand it right, is setup to work without having to change the endpoint address, but i'm so new to this, I've not figured out what i'm missing yet. Thanks.</p> <p>Added after comments below:</p> <p>I grabed fiddler, and after i added the tag, i was able to see an error in fiddler, and when browsing to the .svc file. Error: </p> <p>Configuration Error</p> <p>Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. </p> <p>Parser Error Message: Unrecognized attribute 'multipleSiteBindingsEnabled'. Note that attribute names are case-sensitive.</p> <pre><code>Source Error: Line 30: </bindings> Line 31: <serviceHostingEnvironment aspNetCompatibilityEnabled="true" Line 32: multipleSiteBindingsEnabled="true" /> Line 33: <services> Line 34: <service name="testWCF.Web.Service1"> </code></pre> <p>Source File: \boswinfs03\home\users\web\b706\whl.forystpcom\web.config Line: 32 </p> <p>Version Information: Microsoft .NET Framework Version:2.0.50727.4211; ASP.NET Version:2.0.50727.4016</p> <p>I'm unfamiliar with multipleSiteBindingsEnabled and the best way to handle this, does the version of .NET running affect this? The server i'm running this on supports up to 3.5 it says, but I notice it quotes version 2.0 in the error, not sure if they are connected.</p> |
28,929,317 | 0 | <p>You did not put in the <code>use</code> statement for <code>OAuthTokenCredential</code>.</p> |
6,875,127 | 0 | <p>Based on <a href="http://stackoverflow.com/questions/4324558/whats-the-proper-way-to-install-pip-virtualenv-and-distribute-for-python/5177027#5177027">Walker Hale IV's answer</a> to a similar (but distinct! ;) ) question, there are two keys to doing this:</p> <ul> <li>you don't need to install distribute and pip because these are automatically included in a new virtual environment (and you presumably only want the versions that have been tested with virtualenv)</li> <li>you can use the virtualenv source code to create a new virtual environment, rather than using the system-installed version of virtualenv</li> </ul> <p>So the workflow is:</p> <ul> <li>install Python version X on your system</li> <li>download virtualenv source code version Q (probably the latest)</li> <li>create new virtual environment with Python X and virtualenv Q</li> <li>your new VE is now running Python X and the latest stable versions of pip and distribute</li> <li>pip install any other packages</li> <li>easy_install any other packages that you can't pip install</li> </ul> <p>Notes:</p> <ul> <li>In your new virtual environment, you could install new (or old) versions of distribute, pip or virtualenv. (I think)</li> <li>I don't use WH4's technique of create a bootstrap virtual environment. Instead, I create the new virtual environment from the virtualenv source each time.</li> <li>This technique should be usable on any operating system.</li> <li>If I were explaining this to someone new to the whole Distribute/pip/virtualenv ecosystem concept, I would explain it in a virtualenv-centric way.</li> </ul> <p>I've written a bash script that does the basics in Ubuntu:</p> <pre><code> #! /bin/bash # Script to create a python virtual environment # independently of the system version of virtualenv # # Ideally this would be a cross-platform Python # script with more validation and fewer TODOs, # but you know how it is. # = PARAMETERS = # $1 is the python executable to use # examples: python, python2.6, /path/to/python # $2 is the new environment folder # example: /path/to/env_folder/name ## TODO: should be just a name ## but I can't concatenate strings in bash # $3 is a pip requirements file # example: /path/to/req_folder/name.txt # you must uncomment the relevant code below to use $3 ## TODO: should be just a name ## but I can't concatenate strings in bash # other parameters are hard-coded below # and you must change them before first use # = EXAMPLES OF USE = # . env_create python2.5 /home/env/legacy ## creates environment "legacy" using python 2.5 # . env_create python /home/env/default ## creates environment "default" using whatever version of python is installed # . env_create python3.2 /home/env/bleeding /home/req/testing.txt ## creates environment "bleeding" using python 3.2 and installs packages from testing.txt using pip # = SET UP VARIABLES = # Required version of virtualenv package VERSION=1.6.4 # Folder to store your virtual environments VE_FOLDER='/media/work/environments' ## TODO: not used because I can't concatenate strings in bash # Folder to store bootstrap (source) versions of virtualenv BOOTSTRAP_FOLDER='/media/work/environments/bootstrap' ## TODO: not used because I can't concatenate strings in bash # Folder to store pip requirements files REQUIREMENTS_FOLDER='/media/work/environments/requirements' ## TODO: not used because I can't concatenate strings in bash # Base URL for downloading virtualenv source URL_BASE=http://pypi.python.org/packages/source/v/virtualenv # Universal environment options ENV_OPTS='--no-site-packages --distribute' # $1 is the python interpreter PYTHON=$1 # $2 is the target folder of the new virtual environment VE_TARGET=$2 # $3 is the pip requirements file REQ_TARGET=$3 ## = DOWNLOAD VIRTUALENV SOURCE = ## I work offline so I already have this downloaded ## and I leave this bit commented out # cd $BOOTSTRAP_DIR # curl -O $URL_BASE/virtualenv-$VERSION.tar.gz ## or use wget # = CREATE NEW ENV USING VIRTUALENV SOURCE = cd $BOOTSTRAP_FOLDER tar xzf virtualenv-$VERSION.tar.gz # Create the environment $PYTHON virtualenv-$VERSION/virtualenv.py $ENV_OPTS $VE_TARGET # Don't need extracted version anymore rm -rf virtualenv-$VERSION # Activate new environment cd $VE_TARGET . bin/activate # = INSTALL A PIP REQUIREMENTS FILE = ## uncomment this if you want to automatically install a file # pip install -r $REQ_TARGET # = REPORT ON THE NEW ENVIRONMENT = python --version pip freeze # deactivate ## uncomment this if you don't want to start in your environment immediately </code></pre> <p>Output looks something like this (with downloading switched off and deactivation switched on):</p> <pre> user@computer:/home/user$ . env_create python3 /media/work/environments/test New python executable in /media/work/environments/test/bin/python3 Also creating executable in /media/work/environments/test/bin/python Installing distribute...............done. Installing pip...............done. Python 3.2 distribute==0.6.19 wsgiref==0.1.2 user@computer:/media/work/environments/test$ </pre> |
24,825,015 | 0 | signed or unsigned int in c++ <p>How can i check if given int(or any other data type) is signed or unsigned? I found this function while searching, </p> <pre><code>std::numeric_limits<int>::is_signed </code></pre> <p>But i can only input the data type, is there a way that i can check by variable name, like.</p> <pre><code>signed int x = 5; </code></pre> <p>Now i want to make a function which checks that x is a signed int or not.</p> <p>And if you guys can answer these little questions, that would be highly appreciated.</p> <ol> <li>Why do we use '::' these operators after std? </li> <li>What do they mean when we use them in std::cout, is it the same?</li> <li>Here numeric_limits<> is a class or what?</li> <li>And again, why are we using these '::' before is_signed?</li> </ol> |
12,553,867 | 0 | <p>Did you remove old version of the php? <code>sudo yum remove php</code> or (php5, I don't remember how excatly the package is named)</p> <p>After removing run <code>sudo updatedb</code> and <code>sudo locate php</code> and delete any leftovers (e.g /etc/php, /usr/local/php and so on). Care not to delete files from other applications or the package manager. When your system is clean and no traces of the old version are there install the new version: after the config step that finishes the guide run <code>make</code> and then <code>sudo make install</code></p> |
17,252,799 | 0 | XNA Texture2D Billboarding appears as a white block <p>Very odd problem, when I try and draw my billboard sprite it always appears as a white block, changing the .draw color property still draws it as white, it also doesn't matter it I use a jpeg, or transparent png.</p> <p>[EDIT]</p> <p>So I'm now trying to use a <code>Viewport</code> instead of a basic effect to just get an x and y screen coordinate, I'll fix any scaling issue later, however now the image stays in the exact same spot (on the screen, it doesn't change position based on the camera) and doesn't get any bigger or smaller based on how far away it is</p> <p>My new billboard rendering function:</p> <pre><code>public void Draw(Camera camera, GraphicsDevice device, SpriteBatch spriteBatch, Texture2D Texture) { Viewport viewport = new Viewport(new Rectangle(0, 0, 800, 480)); Vector3 viewSpaceTextPosition = viewport.Project(this.position, camera.Projection, camera.View, camera.World); spriteBatch.Begin(); spriteBatch.Draw(Texture, new Vector2(viewSpaceTextPosition.X, viewSpaceTextPosition.Y), null, Color.White, 0, new Vector2(Texture.Bounds.Center.X, Texture.Bounds.Center.Y), this.Scale, SpriteEffects.None, viewSpaceTextPosition.Z); spriteBatch.End(); device.RasterizerState = RasterizerState.CullCounterClockwise; device.BlendState = BlendState.Opaque; device.DepthStencilState = DepthStencilState.Default; } </code></pre> <p>So is my use of Viewport wrong or do I just need to use it's information differently in <code>spriteBatch.Draw()</code>?</p> |
19,572,852 | 0 | Why use To_Localtime when analyzing IIS logs <p>I've searched for several examples to analyze IIS logs using the Log Parser, taking time into account... For example, this query that shows the number of hits per hour:</p> <pre><code>SELECT QUANTIZE(TO_LOCALTIME(TO_TIMESTAMP(date, time)), 3600) AS Hour, COUNT(*) AS Hits FROM D:\Logs\*.log Group By Hour </code></pre> <p>However I cannot understand why use "TO_LOCALTIME"... Also, if there is a time difference (and a difference in results while using "TO_LOCALTIME" or not), how is that?... Thank you!</p> |
30,243,915 | 0 | <p>I highly recommend this - </p> <pre><code>if(/Element/g.test(Array)){---} </code></pre> |
12,404,646 | 0 | <p>You can try this, It will work for both example.</p> <pre><code>$('h1').each(function(){ var self = $(this); var p = self.text().split(' '); var html = self.html().replace(p[0], '<span>'+ p[0] +'</span>'); self.html(html); }); </code></pre> <p>Check this <strong><a href="http://jsfiddle.net/6seeW/" rel="nofollow">Demo</a></strong></p> |
28,989,954 | 0 | sftp copy files from windows server to linux server using shell scripting <p>I am working on shell script that is supposed to transfer files (with their subdirectories) from a Windows Server to a Linux-Samba server. The Windows server is setup to accept sftp requests and I am logging into the Windows server with shared ssh keys so there is no need for a password exchange. I can log into the Windows from the linux server with this command:</p> <pre><code> sftp user@host_name </code></pre> <p>It executes the sftp command and logs me into the Windows server. When I try to use the:</p> <pre><code> get -r /home_directory/first_level/* /local/directory/to/put/files </code></pre> <p>I get an error message saying "Invalid flag -r". I can't use SCP because it is not enabled on the server. </p> <p>What can I do in order to recursively copy all the files and directories from the Windows server to the linux server using a shell script?</p> |
16,934,559 | 0 | C# how to add data into excel with no headers <p>I tried searching for examples and never i found an example for inserting data into an empty excel.</p> <pre><code>Insert into [Sheet1$] (columnname1, columnName2) values ("somevalue","somevalue"); </code></pre> |
32,914,951 | 0 | Java minesweeper game I want to hide the broad when I start the game? <p>I'm new to this site, however, I'm having problem hiding my broad when I start the game, I just want to make it invisible from the user. But I don't know where did I missed up with my code. Please help me out with this.</p> <pre><code>import java.util.Scanner; public class MineSweeperGame { int row, col; boolean succes = false; public static void main(String[] args) { MineSweeperGame ms = new MineSweeperGame(); ms.run(); } // // Recursive reveal method // public void reveal(int x, int y, char[][] mineField, boolean[][] isVisible) { int minx, miny, maxx, maxy; int result = 0; // // if cell(x, y) is not mine, make sure visible that cell. // if (mineField[x][y] != '*') { isVisible[x][y] = true; // // if cell(x, y) is blank, check all surrounding cells // if (mineField[x][y] == '.') { // // Don't try to check beyond the edges of the board... // minx = (x <= 0 ? 0 : x - 1); miny = (y <= 0 ? 0 : y - 1); maxx = (x >= row - 1 ? row - 1 : x + 1); maxy = (y >= col - 1 ? col - 1 : y + 1); // // Loop over all surrounding cells, call recursive reveal(i, j) method // for (int i = minx; i <= maxx; i++) { for (int j = miny; j <= maxy; j++) { if (isVisible[i][j] == false) { reveal(i, j, mineField, isVisible); } } } } } // // if cell(x, y) is mine, do nothing. // else { } } void printMineMap(char[][] mineField, boolean[][] isVisible) { System.out.println(); succes = true; // // Loop over all cells, print cells // for (int x = 0; x < row; x++) { for (int y = 0; y < col; y++) { // // Loop over all cells, print cells // if (isVisible[x][y]) { System.out.print(" " + mineField[x][y] + " "); } else { System.out.print("[" + mineField[x][y] + "] "); if (mineField[x][y] != '*') { succes = false; } } } System.out.println(); } if (succes) { System.out.println("********** Congratulations~!!! You win. **********"); } } private void run() { // // Initialize MineField // char[][] mineField = MineField.getMineField(); row = mineField.length; col = mineField[0].length; boolean[][] isVisible = new boolean[row][col]; // print mine map printMineMap(mineField, isVisible); while (true) { System.out.print("Enter your guess (x y): "); Scanner in = new Scanner(System.in); // // input x, y // int x = in.nextInt() - 1; if (x < 0) {// if negative value, exit program. System.out.println("Canceled by user."); break; } int y = in.nextInt() - 1; if (x >= row || y >= col) // ignore invalid values { continue; } // // Check cell(x,y) is mine, if yes, quit program // if (mineField[x][y] == '*') { isVisible[x][y] = true; printMineMap(mineField, isVisible); System.out.println("Game Over ~!!!"); break; } // // call recursive reveal method to reveal cell(x, y) // reveal(x, y, mineField, isVisible); printMineMap(mineField, isVisible); } } } </code></pre> <p>where and example of the game when it start ( I tried to post it as the game dose but every time I try it missed up the order).</p> <pre><code>[.] [.] [1] [1] [2] [*] [1] [.] [.] [.] [1] [*] [2] [1] [1] [.] [.] [.] [1] [1] [1] [1] [2] [2] [.] [1] [2] [2] [1] [1] [*] [*] [.] [1] [*] [*] [1] [1] [2] [2] [1] [2] [3] [4] [3] [1] [.] [.] [*] [1] [1] [*] [*] [1] [.] [.] [1] [1] [1] [2] [2] [1] [.] [.] </code></pre> <p>Enter your guess (x y): </p> <p>What I want is something like this </p> <pre><code>[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] </code></pre> |
30,930,082 | 0 | Swift Array Issues <p>I have this code:</p> <pre><code>let posState = positionState(pos) if posState != .None { if posState == .Off { boardArray[pos.row][pos.column] == .On } else { boardArray[pos.row][pos.column] == .Off } } </code></pre> <p>The issue I'm having is that when I attempt to change the value of an element in <code>boardArray</code>, nothing happens. Why does boardArray's element stay the same?</p> |
30,238,382 | 0 | Separator lines for custom spinner are not dispalyed in Lollipop <p>I am using a custom BaseAdapter to create a custom spinner where I am using </p> <pre><code>@Override public View getDropDownView(int position, View cnvtView, ViewGroup prnt) { return cnvtView; } </code></pre> <p>to display a drop down bar. But between the text items here the separator lines are displayed in android 5. This happens only for lollipop version. Not sure why is this happening. </p> <p>Also tried using </p> <pre><code> @Override public boolean areAllItemsEnabled() { return true; } @Override public boolean isEnabled(int position) { return false; </code></pre> <p>}</p> <p>Still no luck. Can any body please explain?</p> |
23,088,033 | 0 | Logging response and request to OAuth provider <p>Is there a way to capture the response from requests served by OAuth? Specifically, I need to log the request and response from <code>OAuthAuthorizationServerProvider.GrantResourceOwnerCredentials()</code>.</p> <p>I've tried extending <code>OwinMiddleware</code> and overriding <code>Invoke</code> as shown in <a href="http://stackoverflow.com/questions/17679644/owin-onsendingheaders-callback-reading-response-body?lq=1">this post</a>, but I'm unable to read the response body. I'd like to use a message handler as <a href="http://stackoverflow.com/questions/17656066/converting-httprequestmessage-to-owinrequest-and-owinresponse-to-httpresponsemes">this post</a> demonstrates, but I don't have <code>UseHttpMessageHandler</code> on my <code>AppBuilder</code> object.</p> <p>Any help would be greatly appreciated. Thank you!</p> <p><strong>Update</strong></p> <p>Modifying the example provided in Brock's excellent <a href="http://brockallen.com/2014/02/28/lidnug-intro-to-owin-and-katana" rel="nofollow">video</a>, here's what I need to do:</p> <pre class="lang-cs prettyprint-override"><code>public class Startup { public void Configuration(IAppBuilder app) { app.Use(typeof(MW1)); app.Map("/api", fooApp => { fooApp.Use<MW2>(); }); } } public class MW1 { Func<IDictionary<string, object>, Task> next; public MW1(Func<IDictionary<string, object>, Task> next) { this.next = next; } public async Task Invoke(IDictionary<string, object> env) { var ctx = new OwinContext(env); await next(env); // I need to be able to read: <h1>MW2 called</h1> written by MW2 var body = ctx.Response.Body; // body.CanRead = False } } public class MW2 { Func<IDictionary<string, object>, Task> next; public MW2(Func<IDictionary<string, object>, Task> next) { this.next = next; } public async Task Invoke(IDictionary<string, object> env) { var ctx = new OwinContext(env); await ctx.Response.WriteAsync("<h1>MW2 called</h1>"); await next(env); } } </code></pre> <p>I actually need to read the response sent from the OAuth provider, but I assume it would be the same process.</p> |
21,696,873 | 0 | <p>The initial problem stems from the restriction that contracts cannot modify the object they belong to (otherwise, the program might behave differently in debug and release mode). The way the language enforces that restriction is by making the <code>this</code> pointer <code>const</code>.</p> <p>A <code>const this</code> means is that you can't modify the <code>this</code> object's fields, and as for calling methods - those methods themselves must be annotated as <code>const</code>, and the same restrictions apply to the code of those methods. This explains the first error: the contract, which was <code>const</code>, was trying to call a non-<code>const</code> (mutable) method. Since mutable methods are allowed to modify <code>this</code>, and contracts are forbidden to do so, the compiler forbids the call.</p> <p>Because of the transitive nature of D's constness, everything that's accessed through the <code>this</code> pointer becomes <code>const</code>. And, if any of the class fields are reference types, the target of their indirections becomes <code>const</code> too. This is how the type system will forbid modifying anything that can be reached through the <code>this</code> pointer.</p> <p>The implication of this is that if a <code>const</code> method is trying to return a class field (with indirections, such as a class type like <code>Node</code>), the returned type must also be <code>const</code>. This is the source of the second error message: the return expression attempted to convert the <code>const Node</code> value, obtained through the <code>const this</code>, to a mutable <code>Node</code>. Currently, the syntax <code>@property const Node sub()</code> indicates that the method itself is <code>const</code> (and has as <code>const this</code>), not the return type.</p> <p>Now, generally, in C++, an object with proper constness support will usually have multiple overloads for the methods which return a class field: <code>const</code>, and non-<code>const</code>. The <code>const</code> versions will return a <code>const</code> reference; the non-<code>const</code> will return a non-<code>const</code> reference. The two versions are needed to allow obtaining a mutable field reference when we have access to a mutable object, but still allow getting a <code>const</code> reference if we only have <code>const</code> access to the object. Most of the time, the code of the two methods will be identical - only the function signature will differ.</p> <p>This is where D's <code>inout</code> comes in. Specifying it on the method and some of its arguments or return value means that those arguments or return value will have the same constness as that of <code>this</code> (the object being referred to). This avoids code duplication for the simple cases where returning <code>const</code> and mutable values uses the same code.</p> <p>The syntax I used is <code>@property inout(Node) sub() inout</code>. I think it can be written in more than one way, but this syntax is unambiguous. Here, the parens in <code>inout(Node)</code> make it explicit that we apply the attribute on the return value, and not the function, and placing the method (<code>this</code>) <code>inout</code> attribute after the parameter list, like <code>const</code> in C++, unambigously specifies that it applies to the function itself.</p> |
23,613,980 | 0 | Does not equal filter using vba-access <p>Hello everyone I have been trying to filter data for the "First Match" and "Second Match" that does not equal certain values so the best way I thought of doing this was to create an array of possible values for the field that you would want to filter out and then use a for loop to go through each possible value and filter the data accordingly and at the same time append the values so the previous filtered data will not be lost.</p> <pre><code>Private Sub notEqual_Click() Dim strArray(0 To 13) As String strArray(0) = 0 strArray(1) = 2 strArray(2) = 3 strArray(3) = 4 strArray(4) = 5 strArray(5) = 6 strArray(6) = 7 strArray(7) = 8 strArray(8) = 9 strArray(9) = 10 strArray(10) = 11 strArray(11) = 12 strArray(12) = 13 strArray(13) = 14 For i = LBound(strArray) To UBound(strArray) 'txtF and txtL refers to the text box value If txtF <> "15" And txtF <> "1" Then Me.Filter = "[First Match] = " & strArray(i) Me.Filter = Me.Filter & strArray(i) End If If txtL <> "15" And txtL <> "1" Then Me.Filter = "[Second Match] = " & strArray(i) Me.Filter = Me.Filter & strArray(i) End If Next Me.FilterOn = True End Sub </code></pre> <p>I get an error that says syntax error (missing operator) in query expression 'First Match0". Am I possibly appending the values the wrong way? I feel like there is something wrong with the code inside the for loop.</p> |
6,944,642 | 0 | <p>Try this: </p> <pre><code>php > list($d,$m,$y) = explode("/","28/04/2011"); php > echo date("Y-m-d",mktime(0,0,0,$m,$d,$y)); 2011-04-28 </code></pre> |
35,235,759 | 0 | After changing a variable, do I have to restart? <p>I have a long running service, that consists of two threads.</p> <pre><code>//MY SERVICE: if(userEnabledProcessOne) //Shared preference value that I'm getting from the settings of my app based on a checkbox processOneThread.start(); if(userEnabledProcessTwo) processTwoThread.start(); </code></pre> <p>Basically, I give the user the option to enable/disable these processes with a checkbox. Now, if the user decides to disable one of the processes <strong>while the service is running</strong>, do I need to restart my service with the updated shared preferences? Like so?</p> <pre><code>//In the settings activity of my app public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if ( isChecked ) { // Change shared preferences to make the process enabled stopService(myService.class) startService(myService.class) } if (!isChecked) // Change shared preferences to make the process enabled stopService(myService.class) startService(myService.class) } </code></pre> <p>Now that I've changed my shared preferences, do I need to relaunch my service consisting of two threads? Do I need to do anything to the threads? Is this efficient?</p> <p>Thanks so much,</p> <p>Ruchir</p> |
31,482,781 | 0 | sqlite errors in multithread PHP script <p>I need to update single sqlite database from different separated PHP threads, all running at the same time. Below is the code for db connection</p> <pre><code> $db = new SQLite3(__DIR__.'/proxy.db'); $db->busyTimeout(5000000); $db->exec('PRAGMA journal_mode=WAL;'); $db->exec('PRAGMA temp_store=2;'); $db->exec('PRAGMA synchronous=0;'); </code></pre> <p>And this is the different methods for updating...</p> <pre><code> $db->query('BEGIN TRANSACTION;UPDATE proxy SET lastused='.time().' WHERE id='.$row['id'].';COMMIT;'); $db->query('BEGIN DEFERRED;UPDATE proxy SET lastused='.time().' WHERE id='.$row['id'].';COMMIT;'); $db->query('BEGIN IMMEDIATE;UPDATE proxy SET lastused='.time().' WHERE id='.$row['id'].';COMMIT;') </code></pre> <p>all of them <em>sometime</em> return error: "Unable to execute statement: SQL logic error or missing database". If remove begin-commit code, then I got SQLite3::query(): database is locked.</p> <p>Can I somehow change the code to get rid of those errors (but still use <em>separated</em> multi-threaded processes)?</p> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.