qid int64 1 74.7M | question stringlengths 0 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 2 48.3k | response_k stringlengths 2 40.5k |
|---|---|---|---|---|---|
13,250,180 | My bash code look likes:
```
set -e
(
flock -n 9
main $@
) 9>/var/lock/mylockfile
```
But currently it don't show any error message, if it is not able to get lock on the file.
Is there a way to show error message ? | 2012/11/06 | [
"https://Stackoverflow.com/questions/13250180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428705/"
] | With "set -e", you can use the ERR signal. As said in the man page of bash
(description of the "set" command with option "-e"):
```
"A trap on ERR, if set, is executed before the shell exits."
```
So you can try something like:
```
set -e
(
trap 'echo flock failed.' ERR
flock -n 9
trap - ERR # reset ERR tr... | The example in the manpage says:
```
(
flock -n 9 || exit 1
# ... commands executed under lock ...
) 9>/var/lock/mylockfile
```
ie it exits if flock fails -- why don't you just use that?
If you want to display an error, you could try this:
```
(
# paranoia: flock may fail with an exit code ot... |
87,971 | Help me complete this network.
I have a cable modem going to a switch. The switch has various devices connected to it. A few computers and a wireless router. I have a a number of computers connected to the wireless router wirelessly.
The devices connected to the switch together can communicate with each other. The d... | 2009/12/26 | [
"https://superuser.com/questions/87971",
"https://superuser.com",
"https://superuser.com/users/8610/"
] | I suggest you use your Access Point as the main router/firewall between the modem and the switch:
Modem>AccessPoint>Switch>Clients ('Wired clients' connect to switch, 'Wireless clients' connect to Access Point through it's SSID. The Access Point will serve addresses via it's DHCP service to all your clients). This con... | If you want full communication between the wired and wireless devices, it is pretty simple.
* Shut off DHCP on the wireless router
* Connect wireless router to the switch using one of the wireless router's local ports (usually numbered 1-4, LAN, local, etc).
Right now you likely have the public port plugged in (marke... |
87,971 | Help me complete this network.
I have a cable modem going to a switch. The switch has various devices connected to it. A few computers and a wireless router. I have a a number of computers connected to the wireless router wirelessly.
The devices connected to the switch together can communicate with each other. The d... | 2009/12/26 | [
"https://superuser.com/questions/87971",
"https://superuser.com",
"https://superuser.com/users/8610/"
] | I suggest you use your Access Point as the main router/firewall between the modem and the switch:
Modem>AccessPoint>Switch>Clients ('Wired clients' connect to switch, 'Wireless clients' connect to Access Point through it's SSID. The Access Point will serve addresses via it's DHCP service to all your clients). This con... | I agree with l0c0b0x. Also both the modem and the wireless router are probably running DHCP servers. You will want to turn one of them off, usually the easiest one to turn off is the one on the modem as not all wireless routers let you turn DHCP off. |
61,792,317 | I have a Bootstrap button, in which I overrode the styling in my stylesheet because I wanted to change the border radius. Now the button has a transition effect from Bootstrap on it, how can I get rid of it? See the snippet below for the result:
```css
.btn {
border-radius: 0;
width: 12.313rem;
padding:... | 2020/05/14 | [
"https://Stackoverflow.com/questions/61792317",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11998623/"
] | Just add !important to overrule, i also added the hover part, wasnt clear to me you needed that specificly.
(also to explain: bootstrap has a lot of build-in classes that use specific constructions like button.btn which will overrule the standard .btn class because it's more specific , so using !important will make su... | If you want to remove the color changes when you hover over the button, then what you have to do is make use of the `hover` pseudo-class, you can find more information about this in the w3c site here <https://www.w3schools.com/css/css_pseudo_classes.asp>
In this snippet you can find a possible solution to what you wan... |
8,939,467 | I have this Chrome extension that modifies the header of requests before sending them. I now would like to be able, within the same extension, to check the header of the response. I searched throughout the Chrome Extension APIs but I couldn't find anything of interest.
This is the code I use for modifying the header o... | 2012/01/20 | [
"https://Stackoverflow.com/questions/8939467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/617461/"
] | I achieved capturing all HTTP requests and responses made by a website, by injecting a script to DOM. I injected injected.js to DOM using following script:
```
/**
* code in inject.js
* added "web_accessible_resources": ["injected.js"] to manifest.json
*/
var s = document.createElement('script');
s.src = chrome.ext... | See the live-headers example.
<http://code.google.com/chrome/extensions/examples/api/debugger/live-headers.zip>
EDIT: For posterity you can find a version of live-headers.zip on their archived bug/patch site <https://chromiumcodereview.appspot.com/9289057>
With the latest revision (2021) no longer including the zip,... |
67,310,601 | I have a user array and I show every user on a card. I only show the avatar, name and surname on the card. But when clicking on each card, I want to dynamically go to a `UserInfo`component for that card and show all the information. I am new on react-router, so to understand how it works, I tried to do with using react... | 2021/04/29 | [
"https://Stackoverflow.com/questions/67310601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14742664/"
] | `<Route>` components render if *any* part of the `path` prop matches the current path. So if you have this:
```
<Switch>
<Route path="/" component={Main} true />
<Route path="/users/:id" component={UserInfo} />
</Switch>
```
The first `<Route>` will *always* match because `/` matches both... | @jered's answer is correct but you can also use the [`exact`](https://reactrouter.com/web/api/Route/exact-bool) prop on the `Route` to specify that it should only render the Main if the path matches exactly the "`/`"
Like this:
```js
<Switch>
<Route path="/" component={Main} exact={true} />
<Route path="/users/:i... |
26,164,691 | I have this SQL work fine except 1 point (at third value I need take previous time), this is the table (times) schema, output, and SQL:
```
id number time
-----------------------------------
1 9 00:00:10.000000
2 10 00:00:15.000000
3 9 00:00:22.000000
4 10 ... | 2014/10/02 | [
"https://Stackoverflow.com/questions/26164691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4087412/"
] | Only need change `SUM` to `MAX`
```
SELECT t.number, COUNT(1) laps,
GROUP_CONCAT(SEC_TO_TIME(time) ORDER BY t.id) times
FROM (
SELECT t1.id, t1.number,
TIME_TO_SEC(t1.time) - COALESCE(MAX(TIME_TO_SEC(t2.time)), 0) time
FROM times t1
LEFT JOIN times t2 ON t1.number = t2.number AND t2.time < t1.time -- S... | This was a bit tricky, but here is a solution:
The main problem is the "smaller than" condition in your join. So first you have to add a running number (rank) to your Groups based on [this answer](https://stackoverflow.com/questions/17939198/row-number-per-group-in-mysql). Then you can join by that rank. The resultin... |
22,597,026 | I have 2 submit buttons in a form. I will upload a file and save in a filepath in server when I click on one "upload" button. I want to use this file path in the code when I click on another button called "Process". When I click the process nothing is happening with dump in below code. Form submits to itself. Is there ... | 2014/03/23 | [
"https://Stackoverflow.com/questions/22597026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3453252/"
] | The reason that your dump is not happening is because `<input type="button">` does not submit forms unless you are doing that via JavaScript.
Please read [Difference between <input type='button' /> and <input type='submit' />](https://stackoverflow.com/questions/290215/difference-between-input-type-button-and-input-ty... | You can try the below code. This dumps the value of the path as well.
```
<cfif isDefined('Form.tmpfile1')>
<cfset root = ExpandPath("/Upload")><!---location where file should be uploaded--->
<cfset filename=GetFileFromPath(Form.tmpFile1)>
<cfset FileExt=ListLast(filename,".")>
<cfset variables.filepat... |
1,687,912 | Has anyone checked out a copy of Drupal 7 yet? What do people think?
I'm pretty excited about the PDO and all of the designers I work with a very excited about the new admin interface/structure.
Do we have any Drupal core developers here on Stack Overflow? | 2009/11/06 | [
"https://Stackoverflow.com/questions/1687912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/197375/"
] | It looks good, and the API is now frozen so module developers can get going before the final release.
A lot of the strength of Drupal comes from the modules and until they are on D7 it won't have a huge amount of benefit over D6.
The architectural changes are good and the api changes generally seem to be a step in t... | I finally got around to signing up on SO, and I'm a core contributor. I'm obviously biased, but I think Drupal 7 is even more of an improvement over D6 than D6 was over D5. The easiest way to give it a spin is to sign up for a [Drupal Gardens](http://www.drupalgardens.com) account. It'll take a little while to get an i... |
1,687,912 | Has anyone checked out a copy of Drupal 7 yet? What do people think?
I'm pretty excited about the PDO and all of the designers I work with a very excited about the new admin interface/structure.
Do we have any Drupal core developers here on Stack Overflow? | 2009/11/06 | [
"https://Stackoverflow.com/questions/1687912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/197375/"
] | It looks good, and the API is now frozen so module developers can get going before the final release.
A lot of the strength of Drupal comes from the modules and until they are on D7 it won't have a huge amount of benefit over D6.
The architectural changes are good and the api changes generally seem to be a step in t... | Drupal Gardens is now in public beta; it is free, and you can export your site at any time. Check out the [FAQ if you know Drupal](http://www.drupalgardens.com/content/how-do-drupal-7-and-drupal-gardens-differ). |
1,687,912 | Has anyone checked out a copy of Drupal 7 yet? What do people think?
I'm pretty excited about the PDO and all of the designers I work with a very excited about the new admin interface/structure.
Do we have any Drupal core developers here on Stack Overflow? | 2009/11/06 | [
"https://Stackoverflow.com/questions/1687912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/197375/"
] | I finally got around to signing up on SO, and I'm a core contributor. I'm obviously biased, but I think Drupal 7 is even more of an improvement over D6 than D6 was over D5. The easiest way to give it a spin is to sign up for a [Drupal Gardens](http://www.drupalgardens.com) account. It'll take a little while to get an i... | Drupal Gardens is now in public beta; it is free, and you can export your site at any time. Check out the [FAQ if you know Drupal](http://www.drupalgardens.com/content/how-do-drupal-7-and-drupal-gardens-differ). |
32,163,602 | I have to convert one xml to html page. I read that xml and mapped to transform xml. I have added html formatting tags in xslt. But it is not reflecting in page. I am getting data of xml in one line side by side. The html code not working what i have given. So any one can let me know how to transform xml to html, is th... | 2015/08/23 | [
"https://Stackoverflow.com/questions/32163602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5256518/"
] | As already mentioned by Patrick Allen in comments, you cannot animate/transition from or to an "auto" value using CSS. For your case, you could replace it with `transform: translate()` like in the below snippet and achieve the same effect.
Below is the relevant SCSS code and what it does:
* The `transform: translate... | ```
$('#click').click(function () {
var windowHeight = $(window).height();
var lineHeight = $('#line').height();
var desiredBottom = 100;
var newPosition = windowHeight - (lineHeight + desiredBottom);
$('#line').animate({top:newPosition},1000,function () {
$('#line').css({
bot... |
32,163,602 | I have to convert one xml to html page. I read that xml and mapped to transform xml. I have added html formatting tags in xslt. But it is not reflecting in page. I am getting data of xml in one line side by side. The html code not working what i have given. So any one can let me know how to transform xml to html, is th... | 2015/08/23 | [
"https://Stackoverflow.com/questions/32163602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5256518/"
] | As already mentioned by Patrick Allen in comments, you cannot animate/transition from or to an "auto" value using CSS. For your case, you could replace it with `transform: translate()` like in the below snippet and achieve the same effect.
Below is the relevant SCSS code and what it does:
* The `transform: translate... | Give `top: 0;` to `.hud` element and it will work fine. Here is the codepen: <http://codepen.io/anon/pen/KpOKdE> |
47,227,482 | I am looking for an approach to allow only whitelisted scripts to run within a sandboxed iframe. I was thinking of an iframe-sandbox directive that allows only whitelisted scripts to run within an iframe. The analogy is the script-src directive in the Content Security Policy.
The problem:
```
<iframe sandbox="allow-... | 2017/11/10 | [
"https://Stackoverflow.com/questions/47227482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4725192/"
] | The answer to this is unfortunately complicated. With the advent of iframe sandboxing the question seems simple enough, but the spec that you're looking for is very much a work in progress. Thus, if you want decent browser support, the issue devolves into how to modify an iframe's content, which usually involves some s... | You can't do this the way you want (for now). As mentioned in comments CSP:EE is a thing yet to come.
However you can try proxying the request and removing the unnecessary scripts from the body on the server side or on the client side, e.g.:
1) Get the needed page via XMLHTTPRequest
2) Remove unwanted
3) Inject int... |
12,563,148 | I am trying to make UserControl (GridSearch) which has another UserControl\_2 inside. I want to add some FrameworkElements to panel of UserControl\_2 using XAML.
So I did ObservableCollection DependencyProperty in GridSearch:
```
public partial class GridSearch : UserControl
{
public GridSearch()
{
I... | 2012/09/24 | [
"https://Stackoverflow.com/questions/12563148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/507102/"
] | Change the getObservableFilters() method to just create and return the observable collection.
And in the GridSearch() constructor, after the call to InitializeComponent(), you can add a handler for Filters.CollectionChanged and provide a non-static member function. | Ok it works finally the key thing was to create new ObservableCollection() in constructor for each instance of the control.
However there is still one problem. Everything works at runtime but designer is not able to display anything as it gets following error:
***Object reference not set to an instance of an object.*... |
9,017,601 | I am relatively new to programming with PHP.
I have created a simple Javascript game and I have managed to insert the player's current score into the database. I have two fields, current score and highest score for the player. How do I check if the player's current score is higher than his highest score and update th... | 2012/01/26 | [
"https://Stackoverflow.com/questions/9017601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1171155/"
] | An update statement setting the current score and possibly updating the highest score per user:
```
UPDATE `scores` SET `current_score` = ?, `high_score` = GREATEST(`high_score`, ?)
WHERE `user` = ....
```
Substitute `?` for the score. | After inserting the current score you could run the following query:
```
UPDATE scores
SET high_score = current_score
WHERE current_score > high_score
``` |
12,240,230 | I'm new to the site and I'm looking for some help in regards to a doubly linked list that stores Mp3's with artistname, songname, albumname, date, and running time. If you could help me out at all, I'd appreciate it. I have been getting a segfault according to GDB in my add function.
The warnings are also as follows:... | 2012/09/02 | [
"https://Stackoverflow.com/questions/12240230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You have a problem here
```
struct MP3 *data;
data->artistName = artistname;
```
you declare a pointer to `MP3` but you do not allocate memory for it. Use `malloc` to allocate the space or just use a plain instance instead.
You also have a problem here
```
pointer->next = (struct MP3*)malloc(sizeof(struct MP3));
... | struct MP3 \*data;
declares a pointer to a data structure, but it doesn't create the structure. So when you try to access it, you are accessing unallocated memory, which causes a segmentation fault.
You need to allocate the memory using malloc:
```
struct MP3 *data; /* declares a pointer to a MP3 structure */
data = ... |
12,240,230 | I'm new to the site and I'm looking for some help in regards to a doubly linked list that stores Mp3's with artistname, songname, albumname, date, and running time. If you could help me out at all, I'd appreciate it. I have been getting a segfault according to GDB in my add function.
The warnings are also as follows:... | 2012/09/02 | [
"https://Stackoverflow.com/questions/12240230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You have a problem here
```
struct MP3 *data;
data->artistName = artistname;
```
you declare a pointer to `MP3` but you do not allocate memory for it. Use `malloc` to allocate the space or just use a plain instance instead.
You also have a problem here
```
pointer->next = (struct MP3*)malloc(sizeof(struct MP3));
... | As the error message says - `"'data' is uninitialized in this function"` - which is obviously true. You *declare* a *pointer to MP3 struct* called 'data'. You never *initialize* the pointer by allocating memory and initializing the pointer to point to that memory. |
50,227,172 | I'm struggling to delete some characters from StringBuilder. The method works fine. However, I want to achieve the same via Java-8 streams API. Current code is verbose. Is there any way to refactor second method removeCarryReturnsCharacters() via Java 8 streams API?
```
private static StringBuilder readEntireFileUsin... | 2018/05/08 | [
"https://Stackoverflow.com/questions/50227172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7430588/"
] | The current code is not verbose due to the lack of the Stream API, but tons of unnecessary operations:
* the initial assignment `needToRemove = "";` is obsolete
* you are maintaining two redundant loop variables, `delCounter` and `endIndex`
* you are using a `while` loop despite you have a classical counting loop with... | ```
private static StringBuilder removeCarryReturnsCharacters(StringBuilder fileData) {
Stream.iterate(1012, i -> i + 1012)
.limit(fileData.length() / 1014)
.sorted(Collections.reverseOrder())
.forEach(e -> {
if (fileData.substring(e, e + 2).equals("^^")) {
... |
50,227,172 | I'm struggling to delete some characters from StringBuilder. The method works fine. However, I want to achieve the same via Java-8 streams API. Current code is verbose. Is there any way to refactor second method removeCarryReturnsCharacters() via Java 8 streams API?
```
private static StringBuilder readEntireFileUsin... | 2018/05/08 | [
"https://Stackoverflow.com/questions/50227172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7430588/"
] | The current code is not verbose due to the lack of the Stream API, but tons of unnecessary operations:
* the initial assignment `needToRemove = "";` is obsolete
* you are maintaining two redundant loop variables, `delCounter` and `endIndex`
* you are using a `while` loop despite you have a classical counting loop with... | It looks like you are trying to remove `^^` from individual lines of the original file. You might solve this using only `File.lines` and `Stream.map`:
```
List<String> lines = Files.lines(filePath, StandardCharsets.ISO_8859_1)
.map(line -> {
if (line.charAt(endIndex) == '^' && line.charAt(endIndex + 1) == '^') {
... |
70,094,467 | I run into a problem in the code below.
```
fun main() {
val table = mutableListOf(
mutableListOf(' ', ' ', ' '),
mutableListOf(' ', ' ', ' '),
mutableListOf(' ', ' ', ' ')
)
println("---------")
println("| " + table[0][0] + " " + table[0][1] + " " + table[0][2] + " |")
println("| " + table[1][0] + " " + ... | 2021/11/24 | [
"https://Stackoverflow.com/questions/70094467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11080408/"
] | I would suggest to do it like this
```
x = coordinates[0].toIntOrNull() ?: 99
y = coordinates[1].toIntOrNull() ?: 99
```
the difference with `toInt()` and `toIntOrNull()` is that `toIntOrNull()` doesn't throw an exception when it can't turn it into an Int but will return null instead. This can be redirected to a fal... | I've done it this way:
```
print("Enter the coordinates: ")
var coordinates = readLine()!!.split(" ").toMutableList()
while (coordinates[0].length > 1 || coordinates[1].length > 1 || coordinates[0].length > 1 && coordinates[1].length > 1 ) {
println("You should enter numbers!")
print("Enter the coordinates: "... |
40,364,843 | I am trying to group records based on a value from a column, so I can use it to display the information elsewhere. At the moment I have this working if I specify the values in the column -
```
@city_count = People.select('city,count(*)').where("city in ('london', 'paris')").group(:city).count
```
This works fine if... | 2016/11/01 | [
"https://Stackoverflow.com/questions/40364843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2427972/"
] | Just use:
```
@city_count = People.group(:city).count
```
to get counts for all cities. This will include an entry for nil. | A more efficient way would be to use the [distinct and count methods](http://api.rubyonrails.org/classes/ActiveRecord/Calculations.html#method-i-count) together.
```
@city_counts = Person.distinct.count(:city)
```
That way the work is done in the db instead of in Ruby. |
43,931 | My Banjo is fair to good quality and strings 1, 2, 3, and 5 all go up 1/2 step per fret as they are supposed to. The 4th string is tuned to D and I tune it quite flat and it doesn't go up 1/2 step, it continually goes sharp as I go higher up the frets. I see no obvious problems. Could it be something wrong wit the stri... | 2016/04/28 | [
"https://music.stackexchange.com/questions/43931",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/28225/"
] | Are you sure the bridge is rightly positioned? Banjo intonation can some times be tricky, requiring the bridge to be positioned in a slightly oblique orientation to allow proper intonation of both the low and high strings.
Try the harmonics at the octave fret in both the treble and bass D strings (1 and 4 counting up... | If, by the 4th D string, you mean the lowest string of the banjo (there is some confusion about the numbering of banjo strings), then it's most likely that the string is at fault- it's probably not wound heavily enough. Are you sure it's the right kind of string? |
43,422 | For example, I issued an ALTER TABLE statement to create an index on a MEDIUMTEXT field in an InnoDB table that has 134k rows where the size of the index was 255 bytes and the average size of the data in the field is 30k. This command has been running for the last 15 minutes or so (and is the only thing running on the ... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2168/"
] | This is a pretty common request apparently - requested as far back as 2005 on [bugs.mysql.com](http://bugs.mysql.com).
It exists in Oracle already, and is listed as useful, but ["it is not a simple thing to do, so don't expect it to be
implemented soon."](http://bugs.mysql.com/bug.php?id=3926). Although that was 2005 ... | Very old question but at leas mysql 5.7 has a proper answer for this
<https://dev.mysql.com/doc/refman/5.7/en/monitor-alter-table-performance-schema.html>
In essence...
```
UPDATE performance_schema.setup_instruments
SET ENABLED = 'YES'
WHERE NAME LIKE 'stage/innodb/alter%';
UPDATE performance_schema.s... |
43,422 | For example, I issued an ALTER TABLE statement to create an index on a MEDIUMTEXT field in an InnoDB table that has 134k rows where the size of the index was 255 bytes and the average size of the data in the field is 30k. This command has been running for the last 15 minutes or so (and is the only thing running on the ... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2168/"
] | In the case of InnoDB tables, one can use [`SHOW ENGINE INNODB STATUS`](http://dev.mysql.com/doc/refman/5.0/en/show-engine.html) to find the transaction doing the ALTER TABLE and check how many row locks the TX holds. This is the number of processed rows. Explained in detail here:
<http://gabrielcain.com/blog/2009/08/... | if anyone wants a bash solution: (the sql was not working for me)
```
cd /var/lib/mysql/mydb
TABLEFILE="MYTABLE.ibd"
TEMPFILE="\#*ibd"
ls -lah $TABLEFILE;
ls -lah $TEMPFILE; # make sure you have only one temp file or modify the above TEMPFILE
SIZE_TOTAL=$(stat -c %s $TABLEFILE);
# other ways to get 1st size and tim... |
43,422 | For example, I issued an ALTER TABLE statement to create an index on a MEDIUMTEXT field in an InnoDB table that has 134k rows where the size of the index was 255 bytes and the average size of the data in the field is 30k. This command has been running for the last 15 minutes or so (and is the only thing running on the ... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2168/"
] | I was able to perform these 2 queries and figure out how many rows remain to be moved.
```
select count(*) from `myoriginalrable`;
select count(*) from `#sql-1e8_11ae5`;
```
this was WAY more helpful than comparing the file size on disk, because changing from myisam to innodb etc changes the row size. | pt-online-schema-change by Percona shows remaining time estimate. By default it prints out the remaining time estimate and progress percentage every 30 seconds.
It also has additional functions compared to just running the ALTER command by itself.
<http://www.percona.com/doc/percona-toolkit/2.1/pt-online-schema-chang... |
43,422 | For example, I issued an ALTER TABLE statement to create an index on a MEDIUMTEXT field in an InnoDB table that has 134k rows where the size of the index was 255 bytes and the average size of the data in the field is 30k. This command has been running for the last 15 minutes or so (and is the only thing running on the ... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2168/"
] | In the case of InnoDB tables, one can use [`SHOW ENGINE INNODB STATUS`](http://dev.mysql.com/doc/refman/5.0/en/show-engine.html) to find the transaction doing the ALTER TABLE and check how many row locks the TX holds. This is the number of processed rows. Explained in detail here:
<http://gabrielcain.com/blog/2009/08/... | Very old question but at leas mysql 5.7 has a proper answer for this
<https://dev.mysql.com/doc/refman/5.7/en/monitor-alter-table-performance-schema.html>
In essence...
```
UPDATE performance_schema.setup_instruments
SET ENABLED = 'YES'
WHERE NAME LIKE 'stage/innodb/alter%';
UPDATE performance_schema.s... |
43,422 | For example, I issued an ALTER TABLE statement to create an index on a MEDIUMTEXT field in an InnoDB table that has 134k rows where the size of the index was 255 bytes and the average size of the data in the field is 30k. This command has been running for the last 15 minutes or so (and is the only thing running on the ... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2168/"
] | I made a query that estimates the time to finish an alter command on an innodb table. You have to run it at least twice on the same session since it compares stats from consecutive runs to make the estimatation.
Don't forget to change *<tableName>* to the correct table name on the fourth line. It gives you two estimati... | [Percona Server](http://www.percona.com/software/percona-server), which is a branched version of MySQL with some enhancements, has this feature.
You can observe extra columns in SHOW PROCESSLIST for ROWS\_SENT and ROWS\_EXAMINED. For example, if your table has 1000000 rows, and you see ROWS\_EXAMINED of 650000, then i... |
43,422 | For example, I issued an ALTER TABLE statement to create an index on a MEDIUMTEXT field in an InnoDB table that has 134k rows where the size of the index was 255 bytes and the average size of the data in the field is 30k. This command has been running for the last 15 minutes or so (and is the only thing running on the ... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2168/"
] | In the case of InnoDB tables, one can use [`SHOW ENGINE INNODB STATUS`](http://dev.mysql.com/doc/refman/5.0/en/show-engine.html) to find the transaction doing the ALTER TABLE and check how many row locks the TX holds. This is the number of processed rows. Explained in detail here:
<http://gabrielcain.com/blog/2009/08/... | This is a pretty common request apparently - requested as far back as 2005 on [bugs.mysql.com](http://bugs.mysql.com).
It exists in Oracle already, and is listed as useful, but ["it is not a simple thing to do, so don't expect it to be
implemented soon."](http://bugs.mysql.com/bug.php?id=3926). Although that was 2005 ... |
43,422 | For example, I issued an ALTER TABLE statement to create an index on a MEDIUMTEXT field in an InnoDB table that has 134k rows where the size of the index was 255 bytes and the average size of the data in the field is 30k. This command has been running for the last 15 minutes or so (and is the only thing running on the ... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2168/"
] | Run `ls -laShr /var/lib/mysql | sort -h` and you'll see files in the mysql folder something like this:
```
-rw-r----- 1 mysql mysql 3.3G Feb 9 13:21 sql-#2088_10fa.ibd
-rw-r----- 1 mysql mysql 10.2G Feb 9 13:21 posts.ibd
```
You can see original table file and temporary target table file as it's being constructed,... | if anyone wants a bash solution: (the sql was not working for me)
```
cd /var/lib/mysql/mydb
TABLEFILE="MYTABLE.ibd"
TEMPFILE="\#*ibd"
ls -lah $TABLEFILE;
ls -lah $TEMPFILE; # make sure you have only one temp file or modify the above TEMPFILE
SIZE_TOTAL=$(stat -c %s $TABLEFILE);
# other ways to get 1st size and tim... |
43,422 | For example, I issued an ALTER TABLE statement to create an index on a MEDIUMTEXT field in an InnoDB table that has 134k rows where the size of the index was 255 bytes and the average size of the data in the field is 30k. This command has been running for the last 15 minutes or so (and is the only thing running on the ... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2168/"
] | I was able to perform these 2 queries and figure out how many rows remain to be moved.
```
select count(*) from `myoriginalrable`;
select count(*) from `#sql-1e8_11ae5`;
```
this was WAY more helpful than comparing the file size on disk, because changing from myisam to innodb etc changes the row size. | [Percona Server](http://www.percona.com/software/percona-server), which is a branched version of MySQL with some enhancements, has this feature.
You can observe extra columns in SHOW PROCESSLIST for ROWS\_SENT and ROWS\_EXAMINED. For example, if your table has 1000000 rows, and you see ROWS\_EXAMINED of 650000, then i... |
43,422 | For example, I issued an ALTER TABLE statement to create an index on a MEDIUMTEXT field in an InnoDB table that has 134k rows where the size of the index was 255 bytes and the average size of the data in the field is 30k. This command has been running for the last 15 minutes or so (and is the only thing running on the ... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2168/"
] | In the case of InnoDB tables, one can use [`SHOW ENGINE INNODB STATUS`](http://dev.mysql.com/doc/refman/5.0/en/show-engine.html) to find the transaction doing the ALTER TABLE and check how many row locks the TX holds. This is the number of processed rows. Explained in detail here:
<http://gabrielcain.com/blog/2009/08/... | [Percona Server](http://www.percona.com/software/percona-server), which is a branched version of MySQL with some enhancements, has this feature.
You can observe extra columns in SHOW PROCESSLIST for ROWS\_SENT and ROWS\_EXAMINED. For example, if your table has 1000000 rows, and you see ROWS\_EXAMINED of 650000, then i... |
43,422 | For example, I issued an ALTER TABLE statement to create an index on a MEDIUMTEXT field in an InnoDB table that has 134k rows where the size of the index was 255 bytes and the average size of the data in the field is 30k. This command has been running for the last 15 minutes or so (and is the only thing running on the ... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2168/"
] | Very old question but at leas mysql 5.7 has a proper answer for this
<https://dev.mysql.com/doc/refman/5.7/en/monitor-alter-table-performance-schema.html>
In essence...
```
UPDATE performance_schema.setup_instruments
SET ENABLED = 'YES'
WHERE NAME LIKE 'stage/innodb/alter%';
UPDATE performance_schema.s... | if anyone wants a bash solution: (the sql was not working for me)
```
cd /var/lib/mysql/mydb
TABLEFILE="MYTABLE.ibd"
TEMPFILE="\#*ibd"
ls -lah $TABLEFILE;
ls -lah $TEMPFILE; # make sure you have only one temp file or modify the above TEMPFILE
SIZE_TOTAL=$(stat -c %s $TABLEFILE);
# other ways to get 1st size and tim... |
40,508,564 | I have an issue to parse a json using ansible
I have a task that connected to rancher and get a json file
task:
```
- uri:
url: http://rancher.local:8080/v1/hosts
method: GET
user: ##################
password: ################
body_format: json
register: hosts_json
- name: test
set_fact:
... | 2016/11/09 | [
"https://Stackoverflow.com/questions/40508564",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4875299/"
] | This is what [filters](http://docs.ansible.com/ansible/playbooks_filters.html) (and [this](http://jinja.pocoo.org/docs/dev/templates/#list-of-builtin-filters)) for:
```
- set_fact:
hosts_all: "{{ hosts_json.json.data | map(attribute='hostname') | list }}"
hosts_i: "{{ hosts_json.json.data | map(attribute='host... | Try this
```
- uri:
url: http://rancher.local:8080/v1/hosts
method: GET
user: ##################
password: ################
body_format: json
register: hosts_json
- name: init fact
set_fact:
rancher_env_hosts: "[]"
- name: test
set_fact:
rancher_env_hosts: "{{rancher_env_hosts}} + [... |
31,815 | I was on about 87 kg to 88 kg. With my height of 1,94 m, it was pretty damn good in terms of my BMI :) I nearly hit exactly the middle of the target value of a mid-twenty male.
However, I started to train for a run a few weeks ago. I'm running nearly every second day (8 to 11 km) and do a few push-ups (20) and sit-ups... | 2016/08/18 | [
"https://fitness.stackexchange.com/questions/31815",
"https://fitness.stackexchange.com",
"https://fitness.stackexchange.com/users/23303/"
] | BMI is just an average target, being healthy and fit varies per person. I used to be really underweight according to BMI measurements while feeling fine and working out almost daily (cycling, running) and eating properly.
I've started doing weight training about 2 years ago and gained about 20kg (44lbs) in muscle, and... | The respondanse have been correct, B.M.I is a flawed way of measuring fat to bone/muscle. Hip to waist measurements provide far a better idea of how much fat you carry. More sophisticated techniques give accurate measurements but are costly.
What to do??? Not always easy to do, but simple to quantify, use more calories... |
31,815 | I was on about 87 kg to 88 kg. With my height of 1,94 m, it was pretty damn good in terms of my BMI :) I nearly hit exactly the middle of the target value of a mid-twenty male.
However, I started to train for a run a few weeks ago. I'm running nearly every second day (8 to 11 km) and do a few push-ups (20) and sit-ups... | 2016/08/18 | [
"https://fitness.stackexchange.com/questions/31815",
"https://fitness.stackexchange.com",
"https://fitness.stackexchange.com/users/23303/"
] | No, do not use BMI to gauge your fitness level.
First of all, and I love pointing this out; the person who invented the BMI scale said that it should NOT be used to indicate the level of fatness in a person.
Second of all, it was invented between 1830 and 1850. Our knowledge of the human body has evolved so much now,... | The respondanse have been correct, B.M.I is a flawed way of measuring fat to bone/muscle. Hip to waist measurements provide far a better idea of how much fat you carry. More sophisticated techniques give accurate measurements but are costly.
What to do??? Not always easy to do, but simple to quantify, use more calories... |
74,340,744 | ```
lcolhead = ['ID', 'Name', 'Email']
lrow1 = [1, 'Jane Doe', 'janedoe@doemail.com']
lrow2 = [2, 'Jake Doe', 'jakedoe@doemail.com']
lrow3 = [3, 'Jane Fox', 'janefox@foxmail.com']
ltable1 = [lcolhead, lrow1, lrow2, lrow3]
for row in ltable1:
for item in row:
print(item, end=' | ')
```
output is each va... | 2022/11/07 | [
"https://Stackoverflow.com/questions/74340744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20435686/"
] | Using your solution, adding a simple `print()` statement in the outer loop fixes it:
```
lcolhead = ['ID', 'Name', 'Email']
lrow1 = [1, 'Jane Doe', 'janedoe@doemail.com']
lrow2 = [2, 'Jake Doe', 'jakedoe@doemail.com']
lrow3 = [3, 'Jane Fox', 'janefox@foxmail.com']
ltable1 = [lcolhead, lrow1, lrow2, lrow3]
for row in... | ```
for row in ltable1:
print( " | ".join( row) + " | ")
```
But I'm questioning the utility of the last vertical bar. |
36,786,329 | I'm debugging C++ program compiled with MSVC under Windows.
I want to investigate issue linked with multi threading. So I put ASSERT in my code and when program reaches ASSERT it displays window about ASSERT (Standart [Abort], [Retry], [Ignore] window) with proposal to pause program in debugger. I press [Retry] button ... | 2016/04/22 | [
"https://Stackoverflow.com/questions/36786329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2000124/"
] | Select Device in-place of Simulator and then make Archive .
[](https://i.stack.imgur.com/1yhgt.png) | [![enter image description here][1]][1]
[1]: <http://i.stack.imgur.com/VQB3K.png> you need to select the 'Generic Ios device' and the go for product -> Archive |
36,786,329 | I'm debugging C++ program compiled with MSVC under Windows.
I want to investigate issue linked with multi threading. So I put ASSERT in my code and when program reaches ASSERT it displays window about ASSERT (Standart [Abort], [Retry], [Ignore] window) with proposal to pause program in debugger. I press [Retry] button ... | 2016/04/22 | [
"https://Stackoverflow.com/questions/36786329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2000124/"
] | Select Device in-place of Simulator and then make Archive .
[](https://i.stack.imgur.com/1yhgt.png) | select device as Generic IOS Device in devices tab
Goto Project -> Archive -> building of your project start after this organiser window will open
in organiser window there is an option "Export" click on that and save your IPA on to your location |
65,185,821 | I have a text field:
```
<Grid item xs={12} sm={6}>
<BzTextField
fullWidth
label="dec"
value={company.dex}
/>
</Grid>
```
what I am trying to do is to create a new component so I can create a new input type number which must add 3 decimal digits (ex. 3.3 becomes 3.300). I am... | 2020/12/07 | [
"https://Stackoverflow.com/questions/65185821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14618967/"
] | You can do it by creating a controlled input and using input's onBlur feature, which will execute onBlur function when you are done editing the input. This function will change add 3 decimal digits to the number.
```
function App() {
const [input, setInput] = React.useState("")
const onBlur = () => {
setInput(pars... | **Try This:**
```
const x = 3.3;
const y = x.toFixed(3);
console.log(y);
// result 3.300
```
>
> **Explanation:**
>
> here `toFixed(n)` method used to extend value.
>
> *Where `n` is the number you want to extend value of number.*
>
>
>
>
> [Click here for more info](http://www.w3schools.com/js/js_numbe... |
65,185,821 | I have a text field:
```
<Grid item xs={12} sm={6}>
<BzTextField
fullWidth
label="dec"
value={company.dex}
/>
</Grid>
```
what I am trying to do is to create a new component so I can create a new input type number which must add 3 decimal digits (ex. 3.3 becomes 3.300). I am... | 2020/12/07 | [
"https://Stackoverflow.com/questions/65185821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14618967/"
] | You can do it by creating a controlled input and using input's onBlur feature, which will execute onBlur function when you are done editing the input. This function will change add 3 decimal digits to the number.
```
function App() {
const [input, setInput] = React.useState("")
const onBlur = () => {
setInput(pars... | Here's one way you could do it using material. I made the assumption that you don't want the text formatted until focus leaves the control. The onChange event in material fires on every key press so this makes it difficult to format using that event alone.
```
import React, { useState } from 'react';
import { TextFiel... |
39,853,803 | I have the following SQL query.
```
DECLARE
@StartDate DATE ='20160101' ,
@EndDate DATE = '20160331',
@Box1 DECIMAL,
@Box2 DECIMAL,
@Box3 DECIMAL,
@Box4 DECIMAL,
@Box5 DECIMAL,
@Box6 DECIMAL,
@Box7 DECIMAL,
@Box8 DECIMAL,
@Box9 DECIMAL
SET @Box1 = (SELECT ROUND(SUM (vt.Vat)... | 2016/10/04 | [
"https://Stackoverflow.com/questions/39853803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1458985/"
] | ```
@Box4 DECIMAL
^^^ here is your problem
```
You never gave your `DECIMAL` types any precision past the decimal point. Hence, SQL Server is displaying the values with zero digits of precision past the decimal point, i.e. as integers.
Since you seem to want two decimal places of precision, try using this d... | Could you please try following
```
SET @Box4 = (SELECT (ROUND(SUM(vt.VatInput * 1.0),2) + @Box2) FROM VatTransactions vt WHERE vt.VatTransactionDate BETWEEN @StartDate AND @EndDate)
```
You will notice that I'm multiplying the column value with a decimal number 1.0
This will convert the result into a decimal number
... |
24,432,776 | ```
$ cat try1.c
#include<stdio.h>
void main()
{
int arr[]={1,2,3,4};
printf("%lu--%lu--%lu--%lu\n", arr, arr+1, &arr, &arr+1);
}
$ gcc try1.c -o try1
$ ./try1
140736912750144--140736912750148--140736912750144--140736912750160
$ ./try1
140735606483504--140735606483508--140735606483504--140735606483520... | 2014/06/26 | [
"https://Stackoverflow.com/questions/24432776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1091784/"
] | So I did this using css and I attached a [fiddle](http://jsfiddle.net/jeRL6/). Basically, I made the `#child` element 900% of it's parent and also gave it a `margin-left` of the width of the parent, so they didn't overlap. Hope this helps! | If I understand your question correctly, you would wnat to make `#child` **9** times larger than the `#parent` because you set `#parent` width to 10%
Change:
```
width: 90%; /* relative to grandparent */
```
to
```
width: 900%; /* relative to grandparent */
``` |
15,788,223 | I'm using `MVVM` and I want to call a `Command` when I right click on my `ListView`. I made a lot of searches but my problem is not solved.
I use this XAML code
```xaml
<ListView ItemsSource="{Binding LibraryList}"
x:Name="MediaList"
Visibility="{Binding MediaListVisibility}"
Margin="14... | 2013/04/03 | [
"https://Stackoverflow.com/questions/15788223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2051158/"
] | use relative source like this (assume your control is a window)
```
Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}, Path=AddToPlaylistCommand}"
``` | ```
Command="{Binding Path=DataContext.AddToPlaylistCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"
``` |
15,788,223 | I'm using `MVVM` and I want to call a `Command` when I right click on my `ListView`. I made a lot of searches but my problem is not solved.
I use this XAML code
```xaml
<ListView ItemsSource="{Binding LibraryList}"
x:Name="MediaList"
Visibility="{Binding MediaListVisibility}"
Margin="14... | 2013/04/03 | [
"https://Stackoverflow.com/questions/15788223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2051158/"
] | use relative source like this (assume your control is a window)
```
Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}, Path=AddToPlaylistCommand}"
``` | ```
Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.AddToPlaylistCommand}"
``` |
15,788,223 | I'm using `MVVM` and I want to call a `Command` when I right click on my `ListView`. I made a lot of searches but my problem is not solved.
I use this XAML code
```xaml
<ListView ItemsSource="{Binding LibraryList}"
x:Name="MediaList"
Visibility="{Binding MediaListVisibility}"
Margin="14... | 2013/04/03 | [
"https://Stackoverflow.com/questions/15788223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2051158/"
] | ```
Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.AddToPlaylistCommand}"
``` | ```
Command="{Binding Path=DataContext.AddToPlaylistCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"
``` |
32,592,531 | I'm trying to share some content of my AngularJS website in twitter using next link:
```
<a href="https://twitter.com/intent/tweet?text=http%3A%2F%2Fwww.test.yanpy.com%2Fes%2Fblog%2Frutas-para-navegar-por-ibiza-y-formentera">
```
When I click on it, the Twitter share page is opened. However, I would like to use Twit... | 2015/09/15 | [
"https://Stackoverflow.com/questions/32592531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1906131/"
] | This should work:
```
select sub.comments_id, sub.comment, date_format(sub.date, '%b %d %Y'), sub.views
from (select comments_id, comment, date, views from tablename where id=0) as sub;
```
The power of MySQL is in sub selection, take advantage of it. | Use the following query:
```
select date_format(str_to_date(date, '%Y-%m-%d %H:%i:%s'), '%b %d %Y') from tablename;
```
`str_to_date` converts string representation to `date` and `date_format` gets you the required formatted string. |
53,632,545 | Dataframe is like this:
```
ID Start_dt
1 10/14/2018
1 10/24/2018
2 7/12/2018
```
I want to find the the max date from the current and previous row i.e.
```
df.Start_dt.rolling(window=1).max().shift(1).fillna(datetime.timedelta(0),unit='days')
```
I get the error that ops is not implemented on rolling... | 2018/12/05 | [
"https://Stackoverflow.com/questions/53632545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6403976/"
] | IIUC, you can use [`Series.rolling.max`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.core.window.Rolling.max.html):
```
dts = pd.to_datetime(df['Start_dt'], errors='coerce')
df['New_col'] = (
pd.to_datetime(dts.astype(int).rolling(2).max()).dt.strftime('%m/%d/%Y'))
ID Start_dt New_col
... | ```
df['Start_dt']=pd.to_datetime(df['Start_dt'])
m=df['Start_dt'] > df['Start_dt'].shift()
df['new_col']=np.where(m,df['Start_dt'],df['Start_dt'].shift())
print(df)
# ID Start_dt new_col
#0 1 2018-10-14 NaT
#1 1 2018-10-24 2018-10-24
#2 2 2018-07-12 2018-10-24
``` |
6,138,787 | I have an Object which comes and has a bunch of public attributes and no getters and setters. BAD!
So I created a class with the attributes and created getters and setters for them. My plan is to wrap the object in my class so it means no direct access to attributes.
I'm kind of unsure how to do this. I understand cas... | 2011/05/26 | [
"https://Stackoverflow.com/questions/6138787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/518004/"
] | Maybe like this?
```
class MyCar implements ICar{
private final Car car;
public MyCar(Car car)
{
this.car = car;
}
public string getModel()
{
return car.model;
}
public void setModel(string value)
{
car.model = value;
}
}
```
now instead of pas... | Use composition. If you class with public properties is called Exposed, just do
```
public class ExposedProtector {
private Exposed exposed; // private means it can't be accessed directly from its container
//public/protected methods here to proxy the access to the exposed.
}
```
Note that nothing will pr... |
6,138,787 | I have an Object which comes and has a bunch of public attributes and no getters and setters. BAD!
So I created a class with the attributes and created getters and setters for them. My plan is to wrap the object in my class so it means no direct access to attributes.
I'm kind of unsure how to do this. I understand cas... | 2011/05/26 | [
"https://Stackoverflow.com/questions/6138787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/518004/"
] | Maybe like this?
```
class MyCar implements ICar{
private final Car car;
public MyCar(Car car)
{
this.car = car;
}
public string getModel()
{
return car.model;
}
public void setModel(string value)
{
car.model = value;
}
}
```
now instead of pas... | If you want your class to be plug-compatible with the original class (meaning that client code does not need to change variable types), then your class will have to be a subclass of the class that the client code expects. In that case, you cannot hide the public variables, although you can easily add getters and setter... |
6,926,442 | I want to have an XML attribute without any value, which simply has one meaning when it exists or does not exist.
Is that valid? | 2011/08/03 | [
"https://Stackoverflow.com/questions/6926442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/876594/"
] | No.
Boolean attributes in XML are of the form `foo="foo"`.
Even in SGML, you must provide the value, (it is the name, `=` and quotes that you can omit, which is why you have things like `<select multiple>` in HTML). | You can have an attribute whose only permitted value is the empty string, "". I'm not sure it's good design, though; I would normally suggest a boolean attribute with values true/false, and a default value of false. |
6,926,442 | I want to have an XML attribute without any value, which simply has one meaning when it exists or does not exist.
Is that valid? | 2011/08/03 | [
"https://Stackoverflow.com/questions/6926442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/876594/"
] | An attribute must be specified with the following syntax:
>
> Name Eq AttValue
>
>
>
where Name is a [legal XML name](http://www.w3.org/TR/xml/#NT-Name), Eq is [= optionally preceded or followed by whitespace](http://www.w3.org/TR/xml/#NT-Eq), and AttValue is a [legal attribute value](http://www.w3.org/TR/xml/#N... | No.
Boolean attributes in XML are of the form `foo="foo"`.
Even in SGML, you must provide the value, (it is the name, `=` and quotes that you can omit, which is why you have things like `<select multiple>` in HTML). |
6,926,442 | I want to have an XML attribute without any value, which simply has one meaning when it exists or does not exist.
Is that valid? | 2011/08/03 | [
"https://Stackoverflow.com/questions/6926442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/876594/"
] | An attribute must be specified with the following syntax:
>
> Name Eq AttValue
>
>
>
where Name is a [legal XML name](http://www.w3.org/TR/xml/#NT-Name), Eq is [= optionally preceded or followed by whitespace](http://www.w3.org/TR/xml/#NT-Eq), and AttValue is a [legal attribute value](http://www.w3.org/TR/xml/#N... | You can have an attribute whose only permitted value is the empty string, "". I'm not sure it's good design, though; I would normally suggest a boolean attribute with values true/false, and a default value of false. |
19,343,901 | I have a little question. I want to write a function in javascript and the function needs to take two extra parameters, for when the function is true and false. But I don't know how to write it. So, I want something like this:
```
function greater (para1, para2, casetrue, casefalse) {
if (para1 > para2) {
c... | 2013/10/13 | [
"https://Stackoverflow.com/questions/19343901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2815780/"
] | try this way, otherwise you'll be returning a function:
```
function greater (para1,para2,casetrue,casefalse) {
if (para1 > para2) {
return casetrue();
} else {
return casefalse();
}
}
``` | ```
function greater (para1, para2, casetrue, casefalse) {
if (para1 > para2) {
return casetrue();
}
else {
return casefalse();
}
}
``` |
19,343,901 | I have a little question. I want to write a function in javascript and the function needs to take two extra parameters, for when the function is true and false. But I don't know how to write it. So, I want something like this:
```
function greater (para1, para2, casetrue, casefalse) {
if (para1 > para2) {
c... | 2013/10/13 | [
"https://Stackoverflow.com/questions/19343901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2815780/"
] | try this way, otherwise you'll be returning a function:
```
function greater (para1,para2,casetrue,casefalse) {
if (para1 > para2) {
return casetrue();
} else {
return casefalse();
}
}
``` | To make the function *greater* return "is greater" or "is smaller" one must return the return value of the parameter functions:
```
function greater(para1, para2, casetrue, casefalse) {
return (para1 > para2) ? casetrue() : casefalse();
}
```
Tested on Firefox 24.0 / Linux |
19,343,901 | I have a little question. I want to write a function in javascript and the function needs to take two extra parameters, for when the function is true and false. But I don't know how to write it. So, I want something like this:
```
function greater (para1, para2, casetrue, casefalse) {
if (para1 > para2) {
c... | 2013/10/13 | [
"https://Stackoverflow.com/questions/19343901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2815780/"
] | try this way, otherwise you'll be returning a function:
```
function greater (para1,para2,casetrue,casefalse) {
if (para1 > para2) {
return casetrue();
} else {
return casefalse();
}
}
``` | Like has been suggested in other answers, the `greater` function is returning functions instead of strings. If this is the desired behavior, you can call the returned function with an extra pair of brackets:
```
greater(5,3, function() {return "is greater"},function() {return "is smaller"})()
``` |
23,687,672 | The scenario: I need to give models access to API tokens stored in the session.
-------------------------------------------------------------------------------
**Background:** I have an API-driven rails 3 application utilizing DataMapper(DM) and a DM adapter to interface with the API. Each DM model has a corresponding... | 2014/05/15 | [
"https://Stackoverflow.com/questions/23687672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/836205/"
] | I set the current user and the request information on my User model using the [request\_store](https://github.com/steveklabnik/request_store) gem which is just a tiny shim over thread local storage with a bit of clean-up.
This makes the information available from any of my models via the User class. I have `User.curre... | Use Thread.current, which is passed in from request to model (note, this breaks if, inside your request, you use sub-threads). You can store the attribute you want to share in a cattr\_accessor or in rails cache:
in a cattr\_accessor
```
class YourClass
cattr_accessor :my_var_hash
...
# and in your controller
#... |
2,699,931 | Currently, if you click item 2, it will reveal a input box and also widen the `<li>`. I don't want it to alter the size of the `<li>` and I want it to open right beneath item 2. How can i achieve this? Also, I want to make it close on click after it's been opened, but my jQuery doesn't seem to work.
```
<html>
<head>
... | 2010/04/23 | [
"https://Stackoverflow.com/questions/2699931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/170365/"
] | To hide the field, replace `click` in your code with `toggle`. | This alteration should do the trick.
```
<li id="menu"> <div style="display:block">Item 2 </div>
<fieldset id="field1" style="display: none;">
<form>
<input type="text">
</form>
</fieldset>
</li>
```
To close it the jquery command would be
```
$('#menu').click(function(){
$... |
1,484,952 | I am new to ruby and currently trying to operate on each character separately from a base String in ruby. I am using ruby 1.8.6 and would like to do something like:
```
"ABCDEFG".each_char do |i|
puts i
end
```
This produces a undefined method `each\_char' error.
I was expecting to see a vertical output of:
```
... | 2009/09/28 | [
"https://Stackoverflow.com/questions/1484952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/106467/"
] | ```
"ABCDEFG".chars.each do |char|
puts char
end
```
also
```
"ABCDEFG".each_char {|char| p char}
```
Ruby version >2.5.1 | But now you can do much more:
```
a = "cruel world"
a.scan(/\w+/) #=> ["cruel", "world"]
a.scan(/.../) #=> ["cru", "el ", "wor"]
a.scan(/(...)/) #=> [["cru"], ["el "], ["wor"]]
a.scan(/(..)(..)/) #=> [["cr", "ue"], ["l ", "wo"]]
``` |
1,484,952 | I am new to ruby and currently trying to operate on each character separately from a base String in ruby. I am using ruby 1.8.6 and would like to do something like:
```
"ABCDEFG".each_char do |i|
puts i
end
```
This produces a undefined method `each\_char' error.
I was expecting to see a vertical output of:
```
... | 2009/09/28 | [
"https://Stackoverflow.com/questions/1484952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/106467/"
] | Extending la\_f0ka's comment, esp. if you also need the index position in your code, you should be able to do
```
s = 'ABCDEFG'
for pos in 0...s.length
puts s[pos].chr
end
```
The `.chr` is important as Ruby < 1.9 [returns the code of the character at that position](http://www.ruby-doc.org/core-1.8.6/String.html... | Returns an array of characters in str. This is a shorthand for str.each\_char.to\_a. If a block is given, which is a deprecated form, works the same as each\_char.
### from [ruby-doc.org](https://ruby-doc.org/core-3.0.0/String.html#method-i-chars)
**also now you can do string.chars** |
1,484,952 | I am new to ruby and currently trying to operate on each character separately from a base String in ruby. I am using ruby 1.8.6 and would like to do something like:
```
"ABCDEFG".each_char do |i|
puts i
end
```
This produces a undefined method `each\_char' error.
I was expecting to see a vertical output of:
```
... | 2009/09/28 | [
"https://Stackoverflow.com/questions/1484952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/106467/"
] | ```
"ABCDEFG".chars.each do |char|
puts char
end
```
also
```
"ABCDEFG".each_char {|char| p char}
```
Ruby version >2.5.1 | there is really a problem in 1.8.6.
and it's ok after this edition
in 1.8.6,you can add this:
```
requre 'jcode'
``` |
1,484,952 | I am new to ruby and currently trying to operate on each character separately from a base String in ruby. I am using ruby 1.8.6 and would like to do something like:
```
"ABCDEFG".each_char do |i|
puts i
end
```
This produces a undefined method `each\_char' error.
I was expecting to see a vertical output of:
```
... | 2009/09/28 | [
"https://Stackoverflow.com/questions/1484952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/106467/"
] | I have the same problem. I usually resort to `String#split`:
```
"ABCDEFG".split("").each do |i|
puts i
end
```
I guess you could also implement it yourself like this:
```
class String
def each_char
self.split("").each { |i| yield i }
end
end
```
**Edit:** yet another alternative is `String#each_byte`, ... | Returns an array of characters in str. This is a shorthand for str.each\_char.to\_a. If a block is given, which is a deprecated form, works the same as each\_char.
### from [ruby-doc.org](https://ruby-doc.org/core-3.0.0/String.html#method-i-chars)
**also now you can do string.chars** |
1,484,952 | I am new to ruby and currently trying to operate on each character separately from a base String in ruby. I am using ruby 1.8.6 and would like to do something like:
```
"ABCDEFG".each_char do |i|
puts i
end
```
This produces a undefined method `each\_char' error.
I was expecting to see a vertical output of:
```
... | 2009/09/28 | [
"https://Stackoverflow.com/questions/1484952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/106467/"
] | ```
"ABCDEFG".chars.each do |char|
puts char
end
```
also
```
"ABCDEFG".each_char {|char| p char}
```
Ruby version >2.5.1 | Returns an array of characters in str. This is a shorthand for str.each\_char.to\_a. If a block is given, which is a deprecated form, works the same as each\_char.
### from [ruby-doc.org](https://ruby-doc.org/core-3.0.0/String.html#method-i-chars)
**also now you can do string.chars** |
1,484,952 | I am new to ruby and currently trying to operate on each character separately from a base String in ruby. I am using ruby 1.8.6 and would like to do something like:
```
"ABCDEFG".each_char do |i|
puts i
end
```
This produces a undefined method `each\_char' error.
I was expecting to see a vertical output of:
```
... | 2009/09/28 | [
"https://Stackoverflow.com/questions/1484952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/106467/"
] | Extending la\_f0ka's comment, esp. if you also need the index position in your code, you should be able to do
```
s = 'ABCDEFG'
for pos in 0...s.length
puts s[pos].chr
end
```
The `.chr` is important as Ruby < 1.9 [returns the code of the character at that position](http://www.ruby-doc.org/core-1.8.6/String.html... | there is really a problem in 1.8.6.
and it's ok after this edition
in 1.8.6,you can add this:
```
requre 'jcode'
``` |
1,484,952 | I am new to ruby and currently trying to operate on each character separately from a base String in ruby. I am using ruby 1.8.6 and would like to do something like:
```
"ABCDEFG".each_char do |i|
puts i
end
```
This produces a undefined method `each\_char' error.
I was expecting to see a vertical output of:
```
... | 2009/09/28 | [
"https://Stackoverflow.com/questions/1484952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/106467/"
] | I have the same problem. I usually resort to `String#split`:
```
"ABCDEFG".split("").each do |i|
puts i
end
```
I guess you could also implement it yourself like this:
```
class String
def each_char
self.split("").each { |i| yield i }
end
end
```
**Edit:** yet another alternative is `String#each_byte`, ... | there is really a problem in 1.8.6.
and it's ok after this edition
in 1.8.6,you can add this:
```
requre 'jcode'
``` |
1,484,952 | I am new to ruby and currently trying to operate on each character separately from a base String in ruby. I am using ruby 1.8.6 and would like to do something like:
```
"ABCDEFG".each_char do |i|
puts i
end
```
This produces a undefined method `each\_char' error.
I was expecting to see a vertical output of:
```
... | 2009/09/28 | [
"https://Stackoverflow.com/questions/1484952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/106467/"
] | I have the same problem. I usually resort to `String#split`:
```
"ABCDEFG".split("").each do |i|
puts i
end
```
I guess you could also implement it yourself like this:
```
class String
def each_char
self.split("").each { |i| yield i }
end
end
```
**Edit:** yet another alternative is `String#each_byte`, ... | Extending la\_f0ka's comment, esp. if you also need the index position in your code, you should be able to do
```
s = 'ABCDEFG'
for pos in 0...s.length
puts s[pos].chr
end
```
The `.chr` is important as Ruby < 1.9 [returns the code of the character at that position](http://www.ruby-doc.org/core-1.8.6/String.html... |
1,484,952 | I am new to ruby and currently trying to operate on each character separately from a base String in ruby. I am using ruby 1.8.6 and would like to do something like:
```
"ABCDEFG".each_char do |i|
puts i
end
```
This produces a undefined method `each\_char' error.
I was expecting to see a vertical output of:
```
... | 2009/09/28 | [
"https://Stackoverflow.com/questions/1484952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/106467/"
] | Extending la\_f0ka's comment, esp. if you also need the index position in your code, you should be able to do
```
s = 'ABCDEFG'
for pos in 0...s.length
puts s[pos].chr
end
```
The `.chr` is important as Ruby < 1.9 [returns the code of the character at that position](http://www.ruby-doc.org/core-1.8.6/String.html... | ```
"ABCDEFG".chars.each do |char|
puts char
end
```
also
```
"ABCDEFG".each_char {|char| p char}
```
Ruby version >2.5.1 |
1,484,952 | I am new to ruby and currently trying to operate on each character separately from a base String in ruby. I am using ruby 1.8.6 and would like to do something like:
```
"ABCDEFG".each_char do |i|
puts i
end
```
This produces a undefined method `each\_char' error.
I was expecting to see a vertical output of:
```
... | 2009/09/28 | [
"https://Stackoverflow.com/questions/1484952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/106467/"
] | I have the same problem. I usually resort to `String#split`:
```
"ABCDEFG".split("").each do |i|
puts i
end
```
I guess you could also implement it yourself like this:
```
class String
def each_char
self.split("").each { |i| yield i }
end
end
```
**Edit:** yet another alternative is `String#each_byte`, ... | But now you can do much more:
```
a = "cruel world"
a.scan(/\w+/) #=> ["cruel", "world"]
a.scan(/.../) #=> ["cru", "el ", "wor"]
a.scan(/(...)/) #=> [["cru"], ["el "], ["wor"]]
a.scan(/(..)(..)/) #=> [["cr", "ue"], ["l ", "wo"]]
``` |
329,253 | I am trying to understand pMOSFET. I searched online tutorial saying that pMOSFET is like a closed switch if V(gs) < V(threshold), like a open switch if V(gs) > V(threshold), V(threshold) typically -1.5V.
But when I do an online simulation, it show the following result. Does anyone know why the left one has current f... | 2017/09/14 | [
"https://electronics.stackexchange.com/questions/329253",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/161908/"
] | MOSFETs have a **body diode** which will conduct when the MOSFET is "backwards biased": in the case of a PMOS, when the drain-source voltage is greater than a diode drop.
It helps to have a MOSFET symbol which has the body diode included:
[](https://i.stack.... | In a P-channel MOSFET, the source needs to be more positive than the drain, otherwise the terminals switch roles. That means that in figure 1, the bottom electrode is acting as the source even though it is supposed to be the drain. In this case, Vgs is -5, since the gate is at 0V and the source is at +5.
Second, the M... |
540,910 | While loading YouTube videos on Ubuntu 14.4 my screen goes black and yet everything still works, lights on the keyboard and the video plays. No amount of pressing buttons (ctrl+alt+f1, power button, mouse clicks etc..) can get the screen to turn on again. I've had ubuntu 14.4 for a few months now and this error started... | 2014/10/24 | [
"https://askubuntu.com/questions/540910",
"https://askubuntu.com",
"https://askubuntu.com/users/185988/"
] | As @AE indicates you can turn off hardware acceleration in chrome in the settings by chrome://settings/ -> 'advanced settings' -> untick 'use hardware acceleration' and restart chrome.
In Firefox It's here:

A restart may be required here as well. | I think your problem maybe caused by adobe-flash. You can update your adobe flash plugin(<https://get.adobe.com/cn/flashplayer/>) or watch Youtube videos in a html5 format(recommended).(turn it on at <https://www.youtube.com/html5>)
Hope can help you. |
6,210,901 | I want to convert the integer into char.
Example:-
```
char c;
for(int i=0;i<10;i++){
system.out.println(" char==="+c);
}
```
I want to print the c as 0,1,2,3,4.....
I had tried :-
```
c=(char)i; --gives error
c=97-i; -----gives a,b,c
``` | 2011/06/02 | [
"https://Stackoverflow.com/questions/6210901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/755094/"
] | Use wrapper classes.
```
c = new Integer(i).toString().charAt(0);
```
by the way, you can also use this :
```
c = (char)(i + 48);
``` | `Character.forDigit()`
<http://download.oracle.com/javase/6/docs/api/java/lang/Character.html> |
26,666,106 | I'm on OSX, with protractor version 1.3.1 installed. If I put browser.debugger() in my test and run with
$ protractor debug test/protractor.conf.js
I go into the debugger screen. Then I hit "c" and it seems to stop at my breakpoint.
However, nothing seems to be in scope, everything comes up as undefined.
debug> brow... | 2014/10/31 | [
"https://Stackoverflow.com/questions/26666106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1108964/"
] | Most of the time is likely be taken by the RSA decryption of the session keys. RSA is much slower than AES. Probably the best thing to do is to create a session single key for multiple fields and decrypt that once. Currently they are all dependent on the same private key anyway, so it would not matter much with regards... | Maybe you can use multiple ajax request to simulate multithreading decryption. |
50,652,685 | I'm trying to connect Ajax with Symfony 4. I need to send some data to my Controller.
JavaScript:
```
$(function() {
$('#sortable').sortable({
axis: 'y',
opacity: 0.7,
update: function(event, ui) {
var list_sortable = $(this).sortable('toArray').toString();
$.aja... | 2018/06/02 | [
"https://Stackoverflow.com/questions/50652685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9834839/"
] | like this javascript code in html:
```
var requestPath = '{{path(app_bundle_route)}}';
```
and use variable name in js file | Actually, this worked for me:
```
var requestPath = "{{path('app_bundle_route')}}";
``` |
17,414,924 | I'm writing unit tests for AtomicInteger and AtomicBoolean. They are going to be used as reference tests for testing emulations of these classes in objective-c, for use in translated projects.
The AtomicInteger test worked out well I think, basically by performing a predictable number of increment, decrement, add and ... | 2013/07/01 | [
"https://Stackoverflow.com/questions/17414924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/741217/"
] | I would concentrate on `compareAndSet`, which is the real difference between an `AtomicBoolean` and an ordinary `boolean`.
For example, use `compareAndSet(false, true)` to control a critical region. Loop doing it until it returns false, then enter the critical region. In the critical region, do something that is very ... | It is four atomic operations. Given you just want one boolean to be the inverse of the other, just have one boolean and keep toggling that. You can calculate the other from this value. |
17,414,924 | I'm writing unit tests for AtomicInteger and AtomicBoolean. They are going to be used as reference tests for testing emulations of these classes in objective-c, for use in translated projects.
The AtomicInteger test worked out well I think, basically by performing a predictable number of increment, decrement, add and ... | 2013/07/01 | [
"https://Stackoverflow.com/questions/17414924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/741217/"
] | I think it's going to be harder to test this than an `AtomicInteger`, as you point out. The space of possible values is much smaller, and thus the space of possible things-that-can-go-wrong is much smaller. Since tests like this basically come down to luck (with lots of looping to increase your chances), it's going to ... | It is four atomic operations. Given you just want one boolean to be the inverse of the other, just have one boolean and keep toggling that. You can calculate the other from this value. |
17,414,924 | I'm writing unit tests for AtomicInteger and AtomicBoolean. They are going to be used as reference tests for testing emulations of these classes in objective-c, for use in translated projects.
The AtomicInteger test worked out well I think, basically by performing a predictable number of increment, decrement, add and ... | 2013/07/01 | [
"https://Stackoverflow.com/questions/17414924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/741217/"
] | I would concentrate on `compareAndSet`, which is the real difference between an `AtomicBoolean` and an ordinary `boolean`.
For example, use `compareAndSet(false, true)` to control a critical region. Loop doing it until it returns false, then enter the critical region. In the critical region, do something that is very ... | I think it's going to be harder to test this than an `AtomicInteger`, as you point out. The space of possible values is much smaller, and thus the space of possible things-that-can-go-wrong is much smaller. Since tests like this basically come down to luck (with lots of looping to increase your chances), it's going to ... |
55,019,248 | I've got a search box that I'm providing autocomplete suggestions for but it's really slow, it takes multiple seconds for suggestions to appear. I'm pretty sure my code is inefficient but I'm not sure the best way to improve it, any suggestions?
```
[HttpPost]
[Route("search")]
public virtual JsonResult Search... | 2019/03/06 | [
"https://Stackoverflow.com/questions/55019248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11158671/"
] | I think that the main problem is that you're using `.FindAll()` which returns a `List<T>`.
This means that when you say `CardRepository.FindAll()` it gets all of the records into an in-memory list and then your subsequent refining queries (e.g. `Where(x => x.Name.ToLower().Contains(query))` and so on) are all run agai... | You could use multi-threading like this (pseudo-C# code):
```
var allCards = CardRepository.FindAll().ToArray(); // Ensure array.
query = query.ToUpper();
var nameTask = Task.StartNew(() => allCards.Where(x => x.Name.ToUpper().Contains(query)).ToArray());
var setTask = Task.StartNew(() => allCards.Where(x => x.Set.Se... |
47,564,765 | I have this recursive function:
F(n)=4F(n-1)+F(n-2), for all n>=2, where F(0)=0 and F(1)=1.
This is my code in python
```
def f(n):
res = 0;
if n == 0:
return 0
elif n == 1:
return 1
else:
res=(4*(f(n-1)))+f(n-2)
return res
print f(2424)
```
And the method in Java... | 2017/11/30 | [
"https://Stackoverflow.com/questions/47564765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7476317/"
] | Let's look at one example `n == 5` that will call `f(4)` and `f(3)`. those in turn will call `f(3)`, `f(2)`, `f(2)` again and `f(1)`. As you can see there is a lot of superfluous evaluations, and this snowballs when you go to larger `n`.
So, just keep track of what you've already computed and things will speed up dram... | You can use the matrix exponentiation method for O(logn)
Here's a link that explains it and how to implement it
<http://www.geeksforgeeks.org/matrix-exponentiation/> |
47,564,765 | I have this recursive function:
F(n)=4F(n-1)+F(n-2), for all n>=2, where F(0)=0 and F(1)=1.
This is my code in python
```
def f(n):
res = 0;
if n == 0:
return 0
elif n == 1:
return 1
else:
res=(4*(f(n-1)))+f(n-2)
return res
print f(2424)
```
And the method in Java... | 2017/11/30 | [
"https://Stackoverflow.com/questions/47564765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7476317/"
] | Lets check by the exact value of that recurrence relation
```
F(n)=4F(n-1)+F(n-2) = 1/10*(2+sqrt(5))^n*sqrt(5)-1/10*(2-sqrt(5))^n*sqrt(5)
```
F(10) = 416020.0
Well this is very hardcore recurrence, and running time is huge. Take a look on this figure:
[](https://... | You can use the matrix exponentiation method for O(logn)
Here's a link that explains it and how to implement it
<http://www.geeksforgeeks.org/matrix-exponentiation/> |
47,564,765 | I have this recursive function:
F(n)=4F(n-1)+F(n-2), for all n>=2, where F(0)=0 and F(1)=1.
This is my code in python
```
def f(n):
res = 0;
if n == 0:
return 0
elif n == 1:
return 1
else:
res=(4*(f(n-1)))+f(n-2)
return res
print f(2424)
```
And the method in Java... | 2017/11/30 | [
"https://Stackoverflow.com/questions/47564765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7476317/"
] | You can use the matrix exponentiation method for O(logn)
Here's a link that explains it and how to implement it
<http://www.geeksforgeeks.org/matrix-exponentiation/> | There is nothing more you can do really with a high level presentation language. If you really want the best optimization possible, you will need to go assembly. But once you reach that level, you will realize that not much will change. Why? Look at the code. There is not much to optimize. If you go C, you might find g... |
47,564,765 | I have this recursive function:
F(n)=4F(n-1)+F(n-2), for all n>=2, where F(0)=0 and F(1)=1.
This is my code in python
```
def f(n):
res = 0;
if n == 0:
return 0
elif n == 1:
return 1
else:
res=(4*(f(n-1)))+f(n-2)
return res
print f(2424)
```
And the method in Java... | 2017/11/30 | [
"https://Stackoverflow.com/questions/47564765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7476317/"
] | Let's look at one example `n == 5` that will call `f(4)` and `f(3)`. those in turn will call `f(3)`, `f(2)`, `f(2)` again and `f(1)`. As you can see there is a lot of superfluous evaluations, and this snowballs when you go to larger `n`.
So, just keep track of what you've already computed and things will speed up dram... | Lets check by the exact value of that recurrence relation
```
F(n)=4F(n-1)+F(n-2) = 1/10*(2+sqrt(5))^n*sqrt(5)-1/10*(2-sqrt(5))^n*sqrt(5)
```
F(10) = 416020.0
Well this is very hardcore recurrence, and running time is huge. Take a look on this figure:
[](https://... |
47,564,765 | I have this recursive function:
F(n)=4F(n-1)+F(n-2), for all n>=2, where F(0)=0 and F(1)=1.
This is my code in python
```
def f(n):
res = 0;
if n == 0:
return 0
elif n == 1:
return 1
else:
res=(4*(f(n-1)))+f(n-2)
return res
print f(2424)
```
And the method in Java... | 2017/11/30 | [
"https://Stackoverflow.com/questions/47564765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7476317/"
] | Let's look at one example `n == 5` that will call `f(4)` and `f(3)`. those in turn will call `f(3)`, `f(2)`, `f(2)` again and `f(1)`. As you can see there is a lot of superfluous evaluations, and this snowballs when you go to larger `n`.
So, just keep track of what you've already computed and things will speed up dram... | There is nothing more you can do really with a high level presentation language. If you really want the best optimization possible, you will need to go assembly. But once you reach that level, you will realize that not much will change. Why? Look at the code. There is not much to optimize. If you go C, you might find g... |
47,564,765 | I have this recursive function:
F(n)=4F(n-1)+F(n-2), for all n>=2, where F(0)=0 and F(1)=1.
This is my code in python
```
def f(n):
res = 0;
if n == 0:
return 0
elif n == 1:
return 1
else:
res=(4*(f(n-1)))+f(n-2)
return res
print f(2424)
```
And the method in Java... | 2017/11/30 | [
"https://Stackoverflow.com/questions/47564765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7476317/"
] | Let's look at one example `n == 5` that will call `f(4)` and `f(3)`. those in turn will call `f(3)`, `f(2)`, `f(2)` again and `f(1)`. As you can see there is a lot of superfluous evaluations, and this snowballs when you go to larger `n`.
So, just keep track of what you've already computed and things will speed up dram... | A more elegant solution can be implemented using the decorator `@lru_cache`.
This avoids the hassle of keeping track an storing computed values under a `for` loop.
Compare these two implementations.
* Without using decorator
In my machine, takes ~**1 minute** to execute `fibonacci_recursive(40)`
```py
def fibonacc... |
47,564,765 | I have this recursive function:
F(n)=4F(n-1)+F(n-2), for all n>=2, where F(0)=0 and F(1)=1.
This is my code in python
```
def f(n):
res = 0;
if n == 0:
return 0
elif n == 1:
return 1
else:
res=(4*(f(n-1)))+f(n-2)
return res
print f(2424)
```
And the method in Java... | 2017/11/30 | [
"https://Stackoverflow.com/questions/47564765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7476317/"
] | Lets check by the exact value of that recurrence relation
```
F(n)=4F(n-1)+F(n-2) = 1/10*(2+sqrt(5))^n*sqrt(5)-1/10*(2-sqrt(5))^n*sqrt(5)
```
F(10) = 416020.0
Well this is very hardcore recurrence, and running time is huge. Take a look on this figure:
[](https://... | There is nothing more you can do really with a high level presentation language. If you really want the best optimization possible, you will need to go assembly. But once you reach that level, you will realize that not much will change. Why? Look at the code. There is not much to optimize. If you go C, you might find g... |
47,564,765 | I have this recursive function:
F(n)=4F(n-1)+F(n-2), for all n>=2, where F(0)=0 and F(1)=1.
This is my code in python
```
def f(n):
res = 0;
if n == 0:
return 0
elif n == 1:
return 1
else:
res=(4*(f(n-1)))+f(n-2)
return res
print f(2424)
```
And the method in Java... | 2017/11/30 | [
"https://Stackoverflow.com/questions/47564765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7476317/"
] | Lets check by the exact value of that recurrence relation
```
F(n)=4F(n-1)+F(n-2) = 1/10*(2+sqrt(5))^n*sqrt(5)-1/10*(2-sqrt(5))^n*sqrt(5)
```
F(10) = 416020.0
Well this is very hardcore recurrence, and running time is huge. Take a look on this figure:
[](https://... | A more elegant solution can be implemented using the decorator `@lru_cache`.
This avoids the hassle of keeping track an storing computed values under a `for` loop.
Compare these two implementations.
* Without using decorator
In my machine, takes ~**1 minute** to execute `fibonacci_recursive(40)`
```py
def fibonacc... |
47,564,765 | I have this recursive function:
F(n)=4F(n-1)+F(n-2), for all n>=2, where F(0)=0 and F(1)=1.
This is my code in python
```
def f(n):
res = 0;
if n == 0:
return 0
elif n == 1:
return 1
else:
res=(4*(f(n-1)))+f(n-2)
return res
print f(2424)
```
And the method in Java... | 2017/11/30 | [
"https://Stackoverflow.com/questions/47564765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7476317/"
] | A more elegant solution can be implemented using the decorator `@lru_cache`.
This avoids the hassle of keeping track an storing computed values under a `for` loop.
Compare these two implementations.
* Without using decorator
In my machine, takes ~**1 minute** to execute `fibonacci_recursive(40)`
```py
def fibonacc... | There is nothing more you can do really with a high level presentation language. If you really want the best optimization possible, you will need to go assembly. But once you reach that level, you will realize that not much will change. Why? Look at the code. There is not much to optimize. If you go C, you might find g... |
6,532,360 | Hi i am trying to execute this query but every time i run in the emulator, it shows force close message. Someone plz tell me **whats wrong in the query?**
```
public String searchRecord(String f) {
Cursor cur= db.query(DATABASE_TABLE,new String[] { UserName, Age, Sex,DOB} , UserName +" like 'sa%'" , null ,null ,nul... | 2011/06/30 | [
"https://Stackoverflow.com/questions/6532360",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/809715/"
] | Just a thought create custom view with your alert text and button and show it as UIAlertView. Clicking on button hide that view. Which will solve your purpose. Below Code you can use for the same. Plz adjust x/y/height/width as per your requirement.
```
UIView *customAlert = [[UIView alloc] initWithFrame:CGRectMake(10... | Swift Solution:
```
// Define a view
var popup:UIView!
func showAlert() {
// customise your view
popup = UIView(frame: CGRect(x: 100, y: 200, width: 200, height: 200))
popup.backgroundColor = UIColor.redColor()
// show on screen
self.view.addSubview(popup)
}
func dismissView(){
// ... |
536,297 | In the old times of `mathptmx`, we wrote stuff such as
```
\documentclass{article}
\pagestyle{empty}
\usepackage{mathptmx}
\begin{document}
Let \(\mathcal{X}=\{X_1,\ldots,X_n\}\).
\end{document}
```
and got from `pdflatex` a fancy calligraphic math , which was sufficiently fancy to be visibly distinct from the remai... | 2020/04/01 | [
"https://tex.stackexchange.com/questions/536297",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/-1/"
] | You can get the desired *X* by loading the `mathrsfs` ("Ralph Smith's Formal Script") font package and writing `\mathscr{X}`.
[](https://i.stack.imgur.com/rHg0G.png)
```
\documentclass{article}
\usepackage{newtxtext,newtxmath}
\usepackage{mathrsfs}
... | mathptmx uses this font here:
```
\documentclass{article}
\pagestyle{empty}
\usepackage{newtxmath}
\DeclareMathAlphabet{\mathcal}{OMS}{ztmcm}{m}{n}
\begin{document}
Let \(\mathcal{X}=\{X_1,\ldots,X_n\}\).
\end{document}
```
[](https://i.stack.imgur... |
536,297 | In the old times of `mathptmx`, we wrote stuff such as
```
\documentclass{article}
\pagestyle{empty}
\usepackage{mathptmx}
\begin{document}
Let \(\mathcal{X}=\{X_1,\ldots,X_n\}\).
\end{document}
```
and got from `pdflatex` a fancy calligraphic math , which was sufficiently fancy to be visibly distinct from the remai... | 2020/04/01 | [
"https://tex.stackexchange.com/questions/536297",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/-1/"
] | The author of `newtxmath` also wrote (and actively maintains) the package [`mathalpha`](https://www.ctan.org/pkg/mathalpha), to easily declare calligraphic, script, fraktur, and blackboard bold math alphabets. With `mathalpha`, you can get your script *X* with the following example.
```
\documentclass{article}
\usepac... | mathptmx uses this font here:
```
\documentclass{article}
\pagestyle{empty}
\usepackage{newtxmath}
\DeclareMathAlphabet{\mathcal}{OMS}{ztmcm}{m}{n}
\begin{document}
Let \(\mathcal{X}=\{X_1,\ldots,X_n\}\).
\end{document}
```
[](https://i.stack.imgur... |
17,783 | How is the related question built?
**Tenons-nous bien ?**
or
**Tenons-nous nous bien ?**
or
**Nous tenons-nous bien ?**
Similarly, for “Vous vous mariez”, is the correct answer
**Mariez-vous ?**
or
**Mariez-vous vous ?**
or
**Vous mariez-vous ?** | 2016/02/14 | [
"https://french.stackexchange.com/questions/17783",
"https://french.stackexchange.com",
"https://french.stackexchange.com/users/174/"
] | The fact that the subject and object pronouns are identical makes the sentences sound a little strange, but doesn't affect the construction.
>
> Te tiens-tu bien ?
>
> Nous tenons-nous bien ?
>
>
> Te maries-tu ?
>
> Vous mariez-vous ?
>
>
>
“*~~Tenons-nous nous bien~~” and “*~~Mariez-vous vous~~” are not... | The third forms are correct French. |
17,783 | How is the related question built?
**Tenons-nous bien ?**
or
**Tenons-nous nous bien ?**
or
**Nous tenons-nous bien ?**
Similarly, for “Vous vous mariez”, is the correct answer
**Mariez-vous ?**
or
**Mariez-vous vous ?**
or
**Vous mariez-vous ?** | 2016/02/14 | [
"https://french.stackexchange.com/questions/17783",
"https://french.stackexchange.com",
"https://french.stackexchange.com/users/174/"
] | **Il y a 3 formes interrogatives possibles.**
**La construction la plus élégante: Avec inversion**, celle qui peut présenter le plus de difficultés pour placer les pronoms: pronom réfléchi COD - verbe - pronom sujet
>
> Nous tenons-nous bien ?
>
>
> Vous mariez-vous ?
>
>
>
La construction introduite par **es... | The third forms are correct French. |
17,783 | How is the related question built?
**Tenons-nous bien ?**
or
**Tenons-nous nous bien ?**
or
**Nous tenons-nous bien ?**
Similarly, for “Vous vous mariez”, is the correct answer
**Mariez-vous ?**
or
**Mariez-vous vous ?**
or
**Vous mariez-vous ?** | 2016/02/14 | [
"https://french.stackexchange.com/questions/17783",
"https://french.stackexchange.com",
"https://french.stackexchange.com/users/174/"
] | The fact that the subject and object pronouns are identical makes the sentences sound a little strange, but doesn't affect the construction.
>
> Te tiens-tu bien ?
>
> Nous tenons-nous bien ?
>
>
> Te maries-tu ?
>
> Vous mariez-vous ?
>
>
>
“*~~Tenons-nous nous bien~~” and “*~~Mariez-vous vous~~” are not... | **Il y a 3 formes interrogatives possibles.**
**La construction la plus élégante: Avec inversion**, celle qui peut présenter le plus de difficultés pour placer les pronoms: pronom réfléchi COD - verbe - pronom sujet
>
> Nous tenons-nous bien ?
>
>
> Vous mariez-vous ?
>
>
>
La construction introduite par **es... |
310,385 | Which term is the correct one in British English for descring degrees in Celcius scale?
I've always refered to it with minus, for instance: In Siberia there are minus 50 degrees. But today I saw [this](https://youtu.be/Fz4ZMLsPzqM) video in which the author is saying "negative 50" when refering to Celcius degrees.
So... | 2022/02/26 | [
"https://ell.stackexchange.com/questions/310385",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/12430/"
] | "It is minus fifty" (not there are minus fifty)
Saying "negative fifty" is a slightly more scientific alternative. Both "minus" and "negative" are used. | You can have below-zero temperatures in Fahrenheit as well as Celsius.
The usual spelling of the C degree name is Celsius. That's how the Swedish scientist (Anders Celsius) who invented the C scale spelled his name.
0 degrees F is minus 17.78 degrees Celsius, so 'sub zero temperatures' in Fahrenheit countries (the US... |
296,655 | >
> Let G be a group. For $g \in G$ write $l\_g : G \rightarrow G$ for the function $l\_g(g') = gg'$. Then $l\_g$ is a permutation of G. Moveover, if we define $\Lambda: G \rightarrow S(G)$ by $\Lambda(g) = l\_g$, then $\Lambda$ is an embedding. In consequence, if G is finite, then it is isomorphic to a subgroup of $S... | 2013/02/06 | [
"https://math.stackexchange.com/questions/296655",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] | Here it means an injective homomorphism. | In this case, *embedding* is being used to say that $G$ has a *copy* of itself into $S(G)$, that is, there exists an injective homomorphism onto its image. |
13,492,124 | I have a Java project with SVN version control system. My IDE is eclipse. Iniitally when I open the project, I edited something. Since this is team project. Someone else commit his own .class and .project file into svn. When I pointed out, he removed .class and .project in some particular sub projects. Anyway, I have .... | 2012/11/21 | [
"https://Stackoverflow.com/questions/13492124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/84592/"
] | Just incase this is still an open question for the OP or someone else stumbles here.
```
import pysal as ps
w = ps.queen_from_shapefile('shapefile.shp')
```
<http://pysal.readthedocs.io/en/latest/users/tutorials/weights.html#pysal-spatial-weight-types> | I am not familiar with the specific data formats being used, but regardless, think the following idea would work.
In Python you can make sets out of tuples of numbers, i.e. `(x,y)` and `(x1,y1,x2,y2)`, so it should be possible to make a set representing all the points or edges in a given polygon. Afterwards you would ... |
158,890 | I have a very simple list, 2 columns actually. "Name" and "Table".
Its for users to reserve a table at an event. "Name" is free text and "Table" is a selection drop down
There are obviously a limited number of seats on each table and I would like to limit the reservation to 10 per table. Trouble is I don't know how! ... | 2015/10/07 | [
"https://sharepoint.stackexchange.com/questions/158890",
"https://sharepoint.stackexchange.com",
"https://sharepoint.stackexchange.com/users/33672/"
] | Try using **commonModalDialogClose**.
Create function to close popup or directly call method.
```
function CloseDlg() {
SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.Cancel);
}
```
Or try to hide using class.
```
$('.CloseSPPopUp').click(function(){
window.top.CloseSPUIPopoup();
});
function C... | Once I closed my modal in the following way
```
var closeLoading = function() {
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function() {
SP.UI.ModalDialog.commonModalDialogClose(1, 1);
});
};
```
So write the following line of code in your button click handler.
```
SP.UI.ModalDialog.commonModalD... |
158,890 | I have a very simple list, 2 columns actually. "Name" and "Table".
Its for users to reserve a table at an event. "Name" is free text and "Table" is a selection drop down
There are obviously a limited number of seats on each table and I would like to limit the reservation to 10 per table. Trouble is I don't know how! ... | 2015/10/07 | [
"https://sharepoint.stackexchange.com/questions/158890",
"https://sharepoint.stackexchange.com",
"https://sharepoint.stackexchange.com/users/33672/"
] | Try using **commonModalDialogClose**.
Create function to close popup or directly call method.
```
function CloseDlg() {
SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.Cancel);
}
```
Or try to hide using class.
```
$('.CloseSPPopUp').click(function(){
window.top.CloseSPUIPopoup();
});
function C... | Here is my code for a custom button, in case it helps someone.
```
<input type="button" value="Cancel" name="gobackbutton2" onclick="SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.Cancel);" />
``` |
222,544 | I am trying to make chef-11.16.4-1.el6.x86\_64.rpm available to our servers via a local yum repo that we've built.
it is not available in RHEL Repos, so i had to manually download and save it in our repo.
so here is what i did on yum repo server:
```
1. cd /packages/rhel65-base/; wget https://opscode-omnibus-package... | 2015/08/11 | [
"https://unix.stackexchange.com/questions/222544",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/120156/"
] | The tools to manipulate the keyboard layout on the virtual consoles are loadkeys, dumpkeys and showkeys. Read their manpages and inform yourself about their intricacies.
Note that these tools only work in a virtual console, not in a terminal emulator in a graphical environment like gnome. The learn about the differenc... | On Debian with Gnome you can install `gnome-tweak-tool`. In the secton "Typing" there are loads of available behaviors for Caps Lock |
11,999,312 | I have created event receiver with C# coding in SharePoint.when item should match is already have. it showing massage like this is my code..
```
public override void ItemAdding(SPItemEventProperties properties)
{
base.ItemAdding(properties);
SPList oList = null;
string str... | 2012/08/17 | [
"https://Stackoverflow.com/questions/11999312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1589418/"
] | As I can see, you have problem with the query string, you should use this:
```
existingItemsQuery.Query = "<Where><And><Eq><FieldRef Name='EventDate'/><Value Type='DateTime' IncludeTimeValue='TRUE'>" + strStartdate + "</Value></Eq><Eq><FieldRef Name='Car_x0020_Name'/><Value Type='Lookup'>" + strCarName + "</Value></Eq... | Not sure that you can register script because the page will be redirected.
But you can use `properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl` and add custom parameter to query string. Also script must be always on the page.
So you just check necessary parameter in QS and show alert if it is present. |
58,830,730 | sorry about the code it is sloppy right now because I've been trying to fix it. Im using a function from another file to remove even numbers from my list but after I call the function the list returns empty.
```
from usefullFunctions import *
def main ():
mylist1 = uRandomList(10,0,15)
listLength = len(mylist1... | 2019/11/13 | [
"https://Stackoverflow.com/questions/58830730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12364686/"
] | Its either a subquery or a group by query. Cant tell without the schema. Add the table definitions to your question and it will likely be a simple answer, unless this is already enough information.
As a completely guessed view of your data, it will be:
```
select CourseNumber,CourseName,Department,count(*) as Number... | Here are a couple options:
```sql
-- left join
SELECT c.course_number, c.course_name, c.department,
COUNT(s.section_number) AS section_count
FROM courses c
LEFT JOIN sections s ON c.course_number = s.course_number -- get section info
GROUP BY 1,2,3
;
-- sub-query
SELECT course_number, course_name, department,
(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.