qid
int64 1
74.7M
| question
stringlengths 0
70k
| date
stringlengths 10
10
| metadata
list | response
stringlengths 0
115k
|
---|---|---|---|---|
1,080,842 |
I know in SQL Server 2005 we could do something like:
>
> DELETE TOP 10 FROM tbX where X = 1
>
>
>
What could be the query to do the same in SQL2K, **considering** that the primary key is composed by two FK columns?
|
2009/07/03
|
[
"https://Stackoverflow.com/questions/1080842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21668/"
] |
hacky, but:
```
SET ROWCOUNT 10
DELETE FROM tbX where X = 1
SET ROWCOUNT 0
```
I wouldn't write this myself, though ;-p
(I'm off to wash my hands...)
|
9,162,847 |
Just learning about PHP and wordpress and getting some problem.Here is my use-case.
I have a text area like
```
<textarea id='contact-message' class='contact-input' name='message' cols='40' rows='4' tabindex='1004'></textarea>
```
and user can input text in this area.everything is working fine but if user while typing the message hit the `"Enter Key"` it will start on the new line in text area and this new line is giving me the following exception when i am trying to submit the form
When user submitting the form i am creating a URL String and passing it to a java script function to submit by ajax call.This is my
PHP code
--------
```
$input = "u_email=".$email;
$input .= "&u_subject=" .$subject . "&u_message=" .$message . "&u_ip=" . $_SERVER["REMOTE_ADDR"] ."&u_name=" .$name;
echo "<script>rtf_submit('$baseURL','$input');</script>";
```
JS Code
-------
```
function rtf_submit(url,requestURL){
}
```
This was the submitted URL being created by above PHP code
```
[email protected]&u_subject=&u_message=Hello World&u_ip=127.0.0.1&u_name=hello
```
and this is the exception i am getting
```
Error: unterminated string literal
Line: 0, Column: 83
Source Code:
rtf_submit('http://localhost/blog/wordpress/wp-content/plugins/user_feedback/','[email protected]&u_subject=&u_message=Hello
```
I press enter key after typing `Hello` and this space/new line is being not handled properly by java-script code.
Is there any way i can handle this at PHP side to avoid such cases or need to be done at java-script?
Thanks in advance
|
2012/02/06
|
[
"https://Stackoverflow.com/questions/9162847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/471607/"
] |
Generally speaking when JVM crashes the content of `hs_err` error log file (controlled by `-XX:ErrorFile`) is often enough to point what the trouble may be.
To prevent Oracle JVM Hotspot to generate Windows minidump (mdmp files), the JVM option to use on command line is: `-XX:-CreateMinidumpOnCrash`
It exists since 2011 but was very difficult to find: [How to disable minidump (mdmp) files generation with Java Hotspot JVM on Windows](https://stackoverflow.com/questions/22769799/how-to-disable-minidump-mdmp-files-generation-with-java-hotspot-jvm-on-windows/22771547#22771547)
|
13,252,219 |
I have the following code:
```
<?php
$result = '<test>hello</test>';
echo $result;
```
When I execute it, then I only receive
```
hello
```
It seems so, that PHP deletes these tags in the string, when i try to give it out. How can I preserve these tags in the string?
|
2012/11/06
|
[
"https://Stackoverflow.com/questions/13252219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1478646/"
] |
you can use [`htmlentities()`](http://php.net/manual/en/function.htmlentities.php) php function : in your case,
```
echo htmlentities($result);
```
or
```
echo htmlentities("<test>hello</test>");
```
better approach will be
```
htmlspecialchars()
```
|
103,160 |
How should I go about mounting an external hard drive without an enclosure?
I have a IDE/SATA to USB adapter. But where should I put the drive, what side should be facing upwards, etc?
|
2010/02/01
|
[
"https://superuser.com/questions/103160",
"https://superuser.com",
"https://superuser.com/users/6244/"
] |
Whenever I have to use an internal hard drive outside the case, I usually just lay it on the metal side with the components facing upwards. As long as this isn't a permanent solution, you should be fine. If you plan to leave the hard drive out in the open all the time, then I would highly recommend an enclosure
Another concern with a naked hard drive is picking it up and moving it while the heads are not parked. A sharp bump or drop of the hard drive could cause the head to crash into the platter, causing permanent damage and data loss. Modern laptop hard drives sometimes have accelerometers that sense the hard drive is falling and park the head before it makes impact, but I'm not sure if desktop hard drives commonly have this or not. You can read up about [head crashes on Wikipedia](http://en.wikipedia.org/wiki/Head_crash) if you're interested.
---
Below is my original answer, which I'll just leave for context.
If you have an internal hard drive that you want to connect to a computer without opening the case (or if it's a laptop), then there are USB adapters you can purchase, such as [this one that adapts both PATA and SATA to USB](http://rads.stackoverflow.com/amzn/click/B000J01I1G), which I have used at work with no problems.
Another solution is the [Thermaltake BlacX SATA docking station](http://rads.stackoverflow.com/amzn/click/B0012Z3MKW). I have two of these for my own purposes and they work great as well. I use these for a rotating backup system so I can always keep one hard drive off-site and hot-swap them as necessary.
|
121 |
While browsing freshpatents.com for software patents, I happened upon [Patent Application #20120226507](http://www.google.com/patents/us20120226507), which seeks to patent a system for moving patient beds from one room to another. The claims:
>
> * A system for the facilitation of bed transitions in health care system comprising:
> + a vendor network subsystem,
> + a bed transitions subsystem and
> + a nurse realty subsystem
> * A web based application for the facilitation of bed transitions in health care systems comprising:
> + a web browser
> + an application generating a webpage
> + an application for generating a bed transition system.
>
>
>
To me, this seems pretty obvious technology. While I am unable to find a directly analogous software package, there are numerous patient management systems in existence, which manage the patient experience as well as handle doctor/nurse scheduling.
Some examples of patient/inpatient management systems:
* NextGen (http://www.nextgen.com/EHR)
* Epic InPatient Clinicals (http://www.epic.com/software-inpatient.php)
*InPatient Clinicals* seems to be very close to the patent's description. Does anyone know of a more exact prior art example?
|
2012/09/18
|
[
"https://patents.stackexchange.com/questions/121",
"https://patents.stackexchange.com",
"https://patents.stackexchange.com/users/272/"
] |
If you read further into the patent under [0022] it says:
>
> The examples below describe a web based computer network. Although the present examples are described and illustrated herein as being implemented in internet based system, the system described is provided as an example and not a limitation.
>
>
>
IANAL, but I believe prior art for this patent would just be *any* hospital that currently manages beds. It does not even need to be a software management system. It could be paper based, or whiteboard based, etc.
For instance, if you could show a hospital that has a list of vendors, a list of beds, and a list of nurses and uses those three things to manage where beds are then simply reimplementing this in software, does not add anything novel to the process.
|
32,141,086 |
I recently took a new job and I am trying to simplify some older queries left around and for the life of me I cannot figure out how to get this down into two queries using union. There's got to be a way but I cant simplify more than what I have.
```
select (
select avg (Employee.salary)
from Employee left join Job_title
on Employee.job_title = Job_title.Job_title
where Employee.Exempt_Non_Exempt_Status='0'
group by Employee.Exempt_Non_Exempt_Status
) as AverageSalary, 'Non-Exempt' as Status
, (
select MIN (Employee.salary)
from Employee left join Job_title
on Employee.job_title = Job_title.Job_title
where Employee.Exempt_Non_Exempt_Status='0'
group by Employee.Exempt_Non_Exempt_Status
) as MinimumSalary, 'Non-Exempt' as Status
, (
select MAX (Employee.salary)
from Employee left join Job_title
on Employee.job_title = Job_title.Job_title
where Employee.Exempt_Non_Exempt_Status='0'
group by Employee.Exempt_Non_Exempt_Status
) as MaximumSalary, 'Non_Exempt' as Status
UNION
select (
select avg (Employee.salary)
from Employee left join Job_title
on Employee.job_title = Job_title.Job_title
where Employee.Exempt_Non_Exempt_Status='1'
group by Employee.Exempt_Non_Exempt_Status
) as AverageSalary, 'Exempt' as Status
, (
select MIN (Employee.salary)
from Employee left join Job_title
on Employee.job_title = Job_title.Job_title
where Employee.Exempt_Non_Exempt_Status='1'
group by Employee.Exempt_Non_Exempt_Status
) as MinimumSalary, 'Exempt' as Status
, (
select MAX (Employee.salary)
from Employee left join Job_title
on Employee.job_title = Job_title.Job_title
where Employee.Exempt_Non_Exempt_Status='1'
group by Employee.Exempt_Non_Exempt_Status
)as MaximumSalary, 'Exempt' as Status
```
|
2015/08/21
|
[
"https://Stackoverflow.com/questions/32141086",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5252012/"
] |
Since you are only selecting 1 field in each of the subqueries, you don't need a "Group By". Also, depending on the the data, you might not need to link in the Job\_title Table.
If you need the Job\_title table then...
```
SELECT Min(salary), Max(salary), Avg(salary), 'Non-Exempt' AS Status
FROM (SELECT employee.salary
FROM employee
LEFT JOIN job_title ON employee.job_title = job_title.job_title
WHERE employee.exempt_non_exempt_status = '0')
UNION
SELECT Min(salary), Max(salary), Avg(salary), 'Exempt' AS Status
FROM (SELECT employee.salary
FROM employee
LEFT JOIN job_title
ON employee.job_title = job_title.job_title
WHERE employee.exempt_non_exempt_status = '1')
```
If you don't need to link in the Job\_title (since you're not using it anywhere) then...
```
SELECT Min(salary), Max(salary), Avg(salary), 'Non-Exempt' AS Status
FROM (SELECT employee.salary
FROM employee
WHERE employee.exempt_non_exempt_status = '0')
UNION
SELECT Min(salary), Max(salary), Avg(salary), 'Exempt' AS Status
FROM (SELECT employee.salary
FROM employee
WHERE employee.exempt_non_exempt_status = '1')
```
|
41,496,804 |
I've just written some code to convert a list of points into a list of to/from tuples but it doesn't feel very efficient.
I was wondering if anyone had any suggestions to make this more concise?
```
from_point, to_point = None, None
point_list = []
for p in [1, 5, 2, 4, 7, 9]:
to_point = p
if from_point and to_point:
point_list.append((from_point, to_point))
from_point = to_point
print(point_list)
```
Input: `[1, 5, 2, 4, 7, 9]`
Output: `[(1, 5), (5, 2), (2, 4), (4, 7), (7, 9)]`
Edit: Changed points to be non sequential.
|
2017/01/05
|
[
"https://Stackoverflow.com/questions/41496804",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4309926/"
] |
You can always use [`zip`](https://docs.python.org/3/library/functions.html#zip):
```
>>> p = [1, 5, 2, 4, 7, 9]
>>> point_list = list(zip(p[:-1], p[1:]))
>>> print(point_list)
[(1, 5), (5, 2), (2, 4), (4, 7), (7, 9)]
```
|
57,425,235 |
Guys I put (like and dislike button not with facebook) my site.And I want to show like values and dislike values.I did but I want just once click.How can I do ?
```
var clicks = 0;
function updateClickCount() {
document.getElementById("clickCount").innerHTML = clicks;
}
onClick="clicks--; updateClickCount();
onClick="clicks++; updateClickCount();
```
I expect the button of once click , but the actual button as much as you want.
|
2019/08/09
|
[
"https://Stackoverflow.com/questions/57425235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10215862/"
] |
You can remove the event listener, after the button gets clicked using [`removeEventListener`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener). Do keep in mind that the parameters supplied in the `removeEventListener` call must be identical with the ones supplied to the `addEventListener` call, otherwise it won't work.
```js
var button = document.getElementById("btn");
button.addEventListener("click", onClick);
function onClick() {
console.log("Clicked");
button.removeEventListener("click", onClick);
}
```
```html
<button id="btn">Click Me!</button>
```
If you have added the listener inline (using `onClick=""` attribute), you can't use `removeEventListener`. You can however remove the `onClick` attribute.
```js
var button = document.getElementById("btn");
function onClick() {
console.log("Clicked");
button.removeAttribute("onClick");
}
```
```html
<button id="btn" onClick="onClick()">Click Me!</button>
```
You could disable the button, making it un-clickable.
```js
var button = document.getElementById("btn");
button.addEventListener("click", onClick);
function onClick() {
console.log("Clicked");
button.disabled = true;
}
```
```html
<button id="btn">Click Me!</button>
```
You can use a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) (Promises can only be resolved once).
```js
var button = document.getElementById("btn");
new Promise(function(resolve) {
button.addEventListener("click", resolve);
}).then(onClick);
function onClick() {
console.log("Clicked");
}
```
```html
<button id="btn">Click Me!</button>
```
Finally you store the info of whether the button has been clicked or not in a boolean variable.
```js
var button = document.getElementById("btn");
var buttonFlag = false;
button.addEventListener("click", onClick);
function onClick() {
if (buttonFlag) return;
console.log("Clicked");
buttonFlag = true;
}
```
```html
<button id="btn">Click Me!</button>
```
Update
You can now also use the [once property](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#once) so that the event only runs once (or never if it's never triggered).
```js
var button = document.getElementById("btn");
button.addEventListener("click", () => console.log("Clicked"), {
once: true
});
```
```html
<button id="btn">Click Me</button>
```
|
11,146,725 |
```
class HelloWorld(object):
def say_it(self):
return 'Hello I am Hello World'
def i_call_hello_world(hw_obj):
print 'here... check type: %s' %type(HelloWorld)
if isinstance(hw_obj, HelloWorld):
print hw_obj.say_it()
from mock import patch, MagicMock
import unittest
class TestInstance(unittest.TestCase):
@patch('__main__.HelloWorld', spec=HelloWorld)
def test_mock(self,MK):
print type(MK)
MK.say_it.return_value = 'I am fake'
v = i_call_hello_world(MK)
print v
if __name__ == '__main__':
c = HelloWorld()
i_call_hello_world(c)
print isinstance(c, HelloWorld)
unittest.main()
```
Here is the traceback
```none
here... check type: <type 'type'>
Hello I am Hello World
True
<class 'mock.MagicMock'>
here... check type: <class 'mock.MagicMock'>
E
======================================================================
ERROR: test_mock (__main__.TestInstance)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/mock.py", line 1224, in patched
return func(*args, **keywargs)
File "t.py", line 18, in test_mock
v = i_call_hello_world(MK)
File "t.py", line 7, in i_call_hello_world
if isinstance(hw_obj, HelloWorld):
TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types
----------------------------------------------------------------------
Ran 1 test in 0.002s
```
**Q1.** Why is this error thrown? They are `<class type='MagicMock>`
**Q2.** How do I pause the mocking so that the first line will pass if the error is fixed?
From the [docs](http://www.voidspace.org.uk/python/mock/mock.html#mock.Mock.__class__):
>
> Normally the `__class__` attribute of an object will return its type. For a mock object with a spec, `__class__` returns the spec class instead. This allows mock objects to pass `isinstance()` tests for the object they are replacing / masquerading as:
>
>
>
```
mock = Mock(spec=3)
isinstance(mock, int)
True
```
|
2012/06/21
|
[
"https://Stackoverflow.com/questions/11146725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/230884/"
] |
IMHO this is a good question and saying "*don't use `isinstance`, use duck typing instead*" is a bad answer. Duck typing is great, but not a silver bullet. Sometimes `isinstance` is necessary, even if it is not pythonic. For instance, if you work with some library or legacy code that isn't pythonic you must play with `isinstance`. It is just the real world and mock was designed to fit this kind of work.
In the code the big mistake is when you write:
```
@patch('__main__.HelloWorld', spec=HelloWorld)
def test_mock(self,MK):
```
From [`patch` documentation](https://docs.python.org/3/library/unittest.mock.html#patch) we read (emphasize is mine):
>
> Inside the body of the function or with statement, the target is patched with a new **object**.
>
>
>
That means when you patch the `HelloWorld` **class object** the reference to `HelloWorld` will be replaced by a `MagicMock` object for the context of the `test_mock()` function.
Then, when `i_call_hello_world()` is executed in `if isinstance(hw_obj, HelloWorld):` `HelloWorld` is a `MagicMock()` object and not a class (as the error suggests).
That behavior is because as a side effect of patching a class reference the 2nd argument of `isinstance(hw_obj, HelloWorld)` becomes an object (a `MagicMock` instance). This is neither a `class` or a `type`. A simple experiment to understand this behavior is to modify `i_call_hello_world()` as follows:
```
HelloWorld_cache = HelloWorld
def i_call_hello_world(hw_obj):
print 'here... check type: %s' %type(HelloWorld_cache)
if isinstance(hw_obj, HelloWorld_cache):
print hw_obj.say_it()
```
The error will disappear because the original reference to `HelloWorld` class is saved in `HelloWorld_cache` when you load the module. When the patch is applied it will change just `HelloWorld` and not `HelloWorld_cache`.
Unfortunately, the previous experiment doesn't give us any way to play with cases like yours because you cannot change the library or legacy code to introduce a trick like this. Moreover, these are that kind of tricks that we would like to never see in our code.
The good news is that you can do something ,but you cannot just `patch` the `HelloWord` reference in the module where you have `isinstace(o,HelloWord)` code to test. The best way depends on the real case that you must solve. In your example you can just create a `Mock` to use as `HelloWorld` object, use `spec` argument to dress it as `HelloWorld` instance and pass the `isinstance` test. This is exactly one of the aims for which `spec` is designed. Your test would be written like this:
```
def test_mock(self):
MK = MagicMock(spec=HelloWorld) #The hw_obj passed to i_call_hello_world
print type(MK)
MK.say_it.return_value = 'I am fake'
v = i_call_hello_world(MK)
print v
```
And the output of just unittest part is
```
<class 'mock.MagicMock'>
here... check type: <type 'type'>
I am fake
None
```
|
6,321,802 |
Can anybody explain the following Perl code for me, please?
I think its in Perl and I have no clue about Perl programming. Please explain what the following code does?
```
$t = test(10);
sub test() {
my $str = unpack("B32", pack("N",shift));
$str2 = substr($str,16,length($str));
return $str2;
}
```
|
2011/06/12
|
[
"https://Stackoverflow.com/questions/6321802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/261002/"
] |
The pack, unpack and substr functions are documented [here](http://perldoc.perl.org/functions/pack.html), [here](http://perldoc.perl.org/functions/unpack.html) and [here](http://perldoc.perl.org/functions/substr.html), respectively.
`pack("N"...)` packs a number into a four-byte network-order representation. `unpack("B32"...)` unpacks this packed number as a string of bits (zeros and ones). The `substr` call takes the second half of this bit string (from bit 16 onwards), which represents the lower 16 bits of the original 32-bit number.
Why it does it this way is a mystery to me. A simpler and faster solution is to deal with the lower 16 bits at the outset (note the lower case `"n"`):
```
sub test($) {
return unpack("B16", pack("n",shift));
}
```
|
30,025 |
I have two SATA HDDs in my desktop PC (one for daily activity, one for storage and backup). I can finely use ReadyBoost with pendrives, but I wonder, Is there a way I could use my underutilized second HDD to participate in the cacheing mechanism (same concept as having two CPU cores crunch things in parallel: have two HDDs fetch data in parallel)? Clearly speaking: I want to enable ReadyBoost on my separate D: drive.
|
2009/08/26
|
[
"https://superuser.com/questions/30025",
"https://superuser.com",
"https://superuser.com/users/1138/"
] |
ReadyBoost is designed to take advantage of the almost non-existant latency of most flash drives to get small amounts of data into memory quickly. A modern hard drive will still easily out transfer most usb flash drives (50-100MB/s vs. 10-20MB/s) after just a few hundred milliseconds on average.
There really isn't a good way to enable your suggested scenario, or a performance reason to consider it. You would be better off using your second hard drive in a RAID1 configuration (some controllers support parallel reading), or possibly offloading programs/data that won't have to contend for I/O with the boot drive. You would be amazed at the near constant amount of small I/O that happens on the boot drive.
|
623,182 |
I remember in vb6 there was a control that was similar to a dropbox/combobox that you can select the drive name. It raises an event which you can then set another control which enumerate files in listbox. (in drive.event you do files.path = drive.path to get this affect).
Is there anything like this in C#? a control that drops down a list of available drives and raises an event when it is changed?
|
2009/03/08
|
[
"https://Stackoverflow.com/questions/623182",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
There's no built-in control to do that, but it's very easy to accomplish with a standard ComboBox. Drop one on your form, change its DropDownStyle to DropDownList to prevent editing, and in the Load event for the form, add this line:
```
comboBox1.DataSource = Environment.GetLogicalDrives();
```
Now you can handle the SelectedValueChanged event to take action when someone changes the selected drive.
After answering [this question](https://stackoverflow.com/questions/623254/getdrivetype-in-c-or-find-out-if-my-drive-is-removable/623256), I've found another (better?) way to do this. You can use the DriveInfo.GetDrives() method to enumerate the drives and bind the result to the ComboBox. That way you can limit which drives apppear. So you could start with this:
```
comboBox1.DataSource = System.IO.DriveInfo.GetDrives();
comboBox1.DisplayMember = "Name";
```
Now comboBox1.SelectedValue will be of type DriveInfo, so you'll get lots more info about the selected game. And if you only want to show network drives, you can do this now:
```
comboBox1.DataSource = System.IO.DriveInfo.GetDrives()
.Where(d => d.DriveType == System.IO.DriveType.Network);
comboBox1.DisplayMember = "Name";
```
I think the DriveInfo method is a lot more flexible.
|
47,216,918 |
I am using a private JAVA library in my project. In the library API, developers wrote a custom Exception class "ClassException" and if any exception raises they throw this class exception object. At some point of view I couldn't figure out clearly where the exception is raised when using this library in my project. All I could see on the console as
`ClassException raised inside a java class Demo` of the private library.
I don't have the source code of the library to change as per my wish. All I can see is the .class file.
**ClassException:**
```
public class ClassException extends Exception {
private static final long serialVersionUID = 1L;
private ClassErrorStatus mErrorCode;
public ClassException(ClassErrorStatus pErrorCode) {
}
public ClassException(String pMessage, ClassErrorStatus pErrorCode) {
}
public ClassException(Throwable pCause, ClassErrorStatus pErrorCode) {
}
public ClassException(String pMessage, Throwable pCause, ClassErrorStatus pErrorCode) {
}
public ClassErrorStatus getErrorStatus() {
}
}
```
How can I override this class methods such that if anywhere a ClassException is thrown it should call my custom class exception methods. Is there anyway to do so?
Like `throw new ClassException()` should call my own Exception class methods.
|
2017/11/10
|
[
"https://Stackoverflow.com/questions/47216918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7670995/"
] |
You could create a **ClassException** with the same package as the library and put it before in the classpath (e.g in a jar starting with \_).
But, you won't get any further information since the exception will be thrown as it's being thrown now.
You could try decompiling the code (if the license allows you) and using the debugger to go step by step.
|
3,928 |
As I noticed the name of Argentinian football club Boca Juniors is pronounced by Argentinians not as I would expect in Spanish but more [close to English](https://www.youtube.com/watch?v=I6mB_Zib63E#t=030)
As far as I understand, the reason for that is this name having English origin and that the word "junior" is absent in Spanish.
The questions are:
- are the assumptions above correct?
- how does Spanish-speaking person without English knowledge know how to pronounce this word? Is it a convention or an exception?
I am wondering what would be the difference between pronouncing the words with origin in other language that speaker doesn't know and "invented" words like in <http://es.wikipedia.org/wiki/Jabberwocky>
|
2013/07/18
|
[
"https://spanish.stackexchange.com/questions/3928",
"https://spanish.stackexchange.com",
"https://spanish.stackexchange.com/users/1722/"
] |
This is a tricky question. If someone doesn't know another language, he/she can't know how to pronounce it well. That's obvious. However, in the case of Boca Juniors, I would say many people in Argentina learn how to say it way before knowing how it is written or how to write at all.
Anyway, in the more general case, I'm no expert but I think **people just "do their best"** to pronounce unknown words correctly. They will apply what they know and try to make the word sound "right" under that frame.
For example, back in the 50s or 60s, in Spain very few people spoke English, and so they used Spanish (or French) rules to pronounce English words and names. Thus, you would hear things like "Umpri Bogar" (Humphrey Bogart), "Yon Baine" (John Wayne), "Kirk Duglas" (Kirk Douglas)...
Nowadays exposure to English is much bigger, and more people speak it, so now we more or less pronounce them well. So the son of Kirk Duglas is Maikel Daglas (the funny thing is we keep saying Kirk Duglas even though we "know" it's wrong).
But, at least here in Spain, people don't take it too far. We can very easily say two English words, one with English pronunciation and the other with Spanish pronunciation, e.g. we pronounce White Label as "uait label" not "uait leibol" or "uite label", and there are some names we haven't got right yet, like Tom Cruise, which *everybody* here says "Tom Cruis" (actually, I think it's slowly changing and more people say it right).
And, lo and behold, if someone says those English words with the proper accent and pronunciation, they can be regarded as "pedantic".
From what I've seen in TV, it seems like in Mexico and other countries in Central and South America, people say English words better, probably because they are more exposed to English, in TV, cinema, etc.
But now that people more or less know how to pronounce English, when they find a foreign word, they (we) will, again, "do their best" to say it. So they will add English to their pronunciation toolbox, and say the word using that toolbox, often mixing things between languages. And now we say German, Russian, Dutch, or whatever language words and names with a mixture of rules of Spanish, English and any other languages we might know, plus whatever similar we might have heard on TV, films, etc., so now "H"s have sound when they shouldn't, "ei" is pronounced like Spanish "i", instead of "ai" (like in German), etc.
|
19,290,406 |
I'm trying to display a string inside a textView object.
currently I'm only getting the first string in the string array.
```
public void onClick(View v) {
Resources res = getResources();
String[] hintsStr = res.getStringArray(R.array.hints);
TextView hintShow = (TextView)findViewById(R.id.hintShow);
int rndInd = (int) Math.random()*5;
//hintShow.setText(rndInd);
hintShow.setText(hintsStr[rndInd]);
//System.out.print(rndInd);
}
```
|
2013/10/10
|
[
"https://Stackoverflow.com/questions/19290406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2684237/"
] |
Try this to generate your random numbers.-
```
Random rand = new Random();
int rndInd = rand.nextInt(5); // Will get a rand number between 0 and 4
```
Also, you should instantiate rand object just once, as an instance variable outside `onClick` method.
|
1,916,870 |
I understand the idea behind complex and imaginary numbers. I am trying to understand quaternions.
What is the relation between imaginary (or complex) numbers, and quaternions?
|
2016/09/06
|
[
"https://math.stackexchange.com/questions/1916870",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/360475/"
] |
**EDITED**
Let's start with the real line $\mathbb{R}$ constituted of real numbers $t$. This [field](https://en.wikipedia.org/wiki/Field_(mathematics)) is not [algebraically closed](https://en.wikipedia.org/wiki/Algebraically_closed_field) from the absence of a real solution to the simple polynomial equation : $$\tag{1} X^2=-1$$
A solution of $(1)$ named $\,\mathbf{i}\,$ was *invented* and supposed belonging to the (imaginary) orthogonal to the real line at $0$. The 'numbers' $\;t+x\,\mathbf{i}\;$ with $\,t,x\,$ real constituting the field $\,\mathbb{C}$. This field *is* algebraically closed and nothing further needed to be added at this point.
But Hamilton wanted to get out of the plane and imagined another independent solution $\,\mathbf{j}\,$ of $(1)$ belonging to the orthogonal to the real and imaginary lines at $0$.
Playing with these new 'extended numbers' $\;t+x\,\mathbf{i}+y\,\mathbf{j}\;$ filling the 3D space he [got into trouble with multiplication](https://en.wikipedia.org/wiki/History_of_quaternions#Hamilton.27s_discovery) since the product of two 'extended numbers' contained the products $\,\mathbf{i}\,\mathbf{j}\,$ and $\,\mathbf{j}\,\mathbf{i}$.
Suppose that $\,\mathbf{i}\,\mathbf{j}\,$ belongs to the 3D space : this means that $\;\mathbf{i}\,\mathbf{j}=a+b\,\mathbf{i}+c\,\mathbf{j}\;$ but if we multiply this (at the left) by $\mathbf{i}\,$, replace $\mathbf{i}\,\mathbf{j}\,$ by the initial expression and simplify everything then we get $\mathbf{j}$ as $\;\mathbf{j}=\alpha +\beta\,\mathbf{i}\;$ : the 3D space collapsed back to the initial complex plane!
From the distributivity and associativity of the product we can't thus have two independent $\mathbf{i}\,$ and $\mathbf{j}\,$ without their product $\;\mathbf{k}:=\mathbf{i}\,\mathbf{j}\,$ being independent too : the 4D space generated by $\,(1,\,\mathbf{i},\,\mathbf{j},\,\mathbf{k})\,$ is mandatory!
And what about $\,\mathbf{j}\,\mathbf{i}$?
If we suppose that $\,\mathbf{i}\,\mathbf{j}=\mathbf{j}\,\mathbf{i}\,$ then everything will remain commutative with $\,\mathbf{k}^2=1\,$ and we obtain what was named [tessarines by James Cockle](https://en.wikipedia.org/wiki/Bicomplex_number#Tessarines) and later bicomplex numbers that were further generalized to [multicomplex numbers](https://en.wikipedia.org/wiki/Multicomplex_number) ($\,\mathbf{k}$ itself defining a [split-complex number](https://en.wikipedia.org/wiki/Split-complex_number)).
But before all this Hamilton noticed that $\,\left(x\,\mathbf{i}+y\,\mathbf{j}\right)^2=xy\;(\mathbf{i}\,\mathbf{j}+\mathbf{j}\,\mathbf{i})-(x^2+y^2)\,$ so that abandoning commutativity and supposing that $\,\mathbf{k}=\mathbf{i}\,\mathbf{j}=-\mathbf{j}\,\mathbf{i}\;$ he could rewrite not only $\,\left(x\,\mathbf{i}+y\,\mathbf{j}\right)^2=-(x^2+y^2)\,$ but also $\,\mathbf{k}^2=-1\,$ and $\,\left(x\,\mathbf{i}+y\,\mathbf{j}+z\,\mathbf{k}\right)^2=-(x^2+y^2+z^2)$.
The 3D space he wished was thus generated by $\,(\mathbf{i},\,\mathbf{j},\,\mathbf{k})\,$ instead of $\,(1,\,\mathbf{i},\,\mathbf{j})\,$ and he gained further an interesting fourth dimension! He was proud enough of his discovery to carve his very nice result into the [stone of Brougham Bridge](https://en.wikipedia.org/wiki/Quaternion#History) :
$$\boxed{\displaystyle\mathbf{i}^2=\mathbf{j}^2=\mathbf{k}^2=\mathbf{i}\mathbf{j}\mathbf{k}=-1}$$
|
804,934 |
I recently installed CentOS 7 on my desktop computer and decided on the minimal install. It couldn't find a network device in the installation process, but I went ahead and installed it anyway. /etc/sysconfig/network-scripts/ifcfg-eth0 didn't exist to start. ifcfg-lo was the only one:
```
[chris@piecework4 /]$ ls /etc/sysconfig/network-scripts | grep ifcfg-
ifcfg-lo
```
I made ifcfg-eth0 with the following values:
```
DEVICE="eth0"
BOOTPROTO=dhcp
NM_CONTROLLED="no"
PERSISTENT_DHCLIENT=1
ONBOOT="yes"
TYPE=Ethernet
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME="eth0"
HWADDR=00:13:D4:37:42:39
```
ifconfig -a only shows this:
```
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 8 bytes 560 (560.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8 bytes 560 (560.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
```
I do have an Ethernet controller...
```
[chris@piecework4 /]$ lspci | grep Ethernet
00:04.0 Ethernet controller: Silicon Integrated Systems [SiS] SiS900 PCI Fast Ethernet (rev 90)
```
Ethernet works fine on every live cd I try.
|
2014/08/30
|
[
"https://superuser.com/questions/804934",
"https://superuser.com",
"https://superuser.com/users/363115/"
] |
If you're dealing with VMWare try following:
I added the following line to my .vmx file:
```
ethernet0.virtualDev = "e1000"
```
reference: [www.centos.org/forums/viewtopic.php?f=47&t=47724](https://www.centos.org/forums/viewtopic.php?f=47&t=47724)
|
14,777,684 |
I'm making a sliding div with jQuery UI, but i have a problem.
I have an outer DIV and 2 inner DIV that are left floated. On the first inner DIV i have the sliding effect.
```
<div id="outer">
Outer Div
<p><a href="#" id="SlideOut">Slide Out</a></p>
<p><a href="#" id="SlideIn">Slide In</a></p>
<div id="inner">inner</div>
<div id="inner2">inner2</div>
</div>
```
---
```
$("#SlideOut").click(function(){
$("#inner").hide("slide",{direction: 'left'},1000);
});
$("#SlideIn").click(function(){
$("#inner").show("slide",{direction: 'left'},1000);
});
```
The problem is that the second DIV doesn't follow the first div.
It is hard to explain, so here is a fiddle where u can maybe understand better my problem.
<http://jsfiddle.net/xFx26/1/>
In short, i want that the second inner div will slide together the first inner div.
|
2013/02/08
|
[
"https://Stackoverflow.com/questions/14777684",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1405918/"
] |
You should be using `animate()` and changing the width, rather than sliding. The slide slides the contents and then hides the actual container. [Updated fiddle.](http://jsfiddle.net/xFx26/2/)
Code:
```
$("#SlideOut").click(function(){
$("#inner").animate({width: 0},1000);
});
$("#SlideIn").click(function(){
$("#inner").animate({width: 200},1000);
});
```
|
1,765,131 |
I want to use a very old app (I think it was created for Windows XP) on Windows 11. The app supposes to work in Hebrew. Unfortunately, it shows some gibberish characters instead of Hebrew.
Here is a screenshot

I want to say that I have the very same app working perfectly on my other system with Windows 10, and I also tried all the methods written at the Super User Question [Windows 10 displays gibberish text in some apps](https://superuser.com/questions/1194667/windows-10-displays-gibberish-text-in-some-apps) with no success.
|
2023/01/26
|
[
"https://superuser.com/questions/1765131",
"https://superuser.com",
"https://superuser.com/users/1767621/"
] |
Seems like the application is asking for a font that doesn't exist on
your computer. Windows is trying to find a replacement font and doesn't
do it very well.
I suppose that you have installed the Hebrew language on the computer.
To trace which fonts the app is trying to use, you could perhaps try
[SysInternals Process Monitor](https://technet.microsoft.com/en-us/sysinternals/processmonitor.aspx)
to find out what font files the process is looking for while it is running.
Use the Filter button to add a filter for "Process Name is oldapp.exe",
and add filters for "Path includes" for typical font file-name extensions
such as `.fon`, `.otf`, and `.ttf`.
You might be lucky and find it this way.
|
25,676,202 |
I'm trying to write a basic program that spits out the English version of a number when the user inputs a numeral:
```
input = 44
output = fourty four
```
Is there a way to describe all integers?
Basically I want the execution to look something like:
```
number = gets.chomp
if number != (whatever the nomenclature is for integer)
puts 'Please enter a positive number'
```
or something to that effect.
|
2014/09/04
|
[
"https://Stackoverflow.com/questions/25676202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4008366/"
] |
You can do that with the `numbers_and_words` gem:
<https://github.com/kslazarev/numbers_and_words>
It supports languages other than english as well.
For example:
```
21.to_words
=> "twenty-one"
44.to_words
=> "forty-four"
```
|
145,634 |
I want to build simple reluctance motor for education purpose. I have couple of small 3 Phase AC Induction motor with 24 slot stator lap winded for 4 pole design.
I want to convert it to reluctance motor, for that I will cast rotor of silicon steel with slots according to ( 24/16 ) design or similar. But as I do not have much winding experience, I want to reuse the existing winding on stator with may be little rewiring of phase ( i.e. remove star / delta, and use all six wire to switching circuit. )
Can this work ? Is this concept possible to work ?
|
2014/12/28
|
[
"https://electronics.stackexchange.com/questions/145634",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/62214/"
] |
A standard 3-phase, AC motor has the stator windings distributed in the slots to form poles that do not have much saliency. A switched reluctance motor has both salient rotor poles and salient stator poles. You would need to rewind the stator to have a motor like that.
A synchronous reluctance motor has a salient-pole rotor, but distributed windings in the stator to form non-salient poles. To convert an induction motor to a synchronous reluctance motor, you could use the stator as it is and machine the rotor to look something like this:
You can get some induction-motor starting torque from the remaining rotor bars, but the best way to operate the motor would be with a variable-frequency drive (VFD). The VFD will provide reluctance torque from stand-still. That may or may not suit your purpose.
Of course, you may have some difficulty with rotor balance.
|
6,599,000 |
I've been using jQuery to build an ajax-heavy site. I typically use jQuery selectors to refer to individual INPUT/BUTTON/TEXTAREA/etc elements I want to interact with (or retrieve values from).
I just realized this morning that I haven't used a FORM tag in ages - I just manipulate everything through ajax requests. My gut tells me this is not good, but on the other hand it's not been an issue (and I don't foresee it becoming one any time soon, all our current needs are met).
One thing to note: I'm not concerned with graceful degradation in absence of JavaScript (it's a corporate LAN; all browser installs are tightly regulated and all users are known to have javascript). With that said, **is there some reason I should start using the FORM tag that I'm just not seeing?**
|
2011/07/06
|
[
"https://Stackoverflow.com/questions/6599000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/390519/"
] |
Yes, you should still be using form tags. If you want to be really technical, it's probably a good idea to have a non-JavaScript fallback as well. But regardless of that, the main reason for continuing to use `<form>`, `<fieldset>`, `<legend>`, and `<label>` is for accessibility compliance.
Forms are really the sore spot when it comes to web accessibility. They need to be conducted perfectly for smooth operation with screen readers or other assistive technologies. In fact, according to ADA and Section 508 laws and regulations, all those tags are *required* when making forms online. Many people would argue that federal regulations only apply to government and state websites, but you can [tell that to Target](http://www.sitepoint.com/target-settles-accessibility-lawsuit-for-6-million/), who was sued over web accessibility issues.
Really, it's a good idea to just obey the rules. And, personally, making the form submit with or without AJAX is pretty easy. For example, I currently have several forms that are imperative that they can be used with out without JavaScript. All the forms are validated and submit via JavaScript (Yes, they are secondarily validated through the PHP script too). The script the JavaScript submits to is the same page the regular form submits to via cURL. One process page for two different methods with the same results (delivered in JSON and decoded via jQuery or PHP's `json_decode`), just the JavaScript version is cleaner, elegant, and more seamless.
In conclusion, I feel your users would benefit more from including the proper tags then excluding them, even if the benefits don't feel obvious to you or them.
|
15,475,370 |
I know that converting `CByteArray` to `CString` is pretty straightforward. But how do I do it the other way around - from `CString` to `CByteArray`?
|
2013/03/18
|
[
"https://Stackoverflow.com/questions/15475370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/94815/"
] |
GetBuffer() method of the CString class returns the array you need. After that you can copy it using the memcpy or other similar function to a CByteArray object.
```
CString csData = L"someData";
CByteArray byteArr;
BYTE *pByteArray = (PBYTE)(LPCTSTR)csData.GetBuffer();
byteArr.SetSize(csData.GetLength());
memcpy(byteArr.GetData(), pByteArray, csData.GetLength());
```
|
51,476,752 |
I was wondering if there is a way to have the EXP function in SQLite. I am accessing a SQLite database and I need to recreate a Logistic Regression estimator by means of SQL code.
|
2018/07/23
|
[
"https://Stackoverflow.com/questions/51476752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2050341/"
] |
Simply you can achieve it by `regex` as follow if you want to just replace the **long number**:
```
String str2 = "/EMOTIONS_TAX/29027000/Points Of Interest/totem,"
+ "/EMOTIONS_TAX/29044000/Places/Italia,"
+ "/EMOTIONS_TAX/29027000/Military Equipment";
str2 = str2.replaceAll("\\d+", "22");
```
And the result will be:
```
/EMOTIONS_TAX/22/Points Of Interest/totem,/EMOTIONS_TAX/22/Places/Italia,/EMOTIONS_TAX/22/Military Equipment
```
### UPDATED
As OP's request, OP tries to retrieve the **number** from the string instead actually and the solution should be:
```
String str2 = "/EMOTIONS_TAX/29027000/Points Of Interest/totem,"
+ "/EMOTIONS_TAX/29044000/Places/Italia,"
+ "/EMOTIONS_TAX/29027000/Military Equipment";
Pattern pattern = Pattern.compile("\\d+");
Matcher matcher = pattern.matcher(str2);
while(matcher.find()) {
System.out.println(matcher.group());
}
```
And the output:
```
29027000
29044000
29027000
```
|
22,032,063 |
I want to check whether a table contains a row or not. Which is faster?
```
IF EXISTS(SELECT * FROM TABLE)
```
or
```
IF EXISTS(SELECT TOP 1 * FROM TABLE)
```
|
2014/02/26
|
[
"https://Stackoverflow.com/questions/22032063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2183594/"
] |
There is no difference between the queries!
The columns in the select don't get evaluated.
If you recall Logical Query processing, the from clause is executed first. The select clause is executed in the last step (actually Order By is, but that is a cosmetic thing).
So when the from clause gets executed, there are rows returned, regardless of the column names.
You have to add columnnames because otherwise you get syntax errors
|
3,919,512 |
As part of my Android app, I'd like to upload bitmaps to be remotely stored. I have simple HTTP GET and POST communication working perfectly, but documentation on how to do a multipart POST seems to be as rare as unicorns.
Furthermore, I'd like to transmit the image directly from memory, instead of working with a file. In the example code below, I'm getting a byte array from a file to be used later on with HttpClient and MultipartEntity.
```
File input = new File("climb.jpg");
byte[] data = new byte[(int)input.length()];
FileInputStream fis = new FileInputStream(input);
fis.read(data);
ByteArrayPartSource baps = new ByteArrayPartSource(input.getName(), data);
```
This all seems fairly clear to me, except that I can't for the life of me find out where to get this ByteArrayPartSource. I have linked to the httpclient and httpmime JAR files, but no dice. I hear that the package structure changed drastically between HttpClient 3.x and 4.x.
Is anyone using this ByteArrayPartSource in Android, and how did they import it?
After digging around in the documentation and scouring the Internet, I came up with something that fit my needs. To make a multipart request such as a form POST, the following code did the trick for me:
```
File input = new File("climb.jpg");
DefaultHttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("http://localhost:3000/routes");
MultipartEntity multi = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
String line;
multi.addPart("name", new StringBody("test"));
multi.addPart("grade", new StringBody("test"));
multi.addPart("quality", new StringBody("test"));
multi.addPart("latitude", new StringBody("40.74"));
multi.addPart("longitude", new StringBody("40.74"));
multi.addPart("photo", new FileBody(input));
post.setEntity(multi);
HttpResponse resp = client.execute(post);
```
The HTTPMultipartMode.BROWSER\_COMPATIBLE bit is very important. Thanks to [Radomir's blog](http://radomirml.com/2009/02/13/file-upload-with-httpcomponents-successor-of-commons-httpclient/comment-page-1#comment-97) on this one.
|
2010/10/12
|
[
"https://Stackoverflow.com/questions/3919512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/458290/"
] |
try this:
```
HttpClient httpClient = new DefaultHttpClient() ;
HttpPost httpPost = new HttpPost("http://example.com");
MultipartEntity entity = new MultipartEntity();
entity.addPart("file", new FileBody(file));
httpPost.setEntity(entity );
HttpResponse response = null;
try {
response = httpClient.execute(httpPost);
} catch (ClientProtocolException e) {
Log.e("ClientProtocolException : "+e, e.getMessage());
} catch (IOException e) {
Log.e("IOException : "+e, e.getMessage());
}
```
|
30,687,413 |
Lights Off is a puzzle game consisting of an n x n grid of lights. At the beginning of the game, some of the lights are switched on. When a light is pressed, this light and the four adjacent lights are toggled, i. e., they are switched on if they were off, and switched off otherwise. The purpose of the game is to switch all the lights off.
Input:
```
000
110
010
```
Output should be
```
000
000
000
```
by selecting cell 00, 10, 11, 21 & 22.
I made following program, it is working fine, I just want to know if there is any more optimal way to resolve it.
```
import javax.swing.*;
import java.awt.*;
import javax.swing.JFrame;
import java.util.Scanner;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class lightOff extends JFrame implements ActionListener
{
public static final int W = 400;
public static final int H = 200;
JButton[][] lights = new JButton[3][3];
int COLS = 3, ROWS = 3;
public lightOff()
{
super("Light Off");
setSize(W,H);
setLayout(new GridLayout(3,3));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Scanner kb = new Scanner(System.in);
String[][] input = {{"0","0","0"},{"1","1","0"},{"0","1","0"}};
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
//input=kb.next();
lights[i][j] = new JButton();
lights[i][j].addActionListener(this);
lights[i][j].setText(input[i][j]);
add(lights[i][j]);
}
}
}
public static void main(String[] args)
{
lightOff obj1 = new lightOff();
obj1.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
JButton action = (JButton)e.getSource();
if(action==lights[0][0])
{
if("0".equals(lights[0][0].getText()))
lights[0][0].setText("1");
else
lights[0][0].setText("0");
// edgeToggle(0,0,action);
forward(0,0);
down(0,0);
}
else if(action==lights[0][1])
{
if(lights[0][2].getText()=="0")
lights[0][2].setText("1");
else
lights[0][2].setText("0");
backward(0,1);
forward(0,1);
down(0,1);
}
else if(action==lights[0][2])
{
if(lights[0][2].getText()=="0")
lights[0][2].setText("1");
else
lights[0][2].setText("0");
// edgeToggle(0,2,action);
backward(0,2);
down(0,2);
}
else if(action==lights[1][0])
{
if(lights[1][0].getText()=="0")
lights[1][0].setText("1");
else
lights[1][0].setText("0");
up(1,0);
down(1,0);
forward(1,0);
}
else if(action==lights[1][1])
{
if(lights[1][1].getText()=="0")
lights[1][1].setText("1");
else
lights[1][1].setText("0");
up(1,1);
down(1,1);
backward(1,1);
forward(1,1);
}
else if(action==lights[1][2])
{
if(lights[1][2].getText()=="0")
lights[1][2].setText("1");
else
lights[1][2].setText("0");
up(1,2);
down(1,2);
backward(1,2);
}
else if(action==lights[2][0])
{
if(lights[2][0].getText()=="0")
lights[2][0].setText("1");
else
lights[2][0].setText("0");
// edgeToggle(2,0,action);
up(2,0);
forward(2,0);
}
else if(action==lights[2][1])
{
if(lights[2][1].getText()=="0")
lights[2][1].setText("1");
else
lights[2][1].setText("0");
up(2,1);
backward(2,1);
forward(2,1);
}
else if(action==lights[2][2])
{
if(lights[2][2].getText()=="0")
lights[2][2].setText("1");
else
lights[2][2].setText("0");
// edgeToggle(2,2,action);
up(2,2);
backward(2,2);
}
}
public void forward(int a, int b)
{
if("0".equals(lights[a][b+1].getText()))
lights[a][b+1].setText("1");
else
lights[a][b+1].setText("0");
}
public void backward(int a, int b)
{
if("0".equals(lights[a][b-1].getText()))
lights[a][b-1].setText("1");
else
lights[a][b-1].setText("0");
}
public void up(int a, int b)
{
if("0".equals(lights[a-1][b].getText()))
lights[a-1][b].setText("1");
else
lights[a-1][b].setText("0");
}
public void down(int a, int b)
{
if("0".equals(lights[a+1][b].getText()))
lights[a+1][b].setText("1");
else
lights[a+1][b].setText("0");
}
}
```
Guys please I need your feedback on this, as Java is new to me so I need to know more optimal way of resolving this problem.
|
2015/06/06
|
[
"https://Stackoverflow.com/questions/30687413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4982115/"
] |
Why not just use the actual enumeration values in the switch statement
```
public class General {
public enum ProcessPriority { Low = 0, Normal = 1, High = 2 };
ProcessPriority _Priority;
[Category("Settings"), DisplayName("Application Priority")]
public ProcessPriority Priority {
get { return _Priority; }
set {
_Priority = value;
switch (value) {
case ProcessPriority.Low:
Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Idle;
break;
case ProcessPriority.Normal:
Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
break;
case ProcessPriority.High:
Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
break;
}
}
}
}
```
The exception message states that it is not valid to implicitly cast an integer to ProcessPriority. It kind of makes sense, since `ProcessPriority priority = -423` wouldn't make much sense in the context of ProcessPriority. Since you explicitly knew the values, you could have alternatively cast the integer like so
```
case (PriorityClass) 1:
```
or alternatively
```
int priorityVal = (int) value;
switch (priorityVal) {
case 0:
....
}
```
|
1,031,978 |
>
> Evaluate $$\sum\_{n = 1}^{\infty} \frac{2}{2^{n}}$$
>
>
>
This is a geometric series and since $a = \dfrac{1}{2}$ Then the infinite sum is jsut $S = \dfrac{1}{1-\frac{1}{2}} = 2$ Then I multiply by $2$ to get $4$ right? But the actual answer should just be $2$. Am I missing something?
|
2014/11/21
|
[
"https://math.stackexchange.com/questions/1031978",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/101645/"
] |
The first term in $\sum\_{n=1}^{\infty}\frac{1}{2^n} = \frac{1}{2}+\frac{1}{4}+\dots$ is $\frac{1}{2}$, so the sum of the geometric series is $\frac{\frac{1}{2}}{1-\frac{1}{2}} = 1$.
Another way to do it is to absorb the $2$ into the denominator and then change the index from $n$ to $k = n-1$:
$$\sum\_{n=1}^{\infty}\frac{2}{2^n} = \sum\_{n=1}^{\infty}\frac{1}{2^{n-1}} = \sum\_{k=0}^{\infty}\frac{1}{2^{k}} = 1 + \frac{1}{2}+\frac{1}{4}+\dots= \frac{1}{1-\frac{1}{2}} = 2$$
|
627,543 |
Someone can to help me with a hint in the following problem:
>
> Show that for any $a,b,c>0$,
> $$\frac{a + \sqrt{ab} + \sqrt[3]{abc}}{3} \leq \sqrt[3]{a \cdot \frac{a+b}{2} \cdot \frac{a+b+c}{3}}.$$
>
>
>
I have tried using the Hölder inequality, but can not apply it efficiently.
Thanks!
|
2014/01/05
|
[
"https://math.stackexchange.com/questions/627543",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/75645/"
] |
If you plan to write a computer program which returns the value of n!, you will face serious problems if you want the result as an integer since, for eaxmple, in C++ the largest integer value should be 2147483647 which is lower than 13!.
If you want for a result as a real number, you would be able to go further but not so much since 170! is already 7.25742\*10^306.
Very often, it is not a single value of n! which is required but the result of operations such as (m! n! / p!) in which each term can be very large but the result of the operation "rather" small. Then, a way to do it is, when applicable, to compute Log(n!), performs the operations using the logarithms and exponentiate the result. For sure, it will not be exact.
For large value of n, a very good approximation is given by Stirling (more or less extended formulas). Have a look at
<http://en.wikipedia.org/wiki/Stirling%27s_approximation>
|
9,763,543 |
I have an SBT 0.7.5 project and its some test cases fail. Until all test cases are fixed, I want to skip tests to generate a JAR. Is there any command line argument that tells SBT to skip all tests, like Maven's `-Dmaven.test.skip=true` flag?
|
2012/03/19
|
[
"https://Stackoverflow.com/questions/9763543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55808/"
] |
I had the same problem, I'm using the [assembly plugin](https://github.com/sbt/sbt-assembly). In this case, the solution was to modify the build file and add
```
test in assembly := {}
```
|
22,931 |
I am looking to do something like this in KSH:
```
if (( $var = (foo|bar)[0-9]*$ )); then
print "variable matched regex"
fi
```
Is it possible at all?
For the record I'm using Ksh `Version M-11/16/88i` on a Solaris 10 machine.
|
2011/10/19
|
[
"https://unix.stackexchange.com/questions/22931",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/4098/"
] |
Ksh has regular expressions, but not in the usual syntax (not in [the version in Solaris 10](http://download.oracle.com/docs/cd/E19253-01/816-5165/6mbb0m9j0/index.html)).
```
if [[ $var = *@(foo|bar)*([0-9]) ]]; then …
```
In the [manual](http://download.oracle.com/docs/cd/E19253-01/816-5165/6mbb0m9j0/index.html), look under “conditional expressions” for what's inside the brackets and under “file name generation” for the pattern syntax.
|
21,835,465 |
Have a object collection like below
```
UtilityName ="tank1";
Period ="A";
Value=170
UtilityName ="tank1";
Period ="B";
Value=120
UtilityName ="tank2";
Period ="A";
Value=220
UtilityName ="tank2";
Period ="B";
Value=260
UtilityName ="tank3";
Period ="A";
Value=0
UtilityName ="tank3";
Period ="B";
Value=0
UtilityName ="tank4";
Period ="A";
Value=10
UtilityName ="tank4";
Period ="B";
Value=0
```
Need a Linq query where i can group objects by UtilityName and sum by "Value" property
and get only those objects whose summation is greater then Zero.
In the above example, i need collection which includes all object except/ excluding Tank 3 object whose summation of Value is 0;
|
2014/02/17
|
[
"https://Stackoverflow.com/questions/21835465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1583754/"
] |
You can try this:
```
var qry = from obj in list
group obj by obj.UtilityName into g
where g.Sum(x => x.Value) > 0
select new { UtilityName = g.Key, Value = g.Sum(x => x.Value)};
```
|
63,517,212 |
I'm making many API calls to iterate through pages of JSON data. I have this code that works, but I'd like to wrap it in a for loop, and be able to chain them together. Is it possible?
```
const URL = 'https://api.pushshift.io/reddit/search/'
const params = {
q: 'javascript',
size: 10,
subreddit: 'askreddit'
}
let ALL_UTC = []
// Submit First Request....
axios.get(URL + 'comment', {
params
})
.then((response) => {
// Handle First Response
let length = response.data.data.length - 1;
let utc = response.data.data[length].created_utc;
ALL_UTC.push(utc)
params.before = utc
// Make A Second Get Request
axios.get(URL + 'comment', {
params
})
.then((response) => {
let length = response.data.data.length - 1;
let utc = response.data.data[length].created_utc;
ALL_UTC.push(utc)
params.before = utc
// Make A Third Get Request
axios.get(URL + 'comment', {
params
})
.then((response) => {
let length = response.data.data.length - 1;
let utc = response.data.data[length].created_utc;
ALL_UTC.push(utc)
params.before = utc
//Make A Fourth Get Request
axios.get(URL + 'comment', {
params
})
.then((response) => {
let length = response.data.data.length - 1;
let utc = response.data.data[length].created_utc;
ALL_UTC.push(utc)
params.before = utc
console.log(`finished all requests... \n${ALL_UTC}`)
})
})
})
```
The output says the list is populating correctly with new dates:
>
> finished all requests...
> 1597903134,1597841977,1597664521,1597539246
>
>
>
As you can see this is getting old quick. I am new to JavaScript... How do I automate this into a loop?
|
2020/08/21
|
[
"https://Stackoverflow.com/questions/63517212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14128791/"
] |
You have to wrap all your inputs inside `form` tag. then update your CSS accordingly.
Try this,
```html
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<div class="game">
<h1>A</h1>
<div class="b">
<div class="streaming-info">
<form>
<input type="radio" id="h1" name="heart" value="heart">
<input type="radio" id="h3" name="heart" value="heart">
<input type="radio" id="h4" name="heart" value="heart">
<input type="radio" id="h5" name="heart" value="heart">
<input type="radio" id="h6" name="heart" value="heart">
<label for="h1" class="viewers"><i class="fas fa-heart"></i></label>
<label for="h2" class="viewers"><i class="fas fa-heart"></i></label>
<label for="h3" class="viewers"><i class="fas fa-heart"></i></label>
<label for="h4" class="viewers"><i class="fas fa-heart"></i></label>
<label for="h5" class="viewers"><i class="fas fa-heart"></i></label>
</form>
</div>
<div class="btnDiv">
<button class="btn"><a href="#">Reviews</a></button>
<button class="btn"><a href="#">Buy</a></button>
</div>
</div>
</div>
<div class="game">
<h1>B</h1>
<div class="b">
<div class="streaming-info">
<form>
<input type="radio" id="h2" name="heart" value="heart">
<input type="radio" id="h2" name="heart" value="heart">
<input type="radio" id="h2" name="heart" value="heart">
<input type="radio" id="h2" name="heart" value="heart">
<input type="radio" id="h2" name="heart" value="heart">
<label for="h1" class="viewers"><i class="fas fa-heart"></i></label>
<label for="h2" class="viewers"><i class="fas fa-heart"></i></label>
<label for="h3" class="viewers"><i class="fas fa-heart"></i></label>
<label for="h4" class="viewers"><i class="fas fa-heart"></i></label>
<label for="h5" class="viewers"><i class="fas fa-heart"></i></label>
</form>
</div>
<div class="btnDiv">
<button class="btn"><a href="#">Reviews</a></button>
<button class="btn"><a href="#">Buy</a></button>
</div>
</div>
</div>
</body>
</html>
```
Hope this helps you a bit :)
|
17,983,154 |
when I serialize the object in XML file I get Reserved characters mentioned in XML below under element "Jobdesc"
Deserializing of the same xml file with these characters gives me
`Error:-System.InvalidOperationException was unhandled`
Q. What is that I have to do to Deserialize the object...what I am doing wrong???????
XML File
```
<?xml version="1.0"?>
<DataCheck xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<JobList>
<Job>
<JobId>500</JobId>
<JobDate>1/1/2013</JobDate>
<Jobdesc>Test the app </Jobdesc>
</Job>
</JobList>
</DataCheck>
```
Serialize Code in C#
```
XmlSerializer ser = new XmlSerializer(typeof(DataCheck));
using (FileStream objFS = new FileStream(@"C:\\test.xml", FileMode.Create))
{
ser.Serialize(objFS, objDataCheck);
}
```
Deserialize code in C#
DataCheck dc;
```
FileStream fs1 = new FileStream(@"C:\test.xml", FileMode.Open);
XmlSerializer xs = new XmlSerializer(typeof(DataCheck));
dc = (DataCheck)xs.Deserialize(fs1);
```
|
2013/08/01
|
[
"https://Stackoverflow.com/questions/17983154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2640093/"
] |
list.append returns None.
```
a = raw_input('Type anything.\n')
foo = [a]
b = raw_input('Another questions? Y/N\n')
while b != 'N':
b = raw_input('Type and to continue, N for stop\n')
if b == 'N': break
foo.append(b)
```
|
47,512 |
If a *phobia* is to have an irrational fear of something, what is the word for having an irrational affinity for something?
For example a numerologist may fear the number 13, but be attracted to (or even have a love for) the number 8. (Some would say this is irrational.)
|
2011/11/07
|
[
"https://english.stackexchange.com/questions/47512",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/9249/"
] |
As @FumbleFingers points out, the [-phil-](http://en.wikipedia.org/wiki/-phil-) suffixes are the closest opposites you'll find:
>
> Suffixes with the common part *-phil- (-phile, -philia, -philic)* are used to specify some kind of attraction or affinity to something, in particular the love or obsession with something. They are antonymic to suffixes *-phob-*.
>
>
>
However, in many cases, we tend to think of passions as a positive thing, so I'm not sure these are the antonyms you're looking for. For example, if I describe myself as a *technophile*, you might think that I am forward-thinking (and it would be the *technophobe* who might be condemned); if I'm an *oenophile*, I'm merely sophisticated; if I'm a *bibliophile*, just educated.
As an alternative, you might consider the [-mania](http://en.wikipedia.org/wiki/-mania) suffix, which "denotes an obsession with something". This would more closely fit the meaning you're looking for of an irrational attraction.
For example, *bibliophilia* is sometimes contrasted with [*bibliomania*](http://en.wikipedia.org/wiki/Bibliomania), where the former is "the usual love of books" but the latter is
>
> a symptom of obsessive–compulsive disorder which involves the collecting or even hoarding of books to the point where social relations or health are damaged.
>
>
>
|
3,382,174 |
I'm wondering what is the best method to handle AJAX calls with jQuery? Right now I'm doing something like following:
```
$("#test").live('click', function(){
// Process form
$.ajax({
type: "post",
url: "test.php",
success: function(html){
if(html.success == 0) {
alert('Error');
} else {
var obj = $.parseJSON(html.rows);
$("#success").html(obj[0].name);
}
},
dataType:'json'
});
return false;
});
```
In test.php file, I'm checking if request is an AJAX request. If it's an AJAX request I'm running a database query to get some data (this part isn't important in this question, I think):
```
// query goes here
if(mysql_num_rows($query) > 0 ) {
$result['success'] = 1;
$result['data'] = json_encode($data);
} else {
$result['success'] = 0;
}
```
Now I'm wondering if my method is the best possible? FYI I'm using KohanaPHP framework currently, so I want to not break MVC "rules". If I'm doing it wrong, do you have any tips and suggestions how to handle AJAX calls in controllers?
Regards,
Tom
|
2010/08/01
|
[
"https://Stackoverflow.com/questions/3382174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/377895/"
] |
What you have looks good here, though I don't think you need a `$.parseJSON()` there, it should already be an object at that point, this should work:
```
$("#success").html(html.rows[0].name);
```
As a side note, from a readability/maintainability perspective, I'd rename your `html` argument to be `data`, like this:
```
success: function(data) {
```
This is purely preference, but using `html` when it's an HTML type response, and `data` or something else when it's JSON/already an object you're expecting keeps things a bit easier to read for outsiders.
|
42,517,640 |
I am using: jquery.dataTables.js from: <https://datatables.net>
I am trying to drag and drop a column from one table to another.
**EDIT:**
so basically what I want to do is:
* be able to drag and drop the names from table 2 into column called **name** in the table above
* after drag and drop the name the same should disappear from the table 2.
**case 2: if I add a new row** using the button **Add new Row**
* I need be able to drag a drop the names from table 2 into that column **name** too.
so basically I want to do a drag and drop just in the column not in the row.
I don't want create a new row just move the names from 1 table to another.
**EDIT 2:**
**1- Can you drag/drop multiples values from Table #2 to Table #1?**
no, the drag and drop will be possible just 1 by 1.
The drag and drop will be just possible after the user clicks in edit or add a new row.
so I will be able to replace names drom table 2 into the column names table 1
**2- If no, the value dragged shall then replace the value where it is dropped?**
yes
**3- If yes,how should it work? Adding new rows with the other values blank?
no row need be added, we just need replace the column name.**
**how will works:**
so after click in edit or add new row i will be able to drag a name from table 2 into column in
table 1.
**few more resquests:**
if select the row in table 2, this row should be change the color, showing was selected. and in the table 1 column name where this need be dropped need to change the color to show the user can be dropped, after the user drop the color should back to normal.
sample working here:
<http://plnkr.co/edit/6sbmBzbXDzm4p6CjaVK0?p=preview>
```js
$(document).ready(function() {
var dataUrl = 'http://www.json-generator.com/api/json/get/ccTtqmPbkO?indent=2';
var options = [
{ key : 'option 1', value : 1 },
{ key : 'option 2', value : 2 },
{ key : 'option 3', value : 3 }
];
$(document).ready(function() {
var $table = $('#example');
var dataTable = null;
$table.on('mousedown', 'td .fa.fa-minus-square', function(e) {
dataTable.row($(this).closest("tr")).remove().draw();
});
$table.on('mousedown.edit', 'i.fa.fa-pencil-square', function(e) {
enableRowEdit($(this));
});
$table.on('mousedown', 'input', function(e) {
e.stopPropagation();
});
$table.on('mousedown.save', 'i.fa.fa-envelope-o', function(e) {
updateRow($(this), true); // Pass save button to function.
});
$table.on('mousedown', '.select-basic', function(e) {
e.stopPropagation();
});
dataTable = $table.DataTable({
ajax: dataUrl,
rowReorder: {
dataSrc: 'order',
selector: 'tr'
},
columns: [{
data: 'order'
}, {
data: 'name'
}, {
data: 'place'
}, {
data: 'delete'
}]
});
$table.css('border-bottom', 'none')
.after($('<div>').addClass('addRow')
.append($('<button>').attr('id', 'addRow').text('Add New Row')));
// Add row
$('#addRow').click(function() {
var $row = $("#new-row-template").find('tr').clone();
dataTable.row.add($row).draw();
// Toggle edit mode upon creation.
enableRowEdit($table.find('tbody tr:last-child td i.fa.fa-pencil-square'));
});
$('#btn-save').on('click', function() {
updateRows(true); // Update all edited rows
});
$('#btn-cancel').on('click', function() {
updateRows(false); // Revert all edited rows
});
function enableRowEdit($editButton) {
$editButton.removeClass().addClass("fa fa-envelope-o");
var $row = $editButton.closest("tr").off("mousedown");
$row.find("td").not(':first').not(':last').each(function(i, el) {
enableEditText($(this))
});
$row.find('td:first').each(function(i, el) {
enableEditSelect($(this))
});
}
function enableEditText($cell) {
var txt = $cell.text();
$cell.empty().append($('<input>', {
type : 'text',
value : txt
}).data('original-text', txt));
}
function enableEditSelect($cell) {
var txt = $cell.text();
$cell.empty().append($('<select>', {
class : 'select-basic'
}).append(options.map(function(option) {
return $('<option>', {
text : option.key,
value : option.value
})
})).data('original-value', txt));
}
function updateRows(commit) {
$table.find('tbody tr td i.fa.fa-envelope-o').each(function(index, button) {
updateRow($(button), commit);
});
}
function updateRow($saveButton, commit) {
$saveButton.removeClass().addClass('fa fa-pencil-square');
var $row = $saveButton.closest("tr");
$row.find('td').not(':first').not(':last').each(function(i, el) {
var $input = $(this).find('input');
$(this).text(commit ? $input.val() : $input.data('original-text'));
});
$row.find('td:first').each(function(i, el) {
var $input = $(this).find('select');
$(this).text(commit ? $input.val() : $input.data('original-value'));
});
}
});
$(document).ready(function() {
var url = 'http://www.json-generator.com/api/json/get/bXcKDeAbyq?indent=2';
table = $('#example2').DataTable({
ajax: url,
order: [[ 0, "desc" ]],
rowReorder: {
dataSrc: 'place',
selector: 'tr'
},
columns: [ {
data: 'name'
}]
});
});
});
```
```css
div.addRow {
line-height: 45px;
background-color: #fff;
padding-left: 10px;
border-bottom: 1px solid;
border-top: 1px solid #e5e5e5;
}
```
```html
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="//cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
<script src="//cdn.rawgit.com/DataTables/RowReorder/ce6d240e/js/dataTables.rowReorder.js"></script>
<link href="//cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css" rel="stylesheet" />
<link href="//cdn.datatables.net/rowreorder/1.2.0/css/rowReorder.dataTables.min.css" rel="stylesheet"/>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<table id="example" class="display" width="100%" cellspacing="0">
<thead>
<tr>
<th>order</th>
<th>name</th>
<th>country</th>
<th>action</th>
</tr>
</thead>
</table>
<table id="new-row-template" style="display:none">
<tbody>
<tr>
<td>999</td> <!-- Use a large number or row might be inserted in the middle -->
<td>__NAME__</td>
<td>__COUNTRY__</td>
<td>
<i class="fa fa-pencil-square" aria-hidden="true"></i>
<i class="fa fa-minus-square" aria-hidden="true"></i>
</td>
</tr>
</tbody>
</table>
<br>
<div class="pull-right">
<button type="button" id="btn-cancel" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" id="btn-save" class="btn btn-primary" data-dismiss="modal">Save</button>
</div>
<br>
<br>
<h1>
table 2
</h1><br>
<br>
<table id="example2" class="display" width="100%" cellspacing="0">
<thead>
<tr>
<th> name</th>
</tr>
</thead>
</table>
<br>
<br>
<h1>
table 2
</h1><br>
<br>
<table id="example2" class="display" width="100%" cellspacing="0">
<thead>
<tr>
<th> name</th>
</tr>
</thead>
</table>
```
|
2017/02/28
|
[
"https://Stackoverflow.com/questions/42517640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/964836/"
] |
I've already responded to this question here: [How to drag and drop a column into another](https://stackoverflow.com/questions/42496330/how-to-drag-and-drop-a-column-into-another)
Some changes to your code (a global MouseUp event and a MouseDown event for the second table):
```
var rowChache = [];
function mouseUp(event) {
var ctrl = $(document.elementsFromPoint(event.clientX, event.clientY)).filter('input.border-highlight');
if (ctrl.length > 0 && rowCache.length > 0) {
var el = rowCache[0];
var data = el.row.data();
if (data.length > 0) {
ctrl.val(data[0].name);
el.row.remove().draw();
}
}
rowCache = [];
$('#example tr td:nth-child(2) input').removeClass('border-highlight');
}
table.on('mousedown', 'tbody tr', function() {
var $row = $(this);
var r = table.rows(function(i, data) {
return data.name == $row.children().first().text();
});
if (r[0].length > 0) {
$row.parents('table').find('tr').removeClass('highlight');
$row.addClass('highlight');
$('#example tr td:nth-child(2) input').addClass('border-highlight');
}
rowCache.push({
row: r
});
});
```
Check also the link: <http://jsfiddle.net/f7debwj2/47/>
|
36,364,177 |
*Please bear with me, I'm new to stackoverflow so let me attempt to explain my problem, if there are any points that I could improve on in my question making please be sure to comment and I'll edit the question*
Okay, so I've got myself a Linked list, I want to order it by a value in the list which happens to be the price:
```
tmpPtr->item->price;
```
The problem I'm having is switching the positions, here's the code:
```
struct inventory *sort_list() {
struct inventory *tmpPtr = pFirstNode;
struct inventory *temp = NULL;
struct inventory *tmpNxt = pFirstNode->next;
int tmp;
while(tmpNxt != NULL){
while(tmpNxt != tmpPtr){
if(tmpNxt->item->price < tmpPtr->item->price){
// if next item price is smaller than current
// temp for the next item
// heres the problem....
temp = tmpNxt->next;
tmpNxt->next = tmpPtr;
tmpPtr->next = temp;
}
else{
// if not any smaller continue
tmpPtr = tmpPtr->next;
}
}
tmpPtr = pFirstNode;
tmpNxt = tmpNxt->next;
}
return tmpPtr;
}
```
The values aren't ordering as I expected from my logic, any pointers would be great
EDIT:
```
struct inventory *sort_list() {
struct inventory *tmpPtr = pFirstNode;
struct inventory *temp = NULL;
struct inventory *tmpNxt = pFirstNode->next;
while(tmpNxt != NULL){
while(tmpNxt != tmpPtr){
if(tmpNxt->item->price < tmpPtr->item->price){
// if next item price is smaller than current
// temp for the next item
if(tmpPtr == pFirstNode){
tmpPtr = pFirstNode->next; // tmpPtr is now second node
pFirstNode->next = tmpPtr->next;
tmpPtr->next = pFirstNode;
pFirstNode = tmpPtr;
}
tmpNxt = tmpPtr->next;
tmpPtr->next = tmpNxt->next;
tmpNxt->next = tmpPtr;
temp->next = tmpNxt;
}
}
temp = tmpPtr;
}
return tmpPtr; // Place holder
}
```
|
2016/04/01
|
[
"https://Stackoverflow.com/questions/36364177",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6141311/"
] |
The solution is to use the new `TextMetrics` element (requires QtQuick 2.5), and its `tightBoundingRect` property, to get the real `width` & `heigth` of the foreground text:
```
import QtQuick 2.5 // required!
Rectangle {
color: "green"
width: t_metrics.tightBoundingRect.width
height: t_metrics.tightBoundingRect.height
Text {
id: a_text
text: "r"
color: "white"
anchors.centerIn: parent
}
TextMetrics {
id: t_metrics
font: a_text.font
text: a_text.text
}
}
```
|
59,960,407 |
I am trying to make a discord bot send a line from a .txt file, dm it to message author, delete that line from the .txt file, than be able to send the next line the next time the command is run. currently it is sending the same line to a user. any ideas of how to fix this?
```
const vpn = './Database files/VPN.txt';
let vpncodes = fs.readFileSync(vpn).toString();
if (command === "vpn") {
if (message.member.roles.some(r => ["Ӿ-ACCESS!"].includes(r.name))) {
if (!lock) {
if (!vpncodes.length == 0) {
let lines = vpncodes.split('\n');
let user = message.author; //grabbing the user mention
user.send("`here are your accounts: " + lines[0] + "`");
message.channel.send("account info has been sent. check your dm's");
lines.splice(0, 1);
fs.writeFile(vpn, lines.join('\n'), function (err) {
if (err) console.log(err)
});
} else {
return message.reply("This item is out of stock");
}
} else {
return message.reply("this database is currently locked");
}
} else {
return message.reply("you dont have permissions to do this");
}
}
module.exports.help = {
name: 'code'
}
```
|
2020/01/29
|
[
"https://Stackoverflow.com/questions/59960407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12752379/"
] |
```
data.sort(key=lambda x: (-x[0], x[1]))
```
If your key is a tuple, the sorting algorithm will prioritize sorting according to the first element of the tuple, then the second and so on.
|
20,742,569 |
I am using webservice of java.But when i am deploying project on server at that time response returns nothing .But in my android application got null pointer exception how to handle this situation please let me know.
```
protected void onPostExecute(String result) {
super.onPostExecute(result);
JSONArray jArr;
ArrayList<String> firstNameList=new ArrayList<String>();
ArrayList<String> lastNameList=new ArrayList<String>();
ArrayList<String> images=new ArrayList<String>();
ArrayList<String> primayEmailList= new ArrayList<String>();
try {
if(result != null){
jArr = new JSONArray(result);
rowItems = new ArrayList<RowItem>();
if(jArr.length()>0){
for (int count = 0; count < jArr.length(); count++) {
JSONObject obj = jArr.getJSONObject(count);
firstNameList.add(obj.optString("firstName"));
lastNameList.add(obj.optString("lastName"));
if(obj.optString("imageurl").contains("profilesmall.png"))
images.add(null);
else
images.add(obj.optString("imageurl"));
primayEmailList.add(obj.optString("emailid"));
}
}
}
if(firstNameList.size() == 0 && lastNameList.size() == 0) {
firstNameList.add("No");
lastNameList.add("Results");
primayEmailList.add("[email protected]");
images.add("");
}
for (int i = 0; i < firstNameList.size(); i++) {
RowItem item = new RowItem(images.get(i),firstNameList.get(i),lastNameList.get(i),primayEmailList.get(i));
rowItems.add(item);
}
listView = (ListView) findViewById(R.id.list);
CustomListViewAdapter adapter = new CustomListViewAdapter(BdaylistActivity.this, R.layout.list_item, rowItems);
listView.setAdapter(adapter);
listView.setOnItemClickListener(BdaylistActivity.this);
m_ProgressDialog.dismiss();
} catch (JSONException e) {
e.printStackTrace();
}
}
```
|
2013/12/23
|
[
"https://Stackoverflow.com/questions/20742569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
You can check the result string return data or not
```
if(result!= null && !result.isEmpty())
```
then you can do this json parsing.
Thanks
|
46,630,376 |
I want to put a ConstraintLayout programmaticly in another ConstraintLayout. But it does not show up, if I inflate it the way I did before with a RelativeLayout.
Here's the code inner file inner\_area.xml:
```
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/innerArea"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/grade_one"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="0dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
android:background="@drawable/onegreen"
app:layout_constraintBottom_toTopOf="@+id/h1"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/v1"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
tools:layout_conversion_absoluteHeight="20dp"
tools:layout_conversion_absoluteWidth="30dp"
tools:layout_conversion_absoluteX="0dp"
tools:layout_conversion_absoluteY="0dp" />
<ImageView
android:id="@+id/grade_three"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
android:background="@drawable/threelila"
app:layout_constraintBottom_toTopOf="@+id/h2"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/v1"
app:layout_constraintTop_toTopOf="@+id/h1"
app:layout_constraintVertical_bias="0.0"
tools:layout_conversion_absoluteHeight="20dp"
tools:layout_conversion_absoluteWidth="30dp"
tools:layout_conversion_absoluteX="0dp"
tools:layout_conversion_absoluteY="20dp" />
.....
</android.support.constraint.ConstraintLayout>
```
Outer LayoutFile parent.xml:
```
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/parentView"
android:background="@color/primary">
</android.support.constraint.ConstraintLayout>
```
Javacode:
```
ViewGroup parentView = rootView.findViewById(R.id.parentView);
final ConstraintLayout innerArea = (ConstraintLayout) inflater.inflate(R.layout.inner_area, container, false);
parentView.addView(innerArea);
```
But when I change in the inner.xml the layout\_width or layout\_height of the innerArea to wrap\_content or match\_parent, nothing happens. But when I change to 2000dp the inner layout shows up.
What am I doing wrong or missing?
|
2017/10/08
|
[
"https://Stackoverflow.com/questions/46630376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1951951/"
] |
Thanks to Cheticamp for pointing me in the right direction. I was inflating the ConstraintLayout with the root layout and not with the Constraint Layout it is supposed to be in. So the correct Javacode is:
```
parentView = rootView.findViewById(R.id.parentView);
ViewGroup parentView = rootView.findViewById(R.id.parentView);
final ConstraintLayout innerArea = (ConstraintLayout)
inflater.inflate(R.layout.inner_area, parentView, false);
parentView.addView(innerArea);
```
|
31,259,022 |
Currently I am working on a ASP.NET web form project which is using Telerik Ajax Version 2015.2.623.45, I have added **Telerik.Web.UI.dll**, **Telerik.Web.Design.dll** into my project reference, but it keeps giving me errors saying
`The type or namespace name 'Telerik' could not be found in the global namespace (are you missing an assembly reference?)`
Here's some info of my project if that may helps:
I am using .NET Framework 4, using Integrated Mode,
the `dll`'s `Aliases` property is "global", and `Copy Local` property is True
and my `web.config` contains following parts:
```js
<controls>
<add tagPrefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI"/>
</controls>
...
...
<httpHandlers>
<add verb="*" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResourceSession, Telerik.Web.UI" validate="false"/>
<add verb="*" path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler, Telerik.Web.UI" validate="false"/>
<add verb="*" path="Telerik.Web.UI.DialogHandler.axd" type="Telerik.Web.UI.DialogHandler, Telerik.Web.UI" validate="false"/>
<add verb="*" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.Upload.RadUploadProgressHandler, Telerik.Web.UI" validate="false"/>
</httpHandlers>
...
...
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="Telerik.Web.UI.RadTextBox, Telerik.Web.UI, Version=2015.2.623.45, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
<add assembly="Telerik.Web.UI.RadAsyncUpload, Telerik.Web.UI, Version=2015.2.623.45, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
<add assembly="Telerik.Web.UI.RadAjaxManagerProxy, Telerik.Web.UI, Version=2015.2.623.45, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
<add assembly="Telerik.Web.UI.RadCodeBlock, Telerik.Web.UI, Version=2015.2.623.45, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
...
...
</assemblies>
</compilation>
...
...
<handlers>
<remove name="Telerik_Web_UI_WebResource_axd"/>
<remove name="Telerik_Web_UI_SpellCheckHandler_axd"/>
<remove name="Telerik_Web_UI_DialogHandler_aspx"/>
<remove name="Telerik_RadUploadProgressHandler_ashx"/>
<add name="Telerik.Web.UI.WebResource.axd" path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResourceSession, Telerik.Web.UI" preCondition="integratedMode"/>
<add name="Telerik.Web.UI.SpellCheckHandler.axd" path="Telerik.Web.UI.SpellCheckHandler.axd" verb="*" type="Telerik.Web.UI.SpellCheckHandler, Telerik.Web.UI" preCondition="integratedMode"/>
<add name="Telerik.Web.UI.DialogHandler.axd" path="Telerik.Web.UI.DialogHandler.axd" verb="*" type="Telerik.Web.UI.DialogHandler, Telerik.Web.UI" preCondition="integratedMode"/>
<add name="Telerik.RadUploadProgressHandler.ashx" path="Telerik.RadUploadProgressHandler.ashx" verb="*" type="Telerik.Web.UI.Upload.RadUploadProgressHandler, Telerik.Web.UI" preCondition="integratedMode"/>
</handlers>
```
I have Googled a lot and tried all method on Telerik Forum, but it does not help...Can someone help me and tell me what am I missing, and how can I reference `Telerik.*.dll` correctly?
|
2015/07/07
|
[
"https://Stackoverflow.com/questions/31259022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2185825/"
] |
You can try removing the references and adding them again. In the properties of the references, "Copy Local" should be set to true (but I think this is the default). Also, make sure you're adding them to the correct project in your solution! (This tripped me up once.)
Finally, make sure the DLLs you are referencing are built against the same version of the .NET Framework your project is targeting. If they're not, you'll get something like the following warning when building:
`Warning 1576 The primary reference "Telerik.Web.Design, Version=2014.2.724.45, Culture=neutral, PublicKeyToken=121fae78165ba3d4, processorArchitecture=MSIL" could not be resolved because it was built against the ".NETFramework,Version=v4.5" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.0".`
|
29,884,268 |
First I wrote the first sample of code and it didn't work correctly. I prefer the first sample, but only the second one works correctly. I don't know why the first sample doesn't change the original array but second does. Where is the difference?
**First sample:**
```
import heapq
def heap_sort(tab):
heap = []
for i in tab:
heapq.heappush(heap, i)
tab = [heapq.heappop(heap) for _ in xrange(len(heap))]
temp_tab = [4, 3, 5, 1]
heap_sort(temp_tab)
print temp_tab
```
Prints:
```
[4, 3, 5, 1]
```
---
**Second sample:**
```
import heapq
def heap_sort(tab):
heap = []
for i in tab:
heapq.heappush(heap, i)
for i, _ in enumerate(tab):
tab[i] = heapq.heappop(heap)
temp_tab = [4, 3, 5, 1]
heap_sort(temp_tab)
print temp_tab
```
Prints:
```
[1, 3, 4, 5]
```
|
2015/04/26
|
[
"https://Stackoverflow.com/questions/29884268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
You could also use `[:]`, that will change the original object passed in:
```
def heap_sort(tab):
heap = []
for i in tab:
heapq.heappush(heap, i)
tab[:] = [heapq.heappop(heap) for _ in xrange(len(heap))]
```
So instead of reassigning the name `tab` to a new object you are actually updating the original `tab` object.
You could also use a generator expression instead of building the whole list:
```
tab[:] = (heapq.heappop(heap) for _ in xrange(len(heap)))
```
|
39,186,309 |
I know there are a lot of similar question as this one on here but the problem I keep running into is that the method in which those other json file arrays are setup is not the same as mine.
What I am trying to do should just be a simple process but as I am not as versed in json arrays and I am other things, the solution is eluding me completely.
I just want to take the data display in a local json file and create PHP variables for each item returned.
The json file is simple and looks something like this...
```
[
{
"titleOne": "Foo",
"textOne": "Bar",
"titleTwo": "Foo",
"textTwo": "Bar"
}
]
```
It will always consist of just these 4 items. Then I use the following PHP to read and decode the file...
```
$data = file_get_contents ('./data.json');
$json = json_decode($data, true);
foreach ($json as $key => $value) {
foreach ($value as $key => $val) {
echo $key . '====>' . $val . '<br/>';
}
}
```
but this simply outputs the data. I am trying to get each one of these 4 items to become variables. Example...
```
$titleOne
$textOne
$titleTwo
$textTwo
```
...so that the variables can be used in a form.
I have found many similar questions as this but the json data is always setup differently resulting in errors as results.
|
2016/08/27
|
[
"https://Stackoverflow.com/questions/39186309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2284703/"
] |
Why not simply define if it's always only 4:
```
$titleOne = $json[0]['titleOne'];
$textOne = $json[0]['textOne'];
$titleTwo = $json[0]['titleTwo'];
$textTwo = $json[0]['textTwo'];
```
|
28,459 |
I have seen the Gaia project from [here](https://astronomy.stackexchange.com/questions/3668/where-can-i-find-a-catalog-of-all-stars-in-the-milky-way) which is about mapping the *stars* in the Milky Way galaxy. But I'm wondering if there is any open data on the positions (or something like "positions" since it probably not calculable now), or "coordinates", of the *galaxies* in the visible universe, as opposed to the stars. I wonder how animations such as [this](https://www.youtube.com/watch?v=HiN6Ag5-DrU) (a time=1m30s point it shows the galaxies zooming out from the Milky Way) get their data on the positions of the galaxies.
|
2018/11/21
|
[
"https://astronomy.stackexchange.com/questions/28459",
"https://astronomy.stackexchange.com",
"https://astronomy.stackexchange.com/users/7620/"
] |
There are *lots* of galaxy catalogs.
If you're only interested in nearby galaxies, there are things like the [Updated Nearby Galaxy Catalog](https://heasarc.gsfc.nasa.gov/w3browse/all/neargalcat.html); downloadable versions can be found [here](http://cdsarc.u-strasbg.fr/viz-bin/cat/J/AJ/145/101).
A classic all-sky galaxy catalog is the Third Reference Catalogue of Bright Galaxies (RC3, published in the early 1990s), which you can query [here](http://vizier.u-strasbg.fr/viz-bin/VizieR?-source=VII/155); if you follow
the "FTP" links, you can find links to download the actual catalog.
(The HyperLEDA catalog that Dr. Chuck mentioned started as the RC3, but has various
bits of data and re-classifications added more or less continuously since.)
A more recent catalog, based on the near-infrared observations of the 2 Micron All-Sky
Survey (2MASS) is the [2MASS Galaxy Redshift Catalog](http://wise2.ipac.caltech.edu/staff/jarrett/2mass/XSCz/index.html), with about one million galaxies.
Even larger catalogs (though not covering the whole sky) can be found among the data
products of the Sloan Digital Sky Survey, e.g. [here](https://www.sdss.org/dr14/data_access/value-added-catalogs/?vac_id=large-scale-structure-galaxy-catalogs)
Many more catalogs exist, though some do not have accurate redshift information (meaning their distance from us is unknown or uncertain), and many are only for parts of the sky, sometimes very small regions (e.g., catalogs from *Hubble Space Telescope* observations).
(As for that video, I suspect very little is based on real data once you get beyond the Andromeda Galaxy...)
|
48,383,970 |
I want to style a table, giving a blue background color to every second row.
However, I want to ignore a specific row - the second one - from this styling rule.
This means that even though there are 4 rows, I want to treat them as 3 rows, so that row 1 is odd, row 2 doesn't exist, row 3 is even, and row 4 is odd.
I tried using `not` or defining `reg` class for all regular rows, but it didn't help.
My expected result would be to have row 3 in blue color.
Result in fact: row 4 is in blue color.
(The logic for my objective: in my real project, row 2 is not really a "row", I use it to add info related to row 1)
```css
tr td {
vertical-align: top;
}
td {
width: 100px;
height: 100px;
background-color: green;
}
table#aa tr:not(.jack):nth-child(even) td {
background-color: blue;
}
table#bb tr.reg:nth-child(even) td {
background-color: blue;
}
```
```html
<table id="aa">
<tr>
<td></td>
<td></td>
</tr>
<tr class="jack">
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>
<div>another try</div>
<table id="bb">
<tr class="reg">
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr class="reg">
<td></td>
<td></td>
</tr>
<tr class="reg">
<td></td><td></td>
</tr>
</table>
```
**EDIT:**
* I don't necessarily have only 4 rows. I might have 20 in another
example.
* The second row is second in this particular example. but it can
the third or the fourth in another example. The main issue is how to
skip it, without using any "fixed" definitions.
|
2018/01/22
|
[
"https://Stackoverflow.com/questions/48383970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3330034/"
] |
Updated Answer, please check this codepen for a working example:
<https://codepen.io/niorad/pen/dJrqGp>
It's possible with some sibling-trickery.
```
table .out:not(:nth-child(odd)) ~ tr:nth-child(even) td {
background-color: blue;
}
table .out:not(:nth-child(odd)) ~ tr:nth-child(odd) td {
background-color: green;
}
table .out:not(:nth-child(even)) ~ tr:nth-child(even) td {
background-color: blue;
}
table .out:not(:nth-child(even)) ~ tr:nth-child(odd) td {
background-color: green;
}
```
|
15,724,211 |
I have a database in sqlite and I want to use Django to present it and make queries on it.
I know how to create a new database by creating new classes in `models.py`, but what is the best way to use Django to access an **existing** database?
|
2013/03/30
|
[
"https://Stackoverflow.com/questions/15724211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1031417/"
] |
This seems to be a question in two parts: firstly, how can one write django model classes to represent an existing database, and secondly how that interacts with `syncdb`.
The answer to the first of these is that django models are not expressive enough to describe every possible SQL database schema, and instead use a subset that works well with the ORM's usage pattern. Tnerefore you may need to accept some adjustments to your schema in order to describe it with django models. In particular:
* Django does not support composite primary keys. That is, you can't have a primary key that spans multiple columns.
* Django expects tables to be named `appname_modelname`, because this convention allows the tables from many apps to easily co-exist in the same database.
If your schema happens to match the subset that django models support or you are willing to make changes to adapt it to be so then your task is simply to write models that match with the schema. [The `inspectdb` tool](https://docs.djangoproject.com/en/1.5/howto/legacy-databases/) may provide a useful starting point.
You can test if you've been successful in describing your database by temporarily reconfiguring your project to use a different *empty* database and running `manage.py syncdb`, and then comparing the schema that Django created with the schema that already existed. If they are the same (or at least close enough) then you got it right.
If your existing database is *not* a good match for Django ORM's assumptions then a more flexible alternative is [SQLAlchemy](http://www.sqlalchemy.org/). It doesn't natively integrate into django's application system but it does provide a more complete database interface that can work with almost any database; some databases will be easy to map, and some others will require some more manual mapping work, but almost all cases should be possible with some creativity.
As for the interaction with `syncdb`: the default behavior for this command is to skip over any models that already seem to have tables in the database. Therefore if you've defined models that do indeed match with your existing database tables it should leave them alone. It *will*, however, create the additional tables required for other apps in your project, including Django's own tables.
Modern Django has [support for multiple databases](https://docs.djangoproject.com/en/dev/topics/db/multi-db/), which could provide you with a further approach: configure your existing database as a *second* database source in your project and use a *database router* to ensure that the appropriate models are loaded from that second database, and further to ensure that django won't attempt to run `syncdb` on this database. This provides true separation at the expense of some additional complexity, but it still requires that your schema be compatible with the ORM's assumptions. It also has [some limitations](https://docs.djangoproject.com/en/dev/topics/db/multi-db/#limitations-of-multiple-databases), largely pertaining to relationships between objects that are persisted in different databases.
If you'd like to be able to make versioned changes to the database Django uses, starting with the schema you've inherited from the existing database, then [South](http://south.aeracode.org/) provides a more flexible and more complete alternative to the builtin `syncdb` mechanism that supports running arbitrary SQL data definition language statements to make changes to your database schema.
|
9,077 |
When using kosher salt one has to use more kosher salt than table salt to achieve the same level of saltiness. Does it mean that using kosher salt causes one to consume more salt (or sodium)?
|
2010/11/12
|
[
"https://cooking.stackexchange.com/questions/9077",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/2803/"
] |
Kosher salt is the same thing (though I'm pretty sure it's not iodized), but the crystals are less dense and larger. There's more air in each piece, and they don't pack together as tightly. That means you have to put a larger volume of kosher to get the same amount of actual sodium chloride (salt).
Think of it as the difference between ice cubes (regular salt) and snow (kosher). Both are water, but ice cubes are way denser than a scoop of snow. When melting it, you'll need more volume of snow to come out to the same amount of water as you'd get from a few ice cubes.
So no, it's not worse for you.
|
38,959,909 |
My program saves user input as a string (UI), then splits it into an array
`char[] charArray = UI.toCharArray();` After this the program needs to read the first letter in `charArray`, use it for different part of the program, and then proceed to the next letter in the array. The problem is reading the array one letter at a time.
How do you access each character in an array in order?
|
2016/08/15
|
[
"https://Stackoverflow.com/questions/38959909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5645656/"
] |
```
for(int i = 0; i < charArray.length; i++)
{
char UIChar = charArray[i];
// Do something with your character in the string.
}
```
|
52,028 |
Over a month ago, I wanted to do some tax-loss harvesting. I wanted to sell a fund that had dropped in value and replace it with a more generic fund. Right before I sold, the fund paid out dividends which were automatically reinvested. I didn't think it would matter because I was selling my entire position, and from what I've read wash sale basis adjustments only apply when there are replacement shares. It's covered in "#1: Selling All" [here](http://fairmark.com/capgain/wash/wsreplac.htm), for example.
However, when I look at my closed positions or tax info year-to-date at my brokerage online, I see the following:
[](https://i.stack.imgur.com/vSkS6.png)
A key shows the blue w symbol as:
[](https://i.stack.imgur.com/bZPMz.png)
I realize it's only a few bucks, so not a big deal, but I'd prefer it not complicate my taxes and I can't help but wonder, why do I have a wash sale basis adjustment if I sold all shares? This is the entirety of my transactions with this fund and I didn't trade it in any other accounts. It has been over 31 days since the sale to ensure my brokerage wasn't waiting to make sure I didn't buy more within that time period. I contacted customer service but they weren't very helpful; basically it was boilerplate "talk to your tax advisor" stuff.
Note that my question is similar to [My Brokerage statement shows "Adjusted due to previous wash sale disallowed loss" what does this mean?](https://money.stackexchange.com/questions/29687/my-brokerage-statement-shows-adjusted-due-to-previous-wash-sale-disallowed-loss) (even looks like the same brokerage), but I believe my situation is different, because I sold all my shares.
|
2015/08/18
|
[
"https://money.stackexchange.com/questions/52028",
"https://money.stackexchange.com",
"https://money.stackexchange.com/users/9090/"
] |
From what you say, a savings account sounds like the most appropriate option. (Of course you should keep your checking account too to use for day-to-day expenses, but put money that you want to sock away into the savings account.)
The only way to guarantee you won't lose money and also guarantee that you can take the money out whenever you want is to put your money in a checking or savings account. If you put it in a savings account you will at least earn some paltry amount of interest, whereas with a checking account you wont. The amount of interest you earn with only a few hundred (or even a few thousand) dollars will be miniscule, but you know that the nominal value of your money won't go down.
The *real* value of your money will go down, because the interest you're earning will be less than inflation. (That is, if you put $1000 in, you know there will be at least $1000 in there until you take some out. But because of inflation, that $1000 won't buy as much in the future as it does today, so the effective buying power of your money will go down.) However, there's no way to avoid this while keeping your money absolutely safe from loss and maintaining absolute freedom to take it out whenever you want.
To address a couple of the alternatives you mentioned:
* A CD is as safe as a savings account, but you can't take the money out until a certain amount of time has passed.
* A mutual fund carries risk and you may lose money.
* Treasury securities (such as T-bills) can be a reasonable part of an investment portfolio in the long term. They are considered risk-free. However, with the small amount of money you're describing, it probably doesn't make sense to invest in treasuries. You can buy treasuries individually from [TreasuryDirect](https://www.treasurydirect.gov/indiv/products/prod_tbills_glance.htm) but there is a minimum holding period of 45 days; also, you can only buy and sell them in multiples of $100. You could buy a mutual fund that invests exclusively in treasuries, but the fund would charge you a fee. Even if there were no such practical obstacles to investing in treasuries, with only a couple thousand dollars for a few years, the difference in gains between treasuries and just leaving the money in a savings account would be literally pennies. It makes more sense to use a savings account, because it's much more flexible: you can deposit and withdraw any amount you like, any time you like.
It's good that you're thinking about this now. However, you shouldn't worry unduly about "getting the most out of your money" at this stage. As you said, you have $400 and will soon be making $200/week. In other words, two weeks after your job starts, you'll have earned as much as your entire savings before you started the job. Even if all your cash "went down the drain", you'd make it up in two weeks.
Of course, you don't want to throw your money away for nothing. But when your savings are small relative to your income, it's not really worth it to agonize over investment choices to try to get the maximum possible return on your investment. Instead, you should do just what you seem to be doing: prioritize safety, both in terms of keeping your money in a safe account, and try to save rather than spending frivolously. In your current situation, you can double your savings in one month, by working at your part-time job. There's no investment anywhere there that can even come close to that. So don't worry about missing out on some secret opportunity. At this stage, you can earn far more by working than you can by investing, so you should try to build up your savings. When you have enough that you are comfortable with more risk, then you will be in a position to consider other kinds of investments (like stock market index funds), which are riskier but will earn you better returns in the long run.
|
6,975,556 |
I would like to make a page where I can load other pages from different domains into it. Loaded pages should work as they work by themselves.
The reason is adding extra functionality to them.
I have tried to do it with JavaScript and iframes, but I was limited by the Same origin policy. Now I'm thinking about Java Applets/JavaFX/Apache Pivot. I have read that with digital signatures they are able to establish a connection to load a page.
My page should also take some information (title, favicon, etc) from the loaded page.
Am I right looking in this way? Or it's still impossible to do? In other case which technology is a better choice?
P.S. Thanks for your help
|
2011/08/07
|
[
"https://Stackoverflow.com/questions/6975556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/883081/"
] |
You can try to use a proxy that will deliver the content to your domain, and then you can manipulate the pages anyway you want (with iframes or ajax).
Let's say you make a *php* proxy named `proxy.php`:
```
<?php
if(isset($_GET['url']))
echo file_get_contents($_GET['url']);
?>
```
The iframe's src should not be pointed to the external page (`<iframe src="somedomain.com/somepage" />`), but to your proxy that delivers the contents of that page to you : `<iframe src="proxy.php?url=somedomain.com/somepage" />`.
This would be an easy way to manage your task, although you cannot really *copy* other sites this way... you still need to take into consideration cookies, headers and other session related variables.
|
33,421,725 |
I have lots of encrypted config file with extension .crp on my Linux box. The .crp files can be de-crypted via a tool say dec\_crp.
My task is to search if a particular string does not exists in .crp file and list it. Hence as such first I need to de-crypted it - now this tool actually dumps the de-crypted data on standard output console without file name being listed.
```
dec_crp < a.crp
..........
..........
```
Now from the data as printed in standard console I need to verify existence of a string. If the same is not there I need to list that file.
Is there a single line command that acn be used to ahive that?
|
2015/10/29
|
[
"https://Stackoverflow.com/questions/33421725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/304974/"
] |
**Solution 1 : Immediate child selector**
You will have to use the CSS selector `>`. This will target all the **immediate** child elements
Example :
```
.className > element {
}
```
See this below:
```css
.container > div {
height: 40px;
width: 100%;
background-color: orange;
margin:10px;
}
```
```html
<div class="container">
<div></div>
<div></div>
<div></div>
</div>
```
**Solution 2 : Nested children selector**
You can also use it as follows:
```
.className element {
}
```
See this below :
```css
.container div {
background-color: orange;
height: 30px;
width: 100%;
margin: 10px;
}
```
```html
<div class="container">
<div></div>
<div></div>
<div></div>
</div>
```
This is slightly different from the previous selector. The difference is that this will select all `divs` (including the nested children) within the `immediate` `divs`. To understand its effect, see below :
```css
.container div {
background-color: orange;
height: 30px;
width: 100%;
margin: 10px;
}
```
```html
<div class="container">
<div></div>
<div></div>
<div>
<div></div>
<div></div>
<div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>
</div>
```
**Solution 3 : Specific child selector (nth-child)**
In case you want to select only a specific/specific set of **immediate** children, you can use the `nth-child selector` as follows:
```
.className > element:nth-child(n) {
}
```
See this below
```css
.container > div {
background-color: orange;
height: 30px;
width: 100%;
margin: 10px;
}
.container > div:nth-child(3n+1) {
background-color: red;
}
```
```html
<div class="container">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
```
**Solution 4 : Nested Specific child selector (nth-child)**
Lastly, you can combine the aforementioned selectors to target specific children and children of children as well as follows :
```
.className > element:nth-child(n) {
}
```
See this below:
```css
.container div {
background-color: orange;
height: 30px;
width: 100%;
margin: 10px;
}
.container div:nth-child(3n+1) {
background-color: red;
}
```
```html
<div class="container">
<div></div>
<div></div>
<div></div>
<div></div>
<div>
<div></div>
<div></div>
<div></div>
<div></div>
<div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>
</div>
```
Hope this helps!!!
|
15,985 |
I have something strange going on with an output. When the following code is called the LED goes on, but it stays on, there is no blinking. If I comment out the set HIGH statement the LED never comes on (as expected).
```
#define devicePin 10
void setup() {
pinMode(devicePin, OUTPUT);
}
void loop() {
digitalWrite(devicePin, HIGH);
delay(2000);
digitalWrite(devicePin, LOW);
}
```
Could I have damaged the board in some way?
|
2015/09/11
|
[
"https://arduino.stackexchange.com/questions/15985",
"https://arduino.stackexchange.com",
"https://arduino.stackexchange.com/users/13330/"
] |
After you drive the pin low, you immediately go to the beginning of the loop and set the pin high (if you have an oscilloscope, you might see a very short downward pulse).
So, add another delay after `digitalWrite(devicePin, LOW)`.
|
15,730,181 |
I'm trying to validate a user using the $\_SESSION superglobal on PHP but it seems $\_Session does not like me any help is kindly apprecciated, i have the following code called index.php:
```
'<?php
'session_start();
'require("administratorcheck.php");
//i have tried require_once "administratorcheck.php"
'?>
```
where in this case administratorcheck.php looks like this for the validation:
```
<?php
$errorMessage = 'Your Login Information Is Not Correct';
if(isset($_POST['username'])){
$username = $_POST['username'];
$password = $_POST['password'];
$adminUser = "admin";
$adminPass = "donkeyKong";
if(($username!=$adminUser)||($password !=$adminPass))
{
echo $errorMessage;
}else{
// session_register('admin');
$_SESSION['admin'] = $username;
header("index.php");
exit();
}
}
if(isset($_SESSION['admin'])!= 'admin')
{
echo '<h2>You Are Not Authorized To View This File</h2><br/>
<table width = "400" border = "2">
<form action = "administratorcheck.php" method="post" >
<tr>
<td colspan = "2">You May Be Able To Login Here</td>
</tr>
<tr>
<td width="108">Admin Username:</td>
<td width="250"><input type="text" name="username" id="username" style="width:98%"/>
</td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="password" id="password" style="width:98%"/></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="button" id="button"
value="Log Me In"/></td>
</tr>
</form>
</table>
</br>
</br>
<a href = "../">Click Here To Return To The Index Page</a>';
exit();
}
```
?>
|
2013/03/31
|
[
"https://Stackoverflow.com/questions/15730181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2097683/"
] |
Problem
=======
the line below is not doing what you think it is doing.
```
if(isset($_SESSION['admin'])!= 'admin')
```
If you break it down into smaller parts you will see. Looking at the first part you see that you get a boolean back from `isset`
```
$isAdminFieldSet = isset($_SESSION['admin']) // this returns a boolean
```
Now in your if statement you are actually doing
```
if($isAdminFieldSet != 'admin') {
```
which is really
```
if(true != 'admin') {
```
or
```
if (false != 'admin') {
```
Solution
========
yes an admin check
```
if (isset($_SESSION['admin']) && $_SESSION['admin'] == 'admin') {
// user is an admin
...
}
```
not an admin check
```
if (!isset($_SESSION['admin']) || $_SESSION['admin'] != 'admin' ) {
// user is not an admin
...
}
```
|
160,736 |
We are creating a warehouse system. In this system, we will have a Extract page (I don't know if this is the right word to describe it, but it's the same as the log in our bank account, where we have all transactions, with the values and then, subtract it to the total value, it's a bank extract I guess).
We need a table to be like this:
[](https://i.stack.imgur.com/gsh53.png)
The table will have all transactions from fiscal notes (with entries and exits of products). If you notice, you can see the `ID` 1 will appear in position 1, 2, and 4. I did try to use `LAG`, but with the `LAG` function, it's getting the `ID` 3 value.
How can I get the lag value, but with the desired product id? I need the last `total` value of PR\_ID = 1.
I tried this:
```
begin tran
insert into almoxarifado.Movimentacao
(produto_id,documento,data,saldo_anterior,entradas,saidas)
select
Lotes.produto_id as produto_id,
NF.numero as documento,
nf.data_cadastro as data,
>>The lag value would be here, I need this field, to be the last total value,
>>but from this specific product.
Lotes.quantidade as entradas,
0 as saidas
from Almoxarifado.Entradas
join Compras.Notas_Fiscais NF on Entradas.nota_fiscal_id = NF.id
join Compras.Notas_Fiscais_Produtos NFP on NFP.nota_fiscal_id = NF.id
join Almoxarifado.Lotes on Lotes.nota_fiscal_produto_id = NFP.id
where convert(date,NF.data_cadastro) = '2017-01-10'
```
Every row needs to have its own total. Let's say day 2, we had 3 water gallons, it gives me a total of 10. then, day 4 I got 3 gallons, I need the row with the total = 10, and in this new row, the total of 13.
It's like a bank extract, where you see your expenses, and the total on each row. Because, the next step would create a view, that will select this table, by product, so , I can see every total, every entry and product exit during a period of time.
|
2017/01/11
|
[
"https://dba.stackexchange.com/questions/160736",
"https://dba.stackexchange.com",
"https://dba.stackexchange.com/users/56050/"
] |
Let me know if this solve your problem.
I've set up a `[rextester](http://rextester.com/LSVU30166)` example to test it.
I've used this data:
```
create table #mov(produto_id int, documento int, data_cadastro datetime, entradas int, salidas int);
insert into #mov values
(1, 1, '2017-01-01', 10, 0),
(1, 1, '2017-01-02', 10, 2),
(2, 1, '2017-01-01', 10, 0),
(1, 1, '2017-01-03', 10, 0),
(3, 1, '2017-01-02', 10, 0);
```
To get the cumulative sum, apply `SUM() OVER` clause in this way:
```
select
produto_id,
documento,
entradas,
salidas,
sum(entradas-salidas) over (partition by produto_id order by produto_id, data_cadastro
rows between unbounded preceding and current row) as acumulato
from
#mov
```
This is the result:
```
+------------+-----------+----------+---------+-----------+
| produto_id | documento | entradas | salidas | acumulato |
+------------+-----------+----------+---------+-----------+
| 1 | 1 | 10 | 0 | 10 |
+------------+-----------+----------+---------+-----------+
| 1 | 1 | 0 | 2 | 8 |
+------------+-----------+----------+---------+-----------+
| 1 | 1 | 10 | 0 | 18 |
+------------+-----------+----------+---------+-----------+
| 2 | 1 | 12 | 0 | 12 |
+------------+-----------+----------+---------+-----------+
| 3 | 1 | 5 | 0 | 5 |
+------------+-----------+----------+---------+-----------+
```
If you need the last acumulato in the same row, you can use:
```
;with cteSum as
(
select
produto_id,
data_cadastro,
documento,
entradas,
salidas,
sum(entradas-salidas) over (partition by produto_id order by produto_id, data_cadastro
rows between unbounded preceding and current row) as acumulato
from
#mov
)
select produto_id, documento, entradas, salidas, acumulado,
lag(acumulato,1,0) over (partition by produto_id order by produto_id, data_cadastro) as last_acm
from cteSum;
+------------+-----------+----------+---------+-----------+----------+
| produto_id | documento | entradas | salidas | acumulato | last_acm |
+------------+-----------+----------+---------+-----------+----------+
| 1 | 1 | 10 | 0 | 10 | 0 |
+------------+-----------+----------+---------+-----------+----------+
| 1 | 1 | 0 | 2 | 8 | 10 |
+------------+-----------+----------+---------+-----------+----------+
| 1 | 1 | 10 | 0 | 18 | 8 |
+------------+-----------+----------+---------+-----------+----------+
| 2 | 1 | 12 | 0 | 12 | 0 |
+------------+-----------+----------+---------+-----------+----------+
| 3 | 1 | 5 | 0 | 5 | 0 |
+------------+-----------+----------+---------+-----------+----------+
```
|
43,931,624 |
i am getting Cannot read property 'lineWidth' of undefined, when using columnrange chart highcharts, this chart i am trying in reactJS
Below is the sample code
```
import React from 'react';
import Highcharts from 'highcharts';
import ReactHighcharts from 'react-highcharts';
// import ReactHighstock from 'react-highstock';
import HighchartsMore from 'highcharts-more';
import HighchartsExporting from 'highcharts-exporting';
export default class MainChartRange extends React.Component {
componentWillMount(){
this.setState({
type:"column"
})
}
componentDidMount(){
setTimeout(function(e){
HighchartsMore(ReactHighcharts.Highcharts);
HighchartsExporting(ReactHighcharts.Highcharts);
},5000);
}
render() {
HighchartsMore(ReactHighcharts.Highcharts);
HighchartsExporting(ReactHighcharts.Highcharts);
var config = {
chart: {
type: 'columnrange',
inverted: true
},
title: {
text: null
},
subTitle: {
text: null
},
legend: {
enabled: false,
},
plotOptions: {
series: {
pointWidth: 30
}
},
plotOptions: {
series: {
pointWidth: 30
}
},
xAxis: {
categories: ['Woring time'],
title: {
text: null
},
gridLineWidth: 0
},
yAxis: {
type: 'datetime'
},
series: [{
data: [
[1,1483337940000,1483337950000],
[1,1483337970000,1483337990000],
[0,1483338000000,1483338010000],
[0,1483338030000,1483338070000]
]
}]
}
return (
<div className="graph-container">
<ReactHighcharts config={ config } style={{"min-width": "310px", "height": "400px", "margin": "0 auto"}}>
</ReactHighcharts>
</div>
)
}
}
```
this sample code working for the other chart types but it is giving an error for "columnrange"
highcharts.js:299 -> Uncaught TypeError: Cannot read property 'lineWidth' of undefined
Please help me find some work around for the "columnrange"
|
2017/05/12
|
[
"https://Stackoverflow.com/questions/43931624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2098013/"
] |
here is workaround that is got above columnrange to work
in render function add the below code
```
Highcharts.seriesTypes.line.prototype.pointAttribs = function (point, state) {
var seriesMarkerOptions = this.options.marker,
seriesStateOptions,
pointOptions = point && point.options,
pointMarkerOptions = (pointOptions && pointOptions.marker) || {},
pointStateOptions,
strokeWidth = 1,
color = this.color,
pointColorOption = pointOptions && pointOptions.color,
pointColor = point && point.color,
zoneColor,
fill,
stroke,
zone;
if (point && this.zones.length) {
zone = point.getZone();
if (zone && zone.color) {
zoneColor = zone.color;
}
}
color = pointColorOption || zoneColor || pointColor || color;
fill = pointMarkerOptions.fillColor || point.color || color ;
stroke = pointMarkerOptions.lineColor || point.color || color;
/*// Handle hover and select states
if (state) {
seriesStateOptions = seriesMarkerOptions.states[state];
pointStateOptions = (pointMarkerOptions.states && pointMarkerOptions.states[state]) || {};
strokeWidth = pointStateOptions.lineWidth || seriesStateOptions.lineWidth || strokeWidth + seriesStateOptions.lineWidthPlus;
fill = pointStateOptions.fillColor || seriesStateOptions.fillColor || fill;
stroke = pointStateOptions.lineColor || seriesStateOptions.lineColor || stroke;
}*/
return {
'stroke': stroke,
'stroke-width': strokeWidth,
'fill': fill
};
};
HighchartsMore(ReactHighcharts.Highcharts);
HighchartsExporting(ReactHighcharts.Highcharts);
```
|
53,979,429 |
I'm trying to setup WordPress with MySQL on my local Windows 10 machine.
I'm getting this error:
>
> Error establishing a database connection
> This either means that the username and password information in your wp-config.php file is incorrect or we can't contact the database server at localhost:3307. This could mean your host's database server is down.
>
>
>
I already checked here: [Error establishing a database connection on wordpress](https://stackoverflow.com/questions/4302738/error-establishing-a-database-connection-on-wordpress)
1. Are you sure you have the correct username and password?
Yes, I can login to SQL Server Workbench with the `root` credentials, so that is working
2. Are you sure that you have typed the correct hostname?
That's what I'm trying below
3. Are you sure that the database server is running?
Yes, checked in MySQL workbench and it's running
I ran this query `select @@hostname` which gives me: `DESKTOP-CFT2ESY`
I tried adding to wp-config.php (not all at the same time):
`define('DB_HOST', 'localhost:3307');`
`define('DB_HOST', 'localhost:8899');`
`define('DB_HOST', 'localhost');`
`define('DB_HOST', 'DESKTOP-CFT2ESY');`
`define('DB_HOST', '127.0.0.1');`
None of these work, it just changes the hostname string in the above error message.
I then added:
`define('WP_ALLOW_REPAIR', true);`
`define('DB_CHARSET', 'utf8');`
But that does not change the error message at all.
**UPDATE 1**
I ran `SHOW GLOBAL VARIABLES LIKE 'PORT';` and my server runs on port 3306. In WorkBench I see my database is up and running.
I also added all privileges for user `root` on my database schema. My user's `Limit to hosts matching` is set to `localhost`.
**UPDATE 2**
I then ran this PHP code which I found [here](https://stackoverflow.com/questions/2583707/can-i-create-a-database-using-pdo-in-php/6549440#6549440) (I just changed the root user's password to my root user's password):
```
<?php
$host="localhost";
$root="root";
$root_password="rootpass";
$user='newuser';
$pass='newpass';
$db="newdb";
try {
$dbh = new PDO("mysql:host=$host", $root, $root_password);
$dbh->exec("CREATE DATABASE `$db`;
CREATE USER '$user'@'localhost' IDENTIFIED BY '$pass';
GRANT ALL ON `$db`.* TO '$user'@'localhost';
FLUSH PRIVILEGES;")
or die(print_r($dbh->errorInfo(), true));
} catch (PDOException $e) {
die("DB ERROR: ". $e->getMessage());
}
?>
```
But this trows the error:
>
> DB ERROR: SQLSTATE[HY000] [2054] Server sent charset unknown to the client. Please, report to the developers
>
>
>
**UPDATE 3**
I then ran query: `SELECT default_character_set_name FROM information_schema.SCHEMATA S WHERE schema_name = "myDB";` which returns `utf8`, so the same character set as defined in my `wp-config.php`.
**UPDATE 4**
I checked [here](https://stackoverflow.com/questions/3513773/change-mysql-default-character-set-to-utf-8-in-my-cnf). I just had a `mysqlrouter.conf.sample` in my `C:\Program Files\MySQL\MySQL Server 8.0\etc` folder, so I added a `my.cnf` file with:
```
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
```
I restarted the MySQL windows service but the error remains the same.
What else can I try?
|
2018/12/30
|
[
"https://Stackoverflow.com/questions/53979429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/769449/"
] |
As commented by @treyBake please see [here](https://stackoverflow.com/questions/43437490/pdo-construct-server-sent-charset-255-unknown-to-the-client-please-rep).
Basically MySQL 8 changed the default charset to utfmb4 and there are now errors with some clients. I downgraded to MySQL Server 5.6 and the problem is gone.
|
56,270,131 |
I have a data of phone number starts with +63 and 09
for example the user insert 09123456789 then save. The user shouldn't success if he enters +639123456789 because it was same number at all.
I tried using substr\_replace
```
$data3 = substr_replace("+63", "0",0, 3);
```
is there other option? i think the substr\_replace will have error in the future.
thanks
|
2019/05/23
|
[
"https://Stackoverflow.com/questions/56270131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2088008/"
] |
If the `+63` must be at the start, you may use a `preg_replace` like
```
$s = preg_replace('~^\+63~', '0', $s);
```
Here,
* `^` - start of a string position
* `\+` - a literal `+`
* `63` - a `63` substring.
See the [regex demo](https://regex101.com/r/6TZaQX/1) and a [PHP demo](https://3v4l.org/5G2Wm).
Please **also consider** [Tpojka's suggestion](https://stackoverflow.com/questions/56270131/how-to-delete-the-first-digit-number-in-php/56270185#comment99158571_56270131) to use a combination of [intl-tel-input](https://github.com/jackocnr/intl-tel-input) on front-end and [libphonenumber-for-php](https://github.com/giggsey/libphonenumber-for-php) on back-end if you need to sanitize and validate international phone numbers.
|
11,471,158 |
```
def suffix(stng):
list = []
length = len(stng)
for i in range(length):
x = stng[i:length] ## This gives a Memory Error..See below
list.append(x)
return list
```
This piece of code is a part of my solution of a problem on interviewstreet.com but when i submit it i get a Memory error...i want to know how to correct it?
This is the traceback:
```
Original exception was:
Traceback (most recent call last):
File "/run-1342184337-542152202/solution.py", line 35, in
listofsuffix=suffix(var)
File "/run-1342184337-542152202/solution.py", line 13, in suffix
x=stng[i:length]
MemoryError
```
|
2012/07/13
|
[
"https://Stackoverflow.com/questions/11471158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1134517/"
] |
A `MemoryError` means you have consumed all your RAM. You are creating a list containing all trailing parts of an original string. If your original string is too long, you will consume a lot of memory.
One possibility is to use a generator to produce the suffixes one at a time instead of creating a list of all of them:
```
def suffixes(stng):
for i in xrange(len(stng)):
yield stng[i:]
```
If the caller of `suffixes` simply iterates over the result, you don't even have to change the caller. If you truly needed an explicit list, then you'll need a different solution.
|
64,704,593 |
I am using np.savetxt to write a 3d array into a single csv file. the first index stores all 3 columns and all 131 rows. Then I use a loop to append the other indexes to the bottom of the csv, but the last 23 columns are cut off.
spars is the 3d array and each of the spar 1-8 are (131,3) arrays
```
spars = np.array((spar1,spar2,spar3,spar4,spar5,spar6,spar7,spar8))
file_out = 'spars.csv'
np.savetxt(file_out,spars[0],delimiter=',')
for i in range(1,8):
f = open((file_out),'a')
f.write('\n')
np.savetxt(f,spars[i],delimiter=',')
f.close
```
|
2020/11/05
|
[
"https://Stackoverflow.com/questions/64704593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14586134/"
] |
try it with escaping the equal sign:
```
'=
```
[](https://i.stack.imgur.com/eHdyL.png)
[](https://i.stack.imgur.com/PWiOE.png)
|
62,813,812 |
```none
Customer | Add Seq | City | Phone
Test1 | 1 |Delhi | 1231
Test1 | 2 |Noida | 2334
Test2 | 1 |Bengaluru | 3333
Test2 | 2 |Noida | 3333
Test2 | 3 |Chennai | 5565
Test3 | 2 |Chennai | 5565
Test4 | 1 |Noida | 3333
Test4 | 2 |Chennai | 5565
Test5 | 1 |Chennai | 5565
```
Need all customer rows, having both Noida and Chennai address
Expected Result:
```none
Test2 | 2 |Noida | 3333
Test2 | 3 |Chennai | 5565
Test4 | 1 |Noida | 3333
Test4 | 2 |Chennai | 5565
```
|
2020/07/09
|
[
"https://Stackoverflow.com/questions/62813812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7785150/"
] |
A simple method uses `exists`. For just two addresses:
```
select t.*
from t
where t.city in ('Noida', 'Chennai') and
exists (select 1
from t t2
where t2.customer = t.customer and
t2.city in ('Noida', 'Chennai') and
t2.city <> t.city
);
```
|
11,520,621 |
I'm new to prolog and I'm doing some exercises for practice. So I'm trying to get the sum of the given numbers in a list. I'm trying to use this:
```
my_last(X, [X]).
my_last(X, [_|L]) :- my_last(X, L).
```
(from [here](https://sites.google.com/site/prologsite/prolog-problems/1))
as my guide. So this is my code for getting the sum:
```
listsum(X, []).
listsum(X, [H|L]):-
X is H + listsum(X, L).
```
when I compile it, it says
>
> practice.pl:3: evaluable `listsum(_G139,_G140)` does not exist
>
> practice.pl:2: Singleton variables: `[X]`
>
>
>
then when I try `listsum(0, [1,2,3]).` it returns `false`.
I still don't understand much about prolog, and list and recursion in prolog.
|
2012/07/17
|
[
"https://Stackoverflow.com/questions/11520621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1276897/"
] |
Arithmetic
----------
As you already discovered, arithmetic can be handled in Prolog with the `(is)/2` operator. It's because in Prolog, everything is only symbolic calculus: things don't have a meaning by default, so the unification `(=)/2` wouldn't know that `(+)/2` refers to the addition for example.
Now, your problem is that you use a regular predicate inside of `(is)/2` (here it's your recursive call). Since `(is)/2` only performs arithmetic, it doens't evaluate the predicate call. It doesn't even recognize it since it's not an arithmetic function.
The fix here would be to affect the result of the recursive call to a variable and then use it in the `(is)/2` call:
```
listsum(X,[]).
listsum(Result, [Head|Tail]) :-
listsum(SumOfTail, Tail),
Result is Head + SumOfTail.
```
Base case correctness
---------------------
But if you test that code you will not get the desired result. The reason is that you have another problem, in your base case. The sum of the empty list isn't "anything", as you stated by writing
```
listsum(X,[]).
```
(`X` is a free variable, hence can be anything).
Instead, it's `0`:
```
listsum(0, []).
```
The resulting code is:
```
listsum(0, []).
listsum(Result, [Head|Tail]) :-
listsum(SumOfTail, Tail),
Result is Head + SumOfTail.
```
Order of arguments
------------------
Now, as a sidenote, in Prolog a convention is that output variables should be put at the end of the predicate while input variables should be put at the start of the predicate, so to behave as wanted we could refactor as follows:
```
listsum([], 0).
listsum([Head|Tail], Result) :-
listsum(Tail, SumOfTail),
Result is Head + SumOfTail.
```
Tail Call Optimization
----------------------
Now, we can still improve this predicate with more advanced techniques. For example we could introduce tail calls so that Tail Call Optimization (googlable) could be performed, thanks to an idiom of declarative programming called an accumulator:
```
listsum(List, Sum) :-
listsum(List, 0, Sum).
listsum([], Accumulator, Accumulator).
listsum([Head|Tail], Accumulator, Result) :-
NewAccumulator is Accumulator + Head,
listsum(Tail, NewAccumulator, Result).
```
The idea behind that is to update an intermediate result at each step of the recursion (by adding the value of the current head of the list to it) and then just state that when the list is empty this intermediate value is the final value.
Getting more general programs
-----------------------------
As you may have noted in Prolog, quite often predicates can be used in several ways. For example, `length/2` can be used to discover the length of a list:
```
?- length([1, 2, 3], Length).
Length = 3.
```
or to build a skeleton list with free variables of a desired length:
```
?- length(List, 3).
List = [_G519, _G522, _G525].
```
Here though, you might have noted that you can't ask Prolog what are the lists which have a sum that is `6`:
```
?- listsum(L, 6).
ERROR: is/2: Arguments are not sufficiently instantiated
```
That's because, to "go backwards", Prolog would have to solve an equation when comes the call to the `(is)/2` operator. And while yours is simple (only additions), arithmetic isn't solvable this way in the general case.
To overcome that problem, constraint programming can be used. A very nice library is available for SWI, clpfd.
The syntax here would be:
```
:- use_module(library(clpfd)).
listsum(List, Sum) :-
listsum(List, 0, Sum).
listsum([], Accumulator, Accumulator).
listsum([Head|Tail], Accumulator, Result) :-
NewAccumulator #= Accumulator + Head,
listsum(Tail, NewAccumulator, Result).
```
Now we can use our predicate in this other way we wished we could use it:
```
?- listsum(L, 6).
L = [6] ;
L = [_G1598, _G1601],
_G1598+_G1601#=6 ;
L = [_G1712, _G1715, _G1718],
_G1712+_G1715#=_G1728,
_G1728+_G1718#=6 . % Here I interrupted the answer but it would not terminate.
```
We could even ask for all the solutions to the problem:
```
?- listsum(L, X).
L = [],
X = 0 ;
L = [X],
X in inf..sup ;
L = [_G2649, _G2652],
_G2649+_G2652#=X . % Here I interrupted the answer but it would not terminate
```
I just mentionned that so that you realize that quite often the use of `(is)/2` should be avoided and use of constraint programming should be preferred to get the most general programs.
|
20,720,404 |
I am working on windows 7 and I found that "notepad" was set as the default program for opening my .bat files. So when I try to execute the batch file by double clicking, it is opened by notepad.
I have tried setting cmd.exe as the default program, which didn't work.
What is the default program I should set for executing .bat files?
|
2013/12/21
|
[
"https://Stackoverflow.com/questions/20720404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2508038/"
] |
Click on "Start"->"Run" and type in "REGEDT32" and press Enter to start the Registry Editor.
Find the following key:
HKEY\_CURRENT\_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.BAT\UserChoice
and delete the key named "UserChoice".
|
45,401,661 |
In Bootstrap how do I make panels auto-collapse when clicking another one so that only one panel is open at a time? I'm not very good at JavaScript.
Here is some sample code:
```
<div class="footer-widget-panel panel-group" id="accordion1">
<div class="panel panel-default">
<div class="panel-heading"><h4 class="panel-title"><a class="collapsed" data-toggle="collapse" data-parent="#accordion1" href="#infoPanel">Information</a></h4>
</div>
<div id="panell" class="panel-collapse collapse">
<div class="panel-body">
Panel 1
</div>
</div>
</div>
</div>
<div class="footer-widget-panel panel-group" id="accordion2">
<div class="panel panel-default">
<div class="panel-heading"><h4 class="panel-title"><a class="collapsed" data-toggle="collapse" data-parent="#accordion2" href="#infoPanel">Information</a></h4>
</div>
<div id="panel2" class="panel-collapse collapse">
<div class="panel-body">
Panel 2
</div>
</div>
</div>
</div>
<div class="footer-widget-panel panel-group" id="accordion3">
<div class="panel panel-default">
<div class="panel-heading"><h4 class="panel-title"><a class="collapsed" data-toggle="collapse" data-parent="#accordion3" href="#infoPanel">Information</a></h4>
</div>
<div id="panel3" class="panel-collapse collapse">
<div class="panel-body">
Panel 3
</div>
</div>
</div>
</div>
```
|
2017/07/30
|
[
"https://Stackoverflow.com/questions/45401661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8266948/"
] |
I think you got the concept of Bootstrap's accordion wrong: You now have three individual accordions each holding one panel (#accordion1, #accordion2, #accordion3). If you want other panels to collapse when you click on one of them, they should all belong to the same parent accordion (referred to by the data-parent attribute). Also, be sure to use all necessary aria- and data- attributes, and refer to the correct heading / panel child IDs. For example:
```
<div class="footer-widget-panel panel-group" id="accordion1" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingOne">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion1" href="#panel1" aria-expanded="true" aria-controls="panel1">Information</a></h4>
</div>
<div id="panel1" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
Panel 1
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingTwo">
<h4 class="panel-title">
<a class="collapsed" data-toggle="collapse" data-parent="#accordion1" href="#panel2" aria-expanded="false" aria-controls="panel2">Information</a>
</h4>
</div>
<div id="panel2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
<div class="panel-body">
Panel 2
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingThree">
<h4 class="panel-title">
<a class="collapsed" data-toggle="collapse" data-parent="#accordion1" href="#panel3" aria-expanded="false" aria-controls="panel3">Information</a>
</h4>
</div>
<div id="panel3" class="panel-collapse collapse">
<div class="panel-body">
Panel 3
</div>
</div>
</div>
</div>
```
JSFiddle: <https://jsfiddle.net/x2bph14h/>
|
46,352,726 |
Need help to calculate `$work_in_daytime` and `$work_in_nighttime`.
```
$nightStart = '22:00';
$nightEnd = '07:00';
$workers = array(
'0' => array(
'name' => 'Lyons',
'start' => '15:15',
'end' => '23:45'
),
'1' => array(
'name' => 'Santos',
'start' => '10:00',
'end' => '22:00'
),
'2' => array(
'name' => 'Montgomery',
'start' => '22:30',
'end' => '08:00'
)
);
foreach ($workers as $worker) {
$length_of_work = abs(strtotime($worker['start']) - strtotime($worker['end'])) / 3600;
$work_in_daytime = '';
$work_in_nighttime = '';
}
```
Thanks for your help.
|
2017/09/21
|
[
"https://Stackoverflow.com/questions/46352726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/627864/"
] |
No. You need to have the peripheral advertise some custom unique identifier other than the Bluetooth device address.
You can for example have that each device has a unique name or use the service data or manufacturer specific data fields.
|
24,657,207 |
I'm trying to pass a date parameter to a php file so it could insert it into a MySQL table. This is how the date is being transferred:
```
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss%20yyyy-MM-dd");
String currentDateandTime = sdf.format(new Date());
```
And this is the part in the php file that tuches the date:
```
$date = $_GET['dt'];
$dateFirst = substr($date, 0, 8);
$dateSecond = substr($date, 11, 10);
$dateComplete = $dateFirst . ' ' . $dateSecond;
$sql=mysql_query("INSERT INTO User
VALUES (NULL, '$uName', '$pass', '$mail', '$disName', 0, '$dateComplete')");
```
The date field in the table is dateTime. The procedure doesn't fall but the date in the table looks like this: "00:00:00 0000-00-00". Can someone please tell me what am I doing wrong? Thank you in advance!
|
2014/07/09
|
[
"https://Stackoverflow.com/questions/24657207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2839803/"
] |
Switch the order of the concatenation:
```
$dateComplete = $dateSecond . ' ' . $dateFirst;
```
The way it is currently written you will be passing `'11:07:19 2014-07-09'` which is not a date format the MySQL understands.
|
33,524 |
in Arabic calāl جلال [#cll msd.] means :
1. great and majestic
2. greatness
this word derives from Arabic calla " great"- Aramean gēl, galā " mound"
When I saw this Arabic word, I compared it to the word "excellent" in English.
etymology of the word excellent:
ex "out from" (see ex-) + -cellere "rise high, tower," related to celsus "high, lofty, great," from PIE root \*kel- (2) "to be prominent; hill."
From ex- + \*cellō (“to rise”), one lost verb whose participle is celsus, from Proto-Indo-European \*kelH- (“to rise”) (whence collis, columen etc.).
Are the English and Arabic forms related? Is it evidence for Indo-Semitic?
|
2019/09/16
|
[
"https://linguistics.stackexchange.com/questions/33524",
"https://linguistics.stackexchange.com",
"https://linguistics.stackexchange.com/users/26641/"
] |
Arabic جلال (*jalāl*) is a well-established part of the triconsonantal root system, built from the root JLL "greatness, magnitude, height".
"Excellent" meanwhile has cognates all across the Indo-European world (in Italic, Germanic, Hellenic, Balto-Slavic, and possibly others), which all trace back very nicely to a reconstructed root \**k-lH* "to be tall".
So if there was a borrowing or relationship, it happened long, long ago, back before Arabic and English existed, in the distant era of Proto-Semitic and Proto-Indo-European. (Otherwise we wouldn't see it so well-integrated into the descendant languages.)
Is it possible that Proto-Semitic and Proto-Indo-European influenced each other, or one borrowed the word from another, or they both got it from the same source, or they both descend from a common ancestor? Sure! Could this word be evidence for a relationship? Absolutely! Especially since, if I remember right, Arabic *j* descends from Proto-Semitic \**g*, a velar.
**But**, and this is an important "but", it takes a whole lot more than one word to establish a relationship between two languages. Languages have *a lot of words* in them, so the law of large numbers says you're practically guaranteed to find some similar-looking words between any two languages if you look hard enough. And that applies to Proto-Indo-European and Proto-Semitic even *more* than it applies to modern languages, due to the inherent uncertainties in the reconstructions. It's not hard to come up with a dozen coincidental similarities between Swahili and Japanese, or Basque and Nahuatl, or any two languages you pick.
So this could be evidence for "Indo-Semitic", **or** it could be a complete coincidence. And until you have a whole lot more evidence, hundreds of words *at least* with clear phonological (and ideally morphological) correspondences between PIE and PS, the null hypothesis is that the two are unrelated.
|
6,185,390 |
I am trying to call rdl reports remotely in ASP.NET, And i was successful calling report without parameter. But when i pass parameter, reporting i not populating and not giving error. It display noting in report. find my code below. and please do suggest me on the same.
```
MyReportViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
MyReportViewer.ServerReport.ReportServerUrl = new Uri(@"http://gblon9sqm10 /ReportServer_DB10");
MyReportViewer.ServerReport.ReportPath = "/Reports/Report1";
MyReportViewer.ShowParameterPrompts = false;
MyReportViewer.ShowPrintButton = true;
ReportParameter[] rptParameters = new ReportParameter[1];
rptParameters[0] = new ReportParameter();
rptParameters[0].Name = "exposureType";
rptParameters[0].Values.Add("Impressions");
MyReportViewer.ServerReport.SetParameters(rptParameters);
MyReportViewer.ServerReport.Refresh();
```
|
2011/05/31
|
[
"https://Stackoverflow.com/questions/6185390",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/777385/"
] |
It's been a while since I set this up but I remember having to make sure that you didn't setup the report again on postback. This is my code in page\_load:
```
if (!Page.IsPostBack)
{
rptViewer.ServerReport.ReportServerUrl = Settings.ReportServerUrl;
if (rptViewer.ServerReport.ReportServerCredentials == null)
rptViewer.ServerReport.ReportServerCredentials = new ReportServerCredentials();
List<ReportParameter> parameters = new List<ReportParameter>();
parameters.Add(new ReportParameter("TitleLabel", "Title string here"));
//More parameters added here...
rptViewer.ServerReport.SetParameters(parameters);
}
```
|
45,776 |
I'm of the impression that they have the same spawn rules as the rest of the hostile mobs. IE: the place has to be sufficiently dark... and that's about it. (they obvoiusly would have to 'fit' where the game places them as well)
The reason behind the question is I almost always (say 80% of the time) have spiders spawning along the outside of the east wall of my house, and there seems to be no reason or rhyme to it beyond that. Its ALWAYS spiders, the house is equally lit along all sides on the outside and in. I am unable to provide screenshots unfortunately, but to help give you an idea of the terrain, my house is surrounded by a 2 block deep and 2 block wide trench, with a one block wide 'balcony' directly outside my wall. the trench is surrounded by a fence. I'm stumped. The east exterior is exactly the same as the west exterior. there should be no reason for this.
I'm aware that supposedly spiders could spawn outside my territory and 'hop' over the fence and get in, but why always the east side? I have no problems anywhere else. And why is it only spiders? If it was somehow a lighting issue I should be getting mobs of all kinds shouldn't I?
|
2012/01/05
|
[
"https://gaming.stackexchange.com/questions/45776",
"https://gaming.stackexchange.com",
"https://gaming.stackexchange.com/users/15095/"
] |
Only things I can think of:
1) Spiders are the only creature that can climb so the could hop the fence.
2) For some reason you spend the majority if your time on the west side of your house and the area around you that creatures can not spawn in is not reaching the east side of the house as well.
3) All other mobs will vanish in daylight, maybe its the same spiders after they appear once? (If you are not killing them)
4) Trees or a low overhang? Spiders can spawn in 1 height as they just need a 2x2 even floor with 1 block of height, the rest need 2+ blocks but only a 1x1 even floor.
With out being able to see your house these are the best guesses I can come up with.
|
20,179 |
Scenario:
* Monk is marked by Fighter.
* Monk attacks Fighter.
* Monk uses **Flurry of Blows** on a different creature.
Does the Fighter get to use Combat Challenge to attack the Monk?
UPDATE: I found [this thread](https://rpg.stackexchange.com/questions/9494/does-flurry-of-blows-count-as-an-attack) that argues that FoB is an attack. Whether or not that argument is correct, this suggests at least three possible paths of reasoning for this question that I'd like to explore; in particular, the third one:
1. Flurry of Blows is an attack and triggers mark retaliation. (argument: it has a target and deals damage, like post-errata magic missile)
2. Flurry of Blows is not an attack and does not trigger mark retaliation. (argument: it doesn't have an attack roll)
3. **Flurry of Blows is *part of the same attack* and does not trigger mark retaliation.** (argument: it is like hunter's quarry, warlock's curse, or rogue's sneak attack)
|
2013/01/11
|
[
"https://rpg.stackexchange.com/questions/20179",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/3645/"
] |
**Yes**
Per the Rules Compendium, p89-90:
>
> **Power Types:** There are two types of powers.
>
>
> *Attack Powers:* These powers are used to damage or hinder others. ...
>
>
> *Utility Powers:* These powers have a variety of uses. ...
>
>
> A power's type is usually relevant only when a character uses a feat or some other game feature that works with powers of one type or the other. If a power's type isn't stated, the power is an attack power if it includes an attack roll or if it deals damage. Otherwise it is a utility power.
>
>
>
Flurry of Blows does not have a type listed (rather, it's listed as "Monk Feature" which is not a type) and it deals damage, therefore it is an attack.
The one counter-argument I can think of would be to say that Flurry of Blows is not an attack because an attack is a type of power, and Flurry of Blows is not actually a power. There are several class features that are never described as powers in the books (hunter's quarry for example) but that the Character Builder creates power cards for simply because a power card is an easy way to keep track of the ability; despite having power cards, these abilities are not actually powers. This does not apply in the case of Flurry of Blows, however; both variants in PHB3 have power cards in the printed book, and the actual class feature says:
>
> You gain the *(centered / stone fist) flurry of blows* power.
>
>
>
|
1,360,633 |
I since yesterday experienced a very strange problem: my Windows 10 Dell laptop can only open www.google.co.uk (also www.google.com) and Youtube, nothing else. I get a "Connection was reset" error message each time.
I tried flushdns, netsh winsock reset, change DNS to 8.8.8.8 (& 8.8.4.4)... everything I could think of, nothing worked. I tried 2 different browsers: Firefox and Edge, both have the same problem, other devices connecting to the same router wirelessly in the house are all fine.
In the end I had to system restore in safe mode, that worked.
As soon as I performed another Windows update (I think it is KB4464218, 10 version 1803) the problem came back. I had to restore the system back to 4 days ago again.
Has anyone else experienced the same problem? Would anyone know what caused this?
|
2018/09/23
|
[
"https://superuser.com/questions/1360633",
"https://superuser.com",
"https://superuser.com/users/933309/"
] |
If you cannot find these languages under
*PC Settings > Time & Language > Region & language > Languages*,
use regedit to navigate to
`HKEY_USERS\.DEFAULT\Keyboard Layout\Preload`.
You will find there the list of keyboards that are preloaded at boot.
Find the added keyboard layouts by their identifiers from the list of
[Keyboard Identifiers](https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/windows-language-pack-default-values),
and delete them.
Just in case, export this registry entry as backup.
EDIT: A more comprehensive answer can be found
[here](https://superuser.com/a/1340511/8672).
|
52,536 |
I am new in javascript. I want to validating a form with five columns.
FormDescription
My Form Contain 5 input fields and one submit buttom

I want following output
1.Initially submit button disabled.
2.All fields are enter button will be enabled.
or else
1.displaying a alert box.. such as "All fields are must be enter"
Thank You.
|
2012/11/28
|
[
"https://sharepoint.stackexchange.com/questions/52536",
"https://sharepoint.stackexchange.com",
"https://sharepoint.stackexchange.com/users/13241/"
] |
If it is SharePoint List form, you can simply make the fields as Required and SharePoint will handle it...
But if its some other form, which I think it is... you can use JavaScript like this:
```
<script type="text/javascript">
function onSubmitValidation() {
if (TrimAll(document.getElementById("field1").value) == "") {
alert('All fields are must be enter');
return false;
}
if (TrimAll(document.getElementById("field2").value) == "") {
alert('All fields are must be enter');
return false;
}
// check for rest of the fields - field3, field4, field5
return true;
}
function TrimAll(s) {
var l = 0; var r = s.length - 1;
while (l < s.length && s[l] == ' ')
{ l++; }
while (r > l && s[r] == ' ')
{ r -= 1; }
return s.substring(l, r + 1);
}
</script>
```
HTML can look like:
```
Fields <input type="text" id="field1" /><input type="text" id="field2" /><input type="text" id="field3" /><input type="text" id="field4" /><input type="text" id="field5" />
<asp:Button ID="btnSubmit" Text="Submit" OnClientClick="onSubmitValidation" OnClick="btnSubmit_Click" />
```
However if you want to utilize input fields in Server-Side code then replace `<input` with `<asp:TextBox`
Javascript change:
Replace `document.getElementById("field1").value` with `document.getElementById("<%= field1.ClientID %>").value`
HTML change:
Replace `<input type="text" id="field1" />` with `<asp:TextBox ID="field1" runat="server"` />
|
4,034,537 |
I'm trying to differentiate this function using the chain rule, but not sure whether I'm doing it right.
I did the following:
I let $u = (x^2 +2x+3)$ and $y = \cos^4u$,
$\frac{du}{dx} = 2x +2$, $\frac{dy}{du} = -\sin^4u$
$\frac{dy}{dx} = \frac{dy}{du} \times \frac{du}{dx}$ = $-\sin^4 \times 2x+2$ = $(1/7) \times -\sin^4(2x+2)$
|
2021/02/21
|
[
"https://math.stackexchange.com/questions/4034537",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/347842/"
] |
$\frac {d\cos^4 u}{du}\ne -\sin^4 u$.
Let $v(x) = x^4$ then we have
SO if you have $\cos^4 u = v(\cos u)$ then
$\frac {d\cos^4 u}{du} = \frac {d v(\cos u)}{du} = \frac {d v(\cos u)}{d(\cos u)} \frac d{\cos u}{du}=$
$4(\cos u)^3\cdot (-\sin u)=$
$-4\sin u\cos^3 u$.
Doing it via the chain rule is
$[\frac{1}{7}cos^4(x^2+2x+3)]'=$
$\frac 17[4(\cos^3(x^2+2x+3))(-\sin(x^2 + 2x + 3)(2x + 2)]=$
$-\frac 47\cos^3(x^2 + 2x + 3)(\sin(x^2 + 2x+3)(2x + 2)$
.....
If you want to be *really* pendantic
Let $f(x) = x^2 +2x + 3$
Let $g(x) = \cos x$
Let $h(x) = x^4$
Let $i(x) = \frac 17 x$
So we have $[i(h(g(f(x)))]' = i'(h(g(f(x)))\cdot h'(g(f(x)))\cdot g'(f(x))\cdot f'(x)$
$i'(w) = [\frac 17 w]' = \frac 17$.
$h'(w) = [w^4]' = 4w^3$.
$g'(w)= [\cos w]' =-\sin w$
$f'(w) = (w^2 +2w + 3)' = 2w+2$
So $[i(h(g(f(x)))]' = i'(h(g(f(x)))\cdot h'(g(f(x)))\cdot g'(f(x))\cdot f'(x)=$
$\frac 17\cdot (4(g(f(x)))^3) \cdot (-\sin(f(x)) \cdot (2x + 2) =$
$\frac 17 \cdot 4(\cos(x^2 + 2x + 3))^3 \cdot (-\sin(x^2 + 2x + 3))\cdot (2x+2) =$
$-\frac 47 \cos^3(x^2 + 2x + 3)(\sin(x^2 + 2x + 3)(2x+2)$.
Oh... I guess we should factor out the $2$ from $2x + 2$...
$= -\frac 87 \cos^3(x^2 + 2x + 3)(\sin(x^2 + 2x + 3)(x+1)$.
....
And I suppose proving $[i(h(g(f(x)))]' = i'(h(g(f(x)))\cdot h'(g(f(x)))\cdot g'(f(x))\cdot f'(x)$ by multiple applications of the chain rule can be done.
Let $h(g(f(x))) = j(x)$ then $[i(j(x))]' = i'(j(x))j'(x)$.
If $k(x) = g(f(x))$ then $j(x) = k(g(x))$ and $j'(x) = k'(g(x))g'(x)$.
And $k'(x) = g'(f(x))f'(x)$. SO the result follows.
======
But one can drive oneself *NUTS* paying that much attention to detail. The comes a point where sums,constants, and powers should be automatic:
If $h(x) = c\cdot (f(g))^k$
then $h'(x) = ck(f(g(x)))^{k-1}f'(g(x))\cdot g'(x)$,
shouldn't be tooooo difficult a result to accept off the bat.
(which is our case with $c = \frac 17, k = 4, f=\cos; g(x) = x^2 + 2x + 3$.
It *shouldn't* be difficult for a student to follow that
$[\frac 17\cos^4(x^2 + 2x + 3)]'=$
$\frac 17\cdot 4\cos^3(x^2+2x+3)\cdot(-\sin(x^2 + 2x + 3))\cdot (2x +2)$.
|
1,015,549 |
My router has a WAN **PRIVATE** IP address which is assigned via DHCP by my ISP. This is different from my public IP address of course.
In my router settings page I can read it: `10.245.134.71`, and gateway IP is `10.245.122.1`.
How can I get to know this IP (while connected to my router via LAN) without having to open the router settings page?
I am looking for a shell command to show the IP in red.
[](https://i.stack.imgur.com/TntTS.png)
If I perform a tracert it doesn't show:
```
tracert 8.8.8.8
1 4 ms <1 ms 10 ms dsldevice.lan [192.168.1.254] <-- I don't need this one
2 17 ms 17 ms 19 ms 10.245.122.1 <-- the actual gateway
3 22 ms 18 ms 17 ms 10.21.107.254
etc etc
```
---
```
tracert 10.245.134.71
1 1 ms 5 ms 3 ms dsldevice.lan [10.245.134.71] <-- This one! but how to get?
```
---
```
tracert dsldevice.lan
1 1 ms 7 ms <1 ms dsldevice.lan [192.168.1.254]
```
|
2015/12/19
|
[
"https://superuser.com/questions/1015549",
"https://superuser.com",
"https://superuser.com/users/535560/"
] |
Try using a different PDF tool, the built in PDF feature in Word is really nice and usually sufficient, but trying to maintain image quality might be an issue.
You can get a freetrial of NitroPDF (my favorite):
<https://www.gonitro.com/>
Or, PFDcreator is free:
<http://www.pdfforge.org/pdfcreator>
These tools will allows you more options when creating/publishing a PDFs.
|
1,878 |
I've heard [w] and [j] are glides and that glides are not considered to be consonants.
I've also seen voiced labiovelar approximant [w] and palatal approximant [j] on the IPA consonant chart.
What's the latest consensus in the linguistic community on whether [w] and [j] should be classified as consonants?
|
2012/05/05
|
[
"https://linguistics.stackexchange.com/questions/1878",
"https://linguistics.stackexchange.com",
"https://linguistics.stackexchange.com/users/790/"
] |
There is a [sonority hierarchy](http://en.wikipedia.org/wiki/Sonority_hierarchy) of phonemes and phones, in which [w] and [j] are certainly closest to the vowels.
Where exactly in this hierarchy you draw the line between vowels and consonants, or whether you distinguish approximants from consonants, depends on the language you are observing and/or the phenomena you are describing.
|
33,873,081 |
I am figuring out how to build a typescript app where all classes are saved in separate .ts files. I am using VS Code. The compile task seems to be working correctly (.ts files get transpiled to .js files), but when I load my main.js file into my HTML page I get this javascript error:
```
Can't find variable: require
```
My typescript code:
```
// __________ car.ts __________
class Car {
color: string;
constructor(color: string) {
this.color = color;
console.log("created a new " + color + " car");
}
}
export = Car;
// __________ main.ts __________
import Car = require('car');
class Startup {
public static main(): number {
console.log('Hello World');
var c = new Car("red");
return 0;
}
}
```
My tsconfig file:
```
{
"compilerOptions": {
"module": "commonjs",
"sourceMap": true
},
"files": [
"car.ts",
"main.ts"
]
}
```
What step am I missing here? Why does javascript need something called 'require' ? Or is there another way to work with classes in separate files?
|
2015/11/23
|
[
"https://Stackoverflow.com/questions/33873081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1083572/"
] |
`require` function is a [part](https://nodejs.org/api/modules.html#modules_module_require_id) of NodeJS. In order to make `require` work in browsers, you need to install [requirejs](http://requirejs.org/docs/download.html).
If you want to use internal modules, add `outFile` to your `tsconfig.json`:
```
{
"compilerOptions": {
"module": "commonjs",
"sourceMap": true,
"outFile": "app.js"
},
"files": [
"car.ts",
"main.ts"
]
}
```
and add `<script src="app.js"></script>` in your `index.html` file.
|
30,970,417 |
Take this code:
```
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
var i = 0
//let v1 = UIView(frame:CGRectMake(113, 111, 132, 194))
//v1.backgroundColor = UIColor.redColor()
//self.view.addSubview(v1)
for v in self.view.subviews as! [UIView] {
v.removeFromSuperview()
i++
}
println(i)
}
}
```
The for loop removes all subviews from the superview. At the end of the loop, `i` is 2, meaning there were 2 subviews removed. Since I didn't add any myself, what are these subviews?
|
2015/06/21
|
[
"https://Stackoverflow.com/questions/30970417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3711622/"
] |
There are two hidden layers in default UIViewController.
When you print the output of your code you'll find
>
> <\_UILayoutGuide: 0x7f981a513750; frame = (0 0; 0 0); hidden = YES;
> layer = > <\_UILayoutGuide: 0x7f981a5142f0;
> frame = (0 0; 0 0); hidden = YES; layer = >
>
>
>
|
18,204,973 |
How can I list all available handlebar templates with their names in the JavaScript console?
|
2013/08/13
|
[
"https://Stackoverflow.com/questions/18204973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1175166/"
] |
Try using `Ember.keys`:
```
Ember.keys(Ember.TEMPLATES);
```
Hope it helps.
|
8,023,247 |
I have html which contains such text
```
.......
<a class="product_name" href="index.php?productID=29785">Funny</a>
........
<a class="product_name" href="index.php?productID=29787">Very Funny</a>
......
```
I'd like to *href* attribute value and text into link so I'd like to get
```
"index.php?productID=29785", "Funny"
"index.php?productID=29787", "Very Funny"
```
And I use
```
MatchCollection mc = Regex.Matches(pageData,
"<a class=\"product_name\" href=\"(.+)\">(.+)</a>");
```
For this. But when I debug code I saw that mc.Count = 0
I think I didn't escaped quotes properly, but I don't know.
|
2011/11/05
|
[
"https://Stackoverflow.com/questions/8023247",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/418251/"
] |
Don't parse HTML with regex. See [here](https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454) for a compelling reason why.
Use the [HTML Agility Pack](http://html-agility-pack.net/?z=codeplex) instead.
|
44,335,915 |
I found a post in here that said basically the same thing I'm asking, but it says to "avoid asking for help or clarification", so I'm starting a new post.
I have a server side CSS being generated on a thank you page after an online order submission - it looks like this:
>
> [](https://i.stack.imgur.com/nNUi7.jpg)
>
>
>
I would like to hide the text logo - top left - "textLogo1" and then I'd like to hide the "continue shopping" link there in the middle.
I can do this in firebug by adding it to the class, but I'm unable to find the class anywhere.
This is for a site using Big Commerce and I'd like to know:
1. How do you write such a jQuery request?
2. Where would I put said request once written? (header.php I'm assuming)
May I use something like this?
```
document.getElementById('item').className = '';
```
**Some of the code I have so far:**
```html
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<title>Thanks for Your Order</title>
<meta charset="UTF-8">
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name='robots' content='noindex, nofollow' />
<link href="//fonts.googleapis.com/css?family=Lato:400,300" rel="stylesheet" type="text/css">
<link rel="shortcut icon" href="https://cdn3.bigcommerce.com/s-4xqa0tnsba/product_images/android-icon-48x48.png?t=1496184441" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<script>
//<![CDATA[
(function() {
// this happens before external dependencies (and dom ready) to reduce page flicker
var node, i;
for (i = window.document.childNodes.length; i--;) {
node = window.document.childNodes[i];
if (node.nodeName == 'HTML') {
node.className += ' javascript';
}
}
})();
//]]>
</script>
<link href="https://cdn4.bigcommerce.com/r-b894c2cb799bac74ce4990fade5989902a6e1a9d/themes/__master/Styles/styles.css" type="text/css" rel="stylesheet" />
<link href="https://cdn4.bigcommerce.com/r-b894c2cb799bac74ce4990fade5989902a6e1a9d/themes/Stencil/Styles/iselector.css" media="all" type="text/css" rel="stylesheet" />
<link href="https://cdn4.bigcommerce.com/r-b894c2cb799bac74ce4990fade5989902a6e1a9d/themes/Stencil/Styles/flexslider.css" media="all" type="text/css" rel="stylesheet" />
<link href="https://cdn4.bigcommerce.com/r-b894c2cb799bac74ce4990fade5989902a6e1a9d/themes/Stencil/Styles/slide-show.css" media="all" type="text/css" rel="stylesheet" />
<link href="https://cdn4.bigcommerce.com/r-b894c2cb799bac74ce4990fade5989902a6e1a9d/themes/Stencil/Styles/styles-slide-show.css" media="all" type="text/css" rel="stylesheet" />
<link href="https://cdn4.bigcommerce.com/r-b894c2cb799bac74ce4990fade5989902a6e1a9d/themes/Stencil/Styles/social.css" media="all" type="text/css" rel="stylesheet" />
<link href="https://cdn4.bigcommerce.com/r-b894c2cb799bac74ce4990fade5989902a6e1a9d/themes/Stencil/Styles/styles.css" media="all" type="text/css" rel="stylesheet" />
<link href="https://cdn4.bigcommerce.com/r-b894c2cb799bac74ce4990fade5989902a6e1a9d/themes/Stencil/Styles/light.css" media="all" type="text/css" rel="stylesheet" />
<link href="https://cdn4.bigcommerce.com/r-b894c2cb799bac74ce4990fade5989902a6e1a9d/themes/Stencil/Styles/theme.css" media="all" type="text/css" rel="stylesheet" />
<link href="https://cdn4.bigcommerce.com/r-b894c2cb799bac74ce4990fade5989902a6e1a9d/themes/Stencil/Styles/grid.css" media="all" type="text/css" rel="stylesheet" />
<link href="https://cdn4.bigcommerce.com/r-b894c2cb799bac74ce4990fade5989902a6e1a9d/themes/Stencil/Styles/responsive.css" media="all" type="text/css" rel="stylesheet" />
<link href="https://cdn4.bigcommerce.com/r-b894c2cb799bac74ce4990fade5989902a6e1a9d/themes/Stencil/Styles/font-awesome.css" media="all" type="text/css" rel="stylesheet" />
<link href="https://cdn4.bigcommerce.com/r-c6bdea2696c2b390db90de13e6bd8dc31e0f984a/javascript/superfish/css/store.css" type="text/css" rel="stylesheet" />
<link type="text/css" rel="stylesheet" href="https://cdn4.bigcommerce.com/r-c6bdea2696c2b390db90de13e6bd8dc31e0f984a/javascript/jquery/plugins/imodal/imodal.css?87ceb" />
<link href="https://cdn3.bigcommerce.com/s-4xqa0tnsba/stencil/39a119c0-217f-0135-4282-525400dfdca6/css/checkout-7a034520-27e5-0135-ba7c-525400970412.css" type="text/css" rel="stylesheet">
<!-- Tell the browsers about our RSS feeds -->
<!-- Include visitor tracking code (if any) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="https://cdn3.bigcommerce.com/r-c6bdea2696c2b390db90de13e6bd8dc31e0f984a/javascript/menudrop.js?"></script>
<script src="https://cdn3.bigcommerce.com/r-c6bdea2696c2b390db90de13e6bd8dc31e0f984a/javascript/viewport.js?"></script>
<!-- Theme bespoke js -->
<script src="https://cdn3.bigcommerce.com/r-b894c2cb799bac74ce4990fade5989902a6e1a9d/themes/Stencil/js/common.js"></script>
<script src="https://cdn3.bigcommerce.com/r-b894c2cb799bac74ce4990fade5989902a6e1a9d/themes/Stencil/js/jquery.autobox.js"></script>
<script src="https://cdn3.bigcommerce.com/r-b894c2cb799bac74ce4990fade5989902a6e1a9d/themes/Stencil/js/init.js"></script>
<script src="https://cdn3.bigcommerce.com/r-b894c2cb799bac74ce4990fade5989902a6e1a9d/themes/Stencil/js/jquery.uniform.min.js"></script>
<script src="https://cdn3.bigcommerce.com/r-b894c2cb799bac74ce4990fade5989902a6e1a9d/themes/Stencil/js/main.js?"></script>
<script>
//<![CDATA[
config.ShopPath = 'https://store-4xqa0tnsba.mybigcommerce.com';
config.Email = '';
config.AppPath = ''; // BIG-8939: Deprecated, do not use.
config.FastCart = 1;
config.ShowCookieWarning = !!0;
var ThumbImageWidth = 190;
var ThumbImageHeight = 285;
//]]>
</script>
<script type="text/javascript">
function beacon_deferred(beacon_api) {
beacon_api.order.success('', 2993220, {
"order": {
"num": "52611501"
},
"customer": {
"id": 3
}
});
beacon_api.set_cookie_domain(".store-4xqa0tnsba.mybigcommerce.com");
beacon_api.pageview('', 2993220, "order_success", {
"order": {
"num": "52611501"
},
"customer": {
"id": 3
}
}, 'dfc98ec4-0f99-4e85-8686-0badb06c9a76', 'f1de836e-72f9-4f25-b331-6b83ca33785f');
}
(function() {
var d = document,
g = d.createElement('script'),
s = d.getElementsByTagName('script')[0];
g.type = 'text/javascript';
g.defer = g.async = true;
g.src = 'https://cdn4.bigcommerce.com/r-c6bdea2696c2b390db90de13e6bd8dc31e0f984a/javascript/jirafe/beacon_api.js';
s.parentNode.insertBefore(g, s);
})();
</script>
<script type="text/javascript" src="https://cdn4.bigcommerce.com/r-c6bdea2696c2b390db90de13e6bd8dc31e0f984a/javascript/jquery/plugins/jquery.form.js?87ceb"></script>
<script type="text/javascript" src="https://cdn4.bigcommerce.com/r-c6bdea2696c2b390db90de13e6bd8dc31e0f984a/javascript/jquery/plugins/imodal/imodal.js?87ceb"></script>
<script type="text/javascript">
(function() {
window.bcanalytics || (window.bcanalytics = []), window.bcanalytics.methods = ["debug", "identify", "track",
"trackLink", "trackForm", "trackClick", "trackSubmit", "page", "pageview", "ab", "alias", "ready", "group",
"on", "once", "off", "initialize"
], window.bcanalytics.factory = function(a) {
return function() {
var b = Array.prototype.slice.call(arguments);
return b.unshift(a), window.bcanalytics.push(b),
window.bcanalytics
}
};
for (var i = 0; i < window.bcanalytics.methods.length; i++) {
var method = window.bcanalytics.methods[i];
window.bcanalytics[method] = window.bcanalytics.factory(method)
}
window.bcanalytics.load = function() {
var a = document.createElement("script");
a.type = "text/javascript",
a.async = !0, a.src = "https://cdn4.bigcommerce.com/r-c6bdea2696c2b390db90de13e6bd8dc31e0f984a/app/assets/js/vendor/bigcommerce/analytics.min.js";
var b = document.getElementsByTagName("script")[0];
b.parentNode.insertBefore(a, b)
}, window.bcanalytics.SNIPPET_VERSION = "2.0.8", window.bcanalytics.load();
bcanalytics.initialize({
"Fornax": {
"host": "https:\/\/analytics.bigcommerce.com",
"cdn": "https:\/\/cdn4.bigcommerce.com\/r-c6bdea2696c2b390db90de13e6bd8dc31e0f984a\/app\/assets\/js\/vendor\/bigcommerce\/fornax.min.js",
"defaultEventProperties": {
"storeId": 999441665,
"experiments": {
"PROJECT-174.channel_twitter": "control",
"PROJECT-331.pos_manager": "on",
"PROJECT-632.square_export": "on",
"PROJECT-756.channel_pinterest": "on",
"PROJECT-756.pinterest_material_options": "control",
"PROJECT-783.channel_facebook": "on",
"PROJECT-783.channel_facebook.disconnect": "on",
"PROJECT-1245.amazon-payments.registration.eu": "on",
"PROJECT-1245.amazon-payments.registration.us": "on",
"PROJECT-1493.custom_order_status_labels": "control",
"OMNI-1010.channel_amazon.coming_soon": "on",
"OMNI-913.channel_amazon": "on",
"OMNI-2917.channel_buy_buttons": "on",
"OMNI-2918.google_shopping": "control",
"OMNI-1010.channel_ebay.coming_soon": "control",
"OMNI-764.channel_ebay": "on",
"OMNI-3167.channel_instagram.coming_soon": "on",
"OMNI-900.channel_amazon.amazon_variants": "control",
"OMNI-799.facebook_checkout": "on",
"OMNI-2943.channel_facebook.refactor": "control",
"OMNI-2999.products.cdn": "on",
"OMNI-3354.omnichannel.cdn": "on",
"BIG-29859.facebook_messenger_integration": "control",
"CP-78.cp_click_tracking": "control",
"PROJECT-1082.promote_ppec": "on",
"BIG-28672.shipstation": "on",
"PROJECT-871.dashboard_redesign": "on",
"PROJECT-974.order_notification": "on",
"ng-products": "control",
"ng-add-edit-products": "control",
"API-417.enable_api_oauth_account_creation": "on",
"CRO-5.new_product_listing": "off",
"CRO-16.left_align_buttons": "on",
"CRO-8.getting-started-content-test": "on",
"CRO-63.separate-design-options": "off",
"PROJECT-1441.dashboard.store_performance_channels": "on",
"PROJECT-1413.PinterestProductListings": "control",
"CRO-83.create_test_order_onboarding_card": "control",
"CP-860.switch_stores": "on",
"PROJECT-1413.PinterestChannelServiceAuth": "control",
"CRO-46.upload-logo-design": "control",
"CP-1284.search-ui": "control",
"PROJECT-1522.google_customer_reviews": "control",
"PROJECT-976.braintree.visa.checkout": "control",
"CP-1252.self_help.phase2": "control",
"DATA-2896.ng-analytics.enable": "control"
}
},
"defaultContext": {
"source": "Bigcommerce Storefront"
},
"anonymousId": "f1de836e-72f9-4f25-b331-6b83ca33785f"
}
});
})();
var BCData = {};
</script>
<script type="text/javascript" src="https://cdn4.bigcommerce.com/r-c6bdea2696c2b390db90de13e6bd8dc31e0f984a/javascript/quicksearch.js"></script>
<!--[if lt IE 9]>
<script src="https://cdn3.bigcommerce.com/r-b894c2cb799bac74ce4990fade5989902a6e1a9d/themes/Stencil/js/html5shiv.js"></script>
<![endif]-->
</head>
<script type="text/javascript" src="https://cdn3.bigcommerce.com/r-c6bdea2696c2b390db90de13e6bd8dc31e0f984a/javascript/jquery/plugins/jCarousel/jCarousel.js?"></script>
<body>
<div id="DrawerMenu">
<div class="inner">
<div class="CategoryList" id="SideCategoryList">
<h3>Categories</h3>
<div class="BlockContent">
<div class="SideCategoryListFlyout">
<ul class="sf-menu sf-horizontal">
<li><a href="http://shop.modassystems.com/tomball-top/">Tomball</a>
<ul>
<li><a href="http://shop.modassystems.com/program/tomball/devices/">Devices</a>
<ul>
<li><a href="http://shop.modassystems.com/program/tomball/devices/android/">Android</a></li>
<li><a href="http://shop.modassystems.com/program/tomball/devices/iphones/">iPhones</a></li>
<li><a href="http://shop.modassystems.com/program/tomball/devices/basic-phones/">Basic Phones</a></li>
<li><a href="http://shop.modassystems.com/program/tomball/devices/tablets/">Tablets</a></li>
<li><a href="http://shop.modassystems.com/program/tomball/devices/mifi/">MiFi</a></li>
</ul>
</li>
<li><a href="http://shop.modassystems.com/tomball/equipment-protection/">Equipment Protection</a></li>
</ul>
</li>
<li><a href="http://shop.modassystems.com/education/">Education</a>
<ul>
<li><a href="http://shop.modassystems.com/education/tomballisdtx/">Tomball ISD</a>
<ul>
<li><a href="http://shop.modassystems.com/education/tomball-isd/devices/">Devices</a>
<ul>
<li><a href="http://shop.modassystems.com/mgdpmtplt/tomball-isd/devices/iphones/">iPhones</a></li>
<li><a href="http://shop.modassystems.com/hidden/education/tomball-isd/devices/basic-phones/">Basic Phones</a></li>
<li><a href="http://shop.modassystems.com/mgdpmtplt/tomball-isd/devices/android/">Android</a></li>
<li><a href="http://shop.modassystems.com/hidden/education/tomball-isd/devices/mifi/">MiFi</a></li>
</ul>
</li>
<li><a href="http://shop.modassystems.com/education/tomball-isd/equipment-protection/">Equipment Protection</a></li>
<li><a href="http://shop.modassystems.com/tisdtxbyod/">BYOD</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="http://shop.modassystems.com/kippdc/">KIPP DC</a>
<ul>
<li><a href="http://shop.modassystems.com/modas-mobile-technology-programs/kipp-dc/phones/">Phones</a>
<ul>
<li><a href="http://shop.modassystems.com/kipp-dc/phones/ios/">iOS</a></li>
<li><a href="http://shop.modassystems.com/kipp-dc/phones/android/">Android</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<div class="Block Moveable Panel" id="SideShopByBrand" style="display:none;"></div>
<div class="Block Moveable Panel" id="SideCategoryShopByPrice" style="display:none;"></div>
<div class="AdditionalInformationList Moveable Panel slist" id="SideAdditionalInformation">
<h3>Additional Information</h3>
<div class="BlockContent">
<ul class="treeview">
<li><a href="/">Home</a></li>
</ul>
<ul class="pages-menu sf-menu sf-horizontal sf-js-enabled">
<li class=" ">
<a href="http://shop.modassystems.com/about-us/"><span>About Us</span></a>
</li>
<li class=" ">
<a href="http://shop.modassystems.com/contact-us/"><span>Contact Us</span></a>
</li>
</ul>
</div>
</div>
<div class="AccountNavigationList Moveable Panel slist" id="SideAccountNavigation">
<h3>Site Information</h3>
<div class="BlockContent js-side-account-menu">
<!-- Fill with content from TopMenu -->
</div>
</div>
<script>
(function($, window) {
'use strict';
var bcTheme = window.bcTheme || {};
bcTheme.mobile = bcTheme.mobile || {};
var MobileAccountMenu = function MobileAccountMenu() {};
MobileAccountMenu.prototype.init = function init(selector) {
this.$element = $(selector);
this.cloneTopMenu();
this.setCurrencyConvertor();
this.bindEvents();
};
MobileAccountMenu.prototype.cloneTopMenu = function cloneTopMenu() {
// Cloning from top menu as Globals don't work down here.
var $topMenuClone = $('.TopMenu ul').clone(),
$phoneNumber = $('<a />', {
'text': $('.js-drawermenu-store-phone-container').find('.phoneIcon').text(),
'href': 'tel:' + $('.js-drawermenu-store-phone-container').find('.js-drawermenu-store-phone').text()
});
//Modify the cloned menu to make phone clickable and hide stuff we don't need
$topMenuClone.find('.phoneIcon').replaceWith($phoneNumber);
$topMenuClone.find('.js-drawermenu-cart').remove();
//append new menu to drawer
this.$element.append($topMenuClone);
};
MobileAccountMenu.prototype.setCurrencyConvertor = function setCurrencyConvertor() {
this.$mobileCurrencyConverter = this.$element.find('.js-drawermenu-currency-converter');
this.$mobileSelectedCurrency = this.$mobileCurrencyConverter.find('.selected-currency');
this.$mobileCurrencyList = this.$mobileCurrencyConverter.find('.CurrencyList');
};
MobileAccountMenu.prototype.bindEvents = function bindEvents() {
var that = this;
this.$mobileSelectedCurrency.on('click', function(e) {
e.preventDefault();
that.$mobileSelectedCurrency.toggleClass('open');
that.$mobileCurrencyList.toggleClass('open');
});
};
bcTheme.mobile.accountMenu = new MobileAccountMenu();
window.bcTheme = window.bcTheme || bcTheme;
}(jQuery, window));
$(function() {
bcTheme.mobile.accountMenu.init('.js-side-account-menu');
});
</script>
</div>
</div>
<script>
//<![CDATA[
$(function() {
//Drawer Subnavigation Accordion
$('#DrawerMenu li ul').addClass('drawer-subcat');
$('#DrawerMenu .drawer-subcat').prev('a').after('<span class="subcat-expand"></span>');
$('#DrawerMenu .subcat-expand').click(function() {
$(this).next('.drawer-subcat').toggleClass('expanded');
$(this).toggleClass('subcat-expanded');
});
});
//]]>
</script>
<div class="page">
<div class="header">
<div class="inner">
<div id="AjaxLoading">
<div class="ajax-loader">
<img src="https://cdn3.bigcommerce.com/r-b894c2cb799bac74ce4990fade5989902a6e1a9d/themes/Stencil/images/loader.png" alt="" /> Loading... Please wait...
</div>
</div>
<div id="Header">
<div class="inner">
<div class="header-logo">
<div id="LogoContainer">
<h1><a href="http://shop.modassystems.com/"><span class="Logo1stWord">Modas</span> Systems</a></h1>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="main">
<div class="inner">
<div class="checkout-banner">
<a href="https://store-4xqa0tnsba.mybigcommerce.com">Continue shopping on Modas Systems</a>
</div>
<div class="Content ExpressCheckoutBlock" id="LayoutColumn2">
<div class="Block">
<h1 class="TitleHeading">Thanks for Your Order, john!</h1>
```
|
2017/06/02
|
[
"https://Stackoverflow.com/questions/44335915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5573647/"
] |
Just use a simple `$('.classname').hide();`, like Matthew Broderick suggested.
In my example, I've set the function to be called on a button press, but you can change that.
```js
function removeLines() {
$('#line1, #line2').hide();
}
```
```css
.container {
height: 200px;
background-color: blue;
}
#line1 {
background-color: red;
}
#line2 {
background-color: yellow;
}
#line3 {
background-color: green;
}
```
```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div id="line1">Line 1</div>
<div id="line2">Line 2</div>
<div id="line3">Line 3</div>
<button onclick="removeLines()">Click me to remove lines 1 and 2</button>
</div>
```
|
40,196,089 |
Please go through this edited table.
[](https://i.stack.imgur.com/gFReZ.png)
You can assume order\_header\_key as order no.
I want to get the list of order nos whose current status is 3 and previous status was 2, and the status date(status3)-status date(2) <=3 days for that order
in the following table
for order no-1 'date(status 3)' - 'date(status 2) = 20 OCT - 19 OCT
which is less than 3 days--> So valid order
but for order no 3 'date(status 3)' - 'date(status 2)' = 30 OCT - 24 OCT
which is more than 3 days so invalid order
order no 2 in invalid since the statuses are 3 and 1 , 2 is missing
|
2016/10/22
|
[
"https://Stackoverflow.com/questions/40196089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7058224/"
] |
Assuming an order can't have more than one entry per order\_no/status combination, you could join two subqueries:
```
SELECT s3.order_no
FROM (SELECT *
FROM orders
WHERE status = 3) s3
JOIN (SELECT *
FROM orders
WHERE status = 2) s2 ON s3.order_no = s2.order_no AND
s3.status_date - s3.status_date <= 3
```
|
177,444 |
I've always wondered how much force water exerted through surface tension. By maximum I mean the theoretical pulling/attracting power.
**Also, what would happen if you raised or lowered the power? Would it affect life? And how much would you have to raise it in order to get a drop of water 1 ft. in height?**
*Thanks guys!*
|
2015/04/20
|
[
"https://physics.stackexchange.com/questions/177444",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/77786/"
] |
Okay, I have a few guesses on what you are trying to say.
>
> I've always wondered how much force water exerted through surface
> tension. By maximum I mean the theoretical pulling/attracting power.
>
>
>
If you mean to ask about a water-water interaction similar to that of a magnet-magnet interaction, then surface tension of water has *very little* to do with whatever you are talking about, rather the inter-molecular interactions matter more. But if you are talking about **[capillary action](http://en.wikipedia.org/wiki/Capillary_action)**, which I suppose you mean here:
>
> And how much would you have to raise it in order to get a drop of water 1 ft. in height?
>
>
>
Then yeah. It's surface tension. I'll just talk about both possibilities and more.
**Clarification: What is Surface Tension?** Listen, surface tension **is not only** about the water. *Water does not move on its own.* Its unit is Newtons per Meter. Why? Because it measures the **net force** being applied at the **edges of contact** between a liquid and its **surroundings**. Think of a glass of water (with gravity). There are a number of forces acting on it:
1. its weight
2. the inter-molecular forces of attraction (from hydrogen-bonds and Van der Waals' forces), which are called **cohesive forces** $F\_{co}$,
3. inter-molecular forces between **(a)** water and the glass material and **(b)** water and the air above, these two kinds are the **adhesive forces** $F\_{ad}$.
The contact edge on this glass is the line where water-glass contact meets water-air contact (I hope I didn't lose you there). And that's effectively the internal perimeter, $L$, of the glass at that level (**red line on the image**).

So the force from the surface tension, $F\_{st}$, would be $F\_{st}=F\_{co}-F\_{ad}$.
Giving us the Surface Tension, $\gamma$, as $$\gamma=\frac{F\_{st}}{L}=\frac{F\_{co}-F\_{ad}}{L}$$
Now, hopefully you've noticed where this is going. This Surface Tension $\gamma$ will vary for every single system. The $F\_{co}$ won't change but the $F\_{ad}$ would.
Examples? In the glass water system the $F\_{ad}$ comes from **two** separate adhesive forces, water-glass and water-air. at the edge of contact, the $F\_{ad}$ from water-glass contact is greater than the cohesive forces in the water, so some of the water climb up along the surface of the glass.
But in case of mercury-glass the cohesion is stronger, so the higher energy part at the edge bends downwards towards the rest of the liquid. Yet a mercury-copper case behaves like the water-glass case.
The Surface Tension $\gamma$ keeps changing as you change the material of the container. And it's that high adhesion between water and the surfaces that help it to stick on glass, steel and that tiny ant of yours.
**Coming to your actual query:** The maximum you say? There's no maximum, it purely depends on the material of the container or the material it's in contact with and also the shape of the material plays a huge role.
Well, instead of newton/gram we will talk about simply newtons, it makes more sense. The idea is, on Earth the adhesive forces need to be strong enough to cause this $F\_{st}>W\_{water}$ to make water climb through a pipe. And that is the case in capillary tubes, the water climbs up until the $F\_{st}$ has been cancelled by its weight. If the tubes are thin enough, like in trees and plants, the water will already reached its destination before the force gets cancelled out.
Now, if we suddenly boost up this adhesion a billion times stronger (limit: imagination) from what is the real and cohesion stays same, then it's gonna suck. Literally. Everything the water or any liquid comes to contact with, it will immediately start to evenly spread out, clothing every nooks and cranny on that surface of that object. It'd be much like when we spill water on the floor. But now it'd be happening EVERYWHERE, on the sides and on the roofs. The rivers, lakes and oceans start allowing a layer of water to swallow everything up, and a carpet of water will cover the world. Trees and plants burst as there is an immense rush of water inside them. The large droplets of water we adored will never form, a droplet release in the air will torn into tiny minuscule droplets, that we can't see. Maybe into water vapor. And Life? I wonder... ;)
Hope that helped. Went a little overboard. :D
|
34,589,903 |
The first function find factors of a number and works fine.
```js
//first find divisors of a number
function divisors(n) {
var result = [];
for (var i = 1; i <= n; i++) {
if ((n % i) == 0) {
result.push(i);
}
}
return result;
}
//the following gives problems
function commonTerms(arr1, arr2) {
var arr1 = [];
arr2 = [];
common = [];
var m = Math.min(arr1.length, arr2.length);
for (var i = 0; i < arr1.length; i++) {
for (var j = 0; j < arr2.length; j++) {
if ((arr1(i)) == (arr2(j))) {
common.push(arr1(i));
} else {
continue;
}
}
}
return common;
}
var x = parseInt(prompt("number to find divisors of?"));
document.write(divisors(x));
var y = parseInt(prompt("number to find divisors of?"));
document.write("<br>" + divisors(y));
alert(commonTerms(divisors(x), divisors(y)));
```
```html
<!DOCTYPE html>
<html>
<head>
<link href="css/styles.css" rel="stylesheet">
</head>
<body>
<h1>GCD</h1>
<p>This is my first website
<br>finding div</p>
</body>
</html>
```
It won't return anything, the second function is the one giving me trouble. I have been looking at it for an hour. Starting to learn programming on my own.
Thank you for your help.
|
2016/01/04
|
[
"https://Stackoverflow.com/questions/34589903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5723270/"
] |
The problem is that you're accessing array items like this: `arr(i)`.
You should do it with square brackets:
```
if ((arr1[i])==(arr2[j])){
common.push(arr1[i]);
//...
}
```
And you don't need the round braces at all. Plus you'd better [use strict comparison](https://stackoverflow.com/questions/359494/does-it-matter-which-equals-operator-vs-i-use-in-javascript-comparisons) (`===` instead of `==`).
So it would be:
```
if (arr1[i] === arr2[j]){
common.push(arr1[i]);
//...
}
```
BTW Consider checking [this question](https://stackoverflow.com/questions/1885557/simplest-code-for-array-intersection-in-javascript)
|
89,172 |
I have a ceiling fixture in the kitchen that I like and can't find a replacement electronic ballast (Tospo TP120-1/26UPL 26W). A replacement fixture has been hard to find and stupid expensive. I realized many of the newer LED ceiling lights are basically just LED tapes.
Since I was going to also run RGB LED tape throughout the kitchen, I thought it might be nice to also control the overhead light. Could run the tape in a square spiral - should give off more light than what was there before. Most of the LED tapes I've seen on Amazon though have a power supply / transformer.
* Do they make ones that don't need a transformer?
* And if so, what would that be called?
* The CFL bulb that was in the fixture would get plenty hot, guessing I shouldn't have to worry about heat off the LEDs but also interesting in any opinions here too.
|
2016/04/22
|
[
"https://diy.stackexchange.com/questions/89172",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/48990/"
] |
The Tospo is a cheap Chinese ballast. To find ballasts, start with what bulbs will fit in the fixture (all the better if you have a bulb already). Then search for ballasts meant to drive that bulb (which also fit in your fixture). I think I see [several on 1000bulbs.com](https://www.1000bulbs.com/category/26-watt-4-pin-gx24q3-base-fluorescent-ballasts/) in the $20 range.
LED strips really, really do not like to bend on the flat side. They will bend only in the direction they go onto the reel. However they do make [LED strips which emit light out the edge](https://www.google.com/search?client=safari&rls=en&q=side%20emitting%20led%20strip&ie=UTF-8&oe=UTF-8) ("side emitting"), these can be curled up in a spiral.
LED strips generally come in 12V or 24V. You might call it a "transformer" but most of them are digital switching power supplies. Very likely you can find one that will fit in the site of the old ballast.
They also do make [LED strips that are 120V](http://amzn.to/1SChqAX). This works by putting 30-40 LEDs in series with dropping resistors. This greatly reduces the number of allowable cut points. Getting this and also side-emitting may be a difficult combination to find. *Of greater concern: you no longer fall under the "low voltage" rules.* Everything you do is subject to the full weight of the National Electrical Code or your local equivalent. The law requires every part be listed (UL, CSA etc.) and installed properly. Break the law and fire insurance won't pay, and it's downhill from there. This is no place to buy Chinese junk.
|
45,834,564 |
I have a find query as given below
```
POST /movies/_find HTTP/1.1
Accept: application/json
Content-Type: application/json
Content-Length: 168
Host: localhost:5984
{
"selector": {
"year": {"$gt": 2010}
},
"fields": ["_id", "_rev", "year", "title"],
"sort": [{"year": "asc"}],
"limit": 2,
"skip": 0
}
```
Which returns the first two results that match the query. Is it possible to get the total number of rows with this query. This is very useful when building pagination
|
2017/08/23
|
[
"https://Stackoverflow.com/questions/45834564",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/561194/"
] |
The recommended way to implement this would be to have a `PageTitle` property on your viewmodel - which is kept in sync with current content-view; and hence its corresponding title.
But if you want to implement this at view level only; then you can do that by introducing a custom bindable property with binding-mode as `OneWayToSource` in your content view. For eg:
```
public class NavigationView : ContentView
{
public static readonly BindableProperty TitleProperty =
BindableProperty.Create("Title",
typeof(string),
typeof(NavigationView),
defaultValue: null,
defaultBindingMode: BindingMode.OneWayToSource);
public string Title
{
get => (string)GetValue(TitleProperty);
set => SetValue(TitleProperty, value);
}
}
```
And, bind your custom property to `ContentPage` title by using a self reference. For eg:
```
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
....
x:Name="_self"
Title="{Binding Path=Content.Title, Source={x:Reference _self}}">
```
Or, add binding to custom view to make full use of binding-mode:
```
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
...
x:Name="_self">
...
<local:NavigationView Title="{Binding Path=Title, Source={x:Reference _self}}">
```
Usage example
-------------
XAML:
```
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TitleView"
x:Class="TitleView.TitleViewPage"
x:Name="_self"
Title="{Binding Path=Content.Title, Source={x:Reference _self}}">
<local:NavigationView Title="This is page-1">
<Button Text="Go to page-2" Clicked="Handle_Clicked" />
</local:NavigationView>
</ContentPage>
```
Code-behind:
```
public partial class TitleViewPage : ContentPage
{
void Handle_Clicked(object sender, System.EventArgs e)
{
this.Content = new NavigationView {
Title = "This is page-2",
Content = new Button { Text = "Go back to page-1", IsEnabled = false } };
}
public TitleViewPage()
{
InitializeComponent();
}
}
```
[](https://i.stack.imgur.com/OP5t6.gif)
**EDIT 1:** Also added some code to illustrate how to define binding from content view to page.
|
3,776,117 |
What is the difference between the `remap`, `noremap`, `nnoremap` and `vnoremap` mapping commands in Vim?
|
2010/09/23
|
[
"https://Stackoverflow.com/questions/3776117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/238030/"
] |
`remap` is an **option** that makes mappings work recursively. By default it is on and I'd recommend you leave it that way. The rest are **mapping commands**, described below:
`:map` and `:noremap` are **recursive** and **non-recursive** versions of the various mapping commands. For example, if we run:
```
:map j gg (moves cursor to first line)
:map Q j (moves cursor to first line)
:noremap W j (moves cursor down one line)
```
Then:
* `j` will be mapped to `gg`.
* `Q` will *also* be mapped to `gg`, because `j` will be expanded for the recursive mapping.
* `W` will be mapped to `j` (and not to `gg`) because `j` will not be expanded for the non-recursive mapping.
Now remember that Vim is a **modal editor**. It has a **normal** mode, **visual** mode and other modes.
For each of these sets of mappings, there is a [mapping](http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_%28Part_1%29#Creating_keymaps) that works in normal, visual, select and operator modes (`:map` and `:noremap`), one that works in normal mode (`:nmap` and `:nnoremap`), one in visual mode (`:vmap` and `:vnoremap`) and so on.
For more guidance on this, see:
```
:help :map
:help :noremap
:help recursive_mapping
:help :map-modes
```
|
37,446,793 |
I have many sets of related data that I want to use to train a neural network. The data is from racing pigeons that fly a set distance. The inputs could be weight, age, size, wing span, sex, distance, time etc. sampled lets say every minute.
I am trying to predict the typical time a pigeon, given the inputs, would take in completing a race.
The input data would be normalised to improve the efficiency of the network.
A typical line of data may look like for weight, age, size, wing span, sex, distance, time would be
-1.34, -1.23, -0.49, 0.47, 0.97, -1, -1.44, -0.75
There would be many of these lines as the race progresses and at the end there would be a time result for each pigeon. Ie 3 hours 5 minutes.
I would then have a complete set of data for this race but obviously each race will be different so I need a way of training it for many races.
My question is, because each race is a discreet event what methods should I use to train the network. What I am confused about is this isn't a continuous stream of data that I can just let it get to work on. Should I train it with one set\race until it has learnt that and then move onto the next one etc or is there a methodology to use for this type of problem.
Thanks!
|
2016/05/25
|
[
"https://Stackoverflow.com/questions/37446793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/654242/"
] |
If I understand your question correctly, you have:
1. A set of races
2. For each race, you have a set of pigeons
3. For each pigeon within the race you have a series of values you record each minute.
4. For each pigeon within the race you also have his final time.
5. You want to predict what will be the final time for a pigeon given a series of values recorded so far in a live race.
If this is all correct, then I would observe the following:
1. For the purpose of this problem it would make sense to ignore whether two pigeons were flying in the same race or in two different races. Thus, the concept of a "race" can be dropped, and the input data can be now just thought of as a set of recorded flies by pigeons.
2. By nature, your data is time series. Regular feed forward networks are not good with time series. You need to use a recurrent network. Presently, the two kinds of recurrent networks that are often used in practice are LSTMs and GRUs.
Writing recurrent neural networks from scratch is not a good idea. Choose a framework (Keras, TensorFlow, Mxnet etc), find documentation on how to train an LSTM in that framework -- all of them have such tutorials -- and adjust it for your use case.
|
17,226,915 |
Trying to have a button open a new activity. My xml for the button looks like this:
```
<Button
android:id="@+id/buttonStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dip"
android:text=""
android:onClick="viewStyle"
/>
```
My button function looks like this:
```
public void viewStyle(View view) {
// launch new brewery page class
Intent i = new Intent(this, BreweryPage.class);
i.putExtra("myBeerObject", e);
i.setClass(this, StylePage.class);
startActivity(i);
}
```
My stylePage.java looks like this:
```
public class StylePage extends Activity {
BeerData e;
//get beer details from bundle
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.brewery_page);
//get data from listview
Intent intent = getIntent();
Bundle b = intent.getExtras();
e = b.getParcelable("myBeerObject");
//show title
TextView tv1 = (TextView) findViewById(R.id.styleTitle);
TextView tv2 = (TextView) findViewById(R.id.styleDescription);
//show description
tv1.setText(e.beerStyle);
tv2.setText(e.beerStyleDescription);
}
}
```
My error is a null pointer exception:
```
06-20 22:33:48.210: E/AndroidRuntime(29904): FATAL EXCEPTION: main
06-20 22:33:48.210: E/AndroidRuntime(29904): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.beerportfoliopro/com.example.beerportfoliopro.StylePage}: java.lang.NullPointerException
06-20 22:33:48.210: E/AndroidRuntime(29904): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307)
06-20 22:33:48.210: E/AndroidRuntime(29904): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2357)
06-20 22:33:48.210: E/AndroidRuntime(29904): at android.app.ActivityThread.access$600(ActivityThread.java:153)
06-20 22:33:48.210: E/AndroidRuntime(29904): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
06-20 22:33:48.210: E/AndroidRuntime(29904): at android.os.Handler.dispatchMessage(Handler.java:99)
06-20 22:33:48.210: E/AndroidRuntime(29904): at android.os.Looper.loop(Looper.java:137)
06-20 22:33:48.210: E/AndroidRuntime(29904): at android.app.ActivityThread.main(ActivityThread.java:5226)
06-20 22:33:48.210: E/AndroidRuntime(29904): at java.lang.reflect.Method.invokeNative(Native Method)
06-20 22:33:48.210: E/AndroidRuntime(29904): at java.lang.reflect.Method.invoke(Method.java:511)
06-20 22:33:48.210: E/AndroidRuntime(29904): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
06-20 22:33:48.210: E/AndroidRuntime(29904): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
06-20 22:33:48.210: E/AndroidRuntime(29904): at dalvik.system.NativeStart.main(Native Method)
06-20 22:33:48.210: E/AndroidRuntime(29904): Caused by: java.lang.NullPointerException
06-20 22:33:48.210: E/AndroidRuntime(29904): at com.example.beerportfoliopro.StylePage.onCreate(StylePage.java:28)
06-20 22:33:48.210: E/AndroidRuntime(29904): at android.app.Activity.performCreate(Activity.java:5104)
06-20 22:33:48.210: E/AndroidRuntime(29904): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
06-20 22:33:48.210: E/AndroidRuntime(29904): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2261)
```
|
2013/06/21
|
[
"https://Stackoverflow.com/questions/17226915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1637374/"
] |
From you logcat
```
Caused by: java.lang.NullPointerException
at com.example.beerportfoliopro.StylePage.onCreate(StylePage.java:28)
```
It clearly tells that you have a `nullpointerexception` at the `line 28` in `oncreate` method in the `StypePage` class within the `com.example.beerportfoliopro` package
And as you said the line 28 is
```
tv1.setText(e.beerStyle);
```
So it seems the tv1 is null. or e is null.
tv1 can only be null after this line
```
TextView tv1 = (TextView) findViewById(R.id.styleTitle);
```
So may be you are inflating the textView with wrong id. Check your layout xml and see if you are inflating correct id.
And e can be null in this line
```
e = b.getParcelable("myBeerObject");
```
So your getparcelable is returning null..
So the problem is either in the above two cases. Check those two.
( all is just a guess)
|
41,719,714 |
I want to add a HTML color-picker using JQuery.
Is there an easier way to achieve this without adding any JQuery libraries?
Tried `<input type="color">` but it's not working.
|
2017/01/18
|
[
"https://Stackoverflow.com/questions/41719714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6787035/"
] |
When you state `L[i] = L[j]` **you do not copy** the content of the list, you simply copy a reference: from now on `L[i]` and `L[j]` point to the same list and changes made through `L[i]` will reflect when you obtain `L[j]`.
A simply fix is simply to copy the list:
```
def lis():
#D = map(int, raw_input().split())
D = [3, 2, 6, 4, 5, 1]
L = [[] for i in range(len(D))]
L[0].append(D[0])
for i in range(len(D)):
for j in range(0,i):
if D[i] > D[j]:
L[i] = **list(**L[j]**)**
L[i].append(D[i])
print(L)
```
Now hoever your algorithm does not work anymore (it was not working in the first place nevertheless). When running your (fixed) code, you get:
```
>>> lis()
[[3, 3], [2], [2, 6], [2, 4], [2, 4, 5], [1]]
```
The `3` occurs twice in the first list, you can solve this by removing the `.append` before the `for` loop. So the final version is:
```
def lis():
#D = map(int, raw_input().split())
D = [3, 2, 6, 4, 5, 1]
L = [[] for i in range(len(D))] #removed the next line
for i in range(len(D)):
for j in range(0,i):
if D[i] > D[j]:
L[i] = list(L[j])
L[i].append(D[i])
print(L)
```
Which produces:
```
>>> lis()
[[3], [2], [2, 6], [2, 4], [2, 4, 5], [1]]
```
>
> **Note**: based on your comment you use [python-2.7](/questions/tagged/python-2.7 "show questions tagged 'python-2.7'"), from [python-3.x](/questions/tagged/python-3.x "show questions tagged 'python-3.x'") there is a method called `.copy()` on lists that you can call.
>
>
>
|
13,021 |
I am trying to transfer over row data from a table to columns in a shapefile table. There is a common "SA" variable between the two (i.e. the study area number) but there is more than one land use type, hence why I must create two new columns for each landuse, in order to capture the area and percentage value for each type. A join won't work because it only captures the values for one land use as opposed to all of them, as the first table doesn't have as many entries as the second.
The reason I need to migrate the data is because I'm trying to use this in dynamic text on data driven pages.
I wrote a SQL script with the help of my friend but it won't execute through field calculator, giving the generic 99999 error:
```
UPDATE SApeelfinal
SET LUp1 = (SELECT perc FROM stat_fin WHERE stat_fin.SA = SApeelfinal.FID_text and LANDUSE = 1)
WHERE EXISTS (SELECT 1 FROM stat_fin WHERE stat_fin.SA = SApeelfinal.FID_text and LANDUSE = 1)
```
Though he said that I have to change the LANDUSE value for each time I run the script and as well change SUM\_AREA and perc. I tried putting it in a toolbox but it wouldn't run that way either. Can someone enlighten me as to a better way to do this?
Also I was wondering if I had to manually create the new fields for this to work.
Here is a screenshot of the two tables:

You can also find a bigger version here: [http://i.imgur.com/sx08u.jpg](https://i.imgur.com/sx08u.jpg)
The red is the common variable between the two tables, the blue is the field I want the percentage to go to (and there would obviously be a new one for area), and the green are the two fields I want to migrate over based on the SATXT and FID\_text common fields.
I've tried using the following python script in the codeblock:
```
def getNewVal(newVal,landuse):
if landuse == 1:
return newVal
else:
return
```
With this in the calculate field:
```
getNewVal(!stat_fin.perc!,!stat_fin.LANDUSE!)
```
But it returns the same error. Is there something I'm doing wrong?
To clarify, there are no joins because joins make dynamic text not work.
|
2011/08/03
|
[
"https://gis.stackexchange.com/questions/13021",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/1963/"
] |
Your need to convert your SQL into VBA or Python for the Field Calculator in ArcMap
<http://webhelp.esri.com/arcgiSDEsktop/9.3/index.cfm?TopicName=Making_field_calculations>
ArcGIS 10 Users can also use Python scripts in ArcGIS Field Calculator

This is a cheaper option than buying ArcSDE and a database that supports SQL.
|
44,637,243 |
I have a large third party webservice; the reference.cs is 33 Mbyte. Using Visual Studio 2017, the proxy uses the XML Serializer, which causes a 5 second delay when creating the channel. I opened a case at Microsoft, and they showed me partially how to modify the reference.cs to use the Datacontract serializer. On the same machine the channel is created in 20 mseconds, which would perfect match my needs.
Unfortunatly the messages fail with small differences, and Microsoft support cannot help.
Are there known restrictions? Any patterns I should look for which makes it for sure it will not work at all and I should start rewriting everything using HTTP Requests?
Actual method which results in overall delay:
```
public XmlMembersMapping ImportMembersMapping(string elementName, string ns,
XmlReflectionMember[] members, bool hasWrapperElement, bool writeAccessors,
bool validate, XmlMappingAccess access) {
ElementAccessor element = new ElementAccessor();
element.IsSoap = true;
element.Name = elementName == null || elementName.Length == 0 ? elementName :
XmlConvert.EncodeLocalName(elementName);
}
```
|
2017/06/19
|
[
"https://Stackoverflow.com/questions/44637243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/317935/"
] |
Ah. I guess the PDFPage is not meant for python 3.6. Following example from [How to read pdf file using pdfminer3k?](https://stackoverflow.com/questions/44024697/how-to-read-pdf-file-using-pdfminer3k) solved my issues!
|
9,677,020 |
Thanks to dmon and the example here [Process the value of preference before save in Android?](https://stackoverflow.com/questions/5858790/process-the-value-of-preference-before-save-in-android)
I was able to get the basic code down. But my value isn't being stored encrypted in preferences.xml on the device and I know this is a simple mistake on my part (java novice).
My encryption and decryption class is working outside of the EditTextPreference code.
Kind Regards,
Mike
My preferences.xml
```
<ping.test.com.EncryptedEditTextpreference
android:key="key"
android:summary="Enter Your Public Key"
android:title="Public Key"
android:inputType="textPassword"/>
</PreferenceCategory>
```
My class to extend EditTextPreference
```
package ping.test.com;
import android.content.Context;
import android.preference.EditTextPreference;
import android.util.AttributeSet;
public class EncryptedEditTextPreference extends EditTextPreference {
public EncryptedEditTextPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public EncryptedEditTextPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public EncryptedEditTextPreference(Context context) {
super(context);
}
@Override
public String getText() {
String value = super.getText();
try {
return SimpleCrypto.decrypt("BiteMe", value);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return value;
}
@Override
protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
super.setText(restoreValue ? getPersistedString(null) : (String) defaultValue);
}
@Override
public void setText(String text) {
try {
super.setText(SimpleCrypto.encrypt("BiteMe", text ));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
```
|
2012/03/13
|
[
"https://Stackoverflow.com/questions/9677020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/724209/"
] |
First, I know it's convenient to have `Preference` Views, but at you special case I would prefer to take a simple EditText and save the Preference manually inside [SharedPreferences](http://developer.android.com/reference/android/content/SharedPreferences.html).
To answer your Question: According to the docs it should work, what you have tried. To get closer to the error try to add Logs like this:
```
@Override
public void setText(String text) {
Log.v("setText", "from " + text);
try {
String to = SimpleCrypto.encrypt("BiteMe", text );
Log.v("setText", "to " + to);
super.setText(to);
} catch (Exception e) {
e.printStackTrace();
}
}
```
verify , that your `SimpleCrypt` class works like expected, and you could add a [TextWatcher](http://developer.android.com/reference/android/text/TextWatcher.html) to the EditText and log it also to see what happens.
Note that this might be usafe at all, as an attacker is able to decompile your apk and see how this encryption works!
|
30,829,685 |
I'm trying to generate a unique/random string in Laravel 5 and check it through my table to see if it exists.
This is what I have, but it seems to be giving the error stated in the title:
```
public static function generate()
{
$exists = true;
while ($exists) {
$code = str_random(15);
$check = self::where('code', $code)->first();
if( ! $check->count()){
$exists = false;
}
}
return $code;
}
```
Anyone know why it's giving this error?
|
2015/06/14
|
[
"https://Stackoverflow.com/questions/30829685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2691958/"
] |
The error you're seeing is telling you that you're trying to call a method on a value which is not an object. Most likely in your code you're returning null as the where in your query didn't return anything results. You can always see what you're returning in Laravel queries by using `dd()`:
`dd(Self::where('code', $code)->first())`
So before calling `count()` or any other method on a value for which you're expecting an object you should check it's not null.
Do to this you can update your if statement in the code you provided:
```
public static function generate()
{
$exists = true;
while ($exists)
{
$code = str_random(15);
// It's good practice to capitalise objects: Self instead of self
$check = Self::where('code', $code)->first();
if(!$check )
{
$exists = false;
}
}
return $code;
}
```
As mentioned by Halayem Anis you can also test if the value you're checking is an object using the `is_object()` function, but I think you may need to use the `&&` operator instead of `||`:
```
if(!$check && !is_object($check))
```
|
5,557,666 |
**Edit** I think the process attribute must point to an element in the same a4j:form. You can skip to my answer below.
---
Reading the *Using process attribute* section of this [article](http://java.dzone.com/news/richfaces-region-partial-jsf) they mention that it can point to any container. **What tags qualify as a container for use of the process attribute?**
Some that I am specifically considering:
* a4j:form
* a4j:outputPanel
* a4j:region
* rich:dataTable
* rich:panel
* rich:modalPanel
|
2011/04/05
|
[
"https://Stackoverflow.com/questions/5557666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/147265/"
] |
It's not possible to point to a4j:region. It definitely works with h:panelGrid or rich:panel. I doubt h:form can be used as the control with process-attribute is already within a form and then you are pointing to another form.
h:dataTable might work if you have inputs inside.
Hope this helps.
|
660,200 |
Is it safe to install ubuntu alongside windows 7?
I have a laptop with 500 GB hard disk and 2 GB RAM and it is pre-installed with windows 7.My professor asks me to install ubuntu 12.04 alongside Windows 7.
However I am not sure whether it is safe to make a dual boot system? Will it affect my hard disk ?Is there any chance of a hard disk crash?
Please help.
|
2015/08/11
|
[
"https://askubuntu.com/questions/660200",
"https://askubuntu.com",
"https://askubuntu.com/users/-1/"
] |
It depends on what do you call "safe"?
There is a risk of data loss if power supply fails during partitioning of the HDD.
There is also a risk that the person who installs Ubuntu removes a wrong partition or incorrectly understands what disk is. That it is not like "Disk D" in Windows. It is a physical disk.
There are lots of things that an inexperienced user can do wrong.
That is why it is always recommended to backup your important data first.
But if you do everything carefully, read manuals first, it can be pretty safe.
You can read [this answer](https://askubuntu.com/a/152902/167850) for directions.
|
27,303,184 |
I'm trying to convert a `string` to a `SolidColorBrush` in C#. The code I'm using is:
```
arrColors[arrColors.Length - 1] =
(SolidColorBrush)new BrushConverter().ConvertFromString(sLine);
```
where sLine is a string read from a text file. For example, `sLine` might be "Black".
This code gives me a `FormatException`.
|
2014/12/04
|
[
"https://Stackoverflow.com/questions/27303184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4326096/"
] |
Assuming all of your brushes are solid colours, you could construct a Color from a string as follows:
```
Color color = (Color)ColorConverter.ConvertFromString(sLine);
```
Then you could create a `SolidColorBrush` from that colour, like so:
```
SolidColorBrush brush = new SolidColorBrush(color);
```
**EDIT**: If the string being converted is English but the current culture is not, you may need to use `ConvertFromInvariantString` instead, like so:
```
ColorConverter converter = new ColorConverter();
Color color = (Color)converter.ConvertFromInvariantString(sLine);
```
|
39,381,119 |
In **feature** usage [example](http://openlayers.org/en/latest/examples/icon.html), there is 2 attributes called `population` and `rainfall`.
```
...
var iconFeature = new ol.Feature({
geometry: new ol.geom.Point([0, 0]),
name: 'Null Island',
population: 4000,
rainfall: 500
});
...
```
What does it means? I searched around and didn't find any information.
|
2016/09/08
|
[
"https://Stackoverflow.com/questions/39381119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3414257/"
] |
It's an example of adding generic properties to a feature that you can then use elsewhere. The example doesn't make it super obvious. In that example you could add another property called 'numberOfDonkeys' with a value of 20, and then you could use that in the click event that fires the popup.
Foe example, I can change the Feature to be this.
```
var iconFeature = new ol.Feature({
geometry: new ol.geom.Point([0, 0]),
name: 'Null Island',
population: 4000,
rainfall: 500,
numberOfDonkeys: 20
});
```
And change the map click event to this.
```
// display popup on click
map.on('click', function(evt) {
var feature = map.forEachFeatureAtPixel(evt.pixel,
function(feature) {
return feature;
});
if (feature) {
var coordinates = feature.getGeometry().getCoordinates();
popup.setPosition(coordinates);
$(element).popover({
'placement': 'top',
'html': true,
'content': feature.get('name') + ' Pop: ' + feature.get('population') + ' Donkeys: ' + feature.get('numberOfDonkeys')
});
$(element).popover('show');
} else {
$(element).popover('destroy');
}
});
```
And you'll see the Population and numberOfDonkeys attributes in the popup.
jsFiddle Example - <https://jsfiddle.net/6vd5gtho/>
Ultimately you don't *need* those attributes at all, you could get rid of them, they are just examples of where you *could* put attributes you wanted to reuse in this way.
|
101,386 |
I am building a druid who will be focusing on wild shaping into elemental body forms and using weapons instead of natural attacks. Because of this I want a way to have my weapons **NOT** meld with me when I wild shape. Currently the only way I know of doing this would be to put the items down or have them in extra dimensional spaces. However then there is the issue of the weapons being incorrectly sized after wild shaping.
A partial solution already exists for armor, called the wild ability for +3. The armor still melds with you when you polymorph.
Specifically I want to create a weapon property which will allow me to exclude or include the weapon its one when I wild shape. Increasing the time to wild shape or something would be fine, so long as the process continues to not provoke attacks of opportunity and is finished within a single round (aka a full round action, not 1 round). Since the weapon does not meld, it resizes just like my form does. Other desires would be it automatically resizing for whoever is wielding it, meaning if I wild shape while not holding it, I can still gain full use of it but I cant have it meld into me at that point.
Such a property kind of exists already in an item called [polymorphic pouch](http://www.d20pfsrd.com/magic-items/wondrous-items/wondrous-items/m-p/polymorphic-pouch/). It is a reasonable 5000 gp for a pouch that does not wild shape, moves to a convenient place on the body, and has extra dimensional space. However because there will be times when I do not want it to and would like it to meld with me (such as forms that are unable to hold the weapon or Im pretending to be an animal).
What I am having issues with is deciding if it should be priced as a bonus (which is most likely) or as just a price like adaptive. Since bonus is most likely, what should the bonus be? A +3 seems too expensive to me, but since I desire the ability I am biased to what it should be priced at.
|
2017/06/12
|
[
"https://rpg.stackexchange.com/questions/101386",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/23058/"
] |
I would start by checking the [Beaststrike Club](http://archivesofnethys.com/MagicWeaponsDisplay.aspx?ItemName=Beaststrike%20Club), which is a club that has several wild-shaping themed effects. It can transform into the head or limb of an animal, and a druid with wild shape can increase the weapon size by one category.
It costs 7,300 gp. Which means **the special ability costs 5,000 gp** (300 gp masterwork, 2,000 gp for +1 enhancement). This is also similar to the cost of a [Resizing](http://www.archivesofnethys.com/MagicWeaponsDisplay.aspx?ItemName=Resizing) weapon (+4,000 gp).
If we check the [Wild](http://archivesofnethys.com/MagicArmorDisplay.aspx?ItemName=Wild) special ability, we will notice that **Wild costs about 15,000 gp**. As a Wild armor should at least be priced as a +4 armor (16,000 gp) and 1,000 gp is the cost of a +1 bonus.
Now, we know that weapon abilities cost at least *twice* as much as armor abilities, even though armors usually keep your character alive so he can keep killing his enemies. That said, a +3 weapon ability would cost way too much (about 30,000 gp), for the simple effect of being able to be used.
We would have to ask the developers to know *why* Wild was priced so high, but we can guess that it's because **armors** are *gone* when wild shaping. At the earlier levels, all you gain to compensate for your now missing armor are small *natural armor* or dex and size bonuses, +2 or +3 to AC. While at later levels this bonus increases to +5 or +7. A druid's answer for this lack for armor AC is the spell [Barkskin](http://www.d20pfsrd.com/magic/all-spells/b/barkskin/), but they have no other option for **missing special abilities** other than Wild.
Meanwhile, your **manufactured weapons** are *replaced* by new natural weapons, so you are losing little if the weapon doesn't have magical special abilities, and sometimes you will even get stronger weapons. Not only that, but druids have the option to obtain properties like *Flaming* or *Keen* by using an [Amulet of Mighty Fists](http://www.d20pfsrd.com/magic-items/wondrous-items/wondrous-items/a-b/amulet-of-mighty-fists/), which is twice the price of a weapon with the same properties, but will apply the effects to *all* natural attacks, and they also have access to [Magic Fang](http://www.d20pfsrd.com/magic/all-spells/m/magic-fang/). So, weapons are pretty much covered in terms of damage for wild shaping druids.
I wanted to say all this simply to point out that **there is no need to price the weapon special ability as high as the armor special ability**. Because there are other items that already cover the weapon balance for wild shaping druids.
With all that said, let's brainstorm a **Wild weapon special ability**.
First, what do we want this ability to do? *Not* transform, right? As in, not meld into the caster's body and actually be available to be wielded if the new form is capable of wielding weapons.
You are not gaining much by wild shaping with a greatsword (2d6) as you will not be able to wield it a the same time as you can make use of your natural attacks effectively, which usually cause 1d6 damage, but allows multiple rolls since you have multiple weapons. If you wild shape a dagger (1d4), the potential damage output is reduced. Which means **the usefulness of the special ability will depend on which weapon it is enchanted on**.
Of course, why would we enchant a weapon with *Wild* if not to use other special abilities with it? That's right, that is the whole point of it.
A *Wild* weapon is, at minimum (assuming a +1 equivalent bonus), a +2 weapon and will cost 4,000 gp (plus masterwork), and any additional special ability applied on it will increase it's cost significantly. A +1 flaming magic sword costs 4,000 gp. A +1 flaming wild magic sword will cost 9,000 gp, a **5,000 gp difference**. See the similarity in price with *Resizing* and *Beaststrike*?
This difference only goes up as the enhancement bonuses increases:
* +3: 7,000 difference (9,000 vs 16,000)
* +4: 9,000 difference (16,000 vs 25,000)
* +5: 11,000 difference (25,000 vs 36,000)
* +6: 12,000 difference (36,000 vs 48,000)
* +7: 16,000 difference (48,000 vs 64,000)
* +8: 17,000 difference (64,000 vs 81,000)
* +9: 19,000 difference (81,000 vs 100,000)
* +10: 21,000 difference (100,000 vs 121,000)
Depending on your build, it might be too expensive for what it does. But as the enhancement bonuses increases, you are allowed to wield an even more powerful weapon than you normally could with an [Amulet of Mighty Fists](http://www.d20pfsrd.com/magic-items/wondrous-items/wondrous-items/a-b/amulet-of-mighty-fists/), especially after +6, as the cost is over 10,000 gp, but that is already past the limit of the amulet (maximum +5) and makes the ability stronger than the amulet.
To me, that is worth a **+1 bonus**.
|
41,833,341 |
The [Eclipse RAP](http://www.eclipse.org/rap/) (Remote Application Platform) project provides a way to write web applications using SWT.
Due to single sourcing, the written code can also be used in desktop SWT/RCP applications.
Since it is a framework for web applications I was wondering if it supports **responsive design**?
If so, a simple example would be great. It does not need to be RCP compatible.
I didn't find a lot on the internet, has there been any efforts towards supporting responsive design?
|
2017/01/24
|
[
"https://Stackoverflow.com/questions/41833341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2343011/"
] |
Due to the fact that RAP shields you from web technology, native CSS and other web-techniques won't work.
To summarize the comments, you will likely have to implement one or more custom layouts that adapt to the available space and show/hide/resize the managed controls accordingly.
You may also want to use custom controls or manipulate existing controls to adapt to the available space. in some places. For example, hide texts on toolbar buttons when space becomes rare.
RAP theming can also be leveraged to a certain extent in order to change the appearance and space of certain controls.
Further reading:
* EclipseCon 2014 talk: <https://www.eclipsecon.org/na2014/sites/default/files/slides/Responsive%20Applications%20Tutorial%20-%20EclipseCon%202014.pdf>
* A blog post with code examples about responsive UIs with SWT: <http://www.codeaffine.com/2014/02/24/responsive-uis-with-eclipse-and-swt/>
* RAP Theming: <https://eclipse.org/rap/developers-guide/devguide.php?topic=theming.html>
* Understanding SWT Layouts: <https://www.eclipse.org/articles/article.php?file=Article-Understanding-Layouts/index.html> (ignore the deprecation warning, the core concepts haven't changed since)
|
406,753 |
This question comes from <https://stats.stackexchange.com/questions/457375/recover-full-covariance-matrix-from-covariance-diagonal-and-precision-off-diagon> where it have not found answers. So, let $\Sigma$ be an $N\times N$ covariance (that is, positive semidefinite) matrix, but we do only know its diagonal and the off-diagonal elements of its inverse $\Sigma^{-1}$ (known as precision matrix).
How can we find $\Sigma$ effectively?
|
2021/10/21
|
[
"https://mathoverflow.net/questions/406753",
"https://mathoverflow.net",
"https://mathoverflow.net/users/6494/"
] |
Following the ideas from my answer to [Carlo's question](https://mathoverflow.net/questions/406831/uniquely-reconstruct-a-matrix-m-from-its-inverse-m-1-if-n-elements-of?noredirect=1&lq=1), let $M(z\_1, \ldots, z\_n)$ be the symmetric matrix with $M(z\_1, \ldots, z\_n)\_{ij} = \Sigma\_{ij}$ for $i \neq j$ and $M(z\_1, \ldots, z\_n)\_{ii} = z\_i$.
Use any sort of numerical optimization algorithm to maximize
$$\log \det M(z\_1, \ldots, z\_n) - \sum\_{i=1}^n \Sigma^{-1}\_{ii} z\_i$$
on the open set of $(z\_1, \ldots, z\_n)$ where $M(z\_1, \ldots, z\_n)$ is positive definite. The function in question is concave, so the optimum is unique and shouldn't be hard to find. This $M(z\_1,\ldots, z\_n)$ will have the desired property.
The equations one gets seems to have fairly high degree, so I would not attempt a symbolic solution.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.