qid
int64 1
74.7M
| question
stringlengths 0
58.3k
| date
stringlengths 10
10
| metadata
list | response_j
stringlengths 2
48.3k
| response_k
stringlengths 2
40.5k
|
---|---|---|---|---|---|
50,208,502 | I had an Angular app with `dev, prod & QA` environments.
I build it by ng build --env=QA
After building, How do I know, that it is in QA environment without deploying it to the server? | 2018/05/07 | [
"https://Stackoverflow.com/questions/50208502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7498614/"
] | We can find it in dist/main.bundle.js with variable environment.
So, by this, we know which environment it is.
```
var environment = {
production: true,
envName: 'QA'
};
``` | You can just import environment anywhere
```
import { environment } from './path/to/env';
```
...
And later use it like so
```
console.log(environment.envName);
``` |
50,208,502 | I had an Angular app with `dev, prod & QA` environments.
I build it by ng build --env=QA
After building, How do I know, that it is in QA environment without deploying it to the server? | 2018/05/07 | [
"https://Stackoverflow.com/questions/50208502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7498614/"
] | We can find it in dist/main.bundle.js with variable environment.
So, by this, we know which environment it is.
```
var environment = {
production: true,
envName: 'QA'
};
``` | First, add a new property to each of the `environment.{env}.ts` files.
```
export const environment = {
production: false,
envName: 'dev'
};
```
Then in the `myapp.component.ts` file import settings, and set the binding.
```
import { environment } from './environment';
export class MyappAppComponent {
environmentName = environment.envName;
}
```
When the application is built (ng build) or served (ng serve), the `environment.{env}.ts` file from `/environments` is pulled and replaces the file within `/src/app`. By default this is dev. |
50,637,672 | I want to fetch data(the images in each post) stored in <https://www.instagram.com/explore/tags/selfie/?__a=1>, but all I get when I decode and var\_dump this is NULL.
```
$obj = json_decode("https://www.instagram.com/explore/tags/selfie/?__a=1", true);
var_dump($obj);
``` | 2018/06/01 | [
"https://Stackoverflow.com/questions/50637672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5909288/"
] | Before decoding json you have to first fetch api response.
```
$obj = json_decode(file_get_contents("https://www.instagram.com/explore/tags/selfie/?__a=1"), true);
``` | The argument to the function json\_decode(), $html must be plaintext/string.
This should work.
```
$url = "https://www.instagram.com/explore/tags/selfie/?__a=1";
$html = file_get_contents($url);
$obj = json_decode($html,true);
var_dump($obj);
```
See this in action [here](https://repl.it/repls/UnselfishBlindProcedurallanguage) |
50,637,672 | I want to fetch data(the images in each post) stored in <https://www.instagram.com/explore/tags/selfie/?__a=1>, but all I get when I decode and var\_dump this is NULL.
```
$obj = json_decode("https://www.instagram.com/explore/tags/selfie/?__a=1", true);
var_dump($obj);
``` | 2018/06/01 | [
"https://Stackoverflow.com/questions/50637672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5909288/"
] | You're trying to `json_decode` the STRING
`https://www.instagram.com/explore/tags/selfie/?__a=1`
What you need to do is to fetch the URL first. I suggest using [`file_get_contents`](http://php.net/manual/en/function.file-get-contents.php), which takes a URL and returns the contents at the end of that URL.
Try this:
```
$json = file_get_contents("https://www.instagram.com/explore/tags/selfie/?__a=1");
$obj = json_decode($json, true);
var_dump($obj);
``` | The argument to the function json\_decode(), $html must be plaintext/string.
This should work.
```
$url = "https://www.instagram.com/explore/tags/selfie/?__a=1";
$html = file_get_contents($url);
$obj = json_decode($html,true);
var_dump($obj);
```
See this in action [here](https://repl.it/repls/UnselfishBlindProcedurallanguage) |
39,424,559 | I quick started with Redis on Windows PC with
```
docker run -p 6379:6379 redis
```
(Redis does not have Windows distribution, [fork for Windows](https://github.com/MSOpenTech/redis) is not the latest version )
```
1:C 10 Sep 08:17:03.635 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.2.3 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 1
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
...
1:M 10 Sep 08:17:03.644 * The server is now ready to accept connections on port 6379
```
Then however I can't connect from Spring Boot app. With `application.properties` like
```
spring.redis.host=localhost
spring.redis.port=6379
```
got error
```
Caused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused: connect
at redis.clients.jedis.Connection.connect(Connection.java:164) ~[jedis-2.8.2.jar:na]
at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:80) ~[jedis-2.8.2.jar:na]
at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1677) ~[jedis-2.8.2.jar:na]
at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:87) ~[jedis-2.8.2.jar:na]
at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:868) ~[commons-pool2-2.4.2.jar:2.4.2]
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:435) ~[commons-pool2-2.4.2.jar:2.4.2]
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363) ~[commons-pool2-2.4.2.jar:2.4.2]
at redis.clients.util.Pool.getResource(Pool.java:49) ~[jedis-2.8.2.jar:na]
... 23 common frames omitted
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[na:1.8.0_45]
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) ~[na:1.8.0_45]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345) ~[na:1.8.0_45]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_45]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_45]
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) ~[na:1.8.0_45]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_45]
at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_45]
at redis.clients.jedis.Connection.connect(Connection.java:158) ~[jedis-2.8.2.jar:na]
... 30 common frames omitted
```
When trying to use Node.js with [node\_redis](https://github.com/NodeRedis/node_redis) example,
I got
```
Error Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
``` | 2016/09/10 | [
"https://Stackoverflow.com/questions/39424559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/482717/"
] | As you mentioned (in the comments), redis bundled their image with `protected-mode` set to yes ([see here](http://redis.io/topics/security)).
**How to go around protected-mode**
* 1) Disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent.
* 2) Alternatively you can disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server.
* 3) If you started the server manually (perhaps for testing), restart it with the '--protected-mode no' option.
* 4) Setup a bind address or an authentication password.
source: [redis-github](https://github.com/docker-library/redis/issues/58)
**Build your own image**
* You could create your own image by pulling redis's and ADDing your own redis.conf to the image ?
* Or update the start command in the Dockerfile to disable protected-mode: `CMD [ "redis-server", "--protected-mode", "no" ]`
**You can also take a look at this Dockerfile which contains the modification suggested above** (last line): <https://github.com/docker-library/redis/blob/23b10607ef1810379d16664bcdb43723aa007266/3.2/Dockerfile>
This Dockerfile is provided in a [Redis issue on github](https://github.com/docker-library/redis/issues/58), it replaces the startup command with `CMD [ "redis-server", "--protected-mode", "no" ]`.
You could just download this Dockerfile and type:
```
$ docker build -t redis-unprotected:latest .
$ docker run -p 6379:6379 redis-unprotected
``` | Thanks to Alex answer and comment in <https://github.com/docker-library/redis/issues/74>
I was able to connect to the Redis using full IP 192.168.99.100:6379
Note that latest 3.2 image has protected mode disabled
<https://github.com/docker-library/redis/issues/75> |
39,424,559 | I quick started with Redis on Windows PC with
```
docker run -p 6379:6379 redis
```
(Redis does not have Windows distribution, [fork for Windows](https://github.com/MSOpenTech/redis) is not the latest version )
```
1:C 10 Sep 08:17:03.635 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.2.3 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 1
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
...
1:M 10 Sep 08:17:03.644 * The server is now ready to accept connections on port 6379
```
Then however I can't connect from Spring Boot app. With `application.properties` like
```
spring.redis.host=localhost
spring.redis.port=6379
```
got error
```
Caused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused: connect
at redis.clients.jedis.Connection.connect(Connection.java:164) ~[jedis-2.8.2.jar:na]
at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:80) ~[jedis-2.8.2.jar:na]
at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1677) ~[jedis-2.8.2.jar:na]
at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:87) ~[jedis-2.8.2.jar:na]
at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:868) ~[commons-pool2-2.4.2.jar:2.4.2]
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:435) ~[commons-pool2-2.4.2.jar:2.4.2]
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363) ~[commons-pool2-2.4.2.jar:2.4.2]
at redis.clients.util.Pool.getResource(Pool.java:49) ~[jedis-2.8.2.jar:na]
... 23 common frames omitted
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[na:1.8.0_45]
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) ~[na:1.8.0_45]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345) ~[na:1.8.0_45]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_45]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_45]
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) ~[na:1.8.0_45]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_45]
at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_45]
at redis.clients.jedis.Connection.connect(Connection.java:158) ~[jedis-2.8.2.jar:na]
... 30 common frames omitted
```
When trying to use Node.js with [node\_redis](https://github.com/NodeRedis/node_redis) example,
I got
```
Error Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
``` | 2016/09/10 | [
"https://Stackoverflow.com/questions/39424559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/482717/"
] | As you mentioned (in the comments), redis bundled their image with `protected-mode` set to yes ([see here](http://redis.io/topics/security)).
**How to go around protected-mode**
* 1) Disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent.
* 2) Alternatively you can disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server.
* 3) If you started the server manually (perhaps for testing), restart it with the '--protected-mode no' option.
* 4) Setup a bind address or an authentication password.
source: [redis-github](https://github.com/docker-library/redis/issues/58)
**Build your own image**
* You could create your own image by pulling redis's and ADDing your own redis.conf to the image ?
* Or update the start command in the Dockerfile to disable protected-mode: `CMD [ "redis-server", "--protected-mode", "no" ]`
**You can also take a look at this Dockerfile which contains the modification suggested above** (last line): <https://github.com/docker-library/redis/blob/23b10607ef1810379d16664bcdb43723aa007266/3.2/Dockerfile>
This Dockerfile is provided in a [Redis issue on github](https://github.com/docker-library/redis/issues/58), it replaces the startup command with `CMD [ "redis-server", "--protected-mode", "no" ]`.
You could just download this Dockerfile and type:
```
$ docker build -t redis-unprotected:latest .
$ docker run -p 6379:6379 redis-unprotected
``` | Ran into a similar problem today.
Using the redis container's IP address for the `JedisConnectionFactory` solved the issue for me.
**Docker command:**
```
docker inspect --format '{{ .NetworkSettings.IPAddress }}' some-redis-instance
``` |
39,424,559 | I quick started with Redis on Windows PC with
```
docker run -p 6379:6379 redis
```
(Redis does not have Windows distribution, [fork for Windows](https://github.com/MSOpenTech/redis) is not the latest version )
```
1:C 10 Sep 08:17:03.635 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.2.3 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 1
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
...
1:M 10 Sep 08:17:03.644 * The server is now ready to accept connections on port 6379
```
Then however I can't connect from Spring Boot app. With `application.properties` like
```
spring.redis.host=localhost
spring.redis.port=6379
```
got error
```
Caused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused: connect
at redis.clients.jedis.Connection.connect(Connection.java:164) ~[jedis-2.8.2.jar:na]
at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:80) ~[jedis-2.8.2.jar:na]
at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1677) ~[jedis-2.8.2.jar:na]
at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:87) ~[jedis-2.8.2.jar:na]
at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:868) ~[commons-pool2-2.4.2.jar:2.4.2]
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:435) ~[commons-pool2-2.4.2.jar:2.4.2]
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363) ~[commons-pool2-2.4.2.jar:2.4.2]
at redis.clients.util.Pool.getResource(Pool.java:49) ~[jedis-2.8.2.jar:na]
... 23 common frames omitted
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[na:1.8.0_45]
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) ~[na:1.8.0_45]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345) ~[na:1.8.0_45]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_45]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_45]
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) ~[na:1.8.0_45]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_45]
at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_45]
at redis.clients.jedis.Connection.connect(Connection.java:158) ~[jedis-2.8.2.jar:na]
... 30 common frames omitted
```
When trying to use Node.js with [node\_redis](https://github.com/NodeRedis/node_redis) example,
I got
```
Error Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
``` | 2016/09/10 | [
"https://Stackoverflow.com/questions/39424559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/482717/"
] | Ran into a similar problem today.
Using the redis container's IP address for the `JedisConnectionFactory` solved the issue for me.
**Docker command:**
```
docker inspect --format '{{ .NetworkSettings.IPAddress }}' some-redis-instance
``` | Thanks to Alex answer and comment in <https://github.com/docker-library/redis/issues/74>
I was able to connect to the Redis using full IP 192.168.99.100:6379
Note that latest 3.2 image has protected mode disabled
<https://github.com/docker-library/redis/issues/75> |
49,255,874 | trying executing this code on the group with joins but its giving me error that its not a group by statement
code below
```
SELECT
sum (quantity),
customers.customer_name,
states.state_name,
regions.region_name
FROM sales JOIN customers ON sales.customer_id = customers.customer_id
join states on customers.state_id = states.state_id
join regions on states.region_id = regions.region_idhaving sum(quantity) >= 10
GROUP BY sales.sale_id, customers.customer_name, states.state_name, regions.region_id
;
```
saying not a group by expression. | 2018/03/13 | [
"https://Stackoverflow.com/questions/49255874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8217437/"
] | ```
dat <- data.frame(VAR1=c(0,1,0,1,0,0,1,1,0),
VAR2=c(1,1,0,1,0,0,1,0,1),
VAR3=c(0,1,1,1,1,0,1,1,1))
dat1 <- dat[,names(sort(colSums(dat), decreasing = TRUE))]
dat1
VAR3 VAR2 VAR1
1 0 1 0
2 1 1 1
3 1 0 0
4 1 1 1
5 1 0 0
6 0 0 0
7 1 1 1
8 1 0 1
9 1 1 0
``` | ```
dat[,names(sort(colSums(dat), decreasing = T))]
```
colSums gives sums of all columns of the *dat*
```
> colSums(dat)
VAR1 VAR2 VAR3
4 5 7
```
sort it in a decreasing order of sum value
```
> sort(colSums(dat), decreasing = T)
VAR3 VAR2 VAR1
7 5 4
```
Get the names in this exact order and display *dat* columns in the same order
```
> dat[,names(sort(colSums(dat), decreasing = T))]
VAR3 VAR2 VAR1
1 0 1 0
2 1 1 1
3 1 0 0
4 1 1 1
5 1 0 0
6 0 0 0
7 1 1 1
8 1 0 1
9 1 1 0
``` |
65,987 | A few days back, I went for a riverside shoot with my Nikon D5300. Unfortunately, moderate rain soon started. I noticed a few photographers, probably with professional grade cameras, were daring enough to shoot the landscape in such weather. The scenic beauty around at that moment was mesmerizing, but I missed capturing any shots, fearing that a single droplet of water would burn out my DSLR. Before trying out taking pictures in rainy condition with my Nikon D5300, I need to know how weather-proof it is. Any suggestions/authentic information is appreciated. | 2015/08/02 | [
"https://photo.stackexchange.com/questions/65987",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/39813/"
] | The D5300 is an entry-level DSLR and is not weatherproof at all. As most cameras, it will handle a few drops of water or snow but you should not let it get wet.
Weatherproof DSLRs and mirrorless exist and they will be able to stand up to strong rain without issues as long as a weatherproof lens is also attached. All camera manufacturers except Pentax/Ricoh reserve such features of higher-end models and pricier lenses, so if you want to get a weather-sealed DSLR and lens for a low cost, you will have to switch systems.
There are things called rain-covers which are basically ponchos for a camera which you can buy to use your D5300 in the rain. Its a little cumbersome to work with and you have to be careful because it is not a sealed bag, but can do for occasional rain. These cost $50-$100 the last time I checked. There different sizes are to accommodate different lenses. | Not sure if it is or not but I took my D5300 up Snowdon while it was raining and hailing, camera got drenched but it is still in good condition |
65,987 | A few days back, I went for a riverside shoot with my Nikon D5300. Unfortunately, moderate rain soon started. I noticed a few photographers, probably with professional grade cameras, were daring enough to shoot the landscape in such weather. The scenic beauty around at that moment was mesmerizing, but I missed capturing any shots, fearing that a single droplet of water would burn out my DSLR. Before trying out taking pictures in rainy condition with my Nikon D5300, I need to know how weather-proof it is. Any suggestions/authentic information is appreciated. | 2015/08/02 | [
"https://photo.stackexchange.com/questions/65987",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/39813/"
] | The D5300 is an entry-level DSLR and is not weatherproof at all. As most cameras, it will handle a few drops of water or snow but you should not let it get wet.
Weatherproof DSLRs and mirrorless exist and they will be able to stand up to strong rain without issues as long as a weatherproof lens is also attached. All camera manufacturers except Pentax/Ricoh reserve such features of higher-end models and pricier lenses, so if you want to get a weather-sealed DSLR and lens for a low cost, you will have to switch systems.
There are things called rain-covers which are basically ponchos for a camera which you can buy to use your D5300 in the rain. Its a little cumbersome to work with and you have to be careful because it is not a sealed bag, but can do for occasional rain. These cost $50-$100 the last time I checked. There different sizes are to accommodate different lenses. | [](https://i.stack.imgur.com/n87kB.jpg)
Above, you see frost on my camera. It is okay to use your camera in moderate rain and just dry off the camera well before the next use. |
65,987 | A few days back, I went for a riverside shoot with my Nikon D5300. Unfortunately, moderate rain soon started. I noticed a few photographers, probably with professional grade cameras, were daring enough to shoot the landscape in such weather. The scenic beauty around at that moment was mesmerizing, but I missed capturing any shots, fearing that a single droplet of water would burn out my DSLR. Before trying out taking pictures in rainy condition with my Nikon D5300, I need to know how weather-proof it is. Any suggestions/authentic information is appreciated. | 2015/08/02 | [
"https://photo.stackexchange.com/questions/65987",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/39813/"
] | The D5300 is an entry-level DSLR and is not weatherproof at all. As most cameras, it will handle a few drops of water or snow but you should not let it get wet.
Weatherproof DSLRs and mirrorless exist and they will be able to stand up to strong rain without issues as long as a weatherproof lens is also attached. All camera manufacturers except Pentax/Ricoh reserve such features of higher-end models and pricier lenses, so if you want to get a weather-sealed DSLR and lens for a low cost, you will have to switch systems.
There are things called rain-covers which are basically ponchos for a camera which you can buy to use your D5300 in the rain. Its a little cumbersome to work with and you have to be careful because it is not a sealed bag, but can do for occasional rain. These cost $50-$100 the last time I checked. There different sizes are to accommodate different lenses. | The most authentic information available for the D5300 is the official manual. Here is the link:
<http://download.nikonimglib.com/archive2/BTcII00t9KUv024jW9c13oRqeg68/D5300VRRM_(En)02.pdf>
Specifically, in the "Caring for the Camera" section, there are several important indicators as to how weatherproof your camera really is, for example:
>
> **Keep dry :** This product is not waterproof, and may malfunction if immersed in water or exposed to high levels of humidity. Rusting of
> the internal mechanism can cause irreparable damage.
>
>
> **Avoid sudden changes in temperature :** Sudden changes in temperature, such as those that occur when entering or leaving a
> heated building on a cold day,can cause condensation inside the
> device. To prevent condensation, place the device in a carrying case
> or plastic bag before exposing it to sudden changes in temperature.
>
>
> **Keep away from strong magnetic fields :** Do not use or store this device in the vicinity of equipment that generates strong
> electromagnetic radiation or magnetic fields. Strong static charges or
> the magnetic fields produced by equipment such as radio transmitters
> could interfere with the monitor, damage data stored on the memory
> card, or affect the product’s internal circuitry.
>
>
> **Do not leave the lens pointed at the sun :** Do not leave the lens pointed at the sun or other strong light source for an extended
> period. Intense light may cause the image sensor to deteriorate or
> produce a white blur effect in photographs.
>
>
>
Further information is provided as well, including caring for the battery, so I suggest you read through it to get a better understanding of the weather capability of your camera. |
65,987 | A few days back, I went for a riverside shoot with my Nikon D5300. Unfortunately, moderate rain soon started. I noticed a few photographers, probably with professional grade cameras, were daring enough to shoot the landscape in such weather. The scenic beauty around at that moment was mesmerizing, but I missed capturing any shots, fearing that a single droplet of water would burn out my DSLR. Before trying out taking pictures in rainy condition with my Nikon D5300, I need to know how weather-proof it is. Any suggestions/authentic information is appreciated. | 2015/08/02 | [
"https://photo.stackexchange.com/questions/65987",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/39813/"
] | Not sure if it is or not but I took my D5300 up Snowdon while it was raining and hailing, camera got drenched but it is still in good condition | [](https://i.stack.imgur.com/n87kB.jpg)
Above, you see frost on my camera. It is okay to use your camera in moderate rain and just dry off the camera well before the next use. |
65,987 | A few days back, I went for a riverside shoot with my Nikon D5300. Unfortunately, moderate rain soon started. I noticed a few photographers, probably with professional grade cameras, were daring enough to shoot the landscape in such weather. The scenic beauty around at that moment was mesmerizing, but I missed capturing any shots, fearing that a single droplet of water would burn out my DSLR. Before trying out taking pictures in rainy condition with my Nikon D5300, I need to know how weather-proof it is. Any suggestions/authentic information is appreciated. | 2015/08/02 | [
"https://photo.stackexchange.com/questions/65987",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/39813/"
] | The most authentic information available for the D5300 is the official manual. Here is the link:
<http://download.nikonimglib.com/archive2/BTcII00t9KUv024jW9c13oRqeg68/D5300VRRM_(En)02.pdf>
Specifically, in the "Caring for the Camera" section, there are several important indicators as to how weatherproof your camera really is, for example:
>
> **Keep dry :** This product is not waterproof, and may malfunction if immersed in water or exposed to high levels of humidity. Rusting of
> the internal mechanism can cause irreparable damage.
>
>
> **Avoid sudden changes in temperature :** Sudden changes in temperature, such as those that occur when entering or leaving a
> heated building on a cold day,can cause condensation inside the
> device. To prevent condensation, place the device in a carrying case
> or plastic bag before exposing it to sudden changes in temperature.
>
>
> **Keep away from strong magnetic fields :** Do not use or store this device in the vicinity of equipment that generates strong
> electromagnetic radiation or magnetic fields. Strong static charges or
> the magnetic fields produced by equipment such as radio transmitters
> could interfere with the monitor, damage data stored on the memory
> card, or affect the product’s internal circuitry.
>
>
> **Do not leave the lens pointed at the sun :** Do not leave the lens pointed at the sun or other strong light source for an extended
> period. Intense light may cause the image sensor to deteriorate or
> produce a white blur effect in photographs.
>
>
>
Further information is provided as well, including caring for the battery, so I suggest you read through it to get a better understanding of the weather capability of your camera. | [](https://i.stack.imgur.com/n87kB.jpg)
Above, you see frost on my camera. It is okay to use your camera in moderate rain and just dry off the camera well before the next use. |
9,836,552 | I need to perform some code when the user stop scrolling the picker, in other way, when the picker stop scrolling. The logic i want to follow is, once the picker stop scrolling, i get the current value and i do some database queries basing on that value.
In the picker view documentation, i don't see a delegate method that can help on such task. Any thoughts? thanx in advance. | 2012/03/23 | [
"https://Stackoverflow.com/questions/9836552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/734308/"
] | whenever you scroll the picker view, didSelect delegate method call at the end of scroll
```
- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
NSLog(@"Selected %i. ", row);
/// do it here your queries
}
```
try with above example and check your console | The delegate class has a method [`pickerView:didSelectRow:inComponent:`](http://developer.apple.com/library/ios/documentation/uikit/reference/UIPickerViewDelegate_Protocol/Reference/UIPickerViewDelegate.html#//apple_ref/occ/intfm/UIPickerViewDelegate/pickerView%3adidSelectRow%3ainComponent%3a), that you can use to detect the selected row. |
32,962,528 | ```
#include <bits/stdc++.h>
using namespace std;
#define HODOR long long int
#define INF 1234567890
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define dwn(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(c, it) for( typeof( (c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define DWN(c, it) for( typeof( (c).end()) it = (c).end()-1; it >= (c).begin(); --it)
#define ss(n) scanf("%s",n)
#define FILL(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mp make_pair
#define ALL(v) v.begin(), v.end()
#define sz(a) ((int)a.size())
#define SET(v, i) (v | (1 << i))
#define TEST(v, i) (v & (1 << i))
#define TOGGLE(v, i) (v ^ (1 << i))
#define gc getchar
#define pc putchar
template<typename X> inline void inp(X &n ) {
register int ch=gc();int sign=1;n=0;
while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=gc();}
while( ch >= '0' && ch <= '9' ) n = (n<<3)+(n<<1) + ch-'0', ch=gc();
n=n*sign;
}
inline void inps(char *n) {
register int ch=gc();
int sign=1;
int i=0;
while( ch != '\n' ){ n[i]=(char)ch; ++i; ch=gc();}
n[i]='\0';
}
int MaxPath(int arr[][100],int n) {
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
cout<<arr[i][j]<<" ";
}
cout<<endl;
}
}
int main() {
int t,n;
inp(t);
while(t--) {
inp(n);
int arr[n][n];
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
inp(arr[i][j]);
}
}
float result = MaxPath(arr,n);
}
return 0;
}
```
>
> **Error seems like this :** error: cannot convert ‘int (*)[n]’ to ‘int (*)[100]’ for argument ‘1’ to ‘int MaxPath(int (\*)[100], int)’
>
>
>
I have seen many posts on stckoverflow , but none of which seems to be working | 2015/10/06 | [
"https://Stackoverflow.com/questions/32962528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4914678/"
] | You could pass in as a pointer to a pointer to int like this
```
int MaxPath(int** arr,int n)
```
but for this to work you would have to declare int arr[n][n] differently
```
int main() {
int t,n;
inp(t);
while(t--) {
inp(n);
int** arr = new int*[n];
for (int i = 0; i < n; i++)
arr[i] = new int[n];
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
inp(arr[i][j]);
}
}
float result = MaxPath(arr,n);
}
//deallocate arr
for (int i = 0; i < n; i++)
{
delete[] arr[i];
}
delete []arr;
return 0;
}
``` | The compiler needs to be able in MaxPath to calculate the address where the data item is stored. This is only possible if it knows the width of the matrix.
One of the simplest solutions is to create some kind of matrix class that implements a two- (or multi-) dimensional type on top of vector. It looks like this:
```
#include <vector>
#include <stdio.h>
template<class T> class matrix
{
std::vector<T> v;
int width;
public:
matrix(int w, int h): v(w*h),width(w) {}
T &operator()(int x, int y) { return v[x+y*width]; }
const T &operator()(int x, int y) const { return v[x+y*width]; }
};
void f(matrix<int> &m)
{
printf("%d\n",m(1,2));
}
int main()
{
matrix<int> m(5,5);
m(1,2)=42;
f(m);
}
```
This is just a minimal example and you may have to extend the matrix class for real world applications. |
61,936,858 | **this is my dataframe:**
```
c_id fname age salary lname
1 abc 21 21.22 yyy
2 def 41 23.4 zzz
```
i need to display the position of the column name with respect to datatype. so my output should be:
```
**FOR INT:**
col_name position
c_id 0
age 2
**for str:**
col_name position
fname 1
lname 4
**for float:**
col_name position
salary 3
``` | 2020/05/21 | [
"https://Stackoverflow.com/questions/61936858",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13343231/"
] | IIUC, you can just create a dataframe from the dtypes and reset the index to get the positional index number.
```
col_df = (
pd.DataFrame(df.dtypes, columns=["DataType"])
.rename_axis("Column")
.reset_index()
.rename_axis("Position")
)
Column DataType
Position
0 c_id int64
1 fname object
2 age int64
3 salary float64
4 lname object
```
---
```
print(col_df[col_df['DataType'] == 'object'])
Column DataType
Position
1 fname object
4 lname object
``` | You could use .dtypes method on DataFrame
```
df.dtypes
>>> Name object
Age int64
City object
Marks float64
dtype: object
df.dtypes['Name']
>>> object
``` |
45,806,172 | what is the best way to check whether a stack exists using the AWS Java SDK, given a stack name?
I've tried the below code based on - <https://github.com/aws/aws-sdk-java/blob/master/src/samples/AwsCloudFormation/CloudFormationSample.java>
```
DescribeStacksRequest wait = new DescribeStacksRequest();
wait.setStackName(stackName);
List<Stack> stacks = awsCFTClient.describeStacks(wait).getStacks();
if (stacks.isEmpty()) {
logger.log("NO_SUCH_STACK");
return true;
}
```
However, I am getting:
AmazonServiceException:com.amazonaws.services.cloudformation.model.AmazonCloudFormationException: Stack with id "stackName" does not exist.
Thanks in advance! | 2017/08/21 | [
"https://Stackoverflow.com/questions/45806172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2817943/"
] | In case someone else is looking for a quick and dirty solution, this works,
```
//returns true if stack exists
public boolean stackExists(AmazonCloudFormation awsCFTClient, String stackName) throws Exception{
DescribeStacksRequest describe = new DescribeStacksRequest();
describe.setStackName(stackName);
//If stack does not exist we will get an exception with describe stack
try {
awsCFTClient.describeStacks(describe).getStacks();
} catch (Exception e) {
logger.log("Error Message: " + e.getMessage());
if (e.getMessage().matches("(.*)" + stackName + "(.*)does not exist(.*)")) {
return false;
} else {
throw e;
}
}
return true;
}
```
If there is a better way for doing this, please let me know. | Found a slightly better way to do it but with a few remarks:
* aws java sdk 2.0 is used here <https://github.com/aws/aws-sdk-java-v2>
* in the example below, you see kotlin syntax
`client.listStacks().stackSummaries().any{ it.stackName() == stackName }`
In Java you can simply replace `any` method `anyMatch`.
According to the shallow check of the former aws java sdk 1.0 there is also `listStacks()` method in AmazonCLoudFormationClient class which does the same.
But in my case, I needed to filter those stacks (because if the stack has status DELETED... it will still appear in the list above) based on the status. So probably overloaded method will be more useful:
```
@Override
public ListStacksResult listStacks(ListStacksRequest request) {
request = beforeClientExecution(request);
return executeListStacks(request);
}
``` |
18,966,169 | Is it possible to show a right click menu on table items with SWT? The menu would be different for every item, e.g for some rows, some of the menu items would be enabled, for others, they would be disabled. So, each row would need its own menu, and when setting up the menu i'd need a way to identify which row I was working with.
Any ideas? | 2013/09/23 | [
"https://Stackoverflow.com/questions/18966169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2790209/"
] | Listening for `SWT.MouseDown`, as suggested by @user4793956, is completely useless. The context menu is always brought up, no need to call `setVisible(true)`. Quite contrary, you need to cancel the `SWT.MenuDetect` event, if you do **not** want the menu to pop up.
This works for me:
```
// Create context menu
Menu menuTable = new Menu(table);
table.setMenu(menuTable);
// Create menu item
MenuItem miTest = new MenuItem(menuTable, SWT.NONE);
miTest.setText("Test Item");
// Do not show menu, when no item is selected
table.addListener(SWT.MenuDetect, new Listener() {
@Override
public void handleEvent(Event event) {
if (table.getSelectionCount() <= 0) {
event.doit = false;
}
}
});
``` | ```
table = new DynamicTable(shell, SWT.BORDER | SWT.FULL_SELECTION);
table.addMenuDetectListener(new MenuDetectListener()
{
@Override
public void menuDetected(MenuDetectEvent e)
{
int index = table.getSelectionIndex();
if (index == -1)
return; //no row selected
TableItem item = table.getItem(index);
item.getData(); //use this to identify which row was clicked.
//The popup can now be displayed as usual using table.toDisplay(e.x, e.y)
}
});
```
More details: <http://www.eclipsezone.com/eclipse/forums/t49734.html> |
18,966,169 | Is it possible to show a right click menu on table items with SWT? The menu would be different for every item, e.g for some rows, some of the menu items would be enabled, for others, they would be disabled. So, each row would need its own menu, and when setting up the menu i'd need a way to identify which row I was working with.
Any ideas? | 2013/09/23 | [
"https://Stackoverflow.com/questions/18966169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2790209/"
] | Listening for `SWT.MouseDown`, as suggested by @user4793956, is completely useless. The context menu is always brought up, no need to call `setVisible(true)`. Quite contrary, you need to cancel the `SWT.MenuDetect` event, if you do **not** want the menu to pop up.
This works for me:
```
// Create context menu
Menu menuTable = new Menu(table);
table.setMenu(menuTable);
// Create menu item
MenuItem miTest = new MenuItem(menuTable, SWT.NONE);
miTest.setText("Test Item");
// Do not show menu, when no item is selected
table.addListener(SWT.MenuDetect, new Listener() {
@Override
public void handleEvent(Event event) {
if (table.getSelectionCount() <= 0) {
event.doit = false;
}
}
});
``` | Without using a DynamicTable:
```
Menu contextMenu = new Menu(table);
table.setMenu(contextMenu);
MenuItem mItem1 = new MenuItem(contextMenu, SWT.None);
mItem1.setText("Menu Item Test.");
table.addListener(SWT.MouseDown, new Listener(){
@Override
public void handleEvent(Event event) {
TableItem[] selection = table.getSelection();
if(selection.length!=0 && (event.button == 3)){
contextMenu.setVisible(true);
}
}
});
``` |
14,326,604 | When a user slides the jQuery Slider over, it effects each image. How do I only get the images pertaining to that slider to change?
I've tried:
`$(this).closest('img.down')` and `$(this).siblings('img.down')`
```
$("#slider").slider({
value:50,
min: 0,
max: 100,
step: 50,
slide: function( event, ui ) {
$('img.up, img.down').css('opacity','.4');
if (ui.value >= 51) {
$('img.up').css('opacity','.8');
}
if (ui.value <= 49) {
$('img.down').css('opacity','.8');
}
}
});
```
[Fiddle here](http://jsfiddle.net/psybJ/5/)
Thanks guys! | 2013/01/14 | [
"https://Stackoverflow.com/questions/14326604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/908392/"
] | You need to make a change to your markup, ***you cannot have three items in a page with the same id***. You can make it
```
class="slider"
```
Move the initialization of the CSS outside of the function then traverse the markup to get the correct image:
```
$('img.up, img.down').css('opacity','.4');
$(".slider").slider({
value:50,
min: 0,
max: 100,
step: 50,
slide: function( event, ui ) {
if (ui.value == 50) {
$(this).parent().find('img.up, img.down').css('opacity','.4');
}
if (ui.value >= 51) {
$(this).parent().find('img.up').css('opacity','.8');
}
if (ui.value <= 49) {
$(this).parent().find('img.down').css('opacity','.8');
}
}
});
```
<http://jsfiddle.net/psybJ/9/> | `siblings` works fine for me: <http://jsfiddle.net/psybJ/8/>
```
$("#slider").slider({
value: 50,
min: 0,
max: 100,
step: 50,
slide: function(event, ui) {
$(this).siblings('img.up, img.down').css('opacity', '.4');
if(ui.value >= 51) {
$(this).siblings('img.up').css('opacity', '.8');
}
if(ui.value <= 49) {
$(this).siblings('img.down').css('opacity', '.8');
}
}
});
``` |
14,326,604 | When a user slides the jQuery Slider over, it effects each image. How do I only get the images pertaining to that slider to change?
I've tried:
`$(this).closest('img.down')` and `$(this).siblings('img.down')`
```
$("#slider").slider({
value:50,
min: 0,
max: 100,
step: 50,
slide: function( event, ui ) {
$('img.up, img.down').css('opacity','.4');
if (ui.value >= 51) {
$('img.up').css('opacity','.8');
}
if (ui.value <= 49) {
$('img.down').css('opacity','.8');
}
}
});
```
[Fiddle here](http://jsfiddle.net/psybJ/5/)
Thanks guys! | 2013/01/14 | [
"https://Stackoverflow.com/questions/14326604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/908392/"
] | You need to make a change to your markup, ***you cannot have three items in a page with the same id***. You can make it
```
class="slider"
```
Move the initialization of the CSS outside of the function then traverse the markup to get the correct image:
```
$('img.up, img.down').css('opacity','.4');
$(".slider").slider({
value:50,
min: 0,
max: 100,
step: 50,
slide: function( event, ui ) {
if (ui.value == 50) {
$(this).parent().find('img.up, img.down').css('opacity','.4');
}
if (ui.value >= 51) {
$(this).parent().find('img.up').css('opacity','.8');
}
if (ui.value <= 49) {
$(this).parent().find('img.down').css('opacity','.8');
}
}
});
```
<http://jsfiddle.net/psybJ/9/> | You really should replace "id" with "class" for your sliders. if you do that then this code will work fine:
```
$(".slider").slider({
value:50,
min: 0,
max: 100,
step: 50,
slide: function( event, ui ) {
var parent = $(this).parent();
if (ui.value >= 51) {
$('img.up',parent).css('opacity','.8');
$('img.down',parent).css('opacity','.4');
}
else if (ui.value <= 49) {
$('img.down',parent).css('opacity','.8');
$('img.up',parent).css('opacity','.4');
}
}
});
``` |
396,799 | I am trying to set up a part of our network as a linux cluster. Since its a little educational for me, I choose using MAAS with JuJu. However there are some questions that boggle my mind and I was hoping that someone could clarify that for me.
The linux cluster I'm about to set up consists of 10 machines. Half of it Dell and the other HP. Both types of machines have a lights-out module (HP=>iLO2, Dell=>DRAC) that support IPMI on a seperate 100Mb NIC. They both support PXE on the first onboard gigabit NIC. I configured the lights out module with a static IP matching the physical layout of the racks and position height. Installing MAAS however didn't ask me on what subnet and vlan the IPMI protocol should be configured. How do I do this?
Also I want only the region controller to be able to contact the internet for package management. The other provisioned nodes should only be allowed to connect to the internet via a proxy on the region controller. So the region controller in my case should be configured with 3 subnets; 1 for internet, 1 for client protocol connectivity and 1 for cluster traffic. The region controller itself should also be a node for JuJu.
Then at last there is the node configuration that should have a sort of basic layout that can be used within JuJu. As far as I could see there is no possibility to set up cluster subnet configuration. Each machine has at least 4 NIC's that I like to assign the different subnets to; 1 for the IPMI traffic, 1 for the PXE boot traffic, 1 for the cluster traffic and 1 for the storage/client network. What I like to do is to bond all these interfaces together as one big trunk and then use VLAN's to separate the traffic **before** provisioning. Then when provisioning a node, MAAS should automagically configure the network interfaces as the layout suggests above.
Maybe what I'm looking for is a advanced configuration tutorial/guide for MAAS and JuJu.
Regards,
Joham | 2013/12/28 | [
"https://askubuntu.com/questions/396799",
"https://askubuntu.com",
"https://askubuntu.com/users/229480/"
] | Maybe if you let install of [Juju GUI](https://juju.ubuntu.com/docs/howto-gui-management.html) to provide adequately more what type of network balancing you need then you could find your answer faster.
[**Using Juju with GUI**](https://juju.ubuntu.com/docs/howto-gui-management.html)
This advanced guides very close to your problem:
[**MAAS: Cluster Configuration**](http://maas.ubuntu.com/docs/cluster-configuration.html)
[**Additional Manual Configuration**](http://maas.ubuntu.com/docs/configure.html#installing-additional-clusters) | Meanwhile I have a better understanding of how networking is arranged in maas and its pretty cool. So to answer my own question:
I recommend against separating IPMI and PXE traffic. Its more efficient to just share the RAC traffic on eth0. All server can boot PXE default on eth0 too.
Besides, you don't need an extra ethernet port/switch for just the RAC, and no extra cables, so that is less energy consumption, thus good! You can use shared nic for iDRAC 5+ & ILO2+, iDRAC 6 and higher have shared nic failover, but iLO2 doesn't.
The nic interface for PXE traffic is normally selectable in the server boot options. From there you assign the maas cluster controllers network interface. This interface is connected to the machines you like to control on that cluster network. Give them a dynamic range to boot into with DHCP and your a go. In the network tab of the maas webgui menu you will find your first network. You can select if you will, the first interface of each machine on that maas network and create a new maas network to route your other traffic to.
Thanks for the input!
Regards,
Joham |
17,981,284 | In this situation, I want to find all records that contain the name steve in one column and [email protected] in another. I know Im missing an operator, but i dont know which
```
SELECT firstname,lastname,middlename,company_name,
primary_emailaddress,alternate_emailaddress,personal_address_line1,
personal_address_line2,personal_address_city,facebook_username,
twitter_username,googleplus_username,linkedin_username,
personal_website_url,birthday_month,notes,personal_address_zipcode,
company_address_zipcode,home_phonenumber,company_phonenumber,
cell_phonenumber,birthday_day,birthday_year,hash,image_file
FROM contacts
WHERE (
MATCH(
firstname,lastname,
primary_emailaddress,alternate_emailaddress,personal_address_line1,
personal_address_city,company_name,
company_address_line1,company_address_city,
facebook_username,twitter_username,googleplus_username,linkedin_username,
personal_website_url
)
AGAINST ('Steve [email protected]' IN BOOLEAN MODE))
``` | 2013/07/31 | [
"https://Stackoverflow.com/questions/17981284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/135605/"
] | Ok, after a lot of searching. I answered my own question.
I've discovered finding anything on the angular documentation is incredibly impossible, but sometimes, once it's found, it changes how you were thinking about your problem.
I began here: <http://docs.angularjs.org/api/ng>.$location
Which took me here: <http://docs.angularjs.org/guide/dev_guide.services>.$location
Which took me to this question: [AngularJS Paging with $location.path but no ngView reload](https://stackoverflow.com/questions/12422611/angularjs-paging-with-location-path-but-no-ngview-reload)
What I ended up doing:
I added `$location.search({name: 'George'});` To where I wanted to change the name (A $scope.$watch).
However, this will still reload the page, unless you do what is in that bottom StackOverflow link and add a parameter to the object you pass into `$routeProvider.when`. In my case, it looked like: `$routeProvider.when('/page', {controller: 'MyCtrl', templateUrl:'path/to/template', reloadOnSearch:false})`.
I hope this saves someone else a headache. | You can change the display of the page using ng-show and ng-hide, these transitions won't reload the page. But I think the problem you're trying to solve is you want to be able to bookmark the page, be able to press refresh and get the page you want.
I'd suggest implementing angular ui-router Which is great for switching between states without reloading the page. The only downfall is you have to change all your routes.
[Check it out here](https://github.com/angular-ui/ui-router) theres a great demo. |
17,981,284 | In this situation, I want to find all records that contain the name steve in one column and [email protected] in another. I know Im missing an operator, but i dont know which
```
SELECT firstname,lastname,middlename,company_name,
primary_emailaddress,alternate_emailaddress,personal_address_line1,
personal_address_line2,personal_address_city,facebook_username,
twitter_username,googleplus_username,linkedin_username,
personal_website_url,birthday_month,notes,personal_address_zipcode,
company_address_zipcode,home_phonenumber,company_phonenumber,
cell_phonenumber,birthday_day,birthday_year,hash,image_file
FROM contacts
WHERE (
MATCH(
firstname,lastname,
primary_emailaddress,alternate_emailaddress,personal_address_line1,
personal_address_city,company_name,
company_address_line1,company_address_city,
facebook_username,twitter_username,googleplus_username,linkedin_username,
personal_website_url
)
AGAINST ('Steve [email protected]' IN BOOLEAN MODE))
``` | 2013/07/31 | [
"https://Stackoverflow.com/questions/17981284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/135605/"
] | I actually found a solution that I find a little more elegant for my application.
The $locationChangeSuccess event is a bit of a brute force approach, but I found that checking the path allows us to avoid page reloads when the route path *template* is unchanged, but reloads the page when switching to a different route template:
```
var lastRoute = $route.current;
$scope.$on('$locationChangeSuccess', function (event) {
if (lastRoute.$$route.originalPath === $route.current.$$route.originalPath) {
$route.current = lastRoute;
}
});
```
Adding that code to a particular controller makes the reloading more intelligent. | You can change the display of the page using ng-show and ng-hide, these transitions won't reload the page. But I think the problem you're trying to solve is you want to be able to bookmark the page, be able to press refresh and get the page you want.
I'd suggest implementing angular ui-router Which is great for switching between states without reloading the page. The only downfall is you have to change all your routes.
[Check it out here](https://github.com/angular-ui/ui-router) theres a great demo. |
17,981,284 | In this situation, I want to find all records that contain the name steve in one column and [email protected] in another. I know Im missing an operator, but i dont know which
```
SELECT firstname,lastname,middlename,company_name,
primary_emailaddress,alternate_emailaddress,personal_address_line1,
personal_address_line2,personal_address_city,facebook_username,
twitter_username,googleplus_username,linkedin_username,
personal_website_url,birthday_month,notes,personal_address_zipcode,
company_address_zipcode,home_phonenumber,company_phonenumber,
cell_phonenumber,birthday_day,birthday_year,hash,image_file
FROM contacts
WHERE (
MATCH(
firstname,lastname,
primary_emailaddress,alternate_emailaddress,personal_address_line1,
personal_address_city,company_name,
company_address_line1,company_address_city,
facebook_username,twitter_username,googleplus_username,linkedin_username,
personal_website_url
)
AGAINST ('Steve [email protected]' IN BOOLEAN MODE))
``` | 2013/07/31 | [
"https://Stackoverflow.com/questions/17981284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/135605/"
] | Ok, after a lot of searching. I answered my own question.
I've discovered finding anything on the angular documentation is incredibly impossible, but sometimes, once it's found, it changes how you were thinking about your problem.
I began here: <http://docs.angularjs.org/api/ng>.$location
Which took me here: <http://docs.angularjs.org/guide/dev_guide.services>.$location
Which took me to this question: [AngularJS Paging with $location.path but no ngView reload](https://stackoverflow.com/questions/12422611/angularjs-paging-with-location-path-but-no-ngview-reload)
What I ended up doing:
I added `$location.search({name: 'George'});` To where I wanted to change the name (A $scope.$watch).
However, this will still reload the page, unless you do what is in that bottom StackOverflow link and add a parameter to the object you pass into `$routeProvider.when`. In my case, it looked like: `$routeProvider.when('/page', {controller: 'MyCtrl', templateUrl:'path/to/template', reloadOnSearch:false})`.
I hope this saves someone else a headache. | I actually found a solution that I find a little more elegant for my application.
The $locationChangeSuccess event is a bit of a brute force approach, but I found that checking the path allows us to avoid page reloads when the route path *template* is unchanged, but reloads the page when switching to a different route template:
```
var lastRoute = $route.current;
$scope.$on('$locationChangeSuccess', function (event) {
if (lastRoute.$$route.originalPath === $route.current.$$route.originalPath) {
$route.current = lastRoute;
}
});
```
Adding that code to a particular controller makes the reloading more intelligent. |
63,678,928 | Suppose a class MyClass implements an interface MyInterface, and it has its own instance method let's say foo().
When i create an instance of MyClass like this:
```
MyInterface myClass = new MyClass();
```
The compiler wouldn't let me access its instance method without an explicit casting:
```
myClass.foo(); // Can't resolve symbol
((MyClass) myClass).foo(); // this is okay
```
Even though the compiler obviously knows myClass is an instance of MyClass:
```
if(myClass instanceof MyClass)
System.out.println(myClass.getClass().getName()); //this will print "MyClass"
```
Why do i need to use cast for compiler to allow me to access the instance method? | 2020/08/31 | [
"https://Stackoverflow.com/questions/63678928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3554898/"
] | The *meaning* of the line `MyInterface myClass = new MyClass()` is, "Create a new `MyClass`, and then forget about all its features except those defined in the interface `MyInterface`."
When you refer to "the compiler obviously knows myClass is an instance of MyClass," you're not actually correct: it's *not* the compiler that knows that, but the *runtime.* The *compiler* was told to forget that information, and it did. | It might be of type `MyClass` but you are treating it as a `MyInterface`. When you do `A myVar = new B();` you only have access to whatever you can access in `A` even though `myVar`is of type `B`. |
33,528,414 | 
I am trying to override the OnLaunched() function in a Template 10 Windows Application, but the problem is that it is sealed in Template 10 BootStrapper class (which inherits from the Application class).
Here's my method:
```
using Windows.UI.Xaml;
...
namespace Sample {
...
sealed partial class App : Template10.Common.BootStrapper {
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
/*************** My stuff *****************
***********************************************/
}
...
}
```
I am using Template10 Blank app for this app, and the OnLaunched() method in BootStrapper class is this:
```
namespace Template10.Common
{
public abstract class BootStrapper : Application
{
...
protected sealed override void OnLaunched(LaunchActivatedEventArgs e);
...
}
...
}
```
I cannot remove the sealed modifier from OnLaunched() in BootStrapper (guess because it is "from metadata").
What's the point of including a sealed method in an abstract class?
Do we get some other method to override, like OnResume(), OnStartAsync(), etc, instead of OnLaunched()?
Update: For reference, here are all the members in BootStrapper:
```
public abstract class BootStrapper : Application
{
public const string DefaultTileID = "App";
protected BootStrapper();
public static BootStrapper Current { get; }
public TimeSpan CacheMaxDuration { get; set; }
public INavigationService NavigationService { get; }
public StateItems SessionState { get; set; }
public bool ShowShellBackButton { get; set; }
protected Func<SplashScreen, UserControl> SplashFactory { get; set; }
public event EventHandler<WindowCreatedEventArgs> WindowCreated;
public static AdditionalKinds DetermineStartCause(IActivatedEventArgs args);
public NavigationService NavigationServiceFactory(BackButton backButton, ExistingContent existingContent);
[AsyncStateMachine(typeof(<OnInitializeAsync>d__44))]
public virtual Task OnInitializeAsync(IActivatedEventArgs args);
public virtual void OnResuming(object s, object e);
public abstract Task OnStartAsync(StartKind startKind, IActivatedEventArgs args);
[AsyncStateMachine(typeof(<OnSuspendingAsync>d__45))]
public virtual Task OnSuspendingAsync(object s, SuspendingEventArgs e);
public Dictionary<T, Type> PageKeys<T>() where T : struct, IConvertible;
public virtual T Resolve<T>(Type type);
public virtual INavigable ResolveForPage(Type page, NavigationService navigationService);
public void UpdateShellBackButton();
[AsyncStateMachine(typeof(<OnActivated>d__26))]
protected sealed override void OnActivated(IActivatedEventArgs e);
[AsyncStateMachine(typeof(<OnCachedFileUpdaterActivated>d__27))]
protected sealed override void OnCachedFileUpdaterActivated(CachedFileUpdaterActivatedEventArgs args);
[AsyncStateMachine(typeof(<OnFileActivated>d__28))]
protected sealed override void OnFileActivated(FileActivatedEventArgs args);
[AsyncStateMachine(typeof(<OnFileOpenPickerActivated>d__29))]
protected sealed override void OnFileOpenPickerActivated(FileOpenPickerActivatedEventArgs args);
[AsyncStateMachine(typeof(<OnFileSavePickerActivated>d__30))]
protected sealed override void OnFileSavePickerActivated(FileSavePickerActivatedEventArgs args);
protected sealed override void OnLaunched(LaunchActivatedEventArgs e);
[AsyncStateMachine(typeof(<OnSearchActivated>d__31))]
protected sealed override void OnSearchActivated(SearchActivatedEventArgs args);
[AsyncStateMachine(typeof(<OnShareTargetActivated>d__32))]
protected sealed override void OnShareTargetActivated(ShareTargetActivatedEventArgs args);
protected sealed override void OnWindowCreated(WindowCreatedEventArgs args);
public enum AdditionalKinds
{
Primary,
Toast,
SecondaryTile,
Other
}
public enum BackButton
{
Attach,
Ignore
}
public enum ExistingContent
{
Include,
Exclude
}
public enum StartKind
{
Launch,
Activate
}
}
```
Please help :} | 2015/11/04 | [
"https://Stackoverflow.com/questions/33528414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5035469/"
] | Template 10 does not allow us to override OnLaunched() method. Instead we can override the OnInitializeAsync() and OnStartAsync() methods for this purpose.
The reason is that Template 10 recommends us to use something called the Single Page Model, which is nothing but using a single instance of the Page class to put in the empty Frame provided by the Framework. How is that benefit to us? Well, if we need to put a menu, say a Hamburger menu, in our app, then we need to copy the code for the menu in each and every page we create in our app. This would lead to things like redundancy, inconsistency, WET code, etc. etc.
Therefore, template 10, initially, creates a Page, which they call the Shell, and then contents of each page is loaded into this Shell page, instead of creating new Pages.
We can override these methods in the following way:
```
sealed partial class App : BootStrapper
{
public App()
{
this.InitializeComponent();
}
public override Task OnInitializeAsync(IActivatedEventArgs args)
{
var nav = NavigationServiceFactory(BackButton.Attach, ExistingContent.Include);
Window.Current.Content = new Views.Shell(nav);
return Task.FromResult<object>(null);
}
public override Task OnStartAsync(BootStrapper.StartKind startKind, IActivatedEventArgs args)
{
NavigationService.Navigate(typeof(Views.MainPage));
return Task.FromResult<object>(null);
}
}
```
Here's where I figured the answer:
<https://github.com/Windows-XAML/Template10/wiki/Docs-%7C-HamburgerMenu>
So, long story short, override OnInitializeAsync() or OnStartAsync(), instead of OnLaunched(). | You're trying to override OnLaunched in MyPage.xaml.cs and I'm pretty safe to assume that your MyPage class does not inherit from Application. So it does not have OnLaunched() method (at least not with that signature). What you need to do is override it in App.xaml.cs, as it's Application.OnLaunched(). App class, which is in App.xaml.cs, inherits from Application.
By the way, this is the example from the blank app template, which you've mentioned:
[](https://i.stack.imgur.com/72fRR.png) |
17,996,678 | I'm trying to find a structural break in my time series using the `breakpoints()` function (in the `strucchange` package). My goal is to find where is "knot" in my dataset. I'm looking for a procedure which would test all possible knots and choose the one who minimize an information criterion such AIC or BIC. `breakpoints()` does a good job but I would like to draw a continuous piecewise linear function. This, I would like the intercept to be the same before and after the breakpoint. Is anyone aware of a function or an option to do this ?
On the picture below, the red line is the true model and the blue line is fitted using `breakpoints()`. I would like a procedure which would fit the true model (no jump at the breakpoint).
See my [gist file](https://gist.github.com/pachevalier/6132114) to reproduce this example.
 | 2013/08/01 | [
"https://Stackoverflow.com/questions/17996678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1967500/"
] | The 'strucchange' package seems designed to return discontinuous results. You may want to look at packages that are designed the way you imagine the result to be structured. The 'segmented' package is one such.
```
require(segmented)
out.lm<-lm(y~date3,data=df)
o<-segmented(out.lm, seg.Z= ~date3, psi=list(date3=c(-10)),
control=seg.control(display=FALSE))
slope(o)
#$date3
# Est. St.Err. t value CI(95%).l CI(95%).u
#slope1 0.3964 0.1802 2.199 0.03531 0.7574
#slope2 -1.6970 0.1802 -9.418 -2.05800 -1.3360
str(fitted(o))
# Named num [1:60] 1.94 2.34 2.74 3.13 3.53 ...
# - attr(*, "names")= chr [1:60] "1" "2" "3" "4" ...
plot(y ~ date3, data=df)
lines(fitted(o) ~ date3, data=df)
```
 | A continuous piecewise linear fit is also called a linear spline, and can be fit with `bs` in the `splines` package (comes with base R).
```
lm(y ~ bs(x, deg=1, df, knots), ...)
```
The breakpoints are called knots, and you have to specify them via either the `knots` argument or the `df` argument (which chooses knots based on the quantiles of `x`).
You can also do it manually; linear splines are particularly simple to code up.
```
lm(y ~ x + pmax(0, x - k1) + pmax(0, x - k2), ...)
```
where `k1` and `k2` are the knots. Add more to taste. |
43,441,231 | I have started working with flex box on React native, on CSS you should set the display to flex but on RN, this is set by default.
What classifies a container object where you can set alignItems, justifyContent?
Does it *only* need to be a view? or is every single component a potential container? | 2017/04/16 | [
"https://Stackoverflow.com/questions/43441231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/457172/"
] | You need to do change in first for loop:-
```
for (i = 1; i < tr.length; i++) { // not start with 0 start with 1.
```
Means leave table `<thead><tr>` and then start searching in rest `<tr>`.
Note:- check it and if you are facing any problem. I will create an example for you. | This can be easily achieved by putting the rows in a tbody, and changing the variabl;e `tr` selector.
```js
$(document).ready(function(){
$('#search-attorneys').on('keyup', function(){
var input, filter, table, tr, td, i;
input = $("#search-attorneys");
filter = $("#search-attorneys").val().toUpperCase();
table = $("#attorneys");
tr = $("tbody tr"); // CHANGED
for (i = 0; i < tr.length; i++) {
tds = tr[i].getElementsByTagName("td");
var found = false;
for (j = 0; j < tds.length; j++) {
td = tds[j];
if (td) {
if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
found = true;
break;
}
}
}
if (found) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
});
});
```
```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" id="search-attorneys" placeholder="Search for names.." title="Type in a name">
<table id="attorneys">
<thead class="cf">
<tr>
<th class="numeric">attorney</th>
<th class="numeric">location</th>
<th class="numeric">practice area</th>
<th class="numeric">email</th>
<th class="numeric">phone</th>
</tr>
</thead>
<tbody>
<tr>
<td data-title="location">Alfreds Futterkiste</td>
<td>Germany</td>
</tr>
<tr>
<td>Berglunds snabbkop</td>
<td>Sweden</td>
</tr>
<tr>
<td>Island Trading</td>
<td>UK</td>
</tr>
<tr>
<td>Koniglich Essen</td>
<td>Germany</td>
</tr>
<tr>
<td>Laughing Bacchus Winecellars</td>
<td>Canada</td>
</tr>
<tr>
<td>Magazzini Alimentari Riuniti</td>
<td>Italy</td>
</tr>
<tr>
<td>North/South</td>
<td>UK</td>
</tr>
<tr>
<td>Paris specialites</td>
<td>France</td>
</tr>
</tbody>
</table>
``` |
86,788 | How do I display a list of values $\{a\_1,a\_2,\ldots,a\_n\}$ in a two column format?
>
> `---------
> 1 | a_1
> 2 | a_2
> 3 | a_3
> ......
> n | a_n`
>
>
>
I tried using TableFormat but this doesn't display the row number. | 2015/06/25 | [
"https://mathematica.stackexchange.com/questions/86788",
"https://mathematica.stackexchange.com",
"https://mathematica.stackexchange.com/users/19923/"
] | **Update**
`ciao`'s answer makes the most sense.
```
TableForm[a /@ Range[5], TableHeadings -> Automatic]
```
**Original Post**
Try this. If your list of values is
```
a /@ Range[5]
(* {a[1], a[2], a[3], a[4], a[5]} *)
```
then you can do something like
```
TableForm@Transpose[{Range[5], a /@ Range[5]}]
```
or
```
TableForm@MapIndexed[{First@#2, #1} &, a /@ Range[5]]
```
(`MapIndexed` is major overkill. I just like using it recently.) | ```
Table[{n, Subscript[a, n]}, {n, 1, 5}] // TableForm
``` |
154,329 | In Leetcode it states that my runtime is only faster than 38% all of submitted JavaScript solutions. Is there anything I can change to make it more efficient?
```
/**
* @param {number} x
* @param {number} y
* @return {number}
*/
var hammingDistance = function(x, y) {
var resultStr =( x^y);
let count =0;
while(resultStr>0){
resultStr =(resultStr&resultStr-1) ;
count++;
}
return count;
};
``` | 2017/02/03 | [
"https://codereview.stackexchange.com/questions/154329",
"https://codereview.stackexchange.com",
"https://codereview.stackexchange.com/users/57142/"
] | A few things could be changed here, non of which I mention are optimisation however. Your solution is almost identical to the [example on the wiki page](https://en.wikipedia.org/wiki/Hamming_distance#Algorithm_example) where you can see hardware optimisations if supported, though the example does not apply to JavaScript.
**Naming**
The `Str` in `resultStr` seems to imply that it's a string but that's not the case. `result` may be better suited, or `val` which is a common choice for this.
While `count` is perfectly fine, `distance` might make it's purpose more obvious (especially since "distance" is in the function name).
**Parentheses**
There's a bunch of parentheses that aren't needed, adding spacing around operators makes it easier to follow.
**Shorthand operators/spacing**
You can take advantage of shorthand operators:
`resultStr = resultStr & resultStr - 1` can be simplified to `resultStr &= resultStr - 1`
Another added benefit is that in this example we don't have to worry about operator precedence.
**ES6**
Since you're using ES6 features such as `let` you can take advantage additional features such as `const` and `=>` (arrow functions).
**ES6 - const/let**
Favour `let` and `const` over `var`. You are already declaring `count` with `let` so it would make sense to do the same for `resultStr`.
If we declare `const hammingDistance = ...` it means that if we later try and reassign `hammingDistance = ...` we will get a `TypeError`.
I recommend using `const` whenever you don't need to reassign a variable. *Note this does not mean the variable is immutable, just that it cannot be reassigned.*
**ES6 - arrow functions**
I've opted to use [arrow function](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions) notation over traditional syntax here. Your example does not benefit from any of the advantages such as lexical `this` so feel free to change back to `function(x, y)` as this is a personal choice.
**Solution**
Here's your code with the suggested changes:
```
const hammingDistance = (x, y) => {
let val = x ^ y;
let distance = 0;
while (val > 0) {
val &= val - 1;
distance++;
}
return distance;
};
```
**For loop solution**
If you wanted, you could replace the `while` loop with a `for` loop as follows:
```
const hammingDistance = (x, y) => {
let val = x ^ y;
let distance;
for (distance = 0; val > 0; distance++) {
val &= val - 1;
}
return distance;
};
``` | Your implementation (with bugs fixed as per the other answer) is very efficient for small Hamming distances, but the cost scales as the Hamming distance. To make it more efficient you should make it independent of the Hamming distance by [parallelising it](https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel). I'm not sure how best to adjust this for JavaScript's weird type system: are you assuming that the input values are 32-bit integers or 52-bit integers? For 32-bit integers the given code can be directly ported:
```
const hammingDistance = (x, y) => {
let val = x ^ y;
val -= (val >> 1) & 0x55555555;
val = (val & 0x33333333) + ((val >> 2) & 0x33333333);
val += (val >> 4) & 0xF0F0F0F;
return (val * 0x1010101) >> 24;
};
``` |
37,395,473 | I am having trouble with some code that was given to me. It isn't concatenating the rows as it should be. I am pulling from 3 tables to select which rows to concatenate. I have a `Comment`, `WorkOrderT` and `WorkMaterial_nonFiltered` table.
The `Comment` table, obviously, has comments and is linked to the `WorkMaterial_nonFiltered` table. The `WorkMaterial_nonFiltered` table is connected to the `WorkOrderT` table which is where the Work Order ID's are.
I am trying to use the Work Order ID to get all the comments for that work order and have them all concatenated into one row per work order id. Here is the code as I currently have it:
```
select
wo.WOId as ID,
STUFF(cast((select distinct '; ' + c.comments
from working.Comment c
where c.Instance_InstanceId = wm.id
for xml path(''), type) as varchar(max)), 1, 1, ' ') as MaterialComments
from
working.WorkOrderT wo
left join
working.WorkMaterial_nonFiltered wm on wm.WorkOrder = wo.WOId
where
wo.WOId = '00559FB6-4DD2-4762-8DE1-8D1B13962AED'
order by
[MaterialComments]
```
When I run this I get 11 rows as a result. The first has the `MaterialComments` as `NULL` then the others have data in them. I don't care about the `NULL` row, unless it's what's causing the problem, it's the others that I really need to have concatenated, separated by the ";". I've tried building this out one step at a time, but I've not been able to figure out why I always get 11 rows instead of just the 1. I've looked into the following other questions to try and find a solution:
[Concatenate many rows into a single text string?](https://stackoverflow.com/questions/194852/concatenate-many-rows-into-a-single-text-string)
[Concatenate Rows using FOR XML PATH() from multiple tables](https://stackoverflow.com/questions/26758458/concatenate-rows-using-for-xml-path-from-multiple-tables)
[How to create a SQL Server function to “join” multiple rows from a subquery into a single delimited field?](https://stackoverflow.com/questions/6899/how-to-create-a-sql-server-function-to-join-multiple-rows-from-a-subquery-into)
[How to make a query with group\_concat in sql server](https://stackoverflow.com/questions/17591490/how-to-make-a-query-with-group-concat-in-sql-server/17591536#17591536)
[String Aggregation in the World of SQL Server](http://www.codeproject.com/Articles/691102/String-Aggregation-in-the-World-of-SQL-Server)
So far I've not been able to get any suggestions from these links to work for me I still get 11 rows instead of 1 concatenated row.
**EDIT**
Here is some sample data from what I have in my tables: (Note sure how to make this an actual table sorry for the sloppy formatting)
```
WorkOrderID Comments
00559FB6-4DD2-4762-8DE1-8D1B13962AED 5/17 caj in transit; expected delivery on 5/18 per ups 1Z25AR580319345668
00559FB6-4DD2-4762-8DE1-8D1B13962AED 5/18 caj updated esd on 6/17 per vendor site
00559FB6-4DD2-4762-8DE1-8D1B13962AED 5/17 caj allocated to ship
00559FB6-4DD2-4762-8DE1-8D1B13962AED 5/17 caj updated esd on 5/27 per vendor site
00559FB6-4DD2-4762-8DE1-8D1B13962AED 5/18 caj processed; no udpated delivery date per estes Tracking #/BOL #: 3SNS31780960
00559FB6-4DD2-4762-8DE1-8D1B13962AED 5/18 caj processed; no updated delivery date per ups 1Z39ER600354622348
008FC1D1-D6A6-4E48-A69F-168DBF8D215A Jun 25 2015 10:22AM;dlb223;6/25 dlb 1Z4370490304215160 to be dlv'd today
008FC1D1-D6A6-4E48-A69F-168DBF8D215A Jun 8 2015 1:11PM;klh323;6/8 klh Reserved to meet 06/30 requested delivery date
008FC1D1-D6A6-4E48-A69F-168DBF8D215A Jun 25 2015 10:23AM;dlb223;6/23/2015
008FC1D1-D6A6-4E48-A69F-168DBF8D215A Jun 25 2015 10:23AM;dlb223;6/5 dlb 1Z4370490304215937 to be dlv'd today
008FC1D1-D6A6-4E48-A69F-168DBF8D215A Jun 25 2015 10:24AM;dlb223;6/25 dlb 1Z4370490304216445 to be dlv'd today
00910B84-486C-4AD4-9B1E-5F8D8B42C841 5/12 jad IN TRANSIT; EXPECTED DELIVERY 5/12 PER UPS 1Z750WA20313280446
00910B84-486C-4AD4-9B1E-5F8D8B42C841 4/29 jad IN TRANSIT; EXPECTED DELIVERY 4/29 PER UPS 1Z39ER600354244542
```
The results I want to look like this: (again I don't know how to make this a table)
```
WorkOrderID Comments
00559FB6-4DD2-4762-8DE1-8D1B13962AED 5/17 caj in transit; expected delivery on 5/18 per ups 1Z25AR580319345668; 5/18 caj updated esd on 6/17 per vendor site; 5/17 caj allocated to ship; 5/17 caj updated esd on 5/27 per vendor site; 5/18 caj processed; no udpated delivery date per estes Tracking #/BOL #: 3SNS31780960; 5/18 caj processed; no updated delivery date per ups 1Z39ER600354622348
008FC1D1-D6A6-4E48-A69F-168DBF8D215A Jun 25 2015 10:22AM;dlb223;6/25 dlb 1Z4370490304215160 to be dlv'd today; Jun 8 2015 1:11PM;klh323;6/8 klh Reserved to meet 06/30 requested delivery date; Jun 25 2015 10:23AM;dlb223;6/23/2015; Jun 25 2015 10:23AM;dlb223;6/5 dlb 1Z4370490304215937 to be dlv'd today; Jun 25 2015 10:24AM;dlb223;6/25 dlb 1Z4370490304216445 to be dlv'd today
00910B84-486C-4AD4-9B1E-5F8D8B42C841 5/12 jad IN TRANSIT; EXPECTED DELIVERY 5/12 PER UPS 1Z750WA20313280446; 4/29 jad IN TRANSIT; EXPECTED DELIVERY 4/29 PER UPS 1Z39ER600354244542
```
I hope that this makes it more clear what I'm trying to accomplish. | 2016/05/23 | [
"https://Stackoverflow.com/questions/37395473",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2911241/"
] | I have ended up using pass through queries to a linked server. That is where the problem actually was. With the data coming back from the linked server. Once I figured that out I was able to get the results that I needed. Now I have a really long pass through query that uses the `for xml` and gives me the comments for the WOID's the way that I need them. | Explicitly ask for a text node within an element, rather than an element.
```
select
wo.WOId as ID,
(select distinct '; ' + c.comments as "text()"
from working.Comment c
where c.Instance_InstanceId = wm.id
for xml path(''), type) as "MaterialComments"
from
working.WorkOrderT wo
left join
working.WorkMaterial_nonFiltered wm on wm.WorkOrder = wo.WOId
where
wo.WOId = '00559FB6-4DD2-4762-8DE1-8D1B13962AED'
order by
[MaterialComments]
``` |
5,267,988 | I just need a hello world demo to see how machine code actually works.
Though windows' **EXE** and linux' **ELF** is near machine code,but it's not **PURE**
How can I write/execute **PURE** machine code? | 2011/03/11 | [
"https://Stackoverflow.com/questions/5267988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/631505/"
] | You **can** write in PURE machine code manually **WITHOUT ASSEMBLY**
Linux/ELF: <https://github.com/XlogicX/m2elf>. This is still a work in progress, I just started working on this yesterday.
Source file for "Hello World" would look like this:
```
b8 21 0a 00 00 #moving "!\n" into eax
a3 0c 10 00 06 #moving eax into first memory location
b8 6f 72 6c 64 #moving "orld" into eax
a3 08 10 00 06 #moving eax into next memory location
b8 6f 2c 20 57 #moving "o, W" into eax
a3 04 10 00 06 #moving eax into next memory location
b8 48 65 6c 6c #moving "Hell" into eax
a3 00 10 00 06 #moving eax into next memory location
b9 00 10 00 06 #moving pointer to start of memory location into ecx
ba 10 00 00 00 #moving string size into edx
bb 01 00 00 00 #moving "stdout" number to ebx
b8 04 00 00 00 #moving "print out" syscall number to eax
cd 80 #calling the linux kernel to execute our print to stdout
b8 01 00 00 00 #moving "sys_exit" call number to eax
cd 80 #executing it via linux sys_call
```
WIN/MZ/PE:
shellcode2exe.py (takes asciihex shellcode and creates a legit MZ PE exe file) script location:
<https://web.archive.org/web/20140725045200/http://zeltser.com/reverse-malware/shellcode2exe.py.txt>
dependency:
<https://github.com/radare/toys/tree/master/InlineEgg>
extract
```
python setup.py build
sudo python setup.py install
``` | When targeting an embedded system you can make a binary image of the rom or ram that is strictly the instructions and associated data from the program. And often can write that binary into a flash/rom and run it.
Operating systems want to know more than that, and developers often want to leave more than that in their file so they can debug or do other things with it later (disassemble with some recognizable symbol names). Also, embedded or on an operating system you may need to separate .text from .data from .bss from .rodata, etc and file formats like .elf provide a mechanism for that, and the preferred use case is to load that elf with some sort of loader be it the operating system or something programming the rom and ram of a microcontroller.
.exe has some header info as well. As mentioned .com didnt it loaded at address 0x100h and branched there.
to create a raw binary from an executable, with a gcc created elf file for example you can do something like
objcopy file.elf -O binary file.bin
If the program is segmented (.text, .data, etc) and those segments are not back to back the binary can get quite large. Again using embedded as an example if the rom is at 0x00000000 and data or bss is at 0x20000000 even if your program only has 4 bytes of data objcopy will create a 0x20000004 byte file filling in the gap between .text and .data (as it should because that is what you asked it to do).
What is it you are trying to do? Reading a elf or intel hex or srec file are quite trivial and from that you can see all the bits and bytes of the binary. Or disassembling the elf or whatever will also show you that in a human readable form. (objdump -D file.elf > file.list) |
5,267,988 | I just need a hello world demo to see how machine code actually works.
Though windows' **EXE** and linux' **ELF** is near machine code,but it's not **PURE**
How can I write/execute **PURE** machine code? | 2011/03/11 | [
"https://Stackoverflow.com/questions/5267988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/631505/"
] | The OS is not running the instructions, the CPU does (except if we're talking about a virtual machine OS, which do exist, I'm thinking about Forth or such things). The OS however does require some metainformation to know, that a file does in fact contain executable code, and how it expects its environment to look like. ELF is not just *near* machine code. It **is** machine code, together with some information for the OS to know that it's supposed to put the CPU to actually execute that thing.
If you want something simpler than ELF but \*nix, have a look at the a.out format, which is much simpler. Traditionally \*nix C compilers do (still) write their executable to a file called a.out, if no output name is specified. | When targeting an embedded system you can make a binary image of the rom or ram that is strictly the instructions and associated data from the program. And often can write that binary into a flash/rom and run it.
Operating systems want to know more than that, and developers often want to leave more than that in their file so they can debug or do other things with it later (disassemble with some recognizable symbol names). Also, embedded or on an operating system you may need to separate .text from .data from .bss from .rodata, etc and file formats like .elf provide a mechanism for that, and the preferred use case is to load that elf with some sort of loader be it the operating system or something programming the rom and ram of a microcontroller.
.exe has some header info as well. As mentioned .com didnt it loaded at address 0x100h and branched there.
to create a raw binary from an executable, with a gcc created elf file for example you can do something like
objcopy file.elf -O binary file.bin
If the program is segmented (.text, .data, etc) and those segments are not back to back the binary can get quite large. Again using embedded as an example if the rom is at 0x00000000 and data or bss is at 0x20000000 even if your program only has 4 bytes of data objcopy will create a 0x20000004 byte file filling in the gap between .text and .data (as it should because that is what you asked it to do).
What is it you are trying to do? Reading a elf or intel hex or srec file are quite trivial and from that you can see all the bits and bytes of the binary. Or disassembling the elf or whatever will also show you that in a human readable form. (objdump -D file.elf > file.list) |
5,267,988 | I just need a hello world demo to see how machine code actually works.
Though windows' **EXE** and linux' **ELF** is near machine code,but it's not **PURE**
How can I write/execute **PURE** machine code? | 2011/03/11 | [
"https://Stackoverflow.com/questions/5267988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/631505/"
] | Everyone knows that the application we usually wrote is run on the operating system. And managed by it.
It means that the operating system is run on the machine. So I think that is PURE machine code which you said.
So, you need to study how an operating system works.
Here is some NASM assembly code for a boot sector which can print "Hello world" in PURE.
```
org
xor ax, ax
mov ds, ax
mov si, msg
boot_loop:lodsb
or al, al
jz go_flag
mov ah, 0x0E
int 0x10
jmp boot_loop
go_flag:
jmp go_flag
msg db 'hello world', 13, 10, 0
times 510-($-$$) db 0
db 0x55
db 0xAA
```
And you can find more resources here: <http://wiki.osdev.org/Main_Page>.
END.
If you had installed nasm and had a floppy, You can
```
nasm boot.asm -f bin -o boot.bin
dd if=boot.bin of=/dev/fd0
```
Then, you can boot from this floppy and you will see the message.
(NOTE: you should make the first boot of your computer the floppy.)
In fact, I suggest you run that code in full virtual machine, like: bochs, virtualbox etc.
Because it is hard to find a machines with a floppy.
So, the steps are
First, you should need to install a full virtual machine.
Second, create a visual floppy by commend: bximage
Third, write bin file to that visual floppy.
Last, start your visual machine from that visual floppy.
NOTE: In <https://wiki.osdev.org> , there are some basic information about that topic. | The OS is not running the instructions, the CPU does (except if we're talking about a virtual machine OS, which do exist, I'm thinking about Forth or such things). The OS however does require some metainformation to know, that a file does in fact contain executable code, and how it expects its environment to look like. ELF is not just *near* machine code. It **is** machine code, together with some information for the OS to know that it's supposed to put the CPU to actually execute that thing.
If you want something simpler than ELF but \*nix, have a look at the a.out format, which is much simpler. Traditionally \*nix C compilers do (still) write their executable to a file called a.out, if no output name is specified. |
5,267,988 | I just need a hello world demo to see how machine code actually works.
Though windows' **EXE** and linux' **ELF** is near machine code,but it's not **PURE**
How can I write/execute **PURE** machine code? | 2011/03/11 | [
"https://Stackoverflow.com/questions/5267988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/631505/"
] | You **can** write in PURE machine code manually **WITHOUT ASSEMBLY**
Linux/ELF: <https://github.com/XlogicX/m2elf>. This is still a work in progress, I just started working on this yesterday.
Source file for "Hello World" would look like this:
```
b8 21 0a 00 00 #moving "!\n" into eax
a3 0c 10 00 06 #moving eax into first memory location
b8 6f 72 6c 64 #moving "orld" into eax
a3 08 10 00 06 #moving eax into next memory location
b8 6f 2c 20 57 #moving "o, W" into eax
a3 04 10 00 06 #moving eax into next memory location
b8 48 65 6c 6c #moving "Hell" into eax
a3 00 10 00 06 #moving eax into next memory location
b9 00 10 00 06 #moving pointer to start of memory location into ecx
ba 10 00 00 00 #moving string size into edx
bb 01 00 00 00 #moving "stdout" number to ebx
b8 04 00 00 00 #moving "print out" syscall number to eax
cd 80 #calling the linux kernel to execute our print to stdout
b8 01 00 00 00 #moving "sys_exit" call number to eax
cd 80 #executing it via linux sys_call
```
WIN/MZ/PE:
shellcode2exe.py (takes asciihex shellcode and creates a legit MZ PE exe file) script location:
<https://web.archive.org/web/20140725045200/http://zeltser.com/reverse-malware/shellcode2exe.py.txt>
dependency:
<https://github.com/radare/toys/tree/master/InlineEgg>
extract
```
python setup.py build
sudo python setup.py install
``` | It sounds like you're looking for the old [16-bit DOS `.COM` file format](http://en.wikipedia.org/wiki/COM_file). The bytes of a `.COM` file are loaded at offset 100h in the program segment (limiting them to a maximum size of 64k - 256 bytes), and the CPU simply started executing at offset 100h. There are no headers or any required information of any kind, just raw CPU instructions. |
5,267,988 | I just need a hello world demo to see how machine code actually works.
Though windows' **EXE** and linux' **ELF** is near machine code,but it's not **PURE**
How can I write/execute **PURE** machine code? | 2011/03/11 | [
"https://Stackoverflow.com/questions/5267988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/631505/"
] | Real Machine Code
-----------------
What you need to run the test: Linux x86 or x64 (in my case I am using Ubuntu x64)
**Let's Start**
This Assembly (x86) moves the value 666 into the eax register:
```
movl $666, %eax
ret
```
Let's make the binary representation of it:
Opcode **movl** (movl is a mov with operand size 32) in binary is = 1011
Instruction **width** in binary is = 1
Register **eax** in binary is = 000
Number **666** in signed 32 bits binary is = 00000000 00000000 00000010 10011010
**666** converted to **little endian** is = 10011010 00000010 00000000 00000000
Instruction **ret** (return) in binary is = 11000011
So finally our pure binary instructions will look like this:
`1011(movl)1(width)000(eax)10011010000000100000000000000000(666)
11000011(ret)`
Putting it all together:
```
1011100010011010000000100000000000000000
11000011
```
For executing it the binary code has to be placed in a memory page with execution privileges, we can do that using the following C code:
```
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
/* Allocate size bytes of executable memory. */
unsigned char *alloc_exec_mem(size_t size)
{
void *ptr;
ptr = mmap(0, size, PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE | MAP_ANON, -1, 0);
if (ptr == MAP_FAILED) {
perror("mmap");
exit(1);
}
return ptr;
}
/* Read up to buffer_size bytes, encoded as 1's and 0's, into buffer. */
void read_ones_and_zeros(unsigned char *buffer, size_t buffer_size)
{
unsigned char byte = 0;
int bit_index = 0;
int c;
while ((c = getchar()) != EOF) {
if (isspace(c)) {
continue;
} else if (c != '0' && c != '1') {
fprintf(stderr, "error: expected 1 or 0!\n");
exit(1);
}
byte = (byte << 1) | (c == '1');
bit_index++;
if (bit_index == 8) {
if (buffer_size == 0) {
fprintf(stderr, "error: buffer full!\n");
exit(1);
}
*buffer++ = byte;
--buffer_size;
byte = 0;
bit_index = 0;
}
}
if (bit_index != 0) {
fprintf(stderr, "error: left-over bits!\n");
exit(1);
}
}
int main()
{
typedef int (*func_ptr_t)(void);
func_ptr_t func;
unsigned char *mem;
int x;
mem = alloc_exec_mem(1024);
func = (func_ptr_t) mem;
read_ones_and_zeros(mem, 1024);
x = (*func)();
printf("function returned %d\n", x);
return 0;
}
```
*Source: <https://www.hanshq.net/files/ones-and-zeros_42.c>*
We can compile it using:
`gcc source.c -o binaryexec`
To execute it:
`./binaryexec`
Then we pass the first sets of instructions:
`1011100010011010000000100000000000000000`
*press enter*
and pass the return instruction:
`11000011`
*press enter*
finally ctrl+d to end the program and get the output:
>
> function returned 666
>
>
> | The next program is an Hello World program I wrote in Machine Code 16 bit (intel 8086), If you want to know machine code, I suggest that you learn Assembly first, because every line of code in Assembly is converted to A code line in Machine Code. For well I know I am from the few people in the world, still programming in Machine Code, instead of Assembly.
BTW, To run it, save the file with a ".com" extension and run on DOSBOX!
[So, this is an Hello World Program.](https://i.stack.imgur.com/a9m59.png) |
5,267,988 | I just need a hello world demo to see how machine code actually works.
Though windows' **EXE** and linux' **ELF** is near machine code,but it's not **PURE**
How can I write/execute **PURE** machine code? | 2011/03/11 | [
"https://Stackoverflow.com/questions/5267988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/631505/"
] | Everyone knows that the application we usually wrote is run on the operating system. And managed by it.
It means that the operating system is run on the machine. So I think that is PURE machine code which you said.
So, you need to study how an operating system works.
Here is some NASM assembly code for a boot sector which can print "Hello world" in PURE.
```
org
xor ax, ax
mov ds, ax
mov si, msg
boot_loop:lodsb
or al, al
jz go_flag
mov ah, 0x0E
int 0x10
jmp boot_loop
go_flag:
jmp go_flag
msg db 'hello world', 13, 10, 0
times 510-($-$$) db 0
db 0x55
db 0xAA
```
And you can find more resources here: <http://wiki.osdev.org/Main_Page>.
END.
If you had installed nasm and had a floppy, You can
```
nasm boot.asm -f bin -o boot.bin
dd if=boot.bin of=/dev/fd0
```
Then, you can boot from this floppy and you will see the message.
(NOTE: you should make the first boot of your computer the floppy.)
In fact, I suggest you run that code in full virtual machine, like: bochs, virtualbox etc.
Because it is hard to find a machines with a floppy.
So, the steps are
First, you should need to install a full virtual machine.
Second, create a visual floppy by commend: bximage
Third, write bin file to that visual floppy.
Last, start your visual machine from that visual floppy.
NOTE: In <https://wiki.osdev.org> , there are some basic information about that topic. | It sounds like you're looking for the old [16-bit DOS `.COM` file format](http://en.wikipedia.org/wiki/COM_file). The bytes of a `.COM` file are loaded at offset 100h in the program segment (limiting them to a maximum size of 64k - 256 bytes), and the CPU simply started executing at offset 100h. There are no headers or any required information of any kind, just raw CPU instructions. |
5,267,988 | I just need a hello world demo to see how machine code actually works.
Though windows' **EXE** and linux' **ELF** is near machine code,but it's not **PURE**
How can I write/execute **PURE** machine code? | 2011/03/11 | [
"https://Stackoverflow.com/questions/5267988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/631505/"
] | Everyone knows that the application we usually wrote is run on the operating system. And managed by it.
It means that the operating system is run on the machine. So I think that is PURE machine code which you said.
So, you need to study how an operating system works.
Here is some NASM assembly code for a boot sector which can print "Hello world" in PURE.
```
org
xor ax, ax
mov ds, ax
mov si, msg
boot_loop:lodsb
or al, al
jz go_flag
mov ah, 0x0E
int 0x10
jmp boot_loop
go_flag:
jmp go_flag
msg db 'hello world', 13, 10, 0
times 510-($-$$) db 0
db 0x55
db 0xAA
```
And you can find more resources here: <http://wiki.osdev.org/Main_Page>.
END.
If you had installed nasm and had a floppy, You can
```
nasm boot.asm -f bin -o boot.bin
dd if=boot.bin of=/dev/fd0
```
Then, you can boot from this floppy and you will see the message.
(NOTE: you should make the first boot of your computer the floppy.)
In fact, I suggest you run that code in full virtual machine, like: bochs, virtualbox etc.
Because it is hard to find a machines with a floppy.
So, the steps are
First, you should need to install a full virtual machine.
Second, create a visual floppy by commend: bximage
Third, write bin file to that visual floppy.
Last, start your visual machine from that visual floppy.
NOTE: In <https://wiki.osdev.org> , there are some basic information about that topic. | When targeting an embedded system you can make a binary image of the rom or ram that is strictly the instructions and associated data from the program. And often can write that binary into a flash/rom and run it.
Operating systems want to know more than that, and developers often want to leave more than that in their file so they can debug or do other things with it later (disassemble with some recognizable symbol names). Also, embedded or on an operating system you may need to separate .text from .data from .bss from .rodata, etc and file formats like .elf provide a mechanism for that, and the preferred use case is to load that elf with some sort of loader be it the operating system or something programming the rom and ram of a microcontroller.
.exe has some header info as well. As mentioned .com didnt it loaded at address 0x100h and branched there.
to create a raw binary from an executable, with a gcc created elf file for example you can do something like
objcopy file.elf -O binary file.bin
If the program is segmented (.text, .data, etc) and those segments are not back to back the binary can get quite large. Again using embedded as an example if the rom is at 0x00000000 and data or bss is at 0x20000000 even if your program only has 4 bytes of data objcopy will create a 0x20000004 byte file filling in the gap between .text and .data (as it should because that is what you asked it to do).
What is it you are trying to do? Reading a elf or intel hex or srec file are quite trivial and from that you can see all the bits and bytes of the binary. Or disassembling the elf or whatever will also show you that in a human readable form. (objdump -D file.elf > file.list) |
5,267,988 | I just need a hello world demo to see how machine code actually works.
Though windows' **EXE** and linux' **ELF** is near machine code,but it's not **PURE**
How can I write/execute **PURE** machine code? | 2011/03/11 | [
"https://Stackoverflow.com/questions/5267988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/631505/"
] | The OS is not running the instructions, the CPU does (except if we're talking about a virtual machine OS, which do exist, I'm thinking about Forth or such things). The OS however does require some metainformation to know, that a file does in fact contain executable code, and how it expects its environment to look like. ELF is not just *near* machine code. It **is** machine code, together with some information for the OS to know that it's supposed to put the CPU to actually execute that thing.
If you want something simpler than ELF but \*nix, have a look at the a.out format, which is much simpler. Traditionally \*nix C compilers do (still) write their executable to a file called a.out, if no output name is specified. | This are nice responses, but why someone would want to do this might guide the answer better. I think the most important reason is to get full control of their machine, especially over its cache writing, for maximum performance, and prevent any OS from sharing the processor or virtualizing your code (thus slowing it down) or especially in these days snooping on your code as well. As far as I can tell, assembler doesn't handle these issues and M$/Intel and other companies treat this like an infringement or "for hackers." This is very wrong headed however. If your assembler code is handed over to an OS or proprietary hardware, true optimization (potentially at GHz frequencies) will be out of reach. This is an very important issue with regards to science and technology, as our computers cannot be used to their full potential without hardware optimization, and are often computing several orders of magnitude below it. There probably is some workaround or some open-source hardware that enables this but I have yet to find it. Penny for anyones thoughts. |
5,267,988 | I just need a hello world demo to see how machine code actually works.
Though windows' **EXE** and linux' **ELF** is near machine code,but it's not **PURE**
How can I write/execute **PURE** machine code? | 2011/03/11 | [
"https://Stackoverflow.com/questions/5267988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/631505/"
] | You **can** write in PURE machine code manually **WITHOUT ASSEMBLY**
Linux/ELF: <https://github.com/XlogicX/m2elf>. This is still a work in progress, I just started working on this yesterday.
Source file for "Hello World" would look like this:
```
b8 21 0a 00 00 #moving "!\n" into eax
a3 0c 10 00 06 #moving eax into first memory location
b8 6f 72 6c 64 #moving "orld" into eax
a3 08 10 00 06 #moving eax into next memory location
b8 6f 2c 20 57 #moving "o, W" into eax
a3 04 10 00 06 #moving eax into next memory location
b8 48 65 6c 6c #moving "Hell" into eax
a3 00 10 00 06 #moving eax into next memory location
b9 00 10 00 06 #moving pointer to start of memory location into ecx
ba 10 00 00 00 #moving string size into edx
bb 01 00 00 00 #moving "stdout" number to ebx
b8 04 00 00 00 #moving "print out" syscall number to eax
cd 80 #calling the linux kernel to execute our print to stdout
b8 01 00 00 00 #moving "sys_exit" call number to eax
cd 80 #executing it via linux sys_call
```
WIN/MZ/PE:
shellcode2exe.py (takes asciihex shellcode and creates a legit MZ PE exe file) script location:
<https://web.archive.org/web/20140725045200/http://zeltser.com/reverse-malware/shellcode2exe.py.txt>
dependency:
<https://github.com/radare/toys/tree/master/InlineEgg>
extract
```
python setup.py build
sudo python setup.py install
``` | On Windows--at least 32bit Windows--you can execute RAW INSTRUCTIONS using a .com file.
For instance, if you take this string and save it in notepad with a .com extension:
```
X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
```
It will print a string and set off your antivirus software. |
5,267,988 | I just need a hello world demo to see how machine code actually works.
Though windows' **EXE** and linux' **ELF** is near machine code,but it's not **PURE**
How can I write/execute **PURE** machine code? | 2011/03/11 | [
"https://Stackoverflow.com/questions/5267988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/631505/"
] | You **can** write in PURE machine code manually **WITHOUT ASSEMBLY**
Linux/ELF: <https://github.com/XlogicX/m2elf>. This is still a work in progress, I just started working on this yesterday.
Source file for "Hello World" would look like this:
```
b8 21 0a 00 00 #moving "!\n" into eax
a3 0c 10 00 06 #moving eax into first memory location
b8 6f 72 6c 64 #moving "orld" into eax
a3 08 10 00 06 #moving eax into next memory location
b8 6f 2c 20 57 #moving "o, W" into eax
a3 04 10 00 06 #moving eax into next memory location
b8 48 65 6c 6c #moving "Hell" into eax
a3 00 10 00 06 #moving eax into next memory location
b9 00 10 00 06 #moving pointer to start of memory location into ecx
ba 10 00 00 00 #moving string size into edx
bb 01 00 00 00 #moving "stdout" number to ebx
b8 04 00 00 00 #moving "print out" syscall number to eax
cd 80 #calling the linux kernel to execute our print to stdout
b8 01 00 00 00 #moving "sys_exit" call number to eax
cd 80 #executing it via linux sys_call
```
WIN/MZ/PE:
shellcode2exe.py (takes asciihex shellcode and creates a legit MZ PE exe file) script location:
<https://web.archive.org/web/20140725045200/http://zeltser.com/reverse-malware/shellcode2exe.py.txt>
dependency:
<https://github.com/radare/toys/tree/master/InlineEgg>
extract
```
python setup.py build
sudo python setup.py install
``` | The next program is an Hello World program I wrote in Machine Code 16 bit (intel 8086), If you want to know machine code, I suggest that you learn Assembly first, because every line of code in Assembly is converted to A code line in Machine Code. For well I know I am from the few people in the world, still programming in Machine Code, instead of Assembly.
BTW, To run it, save the file with a ".com" extension and run on DOSBOX!
[So, this is an Hello World Program.](https://i.stack.imgur.com/a9m59.png) |
1,651 | I flagged many, but not all, of the comments on [this question](https://law.stackexchange.com/q/86530/46948) and [associated answer](https://law.stackexchange.com/a/86532/46948) as not needed/conversational. The flags were declined.
They are mostly talking about the physical makeup of money, inflation and, whether one of their friends in the 1970s would have purchased a beer or cannabis resin with extra money. Some examples (although I don't want to get bogged down in this specific instance; I'm more interested in flagging practice generally):
>
> In the 1970s a friend washed, in a launderette, a pair of jeans with a one-pound note in a pocket. It was real money in those days for a young student. Worth around 12 US dollars in today's values. He sent it to the Bank of England and they mailed him a £1 postal order to cash at a post office.
>
>
>
>
> I don't know where you got that from, but around here, nobody but car dealers and jewelers regularly come in contact with 200 euro bills. Most transactions requiring bills that size are now made electronically. Lots of shops will not accept 500 and 200 bills.
>
>
>
>
> in fact knowing this guy he would have spent £1 of fun money on cannabis resin, and it would have got him around 2 or 3 grams, and you can't really buy that stuff these days. I don't know what £10 would buy now, as I don't use recreational drugs
>
>
>
Can a person who reviews such flags explain how the comments are helpful so that I can be more selective in my flagging (if you even mind that I have over-flagged in this instance)? Or, if it's alright that I might be raising flags that sometimes are declined, let me know that too (i.e. I [should just keep flagging as I see it and you'll just decline what you disagree with and that's all fine](https://law.meta.stackexchange.com/a/939/46948) - I found this other answer after writing this question). I just don't want to be cluttering your queues.
I appreciate any insight into how moderators approach these. To be clear, I am not critical of the approach taken by moderators to these particular flags; it just doesn't match my prior understanding, and am looking for understanding of how the moderators view things to help guide my own flagging behaviour. Hopefully this is also helpful to others. | 2022/11/23 | [
"https://law.meta.stackexchange.com/questions/1651",
"https://law.meta.stackexchange.com",
"https://law.meta.stackexchange.com/users/46948/"
] | I also flagged the comments after seeing this post.
My flag on this comment also got rejected:
>
> I once ran a pair of blue jeans through the cycles through which a
> washing machine puts them and then found that I had left three
> twenty-dollar bills in one of the pockets. That is my only experience
> of money laundering.
>
>
>
I have to say I am quite curious as to how this doesn't quality as being either "outdated, conversational or not relevant to this post.". To me, this is the very definition of conversational. | Handling of comments is increasingly arbitrary on LawSE, but users can help by being more reasonable and exercising some self-restraint when it comes to flagging. As [feetwet said very politely](https://law.meta.stackexchange.com/questions/1651/comments-that-are-conversational#comment3911_1651): Please err on the side of *not* flagging comments.
Although I agree that the comments you quote here are irrelevant, it is frivolous to call a mod's attention for something like this. That extent of "housekeeping by mods" is unnecessary, in part because SE has functionality that automates the creation of chatrooms in instances of intense activity in the comments. The fact that, by the time you flagged all those comments, no automated chatrooms had ensued there reflects that flaggers are being too intolerant and demanding.
By contrast, some moderator keeps removing comments that certainly contribute to improvement or clarification of posts. One recent example relates to one of your [currently deleted posts](https://law.meta.stackexchange.com/a/1638/18505), where you and I made some comments:
[](https://i.stack.imgur.com/LmqtI.jpg)
Transcription:
>
> Me: Interestingly you were the first one who VTC both posts, yet the
> points you develop in this answer have nothing to do with the
> purported reason for VTC (namely, the remark about "*Questions that
> clearly ask for specific legal advice*"). If your stated reason for
> VTC was a different one, this reflects a flaw in the functionality
> about closing posts. Nor does your criticism apply to either of the
> OP's posts. The OP did not intersperse "a bunch" of facts/assumptions
> with questions. Even if he did, that would not be a good reason for
> VTC. The OP's questions mostly paraphrase his central inquiry.
>
>
> You: As I said, I am merely providing points for improvement. If the
> question author tells me this is not welcome, I will delete this
> answer.
>
>
> Me: "*I am merely providing points for improvement.*" The OP's question
> literally is "*Why is this question off topic?*" He is trying to make
> sense of why some users are voting to close his posts. Suggesting the
> OP not to intersperse "a bunch of" facts/assumptions with questions is
> unwarranted and does not help him, in part because he did not do that
> in the first place. Asking him whether he meant "this or that" should
> have been done via comments on his posts (after all, comments also are
> for clarifications), not in lieu of an explanation of why you
> repeatedly voted to close them.
>
>
> You: That's okay. These are just my
> views. I'll trust Bruce to tell me if he finds them unhelpful.
>
>
>
These comments should have been preserved because they promote discernment [among the audience] as to whether an answer truly addresses the OP's actual concern. That instance was notorious because, as I pointed out, you repeatedly were the first one VTC the OP's posts and yet eluded explaining on LawMeta your reasons for doing so. Nevertheless, apparently some mod thought it is better to hinder discernment and suppress critical thinking (at least when articulated by certain users). |
1,651 | I flagged many, but not all, of the comments on [this question](https://law.stackexchange.com/q/86530/46948) and [associated answer](https://law.stackexchange.com/a/86532/46948) as not needed/conversational. The flags were declined.
They are mostly talking about the physical makeup of money, inflation and, whether one of their friends in the 1970s would have purchased a beer or cannabis resin with extra money. Some examples (although I don't want to get bogged down in this specific instance; I'm more interested in flagging practice generally):
>
> In the 1970s a friend washed, in a launderette, a pair of jeans with a one-pound note in a pocket. It was real money in those days for a young student. Worth around 12 US dollars in today's values. He sent it to the Bank of England and they mailed him a £1 postal order to cash at a post office.
>
>
>
>
> I don't know where you got that from, but around here, nobody but car dealers and jewelers regularly come in contact with 200 euro bills. Most transactions requiring bills that size are now made electronically. Lots of shops will not accept 500 and 200 bills.
>
>
>
>
> in fact knowing this guy he would have spent £1 of fun money on cannabis resin, and it would have got him around 2 or 3 grams, and you can't really buy that stuff these days. I don't know what £10 would buy now, as I don't use recreational drugs
>
>
>
Can a person who reviews such flags explain how the comments are helpful so that I can be more selective in my flagging (if you even mind that I have over-flagged in this instance)? Or, if it's alright that I might be raising flags that sometimes are declined, let me know that too (i.e. I [should just keep flagging as I see it and you'll just decline what you disagree with and that's all fine](https://law.meta.stackexchange.com/a/939/46948) - I found this other answer after writing this question). I just don't want to be cluttering your queues.
I appreciate any insight into how moderators approach these. To be clear, I am not critical of the approach taken by moderators to these particular flags; it just doesn't match my prior understanding, and am looking for understanding of how the moderators view things to help guide my own flagging behaviour. Hopefully this is also helpful to others. | 2022/11/23 | [
"https://law.meta.stackexchange.com/questions/1651",
"https://law.meta.stackexchange.com",
"https://law.meta.stackexchange.com/users/46948/"
] | We respond to flags
-------------------
If you flag it, we look at it and we have to make a decision to delete or let them slide. There has been criticism in the past of heavy handedness in deleting comments ([How to deal with comments?](https://law.meta.stackexchange.com/questions/900/how-to-deal-with-comments)). Now there is criticism for leaving them be. Just one more cross to bear.
My position now is to let them lie; particularly if the comment makes me smile. People who want to read the comments will read them; people who don’t will ignore them. Chatty/funny comments are fine; only if the comment thread gets so long that no sensible person is going to read it does it get moved to chat. We get an automatic notification at 20 comments in 7 days; that’ll do for me.
As Mao said “[let a hundred flowers bloom](https://en.wikipedia.org/wiki/Hundred_Flowers_Campaign); fortunately we don’t have his power to become a genocidal maniac if we don’t like the flowers. Comments are like fairy floss: ephemeral, insubstantial, bad for you, and not very satisfying. If something really needs to change, **edit the post** - that’s why you were given the privilege.
What we don’t want is argumentative, nasty, or that generate into pointless bickering. If they don’t do that
[](https://i.stack.imgur.com/XpWIR.gif) | Handling of comments is increasingly arbitrary on LawSE, but users can help by being more reasonable and exercising some self-restraint when it comes to flagging. As [feetwet said very politely](https://law.meta.stackexchange.com/questions/1651/comments-that-are-conversational#comment3911_1651): Please err on the side of *not* flagging comments.
Although I agree that the comments you quote here are irrelevant, it is frivolous to call a mod's attention for something like this. That extent of "housekeeping by mods" is unnecessary, in part because SE has functionality that automates the creation of chatrooms in instances of intense activity in the comments. The fact that, by the time you flagged all those comments, no automated chatrooms had ensued there reflects that flaggers are being too intolerant and demanding.
By contrast, some moderator keeps removing comments that certainly contribute to improvement or clarification of posts. One recent example relates to one of your [currently deleted posts](https://law.meta.stackexchange.com/a/1638/18505), where you and I made some comments:
[](https://i.stack.imgur.com/LmqtI.jpg)
Transcription:
>
> Me: Interestingly you were the first one who VTC both posts, yet the
> points you develop in this answer have nothing to do with the
> purported reason for VTC (namely, the remark about "*Questions that
> clearly ask for specific legal advice*"). If your stated reason for
> VTC was a different one, this reflects a flaw in the functionality
> about closing posts. Nor does your criticism apply to either of the
> OP's posts. The OP did not intersperse "a bunch" of facts/assumptions
> with questions. Even if he did, that would not be a good reason for
> VTC. The OP's questions mostly paraphrase his central inquiry.
>
>
> You: As I said, I am merely providing points for improvement. If the
> question author tells me this is not welcome, I will delete this
> answer.
>
>
> Me: "*I am merely providing points for improvement.*" The OP's question
> literally is "*Why is this question off topic?*" He is trying to make
> sense of why some users are voting to close his posts. Suggesting the
> OP not to intersperse "a bunch of" facts/assumptions with questions is
> unwarranted and does not help him, in part because he did not do that
> in the first place. Asking him whether he meant "this or that" should
> have been done via comments on his posts (after all, comments also are
> for clarifications), not in lieu of an explanation of why you
> repeatedly voted to close them.
>
>
> You: That's okay. These are just my
> views. I'll trust Bruce to tell me if he finds them unhelpful.
>
>
>
These comments should have been preserved because they promote discernment [among the audience] as to whether an answer truly addresses the OP's actual concern. That instance was notorious because, as I pointed out, you repeatedly were the first one VTC the OP's posts and yet eluded explaining on LawMeta your reasons for doing so. Nevertheless, apparently some mod thought it is better to hinder discernment and suppress critical thinking (at least when articulated by certain users). |
24,366,091 | We receive a file from an external provider. One of the columns contains a timestamp in the form "05/01/2014 09:25:41 AM EDT". I am trying to insert this into a TIMESTAMP WITH TIME ZONE column with the following SQL:
`INSERT INTO table VALUES (to_timestamp_tz('05/01/2014 09:25:41 AM EDT', 'MM/DD/YYYY HH12:MI:SS AM TZR TZD'));`
That is when I get `ORA-1882: timezone region not found`. I've also tried specifying this like
`INSERT INTO table VALUES (to_timestamp_tz('05/01/2014 09:25:41 AM EST EDT', 'MM/DD/YYYY HH12:MI:SS AM TZR TZD'));`
but then I get `ORA-1857: not a valid time zone`.
Anyone have an idea how I can insert this? We are running Oracle 11.2.0.3. I can see in `v$timezone_names` that EST and EDT both appear to be valid tzabbrev for tzname 'America/New York'.
EDIT:
It appears that if I substitute EST5EDT for EDT (and CST6CDT, MST7MDT, and PST8PDT for CST, MST, and PST, respectively) , I can get the behavior I need. The problem with this is that I need to know what these substitutions are in advance so I can code around them. I still need to know how to handle potential daylight savings time issues with other timezones. | 2014/06/23 | [
"https://Stackoverflow.com/questions/24366091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3767403/"
] | >
> Are they differ in anything other than the usage ? or Does the syntax and definitions also differ?
>
>
>
The language is the same. The environment is different.
By "Core JavaScript," Flanagan is talking about *the language* and only the objects and functions defined by the [ECMAScript specification](http://ecma-international.org/ecma-262/5.1/), leaving anything provided by the *environment* out.
By "Client-side JavaScript" he's talking about the use of JavaScript, the language, in a browser environemnt. In a browser environment, your code will have access to things provided by the browser, like the `document` object for the current page, the `window`, functions like `alert` that pop up a message, etc.
By "Server-side JavaScript" he's talking about the use of JavaScript, the language, in a server environment. In that environment, your code won't have access to browser-related things because, well, it's not in a browser. It'll probably have access to other things, like APIs for dealing with the file system, databases, network, etc. | * Server-sided: Runs on server (like Node.js)
* Client-sided: Runs in browser
* Core: The set of functionality available to all javascript engines |
24,366,091 | We receive a file from an external provider. One of the columns contains a timestamp in the form "05/01/2014 09:25:41 AM EDT". I am trying to insert this into a TIMESTAMP WITH TIME ZONE column with the following SQL:
`INSERT INTO table VALUES (to_timestamp_tz('05/01/2014 09:25:41 AM EDT', 'MM/DD/YYYY HH12:MI:SS AM TZR TZD'));`
That is when I get `ORA-1882: timezone region not found`. I've also tried specifying this like
`INSERT INTO table VALUES (to_timestamp_tz('05/01/2014 09:25:41 AM EST EDT', 'MM/DD/YYYY HH12:MI:SS AM TZR TZD'));`
but then I get `ORA-1857: not a valid time zone`.
Anyone have an idea how I can insert this? We are running Oracle 11.2.0.3. I can see in `v$timezone_names` that EST and EDT both appear to be valid tzabbrev for tzname 'America/New York'.
EDIT:
It appears that if I substitute EST5EDT for EDT (and CST6CDT, MST7MDT, and PST8PDT for CST, MST, and PST, respectively) , I can get the behavior I need. The problem with this is that I need to know what these substitutions are in advance so I can code around them. I still need to know how to handle potential daylight savings time issues with other timezones. | 2014/06/23 | [
"https://Stackoverflow.com/questions/24366091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3767403/"
] | >
> Are they differ in anything other than the usage ? or Does the syntax and definitions also differ?
>
>
>
The language is the same. The environment is different.
By "Core JavaScript," Flanagan is talking about *the language* and only the objects and functions defined by the [ECMAScript specification](http://ecma-international.org/ecma-262/5.1/), leaving anything provided by the *environment* out.
By "Client-side JavaScript" he's talking about the use of JavaScript, the language, in a browser environemnt. In a browser environment, your code will have access to things provided by the browser, like the `document` object for the current page, the `window`, functions like `alert` that pop up a message, etc.
By "Server-side JavaScript" he's talking about the use of JavaScript, the language, in a server environment. In that environment, your code won't have access to browser-related things because, well, it's not in a browser. It'll probably have access to other things, like APIs for dealing with the file system, databases, network, etc. | Without knowing the book, I can't tell you what is the meaning of `CoreJavaScript`, but in what concerns to the first two the difference is:
Client side javascript as the name says, is javascript code, running on the client side, a typical scenario of this is, when you access a website, and you run javascript code. The code being executed is being executed on the clients machine. This is why it's called client side javascript.
**About the second**, server side javascript, is javascript code running over a server local resources, it's just like C# or Java, but the syntax is based on JavaScript, a good example of this is Node.JS, with Node.JS you write javascript to program on the server side, and that code can be seen as normal C#, C, or any other server side language code.
With server-side code, you can still send javascript to the client-side, but there is a great diference between both, because the client side code is restricted to the clients machine resources, in terms of computing power and permissions. For example client-side javascript can't access the clients hard disk, while with server side you can access your server hard disk without any problem.
**UPDATE**
I've read a bit of the book, and `Core JavaScript` is about the JavaScript language per se (JavaScript Reference), i.e, the syntax, the statements, the function definitions, it's the basics of the language in general.
Imagine you are reading about C# or Java, before writing about Sockets Programming, WebServices, etc, the book is giving the reader an insight of the language first, in terms of it's capabilities, ways to create functions, arrays, and so forth. |
24,366,091 | We receive a file from an external provider. One of the columns contains a timestamp in the form "05/01/2014 09:25:41 AM EDT". I am trying to insert this into a TIMESTAMP WITH TIME ZONE column with the following SQL:
`INSERT INTO table VALUES (to_timestamp_tz('05/01/2014 09:25:41 AM EDT', 'MM/DD/YYYY HH12:MI:SS AM TZR TZD'));`
That is when I get `ORA-1882: timezone region not found`. I've also tried specifying this like
`INSERT INTO table VALUES (to_timestamp_tz('05/01/2014 09:25:41 AM EST EDT', 'MM/DD/YYYY HH12:MI:SS AM TZR TZD'));`
but then I get `ORA-1857: not a valid time zone`.
Anyone have an idea how I can insert this? We are running Oracle 11.2.0.3. I can see in `v$timezone_names` that EST and EDT both appear to be valid tzabbrev for tzname 'America/New York'.
EDIT:
It appears that if I substitute EST5EDT for EDT (and CST6CDT, MST7MDT, and PST8PDT for CST, MST, and PST, respectively) , I can get the behavior I need. The problem with this is that I need to know what these substitutions are in advance so I can code around them. I still need to know how to handle potential daylight savings time issues with other timezones. | 2014/06/23 | [
"https://Stackoverflow.com/questions/24366091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3767403/"
] | >
> Are they differ in anything other than the usage ? or Does the syntax and definitions also differ?
>
>
>
The language is the same. The environment is different.
By "Core JavaScript," Flanagan is talking about *the language* and only the objects and functions defined by the [ECMAScript specification](http://ecma-international.org/ecma-262/5.1/), leaving anything provided by the *environment* out.
By "Client-side JavaScript" he's talking about the use of JavaScript, the language, in a browser environemnt. In a browser environment, your code will have access to things provided by the browser, like the `document` object for the current page, the `window`, functions like `alert` that pop up a message, etc.
By "Server-side JavaScript" he's talking about the use of JavaScript, the language, in a server environment. In that environment, your code won't have access to browser-related things because, well, it's not in a browser. It'll probably have access to other things, like APIs for dealing with the file system, databases, network, etc. | after installation of node js in system then we use javascript on server side. the code of nodejs is just like a javascript. no major differences so its also a javascript. Nodejs enables the user to use javascript code on server side too. |
24,366,091 | We receive a file from an external provider. One of the columns contains a timestamp in the form "05/01/2014 09:25:41 AM EDT". I am trying to insert this into a TIMESTAMP WITH TIME ZONE column with the following SQL:
`INSERT INTO table VALUES (to_timestamp_tz('05/01/2014 09:25:41 AM EDT', 'MM/DD/YYYY HH12:MI:SS AM TZR TZD'));`
That is when I get `ORA-1882: timezone region not found`. I've also tried specifying this like
`INSERT INTO table VALUES (to_timestamp_tz('05/01/2014 09:25:41 AM EST EDT', 'MM/DD/YYYY HH12:MI:SS AM TZR TZD'));`
but then I get `ORA-1857: not a valid time zone`.
Anyone have an idea how I can insert this? We are running Oracle 11.2.0.3. I can see in `v$timezone_names` that EST and EDT both appear to be valid tzabbrev for tzname 'America/New York'.
EDIT:
It appears that if I substitute EST5EDT for EDT (and CST6CDT, MST7MDT, and PST8PDT for CST, MST, and PST, respectively) , I can get the behavior I need. The problem with this is that I need to know what these substitutions are in advance so I can code around them. I still need to know how to handle potential daylight savings time issues with other timezones. | 2014/06/23 | [
"https://Stackoverflow.com/questions/24366091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3767403/"
] | * Server-sided: Runs on server (like Node.js)
* Client-sided: Runs in browser
* Core: The set of functionality available to all javascript engines | Without knowing the book, I can't tell you what is the meaning of `CoreJavaScript`, but in what concerns to the first two the difference is:
Client side javascript as the name says, is javascript code, running on the client side, a typical scenario of this is, when you access a website, and you run javascript code. The code being executed is being executed on the clients machine. This is why it's called client side javascript.
**About the second**, server side javascript, is javascript code running over a server local resources, it's just like C# or Java, but the syntax is based on JavaScript, a good example of this is Node.JS, with Node.JS you write javascript to program on the server side, and that code can be seen as normal C#, C, or any other server side language code.
With server-side code, you can still send javascript to the client-side, but there is a great diference between both, because the client side code is restricted to the clients machine resources, in terms of computing power and permissions. For example client-side javascript can't access the clients hard disk, while with server side you can access your server hard disk without any problem.
**UPDATE**
I've read a bit of the book, and `Core JavaScript` is about the JavaScript language per se (JavaScript Reference), i.e, the syntax, the statements, the function definitions, it's the basics of the language in general.
Imagine you are reading about C# or Java, before writing about Sockets Programming, WebServices, etc, the book is giving the reader an insight of the language first, in terms of it's capabilities, ways to create functions, arrays, and so forth. |
24,366,091 | We receive a file from an external provider. One of the columns contains a timestamp in the form "05/01/2014 09:25:41 AM EDT". I am trying to insert this into a TIMESTAMP WITH TIME ZONE column with the following SQL:
`INSERT INTO table VALUES (to_timestamp_tz('05/01/2014 09:25:41 AM EDT', 'MM/DD/YYYY HH12:MI:SS AM TZR TZD'));`
That is when I get `ORA-1882: timezone region not found`. I've also tried specifying this like
`INSERT INTO table VALUES (to_timestamp_tz('05/01/2014 09:25:41 AM EST EDT', 'MM/DD/YYYY HH12:MI:SS AM TZR TZD'));`
but then I get `ORA-1857: not a valid time zone`.
Anyone have an idea how I can insert this? We are running Oracle 11.2.0.3. I can see in `v$timezone_names` that EST and EDT both appear to be valid tzabbrev for tzname 'America/New York'.
EDIT:
It appears that if I substitute EST5EDT for EDT (and CST6CDT, MST7MDT, and PST8PDT for CST, MST, and PST, respectively) , I can get the behavior I need. The problem with this is that I need to know what these substitutions are in advance so I can code around them. I still need to know how to handle potential daylight savings time issues with other timezones. | 2014/06/23 | [
"https://Stackoverflow.com/questions/24366091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3767403/"
] | * Server-sided: Runs on server (like Node.js)
* Client-sided: Runs in browser
* Core: The set of functionality available to all javascript engines | after installation of node js in system then we use javascript on server side. the code of nodejs is just like a javascript. no major differences so its also a javascript. Nodejs enables the user to use javascript code on server side too. |
24,366,091 | We receive a file from an external provider. One of the columns contains a timestamp in the form "05/01/2014 09:25:41 AM EDT". I am trying to insert this into a TIMESTAMP WITH TIME ZONE column with the following SQL:
`INSERT INTO table VALUES (to_timestamp_tz('05/01/2014 09:25:41 AM EDT', 'MM/DD/YYYY HH12:MI:SS AM TZR TZD'));`
That is when I get `ORA-1882: timezone region not found`. I've also tried specifying this like
`INSERT INTO table VALUES (to_timestamp_tz('05/01/2014 09:25:41 AM EST EDT', 'MM/DD/YYYY HH12:MI:SS AM TZR TZD'));`
but then I get `ORA-1857: not a valid time zone`.
Anyone have an idea how I can insert this? We are running Oracle 11.2.0.3. I can see in `v$timezone_names` that EST and EDT both appear to be valid tzabbrev for tzname 'America/New York'.
EDIT:
It appears that if I substitute EST5EDT for EDT (and CST6CDT, MST7MDT, and PST8PDT for CST, MST, and PST, respectively) , I can get the behavior I need. The problem with this is that I need to know what these substitutions are in advance so I can code around them. I still need to know how to handle potential daylight savings time issues with other timezones. | 2014/06/23 | [
"https://Stackoverflow.com/questions/24366091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3767403/"
] | Without knowing the book, I can't tell you what is the meaning of `CoreJavaScript`, but in what concerns to the first two the difference is:
Client side javascript as the name says, is javascript code, running on the client side, a typical scenario of this is, when you access a website, and you run javascript code. The code being executed is being executed on the clients machine. This is why it's called client side javascript.
**About the second**, server side javascript, is javascript code running over a server local resources, it's just like C# or Java, but the syntax is based on JavaScript, a good example of this is Node.JS, with Node.JS you write javascript to program on the server side, and that code can be seen as normal C#, C, or any other server side language code.
With server-side code, you can still send javascript to the client-side, but there is a great diference between both, because the client side code is restricted to the clients machine resources, in terms of computing power and permissions. For example client-side javascript can't access the clients hard disk, while with server side you can access your server hard disk without any problem.
**UPDATE**
I've read a bit of the book, and `Core JavaScript` is about the JavaScript language per se (JavaScript Reference), i.e, the syntax, the statements, the function definitions, it's the basics of the language in general.
Imagine you are reading about C# or Java, before writing about Sockets Programming, WebServices, etc, the book is giving the reader an insight of the language first, in terms of it's capabilities, ways to create functions, arrays, and so forth. | after installation of node js in system then we use javascript on server side. the code of nodejs is just like a javascript. no major differences so its also a javascript. Nodejs enables the user to use javascript code on server side too. |
93,224 | >
> Use spaces liberally throughout your code. “When in doubt, space it out.”
>
>
>
In the above sentence, what does "space it out" mean?
Source: <https://make.wordpress.org/core/handbook/best-practices/coding-standards/javascript/#spacing> | 2016/06/09 | [
"https://ell.stackexchange.com/questions/93224",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/36262/"
] | In your example
>
> space it out
>
>
>
means to add spaces (or whitespaces) to make the code easier for humans to read.
Consider the difference between
>
> def myMethod(a,b,c)if(a==b)t=0;elseif(b==c)t=a;else t=c;end;return t;end
>
>
>
and
>
> def myMethod(a,b,c)
>
> if(a==b)
>
> t=0;
>
> elseif(b==c)
>
> t=a;
>
> else
>
> t=c;
>
> end;
>
> return t;
>
> end
>
>
>
the nesting, using additional whitespace indentation, more clearly shows how the code will execute given different conditions. In some circumstances, behind the scenes, the additional whitespace is automatically removed (since the computer does not need it) in a process call "minification".
Your example also uses the well known construction since "doubt" and "out" rhyme
>
> when in doubt, *something* it out
>
>
>
where *something* can be any verb that goes with "out" as long as the context makes sense
>
> when in doubt, white it out *(with correction fluid)*
>
> when in doubt, scream it out
>
> when in doubt, cut it out *(a possible saying by surgeons)*
>
> when in doubt, ride it out
>
> when in doubt, wait it out
>
>
> | The construction
>
> (verb) + **it out**
>
>
>
can be used to emphasize a verb in the sense to do that verb more, to do it until its maximum capacity, or to do it completely.
So your example means
>
> use more spaces
>
>
>
In other words, it means exactly what the first part says
>
> Use spaces liberally throughout your code
>
>
>
There are other examples:
* *Talk it out*
To talk until you are satisfied, or until you express all your burdensome emotions
* *Work it out*
To work on a problem until it is finished or fixed
* *Stretch it out*
To stretch something, like a muscle until it is warmed up, or a rubberband until it is about to break
* [*Stick it out*](http://idioms.thefreedictionary.com/stick+it+out)
To continue to do something to its end
There are other examples.
Further, the meaning I gave is not strict. Here is a special case.
>
> [cut it out](http://idioms.thefreedictionary.com/cut+it+out)
>
>
>
It means to stop something completely. For example, if you are trying to study, but your little brother or sister keeps asking you to play, you might tell him or her "Cut it out!" |
43,918,785 | I have a data frame with columns I want to reorder. However, in different iterations of my script, the total number of columns may change.
```
>Fruit
Vendor A B C D E ... Apples Oranges
Otto 4 5 2 5 2 ... 3 4
Fruit2<-Fruit[c(32,33,2:5)]
```
So instead of manually adapting the code (the columns 32 and 33 change) I'd like to do the following:
```
Fruit2<-Fruit[,c("Apples", "Oranges", 2:5)]
```
I tried a couple of syntaxes but could not get it to do what I want. I know, this is a simple syntax issue, but I could not find the solution yet.
The idea is to mix the variable name with the vector to reference the columns when writing a new data frame. I don't want to spell out the whole vector in variable names because in reality it's 30 variables. | 2017/05/11 | [
"https://Stackoverflow.com/questions/43918785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7998091/"
] | Make sure you are "adding" the `mysql-connector-java-5.1.42-bin.jar` file to the classpath when starting your program (obviously it can be a different version number).
something like
```
java -cp .;mysql-connector-java-5.0.8-bin.jar JdbcExample
```
or
```
set CLASSPATH=...;mysql-connector-java-5.0.8-bin.jar
java JdbcExample
```
assuming:
1. the JAR is in the current folder... if that works, consider putting the JAR in a 'central' place a use the complete path in above commands
2. using Windows, otherwise the separator would be `:` instead of `;`
3. the class is in no package
for Ubuntu:
```
java -cp .:mysql-connector-java-5.0.8-bin.jar JdbcExample
``` | Looks like more of a classpath issue. Try adding the jar manually to your project. I ran the same with `mysql-connector-java-5.0.8.jar` and I dont get this error. |
35,679,477 | ```
array[obj][obj] = 1;
```
I want to create 2D array whose index is user defined object. How to do this? or there is some other data structure available to do this? | 2016/02/28 | [
"https://Stackoverflow.com/questions/35679477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5672907/"
] | Android will use `res\values-v21\styles.xml` if the user's device is running Android API level 21+ (Android 5.0+) & will use `res\values\styles.xml` for older versions | It just means that the styles differ in android versions.
`styles.xml` in values-v21 mean that, that particular style is for Android API 21 version 5.0+
while `styles.xml` will be for any other Android version besides 5.0+.
its the same as language where you create an activity for en, fr, pk etc.
Older version would automatically be targetted by the `values/styles.xml` file. |
1,825,624 | I have created a job with the `at` command on Solaris 10.
It's working now but I want to kill it but I don't know how I can find the job number and how to kill that job or process. | 2009/12/01 | [
"https://Stackoverflow.com/questions/1825624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/147352/"
] | You should be able to find your command with a `ps` variant like:
```
ps -ef
ps -fubob # if your job's user ID is bob.
```
Then, once located, it should be a simple matter to use `kill` to kill the process (permissions permitting).
If you're talking about getting rid of jobs in the `at` queue (that aren't running yet), you can use `atq` to list them and `atrm` to get rid of them. | To delete a job which has not yet run, you need the `atrm` command. You can use `atq` command to get its number in the at list.
To kill a job which has already started to run, you'll need to grep for it using:
```
ps -eaf | grep <command name>
```
and then use `kill` to stop it.
A quicker way to do this on most systems is:
```
pkill <command name>
``` |
1,825,624 | I have created a job with the `at` command on Solaris 10.
It's working now but I want to kill it but I don't know how I can find the job number and how to kill that job or process. | 2009/12/01 | [
"https://Stackoverflow.com/questions/1825624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/147352/"
] | To delete a job which has not yet run, you need the `atrm` command. You can use `atq` command to get its number in the at list.
To kill a job which has already started to run, you'll need to grep for it using:
```
ps -eaf | grep <command name>
```
and then use `kill` to stop it.
A quicker way to do this on most systems is:
```
pkill <command name>
``` | First
```
ps -ef
```
to list all processes. Note the the process number of the one you want to kill. Then
```
kill 1234
```
were you replace 1234 with the process number that you want.
Alternatively, if you are absolutely certain that there is only one process with a particular name, or you want to kill multiple processes which share the same name
```
killall processname
``` |
1,825,624 | I have created a job with the `at` command on Solaris 10.
It's working now but I want to kill it but I don't know how I can find the job number and how to kill that job or process. | 2009/12/01 | [
"https://Stackoverflow.com/questions/1825624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/147352/"
] | To delete a job which has not yet run, you need the `atrm` command. You can use `atq` command to get its number in the at list.
To kill a job which has already started to run, you'll need to grep for it using:
```
ps -eaf | grep <command name>
```
and then use `kill` to stop it.
A quicker way to do this on most systems is:
```
pkill <command name>
``` | `at -l` to list jobs, which gives return like this:
```
age2%> at -l
11 2014-10-21 10:11 a hoppent
10 2014-10-19 13:28 a hoppent
```
`atrm 10` kills job 10
Or so my sysadmin told me, and it |
1,825,624 | I have created a job with the `at` command on Solaris 10.
It's working now but I want to kill it but I don't know how I can find the job number and how to kill that job or process. | 2009/12/01 | [
"https://Stackoverflow.com/questions/1825624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/147352/"
] | You should be able to find your command with a `ps` variant like:
```
ps -ef
ps -fubob # if your job's user ID is bob.
```
Then, once located, it should be a simple matter to use `kill` to kill the process (permissions permitting).
If you're talking about getting rid of jobs in the `at` queue (that aren't running yet), you can use `atq` to list them and `atrm` to get rid of them. | First
```
ps -ef
```
to list all processes. Note the the process number of the one you want to kill. Then
```
kill 1234
```
were you replace 1234 with the process number that you want.
Alternatively, if you are absolutely certain that there is only one process with a particular name, or you want to kill multiple processes which share the same name
```
killall processname
``` |
1,825,624 | I have created a job with the `at` command on Solaris 10.
It's working now but I want to kill it but I don't know how I can find the job number and how to kill that job or process. | 2009/12/01 | [
"https://Stackoverflow.com/questions/1825624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/147352/"
] | You should be able to find your command with a `ps` variant like:
```
ps -ef
ps -fubob # if your job's user ID is bob.
```
Then, once located, it should be a simple matter to use `kill` to kill the process (permissions permitting).
If you're talking about getting rid of jobs in the `at` queue (that aren't running yet), you can use `atq` to list them and `atrm` to get rid of them. | `at -l` to list jobs, which gives return like this:
```
age2%> at -l
11 2014-10-21 10:11 a hoppent
10 2014-10-19 13:28 a hoppent
```
`atrm 10` kills job 10
Or so my sysadmin told me, and it |
1,825,624 | I have created a job with the `at` command on Solaris 10.
It's working now but I want to kill it but I don't know how I can find the job number and how to kill that job or process. | 2009/12/01 | [
"https://Stackoverflow.com/questions/1825624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/147352/"
] | `at -l` to list jobs, which gives return like this:
```
age2%> at -l
11 2014-10-21 10:11 a hoppent
10 2014-10-19 13:28 a hoppent
```
`atrm 10` kills job 10
Or so my sysadmin told me, and it | First
```
ps -ef
```
to list all processes. Note the the process number of the one you want to kill. Then
```
kill 1234
```
were you replace 1234 with the process number that you want.
Alternatively, if you are absolutely certain that there is only one process with a particular name, or you want to kill multiple processes which share the same name
```
killall processname
``` |
275,274 | There is a challenge involving a lemon floating in a jug of water which seems impossible to beat. I've noticed it in several pubs of Edinburgh.
The challenge is as follows:
* There is a jug half filled with water.
* Floating in the water, there's a lemon. The lemon doesn't touch either the bottom nor the edges of the jug.
* The challenge is to successfully balance a coin on the lemon.
* Modifying, moving, or more generally touching the lemon are not allowed.
Any attempt to balance a coin on the lemon seems to result in the lemon flipping over, and the coin to sink in the water.
Why is it so hard to balance the coin while it's extremely easy to balance a coin on a lemon set on a table? How do you beat the lemon challenge? | 2016/08/19 | [
"https://physics.stackexchange.com/questions/275274",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/67968/"
] | We assume the lemon is rigid, which is reasonably accurate for these small forces.
Stability in buoyancy requires a small rotation to create a net restoring torque. This is conceptualized as the [metacenter](https://en.wikipedia.org/wiki/Metacentric_height), which is the "average" point the water pushes upward on. For *small* displacement angles this point remains fixed to the object. If the center of gravity is above the metacenter it's unstable. For the lemon, the metacenter is very close to the center since it's almost cylindrically symmetric. A coin raises the center of mass above the metacenter and makes the system unstable, regardless of exactly where it's positioned.
For a lemon on the table, the bumps and/or flat-regions act like a tiny tripod. As long as the center of mass stays above this "tripod" (above a point inside the triangle defined by it's three feet), it is stable. The center of mass depends on the position of the coin, so we can find a location that is stable for an arbitrarily small tripod.
As to the water case, it may be possible if the lemon is oddly shaped enough. | [](https://i.stack.imgur.com/IKbME.jpg)
The real answer is a trick. Sorry
Take a **heavier** coin and squeeze it in sideways underneath, so it's now a lemon with the centre of gravity at the bottom, like the keel on a sailboat.
As long as the top coin is small and light, it should balance. |
275,274 | There is a challenge involving a lemon floating in a jug of water which seems impossible to beat. I've noticed it in several pubs of Edinburgh.
The challenge is as follows:
* There is a jug half filled with water.
* Floating in the water, there's a lemon. The lemon doesn't touch either the bottom nor the edges of the jug.
* The challenge is to successfully balance a coin on the lemon.
* Modifying, moving, or more generally touching the lemon are not allowed.
Any attempt to balance a coin on the lemon seems to result in the lemon flipping over, and the coin to sink in the water.
Why is it so hard to balance the coin while it's extremely easy to balance a coin on a lemon set on a table? How do you beat the lemon challenge? | 2016/08/19 | [
"https://physics.stackexchange.com/questions/275274",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/67968/"
] | [](https://i.stack.imgur.com/IKbME.jpg)
The real answer is a trick. Sorry
Take a **heavier** coin and squeeze it in sideways underneath, so it's now a lemon with the centre of gravity at the bottom, like the keel on a sailboat.
As long as the top coin is small and light, it should balance. | I don't happen to have a lemon at the moment. But here's what I would try. I would try to place the coin so that it's position is as close as possible to the water plane. So then near either tip of the lemon rather than the center. My guess is the lemon is somewhat more stable in pitch than in roll, so it may not pitch up. And if the coin is closer to the water plane the disturbing torque in the roll axis may not be enough to turn the lemon. |
275,274 | There is a challenge involving a lemon floating in a jug of water which seems impossible to beat. I've noticed it in several pubs of Edinburgh.
The challenge is as follows:
* There is a jug half filled with water.
* Floating in the water, there's a lemon. The lemon doesn't touch either the bottom nor the edges of the jug.
* The challenge is to successfully balance a coin on the lemon.
* Modifying, moving, or more generally touching the lemon are not allowed.
Any attempt to balance a coin on the lemon seems to result in the lemon flipping over, and the coin to sink in the water.
Why is it so hard to balance the coin while it's extremely easy to balance a coin on a lemon set on a table? How do you beat the lemon challenge? | 2016/08/19 | [
"https://physics.stackexchange.com/questions/275274",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/67968/"
] | We assume the lemon is rigid, which is reasonably accurate for these small forces.
Stability in buoyancy requires a small rotation to create a net restoring torque. This is conceptualized as the [metacenter](https://en.wikipedia.org/wiki/Metacentric_height), which is the "average" point the water pushes upward on. For *small* displacement angles this point remains fixed to the object. If the center of gravity is above the metacenter it's unstable. For the lemon, the metacenter is very close to the center since it's almost cylindrically symmetric. A coin raises the center of mass above the metacenter and makes the system unstable, regardless of exactly where it's positioned.
For a lemon on the table, the bumps and/or flat-regions act like a tiny tripod. As long as the center of mass stays above this "tripod" (above a point inside the triangle defined by it's three feet), it is stable. The center of mass depends on the position of the coin, so we can find a location that is stable for an arbitrarily small tripod.
As to the water case, it may be possible if the lemon is oddly shaped enough. | I don't happen to have a lemon at the moment. But here's what I would try. I would try to place the coin so that it's position is as close as possible to the water plane. So then near either tip of the lemon rather than the center. My guess is the lemon is somewhat more stable in pitch than in roll, so it may not pitch up. And if the coin is closer to the water plane the disturbing torque in the roll axis may not be enough to turn the lemon. |
48,758,254 | I am trying to join two tables:
Table1: (900 million rows (106 GB). And, id1, id2, id3, id4 are **clustered primary key**, houseType is string)
```
+-----+-----+-----+------------+--------+
| Id1 | id2 | id3 | id4 | val1 |
+-----+-----+-----+------------+--------+
| ac | 15 | 697 | houseType1 | 75.396 |
+-----+-----+-----+------------+--------+
| ac | 15 | 697 | houseType2 | 20.97 |
+-----+-----+-----+------------+--------+
| ac | 15 | 805 | houseType1 | 112.99 |
+-----+-----+-----+------------+--------+
| ac | 15 | 805 | houseType2 | 53.67 |
+-----+-----+-----+------------+--------+
| ac | 27 | 697 | houseType1 | 67.28 |
+-----+-----+-----+------------+--------+
| ac | 27 | 697 | houseType2 | 55.12 |
+-----+-----+-----+------------+--------+
```
Table 2 is very small with 150 rows. And, val1, val2 are **clustered primary key.**
```
+------+------+---------+
| val1 | val2 | factor1 |
+------+------+---------+
| 0 | 10 | 0.82 |
+------+------+---------+
| 10 | 20 | 0.77 |
+------+------+---------+
| 20 | 30 | 0.15 |
+------+------+---------+
```
**What I need :**
For every "val1" in table1, it should be found which range [val1, val2] in table2 it belongs to and its associated "factor1" in table2 should be returned from table2, which will be used for further aggregate calculation.
example of my query:
```
Select a.id1, a.id2, a.id3, a.id4,
max(case when a.val1 >= b.val1 and a.val1 < b.val2 then b.factor1 * a.val1
else null
end ) as result
From Table1 as a,
Table2 as b
Group by a.id1, a.id2, a.id3, a.id4
```
For example, a row :
```
ac , 15, 697, houseType2, 20.97 in table1
0.15 should be returned from table2 because 20.97 in range [20, 30] in table2.
```
**There is no join action in the query because I do not know how to use join here. I just need to lookup the factors for val1 in table2.**
In SQL server, it runs very slow with more than 3 hours.
I also got :
```
Warning: Null value is eliminated by an aggregate or other SET operation.
```
Could anyone help me about this ?
thanks | 2018/02/13 | [
"https://Stackoverflow.com/questions/48758254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3448011/"
] | This should reduce your recordset:
```
Select a.id1, a.id2, a.id3, a.id4,
b.factor1 * a.val1 as result
From Table1 a inner join
Table2 b on a.val1 >= b.val1 and a.val1 < b.val2
```
This way, you will only get a single record from b for each record from a. This is at least a start to improve your performance problem.
No need for MAX because you are joining to get a single record. | I would be inclined to express this as a subquery or lateral join:
```
Select a.id1, a.id2, a.id3, a.id4, b.factor1 * a.val1 as result
From Table1 a cross apply
(select b.*
from Table2 b
where a.val1 >= b.val1 and a.val1 < b.val2
) b;
```
The aggregation is unnecessary because the four keys constitute the primary key. |
30,533,846 | I am using the Chartist plugin for generating charts. I've noticed that it does different element generations through browsers.
In Internet Explorer, it uses the `<text>` element, but it is offset on the left by 70px. I want to move that element on the right 70px, but I can't achieve this. I've tried with the `text-anchor`, `transform`, some letter and word spacing hacks, but none of them work.
Here is the code I am trying to modify:
```
<text class="ct-label ct-horizontal ct-end" x="25" y="205" width="179" height="20">FEB-2015</text>
```
So, instead of X-20, I want X-90.
[Here is a live demo](http://amarsyla.com/sandbox/hotelkey) | 2015/05/29 | [
"https://Stackoverflow.com/questions/30533846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1616512/"
] | Correct (but possibly slow) solution
------------------------------------
This **is** a bug of the Chartist library. They are calculating their label position so it is not center-aligned to the category.
For the permanent solution, you need to take it up with them, so the bug is fixed on their side.
You can find author's contact details on [this GitHub page](https://github.com/gionkunz).
Temporary solution
------------------
In the interim, you can apply a dirty fix by shifting the whole labels block to the right.
As IE11 ignores `transform` properties applied via CSS, we will need to apply it directly to the SVG node properties.
Since you have jQuery on your page, we'll use that for the simplicity sake:
```
<!--[if IE]>
<script>
$chart.on( 'created', function() {
$( '.ct-labels' ).attr( 'transform', 'translate(70)' );
} );
</script>
<![endif]-->
```
Needless to say, this needs to go **after** your other chart code. | How about modifying x attribute via Javascript?
```
<![if !IE]>
<script>
document.getElementsByTagName("text")[0].setAttribute("x", 95);
</script>
<![endif]>
``` |
30,533,846 | I am using the Chartist plugin for generating charts. I've noticed that it does different element generations through browsers.
In Internet Explorer, it uses the `<text>` element, but it is offset on the left by 70px. I want to move that element on the right 70px, but I can't achieve this. I've tried with the `text-anchor`, `transform`, some letter and word spacing hacks, but none of them work.
Here is the code I am trying to modify:
```
<text class="ct-label ct-horizontal ct-end" x="25" y="205" width="179" height="20">FEB-2015</text>
```
So, instead of X-20, I want X-90.
[Here is a live demo](http://amarsyla.com/sandbox/hotelkey) | 2015/05/29 | [
"https://Stackoverflow.com/questions/30533846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1616512/"
] | Correct (but possibly slow) solution
------------------------------------
This **is** a bug of the Chartist library. They are calculating their label position so it is not center-aligned to the category.
For the permanent solution, you need to take it up with them, so the bug is fixed on their side.
You can find author's contact details on [this GitHub page](https://github.com/gionkunz).
Temporary solution
------------------
In the interim, you can apply a dirty fix by shifting the whole labels block to the right.
As IE11 ignores `transform` properties applied via CSS, we will need to apply it directly to the SVG node properties.
Since you have jQuery on your page, we'll use that for the simplicity sake:
```
<!--[if IE]>
<script>
$chart.on( 'created', function() {
$( '.ct-labels' ).attr( 'transform', 'translate(70)' );
} );
</script>
<![endif]-->
```
Needless to say, this needs to go **after** your other chart code. | Text tag is child of svg g element.
You can't change x/y position of g element
but you can use transform="translate(x,y)":
```
<g transform="translate(70,0)" ... >
<text class="ct-label ct-horizontal ct-end" x="25" y="205" width="179" height="20">FEB-2015</text>
<text class="ct-label ct-horizontal ct-end" x="25" y="205" width="179" height="20">FEB-2015</text>
......
</g>
```
info on SVG G:
<http://tutorials.jenkov.com/svg/g-element.html> |
30,533,846 | I am using the Chartist plugin for generating charts. I've noticed that it does different element generations through browsers.
In Internet Explorer, it uses the `<text>` element, but it is offset on the left by 70px. I want to move that element on the right 70px, but I can't achieve this. I've tried with the `text-anchor`, `transform`, some letter and word spacing hacks, but none of them work.
Here is the code I am trying to modify:
```
<text class="ct-label ct-horizontal ct-end" x="25" y="205" width="179" height="20">FEB-2015</text>
```
So, instead of X-20, I want X-90.
[Here is a live demo](http://amarsyla.com/sandbox/hotelkey) | 2015/05/29 | [
"https://Stackoverflow.com/questions/30533846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1616512/"
] | Correct (but possibly slow) solution
------------------------------------
This **is** a bug of the Chartist library. They are calculating their label position so it is not center-aligned to the category.
For the permanent solution, you need to take it up with them, so the bug is fixed on their side.
You can find author's contact details on [this GitHub page](https://github.com/gionkunz).
Temporary solution
------------------
In the interim, you can apply a dirty fix by shifting the whole labels block to the right.
As IE11 ignores `transform` properties applied via CSS, we will need to apply it directly to the SVG node properties.
Since you have jQuery on your page, we'll use that for the simplicity sake:
```
<!--[if IE]>
<script>
$chart.on( 'created', function() {
$( '.ct-labels' ).attr( 'transform', 'translate(70)' );
} );
</script>
<![endif]-->
```
Needless to say, this needs to go **after** your other chart code. | Add this to your style sheet:
```
text{
position: relative;
right: 0px;
left: 50px;
}
```
It will remove your left transform and will move your `<text></text>` to right ( 50px ) |
30,533,846 | I am using the Chartist plugin for generating charts. I've noticed that it does different element generations through browsers.
In Internet Explorer, it uses the `<text>` element, but it is offset on the left by 70px. I want to move that element on the right 70px, but I can't achieve this. I've tried with the `text-anchor`, `transform`, some letter and word spacing hacks, but none of them work.
Here is the code I am trying to modify:
```
<text class="ct-label ct-horizontal ct-end" x="25" y="205" width="179" height="20">FEB-2015</text>
```
So, instead of X-20, I want X-90.
[Here is a live demo](http://amarsyla.com/sandbox/hotelkey) | 2015/05/29 | [
"https://Stackoverflow.com/questions/30533846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1616512/"
] | Correct (but possibly slow) solution
------------------------------------
This **is** a bug of the Chartist library. They are calculating their label position so it is not center-aligned to the category.
For the permanent solution, you need to take it up with them, so the bug is fixed on their side.
You can find author's contact details on [this GitHub page](https://github.com/gionkunz).
Temporary solution
------------------
In the interim, you can apply a dirty fix by shifting the whole labels block to the right.
As IE11 ignores `transform` properties applied via CSS, we will need to apply it directly to the SVG node properties.
Since you have jQuery on your page, we'll use that for the simplicity sake:
```
<!--[if IE]>
<script>
$chart.on( 'created', function() {
$( '.ct-labels' ).attr( 'transform', 'translate(70)' );
} );
</script>
<![endif]-->
```
Needless to say, this needs to go **after** your other chart code. | ```
<!--[if IE]>
<script>
$chart.on( 'created', function() {
$( '.ct-labels' ).attr( 'transform', 'translate(70)' );
} );
</script>
<![endif]-->
``` |
292,887 | Recently I downloaded ubuntu 13.04 (iso). Now after extracting the iso file and running wubi - it says downloading required files though I had already downloaded the iso file (794 MB). So what to do now? | 2013/05/09 | [
"https://askubuntu.com/questions/292887",
"https://askubuntu.com",
"https://askubuntu.com/users/101535/"
] | wubi in 13.04 is not in a releasable state. You have to install Ubuntu 12.10 through wubi and then upgrade to 13.04. follow this [steps](http://schoudhury.com/blog/articles/install-ubuntu-13-04-with-ubuntu-wubi-installer/) | Use the ISO that you have downloaded. You can make a boot-able pendrive by using this utility at <http://www.pendrivelinux.com/>. Then you can install ubuntu using this pendrive.
PS. : in your boot options just check that USB is higher priority to the hard-drive.
Also, Wubi currently is not the best way of installing Ubuntu. You can read it for yourself [here](http://www.omgubuntu.co.uk/2013/04/wubi-advice) |
292,887 | Recently I downloaded ubuntu 13.04 (iso). Now after extracting the iso file and running wubi - it says downloading required files though I had already downloaded the iso file (794 MB). So what to do now? | 2013/05/09 | [
"https://askubuntu.com/questions/292887",
"https://askubuntu.com",
"https://askubuntu.com/users/101535/"
] | wubi in 13.04 is not in a releasable state. You have to install Ubuntu 12.10 through wubi and then upgrade to 13.04. follow this [steps](http://schoudhury.com/blog/articles/install-ubuntu-13-04-with-ubuntu-wubi-installer/) | If you're on Windows, or even on Wine you could also try Unetbootin or LinuxLiveUsb.
I tried both of those for the first time yesterday, both were remarkably easy to use and did the job perfectly. |
292,887 | Recently I downloaded ubuntu 13.04 (iso). Now after extracting the iso file and running wubi - it says downloading required files though I had already downloaded the iso file (794 MB). So what to do now? | 2013/05/09 | [
"https://askubuntu.com/questions/292887",
"https://askubuntu.com",
"https://askubuntu.com/users/101535/"
] | wubi in 13.04 is not in a releasable state. You have to install Ubuntu 12.10 through wubi and then upgrade to 13.04. follow this [steps](http://schoudhury.com/blog/articles/install-ubuntu-13-04-with-ubuntu-wubi-installer/) | DO NOT extract ISO files. Instead mount it using ISO mounting program, and run Wubi. I suggest use Wubi only when you using Ubuntu [12.10](/questions/tagged/12.10 "show questions tagged '12.10'")
---
If you mean installing it on its own partition, instead use [live-usb](/questions/tagged/live-usb "show questions tagged 'live-usb'") from [pendrive](/questions/tagged/pendrive "show questions tagged 'pendrive'") using [UUI (Universal USB Installer)](http://www.pendrivelinux.com/). |
292,887 | Recently I downloaded ubuntu 13.04 (iso). Now after extracting the iso file and running wubi - it says downloading required files though I had already downloaded the iso file (794 MB). So what to do now? | 2013/05/09 | [
"https://askubuntu.com/questions/292887",
"https://askubuntu.com",
"https://askubuntu.com/users/101535/"
] | Use the ISO that you have downloaded. You can make a boot-able pendrive by using this utility at <http://www.pendrivelinux.com/>. Then you can install ubuntu using this pendrive.
PS. : in your boot options just check that USB is higher priority to the hard-drive.
Also, Wubi currently is not the best way of installing Ubuntu. You can read it for yourself [here](http://www.omgubuntu.co.uk/2013/04/wubi-advice) | If you're on Windows, or even on Wine you could also try Unetbootin or LinuxLiveUsb.
I tried both of those for the first time yesterday, both were remarkably easy to use and did the job perfectly. |
292,887 | Recently I downloaded ubuntu 13.04 (iso). Now after extracting the iso file and running wubi - it says downloading required files though I had already downloaded the iso file (794 MB). So what to do now? | 2013/05/09 | [
"https://askubuntu.com/questions/292887",
"https://askubuntu.com",
"https://askubuntu.com/users/101535/"
] | Use the ISO that you have downloaded. You can make a boot-able pendrive by using this utility at <http://www.pendrivelinux.com/>. Then you can install ubuntu using this pendrive.
PS. : in your boot options just check that USB is higher priority to the hard-drive.
Also, Wubi currently is not the best way of installing Ubuntu. You can read it for yourself [here](http://www.omgubuntu.co.uk/2013/04/wubi-advice) | DO NOT extract ISO files. Instead mount it using ISO mounting program, and run Wubi. I suggest use Wubi only when you using Ubuntu [12.10](/questions/tagged/12.10 "show questions tagged '12.10'")
---
If you mean installing it on its own partition, instead use [live-usb](/questions/tagged/live-usb "show questions tagged 'live-usb'") from [pendrive](/questions/tagged/pendrive "show questions tagged 'pendrive'") using [UUI (Universal USB Installer)](http://www.pendrivelinux.com/). |
67,506,376 | I am trying to create a Django application where each User has one model attached to them ( a list of Plants ) and that model is composed of individual plants. I already know I can have the plants connected to the plant list through a many-to-one relationship using foreign key as shown down below:
```
class PlantList(models.Model):
plant_list_id = models.AutoField(primary_key=True)
class Plant(models.Model):
plantlist = models.ForeignKey(PlantList, on_delete = models.CASCADE)
name = models.CharField(max_length = 20)
wateringInterval = models.PositiveSmallIntegerField()
```
However, I want each user to have a plant list attached to them that can be displayed uniquely for each user, according to the plants that they add to their list. How would I make it so that each user has a plant list?
I was trying to have it inside the register form but couldn't figure out how to do it and I wanted each plantlist to have a unique ID so that I can add plants to it easier.
```
class AddNewPlant(forms.Form):
name = forms.CharField(label='Name',max_length = 20)
wateringInterval = forms.IntegerField(label='Watering Interval')
``` | 2021/05/12 | [
"https://Stackoverflow.com/questions/67506376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10322369/"
] | ```
struct Example {
var string: String
init(number: Int) {
string = String(number)
}
init(number: Float) {
string = String(number)
}
init(number: Double) {
string = String(number)
}
}
``` | You can have a look at how swift does this with its String-initializer:
```
struct Example {
init<Number>(number: Number) where Number: BinaryInteger {
string = String(number)
}
}
``` |
67,506,376 | I am trying to create a Django application where each User has one model attached to them ( a list of Plants ) and that model is composed of individual plants. I already know I can have the plants connected to the plant list through a many-to-one relationship using foreign key as shown down below:
```
class PlantList(models.Model):
plant_list_id = models.AutoField(primary_key=True)
class Plant(models.Model):
plantlist = models.ForeignKey(PlantList, on_delete = models.CASCADE)
name = models.CharField(max_length = 20)
wateringInterval = models.PositiveSmallIntegerField()
```
However, I want each user to have a plant list attached to them that can be displayed uniquely for each user, according to the plants that they add to their list. How would I make it so that each user has a plant list?
I was trying to have it inside the register form but couldn't figure out how to do it and I wanted each plantlist to have a unique ID so that I can add plants to it easier.
```
class AddNewPlant(forms.Form):
name = forms.CharField(label='Name',max_length = 20)
wateringInterval = forms.IntegerField(label='Watering Interval')
``` | 2021/05/12 | [
"https://Stackoverflow.com/questions/67506376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10322369/"
] | Use generic structure with Numeric protocol.
```
struct Example<T:Numeric> {
var string: String
init(number: T) {
self.string = "\(number)"
}
}
``` | ```
struct Example {
var string: String
init(number: Int) {
string = String(number)
}
init(number: Float) {
string = String(number)
}
init(number: Double) {
string = String(number)
}
}
``` |
67,506,376 | I am trying to create a Django application where each User has one model attached to them ( a list of Plants ) and that model is composed of individual plants. I already know I can have the plants connected to the plant list through a many-to-one relationship using foreign key as shown down below:
```
class PlantList(models.Model):
plant_list_id = models.AutoField(primary_key=True)
class Plant(models.Model):
plantlist = models.ForeignKey(PlantList, on_delete = models.CASCADE)
name = models.CharField(max_length = 20)
wateringInterval = models.PositiveSmallIntegerField()
```
However, I want each user to have a plant list attached to them that can be displayed uniquely for each user, according to the plants that they add to their list. How would I make it so that each user has a plant list?
I was trying to have it inside the register form but couldn't figure out how to do it and I wanted each plantlist to have a unique ID so that I can add plants to it easier.
```
class AddNewPlant(forms.Form):
name = forms.CharField(label='Name',max_length = 20)
wateringInterval = forms.IntegerField(label='Watering Interval')
``` | 2021/05/12 | [
"https://Stackoverflow.com/questions/67506376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10322369/"
] | Actually if all you want is a string representation of `Int` `Float` `Double` or any other standard numeric type you only need to know that they conform to `CustomStringConvertible` and use `String(describing:)`.
Or you can use conformance to [`Numeric`](https://developer.apple.com/documentation/swift/numeric) **and** [`CustomStringConvertible`](https://developer.apple.com/documentation/swift/customstringconvertible):
```
struct example {
var string: String
init<C: CustomStringConvertible & Numeric>(number: C) {
string = String(describing: number)
}
}
```
and maybe even better `example` itself could conform to `CustomStringConvertible`
```
struct example: CustomStringConvertible {
var description: String
init<C: CustomStringConvertible & Numeric>(number: C) {
description = String(describing: number)
}
}
```
yet another way :
```
struct example<N: Numeric & CustomStringConvertible>: CustomStringConvertible {
let number: N
init(number: N) {
self.number = number
}
var description: String {
String(describing: number)
}
}
```
### EDIT
I think what you want is a custom [Property Wrapper](https://docs.swift.org/swift-book/LanguageGuide/Properties.html#ID617) not `@Binding`:
```
@propertyWrapper struct CustomStringConversion<Wrapped: CustomStringConvertible> {
var wrappedValue: Wrapped
init(wrappedValue: Wrapped) {
self.wrappedValue = wrappedValue
}
var projectedValue: String { .init(describing: wrappedValue) }
}
struct Foo {
@CustomStringConversion var number = 5
}
let foo = Foo()
let number: Int = foo.number // 5
let stringRepresentation: String = foo.$number // "5"
```
But as @LeoDabus pointed out [using `LosslessStringConvertible`](https://stackoverflow.com/questions/65958622/extending-a-type-to-have-multiple-values-for-the-same-associatedtype/65960326#65960326) may be better :
```
struct example<N: Numeric & LosslessStringConvertible>: LosslessStringConvertible {
let number: N
init(number: N) {
self.number = number
}
init?(_ description: String) {
guard let number = N(description) else { return nil }
self.number = number
}
var description: String {
.init(number)
}
}
let bar = example(number: Double.greatestFiniteMagnitude) // 1.7976931348623157e+308
let baz: example<Double>? = example("1.7976931348623157e+308") // 1.7976931348623157e+308
``` | ```
struct Example {
var string: String
init(number: Int) {
string = String(number)
}
init(number: Float) {
string = String(number)
}
init(number: Double) {
string = String(number)
}
}
``` |
67,506,376 | I am trying to create a Django application where each User has one model attached to them ( a list of Plants ) and that model is composed of individual plants. I already know I can have the plants connected to the plant list through a many-to-one relationship using foreign key as shown down below:
```
class PlantList(models.Model):
plant_list_id = models.AutoField(primary_key=True)
class Plant(models.Model):
plantlist = models.ForeignKey(PlantList, on_delete = models.CASCADE)
name = models.CharField(max_length = 20)
wateringInterval = models.PositiveSmallIntegerField()
```
However, I want each user to have a plant list attached to them that can be displayed uniquely for each user, according to the plants that they add to their list. How would I make it so that each user has a plant list?
I was trying to have it inside the register form but couldn't figure out how to do it and I wanted each plantlist to have a unique ID so that I can add plants to it easier.
```
class AddNewPlant(forms.Form):
name = forms.CharField(label='Name',max_length = 20)
wateringInterval = forms.IntegerField(label='Watering Interval')
``` | 2021/05/12 | [
"https://Stackoverflow.com/questions/67506376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10322369/"
] | Use generic structure with Numeric protocol.
```
struct Example<T:Numeric> {
var string: String
init(number: T) {
self.string = "\(number)"
}
}
``` | You can have a look at how swift does this with its String-initializer:
```
struct Example {
init<Number>(number: Number) where Number: BinaryInteger {
string = String(number)
}
}
``` |
67,506,376 | I am trying to create a Django application where each User has one model attached to them ( a list of Plants ) and that model is composed of individual plants. I already know I can have the plants connected to the plant list through a many-to-one relationship using foreign key as shown down below:
```
class PlantList(models.Model):
plant_list_id = models.AutoField(primary_key=True)
class Plant(models.Model):
plantlist = models.ForeignKey(PlantList, on_delete = models.CASCADE)
name = models.CharField(max_length = 20)
wateringInterval = models.PositiveSmallIntegerField()
```
However, I want each user to have a plant list attached to them that can be displayed uniquely for each user, according to the plants that they add to their list. How would I make it so that each user has a plant list?
I was trying to have it inside the register form but couldn't figure out how to do it and I wanted each plantlist to have a unique ID so that I can add plants to it easier.
```
class AddNewPlant(forms.Form):
name = forms.CharField(label='Name',max_length = 20)
wateringInterval = forms.IntegerField(label='Watering Interval')
``` | 2021/05/12 | [
"https://Stackoverflow.com/questions/67506376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10322369/"
] | Actually if all you want is a string representation of `Int` `Float` `Double` or any other standard numeric type you only need to know that they conform to `CustomStringConvertible` and use `String(describing:)`.
Or you can use conformance to [`Numeric`](https://developer.apple.com/documentation/swift/numeric) **and** [`CustomStringConvertible`](https://developer.apple.com/documentation/swift/customstringconvertible):
```
struct example {
var string: String
init<C: CustomStringConvertible & Numeric>(number: C) {
string = String(describing: number)
}
}
```
and maybe even better `example` itself could conform to `CustomStringConvertible`
```
struct example: CustomStringConvertible {
var description: String
init<C: CustomStringConvertible & Numeric>(number: C) {
description = String(describing: number)
}
}
```
yet another way :
```
struct example<N: Numeric & CustomStringConvertible>: CustomStringConvertible {
let number: N
init(number: N) {
self.number = number
}
var description: String {
String(describing: number)
}
}
```
### EDIT
I think what you want is a custom [Property Wrapper](https://docs.swift.org/swift-book/LanguageGuide/Properties.html#ID617) not `@Binding`:
```
@propertyWrapper struct CustomStringConversion<Wrapped: CustomStringConvertible> {
var wrappedValue: Wrapped
init(wrappedValue: Wrapped) {
self.wrappedValue = wrappedValue
}
var projectedValue: String { .init(describing: wrappedValue) }
}
struct Foo {
@CustomStringConversion var number = 5
}
let foo = Foo()
let number: Int = foo.number // 5
let stringRepresentation: String = foo.$number // "5"
```
But as @LeoDabus pointed out [using `LosslessStringConvertible`](https://stackoverflow.com/questions/65958622/extending-a-type-to-have-multiple-values-for-the-same-associatedtype/65960326#65960326) may be better :
```
struct example<N: Numeric & LosslessStringConvertible>: LosslessStringConvertible {
let number: N
init(number: N) {
self.number = number
}
init?(_ description: String) {
guard let number = N(description) else { return nil }
self.number = number
}
var description: String {
.init(number)
}
}
let bar = example(number: Double.greatestFiniteMagnitude) // 1.7976931348623157e+308
let baz: example<Double>? = example("1.7976931348623157e+308") // 1.7976931348623157e+308
``` | You can have a look at how swift does this with its String-initializer:
```
struct Example {
init<Number>(number: Number) where Number: BinaryInteger {
string = String(number)
}
}
``` |
67,506,376 | I am trying to create a Django application where each User has one model attached to them ( a list of Plants ) and that model is composed of individual plants. I already know I can have the plants connected to the plant list through a many-to-one relationship using foreign key as shown down below:
```
class PlantList(models.Model):
plant_list_id = models.AutoField(primary_key=True)
class Plant(models.Model):
plantlist = models.ForeignKey(PlantList, on_delete = models.CASCADE)
name = models.CharField(max_length = 20)
wateringInterval = models.PositiveSmallIntegerField()
```
However, I want each user to have a plant list attached to them that can be displayed uniquely for each user, according to the plants that they add to their list. How would I make it so that each user has a plant list?
I was trying to have it inside the register form but couldn't figure out how to do it and I wanted each plantlist to have a unique ID so that I can add plants to it easier.
```
class AddNewPlant(forms.Form):
name = forms.CharField(label='Name',max_length = 20)
wateringInterval = forms.IntegerField(label='Watering Interval')
``` | 2021/05/12 | [
"https://Stackoverflow.com/questions/67506376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10322369/"
] | Actually if all you want is a string representation of `Int` `Float` `Double` or any other standard numeric type you only need to know that they conform to `CustomStringConvertible` and use `String(describing:)`.
Or you can use conformance to [`Numeric`](https://developer.apple.com/documentation/swift/numeric) **and** [`CustomStringConvertible`](https://developer.apple.com/documentation/swift/customstringconvertible):
```
struct example {
var string: String
init<C: CustomStringConvertible & Numeric>(number: C) {
string = String(describing: number)
}
}
```
and maybe even better `example` itself could conform to `CustomStringConvertible`
```
struct example: CustomStringConvertible {
var description: String
init<C: CustomStringConvertible & Numeric>(number: C) {
description = String(describing: number)
}
}
```
yet another way :
```
struct example<N: Numeric & CustomStringConvertible>: CustomStringConvertible {
let number: N
init(number: N) {
self.number = number
}
var description: String {
String(describing: number)
}
}
```
### EDIT
I think what you want is a custom [Property Wrapper](https://docs.swift.org/swift-book/LanguageGuide/Properties.html#ID617) not `@Binding`:
```
@propertyWrapper struct CustomStringConversion<Wrapped: CustomStringConvertible> {
var wrappedValue: Wrapped
init(wrappedValue: Wrapped) {
self.wrappedValue = wrappedValue
}
var projectedValue: String { .init(describing: wrappedValue) }
}
struct Foo {
@CustomStringConversion var number = 5
}
let foo = Foo()
let number: Int = foo.number // 5
let stringRepresentation: String = foo.$number // "5"
```
But as @LeoDabus pointed out [using `LosslessStringConvertible`](https://stackoverflow.com/questions/65958622/extending-a-type-to-have-multiple-values-for-the-same-associatedtype/65960326#65960326) may be better :
```
struct example<N: Numeric & LosslessStringConvertible>: LosslessStringConvertible {
let number: N
init(number: N) {
self.number = number
}
init?(_ description: String) {
guard let number = N(description) else { return nil }
self.number = number
}
var description: String {
.init(number)
}
}
let bar = example(number: Double.greatestFiniteMagnitude) // 1.7976931348623157e+308
let baz: example<Double>? = example("1.7976931348623157e+308") // 1.7976931348623157e+308
``` | Use generic structure with Numeric protocol.
```
struct Example<T:Numeric> {
var string: String
init(number: T) {
self.string = "\(number)"
}
}
``` |
44,628,848 | I'm trying to create annotations on the MapKit from a `geoJSON` file, but the problem is that the coordinates provided by the `geoJSON` file don't match the coordinate system that `MapKit` uses.
**Question** : How do I convert *read* the geoJSON file and *convert* the coordinates from [``](http://spatialreference.org/ref/epsg/sweref99-13-30/) to `WGS84S`?
Here is an example of what the `geoJSON` file looks like:
```
{"name":"MAPADDRESSPOINT","type":"FeatureCollection"
,"crs":{"type":"name","properties":{"name":"EPSG:3008"}}
,"features":[
{"type":"Feature","geometry":{
"type":"Point","coordinates": [97973.4655999987,6219081.53249992,0]},
"properties":{
"ADDRESSAREA_resolved":"Sadelvägen",
"multi_reader_id":1,
"multi_reader_full_id":1,
"BALSTATUS_resolved":"Gällande",
"REMARKTYPE_resolved":"",
"FARMADDRESSAREA_resolved":"",
"geodb_type":"geodb_point",
"multi_reader_keyword":"GEODATABASE_SDE_2",
"DEVIATEFROMSTANDARD_resolved":"",
"geodb_feature_is_simple":"yes",
"STATUS_resolved":"Ingen information",
"ADDRESSEDCONSTRUCTIONTYPE_resolved":"",
"SUPPLIER_resolved":"",
"multi_reader_type":"GEODATABASE_SDE",
"geodb_oid":18396,
"STAIRCASEIDENTIFIER_resolved":"",
"LOCATIONADDRESSSTATUS_resolved":"Gällande",
"POSITIONKIND_resolved":"Byggnad",
"BALADDRESSTYPE_resolved":"Gatuadressplats",
"COMMENTARY":"","
DTYPE":"",
"EXTERNALID":2,"GID":"{DEEA1685-2FF3-4BEB-823D-B9FA51E09F71}",
"MODIFICATIONDATE":"20170301173751",
"MODIFICATIONSIGN":"BAL service",
"OBJECTID":18396,
"REGDATE":"20110321151134",
"REGSIGN":"BAL service",
"STATUS":0,
"ADDRESSEDCONSTRUCTIONVALUE":"",
"LABELROTATIONANGLE":0,
"POSTCODE":"25483",
"POSITIONKIND":1,
"REALPROPERTYKEY":"120320803",
"BALSTATUS":2,
"BALADDRESSTYPE":1,
"BALID":"D5650F0B-EE54-4C4C-9C40-A8162118288C",
"DESIGNATIONVALUE":"",
"SYNCDATE":"20170301173751",
"STREETNAME":"Sadelvägen",
"ADDRESSAREA":554,
"YARDSNAME":"",
"PLACENAMEID":"",
"ADDRESSLABEL":"Sadelvägen 6",
"DESIGNATIONNUMBERLETTER":"",
"LOCATIONADDRESSSTATUS":3,
"CITY":"Helsingborg",
"ENUMERATOR":"6",
"SYMBOLROTATIONANGLE":0,
"POPULARNAME":"",
"geodb_feature_dataset":"Adress"
}
}
}]
}
``` | 2017/06/19 | [
"https://Stackoverflow.com/questions/44628848",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8171709/"
] | <https://en.m.wikipedia.org/wiki/Transverse_Mercator_projection>
Longitude of natural origin 0° 00' 00.000" N
13° 30' 00.000" E
Scale factor at natural origin
1
False easting
150000
meters
False northing
0
FINAL (Playground) version
```
//: [Previous](@previous)
import Foundation
extension Double {
var rad: Double {
get {
return .pi * self / 180.0
}
}
var deg: Double {
get {
return 180.0 * self / .pi
}
}
}
// SWEREF99 13 30 (GRS80)
let φ0 = 0.0
let λ0 = 13.5.rad
let N0 = 0.0
let E0 = 150000.0
let k0 = 1.0
// GRS80
let a = k0 * 6378137.0
let b = k0 * 6356752.31414034
let n = (a - b)/(a + b)
let n2 = n * n
let n3 = n2 * n
let n4 = n3 * n
let a2 = a * a
let b2 = b * b
let e2 = (a2 - b2)/a2
let H0 = 1.0 + 1.0/4.0*n2 + 1.0/64.0*n4
let H2 = -3.0/2.0*n + 3.0/16.0*n3
let H4 = 15.0/16.0*n2 - 15.0/64.0*n4
let H6 = -35.0/48.0*n3
let H8 = 315.0/512.0*n4
let ν:(Double)->Double = { φ in
return a/(sqrt(1.0 - e2 * sin(φ) * sin(φ)))
}
let ρ:(Double)->Double = { φ in
return ν(φ) * (1.0 - e2) / (1.0 - e2 * sin(φ) * sin(φ))
}
let η2:(Double)->Double = { φ in
return ν(φ) / ρ(φ) - 1.0
}
var arcMeridian1:(Double)->Double = { φ in
let m = (a + b) / 2 * (H0 * φ + H2 * sin(2.0 * φ) + H4 * sin(4.0 * φ) + H6 * sin(6.0 * φ) + H8 * sin(8.0 * φ))
return m
}
var arcMeridian:(Double, Double)->Double = { φ1, φ2 in
return arcMeridian1(φ2) - arcMeridian1(φ1)
}
var cartografic:(Double,Double)->(Double,Double) = { φ, λ in
let νφ = ν(φ)
let ρφ = ρ(φ)
let η2φ = νφ / ρφ - 1.0
let s1 = sin(φ)
let s2 = s1 * s1
let c1 = cos(φ)
let c2 = c1 * c1
let c3 = c2 * c1
let c5 = c3 * c2
let t2 = s2/c2
let t4 = t2 * t2
let k1 = νφ * c1
let k2 = νφ/2.0 * s1 * c1
let k3 = νφ/6.0 * c3 * (νφ / ρφ - t2)
let k4 = νφ/24.0 * s1 * c3 * (5.0 - t2 + 9.0 * η2φ)
let k5 = νφ/120.0 * c5 * (5.0 - 18.0 * t2 + t4 + 14.0 * η2φ - 58.0 * t2 * η2φ)
let k6 = νφ/720.0 * s1 * c5 * (61.0 - 58.0 * t2 + t4)
let Δλ = λ - λ0
let Δλ2 = Δλ * Δλ
let Δλ3 = Δλ2 * Δλ
let Δλ4 = Δλ3 * Δλ
let Δλ5 = Δλ4 * Δλ
let Δλ6 = Δλ4 * Δλ
let N = arcMeridian(φ0,φ) + N0 + Δλ2 * k2 + Δλ4 * k4 + Δλ6 * k6
let E = E0 + Δλ * k1 + Δλ3 * k3 + Δλ5 * k5
return (N,E)
}
var geodetic:(Double,Double)->(Double,Double) = { N, E in
var φ = (N - N0) / a + φ0
var M = arcMeridian(φ0, φ)
var diff = 1.0
repeat {
φ += (N - N0 - M) / a
M = arcMeridian(φ0, φ)
diff = N - N0 - M
} while abs(diff) > 0.0000000001 // max 3 - 4 iterations
let E1 = E - E0
let E2 = E1 * E1
let E3 = E2 * E1
let E4 = E3 * E1
let E5 = E4 * E1
let E6 = E5 * E1
let E7 = E6 * E1
let νφ = ν(φ)
let νφ3 = νφ * νφ * νφ
let νφ5 = νφ3 * νφ * νφ
let νφ7 = νφ5 * νφ * νφ
let ρφ = ρ(φ)
let η2φ = νφ / ρφ - 1.0
let s1 = sin(φ)
let s2 = s1 * s1
let c1 = cos(φ)
let t1 = s1 / c1
let t2 = t1 * t1
let t4 = t2 * t2
let t6 = t4 * t2
let k1 = 1.0 / (c1 * νφ)
let k2 = t1 / (2.0 * ρφ * νφ)
let k3 = 1.0 / (6.0 * νφ3) * (νφ / ρφ + 2.0 * t2)
let k4 = (t1 / (24.0 * ρφ * νφ3)) * (5.0 + 3.0 * t2 + η2φ - 9.0 * t2 * η2φ)
let k5 = 1.0 / (120.0 * νφ5) * (5.0 + 28.0 * t2 + 24.0 * t4)
let k6 = (t1 / (720.0 * ρφ * νφ5)) * (61.0 + 90.0 * t2 + 45.0 * t4)
let k7 = (t1 / (5040.0 * ρφ * νφ7)) * (61.0 + 662.0 * t2 + 1320.0 * t4 + 720.0 * t6)
φ = φ - E2 * k2 + E4 * k4 - E6 * k6
let λ = λ0 + E1 * k1 - E3 * k3 + E5 * k5 - E7 * k7
return (φ, λ)
}
print("pecision check")
let carto0 = cartografic(55.0.rad, 12.75.rad)
print(carto0,"err:", carto0.0 - 6097487.637, carto0.1 - 102004.871)
let carto1 = cartografic(61.0.rad, 14.25.rad)
print(carto1,"err:", carto1.0 - 6765725.847, carto1.1 - 190579.995)
print()
print("given position: N 6219081.53249992, E 97973.4655999987")
let geo = geodetic(6219081.53249992, 97973.4655999987)
print("geodetic: φ =", geo.0.deg,"λ =", geo.1.deg)
//: [Next](@next)
```
prints
```
pecision check
(6097487.6372101102, 102004.87085248799) err: 0.00021011009812355 -0.000147512007970363
(6765725.8471242301, 190579.99493182387) err: 0.000124230049550533 -6.81761302985251e-05
given position: N 6219081.53249992, E 97973.4655999987
geodetic: φ = 56.0916410844269 λ = 12.6641326192406
```
position on map
[](https://i.stack.imgur.com/to2xM.jpg) | I dont understand what are you looking for exactly but what I would do (since you are using swift) is create an extension of MKPointAnnotation and add a new initialiser that takes the geoJSON, parse it, fetch the coordinates (and whatever data you intend to put in the annotation object) and return a MKPointAnnotation with the required data.
just incase you dont know how to parse a JSON here s an example :
```
do {
let dictionary = try JSONSerialization.jsonObject(with: geoJSON!,
options: JSONSerialization.ReadingOptions.mutableContainers) as! [String: AnyObject]
let features = dictionary["features"] as! [[String:AnyObject]]
let geometry = features[0]["geometry"] as! [String: AnyObject]
....
}catch{
//incase the json doesnt get parsed
}
```
keep going until you reach the coordinates ..;
obviously dont use force cast incase you are hesitate about a value instead use guard or if let .... |
12,220,650 | I have a very odd problem related to the Portland Group FORTRAN 90 compiler. I am trying to run a code that *relies* on array overflow to work properly. *I did not write this code!* The originators had to compile it with the flag "-tp=piii" to force the compiler to refrain from optimizations that defeated the array overflow. I guess the idea is that compilers written for the old P3 were too primitive to do this sort of thing. Now, when I try to do the same thing, I get the message "pgf90-Fatal --tp piii is not supported in this installation." So I can't do the same thing.
So: Does pgf90 in its default operation defeat the sort of array overflow the code needs? The people I am working with obviously think it does. And, if it does, could there be some other flag(s) I could use to get what I need from the "-tp=piii" flag?
Bet you never thought you would get a question like this! Just think how *I* feel. And yes, I will be re-writing it as soon as I can convince my keepers to let me do it. | 2012/08/31 | [
"https://Stackoverflow.com/questions/12220650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1380285/"
] | I'm no longer familiar with the PGI compiler and don't have its documentation to hand so can't guide you directly to the compiler option you want, but it will be indexed under something like *array bounds* or *bounds checking*.
Until Fortran 90 it was common practice to write code which ignored, or was ignorant of, array bounds. Much of the code that was written that way is still out in the wild and I (like most Fortran programmers) come across it regularly. Sadly (that's argumentative) so is the attitude that it is an acceptable way to write code; if I meet the attitude out in the wild I terminate it with extreme prejudice.
Rant over ... it is the default behaviour of at least some of the Fortran compilers currently in widespread use to not automatically generate code which, at run-time, has a tantrum when the program steps outside an array's boundaries. However, all of them will have an option to generate code which does include bounds checking at run-time.
Not checking array bounds at run time generally means faster code and most Fortran users are very interested in faster code which goes some way to explaining the default behaviour of compilers.
So, to conclude, you shouldn't have too much trouble reproducing the required behaviour of the code you've inherited. I'll be a little surprised if the PGI compiler doesn't default to not checking array bounds; but it will definitely have an option for switching the feature on or off. | Just in case anyone ever runs into the same problem with the "piii" flag, recent PGI compilers do support this flag .... if you have the 32-bit libraries installed. And, as it turns out, I do not. |
4,043 | Has anyone created a twitter like app in Sharepoint 2007? Would really like to know about your ideas and suggestions. | 2010/07/15 | [
"https://sharepoint.stackexchange.com/questions/4043",
"https://sharepoint.stackexchange.com",
"https://sharepoint.stackexchange.com/users/-1/"
] | There are a few options for you.
Michael Gannotti has this point on how to do it simply with a content editor web part and some javascript:
<http://sharepoint.microsoft.com/blogs/mikeg/Lists/Posts/Post.aspx?ID=1202>
Aidan Garnish has a solution here:
<http://aidangarnish.net/blog/post/2009/02/Twitter-SharePoint-web-part.aspx>
There's a CodePlex project called SharePointTwitter here:
<http://sharepointtwitter.codeplex.com/>
And if you just want to search twitter there's a web part here:
<http://www.mattjimison.com/blog/2009/03/04/twitter-search-webpart/>
Hope that helps! | Check out this [Team Status](http://community.zevenseas.com/Blogs/Daniel/archive/2009/05/09/release-version-of-our-%e2%80%9cassembly-free%e2%80%9d-team-status-template.aspx) solution from Zevenseas. |
4,043 | Has anyone created a twitter like app in Sharepoint 2007? Would really like to know about your ideas and suggestions. | 2010/07/15 | [
"https://sharepoint.stackexchange.com/questions/4043",
"https://sharepoint.stackexchange.com",
"https://sharepoint.stackexchange.com/users/-1/"
] | There are a few options for you.
Michael Gannotti has this point on how to do it simply with a content editor web part and some javascript:
<http://sharepoint.microsoft.com/blogs/mikeg/Lists/Posts/Post.aspx?ID=1202>
Aidan Garnish has a solution here:
<http://aidangarnish.net/blog/post/2009/02/Twitter-SharePoint-web-part.aspx>
There's a CodePlex project called SharePointTwitter here:
<http://sharepointtwitter.codeplex.com/>
And if you just want to search twitter there's a web part here:
<http://www.mattjimison.com/blog/2009/03/04/twitter-search-webpart/>
Hope that helps! | Have a look at [Yammer for SharePoint](http://blog.yammer.com/blog/2010/06/yammer-introduces-microsoft-sharepoint-2007-integration.html). |
4,043 | Has anyone created a twitter like app in Sharepoint 2007? Would really like to know about your ideas and suggestions. | 2010/07/15 | [
"https://sharepoint.stackexchange.com/questions/4043",
"https://sharepoint.stackexchange.com",
"https://sharepoint.stackexchange.com/users/-1/"
] | There are a few options for you.
Michael Gannotti has this point on how to do it simply with a content editor web part and some javascript:
<http://sharepoint.microsoft.com/blogs/mikeg/Lists/Posts/Post.aspx?ID=1202>
Aidan Garnish has a solution here:
<http://aidangarnish.net/blog/post/2009/02/Twitter-SharePoint-web-part.aspx>
There's a CodePlex project called SharePointTwitter here:
<http://sharepointtwitter.codeplex.com/>
And if you just want to search twitter there's a web part here:
<http://www.mattjimison.com/blog/2009/03/04/twitter-search-webpart/>
Hope that helps! | Check this
<http://tweetpart.codeplex.com/> |
14,613,498 | See demo: [jsFiddle](http://jsfiddle.net/bVyW5/)
* I have a simple form that is being toggled when clicking 'show' / 'cancel'
* Everything works fine, but **if you click 'cancel' shortly after the form is revealed, there's a good 2-3 seconds lag before the animation even begins**.
* This doesn't happen if you wait a few seconds before clicking 'cancel'.
* The lag occures in all tested browsers (ie, ff, chrome).
**1. What could cause this lag and how can it be prevented?**
**2. Is there a better way of coding this sequence of animations, that might prevent any lags?**
**HTML**:
```
<div id="newResFormWrap">
<form id="newResForm" action="" method="post" name="newRes">
<div id="newResFormCont">
<h3>title</h3>
<p>form!</p>
<div class="button" id="cancelNewRes">Cancel</div>
</div>
</form>
</div>
<div class="button" id="addRes">show</div>
```
**jQuery:**
```
$("#newResForm").css({opacity: 0});
$("#addRes").click(function () {
toggleNewRes()
});
$("#cancelNewRes").click(function () {
toggleNewRes()
});
//toggleNewRes
function toggleNewRes() {
if ($("#newResFormWrap").css('display') == "none") {//if hidden
$("#addRes").animate({ opacity: 0 }, 'fast', function() {
$("#newResFormWrap").toggle('fast', function (){
$("#newResForm").animate({ opacity: 100 },2000);
});
});
} else { //if visible
$("#newResForm").animate({ opacity: 0 }, 100,function() {
$("#newResFormWrap").toggle('fast', function (){
$("#addRes").animate({ opacity: 100 });
});
});
}
}
``` | 2013/01/30 | [
"https://Stackoverflow.com/questions/14613498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/806061/"
] | Make sure to clear the queue when starting a new animation with `stop()`:
```
$("#newResForm").stop().animate({ opacity: 0 }, 100,function() {
$("#newResFormWrap").toggle('fast', function (){
$("#addRes").animate({ opacity: 100 });
// ...
```
What's causing the lag is the fact that your long 2-second animation `$("#newResForm").animate({ opacity: 100 },2000)` isn't finished yet. JQuery puts animations by default into a queue, waiting for one to finish before the next begins. You clear the queue with `stop()`, which is especially useful if you have two contradicting animations (like an open and close animation, or a mouseover/mouseout animation). In fact you might find it a good practice to begin all your animation chains with `stop()` unless you know you want them to queue with prior animations that may have occurred elsewhere.
Getting into more advanced topics, you can even name different queues, so that for example your hover animations and your expand/collapse animations are treated separately for the purposes of `stop()`. See the `queue` option (when given a string) at <http://api.jquery.com/animate/> for more details. | Add `.stop()` before your animate calls:
```
function toggleNewRes() {
if ($("#newResFormWrap").css('display') == "none") {//if hidden
$("#addRes").stop().animate({ opacity: 0 }, 'fast', function() {
/...
});
} else { //if visible
$("#newResForm").stop().animate({ opacity: 0 }, 100,function() {
/...
});
}
}
``` |
14,613,498 | See demo: [jsFiddle](http://jsfiddle.net/bVyW5/)
* I have a simple form that is being toggled when clicking 'show' / 'cancel'
* Everything works fine, but **if you click 'cancel' shortly after the form is revealed, there's a good 2-3 seconds lag before the animation even begins**.
* This doesn't happen if you wait a few seconds before clicking 'cancel'.
* The lag occures in all tested browsers (ie, ff, chrome).
**1. What could cause this lag and how can it be prevented?**
**2. Is there a better way of coding this sequence of animations, that might prevent any lags?**
**HTML**:
```
<div id="newResFormWrap">
<form id="newResForm" action="" method="post" name="newRes">
<div id="newResFormCont">
<h3>title</h3>
<p>form!</p>
<div class="button" id="cancelNewRes">Cancel</div>
</div>
</form>
</div>
<div class="button" id="addRes">show</div>
```
**jQuery:**
```
$("#newResForm").css({opacity: 0});
$("#addRes").click(function () {
toggleNewRes()
});
$("#cancelNewRes").click(function () {
toggleNewRes()
});
//toggleNewRes
function toggleNewRes() {
if ($("#newResFormWrap").css('display') == "none") {//if hidden
$("#addRes").animate({ opacity: 0 }, 'fast', function() {
$("#newResFormWrap").toggle('fast', function (){
$("#newResForm").animate({ opacity: 100 },2000);
});
});
} else { //if visible
$("#newResForm").animate({ opacity: 0 }, 100,function() {
$("#newResFormWrap").toggle('fast', function (){
$("#addRes").animate({ opacity: 100 });
});
});
}
}
``` | 2013/01/30 | [
"https://Stackoverflow.com/questions/14613498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/806061/"
] | Make sure to clear the queue when starting a new animation with `stop()`:
```
$("#newResForm").stop().animate({ opacity: 0 }, 100,function() {
$("#newResFormWrap").toggle('fast', function (){
$("#addRes").animate({ opacity: 100 });
// ...
```
What's causing the lag is the fact that your long 2-second animation `$("#newResForm").animate({ opacity: 100 },2000)` isn't finished yet. JQuery puts animations by default into a queue, waiting for one to finish before the next begins. You clear the queue with `stop()`, which is especially useful if you have two contradicting animations (like an open and close animation, or a mouseover/mouseout animation). In fact you might find it a good practice to begin all your animation chains with `stop()` unless you know you want them to queue with prior animations that may have occurred elsewhere.
Getting into more advanced topics, you can even name different queues, so that for example your hover animations and your expand/collapse animations are treated separately for the purposes of `stop()`. See the `queue` option (when given a string) at <http://api.jquery.com/animate/> for more details. | Try to use `stop()` :
[Here is jsfiddle.](http://jsfiddle.net/t7mWs/2/)
```
if ($("#newResFormWrap").is(':visible')) {//this way is eaiser to check
$("#addRes").stop(true,false).animate({ opacity: 0 }, 'fast', function() {
$("#newResFormWrap").toggle('fast', function (){
$("#newResForm").animate({ opacity: 100 },2000);
});
});
}
``` |
14,613,498 | See demo: [jsFiddle](http://jsfiddle.net/bVyW5/)
* I have a simple form that is being toggled when clicking 'show' / 'cancel'
* Everything works fine, but **if you click 'cancel' shortly after the form is revealed, there's a good 2-3 seconds lag before the animation even begins**.
* This doesn't happen if you wait a few seconds before clicking 'cancel'.
* The lag occures in all tested browsers (ie, ff, chrome).
**1. What could cause this lag and how can it be prevented?**
**2. Is there a better way of coding this sequence of animations, that might prevent any lags?**
**HTML**:
```
<div id="newResFormWrap">
<form id="newResForm" action="" method="post" name="newRes">
<div id="newResFormCont">
<h3>title</h3>
<p>form!</p>
<div class="button" id="cancelNewRes">Cancel</div>
</div>
</form>
</div>
<div class="button" id="addRes">show</div>
```
**jQuery:**
```
$("#newResForm").css({opacity: 0});
$("#addRes").click(function () {
toggleNewRes()
});
$("#cancelNewRes").click(function () {
toggleNewRes()
});
//toggleNewRes
function toggleNewRes() {
if ($("#newResFormWrap").css('display') == "none") {//if hidden
$("#addRes").animate({ opacity: 0 }, 'fast', function() {
$("#newResFormWrap").toggle('fast', function (){
$("#newResForm").animate({ opacity: 100 },2000);
});
});
} else { //if visible
$("#newResForm").animate({ opacity: 0 }, 100,function() {
$("#newResFormWrap").toggle('fast', function (){
$("#addRes").animate({ opacity: 100 });
});
});
}
}
``` | 2013/01/30 | [
"https://Stackoverflow.com/questions/14613498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/806061/"
] | Make sure to clear the queue when starting a new animation with `stop()`:
```
$("#newResForm").stop().animate({ opacity: 0 }, 100,function() {
$("#newResFormWrap").toggle('fast', function (){
$("#addRes").animate({ opacity: 100 });
// ...
```
What's causing the lag is the fact that your long 2-second animation `$("#newResForm").animate({ opacity: 100 },2000)` isn't finished yet. JQuery puts animations by default into a queue, waiting for one to finish before the next begins. You clear the queue with `stop()`, which is especially useful if you have two contradicting animations (like an open and close animation, or a mouseover/mouseout animation). In fact you might find it a good practice to begin all your animation chains with `stop()` unless you know you want them to queue with prior animations that may have occurred elsewhere.
Getting into more advanced topics, you can even name different queues, so that for example your hover animations and your expand/collapse animations are treated separately for the purposes of `stop()`. See the `queue` option (when given a string) at <http://api.jquery.com/animate/> for more details. | Couple of things. First check out this [JSFiddle](http://jsfiddle.net/bVyW5/1/) to see it in action.
The problem you have is that your fade in animation takes 2 seconds. So when you close it within 2 seconds you experience a delay.
I recalibrated your timings to ensure there are no delay. See if you like them and feel free to change them as you like.
```
if ($("#newResFormWrap").css('display') == "none") {//if hidden
$("#addRes").animate({ opacity: 0 }, 'fast', function() {
$("#newResFormWrap").toggle(0, function (){
$("#newResForm").animate({ opacity: 100 },400);
});
});
} else { //if visible
console.log('click');
$("#newResForm").animate({ opacity: 0 }, 0, function() {
console.log('animated');
$("#newResFormWrap").toggle(0)
});
$("#addRes").animate({ opacity: 100 }, 'fast');
}
``` |
1,602,055 | Given a set $X$ and a family $\mathcal{S}$ of subsets of $X$, prove that there exists a topology $\mathcal{T}(\mathcal{S})$ on $X$ which contains $\mathcal{S}$ and is the smallest with this property (Hint: use the axioms to see what other subsets of $X$, besides the ones from $\mathcal{S}$, must $\mathcal{T}(\mathcal{S})$ contain.)
I checked the axioms of a topology and I think the other subset $\mathcal{T}(\mathcal{S})$ has to contain is $X$ (for the first axiom). Is this correct? and why is this the smallest topology? How do I prove that? | 2016/01/06 | [
"https://math.stackexchange.com/questions/1602055",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/294640/"
] | The "smallest" topology $\mathcal{T}(S)$ is the topology such that if $T'$ is any other topology containing the subsets in the collection $S$, then $\mathcal{T}(S) \subseteq T'$.
As the other answerers have pointed out, consider taking every topology on the set $X$ which contains all of the sets in $S$, and then take the intersection of all of those topologies. We get another topology! To show this:
Consider $(\mathcal{T}\_{i})\_{i \in I}$ to be the collection of topologies on $X$ in which each topology $\mathcal{T}\_{i}$ contains the sets in $S$. We are interested in three things:
1. **Is this intersection non-empty?** Yes! Since the power set of $X$, $\mathcal{P}(X)$ is a topology which contains every set in the collection $S$, and also since the set $X$ is an element of every topology, the intersection of the topologies is non-empty.
2. **Is the intersection a topology?** Yes! You should prove this (it's very easy). Suppose $\mathcal{T}\_{i}$ is a topology for each $i \in I$. Suppose the intersection $\cap\_{i \in I} \mathcal{T}\_{i}$ is non-empty. Then this intersection is also a topology. Prove it.
3. **Once we establish that for the topologies $\mathcal{T}\_{i}$ that contain the collection $S$, $\cap\_{i \in I} \mathcal{T}\_{i}$ is a topology, then we want to know if this topology contains the collection $S$. Does it?** Yes! Why?
4. **Finally, do we have that $\cap\_{i \in I} \mathcal{T}\_{i} \subseteq T$ for any topology $T$ which contains the collection of sets $S$?** Yes! Why? | The intersection of an arbitrary non-empty family of topologies containing $\mathcal{S}$ is still a topology. In this case the family is non-empty, indeed it contains the power set of $X$. |
20,604,093 | I am stuck with a problem installing Qt5 on OSX.
The [Qt Requirements for Mac OSX](http://qt-project.org/doc/qt-5.0/qtdoc/requirements-mac.html) are done - Xcode and command line are installed. Then I followed the steps:
```
# mkdir qt5
# cd qt5
# git clone git://gitorious.org/qt/qtbase.git
# cd qt5
# ./configure
The test for linking against libxcb and support libraries failed!
You might need to install dependency packages, or pass -qt-xcb.
```
Then I also tried
```
# cd qtbase
# ./configure -prefix $HOME/development/macosx/qt5 -nomake docs -nomake examples -nomake demos -nomake tests -opensource -confirm-license -release -no-c++11
Unknown part docs passed to -nomake.
# ./configure
The test for linking against libxcb and support libraries failed!
You might need to install dependency packages, or pass -qt-xcb.
```
Some other links on related problems are:
* ["Failed to load platform plugin "xcb" " while launching qt5 app on linux without qt installed](https://stackoverflow.com/questions/17106315/failed-to-load-platform-plugin-xcb-while-launching-qt5-app-on-linux-without)
* [Qt5 installation problems](https://stackoverflow.com/questions/14424158/qt5-installation-problems)
Then [Xquartz](http://xquartz.macosforge.org/landing/) was also installed, supposing that the problem is because X11 is missing on OSX Mountain Lion, restarted the computer and tried the installation again. It didn't solved the problem a bit.
On Linux Qt5 installation was nice with no hustle. But on OSX it doesn't work.
I hope someone can give any suggestions. | 2013/12/16 | [
"https://Stackoverflow.com/questions/20604093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/194990/"
] | I just encountered this same problem myself, and I worked around it by specifying the argument -no-xcb (instead of -qt-xcb) to the configure script. That allowed the compilation of the Qt libraries to complete (although some of the Qt example programs failed to compile... but it was enough to get me back on track for now).
I suspect this is a Mavericks-specific problem, as the same Qt source tarball (qt-everywhere-enterprise-5.2.0-src.tar.gz) compiled fine with the normal configure invocation under Mountain Lion. | This is nothing to do with Mavericks.
You have MacPorts or something similar in your PATH. The configure script detects X-Windows and therefor tries to configure the xcb backend.
Reset your PATH to a minimal one before compile:
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
That will solve the issue. |
30,373 | 
Plant :Alstonia
Appearance:Blisters (gall) on both sides,cutting galls leaves white fluid.
After some time holes apppears in the blisters.so it seems some insect laid eggs.
What kind of disease is this? It seems to be some kind of blisters on the leaves of a decorative plant.
I'm guessing some insect laid eggs in it for eggs nourishment.
Would you please identify them and tell me how to treat them? | 2017/01/03 | [
"https://gardening.stackexchange.com/questions/30373",
"https://gardening.stackexchange.com",
"https://gardening.stackexchange.com/users/16473/"
] | Alstonia scholaris (L.) R. Br. is a very beautiful ornamental tree, which is commonly known as pagoda tree because of its pagoda like growing habit. It is commonly infected by the Homopteran, Pauropsylla tuberculata Crawf which leads to unsightly gall formation on the leaves as pictured.
The gall is the leaf response to the infection by the parasite which in turn sustains the growing insect. If there is a hole in the gall, the insect has likely already left.
<https://www.cabdirect.org/cabdirect/abstract/20083091676> | I agree, leaf galls. Looks like a Rhododendron regardless, @Atul, need you to take a razor blade and slice through a 'gall' to see if the insect is still there. Take a picture. I would right now cut that infected branch off. This is usually not a death sentence! But before 'trying' any treatment we need to know what that insect is...or virus or bacteria but I am guessing insect. Later, Atul, lets talk about soil improvement. Plants that are stressed by poor environmental conditions are far more susceptible to insect or disease damage. Gaggy soil.
[leaf galls](https://www.google.com/imgres?imgurl=http%3A%2F%2Fcached.imagescaler.hbpl.co.uk%2Fresize%2FscaleWidth%2F620%2Fofflinehbpl.hbpl.co.uk%2Fnews%2FWOH%2F23_GallMiteDamageJuglansDoveAss_rt-2014052812345637.gif&imgrefurl=http%3A%2F%2Falfa-img.com%2Fshow%2Fpetunia-pests-and-diseases.html&docid=P8KDOQSHa9_SoM&tbnid=ylcP9Q2NYaeoiM%3A&vet=1&w=500&h=333&bih=735&biw=1455&q=rhododendron%20leaf%20gall&ved=0ahUKEwjIgtPtsKfRAhUC62MKHbs7ATAQMwgaKAAwAA&iact=mrc&uact=8) - [leaf gall](https://www.google.com/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=0ahUKEwi_0JX8s6fRAhVH5mMKHcv4BocQjRwIBw&url=https%3A%2F%2Fentomologytoday.org%2F2015%2F06%2F11%2Fgalls-insects-behind-the-weird-growths-on-plants%2F&bvm=bv.142059868,d.cGc&psig=AFQjCNEx9BzQ8XVmHHJJEzogJlDcSmEJig&ust=1483582004236157) |
25,390,936 | Not sure if I should use a regex, and if so which, but I'm using SQL (Sequel Pro)
For a particular instance in a table (about 200 columns) I want to remove everything that precedes the year (such as for 3/13/2012 I want to remove 3/13/ ). Some entries only have a year, and some have the month and day preceding the year.
How can I remove the month and day without removing the year in SQL? | 2014/08/19 | [
"https://Stackoverflow.com/questions/25390936",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3597867/"
] | Try this:
```
SELECT DATEPART(YEAR,CONVERT(DATE,{Your Column Name Here}))
``` | You may try like this in MYSQL
```
SELECT YEAR(STR_TO_DATE(datecolumn, "%m/%d/%Y")) from table
```
and in SQL SERVER
```
SELECT YEAR(datecolumn) AS Date
FROM table
``` |
56,007,622 | In this problem, I am trying to understand when an alert should be generated based on 'value'.
If previous 5 values are above 10, then an alert is created. The alert continues to stay active till the value goes below 7.5. Now, once the alert is no longer active and it reaches a stage where previous 5 values are above 10, then an alert is created again.
Here is the logic I am using to do this:
```
NUM_PREV_ROWS = 5
PREV_5_THRESHOLD = 10.0
PREV_THRESHOLD = 7.5
d = {'device': ['a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a',
'a','a','a','a','a','b','b','b','b','b',
'b','b','b','b','b','b','b','b','b','b','b','b','b','b','b','b','b'] ,
'value': [11,11,11,11,11,11,11,8,9,11,11,11,11,11,8,9,6,11,11,11,11,11,11,11,11,11,11,11,11,8,9,11,11,11,11,11,8,9,6,11,11,11,11,11]}
df = pd.DataFrame(data=d)
df['prev>10'] = df['value']>PREV_5_THRESHOLD
df['prev5>10'] = df['prev>10'].rolling(NUM_PREV_ROWS).sum()
df['prev>7.5'] = df['value']>PREV_THRESHOLD
alert = False
alert_series = []
for row in df.iterrows():
if row[1]['prev5>10']==NUM_PREV_ROWS:
alert = True
if row[1]['prev>7.5']==False:
alert = False
alert_series.append(alert)
df['alert'] = alert_series
```
The problem is that the loop should restart when a new device is encountered (in this case, it should first run for A and then run over B once it comes across that device). How can I do this?
This is the output with current logic:
```
print(df)
value prev>10 prev5>10 prev>7.5 alert
a 11 True NaN True False
a 11 True NaN True False
a 11 True NaN True False
a 11 True NaN True False
a 11 True 5.0 True True
a 11 True 5.0 True True
a 11 True 5.0 True True
a 8 False 4.0 True True
a 9 False 3.0 True True
a 11 True 3.0 True True
a 11 True 3.0 True True
a 11 True 3.0 True True
a 11 True 4.0 True True
a 11 True 5.0 True True
a 8 False 4.0 True True
a 9 False 3.0 True True
a 6 False 2.0 False False
a 11 True 2.0 True False
a 11 True 2.0 True False
a 11 True 3.0 True False
a 11 True 4.0 True False
a 11 True 5.0 True True
b 11 True 5.0 True True
b 11 True 5.0 True True
b 11 True 5.0 True True
b 11 True 5.0 True True
b 11 True 5.0 True True
b 11 True 5.0 True True
b 11 True 5.0 True True
b 8 False 4.0 True True
b 9 False 3.0 True True
b 11 True 3.0 True True
b 11 True 3.0 True True
b 11 True 3.0 True True
b 11 True 4.0 True True
b 11 True 5.0 True True
b 8 False 4.0 True True
b 9 False 3.0 True True
b 6 False 2.0 False False
b 11 True 2.0 True False
b 11 True 2.0 True False
b 11 True 3.0 True False
b 11 True 4.0 True False
b 11 True 5.0 True True
```
Appreciate all the help! | 2019/05/06 | [
"https://Stackoverflow.com/questions/56007622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11035965/"
] | There's a [chapter on Scheduling in the Airflow documentation](https://airflow.apache.org/scheduler.html#scheduling-triggers), which states:
>
> Note that if you run a DAG on a schedule\_interval of one day, the run stamped 2016-01-01 will be trigger soon after 2016-01-01T23:59. In other words, the job instance is started once the period it covers has ended.
>
>
> **Let’s Repeat That** The scheduler runs your job one schedule\_interval AFTER the start date, at the END of the period.
>
>
>
You are experiencing exactly this: today (2019-05-06) a DagRun is created for the latest "completed" interval, meaning the week starting on 2019-04-29.
Thinking about it like this might help: if you want to process some data periodically, you need to start processing it *after* the data is ready for that period. | Airflow schedule a dag at the ending of each interval with execution time as the starting of that interval. So usually **execution\_time=schedule\_time-interval**.
For example, in your dag, the last interval was 2019-04-29T14:00:00 to 2019-05-06T14:00:00 and its execution only get scheduled on 2019-05-06T14:00:00 with execution time as 2019-04-29T14:00:00. It is the usual working of airflow. It's not sure how your dag did run with 2019-04-29T14:00:00 before MAY 6th 2 PM, as you mentioned in your question. Maybe you changed the dag interval or made a manual trigger. |
203,266 | I need another excuse of "I was very busy" as people became tired of hearing it. So, I thought of expressing the idea of having a very restricted/limited time for all the tasks that I have been assigned to do and therefore I couldn't completely finish this specific one. The thing is I can't get my hands on a suitable phrase.
I guess it would be something like:
>
> I wasn't able to finish it as I **got pretty restricted** in time.
>
>
>
Is it correct? Can I achieve that meaning better?
It is not necessary to be formal, but I don't want it to be too informal. | 2019/03/31 | [
"https://ell.stackexchange.com/questions/203266",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/80554/"
] | There are some other good suggestions here. I might also use:
>
> I got caught up with other work.
>
>
> I got caught up in other work.
>
>
>
Either of these means that you were very busy or “tangled up” with other work- like you couldn’t escape the trap of the work, so to speak.
EDIT: Sorry, I should have also addressed your own suggestion -
>
> I got pretty restricted in time.
>
>
>
I would not say that, even if the meaning might be understood. The phrasing is awkward - it would sound better to say
>
> My time was restricted.
>
>
>
if you were to use the word *restricted*. *Restricted* is something that *is*, not something that is *gotten*, generally speaking.
Also, *restricted* is often used to indicate some specific enforced limit, like "Access was restricted to authorized users", or "My time was restricted to three hours". I think in this case the word doesn't completely fit if nobody was actually forcing you to only spend a certain amount of time on this particular task. I daresay it might come off as rude to tell someone the time you had for this task was *restricted*; they might think you set a limit on the time you were going to spend on it because you didn't think it was that important. | **Get around to**
*phrasal verb of get*
**deal with (a task) in due course.**
**to do something that you have intended to do for a long time**
>
> I didn't **get around to** putting all the photos in frames.
>
>
> I couldn't **get around to** finishing it on time.
>
>
> I intended to tidy the flat at the weekend, but I didn't **get round to** it.
>
>
> It's been at the back of my mind to call José for several days now, but I haven't **got round to** it yet.
>
>
> He never did **get around to** putting up the shelves.
>
>
> After weeks of putting it off, she finally **got around to** painting the bedroom.
>
>
> Did you **get round to** doing the shopping?
>
>
>
---
**to be tied up**
**to be very busy and unable to speak to anyone, go anywhere, etc:**
**Fig. busy.**
>
> How long will you be **tied up**? I will be **tied up** in a meeting for an
> hour.
>
>
> I was **tied up** and couldn’t get to the phone.
>
>
> He's **tied up** with his new book. He's working hard, you know.
>
>
>
---
**To have too much on plate**
**to be too busy.**
>
> I'm sorry, I just **have too much on my plate** right now. If you have
> **too much on your plate**, can I help?
>
>
>
---
**You could've said:**
>
> I wasn't able to finish it, because I **had too much on my plate.**
>
>
>
or
>
> I wasn't able to finish, because I was a little **tied up**.
>
>
>
or
>
> I couldn't **get around** to it.
>
>
> |
203,266 | I need another excuse of "I was very busy" as people became tired of hearing it. So, I thought of expressing the idea of having a very restricted/limited time for all the tasks that I have been assigned to do and therefore I couldn't completely finish this specific one. The thing is I can't get my hands on a suitable phrase.
I guess it would be something like:
>
> I wasn't able to finish it as I **got pretty restricted** in time.
>
>
>
Is it correct? Can I achieve that meaning better?
It is not necessary to be formal, but I don't want it to be too informal. | 2019/03/31 | [
"https://ell.stackexchange.com/questions/203266",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/80554/"
] | There are some other good suggestions here. I might also use:
>
> I got caught up with other work.
>
>
> I got caught up in other work.
>
>
>
Either of these means that you were very busy or “tangled up” with other work- like you couldn’t escape the trap of the work, so to speak.
EDIT: Sorry, I should have also addressed your own suggestion -
>
> I got pretty restricted in time.
>
>
>
I would not say that, even if the meaning might be understood. The phrasing is awkward - it would sound better to say
>
> My time was restricted.
>
>
>
if you were to use the word *restricted*. *Restricted* is something that *is*, not something that is *gotten*, generally speaking.
Also, *restricted* is often used to indicate some specific enforced limit, like "Access was restricted to authorized users", or "My time was restricted to three hours". I think in this case the word doesn't completely fit if nobody was actually forcing you to only spend a certain amount of time on this particular task. I daresay it might come off as rude to tell someone the time you had for this task was *restricted*; they might think you set a limit on the time you were going to spend on it because you didn't think it was that important. | Suggestions:
I wasn't able to do it because I ran out of time.
There wasn't enough time to do everything I needed to do.
I didn't have sufficient time to do everything. |
18,772,414 | I am working on open-source project on github, and I cloned a the project by doing
`git clone [email protected]:project.git`
Now, All works fine, I can run the project and working on it. But this was a master branch, and now
someone has created a branch called `user_interface` and added some basic HTML, now I need to pull this `user_interface` and merge it to my local working file, so I can immediately start using these additional features from that user. But, the problem is specifying how to explicitly call call that branch `user_interface` and merge it to my local copy.
So far, I tried only `git pull`, but it pulls the original data and merges it to my local directory, so I end up with the same copy I got the last time. | 2013/09/12 | [
"https://Stackoverflow.com/questions/18772414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Apparently egrep doesn't support `{m,n}` repeat syntax:
```
$ egrep -i '((\w)\2)((\w)\4)((\w)\6)' words
bookkeeper
bookkeeping
subbookkeeper
$ egrep -i '((\w)\2)((\w)\4)((\w)\6)((\w)\8)' words
subbookkeeper
```
If you spell out the groups, it works.
This is on my Mac. | Your regex is correct and there is not a bug. `/usr/share/dict/words` does not contain the word "subbookkeeper". |
18,772,414 | I am working on open-source project on github, and I cloned a the project by doing
`git clone [email protected]:project.git`
Now, All works fine, I can run the project and working on it. But this was a master branch, and now
someone has created a branch called `user_interface` and added some basic HTML, now I need to pull this `user_interface` and merge it to my local working file, so I can immediately start using these additional features from that user. But, the problem is specifying how to explicitly call call that branch `user_interface` and merge it to my local copy.
So far, I tried only `git pull`, but it pulls the original data and merges it to my local directory, so I end up with the same copy I got the last time. | 2013/09/12 | [
"https://Stackoverflow.com/questions/18772414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The problem seems to be that egrep is not resetting captured groups on repeats. Not sure if this is a bug or just ambiguity in what the notation implies. If you manually repeat then it should work:
```
egrep -i "(\w)\1(\w)\2(\w)\3(\w)\4" /usr/share/dict/words
```
However, it is strange that this does not work. This does work in perl:
```
perl -lne "print if /((\w)\2){3}/" /usr/share/dict/words
```
BTW, egrep does support {m,n} syntax. This proves that:
```
egrep -i "a{2}" /usr/share/dict/words
``` | Your regex is correct and there is not a bug. `/usr/share/dict/words` does not contain the word "subbookkeeper". |
18,772,414 | I am working on open-source project on github, and I cloned a the project by doing
`git clone [email protected]:project.git`
Now, All works fine, I can run the project and working on it. But this was a master branch, and now
someone has created a branch called `user_interface` and added some basic HTML, now I need to pull this `user_interface` and merge it to my local working file, so I can immediately start using these additional features from that user. But, the problem is specifying how to explicitly call call that branch `user_interface` and merge it to my local copy.
So far, I tried only `git pull`, but it pulls the original data and merges it to my local directory, so I end up with the same copy I got the last time. | 2013/09/12 | [
"https://Stackoverflow.com/questions/18772414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Apparently egrep doesn't support `{m,n}` repeat syntax:
```
$ egrep -i '((\w)\2)((\w)\4)((\w)\6)' words
bookkeeper
bookkeeping
subbookkeeper
$ egrep -i '((\w)\2)((\w)\4)((\w)\6)((\w)\8)' words
subbookkeeper
```
If you spell out the groups, it works.
This is on my Mac. | On my freebsd system it did find match
```
[vaibhavc@freebsd-vai ~]$ cat acb
subbookkeeper
[vaibhavc@freebsd-vai ~]$ egrep "((\w)\2){4,}" -i acb
subbookkeeper
``` |
18,772,414 | I am working on open-source project on github, and I cloned a the project by doing
`git clone [email protected]:project.git`
Now, All works fine, I can run the project and working on it. But this was a master branch, and now
someone has created a branch called `user_interface` and added some basic HTML, now I need to pull this `user_interface` and merge it to my local working file, so I can immediately start using these additional features from that user. But, the problem is specifying how to explicitly call call that branch `user_interface` and merge it to my local copy.
So far, I tried only `git pull`, but it pulls the original data and merges it to my local directory, so I end up with the same copy I got the last time. | 2013/09/12 | [
"https://Stackoverflow.com/questions/18772414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The problem seems to be that egrep is not resetting captured groups on repeats. Not sure if this is a bug or just ambiguity in what the notation implies. If you manually repeat then it should work:
```
egrep -i "(\w)\1(\w)\2(\w)\3(\w)\4" /usr/share/dict/words
```
However, it is strange that this does not work. This does work in perl:
```
perl -lne "print if /((\w)\2){3}/" /usr/share/dict/words
```
BTW, egrep does support {m,n} syntax. This proves that:
```
egrep -i "a{2}" /usr/share/dict/words
``` | On my freebsd system it did find match
```
[vaibhavc@freebsd-vai ~]$ cat acb
subbookkeeper
[vaibhavc@freebsd-vai ~]$ egrep "((\w)\2){4,}" -i acb
subbookkeeper
``` |
18,772,414 | I am working on open-source project on github, and I cloned a the project by doing
`git clone [email protected]:project.git`
Now, All works fine, I can run the project and working on it. But this was a master branch, and now
someone has created a branch called `user_interface` and added some basic HTML, now I need to pull this `user_interface` and merge it to my local working file, so I can immediately start using these additional features from that user. But, the problem is specifying how to explicitly call call that branch `user_interface` and merge it to my local copy.
So far, I tried only `git pull`, but it pulls the original data and merges it to my local directory, so I end up with the same copy I got the last time. | 2013/09/12 | [
"https://Stackoverflow.com/questions/18772414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The problem seems to be that egrep is not resetting captured groups on repeats. Not sure if this is a bug or just ambiguity in what the notation implies. If you manually repeat then it should work:
```
egrep -i "(\w)\1(\w)\2(\w)\3(\w)\4" /usr/share/dict/words
```
However, it is strange that this does not work. This does work in perl:
```
perl -lne "print if /((\w)\2){3}/" /usr/share/dict/words
```
BTW, egrep does support {m,n} syntax. This proves that:
```
egrep -i "a{2}" /usr/share/dict/words
``` | Apparently egrep doesn't support `{m,n}` repeat syntax:
```
$ egrep -i '((\w)\2)((\w)\4)((\w)\6)' words
bookkeeper
bookkeeping
subbookkeeper
$ egrep -i '((\w)\2)((\w)\4)((\w)\6)((\w)\8)' words
subbookkeeper
```
If you spell out the groups, it works.
This is on my Mac. |
233,574 | I'm moving a couple of servers to a colo and was wondering what you would recommend for a hardware firewall to sit in front of them? Is it fine to just get the cheapest Cisco/Fortigate/Juniper/whatever firewall? I don't need anything fancy, pretty much just port forwarding. | 2011/02/09 | [
"https://serverfault.com/questions/233574",
"https://serverfault.com",
"https://serverfault.com/users/546/"
] | Here's an example for some criteria you'll want to consider when selecting a firewall in the scenario you described:
1. Feature set - Make sure it'll perform your immediate and potential future purposes.
2. Performance - Co-location generally provides good network connectivity and throughput. Make sure the device you pick will handle the anticipated loads you'll be capable of.
3. Form factor - You're paying to put equipment here, the smaller the equipment, the more you can pack in.
4. Management - Some devices offer features that make remote management easier, and give you tools in the event you find yourself unable to access it.
I imagine the brand names you've mentioned would have models capable of what you're asking. Most likely it would come down to performance and management of the equipment. | You are probably looking at "wasting" at least 1U of rack space for this firewall.
I would not buy a consumer-grade cheapie firewall.
The Juniper Netscreen SSG5 would probably meet your needs, but it is a paperback size format and doesn't come with rack arms (that I recall). The first "rackable" SSG is the SSG140, but that's not quite so cheap -- definitely overkill for your application here.
If you can figure out a way to mount it neatly, the SSG5 would almost certainly be sufficient. |
233,574 | I'm moving a couple of servers to a colo and was wondering what you would recommend for a hardware firewall to sit in front of them? Is it fine to just get the cheapest Cisco/Fortigate/Juniper/whatever firewall? I don't need anything fancy, pretty much just port forwarding. | 2011/02/09 | [
"https://serverfault.com/questions/233574",
"https://serverfault.com",
"https://serverfault.com/users/546/"
] | Here's an example for some criteria you'll want to consider when selecting a firewall in the scenario you described:
1. Feature set - Make sure it'll perform your immediate and potential future purposes.
2. Performance - Co-location generally provides good network connectivity and throughput. Make sure the device you pick will handle the anticipated loads you'll be capable of.
3. Form factor - You're paying to put equipment here, the smaller the equipment, the more you can pack in.
4. Management - Some devices offer features that make remote management easier, and give you tools in the event you find yourself unable to access it.
I imagine the brand names you've mentioned would have models capable of what you're asking. Most likely it would come down to performance and management of the equipment. | Alternatively - get a Mikrotik RB1100 and see how far it lasts (50mbit for smallish packets was on the table by someone running game servers).
It is CHEAP and has a TON of features in RouterOS. Uses very little power, too.
Then later you can upgrade to something more powerfull if needed. Again, the RB1100 is CHEAP to start with. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.