qid
int64 1
74.7M
| question
stringlengths 0
58.3k
| date
stringlengths 10
10
| metadata
sequence | response_j
stringlengths 2
48.3k
| response_k
stringlengths 2
40.5k
|
---|---|---|---|---|---|
34,041,384 | I created a setup by Advanced Installer software for my program that I've written by c#. I installed my program on VMWare Windows7.
When I try to run it this message is displayed:
 | 2015/12/02 | [
"https://Stackoverflow.com/questions/34041384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5394345/"
] | It would be a good idea to add a default case to your switch statement.
Example:
```
switch (monthNumber) {
case 1: monthString = "January";
break;
//other cases...
default: monthString = "Invalid Month Number";
break;
}
```
This way if `monthNumber` is not 1-12 then there is still a default case for the switch statement to flow to. | Because the designer of Java language believes it made more sense for it to be! Codes are easier to read when variables are initialised. A statement `String foo;` feels non-deterministic because you have to guess what's the default value of String is whereas `String foo = null;` is more deterministic.
To give you a more obvious example, consider this:
```
int x;
Int y;
```
Can you very quickly guess what the default values are? You probably have to pause for a few second to realize x is probably 0 and y is probably null |
34,041,384 | I created a setup by Advanced Installer software for my program that I've written by c#. I installed my program on VMWare Windows7.
When I try to run it this message is displayed:
 | 2015/12/02 | [
"https://Stackoverflow.com/questions/34041384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5394345/"
] | It would be a good idea to add a default case to your switch statement.
Example:
```
switch (monthNumber) {
case 1: monthString = "January";
break;
//other cases...
default: monthString = "Invalid Month Number";
break;
}
```
This way if `monthNumber` is not 1-12 then there is still a default case for the switch statement to flow to. | Local variables MUST always be initialized before use.
For Java 6, the compiler doesn't consider the **"Incomplete"** initialization of variables within flow control blocks and try-catch blocks. The initialization must be done for all cases:
**If - else**:
```
String s;
int a = 10;
if(a > 5){
s = "5";
}else{
System.out.println("");
}
System.out.println(s); // error if s isn't initialized within both if and else blocks
```
**While loop**:
```
String s;
int a = 10;
while(a > 0) {
s= ">0";
a--;
}
System.out.println(s);// error if s isn't initialized outside the while
```
**Try-Catch block**:
```
String s;
try {
s = "";
} catch (Exception e) {}
System.out.println(s);// error if s isn't initialized within both try and catch blocks
```
**Switch block**:
```
String s;
int a = 10;
switch (a) {
case 10:
s="10";
break;
default:
break;
}
System.out.println(s);// error if s isn't initialized all cases, default case included
```
Initialize the variable before the switch and all will be fine.
```
String monthString = "";
``` |
34,041,384 | I created a setup by Advanced Installer software for my program that I've written by c#. I installed my program on VMWare Windows7.
When I try to run it this message is displayed:
 | 2015/12/02 | [
"https://Stackoverflow.com/questions/34041384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5394345/"
] | May be this link will help to get proper understanding.
```
http://stackoverflow.com/questions/5478996/should-java-string-method-local-variables-be-initialized-to-null-or
``` | Local variables MUST always be initialized before use.
For Java 6, the compiler doesn't consider the **"Incomplete"** initialization of variables within flow control blocks and try-catch blocks. The initialization must be done for all cases:
**If - else**:
```
String s;
int a = 10;
if(a > 5){
s = "5";
}else{
System.out.println("");
}
System.out.println(s); // error if s isn't initialized within both if and else blocks
```
**While loop**:
```
String s;
int a = 10;
while(a > 0) {
s= ">0";
a--;
}
System.out.println(s);// error if s isn't initialized outside the while
```
**Try-Catch block**:
```
String s;
try {
s = "";
} catch (Exception e) {}
System.out.println(s);// error if s isn't initialized within both try and catch blocks
```
**Switch block**:
```
String s;
int a = 10;
switch (a) {
case 10:
s="10";
break;
default:
break;
}
System.out.println(s);// error if s isn't initialized all cases, default case included
```
Initialize the variable before the switch and all will be fine.
```
String monthString = "";
``` |
34,041,384 | I created a setup by Advanced Installer software for my program that I've written by c#. I installed my program on VMWare Windows7.
When I try to run it this message is displayed:
 | 2015/12/02 | [
"https://Stackoverflow.com/questions/34041384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5394345/"
] | Because the designer of Java language believes it made more sense for it to be! Codes are easier to read when variables are initialised. A statement `String foo;` feels non-deterministic because you have to guess what's the default value of String is whereas `String foo = null;` is more deterministic.
To give you a more obvious example, consider this:
```
int x;
Int y;
```
Can you very quickly guess what the default values are? You probably have to pause for a few second to realize x is probably 0 and y is probably null | Local variables MUST always be initialized before use.
For Java 6, the compiler doesn't consider the **"Incomplete"** initialization of variables within flow control blocks and try-catch blocks. The initialization must be done for all cases:
**If - else**:
```
String s;
int a = 10;
if(a > 5){
s = "5";
}else{
System.out.println("");
}
System.out.println(s); // error if s isn't initialized within both if and else blocks
```
**While loop**:
```
String s;
int a = 10;
while(a > 0) {
s= ">0";
a--;
}
System.out.println(s);// error if s isn't initialized outside the while
```
**Try-Catch block**:
```
String s;
try {
s = "";
} catch (Exception e) {}
System.out.println(s);// error if s isn't initialized within both try and catch blocks
```
**Switch block**:
```
String s;
int a = 10;
switch (a) {
case 10:
s="10";
break;
default:
break;
}
System.out.println(s);// error if s isn't initialized all cases, default case included
```
Initialize the variable before the switch and all will be fine.
```
String monthString = "";
``` |
34,041,384 | I created a setup by Advanced Installer software for my program that I've written by c#. I installed my program on VMWare Windows7.
When I try to run it this message is displayed:
 | 2015/12/02 | [
"https://Stackoverflow.com/questions/34041384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5394345/"
] | monthString is a local variable within main(), therefore, it must be initialized to prevent the compiler error.
If monthString were a Class variable then it does not have to be initialized explicitly.
You can do this by moving monthString outside of main() and declare it as:
static String monthString; | Local variables MUST always be initialized before use.
For Java 6, the compiler doesn't consider the **"Incomplete"** initialization of variables within flow control blocks and try-catch blocks. The initialization must be done for all cases:
**If - else**:
```
String s;
int a = 10;
if(a > 5){
s = "5";
}else{
System.out.println("");
}
System.out.println(s); // error if s isn't initialized within both if and else blocks
```
**While loop**:
```
String s;
int a = 10;
while(a > 0) {
s= ">0";
a--;
}
System.out.println(s);// error if s isn't initialized outside the while
```
**Try-Catch block**:
```
String s;
try {
s = "";
} catch (Exception e) {}
System.out.println(s);// error if s isn't initialized within both try and catch blocks
```
**Switch block**:
```
String s;
int a = 10;
switch (a) {
case 10:
s="10";
break;
default:
break;
}
System.out.println(s);// error if s isn't initialized all cases, default case included
```
Initialize the variable before the switch and all will be fine.
```
String monthString = "";
``` |
34,041,384 | I created a setup by Advanced Installer software for my program that I've written by c#. I installed my program on VMWare Windows7.
When I try to run it this message is displayed:
 | 2015/12/02 | [
"https://Stackoverflow.com/questions/34041384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5394345/"
] | May be this link will help to get proper understanding.
```
http://stackoverflow.com/questions/5478996/should-java-string-method-local-variables-be-initialized-to-null-or
``` | Because the designer of Java language believes it made more sense for it to be! Codes are easier to read when variables are initialised. A statement `String foo;` feels non-deterministic because you have to guess what's the default value of String is whereas `String foo = null;` is more deterministic.
To give you a more obvious example, consider this:
```
int x;
Int y;
```
Can you very quickly guess what the default values are? You probably have to pause for a few second to realize x is probably 0 and y is probably null |
34,041,384 | I created a setup by Advanced Installer software for my program that I've written by c#. I installed my program on VMWare Windows7.
When I try to run it this message is displayed:
 | 2015/12/02 | [
"https://Stackoverflow.com/questions/34041384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5394345/"
] | What if `monthNumber` is not between 1 and 12? In that case, `monthString` won't be initialized. You should give it some default value when you declare it :
```
String monthString = null; // or ""
``` | Because the designer of Java language believes it made more sense for it to be! Codes are easier to read when variables are initialised. A statement `String foo;` feels non-deterministic because you have to guess what's the default value of String is whereas `String foo = null;` is more deterministic.
To give you a more obvious example, consider this:
```
int x;
Int y;
```
Can you very quickly guess what the default values are? You probably have to pause for a few second to realize x is probably 0 and y is probably null |
7,032,562 | I need to create a INNO Setup script that will allow me to have a dialog, where the user can type in a serial number, then I need to save the serial number they entered into the Windows registry.
Also, if they don't enter a serial number, the next button needs to be disabled, so that they cannot proceed with the installation, if they do not enter a serial number.
Any help would be greatly appriceated.
Thanks! | 2011/08/11 | [
"https://Stackoverflow.com/questions/7032562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/416056/"
] | Here's a stripped down sample of what I use in my scripts. Also, take a look at the InnoSetup docs for CheckSerial (http://www.jrsoftware.org/ishelp/topic\_setup\_userinfopage.htm).
```
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "My Program"
#define MyAppVersion "1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "MyProg.exe"
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{6EAB4CDD-5D03-4EA1-BE97-7102D27CE955}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
[Registry]
Root: HKCU; Subkey: "Software\My Company"; Flags: uninsdeletekeyifempty
Root: HKCU; Subkey: "Software\My Company\My Program"; Flags: uninsdeletekey
Root: HKLM; Subkey: "Software\My Company"; Flags: uninsdeletekeyifempty
Root: HKLM; Subkey: "Software\My Company\My Program"; Flags: uninsdeletekey
Root: HKLM; Subkey: "Software\My Company\My Program\Settings"; ValueType: string; ValueName: "User"; ValueData: "{userinfoname}"
Root: HKLM; Subkey: "Software\My Company\My Program\Settings"; ValueType: string; ValueName: "SN"; ValueData: "{userinfoserial}"
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, "&", "&&")}}"; Flags: nowait postinstall skipifsilent
[Code]
function CheckSerial(Serial: String): Boolean;
var
sTrial : string;
sSerial : string;
begin
sTrial := 'trial';
sSerial := lowercase(Serial);
if (length(Serial) <> 25) AND (sTrial <> sSerial) then
Result := false
else
Result := true;
end;
``` | Inno can prompt the user for this information when you set the UserInfoPage=yes directivve.
If you add a CheckSerial event function, it will also ask for the registration details.
See the [UserInfoPage](http://www.jrsoftware.org/ishelp/topic_setup_userinfopage.htm) page in the help file for more details. |
53,514,700 | Table is given as
```
Food ID | Food Review
1 | good Review
1 | good Review
1 | Bad Review
2 | good Review
2 | Bad Review
3 | Good Review
```
and the Output expected is
```
Food ID | Good Review | All Review | Acceptance score
1 | 2 | 3 | 2/3
```
Acceptance score will be calculated as good Review/All Review
Can anyone please help me with the query ? | 2018/11/28 | [
"https://Stackoverflow.com/questions/53514700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10715741/"
] | Instead of setting the style in each click, [toggle](http://api.jquery.com/toggleclass/) the class `$( "#toogle_menu" ).toggleClass( "toggled" )` and style this class in css
```js
$("#toogle_menu").click(function() {
$("#jy_nav_pos_main").slideToggle("slow"),
$("#toogle_menu").toggleClass("toggled")
});
```
```css
.toggled {
transform: rotate(-90deg);
}
```
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul class="nav nav-tabs row margin_auto" id="jy_nav_pos_main" role="tablist">
......
</ul>
<button id="toogle_menu" class="btn btn-light">
»
</button>
``` | Try this..
```js
var clicked = false;
$("#toogle_menu").click(function() {
var deg = clicked ? 0 : -90;
$("#jy_nav_pos_main").slideToggle("slow"),
$("#toogle_menu").css({
transform: "rotate("+deg+"deg)"
});
clicked = !clicked;
});
```
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul class="nav nav-tabs row margin_auto" id="jy_nav_pos_main" role="tablist">
<li>menu</li>
</ul>
<button id="toogle_menu" class="btn btn-light">
»
</button>
``` |
53,514,700 | Table is given as
```
Food ID | Food Review
1 | good Review
1 | good Review
1 | Bad Review
2 | good Review
2 | Bad Review
3 | Good Review
```
and the Output expected is
```
Food ID | Good Review | All Review | Acceptance score
1 | 2 | 3 | 2/3
```
Acceptance score will be calculated as good Review/All Review
Can anyone please help me with the query ? | 2018/11/28 | [
"https://Stackoverflow.com/questions/53514700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10715741/"
] | Instead of setting the style in each click, [toggle](http://api.jquery.com/toggleclass/) the class `$( "#toogle_menu" ).toggleClass( "toggled" )` and style this class in css
```js
$("#toogle_menu").click(function() {
$("#jy_nav_pos_main").slideToggle("slow"),
$("#toogle_menu").toggleClass("toggled")
});
```
```css
.toggled {
transform: rotate(-90deg);
}
```
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul class="nav nav-tabs row margin_auto" id="jy_nav_pos_main" role="tablist">
......
</ul>
<button id="toogle_menu" class="btn btn-light">
»
</button>
``` | try this...
```
<style type="text/css">
.nav{
display: none;
}
.rotate{
transform: rotate(90deg);
-webkit-transform:rotate(90deg);
-moz-transform:rotate(90deg);
-o-transform:rotate(90deg);
-ms-transform:rotate(90deg);
transition: all 0.4s linear;
}
#clickBtn span{
transition: all 0.4s linear;
}
</style>
<button type="button" id="clickBtn">Click <span class="fa fa-angle-right"></span></button>
<ul class="nav nav-tabs row margin_auto" id="jy_nav_pos_main" role="tablist">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
</ul>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#clickBtn").on('click',function(){
$(this).find('span').toggleClass('rotate');
$(".nav").slideToggle();
});
});
</script>
``` |
8,377,312 | What is the most direct way to convert a symlink into a regular file (i.e. a copy of the symlink target)?
Suppose `filename` is a symlink to `target`. The obvious procedure to turn it into a copy is:
```
cp filename filename-backup
rm filename
mv filename-backup filename
```
Is there a more direct way (i.e. a single command)? | 2011/12/04 | [
"https://Stackoverflow.com/questions/8377312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/462335/"
] | There is no single command to convert a symlink to a regular file. The most direct way is to use `readlink` to find the file a symlink points to, and then copy that file over the symlink:
```
cp --remove-destination `readlink bar.pdf` bar.pdf
```
Of course, if `bar.pdf` is, in fact, a regular file to begin with, then this will clobber the file. Some sanity checking would therefore be advisable. | Change all file.txt from link into file.
```sh
for f in *.txt; do echo $(readlink $f) $f | awk '{print "rsync -L "$1" "$2}'; done | bash
``` |
8,377,312 | What is the most direct way to convert a symlink into a regular file (i.e. a copy of the symlink target)?
Suppose `filename` is a symlink to `target`. The obvious procedure to turn it into a copy is:
```
cp filename filename-backup
rm filename
mv filename-backup filename
```
Is there a more direct way (i.e. a single command)? | 2011/12/04 | [
"https://Stackoverflow.com/questions/8377312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/462335/"
] | There is no single command to convert a symlink to a regular file. The most direct way is to use `readlink` to find the file a symlink points to, and then copy that file over the symlink:
```
cp --remove-destination `readlink bar.pdf` bar.pdf
```
Of course, if `bar.pdf` is, in fact, a regular file to begin with, then this will clobber the file. Some sanity checking would therefore be advisable. | Rsync can nativly deference the symlink for you using -L flag.
```
[user@workstation ~]$ rsync -h | grep -- -L
-L, --copy-links transform symlink into referent file/dir
```
It would be as simple as: `rsync -L <symlink> <destination>` |
8,377,312 | What is the most direct way to convert a symlink into a regular file (i.e. a copy of the symlink target)?
Suppose `filename` is a symlink to `target`. The obvious procedure to turn it into a copy is:
```
cp filename filename-backup
rm filename
mv filename-backup filename
```
Is there a more direct way (i.e. a single command)? | 2011/12/04 | [
"https://Stackoverflow.com/questions/8377312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/462335/"
] | On OSX
>
> rsync `readlink bar.pdf` bar.pdf
>
>
> | Rsync can nativly deference the symlink for you using -L flag.
```
[user@workstation ~]$ rsync -h | grep -- -L
-L, --copy-links transform symlink into referent file/dir
```
It would be as simple as: `rsync -L <symlink> <destination>` |
8,377,312 | What is the most direct way to convert a symlink into a regular file (i.e. a copy of the symlink target)?
Suppose `filename` is a symlink to `target`. The obvious procedure to turn it into a copy is:
```
cp filename filename-backup
rm filename
mv filename-backup filename
```
Is there a more direct way (i.e. a single command)? | 2011/12/04 | [
"https://Stackoverflow.com/questions/8377312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/462335/"
] | Just a rehash of other's answers, but adding the "sanity check" to ensure the link passed in is actually a symbolic link:
```
removelink() {
[ -L "$1" ] && cp --remove-destination "$(readlink "$1")" "$1"
}
```
This is saying that if the file is a symbolic link, then run the copy command. | Another approach if you find yourself doing this often is adapting kbrock's answer into a shell script and putting it into /usr/bin/. Something along the lines of:
```
if [ $# -ne 1 ]
then
echo "Usage: $0 filename"
exit 1
fi
[ -L "$1" ] && cp --remove-destination "$(readlink "$1")" "$1"
```
chmod +x it, and then just run it as a normal command. |
8,377,312 | What is the most direct way to convert a symlink into a regular file (i.e. a copy of the symlink target)?
Suppose `filename` is a symlink to `target`. The obvious procedure to turn it into a copy is:
```
cp filename filename-backup
rm filename
mv filename-backup filename
```
Is there a more direct way (i.e. a single command)? | 2011/12/04 | [
"https://Stackoverflow.com/questions/8377312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/462335/"
] | Many have already stated the following solution:
```
cp --remove-destination `readlink file` file
```
However, this will not work on symbolically linked directories.
Adding a **recursive** and **force** will not work either:
```
cp -rf --remove-destination `readlink file` file
```
**cp: cannot copy a directory, ‘path/file, into itself, ‘file’**
Therefore, it is probably safer to delete the symlink entirely first:
```
resolve-symbolic-link() {
if [ -L $1 ]; then
temp="$(readlink "$1")";
rm -rf "$1";
cp -rf "$temp" "$1";
fi
}
```
Not exactly a one-liner like you had hoped, but put this it into your shell environment, and it can be. | This worked perfectly for me (**edited to work with spaces**):
```
find . -type l | while read f; do /bin/cp -rf --remove-destination -f $(find . -name $(readlink "${f}")) "${f}";done;
```
Allows you to recursively convert all symlinks under the current working folder to its regular file. Also doesn't ask you to overwrite. the "/bin/cp" exists so that you can bypass a possible cp -i alias on your OS which prevents the "-rf" from working. |
8,377,312 | What is the most direct way to convert a symlink into a regular file (i.e. a copy of the symlink target)?
Suppose `filename` is a symlink to `target`. The obvious procedure to turn it into a copy is:
```
cp filename filename-backup
rm filename
mv filename-backup filename
```
Is there a more direct way (i.e. a single command)? | 2011/12/04 | [
"https://Stackoverflow.com/questions/8377312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/462335/"
] | On OSX
>
> rsync `readlink bar.pdf` bar.pdf
>
>
> | This solution works with symlink files and symlink folders/subfolders.
One line, no script needed.
This would be ideal to export or transfer symlinks elsewhere.
Put everything inside a folder.
rsync --archive --copy-links --recursive folderContainingSymlinkFilesAndSymlinkFoldersAndSubfolders myNewFolder |
8,377,312 | What is the most direct way to convert a symlink into a regular file (i.e. a copy of the symlink target)?
Suppose `filename` is a symlink to `target`. The obvious procedure to turn it into a copy is:
```
cp filename filename-backup
rm filename
mv filename-backup filename
```
Is there a more direct way (i.e. a single command)? | 2011/12/04 | [
"https://Stackoverflow.com/questions/8377312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/462335/"
] | ```
for f in $(find -type l);do cp --remove-destination $(readlink $f) $f;done;
```
* Check symlinks in the current directory and subdirectories `find -type l`
* Get the linked file path `readlink $f`
* Remove symlink and copy the file `cp --remove-destination $(readlink $f) $f` | On OSX
>
> rsync `readlink bar.pdf` bar.pdf
>
>
> |
8,377,312 | What is the most direct way to convert a symlink into a regular file (i.e. a copy of the symlink target)?
Suppose `filename` is a symlink to `target`. The obvious procedure to turn it into a copy is:
```
cp filename filename-backup
rm filename
mv filename-backup filename
```
Is there a more direct way (i.e. a single command)? | 2011/12/04 | [
"https://Stackoverflow.com/questions/8377312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/462335/"
] | There is no single command to convert a symlink to a regular file. The most direct way is to use `readlink` to find the file a symlink points to, and then copy that file over the symlink:
```
cp --remove-destination `readlink bar.pdf` bar.pdf
```
Of course, if `bar.pdf` is, in fact, a regular file to begin with, then this will clobber the file. Some sanity checking would therefore be advisable. | in case of "relative" symlinks you could add a awk statement to @jared answer:
```
for f in $(find . -type l); do /bin/cp -rf --remove-destination -f $(find . \! -type l -name $(readlink $f | awk -F"../" '{print $NF}')) $f;done;
```
If you have symlinks pointing to directories you need to use a more radical approach because cp --remove-destination does not work together with symlinks directories correctly
```
for f in `find . -type l`; do (cd `dirname $f`; target=`basename $f`; source=`readlink $target` ; rm -rf $target && cp -r $source $target); done
```
For sure this could be written with less overhead. but it is quite good to read in my opinion. |
8,377,312 | What is the most direct way to convert a symlink into a regular file (i.e. a copy of the symlink target)?
Suppose `filename` is a symlink to `target`. The obvious procedure to turn it into a copy is:
```
cp filename filename-backup
rm filename
mv filename-backup filename
```
Is there a more direct way (i.e. a single command)? | 2011/12/04 | [
"https://Stackoverflow.com/questions/8377312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/462335/"
] | Just a rehash of other's answers, but adding the "sanity check" to ensure the link passed in is actually a symbolic link:
```
removelink() {
[ -L "$1" ] && cp --remove-destination "$(readlink "$1")" "$1"
}
```
This is saying that if the file is a symbolic link, then run the copy command. | There's no single command. But if you don't want a copy and all you want is another reference, you can replace the symlink with a link (aka "hard link"). This only works if they're on the same partition, BTW.
```
rm filename
ln target filename
``` |
8,377,312 | What is the most direct way to convert a symlink into a regular file (i.e. a copy of the symlink target)?
Suppose `filename` is a symlink to `target`. The obvious procedure to turn it into a copy is:
```
cp filename filename-backup
rm filename
mv filename-backup filename
```
Is there a more direct way (i.e. a single command)? | 2011/12/04 | [
"https://Stackoverflow.com/questions/8377312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/462335/"
] | For text files the `sed` command can do this in one line if you pass it the *in-place* switch (`-i`). This is because `sed` does a single pass over a file, cats the output into a temporary file which it subsequently renames to match the original.
Just do an inline `sed` with no transforms:
```
sed -i ';' /path/to/symbolic/link
``` | On OSX
>
> rsync `readlink bar.pdf` bar.pdf
>
>
> |
1,475,551 | I'm trying to use the pigeonhole principle to prove that
>
> if $S$ is a subset of the power set of the first $n$ positive integers, and if $S$ has at least $2^{n-1}+1$ elements, then $S$ must contain a pair of pairwise disjoint sets.
>
>
>
I've been playing around with a small set $\{1,2,3\}$ and I can see the theorem seems to be true in this case. But I can't see, for instance, how to construct the pigeonholes so that $\{2\}$ and $\{3\}$, for instance, end up in the same pigeonhole. I've been looking at which subsets of the power set the elements in $S$ do NOT contain, to no avail.
Can someone give me a hint about which pigeonholes to look at?
I'm adding this in response to the comments below: Demonstrate that it is possible for |S| (i.e., the number of subsets of {1, . . . , n} contained as elements of S ) to equal 2n−1 without any two elements of S being disjoint from each other. I can do this. This provides context. | 2015/10/11 | [
"https://math.stackexchange.com/questions/1475551",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/274450/"
] | Given $S \subseteq \mathcal{P}(n)$ with $|S| \ge 2^{n-1} + 1$, suppose $S$ does not contain a disjoint pair of sets. Let $T = \{n \setminus X \mid X \in S\}$. Then $S, T$ are disjoint subsets of $\mathcal{P}(n)$ having the same cardinality ($X \mapsto (n \setminus X)$ bijects $S \leftrightarrow T$), so:
$$
\begin{align}
|S \cup T| &= |S| + |T| \\
&= 2 |S| \\
&\ge 2(2^{n-1} + 1) \\
&= 2^n + 2
\end{align}
$$
which can't be.
This isn't quite a proof by pigenhole, but maybe it is if you squint. | Try this: there are always as many even-cardinality subsets of a set as there are odd-numbered subsets. Use even-cardinality subsets and odd-cardinality subsets as your pigeonholes. |
33,517,232 | In my app I have a controller that takes a user input consisting of a twitter handle from one view and passes it along through my controller into my factory where it is sent through to my backend code where some API calls are made and ultimately I want to get an image url returned.
I am able to get the image url back from my server but I have been having a whale of a time trying to append it another view. I've tried messing around with $scope and other different suggestions I've found on here but I still can't get it to work.
I've tried doing different things to try and get the pic to be interpolated into the html view. I've tried injecting $scope and playing around with that and still no dice. I'm trying not to use $scope because from what I understand it is better to not abuse $scope and use instead `this` and a controller alias (`controllerAs`) in the view.
I can verify that the promise returned in my controller is the imageUrl that I want to display in my view but I don't know where I'm going wrong.
My controller code:
```
app.controller('TwitterInputController', ['twitterServices', function (twitterServices) {
this.twitterHandle = null;
// when user submits twitter handle getCandidateMatcPic calls factory function
this.getCandidateMatchPic = function () {
twitterServices.getMatchWithTwitterHandle(this.twitterHandle)
.then(function (pic) {
// this.pic = pic
// console.log(this.pic)
console.log('AHA heres the picUrl:', pic);
return this.pic;
});
};
}]);
```
Here is my factory code:
```
app.factory('twitterServices', function ($http) {
var getMatchWithTwitterHandle = function (twitterHandle) {
return $http({
method: 'GET',
url: '/api/twitter/' + twitterHandle
})
.then(function (response) {
return response.data.imageUrl;
});
};
return {
getMatchWithTwitterHandle: getMatchWithTwitterHandle,
};
});
```
this is my app.js
```
var app = angular.module('druthers', ['ui.router']);
app.config(function ($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/');
$stateProvider
.state('/', {
url: '/',
templateUrl: 'index.html',
controller: 'IndexController',
controllerAs: 'index',
views: {
'twitter-input': {
templateUrl: 'app/views/twitter-input.html',
controller: 'TwitterInputController',
controllerAs: 'twitterCtrl'
},
'candidate-pic': {
templateUrl: 'app/views/candidate-pic.html',
controller: 'TwitterInputController',
controllerAs: 'twitterCtrl'
}
}
});
});
```
Here is the view where I want to append the returned image url
```
<div class="col-md-8">
<img class="featurette-image img-circle" ng-src="{{twitterCtrl.pic}}"/>
</div>
``` | 2015/11/04 | [
"https://Stackoverflow.com/questions/33517232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4699240/"
] | You find that convention in [Karma](http://karma-runner.github.io/0.13/dev/git-commit-msg.html)
```
<type>(<scope>): <subject>
<body>
<footer>
```
It can help for:
* automatic generation of the changelog
* simple navigation through git history (eg. ignoring style changes)
Karma's convention include:
>
> Allowed `<type>` values:
>
>
> * feat (new feature for the user, not a new feature for build script)
> * fix (bug fix for the user, not a fix to a build script)
> * docs (changes to the documentation)
> * style (formatting, missing semi colons, etc; no production code change)
> * refactor (refactoring production code, eg. renaming a variable)
> * test (adding missing tests, refactoring tests; no production code change)
> * chore (updating grunt tasks etc; no production code change)
>
>
> Example `<scope>` values:
>
>
> * init
> * runner
> * watcher
> * config
> * web-server
> * proxy
> * etc.
>
>
>
---
Note: a git commit message should not start with blank lines or empty lines.
It is not illegal, but with git 2.10 (Q3 2016), such lines will be trimmed by default for certain operations.
See [commit 054a5ae](https://github.com/git/git/commit/054a5aee6f3e8e90d96f7b3f76f5f55752561c59), [commit 88ef402](https://github.com/git/git/commit/88ef402f9c18dafee5c8b222200f8f984b17a73e), [commit 84e213a](https://github.com/git/git/commit/84e213a30a1d4a3835e23b2f3d6217eb74ea55f7), [commit 84e213a](https://github.com/git/git/commit/84e213a30a1d4a3835e23b2f3d6217eb74ea55f7) (29 Jun 2016), [commit 88ef402](https://github.com/git/git/commit/88ef402f9c18dafee5c8b222200f8f984b17a73e), [commit 84e213a](https://github.com/git/git/commit/84e213a30a1d4a3835e23b2f3d6217eb74ea55f7) (29 Jun 2016), [commit 84e213a](https://github.com/git/git/commit/84e213a30a1d4a3835e23b2f3d6217eb74ea55f7) (29 Jun 2016), and [commit 4e1b06d](https://github.com/git/git/commit/4e1b06da252a7609f0c6641750e6acbec451e698), [commit 7735612](https://github.com/git/git/commit/77356122443039b4b65a7795d66b3d1fdeedcce8) (22 Jun 2016) by [Johannes Schindelin (`dscho`)](https://github.com/dscho).
(Merged by [Junio C Hamano -- `gitster` --](https://github.com/gitster) in [commit 62e5e83](https://github.com/git/git/commit/62e5e83f8dfc98e182a1ca3a48b2c69f4fd417ce), 11 Jul 2016)
>
> `reset --hard`: skip blank lines when reporting the commit subject
> ------------------------------------------------------------------
>
>
> When there are blank lines at the beginning of a commit message, the
> pretty printing machinery already skips them when showing a commit
> subject (or the complete commit message).
>
> We shall henceforth do the
> same when reporting the commit subject after the user called
>
>
>
```
git reset --hard <commit>
```
>
> `commit -C`: skip blank lines at the beginning of the message
> -------------------------------------------------------------
>
>
>
(that is when you take an existing commit object, and reuse the log message and the authorship information (including the timestamp) when creating the commit)
>
> Consistent with the pretty-printing machinery, we skip leading blank
> lines (if any) of existing commit messages.
>
>
> While Git itself only produces commit objects with a single empty line
> between commit header and commit message, it is legal to have more than
> one blank line (i.e. lines containing only white space, or no
> characters) at the beginning of the commit message, and the
> pretty-printing code already handles that.
>
>
> `commit.c`: make [`find_commit_subject()`](https://github.com/git/git/blob/4e1b06da252a7609f0c6641750e6acbec451e698/commit.c#L393) more robust
> ----------------------------------------------------------------------------------------------------------------------------------------------
>
>
> Just like the pretty printing machinery, we should simply ignore
> blank lines at the beginning of the commit messages.
>
>
> This discrepancy was noticed when an early version of the
> `rebase--helper` produced commit objects with more than one empty line
> between the header and the commit message.
>
>
> | Those commit messages follow the Conventional Commits specification: <https://www.conventionalcommits.org/en/v1.0.0/> |
4,153,421 | How can an Eclipse bundle (eg. within activator code) find the dependent Bundle instances at runtime? I would like to find the bundles that Eclipse has choosen to satisfy the dependency requirements, I do not want to interprete the manifest myself.
An example: I would like to find all resources named "marker.txt" in all bundles on which my current bundle depends upon. Also the transitive dependencies. In order to accomplish this I need to be able to find all these bundles to begin with. | 2010/11/11 | [
"https://Stackoverflow.com/questions/4153421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4900/"
] | Please see my answer to [this question](https://stackoverflow.com/questions/3906222/printing-osgi-bundle-classpath/4143048). 4.3 will have a new bundle wiring API that will allow things like this. | You can open an OSGi console and issue the following commands:
```
ss
```
To the the list of bundles, including the numeric id
```
bundle <id>
```
to get more information, including dependencies.
You should also try
```
help
```
to get more commands |
4,153,421 | How can an Eclipse bundle (eg. within activator code) find the dependent Bundle instances at runtime? I would like to find the bundles that Eclipse has choosen to satisfy the dependency requirements, I do not want to interprete the manifest myself.
An example: I would like to find all resources named "marker.txt" in all bundles on which my current bundle depends upon. Also the transitive dependencies. In order to accomplish this I need to be able to find all these bundles to begin with. | 2010/11/11 | [
"https://Stackoverflow.com/questions/4153421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4900/"
] | There is no easy way to determine the dependency.
The best way is to go through the PackageAdmin interface. See the OSGi spec for PackageAdmin and getImportingBundles in particular: [http://www.osgi.org/javadoc/r4v42/org/osgi/service/packageadmin/ExportedPackage.html#getImportingBundles()](http://www.osgi.org/javadoc/r4v42/org/osgi/service/packageadmin/ExportedPackage.html#getImportingBundles%28%29)
You need to determine for all installed bundles, which one exports one or more packages that your bundle is importing. The easiest way to achieve this is to call *PackageAdmin.getExportedPackages(Bundle bundle)* with bundles = *null*. This returns an array of all exported packages. You then need to iterate of this array and call *ExportPackage.getImportingBundles()*. | You can open an OSGi console and issue the following commands:
```
ss
```
To the the list of bundles, including the numeric id
```
bundle <id>
```
to get more information, including dependencies.
You should also try
```
help
```
to get more commands |
4,153,421 | How can an Eclipse bundle (eg. within activator code) find the dependent Bundle instances at runtime? I would like to find the bundles that Eclipse has choosen to satisfy the dependency requirements, I do not want to interprete the manifest myself.
An example: I would like to find all resources named "marker.txt" in all bundles on which my current bundle depends upon. Also the transitive dependencies. In order to accomplish this I need to be able to find all these bundles to begin with. | 2010/11/11 | [
"https://Stackoverflow.com/questions/4153421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4900/"
] | There is no easy way to determine the dependency.
The best way is to go through the PackageAdmin interface. See the OSGi spec for PackageAdmin and getImportingBundles in particular: [http://www.osgi.org/javadoc/r4v42/org/osgi/service/packageadmin/ExportedPackage.html#getImportingBundles()](http://www.osgi.org/javadoc/r4v42/org/osgi/service/packageadmin/ExportedPackage.html#getImportingBundles%28%29)
You need to determine for all installed bundles, which one exports one or more packages that your bundle is importing. The easiest way to achieve this is to call *PackageAdmin.getExportedPackages(Bundle bundle)* with bundles = *null*. This returns an array of all exported packages. You then need to iterate of this array and call *ExportPackage.getImportingBundles()*. | Please see my answer to [this question](https://stackoverflow.com/questions/3906222/printing-osgi-bundle-classpath/4143048). 4.3 will have a new bundle wiring API that will allow things like this. |
49,508 | StackExchange uses "Tags" which I feel might be more geared towards a tech-savvy audience.
For the mainstream users, do you think "Tags" works or would they understand "Topics" better? | 2013/12/29 | [
"https://ux.stackexchange.com/questions/49508",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/39300/"
] | Topic could be used, but it would be wrong. A topic is an information structure which has relations to other topics and is often governed by some kind of authority. Tags are a folksonomy driven information entity, which has no authority and is governed by all users. Everyone in a community participates in the creation of tags, which is the very core of Stackexchange sites.
>
> ...topic is used to describe the information structure, or pragmatic structure of a clause and how it coheres with other clauses...
>
>
>
Source: Wikipedia [Topic](http://en.wikipedia.org/wiki/Topic_%28linguistics%29)
I think it would be wrong to use the wrong words for our labels. We're all here since we love to learn, the right way. | I say "topics". Whenever possible use the most common language you can. "Tags" may be more meaningful to the technologically elite, but usually there's no useful reason to exclude the plebeians.
While I agree with Benny Skogberg's contention that "Topic" has a different meaning than "Tag", the benefits of that precision are lost on someone that doesn't understand what "Tag" means. In fact the definition of "tag" used here at stackexchange might not be the precisely the same as used in other sites, and given that the utility of the precision comes into question.
In general there's a lot of confusion around terms like "tag", and "keyword" and "search term", etc.
In short I think, at least in the context of the stackexchanges, using the term "topics" in place of "tags" would reduce confusion. |
32,264,571 | I am new to Elastic search . Please help me in finding the filter/query to be written to match the exact records using Java API.
```
Below is the mongodb record .I need to get both the record matching the word 'Jerry' using elastic search.
{
"searchcontent" : [
{
"key" : "Jerry",
"sweight" : "1"
},{
"key" : "Kate",
"sweight" : "1"
},
],
"contentId" : "CON_4",
"keyword" : "TEST",
"_id" : ObjectId("55ded619e4b0406bbd901a47")
},
{
"searchcontent" : [
{
"key" : "TOM",
"sweight" : "2"
},{
"key" : "Kruse",
"sweight" : "2"
}
],
"contentId" : "CON_3",
"keyword" : "Jerry",
"_id" : ObjectId("55ded619e4b0406ccd901a47")
}
``` | 2015/08/28 | [
"https://Stackoverflow.com/questions/32264571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3440746/"
] | A [Multi-Match](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html) query is what you need to search across multiple fields. Below query will search for the word "jerry" in both the fields "searchcontent.key" and "keyword" which is what you want.
```
POST <index name>/<type name>/_search
{
"query": {
"multi_match": {
"query": "jerry",
"fields": [
"searchcontent.key",
"keyword"
]
}
}
}
``` | There is no single solution, it depends how you map your data in elastic search and what you are indexing
GET /intu/\_settings
You can use: **query string**.
If you don't need to combine filter you can remove bool and should.
From the documentation: *"The bool query takes a more-matches-is-better approach, so the score from each matching must or should clause will be added together to provide the final \_score for each document."*
For example:
```
GET /yourstaff/_search
{
"query": {
"filtered": {
"query": {
"bool": {
"should":
{
"query_string": {
"query": "jerry"
}
}
}
}
}
}
}
```
Take a look to the documentation:
* [Query string](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax "Query string")
* [Term vs full-search](https://www.elastic.co/guide/en/elasticsearch/guide/current/term-vs-full-text.html)
* [Bool query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html)
Use [Sense](https://chrome.google.com/webstore/detail/sense-beta/lhjgkmllcaadmopgmanpapmpjgmfcfig?hl=en) to figure out what results you want to have |
32,264,571 | I am new to Elastic search . Please help me in finding the filter/query to be written to match the exact records using Java API.
```
Below is the mongodb record .I need to get both the record matching the word 'Jerry' using elastic search.
{
"searchcontent" : [
{
"key" : "Jerry",
"sweight" : "1"
},{
"key" : "Kate",
"sweight" : "1"
},
],
"contentId" : "CON_4",
"keyword" : "TEST",
"_id" : ObjectId("55ded619e4b0406bbd901a47")
},
{
"searchcontent" : [
{
"key" : "TOM",
"sweight" : "2"
},{
"key" : "Kruse",
"sweight" : "2"
}
],
"contentId" : "CON_3",
"keyword" : "Jerry",
"_id" : ObjectId("55ded619e4b0406ccd901a47")
}
``` | 2015/08/28 | [
"https://Stackoverflow.com/questions/32264571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3440746/"
] | A [Multi-Match](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html) query is what you need to search across multiple fields. Below query will search for the word "jerry" in both the fields "searchcontent.key" and "keyword" which is what you want.
```
POST <index name>/<type name>/_search
{
"query": {
"multi_match": {
"query": "jerry",
"fields": [
"searchcontent.key",
"keyword"
]
}
}
}
``` | Using filter is a better option as it caches the results..
```
{
"query":
{
"bool":
{
"should":
[
{
"term":
{
"searchcontent.key":"jerry"
}
},
{
"term":
{
"keyword":"jerry"
}
}
]
}
}
}
```
<https://www.elastic.co/blog/found-optimizing-elasticsearch-searches>
A suggested read for better search. |
32,264,571 | I am new to Elastic search . Please help me in finding the filter/query to be written to match the exact records using Java API.
```
Below is the mongodb record .I need to get both the record matching the word 'Jerry' using elastic search.
{
"searchcontent" : [
{
"key" : "Jerry",
"sweight" : "1"
},{
"key" : "Kate",
"sweight" : "1"
},
],
"contentId" : "CON_4",
"keyword" : "TEST",
"_id" : ObjectId("55ded619e4b0406bbd901a47")
},
{
"searchcontent" : [
{
"key" : "TOM",
"sweight" : "2"
},{
"key" : "Kruse",
"sweight" : "2"
}
],
"contentId" : "CON_3",
"keyword" : "Jerry",
"_id" : ObjectId("55ded619e4b0406ccd901a47")
}
``` | 2015/08/28 | [
"https://Stackoverflow.com/questions/32264571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3440746/"
] | And if you would like to search in all the fields.
Then you can just do a match \_all query,
```
POST <index name>/<type name>/_search.
{
"query": {
"match" : {
"_all" : "Jerry"
}
}
}
```
This searches for 'Jerry' in all the fields. | There is no single solution, it depends how you map your data in elastic search and what you are indexing
GET /intu/\_settings
You can use: **query string**.
If you don't need to combine filter you can remove bool and should.
From the documentation: *"The bool query takes a more-matches-is-better approach, so the score from each matching must or should clause will be added together to provide the final \_score for each document."*
For example:
```
GET /yourstaff/_search
{
"query": {
"filtered": {
"query": {
"bool": {
"should":
{
"query_string": {
"query": "jerry"
}
}
}
}
}
}
}
```
Take a look to the documentation:
* [Query string](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax "Query string")
* [Term vs full-search](https://www.elastic.co/guide/en/elasticsearch/guide/current/term-vs-full-text.html)
* [Bool query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html)
Use [Sense](https://chrome.google.com/webstore/detail/sense-beta/lhjgkmllcaadmopgmanpapmpjgmfcfig?hl=en) to figure out what results you want to have |
32,264,571 | I am new to Elastic search . Please help me in finding the filter/query to be written to match the exact records using Java API.
```
Below is the mongodb record .I need to get both the record matching the word 'Jerry' using elastic search.
{
"searchcontent" : [
{
"key" : "Jerry",
"sweight" : "1"
},{
"key" : "Kate",
"sweight" : "1"
},
],
"contentId" : "CON_4",
"keyword" : "TEST",
"_id" : ObjectId("55ded619e4b0406bbd901a47")
},
{
"searchcontent" : [
{
"key" : "TOM",
"sweight" : "2"
},{
"key" : "Kruse",
"sweight" : "2"
}
],
"contentId" : "CON_3",
"keyword" : "Jerry",
"_id" : ObjectId("55ded619e4b0406ccd901a47")
}
``` | 2015/08/28 | [
"https://Stackoverflow.com/questions/32264571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3440746/"
] | And if you would like to search in all the fields.
Then you can just do a match \_all query,
```
POST <index name>/<type name>/_search.
{
"query": {
"match" : {
"_all" : "Jerry"
}
}
}
```
This searches for 'Jerry' in all the fields. | Using filter is a better option as it caches the results..
```
{
"query":
{
"bool":
{
"should":
[
{
"term":
{
"searchcontent.key":"jerry"
}
},
{
"term":
{
"keyword":"jerry"
}
}
]
}
}
}
```
<https://www.elastic.co/blog/found-optimizing-elasticsearch-searches>
A suggested read for better search. |
36,303,051 | This is main.axml file.
```
`<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/myListView" />
</LinearLayout>`
```
And this is the MainActivity.cs file :
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
```
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
Glop = new List<string>();
Glop.Add("Tom");
Glop.Add("Dick");
Glop.Add("Harry");
Name = FindViewById<ListView>(Resource.Id.myListView);
}
```
I am trying to create a Listview in Xamarin Android.
I have changed the android Id to myListView and also have tried to rebuild the app but it still shows as an error . What should I do now ? | 2016/03/30 | [
"https://Stackoverflow.com/questions/36303051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6133463/"
] | Try rebuilding the app again and saving the main.axml file .
* Build > Clean Solution
* Build Solution | Adjust properties for resource file like here:
[](https://i.stack.imgur.com/2hMr1.png) |
36,303,051 | This is main.axml file.
```
`<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/myListView" />
</LinearLayout>`
```
And this is the MainActivity.cs file :
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
```
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
Glop = new List<string>();
Glop.Add("Tom");
Glop.Add("Dick");
Glop.Add("Harry");
Name = FindViewById<ListView>(Resource.Id.myListView);
}
```
I am trying to create a Listview in Xamarin Android.
I have changed the android Id to myListView and also have tried to rebuild the app but it still shows as an error . What should I do now ? | 2016/03/30 | [
"https://Stackoverflow.com/questions/36303051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6133463/"
] | **For Visual Studio Community 2019 Preview (V 16.0.0, Pr 5.0):**
For this problem and a lot of the problem with the designer I have to repeatedly do the following:
* Save all documents and close VS.
* Navigate to the project folder in your file browser
* Delete (or rename, if you're paranoid) the "obj" and "bin" folders
* Relaunch VS and try the designer again.
With this version (granted, it's still beta) running a clean on the project with the designer open will cause access permission errors that can be corrected with these steps. | Option 1) Make sure update the Xamarin.Android (Tools>Options>Xamarin>Other>Check Now)
Option 2) Run VS as Administrator and Build>Clean and Rebuild the solution.
For my case option 1 did work. [](https://i.stack.imgur.com/BlUXf.png) |
36,303,051 | This is main.axml file.
```
`<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/myListView" />
</LinearLayout>`
```
And this is the MainActivity.cs file :
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
```
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
Glop = new List<string>();
Glop.Add("Tom");
Glop.Add("Dick");
Glop.Add("Harry");
Name = FindViewById<ListView>(Resource.Id.myListView);
}
```
I am trying to create a Listview in Xamarin Android.
I have changed the android Id to myListView and also have tried to rebuild the app but it still shows as an error . What should I do now ? | 2016/03/30 | [
"https://Stackoverflow.com/questions/36303051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6133463/"
] | **For Visual Studio Community 2019 Preview (V 16.0.0, Pr 5.0):**
For this problem and a lot of the problem with the designer I have to repeatedly do the following:
* Save all documents and close VS.
* Navigate to the project folder in your file browser
* Delete (or rename, if you're paranoid) the "obj" and "bin" folders
* Relaunch VS and try the designer again.
With this version (granted, it's still beta) running a clean on the project with the designer open will cause access permission errors that can be corrected with these steps. | 1)Build -> Clean Solution
2)Build Solution |
36,303,051 | This is main.axml file.
```
`<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/myListView" />
</LinearLayout>`
```
And this is the MainActivity.cs file :
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
```
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
Glop = new List<string>();
Glop.Add("Tom");
Glop.Add("Dick");
Glop.Add("Harry");
Name = FindViewById<ListView>(Resource.Id.myListView);
}
```
I am trying to create a Listview in Xamarin Android.
I have changed the android Id to myListView and also have tried to rebuild the app but it still shows as an error . What should I do now ? | 2016/03/30 | [
"https://Stackoverflow.com/questions/36303051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6133463/"
] | Try rebuilding the app again and saving the main.axml file .
* Build > Clean Solution
* Build Solution | Option 1) Make sure update the Xamarin.Android (Tools>Options>Xamarin>Other>Check Now)
Option 2) Run VS as Administrator and Build>Clean and Rebuild the solution.
For my case option 1 did work. [](https://i.stack.imgur.com/BlUXf.png) |
36,303,051 | This is main.axml file.
```
`<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/myListView" />
</LinearLayout>`
```
And this is the MainActivity.cs file :
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
```
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
Glop = new List<string>();
Glop.Add("Tom");
Glop.Add("Dick");
Glop.Add("Harry");
Name = FindViewById<ListView>(Resource.Id.myListView);
}
```
I am trying to create a Listview in Xamarin Android.
I have changed the android Id to myListView and also have tried to rebuild the app but it still shows as an error . What should I do now ? | 2016/03/30 | [
"https://Stackoverflow.com/questions/36303051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6133463/"
] | **For Visual Studio Community 2019 Preview (V 16.0.0, Pr 5.0):**
For this problem and a lot of the problem with the designer I have to repeatedly do the following:
* Save all documents and close VS.
* Navigate to the project folder in your file browser
* Delete (or rename, if you're paranoid) the "obj" and "bin" folders
* Relaunch VS and try the designer again.
With this version (granted, it's still beta) running a clean on the project with the designer open will cause access permission errors that can be corrected with these steps. | I faced this kind of problem. The cause may be from the duplicate resource IDs in the project. For instance, this problem occurs when you copy a layout file (.axml) and simply paste directly into the layout resource folder in the solution explorer pane without meticulous resource ID name review in it.
Since the ID reference rule in the project's namespace is to be unique. While the resource ID is auto-generating in the .Designer file, The VS couldn't determine which one is the right one you intend to use, so all cases of the same resource IDs may be skipped and unprocessed without warning.
The result is - after I made a duplicate layout file in the same project, later I couldn't reference resource name or ID of them while I'm coding.
The solution for me is to look for the duplicate IDs name in the project and correct them to be unique. |
36,303,051 | This is main.axml file.
```
`<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/myListView" />
</LinearLayout>`
```
And this is the MainActivity.cs file :
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
```
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
Glop = new List<string>();
Glop.Add("Tom");
Glop.Add("Dick");
Glop.Add("Harry");
Name = FindViewById<ListView>(Resource.Id.myListView);
}
```
I am trying to create a Listview in Xamarin Android.
I have changed the android Id to myListView and also have tried to rebuild the app but it still shows as an error . What should I do now ? | 2016/03/30 | [
"https://Stackoverflow.com/questions/36303051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6133463/"
] | Try rebuilding the app again and saving the main.axml file .
* Build > Clean Solution
* Build Solution | **For Visual Studio Community 2019 Preview (V 16.0.0, Pr 5.0):**
For this problem and a lot of the problem with the designer I have to repeatedly do the following:
* Save all documents and close VS.
* Navigate to the project folder in your file browser
* Delete (or rename, if you're paranoid) the "obj" and "bin" folders
* Relaunch VS and try the designer again.
With this version (granted, it's still beta) running a clean on the project with the designer open will cause access permission errors that can be corrected with these steps. |
36,303,051 | This is main.axml file.
```
`<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/myListView" />
</LinearLayout>`
```
And this is the MainActivity.cs file :
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
```
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
Glop = new List<string>();
Glop.Add("Tom");
Glop.Add("Dick");
Glop.Add("Harry");
Name = FindViewById<ListView>(Resource.Id.myListView);
}
```
I am trying to create a Listview in Xamarin Android.
I have changed the android Id to myListView and also have tried to rebuild the app but it still shows as an error . What should I do now ? | 2016/03/30 | [
"https://Stackoverflow.com/questions/36303051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6133463/"
] | Adjust properties for resource file like here:
[](https://i.stack.imgur.com/2hMr1.png) | 1)Build -> Clean Solution
2)Build Solution |
36,303,051 | This is main.axml file.
```
`<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/myListView" />
</LinearLayout>`
```
And this is the MainActivity.cs file :
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
```
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
Glop = new List<string>();
Glop.Add("Tom");
Glop.Add("Dick");
Glop.Add("Harry");
Name = FindViewById<ListView>(Resource.Id.myListView);
}
```
I am trying to create a Listview in Xamarin Android.
I have changed the android Id to myListView and also have tried to rebuild the app but it still shows as an error . What should I do now ? | 2016/03/30 | [
"https://Stackoverflow.com/questions/36303051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6133463/"
] | Try rebuilding the app again and saving the main.axml file .
* Build > Clean Solution
* Build Solution | 1)Build -> Clean Solution
2)Build Solution |
36,303,051 | This is main.axml file.
```
`<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/myListView" />
</LinearLayout>`
```
And this is the MainActivity.cs file :
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
```
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
Glop = new List<string>();
Glop.Add("Tom");
Glop.Add("Dick");
Glop.Add("Harry");
Name = FindViewById<ListView>(Resource.Id.myListView);
}
```
I am trying to create a Listview in Xamarin Android.
I have changed the android Id to myListView and also have tried to rebuild the app but it still shows as an error . What should I do now ? | 2016/03/30 | [
"https://Stackoverflow.com/questions/36303051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6133463/"
] | Option 1) Make sure update the Xamarin.Android (Tools>Options>Xamarin>Other>Check Now)
Option 2) Run VS as Administrator and Build>Clean and Rebuild the solution.
For my case option 1 did work. [](https://i.stack.imgur.com/BlUXf.png) | I faced this kind of problem. The cause may be from the duplicate resource IDs in the project. For instance, this problem occurs when you copy a layout file (.axml) and simply paste directly into the layout resource folder in the solution explorer pane without meticulous resource ID name review in it.
Since the ID reference rule in the project's namespace is to be unique. While the resource ID is auto-generating in the .Designer file, The VS couldn't determine which one is the right one you intend to use, so all cases of the same resource IDs may be skipped and unprocessed without warning.
The result is - after I made a duplicate layout file in the same project, later I couldn't reference resource name or ID of them while I'm coding.
The solution for me is to look for the duplicate IDs name in the project and correct them to be unique. |
36,303,051 | This is main.axml file.
```
`<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/myListView" />
</LinearLayout>`
```
And this is the MainActivity.cs file :
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
```
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
Glop = new List<string>();
Glop.Add("Tom");
Glop.Add("Dick");
Glop.Add("Harry");
Name = FindViewById<ListView>(Resource.Id.myListView);
}
```
I am trying to create a Listview in Xamarin Android.
I have changed the android Id to myListView and also have tried to rebuild the app but it still shows as an error . What should I do now ? | 2016/03/30 | [
"https://Stackoverflow.com/questions/36303051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6133463/"
] | Try rebuilding the app again and saving the main.axml file .
* Build > Clean Solution
* Build Solution | I faced this kind of problem. The cause may be from the duplicate resource IDs in the project. For instance, this problem occurs when you copy a layout file (.axml) and simply paste directly into the layout resource folder in the solution explorer pane without meticulous resource ID name review in it.
Since the ID reference rule in the project's namespace is to be unique. While the resource ID is auto-generating in the .Designer file, The VS couldn't determine which one is the right one you intend to use, so all cases of the same resource IDs may be skipped and unprocessed without warning.
The result is - after I made a duplicate layout file in the same project, later I couldn't reference resource name or ID of them while I'm coding.
The solution for me is to look for the duplicate IDs name in the project and correct them to be unique. |
58,240,100 | I have created a VCL Form containing multiple copies of a `TFrame`, each containing multiple `TLabel` components.
The labels take up most of the area inside the frame, providing little exposed client area for selecting the frame specifically. The program must take action when the user selects a frame component and display specific text in the various label captions. The problem is that if the user clicks on one of the label components instead of an open area in the frame, the `OnClick` event is not triggered.
How do I generate the frame's `OnClick` event if the user clicks anywhere within the frame? | 2019/10/04 | [
"https://Stackoverflow.com/questions/58240100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1040289/"
] | Simply assign the very same `OnClick` event handler also to each of the labels inside. Multiple controls can share the same event handler, so long as they have the same signature. | If you don't mind Label's text to be greyed then you can simply set `Enabled` property of your Labels to `False`. This will prevent your labels to capture any keyboard or mouse events and thus all of these will got to the underlying frame. |
58,240,100 | I have created a VCL Form containing multiple copies of a `TFrame`, each containing multiple `TLabel` components.
The labels take up most of the area inside the frame, providing little exposed client area for selecting the frame specifically. The program must take action when the user selects a frame component and display specific text in the various label captions. The problem is that if the user clicks on one of the label components instead of an open area in the frame, the `OnClick` event is not triggered.
How do I generate the frame's `OnClick` event if the user clicks anywhere within the frame? | 2019/10/04 | [
"https://Stackoverflow.com/questions/58240100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1040289/"
] | VCL tests a graphic (non windowed) control's response to mouse events before it decides if it is a valid target. You can use a specialized label then that modifies this response. Easiest would be to use an interposer class in your frame unit (if all the labels are expected to behave the same).
```delphi
type
TLabel = class(Vcl.StdCtrls.TLabel)
protected
procedure CMHitTest(var Message: TCMHitTest); message CM_HITTEST;
end;
TMyFrame = class(TFrame)
...
end;
...
procedure TLabel.CMHitTest(var Message: TCMHitTest);
begin
Message.Result := HTNOWHERE;
end;
``` | Simply assign the very same `OnClick` event handler also to each of the labels inside. Multiple controls can share the same event handler, so long as they have the same signature. |
58,240,100 | I have created a VCL Form containing multiple copies of a `TFrame`, each containing multiple `TLabel` components.
The labels take up most of the area inside the frame, providing little exposed client area for selecting the frame specifically. The program must take action when the user selects a frame component and display specific text in the various label captions. The problem is that if the user clicks on one of the label components instead of an open area in the frame, the `OnClick` event is not triggered.
How do I generate the frame's `OnClick` event if the user clicks anywhere within the frame? | 2019/10/04 | [
"https://Stackoverflow.com/questions/58240100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1040289/"
] | VCL tests a graphic (non windowed) control's response to mouse events before it decides if it is a valid target. You can use a specialized label then that modifies this response. Easiest would be to use an interposer class in your frame unit (if all the labels are expected to behave the same).
```delphi
type
TLabel = class(Vcl.StdCtrls.TLabel)
protected
procedure CMHitTest(var Message: TCMHitTest); message CM_HITTEST;
end;
TMyFrame = class(TFrame)
...
end;
...
procedure TLabel.CMHitTest(var Message: TCMHitTest);
begin
Message.Result := HTNOWHERE;
end;
``` | If you don't mind Label's text to be greyed then you can simply set `Enabled` property of your Labels to `False`. This will prevent your labels to capture any keyboard or mouse events and thus all of these will got to the underlying frame. |
296,288 | I have a requirement like below.
If there aren't any payment methods, There is a text showing in payment page
**No Payment method available.**
under the path
>
> Magento\_Checkout\web\template\payment.html
>
>
>
My requirement here is to include a link after the text like below
`No Payment method available.` **click here** to edit address. ==> It should be linked to customer account page
How can this be achieved, I am not so good in `knockout.js` to bind the links in html pages.
Please can anyone help me implement this functionality? Thanks!! | 2019/11/20 | [
"https://magento.stackexchange.com/questions/296288",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/80394/"
] | First of all, To update message in checkout payment step you need to update **payment.html** file and then, to pass custom link you need to create **mixin of payment.js**
Follow below steps for add link in payment steps when no payment methods available :
>
> **1)** app/code/RH/CustomCheckout/view/frontend/requirejs-config.js
>
>
>
```
var config = {
map: {
'*': {
'Magento_Checkout/template/payment.html':
'RH_CustomCheckout/template/payment.html' //override payment.html file
}
},
config: {
mixins: {
'Magento_Checkout/js/view/payment': {
'RH_CustomCheckout/js/view/payment-mixin': true // Create mixin of payment.js to add custom link
}
}
}
};
```
>
> **2)** app/code/RH/CustomCheckout/view/frontend/web/template/payment.html
>
>
>
```
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<li id="payment" role="presentation" class="checkout-payment-method" data-bind="fadeVisible: isVisible">
<div id="checkout-step-payment"
class="step-content"
data-role="content"
role="tabpanel"
aria-hidden="false">
<!-- ko if: (quoteIsVirtual) -->
<!-- ko foreach: getRegion('customer-email') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
<!--/ko-->
<form id="co-payment-form" class="form payments" novalidate="novalidate">
<input data-bind='attr: {value: getFormKey()}' type="hidden" name="form_key"/>
<fieldset class="fieldset">
<legend class="legend">
<span data-bind="i18n: 'Payment Information'"></span>
</legend><br />
<!-- ko foreach: getRegion('beforeMethods') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!-- /ko -->
<div id="checkout-payment-method-load" class="opc-payment" data-bind="visible: isPaymentMethodsAvailable">
<!-- ko foreach: getRegion('payment-methods-list') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!-- /ko -->
</div>
<div class="no-quotes-block" data-bind="visible: isPaymentMethodsAvailable() == false">
<!-- ko if: (!isPaymentMethodsAvailable()) -->
<span data-bind="i18n: 'No Payment method available.'"></span>
<b><a data-bind="i18n: 'click here', attr: { href: getCustomerAccountUrl() }" target="_new"></a></b>
<span data-bind="i18n: 'to edit address.'"></span>
<!-- /ko -->
</div>
<!-- ko foreach: getRegion('afterMethods') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!-- /ko -->
</fieldset>
</form>
</div>
</li>
```
>
> **3)** app/code/RH/CustomCheckout/view/frontend/web/js/view/payment-mixin.js
>
>
>
```
define([
'jquery',
'underscore',
'uiComponent',
'ko',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/step-navigator',
'Magento_Checkout/js/model/payment-service',
'Magento_Checkout/js/model/payment/method-converter',
'Magento_Checkout/js/action/get-payment-information',
'Magento_Checkout/js/model/checkout-data-resolver',
'mage/translate',
'mage/url'
], function (
$,
_,
Component,
ko,
quote,
stepNavigator,
paymentService,
methodConverter,
getPaymentInformation,
checkoutDataResolver,
$t,
url
) {
'use strict';
var mixin = {
getCustomerAccountUrl: function () {
return window.checkoutConfig.customUrl; // Get URL from Block file
}
};
return function (target) {
return target.extend(mixin);
};
});
```
To pass URL from **block/helper** ,You have to just override **getConfig()** function of **CompositeConfigProvider.php** file.
>
> **4)** app/code/RH/CustomCheckout/etc/frontend/di.xml
>
>
>
```
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- pass custom data to checkout page -->
<type name="Magento\Checkout\Model\CompositeConfigProvider">
<arguments>
<argument name="configProviders" xsi:type="array">
<item name="checkout_custom_payment_block" xsi:type="object">RH\CustomCheckout\Model\CustomConfigProvider</item>
</argument>
</arguments>
</type>
</config>
```
>
> **5)** app/code/RH/CustomCheckout/Model/CustomConfigProvider.php
>
>
>
```
<?php
namespace RH\CustomCheckout\Model;
use Magento\Checkout\Model\ConfigProviderInterface;
class CustomConfigProvider implements ConfigProviderInterface {
protected $customCheckout;
public function __construct(
\RH\CustomCheckout\Block\CustomBlock $customCheckout
) {
$this->customCheckout = $customCheckout;
}
public function getConfig() {
$config = [];
$config['customUrl'] = $this->customCheckout->getCustomerAccountURL();
return $config;
}
}
```
>
> **6)** app/code/RH/CustomCheckout/Block/CustomBlock.php
>
>
>
```
<?php
namespace RH\CustomCheckout\Block;
class CustomBlock extends \Magento\Framework\View\Element\Template {
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
array $data = []
) {
parent::__construct($context, $data);
}
public function getCustomerAccountURL() {
return 'customer account url which you want to add';
}
}
?>
```
---
If you want to add this custom URL into your theme's checkout **payment.html** file. Then, you just need to replace this below code in your html file. and no need to override payment.html file from **requirejs-config.js**. So, remove **payment.html** override code from **requirejs-config.js [Step 1]** if you want to access that data in your theme's checkout **payment.html**
Replace this below div in your theme's **payment.html** file :
**From :**
```
<div class="no-quotes-block" data-bind="visible: isPaymentMethodsAvailable() == false">
<!-- ko i18n: 'No Payment method available.'--><!-- /ko -->
</div>
```
**To :**
```
<div class="no-quotes-block" data-bind="visible: isPaymentMethodsAvailable() == false">
<!-- ko if: (!isPaymentMethodsAvailable()) -->
<span data-bind="i18n: 'No Payment method available.'"></span>
<b><a data-bind="i18n: 'click here', attr: { href: getCustomerAccountUrl() }" target="_new"></a></b>
<span data-bind="i18n: 'to edit address.'"></span>
<!-- /ko -->
</div>
```
---
**Output :**
[](https://i.stack.imgur.com/EbjtC.png)
Hope, It will helpful for you. | You can create one function in `payment.js` file using this way
Create `requirejs-config.js` file here in your custom module
>
> app/code/Vendor/Module/view/frontend/requirejs-config.js
>
>
>
Content for this file is..
```
var config = {
config: {
mixins: {
'Magento_Checkout/js/view/payment': {
'Vendor_Module/js/view/payment-mixin': true
}
}
}
};
```
Now you need to create one `payment-mixin.js` file here
>
> app/code/Vendor/Module/view/frontend/web/js/view/payment-mixin.js
>
>
>
Content for this file is..
```
define([
'jquery',
'underscore',
'uiComponent',
'ko',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/step-navigator',
'Magento_Checkout/js/model/payment-service',
'Magento_Checkout/js/model/payment/method-converter',
'Magento_Checkout/js/action/get-payment-information',
'Magento_Checkout/js/model/checkout-data-resolver',
'mage/translate',
'mage/url'
], function (
$,
_,
Component,
ko,
quote,
stepNavigator,
paymentService,
methodConverter,
getPaymentInformation,
checkoutDataResolver,
$t,
url
) {
'use strict';
var mixin = {
defaults: {
template: 'Vendor_Module/payment'
},
getBaseUrl: function () {
/*You can add your URL here.*/
return url.build('customer/account');
}
};
return function (target) {
return target.extend(mixin);
};
});
```
I've created `getBaseUrl()` function here in this `mixin` file and also override template file from `Magento_Checkout/payment` to `Vendor_Module/payment`.
So now we need to create one template file here in our custom module
>
> app/code/Vendor/Module/view/frontend/web/template/payment.html
>
>
>
Content for this file is
```
<li id="payment" role="presentation" class="checkout-payment-method" data-bind="fadeVisible: isVisible">
<div id="checkout-step-payment"
class="step-content"
data-role="content"
role="tabpanel"
aria-hidden="false">
<!-- ko if: (quoteIsVirtual) -->
<!-- ko foreach: getRegion('customer-email') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
<!--/ko-->
<form id="co-payment-form" class="form payments" novalidate="novalidate">
<input data-bind='attr: {value: getFormKey()}' type="hidden" name="form_key"/>
<fieldset class="fieldset">
<legend class="legend">
<span data-bind="i18n: 'Payment Information'"></span>
</legend><br />
<!-- ko foreach: getRegion('beforeMethods') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!-- /ko -->
<div id="checkout-payment-method-load" class="opc-payment" data-bind="visible: isPaymentMethodsAvailable">
<!-- ko foreach: getRegion('payment-methods-list') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!-- /ko -->
</div>
<div class="no-quotes-block" data-bind="visible: isPaymentMethodsAvailable() == false">
<!-- ko i18n: 'No Payment method available.'--><!-- /ko -->
<a data-bind="attr: { href: getBaseUrl() }"><b>click here</b> to edit address</a>
</div>
<!-- ko foreach: getRegion('afterMethods') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!-- /ko -->
</fieldset>
</form>
</div>
</li>
```
I've called that function in this html template file.
Hope this will work for you! |
40,707,738 | I'm using VueJS to make a simple enough resource management game/interface. At the minute I'm looking to activate the `roll` function every 12.5 seconds and use the result in another function.
At the moment though I keep getting the following error:
>
> Uncaught TypeError: Cannot read property 'roll' of undefined(...)
>
>
>
I have tried:
* `app.methods.roll(6);`
* `app.methods.roll.roll(6);`
* `roll.roll()`
* `roll()`
but can't seem to access the function. Anyone any ideas how I might achieve this?
```
methods: {
// Push responses to inbox.
say: function say(responseText) {
console.log(responseText);
var pushText = responseText;
this.inbox.push({ text: pushText });
},
// Roll for events
roll: function roll(upper) {
var randomNumber = Math.floor(Math.random() * 6 * upper) + 1;
console.log(randomNumber);
return randomNumber;
},
// Initiates passage of time and rolls counters every 5 time units.
count: function count() {
function counting() {
app.town.date += 1;
app.gameState.roll += 0.2;
if (app.gameState.roll === 1) {
var result = app.methods.roll(6);
app.gameState.roll === 0;
return result;
}
}
setInterval(counting, 2500);
...
// Activates the roll at times.
}
}
``` | 2016/11/20 | [
"https://Stackoverflow.com/questions/40707738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3200485/"
] | >
> You can access these methods directly on the VM instance, or use them in directive expressions. All methods will have their `this` context automatically bound to the Vue instance.
>
>
>
– [Vue API Guide on `methods`](https://v2.vuejs.org/v2/api/#methods)
Within a method on a Vue instance you can access other methods on the instance using `this`.
```
var vm = new Vue({
...
methods: {
methodA() {
// Method A
},
methodB() {
// Method B
// Call `methodA` from inside `methodB`
this.methodA()
},
},
...
});
```
To access a method outside of a Vue instance you can assign the instance to a variable (such as `vm` in the example above) and call the method:
```
vm.methodA();
``` | You can use `vm.methodName();`
Example:
```
let vm = new Vue({
el: '#app',
data: {},
methods: {
methodA: function () {
console.log('hello');
},
methodB: function () {
// calling methodA
vm.methodA();
}
},
})
``` |
40,707,738 | I'm using VueJS to make a simple enough resource management game/interface. At the minute I'm looking to activate the `roll` function every 12.5 seconds and use the result in another function.
At the moment though I keep getting the following error:
>
> Uncaught TypeError: Cannot read property 'roll' of undefined(...)
>
>
>
I have tried:
* `app.methods.roll(6);`
* `app.methods.roll.roll(6);`
* `roll.roll()`
* `roll()`
but can't seem to access the function. Anyone any ideas how I might achieve this?
```
methods: {
// Push responses to inbox.
say: function say(responseText) {
console.log(responseText);
var pushText = responseText;
this.inbox.push({ text: pushText });
},
// Roll for events
roll: function roll(upper) {
var randomNumber = Math.floor(Math.random() * 6 * upper) + 1;
console.log(randomNumber);
return randomNumber;
},
// Initiates passage of time and rolls counters every 5 time units.
count: function count() {
function counting() {
app.town.date += 1;
app.gameState.roll += 0.2;
if (app.gameState.roll === 1) {
var result = app.methods.roll(6);
app.gameState.roll === 0;
return result;
}
}
setInterval(counting, 2500);
...
// Activates the roll at times.
}
}
``` | 2016/11/20 | [
"https://Stackoverflow.com/questions/40707738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3200485/"
] | >
> You can access these methods directly on the VM instance, or use them in directive expressions. All methods will have their `this` context automatically bound to the Vue instance.
>
>
>
– [Vue API Guide on `methods`](https://v2.vuejs.org/v2/api/#methods)
Within a method on a Vue instance you can access other methods on the instance using `this`.
```
var vm = new Vue({
...
methods: {
methodA() {
// Method A
},
methodB() {
// Method B
// Call `methodA` from inside `methodB`
this.methodA()
},
},
...
});
```
To access a method outside of a Vue instance you can assign the instance to a variable (such as `vm` in the example above) and call the method:
```
vm.methodA();
``` | ```js
let vm = new Vue({
el: '#testfunc',
data:{
sp1: "Hi I'm textbox1",
sp2: "Hi I'm textbox2"
},
methods:{
chsp1:function(){
this.sp1 = "I'm swapped from textbox2"
},
chsp2:function(){
this.sp2 = "I'm swapped from textbox1";
this.chsp1();
},
swapit:function(){
this.chsp2();
}
}
});
```
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="testfunc">
<input type="text" :value="sp1"></span>
<input type="text" :value="sp2"></span>
<button @click="swapit()">Swap</button>
</div>
``` |
40,707,738 | I'm using VueJS to make a simple enough resource management game/interface. At the minute I'm looking to activate the `roll` function every 12.5 seconds and use the result in another function.
At the moment though I keep getting the following error:
>
> Uncaught TypeError: Cannot read property 'roll' of undefined(...)
>
>
>
I have tried:
* `app.methods.roll(6);`
* `app.methods.roll.roll(6);`
* `roll.roll()`
* `roll()`
but can't seem to access the function. Anyone any ideas how I might achieve this?
```
methods: {
// Push responses to inbox.
say: function say(responseText) {
console.log(responseText);
var pushText = responseText;
this.inbox.push({ text: pushText });
},
// Roll for events
roll: function roll(upper) {
var randomNumber = Math.floor(Math.random() * 6 * upper) + 1;
console.log(randomNumber);
return randomNumber;
},
// Initiates passage of time and rolls counters every 5 time units.
count: function count() {
function counting() {
app.town.date += 1;
app.gameState.roll += 0.2;
if (app.gameState.roll === 1) {
var result = app.methods.roll(6);
app.gameState.roll === 0;
return result;
}
}
setInterval(counting, 2500);
...
// Activates the roll at times.
}
}
``` | 2016/11/20 | [
"https://Stackoverflow.com/questions/40707738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3200485/"
] | You can use `vm.methodName();`
Example:
```
let vm = new Vue({
el: '#app',
data: {},
methods: {
methodA: function () {
console.log('hello');
},
methodB: function () {
// calling methodA
vm.methodA();
}
},
})
``` | ```js
let vm = new Vue({
el: '#testfunc',
data:{
sp1: "Hi I'm textbox1",
sp2: "Hi I'm textbox2"
},
methods:{
chsp1:function(){
this.sp1 = "I'm swapped from textbox2"
},
chsp2:function(){
this.sp2 = "I'm swapped from textbox1";
this.chsp1();
},
swapit:function(){
this.chsp2();
}
}
});
```
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="testfunc">
<input type="text" :value="sp1"></span>
<input type="text" :value="sp2"></span>
<button @click="swapit()">Swap</button>
</div>
``` |
41,759,273 | I am converting html to pdf using jspdf library. i am facing two problems.
1. When i am using pagesplit: true ,it splits the page but the problem is half of data in li remains in first page and half comes in second page and so on.
2.in my image tag src link is not contains extension. It fetchs from url. For eg:"<http://pics.redblue.de/doi/pixelboxx-mss-55590672/fee_786_587_png>", but in pdf image not displaying. If i pass src link ends with extension it is displaying in pdf.But i am using not extension format.
I searched much for both but didn't find any solution. Please help me ... Thanks in advance | 2017/01/20 | [
"https://Stackoverflow.com/questions/41759273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7125183/"
] | For your 2nd question:
You can use base64 encoded images. It works with jspdf.
To convert image into base64, check this: [How to convert image into base64 string using javascript](https://stackoverflow.com/questions/6150289/how-to-convert-image-into-base64-string-using-javascript) | 1 You need to check the pdf size and adjust it.
2 The base64 image renders in the jspdf. You can use this link for getting base64 code and paste it in img src value <https://www.base64-image.de/> |
29,696,044 | I've wrote a script to change a few CSS properties of a div. I've tried 2 methods I found on google but neither of them work. I've thoroughly read the examples and I don't know why this won't work.
When there is less content in the `#rightsection` then there are images in the `#leftsection`, the `#rightsection` attaches to the bottom of the `#contentpage`. But if there is too much content in the `#rightsection`, the content overflows. So I want to change to `position:absolute` to `position:static` when there's a scroll detected upon overflow.
I'm not really that good with JQuery so I'm hoping anybody of you would know the answer. If anybody does know, I'd appreciate it.
```
(function($) {
$.fn.hasScrollBar = function() {
return this.get(0).scrollHeight > this.height();
}
//Method 1
if($("#rightsection").hasScrollBar()){
$('.rightsection1').css({
"position":"static",
"margin":"-75px 0 0 150px"
});
}
//Method 2
if($("#rightsection").hasScrollBar()){
$('#rightsection').addClass("rightsection1");
$('#rightsection').removeClass("rightsection2");
}
})(jQuery);
```
[JSFiddle](http://jsfiddle.net/2e1hcweq/4/)
**Solution**
I changed `(function($)` by `$(document).ready(function()` and now it works flawlessly. | 2015/04/17 | [
"https://Stackoverflow.com/questions/29696044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4373648/"
] | I have found the solution: the problem was that the sub name was the same as the module name. I didn't know it had to be different, but I hope someone will find this useful!
Thanks for all the answers guys! | I came across another issue while running a simple test attempting to run an Access VBA function in an empty database (except for the VBA code) from an Excel procedure. Without any other objects (tables/forms/etc), the Access VBA function was unable to be found. Once I put in a nominal table, the call to the Access VBA function from Excel VBA was successful. Not a usual situation to have an empty database but as I said I was just running a trial to see if the method worked. |
15,867,391 | My Caeser cipher works interactively in the shell with a string, but when I've tried to undertake separate programs to encrypt and decrypt I've run into problems, I don't know whether the input is not being split into a list or not, but the if statement in my encryption function is being bypassed and defaulting to the else statement that fills the list unencrypted. Any suggestions appreciated. I'm using FileUtilities.py from the Goldwasser book. That file is at <http://prenhall.com/goldwasser/sourcecode.zip> in chapter 11, but I don't think the problem is with that, but who knows. Advance thanks.
```
#CaeserCipher.py
class CaeserCipher:
def __init__ (self, unencrypted="", encrypted=""):
self._plain = unencrypted
self._cipher = encrypted
self._encoded = ""
def encrypt (self, plaintext):
self._plain = plaintext
plain_list = list(self._plain)
i = 0
final = []
while (i <= len(plain_list)-1):
if plain_list[i] in plainset:
final.append(plainset[plain_list[i]])
else:
final.append(plain_list[i])
i+=1
self._encoded = ''.join(final)
return self._encoded
def decrypt (self, ciphertext):
self._cipher = ciphertext
cipher_list = list(self._cipher)
i = 0
final = []
while (i <= len(cipher_list)-1):
if cipher_list[i] in cipherset:
final.append(cipherset[cipher_list[i]])
else:
final.append(cipher_list[i])
i+=1
self._encoded = ''.join(final)
return self._encoded
def writeEncrypted(self, outfile):
encoded_file = self._encoded
outfile.write('%s' %(encoded_file))
#encrypt.py
from FileUtilities import openFileReadRobust, openFileWriteRobust
from CaeserCipher import CaeserCipher
caeser = CaeserCipher()
source = openFileReadRobust()
destination = openFileWriteRobust('encrypted.txt')
caeser.encrypt(source)
caeser.writeEncrypted(destination)
source.close()
destination.close()
print 'Encryption completed.'
``` | 2013/04/07 | [
"https://Stackoverflow.com/questions/15867391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/967818/"
] | ```
caeser.encrypt(source)
```
into
```
caeser.encrypt(source.read())
```
`source` is a file object - the fact that this code "works" (by not encrypting anything) is interesting - turns out that you call `list()` over the source before iterating and that turns it into a **list of lines in the file**. Instead of the usual result of `list(string)` which is a list of characters. So when it tries to encrypt each chracter, it finds a whole line that doesn't match any of the replacements you set.
Also like others pointed out, you forgot to include plainset in the code, but that doesn't really matter.
A few random notes about your code (probably nitpicking you didn't ask for, heh)
* You typo'd "Caesar"
* You're using idioms which are inefficient in python (what's usually called "not pythonic"), some of which might come from experience with other languages like C.
+ Those while loops could be `for item in string:` - strings already work as lists of bytes like what you tried to convert.
+ The line that writes to outfile could be just `outfile.write(self._encoded)`
* Both functions are very similar, almost copy-pasted code. Try to write a third function that shares the functionality of both but has two "modes", encrypt and decrypt. You could just make it work over cipher\_list or plain\_list depending on the mode, for example
* I know you're doing this for practice but the standard library includes [these functions](http://www.tutorialspoint.com/python/string_maketrans.htm) for this kind of replacements. Batteries included!
**Edit**: if anyone is wondering what those file functions do and why they work, they call `raw_input()` inside a while loop until there's a suitable file to return. `openFileWriteRobust()` has a parameter that is the default value in case the user doesn't input anything. The code is linked on the OP post. | It isn't obvious to me that there will be anything in `source` after the call to `openFileReadRobust()`. I don't know the specification for `openFileReadRobust()` but it seems like it won't know what file to open unless there is a filename given as a parameter, and there isn't one.
Thus, I suspect `source` is empty, thus `plain` is empty too.
I suggest printing out `source`, `plaintext` and `plain` to ensure that their values are what you expect them to be.
Parenthetically, the `openFileReadRobust()` function doesn't seem very helpful to me if it can return non-sensical values for non-sensical parameter values. I very much prefer my functions to throw an exception immediately in that sort of circumstance. |
15,867,391 | My Caeser cipher works interactively in the shell with a string, but when I've tried to undertake separate programs to encrypt and decrypt I've run into problems, I don't know whether the input is not being split into a list or not, but the if statement in my encryption function is being bypassed and defaulting to the else statement that fills the list unencrypted. Any suggestions appreciated. I'm using FileUtilities.py from the Goldwasser book. That file is at <http://prenhall.com/goldwasser/sourcecode.zip> in chapter 11, but I don't think the problem is with that, but who knows. Advance thanks.
```
#CaeserCipher.py
class CaeserCipher:
def __init__ (self, unencrypted="", encrypted=""):
self._plain = unencrypted
self._cipher = encrypted
self._encoded = ""
def encrypt (self, plaintext):
self._plain = plaintext
plain_list = list(self._plain)
i = 0
final = []
while (i <= len(plain_list)-1):
if plain_list[i] in plainset:
final.append(plainset[plain_list[i]])
else:
final.append(plain_list[i])
i+=1
self._encoded = ''.join(final)
return self._encoded
def decrypt (self, ciphertext):
self._cipher = ciphertext
cipher_list = list(self._cipher)
i = 0
final = []
while (i <= len(cipher_list)-1):
if cipher_list[i] in cipherset:
final.append(cipherset[cipher_list[i]])
else:
final.append(cipher_list[i])
i+=1
self._encoded = ''.join(final)
return self._encoded
def writeEncrypted(self, outfile):
encoded_file = self._encoded
outfile.write('%s' %(encoded_file))
#encrypt.py
from FileUtilities import openFileReadRobust, openFileWriteRobust
from CaeserCipher import CaeserCipher
caeser = CaeserCipher()
source = openFileReadRobust()
destination = openFileWriteRobust('encrypted.txt')
caeser.encrypt(source)
caeser.writeEncrypted(destination)
source.close()
destination.close()
print 'Encryption completed.'
``` | 2013/04/07 | [
"https://Stackoverflow.com/questions/15867391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/967818/"
] | Some points:
* Using a context manager (`with`) makes sure that files are closed after being read or written.
* Since the caesar cipher is a substitution cipher where the shift parameter is the key, there is no need for a separate `encrypt` and `decrypt` member function: they are the same but with the "key" negated.
* The `writeEncrypted` method is but a wrapper for a file's write method. So the class has effectively only two methods, one of which is `__init__`.
* That means you could easily replace it with a single function.
With that in mind your code can be replaced with this;
```
import string
def caesartable(txt, shift):
shift = int(shift)
if shift > 25 or shift < -25:
raise ValueError('illegal shift value')
az = string.ascii_lowercase
AZ = string.ascii_uppercase
eaz = az[-shift:]+az[:-shift]
eAZ = AZ[-shift:]+AZ[:-shift]
tt = string.maketrans(az + AZ, eaz + eAZ)
return tt
enc = caesartable(3) # for example. decrypt would be caesartable(-3)
with open('plain.txt') as inf:
txt = inf.read()
with open('encrypted.txt', 'w+') as outf:
outf.write(txt.translate(enc))
```
If you are using a shift of 13, you can use the built-in `rot13` encoder instead. | It isn't obvious to me that there will be anything in `source` after the call to `openFileReadRobust()`. I don't know the specification for `openFileReadRobust()` but it seems like it won't know what file to open unless there is a filename given as a parameter, and there isn't one.
Thus, I suspect `source` is empty, thus `plain` is empty too.
I suggest printing out `source`, `plaintext` and `plain` to ensure that their values are what you expect them to be.
Parenthetically, the `openFileReadRobust()` function doesn't seem very helpful to me if it can return non-sensical values for non-sensical parameter values. I very much prefer my functions to throw an exception immediately in that sort of circumstance. |
15,867,391 | My Caeser cipher works interactively in the shell with a string, but when I've tried to undertake separate programs to encrypt and decrypt I've run into problems, I don't know whether the input is not being split into a list or not, but the if statement in my encryption function is being bypassed and defaulting to the else statement that fills the list unencrypted. Any suggestions appreciated. I'm using FileUtilities.py from the Goldwasser book. That file is at <http://prenhall.com/goldwasser/sourcecode.zip> in chapter 11, but I don't think the problem is with that, but who knows. Advance thanks.
```
#CaeserCipher.py
class CaeserCipher:
def __init__ (self, unencrypted="", encrypted=""):
self._plain = unencrypted
self._cipher = encrypted
self._encoded = ""
def encrypt (self, plaintext):
self._plain = plaintext
plain_list = list(self._plain)
i = 0
final = []
while (i <= len(plain_list)-1):
if plain_list[i] in plainset:
final.append(plainset[plain_list[i]])
else:
final.append(plain_list[i])
i+=1
self._encoded = ''.join(final)
return self._encoded
def decrypt (self, ciphertext):
self._cipher = ciphertext
cipher_list = list(self._cipher)
i = 0
final = []
while (i <= len(cipher_list)-1):
if cipher_list[i] in cipherset:
final.append(cipherset[cipher_list[i]])
else:
final.append(cipher_list[i])
i+=1
self._encoded = ''.join(final)
return self._encoded
def writeEncrypted(self, outfile):
encoded_file = self._encoded
outfile.write('%s' %(encoded_file))
#encrypt.py
from FileUtilities import openFileReadRobust, openFileWriteRobust
from CaeserCipher import CaeserCipher
caeser = CaeserCipher()
source = openFileReadRobust()
destination = openFileWriteRobust('encrypted.txt')
caeser.encrypt(source)
caeser.writeEncrypted(destination)
source.close()
destination.close()
print 'Encryption completed.'
``` | 2013/04/07 | [
"https://Stackoverflow.com/questions/15867391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/967818/"
] | ```
caeser.encrypt(source)
```
into
```
caeser.encrypt(source.read())
```
`source` is a file object - the fact that this code "works" (by not encrypting anything) is interesting - turns out that you call `list()` over the source before iterating and that turns it into a **list of lines in the file**. Instead of the usual result of `list(string)` which is a list of characters. So when it tries to encrypt each chracter, it finds a whole line that doesn't match any of the replacements you set.
Also like others pointed out, you forgot to include plainset in the code, but that doesn't really matter.
A few random notes about your code (probably nitpicking you didn't ask for, heh)
* You typo'd "Caesar"
* You're using idioms which are inefficient in python (what's usually called "not pythonic"), some of which might come from experience with other languages like C.
+ Those while loops could be `for item in string:` - strings already work as lists of bytes like what you tried to convert.
+ The line that writes to outfile could be just `outfile.write(self._encoded)`
* Both functions are very similar, almost copy-pasted code. Try to write a third function that shares the functionality of both but has two "modes", encrypt and decrypt. You could just make it work over cipher\_list or plain\_list depending on the mode, for example
* I know you're doing this for practice but the standard library includes [these functions](http://www.tutorialspoint.com/python/string_maketrans.htm) for this kind of replacements. Batteries included!
**Edit**: if anyone is wondering what those file functions do and why they work, they call `raw_input()` inside a while loop until there's a suitable file to return. `openFileWriteRobust()` has a parameter that is the default value in case the user doesn't input anything. The code is linked on the OP post. | Some points:
* Using a context manager (`with`) makes sure that files are closed after being read or written.
* Since the caesar cipher is a substitution cipher where the shift parameter is the key, there is no need for a separate `encrypt` and `decrypt` member function: they are the same but with the "key" negated.
* The `writeEncrypted` method is but a wrapper for a file's write method. So the class has effectively only two methods, one of which is `__init__`.
* That means you could easily replace it with a single function.
With that in mind your code can be replaced with this;
```
import string
def caesartable(txt, shift):
shift = int(shift)
if shift > 25 or shift < -25:
raise ValueError('illegal shift value')
az = string.ascii_lowercase
AZ = string.ascii_uppercase
eaz = az[-shift:]+az[:-shift]
eAZ = AZ[-shift:]+AZ[:-shift]
tt = string.maketrans(az + AZ, eaz + eAZ)
return tt
enc = caesartable(3) # for example. decrypt would be caesartable(-3)
with open('plain.txt') as inf:
txt = inf.read()
with open('encrypted.txt', 'w+') as outf:
outf.write(txt.translate(enc))
```
If you are using a shift of 13, you can use the built-in `rot13` encoder instead. |
2,532,105 | I'm having trouble with writing this sequence as a function of $n$ because it's neither geometric nor arithmetic.
>
> $$\begin{cases}
> u\_{n+1} = \frac12 u\_{n} + 3\qquad \forall n \in \mathbb N\\
> u\_{0} = \frac13
> \end{cases}$$
>
>
> | 2017/11/22 | [
"https://math.stackexchange.com/questions/2532105",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/482160/"
] | Hint. Note that for some real number $a$ (which one?),
$$u\_{n+1}-a = \frac12 \left(u\_{n}-a\right).$$
Hence, the sequence $(u\_n-a)\_n$ is of geometric type:
$$u\_{n}-a=\frac12 \left(u\_{n-1}-a\right)=\frac{1}{2^2} \left(u\_{n-2}-a\right)=\dots =\frac{1}{2^{n}} \left(u\_{0}-a\right).$$ | Let $u\_m=v\_m+a\_0+a\_1m+\cdots$
$$6=2u\_{n+1}-u\_n=2v\_{m+1}-v\_m+a\_0(2-1)+a\_1(2(m+1)-m)+\cdots$$
Set $a\_0=6,a\_r=0\forall r>0$
to find $$v\_{n+1}=\dfrac{v\_n}2=\cdots=\dfrac{v\_{n-p}}{2^{p+1}}$$
Now $v\_0+6=u\_0\iff v\_0=?$ |
2,532,105 | I'm having trouble with writing this sequence as a function of $n$ because it's neither geometric nor arithmetic.
>
> $$\begin{cases}
> u\_{n+1} = \frac12 u\_{n} + 3\qquad \forall n \in \mathbb N\\
> u\_{0} = \frac13
> \end{cases}$$
>
>
> | 2017/11/22 | [
"https://math.stackexchange.com/questions/2532105",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/482160/"
] | Hint. Note that for some real number $a$ (which one?),
$$u\_{n+1}-a = \frac12 \left(u\_{n}-a\right).$$
Hence, the sequence $(u\_n-a)\_n$ is of geometric type:
$$u\_{n}-a=\frac12 \left(u\_{n-1}-a\right)=\frac{1}{2^2} \left(u\_{n-2}-a\right)=\dots =\frac{1}{2^{n}} \left(u\_{0}-a\right).$$ | Similarly to what RobertZ did, turning the arithmetico-geometric recurrence to a purely geometric one, you can get rid of the multiplicative coefficient.
Let $u\_n:=\dfrac{v\_n}{2^n}$. Then
$$\dfrac{v\_{n+1}}{2^{n+1}}=\frac12\dfrac{v\_n}{2^n}+3$$ or
$$v\_{n+1}=v\_n+3\cdot2^{n+1}.$$
This recurrence is now easily solved as a geometric summation
$$v\_n=6\,(2^n-1)+\frac13.$$ |
2,532,105 | I'm having trouble with writing this sequence as a function of $n$ because it's neither geometric nor arithmetic.
>
> $$\begin{cases}
> u\_{n+1} = \frac12 u\_{n} + 3\qquad \forall n \in \mathbb N\\
> u\_{0} = \frac13
> \end{cases}$$
>
>
> | 2017/11/22 | [
"https://math.stackexchange.com/questions/2532105",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/482160/"
] | Write $$ 2u\_{n+1}-u\_n = 6 = 2u\_n-u\_{n-1}$$
so we have $$ 2u\_{n+1}-3u\_n +u\_{n-1}=0$$
Then solving the characteristic equation $2x^2-3x+1=0$ which has a solution $x\_1=1$ ans $x\_2={1\over 2}$ we get a general solution $$ u\_n = a\cdot 1^n +b\cdot \Big({1\over 2} \Big)^n$$
Since $u\_1 = {19\over 6}$ by solving a system:
\begin{eqnarray\*}
{1\over 3} &=& a+b\\
{19\over 6} &=& a+{b\over 2}
\end{eqnarray\*}
we get the solution:
$$ u\_n = 6-{17\over 3\cdot 2^n}$$ | Let $u\_m=v\_m+a\_0+a\_1m+\cdots$
$$6=2u\_{n+1}-u\_n=2v\_{m+1}-v\_m+a\_0(2-1)+a\_1(2(m+1)-m)+\cdots$$
Set $a\_0=6,a\_r=0\forall r>0$
to find $$v\_{n+1}=\dfrac{v\_n}2=\cdots=\dfrac{v\_{n-p}}{2^{p+1}}$$
Now $v\_0+6=u\_0\iff v\_0=?$ |
2,532,105 | I'm having trouble with writing this sequence as a function of $n$ because it's neither geometric nor arithmetic.
>
> $$\begin{cases}
> u\_{n+1} = \frac12 u\_{n} + 3\qquad \forall n \in \mathbb N\\
> u\_{0} = \frac13
> \end{cases}$$
>
>
> | 2017/11/22 | [
"https://math.stackexchange.com/questions/2532105",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/482160/"
] | Write $$ 2u\_{n+1}-u\_n = 6 = 2u\_n-u\_{n-1}$$
so we have $$ 2u\_{n+1}-3u\_n +u\_{n-1}=0$$
Then solving the characteristic equation $2x^2-3x+1=0$ which has a solution $x\_1=1$ ans $x\_2={1\over 2}$ we get a general solution $$ u\_n = a\cdot 1^n +b\cdot \Big({1\over 2} \Big)^n$$
Since $u\_1 = {19\over 6}$ by solving a system:
\begin{eqnarray\*}
{1\over 3} &=& a+b\\
{19\over 6} &=& a+{b\over 2}
\end{eqnarray\*}
we get the solution:
$$ u\_n = 6-{17\over 3\cdot 2^n}$$ | Similarly to what RobertZ did, turning the arithmetico-geometric recurrence to a purely geometric one, you can get rid of the multiplicative coefficient.
Let $u\_n:=\dfrac{v\_n}{2^n}$. Then
$$\dfrac{v\_{n+1}}{2^{n+1}}=\frac12\dfrac{v\_n}{2^n}+3$$ or
$$v\_{n+1}=v\_n+3\cdot2^{n+1}.$$
This recurrence is now easily solved as a geometric summation
$$v\_n=6\,(2^n-1)+\frac13.$$ |
2,532,105 | I'm having trouble with writing this sequence as a function of $n$ because it's neither geometric nor arithmetic.
>
> $$\begin{cases}
> u\_{n+1} = \frac12 u\_{n} + 3\qquad \forall n \in \mathbb N\\
> u\_{0} = \frac13
> \end{cases}$$
>
>
> | 2017/11/22 | [
"https://math.stackexchange.com/questions/2532105",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/482160/"
] | Similarly to what RobertZ did, turning the arithmetico-geometric recurrence to a purely geometric one, you can get rid of the multiplicative coefficient.
Let $u\_n:=\dfrac{v\_n}{2^n}$. Then
$$\dfrac{v\_{n+1}}{2^{n+1}}=\frac12\dfrac{v\_n}{2^n}+3$$ or
$$v\_{n+1}=v\_n+3\cdot2^{n+1}.$$
This recurrence is now easily solved as a geometric summation
$$v\_n=6\,(2^n-1)+\frac13.$$ | Let $u\_m=v\_m+a\_0+a\_1m+\cdots$
$$6=2u\_{n+1}-u\_n=2v\_{m+1}-v\_m+a\_0(2-1)+a\_1(2(m+1)-m)+\cdots$$
Set $a\_0=6,a\_r=0\forall r>0$
to find $$v\_{n+1}=\dfrac{v\_n}2=\cdots=\dfrac{v\_{n-p}}{2^{p+1}}$$
Now $v\_0+6=u\_0\iff v\_0=?$ |
40,768,570 | I am using python 3.4. I am able to run my python script without any problem.
But While running my freezed python script , following error have appeared.
I am able to freeze my script successfully too with cx\_freeze.
```
C:\Program Files (x86)\utils>utils.exe
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\requests\packages\__init__.py", line 27, i
n <module>
from . import urllib3
File "C:\Python34\lib\site-packages\requests\packages\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 28, in <module>
from .packages.six.moves.queue import LifoQueue, Empty, Full
File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py", line 203, in load_module
mod = mod._resolve()
File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py", line 115, in _resolve
return _import_module(self.mod)
File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py", line 82, in _import_module
__import__(name)
ImportError: No module named 'queue'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 12, in <module>
__import__(name + "__init__")
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 21, in <module>
scriptModule = __import__(moduleName)
File "utils.py", line 3, in <module>
File "C:\Python34\lib\site-packages\requests\__init__.py", line 63, in <module>
from . import utils
File "C:\Python34\lib\site-packages\requests\utils.py", line 24, in <module>
from ._internal_utils import to_native_string
File "C:\Python34\lib\site-packages\requests\_internal_utils.py", line 11, in <module>
from .compat import is_py2, builtin_str
File "C:\Python34\lib\site-packages\requests\compat.py", line 11, in <module>
from .packages import chardet
File "C:\Python34\lib\site-packages\requests\packages\__init__.py", line 29, in <module>
import urllib3
File "C:\Python34\lib\site-packages\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Python34\lib\site-packages\urllib3\connectionpool.py", line 28, in <module>
from .packages.six.moves.queue import LifoQueue, Empty, Full
File "C:\Python34\lib\site-packages\urllib3\packages\six.py", line 203, in load_module
mod = mod._resolve()
File "C:\Python34\lib\site-packages\urllib3\packages\six.py", line 115, in _resolve
return _import_module(self.mod)
File "C:\Python34\lib\site-packages\urllib3\packages\six.py", line 82, in _import_module
__import__(name)
ImportError: No module named 'queue'
```
Even tried installing package 'six' with no help.
My setup.py is
from cx\_Freeze import setup, Executable
import requests.certs
```
setup(
name = "utils" ,
version = "0.1" ,
description = " utils for accounts" ,
executables = [Executable("utils.py")],
options = {"build_exe": {"packages": ["urllib", "requests"],"include_files":[(requests.certs.where(),'cacert.pem')]}},
```
)
script imports following module
```
import requests
import urllib.request
import uuid
import json
import http.client
from xml.dom import minidom
```
Any help will be highly appreciated. please see me as novice in python | 2016/11/23 | [
"https://Stackoverflow.com/questions/40768570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2678648/"
] | I had the same issues running on Ubuntu with Python 3.5. It seems that `cx_freeze` has problems with libraries that import other files or something like that.
Importing `Queue` together with `requests` worked for me, so:
```
import requests
from multiprocessing import Queue
```
And I don't think specifying `urllib` in `"packages": ["urllib", "requests"]` is necessary. | There are Several options based on project packages:
Method1:
>
> Answer: I solve the problem my issue was I had file named queue.py in the same
> directory
>
>
>
Method2:
Queue is in the multiprocessing module so:
```
from multiprocessing import Queue
```
Method3:
Updating pip from 1.5.6 to 8.1.2
```
`sudo python -m pip install -U pip`
```
Reboot system (don't know if necessary, but only after reboot new version of pip was listed)
Method4:
from six.moves.queue import Queue //I don't know how u import six package |
40,768,570 | I am using python 3.4. I am able to run my python script without any problem.
But While running my freezed python script , following error have appeared.
I am able to freeze my script successfully too with cx\_freeze.
```
C:\Program Files (x86)\utils>utils.exe
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\requests\packages\__init__.py", line 27, i
n <module>
from . import urllib3
File "C:\Python34\lib\site-packages\requests\packages\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 28, in <module>
from .packages.six.moves.queue import LifoQueue, Empty, Full
File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py", line 203, in load_module
mod = mod._resolve()
File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py", line 115, in _resolve
return _import_module(self.mod)
File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py", line 82, in _import_module
__import__(name)
ImportError: No module named 'queue'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 12, in <module>
__import__(name + "__init__")
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 21, in <module>
scriptModule = __import__(moduleName)
File "utils.py", line 3, in <module>
File "C:\Python34\lib\site-packages\requests\__init__.py", line 63, in <module>
from . import utils
File "C:\Python34\lib\site-packages\requests\utils.py", line 24, in <module>
from ._internal_utils import to_native_string
File "C:\Python34\lib\site-packages\requests\_internal_utils.py", line 11, in <module>
from .compat import is_py2, builtin_str
File "C:\Python34\lib\site-packages\requests\compat.py", line 11, in <module>
from .packages import chardet
File "C:\Python34\lib\site-packages\requests\packages\__init__.py", line 29, in <module>
import urllib3
File "C:\Python34\lib\site-packages\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Python34\lib\site-packages\urllib3\connectionpool.py", line 28, in <module>
from .packages.six.moves.queue import LifoQueue, Empty, Full
File "C:\Python34\lib\site-packages\urllib3\packages\six.py", line 203, in load_module
mod = mod._resolve()
File "C:\Python34\lib\site-packages\urllib3\packages\six.py", line 115, in _resolve
return _import_module(self.mod)
File "C:\Python34\lib\site-packages\urllib3\packages\six.py", line 82, in _import_module
__import__(name)
ImportError: No module named 'queue'
```
Even tried installing package 'six' with no help.
My setup.py is
from cx\_Freeze import setup, Executable
import requests.certs
```
setup(
name = "utils" ,
version = "0.1" ,
description = " utils for accounts" ,
executables = [Executable("utils.py")],
options = {"build_exe": {"packages": ["urllib", "requests"],"include_files":[(requests.certs.where(),'cacert.pem')]}},
```
)
script imports following module
```
import requests
import urllib.request
import uuid
import json
import http.client
from xml.dom import minidom
```
Any help will be highly appreciated. please see me as novice in python | 2016/11/23 | [
"https://Stackoverflow.com/questions/40768570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2678648/"
] | I had the same issues running on Ubuntu with Python 3.5. It seems that `cx_freeze` has problems with libraries that import other files or something like that.
Importing `Queue` together with `requests` worked for me, so:
```
import requests
from multiprocessing import Queue
```
And I don't think specifying `urllib` in `"packages": ["urllib", "requests"]` is necessary. | In addition to
```
from multiprocessing import Queue
```
I rolled back to the older version of cx\_freeze:
```
pip install cx-freeze==4.3.3
```
Besides, the "requests" library complained on absence of "urllib3" module. I upgraded this to *requests==2.13.0* and all now works.
I'm using Python 3.4 on Win10. Hope this will help. |
40,768,570 | I am using python 3.4. I am able to run my python script without any problem.
But While running my freezed python script , following error have appeared.
I am able to freeze my script successfully too with cx\_freeze.
```
C:\Program Files (x86)\utils>utils.exe
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\requests\packages\__init__.py", line 27, i
n <module>
from . import urllib3
File "C:\Python34\lib\site-packages\requests\packages\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 28, in <module>
from .packages.six.moves.queue import LifoQueue, Empty, Full
File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py", line 203, in load_module
mod = mod._resolve()
File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py", line 115, in _resolve
return _import_module(self.mod)
File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py", line 82, in _import_module
__import__(name)
ImportError: No module named 'queue'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 12, in <module>
__import__(name + "__init__")
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 21, in <module>
scriptModule = __import__(moduleName)
File "utils.py", line 3, in <module>
File "C:\Python34\lib\site-packages\requests\__init__.py", line 63, in <module>
from . import utils
File "C:\Python34\lib\site-packages\requests\utils.py", line 24, in <module>
from ._internal_utils import to_native_string
File "C:\Python34\lib\site-packages\requests\_internal_utils.py", line 11, in <module>
from .compat import is_py2, builtin_str
File "C:\Python34\lib\site-packages\requests\compat.py", line 11, in <module>
from .packages import chardet
File "C:\Python34\lib\site-packages\requests\packages\__init__.py", line 29, in <module>
import urllib3
File "C:\Python34\lib\site-packages\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Python34\lib\site-packages\urllib3\connectionpool.py", line 28, in <module>
from .packages.six.moves.queue import LifoQueue, Empty, Full
File "C:\Python34\lib\site-packages\urllib3\packages\six.py", line 203, in load_module
mod = mod._resolve()
File "C:\Python34\lib\site-packages\urllib3\packages\six.py", line 115, in _resolve
return _import_module(self.mod)
File "C:\Python34\lib\site-packages\urllib3\packages\six.py", line 82, in _import_module
__import__(name)
ImportError: No module named 'queue'
```
Even tried installing package 'six' with no help.
My setup.py is
from cx\_Freeze import setup, Executable
import requests.certs
```
setup(
name = "utils" ,
version = "0.1" ,
description = " utils for accounts" ,
executables = [Executable("utils.py")],
options = {"build_exe": {"packages": ["urllib", "requests"],"include_files":[(requests.certs.where(),'cacert.pem')]}},
```
)
script imports following module
```
import requests
import urllib.request
import uuid
import json
import http.client
from xml.dom import minidom
```
Any help will be highly appreciated. please see me as novice in python | 2016/11/23 | [
"https://Stackoverflow.com/questions/40768570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2678648/"
] | I had the same issues running on Ubuntu with Python 3.5. It seems that `cx_freeze` has problems with libraries that import other files or something like that.
Importing `Queue` together with `requests` worked for me, so:
```
import requests
from multiprocessing import Queue
```
And I don't think specifying `urllib` in `"packages": ["urllib", "requests"]` is necessary. | In setup.py, `options={"build_exe": {"packages": ["multiprocessing"]}}` can also do the trick. |
40,768,570 | I am using python 3.4. I am able to run my python script without any problem.
But While running my freezed python script , following error have appeared.
I am able to freeze my script successfully too with cx\_freeze.
```
C:\Program Files (x86)\utils>utils.exe
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\requests\packages\__init__.py", line 27, i
n <module>
from . import urllib3
File "C:\Python34\lib\site-packages\requests\packages\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 28, in <module>
from .packages.six.moves.queue import LifoQueue, Empty, Full
File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py", line 203, in load_module
mod = mod._resolve()
File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py", line 115, in _resolve
return _import_module(self.mod)
File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py", line 82, in _import_module
__import__(name)
ImportError: No module named 'queue'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 12, in <module>
__import__(name + "__init__")
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 21, in <module>
scriptModule = __import__(moduleName)
File "utils.py", line 3, in <module>
File "C:\Python34\lib\site-packages\requests\__init__.py", line 63, in <module>
from . import utils
File "C:\Python34\lib\site-packages\requests\utils.py", line 24, in <module>
from ._internal_utils import to_native_string
File "C:\Python34\lib\site-packages\requests\_internal_utils.py", line 11, in <module>
from .compat import is_py2, builtin_str
File "C:\Python34\lib\site-packages\requests\compat.py", line 11, in <module>
from .packages import chardet
File "C:\Python34\lib\site-packages\requests\packages\__init__.py", line 29, in <module>
import urllib3
File "C:\Python34\lib\site-packages\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Python34\lib\site-packages\urllib3\connectionpool.py", line 28, in <module>
from .packages.six.moves.queue import LifoQueue, Empty, Full
File "C:\Python34\lib\site-packages\urllib3\packages\six.py", line 203, in load_module
mod = mod._resolve()
File "C:\Python34\lib\site-packages\urllib3\packages\six.py", line 115, in _resolve
return _import_module(self.mod)
File "C:\Python34\lib\site-packages\urllib3\packages\six.py", line 82, in _import_module
__import__(name)
ImportError: No module named 'queue'
```
Even tried installing package 'six' with no help.
My setup.py is
from cx\_Freeze import setup, Executable
import requests.certs
```
setup(
name = "utils" ,
version = "0.1" ,
description = " utils for accounts" ,
executables = [Executable("utils.py")],
options = {"build_exe": {"packages": ["urllib", "requests"],"include_files":[(requests.certs.where(),'cacert.pem')]}},
```
)
script imports following module
```
import requests
import urllib.request
import uuid
import json
import http.client
from xml.dom import minidom
```
Any help will be highly appreciated. please see me as novice in python | 2016/11/23 | [
"https://Stackoverflow.com/questions/40768570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2678648/"
] | There are Several options based on project packages:
Method1:
>
> Answer: I solve the problem my issue was I had file named queue.py in the same
> directory
>
>
>
Method2:
Queue is in the multiprocessing module so:
```
from multiprocessing import Queue
```
Method3:
Updating pip from 1.5.6 to 8.1.2
```
`sudo python -m pip install -U pip`
```
Reboot system (don't know if necessary, but only after reboot new version of pip was listed)
Method4:
from six.moves.queue import Queue //I don't know how u import six package | In addition to
```
from multiprocessing import Queue
```
I rolled back to the older version of cx\_freeze:
```
pip install cx-freeze==4.3.3
```
Besides, the "requests" library complained on absence of "urllib3" module. I upgraded this to *requests==2.13.0* and all now works.
I'm using Python 3.4 on Win10. Hope this will help. |
40,768,570 | I am using python 3.4. I am able to run my python script without any problem.
But While running my freezed python script , following error have appeared.
I am able to freeze my script successfully too with cx\_freeze.
```
C:\Program Files (x86)\utils>utils.exe
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\requests\packages\__init__.py", line 27, i
n <module>
from . import urllib3
File "C:\Python34\lib\site-packages\requests\packages\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 28, in <module>
from .packages.six.moves.queue import LifoQueue, Empty, Full
File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py", line 203, in load_module
mod = mod._resolve()
File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py", line 115, in _resolve
return _import_module(self.mod)
File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py", line 82, in _import_module
__import__(name)
ImportError: No module named 'queue'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 12, in <module>
__import__(name + "__init__")
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 21, in <module>
scriptModule = __import__(moduleName)
File "utils.py", line 3, in <module>
File "C:\Python34\lib\site-packages\requests\__init__.py", line 63, in <module>
from . import utils
File "C:\Python34\lib\site-packages\requests\utils.py", line 24, in <module>
from ._internal_utils import to_native_string
File "C:\Python34\lib\site-packages\requests\_internal_utils.py", line 11, in <module>
from .compat import is_py2, builtin_str
File "C:\Python34\lib\site-packages\requests\compat.py", line 11, in <module>
from .packages import chardet
File "C:\Python34\lib\site-packages\requests\packages\__init__.py", line 29, in <module>
import urllib3
File "C:\Python34\lib\site-packages\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Python34\lib\site-packages\urllib3\connectionpool.py", line 28, in <module>
from .packages.six.moves.queue import LifoQueue, Empty, Full
File "C:\Python34\lib\site-packages\urllib3\packages\six.py", line 203, in load_module
mod = mod._resolve()
File "C:\Python34\lib\site-packages\urllib3\packages\six.py", line 115, in _resolve
return _import_module(self.mod)
File "C:\Python34\lib\site-packages\urllib3\packages\six.py", line 82, in _import_module
__import__(name)
ImportError: No module named 'queue'
```
Even tried installing package 'six' with no help.
My setup.py is
from cx\_Freeze import setup, Executable
import requests.certs
```
setup(
name = "utils" ,
version = "0.1" ,
description = " utils for accounts" ,
executables = [Executable("utils.py")],
options = {"build_exe": {"packages": ["urllib", "requests"],"include_files":[(requests.certs.where(),'cacert.pem')]}},
```
)
script imports following module
```
import requests
import urllib.request
import uuid
import json
import http.client
from xml.dom import minidom
```
Any help will be highly appreciated. please see me as novice in python | 2016/11/23 | [
"https://Stackoverflow.com/questions/40768570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2678648/"
] | In setup.py, `options={"build_exe": {"packages": ["multiprocessing"]}}` can also do the trick. | In addition to
```
from multiprocessing import Queue
```
I rolled back to the older version of cx\_freeze:
```
pip install cx-freeze==4.3.3
```
Besides, the "requests" library complained on absence of "urllib3" module. I upgraded this to *requests==2.13.0* and all now works.
I'm using Python 3.4 on Win10. Hope this will help. |
78,798 | An API design is actually a programming question, but it can't be answered like "replace `=` by `==` on line 10". Moreover, the asking person has some idea how it should look like and has to start with presenting the idea, otherwise the answers would explore many different directions and not fit together. Starting with such a presentation makes the question appear like no question at all, so it collects closing votes.
Maybe it's just a matter of how the question should be formulated? But I've read the FAQ and have no idea how to make it better. I'm curios if you can advice me.
Maybe is SO not the right place for such questions? If so, I'd see it as a needless constraint.
To be more concrete, this is the [question](https://stackoverflow.com/questions/4914774/better-regex-syntax-ideas), which lead me to this one.
Please, spare me comments about whining.
I'm old enough not to whine because of some critiques.
I'm just asking how to solve a problem of mine. | 2011/02/10 | [
"https://meta.stackexchange.com/questions/78798",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/155925/"
] | I would say programmers.stackexchange.com
This is from its FAQ (emphasis mine):
* **Software engineering**
* Developer testing
* Algorithm and data structure concepts
* **Design patterns**
* **Architecture**
* Development methodologies
* Quality assurance
* Software law
* Programming puzzles
* Freelancing and business concerns | Stack Exchange, in general is setup for questions and answers rather than a discussion. So you are going to have to be tactful in the formulation of your question to avoid close votes. Plus you are going to have to give a clear goal ("question") of what you are looking to solve so that everyone stays on the same course with answers. |
12,751,936 | I am trying to run a fairly simple count based on two MySQL tables but I can't get the syntax right.
```
Table_1 Table_2
Actor | Behavior | Receiver | | Behavior | Type_of_behavior |
Eric a ann a Good
Eric b ann b Bad
Bob a Susan a Good
Bob c Bob c shy
```
I want to `COUNT Table 1.Behavior` by `table_2.Type_of_behavior WHERE Table_1.Behavior = Table_2 Behavior` and `group by Table_1.Actor`. The syntax I've tried is below.
I realize I could join the tables, but for other reasons I need them separate.
```
SELECT actor, JOIN Table_1, Table_2
COUNT(IF(Table_2.Type_of_behavior = "good", 1,0))
AS 'good' FROM Table_1.Behavior GROUP BY actor;
``` | 2012/10/05 | [
"https://Stackoverflow.com/questions/12751936",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1723683/"
] | What you have there is called a "template". As such, you are looking for a templating system.
Assuming those quotes aren't actually in the string, the only template system I know capable of understanding that templating language is [String::Interpolate](http://search.cpan.org/perldoc?String%3a%3aInterpolate).
```
$ perl -E'
use String::Interpolate qw( interpolate );
my $template = q!This is a string with hash value of $foo->{bar}!;
local our $foo = { bar => 123 };
say interpolate($template);
'
This is a string with hash value of 123
```
If the quotes are part of the string, what you have there is Perl code. As such, you could get what you want by executing the string. This can be done using [`eval EXPR`](http://perldoc.perl.org/functions/eval.html).
```
$ perl -E'
my $template = q!"This is a string with hash value of $foo->{bar}"!;
my $foo = { bar => 123 };
my $result = eval($template);
die $@ if $@;
say $result;
'
This is a string with hash value of 123
```
I strongly recommend against this. I'm not particularly found of String::Interpolate either. [Template::Toolkit](http://search.cpan.org/perldoc?Template%3a%3aToolkit) is probably the popular choice for templating system.
```
$ perl -e'
use Template qw( );
my $template = q!This is a string with hash value of [% foo.bar %]!."\n";
my %vars = ( foo => { bar => 123 } );
Template->new()->process(\$template, \%vars);
'
This is a string with hash value of 123
``` | This should work:
```
$foo->{"bar"} = 5;
printf "This is a string with hash value of $foo->{\"bar\"}]";
``` |
66,106,318 | I've got something that bugs me : when somebody requests a route with an id greater than PHP\_INT\_MAX, the id is passed as a string to my controller, thus throwing a 500 error, as my controller's parameters are typed.
For example, given I'm on a 64-bit system, PHP\_INT\_MAX's value is 2^63-1 (9223372036854775807).
If I call my route with 9223372036854775808 (PHP\_INT\_MAX+1, which is still considered as an integer by the router), the kernel tries to send `9.2233720368548E+18` to my controller, hence the 500 error.
I doubt there isn't any way to prevent that to happen, but I didn't find any way to catch this integer-now-string in order to throw a custom error and not the default 500 error I'm having.
Edit: My ids aren't this big, but such an error has been triggered this week-end, alerting the on-call team for nothing. That's why I want to replace it by a 40X error. | 2021/02/08 | [
"https://Stackoverflow.com/questions/66106318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4834168/"
] | On your system `PHP_INT_MAX` has 19 digits. So you could add a route requirement to match only when id has 1-18 digits:
```
/**
* @Route(
* "/some/route/{id}",
* requirements={"id"="\d{1,18}"}
* )
*/
public function yourAction(int $id)
{
...
}
```
More than 18 digits wouldn't match and result in a 404.
But yes, you will "lose" capability to match ids > 999999999999999999 and < PHP\_MAX\_INT, and yes PHP\_MAX\_INT can vary. But this might just be good enough. | You can create a customer Param Converter in your case (<https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html#creating-a-converter>). And apply only for this kind of routes. |
10,102,998 | When I use emacs, I often meet some errors in my code.
When there are some errors in my code, emacs ask me whether I want to "abort" or "terminate-thread".
I want to know what the difference is between "abort" and "terminate-thread" in emacs.
Which one should I choose that will be better?
 | 2012/04/11 | [
"https://Stackoverflow.com/questions/10102998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1326134/"
] | I don't think this question comes from Emacs. So please give us more information (OS in which you run Emacs, which processes you might be running within Emacs, what kind of error happens, where is the actual question displayed (within Emacs's minibuffer, or some popup dialog), ... | Are you using SLIME?
In that case, "abort" will just stop your program, whereas "terminate-thread" will also kill the Lisp thread that SLIME is talking to. |
6,344,655 | I'm consolidating 2 programs into one, and in 2 different files (I have many files), I have a typedef with the same name, different types though.
These types will be used in completely different parts of the program and will never talk to each other, or be used interachangely.
I can of cause just do a search replace in one of the files, but I was wondering if there is another solution to this.
Something like binding a typedef to a specific file.
Or making a typedef local to a class and it's subclasses.
Thanks | 2011/06/14 | [
"https://Stackoverflow.com/questions/6344655",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/237472/"
] | You can encapsulate those `typedef` inside a `namespace`:
```
namespace N1 {
typedef int T;
}
namespace N2 {
typedef int T;
}
```
And in whatever file you want to use first `typedef` simply declare:
```
using namespace N1;
```
same thing for the other one also. | >
> [...]Or making a typedef local to a class
> and it's subclasses.
>
>
>
Well, that's simple:
```
struct A
{
typedef int X;
};
struct B : A
{
X a;
};
struct C
{
typedef double X;
};
```
Typedefs are scoped in C++. |
6,344,655 | I'm consolidating 2 programs into one, and in 2 different files (I have many files), I have a typedef with the same name, different types though.
These types will be used in completely different parts of the program and will never talk to each other, or be used interachangely.
I can of cause just do a search replace in one of the files, but I was wondering if there is another solution to this.
Something like binding a typedef to a specific file.
Or making a typedef local to a class and it's subclasses.
Thanks | 2011/06/14 | [
"https://Stackoverflow.com/questions/6344655",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/237472/"
] | `typedef`s are *always* "local to a file". So it is not exactly clear what you mean by "making it local to a file". Typedef does not introduce an entity with its own linkage, it simply creates an alias to an existing type. For that reason the problem of "making it local to a file" simply does not exist. Each typedef is only visible in the translation unit (file) in which it is declared. So, if you can make sure that your identically named `typedef`s never meet each other in a common translation unit, you problem is formally solved.
It is not a good programming practice though to have the same typedef-name refer to different types in different files, unless these files are naturally separated somehow (like belong to different libraries, or something like that).
Otherwise, you can always rename one of the `typedef`s, or make it a class member or a namespace member. Keep in mind though that in general case the making a `typedef` member of a class will require virtually the same kind of effort as renaming it: the references to that `typedef` will have to be updated in every place in which they are present. Namespaces might be a bit easier, since with namespaces you can use `using` directive.
But again, if your `typedef`s are only referrd from two disjoint sets of files, then the problem does not formally exist. If there are files that are supposed to use both `typedef`s, then the effort you'll have to spend fixing these files will be equivalent to renaming the `typedef`s (regardless of the method you finally choose). | >
> [...]Or making a typedef local to a class
> and it's subclasses.
>
>
>
Well, that's simple:
```
struct A
{
typedef int X;
};
struct B : A
{
X a;
};
struct C
{
typedef double X;
};
```
Typedefs are scoped in C++. |
49,237,821 | I want to change values in a large amount of rows into something else.
I open my data from a csv using pandas as follows:
```
import pandas as pd
import numpy as np
import os
df = pd.read_csv('data.csv', encoding = "ISO-8859-")
```
I then slice my DF changing column names:
```
df1 = df['col 1', 'col 2', 'col 3' 'col 4', 'col 5']
```
Remove useless column names:
```
df2 = df1.columns.str.strip('col')
output:
1, 2, 3, 4, 5
a b a b c
a c a a c
b a c a b
```
Replace values so I can report from the data easier and replace useless answers.
```
df1 = df1.replace('c', None)
df1 = df1.replace('a', 's')
df1 = df1.replace('b', 'n')
```
Now my issues are, when I strip the columns my dataframes loses all of its values, and when I try to re-concat the new df into the previous one it didn't work.
I'm not sure how to use the df.replace on multiple values, also when I run it in different strings and try to append/merge it into the current DF it doesn't really work.
The output I'm after is:
```
output:
1, 2, 3, 4, 5
s n s n NaN
n NaN s s NaN
n s NaN s n
``` | 2018/03/12 | [
"https://Stackoverflow.com/questions/49237821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9375102/"
] | You can pass your conditions to dict
```
df.replace({'c': None,'a':'s','b':'n'})
Out[164]:
1 2 3 4 5
0 s n s n None
1 s None s s None
2 n s None s n
``` | One way is to use a dictionary combined with [`pd.DataFrame.applymap`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.applymap.html), which applies a function elementwise.
```
d = {'c': None, 'a': 's', 'b': 'n'}
res = df.applymap(d.get)
# 1 2 3 4 5
# 0 s n s n None
# 1 s None s s None
# 2 n s None s n
```
**Explanation**
* `df.applymap` works well because *all* your values are being replaced, so `d.get` can be applied on each element without worrying about keys not being found.
* It is likely to be more efficient than `df.replace`, which replaces
each item in the dictionary sequentially. |
4,490,158 | I am getting suspicious that there is no need whatsoever for quantifiers in formal first-order logic. Why do we write $\forall x, P(x)$, when can simply write $P(x)$, assuming that we know that $x$ is a variable (as opposed to a constant).
A similar question has been asked here: [Is the universal quantifier redundant?](https://math.stackexchange.com/questions/4088337/is-the-universal-quantifier-redundant), and a commenter states that the order of quantifiers matters. Indeed, the order of mixed quantifiers matters, but all existential quantifiers can be reformulated as universal quantifiers, so in fact the order does not matter.
I'm struggling to think of a case where a quantifier provides essential information for a statement. | 2022/07/10 | [
"https://math.stackexchange.com/questions/4490158",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/923549/"
] | The problem with replacing $\exists$ with $\neg\forall\neg$ to not have to worry about the order of quantifiers becomes apparent if you actually try doing so and omitting the quantifiers. For instance, $\exists x P(x)$ becomes $\neg \forall x \neg P(x)$ and then you omit the quantifier to get $\neg\neg P(x)$. Wait, that's equivalent to just $P(x)$, which would mean $\forall xP(x)$ under your convention. So $\exists x P(x)$ turned into just $\forall xP(x)$, which isn't right!
The problem here is that the order of negation and universal quantifiers matters. That is, $\forall x\neg P(x)$ is different from $\neg\forall x P(x)$ (so $\neg \forall x \neg P(x)$ is different from $\forall x \neg\neg P(x)$). If you omit universal quantifiers everywhere, you lose this distinction. | Let's consider these two quantified statements:
$$
\begin{align\*}
\forall x\exists y M(x, y) \tag\*{(1)}\\
\exists x\forall y M(x, y) \tag\*{(2)}
\end{align\*}
$$
and let's take the universe of discourse to be people and interpret $M(x,y)$ to mean $y$ is the mother of $x$. Statement (1) says that everybody has a mother while statement (2) say that there there is a person who has every person as a mother. These statements have very different meanings: quantifiers are not redundant.
We write quantifiers to keep close track of the dependencies in our mathematical problems. |
4,490,158 | I am getting suspicious that there is no need whatsoever for quantifiers in formal first-order logic. Why do we write $\forall x, P(x)$, when can simply write $P(x)$, assuming that we know that $x$ is a variable (as opposed to a constant).
A similar question has been asked here: [Is the universal quantifier redundant?](https://math.stackexchange.com/questions/4088337/is-the-universal-quantifier-redundant), and a commenter states that the order of quantifiers matters. Indeed, the order of mixed quantifiers matters, but all existential quantifiers can be reformulated as universal quantifiers, so in fact the order does not matter.
I'm struggling to think of a case where a quantifier provides essential information for a statement. | 2022/07/10 | [
"https://math.stackexchange.com/questions/4490158",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/923549/"
] | The problem with replacing $\exists$ with $\neg\forall\neg$ to not have to worry about the order of quantifiers becomes apparent if you actually try doing so and omitting the quantifiers. For instance, $\exists x P(x)$ becomes $\neg \forall x \neg P(x)$ and then you omit the quantifier to get $\neg\neg P(x)$. Wait, that's equivalent to just $P(x)$, which would mean $\forall xP(x)$ under your convention. So $\exists x P(x)$ turned into just $\forall xP(x)$, which isn't right!
The problem here is that the order of negation and universal quantifiers matters. That is, $\forall x\neg P(x)$ is different from $\neg\forall x P(x)$ (so $\neg \forall x \neg P(x)$ is different from $\forall x \neg\neg P(x)$). If you omit universal quantifiers everywhere, you lose this distinction. | Rob Arthan's answer is exactly right; let me supplement it with an observation from computability theory.
Consider the structure $\mathcal{N}=(\mathbb{N};+,\times)$. It turns out that the quantifier hierarchy over $\mathcal{N}$ is **non-collapsing**: no fixed number of quantifiers will ever be sufficient for capturing all the [definable sets](https://math.stackexchange.com/a/1154042/28111) in $\mathcal{N}$. This turns out (with a slight tweak re: *bounded* quantifiers, resulting in the [arithmetical hierarchy](https://en.wikipedia.org/wiki/Arithmetical_hierarchy)) to have a computational interpretation, according to which definability with $n$ alternations of quantifiers + as many bounded quantifiers as you like corresponds to computability relative to the $n$th "[iterated Halting Problem](https://en.wikipedia.org/wiki/Turing_jump)."
So in a precise sense, "few-quantifier" expressions are *quantitatively less powerful than* "many-quantifier" expressions. |
53,103,321 | I want to convert .raw file to .jpg or .png using some plain python code or any module that is supported in python 2.7 in windows environment.
I tried `rawpy`, PIL modules.
But I am getting some attribute error(frombytes not found); because it is supported in Python3. Let me know if i am wrong..
In `rawpy` the RAW format is not supported.
I need some module or some code that will change .raw to either png or jpeg. | 2018/11/01 | [
"https://Stackoverflow.com/questions/53103321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9305639/"
] | use PIL library
```
from PIL import Image
im = Image.open("img.raw")
rgb_im = im.convert('RGB')
rgb_im.save('img.jpg')
``` | You can use the convert utility which comes with image magic.
```
convert -size 640x360 -depth 8 bgr:input.raw out.jpeg
```
-size -> WxH
bgr is the format of data. it can be rgb also. |
29,887,232 | I am trying to finish one activity from another.
For that purpose I am having **only** the component name of that activity.
How can i finish that ? | 2015/04/27 | [
"https://Stackoverflow.com/questions/29887232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4627995/"
] | >
> Question - is it not possible to ignore the apachehttpclient library provided by google and use a newer version of the library instead?
>
>
>
It is not. The [Apache HttpClient Android Port](http://hc.apache.org/httpcomponents-client-4.3.x/android-port.html) can deployed along-side with the old version shipped with the platform.
>
> Why isnt this possible?
>
>
>
It is believed to be for security reasons. | ok, so i found this at the Apache website,
Google Android 1.0 was released with a pre-BETA snapshot of Apache HttpClient. To coincide with the first Android release Apache HttpClient 4.0 APIs had to be frozen prematurely, while many of interfaces and internal structures were still not fully worked out. As Apache HttpClient 4.0 was maturing the project was expecting Google to incorporate the latest code improvements into their code tree. Unfortunately it did not happen. Version of Apache HttpClient shipped with Android has effectively become a fork. Eventually Google decided to discontinue further development of their fork while refusing to upgrade to the stock version of Apache HttpClient citing compatibility concerns as a reason for such decision. As a result those Android developers who would like to continue using Apache HttpClient APIs on Android cannot take advantage of newer features, performance improvements and bug fixes.
Question - is it not possible to ignore the apachehttpclient library provided by google and use a newer version of the library instead? Why isnt this possible? |
29,887,232 | I am trying to finish one activity from another.
For that purpose I am having **only** the component name of that activity.
How can i finish that ? | 2015/04/27 | [
"https://Stackoverflow.com/questions/29887232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4627995/"
] | >
> Question - is it not possible to ignore the apachehttpclient library provided by google and use a newer version of the library instead?
>
>
>
It is not. The [Apache HttpClient Android Port](http://hc.apache.org/httpcomponents-client-4.3.x/android-port.html) can deployed along-side with the old version shipped with the platform.
>
> Why isnt this possible?
>
>
>
It is believed to be for security reasons. | You need to give the below code snippet in the dependencies section in the build.gradle file of you app module.
```
configurations {
compile.exclude group: "org.apache.httpcomponents", module: "httpclient"
}
``` |
22,998,699 | >
> Windows 7 - 64-bit
>
>
> Git version: 1.7.9
>
>
>
I don't have any problem with lightweight tag, but when trying Annotated git tag command under windows command console (DOS), I get the error as shown below:
```
c:\tempWorkingFolder\Tobedeleted\mastertemp\btc>git tag -a test_tag -f 'test_tag'
fatal: too many params
```
Please help me with this issue.
**Note**: both lightweight and annotated tags work fine under 32-bit windows command console (DOS).
Thanks. | 2014/04/10 | [
"https://Stackoverflow.com/questions/22998699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3521095/"
] | I had the same issue, using double quotes instead of single quotes solved it:
```
git tag -a test_tag -f "test_tag"
``` | Tag name should be the last parameter in your command. See the below syntax.
```
git tag [-a | -s | -u <keyid>] [-f] [-m <msg> | -F <file>]
<tagname> [<commit> | <object>]
```
Your command should look like:
```
git tag -a -f -m 'Commit message' test_tag
``` |
169,692 | I recently ran an encounter on a "restaurant boat" where my players had to obtain info from a noble on board. They successfully bluffed/bribed/sneaked their way on board. Certain areas of the ship were off limits to guest, such as the crew's quarter's, the captain's cabin, and the lower deck with rowers moving the ship along.
My players found a somewhat quiet spot on deck. They proclaimed they wanted to sneak past the guests, who were busy with eating/socializing/etc., into the forbidden areas. One of them cast *pass without trace*, and I asked them to all roll for Stealth. No one got less than 19 on their Stealth check (after modifiers). They then proceeded to "sneak" past guests into the upper areas (not forbidden per se) and then further into "Staff Only" areas.
How do I adjudicate this?
Obviously, they pose as guests, no weapons or armor on, so they would just blend into the crowd and then, in an opportune moment, sneak past a door/curtain/rope barrier. But they are still moving in plain sight of at least a dozen NPCs. The NPCs can probably see them, but they do not *perceive* them.
The same problem would arise for me if they wanted to escape someone following them in a dense marketplace or in a crowded tavern. How can you Hide/roll for Stealth in a crowd of - admittedly uninterested in you - NPCs? | 2020/05/29 | [
"https://rpg.stackexchange.com/questions/169692",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/56835/"
] | Stealth was most likely the wrong choice
========================================
Stealth implies that you are impossible to see. If you succeed on your stealth attempt, you are hidden, if you fail, you are not hidden.
Your players aren't actually trying to be hidden, anybody can see them, they simply don't register them as *somebody who shouldn't be there*.
Blending in with the crowd really shouldn't require a stealth check at all. It might, however, if you like, entail any of the following:
* Persuasion: To get other guests to cooperate if they at some point figure out things are fishy.
* Deception: To bluff their way past guards who are suspicious about the players actually being guests
* Performance: Deception works great for pretending to be a guest when you are not, but performance could also work, depending on who you ask.
None of these things require stealth, because you aren't trying to be unseen, you're trying to blend in.
Stealth doesn't enter the ordeal until they actually try to go somewhere a normal guest would not be allowed. The moment they want to pass into Staff Only areas and the guards would react if a normal guest did that, then they have to actually use their stealth skill, and they would obviously have to do so in a way that makes sense, you can't stealth your way through a door in plain sight, regardless of how well you rolled.
Blending into a crowd to escape from somebody else is a completely different thing than blending into a crowd to not stand out. Once your target no longer has line of sight to you, you can try to stealth. If you succeed, the target no longer knows where you are and you can keep moving in the crowd until they have direct line of sight of you again, at which point you are no longer hidden and the chase most likely continues.
It's the difference between:
"I need to hide in the crowd because I'm a wanted man and if I'm spotted they will arrest me!" and "I need to blend in because I don't want to look out of place and get asked questions by nosy guards." | A Charisma (Deception) vs Wisdom (Insight) check
================================================
I'm guessing that you're referring to a *certain location* in Storm King's Thunder. If I'm right, the book suggests the following on page 216:
>
> The adventurers might try to replace one or more of the workers [of the Grand Dame] [...] A character who wants to get aboard in this fashion must **succeed on a Charisma (Deception) check contested by Captain Storn's Wisdom (Insight) check**. A character who wins the contest can board the ship without raising suspicion.
>
>
>
The informational text on this page is talking about getting on board from the docks while it is tied up between trips, not getting into the *CREW ONLY* sections of the ship while it is underway and entertaining guests onboard but I think the Charisma (Deception) vs Wisdom (Insight) check works for both situations.
It might not be the Captain's Insight they are trying to oppose but that of whomever sees them attempting to access the off limits areas. This could be a crew member or the pit boss Pow Ming).
Even if I'm totally wrong on the campaign, I think the recommendation is still universally applicable. |
169,692 | I recently ran an encounter on a "restaurant boat" where my players had to obtain info from a noble on board. They successfully bluffed/bribed/sneaked their way on board. Certain areas of the ship were off limits to guest, such as the crew's quarter's, the captain's cabin, and the lower deck with rowers moving the ship along.
My players found a somewhat quiet spot on deck. They proclaimed they wanted to sneak past the guests, who were busy with eating/socializing/etc., into the forbidden areas. One of them cast *pass without trace*, and I asked them to all roll for Stealth. No one got less than 19 on their Stealth check (after modifiers). They then proceeded to "sneak" past guests into the upper areas (not forbidden per se) and then further into "Staff Only" areas.
How do I adjudicate this?
Obviously, they pose as guests, no weapons or armor on, so they would just blend into the crowd and then, in an opportune moment, sneak past a door/curtain/rope barrier. But they are still moving in plain sight of at least a dozen NPCs. The NPCs can probably see them, but they do not *perceive* them.
The same problem would arise for me if they wanted to escape someone following them in a dense marketplace or in a crowded tavern. How can you Hide/roll for Stealth in a crowd of - admittedly uninterested in you - NPCs? | 2020/05/29 | [
"https://rpg.stackexchange.com/questions/169692",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/56835/"
] | Stealth was most likely the wrong choice
========================================
Stealth implies that you are impossible to see. If you succeed on your stealth attempt, you are hidden, if you fail, you are not hidden.
Your players aren't actually trying to be hidden, anybody can see them, they simply don't register them as *somebody who shouldn't be there*.
Blending in with the crowd really shouldn't require a stealth check at all. It might, however, if you like, entail any of the following:
* Persuasion: To get other guests to cooperate if they at some point figure out things are fishy.
* Deception: To bluff their way past guards who are suspicious about the players actually being guests
* Performance: Deception works great for pretending to be a guest when you are not, but performance could also work, depending on who you ask.
None of these things require stealth, because you aren't trying to be unseen, you're trying to blend in.
Stealth doesn't enter the ordeal until they actually try to go somewhere a normal guest would not be allowed. The moment they want to pass into Staff Only areas and the guards would react if a normal guest did that, then they have to actually use their stealth skill, and they would obviously have to do so in a way that makes sense, you can't stealth your way through a door in plain sight, regardless of how well you rolled.
Blending into a crowd to escape from somebody else is a completely different thing than blending into a crowd to not stand out. Once your target no longer has line of sight to you, you can try to stealth. If you succeed, the target no longer knows where you are and you can keep moving in the crowd until they have direct line of sight of you again, at which point you are no longer hidden and the chase most likely continues.
It's the difference between:
"I need to hide in the crowd because I'm a wanted man and if I'm spotted they will arrest me!" and "I need to blend in because I don't want to look out of place and get asked questions by nosy guards." | Pass without trace probably wouldn't help
-----------------------------------------
[](https://i.stack.imgur.com/1noz5.jpg)
Does this camo suit make you more stealthy? I bet it does.
Would it help you to blend in with crowds better? I don't think so.
But let's start with the basics first.
The DM should always explicitly ask for checks
----------------------------------------------
>
> One of them cast pass without trace and they all rolled for Stealth
>
>
>
Why did they roll? In 5e the only way would be the DM asksing "make a X check", and the DM shouldn't ask for the Dexterity (Stealth) check *before* characters actually do something sneaky. I think this is the primary thing you made "wrong", all other is just a follow-up.
[Characters do not "use skills" in 5e anymore](https://rpg.stackexchange.com/questions/159361/). Actions like "I use my stealth skill" followed up by a inevitable dice roll was the 3.x thing. In 5e players describe, what their character do, then DM can optionally ask for a dice roll, then DM describes the outcome. This is how the game is described in the "How to play" chapter of the PHB.
So, in this case, you should ask "what do you do", "how do you do that", "what are you trying to accomplish". Then players describe, what their characters do and why. Then you describe the outcome. Maybe you won't ask for any check in the process, it is perfectly fine according to the DMG.
>
> One of them cast pass without trace... They then proceeded to "sneak" past guests
>
>
> How do I adjudicate this?
>
>
>
You follow the [spell description](https://www.dndbeyond.com/spells/pass-without-trace). It says "A veil of shadows and silence radiates from you". Since [there is no ignorable text in 5e spells](https://rpg.stackexchange.com/questions/78012/), this is the part of the spell effect. So the characters followed by magical "veil of shadows and silence" enter the crowd. I doubt this could stay unnoticed, unless common people in your world are blatantly ignorant about magic.
>
> The same problem would arise for me if they wanted to escape someone following them in a dense marketplace or in a crowded tavern. How can you Hide/roll for Stealth in a crowd
>
>
>
DMG suggests Dexterity (Stealth) check with advantage, see page 253 "Ending a Chase". It also says "Other factors might help or hinder the quarry's ability to escape, at your discretion". Ultimately it is up to you, the DM, as long as you follow the common sense and be consistent in your adjudications.
### Summary:
* You ask for a check, not players
* Ask for a check when the consequences are imminent; do not ask beforehand
* When you hesitate, ask players for clarifications. "How do you do that?"
* Pay attention to details in spell descriptions; they might give a hint about how the spell works
* "Dexterity (Stealth)" is fine, also is "Charisma (Stealth)" or any other ability check; RAW you can't choose "wrong" check here — ultimately it's up to the DM, use common sense when adjudicating ability checks; you might also not to ask for a check at all |
169,692 | I recently ran an encounter on a "restaurant boat" where my players had to obtain info from a noble on board. They successfully bluffed/bribed/sneaked their way on board. Certain areas of the ship were off limits to guest, such as the crew's quarter's, the captain's cabin, and the lower deck with rowers moving the ship along.
My players found a somewhat quiet spot on deck. They proclaimed they wanted to sneak past the guests, who were busy with eating/socializing/etc., into the forbidden areas. One of them cast *pass without trace*, and I asked them to all roll for Stealth. No one got less than 19 on their Stealth check (after modifiers). They then proceeded to "sneak" past guests into the upper areas (not forbidden per se) and then further into "Staff Only" areas.
How do I adjudicate this?
Obviously, they pose as guests, no weapons or armor on, so they would just blend into the crowd and then, in an opportune moment, sneak past a door/curtain/rope barrier. But they are still moving in plain sight of at least a dozen NPCs. The NPCs can probably see them, but they do not *perceive* them.
The same problem would arise for me if they wanted to escape someone following them in a dense marketplace or in a crowded tavern. How can you Hide/roll for Stealth in a crowd of - admittedly uninterested in you - NPCs? | 2020/05/29 | [
"https://rpg.stackexchange.com/questions/169692",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/56835/"
] | Stealth was most likely the wrong choice
========================================
Stealth implies that you are impossible to see. If you succeed on your stealth attempt, you are hidden, if you fail, you are not hidden.
Your players aren't actually trying to be hidden, anybody can see them, they simply don't register them as *somebody who shouldn't be there*.
Blending in with the crowd really shouldn't require a stealth check at all. It might, however, if you like, entail any of the following:
* Persuasion: To get other guests to cooperate if they at some point figure out things are fishy.
* Deception: To bluff their way past guards who are suspicious about the players actually being guests
* Performance: Deception works great for pretending to be a guest when you are not, but performance could also work, depending on who you ask.
None of these things require stealth, because you aren't trying to be unseen, you're trying to blend in.
Stealth doesn't enter the ordeal until they actually try to go somewhere a normal guest would not be allowed. The moment they want to pass into Staff Only areas and the guards would react if a normal guest did that, then they have to actually use their stealth skill, and they would obviously have to do so in a way that makes sense, you can't stealth your way through a door in plain sight, regardless of how well you rolled.
Blending into a crowd to escape from somebody else is a completely different thing than blending into a crowd to not stand out. Once your target no longer has line of sight to you, you can try to stealth. If you succeed, the target no longer knows where you are and you can keep moving in the crowd until they have direct line of sight of you again, at which point you are no longer hidden and the chase most likely continues.
It's the difference between:
"I need to hide in the crowd because I'm a wanted man and if I'm spotted they will arrest me!" and "I need to blend in because I don't want to look out of place and get asked questions by nosy guards." | There are some clear rules concerning hiding in the PHB:
>
> The GM decides when circumstances are appropriate for hiding.
>
>
>
And
>
> You can't hide from a creature that can see you clearly.
>
>
>
When you find that waiting for an opportune moment to slip past someone is appropriate, that is covered by the rules. It is also worth noting that an opportune moment is probably one when there is specifically no person looking in the exact relevant direction. From your question I gather that the players need to conceal their entry to the forbidden areas and not their presence in general.
Additionally, Pass without Trace is a one hour concentration spell giving a bonus to stealth for the duration. It does not say that the check must be made immediately. Therefore, you can also demand the check as they enter a forbidden area. In that case, sneaking through the crowd is unnecessary.
If there is ever, realistically, a moment when no one looks in a specific direction would depend on the number of people in the room (unless a distraction was provided). But this is not clearly ruled by the book and you can decide this as the GM. |
169,692 | I recently ran an encounter on a "restaurant boat" where my players had to obtain info from a noble on board. They successfully bluffed/bribed/sneaked their way on board. Certain areas of the ship were off limits to guest, such as the crew's quarter's, the captain's cabin, and the lower deck with rowers moving the ship along.
My players found a somewhat quiet spot on deck. They proclaimed they wanted to sneak past the guests, who were busy with eating/socializing/etc., into the forbidden areas. One of them cast *pass without trace*, and I asked them to all roll for Stealth. No one got less than 19 on their Stealth check (after modifiers). They then proceeded to "sneak" past guests into the upper areas (not forbidden per se) and then further into "Staff Only" areas.
How do I adjudicate this?
Obviously, they pose as guests, no weapons or armor on, so they would just blend into the crowd and then, in an opportune moment, sneak past a door/curtain/rope barrier. But they are still moving in plain sight of at least a dozen NPCs. The NPCs can probably see them, but they do not *perceive* them.
The same problem would arise for me if they wanted to escape someone following them in a dense marketplace or in a crowded tavern. How can you Hide/roll for Stealth in a crowd of - admittedly uninterested in you - NPCs? | 2020/05/29 | [
"https://rpg.stackexchange.com/questions/169692",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/56835/"
] | A Stealth check is appropriate for this, but probably Charisma (Stealth) as opposed to the usual Dexterity (Stealth). It should probably be opposed by a Perception or Insight check on the pursuers part.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Stealth is described as (***emphasis mine***):
>
> Make a Dexterity (Stealth) check ***when you attempt to conceal yourself from enemies***, slink past guards, ***slip away without being noticed***, or sneak up on someone without being seen or heard.
>
>
>
You might, in this case, change the base ability required for the stealth check to something more appropriate, like a Charisma (Stealth) check. The DMG specifically allows for this in the section on Using Ability Scores:
>
> Under certain circumstances, you can decide a character’s proficiency in a skill can be applied to a different ability check. For example, you might decide that a character forced to swim from an island to the mainland must succeed on a Constitution check (as opposed to a Strength check) because of the distance involved. The character is proficient in the Athletics skill, which covers swimming, so you allow the character’s proficiency bonus to apply to this ability check. In effect, you’re asking for a Constitution (Athletics) check, instead of a Strength (Athletics) check.
>
>
> Often, players ask whether they can apply a skill proficiency to an ability check. If a player can provide a good justification for why a character’s training and aptitude in a skill should apply to the check, go ahead and allow it, rewarding the player’s creative thinking.
>
>
>
Why Charisma? Well Charisma is a measure of your personality. It states:
>
> Charisma measures your ability to interact effectively with others. It includes such factors as confidence and eloquence, and it can represent a charming or commanding personality.
>
>
>
From what you have described, your characters are in a social situation, and one in which they need to interact with people (blending in to the point of non-notability is still interacting with the room).
This would be opposed by one of:
* Insight
>
> Your Wisdom (Insight) check decides whether you can determine the true intentions of a creature, such as when searching out a lie or predicting someone’s next move. Doing so involves gleaning clues from body language, speech habits, and changes in mannerisms.
>
>
>
* Perception [either Wisdom (Perception) or Charisma (Perception)]
>
> Your Wisdom (Perception) check lets you spot, hear, or otherwise detect the presence of something. It measures your general awareness of your surroundings and the keenness of your senses.
>
>
>
* Investigation:
>
> When you look around for clues and make deductions based on those clues, you make an Intelligence (Investigation) check.
>
>
>
* An Intelligence or Charisma (Survival) check
+ Intelligence for making deductions, or Charisma for how well someone could read the room.
+ Survival for following someone through a crowd (akin to tracking someone using their footprints, you track them by other people's reactions to them)
+ Wisdom (Survival) may even still be appropriate here.
### So what caused the weird disconnect?
The bit that caused the problem, and was likely inappropriate is the Pass without a Trace spell. It's designed specifically for dark situations where silence is key.
Pass without a Trace states(***emphasis*** and *emphasis* mine):
>
> ***A veil of shadows and silence radiates from you, masking you and your companions from detection***. For the duration, each creature you choose within 30 feet of you (including you) *has a +10 bonus to Dexterity (Stealth) checks* and ***can't be tracked except by magical means***. A creature that receives this bonus leaves behind no tracks or other traces of its passage.
>
>
>
Pass without a Trace, in an urban setting, coincidentally makes you cause a significant disturbance in a crowd (as opposed to just regularly walking through a crowd). Imagine you were a commoner and a shadowy, indiscernible, mass of figures surrounds you making no sound (as the characters walk around you). What are you going to do...probably scream your head off at the terrifying mass that is around you!
5e does not have fluff text, it is rules text all the way down. Pass without a Trace doesn't make you invisible. It doesn't make the people on the street beside you *not see you*. It makes *you* not disturb your surroundings, easier to hide in the shadows and not make any noise.
By making it a Charisma (Stealth) check you still allow the characters to use their Stealth skill, but Pass without a Trace *no longer gives a bonus to the check* as it's not Dexterity (Stealth). | Stealth fits the situation
==========================
The [Stealth](https://www.dndbeyond.com/sources/basic-rules/using-ability-scores#Stealth) section lists the situation you describe as an example:
>
> Make a Dexterity (Stealth) check when you attempt to **conceal yourself from enemies, slink past guards, slip away without being noticed**, or sneak up on someone without being seen or heard.
>
>
>
We can see that 3 out of 4 of the examples listed under this skill directly apply to the situation you are describing. The players are concealing themselves, slinking past guards, and slipping away without being noticed. It's a perfect fit. Clearly, Stealth is the right choice for this situation.
Taking ques from Hiding
-----------------------
Hiding is a mechanic that uses Stealth checks. The abridged version of hiding is: roll a stealth check, enemies contest this with their passive perception, or with their perception if they make an active attempt. Until enemies succeed this check (or the hider leaves hiding), they can't be seen. It would be reasonable to use something similar in this situation too.
Your players rolled well, and the (perhaps intoxicated and distracted) party guests weren't too observant. It doesn't sound like anyone was particularly suspicious of the PCs, and so no one was actively hunting them. The plan has succeeded. Good job players! |
169,692 | I recently ran an encounter on a "restaurant boat" where my players had to obtain info from a noble on board. They successfully bluffed/bribed/sneaked their way on board. Certain areas of the ship were off limits to guest, such as the crew's quarter's, the captain's cabin, and the lower deck with rowers moving the ship along.
My players found a somewhat quiet spot on deck. They proclaimed they wanted to sneak past the guests, who were busy with eating/socializing/etc., into the forbidden areas. One of them cast *pass without trace*, and I asked them to all roll for Stealth. No one got less than 19 on their Stealth check (after modifiers). They then proceeded to "sneak" past guests into the upper areas (not forbidden per se) and then further into "Staff Only" areas.
How do I adjudicate this?
Obviously, they pose as guests, no weapons or armor on, so they would just blend into the crowd and then, in an opportune moment, sneak past a door/curtain/rope barrier. But they are still moving in plain sight of at least a dozen NPCs. The NPCs can probably see them, but they do not *perceive* them.
The same problem would arise for me if they wanted to escape someone following them in a dense marketplace or in a crowded tavern. How can you Hide/roll for Stealth in a crowd of - admittedly uninterested in you - NPCs? | 2020/05/29 | [
"https://rpg.stackexchange.com/questions/169692",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/56835/"
] | Pass without trace probably wouldn't help
-----------------------------------------
[](https://i.stack.imgur.com/1noz5.jpg)
Does this camo suit make you more stealthy? I bet it does.
Would it help you to blend in with crowds better? I don't think so.
But let's start with the basics first.
The DM should always explicitly ask for checks
----------------------------------------------
>
> One of them cast pass without trace and they all rolled for Stealth
>
>
>
Why did they roll? In 5e the only way would be the DM asksing "make a X check", and the DM shouldn't ask for the Dexterity (Stealth) check *before* characters actually do something sneaky. I think this is the primary thing you made "wrong", all other is just a follow-up.
[Characters do not "use skills" in 5e anymore](https://rpg.stackexchange.com/questions/159361/). Actions like "I use my stealth skill" followed up by a inevitable dice roll was the 3.x thing. In 5e players describe, what their character do, then DM can optionally ask for a dice roll, then DM describes the outcome. This is how the game is described in the "How to play" chapter of the PHB.
So, in this case, you should ask "what do you do", "how do you do that", "what are you trying to accomplish". Then players describe, what their characters do and why. Then you describe the outcome. Maybe you won't ask for any check in the process, it is perfectly fine according to the DMG.
>
> One of them cast pass without trace... They then proceeded to "sneak" past guests
>
>
> How do I adjudicate this?
>
>
>
You follow the [spell description](https://www.dndbeyond.com/spells/pass-without-trace). It says "A veil of shadows and silence radiates from you". Since [there is no ignorable text in 5e spells](https://rpg.stackexchange.com/questions/78012/), this is the part of the spell effect. So the characters followed by magical "veil of shadows and silence" enter the crowd. I doubt this could stay unnoticed, unless common people in your world are blatantly ignorant about magic.
>
> The same problem would arise for me if they wanted to escape someone following them in a dense marketplace or in a crowded tavern. How can you Hide/roll for Stealth in a crowd
>
>
>
DMG suggests Dexterity (Stealth) check with advantage, see page 253 "Ending a Chase". It also says "Other factors might help or hinder the quarry's ability to escape, at your discretion". Ultimately it is up to you, the DM, as long as you follow the common sense and be consistent in your adjudications.
### Summary:
* You ask for a check, not players
* Ask for a check when the consequences are imminent; do not ask beforehand
* When you hesitate, ask players for clarifications. "How do you do that?"
* Pay attention to details in spell descriptions; they might give a hint about how the spell works
* "Dexterity (Stealth)" is fine, also is "Charisma (Stealth)" or any other ability check; RAW you can't choose "wrong" check here — ultimately it's up to the DM, use common sense when adjudicating ability checks; you might also not to ask for a check at all | Stealth fits the situation
==========================
The [Stealth](https://www.dndbeyond.com/sources/basic-rules/using-ability-scores#Stealth) section lists the situation you describe as an example:
>
> Make a Dexterity (Stealth) check when you attempt to **conceal yourself from enemies, slink past guards, slip away without being noticed**, or sneak up on someone without being seen or heard.
>
>
>
We can see that 3 out of 4 of the examples listed under this skill directly apply to the situation you are describing. The players are concealing themselves, slinking past guards, and slipping away without being noticed. It's a perfect fit. Clearly, Stealth is the right choice for this situation.
Taking ques from Hiding
-----------------------
Hiding is a mechanic that uses Stealth checks. The abridged version of hiding is: roll a stealth check, enemies contest this with their passive perception, or with their perception if they make an active attempt. Until enemies succeed this check (or the hider leaves hiding), they can't be seen. It would be reasonable to use something similar in this situation too.
Your players rolled well, and the (perhaps intoxicated and distracted) party guests weren't too observant. It doesn't sound like anyone was particularly suspicious of the PCs, and so no one was actively hunting them. The plan has succeeded. Good job players! |
169,692 | I recently ran an encounter on a "restaurant boat" where my players had to obtain info from a noble on board. They successfully bluffed/bribed/sneaked their way on board. Certain areas of the ship were off limits to guest, such as the crew's quarter's, the captain's cabin, and the lower deck with rowers moving the ship along.
My players found a somewhat quiet spot on deck. They proclaimed they wanted to sneak past the guests, who were busy with eating/socializing/etc., into the forbidden areas. One of them cast *pass without trace*, and I asked them to all roll for Stealth. No one got less than 19 on their Stealth check (after modifiers). They then proceeded to "sneak" past guests into the upper areas (not forbidden per se) and then further into "Staff Only" areas.
How do I adjudicate this?
Obviously, they pose as guests, no weapons or armor on, so they would just blend into the crowd and then, in an opportune moment, sneak past a door/curtain/rope barrier. But they are still moving in plain sight of at least a dozen NPCs. The NPCs can probably see them, but they do not *perceive* them.
The same problem would arise for me if they wanted to escape someone following them in a dense marketplace or in a crowded tavern. How can you Hide/roll for Stealth in a crowd of - admittedly uninterested in you - NPCs? | 2020/05/29 | [
"https://rpg.stackexchange.com/questions/169692",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/56835/"
] | Pass without trace probably wouldn't help
-----------------------------------------
[](https://i.stack.imgur.com/1noz5.jpg)
Does this camo suit make you more stealthy? I bet it does.
Would it help you to blend in with crowds better? I don't think so.
But let's start with the basics first.
The DM should always explicitly ask for checks
----------------------------------------------
>
> One of them cast pass without trace and they all rolled for Stealth
>
>
>
Why did they roll? In 5e the only way would be the DM asksing "make a X check", and the DM shouldn't ask for the Dexterity (Stealth) check *before* characters actually do something sneaky. I think this is the primary thing you made "wrong", all other is just a follow-up.
[Characters do not "use skills" in 5e anymore](https://rpg.stackexchange.com/questions/159361/). Actions like "I use my stealth skill" followed up by a inevitable dice roll was the 3.x thing. In 5e players describe, what their character do, then DM can optionally ask for a dice roll, then DM describes the outcome. This is how the game is described in the "How to play" chapter of the PHB.
So, in this case, you should ask "what do you do", "how do you do that", "what are you trying to accomplish". Then players describe, what their characters do and why. Then you describe the outcome. Maybe you won't ask for any check in the process, it is perfectly fine according to the DMG.
>
> One of them cast pass without trace... They then proceeded to "sneak" past guests
>
>
> How do I adjudicate this?
>
>
>
You follow the [spell description](https://www.dndbeyond.com/spells/pass-without-trace). It says "A veil of shadows and silence radiates from you". Since [there is no ignorable text in 5e spells](https://rpg.stackexchange.com/questions/78012/), this is the part of the spell effect. So the characters followed by magical "veil of shadows and silence" enter the crowd. I doubt this could stay unnoticed, unless common people in your world are blatantly ignorant about magic.
>
> The same problem would arise for me if they wanted to escape someone following them in a dense marketplace or in a crowded tavern. How can you Hide/roll for Stealth in a crowd
>
>
>
DMG suggests Dexterity (Stealth) check with advantage, see page 253 "Ending a Chase". It also says "Other factors might help or hinder the quarry's ability to escape, at your discretion". Ultimately it is up to you, the DM, as long as you follow the common sense and be consistent in your adjudications.
### Summary:
* You ask for a check, not players
* Ask for a check when the consequences are imminent; do not ask beforehand
* When you hesitate, ask players for clarifications. "How do you do that?"
* Pay attention to details in spell descriptions; they might give a hint about how the spell works
* "Dexterity (Stealth)" is fine, also is "Charisma (Stealth)" or any other ability check; RAW you can't choose "wrong" check here — ultimately it's up to the DM, use common sense when adjudicating ability checks; you might also not to ask for a check at all | A Charisma (Deception) vs Wisdom (Insight) check
================================================
I'm guessing that you're referring to a *certain location* in Storm King's Thunder. If I'm right, the book suggests the following on page 216:
>
> The adventurers might try to replace one or more of the workers [of the Grand Dame] [...] A character who wants to get aboard in this fashion must **succeed on a Charisma (Deception) check contested by Captain Storn's Wisdom (Insight) check**. A character who wins the contest can board the ship without raising suspicion.
>
>
>
The informational text on this page is talking about getting on board from the docks while it is tied up between trips, not getting into the *CREW ONLY* sections of the ship while it is underway and entertaining guests onboard but I think the Charisma (Deception) vs Wisdom (Insight) check works for both situations.
It might not be the Captain's Insight they are trying to oppose but that of whomever sees them attempting to access the off limits areas. This could be a crew member or the pit boss Pow Ming).
Even if I'm totally wrong on the campaign, I think the recommendation is still universally applicable. |
169,692 | I recently ran an encounter on a "restaurant boat" where my players had to obtain info from a noble on board. They successfully bluffed/bribed/sneaked their way on board. Certain areas of the ship were off limits to guest, such as the crew's quarter's, the captain's cabin, and the lower deck with rowers moving the ship along.
My players found a somewhat quiet spot on deck. They proclaimed they wanted to sneak past the guests, who were busy with eating/socializing/etc., into the forbidden areas. One of them cast *pass without trace*, and I asked them to all roll for Stealth. No one got less than 19 on their Stealth check (after modifiers). They then proceeded to "sneak" past guests into the upper areas (not forbidden per se) and then further into "Staff Only" areas.
How do I adjudicate this?
Obviously, they pose as guests, no weapons or armor on, so they would just blend into the crowd and then, in an opportune moment, sneak past a door/curtain/rope barrier. But they are still moving in plain sight of at least a dozen NPCs. The NPCs can probably see them, but they do not *perceive* them.
The same problem would arise for me if they wanted to escape someone following them in a dense marketplace or in a crowded tavern. How can you Hide/roll for Stealth in a crowd of - admittedly uninterested in you - NPCs? | 2020/05/29 | [
"https://rpg.stackexchange.com/questions/169692",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/56835/"
] | A Charisma (Deception) vs Wisdom (Insight) check
================================================
I'm guessing that you're referring to a *certain location* in Storm King's Thunder. If I'm right, the book suggests the following on page 216:
>
> The adventurers might try to replace one or more of the workers [of the Grand Dame] [...] A character who wants to get aboard in this fashion must **succeed on a Charisma (Deception) check contested by Captain Storn's Wisdom (Insight) check**. A character who wins the contest can board the ship without raising suspicion.
>
>
>
The informational text on this page is talking about getting on board from the docks while it is tied up between trips, not getting into the *CREW ONLY* sections of the ship while it is underway and entertaining guests onboard but I think the Charisma (Deception) vs Wisdom (Insight) check works for both situations.
It might not be the Captain's Insight they are trying to oppose but that of whomever sees them attempting to access the off limits areas. This could be a crew member or the pit boss Pow Ming).
Even if I'm totally wrong on the campaign, I think the recommendation is still universally applicable. | Stealth fits the situation
==========================
The [Stealth](https://www.dndbeyond.com/sources/basic-rules/using-ability-scores#Stealth) section lists the situation you describe as an example:
>
> Make a Dexterity (Stealth) check when you attempt to **conceal yourself from enemies, slink past guards, slip away without being noticed**, or sneak up on someone without being seen or heard.
>
>
>
We can see that 3 out of 4 of the examples listed under this skill directly apply to the situation you are describing. The players are concealing themselves, slinking past guards, and slipping away without being noticed. It's a perfect fit. Clearly, Stealth is the right choice for this situation.
Taking ques from Hiding
-----------------------
Hiding is a mechanic that uses Stealth checks. The abridged version of hiding is: roll a stealth check, enemies contest this with their passive perception, or with their perception if they make an active attempt. Until enemies succeed this check (or the hider leaves hiding), they can't be seen. It would be reasonable to use something similar in this situation too.
Your players rolled well, and the (perhaps intoxicated and distracted) party guests weren't too observant. It doesn't sound like anyone was particularly suspicious of the PCs, and so no one was actively hunting them. The plan has succeeded. Good job players! |
169,692 | I recently ran an encounter on a "restaurant boat" where my players had to obtain info from a noble on board. They successfully bluffed/bribed/sneaked their way on board. Certain areas of the ship were off limits to guest, such as the crew's quarter's, the captain's cabin, and the lower deck with rowers moving the ship along.
My players found a somewhat quiet spot on deck. They proclaimed they wanted to sneak past the guests, who were busy with eating/socializing/etc., into the forbidden areas. One of them cast *pass without trace*, and I asked them to all roll for Stealth. No one got less than 19 on their Stealth check (after modifiers). They then proceeded to "sneak" past guests into the upper areas (not forbidden per se) and then further into "Staff Only" areas.
How do I adjudicate this?
Obviously, they pose as guests, no weapons or armor on, so they would just blend into the crowd and then, in an opportune moment, sneak past a door/curtain/rope barrier. But they are still moving in plain sight of at least a dozen NPCs. The NPCs can probably see them, but they do not *perceive* them.
The same problem would arise for me if they wanted to escape someone following them in a dense marketplace or in a crowded tavern. How can you Hide/roll for Stealth in a crowd of - admittedly uninterested in you - NPCs? | 2020/05/29 | [
"https://rpg.stackexchange.com/questions/169692",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/56835/"
] | Pass without trace probably wouldn't help
-----------------------------------------
[](https://i.stack.imgur.com/1noz5.jpg)
Does this camo suit make you more stealthy? I bet it does.
Would it help you to blend in with crowds better? I don't think so.
But let's start with the basics first.
The DM should always explicitly ask for checks
----------------------------------------------
>
> One of them cast pass without trace and they all rolled for Stealth
>
>
>
Why did they roll? In 5e the only way would be the DM asksing "make a X check", and the DM shouldn't ask for the Dexterity (Stealth) check *before* characters actually do something sneaky. I think this is the primary thing you made "wrong", all other is just a follow-up.
[Characters do not "use skills" in 5e anymore](https://rpg.stackexchange.com/questions/159361/). Actions like "I use my stealth skill" followed up by a inevitable dice roll was the 3.x thing. In 5e players describe, what their character do, then DM can optionally ask for a dice roll, then DM describes the outcome. This is how the game is described in the "How to play" chapter of the PHB.
So, in this case, you should ask "what do you do", "how do you do that", "what are you trying to accomplish". Then players describe, what their characters do and why. Then you describe the outcome. Maybe you won't ask for any check in the process, it is perfectly fine according to the DMG.
>
> One of them cast pass without trace... They then proceeded to "sneak" past guests
>
>
> How do I adjudicate this?
>
>
>
You follow the [spell description](https://www.dndbeyond.com/spells/pass-without-trace). It says "A veil of shadows and silence radiates from you". Since [there is no ignorable text in 5e spells](https://rpg.stackexchange.com/questions/78012/), this is the part of the spell effect. So the characters followed by magical "veil of shadows and silence" enter the crowd. I doubt this could stay unnoticed, unless common people in your world are blatantly ignorant about magic.
>
> The same problem would arise for me if they wanted to escape someone following them in a dense marketplace or in a crowded tavern. How can you Hide/roll for Stealth in a crowd
>
>
>
DMG suggests Dexterity (Stealth) check with advantage, see page 253 "Ending a Chase". It also says "Other factors might help or hinder the quarry's ability to escape, at your discretion". Ultimately it is up to you, the DM, as long as you follow the common sense and be consistent in your adjudications.
### Summary:
* You ask for a check, not players
* Ask for a check when the consequences are imminent; do not ask beforehand
* When you hesitate, ask players for clarifications. "How do you do that?"
* Pay attention to details in spell descriptions; they might give a hint about how the spell works
* "Dexterity (Stealth)" is fine, also is "Charisma (Stealth)" or any other ability check; RAW you can't choose "wrong" check here — ultimately it's up to the DM, use common sense when adjudicating ability checks; you might also not to ask for a check at all | There are some clear rules concerning hiding in the PHB:
>
> The GM decides when circumstances are appropriate for hiding.
>
>
>
And
>
> You can't hide from a creature that can see you clearly.
>
>
>
When you find that waiting for an opportune moment to slip past someone is appropriate, that is covered by the rules. It is also worth noting that an opportune moment is probably one when there is specifically no person looking in the exact relevant direction. From your question I gather that the players need to conceal their entry to the forbidden areas and not their presence in general.
Additionally, Pass without Trace is a one hour concentration spell giving a bonus to stealth for the duration. It does not say that the check must be made immediately. Therefore, you can also demand the check as they enter a forbidden area. In that case, sneaking through the crowd is unnecessary.
If there is ever, realistically, a moment when no one looks in a specific direction would depend on the number of people in the room (unless a distraction was provided). But this is not clearly ruled by the book and you can decide this as the GM. |
169,692 | I recently ran an encounter on a "restaurant boat" where my players had to obtain info from a noble on board. They successfully bluffed/bribed/sneaked their way on board. Certain areas of the ship were off limits to guest, such as the crew's quarter's, the captain's cabin, and the lower deck with rowers moving the ship along.
My players found a somewhat quiet spot on deck. They proclaimed they wanted to sneak past the guests, who were busy with eating/socializing/etc., into the forbidden areas. One of them cast *pass without trace*, and I asked them to all roll for Stealth. No one got less than 19 on their Stealth check (after modifiers). They then proceeded to "sneak" past guests into the upper areas (not forbidden per se) and then further into "Staff Only" areas.
How do I adjudicate this?
Obviously, they pose as guests, no weapons or armor on, so they would just blend into the crowd and then, in an opportune moment, sneak past a door/curtain/rope barrier. But they are still moving in plain sight of at least a dozen NPCs. The NPCs can probably see them, but they do not *perceive* them.
The same problem would arise for me if they wanted to escape someone following them in a dense marketplace or in a crowded tavern. How can you Hide/roll for Stealth in a crowd of - admittedly uninterested in you - NPCs? | 2020/05/29 | [
"https://rpg.stackexchange.com/questions/169692",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/56835/"
] | A Charisma (Deception) vs Wisdom (Insight) check
================================================
I'm guessing that you're referring to a *certain location* in Storm King's Thunder. If I'm right, the book suggests the following on page 216:
>
> The adventurers might try to replace one or more of the workers [of the Grand Dame] [...] A character who wants to get aboard in this fashion must **succeed on a Charisma (Deception) check contested by Captain Storn's Wisdom (Insight) check**. A character who wins the contest can board the ship without raising suspicion.
>
>
>
The informational text on this page is talking about getting on board from the docks while it is tied up between trips, not getting into the *CREW ONLY* sections of the ship while it is underway and entertaining guests onboard but I think the Charisma (Deception) vs Wisdom (Insight) check works for both situations.
It might not be the Captain's Insight they are trying to oppose but that of whomever sees them attempting to access the off limits areas. This could be a crew member or the pit boss Pow Ming).
Even if I'm totally wrong on the campaign, I think the recommendation is still universally applicable. | There are some clear rules concerning hiding in the PHB:
>
> The GM decides when circumstances are appropriate for hiding.
>
>
>
And
>
> You can't hide from a creature that can see you clearly.
>
>
>
When you find that waiting for an opportune moment to slip past someone is appropriate, that is covered by the rules. It is also worth noting that an opportune moment is probably one when there is specifically no person looking in the exact relevant direction. From your question I gather that the players need to conceal their entry to the forbidden areas and not their presence in general.
Additionally, Pass without Trace is a one hour concentration spell giving a bonus to stealth for the duration. It does not say that the check must be made immediately. Therefore, you can also demand the check as they enter a forbidden area. In that case, sneaking through the crowd is unnecessary.
If there is ever, realistically, a moment when no one looks in a specific direction would depend on the number of people in the room (unless a distraction was provided). But this is not clearly ruled by the book and you can decide this as the GM. |
169,692 | I recently ran an encounter on a "restaurant boat" where my players had to obtain info from a noble on board. They successfully bluffed/bribed/sneaked their way on board. Certain areas of the ship were off limits to guest, such as the crew's quarter's, the captain's cabin, and the lower deck with rowers moving the ship along.
My players found a somewhat quiet spot on deck. They proclaimed they wanted to sneak past the guests, who were busy with eating/socializing/etc., into the forbidden areas. One of them cast *pass without trace*, and I asked them to all roll for Stealth. No one got less than 19 on their Stealth check (after modifiers). They then proceeded to "sneak" past guests into the upper areas (not forbidden per se) and then further into "Staff Only" areas.
How do I adjudicate this?
Obviously, they pose as guests, no weapons or armor on, so they would just blend into the crowd and then, in an opportune moment, sneak past a door/curtain/rope barrier. But they are still moving in plain sight of at least a dozen NPCs. The NPCs can probably see them, but they do not *perceive* them.
The same problem would arise for me if they wanted to escape someone following them in a dense marketplace or in a crowded tavern. How can you Hide/roll for Stealth in a crowd of - admittedly uninterested in you - NPCs? | 2020/05/29 | [
"https://rpg.stackexchange.com/questions/169692",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/56835/"
] | A Stealth check is appropriate for this, but probably Charisma (Stealth) as opposed to the usual Dexterity (Stealth). It should probably be opposed by a Perception or Insight check on the pursuers part.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Stealth is described as (***emphasis mine***):
>
> Make a Dexterity (Stealth) check ***when you attempt to conceal yourself from enemies***, slink past guards, ***slip away without being noticed***, or sneak up on someone without being seen or heard.
>
>
>
You might, in this case, change the base ability required for the stealth check to something more appropriate, like a Charisma (Stealth) check. The DMG specifically allows for this in the section on Using Ability Scores:
>
> Under certain circumstances, you can decide a character’s proficiency in a skill can be applied to a different ability check. For example, you might decide that a character forced to swim from an island to the mainland must succeed on a Constitution check (as opposed to a Strength check) because of the distance involved. The character is proficient in the Athletics skill, which covers swimming, so you allow the character’s proficiency bonus to apply to this ability check. In effect, you’re asking for a Constitution (Athletics) check, instead of a Strength (Athletics) check.
>
>
> Often, players ask whether they can apply a skill proficiency to an ability check. If a player can provide a good justification for why a character’s training and aptitude in a skill should apply to the check, go ahead and allow it, rewarding the player’s creative thinking.
>
>
>
Why Charisma? Well Charisma is a measure of your personality. It states:
>
> Charisma measures your ability to interact effectively with others. It includes such factors as confidence and eloquence, and it can represent a charming or commanding personality.
>
>
>
From what you have described, your characters are in a social situation, and one in which they need to interact with people (blending in to the point of non-notability is still interacting with the room).
This would be opposed by one of:
* Insight
>
> Your Wisdom (Insight) check decides whether you can determine the true intentions of a creature, such as when searching out a lie or predicting someone’s next move. Doing so involves gleaning clues from body language, speech habits, and changes in mannerisms.
>
>
>
* Perception [either Wisdom (Perception) or Charisma (Perception)]
>
> Your Wisdom (Perception) check lets you spot, hear, or otherwise detect the presence of something. It measures your general awareness of your surroundings and the keenness of your senses.
>
>
>
* Investigation:
>
> When you look around for clues and make deductions based on those clues, you make an Intelligence (Investigation) check.
>
>
>
* An Intelligence or Charisma (Survival) check
+ Intelligence for making deductions, or Charisma for how well someone could read the room.
+ Survival for following someone through a crowd (akin to tracking someone using their footprints, you track them by other people's reactions to them)
+ Wisdom (Survival) may even still be appropriate here.
### So what caused the weird disconnect?
The bit that caused the problem, and was likely inappropriate is the Pass without a Trace spell. It's designed specifically for dark situations where silence is key.
Pass without a Trace states(***emphasis*** and *emphasis* mine):
>
> ***A veil of shadows and silence radiates from you, masking you and your companions from detection***. For the duration, each creature you choose within 30 feet of you (including you) *has a +10 bonus to Dexterity (Stealth) checks* and ***can't be tracked except by magical means***. A creature that receives this bonus leaves behind no tracks or other traces of its passage.
>
>
>
Pass without a Trace, in an urban setting, coincidentally makes you cause a significant disturbance in a crowd (as opposed to just regularly walking through a crowd). Imagine you were a commoner and a shadowy, indiscernible, mass of figures surrounds you making no sound (as the characters walk around you). What are you going to do...probably scream your head off at the terrifying mass that is around you!
5e does not have fluff text, it is rules text all the way down. Pass without a Trace doesn't make you invisible. It doesn't make the people on the street beside you *not see you*. It makes *you* not disturb your surroundings, easier to hide in the shadows and not make any noise.
By making it a Charisma (Stealth) check you still allow the characters to use their Stealth skill, but Pass without a Trace *no longer gives a bonus to the check* as it's not Dexterity (Stealth). | There are some clear rules concerning hiding in the PHB:
>
> The GM decides when circumstances are appropriate for hiding.
>
>
>
And
>
> You can't hide from a creature that can see you clearly.
>
>
>
When you find that waiting for an opportune moment to slip past someone is appropriate, that is covered by the rules. It is also worth noting that an opportune moment is probably one when there is specifically no person looking in the exact relevant direction. From your question I gather that the players need to conceal their entry to the forbidden areas and not their presence in general.
Additionally, Pass without Trace is a one hour concentration spell giving a bonus to stealth for the duration. It does not say that the check must be made immediately. Therefore, you can also demand the check as they enter a forbidden area. In that case, sneaking through the crowd is unnecessary.
If there is ever, realistically, a moment when no one looks in a specific direction would depend on the number of people in the room (unless a distraction was provided). But this is not clearly ruled by the book and you can decide this as the GM. |
70,597,841 | I'm trying to make the text-info element display only when I hover over the container element using only CSS and no JS and it doesn't work, would love some advice.
I was assuming it had something to do with the display flex instead of display block so I attempted that too, but it didn't help.
Note that even without the hover, the text doesn't display on the page and I can't tell why.
```css
body {
color: #2f80ed;
font-family: Avenir, Helvetica, Arial, sans-serif;
margin: 0;
display: flex;
height: 100vh;
}
p {
margin: 0;
}
.container {
width: 520px;
margin: auto;
}
.container img {
width: 100%;
}
.text {
width: 400px;
margin: 0 auto;
cursor: pointer;
}
.text-code {
text-align: center;
font-size: 120px;
font-weight: 400;
}
.container:hover+.text-info {
display: flex;
}
.text-info {
display: none;
text-align: center;
font-size: 20px;
font-weight: 400;
opacity: 0;
transition: opacity .4s ease-in-out;
}
footer {
width: 100%;
position: absolute;
bottom: 30px;
}
footer p {
margin: auto;
font-size: 16px;
}
footer a {
color: #2f80ed;
}
```
```html
<div class="container">
<img src="empty-boxes.svg" alt="error" />
<div class="text">
<p class="text-code">404</p>
<p class="text-info">
404 is an error.
</p>
</div>
</div>
<footer>
<p>Go back.</p>
<a href="https://google.com"></a>
</footer>
``` | 2022/01/05 | [
"https://Stackoverflow.com/questions/70597841",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16761342/"
] | ```
import requests
baseURL = "https://myurl.repl.co"
x = requests.get(baseURL)
print(x.content)
``` | Install the requests module (much nicer than using urllib2) and then define a route which makes the necessary request - something like:
```
import requests
from flask import Flask
app = Flask(__name__)
@app.route('/some-url')
def get_data():
return requests.get('http://example.com').content
```
Depending on your set up though, it'd be better to configure your webserver to reverse proxy to the target site under a certain URL. |
56,291 | I'm not sure if commercial fish is inspected in any way. I know that most commercial fish is caught in nets, so I don't think that bait is used.
When individuals go fishing, they use worms, flies, or non-kosher fish as bait. After they catch the fish and reel it in, before using the fish, do they need to inspect it for the bait? I doubt that it has been digested that quickly. | 2015/03/10 | [
"https://judaism.stackexchange.com/questions/56291",
"https://judaism.stackexchange.com",
"https://judaism.stackexchange.com/users/5275/"
] | The OU kashrus site writes <https://www.ou.org/torah/halacha/hashoneh-halachos/sat_08_25_12/>
"46:43 Small worms are sometimes found in fish, in the brain, the liver, the intestines, the mouth and the gills. This is common in such fish as pike and herring. When this is common, one must check for them. Small insects can also be found on the outside of a fish, on or near the fins, in the mouth and behind the gills. One must also check these places and remove any such bugs."
Although the stomach and intestines are normally gutted, if one were to try eating that area then it sounds like the worm bait would need to be removed. | Modern commercial fishing uses many different techniques depending on the species sought. [Both trawling, nets and line with auto-baited hooks are utilized](https://en.wikipedia.org/wiki/Fish_processing). Additionally, there are many different types of processing done commercially. Some would require supervision to be certified kosher and some do not (meaning the supervision happens further down the line from the actual fisherman). In cases where the catch is gutted, filleted and flash frozen on the ship, all the inspection requirements mentioned in the OU link in NJM's answer are necessary.
The OU link is primarily aimed at end user (the actual consumer), not the commercial fishing industry. Commercially, inspection usually is happening at the canning/packaging level because that is where the gutting and filleting takes place.
Where baits are used, they would need to be removed which usually happens at the gutting level of processing. So too, non-kosher species need to be removed to comply with the Torah requirement stated in Vayikra 11:9-12. This is why skin with identifying scales attached to each fillet are usually required for filleted, packaged product.
At the consumer level, inspection for parasites does need to be performed, particularly if whole fish are purchased. Most parasites, when present, are found in the digestive tract or the gills. They too are removed during gutting or removal of the heads during processing. If parasites are discovered in the fillet, it should not be used. This would be an indication of infestation of that fish.
On rare occasion, parasites can be found in canned, fully processed fish like tuna and albacore. Since canned fish is actually cooked in the can, something called *retort cooking*, they shouldn't be used if parasites are found. The size of the parasite would in most cases exceed the 1/60 proportion compared to the tuna in that can and would not be considered nullified.
There are special techniques to handle fresh, kosher fish that have been processed together with non-kosher fish to remove the non-kosher fish oil from the surface of the kosher species. |
20,558,153 | I have a search button that goes into my database and searches on a name but when there are two entries for the same name it is only bringing me back one and i can't figure out why. Below is the code I am using now.
```
public boolean search(String str1, String username){//search function for the access history search with two parameters
boolean condition = true;
String dataSourceName = "securitySystem";//setting string datasource to the securitySystem datasource
String dbUrl = "jdbc:odbc:" + dataSourceName;//creating the database path for the connection
try{
//Type of connection driver used
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//Connection variable or object param: dbPath, userName, password
Connection con = DriverManager.getConnection(dbUrl, "", "");
Statement statement = con.createStatement();//creating the statement which is equal to the connection statement
if (!(username.equals(""))){
PreparedStatement ps = con.prepareStatement("select * from securitysystem.accessHistory where name = ?");//query to be executed
ps.setString(1, username);//insert the strings into the statement
ResultSet rs=ps.executeQuery();//execute the query
if(rs.next()){//while the rs (ResultSet) has returned data to cycle through
JTable table = new JTable(buildTableModel(rs));//build a JTable which is reflective of the ResultSet (rs)
JOptionPane.showMessageDialog(null, new JScrollPane(table));//put scrollpane on the table
}
else{
JOptionPane.showMessageDialog(null,"There has been no system logins at this time");// else- show a dialog box with a message for the user
}
}
statement.close();//close the connection
} catch (Exception e) {//catch error
System.out.println(e);
}
return condition;
}
``` | 2013/12/13 | [
"https://Stackoverflow.com/questions/20558153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3073941/"
] | Matthias is spot on.
A @Stateless annotated bean is an EJB which by default provides [Container-Managed-Transactions](http://docs.oracle.com/javaee/6/tutorial/doc/bncij.html). CMT will by default create a new transaction if the client of the EJB did not provide one.
>
> **Required Attribute** If the client is running within a transaction and
> invokes the enterprise bean’s method, the method executes within the
> client’s transaction. If the client is not associated with a
> transaction, the container starts a new transaction before running the
> method.
>
>
> The Required attribute is the implicit transaction attribute for all
> enterprise bean methods running with container-managed transaction
> demarcation. You typically do not set the Required attribute unless
> you need to override another transaction attribute. Because
> transaction attributes are declarative, you can easily change them
> later.
>
>
>
In the recent java-ee-7 [tuturial](http://www.oracle.com/technetwork/articles/java/jaxrs20-1929352.html) on jax-rs, Oracle has example of using EJBs (@Stateless).
>
> ... the combination of EJB's @javax.ejb.Asynchronous annotation and
> the @Suspended AsyncResponse enables asynchronous execution of
> business logic with eventual notification of the interested client.
> Any JAX-RS root resource can be annotated with @Stateless or
> @Singleton annotations and can, in effect, function as an EJB ..
>
>
>
Main difference between @RequestScoped vs @Stateless in this scenario will be that the container can pool the EJBs and avoid some expensive construct/destroy operations that might be needed for beans that would otherwise be constructed on every request. | When you don't want to make your root resource as an EJB (by annotating it with `@Stateless`), you can use a `UserTransaction`.
```
@Path("/things")
@RequestScoped
public class ThingsResource{
@POST
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response create(final Thing thing){
utx.begin();
em.joinTransaction();
final ThingEntity thingEntity = new ThingEntity(thing);
em.persist(thing);
utx.commit();
final URI uri = uriInfo.getAbsolutePathBuilder()
.path(Long.toString(thingEntity.getId())).build();
return Response.created(uri).build();
}
@PersistenceContext(unitName = "somePU")
private transient EntityManager em;
@Resource
private transient UserTransaction ut;
@Context
private transient UriInfo uriInfo;
}
``` |
67,425,200 | HTML and inline JS code:
```
<a onclick='show(user)'>${user.firstName + " " + user.lastName}</a>
```
Inside this show function I am passing an object User which has 5-6 properties, but when I used debugger it is not showing me as an object.
I also tried this , and this is showing be user as object in debugger but I am getting uncaught syntax error.
```
<a onclick='show(${user})'>${user.firstName + " " + user.lastName}</a>
```
I want to pass it as object so that i can utilise its properties.
```js
const displayUsers = (users) => {
const htmlString = users
.map((user) => {
debugger;
return `
<li>
<a onclick='show(user)'>${user.firstName + " " + user.lastName}</a>
</li>
`;
})
.join('');
usersList.innerHTML = htmlString;
console.log(users, 'list')
// console.log(htmlString)
};
function show(user)
{
alert(user);
console.log( user.aonId);
};
``` | 2021/05/06 | [
"https://Stackoverflow.com/questions/67425200",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15856627/"
] | We can use transform here with groupby:
```py
s = df["Business hours"].eq("Yes").groupby(df["Date"]).transform("Sum")
df[s >= 7]
``` | Try groupby filter function :
```
def filter_rows(x):
try:
x['Business hours'].value_counts()['Yes'] >= 7
return True
except KeyError as e:
return False
df = df.groupby('Date').filter(filter_rows)
``` |
29,022,569 | I've written a VB .Net program that does selective intensity pixel modification on graphic files. It's a lot faster than it was when I started (20 seconds vs 90 seconds), but the total time to process multiple images is still slow. I typically run 64 12 MP images, and it takes about 24 minutes to process them all. I thought that if I use multiple threads, each thread processing a subset of the total image set, I could speed things up, so I added multiple background workers. But when I run multiple threads from the program with Thread#.RunWorkerAsync(), the saved images are screwed up. Here's a "good" image, run in a single thread:
<http://freegeographytools.com/good.jpg>
And here's a typical example of the same image when two threads are running:
<http://freegeographytools.com/bad.jpg>
These results are essentially typical, but the "bad" image has a clean stripe near the bottom that looks correct; that doesn't normally appear on most images.
Each thread calls its own subroutine with independent variables, so there should be no variable "cross-contamination". While these results were obtained with images saved as JPG, I've gotten the same results with images saved as TIF files. I've also tried separating the images into different directories, and processing each directory simultaneously, each with its own thread - same result. To modify pixels, I've used GetPixel/SetPixel to change the pixel value, and also used LockBits to modify the image in a byte array - results are the same for both methods. One thread good, two+ thread bad. I'm sure it's something obvious, but I can't figure it out. Suggestions would very much be appreciated. | 2015/03/13 | [
"https://Stackoverflow.com/questions/29022569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4665101/"
] | Change the image's cap insets to make the image fit the way you want:
```
UIImage *barButtonImage = [[UIImage imageNamed:@"ZSSBackArrow"] resizableImageWithCapInsets:UIEdgeInsetsMake(0,width,0,0)];
```
This will keep the width of the image as your specified width.
You may need to play with the numbers a bit to get it just right. | Using the background image property forces the stretching. Try using the image property and play around with the image inset/offset to position the image where you want it. |
45,730,832 | I am using **rxjs/Rx** in angular 2 to create a clock and making lap and Sprint time laps from it.
The Code block is as follows:
**HTML:** (app.component.html)
```
<div class="row">
<div class="col-xs-5">
<div class="row">
<div class="col-xs-6">
<h2>Lap Time</h2>
<ul *ngFor="let lTime of lapTimes">
<li>{{lTime}}</li>
</ul>
</div>
<div class="col-xs-6">
<h2>Sprint Time</h2>
<ul *ngFor="let sTime of sprintTimes">
<li>{{sTime}}</li>
</ul>
</div>
</div>
</div>
<div class="col-xs-5">
<h1>Current Time: {{timeNow}}</h1>
<div>
<button type="button" class="btn btn-large btn-block btn-default" (click)="onStart()">Start Timer</button>
<button type="button" class="btn btn-large btn-block btn-default" (click)="onLoop()">Sprint and Lap</button>
<button type="button" class="btn btn-large btn-block btn-default" (click)="onStop()">Stop Timer</button>
</div>
</div>
</div>
```
**TypeScript:** (app.component.ts)
```
import { Component } from '@angular/core';
import { Observable, Subscription } from 'rxjs/Rx';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
sprintTimes: number[] = [0];
lapTimes: number[] = [0];
timeNow: number = 0;
timer: Observable<any> = Observable.timer(0, 1000);
subs: Subscription;
onStart () {
this.subs = this.timer.subscribe((value) => {
this.tickerFunc();
});
// this.onLoop();
}
onLoop () {
this.onLap();
this.onSprint();
}
onSprint () {
this.sprintTimes.push(this.timeNow);
}
onLap () {
this.lapTimes.push(this.timeNow - this.sprintTimes[this.sprintTimes.length - 1]);
}
onStop () {
this.subs.unsubscribe();
}
tickerFunc () {
this.timeNow++;
}
}
```
This is allowing me to create a clocking functionality. But the **Rxjs/Rx** is insufficiently documented (Its hard for me to understand it via its documentation only).
Is there any better way to do the work I'm doing here in angular? (The main purpose of mine here is: I want to conduct a online exam/ mock test.)
When I'm pressing the Start Clock Button Twice, my clock is ticking as twice as fast. (I don't understand this behavior)
Is there any other third part tool to make this easier?
Sorry that my Type Script code is not properly Indented, I'm finding it hard to use the text editor. And also this is not a place to do homework. | 2017/08/17 | [
"https://Stackoverflow.com/questions/45730832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6152976/"
] | After some digging and understanding in the doc, I found a working solution:
```
"mappings": {
// ...
"cartproduct": {
"_parent": {
"type": "product"
},
"properties": {
"productId": {
"type": "keyword"
},
// etc...
}
}
}
```
And the search query:
```
{
"query": {
"has_parent": {
"parent_type": "product",
"query": {
"term": {
"enabled": true
}
}
}
},
"aggs": {
"products": {
"terms": {
"field": "productId"
}
}
}
}
``` | Why are you restricting your search to only **cartproduct** type? Assuming that you want to aggregate the **productid** throughout the entire index, this type level restriction can be substituted by following to fulfil your requirement.
```
{
"query": {
"bool": {
"filter": {
"term": {
"enabled": "true"
}
}
},
"aggs": {
"products": {
"terms": {
"field": "productId"
}
}
}
}
}
``` |
10,844,448 | Is there a way to detect if the javascript see if there was a click, and if there was, it can do something?
```
function clickin() {
var mouseDown = 0;
document.body.onmousedown = function() {
++mouseDown;
var alle = document.getElementsByClassName('box');
for (var i = 0; i < alle.length; i++) {
value = "this.title='1'"
alle[i].setAttribute("onmouseover", value);
}
document.body.onmouseup = function() {
--mouseDown;
var alle = document.getElementsByClassName('box');
for (var i = 0; i < alle.length; i++) {
value = "0"
alle[i].setAttribute("onmouseover", value);
}
}
}
}
``` | 2012/06/01 | [
"https://Stackoverflow.com/questions/10844448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1418521/"
] | And the question is?
You have already the code.
Anyway, from my point of view, go for [jQuery](http://jquery.com/) and it's [mouse events](http://api.jquery.com/category/events/mouse-events/). | javascript can handle clicks, we use it for that. But it seems that you want to check if clicks are being handled on the document.
if you want to check that specifically at document level you can check if
```
document.onclick==null
```
and also checking mousedown/mouseup events on same way
because if you define a handler as you doing above you will destroy the previous if it exists
if you want to check on a more generic way you have to traverse the document and check for those events on every element.
however event handler can be bound latter and dynamically and checking all tree of a document repeatedly is not a good idea.
in that case (and also in the previous) you can audit the functions **addEventListener** and/or **attachEvent**
see function auditing here:
[How to implement a simple prioritized listener pattern in JavaScript](https://stackoverflow.com/questions/10839146/how-to-implement-a-simple-prioritized-listener-pattern-in-javascript/10839304#10839304)
and with that you can also audit the mouse events without destroying them. |
8,710,581 | >
> **Possible Duplicate:**
>
> [What is the difference between Managed C++ and C++/CLI?](https://stackoverflow.com/questions/2443811/what-is-the-difference-between-managed-c-and-c-cli)
>
> [What is CLI/C++ exactly? How does it differ to 'normal' c++?](https://stackoverflow.com/questions/6399493/what-is-cli-c-exactly-how-does-it-differ-to-normal-c)
>
>
>
I am in doubt of distinguishing between C++ and C++.NET.
Is that right C++ is unmanaged code and C++.NET is managed code?
I need to program for a project in C++. For better building the GUI, I would prefer to use C++.NET.
I also have another plain C++ library (unmanaged C++ DLL file), will it be possible to use it as a normal DLL library in the C++.NET project? | 2012/01/03 | [
"https://Stackoverflow.com/questions/8710581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/413174/"
] | >
> Is that right C++ is unmanaged code and C++.NET is managed code.
>
>
>
There's no such thing as "C++.NET". There's C++/CLI, which is basically C++ with Microsoft extensions that allow you to write code targeting the .NET framework. C++/CLI code compiles to CLR bytecode, and runs on a virtual machine just like C#. I'll assume you're actually talking about C++/CLI.
With respect to that, one can say standard C++ is unmanaged and C++/CLI is managed, but that's very much Microsoft terminology. You'll never see the term "unmanaged" used this way when talking about standard C++ unless in comparison with C++/CLI.
Both standard C++ and C++/CLI can be compiled by the same Visual C++ compiler. The former is the default on VC++ compilers, while a compiler switch is needed to make it compile in latter mode.
>
> I need to program for a project in C++. For better building the GUI, I
> would prefer to use C++.NET.
>
>
>
You can build GUI programs in C++ just as well as C++/CLI. It's just harder because there isn't a standard library in standard C++ for building GUI like the .NET framework has, but there are lots of projects out there like [Qt](http://qt.nokia.com/products/) and [wxWidgets](http://www.wxwidgets.org/) which provide a C++ GUI framework.
>
> I also have another plain C++ library (unmanaged C++ dll), will it be
> possible to use it as a normal dll library in the C++.NET project?
>
>
>
Yes. It might take some extra work to deal with the different standard C++ data types and .NET data types, but you can certainly make it work. | * Yes, C++ is unmanaged code and C++/CLI is managed.
* Yes, you can use your unmanaged C++ DLL in your C++/CLI project. But you have to write a wrapper for that. That means you have to define the unmanaged methods you want to access in your C++/CLI project.
Example:
```
using System.Runtime.InteropServices;
[DllImport("YourDLLName")]
public static extern void UnmanagedMethodName(string parameter1);
``` |
8,710,581 | >
> **Possible Duplicate:**
>
> [What is the difference between Managed C++ and C++/CLI?](https://stackoverflow.com/questions/2443811/what-is-the-difference-between-managed-c-and-c-cli)
>
> [What is CLI/C++ exactly? How does it differ to 'normal' c++?](https://stackoverflow.com/questions/6399493/what-is-cli-c-exactly-how-does-it-differ-to-normal-c)
>
>
>
I am in doubt of distinguishing between C++ and C++.NET.
Is that right C++ is unmanaged code and C++.NET is managed code?
I need to program for a project in C++. For better building the GUI, I would prefer to use C++.NET.
I also have another plain C++ library (unmanaged C++ DLL file), will it be possible to use it as a normal DLL library in the C++.NET project? | 2012/01/03 | [
"https://Stackoverflow.com/questions/8710581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/413174/"
] | >
> Is that right C++ is unmanaged code and C++.NET is managed code.
>
>
>
There's no such thing as "C++.NET". There's C++/CLI, which is basically C++ with Microsoft extensions that allow you to write code targeting the .NET framework. C++/CLI code compiles to CLR bytecode, and runs on a virtual machine just like C#. I'll assume you're actually talking about C++/CLI.
With respect to that, one can say standard C++ is unmanaged and C++/CLI is managed, but that's very much Microsoft terminology. You'll never see the term "unmanaged" used this way when talking about standard C++ unless in comparison with C++/CLI.
Both standard C++ and C++/CLI can be compiled by the same Visual C++ compiler. The former is the default on VC++ compilers, while a compiler switch is needed to make it compile in latter mode.
>
> I need to program for a project in C++. For better building the GUI, I
> would prefer to use C++.NET.
>
>
>
You can build GUI programs in C++ just as well as C++/CLI. It's just harder because there isn't a standard library in standard C++ for building GUI like the .NET framework has, but there are lots of projects out there like [Qt](http://qt.nokia.com/products/) and [wxWidgets](http://www.wxwidgets.org/) which provide a C++ GUI framework.
>
> I also have another plain C++ library (unmanaged C++ dll), will it be
> possible to use it as a normal dll library in the C++.NET project?
>
>
>
Yes. It might take some extra work to deal with the different standard C++ data types and .NET data types, but you can certainly make it work. | Well... C++ .NET is kind of a misnomer.
You can program in C++ using visual studio .NET. Well that's what it was called along time ago. Now a days folks just call it Visual Studio, with the dot NET moniker. Well, at least the splash screen doesn't have a big ol .NET in the logo anymore.
It is kind of understood that using Visual Studio (VS), you can program in managed and unmanaged languages (Lots of choices there btw).
If you want to program in C++ using Visual Studio you have two choices:
1. Unmanaged or native C/C++. This is the old (or new I guess too) C++
that you have always known, and you program with unmanaged memory.
2. Managed C++. They call this C++/CLI. That is read C++ over CLI, not
C++ divided by CLI! This is C++ that has extra keywords, and a few
extra syntax elements than the native C++. This allows you to
utilize the .NET Foundation Class Library and do other fun things in
the .NET framework. This of course uses the garbage collector for
memory for managed types.
Personally my favorite language is C#, but if you need to interop between C++ and .NET than definitely use Managed C++. It is very easy to do, and I think is easier than that other P/Invoke stuff.
If you are going to some project, I would suggest you do your UI in C# and take advantage of all that it has to offer. Then have that reference a mixed mode managed library that contains your C++ code. I think that will be a lot easier for you.
The answer to your last question is yes, you can definitely use that in your app.
Here is how the dependencies would work:
[C# App/GUI] depends on [Managed C++ assembly] depends on [Native C++ Lib] |
8,710,581 | >
> **Possible Duplicate:**
>
> [What is the difference between Managed C++ and C++/CLI?](https://stackoverflow.com/questions/2443811/what-is-the-difference-between-managed-c-and-c-cli)
>
> [What is CLI/C++ exactly? How does it differ to 'normal' c++?](https://stackoverflow.com/questions/6399493/what-is-cli-c-exactly-how-does-it-differ-to-normal-c)
>
>
>
I am in doubt of distinguishing between C++ and C++.NET.
Is that right C++ is unmanaged code and C++.NET is managed code?
I need to program for a project in C++. For better building the GUI, I would prefer to use C++.NET.
I also have another plain C++ library (unmanaged C++ DLL file), will it be possible to use it as a normal DLL library in the C++.NET project? | 2012/01/03 | [
"https://Stackoverflow.com/questions/8710581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/413174/"
] | >
> Is that right C++ is unmanaged code and C++.NET is managed code.
>
>
>
There's no such thing as "C++.NET". There's C++/CLI, which is basically C++ with Microsoft extensions that allow you to write code targeting the .NET framework. C++/CLI code compiles to CLR bytecode, and runs on a virtual machine just like C#. I'll assume you're actually talking about C++/CLI.
With respect to that, one can say standard C++ is unmanaged and C++/CLI is managed, but that's very much Microsoft terminology. You'll never see the term "unmanaged" used this way when talking about standard C++ unless in comparison with C++/CLI.
Both standard C++ and C++/CLI can be compiled by the same Visual C++ compiler. The former is the default on VC++ compilers, while a compiler switch is needed to make it compile in latter mode.
>
> I need to program for a project in C++. For better building the GUI, I
> would prefer to use C++.NET.
>
>
>
You can build GUI programs in C++ just as well as C++/CLI. It's just harder because there isn't a standard library in standard C++ for building GUI like the .NET framework has, but there are lots of projects out there like [Qt](http://qt.nokia.com/products/) and [wxWidgets](http://www.wxwidgets.org/) which provide a C++ GUI framework.
>
> I also have another plain C++ library (unmanaged C++ dll), will it be
> possible to use it as a normal dll library in the C++.NET project?
>
>
>
Yes. It might take some extra work to deal with the different standard C++ data types and .NET data types, but you can certainly make it work. | Managed C++ is a now **deprecated** Microsoft set of deviations from C++, including grammatical and syntactic extensions, keywords and attributes, to bring the C++ syntax and language to the .NET Framework. These extensions allowed C++ code to be targeted to the Common Language Runtime (CLR) in the form of managed code as well as continue to interoperate with native code. Managed C++ was not a complete standalone, or full-fledged programming language.
Managed C++
```
#using <mscorlib.dll>
using namespace System;
int main() {
Console::WriteLine("Hello, world!");
return 0;
}
```
Vanilla C++
```
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, world!";
return 0;
}
``` |
8,710,581 | >
> **Possible Duplicate:**
>
> [What is the difference between Managed C++ and C++/CLI?](https://stackoverflow.com/questions/2443811/what-is-the-difference-between-managed-c-and-c-cli)
>
> [What is CLI/C++ exactly? How does it differ to 'normal' c++?](https://stackoverflow.com/questions/6399493/what-is-cli-c-exactly-how-does-it-differ-to-normal-c)
>
>
>
I am in doubt of distinguishing between C++ and C++.NET.
Is that right C++ is unmanaged code and C++.NET is managed code?
I need to program for a project in C++. For better building the GUI, I would prefer to use C++.NET.
I also have another plain C++ library (unmanaged C++ DLL file), will it be possible to use it as a normal DLL library in the C++.NET project? | 2012/01/03 | [
"https://Stackoverflow.com/questions/8710581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/413174/"
] | Well... C++ .NET is kind of a misnomer.
You can program in C++ using visual studio .NET. Well that's what it was called along time ago. Now a days folks just call it Visual Studio, with the dot NET moniker. Well, at least the splash screen doesn't have a big ol .NET in the logo anymore.
It is kind of understood that using Visual Studio (VS), you can program in managed and unmanaged languages (Lots of choices there btw).
If you want to program in C++ using Visual Studio you have two choices:
1. Unmanaged or native C/C++. This is the old (or new I guess too) C++
that you have always known, and you program with unmanaged memory.
2. Managed C++. They call this C++/CLI. That is read C++ over CLI, not
C++ divided by CLI! This is C++ that has extra keywords, and a few
extra syntax elements than the native C++. This allows you to
utilize the .NET Foundation Class Library and do other fun things in
the .NET framework. This of course uses the garbage collector for
memory for managed types.
Personally my favorite language is C#, but if you need to interop between C++ and .NET than definitely use Managed C++. It is very easy to do, and I think is easier than that other P/Invoke stuff.
If you are going to some project, I would suggest you do your UI in C# and take advantage of all that it has to offer. Then have that reference a mixed mode managed library that contains your C++ code. I think that will be a lot easier for you.
The answer to your last question is yes, you can definitely use that in your app.
Here is how the dependencies would work:
[C# App/GUI] depends on [Managed C++ assembly] depends on [Native C++ Lib] | * Yes, C++ is unmanaged code and C++/CLI is managed.
* Yes, you can use your unmanaged C++ DLL in your C++/CLI project. But you have to write a wrapper for that. That means you have to define the unmanaged methods you want to access in your C++/CLI project.
Example:
```
using System.Runtime.InteropServices;
[DllImport("YourDLLName")]
public static extern void UnmanagedMethodName(string parameter1);
``` |
8,710,581 | >
> **Possible Duplicate:**
>
> [What is the difference between Managed C++ and C++/CLI?](https://stackoverflow.com/questions/2443811/what-is-the-difference-between-managed-c-and-c-cli)
>
> [What is CLI/C++ exactly? How does it differ to 'normal' c++?](https://stackoverflow.com/questions/6399493/what-is-cli-c-exactly-how-does-it-differ-to-normal-c)
>
>
>
I am in doubt of distinguishing between C++ and C++.NET.
Is that right C++ is unmanaged code and C++.NET is managed code?
I need to program for a project in C++. For better building the GUI, I would prefer to use C++.NET.
I also have another plain C++ library (unmanaged C++ DLL file), will it be possible to use it as a normal DLL library in the C++.NET project? | 2012/01/03 | [
"https://Stackoverflow.com/questions/8710581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/413174/"
] | Managed C++ is a now **deprecated** Microsoft set of deviations from C++, including grammatical and syntactic extensions, keywords and attributes, to bring the C++ syntax and language to the .NET Framework. These extensions allowed C++ code to be targeted to the Common Language Runtime (CLR) in the form of managed code as well as continue to interoperate with native code. Managed C++ was not a complete standalone, or full-fledged programming language.
Managed C++
```
#using <mscorlib.dll>
using namespace System;
int main() {
Console::WriteLine("Hello, world!");
return 0;
}
```
Vanilla C++
```
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, world!";
return 0;
}
``` | * Yes, C++ is unmanaged code and C++/CLI is managed.
* Yes, you can use your unmanaged C++ DLL in your C++/CLI project. But you have to write a wrapper for that. That means you have to define the unmanaged methods you want to access in your C++/CLI project.
Example:
```
using System.Runtime.InteropServices;
[DllImport("YourDLLName")]
public static extern void UnmanagedMethodName(string parameter1);
``` |
180,579 | If the caster is in the radius of a harmful area of effect, such as a fireball spell, will the illusory duplicates exist after damage is taken or will they be destroyed? | 2021/02/09 | [
"https://rpg.stackexchange.com/questions/180579",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/60697/"
] | ### The spell description explicitly states only attacks can destroy a duplicate.
The spell description of *mirror image* states:
>
> A duplicate can be destroyed only by an attack that hits it. It ignores all other damage and effects.
>
>
>
Area of effect spells such as *fireball* are “other damage and effects”, not attacks. | No—they are only destroyed when you are targeted with an *attack*
-----------------------------------------------------------------
The spell's [description](https://www.dndbeyond.com/spells/mirror-image) states, in relevant part:
>
> Each time a creature targets you with an attack during the spell's duration, roll a d20 to determine whether the attack instead targets one of your duplicates.
>
>
>
### Fireball is not an attack, because it uses a saving throw instead of an attack roll
The [Sage Advice Compendium](https://media.wizards.com/2019/dnd/downloads/SA-Compendium.pdf) specifically addresses whether Fireball is an attack when describing its interaction with Uncanny Dodge (emphasis added):
>
> A use of Uncanny Dodge works against only one attack, since it expends your reaction, and only if you can see the attacker. ***It works against attacks of all sorts, including spell attacks, but it is no help against a spell or other effect, such as fireball, that delivers its damage after a saving throw rather than after an attack roll***.
>
>
>
This is pretty clear that it is not an attack, because it is unaffected by something that "works against attacks of all sorts, including spell attacks."
The underlying reasoning is described well by [xanderh](https://rpg.stackexchange.com/users/21315/xanderh) [here](https://rpg.stackexchange.com/a/71247/66046)—the *Player's Handbook* states:
>
> If there's ever any question whether something you're doing counts as an attack, the rule is simple: if you're making an attack roll, you're making an attack.
>
>
>
There's no attack roll, so there's no attack.
As additional (though unofficial) evidence, a directly on-point [tweet](https://twitter.com/JeremyECrawford/status/804783094813163520) from Jeremy Crawford:
>
> Fireball is not an attack.
>
>
>
---
Side note: I had initially thought that, since Fireball targets a point, you wouldn't be "targeted" by it. However, this was [incorrect](https://twitter.com/JeremyECrawford/status/609233888523649024):
>
> Look carefully at the text of fireball: every creature affected is called a target.
>
>
>
The relevant text is:
>
> A target takes 8d6 fire damage on a failed save, or half as much damage on a successful one.
>
>
> |
52,445,834 | I'm trying to teach my test automation framework to detect a selected item in an app using opencv (the framework grabs frames/screenshots from the device under test). Selected items are always a certain size and always have blue border which helps but they contain different thumbnail images. See the example image provided.
I have done a lot of Googling and reading on the topic and I'm close to getting it to work expect for one scenario which is image C in the example image. [example image](https://i.stack.imgur.com/CbclA.png) This is where there is a play symbol on the selected item.
My theory is that OpenCV gets confused in this case because the play symbol is basically circle with a triangle in it and I'm asking it to find a rectangular shape.
I found this to be very helpful: <https://www.learnopencv.com/blob-detection-using-opencv-python-c/>
My code looks like this:
```
import cv2
import numpy as np
img = "testimg.png"
values = {"min threshold": {"large": 10, "small": 1},
"max threshold": {"large": 200, "small": 800},
"min area": {"large": 75000, "small": 100},
"max area": {"large": 80000, "small": 1000},
"min circularity": {"large": 0.7, "small": 0.60},
"max circularity": {"large": 0.82, "small": 63},
"min convexity": {"large": 0.87, "small": 0.87},
"min inertia ratio": {"large": 0.01, "small": 0.01}}
size = "large"
# Read image
im = cv2.imread(img, cv2.IMREAD_GRAYSCALE)
# Setup SimpleBlobDetector parameters.
params = cv2.SimpleBlobDetector_Params()
# Change thresholds
params.minThreshold = values["min threshold"][size]
params.maxThreshold = values["max threshold"][size]
# Filter by Area.
params.filterByArea = True
params.minArea = values["min area"][size]
params.maxArea = values["max area"][size]
# Filter by Circularity
params.filterByCircularity = True
params.minCircularity = values["min circularity"][size]
params.maxCircularity = values["max circularity"][size]
# Filter by Convexity
params.filterByConvexity = False
params.minConvexity = values["min convexity"][size]
# Filter by Inertia
params.filterByInertia = False
params.minInertiaRatio = values["min inertia ratio"][size]
# Create a detector with the parameters
detector = cv2.SimpleBlobDetector(params)
# Detect blobs.
keypoints = detector.detect(im)
for k in keypoints:
print k.pt
print k.size
# Draw detected blobs as red circles.
# cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS ensures
# the size of the circle corresponds to the size of blob
im_with_keypoints = cv2.drawKeypoints(im, keypoints, np.array([]), (0, 0, 255),
cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
# Show blobs
cv2.imshow("Keypoints", im_with_keypoints)
cv2.waitKey(0)
```
How do I get OpenCV to only look at the outer shape defined by the blue border and ignore the inner shapes (the play symbol and of course the thumbnail image)? I'm sure it must be do-able somehow. | 2018/09/21 | [
"https://Stackoverflow.com/questions/52445834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8937566/"
] | According to the documentation, `#pragma GCC unroll 1` is supposed to work, if you place it just so. If it doesn't then you should submit a bug report.
Alternatively, you can use a function attribute to set optimizations, I think:
```
void myfn () __attribute__((optimize("no-unroll-loops")));
``` | For concise functions
sans full and partial loop unrolling
when required
the following function attribute
please try.
```
__attribute__((optimize("Os")))
``` |
67,806,380 | I have an array of complex *dict* that have some value as a string "NULL" and I want to remove, my dict looks like this:
```
d = [{
"key1": "value1",
"key2": {
"key3": "value3",
"key4": "NULL",
"z": {
"z1": "NULL",
"z2": "zzz",
},
},
"key5": "NULL"
}, {
"KEY": "NULL",
"AAA": "BBB",
}]
```
And I want to wipe out all keys that have **NULL** as value
Like this:
`[{"key1": "value1", "key2": {"key3": "value3", "z": {"z2": "zzz"}}}, {"AAA": "BBB"}]`
I am using Python 3.9, so it is possible to use walrus operator. | 2021/06/02 | [
"https://Stackoverflow.com/questions/67806380",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/832490/"
] | Here is how you can do this with recursion:
```
def remove_null(d):
if isinstance(d, list):
for i in d:
remove_null(i)
elif isinstance(d, dict):
for k, v in d.copy().items():
if v == 'NULL':
d.pop(k)
else:
remove_null(v)
d = [{
"key1": "value1",
"key2": {
"key3": "value3",
"key4": "NULL",
"z": {
"z1": "NULL",
"z2": "zzz",
},
},
"key5": "NULL"
}, {
"KEY": "NULL",
"AAA": "BBB",
}]
remove_null(d)
print(d)
```
Output:
```
[{"key1": "value1", "key2": {"key3": "value3", "z": {"z2": "zzz"}}}, {"AAA": "BBB"}]
``` | **Solution:**
```
d = [{
"key1": "value1",
"key2": {
"key3": "value3",
"key4": "NULL",
"z": {
"z1": "NULL",
"z2": "zzz",
},
},
"key5": "NULL"
}, {
"KEY": "NULL",
"AAA": "BBB",
}]
for element in list(d):
for key, value in element.copy().items():
if value == "NULL":
element.pop(key, None)
elif isinstance(value, dict):
for inner_key, inner_value in value.copy().items():
if inner_value == "NULL":
value.pop(inner_key, None)
elif isinstance(inner_value, dict):
for nested_inner_key, nested_inner_value in inner_value.copy().items():
if nested_inner_value == "NULL":
inner_value.pop(nested_inner_key, None)
print(d)
```
**Output:**
```
[{'key1': 'value1', 'key2': {'key3': 'value3', 'z': {'z2': 'zzz'}}}, {'AAA': 'BBB'}]
```
Doing `.copy()` of each dictionary / nested dictionary, else you'll end up with [this](https://stackoverflow.com/questions/10107676/python-runtimeerror-dictionary-changed-size-during-iteration) error.
Check out the same [here](https://onlinegdb.com/wYDUvPhFQ) also. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.