qid int64 10 74.7M | question stringlengths 15 26.2k | date stringlengths 10 10 | metadata list | response_j stringlengths 27 28.1k | response_k stringlengths 23 26.8k |
|---|---|---|---|---|---|
1,815,716 | I wondering if it's possible to get the MatchData generated from the matching regular expression in the grammar below.
```
object DateParser extends JavaTokenParsers {
....
val dateLiteral = """(\d{4}[-/])?(\d\d[-/])?(\d\d)""".r ^^ {
... get MatchData
}
}
```
One option of course is to perform ... | 2009/11/29 | [
"https://Stackoverflow.com/questions/1815716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16744/"
] | No, you can't do this. If you look at the definition of the Parser used when you convert a regex to a Parser, it throws away all context and just returns the full matched string:
<http://lampsvn.epfl.ch/trac/scala/browser/scala/tags/R_2_7_7_final/src/library/scala/util/parsing/combinator/RegexParsers.scala?view=markup... | When a Regex is used in a RegexParsers instance, the **implicit def regex(Regex): Parser[String]** in RegexParsers is used to appoly that Regex to the input. The Match instance yielded upon successful application of the RE at the current input is used to construct a Success in the regex() method, but only its "end" val... |
6,693,282 | I have an application that allows the users to delete video files. When I press the delete button, I am using
```
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case DialogInter... | 2011/07/14 | [
"https://Stackoverflow.com/questions/6693282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/833590/"
] | I tend to use AlertDialog.Builder like they show in the official doc example
```
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure you want to exit?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(Dia... | Another (dirty) way:
```
TypedValue typedValue = new TypedValue();
getTheme().resolveAttribute(android.R.attr.alertDialogIcon, typedValue, true);
new AlertDialog.Builder(this)
.setIcon(typedValue.resourceId)
...
.show();
``` |
9,743,513 | I am reading "Effective Java" by Joshua Bloch, item 39 make defensive copy, and I have some questions. I always use the following construct:
```
MyObject.getSomeRef().setSomething(somevalue);
```
which is short for:
```
SomeRef s = MyClass.getSomeRef();
s.setSomething();
MyObject.setSomeRef(s);
```
It always work... | 2012/03/16 | [
"https://Stackoverflow.com/questions/9743513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1260847/"
] | Defensive copy is a good idea, but you need to understand when and where it gets used. If the web of objects you are manipulating is internal, and it not intended to be thread safe, then the defensive copying is being mis-applied.
On the other hand, if this is web of objects that are getting exposed publicly, then you... | I would suggest defining a `readableThing` interface or class, and deriving from it `mutableThing` and `immutableThing` interfaces. A property getter should return one of those interfaces based upon the returned item's relation to the list:
1. It should return a mutableThing if the thing may be safely modified in such... |
42,521,722 | I'm having some issues which I'm guessing are related to self-referencing using .NET Core Web API and Entity Framework Core. My Web API starting choking when I added .Includes for some navigation properties.
I found what appears to be a solution in the older Web API but I don't know how to implement the same thing for... | 2017/03/01 | [
"https://Stackoverflow.com/questions/42521722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42620/"
] | ReferenceLoopHandling.Ignore “hides” the problem, not solves it. What you really need to be doing is building layers. Create domain objects to sit on top of your entities and wrap them in some sort of service/business layer. Look up the repository pattern and apply that if it helps. You’ll need to map between your enti... | If you have a `Minimal API` this will be useful:
```
using System.Text.Json.Serialization;
builder.Services.Configure<Microsoft.AspNetCore.Http.Json.JsonOptions>(opt =>
{
opt.SerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles;
});
``` |
31,459,619 | I triggered the external .js function using $.getScript, after it's done, i am loading the content to 'div' element ('Result'). So after everything is done, i would like to perform other function like say for example alert the downloaded content (eg: #items). But, when i do alert, i don't think the whole content is yet... | 2015/07/16 | [
"https://Stackoverflow.com/questions/31459619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4976920/"
] | I'm not sure your code is in right way, because you get the `js`, but on `done`, you give the html of `#result`, then alert html of `#item`! this doesn't makes any sense to me. Also what is job of `load` function that you wrote below the `$.getScript`?
**Update**
So, you made some update, I think you want to fetch one... | So, after some chat, here is my solution, hope this help:
I made 2 `.html` files, `a.html` and `b.html`.
Content of `a.html`:
```
<div></div>
<script>
$.getScript("main.js", function() {
$("div").load("b.html #items");
});
</script>
```
And `b.html`:
```
<body>
<script src="main.js"></script>
<... |
51,391,193 | Is there any way that the chronometer can be paused if a method is true. I have created a simple jigsaw puzzle and added a chronometer to show the time elapse and I'm trying to stop the timer when the puzzle is Solved.On running, the application runs smoothly, with the chronometer ticking but not stopping when the game... | 2018/07/17 | [
"https://Stackoverflow.com/questions/51391193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10039622/"
] | ```
public void stopChronometer() {
if(running && isSolved()){
chronometer.stop();
running =false;
}
}
```
change to
```
public void stopChronometer(){
if(running || isSolved()){
chronometer.stop();
running =false;
}
}
```
or you can call stopChronometer() from isSol... | I have found the solution
The issue whas that I hadn't declared the method start Chronometer(), chronomer and running as static. Thanks for the help though |
291,681 | I need to find if any lines in a file begin with `**` .
I cannot figure out how to do it because `*` is interpreted as a wildcard by the shell.
```
grep -i "^2" test.out
```
works if the line begins with a 2 but
```
grep -i "^**" test.out
```
obviously doesn't work.
(I also need to know if this line ends wit... | 2016/06/23 | [
"https://unix.stackexchange.com/questions/291681",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/176488/"
] | Use the `\` character to escape the \* to make it a normal character.
```
grep '^\*\*' test.out
```
Also note the single quote `'` and not double quote `"` to prevent the shell expanding things | ### It's not the shell
None of the answers so far has touched on the real problem. It would be helpful to explain *why* it does not work as you expect.
`grep -i "^**" test.out`
Because you have *quoted* the pattern to *grep*, `*` is *not* expanded by the shell. It is passed to *grep* as-is. This is explained in the ... |
1,489,190 | I'm using IntelliJ to do Java Development for an application where we use JSF in a few places. In the .jsp file I have defined my backing class and the code runs properly.
My question is: How do I set up my environment so that when I center click on the method names, which use EL format, IntelliJ navigates to the pr... | 2009/09/28 | [
"https://Stackoverflow.com/questions/1489190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | It's a bit dodgy but you could override the `$` function:
```
var old$ = $;
var xml = ...;
$ = function(arg)
{
return old$(arg, xml);
}
```
I think that should work... maybe... | If you're using a method like jQuery.ajax() or jQuery.get() to retrieve the DOM from another page, just change/set the return type from "json" to "xml".
<http://docs.jquery.com/Ajax/jQuery.ajax#options> (scroll down to "dataType") |
6,226 | In my job I teach a lot of people to use macs. Since you use what you remember I'm always on the look out for funny or memorable ways to remember keyboard or system shortcuts (like you have the option to command escape, I know it's corny, but it works for newbies!).
What are the mnemonics you use to remember importan... | 2011/01/11 | [
"https://apple.stackexchange.com/questions/6226",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/1818/"
] | "Very much long work causes injury just because stress yanks energy gradually."
moVe V very
Marquee M much
Lasso L long
Wand W work
Crop C causes
Eye I injury
Healing J just (Jesus heals)
Brush B because
Stamp S stress
HistorY Y yanks
Erasor E energy
Gradiant G gradually
Blur --
"Optimum practice teaches... | The most obvious mnemonic is really the first letter of the action wanted in combination with `⌘`, e.g. `⌘`-`F` for 'Find'. The hard part comes when that is reserved to some other command than the intended.
I'd suggest first learning the most used shortcuts (maybe just one or two) and start using them whenever possibl... |
46,033,883 | I need middle tab bar item to look different from others. Here is an illustration:
[](https://i.stack.imgur.com/SvMWI.png)
How can I achieve this?
EDIT:
All tabs except of middle react on selection in standard way. Only middle tab looks the same w... | 2017/09/04 | [
"https://Stackoverflow.com/questions/46033883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3400881/"
] | ```
Take a subclass of TabbarController.Remember to call `<UITabBarControllerDelegate>`
func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
//
tabBar.selectionIndicatorImage = returnImageofSelectetab()
}
//Method called everytime when you select tab.
func tabBarC... | You should subclass `UITabBarController` and change the appearance of the third `UITabBarItem` in its `items` array inside `awakeFromNib`.
```
class CustomTabBarController: UITabBarController {
override func awakeFromNib() {
super.awakeFromNib()
guard let items = tabBar.items else {
re... |
47,057,112 | I am trying to implement a simple program in vba and the following problem arises: How do you find a cell data in excel and put all the associated data in the textbox?
For example:
How to make that when typing the name I load the document, the data 1, 2, 3 and the average in the respective textbox.
![This is my sheet]... | 2017/11/01 | [
"https://Stackoverflow.com/questions/47057112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8011307/"
] | Try the following REGEX instead([DEMO](https://regex101.com/r/RAAh4V/2)):
```
/<iframe.*?s*src="http(.*?)".*?<\/iframe>/
```
But beware, You CAN NOT parse HTML with REGEX properly. Please, use some XML parser instead.
Also, it seems you only want to change `http` to `https`. So for that try the following instead:
... | You can try this regex :
```
/(<iframe.+?src=".*?)(?=:)/
```
Live demo [here](https://regex101.com/r/GGU2yj/5)
Sample code in php:
```
$re = '/(<iframe.+?src=".*?)(?=:)/';
$str = '<p>Some random text <iframe src="http://some-random-link.com" width="425" height="350" frameborder="0"></iframe></p>';
$subst = '\\1s';... |
24 | Black holes have so much gravity that [even light can't escape from them](https://astronomy.stackexchange.com/questions/7/why-cant-light-escape-from-a-black-hole/8#8). If we can't see them, and the suck up all electromagnetic radiation, then how can we find them? | 2013/09/24 | [
"https://astronomy.stackexchange.com/questions/24",
"https://astronomy.stackexchange.com",
"https://astronomy.stackexchange.com/users/19/"
] | There are many, many ways of doing this.
[Gravitational lensing](http://en.wikipedia.org/wiki/Gravitational_lens)
------------------------------------------------------------------------
This is by far the most well known. It has been mentioned by the others, but I'll touch on it.
, and is the most visually stunning prediction of Einstein's theory of General Relativity.
This image portrays the geometry of gra... |
256,062 | Small retail business running 5 computers. Thinking about getting a server to run the printers, run a pos system, run quickbooks, and do backups. My question is whether I should invest into getting a Windows server or just use a regular computer? Or is there some other way of easily doing this? My concern is that a Win... | 2011/04/05 | [
"https://serverfault.com/questions/256062",
"https://serverfault.com",
"https://serverfault.com/users/77284/"
] | I would look at [Windows Small Business Server](http://www.microsoft.com/sbs/en/us/default.aspx).
Then see if you qualify for the [Microsoft Bizspark](http://www.microsoft.com/bizspark/) program.
This also could be done with a Linux distribution though the skilled Admin required for that role and configuration if Lin... | [Consider Windows Server 2008 Foundation](http://www.microsoft.com/windowsserver2008/en/us/foundation.aspx)
Limitations are that you can only have 15 users, can't be a child domain or domain trusts. |
58,858,546 | Epicor ERP 10.2.500 has been recently released with the addition of Epicor Functions. They can be called from within Method and Data Directives.
Do anybody has been able to do so with a Form Customization within Epicor? | 2019/11/14 | [
"https://Stackoverflow.com/questions/58858546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12372749/"
] | This is possible via a REST call to your function API. In this case, I had a function that sent an email from some inputs.
```
private void epiButtonC1_Click(object sender, System.EventArgs args)
{
//API Key is included in the query param in this example.
var request = (HttpWebRequest)WebRequest.Create("http... | REST endpoint is the recommended way to perform the function call as pointed out by a-moreng.
If for some reason you cannot use this, you can use a passthrough method to any server-side BO via a customization Adapter. For instance, create an updatable BAQ which you can call from a customization using the DynamicQueryA... |
53,926 | Is there a way to determine whether there exists a positive solution ($x\_i > 0$ and $y\_i > 0$) for all of the following equations to hold when $k > 2$?
$x\_1 + x\_2 + \cdots + x\_{2n} = y\_1 + y\_2 + \cdots + y\_n$.
$x^2\_1 + x^2\_2 + \cdots + x^2\_{2n} = y^2\_1 + y^2\_2 + \cdots + y^2\_n$.
$x^3\_1 + x^3\_2 + \cd... | 2011/01/31 | [
"https://mathoverflow.net/questions/53926",
"https://mathoverflow.net",
"https://mathoverflow.net/users/12652/"
] | One can't have $k \ge 2n$ (proof in a moment). An integer solution at the end.
If $k \le n$ then one can choose $y\_1,y\_2,\cdots,y\_n$ and $x\_{n+1},x\_{n+2},\cdots,x\_{2n}$ and solve for $x\_1,x\_2,\cdots,x\_n$. I arbitrarily decided to try this with $x\_3=3,x\_4=4$ Varying $y\_1,y\_2$ I find
$y\_1,y\_2;x\_1,x\_2,x... | For integers, this is referred to as the Tarry-Escott problem, also as multigrade equations, a search for either term should bring you much joy. I just noticed you have $n$ terms on one side, $2n$ on the other, whereas people are usually more interested in equal numbers of terms on each side. |
22,642,816 | Here's a little background into what I'm trying to achieve, in order to help make my question a bit more clear...I'm creating a Navigation Drawer where each item in the ListView looks similar to the following:

However, I need to be able to change the color of the righ... | 2014/03/25 | [
"https://Stackoverflow.com/questions/22642816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1869968/"
] | Have you tried clearing the `WILL_NOT_DRAW` flag by calling [setWillNotDraw](http://developer.android.com/reference/android/view/View.html#setWillNotDraw%28boolean%29) method in your custom layout?
>
> If this view doesn't do any drawing on its own, set this flag to allow
> further optimizations. By default, this fl... | just call it yourself each time you iterate over the list
```
if(convertView == null){
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
container = (CustomRelativeLayout) inflater.inflate(R.layout.nav_drawer_item,
parent, fa... |
12,796,148 | I've a timer object. I want it to be run every minute. Specifically, it should run a `OnCallBack` method and gets inactive while a `OnCallBack` method is running. Once a `OnCallBack` method finishes, it (a `OnCallBack`) restarts a timer.
Here is what I have right now:
```
private static Timer timer;
private static v... | 2012/10/09 | [
"https://Stackoverflow.com/questions/12796148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1708058/"
] | This is not the correct usage of the System.Threading.Timer. When you instantiate the Timer, you should almost always do the following:
```
_timer = new Timer( Callback, null, TIME_INTERVAL_IN_MILLISECONDS, Timeout.Infinite );
```
This will instruct the timer to tick only once when the interval has elapsed. Then in ... | Is using `System.Threading.Timer` mandatory?
If not, `System.Timers.Timer` has handy `Start()` and `Stop()` methods (and an `AutoReset` property you can set to false, so that the `Stop()` is not needed and you simply call `Start()` after executing). |
12,950,959 | I was astonished that a thing this simple has been troubling me. Below is the code
```
list = []
f = open("log.txt", "rb") # log.txt file has line separated values,
for i in f.readlines():
for value in i.split(" "):
list.append(value)
print list
```
The output is
```
['xx00', '\n', 'xx01in', '\n', ... | 2012/10/18 | [
"https://Stackoverflow.com/questions/12950959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1695014/"
] | The correct way to do this, is:
```
with open('log.txt') as fin:
for line in fin:
print line.split()
```
By using `split()` **without** an argument, the '\n''s automatically don't become a problem (as split or split(None) uses different rules for splitting).
Or, more concisely:
```
from itertools impor... | If you have a bunch of lines with space separated values, and you just want a list of all the values without caring about where the line breaks were (which appears to be the case from your example, since you're always appending to the same list regardless of what line you're on), then don't bother looping over lines. J... |
63,092,672 | How to change color of just one side of the border of a raised button in flutter?
[](https://i.stack.imgur.com/GHlex.png) | 2020/07/25 | [
"https://Stackoverflow.com/questions/63092672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12050995/"
] | Really, the import should go first.
The usual standards for the PPCG site allow answers to create a function that satisfies the challenge requirements, without actually saving it anywhere. At the time the `lambda` creates the function, `permutations` is not available, but the function is not executed, so no error occu... | That code is a no-op. It defines a lambda which is never executed, so Python never encounters the NameError.
Actually executing the lambda before importing `itertools` would reveal the error. |
45,594,620 | **UPDATE : PROBLEM IS SOLVED**
[](https://i.stack.imgur.com/FnOIS.jpg)
According to this image, I am trying to open fragment according to each drawer item. Currently I've made fragment only for 'Easy' which contain **a ListView** but my app **CRASHES... | 2017/08/09 | [
"https://Stackoverflow.com/questions/45594620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Return `view` not `return inflater.inflate(R.layout.fragment_easy, container, false);` in your fragment in onCreateView method.
Edited :
Implement `OnFragmentInteractionListener` in MainActvity
Ex:
```
public class MainActivity extends AppCompatActivity
implements OnFragmentInteractionListener {
// Impleme... | Your `easyFragment.getTag()` call will return `null` because there was no `setTag` call, so just use some `String` tag to bind it with your fragment instead of`null`
```
manager.beginTransaction().replace(R.id.mainBase, easyFragment, "easyFrag").commit();
// ... |
66,037,493 | I'm on a MacBook Pro M1 (and before someone says well it's because of M1 or something else, I've been programming with Flutter and M1 for weeks but then I must have to reset my M1 and after this) ... my big problem:
I can not start my project with a package that include native codes like `shared_preferences` or `sqlit... | 2021/02/03 | [
"https://Stackoverflow.com/questions/66037493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15141193/"
] | Instead of `pod install`, you need to do:
```
arch -x86_64 pod install
```
Cocoapods still doesn't have full Apple Silicon support. Running commands with `arch -x86_64` forces Terminal to use Rosetta 2 instead.
If that doesn't work, try following [this article](https://medium.com/p-society/cocoapods-on-apple-s... | Run
```
sudo gem uninstall ffi
```
and
```
sudo gem install ffi -- --enable-libffi-alloc
``` |
30,794,566 | I'm new to R and RStudio but trying to learn and put together a ShinyApps app. I cannot get past Step 1 of the Shinyapps process, which is to install the devtools package in RStudio. I believe the underlying cause is that the "xml2" package dependency is not installed, but I can't seem to resolve that and I don't under... | 2015/06/12 | [
"https://Stackoverflow.com/questions/30794566",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4556560/"
] | I had an **old R version (3.0.2)** running on **Ubuntu 14.04**. And this is how i had to update R:
* open the sources list `sudo vi /etc/apt/sources.list`
* Add a cran mirror (i.e. `deb http://cran.rstudio.com/bin/linux/ubuntu trusty/`)
* Add an APT-key `sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E0... | Update to the newest version of R then follow the instructions provided in the link and you should be able to get it installed.
<https://github.com/hadley/devtools> |
47,784,649 | Have an array A = [a1, a2, ..., an] where each element in the array is either 0, 1 or 2.
Need to sort the array, but it is stated specifically use a **comparison-based algorithm**. I know it is possible to use linear time algorithms, but you are not allowed to use counting sort or other arrays.
Can anyone help me to ... | 2017/12/13 | [
"https://Stackoverflow.com/questions/47784649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5066026/"
] | Take 1 as the pivot element. Compare with every element. If that is `0`, move it before `1` and if it is `2`, then move it after `1`.
```
#include <iostream>
#include <vector>
#include <iterator>
using namespace std;
void Sort(vector<int>& A) {
int n = A.size(), i = 0, j = 0, k = n - 1;
while (j < k) {
... | Here is a javascript solution. Algorithm is run twice with pivot=1 and pivot=0 based on partition. You can see the algorithm performs COMPARISION rather than knowing 0, 1 or 2.
```
var array = [1,0,2,0,0,1,2,0,2,1,1,1,2,2,0,0,0,1];
console.log("Original Array " + array);
var size = array.length;
function partition(ar... |
34,632,482 | I have a array of strings, but all the stings are written in upper case letters. Is there a way for me to make all the strings in the array to lower case, (and with capitalisation)
```
array = ["BOY","GIRL","MAN"]
// func to convert it to array = ["Boy","Girl","Man"]
```
Is there a way to do this, without rewri... | 2016/01/06 | [
"https://Stackoverflow.com/questions/34632482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5748109/"
] | You can use the map function like this:
```
let array = ["BOY","GIRL","MAN"]
let capitalizedArray = array.map { $0.capitalizedString}
``` | SWIFT 4:
The property capitalizedString has changed to capitalized.
```
let array = ["BOY","GIRL","MAN"]
let capitalizedArray = array.map {$0.capitalized}
``` |
18,704,039 | I have a single table which I need to pull back the 5 most recent records based on a userID and keying off of documentID (no duplicates). Basically, I'm tracking visited pages and trying to pull back the 3 most recent by user.
Sample data:
```
╔══════════════════════════════════════════════╗
║UserID DocumentID Cr... | 2013/09/09 | [
"https://Stackoverflow.com/questions/18704039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/127875/"
] | ```
SELECT TOP 3 UserId, DocumentId, MAX(CreatedDate)
FROM MyTable
WHERE UserId = 71
GROUP BY UserId, DocumentId
ORDER BY MAX(CreatedDate) DESC
``` | ```
Select USERID,DOCUMENT ID
FROM yourtable
QUALIFY ROW_NUMBER OVER(Partition by user id ORDER By document id Desc)<6
```
This works in Teradata. Hope this works in Sql Server too as its mainly ANSI SQL. |
13,709,651 | I want to find GCD of two numbers but without using division or mod operator.
one obvious way would be to write own mod function like this:
```
enter code here
int mod(int a, int b)
{
while(a>b)
a-=b;
return a;
}
```
and then use this function in the euclid algorithm.
Any other way ?? | 2012/12/04 | [
"https://Stackoverflow.com/questions/13709651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1453008/"
] | You can use the substraction based version of [euclidean algorithm](http://en.wikipedia.org/wiki/Euclidean_algorithm#Implementations) up front:
```
function gcd(a, b)
if a = 0
return b
while b ≠ 0
if a > b
a := a − b
else
b := b − a
return a
``` | A more or less direct way is the following code, which is derived from Pick's theorem:
```
int gcd(int a, int b)
{
if( a < 0)
{
a = -a;
}
if( b < 0)
{
b = -b;
}
if( a == b)
{
return a;
}
//swap the values to make the upper bound in the n... |
19,125,507 | This would greatly improve the readability of many regular expressions I write, and when I write a single literal space in my regexes I almost always mean `\s*` anyway. So, is there a "mode" in Perl regular expressions that enables this, like `/s` to make `.` match newlines, etc.? A cursory read through `perlre` didn't... | 2013/10/01 | [
"https://Stackoverflow.com/questions/19125507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8127/"
] | I would try using drush alias files to run drush commands from the outside. Drush alias files allow you to authenticate remotely and run such commands. (some example on drush alias file - <https://drupal.org/node/1401522>).
Aegir (actually one of its components - provision) has integration with drush, so you can use c... | You're looking for [Aegir Services](https://www.drupal.org/project/hosting_services):
>
> Aims to be a one-stop shop for all Web services functionality offered
> within the Aegir Hosting System. It allows for remote site management
> via the Services framework.
>
>
> |
51,131,230 | I have 3 queries in sql:
1st query:
```
select t1ID ,AVG(t2score) AS AVG1
from T1
WHERE t1m1 NOT IN (t2m1,t2m2,t2m3) and t1m2 IN (t2m1,t2m2,t2m3)
group by t1ID
```
Result
```
+------+------+
| t1ID | AVG1 |
+------+------+
| 1 | 55 |
| 2 | 45 |
| 3 | 73 |
| 4 | 69 |
+------+------+
```
2nd qu... | 2018/07/02 | [
"https://Stackoverflow.com/questions/51131230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9648668/"
] | ```
{SELECT t1ID, AVG(FirstT.t2score) AS AVG1, AVG(SecondT.t2score) AS AVG1, AVG(ThirdT.t2score) AS AVG1
FROM T1 t
JOIN T1 FirstT ON FirstT.t1ID = t.t1ID AND FirstT.t1m1 NOT IN (t2m1,t2m2,t2m3) AND FirstT.t1m2 IN (t2m1,t2m2,t2m3)
JOIN T1 SecondT ON SecondT.t1ID = t.t1ID AND SecondT.t1m2 NOT IN (t2m1,t2m2,t2m3) AND Seco... | creating temporary table and inserting data to it may help you |
2,542,764 | When would one choose to use Rx over TPL or are the 2 frameworks orthogonal?
From what I understand Rx is primarily intended to provide an abstraction over events and allow composition but it also allows for providing an abstraction over async operations.
using the Createxx overloads and the Fromxxx overloads and canc... | 2010/03/30 | [
"https://Stackoverflow.com/questions/2542764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/84074/"
] | The main purpose of Rx is not to provide an abstraction over events. This is just one of its outcomes. Its primary purpose is to provide a composable push model for collections.
The reactive framework (Rx) is based on `IObservable<T>` being the mathematical dual of `IEnumerable<T>`. So rather than "pull" items from a ... | Some guidelines I like to follow:
* Am I dealing with data that I don't originate. Data which arrives when it pleases? Then RX.
* Am I originating computations and need to manage concurrency? Then TPL.
* Am I managing multiple results, and need to choose from them based on time? Then RX. |
6,633,024 | ### Intro
So I've been experimenting with the Objective-C low-level runtime APIs defined in `<objc/runtime.h` and following [Apple's documentation](http://developer.apple.com/library/mac/documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html). You can see the results of my playing [in this gist](https:/... | 2011/07/09 | [
"https://Stackoverflow.com/questions/6633024",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/376773/"
] | You can do it with [Google's Geocoding API](http://code.google.com/apis/maps/documentation/geocoding/). What you're actually looking for is reverse-geocoding, but it supports that too. You can have it return XML and then parse it for the postal code (a.k.a zipcode). Should be quite simple actually.
To use the API, sim... | There is no "easy way" to get the actual Zip Code of the user. You
could use the reverse geocoder function to do this but it doesn't
always return the Zip Code, nor is it always accurate. Either way,
you'll have to have location services and internet access active in
order to do it.
OR
--
Please check this [link](htt... |
100,119 | I'm in the USA right now and would like to get some more cash with my non-US ATM card. However, a random sampling of ATMs at large banks (Wells Fargo, Citibank) has shown ATM fees in the $5-6 range, which is kind of ridiculous.
**Which major US banks have the lowest ATM fees for foreign cards?**
I've seen [this](http... | 2017/08/14 | [
"https://travel.stackexchange.com/questions/100119",
"https://travel.stackexchange.com",
"https://travel.stackexchange.com/users/1893/"
] | Most states do *not* allow ATMs to charge foreign cards a fee. California, where I live, is an exception, and the Citibank ATM has a list of states where the fee will be imposed. Either you are here or in one of the other such states.
Many 7-11s have an ATM with $2 or less fee. You might also see if your home bank has... | I'm still looking for a more comprehensive answer, but I ended up withdrawing cash from a **Chase** ATM, which charged me a **$3** fee. |
4,929,549 | ```
if(heading == 2){
nextY = (y-1) % 20;
nextX = x;
}
```
When debugging this program, my heading is 2 and y = 0, however, when I come to this if statement, nextY becomes -1. Why is it not cycling properly? (0-19)? | 2011/02/08 | [
"https://Stackoverflow.com/questions/4929549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/546427/"
] | That's how mod operation generally works for negative numbers in programming (in all languages I tried it in).
But you can easily make number positive before doing mod
```
nextY = (y + 20 - 1) % 20;
``` | Modulo operators often return negative numbers for negative inputs. For example, C# will give you a number from `-356..359` for the expression `x % 360`.
Instead of subtracting 1 then taking modulo 20, you can add 19, which is the same thing but keeps the number positive, or you can use the ternary operator:
```
next... |
68,372,948 | I'm trying to see if I can use `dplyr`'s `coalesce` or something like it to combine rows in the same way `coalesce` combines columns.
I found some other similar posts but none that answer my question.
Here's a toy sample:
```
df <- read.table(sep = "|", header = F, stringsAsFactors = F, text =
"a|NA|NA|d|NA
NA|b|NA... | 2021/07/14 | [
"https://Stackoverflow.com/questions/68372948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7999936/"
] | You can also use the following solution:
```
library(dplyr)
library(janitor)
df %>%
mutate(across(everything(), ~ replace(.x, is.na(.x), unique(.x[!is.na(.x)[1:3]])[1]))) %>%
row_to_names(row_number = 1) %>%
slice(-c(1:2))
a b c d e
1 1 2 3 4 5
2 1 2 3 4 5
3 1 2 3 4 5
4 1 2 3 4 5
``` | Here is another solution using built-in functions and the native pipe operator:
```
df[1:3, ] |>
sapply(function(x) na.omit(x)[1]) |>
rbind(df[-(1:3), ])
# V1 V2 V3 V4 V5
# 1 a b c d e
# 4 1 2 3 4 5
# 5 1 2 3 4 5
# 6 1 2 3 4 5
# 7 1 2 3 4 5
``` |
201,093 | As the topic, how to prove that the only set in $\mathbb{R^1}$ which are both open and close are the $\mathbb{R^1}$ and $\emptyset$. I tried to prove by contradiction, but i can't really show that the assumption implies the contrary. | 2012/09/23 | [
"https://math.stackexchange.com/questions/201093",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/42220/"
] | Let $S\subset \Bbb R$ non-empty, open and closed. Fix $x\_0\in S$. Let $I:=\{r>0:[x\_0-r,x\_0+r]\subset S\}$. As $S$ is open, $I$ is non-empty. If $I$ is bounded, let $\{r\_n\}$ be a sequence which increases to $\sup I$. Then $x\_0+r\_n\in S$ for each $n$, and as $S$ is closed, $x\_0+\sup I\in S$. But $S$ is open, so w... | Assume $U$ and its complement $V$ are both non-empty open subsets of $\mathbb R$. Then there are $x \in U$ and $y \in V$ and by switching the roles of $U$ and $V$, if necessary, we may assume $x < y$. Now let
$$a = \sup\{b \in \mathbb R : [x,b] \subseteq U \}$$
(the supremum exists since $x \in U$ and $y \not\in U$ and... |
4,077,563 | I need to write a code that will copy one set of form values into another. And normally it is done by something like this:
```
<script type="text/javascript">
function copyGroup() {
if(document.formName.copy[0].checked){
document.formName.a1.value = document.formName.b1.value;
document.formName.a2.... | 2010/11/02 | [
"https://Stackoverflow.com/questions/4077563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/434218/"
] | Hope this help:
```
function copyElement(copyFrom, whereToCopy) {
if(document.formName.copy.checked){
document.formName.elements[whereToCopy].value = copyFrom.value;
}
}
</script>
<form name="formName">
<input type="text" name="a1" onkeypress="copyElement(this, 'b1')">
<br>
<input type="te... | Add onchange event to the elements and call your function. |
67,865,756 | I'm looking to calculate if there was an upgrade for a supplier, not the total count.
So, for each contract, for each supplier, was there an upgrade (regardless of the count/sum of upgrades)? If the result is yes, then the answer is 1.
[](https://i.s... | 2021/06/07 | [
"https://Stackoverflow.com/questions/67865756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16149504/"
] | Below formula should works. [Reference here](https://exceljet.net/formula/count-unique-values-with-criteria)
```
=IFERROR(ROWS(UNIQUE(FILTER(B2:B15, D2:D15>0))), 0)
``` | You could try the following:
[](https://i.stack.imgur.com/uINJD.png)
Formula in `G2`:
```
=SUM((D2:D15>0)*(IFERROR(1/COUNTIFS(A2:A15,A2:A15,B2:B15,B2:B15,D2:D15,">0"),0)))
```
This is an CS-entered array formula if you are not working through MS36... |
2,928,212 | I was going through the source code of jQuery. I'm having trouble understanding the wrapping strategy for the jQuery object.
```
(function( window, undefined ) {
// Define a local copy of jQuery
var jQuery = function( selector, context ) {
// The jQuery object is actually just the init constructo... | 2010/05/28 | [
"https://Stackoverflow.com/questions/2928212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/293407/"
] | Duplicate of [javascript: execute a bunch of asynchronous method with one callback](https://stackoverflow.com/questions/2911822/javascript-execute-a-bunch-of-asynchronous-method-with-one-callback/2911891#2911891)
```
function createCallback(limit, fn){
var finishedCalls = 0;
return function(){
if (++fi... | You can always use $.ajax with "async: false" in options and/or use proper callbacks (beforeSend, error, dataFilter, success and complete). |
11,250,297 | With `printf()`, I can use `%hhu` for `unsigned char`, `%hi` for a `short int`, `%zu` for a `size_t`, `%tx` for a `ptrdiff_t`, etc.
What conversion format specifier do I use for a `_Bool`? Does one exist in the standard?
Or do I have to cast it like this:
```
_Bool foo = 1;
printf("foo: %i\n", (int)foo);
``` | 2012/06/28 | [
"https://Stackoverflow.com/questions/11250297",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/712605/"
] | As you stated in a comment to @Jack, "6.3.1.1p1 says that the conversion rank of `_Bool` is less than the rank of all other standard integer types".
In a call to `printf`, a `char` or `short` will be promoted and passed on the stack as an `int` (or an `unsigned int`), so I would think that using `%d` as a format speci... | There is no. Just handling it like an `int` by using `%d` or `%i` specifier.
[`_Bool`](http://en.wikipedia.org/wiki/Compatibility_of_C_and_C++)
>
> In C99, a new keyword, \_Bool, is introduced as the new boolean type.
> In many aspects, it behaves much like an unsigned int, but conversions
> from other integer ty... |
24,127,587 | I'd like to store an array of weak references in Swift. The array itself should not be a weak reference - its elements should be. I think Cocoa `NSPointerArray` offers a non-typesafe version of this. | 2014/06/09 | [
"https://Stackoverflow.com/questions/24127587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/126855/"
] | A functional programming approach
=================================
No extra class needed.
Simply define an array of closures `() -> Foo?` and capture the foo instance as weak using `[weak foo]`.
```swift
let foo = Foo()
var foos = [() -> Foo?]()
foos.append({ [weak foo] in return foo })
foos.forEach { $0()?.doSom... | You could create wrapper around `Array`. Or use this library <https://github.com/NickRybalko/WeakPointerArray>
`let array = WeakPointerArray<AnyObject>()`
It is type safe. |
40,828,529 | It is my first time doing a Petri net, and I want to model a washing machine. I have started and it looks like this so far:
[](https://i.stack.imgur.com/QIEWc.png)
Do you have any corrections or help? I obviously know its not correct, but I am a beginner and not aware of the m... | 2016/11/27 | [
"https://Stackoverflow.com/questions/40828529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5762696/"
] | First comments on your net's way of working:
* there is no arrow back to the `off` state. So once you switch on your washing machine, won't you never be able to switch it off again ?
* `drain` and `dry` both conduct back to `idle`. But when idle has a token, it will either go to delicate or to T1. The conditions ("pr... | Apparently you're missing some condition to stop the process. Now once you start your washing will continue in an endless loop. |
46,481,699 | I just got DB server from infra team which configured by previous team.
I found out that the SQL Server Database can only be opened using Windows Authentication using installation name like "SQLEXPRESS\SQLEXPRESS"
I am working on this Database in local Database machine.
I am curious, why i can't use the localhost name... | 2017/09/29 | [
"https://Stackoverflow.com/questions/46481699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8643485/"
] | Just take row's parent click in adapter and catch the ID column from that click.
```
Item_ID.get(position);
```
And then pass this through the intent to the Activity where you want to show all the data. And then get that ID and query to the database to get all the data.
```
@Override
public Object getItem(int posit... | You can use `adapter.notifyDataSetChanged();` to refresh the listview. |
6,203,189 | I'm currently trying to make some show/hide content more accessible on a large site (in excess of 30,000 pages) and I've come across a weird bug when adding tabindex where a dotted border appears when clicking on the control to open the hidden content.
The set up with *p* tag which you click to fadeIn a *div* which sh... | 2011/06/01 | [
"https://Stackoverflow.com/questions/6203189",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/690363/"
] | whats about:
```
#content div.showHide p.showHideTitle {
outline: none !important;
}
```
You are setting the outline style for the pseudo class `:focus` but this may be "to late".
Here a simple [jsFiddle](http://jsfiddle.net/GPnxS/) | Have you tried setting the `css` with your script? Something like
```
$("#content div.showHide p.showHideTitle").focus(function () {
$(this).css('border','0');
});
``` |
36,980,868 | I am taking my first steps with Angular 2 and angular in general, and I am wondering how to setup a landing page.
My goal is to show a landingpage everytime the user does not have a token in local storage or in a cookie.
My app.component.ts looks like this
```
import {Component} from 'angular2/core';
import {ROUTER... | 2016/05/02 | [
"https://Stackoverflow.com/questions/36980868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3648229/"
] | You can override the router-outlet and check on activation, if the token is present. Something like this:
```
import {Directive, Attribute, ElementRef, DynamicComponentLoader} from 'angular2/core';
import {Router, RouterOutlet, ComponentInstruction} from 'angular2/router';
@Directive({
selector: 'router-outlet'
}... | You can just redirect to a specific route on load when the token is not available.
```
export class AppComponent {
constructor(private router:Router) {
if(!hasToken()) {
router.navigate(['/LoginForm']);
}
}
}
```
Alternatively you can create a custom `RouterOutlet` that checks for each route if it ... |
71,321,951 | I am trying to move CSV files in SFTP folder to GCS using Data Fusion. But I am unable to do it and throwing below error:
Here are the properties of both FTP and GCS plugins. Surprisingly, I could see the data in PREVIEW mode in all the stages but when I try to deploy the pipeline it fails. I tried using CSVParser as ... | 2022/03/02 | [
"https://Stackoverflow.com/questions/71321951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10601337/"
] | I solved this issue by changing the Pipeline execution engine from SPARK to MAPREDUCE in Data Fusion. Now it is working. | Well I have dig a lot on this, I found that this plugins have issues when running [ftp-plugins](https://github.com/data-integrations/ftp-plugins), so at the moment you can't do much on it. Fortunately, there are workarounds for this. To name a few here are some:
* You can use an old version ( Dataproc image to 1.5/1.3... |
42,906,515 | I have the following entity:
```
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
class Quote
{
use SourceTrait;
use TimestampableEntity;
private $quoteId;
private $startDate;
private $endDate;
public function getStartDate(): ?\DateTime
{
ret... | 2017/03/20 | [
"https://Stackoverflow.com/questions/42906515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/719427/"
] | Let's walk through your code line by line.
```
$entity->setStartDate($agreement->getEndDate()->modify('+1 day'));
```
[`modify()`](http://php.net/manual/en/datetime.modify.php) **mutates the `DateTime` object it is called upon**.
This line added +1 day to `$agreement->getEndDate()` AND the **same** DateTime is pass... | It seems to be a problem with the object you are trying to persist. You are getting the right result when you make dump(), but the datetime object is being modified later, so when you persist the object, all of the values get your last datetime result.
I recommend you to make "clone" in your datetime objects, and set t... |
58,201,577 | I have two tables CDmachine and trnasaction.
CDMachine Table with columns CDMachineID, CDMachineName, InstallationDate
Transaction table with columns TransactionID,CDMachineID,TransactionTime,Amount
I am calculating revenue using the below query but it eliminates the machine without any transaction
```
SELECT CDMac... | 2019/10/02 | [
"https://Stackoverflow.com/questions/58201577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10689523/"
] | Move the `WHERE` condition to the `ON` clause:
```
select m.MachineName, sum(t.Amount)
from CDMachine m left join
Transaction t
on m.CDMachineID = t.CDMachineID and
t.TransactionTime between '2019-01-01' and '2019-01-31'
group by m.CDMachineName
order by 2;
```
The `WHERE` clause turns the outer jo... | Even though you are using a LEFT JOIN, the fact that you have a filter on a column from the joined table causes rows that don't meet the join condition to be removed from the result set.
You need to apply the filter on transaction time to the transactions table, before joining it or as part of the join condition. I wo... |
52,804,282 | I have use two different classes:
*ListTitle.kt*
```
class ListTitle {
var id: Int? = null
var title: String? = null
constructor(id:Int, title: String) {
this.id = id
this.title = title
}
}
```
*ListDes.kt*
```
class ListDes {
var address: Int? = null
var des: String? = nul... | 2018/10/14 | [
"https://Stackoverflow.com/questions/52804282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10503160/"
] | You can use [zip](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/zip.html) to merge two lists into one which has `Pairs` as elements.
```
val listOfTitle = listOf(ListTitle(1, "Hello"), ListTitle(2, "World"))
val listDes = listOf(ListDes(1, "World Des"), ListDes(2, "Hello Des"))
val pairList = listOf... | If you just want to print the values you could do this:
```
listOfTitle.forEach {
val id = it.id
println(it.title + " " + listDes.filter { it.address == id }[0].des)
}
```
will print the matching `des` for each `id`:
```
Hello World Des
World Hello Des
```
The above code is supposed to work when bot... |
273,723 | I'd like to run these scans on our test/dev sites, but they're currently behind a IP restricted firewall.
Are you able to provide your public IPs so that I can whitelist them for | 2019/05/07 | [
"https://magento.stackexchange.com/questions/273723",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/76875/"
] | You can override the class **\Magento\Catalog\Block\Adminhtml\Product** using di.xml preference as describe below.
Assume you are using a custom module name "**Company\_MyModule**"
**step 1:** create **di.xml** under YOUR-MAGENTO-**ROOT/app/code/Company/MyModule/etc/adminhtml**
File: **YOUR-MAGENTO-ROOT/app/code/Com... | To disable access from direct URL.
You can override the class **\Magento\Catalog\Block\Adminhtml\Product** using di.xml preference as described below.
Assume you are using a custom module name "**Company\_MyModule**"
**step 1:** create **di.xml** under YOUR-MAGENTO-**ROOT/app/code/Company/MyModule/etc/adminhtml**
F... |
153,861 | So I am redoing light fixtures in my 1946 house located in the USA. I guess I'm overly scared of asbestos, and just wondering on your opinion if this household branch wire is asbestos containing.
It is hard to find images on the internet showing examples of what is and what is not. I could get this tested, but at the ... | 2019/01/01 | [
"https://diy.stackexchange.com/questions/153861",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/94995/"
] | I've been in the industry for over 40 years and have never heard of asbestos in the old wiring insulation. It is oil-impregnated cloth I believe. The more pressing problems that I see from your photo are that the cloth insulation may start to crumble off the copper conductors when you manipulate the wires and that the ... | Even if there is asbestos present in that box, I'd say the hazards of messing with the wiring are far greater than the asbestos exposure, you don't develop asbestosis from the trace exposure that would be possible here. A little reading of materials readily available online may give your concerns some perspective.
Th... |
69,766,994 | I am getting the below error while creating a Logic App from the portal.
>
> "Creation of storage file share failed with: 'The remote server
> returned an error: (403) Forbidden.'. Please check if the storage
> account is accessible."
>
>
>
While selecting the initial Logic App configuration, I am selecting an ex... | 2021/10/29 | [
"https://Stackoverflow.com/questions/69766994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1198379/"
] | It seems not to be possible to deploy a Standard Logic App from the portal, if the targeted storage account will be hidden behind a firewall. The workaround is to [deploy the Standard Logic app via ARM template](https://github.com/VeeraMS/LogicApp-deployment-with-Secure-Storage/). What will happen is that first the Sto... | I had the same error when I deploy my logic app via Bicep, the storage account for the logic app has firewall rules set.
The error message:
>
> ##[error]undefined: Creation of storage file share failed with: 'The remote server returned an error: (403) Forbidden.'. Please check if the storage account is accessible.
>... |
10,100,940 | how does the browser differentiate a cookie is from client-side created (JavaScript) or server-side created (ASP.NET). Is it possible to delete cookie created from server side in client side and vice versa, I'm struggling to delete a cookie was created from client-side using javascript in ASP.NET code-behind. | 2012/04/11 | [
"https://Stackoverflow.com/questions/10100940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/797528/"
] | >
> how does the browser differentiate a cookie is from Client side(javascript created) or serverside created (Asp.net).
>
>
>
It doesn't. A cookie is a cookie.
The closest it comes is the *HTTP Only* flag, which allows a cookie to be hidden from JavaScript. (This provides a little defence against XSS cookie thef... | As far as I know it is possible if there is not property **HttpOnly** [owasp](https://www.owasp.org/index.php/HttpOnly) [wikipedia](http://en.wikipedia.org/wiki/HTTP_cookie#HttpOnly_cookie).
In chrome, for the cookies, there is a field - **Accessible by script**, which indicates if HttpOnly is set. |
3,645,712 | this question is from Codechef.com [if anyone is still solving this question dont look further into the post before trying yourself] and although it runs right, but i need to make it a lot faster.i am a beginner in c,c++.(i know stuff upto arrays,strings and pointers but not file handling etc).So is there a way to make... | 2010/09/05 | [
"https://Stackoverflow.com/questions/3645712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/439970/"
] | >
> 1) Increase the numbers between indices A and B by 1. This is represented by the command "0 A B"
>
>
> 2) Answer how many numbers between indices A and B are divisible by 3. This is represented by the command "1 A B".
>
>
>
Initially numbers are 0 and thus are divisible by 3. Increment by one make the number... | Your solution seems fine I think apart from lacking any bounds checking. Maybe use an 'else' when checking 'c' or a switch, but this will save you trivial amounts of time.
I don't think you'll find something as useless as this in any book. |
59,785,266 | I am beginner on rails. I want to list Brands-Products list. Brands and products must be association. I dont know what to do. Please suggest me example like this. | 2020/01/17 | [
"https://Stackoverflow.com/questions/59785266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12038747/"
] | The walker, I assume, asynchronously accesses files starting from your defined folder, `/etc/`, and as it access files and folders as it's walking, it fires events.
Every time it accesses any element, whether its a file or a folder or whatever, I would imagine it fires the `'entry'` event.
Every time it accesses a fi... | Those are function parameters. They define variable names that get values when the function is called.
```js
const myFunction = function(dir, stat) {
console.log('Got directory: ' + dir)
};
myFunction("Foo", "Bar");
```
It is just that the function is called by *code you did not write yourself*. |
116,074 | I'm searching for an simple shell script to `mv` all folders in `/var/www/uploads/` that containing **Math** or **Physics** in the name to `/mnt/Backup/`. | 2014/02/20 | [
"https://unix.stackexchange.com/questions/116074",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/51005/"
] | Granting 775 permissions on a directory doesn't automatically mean that all users in a certain group will gain `rwx` access to it. They need to either be the owner of the directory or to belong to the directory's group:
```
$ ls -ld some_dir
drwxrwxr-x 2 alex consult 4096 Feb 20 10:10 some_dir/
^ ^
... | This will make alex and ben to colabrate each other in this Directory, And they can't collab in other Dir..
Modify the User group using
```
# usermod -a -G alex,ben alex
```
Then change the Permission for Folder
```
# chown alex:ben consult_documents
```
Check here i have worked it around
```
$ sudo usermod -... |
25,419,618 | I am wondering how to change the `width` of the line at the bottom of the `nav-tabs`.
On their display page <http://getbootstrap.com/components/> where the `nav-tabs` part the line at the bottom stops just before the end of the page.
But mine is keeping at 100%, wondering how do i change the `length` of that
I trie... | 2014/08/21 | [
"https://Stackoverflow.com/questions/25419618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3884114/"
] | I have wrap the ul with a div and set left-right padding on it
```
<div class="navWrapper">
<ul class = "nav nav-tabs " role="tablist">
<li class="active" id="opened"><a href= "#" >Open </a></li>
<li id="completed"><a href ="completedlisting.html" >Completed </a></li>
<li id="completed"... | .nav-tabs {
```
border-bottom-width: 50px;
```
} |
11,935,480 | I've just finished the first working version of a more complex bash script, and I'm wrapping my head around on how to maintain the scripts version.
Why do I need this? Following [GNU Coding Standards For Commandline Interfaces](http://www.gnu.org/prep/standards/html_node/Command_002dLine-Interfaces.html) I've added a ... | 2012/08/13 | [
"https://Stackoverflow.com/questions/11935480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1178669/"
] | The hook-based answers previously given tightly couple the synchronization of the version string with a `git commit`; however it sounds like you want it to work the other way around, i.e. the version is extracted from manually created `git tag` metadata. It turns out that in fact this is pretty much the approach the [`... | >
> Still, I don't know how to keep the version 'up-to-date'.
>
>
>
I do like the post-hook recommendations. However, an alternative approach, you could also use a build system if you already have one available. Do you have an automatic build system? Jenkins or Bamboo? Our build system creates a new tag for each s... |
35,461,643 | Commonly, to find element with property of max value I do like this
```
var itemWithMaxPropValue = collection.OrderByDescending(x => x.Property).First();
```
But is it good way from performance point of view? Maybe I should do something like this?
```
var maxValOfProperty = collection.Max(x => x.Property);
var item... | 2016/02/17 | [
"https://Stackoverflow.com/questions/35461643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5520747/"
] | Both solutions are not very efficient. First solution involves sorting whole collection. Second solution requires traversing collection two times. But you can find item with max property value in one go without sorting collection. There is MaxBy extension in [MoreLINQ](https://www.nuget.org/packages/morelinq/) library.... | The maximum element under some specified function can also be found by means of the following two functions.
```
static class Tools
{
public static T ArgMax<T, R>(T t1, T t2, Func<T, R> f)
where R : IComparable<R>
{
return f(t1).CompareTo(f(t2)) > 0 ? t1 : t2;
}
public static T ArgMax<T, R... |
144,706 | We had a big argument last night with vague conclusions. Is the current with a frequency less than 1 Hz considered DC?
It would still resemble a wave... | 2014/12/20 | [
"https://electronics.stackexchange.com/questions/144706",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/61807/"
] | As others have already pointed out, you can have AC of as low a frequency as you wish.
I think it's worth adding, however, that at such low frequencies it *mostly* won't act much like most of us usually think of AC acting.
Just for an obvious example, you can typically think of a capacitor as allowing AC to flow thro... | Of course. 1 Hz is once per second, and a second is a fairly arbitrary amount of time. If we had settled on 100 seconds per minute, 60 times per minute would have been 0.6 Hz. |
2,534,339 | debuging this class the SelectTemplate Method is run 2 times, but why?
The first time the item is always null.
```
public class PersonDataTemplateSelector : DataTemplateSelector
{
public override DataTemplate SelectTemplate(object item,DependencyObject container)
{
if (item is Person)
{
... | 2010/03/28 | [
"https://Stackoverflow.com/questions/2534339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/252289/"
] | If your Visual Studio is lincesed, of course it is legal. You can use the built-in publish tool in Visual Studio, or use a software like [InstallShield](http://www.flexerasoftware.com/products/installshield.htm) for the installation. | Yes absolutely as long as your license of Visual Studio is legal. |
15,667,938 | I'm confused about the iteration process in python
I have:
```
numbers = [0,1,2,3,4,5]
for i in numbers:
v = numbers
print v
```
Here is the end of loop
but, in C , C++ , Java we know the line inside the `{ }` will be executed repeatedly, or if not given curly braces then the next statement after the loop, ... | 2013/03/27 | [
"https://Stackoverflow.com/questions/15667938",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2190689/"
] | In Python, the indentation, rather than brackets, determines block scope, so in this example both the indented lines will be executed once per iteration of the loop.
This is the single weirdest thing about Python for programmers coming from the C/Java language families, but you get used to it fairly quickly. | Just as an additional note, I think your original code is not doing what I think you want it to do - which is print the numbers 1-5 on their own line. It should be (using Python 3):
```
numbers = [0,1,2,3,4,5]
for i in numbers:
print(i)
```
If you run the following code:
```
numbers = [0,1,2,3,4,5]
v = numbers
... |
4,321,386 | How do I create an object of an abstract class and interface? I know we can't instantiate an object of an abstract class directly. | 2010/12/01 | [
"https://Stackoverflow.com/questions/4321386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/526090/"
] | You can not instantiate an abstract class or an interface - you can instantiate one of their subclasses/implementers.
Examples of such a thing are typical in the use of Java Collections.
```
List<String> stringList = new ArrayList<String>();
```
You are using the interface type `List<T>` as the type, but the instan... | You can provide an implementation as an anonymous class:
```
new SomeInterface() {
public void foo(){
// an implementation of an interface method
}
};
```
Likewise, an anonymous class can extend a parent class instead of implementing an interface (but it can't do both). |
52,468,956 | ```
import torch
import torch.nn as nn
import torch.optim as optim
import torch.utils.data as data
import torchvision.models as models
import torchvision.datasets as dset
import torchvision.transforms as transforms
from torch.autograd import Variable
from torchvision.models.vgg import model_urls
from torchviz import ma... | 2018/09/23 | [
"https://Stackoverflow.com/questions/52468956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1436508/"
] | Here is how you do it with `torchviz` if you want to save the image:
```
# http://www.bnikolic.co.uk/blog/pytorch-detach.html
import torch
from torchviz import make_dot
x=torch.ones(10, requires_grad=True)
weights = {'x':x}
y=x**2
z=x**3
r=(y+z).sum()
make_dot(r).render("attached", format="png")
```
screenshot o... | This might be a late answer. But, especially with `__torch_function__` developed, it is possible to get better visualization. You can try my project here, [torchview](https://github.com/mert-kurttutan/torchview)
For your example of resnet50, you check the colab notebook, [here](https://colab.research.google.com/github... |
16,680,550 | I have a gridview which is bonded totally programatically . I want to hide some columns and also rich them to show them in the label.
Here is my gridview :
```
<Gridview ID=Gridview1 runat="server" ></Gridview>
```
I want to hide EmpID and UnitID . and want to show them in a label on the front-end side
```
EmpID ... | 2013/05/21 | [
"https://Stackoverflow.com/questions/16680550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2407340/"
] | If you want to hide a column base on a logic, you want to use [RowDataBound](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound.aspx).
It is a bit easy to maintain in the future.
Here is the sample. You can hide or show whatever columns you like.
. Note that 名前 is a native Japanese word and i... | 会社{かいしゃ}の名前{なまえ} is grammatically fine, and while compound nouns are sometimes formed by simply eliminating the の particle (e.g.,本{ほん}の棚{たな} -> 本棚{ほんだな} or 勉強{べんきょう}の不足{ふそく} -> 勉強不足{べんきょうぶそく}), in this case the word you are looking for is: 会社名{かいしゃめい} (the *on-yomi* of 名 is generally used in compound nouns and has the ... |
3,036,386 | how do i change the item selected in a combobox selection based on a selection of a datagrid object? | 2010/06/14 | [
"https://Stackoverflow.com/questions/3036386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/283166/"
] | When writing a lambda, the act of capturing variables *significantly* alters the construction of the underlying code (moving variables into fields of compiler-generated classes, that could very easily themselves be chained closure-contexts).
Not even considering the general *complexity* of doing this, it would then ha... | If you still need to use Visual Studio 2013, you can actually write a loop, or lambda expression in the immediate window using also the package manager console window. In my case, I added a list at the top of the function:
```
private void RemoveRoleHierarchy()
{
#if DEBUG
var departments = _unitOfWork... |
9,803,298 | Say I have a function c[i] = f(x[i], y[i]). I have the input value arrays x and y of equal length and I want to calculate the values of array c in the end. How do I get that using LINQ?
i.e. without having to write:
```
c = new double[x.Length];
for (int i = 0; i < x.Length; i++)
{
c[i] = f(x[i], y[i]);
}
``` | 2012/03/21 | [
"https://Stackoverflow.com/questions/9803298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/300929/"
] | Use [`Zip`](http://msdn.microsoft.com/en-us/library/dd267698.aspx) method, e.g.:
```
int[] x = { 1, 2, 3 };
int[] y = { 4, 5, 6 };
var result = x.Zip(y, (i, j) => i + j);
```
or if you have already method with adequate params, simply use:
```
var result = x.Zip(y, Function);
// in this sample Function looks like:
... | You can use a simple `Select`:
```
var c = x.Select((x_i, i) => f(x_i, y[i]));
```
If `c` needs to be an `int[]` instead of `IEnumerable<int>`, append `ToArray` to the end:
```
var c = x.Select((x_i, i) => f(x_i, y[i])).ToArray();
``` |
11,839,766 | in magento on order confirmation email is sent to admin in HTML format,
but i want to change it to plain text format so how and from where i can change that format only for admin, customer should get email in HTMl format as it is.
Can anyone please give me solution for this?
Thanks. | 2012/08/07 | [
"https://Stackoverflow.com/questions/11839766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1537552/"
] | For future readers, **do not edit core files** as others suggest. You can achieve this in config alone with a *tiny* custom module.
I have AheadWorks' blog module installed, you may not, or you may have other modules that need their email format overridden. So, adjust accordingly.
Create `app/etc/modules/YourNameSpac... | First create custom email template from `Transactions emails` and text type set as plain. Note down that template Id. and use in below file.
At `\app\code\local\Mage\Sales\Model\Order.php` `sendNewOrderEmail()` load manually template is and sent variables to that and send email. |
25,512,548 | I am trying to force my site to load in HTTPS. I can create a redirect in PHP which works for PHP files, but I want all requests forced to HTTPS - JS, CSS, Images, etc.
Here's what I have in my .htaccess:
```
ErrorDocument 401 default
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteR... | 2014/08/26 | [
"https://Stackoverflow.com/questions/25512548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3563982/"
] | Keep your `http` to `https` rules before internal WP rule:
```
ErrorDocument 401 default
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=302]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f... | Set a 301 permanent redirect which is more SEO friendly. Already tested:
```
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect all traffic to https
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
# Wordpress rules
RewriteBase /
RewriteRule ^ind... |
3,939,618 | let $x$ be in this interval: $[0, 2\pi]$. the exercise's request is to find the domain of this function:$$\sqrt{(\sin(x))^2 + \sin x}$$
Here's my attempt to solve it:
1. I found the domain of the square root: $$(sin (x))^2 + \sin x \geq 0$$
In this case, I've found that $$\sin x \ge 0 $$ and that: $$\sin x \ge -1 $$
... | 2020/12/08 | [
"https://math.stackexchange.com/questions/3939618",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/583624/"
] | Let $t = \sin x \,\, (-1 \leq t \leq 1)$
The domain of the function will become:
$$t^2 + t \geq 0$$
$$\implies t \in (-\infty, -1] \cup [0, +\infty)$$
But $-1 \leq t \leq 1 \implies t = -1$ or $0 \leq t \leq 1$
* $t = -1 \implies \sin x = -1 \implies x = -\dfrac{\pi}{2} + k2\pi \implies x = \dfrac{3\pi}{2}$ (since... | What if $\sin x(\sin x+1)=0?$
Else we need $\sin x(\sin x+1)>0$
If $\sin x>0,\sin x+1>0\iff\sin x>-1\implies \sin x>$ max$(0,-1)$
$\implies2n\pi\le x\le2n\pi+\pi$
What if $\sin x<0?$ |
105,826 | Wearing a hat has become so widespread in the orthodox community but what is it’s origin? Is it based off of anything from the Torah or Chazal? How old is the custom to wear a hat? And when did it become so widespread? | 2019/07/23 | [
"https://judaism.stackexchange.com/questions/105826",
"https://judaism.stackexchange.com",
"https://judaism.stackexchange.com/users/16397/"
] | This is actually a very complicated question. I will begin by discussing any religious or Torah requirements regarding a head covering, then talk about hats and their relationship to Jews.
There is no religious origin to wear a "hat." By all accounts wearing a hat is a non Jewish custom. The closest thing to an offici... | The idea of a religious head covering seems to have been a מנהג since ancient times, as seen in Sepher Shemuel II 15:30
>
> לוְדָוִ֡ד עֹלֶה֩ בְמַעֲלֵ֨ה הַזֵּיתִ֜ים עֹלֶ֣ה | וּבוֹכֶ֗ה וְרֹ֥אשׁ לוֹ֙ חָפ֔וּי וְה֖וּא הֹלֵ֣ךְ יָחֵ֑ף וְכָל־הָעָ֣ם אֲשֶׁר־אִתּ֗וֹ חָפוּ֙ אִ֣ישׁ רֹאשׁ֔וֹ וְעָל֥וּ עָלֹ֖ה וּבָכֹֽה
>
>
> And Da... |
16,602,807 | In JAVA I am trying to programmatically tell if 2 images are equal when displayed on the screen (AKA same image even though they have different [color spaces](https://en.wikipedia.org/wiki/Color_space). Is there a piece of code that will return a boolean when presented 2 images?
One of the examples I have is a RGB PNG... | 2013/05/17 | [
"https://Stackoverflow.com/questions/16602807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/473290/"
] | You can try this
[Example](https://web.archive.org/web/20121108205937/http://www.lac.inpe.br/JIPCookbook/6050-howto-compareimages.jsp)
***Wayback Machine to the rescue here***
They explain how to compare two images | If you mean exactly the same, compare each pixel.
If you mean compare a RGB image and a greyscale image, you need to convert the RGB to greyscale first, for doing this, you need to know how you did RGB->Greyscale before, there're different ways of doing this and you could get different results.
Edit, if the method it... |
5,056,897 | What should I learn first if I want to build a web application? I just had an excellent idea that I want to work on for a few years myself. I don't have any experience programming besides doing HTML and some bits of CSS. I'm a novice in using the command line (Terminal) in Linux but I have been trying to improve myself... | 2011/02/20 | [
"https://Stackoverflow.com/questions/5056897",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/426313/"
] | I agree with Marc's comment above, but I guess what you're looking for is probably something like [RavenDB](http://ravendb.net/). It's developed specifically with .NET in mind, so would probably seem more "C# friendly" than others such as CouchDB or MongoDB, etc.
Keep in mind, however, that the different NoSQL impleme... | Mongo recently released and is subsequently supporting a native C# driver. Source code is on Github. See here for more details: <http://www.mongodb.org/display/DOCS/CSharp+Language+Center> |
16,954,556 | I have a file with numbers like this:
0.122
1.44
5.44
I want to write a shell script that will give me percentage for the following criteria:
* % of data less than 0.1
* % of data between 0.1 and 0.2
* % of data between 0.2 and 0.5
* % of data greater than 1
I am trying with awk, but not able to get it throug... | 2013/06/06 | [
"https://Stackoverflow.com/questions/16954556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/336045/"
] | Something like this would do:
```
awk '
$1 < 0.1 { c[0]++ }
$1 < 0.2 { c[1]++ }
$1 < 0.5 { c[2]++ }
$1 > 1 { c[3]++ }
END {
c[2] -= c[1];
c[1] -= c[0];
t = c[0] + c[1] + c[2] + c[3];
print (c[0]/t) * 100, (c[1]/t) * 100, (c[2]/t) * 100, (c[3]/t) * 100
}' input
``` | ```
cat file | python -c 'import numpy,sys; a=[float(l.strip()) for l in sys.stdin];b=numpy.histogram(a,bins = [0,.1,.2,.5,1,max(a)])[0];print [x*100/sum(b) for x in b]'
``` |
34,776,161 | I was exploring ways how to implement a general-purpose/DSL language for .NET platform. From what I saw, there are several tools that make language implementation (parsing source code) relatively easy. *Irony*, *Yacc*, *ANTLR*… the problems with these projects are that some are not evolving, some generate slow parsers,... | 2016/01/13 | [
"https://Stackoverflow.com/questions/34776161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1498611/"
] | Roslyn is not meant for this.
The best you'll be able to do with Roslyn is generate a C# (or VB) SyntaxTree & Compilation after you parse your language by hand, letting Roslyn take care of the type system & codegen.
And this will only work at all if your language can be completely translated to C# (or VB) syntax. | I know this is an old thread, but your best bet (in visual studio at least) is to create an IVsSingleFileGenerator that converts your code into c# or other Roslyn language. |
308,552 | I want to install packages by yum in the background as the following
```
yum -y install ntp &
```
but this example isn't working and yum installation not installing in the background. How to fix my command in order to enable `yum` to install the `ntp` in the background ?
```
# yum -y install ntp &
[1] 26960
09:03:... | 2016/09/08 | [
"https://unix.stackexchange.com/questions/308552",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/153544/"
] | Use the `-q` flag for the background job to suppress output.
From the `yum` man pages:
>
> -q, --quiet
>
>
> Run without output. Note that you likely also want to use -y.
>
>
> | It appears yum is running in the background (evidenced by the `[1] 26960` line in the output -- here, 26960 is the process id of the background'd yum), but it is still sending some output to the terminal. To get around this, add an output redirect for stdout and/or stderr as appropriate:
```
yum -y install ntp >/tmp/y... |
8,441,749 | In general, whenever you're representing a range of any kind, you have several choices for what kinds of values to choose for the beginning and ending of your range. For example, if you want to have a range containing the integers 1, 2, 3, 4, 5 you could choose these possible values:
* begin = 0, end = 5 (aka begin < ... | 2011/12/09 | [
"https://Stackoverflow.com/questions/8441749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/167958/"
] | I was hoping someone would give me a link to a nice paper that [E.W. Dijkstra](http://en.wikipedia.org/wiki/Edsger_W._Dijkstra) wrote on the topic. I managed to plug just the right search terms into Google, and found the link I was looking for. The paper is ["Why numbering should start at 0" and also covers why ranges ... | I personally would choose the option
* begin = 1, end = 5 (aka begin <= x <= end)
I like to keep my structures as clear and similar to the human reasoning as possible. If you tell someone "the numbers between 1 and 5" both 1 and 5 are meant to be in the set.
Of course if there are good technical reasons to use somet... |
6,794,344 | Using [`Text::Ngram`](http://search.cpan.org/perldoc?Text%3a%3aNgram) I have
```
my $c = ngram_counts($text, 3);
my %ct = %($c);
```
which doesn't work (`Scalar found where operator expected`). I think this is a combination of not knowing what I'm doing (still not very good with Perl) and being confused about what e... | 2011/07/22 | [
"https://Stackoverflow.com/questions/6794344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/341362/"
] | Use curly braces to dereference the hash reference:
```
my %ct = %{ $ct }; # %$ct would also work
```
And you probably want to use `<=>` for numerical sorting instead of the ASCII-betical sorting `cmp`. | There's no need to make a copy into another hash, just use the reference.
```
my $c = ngram_counts($text, 3);
my @keys = sort {$c->{$a} <=> $c->{$b} } keys %$c;
foreach my $k (@keys) {
print "$k: $c->{$k}\n"
}
```
See <http://perlmonks.org/?node=References+quick+reference> for some easy to remember rules for de... |
366,720 | Currently my code is organized in the following tree structure:
```
src/
module1.py
module2.py
test_module1.py
test_module2.py
subpackage1/
__init__.py
moduleA.py
moduleB.py
test_moduleA.py
test_moduleB.py
```
Where the `module*.py` files contains the sourc... | 2008/12/14 | [
"https://Stackoverflow.com/questions/366720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36131/"
] | If they all begin with `test` then just `nosetest` should work. Nose automatically searches for any files beginning with 'test'. | I'll give a [Testoob](http://www.testoob.org) answer.
Running tests in a single file is like Nose:
```
testoob test_foo.py
```
To run tests in many files you can create suites with the Testoob collectors (in each subpackage)
```
# src/subpackage?/__init__.py
def suite():
import testoob
return testoob.collectin... |
88,422 | I would like to enable all members of an organic group to subscribe to a reminder, that sends an e-mail depending on a date field.
To be more specific: The group has a group content with a date field. Now I would like a mail being sent a specific time before this date becomes actual.
Would would the best way to do this... | 2013/10/09 | [
"https://drupal.stackexchange.com/questions/88422",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/5950/"
] | When it comes to right on schedule or specific time, you need to have crontab on server. Role of cron tab will be none other than calling your cron.php file which in turn allows all modules to set the cron. But this is half of the process since with core drupal cron process you can not have much control on setting sche... | Off the top of my head I think [Maestro](http://drupal.org/project/maestro) can do this with a `Batch Task` or a `Batch Function Task`. In drupal typically `Cron` is setup to run periodically, say every hour or every 15 minutes.
If you truly want a `specific time` for these notifications to go out you need a (cron) ta... |
203,233 | Context
=======
A player amidst one of the groups decided to try his hand at DM'ing for the first time. It's going relatively well despite teething trouble (primarily from a mismatch of expected ideas after forgoing a session 0 against multiple people suggesting it).
Skip forward a few sessions and level 5 where the ... | 2022/12/06 | [
"https://rpg.stackexchange.com/questions/203233",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/77409/"
] | Unfortunately, there isn't
--------------------------
There aren't any unofficial, or official, metrics on the optional rules that different tables use across the world.
As for your situation, I don't think that getting this information will be helpful or useful, even if it was available. While having it would be int... | I'll be a bit of a contrarian; While I agree that trying to pressure a DM on which optional rules to allow, or any other ruling, is undesirable and often counterproductive, I am not enthused with the idea of a **secret set** of "expected optional rules".
Without explicitly knowing flanking is active, I would not expec... |
2,483,755 | I am writing some software (in C++, for Linux/Mac OSX) which runs as a non-privileged user but needs root privileges at some point (to create a new virtual device).
Running this program as root is not a option (mainly for security issues) and I need to know the identity (uid) of the "real" user.
Is there a way to mim... | 2010/03/20 | [
"https://Stackoverflow.com/questions/2483755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/279259/"
] | You can't gain root privileges, you must start out with them and reduce your privileges as needed. The usual way that you do this is to install the program with the "setuid" bit set: this runs the program with the effective userid of the file owner. If you run `ls -l` on `sudo`, you'll see that it is installed that way... | Normally this is done by making your binary suid-root.
One way of managing this so that attacks against your program are hard is to minimize the code that runs as root like so:
```
int privileged_server(int argc, char **argv);
int unprivileged_client(int argc, char **argv, int comlink);
int main(int argc, char **arg... |
54,994,600 | The following code snippet works fine until I uncomment the `plt.legend()` line:
```
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
x = np.linspace(-1, 1)
y = np.linspace(-1, 1)
X, Y = np.meshgrid(x, y)
Z = np.sqrt(X**2 * Y)
fig = plt.figure()
ax = fig.add_subplot(111, pro... | 2019/03/05 | [
"https://Stackoverflow.com/questions/54994600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9270181/"
] | Hi I found that is a bug still the library developers are trying to figure out it.
I have found the following thread about the issue in [git](https://github.com/matplotlib/matplotlib/issues/4067)
Their suggestion they have given is to get the plotting
```
surf = ax.plot_surface(X, Y, Z, label='h=0')
surf._facecolors2... | Update to @AmilaMGunawardana's answer
-------------------------------------
As of `matplotlib 3.3.3`, `_facecolors3d` and `_edgecolors3d` do not exist. So, instead of this:
```
surf._facecolors2d = surf._facecolors3d
surf._edgecolors2d = surf._edgecolors3d
```
that would lead to a similar `AttributeError`, try this... |
30,097,626 | I have two nested states, consisted of a parent abstract state and a child state:
```
.state('app.heatingControllerDetails', {
url: "/clients/:clientId/heatingControllers/:heatingControllerId",
abstract: true,
views: {
'menuContent': {
... | 2015/05/07 | [
"https://Stackoverflow.com/questions/30097626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1908173/"
] | Please correct the sql query section in your code
currently it is
```
$sel = "select cf_id from client_file where cf_id='".$_POST['rmvfile']."'";
```
it should be
```
$sel = "select * from client_file where cf_id='".$_POST['rmvfile']."'";
```
As now it is fetching only cf\_id, you didn't get the other fields. | You have not closed your image-tag properly and the quotes are not closed as well
```
<img src="image/delete1.png" alt="delete" style="width:10px;height:10px"
title="Remove" onclick="myFunction('.$fet['cf_id'].');">
```
And as stated by manikiran, check the if.condition. |
21,631,723 | I have drop-down box where users can select Yes or No, if user selects Yes from the drop-down then i want to show a confirmation box that shows Yes or No option. If only user selects Yes in the confirmation box then i want to proceed calling my other function which makes an update to the backend database. If user selec... | 2014/02/07 | [
"https://Stackoverflow.com/questions/21631723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1669621/"
] | The code has too many Yes/No. I hope it won't confuse to user -
If a user selects **YES** in **DropDownList**, a **Confirmation Message** will be prompted.
If the user selects **YES** in **Confirmation Message**, **DropDownList** will post back to server.
```
<asp:DropDownList ID="ddl_CloseTask" Width="157px"
... | You would want to prompt the user on the "onchange" event of your DropDownList control. You can add the call to your javascript function in the aspx markup or in the code behind. (I used the code behind in this case).
So, your code behind would look something like this:
```
protected void Page_Load( object sender, Ev... |
56,561,444 | I have following scenario:
I have compound object which includes lists in it, I want to pass a 'path' to it like - Result.CustomerList.Name
Result is an object that contains List of Customer, but also contains many other lists of different types. I want to get to the Names of the customers in this particular case.
W... | 2019/06/12 | [
"https://Stackoverflow.com/questions/56561444",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1257267/"
] | On Ubunutu, For Dbeaver 6, it is found in
```
$HOME/.local/share/DBeaverData/workspace6/General/.dbeaver
``` | I've just tried to move configuration for dbeaver 7.3.1 from one win machine to another, and if you copy&paste folder:
>
> C:\Users\your\_user\_name\AppData\Roaming\DBeaverData\
>
>
>
you will get everything works quite smoothly |
203,471 | I want to list all the current running services and output it to a .csv file. Does anyone know how to do this? | 2010/11/18 | [
"https://serverfault.com/questions/203471",
"https://serverfault.com",
"https://serverfault.com/users/60731/"
] | A bit of *good old* shell script:
`@echo off`
`setlocal`
`set SERVICES=`
`for /f "skip=1 tokens=*" %%S in ('%SystemRoot%\System32\net.exe start') do call :ADD_SERVICE %%S`
`echo Running services are : [%SERVICES%]`
`endlocal`
`goto END`
`:ADD_SERVICE`
`set SERVICE=%*`
`if "%SERVICE%" == "" go... | Might I be evil and suggest the Cygwin variant:
```
net start | sed -e '1,2d' -e ':a' -e N -e 's/\n /,/' -e ta > services.csv
``` |
644,523 | If $f(x)= x+b$ when $x≤1$ and $f(x)= ax^2$ when $x > 1$, what are all values of $a$ and $b$ where $f$ is differentiable at $x=1$?
Please explain. Thank you very much for your help. | 2014/01/20 | [
"https://math.stackexchange.com/questions/644523",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/122526/"
] | Hints:
1) The function **must** be continuous at $\;x=1$, so
$$1+b=\lim\_{x\to 1^-}f(x)=\lim\_{x\to 1^+}f(x)=a\implies a-b=1$$
2) Both one-sided differentials must be equal, so:
$$\lim\_{x\to 1^-}\frac{f(x)-f(1)}{x-1}=\lim\_{x\to 1^-}\frac{x+b-(1+b)}{x-1}=\ldots$$
$$\lim\_{x\to 1^+}\frac{f(x)-f(1)}{x-1}=\lim\_{x\t... | You need to find values of $a$ and $b$ so that:
1) $f$ is continuous. I.e., $1+b=a\cdot 1^2$.
and
2) $f'$ is continuous. I.e., $1=2\cdot a\cdot1$. |
30,840 | In Philip K. Dick's **Do Androids Dream of Electric Sheep?** why did Deckard get a citation at the end from his police department? Because he retired too many andys in a single day? I thought the police wants to retire as many as possible. Sounds to me like he should get a bonus. | 2013/01/22 | [
"https://scifi.stackexchange.com/questions/30840",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/11801/"
] | He *was* being rewarded.
[Merriam-Webster's definition](http://www.merriam-webster.com/dictionary/citation) of "Citation":
>
> 1 : an official summons to appear (as before a court)
>
>
> 2
>
>
> * a : an act of quoting; especially : the citing of a previously settled case at law
> * b : excerpt, quotation
>
>
... | Like user [John Rennie](https://scifi.stackexchange.com/users/4144/john-rennie) said in a comment, Deckard got a citation because he "retired" (i.e. executed) six androids, which was a remarkable feat. A citation is another word for commendation, so that's a good thing.
Excerpt from the book:
>
> A moment later the ... |
5,040,000 | is there any way to create events for NSDate ? here is my code
```
NSDate *date = [NSDate date];
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"MMMM d, yyyy"];
NSString *dateStr = [dateFormatter stringFromDate:date];
myDate.tex... | 2011/02/18 | [
"https://Stackoverflow.com/questions/5040000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/319097/"
] | This is a way to implement your scenario with extension methods. While, as others have noted, it would make sense to keep the logic to turn your strings to HTML within MyClass, in certain scenarios it might make sense to use this approach.
```
public class MyClass
{
public String varA{ get; set; }
public Stri... | If you changed `ToHtml` to except a value:
```
public static string ToHtml(string a)
{
// your code here - obviously not returning ""
return "";
}
```
then you can call it like so:
```
MyClass c = new MyClass();
c.varA = "some text";
c.varA = MyClass.ToHtml(c.varA);
```
But, I maybe WAY off what you requi... |
18,502 | As far as I'm aware, the two most common ways to choose a setting for your campaign are one of these:
* The GM makes it up pre-game, or
* the GM has some source book containing the desired setting.
Also, when the players make characters, one of these two ways are most often used:
* The players bring filled out char... | 2012/10/31 | [
"https://rpg.stackexchange.com/questions/18502",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/4555/"
] | It's a great idea to get your players involved in building the setting. Make sure that everyone wants to be involved in this stage of course. It can do more harm than good to force people to create something if they aren't feeling it.
The Dresden Files RPG lets players cooperate in building the city they will be playi... | You will likely run into problems when a players believe that you as the GM don't portrait aspects of the campaign settings the way they intended it.
>
> **GM:** You encounter a group of yellow Frogstar soldiers.
>
>
> **Player:** Yellow? But I wanted them to be green!
>
>
> **GM:** You never said they are suppo... |
33,326 | The Attorney-General is seventh in the line of succession to the Presidency of the United States.
Does an ***Acting*** Attorney-General replace the former Attorney-General in the line of succession? | 2018/11/09 | [
"https://law.stackexchange.com/questions/33326",
"https://law.stackexchange.com",
"https://law.stackexchange.com/users/534/"
] | The presidential line of succession is governed by the U.S. Constitution, specifically [Article II section 1](https://en.wikisource.org/wiki/Constitution_of_the_United_States_of_America#Section_1_2):
>
> In Case of the Removal of the President from Office, or of his Death, Resignation, or Inability to discharge the P... | **No**
A cabinet member is only a cabinet member when they are confirmed not just because they are temporarily doing a cabinet member’s job. |
5,920,352 | I'm trying to add a image to a togglebutton in WPF - C#. The thing is that the assignment I'm working on can't be made with the use of XAML at all. I've tried to set the Content property to an image, but all I get is a normal togglebutton, which isn't helping my cause at all.
```
myToggleButton = new ToggleButton(... | 2011/05/07 | [
"https://Stackoverflow.com/questions/5920352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/715752/"
] | As requested here is the code that works for me in its entirety:
```xml
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid Na... | Are you sure that the provided bitmap resource is able to be located. If not then the image will be empty and so occupy no space and hence the toggle button looks empty. |
42,039,069 | I created this package, I need it in a project but couldn't install it, this error appears:
>
> Could not install package 'Mshwf.NiceLinq 1.0.9'. You are trying to
> install this package into a project that targets
> '.NETFramework,Version=v4.5', but the package does not contain any
> assembly references or conten... | 2017/02/04 | [
"https://Stackoverflow.com/questions/42039069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6197785/"
] | Go to the folder:
```
C:\Users\[username]\.nuget\packages\[package name]\1.0.0.4\lib
```
Rename the folder with the .net version of your project.
Suppose I am using .net framework 4.6.1 my folder name should be `net461` | I had similar issue which i fixed by removing the packages.config(you can edit the file if you don't want to remove) file and then made sure both the package i was using was built using the same .net version as the Project i was using it in(for me the package was built using 4.6 while my console project was targeting e... |
49,653,410 | I am trying to achieve a filter with `mat-autocomplete` that is similar to the following example;
[trade input example](https://www.checkatrade.com/)
So I am trying to achieve the functionality so that when a user begins to type in the trade they are looking for filters based on a partial string match anywhere in the... | 2018/04/04 | [
"https://Stackoverflow.com/questions/49653410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3545438/"
] | You can use a custom pipe to highlight the partial match whenever the user types in something in the filter.
```
@Pipe({ name: 'highlight' })
export class HighlightPipe implements PipeTransform {
transform(text: string, search): string {
const pattern = search
.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g... | To solve the undefined, you should just check for the present of the search string, sometimes you have none on the control:
```
export class HighlightPipe implements PipeTransform {
transform(text: string, search): string {
if (search && text && typeof search === 'string' && typeof text === 'string') {
const... |
32,004,967 | I have two rows of checkboxes and labels.Although horizontal alignment is not an issue , however there is a problem of vertical alignment of second column.How can I achieve a symmetry in this case?
```
<div class="form-inline">
<div class="form-group">
<div class="col-md-4">
<label class="radio-inline">
... | 2015/08/14 | [
"https://Stackoverflow.com/questions/32004967",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1421910/"
] | [I've updated your fiddle](https://jsfiddle.net/vwkkf7ts/7/) with a fixed width on the wrapping div `.col-md-4` and positioned the labels using float with the width of each label set to take 1/3 of the parents width using the `calc` function:
```
label{
float: left;
width: calc(100%/3)
}
``` | What if you wrap each checkbox with a col-sm-3 box?
```
<div class="col-sm-3">
<label class="radio-inline">
<input type="checkbox" name="inlineRadioOptionsWeek" id="Checkbox3" value="3">Wednesday</label>
</div>
```
<https://jsfiddle.net/hobs766o/1/> |
93,712 | I'm building an application that caters to a specific set of people for example construction workers *[edit: removed "students, or coffee drinkers"]*. So for instance, an app for construction workers that can handle photo annotation for pipes, logging their working hours, viewing a blueprint, and contacting city offici... | 2016/05/04 | [
"https://ux.stackexchange.com/questions/93712",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/78630/"
] | I've actually been involved in something similar, and with more than six in one. In the end we went with the approach of having the main home screen of the app display an icon and label for each of the apps. This main screen also provided navigation to the *overall help* page and *overall settings* page. Below is a rou... | If done intuitively you might avoid "extra pain" for users by exploring the following approach:
For one app offering a group of users – let's say construction workers – multiple task-based features, only display relevant features based on the type of construction worker. The user could identify this via a first-time s... |
64,105,244 | I want the container direction as "row" above md size screen and "column" below md size screen?
How can I implement it?
```
<Grid container direction = "row"(in large screens)/direction = "column"(in small screens)>
```
I tried something this.
```
<Grid container classes={gridDirection}>
gridDirection: {
dire... | 2020/09/28 | [
"https://Stackoverflow.com/questions/64105244",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10429886/"
] | The easiest way and I believe the modern way is to use the sx attribute. Then let MUI handle the breakpoints for you.
These are the default MUI breakpoints as of writing.
```
xs = extra-small: 0px
sm = small: 600px
md = medium: 900px
lg = large: 1200px
xl = extra-large: 1536px
```
xs and sm are generally considered ... | At least as on date of answering here, Material UI supports `direction` or `flexDirection` attributes with component, with these attributes supporting responsive value based on breakpoints mapped object passed to it.
For example, in your case, if direction="row" is needed on large screens and direction="column" is ne... |
765,612 | Is it possible to have Ubuntu Desktop running in an LXC/LXD container on top of Ubuntu Server, displaying Ubuntu Desktop's graphical X session on the physical screen that Ubuntu Server outputs to?
Whether it makes sense or not, my idea is to separate the Server "PC" from the Desktop "PC". I intend to set up an Intel N... | 2016/04/30 | [
"https://askubuntu.com/questions/765612",
"https://askubuntu.com",
"https://askubuntu.com/users/301931/"
] | (Not definitely true:)That won't work!(/Not definitely true) What would work though, is doing it the other way round: install the Desktop on your machine and then use LXD to run the web server.
Also, if you have a current NUC box, you should have processor virtualization and could run KVM. I'm not familiar with that, ... | This might help
<https://github.com/ustuehler/lxc-desktop>
It seems you can run multiple desktop instances in lxc containers, however I'm not sure why you would want the server part to have a desktop interface |
28,633,390 | I'm trying to implement a custom error message for my bean validation.
I've annotated my field `firstName` with the validation rule `@Size( min = 2, max = 40, message = "errors.firstName.size" )`.
In my `message.properties` I added a message key `errors.firstName.size=First Name must be between {min} and {max} chars`.... | 2015/02/20 | [
"https://Stackoverflow.com/questions/28633390",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/685202/"
] | Try putting your message key in `ValidationMessages.properties` instead of `message.properties`.
>
> The ValidationMessages resource bundle and the locale variants of this
> resource bundle contain strings that override the default validation
> messages. The ValidationMessages resource bundle is typically a
> prop... | Try to add curly braces to your message key as below :
```
@Size(min = 2, max = 40, message = "{errors.firstName.size}")
``` |
31,251,910 | I'm getting the infamous Run-time error when I run this code, and I don't understand why:
`With ThisWorkbook.Sheets("Data")
.Range(Cells(row1, column1), Cells(row2, column1)).Copy
End With`
row1, column1 and row2 are all defined as Integers.
The error pops up for the second line of code.
Can I get some insight pl... | 2015/07/06 | [
"https://Stackoverflow.com/questions/31251910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5086294/"
] | You forgot the "." before `Cells` (as you are within the `With` scope of the Sheet Data)
```
With ThisWorkbook.Sheets("Sheet2")
.Range(.Cells(1, 1), .Cells(2, 2)).Copy
End With
```
Tested the above example and now it works for me. | Where are you coping the range to. The proper format is
source.copy destination
```
Sheets("Count").Range("C2:D3").Copy Sheets("Count").Range("E2:F3")
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.