pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
2,634,538 | 0 | <p>Why not use <a href="http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html#M002142" rel="nofollow noreferrer">after_create</a> callback and create the feedback in that method?</p> |
6,259,558 | 0 | Where to put WHERE clause? <p>Why can't I put WHERE clause after ORDER BY?</p> <pre><code>SELECT column1 FROM myTable ORDER BY column2 WHERE column2 = 5 </code></pre> <p>Is there any standard reference? Where can i get a SQL standard draft?</p> |
35,372,360 | 0 | <p>After some more research I found a method that works how I want it to thanks for the advice.</p> <pre><code> public static BackgroundManager Load(string filename) { XmlSerializer Serializer = new XmlSerializer(typeof(BackgroundManager)); LoopAgain: try { using (StreamReader Reader = new StreamReader(filename)) { return Serializer.Deserialize(Reader) as BackgroundManager; } } catch (FileNotFoundException) { XmlSerializer BaseSerializer = new XmlSerializer(typeof(BackgroundManagerSettings)); using (StreamWriter Writer = new StreamWriter(filename)) { BaseSerializer.Serialize(Writer, new BackgroundManager().ToBase()); Writer.Close(); } goto LoopAgain; } catch (InvalidOperationException) { File.Delete(filename); goto LoopAgain; } } public void Save(string filename) { XmlSerializer Serializer = new XmlSerializer(typeof(BackgroundManagerSettings)); using (StreamWriter Writer = new StreamWriter(filename)) { Serializer.Serialize(Writer, this.ToBase()); Writer.Close(); } } private dynamic ToBase() { var Temp = Activator.CreateInstance(typeof(BackgroundManagerSettings)); FieldInfo[] Fields = Temp.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); foreach (FieldInfo x in Fields) { x.SetValue(Temp, x.GetValue(this)); } return Temp; } </code></pre> |
32,587,678 | 0 | <p>There are two logically different sizes you could be talking about: the size of the enum <em>constants</em> associated with a given enum type, or the size of an object whose own type is the enum type. For example, given</p> <pre><code>enum example { ONE, TWO }; enum example enum_variable; </code></pre> <p>the first declaration declares both the type <code>enum example</code> and the constants <code>ONE</code> and <code>TWO</code>.</p> <p>Perhaps surprisingly, the constants do <em>not</em> have type <code>enum example</code>; rather they have type <code>int</code>, and they will therefore consume whatever amount of space an <code>int</code> requires (C99 6.7.2.2/3).</p> <p>On the other hand, <code>enum_variable</code> does have type <code>enum example</code>, and more likely it is actually the size of this type that you hope to affect. C gives some constraints there, but designates the specific choice to be implementation-defined (C99 6.7.2.2/4). That's a bit hopeful because it requires implementations to in fact document their choice, and <a href="https://msdn.microsoft.com/en-us/library/17z041d4%28v=vs.100%29.aspx" rel="nofollow">the VS 2010 docs do so</a> if you drill down far enough. Unfortunately for you, the docs say that a variable of <code>enum</code> type is an <code>int</code>. If the docs are to be believed, then, the size of <code>enum</code> variables is not adjustable in VS 2010.</p> |
26,658,912 | 0 | <p>Then it is as simple as:</p> <pre><code>$data=getAllData(); $counted = count($data); $i = 1; foreach($data as $row) { . .Processing $i of $counted records . $i++; } </code></pre> <p>And! I strongly recommend you to use PDO. Find documentation <a href="http://php.net/manual/ro/book.pdo.php" rel="nofollow">HERE</a></p> <p>Hope this helps! :D</p> |
26,217,970 | 0 | WPF not releasing memory on certain computers <p>On certain computers I have a WPF application that doesn't release memory when working with it. For instance when sending a document to the printer, on most computers it's releasing memory all the 2-3 seconds (it's going up for maybe 200 megs then coming back down), which is normal behaviour and when the printing is done I go back to my initial memory state.</p> <p>But on some computers (over 20 computers installed and only one is giving me this issue) it's not freeing the memory. It keeps piling up. I don't mind seeing memory going to 1.5 Gb as long as it's releasing it in the end, but it's not and I get an OutOfMemoryException.</p> <p>I don't have full access to the problematic computer (they're a client's computer we installed a week ago and we just saw this problem) so I can't really test it but it's a standard Windows 7 Pro x64, with 10Gb of RAM and aside from that, it's working like a charm.</p> <p>Also it's not ONLY when printing. The application is kind of a PDF viewer and everytime a new page is loaded for the user, the previous page is freed from memory. Again, it's working fine on most PC, but not in these case.</p> <p>Is there anything that could prevent the memory from being released? I can't seem to find a similar problem anywhere on the web.</p> <p>EDIT: Okay I got a hold of the computer for an hour. I was able to test two things :</p> <ol> <li>GC.Collect() didn't arrange anything (I even forced it with GC.WaitForPendingFinalizer)</li> <li>I tried disposing of the DocumentPage in my Paginator, no luck. I also kept a reference of a ViewModel I was using to display my page on printing, I tried disposing it : didn't work.</li> </ol> <p>What I can say is that in both cases it must be because of the images displayed in my pages. Here's the function I call to get a new page image :</p> <pre><code>'First I get the path to the images Dim path As String = String.Format("{0}\{1}.png", Me.TemporaryFolderPath, page.PageId) Dim imgSource As CachedBitmap 'If the file doesn't exist If Not IO.File.Exists(path) Then 'A function is called which creates the png file for next uses (this way the first loading is slow, but the next times it's faster) imgSource = Pdf.GetPageImage(page.PageNumber, path) Else 'If the file exists I instantiate a new BitmapImage Dim img As New BitmapImage 'And I load it in a stream Using stream As IO.FileStream = IO.File.OpenRead(path) 'I apply the stream to my image img.BeginInit() img.CacheOption = BitmapCacheOption.OnLoad img.StreamSource = stream img.EndInit() 'Flush, close, dispose of my stream stream.Flush() stream.Close() End Using 'And I create a CachedBitmap with this image (which is almost like an ImageSource) imgSource = New CachedBitmap(img, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad) img = Nothing End If 'If my ImageSource is something, I freeze it so that the memory is freed afterwards If imgSource IsNot Nothing Then imgSource.Freeze() Return imgSource </code></pre> <p>All this (freezing the image, setting the cacheOption to OnLoad, loading from a stream) I did to avoid memory leaks. My first attempt to load an image has a huge leak and I refactored my function so that I didn't have this problem anymore. </p> <p>Is there anything there that could be the problem?</p> |
19,868,286 | 0 | <p><code>awk</code> acts like a filter by default. In your case, it's simply blocking on input. Unblock it by explicitly not having input, for example.</p> <pre><code>awk '...' </dev/null </code></pre> |
7,736,240 | 0 | <p>I can't see why you don't want to use BootCompleted, could you provide your reasons?</p> <p>There is no other action that will alert your broadcast receiver of the boot. You will have to use BootCompleted.</p> <p>As a note, I hope you are registering you BroadcastReceiver with the context (since you didn't include that code). If you're not using BootComplete, I don't know what action you've registered to expect your above code to execute.</p> |
8,744,821 | 0 | Send php variable into javascript <pre><code><input type="button" name="Next" id="Next" value="Next" onclick="showNextQuest(<?php echo $_POST ['$qtnid']; ?>)" /> </code></pre> <p>$qtnid is the name of a radio button, i used the post method to know which one among the radio buttons is selected. The radio button has the same name with different values.It return an undefined error when itried to use alert function inside the showNextQuest function in the javascript. plz help me out.</p> |
16,234,919 | 0 | <p>When no charset is defined in the content-type header of your HTTP request, resteasy assumes 'charset=US-ASCII'. See org.jboss.resteasy.plugins.providers.multipart.InputPart:</p> <pre><code>/** * If there is a content-type header without a charset parameter, charset=US-ASCII * is assumed. * <p> * This can be overwritten by setting a different String value in * {@link org.jboss.resteasy.spi.HttpRequest#setAttribute(String, Object)} * with this ("resteasy.provider.multipart.inputpart.defaultCharset") * String`enter code here` as key. It should be done in a * {@link org.jboss.resteasy.spi.interception.PreProcessInterceptor}. * </p> */ </code></pre> <p>So, as a work-around you can do the following:</p> <pre><code> @Provider @ServerInterceptor public class CharsetPreProcessInterceptor implements PreProcessInterceptor { @Override public ServerResponse preProcess(HttpRequest request, ResourceMethod method) throws Failure, WebApplicationException { request.setAttribute(InputPart.DEFAULT_CHARSET_PROPERTY, "charset=UTF-8"); return null; } } </code></pre> |
28,973,645 | 0 | How do the parameters in ruby '.each do' for-loops work? <p>What's confusing me in the code below is how the parameters <code>state</code> and <code>abbrev</code> match up with the keys and and the values of the hash? Or in other words, how is <code>state</code> matched up with <code>'oregon'</code> and <code>abbrev</code> with <code>'OR'</code> (if the parameters matched words in the hash, then I could understand that)</p> <p>Are they matched up correctly because the first parameter is paired with the first value in the code block?</p> <pre><code>states = { 'Oregon' => 'OR', 'Florida' => 'FL', 'California' => 'CA', 'New York' => 'NY', 'Michigan' => 'MI' } states.each do |state, abbrev| puts "#{state} is abbreviated #{abbrev}" end </code></pre> <p>The output of this code:</p> <pre><code>Oregon is abbreviated OR Florida is abbreviated FL California is abbreviated CA New York is abbreviated NY Michigan is abbreviated MI </code></pre> <p>Sorry for not being able to put my question across clearly, still new to this :S</p> <p>Thanks!</p> |
14,423,464 | 0 | <p>When you use the initializer list you can omit the (), when using a parameterless constructor. It does not matter with the new Cat() is inside the list or not.</p> |
23,852,942 | 0 | MySQL - Clarifying about Remote Access Security <p>I have installed a mysql instance on a linux machine. I am concerned over potential security issues. Some tables should not be changed by users and some tables should. At present, the following comes up when I write:</p> <pre><code>SELECT host FROM mysql.user WHERE User = 'root'; +--------------------+ | host | +--------------------+ | % | | 127.0.0.1 | | ::1 | | localhost | | 'myname' | +--------------------+ </code></pre> <p>Is the presence of the '%' something to be concerned about? How would I go about setting up the DB so that the data integrity is not compromised? </p> |
38,888,252 | 0 | <p>Add changeHash: true from where you are redirecting. And then use 'history.back()' or 'history.go(-1)' from your current page. It will only take you 1 page back.</p> <pre><code>$.mobile.changePage("yourpage.html",{ transition: "flip", changeHash: true}); </code></pre> |
5,861,834 | 0 | Chrome browser extensions - hooking into C functions? <p>I'm writing a Chrome extension and some parts of it need to be super high performance. I'm trying to find documentation to see if it's possible to use C extensions within the Chrome extension. Is this currently possible?</p> |
17,268,288 | 0 | What to do when change in one UITableViewCell affect how other cell works? <p>Say I choose to follow or bookmark a catalog. All catalogs that share the same parent will be bookmarked too.</p> <p>After a call to <code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath</code> things will sort of fixed.</p> <p>The thing is <code>cellForRowAtIndexPath</code> is not called until the visible cells become unvisible and then visible again.</p> <p>How do I make visible Cells to refresh again?</p> |
2,248,224 | 0 | <p>If you want to get the name/id from a selection</p> <pre><code>$().attr('name') $().attr('id') </code></pre> <p>or for selecting element(s)</p> <pre><code>$('*[name="somename"]') $('#someid') </code></pre> |
13,100,760 | 0 | <p>As i remember a limitation for request to google maps api is 250 per day for one application. I also remeber that google can stop responce when you send to many request for some part of time. Tell what string did you get from google maps api with this 26th point?</p> |
6,781,871 | 0 | <p>You could try an imaging library like ImageFX, or for an open-source one, try <a href="http://graphics32.org/wiki/" rel="nofollow">Graphics32</a>, or the <a href="http://imaginglib.sourceforge.net/index.php?page=down" rel="nofollow">VampyreImagingLIbrary</a>, according to its Docs <a href="http://galfar.vevb.net/imaging/doc/imaging.html" rel="nofollow">here</a> it supports some operations like drawing lines and rectangles over an image loaded into a buffer. I would expect scanner (image processing) libraries to support grey-scale images better than non-imaging libraries, but I don't expect scanner image processing libraries to be in-memory based. </p> <p>But if you wanted to do the work directly in a visible buffer (You mention TCanvas), and you you are willing to limit yourself to Delphi XE, and Windows 7 only, you could use a Direct2D context, which supports 16 and 32 bit depths but as a 32 bit color depth is still only going to be 8 bit depth with respect to a grayscale image, I think that all normal non-greyscale graphics libraries are going to lose some information on you.</p> <p>If you didn't mind using something a bit old, and a bit tied to Microsoft Windows, you could investigate using DirectDraw style (now merged into <a href="http://msdn.microsoft.com/en-us/directx/aa937781" rel="nofollow">DirectX</a>) both to do the Buffer management (hold the 16 bit data) and letting you draw onto it, as well. I am not aware of it having any special support for 16 bit grayscale images though.</p> <p>Interestingly, <a href="http://stackoverflow.com/questions/1105066/wpf-image-and-directx-surfaceformat">WPF</a> has support for 16 bit grayscale natively. If you could find out how they do it, you could ape the technique in Delphi. That link also discusses using OpenGL to do 16 bit luminance, but there's no suggestion from the question that OpenGL allows that. I have found people trying to use <a href="https://forums.codegear.com/message.jspa?messageID=226578" rel="nofollow">OpenGL</a> for medical applications written in delphi (16 bit grayscale) image display, but no reference to modifying the image in memory.</p> |
31,106,674 | 0 | <p><code>ViewPatterns</code> is probably the way to go here. Your code doesn't work because you need to call <code>viewl</code> or <code>viewr</code> on your <code>Seq</code> first to get something of type <code>ViewL</code> or <code>ViewR</code>. <code>ViewPatterns</code> can handle that pretty nicely:</p> <pre><code>{-# LANGUAGE ViewPatterns #-} foo (S.viewl -> S.EmptyL) = ... -- empty on left foo (S.viewl -> (x S.:< xs)) = ... -- not empty on left </code></pre> <p>Which is equivalent to something like:</p> <pre><code>foo seq = case S.viewl seq of S.EmptyL -> ... (x S.:< xs) -> ... </code></pre> |
25,744,161 | 0 | Can we change in method signature which will work for previous signature in Axis2 <p>I have a webservice with signature public String <code>m1(String s1, String s2)</code> and I wanted to update this signature to public String <code>m1(String s1, String s2, Object... args)</code>. Will it work for client calling <code>m1(String s1, String s2)</code>? Will it be a backword compatible? </p> <p>I tried calling but it is throwing an exception as:</p> <pre><code>Exception in thread "main" java.lang.AbstractMethodError: SampleService.m1(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String; at TestWsClient.main(TestWsClient.java:24) </code></pre> |
13,955,869 | 0 | put some text on jvectormap <p>I'm using the jvectormap plugin and I would like to know if there is a way to put some text directly on the map, like the country's names for example ?</p> <p>thanks !</p> |
40,307,086 | 0 | <p>The gradient you see comes from safari default style. </p> <p>You can remove it with <code>-webkit-appearance:none;</code></p> <hr> <p>Read more about <strong>-webkit-appearance</strong> <strong><a href="http://trentwalton.com/2010/07/14/css-webkit-appearance/" rel="nofollow">here</a></strong></p> |
2,385,186 | 0 | Check if Internet Connection Exists with Ruby? <p>Just asked how to <a href="http://stackoverflow.com/questions/2384167/check-if-internet-connection-exists-with-javascript">check if an internet connection exists using javascript</a> and got some great answers. What's the easiest way to do this in Ruby? In trying to make generated html markup code as clean as possible, I'd like to conditionally render the script tag for javascript files depending on whether or not an internet condition. Something like (this is HAML):</p> <pre><code>- if internet_connection? %script{:src => "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", :type => "text/javascript"} - else %script{:src => "/shared/javascripts/jquery/jquery.js", :type => "text/javascript"} </code></pre> |
20,460,001 | 0 | For loop is not executed <p>Why isn't this loop executed? At runtime woord.length() is equal to 5.</p> <pre><code>for (int j = woord.length(); j <= 0; j--) { //do some magic things here } </code></pre> |
35,314,166 | 0 | <p>Try the following:</p> <pre><code>SELECT ECDSlides.[Supplier Code], ECDSlides.[Supplier Name], ECDSlides.Commodity FROM ECDSlides LEFT JOIN (ECDSlides.Commodity = [Mit Task Details2].Commodity) AND (ECDSlides.[Supplier Code] = [Mit Task Details2].[Supplier Code]) WHERE [Mit Task Details2].Commodity Is Null; </code></pre> |
8,020,748 | 0 | IndicatingAjaxButton works only once <p>I have derived a class from IndicatingAjaxButton (which is the button to a form). But the IAjaxIndicatorAware does only work once, i.e. if the validation of the form fails I print feedback messages within the form. During the 1st request the "onProgress-Circle" is shown. But if I click on the button again (after I made the right input on the form), there is no "onProgress-Circle" anymore. </p> <p>I took a look in the generated HTML: 1) Before the first click, there is a img tag, which gets displayed when the request is started 2) After the first request is processed, this img tag is removed. </p> <p>This are the evaluation steps that are returned from the server:</p> <pre><code><evaluate><![CDATA[var e = Wicket.$('previouse--ajax-indicator'); if (e != null && typeof(e.parentNode) != 'undefined') e.parentNode.removeChild(e);]]></evaluate> </code></pre> <p>This I guess leads to removing all childs from the button, also the img tag. Is this a bug or do I use the button in a wrong way?</p> <p>I use Wicket 1.5</p> <p>Thanks and kind regards, Soccertrash</p> |
12,756,187 | 0 | <p>You are overflowing the max value that can be stored in an int which is 2,147,483,647.</p> <p>When calculating the numerator in your equation you are doing ((39258-0)*(99999-0)) which is 3,925,760,742. </p> <p>If you change it to this you won't have this issue:</p> <pre><code>long numerator = (long)(toFind - sortedArray[low]) * (long)(high - low); mid = low + numerator / (sortedArray[high] - sortedArray[low]); </code></pre> <p>I think you also need to change your while loop to be:</p> <pre><code>while (sortedArray[low] < toFind && sortedArray[high] >= toFind) { </code></pre> <p>Otherwise you have a situation where sortedArray[low] == sortedArray[high] == toFind</p> <p>Then your equation reduces to</p> <pre><code>mid = low + (0 * (high - low)) / 0 = 0/0 </code></pre> <p>Java allows division by zero. I'm not exactly sure what happens though, it may be that in this case mid = infinity or NaN.</p> |
38,742,645 | 0 | <pre><code>$http.post( authUrl+'/things', $.param(requestData), { headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' } } ) .success(function(data, status){ deffered.resolve(data, status); }).error(function(data,status){ }); </code></pre> <p>Refer this.</p> |
36,823,661 | 0 | make input file variable <p>I will like to get this script process csv files <code>"$inputFilename = 'westmike1.csv';"</code> with different names, when a import link to the file is click. At the moment I can go beyond process one file, and for me to use this script at that it will make me duplicate them. </p> <p>Please I need an advice on this thanks.</p> <pre><code>error_reporting(E_ALL | E_STRICT); ini_set('display_errors', true); ini_set('auto_detect_line_endings', true); $inputFilename = 'westmike1.csv'; $outputFilename = 'westmike1.xml'; // Open csv to read $inputFile = fopen($inputFilename, 'rt'); // Get the headers of the file $headers = fgetcsv($inputFile); // Create a new dom document with pretty formatting $doc = new DomDocument(); $doc->formatOutput = true; // Add a root node to the document $root = $doc->createElement('rows'); $root = $doc->appendChild($root); // Loop through each row creating a <row> node with the correct data while (($row = fgetcsv($inputFile)) !== FALSE) { $container = $doc->createElement('row'); foreach ($headers as $i => $header) { $child = $doc->createElement($header); $child = $container->appendChild($child); $value = $doc->createTextNode($row[$i]); $value = $child->appendChild($value); } $root->appendChild($container); } $strxml = $doc->saveXML(); $handle = fopen($outputFilename, "w"); fwrite($handle, $strxml); fclose($handle); $xml = simplexml_load_file('westmike1.xml') or die("ERROR: Cannot create SimpleXML object"); // open MySQL connection $connection = mysqli_connect("localhost", "mikeshop", "sho****", "mike_shop") or die ("ERROR: Cannot connect"); // process node data // create and execute INSERT queries </code></pre> |
20,094,711 | 0 | <p>We can use sub-menu model. So, we don't need to write method for showing popup menu, it will be showing automacally. Have a look:</p> <p>menu.xml</p> <pre><code><menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/action_more" android:icon="@android:drawable/ic_menu_more" android:orderInCategory="1" android:showAsAction="always" android:title="More"> <menu> <item android:id="@+id/action_one" android:icon="@android:drawable/ic_popup_sync" android:title="Sync"/> <item android:id="@+id/action_two" android:icon="@android:drawable/ic_dialog_info" android:title="About"/> </menu> </item> </menu> </code></pre> <p>in MainActivity.java</p> <pre><code>@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } </code></pre> <p>The result is:</p> <p><a href="https://i.stack.imgur.com/xD9Cj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xD9Cj.png" alt="Result"></a></p> |
10,946,503 | 0 | <p>I didn't realise this, and now I feel quite stupid. However, maybe someone who is just starting out will be able to save themselves a few minutes of head-bashing by this answer.</p> <p>It turns out that changes to the database.yml file are only applied once the apache service is restarted/reloaded. Everything is working fine now.</p> |
27,536,812 | 0 | const-correctness in void methods and lambda 'trick' <p>I have a method that accepts a reference of an object as const, this method doesn't change anything of the method and the const indicates that, the thing is that this method also calls other method that is within the class and is void, doesn't accept any argument and is also virtual, meaning that the class that extends the base class can override the method BUT it needs to be const as well. Eg:</p> <pre><code>#include <iostream> class Boz { public: virtual void introduce() const = 0; }; class Foo { public: virtual void callable() const { // ... } void caller(const Boz& object) const { callable(); object.introduce(); } }; class Bar : public Boz { public: void introduce() const { std::cout << "Hi." << std::endl; } }; class Biz : public Foo { public: void callable() const { std::cout << "I'm being called before the introduce." << std::endl; } }; int main(void) { Biz biz; biz.caller(Bar()); return 0; } </code></pre> <p>The output would be:</p> <pre><code>I'm being called before the introduce. Hi. </code></pre> <p>As you can see <code>callable</code> must to be const in order to be called. If I change and do this:</p> <pre><code>class Biz : public Foo { public: void callable() { std::cout << "I'm being called before the introduce." << std::endl; } }; </code></pre> <p>It will compile not errors are thrown but the callable method won't be called, but the virtual one as it's defined as const. It's quite obvious.</p> <p>The trickiest part here:</p> <pre><code>class Foo { public: virtual void callable() { // ... } void caller(const Boz& object) const { auto trick = [&] () { callable(); }; trick(); object.introduce(); } }; class Biz : public Foo { public: void callable() { std::cout << "I'm being called before the introduce." << std::endl; } }; </code></pre> <p>It works and the <code>callable</code> method is called. No errors like <code>passing 'const ...' as 'this' argument</code>.</p> <p>What I'm trying to do is to call <code>callable</code> without the need of being const and the reason is simple: The method doesn't change anything, he don't have access to the object that is begin passed as argument on <code>caller</code> method then we assume that he doesn't have the need to be <code>const</code> but the compiler throws an error even that way. The real problem is that <code>callable</code> is virtual and classes can extend the base class, implement their own <code>callable</code> and try to call other methods but can't if it's not <code>const</code> as well.</p> <p>What I want is pretty much that, is to know how can I call the virtual method without the need of being const (the reason is pretty much that, I'm kind forcing the users that extends the class and override the <code>callable</code> method to only call <code>const</code> methods and this is not what I want) and of course understand what happens with the lambda and why it works.</p> |
20,598,227 | 0 | Class Method NullPointerException <p>I have an</p> <pre><code>public abstract class Entity { public Entity() {} public void update() { this.x = 0; this.y = 0; } } </code></pre> <p>then I have a </p> <pre><code>public class Player Extends Entity { /* Class Definition */ } </code></pre> <p>when i call player.update</p> <p>I get a NullPointerException:</p> <pre><code>Exception in thread "main" java.lang.NullPointerException at MainFrame.Gui.<init>(Gui.java:29) at Start.main(Start.java:13) </code></pre> |
22,985,582 | 0 | Handling null XElements whilst parsing an XDocument <p>Is there a better way of doing something like this:</p> <pre><code>private XElement GetSafeElem(XElement elem, string key) { XElement safeElem = elem.Element(key); return safeElem ?? new XElement(key); } private string GetAttributeValue(XAttribute attrib) { return attrib == null ? "N/A" : attrib.Value; } var elem = GetSafeElem(elem, "hdhdhddh"); string foo = GetAttributeValue(e.Attribute("fkfkf")); //attribute now has a fallback value </code></pre> <p>When parsing elements/attribute values from an XML document? In some cases the element may not be found when doing something like:</p> <pre><code>string foo (string)elem.Element("fooelement").Attribute("fooattribute").Value </code></pre> <p>So an object reference error would occur (assuming the element/attribute aren't found). Same when trying to access the element value</p> |
16,866,755 | 0 | <p>There's no need for another method: if your helper extends <code>Zend_View_Helper_Abstract</code> (and it probably does), you can just use its <code>$view</code> property...</p> <pre><code>$this->view->escape(...) </code></pre> <p>Otherwise you may implement your own <code>setView</code> method (as described <a href="http://framework.zend.com/manual/1.12/en/zend.view.helpers.html#zend.view.helpers.custom" rel="nofollow">here</a>), which will be called when the helper is instantiated. It usually operates on the same-named property.</p> |
35,234,405 | 0 | <p>The solution was to modify the byte code in SWF files using FFDec, and remove the failing part from the main MovieClip's constructor.</p> |
1,663,044 | 0 | <p>Since I wrote the MSDN article you are referring to, I guess I have to answer this one.</p> <p>First, I anticipated this question and that's why I wrote a blog post that shows a more or less real use case for ExpandoObject: <a href="http://blogs.msdn.com/csharpfaq/archive/2009/10/01/dynamic-in-c-4-0-introducing-the-expandoobject.aspx" rel="nofollow noreferrer">Dynamic in C# 4.0: Introducing the ExpandoObject</a>. </p> <p>Shortly, ExpandoObject can help you create complex hierarchical objects. For example, imagine that you have a dictionary within a dictionary:</p> <pre><code>Dictionary<String, object> dict = new Dictionary<string, object>(); Dictionary<String, object> address = new Dictionary<string,object>(); dict["Address"] = address; address["State"] = "WA"; Console.WriteLine(((Dictionary<string,object>)dict["Address"])["State"]); </code></pre> <p>The deeper is the hierarchy, the uglier is the code. With ExpandoObject it stays elegant and readable.</p> <pre><code>dynamic expando = new ExpandoObject(); expando.Address = new ExpandoObject(); expando.Address.State = "WA"; Console.WriteLine(expando.Address.State); </code></pre> <p>Second, as it was already pointed out, ExpandoObject implements INotifyPropertyChanged interface which gives you more control over properties than a dictionary.</p> <p>Finally, you can add events to ExpandoObject like here:</p> <pre><code>class Program { static void Main(string[] args) { dynamic d = new ExpandoObject(); // Initialize the event to null (meaning no handlers) d.MyEvent = null; // Add some handlers d.MyEvent += new EventHandler(OnMyEvent); d.MyEvent += new EventHandler(OnMyEvent2); // Fire the event EventHandler e = d.MyEvent; if (e != null) { e(d, new EventArgs()); } // We could also fire it with... // d.MyEvent(d, new EventArgs()); // ...if we knew for sure that the event is non-null. } static void OnMyEvent(object sender, EventArgs e) { Console.WriteLine("OnMyEvent fired by: {0}", sender); } static void OnMyEvent2(object sender, EventArgs e) { Console.WriteLine("OnMyEvent2 fired by: {0}", sender); } } </code></pre> |
14,804,219 | 0 | web.config prevents file downloadable or viewable <p>I am very new to ASP.net. I visited a website long time ago which I cannot remember the URL now. I wanted to open their CSS file to see the source, but once I clicked the error message says, "you don't have premission to act ........."</p> <p>Now I want to do the same thing to lock up my files. Even visitors could see the file name, but they are unable to open or download it.</p> <p>I wonder if it is possible to achieve on ASP.net or IIS7?</p> <p>Many thanks for suggestions.</p> |
12,456,563 | 0 | Disable audio recording notification while application is in background on iOS SDK 4.2+ <p>In my project, where we use <a href="http://www.pjsip.org/" rel="nofollow">pjsip2</a> to receive streaming audio from a shared server.</p> <p>The app is meant to only receive streaming audio, not record. However even though we have disabled the mic in out code we still get a notification of the app recording while it is in the background (top bar flashing red with text: " (recording)").</p> <p>How can I disable the recording notification while our app is running in the background?</p> |
5,771,554 | 0 | <p>The <code>-1</code> is because integers start at 0, but our counting starts at 1.</p> <p>So, <code>2^32-1</code> is the <em>maximum value</em> for a 32-bit unsigned integer (32 binary digits). <code>2^32</code> is the <em>number of possible values</em>.</p> <p>To simplify why, look at decimal. <code>10^2-1</code> is the maximum value of a 2-digit decimal number (99). Because our intuitive human counting starts at 1, but integers are 0-based, <code>10^2</code> is the number of values (100).</p> |
4,576,192 | 0 | <p>I don't see the problem immediately. A couple of things to consider:</p> <ul> <li>Add a constructor to B that calls super()</li> <li>You are adding the event listener to A, so A must be on the stage before the ENTER_FRAME event will occur</li> <li>You probably want to first use graphics.clear(), and then end with graphics.endFill()</li> </ul> |
19,881,519 | 0 | <p>You can do next create new div with class wich will hold just part of menu which you want to select . For example </p> <pre><code> <div class="menu"> <div class="select"> <ul> <li>Home</li> <li>Home1</li> <li>Home2</li> </ul> </div> <div id="user-data"> ..... </div> </div> </code></pre> <p>Then your jquery will look like </p> <pre><code>$('.select ul li').click(function(){ .... // body )}; </code></pre> |
40,297,651 | 0 | <p>Try storing it as bytes:</p> <pre><code>UUID uuid = UUID.randomUUID(); byte[] uuidBytes = new byte[16]; ByteBuffer.wrap(uuidBytes) .order(ByteOrder.BIG_ENDIAN) .putLong(uuid.getMostSignificantBits()) .putLong(uuid.getLeastSignificantBits()); con.createQuery("INSERT INTO TestTable(ID, Name) VALUES(:id, :name)") .addParameter("id", uuidBytes) .addParameter("name", "test1").executeUpdate(); </code></pre> <p>A bit of an explanation: your table is using BINARY(16), so serializing UUID as its raw bytes is a really straightforward approach. UUIDs are essentially 128-bit ints with a few reserved bits, so this code writes it out as a big-endian 128-bit int. The ByteBuffer is just an easy way to turn two longs into a byte array.</p> <p>Now in practice, all the conversion effort and headaches won't be worth the 20 bytes you save per row.</p> |
432,280 | 0 | <p>I am a non-reading composer who has just "stuck with it" for so long that I've got a good handle on it now. I compose with the computer pretty much.</p> <p>You could get a simple midi sequencer, or a really nice one like the one in Propellorhead Reason (great composing tool), experiment on your own, or download free midi files of Bach and other classical composers, then you can see where the notes are on the keyboard in the midi sequencer. Plus, you can move them around to see what happens.</p> <p>A really good website for learning about voice leading and chord changes (progressions), is </p> <p><a href="http://www.musicnovatory.com/" rel="nofollow noreferrer">http://www.musicnovatory.com/</a></p> <p>It is not a very intuitive site to navigate. But, much can be learned their to help with making good sounding changes via voice leading and chord selection. Be patient and be very curious, that is, poke around a lot on the site, & you'll find gems.</p> <p>Once you have some of that under your belt, get a decent book on counterpoint, and you'll be flyin' before you know it.</p> |
36,559,781 | 0 | <p>Had the exact same "issue". In my case it had to do with the Windows 10 enlarged font and item size. </p> <p>Firefox takes this into account en shows everything 1.25 times enlarged when set to 125%. While chrome does not. </p> <p>So 14px in Firefox becomes: 17.5px on the monitor and in chrome it stays at 14px.</p> |
39,827,465 | 0 | <p>The problem here is that <code>plot</code> needs a function that returns one value and not a vector.</p> <p>One workaround would be to loop over your <code>b</code> and <code>w</code> values one by one and redefine your <code>k</code> function as you go. I've also changed your <code>k</code> function as it wasn't defined for the default parameters.</p> <pre><code>k <- function(b, w) { function(x){b*x+w} } plot2 <- function(k, b, w) { plot(k(b[1], w[1])) for (i in 2:length(b)) { foo <- k(b[i], w[i]) curve(foo, add = TRUE) } } plot2(k, b, w) </code></pre> |
30,017,375 | 0 | rails routing not going to controller as expected <p>I would like to get reviews for a specific user. I'm trying to hit </p> <pre><code>var reviews_url = '/users/' + profile_id + '/reviews.json'; </code></pre> <p>but it's not hitting <code>reviews#index</code> as seen in the logs</p> <pre><code>Started GET "/users/23/reviews.json" for ::1 at 2015-05-03 10:50:01 -0700 Processing by ApplicationController#index as JSON </code></pre> <p>What can I change to make this route hit <code>reviews#index</code>?</p> <p><code>routes.rb</code></p> <pre><code>resources :users do resources :reviews end </code></pre> <p><code>rake routes</code></p> <pre><code>GET /users/:user_id/reviews(.:format) reviews#index </code></pre> <p>EDIT TO ADD ROUTES</p> <pre><code>get 'auth/:provider/callback', to: 'sessions#create' root 'application#index' get '*path' => 'application#index' resources :users do resources :reviews resources :friendships end </code></pre> <p>Note: when I move <code>resources</code> above <code>get '*path' => 'application#index'</code> it works as expected. However I would like to have each call go through <code>application#index</code> (the app is a SPA that knows the current user based on the user in <code>application#index</code>). Maybe I should namespace these routes into <code>api</code>? </p> |
5,990,048 | 0 | <p>What you say doesn't seem to match with the c3p0 docs. Namely it seems there is only a subset of c3p0 parameters that can be accessed through hibernate.cfg.xml. Everything else must be set through a separate c3p0.properties file. See <a href="http://www.mchange.com/projects/c3p0/index.html#hibernate-specific" rel="nofollow">http://www.mchange.com/projects/c3p0/index.html#hibernate-specific</a></p> <p><strong>Edit: It seems the c3p0 docs are completely wrong.</strong> If you do as they say (e.g. include an additional c3p0.properties file) it will be ignored. However, if you simply add the properties to the hibernate config file in the same fashion, it works fine. E.g. adding the following to hibernate.cfg.xml worked, where the prescribed method did not:</p> <pre><code><property name="hibernate.c3p0.acquireRetryAttempts">100</property> <property name="hibernate.c3p0.debugUnreturnedConnectionStackTraces">true</property> <property name="hibernate.c3p0.unreturnedConnectionTimeout">120</property> <property name="hibernate.c3p0.checkoutTimeout">30000</property> </code></pre> <p>There's 2 hours of my life i won't get back. :-(</p> |
18,611,301 | 0 | <p>Have you tried delaying the transition in css? Works for me</p> |
137,060 | 0 | Too many "pattern suffixes" - design smell? <p>I just found myself creating a class called "InstructionBuilderFactoryMapFactory". That's 4 "pattern suffixes" on one class. It immediately reminded me of this:</p> <p><a href="http://www.jroller.com/landers/entry/the_design_pattern_facade_pattern" rel="nofollow noreferrer">http://www.jroller.com/landers/entry/the_design_pattern_facade_pattern</a></p> <p>Is this a design smell? Should I impose a limit on this number? </p> <p>I know some programmers have similar rules for other things (e.g. no more than N levels of pointer indirection in C.)</p> <p>All the classes seem necessary to me. I have a (fixed) map from strings to factories - something I do all the time. The list is getting long and I want to move it out of the constructor of the class that uses the builders (that are created by the factories that are obtained from the map...) And as usual I'm avoiding Singletons.</p> |
20,840,817 | 0 | <pre><code>[super viewDidLoad]; // Do any additional setup after loading the view. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setImage:[UIImage imageNamed:@"aButton"] forState:UIControlStateNormal]; [button setImage:[UIImage imageNamed:@"aButton"] forState:UIControlStateHighlighted]; [button setFrame:CGRectMake(100, 100, 300, 100)]; [self.view addSubview:button]; </code></pre> <p>And do not forget the extention "aButton.png" "aButton.jpg"... </p> |
11,839,013 | 0 | <p>typedef is not a global variable, it's simply an alias for another type. I usually use them for function pointers when I'm passing those around because writing them out every time is annoying. </p> <p><code>typedef int (*function)(int, int);</code></p> <p>I also use them to define a structure, union, or enumeration as a type</p> <pre><code>typedef struct { int x; int y; int z; } Point; </code></pre> |
20,005,336 | 0 | <p>I found the problem. I did a migration and primary keys were changed because of this field photo = models.OneToOneField(Photo,primary_key=True,blank=True). The <code>primary_key=True</code> was messing with the professeur.id </p> |
7,352,080 | 0 | php how to loop through a multi dimensional array <p>I am trying to create a dynamic navigation list that has a sublist for each of the items in the list</p> <p>I have 1 array that contains 12 parent category values and is a straightforward 1 dimensional array. </p> <p>I am looping through that with a foreach loop to make an unordered list</p> <p>The problem I am having is that I have an array of subcategories that is a multidimensional array and I need to create a nested list for each of the subcategories that belong to the parent category. </p> <pre><code><?php //mysql query to get the parent categories $query = "SELECT `parent` FROM `categories` GROUP BY `parent`"; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { $cat[] = $row['parent']; //define the parent categories as a variable }?> <div id="navigation"> <ul> <li><a href="http://localhost/softwarereviews.com">Home</a></li> <?php //loop through the parent categories foreach ($cat as $parent) { //another query to get the child categories that belong to each parent category $query = "SELECT * FROM `categories` WHERE `parent` = '$parent'"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { //need 2 results so create a multi - dimensional array $children[] = array($row['name'] => $row['cat_label']); }?> <li><?php echo $parent; ?></li> <ul> <?php foreach ($children as $key => $value) { ?> <?php foreach ($value as $key => $value) { ?> <li><a href="<?php echo $value;?>"><?php echo $key;?></a><li> <?php } }?> </ul> <?php }?> </ul> </div> </code></pre> <p>What happens at the moment is that the sub list of each category keeps appending the previous lists results, making the each sub list results bigger and bigger.</p> |
15,560,334 | 0 | <p>ah vb6 :) it's been a long time....</p> <p>basically, you can't debug .NET code within VB6 IDE.</p> <p>However, nothing stops you from creating a .NET test project to unit test the .NET dll. <em>And that's what you should have done prior to reference it in VB6.</em></p> <p>If you need to track down a specific issue, another way you can use is to write debugging infos to a file/database/event view/... when the dll is in debug mode, like which functions were called, parameters, stack trace... </p> |
10,059,675 | 0 | <p>Just for debugging purposes, try setting the <code>backgroundColor</code> of <code>aLabel</code> and <code>aReflectionView</code> to see where they're being placed.</p> <pre><code>aLabel.backgroundColor = [UIColor redColor]; aReflectionView.backgroundColor = [UIColor blueColor]; </code></pre> <p>You should see that the <code>aReflectionView</code> is properly centered within its superview, but the <code>aLabel</code>, contained within it, is not. Why not? Because of this line:</p> <pre><code>UILabel *aLabel = [[UILabel alloc]initWithFrame:CGRectMake(((self.view.bounds.size.width / 2) - 150), 0, 300, 90)]; </code></pre> <p>Since <code>aLabel</code> is contained within <code>aReflectionView</code>, it should be centered within the <code>aReflectionView</code> bounds, not the bounds of <code>self.view</code>. Scroll right to see the change:</p> <pre><code>UILabel *aLabel = [[UILabel alloc]initWithFrame:CGRectMake(((aReflectionView.bounds.size.width / 2) - 150), 0, 300, 90)]; </code></pre> <p>For your purposes, it may be better to make <code>aLabel</code> simply fill <code>aReflectionView</code>:</p> <pre><code>UILabel *aLabel = [[UILabel alloc]initWithFrame:aReflectionView.bounds]; </code></pre> |
32,213,813 | 0 | <p>It happened to me and I uninstalled python and all the packages. After that, it worked with magic.</p> |
24,253,126 | 0 | <p>Your configuration is mostly correct. The problem you face is that you use autowiring to inject one of <code>callService</code> dependencies. </p> <p>Seems that you use <code>SqlSessionDaoSupport</code> and its sqlSessionTemplate field is autowired. There are two templates defined so spring cannot automatically wire dependencies. You need specify correct template manually.</p> |
21,619,274 | 0 | <p>You declare your array</p> <pre><code>array[16] so array[0] .. array[15] </code></pre> <p>In the second for loop you have</p> <pre><code>when i = 16 array[16]! </code></pre> <p>valter</p> |
29,161,726 | 0 | <p>you can use given query.</p> <pre><code>CREATE TABLE TABLE_NAME1 ( id BIGINT(20) NOT NULL AUTO_INCREMENT, Ctime DATETIME DEFAULT NULL, KEY id (id) ) ENGINE=INNODB AUTO_INCREMENT=286802795 DEFAULT CHARSET=utf8 PARTITION BY RANGE( TO_DAYS(Ctime) ) ( PARTITION p1 VALUES LESS THAN (TO_DAYS('2011-04-02')), PARTITION p2 VALUES LESS THAN (TO_DAYS('2011-04-03')), PARTITION p3 VALUES LESS THAN (TO_DAYS('2011-04-04')), PARTITION p4 VALUES LESS THAN (TO_DAYS('2011-04-05')), PARTITION p5 VALUES LESS THAN (TO_DAYS('2011-04-06')), PARTITION p6 VALUES LESS THAN (TO_DAYS('2011-04-07')) ); </code></pre> |
9,752,233 | 0 | <p>create your own custom view, and use that. you can animate them in every way you like, using canvas you have given in onDraw() method. </p> <p>this may help: <a href="http://www.apleben.com/2011/01/custom-android-view-the-definition/" rel="nofollow">http://www.apleben.com/2011/01/custom-android-view-the-definition/</a></p> |
35,569,853 | 0 | <p>We could use <code>data.table</code>. Convert the 'data.frame' to 'data.table' (<code>setDT(df1)</code>), create a new grouping variable by using <code>%/%</code> based on the values in 'A'. Then, grouped by 'A1', we get the <code>sum</code> of 'B' and also <code>paste</code> the <code>unique</code> elements in 'A' together. If not needed, the grouping variable 'A1' can be assigned to NULL.</p> <pre><code>library(data.table) setDT(df1)[, A1:= (A-1)%/%2 +1][, list(A= paste0("A",paste(unique(A), collapse="-")), B= sum(B)) ,A1][,A1:= NULL][] # A B #1: A1-2 4 #2: A3-4 9 </code></pre> |
1,827,874 | 0 | what does 'invalid gem format' mean? <p>Does this mean I've hosed my ruby/gem/rails environment somehow? I've been using InstantRails2-0 happily for awhile now, but recently decided to upgrade rails. It has been a major pain so far. First I had issues getting the latest gem version, rubygems-update couldn't get the latest. I was finally able to get the latest gem version by manually downloading it and running setup.rb for rubygems-1.3.5.</p> <p>When I do '<code>gem update rails</code>', I get the following error:</p> <p>invalid gem format forr C:/ruby/lib/ruby/gems/1.8/cache/activesupport-2.3.5.gem</p> <p>I tried manually downloading the activesupport gem and doing 'gem install local [path to gem]'. This appeared to work, so I did the same with rails 2.3.3.gem, but then got the same invalid gem format error, but for activerecord-2.3.3.gem.</p> <p>My gem version is 1.3.5. Current rails version is ....not working anymore because of RubyGem version error: activesupport(2.1.1 not = 2.0.2)</p> |
38,182,509 | 0 | APC cache usage <p>I have to use APC cache just for opcode caching. so is it enough to just enable it from php.ini file with setting variable apc.stat to 'false'? I am already using memcache for object caching. do I need to use APC cache functions like apc_add, apc_fetch etc?</p> |
17,692,629 | 0 | <p>Here is the User class you may need, modify it as per your need:</p> <pre><code>public class User { private int id; private String Name; private String email; private String mobile; private String password; private String role; private String status; private String last_update; public String getName() { return Name; } public void setName(String name) { Name = name; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getMobile() { return mobile; } public void setMobile(String mobile) { this.mobile = mobile; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getRole() { return role; } public void setRole(String role) { this.role = role; } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } public String getLast_update() { return last_update; } public void setLast_update(String last_update) { this.last_update = last_update; } public int getId() { return id; } public void setId(int id) { this.id = id; } @Override public String toString() { return "User [id=" + id + ", Name=" + Name + ", email=" + email + ", mobile=" + mobile + ", password=" + password + ", role=" + role + ", status=" + status + ", last_update=" + last_update + "]"; } } </code></pre> <p>Further in your JDBC code, you will need to create a collection of your User class objects and store the database results in it. Something like this:</p> <pre><code>List<User> usersList = new ArrayList<User>(); while (resultSet.next()) { User user = new User(); user.setId(resultSet.getInt("id")); user.setName(resultSet.getString("name")); user.setEmail(resultSet.getString("email")); user.setMobile(resultSet.getString("mobile")); user.setPassword(resultSet.getString("password")); user.setRole(resultSet.getString("role")); user.setStatus(resultSet.getString("status")); user.setLast_udpate(resultSet.getString("last_update")); // print the results System.out.println(user); usersList.add(user); } </code></pre> |
34,475,728 | 0 | Include Haystack search on all pages <p>Ok I know this question has been asked before, I looked at the answers and (think) I am doing exactly what is supposed to be done, but the search box is only appearing on the 'search' page and not any other page. I have a base.html that I use to extend to all other pages, can anyone help out on this? (FYI, I did try having the form in base.html instead of search.html but that did not work either)</p> <p>Base.html</p> <pre><code>{% load staticfiles %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Search</title> <link href="{% static 'css/bootstrap3.min.css' %}" rel="stylesheet"> <link href="{% static 'css/main.css' %}" rel="stylesheet"> </head> <body> <div class="container"> <header class="clearfix"> {% include 'navbar.html' %} <h3 class="text-muted">My site</h3> </header> <hr> {% block content %}{% endblock %} <hr> <footer> <p class="text-muted">Copyright &copy; 2015</p> </footer> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="{% static 'js/bootstrap.min.js' %}"></script> </body> </html> </code></pre> <p>Search.html</p> <pre><code>{% extends 'base.html' %} {% load staticfiles %} {% load widget_tweaks %} {% block content %} <h2>Search</h2> <form method="get" action="."> <div class="input-group"> {% render_field form.q class+="form-control" type="search" %} <span class="input-group-btn"> <button type="submit" class="btn btn-default">Search</button> </span> </div> {% if query %} <h3>Results</h3> {% for result in page.object_list %} <div class="media"> <div class="media-left"> <img class="media-object" height="100" style="border: 1px solid #ccc;" src="{{ result.object.photo.url }}"> </div> <div class="media-body"> <h4 class="media-heading">Supplier Part Code: <strong>{{ result.object.supplier_code }}</strong></h4> <h4>Mfr Code: <strong>{{ result.object.part.code }}</strong></h4> <p> <strong>Supplier</strong> {{ result.object.supplier.name }} <strong>Price</strong> {{ result.object.price }} <strong>Sale Price</strong> {{ result.object.sale_price }} <strong>Available</strong> {{ result.object.quantity }} <a href="{{ result.object.url }}" target="_blank">Buy Now!</a> </p> </div> </div> {% empty %} <p>No results found.</p> {% endfor %} {% if page.has_previous or page.has_next %} <div> {% if page.has_previous %}<a href="?q={{ query }}&amp;page={{ page.previous_page_number }}">{% endif %}&laquo; Previous{% if page.has_previous %}</a>{% endif %} | {% if page.has_next %}<a href="?q={{ query }}&amp;page={{ page.next_page_number }}">{% endif %}Next &raquo;{% if page.has_next %}</a>{% endif %} </div> {% endif %} {% else %} {# Show some example queries to run, maybe query syntax, something else? #} {% endif %} </form> {% endblock %} </code></pre> <p>Manuals.html (No Search bar displays)</p> <pre><code>{% extends 'base.html' %} {% load staticfiles %} {% block content%} <h1>Hello and welcome to Manuals</h1> {% endblock %} </code></pre> <p>URL patterns</p> <pre><code>url(r'^search/', include('haystack.urls')), url(r'^manuals/$', 'mysite.views.manuals', name='manuals'), </code></pre> |
30,047,256 | 0 | Mongodb, time difference between two checkpoints <p>I m actually developping an application using a Mongodb database. Actually, there's a system with "checkpoints", a user scan an NFC tag when he enters in a place, and scan this same tag to leave this place.</p> <p>So, in my database, I have something like :</p> <pre><code>{ "enterDate":"the-date-iso-string-formatted", "leaveDate":"the-date-iso-string-formatted" } </code></pre> <p>Actually, I need to detect what is the time between two different end point. I mean, how much time the user takes to travel from one place, to the next one.</p> <p>In fact it corresponds to the avg of all the </p> <blockquote> <p>endPoint[1].enterDate- endPoint[0].leaveDate</p> </blockquote> <p>What is the best way, or the quickest way to manage this ?</p> <p>Thanks for advance</p> |
20,133,842 | 0 | <p>You can use the <code>unbackslash</code> function from <a href="https://metacpan.org/pod/String%3a%3aEscape">String::Escape</a> to do this:</p> <pre><code>use String::Escape qw( unbackslash ); my $str = 'Hello\r\nWorld\r\n'; print unbackslash($str); </code></pre> |
936,127 | 0 | <p>You'd want to assign a random value to the ID column, then sort by it and reassign the ID based on position in the sorted rows.</p> |
37,380,972 | 0 | Partition Spark DataFrame based on column <p>I'm trying to partition a Spark DataFrame based on the column "b" using groupByKey() but I end up having different groups in the same partition.</p> <p>Here is the Data Frame and the code I'm using:</p> <pre><code>df: +---+---+ | a| b| +---+---+ | 4| 2| | 5| 1| | 1| 4| | 2| 2| +---+---+ val partitions = df.map(x => x.getLong(1)).distinct().count().toInt val df2 = df.map(r => (r.getLong(1), r)).groupByKey(partitions) val gb = df2.mapPartitions(iterator => { val rows = iterator.toList println(rows) iterator }) The printed rows are: Partition 1: List((2,CompactBuffer([4,2], [2,2]))) Partition 2: List((4,CompactBuffer([1,4])), (1,CompactBuffer([5,1]))) </code></pre> <p>Groups 4 and 1 are in the same partition (2) and I would like to have them in separate partitions, do you know how to do that?</p> <pre><code>Desired output: Partition 1: List((2,CompactBuffer([4,2], [2,2]))) Partition 2: List((4,CompactBuffer([1,4]))) Partition 3: List((1,CompactBuffer([5,1]))) </code></pre> <p>P.S. To give you a bit of context, I'm doing this because I need to update rows in a DataFrame using data from all the other rows sharing the same value for a specific column. Therefore map() is not enough, I'm currently trying to use mapPartitions() where each partition would contain all the rows having a the same value for the specific column. Don't hesitate to tell me if you know a better way of doing this :)</p> <p>Thanks a lot!</p> <p>ClydeX</p> |
33,921,523 | 0 | <p>If you want to adjust background image, then you should use ImageView as a First Child of FrameLayout or RelativeLayout and you can arrange the remaining controls as per your requirement in Second Child or remaining child.</p> |
31,221,627 | 0 | <p>OK, this is not a python but a UNIX problem: </p> <p>A file is, by default, always created owned by the user of the creating process.</p> <p>As root, you can change your effective UID for such operation, and you can change the file ownership afterwards.</p> <p><code>cp</code> supports keeping the original owner: <code>cp -a</code> This might already solve your problem.</p> <p>Setting the UID in your python process is really trivial:</p> <pre><code>import os os.setuid(<userid>) </code></pre> |
40,790,946 | 0 | iOS set statusbar white, and hide in another ViewController <p>I need a white status bar for my main initial ViewController, but also be able to hide it in another ViewController. I can do one or the other, but not both at the same time. Any suggestions?</p> <p>I set it to white by setting </p> <blockquote> <p>View controller-based status bar appearance key to NO in the Info.plist</p> </blockquote> <pre><code>override func preferredStatusBarStyle() -> UIStatusBarStyle { return .LightContent } </code></pre> <hr> <p>And to hide it (on another ViewController presented modally) I do,</p> <pre><code>override func prefersStatusBarHidden() -> Bool { return statusBarHidden } </code></pre> <p><strong>however it won't hide unless</strong> I remove the key I previously added to the Info.plist, but if I remove the key, then the status bar goes back to black.</p> <hr> <p>EDIT-MY Solution: The View controller classes were not working in my case because I have the main view controller embedded in a navigation controller, my fix was to override the same methods but for the navigation controller instead of the view controller in question.</p> <pre><code>extension UINavigationController { public override func preferredStatusBarStyle() -> UIStatusBarStyle { return .LightContent } } </code></pre> |
5,616,186 | 0 | <p>If you want to cycle through the <code>$results</code> array, you should write </p> <p><code>foreach ($results as $key=>$value)</code> </p> <p>rather than </p> <p><code>foreach ($results[0] as $key=>$value)</code> </p> <p>unless <code>$results[0]</code> itself is an array, in which case <code>$results</code> would be a matrix (array of arrays).</p> |
10,622,182 | 0 | <p>It looks like they're already names of variables in your workspace?</p> <pre><code>x <- ls()[grep('^x\\d', ls())] </code></pre> <p>That might get you there if you don't have anything else that starts with an x and a number that you want to include.</p> <p>If they're text strings that you're pasting in or something then perhaps</p> <pre><code>x <- scan() </code></pre> <p>(In general, your question was quite vague)</p> |
20,631,085 | 0 | <p>It can return null for some older J2ME devices which might not have support for location (it will work for most recent J2ME devices too). It shouldn't return null for other cases e.g. iOS, Android, Windows Phone etc..</p> |
25,526,913 | 0 | <p>Perhaps you should consider to filter out the lines before writing them into the excel-sheet. This way you get rid of the additional work of writing then reading again and deleting lines.</p> <p>So you would fetch your data (wherever it comes from), filter the list in c# (remove all items with the specific text in the columns) and write the clean list to excel in the end.</p> |
26,531,727 | 0 | <p>I just found python-snappy on github and installed it via python. Not a permanent solution, but at least something.</p> |
10,934,100 | 0 | <p>Even if you could do this, the difference would be barely noticeable. JSON is parsed REALLY fast. What you need, I believe, is to make several timed calls, maybe using setInterval. This way you can request more content, say, every 2 seconds. If more content is found, append it to the existing one.</p> <p>If you already have all the content you will get, and want to "animate" the content being added, you can parse the JSON received as an object and do something like</p> <pre><code>for (var i=0; i<content.length; setTimeout(i++, 1000)){ $(container).append(content[i]); } </code></pre> |
19,003,011 | 0 | How can I format input fields to form time of day using PHP date() function? <p>I want the user to select a time of day which I then want to convert using the <code>date()</code> function so it can be inserted into a Mysql database <code>datetime</code> table field.</p> <pre><code><select name="event-start-time-hours" class="event-time"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8" selected>8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> </select> <select name="event-start-time-mins" class="event-time"> <option value="00" selected >00</option> <option value="05">05</option> <option value="10">10</option> <option value="15">15</option> <option value="20">20</option> <option value="25">25</option> <option value="30">30</option> <option value="35">35</option> <option value="40">40</option> <option value="45">45</option> <option value="50">50</option> <option value="55">55</option> </select> <select name="event-start-timeofday" class="event-time"> <option value="" selected >AM</option> <option value="">PM</option> </select> </code></pre> <p>I tried:</p> <pre><code> $time = $_POST['event-start-time-mins'] .$_POST['event-start-time-hours']; var_dump($dob = date("H:i:s", $time)); print_r($_POST['event-start-time-hours']); print_r($_POST['event-start-time-mins']); </code></pre> <p>Which returns:</p> <blockquote> <p>string(8) "01:03:22" 220</p> </blockquote> <p>So how do I format this correctly? Many thanks.</p> |
16,778,618 | 0 | Which way is better, and how to pass parameters to windows.forms.timer <p>What I want to accomplish it the following thing:</p> <p>I have a lot of "checks(if/else if etc)" inside a timer, that his interval is 1000 ms,</p> <p>there is a text file that getting updated and the timer read it every 1000 ms and check for some specific changes,</p> <p>under 1 of those conditions if it is true the timer, i need to wait 10 sec and then read another text file and then continue with the rest of the timer code.</p> <p>but in the mean time the timer keep running under those 10 sec and preform the checks every 1sec for all the other conditions and this 1 also.</p> <p>what i thought to do it </p> <p>if the conditions i wanted it true i will start a new timer with 10sec interval and it will continue with the code of that specific part.</p> <p>but what i have hard time to accomplish is how to pass parameters into that timer</p> <p>such as </p> <pre><code>newTimer.Start(int "parameter", string "parameter b", list<string> parameters c") </code></pre> <p>etc etc</p> <p>or if you got any other idea i will be glad to hear.</p> |
4,823,053 | 0 | jquery register event on hyperlinks inside the div <p>I wanted to apply events on hyperlinks under Id's with name "topicColumnTemplate". below is the HTML snippet and I am syntax => <code>$('[id^=topicColumnTemplate] a').click(function() { // do operation});</code></p> <p>But events are not getting applied, Links are generated dynamically if i use after once all the dom is populated using link id through syntax => <code>$('[id^=link]').click(function() { // do operation});</code> it WORKS</p> <p>What is wanted is in javascript intialization wanted to use above first syntax where in using the ul id which is already present in DOM & is not generated dynamically. Just giving div id of ul i.e [id^=topicColumnTemplate] works but it is getting applied all around the ul block which causes function invokation every where around the block & I need function gets invocated only when </p> <p>*<em>*</em> replace "-" with "<" for html</p> <pre><code><ul id="topicColumnTemplate1" class="listcol "> <li id="row_0" class="listrow "> <a id="link_0" class="listtopic">user1</a> </li> <li id="row_1" class="listrow "> <a id="link_1" class="listtopic">user2</a> </li> <li id="row_2" class="listrow "> <a id="link_2" class="listtopic">user3</a> </li> </ul> <ul id="topicColumnTemplate2" class="listcol "> <li id="row_0" class="listrow "> <a id="link_0" class="listtopic" href="#">user1</a> </li> <li id="row_1" class="listrow "> <a id="link_1" class="listtopic" href="#">user2</a> </li> <li id="row_2" class="listrow "> <a id="link_2" class="listtopic" href="#">user3</a> </li> </ul> </code></pre> |
20,822,439 | 0 | <p>I suspect you are trying to compile your code as C++ rather than C. In C++, <code>try</code> is a <a href="http://en.cppreference.com/w/cpp/keyword" rel="nofollow">reserved word</a> (it is used in exception handling).</p> <pre><code>$ gcc test.c $ g++ test.c test.c:3:6: error: expected unqualified-id before 'try' </code></pre> <p>You can use <code>-x</code> to set the language explicitly (with either <code>gcc</code> or <code>g++</code>):</p> <pre><code>$ gcc -x c test.c $ gcc -x c++ test.c test.c:3:6: error: expected unqualified-id before 'try' </code></pre> |
40,017,770 | 0 | <p>If your result will be dynamic(The string length would vary in future) the below solution may work,</p> <pre><code>private void rellenarSpinnerConFoliosDeMaquinasDelPunto(List<String> folios) { try{ maquinas = dbOn.getMaquinasDePunto(idPunto); for (int i = 0; i < maquinas.size(); i++) { foliosDeMaquinas.add(maquinas.get(i).getcFolioMaquina().toString().split("-")[1]); } } catch(ArrayIndexOutOfBoundsException e){ e.printStackTrace(); } adaptadorFoliosMaquina = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, folios); adaptadorFoliosMaquina.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spn_folioMaquina.setAdapter(adaptadorFoliosMaquina); spn_folioMaquina.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { </code></pre> |
30,280,448 | 0 | Change HTML Theme of a specific port <p>I want know that how can we change the theme of page of a specific port from default listing to custom looking theme.</p> <p>I am looking to change my FTP port 21's theme from default to custom, dont exactly know how to..</p> |
25,737,201 | 0 | Six degrees of Kevin Bacon <p>There are a couple other posts about degrees of Kevin Bacon, and the answers on those posts are similar to what I came up with myself before looking it up. But it's evident that I'm still doing something wrong from the results I get and the way the performance of my query falls off as I increase the degree of separation from Kevin Bacon.</p> <p>Here's my query to find all actors with one degree of Kevin Bacon:</p> <pre><code>match p=(:Person {name:"Kevin Bacon"})-[:ACTED_IN*..2]-(:Person) return p </code></pre> <p>If I understand correctly, that's equivalent to this:</p> <pre><code>match p=(:Person {name:"Kevin Bacon"})-[:ACTED_IN]->()<-[:ACTED_IN]-(:Person) return p </code></pre> <p>And indeed, both of these queries return the same number of rows. But if I modify the first version of the query and increase the path length to 6 (i.e., three degrees of Kevin Bacon) it returns 978 rows. There are only 133 Person nodes in the database, so I would expect it to return at most 133 rows.</p> <p>My guess is that it's returning multiple paths to some of the Person nodes. How do I tell it to return only the shortest path to each? Basically, I want to perform a single depth-first or breadth-first search. I think it might involve <code>WITH</code>, but I don't really understand how to use that yet.</p> |
37,420,319 | 0 | Accessing Atlas, individual, and embedded resources/images easily <p>Basically, I have a bunch of images that I can combine into a single image(an atlas) or use individually. For testing/designing purposes, I would like to keep all the images separate but for release they should all be combine into the atlas(for non-embeddable compilers) or embedded.</p> <p>e.g., suppose I have 100 sprites. I can create a single atlas for them, use them all individually unembedded, or embed the atlas, or embed all the image.</p> <p>I'd like to start out with the individual+unembedded case for development then move to the embedded atlas case or embedded individual case(but I think this is probably not as good as the embedded atlas).</p> <p>Is there an easy way to set this up in C# so the transition will be minimal?</p> <p>The problem with the embedded atlas is that I would have to convert loading images(simple Image.FromFile into extracting images from the atlas).</p> <p>Just curious what would be a good approach to remove the need for rewriting a lot of code in the future when the switch is made.</p> <p>I could have something like Image.FromAtlas that essentially figures out the details(uses FromFile if we are in "development mode" or extracts the image from the atlas if in production... I think the embedded case would be rather trivial to implement).</p> <p>What do you think? Thanks.</p> |
30,363,178 | 0 | I would like drop down menu selections to bring post different images when different choices are selected <p>Here is my basic pull down selection tabs. How do I get each choice to post a different image (preferably html source images) when selected. </p> <p>I would like the images to post within the div as well if possible. </p> <pre><code> <div id= "PERSONAL"> <p id= "Range"> Preferred Distance </p> <select class= "Distance" onchange="report(this.value)"> ` <option value="Pick3">Pick Your Range</option> <option value="100 Miles">100 Miles</option> <option value="1000 Miles">1000 Miles</option> <option value="More than 2000 Miles">More than 2000 Miles</option> <option value="Around the World">Around the World</option> </select> <p id= "Weather"> Preferred Weather </p> <select class= "Weather" onchange="report(this.value)"> <option value="Pick2">Pick Your Weather</option> <option value="Cold">Cold</option> <option value="Mild">Mild</option> <option value="Hot">Hot</option> <option value="Anything">Anything</option> </select> <p id= "Moisture"> Wet or Dry </p> <select class= "Moisture" onchange="report(this.value)"> <option value="Pick1">Pick Your Moisture</option> <option value="Desert">Desert Dry</option> <option value="Moderate">Wet and Dry</option> <option value="Rainy">Jungle Wet</option> <option value="Snow">Snow Time!</option> </select> </div> </code></pre> |
32,871,952 | 0 | <p>The following seems to work:</p> <pre><code>match (aType:Type:Class)-[:ANNOTATED_BY]->()-[:OF_TYPE]->(anAnnotationType:Type), (aType:Type)-[:DECLARES]->(aMethod:Method) optional match (aMethod)-[:ANNOTATED_BY]->()-[:OF_TYPE]->(tType:Type) with anAnnotationType, aMethod, tType where anAnnotationType.fqn = "com.mycompany.services.Service" and aMethod.name =~ "update.*" and ((tType is null) or not (tType.fqn = "com.mycompany.services.Transact")) return aMethod.name, tType </code></pre> |
13,860,974 | 0 | Deleting all rows from all tables for a specific Database in a SQL Server <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1899846/how-to-delete-all-rows-from-all-tables-in-a-sql-server-database">How to delete all rows from all tables in a SQL Server database?</a> </p> </blockquote> <p>I want to delete all rows from all tables for a specific database in a sql server which has 10's of other databases as well.</p> <p>I find this post with this query but not sure how it will work</p> <pre><code>EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL' GO EXEC sp_MSForEachTable 'DELETE FROM ?' GO EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL' GO </code></pre> <p>My SQL Server name ServerBanta and Database name is DingDong2010.</p> <p>Taken from <a href="http://stackoverflow.com/questions/1899846/how-to-delete-all-rows-from-all-tables-in-a-sql-server-database">How to delete all rows from all tables in a SQL Server database?</a></p> |
37,418,025 | 0 | <p>Just dont rewrite lastQuote and whichQuoteToChoose on each click event. so i moved those variables out of click event :) </p> <pre><code> $(document).ready(function() { var lastQuote = ""; var whichQuoteToChoose = ""; $("#getQuote").on("click", function() { $.getJSON("http://codepen.io/thomasdean/pen/Yqmgyx.js", function(json) { var html = ""; //alert(lastQuote) while (whichQuoteToChoose === lastQuote) { whichQuoteToChoose = Math.floor(Math.random() * 12); // returns a number between 0 and 11 } lastQuote = whichQuoteToChoose; // this converts raw data into html json = json.filter(function(val) { return (val.id == whichQuoteToChoose); }); json.forEach(function(val) { html += "<div class = 'quote'>" html += "<h2>\"" + val.Quotation + "\"</h2><h2>" + val.Quotee + "</h2>" html += "</div>" }); $(".quote").html(html); }); }); }); </code></pre> |
21,896,950 | 0 | <p>Upside of GUIDs:</p> <p>GUIDs are good if you ever want offline clients to be able to create new records, as you will never get a primary key clash when the new records are synchronised back to the main database. </p> <p>Downside of GUIDs:</p> <p>GUIDS as primary keys can have an effect on the performance of the DB, because for a clustered primary key, the DB will want to keep the rows in order of the key values. But this means a lot of inserts between existing records, because the GUIDs will be random. </p> <p>Using IDENTITY column doesn't suffer from this because the next record is guaranteed to have the highest value and so the row is just tacked on the end every time. No re-shuffle needs to happen.</p> <p>There is a compromise which is to generate a pseudo-GUID which means you would expect a key clash every 70 years or so, but helps the indexing immensely.</p> <p>The other downsides are that a) they do take up more storage space, and b) are a real pain to write SQL against, i.e. much easier to type <code>UPDATE TABLE SET FIELD = 'value' where KEY = 50003</code> than <code>UPDATE TABLE SET FIELD = 'value' where KEY = '{F820094C-A2A2-49cb-BDA7-549543BB4B2C}'</code> </p> <p>Your declaration of the IDENTITY column looks fine to me. The gaps in your key values are probably due to failed attempts to add a row. The IDENTITY value will be incremented but the row never gets committed. Don't let it bother you, it happens in practically every table. </p> <p>EDIT:</p> <p>This question covers what I was meaning by pseudo-GUID. <a href="http://stackoverflow.com/questions/5977137/inserts-with-sequential-guid-key-on-clustered-index-not-significantly-faster">INSERTs with sequential GUID key on clustered index not significantly faster</a></p> <p>In SQL Server 2005+ you can use NEWSEQUENTIALID() to get a random value that is supposed to be greater than the previous ones. See here for more info <a href="http://technet.microsoft.com/en-us/library/ms189786%28v=sql.90%29.aspx" rel="nofollow">http://technet.microsoft.com/en-us/library/ms189786%28v=sql.90%29.aspx</a></p> |
11,214,493 | 0 | <p>You can do a look up of the id, and retrieve the link of the page stored.</p> <p>example: <a href="https://developers.facebook.com/tools/explorer?method=GET&path=191825050853209" rel="nofollow">https://developers.facebook.com/tools/explorer?method=GET&path=191825050853209</a></p> <p>refer to: <a href="https://developers.facebook.com/docs/reference/api/page/" rel="nofollow">https://developers.facebook.com/docs/reference/api/page/</a> under link connection.</p> <p>This method will require use of the graph api, or one of the sdks.</p> <p>refer to: <a href="https://developers.facebook.com/docs/reference/api" rel="nofollow">https://developers.facebook.com/docs/reference/api</a></p> |
21,038,781 | 0 | <pre><code>@echo off pushd c:\test_dir for /r %%a in (*) do ( java -Durl=http://localhost:8983/solr/update/extract?literal.id=%%~nxa -Dtype=application/word -jar post.jar "%%~dpfnxa" ) </code></pre> <p>This will process the files recursively.You can filter the files "wild-cards" expression -> <code>for /r %%a in (*doc)</code> or do it only for the current folder <code>for %%a in (*)</code> .</p> |
27,152,722 | 0 | <p>Another approach would simply use media queries to change the width of the divs. This would allow you to avoid adding more markup.</p> <p><a href="http://jsfiddle.net/14ecjy7n/1/" rel="nofollow">http://jsfiddle.net/14ecjy7n/1/</a></p> <pre><code>div { box-sizing: border-box; float: left; } @media all and (max-width: 639px) { div { width: 50%; } } @media all and (min-width: 640px) { div { width: 100%; } } </code></pre> |
36,683,081 | 0 | Chrome does not show exit full screen window when moving mouse to top of screen <p>So I was testing my site for full screen mode and I noticed that when you move your mouse to the top of your screen when in full screen mode it doesn't show the little window that allowed you to exit full screen without hitting F11. Is this a bug or is it intentionally removed from the latest chrome update? It's pretty annoying. </p> <p>PS: I did recently reinstall my pc and since then I noticed some changes I am not very happy about :( </p> |
691,194 | 0 | Why is my implementation of C++ map not storing values? <p>I have a class called ImageMatrix, which implements the C++ map in a recursive fashion; the end result is that I have a 3 dimensional array.</p> <pre><code>typedef uint32_t VUInt32; typedef int32_t VInt32; class ImageMatrix { public: ImageMatrixRow operator[](VInt32 rowIndex) private: ImageMatrixRowMap rows; }; typedef std::map <VUInt32, VInt32> ImageMatrixChannelMap; class ImageMatrixColumn { public: VInt32 &operator[](VUInt32 channelIndex); private: ImageMatrixChannelMap channels; }; typedef std::map<VUInt32, ImageMatrixColumn> ImageMatrixColumnMap; class ImageMatrixRow { public: ImageMatrixColumn operator[](VUInt32 columnIndex); private: ImageMatrixColumnMap columns; }; typedef std::map<VUInt32, ImageMatrixRow> ImageMatrixRowMap; </code></pre> <p>Each operator simply returns a map-wrapper class within, like so:</p> <pre><code>ImageMatrixRow ImageMatrix::operator[](VInt32 rowIndex) { return rows[rowIndex]; } ImageMatrixColumn ImageMatrixRow::operator[](VUInt32 columnIndex) { return columns[columnIndex]; } VInt32 &ImageMatrixColumn::operator[](VUInt32 channelIndex) { return channels[channelIndex]; } </code></pre> <p>Basically, when I set the value as say 100, and test the value to cout, it shows as 0, and not the number to which I had set it.</p> <pre><code>for (VUInt32 a = 0; a < GetRowCount(); a++) { for (VUInt32 b = 0; b < GetColumnCount(); b++) { for (VUInt32 c = 0; c < GetChannelCount(); c++) { VInt32 value = 100; matrix[a][b][c] = value; VInt32 test = matrix[a][b][c]; // pixel = 100, test = 0 - why? cout << pixel << "/" << test << endl; } } } </code></pre> <p>Note: I've altered the original code for this example so that it takes up less space, so some syntax errors may occur (please don't point them out).</p> |
38,181,664 | 0 | <p>Building on @barak manos' idea, i would just go and look for all my dictionary keys in every line and replace them on site like so:</p> <pre><code>dict = { '¼': '.25', '½': '.50', } def convert(line, dict): for x in dict: line = line.replace(x, dict[x]) line = line.replace(' ' + dict[x], ' 0' + dict[x]) return line a = '1¼ ½ 564as 25½' print(convert(a,dict)) # returns: '1.25 0.50 564as 25.50' </code></pre> <p>The position of the characters you are looking for in the sentence and/or the presence of integers around them or not is irrelevant.</p> |
12,049,315 | 0 | <p>There is a easier way to work around the problem using <code>JavascriptExecutor</code>.</p> <p>For example:</p> <pre><code>document.getElementsByClassName('post-tag')[0].click(); </code></pre> <p>The above javascript would click on the "Selenium" tag on the top right of this page (next to your question), even if it were hidden (hypothetically). </p> <p>All you need to do is issue this JS instruction via the <code>JavascriptExecutor</code> interface like so:</p> <pre><code>(JavascriptExecutor(webdriver)).executeScript("document.getElementsByClassName('post-tag')[0].click();"); </code></pre> <p>This would use the JS sandbox and synthetic click event to perform the click action. Although it defeats the purpose of WebDriver user activity simulation, you can use it in niche scenarios like in your case to good effect.</p> |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.