qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
2,123,395
I've noticed an annoying peculiarity in PHP (running 5.2.11). If one page includes another page (and both contain their own variables and functions), both pages are aware of each others' variables. However, their functions seem to be aware of no variables at all (except those declared within the function). **My question:** Why does that happen? How do I make it *not* happen, or what's a better way to go about this? An example of what I'm describing follows. Main page: ``` <?php $myvar = "myvar."; include('page2.php'); echo "Main script says: $somevar and $myvar\n"; doStuff(); doMoreStuff(); function doStuff() { echo "Main function says: $somevar and $myvar\n"; } echo "The end."; ?> ``` page2.php: ``` <?php $somevar = "Success!"; echo "Included script says: $somevar and $myvar\n"; function doMoreStuff() { echo "Included function says: $somevar and $myvar\n"; } ?> ``` The output: `Included script says: Success! and myvar. Main script says: Success! and myvar. Main function says: and Included function says: and The end.` Both pages output the variables just fine. Their functions do not. WRYYYYYY
2010/01/23
[ "https://Stackoverflow.com/questions/2123395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/254830/" ]
You need to use `global` before using outside-defined variables in a function scope: ``` function doStuff() { global $somevar, $myvar; echo "Main function says: $somevar and $myvar\n"; } ``` More detailed explanation provided at: <http://us.php.net/manual/en/language.variables.scope.php> As comments & other answers pointed out accurately, globals *can be evil*. Check out this article explaining just why: <http://my.opera.com/zomg/blog/2007/08/30/globals-are-evil>
While you could be using global variables, it's generally good practice to pass the variables in as parameters to the functions upon calling. This ensures you know exactly what variables a function is expecting for proper execution. This *is not a bug*, just *intended functionality*. ``` $someVar = 'hey'; $myVar = 'you'; doStuff($someVar, $myVar); doMoreStuff($someVar, $myVar); function doStuff($somevar, $myvar) { echo "Main function says: $somevar and $myvar\n"; } function doMoreStuff($somevar, $myvar) { echo "More function says: $somevar and $myvar\n"; } ``` Also notice that the variables outside of the function scope do not have to have matching names as the function parameters themselves. This allows you to do things like: ``` $badVar = 'look at me, im a bad var.'; goodFunction($badVar); function goodFunction ($goodVar) { // output: look at me, im a good var echo str_replace('bad', 'good', $goodVar); } ```
2,123,395
I've noticed an annoying peculiarity in PHP (running 5.2.11). If one page includes another page (and both contain their own variables and functions), both pages are aware of each others' variables. However, their functions seem to be aware of no variables at all (except those declared within the function). **My question:** Why does that happen? How do I make it *not* happen, or what's a better way to go about this? An example of what I'm describing follows. Main page: ``` <?php $myvar = "myvar."; include('page2.php'); echo "Main script says: $somevar and $myvar\n"; doStuff(); doMoreStuff(); function doStuff() { echo "Main function says: $somevar and $myvar\n"; } echo "The end."; ?> ``` page2.php: ``` <?php $somevar = "Success!"; echo "Included script says: $somevar and $myvar\n"; function doMoreStuff() { echo "Included function says: $somevar and $myvar\n"; } ?> ``` The output: `Included script says: Success! and myvar. Main script says: Success! and myvar. Main function says: and Included function says: and The end.` Both pages output the variables just fine. Their functions do not. WRYYYYYY
2010/01/23
[ "https://Stackoverflow.com/questions/2123395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/254830/" ]
You need to use `global` before using outside-defined variables in a function scope: ``` function doStuff() { global $somevar, $myvar; echo "Main function says: $somevar and $myvar\n"; } ``` More detailed explanation provided at: <http://us.php.net/manual/en/language.variables.scope.php> As comments & other answers pointed out accurately, globals *can be evil*. Check out this article explaining just why: <http://my.opera.com/zomg/blog/2007/08/30/globals-are-evil>
php has no scoping hierarchy, that is, functions are not aware of each others' (or global) variables. This is a bit weird if you worked with other languages before, but it's essentially a Good Thing, because globals are "evil". The best approach is to avoid them altogether.
2,123,395
I've noticed an annoying peculiarity in PHP (running 5.2.11). If one page includes another page (and both contain their own variables and functions), both pages are aware of each others' variables. However, their functions seem to be aware of no variables at all (except those declared within the function). **My question:** Why does that happen? How do I make it *not* happen, or what's a better way to go about this? An example of what I'm describing follows. Main page: ``` <?php $myvar = "myvar."; include('page2.php'); echo "Main script says: $somevar and $myvar\n"; doStuff(); doMoreStuff(); function doStuff() { echo "Main function says: $somevar and $myvar\n"; } echo "The end."; ?> ``` page2.php: ``` <?php $somevar = "Success!"; echo "Included script says: $somevar and $myvar\n"; function doMoreStuff() { echo "Included function says: $somevar and $myvar\n"; } ?> ``` The output: `Included script says: Success! and myvar. Main script says: Success! and myvar. Main function says: and Included function says: and The end.` Both pages output the variables just fine. Their functions do not. WRYYYYYY
2010/01/23
[ "https://Stackoverflow.com/questions/2123395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/254830/" ]
While you could be using global variables, it's generally good practice to pass the variables in as parameters to the functions upon calling. This ensures you know exactly what variables a function is expecting for proper execution. This *is not a bug*, just *intended functionality*. ``` $someVar = 'hey'; $myVar = 'you'; doStuff($someVar, $myVar); doMoreStuff($someVar, $myVar); function doStuff($somevar, $myvar) { echo "Main function says: $somevar and $myvar\n"; } function doMoreStuff($somevar, $myvar) { echo "More function says: $somevar and $myvar\n"; } ``` Also notice that the variables outside of the function scope do not have to have matching names as the function parameters themselves. This allows you to do things like: ``` $badVar = 'look at me, im a bad var.'; goodFunction($badVar); function goodFunction ($goodVar) { // output: look at me, im a good var echo str_replace('bad', 'good', $goodVar); } ```
php has no scoping hierarchy, that is, functions are not aware of each others' (or global) variables. This is a bit weird if you worked with other languages before, but it's essentially a Good Thing, because globals are "evil". The best approach is to avoid them altogether.
26,510,679
After reading these two posts: * [++someVariable Vs. someVariable++ in Javascript](https://stackoverflow.com/questions/3469885/somevariable-vs-somevariable-in-javascript) * <http://community.sitepoint.com/t/variable-vs-variable/6371> I am still confused on the following code: ``` var num = 0; num++ // returns 0 ++num // returns 1 ``` Why dose `num++` return 0? I understand that it assigns first, then adds one, ***but I still don't understand why it doesn't display the 1.*** ``` var num = 0; num++ // returns 0 num // returns 1 ``` I am really confused with the following example: **Example:** ``` var num = 0; num++ // assigns then increments // So if it assigns the num = 0, then increments to 1, Where is one being //stored? Is it assigned anywhere? ``` Or does it assign the expression. (I imagine the expression is this: num = num + 1;) This is probably my best guess but it still isn't 100% clear to me, I still don't understand why num++ displays/returns 0 instead of having the expression being evaluated and returning 1.
2014/10/22
[ "https://Stackoverflow.com/questions/26510679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6475188/" ]
Maybe looking at the specification helps. [Postfix increment operator](http://www.ecma-international.org/ecma-262/5.1/#sec-11.3.1) (`num++`) -------------------------------------------------------------------------------------------------- > > The production *PostfixExpression : LeftHandSideExpression [no LineTerminator here] ++* is evaluated as follows: > > > **1.** Let *lhs* be the result of evaluating *LeftHandSideExpression*. > > > That simply means we are looking at what's before the `++`, e.g. `num` in `num++`. > > **2.** Throw a `SyntaxError` exception if the following conditions are all true: [left out for brevity] > > > This step makes sure that `lhs` really refers to a variable. The postfix operator only works on variables, using e.g. a literal, `1++`, would be a syntax error. > > **3.** Let *oldValue* be [ToNumber](http://www.ecma-international.org/ecma-262/5.1/#sec-9.3)([GetValue](http://www.ecma-international.org/ecma-262/5.1/#sec-8.7.1)(*lhs*)). > > > Get the value of the variable represented by *lhs* and store it in `oldValue`. Imagine it to be something like `var oldValue = num;`. If `num = 0` then `oldValue = 0` as well. > > **4.** Let *newValue* be the result of adding the value 1 to *oldValue*, using the same rules as for the + operator (see [11.6.3](http://www.ecma-international.org/ecma-262/5.1/#sec-11.6.3)). > > > Simply add 1 to `oldValue` and store the result in `newValue`. Something like `newValue = oldValue + 1`. In our case `newValue` would be `1`. > > **5.** Call [PutValue](http://www.ecma-international.org/ecma-262/5.1/#sec-8.7.2)(*lhs*, *newValue*). > > > This assigns the new value to *lhs* again. The equivalent is `num = newValue;`. So `num` is `1` now. > > **6.** Return *oldValue*. > > > Return the value of `oldValue` which is still `0`. So again, in pseudo JavaScript code, `num++` is equivalent to: ``` var oldValue = num; // remember current value var newValue = oldValue + 1; // add one to current value num = newValue; // sore new value return oldValue; // return old value ``` --- [Prefix increment operator](http://www.ecma-international.org/ecma-262/5.1/#sec-11.4.4) (++num) ----------------------------------------------------------------------------------------------- The algorithm is exactly the same as for the postfix operator, with one difference: In the last step, `newValue` is returned instead of `oldValue`: > > 6. Return *newValue*. > > >
Take the following example: ``` var num = 0; var result = 0; ``` The following: ``` result = num++; ``` Is equal to saying: ``` result = num; num = num + 1; ``` On the other hand, this: ``` result = ++num; ``` Is more equitable with this: ``` num = num + 1; result = num; ``` The two statements are kinda like shorthand for doing common operations.
26,510,679
After reading these two posts: * [++someVariable Vs. someVariable++ in Javascript](https://stackoverflow.com/questions/3469885/somevariable-vs-somevariable-in-javascript) * <http://community.sitepoint.com/t/variable-vs-variable/6371> I am still confused on the following code: ``` var num = 0; num++ // returns 0 ++num // returns 1 ``` Why dose `num++` return 0? I understand that it assigns first, then adds one, ***but I still don't understand why it doesn't display the 1.*** ``` var num = 0; num++ // returns 0 num // returns 1 ``` I am really confused with the following example: **Example:** ``` var num = 0; num++ // assigns then increments // So if it assigns the num = 0, then increments to 1, Where is one being //stored? Is it assigned anywhere? ``` Or does it assign the expression. (I imagine the expression is this: num = num + 1;) This is probably my best guess but it still isn't 100% clear to me, I still don't understand why num++ displays/returns 0 instead of having the expression being evaluated and returning 1.
2014/10/22
[ "https://Stackoverflow.com/questions/26510679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6475188/" ]
Maybe looking at the specification helps. [Postfix increment operator](http://www.ecma-international.org/ecma-262/5.1/#sec-11.3.1) (`num++`) -------------------------------------------------------------------------------------------------- > > The production *PostfixExpression : LeftHandSideExpression [no LineTerminator here] ++* is evaluated as follows: > > > **1.** Let *lhs* be the result of evaluating *LeftHandSideExpression*. > > > That simply means we are looking at what's before the `++`, e.g. `num` in `num++`. > > **2.** Throw a `SyntaxError` exception if the following conditions are all true: [left out for brevity] > > > This step makes sure that `lhs` really refers to a variable. The postfix operator only works on variables, using e.g. a literal, `1++`, would be a syntax error. > > **3.** Let *oldValue* be [ToNumber](http://www.ecma-international.org/ecma-262/5.1/#sec-9.3)([GetValue](http://www.ecma-international.org/ecma-262/5.1/#sec-8.7.1)(*lhs*)). > > > Get the value of the variable represented by *lhs* and store it in `oldValue`. Imagine it to be something like `var oldValue = num;`. If `num = 0` then `oldValue = 0` as well. > > **4.** Let *newValue* be the result of adding the value 1 to *oldValue*, using the same rules as for the + operator (see [11.6.3](http://www.ecma-international.org/ecma-262/5.1/#sec-11.6.3)). > > > Simply add 1 to `oldValue` and store the result in `newValue`. Something like `newValue = oldValue + 1`. In our case `newValue` would be `1`. > > **5.** Call [PutValue](http://www.ecma-international.org/ecma-262/5.1/#sec-8.7.2)(*lhs*, *newValue*). > > > This assigns the new value to *lhs* again. The equivalent is `num = newValue;`. So `num` is `1` now. > > **6.** Return *oldValue*. > > > Return the value of `oldValue` which is still `0`. So again, in pseudo JavaScript code, `num++` is equivalent to: ``` var oldValue = num; // remember current value var newValue = oldValue + 1; // add one to current value num = newValue; // sore new value return oldValue; // return old value ``` --- [Prefix increment operator](http://www.ecma-international.org/ecma-262/5.1/#sec-11.4.4) (++num) ----------------------------------------------------------------------------------------------- The algorithm is exactly the same as for the postfix operator, with one difference: In the last step, `newValue` is returned instead of `oldValue`: > > 6. Return *newValue*. > > >
When you type `num++` as a statement, JavaScript will evaluate `num` first -- which is why it's showing the zero -- then increment. That's why it's called the *post*-increment operator. If you were to do this, you'll see what's happening more clearly: ``` var num = 0; num++; // Outputs 0 (current value, set in previous step), then increments num; // Outputs 1 (current value, incremented in previous step) ``` With the *pre*-increment, the incrementation happens first, so you'd get: ``` var num = 0; ++num; // Outputs 1 num; // Outputs 1 ```
33,359,268
"Modify the car-painting example so that the car is painted with your favorite color if you have one; otherwise it is painted w/ the color of your garage (if the color is known); otherwise it is painted red." Car-painting example: car.color = favoriteColor || "black"; **How or what do I need to do to make my script work?** ``` car.color = favoriteColor || "red"; if (car.color = favoriteColor ){ alert("your car is " + favoriteColor); } else if (car.color = garageColor){ alert("your car is " + garageColor); } else { car.color = "red"; } ```
2015/10/27
[ "https://Stackoverflow.com/questions/33359268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4115586/" ]
**This is the correct answer to your question:** See my comments to get a better understanding of how this works. ``` if (favoriteColor) { car.color = favoriteColor; // If you have a favorite color, choose the favorite color. } else if (garageColor) { car.color = garageColor; // If the garage color is known, choose the garage color. } else { car.color = 'red'; // Otherwise, choose the color 'red'. } alert('Your car is: ' + car.color); ``` **[Try it Online!](https://jsfiddle.net/jem6wp11/9/)** **Related Question (for further insight):** <https://softwareengineering.stackexchange.com/q/289475> **Alternative Method:** As another possibility, you can write a [conditional (ternary) operation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator) to compact all of the logic into a single statement. ``` alert('Your car is: ' + (car.color = favoriteColor ? favoriteColor : garageColor ? garageColor : 'red')); ```
It just looks like you need to use double equals signs in your if statement. Use == when checking for equality. Try this: ``` car.color = favoriteColor || "red"; if (car.color == favoriteColor ){ alert("your car is " + favoriteColor); } else if (car.color == garageColor){ alert("your car is " + garageColor); } else { car.color = "red"; } ```
33,359,268
"Modify the car-painting example so that the car is painted with your favorite color if you have one; otherwise it is painted w/ the color of your garage (if the color is known); otherwise it is painted red." Car-painting example: car.color = favoriteColor || "black"; **How or what do I need to do to make my script work?** ``` car.color = favoriteColor || "red"; if (car.color = favoriteColor ){ alert("your car is " + favoriteColor); } else if (car.color = garageColor){ alert("your car is " + garageColor); } else { car.color = "red"; } ```
2015/10/27
[ "https://Stackoverflow.com/questions/33359268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4115586/" ]
**This is the correct answer to your question:** See my comments to get a better understanding of how this works. ``` if (favoriteColor) { car.color = favoriteColor; // If you have a favorite color, choose the favorite color. } else if (garageColor) { car.color = garageColor; // If the garage color is known, choose the garage color. } else { car.color = 'red'; // Otherwise, choose the color 'red'. } alert('Your car is: ' + car.color); ``` **[Try it Online!](https://jsfiddle.net/jem6wp11/9/)** **Related Question (for further insight):** <https://softwareengineering.stackexchange.com/q/289475> **Alternative Method:** As another possibility, you can write a [conditional (ternary) operation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator) to compact all of the logic into a single statement. ``` alert('Your car is: ' + (car.color = favoriteColor ? favoriteColor : garageColor ? garageColor : 'red')); ```
Hope this code will be useful ``` function _showFavColor(getColor){ var favoriteColor = 'red'; var garageColor ="blue"; var carColor = getColor; if (carColor == favoriteColor ){ alert("your car is " + favoriteColor); } else if (carColor == garageColor){ alert("your car is " + garageColor); } else { carColor = "red"; } } _showFavColor('red'); _showFavColor('blue'); ``` [jsfiddle](https://jsfiddle.net/c57da150/) Also take a note on how eqality check is done in js. You can follow this links or google it [Which equals operator (== vs ===) should be used in JavaScript comparisons?](https://stackoverflow.com/questions/359494/does-it-matter-which-equals-operator-vs-i-use-in-javascript-comparisons). <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness> Also if you use car.color and if dont create the car object it will throw an error ``` 'Uncaught SyntaxError: Unexpected token . ' ```
2,730,865
Background: * I have a short list of strings. * The number of strings is not always the same, but are nearly always of the order of a “handful” * In our database will store these strings in a 2nd normalised table * These strings are **never** changed once they are written to the database. We wish to be able to match on these strings quickly in a query without the performance hit of doing lots of joins. So I am thinking of storing a hash code of all these strings in the main table and including it in our index, so the joins are only processed by the database when the hash code matches. So how do I get a good hashcode? I could: * Xor the hash codes of all the string together * Xor with multiply the result after each string (say by 31) * Cat all the string together then get the hashcode * Some other way So what do people think? --- In the end I just concatenate the strings and compute the hashcode for the concatenation, as it is simple and worked well enough. *(If you care we are using .NET and SqlServer)* --- **Bug!, Bug!** [Quoting from Guidelines and rules for GetHashCode](http://ericlippert.com/2011/02/28/guidelines-and-rules-for-gethashcode/) by Eric Lippert > > The documentation for > System.String.GetHashCode notes > specifically that two identical > strings can have different hash codes > in different versions of the CLR, and > in fact they do. Don't store string > hashes in databases and expect them to > be the same forever, because they > won't be. > > > So String.GetHashcode() should not be used for this.
2010/04/28
[ "https://Stackoverflow.com/questions/2730865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57159/" ]
Another way that pops in my head, chain xors with rotated hashes based on index: ``` int shift = 0; int result = 1; for(String s : strings) { result ^= (s.hashCode() << shift) | (s.hashCode() >> (32-shift)) & (1 << shift - 1); shift = (shift+1)%32; } ``` edit: reading the explanation given in effective java, I think geoff's code would be much more efficient.
A SQL-based solution could be based on the checksum and checksum\_agg functions. If I'm following it right, you have something like: ``` MyTable MyTableId HashCode MyChildTable MyTableId (foreign key into MyTable) String ``` with the various strings for a given item (MyTableId) stored in MyChildTable. To calculate and store a checksum reflecting these (never-to-be-changed) strings, something like this should work: ``` UPDATE MyTable set HashCode = checksum_agg(checksum(string)) from MyTable mt inner join MyChildTable ct on ct.MyTableId = mt.MyTableId where mt.MyTableId = @OnlyForThisOne ``` I believe this is order-independant, so strings "The quick brown" would produce the same checksum as "brown The quick".
2,730,865
Background: * I have a short list of strings. * The number of strings is not always the same, but are nearly always of the order of a “handful” * In our database will store these strings in a 2nd normalised table * These strings are **never** changed once they are written to the database. We wish to be able to match on these strings quickly in a query without the performance hit of doing lots of joins. So I am thinking of storing a hash code of all these strings in the main table and including it in our index, so the joins are only processed by the database when the hash code matches. So how do I get a good hashcode? I could: * Xor the hash codes of all the string together * Xor with multiply the result after each string (say by 31) * Cat all the string together then get the hashcode * Some other way So what do people think? --- In the end I just concatenate the strings and compute the hashcode for the concatenation, as it is simple and worked well enough. *(If you care we are using .NET and SqlServer)* --- **Bug!, Bug!** [Quoting from Guidelines and rules for GetHashCode](http://ericlippert.com/2011/02/28/guidelines-and-rules-for-gethashcode/) by Eric Lippert > > The documentation for > System.String.GetHashCode notes > specifically that two identical > strings can have different hash codes > in different versions of the CLR, and > in fact they do. Don't store string > hashes in databases and expect them to > be the same forever, because they > won't be. > > > So String.GetHashcode() should not be used for this.
2010/04/28
[ "https://Stackoverflow.com/questions/2730865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57159/" ]
I see no reason not to concatenate the strings and compute the hashcode for the concatenation. As an analogy, say that I wanted to compute a MD5 checksum for a memory block, I wouldn't split the block up into smaller pieces and compute individual MD5 checksums for them and then combine them with some ad hoc method.
Using the `GetHashCode()` is not ideal for combining multiple values. The problem is that for strings, the hashcode is just a checksum. This leaves little entropy for similar values. e.g. adding hashcodes for ("abc", "bbc") will be the same as ("abd", "abc"), causing a collision. In cases where you need to be absolutely sure, you'd use a real hash algorithm, like SHA1, MD5, etc. The only problem is that they are block functions, which is difficult to quickly compare hashes for equality. Instead, try a CRC or [FNV1](http://isthe.com/chongo/tech/comp/fnv/) hash. FNV1 32-bit is super simple: ``` public static class Fnv1 { public const uint OffsetBasis32 = 2166136261; public const uint FnvPrime32 = 16777619; public static int ComputeHash32(byte[] buffer) { uint hash = OffsetBasis32; foreach (byte b in buffer) { hash *= FnvPrime32; hash ^= b; } return (int)hash; } } ```
2,730,865
Background: * I have a short list of strings. * The number of strings is not always the same, but are nearly always of the order of a “handful” * In our database will store these strings in a 2nd normalised table * These strings are **never** changed once they are written to the database. We wish to be able to match on these strings quickly in a query without the performance hit of doing lots of joins. So I am thinking of storing a hash code of all these strings in the main table and including it in our index, so the joins are only processed by the database when the hash code matches. So how do I get a good hashcode? I could: * Xor the hash codes of all the string together * Xor with multiply the result after each string (say by 31) * Cat all the string together then get the hashcode * Some other way So what do people think? --- In the end I just concatenate the strings and compute the hashcode for the concatenation, as it is simple and worked well enough. *(If you care we are using .NET and SqlServer)* --- **Bug!, Bug!** [Quoting from Guidelines and rules for GetHashCode](http://ericlippert.com/2011/02/28/guidelines-and-rules-for-gethashcode/) by Eric Lippert > > The documentation for > System.String.GetHashCode notes > specifically that two identical > strings can have different hash codes > in different versions of the CLR, and > in fact they do. Don't store string > hashes in databases and expect them to > be the same forever, because they > won't be. > > > So String.GetHashcode() should not be used for this.
2010/04/28
[ "https://Stackoverflow.com/questions/2730865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57159/" ]
A SQL-based solution could be based on the checksum and checksum\_agg functions. If I'm following it right, you have something like: ``` MyTable MyTableId HashCode MyChildTable MyTableId (foreign key into MyTable) String ``` with the various strings for a given item (MyTableId) stored in MyChildTable. To calculate and store a checksum reflecting these (never-to-be-changed) strings, something like this should work: ``` UPDATE MyTable set HashCode = checksum_agg(checksum(string)) from MyTable mt inner join MyChildTable ct on ct.MyTableId = mt.MyTableId where mt.MyTableId = @OnlyForThisOne ``` I believe this is order-independant, so strings "The quick brown" would produce the same checksum as "brown The quick".
Let's solve your root problem. Don't use a hashcode. Just add a integer primary key for each String
2,730,865
Background: * I have a short list of strings. * The number of strings is not always the same, but are nearly always of the order of a “handful” * In our database will store these strings in a 2nd normalised table * These strings are **never** changed once they are written to the database. We wish to be able to match on these strings quickly in a query without the performance hit of doing lots of joins. So I am thinking of storing a hash code of all these strings in the main table and including it in our index, so the joins are only processed by the database when the hash code matches. So how do I get a good hashcode? I could: * Xor the hash codes of all the string together * Xor with multiply the result after each string (say by 31) * Cat all the string together then get the hashcode * Some other way So what do people think? --- In the end I just concatenate the strings and compute the hashcode for the concatenation, as it is simple and worked well enough. *(If you care we are using .NET and SqlServer)* --- **Bug!, Bug!** [Quoting from Guidelines and rules for GetHashCode](http://ericlippert.com/2011/02/28/guidelines-and-rules-for-gethashcode/) by Eric Lippert > > The documentation for > System.String.GetHashCode notes > specifically that two identical > strings can have different hash codes > in different versions of the CLR, and > in fact they do. Don't store string > hashes in databases and expect them to > be the same forever, because they > won't be. > > > So String.GetHashcode() should not be used for this.
2010/04/28
[ "https://Stackoverflow.com/questions/2730865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57159/" ]
I see no reason not to concatenate the strings and compute the hashcode for the concatenation. As an analogy, say that I wanted to compute a MD5 checksum for a memory block, I wouldn't split the block up into smaller pieces and compute individual MD5 checksums for them and then combine them with some ad hoc method.
Let's solve your root problem. Don't use a hashcode. Just add a integer primary key for each String
2,730,865
Background: * I have a short list of strings. * The number of strings is not always the same, but are nearly always of the order of a “handful” * In our database will store these strings in a 2nd normalised table * These strings are **never** changed once they are written to the database. We wish to be able to match on these strings quickly in a query without the performance hit of doing lots of joins. So I am thinking of storing a hash code of all these strings in the main table and including it in our index, so the joins are only processed by the database when the hash code matches. So how do I get a good hashcode? I could: * Xor the hash codes of all the string together * Xor with multiply the result after each string (say by 31) * Cat all the string together then get the hashcode * Some other way So what do people think? --- In the end I just concatenate the strings and compute the hashcode for the concatenation, as it is simple and worked well enough. *(If you care we are using .NET and SqlServer)* --- **Bug!, Bug!** [Quoting from Guidelines and rules for GetHashCode](http://ericlippert.com/2011/02/28/guidelines-and-rules-for-gethashcode/) by Eric Lippert > > The documentation for > System.String.GetHashCode notes > specifically that two identical > strings can have different hash codes > in different versions of the CLR, and > in fact they do. Don't store string > hashes in databases and expect them to > be the same forever, because they > won't be. > > > So String.GetHashcode() should not be used for this.
2010/04/28
[ "https://Stackoverflow.com/questions/2730865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57159/" ]
Standard java practise, is to simply write ``` final int prime = 31; int result = 1; for( String s : strings ) { result = result * prime + s.hashCode(); } // result is the hashcode. ```
If you happen to use Java, you can create an array of strings (or convert a collection to an array), and then use `Arrays.hashCode()` as documented [here](https://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html#hashCode(java.lang.Object[])).
2,730,865
Background: * I have a short list of strings. * The number of strings is not always the same, but are nearly always of the order of a “handful” * In our database will store these strings in a 2nd normalised table * These strings are **never** changed once they are written to the database. We wish to be able to match on these strings quickly in a query without the performance hit of doing lots of joins. So I am thinking of storing a hash code of all these strings in the main table and including it in our index, so the joins are only processed by the database when the hash code matches. So how do I get a good hashcode? I could: * Xor the hash codes of all the string together * Xor with multiply the result after each string (say by 31) * Cat all the string together then get the hashcode * Some other way So what do people think? --- In the end I just concatenate the strings and compute the hashcode for the concatenation, as it is simple and worked well enough. *(If you care we are using .NET and SqlServer)* --- **Bug!, Bug!** [Quoting from Guidelines and rules for GetHashCode](http://ericlippert.com/2011/02/28/guidelines-and-rules-for-gethashcode/) by Eric Lippert > > The documentation for > System.String.GetHashCode notes > specifically that two identical > strings can have different hash codes > in different versions of the CLR, and > in fact they do. Don't store string > hashes in databases and expect them to > be the same forever, because they > won't be. > > > So String.GetHashcode() should not be used for this.
2010/04/28
[ "https://Stackoverflow.com/questions/2730865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57159/" ]
I see no reason not to concatenate the strings and compute the hashcode for the concatenation. As an analogy, say that I wanted to compute a MD5 checksum for a memory block, I wouldn't split the block up into smaller pieces and compute individual MD5 checksums for them and then combine them with some ad hoc method.
So I understand, you effectively have some set of strings that you need to identify by hash code, and that set of strings that you need to identify among will never change? If that's the case, it doesn't particularly matter, so long as the scheme you use gives you unique numbers for the different strings/combinations of strings. I would start by just concatenating the strings and calculating the String.hashCode() and seeing if you end up with unique numbers. If you don't, then you could try: * instead of concatenating strings, concatenate hash codes of the component strings, and try different multipliers (e.g. if you want to identify combiantions of two-string sequences, try HC1 + 17 \* HC2, if that doesn't give unique numbers, try HC1 + 31 \* HC2, then try 19, then try 37 etc -- essentially any small-ish odd number will do fine). * if you don't get unique numbers in this way-- or if you need to cope with the set of possibilities expanding-- then consider a stronger hash code. A 64-bit hash code is a good compromise between ease of comparison and likelihood of hashes being unique. A possible scheme for a 64-bit hash code is as follows: * generate an array of 256 64-bit random numbers using a fairly strong scheme (you could use SecureRandom, though the [XORShift](http://www.javamex.com/tutorials/random_numbers/xorshift.shtml) scheme would work fine) * pick "m", another "random" 64-bit, odd number with more or less half of its bits set * to generate a hash code, go through each byte value, b, making up the string, and take the bth number from your array of random numbers; then XOR or add that with the current hash value, multiplied by "m" So an implementation based on values suggested in Numerical Recipes would be: ``` private static final long[] byteTable; private static final long HSTART = 0xBB40E64DA205B064L; private static final long HMULT = 7664345821815920749L; static { byteTable = new long[256]; long h = 0x544B2FBACAAF1684L; for (int i = 0; i < 256; i++) { for (int j = 0; j < 31; j++) { h = (h >>> 7) ^ h; h = (h << 11) ^ h; h = (h >>> 10) ^ h; } byteTable[i] = h; } } ``` The above is initialising our array of random numbers. We use an XORShift generator, but we could really use any fairly good-quality random number generator (creating a SecureRandom() with a particular seed then calling nextLong() would be fine). Then, to generate a hash code: ``` public static long hashCode(String cs) { if (cs == null) return 1L; long h = HSTART; final long hmult = HMULT; final long[] ht = byteTable; for (int i = cs.length()-1; i >= 0; i--) { char ch = cs.charAt(i); h = (h * hmult) ^ ht[ch & 0xff]; h = (h * hmult) ^ ht[(ch >>> 8) & 0xff]; } return h; } ``` A guide to consider is that given a hash code of n bits, on average you'd expect to have to generate hashes of in the order of 2^(n/2) strings before you get a collision. Or put another way, with a 64-bit hash, you'd expect a collision after around 4 billion strings (so if you're dealing with up to, say, a couple of million strings, the chances of a collision are pretty negligible). Another option would be MD5, which is a very strong hash (practically secure), but it is a 128-bit hash, so you have the slight disadvantage of having to deal with 128-bit values. I would say MD5 is overkill for these purposes-- as I say, with a 64-bit hash, you can deal fairly safely with in the order of a few million strings. (Sorry, I should clarify -- MD5 was designed as a secure hash, it's just that it's since found not to be secure. A "secure" hash is one where given a particular hash it's not feasible to deliberately construct input that would lead to that hash. In some circumstances-- but not as I understand in yours-- you would need this property. You might need it, on the other hand, if the strings you're dealing with a user-input data-- i.e. a malicious user could deliberately try to confuse your system. You might also be interetsed in the following I've written in the past: * [guide to hash codes](http://www.javamex.com/tutorials/collections/hashmaps3.shtml) * [secure hash codes in Java](http://www.javamex.com/tutorials/cryptography/hash_functions_algorithms.shtml) (includes some performance measurements)
2,730,865
Background: * I have a short list of strings. * The number of strings is not always the same, but are nearly always of the order of a “handful” * In our database will store these strings in a 2nd normalised table * These strings are **never** changed once they are written to the database. We wish to be able to match on these strings quickly in a query without the performance hit of doing lots of joins. So I am thinking of storing a hash code of all these strings in the main table and including it in our index, so the joins are only processed by the database when the hash code matches. So how do I get a good hashcode? I could: * Xor the hash codes of all the string together * Xor with multiply the result after each string (say by 31) * Cat all the string together then get the hashcode * Some other way So what do people think? --- In the end I just concatenate the strings and compute the hashcode for the concatenation, as it is simple and worked well enough. *(If you care we are using .NET and SqlServer)* --- **Bug!, Bug!** [Quoting from Guidelines and rules for GetHashCode](http://ericlippert.com/2011/02/28/guidelines-and-rules-for-gethashcode/) by Eric Lippert > > The documentation for > System.String.GetHashCode notes > specifically that two identical > strings can have different hash codes > in different versions of the CLR, and > in fact they do. Don't store string > hashes in databases and expect them to > be the same forever, because they > won't be. > > > So String.GetHashcode() should not be used for this.
2010/04/28
[ "https://Stackoverflow.com/questions/2730865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57159/" ]
Your first option has the only inconvenience of `(String1, String2)` producing the same hashcode of `(String2, String1)`. If that's not a problem (eg. because you have a fix order) it's fine. "*Cat all the string together then get the hashcode*" seems the more natural and secure to me. *Update*: As a comment points out, this has the drawback that the list ("x", "yz") and ("xy","z") would give the same hash. To avoid this, you could join the strings with a string delimiter that cannot appear inside the strings. If the strings are big, you might prefer to hash each one, cat the hashcodes and rehash the result. More CPU, less memory.
A SQL-based solution could be based on the checksum and checksum\_agg functions. If I'm following it right, you have something like: ``` MyTable MyTableId HashCode MyChildTable MyTableId (foreign key into MyTable) String ``` with the various strings for a given item (MyTableId) stored in MyChildTable. To calculate and store a checksum reflecting these (never-to-be-changed) strings, something like this should work: ``` UPDATE MyTable set HashCode = checksum_agg(checksum(string)) from MyTable mt inner join MyChildTable ct on ct.MyTableId = mt.MyTableId where mt.MyTableId = @OnlyForThisOne ``` I believe this is order-independant, so strings "The quick brown" would produce the same checksum as "brown The quick".
2,730,865
Background: * I have a short list of strings. * The number of strings is not always the same, but are nearly always of the order of a “handful” * In our database will store these strings in a 2nd normalised table * These strings are **never** changed once they are written to the database. We wish to be able to match on these strings quickly in a query without the performance hit of doing lots of joins. So I am thinking of storing a hash code of all these strings in the main table and including it in our index, so the joins are only processed by the database when the hash code matches. So how do I get a good hashcode? I could: * Xor the hash codes of all the string together * Xor with multiply the result after each string (say by 31) * Cat all the string together then get the hashcode * Some other way So what do people think? --- In the end I just concatenate the strings and compute the hashcode for the concatenation, as it is simple and worked well enough. *(If you care we are using .NET and SqlServer)* --- **Bug!, Bug!** [Quoting from Guidelines and rules for GetHashCode](http://ericlippert.com/2011/02/28/guidelines-and-rules-for-gethashcode/) by Eric Lippert > > The documentation for > System.String.GetHashCode notes > specifically that two identical > strings can have different hash codes > in different versions of the CLR, and > in fact they do. Don't store string > hashes in databases and expect them to > be the same forever, because they > won't be. > > > So String.GetHashcode() should not be used for this.
2010/04/28
[ "https://Stackoverflow.com/questions/2730865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57159/" ]
I see no reason not to concatenate the strings and compute the hashcode for the concatenation. As an analogy, say that I wanted to compute a MD5 checksum for a memory block, I wouldn't split the block up into smaller pieces and compute individual MD5 checksums for them and then combine them with some ad hoc method.
If you happen to use Java, you can create an array of strings (or convert a collection to an array), and then use `Arrays.hashCode()` as documented [here](https://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html#hashCode(java.lang.Object[])).
2,730,865
Background: * I have a short list of strings. * The number of strings is not always the same, but are nearly always of the order of a “handful” * In our database will store these strings in a 2nd normalised table * These strings are **never** changed once they are written to the database. We wish to be able to match on these strings quickly in a query without the performance hit of doing lots of joins. So I am thinking of storing a hash code of all these strings in the main table and including it in our index, so the joins are only processed by the database when the hash code matches. So how do I get a good hashcode? I could: * Xor the hash codes of all the string together * Xor with multiply the result after each string (say by 31) * Cat all the string together then get the hashcode * Some other way So what do people think? --- In the end I just concatenate the strings and compute the hashcode for the concatenation, as it is simple and worked well enough. *(If you care we are using .NET and SqlServer)* --- **Bug!, Bug!** [Quoting from Guidelines and rules for GetHashCode](http://ericlippert.com/2011/02/28/guidelines-and-rules-for-gethashcode/) by Eric Lippert > > The documentation for > System.String.GetHashCode notes > specifically that two identical > strings can have different hash codes > in different versions of the CLR, and > in fact they do. Don't store string > hashes in databases and expect them to > be the same forever, because they > won't be. > > > So String.GetHashcode() should not be used for this.
2010/04/28
[ "https://Stackoverflow.com/questions/2730865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57159/" ]
Standard java practise, is to simply write ``` final int prime = 31; int result = 1; for( String s : strings ) { result = result * prime + s.hashCode(); } // result is the hashcode. ```
I see no reason not to concatenate the strings and compute the hashcode for the concatenation. As an analogy, say that I wanted to compute a MD5 checksum for a memory block, I wouldn't split the block up into smaller pieces and compute individual MD5 checksums for them and then combine them with some ad hoc method.
2,730,865
Background: * I have a short list of strings. * The number of strings is not always the same, but are nearly always of the order of a “handful” * In our database will store these strings in a 2nd normalised table * These strings are **never** changed once they are written to the database. We wish to be able to match on these strings quickly in a query without the performance hit of doing lots of joins. So I am thinking of storing a hash code of all these strings in the main table and including it in our index, so the joins are only processed by the database when the hash code matches. So how do I get a good hashcode? I could: * Xor the hash codes of all the string together * Xor with multiply the result after each string (say by 31) * Cat all the string together then get the hashcode * Some other way So what do people think? --- In the end I just concatenate the strings and compute the hashcode for the concatenation, as it is simple and worked well enough. *(If you care we are using .NET and SqlServer)* --- **Bug!, Bug!** [Quoting from Guidelines and rules for GetHashCode](http://ericlippert.com/2011/02/28/guidelines-and-rules-for-gethashcode/) by Eric Lippert > > The documentation for > System.String.GetHashCode notes > specifically that two identical > strings can have different hash codes > in different versions of the CLR, and > in fact they do. Don't store string > hashes in databases and expect them to > be the same forever, because they > won't be. > > > So String.GetHashcode() should not be used for this.
2010/04/28
[ "https://Stackoverflow.com/questions/2730865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57159/" ]
I see no reason not to concatenate the strings and compute the hashcode for the concatenation. As an analogy, say that I wanted to compute a MD5 checksum for a memory block, I wouldn't split the block up into smaller pieces and compute individual MD5 checksums for them and then combine them with some ad hoc method.
I hope this is unnecessary, but since you don't mention anything which sounds like you're only using the hashcodes for a first check and then later verifying that the strings are actually equal, I feel the need to warn you: **Hashcode equality != value equality** There will be lots of sets of strings which yield the identical hashcode, but won't always be equal.
57,278,351
I built my bot using Direct Line and authentication works there. But when I deployed my bot to MS Teams, pressing the sign in button does nothing at all. I used the following code: ``` AddDialog(new OAuthPrompt( nameof(OAuthPrompt), new OAuthPromptSettings { ConnectionName = ConnectionName, Text = " Welcome! Please Sign In.", Title = "Sign In", Timeout = 300000, // User has 5 minutes to login (1000 * 60 * 5), }) ); ``` I tried looking up documentation, but it seems they're using a different framework, or the v3 bot framework. How can I make OAuth work in web and ms teams? I'm using Bot Framework v4.
2019/07/30
[ "https://Stackoverflow.com/questions/57278351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1404347/" ]
How are you testing the Teams app? Did you side-load it into your Teams environment? When you are using Azure Bot Service for Authentication in Teams, you need [to whitelist the domain in your Bot Manifest](https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/authentication/auth-oauth-card#getting-started-with-oauthcard-in-teams). This requirement applies to bots built with the v3 and v4 SDK. You could use [App Studio](https://learn.microsoft.com/en-us/microsoftteams/platform/get-started/get-started-app-studio) to add `token.botframework.com` to the `validDomains` section of the [manifest file](https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/apps/apps-package). (or you can build the manifest file manually)
Some weeks ago, we faced the same problem. Luckily, a few weeks ago, Microsoft uploaded a sample: <https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/javascript_nodejs/46.teams-auth> The key here is to use TeamsActivityHandler (found inside teamsActivityHandler.js file) instead of ActivityHandler when extending your bot. Hope it helps!
45,946
In ancient Western times civilians were considered legitimate spoils of war for the victor. Sometime in Western Europe that seems to have changed. While Otto von Bismarck waged symbolic wars in Europe with very little casualties besides largely willing soldiers on the battlefields, colonial wars with indigenous people saw things like Indians scalping civilians, provoking hate in return for having broken the rules of war. In the Middle East today the ubiquitous use of suicide bombers, human shields, terror against civilians and the stateless warfare of some "rebel groups" indicates that they still do not make much of a difference between military and civilian targets or actors. Where does this invention come from, that in war soldiers and civilians have different rights? For example that it is right to take a soldier as prisoner, but not a civilian. Clarification: This is not a question about the formalism of official law, but about actual practice in warfare. Compare for example the European wars of the 1870s with today's wars in Syria and Palestine. I'm asking for the origin of the cultural valuation that a soldier has another status in war than a civilian has. von Bismarck didn't have the war aims to exterminate or enslave all Austrians and all the French, but that's the war aim of the Palestinians today with respect to their enemy the Israelis. And there's an ancient history behind that. When was that tradition broken to give rise to the special rights of civilians?
2018/05/02
[ "https://history.stackexchange.com/questions/45946", "https://history.stackexchange.com", "https://history.stackexchange.com/users/12990/" ]
First, let's clarify; declaring something illegal does not prevent people from doing that thing. Burglary is illegal, but it happens. Sexual harassment is illegal, but it happens. So all of the examples listed are... not really relevant to understanding or answering the question. The examples lead more to confusion than resolution. Second you are citing examples from "ancient Western civilizations" (unspecified, I'm going to assume Rome), then from Bismarck - that is a gap of nearly 2000 years. The Romans were rather enthusiastic about genocide *Carthago delenda est!* During the anarchy, there are examples of people killing hostages and of people behaving with honor. During the [Hundred Years' War](https://en.wikipedia.org/wiki/Hundred_years_war), war on civilians was permitted; perhaps because the civilians were serfs, and therefore not entirely people. Richard the Lionheart was ransomed and treated with dignity, as were most nobles. During the Napoleonic era, the French pursued scientific mass murder of civilians. If you want an answer to this question, you're going to have to narrow down the scope to what impact international law had on a specific war. If you ask the same question about any legal principle, the answer is book length. "What is the history of rules against burglary from Rome to modern intellectual property?" With that as prelude, I think it is fairly easy to identify some inflection points that are critical to the distinction between civilians and combatants: * [Pope crowns Charlemagne](http://www.dw.com/en/charlemagne-is-crowned-emperor-december-25-800/a-4614858-1) - establishing a basis for law that is distinct from the person of the autocrat. (Arguably, the Roman tablets did this first, but I'm not sure they were ever more than a symbol, and any discussion would have to develop Augustus and Domitian.) * [Grotius](https://en.wikipedia.org/wiki/Hugo_Grotius), drew the distinction between law an natural law. (Again, one could argue the [*ius gentium*](https://en.wikipedia.org/wiki/Jus_gentium) but I pick Grotius because he articulates that international law is not divine in origin (and therefore applies even to those that local gods do not love). One could argue the *ius civile* is similar, but I think Roman law is tied to Roman gods, and the Romans are not known for their fundamental respect of the civil rights of non-Roman citizens.) * Some sources privilege the Roman Catholic Church's attempts to impose peace on various conflicts; I believe these are distinct. Another inflection point is the creation of [war crimes](https://en.wikipedia.org/wiki/War_crime) and [crimes against humanity](https://en.wikipedia.org/wiki/Crimes_against_humanity). A third inflection point is the international prohibitions against [Letters of Marque](https://en.wikipedia.org/wiki/Letter_of_marque) and perhaps a discussion of the [Condottieri](https://en.wikipedia.org/wiki/Condottieri). All of these influenced international law on conflict and the treatment of civilians. In every war, there are some who want peace; some who wish to mitigate the suffering. Advocates of peace imposed restrictions on the conduct of war (check for the rules against crossbows, or fighting on holy days, or the requirement for a just war, etc.). Given the breadth of your question (two millennia over the entire surface of the globe) that may be the only honest answer to the question.
I'd put forward there was an inflection point that occurred at some point during the 19th century. It's probably not a single event, and one could probably go on at length as to the precise reasons. You can see clearcut evidence of this on the eve of the Boxer War. In response to the atrocities in China, the German Emperor infamously urged his troops to ['behave like Huns', triggering outrage across Europe](https://books.google.hu/books?id=A2cfZkU5aQgC&pg=PA873&lpg=PA873&dq=boxer+war+tell+troops+to+behave+like+huns&source=bl&ots=dfq_TCQqUN&sig=n_Hmp5ZK7F-SBtl6mf1rtuFZwv4&hl=en&sa=X&ved=0ahUKEwiD3ISoyPDaAhWKjSwKHVLDCoQQ6AEITDAD#v=onepage&q=boxer%20war%20tell%20troops%20to%20behave%20like%20huns&f=false) (p.873). As little as a century or two earlier, it would have been so matter of factly - indeed expected - that troops would do so that it wouldn't have registered as something worth instructing.
15,594
I am reading in the book of Exodus chapter 3 (KJV) about the angel of the Lord appearing to Moses in the burning bush.It is written, **Exodus 3:2** > > And the angel of the Lord appeared unto him in a flame of fire out of > the midst of a bush: and he looked, and, behold, the bush burned with > fire, and the bush was not consumed. > > > **Exodus 3:3-4** > > > **3** Then Moses said, “I will now turn aside and see this great sight, why the bush does not burn.” > **4** So when the Lord saw that he turned aside to look, God called to him from the midst of the bush and said, “Moses, Moses!” And he said, > “Here I am.” > > > The angel and God are both in the midst of the bush.The angel arrived before God. Does God stand beside the angel in the burning bush.? Or is the angel God.? How does the reader understand these scriptures,when considering Moses looked at the burning bush when the angel first appeared in it, and also considering what is written in the book of Exodus chapter 33:19-20 with reference to the "face of God." See this [Question with reference to Exodus 3](https://hermeneutics.stackexchange.com/questions/860/is-the-captain-of-the-lords-host-an-angel-or-god-himself).
2015/02/01
[ "https://hermeneutics.stackexchange.com/questions/15594", "https://hermeneutics.stackexchange.com", "https://hermeneutics.stackexchange.com/users/2572/" ]
The angel appears in the bush alone, we are told nothing of God being there. Angels appear to many in scripture without the presence of fire, so it seems unnecessary to think the bush is burning because if the angel, but rather it is an additional sign to Moses that it burned without being consumed. Moses turning his face from the angel is not unusual either. In many other cases, such as Joshua, Isaiah and even Joseph in the New Testament, they bow, hide their face or are scared. As celestial beings it seems they can have a powerful effect unless they are purposely hiding their identity. I'm leaving out the idea of a Theophany for the moment, which this case and others such as the appearance to Joshua before Jericho may have been. God himself did not have to be present, not in a visible manifestation, to see Moses' response and to then speak to him either directly or through the angel. Trying to figure out God's physical position here is unnecessary, he is everywhere and all-knowing. As for the face of God, if he is not manifest and is simply speaking to him directly or through the angel, then there is no issue. If this IS a Theophany, then things change only a little. We know where He is, in the bush, and we know Moses looked on Him. However, we have many possible Theophanies where He is most likely looked at and there isn't an issue in those cases either. This may be part of a larger discussion, but it seems the appearance of God and Him revealing his Face or His Glory are not the same. He is able to hide or repress that glory in order to appear to men. Christians would hold Christ as the ultimate proof of that as he let go of it to become incarnate. Edit: I will have to edit this tonight for scripture sources, but most everything here is derived from consistency with other passages, outside of Theophany information.
The Angel of the Lord(AOTL) or the Angel of God, is distinct from other angels in the bible and should not be confused with an a ordinary angel". In the Old testament the AOTL has the divine authority to forgive "transgressions",(Exodus 23:21); receive worship (Joshua 5:14)(Gen 18:2; Num 22:31) bless generations (Gen 22:18);create life (Genesis 16:10-13);consume sacrifice left at the altar (Judges 6:21)and to ascend in the very flame of that sacrifice (Judges 13:19). It was this very Angel who commended Abraham on behalf of not witholding "thine only son from me" (Gen 22:12). Furthermore, one will find that the Lord's name is in this Angel of the Lord (Exodus 23:21). In the OT, His name is also secret (Judges 13:18), and yet Wonderful (Judges 13:18 ESV). The Angel of the Lord creates and seals covenants (Judges 2:1-5), and because there is no one greater than himself to swear by, therefore; he swears by "Himself"! (Heb 6:13)(Gen 22:16) A theophany is witnessed of the Angel of the Lord when he tells Jacob, " I am the God of Bethel(Gen 31:11-13). He is the same Angel who introduced "himself" to Moses as the God of Abraham, Issac and Jacob and who also appeared to Moses in the burning bush(Exodus 3:2). He led the Israelites out of Egypt by a cloud during the day and a pillar of fire by night(Exodus 4:19)(Judges 2:1-5). Encounters with the Angel of the Lord has moved witnesses to fear that they have come "face-to-face-with God." (Gen 32:29, Judges 6:22) In the book of Isaiah, we see the christophany of the Angel of the Lord as Isaiah acknowledges the presence of the Angel of the Lord as none other than our Savior Jesus "For he said, Surely they are my people, children that will not lie: so he was their Savior. In all their affliction he was afflicted, and the angel of his presene saved them: in his love and in his pity he redeemed them; and he bare them and carried them all the days of old." (Isaiah 63:8-9) We can understand Jesus having always been present when we read how he announced, "before Abraham was I am." (John 8:58) Certain listeners knew exactly what Jesus implied and were therefore offended just as some are offended even to this day. The Angel of the Lord is the Lamb who was slain before the foundation of the world (Rev 13:8) and was always present and operated from eternity before unveiling His person in the flesh (John 1:1, John 1:14).
15,594
I am reading in the book of Exodus chapter 3 (KJV) about the angel of the Lord appearing to Moses in the burning bush.It is written, **Exodus 3:2** > > And the angel of the Lord appeared unto him in a flame of fire out of > the midst of a bush: and he looked, and, behold, the bush burned with > fire, and the bush was not consumed. > > > **Exodus 3:3-4** > > > **3** Then Moses said, “I will now turn aside and see this great sight, why the bush does not burn.” > **4** So when the Lord saw that he turned aside to look, God called to him from the midst of the bush and said, “Moses, Moses!” And he said, > “Here I am.” > > > The angel and God are both in the midst of the bush.The angel arrived before God. Does God stand beside the angel in the burning bush.? Or is the angel God.? How does the reader understand these scriptures,when considering Moses looked at the burning bush when the angel first appeared in it, and also considering what is written in the book of Exodus chapter 33:19-20 with reference to the "face of God." See this [Question with reference to Exodus 3](https://hermeneutics.stackexchange.com/questions/860/is-the-captain-of-the-lords-host-an-angel-or-god-himself).
2015/02/01
[ "https://hermeneutics.stackexchange.com/questions/15594", "https://hermeneutics.stackexchange.com", "https://hermeneutics.stackexchange.com/users/2572/" ]
I agree with the earlier response that G-d was not standing with the angel in the burning bush. A common way by which G-d communicates with the Patriarchs in Genesis and Exodus is through an angel. As the Hebrew word מַלְאָךְ can mean either "angel" or "messenger," it is clear even in antiquity that G-d communicated through angels. A few examples will illustrate this concept. In Numbers 22, G-d speaks through the she-donkey to Balaam but we later see that an angel was present in the road. It is not clear that the angel played in role in controlling the she-donkey, although the presence of the angel would leave that open as a possibility. In Genesis 19, Lot encounter two messengers (שְׁנֵי מְלְאָכִים) who warn him of the impending doom of the city. Lot apparently could tell they were angels sent by G-d, since he prostrated himself. In this case, the angels do quite a bit of action, such as removing Lot and his family from the city. In the case of Exodus 3:2-4, G-d was present only insofar that one of His angels was there in the bush. As the example with Balaam shows, G-d can create speech without being physically present there, so long as an angel is present. That an angel, but not G-d Himself, was present in the bush ties into Exodus 33:19-20. In Exodus 33:19-20, G-d says that no man can see His face directly and live. Hence the reason for using angels to communicate with the Patriarchs is clear.
The Angel of the Lord(AOTL) or the Angel of God, is distinct from other angels in the bible and should not be confused with an a ordinary angel". In the Old testament the AOTL has the divine authority to forgive "transgressions",(Exodus 23:21); receive worship (Joshua 5:14)(Gen 18:2; Num 22:31) bless generations (Gen 22:18);create life (Genesis 16:10-13);consume sacrifice left at the altar (Judges 6:21)and to ascend in the very flame of that sacrifice (Judges 13:19). It was this very Angel who commended Abraham on behalf of not witholding "thine only son from me" (Gen 22:12). Furthermore, one will find that the Lord's name is in this Angel of the Lord (Exodus 23:21). In the OT, His name is also secret (Judges 13:18), and yet Wonderful (Judges 13:18 ESV). The Angel of the Lord creates and seals covenants (Judges 2:1-5), and because there is no one greater than himself to swear by, therefore; he swears by "Himself"! (Heb 6:13)(Gen 22:16) A theophany is witnessed of the Angel of the Lord when he tells Jacob, " I am the God of Bethel(Gen 31:11-13). He is the same Angel who introduced "himself" to Moses as the God of Abraham, Issac and Jacob and who also appeared to Moses in the burning bush(Exodus 3:2). He led the Israelites out of Egypt by a cloud during the day and a pillar of fire by night(Exodus 4:19)(Judges 2:1-5). Encounters with the Angel of the Lord has moved witnesses to fear that they have come "face-to-face-with God." (Gen 32:29, Judges 6:22) In the book of Isaiah, we see the christophany of the Angel of the Lord as Isaiah acknowledges the presence of the Angel of the Lord as none other than our Savior Jesus "For he said, Surely they are my people, children that will not lie: so he was their Savior. In all their affliction he was afflicted, and the angel of his presene saved them: in his love and in his pity he redeemed them; and he bare them and carried them all the days of old." (Isaiah 63:8-9) We can understand Jesus having always been present when we read how he announced, "before Abraham was I am." (John 8:58) Certain listeners knew exactly what Jesus implied and were therefore offended just as some are offended even to this day. The Angel of the Lord is the Lamb who was slain before the foundation of the world (Rev 13:8) and was always present and operated from eternity before unveiling His person in the flesh (John 1:1, John 1:14).
15,594
I am reading in the book of Exodus chapter 3 (KJV) about the angel of the Lord appearing to Moses in the burning bush.It is written, **Exodus 3:2** > > And the angel of the Lord appeared unto him in a flame of fire out of > the midst of a bush: and he looked, and, behold, the bush burned with > fire, and the bush was not consumed. > > > **Exodus 3:3-4** > > > **3** Then Moses said, “I will now turn aside and see this great sight, why the bush does not burn.” > **4** So when the Lord saw that he turned aside to look, God called to him from the midst of the bush and said, “Moses, Moses!” And he said, > “Here I am.” > > > The angel and God are both in the midst of the bush.The angel arrived before God. Does God stand beside the angel in the burning bush.? Or is the angel God.? How does the reader understand these scriptures,when considering Moses looked at the burning bush when the angel first appeared in it, and also considering what is written in the book of Exodus chapter 33:19-20 with reference to the "face of God." See this [Question with reference to Exodus 3](https://hermeneutics.stackexchange.com/questions/860/is-the-captain-of-the-lords-host-an-angel-or-god-himself).
2015/02/01
[ "https://hermeneutics.stackexchange.com/questions/15594", "https://hermeneutics.stackexchange.com", "https://hermeneutics.stackexchange.com/users/2572/" ]
When one has the understanding of a theophany/christophany , then the explanation of who was in the burning bush would be more easily understood, especially in the case of Shadrach, Meshach, and Abednego. As in Daniel 3:24 it reads: "I see four men loose, walking in the midst of the fire, and they have no hurt; and the form of the fourth is like the Son of God.
The Angel of the Lord(AOTL) or the Angel of God, is distinct from other angels in the bible and should not be confused with an a ordinary angel". In the Old testament the AOTL has the divine authority to forgive "transgressions",(Exodus 23:21); receive worship (Joshua 5:14)(Gen 18:2; Num 22:31) bless generations (Gen 22:18);create life (Genesis 16:10-13);consume sacrifice left at the altar (Judges 6:21)and to ascend in the very flame of that sacrifice (Judges 13:19). It was this very Angel who commended Abraham on behalf of not witholding "thine only son from me" (Gen 22:12). Furthermore, one will find that the Lord's name is in this Angel of the Lord (Exodus 23:21). In the OT, His name is also secret (Judges 13:18), and yet Wonderful (Judges 13:18 ESV). The Angel of the Lord creates and seals covenants (Judges 2:1-5), and because there is no one greater than himself to swear by, therefore; he swears by "Himself"! (Heb 6:13)(Gen 22:16) A theophany is witnessed of the Angel of the Lord when he tells Jacob, " I am the God of Bethel(Gen 31:11-13). He is the same Angel who introduced "himself" to Moses as the God of Abraham, Issac and Jacob and who also appeared to Moses in the burning bush(Exodus 3:2). He led the Israelites out of Egypt by a cloud during the day and a pillar of fire by night(Exodus 4:19)(Judges 2:1-5). Encounters with the Angel of the Lord has moved witnesses to fear that they have come "face-to-face-with God." (Gen 32:29, Judges 6:22) In the book of Isaiah, we see the christophany of the Angel of the Lord as Isaiah acknowledges the presence of the Angel of the Lord as none other than our Savior Jesus "For he said, Surely they are my people, children that will not lie: so he was their Savior. In all their affliction he was afflicted, and the angel of his presene saved them: in his love and in his pity he redeemed them; and he bare them and carried them all the days of old." (Isaiah 63:8-9) We can understand Jesus having always been present when we read how he announced, "before Abraham was I am." (John 8:58) Certain listeners knew exactly what Jesus implied and were therefore offended just as some are offended even to this day. The Angel of the Lord is the Lamb who was slain before the foundation of the world (Rev 13:8) and was always present and operated from eternity before unveiling His person in the flesh (John 1:1, John 1:14).
15,594
I am reading in the book of Exodus chapter 3 (KJV) about the angel of the Lord appearing to Moses in the burning bush.It is written, **Exodus 3:2** > > And the angel of the Lord appeared unto him in a flame of fire out of > the midst of a bush: and he looked, and, behold, the bush burned with > fire, and the bush was not consumed. > > > **Exodus 3:3-4** > > > **3** Then Moses said, “I will now turn aside and see this great sight, why the bush does not burn.” > **4** So when the Lord saw that he turned aside to look, God called to him from the midst of the bush and said, “Moses, Moses!” And he said, > “Here I am.” > > > The angel and God are both in the midst of the bush.The angel arrived before God. Does God stand beside the angel in the burning bush.? Or is the angel God.? How does the reader understand these scriptures,when considering Moses looked at the burning bush when the angel first appeared in it, and also considering what is written in the book of Exodus chapter 33:19-20 with reference to the "face of God." See this [Question with reference to Exodus 3](https://hermeneutics.stackexchange.com/questions/860/is-the-captain-of-the-lords-host-an-angel-or-god-himself).
2015/02/01
[ "https://hermeneutics.stackexchange.com/questions/15594", "https://hermeneutics.stackexchange.com", "https://hermeneutics.stackexchange.com/users/2572/" ]
There are a few times in the Old Testament where *the Angel of The Lord* seems to be alternating with God speaking, and/or with the Angel saying and promising things we would only expect the Lord to say or promise (of course in Old Testament “Lord” just refers to God), yet after answering as “I” in a Godlike manner, this Angel turns right around and says “The Lord” this and “The Lord” that. There may be a correlation between when it goes like this and capitalization “Angel of The Lord”, but I’m not certain. One is Gen 16:7 for ten verses or so. For example: “I” will multiply you. But it was the angel. And calls Him God of seeing. Later she says outright that she spoke to Yahweh. The text always refers to the speaker as the Angel. Now another example, a big one. The situation at the Burning Bush was such that you literally just asked if God is “standing next to” an angel during the interaction with Moses. But note: There are other examples. I don’t normally ever post a video link here, but this exact topic was [recently covered by Rev Winger](https://youtu.be/ryCyQ4N08Q0). Since God is one, there is *a way* in which the whole triune Godhead was speaking. Winger ultimately is asking: **Did the second person of the Trinity run around calling himself *The Angel of the Lord* prior to our Savior arriving in the flesh?**
The Angel of the Lord(AOTL) or the Angel of God, is distinct from other angels in the bible and should not be confused with an a ordinary angel". In the Old testament the AOTL has the divine authority to forgive "transgressions",(Exodus 23:21); receive worship (Joshua 5:14)(Gen 18:2; Num 22:31) bless generations (Gen 22:18);create life (Genesis 16:10-13);consume sacrifice left at the altar (Judges 6:21)and to ascend in the very flame of that sacrifice (Judges 13:19). It was this very Angel who commended Abraham on behalf of not witholding "thine only son from me" (Gen 22:12). Furthermore, one will find that the Lord's name is in this Angel of the Lord (Exodus 23:21). In the OT, His name is also secret (Judges 13:18), and yet Wonderful (Judges 13:18 ESV). The Angel of the Lord creates and seals covenants (Judges 2:1-5), and because there is no one greater than himself to swear by, therefore; he swears by "Himself"! (Heb 6:13)(Gen 22:16) A theophany is witnessed of the Angel of the Lord when he tells Jacob, " I am the God of Bethel(Gen 31:11-13). He is the same Angel who introduced "himself" to Moses as the God of Abraham, Issac and Jacob and who also appeared to Moses in the burning bush(Exodus 3:2). He led the Israelites out of Egypt by a cloud during the day and a pillar of fire by night(Exodus 4:19)(Judges 2:1-5). Encounters with the Angel of the Lord has moved witnesses to fear that they have come "face-to-face-with God." (Gen 32:29, Judges 6:22) In the book of Isaiah, we see the christophany of the Angel of the Lord as Isaiah acknowledges the presence of the Angel of the Lord as none other than our Savior Jesus "For he said, Surely they are my people, children that will not lie: so he was their Savior. In all their affliction he was afflicted, and the angel of his presene saved them: in his love and in his pity he redeemed them; and he bare them and carried them all the days of old." (Isaiah 63:8-9) We can understand Jesus having always been present when we read how he announced, "before Abraham was I am." (John 8:58) Certain listeners knew exactly what Jesus implied and were therefore offended just as some are offended even to this day. The Angel of the Lord is the Lamb who was slain before the foundation of the world (Rev 13:8) and was always present and operated from eternity before unveiling His person in the flesh (John 1:1, John 1:14).
56,427,168
I work behind a corporate firewall. I need pymssql library to use some queries. I try installing via pip, which gives me the error: > > 'pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.' > > > I install openssl as mentioned by multiple answers in this site from <https://slproweb.com/products/Win32OpenSSL.html>. I get the same error even after installation. I set http\_proxy and https\_proxy in the system variable and try again. I get the same error I set the above proxies via command prompt and do a pip/easy\_install. Same issue I try the --trusted host method in pip. Same issue. After this, I download the package manually and do a python setup.py install, which gives me an error: > > 'Microsoft 14+ build tools are required' > > > I download the build tools, hoping this will solve the issue, But i get the same error How can I solve this? I tried with proxy, without proxy and all combinations of the above. Why is my build tools installation not recognised? Note: I do not have anaconda and i have never used it.
2019/06/03
[ "https://Stackoverflow.com/questions/56427168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7255472/" ]
Ok figured this out after paying more attention to the error message. In packages\Umbraco.SqlServerCE.4.0.0.1\build\Umbraco.SqlServerCE.targets it needed the namepsace i added it there and now it builds. Issue now is figuring out how to get updated package for that dependancy
I just wanted to expand on Ismail's answer. His solution is correct however if you are wondering on how to add the namespace and get it running the file should look like this: [Solution](https://i.stack.imgur.com/l6FBw.jpg)
23,365,857
I noticed, that MingW and GCC compilers use multiple cores if available. For example: ``` for (long i = 0; i < 100000; ++i) { some_complicated_calculation(); } ``` If I open up a Task Manager / System Monitor, I can see that multiple (for me: 2) cores are used. How the compiler decides, which code can run on multiple cores? How do I force the compiler, to use only one core? EDIT My code does not contain any multithreaded code. I'm curious why my program (not the compiler) is using multiple cores.
2014/04/29
[ "https://Stackoverflow.com/questions/23365857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1784001/" ]
It is using a single core as long as there is nothing special inside some\_complicated\_calculation() that creates threads or uses async (C++11) or similar. The activity you see on the task manager cannot be related to the executable that iterates. It could be totally unrelated to what you are working on.
Looks like thread\_bind\_to\_processor provided in GNU software radio is what you're looking for: <http://gnuradio.org/doc/doxygen/namespacegr_1_1thread.html#aab5195edcd94db5c71ecbfef9d578fb7>
3,668,250
I have two functions ``` function ShowCrossWord(var randN) { randomnumber = randN; $(document).ready(function() { $.get("crosswords.xml",{},function(xml){ $('crossword',xml).each(function(i) { }); }); }); } ``` and ``` function ShowLegend(var randN) { randomnumber = randN; $(document).ready(function() { $.get("legends.xml",{},function(xml){ $('legend',xml).each(function(i) {}); }); }); } ``` I am using these in a same javascript file: ``` var randomNumber=Math.floor(Math.random()*233); ShowCrossWord(randomNumber); ShowLegend(randomNumber); ``` None of them seems to work. What would be the solution.
2010/09/08
[ "https://Stackoverflow.com/questions/3668250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/348168/" ]
What were you expecting to happen, and what actually happened? So things I can see: * You never do anything with the XML data. I presume it is not even being returned? * You may need to specify a [dataType attribute](http://api.jquery.com/jQuery.get/) of "xml" so jQuery knows what type of data the server is returning. I recommend you double-check these points above, and then use [FireBug](http://getfirebug.com/) to further narrow-down the problem.
I would guess your mimetype of the XML sent from the server is wrong. It's very picky to get that right, or the XML will not be parsed on the client. You could try to register callback functions for success and error and log the error message and the XMLHTTPRequest object.
36,593,615
Can someone show me ho can i use the variables stored in this Ajax call: ``` $.get( "nuoviServiziReview.html", function( data ) { var nuovoServizioReview = $('<div/>',{id:'servizio'+ incremento}); nuovoServizioReview.html(data); nuovoServizioReview.appendTo(parentDiv2); servizio = nuovoServizioReview; reviewOption1 = nuovoServizioReview.find('.select1'); reviewOption2 = nuovoServizioReview.find('.select2'); reviewOption3 = nuovoServizioReview.find('.select3'); prezzoFisso = nuovoServizioReview.find('.select1').children('label:last-child'); nuovoIdCheckbox.attr('checked', true); $(thisBtnOk).addClass('hidden'); //Add title to Review Section var newServiceTitle = ($(idInputeText).val()); servizio.text(newServiceTitle); }); ``` After the call is done, I need to use the variables inside it but from outside the function. I tried to console.log for example the "servizio" var but it print out nothing on the console. I tried to check different examples but I didn't understand how to use them. Can someone show me a practical example? This ajax call is done after a button is clicked on my index page.
2016/04/13
[ "https://Stackoverflow.com/questions/36593615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5832977/" ]
markup: ``` <ItemTemplate> <asp:Label ID="lblStage" runat="server" Text='<%#ShowStage(Eval("codingStage"))%>'></asp:Label> </ItemTemplate> ``` in code behind: ``` protected string ShowStage(int codingStage) { switch (codingStage) { case 0: return "All"; case 1: return "Uncode"; case 2: return "Code"; default: return "All"; } } ```
In the same RowDataBound event, check e.RowRowType to detect the Header row. Once you are in the Header row, find the dropdown with a FindControl call. Once you have the dropdown, save the selected value are text in an instance variable. Then you can access it when RowDataBound fires for data rows.
41,899,192
could someone explain me about this code please? ``` public class Counter { private AtomicInteger value = new AtomicInteger(); public int incrementLongVersion(){//THIS PART2!!! int oldValue = value.get(); while (!value.compareAndSet(oldValue, oldValue+1)){ oldValue = value.get(); } return oldValue+1; } } ``` i mean why can't i just change this code ``` !value.compareAndSet(oldValue, oldValue+1) ``` to ``` false ``` ? I know there will be compile error statement never reached but why ``` !value.compareAndSet(oldValue, oldValue+1) ``` is not getting error? isn't it always false too right? Or why can't I just clear that while loop and just return "oldValue+1"? Thanks and regards.
2017/01/27
[ "https://Stackoverflow.com/questions/41899192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5355260/" ]
If `incrementLongVersion` is called from multiple threads, `value.compareAndSet(oldValue, oldValue+1)` may return `false`. The purpose of the `while` loop is to make sure that the function returns a value that's unique among all working threads. A better way to implement this would be to simply use `incrementAndGet` from `AtomicInteger`. ``` public class Counter { private AtomicInteger value = new AtomicInteger(); public int incrementLongVersion(){ return value.incrementAndGet(); } } ```
It is always `false` because **you know** what that function do, however the compiler does not analyze the body of given method call to check the return value will always be the same, false in this case.
46,704,318
**Edit** So many good answers and all of them work! Thanks a lot guys :) I wish I could mark all of them as solved! **----** Good day Let's say I have these 2 text inputs: ``` <input type="text" id="plt_quantity_sum"/> <!-- this should calculate the "#quantity" where each "#uom_value" is "PLT" --> <input type="text" id="crt_quantity_sum"/><!-- this should calculate the "#quantity" where each "#uom_value" is "CRT" --> ``` Let's assume the following scenario: ```html <table> <tbody> <tr> <th>Item Name</th> <th id="uom_value">UOM</th> <th id="qty">Quantity</th> </tr> <tr> <td>Item 1</td> <td id="uom_value">PLT</td> <td id="qty">5</td> </tr> <tr> <td>Item 2</td> <td class="uom_value">PLT</td> <td id="qty">3</td> </tr> <tr> <td>Item 3</td> <td id="uom_value">CRT</td> <td id="qty">2</td> </tr> <tr> <td>Item 4</td> <td id="uom_value">CRT</td> <td id="qty">3</td> </tr> </tbody> </table> <input type="text" id="plt_quantity_sum" /> <input type="text" id="crt_quantity_sum" /> ``` **What needs to happen:** When the document loads, or via a button click; the quantity of "#plt\_quantity\_sum" and "#crt\_quantity\_sum" should be calculated based on their respective quantities and "UOM" values. Some Javascript I had in mind which should clarify what exactly needs to happen: ``` $(document).ready(function(){ if (document.getElementById("#uom_value").value == "PLT"){ document.getElementById("#plt_quantity_sum").value == (sum of #qty); } else if (document.getElementById("#uom_value").value == "CRT"){ document.getElementById("#crt_quantity_sum").value == (sum of #qty); } }); ``` Thanks for reading and I would greatly appreciate any help.
2017/10/12
[ "https://Stackoverflow.com/questions/46704318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6294563/" ]
Your query will goes like this. ``` $query = mysqli_query($conn, "INSERT INTO tab (ltime) VALUES ('$time')"); ```
Your query should be like this ``` $query = mysqli_query($conn, "INSERT INTO tab (ltime) VALUES ($time)"); ```
46,704,318
**Edit** So many good answers and all of them work! Thanks a lot guys :) I wish I could mark all of them as solved! **----** Good day Let's say I have these 2 text inputs: ``` <input type="text" id="plt_quantity_sum"/> <!-- this should calculate the "#quantity" where each "#uom_value" is "PLT" --> <input type="text" id="crt_quantity_sum"/><!-- this should calculate the "#quantity" where each "#uom_value" is "CRT" --> ``` Let's assume the following scenario: ```html <table> <tbody> <tr> <th>Item Name</th> <th id="uom_value">UOM</th> <th id="qty">Quantity</th> </tr> <tr> <td>Item 1</td> <td id="uom_value">PLT</td> <td id="qty">5</td> </tr> <tr> <td>Item 2</td> <td class="uom_value">PLT</td> <td id="qty">3</td> </tr> <tr> <td>Item 3</td> <td id="uom_value">CRT</td> <td id="qty">2</td> </tr> <tr> <td>Item 4</td> <td id="uom_value">CRT</td> <td id="qty">3</td> </tr> </tbody> </table> <input type="text" id="plt_quantity_sum" /> <input type="text" id="crt_quantity_sum" /> ``` **What needs to happen:** When the document loads, or via a button click; the quantity of "#plt\_quantity\_sum" and "#crt\_quantity\_sum" should be calculated based on their respective quantities and "UOM" values. Some Javascript I had in mind which should clarify what exactly needs to happen: ``` $(document).ready(function(){ if (document.getElementById("#uom_value").value == "PLT"){ document.getElementById("#plt_quantity_sum").value == (sum of #qty); } else if (document.getElementById("#uom_value").value == "CRT"){ document.getElementById("#crt_quantity_sum").value == (sum of #qty); } }); ``` Thanks for reading and I would greatly appreciate any help.
2017/10/12
[ "https://Stackoverflow.com/questions/46704318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6294563/" ]
Your query will goes like this. ``` $query = mysqli_query($conn, "INSERT INTO tab (ltime) VALUES ('$time')"); ```
Columns and tables should have backticks and not single quotes ``` INSERT INTO `tab` (`ltime`) VALUES ($time) ```
46,704,318
**Edit** So many good answers and all of them work! Thanks a lot guys :) I wish I could mark all of them as solved! **----** Good day Let's say I have these 2 text inputs: ``` <input type="text" id="plt_quantity_sum"/> <!-- this should calculate the "#quantity" where each "#uom_value" is "PLT" --> <input type="text" id="crt_quantity_sum"/><!-- this should calculate the "#quantity" where each "#uom_value" is "CRT" --> ``` Let's assume the following scenario: ```html <table> <tbody> <tr> <th>Item Name</th> <th id="uom_value">UOM</th> <th id="qty">Quantity</th> </tr> <tr> <td>Item 1</td> <td id="uom_value">PLT</td> <td id="qty">5</td> </tr> <tr> <td>Item 2</td> <td class="uom_value">PLT</td> <td id="qty">3</td> </tr> <tr> <td>Item 3</td> <td id="uom_value">CRT</td> <td id="qty">2</td> </tr> <tr> <td>Item 4</td> <td id="uom_value">CRT</td> <td id="qty">3</td> </tr> </tbody> </table> <input type="text" id="plt_quantity_sum" /> <input type="text" id="crt_quantity_sum" /> ``` **What needs to happen:** When the document loads, or via a button click; the quantity of "#plt\_quantity\_sum" and "#crt\_quantity\_sum" should be calculated based on their respective quantities and "UOM" values. Some Javascript I had in mind which should clarify what exactly needs to happen: ``` $(document).ready(function(){ if (document.getElementById("#uom_value").value == "PLT"){ document.getElementById("#plt_quantity_sum").value == (sum of #qty); } else if (document.getElementById("#uom_value").value == "CRT"){ document.getElementById("#crt_quantity_sum").value == (sum of #qty); } }); ``` Thanks for reading and I would greatly appreciate any help.
2017/10/12
[ "https://Stackoverflow.com/questions/46704318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6294563/" ]
Your query will goes like this. ``` $query = mysqli_query($conn, "INSERT INTO tab (ltime) VALUES ('$time')"); ```
``` $query = mysqli_query($conn, "INSERT INTO tab (ltime) VALUES ($time)"); ``` Don't use '' when assigning the column name
46,704,318
**Edit** So many good answers and all of them work! Thanks a lot guys :) I wish I could mark all of them as solved! **----** Good day Let's say I have these 2 text inputs: ``` <input type="text" id="plt_quantity_sum"/> <!-- this should calculate the "#quantity" where each "#uom_value" is "PLT" --> <input type="text" id="crt_quantity_sum"/><!-- this should calculate the "#quantity" where each "#uom_value" is "CRT" --> ``` Let's assume the following scenario: ```html <table> <tbody> <tr> <th>Item Name</th> <th id="uom_value">UOM</th> <th id="qty">Quantity</th> </tr> <tr> <td>Item 1</td> <td id="uom_value">PLT</td> <td id="qty">5</td> </tr> <tr> <td>Item 2</td> <td class="uom_value">PLT</td> <td id="qty">3</td> </tr> <tr> <td>Item 3</td> <td id="uom_value">CRT</td> <td id="qty">2</td> </tr> <tr> <td>Item 4</td> <td id="uom_value">CRT</td> <td id="qty">3</td> </tr> </tbody> </table> <input type="text" id="plt_quantity_sum" /> <input type="text" id="crt_quantity_sum" /> ``` **What needs to happen:** When the document loads, or via a button click; the quantity of "#plt\_quantity\_sum" and "#crt\_quantity\_sum" should be calculated based on their respective quantities and "UOM" values. Some Javascript I had in mind which should clarify what exactly needs to happen: ``` $(document).ready(function(){ if (document.getElementById("#uom_value").value == "PLT"){ document.getElementById("#plt_quantity_sum").value == (sum of #qty); } else if (document.getElementById("#uom_value").value == "CRT"){ document.getElementById("#crt_quantity_sum").value == (sum of #qty); } }); ``` Thanks for reading and I would greatly appreciate any help.
2017/10/12
[ "https://Stackoverflow.com/questions/46704318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6294563/" ]
Your query will goes like this. ``` $query = mysqli_query($conn, "INSERT INTO tab (ltime) VALUES ('$time')"); ```
The first way specifies both the column names and the values to be inserted: ``` INSERT INTO table_name (column1, column2, column3, ...)VALUES (value1, value2, value3, ...); ``` If you are adding values for all the columns of the table, you do not need to specify the column names in the SQL query ``` INSERT INTO table_name VALUES (value1, value2, value3, ...); ``` In your case: ``` $query = mysqli_query($conn, "INSERT INTO tab (ltime) VALUES ($time)"); ``` there is no need to single quote with column name: Reference: <https://www.w3schools.com/sql/sql_insert.asp>
10,727,140
I was wondering if there is a way to use my GPU to speed up the training of a network in PyBrain.
2012/05/23
[ "https://Stackoverflow.com/questions/10727140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/896317/" ]
Unless PyBrain is designed for that, you probably can't. You might want to try running your trainer under PyPy if you aren't already -- it's significantly faster than CPython for some workloads. Perhaps this is one of those workloads. :)
Checkout Pylearn2: <https://github.com/lisa-lab/pylearn2> It's a newer library and can run on GPU's with CUDA via cuda-convnet.
69,641,330
I am trying to write a PowerShell script that will return me a JSON...This is what I have been able to get. ``` $stepBase = @{} $wizardDataArray = @{} $stepTypeData =@{} $step = New-Object System.Collections.ArrayList $wizardData = @{"mode"="Add"; "resourceName"="basicServer"; "serverName"="demoServer"; "serverAddress"="xyz.abc.info"; "activeDbCatalog"="demodb";} $stepData = @{"wizardType"="baseServer"; "wizardData"=$wizardData} $stepTypeData = @{"stepType"="runWizard"; "stepData"=$stepData} $step.Add(@{"steps"=$stepTypeData}) $stepBase.Add("steps", $step) $stepBase | ConvertTo-Json -Depth 10 ``` This is the ouput : ``` 0 { "steps": [ { "steps": { "stepData": { "wizardType": "baseServer", "wizardData": { "serverAddress": "xyz.abc.info", "activeDbCatalog": "demodb", "resourceName": "basicServer", "mode": "Add", "serverName": "demoServer" } }, "stepType": "runWizard" } } ] } ``` But this is different from my need...which is this... ``` { "steps": [ { "stepType": "runWizard", "stepData": { "wizardType": "baseServer", "wizardData": { "mode": "Add", "resourceName": "basicServer", "serverName": "demoServer", "serverAddress": "xyz.abc.info", "activeDbCatalog": "demoDb" } } } ] } ``` I am not able to get my array inside the list without mentioning the key "step".
2021/10/20
[ "https://Stackoverflow.com/questions/69641330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14279707/" ]
Try this... ``` $stepBase = @{} $step = New-Object System.Collections.ArrayList $wizardData = @{"mode"="Add"; "resourceName"="basicServer"; "serverName"="demoServer"; "serverAddress"="xyz.abc.info"; "activeDbCatalog"="demodb";} $stepData = @{"wizardType"="demoServer"; "wizardData"=$wizardData} $step.Add(@{"stepType"="runWizard"; "stepData"=$stepData}) $stepBase.Add("steps", $step) $stepBase | ConvertTo-Json -Depth 10 ```
so what if you skip the very last assignment and convert `$step` to JSON? like so: ``` $wizardDataArray = @{} $stepTypeData =@{} $step = New-Object System.Collections.ArrayList $wizardData = @{"mode"="Add"; "resourceName"="basicServer"; "serverName"="demoServer"; "serverAddress"="xyz.abc.info"; "activeDbCatalog"="demodb";} $stepData = @{"wizardType"="baseServer"; "wizardData"=$wizardData} $stepTypeData = @{"stepType"="runWizard"; "stepData"=$stepData} $step.Add(@{"steps"=$stepTypeData}) $step | ConvertTo-Json -Depth 10 ```
25,870,519
We have recently upgraded from Drools 5 to Drools 6 and have run into disturbing conflict issues. We have `kie-ci` imported into out project. `kie-ci` brings in `sisu-guava`. `sisu-guava` changes the accessibility of some of the classes from google's guava. Unfortunately, it uses the same package name as google's guava. Since we're working with google's guava in our project, we are running into conflicts of classes. An attempt to remove `sisu-guava` from the project (using a maven exclusion) results in accessibility exceptions, as the kie-ci code attempt to access classes which are public in `sisu-guava` but are private in google's guava. Any idea how to get round this.
2014/09/16
[ "https://Stackoverflow.com/questions/25870519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/416300/" ]
As far I know, the answer would be **NO**. There is winforms class [Screen.cs](http://referencesource.microsoft.com/#System.Windows.Forms/ndp/fx/src/winforms/Managed/System/WinForms/Screen.cs) that can do few basic things, but that does not expose monitor display name. It exposes though DeviceName that can be used for further analysis, if that helps: ``` Screen.AllScreens[0].Dump() ``` would give you: ``` Screen[Bounds={X=0,Y=0,Width=1920,Height=1200} WorkingArea={X=0,Y=0,Width=1920,Height=1160} Primary=True DeviceName=\\.\DISPLAY1] ``` I did start [MultiMonitorHelper](https://github.com/ErtiEelmaa/MultiMonitorHelper/tree/master) library that should aim to "abstract" away all this meaningless WinAPI/WMI gibberish, but I never got around doing it. It is on my "want-to-do" things list though :p
Maybe over the Registry? It will got through all your Displays. It will return the Name out of the EDID. BUT, there was a Change in Win10! Win10 has no "Control" but a "Properties" SubKey (Workaround at the IF/OR) #untested! ``` Public Function GetMonitorDetails() As List(Of String()) Dim sReturn As List(Of String()) = New List(Of String()) 'Open the Display Reg-Key Dim Display As RegistryKey = Registry.LocalMachine Dim bFailed As Boolean = False Try Display = Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Enum\DISPLAY") Catch ex As Exception sReturn.Add({"Error", ex.Message}) bFailed = True End Try If Not bFailed And (Display IsNot Nothing) Then 'Get all MonitorIDss For Each sMonitorID As String In Display.GetSubKeyNames() Dim MonitorID As RegistryKey = Display.OpenSubKey(sMonitorID) If MonitorID IsNot Nothing Then 'Get all Plug&Play ID's For Each sPNPID As String In MonitorID.GetSubKeyNames() Dim PnPID As RegistryKey = MonitorID.OpenSubKey(sPNPID) If PnPID IsNot Nothing Then Dim sSubkeys As String() = PnPID.GetSubKeyNames() Dim ssSubkeys As String = String.Join(".", sSubkeys) 'Check if Monitor is active If (ssSubkeys.Contains("Control") Or ssSubkeys.Contains("Properties")) And ssSubkeys.Contains("Device Parameters") Then Dim DevParam As RegistryKey = PnPID.OpenSubKey("Device Parameters") Dim sSerial As String = "" Dim sModel As String = "" Dim tmpMfg As String = "" Dim tmpVer As String = "" Dim tmpDev As String = "" Dim iWeek As Integer = 0 Dim iYear As Integer = 0 'Define Search Keys Dim sSerFind As New String(New Char() {ChrW(0), ChrW(0), ChrW(0), ChrW(&HFF)}) Dim sModFind As New String(New Char() {ChrW(0), ChrW(0), ChrW(0), ChrW(&HFC)}) 'Get the EDID code Dim bObj As Byte() = TryCast(DevParam.GetValue("EDID", Nothing), Byte()) If bObj IsNot Nothing Then 'Get the 4 Vesa descriptor blocks Dim sDescriptor As String() = New String(3) {} sDescriptor(0) = Encoding.[Default].GetString(bObj, &H36, 18) sDescriptor(1) = Encoding.[Default].GetString(bObj, &H48, 18) sDescriptor(2) = Encoding.[Default].GetString(bObj, &H5A, 18) sDescriptor(3) = Encoding.[Default].GetString(bObj, &H6C, 18) iWeek = Asc(Encoding.[Default].GetString(bObj, &H10, 1)) iYear = Asc(Encoding.[Default].GetString(bObj, &H11, 1)) + 1990 Dim tmpEDIDMfg As String Dim Char1, Char2, Char3 As Integer Dim Byte1, Byte2 As Byte tmpEDIDMfg = Encoding.[Default].GetString(bObj, &H8, 2) Char1 = 0 : Char2 = 0 : Char3 = 0 Byte1 = CByte(Asc(Left(tmpEDIDMfg, 1))) Byte2 = CByte(Asc(Right(tmpEDIDMfg, 1))) If (Byte1 And 64) > 0 Then Char1 = Char1 + 16 If (Byte1 And 32) > 0 Then Char1 = Char1 + 8 If (Byte1 And 16) > 0 Then Char1 = Char1 + 4 If (Byte1 And 8) > 0 Then Char1 = Char1 + 2 If (Byte1 And 4) > 0 Then Char1 = Char1 + 1 If (Byte1 And 2) > 0 Then Char2 = Char2 + 16 If (Byte1 And 1) > 0 Then Char2 = Char2 + 8 If (Byte2 And 128) > 0 Then Char2 = Char2 + 4 If (Byte2 And 64) > 0 Then Char2 = Char2 + 2 If (Byte2 And 32) > 0 Then Char2 = Char2 + 1 Char3 = Char3 + (Byte2 And 16) Char3 = Char3 + (Byte2 And 8) Char3 = Char3 + (Byte2 And 4) Char3 = Char3 + (Byte2 And 2) Char3 = Char3 + (Byte2 And 1) tmpMfg = Chr(Char1 + 64) & Chr(Char2 + 64) & Chr(Char3 + 64) Dim tmpEDIDMajorVer, tmpEDIDRev As Integer tmpEDIDMajorVer = Asc(Encoding.[Default].GetString(bObj, &H12, 1)) tmpEDIDRev = Asc(Encoding.[Default].GetString(bObj, &H13, 1)) tmpVer = Chr(48 + tmpEDIDMajorVer) & "." & Chr(48 + tmpEDIDRev) Dim tmpEDIDDev1, tmpEDIDDev2 As String tmpEDIDDev1 = Hex(Asc(Encoding.[Default].GetString(bObj, &HA, 1))) tmpEDIDDev2 = Hex(Asc(Encoding.[Default].GetString(bObj, &HB, 1))) If Len(tmpEDIDDev1) = 1 Then tmpEDIDDev1 = "0" & tmpEDIDDev1 If Len(tmpEDIDDev2) = 1 Then tmpEDIDDev2 = "0" & tmpEDIDDev2 tmpDev = tmpEDIDDev2 & tmpEDIDDev1 'Search the Keys For Each sDesc As String In sDescriptor If sDesc.Contains(sSerFind) Then sSerial = sDesc.Substring(4).Replace(vbNullChar, "").Trim() End If If sDesc.Contains(sModFind) Then sModel = sDesc.Substring(4).Replace(vbNullChar, "").Trim() End If Next End If If Not String.IsNullOrEmpty(sPNPID & sSerFind & sModel & sMonitorID) Then sReturn.Add({sMonitorID, sModel, sPNPID, tmpDev, tmpVer, tmpMfg, iWeek, iYear, sSerial}) End If End If End If Next End If Next End If Return sReturn End Function ```
71,883,207
I'm trying to change the date format of my data from (11 20, 2014) to 2014-11-20. I tried this: ``` df.withColumn("newDate", to_date(col("reviewTime"),("mm dd, yyyy"))) ``` Because the days with single digits appear as 1,2,8 instead of 01,02,08 I got this message: SparkUpgradeException: You may get a different result due to the upgrading of Spark 3.0: Fail to parse '09 1, 2014' in the new parser. You can set spark.sql.legacy.timeParserPolicy to LEGACY to restore the behavior before Spark 3.0, or set to CORRECTED and treat it as an invalid datetime string. Caused by: DateTimeParseException: Text '09 1, 2014' could not be parsed at index 3 Is there a way to fix this? Thanks!
2022/04/15
[ "https://Stackoverflow.com/questions/71883207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18812199/" ]
You can wrap the function in a macro, and use the preprocessor to get the variable name as a string. ``` #include <iostream> #include <string> #define printArray(x, y) printArrayElements((#x), x, y) void printArrayElements(std::string name, int num[], int size){ std::cout << "Array name: " << name << std::endl; for(int i=0;i<size;i++){ std::cout << "Array elements: " << num[i] << std::endl; } std::cout << std::endl; } int main() { int test[5] = {1,2,3,4,5}; int cool[10] = {4,1,2,4,5,3,7,4,2,7}; printArray(test, 5); printArray(cool, 10); } ```
This is not possible with vanilla C++ at the moment, but you can use the preprocesser to do it: ``` #define PRINTNAME(name) (std::cout << "name" << ":" << (#name) << std::endl) ```
43,957,034
How do I specific a function can take a list of numbers which can be ints or floats? I tried making a new type using Union like so: ``` num = Union[int, float] def quick_sort(arr: List[num]) -> List[num]: ... ``` However, mypy didn't like this: ``` quickSortLomutoFirst.py:32: error: Argument 1 to "quickSortOuter" has incompatible type List[int]; expected List[Union[int, float]] ``` Is there a Type that encompasses ints and floats?
2017/05/13
[ "https://Stackoverflow.com/questions/43957034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5478942/" ]
The short answer to your question is you should use either TypeVars or Sequence -- using `List[Union[int, float]]` would actually potentially introduce a bug into your code! In short, the problem is that Lists are *invariant* according to the PEP 484 type system (and in many other typesystems -- e.g. Java, C#...). You're attempting to use that list as if it were *covariant* instead. You can learn more about covariance and invariance [here](http://mypy.readthedocs.io/en/latest/generics.html#variance-of-generic-types) and [here](http://mypy.readthedocs.io/en/latest/common_issues.html#invariance-vs-covariance), but perhaps an example of why your code is potentially un-typesafe might be useful. Consider the following code: ``` from typing import Union, List Num = Union[int, float] def quick_sort(arr: List[Num]) -> List[Num]: arr.append(3.14) # We deliberately append a float return arr foo = [1, 2, 3, 4] # type: List[int] quick_sort(foo) # Danger!!! # Previously, `foo` was of type List[int], but now # it contains a float!? ``` If this code were permitted to typecheck, we just broke our code! Any code that relies on `foo` being of exactly type `List[int]` would now break. Or more precisely, even though `int` is a legitimate subtype of `Union[int, float]`, that doesn't mean that `List[int]` is a subtype of `List[Union[int, float]]`, or vice versa. --- If we're ok with this behavior (we're ok with `quick_sort` deciding to inject arbitrary ints or floats into the input array), the fix is to manually annotate `foo` with `List[Union[int, float]]`: ``` foo = [1, 2, 3, 4] # type: List[Union[int, float]] # Or, in Python 3.6+ foo: List[Union[int, float]] = [1, 2, 3, 4] ``` That is, declare up-front that `foo`, despite only containing ints, is also meant to contain floats as well. This prevents us from incorrectly using the list after `quick_sort` is called, sidestepping the issue altogether. In some contexts, this may be what you want to do. For this method though, probably not. --- If we're *not* ok with this behavior, and want `quick_sort` to preserve whatever types were originally in the list, two solutions come to mind: The first is to use a *covariant* type instead of list -- for example, [`Sequence`](https://docs.python.org/3/library/typing.html#typing.Sequence): ``` from typing import Union, Sequence Num = Union[int, float] def quick_sort(arr: Sequence[Num]) -> Sequence[Num]: return arr ``` It turns out Sequence is more or less like List, except that it's immutable (or more precisely, Sequence's API doesn't contain any way of letting you mutate the list). This lets us safely sidestep the bug we had up above. The second solution is to type your array more precisely, and insist that it *must* contain either all ints or all floats, disallowing a mixture of the two. We can do so using [TypeVars with value restrictions](http://mypy.readthedocs.io/en/latest/generics.html#type-variables-with-value-restriction): ``` from typing import Union, List, TypeVar # Note: The informal convention is to prefix all typevars with # either 'T' or '_T' -- so 'TNum' or '_TNum'. TNum = TypeVar('TNum', int, float) def quick_sort(arr: List[TNum]) -> List[TNum]: return arr foo = [1, 2, 3, 4] # type: List[int] quick_sort(foo) bar = [1.0, 2.0, 3.0, 4.0] # type: List[float] quick_sort(foo) ``` This will also prevent us from accidentally "mixing" types like we had up above. I would recommend using the second approach -- it's a bit more precise, and will prevent you from losing information about the exact type a list contains as you pass it through your quicksort function.
From [PEP 484](https://www.python.org/dev/peps/pep-0484/#id26), which proposed type hints: > > Rather than requiring that users write import numbers and then use `numbers.Float` etc., this PEP proposes a straightforward shortcut that is almost as effective: when an argument is annotated as having type `float`, an argument of type `int` is acceptable... > > > Don't bother with the `Union`s. Just stick to `Sequence[float]`. Edit: Thanks to Michael for catching the difference between `List` and `Sequence`.
53,149,526
If we set up a Saga and immediately `Publish(context => ...)` then a message successfully hits the bus. If however, we have something like ``` Initially( When(SomeCommand) .Then(context => { context.Instance.SomeField = 5 }) .TransitionTo(SomeState) .Then(context => this.RaiseEvent(context.Instance, SomeEvent))); During(SomeState, When(SomeEvent) // ConsumeContext is not available here .Publish(context => new SomeEventClass { Foo = context.Instance.SomeField }) .Finalize()); ``` The machine also never transitions to the Final state presumably because of the exception locating a ConsumeContext. We have seen some references to passing a `ConsumeContext` as a parameter in `Publish()` however it's unclear as to which context this needs (Intellisense just makes reference to context1, context2, context3, etc). Is there a way to use `Publish()` after `RaiseEvent()` has already been called? If not, is there a way to publish an event using some other mechanism? MassTransit version is 5.1.5 and Automatonymous is 4.1.2 --- **EDIT** Based on Chris Patterson's answer [here](https://stackoverflow.com/questions/53149526#53154225) we have tried adding the below outside of any `Initially` or `During` ``` WhenEnter(NewState, state => state.Publish(context => new EventClass { Foo = context.Instance.Foo } ) .Finalize(); ``` However it still doesn't publish anything and the state never transitions to `Final`. If we add a `Then` it also never hits this code block. There don't seem to be any exceptions occurring. We also tried using `When(SomeState.Enter)` and it also doesn't work. Side question as maybe this will help with my understanding of why `Publish` and `RaiseEvent` don't seem to play nicely together - why does `Publish` need the `ConsumeContext`? Is it to locate the bus and bindings?
2018/11/05
[ "https://Stackoverflow.com/questions/53149526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/838163/" ]
I'd do this natively in bash using a `for` loop, rather than using `find`. I honestly can't remember if bash makes any promises about the order in which globs will be processed. So, using the sample date you included, here's a one-liner that compares files using `[[`: ``` $ declare -A last=(); for a in *; do for b in $a/[0-9]*/; do [[ $b > $last[$a] ]] && last[$a]=$b; done; done; declare -p last declare -A last=([bbb]="bbb/181105_0000/" [zzz]="zzz/181004_2355/" [aaa]="aaa/181012_1545/" ) ``` Note that the limiting patern here is `$a/[0-9]*/`, which is sufficient for your sample data. You can of course restrict this as necessary, using character classes and eliminating the glob. Note also that the trailing `/` in this pattern ensures that you will only match things that are directories. This will put a `/` at the end of every result in the `$last` array. You can post-process if required: ``` $ for i in "${!last[@]}"; do last[$i]="${last[$i]%/}"; last[$i]="${last[$i]#*/}"; done $ declare -p last declare -A last=([bbb]="181105_0000" [zzz]="181004_2355" [aaa]="181012_1545" ) ``` For easier reading, here's the one-liner split into multiple lines. :) ``` # Create an associative array. Requires bash 4+. declare -A last=() # Step through the top-level directories for a in *; do # Step through the second level directories for b in "$a"/[0-9]*/; do # Compare and record as required [[ $b > $last[$a] ]] && last[$a]="$b" done done # Print the result declare -p last ```
You're tailing the output of the command with `tail -1`. So you will only get the very last line. :) Beyond that your command looks correct. Couple other notes: 1. You can write `find .` without the glob because find is recursive by default 2. `???????????` could be more restrictive if you needed. `??????_????` or using `[[:digit:]]` would be options.
53,149,526
If we set up a Saga and immediately `Publish(context => ...)` then a message successfully hits the bus. If however, we have something like ``` Initially( When(SomeCommand) .Then(context => { context.Instance.SomeField = 5 }) .TransitionTo(SomeState) .Then(context => this.RaiseEvent(context.Instance, SomeEvent))); During(SomeState, When(SomeEvent) // ConsumeContext is not available here .Publish(context => new SomeEventClass { Foo = context.Instance.SomeField }) .Finalize()); ``` The machine also never transitions to the Final state presumably because of the exception locating a ConsumeContext. We have seen some references to passing a `ConsumeContext` as a parameter in `Publish()` however it's unclear as to which context this needs (Intellisense just makes reference to context1, context2, context3, etc). Is there a way to use `Publish()` after `RaiseEvent()` has already been called? If not, is there a way to publish an event using some other mechanism? MassTransit version is 5.1.5 and Automatonymous is 4.1.2 --- **EDIT** Based on Chris Patterson's answer [here](https://stackoverflow.com/questions/53149526#53154225) we have tried adding the below outside of any `Initially` or `During` ``` WhenEnter(NewState, state => state.Publish(context => new EventClass { Foo = context.Instance.Foo } ) .Finalize(); ``` However it still doesn't publish anything and the state never transitions to `Final`. If we add a `Then` it also never hits this code block. There don't seem to be any exceptions occurring. We also tried using `When(SomeState.Enter)` and it also doesn't work. Side question as maybe this will help with my understanding of why `Publish` and `RaiseEvent` don't seem to play nicely together - why does `Publish` need the `ConsumeContext`? Is it to locate the bus and bindings?
2018/11/05
[ "https://Stackoverflow.com/questions/53149526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/838163/" ]
I'd do this natively in bash using a `for` loop, rather than using `find`. I honestly can't remember if bash makes any promises about the order in which globs will be processed. So, using the sample date you included, here's a one-liner that compares files using `[[`: ``` $ declare -A last=(); for a in *; do for b in $a/[0-9]*/; do [[ $b > $last[$a] ]] && last[$a]=$b; done; done; declare -p last declare -A last=([bbb]="bbb/181105_0000/" [zzz]="zzz/181004_2355/" [aaa]="aaa/181012_1545/" ) ``` Note that the limiting patern here is `$a/[0-9]*/`, which is sufficient for your sample data. You can of course restrict this as necessary, using character classes and eliminating the glob. Note also that the trailing `/` in this pattern ensures that you will only match things that are directories. This will put a `/` at the end of every result in the `$last` array. You can post-process if required: ``` $ for i in "${!last[@]}"; do last[$i]="${last[$i]%/}"; last[$i]="${last[$i]#*/}"; done $ declare -p last declare -A last=([bbb]="181105_0000" [zzz]="181004_2355" [aaa]="181012_1545" ) ``` For easier reading, here's the one-liner split into multiple lines. :) ``` # Create an associative array. Requires bash 4+. declare -A last=() # Step through the top-level directories for a in *; do # Step through the second level directories for b in "$a"/[0-9]*/; do # Compare and record as required [[ $b > $last[$a] ]] && last[$a]="$b" done done # Print the result declare -p last ```
The idea to use `sort -u` and `tail -1` is good, and it'll work when used with the list of sub directories from within the same parent directory. The `-u` is going to remove duplicates, but this is not needed because 2 sub directories cannot have the same name within the same parent directory. `?` means any chars; a more restrictive `[0-9]` can be used instead to select a single digit. Give a try to this: ``` find . -maxdepth 1 -type d -print0 | xargs -0 sh -c ' for dir ; do find "${dir}" -maxdepth 1 -type d \ -name '[0-9][0-9][0-1][0-9][0-3][0-9]_[0-2][0-9][0-6][0-9]' | sort | tail -1 done' dummy | sort ``` For each directory found at the first level (first `find . -maxdepth 1 ...`): * all sub directories that match the pattern `[0-9][0-9][0-1][0-9][0-3][0-9]_[0-2][0-9][0-6][0-9]` are listed (second `find`) * only the latest is printed (thanks to `sort` and `tail` commands) the `-print0` and `-0` arguments are used together with the `sh -c` and the `for statement` to make the command line robust to filenames with special chars, such as `line break`. `dummy` is not used but it is mandatory, see `man sh` **TEST** ``` mkdir -p aaa/180809_1047 aaa/180915_0055 aaa/181012_1545 aaa/xyz \ bbb/xyz bbb/180809_1047 bbb/180915_0055 bbb/181012_1545 bbb/181105_0000 \ zzz/xyz zzz/180821_1555 zzz/181004_2355 find . -maxdepth 1 -type d -print0 | xargs -0 sh -c ' for dir ; do find "${dir}" -maxdepth 1 -type d \ -name '[0-9][0-9][0-1][0-9][0-3][0-9]_[0-2][0-9][0-6][0-9]' | sort | tail -1 done' dummy | sort ./bbb/181105_0000 ./aaa/181012_1545 ./zzz/181004_2355 ```
53,149,526
If we set up a Saga and immediately `Publish(context => ...)` then a message successfully hits the bus. If however, we have something like ``` Initially( When(SomeCommand) .Then(context => { context.Instance.SomeField = 5 }) .TransitionTo(SomeState) .Then(context => this.RaiseEvent(context.Instance, SomeEvent))); During(SomeState, When(SomeEvent) // ConsumeContext is not available here .Publish(context => new SomeEventClass { Foo = context.Instance.SomeField }) .Finalize()); ``` The machine also never transitions to the Final state presumably because of the exception locating a ConsumeContext. We have seen some references to passing a `ConsumeContext` as a parameter in `Publish()` however it's unclear as to which context this needs (Intellisense just makes reference to context1, context2, context3, etc). Is there a way to use `Publish()` after `RaiseEvent()` has already been called? If not, is there a way to publish an event using some other mechanism? MassTransit version is 5.1.5 and Automatonymous is 4.1.2 --- **EDIT** Based on Chris Patterson's answer [here](https://stackoverflow.com/questions/53149526#53154225) we have tried adding the below outside of any `Initially` or `During` ``` WhenEnter(NewState, state => state.Publish(context => new EventClass { Foo = context.Instance.Foo } ) .Finalize(); ``` However it still doesn't publish anything and the state never transitions to `Final`. If we add a `Then` it also never hits this code block. There don't seem to be any exceptions occurring. We also tried using `When(SomeState.Enter)` and it also doesn't work. Side question as maybe this will help with my understanding of why `Publish` and `RaiseEvent` don't seem to play nicely together - why does `Publish` need the `ConsumeContext`? Is it to locate the bus and bindings?
2018/11/05
[ "https://Stackoverflow.com/questions/53149526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/838163/" ]
I'd do this natively in bash using a `for` loop, rather than using `find`. I honestly can't remember if bash makes any promises about the order in which globs will be processed. So, using the sample date you included, here's a one-liner that compares files using `[[`: ``` $ declare -A last=(); for a in *; do for b in $a/[0-9]*/; do [[ $b > $last[$a] ]] && last[$a]=$b; done; done; declare -p last declare -A last=([bbb]="bbb/181105_0000/" [zzz]="zzz/181004_2355/" [aaa]="aaa/181012_1545/" ) ``` Note that the limiting patern here is `$a/[0-9]*/`, which is sufficient for your sample data. You can of course restrict this as necessary, using character classes and eliminating the glob. Note also that the trailing `/` in this pattern ensures that you will only match things that are directories. This will put a `/` at the end of every result in the `$last` array. You can post-process if required: ``` $ for i in "${!last[@]}"; do last[$i]="${last[$i]%/}"; last[$i]="${last[$i]#*/}"; done $ declare -p last declare -A last=([bbb]="181105_0000" [zzz]="181004_2355" [aaa]="181012_1545" ) ``` For easier reading, here's the one-liner split into multiple lines. :) ``` # Create an associative array. Requires bash 4+. declare -A last=() # Step through the top-level directories for a in *; do # Step through the second level directories for b in "$a"/[0-9]*/; do # Compare and record as required [[ $b > $last[$a] ]] && last[$a]="$b" done done # Print the result declare -p last ```
Using find, sort, awk: ``` find -name '??????_????' -type d | sort -r | awk -F'/' '{if(!s[$(NF-1)]++) print $0} ```
57,595
Looking at the 3rd edition of *Space Mission Analysis and Design* by Wertz and Larson, their equation (13-4) presents the link equation, $\frac{E\_b}{N\_0} = \frac{PL\_\ell G\_t L\_s L\_a G\_r}{k T\_s R}$, with $E\_b/N\_0$ being the receiver energy per bit over noise density, $P$ is transmitter power, $L\_\ell$ is transmitter-to-antenna line loss, $G\_t$ the transmit antenna gain, $L\_s$ the free space path loss, $L\_a$ transmission path loss (atmospheric and rain absorption, etc.), $G\_r$ the receive antenna gain, $T\_s$ the system noise temperature, $R$ the data bit rate, and $k$ the Boltzmann constant. Their equation (13-13) then has the same equation in logarithmic (decibel) form: $\frac{E\_b}{N\_0} = P + L\_\ell + G\_t + L\_{pr} + L\_s + L\_a + G\_r + 228.6 - 10\log{T\_s} - 10\log{R}$ This equation is identical to (13-4) except for the addition of the $L\_{pr}$ term. I cannot find the definition of $L\_{pr}$. (Hopefully I'm not just missing it.) This term is in equation (13-14) as well but then seems to disappear. What is $L\_{pr}$? Is it a leftover term from a previous edition perhaps, or does changing the equation to logarithmic form somehow require adding that new term?
2022/01/05
[ "https://space.stackexchange.com/questions/57595", "https://space.stackexchange.com", "https://space.stackexchange.com/users/8350/" ]
Lpr and Lpt would be pointing loss, receiver and pointing loss, transmitter, respectively.
As [@TFC points out](https://space.stackexchange.com/a/60291/12102) the $L\_{p}$s are probably *pointing losses* due to pointing errors away from maximum gain. In this case the gains $G$ would have to be the maximum gains for *ideally pointed antennas* from which this pointing error loss should be deducted. Alternatively you could drop the pointing losses and just define the gains as the *actual gains of the antennas in the current direction of the link.* Just like there are several different styles of accounting and budgeting of money that can give the same result, there are different ways you can construct a link budget and define its terms, depending on how you'd like to look at it. You can say that a Voyager spacecraft's high gain X-band antenna has a gain $G$ of 48 dB and that since it's currently pointed a half-degree away from Earth (just making up numbers here), its pointing loss is say -1 dB. Or you could look up the gain of a Voyager's antenna in the direction that Earth sits relative to it and find that the current gain is 47 dB. Six of one, a half-dozen of the other. --- cf [How well can Voyager 1 separate Earth signals from Solar noise these days?](https://space.stackexchange.com/q/14317/12102) and for a plot of Earth's yearly wobble relative to the Sun as seen from the Voyagers (they are so far away now they don't bother to constantly change attitude for small deviations, and also probably can't afford to do that anyway) and a simple example of their radiation patterns and [this answer to *What is the pop-up circular disk with spiral pattern in this NASA animation of the Dragonfly helicopter for Titan? Antenna? Kind, band, target?*](https://space.stackexchange.com/a/53894/12102) and also [How does Curiosity know how to point and move it's high gain antenna in real time?](https://space.stackexchange.com/q/26679/12102) for screenshots of the radiation pattern for some other spacecraft. --- [![Voyager's antennas' radiation patterns](https://i.stack.imgur.com/CDDGJ.png)](https://i.stack.imgur.com/CDDGJ.png) **above:** From DESCANSO Design and Performance Summary Series [Article 4: Voyager Telecommunications](https://descanso.jpl.nasa.gov/DPSummary/Descanso4--Voyager_new.pdf) as discussed in [this answer](https://space.stackexchange.com/a/24343/12102). **below:** from [this answer](https://space.stackexchange.com/a/53894/12102) (I can't currently find the exact attribution) [![enter image description here](https://i.stack.imgur.com/fCBZO.jpg)](https://i.stack.imgur.com/fCBZO.jpg)
1,091,669
I need a JavaScript library, or Flash as well, which allows to connect events to "click" over "arcs" in graphics. I've implemented my graphic through the JS-Graphs library, but I can only intercept the "click" event on "nodes", not on "arcs".
2009/07/07
[ "https://Stackoverflow.com/questions/1091669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39339/" ]
If you're interesting in using Flex, you may also want to take a look at Josh' Tynjala's [Wires UI](http://joshblog.net/2008/11/10/open-source-flex-project-wires-ui-library/) library.
[WireIt](http://javascript.neyric.com/wireit/) might be similar to what you're looking for. However, they use the YUI library and Canvas, so YMMV.
3,860,002
Prove that if $f$ is differentiable at $c$, then $f'(c) = \lim\_{h\to 0}{f(c+h)-f(c)\over h}$. I did this: If f is differentiable at $c$, then it's continuous at $c$, which implies, $\lim\_{x\to c}$ $f(x)=f(c)$ if only if $\lim\_{h\to 0}$ $f(c+h)-f(c)=0$. Then dividing by $h$, $$\lim\_{h\to 0}{f(c+h)-f(c)\over h}=f'(c).$$ I don't know if this is correct, I feel it's kind of arbitrary. Edit: The definition of derivative is as follows- If $f$ is differentiable at a point *a* then the following limit exists: $\lim\_{x\to a} {f(x)-f(a)\over x-a}$.
2020/10/11
[ "https://math.stackexchange.com/questions/3860002", "https://math.stackexchange.com", "https://math.stackexchange.com/users/832388/" ]
So, from what I understand, the question boils down to showing the equivalence of two definitions of the derivative. Here's what you begin with: > > If $f$ is differentiable at $x=a$, the following limit exists and is equal to $f'(a)$: > $\lim\_{x\to a} {f(x)-f(a)\over x-a}$ > > > Now, put $x-a=h$, that is $x = a + h$. $x \to a$ is the same as $h \to 0$, so you finally get: $f'(a) = \lim\_{h\to0} {f(a+h)-f(a)\over h}$ as desired.
The definition of $f'(c)$ is that if $\lim\_{h\to 0}\frac {f(c+h)-f(c)}{h}$ exists then this limit is $f'(c),$ and if this limit doesn't exist then $f'(c)$ doesn't exist. "$f $ is differentiable at $c$" is just another way to say that $f'(c)$ exists.
3,860,002
Prove that if $f$ is differentiable at $c$, then $f'(c) = \lim\_{h\to 0}{f(c+h)-f(c)\over h}$. I did this: If f is differentiable at $c$, then it's continuous at $c$, which implies, $\lim\_{x\to c}$ $f(x)=f(c)$ if only if $\lim\_{h\to 0}$ $f(c+h)-f(c)=0$. Then dividing by $h$, $$\lim\_{h\to 0}{f(c+h)-f(c)\over h}=f'(c).$$ I don't know if this is correct, I feel it's kind of arbitrary. Edit: The definition of derivative is as follows- If $f$ is differentiable at a point *a* then the following limit exists: $\lim\_{x\to a} {f(x)-f(a)\over x-a}$.
2020/10/11
[ "https://math.stackexchange.com/questions/3860002", "https://math.stackexchange.com", "https://math.stackexchange.com/users/832388/" ]
So, from what I understand, the question boils down to showing the equivalence of two definitions of the derivative. Here's what you begin with: > > If $f$ is differentiable at $x=a$, the following limit exists and is equal to $f'(a)$: > $\lim\_{x\to a} {f(x)-f(a)\over x-a}$ > > > Now, put $x-a=h$, that is $x = a + h$. $x \to a$ is the same as $h \to 0$, so you finally get: $f'(a) = \lim\_{h\to0} {f(a+h)-f(a)\over h}$ as desired.
Nevertheless, that answer is done and accepted, but looking comments under OP, let me say, that here we have question about equivalence of **differentiability** and **existence of derivative**: 1. **Differentiability** (Rudin W. - Principles of mathematical analysis-(1976) 212-213 p.). Suppose $f$ is defined on $(a,b) \subset \mathbb{R}$. We say, that $f$ is differentiable in $x \in (a,b)$ if exists linear mapping $A:\mathbb{R} \to \mathbb{R}$, such that $$\lim\limits\_{h \to 0}\frac{f(x+h)-f(x)-Ah}{h}=0$$ this linear mapping we call differential and denote $df(x)(h)=Ah$ 2. **Derivative**.(Same book as above 211p) We say, that $f$ have derivative in $x \in (a,b)$, when exists $$\lim\limits\_{h \to 0}\frac{f(x+h)-f(x)}{h}=B$$ and $B$ we denote as $B=f'(x)$ Now first sentence of OP mean, that this 2 definitions are equivalent: if exists $A$ in first, then exists $B$ from second and they are equal. Reverse also. So $df(x)(h)=f'(x)h$. More [here](https://math.stackexchange.com/questions/3819116/rigorously-whats-happening-when-i-treat-fracdydx-as-a-fraction/3819142#3819142).
40,009,850
what is the meaning of the following command: ``` def run_initial(self) -> object: ``` I don't know why he put `object` after the arrow. What is the meaning of the object here?
2016/10/12
[ "https://Stackoverflow.com/questions/40009850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6680470/" ]
They are type annotations. Type annotations are type hints that were brought in with [pep-0484](https://www.python.org/dev/peps/pep-0484/). They were made to allow developers to use third party tools or modules that consume these to give more information to the user about types for example. The more obvious use case imho right now is that the Python visual editor PyCharm (which is afaik the most used pycharm editor after sublime, which is not a complete editor) supports them to give programmers information about types, and for auto complete. See <https://www.jetbrains.com/help/pycharm/2016.1/type-hinting-in-pycharm.html>
It's a [Type aliases](https://www.python.org/dev/peps/pep-0484/).They were added in pep-404. Straight from the Python docs: > > A type aliases is defined by assigning the type to the alias...Type aliases are useful for simplifying complex type signatures...Note that None as a type hint is a special case and is replaced by type(None). > > >
45,494
Lets $E\_{\tau}^{\rho}$ be the elliptic curve with complex structure given by $\tau$ in upper half plane and complexified Kahler form $\rho \frac{dz\wedge d\bar{z}}{2}$.( $\rho$ is in upper half plane too) Then mirror symmetry says that mirror to $E\_{i}^{\rho}$ in A-side is $E^{i}\_{\rho}$ in B-side.(see the paper of Polishchuk and Zaslow) then what is the mirror for general $E\_{\tau}^{\rho}$ in A-side (i.e. when we change the complex structure on A-side from the one given by $i$ to something else)??
2010/11/09
[ "https://mathoverflow.net/questions/45494", "https://mathoverflow.net", "https://mathoverflow.net/users/5259/" ]
The mirror of $E^\rho\_\tau$ is $E^\tau\_\rho$, as you may have guessed. The reason this is not discussed in, say, Polishchuk/Zaslow is that the derived category does not depend on the symplectic structure, and the Fukaya category does not depend on the complex structure, so for their purposes the parameter $\tau$ is irrelevant. Btw, another article on "Mirror symmetry and elliptic curves" that you might find interesting is due to Dijkgraaf's, with title as indicated; it is contained in a 1995 volume on "The moduli space of curves" (see e.g. <http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.8.4194&rep=rep1&type=pdf>)
I think the answer is: $E\_{\tau}^{\rho/\tau\_{im}} \leftrightarrow E\_{\rho}^{\tau/ \rho\_{im}}$ where $\tau\_{im}$ is the imaginary part of $\tau$ (a positive number). Infact the answer of AByer is correct if write everything in the coordinate $(x,y)$ for the point $x+i\tau=X+iY$ on $E\_{\tau}$ and not the $(X,Y)$.
41,720,270
I have following DataTable ``` DataTable dt = new dataTable(); ``` I have got this dataTable filled from some another method. It will have 50000 rows and 40 columns before executing following statements. Number of rows and columns may vary. hence I have not defined specific set of columns to the dataTable. I want to add two columns at the end (guid and addeddate) and want to add same value in all 50K rows for those 2 columns. I have written simple foreach loop for this. Is there any way that I can do it Parallely? I tried using Parallel.Foreach but didnt get any success. ``` //by this time my dt will have 50000 rows and 40 columns dt.Columns.Add(new DataColumn("guid", typeof(string))); dt.Columns.Add(new DataColumn("addeddate", typeof(DateTime))); string sessionIDValue = Convert.ToString(Guid.NewGuid()); DateTime todayDt = DateTime.Today; foreach (DataRow row in dt.Rows) { row["guid"] = sessionIDValue; row["addeddate"] = todayDt; } ```
2017/01/18
[ "https://Stackoverflow.com/questions/41720270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2116540/" ]
You need to access the rows using explicit indexes, and the row index would be a perfect way to do this. You should be able to create an array equal to the number of rows you have (e.g. 50000) with an index for each row as the values of that array (e.g. 0..1..2..3.. and so on), and then use a parallel loop on that array of indexes whereby you're passing in the explicit row index to your dt.Rows object. The gist of the code would be: ``` // Pseudo code // Create array equal to size of the # of rows (int ArrayOfIndexes[]) // Fill that array with values representing row indexes starting at 0 Parallel.ForEach(ArrayOfIndexes, (index) => { lock(dt) { dt.Rows[index]["guid"] = sessionIDValue; dt.Rows[index]["addeddate"] = todayDt; } } ``` **EDIT**: I did find out that since DataTable isn't thread-safe, that you have to include the lock around your assignments, which obviously yields a performance hit, but should still be faster than simply looping through without the Parallel.ForEach.
An upgrade of @Shane Oborn 's answer without extra variable of ArrayOfIndexes and uses separate lock object. I would use: ``` var lockObj = new object(); Parallel.Foreach(dt.AsEnumerable(), row => { lock(lockObj) { row["guid"] = sessionIDValue; row["addeddate"] = todayDt; } }); ``` You have to add using statements: ``` using System.Data.DataSetExtensions; using System.Linq; using System.Xml; ```
37,152,501
I submit my code to a spark stand alone cluster. Submit command is like below: ``` nohup ./bin/spark-submit \ --master spark://ES01:7077 \ --executor-memory 4G \ --num-executors 1 \ --total-executor-cores 1 \ --conf "spark.storage.memoryFraction=0.2" \ ./myCode.py 1>a.log 2>b.log & ``` I specify the executor use 4G memory in above command. But use the top command to monitor the executor process, I notice the memory usage keeps growing. Now the top Command output is below: ``` PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 12578 root 20 0 20.223g 5.790g 23856 S 61.5 37.3 20:49.36 java ``` My total memory is 16G so 37.3% is already bigger than the 4GB I specified. And it is still growing. Use the ps command , you can know it is the executor process. ``` [root@ES01 ~]# ps -awx | grep spark | grep java 10409 ? Sl 1:43 java -cp /opt/spark-1.6.0-bin-hadoop2.6/conf/:/opt/spark-1.6.0-bin-hadoop2.6/lib/spark-assembly-1.6.0-hadoop2.6.0.jar:/opt/spark-1.6.0-bin-hadoop2.6/lib/datanucleus-api-jdo-3.2.6.jar:/opt/spark-1.6.0-bin-hadoop2.6/lib/datanucleus-rdbms-3.2.9.jar:/opt/spark-1.6.0-bin-hadoop2.6/lib/datanucleus-core-3.2.10.jar:/opt/hadoop-2.6.2/etc/hadoop/ -Xms4G -Xmx4G -XX:MaxPermSize=256m org.apache.spark.deploy.master.Master --ip ES01 --port 7077 --webui-port 8080 10603 ? Sl 6:16 java -cp /opt/spark-1.6.0-bin-hadoop2.6/conf/:/opt/spark-1.6.0-bin-hadoop2.6/lib/spark-assembly-1.6.0-hadoop2.6.0.jar:/opt/spark-1.6.0-bin-hadoop2.6/lib/datanucleus-api-jdo-3.2.6.jar:/opt/spark-1.6.0-bin-hadoop2.6/lib/datanucleus-rdbms-3.2.9.jar:/opt/spark-1.6.0-bin-hadoop2.6/lib/datanucleus-core-3.2.10.jar:/opt/hadoop-2.6.2/etc/hadoop/ -Xms4G -Xmx4G -XX:MaxPermSize=256m org.apache.spark.deploy.worker.Worker --webui-port 8081 spark://ES01:7077 12420 ? Sl 10:16 java -cp /opt/spark-1.6.0-bin-hadoop2.6/conf/:/opt/spark-1.6.0-bin-hadoop2.6/lib/spark-assembly-1.6.0-hadoop2.6.0.jar:/opt/spark-1.6.0-bin-hadoop2.6/lib/datanucleus-api-jdo-3.2.6.jar:/opt/spark-1.6.0-bin-hadoop2.6/lib/datanucleus-rdbms-3.2.9.jar:/opt/spark-1.6.0-bin-hadoop2.6/lib/datanucleus-core-3.2.10.jar:/opt/hadoop-2.6.2/etc/hadoop/ -Xms1g -Xmx1g -XX:MaxPermSize=256m org.apache.spark.deploy.SparkSubmit --master spark://ES01:7077 --conf spark.storage.memoryFraction=0.2 --executor-memory 4G --num-executors 1 --total-executor-cores 1 /opt/flowSpark/sparkStream/ForAsk01.py 12578 ? Sl 21:03 java -cp /opt/spark-1.6.0-bin-hadoop2.6/conf/:/opt/spark-1.6.0-bin-hadoop2.6/lib/spark-assembly-1.6.0-hadoop2.6.0.jar:/opt/spark-1.6.0-bin-hadoop2.6/lib/datanucleus-api-jdo-3.2.6.jar:/opt/spark-1.6.0-bin-hadoop2.6/lib/datanucleus-rdbms-3.2.9.jar:/opt/spark-1.6.0-bin-hadoop2.6/lib/datanucleus-core-3.2.10.jar:/opt/hadoop-2.6.2/etc/hadoop/ -Xms4096M -Xmx4096M -Dspark.driver.port=52931 -XX:MaxPermSize=256m org.apache.spark.executor.CoarseGrainedExecutorBackend --driver-url spark://[email protected]:52931 --executor-id 0 --hostname 10.79.148.184 --cores 1 --app-id app-20160511080701-0013 --worker-url spark://[email protected]:52660 ``` Below are the code. It is very simple so I do not think there is memory leak ``` if __name__ == "__main__": dataDirectory = '/stream/raw' sc = SparkContext(appName="Netflow") ssc = StreamingContext(sc, 20) # Read CSV File lines = ssc.textFileStream(dataDirectory) lines.foreachRDD(process) ssc.start() ssc.awaitTermination() ``` The code for process function is below. Please note that I am using **HiveContext not SqlContext** here. Because SqlContext do not support window function ``` def getSqlContextInstance(sparkContext): if ('sqlContextSingletonInstance' not in globals()): globals()['sqlContextSingletonInstance'] = HiveContext(sparkContext) return globals()['sqlContextSingletonInstance'] def process(time, rdd): if rdd.isEmpty(): return sc.emptyRDD() sqlContext = getSqlContextInstance(rdd.context) # Convert CSV File to Dataframe parts = rdd.map(lambda l: l.split(",")) rowRdd = parts.map(lambda p: Row(router=p[0], interface=int(p[1]), flow_direction=p[9], bits=int(p[11]))) dataframe = sqlContext.createDataFrame(rowRdd) # Get the top 2 interface of each router dataframe = dataframe.groupBy(['router','interface']).agg(func.sum('bits').alias('bits')) windowSpec = Window.partitionBy(dataframe['router']).orderBy(dataframe['bits'].desc()) rank = func.dense_rank().over(windowSpec) ret = dataframe.select(dataframe['router'],dataframe['interface'],dataframe['bits'], rank.alias('rank')).filter("rank<=2") ret.show() dataframe.show() ``` Actually I found below code will cause the problem: ``` # Get the top 2 interface of each router dataframe = dataframe.groupBy(['router','interface']).agg(func.sum('bits').alias('bits')) windowSpec = Window.partitionBy(dataframe['router']).orderBy(dataframe['bits'].desc()) rank = func.dense_rank().over(windowSpec) ret = dataframe.select(dataframe['router'],dataframe['interface'],dataframe['bits'], rank.alias('rank')).filter("rank<=2") ret.show() ``` Because If I remove these 5 line. The code can run all night without showing memory increase. But adding them will cause the memory usage of executor grow to a very high number. Basically the above code is just some window + grouby in SparkSQL. So is this a bug?
2016/05/11
[ "https://Stackoverflow.com/questions/37152501", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5245972/" ]
> > **Disclaimer:** this answer isn't based on debugging, but more on observations and the documentation Apache Spark provides > > > I don't believe that this is a bug to begin with! Looking at your configurations, we can see that you are focusing mostly on the executor tuning, which isn't wrong, but you are forgetting the driver part of the equation. Looking at the spark cluster overview from [Apache Spark documentaion](https://spark.apache.org/docs/1.6.1/cluster-overview.html) [![enter image description here](https://i.stack.imgur.com/wKhQC.png)](https://i.stack.imgur.com/wKhQC.png) As you can see, each worker has an executor, however, in your case, the worker node is the same as the driver node! Which frankly is the case when you run locally or on a standalone cluster in a single node. Further, the driver takes 1G of memory by default unless tuned using `spark.driver.memory` flag. Furthermore, you should not forget about the heap usage from the JVM itself, and the Web UI that's been taken care of by the driver too AFAIK! When you delete the lines of code you mentioned, your code is left without **actions** as `map` function is just a transformation, hence, there will be no execution, and therefore, you don't see memory increase at all! Same applies on `groupBy` as it is just a transformation that will not be executed unless an action is being called which in your case is `agg` and `show` further down the stream! That said, try to minimize your driver memory and the overall number of cores in spark which is defined by `spark.cores.max` if you want to control the number of cores on this process, then cascade down to the executors. Moreover, I would add [`spark.python.profile.dump`](http://spark.apache.org/docs/latest/configuration.html#runtime-environment) to your list of configuration so you can see a profile for your spark job execution, which can help you more with understanding the case, and to tune your cluster more to your needs.
As I can see in your 5 lines, maybe the `groupBy` is the issue , would you try with `reduceBy`, and see how it performs. See [here](https://codereview.stackexchange.com/questions/115082/generic-reduceby-or-groupby-aggregate-functionality-with-spark-dataframe) and [here](https://databricks.gitbooks.io/databricks-spark-knowledge-base/content/best_practices/prefer_reducebykey_over_groupbykey.html).
19,492,165
I want to have a reload button beside my captcha image to reload it with jquery in codeigniter. I searched the net to find a solution for it, but all I found confused me. this is my controller: ``` function create_captcha() { $expiration = time()-300; // Two hour limit $this->db->query("DELETE FROM captcha WHERE captcha_time < ".$expiration); $vals = array( //'word' => 'Random word', 'word_length' => 4, 'img_path' => './uploads/captcha/', 'img_url' => base_url().'uploads/captcha/', 'font_path' => './system/fonts/texb.ttf', 'img_width' => '110', 'img_height' => '30', 'expiration' => '3600' ); $cap = create_captcha($vals); //puts in the db $captchadata = array( 'captcha_id' => '', 'captcha_time' => $cap['time'], 'ip_address' => $this->input->ip_address(), 'word' => $cap['word'] ); $query = $this->db->insert_string('captcha', $captchadata); $this->db->query($query); if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') echo $cap['image']; else return $cap['image']; ``` and this is my view: ``` <div class="captcha-area"> <? echo form_input('captcha', '', 'class="field text captcha"')?> <div id="cap-img"> <? echo $image;?> </div> <a title="reload" class="reload-captcha" href="#"><img src="<? echo base_url(); ?>images/reload.png" /></a> <div class="clear"></div> </div> <script> $(function(){ var base_url = '<?php echo base_url(); ?>'; $('.reload-captcha').click(function(event){ event.preventDefault(); $('.captcha-img').attr('src', base_url+'dashboard/create_captcha?'+Math.random()); }); }); </script> ``` **EDIT:** this is the source code after loading the site ``` <div class="captcha-area"> <input type="text" name="captcha" value="" class="field text captcha"> <div id="cap-img"> <img src="http://example.com/uploads/captcha/1382346264.1026.jpg" width="110" height="30" class="captcha-img" style="border:0;" alt=" "> </div> <a title="reload" class="reload-captcha" href="#"><img src="http://example.com/images/reload.png"></a> <div class="clear"></div> </div> ``` and when I click on the reload button it changes the src attribute to something like: ``` <img src="http://example.com/dashboard/create_captcha?0.8049291325733066" width="110" height="30" class="captcha-img" style="border:0;" alt=" "> ```
2013/10/21
[ "https://Stackoverflow.com/questions/19492165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1269907/" ]
Append your `controller name` and use `ajax` like, ``` $(function(){ var base_url = '<?php echo base_url(); ?>'; $('.reload-captcha').click(function(event){ event.preventDefault(); $.ajax({ url:base_url+'dashboard/create_captcha?'+Math.random(), success:function(data){ $('.captcha-img').attr('src', data); } }); }); }); ```
I changed Ruhan Kumar's code a little bit and could get the satisfying code: ``` <script> $(function(){ var base_url = '<?php echo base_url(); ?>'; $('.reload-captcha').click(function(event){ event.preventDefault(); $.ajax({ url:base_url+'admin/dashboard/create_captcha', success:function(data){ $('.captcha-img').replaceWith(data); } }); }); }); </script> ```
19,492,165
I want to have a reload button beside my captcha image to reload it with jquery in codeigniter. I searched the net to find a solution for it, but all I found confused me. this is my controller: ``` function create_captcha() { $expiration = time()-300; // Two hour limit $this->db->query("DELETE FROM captcha WHERE captcha_time < ".$expiration); $vals = array( //'word' => 'Random word', 'word_length' => 4, 'img_path' => './uploads/captcha/', 'img_url' => base_url().'uploads/captcha/', 'font_path' => './system/fonts/texb.ttf', 'img_width' => '110', 'img_height' => '30', 'expiration' => '3600' ); $cap = create_captcha($vals); //puts in the db $captchadata = array( 'captcha_id' => '', 'captcha_time' => $cap['time'], 'ip_address' => $this->input->ip_address(), 'word' => $cap['word'] ); $query = $this->db->insert_string('captcha', $captchadata); $this->db->query($query); if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') echo $cap['image']; else return $cap['image']; ``` and this is my view: ``` <div class="captcha-area"> <? echo form_input('captcha', '', 'class="field text captcha"')?> <div id="cap-img"> <? echo $image;?> </div> <a title="reload" class="reload-captcha" href="#"><img src="<? echo base_url(); ?>images/reload.png" /></a> <div class="clear"></div> </div> <script> $(function(){ var base_url = '<?php echo base_url(); ?>'; $('.reload-captcha').click(function(event){ event.preventDefault(); $('.captcha-img').attr('src', base_url+'dashboard/create_captcha?'+Math.random()); }); }); </script> ``` **EDIT:** this is the source code after loading the site ``` <div class="captcha-area"> <input type="text" name="captcha" value="" class="field text captcha"> <div id="cap-img"> <img src="http://example.com/uploads/captcha/1382346264.1026.jpg" width="110" height="30" class="captcha-img" style="border:0;" alt=" "> </div> <a title="reload" class="reload-captcha" href="#"><img src="http://example.com/images/reload.png"></a> <div class="clear"></div> </div> ``` and when I click on the reload button it changes the src attribute to something like: ``` <img src="http://example.com/dashboard/create_captcha?0.8049291325733066" width="110" height="30" class="captcha-img" style="border:0;" alt=" "> ```
2013/10/21
[ "https://Stackoverflow.com/questions/19492165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1269907/" ]
> > **#You may reload img by using ajax and javascript see my code** > > > **#You must create a folder captcha in your CI root folder** > > > **#The folder captcha permission to 777 or 666 mean(read, write for all)** > > > **#Then look like ci/captcha** > > > **#Then look like ci/application** > > > **My html.php view** > > > ``` <html> <head> <script> function postRequest(strURL) { var xmlHttp; if (window.XMLHttpRequest) // Mozilla, Safari, ... { var xmlHttp = new XMLHttpRequest(); } else if (window.ActiveXObject) // IE { var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("your browser does not support AJAX"); return; } xmlHttp.open('POST', strURL, true); xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4 && xmlHttp.status==200) { reload_captcha(xmlHttp.responseText); } } xmlHttp.send(strURL); } function reload_captcha(str) { document.getElementById("captcha-img").innerHTML = str; } function get_captcha() { //<a href="#" onclick="JavaScript:get_captcha()" ></a> document.getElementById("captcha-img").innerHTML = '<img src="<?php echo base_url('asset/img/loader.gif'); ?>" height="35" width="37" />'; var url="<?php echo base_url('index/reload_captcha'); ?>"; postRequest(url); } </script> </head> <body> <label>Human test</label> <input type="text" autocomplete="off" maxlength="5" name="captcha" value="" /> <span id="captcha-img" class="captcha-img"> <?php echo $captcha_img; ?> </span> <a href="#reload" onclick="JavaScript:get_captcha()" ><img class="reload-img" src="<?php echo base_url('asset/img/reload.png'); ?>" alt="reload" /></a> </body> </html> ``` > > **My index.php Controller** > > > ``` <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Index extends CI_Controller { public function __construct() { parent::__construct(); $this->load->database(); $this->load->library('form_validation'); $this->load->helper('date'); } public function index() { $this->form_validation->set_rules('captcha', 'Security','trim|required|xss_clean|callback_check_captcha'); if($this->form_validation->run() == False) { $data['captcha_img'] = $this->get_captcha(); $this->load->view('html',$data); } } private function _generate_string($min, $max) { $pool = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; $pool = str_shuffle($pool); $str = ''; for ($i = 0; $i < 5; $i++) { $str .= substr($pool, mt_rand(0, strlen($pool) -1), 1); } return $str; } public function get_captcha() { $this->load->helper('captcha'); $word = $this->_generate_string(2,5); $vals = array( 'word' => $word, 'img_path' => './captcha/', 'img_url' => base_url().'captcha/', 'img_width' => 120, 'img_height' => 35, 'border' => 0, 'font_path' => './system/fonts/texb.ttf', 'expiration' => 3600 //1 houre ); $cap = create_captcha($vals); $this->session->set_userdata($cap['word']); return $cap['image']; } public function reload_captcha() { $new_captcha = $this->get_captcha(); echo "".$new_captcha; } public function check_cap_tcha() { $session_captcha_code = $this->session->userdata('word'); if($session_captcha_code == $user_captcha_code) { return true; }else{ $this->form_validation->set_message('check_captcha', "Security code does not match !"); return false; } } } ``` > > **And after all it's work well !** > > >
I changed Ruhan Kumar's code a little bit and could get the satisfying code: ``` <script> $(function(){ var base_url = '<?php echo base_url(); ?>'; $('.reload-captcha').click(function(event){ event.preventDefault(); $.ajax({ url:base_url+'admin/dashboard/create_captcha', success:function(data){ $('.captcha-img').replaceWith(data); } }); }); }); </script> ```
143,614
The way google is presenting as of today is totally different and I can no longer get the image pages so you can scroll the images before selecting one you want to see. Now there are individual boxes that click through. The entire appearance makes it no longer usuable.. Is there I can do to revert back to the way it was previously? It shows perfectly on Firefox and nothing has changed there.
2014/08/30
[ "https://apple.stackexchange.com/questions/143614", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/89211/" ]
I suspect it's an example of a new policy from Google, where they're deliberately showing old versions of their search pages if you use an out of date browser. You can find information about this from, for example, this [BBC news report](http://www.bbc.com/news/technology-29012038). It's probably a good idea to update Safari, for security reasons. This is what Google are trying to get you to do. But if you have a good reason to keep using 5.1.1, you can see an up-to-date Google homepage by changing the user agent string. There are instructions for doing this available online, e.g. [here](http://osxdaily.com/2013/01/16/change-user-agent-chrome-safari-firefox/).
First I recommend you should update your Safari app. I just made a comparison using the same web site for Images. My Safari (7.0.6) + Chrome + Firefox show exactly the same. The top row shows the categories you can select (also as images). You can scroll down true the images or select a category.
32,194,958
I have a binary file from which I need to read 32 bit patterns- In the event if the EOF is reached such that its less than 32 bits - I need to error out saying unexpected eof else just break. I tried a lot but I am unable to get the incomplete bytes detecting part working. Can someone provide some pointer how to achieve it ? I did thought of exploring one byte at a time byte[0] and evaluating if its EOF but didnt work. ``` for (;;) { bytes_read = fread(buffer, 4, 1, inFile); if (bytes_read == 1) { // perform the task } else { // detect if its incomplete sequence or EOF and output appropriately } } ``` P.S : Editing fread as per comment -
2015/08/25
[ "https://Stackoverflow.com/questions/32194958", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3902763/" ]
Your code tells `fread` to read one record, containing 4 bytes, from the file. If the record is incomplete, it will return 0 (0 records read, error). If the record is missing (at end of file), it will also return 0 (0 records read, normal situation). You must adjust your code to distinguish these cases, by having `fread` return `4` (bytes) instead. If it's impossible to read 4 bytes at the end of file, you want `fread` to output less than 4. To have this behavior, you should tell fread to read in units of 1 byte: ``` bytes_read = fread(buffer, 1, 4, inFile); ``` Then look at the number: ``` if (bytes_read == 4) { // perform the task } else if (bytes_read > 0) { // bad file format - not a multiple of 4 bytes } else if (bytes_read == 0) { break; // success } else // bytes_read = -1 { // general file error } ```
`fread` doesn't return the number of bytes read, it returns the number of items, whose size is given in the second argument, were read. Since you're asking for it to read 1 item; if it encounters EOF before reading all the bytes of the item, it should return `0`. Although `sizeof(char)` is defined to be `1`, it's not appropriate to use it in a context where you're not actually referring to the size of something. In this case, it's just a count, so you should use `1`. ``` size_t items_read = fread(buffer, sizeof(unsigned long), 1, inFile); if (items_read == 1) { // perform the task } else if (feof(inFile)) { // got EOF before reading the last number } else if (ferror(inFile)) { // got an error } ```
72,621,032
My code: [enter image description here](https://i.stack.imgur.com/FBkHr.png) So the output is giving the very first line of the `results` list. My question is how to cut in each "url" element in one run to get the same result? Assume for loop would do?
2022/06/14
[ "https://Stackoverflow.com/questions/72621032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13813231/" ]
You need to map your proxy. And then iterate it.
Try seleniumwire with uc: [https://pypi.org/project/selenium-wire/#certificates:~:text=driver.wait\_for\_request()%20etc.-,Proxies,-If%20the%20site](https://pypi.org/project/selenium-wire/#certificates:%7E:text=driver.wait_for_request()%20etc.-,Proxies,-If%20the%20site) Worked for me
72,404,598
there are 5 column in 1st data frame . by using this find consecutive 1 from last D\_4 to D\_1, if find 0 in between then break and till that how many ones and that will be output [![1st input data frame](https://i.stack.imgur.com/3I36k.png)](https://i.stack.imgur.com/3I36k.png) [![2nd input data frame](https://i.stack.imgur.com/ApAN7.png)](https://i.stack.imgur.com/ApAN7.png) [![output data frame](https://i.stack.imgur.com/u4enr.png)](https://i.stack.imgur.com/u4enr.png)
2022/05/27
[ "https://Stackoverflow.com/questions/72404598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18553146/" ]
`SignInManager<TUser>.PasswordSignInAsync` Method Attempts to sign in the specified userName and password combination as an asynchronous operation and return `Task<SignInResult>`. for bearer token use `CheckPasswordAsync`. its return a flag indicating whether the given password is valid for the specified user. ``` _userManager.CheckPasswordAsync(user, model.Password) ``` if user has valid creadintial then [generate the token](https://www.c-sharpcorner.com/article/jwt-token-authentication-and-authorizations-in-net-core-6-0-web-api/). ``` if (user != null && await _userManager.CheckPasswordAsync(user, model.Password)) { var userRoles = await _userManager.GetRolesAsync(user); var authClaims = new List<Claim> { new Claim(ClaimTypes.Name, user.UserName), new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()), }; foreach (var userRole in userRoles) { authClaims.Add(new Claim(ClaimTypes.Role, userRole)); } var token = GetToken(authClaims); return Ok(new { token = new JwtSecurityTokenHandler().WriteToken(token), expiration = token.ValidTo }); } ``` Ref: [Link1](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.identity.signinmanager-1.passwordsigninasync?view=aspnetcore-6.0), [Link2](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.identity.signinresult?view=aspnetcore-6.0), [Link3](https://stackoverflow.com/questions/53854051/usermanager-checkpasswordasync-vs-signinmanager-passwordsigninasync), [Link4](https://www.c-sharpcorner.com/article/jwt-token-authentication-and-authorizations-in-net-core-6-0-web-api/)
Depending how you want the client to store the token. If you want to deal with it in the client side you can `Return Ok(result.generatedToken)` but if you want to set it as a cookie I would recommend you to just Return Ok() but before that you set the cookie in the header of the response. You do this in the server ``` // append cookie with token to the http response CookieOptions? cookieOptions = new() { HttpOnly = true, SameSite = SameSiteMode.Strict, Secure = true, Expires = ExpirationDate //it has to be a DateTime }; Response.Cookies.Append("token", token, cookieOptions); ``` the advantage of doing it from the server is that you protect the token from being stolen by XSS injection or other attacks since the token is not accessable from javascript and can only be used in HTTPrequests.
46,527,281
even if I know that inheritance is discouraged and composition should be better I'd like to know how to handle inheritance with mobx state class and call a super class method that is already decorated with `@action.bound`. I have this code example (that can be easily executed in a comfortable [jsfiddle](https://jsfiddle.net/2u21nbpp/1/)): ``` const { observable, action } = mobx; class Store { @observable list = [] @observable num = 0 constructor() { console.log('Store ctor') } @action.bound reset() { this.list.clear() this.num = 0 } } class StorePlus extends Store { @observable num2 = 0 constructor() { super() } @action.bound reset() { super.reset() this.num2 = 0 } } const storePlus = new StorePlus() storePlus.reset() ``` Is is broken due to this error: > > Uncaught RangeError: Maximum call stack size exceeded > > > I understand the problem is in calling `super.reset` where `reset` is a super class method already decorated. But I don't understand internals and I don't know what is the best way to use composition over inheritance avoiding to write some adapter methods to expose parent class observables and actions method. Hope my question is clear!
2017/10/02
[ "https://Stackoverflow.com/questions/46527281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/433685/" ]
I'm not sure why exactly, but the issue is the `action.bound`. If you bind `this` in the constructor and wrap the result in action (like this... `this.reset = action(this.reset.bind(this)`), then it appears to work okay. <https://jsfiddle.net/cr82ktdd/> ``` const { observable, action } = mobx; console.clear() class Store { @observable list = [] @observable num = 0 constructor() { console.log('Store ctor') this.reset = action(this.reset.bind(this)) } reset() { console.log('Store reset') this.list.clear() this.num = 0 } } class StorePlus extends Store { @observable num2 = 0 constructor() { super() this.reset = action(this.reset.bind(this)) } reset() { console.log('StorePlus reset') super.reset() this.num2 = 0 } } const storePlus = new StorePlus() storePlus.reset() ```
The problem is that you can't reassign the action, which has already been bounded JavaScript doesn't support binding several contexts to the same function. Remove **bound** and make a bind separately `const storePlus = new StorePlus() storePlus.reset = storePlus.reset.bind(storePlus) storePlus.reset()`
843,858
I want other computers (they are in local network) go to Virtualbox Localhost. can you explain me what to do or at least give me article link. in Virtualbox i have installed fedora19 and computers system is Windows 7.
2014/11/23
[ "https://superuser.com/questions/843858", "https://superuser.com", "https://superuser.com/users/392344/" ]
Guest in bridged mode will use same IP subnet as the host, other computers can access it directly. If it is in NAT mode, you can use port forwarding so when other computers access to specific port of the host, the traffic will forward to another port of the guest. [Here](https://www.virtualbox.org/manual/ch06.html#natforward) is the Virtualbox documentation, but I think the best way to learn it is just try a few settings to experiment it.
You probably need to change the network adapter settings to bridged mode. Right now, it's probably set to NAT'ed mode.
924,794
We have a situation where a number of Reps use there iPhones as hot spots. Not a problem on it's own. However, to prevent over use of data we would like them to Set the Wifi point as Metered when using the iPhone. Again, sounds simple - right? Enter Microsoft they have locked down the ability to toggle Metered connections to Admin accounts so a Standard user cannot not. WTF! Not too much of an issue I can script this - Or so I thought! What I'm looking to do is detect when an iPhone is in use as a hot spot and change a registry value to make it Metered. I came up with this: ``` $wlan = Netsh.exe wlan show interfaces $regpath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost" $keyname = "WiFi" $regVal = "2" if ($wlan_.SSID -like '*iPhone*') {Set-ItemProperty -Path $regpath -Name $keyname -Value $regval WRITE-HOST "Set Reg Key Value" } else {Set-ItemProperty -Path $regpath -Name $keyname -Value "1" Write-Host "No change Made" } ``` All look generally OK and to some degree it does work. However, I can't sem to pass the right information for the IF statement ``` $wlan_.SSID -like '*iPhone*' ``` Always ends up as False. I've Tried SSID, NAME, Profile - all information returned by the Netsh command, but somehow the commands retuen isn't including the information. If you run the Variable you can see the information: ``` $wlan There is 1 interface on the system: Name : Wi-Fi Description : Intel(R) Dual Band Wireless-AC 7265 GUID : ############################ Physical address : ################ State : connected SSID : User iPhone BSSID : ########################### Network type : Infrastructure Radio type : 802.11n Authentication : WPA2-Personal Cipher : CCMP Connection mode : Profile Channel : 1 Receive rate (Mbps) : 144.4 Transmit rate (Mbps) : 144.4 Signal : 99% Profile : User iPhone Hosted network status : Not available ``` I'm assuming I'm missing something terribly obvious but I thought would return the information stored in there? ``` $wlan_.xxxxx ``` But it doesn't ``` PS C:\WINDOWS\system32> $wlan_.SSID -like '*iPnone' False PS C:\WINDOWS\system32> $wlan_.name PS C:\WINDOWS\system32> $wlan_.name -like '*iPnone' False PS C:\WINDOWS\system32> $wlan_.name -like 'Wi-Fi' False ``` I've tried other bits of information and non returned a true result, even when I know it was true - so I'm assuming it's parsing the information across. Any Ideas are very much appropriated. To answer some of the obvious things - all our Users use iPhone's and all are named as "User iPhone" It's not intended as a catch all, but a catch most.
2018/08/03
[ "https://serverfault.com/questions/924794", "https://serverfault.com", "https://serverfault.com/users/479153/" ]
Your EC2 instances just don't have enough permissions to register with ECS cluster: > > Important > > > If you do not launch your container instance with the proper IAM > permissions, your Amazon ECS agent cannot connect to your cluster. > > > Check IAM role that you've assigned to your EC2 instances. It should include appropriate permissions, for example: ``` { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ecs:DeregisterContainerInstance", "ecs:RegisterContainerInstance", "ecr:GetAuthorizationToken" ], "Resource": "*" } ] } ``` Or you can use AWS-managed policy named `AmazonEC2ContainerServiceforEC2Role` and assigned it to your EC2 role. More information is avalable at <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/instance_IAM_role.html>.
this one is also necessary to make it work; Amazon ECS needs permissions to register and deregister container instances with your load balancer when tasks are created and stopped ``` { "Version": "2008-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Principal": { "Service": "ecs.amazonaws.com" }, "Action": "sts:AssumeRole" } ] } ``` <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/check-service-role.html>
924,794
We have a situation where a number of Reps use there iPhones as hot spots. Not a problem on it's own. However, to prevent over use of data we would like them to Set the Wifi point as Metered when using the iPhone. Again, sounds simple - right? Enter Microsoft they have locked down the ability to toggle Metered connections to Admin accounts so a Standard user cannot not. WTF! Not too much of an issue I can script this - Or so I thought! What I'm looking to do is detect when an iPhone is in use as a hot spot and change a registry value to make it Metered. I came up with this: ``` $wlan = Netsh.exe wlan show interfaces $regpath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost" $keyname = "WiFi" $regVal = "2" if ($wlan_.SSID -like '*iPhone*') {Set-ItemProperty -Path $regpath -Name $keyname -Value $regval WRITE-HOST "Set Reg Key Value" } else {Set-ItemProperty -Path $regpath -Name $keyname -Value "1" Write-Host "No change Made" } ``` All look generally OK and to some degree it does work. However, I can't sem to pass the right information for the IF statement ``` $wlan_.SSID -like '*iPhone*' ``` Always ends up as False. I've Tried SSID, NAME, Profile - all information returned by the Netsh command, but somehow the commands retuen isn't including the information. If you run the Variable you can see the information: ``` $wlan There is 1 interface on the system: Name : Wi-Fi Description : Intel(R) Dual Band Wireless-AC 7265 GUID : ############################ Physical address : ################ State : connected SSID : User iPhone BSSID : ########################### Network type : Infrastructure Radio type : 802.11n Authentication : WPA2-Personal Cipher : CCMP Connection mode : Profile Channel : 1 Receive rate (Mbps) : 144.4 Transmit rate (Mbps) : 144.4 Signal : 99% Profile : User iPhone Hosted network status : Not available ``` I'm assuming I'm missing something terribly obvious but I thought would return the information stored in there? ``` $wlan_.xxxxx ``` But it doesn't ``` PS C:\WINDOWS\system32> $wlan_.SSID -like '*iPnone' False PS C:\WINDOWS\system32> $wlan_.name PS C:\WINDOWS\system32> $wlan_.name -like '*iPnone' False PS C:\WINDOWS\system32> $wlan_.name -like 'Wi-Fi' False ``` I've tried other bits of information and non returned a true result, even when I know it was true - so I'm assuming it's parsing the information across. Any Ideas are very much appropriated. To answer some of the obvious things - all our Users use iPhone's and all are named as "User iPhone" It's not intended as a catch all, but a catch most.
2018/08/03
[ "https://serverfault.com/questions/924794", "https://serverfault.com", "https://serverfault.com/users/479153/" ]
Your EC2 instances just don't have enough permissions to register with ECS cluster: > > Important > > > If you do not launch your container instance with the proper IAM > permissions, your Amazon ECS agent cannot connect to your cluster. > > > Check IAM role that you've assigned to your EC2 instances. It should include appropriate permissions, for example: ``` { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ecs:DeregisterContainerInstance", "ecs:RegisterContainerInstance", "ecr:GetAuthorizationToken" ], "Resource": "*" } ] } ``` Or you can use AWS-managed policy named `AmazonEC2ContainerServiceforEC2Role` and assigned it to your EC2 role. More information is avalable at <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/instance_IAM_role.html>.
We had an error in our user data script. I found the error in EC2 - my instance -> Monitor and troubleshoot -> Get system log. Our bash script in the user data had -ex flags on i.e. `#!/bin/bash -ex`, which tells the script to exit immediately as a failure on any errors. The EC2 task would finish starting and look healthy to the Auto Scaling Group, but the cloud-init (EC2 initialization) had terminated and didn't complete, leaving the instance unattached to the ECS cluster. Once I fixed the error in our user data script and launched a new instance, it was able o attach to the ECS cluster as expected.
16,712,869
``` function get_result_professions($key_word) { $sql = "SELECT users.name FROM users inner join users_has_professions on users_has_professions.users_id = users.id inner join professions on users_has_professions.professions_id = professions.id where professions.key_word = ? "; return $this->db->get()->query($sql, $key_word); } ``` When I execute this code I receive the following error: ``` A Database Error Occurred Error Number: 1096 No tables used SELECT * Filename: /var/www/expertt/models/search_model.php Line Number: 31 ``` How can I solve this problem? Thanks in advance.
2013/05/23
[ "https://Stackoverflow.com/questions/16712869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2371512/" ]
Hangouts does not currently have a public API. That said, messages delivered to the Google Talk XMPP server (talk.google.com:5222) are still being delivered to users via Hangouts. This support is only extended to one-on-one conversations, so the notification can't be delivered to a group of users. The messages will need to be supplied through an authenticated Google account in order to be delivered.
I send alarms and other notifications with a python script (failures on database server, partitions without free space, etc), using hangouts. It's easy. Look at <http://www.administracion-linux.com/2014/07/enviar-mensajes-por-hangout-desde.html> to send hangouts.
16,712,869
``` function get_result_professions($key_word) { $sql = "SELECT users.name FROM users inner join users_has_professions on users_has_professions.users_id = users.id inner join professions on users_has_professions.professions_id = professions.id where professions.key_word = ? "; return $this->db->get()->query($sql, $key_word); } ``` When I execute this code I receive the following error: ``` A Database Error Occurred Error Number: 1096 No tables used SELECT * Filename: /var/www/expertt/models/search_model.php Line Number: 31 ``` How can I solve this problem? Thanks in advance.
2013/05/23
[ "https://Stackoverflow.com/questions/16712869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2371512/" ]
Hangouts does not currently have a public API. That said, messages delivered to the Google Talk XMPP server (talk.google.com:5222) are still being delivered to users via Hangouts. This support is only extended to one-on-one conversations, so the notification can't be delivered to a group of users. The messages will need to be supplied through an authenticated Google account in order to be delivered.
There is pre-alpha library for sending hangouts messages on python: <https://pypi.python.org/pypi/hangups/0.1> The API have been reverse engineered and is not published (as someone posted in comments). Thus it might change a Google's will. Also, messages sent using XMPP ceased to be delivered to Hangouts users. I guess this is another cut (of the thousand scheduled).
16,712,869
``` function get_result_professions($key_word) { $sql = "SELECT users.name FROM users inner join users_has_professions on users_has_professions.users_id = users.id inner join professions on users_has_professions.professions_id = professions.id where professions.key_word = ? "; return $this->db->get()->query($sql, $key_word); } ``` When I execute this code I receive the following error: ``` A Database Error Occurred Error Number: 1096 No tables used SELECT * Filename: /var/www/expertt/models/search_model.php Line Number: 31 ``` How can I solve this problem? Thanks in advance.
2013/05/23
[ "https://Stackoverflow.com/questions/16712869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2371512/" ]
There is pre-alpha library for sending hangouts messages on python: <https://pypi.python.org/pypi/hangups/0.1> The API have been reverse engineered and is not published (as someone posted in comments). Thus it might change a Google's will. Also, messages sent using XMPP ceased to be delivered to Hangouts users. I guess this is another cut (of the thousand scheduled).
I send alarms and other notifications with a python script (failures on database server, partitions without free space, etc), using hangouts. It's easy. Look at <http://www.administracion-linux.com/2014/07/enviar-mensajes-por-hangout-desde.html> to send hangouts.
43,207,563
I'm looking to do something like this non-working code in my Django template: ``` {% if os.environ.DJANGO_SETTINGS_MODULE == "settings.staging" %} ``` Is something like this possible? My workaround is creating a context processor to make the variable available across all templates, but wanted to know if there is a more direct way to achieve the same result.
2017/04/04
[ "https://Stackoverflow.com/questions/43207563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2532070/" ]
Use `context_processor`, do as below and you should be able to access `os.environ['DJANGO_SETTINGS_MODULE']` as `SETTING_TYPE` in templates. Example you can use `{% if SETTING_TYPE == "settings.staging" %}` > > project/context\_processors.py > > > ``` import os def export_vars(request): data = {} data['SETTING_TYPE'] = os.environ['DJANGO_SETTINGS_MODULE'] return data ``` > > project/settings.py (your actual settings file) > > > ``` TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ ... 'project.context_processors.export_vars', ... ] } } ] ```
Extending on [@vinay kumar](https://stackoverflow.com/users/3951511/vinay-kumar)'s comment, you can create a custom template filter in the following way: > > application/template\_tags\_folder/template\_tags\_file.py > > > ``` from django.template.defaulttags import register import os @register.filter def env(key): return os.environ.get(key, None) ``` And then in your template you can access it this way: > > template.html > > > ``` {% if 'DJANGO_SETTINGS_MODULE'|env == 'app_name.staging_settings' %} ``` Finally I leave a [django docs reference](https://docs.djangoproject.com/en/3.1/howto/custom-template-tags/) and a [stackoverflow reference](https://stackoverflow.com/questions/6451304/django-simple-custom-template-tag-example) for creating custom template tags and filters in django.
45,306,469
So I found this effect and I'm trying to modify it to be loaded inside a DIV `myeffect`, for example: ``` <html> <head></head> <body> <div class="myeffect"></div> </body> </html> ``` I tried changing some variables but I'm not a JavaScript expert and I can't get it to work inside a DIC. The effect covers the whole screen from top to bottom. The code is on Codepen and can be found here: <https://codepen.io/emilykarp/pen/bVqxRm> Help is welcome.
2017/07/25
[ "https://Stackoverflow.com/questions/45306469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Hope this helps ```js var speeds = []; var count = 1; var colors = ['#bf1e2e', '#ee4037', '#dc5323', '#e1861b', '#e1921e', '#f7ac40', '#f7e930', '#d1da22', '#8bc43f', '#38b349', '#008d42', '#006738', '#29b473', '#00a69c', '#26a9e1', '#1a75bb', '#2a388f', '#262161', '#652d90', '#8e2792', '#9e1f64', '#d91c5c', '#ed297b', '#d91c5c', '#db1e5e', '#bf1e2e', '#f6931e', '#f05a28', '#f6931e', '#fbaf41'] var width = parseInt($('html').css('width'), 10); var random = function(mult, add) { return Math.floor((Math.random()*mult) + add); }; var drop = function(n, height, color) { $('.myeffect').append('<div class="drop" style="left:'+ n*15+'px;height:'+ height+'vh;background-color:'+ color+';"></div>'); }; var createDrops = function(space) { for (var i=speeds.length; i < space/10; i++) { speeds.push(random(3000, 2000)); drop(i, random(70, 30), colors[count]); if (count < colors.length-1) { count++; } else { count = 0; } } }; var animateDrops = function(startingN) { for (var i=startingN; i<speeds.length; i++) { $('.drop:nth-child('+i+')').slideDown(speeds[i]); } }; createDrops(width); animateDrops(0); ``` ```css .drop { width: 16px; height: 200px; display: none; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; position: absolute; top: 0; -webkit-box-shadow: inset -4px -8px 16px -6px rgba(0,0,0,0.47); -moz-box-shadow: inset -4px -8px 16px -6px rgba(0,0,0,0.47); box-shadow: inset -4px -8px 16px -6px rgba(0,0,0,0.47); } ``` ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="myeffect" ></div> ```
The divs it uses are all dynamically generated and appended to the body using this method. ``` var drop = function(n, height, color) { $('body').append('<div class="drop" style="left:'+ n*15+'px;height:'+ height+'vh;background-color:'+ color+';"></div>') )}; ``` So, you would just update the script to append to your element instead of the body element. ``` var drop = function(n, height, color) { $('.myeffect').append('<div class="drop" style="left:'+ n*15+'px;height:'+ height+'vh;background-color:'+ color+';"></div>') )}; ```
45,306,469
So I found this effect and I'm trying to modify it to be loaded inside a DIV `myeffect`, for example: ``` <html> <head></head> <body> <div class="myeffect"></div> </body> </html> ``` I tried changing some variables but I'm not a JavaScript expert and I can't get it to work inside a DIC. The effect covers the whole screen from top to bottom. The code is on Codepen and can be found here: <https://codepen.io/emilykarp/pen/bVqxRm> Help is welcome.
2017/07/25
[ "https://Stackoverflow.com/questions/45306469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Hope this helps ```js var speeds = []; var count = 1; var colors = ['#bf1e2e', '#ee4037', '#dc5323', '#e1861b', '#e1921e', '#f7ac40', '#f7e930', '#d1da22', '#8bc43f', '#38b349', '#008d42', '#006738', '#29b473', '#00a69c', '#26a9e1', '#1a75bb', '#2a388f', '#262161', '#652d90', '#8e2792', '#9e1f64', '#d91c5c', '#ed297b', '#d91c5c', '#db1e5e', '#bf1e2e', '#f6931e', '#f05a28', '#f6931e', '#fbaf41'] var width = parseInt($('html').css('width'), 10); var random = function(mult, add) { return Math.floor((Math.random()*mult) + add); }; var drop = function(n, height, color) { $('.myeffect').append('<div class="drop" style="left:'+ n*15+'px;height:'+ height+'vh;background-color:'+ color+';"></div>'); }; var createDrops = function(space) { for (var i=speeds.length; i < space/10; i++) { speeds.push(random(3000, 2000)); drop(i, random(70, 30), colors[count]); if (count < colors.length-1) { count++; } else { count = 0; } } }; var animateDrops = function(startingN) { for (var i=startingN; i<speeds.length; i++) { $('.drop:nth-child('+i+')').slideDown(speeds[i]); } }; createDrops(width); animateDrops(0); ``` ```css .drop { width: 16px; height: 200px; display: none; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; position: absolute; top: 0; -webkit-box-shadow: inset -4px -8px 16px -6px rgba(0,0,0,0.47); -moz-box-shadow: inset -4px -8px 16px -6px rgba(0,0,0,0.47); box-shadow: inset -4px -8px 16px -6px rgba(0,0,0,0.47); } ``` ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="myeffect" ></div> ```
This actually works for me now. ``` var speeds = []; var count = 1; var colors = ['#bf1e2e', '#ee4037', '#dc5323', '#e1861b', '#e1921e', '#f7ac40', '#f7e930', '#d1da22', '#8bc43f', '#38b349', '#008d42', '#006738', '#29b473', '#00a69c', '#26a9e1', '#1a75bb', '#2a388f', '#262161', '#652d90', '#8e2792', '#9e1f64', '#d91c5c', '#ed297b', '#d91c5c', '#db1e5e', '#bf1e2e', '#f6931e', '#f05a28', '#f6931e', '#fbaf41'] var width = parseInt($('.myeffect').css('width'), 10); var random = function(mult, add) { return Math.floor((Math.random()*mult) + add); }; var drop = function(n, height, color) { $('.myeffect').append('<div class="drop" style="left:'+ n*60+'px;height:'+ height+'vh;background-color:'+ color+';"></div>'); }; var createDrops = function(space) { for (var i=speeds.length; i < space/60 + 2; i++) { speeds.push(random(3000, 2000)); drop(i, random(35, 20), colors[count]); if (count < colors.length-1) { count++; } else { count = 0; } } }; var animateDrops = function(startingN) { for (var i=startingN; i<speeds.length; i++) { $('.drop:nth-child('+i+')').slideDown(speeds[i]); } }; createDrops(width); animateDrops(0); ```
45,306,469
So I found this effect and I'm trying to modify it to be loaded inside a DIV `myeffect`, for example: ``` <html> <head></head> <body> <div class="myeffect"></div> </body> </html> ``` I tried changing some variables but I'm not a JavaScript expert and I can't get it to work inside a DIC. The effect covers the whole screen from top to bottom. The code is on Codepen and can be found here: <https://codepen.io/emilykarp/pen/bVqxRm> Help is welcome.
2017/07/25
[ "https://Stackoverflow.com/questions/45306469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
From what I could see you were missing 3 things in your codepen. 1. you were applying the change to 'html' not '.myeffect' In your js: ``` `var width = parseInt($('.myeffect').css('width'), 10);` ``` 2. you need to set a width to your '.myeffect' In your css: `.myeffect { width: 100px; }` 3. there was no markup in the 'HTML' section of codepen, outside of the html tag that codepen probably provides by default. In your html: ``` <html> <head></head> <body> <div class="myeffect"></div> </body> </html> ``` My codepen: <https://codepen.io/anon/pen/oegwZa>
The divs it uses are all dynamically generated and appended to the body using this method. ``` var drop = function(n, height, color) { $('body').append('<div class="drop" style="left:'+ n*15+'px;height:'+ height+'vh;background-color:'+ color+';"></div>') )}; ``` So, you would just update the script to append to your element instead of the body element. ``` var drop = function(n, height, color) { $('.myeffect').append('<div class="drop" style="left:'+ n*15+'px;height:'+ height+'vh;background-color:'+ color+';"></div>') )}; ```
45,306,469
So I found this effect and I'm trying to modify it to be loaded inside a DIV `myeffect`, for example: ``` <html> <head></head> <body> <div class="myeffect"></div> </body> </html> ``` I tried changing some variables but I'm not a JavaScript expert and I can't get it to work inside a DIC. The effect covers the whole screen from top to bottom. The code is on Codepen and can be found here: <https://codepen.io/emilykarp/pen/bVqxRm> Help is welcome.
2017/07/25
[ "https://Stackoverflow.com/questions/45306469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
From what I could see you were missing 3 things in your codepen. 1. you were applying the change to 'html' not '.myeffect' In your js: ``` `var width = parseInt($('.myeffect').css('width'), 10);` ``` 2. you need to set a width to your '.myeffect' In your css: `.myeffect { width: 100px; }` 3. there was no markup in the 'HTML' section of codepen, outside of the html tag that codepen probably provides by default. In your html: ``` <html> <head></head> <body> <div class="myeffect"></div> </body> </html> ``` My codepen: <https://codepen.io/anon/pen/oegwZa>
This actually works for me now. ``` var speeds = []; var count = 1; var colors = ['#bf1e2e', '#ee4037', '#dc5323', '#e1861b', '#e1921e', '#f7ac40', '#f7e930', '#d1da22', '#8bc43f', '#38b349', '#008d42', '#006738', '#29b473', '#00a69c', '#26a9e1', '#1a75bb', '#2a388f', '#262161', '#652d90', '#8e2792', '#9e1f64', '#d91c5c', '#ed297b', '#d91c5c', '#db1e5e', '#bf1e2e', '#f6931e', '#f05a28', '#f6931e', '#fbaf41'] var width = parseInt($('.myeffect').css('width'), 10); var random = function(mult, add) { return Math.floor((Math.random()*mult) + add); }; var drop = function(n, height, color) { $('.myeffect').append('<div class="drop" style="left:'+ n*60+'px;height:'+ height+'vh;background-color:'+ color+';"></div>'); }; var createDrops = function(space) { for (var i=speeds.length; i < space/60 + 2; i++) { speeds.push(random(3000, 2000)); drop(i, random(35, 20), colors[count]); if (count < colors.length-1) { count++; } else { count = 0; } } }; var animateDrops = function(startingN) { for (var i=startingN; i<speeds.length; i++) { $('.drop:nth-child('+i+')').slideDown(speeds[i]); } }; createDrops(width); animateDrops(0); ```
56,239,093
I have some flow like below in a pipeline. ``` stage('Build') { build job: 'Build' } stage('Run') { build job: 'Run', parameters: [string(name: 'build_version', value: <to get from Build job>)] } ``` I am running a python script inside Build job as execute batch script. ``` ```python build.py``` ``` "build.py" will have a variable "build\_version". I want to pass it to jenkins Job "Build" and inturn to the pipeline and pass the same to "Run" job from pipeline. How can I do that ?
2019/05/21
[ "https://Stackoverflow.com/questions/56239093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4744901/" ]
`:onchange` is not the correct syntax to listen for a change event in vue, you also don't need to pass this.selectedValue into the method as it will be available in your data (you don't have access to `this` in a template). Try the following: Change `:onchange` to be: ``` @change="getStudents" ``` Update your `getStudents` method to: ``` getStudents() { const postTutorClassData = new FormData(); postTutorClassData.append('docent', this.teachername); postTutorClassData.append('apikey', this.apikey); postTutorClassData.append('tutorgroep', this.selectedValue) // remove event and use selected value axios.post(this.URL_TUTORKLAS, postTutorClassData).then(response => { this.docenten = response.data.docent; this.leerlingen = response.data.leerlingen; // this.selectedValue = 'null'; // Changing this to be null will re-trigger the change event, causing your infinite loop }).catch(function (error) { console.log(error); }); }, ```
use @change instead of :onchange
131,948
I am a new (3 months) software developer in a smallish software company (10 people). I've been given a new project which has complex and poorly documented requirements, and I've been asked to speak to my boss (who is a company director) before I begin work so he can show me what to do. I did contact him, asking him to help me, and he said he would but the appointed time passed and I heard nothing. We are spread over three sites and the promised monthly company meeting at the head office has only happened once: in January. We may get one in April, if we are lucky. I work at a site with only 3 people including me: we are all new starters and one guy is the project manager. We have a lot of complex projects for customers in very varying different areas ranging from manufacturing and distribution to service industries. The developers also have to provide support (helpdesk) for the applications and we are currently very busy, recruiting for 1-2 members of staff as we are struggling with the support and taking on the new jobs. In my previous job I worked for 3.5 years for a disorganised company with a boss who was often unavailable for days and who did things in a chaotic manner with no structure whatsoever. I left because I got so frustrated by the environment there, starting in my new workplace in December 2018. I am in my mid 40s and have worked in IT for 15 years, 5 of those in programming. The issue is that my background is in desktop applications, and in this new job I have had to learn web development (CSS, ASP, HTML, Razor views etc etc etc). I have found this surprisingly challenging and despite my educational background (PhD) I've been quite slow in comparison to the experienced developers. My personal life is chaotic as my teenage son has autism/ADHD, I have depression, my teenage daughter has anxiety/depression and my wife has unspecified/undiagnosed mental health issues. She has mentioned feeling suicidal to me several times and gets no real help. The environment at home is physically and mentally chaotic, with frequent crises and lots of extreme stress. I sent this email to my boss this morning, after trying twice unsuccessfully to phone him. I CC'd four other people: three company directors and the project manager in my office. The purpose of CC'ing them was because previously I have complained to the boss about lack of communication (no company meeting as promised) and what I got was a frustrated verbal reply about them being busy. I wanted to make sure something actually gets done about these issues. > > Hi X > > > I can't log in to Visual Studio again, so I can't do my job. The same situation existed yesterday. I struggled for maybe an hour > myself trying to work out the problem and when I contacted you, you > were able to say that it is due to the payment problem which will > hopefully be resolved today. It hasn't, which I find quite worrying. > I am filling in the time watching tutorials on CSS and reading the > spec/documents for \_\_\_\_\_\_\_\_\_\_\_. > > > I was asked to look at \_\_\_\_\_\_\_\_\_\_\_ > and the plan that I was given was that you would get back to me, but > that's not happened. In fact there has been more than one occasion > when you said you would get back to me and you have not been able to - > the time just goes by without any contact. I guess due to the volume > of support that you are all very very busy up at (head office). You > have my sympathy and its great that we are recruiting more people. I > am under quite a lot of stress in my personal life at the moment and > it makes me very anxious when I work in an unstructured environment > with poor communication. Its also frustrating that I want to be > productive and help you out by completing some of these tasks, but I > can't. > > > Kind regards, > Phil > > > He replied with: > > Hi Phil, > > > The problem with your Visual Studio account was fixed yesterday, you should have received an email which I have now > resent. If you still haven't received it please let me know. I will be > in the (your) office tomorrow morning, see you then. > > > Regards, > X > > > He is not a cheerful person and I am anticipating a bit of a backlash when we see him tomorrow. My question is this: **was I wrong in copying in the other directors in the email?** Maybe I should have sent it directly to him first. **Edit:** I spoke to the boss on the phone today and apologised for sending the email, I said that I overreacted. He said that I did and that we need to have a conversation in person. He also made it clear that I am not being fired. Edit: The boss agreed with me that what I wrote was unprofessional and that it was a mistake to involve other people, particularly a non-director. He said it looked like I was trying to 'throw him under a bus'. I said it wasn't my intention to challenge his authority and that I let personal stress (without going into detail) cloud my judgement. He apologised to me for the lack of communication but said he is overworked. In future he said if I need to rant, rant to HIM and don't involve others - except in the rare case when I can't get the right answer out of him (which is unlikely to ever happen). He even said I can discuss personal stuff with him if I need a listening ear. It looks like the boss is a LOT nicer man than I thought. So it is a strong unofficial reprimand. I am embarrassed by my lack of professionalism but the only thing I can do moving forward is to ensure I act professionally in future and this will just be forgotten as a 'blip'.
2019/03/19
[ "https://workplace.stackexchange.com/questions/131948", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/101531/" ]
> > was I wrong in copying in the other directors in the email? > > > **yes**.. I understand that you were likely frustrated but CC-ing others in to what is basically a rant at your boss is unwise. It absolutely comes across as you wanting to air your grievance and annoyance with him in front of others and as an attempt to "shame" him in the process. Giving your relatively new boss a public "Reason you suck" speech is not only unprofessional but can be rather career limiting! I'd suggest apologizing to your boss next time you speak to him - explain that you were just a frustrated that day and you let it get the better of you.
It's so easy to parse the world in terms of justice—I have done so many times, myself. And if we are parsing the world that way, when someone does something that we perceive affects us negatively, it feels like an injustice. Suddenly a part of our brain says we have the high moral ground. Suddenly we feel like actions that expose, criticize, and put a very fine point on the issue are helpful and reasonable. Unfortunately, most of the time we have not actually suffered a truly serious injustice. In the case of your employment, you are being paid to be valuable to the company. If things outside your control truly caused you to be unable to render that value, then you are blameless, so long as you communicated about it and asked for help. If you've done your job of doing all that you can to do your job, and you still can't do your job, then effectively, the company is paying you to sit around not doing your job, which is within its rights. To start changing this way of thinking, I suggest that you read the book [*Never Split the Difference: Negotiating As If Your Life Depended On It*](https://rads.stackoverflow.com/amzn/click/com/B014DUR7L2). Especially pay attention to the part of his story where he worked in a suicide hotline call center, and make a mental note to yourself: *all people* need you to treat them as if they are at-risk, and need your soft skills more than your brutal, hard, sharp logic. If logic is the job at hand, it still has to come after your attention to the people. In the case of your boss, if you really couldn't do your job, it was time to just message him—what you had done, how you were stuck, and how you were attempting to proceed. If you see a pattern of not responding, then it is up to you to address it with the person who isn't responding. And before you ever escalate again, you need to do a last-ditch communication (just like in the book) along the lines of "have you decided to not answer?" Perhaps much better in this case, "should I try to solve this problem on my own?" Make it a question where "no" is the answer you want. You want him to answer, you want his help. As other answers have already said, please consider that you almost certainly need more emotional support. Do you have a big and strong enough support network? You are being pulled apart at home. You need people to talk to and share your problems and get advice and sympathy. Find a support group, or friends, or a therapist, or use your company's Employee Assistance Program to call someone, or go to a church and ask to talk to someone. Do *something*. When we feel like we're at the end of our rope, all of our random life circumstances can start to take on the sense of a life-and-death situation, even when they are nowhere near that. This puts us at risk of acting ineffectively or maladaptively, either of which will only hurt us more and push us closer to the end of our rope. You've got to take this seriously. When you communicate with your boss, or anyone at your work, try to speak in these ways: * "X came to my attention and I'm worried that Y might happen. Do you think it's worth investigating further?" (NOT "if someone doesn't do something about Y immediately the company will burn down tomorrow.") * "I feel X about this situation that's happened a few times. My attempts to solve it so far have consisted of Y & Z, but they haven't appeared to work yet. Do you have any suggestions about how to proceed? This is affecting my work." * "It seems like you X (or it seems like you Y)", and try to reflect back something that the person will really connect with. For your boss, it could be something like "it seems like you are really busy over there. Things must be crazy. Is there some way that I can get help with Z without distracting you from your important work?" * Always ask "how ..." or "what ..." and don't start with who, when, where, and most especially NOT *why*. "How would you like me to proceed?" "What could I do to move forward?" "What do you think might be stopping this from working?" "Do you have ideas on how to solve this?" It may seem unnatural, or unpleasant, but it is almost a guarantee that if you learn to start empathizing with people, making soft observations (e.g., "it seems like you *feeling*" instead of "you always do *negative interpretation*"), learning to synchronize with people, and so on, as I have briefly outlined, you will have far more success in your job and in life as well. How do I know? Yeah, experience is the best teacher. The more I learn to be soft and not pushy, intense, accusatory, and so on, the better results I get in life.
131,948
I am a new (3 months) software developer in a smallish software company (10 people). I've been given a new project which has complex and poorly documented requirements, and I've been asked to speak to my boss (who is a company director) before I begin work so he can show me what to do. I did contact him, asking him to help me, and he said he would but the appointed time passed and I heard nothing. We are spread over three sites and the promised monthly company meeting at the head office has only happened once: in January. We may get one in April, if we are lucky. I work at a site with only 3 people including me: we are all new starters and one guy is the project manager. We have a lot of complex projects for customers in very varying different areas ranging from manufacturing and distribution to service industries. The developers also have to provide support (helpdesk) for the applications and we are currently very busy, recruiting for 1-2 members of staff as we are struggling with the support and taking on the new jobs. In my previous job I worked for 3.5 years for a disorganised company with a boss who was often unavailable for days and who did things in a chaotic manner with no structure whatsoever. I left because I got so frustrated by the environment there, starting in my new workplace in December 2018. I am in my mid 40s and have worked in IT for 15 years, 5 of those in programming. The issue is that my background is in desktop applications, and in this new job I have had to learn web development (CSS, ASP, HTML, Razor views etc etc etc). I have found this surprisingly challenging and despite my educational background (PhD) I've been quite slow in comparison to the experienced developers. My personal life is chaotic as my teenage son has autism/ADHD, I have depression, my teenage daughter has anxiety/depression and my wife has unspecified/undiagnosed mental health issues. She has mentioned feeling suicidal to me several times and gets no real help. The environment at home is physically and mentally chaotic, with frequent crises and lots of extreme stress. I sent this email to my boss this morning, after trying twice unsuccessfully to phone him. I CC'd four other people: three company directors and the project manager in my office. The purpose of CC'ing them was because previously I have complained to the boss about lack of communication (no company meeting as promised) and what I got was a frustrated verbal reply about them being busy. I wanted to make sure something actually gets done about these issues. > > Hi X > > > I can't log in to Visual Studio again, so I can't do my job. The same situation existed yesterday. I struggled for maybe an hour > myself trying to work out the problem and when I contacted you, you > were able to say that it is due to the payment problem which will > hopefully be resolved today. It hasn't, which I find quite worrying. > I am filling in the time watching tutorials on CSS and reading the > spec/documents for \_\_\_\_\_\_\_\_\_\_\_. > > > I was asked to look at \_\_\_\_\_\_\_\_\_\_\_ > and the plan that I was given was that you would get back to me, but > that's not happened. In fact there has been more than one occasion > when you said you would get back to me and you have not been able to - > the time just goes by without any contact. I guess due to the volume > of support that you are all very very busy up at (head office). You > have my sympathy and its great that we are recruiting more people. I > am under quite a lot of stress in my personal life at the moment and > it makes me very anxious when I work in an unstructured environment > with poor communication. Its also frustrating that I want to be > productive and help you out by completing some of these tasks, but I > can't. > > > Kind regards, > Phil > > > He replied with: > > Hi Phil, > > > The problem with your Visual Studio account was fixed yesterday, you should have received an email which I have now > resent. If you still haven't received it please let me know. I will be > in the (your) office tomorrow morning, see you then. > > > Regards, > X > > > He is not a cheerful person and I am anticipating a bit of a backlash when we see him tomorrow. My question is this: **was I wrong in copying in the other directors in the email?** Maybe I should have sent it directly to him first. **Edit:** I spoke to the boss on the phone today and apologised for sending the email, I said that I overreacted. He said that I did and that we need to have a conversation in person. He also made it clear that I am not being fired. Edit: The boss agreed with me that what I wrote was unprofessional and that it was a mistake to involve other people, particularly a non-director. He said it looked like I was trying to 'throw him under a bus'. I said it wasn't my intention to challenge his authority and that I let personal stress (without going into detail) cloud my judgement. He apologised to me for the lack of communication but said he is overworked. In future he said if I need to rant, rant to HIM and don't involve others - except in the rare case when I can't get the right answer out of him (which is unlikely to ever happen). He even said I can discuss personal stuff with him if I need a listening ear. It looks like the boss is a LOT nicer man than I thought. So it is a strong unofficial reprimand. I am embarrassed by my lack of professionalism but the only thing I can do moving forward is to ensure I act professionally in future and this will just be forgotten as a 'blip'.
2019/03/19
[ "https://workplace.stackexchange.com/questions/131948", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/101531/" ]
It is not the best thing to do (actually, it was quite bad), but it is not a career-ending mistake provided you learn from this mistake and not make it a habit. In these kinds of situations (i.e. something not working), you should: * ask verbally (your colleagues or your boss) to whom you should report the problem in order to get support; * keep in contact with the support person until the problem is solved; * if the contact person does not want to help, notify your boss; * if your boss does not want to help, notify directors. **NOTE:** things take time, there might be many things in need to be fixed at the same time etc. **Do not assume** that if your problem was not fixed in XX time, then somebody does not want to help. Actually, *"does not want to help"* usually means that the person tells you something along the meaning of: "Go away, I will not help you." --- > > My question is this: **was I wrong in copying in the other directors in the email**? Maybe I should have sent it directly to him first. > > > You **were wrong**, you did not follow the rules of escalation properly. You should have sent it directly to your boss first. Usually you send copies of an e-mail 2-3 times (at least 1-3 days apart, depending on urgency), before adding more people to CC. > > I spoke to the boss on the phone today and apologised for sending the email, I said that I overreacted. He said that I did and that we need to have a conversation in person. He also made it clear that I am not being fired. > > > It is good that you two had a discussion, that you apologized, and that you will not be fired. When you will talk face-to-face apologize again, and ask him if he is willing to help you better understand how to handle these kinds of situations in the future - hot the escalation process works in the company. I know it is difficult, but you need to "forget" the emotions from home when you are at work. One mistake can be forgive. Maybe the second, and if you are lucky, the third. After that, you should not have much hope. **Bottom line:** you survived this experience, and you should learn as much as possible from it. If it is not a "secret", please tell us the final outcome, when you have it. I am surely curious about it.
It's so easy to parse the world in terms of justice—I have done so many times, myself. And if we are parsing the world that way, when someone does something that we perceive affects us negatively, it feels like an injustice. Suddenly a part of our brain says we have the high moral ground. Suddenly we feel like actions that expose, criticize, and put a very fine point on the issue are helpful and reasonable. Unfortunately, most of the time we have not actually suffered a truly serious injustice. In the case of your employment, you are being paid to be valuable to the company. If things outside your control truly caused you to be unable to render that value, then you are blameless, so long as you communicated about it and asked for help. If you've done your job of doing all that you can to do your job, and you still can't do your job, then effectively, the company is paying you to sit around not doing your job, which is within its rights. To start changing this way of thinking, I suggest that you read the book [*Never Split the Difference: Negotiating As If Your Life Depended On It*](https://rads.stackoverflow.com/amzn/click/com/B014DUR7L2). Especially pay attention to the part of his story where he worked in a suicide hotline call center, and make a mental note to yourself: *all people* need you to treat them as if they are at-risk, and need your soft skills more than your brutal, hard, sharp logic. If logic is the job at hand, it still has to come after your attention to the people. In the case of your boss, if you really couldn't do your job, it was time to just message him—what you had done, how you were stuck, and how you were attempting to proceed. If you see a pattern of not responding, then it is up to you to address it with the person who isn't responding. And before you ever escalate again, you need to do a last-ditch communication (just like in the book) along the lines of "have you decided to not answer?" Perhaps much better in this case, "should I try to solve this problem on my own?" Make it a question where "no" is the answer you want. You want him to answer, you want his help. As other answers have already said, please consider that you almost certainly need more emotional support. Do you have a big and strong enough support network? You are being pulled apart at home. You need people to talk to and share your problems and get advice and sympathy. Find a support group, or friends, or a therapist, or use your company's Employee Assistance Program to call someone, or go to a church and ask to talk to someone. Do *something*. When we feel like we're at the end of our rope, all of our random life circumstances can start to take on the sense of a life-and-death situation, even when they are nowhere near that. This puts us at risk of acting ineffectively or maladaptively, either of which will only hurt us more and push us closer to the end of our rope. You've got to take this seriously. When you communicate with your boss, or anyone at your work, try to speak in these ways: * "X came to my attention and I'm worried that Y might happen. Do you think it's worth investigating further?" (NOT "if someone doesn't do something about Y immediately the company will burn down tomorrow.") * "I feel X about this situation that's happened a few times. My attempts to solve it so far have consisted of Y & Z, but they haven't appeared to work yet. Do you have any suggestions about how to proceed? This is affecting my work." * "It seems like you X (or it seems like you Y)", and try to reflect back something that the person will really connect with. For your boss, it could be something like "it seems like you are really busy over there. Things must be crazy. Is there some way that I can get help with Z without distracting you from your important work?" * Always ask "how ..." or "what ..." and don't start with who, when, where, and most especially NOT *why*. "How would you like me to proceed?" "What could I do to move forward?" "What do you think might be stopping this from working?" "Do you have ideas on how to solve this?" It may seem unnatural, or unpleasant, but it is almost a guarantee that if you learn to start empathizing with people, making soft observations (e.g., "it seems like you *feeling*" instead of "you always do *negative interpretation*"), learning to synchronize with people, and so on, as I have briefly outlined, you will have far more success in your job and in life as well. How do I know? Yeah, experience is the best teacher. The more I learn to be soft and not pushy, intense, accusatory, and so on, the better results I get in life.
131,948
I am a new (3 months) software developer in a smallish software company (10 people). I've been given a new project which has complex and poorly documented requirements, and I've been asked to speak to my boss (who is a company director) before I begin work so he can show me what to do. I did contact him, asking him to help me, and he said he would but the appointed time passed and I heard nothing. We are spread over three sites and the promised monthly company meeting at the head office has only happened once: in January. We may get one in April, if we are lucky. I work at a site with only 3 people including me: we are all new starters and one guy is the project manager. We have a lot of complex projects for customers in very varying different areas ranging from manufacturing and distribution to service industries. The developers also have to provide support (helpdesk) for the applications and we are currently very busy, recruiting for 1-2 members of staff as we are struggling with the support and taking on the new jobs. In my previous job I worked for 3.5 years for a disorganised company with a boss who was often unavailable for days and who did things in a chaotic manner with no structure whatsoever. I left because I got so frustrated by the environment there, starting in my new workplace in December 2018. I am in my mid 40s and have worked in IT for 15 years, 5 of those in programming. The issue is that my background is in desktop applications, and in this new job I have had to learn web development (CSS, ASP, HTML, Razor views etc etc etc). I have found this surprisingly challenging and despite my educational background (PhD) I've been quite slow in comparison to the experienced developers. My personal life is chaotic as my teenage son has autism/ADHD, I have depression, my teenage daughter has anxiety/depression and my wife has unspecified/undiagnosed mental health issues. She has mentioned feeling suicidal to me several times and gets no real help. The environment at home is physically and mentally chaotic, with frequent crises and lots of extreme stress. I sent this email to my boss this morning, after trying twice unsuccessfully to phone him. I CC'd four other people: three company directors and the project manager in my office. The purpose of CC'ing them was because previously I have complained to the boss about lack of communication (no company meeting as promised) and what I got was a frustrated verbal reply about them being busy. I wanted to make sure something actually gets done about these issues. > > Hi X > > > I can't log in to Visual Studio again, so I can't do my job. The same situation existed yesterday. I struggled for maybe an hour > myself trying to work out the problem and when I contacted you, you > were able to say that it is due to the payment problem which will > hopefully be resolved today. It hasn't, which I find quite worrying. > I am filling in the time watching tutorials on CSS and reading the > spec/documents for \_\_\_\_\_\_\_\_\_\_\_. > > > I was asked to look at \_\_\_\_\_\_\_\_\_\_\_ > and the plan that I was given was that you would get back to me, but > that's not happened. In fact there has been more than one occasion > when you said you would get back to me and you have not been able to - > the time just goes by without any contact. I guess due to the volume > of support that you are all very very busy up at (head office). You > have my sympathy and its great that we are recruiting more people. I > am under quite a lot of stress in my personal life at the moment and > it makes me very anxious when I work in an unstructured environment > with poor communication. Its also frustrating that I want to be > productive and help you out by completing some of these tasks, but I > can't. > > > Kind regards, > Phil > > > He replied with: > > Hi Phil, > > > The problem with your Visual Studio account was fixed yesterday, you should have received an email which I have now > resent. If you still haven't received it please let me know. I will be > in the (your) office tomorrow morning, see you then. > > > Regards, > X > > > He is not a cheerful person and I am anticipating a bit of a backlash when we see him tomorrow. My question is this: **was I wrong in copying in the other directors in the email?** Maybe I should have sent it directly to him first. **Edit:** I spoke to the boss on the phone today and apologised for sending the email, I said that I overreacted. He said that I did and that we need to have a conversation in person. He also made it clear that I am not being fired. Edit: The boss agreed with me that what I wrote was unprofessional and that it was a mistake to involve other people, particularly a non-director. He said it looked like I was trying to 'throw him under a bus'. I said it wasn't my intention to challenge his authority and that I let personal stress (without going into detail) cloud my judgement. He apologised to me for the lack of communication but said he is overworked. In future he said if I need to rant, rant to HIM and don't involve others - except in the rare case when I can't get the right answer out of him (which is unlikely to ever happen). He even said I can discuss personal stuff with him if I need a listening ear. It looks like the boss is a LOT nicer man than I thought. So it is a strong unofficial reprimand. I am embarrassed by my lack of professionalism but the only thing I can do moving forward is to ensure I act professionally in future and this will just be forgotten as a 'blip'.
2019/03/19
[ "https://workplace.stackexchange.com/questions/131948", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/101531/" ]
Your frustration level is pretty high right now, and it definitely came out in that email. You should probably seriously consider if working in a small company on projects with complex and poorly documented requirements while learning new technology is something you should be doing. Some people thrive on that kind of nebulous situation, but most people don't. With your home situation, that is probably not a good fit. I also have a son with autism/ADHD and that means I sometimes come in late, sometimes I leave early, and sometimes I need to work from home. Sometimes I even have a full-blown crisis to deal with. I discussed this with my managers before I agreed to be hired, because I wanted to be clear that my home life would sometimes require adjustments to my work schedule. It has never been a problem for me. If you haven't had that conversation with your employer, you need to have it now. You need to have that conversation will all your future employers. The next thing you should do is go to your boss and ask for some period of time where you can focus on learning the stuff you need to know. I'd ask for a week or two, where you can put everything else on hold and spend your time doing tutorials, watching videos, taking online classes to learn CSS, ASP, HTML, Razor views etc etc etc. If you can fully focus on that and exclude all other responsibilities, it's likely that you will get yourself up to speed, your frustration will decrease, and the project can be successful again. If your boss says no, then I think the writing is on the wall. It's time to move on.
I disagree with the other answers here. You absolutely did the right thing. The history you recounted demonstrated a clear pattern of behavior of ignoring your issues - promised meetings that don't take place, phone calls that aren't returned, etc. And if you'd followed the advice here, there would have been no consequence for your latest email to be ignored again, so it would have been. I'm a little bit older than you and what I've learned (through lots of attempts at taking the passive approach as suggested here) is that no good comes (for you) from always seeking to put others before yourself who also seek to put themselves before others. You only got a response because you shone a light on the poor job performance of your boss. Do you honestly believe he sent an email and it somehow got lost? Of course not. He's covering his behind for never having actually sent the email. Do you believe he's going to be at your office the next day by coincidence? Again, no; he's doing that to save face and make himself look like he's on top of a situation he's completely ignored. You did indeed do the right thing. Your boss clearly has his own interests at heart rather than your own. Loyalty to one's commander comes with the understanding that the commander will provide everything their subordinates need to the best of their ability, never throw them under the bus, be quick to take blame and slow to take credit, etc. Your boss seems to have left your location to fend for themselves without even providing you working tools to do so. Don't worry about getting fired - you're too short-handed as is and losing an employee will look bad for your boss right now. That's without considering what he fears will come up in the exit interview. And now he's on notice that he can't walk all over you - things will improve now. Heck, maybe you're the most qualified to be the project manager there. :-)
131,948
I am a new (3 months) software developer in a smallish software company (10 people). I've been given a new project which has complex and poorly documented requirements, and I've been asked to speak to my boss (who is a company director) before I begin work so he can show me what to do. I did contact him, asking him to help me, and he said he would but the appointed time passed and I heard nothing. We are spread over three sites and the promised monthly company meeting at the head office has only happened once: in January. We may get one in April, if we are lucky. I work at a site with only 3 people including me: we are all new starters and one guy is the project manager. We have a lot of complex projects for customers in very varying different areas ranging from manufacturing and distribution to service industries. The developers also have to provide support (helpdesk) for the applications and we are currently very busy, recruiting for 1-2 members of staff as we are struggling with the support and taking on the new jobs. In my previous job I worked for 3.5 years for a disorganised company with a boss who was often unavailable for days and who did things in a chaotic manner with no structure whatsoever. I left because I got so frustrated by the environment there, starting in my new workplace in December 2018. I am in my mid 40s and have worked in IT for 15 years, 5 of those in programming. The issue is that my background is in desktop applications, and in this new job I have had to learn web development (CSS, ASP, HTML, Razor views etc etc etc). I have found this surprisingly challenging and despite my educational background (PhD) I've been quite slow in comparison to the experienced developers. My personal life is chaotic as my teenage son has autism/ADHD, I have depression, my teenage daughter has anxiety/depression and my wife has unspecified/undiagnosed mental health issues. She has mentioned feeling suicidal to me several times and gets no real help. The environment at home is physically and mentally chaotic, with frequent crises and lots of extreme stress. I sent this email to my boss this morning, after trying twice unsuccessfully to phone him. I CC'd four other people: three company directors and the project manager in my office. The purpose of CC'ing them was because previously I have complained to the boss about lack of communication (no company meeting as promised) and what I got was a frustrated verbal reply about them being busy. I wanted to make sure something actually gets done about these issues. > > Hi X > > > I can't log in to Visual Studio again, so I can't do my job. The same situation existed yesterday. I struggled for maybe an hour > myself trying to work out the problem and when I contacted you, you > were able to say that it is due to the payment problem which will > hopefully be resolved today. It hasn't, which I find quite worrying. > I am filling in the time watching tutorials on CSS and reading the > spec/documents for \_\_\_\_\_\_\_\_\_\_\_. > > > I was asked to look at \_\_\_\_\_\_\_\_\_\_\_ > and the plan that I was given was that you would get back to me, but > that's not happened. In fact there has been more than one occasion > when you said you would get back to me and you have not been able to - > the time just goes by without any contact. I guess due to the volume > of support that you are all very very busy up at (head office). You > have my sympathy and its great that we are recruiting more people. I > am under quite a lot of stress in my personal life at the moment and > it makes me very anxious when I work in an unstructured environment > with poor communication. Its also frustrating that I want to be > productive and help you out by completing some of these tasks, but I > can't. > > > Kind regards, > Phil > > > He replied with: > > Hi Phil, > > > The problem with your Visual Studio account was fixed yesterday, you should have received an email which I have now > resent. If you still haven't received it please let me know. I will be > in the (your) office tomorrow morning, see you then. > > > Regards, > X > > > He is not a cheerful person and I am anticipating a bit of a backlash when we see him tomorrow. My question is this: **was I wrong in copying in the other directors in the email?** Maybe I should have sent it directly to him first. **Edit:** I spoke to the boss on the phone today and apologised for sending the email, I said that I overreacted. He said that I did and that we need to have a conversation in person. He also made it clear that I am not being fired. Edit: The boss agreed with me that what I wrote was unprofessional and that it was a mistake to involve other people, particularly a non-director. He said it looked like I was trying to 'throw him under a bus'. I said it wasn't my intention to challenge his authority and that I let personal stress (without going into detail) cloud my judgement. He apologised to me for the lack of communication but said he is overworked. In future he said if I need to rant, rant to HIM and don't involve others - except in the rare case when I can't get the right answer out of him (which is unlikely to ever happen). He even said I can discuss personal stuff with him if I need a listening ear. It looks like the boss is a LOT nicer man than I thought. So it is a strong unofficial reprimand. I am embarrassed by my lack of professionalism but the only thing I can do moving forward is to ensure I act professionally in future and this will just be forgotten as a 'blip'.
2019/03/19
[ "https://workplace.stackexchange.com/questions/131948", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/101531/" ]
> > was I wrong in copying in the other directors in the email? > > > Yes, you were wrong. It's not clear what your goal was in copying others, but attempting to embarrass or undermine your boss is not a good career move. > > Maybe I should have sent it directly to him first. > > > Not maybe. You clearly should have sent it to him directly. Even better would have been to call him and talk with him directly. If you wish to succeed in this company, you are going to have to find a way to work well with others, including your boss. Use your face-to-face meeting tomorrow as an opportunity to discuss ways to better communicate. Talk about regular one-on-one meetings. Talk about when you should expect him to be available and when you shouldn't. And talk about what you should do when you need help immediately. You should come out of the meeting with a clearer understand of what communication medium to use in each circumstance. And hopefully, you will know when it is necessary to include others and when it isn't. > > I am under quite a lot of stress in my personal life at the moment and > it makes me very anxious when I work in an unstructured environment > with poor communication. > > > Think long and hard before your meeting and decide how much you want to talk about your home situation with your boss. Unless you are on very good and friendly terms with your boss, the general advice is to leave home issues at home. I have had bosses that I would be okay with sharing my situation, and other bosses where I absolutely wouldn't share. Consider how you want your boss to react if you share what you shared here in your question. Do you want him to be sympathetic and cut you some slack? Do you want him to change his behavior so that you aren't so anxious? The big fear should be that your boss starts to think that you have so much on your plate outside of work that you aren't up to handling this job. Only you have any insight into how your boss might react. Try to be prepared, think it through ahead of time, proceed with caution. Good luck. > > I spoke to the boss on the phone today and apologised for sending the > email, I said that I overreacted. He said that I did and that we need > to have a conversation in person. He also made it clear that I am not > being fired. > > > That's good news. Hopefully you can both now put this behind you, and find a way toward better communication going forward.
Your frustration level is pretty high right now, and it definitely came out in that email. You should probably seriously consider if working in a small company on projects with complex and poorly documented requirements while learning new technology is something you should be doing. Some people thrive on that kind of nebulous situation, but most people don't. With your home situation, that is probably not a good fit. I also have a son with autism/ADHD and that means I sometimes come in late, sometimes I leave early, and sometimes I need to work from home. Sometimes I even have a full-blown crisis to deal with. I discussed this with my managers before I agreed to be hired, because I wanted to be clear that my home life would sometimes require adjustments to my work schedule. It has never been a problem for me. If you haven't had that conversation with your employer, you need to have it now. You need to have that conversation will all your future employers. The next thing you should do is go to your boss and ask for some period of time where you can focus on learning the stuff you need to know. I'd ask for a week or two, where you can put everything else on hold and spend your time doing tutorials, watching videos, taking online classes to learn CSS, ASP, HTML, Razor views etc etc etc. If you can fully focus on that and exclude all other responsibilities, it's likely that you will get yourself up to speed, your frustration will decrease, and the project can be successful again. If your boss says no, then I think the writing is on the wall. It's time to move on.
131,948
I am a new (3 months) software developer in a smallish software company (10 people). I've been given a new project which has complex and poorly documented requirements, and I've been asked to speak to my boss (who is a company director) before I begin work so he can show me what to do. I did contact him, asking him to help me, and he said he would but the appointed time passed and I heard nothing. We are spread over three sites and the promised monthly company meeting at the head office has only happened once: in January. We may get one in April, if we are lucky. I work at a site with only 3 people including me: we are all new starters and one guy is the project manager. We have a lot of complex projects for customers in very varying different areas ranging from manufacturing and distribution to service industries. The developers also have to provide support (helpdesk) for the applications and we are currently very busy, recruiting for 1-2 members of staff as we are struggling with the support and taking on the new jobs. In my previous job I worked for 3.5 years for a disorganised company with a boss who was often unavailable for days and who did things in a chaotic manner with no structure whatsoever. I left because I got so frustrated by the environment there, starting in my new workplace in December 2018. I am in my mid 40s and have worked in IT for 15 years, 5 of those in programming. The issue is that my background is in desktop applications, and in this new job I have had to learn web development (CSS, ASP, HTML, Razor views etc etc etc). I have found this surprisingly challenging and despite my educational background (PhD) I've been quite slow in comparison to the experienced developers. My personal life is chaotic as my teenage son has autism/ADHD, I have depression, my teenage daughter has anxiety/depression and my wife has unspecified/undiagnosed mental health issues. She has mentioned feeling suicidal to me several times and gets no real help. The environment at home is physically and mentally chaotic, with frequent crises and lots of extreme stress. I sent this email to my boss this morning, after trying twice unsuccessfully to phone him. I CC'd four other people: three company directors and the project manager in my office. The purpose of CC'ing them was because previously I have complained to the boss about lack of communication (no company meeting as promised) and what I got was a frustrated verbal reply about them being busy. I wanted to make sure something actually gets done about these issues. > > Hi X > > > I can't log in to Visual Studio again, so I can't do my job. The same situation existed yesterday. I struggled for maybe an hour > myself trying to work out the problem and when I contacted you, you > were able to say that it is due to the payment problem which will > hopefully be resolved today. It hasn't, which I find quite worrying. > I am filling in the time watching tutorials on CSS and reading the > spec/documents for \_\_\_\_\_\_\_\_\_\_\_. > > > I was asked to look at \_\_\_\_\_\_\_\_\_\_\_ > and the plan that I was given was that you would get back to me, but > that's not happened. In fact there has been more than one occasion > when you said you would get back to me and you have not been able to - > the time just goes by without any contact. I guess due to the volume > of support that you are all very very busy up at (head office). You > have my sympathy and its great that we are recruiting more people. I > am under quite a lot of stress in my personal life at the moment and > it makes me very anxious when I work in an unstructured environment > with poor communication. Its also frustrating that I want to be > productive and help you out by completing some of these tasks, but I > can't. > > > Kind regards, > Phil > > > He replied with: > > Hi Phil, > > > The problem with your Visual Studio account was fixed yesterday, you should have received an email which I have now > resent. If you still haven't received it please let me know. I will be > in the (your) office tomorrow morning, see you then. > > > Regards, > X > > > He is not a cheerful person and I am anticipating a bit of a backlash when we see him tomorrow. My question is this: **was I wrong in copying in the other directors in the email?** Maybe I should have sent it directly to him first. **Edit:** I spoke to the boss on the phone today and apologised for sending the email, I said that I overreacted. He said that I did and that we need to have a conversation in person. He also made it clear that I am not being fired. Edit: The boss agreed with me that what I wrote was unprofessional and that it was a mistake to involve other people, particularly a non-director. He said it looked like I was trying to 'throw him under a bus'. I said it wasn't my intention to challenge his authority and that I let personal stress (without going into detail) cloud my judgement. He apologised to me for the lack of communication but said he is overworked. In future he said if I need to rant, rant to HIM and don't involve others - except in the rare case when I can't get the right answer out of him (which is unlikely to ever happen). He even said I can discuss personal stuff with him if I need a listening ear. It looks like the boss is a LOT nicer man than I thought. So it is a strong unofficial reprimand. I am embarrassed by my lack of professionalism but the only thing I can do moving forward is to ensure I act professionally in future and this will just be forgotten as a 'blip'.
2019/03/19
[ "https://workplace.stackexchange.com/questions/131948", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/101531/" ]
> > was I wrong in copying in the other directors in the email? > > > Yes, you were wrong. It's not clear what your goal was in copying others, but attempting to embarrass or undermine your boss is not a good career move. > > Maybe I should have sent it directly to him first. > > > Not maybe. You clearly should have sent it to him directly. Even better would have been to call him and talk with him directly. If you wish to succeed in this company, you are going to have to find a way to work well with others, including your boss. Use your face-to-face meeting tomorrow as an opportunity to discuss ways to better communicate. Talk about regular one-on-one meetings. Talk about when you should expect him to be available and when you shouldn't. And talk about what you should do when you need help immediately. You should come out of the meeting with a clearer understand of what communication medium to use in each circumstance. And hopefully, you will know when it is necessary to include others and when it isn't. > > I am under quite a lot of stress in my personal life at the moment and > it makes me very anxious when I work in an unstructured environment > with poor communication. > > > Think long and hard before your meeting and decide how much you want to talk about your home situation with your boss. Unless you are on very good and friendly terms with your boss, the general advice is to leave home issues at home. I have had bosses that I would be okay with sharing my situation, and other bosses where I absolutely wouldn't share. Consider how you want your boss to react if you share what you shared here in your question. Do you want him to be sympathetic and cut you some slack? Do you want him to change his behavior so that you aren't so anxious? The big fear should be that your boss starts to think that you have so much on your plate outside of work that you aren't up to handling this job. Only you have any insight into how your boss might react. Try to be prepared, think it through ahead of time, proceed with caution. Good luck. > > I spoke to the boss on the phone today and apologised for sending the > email, I said that I overreacted. He said that I did and that we need > to have a conversation in person. He also made it clear that I am not > being fired. > > > That's good news. Hopefully you can both now put this behind you, and find a way toward better communication going forward.
> > was I wrong in copying in the other directors in the email? > > > **yes**.. I understand that you were likely frustrated but CC-ing others in to what is basically a rant at your boss is unwise. It absolutely comes across as you wanting to air your grievance and annoyance with him in front of others and as an attempt to "shame" him in the process. Giving your relatively new boss a public "Reason you suck" speech is not only unprofessional but can be rather career limiting! I'd suggest apologizing to your boss next time you speak to him - explain that you were just a frustrated that day and you let it get the better of you.
131,948
I am a new (3 months) software developer in a smallish software company (10 people). I've been given a new project which has complex and poorly documented requirements, and I've been asked to speak to my boss (who is a company director) before I begin work so he can show me what to do. I did contact him, asking him to help me, and he said he would but the appointed time passed and I heard nothing. We are spread over three sites and the promised monthly company meeting at the head office has only happened once: in January. We may get one in April, if we are lucky. I work at a site with only 3 people including me: we are all new starters and one guy is the project manager. We have a lot of complex projects for customers in very varying different areas ranging from manufacturing and distribution to service industries. The developers also have to provide support (helpdesk) for the applications and we are currently very busy, recruiting for 1-2 members of staff as we are struggling with the support and taking on the new jobs. In my previous job I worked for 3.5 years for a disorganised company with a boss who was often unavailable for days and who did things in a chaotic manner with no structure whatsoever. I left because I got so frustrated by the environment there, starting in my new workplace in December 2018. I am in my mid 40s and have worked in IT for 15 years, 5 of those in programming. The issue is that my background is in desktop applications, and in this new job I have had to learn web development (CSS, ASP, HTML, Razor views etc etc etc). I have found this surprisingly challenging and despite my educational background (PhD) I've been quite slow in comparison to the experienced developers. My personal life is chaotic as my teenage son has autism/ADHD, I have depression, my teenage daughter has anxiety/depression and my wife has unspecified/undiagnosed mental health issues. She has mentioned feeling suicidal to me several times and gets no real help. The environment at home is physically and mentally chaotic, with frequent crises and lots of extreme stress. I sent this email to my boss this morning, after trying twice unsuccessfully to phone him. I CC'd four other people: three company directors and the project manager in my office. The purpose of CC'ing them was because previously I have complained to the boss about lack of communication (no company meeting as promised) and what I got was a frustrated verbal reply about them being busy. I wanted to make sure something actually gets done about these issues. > > Hi X > > > I can't log in to Visual Studio again, so I can't do my job. The same situation existed yesterday. I struggled for maybe an hour > myself trying to work out the problem and when I contacted you, you > were able to say that it is due to the payment problem which will > hopefully be resolved today. It hasn't, which I find quite worrying. > I am filling in the time watching tutorials on CSS and reading the > spec/documents for \_\_\_\_\_\_\_\_\_\_\_. > > > I was asked to look at \_\_\_\_\_\_\_\_\_\_\_ > and the plan that I was given was that you would get back to me, but > that's not happened. In fact there has been more than one occasion > when you said you would get back to me and you have not been able to - > the time just goes by without any contact. I guess due to the volume > of support that you are all very very busy up at (head office). You > have my sympathy and its great that we are recruiting more people. I > am under quite a lot of stress in my personal life at the moment and > it makes me very anxious when I work in an unstructured environment > with poor communication. Its also frustrating that I want to be > productive and help you out by completing some of these tasks, but I > can't. > > > Kind regards, > Phil > > > He replied with: > > Hi Phil, > > > The problem with your Visual Studio account was fixed yesterday, you should have received an email which I have now > resent. If you still haven't received it please let me know. I will be > in the (your) office tomorrow morning, see you then. > > > Regards, > X > > > He is not a cheerful person and I am anticipating a bit of a backlash when we see him tomorrow. My question is this: **was I wrong in copying in the other directors in the email?** Maybe I should have sent it directly to him first. **Edit:** I spoke to the boss on the phone today and apologised for sending the email, I said that I overreacted. He said that I did and that we need to have a conversation in person. He also made it clear that I am not being fired. Edit: The boss agreed with me that what I wrote was unprofessional and that it was a mistake to involve other people, particularly a non-director. He said it looked like I was trying to 'throw him under a bus'. I said it wasn't my intention to challenge his authority and that I let personal stress (without going into detail) cloud my judgement. He apologised to me for the lack of communication but said he is overworked. In future he said if I need to rant, rant to HIM and don't involve others - except in the rare case when I can't get the right answer out of him (which is unlikely to ever happen). He even said I can discuss personal stuff with him if I need a listening ear. It looks like the boss is a LOT nicer man than I thought. So it is a strong unofficial reprimand. I am embarrassed by my lack of professionalism but the only thing I can do moving forward is to ensure I act professionally in future and this will just be forgotten as a 'blip'.
2019/03/19
[ "https://workplace.stackexchange.com/questions/131948", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/101531/" ]
> > was I wrong in copying in the other directors in the email? > > > Yes, you were wrong. It's not clear what your goal was in copying others, but attempting to embarrass or undermine your boss is not a good career move. > > Maybe I should have sent it directly to him first. > > > Not maybe. You clearly should have sent it to him directly. Even better would have been to call him and talk with him directly. If you wish to succeed in this company, you are going to have to find a way to work well with others, including your boss. Use your face-to-face meeting tomorrow as an opportunity to discuss ways to better communicate. Talk about regular one-on-one meetings. Talk about when you should expect him to be available and when you shouldn't. And talk about what you should do when you need help immediately. You should come out of the meeting with a clearer understand of what communication medium to use in each circumstance. And hopefully, you will know when it is necessary to include others and when it isn't. > > I am under quite a lot of stress in my personal life at the moment and > it makes me very anxious when I work in an unstructured environment > with poor communication. > > > Think long and hard before your meeting and decide how much you want to talk about your home situation with your boss. Unless you are on very good and friendly terms with your boss, the general advice is to leave home issues at home. I have had bosses that I would be okay with sharing my situation, and other bosses where I absolutely wouldn't share. Consider how you want your boss to react if you share what you shared here in your question. Do you want him to be sympathetic and cut you some slack? Do you want him to change his behavior so that you aren't so anxious? The big fear should be that your boss starts to think that you have so much on your plate outside of work that you aren't up to handling this job. Only you have any insight into how your boss might react. Try to be prepared, think it through ahead of time, proceed with caution. Good luck. > > I spoke to the boss on the phone today and apologised for sending the > email, I said that I overreacted. He said that I did and that we need > to have a conversation in person. He also made it clear that I am not > being fired. > > > That's good news. Hopefully you can both now put this behind you, and find a way toward better communication going forward.
It is not the best thing to do (actually, it was quite bad), but it is not a career-ending mistake provided you learn from this mistake and not make it a habit. In these kinds of situations (i.e. something not working), you should: * ask verbally (your colleagues or your boss) to whom you should report the problem in order to get support; * keep in contact with the support person until the problem is solved; * if the contact person does not want to help, notify your boss; * if your boss does not want to help, notify directors. **NOTE:** things take time, there might be many things in need to be fixed at the same time etc. **Do not assume** that if your problem was not fixed in XX time, then somebody does not want to help. Actually, *"does not want to help"* usually means that the person tells you something along the meaning of: "Go away, I will not help you." --- > > My question is this: **was I wrong in copying in the other directors in the email**? Maybe I should have sent it directly to him first. > > > You **were wrong**, you did not follow the rules of escalation properly. You should have sent it directly to your boss first. Usually you send copies of an e-mail 2-3 times (at least 1-3 days apart, depending on urgency), before adding more people to CC. > > I spoke to the boss on the phone today and apologised for sending the email, I said that I overreacted. He said that I did and that we need to have a conversation in person. He also made it clear that I am not being fired. > > > It is good that you two had a discussion, that you apologized, and that you will not be fired. When you will talk face-to-face apologize again, and ask him if he is willing to help you better understand how to handle these kinds of situations in the future - hot the escalation process works in the company. I know it is difficult, but you need to "forget" the emotions from home when you are at work. One mistake can be forgive. Maybe the second, and if you are lucky, the third. After that, you should not have much hope. **Bottom line:** you survived this experience, and you should learn as much as possible from it. If it is not a "secret", please tell us the final outcome, when you have it. I am surely curious about it.
131,948
I am a new (3 months) software developer in a smallish software company (10 people). I've been given a new project which has complex and poorly documented requirements, and I've been asked to speak to my boss (who is a company director) before I begin work so he can show me what to do. I did contact him, asking him to help me, and he said he would but the appointed time passed and I heard nothing. We are spread over three sites and the promised monthly company meeting at the head office has only happened once: in January. We may get one in April, if we are lucky. I work at a site with only 3 people including me: we are all new starters and one guy is the project manager. We have a lot of complex projects for customers in very varying different areas ranging from manufacturing and distribution to service industries. The developers also have to provide support (helpdesk) for the applications and we are currently very busy, recruiting for 1-2 members of staff as we are struggling with the support and taking on the new jobs. In my previous job I worked for 3.5 years for a disorganised company with a boss who was often unavailable for days and who did things in a chaotic manner with no structure whatsoever. I left because I got so frustrated by the environment there, starting in my new workplace in December 2018. I am in my mid 40s and have worked in IT for 15 years, 5 of those in programming. The issue is that my background is in desktop applications, and in this new job I have had to learn web development (CSS, ASP, HTML, Razor views etc etc etc). I have found this surprisingly challenging and despite my educational background (PhD) I've been quite slow in comparison to the experienced developers. My personal life is chaotic as my teenage son has autism/ADHD, I have depression, my teenage daughter has anxiety/depression and my wife has unspecified/undiagnosed mental health issues. She has mentioned feeling suicidal to me several times and gets no real help. The environment at home is physically and mentally chaotic, with frequent crises and lots of extreme stress. I sent this email to my boss this morning, after trying twice unsuccessfully to phone him. I CC'd four other people: three company directors and the project manager in my office. The purpose of CC'ing them was because previously I have complained to the boss about lack of communication (no company meeting as promised) and what I got was a frustrated verbal reply about them being busy. I wanted to make sure something actually gets done about these issues. > > Hi X > > > I can't log in to Visual Studio again, so I can't do my job. The same situation existed yesterday. I struggled for maybe an hour > myself trying to work out the problem and when I contacted you, you > were able to say that it is due to the payment problem which will > hopefully be resolved today. It hasn't, which I find quite worrying. > I am filling in the time watching tutorials on CSS and reading the > spec/documents for \_\_\_\_\_\_\_\_\_\_\_. > > > I was asked to look at \_\_\_\_\_\_\_\_\_\_\_ > and the plan that I was given was that you would get back to me, but > that's not happened. In fact there has been more than one occasion > when you said you would get back to me and you have not been able to - > the time just goes by without any contact. I guess due to the volume > of support that you are all very very busy up at (head office). You > have my sympathy and its great that we are recruiting more people. I > am under quite a lot of stress in my personal life at the moment and > it makes me very anxious when I work in an unstructured environment > with poor communication. Its also frustrating that I want to be > productive and help you out by completing some of these tasks, but I > can't. > > > Kind regards, > Phil > > > He replied with: > > Hi Phil, > > > The problem with your Visual Studio account was fixed yesterday, you should have received an email which I have now > resent. If you still haven't received it please let me know. I will be > in the (your) office tomorrow morning, see you then. > > > Regards, > X > > > He is not a cheerful person and I am anticipating a bit of a backlash when we see him tomorrow. My question is this: **was I wrong in copying in the other directors in the email?** Maybe I should have sent it directly to him first. **Edit:** I spoke to the boss on the phone today and apologised for sending the email, I said that I overreacted. He said that I did and that we need to have a conversation in person. He also made it clear that I am not being fired. Edit: The boss agreed with me that what I wrote was unprofessional and that it was a mistake to involve other people, particularly a non-director. He said it looked like I was trying to 'throw him under a bus'. I said it wasn't my intention to challenge his authority and that I let personal stress (without going into detail) cloud my judgement. He apologised to me for the lack of communication but said he is overworked. In future he said if I need to rant, rant to HIM and don't involve others - except in the rare case when I can't get the right answer out of him (which is unlikely to ever happen). He even said I can discuss personal stuff with him if I need a listening ear. It looks like the boss is a LOT nicer man than I thought. So it is a strong unofficial reprimand. I am embarrassed by my lack of professionalism but the only thing I can do moving forward is to ensure I act professionally in future and this will just be forgotten as a 'blip'.
2019/03/19
[ "https://workplace.stackexchange.com/questions/131948", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/101531/" ]
It's so easy to parse the world in terms of justice—I have done so many times, myself. And if we are parsing the world that way, when someone does something that we perceive affects us negatively, it feels like an injustice. Suddenly a part of our brain says we have the high moral ground. Suddenly we feel like actions that expose, criticize, and put a very fine point on the issue are helpful and reasonable. Unfortunately, most of the time we have not actually suffered a truly serious injustice. In the case of your employment, you are being paid to be valuable to the company. If things outside your control truly caused you to be unable to render that value, then you are blameless, so long as you communicated about it and asked for help. If you've done your job of doing all that you can to do your job, and you still can't do your job, then effectively, the company is paying you to sit around not doing your job, which is within its rights. To start changing this way of thinking, I suggest that you read the book [*Never Split the Difference: Negotiating As If Your Life Depended On It*](https://rads.stackoverflow.com/amzn/click/com/B014DUR7L2). Especially pay attention to the part of his story where he worked in a suicide hotline call center, and make a mental note to yourself: *all people* need you to treat them as if they are at-risk, and need your soft skills more than your brutal, hard, sharp logic. If logic is the job at hand, it still has to come after your attention to the people. In the case of your boss, if you really couldn't do your job, it was time to just message him—what you had done, how you were stuck, and how you were attempting to proceed. If you see a pattern of not responding, then it is up to you to address it with the person who isn't responding. And before you ever escalate again, you need to do a last-ditch communication (just like in the book) along the lines of "have you decided to not answer?" Perhaps much better in this case, "should I try to solve this problem on my own?" Make it a question where "no" is the answer you want. You want him to answer, you want his help. As other answers have already said, please consider that you almost certainly need more emotional support. Do you have a big and strong enough support network? You are being pulled apart at home. You need people to talk to and share your problems and get advice and sympathy. Find a support group, or friends, or a therapist, or use your company's Employee Assistance Program to call someone, or go to a church and ask to talk to someone. Do *something*. When we feel like we're at the end of our rope, all of our random life circumstances can start to take on the sense of a life-and-death situation, even when they are nowhere near that. This puts us at risk of acting ineffectively or maladaptively, either of which will only hurt us more and push us closer to the end of our rope. You've got to take this seriously. When you communicate with your boss, or anyone at your work, try to speak in these ways: * "X came to my attention and I'm worried that Y might happen. Do you think it's worth investigating further?" (NOT "if someone doesn't do something about Y immediately the company will burn down tomorrow.") * "I feel X about this situation that's happened a few times. My attempts to solve it so far have consisted of Y & Z, but they haven't appeared to work yet. Do you have any suggestions about how to proceed? This is affecting my work." * "It seems like you X (or it seems like you Y)", and try to reflect back something that the person will really connect with. For your boss, it could be something like "it seems like you are really busy over there. Things must be crazy. Is there some way that I can get help with Z without distracting you from your important work?" * Always ask "how ..." or "what ..." and don't start with who, when, where, and most especially NOT *why*. "How would you like me to proceed?" "What could I do to move forward?" "What do you think might be stopping this from working?" "Do you have ideas on how to solve this?" It may seem unnatural, or unpleasant, but it is almost a guarantee that if you learn to start empathizing with people, making soft observations (e.g., "it seems like you *feeling*" instead of "you always do *negative interpretation*"), learning to synchronize with people, and so on, as I have briefly outlined, you will have far more success in your job and in life as well. How do I know? Yeah, experience is the best teacher. The more I learn to be soft and not pushy, intense, accusatory, and so on, the better results I get in life.
I disagree with the other answers here. You absolutely did the right thing. The history you recounted demonstrated a clear pattern of behavior of ignoring your issues - promised meetings that don't take place, phone calls that aren't returned, etc. And if you'd followed the advice here, there would have been no consequence for your latest email to be ignored again, so it would have been. I'm a little bit older than you and what I've learned (through lots of attempts at taking the passive approach as suggested here) is that no good comes (for you) from always seeking to put others before yourself who also seek to put themselves before others. You only got a response because you shone a light on the poor job performance of your boss. Do you honestly believe he sent an email and it somehow got lost? Of course not. He's covering his behind for never having actually sent the email. Do you believe he's going to be at your office the next day by coincidence? Again, no; he's doing that to save face and make himself look like he's on top of a situation he's completely ignored. You did indeed do the right thing. Your boss clearly has his own interests at heart rather than your own. Loyalty to one's commander comes with the understanding that the commander will provide everything their subordinates need to the best of their ability, never throw them under the bus, be quick to take blame and slow to take credit, etc. Your boss seems to have left your location to fend for themselves without even providing you working tools to do so. Don't worry about getting fired - you're too short-handed as is and losing an employee will look bad for your boss right now. That's without considering what he fears will come up in the exit interview. And now he's on notice that he can't walk all over you - things will improve now. Heck, maybe you're the most qualified to be the project manager there. :-)
131,948
I am a new (3 months) software developer in a smallish software company (10 people). I've been given a new project which has complex and poorly documented requirements, and I've been asked to speak to my boss (who is a company director) before I begin work so he can show me what to do. I did contact him, asking him to help me, and he said he would but the appointed time passed and I heard nothing. We are spread over three sites and the promised monthly company meeting at the head office has only happened once: in January. We may get one in April, if we are lucky. I work at a site with only 3 people including me: we are all new starters and one guy is the project manager. We have a lot of complex projects for customers in very varying different areas ranging from manufacturing and distribution to service industries. The developers also have to provide support (helpdesk) for the applications and we are currently very busy, recruiting for 1-2 members of staff as we are struggling with the support and taking on the new jobs. In my previous job I worked for 3.5 years for a disorganised company with a boss who was often unavailable for days and who did things in a chaotic manner with no structure whatsoever. I left because I got so frustrated by the environment there, starting in my new workplace in December 2018. I am in my mid 40s and have worked in IT for 15 years, 5 of those in programming. The issue is that my background is in desktop applications, and in this new job I have had to learn web development (CSS, ASP, HTML, Razor views etc etc etc). I have found this surprisingly challenging and despite my educational background (PhD) I've been quite slow in comparison to the experienced developers. My personal life is chaotic as my teenage son has autism/ADHD, I have depression, my teenage daughter has anxiety/depression and my wife has unspecified/undiagnosed mental health issues. She has mentioned feeling suicidal to me several times and gets no real help. The environment at home is physically and mentally chaotic, with frequent crises and lots of extreme stress. I sent this email to my boss this morning, after trying twice unsuccessfully to phone him. I CC'd four other people: three company directors and the project manager in my office. The purpose of CC'ing them was because previously I have complained to the boss about lack of communication (no company meeting as promised) and what I got was a frustrated verbal reply about them being busy. I wanted to make sure something actually gets done about these issues. > > Hi X > > > I can't log in to Visual Studio again, so I can't do my job. The same situation existed yesterday. I struggled for maybe an hour > myself trying to work out the problem and when I contacted you, you > were able to say that it is due to the payment problem which will > hopefully be resolved today. It hasn't, which I find quite worrying. > I am filling in the time watching tutorials on CSS and reading the > spec/documents for \_\_\_\_\_\_\_\_\_\_\_. > > > I was asked to look at \_\_\_\_\_\_\_\_\_\_\_ > and the plan that I was given was that you would get back to me, but > that's not happened. In fact there has been more than one occasion > when you said you would get back to me and you have not been able to - > the time just goes by without any contact. I guess due to the volume > of support that you are all very very busy up at (head office). You > have my sympathy and its great that we are recruiting more people. I > am under quite a lot of stress in my personal life at the moment and > it makes me very anxious when I work in an unstructured environment > with poor communication. Its also frustrating that I want to be > productive and help you out by completing some of these tasks, but I > can't. > > > Kind regards, > Phil > > > He replied with: > > Hi Phil, > > > The problem with your Visual Studio account was fixed yesterday, you should have received an email which I have now > resent. If you still haven't received it please let me know. I will be > in the (your) office tomorrow morning, see you then. > > > Regards, > X > > > He is not a cheerful person and I am anticipating a bit of a backlash when we see him tomorrow. My question is this: **was I wrong in copying in the other directors in the email?** Maybe I should have sent it directly to him first. **Edit:** I spoke to the boss on the phone today and apologised for sending the email, I said that I overreacted. He said that I did and that we need to have a conversation in person. He also made it clear that I am not being fired. Edit: The boss agreed with me that what I wrote was unprofessional and that it was a mistake to involve other people, particularly a non-director. He said it looked like I was trying to 'throw him under a bus'. I said it wasn't my intention to challenge his authority and that I let personal stress (without going into detail) cloud my judgement. He apologised to me for the lack of communication but said he is overworked. In future he said if I need to rant, rant to HIM and don't involve others - except in the rare case when I can't get the right answer out of him (which is unlikely to ever happen). He even said I can discuss personal stuff with him if I need a listening ear. It looks like the boss is a LOT nicer man than I thought. So it is a strong unofficial reprimand. I am embarrassed by my lack of professionalism but the only thing I can do moving forward is to ensure I act professionally in future and this will just be forgotten as a 'blip'.
2019/03/19
[ "https://workplace.stackexchange.com/questions/131948", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/101531/" ]
Your frustration level is pretty high right now, and it definitely came out in that email. You should probably seriously consider if working in a small company on projects with complex and poorly documented requirements while learning new technology is something you should be doing. Some people thrive on that kind of nebulous situation, but most people don't. With your home situation, that is probably not a good fit. I also have a son with autism/ADHD and that means I sometimes come in late, sometimes I leave early, and sometimes I need to work from home. Sometimes I even have a full-blown crisis to deal with. I discussed this with my managers before I agreed to be hired, because I wanted to be clear that my home life would sometimes require adjustments to my work schedule. It has never been a problem for me. If you haven't had that conversation with your employer, you need to have it now. You need to have that conversation will all your future employers. The next thing you should do is go to your boss and ask for some period of time where you can focus on learning the stuff you need to know. I'd ask for a week or two, where you can put everything else on hold and spend your time doing tutorials, watching videos, taking online classes to learn CSS, ASP, HTML, Razor views etc etc etc. If you can fully focus on that and exclude all other responsibilities, it's likely that you will get yourself up to speed, your frustration will decrease, and the project can be successful again. If your boss says no, then I think the writing is on the wall. It's time to move on.
It's so easy to parse the world in terms of justice—I have done so many times, myself. And if we are parsing the world that way, when someone does something that we perceive affects us negatively, it feels like an injustice. Suddenly a part of our brain says we have the high moral ground. Suddenly we feel like actions that expose, criticize, and put a very fine point on the issue are helpful and reasonable. Unfortunately, most of the time we have not actually suffered a truly serious injustice. In the case of your employment, you are being paid to be valuable to the company. If things outside your control truly caused you to be unable to render that value, then you are blameless, so long as you communicated about it and asked for help. If you've done your job of doing all that you can to do your job, and you still can't do your job, then effectively, the company is paying you to sit around not doing your job, which is within its rights. To start changing this way of thinking, I suggest that you read the book [*Never Split the Difference: Negotiating As If Your Life Depended On It*](https://rads.stackoverflow.com/amzn/click/com/B014DUR7L2). Especially pay attention to the part of his story where he worked in a suicide hotline call center, and make a mental note to yourself: *all people* need you to treat them as if they are at-risk, and need your soft skills more than your brutal, hard, sharp logic. If logic is the job at hand, it still has to come after your attention to the people. In the case of your boss, if you really couldn't do your job, it was time to just message him—what you had done, how you were stuck, and how you were attempting to proceed. If you see a pattern of not responding, then it is up to you to address it with the person who isn't responding. And before you ever escalate again, you need to do a last-ditch communication (just like in the book) along the lines of "have you decided to not answer?" Perhaps much better in this case, "should I try to solve this problem on my own?" Make it a question where "no" is the answer you want. You want him to answer, you want his help. As other answers have already said, please consider that you almost certainly need more emotional support. Do you have a big and strong enough support network? You are being pulled apart at home. You need people to talk to and share your problems and get advice and sympathy. Find a support group, or friends, or a therapist, or use your company's Employee Assistance Program to call someone, or go to a church and ask to talk to someone. Do *something*. When we feel like we're at the end of our rope, all of our random life circumstances can start to take on the sense of a life-and-death situation, even when they are nowhere near that. This puts us at risk of acting ineffectively or maladaptively, either of which will only hurt us more and push us closer to the end of our rope. You've got to take this seriously. When you communicate with your boss, or anyone at your work, try to speak in these ways: * "X came to my attention and I'm worried that Y might happen. Do you think it's worth investigating further?" (NOT "if someone doesn't do something about Y immediately the company will burn down tomorrow.") * "I feel X about this situation that's happened a few times. My attempts to solve it so far have consisted of Y & Z, but they haven't appeared to work yet. Do you have any suggestions about how to proceed? This is affecting my work." * "It seems like you X (or it seems like you Y)", and try to reflect back something that the person will really connect with. For your boss, it could be something like "it seems like you are really busy over there. Things must be crazy. Is there some way that I can get help with Z without distracting you from your important work?" * Always ask "how ..." or "what ..." and don't start with who, when, where, and most especially NOT *why*. "How would you like me to proceed?" "What could I do to move forward?" "What do you think might be stopping this from working?" "Do you have ideas on how to solve this?" It may seem unnatural, or unpleasant, but it is almost a guarantee that if you learn to start empathizing with people, making soft observations (e.g., "it seems like you *feeling*" instead of "you always do *negative interpretation*"), learning to synchronize with people, and so on, as I have briefly outlined, you will have far more success in your job and in life as well. How do I know? Yeah, experience is the best teacher. The more I learn to be soft and not pushy, intense, accusatory, and so on, the better results I get in life.
131,948
I am a new (3 months) software developer in a smallish software company (10 people). I've been given a new project which has complex and poorly documented requirements, and I've been asked to speak to my boss (who is a company director) before I begin work so he can show me what to do. I did contact him, asking him to help me, and he said he would but the appointed time passed and I heard nothing. We are spread over three sites and the promised monthly company meeting at the head office has only happened once: in January. We may get one in April, if we are lucky. I work at a site with only 3 people including me: we are all new starters and one guy is the project manager. We have a lot of complex projects for customers in very varying different areas ranging from manufacturing and distribution to service industries. The developers also have to provide support (helpdesk) for the applications and we are currently very busy, recruiting for 1-2 members of staff as we are struggling with the support and taking on the new jobs. In my previous job I worked for 3.5 years for a disorganised company with a boss who was often unavailable for days and who did things in a chaotic manner with no structure whatsoever. I left because I got so frustrated by the environment there, starting in my new workplace in December 2018. I am in my mid 40s and have worked in IT for 15 years, 5 of those in programming. The issue is that my background is in desktop applications, and in this new job I have had to learn web development (CSS, ASP, HTML, Razor views etc etc etc). I have found this surprisingly challenging and despite my educational background (PhD) I've been quite slow in comparison to the experienced developers. My personal life is chaotic as my teenage son has autism/ADHD, I have depression, my teenage daughter has anxiety/depression and my wife has unspecified/undiagnosed mental health issues. She has mentioned feeling suicidal to me several times and gets no real help. The environment at home is physically and mentally chaotic, with frequent crises and lots of extreme stress. I sent this email to my boss this morning, after trying twice unsuccessfully to phone him. I CC'd four other people: three company directors and the project manager in my office. The purpose of CC'ing them was because previously I have complained to the boss about lack of communication (no company meeting as promised) and what I got was a frustrated verbal reply about them being busy. I wanted to make sure something actually gets done about these issues. > > Hi X > > > I can't log in to Visual Studio again, so I can't do my job. The same situation existed yesterday. I struggled for maybe an hour > myself trying to work out the problem and when I contacted you, you > were able to say that it is due to the payment problem which will > hopefully be resolved today. It hasn't, which I find quite worrying. > I am filling in the time watching tutorials on CSS and reading the > spec/documents for \_\_\_\_\_\_\_\_\_\_\_. > > > I was asked to look at \_\_\_\_\_\_\_\_\_\_\_ > and the plan that I was given was that you would get back to me, but > that's not happened. In fact there has been more than one occasion > when you said you would get back to me and you have not been able to - > the time just goes by without any contact. I guess due to the volume > of support that you are all very very busy up at (head office). You > have my sympathy and its great that we are recruiting more people. I > am under quite a lot of stress in my personal life at the moment and > it makes me very anxious when I work in an unstructured environment > with poor communication. Its also frustrating that I want to be > productive and help you out by completing some of these tasks, but I > can't. > > > Kind regards, > Phil > > > He replied with: > > Hi Phil, > > > The problem with your Visual Studio account was fixed yesterday, you should have received an email which I have now > resent. If you still haven't received it please let me know. I will be > in the (your) office tomorrow morning, see you then. > > > Regards, > X > > > He is not a cheerful person and I am anticipating a bit of a backlash when we see him tomorrow. My question is this: **was I wrong in copying in the other directors in the email?** Maybe I should have sent it directly to him first. **Edit:** I spoke to the boss on the phone today and apologised for sending the email, I said that I overreacted. He said that I did and that we need to have a conversation in person. He also made it clear that I am not being fired. Edit: The boss agreed with me that what I wrote was unprofessional and that it was a mistake to involve other people, particularly a non-director. He said it looked like I was trying to 'throw him under a bus'. I said it wasn't my intention to challenge his authority and that I let personal stress (without going into detail) cloud my judgement. He apologised to me for the lack of communication but said he is overworked. In future he said if I need to rant, rant to HIM and don't involve others - except in the rare case when I can't get the right answer out of him (which is unlikely to ever happen). He even said I can discuss personal stuff with him if I need a listening ear. It looks like the boss is a LOT nicer man than I thought. So it is a strong unofficial reprimand. I am embarrassed by my lack of professionalism but the only thing I can do moving forward is to ensure I act professionally in future and this will just be forgotten as a 'blip'.
2019/03/19
[ "https://workplace.stackexchange.com/questions/131948", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/101531/" ]
> > was I wrong in copying in the other directors in the email? > > > **yes**.. I understand that you were likely frustrated but CC-ing others in to what is basically a rant at your boss is unwise. It absolutely comes across as you wanting to air your grievance and annoyance with him in front of others and as an attempt to "shame" him in the process. Giving your relatively new boss a public "Reason you suck" speech is not only unprofessional but can be rather career limiting! I'd suggest apologizing to your boss next time you speak to him - explain that you were just a frustrated that day and you let it get the better of you.
I disagree with the other answers here. You absolutely did the right thing. The history you recounted demonstrated a clear pattern of behavior of ignoring your issues - promised meetings that don't take place, phone calls that aren't returned, etc. And if you'd followed the advice here, there would have been no consequence for your latest email to be ignored again, so it would have been. I'm a little bit older than you and what I've learned (through lots of attempts at taking the passive approach as suggested here) is that no good comes (for you) from always seeking to put others before yourself who also seek to put themselves before others. You only got a response because you shone a light on the poor job performance of your boss. Do you honestly believe he sent an email and it somehow got lost? Of course not. He's covering his behind for never having actually sent the email. Do you believe he's going to be at your office the next day by coincidence? Again, no; he's doing that to save face and make himself look like he's on top of a situation he's completely ignored. You did indeed do the right thing. Your boss clearly has his own interests at heart rather than your own. Loyalty to one's commander comes with the understanding that the commander will provide everything their subordinates need to the best of their ability, never throw them under the bus, be quick to take blame and slow to take credit, etc. Your boss seems to have left your location to fend for themselves without even providing you working tools to do so. Don't worry about getting fired - you're too short-handed as is and losing an employee will look bad for your boss right now. That's without considering what he fears will come up in the exit interview. And now he's on notice that he can't walk all over you - things will improve now. Heck, maybe you're the most qualified to be the project manager there. :-)
131,948
I am a new (3 months) software developer in a smallish software company (10 people). I've been given a new project which has complex and poorly documented requirements, and I've been asked to speak to my boss (who is a company director) before I begin work so he can show me what to do. I did contact him, asking him to help me, and he said he would but the appointed time passed and I heard nothing. We are spread over three sites and the promised monthly company meeting at the head office has only happened once: in January. We may get one in April, if we are lucky. I work at a site with only 3 people including me: we are all new starters and one guy is the project manager. We have a lot of complex projects for customers in very varying different areas ranging from manufacturing and distribution to service industries. The developers also have to provide support (helpdesk) for the applications and we are currently very busy, recruiting for 1-2 members of staff as we are struggling with the support and taking on the new jobs. In my previous job I worked for 3.5 years for a disorganised company with a boss who was often unavailable for days and who did things in a chaotic manner with no structure whatsoever. I left because I got so frustrated by the environment there, starting in my new workplace in December 2018. I am in my mid 40s and have worked in IT for 15 years, 5 of those in programming. The issue is that my background is in desktop applications, and in this new job I have had to learn web development (CSS, ASP, HTML, Razor views etc etc etc). I have found this surprisingly challenging and despite my educational background (PhD) I've been quite slow in comparison to the experienced developers. My personal life is chaotic as my teenage son has autism/ADHD, I have depression, my teenage daughter has anxiety/depression and my wife has unspecified/undiagnosed mental health issues. She has mentioned feeling suicidal to me several times and gets no real help. The environment at home is physically and mentally chaotic, with frequent crises and lots of extreme stress. I sent this email to my boss this morning, after trying twice unsuccessfully to phone him. I CC'd four other people: three company directors and the project manager in my office. The purpose of CC'ing them was because previously I have complained to the boss about lack of communication (no company meeting as promised) and what I got was a frustrated verbal reply about them being busy. I wanted to make sure something actually gets done about these issues. > > Hi X > > > I can't log in to Visual Studio again, so I can't do my job. The same situation existed yesterday. I struggled for maybe an hour > myself trying to work out the problem and when I contacted you, you > were able to say that it is due to the payment problem which will > hopefully be resolved today. It hasn't, which I find quite worrying. > I am filling in the time watching tutorials on CSS and reading the > spec/documents for \_\_\_\_\_\_\_\_\_\_\_. > > > I was asked to look at \_\_\_\_\_\_\_\_\_\_\_ > and the plan that I was given was that you would get back to me, but > that's not happened. In fact there has been more than one occasion > when you said you would get back to me and you have not been able to - > the time just goes by without any contact. I guess due to the volume > of support that you are all very very busy up at (head office). You > have my sympathy and its great that we are recruiting more people. I > am under quite a lot of stress in my personal life at the moment and > it makes me very anxious when I work in an unstructured environment > with poor communication. Its also frustrating that I want to be > productive and help you out by completing some of these tasks, but I > can't. > > > Kind regards, > Phil > > > He replied with: > > Hi Phil, > > > The problem with your Visual Studio account was fixed yesterday, you should have received an email which I have now > resent. If you still haven't received it please let me know. I will be > in the (your) office tomorrow morning, see you then. > > > Regards, > X > > > He is not a cheerful person and I am anticipating a bit of a backlash when we see him tomorrow. My question is this: **was I wrong in copying in the other directors in the email?** Maybe I should have sent it directly to him first. **Edit:** I spoke to the boss on the phone today and apologised for sending the email, I said that I overreacted. He said that I did and that we need to have a conversation in person. He also made it clear that I am not being fired. Edit: The boss agreed with me that what I wrote was unprofessional and that it was a mistake to involve other people, particularly a non-director. He said it looked like I was trying to 'throw him under a bus'. I said it wasn't my intention to challenge his authority and that I let personal stress (without going into detail) cloud my judgement. He apologised to me for the lack of communication but said he is overworked. In future he said if I need to rant, rant to HIM and don't involve others - except in the rare case when I can't get the right answer out of him (which is unlikely to ever happen). He even said I can discuss personal stuff with him if I need a listening ear. It looks like the boss is a LOT nicer man than I thought. So it is a strong unofficial reprimand. I am embarrassed by my lack of professionalism but the only thing I can do moving forward is to ensure I act professionally in future and this will just be forgotten as a 'blip'.
2019/03/19
[ "https://workplace.stackexchange.com/questions/131948", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/101531/" ]
> > was I wrong in copying in the other directors in the email? > > > Yes, you were wrong. It's not clear what your goal was in copying others, but attempting to embarrass or undermine your boss is not a good career move. > > Maybe I should have sent it directly to him first. > > > Not maybe. You clearly should have sent it to him directly. Even better would have been to call him and talk with him directly. If you wish to succeed in this company, you are going to have to find a way to work well with others, including your boss. Use your face-to-face meeting tomorrow as an opportunity to discuss ways to better communicate. Talk about regular one-on-one meetings. Talk about when you should expect him to be available and when you shouldn't. And talk about what you should do when you need help immediately. You should come out of the meeting with a clearer understand of what communication medium to use in each circumstance. And hopefully, you will know when it is necessary to include others and when it isn't. > > I am under quite a lot of stress in my personal life at the moment and > it makes me very anxious when I work in an unstructured environment > with poor communication. > > > Think long and hard before your meeting and decide how much you want to talk about your home situation with your boss. Unless you are on very good and friendly terms with your boss, the general advice is to leave home issues at home. I have had bosses that I would be okay with sharing my situation, and other bosses where I absolutely wouldn't share. Consider how you want your boss to react if you share what you shared here in your question. Do you want him to be sympathetic and cut you some slack? Do you want him to change his behavior so that you aren't so anxious? The big fear should be that your boss starts to think that you have so much on your plate outside of work that you aren't up to handling this job. Only you have any insight into how your boss might react. Try to be prepared, think it through ahead of time, proceed with caution. Good luck. > > I spoke to the boss on the phone today and apologised for sending the > email, I said that I overreacted. He said that I did and that we need > to have a conversation in person. He also made it clear that I am not > being fired. > > > That's good news. Hopefully you can both now put this behind you, and find a way toward better communication going forward.
**Yes, you were definitely wrong to CC this e-mail.** There are several problems here. Let's take a look: > > Hi X I can't log in to Visual Studio again, so I can't do my job. > > > This may be true, or it may not. There are other editors you could use, such as the free Visual Studio Code, especially if you're primarily editing HTML and CSS. Did you consider focusing on these aspects of the app so you could be productive while you waited to get access to Visual Studio? > > The same situation existed yesterday. I struggled for maybe an hour myself trying to work out the problem and when I contacted you, you were able to say that it is due to the payment problem which will hopefully be resolved today. It hasn't, which I find quite worrying. > > > Your boss probably has quite a lot of things going on. If it isn't his top priority to get you to work, that doesn't mean you need to harass him about it. > > I am filling in the time watching tutorials on CSS and reading the spec/documents for \_\_\_\_\_\_\_\_\_\_\_. > > > This is good; it shows that you're trying to be productive. It's not as good as if you were to find an alternative editor so you could work on the actual product, but it's better than nothing. > > I was asked to look at \_\_\_\_\_\_\_\_\_\_\_ and the plan that I was given was that you would get back to me, but that's not happened. In fact there has been more than one occasion when you said you would get back to me and you have not been able to - the time just goes by without any contact. > > > **Now you're making accusations and criticisms, and worse, you're making them to an audience. To be frank, you're lucky you weren't fired or otherwise reprimanded after sending an e-mail like this.** (Your reprimand may be coming tomorrow.) > > I guess due to the volume of support that you are all very very busy up at (head office). You have my sympathy and its great that we are recruiting more people. > > > This is an attempt at a save after the accusations, but it would've been far better not to make them in the first place. > > I am under quite a lot of stress in my personal life at the moment and it makes me very anxious when I work in an unstructured environment with poor communication. > > > **This is unprofessional, especially to put in an e-mail to a wide audience.** Your job is to do your job regardless of the circumstances in your personal life. Granted, that's not always possible, but if things at home are causing problems in the workplace, that's something to discuss with your boss privately, not to air in an e-mail of this sort. The "unstructured environment with poor communication" phrase is rather insulting to your boss and others who work there and is bound to put them on the defensive. > > Its also frustrating that I want to be productive and help you out by completing some of these tasks, but I can't. Kind regards, \_\_\_ > > > With some reworking this could be a reasonable thing to say, but as it is, it makes you sound rather powerless. Not a good look. Now to other matters. You say you're slow compared to the other developers; does that mean there are other developers in your company? If so, you should be soliciting their help. They might also have suggested installing an alternate editor to get you started while waiting for Visual Studio. As for the CC:, for future reference, **when you CC other people on a communication directed at one person, it's usually a passive-aggressive act.** It's the e-mail equivalent of having a loud argument out in the middle of the office where everyone can hear. In some ways it might even be worse, since it's permanently written. **Your job at this point is to *apologize*.** Sending that e-mail was presumptuous and rude and puts your boss in a bad light. When your boss meets with you tomorrow, the first words out of your mouth should be an apology for sending the e-mail and losing your cool, and some indication that you were able to work around the problem (e.g. with an alternate editor). You are probably on thin ice at this point unless your boss has great reserves of patience, so focus on patching up the rift you've caused.
69,653,414
I’m using axon framework with spring boot version ``` compile("org.axonframework:axon-spring-boot-starter:4.3.3") { exclude group: 'org.axonframework', module: 'axon-server-connector' } ``` Recently I’ve started noticing certain business workflows halting suddenly and when I checked the logs I found this exception ``` Command 'com.example.MyCommand' resulted in org.axonframework.common.lock.LockAcquisitionFailedException(Failed to acquire lock for aggregate identifier(AGG_ID), maximum attempts exceeded (100)) ``` This started occurring suddenly and its getting more frequent with time. The aggregate is configured to use snapshotting ``` @Bean public SnapshotTriggerDefinition MyAggregateSnapshotTriggerDefinition(Snapshotter snapshotter) { return new EventCountSnapshotTriggerDefinition(snapshotter, 200); } ``` This aggregate only has a few running instances and they remain alive for a very long period of time (years) I read that this exception is thrown if a process seems to hold a lock on the aggregate for far too long, meanwhile a command requested the lock and timeouted waiting for it. The aggregate does not hold a big amount of data ``` @Aggregate(snapshotTriggerDefinition = "MyAggregateSnapshotTriggerDefinition") public class MyAggregate { @AggregateIdentifier private String aggId; private boolean paused; private int pausingChangelist; private RequestCause pauseCause; //enum private Seat seat; private Queue<Reservation> reservationQueue; private boolean canPauseBuildPool; ... } ``` NONE of commands dispatched to this aggregate are sent in “sendAndWait” mode. All commands have a small payload and there is no heavy computation being done in the command Handler methods. Its litreally checking some boolean flags and raising events. The event sourcing handlers on the other hand do some logic. They manipulate the reservation queue by polling and inserting reservations. ``` @EventSourcingHandler public void on(CertainEvent event) { // poll from queue if not empty // raise SeatReservedEvent } @EventSourcingHandler public void on(SeatReservedEvent event) { // reserve seat } @EventSourcingHandler public void on(SeatFreedEvent event) { // free the seat // poll from queue // if queue not empty -> raise SeatReservedEvent } @EventSourcingHandler public void on(SeatReservationQueuedEvent event) { // add to queue } ``` The weird thing as well, I checked other posts where this same exception is thrown and they seems all to have the exact same error message but mine is the only that has a different number of attempts (100) ``` LockAcquisitionFailedException: Failed to acquire lock for aggregate identifier(AGG_ID), maximum attempts exceeded (2147483647) ``` I read the code of the PessimisticLockFactory and was able to understand that this number (2147483647) represent the number of times a process tried to acquire the lock on an aggregate. Why is **100** only in my case? (NO extra config was added from my side) How can I solve this issue? how can I monitor the locks on the aggregate? how to know what process aquired the token and wouldn’t release it?
2021/10/20
[ "https://Stackoverflow.com/questions/69653414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9499019/" ]
One of the approaches is to store item names in an array or object and then check if the particular item were selected. Here is another approach you could use: ``` const HomeScreen = () => { const itemsData = [ { name: 'Eggs', image: 'image require here', isSelected: false }, { name: 'Pasta', image: '', isSelected: false }, { name: 'Fish', image: '', isSelected: false }, ]; const [items, setItems] = useState(itemsData); const handleSelectItem = (selectedItemIndex) => { const itemsToSelect = items.map((item, index) => { if (selectedItemIndex === index) item.isSelected = !item.isSelected; return item; }, []); setItems(itemsToSelect); // your logic here // AddToPanetry(item[selectedItemIndex].name) }; const renderItem = (item, index) => { const isSelected = items[index].isSelected; return ( <TouchableOpacity style={[styles.button, isSelected && styles.selectedButton]} onPress={() => handleSelectItem(index)}> {/* <Image source={item.image} /> */} <Text>{item.name}</Text> </TouchableOpacity> ); }; return ( <View> <ScrollView> {itemsData.map((item, index) => renderItem(item, index))} </ScrollView> </View> ); }; const styles = StyleSheet.create({ button: { backgroundColor: 'white', padding: 20, }, selectedButton: { backgroundColor: 'pink', }, }); ```
There are 2 options depending on your needs. 1. You could keep your all of your data and selected state in a single stateful array. On press you need to find the item in the array that should update. ``` import * as React from 'react'; import { Text, StyleSheet, TouchableOpacity, Button, FlatList, SafeAreaView, } from 'react-native'; export default function Grocery({ navigation }) { const [state, setState] = React.useState([ { label: 'pasta', pressed: false, }, { label: 'eggs', pressed: false, }, { label: 'fish', pressed: false, }, { label: 'salad', pressed: false, }, ]); const handlePress = (i) => { const newState = [...state]; newState[i].pressed = !state[i].pressed; setState(newState); }; return ( <SafeAreaView style={{ flex: 1 }}> <FlatList data={state} ListHeaderComponent={() => ( <Button title="home" onPress={() => { console.log('press home'); }}> press </Button> )} renderItem={({ item, index }) => ( <TouchableOpacity key={index} id={index} onPress={() => handlePress(index)} style={[ styles.flatListTouchable, item.pressed && styles.flatListTouchablePressed, ]}> <Text style={styles.flatListTouchableText}>{item.label}</Text> </TouchableOpacity> )} /> </SafeAreaView> ); } const styles = StyleSheet.create({ flatListTouchable: { width: '100%', backgroundColor: 'blue', color: 'white', padding: 30, }, flatListTouchablePressed: { backgroundColor: 'black', }, flatListTouchableText: { color: 'white' } }); ``` [Snack](https://snack.expo.dev/@ksav/hot-mixed-nuts) --- 2. You could keep your data and selected state separately. Selected state is managed in the child component. ``` import * as React from 'react'; import { Text, StyleSheet, TouchableOpacity, Button, FlatList, SafeAreaView, } from 'react-native'; const data = [ { label: 'pasta', }, { label: 'eggs', }, { label: 'fish', }, { label: 'salad', }, ]; export default function Grocery({ navigation }) { return ( <SafeAreaView style={{ flex: 1 }}> <FlatList data={data} ListHeaderComponent={() => ( <Button title="home" onPress={() => { console.log('press home'); }}> press </Button> )} renderItem={({ item, index }) => ( <RenderItem item={item} index={index} /> )} /> </SafeAreaView> ); } const RenderItem = ({ item, index }) => { const [pressed, setPressed] = React.useState(false); const handlePress = () => { setPressed(!pressed); }; return ( <TouchableOpacity key={index} id={index} onPress={handlePress} style={[ styles.flatListTouchable, pressed && styles.flatListTouchablePressed, ]}> <Text style={styles.flatListTouchableText}>{item.label}</Text> </TouchableOpacity> ); }; const styles = StyleSheet.create({ flatListTouchable: { width: '100%', backgroundColor: 'blue', color: 'white', padding: 30, }, flatListTouchablePressed: { backgroundColor: 'black', }, flatListTouchableText: { color: 'white', }, }); ``` [Snack](https://snack.expo.dev/@ksav/lonely-soylent)
73,875,239
I am building my first react-native app for both android and IOS. In order for my app to function, I need to use RNPickerSelect. But for some reason when I try to do ``` <RNPickerSelect onValueChange={(value) => setOrgin(value)} value={orgin} useNativeAndroidPickerStyle={false} items={countries} placeholder={{label: "Country of Orgin", value: null}} style={pickerSelectStyles} /> ``` on android I get "Invalid hook call. Hooks can only be called inside of the body of a function component. " How can I solve this issue
2022/09/28
[ "https://Stackoverflow.com/questions/73875239", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19598817/" ]
``` mysql> show create table mytable; CREATE TABLE `mytable` ( `Owner ID` int DEFAULT NULL, `Contractor ID` int DEFAULT NULL, `Phone Number` varchar(20) DEFAULT NULL ) mysql> select concat('alter table `', table_schema, '`.`', table_name, '` rename column `', column_name, '` to `', replace(column_name, ' ', '_'), '`;') as _sql from information_schema.columns where locate(' ', column_name); +--------------------------------------------------------------------------------+ | _sql | +--------------------------------------------------------------------------------+ | alter table `test`.`mytable` rename column `Contractor ID` to `Contractor_ID`; | | alter table `test`.`mytable` rename column `Owner ID` to `Owner_ID`; | | alter table `test`.`mytable` rename column `Phone Number` to `Phone_Number`; | +--------------------------------------------------------------------------------+ ```
By using @Bill Karwin's answer, if you just want to test it in a specific table first, something like this will work: ``` select concat('alter table `mytable` rename column `', column_name, '` to `', replace(lower(column_name), ' ', '_'), '`;') as _sql from (select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'mytable') as mt where locate(' ', column_name); ```
4,545,624
for my purposes of html parsing, I have implemented a PRODUCER/CONSUMER PATTERN. MY problem is the way in wich I can stop the consumer after that a producer have finished the task and a condivised buffer is emtpy . EXAMPLE: I have one PRODUCER and 5 CONSUMER. The producer stop to work because have complished its tasks. So the Consumer how can know that the producer has finished its work?? I have try to implement: ``` import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; public class MainTest { public static void main(String[] args) { BlockingQueue queue = new LinkedBlockingQueue<String>( ); Producer p = new Producer(queue,"0"); // FOR ALL CONSUMER I PASS THE REFERENCE TO THE UNIQUE PRODUCER !!! Consumer c1=new Consumer(queue,"1",p); Consumer c2=new Consumer(queue,"2",p); Consumer c3=new Consumer(queue,"3",p); Consumer c4=new Consumer(queue,"4",p); Consumer c5=new Consumer(queue,"5",p); p.start(); c1.start();c2.start();c3.start();c4.start();c5.start(); } } THE PRODUCER: class Producer extends Thread{ BlockingQueue<String> queue; public Producer(BlockingQueue<String> queue, String s) { super ("THREAD"+s); this.queue = queue; } @SuppressWarnings("deprecation") public void run(){ int messagecode = 1; boolean flagLavora= true; //ciclo infinito while(flagLavora ){ try { System.out.println("-------------------------------------------------------------"); System.out.println(" : IS ALIVE "+Thread.currentThread().isAlive()+" "); System.out.println(" IS INTERRUPTED "+Thread.currentThread().isInterrupted()+" "); System.out.println( this.getName()+">>"+"PRODUTT Thread"); System.out.println("Producing "+(++messagecode)); queue.put("MESSAGE@"+messagecode); System.out.println(messagecode+" in queue"); System.out.println("SIZE QUEUE:"+queue.size()); if (messagecode %9==0) { System.out.println( "STATE PRODUTT "+ Thread.currentThread().getState()); System.out.println( this.getName()+">>PRODUTT CLOSE"); System.out.println( "IS ALIVE:"+ this.currentThread().isAlive()); flagLavora= false; } System.out.println("-------------------------------------------------------------"); sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } System.out.println( "\n \n EXIT CICLE WHILE \n \n"); } THE CONSUMER: class Consumer extends Thread{ static int id; static Producer produttore=null; int code=0; BlockingQueue<String> queue; public Consumer(BlockingQueue<String> queue,String nameThread, Producer p) { super ("THREADN_ "+nameThread); this.produttore=p; this.queue = queue; code=++id; } public void run(){ while(true){ try { System.out.println("\n -------------------------------------------------------------"); System.out.println("CONSUM "+this.getName()+":"+queue.size()+" SIZE QUEUE"); if (produttore==null){ stop(); } else if ( produttore.getState().compareTo(State.RUNNABLE) ==0 || queue.size()!=0){ System.out.println( this.getName()+">> "+code+" waiting for the message..."); String message = queue.take(); System.out.println("Thread:"+code+" --> "+message+" taken!"); if ( produttore.getState().compareTo(State.RUNNABLE) ==0 || produttore!=null){ System.out.println("NULL PRODUTTORE + RUNNABLE"); System.out.println("CONSUMATORE:"+Thread.currentThread().getName() +" CHIUDE \n"); System.out.println("CONTENUTO PRODUTTORE: "+produttore==null); stop(); } System.out.println("------------------------------------------------------------- \n "); //riposa 2 secondi sleep(2000); } else { sleep(1000); } } catch (InterruptedException e) { e.printStackTrace(); System.err.println("PROBLEMI CONSUMATORE:"+Thread.currentThread().getName()); } } } ``` --- SO I would like Know how to implement the scenario in while, The producer complished the task to add on a queue strings, and when finished, die, and the consumer works until there is something in the queue condivided and the consumer is alive. Who could help me?? THANKS
2010/12/28
[ "https://Stackoverflow.com/questions/4545624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/530607/" ]
I'm not sure to understand. You could use the [Thread.IsAlive()](http://download.oracle.com/javase/1.4.2/docs/api/java/lang/Thread.html#isAlive%28%29) method to know if your Producer Thread is still alive. Your `while` will look like this : ``` while(produttore.isAlive() || !queue.isempty()) ```
Try to approach the problem in a different way. Instead of a blocking queue, create an `Executor` (use the [helper methods in `Executors`](http://download.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/Executors.html)). Then for each task, let the producer submit a task to the executor. Now you can simply wait for the executor to terminate after the producer has submitted all tasks (`ExecutorService.awaitTermination()`).
3,498,945
I need to implement authentication in a php app but using fingerprint as part of credentials. So, sincerely I'm kind of lost here. 1) Do I need a product (reader) with javascript SDK? I've seen some using ActiveX but obviously this will work just for IE. I would like a cross-browser solution here. 2) On server side, I suppose I'll natively call some C/C++/Java libs from my php code. Is it right? As you can see, any paper/orientation you could give me would be appreciated.
2010/08/17
[ "https://Stackoverflow.com/questions/3498945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/347527/" ]
Jaison, "you cannot do it" and "PHP" don't belong in the same sentence. Berserkpi, you *can* do this in PHP, but only parts of it. I don't know about the hardware but I can generalize the parameters of your project. Fingerprinting is going to have to be done on some sort of client machine. That means a fingerprint-reading device hooked up to something like a computer, probably through a USB or other serial connection. I can't tell you how that fingerprinting is going to work, but you'll need to get a program running on the machine that submits your fingerprints for authentication. Those fingerprints are going to be sent to a server, probably through a POST request and a PHP API you've set up. This is going to be the toughest part. The tough part is that you need those prints to be consistant -- w/web apps you don't get in with a password that kinds of looks like your password; either the user can be authenticated or the password is rejected. With fingerprints that may not be the case. Whatever it is, so long as it's consistant you can consider it more or less like an MD5 hash. You match it against a hashed version you store in your database and if it matches you authenticate her by generating a token (maybe another MD5) hash that is good for an hour or so.
You cannot do this using PHP - it's a scripting language. However, you can use .NET technologies like C# or VB for hardware porting. My idea: 1. Handle authentication using .NET technologies. 2. Pass the authentication result to PHP using ASP like embedding result in XML/JSON I don't know how much success rate you will get from this solution, but it's worth a try.
3,498,945
I need to implement authentication in a php app but using fingerprint as part of credentials. So, sincerely I'm kind of lost here. 1) Do I need a product (reader) with javascript SDK? I've seen some using ActiveX but obviously this will work just for IE. I would like a cross-browser solution here. 2) On server side, I suppose I'll natively call some C/C++/Java libs from my php code. Is it right? As you can see, any paper/orientation you could give me would be appreciated.
2010/08/17
[ "https://Stackoverflow.com/questions/3498945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/347527/" ]
we made a small app using c# to handle fingerprint scanning and converted the output to binary file. theoretically it shd be compared with wats available on the server and returns a result which determines if the user gets authenticated or not. another method is to use a windows app that works with the fingerprint hardware and posses a simple web browser. once the user gets authenticated it will call a url with and arg that only the coder knows.
You cannot do this using PHP - it's a scripting language. However, you can use .NET technologies like C# or VB for hardware porting. My idea: 1. Handle authentication using .NET technologies. 2. Pass the authentication result to PHP using ASP like embedding result in XML/JSON I don't know how much success rate you will get from this solution, but it's worth a try.
3,498,945
I need to implement authentication in a php app but using fingerprint as part of credentials. So, sincerely I'm kind of lost here. 1) Do I need a product (reader) with javascript SDK? I've seen some using ActiveX but obviously this will work just for IE. I would like a cross-browser solution here. 2) On server side, I suppose I'll natively call some C/C++/Java libs from my php code. Is it right? As you can see, any paper/orientation you could give me would be appreciated.
2010/08/17
[ "https://Stackoverflow.com/questions/3498945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/347527/" ]
i have came across a library, [php\_zklib](https://github.com/dnaextrim/php_zklib) it does seem to work with biometric devices. But Problem is there is no documentation of it over the internet.. I have seen someone Using Fingerprint device for attendance using this library.
You cannot do this using PHP - it's a scripting language. However, you can use .NET technologies like C# or VB for hardware porting. My idea: 1. Handle authentication using .NET technologies. 2. Pass the authentication result to PHP using ASP like embedding result in XML/JSON I don't know how much success rate you will get from this solution, but it's worth a try.
3,498,945
I need to implement authentication in a php app but using fingerprint as part of credentials. So, sincerely I'm kind of lost here. 1) Do I need a product (reader) with javascript SDK? I've seen some using ActiveX but obviously this will work just for IE. I would like a cross-browser solution here. 2) On server side, I suppose I'll natively call some C/C++/Java libs from my php code. Is it right? As you can see, any paper/orientation you could give me would be appreciated.
2010/08/17
[ "https://Stackoverflow.com/questions/3498945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/347527/" ]
Look at here. They have Java, PHP, web app aupported SDK and hardware for biometric authentication. <http://www.m2sys.com/bioplugin/>
You cannot do this using PHP - it's a scripting language. However, you can use .NET technologies like C# or VB for hardware porting. My idea: 1. Handle authentication using .NET technologies. 2. Pass the authentication result to PHP using ASP like embedding result in XML/JSON I don't know how much success rate you will get from this solution, but it's worth a try.
3,498,945
I need to implement authentication in a php app but using fingerprint as part of credentials. So, sincerely I'm kind of lost here. 1) Do I need a product (reader) with javascript SDK? I've seen some using ActiveX but obviously this will work just for IE. I would like a cross-browser solution here. 2) On server side, I suppose I'll natively call some C/C++/Java libs from my php code. Is it right? As you can see, any paper/orientation you could give me would be appreciated.
2010/08/17
[ "https://Stackoverflow.com/questions/3498945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/347527/" ]
Jaison, "you cannot do it" and "PHP" don't belong in the same sentence. Berserkpi, you *can* do this in PHP, but only parts of it. I don't know about the hardware but I can generalize the parameters of your project. Fingerprinting is going to have to be done on some sort of client machine. That means a fingerprint-reading device hooked up to something like a computer, probably through a USB or other serial connection. I can't tell you how that fingerprinting is going to work, but you'll need to get a program running on the machine that submits your fingerprints for authentication. Those fingerprints are going to be sent to a server, probably through a POST request and a PHP API you've set up. This is going to be the toughest part. The tough part is that you need those prints to be consistant -- w/web apps you don't get in with a password that kinds of looks like your password; either the user can be authenticated or the password is rejected. With fingerprints that may not be the case. Whatever it is, so long as it's consistant you can consider it more or less like an MD5 hash. You match it against a hashed version you store in your database and if it matches you authenticate her by generating a token (maybe another MD5) hash that is good for an hour or so.
we made a small app using c# to handle fingerprint scanning and converted the output to binary file. theoretically it shd be compared with wats available on the server and returns a result which determines if the user gets authenticated or not. another method is to use a windows app that works with the fingerprint hardware and posses a simple web browser. once the user gets authenticated it will call a url with and arg that only the coder knows.
3,498,945
I need to implement authentication in a php app but using fingerprint as part of credentials. So, sincerely I'm kind of lost here. 1) Do I need a product (reader) with javascript SDK? I've seen some using ActiveX but obviously this will work just for IE. I would like a cross-browser solution here. 2) On server side, I suppose I'll natively call some C/C++/Java libs from my php code. Is it right? As you can see, any paper/orientation you could give me would be appreciated.
2010/08/17
[ "https://Stackoverflow.com/questions/3498945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/347527/" ]
Jaison, "you cannot do it" and "PHP" don't belong in the same sentence. Berserkpi, you *can* do this in PHP, but only parts of it. I don't know about the hardware but I can generalize the parameters of your project. Fingerprinting is going to have to be done on some sort of client machine. That means a fingerprint-reading device hooked up to something like a computer, probably through a USB or other serial connection. I can't tell you how that fingerprinting is going to work, but you'll need to get a program running on the machine that submits your fingerprints for authentication. Those fingerprints are going to be sent to a server, probably through a POST request and a PHP API you've set up. This is going to be the toughest part. The tough part is that you need those prints to be consistant -- w/web apps you don't get in with a password that kinds of looks like your password; either the user can be authenticated or the password is rejected. With fingerprints that may not be the case. Whatever it is, so long as it's consistant you can consider it more or less like an MD5 hash. You match it against a hashed version you store in your database and if it matches you authenticate her by generating a token (maybe another MD5) hash that is good for an hour or so.
i have came across a library, [php\_zklib](https://github.com/dnaextrim/php_zklib) it does seem to work with biometric devices. But Problem is there is no documentation of it over the internet.. I have seen someone Using Fingerprint device for attendance using this library.
3,498,945
I need to implement authentication in a php app but using fingerprint as part of credentials. So, sincerely I'm kind of lost here. 1) Do I need a product (reader) with javascript SDK? I've seen some using ActiveX but obviously this will work just for IE. I would like a cross-browser solution here. 2) On server side, I suppose I'll natively call some C/C++/Java libs from my php code. Is it right? As you can see, any paper/orientation you could give me would be appreciated.
2010/08/17
[ "https://Stackoverflow.com/questions/3498945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/347527/" ]
Jaison, "you cannot do it" and "PHP" don't belong in the same sentence. Berserkpi, you *can* do this in PHP, but only parts of it. I don't know about the hardware but I can generalize the parameters of your project. Fingerprinting is going to have to be done on some sort of client machine. That means a fingerprint-reading device hooked up to something like a computer, probably through a USB or other serial connection. I can't tell you how that fingerprinting is going to work, but you'll need to get a program running on the machine that submits your fingerprints for authentication. Those fingerprints are going to be sent to a server, probably through a POST request and a PHP API you've set up. This is going to be the toughest part. The tough part is that you need those prints to be consistant -- w/web apps you don't get in with a password that kinds of looks like your password; either the user can be authenticated or the password is rejected. With fingerprints that may not be the case. Whatever it is, so long as it's consistant you can consider it more or less like an MD5 hash. You match it against a hashed version you store in your database and if it matches you authenticate her by generating a token (maybe another MD5) hash that is good for an hour or so.
Look at here. They have Java, PHP, web app aupported SDK and hardware for biometric authentication. <http://www.m2sys.com/bioplugin/>
64,716
> > Drax: You, Quill, are my friend. This dumb tree is my friend. And this green whore is now my... > > > Gamora: You must stop! > > > Drax's statement seems incongruous with reality and his character. * There isn't so much as single kiss in the entire movie, including involving Gamora. * Drax's speech is precise and literal. * Drax isn't generally disrespectful toward women * Gamora resists Peter's advances, saying that she isn't one of the dumb girls he seduces. * While Gamora's attire is not entirely modest, it is not out of the norm either. (Drax himself is half-naked throughout the entire movie.) * At the time he says this, Drax has no motivation to disparage Gamora. His only intention could be honesty. * In jail, Rocket suggests Gamora work out an "exchange" with the guards for a control device, since they find her attractive. Gamora says, "You must be joking." Why did Drax call Gamora a whore?
2014/08/03
[ "https://scifi.stackexchange.com/questions/64716", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/24067/" ]
### Because the prisoners were calling Gamora a "green whore" when she first entered the prison yard, and Drax is incredibly literal. He has no clue they were using it as an insult; he thinks that's what she actually was. * The problem is if you weren't really listening it was easy to miss,there was a lot going on in that scene. * When Drax says it again later in the scene you mention, it is far away enough from the initial event, it may not even register as part of a running gag and can come off extremely insensitive to Gamora (and movie viewers who watched her). **Writer/director James Gunn has answered this question:** > > **[Gunn on Drax calling Gamora a whore](http://www.comicbookresources.com/?page=article&id=58710):** I know some of you don't like Drax calling Gamora a whore. But he heard people saying that to her in the Kyln. So don't blame him, blame me... Because that's what they called her in the Kyln and that's what he thinks she is. > > >
> > Whore, noun: > > > [Definition of WHORE](http://www.merriam-webster.com/dictionary/whore) > > > 1 : A woman who engages in sexual acts for money : prostitute ; also : a promiscuous or immoral woman > > 2 : A male who engages in sexual acts for money > > 3 : A venal or unscrupulous person > > Merriam-Webster Dictionary > > > If Drax does truly say things literally he would have said it in the third definition of this word. He believed that she was a venal or unscrupulous person In reference to her background, how many she has killed, who raised her, it would all make sense that it fits the third definition.
9,240,471
What it says above. Unsurprisingly, I couldn't find a clear answer to this. I just want to know if calling it more than once in a script will cause a problem.
2012/02/11
[ "https://Stackoverflow.com/questions/9240471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/471436/" ]
Quoting [**the manual**](http://fr2.php.net/session_start) : > > As of PHP 4.3.3, calling `session_start()` after the session was > previously started will result in an error of level `E_NOTICE`. > > Also, the second session start will simply be ignored. > > > So, it will not do much -- except raise a notice, which indicates there is some kind of a *problem* ; which means you should not call this function more than once. **Edit after @hakre's comment :** Just to be sure, I've tested with the following portion of code, which calls session\_start() twice, after making sure errors and notices get reported : ``` <?php ini_set('display_errors', 'on'); error_reporting(E_ALL | E_STRICT); session_start(); session_start(); ``` And I do get the following notice : ``` Notice: A session had already been started - ignoring session_start() in /.../temp.php on line 6 ```
No, `session_start` is not idempotent, it has dependencies in the runtime state of the language. You can normally call it more than once which could give you some warnings or errors without much of a difference, however, if you change the session state and/or configuration between calls, the function won't behave the same. As calling the function changes the session state, by a very strict view on idempotent, it's totally not. Additionally, it's important to note that the outcome of that function in correspondence to `$_SESSION` remains defined by the associated store, session name and session id.
9,240,471
What it says above. Unsurprisingly, I couldn't find a clear answer to this. I just want to know if calling it more than once in a script will cause a problem.
2012/02/11
[ "https://Stackoverflow.com/questions/9240471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/471436/" ]
Quoting [**the manual**](http://fr2.php.net/session_start) : > > As of PHP 4.3.3, calling `session_start()` after the session was > previously started will result in an error of level `E_NOTICE`. > > Also, the second session start will simply be ignored. > > > So, it will not do much -- except raise a notice, which indicates there is some kind of a *problem* ; which means you should not call this function more than once. **Edit after @hakre's comment :** Just to be sure, I've tested with the following portion of code, which calls session\_start() twice, after making sure errors and notices get reported : ``` <?php ini_set('display_errors', 'on'); error_reporting(E_ALL | E_STRICT); session_start(); session_start(); ``` And I do get the following notice : ``` Notice: A session had already been started - ignoring session_start() in /.../temp.php on line 6 ```
It will cause an error (session already started). But if you ignore the error, it would be idempotent. In PHP 5.4, we'll get: <http://nl3.php.net/manual/en/function.session-status.php>
20,444,748
I work on branch, let name it `mybranch`. I do not modify `master`. I want to push changes on `origin/feature/mybranch` but I have some problems. What is strange I've done it before a few times and I didn't have any problems. ``` $ git branch develop * feature/mybranch master $ git push To http://...... ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'http://....' hint: Updates were rejected because a pushed branch tip is behind its remote hint: counterpart. If you did not intend to push that branch, you may want to hint: specify branches to push or set the 'push.default' configuration variable hint: to 'simple', 'current' or 'upstream' to push only the current branch. ``` What? Master?! So lets check the `master`. ``` $ git checkout master Switched to branch 'master' Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded. (use "git pull" to update your local branch) $ git pull Updating 45c7319..f6b8e97 error: Your local changes to the following files would be overwritten by merge: platform/....java services/....java ... Please, commit your changes or stash them before you can merge. Aborting ``` This shows 7 modified files. ``` $ git status # On branch master # Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded. # (use "git pull" to update your local branch) # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: platform/....java # modified: algorithms/....java # ... # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # algorithms/.../ # and over 1100 files in bin folder. I don't know why gitignore doesn't work now. ``` This shows 17 (not 7 as above) modified files. Weird ... nevermind. These are not my changes, I want to discard them. ``` $ git checkout -f Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded. (use "git pull" to update your local branch) ``` And I still have these strange changes in `master`...
2013/12/07
[ "https://Stackoverflow.com/questions/20444748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/585773/" ]
1. Your first `git push` failed because your `master` is behind `origin/master`, so it cannot be pushed safely. The error message explained this. 2. Then after `git checkout master` the `git pull` didn't work because you had pending changes that would conflict with the incoming changes from `origin/master`. You must have had these pending changes before you switched the branch with `git checkout master`. As the error message suggests, you should either commit these changes, or stash them. A third option is to discard them, which you did with `git checkout -f` Since you did `git checkout -f`, there should be no more pending changes and `git pull` would work, unless you have staged changes. If you have staged changes, and you're sure you don't need them, you should get rid of them too, with `git reset` or `git reset --hard`. But be careful, those changes will be completely lost.
Seems like you have a conflict in one of the files you changed. Just add them and commit, after that you will be able to pull. It's also possible that after pull you will have to resolve a conflict and then commit again. I hope it helps!
20,444,748
I work on branch, let name it `mybranch`. I do not modify `master`. I want to push changes on `origin/feature/mybranch` but I have some problems. What is strange I've done it before a few times and I didn't have any problems. ``` $ git branch develop * feature/mybranch master $ git push To http://...... ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'http://....' hint: Updates were rejected because a pushed branch tip is behind its remote hint: counterpart. If you did not intend to push that branch, you may want to hint: specify branches to push or set the 'push.default' configuration variable hint: to 'simple', 'current' or 'upstream' to push only the current branch. ``` What? Master?! So lets check the `master`. ``` $ git checkout master Switched to branch 'master' Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded. (use "git pull" to update your local branch) $ git pull Updating 45c7319..f6b8e97 error: Your local changes to the following files would be overwritten by merge: platform/....java services/....java ... Please, commit your changes or stash them before you can merge. Aborting ``` This shows 7 modified files. ``` $ git status # On branch master # Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded. # (use "git pull" to update your local branch) # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: platform/....java # modified: algorithms/....java # ... # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # algorithms/.../ # and over 1100 files in bin folder. I don't know why gitignore doesn't work now. ``` This shows 17 (not 7 as above) modified files. Weird ... nevermind. These are not my changes, I want to discard them. ``` $ git checkout -f Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded. (use "git pull" to update your local branch) ``` And I still have these strange changes in `master`...
2013/12/07
[ "https://Stackoverflow.com/questions/20444748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/585773/" ]
check your master ``` git diff ``` if there no changes, still you get a same problem check for un tracked files add files and stash taht files after that pull your original master and try to push again
Seems like you have a conflict in one of the files you changed. Just add them and commit, after that you will be able to pull. It's also possible that after pull you will have to resolve a conflict and then commit again. I hope it helps!
20,444,748
I work on branch, let name it `mybranch`. I do not modify `master`. I want to push changes on `origin/feature/mybranch` but I have some problems. What is strange I've done it before a few times and I didn't have any problems. ``` $ git branch develop * feature/mybranch master $ git push To http://...... ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'http://....' hint: Updates were rejected because a pushed branch tip is behind its remote hint: counterpart. If you did not intend to push that branch, you may want to hint: specify branches to push or set the 'push.default' configuration variable hint: to 'simple', 'current' or 'upstream' to push only the current branch. ``` What? Master?! So lets check the `master`. ``` $ git checkout master Switched to branch 'master' Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded. (use "git pull" to update your local branch) $ git pull Updating 45c7319..f6b8e97 error: Your local changes to the following files would be overwritten by merge: platform/....java services/....java ... Please, commit your changes or stash them before you can merge. Aborting ``` This shows 7 modified files. ``` $ git status # On branch master # Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded. # (use "git pull" to update your local branch) # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: platform/....java # modified: algorithms/....java # ... # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # algorithms/.../ # and over 1100 files in bin folder. I don't know why gitignore doesn't work now. ``` This shows 17 (not 7 as above) modified files. Weird ... nevermind. These are not my changes, I want to discard them. ``` $ git checkout -f Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded. (use "git pull" to update your local branch) ``` And I still have these strange changes in `master`...
2013/12/07
[ "https://Stackoverflow.com/questions/20444748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/585773/" ]
Part 1: Getting your push done without worrying about `master` -------------------------------------------------------------- (Note: actually, it's already done. See note towards the bottom of part 1.) You're running `git push` with no additional arguments. If you run `git push` with two more arguments, they specify exactly what to push where. The git documents call these the `<repository>` and the `<refspec>`. In your case, the repository is always `origin` (which is the usual standard one git sets up when you clone something). So the `refspec` is the more interesting part. Here's the long1 form: ``` git push origin feature/mybranch:feature/mybranch ``` This limits git to only attempting to push your branch `feature/mybranch`, telling the remote, `origin`, that it should update the branch `feature/mybranch` on *its* side too. If you leave out the `:<same-name>` part, the default is to use the branch name on the left of the colon, so: ``` git push origin feature/mybranch ``` does exactly the same thing, with a bit less command-typing. Now, what happens when you leave out the `<refspec>`? The answer is in the [git push](https://www.kernel.org/pub/software/scm/git/docs/git-push.html) and [git config](https://www.kernel.org/pub/software/scm/git/docs/git-config.html) documentation, although in my 1.8.4.3 text version it's really hard to read, and the on-line version I linked to above is, if anything, worse: :-) > > When the command line does not specify what to push with <refspec>... > arguments or --all, --mirror, --tags options, the command finds the > default by consulting remote.\*.push configuration, and if it > is not found, honors push.default configuration to decide what to push > (See gitlink:git-config[1] for the meaning of push.default). > > > To simplify this a lot, I can tell2 that you have not set either `remote.origin.push` or `push.default`, so you're getting the "default default", which is called `matching`, which means your `git push` calls up `origin` on the metaphorical Internet-phone and says > > Hey, what branches do ya got? > > > and it says: > > I have `master` and `feature/mybranch`. > > > So your git then says: > > OK, well, here's what I think `master` should be, and here's what I think `feature/mybranch` should be. > > > To which he says: > > Whoa there buddy, that would set `master` back a couple of revs! > > > ... and that's when you got the `! [rejected] master -> master (non-fast-forward)` thing. So, there's a couple of really simple solutions. ### Solution #0: do nothing If you still have the original `push` output available, you should be able to see something like this: ``` a430f6d..676699a feature/mybranch -> feature/mybranch ! [rejected] master -> master (non-fast-forward) ``` This means that *even though the change for `master -> master` was rejected*, the change for `feature/mybranch -> feature/mybranch` was accepted. The branch you wanted to push, you did! You just got this annoying error message to go with the success (and now you're wondering what to do with branch `master`). ### Solution #1: be explicit in the `push` If you run: ``` git push origin feature/mybranch ``` your Git and origin's Git will have a shorter conversation. Instead of your Git asking him "hey, whaddaya got there?" and then trying to push *all* "matching" branches, yours will just say: "I have some updates for `feature/mybranch`". The fact that you're behind on `master` will be irrelevant; neither you, nor your Git, nor the remote Git will look there. ### Solution #2: change your `push.default` This only works if your git is new enough, although by now, most are: ``` git config --global push.default simple ``` The Git folks ~~are planning to change~~ changed (as of Git version 2.0) the "default default", because `matching` turns out to be more annoying than helpful, a lot of the time. The new "default default" will be `simple`. (For details on what this means, see [the git config documentation](https://www.kernel.org/pub/software/scm/git/docs/git-config.html).) (Setting the `--global` version will change the default default for you, but not for other people. If any repositories—your own, or others—have a local `push.default` setting, that will override your personal global setting, but for those that don't, your global setting is the one git will use. You can choose instead to set the local setting in each repo, which will affect you and anyone else who uses your own repos, but then you need to remember to set it in all your repos.) --- 1Actually this is only the semi-long form: you can add `refs/heads/` in front of each branch name to make it even longer. That's just for showing off though. :-) 2I'm just guessing, really, but it's a pretty safe bet. Someone who configures `remote.origin.push` and `push.default` probably already knows all of this stuff. --- Part 2: Why won't `master` update? ---------------------------------- I'm much less sure about this, but it looks as though someone had accidentally committed a bunch of (17) `.java` binaries into the `master` branch, probably from not having a correct `.gitignore`. At some point they noticed, oops, didn't want all these binaries! So they updated `.gitignore` and committed that, but probably didn't actually `git rm --cached` all of them, so some are still being tracked. If a file that is now listed as ignored was previously committed, git "obeys the commit" rather than the ignore directive, and you get a lot of this: ``` # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: bin/b1 ``` Depending on how you `git add` and what's in the `.gitignore` it's possible to add the in-repository tracked files (that are overriding the ignore entry), and make them "staged for commit" and commit them. In any case, your `master` is two revs behind, and definitely has some binaries in it—and it's possible that your `feature/mybranch` branch has a "bad" `.gitignore` (some variation on it) that also does not ignore the "right set" of binaries. Git notices that 7 of your binaries (perhaps re-built with your feature branch features) don't match what's checked in on the `master` branch. These would be "unsafely" clobbered (at least, as far as git can tell). If/when you do `git checkout -f master` (or something equivalent), git clobbers them after all, but you are still left with "untracked" files, implying a bad `.gitignore`. Once you're quite certain that it's safe to clobber anything in your work-tree—that you have all *your* work saved away—you can do this to resync your `master` to `origin/master`: ``` git checkout -f master git fetch # resync with origin in case they've fixed more stuff git reset --hard origin/master ``` Assuming you don't want binaries in the branches, check over the various `.gitignore` files and make sure they're correct—you'll probably need to fix some. Then, use `git ls-files` and/or `git ls-tree` to see what's in the index and repo (`git ls-tree` requires that you specify a particular tree object, e.g., `git ls-tree HEAD:bin` to see what's in the `bin` tree, if it exists). To remove committed (even though ignored) files, e.g., to remove everything in `bin`: ``` git rm --cached -r bin ``` (the `--cached` says only remove things in the index), or you can allow git to remove the binaries. Once you have the right stuff "git rm"-ed and any updated `.gitignore` files added, `git commit` the changes: ``` $ cat bin/.gitignore * !.gitignore $ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: bin/.gitignore # deleted: bin/b1 # deleted: bin/b2 # $ git commit -m 'remove binaries, ignore them in the future' [master ac60888] remove binaries, ignore them in the future 3 files changed, 1 insertion(+) create mode 100644 bin/.gitignore delete mode 100644 bin/b1 delete mode 100644 bin/b2 ``` (Finally, rebuild any removed binaries as needed, run tests, do a push if appropriate, etc.) (It's possible that you *do* want the `.java` binaries in the branches, or that you don't and yet no one has fixed up any `.gitignore` entries, etc.; so that's why I'm much less sure about this.)
Seems like you have a conflict in one of the files you changed. Just add them and commit, after that you will be able to pull. It's also possible that after pull you will have to resolve a conflict and then commit again. I hope it helps!
20,444,748
I work on branch, let name it `mybranch`. I do not modify `master`. I want to push changes on `origin/feature/mybranch` but I have some problems. What is strange I've done it before a few times and I didn't have any problems. ``` $ git branch develop * feature/mybranch master $ git push To http://...... ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'http://....' hint: Updates were rejected because a pushed branch tip is behind its remote hint: counterpart. If you did not intend to push that branch, you may want to hint: specify branches to push or set the 'push.default' configuration variable hint: to 'simple', 'current' or 'upstream' to push only the current branch. ``` What? Master?! So lets check the `master`. ``` $ git checkout master Switched to branch 'master' Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded. (use "git pull" to update your local branch) $ git pull Updating 45c7319..f6b8e97 error: Your local changes to the following files would be overwritten by merge: platform/....java services/....java ... Please, commit your changes or stash them before you can merge. Aborting ``` This shows 7 modified files. ``` $ git status # On branch master # Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded. # (use "git pull" to update your local branch) # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: platform/....java # modified: algorithms/....java # ... # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # algorithms/.../ # and over 1100 files in bin folder. I don't know why gitignore doesn't work now. ``` This shows 17 (not 7 as above) modified files. Weird ... nevermind. These are not my changes, I want to discard them. ``` $ git checkout -f Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded. (use "git pull" to update your local branch) ``` And I still have these strange changes in `master`...
2013/12/07
[ "https://Stackoverflow.com/questions/20444748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/585773/" ]
Part 1: Getting your push done without worrying about `master` -------------------------------------------------------------- (Note: actually, it's already done. See note towards the bottom of part 1.) You're running `git push` with no additional arguments. If you run `git push` with two more arguments, they specify exactly what to push where. The git documents call these the `<repository>` and the `<refspec>`. In your case, the repository is always `origin` (which is the usual standard one git sets up when you clone something). So the `refspec` is the more interesting part. Here's the long1 form: ``` git push origin feature/mybranch:feature/mybranch ``` This limits git to only attempting to push your branch `feature/mybranch`, telling the remote, `origin`, that it should update the branch `feature/mybranch` on *its* side too. If you leave out the `:<same-name>` part, the default is to use the branch name on the left of the colon, so: ``` git push origin feature/mybranch ``` does exactly the same thing, with a bit less command-typing. Now, what happens when you leave out the `<refspec>`? The answer is in the [git push](https://www.kernel.org/pub/software/scm/git/docs/git-push.html) and [git config](https://www.kernel.org/pub/software/scm/git/docs/git-config.html) documentation, although in my 1.8.4.3 text version it's really hard to read, and the on-line version I linked to above is, if anything, worse: :-) > > When the command line does not specify what to push with <refspec>... > arguments or --all, --mirror, --tags options, the command finds the > default by consulting remote.\*.push configuration, and if it > is not found, honors push.default configuration to decide what to push > (See gitlink:git-config[1] for the meaning of push.default). > > > To simplify this a lot, I can tell2 that you have not set either `remote.origin.push` or `push.default`, so you're getting the "default default", which is called `matching`, which means your `git push` calls up `origin` on the metaphorical Internet-phone and says > > Hey, what branches do ya got? > > > and it says: > > I have `master` and `feature/mybranch`. > > > So your git then says: > > OK, well, here's what I think `master` should be, and here's what I think `feature/mybranch` should be. > > > To which he says: > > Whoa there buddy, that would set `master` back a couple of revs! > > > ... and that's when you got the `! [rejected] master -> master (non-fast-forward)` thing. So, there's a couple of really simple solutions. ### Solution #0: do nothing If you still have the original `push` output available, you should be able to see something like this: ``` a430f6d..676699a feature/mybranch -> feature/mybranch ! [rejected] master -> master (non-fast-forward) ``` This means that *even though the change for `master -> master` was rejected*, the change for `feature/mybranch -> feature/mybranch` was accepted. The branch you wanted to push, you did! You just got this annoying error message to go with the success (and now you're wondering what to do with branch `master`). ### Solution #1: be explicit in the `push` If you run: ``` git push origin feature/mybranch ``` your Git and origin's Git will have a shorter conversation. Instead of your Git asking him "hey, whaddaya got there?" and then trying to push *all* "matching" branches, yours will just say: "I have some updates for `feature/mybranch`". The fact that you're behind on `master` will be irrelevant; neither you, nor your Git, nor the remote Git will look there. ### Solution #2: change your `push.default` This only works if your git is new enough, although by now, most are: ``` git config --global push.default simple ``` The Git folks ~~are planning to change~~ changed (as of Git version 2.0) the "default default", because `matching` turns out to be more annoying than helpful, a lot of the time. The new "default default" will be `simple`. (For details on what this means, see [the git config documentation](https://www.kernel.org/pub/software/scm/git/docs/git-config.html).) (Setting the `--global` version will change the default default for you, but not for other people. If any repositories—your own, or others—have a local `push.default` setting, that will override your personal global setting, but for those that don't, your global setting is the one git will use. You can choose instead to set the local setting in each repo, which will affect you and anyone else who uses your own repos, but then you need to remember to set it in all your repos.) --- 1Actually this is only the semi-long form: you can add `refs/heads/` in front of each branch name to make it even longer. That's just for showing off though. :-) 2I'm just guessing, really, but it's a pretty safe bet. Someone who configures `remote.origin.push` and `push.default` probably already knows all of this stuff. --- Part 2: Why won't `master` update? ---------------------------------- I'm much less sure about this, but it looks as though someone had accidentally committed a bunch of (17) `.java` binaries into the `master` branch, probably from not having a correct `.gitignore`. At some point they noticed, oops, didn't want all these binaries! So they updated `.gitignore` and committed that, but probably didn't actually `git rm --cached` all of them, so some are still being tracked. If a file that is now listed as ignored was previously committed, git "obeys the commit" rather than the ignore directive, and you get a lot of this: ``` # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: bin/b1 ``` Depending on how you `git add` and what's in the `.gitignore` it's possible to add the in-repository tracked files (that are overriding the ignore entry), and make them "staged for commit" and commit them. In any case, your `master` is two revs behind, and definitely has some binaries in it—and it's possible that your `feature/mybranch` branch has a "bad" `.gitignore` (some variation on it) that also does not ignore the "right set" of binaries. Git notices that 7 of your binaries (perhaps re-built with your feature branch features) don't match what's checked in on the `master` branch. These would be "unsafely" clobbered (at least, as far as git can tell). If/when you do `git checkout -f master` (or something equivalent), git clobbers them after all, but you are still left with "untracked" files, implying a bad `.gitignore`. Once you're quite certain that it's safe to clobber anything in your work-tree—that you have all *your* work saved away—you can do this to resync your `master` to `origin/master`: ``` git checkout -f master git fetch # resync with origin in case they've fixed more stuff git reset --hard origin/master ``` Assuming you don't want binaries in the branches, check over the various `.gitignore` files and make sure they're correct—you'll probably need to fix some. Then, use `git ls-files` and/or `git ls-tree` to see what's in the index and repo (`git ls-tree` requires that you specify a particular tree object, e.g., `git ls-tree HEAD:bin` to see what's in the `bin` tree, if it exists). To remove committed (even though ignored) files, e.g., to remove everything in `bin`: ``` git rm --cached -r bin ``` (the `--cached` says only remove things in the index), or you can allow git to remove the binaries. Once you have the right stuff "git rm"-ed and any updated `.gitignore` files added, `git commit` the changes: ``` $ cat bin/.gitignore * !.gitignore $ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: bin/.gitignore # deleted: bin/b1 # deleted: bin/b2 # $ git commit -m 'remove binaries, ignore them in the future' [master ac60888] remove binaries, ignore them in the future 3 files changed, 1 insertion(+) create mode 100644 bin/.gitignore delete mode 100644 bin/b1 delete mode 100644 bin/b2 ``` (Finally, rebuild any removed binaries as needed, run tests, do a push if appropriate, etc.) (It's possible that you *do* want the `.java` binaries in the branches, or that you don't and yet no one has fixed up any `.gitignore` entries, etc.; so that's why I'm much less sure about this.)
1. Your first `git push` failed because your `master` is behind `origin/master`, so it cannot be pushed safely. The error message explained this. 2. Then after `git checkout master` the `git pull` didn't work because you had pending changes that would conflict with the incoming changes from `origin/master`. You must have had these pending changes before you switched the branch with `git checkout master`. As the error message suggests, you should either commit these changes, or stash them. A third option is to discard them, which you did with `git checkout -f` Since you did `git checkout -f`, there should be no more pending changes and `git pull` would work, unless you have staged changes. If you have staged changes, and you're sure you don't need them, you should get rid of them too, with `git reset` or `git reset --hard`. But be careful, those changes will be completely lost.
20,444,748
I work on branch, let name it `mybranch`. I do not modify `master`. I want to push changes on `origin/feature/mybranch` but I have some problems. What is strange I've done it before a few times and I didn't have any problems. ``` $ git branch develop * feature/mybranch master $ git push To http://...... ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'http://....' hint: Updates were rejected because a pushed branch tip is behind its remote hint: counterpart. If you did not intend to push that branch, you may want to hint: specify branches to push or set the 'push.default' configuration variable hint: to 'simple', 'current' or 'upstream' to push only the current branch. ``` What? Master?! So lets check the `master`. ``` $ git checkout master Switched to branch 'master' Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded. (use "git pull" to update your local branch) $ git pull Updating 45c7319..f6b8e97 error: Your local changes to the following files would be overwritten by merge: platform/....java services/....java ... Please, commit your changes or stash them before you can merge. Aborting ``` This shows 7 modified files. ``` $ git status # On branch master # Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded. # (use "git pull" to update your local branch) # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: platform/....java # modified: algorithms/....java # ... # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # algorithms/.../ # and over 1100 files in bin folder. I don't know why gitignore doesn't work now. ``` This shows 17 (not 7 as above) modified files. Weird ... nevermind. These are not my changes, I want to discard them. ``` $ git checkout -f Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded. (use "git pull" to update your local branch) ``` And I still have these strange changes in `master`...
2013/12/07
[ "https://Stackoverflow.com/questions/20444748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/585773/" ]
Part 1: Getting your push done without worrying about `master` -------------------------------------------------------------- (Note: actually, it's already done. See note towards the bottom of part 1.) You're running `git push` with no additional arguments. If you run `git push` with two more arguments, they specify exactly what to push where. The git documents call these the `<repository>` and the `<refspec>`. In your case, the repository is always `origin` (which is the usual standard one git sets up when you clone something). So the `refspec` is the more interesting part. Here's the long1 form: ``` git push origin feature/mybranch:feature/mybranch ``` This limits git to only attempting to push your branch `feature/mybranch`, telling the remote, `origin`, that it should update the branch `feature/mybranch` on *its* side too. If you leave out the `:<same-name>` part, the default is to use the branch name on the left of the colon, so: ``` git push origin feature/mybranch ``` does exactly the same thing, with a bit less command-typing. Now, what happens when you leave out the `<refspec>`? The answer is in the [git push](https://www.kernel.org/pub/software/scm/git/docs/git-push.html) and [git config](https://www.kernel.org/pub/software/scm/git/docs/git-config.html) documentation, although in my 1.8.4.3 text version it's really hard to read, and the on-line version I linked to above is, if anything, worse: :-) > > When the command line does not specify what to push with <refspec>... > arguments or --all, --mirror, --tags options, the command finds the > default by consulting remote.\*.push configuration, and if it > is not found, honors push.default configuration to decide what to push > (See gitlink:git-config[1] for the meaning of push.default). > > > To simplify this a lot, I can tell2 that you have not set either `remote.origin.push` or `push.default`, so you're getting the "default default", which is called `matching`, which means your `git push` calls up `origin` on the metaphorical Internet-phone and says > > Hey, what branches do ya got? > > > and it says: > > I have `master` and `feature/mybranch`. > > > So your git then says: > > OK, well, here's what I think `master` should be, and here's what I think `feature/mybranch` should be. > > > To which he says: > > Whoa there buddy, that would set `master` back a couple of revs! > > > ... and that's when you got the `! [rejected] master -> master (non-fast-forward)` thing. So, there's a couple of really simple solutions. ### Solution #0: do nothing If you still have the original `push` output available, you should be able to see something like this: ``` a430f6d..676699a feature/mybranch -> feature/mybranch ! [rejected] master -> master (non-fast-forward) ``` This means that *even though the change for `master -> master` was rejected*, the change for `feature/mybranch -> feature/mybranch` was accepted. The branch you wanted to push, you did! You just got this annoying error message to go with the success (and now you're wondering what to do with branch `master`). ### Solution #1: be explicit in the `push` If you run: ``` git push origin feature/mybranch ``` your Git and origin's Git will have a shorter conversation. Instead of your Git asking him "hey, whaddaya got there?" and then trying to push *all* "matching" branches, yours will just say: "I have some updates for `feature/mybranch`". The fact that you're behind on `master` will be irrelevant; neither you, nor your Git, nor the remote Git will look there. ### Solution #2: change your `push.default` This only works if your git is new enough, although by now, most are: ``` git config --global push.default simple ``` The Git folks ~~are planning to change~~ changed (as of Git version 2.0) the "default default", because `matching` turns out to be more annoying than helpful, a lot of the time. The new "default default" will be `simple`. (For details on what this means, see [the git config documentation](https://www.kernel.org/pub/software/scm/git/docs/git-config.html).) (Setting the `--global` version will change the default default for you, but not for other people. If any repositories—your own, or others—have a local `push.default` setting, that will override your personal global setting, but for those that don't, your global setting is the one git will use. You can choose instead to set the local setting in each repo, which will affect you and anyone else who uses your own repos, but then you need to remember to set it in all your repos.) --- 1Actually this is only the semi-long form: you can add `refs/heads/` in front of each branch name to make it even longer. That's just for showing off though. :-) 2I'm just guessing, really, but it's a pretty safe bet. Someone who configures `remote.origin.push` and `push.default` probably already knows all of this stuff. --- Part 2: Why won't `master` update? ---------------------------------- I'm much less sure about this, but it looks as though someone had accidentally committed a bunch of (17) `.java` binaries into the `master` branch, probably from not having a correct `.gitignore`. At some point they noticed, oops, didn't want all these binaries! So they updated `.gitignore` and committed that, but probably didn't actually `git rm --cached` all of them, so some are still being tracked. If a file that is now listed as ignored was previously committed, git "obeys the commit" rather than the ignore directive, and you get a lot of this: ``` # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: bin/b1 ``` Depending on how you `git add` and what's in the `.gitignore` it's possible to add the in-repository tracked files (that are overriding the ignore entry), and make them "staged for commit" and commit them. In any case, your `master` is two revs behind, and definitely has some binaries in it—and it's possible that your `feature/mybranch` branch has a "bad" `.gitignore` (some variation on it) that also does not ignore the "right set" of binaries. Git notices that 7 of your binaries (perhaps re-built with your feature branch features) don't match what's checked in on the `master` branch. These would be "unsafely" clobbered (at least, as far as git can tell). If/when you do `git checkout -f master` (or something equivalent), git clobbers them after all, but you are still left with "untracked" files, implying a bad `.gitignore`. Once you're quite certain that it's safe to clobber anything in your work-tree—that you have all *your* work saved away—you can do this to resync your `master` to `origin/master`: ``` git checkout -f master git fetch # resync with origin in case they've fixed more stuff git reset --hard origin/master ``` Assuming you don't want binaries in the branches, check over the various `.gitignore` files and make sure they're correct—you'll probably need to fix some. Then, use `git ls-files` and/or `git ls-tree` to see what's in the index and repo (`git ls-tree` requires that you specify a particular tree object, e.g., `git ls-tree HEAD:bin` to see what's in the `bin` tree, if it exists). To remove committed (even though ignored) files, e.g., to remove everything in `bin`: ``` git rm --cached -r bin ``` (the `--cached` says only remove things in the index), or you can allow git to remove the binaries. Once you have the right stuff "git rm"-ed and any updated `.gitignore` files added, `git commit` the changes: ``` $ cat bin/.gitignore * !.gitignore $ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: bin/.gitignore # deleted: bin/b1 # deleted: bin/b2 # $ git commit -m 'remove binaries, ignore them in the future' [master ac60888] remove binaries, ignore them in the future 3 files changed, 1 insertion(+) create mode 100644 bin/.gitignore delete mode 100644 bin/b1 delete mode 100644 bin/b2 ``` (Finally, rebuild any removed binaries as needed, run tests, do a push if appropriate, etc.) (It's possible that you *do* want the `.java` binaries in the branches, or that you don't and yet no one has fixed up any `.gitignore` entries, etc.; so that's why I'm much less sure about this.)
check your master ``` git diff ``` if there no changes, still you get a same problem check for un tracked files add files and stash taht files after that pull your original master and try to push again
9,045,769
I am trying to make an addon to a game named Tibia. On their website Tibia.com you can search up people and see their deaths. forexample: <http://www.tibia.com/community/?subtopic=characters&name=Kixus> Now I want to read the deaths data by using Regex in my C# application. But I cannot seem to work it out, I've been spending hours and hours on <http://myregextester.com/index.php> The expression I use is : ``` <tr bgcolor=(?:"#D4C0A1"|"#F1E0C6") ><td width="25%" valign="top" >(.*?)?#160;CET</td><td>((?:Died|Killed) at Level ([^ ]*)|and) by (?:<[^>]*>)?([^<]*).</td></tr> ``` But I cannot make it work. I want the Timestamp, creature / player Level, and creature / player name Thanks in advance. -Regards
2012/01/28
[ "https://Stackoverflow.com/questions/9045769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175245/" ]
It's a bad idea to use regular expressions to parse HTML. They're a very poor tool for the job. If you're parsing HTML, use an HTML parser. For .NET, the usual recommendation is to use the [HTML Agility Pack](http://htmlagilitypack.codeplex.com/).
try this : <http://jsbin.com/atupok/edit#javascript,html> and continue from there .... I did the most job here :) edit <http://jsbin.com/atupok/3/edit> and start using this tool <http://regexr.com?2vrmf> not the one you have.
9,045,769
I am trying to make an addon to a game named Tibia. On their website Tibia.com you can search up people and see their deaths. forexample: <http://www.tibia.com/community/?subtopic=characters&name=Kixus> Now I want to read the deaths data by using Regex in my C# application. But I cannot seem to work it out, I've been spending hours and hours on <http://myregextester.com/index.php> The expression I use is : ``` <tr bgcolor=(?:"#D4C0A1"|"#F1E0C6") ><td width="25%" valign="top" >(.*?)?#160;CET</td><td>((?:Died|Killed) at Level ([^ ]*)|and) by (?:<[^>]*>)?([^<]*).</td></tr> ``` But I cannot make it work. I want the Timestamp, creature / player Level, and creature / player name Thanks in advance. -Regards
2012/01/28
[ "https://Stackoverflow.com/questions/9045769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175245/" ]
As suggested by Joe White, you would have a much more robust implementation if you use an HTML parser for this task. There is plenty of support for this on StackOverflow: see [here](https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454) for example. **If you really have to use regexs** I would recommend breaking your solution down into simpler regexs which can be applied using a top down parsing approach to get the results. For example: 1. use a regex on the whole page which matches the character table I would suggest matching the shortest unique string before and after the table rather than the table itself, and capturing the table using a group, since this avoids having to deal with the possibility of nested tables. 2. use a regex on the character table that matches table rows 3. use a regex on the first cell to match the date 4. use a regex on the second cell to match links 5. use a regex on the second cell to match the players level 6. use a regex on the second cell to match the killers name if it was a creature (there are no links in the cell) This will be much more maintainable if the site changes its Html structure significantly. **A complete working implementation using HtmlAgilityKit** You can dowload the library from the [HtmlAgilityKit](http://htmlagilitypack.codeplex.com/) site on CodePlex. ``` // This class is used to represent the extracted details public class DeathDetails { public DeathDetails() { this.KilledBy = new List<string>(); } public string DeathDate { get; set; } public List<String> KilledBy { get; set; } public int PlayerLevel { get; set; } } public class CharacterPageParser { public string CharacterName { get; private set; } public CharacterPageParser(string characterName) { this.CharacterName = characterName; } public List<DeathDetails> GetDetails() { string url = "http://www.tibia.com/community/?subtopic=characters&name=" + this.CharacterName; string content = GetContent(url); HtmlDocument document = new HtmlDocument(); document.LoadHtml(content); HtmlNodeCollection tables = document.DocumentNode.SelectNodes("//div[@id='characters']//table"); HtmlNode table = GetCharacterDeathsTable(tables); List<DeathDetails> deaths = new List<DeathDetails>(); for (int i = 1; i < table.ChildNodes.Count; i++) { DeathDetails details = BuildDeathDetails(table, i); deaths.Add(details); } return deaths; } private static string GetContent(string url) { using (System.Net.WebClient c = new System.Net.WebClient()) { string content = c.DownloadString(url); return content; } } private static DeathDetails BuildDeathDetails(HtmlNode table, int i) { DeathDetails details = new DeathDetails(); HtmlNode tableRow = table.ChildNodes[i]; //every row should have two cells in it if (tableRow.ChildNodes.Count != 2) { throw new Exception("Html format may have changed"); } HtmlNode deathDateCell = tableRow.ChildNodes[0]; details.DeathDate = System.Net.WebUtility.HtmlDecode(deathDateCell.InnerText); HtmlNode deathDetailsCell = tableRow.ChildNodes[1]; // get inner text to parse for player level and or creature name string deathDetails = System.Net.WebUtility.HtmlDecode(deathDetailsCell.InnerText); // get player level using regex Match playerLevelMatch = Regex.Match(deathDetails, @" level ([\d]+) ", RegexOptions.IgnoreCase); int playerLevel = 0; if (int.TryParse(playerLevelMatch.Groups[1].Value, out playerLevel)) { details.PlayerLevel = playerLevel; } if (deathDetailsCell.ChildNodes.Count > 1) { // death details contains links which we can parse for character names foreach (HtmlNode link in deathDetailsCell.ChildNodes) { if (link.OriginalName == "a") { string characterName = System.Net.WebUtility.HtmlDecode(link.InnerText); details.KilledBy.Add(characterName); } } } else { // player was killed by a creature - capture creature name Match creatureMatch = Regex.Match(deathDetails, " by (.*)", RegexOptions.IgnoreCase); string creatureName = creatureMatch.Groups[1].Value; details.KilledBy.Add(creatureName); } return details; } private static HtmlNode GetCharacterDeathsTable(HtmlNodeCollection tables) { foreach (HtmlNode table in tables) { // Get first row HtmlNode tableRow = table.ChildNodes[0]; // check to see if contains enough elements if (tableRow.ChildNodes.Count == 1) { HtmlNode tableCell = tableRow.ChildNodes[0]; string title = tableCell.InnerText; // skip this table if it doesn't have the right title if (title == "Character Deaths") { return table; } } } return null; } ``` And an example of it in use: ``` CharacterPageParser kixusParser = new CharacterPageParser("Kixus"); foreach (DeathDetails details in kixusParser.GetDetails()) { Console.WriteLine("Player at level {0} was killed on {1} by {2}", details.PlayerLevel, details.DeathDate, string.Join(",", details.KilledBy)); } ```
try this : <http://jsbin.com/atupok/edit#javascript,html> and continue from there .... I did the most job here :) edit <http://jsbin.com/atupok/3/edit> and start using this tool <http://regexr.com?2vrmf> not the one you have.
9,045,769
I am trying to make an addon to a game named Tibia. On their website Tibia.com you can search up people and see their deaths. forexample: <http://www.tibia.com/community/?subtopic=characters&name=Kixus> Now I want to read the deaths data by using Regex in my C# application. But I cannot seem to work it out, I've been spending hours and hours on <http://myregextester.com/index.php> The expression I use is : ``` <tr bgcolor=(?:"#D4C0A1"|"#F1E0C6") ><td width="25%" valign="top" >(.*?)?#160;CET</td><td>((?:Died|Killed) at Level ([^ ]*)|and) by (?:<[^>]*>)?([^<]*).</td></tr> ``` But I cannot make it work. I want the Timestamp, creature / player Level, and creature / player name Thanks in advance. -Regards
2012/01/28
[ "https://Stackoverflow.com/questions/9045769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175245/" ]
It's a bad idea to use regular expressions to parse HTML. They're a very poor tool for the job. If you're parsing HTML, use an HTML parser. For .NET, the usual recommendation is to use the [HTML Agility Pack](http://htmlagilitypack.codeplex.com/).
You can also use [Espresso](http://www.ultrapico.com/ExpressoDownload.htm) tool to work out proper regular expression. To properly escape all special characters that are not parts of regular expression you can use [Regex.Escape](http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.escape.aspx) method: ``` string escapedText = Regex.Escape("<td width=\"25%\" valign=\"top\" >"); ```
9,045,769
I am trying to make an addon to a game named Tibia. On their website Tibia.com you can search up people and see their deaths. forexample: <http://www.tibia.com/community/?subtopic=characters&name=Kixus> Now I want to read the deaths data by using Regex in my C# application. But I cannot seem to work it out, I've been spending hours and hours on <http://myregextester.com/index.php> The expression I use is : ``` <tr bgcolor=(?:"#D4C0A1"|"#F1E0C6") ><td width="25%" valign="top" >(.*?)?#160;CET</td><td>((?:Died|Killed) at Level ([^ ]*)|and) by (?:<[^>]*>)?([^<]*).</td></tr> ``` But I cannot make it work. I want the Timestamp, creature / player Level, and creature / player name Thanks in advance. -Regards
2012/01/28
[ "https://Stackoverflow.com/questions/9045769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175245/" ]
As suggested by Joe White, you would have a much more robust implementation if you use an HTML parser for this task. There is plenty of support for this on StackOverflow: see [here](https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454) for example. **If you really have to use regexs** I would recommend breaking your solution down into simpler regexs which can be applied using a top down parsing approach to get the results. For example: 1. use a regex on the whole page which matches the character table I would suggest matching the shortest unique string before and after the table rather than the table itself, and capturing the table using a group, since this avoids having to deal with the possibility of nested tables. 2. use a regex on the character table that matches table rows 3. use a regex on the first cell to match the date 4. use a regex on the second cell to match links 5. use a regex on the second cell to match the players level 6. use a regex on the second cell to match the killers name if it was a creature (there are no links in the cell) This will be much more maintainable if the site changes its Html structure significantly. **A complete working implementation using HtmlAgilityKit** You can dowload the library from the [HtmlAgilityKit](http://htmlagilitypack.codeplex.com/) site on CodePlex. ``` // This class is used to represent the extracted details public class DeathDetails { public DeathDetails() { this.KilledBy = new List<string>(); } public string DeathDate { get; set; } public List<String> KilledBy { get; set; } public int PlayerLevel { get; set; } } public class CharacterPageParser { public string CharacterName { get; private set; } public CharacterPageParser(string characterName) { this.CharacterName = characterName; } public List<DeathDetails> GetDetails() { string url = "http://www.tibia.com/community/?subtopic=characters&name=" + this.CharacterName; string content = GetContent(url); HtmlDocument document = new HtmlDocument(); document.LoadHtml(content); HtmlNodeCollection tables = document.DocumentNode.SelectNodes("//div[@id='characters']//table"); HtmlNode table = GetCharacterDeathsTable(tables); List<DeathDetails> deaths = new List<DeathDetails>(); for (int i = 1; i < table.ChildNodes.Count; i++) { DeathDetails details = BuildDeathDetails(table, i); deaths.Add(details); } return deaths; } private static string GetContent(string url) { using (System.Net.WebClient c = new System.Net.WebClient()) { string content = c.DownloadString(url); return content; } } private static DeathDetails BuildDeathDetails(HtmlNode table, int i) { DeathDetails details = new DeathDetails(); HtmlNode tableRow = table.ChildNodes[i]; //every row should have two cells in it if (tableRow.ChildNodes.Count != 2) { throw new Exception("Html format may have changed"); } HtmlNode deathDateCell = tableRow.ChildNodes[0]; details.DeathDate = System.Net.WebUtility.HtmlDecode(deathDateCell.InnerText); HtmlNode deathDetailsCell = tableRow.ChildNodes[1]; // get inner text to parse for player level and or creature name string deathDetails = System.Net.WebUtility.HtmlDecode(deathDetailsCell.InnerText); // get player level using regex Match playerLevelMatch = Regex.Match(deathDetails, @" level ([\d]+) ", RegexOptions.IgnoreCase); int playerLevel = 0; if (int.TryParse(playerLevelMatch.Groups[1].Value, out playerLevel)) { details.PlayerLevel = playerLevel; } if (deathDetailsCell.ChildNodes.Count > 1) { // death details contains links which we can parse for character names foreach (HtmlNode link in deathDetailsCell.ChildNodes) { if (link.OriginalName == "a") { string characterName = System.Net.WebUtility.HtmlDecode(link.InnerText); details.KilledBy.Add(characterName); } } } else { // player was killed by a creature - capture creature name Match creatureMatch = Regex.Match(deathDetails, " by (.*)", RegexOptions.IgnoreCase); string creatureName = creatureMatch.Groups[1].Value; details.KilledBy.Add(creatureName); } return details; } private static HtmlNode GetCharacterDeathsTable(HtmlNodeCollection tables) { foreach (HtmlNode table in tables) { // Get first row HtmlNode tableRow = table.ChildNodes[0]; // check to see if contains enough elements if (tableRow.ChildNodes.Count == 1) { HtmlNode tableCell = tableRow.ChildNodes[0]; string title = tableCell.InnerText; // skip this table if it doesn't have the right title if (title == "Character Deaths") { return table; } } } return null; } ``` And an example of it in use: ``` CharacterPageParser kixusParser = new CharacterPageParser("Kixus"); foreach (DeathDetails details in kixusParser.GetDetails()) { Console.WriteLine("Player at level {0} was killed on {1} by {2}", details.PlayerLevel, details.DeathDate, string.Join(",", details.KilledBy)); } ```
You can also use [Espresso](http://www.ultrapico.com/ExpressoDownload.htm) tool to work out proper regular expression. To properly escape all special characters that are not parts of regular expression you can use [Regex.Escape](http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.escape.aspx) method: ``` string escapedText = Regex.Escape("<td width=\"25%\" valign=\"top\" >"); ```
9,045,769
I am trying to make an addon to a game named Tibia. On their website Tibia.com you can search up people and see their deaths. forexample: <http://www.tibia.com/community/?subtopic=characters&name=Kixus> Now I want to read the deaths data by using Regex in my C# application. But I cannot seem to work it out, I've been spending hours and hours on <http://myregextester.com/index.php> The expression I use is : ``` <tr bgcolor=(?:"#D4C0A1"|"#F1E0C6") ><td width="25%" valign="top" >(.*?)?#160;CET</td><td>((?:Died|Killed) at Level ([^ ]*)|and) by (?:<[^>]*>)?([^<]*).</td></tr> ``` But I cannot make it work. I want the Timestamp, creature / player Level, and creature / player name Thanks in advance. -Regards
2012/01/28
[ "https://Stackoverflow.com/questions/9045769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175245/" ]
It's a bad idea to use regular expressions to parse HTML. They're a very poor tool for the job. If you're parsing HTML, use an HTML parser. For .NET, the usual recommendation is to use the [HTML Agility Pack](http://htmlagilitypack.codeplex.com/).
As suggested by Joe White, you would have a much more robust implementation if you use an HTML parser for this task. There is plenty of support for this on StackOverflow: see [here](https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454) for example. **If you really have to use regexs** I would recommend breaking your solution down into simpler regexs which can be applied using a top down parsing approach to get the results. For example: 1. use a regex on the whole page which matches the character table I would suggest matching the shortest unique string before and after the table rather than the table itself, and capturing the table using a group, since this avoids having to deal with the possibility of nested tables. 2. use a regex on the character table that matches table rows 3. use a regex on the first cell to match the date 4. use a regex on the second cell to match links 5. use a regex on the second cell to match the players level 6. use a regex on the second cell to match the killers name if it was a creature (there are no links in the cell) This will be much more maintainable if the site changes its Html structure significantly. **A complete working implementation using HtmlAgilityKit** You can dowload the library from the [HtmlAgilityKit](http://htmlagilitypack.codeplex.com/) site on CodePlex. ``` // This class is used to represent the extracted details public class DeathDetails { public DeathDetails() { this.KilledBy = new List<string>(); } public string DeathDate { get; set; } public List<String> KilledBy { get; set; } public int PlayerLevel { get; set; } } public class CharacterPageParser { public string CharacterName { get; private set; } public CharacterPageParser(string characterName) { this.CharacterName = characterName; } public List<DeathDetails> GetDetails() { string url = "http://www.tibia.com/community/?subtopic=characters&name=" + this.CharacterName; string content = GetContent(url); HtmlDocument document = new HtmlDocument(); document.LoadHtml(content); HtmlNodeCollection tables = document.DocumentNode.SelectNodes("//div[@id='characters']//table"); HtmlNode table = GetCharacterDeathsTable(tables); List<DeathDetails> deaths = new List<DeathDetails>(); for (int i = 1; i < table.ChildNodes.Count; i++) { DeathDetails details = BuildDeathDetails(table, i); deaths.Add(details); } return deaths; } private static string GetContent(string url) { using (System.Net.WebClient c = new System.Net.WebClient()) { string content = c.DownloadString(url); return content; } } private static DeathDetails BuildDeathDetails(HtmlNode table, int i) { DeathDetails details = new DeathDetails(); HtmlNode tableRow = table.ChildNodes[i]; //every row should have two cells in it if (tableRow.ChildNodes.Count != 2) { throw new Exception("Html format may have changed"); } HtmlNode deathDateCell = tableRow.ChildNodes[0]; details.DeathDate = System.Net.WebUtility.HtmlDecode(deathDateCell.InnerText); HtmlNode deathDetailsCell = tableRow.ChildNodes[1]; // get inner text to parse for player level and or creature name string deathDetails = System.Net.WebUtility.HtmlDecode(deathDetailsCell.InnerText); // get player level using regex Match playerLevelMatch = Regex.Match(deathDetails, @" level ([\d]+) ", RegexOptions.IgnoreCase); int playerLevel = 0; if (int.TryParse(playerLevelMatch.Groups[1].Value, out playerLevel)) { details.PlayerLevel = playerLevel; } if (deathDetailsCell.ChildNodes.Count > 1) { // death details contains links which we can parse for character names foreach (HtmlNode link in deathDetailsCell.ChildNodes) { if (link.OriginalName == "a") { string characterName = System.Net.WebUtility.HtmlDecode(link.InnerText); details.KilledBy.Add(characterName); } } } else { // player was killed by a creature - capture creature name Match creatureMatch = Regex.Match(deathDetails, " by (.*)", RegexOptions.IgnoreCase); string creatureName = creatureMatch.Groups[1].Value; details.KilledBy.Add(creatureName); } return details; } private static HtmlNode GetCharacterDeathsTable(HtmlNodeCollection tables) { foreach (HtmlNode table in tables) { // Get first row HtmlNode tableRow = table.ChildNodes[0]; // check to see if contains enough elements if (tableRow.ChildNodes.Count == 1) { HtmlNode tableCell = tableRow.ChildNodes[0]; string title = tableCell.InnerText; // skip this table if it doesn't have the right title if (title == "Character Deaths") { return table; } } } return null; } ``` And an example of it in use: ``` CharacterPageParser kixusParser = new CharacterPageParser("Kixus"); foreach (DeathDetails details in kixusParser.GetDetails()) { Console.WriteLine("Player at level {0} was killed on {1} by {2}", details.PlayerLevel, details.DeathDate, string.Join(",", details.KilledBy)); } ```