_id
stringlengths 2
6
| partition
stringclasses 3
values | text
stringlengths 21
37k
| language
stringclasses 1
value | title
stringclasses 1
value |
---|---|---|---|---|
d19723
|
test
|
Find: else if
Replace: \r\nelse if
Search Mode: Extended
A: Have a try with:
Find what: (\belse if\b)
Replace with: \n$1
|
unknown
| |
d19729
|
test
|
When you do a LEFT JOIN, you are taking all the rows from the first table and if there are no matches for the first join condition, the resulting records for table x will be a NULL record which is why you're using the AND operator 'c.name IS NULL' but I think you have some issues with your query. It's been a while for me so I'm trying not to make an error here but you don't appear to have a table name in your FROM clause and your select can't be in the from clause (i don't think)...maybe I'm wrong but I had to clean up the statement to understand what you are doing better...so please clarify and I can improve my answer.
SELECT
[a].[date] AS 'Date'
,[b].[amt] AS 'Amount'
,[b].[code] AS 'Code'
,[c].[type] AS 'Type'
FROM [table].[name] (NOLOCK)
LEFT JOIN [table].[name] (NOLOCK) date ON [c].[date] = [b].[date]
LEFT JOIN [table].[name] (NOLOCK) name ON [c].[name] = [b].[name]
WHERE (SELECT date
FROM [t]
WHERE DATEADD (hh,-6, DATEADD (ss,[table].[name],'1970')) BETWEEN '2017-04-01' AND '2018-09-30')
AND [a].[date] = [b].[date] //Not sure if this is what you meant
AND [a].[name] = [b].[name]
AND [c].[name] IS NULL
GROUP BY [a].[date],[b].[amt],[b].[code],[c].[type]
A: With some guesswork involved, I could imagine you want:
SELECT DISTINCT
t.date,
b.amt,
b.code,
c.type
FROM t
LEFT JOIN b
ON b.date = t.date
AND b.name = t.name
LEFT JOIN c
ON c.date = b.date
AND (c.name = b.name
OR c.name is null)
WHERE t.date BETWEEN '2017-04-01'
AND '2018-09-30';
*
*Your subquery from t isn't really needed, that check on date can be moved in the WHERE clause. But it wasn't strictly wrong. It depends on what the optimizer makes of it what's better.
*Though your GROUP BY has the same effect, I changed it to a DISTINCT, which might be more clear to understand at a glance.
*And I'm not sure about your join condition for c.
*
*I guessed you want the date to match but allow c.name to be null if it doesn't match. That means you have to use parenthesis to counter the higher precedence of AND over OR.
*You probably want to change the b.s in the join condition to t.s, if record from c should also be added if no matching record from b exists for a record from t. Like it is right now, no record from c is joined for a record from t without a matching record from b.
|
unknown
| |
d19731
|
test
|
One of possible solution is transliteration Cyrillic text into Latin analog. It works but it far from expected results (words pronounces not as good as can be).
var transliterate = function(word) {
var a = { "Ё": "YO", "Й": "I", "Ц": "TS", "У": "U", "К": "K", "Е": "E", "Н": "N", "Г": "G", "Ш": "SH", "Щ": "SCH", "З": "Z", "Х": "H", "Ъ": "'", "ё": "yo", "й": "i", "ц": "ts", "у": "u", "к": "k", "е": "e", "н": "n", "г": "g", "ш": "sh", "щ": "sch", "з": "z", "х": "h", "ъ": "'", "Ф": "F", "Ы": "I", "В": "V", "А": "a", "П": "P", "Р": "R", "О": "O", "Л": "L", "Д": "D", "Ж": "ZH", "Э": "E", "ф": "f", "ы": "i", "в": "v", "а": "a", "п": "p", "р": "r", "о": "o", "л": "l", "д": "d", "ж": "zh", "э": "e", "Я": "Ya", "Ч": "CH", "С": "S", "М": "M", "И": "yi", "Т": "T", "Ь": "'", "Б": "B", "Ю": "YU", "я": "ya", "ч": "ch", "с": "s", "м": "m", "и": "yi", "т": "t", "ь": "'", "б": "b", "ю": "yu" };
return word.split('').map(function(char) {
return a[char] || char;
}).join("");
}
var sayWin = (text) => {
text = /[а-яА-ЯЁё]/.test(text) ? transliterate(text) : text;
var shell = new Shell({
inputEncoding: 'binary'
});
shell.addCommand('Add-Type -AssemblyName System.speech');
shell.addCommand('$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer');
shell.addCommand('$speak.Speak("' + text + '")');
shell.on('output', data => {
console.log("data", data);
});
shell.on('err', err => {
console.log("err", err);
});
shell.on('end', code => {
console.log("code", code);
});
return shell.invoke().then(output => {
shell.dispose()
});
}
A: I may be answering too late, but let it stay here for the future.
I solved this problem for myself by first calling the command:
$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding;
In your case, it will be something like
shell.addCommand('$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding');
|
unknown
| |
d19733
|
test
|
It should simply look like a comma separated values ["aaaaa","bbbb","ccccc"]
That is Set[String], but what you have is Set[Type]. Jackson is doing exactly what it's supposed to do. You need to change your class signature to:
case class Genre(name: String, types: Set[String])
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule
object TestObject {
def main(args: Array[String]): Unit = {
val mapper = new ObjectMapper()
mapper.registerModule(DefaultScalaModule)
val genre = Genre("xxxxxx", Set(new Type("aaaaa"), new Type("bbbb"), new Type("ccccc")))
println("Genre: " + mapper.writeValueAsString(genre))
val anotherGenre = AnotherGenre("xxxxxx", Set("aaaaa", "bbbb", "ccccc"))
println("AnotherGenre: " + mapper.writeValueAsString(anotherGenre))
}
}
class Type(val value: String) extends AnyVal
case class Genre(name: String, types: Set[Type])
case class AnotherGenre(name: String, types: Set[String])
Output:
Genre: {"name":"xxxxxx","types":[{"value":"aaaaa"},{"value":"bbbb"},{"value":"ccccc"}]}
AnotherGenre: {"name":"xxxxxx","types":["aaaaa","bbbb","ccccc"]}
|
unknown
| |
d19735
|
test
|
The method has_object_permission() returns True or False depending in the evaluation of obj.owner == request.user
|
unknown
| |
d19739
|
test
|
You can change the class .input-field, and add more specific selector, for example:
.input-field input
or to email type of input
.input-field input[type=email]
or to focused field:
.input-field input[type=text]:focus
And set the border style:
.input-field input[type=text]:focus{
border-bottom: 1px solid #aaa;
}
You can read more in Materialize documentation: http://materializecss.com/forms.html
EDIT: edited as suggested by @Toby1Kenobi
A: According to the docs you can change the underline colour in CSS by modifying the colour of border-bottom and box-shadow of the element containing the input element (that is the one with the class input-field)
so maybe it would be something like this:
.input-field input[type=email] {
border-bottom: 1px solid red;
box-shadow: 0 1px 0 0 red;
}
|
unknown
| |
d19741
|
test
|
You can use a regular expression like this:
function replaceLetter(str) {
return str.replace(/a/g, 'o');
}
var st = replaceLetter('hahaha');
console.log(st);
Or use another string to accumulate the result like this:
function replaceLetter(str) {
var res = ''; // the accumulator (because string litterals are immutable). It should be initialized to empty string
for(var i = 0; i < str.length; i++) {
var c = str.charAt(i); // get the current character c at index i
if(c == 'a') res += 'o'; // if the character is 'a' then replace it in res with 'o'
else res += c; // otherwise (if it is not 'a') leave c as it is
}
return res;
}
var st = replaceLetter('hahaha');
console.log(st);
A: I always like using split() and join()
var string = "assassination";
var newString = string.split("a").join("o");
A: Strings in Javascript are immutable, and thus any changes to them aren't going to be reflected as you might expect.
Consider just using the string.replace() function instead:
function replaceLetter(string){
// This uses a regular expression to replace all 'a' characters with 'o'
// characters (the /g flag indicates that all should be matched)
return string.replace(/a/g,'o');
}
A: Assuming you want to use a for loop:
function replaceLetter(string){
var result = '';
for (var i = 0; i < string.length; i++) {
result += string[i] === 'a' ? 'o' : string[i];
}
return result;
}
You have to build a new string like this, because as mentioned in a comment, strings are immutable. You can write string[4] = 'b' and it won't cause an error, but it won't do anything either.
It's probably overkill, but you could use reduce, which does the looping internally and maintains the result variable:
const replaceLetter = string =>
[...string].reduce((result, chr) =>
result += (chr === 'a' ? 'o' : chr), '');
However, for this particular case, the regexp solution shown in other answers is probably preferable.
|
unknown
| |
d19743
|
test
|
Looks like this is a known issue/intended. See below:
After further investigation and discussion with the S3 team, I have found that this is expected behavior due to the design of the service. The GET Service call in S3 (s3api list-buckets or s3 ls with no further arguments in the CLI) works differently when being run against different regions. All bucket creations are mastered in us-east-1, then replicated on a global scale - the resulting difference is that there are no "replication" events to the us-east-1 region. The Date Created field displayed in the web console is according to the actual creation date registered in us-east-1, while the AWS CLI and SDKs will display the creation date depending on the specified region (or the default region set in your configuration).
When using an endpoint other than us-east-1, the CreationDate you receive is actually the last modified time according to the bucket's last replication time in this region. This date can change when making changes to your bucket, such as editing its bucket policy. This experienced behavior is result of how S3's architecture has been designed and implemented, making it difficult to change without affecting customers that already expect this behavior.
S3 does intend to change this behavior so that the actual bucket creation date is shown regardless of the region in which the GET Service call is issued, however to answer your question we do not yet have an ETA for the implementation of this change. This change would most likely be announced in the AWS Forums for S3 if you'd like to know when it takes place.
Source
|
unknown
| |
d19745
|
test
|
If directive can be used to provide a condition for the handler to be added only for files matching the pattern in the current folder.
The following example will add the handler for only files in the document root, such as /sitemap.xml and /opensearch.xml but not for /folder/sitemap.xml and /folder/opensearch.xml
<FilesMatch ^(opensearch|sitemap)\.xml$>
<If "%{REQUEST_URI} =~ m#^\/(opensearch|sitemap)\.xml$#">
AddHandler application/x-httpd-php .xml
</If>
</FilesMatch>
In the above example, the condition is checking that the REQUEST_URI matches the regex pattern delimited in m# #.
The ~= comparison operator checks that a string match a regular expression.
The pattern ^\/(opensearch|sitemap)\.xml$ matches REQUEST_URI variable (the path component of the requested URI) such as /opensearch.xml or /sitemap.xml
^ # startwith
\/ # escaped forward-slash
(opensearch|sitemap) # "opensearch" or "sitemap"
\. # .
xml # xml
$ # endwith
A: Have you tried H= in a RewriteRule?
RewriteEngine On
RewriteRule ^(opensearch|sitemap)\.xml$ . [H=application/x-httpd-php5]
Rewrite in htaccess has the built-in property that those filenames in any subdir will have the subdir present in the string the regex tests against so the anchored regex will not match in subdirs.
|
unknown
| |
d19751
|
test
|
Here is the short version of what I've done to make it work. It uses the jade Public API.
var directory = __dirname+'/views/bla/'
, files
, renderedHTML = '';
if( !fs.existsSync(directory) ) {
// directory doesn't exist, in my case I want a 404
return res.status(404).send('404 Not found');
}
// get files in the directory
files = fs.readdirSync(directory);
files.forEach(function(file) {
var template = jade.compile(fs.readFileSync(directory+file, 'utf8'));
// some templating
renderedHTML += '<section><a id="'+file+'" name="'+file+'" class="anchor"> </a>'+template()+'</section>';
});
// render the actual view and pass it the pre rendered views
res.render('view', {
title: 'View',
files: files,
html: renderedHTML
})
And the view just renders the html variable unescaped:
div(class="component-doc-wrap")
!{html}
A: As @user1737909 say, that's not possible using just jade.
The best way to do this (tho) is building a little Express Dynamic (view) Helpers
DEPECATED IN EXPRESS 3.XX
Check these: Jade - way to add dynamic includes
A: in addition to kalemas answer you can also write your includes to a file which is included in jade.
in this example I write my includes to include_all.jade. This file is included in a jade file.
If it does not work, check the path ;-)
e.g.
in your app.js
var includes = "path/to/include1\n";
includes += "path/to/include2";
...
incPath = "path/to/include_all.jade";
fs.open(incPath,'w',function(err,fd){
if(err){
throw 'error open file: ' + incPath +" "+ err;
}
var buffer = new Buffer(includes);
fs.write(fd,buffer,0,buffer.length,null,function(err){
if (err)
throw 'error writing file: ' +err;
fs.close(fd,function(){
console.log('file written ' + incPath);
});
});
});
in your jade file
include path/to/include_all.jade
|
unknown
| |
d19753
|
test
|
find_all has been explained. However, your selector is going to produce duplicates as it will pull the same urls from title and price. Instead, I would use a child combinator and a different class for parent and add a child a tag to get the unique list. I prefer select over find_all. select applies css selectors in order to match on elements. All these a tags have an href so no need to add a test.
from bs4 import BeautifulSoup as bs
import requests
r = requests.get('https://autos.mercadolibre.com.ar/volkswagen/vento/_DisplayType_LF')
soup = bs(r.content, 'lxml')
links = [item['href'] for item in soup.select('.list-view-item-title > a')]
Child combinator:
The child combinator (>) is placed between two CSS selectors. It
matches only those elements matched by the second selector that are
the children of elements matched by the first.
Ref:
*
*https://www.crummy.com/software/BeautifulSoup/bs4/doc/index.html?highlight=select_one#css-selectors
A: Since you are using Beautiful Soup, it is important to understand that the find_all method will return a list of tags that match your requirements. Your issue is that you want the href attribute of those tags. To do that, you can use the notation tag['attr'] on each tag. To do that we will iterate through the returned tags.
from bs4 import BeautifulSoup
import requests
busqueda = requests.get('https://autos.mercadolibre.com.ar/vento/_DisplayType_LF')
auto_cont = BeautifulSoup(busqueda.content)
print([tag['href'] for tag in auto_cont.find_all('a',{'class':'item__info-title'}, href = True)])
A: Try this:
>>> import requests
>>> s = requests.Session()
>>> resp = s.get("https://autos.mercadolibre.com.ar/vento/_DisplayType_LF")
>>> from lxml import html
>>> doc = html.fromstring(resp.text)
>>> doc.xpath("//a[@class='item__info-title']")
[<Element a at 0x11c005688>, <Element a at 0x11c0059a8>, <Element a at 0x11c007e58>, <Element a at 0x11c007ea8>, <Element a at 0x11c007ef8>, <Element a at 0x11c007c78>, <Element a at 0x11c007db8>, <Element a at 0x11c007e08>, <Element a at 0x11c007d68>, <Element a at 0x11c007cc8>, <Element a at 0x11c007d18>, <Element a at 0x11c007bd8>, <Element a at 0x11c007c28>, <Element a at 0x11c007228>, <Element a at 0x11c003318>, <Element a at 0x11c003408>, <Element a at 0x11c0034f8>, <Element a at 0x11c003688>, <Element a at 0x11c0035e8>, <Element a at 0x11c003228>, <Element a at 0x11c003598>, <Element a at 0x11c003458>, <Element a at 0x11c003278>, <Element a at 0x11c003548>, <Element a at 0x11c0034a8>, <Element a at 0x11c003368>, <Element a at 0x11c0033b8>, <Element a at 0x11c0032c8>, <Element a at 0x11c0031d8>, <Element a at 0x11c003188>, <Element a at 0x11c003098>, <Element a at 0x11c003138>, <Element a at 0x11c0030e8>, <Element a at 0x11c003048>, <Element a at 0x11c0036d8>, <Element a at 0x11c003728>, <Element a at 0x11c003778>, <Element a at 0x11c0037c8>, <Element a at 0x11c003818>, <Element a at 0x11c003868>, <Element a at 0x11c0038b8>, <Element a at 0x11c003908>, <Element a at 0x11c003958>, <Element a at 0x11c0039a8>, <Element a at 0x11c0039f8>, <Element a at 0x11c003a48>, <Element a at 0x11c003a98>, <Element a at 0x11c003ae8>, <Element a at 0x11c003b38>, <Element a at 0x11c003b88>, <Element a at 0x11c003bd8>, <Element a at 0x11c003c28>, <Element a at 0x11c003c78>, <Element a at 0x11c003cc8>, <Element a at 0x11c003d18>, <Element a at 0x11c003d68>, <Element a at 0x11c003db8>, <Element a at 0x11c003e08>, <Element a at 0x11c003e58>, <Element a at 0x11c003ea8>, <Element a at 0x11c003ef8>, <Element a at 0x11c003f48>, <Element a at 0x11c003f98>, <Element a at 0x11c006048>, <Element a at 0x11c006098>, <Element a at 0x11c0060e8>, <Element a at 0x11c006138>, <Element a at 0x11c006188>, <Element a at 0x11c0061d8>, <Element a at 0x11c006228>, <Element a at 0x11c006278>, <Element a at 0x11c0062c8>, <Element a at 0x11c006318>, <Element a at 0x11c006368>, <Element a at 0x11c0063b8>, <Element a at 0x11c006408>, <Element a at 0x11c006458>, <Element a at 0x11c0064a8>, <Element a at 0x11c0064f8>, <Element a at 0x11c006548>, <Element a at 0x11c006598>, <Element a at 0x11c0065e8>, <Element a at 0x11c006638>, <Element a at 0x11c006688>, <Element a at 0x11c0066d8>, <Element a at 0x11c006728>, <Element a at 0x11c006778>, <Element a at 0x11c0067c8>, <Element a at 0x11c006818>, <Element a at 0x11c006868>, <Element a at 0x11c0068b8>, <Element a at 0x11c006908>, <Element a at 0x11c006958>, <Element a at 0x11c0069a8>, <Element a at 0x11c0069f8>, <Element a at 0x11c006a48>, <Element a at 0x11c006a98>, <Element a at 0x11c006ae8>, <Element a at 0x11c006b38>, <Element a at 0x11c006b88>]
>>> doc.xpath("//a[@class='item__info-title']/@href")
['https://auto.mercadolibre.com.ar/MLA-793135798-volkswagen-vento-20t-sportline-2007-4p-dh-aa-san-blas-auto-_JM', 'https://auto.mercadolibre.com.ar/MLA-793135798-volkswagen-vento-20t-sportline-2007-4p-dh-aa-san-blas-auto-_JM', 'https://auto.mercadolibre.com.ar/MLA-788603493-volkswagen-vento-25-advance-plus-manual-2015-rpm-moviles-_JM', 'https://auto.mercadolibre.com.ar/MLA-788603493-volkswagen-vento-25-advance-plus-manual-2015-rpm-moviles-_JM', 'https://auto.mercadolibre.com.ar/MLA-774423219-vento-comfortline-0km-2019-volkswagen-linea-nueva-vw-2018-_JM', 'https://auto.mercadolibre.com.ar/MLA-774423219-vento-comfortline-0km-2019-volkswagen-linea-nueva-vw-2018-_JM', 'https://auto.mercadolibre.com.ar/MLA-795714156-volksvagen-vento-advance-plus-25-anticipo-290000-y-ctas-_JM', 'https://auto.mercadolibre.com.ar/MLA-795714156-volksvagen-vento-advance-plus-25-anticipo-290000-y-ctas-_JM', 'https://auto.mercadolibre.com.ar/MLA-792330462-volkswagen-vento-25-luxury-wood-tiptronic-2009-imolaautos--_JM', 'https://auto.mercadolibre.com.ar/MLA-792330462-volkswagen-vento-25-luxury-wood-tiptronic-2009-imolaautos--_JM', 'https://auto.mercadolibre.com.ar/MLA-763941297-vento-highline-0km-automatico-auto-nuevos-volkswagen-vw-2019-_JM', 'https://auto.mercadolibre.com.ar/MLA-763941297-vento-highline-0km-automatico-auto-nuevos-volkswagen-vw-2019-_JM', 'https://auto.mercadolibre.com.ar/MLA-791000164-volkswagen-vento-20-advance-115cv-2015-_JM', 'https://auto.mercadolibre.com.ar/MLA-791000164-volkswagen-vento-20-advance-115cv-2015-_JM', 'https://auto.mercadolibre.com.ar/MLA-788125558-volkswagen-vento-14-tsi-highline-150cv-at-2017-rpm-moviles-_JM', 'https://auto.mercadolibre.com.ar/MLA-788125558-volkswagen-vento-14-tsi-highline-150cv-at-2017-rpm-moviles-_JM', 'https://auto.mercadolibre.com.ar/MLA-777140113-volkswagen-vento-gli-dsg-nav-my-18-_JM', 'https://auto.mercadolibre.com.ar/MLA-777140113-volkswagen-vento-gli-dsg-nav-my-18-_JM', 'https://auto.mercadolibre.com.ar/MLA-795016462-volkswagen-vento-25-luxury-tiptronic-2011-imolaautos--_JM', 'https://auto.mercadolibre.com.ar/MLA-795016462-volkswagen-vento-25-luxury-tiptronic-2011-imolaautos--_JM', 'https://auto.mercadolibre.com.ar/MLA-792487602-volkswagen-25-luxury-170cv-tiptronic-2015-rpm-moviles-_JM', 'https://auto.mercadolibre.com.ar/MLA-792487602-volkswagen-25-luxury-170cv-tiptronic-2015-rpm-moviles-_JM', 'https://auto.mercadolibre.com.ar/MLA-789645020-volkswagen-vento-20-advance-115cv-summer-package-371-_JM', 'https://auto.mercadolibre.com.ar/MLA-789645020-volkswagen-vento-20-advance-115cv-summer-package-371-_JM', 'https://auto.mercadolibre.com.ar/MLA-775185003-vw-0km-volkswagen-vento-14-comfortline-highline-financiado-_JM', 'https://auto.mercadolibre.com.ar/MLA-775185003-vw-0km-volkswagen-vento-14-comfortline-highline-financiado-_JM', 'https://auto.mercadolibre.com.ar/MLA-774502893-volkswagen-vento-14-comfortline-150cv-at-dsg-0km-2019-vw-_JM', 'https://auto.mercadolibre.com.ar/MLA-774502893-volkswagen-vento-14-comfortline-150cv-at-dsg-0km-2019-vw-_JM', 'https://auto.mercadolibre.com.ar/MLA-795734858-volkswagen-vento-25-luxury-tiptronic-2009-_JM', 'https://auto.mercadolibre.com.ar/MLA-795734858-volkswagen-vento-25-luxury-tiptronic-2009-_JM', 'https://auto.mercadolibre.com.ar/MLA-795501655-volkswagen-vento-25-luxury-170cv-_JM', 'https://auto.mercadolibre.com.ar/MLA-795501655-volkswagen-vento-25-luxury-170cv-_JM', 'https://auto.mercadolibre.com.ar/MLA-792476554-volkswagen-vento-14-comfortline-150cv-at-_JM', 'https://auto.mercadolibre.com.ar/MLA-792476554-volkswagen-vento-14-comfortline-150cv-at-_JM', 'https://auto.mercadolibre.com.ar/MLA-790622152-volkswagen-vento-14-tsi-comfortline-dsg-como-nuevo-_JM', 'https://auto.mercadolibre.com.ar/MLA-790622152-volkswagen-vento-14-tsi-comfortline-dsg-como-nuevo-_JM', 'https://auto.mercadolibre.com.ar/MLA-741867064-volkswagen-vento-14-comfortline-150cv-at-_JM', 'https://auto.mercadolibre.com.ar/MLA-741867064-volkswagen-vento-14-comfortline-150cv-at-_JM', 'https://auto.mercadolibre.com.ar/MLA-770677950-volkswagen-vento-20-sportline-tsi-200cv-dgs-_JM', 'https://auto.mercadolibre.com.ar/MLA-770677950-volkswagen-vento-20-sportline-tsi-200cv-dgs-_JM', 'https://auto.mercadolibre.com.ar/MLA-756888148-volkswagen-vento-14-highline-150cv-at-_JM', 'https://auto.mercadolibre.com.ar/MLA-756888148-volkswagen-vento-14-highline-150cv-at-_JM', 'https://auto.mercadolibre.com.ar/MLA-792470321-volkswagen-vento-highline-14-at-_JM', 'https://auto.mercadolibre.com.ar/MLA-792470321-volkswagen-vento-highline-14-at-_JM', 'https://auto.mercadolibre.com.ar/MLA-780443475-volkswagen-vento-20-sportline-tsi-200cv-bi-xenon-_JM', 'https://auto.mercadolibre.com.ar/MLA-780443475-volkswagen-vento-20-sportline-tsi-200cv-bi-xenon-_JM', 'https://auto.mercadolibre.com.ar/MLA-775185107-vw-0km-volkswagen-vento-14-comfortline-highline-financio-ya-_JM', 'https://auto.mercadolibre.com.ar/MLA-775185107-vw-0km-volkswagen-vento-14-comfortline-highline-financio-ya-_JM', 'https://auto.mercadolibre.com.ar/MLA-763006237-volkswagen-nuevo-vento-comfortline-14-tsi-150cv-autotag-a7-_JM', 'https://auto.mercadolibre.com.ar/MLA-763006237-volkswagen-nuevo-vento-comfortline-14-tsi-150cv-autotag-a7-_JM', 'https://auto.mercadolibre.com.ar/MLA-792344363-volkswagen-vento-14-comfortline-150cv-at-_JM', 'https://auto.mercadolibre.com.ar/MLA-792344363-volkswagen-vento-14-comfortline-150cv-at-_JM', 'https://auto.mercadolibre.com.ar/MLA-789195021-volkswagen-vento-comfortline-motor-14-at-tiptronic-_JM', 'https://auto.mercadolibre.com.ar/MLA-789195021-volkswagen-vento-comfortline-motor-14-at-tiptronic-_JM', 'https://auto.mercadolibre.com.ar/MLA-787103884-volkswagen-vento-comfortline-14-150-cv-dsg-_JM', 'https://auto.mercadolibre.com.ar/MLA-787103884-volkswagen-vento-comfortline-14-150-cv-dsg-_JM', 'https://auto.mercadolibre.com.ar/MLA-795438039-volkswagen-vento-14-highline-150cv-at-financio-leasing-0km-_JM', 'https://auto.mercadolibre.com.ar/MLA-795438039-volkswagen-vento-14-highline-150cv-at-financio-leasing-0km-_JM', 'https://auto.mercadolibre.com.ar/MLA-785080712-vento-25-advance-manual-permutofinancio-_JM', 'https://auto.mercadolibre.com.ar/MLA-785080712-vento-25-advance-manual-permutofinancio-_JM', 'https://auto.mercadolibre.com.ar/MLA-739533930-volkswagen-vento-20-tsi-i-2017-i-permuto-i-financio-_JM', 'https://auto.mercadolibre.com.ar/MLA-739533930-volkswagen-vento-20-tsi-i-2017-i-permuto-i-financio-_JM', 'https://auto.mercadolibre.com.ar/MLA-787212749-volkswagen-vento-14-comfortline-150cv-at-_JM', 'https://auto.mercadolibre.com.ar/MLA-787212749-volkswagen-vento-14-comfortline-150cv-at-_JM', 'https://auto.mercadolibre.com.ar/MLA-785738851-volkswagen-vento-advance-summer-package-20-unico-dueno--_JM', 'https://auto.mercadolibre.com.ar/MLA-785738851-volkswagen-vento-advance-summer-package-20-unico-dueno--_JM', 'https://auto.mercadolibre.com.ar/MLA-788508924-volkswagen-vento-25-advance-tiptronic-2007-_JM', 'https://auto.mercadolibre.com.ar/MLA-788508924-volkswagen-vento-25-advance-tiptronic-2007-_JM', 'https://auto.mercadolibre.com.ar/MLA-790696083-volkswagen-vento-14-highline-150cv-at-0km-tiptronic-nuevo-1-_JM', 'https://auto.mercadolibre.com.ar/MLA-790696083-volkswagen-vento-14-highline-150cv-at-0km-tiptronic-nuevo-1-_JM', 'https://auto.mercadolibre.com.ar/MLA-788446116-volkswagen-vento-20-sportline-tsi-200-2013-luxury-tdi-bora-_JM', 'https://auto.mercadolibre.com.ar/MLA-788446116-volkswagen-vento-20-sportline-tsi-200-2013-luxury-tdi-bora-_JM', 'https://auto.mercadolibre.com.ar/MLA-752087027-volkswagen-nuevo-vento-14-highline-0-km-2019-autotag-cb-a7-_JM', 'https://auto.mercadolibre.com.ar/MLA-752087027-volkswagen-nuevo-vento-14-highline-0-km-2019-autotag-cb-a7-_JM', 'https://auto.mercadolibre.com.ar/MLA-781505508-nuevo-vento-entrega-inmediata-tomo-usado-moto-auto-18-_JM', 'https://auto.mercadolibre.com.ar/MLA-781505508-nuevo-vento-entrega-inmediata-tomo-usado-moto-auto-18-_JM', 'https://auto.mercadolibre.com.ar/MLA-742485511-volkswagen-vento-14-highline-150cv-0km-_JM', 'https://auto.mercadolibre.com.ar/MLA-742485511-volkswagen-vento-14-highline-150cv-0km-_JM', 'https://auto.mercadolibre.com.ar/MLA-769182377-vw-volkswagen-vento-gli-230-cv-preventa-2019-0-km-_JM', 'https://auto.mercadolibre.com.ar/MLA-769182377-vw-volkswagen-vento-gli-230-cv-preventa-2019-0-km-_JM', 'https://auto.mercadolibre.com.ar/MLA-790609996-volkswagen-vento-20-luxury-i-140cv-dsg-automatico-diesel-_JM', 'https://auto.mercadolibre.com.ar/MLA-790609996-volkswagen-vento-20-luxury-i-140cv-dsg-automatico-diesel-_JM', 'https://auto.mercadolibre.com.ar/MLA-790664862-volkswagen-vento-25-luxury-170cv-_JM', 'https://auto.mercadolibre.com.ar/MLA-790664862-volkswagen-vento-25-luxury-170cv-_JM', 'https://auto.mercadolibre.com.ar/MLA-784454164-volkswagen-vento-25-luxury-170cv-_JM', 'https://auto.mercadolibre.com.ar/MLA-784454164-volkswagen-vento-25-luxury-170cv-_JM', 'https://auto.mercadolibre.com.ar/MLA-769868579-0km-volkswagen-vento-14-highline-150cv-at-2019-tasa-159-d-_JM', 'https://auto.mercadolibre.com.ar/MLA-769868579-0km-volkswagen-vento-14-highline-150cv-at-2019-tasa-159-d-_JM', 'https://auto.mercadolibre.com.ar/MLA-787564006-volkswagen-vento-20t-sportline-automatico-dsg-2013-_JM', 'https://auto.mercadolibre.com.ar/MLA-787564006-volkswagen-vento-20t-sportline-automatico-dsg-2013-_JM', 'https://auto.mercadolibre.com.ar/MLA-788080154-volkswagen-vento-20-sportline-tsi-200cv-dgs-2013-_JM', 'https://auto.mercadolibre.com.ar/MLA-788080154-volkswagen-vento-20-sportline-tsi-200cv-dgs-2013-_JM', 'https://auto.mercadolibre.com.ar/MLA-771885864-volkswagen-vento-14-comfortline-150cv-aut-sf-_JM', 'https://auto.mercadolibre.com.ar/MLA-771885864-volkswagen-vento-14-comfortline-150cv-aut-sf-_JM', 'https://auto.mercadolibre.com.ar/MLA-795273990-vento-25-manual-unico-dueno-80000-km-motor-cadenero-_JM', 'https://auto.mercadolibre.com.ar/MLA-795273990-vento-25-manual-unico-dueno-80000-km-motor-cadenero-_JM', 'https://auto.mercadolibre.com.ar/MLA-769870550-0km-volkswagen-vento-14-highline-150cv-at-2019-tasa-159-f-_JM', 'https://auto.mercadolibre.com.ar/MLA-769870550-0km-volkswagen-vento-14-highline-150cv-at-2019-tasa-159-f-_JM', 'https://auto.mercadolibre.com.ar/MLA-790653682-volkswagen-vento-25-triptronic-170-cv-cuero-carhaus-_JM', 'https://auto.mercadolibre.com.ar/MLA-790653682-volkswagen-vento-25-triptronic-170-cv-cuero-carhaus-_JM']
|
unknown
| |
d19755
|
test
|
This should work, assuming config-app.properties exists in the class path (in the root). You should not get the error "Can't find resource for bundle java.util.PropertyResourceBundle".
However, what you're trying to do, by substituting ${smtp.host.name.env}, will NOT work with ResourceBundle. You would need another library to do something more complicated like that.
UPDATED
It's not clear what you're trying to do, but assuming you want to have profile for developement and another one for production, you could try to do something like this:
Properties defaultProperties = new Properties();
defaultProperties.load(new FileInputStream("config-app.properties"));
Properties properties = new Properties(defaultProperties);
if (isDev()) {
properties.load(new FileInputStream("config-dev.properties"));
} else {
properties.load(new FileInputStream("whatever.properties"));
}
properties.getProperty("smtp.host.name");
This will have default settings in config-app.properties, which can be overwritten in config-dev.properties or whatever.properties as needed. In this case the keep must be the same.
config-app.properties:
smtp.host.name =localhost
config-dev.properties:
smtp.host.name =smtp.gmail.com
One last note, the previous code is loading the files from the filesystem, if you have them in the classpath, use something like :
defaultProperties.load(Classname.class.getClassLoader().getResourceAsStream("config-app.properties"));
|
unknown
| |
d19757
|
test
|
Essentially, you'd want to go over the first list, and for each item go over the second list and check if any interval overlaps it. Streams make this a tad more elegant:
List<Interval> list1 = // some intervals...
List<Interval> list2 = // some more internvals...
List<Interval> result =
list1.stream()
.filter(i1 -> list2.stream().allMatch(i2 -> i1.overlap(i2) == null))
.collect(Collectors.toList());
|
unknown
| |
d19761
|
test
|
D'oh! Resolved.
GD Library wasn't installed. When I installed it, all was well!
|
unknown
| |
d19763
|
test
|
Try to use:
animalQuestion.append((orderlist: orderlist, questionid: questionid, question: question, description: description))
And do not forgot:
let orderlist = row[4] as Int
Your code incorrect because of:
1) For appending new objects to array you must to use array-method
animalQuestion.append(<Array object>)
2) In your case Array object is a tuple. So first you need to create a tuple, something like:
let orderTuple = (orderlist, questionid, question, description)
and after that appaned orderTuple to animalQuestion array like:
animalQuestion.append(orderTuple)
|
unknown
| |
d19765
|
test
|
You can just create controller for root route.
class RoutesController < ActionController::Base
before_filter :authenticate_user!
def root
root_p = case current_user.role
when 'admin'
SOME_ADMIN_PATH
when 'manager'
SOME_MANAGER_PATH
else
SOME_DEFAULT_PATH
end
redirect_to root_p
end
end
In your routes.rb:
root 'routes#root'
P.S. example expects using Devise, but you can customize it for your needs.
A: There are a few different options:
1. lambda in the routes file(not very railsy)
previously explained
2. redirection in application controller based on a before filter(this is optimal but your admin route will not be at the root)
source rails guides - routing
you would have two routes, and two controllers. for example you might have a HomeController and then an AdminController. Each of those would have an index action.
your config/routes.rb file would have
namespace :admin do
root to: "admin#index"
end
root to: "home#index"
The namespace method gives you a route at /admin and the regular root would be accessible at '/'
Then to be safe; in your admin controller add a before_filter to redirect any non admins, and in your home controller you could redirect any admin users.
3. dynamically changing the layout based on user role.
In the same controller that your root is going to, add a helper method that changes the layout.
layout :admin_layout_filter
private
def admin_layout_filter
if admin_user?
"admin"
else
"application"
end
end
def admin_user?
current_user.present? && current_user.admin?
end
Then in your layouts folder, add a file called admin.html.erb
source: rails guides - layouts and routing
A: You can't truly change the root dynamically, but there's a couple of ways you can fake it.
The solution you want needs to take place in either your application controller or the "default" root controller. The cleanest/easiest solution is simply to have your application controller redirect to the appropriate action in a before filter that only runs for that page. This will cause the users' url to change, however, and they won't really be at the root anymore.
Your second option is to have the method you've specified as root render a different view under whatever conditions you're looking for. If this requires any major changes in logic beyond simply loading a separate view, however, you're better off redirecting.
|
unknown
| |
d19769
|
test
|
I dont' think this is possible with pure CSS. The only think I could think of is using position: absolute for <img> to take it out of the flow in combination with max-height; then adjusting the margin of the text with javascript.
https://jsfiddle.net/zphb0fLd/
Hope it's useful.
A: Well as far as my knowledge, the image size can be increased with relative to text size, but its opposite case is not possible.
Here is my code. I use the flexbox to increase the height of the image as per text size. Let me know if it meets your requirements.
<div class="flex">
<div class="image-container">
<img src="https://via.placeholder.com/300x300" alt="">
</div>
<div class="text-container">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis facilisis nisi elit, vitae interdum nisi porttitor a. Maecenas porta mollis venenatis. Proin suscipit, est et malesuada ultricies, nisi elit aliquam arcu, et luctus felis dolor euismod ante. Praesent nec malesuada arcu. Nunc rutrum erat risus, id elementum leo dignissim eu. Fusce feugiat, massa vestibulum venenatis ullamcorper, nisl justo aliquam purus, nec pellentesque tellus magna non quam. Pellentesque luctus quam in justo congue tempor. Cras placerat sit amet nulla id pretium. Nulla facilisi. Phasellus dictum neque sed lacus congue, vel dapibus enim efficitur.
</p>
</div>
</div>
.flex{
display:flex;
flex-wrap:wrap;
}
.image-container{
flex:1;
}
.text-container{
flex:3;
}
.text-container p{
font-size:2em;
padding:10px;
}
.image-container img{
width:100%;
height:100%;
object-fit:cover;
}
Live example link: https://codepen.io/pranaysharma995/pen/JjdQWyQ
|
unknown
| |
d19771
|
test
|
I don't think Meteor's tracker works well with ReactJS, as their mechanism of re-render is different.
You might want to use this package.
https://github.com/meteor/react-packages/tree/devel/packages/react-meteor-data
You can use it like so.
import { Meteor } from 'meteor/meteor';
import { mount } from 'react-mounter';
import { withTracker } from 'meteor/react-meteor-data';
import { IndexPage } from "./index-page";
FlowRouter.route('/', {
action: () => {
mount(IndexPageContainer, {});
}
});
export const IndexPageContainer = withTracker(() => {
Meteor.subscribe('whatever');
return {
Meteor: {
collection: {
whatever: Whatever.find().fetch()
},
user: Meteor.user(),
userId: Meteor.userId(),
status: Meteor.status(),
loggingIn: Meteor.loggingIn()
}
};
})(IndexPage);
Where IndexPage is your actual component.
You can then access the db by this.props.Meteor.collection.whatever.find()
|
unknown
| |
d19773
|
test
|
There is a question mark because the encoding process recognizes that the encoding can't support the character, and substitutes a question mark instead. By "if you're really good," he means, "if you have a newer browser and proper font support," you'll get a fancier substitution character, a box.
In Joel's case, he isn't trying to display a real character, he literally included the Unicode replacement character, U+FFFD REPLACEMENT CHARACTER.
A: It’s a rather confusing paragraph, and I don’t really know what the author is trying to say. Anyway, different browsers (and other programs) have different ways of handling problems with characters. A question mark “?” may appear in place of a character for which there is no glyph in the font(s) being used, so that it effectively says “I cannot display the character.” Browsers may alternatively use a small rectangle, or some other indicator, for the same purpose.
But the “�” symbol is REPLACEMENT CHARACTER that is normally used to indicate data error, e.g. when character data has been converted from some encoding to Unicode and it has contained some character that cannot be represented in Unicode. Browsers often use “�” in display for a related purpose: to indicate that character data is malformed, containing bytes that do not constitute a character, in the character encoding being applied. This often happens when data in some encoding is being handled as if it were in some other encoding.
So “�” does not really mean “unknown character”, still less “undisplayable character”. Rather, it means “not a character”.
A: A question mark appears when a byte sequence in the raw data does not match the data's character set so it cannot be decoded properly. That happens if the data is malformed, if the data's charset is explicitally stated incorrectly in the HTTP headers or the HTML itself, the charset is guessed incorrectly by the browser when other information is missing, or the user's browser settings override the data's charset with an incompatible charset.
A box appears when a decoded character does not exist in the font that is being used to display the data.
A: Just what it says - some browsers show "a weird character" or a question mark for characters outside of the current known character set. It's their "hey, I don't know what this is" character. Get an old version of Netscape, paste some text form Microsoft Word which is using smart quotes, and you'll get question marks.
http://blog.salientdigital.com/2009/06/06/special-characters-showing-up-as-a-question-mark-inside-of-a-black-diamond/ has a decent explanation.
|
unknown
| |
d19775
|
test
|
You don't have a class as much as you have a dictionary of string and objects. If you do the following, you should be able to deserialize properly:
public class PeopleResponse
{
public Dictionary<string, Info> people { get; set; }
public string hede { get; set; }
public string hodo { get; set; }
}
public class Info
{
public string condition { get; set; }
public string version { get; set; }
}
From there, you should be able to do:
var results = JsonConvert.DeserializeObject<PeopleResponse>("{myJSONGoesHere}");
Edit: Based on your updated question, if you would like to get the names of all whose condition is "good," you can do the following (assuming your deserialized object is called results:
var goodStuff = from p in results.people
where p.Value.condition.ToLower() == "good"
select p.Key;
You could, of course, just get p instead of p.Key, which would return the entire key/value pair.
|
unknown
| |
d19781
|
test
|
I finally solve the problem. I don't know why W3 Total Cache create problems with the jquerys. This was the error on some parts of the web:
Uncaught TypeError: $ is not a function
So I fix it adding this: jQuery(function($)...) instead of function() and now is ok.
I don't know why this happened, all the other pages are working ok, and as I said the only thing that was diferent with this was that plugin.
|
unknown
| |
d19783
|
test
|
This works for me but I am not sure if it's the creator's intention.
from google.cloud import monitoring_v3
from google.cloud.monitoring_v3 import query
project = "..."
client = monitoring_v3.MetricServiceClient()
result = query.Query(
client,
project,
'pubsub.googleapis.com/subscription/num_undelivered_messages',
minutes=1).as_dataframe()
A: You might need to run your code this way for a specific subscription:
from google.cloud import monitoring_v3
from google.cloud.monitoring_v3 import query
project = "my-project"
client = monitoring_v3.MetricServiceClient()
result = query.Query(client,project,'pubsub.googleapis.com/subscription/num_undelivered_messages', minutes=60).as_dataframe()
print(result['pubsub_subscription'][project]['subscription_name'][0])
|
unknown
| |
d19785
|
test
|
Please never run a networking operation on the main (UI) thread .
Main thread is used to:
*
*interact with user.
*render UI components.
any long operation on it may risk your app to be closed with ANR message.
Take a look at the following :
*
*Keeping your application Responsive
*NetworkOnMainThreadException
you can easily use an AsyncTask or a Thread to perform your network operations.
Here is a great tutorial about threads and background work in android: Link
A: Works for me:
Manifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
.java:
private static boolean DEVELOPER_MODE = true;
...
protected void onCreate(Bundle savedInstanceState) {
if (DEVELOPER_MODE) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork() // or .detectAll() for all detectable problems
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.detectLeakedClosableObjects()
.penaltyLog()
.penaltyDeath()
.build());
}
...
hope it helps.
see also : http://developer.android.com/reference/android/os/StrictMode.html
|
unknown
| |
d19789
|
test
|
This doesn't answer the question as it was asked, but I'll risk my reputation and suggest a different solution.
PLEASE, do yourself a favor and never use MessageBox() or other modal UI to display debug information. If you do want to interrupt program execution at that point, use the breakpoint; it also allows you to attach the condition, so that you don't need to examine the value manually.
If you do not want the interruption, just print the value to a debug output window using ::OutputDebugString(). That can be seen in the debugger if it is attached, or via DebugView tool.
Another small suggestion (for Visual Studio users): if you prepend your output with a source file name and the code line number, double-clicking on that line in the output window will take you straight to that line. Just use __FILE__ and __LINE__ in your formatted string.
A: You can't. The preprocessor doesn't know anything about variables or their values, because it doesn't do anything run-time only at compile-time.
A: You can use variable argument list
#include <stdio.h>
void message(const char* format, ...)
{
int len;
char *buf;
va_list args;
va_start(args, format);
len = _vscprintf(format, args) + 1; //add room for terminating '\0'
buf = (char*)malloc(len * sizeof(char));
vsprintf_s(buf, len, format, args);
MessageBoxA(0,buf,"debug",0);
//OutputDebugStringA(buf);
free(buf);
}
message("test %s %d %d %d", "str", 1, 2, 3);
You might also want to change to unicode version.
A: You need to "print" the variable to a buffer (array of char) using something like sprintf (or snprintf in VS 2015) and pass the resulting output to MessageBox as the string to be displayed.
|
unknown
| |
d19797
|
test
|
Since its a daterange picker you choose a range.
I guess from the moment you choose the starting date, the ending date cannot be older than the starting one.
|
unknown
| |
d19799
|
test
|
substr() is the key to your answer here.
You will want to loop through the input string 10 characters at a time to create each line.
<?php
$input = 'hola como estas 0001 hola 02hola como estas';
$output = '';
$stringLength = strlen($input) / 10; // 10 is for number of characters per line
$linesProcessed = 0;
while ($linesProcessed < $stringLength) {
$output .= substr($input, ($linesProcessed * 10), 10) . PHP_EOL;
$linesProcessed++;
}
echo $output;
The output is:
hola como
estas 0001
hola 02ho
la como es
tas
(Note: Use nl2br() or use the CSS style whitespace: pre if you're displaying this in HTML).
|
unknown
| |
d19801
|
test
|
A simple way to do it is to put your GDI+ 1.1 code in #ifdefs and compile it to two different DLLs -- one with the code and one without. Then at runtime load the DLL that will work. Maybe you could even attempt to load the 1.1 DLL and if that fails fall back to the 1.0 DLL.
|
unknown
| |
d19803
|
test
|
using the requests and lxml libraries (lxml for xpath) this becomes a fairly straightforward task:
1 import requests
2 from lxml import etree
3
4 s = requests.session()
5 r = s.get("https://fbref.com/fr/comps/13/calendrier/Scores-et-tableaux-Ligue-1")
6 tree = etree.HTML(r.content)
7 matchreporturls = tree.xpath('//td[@data-stat="match_report"]/a[text()="Rapport de match "]/@href')
8
9 for matchreport in matchreporturls:
10 r = s.get("https://fbref.com" + matchreport)
11 # do something with the response data
12 print('scraped {0}'.format(r.url))
|
unknown
| |
d19809
|
test
|
<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
In the above script the tag sensor is not required in "src" instead of that please provide a googlemapapi key, it will work!!
eg:
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=paste your key here"></script>
Get your key:
https://developers.google.com/maps/documentation/javascript/get-api-key#key
Thanks!!!
|
unknown
| |
d19811
|
test
|
After doing some more digging I found what I was looking for. I found a rather well written example (in C#) of a technique called polygon clipping. This method finds the contact points in world coordinates. It goes through all the steps and code implementation for multiple different situations.
Here is the url: http://www.codezealot.org/archives/394
|
unknown
| |
d19815
|
test
|
Okay, the problem is solved. The code shown above is working. There seems to be a problem with the opened docx document (a customer form) - it may be corrupt.
After using another form the code works :/
|
unknown
| |
d19817
|
test
|
You should probably look at the CJK package that is in the contrib area of Lucene. There is an analyzer and a tokenizer specifically for dealing with Chinese, Japanese, and Korean.
A: I found lucene-gosen while doing a search for my own purposes:
Their example looks fairly decent, but I guess it's the kind of thing that needs extensive testing. I'm also worried about their backwards-compatibility policy (or rather, the complete lack of one.)
|
unknown
| |
d19819
|
test
|
You can use this regular expression to extract all rgb codes:
var regex = /rgb\(([^\)]+)\)/g;
A: You can use this:
string.replace(/^.*?linear-gradient *\((.+)/, function($1, $2) {
return $1.match(/rgb *\([^)]+\)/g); } );
//=> rgb(100, 106, 237),rgb(101, 222, 108)
Assuming there is no other rgb segment outside closing bracket of linear-gradient
A: There is no need for your first extracting. Try the following:
var re = /rgb\(\d{1,3}, ?\d{1,3}, ?\d{1,3}\)/g;
// and then get array of matches
var rgbs = string.match(re);
//It will be equal to null if there is no matches.
|
unknown
| |
d19821
|
test
|
The Session_End event fires when the server-side session times out, which is (default) 20 minutes after the last request has been served. The server does NOT know when the user "navigates away" or "closes the browser", so can't act on that.
A: You could use onUserExit jQuery plugin to call some server side code and abandon the session. Activate onUserExit on document ready :
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery().onUserExit({
execute: function () {
jQuery.ajax({
url: '/EndSession.ashx', async: false
});
},
internalURLs: 'www.yourdomain.com|yourdomain.com'
});
});
</script>
And in EndSession.ashx abandon the session and server side Session_End will be called :
public void ProcessRequest(HttpContext context)
{
context.Session.Abandon();
context.Response.ContentType = "text/plain";
context.Response.Write("My session abandoned !");
}
note that this will not cover all cases (for example if user kills browser trough task manager).
A: No, It will take time to update until session is timedout...
A: It's the limitation of this approach that server will think user is logged in unless the session ends actually; which will happen only when the number of minutes has passed as specified in the session timeout configuration.
Check this post: http://forums.asp.net/t/1283350.aspx
Found this Online-active-users-counter-in-ASP-NET
|
unknown
| |
d19823
|
test
|
Using template_redirect hook, you can redirect user to a specific page when there is "no results found" on a product query search, like:
add_action( 'template_redirect', 'no_products_found_redirect' );
function no_products_found_redirect() {
global $wp_query;
if( isset($_GET['s']) && isset($_GET['post_type']) && 'product' === $_GET['post_type']
&& ! empty($wp_query) && $wp_query->post_count == 0 ) {
wp_redirect( get_permalink( 99 ) );
exit();
}
}
Code goes in functions.php file of your active child theme (or active theme). Tested and works.
|
unknown
| |
d19825
|
test
|
Try some thing like this.
array.map(snippet => (
<>
{snippet.question.map(que => {
if (que.type === "text") {
return <Typography>{que.value}</Typography>;
} else if (que.type === "number") {
return <Number>{que.value}</Number>;
}
return null;
})}
{snippet.answer.map(ans => {
if (ans.type === "text") {
return <Typography>{ans.value}</Typography>;
} else if (ans.type === "number") {
return <Number>{ans.value}</Number>;
}
return null;
})}
</>
));
|
unknown
| |
d19831
|
test
|
You have not mentioned which the Azure IoT Hub scale tier is used. Basically there are two price groups such as Basic and Standard with a significant different cost and capabilities. The Basic tier offers only services for one-way communications between the devices and Azure IoT Hub.
Based on that, the following scenarios can be used for your business case:
1. Basic Tier (non event-driven solution)
The device pushs periodicaly a telementry and non-telemetry messages based on the needs to the Azure IoT Hub, where the non-telemetry messages are routed to the Azure Function via the Service Bus Queue/Topic. Responsibility for this non-telemetry pipe is to persist a real device state in the database. Note, that the 6M messages will cost only $50/month. The back-end application can any time to query this database for devices state.
2. Standard Tier (event-driven solution) In this scenario you can use a Device Twin of the Azure IoT Hub to enable storing a real-device state in the cloud-backend (described by @HelenLo). The device can be triggered by C2D message, changing a desired property, invoking a method or based on the device edge trigger to the action for updating a state (reported properties).
The Azure IoT Hub has a capabilities to run your scheduled jobs for multiple devices.
In this solution, the back-end application can call any time a job for ExportDevicesAsync to the blob storage, see more details here. Note, that the 6M messages will cost $250/month.
As you can see the above each scenario needs to build a different device logic model based on the communications capabilities between the devices and Azure IoT Hub and back. Note, there are some limitations for these communications, see more details here.
A: You can consider using Device Twin of IoT Hub
https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-device-twins
Use device twins to:
*
*Store device-specific metadata in the cloud. For example, the deployment location of a vending machine.
*Report current state information such as available capabilities and conditions from your device app. For example, a device is connected to your IoT hub over cellular or WiFi.
*Synchronize the state of long-running workflows between device app and back-end app. For example, when the solution back end specifies the new firmware version to install, and the device app reports the various stages of the update process.
*Query your device metadata, configuration, or state.
A: IoT Hub provides you with the ability to connect your devices over various protocols. Preferred protocols are messaging protocols, such as MQTT or AMQP, but HTTPS is also supported. Using IoT hub, you do not request data from the device, though. The device will send the data to the IoT Hub. You have to options to implement that with IoT Hub:
*
*The device connects to the IoT Hub whenever it has some data to be sent, and pushes the data up to IoT Hub
*The device does not send any data on its own, but stays always or at least regularly connected to IoT Hub. You then can send a cloud to device message over IoT Hub to the device, requesting the data to be sent. The device then sends the data the same way it would in the first option.
When the data then has been sent to IoT Hub, you need to push it somewhere where it is persistently stored - IoT Hub only keeps messages for 1 day by default. Options for this are:
*
*Create a blob storage account and push to that directly from IoT Hub using a custom endpoint This would probably be the easiest and cheapest. Dependening on how you need to access your data, a blob might not be the best option, though
*Create a function app, create a function with an EventHubTrigger, connect it to IoT Hub and let the function process incoming data by outputting it into any kind of data sink, such as SQL, CosmosDB, Table Storage...
|
unknown
| |
d19833
|
test
|
I think the simplest way would be to write a web service (WCF could be used, for example) which returns the said URL to the other web site. The "request for the URL" would just be a web service call from the other web site to your web service.
A: Sounds like your best bet would be to create a web service that would be consumed by the other websites.
The MSDN site actually has a good overview and a couple of decent tutorials: ASP.NET Web Services
|
unknown
| |
d19835
|
test
|
As long as you have a reference to the JPanel, you can add whatever GUI-element you want, by calling add(JComponent comp) on the JPanel.
So, you can do something like this:
class Panel extends JPanel{
...
}
class Main{
public Main(JPanel thePanel){
thePanel.add(new JButton("Hello"));
}
}
Was this what you were looking for?
You can also update the fields added to the panel from another class, if you have a public accessor-method set up, in the class. So in your panel class, you have a method:
public JButton getButton(){
return button;
}
Then you can access the button from whatever class with a reference to your panel class, like this:
panel.getButton().setText("Some text");
Note that the button could just as well be public, then you could simply call the method directly: panel.button.setText("Some text"); but this is not considered good code, as it violates some general good OOP practices, not relevant to mention here.
|
unknown
| |
d19839
|
test
|
From the Rack spec:
The Body must respond to each and must only yield String values. The Body itself should not be an instance of String, as this will break in Ruby 1.9.
In Ruby 1.8 Strings did respond to each, but that changed in 1.9.
The simplest solution would be to just return an array containing the string:
[status, headers, [response_body]]
|
unknown
| |
d19841
|
test
|
You can have it much more concise with list comprehension:
from fractions import gcd
print(" | 2 3 4 5 6 7 8 9 10 11 12 13 14 15")
print("-----------------------------------------------")
xlist = range(2,16)
ylist = range(2,51)
print("\n".join(" ".join(["%2d | " % b] + [("%2d" % gcd(a, b)) for a in xlist]) for b in ylist))
Output:
| 2 3 4 5 6 7 8 9 10 11 12 13 14 15
-----------------------------------------------
2 | 2 1 2 1 2 1 2 1 2 1 2 1 2 1
3 | 1 3 1 1 3 1 1 3 1 1 3 1 1 3
4 | 2 1 4 1 2 1 4 1 2 1 4 1 2 1
5 | 1 1 1 5 1 1 1 1 5 1 1 1 1 5
6 | 2 3 2 1 6 1 2 3 2 1 6 1 2 3
7 | 1 1 1 1 1 7 1 1 1 1 1 1 7 1
8 | 2 1 4 1 2 1 8 1 2 1 4 1 2 1
9 | 1 3 1 1 3 1 1 9 1 1 3 1 1 3
10 | 2 1 2 5 2 1 2 1 10 1 2 1 2 5
11 | 1 1 1 1 1 1 1 1 1 11 1 1 1 1
12 | 2 3 4 1 6 1 4 3 2 1 12 1 2 3
13 | 1 1 1 1 1 1 1 1 1 1 1 13 1 1
14 | 2 1 2 1 2 7 2 1 2 1 2 1 14 1
15 | 1 3 1 5 3 1 1 3 5 1 3 1 1 15
16 | 2 1 4 1 2 1 8 1 2 1 4 1 2 1
17 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1
18 | 2 3 2 1 6 1 2 9 2 1 6 1 2 3
19 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1
20 | 2 1 4 5 2 1 4 1 10 1 4 1 2 5
21 | 1 3 1 1 3 7 1 3 1 1 3 1 7 3
22 | 2 1 2 1 2 1 2 1 2 11 2 1 2 1
23 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1
24 | 2 3 4 1 6 1 8 3 2 1 12 1 2 3
25 | 1 1 1 5 1 1 1 1 5 1 1 1 1 5
26 | 2 1 2 1 2 1 2 1 2 1 2 13 2 1
27 | 1 3 1 1 3 1 1 9 1 1 3 1 1 3
28 | 2 1 4 1 2 7 4 1 2 1 4 1 14 1
29 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1
30 | 2 3 2 5 6 1 2 3 10 1 6 1 2 15
31 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1
32 | 2 1 4 1 2 1 8 1 2 1 4 1 2 1
33 | 1 3 1 1 3 1 1 3 1 11 3 1 1 3
34 | 2 1 2 1 2 1 2 1 2 1 2 1 2 1
35 | 1 1 1 5 1 7 1 1 5 1 1 1 7 5
36 | 2 3 4 1 6 1 4 9 2 1 12 1 2 3
37 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1
38 | 2 1 2 1 2 1 2 1 2 1 2 1 2 1
39 | 1 3 1 1 3 1 1 3 1 1 3 13 1 3
40 | 2 1 4 5 2 1 8 1 10 1 4 1 2 5
41 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1
42 | 2 3 2 1 6 7 2 3 2 1 6 1 14 3
43 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1
44 | 2 1 4 1 2 1 4 1 2 11 4 1 2 1
45 | 1 3 1 5 3 1 1 9 5 1 3 1 1 15
46 | 2 1 2 1 2 1 2 1 2 1 2 1 2 1
47 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1
48 | 2 3 4 1 6 1 8 3 2 1 12 1 2 3
49 | 1 1 1 1 1 7 1 1 1 1 1 1 7 1
50 | 2 1 2 5 2 1 2 1 10 1 2 1 2 5
This works in Python2 and Python3. If you want zeros at the beginning of each one-digit number, replace each occurence of %2d with %02d. You probably shouldn't print the header like that, but do it more like this:
from fractions import gcd
xlist = range(2, 16)
ylist = range(2, 51)
string = " | " + " ".join(("%2d" % x) for x in xlist)
print(string)
print("-" * len(string))
print("\n".join(" ".join(["%2d | " % b] + [("%2d" % gcd(a, b)) for a in xlist]) for b in ylist))
This way, even if you change xlist or ylist, the table will still look good.
A: Your problem is that the python print statement adds a newline by itself.
One solution to this is to build up your own string to output piece by piece and use only one print statement per line of the table, like such:
from fractions import gcd
print "| 2 3 4 5 6 7 8 9 10 11 12 13 14 15"
print "-----------------------------------"
xlist = range(2,16)
ylist = range(2,51)
for b in ylist:
output=str(b)+" | " #For each number in ylist, make a new string with this number
for a in xlist:
output=output+str(gcd(a,b))+" " #Append to this for each number in xlist
print output #Print the string you've built up
Example output, by the way:
| 2 3 4 5 6 7 8 9 10 11 12 13 14 15
-----------------------------------
2 | 2 1 2 1 2 1 2 1 2 1 2 1 2 1
3 | 1 3 1 1 3 1 1 3 1 1 3 1 1 3
4 | 2 1 4 1 2 1 4 1 2 1 4 1 2 1
5 | 1 1 1 5 1 1 1 1 5 1 1 1 1 5
6 | 2 3 2 1 6 1 2 3 2 1 6 1 2 3
7 | 1 1 1 1 1 7 1 1 1 1 1 1 7 1
8 | 2 1 4 1 2 1 8 1 2 1 4 1 2 1
9 | 1 3 1 1 3 1 1 9 1 1 3 1 1 3
A: You can specify what kind of character end the line using the end parameter in print.
from fractions import gcd
print("| 2 3 4 5 6 7 8 9 10 11 12 13 14 15")
print("-----------------------------------")
xlist = range(2,16)
ylist = range(2,51)
for b in ylist:
print(b + " | ",end="")
for a in xlist:
print(gcd(a,b),end="")
print("")#Newline
If you are using python 2.x, you need to add from __future__ import print_function to the top for this to work.
|
unknown
| |
d19843
|
test
|
Here's a base R option using max.col :
#Select the columns to check
cols <- grep('CHECK', names(mydf), value = TRUE)
#Compare the value
mat <- mydf[cols] == 'A001'
#Find the column name where the value exist in each row
mydf$result <- cols[max.col(mat)]
#If the value does not exist in the row turn to `NA`.
mydf$result[rowSums(mat) == 0] <- NA
mydf
# case id CHECK1 CHECK2 CHECK3 CHECK4 CHECK5 result
#1 1 10 A001 Z001 Z001 Z001 Z001 CHECK1
#2 2 11 B001 B001 B001 B001 B001 <NA>
#3 3 12 C001 C001 C001 A001 C001 CHECK4
A: As a supplement:
I think the long format is a nice option for this case.
Becase it's very clear to show the position "A001" and easy to filter even for more CHECK number.
I will use data.table as a demonstration.
library(data.table)
setDT(mydf)
dt <- melt(mydf, id = 1:2, measure.vars = patterns("CHECK*"))
dt
Long format
case id variable value
1: 1 10 CHECK1 A001
2: 2 11 CHECK1 B001
3: 3 12 CHECK1 C001
4: 1 10 CHECK2 Z001
5: 2 11 CHECK2 B001
6: 3 12 CHECK2 C001
7: 1 10 CHECK3 Z001
8: 2 11 CHECK3 B001
9: 3 12 CHECK3 C001
10: 1 10 CHECK4 Z001
11: 2 11 CHECK4 B001
12: 3 12 CHECK4 A001
13: 1 10 CHECK5 Z001
14: 2 11 CHECK5 B001
15: 3 12 CHECK5 C001
Filter A001
dt[value == "A001"]
case id variable value
1: 1 10 CHECK1 A001
2: 3 12 CHECK4 A001
|
unknown
| |
d19851
|
test
|
@kittyminky you right
the solution is
Accounts.ui.config({ requestPermissions: { facebook: [the_permissons_you_want] } });
A: on my case using Accounts.ui.config yields an error since i only have Accounts defined, Accounts.ui isn't defined for me.
Perhaps because i didn't add that package, but must be a way without using the .ui ?
|
unknown
| |
d19855
|
test
|
Moles is capable of detouring calls to managed code. This class is clearly not dealing with managed code. Try creating a stub for this class, manually. This means crating an INativeMethods interface, have NativeMethods implement INativeMethods, and then use the interface as the stub, as usual. Moles will then generate stub type SINativeMethods from the interface, for use in test projects.
A: "Thus, if a method has no body (such as an abstract method), we cannot detour it." - Moles Dev
|
unknown
| |
d19857
|
test
|
You could use a separate object to define the validation messages:
export const validationMessages = {
required: 'Field is required'
}
// ...code
errors.firstName = validationMessages.required
Then, if you need to change the messages for required, just set the validationMessages.required, like this:
validationMessages.required = 'First name is required'
However, mutate an object with the validation messages isn't a good solution. I strongly recommend you to use a module called redux-form-validators.
With this module, you can easily override the validation message:
import { required, email } from 'redux-form-validators'
<Field
...
validate={required()} // Will use the default required message
>
<Field
...
validate={required({ message: 'Hey, the first name is required!' })} // Will override the default message
/>
|
unknown
| |
d19861
|
test
|
As a best practice, you should not scan and parse poms neither in remote nor local repository. On maven central they already scanned and parsed for you.
Just download nexus-maven-repository-index.gz from index dir (you need that big file 700M length, other files named nexus-maven-repository-index.XXX.gz are incremental updates)
Then use Maven Indexer to unpack index, maven indexer is available as java library and CLI program
As a result of running Maven indexer you'll get ordinary Apache Lucene index, with abitility to update it incrementally.
Here is a documentation, which explains how to unpack index and query data from it.
Most probably, index contain all the data you need.
A: For people still having the same question, I have developed a much simpler way to extract maven index indexes that works for most Nexus-based Maven repositories: the Maven Index Exporter.
From there you could simply get a list of poms and download them, if that's what you aim for.
Note however that it's huge: roughly 20 million documents are indexed for Maven Central and the text export is 14GB. There are as of today approximately 6.5 million pom files on Maven Central.
|
unknown
| |
d19863
|
test
|
Found a work-around answer. You can set the dockerEntrypoint like so:
// build.sbt
dockerEntrypoint := Seq("bin/myapp", "-Dconfig.file=conf/application.prod.conf", "-Dlogger.resource=logback.prod.xml")
A: javaOptions can be supplied to sbt-native-packager with
javaOptions in Universal ++= Seq(
// -J params will be added as jvm parameters
"-J-Xmx2048m",
"-J-Xms256m"
)
Note that these options will be applied to all generated packages (Debian, Rpm, etc.), not just Docker. See the discussion here.
|
unknown
| |
d19865
|
test
|
try:
echo $articles[0]["dates"];
A: foreach($returned_content->find('div.box-inset') as $article) {
$item['dates'] = $article->find('div.important-dates', 0)->plaintext;
$articles[] = $item['dates'];
}
you cannot use echo to output array
foreach($articles as $strarticle)
{
echo $strarticle;
}
|
unknown
| |
d19867
|
test
|
You should use not "Keyboard shortcut" but rather "Mouse shortcut" from a popup menu (number 2 at the picture):
https://developer.android.com/studio/images/intro/keymap-options_2-2_2x.png
Also by default on most linux desktop environments alt+mouse click is already assigned to window dragging. OS shortcuts have more priority. If it's the case for you then either use different shortcut in Android Studio or reassign OS shortcut (in this case Unity): https://askubuntu.com/questions/521423/how-can-i-disable-altclick-window-dragging
After that you should be able to use the shortcut in Android Studio
|
unknown
| |
d19873
|
test
|
if you know your table location in hdfs. This is the most quick way without even opening the hive shell.
You can check you table location in hdfs using command;
show create table <table_name>
then
hdfs dfs -ls <table_path>| sort -k6,7 | tail -1
It will show latest partition location in hdfs
A: You can use "show partitions":
hive -e "set hive.cli.print.header=false;show partitions table_name;" | tail -1 | cut -d'=' -f2
This will give you "2016-03-09" as output.
A: If you want to avoid running the "show partitions" in hive shell as suggested above, you can apply a filter to your max() query. That will avoid doing a fulltable scan and results should be fairly quick!
select max(ingest_date) from db.table_name
where ingest_date>date_add(current_date,-3) will only scan 2-3 partitions.
A: It looks like there is no way to query for the last partition via Hive (or beeline) CLI that checks only metadata (as one should expect).
For the sake of completeness, the alternative I would propose to the bash parsing answer is the one directly querying the metastore, which can be easily extended to more complex functions of the ingest_date rather than just taking the max. For instance, for a MySQL metastore I've used:
SELECT MAX(PARTITIONS.PART_NAME) FROM
DBS
INNER JOIN
TBLS ON DBS.DB_ID = TBLS.DB_ID
INNER JOIN
PARTITIONS ON TBLS.TBL_ID = PARTITIONS.TBL_ID
PARTITIONS DBS.NAME = 'db'
PARTITIONS TBLS.TBL_NAME = 'my_table'
Then the output will be in format partition_name=partition_value.
|
unknown
| |
d19875
|
test
|
You should code:
let persons = [...this.state.persons]
persons[0].name= "updated name"
this.setState({ persons })
A: using dot operator we can achieve this.
let persons = [...this.state.persons]
persons[0].name= "updated name"
this.setState({ persons })
A: Proble with that you mutate component state, below it's example of immutable changing, I recommend you to read articles about how to change react state. Or you can try to use Mobx because it supports mutability
changePerson(index, field, value) {
const { persons } = this.state;
this.setState({
persons: persons.map((person, i) => index === i ? person[field] = value : person)
})
}
// and you can use this method
this.changePerson(0, 'name', 'newName')
A: this.setState(state => (state.persons[0].name = "updated name", state))
A: Assuming some conditional check to find the required person.
const newPersonsData = this.state.persons.map((person)=>{
return person.name=="name1" ? person.name="new_name" : person);
//^^^^^^^ can be some condition
});
this.setState({...this.state,{person:[...newPersonsData ]}});
A: I think the best way is to copy the state first in temporary variable then after update that variable you can go for setState
let personsCopy = this.state.persons
personsCopy [0].name= "new name"
this.setState({ persons: personsCopy })
A: Here's how I would do it.
See if that works for you.
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
persons: [
{ name: "John", age: 24 },
{ name: "Ram", age: 44 },
{ name: "Keerthi", age: 23 }
],
status: "Online"
};
this.changeName = this.changeName.bind(this);
this.changeAge = this.changeAge.bind(this);
}
changeName(value,index) {
this.setState((prevState)=>{
const aux = prevState.persons;
aux[index].name = value;
return aux;
});
}
changeAge(value,index) {
this.setState((prevState)=>{
const aux = prevState.persons;
aux[index].age = value;
return aux;
});
}
render() {
const personItems = this.state.persons.map((item,index)=>
<React.Fragment>
<input value={item.name} onChange={(e)=>this.changeName(e.target.value,index)}/>
<input value={item.age} onChange={(e)=>this.changeAge(e.target.value,index)}/>
<br/>
</React.Fragment>
);
return(
<React.Fragment>
{personItems}
<div>{JSON.stringify(this.state.persons)}</div>
</React.Fragment>
);
}
}
ReactDOM.render(<App/>, document.getElementById('root'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.8.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.8.3/umd/react-dom.production.min.js"></script>
<div id="root"></div>
|
unknown
| |
d19877
|
test
|
SQL Server allows you to add datetime values, so that is a convenient data type for this purpose.
It is easy to convert the date to a datetime -- it is in a standard format.
The time column is tricker, but you can add in ':' for the conversion:
select v.*,
convert(datetime, v.date) + convert(datetime, stuff(stuff(time, 5, 0, ':'), 3, 0, ':'))
from (values ('20210401', '121012')) v(date, time);
A: convert(datetime, DATES + ' ' + substring(TIMES, 1, 2) + ':' + substring(TIMES, 3, 2) + ':' + substring(TIMES, 5, 2) , 121)
|
unknown
| |
d19879
|
test
|
That would almost certainly be achieved using something like posix_memalign.
A: Since 4Kbytes is often the size of a page (see sysconf(3) with _SC_PAGESIZE or the old getpagesize(2) syscall) you could use mmap(2) syscall (which is used by malloc and posix_memalign) to get 4Kaligned memory.
A: you can not allocate physically contiguous memory in user space. Because in User space kernel always allocates memory from highmem zone. But if you are writing a kernel module or a system space code then you can use _get_page() or _get_pages().
|
unknown
| |
d19883
|
test
|
Wrap your entire layout in a <ScrollView>, it just gets truncated because the screen isn't 'high' enough. If you layout would be bigger in height, the first screen would be cut off too.
|
unknown
| |
d19885
|
test
|
If you're seeing different response it means that
*
*Either you're sending a different request. In this case inspect request details from JMeter and from the real browser using a 3rd-party sniffer tool like Fiddler or Burp, identify the inconsistencies and amend your JMeter configuration so it would send exactly the same request as the real browser does (apart from dynamic values which need to be correlated)
*Or one of the previous requests fails somewhere somehow, JMeter automatically treats HTTP responses with status codes below 400 as successful, it might be the case they are not really successful, i.e. you're continuously hitting the login page (you can check it by inspecting response data tab of the View Results Tree listener). Try adding a Response Assertions to the HTTP Request samplers so there will be another layer of explicit checks of the response data, this way you will get confidence that JMeter is doing what it is supposed to be doing.
|
unknown
| |
d19887
|
test
|
To see if object is selected:
if($(".foo").is(':focus')){
// do something
}
To change values on keypress:
$(".foo").bind("keypress", function(e){
$(this).attr('value', 'bar');
})
Though not sure what you mean by changing the values of a drop down, or why you'd want to do that.
|
unknown
| |
d19889
|
test
|
Containers run at the same performance level as the host OS. There is no process performance hit. I created a whitepaper with Docker and HPE on this.
You wouldn't use pm2 or nodemon, which are meant to start multiple processes of your node app and restart them if they fail. That's the job of Docker now.
If in Swarm, you'd just increase the replica count of your service to be similar to the number of CPU/threads you'd want to run at the same time in the swarm.
I don't mention the nodemon/pm2 thing for Swarm in my node-docker-good-defaults so I'll at that as an issue to update it for.
|
unknown
| |
d19895
|
test
|
Please try the following code. This code, will remove your div node from it's parent. div will be moved into body tag.
dojo.require("dijit.Dialog");
var myDialog=new dijit.Dialog(
{
title:"Dialog Title",
content:dojo.byId("divNodeID")
}
);
myDialog.show();
Hope this helps you. Thanks!
A: If you surround your with the HTML that will create a Dialog, it should work.
For example, if your code is:
<form>
... some HTML ...
</form>
then consider coding:
<div data-dojo-type="dijit/Dialog" data-dojo-id="myDialog" title="MyTitle">
<form>
... some HTML ...
</form>
</div>
|
unknown
| |
d19897
|
test
|
Maybe something like this:
<?xml version='1.0' encoding="UTF-8"?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
<p>Text of my document</p>
<xi:include href="copyright.xml"/>
</document>
https://en.wikipedia.org/wiki/XInclude
A: Below example should work to include external file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "testng-1.0.dtd"
[<!ENTITY parent SYSTEM "./src/test/resources/dependencies.xml">]>
<suite name="suite1">
<test name="Managetestss" preserve-order="true">
&parent;
<parameter name="browser" value="chrome"></parameter>
<classes>
<class name="com.az.tests.commun.TNR_Client_001_Ajouter_Client" />
<class name="com.az.tests.client.TNR_Client_002_Rechercher_Client"
</classes>
</test>
</suite>
However the dependencies.xml you provided will not work because testng DTD doesn't support group tag under groups. Refer groups-of-groups and dependencies-in-xml
|
unknown
| |
d19911
|
test
|
As you know the main problem with async coding is losing reference to the current object
That's not true, the arrow function does not bind its own this therefore you don't need to send this to doPromise
export class PromiseComponent {
doPromise () {
return new Promise(function (resolve) {
setTimeout(function () {
resolve({ num: 3113 })
}, 5000)
})
}
}
promiseVal = 0
doMyPromise() {
this.myPromise.doPromise()
.then(res => {
this.promiseVal = res.num
})
}
A: If you want to consume a promise inside your component:
promiseVal = 0
doMyPromise() {
this.myPromise.doPromise().then((res) => {
this.promiseVal = res.num
});
}
And I don't know the reasoning behind your Service but it usually is like this (optional):
export class PromiseComponent {
doPromise() { //This method will return a promise
return new Promise(function (resolve2) {
setTimeout(function () {
resolve2({ num: 3113, obj: obj });
}, 5000);
});
}
}
After OP edited the post:
You can change this:
doMyPromise() {
this.myPromise.doPromise(this).then(this.secondFunc);//UPDATED HERE
}
to
doMyPromise() {
this.myPromise.doPromise(this).then(this.secondFunc.bind(this));//UPDATED HERE
}
|
unknown
| |
d19913
|
test
|
This measure should do what you want, by filtering all players, but leaving the club filter in place:
Club Overall Average =
IF (
HASONEVALUE ( data[Club] ),
CALCULATE (
AVERAGE ( data[Overall] ),
ALL ( data[Name] ),
data[Club] = VALUES ( data[Club] )
),
BLANK()
)
See https://pwrbi.com/2019/05/stack-overflow-56128872/ for worked example
|
unknown
| |
d19915
|
test
|
I hope you have added okio dependency in your gradle file. This will resolve Cannot access ByteString class file error.
compile 'com.squareup.okio:okio:1.13.0'
Then Edit your iUpload interface file like:
public interface iUpload{
@Multipart
@POST("/uploadmultiplepropimages/")
SamplePojoClass getUploadData(
@Part MultipartBody.Part file
@Part MultipartBody.Part prop_id,
@Part MultipartBody.Part type
);
}
Then write MultipartBody.Part like this:
RequestBody lRequestBody = RequestBody.create(MediaType.parse("multipart/form-data"), pFile);
MultipartBody.Part lFile = MultipartBody.Part.createFormData("file", pFile.getName(), lRequestBody);
MultipartBody.Part id = MultipartBody.Part.createFormData("prop_id", "WRITE_ID_HERE");
MultipartBody.Part type = MultipartBody.Part.createFormData("type", "WRITE TYPE HERE");
and finally pass these parameters to your api like this:
uploadImageResponse = RequestResponse.getUploadData(lFile,id,type);
I hope it will resolve your problem.
Note: Here pFile is instance of File. To get file from dicrectory you can write code like:
File pFile = new File("PATH_OF_FILE");
A: I have done Multipart upload in okhttp. I hope this will help.
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
multipartBuilder.setType(MultipartBody.FORM);
multipartBuilder.addFormDataPart("prop_photos", photoFile, RequestBody.create(MEDIA_TYPE_PNG, file));
multipartBuilder
.addFormDataPart("type", type)
.addFormDataPart("prop_id", prop_id);
RequestBody requestBody = multipartBuilder.build();
Request request1 = new Request.Builder().url(urlString).post(requestBody).build();
A: Use the following fuction for your problem
public static RegisterResponse Uploadimage(String id, String photo,String proof) {
File file1 = null, file2 = null;
try {
if (photo.trim() != null && !photo.trim().equals("")) {
file1 = new File(photo);
}
if (proof.trim() != null && !proof.trim().equals("")) {
file2 = new File(proof);
}
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(WEB_SERVICE + "protoupload.php?");
MultipartEntity reqEntity = new MultipartEntity();
// reqEntity.addPart("studentid", new StringBody(
// Global.profileDetail.id));
reqEntity.addPart("id", new StringBody(id));
if (file1 == null) {
reqEntity.addPart("photo", new StringBody(""));
} else {
FileBody bin1 = new FileBody(file1);
reqEntity.addPart("photo", bin1);
}
if (file2 == null) {
reqEntity.addPart("proof", new StringBody(""));
} else {
FileBody bin2 = new FileBody(file2);
reqEntity.addPart("proof", bin2);
}
post.setEntity(reqEntity);
HttpResponse response = client.execute(post);
HttpEntity resEntity = response.getEntity();
String inputStreamString = EntityUtils.toString(resEntity);
if (inputStreamString.contains("result")) {
return new Gson().fromJson(inputStreamString,
RegisterResponse.class);
}
} catch (Exception ex) {
Log.e("Debug", "error: " + ex.getMessage(), ex);
}
return new RegisterResponse();
}
|
unknown
| |
d19917
|
test
|
I've encountered the same issue with legacy code. It appears to be a problem with the implementation of Python 2's file object's __next__ method; it uses a Python level buffer (which -u/PYTHONUNBUFFERED=1 doesn't affect, because those only unbuffer the stdio FILE*s themselves, but file.__next__'s buffering isn't related; similarly, stdbuf/unbuffer can't change any of the buffering at all, because Python replaces the default buffer made by the C runtime; the last thing file.__init__ does for a newly opened file is call PyFile_SetBufSize which uses setvbuf/setbuf [the APIs] to replace the default stdio buffer).
The problem is seen when you have a loop of the form:
for line in sys.stdin:
where the first call to __next__ (called implicitly by the for loop to get each line) ends up blocking to fill the block before producing a single line.
There are three possible fixes:
*
*(Only on Python 2.6+) Rewrap sys.stdio with the io module (backported from Python 3 as a built-in) to bypass file entirely in favor of the (frankly superior) Python 3 design (which uses a single system call at a time to populate the buffer without blocking for the full requested read to occur; if it asks for 4096 bytes and gets 3, it'll see if a line is available and produce it if so) so:
import io
import sys
# Add buffering=0 argument if you won't always consume stdin completely, so you
# can't lose data in the wrapper's buffer. It'll be slower with buffering=0 though.
with io.open(sys.stdin.fileno(), 'rb', closefd=False) as stdin:
for line in stdin:
# Do stuff with the line
This will typically be faster than option 2, but it's more verbose, and requires Python 2.6+. It also allows for the rewrap to be Unicode friendly, by changing the mode to 'r' and optionally passing the known encoding of the input (if it's not the locale default) to seamlessly get unicode lines instead of (ASCII only) str.
*(Any version of Python) Work around problems with file.__next__ by using file.readline instead; despite nearly identical intended behavior, readline doesn't do its own (over)buffering, it delegates to C stdio's fgets (default build settings) or a manual loop calling getc/getc_unlocked into a buffer that stops exactly when it hits end of line. By combining it with two-arg iter you can get nearly identical code without excess verbosity (it'll probably be slower than the prior solution, depending on whether fgets is used under the hood, and how the C runtime implements it):
# '' is the sentinel that ends the loop; readline returns '' at EOF
for line in iter(sys.stdin.readline, ''):
# Do stuff with line
*Move to Python 3, which doesn't have this problem. :-)
A: In Linux, bash, what you are looking for seems to be the stdbuf command.
If you want no buffering (i.e. an unbuffered stream), try this,
# batch_job | stdbuf -o0 myparser
If you want line buffering, try this,
# batch_job | stdbuf -oL myparser
A: You can unbuffer the output:
unbuffer batch_job | myparser
|
unknown
| |
d19919
|
test
|
If you drop the first line, then it can be used in python.
import json
test = '''{
"Name": "SKY",
"SuggestedBots": 50,
"MaxCPM": 3000,
"LastModified": "2019-11-03T23:24:24.0854425-03:00",
"AdditionalInfo": "",
"Author": "KATO",
"Version": "1.1.4",
"IgnoreResponseErrors": false,
"MaxRedirects": 8,
"NeedsProxies": true,
"OnlySocks": false,
"OnlySsl": false,
"MaxProxyUses": 0,
"BanProxyAfterGoodStatus": false,
"EncodeData": false,
"AllowedWordlist1": "",
"AllowedWordlist2": "",
"DataRules": [],
"CustomInputs": [],
"ForceHeadless": false,
"AlwaysOpen": false,
"AlwaysQuit": false,
"DisableNotifications": false,
"CustomUserAgent": "",
"RandomUA": false,
"CustomCMDArgs": ""
}'''
json.loads(test)
# {u'AlwaysQuit': False, u'Author': u'KATO', u'LastModified': u'2019-11-03T23:24:24.0854425-03:00', u'DataRules': [], u'AlwaysOpen': False, u'Version': u'1.1.4', u'DisableNotifications': False, u'NeedsProxies': True, u'CustomInputs': [], u'EncodeData': False, u'BanProxyAfterGoodStatus': False, u'SuggestedBots': 50, u'ForceHeadless': False, u'RandomUA': False, u'AdditionalInfo': u'', u'Name': u'SKY', u'CustomUserAgent': u'', u'MaxRedirects': 8, u'CustomCMDArgs': u'', u'OnlySocks': False, u'MaxProxyUses': 0, u'IgnoreResponseErrors': False, u'AllowedWordlist1': u'', u'AllowedWordlist2': u'', u'OnlySsl': False, u'MaxCPM': 3000}
|
unknown
| |
d19923
|
test
|
Check the srcElement before plugin executions. If it's not an input element, do trigger the contextmenu plugin:
$(document).on("contextmenu", function(e) {
if (!$(e.srcElement).is(":input")) { // if it's not an input element...
$(this).triggerTheContextMenuPlugin();
}
});
A: Use an event listener on the document and check if it was initiated by an input element.
$(document).on("contextmenu", function (e) {
if (e.target.tagName.toUpperCase() === "INPUT") {
console.log("context menu triggered");
}
});
Demo here
A: Inspired by Salman's solution.
You can stop the event propagation in all input elements, with the e.stopPropagation() function. In doing so, you keep the default behavior of the inputs elements:
$(function() {
$(document).on("contextmenu", function(e) {
alert("Context menu triggered, preventing default");
e.preventDefault();
});
$("input").on("contextmenu", function(e) {
e.stopPropagation();
});
});
JSFiddle Demo
|
unknown
| |
d19927
|
test
|
You must be using the old version of the Scheduler SDK. Please find the latest SDK here.
We also have a code sample for said SDK:
https://github.com/Azure-Samples/scheduler-dotnet-getting-started
|
unknown
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.