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 |
|---|---|---|---|---|---|
22,235,460 | I would like the program to re-do the while loop when it catches the exception - the exception being receiving a number zero. Instead it continues a while loop with the code below, I would like it to ask for the user input again until the user inputs a number that is different by zero.
```
import java.util.InputMismatchException;
import java.util.Scanner;
public class whilePerjashtim {
public static int division(int a, int b){
return a/b;
}
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int a, b;
System.out.println("Enter a value: ");
a = s.nextInt();
while(true){
try
{
System.out.println("Enter b value");
b = s.nextInt();
System.out.println("Sum of division is: " + division(a,b));
}
catch(ArithmeticException e)
{
System.err.println("Don't divide by zero!!!");
}
catch (java.util.InputMismatchException e)
{
System.err.println("Enter just a Number!!!");
}
finally
{
System.out.println();
}
}
}
}
``` | 2014/03/06 | [
"https://Stackoverflow.com/questions/22235460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3364271/"
] | Use something of the following form (not exact Java for your homework problem)
```
boolean validInput = false;
while (!validInput) {
.. get input
.. set validInput = true if no error
.. catch error
.. print try again message
}
``` | You can set a boolean value, that determines, if the `while` loop ends succesfully. Then in every loop you start by assuming the value is `true` and when an exception is raised, you set it to `false`.
```
boolean success = false;
while(success == false){
success = true;
try {
System.out.println("Enter b value");
b = s.nextInt();
System.out.println("Sum of divison is: " + division(a,b));
}
catch(ArithmeticException e) {
System.err.println("Dont divide by zero!!!");
success = false;
}
}
``` |
22,235,460 | I would like the program to re-do the while loop when it catches the exception - the exception being receiving a number zero. Instead it continues a while loop with the code below, I would like it to ask for the user input again until the user inputs a number that is different by zero.
```
import java.util.InputMismatchException;
import java.util.Scanner;
public class whilePerjashtim {
public static int division(int a, int b){
return a/b;
}
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int a, b;
System.out.println("Enter a value: ");
a = s.nextInt();
while(true){
try
{
System.out.println("Enter b value");
b = s.nextInt();
System.out.println("Sum of division is: " + division(a,b));
}
catch(ArithmeticException e)
{
System.err.println("Don't divide by zero!!!");
}
catch (java.util.InputMismatchException e)
{
System.err.println("Enter just a Number!!!");
}
finally
{
System.out.println();
}
}
}
}
``` | 2014/03/06 | [
"https://Stackoverflow.com/questions/22235460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3364271/"
] | Use something of the following form (not exact Java for your homework problem)
```
boolean validInput = false;
while (!validInput) {
.. get input
.. set validInput = true if no error
.. catch error
.. print try again message
}
``` | Define a boolean outside of your while loop, and use it for the while's condition.
Assuming I understood your question correctly, you want to stay in the loop if the user's input threw an exception, ie it was invalid input, and you want to break out of the loop when you get valid input from the user.
```
boolean gotValidInput = false;
while (!gotValidInput) {
try {
System.out.println("Enter b value");
b = s.nextInt();
gotValidInput = true;
System.out.println("Sum of divison is: " + division(a,b));
} catch(ArithmeticException e) {
System.err.println("Dont divide by zero!!!");
} catch (java.util.InputMismatchException e) {
System.err.println("Enter just a Number!!!");
} finally {
System.out.println();
}
}
```
In this implementation, your two exceptions would both be thrown before `gotValidInput = true;` gets evaluated, so it would only get set to true if no exceptions were thrown. |
22,235,460 | I would like the program to re-do the while loop when it catches the exception - the exception being receiving a number zero. Instead it continues a while loop with the code below, I would like it to ask for the user input again until the user inputs a number that is different by zero.
```
import java.util.InputMismatchException;
import java.util.Scanner;
public class whilePerjashtim {
public static int division(int a, int b){
return a/b;
}
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int a, b;
System.out.println("Enter a value: ");
a = s.nextInt();
while(true){
try
{
System.out.println("Enter b value");
b = s.nextInt();
System.out.println("Sum of division is: " + division(a,b));
}
catch(ArithmeticException e)
{
System.err.println("Don't divide by zero!!!");
}
catch (java.util.InputMismatchException e)
{
System.err.println("Enter just a Number!!!");
}
finally
{
System.out.println();
}
}
}
}
``` | 2014/03/06 | [
"https://Stackoverflow.com/questions/22235460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3364271/"
] | Use something of the following form (not exact Java for your homework problem)
```
boolean validInput = false;
while (!validInput) {
.. get input
.. set validInput = true if no error
.. catch error
.. print try again message
}
``` | You can put extra outter loop, like
```
while (true) {
System.out.println("Enter a value: ");
a = s.nextInt();
while(true) {
/// terminate the loop in case of problem with a, and allow a user to re done
}
}
``` |
22,235,460 | I would like the program to re-do the while loop when it catches the exception - the exception being receiving a number zero. Instead it continues a while loop with the code below, I would like it to ask for the user input again until the user inputs a number that is different by zero.
```
import java.util.InputMismatchException;
import java.util.Scanner;
public class whilePerjashtim {
public static int division(int a, int b){
return a/b;
}
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int a, b;
System.out.println("Enter a value: ");
a = s.nextInt();
while(true){
try
{
System.out.println("Enter b value");
b = s.nextInt();
System.out.println("Sum of division is: " + division(a,b));
}
catch(ArithmeticException e)
{
System.err.println("Don't divide by zero!!!");
}
catch (java.util.InputMismatchException e)
{
System.err.println("Enter just a Number!!!");
}
finally
{
System.out.println();
}
}
}
}
``` | 2014/03/06 | [
"https://Stackoverflow.com/questions/22235460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3364271/"
] | Use something of the following form (not exact Java for your homework problem)
```
boolean validInput = false;
while (!validInput) {
.. get input
.. set validInput = true if no error
.. catch error
.. print try again message
}
``` | Cleaned up the warnings and moved `s` to ouside the `main` method and defined it as `static`. It appears the s is a resource leak if within the main and is never closed.
```
import java.util.InputMismatchException;
import java.util.Scanner;
public class whilePerjashtim {
private static Scanner s;
public static int division(int a, int b) {
return a / b;
}
public static void main(String[] args) {
int a, b;
s = new Scanner(System.in);
System.out.println("Enter a value: ");
a = s.nextInt();
boolean input = false;
while (input == false) {
try {
System.out.println("Enter b value");
b = s.nextInt();
System.out.println("Sum of division is: " + division(a, b));
input = true;
}
catch (ArithmeticException e) {
System.err.println("Don't divide by zero!!!");
}
catch (InputMismatchException e) {
System.err.println("Enter just a Number!!!");
}
finally {
System.out.println();
}
}
}
}
``` |
22,235,460 | I would like the program to re-do the while loop when it catches the exception - the exception being receiving a number zero. Instead it continues a while loop with the code below, I would like it to ask for the user input again until the user inputs a number that is different by zero.
```
import java.util.InputMismatchException;
import java.util.Scanner;
public class whilePerjashtim {
public static int division(int a, int b){
return a/b;
}
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int a, b;
System.out.println("Enter a value: ");
a = s.nextInt();
while(true){
try
{
System.out.println("Enter b value");
b = s.nextInt();
System.out.println("Sum of division is: " + division(a,b));
}
catch(ArithmeticException e)
{
System.err.println("Don't divide by zero!!!");
}
catch (java.util.InputMismatchException e)
{
System.err.println("Enter just a Number!!!");
}
finally
{
System.out.println();
}
}
}
}
``` | 2014/03/06 | [
"https://Stackoverflow.com/questions/22235460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3364271/"
] | Use something of the following form (not exact Java for your homework problem)
```
boolean validInput = false;
while (!validInput) {
.. get input
.. set validInput = true if no error
.. catch error
.. print try again message
}
``` | You need to handle the erroneous input as well if you want the while loop to continue properly: You need to get rid of the erroneous input at the end of each catch block. Adding continue will simply make the loop run again until the user gives the correct input.
```
catch (InputMismatchException e)
{
System.err.println("Enter just a Number!!!");
//add this
s.nextLine();
continue;
}
``` |
25,204,979 | I am having trouble getting my regex to match the pattern `"(cmd: .*)"`.
For example, I want to match `"(cmd: cd $HOME)"`.
Here is my regex : `\(cmd:\s+.*\)`
The problem is, this will also match `"(cmd: char) ()"`. Since there is a `".*"` inside the regex, it will match all `")"` until the last one it sees. How, do I modify the regex so that it will match something like `"(cmd: (asd) )"` but not if `")"` does not have a matching `"("`. So for instance, the regex would not match the very last parenthesis of this string: `"(cmd: asd) )"`. | 2014/08/08 | [
"https://Stackoverflow.com/questions/25204979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2759719/"
] | I would add another group to capture only thing you need.
```
^\(cmd\:(.*)\)$
``` | It is not possible to accomplish this with a regex. Brace or parenthesis matching requires a recursive/counting feature that is not available in a regex. You'll need a parser for this.
More details available here: <http://blogs.msdn.com/jaredpar/archive/2008/10/15/regular-expression-limitations.aspx> |
25,204,979 | I am having trouble getting my regex to match the pattern `"(cmd: .*)"`.
For example, I want to match `"(cmd: cd $HOME)"`.
Here is my regex : `\(cmd:\s+.*\)`
The problem is, this will also match `"(cmd: char) ()"`. Since there is a `".*"` inside the regex, it will match all `")"` until the last one it sees. How, do I modify the regex so that it will match something like `"(cmd: (asd) )"` but not if `")"` does not have a matching `"("`. So for instance, the regex would not match the very last parenthesis of this string: `"(cmd: asd) )"`. | 2014/08/08 | [
"https://Stackoverflow.com/questions/25204979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2759719/"
] | I would add another group to capture only thing you need.
```
^\(cmd\:(.*)\)$
``` | You want a regex that allows brackets in the match, but only if they are paired. Like this regex:
```
\(cmd:\s+([^()]*\([^()]\))*[^()]*\)
```
See [live demo](http://rubular.com/r/J5stvp8duY) |
25,204,979 | I am having trouble getting my regex to match the pattern `"(cmd: .*)"`.
For example, I want to match `"(cmd: cd $HOME)"`.
Here is my regex : `\(cmd:\s+.*\)`
The problem is, this will also match `"(cmd: char) ()"`. Since there is a `".*"` inside the regex, it will match all `")"` until the last one it sees. How, do I modify the regex so that it will match something like `"(cmd: (asd) )"` but not if `")"` does not have a matching `"("`. So for instance, the regex would not match the very last parenthesis of this string: `"(cmd: asd) )"`. | 2014/08/08 | [
"https://Stackoverflow.com/questions/25204979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2759719/"
] | Give you one Java implementation sample as below:
```
String str3 = "(cmd: (((char))) (ddt)) ()";
String regexp = "\\(cmd: "+ nestingPair(5, '(', ')')+ "\\)";
Pattern pMod = Pattern.compile(regexp);
Matcher mMod = pMod.matcher(str3);
while (mMod.find()) {
System.out.println(mMod.group(0));
}
public String nestingPair(int level, char b, char e) {
String ret = "";
if (level <= 0) { return ret; }
String common = "(?>[^" + b + e + "]*(?>\\\\" + b + "888_888" + "\\\\" + e + ")*[^" + b + e
+ "]*)*";
String core = "[^" + b + e + "]*";
String replace = "(?>[^" + b + e + "]*(?>\\" + b + "888_888" + "\\" + e + ")*[^" + b + e
+ "]*)*";
for (int i = 0; i < level - 1; i++) {
// System.out.println(replace);
replace = replace.replaceFirst("888_888", common);
}
// System.out.println(replace);
ret = replace.replaceAll("888_888", core);
return ret;
}
```
Then, the output is:
```
(cmd: (((char))) (ddt))
```
One remark: The recursive level could be set according to your actual requirements. (in my sample, I set it to 5, normally, I think is enough. I have tried 500, it's ok. but for 1000 , it'll be StackOverFlow).
Since normally, Java-regex doesn't support the Matching Text with Nested Parentheses or any other Nested characters. (e.g. (), {}, [], <>, etc).
There is one open source project ["jree"](http://sourceforge.net/projects/jree/), which has provided this kind of support. FYI. | I would add another group to capture only thing you need.
```
^\(cmd\:(.*)\)$
``` |
25,204,979 | I am having trouble getting my regex to match the pattern `"(cmd: .*)"`.
For example, I want to match `"(cmd: cd $HOME)"`.
Here is my regex : `\(cmd:\s+.*\)`
The problem is, this will also match `"(cmd: char) ()"`. Since there is a `".*"` inside the regex, it will match all `")"` until the last one it sees. How, do I modify the regex so that it will match something like `"(cmd: (asd) )"` but not if `")"` does not have a matching `"("`. So for instance, the regex would not match the very last parenthesis of this string: `"(cmd: asd) )"`. | 2014/08/08 | [
"https://Stackoverflow.com/questions/25204979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2759719/"
] | Give you one Java implementation sample as below:
```
String str3 = "(cmd: (((char))) (ddt)) ()";
String regexp = "\\(cmd: "+ nestingPair(5, '(', ')')+ "\\)";
Pattern pMod = Pattern.compile(regexp);
Matcher mMod = pMod.matcher(str3);
while (mMod.find()) {
System.out.println(mMod.group(0));
}
public String nestingPair(int level, char b, char e) {
String ret = "";
if (level <= 0) { return ret; }
String common = "(?>[^" + b + e + "]*(?>\\\\" + b + "888_888" + "\\\\" + e + ")*[^" + b + e
+ "]*)*";
String core = "[^" + b + e + "]*";
String replace = "(?>[^" + b + e + "]*(?>\\" + b + "888_888" + "\\" + e + ")*[^" + b + e
+ "]*)*";
for (int i = 0; i < level - 1; i++) {
// System.out.println(replace);
replace = replace.replaceFirst("888_888", common);
}
// System.out.println(replace);
ret = replace.replaceAll("888_888", core);
return ret;
}
```
Then, the output is:
```
(cmd: (((char))) (ddt))
```
One remark: The recursive level could be set according to your actual requirements. (in my sample, I set it to 5, normally, I think is enough. I have tried 500, it's ok. but for 1000 , it'll be StackOverFlow).
Since normally, Java-regex doesn't support the Matching Text with Nested Parentheses or any other Nested characters. (e.g. (), {}, [], <>, etc).
There is one open source project ["jree"](http://sourceforge.net/projects/jree/), which has provided this kind of support. FYI. | It is not possible to accomplish this with a regex. Brace or parenthesis matching requires a recursive/counting feature that is not available in a regex. You'll need a parser for this.
More details available here: <http://blogs.msdn.com/jaredpar/archive/2008/10/15/regular-expression-limitations.aspx> |
25,204,979 | I am having trouble getting my regex to match the pattern `"(cmd: .*)"`.
For example, I want to match `"(cmd: cd $HOME)"`.
Here is my regex : `\(cmd:\s+.*\)`
The problem is, this will also match `"(cmd: char) ()"`. Since there is a `".*"` inside the regex, it will match all `")"` until the last one it sees. How, do I modify the regex so that it will match something like `"(cmd: (asd) )"` but not if `")"` does not have a matching `"("`. So for instance, the regex would not match the very last parenthesis of this string: `"(cmd: asd) )"`. | 2014/08/08 | [
"https://Stackoverflow.com/questions/25204979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2759719/"
] | Give you one Java implementation sample as below:
```
String str3 = "(cmd: (((char))) (ddt)) ()";
String regexp = "\\(cmd: "+ nestingPair(5, '(', ')')+ "\\)";
Pattern pMod = Pattern.compile(regexp);
Matcher mMod = pMod.matcher(str3);
while (mMod.find()) {
System.out.println(mMod.group(0));
}
public String nestingPair(int level, char b, char e) {
String ret = "";
if (level <= 0) { return ret; }
String common = "(?>[^" + b + e + "]*(?>\\\\" + b + "888_888" + "\\\\" + e + ")*[^" + b + e
+ "]*)*";
String core = "[^" + b + e + "]*";
String replace = "(?>[^" + b + e + "]*(?>\\" + b + "888_888" + "\\" + e + ")*[^" + b + e
+ "]*)*";
for (int i = 0; i < level - 1; i++) {
// System.out.println(replace);
replace = replace.replaceFirst("888_888", common);
}
// System.out.println(replace);
ret = replace.replaceAll("888_888", core);
return ret;
}
```
Then, the output is:
```
(cmd: (((char))) (ddt))
```
One remark: The recursive level could be set according to your actual requirements. (in my sample, I set it to 5, normally, I think is enough. I have tried 500, it's ok. but for 1000 , it'll be StackOverFlow).
Since normally, Java-regex doesn't support the Matching Text with Nested Parentheses or any other Nested characters. (e.g. (), {}, [], <>, etc).
There is one open source project ["jree"](http://sourceforge.net/projects/jree/), which has provided this kind of support. FYI. | You want a regex that allows brackets in the match, but only if they are paired. Like this regex:
```
\(cmd:\s+([^()]*\([^()]\))*[^()]*\)
```
See [live demo](http://rubular.com/r/J5stvp8duY) |
5,573,396 | How do I set up a fall-back file for an IceCast server? | 2011/04/06 | [
"https://Stackoverflow.com/questions/5573396",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/565403/"
] | If you happen to be using a very useful toolset named **liquidsoap** with icecast2 then you ought to be thrilled with the follow example, which will **play a directory of sound files, or if there is a live stream broadcast then it will fadeout the playlist, play a "jingle" sound file, then fadeup the live stream**. Aside from the silly urls this was pulled from a working environment.
Installing liquidsoap was as painless as apt-get install. If you want to use mp3 then apt-get install lame and then switch to output.icecast.lame(). Create a file with a .liq extension (example.liq), then chmod +x example.liq and you're off to the ./races
Cheerz!
```
#!/usr/bin/liquidsoap
# use the -d flag for daemon mode
set("log.file",false)
set("log.stdout",true)
set("log.level",3)
set("harbor.icy",true)
default = single("say:How are you gentlemen!!
all your base are belong to us.
You are on the way to destruction.
What you say!!
You have no chance to survive make your time!
HA! HA! HA! HA! HA!")
jingles = playlist("/home/edward/micronemez-jinglez")
audio = playlist("/home/edward/micronemez-ogg")
#liveset = mksafe(input.http("http://audio.micronemez.com"))
liveset = strip_blank(input.http("http://f-dt.com"))
liveset = rewrite_metadata([("artist", "FUTURE__DEATH__TOLL"),("title", "LIVE FROM YELLOW_HOUSE")], liveset)
radio = fallback(track_sensitive=false,
[skip_blank(liveset), audio, default])
radio = random(weights=[1,5],[ jingles, radio ])
output.icecast.vorbis(
host="futuredeathtoll.com",port=8000,password="hackme",
genre="Easy Listening",url="http://f-dt.com",
description="pirate radio",mount="micronemez-radio.ogg",
name="FUTURE__DEATH__TOLL ((YELLOW_HOUSE))",radio)
```
some very useful links:
<http://savonet.sourceforge.net/doc-svn/cookbook.html>
<http://oshyn.com/_blog/General/post/Audio_and_Video_Streaming_with_Liquidsoap_and_Icecast/>
<http://wiki.sourcefabric.org/display/LS/WikiStart> | From the doc:
```
fallback-mount>/example2.ogg</fallback-mount>
<fallback-override>1</fallback-override>
<fallback-when-full>1</fallback-when-full>`
```
Please see [icecast2\_config\_file](http://www.icecast.org/docs/icecast-2.3.1/icecast2_config_file.html) for more explanation scroll to the fallback-mount description. |
1,771,470 | I recently found an example on implementing a We3bService with groovy and jax-ws:
the problem is that the @webmethod annotation seems to be ignored.
This is the source code of the groovy script:
```
import javax.jws.soap.*
import javax.jws.*
import javax.xml.ws.*
import javax.xml.bind.annotation.*
@XmlAccessorType(XmlAccessType.FIELD)
class Book {
String name
String author
}
@WebService (targetNamespace="http://predic8.com/groovy-jax/")
@SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.BARE)
class BookService{
@WebMethod
def add(Book book){
println "Name of the book: ${book.name}"
}
}
Endpoint.publish("http://localhost:9000/book", new BookService())
```
and this is the exception caught:
Caught: com.sun.xml.internal.ws.model.RuntimeModelerException:
runtime modeler error: SEI BookService has method **setProperty** annotated as BARE but it has more than one parameter bound to body. This is invalid. Please annotate the method with annotation: @SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)
at wstest.run(wstest.groovy:21) | 2009/11/20 | [
"https://Stackoverflow.com/questions/1771470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/278124/"
] | Two ways of doing it come to mind right away, there are probably others. Both require storing an IP in the database.
1. Block the vote from being created with a uniqueness validation.
```
class Vote < ActiveRecord::Base
validates_uniqueness_of :ip_address
...
end
```
2. Block the vote from being created in the controller
```
class VotesConroller < ApplicationController
...
def create
unless Vote.find_by_post_id_and_ip_address(params[:post_id],request.remote_ip)
posts.votes.create!(params[:vote].update({:ip_address => request.remote_ip}))
end
end
end
``` | You could add an `ip_address` attribute to your `votes` table and `validates_uniqueness_of :ip_address` to ensure that only one vote can come from an IP. |
1,771,470 | I recently found an example on implementing a We3bService with groovy and jax-ws:
the problem is that the @webmethod annotation seems to be ignored.
This is the source code of the groovy script:
```
import javax.jws.soap.*
import javax.jws.*
import javax.xml.ws.*
import javax.xml.bind.annotation.*
@XmlAccessorType(XmlAccessType.FIELD)
class Book {
String name
String author
}
@WebService (targetNamespace="http://predic8.com/groovy-jax/")
@SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.BARE)
class BookService{
@WebMethod
def add(Book book){
println "Name of the book: ${book.name}"
}
}
Endpoint.publish("http://localhost:9000/book", new BookService())
```
and this is the exception caught:
Caught: com.sun.xml.internal.ws.model.RuntimeModelerException:
runtime modeler error: SEI BookService has method **setProperty** annotated as BARE but it has more than one parameter bound to body. This is invalid. Please annotate the method with annotation: @SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)
at wstest.run(wstest.groovy:21) | 2009/11/20 | [
"https://Stackoverflow.com/questions/1771470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/278124/"
] | I would do both EmFi and bensie said and store the IP address with the vote but you might also want to look into creating a blacklist of IPs which you want to block because the represent popular proxy servers (for example, the many proxies in the <http://proxy.org/> list).
As you add to the list it will make it at least a little bit harder for users to cheat. | You could add an `ip_address` attribute to your `votes` table and `validates_uniqueness_of :ip_address` to ensure that only one vote can come from an IP. |
1,771,470 | I recently found an example on implementing a We3bService with groovy and jax-ws:
the problem is that the @webmethod annotation seems to be ignored.
This is the source code of the groovy script:
```
import javax.jws.soap.*
import javax.jws.*
import javax.xml.ws.*
import javax.xml.bind.annotation.*
@XmlAccessorType(XmlAccessType.FIELD)
class Book {
String name
String author
}
@WebService (targetNamespace="http://predic8.com/groovy-jax/")
@SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.BARE)
class BookService{
@WebMethod
def add(Book book){
println "Name of the book: ${book.name}"
}
}
Endpoint.publish("http://localhost:9000/book", new BookService())
```
and this is the exception caught:
Caught: com.sun.xml.internal.ws.model.RuntimeModelerException:
runtime modeler error: SEI BookService has method **setProperty** annotated as BARE but it has more than one parameter bound to body. This is invalid. Please annotate the method with annotation: @SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)
at wstest.run(wstest.groovy:21) | 2009/11/20 | [
"https://Stackoverflow.com/questions/1771470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/278124/"
] | Two ways of doing it come to mind right away, there are probably others. Both require storing an IP in the database.
1. Block the vote from being created with a uniqueness validation.
```
class Vote < ActiveRecord::Base
validates_uniqueness_of :ip_address
...
end
```
2. Block the vote from being created in the controller
```
class VotesConroller < ApplicationController
...
def create
unless Vote.find_by_post_id_and_ip_address(params[:post_id],request.remote_ip)
posts.votes.create!(params[:vote].update({:ip_address => request.remote_ip}))
end
end
end
``` | I would do both EmFi and bensie said and store the IP address with the vote but you might also want to look into creating a blacklist of IPs which you want to block because the represent popular proxy servers (for example, the many proxies in the <http://proxy.org/> list).
As you add to the list it will make it at least a little bit harder for users to cheat. |
18,511,286 | i been wanting to pass a data in the textfield of my selected cell, but im getting a full array of that parsed data where i NSLog the data it let me sees what data im passing and also the thing is when i click on any cell it gives me an exception, which is below
```
[UITableViewController setParentKey:]: unrecognized selector sent to instance 0x7169670
2013-08-29 17:37:58.937 [8322:11303] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewController setParentKey:]: unrecognized selector sent to instance 0x7169670'
```
As im getting an Array of data from the indexPathForSelectedRow.row i have a MutableArray initialized to catch the passed data in my destination view, my segue code goes like that too, what am i doing wrong here?
```
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:@"MySegue"]) {
ChildTableViewController *myNextPage = [segue destinationViewController];
myNextPage.parentKey = [[parsedData listPopulated]objectAtIndex:self.tableView.indexPathForSelectedRow.row];
NSLog(@"segue value = %@", [[parsedData listPopulated]objectAtIndex:self.tableView.indexPathForSelectedRow.row]);
}
}
``` | 2013/08/29 | [
"https://Stackoverflow.com/questions/18511286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2641205/"
] | It looks like you are expecting a `ChildTableViewController` but receiving a `UITableViewController`. Make sure your segue is navigating to what you think. You can also add this:
```
if ([myNextPage isKindOfClass:[ChildTableViewController class]])
```
That will likely prevent the crash, but if the segue is misconfiguration to go to the wrong view controller, you will need to fix that as well for the segue to do anything.
 | Error showing that you are trying to set the `parentKey` property of `UITableViewController` in fact `UITableViewController` doesn't have a property called `parentKey`. So make sure that you properly set the class of your view controller in storyboard to `ChildTableViewController` instead of `UITableViewController` |
18,773,531 | I have some very simple code that works in on the desktop with Chrome, Firefox, IE, and Safari on the Desktop, but when I try it on my Iphone it fails.
It's basically
```
var img1 = document.createElement('img');
img1.onerror = function() {
console.log('img1 fail');
};
img1.onload = function() {
console.log('img1 success');
};
img1.src = 'http://gvgmaps.com/linktothepast/maps/LegendOfZelda-ALinkToThePast-LightWorld.png';
```
The problem is that on the IPhone the `onerror` function runs instead of the `onload`. For the desktop the `onload` runs just fine and there is no `onerror`.
<http://jsfiddle.net/PvY5t/4/>
With the fiddle img1 fails for an unknown reason and img2 is a success.
Can someone please tell me how to get the onload to run sucessfully for img1 and img2 on the IPhone?
EDIT:
Very interesting. I resaved the img as a jpg and now it works <http://jsfiddle.net/PvY5t/9/> Can someone please provide some color on why this might be.
EDIT2:
These links here seem very relevant
[(Really) Long Background Image Does Not Render on iPad Safari](https://stackoverflow.com/questions/9046143/really-long-background-image-does-not-render-on-ipad-safari)
<https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariWebContent/CreatingContentforSafarioniPhone/CreatingContentforSafarioniPhone.html> | 2013/09/12 | [
"https://Stackoverflow.com/questions/18773531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1308788/"
] | Ok I think the answer is this.
I am trying to use a PNG file that is 4096 x 4096
However this apple link
<https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariWebContent/CreatingContentforSafarioniPhone/CreatingContentforSafarioniPhone.html>
says for PNGs my image must be
`width * height ≤ 3 * 1024 * 1024`
Clearly **I am over the known iOS resource limit.**
Max image size for a square should be `sqrt(3 * 1024 * 1024)` which is like 1773px. Sure enough when I shrink the image to 1770px it works <http://jsfiddle.net/PvY5t/10/>
JPEGs have a different resource limit, so my jpg that worked didn't hit that limit. | So I was doing some network profiling in Safari on my iOS Simulator, and it seems like the first image is being requested fine (Response Status 200, OK, and the image seems to be loaded). Still unsure why it's firing the onerror event rather than the onload event though. I'm guessing it has something to do with the headers that Javascript's expecting to get back when the image is loaded, but I can't seem to track it down. Stay tuned for edits.
Edit: do you own/manage the server where the image is hosted? If so it's possible your server is doing something funky when it's serving .png images. |
18,773,531 | I have some very simple code that works in on the desktop with Chrome, Firefox, IE, and Safari on the Desktop, but when I try it on my Iphone it fails.
It's basically
```
var img1 = document.createElement('img');
img1.onerror = function() {
console.log('img1 fail');
};
img1.onload = function() {
console.log('img1 success');
};
img1.src = 'http://gvgmaps.com/linktothepast/maps/LegendOfZelda-ALinkToThePast-LightWorld.png';
```
The problem is that on the IPhone the `onerror` function runs instead of the `onload`. For the desktop the `onload` runs just fine and there is no `onerror`.
<http://jsfiddle.net/PvY5t/4/>
With the fiddle img1 fails for an unknown reason and img2 is a success.
Can someone please tell me how to get the onload to run sucessfully for img1 and img2 on the IPhone?
EDIT:
Very interesting. I resaved the img as a jpg and now it works <http://jsfiddle.net/PvY5t/9/> Can someone please provide some color on why this might be.
EDIT2:
These links here seem very relevant
[(Really) Long Background Image Does Not Render on iPad Safari](https://stackoverflow.com/questions/9046143/really-long-background-image-does-not-render-on-ipad-safari)
<https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariWebContent/CreatingContentforSafarioniPhone/CreatingContentforSafarioniPhone.html> | 2013/09/12 | [
"https://Stackoverflow.com/questions/18773531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1308788/"
] | Ok I think the answer is this.
I am trying to use a PNG file that is 4096 x 4096
However this apple link
<https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariWebContent/CreatingContentforSafarioniPhone/CreatingContentforSafarioniPhone.html>
says for PNGs my image must be
`width * height ≤ 3 * 1024 * 1024`
Clearly **I am over the known iOS resource limit.**
Max image size for a square should be `sqrt(3 * 1024 * 1024)` which is like 1773px. Sure enough when I shrink the image to 1770px it works <http://jsfiddle.net/PvY5t/10/>
JPEGs have a different resource limit, so my jpg that worked didn't hit that limit. | I came across this issue on iOS 9 because I had set `img.crossOrigin = "anonymous"`.
Removing that allowed large photos direct from the camera to load on an iPad. |
2,497,668 | I'm looking to dynamically add watermarks to a video on a website. What, in your opinion, is the best language and library to do so? | 2010/03/23 | [
"https://Stackoverflow.com/questions/2497668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/210072/"
] | You can do this using ffmpeg (from command line or using one of its API such as [ffmpeg-php](http://ffmpeg-php.sourceforge.net/)) with the [watermark](http://www.linuxjournal.com/video/add-watermark-video-ffmpeg) or [drawtext](http://goinggnu.wordpress.com/2007/05/07/watermark-videos-with-ffmpeg/) vhook component, depending of what you want to add (a logo or a simple text). | I believe you have a couple choices.
Both Flash and Silverlight should allow you to create a separate layer and have your watermark displayed.
I'm not sure if there is a way to do this with mpeg/qt videos. |
2,497,668 | I'm looking to dynamically add watermarks to a video on a website. What, in your opinion, is the best language and library to do so? | 2010/03/23 | [
"https://Stackoverflow.com/questions/2497668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/210072/"
] | I believe you have a couple choices.
Both Flash and Silverlight should allow you to create a separate layer and have your watermark displayed.
I'm not sure if there is a way to do this with mpeg/qt videos. | Of course, <http://ffmpeg-php.sourceforge.net/> is better to dynamically add watermarks to a video on your website. |
2,497,668 | I'm looking to dynamically add watermarks to a video on a website. What, in your opinion, is the best language and library to do so? | 2010/03/23 | [
"https://Stackoverflow.com/questions/2497668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/210072/"
] | You can do this using ffmpeg (from command line or using one of its API such as [ffmpeg-php](http://ffmpeg-php.sourceforge.net/)) with the [watermark](http://www.linuxjournal.com/video/add-watermark-video-ffmpeg) or [drawtext](http://goinggnu.wordpress.com/2007/05/07/watermark-videos-with-ffmpeg/) vhook component, depending of what you want to add (a logo or a simple text). | Of course, <http://ffmpeg-php.sourceforge.net/> is better to dynamically add watermarks to a video on your website. |
72,838,101 | Using Angular, I have created an icon component, which allows for attributes `size` and `color` to be set. The following HTML tag creates an icon:
```
<my-icon size='medium' color='primary-dark'>person</my-icon>
```
This component is essentially just a wrapper of the material-icons tag. The attributes `size` and `color` simply add a CSS class to the material-icons tag.
Now, I am using this icon component in one of my parent components. When hovering above this icon, I want to change its color. For this purpose, I have just created some SCSS in my parent component:
```
my-icon {
&:hover {
color: blue;
}
}
```
I have also tried adding an `::ng-deep` in front of `my-icon`. However, the color doesn't change upon hovering above the icon. Changing the opacity instead of the color works.
Apparently, my parent cannot change the color of my icon. I am not sure why. Taking a look at the browser console simply shows that the icon component has a CSS class connected to it, which represents the color set by the color attribute.
Anyways: Can somebody explain this behavior to me? | 2022/07/02 | [
"https://Stackoverflow.com/questions/72838101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11225028/"
] | Your CSS syntax is not valid: <https://codebeautify.org/cssvalidate/y22780750>
Correct syntax:
styles.css
```css
my-icon > mat-icon:hover {
color: blue;
}
.green {
color: green;
}
.medium {
font-size: 50px !important;
}
.large {
font-size: 100px !important;
}
```
Do note, that for size `font-size` I needed to use `!important` to overwrite material defaults.
>
> If you use the !important rule, it will override ALL previous styling rules for that specific property on that element! <https://www.w3schools.com/css/css_important.asp>
>
>
>
Parent html:
```html
<my-icon [size]="'medium'" [color]="'green'" [name]="'person'"></my-icon>
```
For `@Input` binding we use brackets `[]` though it will work without too, just will be more understandable that its a binding. Probably will avoid some unnecessary warnings too from TS or linters.
MyIconComponent:
```js
import { Component, Input } from '@angular/core';
@Component({
selector: 'my-icon',
template: `<mat-icon [ngClass]="[size, color]" aria-label="Example home icon">{{name}}</mat-icon>`,
styles: [`h1 { font-family: Lato; }`],
})
export class MyIconComponent {
@Input() size: string;
@Input() color: string;
@Input() name: string;
}
```
So when you are saying `my-icon:hover { color: blue;}` *(<- this one is valid syntax)* it means `my-icon` should be blue on hover. Ok fine. But the the children of `my-icon`, the `mat-icon`'s, are still going to be green. `my-icon` won't care if it's color should be blue, what should be blue exactly, it doesn't know on what the color should be applied on.
However if you did for example `my-icon :hover { background: blue !important; }` then something would happen with `my-icon` because it does have a background (you can try this with the demo).
Using `my-icon > mat-icon` we target children of `my-icon` and only `mat-icon`'s and their color will be blue on `:hover`, since `mat-icons` know what to do with property `color` - so, they will change their color on hover.
Working example: <https://stackblitz.com/edit/angular-ivy-bqwdqu?file=src%2Fapp%2Fapp.component.html> | You can apply hover style from css to that class
For more reference:
<https://www.w3schools.com/csSref/sel_hover.asp> |
98,496 | The code of my script:
```
import drawtext
drawtext.chain = 'Hello World!'
drawtext.positionx = 0
drawtext.positiony = 0
```
The code of the file drawtext.py:
```
# import game engine modules
from bge import render, logic
# import stand alone modules
import bgl, blf
# create a new font object, use external ttf file
font_path = logic.expandPath('C://Documents and Settings//Guillermo//Mis documentos//Google Drive//Gproyectos//Proyectos con Blender//arial.ttf')
# store the font indice - to use later
font_id = blf.load(font_path)
chain = 'this is the message'
positionx = 0.5
positiony = 0.5
def write():
"""write on screen"""
width = render.getWindowWidth()
height = render.getWindowHeight()
# OpenGL setup
bgl.glMatrixMode(bgl.GL_PROJECTION)
bgl.glLoadIdentity()
bgl.gluOrtho2D(0, width, 0, height)
bgl.glMatrixMode(bgl.GL_MODELVIEW)
bgl.glLoadIdentity()
# BLF drawing routine
blf.position(font_id, (width * positionx), (height * positiony), 0)
blf.size(font_id, 50, 72)
bgl.glColor4f(1.0, 0.0, 0.0, 1.0)
blf.draw(font_id,chain)
def update(cont):
own = cont.owner
chain = own['msg']
# set the font drawing routine to run every frame
scene = logic.getCurrentScene()
scene.post_draw = [write]
```
when you run the game engine, you see this:
[](https://i.stack.imgur.com/7nmbI.png)
And what I want to do is to obtein this:
[](https://i.stack.imgur.com/HJOZM.png)
How can I change my code? | 2018/01/14 | [
"https://blender.stackexchange.com/questions/98496",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/50527/"
] | Managing multiple text fragments
================================
I suggest to place the text attributes into a container such such as a class:
```
class Text():
def __init__(self, text, x, y, color, font_id):
self.text = text
self.x = x
self.y = y
self.color = color
self.font_id = font_id
```
You can use a list or dict too, but I think this is easier to understand as you see the structure of the data.
Then place modify your code that it can work with the above text container:
```
blf.position(text.font_id, (width * text.x), (height * text.y), 0)
blf.size(text.font_id, 50, 72)
bgl.glColor4f(*text.color)
blf.draw(text.font_id, text.text)
```
This still allows just one text to be drawn (as there is just one text container). But now it is pretty easy for us to create a container that can contain any number of texts:
```
texts = []
```
You create that once in your drawtext.py replacing *font\_id*, *chain*, *positionx*, *positiony*.
Make sure your write() can deal with more than one text container:
```
for text in texts:
blf.position(text.font_id, (width * text.x), (height * text.y), 0)
blf.size(text.font_id, 50, 72)
bgl.glColor4f(*text.color)
blf.draw(text.font_id, text.text)
```
Now you can add some comfort to your module, by providing a function that let you easily add new texts:
```
def add(text, x, y, color, font_id=0):
texts.append(Text(text, x, y, color, font_id))
```
Your using script can look like that:
```
import drawtext
import bge
COLOR_GREEN = 0.0, 1.0, 0.0, 1.0
if all(sensor.positive for sensor in bge.logic.getCurrentController().sensors):
drawtext.add("Hello Green World!", 0, 0.15, COLOR_GREEN)
```
The complete drawwtext.py can look like that:
```
import bge
import bgl, blf
texts = []
class Text():
def __init__(self, text, x, y, color, font_id):
self.text = text
self.x = x
self.y = y
self.color = color
self.font_id = font_id
def add(text, x, y, color, font_id=0):
return texts.append(Text(text, x, y, color, font_id))
def write():
"""write on screen"""
width = bge.render.getWindowWidth()
height = bge.render.getWindowHeight()
# OpenGL setup
bgl.glMatrixMode(bgl.GL_PROJECTION)
bgl.glLoadIdentity()
bgl.gluOrtho2D(0, width, 0, height)
bgl.glMatrixMode(bgl.GL_MODELVIEW)
bgl.glLoadIdentity()
# BLF drawing routine
for text in texts:
blf.position(text.font_id, (width * text.x), (height * text.y), 0)
blf.size(text.font_id, 50, 72)
bgl.glColor4f(*text.color)
blf.draw(text.font_id, text.text)
bge.logic.getCurrentScene().post_draw = [write]
```
Font Management
===============
You might have noticed that I skipped fonts in the above code by making them optional. I recommend to manage them separately. The blf-module is the font container already. But you need a way to provide easy access to the loaded fonts without dealing with cryptic numbers. I suggest to create a new module fonts.py encapsulating the load operation:
```
import blf
def load(file):
return blf.load(bge.logic.expandPath(file))
```
this enables you to declare font "constants" right at the beginning of drawtext.py:
```
FONT_ID_ARIAL = fonts.load("//arial.ttf")
FONT_ID_AGENCYR = fonts.load("//AGENCYR.TTF")
```
Which on the other hand enables you to use them when defining your text fragments:
```
import drawtext
import bge
COLOR_GREEN = 0.0, 1.0, 0.0, 1.0
if all(sensor.positive for sensor in bge.logic.getCurrentController().sensors):
drawtext.add("Hello Green World!", 0, 0.15, COLOR_GREEN, drawtext.FONT_ID_AGENCYR)
```
The reason why load() is placed in a new module is simply to avoid defining this function before you define the constants, which let the constants be a the pretty top of drawtext.py
Color Management
================
You can do a similar method with colors. Right now each user script adds his own color. You can provide a few color constants right at the beginning of the module:
```
COLOR_GREEN = 0.0, 1.0, 0.0, 1.0
COLOR_RED = 1.0, 0.0, 0.0, 1.0
COLOR_BLUE = 0.0, 0.0, 1.0, 1.0
COLOR_BLACK = 0.0, 0.0, 0.0, 1.0
COLOR_WHITE = 1.0, 1.0, 1.0, 1.0
```
this allows to use them wherever this module is used:
```
import drawtext
import bge
if all(sensor.positive for sensor in bge.logic.getCurrentController().sensors):
drawtext.add("Hello Green World!", 0, 0.15, drawtext.COLOR_GREEN, drawtext.FONT_ID_AGENCYR)
```
Complete Code
=============
**fonts.py**
```
import bge
import blf
def load(file):
return blf.load(bge.logic.expandPath(file))
```
**drawtext.py**
```
import bge
import bgl, blf
import fonts
FONT_ID_ARIAL = fonts.load("//arial.ttf")
FONT_ID_AGENCYR = fonts.load("//AGENCYR.TTF")
COLOR_GREEN = 0.0, 1.0, 0.0, 1.0
COLOR_RED = 1.0, 0.0, 0.0, 1.0
COLOR_BLUE = 0.0, 0.0, 1.0, 1.0
COLOR_BLACK = 0.0, 0.0, 0.0, 1.0
COLOR_WHITE = 1.0, 1.0, 1.0, 1.0
texts = []
class Text():
def __init__(self, text, x, y, color, font_id):
self.text = text
self.x = x
self.y = y
self.color = color
self.font_id = font_id
def add(text, x, y, color, font_id=0):
return texts.append(Text(text, x, y, color, font_id))
def write():
"""write on screen"""
width = bge.render.getWindowWidth()
height = bge.render.getWindowHeight()
# OpenGL setup
bgl.glMatrixMode(bgl.GL_PROJECTION)
bgl.glLoadIdentity()
bgl.gluOrtho2D(0, width, 0, height)
bgl.glMatrixMode(bgl.GL_MODELVIEW)
bgl.glLoadIdentity()
# BLF drawing routine
for text in texts:
blf.position(text.font_id, (width * text.x), (height * text.y), 0)
blf.size(text.font_id, 50, 72)
bgl.glColor4f(*text.color)
blf.draw(text.font_id, text.text)
bge.logic.getCurrentScene().post_draw = [write]
```
**Show Green Text**
```
import drawtext
import bge
if all(sensor.positive for sensor in bge.logic.getCurrentController().sensors):
drawtext.add("Hello Green World!", 0, 0.15, drawtext.COLOR_GREEN, drawtext.FONT_ID_AGENCYR)
```
**Show Red Text**
```
import drawtext
if all(sensor.positive for sensor in bge.logic.getCurrentController().sensors):
drawtext.add("Hello Red World!",0,0, drawtext.COLOR_RED)
```
Excercise
=========
I suggest to allow customizing the size of the text fragment. How would you do that? | The code of the script:
```
import module_drawseveralwordsII
```
The code of the module\_drawseveralwordsII.py:
```
# import game engine modules
from bge import render, logic
# import stand alone modules
import bgl, blf
# create a new font object, use external ttf file
font_path = logic.expandPath('C://Documents and Settings//Guillermo//Mis documentos//Google Drive//Gproyectos//Proyectos con Blender//arial.ttf')
# store the font indice - to use later
font_id = blf.load(font_path)
chain = ["Hello World!","Hello Country!","Hello Town!", "Hello Home!"]
positionx = [0,0.2,0.4,0.6]
positiony = [0,0.2,0.4,0.6]
ccolor1 = [0.0,0.0,0.0,0.0]
ccolor2 = [0.0,0.0,0.6,0.5]
ccolor3 = [0.0,0.3,0.0,0.5]
ccolor4 = [1.0,1,1,1]
def write():
"""write on screen"""
width = render.getWindowWidth()
height = render.getWindowHeight()
# OpenGL setup
bgl.glMatrixMode(bgl.GL_PROJECTION)
bgl.glLoadIdentity()
bgl.gluOrtho2D(0, width, 0, height)
bgl.glMatrixMode(bgl.GL_MODELVIEW)
bgl.glLoadIdentity()
# BLF drawing routine
i = 0
while i<len(chain):
blf.position(font_id, (width * positionx[i]), (height * positiony[i]), 0)
blf.size(font_id, 50, 72)
bgl.glColor4f(ccolor1[i], ccolor2[i], ccolor3[i], ccolor4[i])
blf.draw(font_id,chain[i])
i = i + 1
def update(cont):
own = cont.owner
chain = own['msg']
# set the font drawing routine to run every frame
scene = logic.getCurrentScene()
scene.post_draw = [write]
```
The differences from the original code are the variable declarations:
```
chain = ["Hello World!","Hello Country!","Hello Town!", "Hello Home!"]
positionx = [0,0.2,0.4,0.6]
positiony = [0,0.2,0.4,0.6]
ccolor1 = [0.0,0.0,0.0,0.0]
ccolor2 = [0.0,0.0,0.6,0.5]
ccolor3 = [0.0,0.3,0.0,0.5]
ccolor4 = [1.0,1,1,1]
```
And this:
```
i = 0
while i<len(chain):
blf.position(font_id, (width * positionx[i]), (height * positiony[i]), 0)
blf.size(font_id, 50, 72)
bgl.glColor4f(ccolor1[i], ccolor2[i], ccolor3[i], ccolor4[i])
blf.draw(font_id,chain[i])
i = i + 1
```
This is what we can see:
[](https://i.stack.imgur.com/BJl2R.png)
I don´t know the exact values of red, and yellow for the 4f color system. But these values must be available on the web. |
14,581,747 | Hey all i have looked thoroughly through all the questions containing `XDocument` and while they are all giving an answer to what I'm looking for (mostly namespaces issues) it seems it just won't work for me.
The problem I'm having is that I'm unable to select any value, be it an attribute or element.
Using this [XML](http://events.feed.comportal.be/agenda.aspx?event=TechDays&year=2013&speakerlist=c%7CExperts)
I'm trying to retrieve the speaker's fullname.
```
public void GetEvent()
{
var xdocument = XDocument.Load(@"Shared\techdays2013.xml");
XNamespace xmlns = "http://www.w3.org/2001/XMLSchema-instance";
var data = from c in xdocument.Descendants(xmlns + "speaker")
select c.Element(xmlns + "fullname").Value;
}
``` | 2013/01/29 | [
"https://Stackoverflow.com/questions/14581747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/514133/"
] | You can omit the namespace declaration in your linq statement.
```
public void GetEvent()
{
var xdocument = XDocument.Load(@"Shared\techdays2013.xml");
//XNamespace xmlns = "http://www.w3.org/2001/XMLSchema-instance";
var data = from c in xdocument.Descendants("speaker")
select c.Element("fullname").Value;
}
``` | 1) You have to drop the namespace
2) You'll have to query more precisely. All your `<speaker>` elements inside `<speakers>` have a fullname but in the next section I spotted `<speaker id="94" />`
A simple fix (maybe not the best) :
```
//untested
var data = from c in xdocument.Root.Descendants("speakers").Descendants("speaker")
select c.Element("fullname").Value;
```
You may want to specify the path more precise:
```
xdocument.Element("details").Element("tracks").Element("speakers").
``` |
14,581,747 | Hey all i have looked thoroughly through all the questions containing `XDocument` and while they are all giving an answer to what I'm looking for (mostly namespaces issues) it seems it just won't work for me.
The problem I'm having is that I'm unable to select any value, be it an attribute or element.
Using this [XML](http://events.feed.comportal.be/agenda.aspx?event=TechDays&year=2013&speakerlist=c%7CExperts)
I'm trying to retrieve the speaker's fullname.
```
public void GetEvent()
{
var xdocument = XDocument.Load(@"Shared\techdays2013.xml");
XNamespace xmlns = "http://www.w3.org/2001/XMLSchema-instance";
var data = from c in xdocument.Descendants(xmlns + "speaker")
select c.Element(xmlns + "fullname").Value;
}
``` | 2013/01/29 | [
"https://Stackoverflow.com/questions/14581747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/514133/"
] | You can omit the namespace declaration in your linq statement.
```
public void GetEvent()
{
var xdocument = XDocument.Load(@"Shared\techdays2013.xml");
//XNamespace xmlns = "http://www.w3.org/2001/XMLSchema-instance";
var data = from c in xdocument.Descendants("speaker")
select c.Element("fullname").Value;
}
``` | You can omit `WebClient` because you have direct local access to a file. I'm just showing a way to process your file on my machine.
```
void Main()
{
string p = @"http://events.feed.comportal.be/agenda.aspx?event=TechDays&year=2013&speakerlist=c%7CExperts";
using (var client = new WebClient())
{
string str = client.DownloadString(p);
var xml = XDocument.Parse(str);
var result = xml.Descendants("speaker")
.Select(speaker => GetNameOrDefault(speaker));
//LinqPad specific call
result.Dump();
}
}
public static string GetNameOrDefault(XElement element)
{
var name = element.Element("fullname");
return name != null ? name.Value : "no name";
}
```
prints:
```
Bart De Smet
Daniel Pearson
Scott Schnoll
Ilse Van Criekinge
John Craddock
Corey Hynes
Bryon Surace
Jeff Prosise
``` |
5,021,338 | I have a UIScrollView with varying numbers of items/subviews. When there is more than one item, scrolling bounce works. However, there are times when the scrollview should only have one item, and I would like to provide the feedback to the user that their scrolls are being recognized--thus the bounce effect. However, UIScrollView disables scrolling with just one item. | 2011/02/16 | [
"https://Stackoverflow.com/questions/5021338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/404146/"
] | Answer: set alwaysBounceHorizontal or alwaysBounceVertical to true. I answered my own question while writing this up and figured I might as well post it to help others. | Additionally, a UIScrollView will not scroll in (width / height) if the contentSize property is not greater than the frame property (in width / height) |
58,918,171 | I had a react project that managed files from azure blob storage also using azure search. Before I got the `metadata_storage_path` property encoded as base64 and I could read it by decoding it with `atob(metadata_storage_path.slice(0, -1))`. Now I deleted the Azure search to add some new stuff to it. But now I get the `metadata_storage_path` encoded 2 time.
I get a string that looks like a regular base64 string ex:
>
> Qhhweufineiurfheurnfuierhfn... and so on
>
>
>
And when I decode it I get a string with spaces between every letter
>
> A K T I G H A L J S H S... and so on
>
>
>
If I remove all spaces and decode the output I get a valid path to my file.
Is there some weird setting that I have enabled by accident?
I had the same problem before but I recreated the Azure search function several times and it just started to work then. | 2019/11/18 | [
"https://Stackoverflow.com/questions/58918171",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6848161/"
] | No, this probably not your fault but rather a defect on our side resulting from the UI. You can use 547271 as tracking item number if talking to someone in the Azure Search team.
To fix this, you'll need to:
* Use a tool such as POSTMAN to edit your Indexer (remove the legacy encoding property)
* Delete and recreate your Index | It sounds like you have both [base64Encode field mapping function](https://learn.microsoft.com/en-us/azure/search/search-indexer-field-mappings#base64EncodeFunction) and the legacy indexer parameter `base64EncodeKeys`. Updating your indexer with the indexer parameter `base64EncodeKeys` set to `false` should get rid of the extra layer of encoding.
The legacy encoding parameter uses UTF16 encoding, which gives you an extra NUL byte between ASCII characters. |
7,228,118 | I've been using eclipse for about 10 years now, and today I will be (forced to) use JDeveloper for the first time.
Being a big fan of the eclipse shortcuts, I would like to know some JDeveloper alternatives for my favorite shortcuts:
* `Ctrl`-`3` (Quick access)
* `Ctrl`-`Shift`-`1` (or `Ctrl`-`1`, depending on your keyboard) (Quick Fix)
* `Ctrl`-`Shift`-`L` (Show the shortcuts :-))
* `Shift`-`Enter` (Add a new line below the current one)
* `Alt`-`↓` (Move line(s))
* `Ctrl`-`Alt`-`↓` (Copy line(s))
Any other shortcuts in JDeveloper I should know about? I have found [this link](http://ikool.wordpress.com/2008/06/23/jdeveloper-and-eclipse-shortcuts-compared/), but the list is way too short. | 2011/08/29 | [
"https://Stackoverflow.com/questions/7228118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/109880/"
] | I once battled JDeveloper for two years and somehow lived to tell about it. If you're using 11g, here is a [trick you can use to load the Eclipse shortcut scheme](http://web-center-suite.blogspot.com/2011/08/jdeveloper-shortcuts.html). I highly recommend doing this as there's really no value in learning the native key bindings.
A second piece of advice, do whatever it takes to get off whatever project you're required to use JDeveloper for. It is an ancient, buggy IDE designed to cater to an [obscure, buggy framework](http://www.oracle.com/technetwork/developer-tools/adf/overview/index.html). You will quickly find yourself handcuffed by JDeveloper and ADF, it is in no way in the same league as Eclipse/Netbeans/IntelliJ. You **will** hate it. You have been warned. | Here is the official link for JDeveloper shortcuts:
<http://download.oracle.com/docs/cd/E16162_01/user.1112/e17455/working_jdev.htm#OJDUG159>
Hope that helps ;) |
554,227 | I cannot close one of my forms programmatically. Can someone help me?
Here's the code:
```
private void WriteCheck_Load(object sender, EventArgs e) {
SelectBankAccountDialog sbad = new SelectBankAccountDialog();
DialogResult result = sbad.ShowDialog();
if (result == DialogResult.Cancel) {
this.Close();
} else {
MessageBox.Show(result.ToString());
}
MessageBox.Show(sbad.bankaccountID.ToString());
}
``` | 2009/02/16 | [
"https://Stackoverflow.com/questions/554227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12243/"
] | By calling `Form.Close()`, the form should close, but not until all waiting events have been processed. You also still have a chance to cancel the form closing in the `FormClosing` event.
First, you'll probably want to `return` after your call to `this.Close()`. If it still doesn't close, step through your code and see what is happening. You may have to set and check a "forciblyClose" flag and return from any other processing methods before it'll actually close. | The actual problem is that windows won't let a form close on it's load method. I have to show the dialog on construction, and then if the dialog result is cancel I have to throw an exception and catch the exception on form creation.
[This place](http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.windowsforms/topic18413.aspx) talks more about it |
554,227 | I cannot close one of my forms programmatically. Can someone help me?
Here's the code:
```
private void WriteCheck_Load(object sender, EventArgs e) {
SelectBankAccountDialog sbad = new SelectBankAccountDialog();
DialogResult result = sbad.ShowDialog();
if (result == DialogResult.Cancel) {
this.Close();
} else {
MessageBox.Show(result.ToString());
}
MessageBox.Show(sbad.bankaccountID.ToString());
}
``` | 2009/02/16 | [
"https://Stackoverflow.com/questions/554227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12243/"
] | As configurator mentioned (in comments), the form must be shown before it can be closed, so, instead of the *Load* event, you should be doing this in the *Shown* event instead.
If you don't want the form visible for the Dialog box, I guess you can wrap the event code in a Visible = false;
In summary, the basic code would be
```
private void WriteCheck_Shown(object sender, EventArgs e)
{
Visible = false;
SelectBankAccountDialog sbad = new SelectBankAccountDialog();
DialogResult result = sbad.ShowDialog();
if (result == DialogResult.Cancel) {
this.Close();
} else {
MessageBox.Show(result.ToString());
}
MessageBox.Show(sbad.bankaccountID.ToString());
Visible = true;
}
``` | By calling `Form.Close()`, the form should close, but not until all waiting events have been processed. You also still have a chance to cancel the form closing in the `FormClosing` event.
First, you'll probably want to `return` after your call to `this.Close()`. If it still doesn't close, step through your code and see what is happening. You may have to set and check a "forciblyClose" flag and return from any other processing methods before it'll actually close. |
554,227 | I cannot close one of my forms programmatically. Can someone help me?
Here's the code:
```
private void WriteCheck_Load(object sender, EventArgs e) {
SelectBankAccountDialog sbad = new SelectBankAccountDialog();
DialogResult result = sbad.ShowDialog();
if (result == DialogResult.Cancel) {
this.Close();
} else {
MessageBox.Show(result.ToString());
}
MessageBox.Show(sbad.bankaccountID.ToString());
}
``` | 2009/02/16 | [
"https://Stackoverflow.com/questions/554227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12243/"
] | As configurator mentioned (in comments), the form must be shown before it can be closed, so, instead of the *Load* event, you should be doing this in the *Shown* event instead.
If you don't want the form visible for the Dialog box, I guess you can wrap the event code in a Visible = false;
In summary, the basic code would be
```
private void WriteCheck_Shown(object sender, EventArgs e)
{
Visible = false;
SelectBankAccountDialog sbad = new SelectBankAccountDialog();
DialogResult result = sbad.ShowDialog();
if (result == DialogResult.Cancel) {
this.Close();
} else {
MessageBox.Show(result.ToString());
}
MessageBox.Show(sbad.bankaccountID.ToString());
Visible = true;
}
``` | The actual problem is that windows won't let a form close on it's load method. I have to show the dialog on construction, and then if the dialog result is cancel I have to throw an exception and catch the exception on form creation.
[This place](http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.windowsforms/topic18413.aspx) talks more about it |
67,219,847 | Is there a way to tell what type of file a google downloadlink will produce? This type of link doesn't tell me anything about the file type (.mov? .png? .jpg?)
(link below is an example)
`https://drive.google.com/u/0/uc?id=2D-99h4-CLMNPO!1234567&export=download` | 2021/04/22 | [
"https://Stackoverflow.com/questions/67219847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6054959/"
] | Unless the file is a Google Docs, Sheets, Slides, etc... that has a special link, e.g. `https://docs.google.com/document/d/FILE-ID`, the rest of the file types are just bundled as a generic link like `https://drive.google.com/file/d/FILE-ID`.
You can view the file type before downloading by using View Mode:
```
https://drive.google.com/file/d/FILE_ID/view
``` | Look at the `mimeType` property of the file.
See <https://developers.google.com/drive/api/v3/reference/files> |
26,986,737 | (I'm new to JavaScript) If all objects inherit their properties from a prototype, and if the default object is Object, why does the following script return undefined in both cases (I was expecting 'Object')?
```
obj1 = {}; //empty object
obj2 = new Object();
console.log(obj1.prototype);
console.log(obj2.prototype);
```
Pardon me if it's a silly question! | 2014/11/18 | [
"https://Stackoverflow.com/questions/26986737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1170686/"
] | `.prototype` is not a property of a live object and thus it doesn't exist so it reports `undefined`. The `.prototype` property is on the constructor which in this case is `Object.prototype`. For a given object in a modern browser, you can get the active prototype with this:
```
var obj1 = {};
var p = Object.getPrototypeOf(obj1);
```
A non-standard and now deprecated way to get the prototype is:
```
var obj1 = {};
var p = obj1.__proto__;
``` | In JavaScript's prototypal inheritance, you have *constructors* and *instances*.
The constructors, such as `Object`, is where you find the `.prototype` chain.
But on the instances, the prototype chain is not really accessible. |
51,039,257 | I'm using here `imageView` , when i click on it should show me a video in (linear10) this video is about 4 sec , i need a code that when i click again on the `imageView` the video should start playing again , every time i clicked on the `imageView` i need it to start the video from the beginning
this is the code im using to play the video:
```
imageview1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
n++;
linear1.setVisibility(View.VISIBLE);
if (n == 1) {
final VideoView vd = new VideoView(MainActivity.this); vd.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.MATCH_PARENT)); linear1.addView(vd);
vd.setVideoURI(Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.mercury));
vd.requestFocus();
vd.start();
```
i tried to add this code , but this will loop the video !!! :
```
vd.setOnCompletionListener(new android.media.MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(android.media.MediaPlayer arg0) {
vd.start();
}
});
```
i want when i clicked on the imageview the video starts playing, then if i clicked again it will start again from the beginning. | 2018/06/26 | [
"https://Stackoverflow.com/questions/51039257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9984006/"
] | Use the seekTo Function of video view to restart the video
```
imageview1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
n++;
linear1.setVisibility(View.VISIBLE);
if (n == 1) {
final VideoView vd = new VideoView(MainActivity.this); vd.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.MATCH_PARENT)); linear1.addView(vd);
vd.setVideoURI(Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.mercury));
vd.requestFocus();
vd.start();
} else {
vd.seekTo(0);
}
``` | Keep boolean values you will handle the video view using seekTo() when the clicks fires.
// playing true - getCurrent seekposition video is playing check the seekTo();
if (playing)
//change the flag and set as false & seekTo(0);
else
// change the flag and set as true seekTo(sum values); |
51,039,257 | I'm using here `imageView` , when i click on it should show me a video in (linear10) this video is about 4 sec , i need a code that when i click again on the `imageView` the video should start playing again , every time i clicked on the `imageView` i need it to start the video from the beginning
this is the code im using to play the video:
```
imageview1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
n++;
linear1.setVisibility(View.VISIBLE);
if (n == 1) {
final VideoView vd = new VideoView(MainActivity.this); vd.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.MATCH_PARENT)); linear1.addView(vd);
vd.setVideoURI(Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.mercury));
vd.requestFocus();
vd.start();
```
i tried to add this code , but this will loop the video !!! :
```
vd.setOnCompletionListener(new android.media.MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(android.media.MediaPlayer arg0) {
vd.start();
}
});
```
i want when i clicked on the imageview the video starts playing, then if i clicked again it will start again from the beginning. | 2018/06/26 | [
"https://Stackoverflow.com/questions/51039257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9984006/"
] | Use the seekTo Function of video view to restart the video
```
imageview1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
n++;
linear1.setVisibility(View.VISIBLE);
if (n == 1) {
final VideoView vd = new VideoView(MainActivity.this); vd.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.MATCH_PARENT)); linear1.addView(vd);
vd.setVideoURI(Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.mercury));
vd.requestFocus();
vd.start();
} else {
vd.seekTo(0);
}
``` | i found the solution guys , ty for help
someone called **jeff** has solve it for me (thanks **Jeff**)
the soulution :
put this code under onCreate:
```
vd = new VideoView(MainActivity.this); vd.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.MATCH_PARENT)); linear1.addView(vd);
vd.setVideoURI(Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.mercury));
}
private VideoView vd;
public void nothing() {
```
and this code under imageview1 onclicklistener :
```
vd.requestFocus();
vd.start();
vd.seekTo(0);
``` |
10,004,502 | I have the following code where after a bool is true I want to add a drawing to my rect. here is the code I have but for some reason it is either not setting the bool or calling the setNeedsDisplay. Am I referencing to the other class properly? thanks
//in AppController.m
```
-(IBAction)colorToggle:(id)sender
{
if ([colorFilter state] == NSOnState)
{
CutoutView *theView = [[CutoutView alloc] init];
[theView setFilterEnabled:YES];
}
```
}
//in cutoutView.m
```
- (void)drawRect:(NSRect)dirtyRect
{
[[[NSColor blackColor]colorWithAlphaComponent:0.9]set];
NSRectFill(dirtyRect);
//this is what i want to be drawn when my bool is true and update the drawRect
if (filterEnabled == YES) {
NSRectFillUsingOperation(NSMakeRect(100, 100, 300, 300), NSCompositeClear);
[self update];
}
}
-(void)update
{
[self setNeedsDisplay:YES];
}
``` | 2012/04/04 | [
"https://Stackoverflow.com/questions/10004502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1034741/"
] | OK, you know how not every UILabel is the same? Like, you can remove one UILabel from a view without all the others disappearing too? Well, your CutoutView is the same way. When you write `CutoutView *theView = [[CutoutView alloc] init];` there, that creates a **new** CutoutView that isn't displayed anywhere. You need to talk to your *existing* CutoutView (probably by hooking up an outlet, but there are any number of perfectly valid designs that will accomplish this goal). | You are forgetting to call the `drawRect:` method, it should looks like this:
```
CutoutView *theView = [[CutoutView alloc] init];
[theView setFilterEnabled:YES];
[theView setNeedsDisplay];
```
From the [docs](https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIView_Class/UIView/UIView.html):
>
> When the actual content of your view changes, it is your
> responsibility to notify the system that your view needs to be
> redrawn. You do this by calling your view’s setNeedsDisplay or
> setNeedsDisplayInRect: method of the view.
>
>
> |
65,817,454 | I am trying to make a jQuery function dynamically decide which array gets run through it based on a button click. Ideally, this is how it would work:
* User clicks one of the "View More ..." buttons.
* The program loads the next 3 images of that specific category (Sports, Concerts, etc.).
Below is a version of that function working, but, only for the Concerts section:
```js
var altConcert = [
"Concert 1",
"Concert 2",
"Concert 3",
"Concert 4",
"Concert 5",
"Concert 6"
];
var imgConcert = [
"https://via.placeholder.com/101/000000",
"https://via.placeholder.com/102/000000",
"https://via.placeholder.com/103/000000",
"https://via.placeholder.com/104/000000",
"https://via.placeholder.com/105/000000",
"https://via.placeholder.com/106/000000"
];
var altSport = [
"Sport 1",
"Sport 2",
"Sport 3",
"Sport 4",
"Sport 5",
"Sport 6"
];
var imgSport = [
"https://via.placeholder.com/101/0000FF",
"https://via.placeholder.com/102/0000FF",
"https://via.placeholder.com/103/0000FF",
"https://via.placeholder.com/104/0000FF",
"https://via.placeholder.com/105/0000FF",
"https://via.placeholder.com/106/0000FF"
];
var count = 0;
$(".load-more-concerts").click(function() {
//Load the next 3 images
for (i = 0; i < 3; i++) {
$("#extraConcert").append(
'<div">' +
'<h3>'+altConcert[count]+'</h3>' +
'<img src="'+imgConcert[count]+'" alt="'+altConcert[count]+'"/>' +
'</div>');
count++;
}
//Scroll to the top (+100px) of the newly loaded images
$('<div id="new-concert-div'+count+'"> </div>').appendTo('#extraConcert');
$('body, html').animate({ scrollTop: $('#new-concert-div'+count+'').offset().top - 100}, 1000);
//Remove the "View More" button when out of images
if (count >= imgConcert.length) {
$(".view-more-concerts").css("display", "none");
return;
}
});
```
```css
#Concerts { float: left; padding-right: 100px; }
```
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="Concerts">
<div id="extraConcert">
<div id="new-concert-div1"> </div>
</div>
<div class="load-more-concerts">
<button class="view-more-concerts">View More Concerts</button>
</div>
</div>
<div id="Sports">
<div id="extraSports">
<div id="new-sports-div1"> </div>
</div>
<div class="load-more-sports">
<button class="view-more-sports">View More Sports</button>
</div>
</div>
```
Is there a way that I could use the ID name ("Sports" or "Concerts") of a div or perhaps pass the array as a parameter to the jQuery function? Or is there some other easier method to solving this that I am completely missing? I am confident I could get this to work if I just duplicated the function with different names, but I am trying to follow the [DRY Principle](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself). | 2021/01/20 | [
"https://Stackoverflow.com/questions/65817454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15047643/"
] | You can use `data` html attributes to achieve what you are looking for.
And in your js file you can just get those data attributes and validate them as i did in the code below.
```js
var altConcert = [
"Concert 1",
"Concert 2",
"Concert 3",
"Concert 4",
"Concert 5",
"Concert 6"
];
var imgConcert = [
"https://via.placeholder.com/101/000000",
"https://via.placeholder.com/102/000000",
"https://via.placeholder.com/103/000000",
"https://via.placeholder.com/104/000000",
"https://via.placeholder.com/105/000000",
"https://via.placeholder.com/106/000000"
];
var altSport = [
"Sport 1",
"Sport 2",
"Sport 3",
"Sport 4",
"Sport 5",
"Sport 6"
];
var imgSport = [
"https://via.placeholder.com/101/0000FF",
"https://via.placeholder.com/102/0000FF",
"https://via.placeholder.com/103/0000FF",
"https://via.placeholder.com/104/0000FF",
"https://via.placeholder.com/105/0000FF",
"https://via.placeholder.com/106/0000FF"
];
var count = 0;
$(".load-more").click(function() {
let alt = window[$(this).attr('data-alt')];
let img = window[$(this).attr('data-img')];
let target = $(this).attr('data-target');
//Load the next 3 images
for (i = 0; i < 3; i++) {
$(`#${target}`).append(
'<div">' +
'<h3>'+alt[count]+'</h3>' +
'<img src="'+img[count]+'" alt="'+alt[count]+'"/>' +
'</div>');
count++;
}
//Scroll to the top (+100px) of the newly loaded images
$('<div id="new-concert-div'+count+'"> </div>').appendTo('#extraConcert');
$('body, html').animate({ scrollTop: $('#new-concert-div'+count+'').offset().top - 100}, 1000);
//Remove the "View More" button when out of images
if (count >= imgConcert.length) {
$(".view-more-concerts").css("display", "none");
return;
}
});
```
```css
#Concerts { float: left; padding-right: 100px; }
```
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="Concerts">
<div id="extraConcert">
<div id="new-concert-div1"> </div>
</div>
<div class="load-more-concerts load-more" data-alt="altConcert" data-img="imgConcert" data-target="extraConcert">
<button class="view-more-concerts">View More Concerts</button>
</div>
</div>
<div id="Sports">
<div id="extraSports">
<div id="new-sports-div1"> </div>
</div>
<div class="load-more-sports load-more" data-alt="altSport" data-img="imgSport" data-target="extraSports">
<button class="view-more-sports">View More Sports</button>
</div>
</div>
```
In my code im getting the `data` attribute that has been clicked in that case i've used `data-target`, `data-alt` and `data-img`.
* `data-target` will the target using an id.
* `data-alt` will be the alt array.
* `data-img` will be the img array.
In javascript code i've used `window` to get the variables from the `data-*` string returned.
It starts to throw `undefined` when the `count` is bigger then the array length, but this can made with a validation like `if(alt[count] !== undefined)`.
More information about `data` attributes can be found here: <https://www.w3schools.com/tags/att_data-.asp> | This is just a quick stab at an answer. I'd probably combine the `alt` and `img` arrays into a single array with `{ alt: '', img: '' }`, but I don't have time...
Basically, the idea is, structure the data to fit your needs!
```js
var arrays = {
concert: {
alt: [
"Concert 1",
"Concert 2",
"Concert 3",
"Concert 4",
"Concert 5",
"Concert 6"
],
img: [
"https://via.placeholder.com/101/000000",
"https://via.placeholder.com/102/000000",
"https://via.placeholder.com/103/000000",
"https://via.placeholder.com/104/000000",
"https://via.placeholder.com/105/000000",
"https://via.placeholder.com/106/000000"
]
},
sport: {
alt: [
"Sport 1",
"Sport 2",
"Sport 3",
"Sport 4",
"Sport 5",
"Sport 6"
],
img: [
"https://via.placeholder.com/101/0000FF",
"https://via.placeholder.com/102/0000FF",
"https://via.placeholder.com/103/0000FF",
"https://via.placeholder.com/104/0000FF",
"https://via.placeholder.com/105/0000FF",
"https://via.placeholder.com/106/0000FF"
]
}
};
var count = 0;
$(".load-more-concerts").click(function() {
//Load the next 3 images
for (i = 0; i < 3; i++) {
$("#extraConcert").append(
'<div">' +
'<h3>' + arrays.concert.alt[count] + '</h3>' +
'<img src="' + arrays.concert.img[count] + '" alt="' + arrays.concert.alt[count] + '"/>' +
'</div>');
count++;
}
//Scroll to the top (+100px) of the newly loaded images
$('<div id="new-concert-div' + count + '"> </div>').appendTo('#extraConcert');
$('body, html').animate({
scrollTop: $('#new-concert-div' + count + '').offset().top - 100
}, 1000);
//Remove the "View More" button when out of images
if (count >= arrays.concert.alt.length) {
$(".view-more-concerts").css("display", "none");
return;
}
});
```
```css
#Concerts {
float: left;
padding-right: 100px;
}
```
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="Concerts">
<div id="extraConcert">
<div id="new-concert-div1"> </div>
</div>
<div class="load-more-concerts">
<button class="view-more-concerts">View More Concerts</button>
</div>
</div>
<div id="Sports">
<div id="extraSports">
<div id="new-sports-div1"> </div>
</div>
<div class="load-more-sports">
<button class="view-more-sports">View More Sports</button>
</div>
</div>
``` |
65,817,454 | I am trying to make a jQuery function dynamically decide which array gets run through it based on a button click. Ideally, this is how it would work:
* User clicks one of the "View More ..." buttons.
* The program loads the next 3 images of that specific category (Sports, Concerts, etc.).
Below is a version of that function working, but, only for the Concerts section:
```js
var altConcert = [
"Concert 1",
"Concert 2",
"Concert 3",
"Concert 4",
"Concert 5",
"Concert 6"
];
var imgConcert = [
"https://via.placeholder.com/101/000000",
"https://via.placeholder.com/102/000000",
"https://via.placeholder.com/103/000000",
"https://via.placeholder.com/104/000000",
"https://via.placeholder.com/105/000000",
"https://via.placeholder.com/106/000000"
];
var altSport = [
"Sport 1",
"Sport 2",
"Sport 3",
"Sport 4",
"Sport 5",
"Sport 6"
];
var imgSport = [
"https://via.placeholder.com/101/0000FF",
"https://via.placeholder.com/102/0000FF",
"https://via.placeholder.com/103/0000FF",
"https://via.placeholder.com/104/0000FF",
"https://via.placeholder.com/105/0000FF",
"https://via.placeholder.com/106/0000FF"
];
var count = 0;
$(".load-more-concerts").click(function() {
//Load the next 3 images
for (i = 0; i < 3; i++) {
$("#extraConcert").append(
'<div">' +
'<h3>'+altConcert[count]+'</h3>' +
'<img src="'+imgConcert[count]+'" alt="'+altConcert[count]+'"/>' +
'</div>');
count++;
}
//Scroll to the top (+100px) of the newly loaded images
$('<div id="new-concert-div'+count+'"> </div>').appendTo('#extraConcert');
$('body, html').animate({ scrollTop: $('#new-concert-div'+count+'').offset().top - 100}, 1000);
//Remove the "View More" button when out of images
if (count >= imgConcert.length) {
$(".view-more-concerts").css("display", "none");
return;
}
});
```
```css
#Concerts { float: left; padding-right: 100px; }
```
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="Concerts">
<div id="extraConcert">
<div id="new-concert-div1"> </div>
</div>
<div class="load-more-concerts">
<button class="view-more-concerts">View More Concerts</button>
</div>
</div>
<div id="Sports">
<div id="extraSports">
<div id="new-sports-div1"> </div>
</div>
<div class="load-more-sports">
<button class="view-more-sports">View More Sports</button>
</div>
</div>
```
Is there a way that I could use the ID name ("Sports" or "Concerts") of a div or perhaps pass the array as a parameter to the jQuery function? Or is there some other easier method to solving this that I am completely missing? I am confident I could get this to work if I just duplicated the function with different names, but I am trying to follow the [DRY Principle](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself). | 2021/01/20 | [
"https://Stackoverflow.com/questions/65817454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15047643/"
] | The selected button should be accessible as $(this) within it's bound click function. You can check for the class of the clicked button. So sticking with your original code and data structure this should work:
```
$(".view-more-concerts, .view-more-sports").click(function() {
if($(this).is('.view-more-concerts')) {
var alts = altConcert;
var imgs = imgConcert;
var subject = 'concert';
var container = 'Concert';
}
else ($(this).is('.view-more-sports')) {
var alts = altSport;
var imgs = imgSport;
var subject = 'sport';
var container = 'Sport';
}
else {
return false;
}
//Load the next 3 images
for (i = 0; i < 3; i++) {
$("#extra"+container).append(
'<div">' +
'<h3>'+alts[count]+'</h3>' +
'<img src="'+imgs[count]+'" alt="'+alts[count]+'"/>' +
'</div>');
count++;
}
//Scroll to the top (+100px) of the newly loaded images
$('<div id="new-'+concert+'-div'+count+'"> </div>').appendTo('#extra'+container);
$('body, html').animate({ scrollTop: $('#new-'+concert+'-div'+count+'').offset().top - 100}, 1000);
//Remove the "View More" button when out of images
if (count >= imgs.length) {
$(".view-more-"+subject).css("display", "none");
return;
}
});
``` | This is just a quick stab at an answer. I'd probably combine the `alt` and `img` arrays into a single array with `{ alt: '', img: '' }`, but I don't have time...
Basically, the idea is, structure the data to fit your needs!
```js
var arrays = {
concert: {
alt: [
"Concert 1",
"Concert 2",
"Concert 3",
"Concert 4",
"Concert 5",
"Concert 6"
],
img: [
"https://via.placeholder.com/101/000000",
"https://via.placeholder.com/102/000000",
"https://via.placeholder.com/103/000000",
"https://via.placeholder.com/104/000000",
"https://via.placeholder.com/105/000000",
"https://via.placeholder.com/106/000000"
]
},
sport: {
alt: [
"Sport 1",
"Sport 2",
"Sport 3",
"Sport 4",
"Sport 5",
"Sport 6"
],
img: [
"https://via.placeholder.com/101/0000FF",
"https://via.placeholder.com/102/0000FF",
"https://via.placeholder.com/103/0000FF",
"https://via.placeholder.com/104/0000FF",
"https://via.placeholder.com/105/0000FF",
"https://via.placeholder.com/106/0000FF"
]
}
};
var count = 0;
$(".load-more-concerts").click(function() {
//Load the next 3 images
for (i = 0; i < 3; i++) {
$("#extraConcert").append(
'<div">' +
'<h3>' + arrays.concert.alt[count] + '</h3>' +
'<img src="' + arrays.concert.img[count] + '" alt="' + arrays.concert.alt[count] + '"/>' +
'</div>');
count++;
}
//Scroll to the top (+100px) of the newly loaded images
$('<div id="new-concert-div' + count + '"> </div>').appendTo('#extraConcert');
$('body, html').animate({
scrollTop: $('#new-concert-div' + count + '').offset().top - 100
}, 1000);
//Remove the "View More" button when out of images
if (count >= arrays.concert.alt.length) {
$(".view-more-concerts").css("display", "none");
return;
}
});
```
```css
#Concerts {
float: left;
padding-right: 100px;
}
```
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="Concerts">
<div id="extraConcert">
<div id="new-concert-div1"> </div>
</div>
<div class="load-more-concerts">
<button class="view-more-concerts">View More Concerts</button>
</div>
</div>
<div id="Sports">
<div id="extraSports">
<div id="new-sports-div1"> </div>
</div>
<div class="load-more-sports">
<button class="view-more-sports">View More Sports</button>
</div>
</div>
``` |
65,817,454 | I am trying to make a jQuery function dynamically decide which array gets run through it based on a button click. Ideally, this is how it would work:
* User clicks one of the "View More ..." buttons.
* The program loads the next 3 images of that specific category (Sports, Concerts, etc.).
Below is a version of that function working, but, only for the Concerts section:
```js
var altConcert = [
"Concert 1",
"Concert 2",
"Concert 3",
"Concert 4",
"Concert 5",
"Concert 6"
];
var imgConcert = [
"https://via.placeholder.com/101/000000",
"https://via.placeholder.com/102/000000",
"https://via.placeholder.com/103/000000",
"https://via.placeholder.com/104/000000",
"https://via.placeholder.com/105/000000",
"https://via.placeholder.com/106/000000"
];
var altSport = [
"Sport 1",
"Sport 2",
"Sport 3",
"Sport 4",
"Sport 5",
"Sport 6"
];
var imgSport = [
"https://via.placeholder.com/101/0000FF",
"https://via.placeholder.com/102/0000FF",
"https://via.placeholder.com/103/0000FF",
"https://via.placeholder.com/104/0000FF",
"https://via.placeholder.com/105/0000FF",
"https://via.placeholder.com/106/0000FF"
];
var count = 0;
$(".load-more-concerts").click(function() {
//Load the next 3 images
for (i = 0; i < 3; i++) {
$("#extraConcert").append(
'<div">' +
'<h3>'+altConcert[count]+'</h3>' +
'<img src="'+imgConcert[count]+'" alt="'+altConcert[count]+'"/>' +
'</div>');
count++;
}
//Scroll to the top (+100px) of the newly loaded images
$('<div id="new-concert-div'+count+'"> </div>').appendTo('#extraConcert');
$('body, html').animate({ scrollTop: $('#new-concert-div'+count+'').offset().top - 100}, 1000);
//Remove the "View More" button when out of images
if (count >= imgConcert.length) {
$(".view-more-concerts").css("display", "none");
return;
}
});
```
```css
#Concerts { float: left; padding-right: 100px; }
```
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="Concerts">
<div id="extraConcert">
<div id="new-concert-div1"> </div>
</div>
<div class="load-more-concerts">
<button class="view-more-concerts">View More Concerts</button>
</div>
</div>
<div id="Sports">
<div id="extraSports">
<div id="new-sports-div1"> </div>
</div>
<div class="load-more-sports">
<button class="view-more-sports">View More Sports</button>
</div>
</div>
```
Is there a way that I could use the ID name ("Sports" or "Concerts") of a div or perhaps pass the array as a parameter to the jQuery function? Or is there some other easier method to solving this that I am completely missing? I am confident I could get this to work if I just duplicated the function with different names, but I am trying to follow the [DRY Principle](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself). | 2021/01/20 | [
"https://Stackoverflow.com/questions/65817454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15047643/"
] | You can use `data` html attributes to achieve what you are looking for.
And in your js file you can just get those data attributes and validate them as i did in the code below.
```js
var altConcert = [
"Concert 1",
"Concert 2",
"Concert 3",
"Concert 4",
"Concert 5",
"Concert 6"
];
var imgConcert = [
"https://via.placeholder.com/101/000000",
"https://via.placeholder.com/102/000000",
"https://via.placeholder.com/103/000000",
"https://via.placeholder.com/104/000000",
"https://via.placeholder.com/105/000000",
"https://via.placeholder.com/106/000000"
];
var altSport = [
"Sport 1",
"Sport 2",
"Sport 3",
"Sport 4",
"Sport 5",
"Sport 6"
];
var imgSport = [
"https://via.placeholder.com/101/0000FF",
"https://via.placeholder.com/102/0000FF",
"https://via.placeholder.com/103/0000FF",
"https://via.placeholder.com/104/0000FF",
"https://via.placeholder.com/105/0000FF",
"https://via.placeholder.com/106/0000FF"
];
var count = 0;
$(".load-more").click(function() {
let alt = window[$(this).attr('data-alt')];
let img = window[$(this).attr('data-img')];
let target = $(this).attr('data-target');
//Load the next 3 images
for (i = 0; i < 3; i++) {
$(`#${target}`).append(
'<div">' +
'<h3>'+alt[count]+'</h3>' +
'<img src="'+img[count]+'" alt="'+alt[count]+'"/>' +
'</div>');
count++;
}
//Scroll to the top (+100px) of the newly loaded images
$('<div id="new-concert-div'+count+'"> </div>').appendTo('#extraConcert');
$('body, html').animate({ scrollTop: $('#new-concert-div'+count+'').offset().top - 100}, 1000);
//Remove the "View More" button when out of images
if (count >= imgConcert.length) {
$(".view-more-concerts").css("display", "none");
return;
}
});
```
```css
#Concerts { float: left; padding-right: 100px; }
```
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="Concerts">
<div id="extraConcert">
<div id="new-concert-div1"> </div>
</div>
<div class="load-more-concerts load-more" data-alt="altConcert" data-img="imgConcert" data-target="extraConcert">
<button class="view-more-concerts">View More Concerts</button>
</div>
</div>
<div id="Sports">
<div id="extraSports">
<div id="new-sports-div1"> </div>
</div>
<div class="load-more-sports load-more" data-alt="altSport" data-img="imgSport" data-target="extraSports">
<button class="view-more-sports">View More Sports</button>
</div>
</div>
```
In my code im getting the `data` attribute that has been clicked in that case i've used `data-target`, `data-alt` and `data-img`.
* `data-target` will the target using an id.
* `data-alt` will be the alt array.
* `data-img` will be the img array.
In javascript code i've used `window` to get the variables from the `data-*` string returned.
It starts to throw `undefined` when the `count` is bigger then the array length, but this can made with a validation like `if(alt[count] !== undefined)`.
More information about `data` attributes can be found here: <https://www.w3schools.com/tags/att_data-.asp> | The selected button should be accessible as $(this) within it's bound click function. You can check for the class of the clicked button. So sticking with your original code and data structure this should work:
```
$(".view-more-concerts, .view-more-sports").click(function() {
if($(this).is('.view-more-concerts')) {
var alts = altConcert;
var imgs = imgConcert;
var subject = 'concert';
var container = 'Concert';
}
else ($(this).is('.view-more-sports')) {
var alts = altSport;
var imgs = imgSport;
var subject = 'sport';
var container = 'Sport';
}
else {
return false;
}
//Load the next 3 images
for (i = 0; i < 3; i++) {
$("#extra"+container).append(
'<div">' +
'<h3>'+alts[count]+'</h3>' +
'<img src="'+imgs[count]+'" alt="'+alts[count]+'"/>' +
'</div>');
count++;
}
//Scroll to the top (+100px) of the newly loaded images
$('<div id="new-'+concert+'-div'+count+'"> </div>').appendTo('#extra'+container);
$('body, html').animate({ scrollTop: $('#new-'+concert+'-div'+count+'').offset().top - 100}, 1000);
//Remove the "View More" button when out of images
if (count >= imgs.length) {
$(".view-more-"+subject).css("display", "none");
return;
}
});
``` |
29,986,297 | The thing is, I have detached threads created on my server which works in a thread-per-client way, so the function which accepts a client, creates another listener function (as a thread, and detaches it) waiting for another client to join.
Like the following in pseudo code:
```
Listen to client...
Accept Client Connection...
If client connection is Valid then
Create and detach a thread of the exact same function.
Else
Keep on listening...
```
I detach the threads only because afterwards, the thread who created a certain thread is handling a client, if that client leaves all clients that logged in after that client would be forced to log out (because there's a chain of threads):
```
//-> means creating a thread
Listening thread... Handling Client 1 -> Listening... Handling 2 -> Listening... Handling 3
```
and so on. So when client 1's thread will terminate, all of the others would do so.
That is why I cannot give up on detach (unless I'd create the threads in the `main()`, obviously, but that's not the architecture of the program).
Now, the problem occurs when someone exits without informing a thing, so the thread won't peacefully end. The only time I notice the fact that a client is not online is when `recv()` or `send()` are returning a negative value. When I notice that, I have to terminate the thread.
I tried doing so by using `std::terminate()` but I get an error window saying `r6010 - abort() has been called.`
How do I terminate that thread without all of the server crashing?
Would I be forced to change the architecture ? | 2015/05/01 | [
"https://Stackoverflow.com/questions/29986297",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3195614/"
] | The way to end a thread is to return from its thread procedure.
If you want the ending decision to be made from deep inside processing code, then throw an exception that is caught by the thread procedure. This has several huge benefits over `pthread_exit`:
* Stack unwinding occurs, so dynamic allocations used by your processing code won't be leaked (if properly held in smart pointers), as well as any other cleanup performed in destructors (flushing file buffers, etc).
* In the future if you want to add retry logic or anything like that, you can catch the exception. Conversely a call to `pthread_exit` is like a call to `std::terminate` or `std::exit` -- the current context ends unconditionally (although a handler can be installed via `set_terminate`, that handler cannot cancel the exit). Reusable code should *never* force an application-level exit. | I think you need to put test a variable in your client comms loop that signals a thread when to return:
```
class ClientComms
{
// set to true when you want the thread to stop
std::atomic_bool done;
public:
ClientComms(): done(false) {}
void operator()()
{
while(!done)
{
// communicate with client
}
}
};
``` |
1,038,782 | **Reference**
This problem grew out from: [Stone's Theorem Integral: Basic Integral](https://math.stackexchange.com/q/1004930/79762)
**Problem**
Given the real line as measure space $\mathbb{R}$ and a Hilbert space $\mathcal{H}$.
Consider a strongly continuous unitary group $U:\mathbb{R}\to\mathcal{B}(\mathcal{H})$.
Take the time evolution $\varphi(t):=U(t)\varphi$.
This time the integral is taken over an infinite measure:
$$\int\_0^\infty e^{-\lambda s}\varphi(s) \, \mathrm ds$$
What interpretations are available and how do they agree? | 2014/11/25 | [
"https://math.stackexchange.com/questions/1038782",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/79762/"
] | If you've shown that the $\operatorname{null}(A) \cap \operatorname{column}(A) = \{ 0 \}$, then
$$A^2v = A(Av) = 0 \ \Longleftrightarrow \ Av = 0$$
That is $\operatorname{null}(A) = \operatorname{null}(A^2)$ and hence $\operatorname{nullity}(A) = \operatorname{nullity}(A^2)$.
Now as $\dim(\mathbb{R}^3) = \operatorname{rank}(A) + \operatorname{nullity}(A) = \operatorname{rank}(A^2) + \operatorname{nullity}(A^2) $, it follows $$\operatorname{rank}(A) = \operatorname{rank}(A^2)$$ | We can prove generally that if $\operatorname{null}(A)\cap \operatorname{col}(A)=\{0\}$, then $\operatorname{rank}(A^2) = \operatorname{rank}(A)$. We can do so as follows:
Let $v\_1,\dots,v\_k$ be a basis for the kernel of $A$. Extend this to a basis $v\_1,\dots,v\_n$ of $\Bbb R^n$.
**Claim:** the vectors $A^2(v\_{k+1}),\dots,A^2(v\_{n})$ form a basis of the column space of $A^2$.
**Proof:** Try it! It's easy to show that these vectors span the column space; the trick is to show that they are also linearly independent. Leave a comment if you get stuck and I'll give you another prod along.
---
Alternatively, use the rank-nullity theorem as the other answer suggests |
1,038,782 | **Reference**
This problem grew out from: [Stone's Theorem Integral: Basic Integral](https://math.stackexchange.com/q/1004930/79762)
**Problem**
Given the real line as measure space $\mathbb{R}$ and a Hilbert space $\mathcal{H}$.
Consider a strongly continuous unitary group $U:\mathbb{R}\to\mathcal{B}(\mathcal{H})$.
Take the time evolution $\varphi(t):=U(t)\varphi$.
This time the integral is taken over an infinite measure:
$$\int\_0^\infty e^{-\lambda s}\varphi(s) \, \mathrm ds$$
What interpretations are available and how do they agree? | 2014/11/25 | [
"https://math.stackexchange.com/questions/1038782",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/79762/"
] | We can prove generally that if $\operatorname{null}(A)\cap \operatorname{col}(A)=\{0\}$, then $\operatorname{rank}(A^2) = \operatorname{rank}(A)$. We can do so as follows:
Let $v\_1,\dots,v\_k$ be a basis for the kernel of $A$. Extend this to a basis $v\_1,\dots,v\_n$ of $\Bbb R^n$.
**Claim:** the vectors $A^2(v\_{k+1}),\dots,A^2(v\_{n})$ form a basis of the column space of $A^2$.
**Proof:** Try it! It's easy to show that these vectors span the column space; the trick is to show that they are also linearly independent. Leave a comment if you get stuck and I'll give you another prod along.
---
Alternatively, use the rank-nullity theorem as the other answer suggests | in your comment you say that you have proved $image(A) \cup null(A) = {0}.$ that shows $null(A) = null(A^2)$ which in turn by the nullity theorem implies $image(A) = image(A^2).$ so the rank of $A$ and rank of $A^2$ are equal to $2.$
what am i missing? |
1,038,782 | **Reference**
This problem grew out from: [Stone's Theorem Integral: Basic Integral](https://math.stackexchange.com/q/1004930/79762)
**Problem**
Given the real line as measure space $\mathbb{R}$ and a Hilbert space $\mathcal{H}$.
Consider a strongly continuous unitary group $U:\mathbb{R}\to\mathcal{B}(\mathcal{H})$.
Take the time evolution $\varphi(t):=U(t)\varphi$.
This time the integral is taken over an infinite measure:
$$\int\_0^\infty e^{-\lambda s}\varphi(s) \, \mathrm ds$$
What interpretations are available and how do they agree? | 2014/11/25 | [
"https://math.stackexchange.com/questions/1038782",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/79762/"
] | If you've shown that the $\operatorname{null}(A) \cap \operatorname{column}(A) = \{ 0 \}$, then
$$A^2v = A(Av) = 0 \ \Longleftrightarrow \ Av = 0$$
That is $\operatorname{null}(A) = \operatorname{null}(A^2)$ and hence $\operatorname{nullity}(A) = \operatorname{nullity}(A^2)$.
Now as $\dim(\mathbb{R}^3) = \operatorname{rank}(A) + \operatorname{nullity}(A) = \operatorname{rank}(A^2) + \operatorname{nullity}(A^2) $, it follows $$\operatorname{rank}(A) = \operatorname{rank}(A^2)$$ | First, the kernel of
$$A=\begin{bmatrix}
2 & 0 & 4\\
1 & -1 & 3\\
2 & 1 & 3
\end{bmatrix}
$$
is generated by $(2,-1,-1)^t$.
Now you want to know the number of solutions of
$$\begin{bmatrix}
2 & 0 & 4\\
1 & -1 & 3\\
2 & 1 & 3
\end{bmatrix}\begin{bmatrix}
x\\
y\\
z
\end{bmatrix}=\begin{bmatrix}
2\\
-1\\
-1
\end{bmatrix}
$$
If there are no solution the rank of $A^2$ is the same of the rank of $A$, i.e. 2, if there is a $1-$dimensional space of solution then the rank of $A^2$ is $1$.
Since the rank of
$$\begin{bmatrix}
2 & 0 & 4& 2\\
1 & -1 & 3&-1\\
2 & 1 & 3&-1
\end{bmatrix}$$
is $3$, the system has no solution, so the rank of $A^2$ is $2$.
In this way you don't need to compute $A^2$, even if probably it would be simpler to do that. |
1,038,782 | **Reference**
This problem grew out from: [Stone's Theorem Integral: Basic Integral](https://math.stackexchange.com/q/1004930/79762)
**Problem**
Given the real line as measure space $\mathbb{R}$ and a Hilbert space $\mathcal{H}$.
Consider a strongly continuous unitary group $U:\mathbb{R}\to\mathcal{B}(\mathcal{H})$.
Take the time evolution $\varphi(t):=U(t)\varphi$.
This time the integral is taken over an infinite measure:
$$\int\_0^\infty e^{-\lambda s}\varphi(s) \, \mathrm ds$$
What interpretations are available and how do they agree? | 2014/11/25 | [
"https://math.stackexchange.com/questions/1038782",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/79762/"
] | If you've shown that the $\operatorname{null}(A) \cap \operatorname{column}(A) = \{ 0 \}$, then
$$A^2v = A(Av) = 0 \ \Longleftrightarrow \ Av = 0$$
That is $\operatorname{null}(A) = \operatorname{null}(A^2)$ and hence $\operatorname{nullity}(A) = \operatorname{nullity}(A^2)$.
Now as $\dim(\mathbb{R}^3) = \operatorname{rank}(A) + \operatorname{nullity}(A) = \operatorname{rank}(A^2) + \operatorname{nullity}(A^2) $, it follows $$\operatorname{rank}(A) = \operatorname{rank}(A^2)$$ | in your comment you say that you have proved $image(A) \cup null(A) = {0}.$ that shows $null(A) = null(A^2)$ which in turn by the nullity theorem implies $image(A) = image(A^2).$ so the rank of $A$ and rank of $A^2$ are equal to $2.$
what am i missing? |
1,038,782 | **Reference**
This problem grew out from: [Stone's Theorem Integral: Basic Integral](https://math.stackexchange.com/q/1004930/79762)
**Problem**
Given the real line as measure space $\mathbb{R}$ and a Hilbert space $\mathcal{H}$.
Consider a strongly continuous unitary group $U:\mathbb{R}\to\mathcal{B}(\mathcal{H})$.
Take the time evolution $\varphi(t):=U(t)\varphi$.
This time the integral is taken over an infinite measure:
$$\int\_0^\infty e^{-\lambda s}\varphi(s) \, \mathrm ds$$
What interpretations are available and how do they agree? | 2014/11/25 | [
"https://math.stackexchange.com/questions/1038782",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/79762/"
] | First, the kernel of
$$A=\begin{bmatrix}
2 & 0 & 4\\
1 & -1 & 3\\
2 & 1 & 3
\end{bmatrix}
$$
is generated by $(2,-1,-1)^t$.
Now you want to know the number of solutions of
$$\begin{bmatrix}
2 & 0 & 4\\
1 & -1 & 3\\
2 & 1 & 3
\end{bmatrix}\begin{bmatrix}
x\\
y\\
z
\end{bmatrix}=\begin{bmatrix}
2\\
-1\\
-1
\end{bmatrix}
$$
If there are no solution the rank of $A^2$ is the same of the rank of $A$, i.e. 2, if there is a $1-$dimensional space of solution then the rank of $A^2$ is $1$.
Since the rank of
$$\begin{bmatrix}
2 & 0 & 4& 2\\
1 & -1 & 3&-1\\
2 & 1 & 3&-1
\end{bmatrix}$$
is $3$, the system has no solution, so the rank of $A^2$ is $2$.
In this way you don't need to compute $A^2$, even if probably it would be simpler to do that. | in your comment you say that you have proved $image(A) \cup null(A) = {0}.$ that shows $null(A) = null(A^2)$ which in turn by the nullity theorem implies $image(A) = image(A^2).$ so the rank of $A$ and rank of $A^2$ are equal to $2.$
what am i missing? |
34,744,219 | I was wondering how can I build a condition based query in Laravel using eloquent?
I've found how to do it with a [raw query](https://stackoverflow.com/a/14179817/1783311) but that that's not what I want also the [answer to this question](https://stackoverflow.com/a/27522556/1783311) isn't that dynamic at least not as dynamic as I want it to be.
What I try to achieve is to create a dynamic WHERE query based on certain conditions, for example if the field is filled or not.
If I use the following code,
```
$matchThese = [
'role' => 'user',
'place' => \Input::get('location')
];
$availableUsers = User::where($matchThese)->take($count)->orderByRaw("RAND()")->get();
```
The query will fail if I don't send a location as POST value. I don't want it to fail I want it to skip to the next WHERE clause in the query. So basically if there's no place given don't search for it. | 2016/01/12 | [
"https://Stackoverflow.com/questions/34744219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1783311/"
] | Build up the query and include the `->where()` clause depending on whether or not you have the location in your input:
```
$query = User::where('role', 'user');
$query = \Input::has('location') ? $query->where('location', \Input::get('location')) : $query;
$availableUsers = $query->take($count)->orderByRaw('RAND()')->get();
``` | Just build the array with an if condition:
```
$matchThese = [
'role' => 'user',
];
if(\Input::has('location')){
$matchThese['place'] = \Input::get('location');
}
$availableUsers = User::where($matchThese)->take($count)->orderByRaw("RAND()")->get();
``` |
34,744,219 | I was wondering how can I build a condition based query in Laravel using eloquent?
I've found how to do it with a [raw query](https://stackoverflow.com/a/14179817/1783311) but that that's not what I want also the [answer to this question](https://stackoverflow.com/a/27522556/1783311) isn't that dynamic at least not as dynamic as I want it to be.
What I try to achieve is to create a dynamic WHERE query based on certain conditions, for example if the field is filled or not.
If I use the following code,
```
$matchThese = [
'role' => 'user',
'place' => \Input::get('location')
];
$availableUsers = User::where($matchThese)->take($count)->orderByRaw("RAND()")->get();
```
The query will fail if I don't send a location as POST value. I don't want it to fail I want it to skip to the next WHERE clause in the query. So basically if there's no place given don't search for it. | 2016/01/12 | [
"https://Stackoverflow.com/questions/34744219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1783311/"
] | Just build the array with an if condition:
```
$matchThese = [
'role' => 'user',
];
if(\Input::has('location')){
$matchThese['place'] = \Input::get('location');
}
$availableUsers = User::where($matchThese)->take($count)->orderByRaw("RAND()")->get();
``` | ```
$query = DB::table('table_name');
if($something == "something"){
$query->where('something', 'something');
}
$some_variable= $query->where('published', 1)->get();
```
You can use something like this. |
34,744,219 | I was wondering how can I build a condition based query in Laravel using eloquent?
I've found how to do it with a [raw query](https://stackoverflow.com/a/14179817/1783311) but that that's not what I want also the [answer to this question](https://stackoverflow.com/a/27522556/1783311) isn't that dynamic at least not as dynamic as I want it to be.
What I try to achieve is to create a dynamic WHERE query based on certain conditions, for example if the field is filled or not.
If I use the following code,
```
$matchThese = [
'role' => 'user',
'place' => \Input::get('location')
];
$availableUsers = User::where($matchThese)->take($count)->orderByRaw("RAND()")->get();
```
The query will fail if I don't send a location as POST value. I don't want it to fail I want it to skip to the next WHERE clause in the query. So basically if there's no place given don't search for it. | 2016/01/12 | [
"https://Stackoverflow.com/questions/34744219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1783311/"
] | Build up the query and include the `->where()` clause depending on whether or not you have the location in your input:
```
$query = User::where('role', 'user');
$query = \Input::has('location') ? $query->where('location', \Input::get('location')) : $query;
$availableUsers = $query->take($count)->orderByRaw('RAND()')->get();
``` | ```
$query = DB::table('table_name');
if($something == "something"){
$query->where('something', 'something');
}
$some_variable= $query->where('published', 1)->get();
```
You can use something like this. |
20,811,509 | While gone through some of the CSS files included with some websites and some other widely used plugins and frameworks, found that they are widely using hyphen separated words as class names. Actually what is the advantage of using such class names.
**For example:
In jquery UI CSS,**
```
.ui-helper-reset {
// CSS properties here...
}
``` | 2013/12/28 | [
"https://Stackoverflow.com/questions/20811509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1101893/"
] | It is just a practice for **readability**. Generally, you cannot have such variables in JavaScript, for separator, as `-` is an operator. When you need separator in JavaScript, you either use something of these:
```
.ui_helper_reset //snake_case
.uiHelperReset //camelCase
```
This way you can differentiate that one is used for CSS and other is for JavaScript. This is my point of view, but can be applied for your answer too! :) | It is just a for **readability**. you may use any names as per convention. |
20,811,509 | While gone through some of the CSS files included with some websites and some other widely used plugins and frameworks, found that they are widely using hyphen separated words as class names. Actually what is the advantage of using such class names.
**For example:
In jquery UI CSS,**
```
.ui-helper-reset {
// CSS properties here...
}
``` | 2013/12/28 | [
"https://Stackoverflow.com/questions/20811509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1101893/"
] | Readability:
------------
`ui-helper-reset` readable,
`uiHelperReset` unreadable.
Safe delimiter:
---------------
When using *[attribute selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors)* like `[class^="icon-"], [class*=" icon-"]` to specifically and safely target the specific classname styles by prefix, while preventing i.e: `.iconography` to be matched.
Ease of use:
------------
In every **decent code editor**, if you use `-` to separate *combined-class-name* you can **easily highlight** a desired portion by **double-click**ing it like: **col-`md`-3**, and replace it (or even document globally) to **col-`sm`-3**. On the other hand, if you use *underscore* `_` like **class\_name\_here**, if you double-click it you'll end up highlighting the whole class-name like: **`class_name_here`**. Such will force you to manually drag-select the desired portion instead.
CSS Naming Convention Methodology
---------------------------------
You can adopt a CSS naming concept like:
* **SUIT CSS**
* **BEM** (Block, Element, Modifier),
* **OOCSS** (Object-Oriented CSS)
* **SMACSS** (Scalable and Modular Architecture for CSS)
* **Atomic CSS**
* …**Your Own Concept** CSS :)
They all help a team speak *"the same language"*, by adopting a stricter *"Naming things"* such as:
[SUIT CSS](https://suitcss.github.io/)
--------------------------------------
```css
/* Block */
.Chat{}
/* -element (child) */
.Chat-message{}
/* --modifier */
.Chat-message--me{} /* Style my messages differently from other messages */
/* .is-state */
.Chat.is-active{} /* Multiple chats - active state handled by JS */
```
or
[BEM](http://getbem.com/):
--------------------------
```css
/* block */
.chat{}
/* __element (child) */
.chat__message{}
/* --modifier */
.chat__message--me{} /* Style my messages differently from other messages */
.chat--js-active{} /* Multiple chats - active state handled by JS */
```
If your `.chat` is part of the page you're viewing, you could use general Block classes like `.btn` and Modifier `.btn--big` like `<a class="btn btn--big">Post</a>`, otherwise if your buttons need a stricter styling specific to your chat application than you'd use `.chat__btn` and `.chat__btn--big` classes. Such classnames can also be preprocessed.
SCSS
----
I.e: by using [**Sass** SCSS](https://sass-lang.com/), a *superset* of CSS3 sintax you can do stuff like:
(Example using SUIT CSS)
```css
.Chat {
font: 14px/1.4 sans-serif;
position: relative;
overflow-y: scroll;
width: 300px;
height: 360px;
&-message { // refers to .Chat-message
padding: 16px;
background: #eee;
&--me { // refers to .Chat-message--me
background: #eef; // Style my messages differently from other messages */
text-align: right;
}
}
&.is-active { // refers to .Chat.is-active (JS)
outline: 3px solid lightblue;
}
}
```
HTML:
```css
<div class="Chat is-active">
<div class="Chat-message">Hi </div>
<div class="Chat-message Chat-message--me">Ciao!<br>How are you? </div>
<div class="Chat-message">Fine thx! Up for a ☕?</div>
</div>
```
[jsFiddle example](https://jsfiddle.net/wfsL1opc/)
---
### Conclusion:
Adopting a stricter **naming format** among a team **is important**. Prevents and minimizes dead legacy classes bloating your HTML, helps code re-usability, readability and speeds up your workflow. Additionally, it *forces* you and your team to think in a much more modular way about your HTML structure - as **components** or **atoms**.
Whatever you decide to use is up to you - **just, be consistent**. | It is just a practice for **readability**. Generally, you cannot have such variables in JavaScript, for separator, as `-` is an operator. When you need separator in JavaScript, you either use something of these:
```
.ui_helper_reset //snake_case
.uiHelperReset //camelCase
```
This way you can differentiate that one is used for CSS and other is for JavaScript. This is my point of view, but can be applied for your answer too! :) |
20,811,509 | While gone through some of the CSS files included with some websites and some other widely used plugins and frameworks, found that they are widely using hyphen separated words as class names. Actually what is the advantage of using such class names.
**For example:
In jquery UI CSS,**
```
.ui-helper-reset {
// CSS properties here...
}
``` | 2013/12/28 | [
"https://Stackoverflow.com/questions/20811509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1101893/"
] | In addition to being more readable, they can also suggest which classes are related to other. Twitter Bootstrap buttons, for example, have classes like
```
btn
btn-danger
btn-sm
```
etc.
The second two are related in usage to the first | It is just a for **readability**. you may use any names as per convention. |
20,811,509 | While gone through some of the CSS files included with some websites and some other widely used plugins and frameworks, found that they are widely using hyphen separated words as class names. Actually what is the advantage of using such class names.
**For example:
In jquery UI CSS,**
```
.ui-helper-reset {
// CSS properties here...
}
``` | 2013/12/28 | [
"https://Stackoverflow.com/questions/20811509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1101893/"
] | Readability:
------------
`ui-helper-reset` readable,
`uiHelperReset` unreadable.
Safe delimiter:
---------------
When using *[attribute selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors)* like `[class^="icon-"], [class*=" icon-"]` to specifically and safely target the specific classname styles by prefix, while preventing i.e: `.iconography` to be matched.
Ease of use:
------------
In every **decent code editor**, if you use `-` to separate *combined-class-name* you can **easily highlight** a desired portion by **double-click**ing it like: **col-`md`-3**, and replace it (or even document globally) to **col-`sm`-3**. On the other hand, if you use *underscore* `_` like **class\_name\_here**, if you double-click it you'll end up highlighting the whole class-name like: **`class_name_here`**. Such will force you to manually drag-select the desired portion instead.
CSS Naming Convention Methodology
---------------------------------
You can adopt a CSS naming concept like:
* **SUIT CSS**
* **BEM** (Block, Element, Modifier),
* **OOCSS** (Object-Oriented CSS)
* **SMACSS** (Scalable and Modular Architecture for CSS)
* **Atomic CSS**
* …**Your Own Concept** CSS :)
They all help a team speak *"the same language"*, by adopting a stricter *"Naming things"* such as:
[SUIT CSS](https://suitcss.github.io/)
--------------------------------------
```css
/* Block */
.Chat{}
/* -element (child) */
.Chat-message{}
/* --modifier */
.Chat-message--me{} /* Style my messages differently from other messages */
/* .is-state */
.Chat.is-active{} /* Multiple chats - active state handled by JS */
```
or
[BEM](http://getbem.com/):
--------------------------
```css
/* block */
.chat{}
/* __element (child) */
.chat__message{}
/* --modifier */
.chat__message--me{} /* Style my messages differently from other messages */
.chat--js-active{} /* Multiple chats - active state handled by JS */
```
If your `.chat` is part of the page you're viewing, you could use general Block classes like `.btn` and Modifier `.btn--big` like `<a class="btn btn--big">Post</a>`, otherwise if your buttons need a stricter styling specific to your chat application than you'd use `.chat__btn` and `.chat__btn--big` classes. Such classnames can also be preprocessed.
SCSS
----
I.e: by using [**Sass** SCSS](https://sass-lang.com/), a *superset* of CSS3 sintax you can do stuff like:
(Example using SUIT CSS)
```css
.Chat {
font: 14px/1.4 sans-serif;
position: relative;
overflow-y: scroll;
width: 300px;
height: 360px;
&-message { // refers to .Chat-message
padding: 16px;
background: #eee;
&--me { // refers to .Chat-message--me
background: #eef; // Style my messages differently from other messages */
text-align: right;
}
}
&.is-active { // refers to .Chat.is-active (JS)
outline: 3px solid lightblue;
}
}
```
HTML:
```css
<div class="Chat is-active">
<div class="Chat-message">Hi </div>
<div class="Chat-message Chat-message--me">Ciao!<br>How are you? </div>
<div class="Chat-message">Fine thx! Up for a ☕?</div>
</div>
```
[jsFiddle example](https://jsfiddle.net/wfsL1opc/)
---
### Conclusion:
Adopting a stricter **naming format** among a team **is important**. Prevents and minimizes dead legacy classes bloating your HTML, helps code re-usability, readability and speeds up your workflow. Additionally, it *forces* you and your team to think in a much more modular way about your HTML structure - as **components** or **atoms**.
Whatever you decide to use is up to you - **just, be consistent**. | In addition to being more readable, they can also suggest which classes are related to other. Twitter Bootstrap buttons, for example, have classes like
```
btn
btn-danger
btn-sm
```
etc.
The second two are related in usage to the first |
20,811,509 | While gone through some of the CSS files included with some websites and some other widely used plugins and frameworks, found that they are widely using hyphen separated words as class names. Actually what is the advantage of using such class names.
**For example:
In jquery UI CSS,**
```
.ui-helper-reset {
// CSS properties here...
}
``` | 2013/12/28 | [
"https://Stackoverflow.com/questions/20811509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1101893/"
] | Readability:
------------
`ui-helper-reset` readable,
`uiHelperReset` unreadable.
Safe delimiter:
---------------
When using *[attribute selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors)* like `[class^="icon-"], [class*=" icon-"]` to specifically and safely target the specific classname styles by prefix, while preventing i.e: `.iconography` to be matched.
Ease of use:
------------
In every **decent code editor**, if you use `-` to separate *combined-class-name* you can **easily highlight** a desired portion by **double-click**ing it like: **col-`md`-3**, and replace it (or even document globally) to **col-`sm`-3**. On the other hand, if you use *underscore* `_` like **class\_name\_here**, if you double-click it you'll end up highlighting the whole class-name like: **`class_name_here`**. Such will force you to manually drag-select the desired portion instead.
CSS Naming Convention Methodology
---------------------------------
You can adopt a CSS naming concept like:
* **SUIT CSS**
* **BEM** (Block, Element, Modifier),
* **OOCSS** (Object-Oriented CSS)
* **SMACSS** (Scalable and Modular Architecture for CSS)
* **Atomic CSS**
* …**Your Own Concept** CSS :)
They all help a team speak *"the same language"*, by adopting a stricter *"Naming things"* such as:
[SUIT CSS](https://suitcss.github.io/)
--------------------------------------
```css
/* Block */
.Chat{}
/* -element (child) */
.Chat-message{}
/* --modifier */
.Chat-message--me{} /* Style my messages differently from other messages */
/* .is-state */
.Chat.is-active{} /* Multiple chats - active state handled by JS */
```
or
[BEM](http://getbem.com/):
--------------------------
```css
/* block */
.chat{}
/* __element (child) */
.chat__message{}
/* --modifier */
.chat__message--me{} /* Style my messages differently from other messages */
.chat--js-active{} /* Multiple chats - active state handled by JS */
```
If your `.chat` is part of the page you're viewing, you could use general Block classes like `.btn` and Modifier `.btn--big` like `<a class="btn btn--big">Post</a>`, otherwise if your buttons need a stricter styling specific to your chat application than you'd use `.chat__btn` and `.chat__btn--big` classes. Such classnames can also be preprocessed.
SCSS
----
I.e: by using [**Sass** SCSS](https://sass-lang.com/), a *superset* of CSS3 sintax you can do stuff like:
(Example using SUIT CSS)
```css
.Chat {
font: 14px/1.4 sans-serif;
position: relative;
overflow-y: scroll;
width: 300px;
height: 360px;
&-message { // refers to .Chat-message
padding: 16px;
background: #eee;
&--me { // refers to .Chat-message--me
background: #eef; // Style my messages differently from other messages */
text-align: right;
}
}
&.is-active { // refers to .Chat.is-active (JS)
outline: 3px solid lightblue;
}
}
```
HTML:
```css
<div class="Chat is-active">
<div class="Chat-message">Hi </div>
<div class="Chat-message Chat-message--me">Ciao!<br>How are you? </div>
<div class="Chat-message">Fine thx! Up for a ☕?</div>
</div>
```
[jsFiddle example](https://jsfiddle.net/wfsL1opc/)
---
### Conclusion:
Adopting a stricter **naming format** among a team **is important**. Prevents and minimizes dead legacy classes bloating your HTML, helps code re-usability, readability and speeds up your workflow. Additionally, it *forces* you and your team to think in a much more modular way about your HTML structure - as **components** or **atoms**.
Whatever you decide to use is up to you - **just, be consistent**. | It is just a for **readability**. you may use any names as per convention. |
977,538 | `crontab -e` defaults to using `vi` for editing.
This is not usually a problem. `vi` is an excellent editor, and easy to learn.
---
Recently I've begun to use `vim` which is installed by
```
sudo apt-get update
sudo apt-get install vim
```
and in order to make it show line numbers and default to proper numbers of spaces when Tab is pressed, plus syntax highlighting for Python development,
the contents of my `/home/username/.vimrc` file is as so:
```
syntax enable
set number
set ts=4
set autoindent
set expandtab
set shiftwidth=4
set cursorline
set showmatch
let python_highlight_all = 1
```
This works out great.
---
However, when I use `crontab -e` it gives the following error messages:
>
> Sorry, the command is not available in this version: syntax enable
>
>
> Sorry, the command is not available in this version: let python\_highlight\_all = 1
>
>
> Press ENTER or type command to continue
>
>
>
Then pressing Enter allows it to continue into `vi` for editing of the cron table.
Questions: What version of vi is it trying to use? Is there a way to set it to the normal vim? Or to set it to another editor? | 2017/11/17 | [
"https://askubuntu.com/questions/977538",
"https://askubuntu.com",
"https://askubuntu.com/users/640711/"
] | When the environment is checked with the `env` command
```
env
```
there is no default EDITOR specified.
Not wanting to waste time trying to figure out what version of `vi` it is trying to use, it seems better to simply solve the problem.
Thus, the solution is simple.
```
export EDITOR=gedit
```
---
Alternatively, it can be set to your favorite editor like this:
```
export EDITOR=nano
```
or
```
export EDITOR=leafpad
```
---
**Once the EDITOR is specified in the environment, `crontab -e` uses it.**
Short and sweet.
---
To make this change take effect at login this line can be appended to
`/home/username/.bashrc`. | >
> `crontab -e` defaults to using `vi` for editing.
>
>
>
Not really. Per `man crontab`:
>
> The `-e` option is used to edit the current crontab using the editor specified by the `VISUAL` or `EDITOR` environment variables. After you exit from the editor, the modified crontab will be installed automatically. If neither of the environment variables is defined, then the default editor `/usr/bin/editor` is used.
>
>
>
`/usr/bin/editor` is a symlink managed by the alternatives system: it points to `/etc/alternatives/editor`, which is itself a symlink to the actual editor. It does not really have a "default" value, as its value at any time depends on the editors which are actually installed on the system. You can obtain its current value with `ls -l /etc/alternatives/editor`, and modify it with `sudo update-alternatives --config editor`. |
977,538 | `crontab -e` defaults to using `vi` for editing.
This is not usually a problem. `vi` is an excellent editor, and easy to learn.
---
Recently I've begun to use `vim` which is installed by
```
sudo apt-get update
sudo apt-get install vim
```
and in order to make it show line numbers and default to proper numbers of spaces when Tab is pressed, plus syntax highlighting for Python development,
the contents of my `/home/username/.vimrc` file is as so:
```
syntax enable
set number
set ts=4
set autoindent
set expandtab
set shiftwidth=4
set cursorline
set showmatch
let python_highlight_all = 1
```
This works out great.
---
However, when I use `crontab -e` it gives the following error messages:
>
> Sorry, the command is not available in this version: syntax enable
>
>
> Sorry, the command is not available in this version: let python\_highlight\_all = 1
>
>
> Press ENTER or type command to continue
>
>
>
Then pressing Enter allows it to continue into `vi` for editing of the cron table.
Questions: What version of vi is it trying to use? Is there a way to set it to the normal vim? Or to set it to another editor? | 2017/11/17 | [
"https://askubuntu.com/questions/977538",
"https://askubuntu.com",
"https://askubuntu.com/users/640711/"
] | When the environment is checked with the `env` command
```
env
```
there is no default EDITOR specified.
Not wanting to waste time trying to figure out what version of `vi` it is trying to use, it seems better to simply solve the problem.
Thus, the solution is simple.
```
export EDITOR=gedit
```
---
Alternatively, it can be set to your favorite editor like this:
```
export EDITOR=nano
```
or
```
export EDITOR=leafpad
```
---
**Once the EDITOR is specified in the environment, `crontab -e` uses it.**
Short and sweet.
---
To make this change take effect at login this line can be appended to
`/home/username/.bashrc`. | in ubuntu 18.04
Right click on file select `properties` select third tab `open with` add new and set it as default. |
977,538 | `crontab -e` defaults to using `vi` for editing.
This is not usually a problem. `vi` is an excellent editor, and easy to learn.
---
Recently I've begun to use `vim` which is installed by
```
sudo apt-get update
sudo apt-get install vim
```
and in order to make it show line numbers and default to proper numbers of spaces when Tab is pressed, plus syntax highlighting for Python development,
the contents of my `/home/username/.vimrc` file is as so:
```
syntax enable
set number
set ts=4
set autoindent
set expandtab
set shiftwidth=4
set cursorline
set showmatch
let python_highlight_all = 1
```
This works out great.
---
However, when I use `crontab -e` it gives the following error messages:
>
> Sorry, the command is not available in this version: syntax enable
>
>
> Sorry, the command is not available in this version: let python\_highlight\_all = 1
>
>
> Press ENTER or type command to continue
>
>
>
Then pressing Enter allows it to continue into `vi` for editing of the cron table.
Questions: What version of vi is it trying to use? Is there a way to set it to the normal vim? Or to set it to another editor? | 2017/11/17 | [
"https://askubuntu.com/questions/977538",
"https://askubuntu.com",
"https://askubuntu.com/users/640711/"
] | >
> `crontab -e` defaults to using `vi` for editing.
>
>
>
Not really. Per `man crontab`:
>
> The `-e` option is used to edit the current crontab using the editor specified by the `VISUAL` or `EDITOR` environment variables. After you exit from the editor, the modified crontab will be installed automatically. If neither of the environment variables is defined, then the default editor `/usr/bin/editor` is used.
>
>
>
`/usr/bin/editor` is a symlink managed by the alternatives system: it points to `/etc/alternatives/editor`, which is itself a symlink to the actual editor. It does not really have a "default" value, as its value at any time depends on the editors which are actually installed on the system. You can obtain its current value with `ls -l /etc/alternatives/editor`, and modify it with `sudo update-alternatives --config editor`. | in ubuntu 18.04
Right click on file select `properties` select third tab `open with` add new and set it as default. |
11,981,371 | If I use the following code to create a sender and receiver
```
qsender = qsession.createSender((Queue)msg.getJMSDestination());
qreceiver=qsession.createReceiver((Queue)msg.getJMSDestination());
```
and then do this
```
qsender.send(msg);
```
Does it just send the message to the queue and will it remain in the queue forever? Do I need to call the receive() method on the receiver or implement the MessageListener interface to get it to the receiver?
Edit: more info
```
qsender = qsession.createSender((Queue)msg.getJMSDestination());
qreceiver=qsession.createReceiver((Queue)msg.getJMSDestination());
temp1 = qsession.createTemporaryQueue();
responseConsumer = qsession.createConsumer(temp1);
msg.setJMSReplyTo(temp1);
responseConsumer.setMessageListener(responseListener);
msg.setJMSCorrelationID(msg.getJMSCorrelationID()+i);
qsender.send(msg);
```
In the above code, what is the temporary queue used for? Is it for receiving the messages? Is it the receiver? And if yes, whats the use of `msg.setJMSReplyTo(temp1)` ? | 2012/08/16 | [
"https://Stackoverflow.com/questions/11981371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1131384/"
] | If its HashMap, i don't think there is a better option than iterating, but if you can use TreeMap use this...
`map.headMap(key).clear();`
**Eg:**
```
public class Test
{
public static void main( String[] args )
{
SortedMap<Integer,String> map = new TreeMap<Integer,String>();
map.put( 1, "HI" );
map.put( 2, "BYE" );
map.put( 4, "GUY" );
map.put( 7, "SKY" );
map.put( 9, "HELLO" );
System.out.println(map.keySet());
map.headMap(5).clear(); // 5 is exclusive
System.out.println(map.keySet());
}
}
``` | Iterating is the only way.
```
// this is the number of items you want to remove
final int NUMBER_TO_REMOVE = 2;
// this is your map
Map<String, String> map = new HashMap<String, String>();
map.put("a", "1");
map.put("b", "2");
map.put("c", "3");
map.put("d", "4");
map.put("e", "5");
map.put("f", "6");
map.put("g", "7");
map.put("h", "8");
map.put("i", "9");
// get the keys
String[] keys = map.keySet().toArray(new String[map.size()]);
// remove the correct number from the map
for(int i = 0; i < NUMBER_TO_REMOVE; i++) {
map.remove(keys[i]);
}
// your map is now NUMBER_TO_REMOVE elements smaller
``` |
11,981,371 | If I use the following code to create a sender and receiver
```
qsender = qsession.createSender((Queue)msg.getJMSDestination());
qreceiver=qsession.createReceiver((Queue)msg.getJMSDestination());
```
and then do this
```
qsender.send(msg);
```
Does it just send the message to the queue and will it remain in the queue forever? Do I need to call the receive() method on the receiver or implement the MessageListener interface to get it to the receiver?
Edit: more info
```
qsender = qsession.createSender((Queue)msg.getJMSDestination());
qreceiver=qsession.createReceiver((Queue)msg.getJMSDestination());
temp1 = qsession.createTemporaryQueue();
responseConsumer = qsession.createConsumer(temp1);
msg.setJMSReplyTo(temp1);
responseConsumer.setMessageListener(responseListener);
msg.setJMSCorrelationID(msg.getJMSCorrelationID()+i);
qsender.send(msg);
```
In the above code, what is the temporary queue used for? Is it for receiving the messages? Is it the receiver? And if yes, whats the use of `msg.setJMSReplyTo(temp1)` ? | 2012/08/16 | [
"https://Stackoverflow.com/questions/11981371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1131384/"
] | If its HashMap, i don't think there is a better option than iterating, but if you can use TreeMap use this...
`map.headMap(key).clear();`
**Eg:**
```
public class Test
{
public static void main( String[] args )
{
SortedMap<Integer,String> map = new TreeMap<Integer,String>();
map.put( 1, "HI" );
map.put( 2, "BYE" );
map.put( 4, "GUY" );
map.put( 7, "SKY" );
map.put( 9, "HELLO" );
System.out.println(map.keySet());
map.headMap(5).clear(); // 5 is exclusive
System.out.println(map.keySet());
}
}
``` | A generic hashmap has only a limited number of interface functions. If K is small, I don't see any obvious better way than iterating, and breaking out of the iteration once K keys are removed. Of course, if K is large it might be better to do something else, such as preserve size-k elements and clear. If you need particular characteristics, your own hashmap could have whatever characteristics you need. |
11,981,371 | If I use the following code to create a sender and receiver
```
qsender = qsession.createSender((Queue)msg.getJMSDestination());
qreceiver=qsession.createReceiver((Queue)msg.getJMSDestination());
```
and then do this
```
qsender.send(msg);
```
Does it just send the message to the queue and will it remain in the queue forever? Do I need to call the receive() method on the receiver or implement the MessageListener interface to get it to the receiver?
Edit: more info
```
qsender = qsession.createSender((Queue)msg.getJMSDestination());
qreceiver=qsession.createReceiver((Queue)msg.getJMSDestination());
temp1 = qsession.createTemporaryQueue();
responseConsumer = qsession.createConsumer(temp1);
msg.setJMSReplyTo(temp1);
responseConsumer.setMessageListener(responseListener);
msg.setJMSCorrelationID(msg.getJMSCorrelationID()+i);
qsender.send(msg);
```
In the above code, what is the temporary queue used for? Is it for receiving the messages? Is it the receiver? And if yes, whats the use of `msg.setJMSReplyTo(temp1)` ? | 2012/08/16 | [
"https://Stackoverflow.com/questions/11981371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1131384/"
] | Why not iterate? You can remove *from the iterator* which is likely to be very efficient - no extra lookup required:
```
Iterator<Map.Enty<Foo, Bar>> it = map.entrySet().iterator();
for (int i = 0; i < k && it.hasNext; i++)
{
it.next();
it.remove();
}
``` | Iterating is the only way.
```
// this is the number of items you want to remove
final int NUMBER_TO_REMOVE = 2;
// this is your map
Map<String, String> map = new HashMap<String, String>();
map.put("a", "1");
map.put("b", "2");
map.put("c", "3");
map.put("d", "4");
map.put("e", "5");
map.put("f", "6");
map.put("g", "7");
map.put("h", "8");
map.put("i", "9");
// get the keys
String[] keys = map.keySet().toArray(new String[map.size()]);
// remove the correct number from the map
for(int i = 0; i < NUMBER_TO_REMOVE; i++) {
map.remove(keys[i]);
}
// your map is now NUMBER_TO_REMOVE elements smaller
``` |
11,981,371 | If I use the following code to create a sender and receiver
```
qsender = qsession.createSender((Queue)msg.getJMSDestination());
qreceiver=qsession.createReceiver((Queue)msg.getJMSDestination());
```
and then do this
```
qsender.send(msg);
```
Does it just send the message to the queue and will it remain in the queue forever? Do I need to call the receive() method on the receiver or implement the MessageListener interface to get it to the receiver?
Edit: more info
```
qsender = qsession.createSender((Queue)msg.getJMSDestination());
qreceiver=qsession.createReceiver((Queue)msg.getJMSDestination());
temp1 = qsession.createTemporaryQueue();
responseConsumer = qsession.createConsumer(temp1);
msg.setJMSReplyTo(temp1);
responseConsumer.setMessageListener(responseListener);
msg.setJMSCorrelationID(msg.getJMSCorrelationID()+i);
qsender.send(msg);
```
In the above code, what is the temporary queue used for? Is it for receiving the messages? Is it the receiver? And if yes, whats the use of `msg.setJMSReplyTo(temp1)` ? | 2012/08/16 | [
"https://Stackoverflow.com/questions/11981371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1131384/"
] | A generic hashmap has only a limited number of interface functions. If K is small, I don't see any obvious better way than iterating, and breaking out of the iteration once K keys are removed. Of course, if K is large it might be better to do something else, such as preserve size-k elements and clear. If you need particular characteristics, your own hashmap could have whatever characteristics you need. | Iterating is the only way.
```
// this is the number of items you want to remove
final int NUMBER_TO_REMOVE = 2;
// this is your map
Map<String, String> map = new HashMap<String, String>();
map.put("a", "1");
map.put("b", "2");
map.put("c", "3");
map.put("d", "4");
map.put("e", "5");
map.put("f", "6");
map.put("g", "7");
map.put("h", "8");
map.put("i", "9");
// get the keys
String[] keys = map.keySet().toArray(new String[map.size()]);
// remove the correct number from the map
for(int i = 0; i < NUMBER_TO_REMOVE; i++) {
map.remove(keys[i]);
}
// your map is now NUMBER_TO_REMOVE elements smaller
``` |
11,981,371 | If I use the following code to create a sender and receiver
```
qsender = qsession.createSender((Queue)msg.getJMSDestination());
qreceiver=qsession.createReceiver((Queue)msg.getJMSDestination());
```
and then do this
```
qsender.send(msg);
```
Does it just send the message to the queue and will it remain in the queue forever? Do I need to call the receive() method on the receiver or implement the MessageListener interface to get it to the receiver?
Edit: more info
```
qsender = qsession.createSender((Queue)msg.getJMSDestination());
qreceiver=qsession.createReceiver((Queue)msg.getJMSDestination());
temp1 = qsession.createTemporaryQueue();
responseConsumer = qsession.createConsumer(temp1);
msg.setJMSReplyTo(temp1);
responseConsumer.setMessageListener(responseListener);
msg.setJMSCorrelationID(msg.getJMSCorrelationID()+i);
qsender.send(msg);
```
In the above code, what is the temporary queue used for? Is it for receiving the messages? Is it the receiver? And if yes, whats the use of `msg.setJMSReplyTo(temp1)` ? | 2012/08/16 | [
"https://Stackoverflow.com/questions/11981371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1131384/"
] | Why not iterate? You can remove *from the iterator* which is likely to be very efficient - no extra lookup required:
```
Iterator<Map.Enty<Foo, Bar>> it = map.entrySet().iterator();
for (int i = 0; i < k && it.hasNext; i++)
{
it.next();
it.remove();
}
``` | A generic hashmap has only a limited number of interface functions. If K is small, I don't see any obvious better way than iterating, and breaking out of the iteration once K keys are removed. Of course, if K is large it might be better to do something else, such as preserve size-k elements and clear. If you need particular characteristics, your own hashmap could have whatever characteristics you need. |
15,815 | I've asked [this question at SO](https://stackoverflow.com/questions/4526143/construct-polygons-out-of-union-of-many-polygons), but only answer I got is a non-answer as far as I can tell, so I would like to try my luck here.
Basically, I'm looking for a better-than-naive algorithm for the constructions of polygons out of union of many polygons, each with a list of Vertex $V$. The naive algorithm to find the union polygon(s) goes like this:
>
> First take two polygons, union them,
> and take another polygon, union it
> with the union of the two polygons,
> and repeat this process until every
> single piece is considered. Then I will run
> through the union polygon list and
> check whether there are still some
> polygons can be combined, and I will
> repeat this step until a
> satisfactory result is achieved.
>
>
>
Is there a smarter algorithm?
For this purpose, you can imagine each polygon as a jigsaw puzzle piece, when you complete them you will get a nice picture. But the catch is that a small portion ( say <5%) of the jigsaw is missing, and you are still require to form a picture as complete as possible; that's the polygon ( or polygons)-- maybe with holes-- that I want to form.
Note: I'm *not* asking about how to union two polygons, but I am asking about--given that I know how to union two polygons--how to union $n$ number of (where $n>>2$) polygons in an efficient manner.
Also,all the polygons can share edges, and some polygon's edge can be shared by one or many other polygon's edge. Polygons can't overlapped among themselves. | 2010/12/29 | [
"https://math.stackexchange.com/questions/15815",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/550/"
] | Likely the best method is to perform a simultaneous [plane sweep](http://en.wikipedia.org/wiki/Plane_sweep) of all the polygons.
This is discussed in *The Algorithms Design Manual* under "[Intersection Detection](http://books.google.com/books?id=7XUSn0IKQEgC&pg=PA618&lpg=PA618&dq=plane+sweep+to+union+polygons&source=bl&ots=z6eFQRNNZd&sig=OYm-w6WA0jJQu3jtosuELrsafxA&hl=en&ei=7FUbTd-4CoWKlwed6MXhCw&sa=X&oi=book_result&ct=result&resnum=1&ved=0CBMQ6AEwAA#v=onepage&q=plane%20sweep%20to%20union%20polygons&f=false)."
(Algorithms to find the intersection can be altered to instead find the union.)
It is also discussed in my textbook *[Computational Geometry in C](http://cs.smith.edu/~orourke/books/compgeom.html)*, Chapter 7, "Intersection of NonConvex Polygons." The time complexity is $O(n \log n + k)$ for $n$ total vertices and $k$ intersection points between edges of different polygons. | If the polygons either share exactly one edge or are disjoint then create a list of edges and the polygons they belong to and then remove each edge that has two polygons, joining those two polygons. |
15,815 | I've asked [this question at SO](https://stackoverflow.com/questions/4526143/construct-polygons-out-of-union-of-many-polygons), but only answer I got is a non-answer as far as I can tell, so I would like to try my luck here.
Basically, I'm looking for a better-than-naive algorithm for the constructions of polygons out of union of many polygons, each with a list of Vertex $V$. The naive algorithm to find the union polygon(s) goes like this:
>
> First take two polygons, union them,
> and take another polygon, union it
> with the union of the two polygons,
> and repeat this process until every
> single piece is considered. Then I will run
> through the union polygon list and
> check whether there are still some
> polygons can be combined, and I will
> repeat this step until a
> satisfactory result is achieved.
>
>
>
Is there a smarter algorithm?
For this purpose, you can imagine each polygon as a jigsaw puzzle piece, when you complete them you will get a nice picture. But the catch is that a small portion ( say <5%) of the jigsaw is missing, and you are still require to form a picture as complete as possible; that's the polygon ( or polygons)-- maybe with holes-- that I want to form.
Note: I'm *not* asking about how to union two polygons, but I am asking about--given that I know how to union two polygons--how to union $n$ number of (where $n>>2$) polygons in an efficient manner.
Also,all the polygons can share edges, and some polygon's edge can be shared by one or many other polygon's edge. Polygons can't overlapped among themselves. | 2010/12/29 | [
"https://math.stackexchange.com/questions/15815",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/550/"
] | Martin Davis describes an approach on his [blog](http://lin-ear-th-inking.blogspot.dk/2007/11/fast-polygon-merging-in-jts-using.html) which he calls "Cascading Union".
The approach is to traverse a spatial index like an R-tree, to union polygons that are likely to overlap or touch, which gets rid of a lot of internal vertices. The naive approach might not reduce the number of vertices at all between two iterations...
**Martin Davis description (snippet)**:
>
> This can be thought of as a post-order traversal of a tree, where the
> union is performed at each interior node. If the tree structure is
> determined by the spatial proximity of the input polygons, and there
> is overlap or adjacency in the input dataset, this algorithm can be
> quite efficient. This is because union operations higher in the tree
> are faster, since linework is "merged away" from the lower levels.
>
>
>

**Complexity**
I don't know the exact complexity of the algorithm, but could be similar to the sweep line algorithm, since the complexity of the algorithms depends on the number of vertices remaining in each step.
See also the [full description](http://lin-ear-th-inking.blogspot.dk/2007/11/fast-polygon-merging-in-jts-using.html) of the *Cascading Union* algorithm on Martin Davis blog. | If the polygons either share exactly one edge or are disjoint then create a list of edges and the polygons they belong to and then remove each edge that has two polygons, joining those two polygons. |
15,815 | I've asked [this question at SO](https://stackoverflow.com/questions/4526143/construct-polygons-out-of-union-of-many-polygons), but only answer I got is a non-answer as far as I can tell, so I would like to try my luck here.
Basically, I'm looking for a better-than-naive algorithm for the constructions of polygons out of union of many polygons, each with a list of Vertex $V$. The naive algorithm to find the union polygon(s) goes like this:
>
> First take two polygons, union them,
> and take another polygon, union it
> with the union of the two polygons,
> and repeat this process until every
> single piece is considered. Then I will run
> through the union polygon list and
> check whether there are still some
> polygons can be combined, and I will
> repeat this step until a
> satisfactory result is achieved.
>
>
>
Is there a smarter algorithm?
For this purpose, you can imagine each polygon as a jigsaw puzzle piece, when you complete them you will get a nice picture. But the catch is that a small portion ( say <5%) of the jigsaw is missing, and you are still require to form a picture as complete as possible; that's the polygon ( or polygons)-- maybe with holes-- that I want to form.
Note: I'm *not* asking about how to union two polygons, but I am asking about--given that I know how to union two polygons--how to union $n$ number of (where $n>>2$) polygons in an efficient manner.
Also,all the polygons can share edges, and some polygon's edge can be shared by one or many other polygon's edge. Polygons can't overlapped among themselves. | 2010/12/29 | [
"https://math.stackexchange.com/questions/15815",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/550/"
] | Likely the best method is to perform a simultaneous [plane sweep](http://en.wikipedia.org/wiki/Plane_sweep) of all the polygons.
This is discussed in *The Algorithms Design Manual* under "[Intersection Detection](http://books.google.com/books?id=7XUSn0IKQEgC&pg=PA618&lpg=PA618&dq=plane+sweep+to+union+polygons&source=bl&ots=z6eFQRNNZd&sig=OYm-w6WA0jJQu3jtosuELrsafxA&hl=en&ei=7FUbTd-4CoWKlwed6MXhCw&sa=X&oi=book_result&ct=result&resnum=1&ved=0CBMQ6AEwAA#v=onepage&q=plane%20sweep%20to%20union%20polygons&f=false)."
(Algorithms to find the intersection can be altered to instead find the union.)
It is also discussed in my textbook *[Computational Geometry in C](http://cs.smith.edu/~orourke/books/compgeom.html)*, Chapter 7, "Intersection of NonConvex Polygons." The time complexity is $O(n \log n + k)$ for $n$ total vertices and $k$ intersection points between edges of different polygons. | Martin Davis describes an approach on his [blog](http://lin-ear-th-inking.blogspot.dk/2007/11/fast-polygon-merging-in-jts-using.html) which he calls "Cascading Union".
The approach is to traverse a spatial index like an R-tree, to union polygons that are likely to overlap or touch, which gets rid of a lot of internal vertices. The naive approach might not reduce the number of vertices at all between two iterations...
**Martin Davis description (snippet)**:
>
> This can be thought of as a post-order traversal of a tree, where the
> union is performed at each interior node. If the tree structure is
> determined by the spatial proximity of the input polygons, and there
> is overlap or adjacency in the input dataset, this algorithm can be
> quite efficient. This is because union operations higher in the tree
> are faster, since linework is "merged away" from the lower levels.
>
>
>

**Complexity**
I don't know the exact complexity of the algorithm, but could be similar to the sweep line algorithm, since the complexity of the algorithms depends on the number of vertices remaining in each step.
See also the [full description](http://lin-ear-th-inking.blogspot.dk/2007/11/fast-polygon-merging-in-jts-using.html) of the *Cascading Union* algorithm on Martin Davis blog. |
52,863,844 | I need save attribute "created\_at" in MySQL formatt "yyyy-mm-dd hh:mm:ss", but display in php format "d-m-Y".
It´s works fine in create scenario but when i update any attribute and save, its overwrite "created\_at" and set like "0000-00-00 00:00:00" automatically in DB.
I use two functions in the model **beforeValidade()** and **afterFind()**.
**common\models\Oficios.php**
```
public function beforeValidate()
{
if ($this->scenario == self::SCENARIO_CREATE){
$this->created_at = date('Y-m-d H:i:s');
}else {
$this->created_at = $this->created_at;
}
return parent::beforeValidate();
}
public function afterFind ()
{
// convert to display format
$this->created_at = strtotime ($this->created_at);
$this->created_at = date ('d-m-Y', $this->created_at);
parent::afterFind ();
}
``` | 2018/10/17 | [
"https://Stackoverflow.com/questions/52863844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9439508/"
] | Why don't you use `TimestampBehavior` in your data model? You could handle this issue easily with this behavior (<https://www.yiiframework.com/doc/guide/2.0/en/concept-behaviors#using-timestamp-behavior>) without doing manually.
As it is stated in the documentation:
>
> This behavior supports automatically updating the timestamp attributes
> of an Active Record model anytime the model is saved via insert(),
> update() or save() method
>
>
> | you could try this:
```
public function rules()
{
return array(
...
array('created_at','default',
'value'=>date('Y-m-d H:i:s'),
'setOnEmpty'=>false,'on'=>'insert')
);
}
```
and eliminate the function "beforeValidate"
I hope it helps you. |
52,863,844 | I need save attribute "created\_at" in MySQL formatt "yyyy-mm-dd hh:mm:ss", but display in php format "d-m-Y".
It´s works fine in create scenario but when i update any attribute and save, its overwrite "created\_at" and set like "0000-00-00 00:00:00" automatically in DB.
I use two functions in the model **beforeValidade()** and **afterFind()**.
**common\models\Oficios.php**
```
public function beforeValidate()
{
if ($this->scenario == self::SCENARIO_CREATE){
$this->created_at = date('Y-m-d H:i:s');
}else {
$this->created_at = $this->created_at;
}
return parent::beforeValidate();
}
public function afterFind ()
{
// convert to display format
$this->created_at = strtotime ($this->created_at);
$this->created_at = date ('d-m-Y', $this->created_at);
parent::afterFind ();
}
``` | 2018/10/17 | [
"https://Stackoverflow.com/questions/52863844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9439508/"
] | Why don't you use `TimestampBehavior` in your data model? You could handle this issue easily with this behavior (<https://www.yiiframework.com/doc/guide/2.0/en/concept-behaviors#using-timestamp-behavior>) without doing manually.
As it is stated in the documentation:
>
> This behavior supports automatically updating the timestamp attributes
> of an Active Record model anytime the model is saved via insert(),
> update() or save() method
>
>
> | You always can use behaviors. This is more clean and advanced way. You can control all events that model has. Here is example:
```
public function behaviors()
{
return [
[
'class' => TimestampBehavior::class,
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'created_at',
'value' => date('Y-m-d H:i:s')
],
[
'class' => AttributeBehavior::class,
'attributes' => [
ActiveRecord::EVENT_AFTER_FIND => 'created_at'
],
'value' => function ($model) {
// Any Format you want
return date('d-m-Y', strtotime($model->created_at));
}
]
];
}
``` |
52,863,844 | I need save attribute "created\_at" in MySQL formatt "yyyy-mm-dd hh:mm:ss", but display in php format "d-m-Y".
It´s works fine in create scenario but when i update any attribute and save, its overwrite "created\_at" and set like "0000-00-00 00:00:00" automatically in DB.
I use two functions in the model **beforeValidade()** and **afterFind()**.
**common\models\Oficios.php**
```
public function beforeValidate()
{
if ($this->scenario == self::SCENARIO_CREATE){
$this->created_at = date('Y-m-d H:i:s');
}else {
$this->created_at = $this->created_at;
}
return parent::beforeValidate();
}
public function afterFind ()
{
// convert to display format
$this->created_at = strtotime ($this->created_at);
$this->created_at = date ('d-m-Y', $this->created_at);
parent::afterFind ();
}
``` | 2018/10/17 | [
"https://Stackoverflow.com/questions/52863844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9439508/"
] | Why don't you use `TimestampBehavior` in your data model? You could handle this issue easily with this behavior (<https://www.yiiframework.com/doc/guide/2.0/en/concept-behaviors#using-timestamp-behavior>) without doing manually.
As it is stated in the documentation:
>
> This behavior supports automatically updating the timestamp attributes
> of an Active Record model anytime the model is saved via insert(),
> update() or save() method
>
>
> | If created\_at is saved as Unix like use `Yii::$app->formatter->asDate($model->created_at,'d-m-Y')` |
24,427,379 | I have a Group model which `has_many` Topics. The Topics model `has_many` Posts.
I want to create an array of all Topics for a Group sorted by the Post attribute `:published_on`.
On my Group show page I have `@group.topics.collect {|x| x.posts }` which returns an `ActiveRecord::Associations::CollectionProxy` array with each element containing an array of post objects.
```
[
[[topic1 post],[topic1 post],[topic1 post]],
[[topic2 post],[topic2 post],[topic2 post]],
[[topic3 post],[topic3 post],[topic3 post]],
]
```
How do I create a single array of posts sorted by :published\_on ? | 2014/06/26 | [
"https://Stackoverflow.com/questions/24427379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/256917/"
] | I think that
```
group.topics.includes(:posts).order("posts.published_on").map(&:posts).flatten
```
would be enough. | You can also resolve this with the correct relations.
On your `Group` model you could do something like:
```
# you already have this relation
has_many :topics
# you add this
has_many :posts, through: :topics
```
That [through](https://guides.rubyonrails.org/association_basics.html#the-has-many-through-association) works using `topics` like a bridge for `posts`, and returning all `posts` that your `group` have.
And than, your query would look something like
`group.posts.order(:published_on)` |
454,724 | I don't understand how to go on with this question:
"As the point $R$ moves on the line $x+y=1$ from $(1,0)$ to $(0,1)$, the point $P$ moves such that it has the same $x$-coordinate as $R$, and its $y$-coordinate is equal to the square root of that of $R$. Describe the locus of $P$ and draw the loci of both $R$ and $P$ on the same set of axes."
Any help would be appreciated,
Thanks | 2013/07/29 | [
"https://math.stackexchange.com/questions/454724",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/70377/"
] | First, just graph the line first on the Cartesian plane. And then,
determine the relationship between $R$ and $P$. Any point $R$ would
be of the form $\left(t,1-t\right)$, where $0\leq t\leq1$.
This means that $P$ will have coordinates $\left(t,\sqrt{1-t}\right)$.
So actually what you have is
\begin{eqnarray\*}
f:R & \rightarrow & P\\
\left(t,1-t\right) & \mapsto & \left(t,\sqrt{1-t}\right).
\end{eqnarray\*}
After some changes in the coordinates, what you have is $\left(1-s,s\right)\mapsto\left(1-s,\sqrt{s}\right)$,
where $0\leq s\leq1$. Just run through all the points and you'll
eventually see a graph, which is actually $y=\sqrt{1-x}$ on $\left[0,1\right]$. | First draw the line hence it will be between $y = 1$ and $x = 1$ and then use the $1/x$ method and it will increase hence the curve will go above the line and create a parabola shape. |
454,724 | I don't understand how to go on with this question:
"As the point $R$ moves on the line $x+y=1$ from $(1,0)$ to $(0,1)$, the point $P$ moves such that it has the same $x$-coordinate as $R$, and its $y$-coordinate is equal to the square root of that of $R$. Describe the locus of $P$ and draw the loci of both $R$ and $P$ on the same set of axes."
Any help would be appreciated,
Thanks | 2013/07/29 | [
"https://math.stackexchange.com/questions/454724",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/70377/"
] | **Hint:** The question can be interpreted as such:
Plot the line $(x,\sqrt{1-x})$ from $x=1$ to $0$. | First draw the line hence it will be between $y = 1$ and $x = 1$ and then use the $1/x$ method and it will increase hence the curve will go above the line and create a parabola shape. |
9,694,759 | I've a got ListBox called lbxUpcommingEvents. When the index is changed the event handler is fired to check for duplicate records. If duplicates are not found, a panel called pnlAction inside a formview is turned on by the way of display style. If dups are found another panel pnlActionCancel is turned on and the oter is tuned off. Basically a toogle effect.
I've tried the visible property, viewstate property, but it does not work and I can't figure it out so once again, I seek wizdom from the collective. Here is my code.
```
protected void lbxUpcommingEvents_OnSelectedIndexChanged(object sender, EventArgs e)
{
pnlEventsSignUp.Visible = true;
string _selectedItemValue = lbxUpcommingEvents.SelectedValue.ToString();
int _eventid = Convert.ToInt32(_selectedItemValue);
Guid _memberId = Guid.Empty;
_memberId = new Guid(Session["myId"].ToString());
// Check for existing signup
EventsMemberSignup _createSingup = new EventsMemberSignup();
dsEventsSingupTableAdapters.MemberEventsTableAdapter da = new dsEventsSingupTableAdapters.MemberEventsTableAdapter();
dsEventsSingup.MemberEventsDataTable dt = da.GetDataForDupCheck(_memberId, _eventid);
if (dt.Rows.Count == 1)
{
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = false;
pnlAction.Style.Add("display","none");
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = true;
pnlActionCancel.Style.Remove("display");
}
else
{
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = false;
pnlActionCancel.Style.Add("display", "none");
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = true;
pnlAction.Style.Remove("display");
}
}
<div id="columnleft">
<a name="content_start" id="content_start"></a>
<div class="leftblock">
<h2>Events Signup</h2>
<p>
</p>
<h3> Upcomming Events</h3>
<p>
<asp:ListBox ID="lbxUpcommingEvents" runat="server" DataSourceID="odsUpcommingEvents"
Rows="6" DataTextField="Title" DataValueField="id" AutoPostBack="true"
Width="206px" OnSelectedIndexChanged="lbxUpcommingEvents_OnSelectedIndexChanged" />
</p>
<h3> Members Attending</h3>
<p>
<asp:DataGrid ID="lboxSignedUpMembers" runat="server" DataSourceID="odsSignedUpMembers"
AutoPostBack="true" AutoGenerateColumns="false" RowStyle-CssClass="gridview" AlternatingRowStyle-CssClass="altbgcolor"
Width="206px" onselectedindexchanged="lboxSignedUpMembers_SelectedIndexChanged" CssClass="gridview"
GridLines="None" BorderStyle="Solid" BorderWidth="1" BorderColor="Black" >
<AlternatingItemStyle BackColor="White" />
<Columns>
<asp:BoundColumn DataField="Name" />
<asp:BoundColumn DataField="Title" />
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label runat="server" ID="lblDate" Text='<%# Eval("StartTime", "{0:d}") %>' />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</p>
</div>
</div>
</td>
<td align="left" >
<!--Start of right column-->
<div id="columnright">
<div class="rightblock">
<asp:Panel ID="pnlEventsSignUpTitle" runat="server" CssClass="actionbuttons">
<h2>Select an Event to Signup</h2>
</asp:Panel>
<asp:Label runat="server" ID="lblNote" ForeColor="#cc0000" Font-Bold="true" />
</div>
<div class="rightblock">
<asp:Panel runat="server" ID="pnlEventsSignUp" visible="false">
<div class="dashedline" ></div>
<asp:FormView ID="fvEventSignUp" runat="server" DataSourceID="ObjectDataSource1"
DataKeyNames="id" Width="100%" >
<ItemTemplate>
<h2>
<asp:HiddenField runat="server" ID="hfEventID" Value='<%# Eval("id") %>' />
<asp:Label Text='<%# Eval("title") %>' runat="server" ID="titleLabel" />
</h2>
<div class="itemdetails">
<br />
location:
<h3>
<asp:Label ID="locationLabel" runat="server" Text='<%# ShowLocationLink(Eval("locationname"),Eval("location")) %>' />
</h3>
<p>
<asp:Label Text='<%# Eval("starttime","{0:D}") %>' runat="server" ID="itemdateLabel" CssClass="GeneralText" />
<asp:Label Text='<%# ShowDuration(Eval("starttime"),Eval("endtime")) %>' runat="server" ID="Label1" CssClass="GeneralText" />
</p>
</div>
<div class="downloadevent">
<a href="#">
<img src="images/icon_download_event.gif" alt="Download this event to your personal calendar"
width="15" height="26" /></a><a href='<%# "events_download.ashx?EventID=" + Convert.ToString(Eval("id")) %>'>Add
this event to your personal calendar</a>
</div>
<Club:ImageThumbnail ID="thumb1" runat="server" ImageSize="Large" PhotoID='<%# Eval("photo") %>' />
<p>
<asp:Label Text='<%# Eval("description") %>' runat="server" ID="descriptionLabel" />
</p>
<div class="dashedline" ></div>
<asp:Panel ID="pnlAction" runat="server" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="Label2" Text="Action<br />Required" Width="80px" Font-Bold="true"
ForeColor="#cc0000" Font-Size="14px" />
</td>
<td>
<img src="images/RedArrow.jpg" alt="Red Arrow Right" />
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCert" Height="30px" Text="Check to Confirm Attendance" /><br />
<asp:CustomValidator runat="server" ID="rfvConfirm"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnkSignUp" runat="server" Text = "I will be attending this event"
OnClick="rlnkSignUp_OnClick" ToolTip="I hereby certify that I am commiting to attending this event."
/>
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel runat="server" ID="pnlActionCancel" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="lblDupSignup" Text="You are alredy signed up for this event" ForeColor="#cc0000" Font-Bold="true" Font-Size="14px" />
</td>
<td>
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCancel" Height="30px" Text="Check to Cancel Attendance" /><br />
<asp:CustomValidator runat="server" ID="CustomValidator1"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnCancel" runat="server" Text="I'm cancelling my participation"
OnClick="rlnCancel_OnClick" />
</td>
</tr>
</table>
</asp:Panel>
</ItemTemplate>
</asp:FormView>
</asp:Panel>
</div>
``` | 2012/03/14 | [
"https://Stackoverflow.com/questions/9694759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/234188/"
] | By default the name of your class is the name of your AOT-compiled namespace (that's what gen-class is for), so you can simply use the namespace's class.
```
(ns foo.core
(:gen-class))
(defn this-jar
"utility function to get the name of jar in which this function is invoked"
[& [ns]]
;; The .toURI step is vital to avoid problems with special characters,
;; including spaces and pluses.
;; Source: https://stackoverflow.com/q/320542/7012#comment18478290_320595
(-> (or ns (class *ns*))
.getProtectionDomain .getCodeSource .getLocation .toURI .getPath))
(defn -main [& _]
(println (this-jar foo.core)))
```
Result of running:
```
$ java -cp foo-0.1.0-SNAPSHOT-standalone.jar foo.core
/home/rlevy/prj/foo/target/foo-0.1.0-SNAPSHOT-standalone.jar
``` | ```
(defn this-jar
"utility function to get the name of jar in which this function is invoked"
[& [ns]]
(-> (or ns (class *ns*))
.getProtectionDomain .getCodeSource .getLocation .toURI .getPath))
```
Note that it's crucial to call `.toURI` to avoid problems with paths that have spaces as described in the equivalent Java question: [How to get the path of a running JAR file?](https://stackoverflow.com/questions/320542/how-to-get-the-path-of-a-running-jar-file). |
9,694,759 | I've a got ListBox called lbxUpcommingEvents. When the index is changed the event handler is fired to check for duplicate records. If duplicates are not found, a panel called pnlAction inside a formview is turned on by the way of display style. If dups are found another panel pnlActionCancel is turned on and the oter is tuned off. Basically a toogle effect.
I've tried the visible property, viewstate property, but it does not work and I can't figure it out so once again, I seek wizdom from the collective. Here is my code.
```
protected void lbxUpcommingEvents_OnSelectedIndexChanged(object sender, EventArgs e)
{
pnlEventsSignUp.Visible = true;
string _selectedItemValue = lbxUpcommingEvents.SelectedValue.ToString();
int _eventid = Convert.ToInt32(_selectedItemValue);
Guid _memberId = Guid.Empty;
_memberId = new Guid(Session["myId"].ToString());
// Check for existing signup
EventsMemberSignup _createSingup = new EventsMemberSignup();
dsEventsSingupTableAdapters.MemberEventsTableAdapter da = new dsEventsSingupTableAdapters.MemberEventsTableAdapter();
dsEventsSingup.MemberEventsDataTable dt = da.GetDataForDupCheck(_memberId, _eventid);
if (dt.Rows.Count == 1)
{
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = false;
pnlAction.Style.Add("display","none");
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = true;
pnlActionCancel.Style.Remove("display");
}
else
{
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = false;
pnlActionCancel.Style.Add("display", "none");
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = true;
pnlAction.Style.Remove("display");
}
}
<div id="columnleft">
<a name="content_start" id="content_start"></a>
<div class="leftblock">
<h2>Events Signup</h2>
<p>
</p>
<h3> Upcomming Events</h3>
<p>
<asp:ListBox ID="lbxUpcommingEvents" runat="server" DataSourceID="odsUpcommingEvents"
Rows="6" DataTextField="Title" DataValueField="id" AutoPostBack="true"
Width="206px" OnSelectedIndexChanged="lbxUpcommingEvents_OnSelectedIndexChanged" />
</p>
<h3> Members Attending</h3>
<p>
<asp:DataGrid ID="lboxSignedUpMembers" runat="server" DataSourceID="odsSignedUpMembers"
AutoPostBack="true" AutoGenerateColumns="false" RowStyle-CssClass="gridview" AlternatingRowStyle-CssClass="altbgcolor"
Width="206px" onselectedindexchanged="lboxSignedUpMembers_SelectedIndexChanged" CssClass="gridview"
GridLines="None" BorderStyle="Solid" BorderWidth="1" BorderColor="Black" >
<AlternatingItemStyle BackColor="White" />
<Columns>
<asp:BoundColumn DataField="Name" />
<asp:BoundColumn DataField="Title" />
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label runat="server" ID="lblDate" Text='<%# Eval("StartTime", "{0:d}") %>' />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</p>
</div>
</div>
</td>
<td align="left" >
<!--Start of right column-->
<div id="columnright">
<div class="rightblock">
<asp:Panel ID="pnlEventsSignUpTitle" runat="server" CssClass="actionbuttons">
<h2>Select an Event to Signup</h2>
</asp:Panel>
<asp:Label runat="server" ID="lblNote" ForeColor="#cc0000" Font-Bold="true" />
</div>
<div class="rightblock">
<asp:Panel runat="server" ID="pnlEventsSignUp" visible="false">
<div class="dashedline" ></div>
<asp:FormView ID="fvEventSignUp" runat="server" DataSourceID="ObjectDataSource1"
DataKeyNames="id" Width="100%" >
<ItemTemplate>
<h2>
<asp:HiddenField runat="server" ID="hfEventID" Value='<%# Eval("id") %>' />
<asp:Label Text='<%# Eval("title") %>' runat="server" ID="titleLabel" />
</h2>
<div class="itemdetails">
<br />
location:
<h3>
<asp:Label ID="locationLabel" runat="server" Text='<%# ShowLocationLink(Eval("locationname"),Eval("location")) %>' />
</h3>
<p>
<asp:Label Text='<%# Eval("starttime","{0:D}") %>' runat="server" ID="itemdateLabel" CssClass="GeneralText" />
<asp:Label Text='<%# ShowDuration(Eval("starttime"),Eval("endtime")) %>' runat="server" ID="Label1" CssClass="GeneralText" />
</p>
</div>
<div class="downloadevent">
<a href="#">
<img src="images/icon_download_event.gif" alt="Download this event to your personal calendar"
width="15" height="26" /></a><a href='<%# "events_download.ashx?EventID=" + Convert.ToString(Eval("id")) %>'>Add
this event to your personal calendar</a>
</div>
<Club:ImageThumbnail ID="thumb1" runat="server" ImageSize="Large" PhotoID='<%# Eval("photo") %>' />
<p>
<asp:Label Text='<%# Eval("description") %>' runat="server" ID="descriptionLabel" />
</p>
<div class="dashedline" ></div>
<asp:Panel ID="pnlAction" runat="server" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="Label2" Text="Action<br />Required" Width="80px" Font-Bold="true"
ForeColor="#cc0000" Font-Size="14px" />
</td>
<td>
<img src="images/RedArrow.jpg" alt="Red Arrow Right" />
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCert" Height="30px" Text="Check to Confirm Attendance" /><br />
<asp:CustomValidator runat="server" ID="rfvConfirm"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnkSignUp" runat="server" Text = "I will be attending this event"
OnClick="rlnkSignUp_OnClick" ToolTip="I hereby certify that I am commiting to attending this event."
/>
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel runat="server" ID="pnlActionCancel" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="lblDupSignup" Text="You are alredy signed up for this event" ForeColor="#cc0000" Font-Bold="true" Font-Size="14px" />
</td>
<td>
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCancel" Height="30px" Text="Check to Cancel Attendance" /><br />
<asp:CustomValidator runat="server" ID="CustomValidator1"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnCancel" runat="server" Text="I'm cancelling my participation"
OnClick="rlnCancel_OnClick" />
</td>
</tr>
</table>
</asp:Panel>
</ItemTemplate>
</asp:FormView>
</asp:Panel>
</div>
``` | 2012/03/14 | [
"https://Stackoverflow.com/questions/9694759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/234188/"
] | The idea of classpath is to hide where classes come from. You may have classes with the same name loaded from different classloaders, you may have the same class in multiple jars and rely on classpath ordering to choose the correct one.
Why do you want to know? If it's for any other reason than debug/logging purposes you are on dangerous ground and should tread carefully.
In fact it's perfectly reasonable for classes to have no jar file. This can happen in java for any runtime generated classes (think proxies).
In clojure a simple example would be as shown in the repl session below... You'll see @mikera's suggestion works fine for `clojure.lang.Atom` which is a built in class. But when you use a `deftype` to create your own type, clojure generates a class and it has no location...
```
user> (prn (-> clojure.lang.Atom
(.getProtectionDomain)
(.getCodeSource)
(.getLocation)))
#<URL file:/workspace/clj-scratch/lib/clojure-1.3.0.jar>
nil
user> (deftype Foo [])
user.Foo
user> (prn (-> (Foo.)
(.getClass)
(.getProtectionDomain)
(.getCodeSource)
(.getLocation)))
nil
nil
user>
``` | You could try getting the path from a class defined by Clojure itself, e.g.:
```
(-> clojure.lang.Atom (.getProtectionDomain) (.getCodeSource) (.getLocation))
=> file:/some/path/to/clojure-1.3.0.jar
```
I believe this is technically the running jar file if you are running Clojure scripts or coding at the REPL. |
9,694,759 | I've a got ListBox called lbxUpcommingEvents. When the index is changed the event handler is fired to check for duplicate records. If duplicates are not found, a panel called pnlAction inside a formview is turned on by the way of display style. If dups are found another panel pnlActionCancel is turned on and the oter is tuned off. Basically a toogle effect.
I've tried the visible property, viewstate property, but it does not work and I can't figure it out so once again, I seek wizdom from the collective. Here is my code.
```
protected void lbxUpcommingEvents_OnSelectedIndexChanged(object sender, EventArgs e)
{
pnlEventsSignUp.Visible = true;
string _selectedItemValue = lbxUpcommingEvents.SelectedValue.ToString();
int _eventid = Convert.ToInt32(_selectedItemValue);
Guid _memberId = Guid.Empty;
_memberId = new Guid(Session["myId"].ToString());
// Check for existing signup
EventsMemberSignup _createSingup = new EventsMemberSignup();
dsEventsSingupTableAdapters.MemberEventsTableAdapter da = new dsEventsSingupTableAdapters.MemberEventsTableAdapter();
dsEventsSingup.MemberEventsDataTable dt = da.GetDataForDupCheck(_memberId, _eventid);
if (dt.Rows.Count == 1)
{
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = false;
pnlAction.Style.Add("display","none");
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = true;
pnlActionCancel.Style.Remove("display");
}
else
{
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = false;
pnlActionCancel.Style.Add("display", "none");
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = true;
pnlAction.Style.Remove("display");
}
}
<div id="columnleft">
<a name="content_start" id="content_start"></a>
<div class="leftblock">
<h2>Events Signup</h2>
<p>
</p>
<h3> Upcomming Events</h3>
<p>
<asp:ListBox ID="lbxUpcommingEvents" runat="server" DataSourceID="odsUpcommingEvents"
Rows="6" DataTextField="Title" DataValueField="id" AutoPostBack="true"
Width="206px" OnSelectedIndexChanged="lbxUpcommingEvents_OnSelectedIndexChanged" />
</p>
<h3> Members Attending</h3>
<p>
<asp:DataGrid ID="lboxSignedUpMembers" runat="server" DataSourceID="odsSignedUpMembers"
AutoPostBack="true" AutoGenerateColumns="false" RowStyle-CssClass="gridview" AlternatingRowStyle-CssClass="altbgcolor"
Width="206px" onselectedindexchanged="lboxSignedUpMembers_SelectedIndexChanged" CssClass="gridview"
GridLines="None" BorderStyle="Solid" BorderWidth="1" BorderColor="Black" >
<AlternatingItemStyle BackColor="White" />
<Columns>
<asp:BoundColumn DataField="Name" />
<asp:BoundColumn DataField="Title" />
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label runat="server" ID="lblDate" Text='<%# Eval("StartTime", "{0:d}") %>' />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</p>
</div>
</div>
</td>
<td align="left" >
<!--Start of right column-->
<div id="columnright">
<div class="rightblock">
<asp:Panel ID="pnlEventsSignUpTitle" runat="server" CssClass="actionbuttons">
<h2>Select an Event to Signup</h2>
</asp:Panel>
<asp:Label runat="server" ID="lblNote" ForeColor="#cc0000" Font-Bold="true" />
</div>
<div class="rightblock">
<asp:Panel runat="server" ID="pnlEventsSignUp" visible="false">
<div class="dashedline" ></div>
<asp:FormView ID="fvEventSignUp" runat="server" DataSourceID="ObjectDataSource1"
DataKeyNames="id" Width="100%" >
<ItemTemplate>
<h2>
<asp:HiddenField runat="server" ID="hfEventID" Value='<%# Eval("id") %>' />
<asp:Label Text='<%# Eval("title") %>' runat="server" ID="titleLabel" />
</h2>
<div class="itemdetails">
<br />
location:
<h3>
<asp:Label ID="locationLabel" runat="server" Text='<%# ShowLocationLink(Eval("locationname"),Eval("location")) %>' />
</h3>
<p>
<asp:Label Text='<%# Eval("starttime","{0:D}") %>' runat="server" ID="itemdateLabel" CssClass="GeneralText" />
<asp:Label Text='<%# ShowDuration(Eval("starttime"),Eval("endtime")) %>' runat="server" ID="Label1" CssClass="GeneralText" />
</p>
</div>
<div class="downloadevent">
<a href="#">
<img src="images/icon_download_event.gif" alt="Download this event to your personal calendar"
width="15" height="26" /></a><a href='<%# "events_download.ashx?EventID=" + Convert.ToString(Eval("id")) %>'>Add
this event to your personal calendar</a>
</div>
<Club:ImageThumbnail ID="thumb1" runat="server" ImageSize="Large" PhotoID='<%# Eval("photo") %>' />
<p>
<asp:Label Text='<%# Eval("description") %>' runat="server" ID="descriptionLabel" />
</p>
<div class="dashedline" ></div>
<asp:Panel ID="pnlAction" runat="server" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="Label2" Text="Action<br />Required" Width="80px" Font-Bold="true"
ForeColor="#cc0000" Font-Size="14px" />
</td>
<td>
<img src="images/RedArrow.jpg" alt="Red Arrow Right" />
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCert" Height="30px" Text="Check to Confirm Attendance" /><br />
<asp:CustomValidator runat="server" ID="rfvConfirm"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnkSignUp" runat="server" Text = "I will be attending this event"
OnClick="rlnkSignUp_OnClick" ToolTip="I hereby certify that I am commiting to attending this event."
/>
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel runat="server" ID="pnlActionCancel" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="lblDupSignup" Text="You are alredy signed up for this event" ForeColor="#cc0000" Font-Bold="true" Font-Size="14px" />
</td>
<td>
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCancel" Height="30px" Text="Check to Cancel Attendance" /><br />
<asp:CustomValidator runat="server" ID="CustomValidator1"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnCancel" runat="server" Text="I'm cancelling my participation"
OnClick="rlnCancel_OnClick" />
</td>
</tr>
</table>
</asp:Panel>
</ItemTemplate>
</asp:FormView>
</asp:Panel>
</div>
``` | 2012/03/14 | [
"https://Stackoverflow.com/questions/9694759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/234188/"
] | By default the name of your class is the name of your AOT-compiled namespace (that's what gen-class is for), so you can simply use the namespace's class.
```
(ns foo.core
(:gen-class))
(defn this-jar
"utility function to get the name of jar in which this function is invoked"
[& [ns]]
;; The .toURI step is vital to avoid problems with special characters,
;; including spaces and pluses.
;; Source: https://stackoverflow.com/q/320542/7012#comment18478290_320595
(-> (or ns (class *ns*))
.getProtectionDomain .getCodeSource .getLocation .toURI .getPath))
(defn -main [& _]
(println (this-jar foo.core)))
```
Result of running:
```
$ java -cp foo-0.1.0-SNAPSHOT-standalone.jar foo.core
/home/rlevy/prj/foo/target/foo-0.1.0-SNAPSHOT-standalone.jar
``` | find source files in a jar: [tools.namespace/clojure-sources-in-jar](http://clojure.github.com/tools.namespace/#clojure.tools.namespace/clojure-sources-in-jar) |
9,694,759 | I've a got ListBox called lbxUpcommingEvents. When the index is changed the event handler is fired to check for duplicate records. If duplicates are not found, a panel called pnlAction inside a formview is turned on by the way of display style. If dups are found another panel pnlActionCancel is turned on and the oter is tuned off. Basically a toogle effect.
I've tried the visible property, viewstate property, but it does not work and I can't figure it out so once again, I seek wizdom from the collective. Here is my code.
```
protected void lbxUpcommingEvents_OnSelectedIndexChanged(object sender, EventArgs e)
{
pnlEventsSignUp.Visible = true;
string _selectedItemValue = lbxUpcommingEvents.SelectedValue.ToString();
int _eventid = Convert.ToInt32(_selectedItemValue);
Guid _memberId = Guid.Empty;
_memberId = new Guid(Session["myId"].ToString());
// Check for existing signup
EventsMemberSignup _createSingup = new EventsMemberSignup();
dsEventsSingupTableAdapters.MemberEventsTableAdapter da = new dsEventsSingupTableAdapters.MemberEventsTableAdapter();
dsEventsSingup.MemberEventsDataTable dt = da.GetDataForDupCheck(_memberId, _eventid);
if (dt.Rows.Count == 1)
{
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = false;
pnlAction.Style.Add("display","none");
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = true;
pnlActionCancel.Style.Remove("display");
}
else
{
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = false;
pnlActionCancel.Style.Add("display", "none");
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = true;
pnlAction.Style.Remove("display");
}
}
<div id="columnleft">
<a name="content_start" id="content_start"></a>
<div class="leftblock">
<h2>Events Signup</h2>
<p>
</p>
<h3> Upcomming Events</h3>
<p>
<asp:ListBox ID="lbxUpcommingEvents" runat="server" DataSourceID="odsUpcommingEvents"
Rows="6" DataTextField="Title" DataValueField="id" AutoPostBack="true"
Width="206px" OnSelectedIndexChanged="lbxUpcommingEvents_OnSelectedIndexChanged" />
</p>
<h3> Members Attending</h3>
<p>
<asp:DataGrid ID="lboxSignedUpMembers" runat="server" DataSourceID="odsSignedUpMembers"
AutoPostBack="true" AutoGenerateColumns="false" RowStyle-CssClass="gridview" AlternatingRowStyle-CssClass="altbgcolor"
Width="206px" onselectedindexchanged="lboxSignedUpMembers_SelectedIndexChanged" CssClass="gridview"
GridLines="None" BorderStyle="Solid" BorderWidth="1" BorderColor="Black" >
<AlternatingItemStyle BackColor="White" />
<Columns>
<asp:BoundColumn DataField="Name" />
<asp:BoundColumn DataField="Title" />
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label runat="server" ID="lblDate" Text='<%# Eval("StartTime", "{0:d}") %>' />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</p>
</div>
</div>
</td>
<td align="left" >
<!--Start of right column-->
<div id="columnright">
<div class="rightblock">
<asp:Panel ID="pnlEventsSignUpTitle" runat="server" CssClass="actionbuttons">
<h2>Select an Event to Signup</h2>
</asp:Panel>
<asp:Label runat="server" ID="lblNote" ForeColor="#cc0000" Font-Bold="true" />
</div>
<div class="rightblock">
<asp:Panel runat="server" ID="pnlEventsSignUp" visible="false">
<div class="dashedline" ></div>
<asp:FormView ID="fvEventSignUp" runat="server" DataSourceID="ObjectDataSource1"
DataKeyNames="id" Width="100%" >
<ItemTemplate>
<h2>
<asp:HiddenField runat="server" ID="hfEventID" Value='<%# Eval("id") %>' />
<asp:Label Text='<%# Eval("title") %>' runat="server" ID="titleLabel" />
</h2>
<div class="itemdetails">
<br />
location:
<h3>
<asp:Label ID="locationLabel" runat="server" Text='<%# ShowLocationLink(Eval("locationname"),Eval("location")) %>' />
</h3>
<p>
<asp:Label Text='<%# Eval("starttime","{0:D}") %>' runat="server" ID="itemdateLabel" CssClass="GeneralText" />
<asp:Label Text='<%# ShowDuration(Eval("starttime"),Eval("endtime")) %>' runat="server" ID="Label1" CssClass="GeneralText" />
</p>
</div>
<div class="downloadevent">
<a href="#">
<img src="images/icon_download_event.gif" alt="Download this event to your personal calendar"
width="15" height="26" /></a><a href='<%# "events_download.ashx?EventID=" + Convert.ToString(Eval("id")) %>'>Add
this event to your personal calendar</a>
</div>
<Club:ImageThumbnail ID="thumb1" runat="server" ImageSize="Large" PhotoID='<%# Eval("photo") %>' />
<p>
<asp:Label Text='<%# Eval("description") %>' runat="server" ID="descriptionLabel" />
</p>
<div class="dashedline" ></div>
<asp:Panel ID="pnlAction" runat="server" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="Label2" Text="Action<br />Required" Width="80px" Font-Bold="true"
ForeColor="#cc0000" Font-Size="14px" />
</td>
<td>
<img src="images/RedArrow.jpg" alt="Red Arrow Right" />
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCert" Height="30px" Text="Check to Confirm Attendance" /><br />
<asp:CustomValidator runat="server" ID="rfvConfirm"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnkSignUp" runat="server" Text = "I will be attending this event"
OnClick="rlnkSignUp_OnClick" ToolTip="I hereby certify that I am commiting to attending this event."
/>
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel runat="server" ID="pnlActionCancel" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="lblDupSignup" Text="You are alredy signed up for this event" ForeColor="#cc0000" Font-Bold="true" Font-Size="14px" />
</td>
<td>
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCancel" Height="30px" Text="Check to Cancel Attendance" /><br />
<asp:CustomValidator runat="server" ID="CustomValidator1"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnCancel" runat="server" Text="I'm cancelling my participation"
OnClick="rlnCancel_OnClick" />
</td>
</tr>
</table>
</asp:Panel>
</ItemTemplate>
</asp:FormView>
</asp:Panel>
</div>
``` | 2012/03/14 | [
"https://Stackoverflow.com/questions/9694759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/234188/"
] | ```
(defn this-jar
"utility function to get the name of jar in which this function is invoked"
[& [ns]]
(-> (or ns (class *ns*))
.getProtectionDomain .getCodeSource .getLocation .toURI .getPath))
```
Note that it's crucial to call `.toURI` to avoid problems with paths that have spaces as described in the equivalent Java question: [How to get the path of a running JAR file?](https://stackoverflow.com/questions/320542/how-to-get-the-path-of-a-running-jar-file). | find source files in a jar: [tools.namespace/clojure-sources-in-jar](http://clojure.github.com/tools.namespace/#clojure.tools.namespace/clojure-sources-in-jar) |
9,694,759 | I've a got ListBox called lbxUpcommingEvents. When the index is changed the event handler is fired to check for duplicate records. If duplicates are not found, a panel called pnlAction inside a formview is turned on by the way of display style. If dups are found another panel pnlActionCancel is turned on and the oter is tuned off. Basically a toogle effect.
I've tried the visible property, viewstate property, but it does not work and I can't figure it out so once again, I seek wizdom from the collective. Here is my code.
```
protected void lbxUpcommingEvents_OnSelectedIndexChanged(object sender, EventArgs e)
{
pnlEventsSignUp.Visible = true;
string _selectedItemValue = lbxUpcommingEvents.SelectedValue.ToString();
int _eventid = Convert.ToInt32(_selectedItemValue);
Guid _memberId = Guid.Empty;
_memberId = new Guid(Session["myId"].ToString());
// Check for existing signup
EventsMemberSignup _createSingup = new EventsMemberSignup();
dsEventsSingupTableAdapters.MemberEventsTableAdapter da = new dsEventsSingupTableAdapters.MemberEventsTableAdapter();
dsEventsSingup.MemberEventsDataTable dt = da.GetDataForDupCheck(_memberId, _eventid);
if (dt.Rows.Count == 1)
{
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = false;
pnlAction.Style.Add("display","none");
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = true;
pnlActionCancel.Style.Remove("display");
}
else
{
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = false;
pnlActionCancel.Style.Add("display", "none");
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = true;
pnlAction.Style.Remove("display");
}
}
<div id="columnleft">
<a name="content_start" id="content_start"></a>
<div class="leftblock">
<h2>Events Signup</h2>
<p>
</p>
<h3> Upcomming Events</h3>
<p>
<asp:ListBox ID="lbxUpcommingEvents" runat="server" DataSourceID="odsUpcommingEvents"
Rows="6" DataTextField="Title" DataValueField="id" AutoPostBack="true"
Width="206px" OnSelectedIndexChanged="lbxUpcommingEvents_OnSelectedIndexChanged" />
</p>
<h3> Members Attending</h3>
<p>
<asp:DataGrid ID="lboxSignedUpMembers" runat="server" DataSourceID="odsSignedUpMembers"
AutoPostBack="true" AutoGenerateColumns="false" RowStyle-CssClass="gridview" AlternatingRowStyle-CssClass="altbgcolor"
Width="206px" onselectedindexchanged="lboxSignedUpMembers_SelectedIndexChanged" CssClass="gridview"
GridLines="None" BorderStyle="Solid" BorderWidth="1" BorderColor="Black" >
<AlternatingItemStyle BackColor="White" />
<Columns>
<asp:BoundColumn DataField="Name" />
<asp:BoundColumn DataField="Title" />
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label runat="server" ID="lblDate" Text='<%# Eval("StartTime", "{0:d}") %>' />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</p>
</div>
</div>
</td>
<td align="left" >
<!--Start of right column-->
<div id="columnright">
<div class="rightblock">
<asp:Panel ID="pnlEventsSignUpTitle" runat="server" CssClass="actionbuttons">
<h2>Select an Event to Signup</h2>
</asp:Panel>
<asp:Label runat="server" ID="lblNote" ForeColor="#cc0000" Font-Bold="true" />
</div>
<div class="rightblock">
<asp:Panel runat="server" ID="pnlEventsSignUp" visible="false">
<div class="dashedline" ></div>
<asp:FormView ID="fvEventSignUp" runat="server" DataSourceID="ObjectDataSource1"
DataKeyNames="id" Width="100%" >
<ItemTemplate>
<h2>
<asp:HiddenField runat="server" ID="hfEventID" Value='<%# Eval("id") %>' />
<asp:Label Text='<%# Eval("title") %>' runat="server" ID="titleLabel" />
</h2>
<div class="itemdetails">
<br />
location:
<h3>
<asp:Label ID="locationLabel" runat="server" Text='<%# ShowLocationLink(Eval("locationname"),Eval("location")) %>' />
</h3>
<p>
<asp:Label Text='<%# Eval("starttime","{0:D}") %>' runat="server" ID="itemdateLabel" CssClass="GeneralText" />
<asp:Label Text='<%# ShowDuration(Eval("starttime"),Eval("endtime")) %>' runat="server" ID="Label1" CssClass="GeneralText" />
</p>
</div>
<div class="downloadevent">
<a href="#">
<img src="images/icon_download_event.gif" alt="Download this event to your personal calendar"
width="15" height="26" /></a><a href='<%# "events_download.ashx?EventID=" + Convert.ToString(Eval("id")) %>'>Add
this event to your personal calendar</a>
</div>
<Club:ImageThumbnail ID="thumb1" runat="server" ImageSize="Large" PhotoID='<%# Eval("photo") %>' />
<p>
<asp:Label Text='<%# Eval("description") %>' runat="server" ID="descriptionLabel" />
</p>
<div class="dashedline" ></div>
<asp:Panel ID="pnlAction" runat="server" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="Label2" Text="Action<br />Required" Width="80px" Font-Bold="true"
ForeColor="#cc0000" Font-Size="14px" />
</td>
<td>
<img src="images/RedArrow.jpg" alt="Red Arrow Right" />
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCert" Height="30px" Text="Check to Confirm Attendance" /><br />
<asp:CustomValidator runat="server" ID="rfvConfirm"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnkSignUp" runat="server" Text = "I will be attending this event"
OnClick="rlnkSignUp_OnClick" ToolTip="I hereby certify that I am commiting to attending this event."
/>
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel runat="server" ID="pnlActionCancel" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="lblDupSignup" Text="You are alredy signed up for this event" ForeColor="#cc0000" Font-Bold="true" Font-Size="14px" />
</td>
<td>
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCancel" Height="30px" Text="Check to Cancel Attendance" /><br />
<asp:CustomValidator runat="server" ID="CustomValidator1"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnCancel" runat="server" Text="I'm cancelling my participation"
OnClick="rlnCancel_OnClick" />
</td>
</tr>
</table>
</asp:Panel>
</ItemTemplate>
</asp:FormView>
</asp:Panel>
</div>
``` | 2012/03/14 | [
"https://Stackoverflow.com/questions/9694759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/234188/"
] | By default the name of your class is the name of your AOT-compiled namespace (that's what gen-class is for), so you can simply use the namespace's class.
```
(ns foo.core
(:gen-class))
(defn this-jar
"utility function to get the name of jar in which this function is invoked"
[& [ns]]
;; The .toURI step is vital to avoid problems with special characters,
;; including spaces and pluses.
;; Source: https://stackoverflow.com/q/320542/7012#comment18478290_320595
(-> (or ns (class *ns*))
.getProtectionDomain .getCodeSource .getLocation .toURI .getPath))
(defn -main [& _]
(println (this-jar foo.core)))
```
Result of running:
```
$ java -cp foo-0.1.0-SNAPSHOT-standalone.jar foo.core
/home/rlevy/prj/foo/target/foo-0.1.0-SNAPSHOT-standalone.jar
``` | I haven't tried this, but it seems like all you need is a class instance. So for example can you not do this:
```
(-> (new Object) (.getClass) (.getProtectionDomain) (.getCodeSource) (.getLocation) (.getPath))
``` |
9,694,759 | I've a got ListBox called lbxUpcommingEvents. When the index is changed the event handler is fired to check for duplicate records. If duplicates are not found, a panel called pnlAction inside a formview is turned on by the way of display style. If dups are found another panel pnlActionCancel is turned on and the oter is tuned off. Basically a toogle effect.
I've tried the visible property, viewstate property, but it does not work and I can't figure it out so once again, I seek wizdom from the collective. Here is my code.
```
protected void lbxUpcommingEvents_OnSelectedIndexChanged(object sender, EventArgs e)
{
pnlEventsSignUp.Visible = true;
string _selectedItemValue = lbxUpcommingEvents.SelectedValue.ToString();
int _eventid = Convert.ToInt32(_selectedItemValue);
Guid _memberId = Guid.Empty;
_memberId = new Guid(Session["myId"].ToString());
// Check for existing signup
EventsMemberSignup _createSingup = new EventsMemberSignup();
dsEventsSingupTableAdapters.MemberEventsTableAdapter da = new dsEventsSingupTableAdapters.MemberEventsTableAdapter();
dsEventsSingup.MemberEventsDataTable dt = da.GetDataForDupCheck(_memberId, _eventid);
if (dt.Rows.Count == 1)
{
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = false;
pnlAction.Style.Add("display","none");
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = true;
pnlActionCancel.Style.Remove("display");
}
else
{
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = false;
pnlActionCancel.Style.Add("display", "none");
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = true;
pnlAction.Style.Remove("display");
}
}
<div id="columnleft">
<a name="content_start" id="content_start"></a>
<div class="leftblock">
<h2>Events Signup</h2>
<p>
</p>
<h3> Upcomming Events</h3>
<p>
<asp:ListBox ID="lbxUpcommingEvents" runat="server" DataSourceID="odsUpcommingEvents"
Rows="6" DataTextField="Title" DataValueField="id" AutoPostBack="true"
Width="206px" OnSelectedIndexChanged="lbxUpcommingEvents_OnSelectedIndexChanged" />
</p>
<h3> Members Attending</h3>
<p>
<asp:DataGrid ID="lboxSignedUpMembers" runat="server" DataSourceID="odsSignedUpMembers"
AutoPostBack="true" AutoGenerateColumns="false" RowStyle-CssClass="gridview" AlternatingRowStyle-CssClass="altbgcolor"
Width="206px" onselectedindexchanged="lboxSignedUpMembers_SelectedIndexChanged" CssClass="gridview"
GridLines="None" BorderStyle="Solid" BorderWidth="1" BorderColor="Black" >
<AlternatingItemStyle BackColor="White" />
<Columns>
<asp:BoundColumn DataField="Name" />
<asp:BoundColumn DataField="Title" />
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label runat="server" ID="lblDate" Text='<%# Eval("StartTime", "{0:d}") %>' />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</p>
</div>
</div>
</td>
<td align="left" >
<!--Start of right column-->
<div id="columnright">
<div class="rightblock">
<asp:Panel ID="pnlEventsSignUpTitle" runat="server" CssClass="actionbuttons">
<h2>Select an Event to Signup</h2>
</asp:Panel>
<asp:Label runat="server" ID="lblNote" ForeColor="#cc0000" Font-Bold="true" />
</div>
<div class="rightblock">
<asp:Panel runat="server" ID="pnlEventsSignUp" visible="false">
<div class="dashedline" ></div>
<asp:FormView ID="fvEventSignUp" runat="server" DataSourceID="ObjectDataSource1"
DataKeyNames="id" Width="100%" >
<ItemTemplate>
<h2>
<asp:HiddenField runat="server" ID="hfEventID" Value='<%# Eval("id") %>' />
<asp:Label Text='<%# Eval("title") %>' runat="server" ID="titleLabel" />
</h2>
<div class="itemdetails">
<br />
location:
<h3>
<asp:Label ID="locationLabel" runat="server" Text='<%# ShowLocationLink(Eval("locationname"),Eval("location")) %>' />
</h3>
<p>
<asp:Label Text='<%# Eval("starttime","{0:D}") %>' runat="server" ID="itemdateLabel" CssClass="GeneralText" />
<asp:Label Text='<%# ShowDuration(Eval("starttime"),Eval("endtime")) %>' runat="server" ID="Label1" CssClass="GeneralText" />
</p>
</div>
<div class="downloadevent">
<a href="#">
<img src="images/icon_download_event.gif" alt="Download this event to your personal calendar"
width="15" height="26" /></a><a href='<%# "events_download.ashx?EventID=" + Convert.ToString(Eval("id")) %>'>Add
this event to your personal calendar</a>
</div>
<Club:ImageThumbnail ID="thumb1" runat="server" ImageSize="Large" PhotoID='<%# Eval("photo") %>' />
<p>
<asp:Label Text='<%# Eval("description") %>' runat="server" ID="descriptionLabel" />
</p>
<div class="dashedline" ></div>
<asp:Panel ID="pnlAction" runat="server" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="Label2" Text="Action<br />Required" Width="80px" Font-Bold="true"
ForeColor="#cc0000" Font-Size="14px" />
</td>
<td>
<img src="images/RedArrow.jpg" alt="Red Arrow Right" />
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCert" Height="30px" Text="Check to Confirm Attendance" /><br />
<asp:CustomValidator runat="server" ID="rfvConfirm"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnkSignUp" runat="server" Text = "I will be attending this event"
OnClick="rlnkSignUp_OnClick" ToolTip="I hereby certify that I am commiting to attending this event."
/>
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel runat="server" ID="pnlActionCancel" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="lblDupSignup" Text="You are alredy signed up for this event" ForeColor="#cc0000" Font-Bold="true" Font-Size="14px" />
</td>
<td>
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCancel" Height="30px" Text="Check to Cancel Attendance" /><br />
<asp:CustomValidator runat="server" ID="CustomValidator1"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnCancel" runat="server" Text="I'm cancelling my participation"
OnClick="rlnCancel_OnClick" />
</td>
</tr>
</table>
</asp:Panel>
</ItemTemplate>
</asp:FormView>
</asp:Panel>
</div>
``` | 2012/03/14 | [
"https://Stackoverflow.com/questions/9694759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/234188/"
] | You could try getting the path from a class defined by Clojure itself, e.g.:
```
(-> clojure.lang.Atom (.getProtectionDomain) (.getCodeSource) (.getLocation))
=> file:/some/path/to/clojure-1.3.0.jar
```
I believe this is technically the running jar file if you are running Clojure scripts or coding at the REPL. | find source files in a jar: [tools.namespace/clojure-sources-in-jar](http://clojure.github.com/tools.namespace/#clojure.tools.namespace/clojure-sources-in-jar) |
9,694,759 | I've a got ListBox called lbxUpcommingEvents. When the index is changed the event handler is fired to check for duplicate records. If duplicates are not found, a panel called pnlAction inside a formview is turned on by the way of display style. If dups are found another panel pnlActionCancel is turned on and the oter is tuned off. Basically a toogle effect.
I've tried the visible property, viewstate property, but it does not work and I can't figure it out so once again, I seek wizdom from the collective. Here is my code.
```
protected void lbxUpcommingEvents_OnSelectedIndexChanged(object sender, EventArgs e)
{
pnlEventsSignUp.Visible = true;
string _selectedItemValue = lbxUpcommingEvents.SelectedValue.ToString();
int _eventid = Convert.ToInt32(_selectedItemValue);
Guid _memberId = Guid.Empty;
_memberId = new Guid(Session["myId"].ToString());
// Check for existing signup
EventsMemberSignup _createSingup = new EventsMemberSignup();
dsEventsSingupTableAdapters.MemberEventsTableAdapter da = new dsEventsSingupTableAdapters.MemberEventsTableAdapter();
dsEventsSingup.MemberEventsDataTable dt = da.GetDataForDupCheck(_memberId, _eventid);
if (dt.Rows.Count == 1)
{
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = false;
pnlAction.Style.Add("display","none");
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = true;
pnlActionCancel.Style.Remove("display");
}
else
{
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = false;
pnlActionCancel.Style.Add("display", "none");
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = true;
pnlAction.Style.Remove("display");
}
}
<div id="columnleft">
<a name="content_start" id="content_start"></a>
<div class="leftblock">
<h2>Events Signup</h2>
<p>
</p>
<h3> Upcomming Events</h3>
<p>
<asp:ListBox ID="lbxUpcommingEvents" runat="server" DataSourceID="odsUpcommingEvents"
Rows="6" DataTextField="Title" DataValueField="id" AutoPostBack="true"
Width="206px" OnSelectedIndexChanged="lbxUpcommingEvents_OnSelectedIndexChanged" />
</p>
<h3> Members Attending</h3>
<p>
<asp:DataGrid ID="lboxSignedUpMembers" runat="server" DataSourceID="odsSignedUpMembers"
AutoPostBack="true" AutoGenerateColumns="false" RowStyle-CssClass="gridview" AlternatingRowStyle-CssClass="altbgcolor"
Width="206px" onselectedindexchanged="lboxSignedUpMembers_SelectedIndexChanged" CssClass="gridview"
GridLines="None" BorderStyle="Solid" BorderWidth="1" BorderColor="Black" >
<AlternatingItemStyle BackColor="White" />
<Columns>
<asp:BoundColumn DataField="Name" />
<asp:BoundColumn DataField="Title" />
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label runat="server" ID="lblDate" Text='<%# Eval("StartTime", "{0:d}") %>' />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</p>
</div>
</div>
</td>
<td align="left" >
<!--Start of right column-->
<div id="columnright">
<div class="rightblock">
<asp:Panel ID="pnlEventsSignUpTitle" runat="server" CssClass="actionbuttons">
<h2>Select an Event to Signup</h2>
</asp:Panel>
<asp:Label runat="server" ID="lblNote" ForeColor="#cc0000" Font-Bold="true" />
</div>
<div class="rightblock">
<asp:Panel runat="server" ID="pnlEventsSignUp" visible="false">
<div class="dashedline" ></div>
<asp:FormView ID="fvEventSignUp" runat="server" DataSourceID="ObjectDataSource1"
DataKeyNames="id" Width="100%" >
<ItemTemplate>
<h2>
<asp:HiddenField runat="server" ID="hfEventID" Value='<%# Eval("id") %>' />
<asp:Label Text='<%# Eval("title") %>' runat="server" ID="titleLabel" />
</h2>
<div class="itemdetails">
<br />
location:
<h3>
<asp:Label ID="locationLabel" runat="server" Text='<%# ShowLocationLink(Eval("locationname"),Eval("location")) %>' />
</h3>
<p>
<asp:Label Text='<%# Eval("starttime","{0:D}") %>' runat="server" ID="itemdateLabel" CssClass="GeneralText" />
<asp:Label Text='<%# ShowDuration(Eval("starttime"),Eval("endtime")) %>' runat="server" ID="Label1" CssClass="GeneralText" />
</p>
</div>
<div class="downloadevent">
<a href="#">
<img src="images/icon_download_event.gif" alt="Download this event to your personal calendar"
width="15" height="26" /></a><a href='<%# "events_download.ashx?EventID=" + Convert.ToString(Eval("id")) %>'>Add
this event to your personal calendar</a>
</div>
<Club:ImageThumbnail ID="thumb1" runat="server" ImageSize="Large" PhotoID='<%# Eval("photo") %>' />
<p>
<asp:Label Text='<%# Eval("description") %>' runat="server" ID="descriptionLabel" />
</p>
<div class="dashedline" ></div>
<asp:Panel ID="pnlAction" runat="server" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="Label2" Text="Action<br />Required" Width="80px" Font-Bold="true"
ForeColor="#cc0000" Font-Size="14px" />
</td>
<td>
<img src="images/RedArrow.jpg" alt="Red Arrow Right" />
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCert" Height="30px" Text="Check to Confirm Attendance" /><br />
<asp:CustomValidator runat="server" ID="rfvConfirm"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnkSignUp" runat="server" Text = "I will be attending this event"
OnClick="rlnkSignUp_OnClick" ToolTip="I hereby certify that I am commiting to attending this event."
/>
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel runat="server" ID="pnlActionCancel" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="lblDupSignup" Text="You are alredy signed up for this event" ForeColor="#cc0000" Font-Bold="true" Font-Size="14px" />
</td>
<td>
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCancel" Height="30px" Text="Check to Cancel Attendance" /><br />
<asp:CustomValidator runat="server" ID="CustomValidator1"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnCancel" runat="server" Text="I'm cancelling my participation"
OnClick="rlnCancel_OnClick" />
</td>
</tr>
</table>
</asp:Panel>
</ItemTemplate>
</asp:FormView>
</asp:Panel>
</div>
``` | 2012/03/14 | [
"https://Stackoverflow.com/questions/9694759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/234188/"
] | The idea of classpath is to hide where classes come from. You may have classes with the same name loaded from different classloaders, you may have the same class in multiple jars and rely on classpath ordering to choose the correct one.
Why do you want to know? If it's for any other reason than debug/logging purposes you are on dangerous ground and should tread carefully.
In fact it's perfectly reasonable for classes to have no jar file. This can happen in java for any runtime generated classes (think proxies).
In clojure a simple example would be as shown in the repl session below... You'll see @mikera's suggestion works fine for `clojure.lang.Atom` which is a built in class. But when you use a `deftype` to create your own type, clojure generates a class and it has no location...
```
user> (prn (-> clojure.lang.Atom
(.getProtectionDomain)
(.getCodeSource)
(.getLocation)))
#<URL file:/workspace/clj-scratch/lib/clojure-1.3.0.jar>
nil
user> (deftype Foo [])
user.Foo
user> (prn (-> (Foo.)
(.getClass)
(.getProtectionDomain)
(.getCodeSource)
(.getLocation)))
nil
nil
user>
``` | find source files in a jar: [tools.namespace/clojure-sources-in-jar](http://clojure.github.com/tools.namespace/#clojure.tools.namespace/clojure-sources-in-jar) |
9,694,759 | I've a got ListBox called lbxUpcommingEvents. When the index is changed the event handler is fired to check for duplicate records. If duplicates are not found, a panel called pnlAction inside a formview is turned on by the way of display style. If dups are found another panel pnlActionCancel is turned on and the oter is tuned off. Basically a toogle effect.
I've tried the visible property, viewstate property, but it does not work and I can't figure it out so once again, I seek wizdom from the collective. Here is my code.
```
protected void lbxUpcommingEvents_OnSelectedIndexChanged(object sender, EventArgs e)
{
pnlEventsSignUp.Visible = true;
string _selectedItemValue = lbxUpcommingEvents.SelectedValue.ToString();
int _eventid = Convert.ToInt32(_selectedItemValue);
Guid _memberId = Guid.Empty;
_memberId = new Guid(Session["myId"].ToString());
// Check for existing signup
EventsMemberSignup _createSingup = new EventsMemberSignup();
dsEventsSingupTableAdapters.MemberEventsTableAdapter da = new dsEventsSingupTableAdapters.MemberEventsTableAdapter();
dsEventsSingup.MemberEventsDataTable dt = da.GetDataForDupCheck(_memberId, _eventid);
if (dt.Rows.Count == 1)
{
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = false;
pnlAction.Style.Add("display","none");
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = true;
pnlActionCancel.Style.Remove("display");
}
else
{
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = false;
pnlActionCancel.Style.Add("display", "none");
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = true;
pnlAction.Style.Remove("display");
}
}
<div id="columnleft">
<a name="content_start" id="content_start"></a>
<div class="leftblock">
<h2>Events Signup</h2>
<p>
</p>
<h3> Upcomming Events</h3>
<p>
<asp:ListBox ID="lbxUpcommingEvents" runat="server" DataSourceID="odsUpcommingEvents"
Rows="6" DataTextField="Title" DataValueField="id" AutoPostBack="true"
Width="206px" OnSelectedIndexChanged="lbxUpcommingEvents_OnSelectedIndexChanged" />
</p>
<h3> Members Attending</h3>
<p>
<asp:DataGrid ID="lboxSignedUpMembers" runat="server" DataSourceID="odsSignedUpMembers"
AutoPostBack="true" AutoGenerateColumns="false" RowStyle-CssClass="gridview" AlternatingRowStyle-CssClass="altbgcolor"
Width="206px" onselectedindexchanged="lboxSignedUpMembers_SelectedIndexChanged" CssClass="gridview"
GridLines="None" BorderStyle="Solid" BorderWidth="1" BorderColor="Black" >
<AlternatingItemStyle BackColor="White" />
<Columns>
<asp:BoundColumn DataField="Name" />
<asp:BoundColumn DataField="Title" />
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label runat="server" ID="lblDate" Text='<%# Eval("StartTime", "{0:d}") %>' />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</p>
</div>
</div>
</td>
<td align="left" >
<!--Start of right column-->
<div id="columnright">
<div class="rightblock">
<asp:Panel ID="pnlEventsSignUpTitle" runat="server" CssClass="actionbuttons">
<h2>Select an Event to Signup</h2>
</asp:Panel>
<asp:Label runat="server" ID="lblNote" ForeColor="#cc0000" Font-Bold="true" />
</div>
<div class="rightblock">
<asp:Panel runat="server" ID="pnlEventsSignUp" visible="false">
<div class="dashedline" ></div>
<asp:FormView ID="fvEventSignUp" runat="server" DataSourceID="ObjectDataSource1"
DataKeyNames="id" Width="100%" >
<ItemTemplate>
<h2>
<asp:HiddenField runat="server" ID="hfEventID" Value='<%# Eval("id") %>' />
<asp:Label Text='<%# Eval("title") %>' runat="server" ID="titleLabel" />
</h2>
<div class="itemdetails">
<br />
location:
<h3>
<asp:Label ID="locationLabel" runat="server" Text='<%# ShowLocationLink(Eval("locationname"),Eval("location")) %>' />
</h3>
<p>
<asp:Label Text='<%# Eval("starttime","{0:D}") %>' runat="server" ID="itemdateLabel" CssClass="GeneralText" />
<asp:Label Text='<%# ShowDuration(Eval("starttime"),Eval("endtime")) %>' runat="server" ID="Label1" CssClass="GeneralText" />
</p>
</div>
<div class="downloadevent">
<a href="#">
<img src="images/icon_download_event.gif" alt="Download this event to your personal calendar"
width="15" height="26" /></a><a href='<%# "events_download.ashx?EventID=" + Convert.ToString(Eval("id")) %>'>Add
this event to your personal calendar</a>
</div>
<Club:ImageThumbnail ID="thumb1" runat="server" ImageSize="Large" PhotoID='<%# Eval("photo") %>' />
<p>
<asp:Label Text='<%# Eval("description") %>' runat="server" ID="descriptionLabel" />
</p>
<div class="dashedline" ></div>
<asp:Panel ID="pnlAction" runat="server" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="Label2" Text="Action<br />Required" Width="80px" Font-Bold="true"
ForeColor="#cc0000" Font-Size="14px" />
</td>
<td>
<img src="images/RedArrow.jpg" alt="Red Arrow Right" />
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCert" Height="30px" Text="Check to Confirm Attendance" /><br />
<asp:CustomValidator runat="server" ID="rfvConfirm"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnkSignUp" runat="server" Text = "I will be attending this event"
OnClick="rlnkSignUp_OnClick" ToolTip="I hereby certify that I am commiting to attending this event."
/>
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel runat="server" ID="pnlActionCancel" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="lblDupSignup" Text="You are alredy signed up for this event" ForeColor="#cc0000" Font-Bold="true" Font-Size="14px" />
</td>
<td>
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCancel" Height="30px" Text="Check to Cancel Attendance" /><br />
<asp:CustomValidator runat="server" ID="CustomValidator1"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnCancel" runat="server" Text="I'm cancelling my participation"
OnClick="rlnCancel_OnClick" />
</td>
</tr>
</table>
</asp:Panel>
</ItemTemplate>
</asp:FormView>
</asp:Panel>
</div>
``` | 2012/03/14 | [
"https://Stackoverflow.com/questions/9694759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/234188/"
] | By default the name of your class is the name of your AOT-compiled namespace (that's what gen-class is for), so you can simply use the namespace's class.
```
(ns foo.core
(:gen-class))
(defn this-jar
"utility function to get the name of jar in which this function is invoked"
[& [ns]]
;; The .toURI step is vital to avoid problems with special characters,
;; including spaces and pluses.
;; Source: https://stackoverflow.com/q/320542/7012#comment18478290_320595
(-> (or ns (class *ns*))
.getProtectionDomain .getCodeSource .getLocation .toURI .getPath))
(defn -main [& _]
(println (this-jar foo.core)))
```
Result of running:
```
$ java -cp foo-0.1.0-SNAPSHOT-standalone.jar foo.core
/home/rlevy/prj/foo/target/foo-0.1.0-SNAPSHOT-standalone.jar
``` | You could try getting the path from a class defined by Clojure itself, e.g.:
```
(-> clojure.lang.Atom (.getProtectionDomain) (.getCodeSource) (.getLocation))
=> file:/some/path/to/clojure-1.3.0.jar
```
I believe this is technically the running jar file if you are running Clojure scripts or coding at the REPL. |
9,694,759 | I've a got ListBox called lbxUpcommingEvents. When the index is changed the event handler is fired to check for duplicate records. If duplicates are not found, a panel called pnlAction inside a formview is turned on by the way of display style. If dups are found another panel pnlActionCancel is turned on and the oter is tuned off. Basically a toogle effect.
I've tried the visible property, viewstate property, but it does not work and I can't figure it out so once again, I seek wizdom from the collective. Here is my code.
```
protected void lbxUpcommingEvents_OnSelectedIndexChanged(object sender, EventArgs e)
{
pnlEventsSignUp.Visible = true;
string _selectedItemValue = lbxUpcommingEvents.SelectedValue.ToString();
int _eventid = Convert.ToInt32(_selectedItemValue);
Guid _memberId = Guid.Empty;
_memberId = new Guid(Session["myId"].ToString());
// Check for existing signup
EventsMemberSignup _createSingup = new EventsMemberSignup();
dsEventsSingupTableAdapters.MemberEventsTableAdapter da = new dsEventsSingupTableAdapters.MemberEventsTableAdapter();
dsEventsSingup.MemberEventsDataTable dt = da.GetDataForDupCheck(_memberId, _eventid);
if (dt.Rows.Count == 1)
{
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = false;
pnlAction.Style.Add("display","none");
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = true;
pnlActionCancel.Style.Remove("display");
}
else
{
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = false;
pnlActionCancel.Style.Add("display", "none");
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = true;
pnlAction.Style.Remove("display");
}
}
<div id="columnleft">
<a name="content_start" id="content_start"></a>
<div class="leftblock">
<h2>Events Signup</h2>
<p>
</p>
<h3> Upcomming Events</h3>
<p>
<asp:ListBox ID="lbxUpcommingEvents" runat="server" DataSourceID="odsUpcommingEvents"
Rows="6" DataTextField="Title" DataValueField="id" AutoPostBack="true"
Width="206px" OnSelectedIndexChanged="lbxUpcommingEvents_OnSelectedIndexChanged" />
</p>
<h3> Members Attending</h3>
<p>
<asp:DataGrid ID="lboxSignedUpMembers" runat="server" DataSourceID="odsSignedUpMembers"
AutoPostBack="true" AutoGenerateColumns="false" RowStyle-CssClass="gridview" AlternatingRowStyle-CssClass="altbgcolor"
Width="206px" onselectedindexchanged="lboxSignedUpMembers_SelectedIndexChanged" CssClass="gridview"
GridLines="None" BorderStyle="Solid" BorderWidth="1" BorderColor="Black" >
<AlternatingItemStyle BackColor="White" />
<Columns>
<asp:BoundColumn DataField="Name" />
<asp:BoundColumn DataField="Title" />
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label runat="server" ID="lblDate" Text='<%# Eval("StartTime", "{0:d}") %>' />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</p>
</div>
</div>
</td>
<td align="left" >
<!--Start of right column-->
<div id="columnright">
<div class="rightblock">
<asp:Panel ID="pnlEventsSignUpTitle" runat="server" CssClass="actionbuttons">
<h2>Select an Event to Signup</h2>
</asp:Panel>
<asp:Label runat="server" ID="lblNote" ForeColor="#cc0000" Font-Bold="true" />
</div>
<div class="rightblock">
<asp:Panel runat="server" ID="pnlEventsSignUp" visible="false">
<div class="dashedline" ></div>
<asp:FormView ID="fvEventSignUp" runat="server" DataSourceID="ObjectDataSource1"
DataKeyNames="id" Width="100%" >
<ItemTemplate>
<h2>
<asp:HiddenField runat="server" ID="hfEventID" Value='<%# Eval("id") %>' />
<asp:Label Text='<%# Eval("title") %>' runat="server" ID="titleLabel" />
</h2>
<div class="itemdetails">
<br />
location:
<h3>
<asp:Label ID="locationLabel" runat="server" Text='<%# ShowLocationLink(Eval("locationname"),Eval("location")) %>' />
</h3>
<p>
<asp:Label Text='<%# Eval("starttime","{0:D}") %>' runat="server" ID="itemdateLabel" CssClass="GeneralText" />
<asp:Label Text='<%# ShowDuration(Eval("starttime"),Eval("endtime")) %>' runat="server" ID="Label1" CssClass="GeneralText" />
</p>
</div>
<div class="downloadevent">
<a href="#">
<img src="images/icon_download_event.gif" alt="Download this event to your personal calendar"
width="15" height="26" /></a><a href='<%# "events_download.ashx?EventID=" + Convert.ToString(Eval("id")) %>'>Add
this event to your personal calendar</a>
</div>
<Club:ImageThumbnail ID="thumb1" runat="server" ImageSize="Large" PhotoID='<%# Eval("photo") %>' />
<p>
<asp:Label Text='<%# Eval("description") %>' runat="server" ID="descriptionLabel" />
</p>
<div class="dashedline" ></div>
<asp:Panel ID="pnlAction" runat="server" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="Label2" Text="Action<br />Required" Width="80px" Font-Bold="true"
ForeColor="#cc0000" Font-Size="14px" />
</td>
<td>
<img src="images/RedArrow.jpg" alt="Red Arrow Right" />
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCert" Height="30px" Text="Check to Confirm Attendance" /><br />
<asp:CustomValidator runat="server" ID="rfvConfirm"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnkSignUp" runat="server" Text = "I will be attending this event"
OnClick="rlnkSignUp_OnClick" ToolTip="I hereby certify that I am commiting to attending this event."
/>
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel runat="server" ID="pnlActionCancel" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="lblDupSignup" Text="You are alredy signed up for this event" ForeColor="#cc0000" Font-Bold="true" Font-Size="14px" />
</td>
<td>
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCancel" Height="30px" Text="Check to Cancel Attendance" /><br />
<asp:CustomValidator runat="server" ID="CustomValidator1"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnCancel" runat="server" Text="I'm cancelling my participation"
OnClick="rlnCancel_OnClick" />
</td>
</tr>
</table>
</asp:Panel>
</ItemTemplate>
</asp:FormView>
</asp:Panel>
</div>
``` | 2012/03/14 | [
"https://Stackoverflow.com/questions/9694759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/234188/"
] | I haven't tried this, but it seems like all you need is a class instance. So for example can you not do this:
```
(-> (new Object) (.getClass) (.getProtectionDomain) (.getCodeSource) (.getLocation) (.getPath))
``` | find source files in a jar: [tools.namespace/clojure-sources-in-jar](http://clojure.github.com/tools.namespace/#clojure.tools.namespace/clojure-sources-in-jar) |
9,694,759 | I've a got ListBox called lbxUpcommingEvents. When the index is changed the event handler is fired to check for duplicate records. If duplicates are not found, a panel called pnlAction inside a formview is turned on by the way of display style. If dups are found another panel pnlActionCancel is turned on and the oter is tuned off. Basically a toogle effect.
I've tried the visible property, viewstate property, but it does not work and I can't figure it out so once again, I seek wizdom from the collective. Here is my code.
```
protected void lbxUpcommingEvents_OnSelectedIndexChanged(object sender, EventArgs e)
{
pnlEventsSignUp.Visible = true;
string _selectedItemValue = lbxUpcommingEvents.SelectedValue.ToString();
int _eventid = Convert.ToInt32(_selectedItemValue);
Guid _memberId = Guid.Empty;
_memberId = new Guid(Session["myId"].ToString());
// Check for existing signup
EventsMemberSignup _createSingup = new EventsMemberSignup();
dsEventsSingupTableAdapters.MemberEventsTableAdapter da = new dsEventsSingupTableAdapters.MemberEventsTableAdapter();
dsEventsSingup.MemberEventsDataTable dt = da.GetDataForDupCheck(_memberId, _eventid);
if (dt.Rows.Count == 1)
{
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = false;
pnlAction.Style.Add("display","none");
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = true;
pnlActionCancel.Style.Remove("display");
}
else
{
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = false;
pnlActionCancel.Style.Add("display", "none");
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = true;
pnlAction.Style.Remove("display");
}
}
<div id="columnleft">
<a name="content_start" id="content_start"></a>
<div class="leftblock">
<h2>Events Signup</h2>
<p>
</p>
<h3> Upcomming Events</h3>
<p>
<asp:ListBox ID="lbxUpcommingEvents" runat="server" DataSourceID="odsUpcommingEvents"
Rows="6" DataTextField="Title" DataValueField="id" AutoPostBack="true"
Width="206px" OnSelectedIndexChanged="lbxUpcommingEvents_OnSelectedIndexChanged" />
</p>
<h3> Members Attending</h3>
<p>
<asp:DataGrid ID="lboxSignedUpMembers" runat="server" DataSourceID="odsSignedUpMembers"
AutoPostBack="true" AutoGenerateColumns="false" RowStyle-CssClass="gridview" AlternatingRowStyle-CssClass="altbgcolor"
Width="206px" onselectedindexchanged="lboxSignedUpMembers_SelectedIndexChanged" CssClass="gridview"
GridLines="None" BorderStyle="Solid" BorderWidth="1" BorderColor="Black" >
<AlternatingItemStyle BackColor="White" />
<Columns>
<asp:BoundColumn DataField="Name" />
<asp:BoundColumn DataField="Title" />
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label runat="server" ID="lblDate" Text='<%# Eval("StartTime", "{0:d}") %>' />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</p>
</div>
</div>
</td>
<td align="left" >
<!--Start of right column-->
<div id="columnright">
<div class="rightblock">
<asp:Panel ID="pnlEventsSignUpTitle" runat="server" CssClass="actionbuttons">
<h2>Select an Event to Signup</h2>
</asp:Panel>
<asp:Label runat="server" ID="lblNote" ForeColor="#cc0000" Font-Bold="true" />
</div>
<div class="rightblock">
<asp:Panel runat="server" ID="pnlEventsSignUp" visible="false">
<div class="dashedline" ></div>
<asp:FormView ID="fvEventSignUp" runat="server" DataSourceID="ObjectDataSource1"
DataKeyNames="id" Width="100%" >
<ItemTemplate>
<h2>
<asp:HiddenField runat="server" ID="hfEventID" Value='<%# Eval("id") %>' />
<asp:Label Text='<%# Eval("title") %>' runat="server" ID="titleLabel" />
</h2>
<div class="itemdetails">
<br />
location:
<h3>
<asp:Label ID="locationLabel" runat="server" Text='<%# ShowLocationLink(Eval("locationname"),Eval("location")) %>' />
</h3>
<p>
<asp:Label Text='<%# Eval("starttime","{0:D}") %>' runat="server" ID="itemdateLabel" CssClass="GeneralText" />
<asp:Label Text='<%# ShowDuration(Eval("starttime"),Eval("endtime")) %>' runat="server" ID="Label1" CssClass="GeneralText" />
</p>
</div>
<div class="downloadevent">
<a href="#">
<img src="images/icon_download_event.gif" alt="Download this event to your personal calendar"
width="15" height="26" /></a><a href='<%# "events_download.ashx?EventID=" + Convert.ToString(Eval("id")) %>'>Add
this event to your personal calendar</a>
</div>
<Club:ImageThumbnail ID="thumb1" runat="server" ImageSize="Large" PhotoID='<%# Eval("photo") %>' />
<p>
<asp:Label Text='<%# Eval("description") %>' runat="server" ID="descriptionLabel" />
</p>
<div class="dashedline" ></div>
<asp:Panel ID="pnlAction" runat="server" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="Label2" Text="Action<br />Required" Width="80px" Font-Bold="true"
ForeColor="#cc0000" Font-Size="14px" />
</td>
<td>
<img src="images/RedArrow.jpg" alt="Red Arrow Right" />
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCert" Height="30px" Text="Check to Confirm Attendance" /><br />
<asp:CustomValidator runat="server" ID="rfvConfirm"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnkSignUp" runat="server" Text = "I will be attending this event"
OnClick="rlnkSignUp_OnClick" ToolTip="I hereby certify that I am commiting to attending this event."
/>
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel runat="server" ID="pnlActionCancel" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="lblDupSignup" Text="You are alredy signed up for this event" ForeColor="#cc0000" Font-Bold="true" Font-Size="14px" />
</td>
<td>
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCancel" Height="30px" Text="Check to Cancel Attendance" /><br />
<asp:CustomValidator runat="server" ID="CustomValidator1"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnCancel" runat="server" Text="I'm cancelling my participation"
OnClick="rlnCancel_OnClick" />
</td>
</tr>
</table>
</asp:Panel>
</ItemTemplate>
</asp:FormView>
</asp:Panel>
</div>
``` | 2012/03/14 | [
"https://Stackoverflow.com/questions/9694759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/234188/"
] | The idea of classpath is to hide where classes come from. You may have classes with the same name loaded from different classloaders, you may have the same class in multiple jars and rely on classpath ordering to choose the correct one.
Why do you want to know? If it's for any other reason than debug/logging purposes you are on dangerous ground and should tread carefully.
In fact it's perfectly reasonable for classes to have no jar file. This can happen in java for any runtime generated classes (think proxies).
In clojure a simple example would be as shown in the repl session below... You'll see @mikera's suggestion works fine for `clojure.lang.Atom` which is a built in class. But when you use a `deftype` to create your own type, clojure generates a class and it has no location...
```
user> (prn (-> clojure.lang.Atom
(.getProtectionDomain)
(.getCodeSource)
(.getLocation)))
#<URL file:/workspace/clj-scratch/lib/clojure-1.3.0.jar>
nil
user> (deftype Foo [])
user.Foo
user> (prn (-> (Foo.)
(.getClass)
(.getProtectionDomain)
(.getCodeSource)
(.getLocation)))
nil
nil
user>
``` | ```
(defn this-jar
"utility function to get the name of jar in which this function is invoked"
[& [ns]]
(-> (or ns (class *ns*))
.getProtectionDomain .getCodeSource .getLocation .toURI .getPath))
```
Note that it's crucial to call `.toURI` to avoid problems with paths that have spaces as described in the equivalent Java question: [How to get the path of a running JAR file?](https://stackoverflow.com/questions/320542/how-to-get-the-path-of-a-running-jar-file). |
74,268 | I have a puncture on my MTB tire. It says tubeless ready, but how do I know if it has a tube in it? Rims are sealed, it is a new bike around 6 months old. | 2021/01/02 | [
"https://bicycles.stackexchange.com/questions/74268",
"https://bicycles.stackexchange.com",
"https://bicycles.stackexchange.com/users/54475/"
] | First you may check whether sealant fluid came out of the punctured tyre. It could indicate a tubeless tyre, though it is not always the case. The sure way to tell is by checking the valve.
If your valve is held by a thin screw-on collar that you can screw off with two finger or no collar at all and that you can easily push back into the rim-bed your tyres have inner tubes. Same if your valves have no threaded shaft,
Tubeless valves will look like those in the picture.[](https://i.stack.imgur.com/g5rUn.jpg)
They are tightly screwed on and require tools for removal. And as you also see in the picture, the core, the silvery bit comes out. Although this my also be be the case with traditional tubes but not always. | The best way is to simply pop the tyre off the rim at some place (you do not have to take off the entire tyre) and see if there is a tube underneath. To do this just take the wheel/tyre in your hands (as if holding your hands on a car steering wheel - you do not have to take the wheel off the bike) and squeeze the tyre sidewall with your thumbs until it detaches from the rim.
If you don't want to do this first, you can try unscrewing the little nut holding the valve snug to the rim and pushing the valve a little into the rim (some valves are not threaded and do not have this nut, in which case you can tell right away that you have a tube, and not tubeless). You'll either be able to see through the hole whether the valve is attached to a tube (in which case, obviously, you have a tube) or not (in which case you have tubeless), or feel the same thing (if it is attached to a tube it will give you a little resistance while pushing it in and wiggling it, if it is not you will be able to push and wiggle it with no resistance). |
74,268 | I have a puncture on my MTB tire. It says tubeless ready, but how do I know if it has a tube in it? Rims are sealed, it is a new bike around 6 months old. | 2021/01/02 | [
"https://bicycles.stackexchange.com/questions/74268",
"https://bicycles.stackexchange.com",
"https://bicycles.stackexchange.com/users/54475/"
] | In general bikes come from the factory with tubes fitted even if tubeless ready. Easiest way to find out is pop the wheel off, shake it about and listen for sloshy sounds which will be the sealant.
“Tubeless ready” tends to mean that the rim has tubeless compatible rim tape and a suitable rim profile combined with tubeless compatible tyres so when you’re ready you can upgrade to tubeless valves and sealant. You may have even been supplied with the valves described by Carel with the bike.
Upgrading to true tubeless is a mixed bag but in balance is worth the bother. To do this at home you’ll need to spend money on:
* Sealant, needs to be replaced/topped up periodically.
* Tubeless valves if you don’t have them.
* A decent high volume floor pump.
The process is described in many places online but is reasonably simple and quick and nothing to fear.
In return you’ll practically never get punctures that deflate the tyre and the ability to run lower tyre pressures for more traction and comfort. In a emergency you can always go back to using a tube, it’s not a one way journey. | The best way is to simply pop the tyre off the rim at some place (you do not have to take off the entire tyre) and see if there is a tube underneath. To do this just take the wheel/tyre in your hands (as if holding your hands on a car steering wheel - you do not have to take the wheel off the bike) and squeeze the tyre sidewall with your thumbs until it detaches from the rim.
If you don't want to do this first, you can try unscrewing the little nut holding the valve snug to the rim and pushing the valve a little into the rim (some valves are not threaded and do not have this nut, in which case you can tell right away that you have a tube, and not tubeless). You'll either be able to see through the hole whether the valve is attached to a tube (in which case, obviously, you have a tube) or not (in which case you have tubeless), or feel the same thing (if it is attached to a tube it will give you a little resistance while pushing it in and wiggling it, if it is not you will be able to push and wiggle it with no resistance). |
70,129 | (There's a bunch here, sorry. I've used bold text to outline the flow of the main content of the question.)
Basically, I'm transcribing the rhythms of a song, mostly in a 6/4 & 4/4 feel, though every now & then the music deviates into a small series of "glitchy syncopations," to put it one way. in the midst of all this, **there's a single bar of 5/8 containing a normal (simple) quarter-note triplet (3 quarters in place of 2) followed by a single articulated 8th note. this got me wondering: if I used such rhythms in a composition which remained in 5/8 time extensively, and wanted to also incorporate *a triplet which spans the entire 5/8 bar* (a slightly more complex tuplet) how would I notate that?**
The answer seemed simple at first to me: *use 3 beamed eighth notes, spaced appropriately, topped with the ratio notation: 3:5. this indicates that there are 3 eighth notes in place of 5*? correct?? (see image below)
**However,** when this figure is compared to the "simple" quarter note triplet mentioned before, there's a possible discrepancy in clarity concerning speed / duration: aside from the differences between note spacing of the components within each triplet, the 3:5 triplet in bar 2, below, (which SHOULD represent a slower/longer triplet than the one in bar 1) suggests that it is faster than the standard quarter-note triplet. which is fully untrue, and seems a tad too misleading for my liking.
[](https://i.stack.imgur.com/Nu6nJ.jpg)
**Am I missing something crucial? like... if the meter is odd / imperfect / irregular, are the rules for notating tuplets altered? in other words, is my notation of the first, simple quarter-note triplet wrong? and is that notation (three quarters with a bracket) better suited for the triplet which spans the entire 5/8 measure?**
Off the top of my head I know of one source: Alexander Scriabin's Prelude in C (Op. 11 No.1): the meter is 2/2, but the general feel is a subdivision of quintuple eighth-note groupings, accents often notated and implied on the 1st and 3rd notes of each quintuplet. The composer never uses tuplet symbols to indicate that 5 eighths take the place of 4 (at least in none of the scores I've seen) but the music makes the subdivision quite clear.
Anyways, in a few places the left hand plays a figure of 3 quarter notes, again, never notated with any tuplet signs, but implied to be a triplet pitted against the quintuplet: 3 quarters in place of 5 eighths (aka a normal quarter-note triplet pitted against the standard pulse of the time sig: 2/2), rather than a quarter note triplet taking the place of 4 out of 5 of the eighth-notes from the quintuplet... or any other rhythm. the distinction between these triplets may seem slight but I believe it makes a difference which one is observed.
[](https://i.stack.imgur.com/Cniu9.jpg)
I realize since the time signature is 2/2 and not 5/8, there may be a difference between this example and my hypothetical, but if my assumption about Scriabin's triplets here being 3:5 is correct, then my very first posited notation of the "simple" quarternote triplet in a 5/8 context may be fallacious, and I should be treating said "simple" tuplet with a more special approach. maybe the following:
[](https://i.stack.imgur.com/3SJ2B.jpg)
Using the 8th-note triplet, explicitly labeled with a "3:4" ratio (above left), instead of the standard quarter note triplet notation, seems a clearer solution. its result is the same as (quarters)3:2 but leaves room for the usage of the 3 quarter grouping to represent triplet which fills the duration of a 5/8 bar, like my assumption of Scriabin. (above, right
One more possible notation:
[](https://i.stack.imgur.com/GBrGp.jpg)
**Is this just one of those kinks in our system of notation? or is there a ~standard protocol based on precedence in sources?** If you've read all this thanks so much. | 2018/04/19 | [
"https://music.stackexchange.com/questions/70129",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/49602/"
] | Wow, very interesting question, and your opening example really shows the problem very well!
If I understand your entire question correctly, *then I recommend not viewing the Scriabin as 3:5*.
The left hand triplets are really 3:2, in the sense that you are playing 3 quarter notes in the span or 2 notated quarter notes. The 3:5 *is the relationship between the hands*, not the relationship to the notated meter, which is an important distinction to make. This is especially important in a piece like this Scriabin prelude, where the right hand is off doing something unexpected: a 5:4 relationship.
In other words, you want to notate it to show the relationship between what's being played and the notated subdivisions. Reading the Scriabin as 3:5 would be incorrect, because that 3:5 is the relationship among the hands themselves.
This is why the second measure of your second example is not ideal, because that quarter-note triplet indicates "3 quarter notes to be played in the span of 2 quarter notes (=4 eighth notes)," which leaves one eighth note unaccounted for in that measure.
I personally prefer the bottom example, because it leaves no doubt as to the notated intent. (But I don't have a source suggesting that this way is optimal.) This notation might catch a sight reader off guard, but based on these rhythms, I doubt sight reading will be a priority :-) | I'm not sure I entirely agree with Richard's answer. Certainly standard notation is to indicate a triplet using notes which would "normally" take longer than the triplet, e.g. three eighth notes for a triplet covering a quarter note.
Your stated problem occurs because 5/8 time can only be "contracted" in this way by using quarter notes. So if I (and I have 50 years' experience with reading oddball scores) were to see in 5/8 time, a quarter-note triplet followed with an eighth rest, I would certainly see the triplet as covering 4 eighth notes. If I see just a quarter-note triplet, I would blink a couple times and make the three notes cover all five eighth notes.
Definitely do **not** write the full-measure triplet with eighth notes, as that violates the "contraction" rule.
Yes, this means the quarter-note triplet means different things depending on whether there's an eighth rest in the same measure, but that's just the way it is. |
70,129 | (There's a bunch here, sorry. I've used bold text to outline the flow of the main content of the question.)
Basically, I'm transcribing the rhythms of a song, mostly in a 6/4 & 4/4 feel, though every now & then the music deviates into a small series of "glitchy syncopations," to put it one way. in the midst of all this, **there's a single bar of 5/8 containing a normal (simple) quarter-note triplet (3 quarters in place of 2) followed by a single articulated 8th note. this got me wondering: if I used such rhythms in a composition which remained in 5/8 time extensively, and wanted to also incorporate *a triplet which spans the entire 5/8 bar* (a slightly more complex tuplet) how would I notate that?**
The answer seemed simple at first to me: *use 3 beamed eighth notes, spaced appropriately, topped with the ratio notation: 3:5. this indicates that there are 3 eighth notes in place of 5*? correct?? (see image below)
**However,** when this figure is compared to the "simple" quarter note triplet mentioned before, there's a possible discrepancy in clarity concerning speed / duration: aside from the differences between note spacing of the components within each triplet, the 3:5 triplet in bar 2, below, (which SHOULD represent a slower/longer triplet than the one in bar 1) suggests that it is faster than the standard quarter-note triplet. which is fully untrue, and seems a tad too misleading for my liking.
[](https://i.stack.imgur.com/Nu6nJ.jpg)
**Am I missing something crucial? like... if the meter is odd / imperfect / irregular, are the rules for notating tuplets altered? in other words, is my notation of the first, simple quarter-note triplet wrong? and is that notation (three quarters with a bracket) better suited for the triplet which spans the entire 5/8 measure?**
Off the top of my head I know of one source: Alexander Scriabin's Prelude in C (Op. 11 No.1): the meter is 2/2, but the general feel is a subdivision of quintuple eighth-note groupings, accents often notated and implied on the 1st and 3rd notes of each quintuplet. The composer never uses tuplet symbols to indicate that 5 eighths take the place of 4 (at least in none of the scores I've seen) but the music makes the subdivision quite clear.
Anyways, in a few places the left hand plays a figure of 3 quarter notes, again, never notated with any tuplet signs, but implied to be a triplet pitted against the quintuplet: 3 quarters in place of 5 eighths (aka a normal quarter-note triplet pitted against the standard pulse of the time sig: 2/2), rather than a quarter note triplet taking the place of 4 out of 5 of the eighth-notes from the quintuplet... or any other rhythm. the distinction between these triplets may seem slight but I believe it makes a difference which one is observed.
[](https://i.stack.imgur.com/Cniu9.jpg)
I realize since the time signature is 2/2 and not 5/8, there may be a difference between this example and my hypothetical, but if my assumption about Scriabin's triplets here being 3:5 is correct, then my very first posited notation of the "simple" quarternote triplet in a 5/8 context may be fallacious, and I should be treating said "simple" tuplet with a more special approach. maybe the following:
[](https://i.stack.imgur.com/3SJ2B.jpg)
Using the 8th-note triplet, explicitly labeled with a "3:4" ratio (above left), instead of the standard quarter note triplet notation, seems a clearer solution. its result is the same as (quarters)3:2 but leaves room for the usage of the 3 quarter grouping to represent triplet which fills the duration of a 5/8 bar, like my assumption of Scriabin. (above, right
One more possible notation:
[](https://i.stack.imgur.com/GBrGp.jpg)
**Is this just one of those kinks in our system of notation? or is there a ~standard protocol based on precedence in sources?** If you've read all this thanks so much. | 2018/04/19 | [
"https://music.stackexchange.com/questions/70129",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/49602/"
] | Wow, very interesting question, and your opening example really shows the problem very well!
If I understand your entire question correctly, *then I recommend not viewing the Scriabin as 3:5*.
The left hand triplets are really 3:2, in the sense that you are playing 3 quarter notes in the span or 2 notated quarter notes. The 3:5 *is the relationship between the hands*, not the relationship to the notated meter, which is an important distinction to make. This is especially important in a piece like this Scriabin prelude, where the right hand is off doing something unexpected: a 5:4 relationship.
In other words, you want to notate it to show the relationship between what's being played and the notated subdivisions. Reading the Scriabin as 3:5 would be incorrect, because that 3:5 is the relationship among the hands themselves.
This is why the second measure of your second example is not ideal, because that quarter-note triplet indicates "3 quarter notes to be played in the span of 2 quarter notes (=4 eighth notes)," which leaves one eighth note unaccounted for in that measure.
I personally prefer the bottom example, because it leaves no doubt as to the notated intent. (But I don't have a source suggesting that this way is optimal.) This notation might catch a sight reader off guard, but based on these rhythms, I doubt sight reading will be a priority :-) | To answer if this one of the kinks in our system, I would just say that our system has not caught up to all of these rhythmic possibilities. I have not done enough looking at scores from musics around the world to see how polyrhythms are notated in different places. But this kind of polyrhythm has just not been common enough in western music to have a standard notation in place for it. Even if this rhythm has become very common, it still takes time for an agreed-upon notation to gain common use. It would be more common to see a measure of 1/2 with a quintuplet of 8th notes in the RH and triplet quarter notes in the LH. But that does not explain the best way to notate it in 5/8.
That being said, I agree with both Richard and Carl. I believe the 3:5 above the triplet enhances the understanding of the rhythm, but I don't think it is necessary. Like Carl, I think I would blink a few times and then understand that the triplet quarter notes should fill the measure. |
70,129 | (There's a bunch here, sorry. I've used bold text to outline the flow of the main content of the question.)
Basically, I'm transcribing the rhythms of a song, mostly in a 6/4 & 4/4 feel, though every now & then the music deviates into a small series of "glitchy syncopations," to put it one way. in the midst of all this, **there's a single bar of 5/8 containing a normal (simple) quarter-note triplet (3 quarters in place of 2) followed by a single articulated 8th note. this got me wondering: if I used such rhythms in a composition which remained in 5/8 time extensively, and wanted to also incorporate *a triplet which spans the entire 5/8 bar* (a slightly more complex tuplet) how would I notate that?**
The answer seemed simple at first to me: *use 3 beamed eighth notes, spaced appropriately, topped with the ratio notation: 3:5. this indicates that there are 3 eighth notes in place of 5*? correct?? (see image below)
**However,** when this figure is compared to the "simple" quarter note triplet mentioned before, there's a possible discrepancy in clarity concerning speed / duration: aside from the differences between note spacing of the components within each triplet, the 3:5 triplet in bar 2, below, (which SHOULD represent a slower/longer triplet than the one in bar 1) suggests that it is faster than the standard quarter-note triplet. which is fully untrue, and seems a tad too misleading for my liking.
[](https://i.stack.imgur.com/Nu6nJ.jpg)
**Am I missing something crucial? like... if the meter is odd / imperfect / irregular, are the rules for notating tuplets altered? in other words, is my notation of the first, simple quarter-note triplet wrong? and is that notation (three quarters with a bracket) better suited for the triplet which spans the entire 5/8 measure?**
Off the top of my head I know of one source: Alexander Scriabin's Prelude in C (Op. 11 No.1): the meter is 2/2, but the general feel is a subdivision of quintuple eighth-note groupings, accents often notated and implied on the 1st and 3rd notes of each quintuplet. The composer never uses tuplet symbols to indicate that 5 eighths take the place of 4 (at least in none of the scores I've seen) but the music makes the subdivision quite clear.
Anyways, in a few places the left hand plays a figure of 3 quarter notes, again, never notated with any tuplet signs, but implied to be a triplet pitted against the quintuplet: 3 quarters in place of 5 eighths (aka a normal quarter-note triplet pitted against the standard pulse of the time sig: 2/2), rather than a quarter note triplet taking the place of 4 out of 5 of the eighth-notes from the quintuplet... or any other rhythm. the distinction between these triplets may seem slight but I believe it makes a difference which one is observed.
[](https://i.stack.imgur.com/Cniu9.jpg)
I realize since the time signature is 2/2 and not 5/8, there may be a difference between this example and my hypothetical, but if my assumption about Scriabin's triplets here being 3:5 is correct, then my very first posited notation of the "simple" quarternote triplet in a 5/8 context may be fallacious, and I should be treating said "simple" tuplet with a more special approach. maybe the following:
[](https://i.stack.imgur.com/3SJ2B.jpg)
Using the 8th-note triplet, explicitly labeled with a "3:4" ratio (above left), instead of the standard quarter note triplet notation, seems a clearer solution. its result is the same as (quarters)3:2 but leaves room for the usage of the 3 quarter grouping to represent triplet which fills the duration of a 5/8 bar, like my assumption of Scriabin. (above, right
One more possible notation:
[](https://i.stack.imgur.com/GBrGp.jpg)
**Is this just one of those kinks in our system of notation? or is there a ~standard protocol based on precedence in sources?** If you've read all this thanks so much. | 2018/04/19 | [
"https://music.stackexchange.com/questions/70129",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/49602/"
] | I'm not sure I entirely agree with Richard's answer. Certainly standard notation is to indicate a triplet using notes which would "normally" take longer than the triplet, e.g. three eighth notes for a triplet covering a quarter note.
Your stated problem occurs because 5/8 time can only be "contracted" in this way by using quarter notes. So if I (and I have 50 years' experience with reading oddball scores) were to see in 5/8 time, a quarter-note triplet followed with an eighth rest, I would certainly see the triplet as covering 4 eighth notes. If I see just a quarter-note triplet, I would blink a couple times and make the three notes cover all five eighth notes.
Definitely do **not** write the full-measure triplet with eighth notes, as that violates the "contraction" rule.
Yes, this means the quarter-note triplet means different things depending on whether there's an eighth rest in the same measure, but that's just the way it is. | To answer if this one of the kinks in our system, I would just say that our system has not caught up to all of these rhythmic possibilities. I have not done enough looking at scores from musics around the world to see how polyrhythms are notated in different places. But this kind of polyrhythm has just not been common enough in western music to have a standard notation in place for it. Even if this rhythm has become very common, it still takes time for an agreed-upon notation to gain common use. It would be more common to see a measure of 1/2 with a quintuplet of 8th notes in the RH and triplet quarter notes in the LH. But that does not explain the best way to notate it in 5/8.
That being said, I agree with both Richard and Carl. I believe the 3:5 above the triplet enhances the understanding of the rhythm, but I don't think it is necessary. Like Carl, I think I would blink a few times and then understand that the triplet quarter notes should fill the measure. |
38,239,057 | I'm a bit confused on how Bot Builder is intended to be used if you want to connect to Slack as well as Kik.
Am I supposed to be using "builder.BotConnectorBot" or will I end up with a "builder.BotConnectorBot" and a separate "builder.SlackBot"? If so, does that mean I'm hosing two separate bots, one for Kik and one for Slack? Or can the same bot built using "builder.BotConnectorBot" be hosted once and work across every channel? | 2016/07/07 | [
"https://Stackoverflow.com/questions/38239057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1203703/"
] | You only need to create a single bot. Just enable it for multiple channels in the portal.
Direct link:
<https://dev.botframework.com/bots?id=>{YourBotId} | You develop one bot and you can use it across multiple channels (skype, slack, FB Messenger, Email, SMS, etc.). This is the main objective of BotFramework to abstract you to the channel implementations.
To add a new channel, you may enter in your bot and BotFramework dev portal and click in the channel you want to add. Some channels (like FB messenger and Slack) may require additional steps to setup the channel.
[](https://i.stack.imgur.com/5jT9L.png)
REF [here](https://docs.botframework.com/en-us/core-concepts/channeldata/#navtitle). |
358,683 | Is it possible to set the root mail address to my gmail address?
And if so how?
Would it work by just setting my email address in the following file?
/etc/aliases :
```
root: mygmail@gmail.com
```
Or does it need to be a domain that is hosted on my webserver?
As a side note: not really sure this has to do with postfix I'm just starting to use freebsd as webserver trying to setup a mailserver using [this tutorial](http://www.unixug.com/content/install-mail-server-postfix-freebsd-82-release) | 2012/02/10 | [
"https://serverfault.com/questions/358683",
"https://serverfault.com",
"https://serverfault.com/users/102762/"
] | Yes you can send email to an account outside your mailserver. But, it might not work out of the box.
Test it first from the commandline:
```
[root@host ~]# /usr/bin/mail -s "Test from $HOSTNAME" mygmail@gmail.com
```
If the mail does not arrive at your gmail account, then you should see a reason why in `/var/log/maillog` . The most common reason that I see is that the host does not know how to route mail to the outside world, or does not have a [Smarthost](http://en.wikipedia.org/wiki/Smarthost) configured in `/etc/mail/sendmail.cf` | This will work fine. I forward root mail to off site mail addresses all the time. |
358,683 | Is it possible to set the root mail address to my gmail address?
And if so how?
Would it work by just setting my email address in the following file?
/etc/aliases :
```
root: mygmail@gmail.com
```
Or does it need to be a domain that is hosted on my webserver?
As a side note: not really sure this has to do with postfix I'm just starting to use freebsd as webserver trying to setup a mailserver using [this tutorial](http://www.unixug.com/content/install-mail-server-postfix-freebsd-82-release) | 2012/02/10 | [
"https://serverfault.com/questions/358683",
"https://serverfault.com",
"https://serverfault.com/users/102762/"
] | This will work fine. I forward root mail to off site mail addresses all the time. | This will work, but you may have to set parameter **append\_at\_myorigin=no** in **main.cf** in case **myorigin** is set. Otherwise if you are sending locally to "root" postfix by default will append myorigin value to the domain part of the recipient. |
358,683 | Is it possible to set the root mail address to my gmail address?
And if so how?
Would it work by just setting my email address in the following file?
/etc/aliases :
```
root: mygmail@gmail.com
```
Or does it need to be a domain that is hosted on my webserver?
As a side note: not really sure this has to do with postfix I'm just starting to use freebsd as webserver trying to setup a mailserver using [this tutorial](http://www.unixug.com/content/install-mail-server-postfix-freebsd-82-release) | 2012/02/10 | [
"https://serverfault.com/questions/358683",
"https://serverfault.com",
"https://serverfault.com/users/102762/"
] | Yes you can send email to an account outside your mailserver. But, it might not work out of the box.
Test it first from the commandline:
```
[root@host ~]# /usr/bin/mail -s "Test from $HOSTNAME" mygmail@gmail.com
```
If the mail does not arrive at your gmail account, then you should see a reason why in `/var/log/maillog` . The most common reason that I see is that the host does not know how to route mail to the outside world, or does not have a [Smarthost](http://en.wikipedia.org/wiki/Smarthost) configured in `/etc/mail/sendmail.cf` | This will work, but you may have to set parameter **append\_at\_myorigin=no** in **main.cf** in case **myorigin** is set. Otherwise if you are sending locally to "root" postfix by default will append myorigin value to the domain part of the recipient. |
4,359,149 | Prove that the unitary closed ball of $l\_1 (\mathbb N)$ is closed in $l\_2 (\mathbb N)$.
My attempt: $$\text{Let $(x\_n)\_{n\in\mathbb N} $ be a sequence such that }\sum\_i^\infty |x\_{n\_i}| \le 1 \ \text{and} \lim\_{n\to \infty } x\_n = x \text { in $ l\_2(\mathbb N)$}$$
If we had that the unitary ball was not closed, then we could have $x$ such that $\sum\_i^\infty |x\_{i}| > 1$ and that:
$$\forall \epsilon >0 \ , \exists p \in \mathbb N:n>p \implies \sum\_i^\infty (x\_{n\_i}-x\_i)^2 <\epsilon $$ After playing with this expression, I couldn't find any contradiction. | 2022/01/17 | [
"https://math.stackexchange.com/questions/4359149",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/730135/"
] | Observe that $\ell\_1(\mathbb{N})\subset\ell\_2(\mathbb{N})$, this the unit $\|\;\|\_1$-ball is contained in $\ell\_2$.
Suppose $(x\_k, x: k\in\mathbb{N})\subset \ell\_2(\mathbb{N})$ such that
1. $\sum\_n|x\_k(n)|\leq 1$,
2. $\|x\_k-x\|^2\_2=\sum\_n|x\_k(n)-x(n)|^2\xrightarrow{k\rightarrow\infty}0$.
Condition (2) implies
$$|x\_k(n)-x(n)|\leq \|x\_k-x\|\_2,\qquad k,n\in\mathbb{N}$$
Hence
$$\lim\_k x\_k(n)=x(n),\qquad n\in\mathbb{N}$$
The conclusion can be obtained by an application of [Fatou's lemma](https://en.wikipedia.org/wiki/Fatou%27s_lemma#Standard_statement), for
$$\sum\_n|x(n)|=\sum\_n\lim\_k|x\_k(n)|\leq\liminf\_k\sum\_n|x\_k(n)|\leq 1$$
by condition (1). | Step I. The closed unit ball in $\ell\_1(\mathbb N)$ is a subset of the closed unit ball of $\ell\_2(\mathbb N)$.
Step II. If $x^n=(x\_k^n)\in\ell\_1(\mathbb N)$, $\|x^n\|\_1\le 1,$ and $(x^n)$ is $\ell\_1-$convergent to $x=(x\_k)$, then clearly $x\_k^n\to x\_k$, for all $k$.
Also, $(x^n)$ is $\ell\_1-$Cauchy. But,
$$
\sum\_{k\in\mathbb N}|x^m\_k-x\_k^n|^2
=\sum\_{k\in\mathbb N}|x^m\_k-x\_k^n||x^m\_k-x\_k^n|
\le 2\sum\_{k\in\mathbb N}|x^m\_k-x\_k^n|,
$$
since $|x^m\_k-x\_k^n|\le 2$, for all $m,n,k$. Thus $(x^n)$ is $\ell\_2-$Cauchy, and hence is $\ell\_2-$convergent.
Say $\|x^n-y\|\_2\to 0$, where $y=(y\_k)$, then clearly $x\_k^n\to y\_k$, for all $k$, and hence $y=x$.
But $x$ is in the unit closed ball of $\ell^1$. |
331,445 | I have an ISP (Beam telecom, if it's relevant) that provides only a LAN cable connection. Using this, whichever site you initially open, you are redirected to its portal page where you are required to log in. After this you can access internet as normal.
The problem that I am facing is when I am trying to setup my ADSL router to use it as a WiFi router so that multiple devices can connect to the internet.
I have connected the ISP's RJ-45 cable into one of my ADSL router's LAN ports and I am able to connect to the internet through the WiFi network using the same process.
The problem is that, when one of the devices has successfully authenticated with the portal (and has been assigned an IP), if I try to use that WiFi from any other device, I am again greeted with the portal page. After authenticating I get access to the Internet in this device, but the previous device loses Internet access and that device is greeted with the portal login page.
So in effect only one device is able to connect to the Internet at a given time.
I have seen few forum posts saying if I use a normal WiFi router which has a WAN port and not the ADSL that I currently have. Would resolve the issue. But I am in doubt if this would really fetch me anything, and I don't want to spend money on another router if it is still in vain.
So any ideas if a non-ADSL router would resolve this issue or if I can change my existing router's settings so that I can connect more than one device?
My ADSL router is a Linksys Wireless-G ADSL Home Gateway, model WAG200G.
Would a flash of DD-WRT custom firmware on my device provide new options that would allow me to make use of my ADSL to work as a normal WiFi router? | 2011/09/03 | [
"https://superuser.com/questions/331445",
"https://superuser.com",
"https://superuser.com/users/6722/"
] | The mechanism being used to stifle you is called "captive portal". While I don't know all that much about it you could do some searching to see if there is a way to persist a connection through it. Persistence with this is usually accomplished with a combination MAC address and a cookie combo.
This may help you: <http://forums.whirlpool.net.au/archive/1574520> | Answering this three year old post for the lack of a better answer. A virtual router is one way but not the idle one.
For such ISPs, (BEAM telecom / ACT etc), you could use PPPoE. You just need to put in your usual credential into the router PPPoE page and then any device connecting to your wifi router will not need the username password as its your router which is authenticated.
>
> I have seen few forum posts saying if I use a normal WiFi router which
> has a WAN port and not the ADSL that I currently have. Would resolve
> the issue. But I am in doubt if this would really fetch me anything,
> and I don't want to spend money on another router if it is still in
> vain.
>
>
>
Yes, you will need a WAN based router for the above to work. |
331,445 | I have an ISP (Beam telecom, if it's relevant) that provides only a LAN cable connection. Using this, whichever site you initially open, you are redirected to its portal page where you are required to log in. After this you can access internet as normal.
The problem that I am facing is when I am trying to setup my ADSL router to use it as a WiFi router so that multiple devices can connect to the internet.
I have connected the ISP's RJ-45 cable into one of my ADSL router's LAN ports and I am able to connect to the internet through the WiFi network using the same process.
The problem is that, when one of the devices has successfully authenticated with the portal (and has been assigned an IP), if I try to use that WiFi from any other device, I am again greeted with the portal page. After authenticating I get access to the Internet in this device, but the previous device loses Internet access and that device is greeted with the portal login page.
So in effect only one device is able to connect to the Internet at a given time.
I have seen few forum posts saying if I use a normal WiFi router which has a WAN port and not the ADSL that I currently have. Would resolve the issue. But I am in doubt if this would really fetch me anything, and I don't want to spend money on another router if it is still in vain.
So any ideas if a non-ADSL router would resolve this issue or if I can change my existing router's settings so that I can connect more than one device?
My ADSL router is a Linksys Wireless-G ADSL Home Gateway, model WAG200G.
Would a flash of DD-WRT custom firmware on my device provide new options that would allow me to make use of my ADSL to work as a normal WiFi router? | 2011/09/03 | [
"https://superuser.com/questions/331445",
"https://superuser.com",
"https://superuser.com/users/6722/"
] | I have got a working solution to my own question. I was able to wirelessly connect one of my PCs running Windows. I installed Virtual Router on my Windows PC that establishes its own wireless network to which other PCs can connect.
So now all my devices can connect to the internet, but the Windows PC has to be running along with the wireless router (and that's free! - minus electricity costs).
I got the link from [addictivetips.com](http://www.addictivetips.com/windows-tips/share-wireless-internet-connection-in-windows-7-without-ad-hoc/) | Answering this three year old post for the lack of a better answer. A virtual router is one way but not the idle one.
For such ISPs, (BEAM telecom / ACT etc), you could use PPPoE. You just need to put in your usual credential into the router PPPoE page and then any device connecting to your wifi router will not need the username password as its your router which is authenticated.
>
> I have seen few forum posts saying if I use a normal WiFi router which
> has a WAN port and not the ADSL that I currently have. Would resolve
> the issue. But I am in doubt if this would really fetch me anything,
> and I don't want to spend money on another router if it is still in
> vain.
>
>
>
Yes, you will need a WAN based router for the above to work. |
63,157,682 | I am trying to summarize data from a health app by date. Each date has multiple entries so I've created a single dictionary that has each unique date as a key (column index `1`), and I want to add the total amount of fat (column index `7`) for each date as a value.
I am new to Python and trying to do this in pure Python rather than with NumPy etc. Any help is much appreciated.
`['18600018', '05-31-2020', 'Dinner', 'salmon', '1 serving', '210.0000000005', '-0.0694999987329796', '14.000000004', '2.999999996', '', '', '', '54.9999999975', '469.9999999995', '', '', '', '', '', '', '20.9999999975', '', '', '', '4.799999997', '', '', '', '', '', '', '', '', '', '', '', '0.3599999985', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']`
So far I have this for loop to increment the dictionary and am getting the following error:
```
fat_dict = {}
for row in data:
date = row[1]
fat = row[7]
if date in fat_dict:
fat_dict[date] = fat
else:
fat_dict[date] += fat
KeyError Traceback (most recent call last)
<ipython-input-3-dfbce568de95> in <module>
80 fat_dict[date] = fat
81 else:
---> 82 fat_dict[date] += fat
83
84
KeyError: '05-31-2020'
```
The ideal outcome would be each unique date (key) with sum of fat for that date (value). | 2020/07/29 | [
"https://Stackoverflow.com/questions/63157682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1642410/"
] | That's because you call the method using `prototype`. In that case `Top.prototype` is binded to `this`. In general `this` is an object "before a dot". That's why in the first call `t.longRun1()`, `this` is `t`.
Correct call would be:
```
this.longRun2().then((out) => {
resolve(out);
}).catch((err) => {
console.log("LR2:" + err);
});
```
If you want to have more control on `this` variable you can use one of these:
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply>
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind>
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call> | One more thing for those who may stumble upon this:
szatkus's answer worked for me.....just not at first, and it was a weird one (well, to me it was.....)
I changed my test code above, and it worked correctly, so I went to the code that I'm working on, and it still crapped out, even with the fix?!? After looking long and hard at the differences between the test code, and my real code, I found one difference:
In my code:
```
return new Promise(function(resolve,reject) {
```
The test code:
```
return new Promise((resolve,reject) => {
```
Functionally (as far as I knew) they are the same...the test code just uses a more recent convention than what I was taught many moons ago. I change my real code to the newer way of calling functions, and (Taa-Daah) it worked!
Maybe someone can comment about why the different results for the two different forms of calling a function? |
31,164,747 | How to change the number of decimal digits?
Changing the `format` Matlab can show only 4 (if `short`) or 15 (if `long`). But I want exactly 3 digits to show. | 2015/07/01 | [
"https://Stackoverflow.com/questions/31164747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5058209/"
] | Just use `duplicated()` on the subset of columns that you want to make sure are unique and use that to subset the main data.frame. For example
```
dd[ !duplicated(dd[,c("P1","P2")]) , ]
``` | If dt is your data frame -
```
library(data.table)
setDT(dt)
dtFiltered = dt[,
Flag := .I - min(.I),
list(P1,P2)
][
Flag == 0
]
dtFiltered = dtFiltered[,
Flag := NULL
]
```
Thanks for Frank for pointing out I missed the P2. |
31,164,747 | How to change the number of decimal digits?
Changing the `format` Matlab can show only 4 (if `short`) or 15 (if `long`). But I want exactly 3 digits to show. | 2015/07/01 | [
"https://Stackoverflow.com/questions/31164747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5058209/"
] | If dt is your data frame -
```
library(data.table)
setDT(dt)
dtFiltered = dt[,
Flag := .I - min(.I),
list(P1,P2)
][
Flag == 0
]
dtFiltered = dtFiltered[,
Flag := NULL
]
```
Thanks for Frank for pointing out I missed the P2. | Try this :
```
dat <- dat[!duplicated(dat[1:2]), ]
``` |
31,164,747 | How to change the number of decimal digits?
Changing the `format` Matlab can show only 4 (if `short`) or 15 (if `long`). But I want exactly 3 digits to show. | 2015/07/01 | [
"https://Stackoverflow.com/questions/31164747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5058209/"
] | Just use `duplicated()` on the subset of columns that you want to make sure are unique and use that to subset the main data.frame. For example
```
dd[ !duplicated(dd[,c("P1","P2")]) , ]
``` | Try this :
```
dat <- dat[!duplicated(dat[1:2]), ]
``` |
11,046,260 | I'm not good in English. What wrong with my text ^^ sorry :)
I have data in my table football.
[jsfiddle](http://jsfiddle.net/ctheidea/7x7MZ/)
I am having trouble building a function to calculate all rows in the table. When the page finishes loading or click row for edit value in textfiled. jQuery will be calculate auto.
GP = Game Played = HOME(W+D+L) + AWAY(W+D+L)
Summary
W = HOME\_W + AWAY\_W
D = HOME\_D + AWAY\_D
L = HOME\_L + AWAY\_L
F = HOME\_F + AWAY\_F
A = HOME\_A + AWAY\_A
GD = Summary(F) - Summary(A)
HTML
```
<table id="table-pts">
<thead>
<tr>
<th colspan="3"> </th>
<th colspan="5">HOME</th>
<th colspan="5">AWAY</th>
<th colspan="5">SUMMARY</th>
<th colspan="2"> </th>
</tr>
<tr>
<th>Pos</th>
<th class="team">Team</th>
<th>GP</th>
<th>W</th>
<th>D</th>
<th>L</th>
<th>F</th>
<th>A</th>
<th>W</th>
<th>D</th>
<th>L</th>
<th>F</th>
<th>A</th>
<th>W</th>
<th>D</th>
<th>L</th>
<th>F</th>
<th>A</th>
<th>GD</th>
<th>Pts</th>
</tr>
</thead>
<tbody>
<tr id="1" class="edit_tr">
<td></td>
<td class="team">
</td>
<td><span id="summary_GP_1"></span></td>
<td>
<span id="home_w_1" class="text">1</span>
<input type="text" value="1" class="editbox" id="home_w_input_1"/>
</td>
<td>
<span id="home_d_1" class="text">3</span>
<input type="text" value="3" class="editbox" id="home_d_input_1"/>
</td>
<td>
<span id="home_l_1" class="text">2</span>
<input type="text" value="2" class="editbox" id="home_l_input_1"/>
</td>
<td>
<span id="home_f_1" class="text">4</span>
<input type="text" value="4" class="editbox" id="home_f_input_1"/>
</td>
<td>
<span id="home_a_1" class="text">76</span>
<input type="text" value="76" class="editbox" id="home_a_input_1"/>
</td>
<td>
<span id="away_w_1" class="text">8</span>
<input type="text" value="8" class="editbox" id="away_w_input_1"/>
</td>
<td>
<span id="away_d_1" class="text">9</span>
<input type="text" value="9" class="editbox" id="away_d_input_1"/>
</td>
<td>
<span id="away_l_1" class="text">10</span>
<input type="text" value="10" class="editbox" id="away_l_input_1"/>
</td>
<td>
<span id="away_f_1" class="text">11</span>
<input type="text" value="11" class="editbox" id="away_f_input_1"/>
</td>
<td>
<span id="away_a_1" class="text">12</span>
<input type="text" value="12" class="editbox" id="away_a_input_1"/>
</td>
<td><span id="summary_w_1" ></span></td>
<td><span id="summary_d_1" class="text"></span></td>
<td><span id="summary_l_1" class="text"></span></td>
<td><span id="summary_f_1" class="text"></span></td>
<td><span id="summary_a_1" class="text"></span></td>
<td><span id="summary_GD_1" class="text"></span></td>
<td><span id="summary_Pts_1" class="text"></span></td>
</tr>
<tr id="2" class="edit_tr">
<td></td>
<td class="team">
</td>
<td><span id="summary_GP_2"></span></td>
<td>
<span id="home_w_2" class="text">1</span>
<input type="text" value="1" class="editbox" id="home_w_input_2"/>
</td>
<td>
<span id="home_d_2" class="text">3</span>
<input type="text" value="3" class="editbox" id="home_d_input_2"/>
</td>
<td>
<span id="home_l_2" class="text">2</span>
<input type="text" value="2" class="editbox" id="home_l_input_2"/>
</td>
<td>
<span id="home_f_2" class="text">4</span>
<input type="text" value="4" class="editbox" id="home_f_input_2"/>
</td>
<td>
<span id="home_a_2" class="text">76</span>
<input type="text" value="76" class="editbox" id="home_a_input_2"/>
</td>
<td>
<span id="away_w_2" class="text">8</span>
<input type="text" value="8" class="editbox" id="away_w_input_2"/>
</td>
<td>
<span id="away_d_2" class="text">9</span>
<input type="text" value="9" class="editbox" id="away_d_input_2"/>
</td>
<td>
<span id="away_l_2" class="text">10</span>
<input type="text" value="10" class="editbox" id="away_l_input_2"/>
</td>
<td>
<span id="away_f_2" class="text">11</span>
<input type="text" value="11" class="editbox" id="away_f_input_2"/>
</td>
<td>
<span id="away_a_2" class="text">12</span>
<input type="text" value="12" class="editbox" id="away_a_input_2"/>
</td>
<td><span id="summary_w_2" ></span></td>
<td><span id="summary_d_2" class="text"></span></td>
<td><span id="summary_l_2" class="text"></span></td>
<td><span id="summary_f_2" class="text"></span></td>
<td><span id="summary_a_2" class="text"></span></td>
<td><span id="summary_GD_2" class="text"></span></td>
<td><span id="summary_Pts_2" class="text"></span></td>
</tr>
</tbody>
```
JQUERY
```
$(document).ready(function(){
$(".edit_tr").click(function(){
var ID = $(this).attr('id');
$("#home_w_"+ID).hide();
$("#home_d_"+ID).hide();
$("#home_l_"+ID).hide();
$("#home_f_"+ID).hide();
$("#home_a_"+ID).hide();
$("#away_w_"+ID).hide();
$("#away_d_"+ID).hide();
$("#away_l_"+ID).hide();
$("#away_f_"+ID).hide();
$("#away_a_"+ID).hide();
$("#home_w_input_"+ID).show();
$("#home_d_input_"+ID).show();
$("#home_l_input_"+ID).show();
$("#home_f_input_"+ID).show();
$("#home_a_input_"+ID).show();
$("#away_w_input_"+ID).show();
$("#away_d_input_"+ID).show();
$("#away_l_input_"+ID).show();
$("#away_f_input_"+ID).show();
$("#away_a_input_"+ID).show();
}).change(function(){
// calculate point in table football
var ID = $(this).attr('id');
var home_w = parseInt($("#home_w_input_"+ID).val());
var home_d = parseInt($("#home_d_input_"+ID).val());
var home_l = parseInt($("#home_l_input_"+ID).val());
var home_f = parseInt($("#home_f_input_"+ID).val());
var home_a = parseInt($("#home_a_input_"+ID).val());
var away_w = parseInt($("#away_w_input_"+ID).val());
var away_d = parseInt($("#away_d_input_"+ID).val());
var away_l = parseInt($("#away_l_input_"+ID).val());
var away_f = parseInt($("#away_f_input_"+ID).val());
var away_a = parseInt($("#away_a_input_"+ID).val());
var summaryW = home_w + away_w;
var summaryD = home_d + away_d;
var summaryL = home_l + away_l;
var summaryF = home_f + away_f;
var summaryA = home_a + away_a;
var summaryGD = summaryF + summaryA;
var summaryPts = summaryW * 3 +summaryD * 1;
var summaryGP = summaryW + summaryD + summaryL;
/* var dataString = 'id='+ ID + '&home_w='+ home_w + '&home_d='+ home_d + '&home_l='+ home_l + '&home_f='+ home_f + '&home_a='+ home_a + '&away_w='+ away_w + '&away_d='+ away_d + '&away_l='+ away_l + '&away_f='+ away_f + '&away_a='+ away_a + '&action=edit_pts';
$("#home_w_"+ID).html('<img src="load.gif"/>');
$.ajax({
type: "POST",
url: "table_pts_action_ajax.php",
data: dataString,
cache: false,
success: function(html)
{*/
// live update in my table football
$("#home_w_"+ID).html(home_w);
$("#home_d_"+ID).html(home_d);
$("#home_l_"+ID).html(home_l);
$("#home_f_"+ID).html(home_f);
$("#home_a_"+ID).html(home_a);
$("#away_w_"+ID).html(away_w);
$("#away_d_"+ID).html(away_d);
$("#away_l_"+ID).html(away_l);
$("#away_f_"+ID).html(away_f);
$("#away_a_"+ID).html(away_a);
$("#summary_w_"+ID).html(summaryW);
$("#summary_d_"+ID).html(summaryD);
$("#summary_l_"+ID).html(summaryL);
$("#summary_f_"+ID).html(summaryF);
$("#summary_a_"+ID).html(summaryA);
$("#summary_GD_"+ID).html(summaryGD);
$("#summary_Pts_"+ID).html(summaryPts);
$("#summary_GP_"+ID).html(summaryGP);
// }
// });
});
$("#table-pts tbody tr").each(function(){
// page is load finish.. calculate point in table football
var ID = $(this).attr('id');
var txtHomeW = parseInt($("#home_w_"+ID).text());
var txtHomeD = parseInt($("#home_d_"+ID).text());
var txtHomeL = parseInt($("#home_l_"+ID).text());
var txtHomeF = parseInt($("#home_f_"+ID).text());
var txtHomeA = parseInt($("#home_a_"+ID).text());
var txtAwayW = parseInt($("#away_w_"+ID).text());
var txtAwayD = parseInt($("#away_d_"+ID).text());
var txtAwayL = parseInt($("#away_l_"+ID).text());
var txtAwayF = parseInt($("#away_f_"+ID).text());
var txtAwayA = parseInt($("#away_a_"+ID).text());
var summaryW = parseInt(txtHomeW+txtAwayW);
var summaryD = parseInt(txtHomeD+txtAwayD);
var summaryL = parseInt(txtHomeL+txtAwayL);
var summaryF = parseInt(txtHomeF+txtAwayF);
var summaryA = parseInt(txtHomeA+txtAwayA);
var summaryGD = parseInt(summaryF-+summaryA);
var summaryPts = parseInt(summaryW * 3 + summaryD * 1);
var summaryGP = parseInt(summaryW + summaryD + summaryL);
$(this).find("#summary_w_"+ID).text(summaryW);
$(this).find("#summary_d_"+ID).text(summaryD);
$(this).find("#summary_l_"+ID).text(summaryL);
$(this).find("#summary_f_"+ID).text(summaryF);
$(this).find("#summary_a_"+ID).text(summaryA);
$(this).find("#summary_GD_"+ID).text(summaryGD);
$(this).find("#summary_Pts_"+ID).text(summaryPts);
$(this).find("#summary_GP_"+ID).text(summaryGP);
});
// Edit input box click action
$(".editbox").mouseup(function(){
return false
});
// Outside click action
$(document).mouseup(function(){
$(".editbox").hide();
$(".text").show();
});
});
```
CSS
```
#table-pts{
color: #333;
text-align: center;
font-size: 12px;
width: 100%;
}
#table-pts tbody tr{
border-bottom: 1px solid #dddcdc;
padding: 10px;
line-height: 30px;
}
#table-pts tbody td{
vertical-align: middle;
padding: 5px 0;
}
#table-pts thead tr th{
text-align: center;
line-height: 30px;
background: #233825;
color: #FFF;
border-left: 1px solid #CCC;
width: 30px;
}
#table-pts .table-team{
width: 10px;
text-align: left;
padding: 3px 7px 3px 7px;
}
#table-pts .editbox{
display: none;
border: 1px solid #CCC;
text-align: center;
}
#table-pts .odd{background: #fafafa;}
.table-hl
{
width: 70px;
}
#table-pts input{
width: 20px;
}
```
Thank you so much. | 2012/06/15 | [
"https://Stackoverflow.com/questions/11046260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1559077/"
] | Though i could not get your problem statement exactly, But you can get the sum of columns like this way.
```
$(document).ready(function(){
var sum = 0;
jQuery('.text').each(function(){
sum += parseInt(jQuery(this).text());
});
console.log(sum);
});
```
If you want to get sum of both row in one var, then use above code.
Otherwise, if you want seperate sum for both row, assign a different class to 2nd row elements as you have assigned 'test' class in both row right now.
After changing class name, use same code for that class.
You can use that code on edit click or change event as well. | just another solution:
```
var tot = 0;
$('tbody tr').each(function() {
$(this).find('.text').each(function(){
tot += parseInt($(this).text());
});
alert(tot);
tot = 0;
});
```
sum salt element:
```
var sum, i, k;
$('tbody tr').each(function() {
k = ($(this).find('.text').length / 2);
for(i = 0; i < ($(this).find('.text').length / 2); i++){
sum = parseInt($(this).find('.text').eq(i).text()) + parseInt($(this).find('.text').eq(k).text());
k++;
alert(sum);
}
});
``` |
35,215,854 | I am developing a Quickfix/n initiator to be used with several counterparties, in the same instance, all using the same version of FIX (4.2 in this instance) but utilizing a unique messaging specification and I would like to use Intellisense/ReSharper to develop said initiator.
Previously I have used the generate.rb script to create source code from a modified FIX##.xml file but would like to use something like FIX42.DeutcheBank.xml, FIX42.CME.xml, FIX42.Whatever, to generate the source with the generate.rb ruby script or a modified version thereof so they can be parsed by IntelliSense/ReSharper and I am having issues because they all use "FIX.4.2" as begin strings and thus causes a compile error.
I know that I can just refer to a field/group via a key like Tags["BidForwardPointsCME"] or something similar with a DataDictionary but, as stated, I would like to be able to use IntelliSense/ReSharper and reference the message fields/groups with something like Quickfix.CounterParty.WhateverField and using the same dll.
I've banged my head against the internet for answers for 3-4 days with no luck - Is what I would like to do possible? If so, how would one go about it?
Hi in advance to Grant Birchmeier <:-] | 2016/02/05 | [
"https://Stackoverflow.com/questions/35215854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3246873/"
] | For anyone that ever is trying to do this, the answer is pretty simple - probably not the most efficient but it works as far as I know.
the trick is to edit two ruby generation scripts (messages\_gen.rb and generate.rb) and place the additional FIX specification XML file(s) in the spec/fix directory.
Assuming that you have a custom FIX xml file for Foo Exchange and that the Foo Exchange uses FIX 4.2, you need to name it FIX.xml (Example: FIXFooExchange.xml)
Next, you will have to override the FIX version in messages\_gen.rb like so:
```
def self.gen_basemsg fixver, destdir
beginstring = fixver
if beginstring.match(/^FIX50/)
beginstring = "FIXT11"
end
if beginstring.match(/^FIXFooExchange/)
beginstring = "FIX42"
end
```
Next you need to add your custom fix version to 6 method definitions in the generate.rb file.
Those methods are:
initialize
agg\_fields
get\_field\_def
generate\_messages
generate\_csproj
generate\_message\_factories
Here are a few examples:
```
def initialize
@fix40 = FIXDictionary.load spec('FIX40')
@fix41 = FIXDictionary.load spec('FIX41')
@fix42 = FIXDictionary.load spec('FIX42')
@fix43 = FIXDictionary.load spec('FIX43')
@fix44 = FIXDictionary.load spec('FIX44')
@fix50 = FIXDictionary.load spec('FIX50')
@fix50sp1 = FIXDictionary.load spec('FIX50SP1')
@fix50sp2 = FIXDictionary.load spec('FIX50SP2')
@fixFooExchange = FIXDictionary.load spec('FIXFooExchange')
@src_path = File.join File.dirname(__FILE__), '..', 'QuickFIXn'
end
def get_field_def fld_name
# we give priority to latest fix version
fld = merge_field_defs(
@fix50sp2.fields[fld_name],
@fix50sp1.fields[fld_name],
@fix50.fields[fld_name],
@fix44.fields[fld_name],
@fixFooExchange.fields[fld_name],
@fix43.fields[fld_name],
@fix42.fields[fld_name],
@fix41.fields[fld_name],
@fix40.fields[fld_name]
)
End
```
Basically you just copy one line and replace the fix version with the customized exchange xml data dictionary name.
The class BeginString in FixValues.cs should be modified to look like this:
```
public class BeginString
{
public const string FIXT11 = "FIXT.1.1";
public const string FIX50 = "FIX.5.0";
public const string FIX44 = "FIX.4.4";
public const string FIX43 = "FIX.4.3";
public const string FIXFooExchange = "FIX.4.2";
public const string FIX42 = "FIX.4.2";
public const string FIX41 = "FIX.4.1";
public const string FIX40 = "FIX.4.0";
}
```
The Values.cs file contains a single class which should be changed to look like this:
```
public class Values
{
public const string BeginString_FIXT11 = "FIXT.1.1";
public const string BeginString_FIX50 = "FIX.5.0";
public const string BeginString_FIX44 = "FIX.4.4";
public const string BeginString_FIX43 = "FIX.4.3";
public const string BeginString_FIXFooExchange = "FIX.4.2";
public const string BeginString_FIX42 = "FIX.4.2";
public const string BeginString_FIX41 = "FIX.4.1";
public const string BeginString_FIX40 = "FIX.4.0";
}
```
Do those things and then run the generate.bat file and you should be able to reference namespaces via '.' rather than using the base FIX version.
Here are some examples:
using QuickFix.FIXFooExchange;
using Message = QuickFix.Message;
```
QuickFix.FIXFooExchange.MessageFactory mF = new QuickFix.FIXFooExchange.MessageFactory();
```
and reference message properties like:
```
string customField = message.yourCustomFieldName.getValue().ToUpper();
```
instead of by
```
string customField = message["yourCustomFieldName"].getValue().ToUpper();
```
Lastly, you need to edit 2 .cs files: FixValues.cs and Values.cs
I've tested this pretty extensively and it seems to work but I would advise that you do testing before you put anything in production. | So the problem is you want 1 QF initiator process to connect to several different counterparties where each session uses a separate data dictionary?
Don't you do this using `DataDictionary=somewhere/FIX42.xml` in the configuration file?
See also <http://quickfixn.org/tutorial/configuration.html> `AppDataDictionary: This setting supports the possibility of a custom application data dictionary for each session.` |
1,939 | There is a feature called 'Upcoming Events' that is used at [Space](https://space.stackexchange.com/), and possibly other sister sites. Their [application of it is not completely without issue](https://space.meta.stackexchange.com/questions/550/how-do-the-upcoming-events-links-work) but it did get me wondering if we might make use of it some how.
Any ideas? | 2014/11/05 | [
"https://pets.meta.stackexchange.com/questions/1939",
"https://pets.meta.stackexchange.com",
"https://pets.meta.stackexchange.com/users/13/"
] | On the litter box question:
We have had a consistent problem with people posting vague problems and not following up when asked for more details that will help us answer the question properly. We've been closing those questions as a temporary measure with a comment about some of the information that we need to answer the question. Once they are updated (if they are updated), we open the question again.
Relevant meta discussions for background reading:
* [Could we have a close reason for "Not enough information"?](https://pets.meta.stackexchange.com/questions/1911/could-we-have-a-close-reason-for-not-enough-information)
* [What kind of quality do we expect from people asking questions?](https://pets.meta.stackexchange.com/questions/1852/what-kind-of-quality-do-we-expect-from-people-asking-questions)
* [What common information should a question poster be expected to provide about their pet?](https://pets.meta.stackexchange.com/questions/561/what-common-information-should-a-question-poster-be-expected-to-provide-about-th)
On the aquarium question:
* [Why is it better to ask all my questions separately, and not all at once?](https://pets.meta.stackexchange.com/questions/1837/why-is-it-better-to-ask-all-my-questions-separately-and-not-all-at-once)
On the pet selection question:
* [Are "Recommend a fish" questions on topic?](https://pets.meta.stackexchange.com/questions/655/are-recommend-a-fish-questions-on-topic)
* [Should we allow "shopping" or product/species recommendation questions?](https://pets.meta.stackexchange.com/questions/82/should-we-allow-shopping-or-product-species-recommendation-questions) | @MattS. posted <http://data.stackexchange.com/pets/revision/241383/315568/question-votes-compared-to-its-views> in chat, in response to my request to look at votes in relation to visits.
If the best questions are the ones with the most up votes per visit. Said differently the questions that were up-voted by the largest percentage of people who read the question are presumably the best questions.
THAN: the best questions are the ones most specific to a small well defined group.
Disregarding the the highest one posted (27% approval rating) as it very new at the time of the survey. The questions with the highest approval ratings, are the ones focusing on specific issues relative to a small group.
Questions with 15%+ approval rating all have 100 or less visitors
Questions with 10-15% approval rating have 220 or less visitors
The first question with more than 300 views and a high approval rating is [Putting a cat into a carrier](https://pets.stackexchange.com/questions/251/putting-a-cat-into-a-carrier) with 461 views and 25 votes for an approval rating of 5%, again a very specific scenario
The first question with more than 1000 views is [How should I discipline my cat for bad behavior?](https://pets.stackexchange.com/questions/67) with 1040 views and 34 votes for a approval rating of 3%
\*Where first = highest approval rating per visits
It is clear from this perspective that the best questions are specific and clearly defined not general or undefined questions.
All the questions that attract the most visitors are those with titles that grab peoples attention, the actual content of the question has little to do with attracting visitors. [Famous Question](https://pets.stackexchange.com/help/badges/28/famous-question) & [Notable Question](https://pets.stackexchange.com/help/badges/27/notable-question)
Approval rating on questions with more than 10k views are going to be skewed, but the highest voted Famous Question is [Why is my dog drinking his pee after he urinates inside?](https://pets.stackexchange.com/questions/473) with 18 votes and 17K visits, again a very specific question with narrow defined parameters.
The example [Best small pet for a fairly small space in a bedroom](https://pets.stackexchange.com/questions/6688/) is posted by an OP that has not returned to the site since asking it, there is insufficient information to provided a good answer for the OP, and it is not narrow or focused enough to add value to anyone else.
The example [Help! My cat pees on everything!](https://pets.stackexchange.com/questions/6678) is also posted by an OP that has not returned, it got a quick answer that was very bad, and later a better answer. In hind site, we would have best served the community by putting it on hold sooner.
In conclusion just because a question can be answered, does not mean it adds value to the site or to the OP. Questions that are overly broad or with insufficient detail do not add value to the site, nor do they encourage visitors. I believe your assessment and conclusions in your question (or accusation) is incorrect.
**Edit November 3, 2015**
**Test Question**
An attempt was made with the question [What small pets should I consider for a preteen with limited space?](https://pets.stackexchange.com/questions/6694) to rephrase the "best small pet" question to narrow the scope as far as possible and make it as answerable as possible; it was rejected by the community (votes from 5 non-moderators) as to broad and opinion based. Note that this question is written by an individual currently in a moderator pro tem position, who has written over 100 question on the site with a vote of 1+. |
1,939 | There is a feature called 'Upcoming Events' that is used at [Space](https://space.stackexchange.com/), and possibly other sister sites. Their [application of it is not completely without issue](https://space.meta.stackexchange.com/questions/550/how-do-the-upcoming-events-links-work) but it did get me wondering if we might make use of it some how.
Any ideas? | 2014/11/05 | [
"https://pets.meta.stackexchange.com/questions/1939",
"https://pets.meta.stackexchange.com",
"https://pets.meta.stackexchange.com/users/13/"
] | **Quick and dirty summary:**
* We've tried these types of questions before and they didn't work out.
* This isn't a forum, we try to avoid discussions outside of the chatroom (and sometimes meta).
* There is a difference between questions/answers that are useful to anyone, and questions/answers that are useful to only one person.
* Not every question is a good question.
* We don't have to take questions we consider to be bad, in the hopes that they'll attract users. Because our user-base is growing without those questions.
* Those questions attract visitors, but not users. We should be focusing on attracting users who will stay and answer questions. Visitors will come on their own as long as we have content, which we need users to build and maintain.
**Detailed Points:**
--------------------
**Best small pet for a fairly small space in a bedroom?**
This is clearly a recommendation question. The problem with recommendation questions is that the person who's going to be taking care of the animal is the best person to choose an animal they want. Any answers to a pet recommendation question are no better than if the person went through an encyclopedia of animal species.
Part of what we consider with questions, is whether or not the question is useful to anyone, or just the person asking the question. If a person asks a question that's only useful to them, then that question is nothing but noise on our site.
Yes, plenty of people google "What pet should I get?". But no one is going to find an answer that question that applies to them. What they're going to find are lists of animals, and then they're going to decide on what animal they want on their own. Again, nothing more than looking through an encyclopedia.
But the real problem with recommendation questions is that encyclopedias are a bettor format for them. We can't physically host an answer those questions with the format of this site.
Let me break it down to give you an idea of why that is:
* There are an estimated 1,367,555 species of animals in the world.1
* Of the estimated 65.976 vertebrates, there are:
+ 5,513 species of mammals.
+ 10,425 species of birds.
+ 9,952 species of reptiles.
+ 7,286 species of amphibians.
+ 32,800 species of fish.
* Of the estimated 1,305,250 invertebrates, there are:
+ 1,000,000 species of insects.
+ 85,000 species of molluscs.
+ 47,000 species of crustaceans.
+ 2,175 species of corals.
+ 102.248 species of arachnids.
+ 165 species of velvet worms.
+ 4 species of horseshoe crabs.
* And then there are 68,658 species without any decided classification.
First off, how would we list all those animals?
The answer is that we don't. People only think about a few select species.
So then why, with all these different species of animals to choose from, is it that the answers are only for a select few species?
The answer is that **Everyone has a bias**.
Normally the bias doesn't matter. If I ask a question about cats, I want someone who spends time with cats to answer it. But with open-ended questions like "What pet should I get" no one is going to take the time to give a comprehensive answer. Partly because no one wants to suggest an animal they know nothing about.
All it leads to a lot of noisy discussion about what animals people like best, and thats something we want to avoid.
Everyone is free to ask for suggestions in the chatroom.
---
1 [ICN Red List](http://cmsdocs.s3.amazonaws.com/summarystats/2014_2_Summary_StatsPage_Documents/2014_2_RL_Stats_Table1.pdf)
**How do I shop for and set up my first fish tank?**
The only problem with your question was that you were trying to cram multiple different questions into one, which is against the rules. You had to have known this, otherwise you wouldn't have included your meta-comment about why your question(s) deserved to be an exception.
You broke the rules, I asked you to follow them, you refused, your question got closed. I don't see anything in that process that's broken.
**Help! My cat pees on everything!**
A question having answers does not designate whether or not a question shouldn't be closed, and it especially doesn't designate whether a question is good.
There will always be someone willing to answer a bad question. That's why it's important to close bad questions early, so that we not only avoid the noise it creates, but we can avoid the arguments of people's questions being closed when they got an answer.
The question was bad because there wasn't enough information to answer it. People don't always include everything that's needed when asking questions, and since we're dealing with live animals, there are many variables we have to deal with. It's created a couple meta discussions, the main one being: [What common information should a question poster be expected to provide about their pet?](https://pets.meta.stackexchange.com/questions/561/what-common-information-should-a-question-poster-be-expected-to-provide-about-th)
The answer was upvoted because it's good general advice on what to try to narrow down the problem, but it technically isn't really a solution to the problem, because we don't know what could be causing the problem. Since we don't know what's causing the problem, it's too broad for us to give an answer to, which is why it was closed.
---
I'm going to re-use the graph I used in [this answer](https://pets.meta.stackexchange.com/a/1920/481) to illustrate that we don't have to worry about gaining users. They come on their own. Which means we don't have to accept bad questions in order to gain users.

([Source](https://www.quantcast.com/pets.stackexchange.com?country=GLOBAL))
If anything, I think we need to worry less about gaining visitors, and more about gaining ***users***, the ones who will stick around and write good answers to questions. None of which will happen if we hold to the same level of quality as Yahoo Answers. Visitors don't build sites, users do.
Bottom line is, if you think these questions are good questions for the site, I think you would be better off arguing *why* they're good, and *why* you think they're answerable, rather than saying that we should keep them because we need to attract users. Because right now, I can't say I see the value in those questions. | @MattS. posted <http://data.stackexchange.com/pets/revision/241383/315568/question-votes-compared-to-its-views> in chat, in response to my request to look at votes in relation to visits.
If the best questions are the ones with the most up votes per visit. Said differently the questions that were up-voted by the largest percentage of people who read the question are presumably the best questions.
THAN: the best questions are the ones most specific to a small well defined group.
Disregarding the the highest one posted (27% approval rating) as it very new at the time of the survey. The questions with the highest approval ratings, are the ones focusing on specific issues relative to a small group.
Questions with 15%+ approval rating all have 100 or less visitors
Questions with 10-15% approval rating have 220 or less visitors
The first question with more than 300 views and a high approval rating is [Putting a cat into a carrier](https://pets.stackexchange.com/questions/251/putting-a-cat-into-a-carrier) with 461 views and 25 votes for an approval rating of 5%, again a very specific scenario
The first question with more than 1000 views is [How should I discipline my cat for bad behavior?](https://pets.stackexchange.com/questions/67) with 1040 views and 34 votes for a approval rating of 3%
\*Where first = highest approval rating per visits
It is clear from this perspective that the best questions are specific and clearly defined not general or undefined questions.
All the questions that attract the most visitors are those with titles that grab peoples attention, the actual content of the question has little to do with attracting visitors. [Famous Question](https://pets.stackexchange.com/help/badges/28/famous-question) & [Notable Question](https://pets.stackexchange.com/help/badges/27/notable-question)
Approval rating on questions with more than 10k views are going to be skewed, but the highest voted Famous Question is [Why is my dog drinking his pee after he urinates inside?](https://pets.stackexchange.com/questions/473) with 18 votes and 17K visits, again a very specific question with narrow defined parameters.
The example [Best small pet for a fairly small space in a bedroom](https://pets.stackexchange.com/questions/6688/) is posted by an OP that has not returned to the site since asking it, there is insufficient information to provided a good answer for the OP, and it is not narrow or focused enough to add value to anyone else.
The example [Help! My cat pees on everything!](https://pets.stackexchange.com/questions/6678) is also posted by an OP that has not returned, it got a quick answer that was very bad, and later a better answer. In hind site, we would have best served the community by putting it on hold sooner.
In conclusion just because a question can be answered, does not mean it adds value to the site or to the OP. Questions that are overly broad or with insufficient detail do not add value to the site, nor do they encourage visitors. I believe your assessment and conclusions in your question (or accusation) is incorrect.
**Edit November 3, 2015**
**Test Question**
An attempt was made with the question [What small pets should I consider for a preteen with limited space?](https://pets.stackexchange.com/questions/6694) to rephrase the "best small pet" question to narrow the scope as far as possible and make it as answerable as possible; it was rejected by the community (votes from 5 non-moderators) as to broad and opinion based. Note that this question is written by an individual currently in a moderator pro tem position, who has written over 100 question on the site with a vote of 1+. |
16,339,947 | I have developed an application with Netbeans (Using Java, JSP and JQuery) in Windows environment. Now I am ready to transfer the application to a web host so that the application can be available on the Web and I am told that the application would have to be moved to a linux environment (hosting service already bought). Here are my concerns:
* How to convert my code to Linux? Is there an automatic tool for this?
* How to deploy my application to the server online (what do I need to copy and to what directory on the web?)
* My application writes to a directory on c:drive on my laptop, what should I do to make the application write to correct directory a designated directory on the web server?
I have read here and there online but just haven't got specific solutions to this. | 2013/05/02 | [
"https://Stackoverflow.com/questions/16339947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1519100/"
] | >
> How to convert my code to Linux? Is there an automatic tool for this?
>
>
>
One of the Java key features is [portability](http://en.wikipedia.org/wiki/Software_portability), so as far as you haven't used any OS-specific code like running a program using CMD or similar or a library that is OS-dependant (which is rare in these times but there are some yet), then you don't have anything to do.
>
> How to deploy my application to the server online (what do I need to copy and to what directory on the web?)
>
>
>
You need to generate a [WAR file](http://en.wikipedia.org/wiki/WAR_file_format_%28Sun%29). This file will zip all your web pages (JSPs) and web resources (js, css, image files) along with the Java binaries (\*.class) and libraries (that must be on *WEB-INF/lib* folder).
Since you're working with NetBeans, here's a Q/A to generate the war file: [How can I create a war file of my project in NetBeans?](https://stackoverflow.com/q/1007346/1065197)
This war file must be placed in the deploy folder of your web application server. Usually, the hosting provides you the tools (generally a link on the web with user and password) to administrate the host, based on this you should ask (or find it by yourself) the option to upload the war file.
>
> My application writes to a directory on c:drive on my laptop, what should I do to make the application write to correct directory a designated directory on the web server?
>
>
>
You need to configure this path as a constant in your application, or even better, configure it in a properties file (or somewhere else) in order to be read and use it by your application easily. Remember that the path should be generic to be supported in almost every OS. For example, if you use a path with name
```
C:\some\path\for\files
```
Its generic form will be:
```
/some/path/for/files
```
Since you're going to work on Linux, make sure the user who executes the Tomcat (or the web application server you will use on production) have enough permissions to write on that folder. This can be easily done (and somebody here can fix this please) using the `chown` command:
```
#> chown -R user /some/path/for/files
```
Here's another Q/A to manage files and path on Java web applications: [How to provide relative path in File class to upload any file?](https://stackoverflow.com/q/6059453/1065197) | OK, first a few thoughts:
1. Convert code to Linux. Once you have your ear of war file, you can just deploy them. It's best if you use UTF8 enconding in your files, specially if you use special characters, but that would be an issue you could test out when you deploy, could also be dependant on the Linux configuration. Having that said, Java is portable and you only have to be sure that the archive you create is compatible with the AppServer that's installed on the Linux hosting. You should get all the information you need about the deployment environment from the hosting site / company.
2. Deployment will depend from site to site, they should give you all instructions.
3. Here you might have a problem. I would say that the easiest way is to just map the directory in a properties file and customize it on every machine you use it. That's the easy part so far. However, you should check if your site will give you access to a directory, and be aware of space limitations and cleanup of the files. If you get, let's say, 100MB and you use 10MB a day, you might end up with trouble after 10 days... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.