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 |
|---|---|---|---|---|---|
19,711,349 | Welcome) have a little trouble, help solve them, please. Here's the code:
```
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import javax.swing.JComponent;
import javax.swing.JFrame;
class MyCanvas extends JComponent {
public void paint(Graphics g) {
Image img1 = Toolkit.getDefaultT... | 2013/10/31 | [
"https://Stackoverflow.com/questions/19711349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2839008/"
] | >
> And I would like more random
>
>
>
Use the `Random` class to generate an integer within your specified range. You would want to use `getWidth()` and `getHeight()` to get the bounds of your component so you can specify a realistic range. Then you can randomize the x, y values.
```
Random random = new Random();... | You are indeed correct that you can draw the same image multiple times by calling
```
g.drawImage(img1, x, y, (int) w, (int) h, this);
```
multiple times for different values of x and y. So, basically what you need to do is randomizing the coordinates. That can be done by using the handy `Random` class in Java:
```... |
10,843 | If I have road tires that have a recommended pressure of 110 PSI and maximum of 120 PSI can I safely pump my tires up to that level or does the inner tube effect the maximum?
I currently have the tires pumped up to 90 PSI however the question [What Pressure Should I Run My Road Bike Tyres At](https://bicycles.stackex... | 2012/08/16 | [
"https://bicycles.stackexchange.com/questions/10843",
"https://bicycles.stackexchange.com",
"https://bicycles.stackexchange.com/users/4731/"
] | The inner tube has no significant effect on max pressure. The valve stem area is the only area sensitive to pressure, and in general the valve can withstand 200 PSI or better. (And if you exceed whatever limit there is the result is "catastrophic" failure, not simply the inability to pump in more air.)
What it sounds ... | In addition to the tire limiting PSI, rim tape is also a factor. Cheap rim tape can prevent higher pressures since they, and the tube, will dimple into the spoke holes of the wheel. Over time, this can cause the tube to fail. |
1,484,739 | I'm new to C++, and I'm confused about arrays and pointers. Could someone tell me how I can properly delete a pointer. Like for example,
```
int *foo;
foo = new int[10];
delete foo;
```
or
```
delete [] foo;
```
Thanks. | 2009/09/27 | [
"https://Stackoverflow.com/questions/1484739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/130278/"
] | If you allocate an array of objects using the `new []` operator then you must use the `delete []` operator and therefore the non-array `new` can only be used with the non-array `delete`.
```
int *a = new int[10];
int *b = new int;
delete [] a;
delete b;
``` | You walked in the front door and left it open. Then you walked through to the back door and tried to close it but you smashed it because it was already closed.
```
foo = new int [10]; // so when you open the front door
delete [] foo; // please remember to close the front door.
foo = new int; // and when ... |
20,941,935 | I know my JSON is valid, I'm wanting to pull all the KEY's out of the array and put them in an object. However it seems I can either access ONE objects Key or Value, the entire array, or one key value pair. I have not figured out how to parse out all the keys, or all the values in the array.
Here is what I've tried:
... | 2014/01/06 | [
"https://Stackoverflow.com/questions/20941935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3161804/"
] | If your input is always in the same format, you can handle it like this
```
$tmp = json_decode($resultSet);
$json_obj = array();
foreach ($tmp as $values) {
array_push($json_obj, $values[0]);
}
```
This will give you `$json_obj` in the desired format with a hardcoded `$resultSet` like the one you provided. | maybe this is what you are looking for:
json encode server-side like:
```
echo json_encode($html);
```
json parse clientside like
```
var str = JSON.parse(data);
alert (JSON.stringify(str))
``` |
645,038 | No matter how many tabs I have, Firefox only shows one item on the taskbar. I'm **not** talking about the previews when you hover over the *item on the taskbar*, that works fine. It only displays 2 or more items on the taskbar if I have 2 or more windows open. Is there a way to do this for each tab? Or even **more pref... | 2013/09/13 | [
"https://superuser.com/questions/645038",
"https://superuser.com",
"https://superuser.com/users/127809/"
] | You can `echo` a bell - `\a` in the remote terminal:
`./long_process ; echo -e '\a'`
Some terminal emulators will play some sort of sound and might show a notifications.
iTerm2, in particular, will show a notification and play a sound, if process' tab is not focused.
Also, notice that I used `;` to separate commands... | There's a really easy way to cause iTerm2 to bounce in the dock until you switch over to it. It's great. To use it, you just need to use iTerm2 and be able to install software on the host you're ssh'd into. Here's how you do it,
1. SSH into the host.
2. Install Shell Integration for iTerm2. On the Mac version of iTerm... |
43,718 | Suppose I was hired as a Junior Manager from 2010 to 2012, then was promoted to Senior Manager from 2012 to 2014. On a resume/CV is it appropriate to list my title as Senior Manager (2010-2014)?
Often on resumes/CVs on LinkedIn I see people who list the highest position they were promoted to along with the entire dur... | 2015/04/06 | [
"https://workplace.stackexchange.com/questions/43718",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/33828/"
] | I do my CV like this as it shows to the recruiter / employer that i have worked at a company a preset period of time and during that period i was promoted several times. If you only list the final job title then it looks odd when there is a gap in your employment (Pre 2008 in below eg) period or if listed as 'Senior De... | >
> On a resume/CV is it appropriate to list my title as Senior Manager
> (2010-2014)?
>
>
>
**Yes,** But specify year as 2012-2014. Or
I would list as "Currently working as Senior Manager".
You can use your current profile as a Heading of Resume, LinkedIn profile and on your business cards (with or without du... |
39,695,293 | After upgrading to Mac OSX Sierra from El Capitan as soon as I run php it denies to run any php project which was previously installed on my system.
That after exploring this issues on internet I came with these options...
After running the below commands:
```
cd /etc/apache2/
sudo mv httpd.conf httpd.conf.sierra
sudo... | 2016/09/26 | [
"https://Stackoverflow.com/questions/39695293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1563528/"
] | I fixed my problem...
To make mcrypt extension work (if you get an error after upgrading)
Then follow [this guide](https://coolestguidesontheplanet.com/install-mcrypt-for-php-on-mac-osx-10-10-yosemite-for-a-development-server/) from scratch...
Please use the updated version of libmcrypt and php (php 5.6 - comes with O... | ```
brew install homebrew/php/php70-mcrypt
``` |
67,930,508 | I have two sorted lists and I need to find the odd ones out in each list.
Currently I am using two list comprehensions with `not in`:
```
> if foo != bar:
in_foo = [i for i in foo if i not in bar]
in_bar = [i for i in bar if i not in foo]
```
However, this method doesn't take advantage of the sorted str... | 2021/06/11 | [
"https://Stackoverflow.com/questions/67930508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14830842/"
] | Here is a comparison of three methods. The `with_intersection` method allows for repeated values within each list, the other two do not. The test considers two sorted lists, each with one million distinct integers.
The `using_sorted` method takes advantage of the fact that both lists are sorted and does not use sets. ... | By putting a None trailer at the end of each list, we can use iterators
and focus on recording the differences. This algorithm is O(n+m):
```
foo = [1, 3, 4, 5]
bar = [2, 4, 5, 6]
i_foo = iter(foo + [None])
i_bar = iter(bar + [None])
n_foo = next(i_foo)
n_bar = next(i_bar)
in_foo = []
in_bar = []
while True:
if ... |
39,661,184 | I am doing an exercise. This is my interface. Now I want a mouse effect for two banners on the left:
[](https://i.stack.imgur.com/vTHI9.png)
When we move mouse on **each banner**, **that banner** will be replaced by a text box with same size, green background (without af... | 2016/09/23 | [
"https://Stackoverflow.com/questions/39661184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4196709/"
] | The java bean and spring-managed beans are different things. Java bean is indeed some object with particular naming convention where spring bean is different.
What spring refers to as (spring managed) bean is simply instance of a class which lifecycle is managed by Spring framework. It doesn't have to follow the Java ... | To save time for those who would like to know the answer to this question, on the Spring official site there is a nice explanation of [Spring Beans](http://docs.spring.io/spring/docs/4.3.9.RELEASE/spring-framework-reference/html/beans.html#beans-introduction) and [high-level view of how Spring works](http://docs.spring... |
20,308,870 | I have a Login table in MySql database . . In table there is a column by cname and one of the value is 'Raghu'. My question is when i write the query as
```
Select *from Login where cname='raghu';
```
Then it is retrieving the record which contains 'Raghu' . I want it to retrieve according to case . How can I retri... | 2013/12/01 | [
"https://Stackoverflow.com/questions/20308870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1007137/"
] | Use: [10.1.7.7. The BINARY Operator](http://dev.mysql.com/doc/refman/5.0/en/charset-binary-op.html)
>
> The BINARY operator casts the string following it to a binary string. This is an easy way to force a comparison to be done byte by byte rather than character by character.
>
>
>
```
Select * from Login where b... | Can you try this, you can use `LOWER` FUNCTION in either column name `LOWER('cname')` or in value `LOWER('raghu')`;
```
Select *from Login where LOWER(`cname`) = 'raghu';
``` |
408,719 | I wonder "which quantity" is conserved in relation to a specific symmetry.
I guess it is in some meaning simply the generator (in the context of Lie theory) of the symmetry, as it is true for angular momentum (conserved) being generator of rotation (symmetry).
I want clear formulation of idea but I can't complete it:... | 2018/05/28 | [
"https://physics.stackexchange.com/questions/408719",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/118357/"
] | Forget that velocity is a vector $\vec{v}$ for the moment, and just let $v:=\vec{v}$ denote the speed (i.e. modulus of the velocity vector). This is just a non-negative real random variable, and you're asking why $\langle v^2\rangle\ne\langle v\rangle^2$. But famously, the difference between these two expressions is ju... | One is defined as
$$
\langle |v|\rangle=\frac{\int |v|f(v)\mathrm{d}v}{\int f(v)\mathrm{d}v}
$$
while the other
$$
\langle v^2\rangle=\frac{\int v^2f(v)\mathrm{d}v}{\int f(v)\mathrm{d}v}.
$$
It is clear that $\langle |v|\rangle^2\neq\langle v^2\rangle$. |
144,714 | I've been working on a fitness journal app and have been trying to come up with a design to show your sets in a summary view.
[](https://i.stack.imgur.com/gHKUG.jpg)
The sets are displayed in chronological order. A super set is when you alternate between 2 or ... | 2022/10/20 | [
"https://ux.stackexchange.com/questions/144714",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/162621/"
] | I'm wondering if you could try being specific.
Instead of 'superset' (or in addition to), you could trying saying what they actually do, which is alternate the exercise.
You also have a lot of repetitive elements overall. The mental model most of us have for weight training is:
**Weight** (times) **Reps**
Instead o... | Gym Dashboard
-------------
These types of designs are called **Dashboards**, specifically, the one referred to in the question, **Gym Dashboard**, **Fitness Dashboard** or **Training Dashboard**. If what you need are design alternatives, you can find several solutions in [Dribbble](https://dribbble.com/search/gym-das... |
66,093 | I did try using the plugin Front End Users but this clashes with something as it prevents access to some front end pages. So I need to manually just set it so that anyone who isn't one of two usernames (or roles) can't access wp-admin. | 2012/09/24 | [
"https://wordpress.stackexchange.com/questions/66093",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14739/"
] | Just revisited that answer as it wasn't updated in a long time. Year is 2021.
The accepted answer is checking whether the current page is a `wp-login.php` page **OR** an admin page **WHILE** using an `admin_init` hook, this is nonsense.
[`admin_init`](https://developer.wordpress.org/reference/hooks/admin_init/) fires... | Based on the answer provided by @kaiser (thank you btw), this is my working code, just in any case someone needs it. It is placed in `functions.php` file.
The condition used is, if the user **can't** `manage_options` or `edit_posts`.
```
function wpse66093_no_admin_access() {
$redirect = home_url( '/' );
if ... |
21,749,798 | I occasionally have react components that are conceptually stateful which I want to reset. The ideal behavior would be equivalent to removing the old component and readding a new, pristine component.
React provides a method `setState` which allows setting the components own explicit state, but that excludes implicit s... | 2014/02/13 | [
"https://Stackoverflow.com/questions/21749798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42921/"
] | You should actually avoid `replaceState` and use `setState` instead.
The docs say that `replaceState` "may be removed entirely in a future version of React." I think it will most definitely be removed because `replaceState` doesn't really jive with the philosophy of React. It facilitates making a React component begin... | Example code (reset the `MyFormComponent` and it's state after submitted successfully):
```
function render() {
const [formkey, setFormkey] = useState( Date.now() )
return <>
<MyFormComponent key={formkey} handleSubmitted={()=>{
setFormkey( Date.now() )
}}/>
</>
}
``` |
3,733,234 | I am interested to know the difference between `this` and `base` object in C#. What is the best practice when using them? | 2010/09/17 | [
"https://Stackoverflow.com/questions/3733234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/167689/"
] | Darin is right on. An example may also help. (There wasn't an example when I initially posted. Now there is.)
```
class Base {
protected virtual void SayHi() {
Console.WriteLine("Base says hi!");
}
}
class Derived : Base {
protected override void SayHi() {
Console.WriteLine("Derived say... | `this` refers to the current class instance.
`base` refers to the base class of the current instance, that is, the class from which it is derived. If the current class is not explicitly derived from anything `base` will refer to the `System.Object` class (I think). |
14,136,636 | I want to connect a `MySql` DB with my android application.
However, I **DON'T** want to/**CAN'T** use `PHP` for doing this.
Almost all solution for `MySql` connection with android on internet uses `PHP`.
I read somewhere that, If one don't want to use `PHP` then `web service` should be used.
But I'm not able t... | 2013/01/03 | [
"https://Stackoverflow.com/questions/14136636",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1061728/"
] | It seems you're mixing up some things.
A web service is simply some code on the internet (web) which allows you to receive and send information to a server, where it is saved per example in a database.
PHP is just a language, in which you can write a web service.
You can use a vast array of languages to create a w... | A webservice, is as it's called, a service, meaning that you have one side consuming it (the android client). if all you want is a persistent storage, you could use SQLite which is an SQL compliant solution which exists within android.
If it's possible to SSH to a server via Android, you could use that to connect to m... |
2,385,617 | I have numbers in javascript from 01(int) to 09(int) and I want add 1(int) to each one.
For example:
```
01 + 1 = 2
02 + 1 = 3
```
But
```
08 + 1 = 1
09 + 1 = 1
```
I know the solution. I've defined them as float type.
**But I want to learn, what is the reason for this result?**
Thank you. | 2010/03/05 | [
"https://Stackoverflow.com/questions/2385617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/286975/"
] | Javascript, like other languages, may treat numbers beginning with `0` as octal. That means only the digits 0 through 7 would be valid.
What seems to be happening is that `08` and `09` are being treated as octal but, because they have invalid characters, those characters are being silently ignored. So what you're actu... | Since you haven't specified the radix it is treated as octal numbers. `08` and `09` are not valid octal numbers.
```
parseInt(08,10) + 1;
```
will give you the correct result.
See **[parseInt](https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Global_Functions/ParseInt)** |
14,743,530 | I am looking at production code in hadoop framework which does not make sense. Why are we using transient and why can't I make the utility method a static method (was told by the lead not to make isThinger a static method)? I looked up the transient keyword and it is related to serialization. Is serialization really us... | 2013/02/07 | [
"https://Stackoverflow.com/questions/14743530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62539/"
] | The problem in your code is the difference between the local mode (dev&testcases using it usually) and the distributed mode.
In the local mode everything will be inside a single JVM, so you can safely assume that if you change a static variable (or a static method that shares some state, in your case `stringToSearchFo... | Unless there is something not shown here, then I suspect that the matter of making `Utility` a `static` method largely comes down to style. In particular, if you are not injecting the `Utility` instance rather than instantiating it on demand within, then it is rather pointless. As it is written, it cannot be overridden... |
2,147 | What are really helpful math resources out there on the web?
Please don't only post a link but a short description of what it does and why it is helpful.
Please only one resource per answer and let the votes decide which are the best! | 2009/10/23 | [
"https://mathoverflow.net/questions/2147",
"https://mathoverflow.net",
"https://mathoverflow.net/users/1047/"
] | For enumerative combinatorics, it's hard to beat Sloane's [Online Encyclopedia of Integer Sequences](https://oeis.org/).
It is what it says on the tin. A huge list of integer sequences, with references, links, formulas, and comments. | For knot theorists, there are two really cool databases:
* [knotinfo](http://www.indiana.edu/~knotinfo) and its cousin [linkinfo](http://www.indiana.edu/~linkinfo), both maintained by Cha and Livingston.
* [knotatlas](http://katlas.math.toronto.edu/wiki/Main_Page), maintained by Bar-Natan. |
798,359 | Can a 64bit Citrix server running a 32bit app through WoW64 handle just as many instances/users as the 32bit Citrix server equivalent?
And if so if I up the memory in the 64bit server will the number of instances/users scale too?
Or are there some strange memory considerations with a 64bit server running a 32bit app? | 2009/04/28 | [
"https://Stackoverflow.com/questions/798359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/97150/"
] | >
> I'm replacing a submit button with an
> anchor link. Since calling
> form.submit() does not activate
> onsubmit's, I'm finding it, and
> eval()ing it myself. But I'd like to
> check if the function exists before
> just eval()ing what's there. – gms8994
>
>
>
```
<script type="text/javascript">
function o... | using a string based variable as example and making use `instanceof Function`
You register the function..assign the variable...check the variable is the name of function...do pre-process... assign the function to new var...then call the function.
```
function callMe(){
alert('You rang?');
}
var value = 'callMe';... |
417,118 | Here we have a problem that seems very intuitive, but is hard to define mathematically.
In Tic Tac Toe, we can find an equivalent of the game in any number of dimensions, it seems.
The trick is to realize the the game is defined by *lines on which the characters can be placed* not how the board is drawn.
1D tic tac ... | 2013/06/11 | [
"https://math.stackexchange.com/questions/417118",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/64746/"
] | It sounds like you're asking about the different *types* of lines that have to be looked at, for instance all the possible lines through the center of the board. If this is so, then you left out two distinct classes in the 3d case. For convenience, I'm going to use coordinates that go from $0$ to $2$ in each direction,... | I play tic-tac-toe frequently. 4D is the most frequently played game for my group, but 6D's a close second.
Here is 2D:
```
_|_|_
_|_|_
| |
```
Here is 3D:
```
_|_|_|_
_|_|_|_
_|_|_|_
| | |
_|_|_|_
_|_|_|_
_|_|_|_
| | |
_|_|_|_
_|_|_|_
_|_|_|_
| | |
_|_|_|_
_|_|_|_
_|_|_|_
| | |
```
Here is 4D. Be... |
17,424,254 | I have ejabberd setup to be the xmpp server between mobile apps, ie. custom iPhone and Android app.
But I've seemingly run into a limitation of the way ejabberd handles online status's.
Scenario:
* User A is messaging User B via their mobiles.
* User B loses all connectivity, so client can't disconnect from server.
... | 2013/07/02 | [
"https://Stackoverflow.com/questions/17424254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1177855/"
] | ejabberd supports stream management as default in latest version. It is implemented in most mobile libraries like Smack for Android and XMPPFramework for iOS.
This is the state of the art in XMPP specification at the moment. | Implementing XEP-198 on ejabberd is quite involved.
Erlang Solutions (I work for them) has an XEP-184 module for ejabberd, with enhanced functionality, that solves this problem. It does the buffering and validation on the server side. As long as client sends messages carrying receipt request and when it is delivered t... |
178,338 | I know these pads are at least 4 summers old, but not sure how old exactly. As I was shutting the swamp cooler down for the winter, I saw that they seemed really dirty. The white material flakes of really easy.
I don't know if I need to clean them or actually replace them?
[ buttons are readily accessible and changeable right now, but will reset at the next program time.... | I've seen something like you're asking used in hotels before. They would have a regular thermostat that allowed the guest to adjust the temperature to their liking, but there was also a keycard reader tied in. In order for the A/C to operate, the guest would have to insert their room key into this device and leave it i... |
3,536,604 | sleep() is a static method of class Thread. How does it work when called from multiple threads. and how does it figure out the current thread of execution. ?
or may be a more generic Question would be How are static methods called from different threads ? Won't there be any concurrency problems ? | 2010/08/21 | [
"https://Stackoverflow.com/questions/3536604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/408215/"
] | >
> how does it figure out the current
> thread of execution?
>
>
>
It doesn't have to. It just calls the operating system, which always sleeps the thread that called it. | `Thread.sleep(long)` is implemented natively in the `java.lang.Thread` class. Here's a part of its API doc:
```
Causes the currently executing thread to sleep (temporarily cease
execution) for the specified number of milliseconds, subject to
the precision and accuracy of system timers and schedulers. The thread
... |
10,294,122 | Can somebody explain how works MySQL function LAST\_INSERT\_ID(). I'm trying to get id of last inserted row in database, but every time get 1.
I use mybatis.
Example query is :
```
<insert id="insertInto" parameterType="Something" timeout="0">
INSERT INTO something (something) VALUES (#{something})
<selectKey re... | 2012/04/24 | [
"https://Stackoverflow.com/questions/10294122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1345122/"
] | `LAST_INSERT_ID` returns the last value **implicitly** inserted into an `AUTO_INCREMENT` column in the current session.
```
CREATE TABLE mytable (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, value INT NOT NULL);
```
To make the column autoincrement, you should omit it from the `INSERT` list:
```
INSERT
INTO mytab... | I have two solutions, after implements much complicated i find out about second one...
I will tell you second which is better one ...
It's pretty simple... just in query insert this `keyProperty="id"`
Like this :
`<insert id="insertInto" parameterType="Something" keyProperty="id" timeout="0">
INSERT INTO something (s... |
26,071,627 | Im trying to do a java script that can convert hex to binary.
What the script does, is that it prompts the user for a hex input and comes up with the binary equivalent output.
Im having issues as i dont know how to set the parameters for the scanner input, as a hex can both be an Int and Char.
I know what i've don... | 2014/09/27 | [
"https://Stackoverflow.com/questions/26071627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3582547/"
] | ```
char hex;
Scanner in = new Scanner(System.in);
System.out.print("Enter a hex digit: ");
hex = in.next().charAt(0);
System.out.println("binary is "+new BigInteger(hex+"", 16).toString(2));
``` | what you need. Use string then convert it.
```
BigInteger.toString(radix)
static String hexToBin(String s) {
return new BigInteger(s, 16).toString(2);
}
``` |
10,978 | I'm wondering if there is any benefit behind double-clicking when using a mechanical torque wrench. Could it be that some folks do it to compensate for slack in the ratcheting mechanism?
In other words, would I lose anything if I torqued down with just a single click?
This [YouTube video](http://youtu.be/9UXftuZcEO4?... | 2014/06/09 | [
"https://mechanics.stackexchange.com/questions/10978",
"https://mechanics.stackexchange.com",
"https://mechanics.stackexchange.com/users/675/"
] | I spent 25 years as a Helicopter technician, and from year one i was Ordered NEVER EVER to double click a torque wrench. This double clicking that i see mechanics do drives me nuts. You are "overtorquing" if you do it twice. | It depends on what you're torquing and the requirements that need to be met for the item your are torquing. In the aviation industry everything is very fine tolerances and small torque ranges. A double click is over-torquing. In the general automotive industry where things are not as precise as aviation a double click ... |
57,458,998 | I want to hide a certain paragraph from the SINGLE POST in WordPress via PHP content filter.
I developed this filtering script, which works like a sunshine:
```
function hideDaStuff( $content ) {
$paragraphs = explode( '</p>', $content );
foreach ($paragraphs as $index => $paragraph) {
if(6 == $index){
... | 2019/08/12 | [
"https://Stackoverflow.com/questions/57458998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11751224/"
] | This theory is untested but I suspect you could throw a [`.select_for_update()`](https://docs.djangoproject.com/en/dev/ref/models/querysets/#select-for-update) on your view's queryset attribute.
`.get_object()` calls `.get_queryset()` and since your code executes in an atomic block the row should be locked until the ... | As your connection is slow and you are updating data via `REST API` being consumed by the client(ex. Android or IOS App maybe), there is no solution to carry out such thing. What you can do is, store the data in the client's local storage and `sync` it with your API once the connection speed is fast enough. You can che... |
31,215,768 | To test if my code is throwing expected exception I use the following syntax:
```
an [IllegalArgumentException] should be thrownBy(Algorithms.create(degree))
```
is there any way to test if thrown exception contains expected message like:
```
an [IllegalArgumentException(expectedMessage)] should be thrownBy(Alg... | 2015/07/04 | [
"https://Stackoverflow.com/questions/31215768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1298028/"
] | [Documentation](http://www.scalatest.org/user_guide/using_matchers):
```
the [ArithmeticException] thrownBy 1 / 0 should have message "/ by zero"
```
and using that example:
```
the [IllegalArgumentException] thrownBy(Algorithms.create(degree)) should have message expectedMessage
``` | Your syntax for checking the message is wrong. As an alternative to what bjfletcher suggested, you can also use the following, as per the documentation:
1. Capture the exception and assign it to a val
`val thrown = the [IllegalArgumentException] thrownBy Algorithms.create(degree)`
2. Use the val to inspect its cont... |
24,534,226 | Although I am a beginner in java, I am trying to plot some data I have using JMathPlot.
Every thing went well, but the script didn't terminate after I closed the window of the plot.
Could any body tells me how to force the script to terminate when I close the window of the plot.
I use a debian machine(32-bit), IDE = ... | 2014/07/02 | [
"https://Stackoverflow.com/questions/24534226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2804070/"
] | You termainate the process when closing the frame, not the panel.
This this:
`frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);`
Also see [JFrame Exit on close Java](https://stackoverflow.com/questions/7799940/jframe-exit-on-close-java) | Sure!
```
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0)
}
});
```
What that does is, waits until the close button is pressed, then runs System.exit(0) which simply terminates your program.
Note: I wrote this on i... |
69,981 | The Harmonium hails from Germany and it is not an Indian instrument. Also, it is an equal tempered instrument. But the harmonium is a very common accompanying instrument in Hindustani Classical (North-Indian tradition) and Bhajan.
Whilst the harmonium is not used for South Indian Carnatic Music, violin is commonly use... | 2018/04/16 | [
"https://music.stackexchange.com/questions/69981",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/49365/"
] | I had always assumed that the harmonium entered Indian culture via Western missionaries. But, according to this source:
[Harmonium Indian Culture](https://indianculture.gov.in/musical-instruments/sushir-vadya/harmonium#:%7E:text=Harmonium%20is%20a%20stringed%20instrument,for%20both%20music%20and%20dance.)
the table-t... | The harmonium is not specifically a German instrument. As "pump organ" you can also find it in England and the US. It was popular has a home replacement of a church organ, which is why you would often find it in religious households for singing hymns. Thus it is not unlikely that missionaries took it with them, includi... |
43,066,350 | I've come up with some code that prints the address and postalcode of my location. This is done in the didupdatelocation function.
The only problem that I occur, is that every second this address get's updated by the "didupdatelocation" function.
Because this is very battery ineffecient, I was looking for ways to use... | 2017/03/28 | [
"https://Stackoverflow.com/questions/43066350",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4671017/"
] | The answers of Rajeshkumar and Basir doesn't change much for the battery power, their delegate method is still called the same number of times per minute.
If you want to have a more efficient behavior, try to change the values of distanceFilter, desiredAccuracy, and activityType (You can find all you need [here](https... | Swift 3 version of this [answer](https://stackoverflow.com/a/22292872/7250862)
```
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
var newLocation = locations.last!
var locationAge = -newLocation.timestamp.timeIntervalSinceNow
if locationAge > 5.0 {
... |
272,635 | I'm doing some shennanigans with jQuery to put little plus/minus icons next to my expanders. Its similar to the windows file trees, or firebugs code expanders.
It works, but its not specific enough.
Hopefully this makes sense...
```
$('div.toggle').hide();//hide all divs that are part of the expand/collapse
$('ul.p... | 2008/11/07 | [
"https://Stackoverflow.com/questions/272635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26107/"
] | ```
$(this).contents('img.expander')
```
This is what you want. It will select all of the nodes that are children of your list. In your case, all of your images are nested inside of the list element, so this will filter out only what you want. | How about making your click event toggle a CSS class on a parent item (in your case, perhaps the ul.product-info). Then you can use CSS background properties to change the background image for a <span> instead of using a literal <img> and trying to fiddle with the src. You would also be able to accomplish a showing and... |
3,259,530 | I'm trying to prove that two definitions of the ordinal sum are equivalent.
In the present question I want to prove that given
$$\tag{1}
\alpha+\beta:=\operatorname{ord}(\{0\}\times \alpha\cup \{1\}\times \beta)
$$
it follows that
$$
\alpha+ \operatorname{S}(\beta)=\operatorname{S}(\alpha+\beta)
\text{, where }\operat... | 2019/06/12 | [
"https://math.stackexchange.com/questions/3259530",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/680792/"
] | We want to prove the following
>
> **Theorem**: For each ordinal $\alpha$, the following equalities characterize the operation $\xi\longmapsto\alpha+\xi$:
>
>
> $$\begin{cases}
> \alpha+0=\alpha\\
> \alpha+S(\beta)=S(\alpha+\beta)\\
> \alpha+\gamma=\text{sup}\{\alpha+\delta\;|\;\delta<\gamma\}\quad\text{if }\gam... | For short let $X=(\{0\}\times \alpha)\cup (\{1\}\times \beta).$
From the 3rd line of your "start" we have $$\alpha + S(\beta)=$$ $$=ord \,(X\cup (\{1\}\times \{\beta\})\,)$$ $$==ord \,(\, (\{0\}\times X)\cup (\{1\}\times \{\beta\})\,)=$$ $$=ord\,(\,(\{0\}\times X)\cup (\{1\}\times \{\alpha+\beta\})\,)=$$ $$=ord\,(\,(\... |
61,897,076 | I've encountered strange behavior when trying to construct a tuple of references from a mix of tuples and integral values.
Given the following:
```
struct A { int v = 1; };
struct B { int v = 2; };
struct C { int v = 3; };
A a;
std::tuple<B,C> tpl;
```
I'm trying to create a third tuple which holds references to al... | 2020/05/19 | [
"https://Stackoverflow.com/questions/61897076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2065991/"
] | You can try this:
```
df['rate_number'] = df['rate_number'].replace('\(|[a-zA-Z]+', '', regex=True)
```
Better answer:
```
df['rate_number_2'] = df['rate_number'].str.extract('([0-9][,.]*[0-9]*)')
```
**Output:**
```
rate_number rate_number_2
0 92 92
1 33 33
2 9.25... | There is a small error with the asterisk's position:
```
df['rate_number_2'] = df['rate_number'].str.extract('([0-9]*[,.][0-9]*)')
``` |
55,073 | I recently updated my server's database system from MySQL to MariaDB.
After update, everything works well.
But, when I went to phpMyAdmin, the default charset and types are changed:

At the end of this image, the default type was set to 'InnoDB' and... | 2013/12/16 | [
"https://dba.stackexchange.com/questions/55073",
"https://dba.stackexchange.com",
"https://dba.stackexchange.com/users/31738/"
] | *"How can I revert my character set" :*
```
ALTER TABLE myTable CONVERT TO CHARACTER SET "utf8";
```
*"How can I revert my type": (MySQL Engine):*
```
ALTER TABLE myTbale ENGINE=MyISAM;
```
*"how can I customize settings when I make new database?"*
**In your my.cnf**
```
default-storage-engine=MyISAM
```
Be... | * You can change server's **charset** and **collation** by editing `my.cnf` file and restart MySQL server to have effect
<http://dev.mysql.com/doc/refman/5.6/en/charset-server.html>
* Now all your tables are of Engine type as **InnoDB**, if you are using MariaDB 5.6+ then it can support Fulltext search with InnoDB wh... |
1,352,522 | I need to write a DLL (using Delphi) which is dynamically loaded into delphi applications and makes RTTI queries (typical operation is to obtain string values for control properties).
The classic problem is that passing strings (and objects) between application and DLL is problematic due to different memory managers us... | 2009/08/29 | [
"https://Stackoverflow.com/questions/1352522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/106688/"
] | Use the same memory manager for your application and your DLLs.
For recent version of Delphi that includes the new FastMM memory manager, use SimpleShareMem as the 1st unit in both your application and the DLL projects.
Or download the [full FastMM4 from SourceForge](http://sourceforge.net/projects/fastmm/), set th... | Here's a nice article that has some recommendations:
<http://www.codexterity.com/memmgr.htm>
I also found this:
<http://sourceforge.net/projects/fastmm/>
I haven't tried either of the libraries they recommend. It might get you version independence, it might not. If you're wanting to distribute the DLL and support d... |
1,002,327 | Are there any site that show good examples of web application styles? Form designs and layout styles? | 2009/06/16 | [
"https://Stackoverflow.com/questions/1002327",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/104849/"
] | Besides the many tutorials and examples on <http://www.w3schools.com/> ?
There is always <http://www.csszengarden.com/> that shows how you can manipulate the content of your web page just by altering the style sheet.
You can find a large list of examples of form designs at:
<http://www.smashingmagazine.com/2008/04/1... | Smashing Magazine has some useful links ... a few have been mentioned in previous responses, so I will add the one that I have found useful ...
[40 Helpful Resources On User Interface Design Patterns](http://www.smashingmagazine.com/2009/06/15/40-helpful-resources-on-user-interface-design-patterns/) |
6,203,090 | I have been using `TForm`'s `OnActivate` event to give me the opportunity to show a dialog box as soon as my app has started. I want the main form to already be loaded & visible. What's a good way to do this?
I have found that `OnActivate` works fine unless the forms `WindowState` is `wsMaximized`.
in the past I've a... | 2011/06/01 | [
"https://Stackoverflow.com/questions/6203090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14031/"
] | In the form's OnCreate event handler post a user message and show the dialog in the handler of the message:
```
unit Unit1;
interface
const
UM_DLG = WM_USER + $100;
type
TForm1 = class(TForm)
...
procedure UMDlg(var Msg: TMessage); message UM_DLG;
...
implementation
procedure TForm1.FormCreate(Sender: TOb... | Well, I do not know if it is the best pratice, but I do like this:
In the PROGRAM file (.dpr - I use Delphi 7) I add this lines:
```
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Form1.Show; // Show Main Form
Form1.Button1.Click; // C... |
3,984 | I am running a logistic model. The actual model dataset has more than 100 variables but I am choosing a test data set in which there are around 25 variables. Before that I also made a dataset which had 8-9 variables. I am being told that AIC and SC values can be used to compare the model. I observed that the model had ... | 2010/10/26 | [
"https://stats.stackexchange.com/questions/3984",
"https://stats.stackexchange.com",
"https://stats.stackexchange.com/users/1763/"
] | It is quite difficult to answer your question in a precise manner, but it seems to me you are comparing two criteria (information criteria and p-value) that don't give the same information. For all information criteria (AIC, or Schwarz criterion), the smaller they are the better the fit of your model is (from a statist... | Grouping SC and AIC together **IS WRONG**. They are very different things, even though people heavily misuse them. AIC is meaningful when you are predicting things, using SC in this scenario can lead (not all the times) to wrong results. Similarly, if you are interested in doing model selection with the principle of pa... |
9,330,882 | I'm working on a java android project. this project requires to use specific commands.
these commands are all developed in c++/c but I've been given two files (.jar and .so) that are supposed to "turn them into" java, so I can use them in my java android project.
The thing is, what am I supposed to do with these 2 fil... | 2012/02/17 | [
"https://Stackoverflow.com/questions/9330882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1216018/"
] | Take a look at [this answer](https://stackoverflow.com/questions/9283040/eclipse-android-project-how-to-reference-library-within-workspace/9283084#9283084) about adding `jar` files. '.so' files can usually just be drag and dropped to the project. | All you need to do is make sure the jar is in your classpath and you can then access the classes within this jar. A jar is just an archive of classes, you don't need to load the library into memory or something similar.
You may want to read the answer to the question here [How to use classes from .jar files?](https://... |
5,103,884 | Hi
I have a jsp page in which following lines
```
if(Exception err) {
out.println (err.getMessage() + "<br/><br/>");
}
```
may get XSS attacks i want to it just display the above things without any XSS attacks
Any thought ? | 2011/02/24 | [
"https://Stackoverflow.com/questions/5103884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/632197/"
] | use [`c:out`](http://download.oracle.com/javaee/5/jstl/1.1/docs/tlddocs/c/out.html) tag.
**Also See**
* [java-best-practices-to-prevent-cross-site-scripting](https://stackoverflow.com/questions/1159729/java-best-practices-to-prevent-cross-site-scripting) | Apache Commons provides StringEscapeUtils, see the [escapeHtml()](http://commons.apache.org/lang/api-2.4/org/apache/commons/lang/StringEscapeUtils.html#escapeHtml%28java.io.Writer,%20java.lang.String%29) method |
2,058,339 | I have a text file with lots of lines and with this structure:
```
[('name_1a',
'name_1b',
value_1),
('name_2a',
'name_2b',
value_2),
.....
.....
('name_XXXa',
'name_XXXb',
value_XXX)]
```
I would like to convert it to:
```
name_1a, name_1b, value_1
name_2a, name_2b, value_2
......
name_XXXa, name_XXXb, value_XXX
... | 2010/01/13 | [
"https://Stackoverflow.com/questions/2058339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/209514/"
] | Oh boy, here is a job for `ast.literal_eval`:
(`literal_eval` is safer than `eval`, since it restricts the input string to literals such as strings, numbers, tuples, lists, dicts, booleans and None:
```
import ast
filename='in'
with open(filename,'r') as f:
contents=f.read()
data=ast.literal_eval(contents)
fo... | Asking what's the best language for doing a given task is a very different question to say, asking: 'what's the best way of doing a given task in a particular language'. The first, what you're asking, is in most cases entirely subjective.
Since this is a fairly simple task, I would suggest going with what you know (un... |
6,036,127 | I just started with Zend Framework 2.0 and wanted to load my own resources.
My own library PWS resides in the library folder.
To override the FrontController resource I have the following file
PWS/Application/Resource/FrontController.php
```
<?php
namespace PWS\Application\Resource;
class FrontController extends ... | 2011/05/17 | [
"https://Stackoverflow.com/questions/6036127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/730277/"
] | Suppose you have a task to perform. Let's say you're a math teacher and you have twenty papers to grade. It takes you two minutes to grade a paper, so it's going to take you about forty minutes.
Now let's suppose that you decide to hire some assistants to help you grade papers. It takes you an hour to locate four assi... | As previous writer has said there are some overhead associated with `Parallel.ForEach`, but that is not why you can't see your performance improvement. `Console.WriteLine` is a synchronous operation, so only one thread is working at a time. Try changing the body to something non-blocking and you will see the performanc... |
13,269,183 | Hi can you guys help me with this, I have try several things.
I need to search between two IEnumerables, here is the code.
```
IEnumerable<Project> Projects = new[] { new Project {id = "1", lan = "test1"}, new Project {id = "2", lan = "test1"}}
IEnumerable<string> lan = new [] { "test1", "test2"};
IEnumerable<string... | 2012/11/07 | [
"https://Stackoverflow.com/questions/13269183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1083647/"
] | I'd use a `HashSet` rather than an array, as it allows check-if-contains as an O(1), rather than O(n), operation:
```
HashSet<string> lan = new HashSet<string> { "test1", "test2" };
IEnumerable<string> indexFiltered = projects
.Where(p => lan.Contains(p.lan))
.Select(p => p.id);
``` | Another efficient approach is using [`Enumerable.Join`](http://msdn.microsoft.com/en-us/library/bb344797.aspx) since it's implemented as a hash table:
```
IEnumerable<string> indexFiltered = from p in Projects
join l in lan on p.lan equals l
selec... |
54,750,231 | I have the below code. I wish to place a table in the body of an HTML email where I want negative values to be color-coded in red, positive values in green and unchanged values to display a dash. I can make it work for a single cell reference, however I can't figure out how to incorporate a For Each...Next command so t... | 2019/02/18 | [
"https://Stackoverflow.com/questions/54750231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4299209/"
] | You were pretty correct till *public static ExpectedCondition visibilityOf(WebElement element): An expectation for checking that an element, known to be present on the DOM of a page, is visible. Visibility means that the element is not only displayed but also has a height and width that is greater than 0. This existing... | How to check presence with `WebElement` as a parameter.
```
public boolean isElementPresent(WebElement element) {
if (element != null) {
try {
//this line checks the visibility but it's not returned.
//It's to perform any operation on the WebElement
element.isDisplayed();
... |
116,322 | I got this on an interview question and I still don't know the answer.
>
> What output will have a nonlinear device if we will give two random frequencies \$f\_1\$ and \$f\_2\$?
>
>
>
I answered that it will have two carriers but I really unsure about my answer. | 2014/06/23 | [
"https://electronics.stackexchange.com/questions/116322",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/46115/"
] | The correct answer is that you don't know without more information about this non-linear device. Non-linear only rules out linear, but can otherwise mean anything else, including putting out a fixed signal regardless of the inputs.
To show that you understand the concept, you should explain that a linear device can pr... | In general, you will get:
* the two original frequencies f1,f2
* The sum and difference of the two frequencies f1 + f2, f1 - f2 (aka intermodulation products)
* The harmonics of each of the two frequencies (f1\*2, f1\*3, f1\*n, f2\*2, f2\*3, f2\*n, ...)
* Harmonics of the intermodulation products
* Intermodulation pro... |
476,165 | I have this function $f(\mathrm{X})$ where $\mathrm{X=A+B+C}$ where $\mathrm{A}$ is a diagonal element with variable $a$ on its diagonal. $\mathrm{B}$ is another diagonal matrix with variable $b$ on its diagonal. $\mathrm{C}$ is a positive definite matrix with variable $c\_{ij}$. Now I want to optimize this function ov... | 2013/08/26 | [
"https://math.stackexchange.com/questions/476165",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/34790/"
] | I'm dropping that $\tfrac{1}{2}$ for simplicity; it can be buried in the $y$ vector. Assuming the function is
$$\begin{aligned}
f(X) &= y^T X y + z^T X^{-1} z - \log\det(X) \\
&= \langle yy^T, X \rangle + \langle zz^T, X^{-1} \rangle - \log\det(X)
\end{aligned}$$
then the gradient is
$$\nabla f(X) = yy^T - X^{-1} zz^T... | Here's some sample Matlab code that uses CVX to solve a problem similar to yours. However, I don't yet know how to handle the $r^T X^{-1} r$ term.
```
N = 30;
y = randn(N,1);
cvx_begin sdp
variable X hermitian
minimize(.5*y'*X*y - log_det(X))
subject to
X >= 0
cvx_end
``` |
12,851,791 | How can I remove digits from a string? | 2012/10/12 | [
"https://Stackoverflow.com/questions/12851791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1739954/"
] | And, just to throw it in the mix, is the oft-forgotten `str.translate` which will work a lot faster than looping/regular expressions:
For Python 2:
```
from string import digits
s = 'abc123def456ghi789zero0'
res = s.translate(None, digits)
# 'abcdefghizero'
```
For Python 3:
```
from string import digits
s = 'ab... | I'd love to use regex to accomplish this, but since you can only use lists, loops, functions, etc..
here's what I came up with:
```
stringWithNumbers="I have 10 bananas for my 5 monkeys!"
stringWithoutNumbers=''.join(c if c not in map(str,range(0,10)) else "" for c in stringWithNumbers)
print(stringWithoutNumbers) #I... |
171,311 | I try to understand using of 'to' at the end of this sentence. I understand the meaning but grammar is confusing me. Can someone explain it to me please? I hope I could express myself. I googled but couldn't find anyting. 'songs to dance ***to***', 'songs to make up ***to***' etc, have same construction. Is it about th... | 2018/06/28 | [
"https://ell.stackexchange.com/questions/171311",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/-1/"
] | To "to" at the end of this sentence is a dangling preposition. If you were pedantic, the sentence would be rewritten as:
>
> Movies **to** which one (can) have a good cry
>
>
>
The "to" functions as a preposition indicating what you are crying for (or, in this case, to). In the second example you provided, it wou... | >
> *movies [(for you) to have a good cry to \_\_ ]*
>
>
>
The bracketed "to have a good cry to" is an infinitival relative clause modifying "movies", in which the relativised element is complement of the preposition "to" (represented by the gap notation '\_\_'). It has a modal meaning similar to that expressed in... |
19,784,025 | I keep getting the following error while trying to install phonegap 3.0 using cli
Can you please help me figure out where I am going wrong?
I am using a Macbook Pro
```
~ developer$ sudo npm install g- phonegap
npm http GET https: //registry.npmjs.org/g-
npm http GET https: //registry.npmjs.org/phonegap
npm http GET h... | 2013/11/05 | [
"https://Stackoverflow.com/questions/19784025",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2955365/"
] | *edit* - Updated Fiddle
I had a similar problem. I got my solution by setting a scroll attribute for background. Also be sure to set the parent container to 100% height and width. AdrianS has the right point for aiming at html to set 100% height and 100% width.
In the following code, I have a `header` class for the b... | The solution I will provide can be seen [here](http://css-tricks.com/perfect-full-page-background-image/). But with a minor change. This method is tested many times and for IE it has IE8+ support. You can see the full browser support in the link that I provided.
```
html {
width: 100%;
height: 100%;
}
body {
bac... |
18,565,313 | I have the Text box .That text Box ID is **text\_1\_\_val**.
I need **1** from that Id.How to Get the Particular part of the textbox ID in jquery which means i need the between \_ and \_\_ from that textbox ID? | 2013/09/02 | [
"https://Stackoverflow.com/questions/18565313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1103259/"
] | If the only requirement is that the character / characters appear between a single and double underscore, try this regular expression match
```
var rx = /_(.+?)__/;
var part = rx.test(idValue) && rx.exec(idValue)[1];
```
This assumes that you're only after the first of any occurrences in your ID value string. If the... | The `split()` method is used to split a string into an array of substrings, and returns the new array.
```
$(your_textbox).attr("id").split("_")[1]
//Syntax
string.split(separator,limit)
```
Function Reference: <http://www.w3schools.com/jsref/jsref_split.asp> |
9,115,273 | I want 'This Is A 101 Test' to be 'This Is A Test', but I can't get the syntax right.
```ruby
src = 'This Is A 101 Test'
puts "A) " + src # base => "This Is A 101 Test"
puts "B) " + src[/([a-z]+)/] # only does first word => "his"
puts "C) " + src.gsub!(/\D/, "") # Does digits, I w... | 2012/02/02 | [
"https://Stackoverflow.com/questions/9115273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/631619/"
] | No regexp:
```
src = 'This Is A 101 Test'
src.delete('^a-zA-Z ') #the ^ negates everything
``` | Do you want to cut ' 101' from the string? Here's your regex
```
src = 'This Is A 101 Test'
puts src.gsub /\ \d+/, ''
# => This Is A Test
```
Also I don't understand why you are using bang version of `gsub`. `gsub!` modifies the original string, `gsub` copies it and modifies the copy. |
50,001,851 | Will appreciate if someone can please guide or provide me pointers to debug the backup issues with Artifactory. Whenever backups are performed - there is always an error message of 401 on /api/v1/system/backup/export in the artifactory.log
The backups exist on backup location but with an error message in the log. Not s... | 2018/04/24 | [
"https://Stackoverflow.com/questions/50001851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9523860/"
] | Since Artifactory version 5.4 there is a separate service in Artifactory named "Access", which manages permissions and security related configurations.
Artifactory authenticates with Access using an access token that is configured in the "[Config Descriptor](https://www.jfrog.com/confluence/display/RTF/Configuration+F... | Added `bootstrap.creds`
```
tomcat@XXXXXXXX:/home/bitnami/apps/artifactory/artifactory_home/etc$ ls -ltrh
total 136K
-rw-r--r-- 1 tomcat tomcat 5.5K Mar 20 16:41 mimetypes.xml
-rw-r--r-- 1 tomcat tomcat 12K Mar 20 16:41 logback.xml
-rw-r--r-- 1 tomcat tomcat 13K Mar 20 16:41 artifactory.system.properties
... |
55,445 | I'm currently watching a cooking series (The Everyday Gourmet) and in one of the lessons the chef talks about what to look for in a wine. For red wine he mentions to look for a wine with a deep red colour as well as a good tannin content, mentioning that subtleties of flavour will likely be lost during cooking.
As he ... | 2015/03/06 | [
"https://cooking.stackexchange.com/questions/55445",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/26666/"
] | One cause of gumminess in 100% rye breads is excessive starch degradation related to amylase enzyme actions. Amylase action is slowed down by increasing acidity. You can increase the acidity by adding a small amount of lemon juice or cream of tartar to your dough as described [here](http://www.veganbaking.net/recipes/b... | Try steaming it instead of baking. |
184,737 | Do the changes in the following sentences change the meaning at all?
>
> He's my friend
>
>
> I'm his friend
>
>
>
Or
>
> He's my co-worker
>
>
> I'm his co-worker
>
>
>
Or
>
> he's my brother
>
>
> I'm his brother
>
>
>
Besides emphasis - is there any change in meaning in these sentences?
Can ... | 2014/07/12 | [
"https://english.stackexchange.com/questions/184737",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/68094/"
] | Yes, it depends on whether the relationships are symmetric. Brotherhood is not symmetric, because if you're a girl and he's your brother, then you could say
>
> he's my brother
>
>
>
but switching it and saying
>
> I'm his brother
>
>
>
is clearly wrong, you'd say
>
> I'm his sister.
>
>
>
In other w... | I agree with what Amit wrote, but would add besides, that in each case the two pairs are not interchangeable because of the point of view of each sentence of each of the pairs. In one case, it's from your point of view (first person singular) in one of the sentences, and from the other person's point of view (third per... |
8,797,568 | I have a `HTML` webform (**NOT** asp.net webform) that submits its form to an `aspx` script.
On the `aspx` script, I'd like to simply forward the form submission to a different form processing script. (after checking just one or two things using `Request.Form["variable"]`)
What is the simplest way to forward the orig... | 2012/01/10 | [
"https://Stackoverflow.com/questions/8797568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/691887/"
] | **I would attempt to solve this problem in the following fashion**
1. Create a Repeater
2. Set the Request.Form as the datasource of the repeater. If this does not work, i would convert Request.Form into a suitable datastructure, such as a Dictionary or Datatable for binding to the Repeater
3. Each repeater item would... | If it is only about simplest way then it is using session variable.
Just save your form values to the session and then you can access it anywhere in your application during the particular session.
So I would have my aspx1 page something like this
```
// ASPX1 page's Page_Load
protected void Page_Load(object sender, ... |
27,453,118 | C++ compiler not letting me use an array as parameter to function call in a userdefined function. Can some one explain this to me and help me with a solution?
```
#include <iostream>
using namespace std;
double GetAverage(int[], int = 10);
int GetAboveAverage(int[], int = 10);
const int ARRAYSIZE = 10;
void main()
{
... | 2014/12/12 | [
"https://Stackoverflow.com/questions/27453118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4355721/"
] | If you want to call method BEFORE constructor you can use initializer block. <https://www.geeksforgeeks.org/g-fact-26-the-initializer-block-in-java/>
```
class A {
{
init()
}
public A() {
//todo
}
private final void init() {
//todo
}
}
``` | Why not this :
```
Class A {
public A() {
//... Do you thing
this.init();
}
public void init() {
//Call after the constructor
}
}
``` |
30,482,083 | I am trying to learn how to utilize Java 8 features(such as lambdas and streams) in my daily programming, since it makes for much cleaner code.
Here's what I am currently working on:
I get a string stream from a local file with some data which I turn into objects later. The input file structure looks something like th... | 2015/05/27 | [
"https://Stackoverflow.com/questions/30482083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4140728/"
] | You need to use [`map()`](https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html#map-java.util.function.Function-) to transform the data as it comes past.
```
Files.lines(Paths.get("resources/planes.txt"))
.map(line -> createAirport(line));
```
This will return a `Stream<Airport>` - if you want ... | The code posted by Steve looks great. But there are still two places can be improved:
1, How to split a string.
2, It may cause issue if the people forget or don't know to close the stream created by calling getAirports() method. So it's better to finish the task(toList() or whatever) in place.
Here is code by [AbacusU... |
5,603,052 | How does HTTPS work with respect to accepting a certificate? | 2011/04/09 | [
"https://Stackoverflow.com/questions/5603052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/686257/"
] | Very sipmly put with a **little story**:
>
> **Client** : *(Connects to the server and, sticks out it's hand)* "Hello! Here are my encryption details."
>
>
> **Server** : (Takes hand of the client) "Hello. Here are my encryption details. Here is my certificate." (Handshake negotiation complete. Client check the c... | First of all we need to distinguish server-side and client-side certificates.
In most cases only the server-side certificate is used. It is used to let the client verify the authenticity of the server that the client has connected to by validating the server's certificate (validation procedure will be described below... |
35,498,389 | When I search Google, I got SBShortcutMenuSimulator, it's can simulator Quick Action operate in iOS simulator. But, how test peek and pop operate? | 2016/02/19 | [
"https://Stackoverflow.com/questions/35498389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4361355/"
] | I find way! If your have MacBook Pro with ForceTouch Trackpad, you can do it.
Follow:
Choose iOS 9.3 with iPhone 6S Simulator, Find Hardware option on menu bar, check "Use Trackpad force for 3D Touch", then use your force touch Trackpad simulate 3D Touch. | You can use FLEX to check it on the simulator. Using a combination of the command, control, and shift keys, you can simulate different levels of 3D touch pressure in the simulator. Each key contributes 1/3 of maximum possible force. Note that you need to move the touch slightly to get pressure updates.
<https://github... |
18,473 | I've been googling around for a cheap CDN service and came across: <http://code.google.com/speed/pss/index.html>
This seems to be a competitor to other CDN services, is this the case?
Thanks | 2011/08/19 | [
"https://webmasters.stackexchange.com/questions/18473",
"https://webmasters.stackexchange.com",
"https://webmasters.stackexchange.com/users/3512/"
] | Anything that helps a search engine better understand the content and makeup of a web page is ostensibly better for SEO. The information a spider is able to discern about the structure of your page directly increases the accuracy of the spider's effective grading of your page. This is not to say that it will necessaril... | The direct answer is: No. You could use HTML4 designing the document with block elements (`<div>`) instead of using semantic elements (`<main>`, `<article>`, `<aside>`, `<nav>`, etc), and the result in the SERPs would be exactly the same. It would affect if you had a really bad design, for example using HTML frames: th... |
35,363,443 | I have an input type number element with a min and max values. Preventing the default function I have customized it to use the with separate inputs.
I don't know how can we trigger the max value from the input element which contains min and max attributes. Though i give max range the plus crosses the value.
```js
$(... | 2016/02/12 | [
"https://Stackoverflow.com/questions/35363443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5257219/"
] | You can read the `max` attribute and then use it in a condition.:
```js
$('.plus').on('click', function(e) {
var val = parseInt($(this).prev('input').val());
var max = parseInt($(this).prev('input').attr('max'));
if(val < max) {
$(this).prev('input').attr('value', val + 1);
}
});
$('.minu... | You just had to put an if condition,
```js
$('.plus').on('click', function(e) {
var val = parseInt($(this).prev('input').val());
if (val < $(this).prev('input').attr('max'))
{
$(this).prev('input').attr('value', val + 1);
}
});
$('.minus').on('click', function(e) {
var val = ... |
916,987 | We know the common result : - If every vertex of a graph **G** has degree at least2, then **G** contains a cycle. Can I conclude that 2-regular graphs are cycles where degree is exactly two of every vertex? I am not getting any contradictory example. Please help me if am wrong. Need some help.
I worked like this: If t... | 2014/09/02 | [
"https://math.stackexchange.com/questions/916987",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/42830/"
] | Suppose $G$ isn't cyclic. We know that $G$ contains at least one cycle $C$ (because every graph with $\delta (G)>1$ contains a cycle). $G$ is connected and that means that there exists vertices, for example $v$, that are not in $C$ but are neigbors to some vertices in $C$, for example $w \in C$. But since $w$ is in cyc... | Note that if $G$ is connected then in the case that every vertex has a degree of exactly 2, not only that there exists a cycle, there exists an Eulerian cycle (in which you use every edge exactly once). |
37,987,563 | I'm new to Jade and i got the assignment to create a select option in a webpage. Everything seems good until i get an empty option element which is created when the drop-down list is empty and the Page is refreshed. I want to somehow remove this empty option element. I went through most posts here but didn't seem to ge... | 2016/06/23 | [
"https://Stackoverflow.com/questions/37987563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5277469/"
] | The extra indentation after the first `option` tag causes all of the following options to be inside the first tag. Remove that extra indentation and it should all work:
```
#remarksField
h1#remarksHeader Remarks
select#shortDesc
option(value= "")= "---"
each index in data
if (index)
option(value= index.id)... | Add placeholder
```
option(value="1" placeholder="Select")
```
It would avoid it from getting blank on refresh. |
309,101 | How do I get the `GridView` control to render the `<thead>` `<tbody>` tags? I know `.UseAccessibleHeaders` makes it put `<th>` instead of `<td>`, but I cant get the `<thead>` to appear. | 2008/11/21 | [
"https://Stackoverflow.com/questions/309101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28543/"
] | This should do it:
```
gv.HeaderRow.TableSection = TableRowSection.TableHeader;
``` | I know this is old, but, here's an interpretation of MikeTeeVee's answer, for a standard gridview:
aspx page:
```
<asp:GridView ID="GridView1" runat="server"
OnPreRender="GridView_PreRender">
```
aspx.cs:
```
protected void GridView_PreRender(object sender, EventArgs e)
{
GridView gv = (GridVi... |
2,688,002 | So far, I've been merely using YARV (ruby 1.9) as merely a faster implementation of ruby than ruby 1.8, and ensured that all of my code is backwards-compatible with ruby 1.8.6. What circumstances, if any, are stopping you from writing 1.9-specific code?
One reason per answer. | 2010/04/22 | [
"https://Stackoverflow.com/questions/2688002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38765/"
] | I wish I could [forget about Iconv](https://stackoverflow.com/questions/2445175/tab-lf-cr-unicode-character) when handling unicode data, like this:
```
Iconv.conv("utf-8", "utf-16le", blob).split("\n")
```
but so far I **could not find good examples**/tutorial of 1.9 unicode handling yet. | Nothing is discouraging me. I've been using Ruby 1.9.1 for everything I do for close to a year now and had few problems. My [major](http://github.com/SFEley/candy) [gems](http://github.com/SFEley/acts_as_icontact) *require* 1.9 for various reasons (easy UTF-8, fibers, etc.) and I've felt no qualms about it. For some ot... |
3,723,044 | If I input `5 5` at the terminal, press enter, and press enter again, I want to exit out of the loop.
```
int readCoefficents(double complex *c){
int i = 0;
double real;
double img;
while(scanf("%f %f", &real, &img) == 2)
c[i++] = real + img * I;
c[i++] = 1 + 0*I; // most significant coeff... | 2010/09/16 | [
"https://Stackoverflow.com/questions/3723044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/449021/"
] | There's a way to do what you want using just scanf:
```
int readCoefficents(double complex *c) {
int i = 0;
double real;
double img;
char buf[2];
while (scanf("%1[\n]", buf) == 0) { // loop until a blank line or EOF
if (scanf("%lf %lf", &real, &img) == 2) // read two floats
... | re PAXDIABLO solution: it does not work properly with EMPTY line entered by user, so this line shall be added in your getLine() function
```
if (strlen(buff) <= 1) return NO_INPUT;
```
after the line:
```
if (fgets (buff, sz, stdin) == NULL)
return NO_INPUT;
```
So it will become :
```
...
if (strlen(bu... |
30,840,961 | I'd like to run a function that is identified by a string.
```
toRun = 'testFunction'
def testFunction():
log.info('In the function');
run(toRun)
```
Where `run` would be whatever command I need to use. I've tried with `exec`/`eval` without much luck. | 2015/06/15 | [
"https://Stackoverflow.com/questions/30840961",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1079477/"
] | The build in function [`getattr()`](https://docs.python.org/2/library/functions.html#getattr) can be used to return an named attribute of the object passed as argument.
**Example**
```
>>> import sys
>>> def function():
... print 'hello'
...
>>> fun_object = getattr( sys.modules[ __name__ ], 'function')
>>> fun_... | You can use `eval`
```
eval("testFunction()") # must have brackets in order to call the function
```
Or you could
```
toRun += "()"
eval("eval(toRun)")
``` |
41,833,798 | I have a dropdown menu and I wanna use angular2 directive to handling open/close of this dropdown.
How can I add `open` class to the `latest-notification` div . by knowing that my directive applied to the `button` tag!
Here is my html code:
```
<div class="header-notification" (clickOutside)="showPopupNotification = ... | 2017/01/24 | [
"https://Stackoverflow.com/questions/41833798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4184592/"
] | Sorry for late respond.
You could use `exportAs` meta property in directive to achieve what you want.
***(I'll show you relevant lines only where you need to make changes)***
---
```
/* #temp is a local template variable */
/* mydir is defined in dropdowndirective as exportAs meta property */
<button #temp=mydir a... | Hello i made an improved update to @Sajad answer regarding:
* angular11
* bootstrap 4
* Renderer2
* addClass(), removeClass()
HTML
```
<div class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle"
appDropdown
>
Manage Recipe
</button>
<div class="dropdown-menu">
... |
71,668,268 | In a jupyter notebook, I can fairly easily check with python code if some libraries are installed on the current kernel of the python notebook.
However there is also the "host" kernel which has its own python env (ie the python process that was launched when `jupyter notebook` was called). Depending on what libraries/... | 2022/03/29 | [
"https://Stackoverflow.com/questions/71668268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/875295/"
] | I guess you can use `!pip list` to show the modules/libraries installed on the current env. But I don't think you can view extensions. | I believe !pip list should work- if not, then pydoc most likely would, see above. |
7,579,385 | I have a java web application that use spring security for log in users, restriction access etc. , and it is working without problems on Glassfish 2.1, Tomcat, jetty, but on glassfish v3 doesn't work, when I try to login, and press button login, I'm getting login box from glassfish server(the box "The server xxxx requi... | 2011/09/28 | [
"https://Stackoverflow.com/questions/7579385",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/627346/"
] | I don't know what is causing this (and potentially it could be one of a number of things), but I suggest that you turn the logging level up to the max and see if that gives you some clues as to what is going on. (When the logging level is DEBUG or higher, SpringSecurity generates lots of logging.)
---
>
> ... the re... | Did you create a JDBC Connection pool and Resource in Glassfish server?
For ex:
```
User: root
Password: java
databaseName: theDatabase
serverName: localhost
portNumber: 3306
driverClass: com.mysql.jdbc.Driver
URL: jdbc:mysql://localhost:3306/dbname
``` |
25,816,333 | Recently I got a interview programming question about how to find maximum number M less than N, and some specific digit is not allowed to exist in M.
For example, N = 123, digit = 2,then it will output: 119
My ideas is to convert N to string first, and then find the first position of digit from left to right to make... | 2014/09/12 | [
"https://Stackoverflow.com/questions/25816333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2052141/"
] | Attempt 3. Still O(n) but due to the special 0 case needing to cascade back up:
```
static int banDigit(int number, int digit) {
int length = (Integer.toString(number)).length();
int result = 0;
boolean foundDigit = false;
for (int i = length - 1; i >= 0; i--) {
if (!foundDigit) {
... | I think it works, please tell me if you see any case not well handled.
```
public static void main(String[] args) {
int N = 100211020;
int digit = 0;
int m;
for (m = 9 ; m > 0 && m == digit; m--);
String sres;
String s = N + "";
int length = s.length();
int i = s.indexOf(di... |
65,772 | I'm new to magento so please remember when responding. What I want to do is change the text on the magento check option. I had the ability to change the title to "wire transfer" but would like to change the text that says "make check payable to" and "send check to".
Please let me know if this is possible and where I w... | 2015/05/05 | [
"https://magento.stackexchange.com/questions/65772",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/24930/"
] | You can do that by enabling the translation mode in magento.
Connect to the admin
Go in `System-> Configuration ->Advanced -> developper -> Translated Inline -> Front End switch` to `yes`
You should see on the front end some red box around every texts, click on the one you need to translate, change it and then re-st... | You can change the text for those by going to `your_web_root/app/design/frontend/base/default/template/payment/form/checkmo.phtml`
The text that gets displayed on the frontend can be found here.
I would copy this file to your theme and then make the necessary text changes.
After you make the change clear your cache i... |
10,189,331 | I have a very simple Child-Parent relationship, where OlderSon inherits from Parent and a Parent has a pointer to his OlderSon, such as:
```cpp
#ifndef PARENT_HXX
#define PARENT_HXX
#include <iostream>
#include <string>
//#include "OlderSon.hxx"
class OlderSon;
class Parent
{
private :
OlderSon* _os;
public... | 2012/04/17 | [
"https://Stackoverflow.com/questions/10189331",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1338339/"
] | You are attempting the impossible. You can fix the bug by moving the implementation of `Parent:Parent` to the implementation file, but your code would still be disastrous.
Constructing a Parent would require constructing an OlderSon and constructing an OlderSon would require constructing a Parent too (since an OlderSo... | why not you define child pointer to as Parent \* like;
```
class Parent
{
private :
Parent* _os;
.
.
.
}
```
Since base class of child is parent. |
1,430,726 | I find it hard to answer the question below. I just don't know how to use the fact that $$\lim\_{n\to\infty} \frac{a\_n}{n}=2.$$ Maybe with limit arithmetic?
>
> Let $(a\_n)$ be a sequence, where $$\lim\_{n\to\infty} \frac{a\_n}{n}=2$$
>
>
> Is it correct that $$\lim\_{n\to\infty}(a\_n-n)=\infty$$
>
>
>
I think... | 2015/09/11 | [
"https://math.stackexchange.com/questions/1430726",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/88027/"
] | for $\forall n>N\_{\epsilon}: \mid(\frac{a\_n}{n}-2)\mid<\epsilon$ which equals to
$\mid\frac{a\_n-n}{n}-1\mid<\epsilon$, hence $1-\epsilon\leq\frac{a\_n-n}{n}\leq1+\epsilon$. As $n>0$ we find $n-n\times\epsilon\leq{a\_n-n}\leq n+n\times\epsilon$. A posteriori, choose now $\epsilon<\frac{1}{n^3}$ you will have the desi... | $$\because \lim\_{n\to\infty}\frac{a\_n}{n}-1=\lim\_{n\to\infty}\frac{a\_n-n}{n}=1$$
$$\therefore a\_n-n=O(n) \rightarrow \infty (n\to\infty)$$ |
32,260,538 | So i have this script in python.
It uses models from django to get some (to be precise: a lot of) data from database.
A quick 'summary' of what i want to achieve (it might be not so important, so you can as well get it just by looking at the code):
There are objects of A type.
For each A object there are related... | 2015/08/27 | [
"https://Stackoverflow.com/questions/32260538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3915216/"
] | As of 8 August 2019 (Mongoose Version 5.6.9), the property to set is "rawResult" and not "passRawResult":
```
M.findOneAndUpdate({}, obj, {new: true, upsert: true, rawResult:true}, function(err, d) {
if(err) console.log(err);
console.log(d);
});
```
Output:
```
{ lastErrorObject:
{ n: 1,
updatedExis... | I'm afraid Using **FindOneAndUpdate** can't do what you whant because it doesn't has middleware and setter and it mention it the docs:
Although values are cast to their appropriate types when using the findAndModify helpers, the following are not applied:
* defaults
* Setters
* validators
* middleware
<http://mongoo... |
3,051,775 | This is a follow-up to my question [here](https://math.stackexchange.com/q/3049863/71829). A subset $A$ of a uniform space is said to be bounded if for each entourage $V$, $A$ is a subset of $V^n[F]$ for some natural number $n$ and some finite set $F$. A subset of a metric space is said to be bounded if it is contained... | 2018/12/25 | [
"https://math.stackexchange.com/questions/3051775",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/71829/"
] | In the context of real functions
$$f(x) = \sqrt x + \sqrt{-x}$$
has a graph consisting of only the point $(0,0)$ | The graph of the function f = {(x,y)} is a single point.
The constant function f:{0} -> {1}, x -> 1, for example.
You could conjure up a meaningless monster like
f(x) = x/0 if x /= 0; f(0) = 0/0 = 1 or whatever.
I don't see any slick answer for a dubious problem.
Use the set theory definition of function ... |
62,991,420 | I'm having a module-structure in python3.8 like this:
```
module
|- __init__.py
|- foo.py
|- bar.py
```
with
```py
# init.py
from .foo import Foo
from .bar import Bar
__all__ = ['Foo', 'Bar', ]
```
I now want to implement a multiplication `foo * bar`. So I'm writing:
```py
# foo.py
from .bar import Bar
class Fo... | 2020/07/20 | [
"https://Stackoverflow.com/questions/62991420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6160723/"
] | Try the `execute()` function. It executes the code directly in the `JavaScript` Console.
```
driver.execute("document.getElementsByClassName(' lazy-load-image-background opacity lazy-load-image-loaded')[0].click()")
```
IF that did not work out, There is a second method using the `WebdriverWait()`.
```
from seleniu... | Please use following xpath "**//img[@src='xxx.jpg']**
Before to click you should wait for that element |
17,318,914 | I have two string arrays in `ar1` and `ar2`, and I am reading the input from file and storing in arrays , `ar1` contains
```
Cat
Lam
Orange
Kam
Ramveer
None
Tue
Apple
```
ar2 contains
```
Dog
elephant
Kam
Monday
Parrot
Queen
Ramveer
Tuesday
Xmas
```
I am trying to sort the arrays in alphabetical order, and i am... | 2013/06/26 | [
"https://Stackoverflow.com/questions/17318914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2424821/"
] | Use an Arraylist as then you dont have to estimate the size of your array as the ArrayList grows dynamically as you add more strings, your code would go something like this
```
File file1= new File("C:\\Users\\Ramveer\\Desktop\\updates\\f1.txt");
File file2=new File("C:\\Users\\Ramveer\\Desktop\\updates\\f2.txt");
Sca... | If your Array don't have null values `Arrays.sort()`works properly.
So it is better to use `List` to avoid that kind of a scenario.
Then you can convert your arrays to `ArrayList` and use `Collections.sort()` to sort them.
```
String[] str1 = {"Cat","Lam","Orange","Kam","Ramveer","None","Tue","Apple"};
Str... |
3,337,787 | Question: Suppose $\left( L, \prec \right)$ is a linear ordering such that for every $X \subseteq L, \left( X, \prec \right)$ is isomorphic to an initial segment of $\left( L, \prec \right)$. Show that $\left( L, \prec \right)$ is a well ordering.
This is what i have gotten so far.
In order to show that $\left( L, \... | 2019/08/29 | [
"https://math.stackexchange.com/questions/3337787",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/546922/"
] | We don't have an isomorphism $f:(X,\prec) \, \to\, (L,\prec)$, only an order-preserving embedding such that the range of $f$ is an *initial segment* of $L$.
Now it's very easy: if we show that $L$ has a smallest element, then every initial segment of $L$ will have a smallest element, thus by the embedding being order-... | First suppose (L, ≺) is a well-ordering. Fix A ⊆ L. We’ll construct an isomorphism from (A, ≺) to an initial segment of (L, ≺).
Define
f ={ (x,a) ∈ L×A: (pred(L,≺,x),≺) ∼= (pred(A,≺,a),≺)}
(i) f is a function: Clearly, f is a relation. To see that it is a function, fix (x, a), (x, b) ∈ f and we’ll show that a = b. Tow... |
868,006 | I'm looking for a lightweight text editor for web.config files which has colour syntax highlighting (like in visual studio).
Any suggestions? | 2009/05/15 | [
"https://Stackoverflow.com/questions/868006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15613/"
] | You can use [Notepad++](http://notepad-plus.sourceforge.net/uk/site.htm). When you work with web.config select XML language to get color syntax highlighting. It looks like [this](http://notepad-plus.sourceforge.net/commun/screenshots/scrsh_lexerXML.gif). | Well obviously you can use any editor (e.g. EditPlus or Notepad++) but if you're looking for a light weight editor client that "knows" what a web.config is have a look at ASPhere
<http://blogs.msdn.com/publicsector/archive/2007/12/07/free-utility-web-config-editor-with-a-great-ui.aspx> |
37,414,513 | I looked on here but I have not been able to find what I want to do.
I simply have a onclick event for a button, and I want to increase the date value of a label by any number of days each time I click the button.
So lets say that number would be 2 days. If the current value of the label is 5/1/2016 when I click the ... | 2016/05/24 | [
"https://Stackoverflow.com/questions/37414513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4596738/"
] | The problem is that you are adding 2 days to TODAY's date every time. What you want to do is add 2 to the date already stored there. You would want to do something like this (warning: have not tried compiling this).
```
lblCurrentDate.Text = DateTime.Parse(lblCurrentDate.Text).AddDays(2).ToString("MM/DD/YYYY");
```
... | You need maintain the data in viewstate, each button click increment by 2
```
protected void Button1_Click(object sender, EventArgs e)
{
if (ViewState["datacount"] == null)
{
ViewState["datacount"] = 0;
}
ViewState["datacount"] = ((i... |
8,265,699 | I'm having trouble bringing back data from my PHP file. I guess I don't really understand the data parameter of this jquery function so I just went off some tutorials.
Jquery
```
$.ajax(
{
url: 'test.php',
dataType: 'text',
data: {test: '1'},
success: function(data)
{
... | 2011/11/25 | [
"https://Stackoverflow.com/questions/8265699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/800452/"
] | **This is work for me**
ajax code
```
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
<title>Test Page</title>
<script>
... | ```
just add "type" POST or GET
//example
$.ajax(
{
url: 'test.php',
type: 'POST',
data: {test: '1'},
success: function(data)
{
window.alert(data);
}
})
``` |
52,555 | We all know those breathtaking tales of dragonslayers soloing a winged lizard. We all love them, and we all think they're badass. But today one thought began to bug me - how in the hell adventurers manage to do that?
I mean, in games, for example, you just have to club it to death while drinking healing potions. But ... | 2016/08/23 | [
"https://worldbuilding.stackexchange.com/questions/52555",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/16753/"
] | There's actually a surprisingly simple solution here, even if it's without any hint of glory, honour, etc. It wouldn't make for a very good story for the local townspeople, hardly the stuff of legends, but it would be effective and the individual attempting it would have good odds of surviving even a failure.
Poison t... | Overwhelming military might, you take each of the dragon's strengths and turn them against him.
Flight
------
This is easy to overcome, you get your dragon in a cave! somewhere low so he can't take out
Strength
--------
The dragon is stronger than you, that means you need to either stay out of reach or get within i... |
2,244,084 | >
> Let $ABC$ be a triangle with $AB=AC$ and $\angle BAC=90^{\circ}$. Let $P,Q$ be points on $AB, AC$ respectively such that $PQ=AB$, and let $O$ be the center of the circle passing through $P,Q$ and tangent to $BC$. Show that $OA\parallel BC$.
>
>
>
It would be enough to show that $A,O,P,Q$ are concyclic. It see... | 2017/04/20 | [
"https://math.stackexchange.com/questions/2244084",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/304635/"
] | Let the circle through points $P, \,Q$ and tangent to the segment $BC$ be denoted by $k$ and let the point of tangency of $k$ and $BC$ be denoted by $T$. Let line $PQ$ intersect line $BC$ at point $E$ and let us assume, without loss of generality, that point $E$ is located so that $B$ is between $E$ and $C$, while $P$ ... | This isn't a proof, because I'm starting with the assumption $OA \parallel BC$. Per questioner's request, writing this up as an answer.
Note that $O$ can't be equal to $A$ because $OA$ wouldn't be a line segment.
Let $D$ be the midpoint of $BC$. The circle won't be tangent to $BC$ at $D$. Let's say it is tangent at... |
4,203,211 | Is there a replacement technology for TAPI that supports third-party call control (3pcc)?
I want to provide the following 3pcc functionalities in an application:
1. Outgoing call:
* User clicks at a button in the application.
* The user's phone goes off hook, and the callee's phone rings.
* The callee's phone sh... | 2010/11/17 | [
"https://Stackoverflow.com/questions/4203211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'd suggest you consider CSTA3.
ECMA CSTA3 is a comprehensive standard for 3rd party telephony call control far superior to TAPI in detail and implemented by several vendors. A web service definition exists for CSTA.
See [ECMA CSTA 3](http://www.ecma-international.org/activities/Communications/TG11/cstaIII.htm)
I c... | The answer to the OP is yes. A couple years ago I was trying to do TAPI work and had all of the same issues as everyone else. Rather than using local hardware and drivers, I found cloud services which do everything requested in the OP. I won't mention a specific service unless someone PM's me. But my recommendation is ... |
7,180,185 | I am new to Linq-to-SQL.
I want to retrieve the identity value from Linq-to-SQL while using `DBContext.SubmitChanges()`. | 2011/08/24 | [
"https://Stackoverflow.com/questions/7180185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/674652/"
] | It should automatically update your record. Something like this:
```
Customer cust = new Customer();
cust.Company = "blah";
context.Customers.Add( cust );
context.SubmitChanges();
int NewPk = cust.Pk;
``` | After you have called `SubmitChanges()` you can access the id field of your object to retrieve the ID. |
19,401,966 | I have a problem with parsing results of google images search. I've tried to do it with `selenium webdriver`. It returned me 100 results, but it was rather slow. I decided to request a page with `requests` module and it returned me only 20 results. How can I get the same 100 results? Is there any way to paginate or som... | 2013/10/16 | [
"https://Stackoverflow.com/questions/19401966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1776946/"
] | I've never tried doing that with selenium, but have you tried using Google's search engine API? It might be useful for you: <https://developers.google.com/products/#google-search>
Also, their restriction for the API is 100 requests per day, so I don't think you'll get more than 100 | You can scrape Google images by using the `beautifulsoup` and `requests` libraries, `selenium` is not required.
To get a batch of 100 images you can use in query param. `"ijn=0"` -> 100 images, `"ijn=1"` -> 200 images.
In order to scrape the full-res image URL with `requests` and `beautifulsoup` you need to scrape da... |
1,221 | Today and since I have joined islam.se, I have seen that almost all of the decisions made by the moderators against other member and me, are too much strict.
Today, during a chat thread, I was blocked for multiple times for just sharing my opinion about the Shias, "which is even accepted by the Shias themselves" there ... | 2014/07/05 | [
"https://islam.meta.stackexchange.com/questions/1221",
"https://islam.meta.stackexchange.com",
"https://islam.meta.stackexchange.com/users/58/"
] | There's nothing wrong with discussing the views of any sect so long as you don't pass negative *immature* judgements on them.
Keep in mind, any fair critique of any particular sect (or any group of people) is better to take place in presence of their representatives so that they have the opportunity to present their ... | I had the experience of goldpseudo deleting an answer in which I presented some relevant scholarly references which (I assume) he considered irrelevant or did not like - perhaps because they were more modernist and liberal in tone.
So I posted another answer challenging his deletion - which has not been deleted yet!
P... |
15,020,622 | I know that
```
Application.ExecutablePath
```
can get the installation folder.
But how can I get the location of publishing folder that I put in "PUBLISH" tab of my project? say.. (of course this will not work)
```
Application.PublishingPath
```
I am just trying to get the manifest file there so that I could kn... | 2013/02/22 | [
"https://Stackoverflow.com/questions/15020622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1862513/"
] | you should just manually store the publishing path to a variable.. | Simply:
```
ApplicationDeployment.CurrentDeployment.ActivationUri
``` |
18,226 | I understand that the public key does not expose the private key. That is not the question.
The question is: Given a EC public key, can a different, but *plausible* and *functional* private key be derived to match the public key?
In other words:
In basic arithmetic, if you know `a x b = c`, and you know any two vari... | 2014/07/19 | [
"https://crypto.stackexchange.com/questions/18226",
"https://crypto.stackexchange.com",
"https://crypto.stackexchange.com/users/12656/"
] | >
> Given a EC public key, can a different, but plausible and functional private key be derived to match the public key?
>
>
>
No, a public key will correspond to only one private key (with one minor exception, which I will explain below). With Elliptic Curve systems, the private key is an integer $d$ between 1 an... | I obviously don't understand the mathematics behind ECC, but I am quite certain that the mentioned `Multiply` is not as simple as regular multiplication, nor as simple as wrapping around a finite field many times over. Because:
When Alice and Bob exchange ECDH public keys, and then they each do `DeriveKeyMaterial()` o... |
47,334,139 | I'm currently trying to make Controlling an RGB LED With an Android Smartphone Using Arduino and Bluetooth Module. As in below link tutorial.
>
> <http://www.instructables.com/id/Controlling-an-RGB-LED-With-an-Android-Smartphone-/>
>
>
>
I'm using Arduino Uno.
I made as in tutorial and code and upload to Arduino ... | 2017/11/16 | [
"https://Stackoverflow.com/questions/47334139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7130882/"
] | I found the "programmer is not responding" error when I tried to flash my attiny85. I got rid of the annoying error when I switched to Arduino IDE 1.6.4 and chose the Arduino Genuino/ Uno as board. That's the important part and a common error: don't switch to "Arduino as ISP" mode when you upload the example sketch nam... | Make sure RESET and GND pins of Arduino are not |
14,621,953 | I have a composite (X) like this:
```
<composite:interface>
<composite:attribute name="textValue" />
<composite:attribute name="textValueChangeListner"
method-signature="void valueChanged(javax.faces.event.ValueChangeEvent)" />
```
```
<composite:implementation>
<ice:inputT... | 2013/01/31 | [
"https://Stackoverflow.com/questions/14621953",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2028132/"
] | Use `whereHas` to filter by any relationship. It won't join the relation but it will filter the current model by a related property. Also look into local scopes to help with situations like this <https://laravel.com/docs/5.3/eloquent#local-scopes>
Your example would be:
```
Restaurant::whereHas('facilities', function... | Do you absolutely have to load it from the Restaurant model? In order to solve the problem, I usually approach it inversely.
```
Facilities::with('restaurant')->where('wifi' ,'=', 0)->get();
```
This will get all the restaurant facilities that match your conditions, and eager load the restaurant.
You can chain mor... |
1,667,420 | I assumed joinable would indicate this, however, it does not seem to be the case.
In a worker class, I was trying to indicate that it was still processing through a predicate:
```
bool isRunning(){return thread_->joinable();}
```
Wouldn't a thread that has exited not be joinable? What am I missing... what is the m... | 2009/11/03 | [
"https://Stackoverflow.com/questions/1667420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445087/"
] | Use [thread::timed\_join()](http://www.boost.org/doc/libs/1_35_0/doc/html/thread/thread_management.html#thread.thread_management.thread.timed_join) with a minimal timeout. It will return false if the thread is still running.
Sample code:
```
thread_->timed_join(boost::posix_time::seconds(0));
``` | I am using boost 1.54, by which stage timed\_join() is being deprecated. Depending upon your usage, you could use joinable() which works perfectly for my purposes, or alternatively you could use try\_join\_for() or try\_join\_until(), see:
<http://www.boost.org/doc/libs/1_54_0/doc/html/thread/thread_management.html> |
53,602,320 | How can I architect code to run a pyqt GUI multiple times consecutively in a process?
(pyqtgraph specifically, if that is relevant)
The context
-----------
A python script that performs long running data capture on measurement equipment (a big for loop). During each capture iteration a new GUI appear and displays l... | 2018/12/03 | [
"https://Stackoverflow.com/questions/53602320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50135/"
] | An application is an executable process that runs on one or more foreground threads each of which can also start background threads to perform parallel operations or operations without blocking the calling thread. An application will terminate after all foreground threads have ended, therefore, you need at least one fo... | If you want your GUI to keep updating in **realtime** and to not be freezed, you have **two main ways** to do it:
1. **Refresh the GUI from time to time** calling `QApplication.processEvents()` inside your time consuming function.
2. **Create a separate thread** (I mean, `QThread`) where you run your time consuming fu... |
28,179,413 | Cannot figure out what this regex pattern does. Searches in google just return generic regex uses. Help please!!!
```
const string HTML_TAG_PATTERN = "<.*?>";
return Regex.Replace(inputString, HTML_TAG_PATTERN, string.Empty);
``` | 2015/01/27 | [
"https://Stackoverflow.com/questions/28179413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2631233/"
] | The above replaces all HTML style tags with an empty space. It matches as follows:
```
< - Match the < character literally
.*? - Match any single character that is not a line break character
between zero and unlimited times, as few times as possible, expanding as needed
> - Match the > character literally
```
... | Try running it through a regex tester (any of a dozen of which canbe found via a search)
* Seeing as the angle brackets (`<` and `>`) aren't typical Regex
syntax, those symbols get matched exactly.
* The `.` means "any character except newline"
* the `*` means "zero or more of the preceding element"
* the `?` means "z... |
58,783,730 | In Thymeleaf, to trigger the index.html page (present in templates folder of resources) providing a new @RequestMapping method in the application's Main class does not work (outputs the string instead of rendering the HTML page) but creating a separate @Controller class with same @RequestMapping method is triggering th... | 2019/11/09 | [
"https://Stackoverflow.com/questions/58783730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5009920/"
] | In my case I didn't have to eject the settings. I used the packages [react-app-rewired](https://www.npmjs.com/package/react-app-rewired) with the [cutomize-cra](https://www.npmjs.com/package/customize-cra).
1. I created the *config-overrides.js* to overrides the config about **cra** (create-react-app)
```
/* config-... | There's a nice tool to avoid the error thrown: <https://github.com/harrysolovay/rescripts>
How to:
1. Install rescripts
>
> npm i -D @rescripts/cli
>
>
>
2. In package.json, replace "react-scripts" with "rescripts":
>
>
> ```
> "scripts": {
> "start": "rescripts start",
> "build": "rescripts build"... |
70,106,975 | in my laravel application i have an input field to insert date of birth,
my date format has to be `d/m/y` and my age limit has to be 18-70
inside my controller's `store` method I have following validation rule for the dob.
```
'date_of_birth'=>['required','bail','date','date_format:d/m/y',function ($attribute, $valu... | 2021/11/25 | [
"https://Stackoverflow.com/questions/70106975",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10249502/"
] | you have two problems with your code:
1- you should remove 'date' from validation, since you are passing a string not a date.
2- you should correct the format to be right: 'd/m/Y' Y is capital letter.
```
$rules = ['date_of_birth' => ['required', 'bail', 'date_format:d/m/Y',
function ($attribute, $valu... | Use `format` method in function
```
$age=Carbon::createFromFormat('d/m/y', $value)->diff(Carbon::now())->format('%y');
``` |
2,340,572 | How can we use global.asax in asp.net? And what is that? | 2010/02/26 | [
"https://Stackoverflow.com/questions/2340572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/227848/"
] | Global asax events explained
**Application\_Init:** Fired when an application initializes or is first called. It's invoked for all HttpApplication object instances.
**Application\_Disposed:** Fired just before an application is destroyed. This is the ideal location for cleaning up previously used resources.
**Applic... | The root directory of a web application has a special significance and certain content can be present on in that folder.
It can have a special file called as “Global.asax”. ASP.Net framework uses the content in the global.asax and creates a
class at runtime which is inherited from HttpApplication.
During the lifetime o... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.