INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
How to have more than 5 JUnits configurations saved in Intellij When I run a test in Junit it will automatically add it self to the run/Debug configuration. That's great but since there a maximum 5 Unit tests there is removes other tests that I configured. Is there a way to configure this number![enter image description here](
None of these are saved, they are greyed out. If you want to takes them press the [disk] button (the forth from the left) once you do this, the save button should be greyed out instead. You are limited to 5 unsaved (recent) configurations.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "java, intellij idea, junit" }
GNU Make: shell cat file yields contents without newlines Makefile: .PHONY: all SHELL:=/usr/bin/env bash all: $(eval x=$(shell cat file)) @echo "$x" File: foo bar Output: foo bar * * * How do I get the contents of the file into the make variable without losing the newlines?
You can't do this with `shell`, as described in its documentation. If you have a sufficiently new version of GNU make, you can use the `file` function however.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "makefile, gnu make" }
How to Use Load Data .dat from Matlab in VB.NET with DataGridView How can I load a data in VB.NET for Matlab? In example I have a code in matlab like this x = load('ex2x.dat'); Then how can I change the data with DataGridView in VB.NET? The concept is like this : x = load("datagridview's column data values"); Please help me.
> Imports System.IO Public Class Form1 Private Sub Button1_Click(ByVal > sender As System.Object, _ ByVal e As System.EventArgs) Handles > Button1.Click > Dim readStream As FileStream > Dim msg As String > Try readStream = New FileStream("c:\testBinary.dat", FileMode.Open) > Dim readBinary As New BinaryReader(readStream) > msg = readBinary.ReadString() > MsgBox(msg) > readStream.Close() > Catch ex As Exception > MsgBox(ex.ToString) > End Try > End Sub End Class use above code it will help full for you
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -2, "tags": "vb.net, matlab" }
What are windows 7 N/KN/VL editions? We're subscribed to MSDN at work and I've noticed that among the various windows "editions" there are downloads such as "Windows 7 Ultimate N" and "Windows 7 Ultimate N and KN". What are these versions and what is the difference between "regular" windows 7 and these version?
* * * * N is made for the EU market and does not include Windows Media Player. * KN is made for the Korean Market and does not include Windows Media Player or an Instant Messenger. * VL are volume license editions for business enterprise customers and uses MAK (Multiple Activation Keys) or KMS (Key Management Server) to activate. * * * Everything else is exactly the same as retail editions except for those changes above.
stackexchange-serverfault
{ "answer_score": 77, "question_score": 58, "tags": "windows, windows 7" }
Use of had and past participle I am talking about two years ago in my sentences below. Her people had fought a hard battle. In celebration, students had taken to the streets and placed carnations in the soldiers’ gun barrels. Is it correct or do I need had placed?
It's correct, Moni. The single "had" governs all the actions that follow. It would even be correct to say, "In celebration, students had taken to the streets, danced, sung songs, exchanged presents, drunk wine and placed carnations in the soldiers’ gun barrels."
stackexchange-english
{ "answer_score": 0, "question_score": 0, "tags": "grammar" }
Does Google News index HTML5 websites? Does anyone know if Google News properly indexes HTML5 websites? For example, since HTML5 allows for to have an h1 tag (instead of having it where the heading tags are done downward, i.e. the article gets h1, a sub section would get h2, the sidebar navigation gets h3, etc.), if I had the tag have an h1, would Google News get confused or do they already support and would notice the h1 and index as they normally do for an HTML4/XHTML page?
I'm sure google can and will index your content. I'm not sure if google will give more weight to article's h1 instead of header's h1 for SEO. Keep in mind that title tag is more important (in SEO weight) than h1 headings. Note that what goes to google results are tags title and meta tag description. Other tags are for weightning only. And as rule of thumb, how close to page's start are they keywords, the best. It could be interesting add an H1 to the header element, from SEO ponit of view.
stackexchange-webmasters
{ "answer_score": 0, "question_score": 1, "tags": "html5, google news" }
what is the best way to mark any text? I need users to mark some section of text with custom tags, I can't use the xml based tags as the whole text will be embedded in XML documents and all the < will be converted to html escape code <. I want users to marks some section of text with tags like skip, bookmark, these tags can have attributes also like bookmark name="first". Which is the best way of allowing users to mark text using the BB forum way like [b]abcd[/b] or using {{bookmark name="first"}}. Or is there any better scheme or technique available. I don't want to change the structure of the text as down by the markdown or textile, I just want to tag some section of text, like the phpBB tags. The question is there any other style than phpBB? Like in some software I see {{bookmark name = "abcd"}} style.
The three common markups I know of for this purpose are Markdown (used, I believe, by SO), textile, and BBCode. The first two are commonly used for blog sites and CMS frameworks, and BBCode I think is usually associated with bulletin-board sites. Preview and mapping utilities are available for each.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "text, markup" }
NodeJS, IRC-bot. Something is slowing it down, but what? Today I just felt like writing an IRC-bot in Javascript with NodeJS. Everything works just fine, but it is bottlenecking somewhere. For example, when I type a command several times it answers me immediately at first, but then starts to queue up and take longer and longer to respond. Here's my code <
I totally forgot about this post. That's what coding drunk does to you! Anyway, I solved it. It was as caf said, server-side ratelimiting. My local ircd was setup wrong. Working like a charm when it's running in a live environment.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, node.js, irc" }
How can I change frame or size of WKInterfaceImage object for Apple Watch? How can I change size of WKInterfaceImage object? Official documentation doesn't provide any way to do this simple step.
The `UIImage` you provide to a `WKInterfaceImage` should already have the desired size. If it doesn't, resize it on the iPhone before sending it to the watch. If you want to change the size anyway, call `setWidth(_:)` and `setHeight(_:)`. This will also change the scaling mode of your image to "scale to fill".
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ios, watchkit, apple watch, wkinterfaceimage" }
Android : How to hide Navigation bar and Optionmenu in login fragment? I have an activity and 3 fragments, the fragment I display is login Fragment.I want to hide the Navigation bar Floating action button and Option Menu in the Login Fragment and display in other two fragment. How can I achieve this?
After a long research I found a solution. That is I lock the navigation drawer in the Login fragment using the code : DrawerLayout drawer = (DrawerLayout) getActivity().findViewById(R.id.drawer_layout); drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); And again using the code below to unlock the navigation drawer in the Welcome fragment. DrawerLayout drawer = (DrawerLayout) getActivity().findViewById(R.id.drawer_layout); drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNDEFINED); This is same for Option Menu as well.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "android" }
How to force compile error for api method that is not in minSdkVersion I've been getting NoSuchMethodException crashes on older devices and I'm wondering why the eclipse IDE isn't giving me at least a warning for using methods that aren't supported yet on older devices. I have the minSDKVersion field set in my AndroidManifest.xml correctly. Is there anyway to get a compile error or at least a warning if I use a method that can't be run on minSdkVersion devices? I've got the following in my AndroidManifest.xml <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16" > </uses-sdk> I don't want to have to test every screen and function of this huge app with an old device. Thanks!
Set the Lint check for NewApi and InlineApi to errors. right click project --> Properties --> Android Lint Preferences. Find `NewApi` and `InlineApi` and set the `Severity` box to Error or Fatal.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 3, "tags": "android" }
How to write a while loop into a CSV file My code looks like: x=0 while (x<3): print('purple'), print('yellow'), print({x}) x=x+1 I want it to log this data into a csv file named 'daffodils.csv'. How do I do this so that the iterations won't write over eachother? For example, if I ran the program two times, my csv file will look like: purple yellow 0 purple yellow 1 purple yellow 2 purple yellow 0 purple yellow 1 purple yellow 2 Thanks
Simply use: t = open("daffodils.csv", "a+") x=0 while (x<3): t.write('purple'), t.write('yellow'), t.write({x}) t.write("\n") x=x+1 t.close() The `a` opens the file in append mode, and the `+` creates it if it doesn't already exist.
stackexchange-stackoverflow
{ "answer_score": -1, "question_score": -2, "tags": "python, csv, while loop" }
strange redirect with url rewrite My .htaccess file is: RewriteEngine on RewriteRule (.*) index.php?_url=$1 [QSA,L] It works perfectly in most cases. But if the requested url exists as a real folder, it goes crazy. For example when i request `/random` it is rewritten to `index.php?_url=random` with status code 200, but for `/static` (which is an existing directory on the web server) it gives a 301 redirect to `/static/?_url=static`
**use this below code for .htaccess** <IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)/$ [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule>
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "apache, .htaccess, mod rewrite, url rewriting" }
C++ declaration and initialization / variables aren't initialized to default value case 1-> int a; std :: cout << a << endl; // prints 0 case 2-> int a; std :: cout << &a << " " << a << endl; // 0x7ffc057370f4 32764 whenever I print address of variable, they aren't initialized to default value why is it so. I thought value of `a` in case 2 is junk but every time I run the code it shows 32764,5,6,7 are these still junk values?
Variables in C++ are not initialized to a default value, hence there's no way to determine the value. You can read more about it here.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "c++11" }
Hows Mozenda Screen Scraper coded? I want to know how is the Mozenda Screen Scraper coded? < I shows a browser where user can select the fields he wants to scrap and it creates a crawl script out of it. The crawl script generation part is clear to me, I want to know does it record the user actions which the user is doing in the browser. I want to do something similar using C#.
I guess they run something like iMacros on the backend. I even noticed the iMacros browser icon in some of their screenshots ;-) If you want to code something like this yourself in C#, the **IE webbrowser control** is the best starting point!
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 7, "tags": "screen scraping, web crawler, web scraping" }
link exe with //MT flag I want to build exe file on windows, without need of vcruntime. So I tried: .cargo/config [target.i686-pc-windows-msvc] rustflags = ["-Clink-args=/MT"] looks like cargo found config, because of `cargo` rebuild whole project, but `dumpbin /DEPENDENTS test.exe` still show `VCRUNTIME140.dll` as dependencies, any ideas how link `VCRUNTIME140` statically?
See this rfc You can try it with rustc nightly: c:\Users\IEUser\test2>rustc -Z unstable-options -C target-feature=+crt-static test.rs
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "windows, linker, rust, rust cargo" }
LDAP Connection Pooling with spring security I was trying setup LDAP connection pooling using spring security and xml based configuration. Below is my configuration, <authentication-manager id="authenticationManager"> <ldap-authentication-provider server-ref="ldapServer" user-dn-pattern="uid={0},ou=users" group-search-filter="(&amp;(objectClass=groupOfUniqueNames)(uniqueMember={0}))" group-search-base="ou=groups" group-role-attribute="cn" role-prefix="ROLE_" user-context-mapper-ref="ldapContextMapperImpl"> </ldap-authentication-provider> </authentication-manager> How do i provide all the connection pooling configuration? I am intending to use PoolingContextSource class as it provides properties to configure pool size etc.
Pooled connections doesn't work with authentication, because the way LDAP authentication works is that the connection is authenticated on creation.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "spring, spring security, connection pooling, spring ldap" }
Does removing an item from a list of class extending runnable terminates its thread? I'm writing a chat server in Java. I was using a fixed array of runnable classes where each element in array represents a client. The threads created are in an infinite loop which reads from socket stream. Now I want to do it with a list so I don't have to worry about array size and it sounds more legit way of doing it. However I couldn't be sure if removing an item also terminates the thread. Actually I have no idea what it does. Also, I'm wondering is there any other possible issues with using list in that kind of situaton. Finally, how about array of Timer? Since I've used Timer for each client, again, does removing a Timer from a Timer list also stops its schedule? Any possible problems?
Hey there i will refer to this question! If the thread is started it will not garbage collected as it is referenced by the containing thread. It will garbage collected if it is done or not started yet! The reason for this is, when started the thread-object gets added to the current `ThreadGroup` (a bit more complex under the hood :) ) and when its done it will automatically removed.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, list, timer, runnable" }
Xamarin.iOS Designer - Creating Action segue not working I am trying to add action segue by dragging a button on one screen to another in Xamarin Studio on Mac. According to instruction provided by Xamarin university, this should create action segue. My exact steps are 1. Click on Control key 2. Select button on 1st screen 3. Drag it to the 2nd screen 4. Release mouse and Control key This should show a little popup prompting you to select type of segue (Push, Modal, or Custom). In my case, the popup shows very briefly, so I have no time to select the type.
It turns out that after restarting Xamarin Studio, I was able to get the popup stay so I can make my selection. I have noticed that Xamarin Studion seem to have strange issues like this and the solution is often to close solution, quit Xamarin studio, restart it, reopen solution and try again.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "ios, xamarin, xamarin.ios, segue" }
Should app binaries be in mounts or volumes or should they exist only within a docker container? What are the best practices regarding this? Say, for example, I am running a java or python app. So I would run a java or python based container but where should my apps live? Should they be in a folder within the base image or should they live in a mounted folder on the host?
You should copy jar to container for dev, stage, production, or test enviroment. Sometimes developers can mount binaries but is is rear case. Here is standard Dockerfile sample, "init" is a script for application stat: FROM openjdk:8-jdk-slim ENV MYSQL_URL="mysql-master:3306" EXPOSE 8080 COPY build/libs/app-*SNAPSHOT.jar /opt/app.jar COPY init /opt/ WORKDIR /opt VOLUME /logs ENTRYPOINT ["/opt/init"] One of advantages is that you can test, deploy to stage, deploy to production the same container and developers can get it for local run to reproduce an issue. Also you can include versioning into the container tag. And you will know from `docker image ls` which version of app with what required env is up.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "docker, containers, volume, mount, binaries" }
Unique Equivalence Relation after a partition of S Suppose that S is a nonempty set and C is a partition of S. Show that there is a unique equivalence relation ∼ on S with equivalence classes being the sets in C. By unique I mean there exist a few equivalence classes such that they are different. My thinking process is define a equivalence relation, but I am not sure how to argue that equivalence classes are different from each other.
Fix a set $X$. Let $P$ be the set of partitions of $X$. Let $C$ be the set of equivalence relations on $X$. Define $f : P \to C$ by $f(p) = \sim_p$, where $\sim_p$ is defined by $x \sim_p y$ if and only if there exists an $a \in p$ such that $x,y \in a $. Define $g : C \to P$ by $g(\sim) = p_\sim$ where $$ p_\sim = \\{C_x \subset X \ \mid \ x \in X \text{ and } (y \in C_x \iff x \sim y )\\} $$ Can you show that $g = f^{-1}$? If so, this establishes a bijection between the set of partitions of a set and the set of equivalence relations (hence equivalence classes) on a set.
stackexchange-math
{ "answer_score": 0, "question_score": 2, "tags": "equivalence relations" }
Are there any values of $x$ for which $\frac{x}{x+1} + \frac{1}{x+1} \neq 1$ Are there any values of $x$ for which $\frac{x}{x+1} + \frac{1}{x+1} \neq 1$ I got -1. does anyone see anymore?
Yes, you are correct. If $x\neq -1$, $$\frac{x}{x+1} + \frac{1}{x+1} = \frac{x+1}{x+1} =1$$ If $x =-1$, $\frac{x}{x+1} + \frac{1}{x+1}$ becomes undefined. However, we can say that $$\lim_{x \rightarrow -1}\frac{x}{x+1} + \frac{1}{x+1}=1$$ See here.
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "algebra precalculus" }
How to Change the Default Displaying Order of Esri Basemaps in basemapGallery? I just started using ArcGIS JS APIs. In my app, I want to combine a few ESRI basemaps with my own basemap service. I am using basemapGallery dijit to change basemaps. By default, basemapGallery shows the imagery map. I want to show OpenStreetMap as the default. How can I make this happen? The code in my app is simple and directly borrowed from ArcGIS samples. So I did not put it here. Thanks!
I think that you'll be best served to create a manual list of the basemaps, including the order, that you want displayed within the gallery. This ArcGIS thread gives quite a bit of detail into what you might be looking for and some code in how to do it.
stackexchange-gis
{ "answer_score": 4, "question_score": 1, "tags": "arcgis maps sdk javascript, arcgis online basemaps, display, order" }
What is the difference between p-adic Lie groups and linear algebraic groups over p-adic fields? I thought they were the same, just different names. Let me make question more precise: Let $G$ be any linear algebraic group over a p-adic field $\mathbb{Q}_p$, is $G$ a p-adic Lie group w.r.t. the analytic topology from $\mathbb{Q}_p$ in the sense of Peter Schneider? If this is the case, Does the Lie algebra from the algebraic group coincide with the Lie algebra from the Lie group? As far as I can see this is true for real number case. But I'm not familiar with p-adic Lie group theory. p-Adic Lie Groups: Peter Schneider:
Consider the map $x\mapsto (x,e^x)$ from $p^2{\mathbb Z}_p$ into ${\mathbb Z}_p\times {\mathbb Z}_p^*$, the latter being the ${\mathbb Z}_p$ rational points of the algebraic group ${\mathbb G}_a\times {\mathbb G}_m$. The image of this map is Zariski dense and hence $p^2{\mathbb Z}_p$ is not an algebraic subgroup of the $p$-adic algebraic group ${\mathbb Z}_p\times {\mathbb Z}_p^*$.
stackexchange-mathoverflow_net_7z
{ "answer_score": 9, "question_score": 14, "tags": "lie groups, algebraic groups, p adic groups" }
Upload to S3 via shell script without aws-cli, possible? As the title says, is it possible to upload to S3 via shell script without aws-cli-tools? If so, how? What I'm trying to do is read from a txt file on S3 (which is public, so no authentication is required). But I want to be able to overwrite whatever is in the file (which is just a number). Thanks in advance, Fadi
Yes you can! You basically emulate the api calls the SDK would do for you through standard linux cmd utils. Look at: < and/or <
stackexchange-stackoverflow
{ "answer_score": 12, "question_score": 7, "tags": "bash, shell, amazon web services, amazon s3, upload" }
Checking for similarity of text in two text strings I have two strings of text (typically two paragraphs). I am looking to check for the "similarity" between them, e.g. check if one paragraph is a plagiarised version of the other. Ideally I need a similarity score, as well as an indication of where the similarities are. I prefer to do this fully in R. Any suggestions please?
The difference of stings can be measured with the levenshtein distance (or concepts that build on top of that). The main idea is to quantify the "editiing distance" of strings: how many letters need to be included/excluded/changed, etc (depending on the algorithm more or less types of editing are allowed). A package in R for this task would be fuzzyjoin. To look up the similarities you could cut both texts (original and suposed plagiate) in sentences and build the fuzzy joins on this - Then you can filter for best matches. The topic is a bit tricky so I recomend trying out different algorithms (jaccard distance, damerau levenshtein, etc). A start into the topic can be found here: <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "r" }
Count unique data within a category I am looking for help in trying to solve an issue with a query. Query: SELECT distinct BRAND,(select count(distinct VIN) from STOCK) as STOCK ITEM COUNT from STOCK What I am trying to achieve is to display the brand and unique count of all VIN numbers which are located in each brand. For some reason when I run the above query each brand eg, Ford,GM,TOYOTA, etc display the same count .
Or do a simple `GROUP BY`: SELECT BRAND, count(distinct VIN) as STOCK_ITEM COUNT from STOCK group by brand
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "mysql, sql, count, isql" }
php foreach with multidimensional array do I need to use a key? I have the following multidimensional array called $responses and it looks like this when I do a print_r !array My foreach loop looks like this but it's not working: foreach ($responses as $response) { $output[$response['poll_response_id']] = array( 'response' => $response['response'], 'response_vote_count' => 0, 'voters' => '' ); } I would like to get an output like this when I do a print_r($output) !output array
You can try this: $output = array(); foreach ($responses as $key => $response) { $output[$key] = array( 'response' => $response[$key], 'response_vote_count' => 0, 'voters' => '' ); } If it doesn't work, please do a "var_dump" on "$responses" instead of "print_r" because we didn't view how this variable is exactly defined.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "php, multidimensional array, foreach" }
How to mock to twitter api using Ruby on Rails? I'm developing a application that uses the twitter API. I'm currently using rspec with mocha, but I found it to be cumbersome and I cannot reuse the mocking that I create for a give method. Is there a way that you can have for a give call, return something, and for another call return something else? Or it needs to be by each method?
Try to use webmock or fake mock. It allows you to stub HTTP requests and setting expectations on HTTP requests in Ruby.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "ruby on rails, twitter, mocking, ruby mocha" }
Derivable functions & Sobolev spaces Is a C^1-function in a bounded domain $\Omega\subset R^n;$ an element of the Sobolev space $W^{2,\infty}(\Omega)$ ?
No. Consider $x^{3/2}$ on $(-1,1)$. It has Holder continuous but not Lipschitz derivative. See Gilbarg-Trudinger Ch. 4 for some related exercises (e.g. a C^1 function with derivative continuous but not Holder continuous for any $\alpha$).
stackexchange-mathoverflow_net_7z
{ "answer_score": 2, "question_score": 0, "tags": "fa.functional analysis" }
Move file to specific folder after upload in forum I am using Drupal 7 with Organic Group and Forum Module. I have added facility to attach files in Forum posts. Now after forum(node) is submitted, I would like to move the file (which is with forum node) to specific folder. Actually I would like to move/copy to other folder during node submit only, is is possible with hook_node_submit()
Here is how I implemented it using hook_node_insert() function. function modulealter_node_insert($node) { // See if a file has been added if ($file_items = field_get_items('node', $node, 'field_file_attachment')) { // Get the first file item $file_item = array_shift($file_items); // Load the file object from the cache/database $file = file_load($file_item['fid']); // The path to the file is in $file->uri //var_dump($node->group_audience['und']['0']['gid']); //Set the destination folder where do you want to move it $destination = "private://filedepot/filedepot/test/".$file->filename; $file = file_copy($file, $destination, FILE_EXISTS_REPLACE); } }
stackexchange-drupal
{ "answer_score": 3, "question_score": 0, "tags": "files" }
Is there a difference between delegate/selector and target/action? When writing Cocoa and implementing a class method that accepts a delegate and one or more selectors to use for its callbacks, does the terminology change from "delegate" and "selectors" to "target" and "action"? More to the point, is "delegate" limited only to when my class is the one getting _called_ , but not when my class is _doing the calling_?
Delegates are usually implemented using Protocols instead of selectors. This is a more formal way of communicating across classes, and is mostly useful when there is more than one method that may be needed. Target/Action are generally used to correspond to an "event-like" situation, such as a click, a timer firing, etc.
stackexchange-stackoverflow
{ "answer_score": 14, "question_score": 7, "tags": "objective c, cocoa, cocoa touch, macos" }
parse jQuery like selector regex I have the string "foo.bar#baz" and i want to get ["foo", ".bar", "#baz"] I tried doing it with "foo.bar#baz".match(/[^.]+/g).join(' .').match(/[^#]+/g).join(' #').split(' '); but i think it's way too long. Do you know any shorter version? PS: I don't want to get ["foo", "bar", "baz"] what i could do with "foo.bar#baz".match(/[.#]+/g);
You can use positive lookahead to split a string but keep the delimiting character. var myString = "foo.bar#baz"; var myRegex = /(?=[\.#])/g; console.log(myString.split(myRegex)); The syntax for positive lookahead is `(?=)`
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, jquery, regex, string" }
Class not recognized I've just installed the Java SDK 8, set the PATH and the CLASSPATH variables, put javax.mail.jar file in the bin directory, but when I try to compile my problem, all javax.mail classes aren't recongnized: C:\Java>javac SendMail.java SendMail.java:5: error: package javax.mail does not exist import javax.mail.Message; Here is the content of my CLASSPATH variable: C:\Java>echo %CLASSPATH% C:\"Program Files"\Java\jdk1.8.0_25\lib;. And here is the content of the bin directory: C:\Java>dir C:\"Program Files"\Java\jdk1.8.0_25\lib\*.jar ant-javafx.jar dt.jar javafx-mx.jar javax.mail.jar jconsole.jar sa-jdi.jar tools.jar What's the problem?
Classpath should contain the individual JAR files, not the directory that contains the jar files. Also the `lib` directory contains stuff you normally don't need. So you want just: set CLASSPATH="C:\Program Files\Java\jdk1.8.0_25\lib\javax.mail.jar" Also you can add classpath on your `java.exe` command line: java.exe -cp "C:\Program Files\Java\jdk1.8.0_25\lib\javax.mail.jar" SendMail
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "java" }
How to test async Mongo query? Is there any good strategy to test an async `insert` to a mongodb collection using MongoDB Scala driver 1.1: driver.myCollection.insertOne(doc).subscribe(new Observer[Completed] { override def onNext(result: Completed): Unit = /* do something */ override def onComplete(): Unit = /* do something */ override def onError(e: Throwable): Unit = /* do something */ }) Any mock suggested to run in it in a test? Mocking the Observable? And in case of integration test?
One possible solution is to invoke `insertOne` and turn the `Observable[T]` into a `Future[T]` and use `Await.result` to synchronously block on it. This conversion is defined inside the [ScalaObservable[T]]( implicit class: import org.mongodb.scala.ObservableImplicits._ val future = driver .myCollection .insertOne(docs) .toFuture() Await.result(future, Duration(3000, MILLISECONDS)) Note this requires the import of `ObservableImplicits`.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "mongodb, scala, unit testing, asynchronous, integration testing" }
Encerrar timer com um alert Eu tenho esse timer de 10 segundos em JS. function startTimer(duration, display) { var timer = duration, hours, minutes, seconds; setInterval(function(){ seconds = parseInt(timer % 10, 10); seconds = seconds < 10 ? "0" + seconds : seconds; display.textContent = seconds; if (--timer < 0) { timer = duration; } }, 1000); } window.onload = function() { var duration = 3600 * 2; // Conversao para horas var display = document.querySelector("#timer"); // Exibir o timer startTimer(duration, display); } Que chama este campo para começar a contagem. <div class="fixed-top" id="timer" align="center"></div> **Eu queria que, quando ele zerar exibir um alerta informando que o tempo acabou!**
O jeito mais simples é adicionar uma verificação para saber quando o tempo acabou, assim: setInterval(function(){ // ... if (seconds == 0) { alert('tempo acabou!'); } }, 1000);
stackexchange-pt_stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, html" }
Replacing all selected elements with javascript I'm trying to select all spans with class .normal on my site, cut the first character and add € as the last character. I'm trying really hard but it just doesn't work even when I try to just replace that with "abc" or any string. My javascript looks like that: $(document).ready(function(){ var prices = document.querySelectorAll('span.normal'); for (i=0; i<prices.length; i++) { prices[i].textContent = prices[i].substring(1) + "€"; } } });
Since you are using jQuery already how about making it completely in jQuery? $(document).ready(function() { $('span.normal').each(function() { $(this).text($(this).text().substring(1) + '€'); }); }) <script src=" <span>abc</span> <span class="normal">abc</span> <span>abc</span> <span class="normal">abc</span>
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "javascript, html, css, selector" }
What do the dashes close to each other near French freeway exits mean? During my last trip to France via car I noticed that French freeways (autoroutes) have a somewhat strange road marking I am not familiar with. Usually, there are two lanes going my direction on a freeway. These lanes are separated by a dashed line indicating I am allowed to cross this line to pass cars by moving to the left lane. A few hundred meters before each exit the frequency of these dashes changes. They are much closer together but still don't form a solid line. As soon as the exit is passed, the line changes back to dashes spread further apart, just as before. In case you do not know what I mean, have a look at e.g. this freeway exit near Paris on Google Maps. What do these dashes near the exit mean? Am I supposed to not change lanes in this area?
It's called a “ _ligne de dissuasion_ ” (literally “deterrence line”). The idea is to indicate that it's too late to switch from the leftmost lane to the exit. But it's not strictly forbidden to cross the line, especially in the other direction (from the rightmost lane to the leftmost lane), e.g. to overtake or make some space for someone getting on the motorway. According to the guidelines published by the ministry using a straight line for that purpose is deemed “too limiting” (“ _trop contraignant_ ”) and reserved for special situations, when the exit is “particularly difficult”. German motorways have slightly different markings to convey the same idea. In France, the same markings are also used on country roads, when overtaking is not strictly forbidden but should only be done for particularly slow vehicles. In both cases, it means more-or-less the same thing: Crossing the line is not _forbidden_ but you are encouraged not to do it if you can avoid it.
stackexchange-travel
{ "answer_score": 23, "question_score": 20, "tags": "legal, france, driving" }
Error establishing a database connection in wordpress I know this is self explanatory but why can't I connect to my database? I have a live website that I wanted to update by first doing development in my local computer. I exported the db to my local pc then imported it to phpmyadmin. When I try to access the site thru localhost/sitename, the error **_Error establishing a database connection_** keeps popping up. I have tried every tutorial and forums out there but still the error persists. I have checked the credentials from wp-config.php and it was the same(same db name, username, password). Is there other contents should I change property? Thanks in advance!
I had this issue some days ago with a multisite, loading a live dump to local development. After some debugging I noticed, that the error message wasn't right. The database was connected, but the path in the database to the sites was wrong. You can check table `<your-prefix>_site` and `<your-prefix>_blogs` if columns `domain` and `path` are correct. That solved my problem, as the error message told something else.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "database" }
Modernizr class assignment I'm new to Modernizr. This may seem like an incredibly OCD question, but I'm curious as to why Modernizr adds a preceding space when it assigns a class to my page's `html` tag when it is the only class assigned? For instance when I inspect my page in a desktop context, my page's `html` tag looks like so: <html dir="ltr" lang="en-AU" style="" class=" no-touchevents"> instead of: <html dir="ltr" lang="en-AU" style="" class="no-touchevents"> Is there a rationale as to why Modernizr adds classes in this manner?
Here's the source code for adding classes in modernizer: < Looks like it's just because they're doing a `+=` on the className and are including a space in case the element already has some classes assigned.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "javascript, html, modernizr" }
Including bias die properties in probability calculations Suppose I have a die with sides $1,2,3,4,5,5$. What is the probability of getting any order of $1,2,3,4,5$ in $5$ rolls? Would I be right in saying you can't use combinations to try and calculate this because the probability of each outcome isn't equally likely?
I would try thinking like this: * What is the probability of rolling 1,2,3,4,5 in _exactly that order_? * What about rolling them in some other order, say 2,1,3,4,5. Is the probability still the same? * How many different orderings are there? * The probability of rolling any of the orderings is the sum of the probabilities for any particular ordering.
stackexchange-math
{ "answer_score": 2, "question_score": 3, "tags": "probability, combinatorics" }
XMLHttpRequest responceText returns undefined, but is defined in chrome console I'm having a rather odd problem communicating between a php localhost and xmlhttprequest, which I can't seem to find an answer in similar questions. When calling "console.log(xhr);", the chrome console clearly displayed responceText as "TestText" while calling "console.log(xhr.responceText);" displays as undefined. The javascript: var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if(xhr.readyState == 4 && xhr.status == 200) { console.log(xhr);//In dropdown menu, displays 'responceText: "TestText"' console.log(xhr.responceText);//Displays "undefined" } } xhr.open('POST', '/file/directory/stuff.php', true); xhr.send(null); And the PHP file: echo "TestText"; Any ideas to why? **SOLUTION:** I can't spell.. it's "responseText". Thanks!
I think it's simple spell mistake: `console.log(xhr.responseText);`
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": -2, "tags": "php, javascript, xmlhttprequest" }
TBD resistor & capacitor(TBD means "To Be Discussed") I’m building the * DN05017/D * power supply from ON Semiconductor. This is the datasheet of the power supply with schematic and BOM So now while searching for the components, I noticed on the schematic and BOM list a resistor without a specific value; all it says is: “TBD”. ![Note R11 on the schematic near U1]( ![Also Note R11!]( R11 is the resistor that shows “TBD” Value. And also note under the “Manufacture Part Number”, that capacitors and resistors have “TBD” but under the “Value” they have noted their specific values. Just R11 has noted “TBD”. I’m integrating this into a AC line monitoring project. I have googled “TBD” but can’t find my answer. A definition I found for TBD: “time to breakdown”, but it didn’t make sense in my case, because I need the value. **Question** What does “TBD” mean in this case? Do I have to determine the value by myself?
From the NCP1251 datasheet, description of pin 3: "A resistive divider from the auxiliary winding to this pin sets the OPP compensation level. When brought above 3 V, the part is fully latched off." With no other information available, wire in a pot and dial up the resistance of R11 (aka bring down the voltage of pin 3, away from shut-off mode) until the device runs without issue under min load, max load, and when adding or removing min and max load.
stackexchange-electronics
{ "answer_score": 1, "question_score": 1, "tags": "power supply, voltage, capacitor, resistors, component values" }
Replacing values in dataset First sorry for this newbie question, but I'm learning for myself so its a little more challenging. I'm with a problem in replacing some negative values in one label of my dataset. In a nutshel, I want to replace those negative values with a default value. I tried doing the code below but didn't work. dset['age'].replace(dset['age'] < 0 ,40) Someone can help me? I know that changing it on CSV file is easier, but I'm trying to get used do pandas library. dset['age'].replace(dset['age'] < 0 ,40) tried too: dset['age'] = dset['age'].replace(dset['age'] < 0 ,40) dset = pd.read_csv('credit-data.csv') dset['age'].replace(dset['age'] < 0 ,40)
dset.loc[dset['age'] < 0, 'age'] = 40
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python, pandas, sklearn pandas" }
Difference between "being passionate" and "being I've looked at definitions of both "passionate" and "passional", and they are pretty much the same, but I can't help but feel being passionate is different from being passional
I had to look up "passional," as I've never heard it used this way. "Passionate" is the normal way of describing something having a lot of passion: passionate lovers, a passionate interest in astronomy. "Passional" means "of or relating to passion" rather than "filled with passion," and might be used if you were academically describing the effects of passion as opposed to some other factor. Passional is also a noun referring to certain Christian texts, which may well be its most common use. 99% of the time, "passionate" is the right word and "passional" will get you funny looks.
stackexchange-ell
{ "answer_score": 1, "question_score": 0, "tags": "grammar, vocabulary, definition" }
Is there a way to extend WSHttpBinding to allow SwA? Using WCF, can I create my own binding (based on WSHttpBinding) and use it manipulate the HTTP request so that I could add standard MIME attachments to it (SwA)?
No, not as far as I know. Why are you not using MTOM ?
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "wcf, customization, wshttpbinding" }
Selecting a gear reduction: torque vs speed I have just sized the DC motors I want to use (corresponding to my robot and its intended applications - my figures include a 50% uncertainty factor to account for friction in reducers and other losses). Now I need to actually choose the exact motors I want to buy from the manufacturer (I am targeting maxon motors as I am not an expert and want no problem). I have a few down to earth questions about linking the mechanical needs to the electrical characteristics, among them: **Question #4:** The motor I chose (maxon brushed DC: 310005 found here) has nominal speed = 7630rpm - nominal torque = 51.6mNm. My needs are max speed = 50.42rpm / max torque = 10620 mNm. This means a reduction factor of 151 for speed and 206 for torque. Should I choose a gear closer to 151 or 206?
If you choose 151 you'll get the speed but won't get the torque, if you choose 206 you'll get the torque but won't get the speed. You can either play with your needs to be able to use that motor or use another higher torque/speed motor.
stackexchange-robotics
{ "answer_score": 0, "question_score": 2, "tags": "motor, servomotor, brushless motor" }
flutter sms package read sms as read I was working on an sms application in flutter. For that I'm using **flutter_sms** packages by **babariviere**. I want to mark a thread as read. Can any one tell How to achieve that.I have read the documentaion but didnt find.Maybe someone here could help me. Thank-You in advance.
No, you cannot with the current implementation of < . This package can only `android.permission.SEND_SMS`, not `android.permission.BROADCAST_SMS`, `android.permission.READ_SMS` nor `android.permission.RECEIVE_SMS`. You can create a github issue asking for your feature request <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "flutter" }
How to compare the last index to the first in a list whilst iterating, or looping I want to compare the last index to the first index in a loop or map step. I want something like this using 'map': def difference(angle): return angle.next() - angle angles = [90,180,270] diff = list(map(difference,angles)) print(diff) Or something like this using a 'for' loop: angles = [90,180,270] diff = [] for angle in angles: diff.append(angles.next()-angle) print(diff) They don't work. You can't call `.next()` on an int type. This does work, but it seems very messy: angles = [90,180,270] i = 0 diff = [] angles.append(angles[0]) while i <len(angles)-1: diff.append(angles[i+1]-angles[i]) i += 1 print(diff) Is there a neater solution? I don't feel like I should have to append the first index to the end to do this operation.
Use `zip` to combine the original list and the same list shifted by one item: diff = [left-right for left, right in zip(angles, angles[1:]+angles[:1])] For `angles = [90,180,270]`, the result would be `[-90, -90, 180]`. * * * Or the other way round (subtract the left value from the right one): diff = [right-left for left, right in zip(angles, angles[1:]+angles[:1])] For `angles = [90,180,270]`, the result would be `[90, 90, -180]`. * * * You can also just eliminate the sign using `abs(...)` if you don't want it: diff = [abs(left-right) for left, right in zip(angles, angles[1:]+angles[:1])] For `angles = [90,180,270]`, the result would be `[90, 90, 180]`.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python 3.x" }
How to remove device(s) from My Market Account? I know I can choose **"Hidden in menus"** and never see the devices again when I install a application. But I don't want my old mobile phones display in my account settings anymore. I have sold those phones already and never use them again! In fact, the list look likes a cemetery in my mind now. ;(
As things currently stand, there is no way to **disassociate** a device from the ones shown in your Market Account. Keeping them hidden is the only way that Google currently offers.
stackexchange-android
{ "answer_score": 13, "question_score": 25, "tags": "google play store, accounts" }
Running Eslint airbnb specific file returns nothing I'm running node_modules/.bin/eslint app.jsx and it returns nothing. I know there are errors on the page however. Anyone know what is going on? I don't even get a message on screen. If I run: node_modules/.bin/eslint --ext=js --ext=jsx I'll see the errors in app.jsx. The reason I am doing just a single file is because I just turned on airbnb with eslint on create-react-app and I have a lot of errors to fix I wanted to do it slowly.
I guess your app.jsx is in a "src" folder, right? So you have to add it in your command like this: node_modules/.bin/eslint ./src/app.jsx Nico
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "reactjs, eslint, eslint config airbnb" }
Vim change colorscheme and vimrc location file I am under Ubuntu 11.04 and when I type vim -v in the shell I get this: version 7.3.35 First, I want to say that I don't see any file called **vimrc** under my home folder. Is this normal behavior? I just see one in `/etc/vim` I have added `colors delek` at the end of the mentioned vimrc file (and I have d* _elek.vim_ * in `/usr/share/vim/vim73/colors`) but when I restart vim, I don't see that scheme. What am I missing here?
Yes that is normal, and you can create the .vimrc file yourself (remember the '.' at the beginning of the file). You can add any VIM options to this file, and there are many guides online for things you can add/do to tweak your .vimrc for a specific use.
stackexchange-askubuntu
{ "answer_score": 1, "question_score": 2, "tags": "vim, colors" }
Can "が" ever mark the direct object? A sentence in my book: > {} **** {}{}{}{}{}{}{} {}{}{}{}{}{}{}{} The very start of the sentence reads: _" **** ...."_ Why is the "" instead of " **** "? Isn't "" the direct object of ""?
is a relative clause. It has a gap in object position: > - - ~~~~ The gap is filled semantically by the following noun phrase : > ① ​ - - > ② [ - - ~~~~ ] These can be translated into English: > ① Kanji have a systematic relationship. > ② the systematic relationship [ _which_ kanji have ] The details are different in English because of articles and relative pronouns, but hopefully you can see the parallel: In example ① we have an independent clause (a complete sentence). In example ② we come up with a noun phrase by **relativizing** the clause; we pull out one of the arguments and turn it into the head noun that the clause modifies.
stackexchange-japanese
{ "answer_score": 4, "question_score": 0, "tags": "particle が, particle を, relative clauses" }
Neural network using Orange I'm using Orange Data Mining in a regression analysis applying Artificial Neural Network (ANN). Some works suggest defining the number of neurons in the input layer as the number of variables. The Orange ANN uses sklearn’s Multi-layer Perceptron algorithm (MLP); however, I can only set the number of neurons per hidden layer (e.g., 4, 3 and 2; tree layers with 4, 3 and 2 neurons). Should I assume a hidden layer as the input layer and set the number of neurons as variable numbers? Does the MLP set the input layer automatically?
I am not familiar with the software you are using, but the number of neurons on the input layer depends on the number of features in the data. What follows, the software can just count the columns and use them to set the number of neurons on the input layer. The hidden layer is not an input layer, it is unlikely for them to name things in a way that confuses those two types of layers.
stackexchange-stats
{ "answer_score": 1, "question_score": 0, "tags": "regression, neural networks, model selection" }
sending mail from localhost without gmail is it possible? I want to send emails using php mail() function using xampp on ubuntu. But its not sent. Please check my code. Do I need to set any email server like gmail for it or I can do it without gmail? <?php $address = "[email protected]"; $subject = 'Test email'; $body = 'If you can read this, your email is working.'; echo "Attempting to email $address...<br />"; if (mail($address, $subject, $body)) { echo 'SUCCESS! PHP successfully delivered email to your MTA. If you don\'t see the email in your inbox in a few minutes, there is a problem with your MTA.'; } else { echo 'ERROR! PHP could not deliver email to your MTA. Check that your PHP settings are correct for your MTA and your MTA will deliver email.'; } ?> If I use smtp gmail account, its sending mails but not using php mail() as I dont want to share my gmail credentials.
try this: How to configure XAMPP to send mail from localhost? You can use other mail services, not only gmail. Later, when you have your own server, install your mail server :)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, email, ubuntu, smtp, sendmail" }
How to address the artifact I want to upload? I am using Actions to compile an executable and then upload it: name: note on: push jobs: cli: runs-on: windows-latest defaults: run: working-directory: ./cli steps: - uses: actions/checkout@master - run: go build -v - run: dir - name: upload cli.exe uses: actions/upload-artifact@v2 with: name: cli.exe path: cli.exe This results in: ![enter image description here]( The `dir` command shows that `cli.exe` is there, but it seems that I do not address it correctly for the upload. How to fix that?
The path of the upload must be provided from the root of the checked-out repo. In my case, the upload section needs therefore to be - name: upload cli.exe uses: actions/upload-artifact@v2 with: name: cli.exe path: cli/cli.exe In other words, `actions/upload-artifact` does not take into account the `working-directory` setting.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "github, github actions" }
Mainting Identity value across multiple tables We have a situation where we have a column called Customer_Number in multiple tables. This column is identity column in all the tables, but is there a way that I can make this column unique among all the tables. for example if I add a row in table_one and identity column assigns it value 1 now if someone add another row in Customer_Number column of table_two , table_three or table_four it should be assigned 2. how can I do this, I have been reading online and it seems I have to create a table to keep record of the last generated value for any of the table and get MAX() of values from that table and add 1 to it to get the next available value, is there a simpler way of doing this?
I have not used it myself but I think you need the new `Sequence Object` You would Create a Sequence Object and rather then using Identity values just get the next value from your sequence object. **Create Sequence Object** CREATE SEQUENCE Sqnc_Number_Generator AS INT --<-- This can be Bigint as well START WITH 1 -- Start with value 1 INCREMENT BY 1 -- Increment with value 1 MINVALUE 1 -- Minimum value to start is 1 MAXVALUE 50000 -- Maximum it can go to 5000 NO CYCLE -- Do not go above 5000 CACHE 500 -- Increment 500 values in memory rather than incrementing from IO **Getting Next value** SELECT NEXT VALUE FOR dbo.Sqnc_Number_Generator AS NxtValue; ## `SQL FIDDLE`
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 3, "tags": "sql server, tsql, sql server 2012, identity" }
How many Gluster Volumes is allowed in single server I have created one Gluster Volume sudo gluster volume create devshare transport tcp server1:/mnt/test GFS1 in server1 and able to mount the share on server2 sudo mount -t glusterfs server1:/devshare but when I tried to create a second volume in server1 and tried to mount in server2 it is not allowing the mount (so a total of two glustervolumes in one server). I am getting error message `endpoint is not connected`. Is it allowed to have two glustershare in one server?
There is not a limit on how many volumes you can have (not that I know of, and if it is, its pretty high). The error you are getting `endpoint is not connected` is FUSE's way of telling you its not able to communicate to the other server. This is normally down to a network interruption. Glusterfs doc here. I have in the past unmounted and remounted all shares and it has came back. This is also gluster way of fixing the issue. I am giving a broad answer, if this is still not fixing the issue I recommend you paste your volumes. Have a look at `gluster volume info`, make sure you can see volumes on both servers etc.
stackexchange-serverfault
{ "answer_score": 2, "question_score": 1, "tags": "linux, network share, glusterfs" }
I Made Tow function in pymongo but the out but that i want is different from i get from the function any ideas how can i fix it? Funtion that save Close,Symbol, Timeframe def Save_(self,collection,symbol,price,TF): db = self.get_db('MTF')[collection] B = {'ts':time.time(),"Symbol":symbol, "Price":price,'TimeFrame':TF} data = db.insert_one(B) return data Function to get data from mongodb def find_all(self,collection): db = self.get_db('MTF')[collection] Symbols ={} data = db.find({}) for i in data: Symbols[i['Symbol']] = [i['Price'],i['TimeFrame']] return Symbols images from mongodb [2]: < images from B Function [1]: < if u see the image from Function B only gave me on timeframe but Function Save have 4 timeframe
Looking at this loop: for i in data: Symbols[i['Symbol']] = [i['Price'],i['TimeFrame']] If you have the same `Symbol` coming from MongoDB, it will overwrite any previous value, so you will only get the final value for each Symbol which is what you are seeing. To fix it you have a few options: you could check the key and either create or append the values to Symbols; or you could use `$push` in an aggregate query.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python, python 3.x, mongodb, pymongo" }
How to print firebird triggers? I would like to print the contents of all the triggers from a firebird database. I have a firebird database with 20 fields and 56 triggers, and each trigger is about 10 to 20 lines of sql code. Is there any gui software able to do this, or an sql command able to SELECT all triggers and then export them as txt file?
Use the IBExpert Tools menu, "Extract Metadata": extract Triggers only and save resulting file to *.txt or *sql. Described here: < Alternatively use the IBExpert Tools menu, "Generate HTML Documentation": generate for Triggers only. This provides an HTML result. Described here: <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 3, "tags": "printing, triggers, firebird" }
CouchDB and Node.js - What module do you recommend? What modules are you using to connect to your CouchDB server, in your Node.js applications? And why would you recommend whatever module you are using?
Try to look at nano which offers simple and minimalistic API for CouchDB or high-level client cradle.
stackexchange-stackoverflow
{ "answer_score": 50, "question_score": 79, "tags": "node.js, couchdb" }
How do you reset a sequential count in R? I'm grouping time data and adding a sequential count... so first set of times is 1, second set 2, etc. This works as expected: df %>% group_by(time) %>% mutate(seq = cur_group_id()) %>% ungroup() I would like to be able to group by date and time, and have the count reset when a new date is reached like this: tribble( ~date, ~time, ~seq, "01/01/21", "11:00", 1, "01/01/21", "11:00", 1, "01/01/21", "12:00", 2, "01/01/21", "12:00", 2, "01/01/21", "1:00", 3, "01/01/21", "1:00", 3, "02/01/21", "10:00", 1, "02/01/21", "10:00", 1 ) Thank you.
We can group by 'date' and use `match` on the `unique` elements of 'time' library(dplyr) df %>% group_by(date) %>% mutate(seq = match(time, unique(time))) %>% ungroup() -output # A tibble: 8 x 3 # date time seq # <chr> <chr> <int> #1 01/01/21 11:00 1 #2 01/01/21 11:00 1 #3 01/01/21 12:00 2 #4 01/01/21 12:00 2 #5 01/01/21 1:00 3 #6 01/01/21 1:00 3 #7 02/01/21 10:00 1 #8 02/01/21 10:00 1
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "r, dplyr" }
Error while looping and displaying content I have an array as below: values = [ {"name": "John","value":1}, {"name": "Miller","value":2} ]; My DOM code <table> <tr *ngFor ="let finalvalue of values"> <td width="55">{{finalvalue.name}}</td> <td width="55"><input type="text"[(ngModel)]="finalvalue.value"/></td> </tr> </table> Expected : John 1 Miller 2 Actual : John 2 Miller 2 Whatever is my final value it is getting shown across all the names on UI. What could be the reason for this? How can I resolve it? Here instead of `input` tag if I use a `label` and display the value then I am getting the result as expected.
Ah, sorry, wrong version of Angular in my first answer. Please see the following snippet that I cloned from another example that does what you're looking for: < Do you have the following imports/declarations declared, `FormsModule`, etc.: @NgModule({ imports: [ BrowserModule, FormsModule ], declarations: [ AppComponent ], bootstrap: [ AppComponent ] })
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "html, angular7, ngmodel" }
difference between the data type and style in the PLC controller tag database I have noticed that few of BOOL datatype tags are of Binary style (which is anticipated) and most are of Decimal (which is surprising). Does anyone know the difference? Thanks,
The value of a variable can be displayed in different **radix** representations. For a datatype BOOL, selecting any radix binary, decimal, octal or hexadecimal will result in the display showing 0 and 1. For datatype DINT or WORD, selecting decimal, octal or hexadecimal will result in the display showing the value in those terms. For example, the value sixteen will be displayed in radix decimal as 16, in radix octal as 20 and in radix hexadecimal as 0F. To answer your question, there is no useful difference in displaying radix binary or radix decimal of a variable of the datatype BOOL.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "binary, boolean, decimal, plc" }
Trying to prove $\sum_{i=1}^{N} i^3 = (\sum_{i=1}^{N} i)^2$ I'm trying to prove $\sum_{i=1}^{N} i^3 = (\sum_{i=1}^{N} i)^2$ but I got stuck along the way. This is what I have so far: The base case is true when $N =1$. Then for the inductive step I did: Assume $\sum_{i=1}^{N} i^3 = (\sum_{i=1}^{N} i)^2$ is true for $1 \leq k \leq N$. Prove $\sum_{i=1}^{N+1} i^3 = (\sum_{i=1}^{N+1} i)^2$. $LHS = \sum_{i=1}^{N+1} i^3$ $\hspace{25pt}= (\sum_{i=1}^{N} i^3) + (N+1)^3$ $\hspace{25pt} = (\sum_{i=1}^{N} i)^2 + (N+1)^3$ (by induction) $\hspace{25pt} = \hspace{5pt}?$ From there I'm not sure how to do the proper conversions into equation/sigma notation to prove the right side. Can anyone help me on how to do this? Thanks.
\begin{align} \\\ k = N \\\ Assume \sum_{i=1}^{N} i^3 = (\sum_{i=1}^{N} i)^2 \\\ \\\ k = N+1 \\\ LHS = \sum_{i=1}^{N+1} i^3 \\\ = (\sum_{i=1}^{N} i^3) + (N+1)^3 \\\ \\\ RHS = (\sum_{i=1}^{N+1} i)^2 \\\ = [\sum_{i=1}^{N} i +(N+1)]^2 \\\ = (\sum_{i=1}^{N} i)^2+2(\sum_{i=1}^{N} i)(N+1)+(N+1)^2 \\\ = (\sum_{i=1}^{N} i)^2+2({N(N+1) \over 2})(N+1)+(N+1)^2 \\\ = (\sum_{i=1}^{N} i)^2+N(N+1)^2+(N+1)^2 \\\ = (\sum_{i=1}^{N} i)^2+(N+1)^2(N+1) \\\ = (\sum_{i=1}^{N} i)^2+(N+1)^3 \\\ = LHS \end{align} Prove by induction.
stackexchange-math
{ "answer_score": 1, "question_score": 2, "tags": "proof verification, induction" }
Python String of Hex to Hex (with leading zeros) I have some issue with hex conversion in Python. I have a string that represents a hex number - `"02"` and I want to convert it to `0x02` and to join it to another hex number. My code: valToWrite1 = '\x3c' valToWrite2 = '02' I want to join those 2 values so that my result will be `"\x3c\x02"`. It's important to keep the leading zeros.
You need `binascii.unhexlify()`: >>> import binascii >>> binascii.unhexlify("02") '\x02' >>> '\x3c' + _ '<\x02'
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 4, "tags": "python, string, python 2.7, python 3.x, hex" }
In Next.js is there a way to determine if if scrollRestoration was used, or even if the back button was used? I am using the `scrollRestoration` feature of Next.js to restore the page position when a back button is pressed. The problem, is that it doesn't restore the horizontal scroll position of the carousels on that page. So I have created my own session variables to track the position of each carousel and restore them on page load. The problem, is that I ONLY want to restore these scroll positions if the back/forward button was pressed. If there is an indicator that `scrollRestoration` was used on the page I could use that, otherwise, if there is an indication that the page was visited using the forward/back buttons that would also solve it. Any ideas?
i have figured out how to determine if scrollRestoration is set for a page. React.useEffect(() => { const hasScrollHistory = sessionStorage.getItem(`__next_scroll_${window.history.state.idx}`); if (hasScrollHistory) { // do your restore logic here } }, []);
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "javascript, routes, next.js" }
how to get near records in sails.js how can we get the nearest records for implementing next and previous record view in sailsjs? is there any built in method for this? e.g. if i have retrieved a single record with id=10, how to get the neighbouring records like record with id=9 and id=11. Regards
Lets assume your records have either sequential primary Key or a createdAt timestamp. Pick either one of these columns/keys can lets call it REFERENCE_FIELD. Next record = Records .findOne() .where({'REFERENCE_FIELD' : {'>':CURRENT_RECORD.REFERENCE_FIELD}}) .sort('REFERENCE_FIELD') .exec(); Previous record = Records .findOne() .where({'REFERENCE_FIELD' : {'<':CURRENT_RECORD.REFERENCE_FIELD}}) .sort('REFERENCE_FIELD desc') .exec();
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -2, "tags": "javascript, node.js, sails.js" }
proving a sum of binomial coefficients How can i prove that $\displaystyle\sum_{k=0}^{n}{2n\choose 2k}=2^{2n-1}$ I tried using induction and pascal's identity but it didn't help me.
We know:$$ (1+x)^{2n}=\sum_{j=0}^{2n}{2n \choose j}x^j$$ Now put $x=1$ and and $x=-1$ in turn and add, $\displaystyle 2^{2n}=(1+1)^{2n}+(1-1)^{2n}=\sum_{j=0}^{2n}{2n \choose j}+\sum_{j=0}^{2n}{2n \choose j}(-1)^j=\sum_{j=0}^{n}{2n \choose 2j}+\sum_{j=0}^{n-1}{2n \choose 2j+1}+\sum_{j=0}^{n}{2n \choose 2j}-\sum_{j=0}^{n-1}{2n \choose 2j+1}=2\sum_{j=0}^{n}{2n \choose 2j}$ $\displaystyle \Rightarrow 2^{2n-1}=\sum_{j=0}^{n}{2n \choose 2j}$
stackexchange-math
{ "answer_score": 10, "question_score": 2, "tags": "discrete mathematics, binomial coefficients" }
how to terminate parent function execution in javascript? I need to override some behaviour of function, that goes after it calls other function. The problem is that this parent function is a library and I dont want to change it, so solutions like make some flag or another change of this function is not so good. I know that I got an caller object in function that I can change, so maybe I can figure out smth with it. Heres the example: function parent() { console.log("some need stuff"); some.handler.function.from.config.that.i.can.change(); console.log("need omit this right till the end"); } function child() { console.log("need to somehow stop evaluation of " + child.caller + " function"); } As a ruby programmer I know there is lambdas with which you can terminate evaluation from inner scope of closure. But Im not sure how to do this from javascript.
You can't do that directly. (Moreover `.caller` is obsolete) You can however use a dirty trick: try{ parentFunction();//calls child }catch(e){ //done } function child(){ doWhatever(); throw new Error("this will hopefully propagate"); } ### Fiddle This will only work assuming the parent does not catch exceptions itself when calling the child. Moreover, it is generally a bad idea to use exceptions for flow control. Use this as a last resort.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 1, "tags": "javascript, closures, evaluation" }
mod_rewrite http_host How can I prevent access to a subdirectory based on HTTP_HOST. I have 2 parked domains pointing to one directory. They both serve up the same website. However I wish each to have a seperate wordpress blog. To do this I'm installing them in different directories. domain1.com/domain1-blog/ domain2.com/domain2-blog/ The trouble is the directories are accessible across domains. For instance domain1.com/domain2-blog/ domain2.com/domain1-blog/ I REALLY don't want people to be able to access across domains. Wordpress will break and I will get duplicate content issues in Google. What is the EXACT code I need to put into my htaccess file to serve up a 404 error should anyone try to access domain1.com/domain2-blog/ OR domain2.com/domain1-blog/ I thought maybe using HTTP_HOST combined with mod_rewrite somehow? I'm a big newb when it comes to htaccess, so the more explicit you can be the better. Thanks
Try adding the following to your htaccess file in the root directory of your domain RewriteEngine on RewriteBase / #if its domain1 RewriteCond %{HTTP_HOST} domain1\.com$ [NC] #and the request is for domain2 blog RewriteCond %{REQUEST_URI} ^/domain2-blog/ [NC] #send a 403 forbidden RewriteRule . - [F,L] #if its domain2 RewriteCond %{HTTP_HOST} domain2\.com$ [NC] #and the request is for domain1 blog RewriteCond %{REQUEST_URI} ^/domain1-blog/ [NC] #send a 403 forbidden RewriteRule . - [F,L]
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "wordpress, .htaccess" }
How to create an UI Designer utility? I need to create an utility where user can create their own data entry screen. The user should be able to drag and drop normal UI controls (`TextBox`, `RadioButton`, `CheckBox`, `ListBox`, `ComboBox` and `Image`) to any container and arrange them to fit their need. The user must be able to change the background and default values (for `TextBox`, `ComboBox`, etc). There should be an option to save the designed screen in either XML/XAML to be used for dynamic UI Creation. Any suggestions on how to approach this scenario are greatly appreciated.
I am also working on a similar project and we have used `Canvas` as designer surface; as done in this CodeProject article - > WPF Diagram Designer - Part 4 < One more project based on this can be found at codeplex- > <
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 4, "tags": ".net, wpf, xaml" }
drag and drop environment to start developing in gwt is there any drag and drop environment to work with GWT widgets. or any user friendly IDE or plugin on IDE's i remember using some thing like MyEclips for developing Hibernate was better then working with .xml files.
The Eclipse-based WindowBuilder Pro supports GWT and is now free, courtesy of Google.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "eclipse, gwt, netbeans, smartgwt, gwt widgets" }
How can I maintain selection in a list between page switches? I have a sharepoint list with many items spread across multiple pages. In AllItems.aspx form, when I select some items, switch to the next page and then go back to the previous page I need those items to stay selected. Can someone, please, give me a clue on how to implement this?
If it's list paging, your best solution really is to just set the item limit to 1000 (or whatever number will always be greater than the number of list items you're displaying) and deal with it. If you can't accept having that large of a list on your page, you should look into writing your own paging function (probably easiest with jQuery) that'll hide list items client-side when they're not on the current page. Set the view's item limit to 1000 (or whatever) and then on page load hide items 11-1000. Then add your paging links/buttons either at the end of the table or in a content editor web part immediately below your list. Paging would show/hide appropriate items/rows, and in theory it wouldn't break SharePoint's JavaScript that handles selecting items.
stackexchange-sharepoint
{ "answer_score": 0, "question_score": 0, "tags": "list" }
After being unplugged when I turn on computer it quickly turns off and back on again I have a desktop that I leave on and plugged in 95% of the time. But lately I have noticed that if I turn it off and unplug it/flip the switch on the power supply, when I turn it back on it powers on for a second, then shuts down, then powers right back up normally. When it first powers on it doesn't seem to get into POST, I don't hear any beeps or codes, and it is only on for maybe a second or two. When it immediately powers back on it goes through POST, I get the single beep and then it boots up. This is the only thing that is "off" about the PC. It runs great and I have never had any problems. I doubt this is normal behavior, what could be going on?
If the PC is a bit older it might be that the BIOS battery is empty: When you start the PC it detects that the BIOS settings are not set and the PC is loading the default values and then restarts to apply them. When changing BIOS settings is is not uncommon that after saving BIOS settings, the PC completely powers off and some seconds later restores power to finally boot with all the new settings active. I assume this behavior is because some BIOS settings are only applied on a cold boot, or the mainboard manufacturer want to make sure that all components are reset.
stackexchange-superuser
{ "answer_score": 1, "question_score": 1, "tags": "windows 10, boot, desktop computer" }
sending parameters to a function in cpp Is it possible to have a call for a function like this: test({22,11}); and then decode the parameter (and their type) in the function declaration? for example: void test(int *a){...}
I don't know what you mean with "decode the parameter", but you can certanly have `test({22,11});`. #include <initializer_list> void test( std::initializer_list<int> params ) { for (int i : params) std::cout << i << ' '; }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "c++, function" }
Tricky predicate logic problem I'm having a hard time proving that this is a valid argument $Premise 1: (Ǝx)Kx→(\forall x)(Lx→Mx)$ $Premise 2: Kc • Lc$ $Conclusion: Mc$ I am getting confused with all the existential/universal instantiation rules. First I did: $Kc\to\forall x(Lx\to Mx)$ by existential instantiation then $Kc\to Lc\to Mc$ by universal instantiation therefore $Mc$ Is there anywhere where I'm supposed to infer modus ponens since I've already been given Kc and Lc in premise 2??
_Hint_ : assuming you are using _Natural Deduction_ ... From _Premise-2_ : $Kc \land Lc$ you have to derive $Kc$ (by $\land$-elimination), followed by $\exists x Kx$ (by $\exists$-introduction). In this way, you can use $\to$-elimination (i.e. _modus ponens_ ) with _Premise-1_ and derive : $(∀x)(Lx \to Mx)$. Now you have to use $\forall$-elimination (i.e. _universal instantiation_ ) with $c$ to get : $Lc \to Mc$.
stackexchange-math
{ "answer_score": 3, "question_score": 2, "tags": "predicate logic, formal proofs" }
What does a high number of rx_crc_errors indicate? When running ethtool I notice a very high level of rx_crc_errors. When the server is under heavy load the counter goes even higher. What does this typically point to as the source of the problem? Media or cable issues?
Typically errors of this type (errors that indicate bad data integrity) are the result of layer 1 problems. I'd investigate cabling and the physical layer interface first.
stackexchange-serverfault
{ "answer_score": 4, "question_score": 2, "tags": "ethtool" }
Xcopy - Trying to copy a folder with certain arguments to another location I'm trying to xcopy certain folders from a directory of 5000 folders, that start with the number 9097* Approx 2000 folders start with 9097. for /f %%A in ('DIR /b /a:D') do ( set temp=%%A set ID=!temp:~0,4! if !ID!==9097 xcopy *!ID!* F:\%INPUT% /S /i My problem is that when it finds the first folder starting with 9097, the code then goes and copies all contents of all the folders, I want it to only copy the 9097 folders. I understand why the code above is doing what it is doing but I can't seem to think of the way for it to just copy the folders and contents starting with 9097. Any advice would be greatly appreciated.
for /d %%a in (9097*) do xcopy "%%~fa" "f:\%input%\%%~nxa" /s /i For each folder with a name starting with `9097`, `xcopy` from the full path of the source folder to the target inside a folder with the name and extension of the source folder.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "batch file, cmd, xcopy" }
Icon along text I got icons and I got text next to it. When I make the screen smaller to around 431px it puts the word underneath the logo see the upper section called flexibel how can I align it that the text stays next to my logo? Take a look at bastiaanbos.ch for the website itself and the code.
You have many ways to achieve this. 1) You can use a layout framework like Bootstrap and harness the grid functionality. For example: <div class="row"> <div class="col-md-2">The icon</div> <div class="col-md-10">The text</div> </div> 2) You can go a rather "hacky" way and use `html tables`. 3) Worst case scenario: Apply `height` to the first `div`.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -5, "tags": "html, css" }
Not Able to Connect JDBC-Hikari To my Micronaut App Error I am Getting after running `sudo ./gradlew run` : > Task :run FAILED 12:03:13.440 [main] ERROR com.zaxxer.hikari.HikariConfig - Failed to load driver class com.mysql.jdbc.Driver from HikariConfig class classloader jdk.internal.loader.ClassLoaders$AppClassLoader@3d4eac69 12:03:13.445 [main] ERROR io.micronaut.runtime.Micronaut - Error starting Micronaut server: Bean definition [javax.sql.DataSource] could not be loaded: Error instantiating bean of type [javax.sql.DataSource] How my Application.yml looks like : * * * micronaut: application: name: freshdb2 * * * #datasources.default: {} datasources: default: url: jdbc:mysql://localhost:3306/mydb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE username: root password: "" driverClassName: com.mysql.jdbc.Driver
You are missing driver, you should add dependency `mysql-connector-java`, for gradle add: runtime group: 'mysql', name: 'mysql-connector-java', version: '8.0.13'
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "java, jdbc, hikaricp, micronaut, sql2o" }
Why is std::string incompatible with C unions? > **Possible Duplicate:** > Why compiler doesn't allow std::string inside union ? I knew that I had this problem when I started with C++: The compiler wouldn't allow me to put a variable of the type `std::string` into unions. That was years ago, but actually I still don't know the exact answer. I read something related to a copy function with the string that the union didn't like, but that's pretty much all. * Why are C++ STL strings incompatible with unions?
From Wikipedia#C.2FC.2B.2B): > C++ does not allow for a data member to be any type that has a full fledged constructor/destructor and/or copy constructor, or a non-trivial copy assignment operator. In particular, it is impossible to have the standard C++ string as a member of a union. Think about it this way: If you have a union of a class type like `std::string` and a primitive type (let's say a `long`), how would the compiler know when you are using the class type (in which case the constructor/destructor will need to be called) and when you are using the simple type? That's why full-fledged class types are not allowed as members of a union.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 3, "tags": "c++, string, unions" }
C# Развёртка WebAPI Расскажите как правильно развернуть WebAPI. Пробовал на хостинге, но там оказывается нет поддержки asp скриптов, так как он не на windows server, после попытался развернуть его на пк собственном сервере(пк), с прокинутами портами 443, но не получилось... так же если запускать webapi через exe, почему то он запускается со стандартами портами 5000-5001, а когда через компилятор, то уже с моими указанами портами в файле launchSettings.json (443)... Расскажите как правильно развернуть
Под Windows используй хостинг под IIS: < Под Linux можешь под Kestel хостить: < Там просто, опубликовал используя RID linux-x64, закинул в linux, создал демона который будет запуска и все - готово! (Не забудь установить dotnet runtime) Ну а самый лучший путь, это в docker контейнере под каким-нибудь apache, nginx или HAProxy: <
stackexchange-ru_stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "c#, asp.net core, asp.net web api, asp" }
Forward WSGI cookies to Requests I am developing a WSGI middleware application (Python 2.7) using Werkzeug. This app works within a SAML SSO environment and needs a SAML token to be accessed. The middleware also performs requests to other applications in the same SAML environment, acting on behalf of the logged in user. In order to do that without the need of user feedback, I need to forward the SAML session cookie that I can get from the WSGI environment to requests that I am performing using the Requests library. My issue is that the cookies that I get from WSGI/Werkzeug can only be parsed as http.cookies.SimpleCooke , while Requests accepts cookielib.CookieJar instances. I have not found a way to cleanly forward these session cookies without resorting to shameful hacks such as parsing the raw content of the set-cookie headers. Any suggestions? Thanks, gm
Cookies are just HTTP headers. Just use pull the cookie value from http.cookies.SimpleCookie, and add it to your requests session's cookie jar. Not a hack. :)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python, python requests, session cookies, saml, wsgi" }
Run GNU parallel commands in different folders I'm trying to run commands in parallel. But these commands need to be run in different directories. How can I achieve this? Can I do something like this: parallel ::: 'cd platform1 && npm install && npm run build-all' 'cd platform2 && npm install && npm run build-prod'
#!/bin/sh (cd platform1 && npm install && npm run build-all && touch flag.1) & (cd platform2 && npm install && npm run build-prod && touch flag.2) & while [ !( -f flag.1 -a -f flag.2 ) ] do sleep 5 done # All the rest code #### Commands placed inside round brackets (or backticks) are launched inside subshell that is launched in background because of trailing `&`
stackexchange-serverfault
{ "answer_score": 0, "question_score": 0, "tags": "linux, xargs" }
Comma/Semicolon Argument Grammatically, should the comma after "June 28" and before "an" be a comma or a semicolon in the example below? > Refunding bonds for Improvement Area No. 1 of Community Facilities District No. 3 were sold Tuesday, July 27, after Council’s approval on **June 28, an action** which supports the city’s Mission as well as the organizational value of stewardship. Thanks!
The Oxford Dictionary of American Usage and Style clearly explains that the use of semicolon (usually described as a super comma) is meant for 'a distinct break than a comma can signal.' It also makes it clear that a semicolon is called for when we have to separate, 'clauses of similar importance and grammatical construction.' In this case, the first part is a main clause and a full-fledged sentence in its own right. The second part is not a main clause and is joined with the first part only as an explanatory addition. As such, this does not call for a semicolon. The comma would do.
stackexchange-english
{ "answer_score": 0, "question_score": 1, "tags": "commas, semicolon" }
how to perform events when a checkbox is checked/unchecked in jquery I have the following jquery code which works fine. $('#onlyTwo').click(function() { $("#textarea3").attr("disabled", true); $("#textarea4").attr("disabled", true); $("#radio3").attr("disabled", true); $("#radio4").attr("disabled", true); return true; }); This is making some fields disabled when 'onlyTwo' checkbox is clicked. How can i make these fields enabed again when 'onlyTwo' checkbox is unchecked... basically i want to know how to find out whether a checkbox is checked or not
or $('#onlyTwo').click(function(){ var stuff = $("#textarea3, #textarea4, #radio3, #radio4"); stuff.attr("disabled", $(this).is(":checked")); });
stackexchange-stackoverflow
{ "answer_score": 18, "question_score": 10, "tags": "jquery" }
Distribute 6 inputs to 9 outputs with pipes I have the task to connect 6 input sources of fluid with 9 output (sinks) sources. Each input should be connected to each output. Each input should be able to distribute the fluid to only 1 output at a time. I have straight pipes, Y connections and valves, that I can use. I should use the MINIMUM amount of valves and Y connections as possible. **Is there a standard approach to reducing the number of components required for a design like this?** * * * This is the best I could get to so far: !enter image description here
As mentioned in the comments, I think it is possible to do it with 15 valves (1 per inlet and 1 per outlet) and 13 Y connections as shown below: !enter image description here
stackexchange-engineering
{ "answer_score": 1, "question_score": 1, "tags": "fluid mechanics, pipelines" }
C++ Switching lines off and on I am using VS2010 C++. For debugging reasons I have commented out lines like this: ms+=t.getElapsedTimeInMicroSec(); became //timer:ms+=t.getElapsedTimeInMicroSec(); Now when I want to include all timer lines, I do a simply text replace and replace all "//timer:" with an empty string, and all these lines become active again. But there is no way to include the "//timer:" on all lines again. I could use #ifdef _MYVAR ms+=t.getElapsedTimeInMicroSec(); #endif instead, but that would make my code much less readable. Is there a simply solution for my problem, for example a switch that I put in front of each line to activate or deactive the lines?
/*timer*/ // ms+=t.getElapsedTimeInMicroSec(); Now you can search and replace `"/*timer*/ //"` with `"/*timer*/"`. Then later, search and replace `"/*timer*/"` with `"/*timer*/ //"`.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "c++, windows, visual studio 2010, ide" }
serenity.use.unique.browser doesn't work on 1.2.2 I have recently updated my dependencies and this seems to have broken serenity.use.unique.browser as a new browser is used for each scenario now. I'm using serenity junit 1.2.2 and cucumber 1.1.23. It was working ok before I updated to these versions.
In 1.2.2 onwards you need to use the `serenity.restart.browser.for.each` property, e.g. ` serenity.restart.browser.for.each = feature ` You can set this property to scenario, story, feature, or never
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "selenium, serenity bdd, thucydides, cucumber serenity" }
24 people in 3 different hotels If I were to place 24 people in three different hotels (8 people at each hotel). How many ways are there to do this? First and foremost I understand that this is a combination problem, (having a hard time adjusting to permutation and combinations but have finally understood that permutation is when the order counts) So how would I go on solving this problem? Am I doing this correct? 24 C 8 = 24!/(8! x !16) = 735471 ways?
First you need to choose $8$ from the $24$ people to stay in the first hotel and then you choose $8$ from the remaining $16$ for staying in the $2$nd hotel. The tenants of the $3$rd hotel are fixed by the first two choices. So, total number of such ways will be $\binom{24}{8} \times \binom{16}{8} = \frac{24!}{(8!)^3}=9465511770$.
stackexchange-math
{ "answer_score": 0, "question_score": 0, "tags": "combinatorics, algebra precalculus, permutations, combinations" }
Adding 2d arrays to 1d arrays How can I add a 2d array into 1d array in java? Whenever I try to do that this message pops up: Type Mismatch: cannot convert from char[][] to char This is my code:: int numberOfCases = Integer.parseInt(scanner.nextLine()); char[] grids = new char[numberOfCases]; for(int i = 0; i < numberOfCases; i++) { while(scanner.hasNext()) { int gridDimensions = Integer.parseInt(scanner.nextLine()); grids[i] = new char[gridDimensions][gridDimensions]; } } Please help or give an alternative to what I am doing.
Make your `grids` variable three-dimensional: char[][][] grids = new char[numberOfCases][][]; Then, you should be able to add your two-dimensional array into this `grids` array.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "java, arrays, multidimensional array" }
Can we use select to Accept() from different listeners in Go? Just as the following codes: for { select { case conn, err := listener1.Accept(): if err != nil { log.Fatal(err) } go handleConn1(conn) case conn, err := listener2.Accept(): if err != nil { log.Fatal(err) } go handleConn1(conn) } } While the editor tells me something wrong with `select` Can we implement something like this in **Go**?
`select` only works with channels (see more here: < In your case, you could span two goroutines so that each of them waits for the `Accept` of one listener and processes the connection: go func() { for { conn, err := listener1.Accept(): if err != nil { log.Fatal(err) } handleConn1(conn) } }() go func () { for { conn, err := listener2.Accept(): if err != nil { log.Fatal(err) } handleConn2(conn) } }()
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "go, goroutine" }
How to validate a Jtextfield to only allow letters in Java? Trying to make this field only allow letters and there is an error on the " (c !='[a-zA-Z]+') " saying invalid character constant textField_CustomerFirstName = new JTextField(); textField_CustomerFirstName.setBounds(152, 100, 273, 22); textField_CustomerFirstName.setColumns(10); contentPane.add(textField_CustomerFirstName); textField_CustomerFirstName.addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent e) { // allows only numbers and back space char c = e.getKeyChar(); if ( ((c !='[a-zA-Z]+') && (c != KeyEvent.VK_BACK_SPACE)) { e.consume(); // ignore event } } });
First, there is a difference between `event.getKeyChar()` and `event.getKeyCode()`. Second, you can use the static methods in java.lang.Character, and I believe you may be after the following: int code = e.getKeyCode(); char c = e.getKeyChar(); if(!Character.isLetter(c) && code!=KeyEvent.VK_BACK_SPACE) { e.consume(); // ignore event } You may also want to investigate whether `Character.isAlphabetic` is suitable for your purposes.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "java, validation, jtextfield" }
Equivalent condition for interpolation polynomial > Let $(x_1,y_1),...,(x_n,y_n)\in \mathbb{R}^2 $, where $x_i\neq x_j$ if $i\neq j$. Let $p$ be a polynomial such that $$\det\begin{pmatrix} p(x)& 1 & x & x^2 &\dots & x^n \\\ y_0 & 1 & x_0 & x_0^2 &\dots &x_0^n \\\ y_1 & 1 & x_1 & x_1^2 &\dots &x_1^n \\\ \vdots & & & & & \vdots \\\ y_n & 1 & x_n & x_n^2 &\dots & x_n^n \end{pmatrix}=0. $$ Then $p(x_k)=y_k ,\forall k=1,...,n$. My ideas: We should compute the determinant using Laplace's formula, although I can't see a nice pattern to do a proof by induction or to conclude the proposition. Thanks for the help bests bjn
**Hint.** Put $x=x_0$ and subtract the second row from the first row. The determinant is then equal to $$ \det\pmatrix{p(x_0)-y_0&0_{1\times(n+1)}\\\ \ast&V}=(p(x_0)-y_0)\det(V), $$ where $V$ is a Vandermonde matrix. In order that this is zero, ...
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "polynomials, determinant, interpolation" }
How to derive a general formula for unit vectors subtruction (which includes only the angles) Suppose I have two unit vectors: $v_1=(cos\phi_2,sin\phi_2),v_2 = (cos\phi_1,sin\phi_1)$ I want to find: 1. The (small) angle between them 2. The length of projection of $V_2$ on $V_1$ What is the mathematical expression for both calculations. I know how to do this calculations by a series of actions, but, whenever I try to write a general mathematical formula (not an algorithm) involving only $\phi_1,\phi_2$ I get confused. Any ideas? Thank you!
The vectors are obtained rotating the unitary vector $\vec u=(1,0)$, the first, $\vec v_1$, by an amount of $\phi_2$ and the second, $\vec v_2$, of $\phi_1$. The angle between them is then $\phi_2-\phi_1$ The projection of $\vec v_2$ on $\vec v_1$ is, given $\vert\vec v_1\vert=\vert\vec v_2\vert=1$: $$|\vec{v_2}|\cos\theta=\dfrac{\vec{v_1}.\vec{v_2}}{|\vec{v_1}|}=\vec{v_1}.\vec{v_2}=\cos\phi_2\cos\phi_2+\sin\phi_2\sin\phi_1=\cos(\phi_2-\phi_1)$$ As expected.
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "calculus, multivariable calculus, trigonometry, vector spaces, vectors" }
C programming pointers and arrays void main(){ char *const p="Hello"; p++; // causes error object p non modifiable } void main(){ char A[10]="ANSHU"; A++; // here causes lvalue problem } So, my question is, what is difference between these two programs and next question is that is array's declaration like this int *const A;
In `char *const p="Hello";` `p` is a `const pointer` to a (non-const) `char`. You can change the actual char, but not the pointer pointing to it. So, **It cannot point to any other memory location after its initialization.** Its important to note that in this statement, the initialization has to be done when declaring this pointer. In `char A[10]="ANSHU";` `A` is an array object and not a `pointer`. so you could not use the operation `A++` for an array object. In `int *const A;` **`A` is a const pointer to int**. So, Pointer cannot change, pointed to value can change.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c" }
How do I show the time of a process in minix, using the library time.h? time_t t; printf("%f\n",time(&t)); it throws "Can not print float number"
# Get Current Date time_t data type depends on your platform. To solve this issue, you can try to cast it to `long long`. And directly print it: printf("%lld\n", (long long) time(NULL)); # Measure time taken by a function or process If you want to calculate the time of a process or a function create a clock_t variable and calculate the difference: clock_t t; t = clock(); myfunction(); t = clock() - t; Note that `t` is the measured time value here.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -2, "tags": "c, process, output, minix, time.h" }
visualizing singularities of maps from sphere to R^2 Is there a classification of singularities from $S^2 \to \mathbb{R}^2$ ? The critical points of the map $(x,y) \mapsto (f_1(x,y),f_2(x,y))$ where the matrix: \\[ \left[\begin{array}{cc}\frac{\partial f_1}{\partial x} & \frac{\partial f_1}{\partial y}\\\\\\\ \frac{\partial f_2}{\partial x} & \frac{\partial f_2}{\partial y} \end{array} \right] \\] has less than full rank. Locally, can we draw a picture of what singularities look like? In the case of maps $S^2 \to \mathbb{R}^1$, we just get the critical points where $f(x,y) = f(x_0,y_0) + (x-x_0,y-y_0)^T (D^2 f )(x-x_0,y-y_0)$
I think you want to look at Guillemin and Golubitsky's book _Stable mappings and their singularities_ , which has a thorough description of what the singularity types of stable mappings are between surfaces. Basically, the only stable singularities for smooth maps between surfaces (i.e., $2$-manifolds) are folds and cusps, and these cannot usually perturbed away by small perturbations. If you don't restrict to stable mappings or some similar class, the kinds of singularities that can occur can be extremely complicated, and I doubt that there is any workable classification.
stackexchange-mathoverflow_net_7z
{ "answer_score": 8, "question_score": 4, "tags": "dg.differential geometry" }
High-Powered USB hub with no AC adapter driven by 2 USB inputs Is there any USB hub that is powered like some of the USB hard drives (connected to 2 ports at the same time). I want to avoid using AC adapter and use two USB ports to power a hub. Does anybody know any examples of such devices?
Do you mean like this: < (see all pictures)
stackexchange-superuser
{ "answer_score": 0, "question_score": 1, "tags": "usb, power" }