qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
42,246,281 | I don't understand why the type system lets me do this?
In other words **I would expect this to crash when foo is passed to the function**.
```
var foo:String!
func someFunction(_ bar:String?) {
print("-- \(bar) --")
}
someFunction(foo)
=> writes "-- nil --"
``` | 2017/02/15 | [
"https://Stackoverflow.com/questions/42246281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/308189/"
] | As @Hamish so correctly points out here:
<https://stackoverflow.com/a/39537558/308189>
>
> If the expression can be explicitly type checked with a strong optional type, it will be. However, the type checker will fall back to forcing the optional if necessary.
>
>
>
And the comment on the answer explains why this ... | ```
// This line will create variable named foo and type of it will be String! and value of it will be nil.
// It mean i can access this variable is force-wraped so it may dangerous but uses of this variable without type checking compiler will not give any warning(ignore by compiler).
var foo:String!
// This function... |
16,216,942 | I have multiple arrays which have code string items in them. I need to match the code from a given string and then return a class name from the matched array.
Might be better if I show you what I've got. So below are the arrays and underneath this is the string I need to return if the given string matches an item fro... | 2013/04/25 | [
"https://Stackoverflow.com/questions/16216942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/391460/"
] | ```
def code_to_string(code)
if [395].include? code
"ss1"
elsif [392, 227, 179, 176].include? code
"ss2"
# and so on
end
```
Note that the codes are integers. to match with a string code, use `%w(392 227 179).include?` instead of the array | I'd recommend joining all the arrays into a multi-dimensional hash and then searching that.
```
a1 = ['395']
a2 = ['392', '227', '179', '176']
h = { a1: a1, a2: a2 }
h.select {|a, v| a if v.include?('392') }.keys.first.to_s
``` |
16,216,942 | I have multiple arrays which have code string items in them. I need to match the code from a given string and then return a class name from the matched array.
Might be better if I show you what I've got. So below are the arrays and underneath this is the string I need to return if the given string matches an item fro... | 2013/04/25 | [
"https://Stackoverflow.com/questions/16216942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/391460/"
] | The most efficient approach would be to generate a translator hash once that can perform the lookup super fast:
```
CODES = {
ss1: ['392', '227', '179', '176'],
ss2: ['389', '386'],
ss3: ['371', '338', '335'],
ss4: ['368', '350', '332', '329', '323', '185', '182']
}
translator = CODES.each_with_object({}){|(s... | I'd recommend joining all the arrays into a multi-dimensional hash and then searching that.
```
a1 = ['395']
a2 = ['392', '227', '179', '176']
h = { a1: a1, a2: a2 }
h.select {|a, v| a if v.include?('392') }.keys.first.to_s
``` |
16,216,942 | I have multiple arrays which have code string items in them. I need to match the code from a given string and then return a class name from the matched array.
Might be better if I show you what I've got. So below are the arrays and underneath this is the string I need to return if the given string matches an item fro... | 2013/04/25 | [
"https://Stackoverflow.com/questions/16216942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/391460/"
] | ```
def code_to_string(code)
if [395].include? code
"ss1"
elsif [392, 227, 179, 176].include? code
"ss2"
# and so on
end
```
Note that the codes are integers. to match with a string code, use `%w(392 227 179).include?` instead of the array | Here's one solution you could try:
```
CODE_LOOKUP = {
[395] => 'ss1',
[392, 227, 179, 176] => 'ss2',
[389, 386] => 'ss3'
# etc
}
def lookup_code(code)
CODE_LOOKUP.each do |codes_to_test, result|
return result if codes_to_test.include?(code)
end
end
lookup_code(395)
# => "ss1"
lookup_code(179)
# => ... |
16,216,942 | I have multiple arrays which have code string items in them. I need to match the code from a given string and then return a class name from the matched array.
Might be better if I show you what I've got. So below are the arrays and underneath this is the string I need to return if the given string matches an item fro... | 2013/04/25 | [
"https://Stackoverflow.com/questions/16216942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/391460/"
] | The most efficient approach would be to generate a translator hash once that can perform the lookup super fast:
```
CODES = {
ss1: ['392', '227', '179', '176'],
ss2: ['389', '386'],
ss3: ['371', '338', '335'],
ss4: ['368', '350', '332', '329', '323', '185', '182']
}
translator = CODES.each_with_object({}){|(s... | Here's one solution you could try:
```
CODE_LOOKUP = {
[395] => 'ss1',
[392, 227, 179, 176] => 'ss2',
[389, 386] => 'ss3'
# etc
}
def lookup_code(code)
CODE_LOOKUP.each do |codes_to_test, result|
return result if codes_to_test.include?(code)
end
end
lookup_code(395)
# => "ss1"
lookup_code(179)
# => ... |
16,216,942 | I have multiple arrays which have code string items in them. I need to match the code from a given string and then return a class name from the matched array.
Might be better if I show you what I've got. So below are the arrays and underneath this is the string I need to return if the given string matches an item fro... | 2013/04/25 | [
"https://Stackoverflow.com/questions/16216942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/391460/"
] | ```
def code_to_string(code)
if [395].include? code
"ss1"
elsif [392, 227, 179, 176].include? code
"ss2"
# and so on
end
```
Note that the codes are integers. to match with a string code, use `%w(392 227 179).include?` instead of the array | ```
h = {:ss1 => [395],:ss2 => [392, 227, 179, 176] }
h.key(h.values.find{|x| x.include? "392".to_i})
#=> :ss2
``` |
16,216,942 | I have multiple arrays which have code string items in them. I need to match the code from a given string and then return a class name from the matched array.
Might be better if I show you what I've got. So below are the arrays and underneath this is the string I need to return if the given string matches an item fro... | 2013/04/25 | [
"https://Stackoverflow.com/questions/16216942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/391460/"
] | The most efficient approach would be to generate a translator hash once that can perform the lookup super fast:
```
CODES = {
ss1: ['392', '227', '179', '176'],
ss2: ['389', '386'],
ss3: ['371', '338', '335'],
ss4: ['368', '350', '332', '329', '323', '185', '182']
}
translator = CODES.each_with_object({}){|(s... | ```
def code_to_string(code)
if [395].include? code
"ss1"
elsif [392, 227, 179, 176].include? code
"ss2"
# and so on
end
```
Note that the codes are integers. to match with a string code, use `%w(392 227 179).include?` instead of the array |
16,216,942 | I have multiple arrays which have code string items in them. I need to match the code from a given string and then return a class name from the matched array.
Might be better if I show you what I've got. So below are the arrays and underneath this is the string I need to return if the given string matches an item fro... | 2013/04/25 | [
"https://Stackoverflow.com/questions/16216942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/391460/"
] | The most efficient approach would be to generate a translator hash once that can perform the lookup super fast:
```
CODES = {
ss1: ['392', '227', '179', '176'],
ss2: ['389', '386'],
ss3: ['371', '338', '335'],
ss4: ['368', '350', '332', '329', '323', '185', '182']
}
translator = CODES.each_with_object({}){|(s... | ```
h = {:ss1 => [395],:ss2 => [392, 227, 179, 176] }
h.key(h.values.find{|x| x.include? "392".to_i})
#=> :ss2
``` |
43,145,603 | I have a json data which was not serialized properly.
I have attached the expected and bad one.
I need to handle the bad json, get in a right format
Expected
```
"channels": {
"heart-rate": {
"events": {
"type": "Project.Model.ChannelEvents.HeartRateChannelEvent, Project, Version=1.2.7.0, Cul... | 2017/03/31 | [
"https://Stackoverflow.com/questions/43145603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7798692/"
] | Firstly, both your input and output JSON are syntactically invalid: they are missing outer braces `{` and `}`. For the remainder of this answer, I'm going to assume this is a typo in the question.
Assuming you have not done so already, you could install [json.net](/questions/tagged/json.net "show questions tagged 'jso... | Use [Json.NET](http://www.newtonsoft.com/json/help/html/SerializingJSON.htm) to Serialize and Deserialize your JSON |
1,824,358 | Okay - I'm beaten.
I have a (PHP-CLI) server written using PHP's socket\_\* functions. I can connect just fine to it using Putty and it works as expected.
However my PHP-CLI client does not work properly. It seems like the client is trying to grab the socket from the server (yes the server/client are on the same sys... | 2009/12/01 | [
"https://Stackoverflow.com/questions/1824358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/186700/"
] | >
> I don't want to get UserGroups each time I'am getting User.
>
>
>
Then don't tie them together in the object model. It gets complex fast, the more you start doing that.
If you are doing that to hand a single instance to the views, you can have a viewmodel with the set of info u need.
Pay attention if you con... | Have a look at using interceptors [here](http://www.castleproject.org/container/documentation/trunk/usersguide/interceptors.html). You can keep your objects clean and do all the initialization inside factories. |
783,399 | How can I get a list of users from AD who are Domain Admins and have not logged in the past 30 days? | 2016/06/11 | [
"https://serverfault.com/questions/783399",
"https://serverfault.com",
"https://serverfault.com/users/360071/"
] | user360071, here is a PowerShell script that will do what you want.
```
Import-Module ActiveDirectory
$Age = 30
$When = ((Get-Date).AddDays(-$Age)).Date
$Members = (Get-ADGroupMember -Identity "Domain Admins" -Recursive).DistinguishedName
Foreach ($Member in $Members) {
Get-ADUser -Identity $Member -Property LastLogon... | To implement user5870571's suggestion with `>> users.csv` (in case your file is blank - mine was too) do the following:
1) save the below script to a .ps1 file. Note that I removed `Export-Csv`
```
Import-Module ActiveDirectory
$Age = Read-Host "Accounts that have not been logged into in the last how many day... |
783,399 | How can I get a list of users from AD who are Domain Admins and have not logged in the past 30 days? | 2016/06/11 | [
"https://serverfault.com/questions/783399",
"https://serverfault.com",
"https://serverfault.com/users/360071/"
] | user360071, here is a PowerShell script that will do what you want.
```
Import-Module ActiveDirectory
$Age = 30
$When = ((Get-Date).AddDays(-$Age)).Date
$Members = (Get-ADGroupMember -Identity "Domain Admins" -Recursive).DistinguishedName
Foreach ($Member in $Members) {
Get-ADUser -Identity $Member -Property LastLogon... | To build on user5870571's post -
I would recommend using the `LastLogonTimestamp` property of the ADUser account, instead of the `LastLogonDate`.
[lastLogon vs. lastLogonTimestamp in Active Directory](https://serverfault.com/questions/734615/lastlogon-vs-lastlogontimestamp-in-active-directory)
* Lastlogon is only up... |
2,791,167 | In ASP.NET MVC, How do I make a partial view available to all controllers? I want to create navigation that is common across the entire site, but when I place the Html.Action into my master page, it only works on views associated with 1 controller.
Right now, I have a **controller action** defined like this:
```
... | 2010/05/07 | [
"https://Stackoverflow.com/questions/2791167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/335649/"
] | Put it in the `views\shared` folder
However looking at your error message, something else seem to be happening. You cannot use `<%=Html.Action%>` to render a view. You should use `<%=Html.RenderPartial("ViewName")%>` | Just to add to ropstah's response, the convention in asp.net-mvc is for a controller to first look in a folder with the same name (less the controller bit) as itself and then to look under the shared folder for a view if it does not find one. |
2,791,167 | In ASP.NET MVC, How do I make a partial view available to all controllers? I want to create navigation that is common across the entire site, but when I place the Html.Action into my master page, it only works on views associated with 1 controller.
Right now, I have a **controller action** defined like this:
```
... | 2010/05/07 | [
"https://Stackoverflow.com/questions/2791167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/335649/"
] | With MVC2 you can now render an action directly in the view. You will need to specify the controller that the action is on, if it isn't rendered from the same controller. Your partial view can be located in the views folder for the controller (instead of shared) if you include it this way. Note that it won't get the Vi... | Put it in the `views\shared` folder
However looking at your error message, something else seem to be happening. You cannot use `<%=Html.Action%>` to render a view. You should use `<%=Html.RenderPartial("ViewName")%>` |
2,791,167 | In ASP.NET MVC, How do I make a partial view available to all controllers? I want to create navigation that is common across the entire site, but when I place the Html.Action into my master page, it only works on views associated with 1 controller.
Right now, I have a **controller action** defined like this:
```
... | 2010/05/07 | [
"https://Stackoverflow.com/questions/2791167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/335649/"
] | With MVC2 you can now render an action directly in the view. You will need to specify the controller that the action is on, if it isn't rendered from the same controller. Your partial view can be located in the views folder for the controller (instead of shared) if you include it this way. Note that it won't get the Vi... | Just to add to ropstah's response, the convention in asp.net-mvc is for a controller to first look in a folder with the same name (less the controller bit) as itself and then to look under the shared folder for a view if it does not find one. |
46,071,465 | I was trying to figure out when to use or why `capacity()` method is different from `length()` method of `StringBuilder` or `StringBuffer` classes.
I have searched on Stack Overflow and managed to come up with [this](https://stackoverflow.com/questions/3184244/stringbuilder-capacity) answer, but I didn't understand it... | 2017/09/06 | [
"https://Stackoverflow.com/questions/46071465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | `StringBuilder` is for building up text. Internally, it uses an array of characters to hold the text you add to it. `capacity` is the size of the array. `length` is how much of that array is currently filled by text that should be used. So with:
```
StringBuilder sb = new StringBuilder(1000);
sb.append("testing");
``... | The length of the string is always less than or equal to the capacity of the builder. The length is the **actual size** of the string stored in the builder, and the capacity is the **maximum size** that it can currently fit.
The builder’s capacity is automatically increased if more characters are added to exceed its c... |
194,936 | I have a string that I would like to manipulate. The string is `H08W2345678` how would I be able to manipulate it so the output is just `W2345678`?
Similarly if the I wanted to drop the last 4 characters from `H08W2345678` so that I get `H08W234` how would I do this? | 2015/04/07 | [
"https://unix.stackexchange.com/questions/194936",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/102813/"
] | Just using bash (or `ksh93` where that syntax comes from or `zsh`):
```
string="H08W2345678"
echo "${string:3}"
W2345678
echo "${string:0:-4}"
H08W234
```
See the Wooledge wiki for more on [string manipulation](http://mywiki.wooledge.org/BashFAQ/100#Removing_part_of_a_string). | ```
$ echo "H08W2345678" | sed 's/^.\{3\}//'
W2345678
```
`sed 's/^.\{3\}//'` will find the first three characters by `^.\{3\}` and replace with blank. Here `^.` will match any character at the start of the string (`^` indicates the start of the string) and `\{3\}` will match the the previous pattern exactly 3 times.... |
194,936 | I have a string that I would like to manipulate. The string is `H08W2345678` how would I be able to manipulate it so the output is just `W2345678`?
Similarly if the I wanted to drop the last 4 characters from `H08W2345678` so that I get `H08W234` how would I do this? | 2015/04/07 | [
"https://unix.stackexchange.com/questions/194936",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/102813/"
] | ```
$ echo "H08W2345678" | sed 's/^.\{3\}//'
W2345678
```
`sed 's/^.\{3\}//'` will find the first three characters by `^.\{3\}` and replace with blank. Here `^.` will match any character at the start of the string (`^` indicates the start of the string) and `\{3\}` will match the the previous pattern exactly 3 times.... | If you have a file in which every line is
an eleven-character (or whatever) string that you want to chop up,
`sed` is the tool to use.
It’s fine for manipulating a single string, but it’s overkill.
For a single string, [Jason’s answer](https://unix.stackexchange.com/q/194936/23408#194938) is probably the best,
if you... |
194,936 | I have a string that I would like to manipulate. The string is `H08W2345678` how would I be able to manipulate it so the output is just `W2345678`?
Similarly if the I wanted to drop the last 4 characters from `H08W2345678` so that I get `H08W234` how would I do this? | 2015/04/07 | [
"https://unix.stackexchange.com/questions/194936",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/102813/"
] | ```
$ echo "H08W2345678" | sed 's/^.\{3\}//'
W2345678
```
`sed 's/^.\{3\}//'` will find the first three characters by `^.\{3\}` and replace with blank. Here `^.` will match any character at the start of the string (`^` indicates the start of the string) and `\{3\}` will match the the previous pattern exactly 3 times.... | With:
```
string="H08W2345678"
```
Matching 3 or 4 characters seems simple (for most shells):
```
$ printf '%s\t%s\n' "${string#???}" "${string%????}"
W2345678 H08W234
```
For the older shells (like the Bourne shell), use:
```
$ string=H08W2345678
$ expr " ${string}" : " ...\(.*\)"
W2345678
$ expr " ${str... |
194,936 | I have a string that I would like to manipulate. The string is `H08W2345678` how would I be able to manipulate it so the output is just `W2345678`?
Similarly if the I wanted to drop the last 4 characters from `H08W2345678` so that I get `H08W234` how would I do this? | 2015/04/07 | [
"https://unix.stackexchange.com/questions/194936",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/102813/"
] | ```
$ echo "H08W2345678" | sed 's/^.\{3\}//'
W2345678
```
`sed 's/^.\{3\}//'` will find the first three characters by `^.\{3\}` and replace with blank. Here `^.` will match any character at the start of the string (`^` indicates the start of the string) and `\{3\}` will match the the previous pattern exactly 3 times.... | >
> ### How to 'drop'/delete characters from in front of a string?
>
>
> I have a string that I would like to manipulate. The string is H08W2345678 how would I be able to manipulate it so the output is just W2345678?
>
>
>
```
echo "H08W2345678" | cut -c 4-
```
>
> Similarly if the I wanted to drop the last 4... |
194,936 | I have a string that I would like to manipulate. The string is `H08W2345678` how would I be able to manipulate it so the output is just `W2345678`?
Similarly if the I wanted to drop the last 4 characters from `H08W2345678` so that I get `H08W234` how would I do this? | 2015/04/07 | [
"https://unix.stackexchange.com/questions/194936",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/102813/"
] | Just using bash (or `ksh93` where that syntax comes from or `zsh`):
```
string="H08W2345678"
echo "${string:3}"
W2345678
echo "${string:0:-4}"
H08W234
```
See the Wooledge wiki for more on [string manipulation](http://mywiki.wooledge.org/BashFAQ/100#Removing_part_of_a_string). | If you have a file in which every line is
an eleven-character (or whatever) string that you want to chop up,
`sed` is the tool to use.
It’s fine for manipulating a single string, but it’s overkill.
For a single string, [Jason’s answer](https://unix.stackexchange.com/q/194936/23408#194938) is probably the best,
if you... |
194,936 | I have a string that I would like to manipulate. The string is `H08W2345678` how would I be able to manipulate it so the output is just `W2345678`?
Similarly if the I wanted to drop the last 4 characters from `H08W2345678` so that I get `H08W234` how would I do this? | 2015/04/07 | [
"https://unix.stackexchange.com/questions/194936",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/102813/"
] | Just using bash (or `ksh93` where that syntax comes from or `zsh`):
```
string="H08W2345678"
echo "${string:3}"
W2345678
echo "${string:0:-4}"
H08W234
```
See the Wooledge wiki for more on [string manipulation](http://mywiki.wooledge.org/BashFAQ/100#Removing_part_of_a_string). | With:
```
string="H08W2345678"
```
Matching 3 or 4 characters seems simple (for most shells):
```
$ printf '%s\t%s\n' "${string#???}" "${string%????}"
W2345678 H08W234
```
For the older shells (like the Bourne shell), use:
```
$ string=H08W2345678
$ expr " ${string}" : " ...\(.*\)"
W2345678
$ expr " ${str... |
194,936 | I have a string that I would like to manipulate. The string is `H08W2345678` how would I be able to manipulate it so the output is just `W2345678`?
Similarly if the I wanted to drop the last 4 characters from `H08W2345678` so that I get `H08W234` how would I do this? | 2015/04/07 | [
"https://unix.stackexchange.com/questions/194936",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/102813/"
] | Just using bash (or `ksh93` where that syntax comes from or `zsh`):
```
string="H08W2345678"
echo "${string:3}"
W2345678
echo "${string:0:-4}"
H08W234
```
See the Wooledge wiki for more on [string manipulation](http://mywiki.wooledge.org/BashFAQ/100#Removing_part_of_a_string). | >
> ### How to 'drop'/delete characters from in front of a string?
>
>
> I have a string that I would like to manipulate. The string is H08W2345678 how would I be able to manipulate it so the output is just W2345678?
>
>
>
```
echo "H08W2345678" | cut -c 4-
```
>
> Similarly if the I wanted to drop the last 4... |
194,936 | I have a string that I would like to manipulate. The string is `H08W2345678` how would I be able to manipulate it so the output is just `W2345678`?
Similarly if the I wanted to drop the last 4 characters from `H08W2345678` so that I get `H08W234` how would I do this? | 2015/04/07 | [
"https://unix.stackexchange.com/questions/194936",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/102813/"
] | If you have a file in which every line is
an eleven-character (or whatever) string that you want to chop up,
`sed` is the tool to use.
It’s fine for manipulating a single string, but it’s overkill.
For a single string, [Jason’s answer](https://unix.stackexchange.com/q/194936/23408#194938) is probably the best,
if you... | With:
```
string="H08W2345678"
```
Matching 3 or 4 characters seems simple (for most shells):
```
$ printf '%s\t%s\n' "${string#???}" "${string%????}"
W2345678 H08W234
```
For the older shells (like the Bourne shell), use:
```
$ string=H08W2345678
$ expr " ${string}" : " ...\(.*\)"
W2345678
$ expr " ${str... |
194,936 | I have a string that I would like to manipulate. The string is `H08W2345678` how would I be able to manipulate it so the output is just `W2345678`?
Similarly if the I wanted to drop the last 4 characters from `H08W2345678` so that I get `H08W234` how would I do this? | 2015/04/07 | [
"https://unix.stackexchange.com/questions/194936",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/102813/"
] | >
> ### How to 'drop'/delete characters from in front of a string?
>
>
> I have a string that I would like to manipulate. The string is H08W2345678 how would I be able to manipulate it so the output is just W2345678?
>
>
>
```
echo "H08W2345678" | cut -c 4-
```
>
> Similarly if the I wanted to drop the last 4... | With:
```
string="H08W2345678"
```
Matching 3 or 4 characters seems simple (for most shells):
```
$ printf '%s\t%s\n' "${string#???}" "${string%????}"
W2345678 H08W234
```
For the older shells (like the Bourne shell), use:
```
$ string=H08W2345678
$ expr " ${string}" : " ...\(.*\)"
W2345678
$ expr " ${str... |
49,144,085 | I have a not completely orthodox CF->S3 setup. The relevant components here are:
1. Cloudfront distribution with `origin s3.ap-southeast-2.amazonaws.com`
2. Lambda@Edge function (Origin Request) that adds a S3 authorisation (version 2) query string (Signed using the S3 policy the function uses).
The request returned ... | 2018/03/07 | [
"https://Stackoverflow.com/questions/49144085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1803096/"
] | So it seems like with Authentication V2 or V4, the `x-amz-cf-id` header that's appended to the origin request and inaccessible by the Lambda@Edge origin request function must be included in the authentication string. This is not possible.
The simple solution is to use the built-in S3 integration in Cloudflare, use a L... | X-amz-cf-id is a reserved header of CF and it could be get by event as event['Records'][0]['cf']['config']['requestId']. You don't have to calculate Authentication V4 with X-amz-cf-id. |
49,144,085 | I have a not completely orthodox CF->S3 setup. The relevant components here are:
1. Cloudfront distribution with `origin s3.ap-southeast-2.amazonaws.com`
2. Lambda@Edge function (Origin Request) that adds a S3 authorisation (version 2) query string (Signed using the S3 policy the function uses).
The request returned ... | 2018/03/07 | [
"https://Stackoverflow.com/questions/49144085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1803096/"
] | So it seems like with Authentication V2 or V4, the `x-amz-cf-id` header that's appended to the origin request and inaccessible by the Lambda@Edge origin request function must be included in the authentication string. This is not possible.
The simple solution is to use the built-in S3 integration in Cloudflare, use a L... | I had alike task of returning S3 signed URL from a CloudFront origin request Lambda@Edge. Here is what I found:
If your S3 bucket does not have dots in the name you can use S3 origin in CloudFront, use domain name in the form of <bucket\_name>.s3.<region>.amazonaws.com and generate signed URL e.g. via getSignedUrl fro... |
49,144,085 | I have a not completely orthodox CF->S3 setup. The relevant components here are:
1. Cloudfront distribution with `origin s3.ap-southeast-2.amazonaws.com`
2. Lambda@Edge function (Origin Request) that adds a S3 authorisation (version 2) query string (Signed using the S3 policy the function uses).
The request returned ... | 2018/03/07 | [
"https://Stackoverflow.com/questions/49144085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1803096/"
] | I believe the `AWSAccessKeyID` => `x-amz-cf-id` replacement is the result of two mechanisms:
First, you need to configure CloudFront to forward the query parameters to the origin. Without that, it will strip all parameters. If you use S3 signed URLs, make sure to also cache based on all parameters as otherwise you'll ... | X-amz-cf-id is a reserved header of CF and it could be get by event as event['Records'][0]['cf']['config']['requestId']. You don't have to calculate Authentication V4 with X-amz-cf-id. |
49,144,085 | I have a not completely orthodox CF->S3 setup. The relevant components here are:
1. Cloudfront distribution with `origin s3.ap-southeast-2.amazonaws.com`
2. Lambda@Edge function (Origin Request) that adds a S3 authorisation (version 2) query string (Signed using the S3 policy the function uses).
The request returned ... | 2018/03/07 | [
"https://Stackoverflow.com/questions/49144085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1803096/"
] | I believe the `AWSAccessKeyID` => `x-amz-cf-id` replacement is the result of two mechanisms:
First, you need to configure CloudFront to forward the query parameters to the origin. Without that, it will strip all parameters. If you use S3 signed URLs, make sure to also cache based on all parameters as otherwise you'll ... | I had alike task of returning S3 signed URL from a CloudFront origin request Lambda@Edge. Here is what I found:
If your S3 bucket does not have dots in the name you can use S3 origin in CloudFront, use domain name in the form of <bucket\_name>.s3.<region>.amazonaws.com and generate signed URL e.g. via getSignedUrl fro... |
24,596,260 | I can't find the neo4j-shell after installing the community edition on Windows. Am I missing something. I wanted to use it to run in a batch of cypher statements. | 2014/07/06 | [
"https://Stackoverflow.com/questions/24596260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3809607/"
] | Personally i will go with more functional aproach and clean the code a little bit.
```
rows.map do |row|
row.cells.map do |cell|
cell.a(text: 'View').exists? ? cell.a(text: 'View').href : cell.text
end
end
```
Hope I helped. | Okay, so I have an answer and it seems to be a non too terribly inelegant one.
Here's what I ended up doing:
```
rows.each do |row|
race_array = Array.new
row.cells.each do |cell|
if cell.a(text: 'View').exists?
race_array << cell.a(text: 'View').href
else
race_array << cell.text
end
end... |
1,184,781 | For any real numbers $a$ and $b$ and $1 \leq p < \infty$, prove that
$$|a+b|^p \leq 2^p \{ |a|^p +|b|^p \}$$
This inequality is given in the the book Real Analysis by Royden, Chapter $7$, page $136$. I don't understand how the author comes to this inequality. Can anyone provide some hints? | 2015/03/11 | [
"https://math.stackexchange.com/questions/1184781",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/54398/"
] | It can be quite simple: let $c=\max\{|a|,|b|\}$ so that
$$
|a+b|\leq |a|+|b|\leq 2c\implies |a+b|^p\leq (2c)^p=2^p(c^p)\leq 2^p(|a|^p+|b|^p).
$$
In fact, you only need $p\geq 0$.
---
**Edit**: As Winther indicates [elsewhere](https://math.stackexchange.com/a/1184791/136641) in this thread, $p\geq 1$ gives you a stro... | Hint:
A [convex function](http://en.wikipedia.org/wiki/Convex_function) always satisfy $$f(tx+(1-t)y)\leq tf(x) + (1-t)f(y),~~~~~~~t\in[0,1]$$
Take $f(x) = |x|^p$, show that this is convex for $p\geq 1$ (for example by the [second derivative test](http://en.wikipedia.org/wiki/Second_derivative_test#Concavity_test)) ... |
194,697 | The pronunciation of the word science seems to vary based on which part of the world you're in. I have heard it pronounced "sai-ens" and "saains" (think "signs").
I have checked the dictionary, but every dictionary is made in a certain country and a really big number of those countries happen to be in the western hem... | 2014/09/03 | [
"https://english.stackexchange.com/questions/194697",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/90214/"
] | **TL;DR:** *Science* has two syllables compared with just one in *signs*, but phonologic factors like fast-speech rules and characteristics of Southeast Asian languages might make them sound alike you.
When you ask “how many syllables” a word has, especially one like *science*, you open up an extremely broad question ... | It has two: sci-ence.
Try clapping your hands while pronouncing the word, try multiply times and pick the one that sounds best! |
194,697 | The pronunciation of the word science seems to vary based on which part of the world you're in. I have heard it pronounced "sai-ens" and "saains" (think "signs").
I have checked the dictionary, but every dictionary is made in a certain country and a really big number of those countries happen to be in the western hem... | 2014/09/03 | [
"https://english.stackexchange.com/questions/194697",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/90214/"
] | **TL;DR:** *Science* has two syllables compared with just one in *signs*, but phonologic factors like fast-speech rules and characteristics of Southeast Asian languages might make them sound alike you.
When you ask “how many syllables” a word has, especially one like *science*, you open up an extremely broad question ... | For standard speakers of English (AmE, BrE, AusE), there are 2 syllables
>
> /'say ens/
>
>
>
with an accent on the first syllable which rhymes by itself with the pronoun 'I'.
For some varieties of English, for example Southern AmE, there is 1 syllable
>
> /sans/
>
>
>
because they tend to 'monophthongize... |
194,697 | The pronunciation of the word science seems to vary based on which part of the world you're in. I have heard it pronounced "sai-ens" and "saains" (think "signs").
I have checked the dictionary, but every dictionary is made in a certain country and a really big number of those countries happen to be in the western hem... | 2014/09/03 | [
"https://english.stackexchange.com/questions/194697",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/90214/"
] | Science has 1 strong and 1 weak syllable.
They together result in its rhythm.
The strong (— ) syllable: long & stressed , Weak (·) syllable: short.
E.g. — · Science ( SAI-ens), — · table | It has two: sci-ence.
Try clapping your hands while pronouncing the word, try multiply times and pick the one that sounds best! |
194,697 | The pronunciation of the word science seems to vary based on which part of the world you're in. I have heard it pronounced "sai-ens" and "saains" (think "signs").
I have checked the dictionary, but every dictionary is made in a certain country and a really big number of those countries happen to be in the western hem... | 2014/09/03 | [
"https://english.stackexchange.com/questions/194697",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/90214/"
] | Science has 1 strong and 1 weak syllable.
They together result in its rhythm.
The strong (— ) syllable: long & stressed , Weak (·) syllable: short.
E.g. — · Science ( SAI-ens), — · table | For standard speakers of English (AmE, BrE, AusE), there are 2 syllables
>
> /'say ens/
>
>
>
with an accent on the first syllable which rhymes by itself with the pronoun 'I'.
For some varieties of English, for example Southern AmE, there is 1 syllable
>
> /sans/
>
>
>
because they tend to 'monophthongize... |
194,697 | The pronunciation of the word science seems to vary based on which part of the world you're in. I have heard it pronounced "sai-ens" and "saains" (think "signs").
I have checked the dictionary, but every dictionary is made in a certain country and a really big number of those countries happen to be in the western hem... | 2014/09/03 | [
"https://english.stackexchange.com/questions/194697",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/90214/"
] | For standard speakers of English (AmE, BrE, AusE), there are 2 syllables
>
> /'say ens/
>
>
>
with an accent on the first syllable which rhymes by itself with the pronoun 'I'.
For some varieties of English, for example Southern AmE, there is 1 syllable
>
> /sans/
>
>
>
because they tend to 'monophthongize... | It has two: sci-ence.
Try clapping your hands while pronouncing the word, try multiply times and pick the one that sounds best! |
42,161,036 | In JavaScript: `{foo: bar, biz: qux}`.
In Ruby: `{foo => bar, biz => qux}`.
In Java:
```
HashMap<K, V> map = new HashMap<>();
map.put(foo, bar);
map.put(biz, qux);
```
Surely Kotlin can do better than Java? | 2017/02/10 | [
"https://Stackoverflow.com/questions/42161036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14637/"
] | You can do:
```
val map = hashMapOf(
"John" to "Doe",
"Jane" to "Smith"
)
```
Here, [`to`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/to.html) is an infix function that creates a `Pair`.
Or, more abstract: use `mapOf()` like
```
val map = mapOf("a" to 1, "b" to 2, "c" to 3)
```
( found on [kotlinla... | There is a proposal to add them to the language:
**[Kotlin/KEEP: Collection Literals](https://github.com/Kotlin/KEEP/pull/112)**
If this goes through, the syntax might be like:
```kotlin
val map = ["a" : 1, "b" : 2, "c" : 3]
``` |
29,717 | So I just adopted a 2 month old Netherland dwarf and I have no idea when to cut his nails. His nails look like this currently so I’m unsure if I should just let the vet cut his nails, or if his nails are just supposed to be this long.
[](https://i.sta... | 2021/02/06 | [
"https://pets.stackexchange.com/questions/29717",
"https://pets.stackexchange.com",
"https://pets.stackexchange.com/users/19800/"
] | To decide when to cut the nails of your rabbit, you can use a rule of thumb: if the nails are longer than the surrounding fur, you should have a closer look to them. (If your rabbit has special/non-natural fur, like rex or teddy, this rule does not work) In average this is between 3 and 12 weeks after the last cut.
If... | I'm in 4-H and I do my rabbits nails once every two weeks. Although I handle mine daily and I don't like being scratched. It really depends on how often you handle it and how fast the nails grow. I'm not saying never cut their nails. But once a month would be just fine or once a week. Depending on how often you wanna d... |
59,265,097 | I am under Windows 10, 64 bits.
I tried several time to update Spyder 4.0.0 with both the Anaconda Prompt and the Anaconda Navigator.
It failed. I uninstalled Anaconda and reinstalled it.
Then I ran the Anaconda Prompt as an Administrator and executed :
```
conda update spyder
```
The version of Spyder was 3.3.6.
... | 2019/12/10 | [
"https://Stackoverflow.com/questions/59265097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12213202/"
] | (*Spyder maintainer here*) Other users have reported that you need to run
`conda update anaconda`
and then
`conda install spyder=4`
to successfully update to version 4. | I also couldn't update Spyder to v4.0.0 on Win x64; but I found a solution.
A word about my setup: I use Miniconda and a conda environment with `conda-forge` as the top channel & the setting `channel_priority: strict` (a recommendation according to [conda-forge](https://docs.conda.io/projects/conda/en/latest/user-guid... |
59,265,097 | I am under Windows 10, 64 bits.
I tried several time to update Spyder 4.0.0 with both the Anaconda Prompt and the Anaconda Navigator.
It failed. I uninstalled Anaconda and reinstalled it.
Then I ran the Anaconda Prompt as an Administrator and executed :
```
conda update spyder
```
The version of Spyder was 3.3.6.
... | 2019/12/10 | [
"https://Stackoverflow.com/questions/59265097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12213202/"
] | I also couldn't update Spyder to v4.0.0 on Win x64; but I found a solution.
A word about my setup: I use Miniconda and a conda environment with `conda-forge` as the top channel & the setting `channel_priority: strict` (a recommendation according to [conda-forge](https://docs.conda.io/projects/conda/en/latest/user-guid... | I had freshly installed Anaconda on my PC. So doing just the following in Anaconda command prompt worked for me. Spyder, along with a lot of others, was updated to 4.0.0.
```
conda update anaconda
``` |
59,265,097 | I am under Windows 10, 64 bits.
I tried several time to update Spyder 4.0.0 with both the Anaconda Prompt and the Anaconda Navigator.
It failed. I uninstalled Anaconda and reinstalled it.
Then I ran the Anaconda Prompt as an Administrator and executed :
```
conda update spyder
```
The version of Spyder was 3.3.6.
... | 2019/12/10 | [
"https://Stackoverflow.com/questions/59265097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12213202/"
] | (*Spyder maintainer here*) Other users have reported that you need to run
`conda update anaconda`
and then
`conda install spyder=4`
to successfully update to version 4. | I had freshly installed Anaconda on my PC. So doing just the following in Anaconda command prompt worked for me. Spyder, along with a lot of others, was updated to 4.0.0.
```
conda update anaconda
``` |
59,265,097 | I am under Windows 10, 64 bits.
I tried several time to update Spyder 4.0.0 with both the Anaconda Prompt and the Anaconda Navigator.
It failed. I uninstalled Anaconda and reinstalled it.
Then I ran the Anaconda Prompt as an Administrator and executed :
```
conda update spyder
```
The version of Spyder was 3.3.6.
... | 2019/12/10 | [
"https://Stackoverflow.com/questions/59265097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12213202/"
] | An additional note here for those trying to upgrade to Spyder 4 and use conda environments in Windows 10. I was wanting to use Spyder 4 but also getting the error inside Spyder saying that it could not find the spyder-kernels. This happened regardless of (1) whether or not I installed Spyder inside a new environment or... | I solved this by uninstalling Spyder then installing by the specific version:
```
conda uninstall spyder
```
```
conda install spyder=4.1.5
``` |
59,265,097 | I am under Windows 10, 64 bits.
I tried several time to update Spyder 4.0.0 with both the Anaconda Prompt and the Anaconda Navigator.
It failed. I uninstalled Anaconda and reinstalled it.
Then I ran the Anaconda Prompt as an Administrator and executed :
```
conda update spyder
```
The version of Spyder was 3.3.6.
... | 2019/12/10 | [
"https://Stackoverflow.com/questions/59265097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12213202/"
] | (*Spyder maintainer here*) Other users have reported that you need to run
`conda update anaconda`
and then
`conda install spyder=4`
to successfully update to version 4. | I solved this by uninstalling Spyder then installing by the specific version:
```
conda uninstall spyder
```
```
conda install spyder=4.1.5
``` |
59,265,097 | I am under Windows 10, 64 bits.
I tried several time to update Spyder 4.0.0 with both the Anaconda Prompt and the Anaconda Navigator.
It failed. I uninstalled Anaconda and reinstalled it.
Then I ran the Anaconda Prompt as an Administrator and executed :
```
conda update spyder
```
The version of Spyder was 3.3.6.
... | 2019/12/10 | [
"https://Stackoverflow.com/questions/59265097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12213202/"
] | (*Spyder maintainer here*) Other users have reported that you need to run
`conda update anaconda`
and then
`conda install spyder=4`
to successfully update to version 4. | An additional note here for those trying to upgrade to Spyder 4 and use conda environments in Windows 10. I was wanting to use Spyder 4 but also getting the error inside Spyder saying that it could not find the spyder-kernels. This happened regardless of (1) whether or not I installed Spyder inside a new environment or... |
59,265,097 | I am under Windows 10, 64 bits.
I tried several time to update Spyder 4.0.0 with both the Anaconda Prompt and the Anaconda Navigator.
It failed. I uninstalled Anaconda and reinstalled it.
Then I ran the Anaconda Prompt as an Administrator and executed :
```
conda update spyder
```
The version of Spyder was 3.3.6.
... | 2019/12/10 | [
"https://Stackoverflow.com/questions/59265097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12213202/"
] | I also couldn't update Spyder to v4.0.0 on Win x64; but I found a solution.
A word about my setup: I use Miniconda and a conda environment with `conda-forge` as the top channel & the setting `channel_priority: strict` (a recommendation according to [conda-forge](https://docs.conda.io/projects/conda/en/latest/user-guid... | I managed to solve this issue, which probably occurred by keeping too many packages in the same *root environment*.
Firstly, try downgrading conda, as it was suggested in the recent [issue on the conda repository](https://github.com/conda/conda/issues/9367#issuecomment-560343340):
```
conda install -n root conda=4.6
... |
59,265,097 | I am under Windows 10, 64 bits.
I tried several time to update Spyder 4.0.0 with both the Anaconda Prompt and the Anaconda Navigator.
It failed. I uninstalled Anaconda and reinstalled it.
Then I ran the Anaconda Prompt as an Administrator and executed :
```
conda update spyder
```
The version of Spyder was 3.3.6.
... | 2019/12/10 | [
"https://Stackoverflow.com/questions/59265097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12213202/"
] | I used the following:
```
conda update anaconda
```
and then
```
conda update spyder
conda install spyder=4.0.1
```
to successfully update to version 4.0.1 | I also couldn't update Spyder to v4.0.0 on Win x64; but I found a solution.
A word about my setup: I use Miniconda and a conda environment with `conda-forge` as the top channel & the setting `channel_priority: strict` (a recommendation according to [conda-forge](https://docs.conda.io/projects/conda/en/latest/user-guid... |
59,265,097 | I am under Windows 10, 64 bits.
I tried several time to update Spyder 4.0.0 with both the Anaconda Prompt and the Anaconda Navigator.
It failed. I uninstalled Anaconda and reinstalled it.
Then I ran the Anaconda Prompt as an Administrator and executed :
```
conda update spyder
```
The version of Spyder was 3.3.6.
... | 2019/12/10 | [
"https://Stackoverflow.com/questions/59265097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12213202/"
] | I also couldn't update Spyder to v4.0.0 on Win x64; but I found a solution.
A word about my setup: I use Miniconda and a conda environment with `conda-forge` as the top channel & the setting `channel_priority: strict` (a recommendation according to [conda-forge](https://docs.conda.io/projects/conda/en/latest/user-guid... | I had the same issue when I was trying
```
conda install spyder=4.1.2
```
then I did the below, it worked!
```
conda config --set allow_conda_downgrades true
conda install conda=4.6.14
``` |
59,265,097 | I am under Windows 10, 64 bits.
I tried several time to update Spyder 4.0.0 with both the Anaconda Prompt and the Anaconda Navigator.
It failed. I uninstalled Anaconda and reinstalled it.
Then I ran the Anaconda Prompt as an Administrator and executed :
```
conda update spyder
```
The version of Spyder was 3.3.6.
... | 2019/12/10 | [
"https://Stackoverflow.com/questions/59265097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12213202/"
] | I solved this by uninstalling Spyder then installing by the specific version:
```
conda uninstall spyder
```
```
conda install spyder=4.1.5
``` | I managed to solve this issue, which probably occurred by keeping too many packages in the same *root environment*.
Firstly, try downgrading conda, as it was suggested in the recent [issue on the conda repository](https://github.com/conda/conda/issues/9367#issuecomment-560343340):
```
conda install -n root conda=4.6
... |
14,325,671 | How can I run a cron job(bash script) only when CPU idle >50%?
I can get cpu idle from TOP
```
top -b -d 00.10 -n 3 |grep ^Cpu
Cpu(s): 0.3%us, 0.3%sy, 0.0%ni, 99.3%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
```
my current setup is:
```
crontab
0,15,30,45 * * * * /usr/bin/php /home/user/batchprocess.php
# I could use a bas... | 2013/01/14 | [
"https://Stackoverflow.com/questions/14325671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/957423/"
] | This is a typical case of [TOCTOU](http://en.wikipedia.org/wiki/Time_of_check_to_time_of_use) - you check if the system is idle, and start your process - but after your check, as or before your process starts, something else caused another process in the system to kick off and you still load the system more than necess... | If you simply wish to have your script executed whenever the system load is e.g. 2.0 or less, you could use a shell script like this:
```
#!/bin/sh
LOAD=`cat /proc/loadavg | cut -d" " -f1`
THRESHOLD=2.0
if [ $(bc <<< "$LOAD <= $THRESHOLD") -eq 1 ]; then
$@
fi
```
Save it as e.g. `/usr/local/bin/if-idle`, and sti... |
46,779,651 | I have a Stata program that outputs a local scalar of space-separated variable names.
I have to run the program twice on two samples (same `dta`) and store the union (intersection - variable names appearing in both scalars) as a new space-separated local scalar (for input to another program).
I can't figure out how... | 2017/10/16 | [
"https://Stackoverflow.com/questions/46779651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2097088/"
] | Stata has a bunch of extended macro functions to use on lists that you can find with `help macrolists`, where you can see that A & B returns the intersection of A and B. If A="a b c d" and B="b c f g", then A & B = "b c".
This allows you to do something like this:
```
clear
scalar l1="vara varb varc"
scalar l2="varc ... | I am not sure I perfectly understand your question, if this is not the appropriate answer, please add an example for us to work with.
Here is the code that checks two space-separated macros and gets their intersection, even if it's not the most elegant, unless your macros are huge it should still be quite fast.
```
l... |
71,036,486 | onclick function to change an image once clicked but its giving me an error in Js saying unexpected else please I need an assistance Im a newbie in programming
```js
function changeImage(){
let a=document.getElementById("changeimg").src
if (a==="img/save.png") {
return a = "img/saveblack.png"
... | 2022/02/08 | [
"https://Stackoverflow.com/questions/71036486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17773484/"
] | ```
micronaut:
server:
port: -1
```
solved the problem for me | Seems micronaut is using a depracated SocketUtils that is problematic
<https://github.com/micronaut-projects/micronaut-core/blob/5a8a7a7318d0f041f5fdfb667a9da5af1860a8e2/inject/src/main/java/io/micronaut/context/env/PropertySourcePropertyResolver.java#L595>
Issue report from Spring
<https://github.com/spring-projects/... |
293,537 | I have a Ubuntu 16.04 Server, with `GDAL 2.1.3, released 2017/20/01`.
I need to project a Raster to [EPSG:7755](https://epsg.io/7755) which was added way back in 2016.
When I use this EPSG code with gdalwarp, I get the following error:
```
ERROR 6: EPSG PCS/GCS code 7755 not found in EPSG support files. Is this a v... | 2018/08/21 | [
"https://gis.stackexchange.com/questions/293537",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/442/"
] | You can't that I know of. It's my understanding that you need to update GDAL to a version that has a newer EPSG database.
* GDAL 2.2 includes [EPSG v 9.0](https://web.archive.org/web/20170608191709/http://www.epsg.org:80/EPSGDataset/WhatIsNew) which was released Dec 2016 so may include
your EPSG code.
* [GDAL 2.3.0](... | In current versions of QGIS, EPSG:7755 expands to
```
+proj=lcc +lat_1=12.472955 +lat_2=35.17280444444444 +lat_0=24 +lon_0=80 +x_0=4000000 +y_0=4000000 +datum=WGS84 +units=m +no_defs
```
So the easiest way is to define a custom CRS with it, and assign that to your raster.
If you update the csv files from GDAL manu... |
293,537 | I have a Ubuntu 16.04 Server, with `GDAL 2.1.3, released 2017/20/01`.
I need to project a Raster to [EPSG:7755](https://epsg.io/7755) which was added way back in 2016.
When I use this EPSG code with gdalwarp, I get the following error:
```
ERROR 6: EPSG PCS/GCS code 7755 not found in EPSG support files. Is this a v... | 2018/08/21 | [
"https://gis.stackexchange.com/questions/293537",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/442/"
] | You can't that I know of. It's my understanding that you need to update GDAL to a version that has a newer EPSG database.
* GDAL 2.2 includes [EPSG v 9.0](https://web.archive.org/web/20170608191709/http://www.epsg.org:80/EPSGDataset/WhatIsNew) which was released Dec 2016 so may include
your EPSG code.
* [GDAL 2.3.0](... | On linux, the epsg database is in your system's proj4 folder (for example /usr/share/proj/epsg) as a simple text file. You can add the appropriate entry in wkt format, providing you have root access. |
30,813,978 | After I save the note in my Android app, the note (or the ListView) of the note/s doesn't appear in the **MainActivity**. The **MainActivity class** of my app is:
```
package com.twitter.i_droidi.mynotes;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import and... | 2015/06/13 | [
"https://Stackoverflow.com/questions/30813978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The problem is that the onCreate is only called once during the lifecycle. When you switch activities, the Main is simply hidden and paused. When you are returned to the activity, the onCreate does not fire again.
Override the onStart method and set your list adapter in there. It will be called right after the onCreat... | This answer **assumes** that your implementation of `Second` activity adds a new note to some global model and that the state of this model is reflected in the `nDS` object that you've **already** created in `MainActivity` (since `onCreate()` of `MainActivity` usually will not be called when you `finish()` `Second`).
... |
30,813,978 | After I save the note in my Android app, the note (or the ListView) of the note/s doesn't appear in the **MainActivity**. The **MainActivity class** of my app is:
```
package com.twitter.i_droidi.mynotes;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import and... | 2015/06/13 | [
"https://Stackoverflow.com/questions/30813978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The problem is that the onCreate is only called once during the lifecycle. When you switch activities, the Main is simply hidden and paused. When you are returned to the activity, the onCreate does not fire again.
Override the onStart method and set your list adapter in there. It will be called right after the onCreat... | I think there are two problem present in your code
1) First replace
```
public List<NotesModel> getAllNotes() {
List<NotesModel> notesList = new ArrayList<NotesModel>();
Cursor cursor = sql.query(myDB.TABLE_NAME, getAllColumns, null, null, null, null, null);
cursor.moveToFirst();
wh... |
7,125,557 | I'm learning Open GL ES and would like to get a more intuitive interface with 3D objects than the one suggested by google in the [TouchRotateActivity sample](http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/TouchRotateActivity.html).
In order to do that, I would like to mult... | 2011/08/19 | [
"https://Stackoverflow.com/questions/7125557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/902912/"
] | You should look at `WaitHandle` class. See example of usage at <http://msdn.microsoft.com/en-us/library/system.threading.waithandle.aspx> | aren't there any async methods for this that would make this problem much simpler?
here's the async [BeginAcceptSocket](http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.beginacceptsocket.aspx) on msdn and it also features a very well documented example. |
60,993,605 | In my template, I need to display the text 'Passed' only if `item.name === 'michael'`is not true.My component has data `courses[]` coming from its parent. I have two interfaces Courses and Teachers where each course id has its own Teacher data.
Here is my code:
```
@Input() courses[];
isRequired = false;
ngonI... | 2020/04/02 | [
"https://Stackoverflow.com/questions/60993605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8527241/"
] | isRequired will be set for all components, if one of the items has the name.
You could try `listing.name === 'michael'`, if the name is inside of the listing.
```
<tbody>
<tr *ngFor="let listing of courses">
<td>
{{listing.name}}
</td>
<td>
<span *ngIf="listing.name === 'michael'... | Your `isRequired` should also be an observable.
Try like this:
```
public isRequired$ = new ReplaySubject<boolean>(1);
```
and then
```
onCheckData(singleList: Courses) {
this.someService.someObservable(singleList.id).subscribe( item => {
if (item.name === 'michael') {
this.isRequired$.next(true);
... |
3,446,592 | If the user highlights the text within an `<h1>` with their cursor, how do I get that `<h1>` object? Or if they selected text within an `<li>`, how do i get that `<li>`? | 2010/08/10 | [
"https://Stackoverflow.com/questions/3446592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/243494/"
] | You can get the selection on Document as,
```
dd = window.getSelection();
desiredElement = dd.focusNode.parentNode; // h1 or li or other
desiredTag = desiredElement.tagName; // its tagname
```
Happy Coding. | ```
$('h1').click(function(){
alert(this); // `this` is the <h1> object clicked.
});
```
is there some tricky part I missed in your question? |
3,446,592 | If the user highlights the text within an `<h1>` with their cursor, how do I get that `<h1>` object? Or if they selected text within an `<li>`, how do i get that `<li>`? | 2010/08/10 | [
"https://Stackoverflow.com/questions/3446592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/243494/"
] | You need to deal with `window.getSelection()`.
See
* See [Here](https://stackoverflow.com/questions/3076052/is-there-a-cross-browser-solution-for-getselection)
* [Here](https://stackoverflow.com/questions/3284443/storing-highlighted-text-in-a-variable)
* and [Here](https://stackoverflow.com/questions/815202/insert-se... | ```
$('h1').click(function(){
alert(this); // `this` is the <h1> object clicked.
});
```
is there some tricky part I missed in your question? |
3,446,592 | If the user highlights the text within an `<h1>` with their cursor, how do I get that `<h1>` object? Or if they selected text within an `<li>`, how do i get that `<li>`? | 2010/08/10 | [
"https://Stackoverflow.com/questions/3446592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/243494/"
] | You can get the selection on Document as,
```
dd = window.getSelection();
desiredElement = dd.focusNode.parentNode; // h1 or li or other
desiredTag = desiredElement.tagName; // its tagname
```
Happy Coding. | You can get the parent element of a selection in all modern mainstream browsers as follows. Bear in mind that Firefox allows multiple selections by default these days; this code will use only the first.
See also my answer here: [How can I get the DOM element which contains the current selection?](https://stackoverflow... |
3,446,592 | If the user highlights the text within an `<h1>` with their cursor, how do I get that `<h1>` object? Or if they selected text within an `<li>`, how do i get that `<li>`? | 2010/08/10 | [
"https://Stackoverflow.com/questions/3446592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/243494/"
] | You need to deal with `window.getSelection()`.
See
* See [Here](https://stackoverflow.com/questions/3076052/is-there-a-cross-browser-solution-for-getselection)
* [Here](https://stackoverflow.com/questions/3284443/storing-highlighted-text-in-a-variable)
* and [Here](https://stackoverflow.com/questions/815202/insert-se... | You can get the parent element of a selection in all modern mainstream browsers as follows. Bear in mind that Firefox allows multiple selections by default these days; this code will use only the first.
See also my answer here: [How can I get the DOM element which contains the current selection?](https://stackoverflow... |
66,788,295 | Currently, element Three goes directly below element One, but I want it so Three goes right below Two. If I add `margin-left:30px` to block class, it Three goes directly below Two, but I would like to know if there is a way to get this done without using margin-left property? Here is the link to codesandbox: <https://c... | 2021/03/24 | [
"https://Stackoverflow.com/questions/66788295",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13759144/"
] | Your example is confusing, as you provide CSS with an element `span.container` that is never used. Plus, `<span>` is an inline-element that you force to become a block-element. It would be better to just use a `<div>` then. It is the "block-element counterpart" of a `span`, a simple wrapper-element without semantics.
... | There are many different approach that you can use. That's an example with flexbox
```css
div {
display: flex;
justify-content: flex-end;
}
span {
width: 50%;
background: blue;
}
```
```html
<div>
<span>One</span>
<span>Two</span>
</div>
<div>
<span ... |
10,158,665 | I have 2 questions in terms of android development and threads
1) When do you think I should use threads in android development?
2) If I have the main UI thread waiting on some variable to be set before it displays a toast, then I thought about having a while(true) loop in a sperate thread that keeps checking that va... | 2012/04/15 | [
"https://Stackoverflow.com/questions/10158665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1217820/"
] | Using threads directly is not necessary in most cases. The android facilities for threaded programming are great, and easy to use.
You have about three options to call the UI thread from another thread:
* [Handler](http://developer.android.com/reference/android/os/Handler.html) - set an handler on the other thread fr... | Never have a `while(true)` loop that continuously runs. It'll burn massive amounts of resources and, in your case, accomplish very little.
Threads are good to run for (mainly) background tasks and resource intensive tasks (so that you don't block the UI thread). To create a new Thread, use the following:
```
new Thre... |
10,158,665 | I have 2 questions in terms of android development and threads
1) When do you think I should use threads in android development?
2) If I have the main UI thread waiting on some variable to be set before it displays a toast, then I thought about having a while(true) loop in a sperate thread that keeps checking that va... | 2012/04/15 | [
"https://Stackoverflow.com/questions/10158665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1217820/"
] | Using threads directly is not necessary in most cases. The android facilities for threaded programming are great, and easy to use.
You have about three options to call the UI thread from another thread:
* [Handler](http://developer.android.com/reference/android/os/Handler.html) - set an handler on the other thread fr... | Depending on the type of app you are working on/with, proper use of Theads can be key to having a fast and responsive UI.
Key Rule:
If you need to to anything that accesses the filesystem, network, image loading, or anything that requires more than simple value or state checks, **immediately launch and perform that... |
10,158,665 | I have 2 questions in terms of android development and threads
1) When do you think I should use threads in android development?
2) If I have the main UI thread waiting on some variable to be set before it displays a toast, then I thought about having a while(true) loop in a sperate thread that keeps checking that va... | 2012/04/15 | [
"https://Stackoverflow.com/questions/10158665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1217820/"
] | Using threads directly is not necessary in most cases. The android facilities for threaded programming are great, and easy to use.
You have about three options to call the UI thread from another thread:
* [Handler](http://developer.android.com/reference/android/os/Handler.html) - set an handler on the other thread fr... | You must use thread, if you want to prevent application from the current error or crash "Application not responding".
i use it when i call web services, geolocations.
Good frensh article:
<http://souissihaythem.blogspot.com/2011/08/application-not-responding.html>
<http://souissihaythem.blogspot.com/2011/08/applicat... |
10,158,665 | I have 2 questions in terms of android development and threads
1) When do you think I should use threads in android development?
2) If I have the main UI thread waiting on some variable to be set before it displays a toast, then I thought about having a while(true) loop in a sperate thread that keeps checking that va... | 2012/04/15 | [
"https://Stackoverflow.com/questions/10158665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1217820/"
] | Never have a `while(true)` loop that continuously runs. It'll burn massive amounts of resources and, in your case, accomplish very little.
Threads are good to run for (mainly) background tasks and resource intensive tasks (so that you don't block the UI thread). To create a new Thread, use the following:
```
new Thre... | You must use thread, if you want to prevent application from the current error or crash "Application not responding".
i use it when i call web services, geolocations.
Good frensh article:
<http://souissihaythem.blogspot.com/2011/08/application-not-responding.html>
<http://souissihaythem.blogspot.com/2011/08/applicat... |
10,158,665 | I have 2 questions in terms of android development and threads
1) When do you think I should use threads in android development?
2) If I have the main UI thread waiting on some variable to be set before it displays a toast, then I thought about having a while(true) loop in a sperate thread that keeps checking that va... | 2012/04/15 | [
"https://Stackoverflow.com/questions/10158665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1217820/"
] | Depending on the type of app you are working on/with, proper use of Theads can be key to having a fast and responsive UI.
Key Rule:
If you need to to anything that accesses the filesystem, network, image loading, or anything that requires more than simple value or state checks, **immediately launch and perform that... | You must use thread, if you want to prevent application from the current error or crash "Application not responding".
i use it when i call web services, geolocations.
Good frensh article:
<http://souissihaythem.blogspot.com/2011/08/application-not-responding.html>
<http://souissihaythem.blogspot.com/2011/08/applicat... |
4,259,873 | I hope I am able to explain my situation accurately.
I have an ASP.NET page that dumps out PDF files for the users with the following code:
```
Response.ContentType = "application/pdf";
Response.AppendHeader("content-disposition", string.Format("inline; filename={0}", getFileName(DateTime.Now)));
`... | 2010/11/23 | [
"https://Stackoverflow.com/questions/4259873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/142186/"
] | This is a simple behavior of the way that acrobat handles the file when you have it open inline. As far as I know there is not a way to dictate this when opening inline, as that becomes the responsibility of Acrobat. | I understand what you're trying to do is not possible because there are problems wth the 'inline' disposition type (I gather it's a PDF and/or browser issue).
I was struggling with the same issue and found this article which promises a solution:
[How to show or download a pdf file from an ASP.NET 2.0 page (iTextSha... |
300,149 | Lets say I use Dependency Injection and don't use a DI framework. So the injection is direct rather automatic. How I should handle the logger class? All the objects, (thousands) should have a Logger reference in their constructors? (We don't consider Singletons and Service Locater as they hide the dependency, and are p... | 2015/10/18 | [
"https://softwareengineering.stackexchange.com/questions/300149",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/46961/"
] | >
> How I should handle the logger class?
>
>
>
You should instantiate it and inject it into stuff that needs it.
>
> All the objects, (thousands) should have a Logger reference in their constructors?
>
>
>
So what? If those objects need to log, then they need to get that dependency *somewhere*.
I would ar... | You basically have two options.
Use the composition relationship
================================
You would't pass a class implementing a `Log` interface to a class, but you would create an `abstract class` where, in its constructor, you directly initialize it's `protected Log` member with `new` instance of your clas... |
45,848,983 | spring boot app with swagger works on localhost but cannot find swagger-ui.jar when deployed to ec2.
This application has no explicit mapping for /error, so you are seeing this as a fallback.
>
> Wed Aug 23 20:37:15 UTC 2017 There was an unexpected error
> (type=Internal Server Error, status=500). Unable to open r... | 2017/08/23 | [
"https://Stackoverflow.com/questions/45848983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8508345/"
] | You have access to the `dispatch` method in the object passed in the first parameter:
```js
get1: ({ commit, dispatch }) => {
dispatch('get2');
},
```
This is covered in the [documentation](https://vuex.vuejs.org/guide/actions.html#dispatching-actions). | ```js
export actions = {
GET_DATA (context) {
// do stuff
context.dispatch('GET_MORE_DATA');
},
GET_MORE_DATA (context) {
// do more stuff
}
}
``` |
45,848,983 | spring boot app with swagger works on localhost but cannot find swagger-ui.jar when deployed to ec2.
This application has no explicit mapping for /error, so you are seeing this as a fallback.
>
> Wed Aug 23 20:37:15 UTC 2017 There was an unexpected error
> (type=Internal Server Error, status=500). Unable to open r... | 2017/08/23 | [
"https://Stackoverflow.com/questions/45848983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8508345/"
] | You have access to the `dispatch` method in the object passed in the first parameter:
```js
get1: ({ commit, dispatch }) => {
dispatch('get2');
},
```
This is covered in the [documentation](https://vuex.vuejs.org/guide/actions.html#dispatching-actions). | for actions that does not require payload
```js
actions: {
BEFORE: async (context, payload) => {
},
AFTER: async (context, payload) => {
await context.dispatch('BEFORE');
}
}
```
for actions that does require **payload**
```js
actions: {
BEFORE: async (context, payload) => {
},
A... |
45,848,983 | spring boot app with swagger works on localhost but cannot find swagger-ui.jar when deployed to ec2.
This application has no explicit mapping for /error, so you are seeing this as a fallback.
>
> Wed Aug 23 20:37:15 UTC 2017 There was an unexpected error
> (type=Internal Server Error, status=500). Unable to open r... | 2017/08/23 | [
"https://Stackoverflow.com/questions/45848983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8508345/"
] | You have access to the `dispatch` method in the object passed in the first parameter:
```js
get1: ({ commit, dispatch }) => {
dispatch('get2');
},
```
This is covered in the [documentation](https://vuex.vuejs.org/guide/actions.html#dispatching-actions). | we can pass parameters also while dispatching.
```js
dispatch('fetchContacts', user.uid);
``` |
45,848,983 | spring boot app with swagger works on localhost but cannot find swagger-ui.jar when deployed to ec2.
This application has no explicit mapping for /error, so you are seeing this as a fallback.
>
> Wed Aug 23 20:37:15 UTC 2017 There was an unexpected error
> (type=Internal Server Error, status=500). Unable to open r... | 2017/08/23 | [
"https://Stackoverflow.com/questions/45848983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8508345/"
] | You have access to the `dispatch` method in the object passed in the first parameter:
```js
get1: ({ commit, dispatch }) => {
dispatch('get2');
},
```
This is covered in the [documentation](https://vuex.vuejs.org/guide/actions.html#dispatching-actions). | You can access the dispatch method through the first argument (context):
```js
export const actions = {
get({ commit, dispatch }) {
dispatch('action2')
}
}
```
However, if you use namespaced you need to specify an option:
```js
export const actions = {
get({ commit, dispatch }) {
dispatch('action2', {}... |
45,848,983 | spring boot app with swagger works on localhost but cannot find swagger-ui.jar when deployed to ec2.
This application has no explicit mapping for /error, so you are seeing this as a fallback.
>
> Wed Aug 23 20:37:15 UTC 2017 There was an unexpected error
> (type=Internal Server Error, status=500). Unable to open r... | 2017/08/23 | [
"https://Stackoverflow.com/questions/45848983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8508345/"
] | for actions that does not require payload
```js
actions: {
BEFORE: async (context, payload) => {
},
AFTER: async (context, payload) => {
await context.dispatch('BEFORE');
}
}
```
for actions that does require **payload**
```js
actions: {
BEFORE: async (context, payload) => {
},
A... | ```js
export actions = {
GET_DATA (context) {
// do stuff
context.dispatch('GET_MORE_DATA');
},
GET_MORE_DATA (context) {
// do more stuff
}
}
``` |
45,848,983 | spring boot app with swagger works on localhost but cannot find swagger-ui.jar when deployed to ec2.
This application has no explicit mapping for /error, so you are seeing this as a fallback.
>
> Wed Aug 23 20:37:15 UTC 2017 There was an unexpected error
> (type=Internal Server Error, status=500). Unable to open r... | 2017/08/23 | [
"https://Stackoverflow.com/questions/45848983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8508345/"
] | You can access the dispatch method through the first argument (context):
```js
export const actions = {
get({ commit, dispatch }) {
dispatch('action2')
}
}
```
However, if you use namespaced you need to specify an option:
```js
export const actions = {
get({ commit, dispatch }) {
dispatch('action2', {}... | ```js
export actions = {
GET_DATA (context) {
// do stuff
context.dispatch('GET_MORE_DATA');
},
GET_MORE_DATA (context) {
// do more stuff
}
}
``` |
45,848,983 | spring boot app with swagger works on localhost but cannot find swagger-ui.jar when deployed to ec2.
This application has no explicit mapping for /error, so you are seeing this as a fallback.
>
> Wed Aug 23 20:37:15 UTC 2017 There was an unexpected error
> (type=Internal Server Error, status=500). Unable to open r... | 2017/08/23 | [
"https://Stackoverflow.com/questions/45848983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8508345/"
] | for actions that does not require payload
```js
actions: {
BEFORE: async (context, payload) => {
},
AFTER: async (context, payload) => {
await context.dispatch('BEFORE');
}
}
```
for actions that does require **payload**
```js
actions: {
BEFORE: async (context, payload) => {
},
A... | we can pass parameters also while dispatching.
```js
dispatch('fetchContacts', user.uid);
``` |
45,848,983 | spring boot app with swagger works on localhost but cannot find swagger-ui.jar when deployed to ec2.
This application has no explicit mapping for /error, so you are seeing this as a fallback.
>
> Wed Aug 23 20:37:15 UTC 2017 There was an unexpected error
> (type=Internal Server Error, status=500). Unable to open r... | 2017/08/23 | [
"https://Stackoverflow.com/questions/45848983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8508345/"
] | You can access the dispatch method through the first argument (context):
```js
export const actions = {
get({ commit, dispatch }) {
dispatch('action2')
}
}
```
However, if you use namespaced you need to specify an option:
```js
export const actions = {
get({ commit, dispatch }) {
dispatch('action2', {}... | we can pass parameters also while dispatching.
```js
dispatch('fetchContacts', user.uid);
``` |
11,928,448 | I followed [this](http://www.raywenderlich.com/11283/cocos2d-x-for-ios-and-android-getting-started) tutorial on raywenderlich.com and I came into a stop on the part where I need to build the native C++ libraries for Android Development.
I am using Mac OS,Cocos2d-x v2.0.1 (latest version), have my Android SDK and NDK s... | 2012/08/13 | [
"https://Stackoverflow.com/questions/11928448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/932643/"
] | I think this should work for you
```
find ~ -name "*.mp3" -o -name "*.ogg"
```
-o is equivalent to boolean `or` | This one provides you with even those files which do *not* have mp3 or audio extension.
```sh
find -print0 | xargs -0 file -F '//' | awk -F '//' 'tolower($2) ~ /audio/ { print $1 }'
```
---
which interprets to:
`find . -print0`
Find (list) every file and output with a null terminator
`xargs -0 file -F '//'` Run ... |
11,928,448 | I followed [this](http://www.raywenderlich.com/11283/cocos2d-x-for-ios-and-android-getting-started) tutorial on raywenderlich.com and I came into a stop on the part where I need to build the native C++ libraries for Android Development.
I am using Mac OS,Cocos2d-x v2.0.1 (latest version), have my Android SDK and NDK s... | 2012/08/13 | [
"https://Stackoverflow.com/questions/11928448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/932643/"
] | I think this should work for you
```
find ~ -name "*.mp3" -o -name "*.ogg"
```
-o is equivalent to boolean `or` | Here is one I just did . . .
for .ogg and .mp3
```
find Music | grep '/*.ogg\|/*.mp3' | sort -u
``` |
11,928,448 | I followed [this](http://www.raywenderlich.com/11283/cocos2d-x-for-ios-and-android-getting-started) tutorial on raywenderlich.com and I came into a stop on the part where I need to build the native C++ libraries for Android Development.
I am using Mac OS,Cocos2d-x v2.0.1 (latest version), have my Android SDK and NDK s... | 2012/08/13 | [
"https://Stackoverflow.com/questions/11928448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/932643/"
] | Here is one I just did . . .
for .ogg and .mp3
```
find Music | grep '/*.ogg\|/*.mp3' | sort -u
``` | `find` does not support the full shell wildcard syntax (specifically, not the curly braces). You'll need to use something like this:
```
find ~ -iname '*.mp3' -o -iname '*.ogg'
``` |
11,928,448 | I followed [this](http://www.raywenderlich.com/11283/cocos2d-x-for-ios-and-android-getting-started) tutorial on raywenderlich.com and I came into a stop on the part where I need to build the native C++ libraries for Android Development.
I am using Mac OS,Cocos2d-x v2.0.1 (latest version), have my Android SDK and NDK s... | 2012/08/13 | [
"https://Stackoverflow.com/questions/11928448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/932643/"
] | I think this should work for you
```
find ~ -name "*.mp3" -o -name "*.ogg"
```
-o is equivalent to boolean `or` | `find` does not support the full shell wildcard syntax (specifically, not the curly braces). You'll need to use something like this:
```
find ~ -iname '*.mp3' -o -iname '*.ogg'
``` |
11,928,448 | I followed [this](http://www.raywenderlich.com/11283/cocos2d-x-for-ios-and-android-getting-started) tutorial on raywenderlich.com and I came into a stop on the part where I need to build the native C++ libraries for Android Development.
I am using Mac OS,Cocos2d-x v2.0.1 (latest version), have my Android SDK and NDK s... | 2012/08/13 | [
"https://Stackoverflow.com/questions/11928448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/932643/"
] | I think this should work for you
```
find ~ -name "*.mp3" -o -name "*.ogg"
```
-o is equivalent to boolean `or` | what about?
```
file * | grep audio
``` |
11,928,448 | I followed [this](http://www.raywenderlich.com/11283/cocos2d-x-for-ios-and-android-getting-started) tutorial on raywenderlich.com and I came into a stop on the part where I need to build the native C++ libraries for Android Development.
I am using Mac OS,Cocos2d-x v2.0.1 (latest version), have my Android SDK and NDK s... | 2012/08/13 | [
"https://Stackoverflow.com/questions/11928448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/932643/"
] | If you enable extglob (`shopt -s extglob`), you can use `*.@(ogg|mp3)`.
```
shopt -s extglob
printf '%s\n' *.@(mp3|ogg)
```
If you need recursion too, enable globstar (requires bash 4.0 or newer)
```
shopt -s extglob globstar
printf '%s\n' **/*.@(mp3|ogg)
```
When you use `ls *.{mp3,ogg}`, you are combining brace... | what about?
```
file * | grep audio
``` |
11,928,448 | I followed [this](http://www.raywenderlich.com/11283/cocos2d-x-for-ios-and-android-getting-started) tutorial on raywenderlich.com and I came into a stop on the part where I need to build the native C++ libraries for Android Development.
I am using Mac OS,Cocos2d-x v2.0.1 (latest version), have my Android SDK and NDK s... | 2012/08/13 | [
"https://Stackoverflow.com/questions/11928448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/932643/"
] | `find` does not support the full shell wildcard syntax (specifically, not the curly braces). You'll need to use something like this:
```
find ~ -iname '*.mp3' -o -iname '*.ogg'
``` | what about?
```
file * | grep audio
``` |
11,928,448 | I followed [this](http://www.raywenderlich.com/11283/cocos2d-x-for-ios-and-android-getting-started) tutorial on raywenderlich.com and I came into a stop on the part where I need to build the native C++ libraries for Android Development.
I am using Mac OS,Cocos2d-x v2.0.1 (latest version), have my Android SDK and NDK s... | 2012/08/13 | [
"https://Stackoverflow.com/questions/11928448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/932643/"
] | This one provides you with even those files which do *not* have mp3 or audio extension.
```sh
find -print0 | xargs -0 file -F '//' | awk -F '//' 'tolower($2) ~ /audio/ { print $1 }'
```
---
which interprets to:
`find . -print0`
Find (list) every file and output with a null terminator
`xargs -0 file -F '//'` Run ... | what about?
```
file * | grep audio
``` |
11,928,448 | I followed [this](http://www.raywenderlich.com/11283/cocos2d-x-for-ios-and-android-getting-started) tutorial on raywenderlich.com and I came into a stop on the part where I need to build the native C++ libraries for Android Development.
I am using Mac OS,Cocos2d-x v2.0.1 (latest version), have my Android SDK and NDK s... | 2012/08/13 | [
"https://Stackoverflow.com/questions/11928448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/932643/"
] | I think this should work for you
```
find ~ -name "*.mp3" -o -name "*.ogg"
```
-o is equivalent to boolean `or` | If you enable extglob (`shopt -s extglob`), you can use `*.@(ogg|mp3)`.
```
shopt -s extglob
printf '%s\n' *.@(mp3|ogg)
```
If you need recursion too, enable globstar (requires bash 4.0 or newer)
```
shopt -s extglob globstar
printf '%s\n' **/*.@(mp3|ogg)
```
When you use `ls *.{mp3,ogg}`, you are combining brace... |
11,928,448 | I followed [this](http://www.raywenderlich.com/11283/cocos2d-x-for-ios-and-android-getting-started) tutorial on raywenderlich.com and I came into a stop on the part where I need to build the native C++ libraries for Android Development.
I am using Mac OS,Cocos2d-x v2.0.1 (latest version), have my Android SDK and NDK s... | 2012/08/13 | [
"https://Stackoverflow.com/questions/11928448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/932643/"
] | This one provides you with even those files which do *not* have mp3 or audio extension.
```sh
find -print0 | xargs -0 file -F '//' | awk -F '//' 'tolower($2) ~ /audio/ { print $1 }'
```
---
which interprets to:
`find . -print0`
Find (list) every file and output with a null terminator
`xargs -0 file -F '//'` Run ... | `find` does not support the full shell wildcard syntax (specifically, not the curly braces). You'll need to use something like this:
```
find ~ -iname '*.mp3' -o -iname '*.ogg'
``` |
17,856,058 | I have an session cookie holding a multidimensional array called cart\_array and I'm using a for each to loop through the inner arrays and a while loop get the key value pairs out.
I want to check if an item exists in the array based not only on the product id (pid) but several other variables such as color and size. ... | 2013/07/25 | [
"https://Stackoverflow.com/questions/17856058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1485347/"
] | 1. Building off @Warewolf's answer, the next step is to create your own custom cell.
Go to `File -> New -> File -> User Interface -> Empty -> Call` this nib `"customNib"`.
2. In your `customNib` drag a `UICollectionView` Cell in. Give it reuse cell identifier `@"Cell"`.
3. `File -> New -> File -> Cocoa Touch Class -> ... | **Swift 5**
**XCode 11.5**
```
import UIKit
// 1. When creating this view, instanciate this class with the param "collectionViewLayout: UICollectionViewFlowLayout".
class BespokeCollectionViewController: UICollectionViewController, UICollectionViewDelegateFlowLayout {
var cellId = "AwesomeCell"
override fu... |
17,856,058 | I have an session cookie holding a multidimensional array called cart\_array and I'm using a for each to loop through the inner arrays and a while loop get the key value pairs out.
I want to check if an item exists in the array based not only on the product id (pid) but several other variables such as color and size. ... | 2013/07/25 | [
"https://Stackoverflow.com/questions/17856058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1485347/"
] | Swift 3
```
class TwoViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UICollectionViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
let flowLayout = UICollectionViewFlowLayout()
let collectionView = UICollectionView(frame: s... | ```
#pragma mark -
#pragma mark - UICollectionView Datasource and Delegates
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
... |
17,856,058 | I have an session cookie holding a multidimensional array called cart\_array and I'm using a for each to loop through the inner arrays and a while loop get the key value pairs out.
I want to check if an item exists in the array based not only on the product id (pid) but several other variables such as color and size. ... | 2013/07/25 | [
"https://Stackoverflow.com/questions/17856058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1485347/"
] | **For swift4 user:--**
```
class TwoViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UICollectionViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
self.collectionView = UICollectionView(frame: self.view.bounds, collectionViewLayout: ... | ```
swift 4 code
//
// ViewController.swift
// coolectionView
//
import UIKit
class ViewController: UIViewController , UICollectionViewDataSource, UICollectionViewDelegate,UICollectionViewDelegateFlowLayout{
@IBOutlet weak var collectionView: UICollectionView!
var items = ["1", "2", "3", "4", "5", "6", "7... |
17,856,058 | I have an session cookie holding a multidimensional array called cart\_array and I'm using a for each to loop through the inner arrays and a while loop get the key value pairs out.
I want to check if an item exists in the array based not only on the product id (pid) but several other variables such as color and size. ... | 2013/07/25 | [
"https://Stackoverflow.com/questions/17856058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1485347/"
] | **Swift 5**
**XCode 11.5**
```
import UIKit
// 1. When creating this view, instanciate this class with the param "collectionViewLayout: UICollectionViewFlowLayout".
class BespokeCollectionViewController: UICollectionViewController, UICollectionViewDelegateFlowLayout {
var cellId = "AwesomeCell"
override fu... | **For whose want create a Custom Cell** :
**CustomCell.h**
```c
#import <UIKit/UIKit.h>
@interface HeaderCollectionViewCell : UICollectionViewCell
@property (strong,nonatomic) UIImageView *image;
@end
```
**CustomCell.m**
```c
#import "HeaderCollectionViewCell.h"
@implementation HeaderCollectionViewCell
#defin... |
17,856,058 | I have an session cookie holding a multidimensional array called cart\_array and I'm using a for each to loop through the inner arrays and a while loop get the key value pairs out.
I want to check if an item exists in the array based not only on the product id (pid) but several other variables such as color and size. ... | 2013/07/25 | [
"https://Stackoverflow.com/questions/17856058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1485347/"
] | **For Swift 2.0**
Instead of implementing the methods that are required to draw the `CollectionViewCells`:
```
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize
{
return CGSizeMake(50, 50);
... | **Swift 5**
**XCode 11.5**
```
import UIKit
// 1. When creating this view, instanciate this class with the param "collectionViewLayout: UICollectionViewFlowLayout".
class BespokeCollectionViewController: UICollectionViewController, UICollectionViewDelegateFlowLayout {
var cellId = "AwesomeCell"
override fu... |
17,856,058 | I have an session cookie holding a multidimensional array called cart\_array and I'm using a for each to loop through the inner arrays and a while loop get the key value pairs out.
I want to check if an item exists in the array based not only on the product id (pid) but several other variables such as color and size. ... | 2013/07/25 | [
"https://Stackoverflow.com/questions/17856058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1485347/"
] | Header file:--
```
@interface ViewController : UIViewController<UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
{
UICollectionView *_collectionView;
}
```
Implementation File:--
```
- (void)viewDidLoad
{
[super viewDidLoad];
self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScree... | Apple Docs:
```
- (id)initWithFrame:(CGRect)frame
collectionViewLayout:(UICollectionViewLayout *)layoutParameters
```
>
> Use this method when initializing a collection view object
> programmatically. If you specify nil for the layout parameter, you
> must assign a layout object to the collectionViewLayout... |
17,856,058 | I have an session cookie holding a multidimensional array called cart\_array and I'm using a for each to loop through the inner arrays and a while loop get the key value pairs out.
I want to check if an item exists in the array based not only on the product id (pid) but several other variables such as color and size. ... | 2013/07/25 | [
"https://Stackoverflow.com/questions/17856058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1485347/"
] | **For Swift 2.0**
Instead of implementing the methods that are required to draw the `CollectionViewCells`:
```
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize
{
return CGSizeMake(50, 50);
... | Swift 3
```
class TwoViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UICollectionViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
let flowLayout = UICollectionViewFlowLayout()
let collectionView = UICollectionView(frame: s... |
17,856,058 | I have an session cookie holding a multidimensional array called cart\_array and I'm using a for each to loop through the inner arrays and a while loop get the key value pairs out.
I want to check if an item exists in the array based not only on the product id (pid) but several other variables such as color and size. ... | 2013/07/25 | [
"https://Stackoverflow.com/questions/17856058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1485347/"
] | Swift 3
```
class TwoViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UICollectionViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
let flowLayout = UICollectionViewFlowLayout()
let collectionView = UICollectionView(frame: s... | colection view exam
```
#import "CollectionViewController.h"
#import "BuyViewController.h"
#import "CollectionViewCell.h"
@interface CollectionViewController ()
{
NSArray *mobiles;
NSArray *costumes;
NSArray *shoes;
NSInteger selectpath;
NSArray *mobilerate;
NSArray *costumerate;
NSAr... |
17,856,058 | I have an session cookie holding a multidimensional array called cart\_array and I'm using a for each to loop through the inner arrays and a while loop get the key value pairs out.
I want to check if an item exists in the array based not only on the product id (pid) but several other variables such as color and size. ... | 2013/07/25 | [
"https://Stackoverflow.com/questions/17856058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1485347/"
] | **For Swift 2.0**
Instead of implementing the methods that are required to draw the `CollectionViewCells`:
```
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize
{
return CGSizeMake(50, 50);
... | ```
#pragma mark -
#pragma mark - UICollectionView Datasource and Delegates
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
... |
17,856,058 | I have an session cookie holding a multidimensional array called cart\_array and I'm using a for each to loop through the inner arrays and a while loop get the key value pairs out.
I want to check if an item exists in the array based not only on the product id (pid) but several other variables such as color and size. ... | 2013/07/25 | [
"https://Stackoverflow.com/questions/17856058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1485347/"
] | Header file:--
```
@interface ViewController : UIViewController<UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
{
UICollectionView *_collectionView;
}
```
Implementation File:--
```
- (void)viewDidLoad
{
[super viewDidLoad];
self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScree... | **For swift4 user:--**
```
class TwoViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UICollectionViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
self.collectionView = UICollectionView(frame: self.view.bounds, collectionViewLayout: ... |
31,219,603 | ```
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
public class NNNTest {
private String SkillNeed="Java;C++;C";
private String SkillHave="SQL:8;Java:9;C++:5;C:9;PHP:5";
public boolean CheckAvailable(){
int flag=0;
int k;
String [] snar=SkillNeed.... | 2015/07/04 | [
"https://Stackoverflow.com/questions/31219603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5030401/"
] | Simply way with java-8:
```
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;
public class NNNTest {
private static String skillNeed = "Java;C++;C"; //the skills the job need
private static String skillHave = "SQL:8;Java:9;C++:5;C:9;PHP:5"; //skill and level you have
pub... | Another Java 8 Solution..
It basically iterates through all required skills and makes sure, using the allMatch() function, that each skill is contained in the givenSkills-String. Keep in mind, that you have to check for ":" aswell, otherwise "C" would also match "C++". This also makes sure, that it exactly matches the ... |
293,134 | Let's say I have a line of text like this
```
Small 0.0..20.0 0.00 1.49 25.71 41.05 12.31 0.00 80.56
```
I want to capture the last six numbers and ignore the *Small* and the first two groups of numbers.
For this exercise, let's ignore the fact that it might be easier to just do some sort of stri... | 2008/11/15 | [
"https://Stackoverflow.com/questions/293134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/305/"
] | If you want to keep each match in a separate backreference, you have no choice but to "spell it out" - if you use repetition, you can either catch all six groups "as one" or only the last one, depending on where you put the capturing parentheses. So no, it's not possible to compact the regex and still keep all six indi... | For usability, you should use string substitution to build regex from composite parts.
```
$d = "[0-9.]+";
$s = ".*?";
$re = "^(Small)$s$d$s$d$s($d)$s($d)$s($d)$s($d)$s($d)$s($d)";
```
At least then you can see the structure past the pattern, and changing one part changes them all.
If you wanted to get really ... |
293,134 | Let's say I have a line of text like this
```
Small 0.0..20.0 0.00 1.49 25.71 41.05 12.31 0.00 80.56
```
I want to capture the last six numbers and ignore the *Small* and the first two groups of numbers.
For this exercise, let's ignore the fact that it might be easier to just do some sort of stri... | 2008/11/15 | [
"https://Stackoverflow.com/questions/293134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/305/"
] | Here is the shortest I could get:
```
^Small\s+(?:[\d.]+\s+){2}([\d.]+)\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)\s*$
```
It must be long because each capture must be specified explicitly. No need to capture "Small", though. But it is better to be specific (\s instead of .) when you can, and to anchor o... | For usability, you should use string substitution to build regex from composite parts.
```
$d = "[0-9.]+";
$s = ".*?";
$re = "^(Small)$s$d$s$d$s($d)$s($d)$s($d)$s($d)$s($d)$s($d)";
```
At least then you can see the structure past the pattern, and changing one part changes them all.
If you wanted to get really ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.