pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
32,576,015
0
<pre><code>pv = function(fv, d, t) fv/(1+d)^t pv(1.05^2, 0.05, c(1, 2)) </code></pre> <p>Here's an explanation. Basically, in R, algebraic functions are applied automatically over numeric data, such that looping is often unnecessary.</p>
34,111,823
0
<p>You don't try to call <code>update_attribute</code> but <code>udpate_attribute</code>.</p> <p>You just have a simple misspelling in there.</p>
18,752,871
0
<p>Add <code>event.preventDefault()</code> at the top of your bind.</p> <p>Also, I recommend changing the event binding to the following:</p> <pre><code>$('#tbl').on('click', 'tr', function(event) { event.preventDefault(); // your code }); </code></pre>
30,764,822
0
<p>There are a few ways to loop through the worksheets in a workbook. I prefer the worksheet index method which simply identifies the worksheet according to its position in the worksheet queue.</p> <pre><code>Sub ExpirationYeartoColors() Dim w As Long, lr As Long, r As Long, vVAL As Variant For w = 1 To Worksheets.Count With Worksheets(w) lr = .Cells(Rows.Count, "A").End(xlUp).Row For r = 2 To lr vVAL = .Range("A" &amp; r) If IsNumeric(vVAL) Then 'treat numbers as numbers!!! vVAL = Int(vVAL) 'maybe vVAL = Year(vVAL) ? Select Case vVAL Case 2015 .Range("A" &amp; r).Interior.Color = RGB(181, 189, 0) Case 2016 .Range("A" &amp; r).Interior.Color = RGB(0, 56, 101) Case 2017 .Range("A" &amp; r).Interior.Color = RGB(0, 147, 178) Case 2018 .Range("A" &amp; r).Interior.Color = RGB(155, 211, 221) Case 2019 .Range("A" &amp; r).Interior.Color = RGB(254, 222, 199) Case 2020 .Range("A" &amp; r).Interior.Color = RGB(238, 242, 210) Case 2021 To 2080 .Range("A" &amp; r).Interior.Color = RGB(238, 242, 210) Case Else .Range("A" &amp; r).Interior.Pattern = xlNone End Select Else Select Case vVAL Case Is = "Unknown" .Range("A" &amp; r).Interior.Color = RGB(197, 200, 203) Case Is = "Available" .Range("A" &amp; r).Interior.Color = RGB(247, 150, 91) Case Is = "CommonArea" .Range("A" &amp; r).Interior.Color = RGB(230, 230, 230) Case Else .Range("A" &amp; r).Interior.Pattern = xlNone End Select End If Next r End With Next w On Error GoTo ErrorHandler ' Insert code that might generate an error here Exit Sub ErrorHandler: ' Insert code to handle the error here Resume Next End Sub </code></pre> <p>There are a number of unanswered questions; particularly about the nature of the data. However, you should be treating numbers as numbers especially if you want to use them in something like <code>Case "2020" To "2080"</code>. I've tried to determine the nature of the values and treated text and numbers separately. This compiles but with no sample data or answers to the comments posed I cannot guarantee its validity.</p> <p>Setting the <em>.pattern</em> to xlNone removes the interior fill rather than painting it white.</p> <p>See <a href="http://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba-macros">How to avoid using Select in Excel VBA macros</a> for more methods on getting away from relying on select and activate to accomplish your goals.</p>
20,637,850
0
<p>The string you are inserting aren't unicode</p> <p>Try this:</p> <pre><code>values.append(u"%s: \t%s" % (unicode(self[i[0]].label), unicode(self.cleaned_data[i[0]]) ) ) </code></pre>
30,877,296
0
Recursively iterate through arrays with Lodash <p>I want to use underscore to go iterate each item and append a period to the end of each fruit's name, and return an array. But there can be many nested levels. </p> <p><code>const</code> <code>NESTED =</code> <code>[ {name: 'Apple', items: [{ name: 'Orange', items: [{name: 'Banana'}] }]}, {name: 'Pear'}]</code></p> <p>My final should look like this:</p> <p><code>NESTED =</code> <code>[{ name: 'Apple.', items: [{name: 'Orange.', items: [{name: 'Banana.'}]}]}, { name: 'Pear.'}]</code></p> <p>There can be many and many items within. This is where I am stuck, my current underscore function only gets the first level, using ._map:</p> <pre><code>let items = _.map(NESTED, function(item){ return { // append the period here, but doesn't go deeper } }); </code></pre> <p>What is a good way to do this?</p>
32,637,640
0
<p>Your procedure takes two parameters. You are calling it without any parameters. Oracle thus looks for a procedure named <code>spfirst</code> that takes no parameters, finds no such procedure, and throws an error.</p> <p>Something like</p> <pre><code>DECLARE l_location nilesh.location%type; l_salary nilesh.monthly_salary%type; BEGIN spfirst( l_location, l_salary ); END; </code></pre> <p>should work. Of course, you'd generally want to do something with the variables that are returned. If you've enabled <code>dbms_output</code>, you could print them out</p> <pre><code>DECLARE l_location nilesh.location%type; l_salary nilesh.monthly_salary%type; BEGIN spfirst( l_location, l_salary ); dbms_output.put_line( 'Location = ' || l_location ); dbms_output.put_line( 'Salary = ' || l_salary ); END; </code></pre> <p>Be aware that your procedure will throw an error unless the <code>nilesh</code> table has exactly one row. It seems likely that you either want the procedure to take an additional parameter that is the key to the table so that the <code>select into</code> always returns a single row or that you want a function that returns a <code>sys_refcursor</code> rather than a procedure that has multiple <code>out</code> parameters.</p>
40,454,375
0
<p>No - it's not a prerequisite, even if you have a client app that consumes them - but imho it's a good idea.</p> <p>Microservices architecture is really nothing new as far as concept. Break up your monolithic app into many components that can iterate quickly at their own pace of development. Cloud native tooling and best practices have brought on this new notion of "microservices" with technology like containers and best practices like code as config.</p> <p>For client consumption across a broad spectrum of client capabilities, microservices are more easily and practically managed with a gateway because the gateway is a piece of infrastructure that acts as a control point for QoS concerns such as security, throttling, caching, payload pagination, lightweight transformation, tracebacks through header injection, etc.</p> <p>It's not necessary, but practically speaking if you have one already baked into your microservices development process as part of a cloud ready infrastructure - you address these things during development consideration and not in "big bang" fashion after the fact - a huge burden in the past for devop/ops folks to get their head around. It's such a burden, that that's why we've started our own solution that marries microservices development integration with management under ones cloud native platform and have a market for it</p>
35,817,151
0
<p>It seems that org.wisdom-framework can provide CPU utilization information and it's easy to add inside Spark. Check this out: <a href="https://github.com/wisdom-framework/wisdom/blob/master/extensions/wisdom-monitor/src/main/java/org/wisdom/monitor/extensions/dashboard/CpuGaugeSet.java" rel="nofollow">https://github.com/wisdom-framework/wisdom/blob/master/extensions/wisdom-monitor/src/main/java/org/wisdom/monitor/extensions/dashboard/CpuGaugeSet.java</a></p> <p>This is what I did:</p> <p>Add the following information at the end of the dependency section in ./core/pom.xml:</p> <pre><code> &lt;dependency&gt; &lt;groupId&gt;org.wisdom-framework&lt;/groupId&gt; &lt;artifactId&gt;wisdom-monitor&lt;/artifactId&gt; &lt;/dependency&gt; </code></pre> <p>and add these in at the end of the dependency section in ./pom.xml:</p> <pre><code> &lt;dependency&gt; &lt;groupId&gt;org.wisdom-framework&lt;/groupId&gt; &lt;artifactId&gt;wisdom-monitor&lt;/artifactId&gt; &lt;version&gt;0.9.1&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>Register cpuGaugeSet in org/apache/spark/metrics/source/JvmSource.scala</p> <pre><code> import org.wisdom.monitor.extensions.dashboard.CpuGaugeSet metricRegistry.registerAll(new CpuGaugeSet) </code></pre> <p>Build spark again. When you report jvm info for through metrics for the executor and driver, you will see three more stats files related to CPU utilization.</p>
25,356,739
0
javax.net.ssl.SSLException: hostname in certificate didn't match android <p>I am creating an android app in which i am sending data to the web service but i am getting error of javax.net.ssl.SSLException: hostname in certificate didn't match android here is my code</p> <pre><code> AsyncHttpClient clien= new AsyncHttpClient(); Log.i("URL", String.valueOf(base_url+"Race.svc/json/Race/Scanners/Add/"+series_event_raceid+"/"+qrCode)); clien.put(base_url+"Race.svc/json/Race/Scanners/Add/"+series_event_raceid+"/"+qrCode, new AsyncHttpResponseHandler() {} </code></pre> <p>where series_event_raceid=103 and qrcode=R12g***</p> <p>anyone please help me</p> <p>here is my logcat</p> <pre><code>08-18 10:06:24.272: W/System.err(5297): javax.net.ssl.SSLException: hostname in certificate didn't match: &lt;development.racerunner.com&gt; != &lt;racerunner.com&gt; OR &lt;racerunner.com&gt; 08-18 10:06:24.272: W/System.err(5297): at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:185) 08-18 10:06:24.272: W/System.err(5297): at org.apache.http.conn.ssl.BrowserCompatHostnameVerifier.verify(BrowserCompatHostnameVerifier.java:54) 08-18 10:06:24.272: W/System.err(5297): at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:114) 08-18 10:06:24.272: W/System.err(5297): at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:95) 08-18 10:06:24.272: W/System.err(5297): at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:388) 08-18 10:06:24.272: W/System.err(5297): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:165) 08-18 10:06:24.272: W/System.err(5297): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164) 08-18 10:06:24.272: W/System.err(5297): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119) 08-18 10:06:24.272: W/System.err(5297): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360) 08-18 10:06:24.272: W/System.err(5297): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555) 08-18 10:06:24.272: W/System.err(5297): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487) 08-18 10:06:24.272: W/System.err(5297): at com.loopj.android.http.AsyncHttpRequest.makeRequest(AsyncHttpRequest.java:98) 08-18 10:06:24.272: W/System.err(5297): at com.loopj.android.http.AsyncHttpRequest.makeRequestWithRetries(AsyncHttpRequest.java:112) 08-18 10:06:24.272: W/System.err(5297): at com.loopj.android.http.AsyncHttpRequest.run(AsyncHttpRequest.java:68) 08-18 10:06:24.272: W/System.err(5297): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422) 08-18 10:06:24.272: W/System.err(5297): at java.util.concurrent.FutureTask.run(FutureTask.java:237) 08-18 10:06:24.272: W/System.err(5297): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 08-18 10:06:24.272: W/System.err(5297): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 08-18 10:06:24.272: W/System.err(5297): at java.lang.Thread.run(Thread.java:811) 08-18 10:06:24.272: I/Fail camera arg1(5297): null 08-18 10:06:24.272: I/Fail camera arg2(5297): null 08-18 10:06:24.272: I/Fail camera arg3(5297): javax.net.ssl.SSLException: hostname in certificate didn't match: &lt;development.racerunner.com&gt; != &lt;racerunner.com&gt; OR &lt;racerunner.com&gt; </code></pre>
6,273,799
0
RequestScope() and Kernel.Get<> in Ninject <p>If I define a binding in ninject with <code>ReqeustScope()</code>, and then call <code>Kernel.Get&lt;T&gt;</code> on that type outside of a request what will the scope of the resolved object be?</p>
13,599,332
0
<p>try this:</p> <pre><code>DECLARE @YourTable table (RowID int, Layout varchar(200)) INSERT INTO @YourTable select ROW_NUMBER() over (order by (select 0)) as rn,replace(RIGHT(data,len(data)-CHARINDEX('_',data,1)),'_',',') from temptab ;WITH SplitSting AS ( SELECT RowID,LEFT(Layout,CHARINDEX(',',Layout)-1) AS Part ,RIGHT(Layout,LEN(Layout)-CHARINDEX(',',Layout)) AS Remainder FROM @YourTable WHERE Layout IS NOT NULL AND CHARINDEX(',',Layout)&gt;0 UNION ALL SELECT RowID,LEFT(Remainder,CHARINDEX(',',Remainder)-1) ,RIGHT(Remainder,LEN(Remainder)-CHARINDEX(',',Remainder)) FROM SplitSting WHERE Remainder IS NOT NULL AND CHARINDEX(',',Remainder)&gt;0 UNION ALL SELECT RowID,Remainder,null FROM SplitSting WHERE Remainder IS NOT NULL AND CHARINDEX(',',Remainder)=0 ) SELECT distinct cast(part as int) FROM SplitSting where len(part) &gt; 0 order by cast(part as int) </code></pre>
13,552,733
0
<p>The database files will be created in the <code>App_Data</code> folder. This will happen once you start writing something to it, not when the application is run. For example if you register a new user the database file will be created.</p>
1,917,084
0
<p>There's a lot here already, so maybe this is just a minor addition but here's what I find to be the biggest differences.</p> <p>Library:</p> <ul> <li>I put this first, because this in my opinion this is the biggest difference in practice. The C standard library is very(!) sparse. It offers a bare minimum of services. For everything else you have to roll your own or find a library to use (and many people do). You have file I/O and some very basic string functions and math. For everything else you have to roll your own or find a library to use. I find I miss extended containers (especially maps) heavily when moving from C++ to C, but there are a lot of other ones.</li> </ul> <p>Idioms:</p> <ul> <li>Both languages have manual memory (resource) management, but C++ gives you some tools to hide the need. In C you will find yourself tracking resources by hand much more often, and you have to get used to that. Particular examples are arrays and strings (C++ <code>vector</code> and <code>string</code> save you a lot of work), smart pointers (you can't really do "smart pointers" as such in C. You <em>can</em> do reference counting, but you have to up and down the reference counts yourself, which is very error prone -- the reason smart pointers were added to C++ in the first place), and the lack of RAII generally which you will notice everywhere if you are used to the modern style of C++ programming. <ul> <li>You have to be explicit about construction and destruction. You can argue about the merits of flaws of this, but there's a lot more explicit code as a result.</li> </ul></li> <li>Error handling. C++ exceptions can be tricky to get right so not everyone uses them, but if you do use them you will find you have to pay a lot of attention to how you do error notification. Needing to check for return values on all important calls (some would argue <em>all</em> calls) takes a lot of discipline and a lot of C code out there doesn't do it.</li> <li>Strings (and arrays in general) don't carry their sizes around. You have to pass a lot of extra parameters in C to deal with this.</li> <li>Without namespaces you have to manage your global namespace carefully. <ul> <li>There's no explicit tying of functions to types as there is with <code>class</code> in C++. You have to maintain a convention of prefixing everything you want associated with a type.</li> </ul></li> <li>You will see a lot more macros. Macros are used in C in many places where C++ has language features to do the same, especially symbolic constants (C has <code>enum</code> but lots of older code uses <code>#define</code> instead), and for generics (where C++ uses templates).</li> </ul> <p>Advice:</p> <ul> <li>Consider finding an extended library for general use. Take a look at <a href="http://library.gnome.org/devel/glib/stable/" rel="nofollow noreferrer">GLib</a> or <a href="http://apr.apache.org/" rel="nofollow noreferrer">APR</a>. <ul> <li>Even if you don't want a full library consider finding a map / dictionary / hashtable for general use. Also consider bundling up a bare bones "string" type that contains a size.</li> </ul></li> <li>Get used to putting module or "class" prefixes on all public names. This is a little tedious but it will save you a lot of headaches.</li> <li><p>Make heavy use of forward declaration to make types opaque. Where in C++ you might have private data in a header and rely on <code>private</code> is preventing access, in C you want to push implementation details into the source files as much as possible. (You actually want to do this in C++ too in my opinion, but C makes it easier, so more people do it.)</p> <p>C++ reveals the implementation in the header, even though it technically hides it from access outside the class.</p> <pre><code>// C.hh class C { public: void method1(); int method2(); private: int value1; char * value2; }; </code></pre> <p>C pushes the 'class' definition into the source file. The header is all forward declarations.</p> <pre><code>// C.h typedef struct C C; // forward declaration void c_method1(C *); int c_method2(C *); // C.c struct C { int value1; char * value2; }; </code></pre></li> </ul>
16,610,374
0
Error in an example from book - "Unexpected token {" <p>I was reading a book on JavaScript (recently started to learn). While running one of the examples from a book, I get an error. I'm using Chromium browser on Ubuntu, 14.0.835.202.</p> <p>Since I'm a newbie, I can't understand why there is an error. Thanks in advance.</p> <pre><code>Function.prototype.method = function (name, fn) { this.prototype[name] = fn; return this; }; var Person { this.name = name; this.age = age; }; Person. method ("getName", function { // error here - "Uncaught SyntaxError: Unexpected token {" return this.name; }). method ("getAge", function { return this.age; }); var alice = new Person ("Alice", 93); var bill = new Person ("Bill", 30); Person. method ("getGreeting", function { return "Hi" + this.getName() + "!"; }); alert (alice.getGreeting()); </code></pre> <p>EDIT:</p> <p>The solution gave me another question that I wanted to ask. For object declaration:</p> <pre><code>var Object = function (...) // line 1 { // code here }; </code></pre> <p>if the number of variables is so big that I don't want to list them in line 1, what can I do?</p>
18,963,437
0
<p>integers are not passed by reference in JavaScript meaning there is no way to change the interval by changing your variable.</p> <p>Simply cancel the setInterval and restart it again with the new time.</p> <p>Example can be found here: <a href="http://jsfiddle.net/Elak/yUxmw/2/" rel="nofollow">http://jsfiddle.net/Elak/yUxmw/2/</a></p> <pre><code>var Interval; (function () { var createInterval = function (callback, time) { return setInterval(callback, time); } Interval = function (callback, time) { this.callback = callback; this.interval = createInterval(callback, time); }; Interval.prototype.updateTimer = function (time) { clearInterval(this.interval); createInterval(this.callback, time); }; })(); $(document).ready(function () { var inter = new Interval(function () { $("#out").append("&lt;li&gt;" + new Date().toString() + "&lt;/li&gt;"); }, 1000); setTimeout(function () { inter.updateTimer(500); }, 2000); }); </code></pre>
22,179,175
0
C# How can I make an extension accept IEnumerable instead of array for params <p>Having this extension </p> <pre><code> public static bool In&lt;T&gt;(this T t, params T[] values) { return values.Contains(t); } </code></pre> <p>wanted it to accept IEnumerable and casting to array if needed inside the extension, but I don't know how to use the params keyword for that.</p> <p>Tryed :</p> <pre><code> public static bool In&lt;T&gt;(this T t, params IEnumerable&lt;T&gt; values) { return values.Contains(t); } </code></pre> <p>but this generates a compile-time error : <strong>The parameter array must be a single dimensional array</strong></p> <p>Is there any way to make the extension method support IEnumerable params ? if not, why not ?</p>
29,047,126
0
<p>The callback in findOne happens in the future, it is async. You must render inside said callback for the data to exist.</p> <pre><code> User.findOne({'username' : following_user }, function(err,user) { following_users_details.push({ username: user.username, profilepic : user.photo, userbio : user.bio }); res.render('users/userAccount',{user:req.user, following_users_details:following_users_details }); }); } </code></pre>
17,329,320
0
<p><code>&lt;header&gt;</code> is also good for the page header or for a <code>&lt;section&gt;</code>'s header not just for articles. You can use both your examples without a problem. I recommend you use <code>&lt;header&gt;</code> for easier readability.</p>
35,135,336
0
<p>try to re-size function all the script also put in to the </p> <p>$(window).resize(function(){</p> <p>}) it's call on </p>
40,435,037
0
<p>Replace that line with this and it would definitely work.</p> <pre><code>'com.android.support:design:25.0.0' </code></pre>
1,681,257
0
<p>I always add the following init-method to my bootstrap to pass the configuration into the registry.</p> <pre><code>protected function _initConfig() { $config = new Zend_Config($this-&gt;getOptions(), true); Zend_Registry::set('config', $config); return $config; } </code></pre> <p>This will shorten your code a little bit:</p> <pre><code>class My_UserController extends Zend_Controller_Action { public function indexAction() { $manager = new My_Model_Manager(Zend_Registry::get('config')-&gt;my); $this-&gt;view-&gt;items = $manager-&gt;getItems(); } } </code></pre>
28,561,779
0
<p>What you are lookin for is Typehead. It is very easy to implement in Angular using Bootstrap UI.</p> <p><a href="http://angular-ui.github.io/bootstrap/#/typeahead" rel="nofollow">Typehead in Bootstrap UI</a></p>
13,010,430
0
<p>The textarea should already be hidden since it will only be used as a fallback. The editor itself is contained in an iframe with class <code>wysihtml5-sandbox</code>. So this should toggle the editor</p> <pre><code>$(".wysihtml5-sandbox").hide() </code></pre>
32,152,331
0
How to change the database that ASP.NET Identity use for creating its necessary tables? <p>I have 2 projects in my solution</p> <ol> <li>Web UI</li> <li>Web API</li> </ol> <p>I am using Web API project for authentication (ASsp.Net Identity Framework). Below is the web.config setting for the connection string in Web.API project</p> <pre><code>&lt;connectionStrings&gt; &lt;add name="AuthContext" connectionString="Data Source=./SQLEXPRESS;Initial Catalog=TestDB;Integrated Security=SSPI;" providerName="System.Data.SqlClient" /&gt; &lt;/connectionStrings&gt; </code></pre> <p>My DbContext Class</p> <pre><code>public class AuthContext : IdentityDbContext&lt;IdentityUser&gt; { public AuthContext() : base("AuthContext",throwIfV1Schema:false) { } public static AuthContext Create() { return new AuthContext(); } public DbSet&lt;Client&gt; Clients { get; set; } public DbSet&lt;RefreshToken&gt; RefreshTokens { get; set; } } </code></pre> <p>TestDB is an existing database with few tables. This is what I did in Web API project in the Package Manager Console</p> <ol> <li>Enable-Migrations</li> <li>Add-Migration InitialCreate</li> <li>Update-Database</li> </ol> <p>It always create a new database called AuthContext instead of adding the necessary tables in TestDB.</p> <p>I set the Web UI project as the Startup Project in my solution. How do I get update-database to create tables in TestDb instead of creating of new database.</p> <p>-Alan-</p>
15,065,320
0
<p>Well, the fibonacci series grows (approximately) exponentially with a ratio of 1.618 (the golden ratio).</p> <p>If you take the log base 1.618 of <code>Integer.MAX_VALUE</code> it will therefore tell you approximately how many iterations you can go before overflowing....</p> <p>Alternatively, you can determine empirically when it overflows just by doing the calculations....</p>
16,811,720
0
<p>What you need is to detect when an element is added to a page, specifically <code>&lt;video&gt;</code> element. There is a DOM event for that, but it's been deprecated - see this <a href="http://stackoverflow.com/questions/7434685/event-when-element-added-to-page">answer</a>. The answer may be helpful to you, the accepted answer suggests <code>setInterval()</code>.</p> <p>Try this:</p> <pre><code>function checkVideo() { var videoTags = document.getElementsByTagName("video"); if (videoTags.length &gt; 0) { // do something with video } setTimeout( checkDOMChange, 1000); // schedule the next check </code></pre> <p>}</p> <p>Then just run checkVideo() when document is loaded (e.g. <code>$(document).ready(checkVideo)</code> with jQuery).</p> <p>jQuery also has a function <a href="http://api.jquery.com/live/" rel="nofollow">live()</a> which should solve your problem, but it is deprecated now.</p>
36,608,615
0
<p>In case of conflict you should select the higher number of the two. But whatever you choose it has no impact on actual migrations. </p> <p>If you choose the lower number then next time you run <code>rake db:migrate</code> it will change this number (to the higher one) and you will have a change in your <code>schema.rb</code> and no migration. It's not a problem - only your commit will be a bit strange.</p> <p>Rails rake task runs all migrations that it finds and that don't have a value in <code>schema_migrations</code> table. And then it takes the highest migration timestamp and puts this timestamp into the <code>schema.rb</code>. The whole migration idea is not based on some "most recent timestamp" (schema version) but it's based on the content of <code>schema_migrations</code> table that contains all migration timestamps that it has already run. So through this table it guarantees that no migration is skipped.</p>
24,295,090
1
Python RQ: pattern for callback <p>I have now a big number of documents to process and am using Python RQ to parallelize the task.</p> <p>I would like a pipeline of work to be done as different operations is performed on each document. For example: <code>A</code> -> <code>B</code> -> <code>C</code> means pass the document to function <code>A</code>, after <code>A</code> is done, proceed to <code>B</code> and last <code>C</code>.</p> <p>However, Python RQ does not seem to support the pipeline stuff very nicely.</p> <p>Here is a simple but somewhat dirty of doing this. In one word, each function along the pipeline call its next function in a nesting way.</p> <p>For example, for a pipeline <code>A</code>-><code>B</code>-><code>C</code>.</p> <p>At the top level, some code is written like this:</p> <p><code>q.enqueue(A, the_doc)</code></p> <p>where q is the <code>Queue</code> instance and in function <code>A</code> there are code like:</p> <p><code>q.enqueue(B, the_doc)</code></p> <p>And in <code>B</code>, there are something like this:</p> <p><code>q.enqueue(C, the_doc)</code></p> <p>Is there any other way more elegant than this? For example some code in <strong>ONE</strong> function:</p> <p><code>q.enqueue(A, the_doc) q.enqueue(B, the_doc, after = A) q.enqueue(C, the_doc, after= B) </code></p> <p><a href="http://python-rq.org/docs/" rel="nofollow">depends_on</a> parameter is the closest one to my requirement, however, running something like:</p> <p><code> A_job = q.enqueue(A, the_doc) q.enqueue(B, depends_on=A_job )</code></p> <p>won't work. As <code>q.enqueue(B, depends_on=A_job )</code> is executed immediately after <code>A_job = q.enqueue(A, the_doc)</code> is executed. By the time B is enqueued, the result from A might not be ready as it takes time to process.</p> <p>PS:</p> <p>If Python RQ is not really good at this, what else tool in Python can I use to achieve the same purpose:</p> <ol> <li>round-robin parallelization</li> <li>pipeline processing support</li> </ol>
5,998,952
0
Converting a jQuery object to a plain object <p>Does jQuery provide a way to convert a selected element that is a jQuery object to a plain object, for example if you wanted to just perform basic javascript actions on the object without using jQuery after the element has bee initially selected?</p> <p>Thanks in advance.</p>
11,240,042
0
<p>This is known as function calling..</p> <p>like you call function in other programing language like in java or c#:</p> <pre><code>ob.method() // where ob is object and method is the function name.. </code></pre> <p>similarly if you want to call a function in objective c the syntax is calling function is like this : </p> <pre><code> [ob method]; </code></pre>
20,924,306
0
<p>You're missing the block for while. – Ashwin Mukhija Dec 30 '13 at 19:45 </p> <p>that fixed it. </p>
34,940,569
0
<p>You can collect your list items and concat them using <a href="http://php.net/manual/en/function.implode.php" rel="nofollow">implode</a> method:</p> <pre><code>&lt;?php if (!empty($topmenu) &amp;&amp; !empty($menulist)) { $listItems = array(); foreach ($topmenu as $mainparent) { $arry = getmenuvalue($mainparent-&gt;id, $menulist, MAINURL); if (isset($mainparent-&gt;children) &amp;&amp; !empty($mainparent-&gt;children)) { $listItems[] = '&lt;li class="dropdown"&gt; &lt;a href="' . $arry['url'] . '" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"&gt;' . $arry['name'] . '&lt;span class="caret"&gt; &lt;/span&gt;&lt;/a&gt;&lt;/li&gt;'; } else { $listItems[] = '&lt;li&gt;&lt;a href="' . $arry['url'] . '"&gt;' . $arry['name'] . '&lt;/a&gt;&lt;/li&gt;'; } } echo implode('&lt;li&gt; | &lt;/li&gt;', $listItems); } ?&gt; </code></pre>
24,368,556
0
<p>All of your dropwizard dependencies are using <code>${project.version}</code> instead of <code>${dropwizard.version}</code>. Should look like this:</p> <pre class="lang-xml prettyprint-override"><code>&lt;dependency&gt; &lt;groupId&gt;io.dropwizard&lt;/groupId&gt; &lt;artifactId&gt;dropwizard-core&lt;/artifactId&gt; &lt;version&gt;${dropwizard.version}&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;io.dropwizard&lt;/groupId&gt; &lt;artifactId&gt;dropwizard-auth&lt;/artifactId&gt; &lt;version&gt;${dropwizard.version}&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;io.dropwizard&lt;/groupId&gt; &lt;artifactId&gt;dropwizard-assets&lt;/artifactId&gt; &lt;version&gt;${project.version}&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;io.dropwizard&lt;/groupId&gt; &lt;artifactId&gt;dropwizard-spdy&lt;/artifactId&gt; &lt;version&gt;${dropwizard.version}&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;io.dropwizard&lt;/groupId&gt; &lt;artifactId&gt;dropwizard-hibernate&lt;/artifactId&gt; &lt;version&gt;${dropwizard.version}&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;io.dropwizard&lt;/groupId&gt; &lt;artifactId&gt;dropwizard-migrations&lt;/artifactId&gt; &lt;version&gt;${dropwizard.version}&lt;/version&gt; &lt;/dependency&gt; </code></pre>
1,029,609
0
A WPF App fails when coming out of hibernate mode <p>I have a WPF application that fails to come out of the timed sleep, followed by hibernate. The render thread seems to be failing during initialization. I tried removing hardware acceleration to check that it's not graphics card related, but that did not help.</p> <p>Here is an exception along with the stacktrace:</p> <p>ERROR An unspecified error occurred on the render thread. Stack trace: at System.Windows.Media.MediaContext.NotifyPartitionIsZombie(Int32 failureCode) at System.Windows.Media.MediaContext.NotifyChannelMessage() at System.Windows.Interop.HwndTarget.HandleMessage(Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean&amp; handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean&amp; handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter) at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG&amp; msg) at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.Run() at System.Windows.Application.RunDispatcher(Object ignore) at System.Windows.Application.RunInternal(Window window) at System.Windows.Application.Run(Window window) at System.Windows.Application.Run()</p> <p>I googled around, and people suggest that it might have something to do with AllowsTransparency property being set to true; however, i did not see this issue when running a simple test app.</p> <p>Any ideas about the exception and possible causes/solutions are highly appreciated.</p>
19,495,427
0
SQL SELECT everything after a certain character <p>I need to extract everything after the last '=' (<a href="http://www.domain.com?query=blablabla">http://www.domain.com?query=blablabla</a> - > blablabla) but this query returns the entire strings. Where did I go wrong in here:</p> <pre><code>SELECT RIGHT(supplier_reference, CHAR_LENGTH(supplier_reference) - SUBSTRING('=', supplier_reference)) FROM ps_product </code></pre>
20,899,657
0
<p><code>R.layout.da_item</code> file only contains <code>R.id.ingredientbox</code> so your <code>covertView</code> and <code>holder.name</code> are referring to the same object.</p> <p>Now when you call </p> <pre><code>convertView.setTag(holder); </code></pre> <p>holder set to tag of convertView object and then you call</p> <pre><code>holder.name.setTag(state); </code></pre> <p>which overrides the tag as both objects are same.</p> <p>Try to remove 2nd call and check.</p> <p><strong>EDIT</strong> Change your holder class to:</p> <pre><code> private class ViewHolder { Items state; CheckBox name; } </code></pre> <p>don't write <code>holder.name.setTag(state);</code>. Instead do following:</p> <pre><code>holder.state=state; </code></pre> <p>Now when you want items just say:</p> <pre><code>Items _state = ((ViewHolder) cb.getTag()).state; </code></pre>
39,445,025
0
SonarQube Plugin for Jenkins does not find SonarQube Scanner executable <p>I am trying to run the SonarQube Scanner within Jenkins as a post-build step. However, I keep getting the error message below:</p> <pre><code>------------------------------------------------------------------------ SONAR ANALYSIS FAILED ------------------------------------------------------------------------ FATAL: SonarQube Scanner executable was not found for SonarQube Build step 'Execute SonarQube Scanner' marked build as failure </code></pre> <p>From <a href="http://stackoverflow.com/questions/34951252/why-i-am-getting-sonarqube-runner-executable-was-not-found-for-sonarquberunner-5">similar questions</a> on stackoverflow I read that one should choose "Install automatically" for the SonarQube Scanner, which I have done.</p> <p>My configurations is as follows: </p> <ul> <li>SonarQube 6.0 </li> <li>Jenkins 1.609.3 </li> <li>SonarQube Plugin 2.4.4</li> </ul> <h2>SonarQube Servers</h2> <p><a href="https://postimg.org/image/h79rt6ted/" rel="nofollow"><img src="https://s10.postimg.org/ed6mfqr89/sonarqubeservers.png" alt="sonarqubeservers.png"></a></p> <h2>SonarQube Scanner</h2> <p><a href="https://postimg.org/image/5wngqd23b/" rel="nofollow"><img src="https://s15.postimg.org/69euwjkd7/sonarqubescanner.png" alt="sonarqubescanner.png"></a></p> <h2>Build-step</h2> <p><a href="https://postimg.org/image/y3f4xzqh9/" rel="nofollow"><img src="https://s14.postimg.org/dw1p5ot01/buildstep.png" alt="buildstep.png"></a></p>
9,293,152
0
<p>This might work for you:</p> <pre><code>sed 's/[^/]*,-,\.txt$//p;d' file </code></pre>
20,895,289
0
<p>There's a few bits here and there that are a little more advanced than you need to delve into right now but the most of it is basic HTML.</p> <p>You can change the templates but unfortunately the post ID has to stay ..it's built in.</p> <p>You can find more info here; <a href="http://webapps.stackexchange.com/questions/28049/changing-messy-tumblr-url">http://webapps.stackexchange.com/questions/28049/changing-messy-tumblr-url</a></p> <p>Good luck with the template.</p>
39,658,315
0
<pre><code>abstract class Robot { private WorldOfRobots world; public void setWorld(WorldOfRobots world) { this.world=world; } // content } public class Telebot extends Robot { public Telebot(String newName, String newDirection) { super(newName, newDirection); } public void doSomething() { world.doSomethingElse(); } } public class WorldOfRobots { // List of robots private ArrayList&lt;Robot&gt; robots; public WorldOfRobots() { robots = new ArrayList&lt;Robot&gt;(); } public void addRobot(Robot robot) { robots.add(robot); robot.setWorld(this); } } </code></pre> <p>Storing a reference for the <code>WorldOfRobots</code> in the <code>Robot</code> class is reasonable in this case. If you want a robot to belong to multiple <code>WorldOfRobots</code> then change the world varible to List.</p>
3,019,650
0
<p>There is a <a href="http://rsm.codeplex.com/" rel="nofollow noreferrer">R# settings manager</a> plugin for resharper that stores all of this I think, including stylecop settings</p>
37,936,241
0
<p>We can use <code>data.table</code>. Convert the 'data.frame' to 'data.table' (<code>setDT(data)</code>), grouped by 'site', <code>if</code> the length of the unique 'method' is greater than 1, then get the Subset of Data.table.</p> <pre><code>library(data.table) setDT(data)[, if(uniqueN(method)&gt;1) .SD , by = site] </code></pre> <hr> <p>Or with <code>dplyr</code>, we can do it.</p> <pre><code>library(dplyr) data %&gt;% group_by(site) %&gt;% filter(n_distinct(method)&gt;1) </code></pre> <hr> <p>A possible <code>base R</code> option would be</p> <pre><code>data[ with(data, ave(method, site, FUN = function(x) length(unique(x))&gt;1)),] </code></pre>
22,548,845
0
Calculate sub-paths between two vertices from minimum spanning trees <p>I have a minimum spanning tree (MST) from a given graph. I am trying to compute the unique sub-path (which should be part of the MST, not the graph) for any two vertices but I am having trouble finding an efficient way of doing it. </p> <p>So far, I have used Kruskal's algorithm (using Disjoint Data structure) to calculate the MST (for example: 10 vertices A to J).. But now I want to calculate the sub-path between C to E.. or J to C (assuming the graph is undirected). </p> <p>Any suggestions would be appreciated. </p>
16,640,471
0
String Formatting <p>I am currently trying to construct a program that prints Pascal's Triangles at different heights through calling a method to construct the triangle with an int parameter for height of the triangle. When trying to run my program, the first Pascal's triangle prints bu then I get an Exception error, reading this:</p> <pre><code>java.util.FormatFlagsConversionMismatchException: Conversion = s, Flags = 0 at java.util.Formatter$FormatSpecifier.failMismatch(Unknown Source) at java.util.Formatter$FormatSpecifier.checkBadFlags(Unknown Source) at java.util.Formatter$FormatSpecifier.checkGeneral(Unknown Source) at java.util.Formatter$FormatSpecifier.&lt;init&gt;(Unknown Source) at java.util.Formatter.parse(Unknown Source) at java.util.Formatter.format(Unknown Source) at java.io.PrintStream.format(Unknown Source) at PascalsTriangle.drawTriangle(PascalsTriangle.java:19) at PascalsTriangle.main(PascalsTriangle.java:39) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at edu.rice.cs.drjava.model.compiler.JavacCompiler.runCommand(JavacCompiler.java:272) </code></pre> <blockquote> <p></p> </blockquote> <p>Through debugging, I noticed that there is an issue with how I formatted the String output in line 19. I am fairly new to Java programming and I have tried to work through different formatting issues in my code, but I have been stumped on how to make this work. Any suggestions on how I can prevent this exception error from happening?</p> <p>Here is the code to my program:</p> <pre><code>public class PascalsTriangle { private int height; public void drawTriangle(int height) { System.out.println("A Pascal Triangle with height " + height); for(int i = 0; i &lt;= height; i++) { int number = 1; System.out.format("%" + ((height-i) * 2) + "s", " "); for(int j = 0; j &lt;= i; j++) { System.out.format("%5d", number); number = number * (i - j) / (j + 1); } System.out.println(); } } public static void main(String[] args) { PascalsTriangle pascal = new PascalsTriangle(); pascal.drawTriangle(4); pascal.drawTriangle(10); pascal.drawTriangle(7); pascal.drawTriangle(2); } } </code></pre>
9,904,728
0
Backbone: special encoding during save <p>Note: I know this is <strong><em>wrong</em></strong>, but this is a technical requirement by the server team. </p> <p>I have a User object that extends Backbone.Model. It receives it's data using normal, mostly good, JSON from the server. </p> <p>HOWEVER there is a requirement when saving THE SAME INFORMATION to encode emails with url encoding. </p> <p>When receiving the data it is possible to pre-process it with the Backbone.Model.parse method, is there an equivalent way to pre-process the data before sending it? (without overriding the sync method)</p>
17,338,065
0
Android BitmapFactory.decodeFile skia error <p>I'm designing an activity that shows some images. The code below gets image files and places them into the screen.</p> <pre><code> for(int i=0;i&lt;photoPaths.size();i++){ BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 4; //Bitmap bm= BitmapFactory.decodeFile(new File(photoPaths.get(i)).getAbsolutePath()); Bitmap bm= BitmapFactory.decodeFile(new File(photoPaths.get(i)).getAbsolutePath()); int imageH=bm.getHeight(); int imageW=bm.getWidth(); ImageView image=new ImageView(this); image.setImageBitmap(bm); int padding=10; image.setPadding(0, padding, padding, 0); } </code></pre> <p>The code is running well while placing 5 photos. After them when 6th is placing code fails.</p> <p>Here is the LogCat messages:</p> <pre><code> 06-27 11:13:13.202: D/skia(17373): --- decoder-&gt;decode returned false 06-27 11:13:13.202: D/AndroidRuntime(17373): Shutting down VM 06-27 11:13:13.202: W/dalvikvm(17373): threadid=1: thread exiting with uncaught exception (group=0x4142c2a0) 06-27 11:13:13.202: E/AndroidRuntime(17373): FATAL EXCEPTION: main 06-27 11:13:13.202: E/AndroidRuntime(17373): java.lang.OutOfMemoryError 06-27 11:13:13.202: E/AndroidRuntime(17373): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method) 06-27 11:13:13.202: E/AndroidRuntime(17373): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:652) 06-27 11:13:13.202: E/AndroidRuntime(17373): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:391) 06-27 11:13:13.202: E/AndroidRuntime(17373): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:451) 06-27 11:13:13.202: E/AndroidRuntime(17373): at com.artechin.mbtkatalog.PhotoGallery.onCreate(PhotoGallery.java:94) 06-27 11:13:13.202: E/AndroidRuntime(17373): at android.app.Activity.performCreate(Activity.java:5188) 06-27 11:13:13.202: E/AndroidRuntime(17373): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094) 06-27 11:13:13.202: E/AndroidRuntime(17373): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074) 06-27 11:13:13.202: E/AndroidRuntime(17373): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135) 06-27 11:13:13.202: E/AndroidRuntime(17373): at android.app.ActivityThread.access$700(ActivityThread.java:140) 06-27 11:13:13.202: E/AndroidRuntime(17373): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237) 06-27 11:13:13.202: E/AndroidRuntime(17373): at android.os.Handler.dispatchMessage(Handler.java:99) 06-27 11:13:13.202: E/AndroidRuntime(17373): at android.os.Looper.loop(Looper.java:137) 06-27 11:13:13.202: E/AndroidRuntime(17373): at android.app.ActivityThread.main(ActivityThread.java:4921) 06-27 11:13:13.202: E/AndroidRuntime(17373): at java.lang.reflect.Method.invokeNative(Native Method) 06-27 11:13:13.202: E/AndroidRuntime(17373): at java.lang.reflect.Method.invoke(Method.java:511) 06-27 11:13:13.202: E/AndroidRuntime(17373): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038) 06-27 11:13:13.202: E/AndroidRuntime(17373): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805) 06-27 11:13:13.202: E/AndroidRuntime(17373): at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>How can I solve the problem?</p>
3,799,591
0
<p>You should be referencing $ variable like this:</p> <pre><code>$("body",window.content) </code></pre> <p>Also I have also used jQuery in my firefox extension it works seamlessly with no issues at all. </p>
9,994,343
0
Javascript call a c function at the server side <p>Is there a way i can call c functions from JavaScript at server side . and if possible back from c to javascript.</p>
36,588,180
0
Customized bootstrap doesn't have breakpoint for XS screen size <p>I only wanted the CSS for the Grid layout and Responsive utilities, so I customized boostrap for my application here - <a href="http://getbootstrap.com/customize/?id=568dcb34f5eabdd2e526e20c7041d8bc" rel="nofollow noreferrer">http://getbootstrap.com/customize/?id=568dcb34f5eabdd2e526e20c7041d8bc</a></p> <p>Part of the default settings on that page define where common breakpoints are -</p> <p><a href="https://i.stack.imgur.com/bB513.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bB513.png" alt="enter image description here"></a></p> <p>When I downloaded my customized file, I noticed media queries for the breakpoints 768px, 992px, and 1200px. But I didn't see anything about 480px.</p> <p>Is there a reason for that? I know the CSS file is structured to applyl to the smallest resolution first and then increase in resolution progressively, but wouldn't their still be a break point for less than and greater than 480px? </p>
31,151,373
0
<pre><code>Today at 14:34 Yesterday at 10:20 2 days ago (02/02/2015 12:43) Last week (04/01/2015 12:42) </code></pre> <p>You can format the date and time format using custom DateTime format strings. The other part you will need to code in your own logic.</p> <p><a href="https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx" rel="nofollow">MSDN: Custom DateTime Format Strings</a></p> <pre><code>DateTime dd = now; dd.ToString("HH:mm"); dd.ToString("dd/MM/yyyy HH:mm"); </code></pre>
30,378,210
0
Increased Ram Usage on android device <p>I run the following code to start a service:</p> <pre><code>public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent intent = new Intent(this, CreatingService.class); startService(intent); //finish(); } } </code></pre> <p>This initially takes 13-14 MB of memory when seen in the task manager. When i go back to home screen and kill the activity (swiping off from recent list) the service gets recreated(<code>START_STICKY</code>) and it takes around 3-4 MB of memory from then on. Also if the <code>finish()</code> was not commented off in the above code it would take 3-4 MB again. But I cannot do this.</p> <p>Can anyone explain what exactly is happening and a workaround for this?</p>
17,567,297
0
How can I read the value of a custom field from my Sitecore Webforms? <p>I'm using Sitecore WebForms for Marketeers. I have created a custom field with a custom property. The custom field works fine.</p> <p>I want to read the custom property when I click on the submit button, but I do not know how I can read the custom property.</p> <p>In the field value is the C# parameter property, but this is null. How can I read the value of the custom property?</p> <p>Relevant code:</p> <pre class="lang-cs prettyprint-override"><code> //Set values in dictionary var values = new Dictionary&lt;String, String&gt;(); foreach (AdaptedControlResult field in fields) { values.Add(field.FieldName, field.Value); } </code></pre>
12,706,480
0
<p>With the <code>extern</code> clause you are telling the compiler to resolve that symbol when it links. After linking, in the binary file there will be just one symbol with the name <code>ptr_to_var</code>. You, of course, must assure that it gets initialised somewhere. In the code you pasted, we cannot know whether it's been initialised or not. Though it seems you didn't. </p> <p>By the way, try to make an <code>nm</code> to the libraries. You will see the symbols that you specified as <code>extern</code> as undefined (capital u), except in that library or object file where is it indeed defined (i.e., declared without the <code>extern</code> clause).</p>
33,336,197
0
<p>If you suspect that some other process or thread in your app is taking too much CPU time then use:</p> <p>GetThreadTimes under windows </p> <p>or</p> <p>clock_gettime with CLOCK_THREAD_CPUTIME_ID under linux</p> <p>to measure threads CPU time your function was being executed. This will exclude from your measurements time other threads/processes were executed during profiling.</p>
27,785,759
0
Get Absolute Path Relative to DLL location <p>I have a dll that depends on some external files. I have relative paths (relative to the dll location) to those files.</p> <p>I need to be able to load/read those files from the DLL.</p> <p>To find the absolute path to the files I was using:</p> <pre><code>System.IO.Path.GetFullPath(filePath); </code></pre> <p>It seemed to be working, but I found that this is actually returning a path relative to the 'current directory'. I found that the current directory changes at some point from the dll location (and may never even be the dll path).</p> <p>What's the easiest way to get the absolute path of the files relative to the DLL from code running in the DLL?</p> <p>I was going to use the following, but found that it returns the path to the EXE that has loaded the DLL, not the DLL path:</p> <pre><code>AppDomain.CurrentDomain.BaseDirectory </code></pre>
14,422,947
0
<p>I ended up writing my own algorithm to break the text only on whitespace. I had originally used the <a href="http://developer.android.com/reference/android/graphics/Paint.html#breakText%28java.lang.CharSequence,%20int,%20int,%20boolean,%20float,%20float%5b%5d%29">breakText</a> method of <a href="http://developer.android.com/reference/android/graphics/Paint.html">Paint</a>, but was having some issues (that may actually be resolved in this version of the code, but that's OK). This isn't my best chunk of code, and it could definitely be cleaned up a bit, but it works. Since I'm overriding <a href="http://developer.android.com/reference/android/widget/TextView.html">TextView</a>, I just call this from the <a href="http://developer.android.com/reference/android/view/View.html#onSizeChanged%28int,%20int,%20int,%20int%29">onSizeChanged</a> method to ensure that there's a valid width.</p> <pre class="lang-js prettyprint-override"><code>private static void breakManually(TextView tv, Editable editable) { int width = tv.getWidth() - tv.getPaddingLeft() - tv.getPaddingRight(); if(width == 0) { // Can't break with a width of 0. return false; } Paint p = tv.getPaint(); float[] widths = new float[editable.length()]; p.getTextWidths(editable.toString(), widths); float curWidth = 0.0f; int lastWSPos = -1; int strPos = 0; final char newLine = '\n'; final String newLineStr = "\n"; boolean reset = false; int insertCount = 0; //Traverse the string from the start position, adding each character's //width to the total until: //* A whitespace character is found. In this case, mark the whitespace //position. If the width goes over the max, this is where the newline //will be inserted. //* A newline character is found. This resets the curWidth counter. //* curWidth &gt; width. Replace the whitespace with a newline and reset //the counter. while(strPos &lt; editable.length()) { curWidth += widths[strPos]; char curChar = editable.charAt(strPos); if(((int) curChar) == ((int) newLine)) { reset = true; } else if(Character.isWhitespace(curChar)) { lastWSPos = strPos; } else if(curWidth &gt; width &amp;&amp; lastWSPos &gt;= 0) { editable.replace(lastWSPos, lastWSPos + 1, newLineStr); insertCount++; strPos = lastWSPos; lastWSPos = -1; reset = true; } if(reset) { curWidth = 0.0f; reset = false; } strPos++; } if(insertCount != 0) { tv.setText(editable); } } </code></pre>
14,722,981
0
<p>I started out with Qiulang answer, but it didn't work for me. What worked for me is to call the setAssetsFilter 3 times in a row with all filter combinations, before starting the enumeration.</p> <pre><code>[group setAssetsFilter:[ALAssetsFilter allPhotos]]; [group setAssetsFilter:[ALAssetsFilter allVideos]]; [group setAssetsFilter:[ALAssetsFilter allAssets]]; </code></pre>
12,412,722
0
<p>Fatal errors don't produce 500 errors in and of themselves, they would return 200 with blank page typically (if no output had been flushed to browser at the point of the error) . Plus this will not help you anyway, as Apache would be no longer involved when PHP is having the error.</p> <p>Maybe you could register a shutdown function to send 500 header (to get 500 result) and display the content you want to display.</p>
39,644,633
0
<p>I also lost a half of day trying to fix this.</p> <p>It appeared that root was my project pom.xml file with dependency:</p> <pre><code> &lt;dependency&gt; &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt; &lt;artifactId&gt;jsp-api&lt;/artifactId&gt; &lt;version&gt;2.1&lt;/version&gt; &lt;scope&gt;provided&lt;/scope&gt; &lt;/dependency&gt; </code></pre> <p>Other members of the team had no problems. At the end it appeared, that I got newer tomcat which has different version of jsp-api provided (in tomcat 7.0.60 and above it will be jsp-api 2.2).</p> <p>So in this case, options would be:</p> <pre><code>a) installing different (older/newer) tomcat like (Exactly what I did, because team is on older version) b) changing dependency scope to 'compile' c) update whole project dependencies to the actual version of Tomcat/lib provided APIs d) put matching version of the jsp-api.jar in {tomcat folder}/lib </code></pre>
30,984,528
0
<p>This is usually an indication that you're mixing dirty dlls with different versions together. Try uninstalling all NuGet packages, delete the NuGet <code>/packages</code> folder than installing all NuGet packages again and check that the <code>/packages</code> folder is only using the same version of ServiceStack for all its NuGet packages.</p>
35,304,510
0
<p>First of all. You should use only one column for a date whenever is possible.</p> <p>But in your case, your columns are VARCHAR type. Try something like this.</p> <pre><code>SELECT * FROM table_name where YEAR = '2016' order by CONVERT(Int,YEAR), (CASE MONTH WHEN 'January' THEN 1 WHEN 'February' THEN 2 WHEN 'March' THEN 3 WHEN 'April' THEN 4 WHEN 'May' THEN 5 WHEN 'June' THEN 6 WHEN 'July' THEN 7 WHEN 'August' THEN 8 WHEN 'September' THEN 9 WHEN 'October' THEN 10 WHEN 'November' THEN 11 WHEN 'December' THEN 12), CONVERT(Int,DDATE), CONVERT(TIME, TIME) </code></pre>
30,912,830
0
Cannot find android sdk in eclipse <p>How to get android sdk 5.0 api 21 - not available in eclipse android sdk manager Please tell me the solution. Thank you very much.</p>
2,365,517
0
<p>I don't know if this will help with your problem, but in any case: jQuery is selector-based, so use classes instead of IDs (remove the #s everywhere and change the corresponding id/name attributes to class attributes) and your code will be much more generic, hence more reusable and maintainable.</p>
27,145,931
0
<p>Just use pixelOffset property:</p> <pre><code>var infoWindow = new google.maps.InfoWindow({pixelOffset:new google.maps.Size(0, -100)}); </code></pre>
11,123,221
0
Apache CXF via TLS <p>Update on 06/21/2012 A little update. Today I finally caught the exception which is preventing me from connecting to the server. Here is what I get after calling <code>getInputStream()</code>:</p> <pre><code>javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target </code></pre> <p>===========================================================</p> <p><strong>Original message:</strong></p> <p>I'm trying to make my client (the client is not written entirely by me) work with a published web service over TLS (the client works over http). I'm new to this area I've never worked with web services closely before. I've checked with soapUI that the web service is correctly published and accessible. The address is <strong>https://:9080/SOAOICCT/services/SessionService?wsdl</strong>. I can send a request and receive a reply. But my client throws a lot of exceptions. Here are the most important:</p> <pre><code>javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service. at &lt;My class.my method&gt;(SessionServiceDAO.java:548) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ...... Caused by: javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service. at org.apache.cxf.jaxws.ServiceImpl.&lt;init&gt;(ServiceImpl.java:150) at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:65) at javax.xml.ws.Service.&lt;init&gt;(Service.java:56) ......... Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: java.lang.IllegalArgumentException: InputSource must have a ByteStream or CharacterStream at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:226) at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:179) at org.apache.cxf.wsdl11.WSDLServiceFactory.&lt;init&gt;(WSDLServiceFactory.java:91) ... 70 more Caused by: java.lang.IllegalArgumentException: InputSource must have a ByteStream or CharacterStream at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:983) at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:217) ... 72 more </code></pre> <p>I've tracked this issue to the method <code>java.net.HttpURLConnection.getResponseCode()</code>. Here it is:</p> <pre><code>public int getResponseCode() throws IOException { /* * We're got the response code already */ if (responseCode != -1) { return responseCode; } /* * Ensure that we have connected to the server. Record * exception as we need to re-throw it if there isn't * a status line. */ Exception exc = null; try { getInputStream(); } catch (Exception e) { exc = e; } </code></pre> <p>I get an exception at <code>getInputStream()</code> and never actually connect to the server. This exception is later swallowed in <code>org.apache.cxf.transport.TransportURIResolver.resolve(String, String)</code> here</p> <pre><code>} catch (Exception e) { //ignore } </code></pre> <p>The issue seems to be something very simple like authentication or a parameter. Are there any obvious reasons why I cannot connect to the web service? I'm a newbie I can make even a very simple mistake.</p> <p>Here is my <code>http:conduit</code>:</p> <pre><code>&lt;http:conduit name="*.http-conduit"&gt; &lt;http:tlsClientParameters secureSocketProtocol="TLS"&gt; &lt;sec:trustManagers&gt; &lt;sec:keyStore type="JKS" password="123123" file="config.soa.client/trustedCA.keystore"/&gt; &lt;/sec:trustManagers&gt; &lt;sec:cipherSuitesFilter&gt; &lt;sec:include&gt;SSL_RSA_WITH_RC4_128_MD5&lt;/sec:include&gt; &lt;sec:include&gt;SSL_RSA_WITH_RC4 _128_SHA&lt;/sec:include&gt; &lt;sec:include&gt;SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA&lt;/sec:include&gt; &lt;sec:include&gt;.*_EXPORT_.*&lt;/sec:include&gt; &lt;sec:include&gt;.*_EXPORT1024_.*&lt;/sec:include&gt; &lt;sec:include&gt;.*_WITH_DES_.*&lt;/sec:include&gt; &lt;sec:include&gt;.*_WITH_NULL_.*&lt;/sec:include&gt; &lt;sec:exclude&gt;.*_DH_anon_.*&lt;/sec:exclude&gt; &lt;/sec:cipherSuitesFilter&gt; &lt;/http:tlsClientParameters&gt; &lt;/http:conduit&gt; </code></pre> <p>A little update. Today I finally caught the exception which is preventing me from connecting to the server. Here is what I get after calling <code>getInputStream()</code>:</p> <pre><code>javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target </code></pre>
26,130,457
0
LINQ JOIN and OUTER JOIN - How to turn SQL into LINQ expression <p>I would like to turn the following SQL query into a LINQ expression (using Entity Framework 6.1). Thus far I have been unable find an acceptable LINQ expression that produces similar results. Any help turning this simple SQL statement into a LINQ express would be appreciated.</p> <pre><code>SELECT AAG.Id AS GroupId, A.Id AS ActivityId, A.Title As Title, CASE WHEN AA.CompletedOn IS NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS Completed, COALESCE(AAG.PointValue, 0) + SUM(COALESCE(AQ.PointValue, 0)) AS PointTotal FROM ActivityAssignmentGroup AAG INNER JOIN ActivityAssignment AA ON AA.GroupId = AAG.Id INNER JOIN Activity A ON AA.ActivityId = A.Id LEFT OUTER JOIN ActivityQuestion AQ ON AQ.ActivityId = A.Id WHERE AAG.AssignedToId = 6 GROUP BY AAG.Id, A.Id, A.Title, CASE WHEN AA.CompletedOn IS NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, COALESCE(AAG.PointValue,0) </code></pre> <p>Without the LEFT OUTER JOIN portion, the below LINQ statement is partially complete, but I cannot figure out the appropriate syntax to add the LEFT OUTER JOIN condition:</p> <pre><code>var assignments = await (from g in db.AssignmentGroups.AsNoTracking().Where(x =&gt; x.AssignedToId == studentTask.Result.PersonId) join aa in db.ActivityAssignments.AsNoTracking() on g.Id equals aa.GroupId join a in db.Activities.AsNoTracking() on aa.ActivityId equals a.Id select new ActivityListViewModel { Id = a.Id, Points = g.PointValue ?? 0, Title = a.Title, GroupId = g.Id, Complete = (aa.CompletedOn != null) }); </code></pre> <p>Edit:</p> <p>Thanks for the response Bob. I attempted to use the DefaultIfEmpty and looked at the resultant SQL query generated by the Entity Framework, but it didn't work. Prior to making this post, this is the LINQ statement I attempted:</p> <pre><code>var assignments = from g in db.AssignmentGroups.AsNoTracking().Where(x =&gt; x.AssignedToId == studentTask.Result.PersonId) join aa in db.ActivityAssignments.AsNoTracking() on g.Id equals aa.GroupId join a in db.Activities.AsNoTracking() on aa.ActivityId equals a.Id from aq in db.ActivityQuestions.Where(q =&gt; q.ActivityId == a.Id).DefaultIfEmpty() group aq by new { ActivityId = aq.ActivityId, Title = a.Title, GroupId = g.Id, Points = g.PointValue ?? 0, Completed = (aa.CompletedOn != null) } into s select new ActivityListViewModel { Id = s.Key.ActivityId, Points = s.Key.Points + s.Sum(y =&gt; y.PointValue ?? 0), //g.PointValue ?? 0, Title = s.Key.Title, GroupId = s.Key.GroupId, Complete = s.Key.Completed }; </code></pre> <p>Of course, it didn't work either. The result was items missing the Id (ActivityId).</p>
33,677,985
0
<p>You can use</p> <pre><code>^(?!0$)\d+(?:[,.][05])?$ </code></pre> <p>See <a href="https://regex101.com/r/iJ6dY5/7" rel="nofollow">demo</a></p> <p>This will match your required numbers and will exclude a <code>0</code>-only number thanks to the look-ahead at the beginning.</p> <p>Main changes:</p> <ul> <li><code>\d+</code> - replaced <code>[1-9]\d*</code> to allow a <code>0</code> as the integer part</li> <li><code>[,.]</code> - replace <code>\.</code> to allow a comma as a decimal separator.</li> <li>The lookahead adds a <code>0</code>-number exception.</li> </ul> <p>The lookahead can be enhanced to disallow <code>0.000</code>-like input:</p> <pre><code>^(?!0+(?:[,.]0+)?$)\d+(?:[,.][05])?$ </code></pre> <p>See <a href="https://regex101.com/r/iJ6dY5/6" rel="nofollow">another demo</a>.</p>
23,465,475
0
<p>Try the following:</p> <pre><code> var parts = table_id.split('_'); var num = parts[1]; // it would be the number you want </code></pre> <p>For more detail on <code>split()</code> check <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split" rel="nofollow">this link</a></p> <p>Or you may try the following:</p> <pre><code>var regex = /.*_(\d+)/; var num = table_id.replace(regex, '$1') </code></pre>
26,067,681
0
<p><a href="https://www.digitalocean.com/community/tutorials/how-to-manually-install-oracle-java-on-a-debian-or-ubuntu-vps" rel="nofollow">This post</a>, which I found by Googling "download jdk8 linux 64 ubuntu", answers your question. Use:</p> <pre><code>$ wget --header "Cookie: oraclelicense=accept-securebackup-cookie" \ http://download.oracle.com/otn-pub/java/jdk/8u20-b26/jdk-8u20-linux-x64.tar.gz </code></pre> <p>and follow instructions to install it.</p>
9,263,742
0
<p>Perhaps:</p> <pre><code>select a.name, a.uniqueCustID, a.info1, b.info2, c.info3 from table1 a left outer join table1 b on b.pk = a.pk and b.info1 is not null left outer join table1 c on c.pk = a.pk and c.info2 is not null </code></pre> <p>The left outer joins are needed because you don't know in advance if a user will have 1, 2 or 3 records with data. This way, if there is no data, a null will be inserted in the corresponding field.</p>
28,432,773
0
<p>When I run into this issue, its always because I choose the wrong type data type.. The data type for the child column must match the parent column exactly.</p> <p>Example: table.key = int &amp; table.child=vchar</p> <p>For me, its always that! Hope that helps.</p>
28,095,209
0
IIS blocking LFTP command <p>I'm trying to execute a LFTP command using the <code>system()</code> PHP method in a IIS 7.0 site.</p> <pre><code>$command = 'cmd /c lftp -c "open -u name,password -p 22 sftp://server.mylife.com ; cd test/portal/template ; put /cygdrive/c/inetpub/uploads/cata/exports/tpl_1421946484/cata.csv;"'; system($command); </code></pre> <p>I put it in a PHP file. If if run it directly by the command line <code>php sendFile.php</code> it works fine. But if I access this same php file throught a IIS 7.0 website, I got nothing and no error.</p> <p>I can't understand where it comes from...!</p> <p>Any help ?</p>
19,228,104
0
<p>It seems that it´s a documented service now: <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile" rel="nofollow">https://developer.here.com/rest-apis/documentation/enterprise-map-tile</a> </p>
2,670,599
0
Remove all styles from dynamic label in asp.net <p>I have a label and I got some text from database. text format like: Windows Server 2008 ...etc But sometimes there are different fonts or something like style. How can I remove all of them quickly?</p> <p>I know I can make it with replace command. But is there any quick way for it?</p>
31,791,365
0
Cocoapod 0.38.0 and AFNetworking 2.5 AF_APP_EXTENSIONS compilation error <p>My project has 9 targets : </p> <pre><code>- Prod - Prod_app_extension_1 - Prod_app_extension_2 - Beta - Beta_app_extension_1 - Beta_app_extension_2 - Dev - Dev_app_extension_2 - Dev_app_extension_2 </code></pre> <p>I'm using 0.38.2 cocoapod version and 2.5.4 AFNetworking.</p> <p>I'm trying to use AFNetworking with cocoapod but I get the <em>AF_APP_EXTENSIONS</em> error while compiling. After searching for the solution on the web, I understand the problem and found that defining the 'preprocessor macros' <em>AF_APP_EXTENSIONS</em> can fix the problem. </p> <p>But here is the struggle : By default, <em>AF_APP_EXTENSIONS</em> is correctly added into my 6 app_extensions. In the other hand, when I navigate through my Pods target, <strong>each Pods are separated</strong> :</p> <pre><code>- NSDate+TimeAgo - AFNetworking - iRate - AppUtils - Prod - Prod_app_extension_1 - Prod_app_extension_2 - Beta - Beta_app_extension_1 - Beta_app_extension_2 - Dev - Dev_app_extension_2 - Dev_app_extension_2 </code></pre> <p>In another project I made, all pods are generated this way : </p> <pre><code>- Prod - Pods-Prod-NSDate+TimeAgo - Pods-Prod-AFNetworking - Pods-Prod-iRate - Pods-Prod-AppUtils - Prod_app_extension_1 - Pods-Prod_app_extension_1-NSDate+TimeAgo - Pods-Prod_app_extension_1-AFNetworking - Pods-Prod_app_extension_1-iRate - Prod_app_extension_2 - Pods-Prod_app_extension_2-NSDate+TimeAgo - Pods-Prod_app_extension_2-AFNetworking - Pods-Prod_app_extension_2-iRate - Beta - Pods-Beta-NSDate+TimeAgo - Pods-Beta-AFNetworking - Pods-Beta-iRate - Pods-Beta-AppUtils - Beta_app_extension_1 - Pods-Beta_app_extension_1-NSDate+TimeAgo - Pods-Beta_app_extension_1-AFNetworking - Pods-Beta_app_extension_1-iRate - Beta_app_extension_2 - Pods-Beta_app_extension_2-NSDate+TimeAgo - Pods-Beta_app_extension_2-AFNetworking - Pods-Beta_app_extension_2-iRate - Dev - Pods-Dev-NSDate+TimeAgo - Pods-Dev-AFNetworking - Pods-Dev-iRate - Pods-Dev-AppUtils - Dev_app_extension_1 - Pods-Dev_app_extension_1-NSDate+TimeAgo - Pods-Dev_app_extension_1-AFNetworking - Pods-Dev_app_extension_1-iRate - Dev_app_extension_2 - Pods-Dev_app_extension_2-NSDate+TimeAgo - Pods-Dev_app_extension_2-AFNetworking - Pods-Dev_app_extension_2-iRate </code></pre> <p>I think this is why my 'preprocessor macros' <em>AF_APP_EXTENSIONS</em> isn't define into the 'AFNetworking' Pods target. </p> <p>Here is my Podfile :</p> <pre><code>platform :ios, '7.0' xcodeproj 'myProj.xcodeproj' def generic_pods pod 'NSDate+TimeAgo' pod 'AFNetworking', '~&gt; 2.0' end def app_pods pod 'iRate' pod 'AppUtils', end target "Prod" do generic_pods app_pods end target "Prod_app_extension_1" do generic_pods end target "Prod_app_extension_2" do generic_pods end target "Beta" do generic_pods app_pods end target "Beta_app_extension_1" do generic_pods end target "Beta_app_extension_2" do generic_pods end target "Dev" do generic_pods app_pods end target "Dev_app_extension_1" do generic_pods end target "Dev_app_extension_2" do generic_pods end </code></pre> <p>I don't know what the problem is, and it's driving me crazy. </p>
30,633,760
0
<p><sup>Disclaimer: I'm using Selenium's .NET bindings, not Java. I don't think that will make a difference in this case.</sup></p> <p><a href="https://duckduckgo.com/l/?kh=-1&amp;uddg=https%3A%2F%2Fcode.google.com%2Fp%2Fselenium%2Fissues%2Fdetail%3Fid%3D8399" rel="nofollow">Selenium 2.44 had an issue with Firefox <strong>36</strong></a>, but this was resolved in Selenium 2.45. It's possible that Firefox versions between 29 and 35 might be incompatible with Selenium 2.45, although this is just a guess on my part.</p> <hr> <p>I had an issue with Seleinum 2.45 driving Firefox version <strong>38</strong>: when instantiating the Firefox driver with no profile, an instance of Firefox would load and immediately crash to desktop; subsequently another instance would load as normal.</p> <p>I found that the issue didn't occur when instantiating the Selenium Firefox driver from an existing profile, so my workaround was to create a blank profile, launch Selenium's Firefox driver using a <em>temporary copy</em> of that profile; then at the conclusion of the test, delete the temporary copy.</p> <p>Try <a href="http://docs.seleniumhq.org/docs/03_webdriver.jsp#firefox-driver" rel="nofollow">launching the Firefox driver with an existing profile</a>.</p>
25,323,774
0
Some users report ClassNotFoundException for launch activity <p>Some users are reporting a crash for my App which I cannot reproduce or even verify.</p> <pre><code>java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{my.app/com.example.activity.SplashScreenActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.activity.SplashScreenActivity" on path: /mnt/asec/my.app-1/pkg.apk at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2219) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349) at android.app.ActivityThread.access$700(ActivityThread.java:159) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:176) at android.app.ActivityThread.main(ActivityThread.java:5419) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.activity.SplashScreenActivity" on path: /mnt/asec/my.app-1/pkg.apk at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:64) at java.lang.ClassLoader.loadClass(ClassLoader.java:501) at java.lang.ClassLoader.loadClass(ClassLoader.java:461) at android.app.Instrumentation.newActivity(Instrumentation.java:1078) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2210) ... 11 more </code></pre> <p>My problem is I get some negative reviews from people who seem unable starting the App at all. I downloaded it on all my test devices from the Play Store and it ran fine.</p> <p>The systems reported to me where Android 4.1 (Huawei Phone), Android 4.3 (Galaxy S3) and Android 4.4 (Galaxy Note 2).</p> <p>I disassembled my apk and checked that the class is in fact contained, and referenced properly. And as previously mentioned, none of the devices available to me can reproduce the problem.</p>
1,213,420
0
<p><code>malloc</code> is for memory allocation. <code>num + 1</code> is to allow for the null-terminator - <code>\0</code>.</p>
12,733,257
0
PHP cURL sitemap generator <p>Hi All I am having a problem with my sitemap generator it works great on a few thousand URLS but when it gets to 20000 URL it starts to go wrong is there anything else i can be doing to help prevent this </p> <pre><code>$request_url ="http://www.example.com";//put your url here $url=str_replace("http://", "", $request_url); // i added this because to check if wwwdomain.com is in the url $alllinks=array();// create an array for all the links $alllinks2=array();// create an array for all the links $alllinks3=array();// create an array for all the links $newUrl=array();// create an array for all the links $badUrls=array("basket", "#" ,"mailto", "javascript:document", "reviews.php", "review.php","tab=",".JPG",".jpg","png","PNG","gif","GIF","item_id=","../", "pn_pr");// array of urls we dont want to include $ch = curl_init(); //search for links curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, CURLOPT_URL, $request_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt ($ch,CURLOPT_VERBOSE,false); curl_setopt($ch, CURLOPT_TIMEOUT, 900); $result = curl_exec($ch); </code></pre> <p>Thank you</p>
37,786,856
0
<p>I ended up using ti.imagefactory module. The zip files for android and ios I found here: <a href="https://github.com/appcelerator-modules/ti.imagefactory/releases" rel="nofollow">https://github.com/appcelerator-modules/ti.imagefactory/releases</a></p> <p>Example can be found here: <a href="https://github.com/appcelerator-modules/ti.imagefactory/blob/stable/ios/example/app.js" rel="nofollow">https://github.com/appcelerator-modules/ti.imagefactory/blob/stable/ios/example/app.js</a></p> <p>I used code from the examples in my app and it seems to work fine!</p>
11,654,439
0
<p>If it's an older, non-OpenXML version of version of Excel you can use NPOI, it's available for download here:</p> <p><a href="http://npoi.codeplex.com/" rel="nofollow">http://npoi.codeplex.com/</a></p> <pre><code>HSSFWorkbook workbook; using (FileStream fs = new FileStream(sheetfilename + ".xls", FileMode.Open, FileAccess.Read)) { workbook = new HSSFWorkbook(fs); var sheet = workbook.GetSheet("Sheet1"); ...do something.. } </code></pre>
23,776,910
0
Finding absolute coordinates from relative coordinates in 3D space <p>My question is fairly difficult to explain, so please bear with me. I have a random object with Forward, Right, and Up vectors. Now, imagine this particular object is rotated randomly across all three axis randomly. How would I go about finding the REAL coordinates of a point relative to the newly rotated object?</p> <p>Example: <img src="https://i.stack.imgur.com/LfEtJ.png" alt="enter image description here"></p> <p>How would I, for instance, find the forward-most corner of the cube given its Forward, Right, and Up vectors (as well as its coordinates, obviously) assuming that the colored axis is the 'real' axis.</p> <p>The best I could come up with is:</p> <pre><code>x=cube.x+pointToFind.x*(forward.x+right.x+up.x) y=cube.y+pointToFind.y*(forward.y+right.y+up.y) z=cube.z+pointToFind.z*(forward.z+right.z+up.z) </code></pre> <p>This worked sometimes, but failed when one of the coordinates for the point was 0 for obvious reasons.</p> <p>In short, I don't know what do to, or really how to accurately describe what I'm trying to do... This is less of a programming questions and more of a general math question.</p>
2,378,063
0
<ul> <li>If you make a Controller method with a different parameter name from <strong>id</strong> for a single parameter method, <em>you have to make a new route</em>. Just bite the bullet and use <strong>id</strong> (it doesn't care about the type) and explain it in the comments.</li> <li><p>Makes sure you name your parameters with <code>RedirectToAction</code> :</p> <p><code>return RedirectToAction("DonateToCharity", new { id = 1000 });</code></p></li> <li><p><a href="http://stackoverflow.com/questions/279665/how-can-i-maintain-modelstate-with-redirecttoaction">You lose your ViewData when you <code>RedirectToAction</code></a>.</p></li> </ul>
39,919,539
0
<p>You can not remove keys from a dictionary in a signed document, and expect the signatures to remain valid. You can only remove the last signature that was added. If a document was signed by multiple people, and you want to remove the first signature, all subsequent signatures will be broken.</p> <p>This image explains why:</p> <p><a href="https://i.stack.imgur.com/7f0D7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7f0D7.png" alt="enter image description here"></a></p> <p>This image shows that every new digital signature keeps the original bytes intact. With every new signature new bytes are added. Rev1 represents the bytes of a document that has 1 digital signature. Rev2 represents the bytes of a document that has 2 digital signatures. The second digital signatures signs Rev1 completely. If you'd remove the first signature, the second signature would become invalid.</p> <p>A digital signature is a special type of form field. With iText, you can get the names of the signature form fields of a PDF like this:</p> <pre><code>PdfReader reader = new PdfReader(path); AcroFields fields = reader.getAcroFields(); ArrayList&lt;String&gt; names = fields.getSignatureNames(); </code></pre> <p>You can only remove the signature that covers the whole document, for instance, if we have <code>"sig1"</code>, <code>"sig2"</code>, and <code>"sig3"</code> (added in that order), only <code>fields.signatureCoversWholeDocument("sig3")</code> will return true.</p> <p>You can get the total number of revisions like this: <code>fields.getTotalRevisions()</code> and a specific revision like this: <code>fields.getRevision("sig1")</code> (provided that there's a signature field named <code>"sig1"</code>).</p> <p>Suppose that the image represents your document, and you have to remove 1 signature, then you can only remove the third signature by removing all the bytes that were added in revision 3 (Rev3). With iText, that means going back to revision 2 (Rev2). That revision was signed using the signature field <code>sig2</code>. You can extract this revision like this:</p> <pre><code>FileOutputStream os = new FileOutputStream("revision2.pdf"); byte bb[] = new byte[1028]; InputStream ip = fields.extractRevision("sig2"); int n = 0; while ((n = ip.read(bb)) &gt; 0) os.write(bb, 0, n); os.close(); ip.close(); </code></pre> <p>The file <code>revision2.pdf</code> will be the file signed by <code>"sig1"</code> and <code>"sig2"</code> without the bytes that were added when creating <code>"sig3"</code>.</p>
27,702,422
0
Streaming H264 video for Logitech C920 using GStreamer produces a relief <p>I'm trying to stream the native H264 video from a Logitech C920 camera using GStreamer 1.2.4:</p> <pre><code>gst-launch-1.0 v4l2src ! video/x-h264,width=640,height=480,framerate=10/1 ! \ h264parse ! decodebin ! videoconvert ! ximagesink sync=false </code></pre> <p>This produces an image output which is a kind of a relief: <img src="https://i.stack.imgur.com/S3l8Z.png" alt="Relief image of Logitech C920 H264 stream"></p> <p>As soon as add more movement to the scene, the image quality improves but is still far away from being sufficent. I seems that anyhow the stable parts of the video stream are not decoded. </p> <p>Any ideas?</p> <p>I'm using gstreamer 1.2.4 on a Banana PI (Debian Wheezy)</p>
19,401,727
0
<p>One alternative I can think of is Linked CSE. It is a CSE where you host the annotations (urls associated with labels, which decide whether url should be displayed or not) lives on your own server.</p> <p>Because you are not pushing the annotations to Google, you don't incur indexing cost.</p> <p><a href="https://developers.google.com/custom-search/docs/linked_cse" rel="nofollow">https://developers.google.com/custom-search/docs/linked_cse</a> </p>
40,288,524
0
<p>You could use Spring JDBC to populate data in your application.</p> <p>Here you have example how to use it:</p> <p><a href="http://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html#howto-initialize-a-database-using-spring-jdbc" rel="nofollow">http://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html#howto-initialize-a-database-using-spring-jdbc</a></p> <p>But better solution could be using Flyway or Liquibase. How to use this tools is also described in spring documentation.</p>
18,219,240
0
<p>You need to rethink your question. You don't want the 'string' to be case insensitive, but much rather your comparison to realize, that HKCU is the same as Hkcu or hKcU.</p> <p>For this end, there's a number of options, one of which is the already mentioned function <code>stricmp</code>. Prototype is:</p> <pre><code>#include &lt;string.h&gt; int stricmp(const char *string1, const char *string2); </code></pre> <p>Meaning, you'd use it like:</p> <pre><code>if(stricmp(argv[2], "HKCU") == 0) { } </code></pre> <p>Another option is the <code>strcasecmp</code> function which operates similarly.</p> <p>Hope this helps.</p>
40,964,304
0
<p>You might want to check out: <a href="http://www.sqltolinq.com/" rel="nofollow noreferrer">http://www.sqltolinq.com/</a></p> <p>Linqer is a SQL to LINQ converter tool. It helps you to learn LINQ and convert your existing SQL statements.</p> <p>Not every SQL statement can be converted to LINQ, but Linqer covers many different types of SQL expressions.</p> <p>Lets assume you have Table1 and Table2 in an EF dbcontext.</p> <pre><code>from Table1 in context from Table2 in context .Where(t2=&gt; t2.ID == Table1.ID &amp;&amp; t2.example == null).DefaultIfEmpty() select new { id= Table1.ID ,test = Table1.Test ,test2 = Table2.Test } </code></pre>
18,317,083
0
Editing HTML5 LocalStorage through a function <p>I want to be able to add an "Ignore List" with the results being saved on the users browser.</p> <p>The Ignored List is saved as a JSON array and looks like this:</p> <pre><code>[{"username":"test_user","date_added":"19/08/13","description":"Don't like this person."},{"username":"test_user_2","date_added":"19/08/13","description":"Don't like this person."}] </code></pre> <p>And the function required to add the users look like this:</p> <pre><code>function add_to_ignore_list() { var ignored_users = localStorage.getItem("ignore_list"); // returns ignore list var username = return_current_username(); // returns test_user3 var date = return_current_date(); // returns 19/08/13 var description = prompt("Why do you want to ignore this user?"); // returns desc add_to_list = { "username" : username, "date_added" : date, "description" : description }; ignored_users.push(add_to_list); localStorage["ignore_list"] = JSON.stringify(ignored_users); $(".user_wrapper").css("background-color","#B40404"); } </code></pre> <p>For some reason it isn't working and I can't see why Please help.</p>
4,451,251
0
<p>On the server people are not obliged to use a specific language, and JavaScript is so free-form that code becomes very difficult to maintain.</p> <p>That's why the largest percentage of people choose something else.</p>
4,000,173
0
MIPS Register comparator <p>Given two input registers in MIPS: $t0, $t1</p> <p>How would you figure out which one is bigger without using branches?</p>
32,612,324
0
How to subset data for a specific column with ddply? <p>I would like to know if there is a simple way to achieve what I describe below using <code>ddply</code>. My data frame describes an experiment with two conditions. Participants had to select between options <em>A</em> and <em>B</em>, and we recorded how long they took to decide, and whether their responses were accurate or not. </p> <p>I use <code>ddply</code> to create averages by condition. The column <code>nAccurate</code> summarizes the number of accurate responses in each condition. I also want to know how much time they took to decide and express it in the column <code>RT</code>. However, I want to calculate average response times <strong>only when participants got the response right</strong> (i.e. <code>Accuracy==1</code>). Currently, the code below can only calculate average reaction times for all responses (accurate and inaccurate ones). Is there a simple way to modify it to get average response times computed only in accurate trials?</p> <p>See sample code below and thanks!</p> <pre><code>library(plyr) # Create sample data frame. Condition = c(rep(1,6), rep(2,6)) #two conditions Response = c("A","A","A","A","B","A","B","B","B","B","A","A") #whether option "A" or "B" was selected Accuracy = rep(c(1,1,0),4) #whether the response was accurate or not RT = c(110,133,121,122,145,166,178,433,300,340,250,674) #response times df = data.frame(Condition,Response, Accuracy,RT) head(df) Condition Response Accuracy RT 1 1 A 1 110 2 1 A 1 133 3 1 A 0 121 4 1 A 1 122 5 1 B 1 145 6 1 A 0 166 # Calculate averages. avg &lt;- ddply(df, .(Condition), summarise, N = length(Response), nAccurate = sum(Accuracy), RT = mean(RT)) # The problem: response times are calculated over all trials. I would like # to calculate mean response times *for accurate responses only*. avg Condition N nAccurate RT 1 6 4 132.8333 2 6 4 362.5000 </code></pre>
28,846,495
0
<p>Try the following code.</p> <pre><code>function checkDate(theForm) { var a = theForm.date1.value; var b = theForm.date2.value; var date1 = new Date(a); var date2 = new Date(b); date1.setHours(date1.getHours() - 9); date2.setHours(date2.getHours() - 9); document.getElementById("demo").innerHTML = "Date 1 : " + date1.toString() + "&lt;br/&gt;Date 2 : " + date2.toString(); return false; } </code></pre>
36,054,215
0
lwip tcp payload length is changing <p>I am using lwip tcp for streaming data from sensor to a server program running in a PC(linux).My TCP_MSS is 1160, even though it sending packets of size 462,which is normal. But while doing so suddenly my packet size is changed to 1160 and after sending a few packets of size 1160 the connection is getting terminated by sending FIN packet. Why? I am getting the ACKs also from the server side. There is no congestion or any other network issue. </p>
7,379,311
0
<p>Instead of using $.getJSON, you can use $.ajax and set the cache option to false. I think that sound fix the issue.</p> <pre><code>$("#loginForm").submit(function(e) { var form = $(this); $.ajax({ type: 'GET', url: "cfcs/security.cfc?method=processLogin&amp;ajax=1&amp;returnformat=JSON&amp;queryformat=column&amp;" + form.serialize(), dataType: "json", cache: false, success: function(json) { // everything is ok. (server returned true) if (json === true) { // close the overlay triggers.eq(0).overlay().close(); $("#loginMenu").html("&lt;a href='logout.cfm'&gt;Log out&lt;/a&gt;"); // server-side validation failed. use invalidate() to show errors } else if (json === "More than five") { var tempString tempString = "&lt;h2&gt;Too many failed logins &lt;/h2&gt;" $("#loginMsg").html(tempString); triggers.eq(0).overlay().close(); $("#toomanylogins").overlay().load(); } else { var tempString tempString = "&lt;h2&gt;" + json + " failed logins&lt;/h2&gt;" $("#loginMsg").html(tempString); } } }); // prevent default form submission logic e.preventDefault(); }); // initialize validator and add a custom form submission logic $("#signupForm").validator().submit(function(e) { var form = $(this); // client-side validation OK. if (!e.isDefaultPrevented()) { // submit with AJAX $.ajax({ type: 'GET', url: "cfcs/security.cfc?method=processSignup&amp;returnformat=JSON&amp;queryformat=column&amp;" + form.serialize(), dataType: "json", cache: false, success: function(json) { // everything is ok. (server returned true) if (json === true) { // close the overlay triggers.eq(1).overlay().close(); $("#loginMenu").html("&lt;a href='logout.cfm'&gt;Log out&lt;/a&gt;"); // server-side validation failed. use invalidate() to show errors } else { form.data("validator").invalidate(json); } } }); // prevent default form submission logic e.preventDefault(); } }); </code></pre>
34,014,302
0
<p>Now you could zoom to bounds with <strong>.newLatLngBounds()</strong> method:</p> <pre><code>map.animateCamera(CameraUpdateFactory.newLatLngBounds(place.getViewport(), 10)); // 10 is padding </code></pre> <p>It will move and zoom to given bounds, so they all visible on a screen (e.g. different zoom for city or country). It works perfectly with location search.</p>
14,083,126
0
How can the onMouseWheel event be caught and stopped from being handled elsewhere <p>I would like to catch the <code>onMouseWheel</code> event for the whole page (for context I am doing custom scrolling) but need to stop everything else on the page handling it too. How could this be done?</p> <p>Thanks in advance.</p>
8,209,930
0
How to set child li attribute based on the parent li attribute using Jquery? <p>I have the menu structure like below,</p> <pre><code>&lt;div class="submenu"&gt; &lt;ul class="treeview"&gt; &lt;li class="submenu" id="menu-item-5592" style="background-image: url('open.gif');"&gt; &lt;a href="/Products/Category/Large-Custom-Water-Features"&gt;Large Custom Water Features&lt;/a&gt; &lt;ul class="sub-menu" rel="open" style="display: block;"&gt; &lt;li class="submenu" &gt; &lt;ul class="submenu" rel="closed" style="disply:none;"&gt; &lt;li&gt;&lt;/li&gt; &lt;li&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>In the above menu the whole li has <code>style="background-image: url('open.gif');"</code>. previously it was <code>style="background-image: url('closed.gif');"</code>.</p> <p>the above attribute set when i clicked that link. i need when i click that link the i needt to change display attribute from <code>&lt;ul class="submenu" rel="closed" style="display:none;"&gt;</code> to <code>&lt;ul class="submenu" rel="closed" style="display:block;"&gt;</code></p> <p>how can i do this?</p>