input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
Why can two git worktrees not check out the same branch? <p>Using a separate <a href="https://git-scm.com/docs/git-worktree" rel="nofollow">git-worktree</a>, why can I not check out the same branch as in the main working copy? If I try, I get the error:</p>
<pre><code>fatal: 'mybranch' is already checked out at '/path... | <blockquote>
<p>I can see that if I check in from one worktree, the other would end up in a detached HEAD state</p>
</blockquote>
<p>Actually, it <em>wouldn't</em>, and that's the problem!</p>
<p>Each work-tree has its own <code>HEAD</code>, and its own index (aka staging-area or cache). All share the actual under... |
Can anyone explain the output of following statement? <p>I am not able to understand the following statement written in C:</p>
<pre><code>printf("%d", printf("%d", printf("%s", "I love c programming")));
</code></pre>
<p>Is it valid to write such statement in C?</p>
<p>When I run it, I get the output:</p>
<pre><cod... | <p><code>printf</code> returns an <code>int</code> indicating an error or containing the number of characters written. So, because <code>%d</code> is the format string for an <code>int</code>, this nesting is completely valid.</p>
<p>Your output is <code>"I love c programming202"</code>. So let's break that down:</p>
... |
Calculate run time of a given function python <p>I have created a function that takes in a another function as parameter and calculates the run time of that particular function. but when i run it, i can not seem to understand why this is not working . Does any one know why ? </p>
<pre><code>import time
import random
i... | <p>It looks like the code just executes incredibly fast. In <code>bubbleSort</code>, I added an additional <code>for</code> loop to execute the comparisons another <code>10000</code> times:</p>
<pre><code>@timeit
def bubbleSort(NumList):
compCount,copyCount= 0,0
for i in range(10000):
for currentRange... |
write xsi:type using XmlWriter <p>Is there a way to add the string "xsi:type="SomeType" using XmlWriter class ?</p>
<p>My Element should look like this:</p>
<pre><code><Event xsi:type="SomeEvent" filename="c:\myFile.txt" ilepresence="Present">
</code></pre>
| <p>I could not find a way to add an attribute "xsi:type" to an Element using XmlWriter. I ended up using XmlDocument instead and was able to achieve my goal.</p>
<p>This was my code for achieving the same:</p>
<pre><code>XmlElement items = xmlDoc.CreateElement("Items");
xmlDoc.AppendChild(items);
xmlDoc.DocumentElem... |
Event listener for window.fetch <p>Is there any possibility to globally monitor all <code>window.fetch</code> requests? I know it works with Promises, which is great, but I need to get notified whenever any of such requests is done (fail/success). I have no access to the functions which invoke these or are success/fail... | <p>You can overwrite the fetch function the following way:</p>
<pre><code>var oldFetch = fetch; // must be on the global scope
fetch = function(url, options) {
var promise = oldFetch(url, options);
// Do something with the promise
return promise;
}
</code></pre>
<p>This way you can get control over the r... |
Scala: accessing java primitives done directly or via a wrapper? <p>I know that you can access java primitives directly from Scala </p>
<pre><code>val javaDouble = new java.lang.Double(1.0)
</code></pre>
<p>Does this mean that we are accessing the primitives <strong>via a wrapper</strong> or <strong>directly</strong>... | <p>You say "I know you can access Java primitives directly" and then follow immediately with an example of <em>not</em> a Java primitive but the Java class used to box a primitive.</p>
<p>Scala can access unboxed primitives--the <code>length</code> method on strings, for instance:</p>
<pre><code>scala> val l = "fi... |
Pass stream wrapped by Zend Diactoros PhpInputStream (PSR-7 StreamInterface) to fopen-like function? <p>I have to write something to process an XML document sent via POST. The document has base-64 encoded binaries inside so the request can be quite large.</p>
<p>This works:</p>
<pre><code>$document = simplexml_load_... | <p><a href="https://github.com/zendframework/zend-diactoros/issues/209" rel="nofollow">I asked</a> on the GitHub repo. The solution is to detach the the stream resource from the wrapper object. You can no longer use the wrapper but at least the stream resource is summoned from the framework so at least some decouplin... |
Is this a reasonable approach to building flexible implementations <p>I am the author of several C# libraries used by thousands of developers. I am constantly asked for custom implementations to enable edge cases. I have used the following approaches and each has their merits. Allow me to list them, if for no other rea... | <p>It's a valid option, but it has a few drawbacks (as you already mention). </p>
<p>Apart from the ones you mention, there's also the fact that your methods can't be generic. (you can't have a <code>Func<T><string, T></code> for example).</p>
<p>I would not suggest using properties though, that could get... |
How to remove all the elements in the array without changing its size in python <p>If i created an array </p>
<pre><code>b = [[] for _ in xrange(10)]
</code></pre>
<p>and i store some numbers in it like this</p>
<pre><code>b = [[], [1], [22, 132], [3, 123], [], [], [6], [], [], [89]]
</code></pre>
<p>Now i want to ... | <p>You need to loop over <code>b</code>, either setting each element to the empty list or deleting the contents of that element:</p>
<pre><code>for i in xrange(len(b)):
b[i] = []
</code></pre>
<p>or</p>
<pre><code>for i in xrange(len(b)):
del b[i][:]
</code></pre>
|
UPDATE table. SET statement wrong syntax? <p>I need some more help. OK, I've got a table as follows:</p>
<pre><code>mysql> SELECT * FROM MODELOS;
+--------+----------+---------+
| ID_MOD | ID_MARCA | MODELO |
+--------+----------+---------+
| 1 | NULL | PICASSA |
| 2 | NULL | C4 |
| 3 |... | <p>I would recommend you don't use subqueries for update, if for any reason than ma of MySQL up through 5.7 cannot optimize inside a subquery. </p>
<p>From the docs: (<a href="https://dev.mysql.com/doc/refman/5.7/en/subquery-optimization.html" rel="nofollow">https://dev.mysql.com/doc/refman/5.7/en/subquery-optimizatio... |
C# System.IO.File.Copy from shared drive works on localhost but access to the path is denied on server <p>I want to copy a pdf from a shared folder to a project folder. So I use System.IO.File.Copy:</p>
<pre><code>System.IO.File.Copy(@"\\netstore\IT\SIGN\112454.pdf", "C:\inetpub\wwwroot\myaspmvcwebapisite\temp\112454.... | <p>Are you saying it runs fine when hosted in a local IIS or within Visual Studio (IIS Express)? IIS Express runs under the active user account, but IIS runs under the App Pool's Identity. Granting access to IIS_USRS is enough for a local directory, but a remote directory will require authentication, which means it wil... |
NStableView does not show my data <p>I have a tableView with an image and a textField but they are not showing the data. What could be missing?</p>
<p>I have tableColumn identifier set as MainCell...
I converted obj-c from <a href="https://github.com/lucasderraugh/AppleProg-Cocoa-Tutorials/blob/master/Lesson%2051/Les... | <p>Translating Objective-C to Swift literally is always a bad idea.</p>
<ul>
<li>First of all make sure that both <code>datasource</code> and <code>delegate</code> of the table view are connected to the view controller in Interface Builder.</li>
<li>Make sure also that the Identifier of the <code>NSTableCellView</code... |
Xamarin Forms: MasterPage Helper class <p>My current app has multiple master detail pages. I want to create a helper class which has a function that accepts list of PageModels-Pages( ViewModels-views ) which I can iterate through and create master detail pages.</p>
<p><strong>MyCurrent Code:</strong></p>
<pre><code>p... | <p>The <code>AddPage<T></code> method is a generic method, which expects a type. In this case it is <code>FreshBasePageModel</code>. The normal usage would be something like:</p>
<pre><code>masterDetail.AddPage<MyViewModel>("MyPage", model);
</code></pre>
<p>or:</p>
<pre><code>masterDetail.AddPage<MyV... |
Trying to connect to a database and present view with Entity Framework. Getting Error with dbContext in controller <p>I am trying to view a database in my browser which I have connected successfully through entity framework to my MVC project. </p>
<p>However I keep getting an error under the using statement applying t... | <p>If <code>Model1</code> has a red squiggly, that's because it either doesn't exist in any project reference and/or the namespace has not been included in the current file.</p>
<p>If you right-click on <code>Model1</code> in your code, you should see a <code>Resolve</code> item in the context menu that appears. If yo... |
C# regular expression match triple quotes """ <p>I have a text file that contain 3 quotations (""") in various lines in text. It also have 6 blank spaces before that in every line.
I have tried doing @"\s{6}\"{3}"; and various cases, but it seems like c# doesn't like when it sees 3 quotations mark together. What I'm t... | <p>To escape a quote inside a verbatim string (starts with @) use double quotes. Also there is a Regex.Replace method that you could use like this:</p>
<pre><code>string input = @" """"""Step: 33 And I enter
Step: 34 And I set the ";
string pattern = @"\s{6}""{3}";
string replacement = "\"\"\"\r\n... |
Listen com port without blocking web application <p>In a web application with spring boot, i search a way to be able to have a method who always listening on the server com port, without blocking the rest of the application.</p>
<p>I use <a href="https://github.com/RishiGupta12/SerialPundit" rel="nofollow">https://git... | <p>What you need to do is;</p>
<p>While your webapp is booting up;</p>
<ul>
<li>Spawn a thread that will listen on your serial port continously,</li>
<li>Make it write it's output to a common place (i.e some thread-safe queue, ThreadLocal etc)</li>
<li>Access to that common container from your Spring controllers</li>... |
java.lang.NoClassDefFoundError in slf4 with spring <p>I'm having troubles configuring slf4j with Spring. I'm using maven, and I can package a .jar, but when I run it, it gives the following exception:</p>
<pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at logger.Lo... | <p>Obviously, <code>org.slf4j.LoggerFactory</code> class can't be found under your classpath.</p>
<ol>
<li>Try to pull the dependencies again, from command-line and from your project folder: <code>dependency:copy-dependencies</code></li>
<li>Try to sync your eclipse IDE by refreshing the project, and/or by m2e eclipse... |
How to calculate Variable Importance in SVM regression models <p>How do I calculate the variable importance of an <a href="https://en.wikipedia.org/wiki/Support_vector_machine" rel="nofollow">SVM</a> regression model implemented in Python?</p>
<p>At least, if an already-implemented function does not exist, I would lik... | <p>You can use "l1" as the <a href="http://scikit-learn.org/stable/modules/generated/sklearn.svm.LinearSVC.html" rel="nofollow">penalty function</a> to get a sparse model. See <a href="http://stats.stackexchange.com/questions/2179/variable-importance-from-svm">here</a> for details. Then just inspect the coefficients o... |
C# Correct pattern for Paralle.For async await method <p>I would like some advise on this method. Is this a good pattern to go with or will something else perform better?</p>
<pre><code> public async Task<PortfolioLoans> GetSampleOfPortfolioLoanNumbers(int count = 1)
{
var sqlConn = new SqlConnec... | <p>The <code>Parallel</code> class was relaesed before before async/await. It does <strong><em>NOT</em></strong> support using <code>async</code> in as the method boday. When you use <code>async</code> it creates an annonamous <code>async void</code> function and because of that it can't tell when the work is complete ... |
How to run python scripts and do CMD in Dockerfile for the docker container <p>I have an image with a custom Dockerfile. When I start the container, I want to run <code>CMD ["npm, "start"]</code> but right before that, I need to run three scripts.</p>
<p>I've tried:</p>
<p>1)putting the python scripts followed by npm... | <p>Had to run <code>ENTRYPOINT ["script-path/script.sh"]</code></p>
|
JQuery autocompleted does not clear the input after select <p>I want my input field to be cleared after the user select the input from the autocopmleted I have searched for answers on stackoverflow and none of the answers work for me.
Here is my code:</p>
<pre><code> $("#fastSearchInput").autocomplete({
... | <p>Change the name of your select handler's first parameter to <code>event</code>. E.G</p>
<pre><code>$("#fastSearchInput").autocomplete({
source: users,
select: function (event, ui)
{
id = ui.item.data;
window.open("member.php?id="+id,'_blank');
$(this).val("");
event.preventDefault();
}});... |
Adwords - Approved banner won't display <p>I started my first Adwords text campaign few weeks ago and everything looked ok. I get 20-30 visitors a day for about 3 euros per day.
Now I added banner add, they approved it, but it won't display as you can see on the screenshot. I paused the text ad and I raised the bid to ... | <p>It's better to create two separate campaigns:
Search Network only for text ads
Display Network only for banners</p>
<p><a href="https://support.google.com/adwords/answer/2567043?hl=en" rel="nofollow">https://support.google.com/adwords/answer/2567043?hl=en</a></p>
<p>Also, create multiple banners (horizontal, verti... |
Rotate Mapbox Map depending of the phone current orientation <p>I'm trying to rotate the map to always face the direction we are moving towards to with <strong>MapBox</strong> Android. Currently, this is what I tried without success:</p>
<p>This is where I initialize the <code>mapbox</code> map:</p>
<pre><code>mapVie... | <p>Which version of the SDK are you using? I <a href="https://github.com/mapbox/mapbox-gl-native/pull/5877" rel="nofollow">merged a compass listener fix</a> last month that fixed the compass bearing tracking. You can read more about the <a href="https://github.com/mapbox/mapbox-gl-native/issues/5861" rel="nofollow">iss... |
Create business object using JSON processing from JavaEE 7 <p>I am investigating JSON processing from JavaEE 7 and i have a question described below.</p>
<p>(before asking i have read below info but still have a question)</p>
<p><a href="http://docs.oracle.com/javaee/7/tutorial/jsonp004.htm" rel="nofollow">http://doc... | <p>I think what you're looking for is a constructor method. In your case for the user you have three separate fields which can be populated as soon as you instantiate your User object.</p>
<p>In order to do this add this method (constructor) to your User class:</p>
<pre><code>public User(Long id, String email, String... |
Extjs ajax request is returning in a disorderly manner <p>My application performs a code for query.
The user enters the 3947 code.</p>
<p>For each type a query in this case four querys.
But as the request is asynchronous, there is sometimes the last to arrive before others.
So it happens that the last record returned ... | <p>In a simplified way you could ignore all requests and perform only the last in this way:</p>
<pre><code>listeners: {
change: function (sender, newValue, oldValue, eOpts) {
if (call_request) clearTimeout(call_request);
call_request = setTimeout(loadData, 750);
}}
</code></pre>
|
Which way is better to pass function in javascript? <p>If I have 3 js files as follow:</p>
<p>file1.js</p>
<pre><code>this.functionName = function(params) { //do something};
</code></pre>
<p>file2.js</p>
<pre><code>function fucntionName(params) {
//do something
};
module.exports = {
functionName
};
</co... | <p>If you are using ES6 with Babel, it is a lot cleaner to use the <code>export</code> syntax. That is, if you want to reference the function directly, like this:</p>
<pre><code>const fName = function(){
/* do stuff here */
}
export default fName;
</code></pre>
<p>Or if you want to export multiple functions without... |
Howto use parameters in a function or alias in .bashrc on ubuntu? <p>For example this does not work:</p>
<pre><code>man(){ man -H "$1" & }
</code></pre>
<p>But I need the parameter, because I want the command to end with an ampersand.</p>
<p>This doesn't work as well:</p>
<pre><code>man(){ firefox & man -H ... | <p>The parameter isn't a problem. The <em>recursion</em> is the (most severe immediate) problem.</p>
<p>When you have a function named <code>man</code> call <code>man</code>, it calls itself. You're starting an unbounded set of background shells. Using <code>command</code> will prevent that recursion, as it bypasses f... |
Pandas to_csv export giving wrong values in a dataframe <p>I am using pandas and have imported two csv.</p>
<p>df1 is </p>
<p><a href="http://i.stack.imgur.com/wCbAG.png" rel="nofollow"><img src="http://i.stack.imgur.com/wCbAG.png" alt="enter image description here"></a></p>
<p>df2 is </p>
<p><a href="http://i.stac... | <p>I looked at your files, as @root was saying above, in df1 the combination of <code>Origin City Code</code> and <code>DC</code> are not unique. For instance, there are two records with <code>Origin City Code</code> = GGN and <code>DC</code> = ASA. </p>
<p>If you want to check it out you can run the following code:</... |
UIDatePicker in a popover randomly doesn't update the first time but will every time after that <p>I have a UIDatePicker being shown in a popover. When I spin, half the time the value won't update, then it will every time after that. The other half, it updates the first time and every time after that - just as expected... | <p>Seems like iOS buffer issues.</p>
<p>try to change the runloop and make the multiple of 60 secs. It works for me.</p>
<pre><code>- (void) someMethodName
{
[self performSelector:@selector(sel:) withObject:datePicker afterDelay:0];
}
- (void) sel:(UIDatePicker *)datePicker
{
datePicker.countDownDuration = 6... |
C# Sort a list from the values of another list <p>hoping you can help me with this.</p>
<p>Okay I have two lists.</p>
<p>List1 - Gets the names of files without a path (so I can list the names on dynamically created buttons). More so for visual purposes only.</p>
<p>List2 - Stores the actual path to the file.</p>
<... | <p>I agree with the comments above, use a single list of full paths and use the System.Io.Path.FileName method to order by file name regardless of directory.</p>
<pre><code> var list2 = new List<string>() { @"C:\Directory1\B.txt", @"C:\Directory2\A.txt" };
var orderedList = list2.OrderBy(System.IO... |
Using multiple levels of inheritance with sqlalchemy declarative base <p>I have many tables with identical columns. The difference is the table names themselves. I want to set up a inheritance chain to minimize code duplication. The following single layer inheritance works the way I want it to:</p>
<pre><code>from sql... | <p>An example is in the <a href="http://docs.sqlalchemy.org/en/latest/orm/extensions/declarative/mixins.html#augmenting-the-base" rel="nofollow">docs</a>. In particular, <code>__abstract__ = True</code> is not necessary. This works fine:</p>
<pre><code>class Base(object):
@declared_attr
def __tablename__(cls):... |
How to make requests.post not to wrap dict values in arrays in python? <p>I use python requests.post function to send json queries to my django app.</p>
<pre><code>r = requests.post(EXTERNAL_SERVER_ADDRESS, data={'123':'456', '456':'789'})
</code></pre>
<p>But on the external server request.POST object looks like thi... | <p>requests is not doing anything here. Presumably your receiving server is Django; that's just how it represents data from a request. <code>request.POST['123']</code> would still give '456'.</p>
|
Swagger's allOf shows up as undefined <p>I've take the allOf examples in <a href="https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#models-with-composition" rel="nofollow">https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#models-with-composition</a>, and applied them to par... | <p>A <code>type</code> field is missing in <code>Cat</code> Definitions Object and therefore swagger-editor shows <code>undefined</code>. </p>
<p>Add <code>type: object</code> as follow can fix it:</p>
<pre><code>Cat:
type: object
description: A representation of a cat
allOf:
</code></pre>
|
Can I access the owning class in the constructor in c++? <p>Let's say I have the following code:</p>
<pre><code>class CreatedClass
{
public:
CreatedClass()
{
OwnerClass* oc = GetMyOwner(); //How without parameters?
}
};
class OwnerClass
{
public:
OwnerClass()
... | <p>The short answer is "not really."</p>
<p>Also, if you were to pass in the "owning" class, you would want to do it by reference, not by pointer, as presumably there would never be a case where there was no "owning" class.</p>
<p>The larger question is, what are you trying to accomplish with this?</p>
|
Page order Changed and now getContext is Null <p>I changed my applications so a different page would load when ran but now I receive the error</p>
<blockquote>
<p>Unable to get property 'getContext' of undefined or null reference</p>
</blockquote>
<p>It's not causing any problems yet but I'm hoping to fix it before... | <p>I think I found the solution to my problem. Since page 1 requires the <code>@Scripts.Render("~/Scripts/app")</code> line I moved it from the bottom of <code>Layout.cshtml</code> to <code>Page 1.cshtml</code> since <code>Page 1.cshtml</code> isn't the first to load anymore.</p>
<p>I'm currently checking to make sur... |
Argument type '[HKCategoryType?]' does not conform to expected type 'Hashable' <p>I am trying to request the authorisation for a Category in healthkit by using code:</p>
<pre><code>let healthKitStore: HKHealthStore = HKHealthStore()
let healthKitTypesToWrite = Set(arrayLiteral:[
HKObjectType.categoryType(forIdenti... | <p>The linked article is not a good example of creating a Set from ArrayLiteral.</p>
<p>You need to pass a <code>Set<HKSampleType></code> to <code>requestAuthorization(toShare:read:)</code> (the method has been renamed in Swift 3), and Swift is not good at inferring collection types.</p>
<p>So, you'd better exp... |
inserting a node to a certain node in XML file Using R <p>I've XML file, consist of 37 Major folder,each major folder has number of minor folders, and each minor folder has 3 placemarks.</p>
<p>i wanna add this node to the first placemark at this first minor folder which in the first major folder. </p>
<p>i tried to ... | <p>Consider using <code>getNodeSet</code> to find the specific element you intend to add the XML snippet, then in defining the new child make sure to reference the new element's parent to this nodeset:</p>
<pre><code>data <- xmlTreeParse("xml_data.xml")
firstplacemark <- getNodeSet(data, "/Folder/Folder[1]/Folde... |
How to select an Angular 2 Array Object from JSON <p>I am very new to Angular 2, and I am having trouble with what I feel is a small, but frustrating problem.</p>
<p>I am building a SPA with two main pages, the admin page and the actual app homepage. The admin panel needs to be able to update several text fields on th... | <p>First, your Angular2 app will completly run on the client side.
So there is no possibility to create a JSON-file. You will need a backend-server.
Your Angular2 app will GET/POST the content from/to the backend.</p>
<p>And better than a JSON-file would be a database (MySql, MsSql, Postgre, MongoDb, ....)</p>
|
How to extract all values from a nested arrays in an array into a single flat array - JS <p>I'm looking for a function which would extract all the elements from an array, even these nested, and return a single flat array with all the elements.</p>
<pre><code>Example:
function(1, [2, 3], 4, 5, [6, [7]], [8, [9, [10, ... | <p>Try this one:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function extract(){
return [].slice.call(arguments).reduce(function(a,b){
return a.concat(Array... |
Extracting a row from a table from a url <p>I want to download EPS value for all years (Under Annual Trends) from the below link.
<a href="http://www.bseindia.com/stock-share-price/stockreach_financials.aspx?scripcode=500180&expandable=0" rel="nofollow">http://www.bseindia.com/stock-share-price/stockreach_financial... | <p>The text is in the <em>td</em> not the <em>tr</em> so get the <em>td</em> using the text and then call <em>.parent</em> to get the <em>tr</em>:</p>
<pre><code>In [12]: table = soup.find('table',{'id' :'acr'})
In [13]: tr = table.find('td', text='EPS').parent
In [14]: print(tr)
<tr><td class="TTRow_left" ... |
How to batch GitHub GraphQL API queries? <p>How can multiple queries be batched into a single request to GitHub's GraphQL API?</p>
<p>For example, how would you batch these 2 queries into a single request and receive a single response? And would this technique work with many more queries (say 200)?</p>
<pre><code>{
... | <p>You need to wrap the calls to both fields in one query:</p>
<pre><code>{
repositoryOwner(login:"rails") {
repository(name:"rails") {
description
homepageURL
}
}
repositoryOwner(login:"github") {
repository(name:"graphql-client") {
description
homepageURL
}
}
}
</code... |
How restart a stopped docker container <p>Suppose i launch a docker container from an image with this command:</p>
<pre><code> docker run -d myimage /bin/bash -c "mycommand"
</code></pre>
<p>When mycommand is finished, the container is stopped (i suppose it is stopped) but it is not deleted, because i can see it wit... | <p>Yes, when the initial command finish its execution then the container stops.</p>
<p>You can start a stopped container using:</p>
<p><code>docker start container_name</code></p>
<p>If you want to see the output of your command then you should add <code>-ai</code> options:</p>
<p><code>docker start -ai container_n... |
php code to check if a string is in the database or not is not working <p>I wrote a php code to check that a random string generated is in the database or not. but it says that "Object of class mysqli_result could not be converted to int in C:\xampp\htdocs\mobile\include\user.php on line 147".</p>
<p>My code is:</p>
... | <p>I modified my code and now the problem is solved</p>
<p>My code:</p>
<p>private function generate_URC() { //URC = Unique User Registration Code
$URC = $this->generateRandomString();</p>
<pre><code> $query = "select URC from " . $this->db_URC_table . " where URC = '$URC' Limit 1";
$result ... |
Jasper Reports: Exporting report to multiple files <p>I'm developing a jrxml template for generate job candidate's resume. The candidates are in my database.</p>
<p>I need to generate a Word file (.docx) for 1 record (by job candidate), as the image below:</p>
<p><a href="http://i.stack.imgur.com/AAaN1.jpg" rel="nofo... | <p><strong>PROBLEM SOLUTION</strong></p>
<p>I solved the problem by inserting a variable in the footer of each page with the expression: $V{REPORT_COUNT}, which have record count that is in the Detail Band:
<a href="http://i.stack.imgur.com/33pHI.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/33pHI.jpg" alt="e... |
How Can I create a wrapper module in Angular2 for multiple modules? <p>I am currently trying to clean up my project structure and I wanted to keep my AppComponent as clean as possible. I am importing angular2 material in its own file:</p>
<pre><code>import { NgModule } from '@angular/core';
// Material
import { MdCar... | <p>You can use <strong>SharedModule</strong>. Declare common things in <strong>SharedModule</strong> and then import <strong>SharedModule</strong> in components where you want to use common things.</p>
<p>Learn more about SharedModule here : <a href="https://angular.io/docs/ts/latest/guide/ngmodule.html#!#shared-modul... |
Add custom new routes to rails resources <p>I my routes file, I have defined a resource</p>
<pre><code>namespace :admin do
resources :invoices, only: [:index, :new]
end
</code></pre>
<p>Then I've got a route rule with corresponding path helper new_admin_invoice_path</p>
<pre><code>new_admin_invoice GET /admin/invo... | <p>Here is the easy rails way from official guide</p>
<pre><code>resources :invoices, only: [:index] do
get 'incoming', on: :new, type: :incoming, action: :new
end
</code></pre>
<p>Results to</p>
<pre><code>incoming_new_admin_invoice GET /admin/invoices/new/incoming(.:format) admin/invoices#new {:type=>:incomin... |
Using the "i-=smallest" statement in the code below, I intend to alter my original array arr, but that isn't happening. What do I do? <p>Here's the code:</p>
<pre><code>n = int(input())
arr = input().split()
arr = [int(x) for x in arr]
smallest = 1001
while(True):
if smallest==0:
break
arr.sort()
c... | <p>Let's look at the inside loop</p>
<pre><code>for i in arr:
if i==0:
arr.remove(i)
i-=smallest
count+=1
</code></pre>
<p>It assigns the first value in <code>arr</code> to <code>i</code>. Since no value of the array is zero, it doesn't remove anything from the list. </p>
<p>It then reassigns the... |
EF - not supported in LINQ to Entities <p>I am trying to list some food items with a controller. I use Repository pattern with UnitOfWork for the data in another assembly and referenced it in a BaseApiController. The <strong>Data</strong> property is my UnitOfWork instance.</p>
<pre><code>var result = Data.Food
... | <p>Change you <code>FoodItem</code> class to the one below, <strong><code>IEnumerable<T></code> is not supported as a type for a navigation collection</strong> :</p>
<pre><code>public class FoodItem
{
public FoodItem()
{
this.Measures = new HashSet<Measure>();
this.DiaryEntries = ne... |
In WebLogic is there a way to start the Administration Console Manually <p>When I start up my WebLogic server I'm only getting the entity manager to come up. The administration console isn't coming up. I.e. MySite:7001/console is bombing but MySite:7001/em is coming up fine. Any ideas of how to correct this?</p>
| <p>This actually ended up being a glitch. After I bounced the server, the console and entity manager came up just fine under the same port.</p>
|
Send webRTC getUserMedia webCam stream over socketio <p>I have this piece of code: </p>
<pre><code>navigator.mediaDevices.getUserMedia(param)
.then(function(stream) {
video.srcObject = stream;
video.play();
}
})
.catch(function (err) {});
</code></pre>
<p>In this code I want to send this stream over socketi... | <p>I think something like this is your best bet: <a href="http://stackoverflow.com/a/17938723/5915143">http://stackoverflow.com/a/17938723/5915143</a></p>
<p>You'd record the stream using MediaStreamRecorder and send it with 'emit()' calls on socket io to your server.</p>
<p>Alternatively you can use a streaming libr... |
After adding elements to a div with javascript, an untouched existing link stops working? <p>I have some html like this</p>
<pre><code><div id='myArea'></div>
<div id='aDifferentUnrelatedArea'></div>
<a href='#' id='closeButton' class='myButton'>Close</a>
</code></pre>
<p>the butto... | <p>Sorry for the confusion but thanks for helping me find the problem. The actual problem was I had this floating footer button at the bottom of the page. It seemed to take up the whole line's functionalities (I mean anything on the same line as the button would behave like a picture). I just added extra space at the b... |
Spying method calls the actual Method <p>I am writing a JUnit with Mockito. But on the line </p>
<pre><code>when(encryptDecryptUtil.getKeyFromKeyStore(any(String.class))).thenReturn(keyMock);
</code></pre>
<p>It calls the actual method, which is causing the test failure. Interesting point is that it directly makes th... | <p>Have a look at the "Important gotcha on spying real objects" section of the <a href="http://site.mockito.org/mockito/docs/current/org/mockito/Spy.html" rel="nofollow">Spy documentation</a>.</p>
<p>Essentially, you cannot use the <code>when(...).thenReturn(...)</code> pattern with Spies, because as you have discover... |
Receiving strict mode warning while running node 4.4.7 <p>I believe node v4.4.7 supported ES6. However node refuses to compile my program:</p>
<pre><code>user1-$ node -v
v4.4.7
user1-$ node index.js
event-service.js:85
let sql = 'SELECT * FROM group_events where id = ?';
^^^
SyntaxError: Block-scoped dec... | <p>run <code>node --use_strict index.js</code> to force it using strict mode</p>
|
TFS error: "the project file or web could not be found" <p>I've been dealing with this issue for weeks now but until today was unable to solve it. I have a solution with 5 projects in it. It downloads them just fine except for one. I could not figure out why... I get the error:</p>
<p>"the project file or web could no... | <p>I dug into the solution file from file explorer and noticed that it was referencing the project from another folder outside the project (which I hadn't noticed existed till today). Once I downloaded that project from TFS it fixed the problem. </p>
<p>I figured since no where on google did I find this exact error me... |
How we can link my own design website to whmcs <p>I am planning to start website hosting company as a reseller.I have big trouble about designing of my website for web hosting.I want my clients choose plans, register domain and create own cpanel account by registering on my own design sign up form.I searched almost eve... | <p>You need to add your product in WHMCS with the cart URL and then assign that cart URL on your site so that when your client select plan, WHMCS will create account under your reseller account with that plan details.</p>
<p>You can add your product in your WHMCS URL with <a href="http://docs.whmcs.com/Products_and_Se... |
Trigger an event created by .on() <p>I have a jQuery event defined as follows :</p>
<pre><code>$('#pagebody').on('click', '#serverCompTab', function () {
toggleTabs('#serverComp', '#serverCompTab');
});
</code></pre>
<p>I would like to trigger this event manually on my code like <code>$('#'serverCompTab].onclick(... | <p>Use <code>click()</code> instead of <code>onclick()</code> :</p>
<pre><code>$('#serverCompTab').click();
//Or
$('#serverCompTab').trigger('click');
</code></pre>
<p><strong>NOTE :</strong> you should replace <code>]</code> by <code>)</code> and move the quote to the end :</p>
<pre><code>$('#'serverCompTab]
____^_... |
QStyledItemDelegate partially select text of default QLineEdit editor <p>I have a subclass of <code>QStyledItemDelegate</code> which at the moment does not reimplement any functions (for simplicity of the question).</p>
<p>With default <code>QStyledItemDelegate</code> implementation, when the user begins to edit text ... | <p>As noted in my comments to the question, the problem with subclassing <code>QStyledItemDelegate</code> and trying to set any default selection in <code>setEditorData</code> like this:</p>
<pre><code>void setEditorData(QWidget* editor, const QModelIndex &index)const{
QStyledItemDelegate::setEditorData(editor... |
How can I check if an audio livestream is active behind a given URL? <p>I want to build a little script in nodejs which goes through a list of URLs and <strong>checks if there is an audio livestream actually running</strong>.</p>
<p>The URLs can either be direct mp3 livestreams or HLS livestream URLs which link to .m3... | <p>The tricky thing here is that even though the source may be down, the server may still return its buffered data. In fact, this is very common. Servers will buffer 20-30 seconds of data or so, and will send that to you on connect. With HLS, the problem is even worse as usually a large number of HLS segments will b... |
excaping characters to run xp_cmdshell <p>I know that I need to escape the @cmd var to run:</p>
<pre><code>declare @cmd 'xp_cmdshell ''echo Mary|Warrior > c:\test.txt'''
exec (@cmd)
</code></pre>
<p>because the character '|' would fail when running the command.</p>
<p>So, previous running I set:</p>
<pre><code>s... | <p>You can try using this query, As sean mentioned it is potential sql injection</p>
<pre><code>declare @cmd nvarchar(500) = N'echo ''Mary|Warrior'' > c:\test.txt'
exec master.sys.xp_cmdshell @cmd
</code></pre>
|
How would I create a form for a foreign key field that has a drop down menu with an 'add item' option in django? <p>I'll start with my model fields: </p>
<pre><code>class Store(models.Model):
name = models.CharField(max_length=250)
def __str__(self):
return self.name
class Product(models.Model):
... | <p>Django implements this in terms of <a href="https://docs.djangoproject.com/en/1.10/topics/forms/formsets/" rel="nofollow">a "formset"</a>. Check out this tutorial for additional information: <a href="http://whoisnicoleharris.com/2015/01/06/implementing-django-formsets.html" rel="nofollow">http://whoisnicoleharris.co... |
Need help adding API PUT method to Python script <p>I am using the script below to collect inventory information from servers and send it to a product called Device42. The script currently works however one of the APIs that I'm trying to add uses PUT instead of POST. I'm not a programmer and just started using python w... | <p>Ok first things first you need to understand the difference between PUT and POST. I would write it out but another member of the community gave a very good description of the two <a href="http://stackoverflow.com/questions/107390/whats-the-difference-between-a-post-and-a-put-http-request">here</a>.</p>
<p>Now, yes ... |
nested for loops for method in a multi array, java <p>How come my code returns false when I run it?</p>
<pre><code>//Main
public class blah {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Strict run = new Strict();
//Input
int[][] m1 = new int[3][... | <p>You set isitEqual as false initially and never change it to true anywhere in your equals() method.</p>
<p>You can either replace</p>
<pre><code>return isitEqual;
</code></pre>
<p>with</p>
<pre><code>return true;
</code></pre>
<p>and just remove</p>
<pre><code>boolean isitEqual = false;
</code></pre>
<p>all t... |
Check if string from main is a valid float <p>I currently have the below code. However if something like 3.1?43 is entered it is still labeled as a float. I know that I am not properly checking after the . but I am unsure of how to check for that.</p>
<pre><code>int floatNum(char *s) {
char *ptr = s;
char *ep ... | <p>To test if a string is a valid floating point value, use <a href="https://linux.die.net/man/3/strtod" rel="nofollow"><code>strtod</code></a>. This function parses numeric strings with an optional decimal point and an optional exponent specifier ("e" or "E"):</p>
<pre><code>char *p;
errno = 0;
double f = strtod(st... |
Getting a value from a different column but same row and adding it to a sum using VBA <p>I'm having trouble with this code. The code goes through one column (column B) and whenever it sees a specific word it would take the value located in column D. e.g if the key word is located in B2 then it would take the value from... | <p>As per my comment this can be done with the following formula:</p>
<pre><code>=SUMIF(Sheet1!B:B,"Payment",Sheet1!D:D)
</code></pre>
<p>But if you want the vba:</p>
<ol>
<li>The second loop is not needed.</li>
<li>The output on Sheet2 should be after the loop.</li>
<li>No need to activate the sheet.</li>
</ol>
<p... |
Angular 2 â Acting on two BehaviorSubject / Observables <p>Suppose I have a component which needs two observables to render its content:</p>
<pre><code>this.manifest.subscribe((a) => {
f(a, b)
})
this.route.params.subscribe((b) => {
f(a, b)
})
</code></pre>
<p>What is the proper Angular / rxjs way ... | <p>You can use <code>combineLatest</code> to merge the two streams and fire each time one of them fires.</p>
<pre><code>Rx.Observable.combineLatest(this.manifest, this.route.params, (a, b) => f(a, b))
.subscribe(c => /*Do something with the result of f(a,b)*/
</code></pre>
<p>Note that the above only fires on... |
Not able to calculate of count based on two conditions in VBA? <p>I am trying to calculate the count of some data occerence based on two conditions by using VBA in Excel. Below is the scenario that i am trying to implement :</p>
<p>There is one Excel Sheet say <strong>SHEET1</strong> having data as mentioned below.</p... | <p>You can use this UDF:</p>
<pre><code>Function COUNTX(crit As String, critrng As Range, prdrng As Range) As Long
Dim critArr, prdArr
Dim i&, j&
Set dict = CreateObject("Scripting.Dictionary")
critArr = critrng.Value
prdArr = prdrng.Value
For i = LBound(critArr, 1) To UBound(critArr, 1)
If critArr(i, 1)... |
Manage number of attempts to an endpoint in a restful api <p>While there is no session in a restful api, what's the best/common way to manage number of attempts (for example login) in a restful api?</p>
| <p>Create a table inside the Database like token_storage_tbl, then add three columns: tid (int) 255 PK AI, token (varchar) 1024, times_used int (255)</p>
<p>You can then use your connection to query and increment the times_used table.</p>
<pre><code>$smtp = $pdo->Prepare('UPDATE token_storage_tbl SET times_used = ... |
Date not loaded properly vue.js <p>With the function <code>getDate()</code> I would like to show the <code>current date</code> in a input field. That's why I've bind <code>ride.date</code> to one of the input fields. </p>
<p>But for some reason the date is placed after I fill in one letter in one of the other fields..... | <p>In the <code>data</code> function, instead of initializing <code>ride</code> as an empty object, you should initialize it like this:</p>
<pre><code>ride: { name: '', date: '' },
</code></pre>
<p>This shall resolve your issue.</p>
<p>To understand what is going on, please read the "<a href="http://vuejs.org/guide/... |
how to insert trendlines in scatterplot matrix <p>I have made a scatterplot matrix and whish to ad trend lines to each of the plots or just to those of significans.
my R command:
cor(K4Full[,c(6:9,22:25)])
plot(K4Full[,c(6:8,22:25)])</p>
<p><img src="http://i.stack.imgur.com/BWjVl.jpg" alt="Scatterplot matrix"></p>
| <p>you can try the following:</p>
<pre><code>pairs(K4Full[,c(6:8,22:25)], panel=panel.smooth)
</code></pre>
<p>example with mtcars dataset:</p>
<pre><code>pairs(mtcars[1:6],panel=panel.smooth)
</code></pre>
<p><a href="http://i.stack.imgur.com/YVn0f.png" rel="nofollow"><img src="http://i.stack.imgur.com/YVn0f.png" ... |
Why Does My C Binary to Decimal Program Not Return the Correct Value? <p>For part of a larger assignment, I'm writing a program that converts a binary number to a decimal. I know the way I'm doing it is kind of weird and could probably be improved upon, but I like the way it is now, and it almost works. The only proble... | <p>I like the pointless but fun <em>decimal coded binary</em> (DCB) representation but you way over engineered this. Consider using the logic in your <code>countDigits()</code> function as the basis for <code>binToDec()</code> and you get something much simpler like:</p>
<pre><code>#include <stdio.h>
#include &... |
Implement Redirection in C <p>I am implementing a shell in C. But I have a problem with file redirection.
My problem is the following. If I only type <code>cat filename</code>, my shell will display the file and return back to prompt waiting for next command. However, the shell will exit after running <code>cat < f... | <p>This seems like a homework problem...</p>
<p>From what I can tell, you are extracting the full command (without the "< filename") to execute, and you are trying to open a file descriptor with the file name after the "<".</p>
<p>The very next line, 51, makes no sense. </p>
<p>The problem is that once you fin... |
Confusing github graph <p>I have found, that in easy way I can create for my github repo web page (using pages.github.com), so I don't thing a lot and I perform all necessary steps to do that. </p>
<p>Everything work, I have my brand new repo website but when I comes back to my repo graph I can see something wierd: </... | <p>That indicates the history of those two branches are unrelated. They have different roots. They share nothing in common except they're in the same repository.</p>
<p>This is normal for Github Pages. It's a branch stored in your repository for your website. It does not contain your code and has no relationship to yo... |
Gmaps function loadGeojson <p>I need to read a GeoJSON select a line according to the search made by the user and then draw it on the map. Until this moment I am doing as in the code below, I walk the property, locate the line and step into a variable to plot on the map using the <code>loadGeoJson</code> function. But ... | <p>Use <code>.addGeoJson</code> rather than <code>.loadGeoJson</code></p>
|
Python: registering key presses and saving responses to an array or matrix <p>I am very new to Python, and I have been struggling with trying to find an answer to this question for a while now.</p>
<p>I am using Python 3.5 to write an experiment script. I would like to write a script that loops through a number of tri... | <p>The two big mistakes are trying to do repetitions with a loop and defining the function within the loop. Putting characters in a numpy array is likely not what you want. Anyway, you can build on the following.</p>
<pre><code>import tkinter as tk
num_trials = 5
trials = 0
responses = []
def keypress(event):
... |
Sitecore 8.1 with Solr Search performance issue <p>I am working on Sitecore 8.1 Application in which i have implemented Solr Search. But i am having issue with Performance when i am redirecting my page to search results. It is taking too much time i.e. 8-9 sec to display results. I have did following things. </p>
<p>A... | <p>You can optimize your search code:</p>
<ul>
<li>start by using a PredicateBuilder for your search query (if not for performance, do it for readability)</li>
<li>don't make all your functions public (not for performance, just for clean code)</li>
<li>use <code>Page</code> in your query instead of Take to limit the a... |
show select2 multiple selection outside searchbox <p>Is there any way to show select2 selected items outside search box?<br>
what i have now:<br>
Here is a sample <a href="http://jsfiddle.net/q2hp451y/2/" rel="nofollow">fiddle</a>:<br>
<a href="http://i.stack.imgur.com/3hUPY.jpg" rel="nofollow"><img src="http://i.stack... | <p>Right now you have it set to overflow: hidden;. Take that off by inherit and then set how far from the top you want your answers to go.</p>
<p><a href="http://jsfiddle.net/q2hp451y/3/" rel="nofollow">http://jsfiddle.net/q2hp451y/3/</a></p>
<pre><code>.select2-search-choice{
width:100%
}
.select2-container-multi... |
Linking error between assembler and C code (MinGW) <p>Error: In function '_go': c.asm:(.text+0x6): undefined reference to `k_main'
<br>
compilation: <br>
asm\nasm -f elf -o c.o c.asm
<br>
bin\ld -oformatbinary -Ttext 0x200000 -o bin\kernel.bin c.o bin\video.o bin\inter.o bin\finter.o bin\kernel.o -I "C:\MinGW\include" ... | <p>The actual encoding of identifiers is defined by the object-format/platform/compiler, and in this case C functions get a underscore prefixed, so the symbol is actually <code>_k_main</code>.</p>
<p>You can use macros to do the encoding if you want it to be portable, or you can force the symbol in the C source code.<... |
How to convert a string with the name of a class to the class type itself? <p>In order to store a class name in a log file I converted the description of a class type to a string:</p>
<pre><code>let objectType: NSObject.Type = Object.self
let str = String(describing: objectType)
</code></pre>
<p>However, I do not suc... | <p>I simply created an extension to use on any object:</p>
<pre><code>extension NSObject {
// Save Name of Object with this method
func className() -> String {
return NSStringFromClass(self.classForCoder)
}
// Convert String to object Type
class func objectFromString(string: String) ... |
An ALU in Verilog, lack of output while simulating <p>I write an simple ALU in verilog like this:</p>
<pre><code>input [15:0] in;
output reg [15:0] out;
reg [15:0] r [0:7];
reg [3:0] opcode;
reg [3:0] outreg;
reg [3:0] var1, var2;
reg [15:0] a1, a2;
parameter STO = 4'b0000;
parameter ADD = 4'b0001;
parameter MUL = 4... | <p><code>$monitor</code> displays the values of its parameters EVERY time ANY of its parameter changes value. How can you expect two lines of <code>20</code>?</p>
<p><a href="http://www.referencedesigner.com/tutorials/verilog/verilog_09.php" rel="nofollow">Ref</a></p>
|
Ruby Conditionals/Case Expression <p>I'm fairly new to code and I have a quick question on Ruby conditionals, specifically Case Expressions. I have a method in which I want to return a string "odd" if the string length is odd and "even" if the string length is even.</p>
<p>Simple stuff I know and I can get the results... | <p>You've written your <code>case</code> statement wrong. It takes two forms, which is unusual compared to other languages. The first form takes an argument, and that argument is compared to all possible cases. The second form is without argument and each case is evaluated independently.</p>
<p>The most minimal fix is... |
Android Radio App that streams my mp3 from a dropbox server <p>I have a dropbox media server that has a collection of mp3 files that I want to stream onto an android application.</p>
<p>I know that using the "MediaPlayer" is the best way to go in the API.</p>
<p>How my main concern is how do I automate the process, w... | <p>If the server gives apps audio files;put the files in a queue and play them using mediaplayer or another audio player.
Get first song from server and start playing it, meanwhile continue downloading other songs one by one. </p>
|
Group By SQL Statement - Get countries with more than 5 cities <p>I am trying to pull the countries that have more than 5 cities.</p>
<p>Tables:</p>
<p><strong>City</strong> <code>city_id, city, country_id, last_update</code></p>
<p><strong>Country</strong> <code>country_id, country, last_update</code></p>
<p>I thi... | <pre><code>select country
from country inner join city on city.country_id = country.country_id
group by country
having count(distinct city) > 5
</code></pre>
|
Hide class if locally stored? <p>I have a wordpress site and have a message showing on every page load. When button (.ig_close) is clicked I want the message not to show anymore after page refresh.</p>
<pre><code>// html
<div class="icegram action_bar_135">
<div id="icegram_message_135">
<di... | <p>The problem is that the <code><div class="icegram ..."></code> does not exist in the moment of <code>document.ready</code>. They are inserted into the DOM after that moment.</p>
<p>You could need to check if the <code>Icegram</code> plugin offers some JavaScript event you can observe and act on.</p>
<p><stro... |
Allow end-user to upload and execute javascript on server side <p>I'm studying javascript/nodeJS to develop ERP solution. I would like to allow ERP end-users to upload their own custom scripts, so they can interact with ERP scripts. Of course user scripts should implement pre-defined ERP API. </p>
<p>For example this ... | <p>I would suggest you to use <a href="https://nodejs.org/api/cluster.html#cluster_worker_process" rel="nofollow">workers</a>.
It will look something like this:</p>
<pre><code>const cluster = require('cluster');
cluster.setupMaster({
exec: 'fileUploadedByUser.js'
});
cluster.fork();
</code></pre>
<p>But I would... |
awk to Join or merge lines on finding a pattern <p>I have some data in a file i need to sort (maybe using awk) and would appreciate some help if possible</p>
<p>Here is a small sample of the file..</p>
<pre><code>DEFAULT,number,7996012132,,test,1,SP_A,SIX,,,
,,,,FOUR,,,
,,,,NINE,,,
,,,,TWO,,,
DEFAULT,number,79960... | <p>Here's my solution:</p>
<pre><code>awk 'BEGIN {line=""} /DEFAULT/ {print line; line=$0} !/DEFAULT/ {line = line""$0} END {print line}' data.txt | awk -F, '/FOUR/ {print $3" FOUR"}'
</code></pre>
<p>An explanation:</p>
<pre><code># Initialize line variable to blank
BEGIN { line="" }
# If the line cont... |
Unable to make a list of http get calls through one service in angularjs to handle exceptions? <p><strong>Process:</strong>
I try to call 4 httpget call though one httpGet method in a service, my first httpget call return an error and the rest of the calls return success message.</p>
<p><strong>issues:</strong> I try ... | <p>Define $scope.ErrorResponse before you point to it. Like this</p>
<pre><code>$scope.ErrorResponse = function(error)
{
window.location.href = "Error#?" + error;
}
$scope.getTemp = function ()
{
myService.getTemplate(id, $scope.getTemplateResponse, $scope.ErrorResponse);
};
</code></pre>
<p>Validate success/er... |
extract textpattern from excel cell <p>I have an excel table with around 500 rows. one column (D) contains a text and somewhere in that text there might be a ISBN number, looking something like this "ISBN 123-456-67-8-90". I would like to extract that ISBN (remove it from the cell) and move it to a different cell in th... | <p>I have a ready formula for this in case you want to extract just the ISBN number.</p>
<pre><code>=LEFT(RIGHT(SUBSTITUTE(A2,"ISBN ","|"),LEN(SUBSTITUTE(A2,"ISBN ","|"))-FIND("|",SUBSTITUTE(A2,"ISBN ","|"))),IFERROR(FIND(" ",RIGHT(SUBSTITUTE(A2,"ISBN ","|"),LEN(SUBSTITUTE(A2,"ISBN ","|"))-FIND("|",SUBSTITUTE(A2,"ISBN... |
python ctypes array will not return properly <p>This does not work:</p>
<pre><code>def CopyExportVars(self, n_export):
export_array = (ctypes.c_double * n_export)()
self.dll_handle.vs_copy_export_vars(ctypes.cast(export_array, ctypes.POINTER(ctypes.c_double)))
return export_array().contents
</code></pre>
... | <p>Error is pretty self-explainatory. <code>export_array</code> is not a callable object, but you try to call it in last line of function. Also, you try to use pointer-related interface ('.contents') to retrieve value from array, not pointer to it.</p>
<p>Simplest way to make it work would be to convert <code>ctypes</... |
Setting variables in TFS RMI tasks <p>TFS release management has a concept of variables. They're set in the release definition at design time. Is there a way for tasks to change variables so that other tasks see the changes?</p>
<p>The Windows <code>SET</code> command only affects the environment of the currently exec... | <p>I believe so. I have not tested this, but take a look at this VSO Build Task:</p>
<p><a href="https://marketplace.visualstudio.com/items?itemName=jessehouwing.jessehouwing-vsts-variable-tasks" rel="nofollow">https://marketplace.visualstudio.com/items?itemName=jessehouwing.jessehouwing-vsts-variable-tasks</a></p>
... |
Rails 5: update nested attributes through another model <p>I can not update nested attributes which is related with current model by 3rd model.</p>
<p>Focused model: Profile</p>
<pre><code>class Profile < ApplicationRecord
belongs_to :user
has_many :phone_numbers
##Set nested attributes
accepts_nested_att... | <p>The errors is super clear and full of call to action:</p>
<ul>
<li>add <code>profile_id</code> column to <code>phone_numbers</code> table to reflect the association between <code>Profile</code> and <code>PhoneNumber</code> models.</li>
</ul>
|
How to convert a string of MM-dd-yyyy to (full month)-yyyy <p>I have a string variable with the value of 07/31/2016 and I need to convert this to show as July 2016. How can I do this in C#?</p>
| <pre><code>var input = "07/31/2016";
var date = DateTime.Parse(input);
var output = date.ToString("MMMM-yyyy");
</code></pre>
<p>See <a href="https://msdn.microsoft.com/en-us/library/1k1skd40(v=vs.110).aspx" rel="nofollow">DateTime.Parse</a>.</p>
<p>See also <a href="https://msdn.microsoft.com/en-us/library/8kb3ddd4(... |
Find sendmail version (sSMTP or Postfix or other) <p>I have a script which runs on multiple servers. Some servers are using <strong>sSMTP</strong> and some are using <strong>postfix</strong>. </p>
<p>I want to find which version of <strong>sendmail</strong> my server is running in runtime, because <code>-t</code> is n... | <blockquote>
<p>Is there a more efficient method to achieve this?</p>
</blockquote>
<p>Yes; don't try to find the sendmail version, and use a standard way of sending mail...</p>
<p>You should use the <code>mail</code> (or <code>mailx</code>) command for better compatibility</p>
<pre><code>MAILCMD=$(type -p mail ||... |
Cleaning stdin buffer issue <p>Say I have the following piece of code</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
int main() {
char choice;
char name[5] = "";
do {
printf("a = new name or anything else to quit\nChoice: ");
... | <p>You need to check if <code>name</code> contains a newline character. If it does, there's nothing in the buffer and you don't need to flush it.</p>
<pre><code> fgets(name, 5, stdin);
printf("Name: %s\n", name);
if (strchr(name, '\n') == NULL) {
int c;
while ((c = getchar()) != '\n' &&... |
npm install phantom.js fails <p>When I run npm install, i get the following error I reinstalled node and that did not fix the problem. Not really sure where to go from here. It seems like it downloads a bunch of files and extracts them then quits unexpected when after saying receiving. </p>
<pre><code>Install exited ... | <p>It sounds like there's an issue with <code>install.js</code> which is located inside the <code>phantomjs</code> <code>node_modules</code> folder. What happens if you try to install a different version of the package? </p>
|
C++ null pointer argument as optional argument alternative in C# <p>I need to translate/rewrite some C++ code in C#. For quite a few methods, the person who wrote the C++ code had done something like this in the prototype,</p>
<pre><code>float method(float a, float b, int *x = NULL);
</code></pre>
<p>And then in the ... | <p>It looks to me like you want an optional <code>out</code> parameter.</p>
<p>I would do it with overrides in C#.</p>
<pre><code>public static float method(float a, float b, out int x){
//Implementation
}
public static float method(float a, float b){
//Helper
int x;
return method(a, b, out x);
}
</co... |
Ruby: No implicit conversion of nil into Hash <p>Ruby Rails Newbie-having issues with this code (not written by me). I feel like this should not be too hard, but when I run this, I just get
"no implicit conversion of nil into Hash". I can not find good documentation on this. Thanks in advance!</p>
<p>Here is our YAML... | <p>OK, here is your code:</p>
<pre><code>def sorted_college_list_for_degrees_with_library
list = **(line 178)**COLLEGE_AND_DEPARTMENT["current_colleges_for_degrees"].merge(COLLEGE_AND_DEPARTMENT["library"][0])
list.keys.collect do |k|
[k]["label"]
end.sort << "Other"
def sorted_college_list_for_generic_w... |
Unable to Install Rails and other Ruby Gems on Mac OS El Capitan 10.11.3 <p>I have properly setup homebrew and Ruby Version 2.3.1 following this site <a href="https://gorails.com/setup/osx/10.11-el-capitan" rel="nofollow">https://gorails.com/setup/osx/10.11-el-capitan</a>. However, when I tried to install Rails or othe... | <p>Back in the days i would get errors while installing Rails aswell, but nowadays we have <a href="http://installrails.com" rel="nofollow">Installrails.com</a></p>
<p>I have never encountered any errors while following the tutorials on that site. You might want to give that a try.</p>
|
ASP.NET Identity password requirements overriding my own <p>So I need to import a bunch of users into my ASP.NET Identity based system and some of he passwords are very short (as little as three characters) and beyond my control. I need to import these passwords so existing users can login and change their passwords to... | <p>Check your web.config file to make sure it doesn't have a minimum password length requirement in it that is overriding everything else.</p>
|
MS Access link to SQL Server - validate input against 2nd table? <p>I'm trying to think of the easiest way for non-tech users to dump info into a database, without coding my own web application.</p>
<p>Essentially, they are recording subjective phone grading scores for employees.</p>
<p>I linked an Access form to our... | <p>There are two ways to solve this problem. </p>
<p>The simplest is to use a combobox field for your employee information. Use the employee table as the list data source for the combobox and then set the LimitToList property to true. This assumes that you have setup linked table connections for both your employee tab... |
Python function gets stuck (no error) but I can't understand why <p>The function does what I want it to, but when it's done it just sits there rather than continuing from where I called it and I can't figure out why. The code is:</p>
<pre><code>x = 9
y = 9
n = 10
ty = 1
tx = 1
while ty <= y:
while tx <= x:
... | <p>I wasn't able to work out what was happening (turns out if I left it for a few minutes it would actually finish though), instead, I realised that I didn't need to use recursion to achieve what I wanted (and I also realised the function didn't actually do what I want to do).</p>
<p>For anyone interested, I simplifie... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.