problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
SSRS Report Multi Parameters : In my SSRS report there are 4 parameters StartDate, EndDate, MeterId, & DisplayBy
Start Date: datetime datatype
EndDate : datetime datatype
MeterId : is a drop down list and this will populate based on SQL query
DisplayBy: is a drop down list and this has the following values (Hour,day,Month & year)
The Database that stores hourly values for Meters, the following are the DB table columns: (MeterId,ReadingDate,Hours,Quantity,Price)
When I select the startdate, end date and the meter Id and display i want to show report based on the startdate & enddate and then by display values.
If the display is hour, the we got display all the 24 hour values for the MeterId,Quantity, Price for the date range.
If the display is day, we got display total quantity and total price for the MeterId for that date range.
If the display is Month, we got display total quantity and total price for the MeterId for that date range.
If the display is Year, we got display total quantity and total price for the MeterId for that date range. Say for example If i select start date as 1-1-2016 and end date as 12-31-2016. My result should show 12 rows for each month with their total Quantity, Total price for that particular MEterID.
Please suggest your idea...
| 0debug
|
Cannot read property 'getHostNode' of null : <p>I have a horizon/react app with react router and I have a simple button in my app:</p>
<pre><code><Link className="dark button" to="/">Another Search</Link>
</code></pre>
<p>When I click on it, I get the following exception:</p>
<pre><code>Uncaught TypeError: Cannot read property 'getHostNode' of null
</code></pre>
<p>The error comes from:</p>
<pre><code>getHostNode: function (internalInstance) {
return internalInstance.getHostNode();
},
</code></pre>
<p>Any idea why am I getting this?</p>
| 0debug
|
C++ program . The program should use recursion and looping : <p>Im trying to run a C++ program with binary output. Please help .</p>
<p>0000
0001
0010
0011
0101
0110
0111
1000
1111</p>
| 0debug
|
static int vpc_has_zero_init(BlockDriverState *bs)
{
BDRVVPCState *s = bs->opaque;
VHDFooter *footer = (VHDFooter *) s->footer_buf;
if (cpu_to_be32(footer->type) == VHD_FIXED) {
return bdrv_has_zero_init(bs->file);
} else {
return 1;
}
}
| 1threat
|
static void expand_rle_row(unsigned char *optr, unsigned char *iptr,
int chan_offset, int pixelstride)
{
unsigned char pixel, count;
#ifndef WORDS_BIGENDIAN
if (pixelstride == 4 && chan_offset != 3) {
chan_offset = 2 - chan_offset;
}
#endif
optr += chan_offset;
while (1) {
pixel = *iptr++;
if (!(count = (pixel & 0x7f))) {
return;
}
if (pixel & 0x80) {
while (count--) {
*optr = *iptr;
optr += pixelstride;
iptr++;
}
} else {
pixel = *iptr++;
while (count--) {
*optr = pixel;
optr += pixelstride;
}
}
}
}
| 1threat
|
static int nbd_co_request(BlockDriverState *bs,
NBDRequest *request,
QEMUIOVector *qiov)
{
NBDClientSession *client = nbd_get_client_session(bs);
int ret;
assert(!qiov || request->type == NBD_CMD_WRITE ||
request->type == NBD_CMD_READ);
ret = nbd_co_send_request(bs, request,
request->type == NBD_CMD_WRITE ? qiov : NULL);
if (ret < 0) {
return ret;
}
return nbd_co_receive_reply(client, request,
request->type == NBD_CMD_READ ? qiov : NULL);
}
| 1threat
|
static int mov_read_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom,
enum AVCodecID codec_id)
{
AVStream *st;
uint64_t size;
uint8_t *buf;
int err;
if (c->fc->nb_streams < 1)
return 0;
st= c->fc->streams[c->fc->nb_streams-1];
if (st->codec->codec_id != codec_id)
return 0;
size= (uint64_t)st->codec->extradata_size + atom.size + 8 + FF_INPUT_BUFFER_PADDING_SIZE;
if (size > INT_MAX || (uint64_t)atom.size > INT_MAX)
return AVERROR_INVALIDDATA;
if ((err = av_reallocp(&st->codec->extradata, size)) < 0)
return err;
buf = st->codec->extradata + st->codec->extradata_size;
st->codec->extradata_size= size - FF_INPUT_BUFFER_PADDING_SIZE;
AV_WB32( buf , atom.size + 8);
AV_WL32( buf + 4, atom.type);
avio_read(pb, buf + 8, atom.size);
return 0;
}
| 1threat
|
int avio_read_partial(AVIOContext *s, unsigned char *buf, int size)
{
int len;
if (size < 0)
return -1;
if (s->read_packet && s->write_flag) {
len = s->read_packet(s->opaque, buf, size);
if (len > 0)
s->pos += len;
return len;
}
len = s->buf_end - s->buf_ptr;
if (len == 0) {
s->buf_end = s->buf_ptr = s->buffer;
fill_buffer(s);
len = s->buf_end - s->buf_ptr;
}
if (len > size)
len = size;
memcpy(buf, s->buf_ptr, len);
s->buf_ptr += len;
if (!len) {
if (s->error) return s->error;
if (avio_feof(s)) return AVERROR_EOF;
}
return len;
}
| 1threat
|
Browser URL issue beacuse special character like "&" : Hello i have a website using php and connected with mysql database. i have also a admindashboard for control the users with some features.in php script i have code
<a href="../loginUser2.php?userName=<?php echo $SQLRow["userid"];?>" target="_blank" class="a">Records</a>
this code make a login url link like this when complete with username
mydomain.com/loginUser2.php?userName=abc&xyz
in mysql from table take username abc&xyz or any user. everything is fine just in web browser when i click link for any user then user is automatically login with help of php. but when in any user name use symbol or special character LIKE currently i have issue in "&" symbol. when i edit the url with my self and in web browser when i type manually link with replace of & with %26 link work and user login successfully. i just want if any how user is registered in mysql database with contain any special character symbol like & or etc so how can i fix web browser work automatically handle this type of symbols and characters.
i tried one stupid thing in myphpadmin edit username column and update username like this abc%26xyz i thought when i will update then its works like &=%26 but i am fail. please help guide any simple way to fix this.
Thanks
| 0debug
|
Sometimes pip install is very slow : <p>I am sure it is not network issue. Some of my machine install packages using pip is very fast while some other machine is pretty slow, from the logs, I suspect the slow is due to it will compile the package, I am wondering how can I avoid this compilation to make the pip installation fast. Here's the logs from the slow pip installation.</p>
<pre><code>Collecting numpy==1.10.4 (from -r requirements.txt (line 1))
Downloading numpy-1.10.4.tar.gz (4.1MB)
100% |████████████████████████████████| 4.1MB 95kB/s
Requirement already satisfied (use --upgrade to upgrade): wheel==0.26.0 in ./lib/python2.7/site-packages (from -r requirements.txt (line 2))
Building wheels for collected packages: numpy
Running setup.py bdist_wheel for numpy ... -
done
Stored in directory: /root/.cache/pip/wheels/66/f5/d7/f6ddd78b61037fcb51a3e32c9cd276e292343cdd62d5384efd
Successfully built numpy
</code></pre>
| 0debug
|
Vector is not clearing : <p>I have created a function that gets a series of guesses (a sequence of colors) from a user and puts them in a vector, and this function is called within a while loop in main().</p>
<p>Each time it is called by the while loop, the guess should be cleared before being refilled with inputs. However, within the second loop, entering a color I entered during the first loop activates my error message ("Invalid or repeated color entry..."), suggesting that the vector was not successfully cleared.</p>
<p>I've tried to clear it with a space, various strings, etc., but nothing seems to clear it. What am I missing?</p>
<p>Function:</p>
<pre><code>void getGuess(vector<string> &currentGuessPegs, vector<string> &colorChoices, int maxPegSlots) {
string input; // stores input temporarily
// ---clear previous guess---
for (int i = 0; i < maxPegSlots; i++) {
currentGuessPegs[i] == "";
}
// ---prompt player for each peg guess and store in currentGuessPegs---
for (int i = 0; i < maxPegSlots; i++) {
cout << "Peg " << i+1 << ": ";
cin >> input;
while (find(currentGuessPegs.begin(), currentGuessPegs.end(), input) != currentGuessPegs.end() // Loops if color entry has already been used
|| find(colorChoices.begin(), colorChoices.end(), input) == colorChoices.end()) { // or is an invalid choice
cout << "Invalid or repeated color entry. See color choices and re-enter a color you have not used.\n";
cout << "Peg " << i + 1 << ": ";
cin >> input;
}
currentGuessPegs[i] = input;
}
}
</code></pre>
<p>And here is my call to the function from main():</p>
<pre><code>// ---get and check guesses until maximum # of guesses is exceeded or solution is guessed---
while (guessCount < maximumGuesses && solutionGuessed == false) {
getGuess(currentGuess, colorOptions, numberOfPegs); // get the guess
solutionGuessed = checkGuess(currentGuess, solution, numberOfPegs, red, white); // check the guess; returns true if solution was guessed
cout << "r: " << red << " w: " << white << endl << endl;
guessCount++;
}
</code></pre>
| 0debug
|
javascript removing copyright character from text : I am using some regex to remove white spaces from some text in javascript. The current regex looks like this
var cleaned_plaintext = website_content;
cleaned_plaintext = cleaned_plaintext.toLowerCase();
cleaned_plaintext = cleaned_plaintext.replace(/(\0\r\n|\n|\r|\0)/gm," ");
cleaned_plaintext = cleaned_plaintext.replace(/\s+/g," ");
cleaned_plaintext = cleaned_plaintext.replace(/[...\(\)]/g,"");
cleaned_plaintext = cleaned_plaintext.replace(/[…]/g,"");
cleaned_plaintext = cleaned_plaintext.replace(/[:!?.,={-}]/g," ");
cleaned_plaintext = cleaned_plaintext.replace(/\s+/g," ");
The above regex does pretty good at cleaning up most white spaces but say I have symbols like these
©
How can I remove those with regex? Also any tips on cleaning up that above regex to make it more streamlined, faster, etc....
| 0debug
|
Basic Ruby: what is the difference between these 2 codes? i get false for one and true for another : I got these 2 codes from 2 websites defining the longest word in a string but one code gives me true and one gives me false. Can someone tell me why?
def longest_word(sentence)
words = sentence.split(" ")
longest_word = nil
word_idx = 0
while word_idx < words.length
current_word = words[word_idx]
if longest_word == nil
longest_word = current_word
elsif longest_word.length < current_word.length
longest_word = current_word
end
word_idx += 1
end
return longest_word
end
AND
def LongestWord(sen)
arr = sen.split.map do |w|
/[a-zA-Z0-9\s]+/.match(w)
end
longest = arr.max_by do |w|
w.to_s.length
end
return longest
end
| 0debug
|
scala for spark - filtering out rows of a table bassed on a column : I'm a beginner with scala and am trying to filter out table rows based in column value.
I have a dataframe(spark):
id value
3 0
3 1
3 0
4 1
4 0
4 0
I want to create a new dataframe deleting all rows with value!=0:
id value
3 0
3 0
4 0
4 0
I figured the syntax should be something like this but couldn't get it right
val newDataFrame = OldDataFrame.filter($"value"==0)
tnx!
| 0debug
|
C++ std::list segmentation fault : <p>I got a segmentation fault (core dumped) while runing my programm. The first version runs perfectly but i need the list as a pointer but then the code doesn't work anymore see second code. What am i doing wrong?</p>
<p>Runing version:</p>
<p></p>
<pre><code>int main(int argc, char *argv[]) {
std::list<int> TestList;
for (int i = 0; i < 10; ++i) {
TestList.push_back(i);
}
for (std::list<int>::const_iterator iterator = TestList.begin(), end = TestList.end(); iterator != end; ++iterator) {
std::cout << *iterator << std::endl;
}
return 0;
}
</code></pre>
<p></p>
<p>Not runing version:</p>
<p></p>
<pre><code>int main(int argc, char *argv[]) {
std::list<int> *TestList;
for (int i = 0; i < 10; ++i) {
TestList->push_back(i);
}
for (std::list<int>::const_iterator iterator = TestList->begin(), end = TestList->end(); iterator != end; ++iterator) {
std::cout << *iterator << std::endl;
}
return 0;
}
</code></pre>
<p></p>
| 0debug
|
Why should a production Kubernetes cluster have a minimum of three nodes? : <p>The <a href="https://kubernetes.io/docs/tutorials/kubernetes-basics/cluster-intro/" rel="noreferrer">first section</a> of the official Kubernetes tutorial states that,</p>
<blockquote>
<p>A Kubernetes cluster that handles production traffic should have a minimum of three nodes.</p>
</blockquote>
<p>but gives no rationale for why three is preferred. Is three desirable over two in order to avoid a split-brain scenario, to merely allow for greater availability, or to cater to something specific to the internals of Kubernetes? I would have thought a split-brain scenario would only happen with multiple Kubernetes clusters (each having distinct masters) whereas a single cluster should be able to handle at least two nodes, each, perhaps, in their own availability-zone. </p>
| 0debug
|
CoinBase Rest Api integration in andorid : I home your are well, i am asking a question how to use rest coinbase Api in Andorid. I searching in whole website no solution to this api. This api is not used in Postman. Github coin base sdk is too old.Using this api in postman but no response in postman. Please help me for this api.
Thanks
Mukesh Singh
| 0debug
|
how to get all the sequences and columns to which sequence is applied using single query in psql ? any direct or indirect way to get the list? : I want **to get all the sequences created, tables and columns to which that sequence is applied in a database** using a **single query** in **PostgreSQL**. Any direct or indirect method is helpful.
| 0debug
|
Crash when attempting to save a String to UserDefaults in Swift : <p>I am using this line of code to save a String to UserDefaults,</p>
<pre><code>UserDefaults.standard.set(userSelected, forKey: "myKeyString")
</code></pre>
<p>However it results in the crash,</p>
<pre><code>[User Defaults] Attempt to set a non-property-list object (Function) as an NSUserDefaults/CFPreferences value for key myKeyString
</code></pre>
<p>Why?</p>
| 0debug
|
File handling: creating a single file, storing information (from an array) & retrieving information(from an array) : <p>I am taking a class in Java. I am currently writing a simple game that deals with file handling. One of the requirements is to keep track of player names & scores using an array, storing the array in a file, and retrieving specific information from the array.</p>
<p>For example: the game would consist of a persons name along with the amount of points they have. The game would save that to an array in a file. The file can either call that particular person's name & points (to continue playing) OR display the top 10 high scores.</p>
<p>How do I do this?</p>
| 0debug
|
Concatenate two vectors while preserving order in R : <p>This is hard to explain, so I'll try and then leave a simple example. When I concatenate the vectors, I would like the first element of each vector next to each other, then the second elements next to each other, etc. See example below. </p>
<pre><code>x <- c("a","b","c")
y <- c(1,2,3)
c(x,y)
[1] "a" "b" "c" "1" "2" "3"
</code></pre>
<p>However, I would like the following: </p>
<pre><code>[1] "a" "1" "b" "2" "c" "3"
</code></pre>
<p>I'm sure there is an answer on here already, but I'm having trouble putting in the right search. Any help appreciated!</p>
| 0debug
|
static inline void RENAME(rgb24tobgr24)(const uint8_t *src, uint8_t *dst, long src_size)
{
unsigned i;
#if COMPILE_TEMPLATE_MMX
x86_reg mmx_size= 23 - src_size;
__asm__ volatile (
"test %%"REG_a", %%"REG_a" \n\t"
"jns 2f \n\t"
"movq "MANGLE(mask24r)", %%mm5 \n\t"
"movq "MANGLE(mask24g)", %%mm6 \n\t"
"movq "MANGLE(mask24b)", %%mm7 \n\t"
".p2align 4 \n\t"
"1: \n\t"
PREFETCH" 32(%1, %%"REG_a") \n\t"
"movq (%1, %%"REG_a"), %%mm0 \n\t"
"movq (%1, %%"REG_a"), %%mm1 \n\t"
"movq 2(%1, %%"REG_a"), %%mm2 \n\t"
"psllq $16, %%mm0 \n\t"
"pand %%mm5, %%mm0 \n\t"
"pand %%mm6, %%mm1 \n\t"
"pand %%mm7, %%mm2 \n\t"
"por %%mm0, %%mm1 \n\t"
"por %%mm2, %%mm1 \n\t"
"movq 6(%1, %%"REG_a"), %%mm0 \n\t"
MOVNTQ" %%mm1, (%2, %%"REG_a") \n\t"
"movq 8(%1, %%"REG_a"), %%mm1 \n\t"
"movq 10(%1, %%"REG_a"), %%mm2 \n\t"
"pand %%mm7, %%mm0 \n\t"
"pand %%mm5, %%mm1 \n\t"
"pand %%mm6, %%mm2 \n\t"
"por %%mm0, %%mm1 \n\t"
"por %%mm2, %%mm1 \n\t"
"movq 14(%1, %%"REG_a"), %%mm0 \n\t"
MOVNTQ" %%mm1, 8(%2, %%"REG_a") \n\t"
"movq 16(%1, %%"REG_a"), %%mm1 \n\t"
"movq 18(%1, %%"REG_a"), %%mm2 \n\t"
"pand %%mm6, %%mm0 \n\t"
"pand %%mm7, %%mm1 \n\t"
"pand %%mm5, %%mm2 \n\t"
"por %%mm0, %%mm1 \n\t"
"por %%mm2, %%mm1 \n\t"
MOVNTQ" %%mm1, 16(%2, %%"REG_a") \n\t"
"add $24, %%"REG_a" \n\t"
" js 1b \n\t"
"2: \n\t"
: "+a" (mmx_size)
: "r" (src-mmx_size), "r"(dst-mmx_size)
);
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
if (mmx_size==23) return;
src+= src_size;
dst+= src_size;
src_size= 23-mmx_size;
src-= src_size;
dst-= src_size;
#endif
for (i=0; i<src_size; i+=3) {
register uint8_t x;
x = src[i + 2];
dst[i + 1] = src[i + 1];
dst[i + 2] = src[i + 0];
dst[i + 0] = x;
}
}
| 1threat
|
how to get a hidden value from HTML? : <p id="sub-total">
<strong>Total</strong>: <span id="stotal"></span></p>
<p><input type="submit" id="submit-order" value="Submit" class="btn"/></p>
how to get "stotal" value from the html and pass to server.Now the value is coming from Jquery.
| 0debug
|
SoapUI 5.3.0 Mac hangs on any use after installation : <p>SoapUI 5.3.0 (latest open source version) Mac hangs on clean-install on MacOS 10.12.3 - with all presets suggested by the installer.</p>
<p>I tried rebooting & installing again - every time when you load the app it's just an eternal beach ball with no menus clickable - and requires a force quit - even after 5 minutes of just leaving it.</p>
<p>I've found nothing on Google about this</p>
<p>How can I fix this?!</p>
| 0debug
|
Scala division by zero yields different results : <p>I am confused with how Scala handles division by zero. Here is a REPL code snippet. </p>
<pre><code>scala> 1/0
java.lang.ArithmeticException: / by zero
... 33 elided
scala> 1.toDouble/0.toDouble
res1: Double = Infinity
scala> 0.0/0.0
res2: Double = NaN
scala> 0/0
java.lang.ArithmeticException: / by zero
... 33 elided
scala> 1.toInt/0.toInt
java.lang.ArithmeticException: / by zero
... 33 elided
</code></pre>
<p>As you can see in the above example, depending on how you divide by zero, you get one of the following: </p>
<ul>
<li>"java.lang.ArithmeticException: / by zero" </li>
<li>"Double = NaN" </li>
<li>"Double = Infinity"</li>
</ul>
<p>This makes debugging quite challenging especially when dealing with data of unknown characteristics. What is the reasoning behind this approach, or even a better question, how to handle division by zero in a unified manner in Scala?</p>
| 0debug
|
static void qobject_input_type_number(Visitor *v, const char *name, double *obj,
Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
QInt *qint;
QFloat *qfloat;
if (!qobj) {
return;
}
qint = qobject_to_qint(qobj);
if (qint) {
*obj = qint_get_int(qobject_to_qint(qobj));
return;
}
qfloat = qobject_to_qfloat(qobj);
if (qfloat) {
*obj = qfloat_get_double(qobject_to_qfloat(qobj));
return;
}
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"number");
}
| 1threat
|
static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
{
int i, consumed, ret = 0;
s->ref = NULL;
s->eos = 0;
s->nb_nals = 0;
while (length >= 4) {
HEVCNAL *nal;
int extract_length = 0;
if (s->is_nalff) {
int i;
for (i = 0; i < s->nal_length_size; i++)
extract_length = (extract_length << 8) | buf[i];
buf += s->nal_length_size;
length -= s->nal_length_size;
if (extract_length > length) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid NAL unit size.\n");
ret = AVERROR_INVALIDDATA;
goto fail;
}
} else {
if (buf[2] == 0) {
length--;
buf++;
continue;
}
if (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
buf += 3;
length -= 3;
}
if (!s->is_nalff)
extract_length = length;
if (s->nals_allocated < s->nb_nals + 1) {
int new_size = s->nals_allocated + 1;
HEVCNAL *tmp = av_realloc_array(s->nals, new_size, sizeof(*tmp));
if (!tmp) {
ret = AVERROR(ENOMEM);
goto fail;
}
s->nals = tmp;
memset(s->nals + s->nals_allocated, 0, (new_size - s->nals_allocated) * sizeof(*tmp));
av_reallocp_array(&s->skipped_bytes_nal, new_size, sizeof(*s->skipped_bytes_nal));
av_reallocp_array(&s->skipped_bytes_pos_size_nal, new_size, sizeof(*s->skipped_bytes_pos_size_nal));
av_reallocp_array(&s->skipped_bytes_pos_nal, new_size, sizeof(*s->skipped_bytes_pos_nal));
s->skipped_bytes_pos_size_nal[s->nals_allocated] = 1024;
s->skipped_bytes_pos_nal[s->nals_allocated] = av_malloc_array(s->skipped_bytes_pos_size_nal[s->nals_allocated], sizeof(*s->skipped_bytes_pos));
s->nals_allocated = new_size;
}
s->skipped_bytes_pos_size = s->skipped_bytes_pos_size_nal[s->nb_nals];
s->skipped_bytes_pos = s->skipped_bytes_pos_nal[s->nb_nals];
nal = &s->nals[s->nb_nals];
consumed = extract_rbsp(s, buf, extract_length, nal);
s->skipped_bytes_nal[s->nb_nals] = s->skipped_bytes;
s->skipped_bytes_pos_size_nal[s->nb_nals] = s->skipped_bytes_pos_size;
s->skipped_bytes_pos_nal[s->nb_nals++] = s->skipped_bytes_pos;
if (consumed < 0) {
ret = consumed;
goto fail;
}
ret = init_get_bits8(&s->HEVClc->gb, nal->data, nal->size);
if (ret < 0)
goto fail;
hls_nal_unit(s);
if (s->nal_unit_type == NAL_EOS_NUT || s->nal_unit_type == NAL_EOB_NUT)
s->eos = 1;
buf += consumed;
length -= consumed;
}
for (i = 0; i < s->nb_nals; i++) {
int ret;
s->skipped_bytes = s->skipped_bytes_nal[i];
s->skipped_bytes_pos = s->skipped_bytes_pos_nal[i];
ret = decode_nal_unit(s, s->nals[i].data, s->nals[i].size);
if (ret < 0) {
av_log(s->avctx, AV_LOG_WARNING, "Error parsing NAL unit #%d.\n", i);
if (s->avctx->err_recognition & AV_EF_EXPLODE)
goto fail;
}
}
fail:
if (s->ref && s->threads_type == FF_THREAD_FRAME)
ff_thread_report_progress(&s->ref->tf, INT_MAX, 0);
return ret;
}
| 1threat
|
Command CodeSign failed with non zero when deploying to device : I received this error when trying to deploy application to device. I am using XCode 10.1 with free developer account. In signing section I set personal team with signing certificate iPhone Developer. I can ran the app in iOS simulator but not run in real device.
| 0debug
|
How to convert javascript object to json : I am trying to convert the follwing javascript object into valid json-
[{
'"Sno"': '"1"',
'"Purchase Date Time"': '"2017-11-14 14:09:32"',
'"Txn Type"': '"COD"',
'"Order Status"': '"DELIVERED"'
},
{
'"Sno"': '"2"',
'"Purchase Date Time"': '"2017-11-14 14:09:32"',
'"Txn Type"': '"COD"',
'"Order Status"': '"DELIVERED"'
}]
How can I do that?
| 0debug
|
Module build failed (from ./node_modules/@ngtools/webpack/src/index.js): : <p>I have created an application on angular 7 and ionic 4.
I tried to edit app.routing.ts file, setting path and component. From then on I am getting this error below: </p>
<pre><code>ERROR in ./src/app/department/department.module.ts
[ng] Module build failed (from ./node_modules/@ngtools/webpack/src/index.js):
[ng] Error: ENOENT: no such file or directory, open 'C:\Users\x\department\department.module.ts'
[ng] at Object.openSync (fs.js:436:3)
[ng] at Object.readFileSync (fs.js:341:35)
[ng] at Storage.provideSync (C:\Users\x\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:98:13)
</code></pre>
| 0debug
|
Mock dependency in jest with typescript : <p>When testing a module that has a dependency in a different file. When assigning that module to be <code>jest.Mock</code> typescript gives an error that the method <code>mockReturnThisOnce</code>(or any other jest.Mock method) does not exist on the dependency, this is because it is previously typed. What is the proper way to get typescript to inherit the types from jest.Mock?</p>
<p>Here is a quick example.</p>
<p>Dependency</p>
<pre><code>const myDep = (name: string) => name;
export default myDep;
</code></pre>
<p>test.ts</p>
<pre><code>import * as dep from '../depenendency';
jest.mock('../dependency');
it('should do what I need', () => {
//this throws ts error
// Property mockReturnValueOnce does not exist on type (name: string)....
dep.default.mockReturnValueOnce('return')
}
</code></pre>
<p>I feel like this is a very common use case and not sure how to properly type this. Any help would be much appreciated! </p>
| 0debug
|
void vring_teardown(Vring *vring)
{
hostmem_finalize(&vring->hostmem);
}
| 1threat
|
static void test_io_channel_ipv4_fd(void)
{
QIOChannel *ioc;
int fd = -1;
fd = socket(AF_INET, SOCK_STREAM, 0);
g_assert_cmpint(fd, >, -1);
ioc = qio_channel_new_fd(fd, &error_abort);
g_assert_cmpstr(object_get_typename(OBJECT(ioc)),
==,
TYPE_QIO_CHANNEL_SOCKET);
object_unref(OBJECT(ioc));
| 1threat
|
Which scenarios allow to use Chef or Azure SDK to create VM and deploy in automation : <p>There are two ways defined in the Microsoft site in order to create the azure VM.</p>
<ol>
<li><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/windows/csharp" rel="nofollow noreferrer">Creating from C#</a></li>
<li><a href="https://docs.microsoft.com/en-us/azure/virtual-machines/windows/chef-automation" rel="nofollow noreferrer">Create using Chef</a></li>
</ol>
<p>I want to know what is the difference and what would be flexibility can be achieved using the process defined, as VM can also be managed from the Azure portal like Chef Server.</p>
<p>My scenario is to provide the complete automation in creating the azure VM and deploy the app package on it after installing the IIS.</p>
| 0debug
|
static int qcow2_do_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVQcow2State *s = bs->opaque;
unsigned int len, i;
int ret = 0;
QCowHeader header;
Error *local_err = NULL;
uint64_t ext_end;
uint64_t l1_vm_state_index;
ret = bdrv_pread(bs->file, 0, &header, sizeof(header));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read qcow2 header");
goto fail;
}
be32_to_cpus(&header.magic);
be32_to_cpus(&header.version);
be64_to_cpus(&header.backing_file_offset);
be32_to_cpus(&header.backing_file_size);
be64_to_cpus(&header.size);
be32_to_cpus(&header.cluster_bits);
be32_to_cpus(&header.crypt_method);
be64_to_cpus(&header.l1_table_offset);
be32_to_cpus(&header.l1_size);
be64_to_cpus(&header.refcount_table_offset);
be32_to_cpus(&header.refcount_table_clusters);
be64_to_cpus(&header.snapshots_offset);
be32_to_cpus(&header.nb_snapshots);
if (header.magic != QCOW_MAGIC) {
error_setg(errp, "Image is not in qcow2 format");
ret = -EINVAL;
goto fail;
}
if (header.version < 2 || header.version > 3) {
error_setg(errp, "Unsupported qcow2 version %" PRIu32, header.version);
ret = -ENOTSUP;
goto fail;
}
s->qcow_version = header.version;
if (header.cluster_bits < MIN_CLUSTER_BITS ||
header.cluster_bits > MAX_CLUSTER_BITS) {
error_setg(errp, "Unsupported cluster size: 2^%" PRIu32,
header.cluster_bits);
ret = -EINVAL;
goto fail;
}
s->cluster_bits = header.cluster_bits;
s->cluster_size = 1 << s->cluster_bits;
s->cluster_sectors = 1 << (s->cluster_bits - 9);
if (header.version == 2) {
header.incompatible_features = 0;
header.compatible_features = 0;
header.autoclear_features = 0;
header.refcount_order = 4;
header.header_length = 72;
} else {
be64_to_cpus(&header.incompatible_features);
be64_to_cpus(&header.compatible_features);
be64_to_cpus(&header.autoclear_features);
be32_to_cpus(&header.refcount_order);
be32_to_cpus(&header.header_length);
if (header.header_length < 104) {
error_setg(errp, "qcow2 header too short");
ret = -EINVAL;
goto fail;
}
}
if (header.header_length > s->cluster_size) {
error_setg(errp, "qcow2 header exceeds cluster size");
ret = -EINVAL;
goto fail;
}
if (header.header_length > sizeof(header)) {
s->unknown_header_fields_size = header.header_length - sizeof(header);
s->unknown_header_fields = g_malloc(s->unknown_header_fields_size);
ret = bdrv_pread(bs->file, sizeof(header), s->unknown_header_fields,
s->unknown_header_fields_size);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read unknown qcow2 header "
"fields");
goto fail;
}
}
if (header.backing_file_offset > s->cluster_size) {
error_setg(errp, "Invalid backing file offset");
ret = -EINVAL;
goto fail;
}
if (header.backing_file_offset) {
ext_end = header.backing_file_offset;
} else {
ext_end = 1 << header.cluster_bits;
}
s->incompatible_features = header.incompatible_features;
s->compatible_features = header.compatible_features;
s->autoclear_features = header.autoclear_features;
if (s->incompatible_features & ~QCOW2_INCOMPAT_MASK) {
void *feature_table = NULL;
qcow2_read_extensions(bs, header.header_length, ext_end,
&feature_table, NULL);
report_unsupported_feature(errp, feature_table,
s->incompatible_features &
~QCOW2_INCOMPAT_MASK);
ret = -ENOTSUP;
g_free(feature_table);
goto fail;
}
if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) {
if ((flags & BDRV_O_RDWR) && !(flags & BDRV_O_CHECK)) {
error_setg(errp, "qcow2: Image is corrupt; cannot be opened "
"read/write");
ret = -EACCES;
goto fail;
}
}
if (header.refcount_order > 6) {
error_setg(errp, "Reference count entry width too large; may not "
"exceed 64 bits");
ret = -EINVAL;
goto fail;
}
s->refcount_order = header.refcount_order;
s->refcount_bits = 1 << s->refcount_order;
s->refcount_max = UINT64_C(1) << (s->refcount_bits - 1);
s->refcount_max += s->refcount_max - 1;
if (header.crypt_method > QCOW_CRYPT_AES) {
error_setg(errp, "Unsupported encryption method: %" PRIu32,
header.crypt_method);
ret = -EINVAL;
goto fail;
}
s->crypt_method_header = header.crypt_method;
if (s->crypt_method_header) {
if (bdrv_uses_whitelist() &&
s->crypt_method_header == QCOW_CRYPT_AES) {
error_setg(errp,
"Use of AES-CBC encrypted qcow2 images is no longer "
"supported in system emulators");
error_append_hint(errp,
"You can use 'qemu-img convert' to convert your "
"image to an alternative supported format, such "
"as unencrypted qcow2, or raw with the LUKS "
"format instead.\n");
ret = -ENOSYS;
goto fail;
}
bs->encrypted = true;
bs->valid_key = true;
}
s->l2_bits = s->cluster_bits - 3;
s->l2_size = 1 << s->l2_bits;
s->refcount_block_bits = s->cluster_bits - (s->refcount_order - 3);
s->refcount_block_size = 1 << s->refcount_block_bits;
bs->total_sectors = header.size / 512;
s->csize_shift = (62 - (s->cluster_bits - 8));
s->csize_mask = (1 << (s->cluster_bits - 8)) - 1;
s->cluster_offset_mask = (1LL << s->csize_shift) - 1;
s->refcount_table_offset = header.refcount_table_offset;
s->refcount_table_size =
header.refcount_table_clusters << (s->cluster_bits - 3);
if (header.refcount_table_clusters > qcow2_max_refcount_clusters(s)) {
error_setg(errp, "Reference count table too large");
ret = -EINVAL;
goto fail;
}
ret = validate_table_offset(bs, s->refcount_table_offset,
s->refcount_table_size, sizeof(uint64_t));
if (ret < 0) {
error_setg(errp, "Invalid reference count table offset");
goto fail;
}
if (header.nb_snapshots > QCOW_MAX_SNAPSHOTS) {
error_setg(errp, "Too many snapshots");
ret = -EINVAL;
goto fail;
}
ret = validate_table_offset(bs, header.snapshots_offset,
header.nb_snapshots,
sizeof(QCowSnapshotHeader));
if (ret < 0) {
error_setg(errp, "Invalid snapshot table offset");
goto fail;
}
if (header.l1_size > QCOW_MAX_L1_SIZE / sizeof(uint64_t)) {
error_setg(errp, "Active L1 table too large");
ret = -EFBIG;
goto fail;
}
s->l1_size = header.l1_size;
l1_vm_state_index = size_to_l1(s, header.size);
if (l1_vm_state_index > INT_MAX) {
error_setg(errp, "Image is too big");
ret = -EFBIG;
goto fail;
}
s->l1_vm_state_index = l1_vm_state_index;
if (s->l1_size < s->l1_vm_state_index) {
error_setg(errp, "L1 table is too small");
ret = -EINVAL;
goto fail;
}
ret = validate_table_offset(bs, header.l1_table_offset,
header.l1_size, sizeof(uint64_t));
if (ret < 0) {
error_setg(errp, "Invalid L1 table offset");
goto fail;
}
s->l1_table_offset = header.l1_table_offset;
if (s->l1_size > 0) {
s->l1_table = qemu_try_blockalign(bs->file->bs,
align_offset(s->l1_size * sizeof(uint64_t), 512));
if (s->l1_table == NULL) {
error_setg(errp, "Could not allocate L1 table");
ret = -ENOMEM;
goto fail;
}
ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table,
s->l1_size * sizeof(uint64_t));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read L1 table");
goto fail;
}
for(i = 0;i < s->l1_size; i++) {
be64_to_cpus(&s->l1_table[i]);
}
}
ret = qcow2_update_options(bs, options, flags, errp);
if (ret < 0) {
goto fail;
}
s->cluster_cache = g_malloc(s->cluster_size);
s->cluster_data = qemu_try_blockalign(bs->file->bs, QCOW_MAX_CRYPT_CLUSTERS
* s->cluster_size + 512);
if (s->cluster_data == NULL) {
error_setg(errp, "Could not allocate temporary cluster buffer");
ret = -ENOMEM;
goto fail;
}
s->cluster_cache_offset = -1;
s->flags = flags;
ret = qcow2_refcount_init(bs);
if (ret != 0) {
error_setg_errno(errp, -ret, "Could not initialize refcount handling");
goto fail;
}
QLIST_INIT(&s->cluster_allocs);
QTAILQ_INIT(&s->discards);
if (qcow2_read_extensions(bs, header.header_length, ext_end, NULL,
&local_err)) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto fail;
}
if (s->crypt_method_header == QCOW_CRYPT_AES) {
unsigned int cflags = 0;
if (flags & BDRV_O_NO_IO) {
cflags |= QCRYPTO_BLOCK_OPEN_NO_IO;
}
s->crypto = qcrypto_block_open(s->crypto_opts, NULL, NULL,
cflags, errp);
if (!s->crypto) {
ret = -EINVAL;
goto fail;
}
}
if (header.backing_file_offset != 0) {
len = header.backing_file_size;
if (len > MIN(1023, s->cluster_size - header.backing_file_offset) ||
len >= sizeof(bs->backing_file)) {
error_setg(errp, "Backing file name too long");
ret = -EINVAL;
goto fail;
}
ret = bdrv_pread(bs->file, header.backing_file_offset,
bs->backing_file, len);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read backing file name");
goto fail;
}
bs->backing_file[len] = '\0';
s->image_backing_file = g_strdup(bs->backing_file);
}
s->snapshots_offset = header.snapshots_offset;
s->nb_snapshots = header.nb_snapshots;
ret = qcow2_read_snapshots(bs);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read snapshots");
goto fail;
}
if (!bs->read_only && !(flags & BDRV_O_INACTIVE) && s->autoclear_features) {
s->autoclear_features = 0;
ret = qcow2_update_header(bs);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not update qcow2 header");
goto fail;
}
}
qemu_co_mutex_init(&s->lock);
bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP;
if (!(flags & (BDRV_O_CHECK | BDRV_O_INACTIVE)) && !bs->read_only &&
(s->incompatible_features & QCOW2_INCOMPAT_DIRTY)) {
BdrvCheckResult result = {0};
ret = qcow2_check(bs, &result, BDRV_FIX_ERRORS | BDRV_FIX_LEAKS);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not repair dirty image");
goto fail;
}
}
#ifdef DEBUG_ALLOC
{
BdrvCheckResult result = {0};
qcow2_check_refcounts(bs, &result, 0);
}
#endif
return ret;
fail:
g_free(s->unknown_header_fields);
cleanup_unknown_header_ext(bs);
qcow2_free_snapshots(bs);
qcow2_refcount_close(bs);
qemu_vfree(s->l1_table);
s->l1_table = NULL;
cache_clean_timer_del(bs);
if (s->l2_table_cache) {
qcow2_cache_destroy(bs, s->l2_table_cache);
}
if (s->refcount_block_cache) {
qcow2_cache_destroy(bs, s->refcount_block_cache);
}
g_free(s->cluster_cache);
qemu_vfree(s->cluster_data);
qcrypto_block_free(s->crypto);
qapi_free_QCryptoBlockOpenOptions(s->crypto_opts);
return ret;
}
| 1threat
|
Recursion with array's PHP : <p>I have a function (listarUrls ()) that returns / scans all the urls it finds on a web page.
I need that for each of the urls that the function returns to me, I return to the list / scan all the urls of that page
many times as requested by the user, that is</p>
<pre><code> .If the user asks for 1 iteration of the url www.a.com, bring back:
-$arry[0] www.1.com
-$arry[1] www.2.com
-..... So with all the urls you find in www.a.com
.If the user asks for 2 iteration of the url www.a.com, bring back:
-$arry[0] www.1.com
-$arry[0][0] www.1-1.com
-$arry[0][1] www.1-2.com
-...So with all the urls you find in www.1.com
-$arry[1] www.2.com
-$arry[1][0] www.2-1.com
-$arry[1][1] www.2-2.com
-...So with all the urls you find in www.2.com
-...
.If the user asks for 3 iteration of the url www.a.com, bring back:
-$arry[0] www.1.com
-$arry[0][0] www.1-1.com
-$arry[0][0][0] www.1-1-1.com
-$arry[0][0][1] www.1-1-2.com
-...So with all the urls you find in www.1-1.com
-$arry[0][1] www.1-2.com
-$arry[0][1][0] www.1-2-1.com
-$arry[0][1][1] www.1-2-2.com
-...So with all the urls you find in www.1-2.com
-$arry[1] www.2.com
-$arry[1][0] www.2-1.com
-$arry[1][0][0] www.2-1-1.com
-$arry[1][0][1] www.2-1-2.com
-...So with all the urls you find in www.2-1.com
-$arry[1][1] www.2-2.com
-$arry[1][1][0] www.2-2-1.com
-$arry[1][1][1] www.2-2-2.com
-...So with all the urls you find in www.2-2.com
-...
</code></pre>
<p>Could someone shed some light on the subject please?</p>
| 0debug
|
Output of the program : int main(void)
{
char c='012';
printf("%c",c);
return 0;
}
Why is 2 getting printed?
| 0debug
|
static int vp3_decode_end(AVCodecContext *avctx)
{
Vp3DecodeContext *s = avctx->priv_data;
av_free(s->all_fragments);
av_free(s->coded_fragment_list);
av_free(s->superblock_fragments);
av_free(s->superblock_macroblocks);
av_free(s->macroblock_fragments);
av_free(s->macroblock_coded);
avctx->release_buffer(avctx, &s->golden_frame);
avctx->release_buffer(avctx, &s->last_frame);
avctx->release_buffer(avctx, &s->current_frame);
return 0;
}
| 1threat
|
int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
VhostBackendType backend_type, uint32_t busyloop_timeout)
{
uint64_t features;
int i, r;
hdev->migration_blocker = NULL;
r = vhost_set_backend_type(hdev, backend_type);
assert(r >= 0);
r = hdev->vhost_ops->vhost_backend_init(hdev, opaque);
if (r < 0) {
goto fail;
}
if (used_memslots > hdev->vhost_ops->vhost_backend_memslots_limit(hdev)) {
fprintf(stderr, "vhost backend memory slots limit is less"
" than current number of present memory slots\n");
r = -1;
goto fail;
}
QLIST_INSERT_HEAD(&vhost_devices, hdev, entry);
r = hdev->vhost_ops->vhost_set_owner(hdev);
if (r < 0) {
goto fail;
}
r = hdev->vhost_ops->vhost_get_features(hdev, &features);
if (r < 0) {
goto fail;
}
for (i = 0; i < hdev->nvqs; ++i) {
r = vhost_virtqueue_init(hdev, hdev->vqs + i, hdev->vq_index + i);
if (r < 0) {
goto fail_vq;
}
}
if (busyloop_timeout) {
for (i = 0; i < hdev->nvqs; ++i) {
r = vhost_virtqueue_set_busyloop_timeout(hdev, hdev->vq_index + i,
busyloop_timeout);
if (r < 0) {
goto fail_busyloop;
}
}
}
hdev->features = features;
hdev->memory_listener = (MemoryListener) {
.begin = vhost_begin,
.commit = vhost_commit,
.region_add = vhost_region_add,
.region_del = vhost_region_del,
.region_nop = vhost_region_nop,
.log_start = vhost_log_start,
.log_stop = vhost_log_stop,
.log_sync = vhost_log_sync,
.log_global_start = vhost_log_global_start,
.log_global_stop = vhost_log_global_stop,
.eventfd_add = vhost_eventfd_add,
.eventfd_del = vhost_eventfd_del,
.priority = 10
};
if (hdev->migration_blocker == NULL) {
if (!(hdev->features & (0x1ULL << VHOST_F_LOG_ALL))) {
error_setg(&hdev->migration_blocker,
"Migration disabled: vhost lacks VHOST_F_LOG_ALL feature.");
} else if (!qemu_memfd_check()) {
error_setg(&hdev->migration_blocker,
"Migration disabled: failed to allocate shared memory");
}
}
if (hdev->migration_blocker != NULL) {
migrate_add_blocker(hdev->migration_blocker);
}
hdev->mem = g_malloc0(offsetof(struct vhost_memory, regions));
hdev->n_mem_sections = 0;
hdev->mem_sections = NULL;
hdev->log = NULL;
hdev->log_size = 0;
hdev->log_enabled = false;
hdev->started = false;
hdev->memory_changed = false;
memory_listener_register(&hdev->memory_listener, &address_space_memory);
return 0;
fail_busyloop:
while (--i >= 0) {
vhost_virtqueue_set_busyloop_timeout(hdev, hdev->vq_index + i, 0);
}
i = hdev->nvqs;
fail_vq:
while (--i >= 0) {
vhost_virtqueue_cleanup(hdev->vqs + i);
}
fail:
r = -errno;
hdev->vhost_ops->vhost_backend_cleanup(hdev);
QLIST_REMOVE(hdev, entry);
return r;
}
| 1threat
|
static void decode_delta_e(uint8_t *dst,
const uint8_t *buf, const uint8_t *buf_end,
int w, int flag, int bpp, int dst_size)
{
int planepitch = FFALIGN(w, 16) >> 3;
int pitch = planepitch * bpp;
int planepitch_byte = (w + 7) / 8;
unsigned entries, ofssrc;
GetByteContext gb, ptrs;
PutByteContext pb;
int k;
if (buf_end - buf <= 4 * bpp)
return;
bytestream2_init_writer(&pb, dst, dst_size);
bytestream2_init(&ptrs, buf, bpp * 4);
for (k = 0; k < bpp; k++) {
ofssrc = bytestream2_get_be32(&ptrs);
if (!ofssrc)
continue;
if (ofssrc >= buf_end - buf)
continue;
bytestream2_init(&gb, buf + ofssrc, buf_end - (buf + ofssrc));
entries = bytestream2_get_be16(&gb);
while (entries) {
int16_t opcode = bytestream2_get_be16(&gb);
unsigned offset = bytestream2_get_be32(&gb);
bytestream2_seek_p(&pb, (offset / planepitch_byte) * pitch + (offset % planepitch_byte) + k * planepitch, SEEK_SET);
if (opcode >= 0) {
uint16_t x = bytestream2_get_be16(&gb);
while (opcode && bytestream2_get_bytes_left_p(&pb) > 0) {
bytestream2_put_be16(&pb, x);
bytestream2_skip_p(&pb, pitch - 2);
opcode--;
}
} else {
opcode = -opcode;
while (opcode && bytestream2_get_bytes_left(&gb) > 0) {
bytestream2_put_be16(&pb, bytestream2_get_be16(&gb));
bytestream2_skip_p(&pb, pitch - 2);
opcode--;
}
}
entries--;
}
}
}
| 1threat
|
Is possible to use cookie based authentication with ASP.NET Web API and SPA? : <p>I want to create the web application which will be based on angularjs frontend and ASP.NET Web API. I need create the secure api but I can't use the token based authentication on the company's server where will be implemented this web application.</p>
<p>Is possible use the cookie based authentication for SPA and ASP.NET Web API?</p>
<p>How can I configure the cookie based authentication on the ASP.NET project for this scenario where I have the SPA and Web API?</p>
| 0debug
|
static int ea_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
EaDemuxContext *ea = s->priv_data;
AVStream *st;
if (!process_ea_header(s))
return AVERROR(EIO);
if (ea->video_codec) {
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
ea->video_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = ea->video_codec;
st->codec->codec_tag = 0;
st->codec->time_base = ea->time_base;
st->codec->width = ea->width;
st->codec->height = ea->height;
if (ea->audio_codec) {
if (ea->num_channels <= 0) {
av_log(s, AV_LOG_WARNING, "Unsupported number of channels: %d\n", ea->num_channels);
ea->audio_codec = 0;
if (ea->sample_rate <= 0) {
av_log(s, AV_LOG_ERROR, "Unsupported sample rate: %d\n", ea->sample_rate);
ea->audio_codec = 0;
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 33, 1, ea->sample_rate);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = ea->audio_codec;
st->codec->codec_tag = 0;
st->codec->channels = ea->num_channels;
st->codec->sample_rate = ea->sample_rate;
st->codec->bits_per_coded_sample = ea->bytes * 8;
st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
st->codec->bits_per_coded_sample / 4;
st->codec->block_align = st->codec->channels*st->codec->bits_per_coded_sample;
ea->audio_stream_index = st->index;
ea->audio_frame_counter = 0;
| 1threat
|
Boostrap - My table can't read a local json file : i don't know, i can't read some json file ou put a table which read json data (internal or external source)
Someone have an idea ?
here is my link and script i used
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.10.1/bootstrap-table.min.css">
<script src="https://unpkg.com/[email protected]/dist/bootstrap-table.min.js"></script>
Here is my script where I create the table, i use data-url to load the data from a local json file
<table id="table" data-toggle="table" data-height="460" data-search="true" data-url="data.json">
<thead>
<tr>
<th data-field="id">#</th>
<th data-field="oeuvre" data-search-formatter="false" data-formatter="nameFormatter">Oeuvres</th>
<th data-field="type" data-formatter="nameFormatter">Type</th>
<th data-field="artist" data-formatter="nameFormatter">Artiste</th>
<th data-field="sheet" data-formatter="nameFormatter">Fiche</th>
</tr>
</thead>
</table>
<script>
$table.bootstrapTable('refresh',{data: data})
})
function nameFormatter(value) {
return 'Formatted ' + value
}
var $table = $('#table')
$(function() {
var data = [
{"id":1,"oeuvre":"choppe","type":"Ambre","artist":"Etienne","sheet":"<a href=\"description.html\">"}
]
$table.bootstrapTable({data: data})
})
</script>
i really don't know why it doesn't work...
thanks in advance
| 0debug
|
static void tcg_constant_folding(TCGContext *s)
{
int oi, oi_next, nb_temps, nb_globals;
nb_temps = s->nb_temps;
nb_globals = s->nb_globals;
reset_all_temps(nb_temps);
for (oi = s->gen_first_op_idx; oi >= 0; oi = oi_next) {
tcg_target_ulong mask, partmask, affected;
int nb_oargs, nb_iargs, i;
TCGArg tmp;
TCGOp * const op = &s->gen_op_buf[oi];
TCGArg * const args = &s->gen_opparam_buf[op->args];
TCGOpcode opc = op->opc;
const TCGOpDef *def = &tcg_op_defs[opc];
oi_next = op->next;
if (opc == INDEX_op_call) {
nb_oargs = op->callo;
nb_iargs = op->calli;
} else {
nb_oargs = def->nb_oargs;
nb_iargs = def->nb_iargs;
}
for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) {
if (temps[args[i]].state == TCG_TEMP_COPY) {
args[i] = find_better_copy(s, args[i]);
}
}
switch (opc) {
CASE_OP_32_64(add):
CASE_OP_32_64(mul):
CASE_OP_32_64(and):
CASE_OP_32_64(or):
CASE_OP_32_64(xor):
CASE_OP_32_64(eqv):
CASE_OP_32_64(nand):
CASE_OP_32_64(nor):
CASE_OP_32_64(muluh):
CASE_OP_32_64(mulsh):
swap_commutative(args[0], &args[1], &args[2]);
break;
CASE_OP_32_64(brcond):
if (swap_commutative(-1, &args[0], &args[1])) {
args[2] = tcg_swap_cond(args[2]);
}
break;
CASE_OP_32_64(setcond):
if (swap_commutative(args[0], &args[1], &args[2])) {
args[3] = tcg_swap_cond(args[3]);
}
break;
CASE_OP_32_64(movcond):
if (swap_commutative(-1, &args[1], &args[2])) {
args[5] = tcg_swap_cond(args[5]);
}
if (swap_commutative(args[0], &args[4], &args[3])) {
args[5] = tcg_invert_cond(args[5]);
}
break;
CASE_OP_32_64(add2):
swap_commutative(args[0], &args[2], &args[4]);
swap_commutative(args[1], &args[3], &args[5]);
break;
CASE_OP_32_64(mulu2):
CASE_OP_32_64(muls2):
swap_commutative(args[0], &args[2], &args[3]);
break;
case INDEX_op_brcond2_i32:
if (swap_commutative2(&args[0], &args[2])) {
args[4] = tcg_swap_cond(args[4]);
}
break;
case INDEX_op_setcond2_i32:
if (swap_commutative2(&args[1], &args[3])) {
args[5] = tcg_swap_cond(args[5]);
}
break;
default:
break;
}
switch (opc) {
CASE_OP_32_64(shl):
CASE_OP_32_64(shr):
CASE_OP_32_64(sar):
CASE_OP_32_64(rotl):
CASE_OP_32_64(rotr):
if (temps[args[1]].state == TCG_TEMP_CONST
&& temps[args[1]].val == 0) {
tcg_opt_gen_movi(s, op, args, args[0], 0);
continue;
}
break;
CASE_OP_32_64(sub):
{
TCGOpcode neg_op;
bool have_neg;
if (temps[args[2]].state == TCG_TEMP_CONST) {
break;
}
if (opc == INDEX_op_sub_i32) {
neg_op = INDEX_op_neg_i32;
have_neg = TCG_TARGET_HAS_neg_i32;
} else {
neg_op = INDEX_op_neg_i64;
have_neg = TCG_TARGET_HAS_neg_i64;
}
if (!have_neg) {
break;
}
if (temps[args[1]].state == TCG_TEMP_CONST
&& temps[args[1]].val == 0) {
op->opc = neg_op;
reset_temp(args[0]);
args[1] = args[2];
continue;
}
}
break;
CASE_OP_32_64(xor):
CASE_OP_32_64(nand):
if (temps[args[1]].state != TCG_TEMP_CONST
&& temps[args[2]].state == TCG_TEMP_CONST
&& temps[args[2]].val == -1) {
i = 1;
goto try_not;
}
break;
CASE_OP_32_64(nor):
if (temps[args[1]].state != TCG_TEMP_CONST
&& temps[args[2]].state == TCG_TEMP_CONST
&& temps[args[2]].val == 0) {
i = 1;
goto try_not;
}
break;
CASE_OP_32_64(andc):
if (temps[args[2]].state != TCG_TEMP_CONST
&& temps[args[1]].state == TCG_TEMP_CONST
&& temps[args[1]].val == -1) {
i = 2;
goto try_not;
}
break;
CASE_OP_32_64(orc):
CASE_OP_32_64(eqv):
if (temps[args[2]].state != TCG_TEMP_CONST
&& temps[args[1]].state == TCG_TEMP_CONST
&& temps[args[1]].val == 0) {
i = 2;
goto try_not;
}
break;
try_not:
{
TCGOpcode not_op;
bool have_not;
if (def->flags & TCG_OPF_64BIT) {
not_op = INDEX_op_not_i64;
have_not = TCG_TARGET_HAS_not_i64;
} else {
not_op = INDEX_op_not_i32;
have_not = TCG_TARGET_HAS_not_i32;
}
if (!have_not) {
break;
}
op->opc = not_op;
reset_temp(args[0]);
args[1] = args[i];
continue;
}
default:
break;
}
switch (opc) {
CASE_OP_32_64(add):
CASE_OP_32_64(sub):
CASE_OP_32_64(shl):
CASE_OP_32_64(shr):
CASE_OP_32_64(sar):
CASE_OP_32_64(rotl):
CASE_OP_32_64(rotr):
CASE_OP_32_64(or):
CASE_OP_32_64(xor):
CASE_OP_32_64(andc):
if (temps[args[1]].state != TCG_TEMP_CONST
&& temps[args[2]].state == TCG_TEMP_CONST
&& temps[args[2]].val == 0) {
tcg_opt_gen_mov(s, op, args, args[0], args[1]);
continue;
}
break;
CASE_OP_32_64(and):
CASE_OP_32_64(orc):
CASE_OP_32_64(eqv):
if (temps[args[1]].state != TCG_TEMP_CONST
&& temps[args[2]].state == TCG_TEMP_CONST
&& temps[args[2]].val == -1) {
tcg_opt_gen_mov(s, op, args, args[0], args[1]);
continue;
}
break;
default:
break;
}
mask = -1;
affected = -1;
switch (opc) {
CASE_OP_32_64(ext8s):
if ((temps[args[1]].mask & 0x80) != 0) {
break;
}
CASE_OP_32_64(ext8u):
mask = 0xff;
goto and_const;
CASE_OP_32_64(ext16s):
if ((temps[args[1]].mask & 0x8000) != 0) {
break;
}
CASE_OP_32_64(ext16u):
mask = 0xffff;
goto and_const;
case INDEX_op_ext32s_i64:
if ((temps[args[1]].mask & 0x80000000) != 0) {
break;
}
case INDEX_op_ext32u_i64:
mask = 0xffffffffU;
goto and_const;
CASE_OP_32_64(and):
mask = temps[args[2]].mask;
if (temps[args[2]].state == TCG_TEMP_CONST) {
and_const:
affected = temps[args[1]].mask & ~mask;
}
mask = temps[args[1]].mask & mask;
break;
CASE_OP_32_64(andc):
if (temps[args[2]].state == TCG_TEMP_CONST) {
mask = ~temps[args[2]].mask;
goto and_const;
}
mask = temps[args[1]].mask;
break;
case INDEX_op_sar_i32:
if (temps[args[2]].state == TCG_TEMP_CONST) {
tmp = temps[args[2]].val & 31;
mask = (int32_t)temps[args[1]].mask >> tmp;
}
break;
case INDEX_op_sar_i64:
if (temps[args[2]].state == TCG_TEMP_CONST) {
tmp = temps[args[2]].val & 63;
mask = (int64_t)temps[args[1]].mask >> tmp;
}
break;
case INDEX_op_shr_i32:
if (temps[args[2]].state == TCG_TEMP_CONST) {
tmp = temps[args[2]].val & 31;
mask = (uint32_t)temps[args[1]].mask >> tmp;
}
break;
case INDEX_op_shr_i64:
if (temps[args[2]].state == TCG_TEMP_CONST) {
tmp = temps[args[2]].val & 63;
mask = (uint64_t)temps[args[1]].mask >> tmp;
}
break;
case INDEX_op_trunc_shr_i32:
mask = (uint64_t)temps[args[1]].mask >> args[2];
break;
CASE_OP_32_64(shl):
if (temps[args[2]].state == TCG_TEMP_CONST) {
tmp = temps[args[2]].val & (TCG_TARGET_REG_BITS - 1);
mask = temps[args[1]].mask << tmp;
}
break;
CASE_OP_32_64(neg):
mask = -(temps[args[1]].mask & -temps[args[1]].mask);
break;
CASE_OP_32_64(deposit):
mask = deposit64(temps[args[1]].mask, args[3], args[4],
temps[args[2]].mask);
break;
CASE_OP_32_64(or):
CASE_OP_32_64(xor):
mask = temps[args[1]].mask | temps[args[2]].mask;
break;
CASE_OP_32_64(setcond):
case INDEX_op_setcond2_i32:
mask = 1;
break;
CASE_OP_32_64(movcond):
mask = temps[args[3]].mask | temps[args[4]].mask;
break;
CASE_OP_32_64(ld8u):
mask = 0xff;
break;
CASE_OP_32_64(ld16u):
mask = 0xffff;
break;
case INDEX_op_ld32u_i64:
mask = 0xffffffffu;
break;
CASE_OP_32_64(qemu_ld):
{
TCGMemOpIdx oi = args[nb_oargs + nb_iargs];
TCGMemOp mop = get_memop(oi);
if (!(mop & MO_SIGN)) {
mask = (2ULL << ((8 << (mop & MO_SIZE)) - 1)) - 1;
}
}
break;
default:
break;
}
partmask = mask;
if (!(def->flags & TCG_OPF_64BIT)) {
mask |= ~(tcg_target_ulong)0xffffffffu;
partmask &= 0xffffffffu;
affected &= 0xffffffffu;
}
if (partmask == 0) {
assert(nb_oargs == 1);
tcg_opt_gen_movi(s, op, args, args[0], 0);
continue;
}
if (affected == 0) {
assert(nb_oargs == 1);
tcg_opt_gen_mov(s, op, args, args[0], args[1]);
continue;
}
switch (opc) {
CASE_OP_32_64(and):
CASE_OP_32_64(mul):
CASE_OP_32_64(muluh):
CASE_OP_32_64(mulsh):
if ((temps[args[2]].state == TCG_TEMP_CONST
&& temps[args[2]].val == 0)) {
tcg_opt_gen_movi(s, op, args, args[0], 0);
continue;
}
break;
default:
break;
}
switch (opc) {
CASE_OP_32_64(or):
CASE_OP_32_64(and):
if (temps_are_copies(args[1], args[2])) {
tcg_opt_gen_mov(s, op, args, args[0], args[1]);
continue;
}
break;
default:
break;
}
switch (opc) {
CASE_OP_32_64(andc):
CASE_OP_32_64(sub):
CASE_OP_32_64(xor):
if (temps_are_copies(args[1], args[2])) {
tcg_opt_gen_movi(s, op, args, args[0], 0);
continue;
}
break;
default:
break;
}
switch (opc) {
CASE_OP_32_64(mov):
tcg_opt_gen_mov(s, op, args, args[0], args[1]);
break;
CASE_OP_32_64(movi):
tcg_opt_gen_movi(s, op, args, args[0], args[1]);
break;
CASE_OP_32_64(not):
CASE_OP_32_64(neg):
CASE_OP_32_64(ext8s):
CASE_OP_32_64(ext8u):
CASE_OP_32_64(ext16s):
CASE_OP_32_64(ext16u):
case INDEX_op_ext32s_i64:
case INDEX_op_ext32u_i64:
if (temps[args[1]].state == TCG_TEMP_CONST) {
tmp = do_constant_folding(opc, temps[args[1]].val, 0);
tcg_opt_gen_movi(s, op, args, args[0], tmp);
break;
}
goto do_default;
case INDEX_op_trunc_shr_i32:
if (temps[args[1]].state == TCG_TEMP_CONST) {
tmp = do_constant_folding(opc, temps[args[1]].val, args[2]);
tcg_opt_gen_movi(s, op, args, args[0], tmp);
break;
}
goto do_default;
CASE_OP_32_64(add):
CASE_OP_32_64(sub):
CASE_OP_32_64(mul):
CASE_OP_32_64(or):
CASE_OP_32_64(and):
CASE_OP_32_64(xor):
CASE_OP_32_64(shl):
CASE_OP_32_64(shr):
CASE_OP_32_64(sar):
CASE_OP_32_64(rotl):
CASE_OP_32_64(rotr):
CASE_OP_32_64(andc):
CASE_OP_32_64(orc):
CASE_OP_32_64(eqv):
CASE_OP_32_64(nand):
CASE_OP_32_64(nor):
CASE_OP_32_64(muluh):
CASE_OP_32_64(mulsh):
CASE_OP_32_64(div):
CASE_OP_32_64(divu):
CASE_OP_32_64(rem):
CASE_OP_32_64(remu):
if (temps[args[1]].state == TCG_TEMP_CONST
&& temps[args[2]].state == TCG_TEMP_CONST) {
tmp = do_constant_folding(opc, temps[args[1]].val,
temps[args[2]].val);
tcg_opt_gen_movi(s, op, args, args[0], tmp);
break;
}
goto do_default;
CASE_OP_32_64(deposit):
if (temps[args[1]].state == TCG_TEMP_CONST
&& temps[args[2]].state == TCG_TEMP_CONST) {
tmp = deposit64(temps[args[1]].val, args[3], args[4],
temps[args[2]].val);
tcg_opt_gen_movi(s, op, args, args[0], tmp);
break;
}
goto do_default;
CASE_OP_32_64(setcond):
tmp = do_constant_folding_cond(opc, args[1], args[2], args[3]);
if (tmp != 2) {
tcg_opt_gen_movi(s, op, args, args[0], tmp);
break;
}
goto do_default;
CASE_OP_32_64(brcond):
tmp = do_constant_folding_cond(opc, args[0], args[1], args[2]);
if (tmp != 2) {
if (tmp) {
reset_all_temps(nb_temps);
op->opc = INDEX_op_br;
args[0] = args[3];
} else {
tcg_op_remove(s, op);
}
break;
}
goto do_default;
CASE_OP_32_64(movcond):
tmp = do_constant_folding_cond(opc, args[1], args[2], args[5]);
if (tmp != 2) {
tcg_opt_gen_mov(s, op, args, args[0], args[4-tmp]);
break;
}
goto do_default;
case INDEX_op_add2_i32:
case INDEX_op_sub2_i32:
if (temps[args[2]].state == TCG_TEMP_CONST
&& temps[args[3]].state == TCG_TEMP_CONST
&& temps[args[4]].state == TCG_TEMP_CONST
&& temps[args[5]].state == TCG_TEMP_CONST) {
uint32_t al = temps[args[2]].val;
uint32_t ah = temps[args[3]].val;
uint32_t bl = temps[args[4]].val;
uint32_t bh = temps[args[5]].val;
uint64_t a = ((uint64_t)ah << 32) | al;
uint64_t b = ((uint64_t)bh << 32) | bl;
TCGArg rl, rh;
TCGOp *op2 = insert_op_before(s, op, INDEX_op_movi_i32, 2);
TCGArg *args2 = &s->gen_opparam_buf[op2->args];
if (opc == INDEX_op_add2_i32) {
a += b;
} else {
a -= b;
}
rl = args[0];
rh = args[1];
tcg_opt_gen_movi(s, op, args, rl, (uint32_t)a);
tcg_opt_gen_movi(s, op2, args2, rh, (uint32_t)(a >> 32));
oi_next = op2->next;
break;
}
goto do_default;
case INDEX_op_mulu2_i32:
if (temps[args[2]].state == TCG_TEMP_CONST
&& temps[args[3]].state == TCG_TEMP_CONST) {
uint32_t a = temps[args[2]].val;
uint32_t b = temps[args[3]].val;
uint64_t r = (uint64_t)a * b;
TCGArg rl, rh;
TCGOp *op2 = insert_op_before(s, op, INDEX_op_movi_i32, 2);
TCGArg *args2 = &s->gen_opparam_buf[op2->args];
rl = args[0];
rh = args[1];
tcg_opt_gen_movi(s, op, args, rl, (uint32_t)r);
tcg_opt_gen_movi(s, op2, args2, rh, (uint32_t)(r >> 32));
oi_next = op2->next;
break;
}
goto do_default;
case INDEX_op_brcond2_i32:
tmp = do_constant_folding_cond2(&args[0], &args[2], args[4]);
if (tmp != 2) {
if (tmp) {
do_brcond_true:
reset_all_temps(nb_temps);
op->opc = INDEX_op_br;
args[0] = args[5];
} else {
do_brcond_false:
tcg_op_remove(s, op);
}
} else if ((args[4] == TCG_COND_LT || args[4] == TCG_COND_GE)
&& temps[args[2]].state == TCG_TEMP_CONST
&& temps[args[3]].state == TCG_TEMP_CONST
&& temps[args[2]].val == 0
&& temps[args[3]].val == 0) {
do_brcond_high:
reset_all_temps(nb_temps);
op->opc = INDEX_op_brcond_i32;
args[0] = args[1];
args[1] = args[3];
args[2] = args[4];
args[3] = args[5];
} else if (args[4] == TCG_COND_EQ) {
tmp = do_constant_folding_cond(INDEX_op_brcond_i32,
args[0], args[2], TCG_COND_EQ);
if (tmp == 0) {
goto do_brcond_false;
} else if (tmp == 1) {
goto do_brcond_high;
}
tmp = do_constant_folding_cond(INDEX_op_brcond_i32,
args[1], args[3], TCG_COND_EQ);
if (tmp == 0) {
goto do_brcond_false;
} else if (tmp != 1) {
goto do_default;
}
do_brcond_low:
reset_all_temps(nb_temps);
op->opc = INDEX_op_brcond_i32;
args[1] = args[2];
args[2] = args[4];
args[3] = args[5];
} else if (args[4] == TCG_COND_NE) {
tmp = do_constant_folding_cond(INDEX_op_brcond_i32,
args[0], args[2], TCG_COND_NE);
if (tmp == 0) {
goto do_brcond_high;
} else if (tmp == 1) {
goto do_brcond_true;
}
tmp = do_constant_folding_cond(INDEX_op_brcond_i32,
args[1], args[3], TCG_COND_NE);
if (tmp == 0) {
goto do_brcond_low;
} else if (tmp == 1) {
goto do_brcond_true;
}
goto do_default;
} else {
goto do_default;
}
break;
case INDEX_op_setcond2_i32:
tmp = do_constant_folding_cond2(&args[1], &args[3], args[5]);
if (tmp != 2) {
do_setcond_const:
tcg_opt_gen_movi(s, op, args, args[0], tmp);
} else if ((args[5] == TCG_COND_LT || args[5] == TCG_COND_GE)
&& temps[args[3]].state == TCG_TEMP_CONST
&& temps[args[4]].state == TCG_TEMP_CONST
&& temps[args[3]].val == 0
&& temps[args[4]].val == 0) {
do_setcond_high:
reset_temp(args[0]);
temps[args[0]].mask = 1;
op->opc = INDEX_op_setcond_i32;
args[1] = args[2];
args[2] = args[4];
args[3] = args[5];
} else if (args[5] == TCG_COND_EQ) {
tmp = do_constant_folding_cond(INDEX_op_setcond_i32,
args[1], args[3], TCG_COND_EQ);
if (tmp == 0) {
goto do_setcond_const;
} else if (tmp == 1) {
goto do_setcond_high;
}
tmp = do_constant_folding_cond(INDEX_op_setcond_i32,
args[2], args[4], TCG_COND_EQ);
if (tmp == 0) {
goto do_setcond_high;
} else if (tmp != 1) {
goto do_default;
}
do_setcond_low:
reset_temp(args[0]);
temps[args[0]].mask = 1;
op->opc = INDEX_op_setcond_i32;
args[2] = args[3];
args[3] = args[5];
} else if (args[5] == TCG_COND_NE) {
tmp = do_constant_folding_cond(INDEX_op_setcond_i32,
args[1], args[3], TCG_COND_NE);
if (tmp == 0) {
goto do_setcond_high;
} else if (tmp == 1) {
goto do_setcond_const;
}
tmp = do_constant_folding_cond(INDEX_op_setcond_i32,
args[2], args[4], TCG_COND_NE);
if (tmp == 0) {
goto do_setcond_low;
} else if (tmp == 1) {
goto do_setcond_const;
}
goto do_default;
} else {
goto do_default;
}
break;
case INDEX_op_call:
if (!(args[nb_oargs + nb_iargs + 1]
& (TCG_CALL_NO_READ_GLOBALS | TCG_CALL_NO_WRITE_GLOBALS))) {
for (i = 0; i < nb_globals; i++) {
reset_temp(i);
}
}
goto do_reset_output;
default:
do_default:
if (def->flags & TCG_OPF_BB_END) {
reset_all_temps(nb_temps);
} else {
do_reset_output:
for (i = 0; i < nb_oargs; i++) {
reset_temp(args[i]);
if (i == 0) {
temps[args[i]].mask = mask;
}
}
}
break;
}
}
}
| 1threat
|
UISplitViewController always show master view in iPad portrait mode iOS 9 : <p>I'm building a universal app using UISplitViewController and targeting iOS 9 and above. The app language is Objective-C.</p>
<p>Having started with the Xcode Master/Detail template and set up my views in the standard way, I'm realising that the app will be better if I keep the master view on screen at all times (on iPad), including when the device is in portrait mode. However, no matter how hard I search, I can't find anything to help me learn how this is achieved. I know this was previously achieved using splitViewController:shouldHideViewController:inOrientation:</p>
<p>However, this method is deprecated in iOS 9 and I can't figure out what replaces it and why. I've looked at the new delegate methods for UISplitViewController and find them completely lacking in any level of intuitiveness.</p>
<p>I'd really appreciate some pointers in regard to what replaces splitViewController:shouldHideViewController:inOrientation: and how it can be used to keep the master view displayed at all times on the iPad.</p>
| 0debug
|
void memory_region_init_io(MemoryRegion *mr,
const MemoryRegionOps *ops,
void *opaque,
const char *name,
uint64_t size)
{
memory_region_init(mr, name, size);
mr->ops = ops;
mr->opaque = opaque;
mr->terminates = true;
mr->backend_registered = false;
}
| 1threat
|
How to make a onclick iframe make a button visible? : <p>I cant figure out how todo this if i can get any help it would mean alot ove been stumped for the last hour looking everywhere for an awnser maybe im searching the wrong this i dont know. please help thanks!</p>
| 0debug
|
how to order my tuple of spark results descending order using value : <p>I am new to spark and scala. I need to order my result count tuple which is like (course, count) into descending order. I put like below</p>
<pre><code> val results = ratings.countByValue()
val sortedResults = results.toSeq.sortBy(_._2)
</code></pre>
<p>But still its't working. In the above way it will sort the results by count with ascending order. But I need to have it in descending order. Can anybody please help me.</p>
<p>Results would be like below</p>
<pre><code>(History, 12100),
(Music, 13200),
(Drama, 143000)
</code></pre>
<p>But I need to display it like below </p>
<pre><code>(Drama, 143000),
(Music, 13200),
(History, 12100)
</code></pre>
<p>thanks</p>
| 0debug
|
What is Synchronous and asynchronous in android? : <p>I want to know the definition and meaning of word Synchronous and Asynchronous.Can any one explain me these topics I will be really appreciate.</p>
| 0debug
|
what does the weak_alias function do and where is it defined : <p>So I'm looking through the source of gcc compiler and I've come along this in fork.c:</p>
<pre><code>int
__fork ()
{
__set_errno (ENOSYS);
return -1;
}
libc_hidden_def (__fork)
stub_warning (fork)
weak_alias (__fork, fork)
#include <stub-tag.h>
</code></pre>
<p>I'm trying to figure out what weak_alias does. I've used the grep command inside the glibc source files to find all occurrences of #define weak_alias:</p>
<pre><code>grep -r "#define weak_alias"
</code></pre>
<p>I've found many occurrences of the macro:</p>
<pre><code>#define weak_alias(n, a)
</code></pre>
<p>but the macros don't actually explain anything. They just define that statement they don't show how its being replaced. For example one occurrence is in profil.c:</p>
<pre><code>/* Turn off the attempt to generate ld aliasing records. */
#undef weak_alias
#define weak_alias(a,b)
</code></pre>
<p>So any ideas what weak_alias does and where it is being defined?</p>
<p>Thanks in advance</p>
| 0debug
|
av_cold void ff_vp8dsp_init_neon(VP8DSPContext *dsp)
{
dsp->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_neon;
dsp->vp8_idct_add = ff_vp8_idct_add_neon;
dsp->vp8_idct_dc_add = ff_vp8_idct_dc_add_neon;
dsp->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_neon;
dsp->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_neon;
dsp->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16_neon;
dsp->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16_neon;
dsp->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_neon;
dsp->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_neon;
dsp->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16_inner_neon;
dsp->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16_inner_neon;
dsp->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_neon;
dsp->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_neon;
dsp->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter16_simple_neon;
dsp->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter16_simple_neon;
dsp->put_vp8_epel_pixels_tab[0][0][0] = ff_put_vp8_pixels16_neon;
dsp->put_vp8_epel_pixels_tab[0][0][2] = ff_put_vp8_epel16_h6_neon;
dsp->put_vp8_epel_pixels_tab[0][2][0] = ff_put_vp8_epel16_v6_neon;
dsp->put_vp8_epel_pixels_tab[0][2][2] = ff_put_vp8_epel16_h6v6_neon;
dsp->put_vp8_epel_pixels_tab[1][0][0] = ff_put_vp8_pixels8_neon;
dsp->put_vp8_epel_pixels_tab[1][0][1] = ff_put_vp8_epel8_h4_neon;
dsp->put_vp8_epel_pixels_tab[1][0][2] = ff_put_vp8_epel8_h6_neon;
dsp->put_vp8_epel_pixels_tab[1][1][0] = ff_put_vp8_epel8_v4_neon;
dsp->put_vp8_epel_pixels_tab[1][1][1] = ff_put_vp8_epel8_h4v4_neon;
dsp->put_vp8_epel_pixels_tab[1][1][2] = ff_put_vp8_epel8_h6v4_neon;
dsp->put_vp8_epel_pixels_tab[1][2][0] = ff_put_vp8_epel8_v6_neon;
dsp->put_vp8_epel_pixels_tab[1][2][1] = ff_put_vp8_epel8_h4v6_neon;
dsp->put_vp8_epel_pixels_tab[1][2][2] = ff_put_vp8_epel8_h6v6_neon;
dsp->put_vp8_epel_pixels_tab[2][0][1] = ff_put_vp8_epel4_h4_neon;
dsp->put_vp8_epel_pixels_tab[2][0][2] = ff_put_vp8_epel4_h6_neon;
dsp->put_vp8_epel_pixels_tab[2][1][0] = ff_put_vp8_epel4_v4_neon;
dsp->put_vp8_epel_pixels_tab[2][1][1] = ff_put_vp8_epel4_h4v4_neon;
dsp->put_vp8_epel_pixels_tab[2][1][2] = ff_put_vp8_epel4_h6v4_neon;
dsp->put_vp8_epel_pixels_tab[2][2][0] = ff_put_vp8_epel4_v6_neon;
dsp->put_vp8_epel_pixels_tab[2][2][1] = ff_put_vp8_epel4_h4v6_neon;
dsp->put_vp8_epel_pixels_tab[2][2][2] = ff_put_vp8_epel4_h6v6_neon;
dsp->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_neon;
dsp->put_vp8_bilinear_pixels_tab[0][0][1] = ff_put_vp8_bilin16_h_neon;
dsp->put_vp8_bilinear_pixels_tab[0][0][2] = ff_put_vp8_bilin16_h_neon;
dsp->put_vp8_bilinear_pixels_tab[0][1][0] = ff_put_vp8_bilin16_v_neon;
dsp->put_vp8_bilinear_pixels_tab[0][1][1] = ff_put_vp8_bilin16_hv_neon;
dsp->put_vp8_bilinear_pixels_tab[0][1][2] = ff_put_vp8_bilin16_hv_neon;
dsp->put_vp8_bilinear_pixels_tab[0][2][0] = ff_put_vp8_bilin16_v_neon;
dsp->put_vp8_bilinear_pixels_tab[0][2][1] = ff_put_vp8_bilin16_hv_neon;
dsp->put_vp8_bilinear_pixels_tab[0][2][2] = ff_put_vp8_bilin16_hv_neon;
dsp->put_vp8_bilinear_pixels_tab[1][0][0] = ff_put_vp8_pixels8_neon;
dsp->put_vp8_bilinear_pixels_tab[1][0][1] = ff_put_vp8_bilin8_h_neon;
dsp->put_vp8_bilinear_pixels_tab[1][0][2] = ff_put_vp8_bilin8_h_neon;
dsp->put_vp8_bilinear_pixels_tab[1][1][0] = ff_put_vp8_bilin8_v_neon;
dsp->put_vp8_bilinear_pixels_tab[1][1][1] = ff_put_vp8_bilin8_hv_neon;
dsp->put_vp8_bilinear_pixels_tab[1][1][2] = ff_put_vp8_bilin8_hv_neon;
dsp->put_vp8_bilinear_pixels_tab[1][2][0] = ff_put_vp8_bilin8_v_neon;
dsp->put_vp8_bilinear_pixels_tab[1][2][1] = ff_put_vp8_bilin8_hv_neon;
dsp->put_vp8_bilinear_pixels_tab[1][2][2] = ff_put_vp8_bilin8_hv_neon;
dsp->put_vp8_bilinear_pixels_tab[2][0][1] = ff_put_vp8_bilin4_h_neon;
dsp->put_vp8_bilinear_pixels_tab[2][0][2] = ff_put_vp8_bilin4_h_neon;
dsp->put_vp8_bilinear_pixels_tab[2][1][0] = ff_put_vp8_bilin4_v_neon;
dsp->put_vp8_bilinear_pixels_tab[2][1][1] = ff_put_vp8_bilin4_hv_neon;
dsp->put_vp8_bilinear_pixels_tab[2][1][2] = ff_put_vp8_bilin4_hv_neon;
dsp->put_vp8_bilinear_pixels_tab[2][2][0] = ff_put_vp8_bilin4_v_neon;
dsp->put_vp8_bilinear_pixels_tab[2][2][1] = ff_put_vp8_bilin4_hv_neon;
dsp->put_vp8_bilinear_pixels_tab[2][2][2] = ff_put_vp8_bilin4_hv_neon;
}
| 1threat
|
static void cg3_initfn(Object *obj)
{
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
CG3State *s = CG3(obj);
memory_region_init_ram(&s->rom, NULL, "cg3.prom", FCODE_MAX_ROM_SIZE,
&error_abort);
memory_region_set_readonly(&s->rom, true);
sysbus_init_mmio(sbd, &s->rom);
memory_region_init_io(&s->reg, NULL, &cg3_reg_ops, s, "cg3.reg",
CG3_REG_SIZE);
sysbus_init_mmio(sbd, &s->reg);
}
| 1threat
|
How to make a method for downloading a jasper report on Spring Boot? : <p>I made a jasper report, and all the fields, get the list of objects I need to pass on to it. Just don't know how to continue.</p>
| 0debug
|
Schedule a Python script via batch on windows (using Anaconda) : <p>I have a script that i run every day and want to make a schedule for it, i have already tried a batch file with: </p>
<p><code>start C:\Users\name\Miniconda3\python.exe C:\script.py</code></p>
<p>And im able to run some basic python commands in it, the problem is that my actual script uses some libraries that were installed with Anaconda, and im unable to use them in the script since Anaconda will not load.</p>
<p>Im working on windows and can't find a way to start Anaconda and run my script there automatically every day.</p>
| 0debug
|
Which statement inserted independently at line 9 will compile? : import java.util.*;
4. class Business { }
5. class Hotel extends Business { }
6. class Inn extends Hotel { }
7. public class Travel {
8. ArrayList<Hotel> go()
{
9. // insert code here
10. }
11. }
| 0debug
|
Can someone explain me this? It's about arrays and some handling of an if statement inside of array : <p>I don't understand the part of the if statement in this piece of code.
And is it possible to write this with using if and else if?</p>
<pre><code>int klein(int A[], int n, int& i, int X)
{
int j;
int kl = -1;
i = -1;
for(j = 0; j < n; j++)
{
if(A[j] > X && (kl == -1 || A[j] < X))
{
i = j;
kl = A[j] ;
}
}
return kl;
}
</code></pre>
| 0debug
|
Check return status of psql command in unix shell scripting : <p>I am using psql command to connect and issue a query on postgreSQL database. Can anybody let me know how to check the return status of the executed query in shell script.</p>
<p>I have used <code>echo $?</code> command to check the status but it always returning zero.</p>
<p>Thanks for the help.</p>
| 0debug
|
ggplot inserting space before degree symbol on axis label : <p>I'd like to put a degree symbol on the x axis but the result has an extra space that I can't seem to get rid of. The text should read 'Temperature (*C)', not 'Temperature ( *C)'. I've tried two different solutions but can't seem to get rid of the space.</p>
<pre><code>ggdat<-data.frame(x=rnorm(100),y=rnorm(100))
#neither of these approaches work
xlab <- expression(paste('Temperature (',~degree,'C)',sep=''))
xlab <- expression('Temperature ('*~degree*C*')')
ggplot(data=ggdat,aes(x=x,y=y)) +
geom_point() +
labs(x=xlab)
</code></pre>
<p><a href="https://i.stack.imgur.com/SILdo.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/SILdo.jpg" alt="Scatter plot"></a></p>
<p>Any help is appreciated!</p>
<p>Ben</p>
| 0debug
|
Why does array.index("foo") raise an exception instead of returning -1 if no element is found? : <p>If I want to find the array index of a given item i Python, I'll do something like this:</p>
<pre><code>a = ["boo", "foo", "bar", "foz"]
i = a.index("foo")
</code></pre>
<p>and <code>i</code> would be <code>1</code></p>
<p>If I'm looking for a non existing item a <code>ValueError</code> exception is raised. </p>
<p><strong>Question:</strong> Why is it preferable to raise an exception instead of returning <code>-1</code> (as JavaScript's equivalent function <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf" rel="nofollow noreferrer"><code>indexOf</code></a> does)? I find it much easier to check for -1 instead of wrapping code blocks in try-catch.</p>
| 0debug
|
Can't able to check two date values are equal or not in typescript : <pre><code>var d1 = new Date("02/22/2018");
var d2 = new Date("02/22/2018");
if(d1 == d2){
}
</code></pre>
<p>** - this is not working. its always return false. but if I write a condition
as bellow then its working fine.**</p>
<pre><code>if(d1 <= d2 && d1 >= d2){
}
</code></pre>
| 0debug
|
How to print $ using String Interpolation : <p>I have just started learning scala .I want to print $ using String Interpolation</p>
<pre><code>def main(args:Array[String]){
println("Enter the string")
val inputString:String=readLine()
val inputAsDouble:Double=inputString.toDouble
printf(f" You owe '${inputAsDouble}%.1f3 ")
}
</code></pre>
<p>Input is 2.7255 I get output as .You owe 2.73 while i want it as You owe $2.73
any pointers will be of a great help</p>
| 0debug
|
static int pipe_open(URLContext *h, const char *filename, int flags)
{
int fd;
if (flags & URL_WRONLY) {
fd = 1;
} else {
fd = 0;
}
#if defined(__MINGW32__) || defined(CONFIG_OS2) || defined(__CYGWIN__)
setmode(fd, O_BINARY);
#endif
h->priv_data = (void *)(size_t)fd;
h->is_streamed = 1;
return 0;
}
| 1threat
|
static void ppc_prep_init(QEMUMachineInitArgs *args)
{
ram_addr_t ram_size = args->ram_size;
const char *cpu_model = args->cpu_model;
const char *kernel_filename = args->kernel_filename;
const char *kernel_cmdline = args->kernel_cmdline;
const char *initrd_filename = args->initrd_filename;
const char *boot_device = args->boot_device;
MemoryRegion *sysmem = get_system_memory();
PowerPCCPU *cpu = NULL;
CPUPPCState *env = NULL;
char *filename;
nvram_t nvram;
M48t59State *m48t59;
MemoryRegion *PPC_io_memory = g_new(MemoryRegion, 1);
PortioList *port_list = g_new(PortioList, 1);
#if 0
MemoryRegion *xcsr = g_new(MemoryRegion, 1);
#endif
int linux_boot, i, nb_nics1, bios_size;
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *bios = g_new(MemoryRegion, 1);
uint32_t kernel_base, initrd_base;
long kernel_size, initrd_size;
DeviceState *dev;
PCIHostState *pcihost;
PCIBus *pci_bus;
PCIDevice *pci;
ISABus *isa_bus;
ISADevice *isa;
qemu_irq *cpu_exit_irq;
int ppc_boot_device;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
sysctrl = g_malloc0(sizeof(sysctrl_t));
linux_boot = (kernel_filename != NULL);
if (cpu_model == NULL)
cpu_model = "602";
for (i = 0; i < smp_cpus; i++) {
cpu = cpu_ppc_init(cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to find PowerPC CPU definition\n");
exit(1);
}
env = &cpu->env;
if (env->flags & POWERPC_FLAG_RTC_CLK) {
cpu_ppc_tb_init(env, 7812500UL);
} else {
cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
}
qemu_register_reset(ppc_prep_reset, cpu);
}
memory_region_init_ram(ram, NULL, "ppc_prep.ram", ram_size);
vmstate_register_ram_global(ram);
memory_region_add_subregion(sysmem, 0, ram);
memory_region_init_ram(bios, NULL, "ppc_prep.bios", BIOS_SIZE);
memory_region_set_readonly(bios, true);
memory_region_add_subregion(sysmem, (uint32_t)(-BIOS_SIZE), bios);
vmstate_register_ram_global(bios);
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_elf(filename, NULL, NULL, NULL,
NULL, NULL, 1, ELF_MACHINE, 0);
if (bios_size < 0) {
bios_size = get_image_size(filename);
if (bios_size > 0 && bios_size <= BIOS_SIZE) {
hwaddr bios_addr;
bios_size = (bios_size + 0xfff) & ~0xfff;
bios_addr = (uint32_t)(-bios_size);
bios_size = load_image_targphys(filename, bios_addr, bios_size);
}
if (bios_size > BIOS_SIZE) {
fprintf(stderr, "qemu: PReP bios '%s' is too large (0x%x)\n",
bios_name, bios_size);
exit(1);
}
}
} else {
bios_size = -1;
}
if (bios_size < 0 && !qtest_enabled()) {
fprintf(stderr, "qemu: could not load PPC PReP bios '%s'\n",
bios_name);
exit(1);
}
if (filename) {
g_free(filename);
}
if (linux_boot) {
kernel_base = KERNEL_LOAD_ADDR;
kernel_size = load_image_targphys(kernel_filename, kernel_base,
ram_size - kernel_base);
if (kernel_size < 0) {
hw_error("qemu: could not load kernel '%s'\n", kernel_filename);
exit(1);
}
if (initrd_filename) {
initrd_base = INITRD_LOAD_ADDR;
initrd_size = load_image_targphys(initrd_filename, initrd_base,
ram_size - initrd_base);
if (initrd_size < 0) {
hw_error("qemu: could not load initial ram disk '%s'\n",
initrd_filename);
}
} else {
initrd_base = 0;
initrd_size = 0;
}
ppc_boot_device = 'm';
} else {
kernel_base = 0;
kernel_size = 0;
initrd_base = 0;
initrd_size = 0;
ppc_boot_device = '\0';
for (i = 0; boot_device[i] != '\0'; i++) {
if (boot_device[i] >= 'a' && boot_device[i] <= 'f') {
ppc_boot_device = boot_device[i];
break;
}
}
if (ppc_boot_device == '\0') {
fprintf(stderr, "No valid boot device for Mac99 machine\n");
exit(1);
}
}
if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
hw_error("Only 6xx bus is supported on PREP machine\n");
}
dev = qdev_create(NULL, "raven-pcihost");
pcihost = PCI_HOST_BRIDGE(dev);
object_property_add_child(qdev_get_machine(), "raven", OBJECT(dev), NULL);
qdev_init_nofail(dev);
pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0");
if (pci_bus == NULL) {
fprintf(stderr, "Couldn't create PCI host controller.\n");
exit(1);
}
pci = pci_create_simple(pci_bus, PCI_DEVFN(1, 0), "i82378");
cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
cpu = POWERPC_CPU(first_cpu);
qdev_connect_gpio_out(&pci->qdev, 0,
cpu->env.irq_inputs[PPC6xx_INPUT_INT]);
qdev_connect_gpio_out(&pci->qdev, 1, *cpu_exit_irq);
sysbus_connect_irq(&pcihost->busdev, 0, qdev_get_gpio_in(&pci->qdev, 9));
sysbus_connect_irq(&pcihost->busdev, 1, qdev_get_gpio_in(&pci->qdev, 11));
sysbus_connect_irq(&pcihost->busdev, 2, qdev_get_gpio_in(&pci->qdev, 9));
sysbus_connect_irq(&pcihost->busdev, 3, qdev_get_gpio_in(&pci->qdev, 11));
isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(pci), "isa.0"));
isa = isa_create(isa_bus, TYPE_PC87312);
dev = DEVICE(isa);
qdev_prop_set_uint8(dev, "config", 13);
qdev_init_nofail(dev);
memory_region_init_io(PPC_io_memory, NULL, &PPC_prep_io_ops, sysctrl,
"ppc-io", 0x00800000);
memory_region_add_subregion(sysmem, 0x80000000, PPC_io_memory);
pci_vga_init(pci_bus);
nb_nics1 = nb_nics;
if (nb_nics1 > NE2000_NB_MAX)
nb_nics1 = NE2000_NB_MAX;
for(i = 0; i < nb_nics1; i++) {
if (nd_table[i].model == NULL) {
nd_table[i].model = g_strdup("ne2k_isa");
}
if (strcmp(nd_table[i].model, "ne2k_isa") == 0) {
isa_ne2000_init(isa_bus, ne2000_io[i], ne2000_irq[i],
&nd_table[i]);
} else {
pci_nic_init_nofail(&nd_table[i], pci_bus, "ne2k_pci", NULL);
}
}
ide_drive_get(hd, MAX_IDE_BUS);
for(i = 0; i < MAX_IDE_BUS; i++) {
isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], ide_irq[i],
hd[2 * i],
hd[2 * i + 1]);
}
isa_create_simple(isa_bus, "i8042");
cpu = POWERPC_CPU(first_cpu);
sysctrl->reset_irq = cpu->env.irq_inputs[PPC6xx_INPUT_HRESET];
portio_list_init(port_list, NULL, prep_portio_list, sysctrl, "prep");
portio_list_add(port_list, get_system_io(), 0x0);
#if 0
memory_region_init_io(xcsr, NULL, &PPC_XCSR_ops, NULL, "ppc-xcsr", 0x1000);
memory_region_add_subregion(sysmem, 0xFEFF0000, xcsr);
#endif
if (usb_enabled(false)) {
pci_create_simple(pci_bus, -1, "pci-ohci");
}
m48t59 = m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 59);
if (m48t59 == NULL)
return;
sysctrl->nvram = m48t59;
nvram.opaque = m48t59;
nvram.read_fn = &m48t59_read;
nvram.write_fn = &m48t59_write;
PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "PREP", ram_size, ppc_boot_device,
kernel_base, kernel_size,
kernel_cmdline,
initrd_base, initrd_size,
0,
graphic_width, graphic_height, graphic_depth);
}
| 1threat
|
python: Random number generator that doesn't return values in range of all previously returned numbers : My goal is to generate random numbers between (0,500), but any new numbers have to be at minimum 120 more/less than any previously returned values. I am using python in processing, it has the function - random(), which accepts 2 arguments and returns a random number between them.
| 0debug
|
ESP32 CAM - EEPROM / sdcard / non erasable memory - beginier problem : {overwiew}
I am working on my first project with ESP32, I have ESP32 CAM model and I am creating an automatic roller blinds. I got most of the project working - I have web server that controls continous servo and all mechanics. I want to be able to adjust the time for going up-down without reprograming the microcontroller. The goal is to have an automatic roller blinds with alarm clock function.
{problem}
I need a way to reliable save/read data to store variables state, even without power. How to achive it with ESP32 CAM?
{additional info}
On arduino board that would be EEPROM, and I found some tutorials that claim that EEPROM can be used on ESP32. However, when I tried using EEPROM, it looks like the values are overwritten while bootloading. So I guess ESP32 CAM needs different approach. Correct me if I am wrong, please.
| 0debug
|
static BlockMeasureInfo *qcow2_measure(QemuOpts *opts, BlockDriverState *in_bs,
Error **errp)
{
Error *local_err = NULL;
BlockMeasureInfo *info;
uint64_t required = 0;
uint64_t virtual_size;
uint64_t refcount_bits;
uint64_t l2_tables;
size_t cluster_size;
int version;
char *optstr;
PreallocMode prealloc;
bool has_backing_file;
cluster_size = qcow2_opt_get_cluster_size_del(opts, &local_err);
if (local_err) {
goto err;
}
version = qcow2_opt_get_version_del(opts, &local_err);
if (local_err) {
goto err;
}
refcount_bits = qcow2_opt_get_refcount_bits_del(opts, version, &local_err);
if (local_err) {
goto err;
}
optstr = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
prealloc = qapi_enum_parse(PreallocMode_lookup, optstr,
PREALLOC_MODE__MAX, PREALLOC_MODE_OFF,
&local_err);
g_free(optstr);
if (local_err) {
goto err;
}
optstr = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FILE);
has_backing_file = !!optstr;
g_free(optstr);
virtual_size = align_offset(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),
cluster_size);
l2_tables = DIV_ROUND_UP(virtual_size / cluster_size,
cluster_size / sizeof(uint64_t));
if (l2_tables * sizeof(uint64_t) > QCOW_MAX_L1_SIZE) {
error_setg(&local_err, "The image size is too large "
"(try using a larger cluster size)");
goto err;
}
if (in_bs) {
int64_t ssize = bdrv_getlength(in_bs);
if (ssize < 0) {
error_setg_errno(&local_err, -ssize,
"Unable to get image virtual_size");
goto err;
}
virtual_size = align_offset(ssize, cluster_size);
if (has_backing_file) {
required = virtual_size;
} else {
int cluster_sectors = cluster_size / BDRV_SECTOR_SIZE;
int64_t sector_num;
int pnum = 0;
for (sector_num = 0;
sector_num < ssize / BDRV_SECTOR_SIZE;
sector_num += pnum) {
int nb_sectors = MAX(ssize / BDRV_SECTOR_SIZE - sector_num,
INT_MAX);
BlockDriverState *file;
int64_t ret;
ret = bdrv_get_block_status_above(in_bs, NULL,
sector_num, nb_sectors,
&pnum, &file);
if (ret < 0) {
error_setg_errno(&local_err, -ret,
"Unable to get block status");
goto err;
}
if (ret & BDRV_BLOCK_ZERO) {
} else if ((ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ALLOCATED)) ==
(BDRV_BLOCK_DATA | BDRV_BLOCK_ALLOCATED)) {
pnum = ROUND_UP(sector_num + pnum, cluster_sectors) -
sector_num;
required += (sector_num % cluster_sectors + pnum) *
BDRV_SECTOR_SIZE;
}
}
}
}
if (prealloc == PREALLOC_MODE_FULL || prealloc == PREALLOC_MODE_FALLOC) {
required = virtual_size;
}
info = g_new(BlockMeasureInfo, 1);
info->fully_allocated =
qcow2_calc_prealloc_size(virtual_size, cluster_size,
ctz32(refcount_bits));
info->required = info->fully_allocated - virtual_size + required;
return info;
err:
error_propagate(errp, local_err);
return NULL;
}
| 1threat
|
void aio_context_ref(AioContext *ctx)
{
g_source_ref(&ctx->source);
}
| 1threat
|
static void send_ext_audio_ack(VncState *vs)
{
vnc_lock_output(vs);
vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);
vnc_write_u8(vs, 0);
vnc_write_u16(vs, 1);
vnc_framebuffer_update(vs, 0, 0,
surface_width(vs->vd->ds),
surface_height(vs->vd->ds),
VNC_ENCODING_AUDIO);
vnc_unlock_output(vs);
vnc_flush(vs);
}
| 1threat
|
Differences b/n mapState, mapGetters, mapActions, mapMutations in Vuex : <p>I have been using vue/vuex for months and I see <code>mapState</code>, <code>mapGetters</code>, <code>mapActions</code>, <code>mapMutations</code> but don't know what they do except for <code>mapState</code>.</p>
<p>This is how I use <code>mapState</code></p>
<pre><code>// mutations.js
user: {
address: {},
name: '',
age: ''
}
</code></pre>
<p>and in my code I have something like this: </p>
<pre><code>import { mapState } from 'vuex'
export default {
data: {},
computed: {
...mapState({
address: state => state.user.address
})
}
}
</code></pre>
<p>then I can use address anywhere, but I don't know what the others are used for. </p>
<p>can someone give a simple example? thanks</p>
| 0debug
|
static void parse_palette_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
PGSSubContext *ctx = avctx->priv_data;
const uint8_t *buf_end = buf + buf_size;
const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
int color_id;
int y, cb, cr, alpha;
int r, g, b, r_add, g_add, b_add;
buf += 2;
while (buf < buf_end) {
color_id = bytestream_get_byte(&buf);
y = bytestream_get_byte(&buf);
cr = bytestream_get_byte(&buf);
cb = bytestream_get_byte(&buf);
alpha = bytestream_get_byte(&buf);
YUV_TO_RGB1(cb, cr);
YUV_TO_RGB2(r, g, b, y);
av_dlog(avctx, "Color %d := (%d,%d,%d,%d)\n", color_id, r, g, b, alpha);
ctx->clut[color_id] = RGBA(r,g,b,alpha);
}
}
| 1threat
|
How to define build-args in docker-compose? : <p>I have the following docker-compose file </p>
<pre><code>version: '3'
services:
node1:
build: node1
image: node1
container_name: node1
node2:
build: node2
image: node2
container_name: node2
</code></pre>
<p>I can build both images and start them with a single command</p>
<p><code>docker-compose up -d --build</code></p>
<p>But I would like to use build-args on the builds. The original build script of the image outside of the scope of compose looks something like this</p>
<pre><code>#!/bin/sh
docker build \
--build-arg ADMIN_USERNNAME_1=weblogic \
--build-arg ADMIN_PASSWORD_1=weblogic1 \
--build-arg ADMIN_NAME_1=admin \
--build-arg ...
--build-arg ... \
-t test/foo .
</code></pre>
<p>Both images would use build-args of the same name but different value. Also, as there are dozens of build args, it would be convenient to store them in a compose service specific build-properties file. Is this possible with docker-compose?</p>
| 0debug
|
How can i "eliminate" a object name form a javascript object? : I want to get is the following thing.
Starting from a json like this:
{ "de"{ "errors.de.i18n.js": { "errors": { "addcreditcard":"Wir konnten diese Karte nicht verifizieren. Bitte überprüfe deine Angaben und versuche es noch einmal.",...
How can i get this ?:
{ "de"{ "errors": { "addcreditcard":"Wir konnten diese Karte nicht verifizieren. Bitte überprüfe deine Angaben und versuche es noch einmal.",
Thank you all
| 0debug
|
Angular 2 observable subscribing twice executes call twice : <p><strong>Problem</strong><br>
I subscribe to an httpClient.get observable twice. However, this means that my call gets executed twice. Why is this?</p>
<p><strong>Proof</strong><br>
For every subscribe() I do, I get another line in the login page.</p>
<p><strong>Code (onSubmit() from login page button)</strong></p>
<pre><code>var httpHeaders = new HttpHeaders()
.append("Authorization", 'Basic ' + btoa(this.username + ':' + this.password));
var observable = this.httpClient.get('api/version/secured', { headers: httpHeaders});
observable.subscribe(
() => {
console.log('First request completed');
},
(error: HttpErrorResponse) => {
console.log('First request error');
}
);
observable.subscribe(
() => {
console.log('Second request completed');
},
(error: HttpErrorResponse) => {
console.log('Second request error');
}
);
</code></pre>
<p><strong>Console</strong></p>
<pre><code>zone.js:2935 GET http://localhost:4200/api/version/secured 401 (Unauthorized)
login.component.ts:54 First request error
zone.js:2935 GET http://localhost:4200/api/version/secured 401 (Unauthorized)
login.component.ts:62 First request error
</code></pre>
<p><strong>Irrelevant background</strong><br>
I have a LogonService object which handles al my login functionality. It contains a boolean variable that shows whether I am logged in or not. Whenever I call the login function, it subscribes to the observable of the httpClient.get, to set the login variable to true or false. But the login function also returns the observable, which gets subscribed to. Took me some time to link the double request to the double subscription. If there is a better way of tracking the login than through a variable, let me know! I am trying to learn angular :)</p>
| 0debug
|
FTP connexion with implicit TLS by Python : <p>Does anyone know how to connect FTP with implicit TLS via Python?</p>
<p>Thank you</p>
| 0debug
|
How can I call a method from another class with constructors? : <p>I have two classes with a constructor. How can I call a method from one class to another?</p>
| 0debug
|
Bootsrap Custom nav bar shapes : I want make a custom nav bar shapes like below attached images.
[Design image][1]
I have use below css for this shape.
```
.navbar-nav.nav-bar-custom{
transform: skew(-21deg);
border: 1px solid black;
}
```
But when use this. all my text looks like italic shape. see attached image.
[After add above css][2]
Any one can help me to resolve this issue?
[1]: https://i.stack.imgur.com/G7iIV.png
[2]: https://i.stack.imgur.com/yC7sY.png
| 0debug
|
If..else loop and array does not follow condition for php : I had problem with this particular code. The conditions are:
~When `$rows['Machine#']` is not in array, push in `$machineArr` array and unset the `$totalTimeArr` array.
~When `$rows['Machine#']` is in the array, push `$rows['TotalTime']` into `$totalTimeArr` array for addition.
~`$graphArr[]` should be updated (for `array_sum($totalTimeArr)`) first before push into array.
I now have problems regarding the third condition. It does not calculate first, instead it pushes the first data input. I have tried using `do while` loop, putting `$graphArr[] = '["'.$rows['Machine#'].'",'.array_sum($totalTimeArr).']';` outside the `if else` loop, but this seems to be the closest I can get to what its supposed to be. Other codes doesnt seem to have problems and work well. Appreciate your recommendations/suggestions/assistance. Thanks. Below is the code.
while ($rows = mysqli_fetch_array($conn))
{
if(!(in_array($rows['Machine#'], $machineArr)))
{
unset($totalTimeArr);
$machineArr[] = $rows['Machine#'];
$totalTimeArr[] = $rows['TotalTime'];
$graphArr[] = '["'.$rows['Machine#'].'",'.array_sum($totalTimeArr).']';
}
else if(in_array($rows['Machine#'], $machineArr))
{
$totalTimeArr[] = $rows['TotalTime'];
}
}
| 0debug
|
Launching Explorer from WSL : <p><code>start .</code> is used to launch an explorer window from cmd.</p>
<p>When doing the same from wsl, I get</p>
<blockquote>
<p>$ start . start: Unable to connect to system bus: Failed to connect to
socket /var/run/dbus/system_bus_socket: No such file or directory</p>
</blockquote>
<p>Is there an easy way to fix this?</p>
| 0debug
|
How to customise config.toml on Kubernetes? : <p>I'm have a Gitlab cloud connected to a k8s cluster running on Google (GKE).
The cluster was created via Gitlab cloud.</p>
<p>I want to customise the <code>config.toml</code> because I want to <em>fix</em> the cache on k8s as suggested in <a href="https://gitlab.com/gitlab-org/gitlab-runner/issues/1906" rel="noreferrer">this issue</a>.</p>
<p>I found the <code>config.toml</code> configuration in the <code>runner-gitlab-runner</code> ConfigMap.
I updated the ConfigMap to contain this <code>config.toml</code> setup:</p>
<pre><code> config.toml: |
concurrent = 4
check_interval = 3
log_level = "info"
listen_address = '[::]:9252'
[[runners]]
executor = "kubernetes"
cache_dir = "/tmp/gitlab/cache"
[runners.kubernetes]
memory_limit = "1Gi"
[runners.kubernetes.node_selector]
gitlab = "true"
[[runners.kubernetes.volumes.host_path]]
name = "gitlab-cache"
mount_path = "/tmp/gitlab/cache"
host_path = "/home/core/data/gitlab-runner/data"
</code></pre>
<p>To apply the changes I deleted the <code>runner-gitlab-runner-xxxx-xxx</code> pod so a new one gets created with the updated <code>config.toml</code>.</p>
<p>However, when I look into the new pod, the <code>/home/gitlab-runner/.gitlab-runner/config.toml</code> now contains 2 <code>[[runners]]</code> sections:</p>
<pre><code>listen_address = "[::]:9252"
concurrent = 4
check_interval = 3
log_level = "info"
[session_server]
session_timeout = 1800
[[runners]]
name = ""
url = ""
token = ""
executor = "kubernetes"
cache_dir = "/tmp/gitlab/cache"
[runners.kubernetes]
host = ""
bearer_token_overwrite_allowed = false
image = ""
namespace = ""
namespace_overwrite_allowed = ""
privileged = false
memory_limit = "1Gi"
service_account_overwrite_allowed = ""
pod_annotations_overwrite_allowed = ""
[runners.kubernetes.node_selector]
gitlab = "true"
[runners.kubernetes.volumes]
[[runners.kubernetes.volumes.host_path]]
name = "gitlab-cache"
mount_path = "/tmp/gitlab/cache"
host_path = "/home/core/data/gitlab-runner/data"
[[runners]]
name = "runner-gitlab-runner-xxx-xxx"
url = "https://gitlab.com/"
token = "<my-token>"
executor = "kubernetes"
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.kubernetes]
host = ""
bearer_token_overwrite_allowed = false
image = "ubuntu:16.04"
namespace = "gitlab-managed-apps"
namespace_overwrite_allowed = ""
privileged = true
service_account_overwrite_allowed = ""
pod_annotations_overwrite_allowed = ""
[runners.kubernetes.volumes]
</code></pre>
<p>The file <code>/scripts/config.toml</code> is the configuration as I created it in the ConfigMap.
So I suspect the <code>/home/gitlab-runner/.gitlab-runner/config.toml</code> is somehow updated when registering the Gitlab-Runner with the Gitlab cloud.</p>
<p>If if changing the <code>config.toml</code> via the ConfigMap does not work, how should I then change the configuration? I cannot find anything about this in Gitlab or Gitlab documentation.</p>
| 0debug
|
Suppose i have matrix the first and second column represent x,y-coordinates and third column is cluster id :
95.0129 5.7891 3.0000
23.1139 35.2868 1.0000
60.6843 81.3166 2.0000
48.5982 0.9861 3.0000
89.1299 13.8891 3.0000
76.2097 20.2765 3.0000
45.6468 19.8722 3.0000
1.8504 60.3792 1.0000
82.1407 27.2188 3.0000
44.4703 19.8814 3.0000
61.5432 1.5274 3.0000
79.1937 74.6786 2.0000
92.1813 44.5096 2.0000
73.8207 93.1815 2.0000
17.6266 46.5994 1.0000
40.5706 41.8649 1.0000
93.5470 84.6221 2.0000
91.6904 52.5152 2.0000
41.0270 20.2647 3.0000
89.3650 67.2137 2.0000
I want create the matrix of individual cluster id with its x,y coordinates using matlab, for example cluster 1; c(1)= [23.1139 35.2868 ;17.6266 46.5994;40.5706 41.8649]
| 0debug
|
How can I install JDK on Ubuntu 32 bits? : <p>I read this <a href="http://www.oracle.com/technetwork/java/javase/install-linux-self-extracting-138783.html" rel="nofollow noreferrer">tutorial</a> from Oracle but it doesn't work anyway. Any of you guys know how to install JDK on Ubuntu 32 bits?</p>
| 0debug
|
decode_coeffs_b_generic(VP56RangeCoder *c, int16_t *coef, int n_coeffs,
int is_tx32x32, int is8bitsperpixel, int bpp, unsigned (*cnt)[6][3],
unsigned (*eob)[6][2], uint8_t (*p)[6][11],
int nnz, const int16_t *scan, const int16_t (*nb)[2],
const int16_t *band_counts, const int16_t *qmul)
{
int i = 0, band = 0, band_left = band_counts[band];
uint8_t *tp = p[0][nnz];
uint8_t cache[1024];
do {
int val, rc;
val = vp56_rac_get_prob_branchy(c, tp[0]);
eob[band][nnz][val]++;
if (!val)
break;
skip_eob:
if (!vp56_rac_get_prob_branchy(c, tp[1])) {
cnt[band][nnz][0]++;
if (!--band_left)
band_left = band_counts[++band];
cache[scan[i]] = 0;
nnz = (1 + cache[nb[i][0]] + cache[nb[i][1]]) >> 1;
tp = p[band][nnz];
if (++i == n_coeffs)
break;
goto skip_eob;
}
rc = scan[i];
if (!vp56_rac_get_prob_branchy(c, tp[2])) {
cnt[band][nnz][1]++;
val = 1;
cache[rc] = 1;
} else {
if (!tp[3])
memcpy(&tp[3], ff_vp9_model_pareto8[tp[2]], 8);
cnt[band][nnz][2]++;
if (!vp56_rac_get_prob_branchy(c, tp[3])) {
if (!vp56_rac_get_prob_branchy(c, tp[4])) {
cache[rc] = val = 2;
} else {
val = 3 + vp56_rac_get_prob(c, tp[5]);
cache[rc] = 3;
}
} else if (!vp56_rac_get_prob_branchy(c, tp[6])) {
cache[rc] = 4;
if (!vp56_rac_get_prob_branchy(c, tp[7])) {
val = vp56_rac_get_prob(c, 159) + 5;
} else {
val = (vp56_rac_get_prob(c, 165) << 1) + 7;
val += vp56_rac_get_prob(c, 145);
}
} else {
cache[rc] = 5;
if (!vp56_rac_get_prob_branchy(c, tp[8])) {
if (!vp56_rac_get_prob_branchy(c, tp[9])) {
val = 11 + (vp56_rac_get_prob(c, 173) << 2);
val += (vp56_rac_get_prob(c, 148) << 1);
val += vp56_rac_get_prob(c, 140);
} else {
val = 19 + (vp56_rac_get_prob(c, 176) << 3);
val += (vp56_rac_get_prob(c, 155) << 2);
val += (vp56_rac_get_prob(c, 140) << 1);
val += vp56_rac_get_prob(c, 135);
}
} else if (!vp56_rac_get_prob_branchy(c, tp[10])) {
val = (vp56_rac_get_prob(c, 180) << 4) + 35;
val += (vp56_rac_get_prob(c, 157) << 3);
val += (vp56_rac_get_prob(c, 141) << 2);
val += (vp56_rac_get_prob(c, 134) << 1);
val += vp56_rac_get_prob(c, 130);
} else {
val = 67;
if (!is8bitsperpixel) {
if (bpp == 12) {
val += vp56_rac_get_prob(c, 255) << 17;
val += vp56_rac_get_prob(c, 255) << 16;
}
val += (vp56_rac_get_prob(c, 255) << 15);
val += (vp56_rac_get_prob(c, 255) << 14);
}
val += (vp56_rac_get_prob(c, 254) << 13);
val += (vp56_rac_get_prob(c, 254) << 12);
val += (vp56_rac_get_prob(c, 254) << 11);
val += (vp56_rac_get_prob(c, 252) << 10);
val += (vp56_rac_get_prob(c, 249) << 9);
val += (vp56_rac_get_prob(c, 243) << 8);
val += (vp56_rac_get_prob(c, 230) << 7);
val += (vp56_rac_get_prob(c, 196) << 6);
val += (vp56_rac_get_prob(c, 177) << 5);
val += (vp56_rac_get_prob(c, 153) << 4);
val += (vp56_rac_get_prob(c, 140) << 3);
val += (vp56_rac_get_prob(c, 133) << 2);
val += (vp56_rac_get_prob(c, 130) << 1);
val += vp56_rac_get_prob(c, 129);
}
}
}
#define STORE_COEF(c, i, v) do { \
if (is8bitsperpixel) { \
c[i] = v; \
} else { \
AV_WN32A(&c[i * 2], v); \
} \
} while (0)
if (!--band_left)
band_left = band_counts[++band];
if (is_tx32x32)
STORE_COEF(coef, rc, ((vp8_rac_get(c) ? -val : val) * qmul[!!i]) / 2);
else
STORE_COEF(coef, rc, (vp8_rac_get(c) ? -val : val) * qmul[!!i]);
nnz = (1 + cache[nb[i][0]] + cache[nb[i][1]]) >> 1;
tp = p[band][nnz];
} while (++i < n_coeffs);
return i;
}
| 1threat
|
Indentationt error Python (if/else) : i have a problem with my code. I dont know why but the python compiler throw me an error about indentation in my "else"
def enum2(q,k):
n = q.length
if k == n:
#asdasdsa
else:
for i in range(0,n):
q[k] = i
if (isSafe(q,k)):
enum2(q,k+1)
else:
^
IndentationError: expected an indented block
i searched some spaces but i didnt find nothing just tabs.
| 0debug
|
PySpark - Pass list as parameter to UDF : <p>I need to pass a list into a UDF, the list will determine the score/category of the distance. For now, I am hard coding all distances to be the 4th score.</p>
<pre><code>a= spark.createDataFrame([("A", 20), ("B", 30), ("D", 80)],["Letter", "distances"])
from pyspark.sql.functions import udf
def cate(label, feature_list):
if feature_list == 0:
return label[4]
label_list = ["Great", "Good", "OK", "Please Move", "Dead"]
udf_score=udf(cate, StringType())
a.withColumn("category", udf_score(label_list,a["distances"])).show(10)
</code></pre>
<p>when I try something like this, I get this error. </p>
<pre><code>Py4JError: An error occurred while calling z:org.apache.spark.sql.functions.col. Trace:
py4j.Py4JException: Method col([class java.util.ArrayList]) does not exist
at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:318)
at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:339)
at py4j.Gateway.invoke(Gateway.java:274)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.GatewayConnection.run(GatewayConnection.java:214)
at java.lang.Thread.run(Thread.java:745)
</code></pre>
| 0debug
|
How to add attribute in TR and TD? : <p>I want to add row using data datatables, and I can do it like this</p>
<pre><code>var table = $('#mytable').DataTable();
table.add.row(['first column', 'second column', 'three column', 'etc']);
</code></pre>
<p>What I need is something like this (some attribute in TR and TD tag)</p>
<pre><code><tr id="someID">
<td>first column</td>
<td>second column</td>
<td>three column</td>
<td id="otherID">etc</td>
</tr>
</code></pre>
<p>How I can do it with datatables?</p>
| 0debug
|
static uint32_t drc_unisolate_logical(sPAPRDRConnector *drc)
{
if (!drc->dev ||
drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_UNUSABLE) {
return RTAS_OUT_NO_SUCH_INDICATOR;
}
drc->isolation_state = SPAPR_DR_ISOLATION_STATE_UNISOLATED;
return RTAS_OUT_SUCCESS;
}
| 1threat
|
count two different buttons with one calculate function : I'm sure this is simple but I can't seem to wrap my mind around it. I have two buttons in my C# wpf form, one to mark an answer right, one to mark it wrong. All I need to do is keep track of how many times each button is clicked, but with ONE calculate method. Any ideas?
| 0debug
|
int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, size;
size = RAW_PACKET_SIZE;
if (av_new_packet(pkt, size) < 0)
return AVERROR(ENOMEM);
pkt->pos= avio_tell(s->pb);
pkt->stream_index = 0;
ret = ffio_read_partial(s->pb, pkt->data, size);
if (ret < 0) {
av_free_packet(pkt);
return ret;
}
pkt->size = ret;
return ret;
}
| 1threat
|
Object *object_dynamic_cast(Object *obj, const char *typename)
{
GSList *i;
if (object_is_type(obj, typename)) {
return obj;
}
for (i = obj->interfaces; i; i = i->next) {
Interface *iface = i->data;
if (object_is_type(OBJECT(iface), typename)) {
return OBJECT(iface);
}
}
if (object_is_type(obj, TYPE_INTERFACE)) {
Interface *iface = INTERFACE(obj);
if (object_is_type(iface->obj, typename)) {
return iface->obj;
}
}
return NULL;
}
| 1threat
|
Intellij Window open Minimized : <p>When Opening up a new project in Intellij the window opens up extremely minimized and almost impossible to see. Is there a properly to set the default window size when opening. </p>
<p>My Setup
Mac OSX El Capitan
Intellij 2015 - 16.3.4 (I have experienced this in all of these versions)</p>
<p>See image below for how small the Window opens </p>
<p><a href="https://i.stack.imgur.com/s6i29.png" rel="noreferrer"><img src="https://i.stack.imgur.com/s6i29.png" alt="enter image description here"></a></p>
| 0debug
|
I need to filter the list based on the user input in sala list : How to get the result as like below..?Can anyone help....
val original=List("a","ab","abc","abcd","zadad","ji","jijdf","bcab",
"frab","abkcdef","opabcd")
val find="ab"
val result="abc","abcd","bcab","frab","abcdef","opabcd"
| 0debug
|
Improve design movement on Snake game : <p>I am trying to improve my game development design and for now I have something like this:</p>
<pre><code>class Movement {
private:
Body b;
public:
move_up() {
// catch the body head
// add one snake character above head
// catch the body tail
// remove the tail character
}
move_down(){
// catch the body head
// add one snake character below head
// catch the body tail
// remove the tail character
}
move_left(){
// catch the body head
// add one snake character on left side of head
// catch the body tail
// remove the tail character
}
move_right(){
// catch the body head
// add one snake character on right side of head
// catch the body tail
// remove the tail character
}
}
</code></pre>
<p>It is pretty ugly to see repetead pseudocode inside each move method. I would like to make this more generic but I don't know how to do it in C++. Any suggestions?</p>
| 0debug
|
static void gen_rfci_40x(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
gen_helper_40x_rfci(cpu_env);
gen_sync_exception(ctx);
#endif
}
| 1threat
|
React js - How to mock Context when testing component : <p>I'm trying to test a component which inherits context from a root component, without loading/rendering everything from the root down. I've tried and searched for examples on how to mock the context but can't find anything (at least that doesn't use jest).</p>
<p>Here's a simplified example of what I'm trying to achieve.</p>
<p>Is there a simple way I can mock reactEl.context for the test?</p>
<pre><code>/**
* Root Element that sets up & shares context
*/
class Root extends Component {
getChildContext() {
return {
language: { text: 'A String'}
};
}
render() {
return (
<div>
<ElWithContext />
</div>
);
}
}
Root.childContextTypes = { language: React.PropTypes.object };
/**
* Child Element which uses context
*/
class ElWithContext extends React.Component{
render() {
const {language} = this.context;
return <p>{language.text}</p>
}
}
ElWithContext.contextTypes = { language: React.PropTypes.object }
/**
* Example test where context is unavailable.
*/
let el = React.createElement(ElWithContext)
element = TestUtils.renderIntoDocument(el);
// ERROR: undefined is not an object (evaluating 'language.text')
describe("ElWithContext", () => {
it('should contain textContent from context', () => {
const node = ReactDOM.findDOMNode(element);
expect(node.textContent).to.equal('A String');
});
})
</code></pre>
| 0debug
|
Setter method doesnt work : <p>my problem is the other two parametere doesnt work and just first parametere repeat in output?!</p>
<p>here is the main class:</p>
<pre><code>public static void main(String[] args) {
Time object = new Time(8, 60, 13);
System.out.println(object.getHour()+ ":" + object.getMinute() + ":" + object.getSecond());
}
</code></pre>
<p>and here is my Class:</p>
<pre><code>public class Time {
private int hour;
private int minute;
private int second;
public int getHour(){
return hour;
}
public void setHour(int h){
hour = h;
}
public int getMinute(){
return hour;
}
public void setMinute(int m){
minute = m;
}
public int getSecond(){
return hour;
}
public void setSecond(int s){
second = s;
}
public Time(int h,int m,int s){
setHour(h);
setMinute(m);
setSecond(s);
}
</code></pre>
| 0debug
|
static int decode_residuals(FLACContext *s, int channel, int pred_order)
{
int i, tmp, partition, method_type, rice_order;
int sample = 0, samples;
method_type = get_bits(&s->gb, 2);
if (method_type != 0){
av_log(s->avctx, AV_LOG_DEBUG, "illegal residual coding method %d\n", method_type);
rice_order = get_bits(&s->gb, 4);
samples= s->blocksize >> rice_order;
sample=
i= pred_order;
for (partition = 0; partition < (1 << rice_order); partition++)
{
tmp = get_bits(&s->gb, 4);
if (tmp == 15)
{
av_log(s->avctx, AV_LOG_DEBUG, "fixed len partition\n");
tmp = get_bits(&s->gb, 5);
for (; i < samples; i++, sample++)
s->decoded[channel][sample] = get_sbits(&s->gb, tmp);
else
{
for (; i < samples; i++, sample++){
s->decoded[channel][sample] = get_sr_golomb_flac(&s->gb, tmp, INT_MAX, 0);
i= 0;
return 0;
| 1threat
|
int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src)
{
dst->pts = src->pts;
dst->pos = av_frame_get_pkt_pos(src);
dst->format = src->format;
switch (dst->type) {
case AVMEDIA_TYPE_VIDEO:
dst->video->w = src->width;
dst->video->h = src->height;
dst->video->sample_aspect_ratio = src->sample_aspect_ratio;
dst->video->interlaced = src->interlaced_frame;
dst->video->top_field_first = src->top_field_first;
dst->video->key_frame = src->key_frame;
dst->video->pict_type = src->pict_type;
av_freep(&dst->video->qp_table);
dst->video->qp_table_linesize = 0;
if (src->qscale_table) {
int qsize = src->qstride ? src->qstride * ((src->height+15)/16) : (src->width+15)/16;
dst->video->qp_table = av_malloc(qsize);
if(!dst->video->qp_table)
return AVERROR(ENOMEM);
dst->video->qp_table_linesize = src->qstride;
memcpy(dst->video->qp_table, src->qscale_table, qsize);
}
break;
case AVMEDIA_TYPE_AUDIO:
dst->audio->sample_rate = src->sample_rate;
dst->audio->channel_layout = src->channel_layout;
break;
default:
return AVERROR(EINVAL);
}
return 0;
}
| 1threat
|
hello guys i'm trying to solve a simple python problem there is something wrong with it please help me out to find out : #problem=A soccer team is looking for girls from ages 10 to 12 to play on their team. Write a program to ask the user’s age and whether the user is male or female (using “m” or “f”). Display a message indicating whether the person is eligible to play on the team. but Make the program so that it doesn’t ask for the age unless the user is a girl.
#here is my code
name=raw_input("Enter ur name ")
gender=raw_input("Enter ur gender ")
if gender=="f":
age=float(raw_input("enter ur age "))
if 10<= age <=12:
print "ur eligible"
elif gender=="m":
print "male not allowed"
else :
print "ur not eligible"
| 0debug
|
static void ivshmem_check_memdev_is_busy(const Object *obj, const char *name,
Object *val, Error **errp)
{
if (host_memory_backend_is_mapped(MEMORY_BACKEND(val))) {
char *path = object_get_canonical_path_component(val);
error_setg(errp, "can't use already busy memdev: %s", path);
g_free(path);
} else {
qdev_prop_allow_set_link_before_realize(obj, name, val, errp);
}
}
| 1threat
|
static void net_slirp_cleanup(NetClientState *nc)
{
SlirpState *s = DO_UPCAST(SlirpState, nc, nc);
slirp_cleanup(s->slirp);
qemu_remove_exit_notifier(&s->exit_notifier);
slirp_smb_cleanup(s);
QTAILQ_REMOVE(&slirp_stacks, s, entry);
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.