input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
Array of struct modify with pointer <p>I wanna function to modify each element of array of structure with pointer. </p>
<p>I am using two different size arrays </p>
<pre><code>struct color
{
char red;
char blue;
int white;
};
struct colorInit
{
char red;
char blue;
int white;
int pad... | <blockquote>
<p>am i using pointer right way in the function ?</p>
</blockquote>
<p>Syntactically speaking, yes.</p>
<p>The function will work fine if <code>ptr</code> points to an array of 30 or more objects. Otherwise, it will have undefined behavior.</p>
<p>The following is not valid any more since the OP chang... |
onClick function doesn't bind in reactjs <p>I'm a newbie to reactjs and using click handler to show/hide some div's in my webpage. The onClick method of button doesn't call the required function.
Here is a snippet of the code.</p>
<pre><code> showPartsInfo: function(e){
console.log(e+" here in parts ");
... | <p>Inside your <code>.map</code> function, you're creating a function, so you're executing all the code inside the scope of that function. So, <code>this.showPartsInfo</code> doesn't exist, because <code>this</code> is pointing to the function itself.</p>
<p>You have to bind that function to the component context, usi... |
Where Clause on Compound Index Produces "not indexed" Error <p>I have the following table schema:</p>
<pre><code>db.version(1).stores({
sales: "[item_id+date],sales"
});
</code></pre>
<p>Where the combination of <code>date</code> and <code>item_id</code> must be unique. How can I get all the records for a given <... | <pre><code>db.sales.where('[item_id+date]').between ([some_item_id, -Infinity], [some_item_id, Dexie.maxKey])
</code></pre>
|
The levenberg-marquardt method for solving non-linear equations <p>I tried implement the levenberg-marquardt method for solving non-linear equations on Julia based on <a href="http://mads.lanl.gov/presentations/Leif_LM_presentation_m.pdf" rel="nofollow">Numerical Optimization using the
Levenberg-Marquardt Algorithm</a... | <p>I have at the moment no way to test this, but one line does not make sense mathematically:</p>
<p>In the computation of <code>Xnew</code> it should be either <code>inv(G)*dC</code> or <code>G\dC</code>, but not a mix of both. Preferably the second, since the solution of a linear system does not require the computat... |
FreeLibraryAndExitThread crashes program when unloading injected DLL <p>I am writing a DLL that gets injected into a game in order to play around with some reverse engineering. For a while I was able to successfully inject, eject and reinject as I made changes to the program. I'm using <code>FreeLibraryAndExitThread</c... | <p>Here's the solution:</p>
<p>The problem was that invoking <code>XInputGetState</code> caused my DLL to automatically load <code>XINPUT1_4.dll</code>, and when I called FreeLibraryAndExitThread, my DLL unloading forced the XInput DLL to unload as well. Code within the program (probably from a thread in XInput 1.4) a... |
document.getElementById doesn't retrieve an element that actually exists <p>Here is the DOM that clearly contains an input with id=<code>RESULT_TextField-11</code>:
<a href="http://i.stack.imgur.com/lhXgU.png" rel="nofollow"><img src="http://i.stack.imgur.com/lhXgU.png" alt="enter image description here"></a></p>
<p>B... | <p>The input can't be found because it's within an iFrame. You would have to target it with something like this instead:</p>
<pre><code>document.getElementById('frame-one997541297').contentWindow.document.getElementById('RESULT_TextField-11')
</code></pre>
<p>However, that won't work either because the iFrame is load... |
What is a delimiter in this chomp function? <p>I am trying to understand what the following code does</p>
<pre><code>void chomp (char* string, char delim) {
size_t len = strlen (string);
if (len == 0) return;
char* nlpos = string + len - 1;
if (*nlpos == delim) *nlpos = '\0';
}
</code></pre>
<p>... | <p>If the last character of the string matches delim, then that characters position in the string (*nlpos) is assigned a zero byte, which effectively terminates the C string one position closer to the beginning of the string.</p>
<p>I <em>think</em> that the term chomp became popular with Perl that often trimmed off t... |
Restore purchase using com.logicallabs.inappproducts <p>How do you restore a purchase using: com.logicallabs.inappproducts? I have been messing around with this all afternoon. I can purchase a product and restore it as if I were to buy it again, but can't figure out how to directly restore it.</p>
| <p>You can get a list of purchased products with this:</p>
<pre><code>InAppProducts.addEventListener('receivedPurchases', function(e) {
e.purchases.forEach(...
});
InAppProducts.getPurchases();
</code></pre>
<p>Then when you find the product you're trying to restore, execute the same code that calls when you purc... |
MySQL: Duplicate entry for key (Formerly "What does 'idx' mean?") <p>Update: After a lot of painful research, I've discovered what the problem actually is and updated the title to make a little more sense. I'll put my answer below.</p>
<p>Unfortunately, I'm not able to copy the query that's giving me this problem bec... | <p>"idx_" is a common prefix for index names.</p>
<p>You many have an index that does not allow duplicate values for the column values referenced by that index.</p>
|
Python index out of range when missing user user input <p>I know this is a simple fix--but I can't for the life of me figure out how to fix this IndexError. </p>
<pre><code>def show_status():
print("\nThis is the " + rooms[current_room]["name"])
rooms = {
1 : { "name" : "Highway" ,
"west... | <p><code>move[0]</code> checks for the first member of the list, and will throw an <code>IndexError</code> if <code>move</code> is an empty, as when the user simply presses enter. You can check that <code>move</code> is true first: if it isn't, the <code>and</code> operator will circumvent the next check.</p>
<p>It se... |
Java TCP File Transfer Only Complete On First Attempt <p>Despite hours of researching this problem, I have made very little progress. According to my professor, the code should be working as written...</p>
<p>I have a server that stays open, and a client that requests a file. Once the client receives the file, the cli... | <p>It's worth checking, in your server code, what value comes back from the file <code>read()</code> call, so:</p>
<pre><code>int bytesRead = bis.read(byteArray, 0, byteArray.length);
System.out.println("File bytes read: " + bytesRead + " from file size: " + myFile.length());
</code></pre>
<p>The <code>read()</code>... |
ng-bind not updating, only after refreshing the page <p>Using <code>$resource</code> to get the data, the pages have the data from the previous page until I refresh it. I've read that it's because angular itself doesn't know that it's been updated. However even after using $watch and <code>$applyAsync</code>, it doesn'... | <p>Your code looks good to me, so I think this is a routing issue. Maybe you could try resolving the resource in the router and not in the controller. <a href="https://github.com/angular-ui/ui-router/wiki#resolve" rel="nofollow">https://github.com/angular-ui/ui-router/wiki#resolve</a></p>
<p>I would also try assigning... |
Angular2 application with NodeJS not loading everything <p>I'm experimenting with Angular2 and, with the quick start guide on their official documentation, I'm definitely up and running. However, if I want to do any APIs on the server or host it on the cloud it seems I'll need to use Node. I think I have everything set... | <p>When you are telling express where to look for the static files, you have to include where your js files will be as well.</p>
<p>For example, in one of my projects I have it like so</p>
<pre><code>app.use('/css', express.static(path.resolve(appPath, 'css')));
app.use('/lib/css', express.static(path.resolve(appPath... |
Subquery returned more than 1 value with insert from XML <p>This is a portion of a much larger stored procedure, but before I can get going I have to first parse XML, extract the attributes, and insert them into a temp table. Then I will use that table to perform functions later on.</p>
<p>When I try to insert into th... | <p>Try this code to fetch the data from the XML :</p>
<pre><code>SELECT
FirstName = xc.value('@FirstName', 'varchar(50)'),
LastName = xc.value('@LastName', 'varchar(50)'),
Email = xc.value('@Email', 'varchar(50)'),
Date = xc.value('@Date', 'varchar(50)')
FROM
@MESSAGELIST.nodes('/object/Record') AS... |
Why is python adding "ï £" to my filenames when decrypting AES? <p>I'm not running into any error just the output for my program is doing something strange. I've also noticed this thread here: <a href="http://stackoverflow.com/questions/30070309/encrypt-file-with-aes-256-and-decrypt-file-to-its-original-format">Encrypt... | <p>Let's read the <a href="https://docs.python.org/2/library/stdtypes.html#bltin-file-objects" rel="nofollow">documentation</a> (emphasis mine):</p>
<blockquote>
<pre><code>file.readline([size])
</code></pre>
<p>Read one entire line from the file. <strong><em>A trailing newline character is kept in the string (bu... |
WebView Client Not Allowing to Open SAPUI5 Projects with MVC, But opens on Browser(SAPUI5) <p>I am unable to get a WebView to load an URL(Containing SAPUI5 Resources and hosted on Github Pages). The URL is a Public URL and loads perfectly in the browser.(Also loads in the Android Chrome Browser).</p>
<p>But, when i pu... | <p>You can try that:</p>
<pre><code>private void openWeb(String url) {
mWebView.setWebViewClient(new WebViewClient());
mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int progress) {
Log.d(TAG, "Progress =... |
Error 0x6700 in securechannel.processSecurity(apdu) <p>I want to generate gp secure channel 01. my trace is:</p>
<pre><code>Send: 80 50 00 00 08 00 00 00 00 00 00 00 00
Recv: 00 00 00 00 00 00 00 00 00 00 FF 02 00 02 0E 5A 8F F4 57 DD 35 5C 49 A6 8B 15 E9 A5 9000
</code></pre>
<p>so I have :</p>
<pre><code>Card chal... | <p>According to the <a href="http://www.globalplatform.org/specificationscard.asp" rel="nofollow">GlobalPlatform specification</a>, the EXTERNAL AUTHENTICATE command has to include the host cryptogram as well as the MAC. Both are 8 bytes long, hence, your command should be 16 bytes in total. </p>
<p>If you want to imp... |
Looping through multiple instances in source code? <p>I'm trying to pull out information from some source code.</p>
<p>view-source:<a href="http://www.championcounter.com/mordekaiser" rel="nofollow">http://www.championcounter.com/mordekaiser</a></p>
<p>There are multiple occurrences of something like this:</p>
<p>al... | <p>You're going to have a much easier time if you first use a regular expression to pull out all the "counters" info, like this (warning, this is Swift 2.2, not Swift 3):</p>
<pre><code>let pattern = "alt=\".*?\""
let s = // source of the page
let exp = try! NSRegularExpression(pattern: pattern, options: [])
let res =... |
Turing Logarithmic Function <p>I was wondering if Turing had a logarithmic function and what it was. If not, I was wondering how I could create my own logarithmic function without a table look up or brute force if it is possible. Thanks in advance. </p>
| <p>Turns out there is no way to do it. Better off using brute force.</p>
|
traversing folders, several subfolders for the files in python <p>I've a folder structure similar to what's outlined below.</p>
<pre><code>Path
|
|
+----SubDir1
| |
| +---SubDir1A
| | |
| | |----- FileA.0001.ext
| | |----- ...
| | |----- ...
| | |... | <p>Your issue is actually those two lines, remove them and you sould be fine:</p>
<pre><code>if len(subdirList) > 0:
del subdirList[0]
</code></pre>
<p><strong>Explanation</strong> : </p>
<p>What they do is <strong>they make the first subdirectory inside each directory disappear before <code>os.walk</code> ha... |
How can I manipulate a website based on input from an android application? <p>I would like to make an app where when a certain action is preformed the person who downloaded the app can get money sent to them in the form of a gift card or pay pal. What I don't know is how to get the android app to preform that action. I... | <p>Basically, what you need to get this working is to use an application programming interface (API). An API lets your program communicate with other programs such as PayPal. Your app will ask for PayPal for some data (perhaps an account number to send the money to) and PayPal will send a response. This response will e... |
How to get both exceptions if a child object and a parent object have an exception thrown <p>In C#, if a child object has try catch block of code, and a parent object also has a try catch block of code, if the child object throws an exception, how can I get the details for both of the exceptions?</p>
<p>Here is the ex... | <p>Typically, the parent object will throw the exception with the child exception in the InnerException. InnerExceptions can have InnerExceptions, so you can go all the way down to the root cause.</p>
<p>EDIT:</p>
<p>The pattern looks like:</p>
<pre><code>void SomeMethod()
{
try
{
}
catch (Exception e)
... |
C++ If statement causes CMD to not post output? <p>I made a BMI calc in C++, and decided I'd want to add a portion that calculates a users new BMI given a weight change weekly(say, losing 2 pounds every week, or gaining 2 pounds every week, for n weeks) I have two if statements set up, so that when asked what weight ch... | <p>Big problem with PosBMI being declared and initialized then immediately overwritten by std::cin call. Analogous problem in NegBMI.</p>
<pre><code>double PosBMI = (weight + GoalWeight) * 703 / (pow(HeightConverter, 2));
cin >> PosBMI;
</code></pre>
<p>Then of course, weight is not declared... I think that yo... |
No match for operator<< in C++ <p>I am just learning C++ and I am getting the following error message and I'm not sure what is causing it or how to fix it:</p>
<pre><code>error: no match for operator<< (operand types are std::istream, std::basic_istream<char> and char)
cin << grade;
</code></pre>
<p... | <p>This doesn't look correct:</p>
<pre><code>cin << grade;
</code></pre>
<p>The <code>cin</code> is an input stream not an output stream.</p>
<p>You have a correct version here: </p>
<pre><code> cin >> hours;
</code></pre>
|
Contextual type 'NSObject' cannot be used with dictionary literal <p>I have a method that resets the password of a user, and I'm making this request asynchronously. The line that throws this error is the following:</p>
<pre><code>authController.resetPasswordAsyncWithEmail(["email": email]) { (success, context, _, erro... | <p>Had to change the lingo of the method a bit and cast the dictionary as NSObject like so:</p>
<pre><code>authController.resetPasswordAsync(withEmail: ["email": email] as NSObject!) { (success, context, _, error) -> Void in
</code></pre>
|
How to make image stay after resizing? <p>I'm new to Java, and I'm trying to figure out how to make sure my image stays on the screen after resizing the window. I've tried looking for the answer before posting, but I can't seem to find what I'm looking for. </p>
<p>What is the best way to do this would be and how I sh... | <p>To get the image to stay:</p>
<ul>
<li>Don't use a Graphics object obtained by calling <code>getGraphics()</code> on a Swing component. These objects are short-lived and risk causing disappearing images or NullPointerExceptions.</li>
<li>Instead draw with the Graphics object given by the JVM to your JPanel's paintC... |
dynamic options in select2 after click in some button <p>I'm using <a href="https://select2.github.io/" rel="nofollow">Select2</a> in my website and I need to reload (change) the options in the select with new ones after some user interaction.</p>
<p>I have this:</p>
<p><a href="http://i.stack.imgur.com/3CYL1.png" re... | <p>I found <a href="http://stackoverflow.com/questions/13240047/clear-dropdown-using-jquery-select2">this question</a> from a few years ago, and one answer suggests calling <code>.html('')</code> on the element before adding the new data options...</p>
<p>Try this:</p>
<p><div class="snippet" data-lang="js" data-hide... |
creating a loop to convert rolling date periods to as.Date <p>I'm new to R, but have been following a pretty good guide to help along the way. </p>
<p>I've imported sales data for the past 36 months, used tidyr to move the Date columns to rows, and then cleaned the Date character string to a Month Date, Year.</p>
<p>... | <p>It seems you are only looking at the first part of your rolling date to determine the representative date (the date you are replacing).
In that case you could take advantage of backreferences in replacement when using gsub and regular expression</p>
<pre><code># Function might not be need now
clean <- function... |
How can I properly setup my controller? 'Cannot set property 'values' of undefined' <p>I want a particular div to have access to the 'values' object inside my 'WorkHistoryController' controller:</p>
<pre><code><div id="container1" ng-controller="WorkHistoryController">
<h3 id="tree-title">{{values.nam... | <p>inject <code>$scope</code></p>
<blockquote>
<p>WorkHistoryController.$inject = ['$scope'];</p>
</blockquote>
|
Django. Access the foreign key fields in the template from a form object <p>I use Django 1.8.14. I have two models:</p>
<pre><code>class Event(models.Model):
title = models.CharField(max_length=255,)
date = models.DateTimeField()
...
def __unicode__(self):
return self.title
class Card(models.Mo... | <p>I've found a solution.</p>
<pre><code>class CardForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(CardForm, self).__init__(*args, **kwargs)
self.fields['event'].label_from_instance = lambda obj: "%s %s" % (obj.title, obj.date)
</code></pre>
|
Radio buttons selection on regular interval is not working <p>I want to automatically change the selection on radio buttons at regular interval. I'm calling setTimeOut in for loop after every 2000ms, but radio button selection is not changing with respect to the interval I've set.
Here's my code:
HTML:</p>
<pre><code>... | <p>In order to avoid running all 3 setTimeouts at once, use a global var for the counter instead of a for loop, and add the setTimeout to the end of the autoSlide() function.</p>
<pre><code>var n = 1;
function autoSlide(n) {
console.log(n);
document.getElementById("carousel"+n).checked = true;
if (n<3) {
... |
Handling null in RxJava2 <p>With the upcoming <a href="https://github.com/ReactiveX/RxJava/tree/2.x" rel="nofollow">RxJava2 release</a> one of the important changes is that <code>null</code> is no longer accepted as a stream element, i.e. following code will throw an exception: <code>Observable.just(null)</code></p>
<... | <p>Well, there are several ways to represent what you want.</p>
<p>One option is to use <code>Observable<Optional<CacheItem>></code>:</p>
<pre><code>Observable<Optiona<CacheItem>> getStream(final long id) {
return Observable.defer(() -> {
return Observable.just(Optional.ofNullable(fin... |
Inserting into database gives me "localhost not working" <p>I'm trying to insert information into database through two inputs when you click a submit button. But when I click it it says it can't connect to localhost (everything else works so I know it has to be some form of syntax problem) Code:</p>
<pre><code> <... | <blockquote>
<p><em>GOT IT WORKING.. all that was the problem was the "=" that @Fred-ii- mentioned.. â Chumppe</em></p>
</blockquote>
<p>Posting as a community wiki. I don't want rep for this but just to close the question.</p>
<p><a href="http://stackoverflow.com/questions/39781490/inserting-into-database-gives-... |
Best strategy for caching GraphQL content with permissions and authorization <p>I am building a service using a GraphQL server.
It has sessions and user permissions as any other usual services.
For example, <code>{ viewer { friends { name } } }</code> will look different for each user session.</p>
<p>What is the best ... | <p>If you're runing <code>graphql</code> on javascript, you can use Facebook's powerfull utility <code>Dataloader</code>
<a href="https://github.com/facebook/dataloader" rel="nofollow">https://github.com/facebook/dataloader</a></p>
<p>It can cache and batch your queries.</p>
<p>As for the caching session queries, <c... |
Translating a function that styles a div based on mouse movement from jQuery to Angular makes coordinates spazz out <p>Here is a <a href="https://jsfiddle.net/2Radon/w1qxp4um/" rel="nofollow">JSFiddle of the function</a> I built some time ago in JQuery before I learned AngularJS for the project I intended to use it in.... | <p>Your math is off. Try <a href="http://plnkr.co/edit/wjH6uAqNa098SMI1mnTL?p=preview" rel="nofollow">this</a>. My math isn't exact but it's closer to what you're looking for</p>
<pre><code>angular.module('mouseMovement', [])
.controller('MouseMovementController', ['$scope', '$element', function MouseMovementCon... |
How do I access the RoamingState folder of an UWP when it calls my DLL? <p>I can't get C++ to work with the "ms-appdata:///roaming/" call to retrieve files</p>
<p>I am currently using cpp to write a Chinese Input Method Editor, and it is packaged as a dll.<br>
Therefore, when I make a call to ifstream to read my Setti... | <p>Use Windows::Storage::ApplicationData::RoamingFolder::Path property to get a full path to the roaming folder:</p>
<p><a href="https://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata.roamingfolder.aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/windows/apps/windows.storage... |
ExpressJS routing errors <p>I'm trying to create a collection of microservices. The problem is, my routes don't seem to redirect to the right place.</p>
<p>Here is my index.js file:</p>
<pre><code>var express = require("express");
var app = express();
var port = process.env.PORT || 3000;
var timestamp = require("./ro... | <p>Change the line <code>app.get("/timestamp", timestamp);</code> to <code>app.use("/timestamp", timestamp);</code>.</p>
<p>I think you intended mounting the timestamp Router <strong>middleware</strong> on <code>/timestamp</code> path, and not as a callback to a GET request which is what you are currently doing.</p>
|
why would THREE.ColladaLoader halt all activity on the site? <p>I am loading an animated .dae file, and I've used the 'onProgress' argument to see it's loading progress. The file loads to 74% in 2 seconds, but then the whole page is paused for 23 more seconds before the model actually loads (and all other activity paus... | <p>That is because JS is single theaded and once the file is loaded, what is asynchronous, it starts to parse it and creates everything, what is called a "blocking" process, because it uses the one thread which is available for JS until it is done. Afterwards your animation is resumed. While such a process is running, ... |
Factory class with abstractmethod <p>I've created a factory class called <code>FitFunction</code> that adds a whole bunch of stuff beyond what I've shown. The label method <code>pretty_string</code> is supposed to just return the string as written. When I run this file, it prints a string that is as useful as the <code... | <p>Use:</p>
<pre><code>print("Gaussian.pretty_string: %s" % Gaussian.pretty_string())
</code></pre>
<p>Or else you are printing the <code>repr</code> of the <em>method</em>, not the <em>result of calling the method</em>, which is the string you are looking for.</p>
|
How do I make Babel require the Babel-compiled Files? <p>If I have two files, let's call them A.js and B.js:</p>
<pre><code>/src/A.js
/src/B/B.js
</code></pre>
<p>A.js uses B.js via ES6 module syntax:</p>
<pre><code>import B from './B/B.js';
</code></pre>
<p>and B.js imports other stuff such as:</p>
<pre><code>imp... | <p>You don't need to rename any imports. Instead of compiling individual files, compile your whole source folder. This will preserve relative imports.</p>
<p>If your have</p>
<pre><code>src/
A.js
B.js
</code></pre>
<p>and run <code>babel src --out-dir lib</code>, you will get</p>
<pre><code>lib/
A.js
B.js
s... |
Passing an array from controller to view laravel using compact <p>I'm using laravel 5.3 (make:auth automatic register and user authentication generator), and I would like to let user choose their tags in the registration form.</p>
<p>I wanna pass <code>$tags = App\Tag::all();</code> to the <code>register.blade.php</co... | <p>Don't feed the variable itself, provide the variable name when using <code>compact</code>. </p>
<pre><code>return view('auth.register', compact('tags'));
</code></pre>
|
R nested for multiple if loops to generate new vector <p>I have 20 workers doing 100 tasks each. I have generated the true answer for each task, which is 1 out of 5 answers by</p>
<pre><code>answers <- c("liver", "blood", "lung", "brain", "heart")
truth <- sample(answers, no.tasks, replace = TRUE, prob = c(0.2, ... | <p>Consider initializing with a list that carries underlying character vector of 1,000 elements. </p>
<pre><code>df <- vector("list", 2000)
for (i in 1:nrow(dataSet)){
if (dataSet$truth[i] == "liver")
{
df[[i]] <-(rep(sample(answers, no.tasks, prob = c(0.9, 0.02, 0.02, 0.02, 0.02), no.workers)))
} else if (da... |
How Do I Link Multiple Buttons With Their Corresponding Labels While Using A Timer? (Visual Studios 2015) <p>I got an answer from a previous problem but it isn't quite right. I want <code>button1</code> to do the same thing as <code>button2</code> but, it isn't. I also want to know how I should add more buttons to the ... | <p>a <code>Button_click</code> is an event , in c# event are made to notify objects about any modification or something that happened to a specific object .
<p>the button is an object that has alot of events same as Click<br/>
so if you want your buttons to do the same event you can just listen to them all and make ON... |
How to highlight text in a JTextPane with setFocusable(false)? <p>So I have a <code>JTextPane</code> that basically serves as a console. I have it in the center field of a <code>JFrame</code> and a <code>JTextField</code> in the south field. The <code>JTextField</code> will take the text it has, and add it to the <code... | <blockquote>
<p>using setEditable(false) stopped any text from appearing on the JTextPane. </p>
</blockquote>
<p>You can make the <code>JTextPane</code> uneditable but you can't update the text via the text pane.</p>
<p>Instead you can update the text via the <code>Document</code>:</p>
<pre><code>//int len = pane.... |
CSS style sheets wont link <p>Linking my CSS style sheet stopped working all of a sudden?</p>
<p>The CSS file is one folder up. Plus I used the IDE auto fill feature to fill out the href.</p>
<p>Plus this is a practice file from Lynda.com</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="tru... | <p>Your error message from the server talks about <code>photogallery</code> with a lower-case <code>p</code>, yet your paths indicate <code>Photogallery</code> with an upper-case <code>P</code>. Which is it? You may have an issue with the way Windows distinguishes between upper case and lower case in paths, and/or how ... |
Google Maps API (JavaScript): Maps not showing <p>I'm obviously making a thing which is meant to show a Map.</p>
<p>Literally nothing happens - no Map, no Errors, no crash and burn.</p>
<p>Here is my code:</p>
<pre><code><div style="height:100%; width: 100%;">
<div id="map-canvas"></div>
</d... | <p>I would say you have two issues.</p>
<ol>
<li><p>your map div doesn't have a size (you don't specify the size of the containing element for the anonymous div <code><div style="height:100%; width: 100%;"></code>).</p></li>
<li><p>your <a href="https://developers.google.com/maps/documentation/javascript/referen... |
Move to next column after specific number of lines in python <p>If I have a data set that runs:<br>
1<br>
2<br>
3<br>
4<br>
5<br>
6<br>
from a python output, and i want:<br>
1 4<br>
2 5<br>
3 6<br>
basically after a specific number of lines, I would like to move the output into the next column, can this be done in P... | <pre><code>lines = ['1','2','3','4','5','6']
print(lines[:round(len(lines)/2)])
for i in range(round(len(lines)/2)):
print(lines[i] + lines[i + 3], sep=' ')
## 1 4
## 2 5
## 3 6
</code></pre>
<p>Anyways you are going to keep your file data in list. So I see that you are able to do it by your own. It is the f... |
Is it possible to write a function template which returns whether the number of arguments is divisible by N? <p>I've been learning about variadic templates, and with the help of <a href="http://eli.thegreenplace.net/2014/variadic-templates-in-c/">this excellent blog post</a>, I've managed to write a function template <... | <p>Yes, it's as simple as </p>
<pre><code>template<int N, typename... Ts>
constexpr bool number_of_args_divisible_by(Ts&&...)
{
return sizeof...(Ts) % N == 0;
}
</code></pre>
<p>Alternatively, you can return a more metaprogramming-friendly type:</p>
<pre><code>template<int N, typename... Ts>
... |
Using Java RMI, why does a remote method call yield the client's timezone instead of the server's? <p>I'm trying to grasp the basics of Java RMI. </p>
<p>The idea is to have two separate processes running, each primed by a separate main in one of two classes:</p>
<ul>
<li><code>Client</code> running as a client</li>
... | <p>Because <code>Document</code> is an exported remote object, it is running as a callback at the client. Not by copy at the server.</p>
<p>Remove the remote interface and <code>extends UnicastRemoteObject</code>, and make it serializable.</p>
|
Setting text size inside of a Button <p>I figured I could create a label, use setFont(new Font(...)), then create a button and use .getText() inside of the Button but it still looks like default fonts etc.</p>
<p>How would I correctly set the font of text inside of a Button?</p>
<pre><code>Label startLabel = new Labe... | <p>You need</p>
<pre><code>start = new Button("Start");
start.setFont(new Font(26));
</code></pre>
<p>You don't need to create a <code>Label</code> unless you actually need a <code>Label</code> in your UI.</p>
|
Remove a sentence starting with a word in R? <p>I have a tweet text like this in R. </p>
<pre><code>"RT @SportClipsUT125: #SavingLivesLooksGood with #RedCross. Donate this month &amp; Get free haircut cpn. https://somewebsite https://somewebsiteâ¦"
</code></pre>
<p>How can I remove all the links (to remove dupli... | <p>A simple solution is to change your gsub command:</p>
<p><strike><code>gsub("http[s]*://[[:alnum:]]*", "", test_str)</code> This will correctly remove URL's, both http and https versions</strike></p>
<p>@alistaire's suggestion in the comments actually works in more cases is more understandable <code>gsub('http\\S*... |
Modify multiple keys of dictionary by a mapping dictionary <p>I have 2 dict, one original and one for mapping the original one's key to another value simultaneously,for instance:</p>
<p><strong>original dict</strong></p>
<pre><code>built_dict={'China':{'deportivo-cuenca-u20':{'danny':'test1'}},
'Germany':... | <p>Well I have found a solution for this,the code:</p>
<pre><code>def club2team(built_dict,club_team_dict):
for row in built_dict:
# print test_dict[row]
for sub_row in built_dict[row].keys():
for key in club_team_dict:
# the key of club_team_dict must be a subset of test_dict,or you have t... |
Finding the Intersection of 2 sorted lists <p>I have an assignment for
Given two sorted lists of comparable items,
L1 and L2. You can assume that in L1 and
L2 all elements are different (no duplicates) but t
he interception between L1 and L2 may be
non-empty.</p>
<p>(b)
Implement an efficient method in
Java t... | <p>Well, think about this.
list1 {1, 2, 3, 5}
list2 {1, 5}.
As shmosel said, what happen if your loop runs twice? It exit the loop, and the function.
Ideally, you want to go through all elements on <strong>both array</strong>.<br/></p>
<p>BTW, I don't think your solution is working as well (you can of cause, but yo... |
How to declare a queried value and use it in CASE? <p>I want to convert the DOB into the number age, then assign the age value into different age groups on SQL Server. </p>
<p>I have found the way to do the first step, and the second step ideally I should set the first step's result as a variable and let it compare in... | <p>No, not in the <code>case</code> statement. The two traditional recommendations are to use CTEs or subqueries. But, SQL Server also supports <code>apply</code>:</p>
<pre><code>SELECT FirstName, LastName,
(CASE WHEN v.age <= 18 THEN 'Under 18'
WHEN v.age <= 30 THEN '19-30'
WH... |
When/Why Does Mutual Left Recursion Happen in Antlr? <p>I have an <code>expression</code> that is a collection of my other top-level things. In <code>expression</code> I have <code>math</code> that is <code>expression (op) expression</code>. With this I get </p>
<p><strong>The following sets of rules are mutually left... | <p>Antlr4 can handle direct left recursion, but not indirect left recursion, where a left recursive rule is defined as a rule that "either directly or indirectly invokes itself on the left edge of an alternative" (TDAR; pg 71).</p>
<p>When, as in the first example, the <code>#mathExpression</code> alternative is facto... |
How to change the form fields by clicking the button in REACT.js? <p>I have signup.jsx</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>import React from "react"
import { re... | <p>Try not to change props of own component after component has mounted. Instead use states.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>import React from "react"
import... |
Open Wifi Settings by "prefs:root=WIFI" failed in iOS 10 <p>I was using prefs:root=WIFI url scheme in my app with prefs entered in info.plist to open directly the iOS settings application in Wi-Fi settings and it was working great on iOS 9 but it does not work anymore on iOS 10.</p>
<p>Does anyone know if this is just... | <p>My app is also using that api. Unfortunately apple disable this on iOS 10. Here's my solution: below iOS 10, it can still open Setting App. on iOS 10, it will go to a subpage(Cellular Data access) of Setting App, you can back to setting page by one click. I decide to keep it. because it's still convenient than user ... |
Get files in drive with certain file size VB.NET <p>I am trying to create a program that will scan through your entire C drive and then have it add the items with a certain file size to a listbox! I've been trying at this thing for hours and I really need some help on it! I would really appreciate it if anyone could he... | <p>Try this:</p>
<pre><code>Private searchfilesVar As Long = 0
Private Sub searchF(dire As String)
Dim di As New IO.DirectoryInfo(dire)
Dim diar1 As IO.FileInfo() = di.GetFiles()
For Each f As IO.FileInfo In diar1
If f.Length > 3221225472 Then 'Length in bytes
sea... |
SQL subquery not producing correct results <p>I'm using MySQL 5.7.15</p>
<p><strong>I'm trying to get a list of all the business that match the where clause (near a certain location), for each business I need to get the picture with the most likes. Here is where it gets complicated, if the business has a plan type oth... | <p><a href="http://data.stackexchange.com/stackoverflow/query/546807/sql-subquery-not-producing-correct-results" rel="nofollow">This simple query</a>:</p>
<pre><code>SELECT
b.*
, bp.business_id
, bp.plan_type_id
, p.likes
, p.b_pic
, u.username
, u.picture_path
FROM business_plans AS bp
I... |
How to sort an array list of labels based on label text? JavaFX <p>I am attempting to sort an array list of Label elements with text that has the following format:</p>
<p>"1: Consult with [someone] @14:15"</p>
<p>I am aiming to sort the list via the time variable, specifically the hour between the @ and : . To do thi... | <p>Given that your <code>dailyConsults</code> is a <code>List<Label></code> you may consider:</p>
<pre><code> Collections.sort(dailyConsults, Comparator.comparingInt(label -> {
String s = label.getText();
s = s.substring(s.indexOf("@") +1);
return Integer.parseInt(s.substring(0, s.i... |
How can I compile SDL2 and GLEW applications statically on Linux? <p>I am attempting to compile an OpenGl application that uses SDL2 and GLEW in such a way that it will run on any version of Linux it may find itself -- not just where it was originally compiled. To do this, I have tried several things none of which work... | <p>Older Loki games did full static linking. Probably not worth it anymore, and far more difficult if you use external libraries.</p>
<p>Libraries are often not self-sufficient, requiring other libraries, .... Dynamic library have dependency information built-in, but static library is just an archive of <code>.o</code... |
Why does PdfName.V validate the previous value? <p>I've been working with iText 7 to create pdfs, and it works really well, but I've come across an issue with form validation. The following code generates a pdf file with a simple text input box:</p>
<pre><code>import java.io.FileNotFoundException;
import com.itextpdf... | <p>I figured out the answer! Since this is a validation event, the current value must be retrieved with <code>event.value</code> and not the field value.</p>
<p>So the updated line of code from the question:</p>
<pre><code>setAdditionalAction(PdfName.V, PdfAction.createJavaScript("app.alert(event.value);"));
</code><... |
Automatically Run a Script in my Browser console after opening a link using Python <p>I want to run some JavaScript in my browser DevTools console. So far, I have opened up a specific website only through it. Can it be done in Python?</p>
<p>Right now, I am using the following code:</p>
<pre><code>url = 'http://some-... | <p>I don't belive this can be done, as </p>
<blockquote>
<p>ChromeDriver 2 and the DevTools windows both compete for the same
automation channel, and ChromeDriver automatically closes the DevTools
window in order for it to work.</p>
</blockquote>
<p>See here for more: <a href="http://stackoverflow.com/questions... |
How do I check if a character is neither a letter nor a digit in Java? <p>So I'm writing some code in Java and I'm trying to find out if there is a way to write a line of code that checks if a character in a string is neither a letter nor a digit. I know that:</p>
<p><code>Character.isDigit()</code> checks for a numbe... | <p><a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isLetterOrDigit(char)">Java provides a method for that</a> - all you need to do is to negate its result:</p>
<pre><code>if (!Character.isLetterOrDigit(ch)) {
...
}
</code></pre>
|
How can I center text in a div with viewport units? <p>When using pixel units, I can align text no problem. But with viewport units, I can't get anywhere. Here is my code.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snipp... | <p>Very simple with CSS flexbox:</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>#aboutMeTitle {
display: flex;
justify-content: center; /* center p horizontally */... |
Android Google Sheets API update() specific worksheet <p>I'm trying to use the Google Sheets API (v4) for Android, and I can't find how to use the <code>values().update()</code> or <code>batchUpdate()</code> methods to update <strong>a specific workbook</strong> of the sheet.</p>
<p>Does anyone know how to do this?</p... | <p>Be noted that the <a href="https://developers.google.com/sheets/guides/migration" rel="nofollow">v4 version</a> is JSON-based and often require you to specify a <a href="https://developers.google.com/sheets/guides/concepts#spreadsheet_id" rel="nofollow">spreadsheet ID</a> of the spreadsheet you are working with. The... |
webcomponent style applied all in safari and firefox using webcomponentsjs <p>I have two custom element:</p>
<pre><code><name-card data-color="#000000"></name-card>
<name-card data-color="#80B88C"></name-card>
</code></pre>
<p>which I will applied their <code>data-color</code> to the style.
Fr... | <p>This is due to the fact the polyfill cannot realize totally the css isolation.</p>
<p>So the CSS stylesheet that you add in a polyfilled Shadow DOM is in fact applied to the whole document. When the same name rule is used twice, the last one wins. That's why you observe this behaviour in Safari and Firefox.</p>
<p... |
What are the possible options to simv executable and what are their meaning? <p>What are possible arguments/options for the executable simv?</p>
<p>Indicating a reference document that I can download from the net would greatly help.</p>
| <p>The command line arguments for simv are available from <a href="http://solvnet.synopsys.com" rel="nofollow">Solvnet</a>. However you will need to have an account with Synopsys to get access to the document. The information is available as part of the VCS/VCSMX userguide.</p>
<p>I could not find a -h/--help equivale... |
Alloy-ui multiple datepicker send selection to other input <p>I have AlloyUi datepicker that is triggered by <code>div id="trigger"</code>, but I want to display the dates selected in the hidden <code>input id="dates"</code>.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="... | <p>You can copy the <code>#startdate</code> <code>value</code> attribute into the <code>#dates</code> <code>value</code> attribute <a href="http://yuilibrary.com/yui/docs/event/#after" rel="nofollow"><code>after</code></a> the date is clicked:</p>
<pre><code>after: {
dateClick: function(event) {
output.set... |
Dynamically add a new maven dependency? <p>I need to add a new maven dependency to my maven project when project is built by the continuous integration server, but the dependency should not be there when developers are building the project locally.</p>
<p>Is there a way to dynamically add the dependency through a mave... | <p>Using profiles is the best way for this kind of case </p>
<p>Here is the example to customize the dependencies inclusion</p>
<pre><code> <profiles>
<profile>
<id>profile-dev</id>
<dependencies>
<dependency>
depednency A
</dependency&... |
Batch file finding a filename which contains a substring <p>I want to write a batch file to find all .vsdm files and the file name must contain a substring "2.4". But my code is telling me that all my .vsdm files contains the substring "2.4" which is not correct.</p>
<pre><code>FOR /R %completepath% %%G IN (*.vsdm) DO... | <pre><code>If "%file%"=="%file:2.4=%" (
echo Filename "%file%" does NOT contain 2.4
) else (
echo Filename "%file%" contains 2.4
)
</code></pre>
<p>Including the filename in the <code>echo</code> may reveal more. I can see no reason for the double-negative approach. The way the code operates may depend on prec... |
php variable inside onclick function? <p>I have a php file in this i have to write html also instead of closing php tag every time i just use <code>echo 'html code';</code></p>
<p>So my code is like</p>
<pre><code><?php
$mid = 1;
echo '<div class="message_wrap"><span onclick="viewMessage(1)">Cl... | <p>It returns "Uncaught SyntaxError: Unexpected token }" error because the parameter you passed has space before it and "="" after ) because of that approach </p>
<p>to fix it change your </p>
<pre><code>echo '<div class="message_wrap"><span onclick="viewMessage("'.$mid.'")">Click</span></div>... |
Find which dependency in pom.xml include the specified jar <p>There are multiple modules in one web project and the project uses maven to manage the jars. I am curious that how to find which dependency in pom.xml the jar belongs to ? for example.
in ROOT.war/WEB-INF/lib/xxx.jar</p>
<p>I want to find the dependency A i... | <p><code>mvn dependency:tree</code> will print out a tree of how your dependencies are being resolved.</p>
<p>You can search that output for the jar you are interested in.</p>
<p><em>There's probably other ways to work it out, but I tend to just pick a small set of generally useful commands and rely on them for most ... |
BlackJack window program wont show up <p>I have assigned to write a basic BlackJack Window Program using JFrame and card images provided by my teacher. I wrote everything out from what I think should work however it doesn't show up at all when I compile it. Is am I missing something?</p>
<p>When I compile the program ... | <p>A. Analysis:</p>
<p>Lets start executing your code manually, your code's starting point is static void main where I can see MyFrame's object is being initialized. Then BlackJack's object is being initialized.</p>
<p>B. The problem:</p>
<ol>
<li>There is no MyFrame class you have declared in your code.</li>
<li>Bl... |
How to use Android webview to run javascript that depends on another library/module <p>We can run simple javascript function (jsCode) like:</p>
<pre><code>function() {
return "test"
}
</code></pre>
<p>in webview:</p>
<pre><code>String js = "(" + jsCode + ") ();"
mWebView.evaluateJavascript(js, new ValueCallback&l... | <p>I achieved this by evaluating the external javascript file before evaluating the jsCode</p>
<pre><code>private String[] jsFiles = {"external_lib.js", "main.js"};
private void evaluateJS() {
try {
String js = readFromAssets(jsFiles[fileIndex]);
Log.e(TAG, "evaluating: " + jsFiles[fil... |
How can I set priority on event flows in wso2cep? <p>Let's say, we have several event flows. Some of them loads reference data to hazelcast event tables and others are actual event processors.</p>
<p>My objective is, while wso2cep server starts up, it will first run those event flows which are loading reference data t... | <p>I can see no other option other than loading within in individual execution plans.
There are two options:</p>
<ol>
<li>Use trigger to load reference data periodically from RDBMS to Hazelcast. The actual process will use from Hazelcast table (This execution plan has been provided below)</li>
<li>Load from RDBMS and ... |
wxPython: Redirecting events on other widgets (TextCtrl) <p>The case study doesn't seem too hard to explain, but I guess TextCtrl in wxPython aren't often used in this way. So here it is: I have a simple window with two TextCtrls. One is an input widget (the user is supposed to enter commands there), the second is a... | <p>Give <code>self.input.EmulateKeyPress(e)</code> a try. If you're on Windows it should work fine. On other platforms it is not perfect, but basically works there too.</p>
<p>Other options would be to use <code>wx.UiActionSimulator</code>, or simply to append the new character to the input textctrl in your code.</p... |
how to filter between date in codeigniter <p>i have a problem , how to filter between date if i only have one column date in my table ?</p>
<p>this is my model </p>
<pre><code>public function filter_date ($first_date,$second_date) {
$this->db->where('tanggal >=',$first_date);
$this->db->where('tanggal... | <p>I still don't know which are your filter requirements but if you want to filter dates that are between a certain range e.g. 'tanggal' has to be greater or equal then $first_date and less or equal than $second_date you could do it so:</p>
<pre><code>$this->db->where('tanggal >=',$first_date);
$this->db-... |
How to select based on values "keyed" by another column? <p>PostgreSQL newbie here. I have data that look like this:</p>
<pre><code>+-----------+---------+-------+
| StudentID | ClassID | Grade |
+-----------+---------+-------+
| 19927 | A13 | 5 |
| 19927 | A07 | 3 |
| 19927 | B22 | ... | <p>Postgresql gives lots of different ways of doing it, here's one</p>
<pre><code>SELECT a13.* FROM
(SELECT * FROM table1 where classid='A13') as a13
INNER JOIN
(SELECT * FROM table1 where classid='A07') as a07
ON a13.grade > a07.grade
</code></pre>
|
SQL Server : deleting rows by month name <p>How do I delete by month name instead of date number?</p>
<p>I would like to use 'April' instead of '04'</p>
<p>This is as far as i have gotten, but it still does not work.</p>
<pre><code>DELETE *
FROM myTable
WHERE CONVERT(DATE, myColumn) LIKE 'April'
</code></pre>
| <pre><code>DELETE
FROM
MyTable
WHERE
DATENAME(MONTH,myColumn) LIKE 'April'
</code></pre>
<p>since SQL-SERVER 2008 you can use <code>DATENAME()</code> function to extract it from a date. I personally would still prefer the integers but since you asked....</p>
<p><a href="https://msdn.microsoft.com/en-us/libra... |
Popover editable for tooltip <p>I am new to angular js and bootstrap. I have a requirement that i need to implement a popover on hover or click and the user should be able to edit the tooltip. Could you suggest an approach to implement it. </p>
<pre><code><a href="#" title="Header" data-toggle="popover" data-trigge... | <p>Check the <code>angular-ui-bootstrap</code> - project, specifically the popover directive: </p>
<p><a href="https://angular-ui.github.io/bootstrap/#/popover" rel="nofollow">https://angular-ui.github.io/bootstrap/#/popover</a></p>
<p>You will need to add the angular-ui-bootstrap scripts to index.html, along with th... |
selenium web driver wait until page to refresh <p>Below is the code snippet of my selenium test case, where i use select method to choose a value from the drop down . And the next step would be clicking on the submit . But by the time i try to click on the submit button the page is not refreshed(which will refresh the ... | <pre><code>public void WaitForElementToLoad(String selector, String key, String seconds)
throws ValidationException {
Integer time = Integer.valueOf(seconds);
WebElement element = null;
while (time > 0) {
try {
element = getSpecificWebElement(select... |
How to chain promise in redux action <p>How do i make an api call first in redux action and then dispatch GET_TODOs?</p>
<pre><code>// first the api call has to be made,
export function getTodos() {
return {
type: 'GET_TODOS',
promise: request.get(API_URL)
}
}
</code></pre>
<p>t... | <p>Use <a href="https://www.npmjs.com/package/redux-thunk" rel="nofollow">thunk middleware</a>. Here's how your action would look like:</p>
<pre><code>export const GET_TODOS = 'GET_TODOS'
export const GET_TODOS_SUCCESS = 'GET_TODOS_SUCCESS'
export const GET_TODOS_FAILURE = 'GET_TODOS_FAILURE'
export function getTodos... |
Angular ng-bind not accessing scope variables <p>ng-bind is not accessing the $scope variables. When the view loads the data is not rendered - it's just blank, but I can see all of the data I need to access under the "showTopic" variable in the $scope in the console. Any ideas where I'm going wrong?</p>
<p>The problem... | <p>The problem is occurring because of your view change. When you change views the scope changes as well. The scope exists in your <code>dashboard</code> view with correct scope variables, but is actually empty in the <code>topic</code> view. I know it looks deceiving because you are logging the object. So if you are ... |
Passing text after onclick on href in jQUERY <p>I want to get the text from onclick href in particular href when class="bank cur" while getting the data-name="建设é¶è¡"</p>
<p>But it does not work. In function i am getting nothing to pass.Please help how to get value the text.</p>
<pre><code> <ul class="ban... | <p>You can extract the content of the clicked element like so:</p>
<pre><code>$(".bank").click(function(event){
var $target = $(event.target);
$target.text(); // gets text (of a link, div, etc)
$target.val(); // gets value (of an input)
$target.html(); // gets html
$target.attr('href'); //gets value o... |
refresh Morris Chart with AJAX <p>As the first I would like to apologise for my bad English. Though I understand the English language, but can express myself In writing, unfortunately, very badly. So I use a translator's tool.</p>
<p>Now I come to my question:</p>
<p>With pleasure I would update my charts shown with ... | <p>Redraw the char using <code>redraw()</code></p>
<pre><code>graph.setData(data);
graph.redraw();
</code></pre>
|
Two TextView impliment count information after short title and long title(ellipsize end) <p>The first text is use to display title. the second is use to show this page list or recyclerview items size, my solution is use tow TextView, it work but I think is not good solution to deal with it. Any one show me another way ... | <p>Just add <code>android:maxLines="1"</code> and <code>android:ellipsize="end"</code> to the TextView in your XML layout.</p>
|
Combining parent details requests in RxJava <p>I have a list of objects of class A that I get from a server. This class A contains, among other items, a list of IDs. These IDs are then used to retrieve a list of objects of class B.</p>
<p>I have functions that return</p>
<pre><code>Observable<List<A>>
</c... | <p>Suppose, as you described, you have the functions:</p>
<pre><code>Observable<List<A>> getAList()
</code></pre>
<p>and</p>
<pre><code>Observable<B> getB(Long id)
</code></pre>
<p>Basically you need to make use of <code>Observable.from</code> method to decouple list to single elements and of cour... |
Renaming all files in another folder? <p>I found this code from a post from 2 years ago.
It works great, but is it possible to set a destination for another folder?</p>
<p>This BAT file renames all .jpg files in the current folder. Im wondering if it is possible to input a destination to rename all jpgs in another fol... | <p>WOW ok all i had to do is use
cd C:\folder path</p>
<p>I cant believe it was that easy LOL</p>
|
how to import d3.js to angular 2? <p>I'm using the final version of angular 2 with out angular cli and webpack.</p>
<pre><code>import * as d3 from 'd3'; //ERROR: Cannot find module 'd3'
</code></pre>
<p>I installed d3:
npm install d3 --save</p>
<p>what is the problem?</p>
<hr>
<p>system.config.js:</p>
<pre><code... | <pre><code>typings install --global --save dt~d3
</code></pre>
<p>You have a JavaScript library(d3) in your code and you are trying to import it in TypeScript code. TypeScript does not know the "shape" of that library and you need to install a <a href="https://blog.mariusschulz.com/2014/05/19/using-typescripts-type-de... |
Can a MagicMock object be iterated over? <p>What I would like to do is this...</p>
<pre><code>x = MagicMock()
x.iter_values = [1, 2, 3]
for i in x:
i.method()
</code></pre>
<p>I am trying to write a unit test for this function but I am unsure about how to go about mocking all of the methods called without callin... | <p>What you actually want to do is not return a <code>Mock</code> with a <code>return_value=[]</code>. You actually want to return a <code>list</code> of <code>Mock</code> objects. Here is a snippet of your test code with the correct components and a small example to show how to test one of the iterations in your loop:... |
Can substitute default softmax with self-implemented one in TensorFlow? <p>I just wonder could the softmax provided by the TensorFlow package, namely, tensorflow.nn.softmax, be substituted by one implemented by myself?</p>
<p>I run the original tutorial file mnist_softmax.py with cross_entropy calculation:</p>
<pre><... | <p>Your <code>y2</code> as a matter of fact is not equivalent to computing softmax. Softmax is</p>
<pre><code>softmax(y) = e^y / S
</code></pre>
<p>Where <code>S</code> is a normalizing factor (the sum of <code>e^y</code> across all <code>y</code>s). Also, when you compute the normalizing factor, you only need to red... |
How to double an array size using a for loop to compare selection sort performance with different array sizes? <p>My goal for this project was to measure the performance of selection sort using random numbers. I wanted to begin with an array size of n=100, and I wanted to double that array size up to 200,000 (n = 100 *... | <pre><code> public static void selectionSort(int[] data) {
int temp;
int j;
int i;
for (i = 0; i < data.length - 1; i++ ){
int min = i;
for(j = i + 1; j < data.length; j++){
if(data[j] < data[min])
min = j;
}
... |
Passing pandas DataFrame by reference <p>My question is regarding immutability of pandas DataFrame when it is passed by reference. Consider the following code:</p>
<pre><code>import pandas as pd
def foo(df1, df2):
df1['B'] = 1
df1 = df1.join(df2['C'], how='inner')
return()
def main(argv = None):
#... | <p>Python doesn't have pass by value vs. pass by reference - there are just <a href="https://docs.python.org/2/reference/executionmodel.html#naming-and-binding" rel="nofollow">bindings from names to objects</a>. </p>
<p>If you change your function to</p>
<pre><code>def foo(df1, df2):
res = df1.join(df2['C'], how... |
How to get the file value in Jquery and pass value in AJAX <p>Here I want insert the values in Database here normal value like name, email, area... This value getting and after that value passed in next through AJAX and doing insertion part but while file uploading I can't get <code>consloe.log(file);</code> I am getti... | <p>You could not upload file via ajax like this you need metadata, instead of json object, you can code ajax like below:-</p>
<pre><code>// have a look..
formdata= new FormData($('#formid')[0]);
// to console data you do it with just get method on form data like
console.log(formdata.get('file')); // for file
console.l... |
Is there any difference between inner join and table separated with a comma? <p>Is there any performance difference between these two query. Both query returns the same result.</p>
<pre><code>select * from tbl_a, tbl_b
</code></pre>
<p>and</p>
<pre><code>select * from tbl_a INNER JOIN tbl_b
</code></pre>
| <p>There is a thread already touching on this topic. Check it out:</p>
<p><a href="http://stackoverflow.com/questions/38549/what-is-the-difference-between-inner-join-and-outer-join">What is the difference between inner join and outer join</a></p>
<p>Performance wise, it will all come down to the amount of data you're... |
How to evaluate a boolean expression in C? <p>I want to evaluate the following boolean expression in C:</p>
<pre><code>f = (b+c')(a'+c')(a+b'+c)
</code></pre>
<p>This is my current program:</p>
<pre><code>#include <stdio.h>
int main()
{
int a,b,c,f;
a=0;b=1;c=1;
f=((b|(~c))&((~a)|(~c))&(a|(... | <p>In C you use <code>!</code> for negation:</p>
<pre><code>#include <stdio.h>
int main()
{
int a,b,c,f;
a=0;b=1;c=1;
f=((b||(!c))&&((!a)||(!c))&&(a||(!b)||c));
printf("%d\n",f);
}
</code></pre>
<p>The <code>~</code> operator flips all the bits in a number, which is not what you w... |
SQLite not insert value <p>This is my table structure</p>
<pre><code> CREATE TABLE "Ranking" ( `Id` INTEGER PRIMARY KEY AUTOINCREMENT, `Score` INTEGER )
</code></pre>
<p>This is my function </p>
<pre><code> public long insertScore(int score) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues co... | <p>try this</p>
<pre><code>String CREATE_CONTACTS_TABLE = "CREATE TABLE Ranking ( Id INTEGER PRIMARY KEY,Score INTEGER)";
</code></pre>
<p>fetch like this i think it will work</p>
<pre><code>public List<Ranking> getRanking() {
List<Ranking> listRanking = new ArrayList<>();
SQLiteDatabase db... |
Registering generic type with multiple constructors <p>I am trying to move from Unity to Simple Injector and having trouble getting the Injection to work with Simple Injector.</p>
<p>Working Unity code is below</p>
<pre><code>var container = new UnityContainer();
DependencyResolver.SetResolver(new UnityDependencyReso... | <p>There are several ways you can solve this in Simple Injector.</p>
<p>First of all, always let your components have a single constructor, since having <a href="https://www.cuttingedge.it/blogs/steven/pivot/entry.php?id=97" rel="nofollow">multiple constructors is an anti-pattern</a>.</p>
<p>Since however the supplie... |
mysql: failed to embed select into select <p>I created a database for problem set with 6 column(<code>problemId</code>, <code>a</code> ,<code>b</code> ,<code>c</code> ,<code>d</code>
, <code>rightAnswer</code>), where <code>a</code>,<code>b</code>,<code>c</code>,<code>d</code> stores the details of each option and <cod... | <p>You could use a CASE expression ... </p>
<pre><code> SELECT CASE t.rightanswer
WHEN 'a' THEN t.a
WHEN 'b' THEN t.b
WHEN 'c' THEN t.c
WHEN 'd' THEN t.d
ELSE NULL
END AS rightanswer_val
FROM mytable t
WHERE t.problemid = 1
</code></pre>
<p>That would s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.