input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
Set variable to Memory Address in Python 3.5 <p>How would I convert these lines (originally python-2.7) to Python-3.5:</p>
<pre><code>DELETE = 0x00010000L
READ_CONTROL = 0x00020000L
WRITE_DAC = 0x00040000L
WRITE_OWNER = 0x0008000... | <p>Python 3 no longer has a distinction between a long and regular int. </p>
<p>Just remove the <code>L</code> at the end of the hex literals and you are good to go:</p>
<pre><code>>>> STANDARD_RIGHTS_ALL = 0x001F0000
>>> STANDARD_RIGHTS_ALL
2031616
>>> hex(STANDARD_RIGHTS_ALL... |
Entity Framework grouping by column from join <p>I have the next query:</p>
<pre><code>select VisitLines.ProcedureId, COUNT(DISTINCT VisitLines.VisitId) as nt
from Visits
LEFT JOIN VisitLines ON Visits.Id = VisitLines.VisitId
WHERE Visits.VisitStatusId = 1 AND Visits.IsActive = 1 AND VisitLines.IsActive = 1
GROUP BY ... | <p>I found. Need to use <code>SelectMany</code> with second parameter <code>resultSelector</code>:</p>
<pre><code>dbContext.Visits.Where(x => x.IsActive)
.SelectMany(x => x.VisitLines, (v, vl) => new
{
v.Id,
vl.ProcedureId
})
... |
Access Angular2 object? <p>I want to save and access to the Angular2 object but I am getting undefined as value. I am getting a object but this not accessible such as array. How can I do it as array?</p>
<p><strong>Node.js api.js</strong></p>
<pre><code>api.get('/getData', function(req, res){
res.send({name:'test'}... | <p><code>this.items.subscribe(...)</code> is asynchronous meaning that it won't run that code right now. <code>this.items</code> is an <a href="https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/observable.md" rel="nofollow"><code>Observable</code></a> which in short means that when something happens ... |
Generic collection for realm objects <p>We're finding that our project has lots of duplicated/boilerplate code surrounding collections of realm objects for basic list view controllers, and wondering if there's some generic container we can encapsulate them in. </p>
<p>It seems like <code>AnyRealmCollection</code> is v... | <p><code>AnyRealmCollection<T></code> is used in the following manner.</p>
<pre><code>class ParentController<T: Object>: UITableViewController {
var dataSource: AnyRealmCollection<T>!
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return dataSou... |
How can I place and handle a standard Windows button in Processing? <p>Title says it all.</p>
<p>(more characters.)</p>
| <p>There is no such thing as a standard Windows button. The whole point of the article you linked is explaining that there isn't a standard button. That is a guide explaining what your buttons should look like to make them standard. How you do that is up to you and the language you choose (in this case, Processing). Bu... |
Facebook Messenger API: Webviews Opening in Browser <p>I'm trying to use the Facebook Messenger API to create a "generic" message with a button. When that button is clicked, I want to display a "webview" (ie. a framed version of a webpage inside Messenger).</p>
<p>However, even though my button has the required <code... | <p>Apparently, webview only started to work in the last update.</p>
<p>Try to update your Messenger app.</p>
<p><a href="https://messengerblog.com/bots/messenger-platform-1-2-link-ads-to-messenger-enhanced-mobile-websites-payments-and-more/" rel="nofollow">https://messengerblog.com/bots/messenger-platform-1-2-link-ad... |
Remove checked checkboxes using JQuery <p>I'm trying to remove my checked checkboxes using</p>
<pre><code>$(".gone").removeAttr('checked');
</code></pre>
<p>If you scroll to the bottom and click <code>+ Add new Line</code> it will append another <code><tr></code>. What I'm trying to do is remove a <code><tr&... | <p>You don't need to use event delegation. This will make sense if you want to add for example event listeners to elements that append after that the DOM has been loaded. In your situation you can add an event listener to the element with class <code>.gone</code> and then find all checked <code>checkboxes</code> and re... |
Android AsyncTask vs Thread + Handler vs rxjava <p>I know this is the question which was asked many many times. However there is something I never found an answer for. So hopefully someone can shed me some light.</p>
<p>We all know that AsyncTask and Thread are options for executing background tasks to avoid ANR issue... | <p>AsyncTask and Thread+Handler are not carefully designed and implemented. RxJava, Akka and other frameworks for asynchronous execution seem more carefully developed.</p>
<p>Each technology has its limitations. AsyncTask is for a single parallel task with ability to show progress on UI. However, if activity is regene... |
Firebase authentication signs out previously authenticated users causing permission denied errors for them <p>1) User X visits my webpage, and X is correctly authenticated and able to write to my firebase database via the web browser.</p>
<p>2) User Y then visits my webpage, and Y is authenticated and able to write to... | <p>Only a single person can be authenticated in an app at one time.</p>
<p>If you open multiple tabs in the same browser window, they will very likely end up as a single user.</p>
<p>To have multiple users on a single machine, either use a different, secondary browser or open an incognito window.</p>
|
String Split Situation <p>I have a fairly specific problem, where I want to take an equation and break it up, but also pay attention to negative numbers. Like:</p>
<pre><code>exampleString = "12--5*-2"
</code></pre>
<p>Using that string I wish to split it into 3 number values:<br>
<code>[12, -5, -2]</code></p>
<p>Iv... | <p>You could use a regular expression like the following to split the string.</p>
<pre><code>"(?<!\\G)[*/+-])"
</code></pre>
<p>The regular expression will split at any of the specified chars *,/,+,- iff the previous char was not a match (-> '--' will split only at the first '-').</p>
|
source BYTE "This is the source string",0 target BYTE SIZEOF source DUP(0),0 <p>What is SIZEOF referring to? Is it referring to the size of the source (lengthOf * TYPE which is equal to number of elements in the array * the size of each element)? Also, can someone explain DUP(0),0? This is referring to Assembly x86 MAS... | <p><code>SIZEOF</code> simply denotes the <a href="https://msdn.microsoft.com/en-us/library/xzbax489.aspx" rel="nofollow">size of a type or structure</a>. </p>
<p>It refers to whatever you put after the <code>SIZEOF</code> keyword. </p>
<pre><code>SIZEOF element ; refers to a single element in the array.
SIZE... |
In token-based authentication how do tokens get verified? <p>I've read numerous token based authentication articles and they typically fail to explain how the server verifies token. I understand that:</p>
<ol>
<li>User Requests Access with Username / Password</li>
<li>Application validates credentials</li>
<li>Applica... | <p>It depends. The token can be a hash of the username the password and a key that the client generates, it can be just random and stored in a db, there is not a unique answer for this</p>
|
Can't update file name in Google Drive <p>I am trying to update a file in Google Drive using Java.</p>
<pre><code>File f =
drive.files().update(fileId, null).setAddParents(newParentId).setRemoveParents(oldParentId).set("name", "new name").execute();
</code></pre>
<p>The parent folder is updated, but the file name is ... | <p>Filename or title belongs to metadata according to <a href="https://developers.google.com/drive/android/metadata" rel="nofollow">Working with File and Folder Metadata</a> guide.</p>
<blockquote>
<p>"Metadata is encapsulated in the Metadata class and contains all
details about a file or folder including the titl... |
Outputting HTML User Input *Using HTML Code* <p>I am trying to output information that the user inputs into the website. Here is my code for the first part of the page that displays the information that is filled in (this code works):</p>
<p></p>
<pre><code><form action = "comment_process.php" method = "post">
... | <p>Check your input naming. It is <code>name</code> in your HTML and <code>firstname</code> in your php.
Also make sure to use a semi-colon after each line in your php or else it will have errors. <code>echo "Hello $v! <br>";</code></p>
<p>Not an error, but maybe confusing, your options in the drop down have dif... |
How to relate values of a single attribute in database <p>I am confused about how to make relationship among values of a single attribute in a MYSQL database for e.g. I have two tables in database named "Language" and "Dictionary" so in Entity "Language" there are two attributes 1st is "language_id" and the other is "N... | <p>My first thought is to add an extra column to Dictionary which references a primary word. The two tables might look like this:</p>
<pre><code>Language
--------
language_id
name
Dictionary
----------
id
word
language_id
primary_id
</code></pre>
<p>If the primary word is in English, it would have a primary_id of nu... |
ListView loses formatting when scroll <p>I have made one Adapter to my ListView and I want to programmatically change the color of some lines if they have the value I specified.</p>
<p>The code below shows how this is implemented. Two strange things happen:</p>
<p>1) The first line should be painted, but was not bein... | <p>the view in listView will be reused, try to think you are set each view in one place. So you need consider every situation, add <strong>else{}</strong></p>
<pre><code>if (Legend.getValue().equals("Color")){
convertView.setBackgroundColor(Color.GRAY);
Legend.setValue("");
} else {
//set backgro... |
Powershell file URL / file filtering <p>I am trying to generate an html page with file index. This approach worked seamlessly:</p>
<pre><code>$htmlout = Get-ChildItem -Path "$SearchPath" -Filter "$fileType" -Recurse |
Select @{Name="Link";Expression={("<a rel=" + $_.FullName + " href=file:///" + $_.FullName + ">... | <h2>Background</h2>
<p>As far as I can tell, there is a discrepancy with the interaction between the <code>.ToString()</code> method and the <strong><em>DefaultDisplayProperty</em></strong> of objects returned by <code>Get-ChildItem</code>.</p>
<p>The behavior manifests when both of the following conditions are true:... |
Haskell - add n number of 0s into a list <p>I'm quite new to haskell. Given list [a] of integers and an integer n, how can I add n 0s in the beginning of list [a]. Many thanks.</p>
| <p>This is super straightforward: it's just</p>
<pre><code>replicate n 0 ++ list
</code></pre>
<p>where <code>replicate</code> just makes a list of <code>n</code> occurrences of the specified element, and <code>++</code> combines the lists together.</p>
|
Obtaining max of unsigned integer with bitwise not on zero value <p>I'm trying to obtain the maximum value of a certain unsigned integer type without including any headers like <code><limits></code>. So I thought I'd simply flip the bits of the unsigned integer value 0.</p>
<pre><code>#include <iostream>
#... | <blockquote>
<p>... to obtain the maximum value of a certain unsigned integer type without including any headers</p>
</blockquote>
<p>Simply assign the value <code>-1</code></p>
<pre><code>unsigned_type_of_choice max = -1;
</code></pre>
<p>Conversion of the <code>-1</code>, which is an <code>int</code>, to any uns... |
Unable to connect website to SQL Server <p>I'm having some trouble setting up a dev instance of a C# based website using SQL Server. I'm used to doing this all with MySQL, so this is all a bit alien for me. Having read through MS troubleshooting, my setting appear to be OK, but this is still not working, so clearly I'm... | <p>The error itself already said incorrect server configuration on <code>web.config</code>:</p>
<blockquote>
<p>A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
was not accessible. Verify that the instance name is correct and that
... |
Expression visitor only calling VisitParameter for some lambda expressions <p>I want to be able to used nested extension methods to do projection of entities in EF to corresponding view models. (see my previous question <a href="http://stackoverflow.com/questions/39585427/projection-of-single-entities-in-ef-with-extens... | <p>First thing to remember is that when parsing nodes, we essentially run backwards:</p>
<pre><code>entity => new ProfileModel
{
SomethingElses = entity.SomethingElses.AsQueryable().ToViewModels()
}
</code></pre>
<p>Here, we process <code>ToViewModels()</code>, then <code>AsQueryable()</code>, then <code>Somet... |
XPath for elements using Chrome? <p>Is there a way to get XPath of UI elements using <a href="https://developer.chrome.com/devtools" rel="nofollow">Chrome Developer Tools (DevTools)</a>?
I want to use the XPath in Selenium UI auto-testing.</p>
| <h2>How to get an XPath to an element in Chrome</h2>
<ol>
<li>Right-click on the UI element and select "Inspect."</li>
<li>A tree structure representation of the elements is shown.</li>
<li>Right-click on any element and select "Copy > Copy XPath."</li>
<li>Your clipboard will then have the XPath to the selected eleme... |
Put font color in a certain line or word using C programming <p>I tried the system("COLOR 0a"); but it will change all the font color to that color. I also tried the textcolor(4) it gives me an error, the error message is textcolor is undeclared but I include the conio.h. What the problem?</p>
<p>NOTE: Im using window... | <p>You can use the Windows function <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms686047(v=vs.85).aspx" rel="nofollow"><code>SetConsoleTextAttribute</code></a>. A list of attributes is <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms682088(v=vs.85).aspx#_win32_character_attribu... |
Copy file extension without preserving the folder structure <p>I have a set of file list located at different folder and I would like to copy it to a different location after filtering the files without preserving the folder structure .</p>
<p><code>find -regex '.*\(xml\|hex\|out\)' | cpio -pdm /data/Folder/Project/GU... | <p>Found the answer but can someone explain why I need to use -exec for the cp ?Whats the "{}" for ? and why at the end of the command I had to add a \ and also a ;</p>
<p><code>find -regex '.*\(xml\|hex\|out\|rc\|map\)' -exec cp {} /data/Folder/Project/GUI/output/ \;</code></p>
|
Hibernate default value for @joincolumn <p>I am using jpa/hibernate</p>
<p>Country.java</p>
<pre><code>@Column(nullable = false, name = "REGION")
private String region;
@Id
@Column(nullable = false, name = "CODE")
private String Code;
</code></pre>
<p>User.java</p>
<pre><code>@Column(nullable = false, name = "NAME... | <blockquote>
<p>Is there a way that I can set a default value for a @joinColumn in User.java for country column in hibernate?</p>
</blockquote>
<p>You could use <a href="http://docs.oracle.com/javaee/6/api/javax/persistence/JoinColumn.html#columnDefinition()" rel="nofollow"><code>columnDefinition</code> field in <co... |
Cannot read property 'x' of undefined <p>So I have been trying to put together a simple little text based RPG and I just finished creating objects for the buttons and the different types of characters. When I stopped for the day and saved, I had no errors, but I came back on today and received the error "Cannot read pr... | <p>When you call </p>
<p><code>var btn1 = new Button( /*customize button*/ );</code></p>
<p><code>Button</code> should be sent a value for config. Because this isn't present, when you try to access <code>config.x</code> you get the error.</p>
<p>To solve the problem you need to send in relevant data to <code>Button<... |
Kentico Preventing Misuse of memberships / accounts (e-commerce) <p>Our current Kentico site sells <a href="https://docs.kentico.com/display/K8/Membership+management" rel="nofollow">memberships</a> to content and it works fine.</p>
<p>The issue we have is the subsequent misuse of these accounts (sharing).
We suspect a... | <p>Well, if they <em>know</em> passwords for logging in than there is so much you can do... You could theoretically check the IP of the user and limit somehow based on how often/from which IPs the account is logging in, but I'm not sure how good idea that is.</p>
<p>Its hard to advise since we have no idea of the busi... |
How to find the max value of an unsorted array <p>I am really new to java and I signed up for an AP class which is being taught very badly, and so I have no idea of how to do this part of the assignment. It prampts you to add code that will do the following</p>
<p>Find and print the maximum sale. Print both the id of ... | <p>One possible strategy for finding a max value of an unsorted array is to go through the array (using a <code>for</code> loop, perhaps), and keeping track of the maximum value as you go through it.</p>
<p>I don't want to do your homework, but that might look like:</p>
<pre><code> max = Integer.MIN (the smallest p... |
Why when i hover over my text box it doesnt affect the background <p>if you hover over one of my posts on this site <a href="http://motivationalblogging.com/" rel="nofollow">http://motivationalblogging.com/</a> it zooms. I got the zoom to work, but as soon as i hover over the text that appears the zoom stops. I have tr... | <pre><code>a:link {
color: black;
}
a:visited {
color: gray;
}
a:hover {
color: pink;
}
a:active {
color: yellow;
}
.background-switch {
text-align: center;
padding: 1em;
max-width: 250px;
font-size: 2.2em;
border-radius: 30px;
background-color: pink;
}
.background-switch:hover {
background-colo... |
How to deploy dependencies with XPages Runtime in Bluemix <p>I uploaded my project to Bluemix using IBM Domino Designer, the XPages runtime started fine. During testing, I hit the URL and I received a message </p>
<p>"The application /gittest.nsf requires org.openntf.xsp.debugtoolbar.library. This library cannot be f... | <p>You need to put all the osgi plugins in a folder named 'shared-plugins' this directory should be at the same level as the Manifest.yaml file in your project's deployments folder.
More details see the blog of Oliver Busse
<a href="http://oliverbusse.notesx.net/hp.nsf/blogpost.xsp?documentId=FD2" rel="nofollow">http:/... |
How to get base url without accessing a request <p>How to get the base URL in AspNet core application without having a request?</p>
<p>I know from the Request you can get the scheme and host (ie <code>$"{Request.Scheme}//{Request.Host}"</code> would give something like <a href="https://localhost:5000" rel="nofollow">h... | <p>You are right, hosting URL is an external information, and you can simply pass it as configuration parameter to your application.</p>
<p>Maybe this is help you somehow: without request you can get a configured listening address (like <code>http://+:5000</code>) using <a href="https://github.com/aspnet/Hosting/blob/... |
How to present a secure, HTTP-only cookie as a bearer token (without Angular.JS)? <p>Is it possible to store a JWT as a secure, HTTP-only cookie <strong>and</strong> present it as a bearer token <strong>without</strong> using Angular.JS?</p>
<p>I assume that this might be possible, since Angular.JS has similar functio... | <p>Hahahah yes...angularjs is just javascript</p>
<p>You need to find out what library is parsing the cookie on the back end..if you're using express, for example, you're probably using cookieParser...you can just console.log(req.cookie), and you can see all the cookies that are sent.</p>
<p>You can set a cookie pret... |
php header force download returning unusable mp3 <p>i have been working on this for 5 days now... tearing down code and rebuilding it. I am trying to force a mp3 file download. When it has no special characters ( ampersand, quote, apostrophe), the download works fine. I loose all the metadata in the file, but the file ... | <p>I found my issue. I didnt add a filesize to it,so it wasnt reading the length of the file. Added these 2 lines and works flawlessly</p>
<pre><code>$size = filesize('../data/lib/'.$file);
header('Content-Length: ' . $size);
</code></pre>
|
How to easily modularize Javascript like C/C++ <p>I have a large project entirely built in JavaScript, I have an ordered and "inside modularized" 5k lines .js file that's the engine of whole site. </p>
<p>Now I have to make other site (extension of this one) in which I'll have to repeat a lot of code, my question is, ... | <p>Use webpack to bundle your code <a href="http://webpack.github.io/docs/tutorials/getting-started/" rel="nofollow">http://webpack.github.io/docs/tutorials/getting-started/</a></p>
|
Using Wireshark to extract payload from captured packets to in CSV file <p>I run Wireshark to capture packets generated from my simulation. I use File > Export Packet Dissection > As CSV... to extract the captured packets into CSV file in order to do some machine learning. The following is an example of I got:</p>
<pr... | <p>Extracting the payload can be difficult, depends on link encryption. In case the link is unencrypted It's possible in some cases and CSV is one of them. Please follow this <a href="https://www.wireshark.org/docs/wsug_html_chunked/ChIOExportSection.html" rel="nofollow">link</a>. Let me know if that worked for you. ... |
Using Multiples in C <p>I'm trying to teach myself C and have only done a few things in CodeAcademy so far. I'm pretty lacking when it comes to loops in my current online course. Let's say I wanted to use a loop to make the first 5 multiples of 1 through 10 like below. </p>
<p><div class="snippet" data-lang="js" data-... | <p>A big part of programming is about breaking larger problems into smaller problems.</p>
<p>If the problem of making this table is too much for you, then break the problem into pieces. e.g.</p>
<ul>
<li>Write a function that can print the header</li>
<li>Write a function capable of printing one line of the table</li... |
AWS custom autoscaling policy <p>I am trying to figure out the way to create a custom autoscale policy for autoscaling in AWS using boto. I saw that the scale out and scale in policies are defined using system dependent resources like CPU utilization.
But I want the scale out/in policy to be defined in a way that it ca... | <p>Autoscaling doesnt do that for you. The reverse works though, you can <a href="http://docs.aws.amazon.com/AutoScaling/latest/APIReference/API_ExecutePolicy.html" rel="nofollow">execute a policy</a>.</p>
<p>What you could also do is send your custom metrics to cloudwatch, configure an alarm on that and add an autosc... |
How can I init and use i18next plugin in website project? <p>After reading the document of i18next, I am still confused about how to init & use it in both navigator auto detecting way and event trigger way.
Do I need to include it with <code><script></code> tag again if I have had npm install it?
Totally novi... | <p>To use libraries installed with NPM in the browser, you traditionally need to use a build tool like Browserify or Webpack. Asking how to use an npm library in the browser is too broad of a question for StackOverflow.</p>
<p>If you aren't familiar with those tools and want to get up and running quickly, you can just... |
Using series to approximate log(2) <pre><code>double k = 0;
int l = 1;
double digits = pow(0.1, 5);
do
{
k += (pow(-1, l - 1)/l);
l++;
} while((log(2)-k)>=digits);
</code></pre>
<p>I'm trying to write a little program based on an example I seen using a series of Σ_(l=1) (pow(-1, l - 1)/l) to estimate lo... | <p>I assume that you are trying to extimate the natural logarithm of 2 by its Taylor series expansion:</p>
<pre>
â (-1)<sup><em>n</em> + 1</sup>
ln(<em>x</em>) = <strong>â</strong> ââââââââ(<em>x</em> - 1)<sup><em>n</em></sup>
<sup><em>n</em>=1</sup> <em>n</em>
</pre>
<p>One ... |
Javascript: how to make a website that allow user to scroll in any direction? <p>This site is pretty cool, <a href="http://pharrellwilliams.com/" rel="nofollow">http://pharrellwilliams.com/</a>, and I'm wondering what function makes the users can scroll in any direction and the size of page is endless.</p>
| <p>No problem, make a div that's HUGE, like 10,000px (hardcoded!) in width or something that's way bigger than any possible screen size, and however high you need it to be. Then, fill with content. Boom! Your done.</p>
|
AssetManager libgdx Asset not loaded <p>I am having an issue with my AssetManager in libgdx, I am creating it in my Main class and have a getMethod to return the assetManager to my screens. When I go to assetManager.get(etc.) in my screens classes It says </p>
<pre><code>FATAL EXCEPTION: GLThread 563
... | <p>Do you ever get to the menu screen? you switch to Splash() before assetmanager is done loading and before the 3000 milisecs. Even before you check for any of those.</p>
<p>assetManager.update() will return false until the asset is loaded. assetManager.update() is meant to be called every frame until it returns true... |
Java : Convert Color string value to Hexa value <p>I am trying to change color value to color <code>hexa</code> code. So, I code like this:</p>
<pre><code>color = Integer.toHexString(colorpick.getValue().hashCode()).substring(0, 6).toUpperCase();
</code></pre>
<p>The above code is <strong>Ok</strong> for all colors e... | <p>this is absolutely wrong here: </p>
<pre><code>colorpick.getValue().hashCode()
</code></pre>
<p>hashcode is a specific code generated by the JVM to manage hash numbers related to instances and hash-tables... and has NOTHING to do with colors..</p>
<p>this should be more than ok</p>
<pre><code>colorpick.getValue(... |
Why gcloud command is slow to start? <p>Just typing <code>gcloud</code> for help take 5 secs.</p>
<pre><code>$ gcloud
...
gcloud 0.30s user 0.13s system 7% cpu 5.508 total
$ gcloud version
Google Cloud SDK 128.0.0
alpha 2016.01.12
bq 2.0.24
bq-nix 2.0.24
core 2016.09.23
core-nix 2016.09.20
gcloud
gsutil 4.21
gsutil... | <h2>tl;dr</h2>
<p>It turns out that <code>socket.gethostbyaddr(socket.gethostname())</code> is slow for <code>.local</code> hostname in macOS.</p>
<pre><code>$ python -i
>>> socket.gethostname()
'hiroshi-MacBook.local'
>>> socket.gethostbyaddr(socket.gethostname()) # it takes about 5 seconds
('local... |
MVC - Html.Action to retrieve element using Javascript, then pass it as parameter to Controller, then return a PartialView <p>View - My view has a modal that has an <code>@Html.Action</code> that calls the <code>PartialViewResult</code> in <code>Controller</code>. Notice the <code>@Html.Action("RetrieveItemPrice", new ... | <p>Assuming you have many items with different item_Id and you want to show the modal dialog when this item is clicked. You should be listen to the click event on the element, make an ajax call and get the response (partial view result) and use that to build your modal dialog content.</p>
<p>Assuming your main view ha... |
How to generate image background that flips with each duplication in css? <p>I have an image </p>
<p><a href="http://i.stack.imgur.com/fNPVc.png" rel="nofollow"><img src="http://i.stack.imgur.com/fNPVc.png" alt="enter image description here"></a></p>
<p>If I set this image as a background with window being larger tha... | <p>The answer is: <strong>You can't.</strong> You can not flip a background image using just CSS. </p>
<p>Possible Solutions for you :</p>
<p>Looking at your problem, if you do not want to repeat your image, then set </p>
<pre><code>background-repeat: no-repeat
</code></pre>
<p>And you can also set </p>
<pre><code... |
Insert (single) spaces before and after a specific symbol <p>I need to insert (single) spaces before and after a specific symbol (e.g. "|"), like this:</p>
<pre><code>string input = "|ABC|xyz |123||999| aaa| |BBB";
string output = "| ABC | xyz | 123 | | 999 | aaa | | BBB";
</code></pre>
<p>This can easily be achi... | <p>Thanks @Santhosh Nayak.</p>
<p>I just write more C# code to get the output as OP want. </p>
<pre><code>string input = "|ABC|xyz |123||999| aaa| |BBB";
string pattern = @"[\s]*[|][\s]*";
string replacement = " | ";
string output = Regex.Replace(input, pattern, (match) => {
if(match.Index != 0)
r... |
How to import "stompjs/lib/stomp.min" in angular2-webpack <p>I have an angular2-webpack app , want to implements stomp,sockjs-client,websocket.</p>
<p>have added <strong>"sockjs": "0.3.18",
"stompjs": "2.3.3"</strong> in package.json.</p>
<p>when write like this in a service :</p>
<pre><code>import * as SockJS f... | <p>Why do you expect this code to work? Did you find an example with this syntax somewhere? The p<code>Stomp</code> object only contains a lowercase <a href="https://github.com/jmesnil/stomp-websocket/blob/master/lib/stomp.js#L461-L483" rel="nofollow"><code>client</code></a>, and nothing else from your list.</p>
<p>Ju... |
Execute script after page loads in javascript/jquery <p>I am not the original writer of this bookmarklet but am trying to improve/update it to execute the script after the page loads. I would like to hit the bookmarklet as the page loads and it will perform the task when it does finally load. I've tried many forms of $... | <p>Note: "after the page loads" can mean many things, so I interpreted it as "after all html loaded", figuring that's a fairly robust interpretation.</p>
<p>This should take care of you, with a little vanilla Javascript:</p>
<pre><code>document.addEventListener("DOMContentLoaded", function(event) {
console.log("Wha... |
Custom made sections not appearing with Shopify's new theme editor <p>With the release of the new theme editor I've been assigned to build a new client's website using Shopify's new theme builder framework. </p>
<p>Everything has been going fine except that when I go to create a new 'Section' in the backend it fails t... | <p>You're almost there, just missing one thing. Sections will only show up as options to be added if they have a preset defined.</p>
<p>This update will make it show up:</p>
<pre><code>{% schema %}
{
"name": "Call to Actions",
"class": "index-section index-section--flush",
"settings": [
{
"id": "cta_1... |
Android Data Binding XML Error <p>I'm using Data Binding Library on a Android Studio Project when whenever I build, run, clean, rebuild, etc I get the following error:</p>
<pre><code> :app:processDebugResources AGPBI:
{"kind":"error","text":"Error parsing XML: duplicate attribute","sources": [{"file":"C:\\Users\\luci... | <p>Try to remove <strong>android:layout_width</strong> and <strong>android:layout_height="match_parent"</strong> in <strong>layout</strong> tag</p>
<pre><code> <layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="task"
type="com.pichardo.im... |
Writing a webpack or babel plugin to compile static property into stylesheet <p>I'd like to declare my styles (stylus) inside of my React component classes as such. Preferably while also utilizing CSS modules:</p>
<pre><code>export default class HelloWorld extends Component {
render() {
return (
<div cl... | <p>What you're trying to do is not possible, but there is a workaround; unfortunately, the answer might taste like bathtub gin. As you are probably aware, you cannot directly <code>require</code> Stylus. Accordingly, your forced to use a Stylus loader which you have two options, stylus-loader or Walmarts <a href="https... |
Why memory leak happended when std::thread is used, but it does not occur when run in sequence? <p>It's strange that when run the code in sequence, every thing is ok. However, when std::thread is used, memory leak has happend. I used <code>top -p <pid></code> to check the <code>VIRT</code>, it increased obviously... | <p>Technically not an answer but ... Where is delete for <code>std::thread *t = new std::thread(ThreadFunc)</code> ?</p>
|
How do I convert string hex representation to byte ? - javascript <p>My problem consists of stream of bytes or array of bytes.
This is no problem with these</p>
<pre><code>'\u0000'
'\u0000'
'\u0001'
'\u0010'
</code></pre>
<p>But the problem lies when i decode some special characters as this</p>
<pre><code>'\u0000'
... | <p>I'm not sure I've understood your question correctly but sounds like you want to convert an array of strings which represent hex bytes into a number. </p>
<p>If you've got a string representation of hex numbers you could convert them using something like:</p>
<pre><code>function bufferToInt(buff) {
var string ... |
excel formula copying value with 0 string <p>i have a cell A, B, and C.</p>
<p>A=16</p>
<p>B=01</p>
<p>C=0001</p>
<p>my question is i want a value of the cell D is like this D = 16-01-0001.</p>
<p>Note cell D is dynamic sometimes in cell D the value is 0021 or 0321 . .</p>
| <p>Just concatenate the strings from the cells with the "-" text string. The concatenation operator is the ampersand sign <code>&</code></p>
<pre><code>Sub test()
Range("D1") = Range("A1") & "-" & Range("B1") & "-" & Range("C1")
End Sub
</code></pre>
<p>Or use a formula instead of VBA:</p>
<pre... |
dropzone in a form - InvalidAuthenticityToken <p>I am using drop zone as part of a form. ie. the form has other elements apart from just the dropzone field. Also, no new view is loaded after form submission, just some js code so remote = true. The form looks like this: </p>
<pre><code><%= form_tag submit_form_path... | <p>try adding the header to your Dropzone request</p>
<pre><code>Dropzone.options.myDropzone = {
url: '/submit_form',
autoProcessQueue: false,
...
headers: {
'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
}
}
</code></pre>
|
Scala: Convert xml dataframe to csv file <p>Using Scala and IntelliJ,</p>
<p>I have an xml file and I have written it to a dataframe as shown below: </p>
<pre><code>var dftest = spark.read.format("com.databricks.spark.xml").option("rowTag","transferBatch").load(file)
</code></pre>
<p>The schema is long and has many ... | <p>Please take a look at Spark-csv library from Databricks:</p>
<p>Here is a simple example:</p>
<pre><code>mydf.write.
format("com.databricks.spark.csv").
option("header", "true").
save("out.csv")
</code></pre>
<p>You can find it here:
<a href="https://mvnrepository.com/artifact/com.databricks/spark-csv... |
UnsafeMutablePointer initialization <pre><code>1. let context = CGContext(...)
2. context.draw(...)
3. let buffer = UnsafeMutablePointer<UInt32>(context.data) // error here
</code></pre>
<p>Using Swift 3, line 3 produces an error that says: </p>
<pre><code>Cannot invoke initializer for type 'UnsafeMutablePoi... | <p>I guess this will do the initialization.</p>
<pre><code> let ptr = context.data
let data = ptr!.assumingMemoryBound(to: UnsafeMutablePointer<UInt32>.self).pointee
let pixelBuffer = UnsafeMutablePointer<UInt32>(data)
</code></pre>
|
How to retrieve particular data from xml file using c# <p>As a part of functional testing of my Api, I want to scrap the "body" part of given xml using C#. How can I do that? </p>
<p>This is my xml file</p>
<pre><code><Root>
<collection> </collection>
<run>
<stats> </stats... | <p>First Load the Your xml in XmlDocument object and than using <code>GetElementsByTagName("body")</code> you can get the Node say body </p>
<pre><code>XmlDocument _LocalInfo_Xml = new XmlDocument();
_LocalInfo_Xml.Load(_LocalInfo_Path);
XmlElement _XmlElement;
_XmlElement = _LocalInfo_Xml.GetElementsByTagName("body")... |
What's is BOOST_LOG_DOXYGEN_PASS for in Boost.Log? <p>There're some strange code in Boost.Log library, for example in BoostFileLogging.cpp, it says</p>
<pre><code>#ifndef BOOST_LOG_DOXYGEN_PASS
#define BOOST_LOG_INIT_LOG_TO_FILE_INTERNAL(z, n, data)\
template< BOOST_PP_ENUM_PARAMS(n, typename T) >\
inli... | <p>Doxygen is a program that parses source code and generates documentation.</p>
<p>The purpose of this is so that Doxygen sees (and documents) something different from what the real compiler sees.</p>
<p>In this case, Doxygen will see a variadic template, and so the HTML documentation will say something like this:</... |
VBA code cannot run in shared workbook <p>Just a concern regarding shared workbooks. I have a script that moves a certain row to the appropriate sheet based on cell values. </p>
<p>When I copy the row, the format is usually pasted in unshared workbooks.</p>
<p>However, in shared workbooks, formats are completely igno... | <p>Shared workbooks have limitations. The biggest one is that they can become corrupt at any time and are impossible to troubleshoot because their behaviour is not consistent. </p>
<p>Avoid shared workbooks. </p>
|
Bitwise Operators <p>I'm new here but had some questions about my Computing 2 HW.</p>
<p>Given the main function:</p>
<pre><code>void set_flag(int* flag_holder, int flag_position);
int check_flag(int flag_holder, int flag_position);
int main(int argc, char* argv[])
{
int flag_holder = 0;
int i;
set_flag(... | <p>Let me tell you the similarity between multiplication and bitwise</p>
<p>left shift & right shift are used to set flags mostly </p>
<pre><code>2 = 0010
</code></pre>
<p>when you left shit 2 by 1, all the bits are shifted to left and with zero appended.</p>
<pre><code>0010 << 1
0100
</code></pre>
<p... |
Passing ArrayList<String> from ActivityA to ActivityB <p>I am making the following app for my school assignment. It is a simple Pizza app, which asks the user to select which topping they would like on their pizza. I ask the user to select the toppings they want by check-boxes. Once the user selects the toppings and cl... | <p>To pass <code>ArrayList</code> to another Activity:</p>
<pre><code>Intent i = new Intent(TanavActivityAd1.this,TanavActivityOrder.class);
i.putExtra("Choice", topping);
startActivity(i);
</code></pre>
<p>get <code>Arraylist</code> in another Activity:</p>
<pre><code>ArrayList<String> toppings = (ArrayList&l... |
Passing variable from URL + Selecting from SQL and Echoing it <p>Title is a little hard to understand, so basically I'm making a Pastebin clone and am attempting to do a kind of viewmember.php?id=1213 thing for viewing pastes. However, I can't figure it out at all. I've done a lot of research, and after finally underst... | <p>You need to run the command to execute the query.</p>
<pre><code>$sql = "SELECT field1, field2 FROM pasteinfo WHERE id = ?"; // Specify fields in query
$stmt->bind_param("i", $getid); /* bind parameters for markers */
$stmt->execute(); /* execute query */
$stmt->bind_result($field1, $field2); /* bind res... |
"[AppName] has stopped" in my physical device. ERROR in logcat: java.lang.NullPointerException <p>I have been working on a game in android studio and libgdx and whenever I run it on my physical device it says "[AppName] has stopped". </p>
<p>I have checked for the names of the images that i used (spelling, capitalizat... | <p>You have not set "title" to anything yet. You have only declared it to exist.
title is set in show() which is called after the constructor.
You need to do </p>
<pre><code>title = new Texture ("BGASTRO.png");
</code></pre>
<p>BEFORE you try to get the height of the texture. This goes for all other variables too, ma... |
refreshing previous activity in current activity <p>Let "<strong>A</strong>" be the first activity where am getting a response from server and saved in shared preference/(using intent) and then send to second activity "<strong>B</strong>" and showing a values in textview. Now my question is , is it possible to refresh... | <p>what you are going to do is not a good practice. when you go the second activity the first activity is stopped.</p>
<p>you'd better have a third class to handle your network stuff and then access that third class from wherever and whenever you want.</p>
|
String keeps getting reset to null <p>I'm writing this code that should let me add an student to a fictional DB, everything is working fine but the <code>setMail</code>.</p>
<p>If I run the code from main, when I reach the mail section, after I write mail and select mail service (@gmail, @hotmail, etc) and I press ace... | <p>Calling RegistroEstudiante.setCorreo() from Correos.java seems to happen on a different thread (AWT) than the do-while loop (main), thus the correo field is not getting updated. With some Thread.currentThread() calls added to your code the log printout is the following</p>
<pre><code>En RegistroEstudiante.java null... |
Not able to insert data into SQL Server 2014 using Asp.net MVC4 <p>I am totally new in .net, I tried to follow following link tutorial</p>
<p><a href="https://www.youtube.com/watch?v=WLD6DvLI35Y&list=PLx7nFxMa-ZcIz2VBKC8FyMjQNmlIvrAi9" rel="nofollow">https://www.youtube.com/watch?v=WLD6DvLI35Y&list=PLx7nFxMa-Z... | <p>I haven't tested it but I think you need a space between SELECT and @@Identity here:
<code>String query = sql + ";SELECT@@Identity;";</code></p>
<p>I think you're getting the 0 from the catch block inside the DataInsert method. </p>
<p>Also, you're executing the query twice; remove <code>cmd.ExecuteNonQuery();</co... |
Rails & Mailgun: emails not sending <p>I have an app that sends out email notifications. Some users have mentioned they are not receiving notifications.</p>
<p>NotificationMailer.rb:</p>
<pre><code> def send_daily_digest(user_id)
@user = User.find(user_id)
mail(to: @user.email, subject: "#{@jobs.count} n... | <p>/config/environments/development.rb</p>
<pre><code> config.action_mailer.raise_delivery_errors = false
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:authentication => :plain,
:addr... |
Play Framework Authentication in a single page app <p>I am trying to add authentication to my Play Framework single page app.</p>
<p>What I would like to have is something like:</p>
<pre><code>def unsecured = Action {
Ok("This action is not secured")
}
def secured = AuthorizedAction {
// get the authenticate... | <p>The simplest way in my opinion is to go with <code>ActionBuilder</code>. You can define an action builder as a class (and pass it some dependencies) or as an object.</p>
<p>First you'll need to define a type a request that will contain the information about the user:</p>
<pre><code>// You can add other useful info... |
How can i completly destroy session. if session not availbale redirect to login page <p>Hello i am trying to destory session when i press signout button then it's logging out and redirecting to login page; but <code>when click back in browser that page is loading with loign menu on top.</code></p>
<p>And i have wrote ... | <pre><code><?php
session_start();
if($_SESSION['id']){
unset($_SESSION['id']); // destroys the specified session.
}
header('Location:index.php'); //redirect to preferred page after unset the session
?>
</code></pre>
|
Coffeescript invalid syntax <p>Thoughts on why the following is invalid syntactically?</p>
<pre><code>@foo(@bar('/test', {
password
username
_method: 'GET'
}
)
)
</code></pre>
| <p>The problem is the indentation.</p>
<p>The second parenthesis couldn't be read properly.
If you make an indent explicitly for it, it work.</p>
<pre><code>@foo(
@bar('/test', {
password
username
_method: 'GET'
}
)
)
</code></pre>
<p>Or remove indentation of the closing parenthesis.</p>
<... |
Ctrl-S in console not working. It seems to be waiting on input <p>I'm trying to make a console application in C#. When using <code>Console.ReadKey</code> and typing <kbd>Ctrl + S</kbd> the application seems to be "waiting" on another keypress because the next key I type also gets eaten.</p>
<p>How can I prevent this f... | <p>After some digging the only way I could figure out how to do this is to call some native methods to disable <code>ENABLE_LINE_INPUT</code>. I don't know why this works because the docs for <code>ENABLE_LINE_INPUT</code> say:</p>
<blockquote>
<p>The ReadFile or ReadConsole function returns only when a carriage ret... |
How to concatenate values inside two arrays in Ruby <p>Say I have the following two arrays:</p>
<pre><code>a = [1, 0, 2, 1, 6]
b = [0, 5, 5, 6, 1]
</code></pre>
<p>I want to create (or modify a or b) an array with the <em>values</em> inside each relative index of the array to be added together, like:</p>
<pre><code>... | <p>You could <code>zip</code> and then use <code>reduce</code>:</p>
<pre><code>p a.zip(b).map{|v| v.reduce(:+) }
#=> [1, 5, 7, 7, 7]
</code></pre>
<p>Or, if you're sure that array <code>a</code> and <code>b</code> will always be of equal length:</p>
<pre><code>p a.map.with_index { |v, i| v + b[i] }
#=> [1, 5, ... |
VkKeyScanEx not working on "F" keys and others <p>Right now I'm grabbing the string of an entry from a QKeySequence object and converting it into a keycode.</p>
<p>Problem is that it doesn't work anything that has more than 1 character, (f1-12/delete/end/etc.).</p>
<pre><code> QString keys = uiPtr->keySequenceE... | <p>qUtf16Printable returns:"Returns str as a const ushort *, but cast to a const wchar_t * to avoid warnings"</p>
<p>But in your code you are not assigning the return value to a pointer, the return value is assigned to a character (const wchar_t).</p>
<p>probably try</p>
<pre><code>const wchar_t* keyPtr = .........
... |
convert multi level Object values to string javascript <p>i have the following Object</p>
<pre><code>var myObject = {
first:{
key1:'value1',
key2:'value2',
key3:'value3',
key4:'value4',
},
second:{
key1:'value1',
key2:'value2',
key3:'value3',
},
... | <p>You can use <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys" rel="nofollow"><code>Object.keys</code></a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach" rel="nofollow"><code>Array#forEach</code></a> met... |
WxPython's ScrolledWindow element collapses to minimum size <p>I am using a Panel within a Frame to display images (the GUI need to switch between multiple panels and hence the hierarchy). As images should be displayed in native size I used ScrolledWindow as the panel parent. The scrolls do appear and work, but it caus... | <p>You're calling <code>Fit()</code>, so you're explicitly asking the panel to fit its contents, but you don't specify the min/best size of this contents anywhere (AFAICS, there is a lot of code here, so I could be missing something).</p>
<p>If you want to use some minimal size for the panel, just set it using <code>S... |
How do I call line or cv::line with OpenCV 3.1? <p>The tutorial I'm following has code like the following:</p>
<pre><code>line( img_matches, ..., ..., Scalar( 0, 255, 0), 4 );
</code></pre>
<p>where img_matches is just a Mat, the next two arguments are points and then there's a color and a width. I have figured out e... | <p>It's most likely you have not included the required header file. </p>
<p>Main header for opencv c++ api is in <code>opencv.hpp</code>, while the function you ask specifically (<code>cv::line</code>) is in <code>imgproc.hpp</code> (which is also included in most general <code>opencv.hpp</code>)</p>
|
Css many DIV with 100% height and width <p>I have three div. However, the third div cannot utilize the whole width 100% and height 100%. Can anyone tell me why? In the codepen, I have already highlighted the problems. Thanks a lot.</p>
<p><a href="http://codepen.io/anon/pen/VKyYRr" rel="nofollow">http://codepen.io/ano... | <p>You have this rule:</p>
<pre><code>.row > * {
padding: 0 0 0 40px;
}
</code></pre>
<p>That means every direct child of a <code>.row</code> has a right padding. Just set the padding to zero:</p>
<pre><code>#Word_wrapper {
padding: 0;
}
</code></pre>
<p>And you will have the whole width. To gain the hei... |
Overlay an opacified image with an icon <p>Basically what I'm trying to do is overlay an image with an icon (<code>display: none</code> at first), then add a hover effect to show up the icon and opacify the image. It doesn't work. </p>
<p>So is there any way to overlay an icon on top of an opacified image?</p>
<p>Exa... | <p>Basically you have to move the icon into the <code>.thumbnail</code> wrapper, to apply an effect on hover over <code>.thumbnail</code>. Then you just can set <code>display: block;</code> on hover and your icon appears.</p>
<p>You also need to give <code>.icon</code> a <a href="https://developer.mozilla.org/en-US/do... |
java try-with-resource not working with scala <p>In Scala application, am trying to read lines from a file using java nio try-with-resource construct.</p>
<p>Scala version 2.11.8<br>
Java version 1.8</p>
<pre><code>try(Stream<String> stream = Files.lines(Paths.get("somefile.txt"))){
stream.forEach(System.ou... | <p>There is no directly support for javas try-with-resources construct in scala, but your can pretty easy build your own support, by applying the loan pattern:</p>
<pre><code>import java.lang.AutoCloseable
import java.nio.file.{Files, Paths}
import java.util.Optional
def autoClose[A <: AutoCloseable,B](
cl... |
Is $fetched some implicit variable in Perl <p>I'm trying to analyze a CGI file written in Perl. I know that a variable declared in file A that uses/requires file B is available in file B as long as it's global. But please take a look at this piece of code:</p>
<pre class="lang-perl prettyprint-override"><code>sub make... | <p>Perl is seeing that you are using a variable named <code>%fetched</code> so it just goes ahead and creates one for you. This is behavior that is a hold over from the early days of Perl.</p>
<p>You should <code>use strict;</code> at the top of your file, and then declare <code>my %fetched;</code> near the top, sinc... |
Cropping UIImage by custom shape <p>I have a background UIImage, and I would like to crop the background UIImage with a custom shape so this background image only "appears" through the custom shape. For example, I have a moon-shaped custom shape, and I would like the background image to only come through on the moon-sh... | <p>On your background image you'll have to add a custom mask through <code>CALayer</code>.
Keep in mind, everything you color in the mask.png (moon) will be visible, everything <em>transparent</em> will not display.</p>
<pre><code>UIImage *moonImage = [UIImage imageNamed:@"mask.png"];
CALayer *maskLayer = [CALayer lay... |
Android: How to disable keyboard on webview for some specific page? <p>I have one <code>WebView</code> which has a <code>RelativeLayout</code> parent.
in <code>WebView</code> when i click on some specific button, it loads another url. i want to disable keyboard on that url. and that url i got in shouldoverrideurlloadin... | <p>Okey as you mention you want to hide keyboard for particular link, do something like this,</p>
<pre><code>public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.e("Loading URL", url);
view.loadUrl(url);
if(url.equals(yourUrl)){
// hide keyboard
} else {
// unhide k... |
How to create complex UI component (ex- seatmap) using NativeScript <p>I am working with Nativescript and while it's great to create interfaces with the provided UI components, I haven't found a way to implement custom components that can be used across platforms. </p>
<p>What is the proper way of implementing a compl... | <p>You can create <a href="https://docs.nativescript.org/ui/basics#custom-components" rel="nofollow">custom components</a> that can be reused in your application. Nice how-to blog on that matter can be found <a href="http://blog.bradleygore.com/2016/03/12/custom-nativescript-components/" rel="nofollow">here</a>.
The ar... |
Can we set image on imageview using Xcasset in Objective c? <p>I have imageview n view controller, whose size vary according to iphone size. I want to set height constant and width will be vary (framewidth).</p>
<pre><code>So I decided to keep differnt image in Xcassets of size
a) (320, 110) i.e framewidth of Iphone... | <p>At your Images.xcassets you can add the same image with all the 3 images sizes and than you just use it.</p>
<p>To export your images, and keep all organized, export all of them with this names:</p>
<pre><code>- image-name@.png
- image-name@2x.png
- image-name@3x.png
</code></pre>
<p>You can check this <a href="h... |
header, container, footer need to fit in any resolution without scroller <p>here is my <a href="https://jsfiddle.net/6upkcet8/" rel="nofollow">fiddle</a>, header, container, footer need to fit in any resolution without scroller or is there any way to do it without using fixed position</p>
<p><div class="snippet" data-... | <ol>
<li><p>Add this <a href="https://developer.mozilla.org/en-US/docs/Mobile/Viewport_meta_tag" rel="nofollow">viewport meta tag</a> inside the <code><head></code> tag:</p>
<pre><code><meta name="viewport" content="width=device-width">
</code></pre>
<p>This should make the page render at a reasonable siz... |
how can insert data into mongodb from android app? <p>I want to insert my json data into mongo database, i import mongo Driver v 3.2.2 and create a database , collection in mlab.com but i cant send data in database such an document.</p>
<p>this is my code :</p>
<pre><code>try {
MongoClientURI uri = new MongoClie... | <p>Your code was a little bit deprecated. I have adjusted it (used mongo-driver 3.2.2) and tested against my local mongo and it works fine:</p>
<pre><code>try {
MongoClientURI uri = new MongoClientURI("mongodb://localhost:27017/test");
MongoClient client = new MongoClient(uri);
MongoDatabase db = client.... |
Could not install package 'IEDriver 2.0.0' <p>I'm doing an UIAutomation Project in C# using Selenium. The automation is to be done in Internet Explorer. So I tried downloading IEDriver.exe from NuGet Package Manager but faced following error:</p>
<blockquote>
<p>Severity Code Description Project File Line ... | <p>If you look inside the IEDriver 2.0 NuGet package it just contains a single file: IEDriverServer.exe.</p>
<p>You cannot install this NuGet package into a project. It does not have any lib directories so NuGet will not be able to add it to your project.</p>
|
Count number of connected socket with socket.io <p>I am keeping track of the number of sockets connected using <code>socket.io</code>.</p>
<p>On the server, I have used the code</p>
<pre><code>let numClients = 0;
io.on('connection', (socket) => {
io.sockets.emit('number sockets', numClients++);
socket.on('di... | <p>There is a <a href="https://github.com/LearnBoost/socket.io/issues/463" rel="nofollow">github issue</a> for this. The problem is that whenever someone disconnects socket.io doesn't delete ( splice ) from the array, but simply sets the value to "null"</p>
<p>It's a mind buzz, why the people behind socket.io have lef... |
Undefined is not an object (evaluating 'value.phrase.replace') <p>My unit test keeps failing with the following error message:</p>
<pre><code>LOG: 'f40e0e47-6457-463b-a5f9-9dc97bd2d0ce'
LOG: [Object{phrase_id: 'f40e0e47-6457-463b-a5f9-9dc97bd2d0ce', phrase: 'Training {{group}} to develop their {{attribute}} by ensurin... | <p>You should check for null/undefined before trying to use the object e.g.</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>if(replacers!=undefined){
Object.keys(replacer... |
spree commerce adding product <p>I'm using spree commerce to a store. I want to keep the admin panel simple. </p>
<p>Ex : Admin can add product without the need of any properties and other things</p>
<p>As we will be displaying only the product name and the quantity in the storefront</p>
<p>Is this possible ? </p>
| <p>Yes it it, you don't have to add any properties for product. As i remember most important things for product are: name, available_on, price, shipping_category. And you have to have stock or do not track_inventory.
But remember when you are creating Product you also create master variant.
It is also nice to have a... |
JSTL loop by column index <p>How can I display the element in the array by using column index instead of calling the column name in JSTL.</p>
<p>Suppose I have a table:</p>
<pre><code>Column1 | Column2 | Column3 | Column4
--------------------------------------
| | |
| | ... | <p>If I understand correctly, you work on an array (you speak about column and index) so you can access it by index easily.</p>
<pre><code><td>${c[0]}</td>
<td>${c[1]}</td>
<td>${c[2]}</td>
<td>${c[3]}</td>
</code></pre>
<p>You can loop on it if you want like this:</p>
... |
Typescript Comments in bundled js-file <p>is there a way to add an important comment to the top of the bundled js-file in typescript.</p>
<p>i would like to add automaitcally a comment with the Version-information to the top of the js-file everytime it gets "compiled".</p>
<p>like: </p>
<pre><code>/*!
v 1.0.1.0
Git:... | <p>Yes, there are a set of "header" and "footer" tools. I'm using <a href="https://www.npmjs.com/package/gulp-header" rel="nofollow">gulp-header</a> and <a href="https://www.npmjs.com/package/gulp-footer" rel="nofollow">gulp-footer</a>. I beleive similar tools are existing for other build tools.</p>
|
Amount of decimal places and fixing column formating <p>Here is the problem I have to answer:
(Compare loans with various interest rates) Write a program that lets the user enter the loan amount and loan period in number of years and displays the monthly and total payments for each interest rate starting from 5% to 8%,... | <p>First of all, I please you not to use <code>Double</code> for working with money.</p>
<p>You can try do this to have only 2 digits after <code>,</code> : <code>System.out.printf("%.2f", yourNumber);</code></p>
|
Google storage bucket is public and still no access to files <p>I am creating a public bucket with nodeJS (apologise for the ES5/ES6 mix, copied Google's example were ES5):</p>
<pre><code> var gcloud = require('google-cloud');
const gcs = gcloud.storage({
projectId: 'h-212f6',
keyFilename: './h-9a8141296... | <p>When you set the ACL in your code above, you're setting it for existing objects. In order to set it as the default ACL for new objects, too, you need to do the following:</p>
<pre><code>bucket.acl.default.add({
entity: 'allUsers',
role: gcloud.storage.acl.READER_ROLE
}, function(err, aclObject) {
consol... |
C# putting datagridview date show in a datetimepicker <pre><code>private void dgw_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
try
{
DataGridViewRow dr = dgw.SelectedRows[0];
TextBox1.Text = dr.Cells[0].Value.ToString();
cmdproduct.Text = dr.Cells[1].Value.ToString()... | <pre><code> DateTime stockDate;
if (DateTime.TryParse(dr.Cells[4].Value.ToString(), out stockDate))
{
dateTimePicker1.Value = stockDate;
}
</code></pre>
|
Certificates and provisions for iOS build in {N} <p>I have followed steps mentioned at <a href="http://stackoverflow.com/a/21253261/6449750">this answer</a> for creating development certificate and provision profile. I am trying to implement FCM and running <strong>Nativescript</strong> application in real device. Foll... | <p>In tutorial he didn't check push notification in app id please ensure that in your app id you enabled Push notification as screenshot and has green circle </p>
<p><a href="https://i.stack.imgur.com/LfqOT.png" rel="nofollow"><img src="https://i.stack.imgur.com/LfqOT.png" alt="enter image description here"></a></p>
|
addEventListener useCapture support on mobile <p>It seems that the useCapture flag has a pretty good support on desktop browsers.</p>
<p>In this page: <a href="https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener" rel="nofollow">https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addE... | <p>After a little research, I concluded that it should work the same on those mobiles.</p>
<p>Chrome works the same on android: <a href="http://stackoverflow.com/questions/16944522/what-are-differences-between-chrome-on-android-and-desktop-chrome">What are differences between Chrome on Android and Desktop Chrome?</a><... |
How to check selected time is within the given time range in Javascript <p>I need to determine if the selected times (start time, end time) by the user is in the array of appointment times.</p>
<p>I get the appointment times from exchange web service and the output is :</p>
<pre><code>[{Status: "Busy", StartTime: "20... | <p>You can combine <a href="http://stackoverflow.com/questions/325933/determine-whether-two-date-ranges-overlap">this logic</a> with <a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/some" rel="nofollow"><code>Array.prototype.some</code></a></p>
<p><div class="snippet" data-l... |
When to use Javascript or Jquery to build web widgets <p>Say I'm trying to build a widget like Sumome or intercom.io. </p>
<p>Would both javascript and jquery do the job?</p>
<p>Is there any negativity to using Jquery for building a web widget that communicates with a rails server?</p>
| <p>if there is small content and not too much complex events required on DOM then use javascript. If there is more complex content and you want to make more manipulation with the data then use jquery.</p>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.