qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
901,220 | On CentOS 7 have I been trying out different firewalld rules and iptables commands, and now want to do it all over, but only using firewalld.
**Question**
How can I reset all rules to the default that CentOS 7's firewalld ships with? | 2018/03/12 | [
"https://serverfault.com/questions/901220",
"https://serverfault.com",
"https://serverfault.com/users/24610/"
] | If you trully want to delete everything as John Ashpool say's
`rm -rf /etc/firewalld/zones` or /usr/etc/firewalld/zones depending on your distro
and
```
iptables -X
iptables -F
iptables -Z
```
plus
```
systemctl restart firewalld
```
and then you have a new set of rules and zones ;) | Any default `zones` that come with distribution, if modified, get copied to `/etc/firewalld/zones` directory with those modifications.
Which also means that the source of `default` zone files is not this directory and re-installation doesn't know about the files under this directory (`/etc/firewalld/zones`) so these ... |
70,800,563 | I want to pass props into a function from the route, my code currently looks like this
**Route**
```
<Route path="/person" render={(params) => <ProductDetails {...params} />} />
```
**Code**
```
function ProductDetails(props) {
return (
<div className="section has-text-centered mt-4">
console.l... | 2022/01/21 | [
"https://Stackoverflow.com/questions/70800563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17647444/"
] | Since `y` contains *disjoint ranges* and the union of them is also a range, a very fast solution is to first perform a binary search on `y` and then count the resulting indices and only return the ones that appear at least 10 times. The complexity of this algorithm is `O(Nx log Ny)` with `Nx` and `Ny` the number of ite... | Turn y into 2 dicts.
```
index = { # index to count map
0 : 0,
1 : 0,
2 : 0,
3 : 0,
4 : 0
}
y = { # elem to index map
1: 0,
2: 0,
3: 0,
4: 1,
5: 2,
6: 2,
7: 3,
8 : 4,
9 : 4,
10 : 4,
11 : 4
}
```
Since you know `y` in advance, I don't count the above op... |
70,800,563 | I want to pass props into a function from the route, my code currently looks like this
**Route**
```
<Route path="/person" render={(params) => <ProductDetails {...params} />} />
```
**Code**
```
function ProductDetails(props) {
return (
<div className="section has-text-centered mt-4">
console.l... | 2022/01/21 | [
"https://Stackoverflow.com/questions/70800563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17647444/"
] | Since `y` contains *disjoint ranges* and the union of them is also a range, a very fast solution is to first perform a binary search on `y` and then count the resulting indices and only return the ones that appear at least 10 times. The complexity of this algorithm is `O(Nx log Ny)` with `Nx` and `Ny` the number of ite... | This uses `y` to create a linear array mapping every int to the (1 plus), the index of the range or subgroup the int is in; called `x2range_counter`.
`x2range_counter` uses a 32 bit array.array type to save memory and can be cached and used for calculations of **all** `x` on the same `y`.
calculating the hits in each... |
65,897,562 | Considering the below object:
```
[
{
id: 5fc0be2990a8a12cc0ba0b5c,
projectName: 'E-271120-B',
projectManagaer: '5f7f1ba973ff621da4322248',
dataInici: 2020-11-26T23:00:00.000Z,
dataEntrega: 2020-11-26T23:00:00.000Z,
dtoGlobal: null,
dtoProjecte: null,
archived: false,
created: 202... | 2021/01/26 | [
"https://Stackoverflow.com/questions/65897562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14571284/"
] | Here is possible replace `name2` misisng values by `name1` and assign to `name1`:
```
df['name1'] = df['name2'].fillna(df['name1'])
print (df)
id name1 name2
0 1 James James
1 2 Bond NaN
2 3 Steven NaN
3 4 Kevin Kevin
4 5 Tim Tim
```
Or you can use some solution with test missi... | ```py
df.name1 = np.where(df.name2.isna(), df.name1, df.name2)
```
Here the complete code:
```py
import pandas as pd
import numpy as np
df = pd.DataFrame(
data = [
['James', 'James'],
['Bond', np.nan],
['Steven', np.nan],
['Tom', 'Kevin'],
['Alba', 'Tim',],
], column... |
12,868,003 | Please consider the following piece of code
```
#include <stdio.h>
#define ROW_SIZE 2
#define COL_SIZE 2
int main()
{
int a[ROW_SIZE][COL_SIZE]={{1,2},{3,4}};
// Base address:Pointer to the first element a 1D array
printf("Base address of array:%p\n",a);
//The value at the base address: should be the ad... | 2012/10/12 | [
"https://Stackoverflow.com/questions/12868003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1325569/"
] | Arrays aren't pointers, and in C, a multidimensional array is just an array of arrays. In many contexts, using the name of an array "decays" into a pointer to the first element of that array. That's what happens in both of your print statements. In the first case:
```
printf("Base address of array:%p\n",a);
```
`a` ... | I think the formatting of your output is throwing you. You are right, the address of the first array element (0xbff77434) *is* different from the value (1). The %p is getting confused trying to force both to a "pointer" format.
And yes, Carl's correct too.
If you want to see what's *at* the first element, you would ... |
12,868,003 | Please consider the following piece of code
```
#include <stdio.h>
#define ROW_SIZE 2
#define COL_SIZE 2
int main()
{
int a[ROW_SIZE][COL_SIZE]={{1,2},{3,4}};
// Base address:Pointer to the first element a 1D array
printf("Base address of array:%p\n",a);
//The value at the base address: should be the ad... | 2012/10/12 | [
"https://Stackoverflow.com/questions/12868003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1325569/"
] | Arrays aren't pointers, and in C, a multidimensional array is just an array of arrays. In many contexts, using the name of an array "decays" into a pointer to the first element of that array. That's what happens in both of your print statements. In the first case:
```
printf("Base address of array:%p\n",a);
```
`a` ... | The bidimensional array `a[2][2]` can be seen as a monodimensional array with 4 elements. Think what happens when you cast `a` to an `int*` pointer:
```
int a[2][2] = {{ 1, 2 }, { 3, 4 }};
int* p = (int*) a; // == { 1, 2, 3, 4 }
assert(a[1][0] == p[2] == 3); // true
int* a0 = a[0]; // the first row in the bidimensi... |
12,868,003 | Please consider the following piece of code
```
#include <stdio.h>
#define ROW_SIZE 2
#define COL_SIZE 2
int main()
{
int a[ROW_SIZE][COL_SIZE]={{1,2},{3,4}};
// Base address:Pointer to the first element a 1D array
printf("Base address of array:%p\n",a);
//The value at the base address: should be the ad... | 2012/10/12 | [
"https://Stackoverflow.com/questions/12868003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1325569/"
] | Arrays aren't pointers, and in C, a multidimensional array is just an array of arrays. In many contexts, using the name of an array "decays" into a pointer to the first element of that array. That's what happens in both of your print statements. In the first case:
```
printf("Base address of array:%p\n",a);
```
`a` ... | Re-structuring the diagram in the question and consolidating the information from previous answers, I am creating the following answer.

### One dimensional array
* Consider an array a of 4 integers as `a[4]`
* Basic rule is both `a` and `&a` will point to s... |
12,868,003 | Please consider the following piece of code
```
#include <stdio.h>
#define ROW_SIZE 2
#define COL_SIZE 2
int main()
{
int a[ROW_SIZE][COL_SIZE]={{1,2},{3,4}};
// Base address:Pointer to the first element a 1D array
printf("Base address of array:%p\n",a);
//The value at the base address: should be the ad... | 2012/10/12 | [
"https://Stackoverflow.com/questions/12868003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1325569/"
] | Re-structuring the diagram in the question and consolidating the information from previous answers, I am creating the following answer.

### One dimensional array
* Consider an array a of 4 integers as `a[4]`
* Basic rule is both `a` and `&a` will point to s... | I think the formatting of your output is throwing you. You are right, the address of the first array element (0xbff77434) *is* different from the value (1). The %p is getting confused trying to force both to a "pointer" format.
And yes, Carl's correct too.
If you want to see what's *at* the first element, you would ... |
12,868,003 | Please consider the following piece of code
```
#include <stdio.h>
#define ROW_SIZE 2
#define COL_SIZE 2
int main()
{
int a[ROW_SIZE][COL_SIZE]={{1,2},{3,4}};
// Base address:Pointer to the first element a 1D array
printf("Base address of array:%p\n",a);
//The value at the base address: should be the ad... | 2012/10/12 | [
"https://Stackoverflow.com/questions/12868003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1325569/"
] | Re-structuring the diagram in the question and consolidating the information from previous answers, I am creating the following answer.

### One dimensional array
* Consider an array a of 4 integers as `a[4]`
* Basic rule is both `a` and `&a` will point to s... | The bidimensional array `a[2][2]` can be seen as a monodimensional array with 4 elements. Think what happens when you cast `a` to an `int*` pointer:
```
int a[2][2] = {{ 1, 2 }, { 3, 4 }};
int* p = (int*) a; // == { 1, 2, 3, 4 }
assert(a[1][0] == p[2] == 3); // true
int* a0 = a[0]; // the first row in the bidimensi... |
100,315 | I've heard many times people debate the possibility of a real world computation that is impossible for a Turing machine, especially in the context of a human mind. Implying that the Church-Turing thesis is wrong and that a Turing machine does not accurately model any possible real world computation. To me, it seems tha... | 2018/11/19 | [
"https://cs.stackexchange.com/questions/100315",
"https://cs.stackexchange.com",
"https://cs.stackexchange.com/users/88787/"
] | No, it is not too strong.
We fundamentally conceive of computation as an activity with unlimited resources.
For instance, take a very popular and simple algorithm such as long division. It takes two *arbitrarily large* numbers and can produce an *arbitrarily large* resulting number. During the computation, an arbitrar... | **Is it too strong?**
The concern should not be that a Turing machine is a too strong model because of the way we construct a Turing machine. Turing machine is essentially a framework for defining a notion of algorithm in its basic, simple steps. Every algorithm executed on a Turing machine can be executed by hand, ... |
100,315 | I've heard many times people debate the possibility of a real world computation that is impossible for a Turing machine, especially in the context of a human mind. Implying that the Church-Turing thesis is wrong and that a Turing machine does not accurately model any possible real world computation. To me, it seems tha... | 2018/11/19 | [
"https://cs.stackexchange.com/questions/100315",
"https://cs.stackexchange.com",
"https://cs.stackexchange.com/users/88787/"
] | No, it is not too strong.
We fundamentally conceive of computation as an activity with unlimited resources.
For instance, take a very popular and simple algorithm such as long division. It takes two *arbitrarily large* numbers and can produce an *arbitrarily large* resulting number. During the computation, an arbitrar... | No, the Turing machine isn't unreasonably strong. You could build a physical Turing machine by giving it a finite length of tape and the ability to say "I've run out of tape – please give me more!" and that's something an ordinary computer can do, too, if it has removable media.
After any finite amount of time, a Turi... |
38,424,628 | I want to get the posts from today that I made, all of them, except the ones that I posted in the last 20 minutes.
for example, now is 3:30.
I want to get all posts that I did today until 3:10.
I tried:
```
SELECT id, titulo
FROM posts
WHERE data > DATE_SUB(NOW(), INTERVAL 20 MINUTE)
ORDER BY RAND()
```
but no su... | 2016/07/17 | [
"https://Stackoverflow.com/questions/38424628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5317298/"
] | Your query is set to get posts from the last 20 minutes, if you want today except the last 20 minutes, you should use `data < DATE_SUB( NOW( ) , INTERVAL 20
MINUTE )` and not bigger than.
The second part (from today) can be done with [curdate()](https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#fun... | Your condition is doing it the wrong way: you want to return posts older than the date it was 20 minutes ago:
```
SELECT id, titulo
FROM posts
WHERE data < DATE_SUB(NOW(), INTERVAL 20 MINUTE)
ORDER BY RAND()
```
You also said you want only today's posts, so a second test must be added. The query is then:
```
SELECT... |
38,424,628 | I want to get the posts from today that I made, all of them, except the ones that I posted in the last 20 minutes.
for example, now is 3:30.
I want to get all posts that I did today until 3:10.
I tried:
```
SELECT id, titulo
FROM posts
WHERE data > DATE_SUB(NOW(), INTERVAL 20 MINUTE)
ORDER BY RAND()
```
but no su... | 2016/07/17 | [
"https://Stackoverflow.com/questions/38424628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5317298/"
] | Your query is set to get posts from the last 20 minutes, if you want today except the last 20 minutes, you should use `data < DATE_SUB( NOW( ) , INTERVAL 20
MINUTE )` and not bigger than.
The second part (from today) can be done with [curdate()](https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#fun... | If you want your queries still being fast by using indexes you need to avoid using functions on columns with potencial indexes. You can do it like this
```
WHERE data between curdate() and now() - interval 20 MINUTE
``` |
57,684 | **"Even a small bird has many more bones in its neck than in a tall giraffe. "**
The sentence structure is quite weird, how to parse it? | 2015/05/26 | [
"https://ell.stackexchange.com/questions/57684",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/2065/"
] | When you say "someone was *survived by* so-and-so", it means that that someone is deceased, and their surviving relatives are so-and-so.
Here, it means "her partner X was still alive when she died." | It means that after her death, her partner is still alive. |
57,684 | **"Even a small bird has many more bones in its neck than in a tall giraffe. "**
The sentence structure is quite weird, how to parse it? | 2015/05/26 | [
"https://ell.stackexchange.com/questions/57684",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/2065/"
] | When you say "someone was *survived by* so-and-so", it means that that someone is deceased, and their surviving relatives are so-and-so.
Here, it means "her partner X was still alive when she died." | If you see:
>
> He was 43 and is survived by his wife, a son and daughter.
>
>
>
then that means he died while those family members are still alive. |
21,716,004 | Hello I was trying to find a solution for a small script that can rotate objects around 1 center but it seems a bit too tricky for me.
I've found almost perfect solution and tried to modify it to suit my needs but there's a problem.
I'm trying to make 3 objects with text to rotate with same speed, same orbit but diffe... | 2014/02/12 | [
"https://Stackoverflow.com/questions/21716004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3299345/"
] | I use post\_install hook in Podfile. Like this:
```
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
if config.name.include?("Debug")
config.build_settings['GCC_OPTIMIZATION_LEVEL'] = '0'
config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-O... | If you also want the DEBUG macro added for debugging with assertions enabled, you can use the following script:
```
post_install do |installer|
installer.project.build_configurations.each do |config|
if config.name.include?("Debug")
# Set optimization level for project
config.build_settings['GCC_OPTI... |
21,716,004 | Hello I was trying to find a solution for a small script that can rotate objects around 1 center but it seems a bit too tricky for me.
I've found almost perfect solution and tried to modify it to suit my needs but there's a problem.
I'm trying to make 3 objects with text to rotate with same speed, same orbit but diffe... | 2014/02/12 | [
"https://Stackoverflow.com/questions/21716004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3299345/"
] | I use post\_install hook in Podfile. Like this:
```
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
if config.name.include?("Debug")
config.build_settings['GCC_OPTIMIZATION_LEVEL'] = '0'
config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-O... | To anybody seeing this using cocoapods 0.38.0 or later:
Use "pods\_project" instead of "project"
The previous answers use the word "project" (installer.project.build\_configurations.each)
Project was deprecated and replaced with pods\_project.
<https://github.com/CocoaPods/CocoaPods/issues/3747>
```
post_install do... |
21,716,004 | Hello I was trying to find a solution for a small script that can rotate objects around 1 center but it seems a bit too tricky for me.
I've found almost perfect solution and tried to modify it to suit my needs but there's a problem.
I'm trying to make 3 objects with text to rotate with same speed, same orbit but diffe... | 2014/02/12 | [
"https://Stackoverflow.com/questions/21716004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3299345/"
] | I use post\_install hook in Podfile. Like this:
```
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
if config.name.include?("Debug")
config.build_settings['GCC_OPTIMIZATION_LEVEL'] = '0'
config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-O... | Instead of `post_install` you can add following line to Podfile:
`project 'ProjectName', 'DebugConfigurationName' => :debug` |
21,716,004 | Hello I was trying to find a solution for a small script that can rotate objects around 1 center but it seems a bit too tricky for me.
I've found almost perfect solution and tried to modify it to suit my needs but there's a problem.
I'm trying to make 3 objects with text to rotate with same speed, same orbit but diffe... | 2014/02/12 | [
"https://Stackoverflow.com/questions/21716004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3299345/"
] | To anybody seeing this using cocoapods 0.38.0 or later:
Use "pods\_project" instead of "project"
The previous answers use the word "project" (installer.project.build\_configurations.each)
Project was deprecated and replaced with pods\_project.
<https://github.com/CocoaPods/CocoaPods/issues/3747>
```
post_install do... | If you also want the DEBUG macro added for debugging with assertions enabled, you can use the following script:
```
post_install do |installer|
installer.project.build_configurations.each do |config|
if config.name.include?("Debug")
# Set optimization level for project
config.build_settings['GCC_OPTI... |
21,716,004 | Hello I was trying to find a solution for a small script that can rotate objects around 1 center but it seems a bit too tricky for me.
I've found almost perfect solution and tried to modify it to suit my needs but there's a problem.
I'm trying to make 3 objects with text to rotate with same speed, same orbit but diffe... | 2014/02/12 | [
"https://Stackoverflow.com/questions/21716004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3299345/"
] | To anybody seeing this using cocoapods 0.38.0 or later:
Use "pods\_project" instead of "project"
The previous answers use the word "project" (installer.project.build\_configurations.each)
Project was deprecated and replaced with pods\_project.
<https://github.com/CocoaPods/CocoaPods/issues/3747>
```
post_install do... | Instead of `post_install` you can add following line to Podfile:
`project 'ProjectName', 'DebugConfigurationName' => :debug` |
51,073,133 | I'm just getting started working with Bazel. So, I apologize in advance that I haven't been able to figure this out.
I'm trying to run a command that outputs a bunch of files to a directory and make this directory available for subsequent targets. I have two different attempts:
1. Use genrule
2. Write my own rule
I ... | 2018/06/28 | [
"https://Stackoverflow.com/questions/51073133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/177293/"
] | The output of a `genrule` [must be a fixed list of files](https://docs.bazel.build/versions/master/be/general.html#genrule.outs). As a work-around, you can create a zip from the output directory.
I used this approach to manipulate the output of `yarn install` where the usual method was not viable:
```py
genrule(
... | A while ago I created this example showing how to use directories with skylark action: [How to build static library from the Generated source files using Bazel Build](https://stackoverflow.com/questions/48417712/how-to-build-static-library-from-the-generated-source-files-using-bazel-build/48524539#48524539). Maybe it s... |
51,073,133 | I'm just getting started working with Bazel. So, I apologize in advance that I haven't been able to figure this out.
I'm trying to run a command that outputs a bunch of files to a directory and make this directory available for subsequent targets. I have two different attempts:
1. Use genrule
2. Write my own rule
I ... | 2018/06/28 | [
"https://Stackoverflow.com/questions/51073133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/177293/"
] | A while ago I created this example showing how to use directories with skylark action: [How to build static library from the Generated source files using Bazel Build](https://stackoverflow.com/questions/48417712/how-to-build-static-library-from-the-generated-source-files-using-bazel-build/48524539#48524539). Maybe it s... | <https://github.com/aspect-build/bazel-lib/blob/main/docs/run_binary.md> has a similar API to genrule, and it supports directory outputs. |
51,073,133 | I'm just getting started working with Bazel. So, I apologize in advance that I haven't been able to figure this out.
I'm trying to run a command that outputs a bunch of files to a directory and make this directory available for subsequent targets. I have two different attempts:
1. Use genrule
2. Write my own rule
I ... | 2018/06/28 | [
"https://Stackoverflow.com/questions/51073133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/177293/"
] | The output of a `genrule` [must be a fixed list of files](https://docs.bazel.build/versions/master/be/general.html#genrule.outs). As a work-around, you can create a zip from the output directory.
I used this approach to manipulate the output of `yarn install` where the usual method was not viable:
```py
genrule(
... | <https://github.com/aspect-build/bazel-lib/blob/main/docs/run_binary.md> has a similar API to genrule, and it supports directory outputs. |
83 | I am the "moderator-owner" of the [Windom Antenna Yahoo!Group](http://groups.yahoo.com/group/windom_antenna/join).
I have been longing to move that Yahoo!Group to a more "mature" Q&A site like ham.stackexchange.com.
What would be the best strategy to do so?
I have noticed that Yahoo! accounts can be used to sign in ... | 2013/10/31 | [
"https://ham.meta.stackexchange.com/questions/83",
"https://ham.meta.stackexchange.com",
"https://ham.meta.stackexchange.com/users/250/"
] | Welcome to the site, and I'm glad to hear you find this site a worthwhile successor to your own community! I hope you have great success with it.
I'm not sure if there's much of a *strategy* beyond encouraging people to start using this site. Yes, if the participants already have a Yahoo! account, they will be able to... | One suggestion I could make that might help is to simply subscribe the group to the weekly newsletter posts from this site. That will help encourage them to use the new site, and give them a flavor for what kinds of questions are being asked here. Aside from that, just post a really good review with some good sample qu... |
13,448,535 | I'm writing MineSweeper and using `JButton`s on a `GridLayout`. The numbers of rows and columns are entered by the user, so setting fixed size may cause several problems.
How can I remove the space between the buttons without setting the fixed size of the panel?


The other thing I tried was passing a negative h/vgap to the `GridLayout`
;
``` |
1,095,159 | I got a `Base` superclass and a bunch of derived classes, like `Base::Number`, `Base::Color`. I'd like to be able to use those child classes as if I they inherited from say `Fixnum` in the case of `Number`.
What's the best way to do this, while still having them respond appropriately to `is_a? Base` ?
So, I should be... | 2009/07/07 | [
"https://Stackoverflow.com/questions/1095159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/120146/"
] | Why do you insist on using is\_a?/kind\_of? when respond\_to? is a much cleaner way of checking things? You want objects to implement an interface/contract not to be a subclass of any arbitrarily chosen superclass. But maybe I'm missing some kind of requirement here.
**Edit**: I understand your reasoning, but it often... | I think you are using inheritance incorrectly if you have completely unrelated classes like "Number" and "Color" all deriving from the same base class. I would use composition instead if they do need access to the same routines (not sure why they would though). |
1,095,159 | I got a `Base` superclass and a bunch of derived classes, like `Base::Number`, `Base::Color`. I'd like to be able to use those child classes as if I they inherited from say `Fixnum` in the case of `Number`.
What's the best way to do this, while still having them respond appropriately to `is_a? Base` ?
So, I should be... | 2009/07/07 | [
"https://Stackoverflow.com/questions/1095159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/120146/"
] | This is actually quite simple using Ruby:
```
module Slugish
attr_accessor :slug
def loud_slug
"#{slug}!"
end
end
class Stringy < String
include Slugish
end
class Hashy < Hash
include Slugish
end
hello = Stringy.new("Hello")
world = Stringy.new("World")
hello.slug = "So slow"
world.slug = "Worldly"
... | I think you are using inheritance incorrectly if you have completely unrelated classes like "Number" and "Color" all deriving from the same base class. I would use composition instead if they do need access to the same routines (not sure why they would though). |
1,095,159 | I got a `Base` superclass and a bunch of derived classes, like `Base::Number`, `Base::Color`. I'd like to be able to use those child classes as if I they inherited from say `Fixnum` in the case of `Number`.
What's the best way to do this, while still having them respond appropriately to `is_a? Base` ?
So, I should be... | 2009/07/07 | [
"https://Stackoverflow.com/questions/1095159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/120146/"
] | Why do you insist on using is\_a?/kind\_of? when respond\_to? is a much cleaner way of checking things? You want objects to implement an interface/contract not to be a subclass of any arbitrarily chosen superclass. But maybe I'm missing some kind of requirement here.
**Edit**: I understand your reasoning, but it often... | Ruby's equivalent to multiple inheritance is mixins. It sounds to me like what you want is for Base to be a module that gets mixed in to several classes. |
1,095,159 | I got a `Base` superclass and a bunch of derived classes, like `Base::Number`, `Base::Color`. I'd like to be able to use those child classes as if I they inherited from say `Fixnum` in the case of `Number`.
What's the best way to do this, while still having them respond appropriately to `is_a? Base` ?
So, I should be... | 2009/07/07 | [
"https://Stackoverflow.com/questions/1095159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/120146/"
] | This is actually quite simple using Ruby:
```
module Slugish
attr_accessor :slug
def loud_slug
"#{slug}!"
end
end
class Stringy < String
include Slugish
end
class Hashy < Hash
include Slugish
end
hello = Stringy.new("Hello")
world = Stringy.new("World")
hello.slug = "So slow"
world.slug = "Worldly"
... | Why do you insist on using is\_a?/kind\_of? when respond\_to? is a much cleaner way of checking things? You want objects to implement an interface/contract not to be a subclass of any arbitrarily chosen superclass. But maybe I'm missing some kind of requirement here.
**Edit**: I understand your reasoning, but it often... |
1,095,159 | I got a `Base` superclass and a bunch of derived classes, like `Base::Number`, `Base::Color`. I'd like to be able to use those child classes as if I they inherited from say `Fixnum` in the case of `Number`.
What's the best way to do this, while still having them respond appropriately to `is_a? Base` ?
So, I should be... | 2009/07/07 | [
"https://Stackoverflow.com/questions/1095159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/120146/"
] | This is actually quite simple using Ruby:
```
module Slugish
attr_accessor :slug
def loud_slug
"#{slug}!"
end
end
class Stringy < String
include Slugish
end
class Hashy < Hash
include Slugish
end
hello = Stringy.new("Hello")
world = Stringy.new("World")
hello.slug = "So slow"
world.slug = "Worldly"
... | Ruby's equivalent to multiple inheritance is mixins. It sounds to me like what you want is for Base to be a module that gets mixed in to several classes. |
55,945,347 | So for this program, the mean and median are supposed to calculated and displayed but I do not think the data I am inputting is getting put into the array because it runs without error but does not display any data I have put into it.
```
public static double Mean(double[] gradeArray, int numGrades) {
double total... | 2019/05/02 | [
"https://Stackoverflow.com/questions/55945347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11199610/"
] | First, let's turn the data from "2 rows with one phone number each per client" into "one row of 2 phone number columns per client"
```
SELECT
nm_client,
MAX(CASE WHEN nm_phoneType = 1 THEN nu_phone END) as landline,
MAX(CASE WHEN nm_phoneType = 2 THEN nu_phone END) as mobile
FROM Clients
JOIN Phones
ON Clients.... | Use `APPLY`:
```
SELECT c.nm_client, c.nm_phoneType, p.nu_phone
FROM Clients c OUTER APPLY
(SELECT TOP (1) p.*
FROM Phones p
WHERE c.id_client = p.id_client
ORDER BY (CASE WHEN p.cd_phoneType = 2 THEN 1 ELSE 2 END)
);
```
You can also phrase this as a correlated subquery (because you wan... |
11,148,567 | I have some vertex data. Positions, normals, texture coordinates. I probably loaded it from a .obj file or some other format. Maybe I'm drawing a cube. But each piece of vertex data has its own index. Can I render this mesh data using OpenGL/Direct3D? | 2012/06/22 | [
"https://Stackoverflow.com/questions/11148567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/734069/"
] | In the most general sense, no. OpenGL and Direct3D only allow one index per vertex; the index fetches from each stream of vertex data. Therefore, every unique combination of components must have its own separate index.
So if you have a cube, where each face has its own normal, you will need to replicate the position a... | I found a way that allows you to reduce this sort of repetition that runs a bit contrary to some of the statements made in the other answer (but doesn't specifically fit the question asked here). It does however address [my question](https://stackoverflow.com/questions/52361930/other-forms-of-indexing-for-gl-draw) whic... |
33,930,828 | I am trying to connect to `Azure Resource Manager API` using `java` sdk. I have an AD application which has "Windows Service Management API" permissions enabled. When running the test samples, I am hitting the following error when performing get call on a specific resource group.
```
Exception in thread "main" com.mic... | 2015/11/26 | [
"https://Stackoverflow.com/questions/33930828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5606859/"
] | As @Gaurav Mantri said, the easiest way for assigning reader role for your ad app is using Azure Preview Portal if runing the sample `ServicePrincipalExample` at <https://github.com/Azure/azure-sdk-for-java/blob/master/azure-mgmt-samples/src/main/java/com/microsoft/azure/samples/authentication/ServicePrincipalExample.j... | What you would need to do is assign your application `Reader` role in your Azure Subscription. This you could do programmatically using ARM API or you could use [`Azure PowerShell`](https://azure.microsoft.com/en-in/documentation/articles/role-based-access-control-powershell/) to do that.
However the easiest for you ... |
40,008,126 | I want to send a custom message into the Telegram. How can I set the ChannelData property in reply using C#? Should be set a string which is name-valued such as mentioned in this link [CustomMessage](https://docs.botframework.com/en-us/csharp/builder/sdkreference/channels.html#customtelegrammessages)? Could you provide... | 2016/10/12 | [
"https://Stackoverflow.com/questions/40008126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3768871/"
] | Both `0 .. *` and `0 ... *` are fine.
* Iterating over them, for example with a `for` loop, has exactly the same effect in both cases. (Neither will leak memory by keeping around already iterated elements.)
* Assigning them to a `@` variable produces the same lazy Array.
So as long as you only want to count up number... | There is a difference between ".." (Range) and "..." (Seq):
```
$ perl6
> 1..10
1..10
> 1...10
(1 2 3 4 5 6 7 8 9 10)
> 2,4...10
(2 4 6 8 10)
> (3,6...*)[^5]
(3 6 9 12 15)
```
The "..." operator can intuit patterns!
<https://docs.perl6.org/language/operators#index-entry-..._operators>
As I understand, you can trav... |
40,008,126 | I want to send a custom message into the Telegram. How can I set the ChannelData property in reply using C#? Should be set a string which is name-valued such as mentioned in this link [CustomMessage](https://docs.botframework.com/en-us/csharp/builder/sdkreference/channels.html#customtelegrammessages)? Could you provide... | 2016/10/12 | [
"https://Stackoverflow.com/questions/40008126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3768871/"
] | Semantically speaking, a `Range` is a static thing (a bounded set of values), a `Seq` is a dynamic thing (a value generator) and a lazy `List` a static view of a dynamic thing (an immutable cache for generated values).
*Rule of thumb:* Prefer static over dynamic, but simple over complex.
In addition, a `Seq` is an it... | There is a difference between ".." (Range) and "..." (Seq):
```
$ perl6
> 1..10
1..10
> 1...10
(1 2 3 4 5 6 7 8 9 10)
> 2,4...10
(2 4 6 8 10)
> (3,6...*)[^5]
(3 6 9 12 15)
```
The "..." operator can intuit patterns!
<https://docs.perl6.org/language/operators#index-entry-..._operators>
As I understand, you can trav... |
588,446 | I'm planning an experiment, but due to cost and other circumstances, there will only be one realization of it. So the plan is to collect as many different types of data as we can with a variety of techniques and sift through it. However, I'm not sure how to address quantifying or estimating the uncertainty in any given... | 2020/10/20 | [
"https://physics.stackexchange.com/questions/588446",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/6634/"
] | The relation $\Lambda^{\mu}\_{\ \ \sigma}\,\Lambda^{\nu\sigma}=\eta^{\mu\nu}$, or more properly
$$
\Lambda^{\mu}\_{\ \ \sigma}\,\eta^{\sigma\tau}\,\Lambda^{\nu}\_{\ \ \tau}=\eta^{\mu\nu}\ ,
$$
actually is the *definition* of a Lorentz transformation $\Lambda^{\mu}\_{\nu}$. As such it cannot be proven true, unless you... | After some more thought:
${\Lambda\_\beta}^\rho$ is the inverse Lorentz transformation matrix and also satisfy the orthogonal matrix requirement:
$${(\Lambda^T)\_\beta}^\rho{\Lambda\_\rho}^\mu={\Lambda^\rho}\_\beta{\Lambda\_\rho}^\mu=1$$
Taking the transpose of both sides,
$${\Lambda^\mu}\_\rho{\Lambda\_\beta}^\rho=1... |
63,697,432 | I am trying to create a "histogram", except the y-axis is not supposed to be the frequency of data points within a bin. Instead, I wish to set my own y-axis values for each bin.
For example, let's say my `x` values are:`[1, 2.2, 1.4, 2, 3.3, 2.6, 3, 1.5, 3.9] and my y-values are [1, 2, 2.5, 1, 0.5, 3, 4, 3, 2]`
Treat... | 2020/09/02 | [
"https://Stackoverflow.com/questions/63697432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14205796/"
] | Try reinstalling the typing\_extensions package using:
```sh
pip uninstall typing_extensions
pip install typing_extensions
``` | Im not really sure of my answer but,
Maybe You can try putting `typing-extensions` instead of `typing_extensions` in the `builder.spec` file.
replace `_` with `-` for that. |
369,887 | An exceptional complex Lie algebra is a simple Lie algebra whose Dynkin diagram is of exceptional (nonclassical) type. There are exactly five such Lie algebras: $\mathfrak{g}\_{2}$, ${\mathfrak {f}}\_{4}$,${\mathfrak {e}}\_{6}$,
${\mathfrak {e}}\_{7}$, ${\mathfrak {e}}\_{8}$; their respective dimensions are 14, 52, 78,... | 2020/08/22 | [
"https://mathoverflow.net/questions/369887",
"https://mathoverflow.net",
"https://mathoverflow.net/users/106497/"
] | I prefer to use the language of algebraic groups.
All algebraic groups and Lie algebras are defined over $\Bbb C$.
**1.** Let ${\mathfrak g}$ be a semisimple Lie algebra.
Consider the automorphism group ${\rm Aut\,}{\mathfrak g}$,
its identity component $G^{\rm ad}:=({\rm Aut\,}{\mathfrak g})^0$,
and the *group of out... | I have just dumped the comments in an answer, and hope someone will make a better answer than this. (EDIT: Someone has! See @MikhailBorovoi's [answer](https://mathoverflow.net/a/369936).) I'll be happy to delete this one—or you can just edit this one, which is CW to avoid reputation (since I'm just compiling comments).... |
68,746,507 | I have a database that is updated with new rows almost every few seconds.
I have a table on my website that I would like to be automatically updated with the new rows added to the top without the user having to refresh the page.
I was testing the below:
```
$(document).ready(function(){
loadstati... | 2021/08/11 | [
"https://Stackoverflow.com/questions/68746507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4742639/"
] | You could add a timestamp to your rows and only pull (and load) the extra rows happened since the last update.
Let's say you loaded the page at 00:01, then you pull and append (instead of load) the rows added since 00:01 and update the timestamp.
This would solve the issue deleting the selection, because it would add... | The best approach would be use AJAX. The server should only send data of the updated fields (JSON format preferable) and javascript should simply replace `textContent` of the needed field(s). |
4,180,742 | So I implemented my own form of Enum static classes so I can associate strings to enumeration values. One of the shared functions in each enum class, `GetValue`, is used to quickly look up the string value from an internal array via the offset. While all of the enum classes implement the same exact function, the data t... | 2010/11/15 | [
"https://Stackoverflow.com/questions/4180742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/482691/"
] | How about this as a solution:
```
Friend NotInheritable Class EExample
Inherits EBase
Protected Sub New()
End Sub
Protected Overrides Function BuildValues() As EBase.Enums()
Return New Enums() _
{ _
Build(Of EExample)("one_adam", 0), _
Build(Of EExample)("two_b... | Wow, this sure sounds like it's getting deep quick. Are you sure you need all that?
Wouldn't it be easier to associate the strings to enumeration values by creating a class, having the enums in the same file (or even nested in the same namespace, if you prefer), and then using a .ToFriendlyName() method to extract the... |
70,091,993 | What I want is to search tweets that have multiple words I choose on twitter with python.
The official doc dose not say anything but it seems that the search method only takes 1 query.
source code
```
import tweepy
CK=
CS=
AT=
AS=
auth = tweepy.OAuthHandler(CK, CS)
auth.set_access_token(AT, AS)
api = tweepy.API(auth)... | 2021/11/24 | [
"https://Stackoverflow.com/questions/70091993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15938343/"
] | It's easier like this:
```
public void FillGrid()
{
var dt = new DataTable();
var da = new SqlDataAdapter("select * from std", "server =.; initial catalog=testdb; User ID=sa; Password=123");
da.Fill(dt);
dataGridView1.DataSource = dt;
}
```
but if you're going to use such ... | you have made multiple mistakes. First you read data wirh dataraeader and in every iteration define two `stname` and `nimnum` variables like. So when loop ends variables are destroyed. You have to define data table and read data by dataraeader and and add them to it row by row. Or read by sqldataadapter and read it imm... |
49,319,217 | How should be the for-loop if I am trying to generalize this :
given `Number = 3`
```
FirstCellToWrite.Value = Controls("txtBox" & 1).Text
FirstCellToWrite.Offset(1, 0).Value = Controls("txtBox" & 2).Text
FirstCellToWrite.Offset(2, 0).Value = Controls("txtBox" & 3).Text
FirstCellToWrite.Offset(0, 1).Value = ... | 2018/03/16 | [
"https://Stackoverflow.com/questions/49319217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9228407/"
] | Try it without q or i and some maths on p.
```
For p = 0 To number - 1
debug.print "i=" & p mod 3 & ", q=" & int(p/3) & ", p=" & p+1
FirstCellToWrite.Offset(p mod 3, int(p/3)).Value = Controls("txtBox" & p+1).Text
Next p
```
Immediate window results:
```
i=0, q=0, p=1
i=1, q=0, p=2
i=2, q=0, p=3
i=0, q=1, p... | I think your p and q should be the other way around:
`FirstCellToWrite.Offset(i,p).value = Controls("txtBox" & q).Text`
And the `q = q + 1` should be between the "i" for loop. |
49,319,217 | How should be the for-loop if I am trying to generalize this :
given `Number = 3`
```
FirstCellToWrite.Value = Controls("txtBox" & 1).Text
FirstCellToWrite.Offset(1, 0).Value = Controls("txtBox" & 2).Text
FirstCellToWrite.Offset(2, 0).Value = Controls("txtBox" & 3).Text
FirstCellToWrite.Offset(0, 1).Value = ... | 2018/03/16 | [
"https://Stackoverflow.com/questions/49319217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9228407/"
] | Try using something like the following:
```
Dim ctrl As Long, RowCount As Long, ColumnCount As Long, IncrementCounter As Long
IncrementCounter = 3
For ctrl = 1 To 9
FirstCellToWrite.Offset(RowCount, ColumnCount).Value2 = Controls("txtBox" & ctrl).Text
RowCount = RowCount + 1
If ctrl Mod IncrementCounter ... | I think your p and q should be the other way around:
`FirstCellToWrite.Offset(i,p).value = Controls("txtBox" & q).Text`
And the `q = q + 1` should be between the "i" for loop. |
49,319,217 | How should be the for-loop if I am trying to generalize this :
given `Number = 3`
```
FirstCellToWrite.Value = Controls("txtBox" & 1).Text
FirstCellToWrite.Offset(1, 0).Value = Controls("txtBox" & 2).Text
FirstCellToWrite.Offset(2, 0).Value = Controls("txtBox" & 3).Text
FirstCellToWrite.Offset(0, 1).Value = ... | 2018/03/16 | [
"https://Stackoverflow.com/questions/49319217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9228407/"
] | If you simplify it less, using just 1 loop:
```
For p = 0 To (number-1)\3 'Using \ instead of / returns just the integer part
'i.e. 1/2 = 0.5, 1\2 = 0 and 5/2 = 2.5, 5\2 = 2
FirstCellToWrite.Offset(0, p).Value = Controls("txtBox" & (3*p + 1)).Text
FirstCellToWrite.Offset(1, p).Value = Controls("txtBox" & (3*p ... | I think your p and q should be the other way around:
`FirstCellToWrite.Offset(i,p).value = Controls("txtBox" & q).Text`
And the `q = q + 1` should be between the "i" for loop. |
49,319,217 | How should be the for-loop if I am trying to generalize this :
given `Number = 3`
```
FirstCellToWrite.Value = Controls("txtBox" & 1).Text
FirstCellToWrite.Offset(1, 0).Value = Controls("txtBox" & 2).Text
FirstCellToWrite.Offset(2, 0).Value = Controls("txtBox" & 3).Text
FirstCellToWrite.Offset(0, 1).Value = ... | 2018/03/16 | [
"https://Stackoverflow.com/questions/49319217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9228407/"
] | Try it without q or i and some maths on p.
```
For p = 0 To number - 1
debug.print "i=" & p mod 3 & ", q=" & int(p/3) & ", p=" & p+1
FirstCellToWrite.Offset(p mod 3, int(p/3)).Value = Controls("txtBox" & p+1).Text
Next p
```
Immediate window results:
```
i=0, q=0, p=1
i=1, q=0, p=2
i=2, q=0, p=3
i=0, q=1, p... | Try using something like the following:
```
Dim ctrl As Long, RowCount As Long, ColumnCount As Long, IncrementCounter As Long
IncrementCounter = 3
For ctrl = 1 To 9
FirstCellToWrite.Offset(RowCount, ColumnCount).Value2 = Controls("txtBox" & ctrl).Text
RowCount = RowCount + 1
If ctrl Mod IncrementCounter ... |
49,319,217 | How should be the for-loop if I am trying to generalize this :
given `Number = 3`
```
FirstCellToWrite.Value = Controls("txtBox" & 1).Text
FirstCellToWrite.Offset(1, 0).Value = Controls("txtBox" & 2).Text
FirstCellToWrite.Offset(2, 0).Value = Controls("txtBox" & 3).Text
FirstCellToWrite.Offset(0, 1).Value = ... | 2018/03/16 | [
"https://Stackoverflow.com/questions/49319217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9228407/"
] | If you simplify it less, using just 1 loop:
```
For p = 0 To (number-1)\3 'Using \ instead of / returns just the integer part
'i.e. 1/2 = 0.5, 1\2 = 0 and 5/2 = 2.5, 5\2 = 2
FirstCellToWrite.Offset(0, p).Value = Controls("txtBox" & (3*p + 1)).Text
FirstCellToWrite.Offset(1, p).Value = Controls("txtBox" & (3*p ... | Try using something like the following:
```
Dim ctrl As Long, RowCount As Long, ColumnCount As Long, IncrementCounter As Long
IncrementCounter = 3
For ctrl = 1 To 9
FirstCellToWrite.Offset(RowCount, ColumnCount).Value2 = Controls("txtBox" & ctrl).Text
RowCount = RowCount + 1
If ctrl Mod IncrementCounter ... |
59,792,174 | I have a dataframe of data for 400,000 trees of 6 different species. Each species is assigned a numeric species code that corresponds with a specific species. I would like to add another column listing the scientific name of each tree. The species codes are not consecutive, as this data was filtered down from 490,000 t... | 2020/01/17 | [
"https://Stackoverflow.com/questions/59792174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12732850/"
] | One solution would be to use `mutate` with `case_when` if you know which numbers correspond to what Species, I have filled out some of them which gives the code to follow on:
```
library(tidyverse)
x <-"
Index Age Species_code
0 45 14
1 47 32
2 14 62
3 78 126
4 ... | You may want to use the `ifelse()` function.
You may also want to use:
```
my_names <- numeric()
my_names[47] <- "Licania_heteromorpha"
my_names[63] <- "Chrysophyllum_cuneifolium"
...
df$Species <- names[df$Species_code]
```
You may yet also have a look at `dplyr` numerous functions for that, like `case_when` and `... |
59,792,174 | I have a dataframe of data for 400,000 trees of 6 different species. Each species is assigned a numeric species code that corresponds with a specific species. I would like to add another column listing the scientific name of each tree. The species codes are not consecutive, as this data was filtered down from 490,000 t... | 2020/01/17 | [
"https://Stackoverflow.com/questions/59792174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12732850/"
] | One solution would be to use `mutate` with `case_when` if you know which numbers correspond to what Species, I have filled out some of them which gives the code to follow on:
```
library(tidyverse)
x <-"
Index Age Species_code
0 45 14
1 47 32
2 14 62
3 78 126
4 ... | As your problem have only 6 especies, you can do this:
```
df$Species = NULL
df$Species[df$Species_code == 14] = 'Licania_heteromorpha'
df$Species[df$Species_code == 32] = 'Pouteria_reticulata'
.....
``` |
45,096,654 | I recently signed up and started playing with GAE for python. I was able to get their standard/flask/hello\_world project. But, when I tried to upload a simple cron job following the instructions at <https://cloud.google.com/appengine/docs/standard/python/config/cron>, I get an "Internal Server Error".
My cron.yaml
`... | 2017/07/14 | [
"https://Stackoverflow.com/questions/45096654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/593644/"
] | I was having this problem as well, at about the same timeline. Without any changes, the deploy worked this morning, so my guess is that this was a transient server problem on Google's part. | I was just struggling with this same issue. In my case, I am using the PHP standard environment and kept receiving the '500 Internal Server Error' when I tried to publish our cron.yaml file from the Google Cloud SDK with the command:
```
gcloud app deploy cron.yaml --project {PROJECT_NAME}
```
To fix it, I did the f... |
65,110,119 | When I write following, it gives no compilation warning/error.
```
long universe_of_defects = 4294967295L;
```
But when I negate the long int, it gives compilation warning.
```
long universe_of_defects = -4294967295L;
warning: overflow in conversion from 'long long int' to 'long int' changes value from '-4294... | 2020/12/02 | [
"https://Stackoverflow.com/questions/65110119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14401473/"
] | That's just an artifact of your client tool.
In reality, PostgreSQL users don't belong to any database; they are shared by all databases. So no matter to which database you are connected when you create a user, it will equally exist for all databases.
You can use the `CONNECT` permission on the database object or (mo... | According to <https://www.postgresql.org/docs/current/sql-createrole.html>:
>
> CREATE ROLE adds a new role to a PostgreSQL database cluster. A role is an entity that can own database objects and have database privileges; a role can be considered a “user”, a “group”, or both depending on how it is used. Refer to Chap... |
4,701,330 | We want to find the shortest path between two points in a special grid. We can travel between adjacent squares in a single move, but we can also travel between cells of the same type (there are 10 types) in a single move no matter the distance between them.
How can we find the the number of steps required to travel be... | 2011/01/15 | [
"https://Stackoverflow.com/questions/4701330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/89806/"
] | You can represent the maze as a graph and solve it using BFS (it works for this case and is simpler than Dijkstra and A\*).
In order to fill the edges you can do this:
```
for each row
for each line
if char == 'S' mark this point as start
if char == 'E' mark this point as end
if char != 'W' then
... | This could be done with [Dynamic programming](http://en.wikipedia.org/wiki/Dynamic_programming). Here you define connectivity, and start on the first square. You keep record of the minimal distance found to travel to a certain point. When you reached your endpoint, you find the path by backtracking the route of quickes... |
4,701,330 | We want to find the shortest path between two points in a special grid. We can travel between adjacent squares in a single move, but we can also travel between cells of the same type (there are 10 types) in a single move no matter the distance between them.
How can we find the the number of steps required to travel be... | 2011/01/15 | [
"https://Stackoverflow.com/questions/4701330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/89806/"
] | Make 10 arrays, each one containing the cells of corresponding type. Now run Dijkstra (or BFS), but when you visit a cell of type `i`, add all cells of type `i` to the queue and clear the corresponding array. This way you don't have to visit every edge between cells of the same type and the complexity is O(n^2) instead... | You can represent the maze as a graph and solve it using BFS (it works for this case and is simpler than Dijkstra and A\*).
In order to fill the edges you can do this:
```
for each row
for each line
if char == 'S' mark this point as start
if char == 'E' mark this point as end
if char != 'W' then
... |
4,701,330 | We want to find the shortest path between two points in a special grid. We can travel between adjacent squares in a single move, but we can also travel between cells of the same type (there are 10 types) in a single move no matter the distance between them.
How can we find the the number of steps required to travel be... | 2011/01/15 | [
"https://Stackoverflow.com/questions/4701330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/89806/"
] | Make 10 arrays, each one containing the cells of corresponding type. Now run Dijkstra (or BFS), but when you visit a cell of type `i`, add all cells of type `i` to the queue and clear the corresponding array. This way you don't have to visit every edge between cells of the same type and the complexity is O(n^2) instead... | I think the simplest way to solve is model the grid as a graph. Create an edge between 2 neighbors, also create one edge between two nodes of same type. After that, a simple BFS from source to dest can answer the shortest path between the two nodes.
<http://en.wikipedia.org/wiki/Breadth-first_search>
The complexity i... |
4,701,330 | We want to find the shortest path between two points in a special grid. We can travel between adjacent squares in a single move, but we can also travel between cells of the same type (there are 10 types) in a single move no matter the distance between them.
How can we find the the number of steps required to travel be... | 2011/01/15 | [
"https://Stackoverflow.com/questions/4701330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/89806/"
] | Make 10 arrays, each one containing the cells of corresponding type. Now run Dijkstra (or BFS), but when you visit a cell of type `i`, add all cells of type `i` to the queue and clear the corresponding array. This way you don't have to visit every edge between cells of the same type and the complexity is O(n^2) instead... | I solved this one during the contest by using BFS.
The problem can be modeled as a graph. Each cell is a node and has an edge with each adjacent cell. Instead of building the graph explicitly, we can simply keep the graph implicit by visiting each cell and its neighbours by computing grid coordinates as needed.
Each ... |
4,701,330 | We want to find the shortest path between two points in a special grid. We can travel between adjacent squares in a single move, but we can also travel between cells of the same type (there are 10 types) in a single move no matter the distance between them.
How can we find the the number of steps required to travel be... | 2011/01/15 | [
"https://Stackoverflow.com/questions/4701330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/89806/"
] | You can represent the maze as a graph and solve it using BFS (it works for this case and is simpler than Dijkstra and A\*).
In order to fill the edges you can do this:
```
for each row
for each line
if char == 'S' mark this point as start
if char == 'E' mark this point as end
if char != 'W' then
... | Construct a graph of all the squares as vertices with the edges marking possible moves and then let Dijkstra's algorithm work it out. |
4,701,330 | We want to find the shortest path between two points in a special grid. We can travel between adjacent squares in a single move, but we can also travel between cells of the same type (there are 10 types) in a single move no matter the distance between them.
How can we find the the number of steps required to travel be... | 2011/01/15 | [
"https://Stackoverflow.com/questions/4701330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/89806/"
] | I solved this one during the contest by using BFS.
The problem can be modeled as a graph. Each cell is a node and has an edge with each adjacent cell. Instead of building the graph explicitly, we can simply keep the graph implicit by visiting each cell and its neighbours by computing grid coordinates as needed.
Each ... | Construct a graph of all the squares as vertices with the edges marking possible moves and then let Dijkstra's algorithm work it out. |
4,701,330 | We want to find the shortest path between two points in a special grid. We can travel between adjacent squares in a single move, but we can also travel between cells of the same type (there are 10 types) in a single move no matter the distance between them.
How can we find the the number of steps required to travel be... | 2011/01/15 | [
"https://Stackoverflow.com/questions/4701330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/89806/"
] | I solved this one during the contest by using BFS.
The problem can be modeled as a graph. Each cell is a node and has an edge with each adjacent cell. Instead of building the graph explicitly, we can simply keep the graph implicit by visiting each cell and its neighbours by computing grid coordinates as needed.
Each ... | I think the simplest way to solve is model the grid as a graph. Create an edge between 2 neighbors, also create one edge between two nodes of same type. After that, a simple BFS from source to dest can answer the shortest path between the two nodes.
<http://en.wikipedia.org/wiki/Breadth-first_search>
The complexity i... |
4,701,330 | We want to find the shortest path between two points in a special grid. We can travel between adjacent squares in a single move, but we can also travel between cells of the same type (there are 10 types) in a single move no matter the distance between them.
How can we find the the number of steps required to travel be... | 2011/01/15 | [
"https://Stackoverflow.com/questions/4701330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/89806/"
] | I think the simplest way to solve is model the grid as a graph. Create an edge between 2 neighbors, also create one edge between two nodes of same type. After that, a simple BFS from source to dest can answer the shortest path between the two nodes.
<http://en.wikipedia.org/wiki/Breadth-first_search>
The complexity i... | Construct a graph of all the squares as vertices with the edges marking possible moves and then let Dijkstra's algorithm work it out. |
4,701,330 | We want to find the shortest path between two points in a special grid. We can travel between adjacent squares in a single move, but we can also travel between cells of the same type (there are 10 types) in a single move no matter the distance between them.
How can we find the the number of steps required to travel be... | 2011/01/15 | [
"https://Stackoverflow.com/questions/4701330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/89806/"
] | Make 10 arrays, each one containing the cells of corresponding type. Now run Dijkstra (or BFS), but when you visit a cell of type `i`, add all cells of type `i` to the queue and clear the corresponding array. This way you don't have to visit every edge between cells of the same type and the complexity is O(n^2) instead... | Construct a graph of all the squares as vertices with the edges marking possible moves and then let Dijkstra's algorithm work it out. |
4,701,330 | We want to find the shortest path between two points in a special grid. We can travel between adjacent squares in a single move, but we can also travel between cells of the same type (there are 10 types) in a single move no matter the distance between them.
How can we find the the number of steps required to travel be... | 2011/01/15 | [
"https://Stackoverflow.com/questions/4701330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/89806/"
] | I solved this one during the contest by using BFS.
The problem can be modeled as a graph. Each cell is a node and has an edge with each adjacent cell. Instead of building the graph explicitly, we can simply keep the graph implicit by visiting each cell and its neighbours by computing grid coordinates as needed.
Each ... | You can represent the maze as a graph and solve it using BFS (it works for this case and is simpler than Dijkstra and A\*).
In order to fill the edges you can do this:
```
for each row
for each line
if char == 'S' mark this point as start
if char == 'E' mark this point as end
if char != 'W' then
... |
499,738 | I am newbie with Ubuntu.I am trying to download Okular pdf reader from Software Center but I am getting some error.
At first it was asking for installation of packages from not authenticated source,when I click on **Use this source** it goes and do something like
**upadating cache**  since May 2014. You either need to update to a more recent version of Ubuntu (i.e. 14.04), or find an alternative repository. The alternative repository for 12.10 is released [h... | As 12.10 is EOL, the repos for it have moved. Upgrade to a newer version of ubuntu (or downgrade to 12.04, though that is really not recommended) to access the normal repos. If you absolutely need to use that version of ubuntu, consider adding the archive repos, google for instructions on how to do that. In the end my ... |
303,502 | I know about this theory but I cannot get the picture that how moving faster than light even 100.01% of light-speed would make universe run backward. | 2017/01/07 | [
"https://physics.stackexchange.com/questions/303502",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/33504/"
] | So, rather than make some general argument, I will show how, if you can send things faster than light between two points, you can send things backwards in time. To do this, I will need to assume two things:
* the Lorentz transformations are correct;
* all inertial frames are equivalent & in particular if you can do so... | If you exceed the speed of light the traditional gamma factor in special relativity gets an imaginary value for the ratio of times (and also the ratio of lengths) from the viewpoint of observers which is meaningless unless you want to consider [Godel metric](https://en.wikipedia.org/wiki/G%C3%B6del_metric) according to... |
16,301,384 | I have headers:
```
header('Content-Type: text/html; charset=UTF-8');
header("Content-type: application/octetstream");
header('Content-Disposition: attachment; filename="export.csv"');
```
but decoding not work correct if I have word in database `"Pagrindinė"` in excel show `"Pagr... | 2013/04/30 | [
"https://Stackoverflow.com/questions/16301384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2287965/"
] | >
> What is wrong with my headers ?
>
>
>
Nothing, your headers are looking fine.
>
> What is wrong with Excel?
>
>
>
The user who opens the file in Excel needs to tell Excel that the file is in UTF-8 encoding. Direct that user to contact the vendor of the software it uses for her/his support options.
Users... | Maybe if you change the format text encoding of your .php file when you save it, to Unicode (UTF-8). It works for me.
Hope it helps. |
16,301,384 | I have headers:
```
header('Content-Type: text/html; charset=UTF-8');
header("Content-type: application/octetstream");
header('Content-Disposition: attachment; filename="export.csv"');
```
but decoding not work correct if I have word in database `"Pagrindinė"` in excel show `"Pagr... | 2013/04/30 | [
"https://Stackoverflow.com/questions/16301384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2287965/"
] | >
> What is wrong with my headers ?
>
>
>
Nothing, your headers are looking fine.
>
> What is wrong with Excel?
>
>
>
The user who opens the file in Excel needs to tell Excel that the file is in UTF-8 encoding. Direct that user to contact the vendor of the software it uses for her/his support options.
Users... | try this:
```
header('Content-Transfer-Encoding: binary');
header("Content-Type: application/octet-stream");
header("Content-Transfer-Encoding: binary");
header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
header('Content-Disposition: attachment; filename = "Export '.date("Y-m-d").'.xls"');
header('Pragma: no-ca... |
45,037,540 | Here is a code to download File from Google Cloud Storage:
```
@Override
public void write(OutputStream outputStream) throws IOException {
try {
LOG.info(path);
InputStream stream = new ByteArrayInputStream(GoogleJsonKey.JSON_KEY.getBytes(StandardCharsets.UTF_8));
StorageOptions options = S... | 2017/07/11 | [
"https://Stackoverflow.com/questions/45037540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/785349/"
] | Just to clarify, do you need an `OutputStream` or an `InputStream` ? One way to look at this is that the data stored in Google Cloud Storage object as a file and you having an InputStream to read that file. If that works, read on.
There is no existing method in Storage API which provides an `InputStream` or an `Outpu... | Currently the cleanest option I could find looks like this:
```
Blob blob = bucket.get("some-file");
ReadChannel reader = blob.reader();
InputStream inputStream = Channels.newInputStream(reader);
```
The Channels is from java.nio. Furthermore you can then use commons io to easily read to InputStream into an OutputSt... |
45,037,540 | Here is a code to download File from Google Cloud Storage:
```
@Override
public void write(OutputStream outputStream) throws IOException {
try {
LOG.info(path);
InputStream stream = new ByteArrayInputStream(GoogleJsonKey.JSON_KEY.getBytes(StandardCharsets.UTF_8));
StorageOptions options = S... | 2017/07/11 | [
"https://Stackoverflow.com/questions/45037540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/785349/"
] | Just to clarify, do you need an `OutputStream` or an `InputStream` ? One way to look at this is that the data stored in Google Cloud Storage object as a file and you having an InputStream to read that file. If that works, read on.
There is no existing method in Storage API which provides an `InputStream` or an `Outpu... | Code, based on @Tuxdude answer
```
@Nullable
public byte[] getFileBytes(String gcsUri) throws IOException {
Blob blob = getBlob(gcsUri);
ReadChannel reader;
byte[] result = null;
if (blob != null) {
reader = blob.reader();
InputStream inputStream = Channels... |
45,037,540 | Here is a code to download File from Google Cloud Storage:
```
@Override
public void write(OutputStream outputStream) throws IOException {
try {
LOG.info(path);
InputStream stream = new ByteArrayInputStream(GoogleJsonKey.JSON_KEY.getBytes(StandardCharsets.UTF_8));
StorageOptions options = S... | 2017/07/11 | [
"https://Stackoverflow.com/questions/45037540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/785349/"
] | Just to clarify, do you need an `OutputStream` or an `InputStream` ? One way to look at this is that the data stored in Google Cloud Storage object as a file and you having an InputStream to read that file. If that works, read on.
There is no existing method in Storage API which provides an `InputStream` or an `Outpu... | Another (convenient) way to stream a file from Google Cloud Storage, with [google-cloud-nio](https://github.com/googleapis/google-cloud-java/tree/v0.30.0/google-cloud-contrib/google-cloud-nio):
```java
Path path = Paths.get(URI.create("gs://bucket/file.csv"));
InputStream in = Files.newInputStream(path);
``` |
45,037,540 | Here is a code to download File from Google Cloud Storage:
```
@Override
public void write(OutputStream outputStream) throws IOException {
try {
LOG.info(path);
InputStream stream = new ByteArrayInputStream(GoogleJsonKey.JSON_KEY.getBytes(StandardCharsets.UTF_8));
StorageOptions options = S... | 2017/07/11 | [
"https://Stackoverflow.com/questions/45037540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/785349/"
] | Just to clarify, do you need an `OutputStream` or an `InputStream` ? One way to look at this is that the data stored in Google Cloud Storage object as a file and you having an InputStream to read that file. If that works, read on.
There is no existing method in Storage API which provides an `InputStream` or an `Outpu... | Folks should be using Java 9 or above by now and so can use InputStream `transferTo` the output stream:
```java
// the resource url is something like gs://youbucket/some/file/path.csv
public InputStream getUriAsInputStream( Storage storage, String resourceUri) {
String[] parts = resourceUri.split("/")... |
45,037,540 | Here is a code to download File from Google Cloud Storage:
```
@Override
public void write(OutputStream outputStream) throws IOException {
try {
LOG.info(path);
InputStream stream = new ByteArrayInputStream(GoogleJsonKey.JSON_KEY.getBytes(StandardCharsets.UTF_8));
StorageOptions options = S... | 2017/07/11 | [
"https://Stackoverflow.com/questions/45037540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/785349/"
] | Currently the cleanest option I could find looks like this:
```
Blob blob = bucket.get("some-file");
ReadChannel reader = blob.reader();
InputStream inputStream = Channels.newInputStream(reader);
```
The Channels is from java.nio. Furthermore you can then use commons io to easily read to InputStream into an OutputSt... | Code, based on @Tuxdude answer
```
@Nullable
public byte[] getFileBytes(String gcsUri) throws IOException {
Blob blob = getBlob(gcsUri);
ReadChannel reader;
byte[] result = null;
if (blob != null) {
reader = blob.reader();
InputStream inputStream = Channels... |
45,037,540 | Here is a code to download File from Google Cloud Storage:
```
@Override
public void write(OutputStream outputStream) throws IOException {
try {
LOG.info(path);
InputStream stream = new ByteArrayInputStream(GoogleJsonKey.JSON_KEY.getBytes(StandardCharsets.UTF_8));
StorageOptions options = S... | 2017/07/11 | [
"https://Stackoverflow.com/questions/45037540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/785349/"
] | Currently the cleanest option I could find looks like this:
```
Blob blob = bucket.get("some-file");
ReadChannel reader = blob.reader();
InputStream inputStream = Channels.newInputStream(reader);
```
The Channels is from java.nio. Furthermore you can then use commons io to easily read to InputStream into an OutputSt... | Another (convenient) way to stream a file from Google Cloud Storage, with [google-cloud-nio](https://github.com/googleapis/google-cloud-java/tree/v0.30.0/google-cloud-contrib/google-cloud-nio):
```java
Path path = Paths.get(URI.create("gs://bucket/file.csv"));
InputStream in = Files.newInputStream(path);
``` |
45,037,540 | Here is a code to download File from Google Cloud Storage:
```
@Override
public void write(OutputStream outputStream) throws IOException {
try {
LOG.info(path);
InputStream stream = new ByteArrayInputStream(GoogleJsonKey.JSON_KEY.getBytes(StandardCharsets.UTF_8));
StorageOptions options = S... | 2017/07/11 | [
"https://Stackoverflow.com/questions/45037540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/785349/"
] | Currently the cleanest option I could find looks like this:
```
Blob blob = bucket.get("some-file");
ReadChannel reader = blob.reader();
InputStream inputStream = Channels.newInputStream(reader);
```
The Channels is from java.nio. Furthermore you can then use commons io to easily read to InputStream into an OutputSt... | Folks should be using Java 9 or above by now and so can use InputStream `transferTo` the output stream:
```java
// the resource url is something like gs://youbucket/some/file/path.csv
public InputStream getUriAsInputStream( Storage storage, String resourceUri) {
String[] parts = resourceUri.split("/")... |
45,037,540 | Here is a code to download File from Google Cloud Storage:
```
@Override
public void write(OutputStream outputStream) throws IOException {
try {
LOG.info(path);
InputStream stream = new ByteArrayInputStream(GoogleJsonKey.JSON_KEY.getBytes(StandardCharsets.UTF_8));
StorageOptions options = S... | 2017/07/11 | [
"https://Stackoverflow.com/questions/45037540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/785349/"
] | Code, based on @Tuxdude answer
```
@Nullable
public byte[] getFileBytes(String gcsUri) throws IOException {
Blob blob = getBlob(gcsUri);
ReadChannel reader;
byte[] result = null;
if (blob != null) {
reader = blob.reader();
InputStream inputStream = Channels... | Another (convenient) way to stream a file from Google Cloud Storage, with [google-cloud-nio](https://github.com/googleapis/google-cloud-java/tree/v0.30.0/google-cloud-contrib/google-cloud-nio):
```java
Path path = Paths.get(URI.create("gs://bucket/file.csv"));
InputStream in = Files.newInputStream(path);
``` |
45,037,540 | Here is a code to download File from Google Cloud Storage:
```
@Override
public void write(OutputStream outputStream) throws IOException {
try {
LOG.info(path);
InputStream stream = new ByteArrayInputStream(GoogleJsonKey.JSON_KEY.getBytes(StandardCharsets.UTF_8));
StorageOptions options = S... | 2017/07/11 | [
"https://Stackoverflow.com/questions/45037540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/785349/"
] | Code, based on @Tuxdude answer
```
@Nullable
public byte[] getFileBytes(String gcsUri) throws IOException {
Blob blob = getBlob(gcsUri);
ReadChannel reader;
byte[] result = null;
if (blob != null) {
reader = blob.reader();
InputStream inputStream = Channels... | Folks should be using Java 9 or above by now and so can use InputStream `transferTo` the output stream:
```java
// the resource url is something like gs://youbucket/some/file/path.csv
public InputStream getUriAsInputStream( Storage storage, String resourceUri) {
String[] parts = resourceUri.split("/")... |
45,037,540 | Here is a code to download File from Google Cloud Storage:
```
@Override
public void write(OutputStream outputStream) throws IOException {
try {
LOG.info(path);
InputStream stream = new ByteArrayInputStream(GoogleJsonKey.JSON_KEY.getBytes(StandardCharsets.UTF_8));
StorageOptions options = S... | 2017/07/11 | [
"https://Stackoverflow.com/questions/45037540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/785349/"
] | Another (convenient) way to stream a file from Google Cloud Storage, with [google-cloud-nio](https://github.com/googleapis/google-cloud-java/tree/v0.30.0/google-cloud-contrib/google-cloud-nio):
```java
Path path = Paths.get(URI.create("gs://bucket/file.csv"));
InputStream in = Files.newInputStream(path);
``` | Folks should be using Java 9 or above by now and so can use InputStream `transferTo` the output stream:
```java
// the resource url is something like gs://youbucket/some/file/path.csv
public InputStream getUriAsInputStream( Storage storage, String resourceUri) {
String[] parts = resourceUri.split("/")... |
10,810,450 | I have two divs `div1` and `div2`. I want div2 to be automatically hidden but when i click on `preview` div then `div2` to be made visible and `div1` to hide. This is the code i tried but no luck :(
```
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javasc... | 2012/05/30 | [
"https://Stackoverflow.com/questions/10810450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/639406/"
] | This is an easier way to do it. Hope this helps...
```
<script type="text/javascript">
$(document).ready(function () {
$("#preview").toggle(function() {
$("#div1").hide();
$("#div2").show();
}, function() {
$("#div1").show();
$("#div2").hide();
});
});
<div id="div1">
This ... | The second time you're referring to div2, you're not using the # id selector.
There's no element named div2. |
10,810,450 | I have two divs `div1` and `div2`. I want div2 to be automatically hidden but when i click on `preview` div then `div2` to be made visible and `div1` to hide. This is the code i tried but no luck :(
```
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javasc... | 2012/05/30 | [
"https://Stackoverflow.com/questions/10810450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/639406/"
] | This is an easier way to do it. Hope this helps...
```
<script type="text/javascript">
$(document).ready(function () {
$("#preview").toggle(function() {
$("#div1").hide();
$("#div2").show();
}, function() {
$("#div1").show();
$("#div2").hide();
});
});
<div id="div1">
This ... | At first if you want to hide div element with id = "abc" on load and then toggle between hide and show using a button with id = "btn" then,
```
$(document).ready(function() {
$("#abc").hide();
$("#btn").click(function() {
$("#abc").toggle();
});
});
``` |
10,810,450 | I have two divs `div1` and `div2`. I want div2 to be automatically hidden but when i click on `preview` div then `div2` to be made visible and `div1` to hide. This is the code i tried but no luck :(
```
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javasc... | 2012/05/30 | [
"https://Stackoverflow.com/questions/10810450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/639406/"
] | Make sure to watch your selectors. You appear to have forgotten the `#` for `div2`. Additionally, you can toggle the visibility of many elements at once with `.toggle()`:
```
// Short-form of `document.ready`
$(function(){
$("#div2").hide();
$("#preview").on("click", function(){
$("#div1, #div2").toggl... | At first if you want to hide div element with id = "abc" on load and then toggle between hide and show using a button with id = "btn" then,
```
$(document).ready(function() {
$("#abc").hide();
$("#btn").click(function() {
$("#abc").toggle();
});
});
``` |
10,810,450 | I have two divs `div1` and `div2`. I want div2 to be automatically hidden but when i click on `preview` div then `div2` to be made visible and `div1` to hide. This is the code i tried but no luck :(
```
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javasc... | 2012/05/30 | [
"https://Stackoverflow.com/questions/10810450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/639406/"
] | This is an easier way to do it. Hope this helps...
```
<script type="text/javascript">
$(document).ready(function () {
$("#preview").toggle(function() {
$("#div1").hide();
$("#div2").show();
}, function() {
$("#div1").show();
$("#div2").hide();
});
});
<div id="div1">
This ... | ```
$(document).ready(function() {
$('#div2').hide(0);
$('#preview').on('click', function() {
$('#div1').hide(300, function() { // first hide div1
// then show div2
$('#div2').show(300);
});
});
});
```
You missed `#` before `div2`
**[Working Sample](http://js... |
10,810,450 | I have two divs `div1` and `div2`. I want div2 to be automatically hidden but when i click on `preview` div then `div2` to be made visible and `div1` to hide. This is the code i tried but no luck :(
```
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javasc... | 2012/05/30 | [
"https://Stackoverflow.com/questions/10810450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/639406/"
] | You are missing `#` hash character before id selectors, this should work:
```
$(document).ready(function() {
$("#div2").hide();
$("#preview").click(function() {
$("#div1").hide();
$("#div2").show();
});
});
```
---
[Learn More about jQuery ID Selectors](http://api.jquery.com/id-selector/) | The second time you're referring to div2, you're not using the # id selector.
There's no element named div2. |
10,810,450 | I have two divs `div1` and `div2`. I want div2 to be automatically hidden but when i click on `preview` div then `div2` to be made visible and `div1` to hide. This is the code i tried but no luck :(
```
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javasc... | 2012/05/30 | [
"https://Stackoverflow.com/questions/10810450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/639406/"
] | Make sure to watch your selectors. You appear to have forgotten the `#` for `div2`. Additionally, you can toggle the visibility of many elements at once with `.toggle()`:
```
// Short-form of `document.ready`
$(function(){
$("#div2").hide();
$("#preview").on("click", function(){
$("#div1, #div2").toggl... | This is an easier way to do it. Hope this helps...
```
<script type="text/javascript">
$(document).ready(function () {
$("#preview").toggle(function() {
$("#div1").hide();
$("#div2").show();
}, function() {
$("#div1").show();
$("#div2").hide();
});
});
<div id="div1">
This ... |
10,810,450 | I have two divs `div1` and `div2`. I want div2 to be automatically hidden but when i click on `preview` div then `div2` to be made visible and `div1` to hide. This is the code i tried but no luck :(
```
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javasc... | 2012/05/30 | [
"https://Stackoverflow.com/questions/10810450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/639406/"
] | You are missing `#` hash character before id selectors, this should work:
```
$(document).ready(function() {
$("#div2").hide();
$("#preview").click(function() {
$("#div1").hide();
$("#div2").show();
});
});
```
---
[Learn More about jQuery ID Selectors](http://api.jquery.com/id-selector/) | ```
$(document).ready(function() {
$('#div2').hide(0);
$('#preview').on('click', function() {
$('#div1').hide(300, function() { // first hide div1
// then show div2
$('#div2').show(300);
});
});
});
```
You missed `#` before `div2`
**[Working Sample](http://js... |
10,810,450 | I have two divs `div1` and `div2`. I want div2 to be automatically hidden but when i click on `preview` div then `div2` to be made visible and `div1` to hide. This is the code i tried but no luck :(
```
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javasc... | 2012/05/30 | [
"https://Stackoverflow.com/questions/10810450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/639406/"
] | Make sure to watch your selectors. You appear to have forgotten the `#` for `div2`. Additionally, you can toggle the visibility of many elements at once with `.toggle()`:
```
// Short-form of `document.ready`
$(function(){
$("#div2").hide();
$("#preview").on("click", function(){
$("#div1, #div2").toggl... | ```
$(document).ready(function() {
$('#div2').hide(0);
$('#preview').on('click', function() {
$('#div1').hide(300, function() { // first hide div1
// then show div2
$('#div2').show(300);
});
});
});
```
You missed `#` before `div2`
**[Working Sample](http://js... |
10,810,450 | I have two divs `div1` and `div2`. I want div2 to be automatically hidden but when i click on `preview` div then `div2` to be made visible and `div1` to hide. This is the code i tried but no luck :(
```
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javasc... | 2012/05/30 | [
"https://Stackoverflow.com/questions/10810450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/639406/"
] | Make sure to watch your selectors. You appear to have forgotten the `#` for `div2`. Additionally, you can toggle the visibility of many elements at once with `.toggle()`:
```
// Short-form of `document.ready`
$(function(){
$("#div2").hide();
$("#preview").on("click", function(){
$("#div1, #div2").toggl... | You are missing `#` hash character before id selectors, this should work:
```
$(document).ready(function() {
$("#div2").hide();
$("#preview").click(function() {
$("#div1").hide();
$("#div2").show();
});
});
```
---
[Learn More about jQuery ID Selectors](http://api.jquery.com/id-selector/) |
10,810,450 | I have two divs `div1` and `div2`. I want div2 to be automatically hidden but when i click on `preview` div then `div2` to be made visible and `div1` to hide. This is the code i tried but no luck :(
```
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javasc... | 2012/05/30 | [
"https://Stackoverflow.com/questions/10810450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/639406/"
] | Make sure to watch your selectors. You appear to have forgotten the `#` for `div2`. Additionally, you can toggle the visibility of many elements at once with `.toggle()`:
```
// Short-form of `document.ready`
$(function(){
$("#div2").hide();
$("#preview").on("click", function(){
$("#div1, #div2").toggl... | The second time you're referring to div2, you're not using the # id selector.
There's no element named div2. |
33,443,130 | ```
template <int* ip> struct test {};
struct q {
static int a;
int b;
constexpr q(int b_) : b(b_) {}
};
int i;
constexpr q q0(2);
int main()
{
constexpr test<&i> t1; // Works fine
constexpr test<&q::a> t2; // Works
constexpr test<&q0.b> t3; // Does not work; address of non-static ... | 2015/10/30 | [
"https://Stackoverflow.com/questions/33443130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2035439/"
] | First, to use pointers/references to subobjects, you'd need to be able to mangle them. That's a pretty big undertaking.
Second, and probably more importantly, from [N4198](http://wg21.link/N4198):
>
> The restriction that the constant expression must name a complete
> object is retained to avoid aliasing problems w... | Replace your main with this piece of code
```
int main(void)
{
constexpr static int bb = 5;
constexpr test<&bb> t;
return 0;
}
```
and you will receive the error bb cannot be used as a template argument because it has no linkage ( not to be mistaken with linker related staff ) .
Class data members canno... |
3,150,605 | my company wants to sponsor me for some online sql server DBA classes. can someone please recommend a beginner's class to me? | 2010/06/30 | [
"https://Stackoverflow.com/questions/3150605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/117700/"
] | Use an existing template engine if you want something on top of PHP, don't reinvent the wheel.
Give twig a go <http://www.twig-project.org/> | 1) use MVC pattern instead.
2) PHP is template engine. Why just dont use it? |
3,150,605 | my company wants to sponsor me for some online sql server DBA classes. can someone please recommend a beginner's class to me? | 2010/06/30 | [
"https://Stackoverflow.com/questions/3150605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/117700/"
] | 1) use MVC pattern instead.
2) PHP is template engine. Why just dont use it? | It is my duty as a programmer to toot [my own horn](http://sourceforge.net/projects/vision-language/) in the hope that I might be helpful. |
3,150,605 | my company wants to sponsor me for some online sql server DBA classes. can someone please recommend a beginner's class to me? | 2010/06/30 | [
"https://Stackoverflow.com/questions/3150605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/117700/"
] | Use an existing template engine if you want something on top of PHP, don't reinvent the wheel.
Give twig a go <http://www.twig-project.org/> | It is my duty as a programmer to toot [my own horn](http://sourceforge.net/projects/vision-language/) in the hope that I might be helpful. |
3,859,801 | What is the difference between
`margin-left: 10px;` and `position: relative; left: 10px;`?
It seems to produce the same result | 2010/10/04 | [
"https://Stackoverflow.com/questions/3859801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/434273/"
] | When you move something with `position:relative` you're not actually moving the space it takes up on the page, just where it is displayed.
An easy way to test this is to use a simple structure like this:
```
<div id = "testbox">
<img src = "http://www.dummyimage.com/300x200" id = "first">
<img src = "http://www.d... | I can only suppose it is there for other positions with margins. i.e.:
```
margin-left: 5px;
position: inherited; left: 10px;
``` |
3,859,801 | What is the difference between
`margin-left: 10px;` and `position: relative; left: 10px;`?
It seems to produce the same result | 2010/10/04 | [
"https://Stackoverflow.com/questions/3859801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/434273/"
] | The simplest way I can explain it is that `margin-left` moves the element itself, whereas `left` (with `position: relative`) pushes other elements away. Although that's not, perhaps the clearest description.
With pictures, though:
```
+----------------------------------------------------------------------... | I can only suppose it is there for other positions with margins. i.e.:
```
margin-left: 5px;
position: inherited; left: 10px;
``` |
3,859,801 | What is the difference between
`margin-left: 10px;` and `position: relative; left: 10px;`?
It seems to produce the same result | 2010/10/04 | [
"https://Stackoverflow.com/questions/3859801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/434273/"
] | When you move something with `position:relative` you're not actually moving the space it takes up on the page, just where it is displayed.
An easy way to test this is to use a simple structure like this:
```
<div id = "testbox">
<img src = "http://www.dummyimage.com/300x200" id = "first">
<img src = "http://www.d... | The simplest way I can explain it is that `margin-left` moves the element itself, whereas `left` (with `position: relative`) pushes other elements away. Although that's not, perhaps the clearest description.
With pictures, though:
```
+----------------------------------------------------------------------... |
3,859,801 | What is the difference between
`margin-left: 10px;` and `position: relative; left: 10px;`?
It seems to produce the same result | 2010/10/04 | [
"https://Stackoverflow.com/questions/3859801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/434273/"
] | When you move something with `position:relative` you're not actually moving the space it takes up on the page, just where it is displayed.
An easy way to test this is to use a simple structure like this:
```
<div id = "testbox">
<img src = "http://www.dummyimage.com/300x200" id = "first">
<img src = "http://www.d... | Consider any given block element (a DIV for example) as a box. `position:relative;` makes the box's position on the page relative to the element it is nested inside (another DIV for example) and `left:10px;` moves the box 10 pixels to the right (AWAY from the left).
Now `margin-left: 10px;` has nothing to do with that... |
3,859,801 | What is the difference between
`margin-left: 10px;` and `position: relative; left: 10px;`?
It seems to produce the same result | 2010/10/04 | [
"https://Stackoverflow.com/questions/3859801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/434273/"
] | The simplest way I can explain it is that `margin-left` moves the element itself, whereas `left` (with `position: relative`) pushes other elements away. Although that's not, perhaps the clearest description.
With pictures, though:
```
+----------------------------------------------------------------------... | Consider any given block element (a DIV for example) as a box. `position:relative;` makes the box's position on the page relative to the element it is nested inside (another DIV for example) and `left:10px;` moves the box 10 pixels to the right (AWAY from the left).
Now `margin-left: 10px;` has nothing to do with that... |
44,961,759 | A messenger displays the search results based on the input given by the user. Need to highlight the word that is been searched, while displaying the result.
These are the html and component that is been used.
**Component.html**
```
<div *ngFor = "let result of resultArray">
<div>Id : result.id </div>
<div>Summary :... | 2017/07/07 | [
"https://Stackoverflow.com/questions/44961759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8089526/"
] | The selected answer has the following issues:
1. It will return undefined if there is nothing provided in the search string
2. The search should be case insensitive but that should not replace the original string case.
i would suggest the following code instead
```
transform(value: string, args: string): any {
i... | Building on a previous answer (HighlightedText-Component) I ended up with this:
```
import { Component, Input, OnChanges } from "@angular/core";
@Component({
selector: 'highlighted-text',
template: `
<ng-container *ngFor="let match of result">
<mark *ngIf="(match === needle); else nomatch"... |
44,961,759 | A messenger displays the search results based on the input given by the user. Need to highlight the word that is been searched, while displaying the result.
These are the html and component that is been used.
**Component.html**
```
<div *ngFor = "let result of resultArray">
<div>Id : result.id </div>
<div>Summary :... | 2017/07/07 | [
"https://Stackoverflow.com/questions/44961759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8089526/"
] | If you have multiple words in your string than use pipe which accepts array and highlight each word in result.
You can use following pipe for multiple search words:-
```
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'highlight'
})
export class HighlightText implements PipeTransform {
... | To expand on Kamal's answer,
The value coming into the transform method, could be a number, perhaps a cast to string `String(value)` would be safe thing to do.
```
transform(value: string, args: string): any {
if (args && value) {
value = String(value); // make sure its a string
let startIndex = v... |
44,961,759 | A messenger displays the search results based on the input given by the user. Need to highlight the word that is been searched, while displaying the result.
These are the html and component that is been used.
**Component.html**
```
<div *ngFor = "let result of resultArray">
<div>Id : result.id </div>
<div>Summary :... | 2017/07/07 | [
"https://Stackoverflow.com/questions/44961759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8089526/"
] | You can do that by creating a pipe and applying that pipe to the **summary** part of array inside `ngfor`. Here is the code for `Pipe`:
```
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'highlight'
})
export class HighlightSearch implements PipeTransform {
transform(value: any, args: an... | Building on a previous answer (HighlightedText-Component) I ended up with this:
```
import { Component, Input, OnChanges } from "@angular/core";
@Component({
selector: 'highlighted-text',
template: `
<ng-container *ngFor="let match of result">
<mark *ngIf="(match === needle); else nomatch"... |
44,961,759 | A messenger displays the search results based on the input given by the user. Need to highlight the word that is been searched, while displaying the result.
These are the html and component that is been used.
**Component.html**
```
<div *ngFor = "let result of resultArray">
<div>Id : result.id </div>
<div>Summary :... | 2017/07/07 | [
"https://Stackoverflow.com/questions/44961759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8089526/"
] | Building on a previous answer (HighlightedText-Component) I ended up with this:
```
import { Component, Input, OnChanges } from "@angular/core";
@Component({
selector: 'highlighted-text',
template: `
<ng-container *ngFor="let match of result">
<mark *ngIf="(match === needle); else nomatch"... | To expand on Kamal's answer,
The value coming into the transform method, could be a number, perhaps a cast to string `String(value)` would be safe thing to do.
```
transform(value: string, args: string): any {
if (args && value) {
value = String(value); // make sure its a string
let startIndex = v... |
44,961,759 | A messenger displays the search results based on the input given by the user. Need to highlight the word that is been searched, while displaying the result.
These are the html and component that is been used.
**Component.html**
```
<div *ngFor = "let result of resultArray">
<div>Id : result.id </div>
<div>Summary :... | 2017/07/07 | [
"https://Stackoverflow.com/questions/44961759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8089526/"
] | The selected answer has the following issues:
1. It will return undefined if there is nothing provided in the search string
2. The search should be case insensitive but that should not replace the original string case.
i would suggest the following code instead
```
transform(value: string, args: string): any {
i... | To expand on Kamal's answer,
The value coming into the transform method, could be a number, perhaps a cast to string `String(value)` would be safe thing to do.
```
transform(value: string, args: string): any {
if (args && value) {
value = String(value); // make sure its a string
let startIndex = v... |
44,961,759 | A messenger displays the search results based on the input given by the user. Need to highlight the word that is been searched, while displaying the result.
These are the html and component that is been used.
**Component.html**
```
<div *ngFor = "let result of resultArray">
<div>Id : result.id </div>
<div>Summary :... | 2017/07/07 | [
"https://Stackoverflow.com/questions/44961759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8089526/"
] | The selected answer has the following issues:
1. It will return undefined if there is nothing provided in the search string
2. The search should be case insensitive but that should not replace the original string case.
i would suggest the following code instead
```
transform(value: string, args: string): any {
i... | If you have multiple words in your string than use pipe which accepts array and highlight each word in result.
You can use following pipe for multiple search words:-
```
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'highlight'
})
export class HighlightText implements PipeTransform {
... |
44,961,759 | A messenger displays the search results based on the input given by the user. Need to highlight the word that is been searched, while displaying the result.
These are the html and component that is been used.
**Component.html**
```
<div *ngFor = "let result of resultArray">
<div>Id : result.id </div>
<div>Summary :... | 2017/07/07 | [
"https://Stackoverflow.com/questions/44961759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8089526/"
] | You can do that by creating a pipe and applying that pipe to the **summary** part of array inside `ngfor`. Here is the code for `Pipe`:
```
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'highlight'
})
export class HighlightSearch implements PipeTransform {
transform(value: any, args: an... | One difficulty the innerHTML method has is in styling the `<mark>` tag. Another method is to place this in a component, allowing for much more options in styling.
**highlighted-text.component.html**
```
<mark *ngIf="matched">{{matched}}</mark>{{unmatched}}
```
**highlighted-text.component.ts**
```
import { Compone... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.