problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static gboolean guest_exec_output_watch(GIOChannel *ch,
GIOCondition cond, gpointer p_)
{
GuestExecIOData *p = (GuestExecIOData *)p_;
gsize bytes_read;
GIOStatus gstatus;
if (cond == G_IO_HUP || cond == G_IO_ERR) {
goto close;
}
if (p->size == p->length) {
gpointer t = NULL;
if (!p->truncated && p->size < GUEST_EXEC_MAX_OUTPUT) {
t = g_try_realloc(p->data, p->size + GUEST_EXEC_IO_SIZE);
}
if (t == NULL) {
gchar buf[GUEST_EXEC_IO_SIZE];
p->truncated = true;
gstatus = g_io_channel_read_chars(ch, buf, sizeof(buf),
&bytes_read, NULL);
if (gstatus == G_IO_STATUS_EOF || gstatus == G_IO_STATUS_ERROR) {
goto close;
}
return true;
}
p->size += GUEST_EXEC_IO_SIZE;
p->data = t;
}
gstatus = g_io_channel_read_chars(ch, (gchar *)p->data + p->length,
p->size - p->length, &bytes_read, NULL);
if (gstatus == G_IO_STATUS_EOF || gstatus == G_IO_STATUS_ERROR) {
goto close;
}
p->length += bytes_read;
return true;
close:
g_io_channel_unref(ch);
g_atomic_int_set(&p->closed, 1);
return false;
}
| 1threat
|
static void fill_buffer(AVIOContext *s)
{
int max_buffer_size = s->max_packet_size ?
s->max_packet_size : IO_BUFFER_SIZE;
uint8_t *dst = s->buf_end - s->buffer + max_buffer_size < s->buffer_size ?
s->buf_end : s->buffer;
int len = s->buffer_size - (dst - s->buffer);
if (!s->read_packet && s->buf_ptr >= s->buf_end)
s->eof_reached = 1;
if (s->eof_reached)
return;
if (s->update_checksum && dst == s->buffer) {
if (s->buf_end > s->checksum_ptr)
s->checksum = s->update_checksum(s->checksum, s->checksum_ptr,
s->buf_end - s->checksum_ptr);
s->checksum_ptr = s->buffer;
}
if (s->read_packet && s->orig_buffer_size && s->buffer_size > s->orig_buffer_size) {
if (dst == s->buffer) {
ffio_set_buf_size(s, s->orig_buffer_size);
s->checksum_ptr = dst = s->buffer;
}
av_assert0(len >= s->orig_buffer_size);
len = s->orig_buffer_size;
}
if (s->read_packet)
len = s->read_packet(s->opaque, dst, len);
else
len = 0;
if (len <= 0) {
s->eof_reached = 1;
if (len < 0)
s->error = len;
} else {
s->pos += len;
s->buf_ptr = dst;
s->buf_end = dst + len;
s->bytes_read += len;
}
}
| 1threat
|
void msix_reset(PCIDevice *dev)
{
if (!(dev->cap_present & QEMU_PCI_CAP_MSIX))
return;
msix_free_irq_entries(dev);
dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] &=
~dev->wmask[dev->msix_cap + MSIX_CONTROL_OFFSET];
memset(dev->msix_table_page, 0, MSIX_PAGE_SIZE);
msix_mask_all(dev, dev->msix_entries_nr);
}
| 1threat
|
Where to set cookie in Isomorphic Redux Application? : <p>I have 3 general questions about redux and isomorphic application:</p>
<ul>
<li><strong>What is the best way to share 'runtime' data between client and server?</strong>
For instance, when the user logged in a distant API, I store the session object in cookies. In that way, <strong>next time</strong> the client requests my front-end, the front-end server can read the cookies and initialize the redux store with it's previous session. The downside of this is that the client HAS to validate/invalidate the session on boot (eg in componentDidMount of the root component).
Should I request the session server side rather than read it from cookies?</li>
<li><strong>Where should I execute the operation of cookie storing, in action creators or in reducers?</strong> Should I store the cookie in my reducer that handle the user session?</li>
<li><strong>Where should I execute the operation of redirect the user (via react-router)?</strong> I mean when my user is successfully logged in, from where should I dispatch the redirect action (from the loginActionCreator once the login promise is resolved?, somewhere else? )</li>
</ul>
<p>Thanks in advance.</p>
| 0debug
|
Copyright logo & map visibility : <p>I'm aware of terms of using Google Maps API, but in the following case is a bit unclear:</p>
<p>I want to make the whole <code>mapView</code> container transparent by 50% or 60%. I don't want to modify or remove Google copyrights (Google logo in the corner).</p>
<p>Is it legal from this point of view? Does it violate Google's terms of use?</p>
<p>Thanks.</p>
| 0debug
|
How avoid Scrapy garbage in response : Hi and thanks in advance:
When I run scrapy I put the items in a .json but furthermore the items I want I get some garbage:
[download latency,download tieout, depth and download slot are the not desired ones][1]
1 import scrapy
2
3 class LibresSpider(scrapy.Spider):
4 name = 'libres'
5 allowed_domains = ['www.todostuslibros.com']
6 start_urls = ['https://www.todostuslibros.com/mas_vendidos/']
7
8 def parse(self, response):
9 for tfg in response.css('li.row-fluid'):
10 doc={}
11 data = tfg.css('book-basics')
12 doc['titulo'] = tfg.css('h2 a::text').extract_first()
13 doc['url'] = response.urljoin(tfg.css('h2 a::attr(href)').extract_first())
14
15 yield scrapy.Request(doc['url'], callback=self.parse_detail, meta=doc)
16
17 next = response.css('a.next::attr(href)').extract_first()
18 if next is not None:
19 next_page = response.urljoin(next)
20 yield scrapy.Request(next_page, callback=self.parse)
21
22 def parse_detail(self, response):
23
24 detail = response.meta
25 detail['page_count'] = ' '.join(response.css('dd.page.count::text').extract())
26 detail['keywords'] = ' '.join(response.css('div.descripcio a::text').extract())
27
28 yield detail
I know that those undesired data came whith the response (line 26) but I would to know how avoid that data ends in my json.
[1]: https://i.stack.imgur.com/iAJdO.png
| 0debug
|
static int wv_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
ByteIOContext *pb = s->pb;
WVContext *wc = s->priv_data;
AVStream *st;
if(wv_read_block_header(s, pb) < 0)
return -1;
wc->block_parsed = 0;
st = av_new_stream(s, 0);
if (!st)
return -1;
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_WAVPACK;
st->codec->channels = wc->chan;
st->codec->sample_rate = wc->rate;
st->codec->bits_per_coded_sample = wc->bpp;
av_set_pts_info(st, 64, 1, wc->rate);
s->start_time = 0;
s->duration = (int64_t)wc->samples * AV_TIME_BASE / st->codec->sample_rate;
if(!url_is_streamed(s->pb)) {
int64_t cur = url_ftell(s->pb);
ff_ape_parse_tag(s);
if(!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
ff_id3v1_read(s);
url_fseek(s->pb, cur, SEEK_SET);
}
return 0;
}
| 1threat
|
Why is the following code is non-terminating? : following is the code:-
int main()
{
printf("Hello world\");
main("hellow",32);
return 0;
}
| 0debug
|
How to change all negative numbers to positive python? : <p>In python 3, how can we change a list of numbers (such as 4, 1, -7, 1, -3) and change all of the negative signs into positive signs?</p>
| 0debug
|
access vba random value from combobox : i have a combobox of Client codes that links to table - ClientT.
when i click a button randomcmd i would like a random client code to appear in the combobox.
my thought was use VBA code to find the maximum number of clients in ClientT, then Rnd function to pick a number between max and 0, then convert that number to a value from the list.
i just can't find any similar code to use. all i have so far is a number that generates randomly.
Private Sub Randomcmd_Click()
ClientCodecmb = Int(999 * Rnd) + 1
End Sub
please help.
| 0debug
|
static int vmdaudio_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
const uint8_t *buf_end;
int buf_size = avpkt->size;
VmdAudioContext *s = avctx->priv_data;
int block_type, silent_chunks, audio_chunks;
int ret;
uint8_t *output_samples_u8;
int16_t *output_samples_s16;
if (buf_size < 16) {
av_log(avctx, AV_LOG_WARNING, "skipping small junk packet\n");
*got_frame_ptr = 0;
return buf_size;
}
block_type = buf[6];
if (block_type < BLOCK_TYPE_AUDIO || block_type > BLOCK_TYPE_SILENCE) {
av_log(avctx, AV_LOG_ERROR, "unknown block type: %d\n", block_type);
return AVERROR(EINVAL);
}
buf += 16;
buf_size -= 16;
silent_chunks = 0;
if (block_type == BLOCK_TYPE_INITIAL) {
uint32_t flags;
if (buf_size < 4) {
av_log(avctx, AV_LOG_ERROR, "packet is too small\n");
return AVERROR(EINVAL);
}
flags = AV_RB32(buf);
silent_chunks = av_popcount(flags);
buf += 4;
buf_size -= 4;
} else if (block_type == BLOCK_TYPE_SILENCE) {
silent_chunks = 1;
buf_size = 0;
}
audio_chunks = buf_size / s->chunk_size;
s->frame.nb_samples = ((silent_chunks + audio_chunks) * avctx->block_align) / avctx->channels;
if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
output_samples_u8 = s->frame.data[0];
output_samples_s16 = (int16_t *)s->frame.data[0];
if (silent_chunks > 0) {
int silent_size = avctx->block_align * silent_chunks;
if (s->out_bps == 2) {
memset(output_samples_s16, 0x00, silent_size * 2);
output_samples_s16 += silent_size;
} else {
memset(output_samples_u8, 0x80, silent_size);
output_samples_u8 += silent_size;
}
}
if (audio_chunks > 0) {
buf_end = buf + buf_size;
while (buf < buf_end) {
if (s->out_bps == 2) {
decode_audio_s16(output_samples_s16, buf, s->chunk_size,
avctx->channels);
output_samples_s16 += avctx->block_align;
} else {
memcpy(output_samples_u8, buf, s->chunk_size);
output_samples_u8 += avctx->block_align;
}
buf += s->chunk_size;
}
}
*got_frame_ptr = 1;
*(AVFrame *)data = s->frame;
return avpkt->size;
}
| 1threat
|
static void pxa2xx_gpio_write(void *opaque,
target_phys_addr_t offset, uint32_t value)
{
struct pxa2xx_gpio_info_s *s = (struct pxa2xx_gpio_info_s *) opaque;
int bank;
offset -= s->base;
if (offset >= 0x200)
return;
bank = pxa2xx_gpio_regs[offset].bank;
switch (pxa2xx_gpio_regs[offset].reg) {
case GPDR:
s->dir[bank] = value;
pxa2xx_gpio_handler_update(s);
break;
case GPSR:
s->olevel[bank] |= value;
pxa2xx_gpio_handler_update(s);
break;
case GPCR:
s->olevel[bank] &= ~value;
pxa2xx_gpio_handler_update(s);
break;
case GRER:
s->rising[bank] = value;
break;
case GFER:
s->falling[bank] = value;
break;
case GAFR_L:
s->gafr[bank * 2] = value;
break;
case GAFR_U:
s->gafr[bank * 2 + 1] = value;
break;
case GEDR:
s->status[bank] &= ~value;
pxa2xx_gpio_irq_update(s);
break;
default:
cpu_abort(cpu_single_env,
"%s: Bad offset " REG_FMT "\n", __FUNCTION__, offset);
}
}
| 1threat
|
document.write('<script src="evil.js"></script>');
| 1threat
|
How custom the design of UIButton in objective-C? : <p>I need help to create a custom UIButton, I'm creating a tweak, i have an custom uiview and i know how to add a button on it. </p>
<p>But i don't like the blue and tiny stock style of it, I want to custom my button like my UIView with color style and size but don't know how to.</p>
<p>I want something like this : <a href="https://i.stack.imgur.com/ROYEH.png" rel="nofollow noreferrer">Image of button style I want</a></p>
| 0debug
|
static uint64_t omap_id_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
if (size != 4) {
return omap_badwidth_read32(opaque, addr);
}
switch (addr) {
case 0xfffe1800:
return 0xc9581f0e;
case 0xfffe1804:
return 0xa8858bfa;
case 0xfffe2000:
return 0x00aaaafc;
case 0xfffe2004:
return 0xcafeb574;
case 0xfffed400:
switch (s->mpu_model) {
case omap310:
return 0x03310315;
case omap1510:
return 0x03310115;
default:
hw_error("%s: bad mpu model\n", __FUNCTION__);
}
break;
case 0xfffed404:
switch (s->mpu_model) {
case omap310:
return 0xfb57402f;
case omap1510:
return 0xfb47002f;
default:
hw_error("%s: bad mpu model\n", __FUNCTION__);
}
break;
}
OMAP_BAD_REG(addr);
return 0;
}
| 1threat
|
static int mtv_read_packet(AVFormatContext *s, AVPacket *pkt)
{
MTVDemuxContext *mtv = s->priv_data;
ByteIOContext *pb = s->pb;
int ret;
#if !HAVE_BIGENDIAN
int i;
#endif
if((url_ftell(pb) - s->data_offset + mtv->img_segment_size) % mtv->full_segment_size)
{
url_fskip(pb, MTV_AUDIO_PADDING_SIZE);
ret = av_get_packet(pb, pkt, MTV_ASUBCHUNK_DATA_SIZE);
if(ret != MTV_ASUBCHUNK_DATA_SIZE)
return AVERROR(EIO);
pkt->pos -= MTV_AUDIO_PADDING_SIZE;
pkt->stream_index = AUDIO_SID;
}else
{
ret = av_get_packet(pb, pkt, mtv->img_segment_size);
if(ret != mtv->img_segment_size)
return AVERROR(EIO);
#if !HAVE_BIGENDIAN
for(i=0;i<mtv->img_segment_size/2;i++)
*((uint16_t *)pkt->data+i) = bswap_16(*((uint16_t *)pkt->data+i));
#endif
pkt->stream_index = VIDEO_SID;
}
return ret;
}
| 1threat
|
long do_sigreturn(CPUPPCState *env)
{
struct target_sigcontext *sc = NULL;
struct target_mcontext *sr = NULL;
target_ulong sr_addr = 0, sc_addr;
sigset_t blocked;
target_sigset_t set;
sc_addr = env->gpr[1] + SIGNAL_FRAMESIZE;
if (!lock_user_struct(VERIFY_READ, sc, sc_addr, 1))
goto sigsegv;
#if defined(TARGET_PPC64)
set.sig[0] = sc->oldmask + ((long)(sc->_unused[3]) << 32);
#else
if(__get_user(set.sig[0], &sc->oldmask) ||
__get_user(set.sig[1], &sc->_unused[3]))
goto sigsegv;
#endif
target_to_host_sigset_internal(&blocked, &set);
sigprocmask(SIG_SETMASK, &blocked, NULL);
if (__get_user(sr_addr, &sc->regs))
goto sigsegv;
if (!lock_user_struct(VERIFY_READ, sr, sr_addr, 1))
goto sigsegv;
if (restore_user_regs(env, sr, 1))
goto sigsegv;
unlock_user_struct(sr, sr_addr, 1);
unlock_user_struct(sc, sc_addr, 1);
return -TARGET_QEMU_ESIGRETURN;
sigsegv:
unlock_user_struct(sr, sr_addr, 1);
unlock_user_struct(sc, sc_addr, 1);
qemu_log("segfaulting from do_sigreturn\n");
force_sig(TARGET_SIGSEGV);
return 0;
}
| 1threat
|
Using Expect after SSH : <p>I'm trying to install a pkg file on remote machines. Facing issue while using expect inside ssh. unable to pass the password while using actual password or variable $pass</p>
<pre><code>#!/bin/bash
agentpath="/Users/vigneshganapathy/Downloads/FS-Agent"
pass="xxx"
expect -c "spawn ssh -o StrictHostKeyChecking=no shyamkarthikv@192.168.57.33
expect \"*?assword:\" {send \"$pass\r\"; exp_continue}
spawn sudo installer -pkg \"/tmp/FS-Agent/FS-Agent.pkg\" -target \"/\"
expect \"*?assword:\" {send \"xxx/r\"; exp_continue}"
</code></pre>
| 0debug
|
How to perform a non linear regression using nls function? : I have set of Temperature and Discomfort index value for each temperature data. When i plot a graph between temperature(x axis) and Calculated Discomfort index value( y axis) i get a inverted U shape curve. I want to do non linear regression out of it and convert it into PMML model.My aim is to get the predicted dicomfort value if i give certain temperature.
Please find the below data set :
Temp <- c(0,5,10,6 ,9,13,15,16,20,21,24,26,29,30,32,34,36,38,40,43,44,45 50,60)
Disc<-c(0.00,0.10,0.25,0.15,0.24,0.26,0.30,0.31,0.40,0.41,0.49,0.50,0.56 0.80,0.90,1.00,1.00,1.00,0.80,0.50,0.40,0.20,0.15,0.00)
How to do non linear regression for this data set ?
Thanks
Arul
| 0debug
|
Vue.js - event handling with on-mouse-click down (and not up) : <p>With Vue.js 2 when I add in an @click event to an element and attempt to click something, the event isn't triggered until after I have completed my click (press down -> up).</p>
<p>How do I trigger an event immediate after a mouse click down?</p>
<p>Example:</p>
<pre><code><div @click="foo()">
Hello
</div>
</code></pre>
| 0debug
|
How to use string parameters inside groovy script in jenkins freestyle project? : I have created a jenkins freestyle project executing groovy script inside which i need to call an api to validate username and password. How to pass these parameters and use the same inside the groovy script.
A bit urgent.
| 0debug
|
void cpu_unregister_map_client(void *_client)
{
MapClient *client = (MapClient *)_client;
LIST_REMOVE(client, link);
qemu_free(client);
}
| 1threat
|
static void release_delayed_buffers(PerThreadContext *p)
{
FrameThreadContext *fctx = p->parent;
while (p->num_released_buffers > 0) {
AVFrame *f = &p->released_buffers[--p->num_released_buffers];
pthread_mutex_lock(&fctx->buffer_mutex);
free_progress(f);
f->thread_opaque = NULL;
f->owner->release_buffer(f->owner, f);
pthread_mutex_unlock(&fctx->buffer_mutex);
}
}
| 1threat
|
Clean way to use postgresql window functions in django ORM? : <p>I'd like to use postgresql window functions like <code>rank()</code> and <code>dense_rank</code> in some queries in need to do in Django. I have it working in raw SQL but I'm not sure how to do this in the ORM.</p>
<p>Simplified it looks like this:</p>
<pre><code>SELECT
id,
user_id,
score,
RANK() OVER(ORDER BY score DESC) AS rank
FROM
game_score
WHERE
...
</code></pre>
<p>How would you do this in the ORM? </p>
<p>At some point I might need to add partitioning too :|</p>
<p>(we're using Django 1.9 on Python 3 and already depend on django.contrib.postgres features)</p>
| 0debug
|
Which python should you use for new projects in 2017? : <p><a href="https://stackoverflow.com/questions/2090820/what-version-of-python-should-i-use-if-im-a-new-to-python">This question</a> asked in 2010 says "use python 2".</p>
<p>Seven years later, what's the best python to use for new projects, 2.7 or 3.6?</p>
| 0debug
|
BeautifulSoup : get whole line using a text : I need all the lines which contains the text '.mp4'. The Html file has no tag!
My code:
soup = BeautifulSoup(content, 'lxml')
c = soup.find('.mp4').findAll(text=True, recursive=False)
for i in c:
print(i)
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<script type="text/javascript">
/* <![CDATA[ */
function getEmbed(width, height) {
if (width && height) {
return '<iframe width="' + width + '" height="' + height + '" src="https://www.ptrex.com/embed/33247" frameborder="0" allowfullscreen webkitallowfullscreen mozallowfullscreen oallowfullscreen msallowfullscreen></iframe>';
}
return '<iframe width="768" height="432" src="https://www.ptrex.com/embed/33247" frameborder="0" allowfullscreen webkitallowfullscreen mozallowfullscreen oallowfullscreen msallowfullscreen></iframe>';
}
var flashvars = {
video_id: '33247', license_code: '$535555517668914', rnd: '1537972655', video_url: 'https://www.ptrex.com/get_file/4/996a9088fdf801992d24457cd51469f3f7aaaee6a0/33000/33247/33247.mp4/', postfix: '.mp4', video_url_text: '480p', video_alt_url: 'https://www.ptrex.com/get_file/4/774833c428771edee2cf401ef2264e746a06f9f370/33000/33247/33247_720p.mp4/', video_alt_url_text: '720p HD', video_alt_url_hd: '1', timeline_screens_url: '//di-iu49il1z.leasewebultracdn.com/contents/videos_screenshots/33000/33247/timelines/timeline_mp4/200x116/{time}.jpg', timeline_screens_interval: '10', preview_url: '//di-iu49il1z.leasewebultracdn.com/contents/videos_screenshots/33000/33247/preview.mp4.jpg', skin: 'youtube.css', bt: '1', volume: '1', hide_controlbar: '1', hide_style: 'fade', related_src: 'https://www.ptrex.com/related_videos_html/33247/', adv_pre_vast: 'https://pt.ptawe.com/vast/v3?psid=ed_pntrexvb1&utm_source=bf1&utm_medium=network&ms_notrack=1', lrcv: '1556867449254522707330811', adv_pre_replay_after: '2', embed: '1' };
var player_obj = kt_player('kt_player', 'https://www.ptrex.com/player/kt_player.swf?v=4.0.2', '100%', '100%', flashvars);
/* ]]> */
</script>
<!-- end snippet -->
| 0debug
|
ImportError: cannnot import name 'Imputer' from 'sklearn.preprocessing' : <p>Trying to import Imputer from sklearn,</p>
<pre><code>import pandas as pd
dataset = pd.read_csv('Data.csv')
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, 3].values
#PART WHERE ERROR OCCURS:-
from sklearn.preprocessing import Imputer
</code></pre>
<p>Shows "ImportError: cannot import name 'Imputer' from 'sklearn.preprocessing' (/home/codeknight13/anaconda3/lib/python3.7/site-packages/sklearn/preprocessing/__init__.py)"</p>
| 0debug
|
Python - Get number of items in list not equal to something : <p>How do you get the number of items that are NOT 204 in this list?</p>
<pre><code>data = [204, 204, 204, 500, 204, 204, 500, 500, 204, 404]
number_of_not_204 = any(x != 204 for x in data)
# returns True
print number_of_not_204
# looking to get the number 4 (500, 500, 500, and 404 are not 204)
</code></pre>
| 0debug
|
RxSwift, What is the difference between Do and Map? : What is the difference between "do" operator and "map" operator?
It seems the same. I'm learning RxSwift.
Please check the marble diagram of do and map.
do
http://reactivex.io/documentation/operators/do.html
map
http://reactivex.io/documentation/operators/map.html
| 0debug
|
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
| 1threat
|
document.getElementById('input').innerHTML = user_input;
| 1threat
|
Creating a view dynamically via a variable - SQL SERVER : I am attempting to create a SQL Server view based upon a query dynamically using a variable.
I have written and tested the query and can confirm it works with the results, I have attached a link to Imgur to view the screenshots as I am unable to post the full query due to reasons.
Creating the view however, I am receiving a few errors and can't seem to work them out! I have checked over the query multiple times and re-structured my code in creating the view.
declare @MarketingCampaignID int,@viewQuery nvarchar(max)
set @MarketingCampaignID=246159
if exists(select * from sys.views where name='vwCampaign_' + cast(@MarketingCampaignID as nvarchar(255)) + '_FlatValueTable')
begin
set @viewQuery = 'drop view XMPieTracking.vwCampaign_' + cast(@MarketingCampaignID as nvarchar(255)) + '_FlatValueTable'
exec (@viewQuery)
end
set @viewQuery = N'Create View XMPieTracking.vwCampaign_' + cast(@MarketingCampaignID as nvarchar(255)) + '_FlatValueTable'
set @viewQuery = @viewQuery + N'SELECT * FROM (...)
exec( @viewQuery)
- See images. https://imgur.com/a/qIhN339
| 0debug
|
static uint64_t xscom_read(void *opaque, hwaddr addr, unsigned width)
{
PnvChip *chip = opaque;
uint32_t pcba = pnv_xscom_pcba(chip, addr);
uint64_t val = 0;
MemTxResult result;
val = xscom_read_default(chip, pcba);
if (val != -1) {
goto complete;
}
val = address_space_ldq(&chip->xscom_as, pcba << 3, MEMTXATTRS_UNSPECIFIED,
&result);
if (result != MEMTX_OK) {
qemu_log_mask(LOG_GUEST_ERROR, "XSCOM read failed at @0x%"
HWADDR_PRIx " pcba=0x%08x\n", addr, pcba);
xscom_complete(current_cpu, HMER_XSCOM_FAIL | HMER_XSCOM_DONE);
return 0;
}
complete:
xscom_complete(current_cpu, HMER_XSCOM_DONE);
return val;
}
| 1threat
|
static void demap_tlb(SparcTLBEntry *tlb, target_ulong demap_addr,
const char* strmmu, CPUState *env1)
{
unsigned int i;
target_ulong mask;
for (i = 0; i < 64; i++) {
if (TTE_IS_VALID(tlb[i].tte)) {
mask = 0xffffffffffffe000ULL;
mask <<= 3 * ((tlb[i].tte >> 61) & 3);
if ((demap_addr & mask) == (tlb[i].tag & mask)) {
replace_tlb_entry(&tlb[i], 0, 0, env1);
#ifdef DEBUG_MMU
DPRINTF_MMU("%s demap invalidated entry [%02u]\n", strmmu, i);
dump_mmu(env1);
#endif
}
}
}
}
| 1threat
|
How do i order a column in sql server in following manner? : I am trying to order by sql column which have a data type of nvarchar. My column data looks like this.
9 AM - 11 AM
1 PM - 3 PM
11 AM - 1 PM
3 PM - 5 PM
5 PM - 7 PM
And i want to order by my column in this manner
9 AM - 11 AM
11 AM - 1 PM
1 PM - 3 PM
3 PM - 5 PM
5 PM - 7 PM
How can i do this?
| 0debug
|
static int mmu_translate_sfaa(CPUS390XState *env, target_ulong vaddr,
uint64_t asc, uint64_t asce, target_ulong *raddr,
int *flags, int rw)
{
if (asce & _SEGMENT_ENTRY_INV) {
DPRINTF("%s: SEG=0x%" PRIx64 " invalid\n", __func__, asce);
trigger_page_fault(env, vaddr, PGM_SEGMENT_TRANS, asc, rw);
return -1;
}
if (asce & _SEGMENT_ENTRY_RO) {
*flags &= ~PAGE_WRITE;
}
*raddr = (asce & 0xfffffffffff00000ULL) | (vaddr & 0xfffff);
PTE_DPRINTF("%s: SEG=0x%" PRIx64 "\n", __func__, asce);
return 0;
}
| 1threat
|
Doing multiples of a number in java issues with implementation : <p>Im not sure how to go about making this code.. well at least the total part of this. this is my code right now, I understand the math behind it. I'm just not sure how to implement it. Would I use a loop? here is my code as of right now. I know its not correct but its the start of it.</p>
<pre><code>public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("what number would you like me to multiply: ");
int number = in.nextInt();
System.out.println("how many multiples of "+number+" would you like to see: ");
int multiple = in.nextInt();
int total =
System.out.println("total :"+total);
}
</code></pre>
<p>here is the output that I would like to get:</p>
<pre><code> What number would you like me to multiply? 4
How many multiples of 4 would you like to see? 7
The first 7 multiples of 4 are: 4, 8, 12, 16, 20, 24, 28
</code></pre>
| 0debug
|
int qemu_read_password(char *buf, int buf_size)
{
uint8_t ch;
int i, ret;
printf("password: ");
fflush(stdout);
term_init();
i = 0;
for (;;) {
ret = read(0, &ch, 1);
if (ret == -1) {
if (errno == EAGAIN || errno == EINTR) {
continue;
} else {
break;
}
} else if (ret == 0) {
ret = -1;
break;
} else {
if (ch == '\r' ||
ch == '\n') {
ret = 0;
break;
}
if (i < (buf_size - 1)) {
buf[i++] = ch;
}
}
}
term_exit();
buf[i] = '\0';
printf("\n");
return ret;
}
| 1threat
|
determine number n , know X is n th ugly number : > "Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The
> sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, … shows the first 11 ugly
> numbers. By convention, 1 is included."
Given number X, determine the order of X in that sequence.
Example : X = 12, output : 10.
I have an algorithm O(X) but X might be 1e18, what should I do?
There might be 10^5 queries, each query gives us a number X.
Thank you.
| 0debug
|
Currently Attempting to Optimize SQL queries. Need help! Details below : I'm currently attempting to optimize some SQL queries in a VB format (Ancient, I know) but I'm just attempting to make the queries more efficient.
This is an example of how some of the queries are now
"SELECT DISTINCT Appointments.WithID, Users.LastName, Users.FirstName"
" FROM Appointments INNER JOIN AppointmentTypes ONAppointmentTypes.ID =
Appointments.AppTypeID "
" INNER JOIN Users ON Users.ID = Appointmens.WithID"
"WHERE Appointments.Hide = 0"
"ORDER BY Users.LastName, Users.FirstName"
Above is the initial query that runs, then for all of the results, which generally are the returned Appointments.WithID, A for each loop happens for each item where another query is run, for example below
"SELECT Appointments.CustomerID FROM Appointments"
"WHERE Appointments.Hide = 0"
"AND Appointments.WithID = (And this is where the "Appointment.WithID"'s
from the previous query are entered)
So I'm not sure if I explained this properly or not BUT all in all, the second query is run multiple times for EACH Appointment.WithID which is found from the first query. I need a way where I can incorporate the second query within the first so it doesnt run the second query hundreds of times depending on the amount of WithID's returned
Any help would be appreciated
| 0debug
|
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
{
int i, count, ret, read_size, j;
AVStream *st;
AVPacket pkt1, *pkt;
int64_t old_offset = avio_tell(ic->pb);
int orig_nb_streams = ic->nb_streams;
for(i=0;i<ic->nb_streams;i++) {
AVCodec *codec;
AVDictionary *thread_opt = NULL;
st = ic->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
if(!st->codec->time_base.num)
st->codec->time_base= st->time_base;
}
if (!st->parser && !(ic->flags & AVFMT_FLAG_NOPARSE)) {
st->parser = av_parser_init(st->codec->codec_id);
if(st->need_parsing == AVSTREAM_PARSE_HEADERS && st->parser){
st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
}
}
assert(!st->codec->codec);
codec = avcodec_find_decoder(st->codec->codec_id);
av_dict_set(options ? &options[i] : &thread_opt, "threads", "1", 0);
if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE
&& codec && !st->codec->codec)
avcodec_open2(st->codec, codec, options ? &options[i]
: &thread_opt);
if(!has_codec_parameters(st->codec)){
if (codec && !st->codec->codec)
avcodec_open2(st->codec, codec, options ? &options[i]
: &thread_opt);
}
if (!options)
av_dict_free(&thread_opt);
}
for (i=0; i<ic->nb_streams; i++) {
ic->streams[i]->info->last_dts = AV_NOPTS_VALUE;
}
count = 0;
read_size = 0;
for(;;) {
if (ff_check_interrupt(&ic->interrupt_callback)){
ret= AVERROR_EXIT;
av_log(ic, AV_LOG_DEBUG, "interrupted\n");
break;
}
for(i=0;i<ic->nb_streams;i++) {
int fps_analyze_framecount = 20;
st = ic->streams[i];
if (!has_codec_parameters(st->codec))
break;
if (av_q2d(st->time_base) > 0.0005)
fps_analyze_framecount *= 2;
if (ic->fps_probe_size >= 0)
fps_analyze_framecount = ic->fps_probe_size;
if( tb_unreliable(st->codec) && !(st->r_frame_rate.num && st->avg_frame_rate.num)
&& st->info->duration_count < fps_analyze_framecount
&& st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
break;
if(st->parser && st->parser->parser->split && !st->codec->extradata)
break;
if(st->first_dts == AV_NOPTS_VALUE)
break;
}
if (i == ic->nb_streams) {
if (!(ic->ctx_flags & AVFMTCTX_NOHEADER)) {
ret = count;
av_log(ic, AV_LOG_DEBUG, "All info found\n");
break;
}
}
if (read_size >= ic->probesize) {
ret = count;
av_log(ic, AV_LOG_DEBUG, "Probe buffer size limit %d reached\n", ic->probesize);
break;
}
ret = read_frame_internal(ic, &pkt1);
if (ret == AVERROR(EAGAIN))
continue;
if (ret < 0) {
AVPacket empty_pkt = { 0 };
int err;
av_init_packet(&empty_pkt);
ret = -1;
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
do {
err = try_decode_frame(st, &empty_pkt,
(options && i < orig_nb_streams) ?
&options[i] : NULL);
} while (err > 0 && !has_codec_parameters(st->codec));
if (err < 0) {
av_log(ic, AV_LOG_WARNING,
"decoding for stream %d failed\n", st->index);
} else if (!has_codec_parameters(st->codec)){
char buf[256];
avcodec_string(buf, sizeof(buf), st->codec, 0);
av_log(ic, AV_LOG_WARNING,
"Could not find codec parameters (%s)\n", buf);
} else {
ret = 0;
}
}
break;
}
pkt= add_to_pktbuf(&ic->packet_buffer, &pkt1, &ic->packet_buffer_end);
if ((ret = av_dup_packet(pkt)) < 0)
goto find_stream_info_err;
read_size += pkt->size;
st = ic->streams[pkt->stream_index];
if (st->codec_info_nb_frames>1) {
if (st->time_base.den > 0 && av_rescale_q(st->info->codec_info_duration, st->time_base, AV_TIME_BASE_Q) >= ic->max_analyze_duration) {
av_log(ic, AV_LOG_WARNING, "max_analyze_duration reached\n");
break;
}
st->info->codec_info_duration += pkt->duration;
}
{
int64_t last = st->info->last_dts;
if(pkt->dts != AV_NOPTS_VALUE && last != AV_NOPTS_VALUE && pkt->dts > last){
int64_t duration= pkt->dts - last;
double dur= duration * av_q2d(st->time_base);
if (st->info->duration_count < 2)
memset(st->info->duration_error, 0, sizeof(st->info->duration_error));
for (i=1; i<FF_ARRAY_ELEMS(st->info->duration_error); i++) {
int framerate= get_std_framerate(i);
int ticks= lrintf(dur*framerate/(1001*12));
double error = dur - (double)ticks*1001*12 / framerate;
st->info->duration_error[i] += error*error;
}
st->info->duration_count++;
if (st->info->duration_count > 3)
st->info->duration_gcd = av_gcd(st->info->duration_gcd, duration);
}
if (last == AV_NOPTS_VALUE || st->info->duration_count <= 1)
st->info->last_dts = pkt->dts;
}
if(st->parser && st->parser->parser->split && !st->codec->extradata){
int i= st->parser->parser->split(st->codec, pkt->data, pkt->size);
if (i > 0 && i < FF_MAX_EXTRADATA_SIZE) {
st->codec->extradata_size= i;
st->codec->extradata= av_malloc(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
memcpy(st->codec->extradata, pkt->data, st->codec->extradata_size);
memset(st->codec->extradata + i, 0, FF_INPUT_BUFFER_PADDING_SIZE);
}
}
try_decode_frame(st, pkt, (options && i < orig_nb_streams ) ? &options[i] : NULL);
st->codec_info_nb_frames++;
count++;
}
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
if(st->codec->codec)
avcodec_close(st->codec);
}
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
if (st->codec_info_nb_frames>2 && !st->avg_frame_rate.num && st->info->codec_info_duration)
av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
(st->codec_info_nb_frames-2)*(int64_t)st->time_base.den,
st->info->codec_info_duration*(int64_t)st->time_base.num, 60000);
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (tb_unreliable(st->codec) && st->info->duration_count > 15 && st->info->duration_gcd > 1 && !st->r_frame_rate.num)
av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, st->time_base.den, st->time_base.num * st->info->duration_gcd, INT_MAX);
if (st->info->duration_count && !st->r_frame_rate.num
&& tb_unreliable(st->codec)
){
int num = 0;
double best_error= 2*av_q2d(st->time_base);
best_error = best_error*best_error*st->info->duration_count*1000*12*30;
for (j=1; j<FF_ARRAY_ELEMS(st->info->duration_error); j++) {
double error = st->info->duration_error[j] * get_std_framerate(j);
if(error < best_error){
best_error= error;
num = get_std_framerate(j);
}
}
if (num && (!st->r_frame_rate.num || (double)num/(12*1001) < 1.01 * av_q2d(st->r_frame_rate)))
av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, num, 12*1001, INT_MAX);
}
if (!st->r_frame_rate.num){
if( st->codec->time_base.den * (int64_t)st->time_base.num
<= st->codec->time_base.num * st->codec->ticks_per_frame * (int64_t)st->time_base.den){
st->r_frame_rate.num = st->codec->time_base.den;
st->r_frame_rate.den = st->codec->time_base.num * st->codec->ticks_per_frame;
}else{
st->r_frame_rate.num = st->time_base.den;
st->r_frame_rate.den = st->time_base.num;
}
}
}else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if(!st->codec->bits_per_coded_sample)
st->codec->bits_per_coded_sample= av_get_bits_per_sample(st->codec->codec_id);
switch (st->codec->audio_service_type) {
case AV_AUDIO_SERVICE_TYPE_EFFECTS:
st->disposition = AV_DISPOSITION_CLEAN_EFFECTS; break;
case AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED:
st->disposition = AV_DISPOSITION_VISUAL_IMPAIRED; break;
case AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED:
st->disposition = AV_DISPOSITION_HEARING_IMPAIRED; break;
case AV_AUDIO_SERVICE_TYPE_COMMENTARY:
st->disposition = AV_DISPOSITION_COMMENT; break;
case AV_AUDIO_SERVICE_TYPE_KARAOKE:
st->disposition = AV_DISPOSITION_KARAOKE; break;
}
}
}
estimate_timings(ic, old_offset);
compute_chapters_end(ic);
#if 0
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if(b-frames){
ppktl = &ic->packet_buffer;
while(ppkt1){
if(ppkt1->stream_index != i)
continue;
if(ppkt1->pkt->dts < 0)
break;
if(ppkt1->pkt->pts != AV_NOPTS_VALUE)
break;
ppkt1->pkt->dts -= delta;
ppkt1= ppkt1->next;
}
if(ppkt1)
continue;
st->cur_dts -= delta;
}
}
}
#endif
find_stream_info_err:
for (i=0; i < ic->nb_streams; i++) {
if (ic->streams[i]->codec)
ic->streams[i]->codec->thread_count = 0;
av_freep(&ic->streams[i]->info);
}
return ret;
}
| 1threat
|
Why is null+null = 0 in javascript : <p>I was doing some test for fun when noticed <code>null+null</code> is equal to <code>0</code>in javascript.
Is there any reason for it ?</p>
| 0debug
|
How to open new activity after cardview clicked? : <p>How to open new activity after cardview clicked ?
I have CardView and RecyclerView, then I loop my data with RecycleView.</p>
| 0debug
|
how to connect back end java code with front end code(Html and css and java script) while constructing web site? : <p>Here my back-end code is on java and front end code is with html and css and java script, is there best way to pass my logic from back end to front end </p>
| 0debug
|
int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg,
const struct iovec *iov G_GNUC_UNUSED,
size_t niov G_GNUC_UNUSED,
uint8_t **result G_GNUC_UNUSED,
size_t *resultlen G_GNUC_UNUSED,
Error **errp)
{
error_setg(errp,
"Hash algorithm %d not supported without GNUTLS",
alg);
return -1;
}
| 1threat
|
static inline TranslationBlock *tb_find_fast(void)
{
TranslationBlock *tb;
target_ulong cs_base, pc;
int flags;
cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags);
tb = env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)];
if (unlikely(!tb || tb->pc != pc || tb->cs_base != cs_base ||
tb->flags != flags)) {
tb = tb_find_slow(pc, cs_base, flags);
}
return tb;
}
| 1threat
|
static int mmu_translate_asc(CPUS390XState *env, target_ulong vaddr,
uint64_t asc, target_ulong *raddr, int *flags,
int rw)
{
uint64_t asce = 0;
int level, new_level;
int r;
switch (asc) {
case PSW_ASC_PRIMARY:
PTE_DPRINTF("%s: asc=primary\n", __func__);
asce = env->cregs[1];
break;
case PSW_ASC_SECONDARY:
PTE_DPRINTF("%s: asc=secondary\n", __func__);
asce = env->cregs[7];
break;
case PSW_ASC_HOME:
PTE_DPRINTF("%s: asc=home\n", __func__);
asce = env->cregs[13];
break;
}
if (asce & _ASCE_REAL_SPACE) {
*raddr = vaddr;
return 0;
}
switch (asce & _ASCE_TYPE_MASK) {
case _ASCE_TYPE_REGION1:
break;
case _ASCE_TYPE_REGION2:
if (vaddr & 0xffe0000000000000ULL) {
DPRINTF("%s: vaddr doesn't fit 0x%16" PRIx64
" 0xffe0000000000000ULL\n", __func__, vaddr);
trigger_page_fault(env, vaddr, PGM_TRANS_SPEC, asc, rw);
return -1;
}
break;
case _ASCE_TYPE_REGION3:
if (vaddr & 0xfffffc0000000000ULL) {
DPRINTF("%s: vaddr doesn't fit 0x%16" PRIx64
" 0xfffffc0000000000ULL\n", __func__, vaddr);
trigger_page_fault(env, vaddr, PGM_TRANS_SPEC, asc, rw);
return -1;
}
break;
case _ASCE_TYPE_SEGMENT:
if (vaddr & 0xffffffff80000000ULL) {
DPRINTF("%s: vaddr doesn't fit 0x%16" PRIx64
" 0xffffffff80000000ULL\n", __func__, vaddr);
trigger_page_fault(env, vaddr, PGM_TRANS_SPEC, asc, rw);
return -1;
}
break;
}
level = asce & _ASCE_TYPE_MASK;
new_level = level + 4;
asce = (asce & ~_ASCE_TYPE_MASK) | (new_level & _ASCE_TYPE_MASK);
r = mmu_translate_asce(env, vaddr, asc, asce, new_level, raddr, flags, rw);
if ((rw == 1) && !(*flags & PAGE_WRITE)) {
trigger_prot_fault(env, vaddr, asc);
return -1;
}
return r;
}
| 1threat
|
Regular expression in R - Text between strings, Digit between strings and digit and text after strings : <p>I have several question about regular expressions in R, which are related to <a href="https://stackoverflow.com/questions/57384597/regular-expression-in-r-spaces-before-and-after-the-text">one</a> my previous posts in stack overflow but is a bit more expansive.</p>
<p>I have lines in a text file that represent stats. I load these files in R and want to get the values of some of these statistics.</p>
<p>First case, statistics of this type:</p>
<pre><code>system.cpu.dcache.overall_accesses::.cpu.data 42519477 # number of overall (read+write) accesses
system.l2.overall_accesses::.cpu.data 1335898 # number of overall (read+write) accesses
system.l3.overall_accesses::.cpu.data 1331502 # number of overall (read+write) accesses
</code></pre>
<p>In this case, I want to catch the cache level as string (which is between "system." and ."overall_accesses") and the value as integer that is between the whitespaces.</p>
<p>cache_level = "cpu.dcache" or "l2" or "l3"
value = "42519477" etc.</p>
<p>Second case:</p>
<pre><code>system.l3.compressor.compression_size::256 58740 # Number of blocks that compressed to fit in 256 bits"
system.l3.compressor.compression_size::256 65742 # Number of blocks that compressed to fit in 512 bits"
</code></pre>
<p>In this case, I want to catch the cache level as string, the value as integer, as well as the compression size (i.e. 256 or 512). The compression size is always gonna be a number.</p>
<p>compression_size = "256" or "512"</p>
<p>Third case:</p>
<pre><code>system.l2.compressor.encoding::Base4_1 87521 # Number of data entries that match encoding Base4_1
system.l2.compressor.encoding::Base8_1 58731 # Number of data entries that match encoding Base8_1
system.l2.compressor.encoding::Uncompressed 24125 # Number of data entries that match encoding Uncompressed
</code></pre>
<p>This case is similar to the second one, in that I want to get the same things, but the encoding is a string.</p>
<p>compression_encoding = "Base4_1" or "Base8_1" or "Uncompressed"</p>
<p>For getting the lines I have in mind something like this:</p>
<pre><code>For first: if (grepl("system.+\\.*.overall_accesses::.cpu.data", line))
For second: if (grepl("system.\\.*.compressor.compression_size::\\d+", line))
For third: if (grepl("system.\\.*.compressor.encoding::\\.*", line))
</code></pre>
<p>I'm not sure whether these will work though. Then I need to get the different data.</p>
<p>Thanks.</p>
| 0debug
|
static int qemu_paio_submit(struct qemu_paiocb *aiocb, int is_write)
{
aiocb->is_write = is_write;
aiocb->ret = -EINPROGRESS;
aiocb->active = 0;
mutex_lock(&lock);
if (idle_threads == 0 && cur_threads < max_threads)
spawn_thread();
TAILQ_INSERT_TAIL(&request_list, aiocb, node);
mutex_unlock(&lock);
cond_broadcast(&cond);
return 0;
}
| 1threat
|
Unable to get element with id="parcelMailingAddressResult" from https://www.mohavecounty.us/ContentPage.aspx?id=111&cid=869&parcel=10272001 : Unable to get element with id="parcelMailingAddressResult" from https://www.mohavecounty.us/ContentPage.aspx?id=111&cid=869&parcel=10272001 using HTMLUnit in Java
If you go to https://www.mohavecounty.us/ContentPage.aspx?id=111&cid=869&parcel=10272001 , you will see that there is a mailing address. A DOM inspection of the website shows that address has the following id: id="parcelMailingAddressResult". I have been trying for several days to get that mailing address using my Java/HTMLUnit problem, and nothing I tried worked.
Below are three methods that I tried within the same code.
System.getProperties().put("org.apache.commons.logging.simplelog.defaultlog", "fatal");
final WebClient webClient = new WebClient();
webClient.getOptions().setCssEnabled(false);
webClient.getOptions().setJavaScriptEnabled(false);
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.setRefreshHandler(new RefreshHandler() {
public void handleRefresh(Page page, URL url, int arg) throws IOException {
System.out.println("handleRefresh");
}
});
HtmlPage page = (HtmlPage) webClient.getPage("https://www.mohavecounty.us/ContentPage.aspx?id=111&cid=869&parcel=10272001");
DomElement ownerAddresses = page.getElementById("parcelMailingAddressResult");
NodeList nodes = page.getElementsByTagName("parcelMailingAddressResult");
final HtmlDivision div = (HtmlDivision) page.getByXPath("//div[@class='container-fluid row']").get(0);
I expected the variables ownderAddresses and nodes to contain information that includes the owner's address. I expect div to contain some other information and, once I changed get(0) to get(<someHigherInteger>), to contain also information about the owner's address.
Instead:
1) ownerAddresses = null (after execution of ownerAddress = ...)
2) nodes is of size 0 (after execution of nodes = ...)
3) final HtmlDivision div = (HtmlDivision) page.getByXPath("//div[@class='container-fluid row']").get(0);
after about 13 seconds, throws the following exception:
Exception: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
which means that (HtmlDivision) page.getByXPath("//div[@class='container-fluid row']") was of length 0.
| 0debug
|
How to retrieve Medium stories for a user from the API? : <p>I'm trying to integrate Medium blogging into an app by showing some cards with posts images and links to the original Medium publication.</p>
<p>From Medium API docs I can see how to retrieve publications and create posts, but it doesn't mention retrieving posts. Is retrieving posts/stories for a user currently possible using the Medium's API?</p>
| 0debug
|
static void sysctl_write(void *opaque, target_phys_addr_t addr, uint64_t value,
unsigned size)
{
MilkymistSysctlState *s = opaque;
trace_milkymist_sysctl_memory_write(addr, value);
addr >>= 2;
switch (addr) {
case R_GPIO_OUT:
case R_GPIO_INTEN:
case R_TIMER0_COUNTER:
case R_TIMER1_COUNTER:
case R_DBG_SCRATCHPAD:
s->regs[addr] = value;
break;
case R_TIMER0_COMPARE:
ptimer_set_limit(s->ptimer0, value, 0);
s->regs[addr] = value;
break;
case R_TIMER1_COMPARE:
ptimer_set_limit(s->ptimer1, value, 0);
s->regs[addr] = value;
break;
case R_TIMER0_CONTROL:
s->regs[addr] = value;
if (s->regs[R_TIMER0_CONTROL] & CTRL_ENABLE) {
trace_milkymist_sysctl_start_timer0();
ptimer_set_count(s->ptimer0,
s->regs[R_TIMER0_COMPARE] - s->regs[R_TIMER0_COUNTER]);
ptimer_run(s->ptimer0, 0);
} else {
trace_milkymist_sysctl_stop_timer0();
ptimer_stop(s->ptimer0);
}
break;
case R_TIMER1_CONTROL:
s->regs[addr] = value;
if (s->regs[R_TIMER1_CONTROL] & CTRL_ENABLE) {
trace_milkymist_sysctl_start_timer1();
ptimer_set_count(s->ptimer1,
s->regs[R_TIMER1_COMPARE] - s->regs[R_TIMER1_COUNTER]);
ptimer_run(s->ptimer1, 0);
} else {
trace_milkymist_sysctl_stop_timer1();
ptimer_stop(s->ptimer1);
}
break;
case R_ICAP:
sysctl_icap_write(s, value);
break;
case R_DBG_WRITE_LOCK:
s->regs[addr] = 1;
break;
case R_SYSTEM_ID:
qemu_system_reset_request();
break;
case R_GPIO_IN:
case R_CLK_FREQUENCY:
case R_CAPABILITIES:
error_report("milkymist_sysctl: write to read-only register 0x"
TARGET_FMT_plx, addr << 2);
break;
default:
error_report("milkymist_sysctl: write access to unknown register 0x"
TARGET_FMT_plx, addr << 2);
break;
}
}
| 1threat
|
static void qapi_dealloc_start_list(Visitor *v, const char *name, Error **errp)
{
QapiDeallocVisitor *qov = to_qov(v);
qapi_dealloc_push(qov, NULL);
}
| 1threat
|
int ff_lpc_calc_coefs(DSPContext *s,
const int32_t *samples, int blocksize, int max_order,
int precision, int32_t coefs[][MAX_LPC_ORDER],
int *shift, int use_lpc, int omethod, int max_shift, int zero_shift)
{
double autoc[MAX_LPC_ORDER+1];
double ref[MAX_LPC_ORDER];
double lpc[MAX_LPC_ORDER][MAX_LPC_ORDER];
int i, j, pass;
int opt_order;
assert(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER);
if(use_lpc == 1){
s->flac_compute_autocorr(samples, blocksize, max_order, autoc);
compute_lpc_coefs(autoc, max_order, lpc, ref);
}else{
LLSModel m[2];
double var[MAX_LPC_ORDER+1], weight;
for(pass=0; pass<use_lpc-1; pass++){
av_init_lls(&m[pass&1], max_order);
weight=0;
for(i=max_order; i<blocksize; i++){
for(j=0; j<=max_order; j++)
var[j]= samples[i-j];
if(pass){
double eval, inv, rinv;
eval= av_evaluate_lls(&m[(pass-1)&1], var+1, max_order-1);
eval= (512>>pass) + fabs(eval - var[0]);
inv = 1/eval;
rinv = sqrt(inv);
for(j=0; j<=max_order; j++)
var[j] *= rinv;
weight += inv;
}else
weight++;
av_update_lls(&m[pass&1], var, 1.0);
}
av_solve_lls(&m[pass&1], 0.001, 0);
}
for(i=0; i<max_order; i++){
for(j=0; j<max_order; j++)
lpc[i][j]= m[(pass-1)&1].coeff[i][j];
ref[i]= sqrt(m[(pass-1)&1].variance[i] / weight) * (blocksize - max_order) / 4000;
}
for(i=max_order-1; i>0; i--)
ref[i] = ref[i-1] - ref[i];
}
opt_order = max_order;
if(omethod == ORDER_METHOD_EST) {
opt_order = estimate_best_order(ref, max_order);
i = opt_order-1;
quantize_lpc_coefs(lpc[i], i+1, precision, coefs[i], &shift[i], max_shift, zero_shift);
} else {
for(i=0; i<max_order; i++) {
quantize_lpc_coefs(lpc[i], i+1, precision, coefs[i], &shift[i], max_shift, zero_shift);
}
}
return opt_order;
}
| 1threat
|
UITableView header view overlap cells in iOS 10 : <p>There's a simple <code>UITableView</code> in my app, and there's a custom view for the <code>tableView.tableHeaderView</code> property. When this property is set, the view has the correct size (full width, about 45px high).</p>
<pre><code>[_resultHeaderView sizeToFit]; // the view as the correct frame
[_resultTableView setTableHeaderView:_resultHeaderView];
</code></pre>
<p>In iOS 9 and previous versions, the header displays correctly, but in iOS 10, the cells start at the same Y coordinate as my header view, so my header view appears over the first cell.</p>
<p>Setting these properties also have no effect:</p>
<pre><code>self.edgesForExtendedLayout = UIRectEdgeNone;
self.automaticallyAdjustsScrollViewInsets = NO;
</code></pre>
<p>Has something changed in iOS 10 that could explain this different behavior? What would be a good solution?</p>
<p>Thanks</p>
| 0debug
|
void xen_pt_config_delete(XenPCIPassthroughState *s)
{
struct XenPTRegGroup *reg_group, *next_grp;
struct XenPTReg *reg, *next_reg;
if (s->msix) {
xen_pt_msix_delete(s);
}
if (s->msi) {
g_free(s->msi);
}
QLIST_FOREACH_SAFE(reg_group, &s->reg_grps, entries, next_grp) {
QLIST_FOREACH_SAFE(reg, ®_group->reg_tbl_list, entries, next_reg) {
QLIST_REMOVE(reg, entries);
g_free(reg);
}
QLIST_REMOVE(reg_group, entries);
g_free(reg_group);
}
}
| 1threat
|
float32 float32_sqrt( float32 a STATUS_PARAM )
{
flag aSign;
int16 aExp, zExp;
bits32 aSig, zSig;
bits64 rem, term;
aSig = extractFloat32Frac( a );
aExp = extractFloat32Exp( a );
aSign = extractFloat32Sign( a );
if ( aExp == 0xFF ) {
if ( aSig ) return propagateFloat32NaN( a, 0 STATUS_VAR );
if ( ! aSign ) return a;
float_raise( float_flag_invalid STATUS_VAR);
return float32_default_nan;
}
if ( aSign ) {
if ( ( aExp | aSig ) == 0 ) return a;
float_raise( float_flag_invalid STATUS_VAR);
return float32_default_nan;
}
if ( aExp == 0 ) {
if ( aSig == 0 ) return 0;
normalizeFloat32Subnormal( aSig, &aExp, &aSig );
}
zExp = ( ( aExp - 0x7F )>>1 ) + 0x7E;
aSig = ( aSig | 0x00800000 )<<8;
zSig = estimateSqrt32( aExp, aSig ) + 2;
if ( ( zSig & 0x7F ) <= 5 ) {
if ( zSig < 2 ) {
zSig = 0x7FFFFFFF;
goto roundAndPack;
}
aSig >>= aExp & 1;
term = ( (bits64) zSig ) * zSig;
rem = ( ( (bits64) aSig )<<32 ) - term;
while ( (sbits64) rem < 0 ) {
--zSig;
rem += ( ( (bits64) zSig )<<1 ) | 1;
}
zSig |= ( rem != 0 );
}
shift32RightJamming( zSig, 1, &zSig );
roundAndPack:
return roundAndPackFloat32( 0, zExp, zSig STATUS_VAR );
}
| 1threat
|
Configure tmux scroll speed : <p>Can tmux scroll speed (using a mouse wheel or touch pad) be configured?</p>
<p>Tmux 2.1 sort of broke scrolling (depending on your configuration), forcing me to update my config. I did that a few weeks ago.</p>
<p>But now I think tmux scrolls* slower than it used to. I think I read you can configure the scroll speed but I can't find any mention of that anywhere now.</p>
<p>* Scrolling with a mouse wheel that is. (I'm actually using a Macbook trackpad but I think it's equivalent to a mouse wheel.)</p>
<p>I know you can do 10C-u (with vi key bindings) to jump up 10 pages, but I'd also like to be able to just scroll fast with the mouse.</p>
<p>I think this is all the relevant config I personally have currently:</p>
<pre><code># Use the mouse to select panes, select windows (click window tabs), resize
# panes, and scroll in copy mode.
# Requires tmux version >= 2.1 (older versions have different option names for mouse)
set -g mouse on
# No need to enter copy-mode to start scrolling.
# From github.com/tmux/tmux/issues/145
# Requires tmux version >= 2.1 (older versions have different solutions)
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'"
</code></pre>
| 0debug
|
document.getElementById('input').innerHTML = user_input;
| 1threat
|
How to transform attribute values into keys? : <p>I have a JSON in the format. </p>
<pre><code>var input = [
{status:"good", state: "NY"},
{status:"bad", state: "FL"},
{status:"decent", state: "CA"}
]
</code></pre>
<p>I want to transform it in an object of the format:</p>
<pre><code>myObj = {NY:"good",FL:"bad",CA:"decent"}
</code></pre>
<p>The reason I want this is so that I can easily grab the myObj.NY value.</p>
| 0debug
|
interview question hive partitioning and bucketing : <p>I am new to Hive and i recently had an interview in which i was asked below questions. can someone help with the right answer.</p>
<ol>
<li>While doing partioning what if data is missing from one column how will partitioning handle it?</li>
<li>Can you import log file using sqoop? I gave the answer NO as sqoop is used to import data from RDBMS tables to hadoop.</li>
<li>In the employee table if the value is null for any data can you still sqoop it?</li>
<li>Employee table is given with employee id, location, salary, department, whaat column will be used in partioning and bucketting? I think we can use department as partioning and employee id, location and salary can be used as bucketing, please confirm.</li>
</ol>
| 0debug
|
static void ehci_trace_itd(EHCIState *s, target_phys_addr_t addr, EHCIitd *itd)
{
trace_usb_ehci_itd(addr, itd->next);
}
| 1threat
|
static inline unsigned in_reg(IVState *s, enum Reg reg)
{
const char *name = reg2str(reg);
QTestState *qtest = global_qtest;
unsigned res;
global_qtest = s->qtest;
res = qpci_io_readl(s->dev, s->reg_base + reg);
g_test_message("*%s -> %x\n", name, res);
global_qtest = qtest;
return res;
}
| 1threat
|
select tow table oracle : Please help
I am I have two tables
EMPLOYEE, DEPARTMENT
Table DEPARTMENT
There are fields in which
DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID
EMPLOYEE table
There are fields in which
EMPLOYEE_ID
FIRST_NAME
LAST_NAME
EMAIL
PHONE_NUMBER
HIRE_DATE DATE
JOB_ID
SALARY
COMMISSION_PCT
MANAGER_ID
DEPARTMENT_ID
When the desired number appears DEPARTMENT_ID chose me EMPLOYEE_ID
> FIRST_NAME
> LAST_NAME
> EMAIL
> PHONE_NUMBER
> HIRE_DATE DATE
> JOB_ID
> SALARY
> COMMISSION_PCT
> MANAGER_ID
> DEPARTMENT_ID
| 0debug
|
static inline void RENAME(bgr32ToY)(uint8_t *dst, uint8_t *src, int width)
{
int i;
for(i=0; i<width; i++)
{
int b= ((uint32_t*)src)[i]&0xFF;
int g= (((uint32_t*)src)[i]>>8)&0xFF;
int r= (((uint32_t*)src)[i]>>16)&0xFF;
dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT);
}
}
| 1threat
|
Member Variable in Header Undefined : <p>I'm trying to learn how to split my code up into header and source files, but don't understand why my member variable <code>attackPower</code> is considered undefined.</p>
<p>Enemy.h</p>
<pre><code>#pragma once
class Enemy{
protected:
int attackPower;
public:
Enemy();
void setAttackPower(int a);
virtual void attack() = 0;
};
</code></pre>
<p>Enemy.cpp</p>
<pre><code>#include <iostream>
#include "Enemy.h"
class Enemy {
public:
Enemy::Enemy(){
attackPower = 0;
}
void Enemy::setAttackPower(int a){
attackPower = a;
}
};
</code></pre>
<p>In Enemy.cpp, Visual Studio tells me </p>
<blockquote>
<p>identifier "attackPower" is undefined</p>
</blockquote>
| 0debug
|
Promoting my GitHub repo : <p>I've just recently open-sourced my app, but I'm not entirely sure how to promote the GitHub repository. The whole idea of open-sourcing it was to get the power of the developer community on my side, but I'm not sure how to get people noticing the repo. Does anyone have any suggestions?</p>
| 0debug
|
How easily create an array from .csv and search in it using C#? : <p>There is a 1.csv file</p>
<pre><code>name1;5547894;bnt652147
name2;5546126;bnt956231
name3;5549871;nhy754497
</code></pre>
<p>How in fast and elegant way, may be in one line, read this file and add separated values to 2d array?</p>
<p>And then, how we can easily and quickly seach for some string in that array?</p>
| 0debug
|
Open Visual Studio 2009 Solution in Visual Studio 2013 without Upgrading : In short: **I need to open an application originally built in VS09 in VS13 without upgrading the project since the overall project architecture must remain the same for when I check it back into source control.**
Details: I need to open a Visual Studio solution (.sln) inside **Visual Studio 2013**. The solution in question was originally developed in Visual Studio 2009, so when I try to open said solution in Visual Studio 2013, I am shown a prompt with the projects within the solution checkmarked, with the message:
* These projects are either or supported or need project behavior impacting modifications to open in this version of Visual Studio. Projects no displayed either require no changes or will automatically be modified such that behavior is not impacted. Visual Studio will automatically make functional changes to the following projects in order to open them. You will not be able to open these projects in the version of Visual Studio in which they were originally created.*
My attempt at a fix was to just upgrade the solution and hope for the best. This is successful, but after building and attempting to run the main project, I see the following build error:
* The type 'Microsoft.Web.Services3.WebServicesClientProtocol' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. *
I then tried both commenting out the references to this assembly *and* adding in the missing reference. Okay, so then I rebuilt the solution and attempted to run. Same error, but for a different assembly. Repeat fix, same error for different assembly. This pattern continues and continues, and at this point I realize this is unacceptable anyway, because when I make a change to this solution, I need to check it back into source control. When others open it, they may be opening it in VS09, and therefore this “upgraded” version is inconsistent with the version the business uses. I need to open the solution originally build in VS 2009 in VS 2013 (can't work around this, needs to be VS13). If it helps, I'm using *64 bit Visual Studio 2013 Ultimate.*
Any help or guidance will be greatly appreciated!
| 0debug
|
def max_path_sum(tri, m, n):
for i in range(m-1, -1, -1):
for j in range(i+1):
if (tri[i+1][j] > tri[i+1][j+1]):
tri[i][j] += tri[i+1][j]
else:
tri[i][j] += tri[i+1][j+1]
return tri[0][0]
| 0debug
|
static int doTest(uint8_t *ref[4], int refStride[4], int w, int h,
enum PixelFormat srcFormat, enum PixelFormat dstFormat,
int srcW, int srcH, int dstW, int dstH, int flags)
{
uint8_t *src[4] = {0};
uint8_t *dst[4] = {0};
uint8_t *out[4] = {0};
int srcStride[4], dstStride[4];
int i;
uint64_t ssdY, ssdU=0, ssdV=0, ssdA=0;
struct SwsContext *srcContext = NULL, *dstContext = NULL,
*outContext = NULL;
int res;
res = 0;
for (i=0; i<4; i++) {
if (srcFormat==PIX_FMT_RGB24 || srcFormat==PIX_FMT_BGR24)
srcStride[i]= srcW*3;
else if (srcFormat==PIX_FMT_RGB48BE || srcFormat==PIX_FMT_RGB48LE)
srcStride[i]= srcW*6;
else
srcStride[i]= srcW*4;
if (dstFormat==PIX_FMT_RGB24 || dstFormat==PIX_FMT_BGR24)
dstStride[i]= dstW*3;
else if (dstFormat==PIX_FMT_RGB48BE || dstFormat==PIX_FMT_RGB48LE)
dstStride[i]= dstW*6;
else
dstStride[i]= dstW*4;
src[i]= av_mallocz(srcStride[i]*srcH+16);
dst[i]= av_mallocz(dstStride[i]*dstH+16);
out[i]= av_mallocz(refStride[i]*h);
if (!src[i] || !dst[i] || !out[i]) {
perror("Malloc");
res = -1;
goto end;
}
}
srcContext= sws_getContext(w, h, PIX_FMT_YUVA420P, srcW, srcH, srcFormat, flags, NULL, NULL, NULL);
if (!srcContext) {
fprintf(stderr, "Failed to get %s ---> %s\n",
av_pix_fmt_descriptors[PIX_FMT_YUVA420P].name,
av_pix_fmt_descriptors[srcFormat].name);
res = -1;
goto end;
}
dstContext= sws_getContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat, flags, NULL, NULL, NULL);
if (!dstContext) {
fprintf(stderr, "Failed to get %s ---> %s\n",
av_pix_fmt_descriptors[srcFormat].name,
av_pix_fmt_descriptors[dstFormat].name);
res = -1;
goto end;
}
outContext= sws_getContext(dstW, dstH, dstFormat, w, h, PIX_FMT_YUVA420P, flags, NULL, NULL, NULL);
if (!outContext) {
fprintf(stderr, "Failed to get %s ---> %s\n",
av_pix_fmt_descriptors[dstFormat].name,
av_pix_fmt_descriptors[PIX_FMT_YUVA420P].name);
res = -1;
goto end;
}
sws_scale(srcContext, ref, refStride, 0, h , src, srcStride);
sws_scale(dstContext, src, srcStride, 0, srcH, dst, dstStride);
sws_scale(outContext, dst, dstStride, 0, dstH, out, refStride);
ssdY= getSSD(ref[0], out[0], refStride[0], refStride[0], w, h);
if (hasChroma(srcFormat) && hasChroma(dstFormat)) {
ssdU= getSSD(ref[1], out[1], refStride[1], refStride[1], (w+1)>>1, (h+1)>>1);
ssdV= getSSD(ref[2], out[2], refStride[2], refStride[2], (w+1)>>1, (h+1)>>1);
}
if (isALPHA(srcFormat) && isALPHA(dstFormat))
ssdA= getSSD(ref[3], out[3], refStride[3], refStride[3], w, h);
ssdY/= w*h;
ssdU/= w*h/4;
ssdV/= w*h/4;
ssdA/= w*h;
printf(" %s %dx%d -> %s %4dx%4d flags=%2d SSD=%5"PRId64",%5"PRId64",%5"PRId64",%5"PRId64"\n",
av_pix_fmt_descriptors[srcFormat].name, srcW, srcH,
av_pix_fmt_descriptors[dstFormat].name, dstW, dstH,
flags, ssdY, ssdU, ssdV, ssdA);
fflush(stdout);
end:
sws_freeContext(srcContext);
sws_freeContext(dstContext);
sws_freeContext(outContext);
for (i=0; i<4; i++) {
av_free(src[i]);
av_free(dst[i]);
av_free(out[i]);
}
return res;
}
| 1threat
|
Jest test fails : TypeError: window.matchMedia is not a function : <p>This is my first front-end testing experience. In this project, I'm using jest snapshot testing and got an error <code>TypeError: window.matchMedia is not a function</code> inside my component. </p>
<p>I go through jest documentation, I found "Manual mocks" section, but I have not any idea about how to do that yet. </p>
| 0debug
|
static void *do_touch_pages(void *arg)
{
MemsetThread *memset_args = (MemsetThread *)arg;
char *addr = memset_args->addr;
uint64_t numpages = memset_args->numpages;
uint64_t hpagesize = memset_args->hpagesize;
sigset_t set, oldset;
int i = 0;
sigemptyset(&set);
sigaddset(&set, SIGBUS);
pthread_sigmask(SIG_UNBLOCK, &set, &oldset);
if (sigsetjmp(memset_args->env, 1)) {
memset_thread_failed = true;
} else {
for (i = 0; i < numpages; i++) {
memset(addr, 0, 1);
addr += hpagesize;
}
}
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
return NULL;
}
| 1threat
|
what does this for loop do in c ? for(; j; printf("%d %d",i,j)) :
#include <stdio.h>
int main(void) {
int i=1,j=1;
for (; j; printf("%d %d",i,j))
j = i++<=5;
return 0;
}
**output-**
2 13 14 15 16 17 0
can anyone Explain,what is happening inside the loop!. This question is asked by Zoho Cooperation in the interview process.
| 0debug
|
static coroutine_fn int cloop_co_read(BlockDriverState *bs, int64_t sector_num,
uint8_t *buf, int nb_sectors)
{
int ret;
BDRVCloopState *s = bs->opaque;
qemu_co_mutex_lock(&s->lock);
ret = cloop_read(bs, sector_num, buf, nb_sectors);
qemu_co_mutex_unlock(&s->lock);
return ret;
}
| 1threat
|
How do I send an email to an email address with an custom message : <p>I wanted to send an email such as an confirmation email to an email address that the user has alredy specified in an input tag. Exampe:
I type in my email in an input tag and then I would recive an email at the address I entered in the input tag. Thanks, and If you know the answer could you possibly send me an code to paste in. (Im an php noob)</p>
| 0debug
|
Explain this code to me : Explain this code to me. This is a program to print integer inputs as outputs in letters. if i input 35 then output will be thirty five. i understood most of it but want to know how **tens** take the value from
"twenty thirty forty fifty sixty seventy eighty ninety"
The code is:
num = int(input("Enter the number:"))
numbers = ("zero one two three four five six seven eight nine".split())
numbers.extend("ten eleven twelve thirteen fourteen fifteen sixteen".split())
numbers.extend("seventeen eighteen nineteen".split())
numbers.extend(tens if ones == "zero" else (tens + " " + ones)
for tens in "twenty thirty forty fifty sixty seventy eighty ninety".split()
for ones in numbers[0:10])
print(numbers[num])
| 0debug
|
static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time)
{
RTPDemuxContext *s = s1->priv_data;
uint32_t rtp_ts;
#if defined(DEBUG)
printf("RTCP: %02x %"PRIx64" %x\n", s->payload_type, ntp_time, s->timestamp);
#endif
if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE) s->first_rtcp_ntp_time = ntp_time;
s->last_rtcp_ntp_time = ntp_time;
rtp_ts = av_rescale_q(ntp_time - s->first_rtcp_ntp_time, AV_TIME_BASE_Q,
s1->streams[0]->time_base) + s->base_timestamp;
put_byte(s1->pb, (RTP_VERSION << 6));
put_byte(s1->pb, 200);
put_be16(s1->pb, 6);
put_be32(s1->pb, s->ssrc);
put_be32(s1->pb, ntp_time / 1000000);
put_be32(s1->pb, ((ntp_time % 1000000) << 32) / 1000000);
put_be32(s1->pb, rtp_ts);
put_be32(s1->pb, s->packet_count);
put_be32(s1->pb, s->octet_count);
put_flush_packet(s1->pb);
}
| 1threat
|
how to skip mysql reserved words from (bulk text) : <p>I am having error:
( SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 's a immoderate-immoderate-fine boy' WHERE id='4'' at line 1all )</p>
<p>I am actually trying to modify and save bulk text using the method bellow by looping but the problem is I get above error after process few text. As I found mysql reserved words getting matched while looping on bulk text. How can I modify my method to work on bulk text without mysql reserved word conflict problem. Whats the solution?</p>
<p>Text update method:</p>
<pre><code>public function update_des($id,$des){
try
{
$stmt = $this->conn->prepare("UPDATE products SET des='$des' WHERE id='$id'");
$stmt->execute();
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
</code></pre>
| 0debug
|
I need help in python Spell checker : Traceback (most recent call last):
File "C:\Python27\pys_new.py", line 3, in <module>
spell = SpellChecker()
File "C:\Python27\lib\site-packages\spellchecker\spellchecker.py", line 36, in __init__
raise ValueError(msg)
ValueError: The provided dictionary language (en) does not exist!
I'm getting this error when i try to run the program. Anybody please help
| 0debug
|
static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
int64_t offset, int count, BdrvRequestFlags flags)
{
BlockDriver *drv = bs->drv;
QEMUIOVector qiov;
struct iovec iov = {0};
int ret = 0;
bool need_flush = false;
int head = 0;
int tail = 0;
int max_write_zeroes = MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, INT_MAX);
int alignment = MAX(bs->bl.pwrite_zeroes_alignment,
bs->bl.request_alignment);
assert(alignment % bs->bl.request_alignment == 0);
head = offset % alignment;
tail = (offset + count) % alignment;
max_write_zeroes = QEMU_ALIGN_DOWN(max_write_zeroes, alignment);
assert(max_write_zeroes >= bs->bl.request_alignment);
while (count > 0 && !ret) {
int num = count;
if (head) {
num = MIN(count, alignment - head);
head = 0;
} else if (tail && num > alignment) {
num -= tail;
}
if (num > max_write_zeroes) {
num = max_write_zeroes;
}
ret = -ENOTSUP;
if (drv->bdrv_co_pwrite_zeroes) {
ret = drv->bdrv_co_pwrite_zeroes(bs, offset, num,
flags & bs->supported_zero_flags);
if (ret != -ENOTSUP && (flags & BDRV_REQ_FUA) &&
!(bs->supported_zero_flags & BDRV_REQ_FUA)) {
need_flush = true;
}
} else {
assert(!bs->supported_zero_flags);
}
if (ret == -ENOTSUP) {
int max_transfer = MIN_NON_ZERO(bs->bl.max_transfer,
MAX_WRITE_ZEROES_BOUNCE_BUFFER);
BdrvRequestFlags write_flags = flags & ~BDRV_REQ_ZERO_WRITE;
if ((flags & BDRV_REQ_FUA) &&
!(bs->supported_write_flags & BDRV_REQ_FUA)) {
write_flags &= ~BDRV_REQ_FUA;
need_flush = true;
}
num = MIN(num, max_transfer);
iov.iov_len = num;
if (iov.iov_base == NULL) {
iov.iov_base = qemu_try_blockalign(bs, num);
if (iov.iov_base == NULL) {
ret = -ENOMEM;
goto fail;
}
memset(iov.iov_base, 0, num);
}
qemu_iovec_init_external(&qiov, &iov, 1);
ret = bdrv_driver_pwritev(bs, offset, num, &qiov, write_flags);
if (num < max_transfer) {
qemu_vfree(iov.iov_base);
iov.iov_base = NULL;
}
}
offset += num;
count -= num;
}
fail:
if (ret == 0 && need_flush) {
ret = bdrv_co_flush(bs);
}
qemu_vfree(iov.iov_base);
return ret;
}
| 1threat
|
static uint64_t imx_serial_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
IMXSerialState *s = (IMXSerialState *)opaque;
uint32_t c;
DPRINTF("read(offset=%x)\n", offset >> 2);
switch (offset >> 2) {
case 0x0:
c = s->readbuff;
if (!(s->uts1 & UTS1_RXEMPTY)) {
c |= URXD_CHARRDY;
s->usr1 &= ~USR1_RRDY;
s->usr2 &= ~USR2_RDR;
s->uts1 |= UTS1_RXEMPTY;
imx_update(s);
qemu_chr_accept_input(s->chr);
}
return c;
case 0x20:
return s->ucr1;
case 0x21:
return s->ucr2;
case 0x25:
return s->usr1;
case 0x26:
return s->usr2;
case 0x2A:
return s->ubmr;
case 0x2B:
return s->ubrc;
case 0x2d:
return s->uts1;
case 0x24:
return s->ufcr;
case 0x2c:
return s->onems;
case 0x22:
return s->ucr3;
case 0x23:
case 0x29:
return 0x0;
default:
IPRINTF("imx_serial_read: bad offset: 0x%x\n", (int)offset);
return 0;
}
}
| 1threat
|
Get all numbers in a text and get the sum : <p>I have this textbox</p>
<pre><code> HAIJME 130, PAYIJE 150, IDHEUO 200
</code></pre>
<p>And should have the result of 130+150+200 = 480</p>
<p>I've searched codes for getting words/numbers in a textbox but it needs to have a start or and end and will get remaining characters. In my case, I cannot assume that the numbers will have exact 3 characters every time.</p>
| 0debug
|
Implement an interface : I'm studying implement an interface and abstract class and here it comes to this question that I'm struggling with. I hope you guys can help me out with this question and I'm looking for an explanation in order to understand the code. Any advice is welcome and truly appreciate.
I have been trying to run the code to get the output but it does not work.I think C is an answer but I'm not sure.
Here is the question: Which of the following will order an array of Student objects by last name, then by credits (if two students have the same last name) if you were to pass the array of Students to the Arrays.sort() method?
```java
Student[] list;
// The array is created and filled with Student objects...
Arrays.sort(list);
A. public class Student implements Comparable {
private String lastName;
private int credits;
public int compareTo(Student s) {
int result = lastName.compareTo( s.getLastName() );
if (result != 0)
return result;
else
return credits - s.getCredits();
}
}
B. public class Student implements Comparable {
private String lastName;
private int credits;
public int compareTo(Object o) {
int result = credits - ( ((Student) o).getCredits() );
if (result != 0)
return result;
else
return lastName.compareTo( ((Student) o).getLastName() );
}
}
C. public class Student {
private String lastName;
private int credits;
public int compareTo(Object o) {
result = lastName.compareTo( ((Student) o).getLastName() );
if (result != 0)
return result;
else
return credits - ( ((Student) o).getCredits() );
}
}
D. public class Student implements Comparable {
private String lastName;
private int credits;
public int compareTo(Object o) {
int result = lastName.compareTo( ((Student) o).getLastName() );
if (result != 0)
return result;
else
return credits - ( ((Student) o).getCredits() );
}
}
```
| 0debug
|
deserialize JSON without one by one in VB.NET (part 2) : I have this JSON:
> {"JOE":{"id":7,"age":"23"},"BILLY":{"id":8,"age":"29"}}
i have this solution for a more simple JSON structure posted by RajN.
Dim j1 As String = "{ "JOE"":""0.90000000"",""JOE"":""3.30000000"",""MONROE"":""1.20000000""}"
Dim dict = JsonConvert.DeserializeObject(Of Dictionary(Of String, String))(j1)
For Each kvp In dict
Console.WriteLine(kvp.Key & " - " + kvp.Value)
Next
I'm looking for how to do with the new JSON data.
Thanks in advance
| 0debug
|
int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx,
uint8_t *buf, int buf_size,
const short *samples)
{
AVPacket pkt;
AVFrame *frame;
int ret, samples_size, got_packet;
av_init_packet(&pkt);
pkt.data = buf;
pkt.size = buf_size;
if (samples) {
frame = av_frame_alloc();
if (avctx->frame_size) {
frame->nb_samples = avctx->frame_size;
} else {
int64_t nb_samples;
if (!av_get_bits_per_sample(avctx->codec_id)) {
av_log(avctx, AV_LOG_ERROR, "avcodec_encode_audio() does not "
"support this codec\n");
av_frame_free(&frame);
return AVERROR(EINVAL);
}
nb_samples = (int64_t)buf_size * 8 /
(av_get_bits_per_sample(avctx->codec_id) *
avctx->channels);
if (nb_samples >= INT_MAX) {
av_frame_free(&frame);
return AVERROR(EINVAL);
}
frame->nb_samples = nb_samples;
}
samples_size = av_samples_get_buffer_size(NULL, avctx->channels,
frame->nb_samples,
avctx->sample_fmt, 1);
if ((ret = avcodec_fill_audio_frame(frame, avctx->channels,
avctx->sample_fmt,
(const uint8_t *)samples,
samples_size, 1)) < 0) {
av_frame_free(&frame);
return ret;
}
if (avctx->sample_rate && avctx->time_base.num)
frame->pts = ff_samples_to_time_base(avctx,
avctx->internal->sample_count);
else
frame->pts = AV_NOPTS_VALUE;
avctx->internal->sample_count += frame->nb_samples;
} else {
frame = NULL;
}
got_packet = 0;
ret = avcodec_encode_audio2(avctx, &pkt, frame, &got_packet);
if (!ret && got_packet && avctx->coded_frame) {
avctx->coded_frame->pts = pkt.pts;
avctx->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY);
}
av_packet_free_side_data(&pkt);
if (frame && frame->extended_data != frame->data)
av_freep(&frame->extended_data);
av_frame_free(&frame);
return ret ? ret : pkt.size;
}
| 1threat
|
BlockDriverAIOCB *thread_pool_submit_aio(ThreadPoolFunc *func, void *arg,
BlockDriverCompletionFunc *cb, void *opaque)
{
ThreadPool *pool = &global_pool;
ThreadPoolElement *req;
req = qemu_aio_get(&thread_pool_aiocb_info, NULL, cb, opaque);
req->func = func;
req->arg = arg;
req->state = THREAD_QUEUED;
req->pool = pool;
QLIST_INSERT_HEAD(&pool->head, req, all);
trace_thread_pool_submit(pool, req, arg);
qemu_mutex_lock(&pool->lock);
if (pool->idle_threads == 0 && pool->cur_threads < pool->max_threads) {
spawn_thread(pool);
}
QTAILQ_INSERT_TAIL(&pool->request_list, req, reqs);
qemu_mutex_unlock(&pool->lock);
qemu_sem_post(&pool->sem);
return &req->common;
}
| 1threat
|
static void gt64120_write_config(PCIDevice *d, uint32_t address, uint32_t val,
int len)
{
#ifdef TARGET_WORDS_BIGENDIAN
val = bswap32(val);
#endif
pci_default_write_config(d, address, val, len);
}
| 1threat
|
spring-boot testing - Could multiple test share a single context? : <p>I created multiple spring-boot testing class, <em>(with <code>spring-boot</code> <strong>1.4.0</strong>)</em>.</p>
<p><strong>FirstActionTest.java</strong>:</p>
<pre><code>@RunWith(SpringRunner.class)
@WebMvcTest(FirstAction.class)
@TestPropertySource("classpath:test-application.properties")
public class FirstActionTest {
@Autowired
private MockMvc mvc;
// ...
}
</code></pre>
<p><strong>SecondActionTest.java</strong>:</p>
<pre><code>@RunWith(SpringRunner.class)
@WebMvcTest(SecondAction.class)
@TestPropertySource("classpath:test-application.properties")
public class SecondActionTest {
@Autowired
private MockMvc mvc;
// ...
}
</code></pre>
<p>When run test via:</p>
<blockquote>
<p>mvn test</p>
</blockquote>
<p>It seems created a spring test context for each testing class, which is not necessary I guess.</p>
<p><strong>The question is:</strong></p>
<ul>
<li>Is it possible to share a single spring test context among multiple testing class, and if yes, how?</li>
</ul>
| 0debug
|
static void bdrv_password_cb(void *opaque, const char *password,
void *readline_opaque)
{
Monitor *mon = opaque;
BlockDriverState *bs = readline_opaque;
int ret = 0;
Error *local_err = NULL;
bdrv_add_key(bs, password, &local_err);
if (local_err) {
error_report_err(local_err);
ret = -EPERM;
}
if (mon->password_completion_cb)
mon->password_completion_cb(mon->password_opaque, ret);
monitor_read_command(mon, 1);
}
| 1threat
|
How can I make my whole php safer? : <p>I would like to know how to make a php file safer in general. I actually use mysqli, which is unfortunately not the newest version anymore, I know. I mysqli_escape_str...() all strings entered in input fields, too. But do you have some tips regarding the safety. I also use some ajax, if you need to know that. </p>
| 0debug
|
Running ChromeDriver with Python selenium on Heroku : <p>So I have a Flask server on Heroku which has been working fine as expected for some time.Now, as per new requirements, I need to add functionality to the Flask server to fetch a page from an external website.Because of reasons best known to me, I am using Selenium along with Chrome web driver to do this.Locally I was able to set this up and it works fine but I am quite unsure as to how to set it up on the Heroku server. I read a bit about buildpacks and found this buildpack for ChromeDriver :</p>
<pre><code>https://elements.heroku.com/buildpacks/jimmynguyc/heroku-buildpack-chromedriver
</code></pre>
<p>However, I am not sure how to proceed further.How do I install chromium browser itself and what else is needed to tie it all up ?</p>
| 0debug
|
static QEMUFile *open_test_file(bool write)
{
int fd = dup(temp_fd);
QIOChannel *ioc;
lseek(fd, 0, SEEK_SET);
if (write) {
g_assert_cmpint(ftruncate(fd, 0), ==, 0);
}
ioc = QIO_CHANNEL(qio_channel_file_new_fd(fd));
if (write) {
return qemu_fopen_channel_output(ioc);
} else {
return qemu_fopen_channel_input(ioc);
}
}
| 1threat
|
int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
{
const AVCodec *orig_codec = dest->codec;
uint8_t *orig_priv_data = dest->priv_data;
if (avcodec_is_open(dest)) {
av_log(dest, AV_LOG_ERROR,
"Tried to copy AVCodecContext %p into already-initialized %p\n",
src, dest);
return AVERROR(EINVAL);
}
copy_context_reset(dest);
memcpy(dest, src, sizeof(*dest));
av_opt_copy(dest, src);
dest->priv_data = orig_priv_data;
dest->codec = orig_codec;
if (orig_priv_data && src->codec && src->codec->priv_class &&
dest->codec && dest->codec->priv_class)
av_opt_copy(orig_priv_data, src->priv_data);
dest->slice_offset = NULL;
dest->hwaccel = NULL;
dest->internal = NULL;
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
dest->coded_frame = NULL;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
dest->extradata = NULL;
dest->intra_matrix = NULL;
dest->inter_matrix = NULL;
dest->rc_override = NULL;
dest->subtitle_header = NULL;
dest->hw_frames_ctx = NULL;
#define alloc_and_copy_or_fail(obj, size, pad) \
if (src->obj && size > 0) { \
dest->obj = av_malloc(size + pad); \
if (!dest->obj) \
goto fail; \
memcpy(dest->obj, src->obj, size); \
if (pad) \
memset(((uint8_t *) dest->obj) + size, 0, pad); \
}
alloc_and_copy_or_fail(extradata, src->extradata_size,
AV_INPUT_BUFFER_PADDING_SIZE);
dest->extradata_size = src->extradata_size;
alloc_and_copy_or_fail(intra_matrix, 64 * sizeof(int16_t), 0);
alloc_and_copy_or_fail(inter_matrix, 64 * sizeof(int16_t), 0);
alloc_and_copy_or_fail(rc_override, src->rc_override_count * sizeof(*src->rc_override), 0);
alloc_and_copy_or_fail(subtitle_header, src->subtitle_header_size, 1);
av_assert0(dest->subtitle_header_size == src->subtitle_header_size);
#undef alloc_and_copy_or_fail
if (src->hw_frames_ctx) {
dest->hw_frames_ctx = av_buffer_ref(src->hw_frames_ctx);
if (!dest->hw_frames_ctx)
goto fail;
}
return 0;
fail:
copy_context_reset(dest);
return AVERROR(ENOMEM);
}
| 1threat
|
How to fix stringIndexOutOfBoundsExceptipon on android? : My app record camera preview every 5 minute.
record file is save on `/sdcard/Movies/*.mp4`
before create record file. check current storage space
//execute every 5 minute.
if (current space < MAX_SIZE) { //record start
//record start
} else { //record impossible. try old file delete.
RecordFile recFile = new RecordFile();
boolean ret = recFile.deleteOldFile();
}
my situation current record impossible. try old file delete.
but occur `StringIndexOutOfBoundsException`
my source
RecordFile.class
private ArrayList<String> mRecFiles;
private ArrayList<Long> mRecFilesNum;
private HashMap<Long, String> fileMap;
private String filePath;
private String delFileName;
public boolean deleteOldFile() {
String delFname = getRecordFileList();
File delFile = new File(filePath + delFname);
if (delFile.delete()) {
//success old file delete
return true;
} else {
//fail delete
return true;
}
}
public String getRecordFileList() {
filePath = Environment.getExternalStorageDirectory() + File.separator
+ Environment.DIRECTORY_MOVIES + File.separator;
mRecFiles = new ArrayList();
mRecFilesNum = new ArrayList();
fileMap = new HashMap();
File file = new File(filePath);
File[] list = file.listFiles();
for (int i = 0; i < list.length; i++) {
String fname = list[i].getName();
int idx = fname.lastIndexOf(".");
String fname2 = fname.substring(0, idx); //occur stringIndexOutOfBoundsException
long tmp = Long.parseLong(fname2.replaceAll("[^0-9]", ""));
fileMap.put(tmp, fname);
mRecFilesNum.add(tmp);
}
long max = Collections.max(mRecFilesNum);
long min = Collections.min(mRecFilesNum);
Iterator<Long> iterator = fileMap.keySet().iterator();
while (iterator.hasNext()) {
Long key = iterator.next();
if (key == min) {
delFileName = fileMap.get(key);
break;
}
}
return delFileName;
}
}
java.lang.StringIndexOutOfBoundsException: length=10; regionStart=0; regionLength=-1
at java.lang.String.startEndAndLength(String.java:298)
at java.lang.String.substring(String.java:1087)
at kr.co.iosystem.blackeyeonandroid.record.RecordFile.getRecordFileList(RecordFile.java:72)
at kr.co.iosystem.blackeyeonandroid.record.RecordFile.deleteBeforeFile(RecordFile.java:35)
at kr.co.iosystem.blackeyeonandroid.BlackEyeActivity$mRecTimerHandler.handleMessage(BlackEyeActivity.java:582)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5415)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:745)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:635)
How to fix this problem?
thanks.
| 0debug
|
import math
def divSum(n):
sum = 1;
i = 2;
while(i * i <= n):
if (n % i == 0):
sum = (sum + i +math.floor(n / i));
i += 1;
return sum;
def areEquivalent(num1,num2):
return divSum(num1) == divSum(num2);
| 0debug
|
Unity3d drawing with whitespaces (sorry for my English) : I made drawing lines using LineRenderer. Game is 2d. Now, what I want, is to make whitespace in line exactly where the line is on the gameobject with collider. Cant understand how to achive that. It looks like hard task for me.
| 0debug
|
Find time to nearest occurrence of particular value for each row : <p>Say I have a data table:</p>
<pre><code>dt <- data.table(
datetime = seq(as.POSIXct("2016-01-01 00:00:00"),as.POSIXct("2016-01-01 10:00:00"), by = "1 hour"),
ObType = c("A","A","B","B","B","B","A","A","B","A","A")
)
dt
datetime ObType
1: 2016-01-01 00:00:00 A
2: 2016-01-01 01:00:00 A
3: 2016-01-01 02:00:00 B
4: 2016-01-01 03:00:00 B
5: 2016-01-01 04:00:00 B
6: 2016-01-01 05:00:00 B
7: 2016-01-01 06:00:00 A
8: 2016-01-01 07:00:00 A
9: 2016-01-01 08:00:00 B
10: 2016-01-01 09:00:00 A
11: 2016-01-01 10:00:00 A
</code></pre>
<p>What I need to do is wherever the ObType is "B", I need to find the time to the nearest ObType "A" on either side. So the result should look like (in hours):</p>
<pre><code> datetime ObType timeLag timeLead
1: 2016-01-01 00:00:00 A NA NA
2: 2016-01-01 01:00:00 A NA NA
3: 2016-01-01 02:00:00 B 1 4
4: 2016-01-01 03:00:00 B 2 3
5: 2016-01-01 04:00:00 B 3 2
6: 2016-01-01 05:00:00 B 4 1
7: 2016-01-01 06:00:00 A NA NA
8: 2016-01-01 07:00:00 A NA NA
9: 2016-01-01 08:00:00 B 1 1
10: 2016-01-01 09:00:00 A NA NA
11: 2016-01-01 10:00:00 A NA NA
</code></pre>
<p>I usually use data.table, but non data.table solutions are also fine.</p>
<p>Thanks!</p>
<p>Lyss</p>
| 0debug
|
std::make_shared() change in C++17 : <p>In <a href="http://en.cppreference.com/w/cpp/memory/shared_ptr/make_shared" rel="noreferrer">cppref</a>, the following holds until C++17:</p>
<blockquote>
<p>code such as <code>f(std::shared_ptr<int>(new int(42)), g())</code> can cause a
memory leak if <code>g</code> gets called after <code>new int(42)</code> and throws an
exception, while <code>f(std::make_shared<int>(42), g())</code> is safe, since
two function calls are never interleaved.</p>
</blockquote>
<p>I'm wondering which change introduced in C++17 renders this no longer applicable.</p>
| 0debug
|
How can I import all class and method from python file? : <p>I want to import all classes and methods from a python file. Currently I imported by writing their name, as like,
from utils import a,b,c,d</p>
<p>But I want to import without writing name.</p>
<p>python version 4.1
Thanks</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.