input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
The final contents of the array from algorithm <p>Im student from Poland and I have little knowledge about the operation of this algorithm. </p>
<p>Here is the algorithm:</p>
<pre><code>n <- 1
for i = 1,2, ..., k do
n <- 2 * n
s <- 1
while s < n do
j <- 1
while j < n do
if A[j] &... | <p>What you'll want to do is hand trace your code. Here's a <a href="https://www.youtube.com/watch?v=TZss5ukwN8s" rel="nofollow">small video</a> on how to hand trace code. You can also search google for "hand trace code". </p>
<p>It's a tedious process but it will be what you want to do when you need to understand how... |
API: what HTTP status code to use for multiple items found error? <p>Suppose there is a lookup API endpoint. A response can be successful (200), not found (404), ... and in my case <strong>more than one item found</strong> is an error. Which HTTP status code can describe more than one item found error the best?</p>
| <p>That's an interesting problem. If it's an API call for a lookup and you get multiple results back, I'm actually expecting a <code>200</code> code with an results array.</p>
<p>But if the request itself is wrongfully formatted, so that it's not clear what it is the client is asking for, you could send a <code>400</c... |
Trouble with Bochs - Bootloader development <p>Currently, I am trying to write a tiny OS from scratch. Unfortunately, In the first step, I faced a problem which drives me crazy. I write the following code as my bootloader. </p>
<pre><code>.code16 #generate 16-bit code
.text #execu... | <p>You must create a bochs file in order it works well. Also You can use virtual machine. I test your code and it works fine. </p>
|
Stuck in a recursion maze <p>Need a push in the right direction for a class assignment. I've read other posts that mentioned creating a variable/method to store the path traveled, but not sure how to get about it...
Edited 9/28/16
was able to get to the end point of the maze but still haven't figured out
... | <p>The easy way is to wait until you find the solution. Then simply record the successful moves as you crawl back up that branch of the call tree. Each winning call prepends its move to the front of the return value and passes that back up the stack. This would be something like</p>
<pre><code>result = move(rowM + ... |
Convert list of numbers to code <p>I get a list of 40 numbers that I have to convert to code. Here is an example of half of the list:</p>
<p>9781101987971
9780385349741
9780385542364
9781550022134
9781501132933
9780345531094
9780374280024
9780670026197
9781250069795
9780062297716
9781250075727
9781501139888
9780062300... | <p>You could use an array and generate all tags with the appropriate values.</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>var isbn = '9781101987971 9780385349741 97803855... |
Google places API to get airport names in autocomplete <p>I am using google places Api. I want to have only the airports of particular country to displayed by autocomplete api. Is there any way to achieve this?</p>
| <p>For a place search, you can apply a type filter from within a predefined list (airport included): <a href="https://developers.google.com/places/supported_types" rel="nofollow">https://developers.google.com/places/supported_types</a></p>
<p>The place search doesn't allow country filtering (it uses latlng + radius pa... |
How do I execute code in an activity when a pop up menu is closed in Android <p>I have an activity that opens a menu (DialogFragment) that's being used to delete items from a list view. Information about the list item that was selected is being passed to the menu in the form of arguments ie. </p>
<pre><code> Dialog... | <p>You can extend the DialogFragment class and override onDimiss method, get the activity and execute the code.</p>
<p>Check this answer: <a href="http://stackoverflow.com/a/23786151/2828400">http://stackoverflow.com/a/23786151/2828400</a></p>
|
PHP Convert datetime format <p>Is there a way in PHP to convert the date time format from the one in the left to the one on the right?</p>
<p><strong>1900-01-01T00:00:00-06:00</strong> to <strong>1900-01-01 00:00:00.000</strong></p>
<p><strong>2015-06-18T00:00:00-05:00</strong> to <strong>2015-06-18 00:00:00.000</str... | <p>Since only the year month and day are pertinent, you can just use <code>date_format</code> to get that from your existing string, then concatenate your time to it, resulting in the string you're after.</p>
<pre><code>date_format(new DateTime("1900-01-01T00:00:00-06:00"),"Y-m-d")." 00:00:00.000";
// 1900-01-01 00:00... |
Error 407 after computer name change: Visual studio Team Services / TFS <p>My infrastructure changed the name of my computer. When I opened visual studio to connect to TFS, I got a message saying that "Workspace 'X' does not reside on this computer. If this computer was recently renamed, the workspace may be updated b... | <p>This error usually occurs when VS tried to do an automatic update but was stopped by the proxy. You can try below way to prompt for credentials:</p>
<blockquote>
<p><strong>WORKAROUND:</strong></p>
<ol>
<li>Open <strong>TOOLS>Extensions & Updates</strong></li>
<li>Click on <strong>Updates...</strong... |
MIPS, dynamic array, third input overwrites the second <p>I am trying to create an array that takes any number of single digit integers and when the user enters -1, it stops taking more. However, the first and second numbers are stored correctly. Once I syscall for a third input, the memory address where my second numb... | <p>Solution?: Wow, I solved this issue by literally moving the myArray and char part below the declaration of the strings, like sp and cr. I think this is because the array space should be declared after the strings, otherwise the strings will overwrite whatever space you just declared. Then, as I adjusted my dynamic a... |
python 27 - Creating and running instances of another script in parallel <p>I'm attempting to build a multiprocessing script that retrieves dicts of attributes from a MySQL table and then runs instances of my main script in <strong>parallel</strong>, using each dict retrieved from the MySQL table as an argument to each... | <p>You could store your dictionaries in a list and then try something like that:</p>
<pre><code>from multiprocessing import Pool as ThreadPool
# ...
def parallel_function(list_of_dictionaries,threads=20):
thread_pool = ThreadPool(threads)
results = thread_pool.map(SC.queen_bee() ,list_of_dictionaries)
th... |
Playing one sprite sheet after another <p>Heyo, i have this sprite sheet <a href="http://codepen.io/benasl/pen/yabpxo" rel="nofollow">http://codepen.io/benasl/pen/yabpxo</a> that i want to be changed to another one after it ends, and after the second one ends the first one needs to start again, and so on... I don't kno... | <p>Is quite complicated to implement this feature with pure CSS, since you want to create a loop of two animations.<br>
Instead, I would suggest using <code>Javascript</code> + <code>CSS</code>.<br>
So you can actually combine them and have more control over your animations</p>
<p>Take a look of this <a href="http://j... |
python3 How to select two elements on either side of a random element in a list? <p>I have finished this part of the code so far:</p>
<pre><code>wedding = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
from random import randrange
random_index = randrange(0, len(wedding))
print('TV =', wedding[random_index])
</code></pre>
<p>I g... | <p>When using arrays, always check for your array bounds in your code. The below code will output the value from the array that is to the left and right of the randomly selected index value. If either of the indexes are out of bounds, it will not output that value.</p>
<pre><code>from random import randrange
wedding... |
htaccess: rewrite query string to path <p>I have a domain with the following query string:</p>
<pre><code>http://example.com/?taxo=question&cata=foo&catb=bar&catc=more
</code></pre>
<p>My objective is to convert this query string after <code>?taxo=</code> into a path based on the values for each parameter... | <p>You cannot match query string in a <code>RewriteRule</code>. You should use <code>QUERY_STRING</code> variable in a <code>RewriteCond</code> to match and capture value from query string:</p>
<pre><code>RewriteEngine On
RewriteCond %{QUERY_STRING} ^taxo=([^&]+)&([^=]+)=([^&]+)&([^=]+)=([^&]+)&am... |
Alamofire, Session Manager limit retry count <p>I'm using Alamofire's SessionManager to make requests to my API services. </p>
<p>Is there a way to limit the retry counts in Alamofire? </p>
<p>I'm using the new RequestAdapter and RequestTrier Protocols to provide a retry mechanims in Alamofire v4.</p>
<p>I want to l... | <p>I have solved this with Alamofire's <code>RequestRetrier</code> protocol:</p>
<pre><code>class Retrier: RequestRetrier {
var defaultRetryCount = 4
private var requestsAndRetryCounts: [(Request, Int)] = []
private var lock = NSLock()
private func index(request: Request) -> Int? {
retur... |
How to write to multiple tables per read row using Spring Batch with no conditions <p>I have found many examples to use multiple writers in this forum. Most, if not all, of the answers focus on CompositeItemWriter and ClassifierItemWriter. </p>
<p><em>Business Need</em>: Read a single line from an input file. This lin... | <p>I believe the comments from @Hansjoerg and @Luca provide valuable responses to this question and were researched prior to and during the research for an answer.</p>
<p>I was able to resolve this issue by continuing the use of a ItemSqlParameterSourceProvider and the code is below. When I initially explored how to u... |
fuzzy search on doubles postgres <p>I would like to fuzzy search on decimal numbers instead of strings. So the idea is searching for 100 should bring a range of 100, 90, 95, 105, 108, 120 number values from rows in database.</p>
<p>I have tried like keyword too but it doesnt work as i wants. How can i do a fuzzy searc... | <p>Use <code>between</code>. The function is an example:</p>
<pre><code>create or replace function fuzzy_match_numeric
(number numeric, value numeric, deviation numeric)
returns boolean language sql as $$
select number between value- value* deviation and value+ value* deviation
$$;
</code></pre>
<p>Check for ... |
Facebook Swift SDK: loginManager Type of expression is ambiguous error <p>I'm using the following code to add a facebook login to a UIButton action:</p>
<pre><code>func facebookButtonClicked(sender: UIButton) {
let loginManager = LoginManager()
loginManager.logIn([.PublicProfile], viewController : self) { log... | <p>So I somewhat fixed this issue by using the proper facebook syntax since the recent update. </p>
<blockquote>
<pre><code>@IBAction func facebookBtnTapped(_ sender: AnyObject) {
</code></pre>
</blockquote>
<pre><code> let loginManager = LoginManager()
loginManager.logIn([ .publicProfile ], viewController: se... |
Read/Write TCP options field <p>I want to read and write custom data to TCP options field using Scapy. I know how to use TCP options field in Scapy in "normal" way as dictionary, but is it possible to write to it byte per byte?</p>
| <p>You can not directly write the TCP options field byte per byte, however you can either:</p>
<ul>
<li>write your entire TCP segment byte per byte: <code>TCP("\x01...\x0n")</code></li>
<li>add an option to Scapy's code manually in scapy/layers/inet.py <code>TCPOptions</code> structure</li>
</ul>
<p>These are workaro... |
Mark task as "Today" from project screen? <p>When in the "New Tasks" view, there is a shortcut that allows you to prioritize tasks as "Today", "Upcoming", or "Later":</p>
<p><a href="http://i.stack.imgur.com/IdzOK.png" rel="nofollow"><img src="http://i.stack.imgur.com/IdzOK.png" alt="New Tasks shortcut"></a></p>
<p>H... | <p>With the task selected (highlighted in the left pane, and open on the right), you can use the keyboard shortcuts <code>Tab+Y</code>, <code>Tab+U</code>, and <code>Tab+L</code> to mark tasks assigned to you as Today, Upcoming, and Later, respectively.</p>
<p><a href="https://asana.com/guide/help/faq/shortcuts" rel="... |
R How to get total CPU time with foreach? <p>I am trying to get total CPU hours of a code run in parallel (using <code>foreach</code> from the package <code>doParallel</code>) but I'm not sure how to go about doing this. I have used <code>proc.time()</code> but it just returns a difference in 'real' time. From what I h... | <p>A Little trick is to return the measured runtime with your computation result together by <code>list</code>. An example as below, we use <code>system.time()</code> to get the runtime as same as <code>proc.time()</code>.</p>
<p>NOTE: this is the modified example from my blog post of <a href="http://www.parallelr.com... |
Filtering on sonarqube Type (i.e. Bug/Vulnerability/Code Smell) = empty results <p>The "Type" filter for my installation of SonarQube 5.6 appears to be non-functional. Note in the first screen-shot that the number of Rules of Type Bug, Vulnerability, or Code Smell is 0 (even though several Rules in the screen shot are ... | <p>Those search facets are populated from ElasticSearch. The fact that they're screwed up indicates that the ES indices are toast. Try deleting <em>/data/es</em> and restarting.</p>
|
sed extract between two patterns <p>I need to extract the lines between "Timing exception" and "---------" from the report below, then output them to a file</p>
<pre><code>Timing exceptions with no effect exception's
report timing -paths [eval [::legacy::get_attribute paths <exception>]]
/designs/exceptions/pat... | <p>Add <code>^</code> before <code>Timing exceptions</code> to indicate start of the line:</p>
<pre><code>sed -n '/^Timing exceptions/,/-----/p' file.txt
</code></pre>
<p>You have <code>Timing exceptions</code> in two lines, one at first, and the other after the <code>----</code> line, so you are getting two chunks,... |
nginx proxy_pass to root without path <p>In the <a href="http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass" rel="nofollow">nginx proxy_pass documentation</a> it says</p>
<blockquote>
<p>If proxy_pass is specified without a URI, the request URI is <strong>passed to the server in the same form as sen... | <p>You can specify <code>http://localhost:8080/</code> with the trailing slash, denoting <code>/</code> as the URI. You cannot do this in named locations (AFAIK, nginx will throw error).</p>
|
Line numbers in malloc trace using Pin <p>I am working on Pintool for tracing malloc/free operations. From the ManualExamples/malloc_trace.cpp I was able to print out malloc/free in a sample code. </p>
<p>I was wondering if there is a way to print the line numbers in the source code where malloc/free is encountered. I... | <p>You can try the following API:</p>
<pre><code> void LEVEL_PINCLIENT::PIN_GetSourceLocation(ADDRINT address,
INT32 * column,
INT32 * line,
string * fileName
)
</code></pre>
<p><a href="http://www.cs.virginia.edu/kim/publicity/pin/docs/25945/Pin/html/group__DEBUG__API.html" ... |
Transfer map<string, pair> to vector <p>So I have this map m</p>
<pre><code>typedef pair<int,int>p;
map<string, p> m;
</code></pre>
<p>It holds all of the words in a text file, and the first int in the pair is the frequency of the word and the second is the position of its first character in the text file... | <p>The simple method is to create a structure with all three fields:</p>
<pre><code>struct Record
{
std::string word;
int count;
std::streampos file_position;
};
</code></pre>
<p>Next is to iterate through the map, creating instances of the above structure, filling them in and appending to the vector: ... |
How I can get current date in xml in odoo? <p>I am adding group by filter of past due in accounting tab in odoo. And want to get context <strong>due_date < current date</strong>, but i am not getting current date anywhere, I don't know how i can get it, anybody can tell me that how to get current date in odoo? </p>
... | <pre><code><xpath expr="//filter[@string='Due Month']" position="after
<filter string="Past Due" name="past_due_filter" domain="[('date_due','&lt;',current_date)]" />
</xpath>
</code></pre>
|
select case and drop downbox <p>I am a beginner in ASP.Net and I am currently having problems trying to understand the mechanics of using the drop-down list. </p>
<p>My problem is I am trying to use a <code>Select Case</code> expression where I create a variable called <code>value</code> that is set equal to my drop-d... | <p>Please use string here</p>
<pre><code>Select Case value
Case value
' set Constant values to Bagvalues and OvWBagValues based on user selection
End Select
</code></pre>
|
scroll image doesn't work <p>The following codes are not working as intended.</p>
<p>index.html</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-css lang-css prettyprint-override"><code>#header {
z-index: 2;
... | <p>You already have <code>#coordinations</code> set as <code>display: absolute</code>, why not just move it off-screen with a <code>left: -9999px;</code>? </p>
|
Strategy for keeping gRPC definitions and generated files in VCS <p>I wanted to use gRPC in a system composed of multiple services (each in its own repository) and I was wondering about approach towards versioning in Git:</p>
<ul>
<li>*.proto files</li>
<li>generated code (mostly Go/Java/Python)</li>
</ul>
<p>So far ... | <p>General best practice is to keep the generated files out of the repository and to always auto-generate them on build. For example, when you compile Java programs, you don't add any generated <code>.jar</code> files to source control; that's redundant and asking for headaches down the road. The same deal goes for pro... |
Data limits in server-sent events <p>I'm using server-sent events in order to execute queries on your database. The server streams the stats in realtime with <code>stats</code> events and when the query is executed, it sends <code>result</code> event with the data and closes the connection.</p>
<p>You can test it with... | <p>I'm almost certain your problem is server-side, not a problem with the browsers, or their implementation of SSE. When I test your curl command it ends abruptly at this point:</p>
<pre><code>...null,null,null],["2016-08-30T14:08:03Z","MichMich",
</code></pre>
<p>(Slightly different on each run.)</p>
<p>Not just mi... |
Implode a multidimensional JSON array (PHP) without loops <p>I'm working with a REST API and the response is given back in JSON. Here's a print_r version of what it looks like:</p>
<pre><code> [topics] => Array
(
[0] => stdClass Object
(
... | <p>This is simply a problem with how you are accessing the property - it's an object, not an array:</p>
<pre><code>$arr = array_map(function($topics_array){ return $topics_array->value; }, $arr);
</code></pre>
|
Problems with pd.read_csv <p>I have Anaconda 3 on Windows 10. I am using pd.read_csv() to load csv files but I get error messages. To begin with I tried <code>df = pd.read_csv('C:\direct_marketing.csv')</code> which worked and the file was imported.</p>
<p>Then I tried <code>df = pd.read_csv('C:\tutorial.csv')</code>... | <p>Try escaping the backslashes:</p>
<pre><code>df = pd.read_csv('C:\\Users\\test.csv')
</code></pre>
|
I don't know what is causing the segmentation fault in my code <p>I'm at my wit's end with this code and I am new to c++ so I don't even know where to begin to check for this error. What is causing the segmentation fault in my code and how do I fix it?</p>
<pre><code>#include <iostream>
#include <string>
#... | <p>You have undefined behavior in this code (and the other constructors):</p>
<pre><code>Student::Student ()
{
name = "";
numClasses = 0;
for (int x = 0; x < 10; ++x)
{
classList[x] = "";
}
}
</code></pre>
<p>You never allocated any elements in the <code>classList</code> vector, so the reference to ... |
Regex to get match up through second to last occurrence of a string <p>If I have the following string:</p>
<p><code>hello/everyone/good/bye/world</code></p>
<p>I want to match everything up through the second to last forward slash:</p>
<p><code>hello/everyone/good/</code></p>
<p>But the number of slashes may vary.<... | <p>Instead of a regular expression, use <code>split</code> and take advantage of "slicing".</p>
<pre><code>t = "hello/everyone/good/bye/world"
ts = t.split("/")
print "/".join( ts[0:-2] ) + "/"
</code></pre>
<p>This prints </p>
<pre><code>hello/everyone/good/
</code></pre>
<p>This answer is for python2 (you did not... |
Order Progress bar is broken when bootstrap is applied <p>I am trying to use this progress step wizard and it works fine but when i try to add the bootstrap css everything messes up and i dont know what is what is wrong.</p>
<p>Here is a js fiddle
<a href="https://jsfiddle.net/gy2gqns1/" rel="nofollow">https://jsfidd... | <p>Bootstrap adding son styling to ul ad other that override your style.
With little correction to your style you can correct the modify by bs:</p>
<pre><code>.step-wizard {
display: inline-block;
position: relative;
width: 100%;
}
.step-wizard .swprogress {
position: absolute;
top: 43px;
left: 12.5%;
wi... |
angularjs how can i post my form into the json <p>I am building my first angular app and looking to post my form into my JSON data.</p>
<p>This is my form:</p>
<pre><code> <span ng-show="show">
<form name="inputForm" class="form-group" ng-controller="FormController as autoctrl" ng-submit="inputForm.$vali... | <p>Since you are using <code>controllerAs</code> you need to add the controller object to all the variables in <code>ng-model</code></p>
<p>Example:</p>
<pre><code><input name="type" ng-model="type">
</code></pre>
<p>Should be:</p>
<pre><code><input name="type" ng-model="autoctrl.type">
</code></pre>... |
how do you add two or more numbers selected randomly by the user in a single EditText using android studio? <p>I am making a mobile calculator and I am aware there are many that have been created. I tried using others as an example to build mine but I have been stuck for days. I was able to display numbers on the EditT... | <p>A couple ways to achieve this, you just need a way to retrieve the current number in the calculator and perform an operation against the new selected number</p>
<p>So store the main number in its own variable, and then perform the desired operation against a new number, before you set the new edittext value</p>
|
Did I write this recursively? <p>I need to write a recursive method to reverse a list, using no loops and no built-in functions such as <strong>reverse, reversed</strong>, or <strong>::</strong> (the list-slicing operator).</p>
<p>Did I do this properly?</p>
<pre><code>def reverseList(alist):
if len(alist) == 1:
... | <p>Yes, you did great. The code is short, clear, readable, and calls itself appropriately. Yes, you can recode this for the empty list.</p>
<pre><code>if len(alist) <= 1:
return alist
</code></pre>
<p>Also, try a few more test cases:</p>
<pre><code>print (reverseList([1,2,3,4,5]))
print (reverseList([1, [Fa... |
How do I loop through an array in an array of objects <p>I know how to run loops inside react but how do I do it inside an object which is already inside an array being looped?</p>
<p>I am trying to display each ingredient item as an <code><li></code>, so far I have got it working with recipe but I am lost with ... | <p>How about this way :</p>
<pre><code> loop: function(ingredients) {
return ingredients.map((ingredient, index) => {
return (<li key={index} className="list-group-item">{ingredient}</li>)
})
},
render(){
...
{this.loop(item.ingredients)}
...
}
</code></pre>
<p>One... |
How can I reduce the padding in tabs of tablayout in Appcelerator tabgroup on Android? <p>I have five tabs (<code>Events</code>, <code>Groups</code>, <code>Devices</code>, <code>Map</code>, and <code>More</code>) in a <code>tabgroup</code> component on Android using Appcelerator's titanium. I don't want the user to ha... | <p>You can use titanium platform folder to define
Your custom styles your_project/app/platform/android/....</p>
<p>Here are described how to style:
<a href="http://stackoverflow.com/questions/22231234/styling-tab-widgets-using-xml">Styling Tab Widget's using XML</a></p>
|
How to test Android Pay with a debug APK? <p>By default, Android Pay refuses to work in debug builds, which makes testing tricky. What we've done so far is to actually merge new code into a develop or hotfix branch so our build environment will make a signed APK which can be tested. This is not ideal.</p>
<p><a href="... | <p>No, there is not a debug mode option to that per docs:</p>
<p><a href="https://developer.android.com/google/play/billing/billing_testing.html" rel="nofollow">https://developer.android.com/google/play/billing/billing_testing.html</a></p>
<p>set a separate machine with a CI server and have it do the alpha and beta b... |
How to write a function with a list as parameters <p>Here is the question, I'm trying to deï¬ne a function <code>sample_mean</code> that takes in a list of numbers as a parameter and returns the sample mean of the the numbers in that list. Here is what I have so far, but I'm not sure it is totally right. </p>
<pre><... | <p>Firstly, don't use <code>list</code> as a name because it shadows/hides the builtin <a href="https://docs.python.org/3/library/functions.html#func-list" rel="nofollow"><code>list</code></a> class for the scope in which it is declared. Use a name that describes the values in the list, in this case <code>samples</code... |
How do I see the help for the `dplyr::collect` method? <p>I am trying to find out what additional arguments can be passed to <code>dplyr::collect</code> in the ellipsis <code>...</code>. I want to do this because I believe that the behaviour of <code>collect</code> has changed between <code>dplyr</code> version <code>0... | <p>As noted by <a href="http://stackoverflow.com/users/2860938/chrisss">Chrisss</a> and <a href="http://stackoverflow.com/users/4891738/zheyuan-li">Zheyuan Li</a>:</p>
<ol>
<li>The asterisk/star/* next to the method name after running <code>methods</code> indicates that each of these methods are not exported from the ... |
HTML5 Three.js r81 shadows lose alpha map during camera rotation <p>Working with Three.JS r81 I'm having an issue with shadows being cast through transparent materials with a custom depth shader. When I have just a tree in my scene, the shadows look great. The second I add in a simple box approximately 100 units to t... | <p>It looks like this was all due to a dumb mistake on my part. My shader material uniforms were using mesh.material instead of mesh.material.map. After changing it, it works just fine.</p>
<pre><code>var uniforms = { texture: { type: "t", value: mesh.material.map } }
shaderLibrary[libraryName] = new THREE.ShaderMa... |
How do I group legend entries using Chartjs? <p>Does <a href="http://www.chartjs.org/" rel="nofollow">Chartjs</a> support grouping legend entries based on some fixed attribute? For example, say I'd like to group two legend entries and provide them a common heading 'Neuroscience'. Is this currently supported in the li... | <p>After more research, yes Chartjs provides an easy interface to customize the legend. Each chart accepts a <code>legendCallback</code> function that takes the chart object as it's only argument and returns a html string representing the legend. </p>
<p>See <a href="http://www.chartjs.org/docs/#chart-configuration-... |
Can someone explain the code behind the marked area on this website? <p>I am trying to figure out how to add a background that extends to the edges of the page no matter what the size, like on the website here <a href="http://www.wisemanpanel.co.nz/" rel="nofollow">http://www.wisemanpanel.co.nz/</a></p>
<p>And I'm tal... | <p>It's simply a background image applied to the tag <code><body></code> which repeats horizontally (<code>background-repeat: repeat-x;</code>)</p>
<p>Just right click->inspect-> <code>body</code> tag and you will see :)</p>
|
Swift: Can not use array filter in if let statement condition <p>Suppose I have an array of user's names</p>
<pre><code>let users = ["Hello", "1212", "12", "Bob", "Rob"]
</code></pre>
<p>I want to get the first user whose name length is 2, so I filtered the array and got the first user</p>
<pre><code>if let selected... | <p>You can make this work by putting parentheses around the closure that you're passing to <code>filter</code>:</p>
<pre><code>if let selected = users.filter({$0.characters.count == 2}).first {
print(selected)
}
</code></pre>
<p>That is the right way to do it. The trailing closure syntax doesn't work very well s... |
How to add custom string to angular application url without effecting the normal functioning? <p>I have an angular application working with angular ui-router. When I run the application from server the url is like <code>localhost/..../index.html</code></p>
<p>After I click on any state the url changes to
<code>localh... | <p>You can send and receive custom variables within the URL by using <a href="https://docs.angularjs.org/api/ngRoute/service/$route" rel="nofollow">$routeProvider</a> and <a href="https://docs.angularjs.org/api/ngRoute/service/$routeParams" rel="nofollow">$routeParams</a>. </p>
<p>Setup the router <code>with/your/:cu... |
Query MySQL count data & turn into JSON <p>My table contains a column of '<em>datetimes</em>', with an id.</p>
<pre><code>+----+---------------------+
| id | datetime |
+----+---------------------+
| 0 | 2016-09-02 12:13:13 |
| 1 | 2016-09-02 10:16:11 |
| 2 | 2016-09-05 11:03:23 |
| 3 | 2016-09-08 11:34... | <p>Use the following query:</p>
<pre><code>SELECT DATE_FORMAT(datetime, '%Y-%m-%d') AS `date`,
COUNT(*) AS `count`
FROM yourTable
GROUP BY DATE_FORMAT(datetime, '%Y-%m-%d')
</code></pre>
<p>Then create the JSON in your PHP code:</p>
<pre><code>$a = array();
while ($row = mysql_fetch_array($result, MYSQL_ASSOC... |
Sharing information between ViewContollers <p>I am developing a game using Sprite and the game works perfectly fine. I am trying to add in a feature that allows you to change things on that GameView. But the buttons for the feature are on a different ViewController. How would I be able to have the code be implemented i... | <p>Take a look to this question:</p>
<p><a href="http://stackoverflow.com/questions/5210535/passing-data-between-view-controllers">Passing Data between View Controllers</a> (One of the answers shows Swift 3 syntax.)</p>
<p>Anyway, what I personally have done in these cases is to use <a href="https://developer.apple.c... |
iOS - skipHiddenFiles in an array still needs fixing <p>My problem: I have already searched this forum regarding this topic
(i.e.:<a href="http://stackoverflow.com/questions/499673/getting-a-list-of-files-in-a-directory-with-a-glob">Getting a list of files in a directory with a glob</a>),
but still having some challen... | <p>filteredArrayUsingPredicate: returns a new array instance; it does not modify the array it is given. It is not an NSMutableArray. (The naming follows the pattern in the method -sortedArrayUsingSelector:, which returns a new array; the NSMutableArray method is -sortUsingSelector:, with a void return value -- one is... |
__vectorcall via C++/CLI or PInvoke (C#) <p>Is there any way to invoke C++ functions that use the __vectorcall calling convention via PInvoke or C++/ CLI? So far my attempts have suggested this is not possible (yet). Figured I would ask here to see if anyone knew of a creative way.</p>
| <p>You could create a forwarding function in C++ that takes its arguments in the normal way (cdecl), then forwards those on to the function that expects them in __vectorcall.</p>
|
json creates additional attributes than my object <p>I have a class that has attributes A,B,C. I am using Jackson parser to convert my class object to JSON. But the Json output has additional attributes that are not members of the class. When and how does this happen? </p>
<pre><code>Class MyClass{
public int A;
publi... | <p>Download Google Chrome "Postman"
select post method and paste your json link, see the no of object appearing in the json tab..
hope this will help.</p>
|
Tkinter formatting multiple frames next to each other <p>so I am creating a GUI and I essentially want to have two different "toolbars" at the top of the GUI, similar to <img src="http://i.imgur.com/NZByh97.png" alt="this">.<br>
Currently, I have the respective buttons for each toolbar placed into two different respect... | <p>You can try putting the <code>toolbar</code> and <code>selectBar</code> inside a <code>Frame</code>, and use <code>pack()</code> instead of <code>grid()</code>:</p>
<pre><code>topbar = Frame(self)
....
toolbar = Frame(topbar, ...)
toolbar.pack(side=LEFT, fill=X, expand=True)
...
selectBar = Frame(topbar, ...)
selec... |
Reading serial output from Pyserial doesnt work reliably <p>I am connecting to device using code blow on MacOS and out of 100 times this code would make connection only 1 or two times and dones't respond(since there is no timeout) rest of the times.</p>
<pre><code>ser = serial.Serial(port="/dev/xyz",timeout = None, ba... | <pre><code>def startSerial(tty_id):
ser = serial.Serial(port = tty_id, timeout = None)
ser.close()
ser.open()
if ser.isOpen():
print(ser.portstr, ":connection successful.")
return ser
else:
return False
</code></pre>
<p>Calling ser.close() before .open() fixed it. I tested i... |
Cannot use 'in' operator to search for 'sth' in undefined <p>Here is my code:</p>
<pre><code>.
.
keydown: function(ev) {
clearTimeout( $(this).data('timer') );
if ( 'abort' in $(this).data('xhr') ) $(this).data('xhr').abort(); // error here
var xhr, timer = setTimeout(function() {
xhr = $.aj... | <p>Change from:</p>
<pre><code>if ('abort' in $(this).data('xhr') ) $(this).data('xhr').abort();
</code></pre>
<p>to:</p>
<pre><code>if ($(this).data('xhr') && $(this).data('xhr').abort) {
$(this).data('xhr').abort();
}
</code></pre>
<p>problem was simply checking if object has <code>xhr</code> element<... |
Cannot deploy UWP app to Win 10 Mobile <p>I am writing a UWP app that I want to deploy to the store as a replacement to an existing Win 8.1 app.</p>
<p>The current app that is in the store has packages for Win Phone 7 and Win Phone 8.1 and I want to add a new UWP package for the Win 10 family.</p>
<p>After I run the ... | <p>According to your error code, I think you may have the same problem like <a href="http://stackoverflow.com/questions/38761713/error-dep0001-unexpected-error-2147009287-deploy-windows-phone-universal-10">Error DEP0001 : Unexpected Error: -2147009287 deploy Windows Phone Universal 10</a>.</p>
<p>To fix this issue, yo... |
Jackson's @JsonTypeInfo(use = Id.CUSTOM, include = As.PROPERTY, property = "type") reads all fields of JSON except for "type" <p>I stepped through each line of code, but I think it's how Jackson handles polymorphism internally. </p>
<p>Using the classic example of <code>Dog</code> and <code>Cat</code> extending <code>... | <p>Set <code>visible=true</code> for <code>@JsonTypeInfo</code>: </p>
<pre><code>@JsonTypeInfo(use = Id.CUSTOM, include = As.PROPERTY, property = "type", visible=true)
</code></pre>
<p>Refer <a href="http://stackoverflow.com/a/14146357/3831137">this post</a></p>
|
How to process multiple CSV format files using Spring batch <p>I am using spring batch to process my inbound files, below is my use-case</p>
<ol>
<li>will be receiving a zip contains 15 files of CSV format</li>
<li>I need to process them in parallel </li>
<li>after all files were processed need to do some calculation ... | <p>I would like to follow the below approach</p>
<ol>
<li><p>Partitioner</p>
<ul>
<li>Unzip the zip file</li>
<li>For each of CSV file, create a ExecutionContext and add to Queue for pararell processing.</li>
</ul></li>
<li><p>Reader will be CSV Reader provided by Spring Batch.</p></li>
<li><p>Listener will be used t... |
Scrapy Post Data <p>Im moving from python requests to scrapy, I'd like to make a post request that clicks a button at the bottom of an instagram hashtag page.</p>
<p>The cURL is this</p>
<pre><code>curl "https://www.instagram.com/query/" -H "cookie: mid=VwBJIwAEAAGiVNY3epWm9pRgD9Ge; fbm_124024574287414=base_domain=.i... | <p>You seem to be missing correct headers or any headers for that matter.</p>
<p>You should provide every header that you see in the network inspector, aside from cookies that scrapy managed and populates by itself.</p>
<p>You can easily extract the headers from the curl string network inspect gives you by:</p>
<pre... |
Problems with drawing program in processing <p>I'm creating a basic drawing program in Java processing, I have two colors down (as well as an eraser) and I just created a new color (green). For some reason when I click on green, it doesn't change the color. Thanks!</p>
<p>(Note, I ran this program in Eclipse with proc... | <p>Like I said in <a href="http://stackoverflow.com/questions/39548126/processing-drawing-problems">your previous question</a>, you really shouldn't use a variable named <code>color</code>. It might work for you in eclipse, but it's confusing. At the very least it makes it harder for us to help you. While you're at it,... |
Programmatically add point into map at Google Drive <p>I want to add point into exist Google Drive map file uses JavaScript. I found related <a href="https://developers.google.com/drive/v2/reference/files/update#examples" rel="nofollow">API method</a>. But I can't found specification for MIME-type 'application/vnd.goog... | <p>There doesn't seem to be an API that can manipulate My Maps files (which I believe your inquiry is the same as the one here in <a href="https://productforums.google.com/forum/#!topic/maps/PqHwHr3HLm8" rel="nofollow">Google productforums</a>).</p>
|
Go type automatically converting when it seems like it shouldn't <p>Sorry for the ambiguous title. I'm not getting a compiler error when I believe that I should, based on creating a new type and a function that takes an argument of that type.</p>
<p>The example:</p>
<pre><code>package search
//Some random type alias... | <p>We can simplify this example a bit further (<a href="https://play.golang.org/p/i6_d1zTGwn" rel="nofollow">playground</a>):</p>
<pre><code>package main
type Foo string
type Bar int
func main() {
var f Foo = "foo"
var b Bar = 1
println(f, b)
}
</code></pre>
<p>This is explained in the <a href="http:/... |
HTTPS websites require Secure WebSocket channel? <p>I'm just start learning WebSockets. (Now with Ratchet for PHP). I'm testing on my 2 different domains. One for the Website (with Javascript calls), and another one is WS/Ratchet Server.</p>
<p>When the Website is on HTTPS, the Javascript throws below errors:</p>
<bl... | <p>Yes, as per my knowledge, you have to use WS server on SSL to end point from https://</p>
<p>Then your ws:// end point will be like wss://</p>
|
Is Promise.all not working on the second time through? Why not? <p>I'm just finishing off this basic webscraper project for a tshirt website.</p>
<p>It enters through one hardcoded url, the home page. It will search for any product pages, and add them to an url. If it finds another link (<code>remainder</code>), it wi... | <p>The issue is <code>tshirtArray</code> is not defined in <code>convertJson2Csv()</code>. At <code>lastlastScraperPt2</code> pass <code>tshirtArray</code> to <code>convertJsonCsv()</code></p>
<pre><code>convertJson2Csv(tshirtArray)
</code></pre>
<p>at <code>convertJson2Csv</code></p>
<pre><code>function convertJson... |
Compute digit-sums in specific columns of a data frame <p>I'm trying to sum the digits of integers in the last 2 columns of my data frame. I have found a function that does the summing, but I think I may have an issue with applying the function - not sure?</p>
<pre><code>Dataframe
a = c("a", "b", "c")
b = c(1, 11, 2)... | <p>Your function <code>digitsum</code> at the moment works fine for a single scalar input, for example,</p>
<pre><code>digitsum(32)
# [1] 5
</code></pre>
<p>But, it can not take a vector input, otherwise <code>":"</code> will complain. You need to vectorize this function, using <code>Vectorize</code>:</p>
<pre><code... |
Selenium click a button if the parameter is true <p>I wanted to create a function which takes a parameter and if the parament is True then the button is click otherwise no. Can i use this?</p>
<pre><code>def buttonClick(self, Button):
if Button == True:
self.driver.find_element_by_id('button').click
</code... | <p>Two main things to fix from the top of my head:</p>
<ul>
<li>you can avoid having <code>== True</code> part</li>
<li>you are not calling the <code>click</code> method - add the <code>()</code></li>
</ul>
<p>Fixed version:</p>
<pre><code>def buttonClick(self, should_click_button):
if should_click_button:
... |
Why does the following code of read() call stall? <p>Got no warning compiling with gcc -Wall -W -g3 <<em>inputfile.c</em>>
but binary doesn't show anything and not getting $ prompt.
gcc version 4.9.2 (Ubuntu 4.9.2-10ubuntu13). I've taken it from the book Unix System Programming by Keith Haviland. Example of read() ... | <p>You have misplaced brackets here:</p>
<pre><code>if( (fd = open("fi.txt", O_RDONLY) == -1)){
</code></pre>
<p>which results in fd being set to 0, rather than the return value of open. Thus you are actually reading from fd 0 (STDIN).</p>
<p>It should be:</p>
<pre><code>if( (fd = open("fi.txt", O_RDONLY)) == -1){
... |
Call to a member function fill() on string <p>I got this error after trying to edit my data.
FatalErrorException in CRUDRenderHelper.php line 41: Call to a member function fill() on string</p>
<p>my CarCategoriesController code :</p>
<pre><code><?php
namespace App\Http\Controllers;
use App\Http\Requests;
use Ap... | <p>You probably have a route like this:</p>
<pre><code>Route::post('car_category/{id}', 'CarCategoriesController@save');
</code></pre>
<p>You are receiving the an id from your route. By default, they are being passed to your controller methods as strings. In your code, you are passing the id, which is a string, to yo... |
Why it says Boolean was given <p>can anyone help me on this. I'm trying to fetch all the data from table. but it keeps returning as boolean. </p>
<pre><code><?php
$con = mysqli_connect("localhost", "root", "", "student");
$query = "SELECT * FROM `announcement` ORDER BY `announce_id` DESC";
$result = m... | <p>Please make sure you have a data in "announcement" Table.</p>
<p>You can check the number of rows return in the result set by using the mysqli_num_rows() function.</p>
<p>Try this:</p>
<pre><code>$con = mysqli_connect("localhost", "root", "", "student");
$query = "SELECT * FROM `announcement` ORDER BY `announce_i... |
Understanding third row of Perspective projection matrix <p>What is the purpose of the third row of this perspective matrix? Couldn't we simply keep the original z coordinate, and still be able to determine which points should be drawn in front of others? If we replace cell (3,3) by 1 and cell (3,4) by 0, the point wou... | <p>Yes, theoretically you could keep the z-values as they are to get comparability. However, practice does not allow that. And actually, this matrix will not work on its own. But let me come to that later. Here is a diagram of the resulting projected z versus the input z coordinate, assuming a near clipping plane of 1 ... |
Using pipe() and execvp() killing my program <p>My program is killed when I run this bit of code but I can't seem to figure out why. </p>
<pre><code>int pipefd[2];
pipe(pipefd);
pid = fork();
if(pid == 0){ //child process, receives data from pipe for execution
close(0);
dup(pipefd[0]); ... | <p><sup><em>Transferring comments into an answer.</em></sup></p>
<h3>Closing pipes</h3>
<p>You are not closing enough pipe file descriptors. If you duplicate a descriptor to standard input or output, you should close both of the pipe descriptors.</p>
<blockquote>
<p>Which other pipe file descriptors should I be cl... |
How to Delete an item after loading the component in QtQuick 1.1 <p>This question is regarding QtQuick 1.1, qml, GUI creation</p>
<p>So i have created a component with 3 items (image or rect etc.,) Because this is reused in many screens of my application.</p>
<p>In one particular screen there is need only 2 item.</p>... | <p>In most case you can just change the visibility of an object.</p>
<pre><code>visible: false
</code></pre>
<p>or</p>
<pre><code>opacity: 0
</code></pre>
<p>For example you can add alias property for it.</p>
<pre><code>//Mycomponent.qml
Rectangle {
id: myRect
property alias item1Visible: item1.visible
... |
Function saves and prints only one value from array. how it can be fixed? <p>I have got a function which allows me to save droped items for a loop inside form. Here is <a href="https://jsfiddle.net/montel388/ny1n9gm0/3/" rel="nofollow">sample</a> with two processes. What i want to do is to print saved values on the nex... | <p>Ok, I added hidden input into the function and it helped me. Here is what i did:</p>
<pre><code> var LISTOBJ = {
saveList: function() {
$(".proc").each(function() {
var listCSV = [];
$(this).find("li").each(function(){
listCSV.push($(this).text());
});
... |
Why is this string unparseable? <pre><code>JSON.parse('["foo", "bar\\"]'); //Uncaught SyntaxError: Unexpected end of JSON input
</code></pre>
<p>When I look at the above code everything seems grammatically correct. It's a JSON string that I assumed would be able to be converted back to an array that contains the strin... | <p>It seems like your code should be:</p>
<pre><code>JSON.parse('["foo", "bar\\\\"]');
</code></pre>
<p>Your Json object is indeed <code>["foo", "bar\\"]</code> but if you want it to be represented in a JavaScript code you need to escape again the <code>\</code> characters, thus having four <code>\</code> characters.... |
Escaping ~! in awk (bash command), backslash not last character on line <p>I am trying to run a bash command in the following format:</p>
<pre><code>declare "test${nb}"="$(cat file.txt | awk '{if($3>0.5 && $3 !~ "ddf") $2="NA"; print $1,$2}')"
</code></pre>
<p>where $nb is an int (e.g. 2) and file.txt cont... | <p>Lose the quotes:</p>
<pre><code>$ declare x="$( echo '!' )"
-bash: !': event not found
$ declare x=$( echo '!' )
$ echo "$x"
!
</code></pre>
<p>You have a lot of other issues with your statement, though, including UUOC, using a scalar to emulate an array, non idiomatic awk syntax, etc. Try this instead:</p>
<pre>... |
Excel file can not normally open <p>My Excel file generated by the table2excel jQuery plugin will not open properly, and will throw <strong>XXXX.xls file format; the extension doesn't match.</strong>
and I think this file is a text file, not a real binary excel file.
<a href="http://i.stack.imgur.com/jeeLB.png" rel="no... | <p>I happened across this <a href="http://stackoverflow.com/questions/33031702/excel-file-generated-by-table2excel-jquery-plugin-throws-error-when-opened?rq=1">SO question</a>, and it appears you are using the answer's <a href="https://jsfiddle.net/t8tegrad/8/" rel="nofollow">jsfiddle</a>. The reason it pops up the war... |
Java thread producer and consumer <p>I was writing a small program to use <code>ReentrantLock</code> instead of <code>synchronized</code> of producer and consumer problem. But the program got stuck because once the produced items are consumed, the consumer thread will stop and never resume to consume again. </p>
<p>Co... | <p>Okay you forgot to do two things:</p>
<ol>
<li>update the variable n when you consume and produce</li>
<li>remove the Mantou from the list after consume (this is hard to do with a list and so I recommend using ArrayList instead)</li>
</ol>
<p>Also, your two conditions are unnecessary... You can just do it with one... |
Nginx: when to use proxy_set_header Host $host vs $proxy_host <p>I've been reading up on reverse proxying and am wondering when <code>proxy_set_header Host $host</code> is appropriate over <code>proxy_set_header Host $proxy_host</code>. I did some research and in <a href="https://www.digitalocean.com/community/tutorial... | <p>In general there is no need to explicitly do <code>proxy_set_header Host proxy_host</code> because it's the default. If you need to call a server by something <em>other</em> than what is in the <code>proxy_pass</code> directive, then you will need to override via <code>proxy_set_header something</code>. </p>
<p>If ... |
How to handle self generated URLs which doesn't exist in my server <p>Sorry if I didn't ask this question in the right way because I guess there may be duplicate questions on SO but I am new to this one so I don't really know the right words to search on.</p>
<p>I purposely generated some URLs which doesn't exists in ... | <p>What you want to do is to Rewrite URLs.</p>
<p>Its a bulky tutorial on its own but check out this article <a href="https://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/" rel="nofollow">URL Rewriting for Beginners</a></p>
<p>Also refer to this SO question <a href="http://stackoverflow.com/q... |
Range.insertNode() without triggering "selectionchange" <p>How to insert a node after a selection without triggering any "selectionchange" event.</p>
<p>I got the range from Selection.getRangeAt(0).</p>
<p><a href="http://stackoverflow.com/questions/3597116/insert-html-after-a-selection">Insert HTML after a selection... | <p>I have found a workaround.</p>
<p>Basically, I was manipulating a Range object. If I can detach one then I can manipulate it however I want. So I made a design choice and passed the detached range as a parameter in the function.</p>
<p>After some trial and error, I used this which works:</p>
<pre><code>var r = ra... |
Add a Video to AngularJs Image Slider (ui.bootstrap.carousel) <p>I am developing web application using AngularJS and I have a requirement that there should be an Image slider which consists of Images and Videos.</p>
<p>according to sample given in <a href="https://angular-ui.github.io/bootstrap/" rel="nofollow">UI Boo... | <p>The default implementation of the carousel is built for images, it does not support having any other media. So out of the box inserting videos into your carousel is not possible.</p>
|
How to click an element without id inside div without class using Xpath and C# <p><a href="http://i.stack.imgur.com/cWIeU.png" rel="nofollow"><img src="http://i.stack.imgur.com/cWIeU.png" alt="enter image description here"></a></p>
<p>I am supposed to click the link (highlighted blue, refer to image above), but <code>... | <p>Your tried locator looks incorrect, you should try using <code>xpath</code> with text to locate desire element as below :-</p>
<pre><code>_driver.FindElement(By.XPath(".//div[text()='HH3']")).Click();
</code></pre>
|
Printing UI Without Vowels Using Loops Without replaceAll(); in Java <p>I am trying to take user input and modify it so that I print the string without any vowels. I have been able to do this successfully with the following code.</p>
<pre><code>Scanner in = new Scanner(System.in);
System.out.println("Enter a word:... | <p>One way would be to convert your string to an array of characters <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#toCharArray%28%29" rel="nofollow">toCharArray()</a> and then compared with a case and add a new chain StringBuilder</p>
<pre><code> String word = in.next();
StringBuilder bu... |
Update global variable in C via reference by parameter <pre><code>short int PC = 0;
int main() {
foo(&PC) ;
}
void foo(short int PC) {
PC++;
}
</code></pre>
<p>How do I successfully update the global variable of PC?</p>
<p><strong>Note</strong>: PC must be passed as a parameter and the global variable n... | <p>You just need to take the argument as a pointer:</p>
<pre><code>short int PC = 0;
void foo(short int *pc) {
(*pc)++;
}
int main() {
foo(&PC) ;
}
</code></pre>
<p>I moved <code>foo()</code> above <code>main()</code> because in C you have to declare things before they are used. If you prefer you could... |
Error Could Not Implicit Value ToResponseMarshaller[SearchResponse] <p>what i want to achieve are : create an API, which looking for into ElasticSearch. my programming language is Scala.</p>
<p>//myRoute.scala</p>
<pre><code>val pencarianES =
{
post
{
path("cariES")
{
parameters("xQuery"... | <p>Although building RootJsonFormat for java classes is very tedious, here one example for one result. Just import in scope:</p>
<pre><code>object SearchResultProtocol {
implicit object SearchResulJsonFormatObject extends RootJsonFormat[SearchResponse] {
def read(e: JsValue) = null
/* {
"_shards":{
"t... |
Adding an element to every item of an array in ruby <p>I currently have an input <code>[['a', [0, 1]], ['b', [1]]]</code>. I'm trying to combine the first item to every element in <code>[0,1]</code> i.e.: <code>'a'</code> in <code>['a',[0,1] => [['a',0],['a',1],['b',1]]</code> like ordered pairs. I've done it but it... | <pre><code>â¶ arr.flat_map { |e| [e.first].product(e.last) }
#â [["a", 0], ["a", 1], ["b", 1]]
</code></pre>
|
Failed to connect to mailserver at "localhost" port 587, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in wamp server <p>i am using simple send email in php and get this error </p>
<blockquote>
<p>Warning: mail() [function.mail]: Failed to connect to mailserver at
"localhost" port 587, ver... | <p>SMTP server is required for sending emails. You need to mention SMTP host and SMTP port in php.ini file. If your config is proper then the mail function will work. There are various SMTP servers are available. You can search for them.</p>
|
Get zipped TFS 2015 (vNext) build output logs through powershell (just like the download link after the build) <p>I'm wondering if anyone has a PowerShell script to either download all the current build logs for this build id (up to the current step) through the Rest API for TFS 2015 (vNext), create separate text files... | <p>You can use TFS REST API in your script to <a href="https://www.visualstudio.com/ru-ru/docs/integrate/api/build/builds#logs" rel="nofollow">get Build Logs</a> directly:</p>
<pre><code>GET https://{instance}/DefaultCollection/{project}/_apis/build/builds/{buildId}/logs
</code></pre>
<blockquote>
<p>instance: VS T... |
Looking for CMS Image Gallery <p>This is my current insert image function, i'm using TinyMCE <a href="http://i.stack.imgur.com/cJvMv.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/cJvMv.jpg" alt="Screenshot"></a>
instead of manually putting the images on the uploads folder then manually inserting the directory ... | <p>Something like : <a href="http://www.dropzonejs.com/" rel="nofollow">http://www.dropzonejs.com/</a> </p>
<blockquote>
<p>DropzoneJS is an open source library that provides dragânâdrop file uploads with image previews.</p>
</blockquote>
<p>This provides the client side interface to drag/drop an image. Your co... |
Trying to create a pandas series within a dataframe with values based on whether or not keys are in another dataframe <p>Boiling it down simply...</p>
<p>Dataframe 1 = yellow_fruits
The columns are fruit_name, and location</p>
<p>Dataframe 2 = red_fruits
The columns are fruit_name, and location</p>
<p>Dataframe 3 = ... | <p>The classic way would be to use your conditions as indexers:</p>
<pre><code>df1 = pd.DataFrame({'fruit_name':['banana', 'lemon']})
df2 = pd.DataFrame({'fruit_name':['strawberry', 'apple']})
df3 = pd.DataFrame({'fruit_name':['lemon', 'rockmelon', 'apple']})
df3["color"] = "unknown"
df3["color"][df3['fruit_name'].is... |
groupby and add some rows <p>I have a dataframe below</p>
<pre><code> A B
0 a 1
1 a 2
2 c 3
3 c 4
4 e 5
</code></pre>
<p>I would like to get summing result below.key = column A</p>
<pre><code>df.B.groupby(df.A).agg(np.sum)
</code></pre>
<p>But I want to add specific row. </p>
<pre><code> B
a 3
b 0... | <p>Use <code>reindex</code></p>
<pre><code>df.groupby('A').B.sum().reindex(list('abcdef'), fill_value=0)
A
a 3
b 0
c 7
d 0
e 5
f 0
Name: B, dtype: int64
</code></pre>
|
code looks great in codeacademy, but not any other browser <p>Ive been working on a 3d website, and i decided it would be easier to work on it through code academy make your own video game. <a href="https://www.codecademy.com/courses/web-beginner-en-X7bpO/0/1" rel="nofollow">https://www.codecademy.com/courses/web-begin... | <p>You can fix the problem by removing the <code><!DOCTYPE html></code> declaration, though this is not a preferable solution, as it indicates that a mistake was made in the style.</p>
<p>Instead, try adding the following to your style for <code>html, body</code>:</p>
<pre><code>height: 100%;
width: 100%;
</cod... |
How to get an MP3 bit rate in SWIFT <p>I am searching for a way of getting an mp3 bitrate like <code>128kbps</code> or <code>320kbps</code> for mp3 audio from url link.</p>
<p>I have a <code>UITableView</code> that loads a list of files from url list, and I would like to display an audio quality.
I have tried using <c... | <p>Just using the formula. It was that easy.. </p>
<pre><code>var bitrate: Int { // kbps
if size > 0 && duration > 0 {
return size * 8 / 1000 / duration
}
</code></pre>
|
Set the li active based on the url <p>Can someone help me to find what's the problem to my code? Im trying to set the <code>li</code> to active based on it's url. But the problem is nothing is set to active after loading. Give me ideas on how to do this or any alternative ways to do this?</p>
<p><strong>NOTE</strong> ... | <p>Can you try with following code:</p>
<pre><code>$(document).ready(function() {
$(function(){
//location.search will give us query string i.e. part present after ? mark and ? itself which is nothing but ?subjdescr=COMPUTER PROGRAMMING 1
var current = decodeURIComponent(location.search); //decod... |
A Pivot table in r with binary output <p>I have the following dataset </p>
<pre><code>#datset
id attributes value
1 a,b,c 1
2 c,d 0
3 b,e 1
</code></pre>
<p>I wish to make a pivot table out of them and assign binary values to the attribute (1 to the attributes if they exist otherwise... | <p>We split the 'attributes' column by ',', get the frequency with <code>mtabulate</code> from <code>qdapTools</code> and <code>cbind</code> with the first and third column.</p>
<pre><code>library(qdapTools)
cbind(df1[1], mtabulate(strsplit(df1$attributes, ",")), df1[3])
# id a b c d e value
#1 1 1 1 1 0 0 1
#2 ... |
Print rows of triangle if a user specifies (more than 0) <p>I want the code to do this:
If I enter '5' it would print 5 triangle rows like this:</p>
<pre><code>+
++
+++
++++
+++++
</code></pre>
<p>I also want to inverse it afterwards so that it looks like so:</p>
<pre><code>+++++
++++
+++
++
+
</code><... | <p>Yes, you have to do it with nested-loops.</p>
<p>Take a look at this code:</p>
<pre><code>Scanner input = new Scanner(System.in);
int Rows = 0;
while (Rows <= 0) { // Keep asking the user if they enter something less than zero
System.out.print("How many rows do you want in your triangle, more than 0?: ");
... |
disable viewport zoom iOS10 safari? <p>I've tried all three of these but no luck:</p>
<pre><code><meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;
user-scalable=0;" />
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;
user-scalab... | <p>This should work until Apple comes to their senses and stops removing features we all use...</p>
<pre><code>document.documentElement.addEventListener('gesturestart', function (event) {
event.preventDefault();
}, false);
</code></pre>
|
TextBlock Text property not updating on updating its source Binding property? <p>I have the following code snippet in XAML.</p>
<pre><code><Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="01*"/>
<ColumnDefinition Width="03*"/>
<ColumnDefinition Width="01*... | <p>Of the two answers given so far, the only one that comes even close to what I think is a reasonable alternative is the second option presented in <a href="http://stackoverflow.com/a/39716289">this answer</a> (i.e. after <em>"if you want to 'Update' SelectedName you could"</em>).</p>
<p>That said, it seems to me tha... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.