problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
static void qemu_cleanup_net_client(NetClientState *nc)
{
QTAILQ_REMOVE(&net_clients, nc, next);
nc->info->cleanup(nc);
}
| 1threat |
av_cold void ff_h264dsp_init_ppc(H264DSPContext *c, const int bit_depth,
const int chroma_format_idc)
{
#if HAVE_ALTIVEC
if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC))
return;
if (bit_depth == 8) {
c->h264_idct_add = h264_idct_add_altivec;
if (chroma_format_idc == 1)
c->h264_idct_add8 = h264_idct_add8_altivec;
c->h264_idct_add16 = h264_idct_add16_altivec;
c->h264_idct_add16intra = h264_idct_add16intra_altivec;
c->h264_idct_dc_add= h264_idct_dc_add_altivec;
c->h264_idct8_dc_add = h264_idct8_dc_add_altivec;
c->h264_idct8_add = h264_idct8_add_altivec;
c->h264_idct8_add4 = h264_idct8_add4_altivec;
c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_altivec;
c->h264_h_loop_filter_luma= h264_h_loop_filter_luma_altivec;
c->weight_h264_pixels_tab[0] = weight_h264_pixels16_altivec;
c->weight_h264_pixels_tab[1] = weight_h264_pixels8_altivec;
c->biweight_h264_pixels_tab[0] = biweight_h264_pixels16_altivec;
c->biweight_h264_pixels_tab[1] = biweight_h264_pixels8_altivec;
}
#endif
}
| 1threat |
ngrx effects error handling : <p>I have a very basic question concerning @ngrx effects: How to ignore an error that happens during the execution of an effect such that it doesn't affect future effect execution?</p>
<p>My situation is as follows: I have an action (LOGIN) and an effect listening to that action. If an error happens inside this effect, I want to ignore it. When LOGIN is dispatched a second time after this error, the effect should be executed a second time.</p>
<p>My first attempt to do this was:</p>
<pre><code> @Effect()
login$ = this.actions$
.ofType('LOGIN')
.flatMap(async () => {
console.debug('LOGIN');
// throw an error
let x = [];x[0]();
})
.catch(err => {
console.error('Error at login', err);
return Observable.empty();
});
</code></pre>
<p>Dispatching LOGIN the first time throws and catches the error, as expected. However, if I dispatch LOGIN a second time afterwards, nothing happens; the effect is not executed.</p>
<p>Therefore I tried the following:</p>
<pre><code> .catch(err => {
return this.login$;
});
</code></pre>
<p>, but this results in an endless loop... Do you know how to catch the error without preventing effect execution afterwards?</p>
| 0debug |
Table View Data Source in MVVM-C : <p>where should I put UITableView Data Sources (I am using RxDataSources) when using MVVM-C architecture?</p>
| 0debug |
fill 3 listview that's in separate tabs in android tabhost : I have 3 tabs in my tabhost and each tab have one list view.
How can I fill each listview when switch each tab?
(Android activity) | 0debug |
static int usb_hub_handle_control(USBDevice *dev, int request, int value,
int index, int length, uint8_t *data)
{
USBHubState *s = (USBHubState *)dev;
int ret;
ret = usb_desc_handle_control(dev, request, value, index, length, data);
if (ret >= 0) {
return ret;
}
switch(request) {
case DeviceRequest | USB_REQ_GET_STATUS:
data[0] = (1 << USB_DEVICE_SELF_POWERED) |
(dev->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP);
data[1] = 0x00;
ret = 2;
break;
case DeviceOutRequest | USB_REQ_CLEAR_FEATURE:
if (value == USB_DEVICE_REMOTE_WAKEUP) {
dev->remote_wakeup = 0;
} else {
goto fail;
}
ret = 0;
break;
case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:
if (value == 0 && index != 0x81) {
goto fail;
}
ret = 0;
break;
case DeviceOutRequest | USB_REQ_SET_FEATURE:
if (value == USB_DEVICE_REMOTE_WAKEUP) {
dev->remote_wakeup = 1;
} else {
goto fail;
}
ret = 0;
break;
case DeviceRequest | USB_REQ_GET_CONFIGURATION:
data[0] = 1;
ret = 1;
break;
case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
ret = 0;
break;
case DeviceRequest | USB_REQ_GET_INTERFACE:
data[0] = 0;
ret = 1;
break;
case DeviceOutRequest | USB_REQ_SET_INTERFACE:
ret = 0;
break;
case GetHubStatus:
data[0] = 0;
data[1] = 0;
data[2] = 0;
data[3] = 0;
ret = 4;
break;
case GetPortStatus:
{
unsigned int n = index - 1;
USBHubPort *port;
if (n >= NUM_PORTS) {
goto fail;
}
port = &s->ports[n];
data[0] = port->wPortStatus;
data[1] = port->wPortStatus >> 8;
data[2] = port->wPortChange;
data[3] = port->wPortChange >> 8;
ret = 4;
}
break;
case SetHubFeature:
case ClearHubFeature:
if (value == 0 || value == 1) {
} else {
goto fail;
}
ret = 0;
break;
case SetPortFeature:
{
unsigned int n = index - 1;
USBHubPort *port;
USBDevice *dev;
if (n >= NUM_PORTS) {
goto fail;
}
port = &s->ports[n];
dev = port->port.dev;
switch(value) {
case PORT_SUSPEND:
port->wPortStatus |= PORT_STAT_SUSPEND;
break;
case PORT_RESET:
if (dev) {
usb_send_msg(dev, USB_MSG_RESET);
port->wPortChange |= PORT_STAT_C_RESET;
port->wPortStatus |= PORT_STAT_ENABLE;
}
break;
case PORT_POWER:
break;
default:
goto fail;
}
ret = 0;
}
break;
case ClearPortFeature:
{
unsigned int n = index - 1;
USBHubPort *port;
if (n >= NUM_PORTS) {
goto fail;
}
port = &s->ports[n];
switch(value) {
case PORT_ENABLE:
port->wPortStatus &= ~PORT_STAT_ENABLE;
break;
case PORT_C_ENABLE:
port->wPortChange &= ~PORT_STAT_C_ENABLE;
break;
case PORT_SUSPEND:
port->wPortStatus &= ~PORT_STAT_SUSPEND;
break;
case PORT_C_SUSPEND:
port->wPortChange &= ~PORT_STAT_C_SUSPEND;
break;
case PORT_C_CONNECTION:
port->wPortChange &= ~PORT_STAT_C_CONNECTION;
break;
case PORT_C_OVERCURRENT:
port->wPortChange &= ~PORT_STAT_C_OVERCURRENT;
break;
case PORT_C_RESET:
port->wPortChange &= ~PORT_STAT_C_RESET;
break;
default:
goto fail;
}
ret = 0;
}
break;
case GetHubDescriptor:
{
unsigned int n, limit, var_hub_size = 0;
memcpy(data, qemu_hub_hub_descriptor,
sizeof(qemu_hub_hub_descriptor));
data[2] = NUM_PORTS;
limit = ((NUM_PORTS + 1 + 7) / 8) + 7;
for (n = 7; n < limit; n++) {
data[n] = 0x00;
var_hub_size++;
}
limit = limit + ((NUM_PORTS + 7) / 8);
for (;n < limit; n++) {
data[n] = 0xff;
var_hub_size++;
}
ret = sizeof(qemu_hub_hub_descriptor) + var_hub_size;
data[0] = ret;
break;
}
default:
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| 1threat |
Formatting text in C : <p>I need an advice on how to handle this task.
I would like to format chars so that only a given number of characters were on one line. User input would be the number representing the max length of the line. The program would then print the char formatted in a way that words are divided by only one space and when some word doesn't fit in the line anymore, it would be printed on a new line.
Example:</p>
<pre><code>char text="Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer metus";
format(text,20);
</code></pre>
<p>Expected output:</p>
<pre><code>Lorem ipsum dolor
sit amet,
consectetuer
adipiscing elit.
Integer metus
</code></pre>
<p>What's the easiest way to do this?</p>
| 0debug |
Xcode 9.3 Playground - diagnosticd : <p>I noticed every time I launch a Playground in Xcode (version 9.3) a daemon starts in the background and uses more that 100% of my CPU!</p>
<p>I deleted Xcode's cache and its DerivedData folder but no change.</p>
<p>Does anyone know how to resolve this problem?</p>
| 0debug |
Angular 2: Two different types with this name exist : <p>In my Angular 2 app, I have following code:</p>
<pre><code>import { Observable } from 'rxjs/Rx';
import { Subscription } from '@angular-cli/ast-tools/node_modules/rxjs/Rx';
...
private broadcastDataSubject: BehaviorSubject<Event>;
...
let sub: Subscription = this.broadcastDataSubject.asObservable().subject(event).subscribe(() => this.bla());
</code></pre>
<p>Problem is in the last row, code will not complile because of:</p>
<p><strong>"Type 'Subscription' is not assignable to type 'Subscription'. Two different types with this name exist, but they are unrelated."</strong></p>
<p>I have same code in my second project and it runs without problem. </p>
| 0debug |
decimal to string convertion : What is the parameter that I should use to convert following decimal values to string.(decimalVariable.ToString("x");)
decimal values
120.5 => 120.50 (string)
110 => 110 (string)
25.356 => 25.356 (string)
| 0debug |
Systemd with multiple execStart : <p>i Would know if it's possible to create service with the same script started with different input parameters.
Such as:</p>
<pre><code>[Unit]
Description=script description
[Service]
Type=simple
ExecStart=/script.py parameters1
ExecStart=/script.py parameters2
Restart=on-failure
[Install]
WantedBy=multi-user.target
</code></pre>
<p>is it possible? then it will launched to serial-mode? or into two different process? Best regards</p>
| 0debug |
In C# can you define an alias to a value tuple with names? : <p>I know it's possible to define aliases in C# with the <em>using</em> keyword.</p>
<p>e.g.</p>
<pre><code>using ResponseKey = System.ValueTuple<System.Guid, string, string>;
</code></pre>
<p>However, is it possible to define one using the new syntax for value tuples?</p>
<pre><code>using ResponseKey = (Guid venueId, string contentId, string answer);
</code></pre>
<p>This syntax does not appear to work. Should it?</p>
| 0debug |
alert('Hello ' + user_input); | 1threat |
static void avc_wgt_16width_msa(uint8_t *data,
int32_t stride,
int32_t height,
int32_t log2_denom,
int32_t src_weight,
int32_t offset_in)
{
uint8_t cnt;
v16u8 zero = { 0 };
v16u8 src0, src1, src2, src3;
v16u8 dst0, dst1, dst2, dst3;
v8u16 src0_l, src1_l, src2_l, src3_l;
v8u16 src0_r, src1_r, src2_r, src3_r;
v8u16 temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7;
v8u16 wgt, denom, offset;
offset_in <<= (log2_denom);
if (log2_denom) {
offset_in += (1 << (log2_denom - 1));
}
wgt = (v8u16) __msa_fill_h(src_weight);
offset = (v8u16) __msa_fill_h(offset_in);
denom = (v8u16) __msa_fill_h(log2_denom);
for (cnt = height / 4; cnt--;) {
LOAD_4VECS_UB(data, stride, src0, src1, src2, src3);
ILV_B_LRLR_UH(src0, zero, src1, zero, src0_l, src0_r, src1_l, src1_r);
ILV_B_LRLR_UH(src2, zero, src3, zero, src2_l, src2_r, src3_l, src3_r);
temp0 = wgt * src0_r;
temp1 = wgt * src0_l;
temp2 = wgt * src1_r;
temp3 = wgt * src1_l;
temp4 = wgt * src2_r;
temp5 = wgt * src2_l;
temp6 = wgt * src3_r;
temp7 = wgt * src3_l;
ADDS_S_H_4VECS_UH(temp0, offset, temp1, offset,
temp2, offset, temp3, offset,
temp0, temp1, temp2, temp3);
ADDS_S_H_4VECS_UH(temp4, offset, temp5, offset,
temp6, offset, temp7, offset,
temp4, temp5, temp6, temp7);
MAXI_S_H_4VECS_UH(temp0, temp1, temp2, temp3, 0);
MAXI_S_H_4VECS_UH(temp4, temp5, temp6, temp7, 0);
SRL_H_4VECS_UH(temp0, temp1, temp2, temp3,
temp0, temp1, temp2, temp3, denom);
SRL_H_4VECS_UH(temp4, temp5, temp6, temp7,
temp4, temp5, temp6, temp7, denom);
SAT_U_H_4VECS_UH(temp0, temp1, temp2, temp3, 7);
SAT_U_H_4VECS_UH(temp4, temp5, temp6, temp7, 7);
PCKEV_B_4VECS_UB(temp1, temp3, temp5, temp7, temp0, temp2, temp4, temp6,
dst0, dst1, dst2, dst3);
STORE_4VECS_UB(data, stride, dst0, dst1, dst2, dst3);
data += 4 * stride;
}
}
| 1threat |
static void nal_send(AVFormatContext *ctx, const uint8_t *buf, int len, int last_packet_of_frame)
{
RTPMuxContext *rtp_ctx = ctx->priv_data;
int rtp_payload_size = rtp_ctx->max_payload_size - RTP_HEVC_HEADERS_SIZE;
int nal_type = (buf[0] >> 1) & 0x3F;
if (len <= rtp_ctx->max_payload_size) {
int buffered_size = rtp_ctx->buf_ptr - rtp_ctx->buf;
if (buffered_size + 2 + len > rtp_ctx->max_payload_size) {
flush_buffered(ctx, 0);
buffered_size = 0;
}
if (buffered_size + 4 + len <= rtp_ctx->max_payload_size) {
if (buffered_size == 0) {
*rtp_ctx->buf_ptr++ = 48 << 1;
*rtp_ctx->buf_ptr++ = 1;
}
AV_WB16(rtp_ctx->buf_ptr, len);
rtp_ctx->buf_ptr += 2;
memcpy(rtp_ctx->buf_ptr, buf, len);
rtp_ctx->buf_ptr += len;
rtp_ctx->buffered_nals++;
} else {
flush_buffered(ctx, 0);
ff_rtp_send_data(ctx, buf, len, last_packet_of_frame);
}
} else {
flush_buffered(ctx, 0);
rtp_ctx->buf[0] = 49 << 1;
rtp_ctx->buf[1] = 1;
rtp_ctx->buf[2] = nal_type;
rtp_ctx->buf[2] |= 1 << 7;
buf += 2;
len -= 2;
while (len > rtp_payload_size) {
memcpy(&rtp_ctx->buf[RTP_HEVC_HEADERS_SIZE], buf, rtp_payload_size);
ff_rtp_send_data(ctx, rtp_ctx->buf, rtp_ctx->max_payload_size, 0);
buf += rtp_payload_size;
len -= rtp_payload_size;
rtp_ctx->buf[2] &= ~(1 << 7);
}
rtp_ctx->buf[2] |= 1 << 6;
memcpy(&rtp_ctx->buf[RTP_HEVC_HEADERS_SIZE], buf, len);
ff_rtp_send_data(ctx, rtp_ctx->buf, len + 2, last_packet_of_frame);
}
}
| 1threat |
static int get_cox(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c)
{
uint8_t byte;
if (s->buf_end - s->buf < 5)
return AVERROR(EINVAL);
c->nreslevels = bytestream_get_byte(&s->buf) + 1;
if (c->nreslevels < s->reduction_factor)
c->nreslevels2decode = 1;
else
c->nreslevels2decode = c->nreslevels - s->reduction_factor;
c->log2_cblk_width = bytestream_get_byte(&s->buf) + 2;
c->log2_cblk_height = bytestream_get_byte(&s->buf) + 2;
c->cblk_style = bytestream_get_byte(&s->buf);
if (c->cblk_style != 0) {
av_log(s->avctx, AV_LOG_ERROR, "no extra cblk styles supported\n");
return -1;
}
c->transform = bytestream_get_byte(&s->buf);
if ((s->avctx->flags & CODEC_FLAG_BITEXACT) && (c->transform == FF_DWT97))
c->transform = FF_DWT97_INT;
if (c->csty & JPEG2000_CSTY_PREC) {
int i;
for (i = 0; i < c->nreslevels; i++) {
byte = bytestream_get_byte(&s->buf);
c->log2_prec_widths[i] = byte & 0x0F;
c->log2_prec_heights[i] = (byte >> 4) & 0x0F;
}
}
return 0;
}
| 1threat |
Jupyter notebook taking forever to iterate over a for loop : <p>I an using the following for loop to iterate over df (droping a row if condition match) :</p>
<pre><code>for index, row in df.iterrows():
if(pd.isnull(row["CR Date"])):
df.drop(index, inplace=True)
</code></pre>
<p>the df shape 240,000*30
It is working BUT It is taking more than 1.5 hours.
Is there any faster way?
I am using Anaconda JupyterLab</p>
| 0debug |
Tcl script for getting windows service is exist or not : <p>I want to check whether windows service is already installed or not by using tcl script.
note that i am using ActiveTcl.8.6.7 version.</p>
<p>Thanks in advance.</p>
| 0debug |
static void usbredir_handle_data(USBDevice *udev, USBPacket *p)
{
USBRedirDevice *dev = DO_UPCAST(USBRedirDevice, dev, udev);
uint8_t ep;
ep = p->ep->nr;
if (p->pid == USB_TOKEN_IN) {
ep |= USB_DIR_IN;
}
switch (dev->endpoint[EP2I(ep)].type) {
case USB_ENDPOINT_XFER_CONTROL:
ERROR("handle_data called for control transfer on ep %02X\n", ep);
p->status = USB_RET_NAK;
break;
case USB_ENDPOINT_XFER_ISOC:
usbredir_handle_iso_data(dev, p, ep);
break;
case USB_ENDPOINT_XFER_BULK:
if (p->state == USB_PACKET_SETUP && p->pid == USB_TOKEN_IN &&
p->ep->pipeline) {
p->status = USB_RET_ADD_TO_QUEUE;
break;
}
usbredir_handle_bulk_data(dev, p, ep);
break;
case USB_ENDPOINT_XFER_INT:
if (ep & USB_DIR_IN) {
usbredir_handle_interrupt_in_data(dev, p, ep);
} else {
usbredir_handle_interrupt_out_data(dev, p, ep);
}
break;
default:
ERROR("handle_data ep %02X has unknown type %d\n", ep,
dev->endpoint[EP2I(ep)].type);
p->status = USB_RET_NAK;
}
}
| 1threat |
static void monitor_fdset_cleanup(MonFdset *mon_fdset)
{
MonFdsetFd *mon_fdset_fd;
MonFdsetFd *mon_fdset_fd_next;
QLIST_FOREACH_SAFE(mon_fdset_fd, &mon_fdset->fds, next, mon_fdset_fd_next) {
if (mon_fdset_fd->removed) {
close(mon_fdset_fd->fd);
g_free(mon_fdset_fd->opaque);
QLIST_REMOVE(mon_fdset_fd, next);
g_free(mon_fdset_fd);
}
}
if (QLIST_EMPTY(&mon_fdset->fds) && QLIST_EMPTY(&mon_fdset->dup_fds)) {
QLIST_REMOVE(mon_fdset, next);
g_free(mon_fdset);
}
}
| 1threat |
Having trouble with "Rectangles" (am a simpleton) : I recently got back into coding and have forgotten most things (am a simpleton), tried warming up with a simple question ":Create a class Rectangle with instance variables length and width to have default value of 1 for both of them. The class should have suitable set and get methods for accessing its instance variables. The set methods should verify that length and width are assigned a value that is larger than 0.0 and is lesser than 20.0, Provide suitable public methods to calculate the rectangle’s perimeter and area. Write a suitable class "RectangleTest" to test the Rectangle class.
What i came up with:
package rectangle;
public class Rectangle
{
private double width;
private double length;
public Rectangle()
{
width=1;
length=1;
}
public Rectangle(double width, double length)
{
this.width = width;
this.length = length;
}
public void setWidth(float width)
{
this.width = width;
}
public float getWidth()
{
return (float) width;
}
public void setLength(float length)
{
this.length = length;
}
public float getLength()
{
return (float) length;
}
public double getPerimeter()
{
return 2 * (width + length);
}
public double getArea()
{
return width * length;
}
}
----------
package rectangle;
import java.util.Scanner;
public class RectangleTest extends Rectangle
{
public static void main(String[] args)
{
Scanner RectangleTest = new Scanner(System.in);
System.out.print("Length: ");
float lengthInput = RectangleTest.nextFloat();
System.out.print("Width: ");
float widthInput = RectangleTest.nextFloat();
Rectangle rectangle = new Rectangle (lengthInput, widthInput);
System.out.printf("Perimeter: %f%n",
rectangle.getPerimeter());
System.out.printf("Area: %f%n",
rectangle.getArea());
}
}
code is fine, it's just i am not sure how to implement the between 0 - 20 without breaking everything and have tried different things, is it actually pretty easy?
| 0debug |
static int64_t asf_read_pts(AVFormatContext *s, int64_t *ppos, int stream_index)
{
ASFContext *asf = s->priv_data;
AVPacket pkt1, *pkt = &pkt1;
int64_t pos= *ppos;
int64_t pts;
assert(pos % asf->packet_size == 0);
url_fseek(&s->pb, pos + s->data_offset, SEEK_SET);
do{
pos= url_ftell(&s->pb) - s->data_offset;
asf_reset_header(s);
if (av_read_frame(s, pkt) < 0)
return AV_NOPTS_VALUE;
pts= pkt->pts;
av_free_packet(pkt);
}while(pkt->stream_index != stream_index);
*ppos= pos;
return pts;
}
| 1threat |
unsigned int codec_get_tag(const CodecTag *tags, int id)
{
while (tags->id != 0) {
if (tags->id == id)
return tags->tag;
tags++;
}
return 0;
}
| 1threat |
static int shorten_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
ShortenContext *s = avctx->priv_data;
int i, input_buf_size = 0;
int ret;
if (s->max_framesize == 0) {
void *tmp_ptr;
s->max_framesize = 8192;
tmp_ptr = av_fast_realloc(s->bitstream, &s->allocated_bitstream_size,
s->max_framesize + FF_INPUT_BUFFER_PADDING_SIZE);
if (!tmp_ptr) {
av_log(avctx, AV_LOG_ERROR, "error allocating bitstream buffer\n");
return AVERROR(ENOMEM);
}
memset(tmp_ptr, 0, s->allocated_bitstream_size);
s->bitstream = tmp_ptr;
}
if (1 && s->max_framesize) {
buf_size = FFMIN(buf_size, s->max_framesize - s->bitstream_size);
input_buf_size = buf_size;
if (s->bitstream_index + s->bitstream_size + buf_size + FF_INPUT_BUFFER_PADDING_SIZE >
s->allocated_bitstream_size) {
memmove(s->bitstream, &s->bitstream[s->bitstream_index],
s->bitstream_size);
s->bitstream_index = 0;
}
if (buf)
memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], buf,
buf_size);
buf = &s->bitstream[s->bitstream_index];
buf_size += s->bitstream_size;
s->bitstream_size = buf_size;
if (buf_size < s->max_framesize && avpkt->data) {
*got_frame_ptr = 0;
return input_buf_size;
}
}
init_get_bits(&s->gb, buf, buf_size * 8);
skip_bits(&s->gb, s->bitindex);
if (!s->got_header) {
if ((ret = read_header(s)) < 0)
return ret;
*got_frame_ptr = 0;
goto finish_frame;
}
if (s->got_quit_command) {
*got_frame_ptr = 0;
return avpkt->size;
}
s->cur_chan = 0;
while (s->cur_chan < s->channels) {
unsigned cmd;
int len;
if (get_bits_left(&s->gb) < 3 + FNSIZE) {
*got_frame_ptr = 0;
break;
}
cmd = get_ur_golomb_shorten(&s->gb, FNSIZE);
if (cmd > FN_VERBATIM) {
av_log(avctx, AV_LOG_ERROR, "unknown shorten function %d\n", cmd);
*got_frame_ptr = 0;
break;
}
if (!is_audio_command[cmd]) {
switch (cmd) {
case FN_VERBATIM:
len = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE);
while (len--)
get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE);
break;
case FN_BITSHIFT:
s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE);
break;
case FN_BLOCKSIZE: {
unsigned blocksize = get_uint(s, av_log2(s->blocksize));
if (blocksize > s->blocksize) {
av_log(avctx, AV_LOG_ERROR,
"Increasing block size is not supported\n");
return AVERROR_PATCHWELCOME;
}
if (!blocksize || blocksize > MAX_BLOCKSIZE) {
av_log(avctx, AV_LOG_ERROR, "invalid or unsupported "
"block size: %d\n", blocksize);
return AVERROR(EINVAL);
}
s->blocksize = blocksize;
break;
}
case FN_QUIT:
s->got_quit_command = 1;
break;
}
if (cmd == FN_BLOCKSIZE || cmd == FN_QUIT) {
*got_frame_ptr = 0;
break;
}
} else {
int residual_size = 0;
int channel = s->cur_chan;
int32_t coffset;
if (cmd != FN_ZERO) {
residual_size = get_ur_golomb_shorten(&s->gb, ENERGYSIZE);
if (s->version == 0)
residual_size--;
}
if (s->nmean == 0)
coffset = s->offset[channel][0];
else {
int32_t sum = (s->version < 2) ? 0 : s->nmean / 2;
for (i = 0; i < s->nmean; i++)
sum += s->offset[channel][i];
coffset = sum / s->nmean;
if (s->version >= 2)
coffset = s->bitshift == 0 ? coffset : coffset >> s->bitshift - 1 >> 1;
}
if (cmd == FN_ZERO) {
for (i = 0; i < s->blocksize; i++)
s->decoded[channel][i] = 0;
} else {
if ((ret = decode_subframe_lpc(s, cmd, channel,
residual_size, coffset)) < 0)
return ret;
}
if (s->nmean > 0) {
int32_t sum = (s->version < 2) ? 0 : s->blocksize / 2;
for (i = 0; i < s->blocksize; i++)
sum += s->decoded[channel][i];
for (i = 1; i < s->nmean; i++)
s->offset[channel][i - 1] = s->offset[channel][i];
if (s->version < 2)
s->offset[channel][s->nmean - 1] = sum / s->blocksize;
else
s->offset[channel][s->nmean - 1] = (sum / s->blocksize) << s->bitshift;
}
for (i = -s->nwrap; i < 0; i++)
s->decoded[channel][i] = s->decoded[channel][i + s->blocksize];
fix_bitshift(s, s->decoded[channel]);
s->cur_chan++;
if (s->cur_chan == s->channels) {
uint8_t *samples_u8;
int16_t *samples_s16;
int chan;
frame->nb_samples = s->blocksize;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
for (chan = 0; chan < s->channels; chan++) {
samples_u8 = ((uint8_t **)frame->extended_data)[chan];
samples_s16 = ((int16_t **)frame->extended_data)[chan];
for (i = 0; i < s->blocksize; i++) {
switch (s->internal_ftype) {
case TYPE_U8:
*samples_u8++ = av_clip_uint8(s->decoded[chan][i]);
break;
case TYPE_S16HL:
case TYPE_S16LH:
*samples_s16++ = av_clip_int16(s->decoded[chan][i]);
break;
}
}
}
*got_frame_ptr = 1;
}
}
}
if (s->cur_chan < s->channels)
*got_frame_ptr = 0;
finish_frame:
s->bitindex = get_bits_count(&s->gb) - 8 * (get_bits_count(&s->gb) / 8);
i = get_bits_count(&s->gb) / 8;
if (i > buf_size) {
av_log(s->avctx, AV_LOG_ERROR, "overread: %d\n", i - buf_size);
s->bitstream_size = 0;
s->bitstream_index = 0;
return AVERROR_INVALIDDATA;
}
if (s->bitstream_size) {
s->bitstream_index += i;
s->bitstream_size -= i;
return input_buf_size;
} else
return i;
}
| 1threat |
Importing any 3d model in unreal engine 4 in-game from local disk : <p>I want to import a 3d model/mesh inside a game. Kinda like import a mesh from file explorer kinda thing.
Is there any good way to do this? Without much coding.</p>
| 0debug |
int av_opencl_create_kernel(AVOpenCLKernelEnv *env, const char *kernel_name)
{
cl_int status;
int i, ret = 0;
LOCK_OPENCL;
if (strlen(kernel_name) + 1 > AV_OPENCL_MAX_KERNEL_NAME_SIZE) {
av_log(&openclutils, AV_LOG_ERROR, "Created kernel name %s is too long\n", kernel_name);
ret = AVERROR(EINVAL);
goto end;
}
if (!env->kernel) {
if (gpu_env.kernel_count >= MAX_KERNEL_NUM) {
av_log(&openclutils, AV_LOG_ERROR,
"Could not create kernel with name '%s', maximum number of kernels %d already reached\n",
kernel_name, MAX_KERNEL_NUM);
ret = AVERROR(EINVAL);
goto end;
}
for (i = 0; i < gpu_env.program_count; i++) {
env->kernel = clCreateKernel(gpu_env.programs[i], kernel_name, &status);
if (status == CL_SUCCESS)
break;
}
if (status != CL_SUCCESS) {
av_log(&openclutils, AV_LOG_ERROR, "Could not create OpenCL kernel: %s\n", opencl_errstr(status));
ret = AVERROR_EXTERNAL;
goto end;
}
gpu_env.kernel_count++;
env->command_queue = gpu_env.command_queue;
av_strlcpy(env->kernel_name, kernel_name, sizeof(env->kernel_name));
}
end:
UNLOCK_OPENCL;
return ret;
}
| 1threat |
How to Edit a File Text in Perl : <p>I have a file now in that i want to update the value of variable.How can we do this .
<strong>File Content:</strong></p>
<pre><code><Config>
NUM1 = 8
AMV1 = 8
AMV2 = 8
DEF2 = 8
DGF = 8
</Config>
</code></pre>
<p>Now in this i want to change the value of <code>NUM1</code> how can we do this in Perl.</p>
| 0debug |
static void test_qemu_strtoul_full_max(void)
{
const char *str = g_strdup_printf("%lu", ULONG_MAX);
unsigned long res = 999;
int err;
err = qemu_strtoul(str, NULL, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, ULONG_MAX);
}
| 1threat |
Syntax: const {} = variableName, can anyone explain or point me into the right direction : <p>What does this syntax mean in JavaScript (ES6 probably):</p>
<p>const {} = variablename;</p>
<p>I'm currently trying to get a grip of React. In a lot of examples I came across that syntax. For example:</p>
<pre><code>const {girls, guys, women, men} = state;
</code></pre>
| 0debug |
static void raw_aio_writev_scrubbed(void *opaque, int ret)
{
RawScrubberBounce *b = opaque;
if (ret < 0) {
b->cb(b->opaque, ret);
} else {
b->cb(b->opaque, ret + 512);
}
qemu_iovec_destroy(&b->qiov);
qemu_free(b);
}
| 1threat |
Easy way to prevent add object with the same value to array : <p>Like in title easy way to prevent add object with the same value to array</p>
<pre><code>const array = [
{
name:'John'
},
{
name: 'Mark'
}
]
array.push({name: 'John'}) //don't add
array.push({name: 'Kevin'}) //add
console.log(array)
</code></pre>
| 0debug |
static target_ulong h_register_logical_lan(CPUPPCState *env,
sPAPREnvironment *spapr,
target_ulong opcode,
target_ulong *args)
{
target_ulong reg = args[0];
target_ulong buf_list = args[1];
target_ulong rec_queue = args[2];
target_ulong filter_list = args[3];
VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
VIOsPAPRVLANDevice *dev = (VIOsPAPRVLANDevice *)sdev;
vlan_bd_t filter_list_bd;
if (!dev) {
return H_PARAMETER;
}
if (dev->isopen) {
hcall_dprintf("H_REGISTER_LOGICAL_LAN called twice without "
"H_FREE_LOGICAL_LAN\n");
return H_RESOURCE;
}
if (check_bd(dev, VLAN_VALID_BD(buf_list, SPAPR_VIO_TCE_PAGE_SIZE),
SPAPR_VIO_TCE_PAGE_SIZE) < 0) {
hcall_dprintf("Bad buf_list 0x" TARGET_FMT_lx "\n", buf_list);
return H_PARAMETER;
}
filter_list_bd = VLAN_VALID_BD(filter_list, SPAPR_VIO_TCE_PAGE_SIZE);
if (check_bd(dev, filter_list_bd, SPAPR_VIO_TCE_PAGE_SIZE) < 0) {
hcall_dprintf("Bad filter_list 0x" TARGET_FMT_lx "\n", filter_list);
return H_PARAMETER;
}
if (!(rec_queue & VLAN_BD_VALID)
|| (check_bd(dev, rec_queue, VLAN_RQ_ALIGNMENT) < 0)) {
hcall_dprintf("Bad receive queue\n");
return H_PARAMETER;
}
dev->buf_list = buf_list;
sdev->signal_state = 0;
rec_queue &= ~VLAN_BD_TOGGLE;
stq_tce(sdev, buf_list, rec_queue);
stq_tce(sdev, buf_list + 8, filter_list_bd);
spapr_tce_dma_zero(sdev, buf_list + VLAN_RX_BDS_OFF,
SPAPR_VIO_TCE_PAGE_SIZE - VLAN_RX_BDS_OFF);
dev->add_buf_ptr = VLAN_RX_BDS_OFF - 8;
dev->use_buf_ptr = VLAN_RX_BDS_OFF - 8;
dev->rx_bufs = 0;
dev->rxq_ptr = 0;
spapr_tce_dma_zero(sdev, VLAN_BD_ADDR(rec_queue), VLAN_BD_LEN(rec_queue));
dev->isopen = 1;
return H_SUCCESS;
}
| 1threat |
The problem with the markers in Google maps : There was a problem, how to remove these buttons from the bottom?
https://imgur.com/3JXa8xe | 0debug |
for loops and arrays in python : I've been far from python for a while. when I try bellow code it gives me
> IndexEroor
n = int(input())
array = []
for i in range(n):
array[i] = i+1
| 0debug |
switch statement not changing a variable : <p>I have a switch statement that goes as follows:</p>
<pre><code> switch (event.key.keysym.sym) {
case SDLK_ESCAPE:
running = false;
break;
case SDLK_w:
y -= 10;
std::cout << "pressed" << std::endl;
std::cout << y << std::endl;
case SDLK_s:
y += 10;
}
</code></pre>
<p>when i run this program, press w and look in the console pressed is displayed and so is the value of y but however much i press w variable y will not change.</p>
<p>s however works just fine.</p>
| 0debug |
static int vfio_add_std_cap(VFIODevice *vdev, uint8_t pos)
{
PCIDevice *pdev = &vdev->pdev;
uint8_t cap_id, next, size;
int ret;
cap_id = pdev->config[pos];
next = pdev->config[pos + 1];
size = vfio_std_cap_max_size(pdev, pos);
if (next) {
ret = vfio_add_std_cap(vdev, next);
if (ret) {
return ret;
}
} else {
pdev->config[PCI_CAPABILITY_LIST] = 0;
}
switch (cap_id) {
case PCI_CAP_ID_MSI:
ret = vfio_setup_msi(vdev, pos);
break;
case PCI_CAP_ID_MSIX:
ret = vfio_setup_msix(vdev, pos);
break;
default:
ret = pci_add_capability(pdev, cap_id, pos, size);
break;
}
if (ret < 0) {
error_report("vfio: %04x:%02x:%02x.%x Error adding PCI capability "
"0x%x[0x%x]@0x%x: %d", vdev->host.domain,
vdev->host.bus, vdev->host.slot, vdev->host.function,
cap_id, size, pos, ret);
return ret;
}
return 0;
}
| 1threat |
Possible to bring the app from background to foreground? : <p>When running an XCT UI test it is possible to put the application under test in the background with:</p>
<pre><code>XCUIDevice().pressButton(XCUIDeviceButton.Home)
</code></pre>
<p>It it possible in some way to bring the app back to foreground (active state) without relaunching the application?</p>
| 0debug |
static int make_ydt24_entry(int p1, int p2, int16_t *ydt)
{
int lo, hi;
lo = ydt[p1];
hi = ydt[p2];
return (lo + (hi << 8) + (hi << 16)) << 1;
}
| 1threat |
Python Questions help. Im lost : Write a program that asks a user how many numbers they wish to process, then ask for that many numbers. Find the total and the maximum of the numbers processed. Example output:
Enter the number of values to process: 5
First value: 3
Next value: 9.2
Next value: -2.5
Next value: 0.25
Next value: 6
The total is 15.95
The maximum is 9.20
One thing im lost on is that if if have for num in (1, 3)
and num gets assigned multiples values how do I extract both those values | 0debug |
static inline int epoll_events_from_pfd(int pfd_events)
{
return (pfd_events & G_IO_IN ? EPOLLIN : 0) |
(pfd_events & G_IO_OUT ? EPOLLOUT : 0) |
(pfd_events & G_IO_HUP ? EPOLLHUP : 0) |
(pfd_events & G_IO_ERR ? EPOLLERR : 0);
}
| 1threat |
uint64_t HELPER(neon_sub_saturate_s64)(uint64_t src1, uint64_t src2)
{
uint64_t res;
res = src1 - src2;
if (((res ^ src1) & SIGNBIT64) && ((src1 ^ src2) & SIGNBIT64)) {
env->QF = 1;
res = ((int64_t)src1 >> 63) ^ ~SIGNBIT64;
}
return res;
}
| 1threat |
Displaying KML Layers on Maps at Native Android apps Best Practice : <p>I have big KML file to a native Android application, please check the following details and give an advice.</p>
<p><strong>KML file details</strong>:</p>
<ul>
<li><strong>size</strong>: 1.7 MB</li>
<li><strong>total number of kml file elements</strong>: 500 elements</li>
<li><strong>total number of polygon</strong>: 1000 polygon</li>
</ul>
<p><strong>Android app details</strong>:</p>
<ul>
<li>the above details will be viewed in Fragment</li>
<li>I used the following support library to implement this screen
compile 'com.google.maps.android:android-maps-utils:0.4+'</li>
<li>some caluctations are done on loading the screens(like distance calculations)</li>
</ul>
<p><strong>Issue</strong>:</p>
<ul>
<li>Take a lot of time to load the map and kml layer about 8 sec
create KMLLayer instance </li>
</ul>
<p>What is the best practice to implement the above details with good performance?</p>
<p>please advise.</p>
| 0debug |
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (NSConcreteData)' : Getting an error NSInvalidArgumentException', reason: 'Invalid type in JSON write . I hope this error when i post image data string in Request.Please help
let imageData : NSData!
imageData = UIImagePNGRepresentation(first.image!)!
let base64String = imageData.base64EncodedDataWithOptions(NSDataBase64EncodingOptions.Encoding64CharacterLineLength)
requestObject["pimage1"] = base64String
let jsonData = try! NSJSONSerialization.dataWithJSONObject(params, options: .PrettyPrinted)
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (NSConcreteData)' | 0debug |
MatDialog Service Unit Test Angular 6 Error : <p>I'm having modal service to open, confirm and close dialog and i am making its unit test file but i got and error on Angular and this is the code.</p>
<p><strong>modal.service.ts</strong></p>
<pre><code>@Injectable()
export class ModalService {
constructor(private dialog: MatDialog) { }
public open<modalType>(modalComponent: ComponentType<modalType>): Observable<any> {
let dialogRef: MatDialogRef<any>;
dialogRef = this.dialog.open(modalComponent, {
maxWidth: '100vw'
});
console.log(dialogRef)
dialogRef.componentInstance.body = body;
return dialogRef.afterClosed().pipe(map(result => console.log('test'); );
}
}
</code></pre>
<p>modal.service.spec.ts</p>
<pre><code>export class TestComponent {}
describe('ModalService', () => {
let modalService: ModalService;
const mockDialogRef = {
open: jasmine.createSpy('open')
};
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [ MatDialogModule ],
providers: [
ModalService,
MatDialogRef,
{ provide: MatDialog, useClass: MatDialogStub }
]
}).compileComponents();
modalService = TestBed.get(ModalService);
}));
it('open modal', () => {
modalService.open(DummyComponent, '300px');
expect(modalService.open).toHaveBeenCalled();
});
});
</code></pre>
<p>So with that code the error is</p>
<pre><code>TypeError: Cannot read property 'componentInstance' of undefined
</code></pre>
<p>Can you help me how to make this successful? Help is much appreciated.</p>
| 0debug |
restore_fpu_state(CPUSPARCState *env, qemu_siginfo_fpu_t *fpu)
{
int err;
#if 0
#ifdef CONFIG_SMP
if (current->flags & PF_USEDFPU)
regs->psr &= ~PSR_EF;
#else
if (current == last_task_used_math) {
last_task_used_math = 0;
regs->psr &= ~PSR_EF;
}
#endif
current->used_math = 1;
current->flags &= ~PF_USEDFPU;
#endif
#if 0
if (verify_area (VERIFY_READ, fpu, sizeof(*fpu)))
return -EFAULT;
#endif
#if 0
err = __copy_from_user(&env->fpr[0], &fpu->si_float_regs[0],
(sizeof(unsigned long) * 32));
#endif
err |= __get_user(env->fsr, &fpu->si_fsr);
#if 0
err |= __get_user(current->thread.fpqdepth, &fpu->si_fpqdepth);
if (current->thread.fpqdepth != 0)
err |= __copy_from_user(¤t->thread.fpqueue[0],
&fpu->si_fpqueue[0],
((sizeof(unsigned long) +
(sizeof(unsigned long *)))*16));
#endif
return err;
}
| 1threat |
void OPPROTO op_idivw_AX_T0(void)
{
int num, den, q, r;
num = (EAX & 0xffff) | ((EDX & 0xffff) << 16);
den = (int16_t)T0;
if (den == 0) {
raise_exception(EXCP00_DIVZ);
}
q = (num / den) & 0xffff;
r = (num % den) & 0xffff;
EAX = (EAX & ~0xffff) | q;
EDX = (EDX & ~0xffff) | r;
}
| 1threat |
Irregular bootstrap3 grid, one column out of container : <p>I'm seeing some crazy layouts sometimes. One of them is layout where we have boostrap container that has max width, let's say 1120px.</p>
<p>One of columns has 50% width of container, and the second has 50% width, not container but browser. </p>
<p>I've attached 2 screens to clarify my question - and the question is: does anybody has claver solution, that is responsive and will not break things during resisizing ?
So, 2 columns will not collapse ?</p>
<p>I will not provide html / css code, as i have no idea, how to code this right and without javascript.</p>
<p>If any of You have any ideas, i'm saying "thanks for a tip :)"</p>
<p><a href="https://i.stack.imgur.com/HCQmH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HCQmH.png" alt="enter image description here"></a></p>
<p><a href="https://i.stack.imgur.com/V20Zb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V20Zb.png" alt="enter image description here"></a></p>
| 0debug |
Why output other date? : <p>i have this code </p>
<pre><code>public class HelloWorld{
public static void main(String []args){
try{
java.util.Date mDate;
java.text.SimpleDateFormat readFormat = new java.text.SimpleDateFormat("yyyy-mm-dd");
mDate = readFormat.parse("2017-02-05");
System.out.println("date: " + mDate.toString());
} catch (java.text.ParseException e1) {
e1.printStackTrace();
}
}
</code></pre>
<p>}</p>
<p>i expected output like Feb 05 00:02:00 UTC 2017 </p>
<p>but im getting output Jan 05 00:02:00 UTC 2017 why? what's wrong in my code?</p>
<p><a href="https://i.stack.imgur.com/CegcW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CegcW.png" alt="enter image description here"></a></p>
| 0debug |
How to design a good JWT authentication filter : <p>I am new to JWT. There isn't much information available in the web, since I came here as a last resort. I already developed a spring boot application using spring security using spring session. Now instead of spring session we are moving to JWT. I found few links and now I can able to authenticate a user and generate token. Now the difficult part is, I want to create a filter which will be authenticate every request to the server,</p>
<ol>
<li>How will the filter validate the token? (Just validating the signature is enough?)</li>
<li>If someone else stolen the token and make rest call, how will I verify that.</li>
<li>How will I by-pass the login request in the filter? Since it doesn't have authorization header.</li>
</ol>
| 0debug |
how to write test case using NUnit which has a dependency of intefaces? : public List<CustomerViewModel> GetResellerCustomersWithProperties(string shortCode)
{
var businessManager =
DependencyContainer.GetInstance<ICortexBusinessManager>();
return businessManager.GetResellerCustomersWithProperties(shortCode);
}
How do we write Test case using Nunit which has a dependency from interfaces. | 0debug |
`createDraweerNavigation()` has been moved to `react-navigation-drawer` : [createDrawerNavigation() has been moved to react-navigation-drawer. See https://reactnavigation.org/docs/4.x/drawer-navigator.html for more details][1]
[1]: https://i.stack.imgur.com/yoadY.jpg | 0debug |
static inline void RENAME(rgb32to16)(const uint8_t *src, uint8_t *dst, unsigned src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#ifdef HAVE_MMX
mm_end = end - 15;
#if 1
asm volatile(
"movq %3, %%mm5 \n\t"
"movq %4, %%mm6 \n\t"
"movq %5, %%mm7 \n\t"
".balign 16 \n\t"
"1: \n\t"
PREFETCH" 32(%1) \n\t"
"movd (%1), %%mm0 \n\t"
"movd 4(%1), %%mm3 \n\t"
"punpckldq 8(%1), %%mm0 \n\t"
"punpckldq 12(%1), %%mm3 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm3, %%mm4 \n\t"
"pand %%mm6, %%mm0 \n\t"
"pand %%mm6, %%mm3 \n\t"
"pmaddwd %%mm7, %%mm0 \n\t"
"pmaddwd %%mm7, %%mm3 \n\t"
"pand %%mm5, %%mm1 \n\t"
"pand %%mm5, %%mm4 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm4, %%mm3 \n\t"
"psrld $5, %%mm0 \n\t"
"pslld $11, %%mm3 \n\t"
"por %%mm3, %%mm0 \n\t"
MOVNTQ" %%mm0, (%0) \n\t"
"add $16, %1 \n\t"
"add $8, %0 \n\t"
"cmp %2, %1 \n\t"
" jb 1b \n\t"
: "+r" (d), "+r"(s)
: "r" (mm_end), "m" (mask3216g), "m" (mask3216br), "m" (mul3216)
);
#else
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_16mask),"m"(green_16mask));
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 4%1, %%mm3\n\t"
"punpckldq 8%1, %%mm0\n\t"
"punpckldq 12%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psrlq $3, %%mm0\n\t"
"psrlq $3, %%mm3\n\t"
"pand %2, %%mm0\n\t"
"pand %2, %%mm3\n\t"
"psrlq $5, %%mm1\n\t"
"psrlq $5, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $8, %%mm2\n\t"
"psrlq $8, %%mm5\n\t"
"pand %%mm7, %%mm2\n\t"
"pand %%mm7, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*s),"m"(blue_16mask):"memory");
d += 4;
s += 16;
}
#endif
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
register int rgb = *(uint32_t*)s; s += 4;
*d++ = ((rgb&0xFF)>>3) + ((rgb&0xFC00)>>5) + ((rgb&0xF80000)>>8);
}
}
| 1threat |
static int cook_decode_init(AVCodecContext *avctx)
{
COOKextradata *e = (COOKextradata *)avctx->extradata;
COOKContext *q = avctx->priv_data;
if (avctx->extradata_size <= 0) {
av_log(avctx,AV_LOG_ERROR,"Necessary extradata missing!\n");
return -1;
} else {
av_log(avctx,AV_LOG_DEBUG,"codecdata_length=%d\n",avctx->extradata_size);
if (avctx->extradata_size >= 8){
e->cookversion = be2me_32(e->cookversion);
e->samples_per_frame = be2me_16(e->samples_per_frame);
e->subbands = be2me_16(e->subbands);
}
if (avctx->extradata_size >= 16){
e->js_subband_start = be2me_16(e->js_subband_start);
e->js_vlc_bits = be2me_16(e->js_vlc_bits);
}
}
q->sample_rate = avctx->sample_rate;
q->nb_channels = avctx->channels;
q->bit_rate = avctx->bit_rate;
q->random_state = 1;
q->samples_per_channel = e->samples_per_frame / q->nb_channels;
q->samples_per_frame = e->samples_per_frame;
q->subbands = e->subbands;
q->bits_per_subpacket = avctx->block_align * 8;
q->js_subband_start = 0;
q->log2_numvector_size = 5;
q->total_subbands = q->subbands;
av_log(NULL,AV_LOG_DEBUG,"e->cookversion=%x\n",e->cookversion);
q->joint_stereo = 0;
switch (e->cookversion) {
case MONO:
if (q->nb_channels != 1) {
av_log(avctx,AV_LOG_ERROR,"Container channels != 1, report sample!\n");
return -1;
}
av_log(avctx,AV_LOG_DEBUG,"MONO\n");
break;
case STEREO:
if (q->nb_channels != 1) {
q->bits_per_subpacket = q->bits_per_subpacket/2;
}
av_log(avctx,AV_LOG_DEBUG,"STEREO\n");
break;
case JOINT_STEREO:
if (q->nb_channels != 2) {
av_log(avctx,AV_LOG_ERROR,"Container channels != 2, report sample!\n");
return -1;
}
av_log(avctx,AV_LOG_DEBUG,"JOINT_STEREO\n");
if (avctx->extradata_size >= 16){
q->total_subbands = q->subbands + e->js_subband_start;
q->js_subband_start = e->js_subband_start;
q->joint_stereo = 1;
q->js_vlc_bits = e->js_vlc_bits;
}
if (q->samples_per_channel > 256) {
q->log2_numvector_size = 6;
}
if (q->samples_per_channel > 512) {
q->log2_numvector_size = 7;
}
break;
case MC_COOK:
av_log(avctx,AV_LOG_ERROR,"MC_COOK not supported!\n");
return -1;
break;
default:
av_log(avctx,AV_LOG_ERROR,"Unknown Cook version, report sample!\n");
return -1;
break;
}
q->mlt_size = q->samples_per_channel;
q->numvector_size = (1 << q->log2_numvector_size);
init_rootpow2table(q);
init_pow2table(q);
init_gain_table(q);
if (init_cook_vlc_tables(q) != 0)
return -1;
if(avctx->block_align >= UINT_MAX/2)
return -1;
if (q->nb_channels==2 && q->joint_stereo==0) {
q->decoded_bytes_buffer =
av_mallocz(avctx->block_align/2
+ DECODE_BYTES_PAD2(avctx->block_align/2)
+ FF_INPUT_BUFFER_PADDING_SIZE);
} else {
q->decoded_bytes_buffer =
av_mallocz(avctx->block_align
+ DECODE_BYTES_PAD1(avctx->block_align)
+ FF_INPUT_BUFFER_PADDING_SIZE);
}
if (q->decoded_bytes_buffer == NULL)
return -1;
q->gain_ptr1[0] = &q->gain_1;
q->gain_ptr1[1] = &q->gain_2;
q->gain_ptr2[0] = &q->gain_3;
q->gain_ptr2[1] = &q->gain_4;
if ( init_cook_mlt(q) == 0 )
return -1;
if (q->total_subbands > 53) {
av_log(avctx,AV_LOG_ERROR,"total_subbands > 53, report sample!\n");
return -1;
}
if (q->subbands > 50) {
av_log(avctx,AV_LOG_ERROR,"subbands > 50, report sample!\n");
return -1;
}
if ((q->samples_per_channel == 256) || (q->samples_per_channel == 512) || (q->samples_per_channel == 1024)) {
} else {
av_log(avctx,AV_LOG_ERROR,"unknown amount of samples_per_channel = %d, report sample!\n",q->samples_per_channel);
return -1;
}
#ifdef COOKDEBUG
dump_cook_context(q,e);
#endif
return 0;
}
| 1threat |
Python pathlib make directories if they don’t exist : <p>If I wanted to specify a path to save files to and make directories that don’t exist in that path, is it possibly to do this using the pathlib library in one line of code? </p>
| 0debug |
Can't make git stop tracking package-lock.json : <p>With npm v5 here is now <code>package-lock.json</code> file being created after <code>npm install</code></p>
<p>It is recommended to commit this file, but I have issue that this file is different for some reason between my dev machine and my server. Even if I push that file to repo, after <code>npm install</code> on server, file changes.</p>
<p>So now I'm attempting to make git untrack this file. After following numerous answers from other questions, I seem to have almost managed to do so, it's not tracked on dev machine, doesn't appear in the repo itself, but after I pull code to server and make <code>npm install</code>, it appears in <code>modified</code> files.</p>
<p>File is in <code>.gitignore</code>, but server git for some reason ignores it.</p>
<pre>git check-ignore -v -n package-lock.json
:: package-lock.json</pre>
<pre>git check-ignore -v -n --no-index package-lock.json
.gitignore:10:package-lock.json package-lock.json </pre>
<p><em>Possibly relevant info:</em></p>
<p>Dev machine: Windows 10.
Server: Ubuntu 14.04.
I'm pulling code to server using tags.</p>
| 0debug |
Which typeface in Intellij IDEA for MAC OS X : I have Windows but I want this typeface.
[PIC][1]
[1]: http://i.stack.imgur.com/FPEec.png | 0debug |
How to get connectionString from EF Core 2.0 DbContext : <p>In EF6 works this code:</p>
<pre><code> public string GetConnectionString(DbContext ctx)
{
ObjectContext _objectContext = ((IObjectContextAdapter)ctx).ObjectContext;
if (_objectContext?.Connection != null)
{
EntityConnection entityConnection = _objectContext.Connection as EntityConnection;
return entityConnection?.StoreConnection?.ConnectionString;
}
return null;
}
</code></pre>
<p>How to do it in EF Core 2.0 ?</p>
| 0debug |
static int ehci_process_itd(EHCIState *ehci,
EHCIitd *itd)
{
USBDevice *dev;
USBEndpoint *ep;
int ret;
uint32_t i, len, pid, dir, devaddr, endp;
uint32_t pg, off, ptr1, ptr2, max, mult;
dir =(itd->bufptr[1] & ITD_BUFPTR_DIRECTION);
devaddr = get_field(itd->bufptr[0], ITD_BUFPTR_DEVADDR);
endp = get_field(itd->bufptr[0], ITD_BUFPTR_EP);
max = get_field(itd->bufptr[1], ITD_BUFPTR_MAXPKT);
mult = get_field(itd->bufptr[2], ITD_BUFPTR_MULT);
for(i = 0; i < 8; i++) {
if (itd->transact[i] & ITD_XACT_ACTIVE) {
pg = get_field(itd->transact[i], ITD_XACT_PGSEL);
off = itd->transact[i] & ITD_XACT_OFFSET_MASK;
ptr1 = (itd->bufptr[pg] & ITD_BUFPTR_MASK);
ptr2 = (itd->bufptr[pg+1] & ITD_BUFPTR_MASK);
len = get_field(itd->transact[i], ITD_XACT_LENGTH);
if (len > max * mult) {
len = max * mult;
}
if (len > BUFF_SIZE) {
return USB_RET_PROCERR;
}
pci_dma_sglist_init(&ehci->isgl, &ehci->dev, 2);
if (off + len > 4096) {
uint32_t len2 = off + len - 4096;
uint32_t len1 = len - len2;
qemu_sglist_add(&ehci->isgl, ptr1 + off, len1);
qemu_sglist_add(&ehci->isgl, ptr2, len2);
} else {
qemu_sglist_add(&ehci->isgl, ptr1 + off, len);
}
pid = dir ? USB_TOKEN_IN : USB_TOKEN_OUT;
dev = ehci_find_device(ehci, devaddr);
ep = usb_ep_get(dev, pid, endp);
usb_packet_setup(&ehci->ipacket, pid, ep);
usb_packet_map(&ehci->ipacket, &ehci->isgl);
ret = usb_handle_packet(dev, &ehci->ipacket);
usb_packet_unmap(&ehci->ipacket);
qemu_sglist_destroy(&ehci->isgl);
#if 0
if (ret == USB_RET_NAK) {
if (ehci->isoch_pause > 0) {
DPRINTF("ISOCH: received a NAK but paused so returning\n");
ehci->isoch_pause--;
return 0;
} else if (ehci->isoch_pause == -1) {
DPRINTF("ISOCH: recv NAK & isoch pause inactive, setting\n");
ehci->isoch_pause = 50;
return 0;
} else {
DPRINTF("ISOCH: isoch pause timeout! return 0\n");
ret = 0;
}
} else {
DPRINTF("ISOCH: received ACK, clearing pause\n");
ehci->isoch_pause = -1;
}
#else
if (ret == USB_RET_NAK) {
ret = 0;
}
#endif
if (ret >= 0) {
if (!dir) {
set_field(&itd->transact[i], len - ret, ITD_XACT_LENGTH);
} else {
set_field(&itd->transact[i], ret, ITD_XACT_LENGTH);
}
if (itd->transact[i] & ITD_XACT_IOC) {
ehci_record_interrupt(ehci, USBSTS_INT);
}
}
itd->transact[i] &= ~ITD_XACT_ACTIVE;
}
}
return 0;
}
| 1threat |
static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, int16_t bS[7], int bsi, int qp ) {
int index_a = qp + h->slice_alpha_c0_offset;
int alpha = alpha_table[index_a];
int beta = beta_table[qp + h->slice_beta_offset];
if (alpha ==0 || beta == 0) return;
if( bS[0] < 4 ) {
int8_t tc[4];
tc[0] = tc0_table[index_a][bS[0*bsi]];
tc[1] = tc0_table[index_a][bS[1*bsi]];
tc[2] = tc0_table[index_a][bS[2*bsi]];
tc[3] = tc0_table[index_a][bS[3*bsi]];
h->h264dsp.h264_h_loop_filter_luma_mbaff(pix, stride, alpha, beta, tc);
} else {
h->h264dsp.h264_h_loop_filter_luma_mbaff_intra(pix, stride, alpha, beta);
}
}
| 1threat |
How to get all the names from all the tags from form with Bottle python as dict? : Coudl you help me with the following question.
How to get all the names from all the tags form with the library Bottle on python as a dict ?.
Because actually the request.forms only provides me the last set of "names" from the HTML tags.
Thanks. | 0debug |
Why my recursion doesn't work in os.listdir() : [This is my code. And it seems like it didn't go into the recursion function][1]
[1]: https://i.stack.imgur.com/qp33h.png | 0debug |
R : function lapply error : subscript out of bounds : I have to make a 4*4 Kohonen map for a project.
However, I get the error
> Error in win_index[1, ] : subscript out of bounds
> In addition: There were 16 warnings (use warnings() to see them)
After testing my code, I guess it's the lapply function (line 77) that doesn't
is not executed correctly because the matrix thus created contains only NA.
And so since this matrix is used later on, the result is not correct because
NA is present throughout the program.
######################################
## Initialize random matrix phi/psi ##
######################################
##Pour mac
setwd("/Users/amandinelecerfdefer/Desktop/Kohonen_MAP")
data_phipsi<-read.csv("/Users/amandinelecerfdefer/Desktop/Kohonen_MAP/pbA.txt.new.2.rep30.phipsi",h=F)
colnames(data_phipsi)<-c("phi1","psi2","phy2","psi3","phy3","psi4","phy4","psi5")
random_list<-list()
borne<-16
for(n in 1:borne){
random_list[[n]]<-floor(runif(8,min=-180,max=180))
}
# ##############Print random matrix#####
# for(n in 1:16){
# print(random_list[[n]])
# }
#creation of a matrix 4*4 representing the Kohonen map containing the vectors of the angles phi/psi
Kohonen_matrix<-matrix(random_list,ncol=sqrt(borne),nrow=sqrt(borne))
rownames(Kohonen_matrix)<-c('1','2','3','4')
colnames(Kohonen_matrix)<-c('1','2','3','4')
#############################################
##Function for distance calculation (RMSDA)##
#############################################
RMSDA<-function(data_phipsi,Kohonen_matrix)
{
difference<-data_phipsi-Kohonen_matrix
for(j in 1:length(difference)){
if (difference[j]< -180) {difference[j]=difference[j]+360}
if (difference[j]> +180) {difference[j]=difference[j]-360}
}
distance=mean(sqrt(difference^2))
return(distance)
}
#######################
##LEARNING FUNCTION ##
#######################
learning<-function(initial_rate,iteration,data_phipsi){
return(initial_rate/(1+(iteration/nrow(data_phipsi))))
}
##############################
## Program for Kohonen MAp ###
##############################
initial_rate=0.75 # Decrease with training time
initial_radius=2 # Decrease with training time
iteration=3
for(step in 1:iteration)
{
data_phipsi<-data_phipsi[sample(nrow(data_phipsi)),] # Sample vectors of training (samples of lines of the dataframe)
print(step) #Visualize where we are in loops
for(k_row in 1:nrow(data_phipsi))
{
#Update learn_rate and radius at each row of each iteration
learn_rate<-learning(initial_rate,((step-1)*nrow(data_phipsi))+k_row,data_phipsi)
learn_radius<-learning(initial_rate,((step-1)*nrow(data_phipsi))+k_row,data_phipsi)
#Find distance between each vectors of angles of Kohonen Map and the training vector
phipsi_RMSDA<-lapply(random_list, RMSDA, data_phipsi=data_phipsi[k_row,])
#Unlist and create a matrix of distances
vector_RMSDA<-unlist(phipsi_RMSDA)
matrix_RMSDA<-matrix(vector_RMSDA,sqrt(borne),sqrt(borne))
#Take the index of the winning neuron, it's the neuron that are more similar than the training vector
win_index<-which(matrix_RMSDA==min(matrix_RMSDA), arr.ind=TRUE)
current_index<-list(c(1,1),c(2,1),c(3,1), c(4,1), c(1,2),c(2,2),c(3,2), c(4,2),c(1,3),c(2,3),c(3,3), c(4,3), c(1,4),c(2,4),c(3,4), c(4,4), c(1,4),c(2,4),c(3,4), c(4,4))
#Update of angles of Kohonen Map vectors with the equation (be careful at number of parenthesis)
for (mlist in 1:borne)
{
distance<-as.numeric(dist(rbind(win_index[1,], current_index[[mlist]])))
random_list[[mlist]]<-(random_list[[mlist]]+ ( prot_phipsi[i_row,]-random_list[[mlist]])* (learn_rate*( exp (- ((distance)^2/(2*((learn_radius)^2)) )) ) ))
}
Kohonen_matrix<-matrix(random_list,sqrt(borne),sqrt(borne))
}
}
How is it possible to fix this lapply error?
Thank you. Thank you.
| 0debug |
How to create custom regex pattern in java script : <p>I have text box that can accept only numbers (floated number too (1.5 or 2.5 like this) with percentage symbol at end of the number but this % symbol not mandatory it an optional. I want do this using regular expression in javascript.</p>
| 0debug |
How to using math jax? : I've been read the docs and I still don't get how to apply it from TeX
so basically i wanted to convert this string
` <p><span class='math-tex'>\\( x>0,y>0 \\)</span></p>`
`<p><span class='math-tex'>( (\\frac{2}{7},\\frac{2}{18}) )</span></p>`
they are tex version right ? using `\\( \\)`
from my API and I still have no idea how to convert it
````
<script>
MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
}
};
</script>
<script type='text/javascript' async
src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML'>
</script>
<p>
<span class='math-tex'>( (\\frac{2}{7},\\frac{2}{18}) )</span>
</p>
```` | 0debug |
static void intel_hda_mmio_writew(void *opaque, target_phys_addr_t addr, uint32_t val)
{
IntelHDAState *d = opaque;
const IntelHDAReg *reg = intel_hda_reg_find(d, addr);
intel_hda_reg_write(d, reg, val, 0xffff);
}
| 1threat |
recursion with or without return statement : <p>this is the problem I solved for recursion<br/></p>
<blockquote>
<p>phone_book return <br/>
[119, 97674223, 1195524421] false <br/>
[123,456,789] true <br/>
[12,123,1235,567,88] false</p>
</blockquote>
<p>when it have the prefix of the any number it will return false <br/>
anyway here is my solution <br/></p>
<pre><code>def solution(phone_book):
answer = True
arr = []
print(phone_book,len(phone_book))
if len(phone_book) <=1: return True
phone_book.sort(key = lambda s: len(str(s)))
length = len(str(phone_book[0]))
for st in phone_book[1:]:
if phone_book[0] == st[:length]: return False
return solution(phone_book[1:])
</code></pre>
<p>but for last recursion part <br/>
if I remove the return it return the None value <br/>
I want to know why it return the None value <br/></p>
<blockquote>
<pre><code> solution(phone_book[1:]) ---> this will return None value without return statemetn
</code></pre>
</blockquote>
| 0debug |
Clone text from p to an input value without update : I can not find the way to clone the displayed inside a p into an input value.
the text inside a p looks like ".30, .31, .6, .38" and it is updated without recharging, so i need is clone in each update.
any idea?
thx!!!
Copy this:
<p id="filter-display">.30, .31, .6, .38</p>
into this:
<input type="hidden" name="tags" value=".30, .31, .6, .38">
| 0debug |
MySQL Workbench 6.3 (Mac) hangs on simple queries : <p>I am using MySQL Workbench 6.3.7 build 1199 CE (64 bits) on a Mac with OS X Yosemite 10.10.5. I am connecting to an Amazon RDS MySQL instance.</p>
<p>When I enter a simple query such as</p>
<pre><code>select * from `devices`;
</code></pre>
<p>and click the lightning-bolt-with-cursor icon, the query starts, indicated by the spinner activating next to the "SQL File 4" tab in the following screenshot. However, the query doesn't complete and it just hangs. The white-hand-in-red-stop-sign icon is disabled.</p>
<p><a href="https://i.stack.imgur.com/rtr7a.png"><img src="https://i.stack.imgur.com/rtr7a.png" alt="screenshot of MySQL Workbench in hung state"></a></p>
<p>I can only force quit MySQL Workbench from this point on. If I try to do a regular quit, nothing happens.</p>
<p>How can I consistently run a simple query on my database? Sometimes it works (maybe 10% of the time), but it mostly just hangs.</p>
| 0debug |
LocalDate.plus Incorrect Answer : <p>Java's LocalDate API seems to be giving the incorrect answer when calling <code>plus(...)</code> with a long <code>Period</code>, where I'm getting an off by one error. Am I doing something wrong here?</p>
<pre class="lang-java prettyprint-override"><code>import java.time.LocalDate;
import java.time.Month;
import java.time.Period;
import java.time.temporal.ChronoUnit;
public class Main
{
public static void main(String[] args)
{
// Long Period
LocalDate birthA = LocalDate.of(1965, Month.SEPTEMBER, 27);
LocalDate eventA = LocalDate.of(1992, Month.MAY, 9);
LocalDate halfA = eventA.plus(Period.between(birthA, eventA));
System.out.println(halfA); // 2018-12-21 ????
System.out.println(ChronoUnit.DAYS.between(birthA, eventA)); // 9721
System.out.println(ChronoUnit.DAYS.between(eventA, halfA)); // 9722 ????
// Short Period
LocalDate birthB = LocalDate.of(2012, Month.SEPTEMBER, 10);
LocalDate eventB = LocalDate.of(2012, Month.SEPTEMBER, 12);
LocalDate halfB = eventB.plus(Period.between(birthB, eventB));
System.out.println(halfB); // 2018-09-14
System.out.println(ChronoUnit.DAYS.between(birthB, eventB)); // 2
System.out.println(ChronoUnit.DAYS.between(eventB, halfB)); // 2
}
}
</code></pre>
| 0debug |
Delphi type mismatch in expresion when try to filter dbgrid : Am geting this error when i try to filter `DBGrid` by date with `DateTimePicker` component
> Type mismatch in expresion
**Code**
procedure TGrupeForm.DateCreatedFilterChange(Sender: TObject);
begin
if CreatedEditPicker.Date <> Date then
begin
ClientDataSet1.Filter := 'Created LIKE '+QuotedStr('%'+DateToStr(CreatedEditPicker.Date)+'%');
ClientDataSet1.Filtered := True;
end
else
ClientDataSet1.Filtered := False;
end;
What i do wrong ? | 0debug |
Specifying array size with constructor (Java) : I found some answers on this but I probably didn't understand it correctly because it didn't work for me
Employee is an object defined in another class
public class Firm {
Employee employees[];
public Firm (int rosterSize){
this.employees = new employees[rosterSize];
}
}
I'm an absolute newbie, keep that in mind, please. | 0debug |
How do I use roxygen to document a R package that includes a function with the same name? : <p>I'm learning to use roxygen. I see that the <a href="https://cran.r-project.org/web/packages/roxygen2/vignettes/rd.html#documenting-packages" rel="noreferrer">rd vignette</a> advocates using "_PACKAGE" to indicate that I'm creating package documentation, and says "This also works if there’s already a function called pkgname()."</p>
<p>I've also seen the <a href="http://r-pkgs.had.co.nz/man.html#man-packages" rel="noreferrer">R packages book</a> approach of using</p>
<pre><code>NULL
</code></pre>
<p>with @docType and @name specified, but when I attempt to make a toy example with either approach, it doesn't work as I expect.</p>
<p>As a toy example, I'd like to make a "hello" package that includes a "hello()" function. </p>
<p>I expect to get documentation about my hello <strong>package</strong> with</p>
<pre><code>?hello
</code></pre>
<p>or perhaps something like</p>
<pre><code>package?hello
</code></pre>
<p>and I expect to get documentation about the included hello <strong>function</strong> with</p>
<pre><code>?hello()
</code></pre>
<p>Where am I going wrong? - implementation with roxygen, the way I'm attempting to query the documentation, incorrect expectations, or something else? </p>
<p>I've already looked at questions about <a href="https://stackoverflow.com/questions/34439970/inline-package-overview-documentation-using-roxygen">package documentation</a> and <a href="https://stackoverflow.com/questions/13339021/devtools-roxygen-package-creation-and-rd-documentation/13348872#13348872">function documentation</a>, but things remain unclear to me.</p>
<p>Here's some details about my toy example:</p>
<p>hello/DESCRIPTION file:</p>
<pre><code>Package: hello
Type: Package
Title: A mostly empty package
Version: 0.1
Date: 2016-06-21
Authors@R: person("Some", "Person", email = "fake@madeup.org", role = c("aut", "cre"))
Description: More about what it does (maybe more than one line)
License: MIT
LazyData: TRUE
RoxygenNote: 5.0.1.9000
</code></pre>
<p>hello/R/hello.R</p>
<pre><code>#' hello
#'
#' This is a mostly empty package to learn roxygen documentation.
#'
#' Hello allows me to learn how to write documentation in comment blocks
#' co-located with code.
#' @docType package
#' @name hello
"_PACKAGE"
#' hello
#'
#' This function returns "Hello, world!".
#' @export
#' @examples
#' hello()
hello <- function() {
print("Hello, world!")
}
</code></pre>
<p>With this, after I run <code>document()</code>, hello/man/hello.Rd is generated. It contains a combination of the descriptions I've written for the hello package and the hello() function. <code>?hello</code> and <code>?hello()</code> both return that .Rd file.</p>
<p>Here's what the .Rd looks like:</p>
<pre><code>% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hello.R
\docType{package}
\name{hello}
\alias{hello}
\alias{hello-package}
\title{hello}
\usage{
hello()
}
\description{
This is a mostly empty package to learn roxygen documentation.
This function returns "Hello, world!".
}
\details{
Hello allows me to learn how to write documentation in comment blocks
co-located with code.
}
\examples{
hello()
}
</code></pre>
| 0debug |
static int scsi_disk_emulate_command(SCSIDiskReq *r, uint8_t *outbuf)
{
SCSIRequest *req = &r->req;
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev);
uint64_t nb_sectors;
int buflen = 0;
int ret;
switch (req->cmd.buf[0]) {
case TEST_UNIT_READY:
if (!bdrv_is_inserted(s->bs))
goto not_ready;
break;
case REQUEST_SENSE:
if (req->cmd.xfer < 4)
goto illegal_request;
memset(outbuf, 0, 4);
buflen = 4;
if (s->sense.key == NOT_READY && req->cmd.xfer >= 18) {
memset(outbuf, 0, 18);
buflen = 18;
outbuf[7] = 10;
outbuf[12] = 0x3a;
outbuf[13] = 0;
}
outbuf[0] = 0xf0;
outbuf[1] = 0;
outbuf[2] = s->sense.key;
scsi_disk_clear_sense(s);
break;
case INQUIRY:
buflen = scsi_disk_emulate_inquiry(req, outbuf);
if (buflen < 0)
goto illegal_request;
break;
case MODE_SENSE:
case MODE_SENSE_10:
buflen = scsi_disk_emulate_mode_sense(req, outbuf);
if (buflen < 0)
goto illegal_request;
break;
case READ_TOC:
buflen = scsi_disk_emulate_read_toc(req, outbuf);
if (buflen < 0)
goto illegal_request;
break;
case RESERVE:
if (req->cmd.buf[1] & 1)
goto illegal_request;
break;
case RESERVE_10:
if (req->cmd.buf[1] & 3)
goto illegal_request;
break;
case RELEASE:
if (req->cmd.buf[1] & 1)
goto illegal_request;
break;
case RELEASE_10:
if (req->cmd.buf[1] & 3)
goto illegal_request;
break;
case START_STOP:
if (s->drive_kind == SCSI_CD && (req->cmd.buf[4] & 2)) {
bdrv_eject(s->bs, !(req->cmd.buf[4] & 1));
}
break;
case ALLOW_MEDIUM_REMOVAL:
bdrv_set_locked(s->bs, req->cmd.buf[4] & 1);
break;
case READ_CAPACITY:
memset(outbuf, 0, 8);
bdrv_get_geometry(s->bs, &nb_sectors);
if (!nb_sectors)
goto not_ready;
nb_sectors /= s->cluster_size;
nb_sectors--;
s->max_lba = nb_sectors;
if (nb_sectors > UINT32_MAX)
nb_sectors = UINT32_MAX;
outbuf[0] = (nb_sectors >> 24) & 0xff;
outbuf[1] = (nb_sectors >> 16) & 0xff;
outbuf[2] = (nb_sectors >> 8) & 0xff;
outbuf[3] = nb_sectors & 0xff;
outbuf[4] = 0;
outbuf[5] = 0;
outbuf[6] = s->cluster_size * 2;
outbuf[7] = 0;
buflen = 8;
break;
case SYNCHRONIZE_CACHE:
ret = bdrv_flush(s->bs);
if (ret < 0) {
if (scsi_handle_rw_error(r, -ret, SCSI_REQ_STATUS_RETRY_FLUSH)) {
return -1;
}
}
break;
case GET_CONFIGURATION:
memset(outbuf, 0, 8);
outbuf[7] = 8;
buflen = 8;
break;
case SERVICE_ACTION_IN:
if ((req->cmd.buf[1] & 31) == 0x10) {
DPRINTF("SAI READ CAPACITY(16)\n");
memset(outbuf, 0, req->cmd.xfer);
bdrv_get_geometry(s->bs, &nb_sectors);
if (!nb_sectors)
goto not_ready;
nb_sectors /= s->cluster_size;
nb_sectors--;
s->max_lba = nb_sectors;
outbuf[0] = (nb_sectors >> 56) & 0xff;
outbuf[1] = (nb_sectors >> 48) & 0xff;
outbuf[2] = (nb_sectors >> 40) & 0xff;
outbuf[3] = (nb_sectors >> 32) & 0xff;
outbuf[4] = (nb_sectors >> 24) & 0xff;
outbuf[5] = (nb_sectors >> 16) & 0xff;
outbuf[6] = (nb_sectors >> 8) & 0xff;
outbuf[7] = nb_sectors & 0xff;
outbuf[8] = 0;
outbuf[9] = 0;
outbuf[10] = s->cluster_size * 2;
outbuf[11] = 0;
outbuf[12] = 0;
outbuf[13] = get_physical_block_exp(&s->qdev.conf);
if (s->qdev.conf.discard_granularity) {
outbuf[14] = 0x80;
}
buflen = req->cmd.xfer;
break;
}
DPRINTF("Unsupported Service Action In\n");
goto illegal_request;
case REPORT_LUNS:
if (req->cmd.xfer < 16)
goto illegal_request;
memset(outbuf, 0, 16);
outbuf[3] = 8;
buflen = 16;
break;
case VERIFY:
break;
case REZERO_UNIT:
DPRINTF("Rezero Unit\n");
if (!bdrv_is_inserted(s->bs)) {
goto not_ready;
}
break;
default:
goto illegal_request;
}
scsi_req_set_status(r, GOOD, NO_SENSE);
return buflen;
not_ready:
scsi_command_complete(r, CHECK_CONDITION, NOT_READY);
return -1;
illegal_request:
scsi_command_complete(r, CHECK_CONDITION, ILLEGAL_REQUEST);
return -1;
}
| 1threat |
def reverse_vowels(str1):
vowels = ""
for char in str1:
if char in "aeiouAEIOU":
vowels += char
result_string = ""
for char in str1:
if char in "aeiouAEIOU":
result_string += vowels[-1]
vowels = vowels[:-1]
else:
result_string += char
return result_string | 0debug |
static TCGv gen_mulu_i64_i32(TCGv a, TCGv b)
{
TCGv tmp1 = tcg_temp_new(TCG_TYPE_I64);
TCGv tmp2 = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_extu_i32_i64(tmp1, a);
dead_tmp(a);
tcg_gen_extu_i32_i64(tmp2, b);
dead_tmp(b);
tcg_gen_mul_i64(tmp1, tmp1, tmp2);
return tmp1;
}
| 1threat |
uint64_t HELPER(neon_abdl_u16)(uint32_t a, uint32_t b)
{
uint64_t tmp;
uint64_t result;
DO_ABD(result, a, b, uint8_t);
DO_ABD(tmp, a >> 8, b >> 8, uint8_t);
result |= tmp << 16;
DO_ABD(tmp, a >> 16, b >> 16, uint8_t);
result |= tmp << 32;
DO_ABD(tmp, a >> 24, b >> 24, uint8_t);
result |= tmp << 48;
return result;
}
| 1threat |
static void do_video_out(AVFormatContext *s,
AVOutputStream *ost,
AVInputStream *ist,
AVFrame *in_picture,
int *frame_size)
{
int nb_frames, i, ret;
int64_t topBand, bottomBand, leftBand, rightBand;
AVFrame *final_picture, *formatted_picture, *resampling_dst, *padding_src;
AVFrame picture_crop_temp, picture_pad_temp;
AVCodecContext *enc, *dec;
avcodec_get_frame_defaults(&picture_crop_temp);
avcodec_get_frame_defaults(&picture_pad_temp);
enc = ost->st->codec;
dec = ist->st->codec;
nb_frames = 1;
*frame_size = 0;
if(video_sync_method){
double vdelta;
vdelta = get_sync_ipts(ost) / av_q2d(enc->time_base) - ost->sync_opts;
if (vdelta < -1.1)
nb_frames = 0;
else if (video_sync_method == 2 || (video_sync_method<0 && (s->oformat->flags & AVFMT_VARIABLE_FPS))){
if(vdelta<=-0.6){
nb_frames=0;
}else if(vdelta>0.6)
ost->sync_opts= lrintf(get_sync_ipts(ost) / av_q2d(enc->time_base));
}else if (vdelta > 1.1)
nb_frames = lrintf(vdelta);
if (nb_frames == 0){
++nb_frames_drop;
if (verbose>2)
fprintf(stderr, "*** drop!\n");
}else if (nb_frames > 1) {
nb_frames_dup += nb_frames;
if (verbose>2)
fprintf(stderr, "*** %d dup!\n", nb_frames-1);
}
}else
ost->sync_opts= lrintf(get_sync_ipts(ost) / av_q2d(enc->time_base));
nb_frames= FFMIN(nb_frames, max_frames[CODEC_TYPE_VIDEO] - ost->frame_number);
if (nb_frames <= 0)
return;
if (ost->video_crop) {
if (av_picture_crop((AVPicture *)&picture_crop_temp, (AVPicture *)in_picture, dec->pix_fmt, ost->topBand, ost->leftBand) < 0) {
fprintf(stderr, "error cropping picture\n");
if (exit_on_error)
av_exit(1);
return;
}
formatted_picture = &picture_crop_temp;
} else {
formatted_picture = in_picture;
}
final_picture = formatted_picture;
padding_src = formatted_picture;
resampling_dst = &ost->pict_tmp;
if (ost->video_pad) {
final_picture = &ost->pict_tmp;
if (ost->video_resample) {
if (av_picture_crop((AVPicture *)&picture_pad_temp, (AVPicture *)final_picture, enc->pix_fmt, ost->padtop, ost->padleft) < 0) {
fprintf(stderr, "error padding picture\n");
if (exit_on_error)
av_exit(1);
return;
}
resampling_dst = &picture_pad_temp;
}
}
if (ost->video_resample) {
padding_src = NULL;
final_picture = &ost->pict_tmp;
if( (ost->resample_height != (ist->st->codec->height - (ost->topBand + ost->bottomBand)))
|| (ost->resample_width != (ist->st->codec->width - (ost->leftBand + ost->rightBand)))
|| (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) {
fprintf(stderr,"Input Stream #%d.%d frame size changed to %dx%d, %s\n", ist->file_index, ist->index, ist->st->codec->width, ist->st->codec->height,avcodec_get_pix_fmt_name(ist->st->codec->pix_fmt));
topBand = ((int64_t)ist->st->codec->height * ost->original_topBand / ost->original_height) & ~1;
bottomBand = ((int64_t)ist->st->codec->height * ost->original_bottomBand / ost->original_height) & ~1;
leftBand = ((int64_t)ist->st->codec->width * ost->original_leftBand / ost->original_width) & ~1;
rightBand = ((int64_t)ist->st->codec->width * ost->original_rightBand / ost->original_width) & ~1;
assert(topBand <= INT_MAX && topBand >= 0);
assert(bottomBand <= INT_MAX && bottomBand >= 0);
assert(leftBand <= INT_MAX && leftBand >= 0);
assert(rightBand <= INT_MAX && rightBand >= 0);
ost->topBand = topBand;
ost->bottomBand = bottomBand;
ost->leftBand = leftBand;
ost->rightBand = rightBand;
ost->resample_height = ist->st->codec->height - (ost->topBand + ost->bottomBand);
ost->resample_width = ist->st->codec->width - (ost->leftBand + ost->rightBand);
ost->resample_pix_fmt= ist->st->codec->pix_fmt;
sws_freeContext(ost->img_resample_ctx);
sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
ost->img_resample_ctx = sws_getContext(
ist->st->codec->width - (ost->leftBand + ost->rightBand),
ist->st->codec->height - (ost->topBand + ost->bottomBand),
ist->st->codec->pix_fmt,
ost->st->codec->width - (ost->padleft + ost->padright),
ost->st->codec->height - (ost->padtop + ost->padbottom),
ost->st->codec->pix_fmt,
sws_flags, NULL, NULL, NULL);
if (ost->img_resample_ctx == NULL) {
fprintf(stderr, "Cannot get resampling context\n");
av_exit(1);
}
}
sws_scale(ost->img_resample_ctx, formatted_picture->data, formatted_picture->linesize,
0, ost->resample_height, resampling_dst->data, resampling_dst->linesize);
}
if (ost->video_pad) {
av_picture_pad((AVPicture*)final_picture, (AVPicture *)padding_src,
enc->height, enc->width, enc->pix_fmt,
ost->padtop, ost->padbottom, ost->padleft, ost->padright, padcolor);
}
for(i=0;i<nb_frames;i++) {
AVPacket pkt;
av_init_packet(&pkt);
pkt.stream_index= ost->index;
if (s->oformat->flags & AVFMT_RAWPICTURE) {
AVFrame* old_frame = enc->coded_frame;
enc->coded_frame = dec->coded_frame;
pkt.data= (uint8_t *)final_picture;
pkt.size= sizeof(AVPicture);
pkt.pts= av_rescale_q(ost->sync_opts, enc->time_base, ost->st->time_base);
pkt.flags |= PKT_FLAG_KEY;
write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]);
enc->coded_frame = old_frame;
} else {
AVFrame big_picture;
big_picture= *final_picture;
big_picture.interlaced_frame = in_picture->interlaced_frame;
if(avcodec_opts[CODEC_TYPE_VIDEO]->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME)){
if(top_field_first == -1)
big_picture.top_field_first = in_picture->top_field_first;
else
big_picture.top_field_first = top_field_first;
}
if (same_quality) {
big_picture.quality = ist->st->quality;
}else
big_picture.quality = ost->st->quality;
if(!me_threshold)
big_picture.pict_type = 0;
big_picture.pts= ost->sync_opts;
ret = avcodec_encode_video(enc,
bit_buffer, bit_buffer_size,
&big_picture);
if (ret < 0) {
fprintf(stderr, "Video encoding failed\n");
av_exit(1);
}
if(ret>0){
pkt.data= bit_buffer;
pkt.size= ret;
if(enc->coded_frame->pts != AV_NOPTS_VALUE)
pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
if(enc->coded_frame->key_frame)
pkt.flags |= PKT_FLAG_KEY;
write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]);
*frame_size = ret;
video_size += ret;
if (ost->logfile && enc->stats_out) {
fprintf(ost->logfile, "%s", enc->stats_out);
}
}
}
ost->sync_opts++;
ost->frame_number++;
}
}
| 1threat |
void monitor_disas(Monitor *mon, CPUState *cpu,
target_ulong pc, int nb_insn, int is_physical)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
int count, i;
CPUDebug s;
INIT_DISASSEMBLE_INFO(s.info, (FILE *)mon, monitor_fprintf);
s.cpu = cpu;
monitor_disas_is_physical = is_physical;
s.info.read_memory_func = monitor_read_memory;
s.info.print_address_func = generic_print_address;
s.info.buffer_vma = pc;
s.info.cap_arch = -1;
s.info.cap_mode = 0;
#ifdef TARGET_WORDS_BIGENDIAN
s.info.endian = BFD_ENDIAN_BIG;
#else
s.info.endian = BFD_ENDIAN_LITTLE;
#endif
if (cc->disas_set_info) {
cc->disas_set_info(cpu, &s.info);
}
if (s.info.cap_arch >= 0 && cap_disas_monitor(&s.info, pc, nb_insn)) {
return;
}
if (!s.info.print_insn) {
monitor_printf(mon, "0x" TARGET_FMT_lx
": Asm output not supported on this arch\n", pc);
return;
}
for(i = 0; i < nb_insn; i++) {
monitor_printf(mon, "0x" TARGET_FMT_lx ": ", pc);
count = s.info.print_insn(pc, &s.info);
monitor_printf(mon, "\n");
if (count < 0)
break;
pc += count;
}
}
| 1threat |
make "continue" button appear when items selected and disappear when items unselected using javascript : my question is abou make "continue" button appear when items selected and disappear when items unselected using javascript thank you :D | 0debug |
static void raw_lock_medium(BlockDriverState *bs, bool locked)
{
bdrv_lock_medium(bs->file->bs, locked);
}
| 1threat |
Finding columns in dataframe with specific number of values in R : <p>I have a dataframe(data.table) with over 3000 columns. I need to find out the columns in my dataframe that have only 2 and less than 2 values in them. I then after extracting those columns with 2 and less then 2 values I want to drop them out of the original data frame.
I illustrate as follows:
Original data frame</p>
<pre><code>Month A B C
Jan-00 0.007 NA 1758.27
Feb-00 0.004 NA 1310.43
Mar-00 0.004 NA 1260.89
Apr-00 0.004 0.0002 1137.34
May-00 0.005 6.05E-05 1595.78
Jun-00 0.003 NA 4968.89
Jul-00 0.007 NA NA
Aug-00 0.005 NA NA
Sep-00 0.004 NA NA
</code></pre>
<p>Desired output</p>
<pre><code> Month A C
Jan-00 0.007 1758.27
Feb-00 0.004 1310.435
Mar-00 0.004 1260.89
Apr-00 0.004 1137.342105
May-00 0.005 1595.78125
Jun-00 0.003 4968.895238
Jul-00 0.007 NA
Aug-00 0.005 NA
Sep-00 0.004 NA
</code></pre>
<p>I would appreciate your help in this regard.</p>
| 0debug |
Redux Form - initialValues not updating with state : <p>I am having some issues with setting the inital form field values using redux-form.</p>
<p>I am using redux-form v6.0.0-rc.3 and react v15.3.0.</p>
<p>So here's my issue, I have a grid of users and when a user row is clicked on, I am navigating to an edit users page and including the users id in the url. Then on the edit users page, I am grabbing the id and calling fetchUser(this.props.params.id) which is an action creator that returns this.state.users. I am then attempting to set the forms inital values by calling:</p>
<pre><code>function mapStateToProps(state) {
return { initialValues: state.users.user }
}
</code></pre>
<p>By my understanding, this should set the initialValues to state.users.user and whenever this state is updated the initialValues should be updated as well. This is not the case for me. InitialValues is being set to the previously clicked on user row (i.e the previous state for this.state.users.user). So I decided to test this and add a button to this component and when its clicked I am calling fetchUser again with a user id hard coded in:</p>
<p><code>this.props.fetchUser('75e585aa-480b-496a-b852-82a541aa0ca3');</code></p>
<p>This is updating the state correctly but the values for initialValues do not change. It is not getting updated when the state is updated. I tested this exact same process on an older version of redux-form and it worked as expected.</p>
<p>Am I doing something wrong here or is this an issue with the version I am using.</p>
<p>Users Edit Form - </p>
<pre><code>class UsersShowForm extends Component {
componentWillMount() {
this.props.fetchUser(this.props.params.id);
}
onSubmit(props){
console.log('submitting');
}
changeUser() {
this.props.fetchUser('75e585aa-480b-496a-b852-82a541aa0ca3');
}
renderTextField(field) {
return (
<TextField
floatingLabelText={field.input.label}
errorText={field.touched && field.error}
fullWidth={true}
{...field.input}
/>)
}
render() {
const { handleSubmit, submitting, pristine } = this.props;
return(
<div>
<form onSubmit={handleSubmit(this.onSubmit.bind(this))} className="mdl-cell mdl-cell--12-col">
<Field name="emailAddress" component={this.renderTextField} label="Email Address"/>
<Field name="firstName" component={this.renderTextField} label="First Name"/>
<Field name="lastName" component={this.renderTextField} label="Last Name"/>
</form>
<RaisedButton onClick={this.changeUser.bind(this)} label="Primary" primary={true} />
</div>
);
}
}
function mapStateToProps(state) {
return { initialValues: state.users.user }
}
UsersShowForm = reduxForm({
form: 'UsersShowForm'
})(UsersShowForm)
UsersShowForm = connect(
mapStateToProps,
actions
)(UsersShowForm)
export default UsersShowForm
</code></pre>
<p>Users Reducer - </p>
<pre><code>import {
FETCH_USERS,
FETCH_USER
} from '../actions/types';
const INITIAL_STATE = { all: [], user: {} };
export default function(state = { INITIAL_STATE }, action) {
switch (action.type) {
case FETCH_USERS:
return {...state, all: action.payload };
case FETCH_USER:
return {...state, user: action.payload };
default:
return state;
}
}
</code></pre>
<p>Reducer Index - </p>
<pre><code>import { combineReducers } from 'redux';
import { reducer as formReducer } from 'redux-form';
import usersReducer from './users_reducer';
const rootReducer = combineReducers({
form: formReducer,
users: usersReducer
});
export default rootReducer;
</code></pre>
| 0debug |
Double* to double conversion error when trying to pass a function C++ : I am fairly new to c++ and I am writing a program that has a struct, and 3 functions named win_percentage, Wins_losses, and winning_teams. The object of this assignment is to create a program that prints out 13 school teams, their records, and then to print out the teams who are over .500 in wins.
I keep getting an error that says **"cannot convert 'double (*)(std::__cxx11::string, double, double) {aka double (*)(std::__cxx11::basic_string<char>, double, double)}' to 'double' for argument '4' to 'void wins_losses(std::__cxx11::string, double, double, double)'
wins_losses(school1.name,school1.wins,school1.losses, win_percentage);**" The problem occurs when I am trying to pass the win_percentage function into the other functions. How am I able to fix this problem? please help lol
here is my code. (ps I will make a for loop for this program)
#include <iostream>
#include<string>
using namespace std;
struct Team
{
string name;
int wins;
int losses;
};
double win_percentage (string , double , double );
void wins_losses (string , double , double , double );
void winning_teams (string , double , double , double );
int main() {
Team school1 = {"Bethune-Cookman", 11, 3};
Team school2 = {"Coppin State", 5, 9};
Team school3 = {"Delaware State", 1, 13};
Team school4 = {"Florida A&M", 6, 8};
Team school5 = {"Hampton", 11, 4};
Team school6 = {"Howard", 6, 8};
Team school7 = {"Maryland Eastern Shore", 2, 12};
Team school8 = {"Morgan State", 6, 8};
Team school9 = {"North Carolina A&T", 10, 4};
Team school10 = {"North Carolina Central", 8, 6};
Team school11 = {"Norfolk State", 10, 4};
Team school12 = {"Savannah State", 10, 4};
Team school13 = {"South Carolina State", 6, 8};
cout<< "MEAC MENS BASKETBALL TEAMS CONFERENCE STANDINGS"<< endl;
cout<< school1.name<<" "<<school1.wins<<"-"<<school1.losses<< endl;
cout<< school2.name<<" "<<school2.wins<<"-"<<school2.losses<< endl;
cout<< school3.name<<" "<<school3.wins<<"-"<<school3.losses<< endl;
cout<< school4.name<<" "<<school4.wins<<"-"<<school4.losses<< endl;
cout<< school5.name<<" "<<school5.wins<<"-"<<school5.losses<< endl;
cout<< school6.name<<" "<<school6.wins<<"-"<<school6.losses<< endl;
cout<< school7.name<<" "<<school7.wins<<"-"<<school7.losses<< endl;
cout<< school8.name<<" "<<school8.wins<<"-"<<school8.losses<< endl;
cout<< school9.name<<" "<<school9.wins<<"-"<<school9.losses<< endl;
cout<< school10.name<<" "<<school10.wins<<"-"<<school10.losses<< endl;
cout<< school11.name<<" "<<school11.wins<<"-"<<school11.losses<< endl;
cout<< school12.name<<" "<<school12.wins<<"-"<<school12.losses<< endl;
cout<< school13.name<<" "<<school13.wins<<"-"<<school13.losses<< endl;
cout<<"TEAMS WINNING PERCENTAGE"<<endl;
win_percentage(school1.name,school1.wins,school1.losses);
win_percentage(school2.name,school2.wins,school2.losses);
win_percentage(school3.name,school3.wins,school3.losses);
win_percentage(school4.name,school4.wins,school4.losses);
win_percentage(school5.name,school5.wins,school5.losses);
win_percentage(school6.name,school6.wins,school6.losses);
win_percentage(school7.name,school7.wins,school7.losses);
win_percentage(school8.name,school8.wins,school8.losses);
win_percentage(school9.name,school9.wins,school9.losses);
win_percentage(school10.name,school10.wins,school10.losses);
win_percentage(school11.name,school11.wins,school11.losses);
win_percentage(school12.name,school12.wins,school12.losses);
win_percentage(school13.name,school13.wins,school13.losses);
cout<<"TEAMS WITH WINNING RECORDS"<<endl;
wins_losses(school1.name,school1.wins,school1.losses, win_percentage);
wins_losses(school2.name,school2.wins,school2.losses,win_percentage);
wins_losses(school3.name,school3.wins,school3.losses,win_percentage);
wins_losses(school4.name,school4.wins,school4.losses,win_percentage);
wins_losses(school5.name,school5.wins,school5.losses,win_percentage);
wins_losses(school6.name,school6.wins,school6.losses,win_percentage);
wins_losses(school7.name,school7.wins,school7.losses,win_percentage);
wins_losses(school8.name,school8.wins,school8.losses,win_percentage);
wins_losses(school9.name,school9.wins,school9.losses,win_percentage);
wins_losses(school10.name,school10.wins,school10.losses,win_percentage);
wins_losses(school11.name,school11.wins,school11.losses,win_percentage);
wins_losses(school12.name,school12.wins,school12.losses,win_percentage);
wins_losses(school13.name,school13.wins,school13.losses,win_percentage);
winning_teams(school1.name,school1.wins,school1.losses,win_percentage);
winning_teams(school2.name,school2.wins,school2.losses,win_percentage);
winning_teams(school3.name,school3.wins,school3.losses,win_percentage);
winning_teams(school4.name,school4.wins,school4.losses,win_percentage);
winning_teams(school5.name,school5.wins,school5.losses,win_percentage);
winning_teams(school6.name,school6.wins,school6.losses,win_percentage);
winning_teams(school7.name,school7.wins,school7.losses,win_percentage);
winning_teams(school8.name,school8.wins,school8.losses,win_percentage);
winning_teams(school9.name,school9.wins,school9.losses,win_percentage);
winning_teams(school10.name,school10.wins,school10.losses,win_percentage);
winning_teams(school11.name,school11.wins,school11.losses,win_percentage);
winning_teams(school12.name,school12.wins,school12.losses,win_percentage);
winning_teams(school13.name,school13.wins,school13.losses,win_percentage);
return 0;
}
double win_percentage(string a, double b, double c){
double x;
x == b / (b + c);
cout<< a<<" "<<x<<endl;
}
void wins_losses( string e, double f, double g, double h){
cout<< e<< "Record is"<<f<<"-"<<g<< h<<endl;
}
void winning_teams(string w, int f, int y, double z){
if ( z >.500){
cout<< w<<" "<<f<< "-"<<y<< " "<< z<< endl;
}
} | 0debug |
cursor.execute('SELECT * FROM users WHERE username = ' + user_input) | 1threat |
Why is it that when i run my code it says "AttributeError: Enemy instance has no attribute 'enemy'"? : <p>my code can both be found and ran here : <a href="https://repl.it/Bda9/10" rel="nofollow">https://repl.it/Bda9/10</a></p>
<p>right now i'm focusing on the 'explore' then 'attack' pathways, but for some reason this code will not run a single attack. I need to get this at least working by tonight. We just started OOP and... well... this is frustrating me.</p>
<p>what is causing that error?
why does the code not recognize enemy (I think that's what the error means)?</p>
| 0debug |
Filter out all users created 23 days ago using mysql : <p>I want to make a user expiring notification module. In that module I want to send emails when users completed 23 days from their 30 days trial period.And after the 30 days trial period completed I wanna send them the trial period expired email. To do that task I wanna make a efficient mysql queries for both tasks. </p>
<p>example : created_time = 2018-08-08 23:16:55 </p>
| 0debug |
static void io_write(IPackDevice *ip, uint8_t addr, uint16_t val)
{
IPOctalState *dev = IPOCTAL(ip);
unsigned reg = val & 0xFF;
unsigned block = addr >> 5;
unsigned channel = addr >> 4;
unsigned offset = (addr & 0x1F) ^ 1;
SCC2698Channel *ch = &dev->ch[channel];
SCC2698Block *blk = &dev->blk[block];
uint8_t old_isr = blk->isr;
uint8_t old_imr = blk->imr;
switch (offset) {
case REG_MRa:
case REG_MRb:
ch->mr[ch->mr_idx] = reg;
DPRINTF("Write MR%u%c 0x%x\n", ch->mr_idx + 1, channel + 'a', reg);
ch->mr_idx = 1;
break;
case REG_CSRa:
case REG_CSRb:
DPRINTF("Write CSR%c: 0x%x\n", channel + 'a', reg);
break;
case REG_CRa:
case REG_CRb:
write_cr(dev, channel, reg);
break;
case REG_THRa:
case REG_THRb:
if (ch->sr & SR_TXRDY) {
DPRINTF("Write THR%c (0x%x)\n", channel + 'a', reg);
if (ch->dev) {
uint8_t thr = reg;
qemu_chr_fe_write(ch->dev, &thr, 1);
}
} else {
DPRINTF("Write THR%c (0x%x), Tx disabled\n", channel + 'a', reg);
}
break;
case REG_ACR:
DPRINTF("Write ACR%c 0x%x\n", block + 'A', val);
break;
case REG_IMR:
DPRINTF("Write IMR%c 0x%x\n", block + 'A', val);
blk->imr = reg;
break;
case REG_OPCR:
DPRINTF("Write OPCR%c 0x%x\n", block + 'A', val);
break;
default:
DPRINTF("Write unknown/unsupported register 0x%02x %u\n", offset, val);
}
if (old_isr != blk->isr || old_imr != blk->imr) {
update_irq(dev, block);
}
}
| 1threat |
I have code like this need to fetch only one specific value from the database : <?php
$stmt = $conn->prepare('SELECT Distinct(specificcategoryname) FROM `clientstable` c,specificcategories s where c.PhoneNumber=:phNo and c.SpecificCategoryId=s.SpecificCategoryId');
$stmt->execute(['phNo'=>$phNo]);
while($row = $stmt->fetch()) {
echo "<tr>";
echo "<td>".$row['specificcategoryname']."</td>";
echo "</tr>";
}
?> | 0debug |
Dockerfile: Setting multiple environment variables in single line : <p>I was under the impression that environmental variables could be set on a single line as follows so as to minimize intermediary images.</p>
<pre><code>FROM alpine:3.6
ENV RUBY_MAJOR 2.4 \
RUBY_VERSION 2.4.1 \
RUBY_DOWNLOAD_SHA256 4fc8a9992de3e90191de369270ea4b6c1b171b7941743614cc50822ddc1fe654 \
RUBYGEMS_VERSION 2.6.12 \
BUNDLER_VERSION 1.15.3
</code></pre>
<p>However, running a container based off of this snippet and calling <code># set |grep RU</code> I see that the variables are not being assigned separately, but are combined into a single string.</p>
<pre><code>RUBY_MAJOR='2.4 RUBY_VERSION 2.4.1 RUBY_DOWNLOAD_SHA256 4fc8a9992de3e90191de369270ea4b6c1b171b7941743614cc50822ddc1fe654 RUBYGEMS_VERSION 2.6.12 BUNDLER_VERSION 1.15.3'
</code></pre>
<p>However, if I explicitly set each variable as below, I get the expected output and there are no errors when calling the variables. </p>
<pre><code>ENV RUBY_MAJOR 2.4
ENV RUBY_VERSION 2.4.1
ENV RUBY_DOWNLOAD_SHA256 4fc8a9992de3e90191de369270ea4b6c1b171b7941743614cc50822ddc1fe654
ENV RUBYGEMS_VERSION 2.6.12
ENV BUNDLER_VERSION 1.15.3
</code></pre>
<p><strong>Question:</strong> Is it is possible to combine the setting of environment variables on a single line? If so, how would I do it? And is it a good practice?</p>
| 0debug |
html helper syntax for radio button in asp.net mvc : how to write this code with html helper in asp using html helper in asp.net mvc
<label>
<input name="form-field-radio" type="radio" class="inverted">
<span class="text">OF BASIC</span>
</label>
| 0debug |
static void matroska_merge_packets(AVPacket *out, AVPacket *in)
{
out->data = av_realloc(out->data, out->size+in->size);
memcpy(out->data+out->size, in->data, in->size);
out->size += in->size;
av_destruct_packet(in);
av_free(in);
}
| 1threat |
Slicing words from string : <p>I have a string that has words and spaces,</p>
<pre><code>var version = "One Forty Six 1.1 V2 (10 kilo / 20 kilo) (2000 - 2005)"
</code></pre>
<p>I want to extract</p>
<pre><code>One Forty Six 1.1 V2
</code></pre>
<p>out of it.
What is the best practice of doing it? How can i use <strong>.slice</strong> to extract what i am looking for?</p>
| 0debug |
static av_always_inline void decode_bgr_1(HYuvContext *s, int count,
int decorrelate, int alpha)
{
int i;
OPEN_READER(re, &s->gb);
for (i = 0; i < count; i++) {
unsigned int index;
int code, n;
UPDATE_CACHE(re, &s->gb);
index = SHOW_UBITS(re, &s->gb, VLC_BITS);
code = s->vlc[4].table[index][0];
n = s->vlc[4].table[index][1];
if (code != -1) {
*(uint32_t*)&s->temp[0][4 * i] = s->pix_bgr_map[code];
LAST_SKIP_BITS(re, &s->gb, n);
} else {
int nb_bits;
if(decorrelate) {
VLC_INTERN(s->temp[0][4 * i + G], s->vlc[1].table,
&s->gb, re, VLC_BITS, 3);
UPDATE_CACHE(re, &s->gb);
index = SHOW_UBITS(re, &s->gb, VLC_BITS);
VLC_INTERN(code, s->vlc[0].table, &s->gb, re, VLC_BITS, 3);
s->temp[0][4 * i + B] = code + s->temp[0][4 * i + G];
UPDATE_CACHE(re, &s->gb);
index = SHOW_UBITS(re, &s->gb, VLC_BITS);
VLC_INTERN(code, s->vlc[2].table, &s->gb, re, VLC_BITS, 3);
s->temp[0][4 * i + R] = code + s->temp[0][4 * i + G];
} else {
VLC_INTERN(s->temp[0][4 * i + B], s->vlc[0].table,
&s->gb, re, VLC_BITS, 3);
UPDATE_CACHE(re, &s->gb);
index = SHOW_UBITS(re, &s->gb, VLC_BITS);
VLC_INTERN(s->temp[0][4 * i + G], s->vlc[1].table,
&s->gb, re, VLC_BITS, 3);
UPDATE_CACHE(re, &s->gb);
index = SHOW_UBITS(re, &s->gb, VLC_BITS);
VLC_INTERN(s->temp[0][4 * i + R], s->vlc[2].table,
&s->gb, re, VLC_BITS, 3);
}
if (alpha) {
UPDATE_CACHE(re, &s->gb);
index = SHOW_UBITS(re, &s->gb, VLC_BITS);
VLC_INTERN(s->temp[0][4 * i + A], s->vlc[2].table,
&s->gb, re, VLC_BITS, 3);
}
}
}
CLOSE_READER(re, &s->gb);
}
| 1threat |
How to colour tables in R - Conditional Fomatting : <p>I want to assign colors to tables in R.</p>
<p><a href="https://i.stack.imgur.com/YjF3r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YjF3r.png" alt="enter image description here"></a></p>
<p>Is it possible to create a table like this in R - where the predicted class is colored green when it is green and red when it is red.</p>
<p>The above table displayed is done in excel.</p>
| 0debug |
static void mxf_write_package(AVFormatContext *s, enum MXFMetadataSetType type, const char *package_name)
{
MXFContext *mxf = s->priv_data;
AVIOContext *pb = s->pb;
int i, track_count = s->nb_streams+1;
int name_size = mxf_utf16_local_tag_length(package_name);
int user_comment_count = 0;
if (type == MaterialPackage) {
if (mxf->store_user_comments)
user_comment_count = mxf_write_user_comments(s, s->metadata);
mxf_write_metadata_key(pb, 0x013600);
PRINT_KEY(s, "Material Package key", pb->buf_ptr - 16);
klv_encode_ber_length(pb, 92 + name_size + (16*track_count) + (16*user_comment_count) + 12*mxf->store_user_comments);
} else {
mxf_write_metadata_key(pb, 0x013700);
PRINT_KEY(s, "Source Package key", pb->buf_ptr - 16);
klv_encode_ber_length(pb, 112 + name_size + (16*track_count) + 12*mxf->store_user_comments);
}
mxf_write_local_tag(pb, 16, 0x3C0A);
mxf_write_uuid(pb, type, 0);
av_log(s,AV_LOG_DEBUG, "package type:%d\n", type);
PRINT_KEY(s, "package uid", pb->buf_ptr - 16);
mxf_write_local_tag(pb, 32, 0x4401);
mxf_write_umid(s, type == SourcePackage);
PRINT_KEY(s, "package umid second part", pb->buf_ptr - 16);
if (name_size)
mxf_write_local_tag_utf16(pb, 0x4402, package_name);
mxf_write_local_tag(pb, 8, 0x4405);
avio_wb64(pb, mxf->timestamp);
mxf_write_local_tag(pb, 8, 0x4404);
avio_wb64(pb, mxf->timestamp);
mxf_write_local_tag(pb, track_count*16 + 8, 0x4403);
mxf_write_refs_count(pb, track_count);
mxf_write_uuid(pb, type == MaterialPackage ? Track :
Track + TypeBottom, -1);
for (i = 0; i < s->nb_streams; i++)
mxf_write_uuid(pb, type == MaterialPackage ? Track : Track + TypeBottom, i);
if (mxf->store_user_comments) {
mxf_write_local_tag(pb, user_comment_count*16 + 8, 0x4406);
mxf_write_refs_count(pb, user_comment_count);
for (i = 0; i < user_comment_count; i++)
mxf_write_uuid(pb, TaggedValue, mxf->tagged_value_count - user_comment_count + i);
}
if (type == SourcePackage) {
mxf_write_local_tag(pb, 16, 0x4701);
if (s->nb_streams > 1) {
mxf_write_uuid(pb, MultipleDescriptor, 0);
mxf_write_multi_descriptor(s);
} else
mxf_write_uuid(pb, SubDescriptor, 0);
}
mxf_write_track(s, mxf->timecode_track, type);
mxf_write_sequence(s, mxf->timecode_track, type);
mxf_write_timecode_component(s, mxf->timecode_track, type);
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
mxf_write_track(s, st, type);
mxf_write_sequence(s, st, type);
mxf_write_structural_component(s, st, type);
if (type == SourcePackage) {
MXFStreamContext *sc = st->priv_data;
mxf_essence_container_uls[sc->index].write_desc(s, st);
}
}
}
| 1threat |
Use arrow function in vue computed does not work : <p>I am learning Vue and facing a problem while using arrow function in computed property.</p>
<p>My original code works fine (See snippet below).</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>new Vue({
el: '#app',
data: {
turnRed: false,
turnGreen: false,
turnBlue: false
},
computed:{
switchRed: function () {
return {red: this.turnRed}
},
switchGreen: function () {
return {green: this.turnGreen}
},
switchBlue: function () {
return {blue: this.turnBlue}
}
}
});</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>.demo{
width: 100px;
height: 100px;
background-color: gray;
display: inline-block;
margin: 10px;
}
.red{
background-color: red;
}
.green{
background-color: green;
}
.blue{
background-color: blue;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.2.4/vue.js"></script>
<div id="app">
<div class="demo" @click="turnRed = !turnRed" :class="switchRed"></div>
<div class="demo" @click="turnGreen = !turnGreen" :class="switchGreen"></div>
<div class="demo" @click="turnBlue = !turnBlue" :class="switchBlue"></div>
</div></code></pre>
</div>
</div>
</p>
<p>However, after I change methods in computed property, the color will not change (though the turnRed value still switch between true and false successfully).</p>
<p>This is my code:</p>
<pre><code>computed:{
switchRed: () => {
return {red: this.turnRed}
},
switchGreen: () => {
return {green: this.turnGreen}
},
switchBlue: () => {
return {blue: this.turnBlue}
}
}
</code></pre>
<p>Do I use the wrong syntax ?</p>
| 0debug |
PIX_SAD(mmxext)
#endif
av_cold void ff_dsputil_init_pix_mmx(DSPContext *c, AVCodecContext *avctx)
{
#if HAVE_INLINE_ASM
int cpu_flags = av_get_cpu_flags();
if (INLINE_MMX(cpu_flags)) {
c->pix_abs[0][0] = sad16_mmx;
c->pix_abs[0][1] = sad16_x2_mmx;
c->pix_abs[0][2] = sad16_y2_mmx;
c->pix_abs[0][3] = sad16_xy2_mmx;
c->pix_abs[1][0] = sad8_mmx;
c->pix_abs[1][1] = sad8_x2_mmx;
c->pix_abs[1][2] = sad8_y2_mmx;
c->pix_abs[1][3] = sad8_xy2_mmx;
c->sad[0] = sad16_mmx;
c->sad[1] = sad8_mmx;
}
if (INLINE_MMXEXT(cpu_flags)) {
c->pix_abs[0][0] = sad16_mmxext;
c->pix_abs[1][0] = sad8_mmxext;
c->sad[0] = sad16_mmxext;
c->sad[1] = sad8_mmxext;
if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
c->pix_abs[0][1] = sad16_x2_mmxext;
c->pix_abs[0][2] = sad16_y2_mmxext;
c->pix_abs[0][3] = sad16_xy2_mmxext;
c->pix_abs[1][1] = sad8_x2_mmxext;
c->pix_abs[1][2] = sad8_y2_mmxext;
c->pix_abs[1][3] = sad8_xy2_mmxext;
}
}
if (INLINE_SSE2(cpu_flags) && !(cpu_flags & AV_CPU_FLAG_3DNOW) && avctx->codec_id != AV_CODEC_ID_SNOW) {
c->sad[0] = sad16_sse2;
}
#endif
}
| 1threat |
How can I tell if a given git tag is annotated or lightweight? : <p>I type <code>git tag</code> and it lists my current tags:</p>
<pre><code>1.2.3
1.2.4
</code></pre>
<p>How can I determine which of these is annotated, and which is lightweight?</p>
| 0debug |
Algorithms in DHCP : <p>What are the algorithms that dictate how DHCP assigns IP addresses? Are there any references, algorithms, C/Assembly/C++/etc. source code that demonstrates how DHCP assigns IP addresses almost so flawlessly? Thanks.</p>
| 0debug |
Is there a way to retrieve available disk space in java or some other language? : <p>I want to build an application that gives me a warning when my harddrive is about to become full. For this the program needs to retrieve the amount of available disk space. Anyone kows how I can do this?</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.