qid
int64
1
74.7M
question
stringlengths
15
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
4
30.2k
response_k
stringlengths
11
36.5k
2,396,782
Why doesn't php support this syntax: ``` $s = explode('-', 'foo-bar')[0]; ``` ?
2010/03/07
[ "https://Stackoverflow.com/questions/2396782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/288251/" ]
You can write it using [`list`](http://php.net/manual/en/function.list.php): ``` list($first_value) = explode(‘-’,‘foo-bar’); ```
Instead you could use this if you'r force to use inline : substr($var,0, strrpos($var,'-')); But I prefer the list solution , it's more elegant ! ---
140,102
I have a CRUD app for `<DomainObject>`s. They are persisted in a database. There is a new requirement: keep track of the `<DomainObject>`s that have been created since the app was opened, so that the user can see what he/she has done. I see three ways to implement this: 1. every time the app is opened, create a new ...
2012/03/16
[ "https://softwareengineering.stackexchange.com/questions/140102", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/-1/" ]
> > There is a new requirement: keep track of the s that > have been created since the app was opened, so that the user can see > what he/she has done. > > > I Don't fully understand you three ways But the correct way to do this is as follows. Every table in your system (The you want yo track) should have the fo...
All the projects I work on have audit data like you describe and its all handled through audit tables/composite keys with version numbers that are managed through SPs. It may seem like you are putting business logic in the database, but rules for maintaining history are more data management issues than true business lo...
140,102
I have a CRUD app for `<DomainObject>`s. They are persisted in a database. There is a new requirement: keep track of the `<DomainObject>`s that have been created since the app was opened, so that the user can see what he/she has done. I see three ways to implement this: 1. every time the app is opened, create a new ...
2012/03/16
[ "https://softwareengineering.stackexchange.com/questions/140102", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/-1/" ]
Maintaining an Audit table of denormalized `DomainObject` records with various user actions is the best bet. By flattening the object tree of `DomainObject` and storing all the data in an Audit table with user information and timestamps, then you have a complete history of all changes to `DomainObject`'s regardless of...
All the projects I work on have audit data like you describe and its all handled through audit tables/composite keys with version numbers that are managed through SPs. It may seem like you are putting business logic in the database, but rules for maintaining history are more data management issues than true business lo...
34,062,615
I have this : [![source case](https://i.stack.imgur.com/TfYWR.png)](https://i.stack.imgur.com/TfYWR.png) and what i want exactly is that to show portion of Bitmap via **coords**(X,Y) of object with OnTouchListener(orange **square** with dot in center). So the problem is that i want to draw portion of image like ...
2015/12/03
[ "https://Stackoverflow.com/questions/34062615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4793465/" ]
``` f1(std::string& descriptor) { if (descriptor.empty()) { encode(descriptor) } } void encode(std::string& descriptor) { // Change string here. } ``` Consider that I use `std::string` because you tagged the post with `c++` and not `c` and I don't see any reason to use `char*` instead of a `...
``` f1(char* descriptor) { if (strcmp(descriptor, "") == 0) { strcpy(descriptor, "new_name"); } ... encode(descriptor) } ```
34,062,615
I have this : [![source case](https://i.stack.imgur.com/TfYWR.png)](https://i.stack.imgur.com/TfYWR.png) and what i want exactly is that to show portion of Bitmap via **coords**(X,Y) of object with OnTouchListener(orange **square** with dot in center). So the problem is that i want to draw portion of image like ...
2015/12/03
[ "https://Stackoverflow.com/questions/34062615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4793465/" ]
If you are using C++, you should be using `std::string` or some variant. I'll assume you're using C, since your code is pure C. ``` if (strcmp(descriptor, "") == 0) { char d[9] ="new_name"; descriptor = d; } ``` This is wrong (and, believe me, very bad) because `d` becomes out of scope as soon as it gets ou...
``` f1(char* descriptor) { if (strcmp(descriptor, "") == 0) { strcpy(descriptor, "new_name"); } ... encode(descriptor) } ```
34,062,615
I have this : [![source case](https://i.stack.imgur.com/TfYWR.png)](https://i.stack.imgur.com/TfYWR.png) and what i want exactly is that to show portion of Bitmap via **coords**(X,Y) of object with OnTouchListener(orange **square** with dot in center). So the problem is that i want to draw portion of image like ...
2015/12/03
[ "https://Stackoverflow.com/questions/34062615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4793465/" ]
``` f1(std::string& descriptor) { if (descriptor.empty()) { encode(descriptor) } } void encode(std::string& descriptor) { // Change string here. } ``` Consider that I use `std::string` because you tagged the post with `c++` and not `c` and I don't see any reason to use `char*` instead of a `...
If you can assume: 1. `char* descriptor` points to a buffer of sufficient length: 2. Overwriting descriptor's buffer is entirely fine. Then you can do the single line: ``` encode(*descriptor:descriptor?strcpy(descriptor,"new_name")); ``` The ternary operator evaluates to `descriptor` if `*descriptor` is not null, ...
34,062,615
I have this : [![source case](https://i.stack.imgur.com/TfYWR.png)](https://i.stack.imgur.com/TfYWR.png) and what i want exactly is that to show portion of Bitmap via **coords**(X,Y) of object with OnTouchListener(orange **square** with dot in center). So the problem is that i want to draw portion of image like ...
2015/12/03
[ "https://Stackoverflow.com/questions/34062615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4793465/" ]
``` f1(std::string& descriptor) { if (descriptor.empty()) { encode(descriptor) } } void encode(std::string& descriptor) { // Change string here. } ``` Consider that I use `std::string` because you tagged the post with `c++` and not `c` and I don't see any reason to use `char*` instead of a `...
If you are using C++, you should be using `std::string` or some variant. I'll assume you're using C, since your code is pure C. ``` if (strcmp(descriptor, "") == 0) { char d[9] ="new_name"; descriptor = d; } ``` This is wrong (and, believe me, very bad) because `d` becomes out of scope as soon as it gets ou...
34,062,615
I have this : [![source case](https://i.stack.imgur.com/TfYWR.png)](https://i.stack.imgur.com/TfYWR.png) and what i want exactly is that to show portion of Bitmap via **coords**(X,Y) of object with OnTouchListener(orange **square** with dot in center). So the problem is that i want to draw portion of image like ...
2015/12/03
[ "https://Stackoverflow.com/questions/34062615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4793465/" ]
If you are using C++, you should be using `std::string` or some variant. I'll assume you're using C, since your code is pure C. ``` if (strcmp(descriptor, "") == 0) { char d[9] ="new_name"; descriptor = d; } ``` This is wrong (and, believe me, very bad) because `d` becomes out of scope as soon as it gets ou...
If you can assume: 1. `char* descriptor` points to a buffer of sufficient length: 2. Overwriting descriptor's buffer is entirely fine. Then you can do the single line: ``` encode(*descriptor:descriptor?strcpy(descriptor,"new_name")); ``` The ternary operator evaluates to `descriptor` if `*descriptor` is not null, ...
52,627,242
Let's say I have this example string: ``` String text = "Data/DataFrontEnd/src/pt/data,Data/DataBackEnd/src/pt/groove"; ``` And I want to get this string as a result of a replacement procedure: ``` String textreplaced = "**/src/pt/data,**/src/pt/groove"; ``` Basically, what I wanted was to replace all occurrence...
2018/10/03
[ "https://Stackoverflow.com/questions/52627242", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4446996/" ]
Use [positive lookahead](https://www.regular-expressions.info/refadv.html): ``` String text = "Data/DataFrontEnd/src/pt/data,Data/DataBackEnd/src/pt/groove"; System.out.println(text.replaceAll("([\\w/]+)(?=/src)", "**")); // **/src/pt/data,**/src/pt/groove ```
Here's an alternative non-regex based answer, in case anyone wants it: ``` String textreplaced = ""; String[] split = text.split(","); for (int i = 0; i < split.length; i++) { textreplaced += "**" + split[i].substring(split[i].indexOf("/src")); if (i != split.length - 1) { textreplaced += ","; } } ...
20,396,707
we developed an app mostly tested on a Galaxy Nexus. Now after some testing on other devices, we see that a dialog with title, some message and ok/cancel button on some devices (specially Nexus S) doesn't fit "wrap content". the Dialog is about 80% filled over the sreen it looks like: //start Title Border M...
2013/12/05
[ "https://Stackoverflow.com/questions/20396707", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648907/" ]
Okay, I got it. Using the first approach, Meteor throws a `ReferenceError`. This is due to the client-side simulation of the function. This feature is described in the documentation [here](http://docs.meteor.com/#meteor_methods). So the code works with both approaches, but when also being defined on the client, it thr...
I think you might just need a var serverVar; at the very top (shared)
20,396,707
we developed an app mostly tested on a Galaxy Nexus. Now after some testing on other devices, we see that a dialog with title, some message and ok/cancel button on some devices (specially Nexus S) doesn't fit "wrap content". the Dialog is about 80% filled over the sreen it looks like: //start Title Border M...
2013/12/05
[ "https://Stackoverflow.com/questions/20396707", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648907/" ]
dont use Meteor.isServer() > > Meteor.isServer can be used to limit where code runs, but it does not > prevent code from being sent to the client. > > > [check this answer](https://stackoverflow.com/questions/10122977/what-are-the-best-practices-for-structuring-a-large-meteor-app-with-many-html-te) to structure...
I think you might just need a var serverVar; at the very top (shared)
73,151,074
Having some trouble after a few hours wrapping my head around what I'm doing wrong with this TS signature. **I'm writing a group by function:** ``` const group = <T>(items: T[], fn: (item: T) => T[keyof T]) => { return items.reduce((prev, next) => { const prop = fn(next) as unknown as string; return { ...
2022/07/28
[ "https://Stackoverflow.com/questions/73151074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2180105/" ]
I notice that "admin" and "user" can only be obtained from the values of the data array (possible values of `data[number]['type']`). TypeScript by default won't assume much from the values other than the values are strings. (The situation for 'type' and 'name' is different as they are obtained from keys) But if you...
In your function signature you do not specify the return type of the function. You just need to make the return of type T like this : ``` const group = <T>(items: T[], fn: (item: T) => T[keyof T]):T => { return items.reduce((prev, next) => { const prop = fn(next) as unknown as string; return { ...prev, [prop]: pre...
5,905,068
I'm creating a Rails app with an iOS client and found [ObjectiveResource](http://iphoneonrails.com/). It looks awesome for CRUD operations, but it hasn't been updated since 2009 so it seems built for rails2 and the first iphone sdk. Does anyone know of a similar but up to date framework?
2011/05/05
[ "https://Stackoverflow.com/questions/5905068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/584432/" ]
Everybody's talking about [Restkit](http://restkit.org/) these days. I haven't tried it yet myself, though.
You could have a look here: <https://rhomobile.com/> It enables you to code mobile apps with a framework made in ruby and very close to Rails. Apps are compatible with most smartphones.
5,905,068
I'm creating a Rails app with an iOS client and found [ObjectiveResource](http://iphoneonrails.com/). It looks awesome for CRUD operations, but it hasn't been updated since 2009 so it seems built for rails2 and the first iphone sdk. Does anyone know of a similar but up to date framework?
2011/05/05
[ "https://Stackoverflow.com/questions/5905068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/584432/" ]
Everybody's talking about [Restkit](http://restkit.org/) these days. I haven't tried it yet myself, though.
Anybody ever used ASIHTTPRequest? Ill be experimenting with it next view hours. <http://allseeing-i.com/ASIHTTPRequest/>
5,905,068
I'm creating a Rails app with an iOS client and found [ObjectiveResource](http://iphoneonrails.com/). It looks awesome for CRUD operations, but it hasn't been updated since 2009 so it seems built for rails2 and the first iphone sdk. Does anyone know of a similar but up to date framework?
2011/05/05
[ "https://Stackoverflow.com/questions/5905068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/584432/" ]
You could have a look here: <https://rhomobile.com/> It enables you to code mobile apps with a framework made in ruby and very close to Rails. Apps are compatible with most smartphones.
Anybody ever used ASIHTTPRequest? Ill be experimenting with it next view hours. <http://allseeing-i.com/ASIHTTPRequest/>
2,496,004
We are considering the made up words opsure and clinterior, where the opsure of a set $A$ is the smallest open set containing $A$ and the clinterior of a set $B$ is the largest closed set contained in $B$. I am tasked with the following: > > Give an example a set $X$ which does not have an opsure, and give an examp...
2017/10/30
[ "https://math.stackexchange.com/questions/2496004", "https://math.stackexchange.com", "https://math.stackexchange.com/users/378351/" ]
**Hint** For a set that has no oposure, consider $[0,1].$ For a set that has no clinterior, consider $(0,1)$. The "key reason" has to do with the fact that intersections of open sets are not necessarily open and unions of closed sets are not necessarily closed.
I assume that you define smaller as $A$ is smaller than $B$ if $A\subsetneq B$ and the smallest set of a family is a set that is smaller than any other set in the family. You should probably start with the reason a set always have an interior and closure to see where this reason breaks down for clinterior and opsure....
11,416,019
**Question:** I'm trying to use PetaPoco to join more than four tables to populate an object of type A with five members of type B (very similiar to this question: <https://stackoverflow.com/a/11275334/296296>). From what I've read it would be possible to use this syntax: ``` var result = db.Query<Investment>(new Syst...
2012/07/10
[ "https://Stackoverflow.com/questions/11416019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/296296/" ]
You need to create a system variable for ANDROID\_HOME, not set it in your PATH.
You need to set the Android Development Tools SDK Location path in Eclipse: click on Window -> Preferences and select Android. The SDK Location can be set under Android preferences.
11,416,019
**Question:** I'm trying to use PetaPoco to join more than four tables to populate an object of type A with five members of type B (very similiar to this question: <https://stackoverflow.com/a/11275334/296296>). From what I've read it would be possible to use this syntax: ``` var result = db.Query<Investment>(new Syst...
2012/07/10
[ "https://Stackoverflow.com/questions/11416019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/296296/" ]
If you are using Linux, exporting the `ANDROID_HOME` in the `.bashrc` may not work. ``` export ANDROID_HOME=/home/toro/etc/android-sdk-linux ``` For me it works only when I export `ANDROID_HOME` in the `/etc/environment` file like this: ``` ANDROID_HOME=/home/toro/etc/android-sdk-linux ``` ~~You have to restart ...
Another way is to set the environment variable into run configuration for pom.xml. Go to Run Configurations menu, select the Run configuration used for your project pom.xml and select the *Environment* Tab and select "New", then insert: * ANDROID\_HOME into name Field * path to your sdk into value field It works, a...
11,416,019
**Question:** I'm trying to use PetaPoco to join more than four tables to populate an object of type A with five members of type B (very similiar to this question: <https://stackoverflow.com/a/11275334/296296>). From what I've read it would be possible to use this syntax: ``` var result = db.Query<Investment>(new Syst...
2012/07/10
[ "https://Stackoverflow.com/questions/11416019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/296296/" ]
on your command line, run: `mvn clean install -- Dandroid.sdk.path="/Applications/Android Studio.app/sdk/"` none of the other methods really worked. (setting `ANDROID_HOME` doesn't do anything)
You need to set the Android Development Tools SDK Location path in Eclipse: click on Window -> Preferences and select Android. The SDK Location can be set under Android preferences.
11,416,019
**Question:** I'm trying to use PetaPoco to join more than four tables to populate an object of type A with five members of type B (very similiar to this question: <https://stackoverflow.com/a/11275334/296296>). From what I've read it would be possible to use this syntax: ``` var result = db.Query<Investment>(new Syst...
2012/07/10
[ "https://Stackoverflow.com/questions/11416019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/296296/" ]
Ensure your Android SDK installation contains the libraries for the **same API version you have configured on your pom.xml**. For example, if your configuration XML looks like: ``` <plugin> <groupId>com.jayway.maven.plugins.android.generation2</groupId> <artifactId>android-maven-plugin</artifactId> ... ...
Setting an ANDROID\_HOME variable in your .bashrc or whatever will work, but remember to **export** that variable so that it is available to subprocesses. Setting ANDROID\_HOME with the other methods suggested here will get you through some initial errors, but without ANDROID\_HOME exported your build will probably fai...
11,416,019
**Question:** I'm trying to use PetaPoco to join more than four tables to populate an object of type A with five members of type B (very similiar to this question: <https://stackoverflow.com/a/11275334/296296>). From what I've read it would be possible to use this syntax: ``` var result = db.Query<Investment>(new Syst...
2012/07/10
[ "https://Stackoverflow.com/questions/11416019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/296296/" ]
Ensure your Android SDK installation contains the libraries for the **same API version you have configured on your pom.xml**. For example, if your configuration XML looks like: ``` <plugin> <groupId>com.jayway.maven.plugins.android.generation2</groupId> <artifactId>android-maven-plugin</artifactId> ... ...
Another way is to set the environment variable into run configuration for pom.xml. Go to Run Configurations menu, select the Run configuration used for your project pom.xml and select the *Environment* Tab and select "New", then insert: * ANDROID\_HOME into name Field * path to your sdk into value field It works, a...
11,416,019
**Question:** I'm trying to use PetaPoco to join more than four tables to populate an object of type A with five members of type B (very similiar to this question: <https://stackoverflow.com/a/11275334/296296>). From what I've read it would be possible to use this syntax: ``` var result = db.Query<Investment>(new Syst...
2012/07/10
[ "https://Stackoverflow.com/questions/11416019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/296296/" ]
You need to create a system variable for ANDROID\_HOME, not set it in your PATH.
Another way is to set the environment variable into run configuration for pom.xml. Go to Run Configurations menu, select the Run configuration used for your project pom.xml and select the *Environment* Tab and select "New", then insert: * ANDROID\_HOME into name Field * path to your sdk into value field It works, a...
11,416,019
**Question:** I'm trying to use PetaPoco to join more than four tables to populate an object of type A with five members of type B (very similiar to this question: <https://stackoverflow.com/a/11275334/296296>). From what I've read it would be possible to use this syntax: ``` var result = db.Query<Investment>(new Syst...
2012/07/10
[ "https://Stackoverflow.com/questions/11416019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/296296/" ]
on your command line, run: `mvn clean install -- Dandroid.sdk.path="/Applications/Android Studio.app/sdk/"` none of the other methods really worked. (setting `ANDROID_HOME` doesn't do anything)
Another way is to set the environment variable into run configuration for pom.xml. Go to Run Configurations menu, select the Run configuration used for your project pom.xml and select the *Environment* Tab and select "New", then insert: * ANDROID\_HOME into name Field * path to your sdk into value field It works, a...
11,416,019
**Question:** I'm trying to use PetaPoco to join more than four tables to populate an object of type A with five members of type B (very similiar to this question: <https://stackoverflow.com/a/11275334/296296>). From what I've read it would be possible to use this syntax: ``` var result = db.Query<Investment>(new Syst...
2012/07/10
[ "https://Stackoverflow.com/questions/11416019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/296296/" ]
Another way is to set the environment variable into run configuration for pom.xml. Go to Run Configurations menu, select the Run configuration used for your project pom.xml and select the *Environment* Tab and select "New", then insert: * ANDROID\_HOME into name Field * path to your sdk into value field It works, a...
Create a file called **local.properties** in your root directory of your project. With the contents; ``` sdk.dir=c:\\path\\to\\android-sdk ```
11,416,019
**Question:** I'm trying to use PetaPoco to join more than four tables to populate an object of type A with five members of type B (very similiar to this question: <https://stackoverflow.com/a/11275334/296296>). From what I've read it would be possible to use this syntax: ``` var result = db.Query<Investment>(new Syst...
2012/07/10
[ "https://Stackoverflow.com/questions/11416019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/296296/" ]
Setting an ANDROID\_HOME variable in your .bashrc or whatever will work, but remember to **export** that variable so that it is available to subprocesses. Setting ANDROID\_HOME with the other methods suggested here will get you through some initial errors, but without ANDROID\_HOME exported your build will probably fai...
Create a file called **local.properties** in your root directory of your project. With the contents; ``` sdk.dir=c:\\path\\to\\android-sdk ```
11,416,019
**Question:** I'm trying to use PetaPoco to join more than four tables to populate an object of type A with five members of type B (very similiar to this question: <https://stackoverflow.com/a/11275334/296296>). From what I've read it would be possible to use this syntax: ``` var result = db.Query<Investment>(new Syst...
2012/07/10
[ "https://Stackoverflow.com/questions/11416019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/296296/" ]
You need to create a system variable for ANDROID\_HOME, not set it in your PATH.
Create a file called **local.properties** in your root directory of your project. With the contents; ``` sdk.dir=c:\\path\\to\\android-sdk ```
23,605,191
I have a test case i.e created using coded UI. I want to run the test using MStest. I am able to run the test case in my system, but when i try to run in another system , it throws this error "Unable to load the test container 'C:\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\bin\Debug\*\*\*.dll' or one of its dependencies. Erro...
2014/05/12
[ "https://Stackoverflow.com/questions/23605191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1158910/" ]
To execute the tests on a machine that is not set up for development of coded ui, you need to install the Visual Studio Test **agent** on that machine, and a Visual Studio **controller** to manage the agent. There's a great article [here](https://learn.microsoft.com/en-us/visualstudio/test/lab-management/install-confi...
Please have Microsoft Test Agent installed in that system. <http://www.microsoft.com/en-us/download/details.aspx?id=38186>
206,021
I was recently studying Maxwell's equations. Got a bit confused about divergence. Would someone please tell me if the divergence of a uniform electric field = $0$, & why it is so?
2015/09/09
[ "https://physics.stackexchange.com/questions/206021", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/87169/" ]
The divergence of a field talks about the existence of 'source/sink charges' for it at a given point. A field is locally directed towards (converges) a sink, and away from a source (diverges). The divergence is non zero at a point where a source or sink exists. Conventionally, positive charges are sources, and negative...
Divergence can be defined as an ratio of "field flux out of a closed surface" and "volume of that closed surface", and let volume sink to zero, $dv \rightarrow 0$. $$ \text{div}\vec{E}=\frac{1}{dv} \oint\vec{E}\cdot {d\vec{a}} $$ Electric field flux out of a closed surface of a uniform field is always zero - how muc...
54,102,781
I have a few methods doing this: ``` def method_a Net::SSH.start(...) do |ssh| end end def method_b Net::SSH.start(...) do |ssh| end end def method_c Net::SSH.start(...) do |ssh| end end ``` Each methods call Net::SSH start which are individual SSH sessions, doing different things. Is there...
2019/01/09
[ "https://Stackoverflow.com/questions/54102781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2875733/" ]
According [repositories documentation](https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.core-concepts) using `CrudRepository` provides a method called **count()** that is one of the [Superinterfaces](https://docs.spring.io/spring-data/jpa/docs/current/api/org/springframework/data/jpa/rep...
\*> Actually I want it return a json format like [{ name: kermit, value:6}]. Now it just return a number 6 only. How I can do that? Thank you! First, create a class to wrap your data: ``` public class UserMembership { private String userId; private long numberOfUsers; public UserMembership(String userId, long n...
71,445,353
Using javascript, my objective is to query the URL and append parameters to all links on a page. If the link already contains a parameter, the link will append the new parameters: > > User access page:<https://example.com/?location=brazil> > > Link on page was: <https://link.com/?hello=ok> > > Link becomes: <...
2022/03/11
[ "https://Stackoverflow.com/questions/71445353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18442961/" ]
You could just check if the queryString variable contains a `?` and replace it with a `&` instead. So your code would be something like ``` var queryString = new URL(window.location).search; document.querySelectorAll("[href]").forEach(link => { var current = link.href; const queryStrToUse = queryString.replac...
``` var queryString = new URL(window.location).search; document.querySelectorAll("[href]").forEach(link => { var current = link.href; link.href = `${current}${current.includes('?') ? queryString.replace('?', '&') : queryString}`; }); ```
71,445,353
Using javascript, my objective is to query the URL and append parameters to all links on a page. If the link already contains a parameter, the link will append the new parameters: > > User access page:<https://example.com/?location=brazil> > > Link on page was: <https://link.com/?hello=ok> > > Link becomes: <...
2022/03/11
[ "https://Stackoverflow.com/questions/71445353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18442961/" ]
It is not a good idea to change the anchor href attribute with javascript for many reasons, but if this is a must you can do: ``` document.querySelectorAll("a").forEach(link => { link.href = link.href.includes("?") ? link.href + queryString.replace("?", "&") : link.href + queryString; }); ```
``` var queryString = new URL(window.location).search; document.querySelectorAll("[href]").forEach(link => { var current = link.href; link.href = `${current}${current.includes('?') ? queryString.replace('?', '&') : queryString}`; }); ```
58,792,844
Good evening everyone! I have a small problem with my code that I can't solve correctly. I need to output to the console the simplest recipe for soup through the callback function. Please help with advice. Thank in advanse! From online tutorials and YouTube, I understand that if we passed one function as a parameter t...
2019/11/10
[ "https://Stackoverflow.com/questions/58792844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11988272/" ]
You can use `reduceRight` to accumulate the callback chain into one function, and then call it. This way you avoid what is commonly called "call back hell": ```js [setWater, cutOnion, waitForWater, putOnion, putCarrot, soupIsReady].reduceRight((acc, f) => () => f(() => acc()) )(); function setWater(param){ co...
Thanks to @Caramiriel for hint. I have an answer) ```js function callback(){ setWater(function() { cutOnion(function(){ cutCarrot(function(){ waitForWater(function(){ putOnion(function(){ putCarrot(function(){ ...
58,792,844
Good evening everyone! I have a small problem with my code that I can't solve correctly. I need to output to the console the simplest recipe for soup through the callback function. Please help with advice. Thank in advanse! From online tutorials and YouTube, I understand that if we passed one function as a parameter t...
2019/11/10
[ "https://Stackoverflow.com/questions/58792844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11988272/" ]
Thanks to @Caramiriel for hint. I have an answer) ```js function callback(){ setWater(function() { cutOnion(function(){ cutCarrot(function(){ waitForWater(function(){ putOnion(function(){ putCarrot(function(){ ...
I see somthing like that... ```js // Put the water to boil function setWater(param) { console.log('We start to cook the soup. We put the water to warm.'); fct = param.shift(); fct(param); } // Chop the onion function cutOnion(param) { setTimeout(() => { console.log('Chop the onion'); fct = p...
58,792,844
Good evening everyone! I have a small problem with my code that I can't solve correctly. I need to output to the console the simplest recipe for soup through the callback function. Please help with advice. Thank in advanse! From online tutorials and YouTube, I understand that if we passed one function as a parameter t...
2019/11/10
[ "https://Stackoverflow.com/questions/58792844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11988272/" ]
Thanks to @Caramiriel for hint. I have an answer) ```js function callback(){ setWater(function() { cutOnion(function(){ cutCarrot(function(){ waitForWater(function(){ putOnion(function(){ putCarrot(function(){ ...
You can stack them all like this as well: ``` setWater(cutOnion(cutCarrot(waitForWater(putOnion(putCarrot(soupIsReady)))))); ``` Then remove all your setTimeouts.
58,792,844
Good evening everyone! I have a small problem with my code that I can't solve correctly. I need to output to the console the simplest recipe for soup through the callback function. Please help with advice. Thank in advanse! From online tutorials and YouTube, I understand that if we passed one function as a parameter t...
2019/11/10
[ "https://Stackoverflow.com/questions/58792844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11988272/" ]
You can use `reduceRight` to accumulate the callback chain into one function, and then call it. This way you avoid what is commonly called "call back hell": ```js [setWater, cutOnion, waitForWater, putOnion, putCarrot, soupIsReady].reduceRight((acc, f) => () => f(() => acc()) )(); function setWater(param){ co...
I see somthing like that... ```js // Put the water to boil function setWater(param) { console.log('We start to cook the soup. We put the water to warm.'); fct = param.shift(); fct(param); } // Chop the onion function cutOnion(param) { setTimeout(() => { console.log('Chop the onion'); fct = p...
58,792,844
Good evening everyone! I have a small problem with my code that I can't solve correctly. I need to output to the console the simplest recipe for soup through the callback function. Please help with advice. Thank in advanse! From online tutorials and YouTube, I understand that if we passed one function as a parameter t...
2019/11/10
[ "https://Stackoverflow.com/questions/58792844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11988272/" ]
You can use `reduceRight` to accumulate the callback chain into one function, and then call it. This way you avoid what is commonly called "call back hell": ```js [setWater, cutOnion, waitForWater, putOnion, putCarrot, soupIsReady].reduceRight((acc, f) => () => f(() => acc()) )(); function setWater(param){ co...
You can stack them all like this as well: ``` setWater(cutOnion(cutCarrot(waitForWater(putOnion(putCarrot(soupIsReady)))))); ``` Then remove all your setTimeouts.
47,884,449
Can we have the orientation locked for splash screen in potrait for the app that supports all orientations?Currenly when I launch the app while device is landscape makes the splash screen looking really ugly,and I need it only in portrait.
2017/12/19
[ "https://Stackoverflow.com/questions/47884449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6081374/" ]
If you would like to use a launch screen storyboard in a single orientation, change the info.plist to specify that orientation only. Then if you would like to have the app run different orientations after the launch screen storyboard has finished, then simply add the following method to your app delegate (objective-c)...
The only way to lock the splash screen into portrait orientation is if the supported orientations for the app are set to portrait alone.
120,786
Is there a one-liner that will list all executables from $PATH in Bash?
2014/03/21
[ "https://unix.stackexchange.com/questions/120786", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/1806/" ]
I came up with this: ``` IFS=':';for i in $PATH; do test -d "$i" && find "$i" -maxdepth 1 -executable -type f -exec basename {} \;; done ``` **EDIT**: It seems that this is the only command that don't trigger SELinux alert while reading some of the files in bin directory by apache user.
``` #!/usr/bin/env python import os from os.path import expanduser, isdir, join, pathsep def list_executables(): paths = os.environ["PATH"].split(pathsep) executables = [] for path in filter(isdir, paths): for file_ in os.listdir(path): if os.access(join(path, file_), os.X_OK): ...
120,786
Is there a one-liner that will list all executables from $PATH in Bash?
2014/03/21
[ "https://unix.stackexchange.com/questions/120786", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/1806/" ]
With zsh: ``` whence -pm '*' ``` Or: ``` print -rC1 -- $commands ``` (note that for commands that appear in more than one component of `$PATH`, they will list only the first one). If you want the commands without the full paths, and sorted for good measure: ``` print -rC1 -- ${(ko)commands} ``` (that is, get ...
I came up with this: ``` IFS=':';for i in $PATH; do test -d "$i" && find "$i" -maxdepth 1 -executable -type f -exec basename {} \;; done ``` **EDIT**: It seems that this is the only command that don't trigger SELinux alert while reading some of the files in bin directory by apache user.
120,786
Is there a one-liner that will list all executables from $PATH in Bash?
2014/03/21
[ "https://unix.stackexchange.com/questions/120786", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/1806/" ]
In any POSIX shell, without using any external command (assuming `printf` is built in, if not fall back to `echo`) except for the final sorting, and assuming that no executable name contains a newline: ```bsh { set -f; IFS=:; for d in $PATH; do set +f; [ -n "$d" ] || d=.; for f in "$d"/.[!.]* "$d"/..?* "$d"/*; do [ -f...
If you can run Python 2 in your shell, the following (ridiculously long) one-liner can be used as well: ```bsh python2 -c 'import os;import sys;output = lambda(x) : sys.stdout.write(x + "\n"); paths = os.environ["PATH"].split(":") ; listdir = lambda(p) : os.listdir(p) if os.path.isdir(p) else [ ] ; isfile = lambda(x) ...
120,786
Is there a one-liner that will list all executables from $PATH in Bash?
2014/03/21
[ "https://unix.stackexchange.com/questions/120786", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/1806/" ]
This is not an answer, but it's showing binary, a command which you could run ``` compgen -c ``` (assuming `bash`) Other useful commands ``` compgen -a # will list all the aliases you could run. compgen -b # will list all the built-ins you could run. compgen -k # will list all the keywords you could run. compgen ...
If you can run Python 2 in your shell, the following (ridiculously long) one-liner can be used as well: ```bsh python2 -c 'import os;import sys;output = lambda(x) : sys.stdout.write(x + "\n"); paths = os.environ["PATH"].split(":") ; listdir = lambda(p) : os.listdir(p) if os.path.isdir(p) else [ ] ; isfile = lambda(x) ...
120,786
Is there a one-liner that will list all executables from $PATH in Bash?
2014/03/21
[ "https://unix.stackexchange.com/questions/120786", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/1806/" ]
In any POSIX shell, without using any external command (assuming `printf` is built in, if not fall back to `echo`) except for the final sorting, and assuming that no executable name contains a newline: ```bsh { set -f; IFS=:; for d in $PATH; do set +f; [ -n "$d" ] || d=.; for f in "$d"/.[!.]* "$d"/..?* "$d"/*; do [ -f...
On MacOS with zsh you can do this: ``` find ${(s/:/)PATH} ``` or, if you want to be fancy: ``` find ${(s/:/)PATH} -maxdepth 1 -perm -u+x -type f | xargs basename ```
120,786
Is there a one-liner that will list all executables from $PATH in Bash?
2014/03/21
[ "https://unix.stackexchange.com/questions/120786", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/1806/" ]
With zsh: ``` whence -pm '*' ``` Or: ``` print -rC1 -- $commands ``` (note that for commands that appear in more than one component of `$PATH`, they will list only the first one). If you want the commands without the full paths, and sorted for good measure: ``` print -rC1 -- ${(ko)commands} ``` (that is, get ...
In any POSIX shell, without using any external command (assuming `printf` is built in, if not fall back to `echo`) except for the final sorting, and assuming that no executable name contains a newline: ```bsh { set -f; IFS=:; for d in $PATH; do set +f; [ -n "$d" ] || d=.; for f in "$d"/.[!.]* "$d"/..?* "$d"/*; do [ -f...
120,786
Is there a one-liner that will list all executables from $PATH in Bash?
2014/03/21
[ "https://unix.stackexchange.com/questions/120786", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/1806/" ]
How about this ``` find ${PATH//:/ } -maxdepth 1 -executable ``` The string substitution is used with Bash.
``` #!/usr/bin/env python import os from os.path import expanduser, isdir, join, pathsep def list_executables(): paths = os.environ["PATH"].split(pathsep) executables = [] for path in filter(isdir, paths): for file_ in os.listdir(path): if os.access(join(path, file_), os.X_OK): ...
120,786
Is there a one-liner that will list all executables from $PATH in Bash?
2014/03/21
[ "https://unix.stackexchange.com/questions/120786", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/1806/" ]
This is not an answer, but it's showing binary, a command which you could run ``` compgen -c ``` (assuming `bash`) Other useful commands ``` compgen -a # will list all the aliases you could run. compgen -b # will list all the built-ins you could run. compgen -k # will list all the keywords you could run. compgen ...
How about this ``` find ${PATH//:/ } -maxdepth 1 -executable ``` The string substitution is used with Bash.
120,786
Is there a one-liner that will list all executables from $PATH in Bash?
2014/03/21
[ "https://unix.stackexchange.com/questions/120786", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/1806/" ]
This is not an answer, but it's showing binary, a command which you could run ``` compgen -c ``` (assuming `bash`) Other useful commands ``` compgen -a # will list all the aliases you could run. compgen -b # will list all the built-ins you could run. compgen -k # will list all the keywords you could run. compgen ...
I came up with this: ``` IFS=':';for i in $PATH; do test -d "$i" && find "$i" -maxdepth 1 -executable -type f -exec basename {} \;; done ``` **EDIT**: It seems that this is the only command that don't trigger SELinux alert while reading some of the files in bin directory by apache user.
120,786
Is there a one-liner that will list all executables from $PATH in Bash?
2014/03/21
[ "https://unix.stackexchange.com/questions/120786", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/1806/" ]
If you can run Python 2 in your shell, the following (ridiculously long) one-liner can be used as well: ```bsh python2 -c 'import os;import sys;output = lambda(x) : sys.stdout.write(x + "\n"); paths = os.environ["PATH"].split(":") ; listdir = lambda(p) : os.listdir(p) if os.path.isdir(p) else [ ] ; isfile = lambda(x) ...
On MacOS with zsh you can do this: ``` find ${(s/:/)PATH} ``` or, if you want to be fancy: ``` find ${(s/:/)PATH} -maxdepth 1 -perm -u+x -type f | xargs basename ```
24,478,774
I'm parsing two CSV files which contains IP addresses. The first is a source CSV, and the second is a "Blacklist". Because of the size of the source file, I'm trying to optimize the speed at which I find IP addresses that match the blacklist. **EDIT:** The blacklist consists of IP Address "Blocks". This means that ea...
2014/06/29
[ "https://Stackoverflow.com/questions/24478774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3250023/" ]
I assume you're talking IPV4 addresses of the form xxx.xxx.xxx.xxx. You can easily convert an IP address into an integer. Each segment (i.e. xxx) is 8 bits (i.e. one byte). So four of them together makes a 32-bit integer. So, given an IP address like "192.168.100.12", you can split it into its four parts, parse each o...
Put both files in a String. Use split(",") to split the ip's in the first string. Loop through the obtained ips array. For every ip search for it in the second String like `blacklist.indexOf("," + ip + ",")` But first add a "," at start and end of blacklist string.
24,478,774
I'm parsing two CSV files which contains IP addresses. The first is a source CSV, and the second is a "Blacklist". Because of the size of the source file, I'm trying to optimize the speed at which I find IP addresses that match the blacklist. **EDIT:** The blacklist consists of IP Address "Blocks". This means that ea...
2014/06/29
[ "https://Stackoverflow.com/questions/24478774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3250023/" ]
I assume you're talking IPV4 addresses of the form xxx.xxx.xxx.xxx. You can easily convert an IP address into an integer. Each segment (i.e. xxx) is 8 bits (i.e. one byte). So four of them together makes a 32-bit integer. So, given an IP address like "192.168.100.12", you can split it into its four parts, parse each o...
Brute force it. Load everything into ram, no reason not to. Split the ips into a 2d array. {0:123,123,123,123} Blacklist into a 3d array. Now you can start searching for integers. When you have a match compare the next section. If source value higher then compare to the END block same section. When you have a match pus...
24,478,774
I'm parsing two CSV files which contains IP addresses. The first is a source CSV, and the second is a "Blacklist". Because of the size of the source file, I'm trying to optimize the speed at which I find IP addresses that match the blacklist. **EDIT:** The blacklist consists of IP Address "Blocks". This means that ea...
2014/06/29
[ "https://Stackoverflow.com/questions/24478774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3250023/" ]
I assume you're talking IPV4 addresses of the form xxx.xxx.xxx.xxx. You can easily convert an IP address into an integer. Each segment (i.e. xxx) is 8 bits (i.e. one byte). So four of them together makes a 32-bit integer. So, given an IP address like "192.168.100.12", you can split it into its four parts, parse each o...
You could use a data structure called [Bloom Filter](http://en.wikipedia.org/wiki/Bloom_filter). Which is rather efficient performance and storage wise. As for an example, there's a question here, [Most Efficient way of implementing a BlackList](https://stackoverflow.com/questions/7910130/most-efficient-way-of-implemen...
24,478,774
I'm parsing two CSV files which contains IP addresses. The first is a source CSV, and the second is a "Blacklist". Because of the size of the source file, I'm trying to optimize the speed at which I find IP addresses that match the blacklist. **EDIT:** The blacklist consists of IP Address "Blocks". This means that ea...
2014/06/29
[ "https://Stackoverflow.com/questions/24478774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3250023/" ]
I assume you're talking IPV4 addresses of the form xxx.xxx.xxx.xxx. You can easily convert an IP address into an integer. Each segment (i.e. xxx) is 8 bits (i.e. one byte). So four of them together makes a 32-bit integer. So, given an IP address like "192.168.100.12", you can split it into its four parts, parse each o...
It seems like the most direction solution would be to use an [interval tree](http://en.wikipedia.org/wiki/Interval_tree) to store the blacklist. Then check if the IP intersects with any of the intervals. You also might want to consider using a Trie/hashtable to get fast lookups where the interval is the same. IE: 216...
53,241,703
I have defined a config var "BASE\_URL" in my Heroku app and I'm trying to access it in my React app as ``` process.env.BASE_URL ``` but it gives me undefined when I console.log it as it seems to be not existing. How can I access Heroku config vars in my React app?
2018/11/10
[ "https://Stackoverflow.com/questions/53241703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10282177/" ]
If you use Create React App (or react-scripts), prepend the variable with `REACT_APP_`, for instance, `REACT_APP_BASE_URL`, and Create React App [automatically uses its value during the build process](https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables), making it then accessible in the...
You have to use a [module that loads environment variables](https://github.com/motdotla/dotenv). Then, ``` require('dotenv').config() ... console.log(process.env.BASE_URL); ``` Check this [post](https://medium.com/@trekinbami/using-environment-variables-in-react-6b0a99d83cf5), pretty useful.
53,241,703
I have defined a config var "BASE\_URL" in my Heroku app and I'm trying to access it in my React app as ``` process.env.BASE_URL ``` but it gives me undefined when I console.log it as it seems to be not existing. How can I access Heroku config vars in my React app?
2018/11/10
[ "https://Stackoverflow.com/questions/53241703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10282177/" ]
You have to use a [module that loads environment variables](https://github.com/motdotla/dotenv). Then, ``` require('dotenv').config() ... console.log(process.env.BASE_URL); ``` Check this [post](https://medium.com/@trekinbami/using-environment-variables-in-react-6b0a99d83cf5), pretty useful.
for react es6 use import {} from 'dotenv/config'
53,241,703
I have defined a config var "BASE\_URL" in my Heroku app and I'm trying to access it in my React app as ``` process.env.BASE_URL ``` but it gives me undefined when I console.log it as it seems to be not existing. How can I access Heroku config vars in my React app?
2018/11/10
[ "https://Stackoverflow.com/questions/53241703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10282177/" ]
You have to use a [module that loads environment variables](https://github.com/motdotla/dotenv). Then, ``` require('dotenv').config() ... console.log(process.env.BASE_URL); ``` Check this [post](https://medium.com/@trekinbami/using-environment-variables-in-react-6b0a99d83cf5), pretty useful.
First install dotenv using yarn/npm ``` yarn add dotenv ``` or ``` npm install dotenv ``` Then create a **.env** file in parent directory of src folder and then add your key in .env file prefixed REACT\_APP\_ like ``` REACT_APP_YOUR_API=15dw8... ``` Now in your app.js configure dotenv ``` require('dotenv')....
53,241,703
I have defined a config var "BASE\_URL" in my Heroku app and I'm trying to access it in my React app as ``` process.env.BASE_URL ``` but it gives me undefined when I console.log it as it seems to be not existing. How can I access Heroku config vars in my React app?
2018/11/10
[ "https://Stackoverflow.com/questions/53241703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10282177/" ]
If you use Create React App (or react-scripts), prepend the variable with `REACT_APP_`, for instance, `REACT_APP_BASE_URL`, and Create React App [automatically uses its value during the build process](https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables), making it then accessible in the...
for react es6 use import {} from 'dotenv/config'
53,241,703
I have defined a config var "BASE\_URL" in my Heroku app and I'm trying to access it in my React app as ``` process.env.BASE_URL ``` but it gives me undefined when I console.log it as it seems to be not existing. How can I access Heroku config vars in my React app?
2018/11/10
[ "https://Stackoverflow.com/questions/53241703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10282177/" ]
If you use Create React App (or react-scripts), prepend the variable with `REACT_APP_`, for instance, `REACT_APP_BASE_URL`, and Create React App [automatically uses its value during the build process](https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables), making it then accessible in the...
First install dotenv using yarn/npm ``` yarn add dotenv ``` or ``` npm install dotenv ``` Then create a **.env** file in parent directory of src folder and then add your key in .env file prefixed REACT\_APP\_ like ``` REACT_APP_YOUR_API=15dw8... ``` Now in your app.js configure dotenv ``` require('dotenv')....
53,241,703
I have defined a config var "BASE\_URL" in my Heroku app and I'm trying to access it in my React app as ``` process.env.BASE_URL ``` but it gives me undefined when I console.log it as it seems to be not existing. How can I access Heroku config vars in my React app?
2018/11/10
[ "https://Stackoverflow.com/questions/53241703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10282177/" ]
First install dotenv using yarn/npm ``` yarn add dotenv ``` or ``` npm install dotenv ``` Then create a **.env** file in parent directory of src folder and then add your key in .env file prefixed REACT\_APP\_ like ``` REACT_APP_YOUR_API=15dw8... ``` Now in your app.js configure dotenv ``` require('dotenv')....
for react es6 use import {} from 'dotenv/config'
7,855,723
I gotta an uncommon problem over here. I have to call the tinnyURL service to shorten my URL, it is working fine. After that, I have to call another tab, but for some reason, it calls a pop-up. I'm assuming that the problem is when I call the tinyURL service, but I don't know how to fix it. Below is the code I've w...
2011/10/21
[ "https://Stackoverflow.com/questions/7855723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1007885/" ]
There can be many reasons for having your popups blocked, but in this case I bet it's because the popup is not in reaction to a user event such as a click or keyboard input. In your case that would mean doing the url shortening in the background before even letting the user choose to post to twitter, and when they do...
It's me again, I just have figured out the problem. All I did was to avoid the TinyURL service and call directly the Twitter page updater as below. ``` var myString:String = "http://twitter.com/home?status=" + MESSAGE + " " + LINK; var url:URLRequest = new URLRequest(myString); navigateToURL(url); ``` Luckily, the...
15,042,374
I'm trying to come up with a way to select Element 2. ``` <div class="wrapper"> <div class="qe datepicker">Element 1</div> <div class="qe">Element 2</div> <div class="qe fileuploader">Element 3</div> <div class="qe fileuploader datepicker">Element 4</div> </div> ``` Though I haven't tested this code,...
2013/02/23
[ "https://Stackoverflow.com/questions/15042374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2043615/" ]
``` $(".wrapper").children("[class=qe]") ``` Change the selector to match elements where the `class` equals `"qe"`.
You can do that with the attribute selector: ``` $('.wrapper>[class=qe]') ``` Demo: <http://jsfiddle.net/ZdNaf/>
10,808,246
Does anyone know how to create the RestEasy client side calls to upload a file using the following two interface signatures? I'm not finding any information at all. I know how to do it using the HttpClient but I'd like to use the client proxy to keep it consistent. ``` @POST @Path("/upload") @Consumes("multipart/form-...
2012/05/29
[ "https://Stackoverflow.com/questions/10808246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/464314/" ]
With RESTEasy 3.0.X a file upload via MultipartFormData could look like this: ``` ResteasyClient client = new ResteasyClientBuilder().build(); ResteasyWebTarget target = client.target("http://.../upload"); MultipartFormDataOutput mdo = new MultipartFormDataOutput(); mdo.addFormData("file", new FileInputStream(new Fi...
I spent a bunch of time looking around for an answer to this, but I finally figured out how to make it work. You need to add: ``` resteasy-multipart-provider-2.3.5.Final.jar ``` to your classpath (or whatever version of `resteasy` you are using). You then can do something of this form: ``` ClientRequest add_reques...
1,305,531
Which is better (and for what reasons) to use to connect to MS SQL, Oracle or Firebird from a Delphi Win32 application -- ADO or DBX (Database Express)? Both allow you to connect to the major databases. I like the way ADO does it all with a connection string change and the fact that ADO and the drivers are included wi...
2009/08/20
[ "https://Stackoverflow.com/questions/1305531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
General rule: every layer of components will possibly add an additional layer of bugs. Both ADO and DBX are component wrappers around standard database functionality, thus they're both equally strong. So the proper choice should be based on other factors, like the databases that you want to use. If you want to connect ...
ADO is Microsoft world DBX was created at the beginning (Delphi 6) for cross platform and Kylix
1,305,531
Which is better (and for what reasons) to use to connect to MS SQL, Oracle or Firebird from a Delphi Win32 application -- ADO or DBX (Database Express)? Both allow you to connect to the major databases. I like the way ADO does it all with a connection string change and the fact that ADO and the drivers are included wi...
2009/08/20
[ "https://Stackoverflow.com/questions/1305531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
My two cents: DBX is significantly faster (on both oracle and sql), and significantly more finicky and harder to deploy. If performance is a factor, I'd go with DBX. Otherwise, I'd just use ADO for simplicity's sake.
ADO is Microsoft world DBX was created at the beginning (Delphi 6) for cross platform and Kylix
1,305,531
Which is better (and for what reasons) to use to connect to MS SQL, Oracle or Firebird from a Delphi Win32 application -- ADO or DBX (Database Express)? Both allow you to connect to the major databases. I like the way ADO does it all with a connection string change and the fact that ADO and the drivers are included wi...
2009/08/20
[ "https://Stackoverflow.com/questions/1305531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
ADO is simple to use and is there, you only must make sure to install the correponding client driver in the client side. I found DBX more flexible and it is better integrated within IDE and another technologies like DataSnap. For the same purpose than you, I have used DBX with Third Party Drivers from [DevArt](http:/...
ADO is Microsoft world DBX was created at the beginning (Delphi 6) for cross platform and Kylix
1,305,531
Which is better (and for what reasons) to use to connect to MS SQL, Oracle or Firebird from a Delphi Win32 application -- ADO or DBX (Database Express)? Both allow you to connect to the major databases. I like the way ADO does it all with a connection string change and the fact that ADO and the drivers are included wi...
2009/08/20
[ "https://Stackoverflow.com/questions/1305531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
As others have said, DBX may have the edge in raw performance in certain cases or under specific circumstances, but ADO is the basis for a very larger number of applications in the world so although performance of ADO may be relatively poorer, clearly that does not mean "unacceptably" poor. For myself, and informed by...
ADO is Microsoft world DBX was created at the beginning (Delphi 6) for cross platform and Kylix
1,305,531
Which is better (and for what reasons) to use to connect to MS SQL, Oracle or Firebird from a Delphi Win32 application -- ADO or DBX (Database Express)? Both allow you to connect to the major databases. I like the way ADO does it all with a connection string change and the fact that ADO and the drivers are included wi...
2009/08/20
[ "https://Stackoverflow.com/questions/1305531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
ADO is simple to use and is there, you only must make sure to install the correponding client driver in the client side. I found DBX more flexible and it is better integrated within IDE and another technologies like DataSnap. For the same purpose than you, I have used DBX with Third Party Drivers from [DevArt](http:/...
As others have said, DBX may have the edge in raw performance in certain cases or under specific circumstances, but ADO is the basis for a very larger number of applications in the world so although performance of ADO may be relatively poorer, clearly that does not mean "unacceptably" poor. For myself, and informed by...
1,305,531
Which is better (and for what reasons) to use to connect to MS SQL, Oracle or Firebird from a Delphi Win32 application -- ADO or DBX (Database Express)? Both allow you to connect to the major databases. I like the way ADO does it all with a connection string change and the fact that ADO and the drivers are included wi...
2009/08/20
[ "https://Stackoverflow.com/questions/1305531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In the beginning of Delphi, people praised the multi-DBMS support in Delphi. Everyone loved the BDE (because that was the only way to do that). But when looking at customers over more then the past decade, I have seen a steady decrease of multi-DBMS support in their applications. The cost of supporting multiple DBMS ...
General rule: every layer of components will possibly add an additional layer of bugs. Both ADO and DBX are component wrappers around standard database functionality, thus they're both equally strong. So the proper choice should be based on other factors, like the databases that you want to use. If you want to connect ...
1,305,531
Which is better (and for what reasons) to use to connect to MS SQL, Oracle or Firebird from a Delphi Win32 application -- ADO or DBX (Database Express)? Both allow you to connect to the major databases. I like the way ADO does it all with a connection string change and the fact that ADO and the drivers are included wi...
2009/08/20
[ "https://Stackoverflow.com/questions/1305531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In the beginning of Delphi, people praised the multi-DBMS support in Delphi. Everyone loved the BDE (because that was the only way to do that). But when looking at customers over more then the past decade, I have seen a steady decrease of multi-DBMS support in their applications. The cost of supporting multiple DBMS ...
As others have said, DBX may have the edge in raw performance in certain cases or under specific circumstances, but ADO is the basis for a very larger number of applications in the world so although performance of ADO may be relatively poorer, clearly that does not mean "unacceptably" poor. For myself, and informed by...
1,305,531
Which is better (and for what reasons) to use to connect to MS SQL, Oracle or Firebird from a Delphi Win32 application -- ADO or DBX (Database Express)? Both allow you to connect to the major databases. I like the way ADO does it all with a connection string change and the fact that ADO and the drivers are included wi...
2009/08/20
[ "https://Stackoverflow.com/questions/1305531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
ADO is simple to use and is there, you only must make sure to install the correponding client driver in the client side. I found DBX more flexible and it is better integrated within IDE and another technologies like DataSnap. For the same purpose than you, I have used DBX with Third Party Drivers from [DevArt](http:/...
In the beginning of Delphi, people praised the multi-DBMS support in Delphi. Everyone loved the BDE (because that was the only way to do that). But when looking at customers over more then the past decade, I have seen a steady decrease of multi-DBMS support in their applications. The cost of supporting multiple DBMS ...
1,305,531
Which is better (and for what reasons) to use to connect to MS SQL, Oracle or Firebird from a Delphi Win32 application -- ADO or DBX (Database Express)? Both allow you to connect to the major databases. I like the way ADO does it all with a connection string change and the fact that ADO and the drivers are included wi...
2009/08/20
[ "https://Stackoverflow.com/questions/1305531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
ADO is simple to use and is there, you only must make sure to install the correponding client driver in the client side. I found DBX more flexible and it is better integrated within IDE and another technologies like DataSnap. For the same purpose than you, I have used DBX with Third Party Drivers from [DevArt](http:/...
My two cents: DBX is significantly faster (on both oracle and sql), and significantly more finicky and harder to deploy. If performance is a factor, I'd go with DBX. Otherwise, I'd just use ADO for simplicity's sake.
1,305,531
Which is better (and for what reasons) to use to connect to MS SQL, Oracle or Firebird from a Delphi Win32 application -- ADO or DBX (Database Express)? Both allow you to connect to the major databases. I like the way ADO does it all with a connection string change and the fact that ADO and the drivers are included wi...
2009/08/20
[ "https://Stackoverflow.com/questions/1305531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In the beginning of Delphi, people praised the multi-DBMS support in Delphi. Everyone loved the BDE (because that was the only way to do that). But when looking at customers over more then the past decade, I have seen a steady decrease of multi-DBMS support in their applications. The cost of supporting multiple DBMS ...
ADO is Microsoft world DBX was created at the beginning (Delphi 6) for cross platform and Kylix
17,460
I have come up with a new descriptor(floating point). I want to evaluate this descriptor against SIFT, GLOH, etc etc. I am using the K. Mikolajczyk, C. Schmid, approach. The method is described in the link <http://www.robots.ox.ac.uk/~vgg/research/affine/descriptors.html>. They have provided the binaries and the data s...
2014/07/24
[ "https://dsp.stackexchange.com/questions/17460", "https://dsp.stackexchange.com", "https://dsp.stackexchange.com/users/10610/" ]
You can attack this in 2 approaches: 1. Interpolation. 2. Resample. ### Interpolation Build a new time grid as you wish and use Kernel to interpolate data. Since you need to make a small change even a [Linear Interpolation](https://en.wikipedia.org/wiki/Linear_interpolation) should work very well. ### Resample ...
Assuming the signal was reasonably band-limited before sampling, you can just use a high quality interpolation, such as a Sinc interpolation kernel, to calculate new equally spaced points at any lower density. For small frequency deltas, even a long interpolation kernel or high degree polynomial interpolation can be a...
17,460
I have come up with a new descriptor(floating point). I want to evaluate this descriptor against SIFT, GLOH, etc etc. I am using the K. Mikolajczyk, C. Schmid, approach. The method is described in the link <http://www.robots.ox.ac.uk/~vgg/research/affine/descriptors.html>. They have provided the binaries and the data s...
2014/07/24
[ "https://dsp.stackexchange.com/questions/17460", "https://dsp.stackexchange.com", "https://dsp.stackexchange.com/users/10610/" ]
You can attack this in 2 approaches: 1. Interpolation. 2. Resample. ### Interpolation Build a new time grid as you wish and use Kernel to interpolate data. Since you need to make a small change even a [Linear Interpolation](https://en.wikipedia.org/wiki/Linear_interpolation) should work very well. ### Resample ...
I would have rather this be a comment but due to a lack of reputation I cannot do such. Anyways I all wanted to say was: Instead of worrying about how to resample the data just yet, have you tried correcting your code or investigating why you are getting too much data? I do not know of any ADC where you just "tell"...
31,455,420
I have to projects that I'm working on on my local environment. Both use PHP sessions. Whenever I log into one website, the other one shows that I'm already logged in, but it doesn't allow me to access the admin panel, since the username and password isn't in that projects database. How can I fix it?
2015/07/16
[ "https://Stackoverflow.com/questions/31455420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4364134/" ]
Few problems that I see: -The example code you provided was a mess, that could be due to poor formatting but regardless, I've fixed it for my example. -You are calling `e1.get()` once, after creating the Entry. This would return an empty string; however you don't actually *do* anything with the stored variable anyw...
The script will insert the the button then it will get the value which is blank so you need to move the us to into the function and then remove the us from the parameters this will mean that the value is set when the button is clicked also you should put some try statement to ensure that the program can handle all inp...
13,439,898
According to the correct answer in [Static array vs. dynamic array in C++](https://stackoverflow.com/questions/2672085/c-static-array-vs-dynamic-array) static arrays have fixed sizes. However, this compiles and runs just fine: ``` int main(int argc, char** argv) { int myArray[2]; myArray[0] = 0; myArray[1] = 1; co...
2012/11/18
[ "https://Stackoverflow.com/questions/13439898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1173112/" ]
You're not actually enlarging the array. Let's see your code in detail: ``` int myArray[2]; myArray[0] = 0; myArray[1] = 1; ``` You create an array of two positions, with indexes from 0 to 1. So far, so good. ``` myArray[4]; ``` You're accessing the fifth element in the array (an element which surely does not ex...
No, not a chance in hell. All you've done is illegally access it outside it's bounds. The fact that this happens to not throw an error for you is utterly irrelevant. It is thoroughly UB.
13,439,898
According to the correct answer in [Static array vs. dynamic array in C++](https://stackoverflow.com/questions/2672085/c-static-array-vs-dynamic-array) static arrays have fixed sizes. However, this compiles and runs just fine: ``` int main(int argc, char** argv) { int myArray[2]; myArray[0] = 0; myArray[1] = 1; co...
2012/11/18
[ "https://Stackoverflow.com/questions/13439898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1173112/" ]
You're not actually enlarging the array. Let's see your code in detail: ``` int myArray[2]; myArray[0] = 0; myArray[1] = 1; ``` You create an array of two positions, with indexes from 0 to 1. So far, so good. ``` myArray[4]; ``` You're accessing the fifth element in the array (an element which surely does not ex...
First, this is not a static array, it is an array allocated in the *automatic storage*. Next, the ``` myArray[4]; ``` is not a new declaration, it is a discarded read from element #4 of the previously declared 2-element array - an undefined behavior. Assignments that follow ``` myArray[2] = 2; myArray[3] = 3; ``...
10,314,573
I shouldnt be able to delete a file with an open handle, correct? So i create a file, then i straight away try to delete it, expecting this to fail. Or am i wrong and the handle doesnt have to be closed before deleting the file? ``` HANDLE hFile = CreateFile (TEXT(file), GENERIC_WRITE, ...
2012/04/25
[ "https://Stackoverflow.com/questions/10314573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1100102/" ]
It depends on how the file has been opened. If the share mode has `FILE_SHARE_DELETE` specified, then it may be deleted by others. Even if you memory map the file, and it has been opened with this flag (and read/write sharing), then it can still be deleted by the shell (at least I've tried this and it happens, but pe...
Yes, it would fail. > > The DeleteFile function fails if an application attempts to delete a > file that is open for normal I/O or as a memory-mapped file. > > >
10,314,573
I shouldnt be able to delete a file with an open handle, correct? So i create a file, then i straight away try to delete it, expecting this to fail. Or am i wrong and the handle doesnt have to be closed before deleting the file? ``` HANDLE hFile = CreateFile (TEXT(file), GENERIC_WRITE, ...
2012/04/25
[ "https://Stackoverflow.com/questions/10314573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1100102/" ]
It depends on how the file has been opened. If the share mode has `FILE_SHARE_DELETE` specified, then it may be deleted by others. Even if you memory map the file, and it has been opened with this flag (and read/write sharing), then it can still be deleted by the shell (at least I've tried this and it happens, but pe...
Have you tried this? MS documentation states that: > > The DeleteFile function fails if an application attempts to delete a file that is open for normal I/O or as a memory-mapped file. > > > So if you're not getting that behaviour I'd suggest it's down to the way you've opened the file. Are you sure that your che...
2,132,453
The N and O are NOT next to each other , the I is directly before the D and the letters EEE are NOT together( 2 E's can be together). Here's what i tried to do but got stuck N O together A= 12!2!/ 3! I Before D B= 12!/ 3! EEE together C= 11! n= A + B + C - |A ∩ B| - |A ∩ C| - |B ∩ C| + |A ∩ B ∩ C| then i tried to c...
2017/02/06
[ "https://math.stackexchange.com/questions/2132453", "https://math.stackexchange.com", "https://math.stackexchange.com/users/408201/" ]
$$ \int \frac{1}{\sin(\theta)\cos^2(\theta)}d\theta $$ $$ =\int \frac{\sin(\theta)}{\cos^2(\theta)(1-\cos^2(\theta))}d\theta $$ then use $u=\cos(\theta)$ and partial fractions on the result.
and $$ \int \frac{1}{\sin(\theta)\cos^2(\theta)}d\theta= \int \frac{\sin\theta}{\sin^2(\theta)\cos^2(\theta)}d\theta= \int \frac{-d(\cos\theta)}{(1-\cos^2\theta)\cos^2(\theta)}d\theta=... $$
2,132,453
The N and O are NOT next to each other , the I is directly before the D and the letters EEE are NOT together( 2 E's can be together). Here's what i tried to do but got stuck N O together A= 12!2!/ 3! I Before D B= 12!/ 3! EEE together C= 11! n= A + B + C - |A ∩ B| - |A ∩ C| - |B ∩ C| + |A ∩ B ∩ C| then i tried to c...
2017/02/06
[ "https://math.stackexchange.com/questions/2132453", "https://math.stackexchange.com", "https://math.stackexchange.com/users/408201/" ]
$$ \int \frac{1}{\sin(\theta)\cos^2(\theta)}d\theta $$ $$ =\int \frac{\sin(\theta)}{\cos^2(\theta)(1-\cos^2(\theta))}d\theta $$ then use $u=\cos(\theta)$ and partial fractions on the result.
$$\int \sqrt{1 + x^{-2}}dx=\int \frac{\sqrt{1 + x^2}}{x}dx$$ With substitution $u=x^{2}$, $du=2xdx$. $$\int \frac{\sqrt{1 + x^2}}{x}dx=\int \frac{\sqrt{u+1}}{2u}du=\frac{1}{2} \int \frac{\sqrt{u+1}}{u}du $$ With substitution $v=\sqrt{u+1}$, $dv=\frac{1}{2v}du$. \begin{align} \frac{1}{2} \int \frac{u+1}{u}du &=\frac...
2,132,453
The N and O are NOT next to each other , the I is directly before the D and the letters EEE are NOT together( 2 E's can be together). Here's what i tried to do but got stuck N O together A= 12!2!/ 3! I Before D B= 12!/ 3! EEE together C= 11! n= A + B + C - |A ∩ B| - |A ∩ C| - |B ∩ C| + |A ∩ B ∩ C| then i tried to c...
2017/02/06
[ "https://math.stackexchange.com/questions/2132453", "https://math.stackexchange.com", "https://math.stackexchange.com/users/408201/" ]
$$ \int \frac{1}{\sin(\theta)\cos^2(\theta)}d\theta $$ $$ =\int \frac{\sin(\theta)}{\cos^2(\theta)(1-\cos^2(\theta))}d\theta $$ then use $u=\cos(\theta)$ and partial fractions on the result.
I get $\int \frac{sec \theta}{tan \theta}d \theta$ from your simplification Which gives $\int \frac{1/cos \theta}{sin \theta / cos \theta}d \theta$ = $\int \frac{1}{sin \theta}d \theta$ = $\int csc \theta d \theta$ which integrates similarly to $sec\ \theta$ and then the fun of back-substituting.
2,132,453
The N and O are NOT next to each other , the I is directly before the D and the letters EEE are NOT together( 2 E's can be together). Here's what i tried to do but got stuck N O together A= 12!2!/ 3! I Before D B= 12!/ 3! EEE together C= 11! n= A + B + C - |A ∩ B| - |A ∩ C| - |B ∩ C| + |A ∩ B ∩ C| then i tried to c...
2017/02/06
[ "https://math.stackexchange.com/questions/2132453", "https://math.stackexchange.com", "https://math.stackexchange.com/users/408201/" ]
$$ \int \frac{1}{\sin(\theta)\cos^2(\theta)}d\theta $$ $$ =\int \frac{\sin(\theta)}{\cos^2(\theta)(1-\cos^2(\theta))}d\theta $$ then use $u=\cos(\theta)$ and partial fractions on the result.
Let $x^2+1=u^2$, so that $2x\,dx=2u\,du$, which implies $${dx\over x}={u\,du\over x^2}={u\over u^2-1}du$$ Then $$\int{\sqrt{1+x^2}\over x}dx=\int{u^2\over u^2-1}du={1\over2}\int\left(2+{1\over u-1}-{1\over u+1} \right)du=u+{1\over2}\ln\left(u-1\over u+1 \right)+C\\=\sqrt{x^2+1}+{1\over2}\ln\left(\sqrt{x^2+1}-1\ove...
2,132,453
The N and O are NOT next to each other , the I is directly before the D and the letters EEE are NOT together( 2 E's can be together). Here's what i tried to do but got stuck N O together A= 12!2!/ 3! I Before D B= 12!/ 3! EEE together C= 11! n= A + B + C - |A ∩ B| - |A ∩ C| - |B ∩ C| + |A ∩ B ∩ C| then i tried to c...
2017/02/06
[ "https://math.stackexchange.com/questions/2132453", "https://math.stackexchange.com", "https://math.stackexchange.com/users/408201/" ]
$$ \int \frac{1}{\sin(\theta)\cos^2(\theta)}d\theta $$ $$ =\int \frac{\sin(\theta)}{\cos^2(\theta)(1-\cos^2(\theta))}d\theta $$ then use $u=\cos(\theta)$ and partial fractions on the result.
Set $x^{-1}=\sinh t$, so $\sqrt{1+x^{-2}}=\cosh t$. Then $$ dx=-\frac{\cosh t}{\sinh^2t}\,dt $$ and the integral becomes $$ -\int\frac{\cosh^2t}{\sinh^2t}\,dt= -\int\frac{1+\sinh^2t}{\sinh^2t}\,dt=\frac{\cosh t}{\sinh t}-t+c= \sqrt{1+x^2}-\operatorname{arsinh}\frac{1}{x}+c $$ You can find a more explicit expression for...
14,536,898
I'm trying to build an internal DSL in Scala to represent algebraic definitions. Let's consider this simplified data model: ``` case class Var(name:String) case class Eq(head:Var, body:Var*) case class Definition(name:String, body:Eq*) ``` For example a simple definition would be: ``` val x = Var("x") val y = Var("...
2013/01/26
[ "https://Stackoverflow.com/questions/14536898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/204851/" ]
While Scalas syntax is powerful, it is not flexible enough to create arbitrary delimiters for symbols. Thus, there is no way to leave commas and replace them only with spaces. Nevertheless, it is possible to use macros and parse a string with arbitrary content at compile time. It is not an "easy" solution, but one tha...
In addition to sschaef's nice solution I want to mention a few possibilities that are commonly used to get rid of commas in list construction for a DSL. Colons ------ This might be trivial, but it is sometimes overlooked as a solution. ``` line1 :: line2 :: line3 :: Nil ``` For a DSL it is often desired that every...
14,536,898
I'm trying to build an internal DSL in Scala to represent algebraic definitions. Let's consider this simplified data model: ``` case class Var(name:String) case class Eq(head:Var, body:Var*) case class Definition(name:String, body:Eq*) ``` For example a simple definition would be: ``` val x = Var("x") val y = Var("...
2013/01/26
[ "https://Stackoverflow.com/questions/14536898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/204851/" ]
While Scalas syntax is powerful, it is not flexible enough to create arbitrary delimiters for symbols. Thus, there is no way to leave commas and replace them only with spaces. Nevertheless, it is possible to use macros and parse a string with arbitrary content at compile time. It is not an "easy" solution, but one tha...
Here is another solution which is relatively simple and enables a syntax that is pretty close to your ideal (as other have pointed, the exact syntax your asked for is not possible, in particular because you cannot redefine delimiter symbols). My solution stretches a bit what is reasonable to do because it adds an oper...
14,536,898
I'm trying to build an internal DSL in Scala to represent algebraic definitions. Let's consider this simplified data model: ``` case class Var(name:String) case class Eq(head:Var, body:Var*) case class Definition(name:String, body:Eq*) ``` For example a simple definition would be: ``` val x = Var("x") val y = Var("...
2013/01/26
[ "https://Stackoverflow.com/questions/14536898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/204851/" ]
In addition to sschaef's nice solution I want to mention a few possibilities that are commonly used to get rid of commas in list construction for a DSL. Colons ------ This might be trivial, but it is sometimes overlooked as a solution. ``` line1 :: line2 :: line3 :: Nil ``` For a DSL it is often desired that every...
Here is another solution which is relatively simple and enables a syntax that is pretty close to your ideal (as other have pointed, the exact syntax your asked for is not possible, in particular because you cannot redefine delimiter symbols). My solution stretches a bit what is reasonable to do because it adds an oper...
55,646,777
I have a plot with two y-axis on a shared x-axis, and I want to make them align at y=0 so that I can draw a horizontal line to highlight the zero tick. currently the two axis are not aligned and I have to draw two line which is terrible. How can I achieve this?  [![enter image description here](https://i.stack.imgur....
2019/04/12
[ "https://Stackoverflow.com/questions/55646777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/459234/" ]
Assuming that you created the plots with a shared axis, you just have to modify the range of y to be centered at zero or have a similar offset multiplier in both plots (i.e set `ax.set_ylim(-6,6)` for both plots). The following code is an example. ``` from matplotlib import pyplot as plt import numpy as np #Create so...
I found [this excellent library](https://github.com/ryutok/mpl_axes_aligner) which aligns the axes and keeps automatic scaling. Install ------- `pip install mpl-axes-aligner` Usage ----- ```py import numpy as np import matplotlib.pyplot as plt import mpl_axes_aligner x = np.arange(0.0, 30, 0.1) y1 = 0.1 * x * np.s...
55,646,777
I have a plot with two y-axis on a shared x-axis, and I want to make them align at y=0 so that I can draw a horizontal line to highlight the zero tick. currently the two axis are not aligned and I have to draw two line which is terrible. How can I achieve this?  [![enter image description here](https://i.stack.imgur....
2019/04/12
[ "https://Stackoverflow.com/questions/55646777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/459234/" ]
Assuming that you created the plots with a shared axis, you just have to modify the range of y to be centered at zero or have a similar offset multiplier in both plots (i.e set `ax.set_ylim(-6,6)` for both plots). The following code is an example. ``` from matplotlib import pyplot as plt import numpy as np #Create so...
Here's another way, which I think is more versatile. ``` import numpy as np %matplotlib inline import matplotlib.pyplot as plt def align_zeros(axes): ylims_current = {} # Current ylims ylims_mod = {} # Modified ylims deltas = {} # ymax - ymin for ylims_current ratios = {} ...
55,646,777
I have a plot with two y-axis on a shared x-axis, and I want to make them align at y=0 so that I can draw a horizontal line to highlight the zero tick. currently the two axis are not aligned and I have to draw two line which is terrible. How can I achieve this?  [![enter image description here](https://i.stack.imgur....
2019/04/12
[ "https://Stackoverflow.com/questions/55646777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/459234/" ]
I had the same issue, and what I did was to change the extents of the y-axis, depending on the ratio of the min to max limits. If you set the ratio of the y-axes to be the same, the zero point should be the same. ``` fig, ax1 = plt.subplots() ax1.plot(...) # Plot first data set ax2 = ax1.twinx() ax2.plot(...) ...
I found [this excellent library](https://github.com/ryutok/mpl_axes_aligner) which aligns the axes and keeps automatic scaling. Install ------- `pip install mpl-axes-aligner` Usage ----- ```py import numpy as np import matplotlib.pyplot as plt import mpl_axes_aligner x = np.arange(0.0, 30, 0.1) y1 = 0.1 * x * np.s...
55,646,777
I have a plot with two y-axis on a shared x-axis, and I want to make them align at y=0 so that I can draw a horizontal line to highlight the zero tick. currently the two axis are not aligned and I have to draw two line which is terrible. How can I achieve this?  [![enter image description here](https://i.stack.imgur....
2019/04/12
[ "https://Stackoverflow.com/questions/55646777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/459234/" ]
I found [this excellent library](https://github.com/ryutok/mpl_axes_aligner) which aligns the axes and keeps automatic scaling. Install ------- `pip install mpl-axes-aligner` Usage ----- ```py import numpy as np import matplotlib.pyplot as plt import mpl_axes_aligner x = np.arange(0.0, 30, 0.1) y1 = 0.1 * x * np.s...
Here's another way, which I think is more versatile. ``` import numpy as np %matplotlib inline import matplotlib.pyplot as plt def align_zeros(axes): ylims_current = {} # Current ylims ylims_mod = {} # Modified ylims deltas = {} # ymax - ymin for ylims_current ratios = {} ...
55,646,777
I have a plot with two y-axis on a shared x-axis, and I want to make them align at y=0 so that I can draw a horizontal line to highlight the zero tick. currently the two axis are not aligned and I have to draw two line which is terrible. How can I achieve this?  [![enter image description here](https://i.stack.imgur....
2019/04/12
[ "https://Stackoverflow.com/questions/55646777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/459234/" ]
I had the same issue, and what I did was to change the extents of the y-axis, depending on the ratio of the min to max limits. If you set the ratio of the y-axes to be the same, the zero point should be the same. ``` fig, ax1 = plt.subplots() ax1.plot(...) # Plot first data set ax2 = ax1.twinx() ax2.plot(...) ...
Here's another way, which I think is more versatile. ``` import numpy as np %matplotlib inline import matplotlib.pyplot as plt def align_zeros(axes): ylims_current = {} # Current ylims ylims_mod = {} # Modified ylims deltas = {} # ymax - ymin for ylims_current ratios = {} ...
20,943,431
With the code: ``` <table> <tr><td contenteditable>My_Name</td><td>Surname</td></tr> <tr><td contenteditable>My_Name2</td><td>Surname2</td></tr> </table> ``` You can edit a cell in an HTML table. My problem is when I edit the cell and press `enter`, it creates a new line in cell. What I really would like is, if I pr...
2014/01/06
[ "https://Stackoverflow.com/questions/20943431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2672634/" ]
Disclaimer: This code requires JQuery. Something like this? <http://jsfiddle.net/v2Tdn/3/> ```js $('td').keypress(function (evt) { if (evt.which == 13) { evt.preventDefault(); var cellindex = $(this).index() // get next row, then select same cell index var rowindex = $(this).parent...
[Demo](http://jsfiddle.net/qft8S/2/) showing how to capture and `preventDefault` action on enter key press. Here's the code that does the trick: ``` $('table').bind('keypress', function (e) { var code = e.keyCode || e.which; if (code == 13) { console.log("Enter pressed"); e.pre...
20,943,431
With the code: ``` <table> <tr><td contenteditable>My_Name</td><td>Surname</td></tr> <tr><td contenteditable>My_Name2</td><td>Surname2</td></tr> </table> ``` You can edit a cell in an HTML table. My problem is when I edit the cell and press `enter`, it creates a new line in cell. What I really would like is, if I pr...
2014/01/06
[ "https://Stackoverflow.com/questions/20943431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2672634/" ]
I've built a fully editable table "Grid" in JS and HTML before.. and logic behind it simply is as following: 1- in your table after you layout all your cols, add an action col and add a "edit" link in each row that points to an Edit function, in this Edit link pass the row index so.. it will look like that: ``` <a hre...
[Demo](http://jsfiddle.net/qft8S/2/) showing how to capture and `preventDefault` action on enter key press. Here's the code that does the trick: ``` $('table').bind('keypress', function (e) { var code = e.keyCode || e.which; if (code == 13) { console.log("Enter pressed"); e.pre...
20,943,431
With the code: ``` <table> <tr><td contenteditable>My_Name</td><td>Surname</td></tr> <tr><td contenteditable>My_Name2</td><td>Surname2</td></tr> </table> ``` You can edit a cell in an HTML table. My problem is when I edit the cell and press `enter`, it creates a new line in cell. What I really would like is, if I pr...
2014/01/06
[ "https://Stackoverflow.com/questions/20943431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2672634/" ]
Disclaimer: This code requires JQuery. Something like this? <http://jsfiddle.net/v2Tdn/3/> ```js $('td').keypress(function (evt) { if (evt.which == 13) { evt.preventDefault(); var cellindex = $(this).index() // get next row, then select same cell index var rowindex = $(this).parent...
You have to understand that 'contenteditable' is making your markup behaving like a `<textarea>`. Normally, people press the `tab` key to skip from a form field to another. Using jQuery javascript library, you can read the keyboard for `enter` key, javascript it to 'escape' the edition by setting focus somewhere else,...
20,943,431
With the code: ``` <table> <tr><td contenteditable>My_Name</td><td>Surname</td></tr> <tr><td contenteditable>My_Name2</td><td>Surname2</td></tr> </table> ``` You can edit a cell in an HTML table. My problem is when I edit the cell and press `enter`, it creates a new line in cell. What I really would like is, if I pr...
2014/01/06
[ "https://Stackoverflow.com/questions/20943431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2672634/" ]
I've built a fully editable table "Grid" in JS and HTML before.. and logic behind it simply is as following: 1- in your table after you layout all your cols, add an action col and add a "edit" link in each row that points to an Edit function, in this Edit link pass the row index so.. it will look like that: ``` <a hre...
You have to understand that 'contenteditable' is making your markup behaving like a `<textarea>`. Normally, people press the `tab` key to skip from a form field to another. Using jQuery javascript library, you can read the keyboard for `enter` key, javascript it to 'escape' the edition by setting focus somewhere else,...
408,685
My old laptop died, and I need to rebuild my TeX-system. The new setup: > > Windows 10, > MikTeX 2.9, > WinEdt10.2 > > > In my old system I somehow managed to make WinEdt behave in the following IMHO desirable way. May be not your preferences, but this leads to an ideal workflow for me: 1. When I click a .TeX ...
2018/01/03
[ "https://tex.stackexchange.com/questions/408685", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/9446/" ]
Try this. 1. Open the Windows registry editor (`Win+R` -> regedit). 2. On the `HKEY_CLASSES_ROOT` find the `WinEdt.TeX` key. 3. Go to subkey `WinEdt.tex\shell\open\command` 4. On the `predefined` value, change something like `"C:\Program Files\WinEdt Team\WinEdt 10\WinEdt.exe" "%1"` to `"C:\Program Files\WinEdt Tea...
What Arzigoglu wrote in her/his answer is perfectly right. In fact `-V` is the right command line switch to start WinEdt in "virgin mode". However, instead of modifying the Windows registry, this can be done directly from within WinEdt. Open the Configuration Wizard dialog from the Options menu and select the "Filet...
1,903,700
I'd like a simple perl script / sub to read a sql server table into a hash, does anyone have a good script or snippet (with 'use's) that can do this given a connection string and table name? Here's a template: ``` sub sqltable { my ($connStr,$table) = @_; my ($user, $password, $host) = ($connectstr =~...
2009/12/14
[ "https://Stackoverflow.com/questions/1903700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9467/" ]
See [selectall\_hashref](http://search.cpan.org/perldoc/DBI#selectall_hashref) in the Perl DBI page.
You are exactly describing [Tie::DBI](http://search.cpan.org/dist/Tie-DBI/lib/Tie/DBI.pm). The `tie` facility in Perl allows native data structures (such as arrays and hashes) to represent data that comes from other mechanisms, such as databases and files. That said, there's a lot of reading you can do on the general ...
1,903,700
I'd like a simple perl script / sub to read a sql server table into a hash, does anyone have a good script or snippet (with 'use's) that can do this given a connection string and table name? Here's a template: ``` sub sqltable { my ($connStr,$table) = @_; my ($user, $password, $host) = ($connectstr =~...
2009/12/14
[ "https://Stackoverflow.com/questions/1903700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9467/" ]
See [selectall\_hashref](http://search.cpan.org/perldoc/DBI#selectall_hashref) in the Perl DBI page.
I think this is the solution you are looking for. ``` sub get_db { my ($server,$database,$tbl,$username,$password) = @_; my $dbh = DBI->connect("dbi:ODBC:DRIVER={SQL Server};SERVER=$server;DATABASE=$database",$username,$password); die "Error connecting to database: Error $DBI::err - $DBI::errstr\n" unless defi...
1,903,700
I'd like a simple perl script / sub to read a sql server table into a hash, does anyone have a good script or snippet (with 'use's) that can do this given a connection string and table name? Here's a template: ``` sub sqltable { my ($connStr,$table) = @_; my ($user, $password, $host) = ($connectstr =~...
2009/12/14
[ "https://Stackoverflow.com/questions/1903700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9467/" ]
Regarding connecting to SQL Server using Perl, * If you're on a Windows machine, see: [How do I connect to a MSSQL database using Perl’s DBI module in Windows?](https://stackoverflow.com/questions/202962/how-do-i-connect-to-a-mssql-database-using-perls-dbi-module-in-windows) * If you're on Linux, see: [How do I access...
You are exactly describing [Tie::DBI](http://search.cpan.org/dist/Tie-DBI/lib/Tie/DBI.pm). The `tie` facility in Perl allows native data structures (such as arrays and hashes) to represent data that comes from other mechanisms, such as databases and files. That said, there's a lot of reading you can do on the general ...
1,903,700
I'd like a simple perl script / sub to read a sql server table into a hash, does anyone have a good script or snippet (with 'use's) that can do this given a connection string and table name? Here's a template: ``` sub sqltable { my ($connStr,$table) = @_; my ($user, $password, $host) = ($connectstr =~...
2009/12/14
[ "https://Stackoverflow.com/questions/1903700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9467/" ]
Regarding connecting to SQL Server using Perl, * If you're on a Windows machine, see: [How do I connect to a MSSQL database using Perl’s DBI module in Windows?](https://stackoverflow.com/questions/202962/how-do-i-connect-to-a-mssql-database-using-perls-dbi-module-in-windows) * If you're on Linux, see: [How do I access...
I think this is the solution you are looking for. ``` sub get_db { my ($server,$database,$tbl,$username,$password) = @_; my $dbh = DBI->connect("dbi:ODBC:DRIVER={SQL Server};SERVER=$server;DATABASE=$database",$username,$password); die "Error connecting to database: Error $DBI::err - $DBI::errstr\n" unless defi...
1,646,951
Let $F\subset X$ be a finite family of sets of $X$. Is the sigma-algebra generated by $F$ ($\sigma(F)$) also finite? I was trying to use induction: If $F$ has one element say $A$ then $\sigma(F)=\{\varnothing, X, A, A^c\}$ Suppose that it is true for a family of sets with $n$ elements. Know Let $F$ a family of sets ...
2016/02/09
[ "https://math.stackexchange.com/questions/1646951", "https://math.stackexchange.com", "https://math.stackexchange.com/users/128422/" ]
No need for induction. If your sets are $A\_1,\ldots,A\_n$, then consider all the intersections $B\_1\cap \cdots \cap B\_n$, where each $B\_i$ is either $A\_i$ or $A\_i^c$. There are at most $2^n$ such intersections (you may have repetitions). Added: the $\sigma$-algebra is then formed by all unions of these sets, nam...
So $|\sigma(F)| \le 2^{2^{|F|}}$ for a finite family of sets $F$, where $|A|$ is used to denote the number of elements in $A$.