pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
28,900,135
0
<p>Don't mix up EJB Annotation with new as CountriesFacadeLocal cin = new CountriesFacade(); In case you have decided to use use Container logic as EJB you should stick to this. Otherwise your field isn't initialized at all (neither EJB nor new) and therfore null. </p>
30,590,573
0
<p>You can do this the socialengine Socialengine single sign on plugin:</p> <p><a href="http://www.ipragmatech.com/socialengine-single-sign-on" rel="nofollow">http://www.ipragmatech.com/socialengine-single-sign-on</a></p>
22,113,927
0
<p>Applying the command</p> <pre><code>netsh wlan show all </code></pre> <p>in windows would show details of all the routers including the BSSID in your wireless range, even though you might not have been connected to the router.</p>
5,728,526
0
<p>There's also</p> <pre><code>var p = new Program(); string btchid = p.GetCommandLine(); </code></pre>
14,236,276
0
<p>Conmpression is always expensive but you might be able to improve with</p> <pre><code>OutputStream bOut = new BufferedOutputStream(new FileOutputStream("saves/p-" + layer + ".gz")); DeflaterOutputStream defOut = new DeflaterOutputStream(bOut, new Deflater(Deflater.BEST_SPEED)); //buffer.flip(); byte[] bytes = new byte[1024]; while (buffer.hasRemaining()) { int len = Math.min(buffer.remaining(), bytes.length); buffer.get(bytes, 0, len); defOut.write(bytes, 0, len); } defOut.close(); </code></pre>
27,031,485
0
<p>The <a href="https://developer.mozilla.org/en-US/docs/Web/Events/keydown" rel="nofollow">keydown</a> event supports event bubbling, so you can just add the handler to the <code>container</code> element like</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>document.querySelectorAll('.container')[0].addEventListener('keydown', function(e) { console.log('keypressed', this, e); //e.target will refer to the actual event target log('down in `' + e.target.innerHTML + '` with keycode: ' + (e.keyCode)) }) function log(msg) { document.querySelector('#log').innerHTML = msg; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class='container'&gt; &lt;p tabindex="1"&gt;content&lt;/p&gt; &lt;p tabindex="1"&gt;in enough different elements&lt;/p&gt; &lt;p tabindex="1"&gt;that making listeners&lt;/p&gt; &lt;p tabindex="1"&gt;for all of them&lt;/p&gt; &lt;p tabindex="1"&gt;would be a huge pain&lt;/p&gt; &lt;/div&gt; &lt;div id="log"&gt;&lt;/div&gt;</code></pre> </div> </div> </p>
4,095,303
0
What is the recommended way to handle links that are used just for style and/or interactive purposes? <p>For example, the link below triggers something in jQuery but does not go to another page, I used this method a while back ago.</p> <pre><code>&lt;a class="trigger" href="#"&gt; Click Me &lt;/a&gt; </code></pre> <p>Notice theres a just a hash tag there, and usually causes the page to jump when clicked on, right? [I think]. It is only for interactive stuff, doesn't go to another page or anything else. I see a lot of developers do this.</p> <p>I feel like its the wrong thing to do though. Is there another recommended way to do this without using HTML attributes a way where it is not suppose to be used?</p> <p>Not using <code>&lt;button&gt;</code> ether because the link would not be a button.</p> <p>Maybe without a hash?</p> <pre><code>&lt;a class="trigger"&gt; Click Me &lt;/a&gt; </code></pre> <p>&amp; in CSS:</p> <pre><code>.trigger { cursor: pointer; } </code></pre> <p>So the user still knows its for something that you should click?</p>
22,360,469
0
<p>I would go the one field approach. You could have three columns, <code>Name</code>, <code>Surname</code>, and <code>field_values</code>. In the <code>field_values</code> column, store a PHP <a href="http://php.net/serialize" rel="nofollow"><code>serialized</code></a> string of an array representing what would otherwise be your columns. For example, running:</p> <pre><code>array( ['col1'] =&gt; 'val', ['col2'] =&gt; 'val1', ['col3'] =&gt; 'val2', ['col4'] =&gt; 'val3' ) </code></pre> <p>through <code>serialize()</code> would give you:</p> <pre><code>a:4:{s:4:"col1";s:3:"val";s:4:"col2";s:4:"val1";s:4:"col3";s:4:"val2";s:4:"col4";s:4:"val3";} </code></pre> <p>and you can take this value and run it back through <code>unserialize()</code> to restore your array and use it however you need to. Loading/saving data within this array is no more difficult than changing values in the array before serializing it and then saving it to the <code>field_values</code> column.</p> <p>With this method you can have as many or few 'columns' as you need with no need for a ton of columns or tables.</p>
7,031,801
0
<p>The question was edited after I originally posted this and it was accepted. The answer to the updated question is to open the file in binary mode:</p> <pre><code>crystal = open('vmises.dat', 'rb') </code></pre> <hr> <p>Answer to original, pre-edit question:</p> <p>Well, <code>data</code> is a string. The object you need to work on is <code>a</code>.</p> <pre><code>a = open('data.txt','r') b = pickle.load(a) c = pickle.load(a) d = pickle.load(a) a.close() </code></pre> <p>For <code>pickle</code> info, see the <a href="http://wiki.python.org/moin/UsingPickle" rel="nofollow">Python Wiki</a> or <a href="https://python4kids.wordpress.com/2011/02/04/an-awful-pickle/" rel="nofollow">Python for Kids</a>.</p>
28,585,915
0
<p>There are two plugins/listeners that will generate this directly within JMeter UI or write the files to results if you are doing distributed test. Both are from the <a href="http://jmeter-plugins.org/wiki/ExtrasSet/" rel="nofollow noreferrer">Extras Set</a>.</p> <ul> <li><p><a href="http://jmeter-plugins.org/wiki/RespTimePercentiles/" rel="nofollow noreferrer">Response Times Percentiles</a> <img src="https://i.stack.imgur.com/MTL6I.png" alt="enter image description here"> The test I am using is simple and the response time is in ms. Y-axis is milliseconds, and X-Axis is percentage of requests responding in that time. </p></li> <li><p><a href="http://jmeter-plugins.org/wiki/RespTimesDistribution/" rel="nofollow noreferrer">Response Times Distribution</a> Same concept except Y-Axis is number of requests responding in that bucket, X-Axis the response time in milliseconds. The size of the distribution is configurable. </p></li> </ul> <p><img src="https://i.stack.imgur.com/3SNAy.png" alt="enter image description here"></p> <p>Plugin installation is described <a href="http://jmeter-plugins.org/wiki/PluginInstall/" rel="nofollow noreferrer">here</a>, it is as simple as copying files into your JMeter installation. </p>
5,542,143
0
<p>try adding ToArray() after your LINQ query. I do know that LINQ follows lazy evaluation rule, and ToArray() forces evaluation to be eager. </p>
34,745,801
0
<p>Do the following:</p> <pre><code>#config/routes.rb resources :jobs do get "search(/:keyword)", action: :show, on: :collection #-&gt; url.com/jobs/search?keyword=query || url.com/jobs/search/:keyword end #app/assets/javascripts/application.js $(document).on("keypress", "#search", function(e) { $.get("jobs/search", {keyword: $('#search').val()}); }); #app/controllers/jobs_controller.rb class JobsController &lt; ApplicationController def show if params[:keyword] @jobs = Job.where id: params[:keyword] else @job = Job.find params[:id] end respond_to do |format| format.js format.html {redirect_to customers_url} end end end #app/views/jobs/show.js.erb ("&lt;%=j render @jobs %&gt;").appendTo("#jobs-table"); </code></pre>
18,732,500
0
<p>make <code>timerHolder</code> object <code>null</code> after canceling it.</p> <pre><code>if(Class.isAddTime()){ timerHolder.cancel(); timerHolder=null; AddTime(); Class.isAddTime = false; } </code></pre>
33,540,492
0
<p><a href="http://stackoverflow.com/a/32454407/2281718">This answer</a> solved this problem for me. Create a custom <code>AppBarLayout.Behavior</code> like this:</p> <pre><code>public final class FlingBehavior extends AppBarLayout.Behavior { private static final int TOP_CHILD_FLING_THRESHOLD = 3; private boolean isPositive; public FlingBehavior() { } public FlingBehavior(Context context, AttributeSet attrs) { super(context, attrs); } @Override public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, float velocityX, float velocityY, boolean consumed) { if (velocityY &gt; 0 &amp;&amp; !isPositive || velocityY &lt; 0 &amp;&amp; isPositive) { velocityY = velocityY * -1; } if (target instanceof RecyclerView &amp;&amp; velocityY &lt; 0) { final RecyclerView recyclerView = (RecyclerView) target; final View firstChild = recyclerView.getChildAt(0); final int childAdapterPosition = recyclerView.getChildAdapterPosition(firstChild); consumed = childAdapterPosition &gt; TOP_CHILD_FLING_THRESHOLD; } return super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed); } @Override public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, int dx, int dy, int[] consumed) { super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed); isPositive = dy &gt; 0; } } </code></pre> <p>and add it to the <code>AppBarLayout</code> like this:</p> <pre><code>&lt;android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" ... app:layout_behavior="com.example.test.FlingBehavior"&gt; </code></pre>
38,008,596
0
<p><strong>You can't <em>change</em> the ID of an entity</strong>. The ID uniquely identifies an entity object. Different ID = different entity object. You can manually edit the value of the annotated <code>@Id</code> column in the database, sure; but for all purposes, that record is now a <em>different</em> entity object, because it has a different ID.<br> For any framework to <em>know</em> that your <code>User</code> is the same <code>User</code> despite having a different ID, there'd have to exist some other internal column that could be used to identify the User. Something like "oh, ok, the <code>openID</code> is different but the <code>socialSecurityNumber</code> is the same, so it's the same <code>User</code>". But then again, your ID would not be the <code>openID</code> field: you'd have to annotate <code>socialSecurityNumber</code> as the actual <code>@Id</code> so the framework knows.</p> <p>And in fact, in your example you're doing this:</p> <pre><code>User user = userRepo.findOne("o3sVZuA4p81wG24ph5Z5lmnrVhlc"); </code></pre> <p>So it seems like you <em>do</em> have a unique ID <code>"o3sVZuA4p81wG24ph5Z5lmnrVhlc"</code>, it's only that you haven't declared it in your <code>User</code>.</p> <p>Just remove the <code>@Id</code> annotation from <code>openId</code> and declare that other field as <code>@Id</code>. That way you'd be able to update the <code>openID</code> of any <code>User</code> and have it reflected in every <code>Gift</code> too.</p>
2,598,638
0
<p>No, you can't do this - but you should look at using <a href="http://msdn.microsoft.com/en-us/library/1hsbd92d.aspx" rel="nofollow noreferrer"><code>ArraySegment</code></a> instead.</p> <p>Note that an array object consists of metadata about its length etc and then the data itself. You can't create a slice of an existing array and still have the metadata next to the data, if you see what I mean - there'd have to be an extra level of indirection (which is what <code>ArraySegment</code> provides).</p> <p>(I'm slightly surprised that ArraySegment doesn't do more wrapping, e.g. by implementing <code>IList&lt;T&gt;</code>, but there we go. It would be easy enough to create such a structure if you wanted to.)</p>
1,763,477
0
<p>admin/config/regional/date-time/formats and you can create custom formats and use it in views. remember to clear cache and reload the views edit page, otherwise you won't see the new formats.</p>
27,583,701
0
Using bind for form with lot of inputs (PHP) <p>I have form with lot of inputs, and I'm trying to import them in database (mysql). I want to use bind but trying to avoid writing all variables so many times. Probably I can't explain so good, so I will here is a code</p> <pre><code>if(isset($_POST['firstName']) &amp;&amp; isset($_POST['lastName']) &amp;&amp; isset($_POST['gender'])){ $firstName=trim($_POST['firstName']); $lastName=trim($_POST['lastName']); $gender=trim($_POST['gender']); if(!empty($firstName)&amp;&amp; !empty($lastName)) { $unos = $db-&gt;prepare("INSERT INTO members (firstName,lastName,gender) VALUES (?,?,?)"); $unos-&gt;bind_param('sss', $firstName, $lastName, $gender); if($unos-&gt;execute()) {.... </code></pre> <p>1.Well this is working fine , and it's not a problem, but now I want to add more inputs so I tried this </p> <pre><code>if(isset($_POST['firstName']) &amp;&amp; isset($_POST['lastName']) &amp;&amp; isset($_POST['gender'])){ $firstName=trim($_POST['firstName']); $lastName=trim($_POST['lastName']); $gender=trim($_POST['gender']); $param=array('$firstName','$lastName','$gender'); $type='sss'; $param_list = implode(',', $param); if(!empty($param)) { $unos = $db-&gt;prepare("INSERT INTO members (firstName,lastName,gender) VALUES (?,?,?)"); $unos-&gt;bind_param($type,implode(',', $param)); if($unos-&gt;execute()) {.... </code></pre> <p>and it's not working. I get "Number of elements in type definition string doesn't match number of bind variables"... I don't get it, because when I echo this implode thing I get what I need. I'm pretty newbie with PHP, so help will be so precious. :)</p>
30,391,255
0
<p>In this statement, you get number, use it as address in <em>memory</em>, which is most likely invalid.</p> <pre><code>file.write((char*)num, sizeof(num)); </code></pre> <p>If you want to write <code>num</code> in binary representation, you should get its address first:</p> <pre><code>file.write(reinterpret_cast&lt;char*&gt;(&amp;num), sizeof(num)); </code></pre> <p>Note the ampersand which is unary operator for getting addresses. I have also used <code>reinterpret_cast</code> which is C++ type conversion for such cases. C-style conversion may hide errors (but <code>reinterpret_cast</code> is also valid for <code>int</code>-><code>*</code> conversion).</p> <p>P.S. <code>void main()</code> is an invalid prototype of main. It should return <code>int</code> at least.</p>
31,426,418
0
Converting HTML to pdf and save it to given location without opening "Save As" or "Download" window <p>I am converting html into pdf. It is working fine. but when i try to save html into any location it gives me error <code>Network path not found</code>. I am having some line of code</p> <pre><code> #region Trying to convert pdf Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=Panel.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); StringReader sr = new StringReader(htmlStringToConvert); iTextSharp.text.Document pdfDoc = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 10f, 10f, 100f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); Response.End(); #endregion </code></pre> <p>I am getting error at <code>htmlparser.Parse(sr)</code>.</p> <p>Thanks in advance</p>
1,426,808
0
Can I deploy in SharePoint two Web Parts with the same DLL, but two .webpart files, at the same time <p>Is it possible to have two Web Parts with the same DLL, but two .webpart files, deployed in Sharepoint at the same time?</p> <p><strong>Background</strong> : I am developing an application that will generate a ".cab" file containing a Web Part (ASP.NET 2.0 Web Part). After that, the user should be able to deploy this ".cab" file in a in a SharePoint server.</p> <p>My application already includes the DLL of a Web Part. The "behavior" of this Web Part depends on the properties of the ".webpart" file which will be generated at runtime by my application (its content will change depending on certain user choices) After generating the ".webpart" file, it packages it to a ".cab" file along a Manifest.xml and the DLL.</p> <p>Imagine that the user creates two "cab" files using my application. And he wants to deploy them into SharePoint.</p> <p>To test this, I create this two ".cab" files with my app, and in SharePoint I execute:</p> <pre><code>$&gt; STSADM.EXE -o addwppack &lt;cab filename #1&gt; $&gt; STSADM.EXE -o addwppack &lt;cab filename #2&gt; $&gt; STSADM.EXE -o deletewppack &lt;cab filename #1&gt; </code></pre> <p>After the execution of the third command, the Web Part #2 doesn't have the DLL. When I installed Web Part #2, SharePoint override the DLL file of Web part #1 The problem here is that the DLL of both files is copied to same location. That location is the Assembly name of DLL. That assembly name cannot be changed without recompiling again (I think).</p> <p>Is there anyway to deploy two cab files independently, even if they share the same DLL?</p>
7,208,463
0
<p>I have done something like this in my code recently. Would the following work for you?</p> <pre><code>public TEntity GetById(Guid id, params Expression&lt;Func&lt;TEntity, object&gt;&gt;[] includeProperties) { if (id == Guid.Empty) return null; var set = _unitOfWork.CreateSet&lt;TEntity&gt;(); foreach(var includeProperty in includeProperties) { set.Include(includeProperty); } return set.First(i =&gt; i.Id == id); } </code></pre> <p>Then you would call it like this...</p> <p><code>var entity = _repository.GetById(theId, e =&gt; e.Prop1, e=&gt; e.Prop2, e=&gt; e.Prop3);</code></p> <p>I know this doesn't exactly follow your pattern, but I think you could refactor it as required.</p>
28,893,201
0
Assign value to anchor tag - angularjs <p>User sees a list of options (eg: 1.Apple ; 2.Banana ; 3.Mango). There is a textbox where user types in the desired option and clicks send to proceed further.</p> <p><strong>Existing Setup:</strong></p> <p><strong>HTML:</strong></p> <pre><code>&lt;p ng-repeat="opt in objHistory.OptionItems track by $index"&gt; {{ opt.SortOrder }}. {{ opt.OptionName }} &lt;/p&gt; &lt;textarea ng-model="userInput"&gt;&lt;/textarea&gt; &lt;a href="javascript:;" ng-click="GetNextItem()"&gt;Send&lt;/a&gt; </code></pre> <p><strong>JS:</strong></p> <pre><code>$scope.GetNextItem = function () { alert($scope.userInput); //some code } </code></pre> <p>The above code is working good. But now I have changed the options to anchor tags, so user can click on them, instead of typing and the same flow follows.</p> <p><strong>New HTML:</strong></p> <pre><code>&lt;p ng-repeat="opt in objHistory.OptionItems track by $index"&gt; &lt;a href="javascript:;" ng-model = "userInput" ng-init="userInput=opt.SortOrder" ng-click="GetNextItem()"&gt;{{ opt.SortOrder }}. {{ opt.OptionName }} &lt;/a&gt; &lt;/p&gt; </code></pre> <p>I get <code>undefined</code> in the alert now. Where am I going wrong? Can the same <code>ng-model</code> variable name be used multiple times (I'm using it for the <code>textbox</code> and also the <code>anchor</code> tags)?</p>
437,548
0
<p>Instead of <code>%ProgramFiles%</code>, isn't there a <code>%Programfiles(x86)%</code> that always goes where you want, regardless of which cmd.exe is running? My XP-64 systems all have that; excuse me for not taking the time to boot up a Vista system.</p>
23,775,134
1
ForeignKey field with null=True gives 'NoneType' object has no attribute id <p>I am new to Django.</p> <p>I have the following models.py</p> <pre><code>from django.db import models from django.contrib.auth.models import User from django.utils import timezone import os def get_upload_path(instance, filename): return os.path.join( "folder_%d" % instance.folder.id, filename) class Folder(models.Model): folder_name=models.CharField(max_length=100) parent_folder=models.ForeignKey('self', null=True, blank=True) folder_description=models.TextField(max_length=200) def __unicode__(self): return self.folder_name class File(models.Model): folder=models.ForeignKey(Folder, null=True, blank=True) uploaded_file=models.FileField(upload_to=get_upload_path) pub_date = models.DateTimeField('date published',default=timezone.now()) tag=models.ManyToManyField(FileTag) notes=models.TextField(max_length=200) uploader=models.ForeignKey(User) def __unicode__(self): return str(self.uploaded_file) def filename(self): return os.path.basename(self.uploaded_file.name) </code></pre> <p>If I try to save a File object with folder attribute with null its gives me 'AttributeError' saying 'NoneType' Object has no attribute id</p>
3,259,059
0
converge to zero via underflow <p><strong>please ignore this post, I misread algorithm, so the question is not relevant. However, I cannot close post anymore</strong>. Please vote to close</p> <p>I have been using certain algorithm from numerical recipes, which converges to zero via underflow:</p> <pre><code>// all types are the same floating type sum = 0 for (i in 0,N) sum += abs(V[i]); </code></pre> <p>my question, how does it happen? how does sum of small positive floating-point numbers converge to underflow/zero?</p> <p>is there some condition where <code>0 + f = 0 , f &gt; 0</code>?</p> <p>algorithm in question is Jacoby, <a href="http://www.mpi-hd.mpg.de/astrophysik/HEA/internal/Numerical_Recipes/f11-1.pdf" rel="nofollow noreferrer">http://www.mpi-hd.mpg.de/astrophysik/HEA/internal/Numerical_Recipes/f11-1.pdf</a>, page 460. It is quite possible I misunderstand how the convergence is achieved, if so, please correct me.</p> <p>thank you</p>
26,898,066
0
Can't Delete Contacts from Read-Only Accounts - Sync Adapter <p>I've created a custom SyncAdapter and given it the following XML:</p> <pre><code>&lt;sync-adapter xmlns:android="http://schemas.android.com/apk/res/android" android:contentAuthority="com.android.contacts" android:supportsUploading="true" android:userVisible="true" android:accountType="@string/authenticator_account_type"/&gt; </code></pre> <p>Thousands of searches has led me to 'supportsUploading="true"' but this is definitely not the case - contacts are still being marked as read-only.</p> <p>Since most of the documentation has a very "self-explanatory" vibe to it (Which is definitely not the case), I have no idea where to begin. Could someone please give me direction on this?</p> <p><strong>Edit:</strong> I even verified that the Account was in line with what Google has set for their accounts:</p> <p><img src="https://i.stack.imgur.com/XM7nY.jpg" alt=""> </p>
13,938,619
0
<p>In this particular case you could also override how REST framework determines the name to use for the endpoint, by overriding the <code>.get_name()</code> method.</p> <p>If you do take that route you'll probably find yourself wanting to define a set of base classes for your views, and override the method on all your base view using a simple mixin class.</p> <p>For example:</p> <pre><code>class GetNameMixin(object): def get_name(self): # Your docstring-or-ancestor-docstring code here class ListAPIView(GetNameMixin, generics.ListAPIView): pass class RetrieveAPIView(GetNameMixin, generics.RetrieveAPIView): pass </code></pre> <p>Note also that the <code>get_name</code> method is considered private, and is likely to change at some point in the future, so you would need to keep tabs on the release notes when upgrading, for any changes there. </p>
21,973,822
0
<p><a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.polyfit.html" rel="nofollow">numpy.polyfit</a></p> <blockquote> <p>Fit a polynomial p(x) = p[0] * x**deg + ... + p[deg] of degree deg to points (x, y). Returns a vector of coefficients p that minimises the squared error.</p> </blockquote> <p>Example from the docs: </p> <pre><code>&gt;&gt;&gt; x = np.array([0.0, 1.0, 2.0, 3.0, 4.0, 5.0]) &gt;&gt;&gt; y = np.array([0.0, 0.8, 0.9, 0.1, -0.8, -1.0]) &gt;&gt;&gt; z = np.polyfit(x, y, 3) &gt;&gt;&gt; z array([ 0.08703704, -0.81349206, 1.69312169, -0.03968254]) </code></pre>
1,927,735
0
<p>Given that characters can take a variable number of bytes this would be pretty tough to do without converting the bytes to characters with a <code>TextReader</code>.</p> <p>You could wrap up a <code>TextReader</code> and give it a <code>Seek</code> method that ensures enough characters have been loaded to satisfy each request.</p>
5,587,652
0
<p>This might be more of a process issue and less of a coding issue.</p> <p>You need to strictly separate the implementation process and the roll-out process during software development. The configuration files containing the passwords must be filled with the real passwords during roll-out, not before. The programmers can work with the password for the developing environment and the roll-out team changes those passwords once the application is complete. That way the real passwords are never disclosed to the people coding the application.</p> <p>If you cannot ensure that programmers do not get access to the live system, you need to encrypt the configuration files. The best way to do this depends on the programming language. I am currently working on a Java application that encrypts the .properties files with the appropriate functions from the <a href="http://www.owasp.org/index.php/Category%3aOWASP_Enterprise_Security_API" rel="nofollow">ESAPI project</a> and I can recommend that. If you are using other languages, you have to find equivalent mechanisms.</p> <p>Any time you want to change passwords, an administrator generates a new file and encrypts it, before copying the file to the server.</p> <p>In case you want maximum security and do not want to store the key to decrypt the configuration on your system, an administrator can supply it whenever the system reboots. But this might take things too far, depending on your needs.</p>
12,108,141
0
<p>you may want to apply a force or an impulse (which is a force applied in a time stamp only). See this link <a href="http://www.iforce2d.net/b2dtut/jumping" rel="nofollow">http://www.iforce2d.net/b2dtut/jumping</a></p>
3,370,623
0
<p>I think the answer is that this is just a bug in the Microsoft IIS API that we have to live with. I've opened a bug report on MS connect which has had 2 upvotes, however MS have shown no interest in this (and I doubt they will any time soon).</p> <p>I don't believe there is a workaround for getting the actual state (as the question asks). Some have suggested that I should probe port 21, but this only tells me if there is <em>an</em> FTP server running, not <em>what</em> FTP server is running (as you can have multiple sites) -- so in some cases, this approach is completely useless.</p> <p>The workaround to <em>stopping and starting</em> the site (which also causes a similar error) is to set auto-start to false on the FTP site and restart IIS (it's not great, but it works just fine).</p>
10,568,422
0
<p>The logical <a href="http://developer.android.com/reference/android/util/DisplayMetrics.html#density" rel="nofollow">density</a> of the display is given in the <code>DisplayMetrics</code> class, and can be retrieved with,</p> <pre><code>getResources().getDisplayMetrics().density </code></pre> <p>Thus, to convert <code>dp</code> to <code>px</code>, you would do,</p> <pre><code>int density = getResources().getDisplayMetrics().density; int px = (int) (dp * density); </code></pre> <p>To convert <code>px</code> to <code>dp</code>, just perform the inverse operation,</p> <pre><code>int dp = px/density; </code></pre>
16,287,730
0
<p>it appears that <code>var</code> is <code>None</code> in what you provided. Everything is correct, but <code>var</code> does not contain a string.</p>
16,030,123
0
<p><code>std::cin.ignore(100,'\n');</code> did the trick.</p>
19,654,087
0
How handle Log File in in selenium webdriver using java <p>I don't know how to handle log file in selenium webdriver using java .. i wanna perform following task in log file : - store label of each link of website page in log file - Read that stored label one by one </p> <p>is it possible in selenium ...?</p>
30,736,389
0
Ajax request not printing html response <p>I have an ajax request that fetches some data and returns a html response that I print out on the page. The problem is that for some reason the html response doesn't get printed, only textual data does. The correct response is being returned as I've checked in the browser console.</p> <p>Here is the ajax function:</p> <pre><code>function getRating(work_id, selectorToWriteTo) { $.ajax({ url: '/read/getRatingsForGivenWork', type: 'GET', dataType: 'html', async: true, data: { field1: work_id}, success: function (data) { //your success code $(selectorToWriteTo).html(data); }, error: function (xhr, ajaxOptions, thrownError) { alert("Error: " + thrownError); } }); } </code></pre> <p>function that returns the html data:</p> <pre><code> public function getRatingsForGivenWork() { $ratings = $this-&gt;getModel ( 'read', 'getRatingsForGivenWork', $_GET['field1']); if($ratings !== null) { print "&lt;div class=\"ui small star rating\" data-rating=\"" . $ratings ."\" data-max-rating=\"5\"&gt;Leave rating&lt;/div&gt;"; } else { print 0; } } </code></pre> <p>Where I invoke the ajax function:</p> <pre><code>&lt;div class="extra"&gt; &lt;script&gt; document.write(getRating(&lt;?php echo $row['works.work_id']; ?&gt;, '.extra')); &lt;/script&gt; &lt;/div&gt; </code></pre> <p>Response in Chrome developer tools:</p> <p><img src="https://i.stack.imgur.com/uvYJU.png" alt="enter image description here"></p> <p>Chrome console:</p> <p><img src="https://i.stack.imgur.com/wKdVA.png" alt="enter image description here"></p> <p>The right response comes back but it doesn't print the html on the page. Anyone know why this is?</p>
1,060,848
0
<p>A slightly cleaner format of the above:</p> <pre><code> private void amount_PaidTextBox_KeyPress(object sender, KeyPressEventArgs e) { e.Handled = !(Char.IsNumber(e.KeyChar) || (e.KeyChar==Keys.Back)); } </code></pre>
11,750,278
0
Merge and rebase remote branches <p>I have one local branch <code>master</code>, and track two remote branches <code>master</code> and <code>dev-me</code>. Meanwhile, another developer has his own local <code>master</code>, and tracks the same remote <code>master</code> and his own dedicate remote branch <code>dev-other</code>.</p> <p>From time to time, we each respectively push from own local <code>master</code> to remote dev branch (i.e. <code>dev-me</code> or <code>dev-other</code>). We then want to merge our remote <code>dev-x</code> branches into the remote <code>master</code> branch.</p> <p>I am thinking to do the following:</p> <ol> <li><p>Either of us <em>merges</em> his remote <code>dev-x</code> branch into remote <code>master</code> branch.</p></li> <li><p>The other person <em>rebases</em> from this merged remote <code>master</code> branch to his own remote <code>dev-x</code> branch.</p></li> <li><p>The same person from step 2) <em>merges</em> back to the remote <code>master</code> branch.</p></li> </ol> <p>Is this a correct approach?</p>
27,787,123
0
<p>I think you have a problem with quotes in your statement text. Look at this excerpt based on your code when I tested in the Immediate window:</p> <pre class="lang-sql prettyprint-override"><code>intYear = 2015 ? "WHERE [Market Segment]= 'CMS Part D (CY ' &amp; (intYear) &amp; ')'" WHERE [Market Segment]= 'CMS Part D (CY ' &amp; (intYear) &amp; ')' </code></pre> <p>That can't be right. And when Access tries to execute the query and sees <em>intYear</em>, it interprets that to be a parameter because the db engine knows nothing about a VBA variable named <em>intYear</em>.</p> <p>I think it should look like this:</p> <pre class="lang-sql prettyprint-override"><code>? "WHERE [Market Segment]= 'CMS Part D (CY " &amp; (intYear) &amp; ")'" WHERE [Market Segment]= 'CMS Part D (CY 2015)' </code></pre> <p>I encourage you to follow KevenDenen's advice to add <code>Debug.Print strCount2</code> to the code after it has finished building the <code>strCount2</code> string. Then you can run the code and view the text of the completed statement in the Immediate window. (You can use <kbd>Ctrl</kbd>+<kbd>g</kbd> to go to the Immediate window.) It helps tremendously to examine the actual statement your code is asking Access to execute.</p>
21,388,883
0
<p>No, this is not possible. There is no API to programatically set the user's alarm.</p> <p>However, you can invoke the clock application to a specific view-state (alarm screen) and allow the user to set the alarm themselves.</p> <p>Here's how to invoke an app: <a href="https://developer.blackberry.com/native/documentation/cascades/device_platform/invocation/sending_invocation.html" rel="nofollow">https://developer.blackberry.com/native/documentation/cascades/device_platform/invocation/sending_invocation.html</a></p> <p>Here's the info on how to invoke the alarm clock: <a href="https://developer.blackberry.com/native/documentation/cascades/device_platform/invocation/clock.html" rel="nofollow">https://developer.blackberry.com/native/documentation/cascades/device_platform/invocation/clock.html</a></p>
10,220,362
0
<p>If I may expand on <a href="http://stackoverflow.com/users/987361/user987361">user987361</a>'s answer:</p> <p>From the <a href="https://developers.google.com/accounts/docs/OAuth2WebServer#offline">offline access</a> portion of the OAuth2.0 docs:</p> <blockquote> <p>When your application receives a refresh token, it is important to store that refresh token for future use. If your application loses the refresh token, it will have to re-prompt the user for consent before obtaining another refresh token. If you need to re-prompt the user for consent, include the <code>approval_prompt</code> parameter in the authorization code request, and set the value to <code>force</code>.</p> </blockquote> <p>So, when you have already granted access, subsequent requests for a <code>grant_type</code> of <code>authorization_code</code> will not return the <code>refresh_token</code>, even if <code>access_type</code> was set to <code>offline</code> in the query string of the consent page.</p> <p>As stated in the quote above, in order to obtain a <strong>new</strong> <code>refresh_token</code> after already receiving one, you will need to send your user back through the prompt, which you can do by setting <code>approval_prompt</code> to <code>force</code>.</p> <p>Cheers,</p> <p>PS This change was announced in a <a href="http://googlecode.blogspot.com/2011/10/upcoming-changes-to-oauth-20-endpoint.html">blog post</a> as well.</p>
21,450,295
0
<pre><code>struct A{ union B{ struct C { float x, y, z; } S; float xyz[3]; } U; int a; }; int main () { struct A v = { .U.S.x = 0.0f, .U.S.y = 123.234f, .U.S.z= 123.3f }; struct A w = { .U.xyz = {0.0f, 123.234f, 123.3f} }; printf("\n %f %f %f \n ",v.U.S.x, v.U.S.y ,v.U.S.z); } </code></pre>
6,444,854
0
<p>It's a bit confusing but I think the optional attribute (@ManyToOne, @Basic,...) is not used for schema generation by some JPA implementations.</p> <p>I think you need to use the @JoinColumn annotation and set nullable to false: <a href="http://download.oracle.com/javaee/6/api/javax/persistence/JoinColumn.html" rel="nofollow">http://download.oracle.com/javaee/6/api/javax/persistence/JoinColumn.html</a></p> <p>(Or @Column in non-join cases: <a href="http://download.oracle.com/javaee/6/api/javax/persistence/Column.html" rel="nofollow">http://download.oracle.com/javaee/6/api/javax/persistence/Column.html</a>)</p>
28,095,927
0
<p>Concatenate string properly:</p> <p>Replace this:</p> <pre><code>var newImage = "&lt;img src='https://api.twilio.com" + data + "/&gt;"; // you're missing to close quote for src here ^^ </code></pre> <p>With this:</p> <pre><code>var newImage = "&lt;img src='https://api.twilio.com" + data + "' /&gt;"; </code></pre> <p>Or switch the quotes:</p> <pre><code>var newImage = '&lt;img src="https://api.twilio.com' + data + '" /&gt;'; </code></pre>
599,194
0
<p>Try going:</p> <pre><code>$var=$d-&gt;say(); echo $var; </code></pre>
10,692,038
0
<p>Here is an example script:</p> <pre><code>&lt;script type="text/javascript"&gt; if (top != self) { var wicket = top.Wicket; if (wicket &amp;&amp; wicket.Window) { var modal = wicket.Window.get(); if (modal) { modal.close(); } } top.location.href = location.href; } &lt;/script&gt; </code></pre>
9,367,102
0
<p>The simplest way is to hook up to the <a href="http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&amp;l=EN-US&amp;k=k%28MICROSOFT.WIN32.SYSTEMEVENTS.POWERMODECHANGED%29;k%28POWERMODECHANGED%29;k%28TargetFrameworkMoniker-%22.NETFRAMEWORK,VERSION=V4.0%22%29;k%28DevLang-CSHARP%29&amp;rd=true" rel="nofollow">Microsoft.Win32.SystemEvents.PowerModeChanged</a>. However, you need to look at the SystemInformation.PowerStatus value to figure out what changed.</p>
22,480,996
0
<p>You can use <strong>Having Clause</strong> in Conjunction with <strong>Group By</strong></p> <pre><code>select ename from emp where sal &gt; any (select avg(sal) from emp group by deptno) having count(*)&gt;4; </code></pre>
27,574,559
0
<p>The reason why <code>respond_to?(:say_hello)</code> is returning <code>false</code> is due to the fact <code>class A</code> has <code>say_hello</code> as instance method and since you are extending <code>class B</code> the <code>create_say_hello_if_not_exists</code> is declared as class method and it does not find <code>say_hello</code>. </p> <p>Changing the code to the following would do the trick. I'm declaring <code>say_hello</code> in <code>class A</code> as class method and am calling it in a static manner.</p> <pre> module B def create_say_hello_if_not_exists puts respond_to?(:say_hello) define_method :say_hello do puts 'hello' end unless respond_to?(:say_hello) end end class A def self.say_hello puts 'hi' end extend B create_say_hello_if_not_exists end A.say_hello </pre>
1,065,148
0
<p>Rihan is partially correct...</p> <p>In your Project Property page, Web tab: Enable Edit and Continue</p> <p>If checked - The Development server will close when the app (not VS) stops.</p> <p>If unchecked - Development server keeps running</p>
10,822,468
0
<p>vartical-align is very particular to get to work (which is why I almost never use it)</p> <p>On the span: <code>position:absolute; bottom:0; right:0;</code></p> <p>and put a height/width on the parent div and you'll be all set</p>
22,967,021
0
<p>I ran into the same issue - all of the tutorials seem to be based on Node.js. However, I found some excellent resources to get started with from the <a href="https://chutzpah.codeplex.com/">Chutzpah Javascript Test Runner</a> project. Chutzpah appears to support QUnit, Jasmine, and Mocha testing frameworks. Essentially, install the packages/extensions listed below, follow the Jasmine tutorials for building out unit tests on the Pivotal Gist (or the Angular demo), and you'll be able to right-click (to pull up the context menu) on a Javascript test and run it (selecting the option "Run JS Tests"). Hope these resources help!</p> <p>Visual Studio Extensions:</p> <ul> <li><a href="http://visualstudiogallery.msdn.microsoft.com/f8741f04-bae4-4900-81c7-7c9bfb9ed1fe">Chutzpah Test Adapter for Test Explorer</a> (VS2012/2013 support)</li> <li><a href="http://visualstudiogallery.msdn.microsoft.com/71a4e9bd-f660-448f-bd92-f5a65d39b7f0">Chutzpah Context Menu Extension</a> (VS2012/2013 support)</li> <li><a href="https://www.nuget.org/packages/jasmine-js/">Jasmine NuGet Package</a></li> </ul> <p>Tutorials</p> <ul> <li><a href="http://blog.tyukhnin.com/2013/01/dev-nuget-jasmin-chutzpah-js-unit.html">Yuriy Tyukhnin's tutorial</a> </li> <li><a href="http://www.rosher.co.uk/post/2013/10/22/Unit-Testing-AngularJS-with-Jasmine-Chutzpah-and-Visual-Studio.aspx">Rosher Consulting's tutorial</a></li> </ul> <p><strong>Edit</strong>: Because it has been linked here, I also threw a blog post together about this - <a href="http://codeforcoffee.org/setting-up-angular-js-jasmine-and-karma-in-visual-studio/">http://codeforcoffee.org/setting-up-angular-js-jasmine-and-karma-in-visual-studio/</a></p>
31,354,359
0
<p>"location" directive should be inside a 'server' directive, e.g.</p> <pre><code>server { listen 8765; location / { resolver 8.8.8.8; proxy_pass http://$http_host$uri$is_args$args; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } </code></pre>
10,625,584
1
Embedding python in multithreaded C application <p>I'm embedding the python interpreter in a multithreaded C application and I'm a little confused as to what APIs I should use to ensure thread safety.</p> <p>From what I gathered, when embedding python it is up to the embedder to take care of the GIL lock before calling any other Python C API call. This is done with these functions:</p> <pre><code>gstate = PyGILState_Ensure(); // do some python api calls, run python scripts PyGILState_Release(gstate); </code></pre> <p>But this alone doesn't seem to be enough. I still got random crashes since it doesn't seem to provide mutual exclusion for the Python APIs.</p> <p>After reading some more docs I also added: </p> <pre><code>PyEval_InitThreads(); </code></pre> <p>right after the call to <code>Py_IsInitialized()</code> but that's where the confusing part comes. The docs state that this function:</p> <blockquote> <p>Initialize and acquire the global interpreter lock</p> </blockquote> <p>This suggests that when this function returns, the GIL is supposed to be locked and should be unlocked somehow. but in practice this doesn't seem to be required. With this line in place my multithreaded worked perfectly and mutual exclusion was maintained by the <code>PyGILState_Ensure/Release</code> functions.<br> When I tried adding <code>PyEval_ReleaseLock()</code> after <code>PyEval_ReleaseLock()</code> the app dead-locked pretty quickly in a subsequent call to <code>PyImport_ExecCodeModule()</code>.</p> <p>So what am I missing here? </p>
39,252,109
0
<h2>Solution #1: Star unpacking for one-line initialization</h2> <p>Star-unpacking will work, but only if all the fields in your structure are integer types. In Python 2.x, <code>c_char</code> cannot be initialized from an <code>int</code> (it works fine in 3.5). If you change the type of <code>state</code> to <code>c_byte</code>, then you can just do:</p> <pre><code>mystr = MyStruct(*myarr) </code></pre> <p>This doesn't actually benefit from any <code>array</code> specific magic (the values are briefly converted to Python <code>int</code>s in the unpacking step, so you're not reducing peak memory usage), so you'd only bother with an <code>array</code> if initializing said <code>array</code> was easier than directly reading into the structure for whatever reason.</p> <p>If you go the star unpacking route, reading <code>.state</code> will now get you <code>int</code> values instead of len 1 <code>str</code> values. If you want to initialize with <code>int</code>, but read as one character <code>str</code>, you can use a protected name wrapped in a <code>property</code>:</p> <pre><code>class MyStruct(Structure): _fields_ = [... ("_state", c_byte), # "Protected" name int-like; constructor expects int ...] @property def state(self): return chr(self._state) @state.setter def state(self, x): if isinstance(x, basestring): x = ord(x) self._state = x </code></pre> <p>A similar technique could be used without <code>property</code>s by defining your own <code>__init__</code> that converted the <code>state</code> argument passed:</p> <pre><code>class MyStruct(Structure): _fields_ = [("init", c_uint), ("state", c_char), ...] def __init__(self, init=0, state=b'\0', *args, **kwargs): if not isinstance(state, basestring): state = chr(state) super(MyStruct, self).__init__(init, state, *args, **kwargs) </code></pre> <h2>Solution #2: Direct <code>memcpy</code>-like solutions to reduce temporaries</h2> <p>You can use some <code>array</code> specific magic to avoid the temporary Python level <code>int</code>s though (and avoid the need to change <code>state</code> to <code>c_byte</code>) without real file objects using a fake (in-memory) file-like object:</p> <pre><code>import io mystr = MyStruct() # Default initialize # Use BytesIO to gain the ability to write the raw bytes to the struct # because BytesIO's readinto isn't finicky about exact buffer formats io.BytesIO(myarr.tostring()).readinto(mystr) # In Python 3, where array implements the buffer protocol, you can simplify to: io.BytesIO(myarr).readinto(mystr) # This still performs two memcpys (one occurs internally in BytesIO), but # it's faster by avoiding a Python level method call </code></pre> <p>This only works because your non-<code>c_int</code> width attributes are followed by <code>c_int</code> width attributes (so they're padded out to four bytes anyway); if you had two <code>c_ubyte</code>/<code>c_char</code>/etc. types back to back, then you'd have problems (because one value of the <code>array</code> would initialize two fields in the struct, which does not appear to be what you want).</p> <p>If you were using Python 3, you could benefit from <code>array</code> specific magic to avoid the cost of both unpacking and the two step <code>memcpy</code> of the <code>BytesIO</code> technique (from <code>array</code> -> <code>bytes</code> -> struct). It works in Py3 because Py3's <code>array</code> type supports the buffer protocol (it didn't in Py2), and because Py3's <code>memoryview</code> features a <code>cast</code> method that lets you change the format of the <code>memoryview</code> to make it directly compatible with <code>array</code>:</p> <pre><code>mystr = MyStruct() # Default initialize # Make a view on mystr's underlying memory that behaves like a C array of # unsigned ints in native format (matching array's type code) # then perform a "memcpy" like operation using empty slice assignment # to avoid creating any Python level values. memoryview(mystr).cast('B').cast('I')[:] = myarr </code></pre> <p>Like the <code>BytesIO</code> solution, this only works because your fields all happen to pad to four bytes in size</p> <h2>Performance</h2> <p>Performance-wise, star unpacking wins for small numbers of fields, but for large numbers of fields (your case has a couple dozen), direct <code>memcpy</code> based approaches win out; in tests for a 23 field class, the <code>BytesIO</code> solution won over star unpacking on my Python 2.7 install by a factor of 2.5x (star unpacking was 2.5 microseconds, <code>BytesIO</code> was 1 microsecond).</p> <p>The <code>memoryview</code> solution scales similarly to the <code>BytesIO</code> solution, though as of 3.5, it's slightly slower than the <code>BytesIO</code> approach (likely a result of the need to construct several temporary <code>memoryview</code>s to perform the necessary casting operations and/or the <code>memoryview</code> slice assignment code being general purpose for many possible formats, so it's not simple <code>memcpy</code> in implementation). <code>memoryview</code> might scale better for much larger copies (if the losses are due to the fixed <code>cast</code> overhead), but it's rare that you'd have a struct large enough to matter; it would only be in more general purpose copying scenarios (to and from <code>ctypes</code> arrays or the like) that <code>memoryview</code> would potentially win.</p>
21,826,359
0
<p>My suggestion: don't take this approach. It feels dirty. Go back to the drawing board if you can.</p> <p>With that in mind, you won't be able to interject a merge like you want with the existing JSON marshalling support in Spray. You'll need to stitch it together yourself. Something like this should at least point you in the right direction (provided it be the direction you must go):</p> <pre><code>import org.json4s.JsonAST._ import org.json4s.JsonDSL._ def mergedParametersAndEntity[T](implicit m:Manifest[T]): Directive1[T] = { entity(as[JObject]).flatMap { jObject =&gt; parameterMap flatMap { params =&gt; val left = JObject(params.mapValues { v =&gt; JString(v) }.toSeq : _*) provide(left.merge(jObject).extract[T]) } } } </code></pre>
38,392,683
0
Why can I assign a string literal whose length is less than the array itself? <p>I'm a bit baffled that this is allowed:</p> <pre><code>char num[6] = "a"; </code></pre> <p>What is happening here? Am I assigning a pointer to the array or copying the literal values into the array (and therefore I'm able to modify them later)?</p>
23,700,348
0
<p>I've created an overly complex solution that allows you to create a helper function to do an inline type of rang value finder. The ranger function takes the cut points you want to split on and then returns a function that will choose the value of the parameter based on which interval it falls. It primarily uses <code>findInterval</code> but unfortunately you inequalities don't exactly line up with how <code>findInterval</code> likes to do them so I had to do some fiddling.</p> <pre><code>#meta-helper function ranger&lt;-function(rng) { function(x, ...) { dots&lt;-list(...) stopifnot(ncol(dots)==length(rng)+1) m&lt;-findInterval(x, rng)+1 ex&lt;-match(x, rng); if (any(!is.na(ex))) { m[which(ex&gt;1)]&lt;-ex[which(ex&gt;1)] } out&lt;-rep(NA, length(x)) for(i in seq_along(dots)) { out[m==i]&lt;-rep(dots[[i]], length.out=length(x))[m==i] } out; } } #helper function abc&lt;-ranger(c(600,4000)) #implementation 1 x&lt;-c(100,2000,5000) a&lt;-abc(x, 0.01, 0.1, 0.12)*x + abc(x, 0, 118, -162); a; #implementation 2 a&lt;-abc(x, x * 0.01, 118 + (x*0.1), 318 + ((x-4000)*0.12)); a; </code></pre> <p>So while it may not be the best choice in this case, i might be useful if you have a bunch of different ranges or something like that.</p>
23,734,395
0
<p>Happens if you compile for different machine types - for example 32 vs 64.</p> <p>If you have 32bits app, add --machine 32 to the nvcc param and it will be fine.</p>
4,017,695
0
<p>Put your code in a closure, like this:</p> <pre><code>(function (){ if(already_done){ return; } doSomeStuff(); })(); </code></pre> <p>It should work.</p>
24,658,665
0
<p>Try using the 'ren' command. So ren filename.txt filename.cat. </p>
930,932
0
Returning different data type depending on the data (C++) <p>Is there anyway to do something like this?</p> <pre><code>(correct pointer datatype) returnPointer(void* ptr, int depth) { if(depth == 8) return (uint8*)ptr; else if (depth == 16) return (uint16*)ptr; else return (uint32*)ptr; } </code></pre> <p>Thanks</p>
4,411,861
0
<p>You can include newlines in strings by explicitly specifying them:</p> <pre><code>&lt;string name="hint"&gt;Manny, Moe and Jack\nThey know what I\'m after.&lt;/string&gt; </code></pre> <p>Newlines in the XML are treated as spaces.</p>
2,013,934
0
How to get assembly version of a project in a visual studio 2008 deployment project <p>I have a deployment project in visual studio 2008 that installs several C# projects. Among other things, I'd like it to write projects assembly version to registry.</p> <p>Is there a way to automatically find out whats the projects assembly version (written in AssemblyInfo.cs) and write that as value of a registry property?</p> <p>If not, is there any way to do this better than by hand? It is important that these values are correct because they are used by our updating software.</p> <p>Thank you.</p> <p><strong>EDIT</strong>: I'm not sure I was completely clear in my question. I don't want to get this number and store it to a string. I want to write it to registry with Deployment Projects Registry Editor (not sure if that's the official name, you can get to it by right clicking the deployment project in solution explorer and navigating to View->Registry)</p>
14,192,908
0
<p>You can change offset and width of your toolbar, if you want to use customview (initWithCustomView) </p> <pre><code>[myToolBar setFrame:CGRectMake(-10, 0, [UIScreen mainScreen].bounds.size.width+10, 44)]; </code></pre>
3,629,215
0
<p>The layer you are looking for is https. Just make sure the requests go over https if the data is sensitive.</p>
19,012,720
0
Golang query multiple databases with a JOIN <p>Using the golang example below, how can I query (JOIN) multiple databases. For example, I want to have the relation <code>db1.username.id = db2.comments.username_id</code>.</p> <pre><code>id := 123 var username string err := db.QueryRow("SELECT username FROM users WHERE id=?", id).Scan(&amp;username) switch { case err == sql.ErrNoRows: log.Printf("No user with that ID.") case err != nil: log.Fatal(err) default: fmt.Printf("Username is %s\n", username) } </code></pre>
14,663,852
0
Get Google Document as HTML <p>I had a wild idea that I could build a website blog for an unsophisticated user friend using Google Drive Documents to back it. I was able to create a contentService that compiles a list of documents. However, I can't see a way to convert the document to HTML. I know that Google can render documents in a web page, so I wondered if it was possible to get a rendered version for use in my content service. </p> <p>Is this possible?</p>
11,961,081
0
<p>You'll need to use Tomcat 7 (or any other container that supports Servlet 3.0 onwards) to use that style of programming. Look at the asynchronous request processing parts of the Servlet 3.0 specification.</p> <p>Prior to Servlet 3.0, request/response processing is synchronous. i.e. you cannot 'park' a request/response pair and then handle them later in a different thread. Pretty much as soon as your doPost() method exits, Tomcat will recycle the request and response objects ready to use them to handle a new request.</p>
39,640,792
0
<p>Thanks for the inputs. I ended up removing the if statement for the ValidationSummary(). To handle both what I ended up doing was, add a second little script similar to the shown above but for the window.onload event. This way it catches the ModelState errors while the one above handles the obtrusive.</p>
18,966,534
0
<p>Look at the SQL debug output, the regions are being retrieved using separate queries, that's how Cakes ORM currently works.</p> <p>In your case there's a relatively simple workaround. Just <a href="http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#creating-and-destroying-associations-on-the-fly">create a proper association on the fly</a>, for example <code>Profile belongsTo Region</code>.</p> <p>Here's an (untested) example, it adds a <code>belongsTo</code> association with the <code>foreignKey</code> option set to <code>false</code> in order to disable the automatic foreign key generation by the ORM, this is necessary as it would otherwise look for something like <code>Profile.region_id</code>. Note that consequently the <code>contain</code> config has to be changed too!</p> <pre><code>$this-&gt;Profile-&gt;bindModel(array( 'belongsTo' =&gt; array( 'Region' =&gt; array( 'foreignKey' =&gt; false, 'conditions' =&gt; array('Region.id = Store.region_id') ), ) )); $this-&gt;Paginator-&gt;settings = array( 'conditions' =&gt; array('Profile.job_title_id' =&gt; '1'), 'contain' =&gt; array('Store', 'Region') ); </code></pre> <p>That should generate a proper query that includes the <code>stores</code> as well as the <code>regions</code> table, making it possible to sort on <code>Region.name</code>. Note that the resulting array will be a little different, <code>Region</code> will not be nested in <code>Store</code>, everything will be placed in the same level, ie:</p> <pre><code>Array ( [Profile] =&gt; Array ( .... ) [Store] =&gt; Array ( .... ) [Region] =&gt; Array ( .... ) ) </code></pre> <p>Either you modify your view code accordingly, or you transform the retrieved data before passing it to the view. A third option would be to include a nested <code>Region</code> in the <code>contain</code> config, however that would result in additional queries that are totally unnecessary as the data was already fetched with the main query, so I wouldn't recommend that.</p>
23,643,387
0
<p>This should do the trick:</p> <pre><code>d3.csv("wlythree.csv", function(data) { var values = []; values = data.map(function(d) { return d.percentage; }); console.log(values) }); </code></pre> <p>It yields:</p> <pre><code>["0.275862068965517", "0.137931034482759", ...] </code></pre> <p>EDIT: placed declaration of <code>values</code> inside the callback since the csv loading is asynchronous and that better reflects the script flow.</p>
34,608,908
0
<p>The value of the <code>SOAPAction</code> header is wrong. The correct value should be given in the WSDL for each operation. For example <code>http://tempuri.org/HelloWorld</code> for the <code>HelloWorld</code> operation</p> <pre><code>&lt;wsdl:operation name="HelloWorld"&gt; &lt;soap:operation soapAction="http://tempuri.org/HelloWorld" style="document" /&gt; &lt;wsdl:input&gt; </code></pre> <p>or <code>http://tempuri.org/Addweb</code> for the <code>Addweb</code> operation</p>
11,614,708
0
<p>Try this,</p> <pre><code>var user = document.myForm.un.value; </code></pre> <p>I'm not sure if you've already heard of JQuery but I would recommend you use it. Check this out <a href="http://jquery.com/" rel="nofollow">http://jquery.com/</a>.</p>
12,273,356
0
<p>Not the code generated by the async and await keyword themselves, no. They create code that runs on your the current thread, assuming it has a synchronization context. If it doesn't then you actually do get threads, but that's using the pattern for no good reason. The <em>await expression</em>, what you write on the right side of the await keyword causes threads to run.</p> <p>But that thread is often not observable, it may be a device driver thread. Which reports that it is done with a I/O completion port. Pretty common, I/O is always a good reason to use await. If not already forced on you by WinRT, the real reason that async/await got added.</p> <p>A note about "having a synchronization context". You have one on a thread if the SynchronizationContext.Current property is not null. This is almost only ever the case on the main thread of a gui app. Also the only place where you normally ever worry about having delays not freeze your user interface.</p>
31,153,579
0
<p><code>NSTimer</code> that calls a selector on the current threads run loop. It may not be 100% precise time-wise as it attempts to dequeue the message from the run loop and perform the selector.</p>
15,080,607
0
Ember Object in path STRING could not be found or was destroyed <p>I have a small application where I'm getting translations json for a locale and updating Ember.STRINGS. Am I doing something wrong? </p> <pre><code>$.get("http://localhost:8000/translations.json", {locale : locale}, function (data) { Ember.set('STRINGS', data) ; }); </code></pre> <p>In 0.9.5 I was doing </p> <blockquote> <pre><code>Ember.STRINGS = data </code></pre> </blockquote> <p>; and it seemed to work. When I changed it to 1.0.0 a lot of things started crashing around. Both of these don't work. </p> <blockquote> <pre><code>Ember.STRINGS = data ; Ember.set('STRINGS', data) ; </code></pre> </blockquote>
33,681,443
0
<p>Have you tried any of these techniques?</p> <p>This is from <a href="https://msdn.microsoft.com/en-us/data/jj574232.aspx?f=255&amp;MSPPError=-2147217396" rel="nofollow">this MSDN page about eager loading</a></p> <pre><code>using (var context = new BloggingContext()) { // Load all blogs and related posts var blogs1 = context.Blogs .Include(b =&gt; b.Posts) .ToList(); // Load one blogs and its related posts var blog1 = context.Blogs .Where(b =&gt; b.Name == "ADO.NET Blog") .Include(b =&gt; b.Posts) .FirstOrDefault(); // Load all blogs and related posts // using a string to specify the relationship var blogs2 = context.Blogs .Include("Posts") .ToList(); // Load one blog and its related posts // using a string to specify the relationship var blog2 = context.Blogs .Where(b =&gt; b.Name == "ADO.NET Blog") .Include("Posts") .FirstOrDefault(); } </code></pre> <p><br></p> <p><strong>Some remarks on lazy and eager loading</strong></p> <p>Generelly I tend to work without lazy loading. I like to know when my entities are loaded and when not (eager loading).</p> <p>Lazy loading can be turned off </p> <ul> <li><p>completely by setting the respective property on the <code>DbContext</code>:</p> <p><code>this.Configuration.LazyLoadingEnabled = false;</code></p></li> <li><p>for a specific entity when the navigation property is not marked virtual. For more info, see the linked MSDN article</p></li> </ul>
1,812,894
0
<p>Why do you want to know, what kind of database field you are using? Are you storing information from the form through raw sql? You should have some model, that you are storing information from the form and it will do all the work for you.</p> <p>Maybe you could show some form code? Right now it's hard to determine, what exactly you are trying to do.</p>
24,946,289
0
<p>It's not ideal but I compare the page text against following regex since on my setup that text accompanies web page errors: </p> <pre><code>(?:(access is denied)|(access is forbidden)|(server error)|(not found)) </code></pre>
15,063,375
0
Jenkins + selenium tests with failsafe plugin <p>I have a Jenkins platform which calls maven to make unit tests (with surefire plugin) and integration tests (with failsafe plugin). When there is an error in the integration tests, Jenkins considers the build as successfull. Is this behavior normal? I'd prefer it considers the build as unstable. More generally, do you know how Jenkins read and interprets the result of the build to consider a build as successfull or unstable? I read somewhere on the net that the failsafe reports must be redirected to the surefire report path. I did id but the problem is still here.</p> <p>pom.xml :</p> <pre class="lang-xml prettyprint-override"><code>[...] &lt;plugin&gt; &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt; &lt;version&gt;2.10&lt;/version&gt; &lt;configuration&gt; &lt;disableXmlReport&gt;false&lt;/disableXmlReport&gt; &lt;/configuration&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;default-test&lt;/id&gt; &lt;phase&gt;test&lt;/phase&gt; &lt;configuration&gt; &lt;includes&gt; &lt;include&gt;**/tests/**&lt;/include&gt; &lt;/includes&gt; &lt;excludes&gt; &lt;exclude&gt;**/testsIntegration/**&lt;/exclude&gt; &lt;/excludes&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-failsafe-plugin&lt;/artifactId&gt; &lt;version&gt;2.7.2&lt;/version&gt; &lt;configuration&gt; &lt;disableXmlReport&gt;false&lt;/disableXmlReport&gt; &lt;reportsDirectory&gt;${basedir}/target/surefire-reports&lt;/reportsDirectory&gt; &lt;includes&gt; &lt;include&gt;com/acelys/conventionsJuridiques/*.java&lt;/include&gt; &lt;!-- ... inclure les tests Selenium --&gt; &lt;/includes&gt; &lt;/configuration&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;integration-test&lt;/id&gt; &lt;phase&gt;integration-test&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;integration-test&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;includes&gt; &lt;include&gt;**/testsIntegration/**&lt;/include&gt; &lt;/includes&gt; &lt;excludes&gt; &lt;exclude&gt;**/tests/**&lt;/exclude&gt; &lt;/excludes&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; [...] </code></pre> <p>output of jenkins :</p> <pre><code>[...] mojoStarted org.apache.maven.plugins:maven-failsafe-plugin:2.7.2(integration-test) [INFO] [INFO] --- maven-failsafe-plugin:2.7.2:integration-test (integration-test) @ BaseContrats --- [INFO] Failsafe report directory: C:\jenkins_home\workspace\Base Contrats EXT JS MAVEN\target\surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running com.acelys.conventionsJuridiques.testsIntegration.connexion.TestConnexion Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 23.971 sec &lt;&lt;&lt; FAILURE! Results : Failed tests: testHomePage(com.acelys.conventionsJuridiques.testsIntegration.connexion.TestConnexion) Tests run: 1, Failures: 1, Errors: 0, Skipped: 0 [WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent! mojoSucceeded org.apache.maven.plugins:maven-failsafe-plugin:2.7.2(integration-test) mojoStarted org.apache.tomcat.maven:tomcat6-maven-plugin:2.1-SNAPSHOT(tomcat-shutdown) [INFO] [INFO] --- tomcat6-maven-plugin:2.1-SNAPSHOT:shutdown (tomcat-shutdown) @ BaseContrats --- 25 févr. 2013 09:32:08 org.apache.coyote.http11.Http11Protocol destroy INFO: Stopping Coyote HTTP/1.1 on http-8080 25 févr. 2013 09:32:08 org.apache.catalina.core.ApplicationContext log INFO: Closing Spring root WebApplicationContext 25 févr. 2013 09:32:08 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc mojoSucceeded org.apache.tomcat.maven:tomcat6-maven-plugin:2.1-SNAPSHOT(tomcat-shutdown) projectSucceeded BaseContrats:BaseContrats:1.0-SNAPSHOT sessionEnded [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2:07.408s [INFO] Finished at: Mon Feb 25 09:32:08 CET 2013 [INFO] Final Memory: 13M/51M [INFO] ------------------------------------------------------------------------ Projects to build: [MavenProject: BaseContrats:BaseContrats:1.0-SNAPSHOT @ C:\jenkins_home\workspace\Base Contrats EXT JS MAVEN\pom.xml] [JENKINS] Archiving C:\jenkins_home\workspace\Base Contrats EXT JS MAVEN\pom.xml to C:\jenkins_home\jobs\Base Contrats EXT JS MAVEN\modules\BaseContrats$BaseContrats\builds\2013-02-25_09-29-58\archive\BaseContrats\BaseContrats\1.0-SNAPSHOT\BaseContrats-1.0-SNAPSHOT.pom [JENKINS] Archiving C:\jenkins_home\workspace\Base Contrats EXT JS MAVEN\target\ConventionsJuridiques.war to C:\jenkins_home\jobs\Base Contrats EXT JS MAVEN\modules\BaseContrats$BaseContrats\builds\2013-02-25_09-29-58\archive\BaseContrats\BaseContrats\1.0-SNAPSHOT\BaseContrats-1.0-SNAPSHOT.war channel stopped Finished: SUCCESS </code></pre>
39,905,785
0
<p>Try this...you have problem with your IBOutlet...</p> <pre><code> @IBAction func Background Cyan(sender: UIButton) { view.backgroundColor = UIColor.cyan } </code></pre> <p>Paste this code into yourstoryboard and reconnect the outlet. This will do the job...</p>
6,932,626
0
<p>According to a similar <a href="http://www.mathworks.com/matlabcentral/newsreader/view_thread/164962" rel="nofollow noreferrer">discussion</a>, you can create a <a href="http://www.mathworks.com/help/techdoc/ref/uicontrol.html" rel="nofollow noreferrer">UICONTROL</a> <code>pushbutton</code> which has the advantage that it accepts HTML input string. Then using <a href="http://www.mathworks.com/matlabcentral/fileexchange/14317-findjobj-find-java-handles-of-matlab-graphic-objects" rel="nofollow noreferrer">FINDJOBJ</a>, we can fake the look of a clickable hyperlink:</p> <pre><code>fName = 'C:\path\to\file.pdf'; str = '&lt;html&gt;&lt;a href=""&gt;Click here for plot documentation&lt;/a&gt;&lt;/html&gt;'; figure('Resize','off', 'MenuBar','none') imshow('coins.png') hButton = uicontrol('Style','pushbutton', 'Position',[320 50 170 20], ... 'String',str, 'Callback',@(o,e)open(fName)); jButton = findjobj(hButton); jButton.setCursor( java.awt.Cursor(java.awt.Cursor.HAND_CURSOR) ); jButton.setContentAreaFilled(0); </code></pre> <p><img src="https://i.stack.imgur.com/qidGH.png" alt="screenshot"></p>
23,867,073
0
HTTP Request is a message within a request/response sequence, according to HTTP specification. May also refer an HttpRequest class in software frameworks and libraries that automates relevant functionality
2,821,321
0
<p>My teacher just emailed me back. For anyone wondering:</p> <pre><code>p(char[20]) Sample </code></pre> <p>Where 20 is the number of characters to print out.</p> <p>To print a C-style <code>NUL</code>-terminated string, you should also be able to do this:</p> <pre><code>print (char*) &amp;Sample printf "%s", &amp;Sample </code></pre>
7,512,013
0
<p>If you want a designed select I'd suggest you use jQuery then find a good plugin for customizing select boxes, try Googling "jquery design select". Have never used a jQuery plugin for this but I know they exist.</p> <p>Hope this helps!</p>
13,307,217
0
Good naming candidates for some common name like "info" and "manager"? <p>Some books said that we should avoid using names like <code>'XXInfo'</code>, <code>'XXManager'</code> (I forgot the book name), so I try to find the good candidates for these names, but I can't find some good substitute for <code>'UserInfo'</code>, <code>'ProxyManager'</code> or something like this.</p> <p>Could anyone give some good advice about how to select the more expressive names? I'm not a English-speaking man</p>
9,899,163
0
<p>I figured it out myself. It was very simple. Create individual lists for each company Add the web part of each individual lists to a page permission them by Target Audiences.</p>
1,265,041
0
Is it necessary to know flash designing for flex3? <p>I am from a programming background ,and newbie to flex3 . i would like to learn flex3 and develop some application using rails and flex3 . Is it necessary to know flash in order to learn flex3 or just learning Action script 3 would do ? .Can anybody tell what are the prerequisites to learn flex3 . Thanks in Advance.</p>
40,810,096
0
Adwords not displaying in android app <p>I have added the code for displaying Adwords ad in my android app</p> <pre><code>MobileAds.initialize(getApplicationContext(),"ca-app-key"); AdView mAdView = (AdView) findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder() .build(); mAdView.loadAd(adRequest); </code></pre> <p>After publishing my app in Android playstore and downloading it from there to check whether ads are appearing, i see no ads.I don't understand what is going wrong here.</p>
11,281,985
0
<p>In .Net, I found that the above method didn't work quite as expected. The trick was to use .Net's built-in input redirection - and not the <code>&lt;</code> operator. Here's what the code looks like now:</p> <pre class="lang-csharp prettyprint-override"><code>System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.EnableRaisingEvents = false; proc.StartInfo.FileName = "c:\\psftp.exe"; proc.StartInfo.UseShellExecute = false; proc.StartInfo.RedirectStandardInput = true; proc.StartInfo.Arguments = strIP + " -v -l " + strUsername + " -pw " + strPassword + " -b " + strBatchFilename; proc.Start(); StreamWriter myStreamWriter = proc.StandardInput; myStreamWriter.WriteLine("Y\n"); //override the public key question &lt;--- myStreamWriter.Close(); proc.WaitForExit(); proc.Close(); </code></pre>
27,146,719
0
<p>Got the answer... Need to add following lines After first block of code...</p> <pre><code>//reading Big Xml File $foo = $row-&gt;EDITABLE_INFO_SECTION-&gt;load(); write_log("This is xml output".$foo); </code></pre>
25,699,791
0
Why can't you name a function in Go "init"? <p>So, today while I was coding I found out that creating a function with the name <code>init</code> generated an error <code>method init() not found</code>, but when I renamed it to <code>startup</code> it all worked fine.</p> <p>Is the word "init" preserved for some internal operation in Go or am I'm missing something here?</p>
3,388,182
0
<p>This should answer it: <a href="http://en.wikipedia.org/wiki/Don%27t_repeat_yourself" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Don%27t_repeat_yourself</a> and <a href="http://www.codinghorror.com/blog/2007/03/curlys-law-do-one-thing.html" rel="nofollow noreferrer">http://www.codinghorror.com/blog/2007/03/curlys-law-do-one-thing.html</a></p> <blockquote> <p>Curly's Law, Do One Thing, is reflected in several core principles of modern software development:</p> <ul> <li><p><strong>Don't Repeat Yourself</strong></p> <p>If you have more than one way to express the same thing, at some point the two or three different representations will most likely fall out of step with each other. Even if they don't, you're guaranteeing yourself the headache of maintaining them in parallel whenever a change occurs. And change will occur. Don't repeat yourself is important if you want flexible and maintainable software.</p></li> <li><p><strong>Once and Only Once</strong></p> <p>Each and every declaration of behavior should occur once, and only once. This is one of the main goals, if not the main goal, when refactoring code. The design goal is to eliminate duplicated declarations of behavior, typically by merging them or replacing multiple similar implementations with a unifying abstraction.</p></li> <li><p><strong>Single Point of Truth</strong></p> <p>Repetition leads to inconsistency and code that is subtly broken, because you changed only some repetitions when you needed to change all of them. Often, it also means that you haven't properly thought through the organization of your code. Any time you see duplicate code, that's a danger sign. Complexity is a cost; don't pay it twice.</p></li> </ul> </blockquote>
15,997,560
0
Embedded Jetty and Jax-rs xml configuration <p>Hey guys i am trying to configure and run a Restful service using Embedded-jetty and jax-rs i found this <a href="http://java.dzone.com/articles/going-restnoxml-embedding" rel="nofollow">tutorial</a> and it works brilliantly however one of my requirements is to configure as much as possible through spring xml in the applicationContext.xml file.</p> <p>The part i would like to do in xml is the AppConfig.java class</p> <pre><code> @Configuration public class AppConfig { @Bean( destroyMethod = "shutdown" ) public SpringBus cxf() { return new SpringBus(); } @Bean public Server jaxRsServer() { JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance().createEndpoint( jaxRsApiApplication(), JAXRSServerFactoryBean.class ); factory.setServiceBeans( Arrays.&lt; Object &gt;asList( peopleRestService() ) ); factory.setAddress( '/' + factory.getAddress() ); factory.setProviders( Arrays.&lt; Object &gt;asList( jsonProvider() ) ); return factory.create(); } @Bean public JaxRsApiApplication jaxRsApiApplication() { return new JaxRsApiApplication(); } @Bean public StatsRestService peopleRestService() { return new StatsRestService(); } @Bean public StatsService peopleService() { return new StatsService(); } @Bean public JacksonJsonProvider jsonProvider() { return new JacksonJsonProvider(); } } </code></pre> <p>and where it is used</p> <pre><code>context.setInitParameter( "contextClass", AnnotationConfigWebApplicationContext.class.getName() ); context.setInitParameter( "contextConfigLocation", AppConfig.class.getName() ); </code></pre> <p>unfortunately i can not find any decent posts online on how to do this in XML, i would greatly appreciate some help.</p>
5,668,411
0
<p>Try <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BlendMode.html#LAYER" rel="nofollow">BlendMode.LAYER</a>, it saved many lives.</p>
260,528
0
<p>Don't use the session!!! If the user opens a second tab with a different request the session will be reused and the results will not be the ones that he/she expects. You can use a combination of ViewState and Session but still measure how much you can handle without any sort of caching before you resort to caching.</p>
2,328,372
0
<p>You can specify the dependencies of your Windows Service to have it require another service. If you specify a dependency on the EventLog service, then Windows will wait until your service is shut down before shutting down the Event Log.</p> <p><a href="http://kb2.adobe.com/cps/400/kb400960.html" rel="nofollow noreferrer">http://kb2.adobe.com/cps/400/kb400960.html</a> describes how to do it by modifying a few registry keys.</p> <blockquote> <p>Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services and locate the service that you need to set a dependency for. Open the 'DependOnService' key on the right side. If the selected service does not have a 'DependOnService' key, then create one by right-clicking and selecting New > Multi-String Value. In the value field, enter the names of all services that the current service will depend on. Each service name must be entered properly and on a separate line.</p> </blockquote>