problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
How can I use js var in html? : <p>I'm actually trying to use a js var in my html code like this :</p>
<hr>
<p>In javascript code :</p>
<pre><code>var test = 'This is a test';
</code></pre>
<p>And in the html :</p>
<pre><code><p>display var test here</p>
</code></pre>
<p>How can I display the value of my js var in html like this ?</p>
| 0debug |
Making a Java class Thread safe : I am trying to understand as to how to make the Java class thread-safe.
package com.test;
public class ThreadBean {
private int x;
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
}
Inorder to do this,I need to create another program that spawns the threads(lets say 2 threads) and then each of the two threads sets values using the setX().When the values are being read using getX() I should be able to see inconsistencies thanks to the above ThreadBean class not being threadsafe.This maybe a simplistic case but this is just for my understanding.Please advise.Thanks | 0debug |
static av_cold int nvenc_encode_init(AVCodecContext *avctx)
{
NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS encode_session_params = { 0 };
NV_ENC_PRESET_CONFIG preset_config = { 0 };
CUcontext cu_context_curr;
CUresult cu_res;
GUID encoder_preset = NV_ENC_PRESET_HQ_GUID;
GUID codec;
NVENCSTATUS nv_status = NV_ENC_SUCCESS;
AVCPBProperties *cpb_props;
int surfaceCount = 0;
int i, num_mbs;
int isLL = 0;
int lossless = 0;
int res = 0;
int dw, dh;
int qp_inter_p;
NvencContext *ctx = avctx->priv_data;
NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs;
NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->nvenc_funcs;
if (!nvenc_dyload_nvenc(avctx))
return AVERROR_EXTERNAL;
ctx->last_dts = AV_NOPTS_VALUE;
ctx->encode_config.version = NV_ENC_CONFIG_VER;
ctx->init_encode_params.version = NV_ENC_INITIALIZE_PARAMS_VER;
preset_config.version = NV_ENC_PRESET_CONFIG_VER;
preset_config.presetCfg.version = NV_ENC_CONFIG_VER;
encode_session_params.version = NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER;
encode_session_params.apiVersion = NVENCAPI_VERSION;
if (ctx->gpu >= dl_fn->nvenc_device_count) {
av_log(avctx, AV_LOG_FATAL, "Requested GPU %d, but only %d GPUs are available!\n", ctx->gpu, dl_fn->nvenc_device_count);
res = AVERROR(EINVAL);
goto error;
}
ctx->cu_context = NULL;
cu_res = dl_fn->cu_ctx_create(&ctx->cu_context, 4, dl_fn->nvenc_devices[ctx->gpu]);
if (cu_res != CUDA_SUCCESS) {
av_log(avctx, AV_LOG_FATAL, "Failed creating CUDA context for NVENC: 0x%x\n", (int)cu_res);
res = AVERROR_EXTERNAL;
goto error;
}
cu_res = dl_fn->cu_ctx_pop_current(&cu_context_curr);
if (cu_res != CUDA_SUCCESS) {
av_log(avctx, AV_LOG_FATAL, "Failed popping CUDA context: 0x%x\n", (int)cu_res);
res = AVERROR_EXTERNAL;
goto error;
}
encode_session_params.device = ctx->cu_context;
encode_session_params.deviceType = NV_ENC_DEVICE_TYPE_CUDA;
nv_status = p_nvenc->nvEncOpenEncodeSessionEx(&encode_session_params, &ctx->nvencoder);
if (nv_status != NV_ENC_SUCCESS) {
ctx->nvencoder = NULL;
av_log(avctx, AV_LOG_FATAL, "OpenEncodeSessionEx failed: 0x%x\n", (int)nv_status);
res = AVERROR_EXTERNAL;
goto error;
}
if (ctx->preset) {
if (!strcmp(ctx->preset, "slow")) {
encoder_preset = NV_ENC_PRESET_HQ_GUID;
ctx->twopass = 1;
} else if (!strcmp(ctx->preset, "medium")) {
encoder_preset = NV_ENC_PRESET_HQ_GUID;
ctx->twopass = 0;
} else if (!strcmp(ctx->preset, "fast")) {
encoder_preset = NV_ENC_PRESET_HP_GUID;
ctx->twopass = 0;
} else if (!strcmp(ctx->preset, "hq")) {
encoder_preset = NV_ENC_PRESET_HQ_GUID;
} else if (!strcmp(ctx->preset, "hp")) {
encoder_preset = NV_ENC_PRESET_HP_GUID;
} else if (!strcmp(ctx->preset, "bd")) {
encoder_preset = NV_ENC_PRESET_BD_GUID;
} else if (!strcmp(ctx->preset, "ll")) {
encoder_preset = NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID;
isLL = 1;
} else if (!strcmp(ctx->preset, "llhp")) {
encoder_preset = NV_ENC_PRESET_LOW_LATENCY_HP_GUID;
isLL = 1;
} else if (!strcmp(ctx->preset, "llhq")) {
encoder_preset = NV_ENC_PRESET_LOW_LATENCY_HQ_GUID;
isLL = 1;
} else if (!strcmp(ctx->preset, "lossless")) {
encoder_preset = NV_ENC_PRESET_LOSSLESS_DEFAULT_GUID;
lossless = 1;
} else if (!strcmp(ctx->preset, "losslesshp")) {
encoder_preset = NV_ENC_PRESET_LOSSLESS_HP_GUID;
lossless = 1;
} else if (!strcmp(ctx->preset, "default")) {
encoder_preset = NV_ENC_PRESET_DEFAULT_GUID;
} else {
av_log(avctx, AV_LOG_FATAL, "Preset \"%s\" is unknown! Supported presets: slow, medium, fast, hp, hq, bd, ll, llhp, llhq, lossless, losslesshp, default\n", ctx->preset);
res = AVERROR(EINVAL);
goto error;
}
}
if (ctx->twopass < 0) {
ctx->twopass = isLL;
}
switch (avctx->codec->id) {
case AV_CODEC_ID_H264:
codec = NV_ENC_CODEC_H264_GUID;
break;
case AV_CODEC_ID_H265:
codec = NV_ENC_CODEC_HEVC_GUID;
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown codec name\n");
res = AVERROR(EINVAL);
goto error;
}
nv_status = p_nvenc->nvEncGetEncodePresetConfig(ctx->nvencoder, codec, encoder_preset, &preset_config);
if (nv_status != NV_ENC_SUCCESS) {
av_log(avctx, AV_LOG_FATAL, "GetEncodePresetConfig failed: 0x%x\n", (int)nv_status);
res = AVERROR_EXTERNAL;
goto error;
}
ctx->init_encode_params.encodeGUID = codec;
ctx->init_encode_params.encodeHeight = avctx->height;
ctx->init_encode_params.encodeWidth = avctx->width;
if (avctx->sample_aspect_ratio.num && avctx->sample_aspect_ratio.den &&
(avctx->sample_aspect_ratio.num != 1 || avctx->sample_aspect_ratio.num != 1)) {
av_reduce(&dw, &dh,
avctx->width * avctx->sample_aspect_ratio.num,
avctx->height * avctx->sample_aspect_ratio.den,
1024 * 1024);
ctx->init_encode_params.darHeight = dh;
ctx->init_encode_params.darWidth = dw;
} else {
ctx->init_encode_params.darHeight = avctx->height;
ctx->init_encode_params.darWidth = avctx->width;
}
if (avctx->width == 720 &&
(avctx->height == 480 || avctx->height == 576)) {
av_reduce(&dw, &dh,
ctx->init_encode_params.darWidth * 44,
ctx->init_encode_params.darHeight * 45,
1024 * 1024);
ctx->init_encode_params.darHeight = dh;
ctx->init_encode_params.darWidth = dw;
}
ctx->init_encode_params.frameRateNum = avctx->time_base.den;
ctx->init_encode_params.frameRateDen = avctx->time_base.num * avctx->ticks_per_frame;
num_mbs = ((avctx->width + 15) >> 4) * ((avctx->height + 15) >> 4);
ctx->max_surface_count = (num_mbs >= 8160) ? 32 : 48;
if (ctx->buffer_delay >= ctx->max_surface_count)
ctx->buffer_delay = ctx->max_surface_count - 1;
ctx->init_encode_params.enableEncodeAsync = 0;
ctx->init_encode_params.enablePTD = 1;
ctx->init_encode_params.presetGUID = encoder_preset;
ctx->init_encode_params.encodeConfig = &ctx->encode_config;
memcpy(&ctx->encode_config, &preset_config.presetCfg, sizeof(ctx->encode_config));
ctx->encode_config.version = NV_ENC_CONFIG_VER;
if (avctx->refs >= 0) {
switch (avctx->codec->id) {
case AV_CODEC_ID_H264:
ctx->encode_config.encodeCodecConfig.h264Config.maxNumRefFrames = avctx->refs;
break;
case AV_CODEC_ID_H265:
ctx->encode_config.encodeCodecConfig.hevcConfig.maxNumRefFramesInDPB = avctx->refs;
break;
}
}
if (avctx->gop_size > 0) {
if (avctx->max_b_frames >= 0) {
ctx->encode_config.frameIntervalP = avctx->max_b_frames + 1;
}
ctx->encode_config.gopLength = avctx->gop_size;
switch (avctx->codec->id) {
case AV_CODEC_ID_H264:
ctx->encode_config.encodeCodecConfig.h264Config.idrPeriod = avctx->gop_size;
break;
case AV_CODEC_ID_H265:
ctx->encode_config.encodeCodecConfig.hevcConfig.idrPeriod = avctx->gop_size;
break;
}
} else if (avctx->gop_size == 0) {
ctx->encode_config.frameIntervalP = 0;
ctx->encode_config.gopLength = 1;
switch (avctx->codec->id) {
case AV_CODEC_ID_H264:
ctx->encode_config.encodeCodecConfig.h264Config.idrPeriod = 1;
break;
case AV_CODEC_ID_H265:
ctx->encode_config.encodeCodecConfig.hevcConfig.idrPeriod = 1;
break;
}
}
if (ctx->encode_config.frameIntervalP >= 2)
ctx->last_dts = -2;
if (avctx->bit_rate > 0) {
ctx->encode_config.rcParams.averageBitRate = avctx->bit_rate;
} else if (ctx->encode_config.rcParams.averageBitRate > 0) {
ctx->encode_config.rcParams.maxBitRate = ctx->encode_config.rcParams.averageBitRate;
}
if (avctx->rc_max_rate > 0)
ctx->encode_config.rcParams.maxBitRate = avctx->rc_max_rate;
if (lossless) {
if (avctx->codec->id == AV_CODEC_ID_H264)
ctx->encode_config.encodeCodecConfig.h264Config.qpPrimeYZeroTransformBypassFlag = 1;
ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CONSTQP;
ctx->encode_config.rcParams.constQP.qpInterB = 0;
ctx->encode_config.rcParams.constQP.qpInterP = 0;
ctx->encode_config.rcParams.constQP.qpIntra = 0;
avctx->qmin = -1;
avctx->qmax = -1;
} else if (ctx->cbr) {
if (!ctx->twopass) {
ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CBR;
} else {
ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_2_PASS_QUALITY;
if (avctx->codec->id == AV_CODEC_ID_H264) {
ctx->encode_config.encodeCodecConfig.h264Config.adaptiveTransformMode = NV_ENC_H264_ADAPTIVE_TRANSFORM_ENABLE;
ctx->encode_config.encodeCodecConfig.h264Config.fmoMode = NV_ENC_H264_FMO_DISABLE;
}
}
if (avctx->codec->id == AV_CODEC_ID_H264) {
ctx->encode_config.encodeCodecConfig.h264Config.outputBufferingPeriodSEI = 1;
ctx->encode_config.encodeCodecConfig.h264Config.outputPictureTimingSEI = 1;
} else if(avctx->codec->id == AV_CODEC_ID_H265) {
ctx->encode_config.encodeCodecConfig.hevcConfig.outputBufferingPeriodSEI = 1;
ctx->encode_config.encodeCodecConfig.hevcConfig.outputPictureTimingSEI = 1;
}
} else if (avctx->global_quality > 0) {
ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CONSTQP;
ctx->encode_config.rcParams.constQP.qpInterB = avctx->global_quality;
ctx->encode_config.rcParams.constQP.qpInterP = avctx->global_quality;
ctx->encode_config.rcParams.constQP.qpIntra = avctx->global_quality;
avctx->qmin = -1;
avctx->qmax = -1;
} else {
if (avctx->qmin >= 0 && avctx->qmax >= 0) {
ctx->encode_config.rcParams.enableMinQP = 1;
ctx->encode_config.rcParams.enableMaxQP = 1;
ctx->encode_config.rcParams.minQP.qpInterB = avctx->qmin;
ctx->encode_config.rcParams.minQP.qpInterP = avctx->qmin;
ctx->encode_config.rcParams.minQP.qpIntra = avctx->qmin;
ctx->encode_config.rcParams.maxQP.qpInterB = avctx->qmax;
ctx->encode_config.rcParams.maxQP.qpInterP = avctx->qmax;
ctx->encode_config.rcParams.maxQP.qpIntra = avctx->qmax;
qp_inter_p = (avctx->qmax + 3 * avctx->qmin) / 4;
if (ctx->twopass) {
ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_2_PASS_VBR;
if (avctx->codec->id == AV_CODEC_ID_H264) {
ctx->encode_config.encodeCodecConfig.h264Config.adaptiveTransformMode = NV_ENC_H264_ADAPTIVE_TRANSFORM_ENABLE;
ctx->encode_config.encodeCodecConfig.h264Config.fmoMode = NV_ENC_H264_FMO_DISABLE;
}
} else {
ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_VBR_MINQP;
}
} else {
qp_inter_p = 26;
if (ctx->twopass) {
ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_2_PASS_VBR;
} else {
ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_VBR;
}
}
ctx->encode_config.rcParams.enableInitialRCQP = 1;
ctx->encode_config.rcParams.initialRCQP.qpInterP = qp_inter_p;
if(avctx->i_quant_factor != 0.0 && avctx->b_quant_factor != 0.0) {
ctx->encode_config.rcParams.initialRCQP.qpIntra = av_clip(
qp_inter_p * fabs(avctx->i_quant_factor) + avctx->i_quant_offset, 0, 51);
ctx->encode_config.rcParams.initialRCQP.qpInterB = av_clip(
qp_inter_p * fabs(avctx->b_quant_factor) + avctx->b_quant_offset, 0, 51);
} else {
ctx->encode_config.rcParams.initialRCQP.qpIntra = qp_inter_p;
ctx->encode_config.rcParams.initialRCQP.qpInterB = qp_inter_p;
}
}
if (avctx->rc_buffer_size > 0) {
ctx->encode_config.rcParams.vbvBufferSize = avctx->rc_buffer_size;
} else if (ctx->encode_config.rcParams.averageBitRate > 0) {
ctx->encode_config.rcParams.vbvBufferSize = 2 * ctx->encode_config.rcParams.averageBitRate;
}
if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
ctx->encode_config.frameFieldMode = NV_ENC_PARAMS_FRAME_FIELD_MODE_FIELD;
} else {
ctx->encode_config.frameFieldMode = NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME;
}
switch (avctx->codec->id) {
case AV_CODEC_ID_H264:
ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.colourMatrix = avctx->colorspace;
ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.colourPrimaries = avctx->color_primaries;
ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.transferCharacteristics = avctx->color_trc;
ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.videoFullRangeFlag = (avctx->color_range == AVCOL_RANGE_JPEG
|| avctx->pix_fmt == AV_PIX_FMT_YUVJ420P || avctx->pix_fmt == AV_PIX_FMT_YUVJ422P || avctx->pix_fmt == AV_PIX_FMT_YUVJ444P);
ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.colourDescriptionPresentFlag =
(avctx->colorspace != 2 || avctx->color_primaries != 2 || avctx->color_trc != 2);
ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.videoSignalTypePresentFlag =
(ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.colourDescriptionPresentFlag
|| ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.videoFormat != 5
|| ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.videoFullRangeFlag != 0);
ctx->encode_config.encodeCodecConfig.h264Config.sliceMode = 3;
ctx->encode_config.encodeCodecConfig.h264Config.sliceModeData = 1;
ctx->encode_config.encodeCodecConfig.h264Config.disableSPSPPS = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0;
ctx->encode_config.encodeCodecConfig.h264Config.repeatSPSPPS = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 0 : 1;
ctx->encode_config.encodeCodecConfig.h264Config.outputAUD = 1;
if (!ctx->profile && !lossless) {
switch (avctx->profile) {
case FF_PROFILE_H264_HIGH_444_PREDICTIVE:
ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_444_GUID;
break;
case FF_PROFILE_H264_BASELINE:
ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_BASELINE_GUID;
break;
case FF_PROFILE_H264_MAIN:
ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_MAIN_GUID;
break;
case FF_PROFILE_H264_HIGH:
case FF_PROFILE_UNKNOWN:
ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID;
break;
default:
av_log(avctx, AV_LOG_WARNING, "Unsupported profile requested, falling back to high\n");
ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID;
break;
}
} else if(!lossless) {
if (!strcmp(ctx->profile, "high")) {
ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID;
avctx->profile = FF_PROFILE_H264_HIGH;
} else if (!strcmp(ctx->profile, "main")) {
ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_MAIN_GUID;
avctx->profile = FF_PROFILE_H264_MAIN;
} else if (!strcmp(ctx->profile, "baseline")) {
ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_BASELINE_GUID;
avctx->profile = FF_PROFILE_H264_BASELINE;
} else if (!strcmp(ctx->profile, "high444p")) {
ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_444_GUID;
avctx->profile = FF_PROFILE_H264_HIGH_444_PREDICTIVE;
} else {
av_log(avctx, AV_LOG_FATAL, "Profile \"%s\" is unknown! Supported profiles: high, main, baseline\n", ctx->profile);
res = AVERROR(EINVAL);
goto error;
}
}
if (avctx->pix_fmt == AV_PIX_FMT_YUV444P) {
ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_444_GUID;
avctx->profile = FF_PROFILE_H264_HIGH_444_PREDICTIVE;
}
ctx->encode_config.encodeCodecConfig.h264Config.chromaFormatIDC = avctx->profile == FF_PROFILE_H264_HIGH_444_PREDICTIVE ? 3 : 1;
if (ctx->level) {
res = input_string_to_uint32(avctx, nvenc_h264_level_pairs, ctx->level, &ctx->encode_config.encodeCodecConfig.h264Config.level);
if (res) {
av_log(avctx, AV_LOG_FATAL, "Level \"%s\" is unknown! Supported levels: auto, 1, 1b, 1.1, 1.2, 1.3, 2, 2.1, 2.2, 3, 3.1, 3.2, 4, 4.1, 4.2, 5, 5.1\n", ctx->level);
goto error;
}
} else {
ctx->encode_config.encodeCodecConfig.h264Config.level = NV_ENC_LEVEL_AUTOSELECT;
}
break;
case AV_CODEC_ID_H265:
ctx->encode_config.encodeCodecConfig.hevcConfig.hevcVUIParameters.colourMatrix = avctx->colorspace;
ctx->encode_config.encodeCodecConfig.hevcConfig.hevcVUIParameters.colourPrimaries = avctx->color_primaries;
ctx->encode_config.encodeCodecConfig.hevcConfig.hevcVUIParameters.transferCharacteristics = avctx->color_trc;
ctx->encode_config.encodeCodecConfig.hevcConfig.hevcVUIParameters.videoFullRangeFlag = (avctx->color_range == AVCOL_RANGE_JPEG
|| avctx->pix_fmt == AV_PIX_FMT_YUVJ420P || avctx->pix_fmt == AV_PIX_FMT_YUVJ422P || avctx->pix_fmt == AV_PIX_FMT_YUVJ444P);
ctx->encode_config.encodeCodecConfig.hevcConfig.hevcVUIParameters.colourDescriptionPresentFlag =
(avctx->colorspace != 2 || avctx->color_primaries != 2 || avctx->color_trc != 2);
ctx->encode_config.encodeCodecConfig.hevcConfig.hevcVUIParameters.videoSignalTypePresentFlag =
(ctx->encode_config.encodeCodecConfig.hevcConfig.hevcVUIParameters.colourDescriptionPresentFlag
|| ctx->encode_config.encodeCodecConfig.hevcConfig.hevcVUIParameters.videoFormat != 5
|| ctx->encode_config.encodeCodecConfig.hevcConfig.hevcVUIParameters.videoFullRangeFlag != 0);
ctx->encode_config.encodeCodecConfig.hevcConfig.sliceMode = 3;
ctx->encode_config.encodeCodecConfig.hevcConfig.sliceModeData = 1;
ctx->encode_config.encodeCodecConfig.hevcConfig.disableSPSPPS = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0;
ctx->encode_config.encodeCodecConfig.hevcConfig.repeatSPSPPS = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 0 : 1;
ctx->encode_config.encodeCodecConfig.hevcConfig.outputAUD = 1;
ctx->encode_config.profileGUID = NV_ENC_HEVC_PROFILE_MAIN_GUID;
avctx->profile = FF_PROFILE_HEVC_MAIN;
if (ctx->level) {
res = input_string_to_uint32(avctx, nvenc_hevc_level_pairs, ctx->level, &ctx->encode_config.encodeCodecConfig.hevcConfig.level);
if (res) {
av_log(avctx, AV_LOG_FATAL, "Level \"%s\" is unknown! Supported levels: auto, 1, 2, 2.1, 3, 3.1, 4, 4.1, 5, 5.1, 5.2, 6, 6.1, 6.2\n", ctx->level);
goto error;
}
} else {
ctx->encode_config.encodeCodecConfig.hevcConfig.level = NV_ENC_LEVEL_AUTOSELECT;
}
if (ctx->tier) {
if (!strcmp(ctx->tier, "main")) {
ctx->encode_config.encodeCodecConfig.hevcConfig.tier = NV_ENC_TIER_HEVC_MAIN;
} else if (!strcmp(ctx->tier, "high")) {
ctx->encode_config.encodeCodecConfig.hevcConfig.tier = NV_ENC_TIER_HEVC_HIGH;
} else {
av_log(avctx, AV_LOG_FATAL, "Tier \"%s\" is unknown! Supported tiers: main, high\n", ctx->tier);
res = AVERROR(EINVAL);
goto error;
}
}
break;
}
nv_status = p_nvenc->nvEncInitializeEncoder(ctx->nvencoder, &ctx->init_encode_params);
if (nv_status != NV_ENC_SUCCESS) {
av_log(avctx, AV_LOG_FATAL, "InitializeEncoder failed: 0x%x\n", (int)nv_status);
res = AVERROR_EXTERNAL;
goto error;
}
ctx->input_surfaces = av_malloc(ctx->max_surface_count * sizeof(*ctx->input_surfaces));
if (!ctx->input_surfaces) {
res = AVERROR(ENOMEM);
goto error;
}
ctx->output_surfaces = av_malloc(ctx->max_surface_count * sizeof(*ctx->output_surfaces));
if (!ctx->output_surfaces) {
res = AVERROR(ENOMEM);
goto error;
}
for (surfaceCount = 0; surfaceCount < ctx->max_surface_count; ++surfaceCount) {
NV_ENC_CREATE_INPUT_BUFFER allocSurf = { 0 };
NV_ENC_CREATE_BITSTREAM_BUFFER allocOut = { 0 };
allocSurf.version = NV_ENC_CREATE_INPUT_BUFFER_VER;
allocOut.version = NV_ENC_CREATE_BITSTREAM_BUFFER_VER;
allocSurf.width = (avctx->width + 31) & ~31;
allocSurf.height = (avctx->height + 31) & ~31;
allocSurf.memoryHeap = NV_ENC_MEMORY_HEAP_SYSMEM_CACHED;
switch (avctx->pix_fmt) {
case AV_PIX_FMT_YUV420P:
allocSurf.bufferFmt = NV_ENC_BUFFER_FORMAT_YV12_PL;
break;
case AV_PIX_FMT_NV12:
allocSurf.bufferFmt = NV_ENC_BUFFER_FORMAT_NV12_PL;
break;
case AV_PIX_FMT_YUV444P:
allocSurf.bufferFmt = NV_ENC_BUFFER_FORMAT_YUV444_PL;
break;
default:
av_log(avctx, AV_LOG_FATAL, "Invalid input pixel format\n");
res = AVERROR(EINVAL);
goto error;
}
nv_status = p_nvenc->nvEncCreateInputBuffer(ctx->nvencoder, &allocSurf);
if (nv_status != NV_ENC_SUCCESS) {
av_log(avctx, AV_LOG_FATAL, "CreateInputBuffer failed\n");
res = AVERROR_EXTERNAL;
goto error;
}
ctx->input_surfaces[surfaceCount].lockCount = 0;
ctx->input_surfaces[surfaceCount].input_surface = allocSurf.inputBuffer;
ctx->input_surfaces[surfaceCount].format = allocSurf.bufferFmt;
ctx->input_surfaces[surfaceCount].width = allocSurf.width;
ctx->input_surfaces[surfaceCount].height = allocSurf.height;
allocOut.size = 1024 * 1024;
allocOut.memoryHeap = NV_ENC_MEMORY_HEAP_SYSMEM_CACHED;
nv_status = p_nvenc->nvEncCreateBitstreamBuffer(ctx->nvencoder, &allocOut);
if (nv_status != NV_ENC_SUCCESS) {
av_log(avctx, AV_LOG_FATAL, "CreateBitstreamBuffer failed\n");
ctx->output_surfaces[surfaceCount++].output_surface = NULL;
res = AVERROR_EXTERNAL;
goto error;
}
ctx->output_surfaces[surfaceCount].output_surface = allocOut.bitstreamBuffer;
ctx->output_surfaces[surfaceCount].size = allocOut.size;
ctx->output_surfaces[surfaceCount].busy = 0;
}
if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
uint32_t outSize = 0;
char tmpHeader[256];
NV_ENC_SEQUENCE_PARAM_PAYLOAD payload = { 0 };
payload.version = NV_ENC_SEQUENCE_PARAM_PAYLOAD_VER;
payload.spsppsBuffer = tmpHeader;
payload.inBufferSize = sizeof(tmpHeader);
payload.outSPSPPSPayloadSize = &outSize;
nv_status = p_nvenc->nvEncGetSequenceParams(ctx->nvencoder, &payload);
if (nv_status != NV_ENC_SUCCESS) {
av_log(avctx, AV_LOG_FATAL, "GetSequenceParams failed\n");
goto error;
}
avctx->extradata_size = outSize;
avctx->extradata = av_mallocz(outSize + AV_INPUT_BUFFER_PADDING_SIZE);
if (!avctx->extradata) {
res = AVERROR(ENOMEM);
goto error;
}
memcpy(avctx->extradata, tmpHeader, outSize);
}
if (ctx->encode_config.frameIntervalP > 1)
avctx->has_b_frames = 2;
if (ctx->encode_config.rcParams.averageBitRate > 0)
avctx->bit_rate = ctx->encode_config.rcParams.averageBitRate;
cpb_props = ff_add_cpb_side_data(avctx);
if (!cpb_props)
return AVERROR(ENOMEM);
cpb_props->max_bitrate = ctx->encode_config.rcParams.maxBitRate;
cpb_props->avg_bitrate = avctx->bit_rate;
cpb_props->buffer_size = ctx->encode_config.rcParams.vbvBufferSize;
return 0;
error:
for (i = 0; i < surfaceCount; ++i) {
p_nvenc->nvEncDestroyInputBuffer(ctx->nvencoder, ctx->input_surfaces[i].input_surface);
if (ctx->output_surfaces[i].output_surface)
p_nvenc->nvEncDestroyBitstreamBuffer(ctx->nvencoder, ctx->output_surfaces[i].output_surface);
}
if (ctx->nvencoder)
p_nvenc->nvEncDestroyEncoder(ctx->nvencoder);
if (ctx->cu_context)
dl_fn->cu_ctx_destroy(ctx->cu_context);
nvenc_unload_nvenc(avctx);
ctx->nvencoder = NULL;
ctx->cu_context = NULL;
return res;
}
| 1threat |
How an IoT sensor based device communicates with the cloud? : <p>So, how does an IoT sensor based device communicates with the cloud?
Does it uses Google Cloud Internet of Things or WSO2 or something similar and where is this API running from?</p>
<p>Thanks in advance</p>
| 0debug |
SyntaxError: import declarations may only appear at top level of a module : <p>I am trying to use a plugin called "Simplebar" found on GitHub, <a href="https://github.com/Grsmto/simplebar" rel="noreferrer">GitHub SimpleBar</a> but after downloading the scripts and looking at the simple.js script, it looks like it has an error "SyntaxError: import declarations may only appear at top level of a module"</p>
<p>At the top of the simplebar.js file there are some import lines of code:</p>
<pre><code>import scrollbarWidth from 'scrollbarwidth'
import debounce from 'lodash.debounce'
import './simplebar.css'
</code></pre>
<p>If I look in my browser debugger I see an error: "SyntaxError: import declarations may only appear at top level of a module".</p>
<p>Has anyone tried to us this plugin.</p>
<p>Many thanks in advance for your time.</p>
| 0debug |
Module location of self-written perl module : I am trying to use my module in a script.
I know that you have to provide a module location and would like to provide the path in the script. However, I get the error message:
No such file or directory
this is my script:
use strict;
use warnings;
use lib "C:/Users/XPS13/Documents/Uni/UEProgramming";
use Bioinformatics;
my $DNAinput = "restriction_test.txt";
open (my $FH_DNA_in, "<", $DNAinput) or die " Can't open file $DNAinput: $!\n";
print "Pattern match for input file \n";
print (Bioinformatics::Pattern($FH_DNA_in), "\n"); # applying module function
and this is my module
package Bioinformatics; # making module, 1st line contains name
use strict; # module uses strict and warnings
use warnings;
sub Pattern {
my $count = "0";
my ($DNAinput) = @_;
open (my $FH_DNA_in, "<", $DNAinput) or die " Can't open file $DNAinput: $!\n";
while (my $line = <$FH_DNA_in>) {
if ($line =~ /[AG]GATC[TC]/ ) {
++ $count;
}
}
print "Your sequence contains the pattern [AG]GATC[TC] $count times\n";
}
1; # last line
| 0debug |
Should I learn Actionscript 3 along with Javascript to make web games? : <p>Hello(my first post on stack overflow)
I wanted to ask that should I learn Actionscript 3 or not, Am Already learning Javascript on Codecademy (20% completed). Someone suggested me to learn AC 3 and get the Flixel tuotorials on new grounds,Should I learn AS3 along or just focus on JS. Purpose for learning a language is to make 2d scroller web games,that works on smart phones and tablets.</p>
| 0debug |
java try-with-resource not working with scala : <p>In Scala application, am trying to read lines from a file using java nio try-with-resource construct.</p>
<p>Scala version 2.11.8<br>
Java version 1.8</p>
<pre><code>try(Stream<String> stream = Files.lines(Paths.get("somefile.txt"))){
stream.forEach(System.out::println); // will do business process here
}catch (IOException e) {
e.printStackTrace(); // will handle failure case here
}
</code></pre>
<p>But the compiler throws error like<br>
◾not found: value stream<br>
◾A try without a catch or finally is equivalent to putting its body in a block; no exceptions are handled.</p>
<p>Not sure what is the problem. Am new to using Java NIO, so any help is much appreciated.</p>
| 0debug |
static coroutine_fn void nbd_co_client_start(void *opaque)
{
NBDClientNewData *data = opaque;
NBDClient *client = data->client;
NBDExport *exp = client->exp;
if (exp) {
nbd_export_get(exp);
QTAILQ_INSERT_TAIL(&exp->clients, client, next);
}
qemu_co_mutex_init(&client->send_lock);
if (nbd_negotiate(data)) {
client_close(client);
goto out;
}
nbd_client_receive_next_request(client);
out:
g_free(data);
}
| 1threat |
int vhdx_parse_log(BlockDriverState *bs, BDRVVHDXState *s, bool *flushed,
Error **errp)
{
int ret = 0;
VHDXHeader *hdr;
VHDXLogSequence logs = { 0 };
hdr = s->headers[s->curr_header];
*flushed = false;
if (s->log.hdr == NULL) {
s->log.hdr = qemu_blockalign(bs, sizeof(VHDXLogEntryHeader));
}
s->log.offset = hdr->log_offset;
s->log.length = hdr->log_length;
if (s->log.offset < VHDX_LOG_MIN_SIZE ||
s->log.offset % VHDX_LOG_MIN_SIZE) {
ret = -EINVAL;
goto exit;
}
if (hdr->log_version != 0) {
ret = -EINVAL;
goto exit;
}
if (guid_eq(hdr->log_guid, zero_guid)) {
goto exit;
}
if (hdr->log_length == 0) {
goto exit;
}
if (hdr->log_length % VHDX_LOG_MIN_SIZE) {
ret = -EINVAL;
goto exit;
}
ret = vhdx_log_search(bs, s, &logs);
if (ret < 0) {
goto exit;
}
if (logs.valid) {
if (bs->read_only) {
ret = -EPERM;
error_setg_errno(errp, EPERM,
"VHDX image file '%s' opened read-only, but "
"contains a log that needs to be replayed. To "
"replay the log, execute:\n qemu-img check -r "
"all '%s'",
bs->filename, bs->filename);
goto exit;
}
ret = vhdx_log_flush(bs, s, &logs);
if (ret < 0) {
goto exit;
}
*flushed = true;
}
exit:
return ret;
}
| 1threat |
Python| kee/value pair not incrementing : I'm fairly knew to Python so I'm following along using the Head First Python 2nd edition. I come across an example I'm completely stumped on and I was wondering that I'm doing wrong as I'm following along just right. I've done some research on the internet on how to properly increment a key/value pair in dictionary and I seem to be doing it right so not sure what is going on. Here is what I have running: Python 3.5.2. on Mac OS Sierra.
fruits = {}
fruits['apples'] = 10
if 'bananas' in fruits:
fruits['bananas'] += 1
else:
fruits['bananas'] = 1
Initially when I print fruits it show bananas 1, apples 10 but the second time I print fruits it should show bananas 2 but it doesn't and only show 1. Its not increasing.
Thank you for your knowledge. | 0debug |
Checking internet connection on click button : <p>I'd like to create a button to go to another activity for webview. Before going to the next activity I like to check internet connection:
if device is connected, OK, go to the next activity.
if not, Toast a message like this "No Internet Connection". However, I don't want the device go to the respected activity.
I've tried different method explained in this website but didn't work.
Tnx a bunch guys.</p>
| 0debug |
static int read_dialogue(ASSContext *ass, AVBPrint *dst, const uint8_t *p,
int64_t *start, int *duration)
{
int pos;
int64_t end;
int hh1, mm1, ss1, ms1;
int hh2, mm2, ss2, ms2;
if (sscanf(p, "Dialogue: %*[^,],%d:%d:%d%*c%d,%d:%d:%d%*c%d,%n",
&hh1, &mm1, &ss1, &ms1,
&hh2, &mm2, &ss2, &ms2, &pos) >= 8) {
const int layer = atoi(p + 10);
end = (hh2*3600LL + mm2*60LL + ss2) * 100LL + ms2;
*start = (hh1*3600LL + mm1*60LL + ss1) * 100LL + ms1;
*duration = end - *start;
av_bprint_clear(dst);
av_bprintf(dst, "%u,%d,%s", ass->readorder++, layer, p + pos);
while (dst->len > 0 &&
dst->str[dst->len - 1] == '\r' ||
dst->str[dst->len - 1] == '\n')
dst->str[--dst->len] = 0;
return 0;
}
return -1;
}
| 1threat |
static uint64_t omap_rtc_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
struct omap_rtc_s *s = (struct omap_rtc_s *) opaque;
int offset = addr & OMAP_MPUI_REG_MASK;
uint8_t i;
if (size != 1) {
return omap_badwidth_read8(opaque, addr);
}
switch (offset) {
case 0x00:
return to_bcd(s->current_tm.tm_sec);
case 0x04:
return to_bcd(s->current_tm.tm_min);
case 0x08:
if (s->pm_am)
return ((s->current_tm.tm_hour > 11) << 7) |
to_bcd(((s->current_tm.tm_hour - 1) % 12) + 1);
else
return to_bcd(s->current_tm.tm_hour);
case 0x0c:
return to_bcd(s->current_tm.tm_mday);
case 0x10:
return to_bcd(s->current_tm.tm_mon + 1);
case 0x14:
return to_bcd(s->current_tm.tm_year % 100);
case 0x18:
return s->current_tm.tm_wday;
case 0x20:
return to_bcd(s->alarm_tm.tm_sec);
case 0x24:
return to_bcd(s->alarm_tm.tm_min);
case 0x28:
if (s->pm_am)
return ((s->alarm_tm.tm_hour > 11) << 7) |
to_bcd(((s->alarm_tm.tm_hour - 1) % 12) + 1);
else
return to_bcd(s->alarm_tm.tm_hour);
case 0x2c:
return to_bcd(s->alarm_tm.tm_mday);
case 0x30:
return to_bcd(s->alarm_tm.tm_mon + 1);
case 0x34:
return to_bcd(s->alarm_tm.tm_year % 100);
case 0x40:
return (s->pm_am << 3) | (s->auto_comp << 2) |
(s->round << 1) | s->running;
case 0x44:
i = s->status;
s->status &= ~0x3d;
return i;
case 0x48:
return s->interrupts;
case 0x4c:
return ((uint16_t) s->comp_reg) & 0xff;
case 0x50:
return ((uint16_t) s->comp_reg) >> 8;
}
OMAP_BAD_REG(addr);
return 0;
}
| 1threat |
Passing file content into memory is faulty. I have tried over and over and I am a bit stuck :
I am wondering why while I think I make the function call to load appropriately,
it seems that fread cannot read into my chunk of memory correctly and so it creates a segmentation fault[in load function]!Please point me to the right approach
The link to the code is https://www.onlinegdb.com/BJiHlFwUZ
Thank you
| 0debug |
How to mount docker volume with jenkins docker container? : <p>I have jenkins running inside container and project source code on github.</p>
<p>I need to run project in container on the same host as jenkins, but not as docker-in-docker, i want to run them as sibling containers.</p>
<p>My pipeline looks like this:</p>
<ol>
<li>pull the source from github</li>
<li>build the project image</li>
<li>run the project container</li>
</ol>
<p>What i do right now is using the docker socket of host from jenkins container:</p>
<pre><code>/var/run/docker.sock:/var/run/docker.sock
</code></pre>
<p>I have problem when jenkins container mount the volume with source code from /var/jenkins_home/workspace/BRANCH_NAME to project container:</p>
<pre><code>volumes:
- ./servers/identity/app:/srv/app
</code></pre>
<p>i am getting empty folder "/srv/app" in project container</p>
<p>My best guess is that docker tries to mount it from host and not from the jenkins container.</p>
<p>So the question is: how can i explicitly set the container from which i mount the volume? </p>
| 0debug |
EXCEL MACRO - FILTERS : Greetings.
I am trying to write a MACRO in EXCEL.
I have multiple sheets and I want to filter based on the YELLOW fill color.
How do I write macro for this ? My apologies if my question sounds dumb but I really want to learn MACROS in Excel.
Best regards,
Babar | 0debug |
Chagne text box border color in login page as in gmail : I am developing a login page having input filed functionality similar to gmail input field i.e. in focus mode input field should be blue and when validation fails it changes into red, please help.
Many-Many Thanks in advance… | 0debug |
static void channel_event(int event, SpiceChannelEventInfo *info)
{
SpiceServerInfo *server = g_malloc0(sizeof(*server));
SpiceChannel *client = g_malloc0(sizeof(*client));
server->base = g_malloc0(sizeof(*server->base));
client->base = g_malloc0(sizeof(*client->base));
bool need_lock = !qemu_thread_is_self(&me);
if (need_lock) {
qemu_mutex_lock_iothread();
}
if (info->flags & SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT) {
add_addr_info(client->base, (struct sockaddr *)&info->paddr_ext,
info->plen_ext);
add_addr_info(server->base, (struct sockaddr *)&info->laddr_ext,
info->llen_ext);
} else {
error_report("spice: %s, extended address is expected",
__func__);
}
switch (event) {
case SPICE_CHANNEL_EVENT_CONNECTED:
qapi_event_send_spice_connected(server->base, client->base, &error_abort);
break;
case SPICE_CHANNEL_EVENT_INITIALIZED:
if (auth) {
server->has_auth = true;
server->auth = g_strdup(auth);
}
add_channel_info(client, info);
channel_list_add(info);
qapi_event_send_spice_initialized(server, client, &error_abort);
break;
case SPICE_CHANNEL_EVENT_DISCONNECTED:
channel_list_del(info);
qapi_event_send_spice_disconnected(server->base, client->base, &error_abort);
break;
default:
break;
}
if (need_lock) {
qemu_mutex_unlock_iothread();
}
qapi_free_SpiceServerInfo(server);
qapi_free_SpiceChannel(client);
}
| 1threat |
shortcut for typing kubectl --all-namespaces everytime : <p>Is there any alias we can make for all-namespace as kubectl don't recognise the command <code>kubectl --all-namespaces</code> or any kind of shortcut to minimize the typing of the whole command.</p>
| 0debug |
enum AVCodecID avpriv_fmt_v4l2codec(uint32_t v4l2_fmt)
{
int i;
for (i = 0; avpriv_fmt_conversion_table[i].codec_id != AV_CODEC_ID_NONE; i++) {
if (avpriv_fmt_conversion_table[i].v4l2_fmt == v4l2_fmt) {
return avpriv_fmt_conversion_table[i].codec_id;
}
}
return AV_CODEC_ID_NONE;
}
| 1threat |
How can build my react app to put in a server? : <p>i just finish my first website using react and I gonna put in my server(hostgator), how can I build it?? thanks</p>
| 0debug |
how to heck if the record exist in xamarin : Data Helper
public bool insertIntoTablePerson(Person person)
{
try
{
using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "Persons.db")))
{
connection.Insert(person);
return true;
}
}
catch (SQLiteException ex)
{
Log.Info("SQLiteEx", ex.Message);
return false;
}
}
| 0debug |
Vue.js routes serving from subdirectory : <p>I would like to serve my Vue.js app from a subdirectory on a staging server. For example: <a href="http://url.com/subdir/app/" rel="noreferrer">http://url.com/subdir/app/</a></p>
<p>Right now if I do this and set up the build config assetsPublicPath to serve from that folder, all the assets are served fine but my app does not get routed correctly. The "home" page gets routed to the 'catch-all', and any further routes simply show the normal white-page 404.</p>
<p>Here is my router:</p>
<pre><code>export default new Router({
mode: 'history',
routes: [
{
path: '/',
component: ContentView,
children: [
{
path: '/',
name: 'DataTable',
component: DataTable,
meta: { requiresAuth: true }
},
// ===================================
// Login
// ===================================
{
path: '/login',
name: 'AppLogin',
component: AppLogin,
meta: { checkAlreadyLoggedIn: true }
},
{
path: '/logout',
name: 'AppLogout',
component: AppLogout,
meta: { requiresAuth: true }
}
]
},
{
path: '*',
component: ContentView,
children: [
{
path: '/',
name: 'NotFound',
component: NotFound
}
]
}
]})
</code></pre>
<p>And here is the necessary config/index.js changes: <code>assetsPublicPath: '/subdir/app/'</code></p>
<p>In local development the routes work fine. But on the staging server all static assets, the built JS and CSS etc all serve fine. However the home route shows the catch-all. I am assuming it's because my routes are not set up correctly, or because I need to do something to serve from a subdirectory in production.</p>
| 0debug |
how to select a table by parameters in jasper report using java in eclipse? : i have a button . when i hit it . it create a table in database with name+billno+date. and inserts all details like product name and etc into database.
now i want to when the new table is created , after that jasper report fetch that newly created table and show it in table of jasper report.
for that i created a parameter.
Hashmap param = new Hashmap();
param.put("TABLE" , name+bill+date);
after that i created a table in jasper report and tried to do this query.
select * from $P{TABLE}
but it throws an error | 0debug |
Deleting undesired characters at the end of a char : <p>With this code below I dont know how to delete the undesired characters appearing at the end of the message array. It is compulsory for me to use char, can't use strings, because of the rest of my code.
recvbuf is also a char* recvbuf=new char</p>
<pre><code> char* message=new char[140];
for (int i=1; i<141; i++){
message[i-1]=recvbuf[i];
}
printf("Message: %s\n", message);
delete[]recvbuf;
</code></pre>
| 0debug |
static void error_callback_bh(void *opaque)
{
Coroutine *co = opaque;
qemu_coroutine_enter(co);
}
| 1threat |
Finding the average from user given list in python : <p>I need to get the user to input the grades of both "boys" and "girls" until they want to stop adding the grades. Than find the average of the boys grades and the average of the girls and print them both separately.</p>
<p>My issue is I don't understand how i'm supposed to make it so the user can add as many grades as they want for both the boys and the girls, and then get both of the averages.</p>
<p>I'm still very new to python and am not sure what the best method for this would be, like would I use <code>while</code> or <code>if</code> in some way that I haven't learned yet?</p>
| 0debug |
react-intl - accessing nested messages : <p>I'm trying to use <code>react-intl</code> package inside an app. The app is rendered on the server so I wrote some code to determine which language to use and serve into <code>IntlProvider</code>.</p>
<p>Translations were provided in <code>messages.js</code> file and they look like this:</p>
<pre><code>export default {
en: {
message: '...some message',
nested: {
anotherMessage: '...another message',
}
}
de: {
// ...
}
}
</code></pre>
<p>What I do is something like this:</p>
<pre><code>// import messages from './messages.js'
// Check the locale for the user (based on cookies or other things)
const locale = ...
// Get the required messages
const messagesForLocale= = messages[locale];
// Supply the messages to the IntlProvider
<IntlProvider locale={locale} messages={messagesForLocale}>
// ...
</IntlProvider>
</code></pre>
<p>Then when I use <code>FormattedMessage</code> component I can't access the nested message (<code>anotherMessage</code>) with code like this:</p>
<pre><code><FormattedMessage id="nested.anotherMessage" ... />
</code></pre>
<p>But <code>message</code> is accessible.</p>
<p>Any ideas where I made the mistake, or maybe I'm missing something in the whole concept?</p>
| 0debug |
How to get True/False mask from Pandas Series? : <p>I have a pandas Serie containing some strings</p>
<pre><code>s = pd.Series(['a', 'b', 'c', 'd', 'a'], index=[1, 2, 3, 4, 5])
</code></pre>
<p>How can I get a serie of True/False based on equality of a string?
For example I want to check the positions of all 'a' and from the example above I want to get as a result</p>
<pre><code>True, False, False, False, True
</code></pre>
| 0debug |
How to dispatch an Action or a ThunkAction (in TypeScript, with redux-thunk)? : <p>Say I have code like so:</p>
<pre><code>import { Action, Dispatch } from 'redux';
import { ThunkAction } from 'redux-thunk';
interface StateTree {
field: string;
}
function myFunc(action: Action | ThunkAction<void, StateTree, void>,
dispatch: Dispatch<StateTree>) {
dispatch(action); // <-- This is where the error comes from
}
</code></pre>
<p>...I get this error from the TypeScript compiler:</p>
<pre><code>ERROR in myFile.ts:x:y
TS2345: Argument of type 'Action | ThunkAction<void, StateTree, void>' is not assignable to parameter of type 'Action'.
Type 'ThunkAction<void, StateTree, void>' is not assignable to type 'Action'.
Property 'type' is missing in type 'ThunkAction<void, StateTree, void>'.
</code></pre>
<p>I believe the problem is because of the way the <code>redux-thunk</code> type definition file augments the <code>redux</code> <code>Dispatch</code> interface and the inability for TypeScript to know which definition of <code>Dispatch</code> to use.</p>
<p>Is there a way around this?</p>
| 0debug |
gen_set_condexec (DisasContext *s)
{
if (s->condexec_mask) {
uint32_t val = (s->condexec_cond << 4) | (s->condexec_mask >> 1);
TCGv tmp = new_tmp();
tcg_gen_movi_i32(tmp, val);
store_cpu_field(tmp, condexec_bits);
}
}
| 1threat |
Angular 6 - why is my component property (and thus console.log() value) still undefined after my API call method? : export class CaseStudyDetailComponent implements OnInit {
casestudy: CaseStudy;
constructor ( private caseStudyService: CaseStudyService, private route: ActivatedRoute, public titleService: Title ) { }
ngOnInit() {
this.route.params.subscribe((params: { Handle: string }) => {
this.caseStudyService.getCaseStudy(params.Handle).subscribe(casestudy => this.casestudy = casestudy);
});
console.log(this.casestudy);
}
} | 0debug |
How can I read data from file ? I can't fix it : <p>I record students informations to txt file but when I want to read data's from file
just read information's in the first row. Also I calculate the average of the students but when ı want to read average it's not working.</p>
<pre><code> FILE *fout;
fout = fopen("English Class.txt","w");
printf("Please enter student number of class : ");
scanf("%d", &x.classNum);
fprintf(fout, "Class Number : %d\n",x.classNum);
for(i=0; i<x.classNum; i++){
printf("Please Enter %d.Student Name : ",i+1);
scanf("%s",&x.Name);
printf("Please Enter %d.Student Surname : ",i+1);
scanf("%s",&x.Surname);
printf("Please Enter %d.Student Number : ",i+1);
scanf("%d",&x.StudentNumber);
printf("Please Enter %d.Student Score : ",i+1);
scanf("%d",&x.EnglishScore);
x.total = x.total + x.EnglishScore;
fprintf(fout, "\nStudent Name : %s %s Student Number : %d Student Score : %d\n", x.Name, x.Surname, x.StudentNumber, x.EnglishScore);
}
x.average = x.total / x.classNum;
fprintf(fout, "\n\nClass Average is : %f", x.average);
fclose(fout);
</code></pre>
<p>I get students records from top code</p>
<pre><code> FILE *fin;
fin = fopen("English Class.txt","r");
fscanf(fin, "Class Number : %d\nStudent Name : %s %s Student Number : %d Student Score : %d\n\nClass Average is : %f",&x.classNum, &x.Name, &x.Surname, &x.StudentNumber, &x.EnglishScore, &x.average);
fclose(fin);
printf("Class Number : %d\n", x.classNum);
for(i=0; i<x.classNum; i++){
fscanf(fin, "\nStudent Name : %s %s Student Number : %d Student Score : %d\n\nClass Average is : %f", &x.Name, &x.Surname, &x.StudentNumber, &x.EnglishScore);
fclose(fin);
printf("\nStudent Name : %s %s Student Number : %d Student Score : %d\n", x.Name, x.Surname, x.StudentNumber, x.EnglishScore);
}
printf("\n\nClass Average is : %f", x.average);
</code></pre>
| 0debug |
static uint32_t xen_platform_ioport_readb(void *opaque, uint32_t addr)
{
addr &= 0xff;
if (addr == 0) {
return platform_fixed_ioport_readb(opaque, XEN_PLATFORM_IOPORT);
} else {
return ~0u;
}
}
| 1threat |
How does Bash modulus/remainder work? : <p>Can somebody explain how it works? I just don't understand it. Why we get 2 from </p>
<pre><code>expr 5 % 3
</code></pre>
<p>or 1 from </p>
<pre><code>expr 5 % 4
</code></pre>
| 0debug |
How to get the previous Activty in android : we are in activity A and we do this following code :
if (previousActivity.equals("Activity 1 ") ) {
calling acvtivity B }
else if (previousActivity.equals("Activity 2 ") ) {
calling activity C }
Is it possible ?
thanks in advance | 0debug |
static SchroFrame *libschroedinger_frame_from_data(AVCodecContext *avctx,
const AVFrame *frame)
{
SchroEncoderParams *p_schro_params = avctx->priv_data;
SchroFrame *in_frame = ff_create_schro_frame(avctx,
p_schro_params->frame_format);
if (in_frame) {
if (av_frame_copy(in_frame->priv, frame) < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to copy input data\n");
return NULL;
}
}
return in_frame;
}
| 1threat |
ssize_t cpu_get_note_size(int class, int machine, int nr_cpus)
{
int name_size = 8;
size_t elf_note_size = 0;
int note_head_size;
const NoteFuncDesc *nf;
assert(class == ELFCLASS64);
assert(machine == EM_S390);
note_head_size = sizeof(Elf64_Nhdr);
for (nf = note_func; nf->note_contents_func; nf++) {
elf_note_size = elf_note_size + note_head_size + name_size +
nf->contents_size;
}
return (elf_note_size) * nr_cpus;
}
| 1threat |
static inline void RENAME(rgb16to32)(const uint8_t *src, uint8_t *dst, int src_size)
{
const uint16_t *end;
const uint16_t *mm_end;
uint8_t *d = dst;
const uint16_t *s = (const uint16_t*)src;
end = s + src_size/2;
__asm__ volatile(PREFETCH" %0"::"m"(*s):"memory");
__asm__ volatile("pxor %%mm7,%%mm7 \n\t":::"memory");
__asm__ volatile("pcmpeqd %%mm6,%%mm6 \n\t":::"memory");
mm_end = end - 3;
while (s < mm_end) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq %1, %%mm1 \n\t"
"movq %1, %%mm2 \n\t"
"pand %2, %%mm0 \n\t"
"pand %3, %%mm1 \n\t"
"pand %4, %%mm2 \n\t"
"psllq $3, %%mm0 \n\t"
"psrlq $3, %%mm1 \n\t"
"psrlq $8, %%mm2 \n\t"
PACK_RGB32
:"=m"(*d)
:"m"(*s),"m"(mask16b),"m"(mask16g),"m"(mask16r)
:"memory");
d += 16;
s += 4;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
while (s < end) {
register uint16_t bgr;
bgr = *s++;
*d++ = (bgr&0x1F)<<3;
*d++ = (bgr&0x7E0)>>3;
*d++ = (bgr&0xF800)>>8;
*d++ = 255;
}
}
| 1threat |
Replace all 'char' in string to 'charchar' : <p>Bumping into an issue when inserting data to SQLite. In SQLite we have to write two single quote(') when we want to add a value containing (').
<a href="https://stackoverflow.com/questions/12615113/how-to-escape-special-characters-like-in-sqlite-in-android/27082084">How to escape special characters like ' in sqlite in android</a></p>
<hr>
<h2>Question</h2>
<p>How to replace all (') in string to ('')?</p>
<blockquote>
<p>My bro's watch is 8 o'clock ==> My bro''s watch is 8 o''clock</p>
</blockquote>
<p>It's better if the answer is written in Swift.
Thank you!</p>
| 0debug |
static int RENAME(resample_linear)(ResampleContext *c,
DELEM *dst, const DELEM *src,
int n, int update_ctx)
{
int dst_index;
int index= c->index;
int frac= c->frac;
int sample_index = index >> c->phase_shift;
#if FILTER_SHIFT == 0
double inv_src_incr = 1.0 / c->src_incr;
#endif
index &= c->phase_mask;
for (dst_index = 0; dst_index < n; dst_index++) {
FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * index;
FELEM2 val=0, v2 = 0;
int i;
for (i = 0; i < c->filter_length; i++) {
val += src[sample_index + i] * (FELEM2)filter[i];
v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_alloc];
}
#ifdef FELEML
val += (v2 - val) * (FELEML) frac / c->src_incr;
#else
# if FILTER_SHIFT == 0
val += (v2 - val) * inv_src_incr * frac;
# else
val += (v2 - val) / c->src_incr * frac;
# endif
#endif
OUT(dst[dst_index], val);
frac += c->dst_incr_mod;
index += c->dst_incr_div;
if (frac >= c->src_incr) {
frac -= c->src_incr;
index++;
}
sample_index += index >> c->phase_shift;
index &= c->phase_mask;
}
if(update_ctx){
c->frac= frac;
c->index= index;
}
return sample_index;
}
| 1threat |
Securing Registration RESTful API against registering many users : <p>I am developing <code>RESTful APIs</code> with <code>ASP.NET WebAPI</code> for an <code>Android application</code> and there is an option to make a registration through our application. Suppose that our registration endpoint is something like '/api/register/' with some parameters like 'username', 'password' and 'email address'. So this endpoint is likely to be opened not only for Android device, but for everyone.</p>
<p>I mean it is easy to trace all the requests and responses to and from our server, so a bad person may calls this endpoint to start registering many users in our system.</p>
<p>I want to know how I can secure my API?</p>
| 0debug |
find firs reoccuring char in a string w/o using array and not picking a letter manually[JAVA] : i've looked through the posts but couldn't find the exact answer. This is the code i have. it only returns a value when i set s.CharAt(0) and then h will equl h. Bu t i wan't it to run automatically and w/o arrays. thank you
String s = "hellohe";
int d = s.length();
for (int i =0; i<d;i++)//{
char result=s.charAt(0);
if (result==s.charAt(i)){
System.out.println(result);
}
| 0debug |
static int oma_read_header(AVFormatContext *s)
{
int ret, framesize, jsflag, samplerate;
uint32_t codec_params, channel_id;
int16_t eid;
uint8_t buf[EA3_HEADER_SIZE];
uint8_t *edata;
AVStream *st;
ID3v2ExtraMeta *extra_meta = NULL;
OMAContext *oc = s->priv_data;
ff_id3v2_read(s, ID3v2_EA3_MAGIC, &extra_meta);
ret = avio_read(s->pb, buf, EA3_HEADER_SIZE);
if (ret < EA3_HEADER_SIZE)
return -1;
if (memcmp(buf, ((const uint8_t[]){'E', 'A', '3'}), 3) ||
buf[4] != 0 || buf[5] != EA3_HEADER_SIZE) {
av_log(s, AV_LOG_ERROR, "Couldn't find the EA3 header !\n");
return AVERROR_INVALIDDATA;
}
oc->content_start = avio_tell(s->pb);
eid = AV_RB16(&buf[6]);
if (eid != -1 && eid != -128 && decrypt_init(s, extra_meta, buf) < 0) {
ff_id3v2_free_extra_meta(&extra_meta);
return -1;
}
ff_id3v2_free_extra_meta(&extra_meta);
codec_params = AV_RB24(&buf[33]);
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->start_time = 0;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_tag = buf[32];
st->codec->codec_id = ff_codec_get_id(ff_oma_codec_tags,
st->codec->codec_tag);
switch (buf[32]) {
case OMA_CODECID_ATRAC3:
samplerate = ff_oma_srate_tab[(codec_params >> 13) & 7] * 100;
if (!samplerate) {
av_log(s, AV_LOG_ERROR, "Unsupported sample rate\n");
return AVERROR_INVALIDDATA;
}
if (samplerate != 44100)
avpriv_request_sample(s, "Sample rate %d", samplerate);
framesize = (codec_params & 0x3FF) * 8;
jsflag = (codec_params >> 17) & 1;
st->codec->channels = 2;
st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
st->codec->sample_rate = samplerate;
st->codec->bit_rate = st->codec->sample_rate * framesize * 8 / 1024;
if (ff_alloc_extradata(st->codec, 14))
return AVERROR(ENOMEM);
edata = st->codec->extradata;
AV_WL16(&edata[0], 1);
AV_WL32(&edata[2], samplerate);
AV_WL16(&edata[6], jsflag);
AV_WL16(&edata[8], jsflag);
AV_WL16(&edata[10], 1);
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
break;
case OMA_CODECID_ATRAC3P:
channel_id = (codec_params >> 10) & 7;
if (!channel_id) {
av_log(s, AV_LOG_ERROR,
"Invalid ATRAC-X channel id: %"PRIu32"\n", channel_id);
return AVERROR_INVALIDDATA;
}
st->codec->channel_layout = ff_oma_chid_to_native_layout[channel_id - 1];
st->codec->channels = ff_oma_chid_to_num_channels[channel_id - 1];
framesize = ((codec_params & 0x3FF) * 8) + 8;
samplerate = ff_oma_srate_tab[(codec_params >> 13) & 7] * 100;
if (!samplerate) {
av_log(s, AV_LOG_ERROR, "Unsupported sample rate\n");
return AVERROR_INVALIDDATA;
}
st->codec->sample_rate = samplerate;
st->codec->bit_rate = samplerate * framesize * 8 / 2048;
avpriv_set_pts_info(st, 64, 1, samplerate);
break;
case OMA_CODECID_MP3:
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
framesize = 1024;
break;
case OMA_CODECID_LPCM:
st->codec->channels = 2;
st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
st->codec->sample_rate = 44100;
framesize = 1024;
st->codec->bit_rate = st->codec->sample_rate * 32;
st->codec->bits_per_coded_sample =
av_get_bits_per_sample(st->codec->codec_id);
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
break;
default:
av_log(s, AV_LOG_ERROR, "Unsupported codec %d!\n", buf[32]);
return AVERROR(ENOSYS);
}
st->codec->block_align = framesize;
return 0;
}
| 1threat |
static void hScale8To19_c(SwsContext *c, int16_t *_dst, int dstW, const uint8_t *src,
const int16_t *filter, const int16_t *filterPos,
int filterSize)
{
int i;
int32_t *dst = (int32_t *) _dst;
for (i=0; i<dstW; i++) {
int j;
int srcPos= filterPos[i];
int val=0;
for (j=0; j<filterSize; j++) {
val += ((int)src[srcPos + j])*filter[filterSize*i + j];
}
dst[i] = FFMIN(val>>3, (1<<19)-1);
}
}
| 1threat |
Force CMake in verbose mode via Gradle and the Android NDK : <p>I'm using Gradle and CMake to compile an Android NDK project from the command line. Previously, I was using Ant and <code>ndk-build</code> but I'm trying to migrate the project completely to Gradle and CMake.</p>
<p>In my <code>build.gradle</code> I have the following lines to invoke CMake:</p>
<pre><code>externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
}
}
</code></pre>
<p>Now how can I force CMake to print all compiler calls to the console before it makes them? Specifically, I want to see just how CMake runs the compiler and linker.</p>
<p>I've already tried the following, all to no avail:</p>
<p>1) In my <code>CMakeLists.txt</code> I have put the following line:</p>
<pre><code>set(CMAKE_VERBOSE_MAKEFILE on)
</code></pre>
<p>Didn't have any effect.</p>
<p>2) I have started the build like this:</p>
<pre><code>./gradlew build --info
</code></pre>
<p>Gradle printed some stuff, but no compiler calls.</p>
<p>3) And like this:</p>
<pre><code>./gradlew build --debug
</code></pre>
<p>Gradle printed lots of stuff, but no compiler calls.</p>
<p>So none of those three attempts did what I wanted which makes me wonder how can I see how CMake runs clang on my individual source files?</p>
| 0debug |
static int ea_probe(AVProbeData *p)
{
switch (AV_RL32(&p->buf[0])) {
case ISNh_TAG:
case SCHl_TAG:
case SEAD_TAG:
case SHEN_TAG:
case kVGT_TAG:
case MADk_TAG:
case MPCh_TAG:
case MVhd_TAG:
case MVIh_TAG:
break;
default:
return 0;
}
if (AV_RL32(&p->buf[4]) > 0xfffff && AV_RB32(&p->buf[4]) > 0xfffff)
return 0;
return AVPROBE_SCORE_MAX;
}
| 1threat |
Custom Design Pattern, e.g. IDisposable Pattern : <p>Short version: How can I create my own pattern binded to a interface, just like IDisposable Pattern Snippet?</p>
<p>Long version: Whenever I implement a "IDisposable", Visual Studio 2015 offers me an option to implement IDisposable Pattern and it writes some code to my class... So, how can I have my own pattern to implement with a certain interface (create by me)?</p>
<p>The idea is that all the developers can have an clue of how to implement a certain interface with the correct "pattern".</p>
| 0debug |
gcc doesn't locate file in directory : build_hello_tf.sh:
#!/bin/bash
TARGET_DIRECTORY="$(pwd)/src/addons/tensorflow/"
echo ${TARGET_DIRECTORY}
gcc -L${TARGET_DIRECTORY} hello_tf.c
ls ${TARGET_DIRECTORY}
output:
/home/karl/dev/node/tensorflow/src/addons/tensorflow/
gcc: error: hello_tf.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
hello_tf.c src
It doesn't seem to want to locate the file in the directory. | 0debug |
How to use @ as a function in laravel 6 : I am buildin a website and im creating an admin and user login form but im facing some problems because when I try to type for example @extends or any ohter function with "@" it doest change color or do anything (sorry for not being to clear). So basicly it doesnt act as a function but just as a simple text that later shows up at the display on the website. If anyone can help me i would be very happy because I have been trying for hours and its important for me to finish this website | 0debug |
2 Output Neural Network for Large Classificaiton Tasks : I've been thinking about this for a while but I cant seem to find any data on it. When classifying with a neural network you usually assign regions of the output neuron's activation function to a specific class, e.g. For tanh you could set 0.8 for class 1 and -0.8 for class 2. This is all well and good if you have up to 3 classes (the third class can be around zero), but when you have more classes things can become tricky.
Take an example where you are classifying football players based on their statistics. An attacking midfield player and a striker have similar statistics, but if you assign them to regions on opposite sides of the activation function, the accuracy of the classifier is surely harmed.
Would it not be easier to have a 2 output neural network that outputs an arbitrary x and a y value such that the class regions could be represented in 2D rather than 1D? You could essentially have a circle, cut into the number of classes you want and have the centre of each slice as the target value for the class. This seems like a good way to classify to me but the lack of relevant data on the subject is leading me to believe there are easier ways to perform classification with a higher number of classes (say 6 classes for example). The reason I ask is because I am trying to classify football players in certain positions based on their stats. You can see a scatter plot of the top 2 principal component scores for players below.
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/F6a0D.png | 0debug |
No matching distribution found for django : <p>I'm quite fresh in programming - I was using Django 1.10.6 and I tried to switch to 1.18 and that's what happened:</p>
<pre><code> (env)$ pip install django==1.18
Collecting django==1.18
Could not find a version that satisfies the requirement django==1.18
(from versions: 1.1.3, 1.1.4, 1.2, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5, 1.2.6,
1.2.7, 1.3, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.3.5, 1.3.6, 1.3.7, 1.4, 1.4.1, 1.4.2,
1.4.3, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.4.8, 1.4.9, 1.4.10, 1.4.11, 1.4.12, 1.4.13,
1.4.14, 1.4.15, 1.4.16, 1.4.17, 1.4.18, 1.4.19, 1.4.20, 1.4.21, 1.4.22, 1.5,
1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.5.5, 1.5.6, 1.5.7, 1.5.8, 1.5.9, 1.5.10, 1.5.11,
1.5.12, 1.6, 1.6.1, 1.6.2, 1.6.3, 1.6.4, 1.6.5, 1.6.6, 1.6.7, 1.6.8, 1.6.9,
1.6.10, 1.6.11, 1.7, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 1.7.5, 1.7.6, 1.7.7, 1.7.8,
1.7.9, 1.7.10, 1.7.11, 1.8a1, 1.8b1, 1.8b2, 1.8rc1, 1.8, 1.8.1, 1.8.2, 1.8.3,
1.8.4, 1.8.5, 1.8.6, 1.8.7, 1.8.8, 1.8.9, 1.8.10, 1.8.11, 1.8.12, 1.8.13,
1.8.14, 1.8.15, 1.8.16, 1.8.17, 1.8.18, 1.9a1, 1.9b1, 1.9rc1, 1.9rc2, 1.9,
1.9.1, 1.9.2, 1.9.3, 1.9.4, 1.9.5, 1.9.6, 1.9.7, 1.9.8, 1.9.9, 1.9.10, 1.9.11,
1.9.12, 1.9.13, 1.10a1, 1.10b1, 1.10rc1, 1.10, 1.10.1, 1.10.2, 1.10.3, 1.10.4,
1.10.5, 1.10.6, 1.10.7, 1.11a1, 1.11b1, 1.11rc1, 1.11, 1.11.1, 1.11.2)
No matching distribution found for django==1.18
</code></pre>
<p>What is wrong? I should upgrade pip?</p>
| 0debug |
Login / directory creator : <p>all.</p>
<p>I've got a big ask, and I have no idea how to go around it.</p>
<p>I want to make a login / signup form, which creates a directory on the server for each new user. This directory, somewhat obviously, must not be publicly accessible by other users, and must automatically copy / make it's index.php file and subdirectories.</p>
<p>I'm afraid that I won't have much luck, as I've never made any form of encrypted login before, let alone a fancy automated one like this.</p>
<p>No code as of yet. Any help appreciated!</p>
| 0debug |
def str_to_tuple(test_str):
res = tuple(map(int, test_str.split(', ')))
return (res) | 0debug |
AWS EB Error: Incorrect application version found on all instances : <p>I am trying to use the EB CLI to deploy an application into an environment but I seem to be getting strange errors. Is there a way to empty out previous application versions so I can upload a fresh application?</p>
<p>The message I see after I execute eb deploy.</p>
<pre><code>Update environment operation is complete, but with errors. For more information, see troubleshooting documentation.
</code></pre>
<p>I am currently getting this error:</p>
<pre><code>Incorrect application version found on all instances. Expected version [app version]
</code></pre>
<p>The logs file also seems to be getting deleted for some reason.</p>
| 0debug |
void cris_mmu_flush_pid(CPUState *env, uint32_t pid)
{
target_ulong vaddr;
unsigned int idx;
uint32_t lo, hi;
uint32_t tlb_vpn;
int tlb_pid, tlb_g, tlb_v, tlb_k;
unsigned int set;
unsigned int mmu;
pid &= 0xff;
for (mmu = 0; mmu < 2; mmu++) {
for (set = 0; set < 4; set++)
{
for (idx = 0; idx < 16; idx++) {
lo = env->tlbsets[mmu][set][idx].lo;
hi = env->tlbsets[mmu][set][idx].hi;
tlb_vpn = EXTRACT_FIELD(hi, 13, 31);
tlb_pid = EXTRACT_FIELD(hi, 0, 7);
tlb_g = EXTRACT_FIELD(lo, 4, 4);
tlb_v = EXTRACT_FIELD(lo, 3, 3);
tlb_k = EXTRACT_FIELD(lo, 2, 2);
if (tlb_v && !tlb_g && (tlb_pid == pid || tlb_k)) {
vaddr = tlb_vpn << TARGET_PAGE_BITS;
D(fprintf(logfile,
"flush pid=%x vaddr=%x\n",
pid, vaddr));
tlb_flush_page(env, vaddr);
}
}
}
}
}
| 1threat |
Buffer implementing io.WriterAt in go : <p>I'm using the aws-sdk to download a file from an s3 bucket. The S3 download function want's something that implements io.WriterAt however bytes.Buffer doesn't implement that. Right now I'm creating a file which implements io.WriterAt but I'd like something in memory.</p>
| 0debug |
React Native Error: ENOSPC: System limit for number of file watchers reached : <p>I have setup a new blank react native app.</p>
<p>After installing few node modules I got this error. </p>
<p><a href="https://i.stack.imgur.com/x4zCh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/x4zCh.png" alt="enter image description here"></a></p>
<p>I know it's related to no enough space for watchman to watch for all file changes.</p>
<p>I want to know what's the best course of action to take here ? </p>
<p>Should I ignore <code>node_modules</code> folder by adding it to <code>.watchmanconfig</code> ? </p>
| 0debug |
not able to connect to mysql docker from local : <p>I am trying to connect to mysql database from docker image. However it's throwing errors. </p>
<p>following is the docker image I am using.
<a href="https://hub.docker.com/_/mysql/" rel="noreferrer">https://hub.docker.com/_/mysql/</a></p>
<p>And following is the command I have used to run the docker image. </p>
<pre><code>docker run -p 3306:3306 --name mysql_80 -e MYSQL_ROOT_PASSWORD=password -d mysql:8
</code></pre>
<p>Following is the output of <code>docker ps</code> command </p>
<pre><code>CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9f35d2e39476 mysql:8 "docker-entrypoint.s…" 5 minutes ago Up 5 minutes 0.0.0.0:3306->3306/tcp
</code></pre>
<p>if I check the IP using docker inspect and ping that IP, it shows IP is not reachable. </p>
<pre><code>docker inspect 9f35d2e39476 | grep -i ipaddress
</code></pre>
<p>And if i try to connect using <code>localhost</code> and <code>127.0.0.1</code> I am getting following error. </p>
<blockquote>
<p>Unable to load authentication plugin 'caching_sha2_password'.</p>
</blockquote>
| 0debug |
How to pass @Input() params to an angular 2 component created with DynamicComponentLoader : <p>The DynamicContentLoader docs don't explain how I can properly load a child component's inputs. Let's say I have a child like:</p>
<pre><code>@Component({
selector: 'child-component',
template: '<input type="text" [(ngModel)]="thing.Name" />'
})
class ChildComponent {
@Input() thing : any;
}
</code></pre>
<p>and a parent like:</p>
<pre><code>@Component({
selector: 'my-app',
template: 'Parent (<div #child></div>)'
})
class MyApp {
thing : any;
constructor(dcl: DynamicComponentLoader, elementRef: ElementRef) {
dcl.loadIntoLocation(ChildComponent, elementRef, 'child');
}
}
</code></pre>
<p>How should I go about passing <code>thing</code> into the child component such that the two components can be data bound against the same thing. </p>
<p>I tried to do this:</p>
<pre><code>@Component({
selector: 'my-app',
template: 'Parent (<div #child></div>)'
})
class MyApp {
thing : any;
constructor(dcl: DynamicComponentLoader, elementRef: ElementRef) {
dcl.loadIntoLocation(ChildComponent, elementRef, 'child').then(ref => {
ref.instance.thing = this.thing;
});
}
}
</code></pre>
<p>It sort of works, but they are not synchronised as you would expect. </p>
<p>Basically I am trying to achieve the same thing that would have been achieved by using ng-include in angular 1 where the child is a dynamically determined component and shares the model with its parent. </p>
<p>Thanks in advance ...</p>
| 0debug |
How to get next earliest date from today in sql? : Product | color | size | qty | Avail-date
A RED XS 10 2018-05-24 ===> Today
A RED XS 50 2018-05-29
A RED XS 40 2018-04-01
A RED XS 30 2018-05-26 ===> Target line to be pulled | 0debug |
static int mpc8_decode_init(AVCodecContext * avctx)
{
int i;
MPCContext *c = avctx->priv_data;
GetBitContext gb;
static int vlc_inited = 0;
if(avctx->extradata_size < 2){
av_log(avctx, AV_LOG_ERROR, "Too small extradata size (%i)!\n", avctx->extradata_size);
return -1;
}
memset(c->oldDSCF, 0, sizeof(c->oldDSCF));
av_init_random(0xDEADBEEF, &c->rnd);
dsputil_init(&c->dsp, avctx);
ff_mpc_init();
init_get_bits(&gb, avctx->extradata, 16);
skip_bits(&gb, 3);
c->maxbands = get_bits(&gb, 5) + 1;
skip_bits(&gb, 4);
c->MSS = get_bits1(&gb);
c->frames = 1 << (get_bits(&gb, 3) * 2);
if(vlc_inited) return 0;
av_log(avctx, AV_LOG_DEBUG, "Initing VLC\n");
init_vlc(&band_vlc, MPC8_BANDS_BITS, MPC8_BANDS_SIZE,
mpc8_bands_bits, 1, 1,
mpc8_bands_codes, 1, 1, INIT_VLC_USE_STATIC);
init_vlc(&q1_vlc, MPC8_Q1_BITS, MPC8_Q1_SIZE,
mpc8_q1_bits, 1, 1,
mpc8_q1_codes, 1, 1, INIT_VLC_USE_STATIC);
init_vlc(&q9up_vlc, MPC8_Q9UP_BITS, MPC8_Q9UP_SIZE,
mpc8_q9up_bits, 1, 1,
mpc8_q9up_codes, 1, 1, INIT_VLC_USE_STATIC);
init_vlc(&scfi_vlc[0], MPC8_SCFI0_BITS, MPC8_SCFI0_SIZE,
mpc8_scfi0_bits, 1, 1,
mpc8_scfi0_codes, 1, 1, INIT_VLC_USE_STATIC);
init_vlc(&scfi_vlc[1], MPC8_SCFI1_BITS, MPC8_SCFI1_SIZE,
mpc8_scfi1_bits, 1, 1,
mpc8_scfi1_codes, 1, 1, INIT_VLC_USE_STATIC);
init_vlc(&dscf_vlc[0], MPC8_DSCF0_BITS, MPC8_DSCF0_SIZE,
mpc8_dscf0_bits, 1, 1,
mpc8_dscf0_codes, 1, 1, INIT_VLC_USE_STATIC);
init_vlc(&dscf_vlc[1], MPC8_DSCF1_BITS, MPC8_DSCF1_SIZE,
mpc8_dscf1_bits, 1, 1,
mpc8_dscf1_codes, 1, 1, INIT_VLC_USE_STATIC);
init_vlc_sparse(&q3_vlc[0], MPC8_Q3_BITS, MPC8_Q3_SIZE,
mpc8_q3_bits, 1, 1,
mpc8_q3_codes, 1, 1,
mpc8_q3_syms, 1, 1, INIT_VLC_USE_STATIC);
init_vlc_sparse(&q3_vlc[1], MPC8_Q4_BITS, MPC8_Q4_SIZE,
mpc8_q4_bits, 1, 1,
mpc8_q4_codes, 1, 1,
mpc8_q4_syms, 1, 1, INIT_VLC_USE_STATIC);
for(i = 0; i < 2; i++){
init_vlc(&res_vlc[i], MPC8_RES_BITS, MPC8_RES_SIZE,
&mpc8_res_bits[i], 1, 1,
&mpc8_res_codes[i], 1, 1, INIT_VLC_USE_STATIC);
init_vlc(&q2_vlc[i], MPC8_Q2_BITS, MPC8_Q2_SIZE,
&mpc8_q2_bits[i], 1, 1,
&mpc8_q2_codes[i], 1, 1, INIT_VLC_USE_STATIC);
init_vlc(&quant_vlc[0][i], MPC8_Q5_BITS, MPC8_Q5_SIZE,
&mpc8_q5_bits[i], 1, 1,
&mpc8_q5_codes[i], 1, 1, INIT_VLC_USE_STATIC);
init_vlc(&quant_vlc[1][i], MPC8_Q6_BITS, MPC8_Q6_SIZE,
&mpc8_q6_bits[i], 1, 1,
&mpc8_q6_codes[i], 1, 1, INIT_VLC_USE_STATIC);
init_vlc(&quant_vlc[2][i], MPC8_Q7_BITS, MPC8_Q7_SIZE,
&mpc8_q7_bits[i], 1, 1,
&mpc8_q7_codes[i], 1, 1, INIT_VLC_USE_STATIC);
init_vlc(&quant_vlc[3][i], MPC8_Q8_BITS, MPC8_Q8_SIZE,
&mpc8_q8_bits[i], 1, 1,
&mpc8_q8_codes[i], 1, 1, INIT_VLC_USE_STATIC);
}
vlc_inited = 1;
return 0;
}
| 1threat |
int cpu_x86_signal_handler(int host_signum, struct siginfo *info,
void *puc)
{
uint32_t *regs = (uint32_t *)(info + 1);
void *sigmask = (regs + 20);
unsigned long pc;
int is_write;
uint32_t insn;
pc = regs[1];
is_write = 0;
insn = *(uint32_t *)pc;
if ((insn >> 30) == 3) {
switch((insn >> 19) & 0x3f) {
case 0x05:
case 0x06:
case 0x04:
case 0x07: d
case 0x24: f
case 0x27: df
case 0x25: fsr
is_write = 1;
break;
}
}
return handle_cpu_signal(pc, (unsigned long)info->si_addr,
is_write, sigmask);
}
| 1threat |
Range of card in database cell : How can I insert a range of cards like AA-QQ (AA, KK, QQ) in a cell of a database?
I will use java
I can't use 2 column like in [this thread][1] because cardsaren't numbers
[1]:http://stackoverflow.com/a/7463531/6942539
| 0debug |
void HELPER(srstu)(CPUS390XState *env, uint32_t r1, uint32_t r2)
{
uintptr_t ra = GETPC();
uint32_t len;
uint16_t v, c = env->regs[0];
uint64_t end, str, adj_end;
if (env->regs[0] & 0xffff0000u) {
cpu_restore_state(ENV_GET_CPU(env), ra);
program_interrupt(env, PGM_SPECIFICATION, 6);
}
str = get_address(env, r2);
end = get_address(env, r1);
adj_end = end + ((str ^ end) & 1);
for (len = 0; len < 0x2000; len += 2) {
if (str + len == adj_end) {
env->cc_op = 2;
return;
}
v = cpu_lduw_data_ra(env, str + len, ra);
if (v == c) {
env->cc_op = 1;
set_address(env, r1, str + len);
return;
}
}
env->cc_op = 3;
set_address(env, r2, str + len);
}
| 1threat |
how to increment and decrement date in android ? : I am newbie to android.I have to create a app which displays current date.On forward swiping date should be incremented and on backward swiping date should be decremented.
I am succeeded in displaying current date and increment on swiping forward.But i donno how to decremnt on swiping backward in single activity.
Here is my code.
TAB activity
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
Calendar c = Calendar.getInstance();
c.add(Calendar.DAY_OF_MONTH,position);
String dte = sdf.format(c.getTime()).toString();
TextView textView2 = getView().findViewById(R.id.textView2);
textView2.setText(dte);
}
}
| 0debug |
python : Which city has the highest number of trip : python: Which city has the highest number of trips
In a csv file, bikeshare data is available for three different NYC,Chicago, Washington
1. Need to find ,which city has highest number of trips.
2. Which city has the highest proportion of trips made by subscribers(User_type)?
Please guide me through sample code. Thanks in advance. | 0debug |
How to make folder , file using keyboard shortcut? For Windows 8 : <p>How to make folder/file using keyboard shortcut ? I am beginner user for that case do not know this shortcut.</p>
| 0debug |
Sending a persistent message in RabbitMQ via HTTP API : <p>I want to send a persistent mesaage via HTTP API. Im using this command:</p>
<pre><code>curl -u UN:PWD -H "content-type:application/json" -X POST -d'{"properties":{},"routing_key":"QueueName","payload":"HI","payload_encoding":"string", "deliverymode": 2}' http://url:8080/api/exchanges/%2f/amq.default/publish
</code></pre>
<p>My queue is durable and deliverymode is also set to 2(Persistent), but the messages published are not durable. What change needs to be done?
When I send the same via Management Console, the message is persistent but not via HTTP API.</p>
| 0debug |
Looking for text editor with multiple functionalities : <p>I'm building a web app; front-end in Angular and back-end in Ruby on Rails.</p>
<p>I need to achieve below functionalities. I am basically adding text editor so users can edit template letters in my service.</p>
<pre><code>1) Load .doc file from the file system(or remote server) to the text editor
2) Edit the loaded .doc file and save the file as different name
</code></pre>
<p>Is there any recommendable free text editor which can achieve those?</p>
| 0debug |
How can I correctly implement setTimeout? : <p>I'm trying to use <code>setTimeout</code> to perform <code>document.write</code> after a certain delay after a form is submitted. For now, the delay is a static 3000ms. However, when I try to implement it, <code>document.write</code> happens instantly. How can I implement setTimeout correctly?</p>
<p>This is for a website. Form submission happens before this block of code runs, and variables are passed from what is submitted.</p>
<pre><code>
function findInterval(){
var delay = document.forms["options"]["delay"].value;
min = Math.ceil(min);
max = Math.ceil(max);
var result = Math.floor(Math.random() * (max - min + 1)) + min;
var total = parseInt(delay) + parseInt(result);
setTimeout(document.write(total), 3000);
}
</code></pre>
<p>My understanding is that my code should wait 3 seconds, then do <code>document.write(total)</code> but that's not the case. What am I doing wrong?</p>
| 0debug |
Undefined Image src Model popup : I'm making a Image Gallery with model popup, The JavaScript code is working, but Undefined Image src of the gallery popup modal box. What mistake i did? Any Help is Greatly Appreciated, thanks.
<?php echo '<img id="myImg" src="'.esc_url( $info['0'] ).'" onclick="imgPopup();" alt="Snow" style="width:100%;max-width:300px">'; ?>
function imgPopup(){
var modal = document.getElementById('myModal');
var modalImg = document.getElementById("myImg1");
modal.style.display = "block";
modalImg.src = this.src;
var span = document.getElementsByClassName("close")[0];
span.onclick = function() {
modal.style.display = "none";
} } | 0debug |
How to convert JSON data into a tree image? : <p>I'm using <a href="http://treelib.readthedocs.io/en/latest/examples.html" rel="noreferrer">treelib</a> to generate trees, now I need easy-to-read version of trees, so I want to convert them into images. For example:
<a href="https://i.stack.imgur.com/sr9eC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sr9eC.png" alt="enter image description here"></a></p>
<p>The sample JSON data, for the following tree:</p>
<p><a href="https://i.stack.imgur.com/oaR1K.png" rel="noreferrer"><img src="https://i.stack.imgur.com/oaR1K.png" alt="enter image description here"></a></p>
<p>With data:</p>
<pre><code>>>> print(tree.to_json(with_data=True))
{"Harry": {"data": null, "children": [{"Bill": {"data": null}}, {"Jane": {"data": null, "children": [{"Diane": {"data": null}}, {"Mark": {"data": null}}]}}, {"Mary": {"data": null}}]}}
</code></pre>
<p>Without data:</p>
<pre><code>>>> print(tree.to_json(with_data=False))
{"Harry": {"children": ["Bill", {"Jane": {"children": [{"Diane": {"children": ["Mary"]}}, "Mark"]}}]}}
</code></pre>
<p>Is there anyway to use <a href="https://pypi.python.org/pypi/graphviz" rel="noreferrer">graphviz</a> or <a href="https://d3js.org/" rel="noreferrer">d3.js</a> or some other python library to generate tree using this JSON data?</p>
| 0debug |
Select value based on values from other columns : I have question. I have column for price. I need to select price based on another column called status .. if status is p then select that price first else select price from other status h. I need to make sure that query selects the price if status is p first when both status P & h are available. Thanks for help | 0debug |
static void clipper_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
AlphaCPU *cpus[4];
PCIBus *pci_bus;
ISABus *isa_bus;
qemu_irq rtc_irq;
long size, i;
const char *palcode_filename;
uint64_t palcode_entry, palcode_low, palcode_high;
uint64_t kernel_entry, kernel_low, kernel_high;
memset(cpus, 0, sizeof(cpus));
for (i = 0; i < smp_cpus; ++i) {
cpus[i] = cpu_alpha_init(cpu_model ? cpu_model : "ev67");
}
cpus[0]->env.trap_arg0 = ram_size;
cpus[0]->env.trap_arg1 = 0;
cpus[0]->env.trap_arg2 = smp_cpus;
pci_bus = typhoon_init(ram_size, &isa_bus, &rtc_irq, cpus,
clipper_pci_map_irq);
rtc_init(isa_bus, 1900, rtc_irq);
pit_init(isa_bus, 0x40, 0, NULL);
isa_create_simple(isa_bus, "i8042");
pci_vga_init(pci_bus);
serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS);
for (i = 0; i < nb_nics; i++) {
pci_nic_init_nofail(&nd_table[i], pci_bus, "e1000", NULL);
}
{
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
ide_drive_get(hd, ARRAY_SIZE(hd));
pci_cmd646_ide_init(pci_bus, hd, 0);
}
palcode_filename = (bios_name ? bios_name : "palcode-clipper");
palcode_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, palcode_filename);
if (palcode_filename == NULL) {
hw_error("no palcode provided\n");
exit(1);
}
size = load_elf(palcode_filename, cpu_alpha_superpage_to_phys,
NULL, &palcode_entry, &palcode_low, &palcode_high,
0, EM_ALPHA, 0);
if (size < 0) {
hw_error("could not load palcode '%s'\n", palcode_filename);
exit(1);
}
for (i = 0; i < smp_cpus; ++i) {
cpus[i]->env.pal_mode = 1;
cpus[i]->env.pc = palcode_entry;
cpus[i]->env.palbr = palcode_entry;
}
if (kernel_filename) {
uint64_t param_offset;
size = load_elf(kernel_filename, cpu_alpha_superpage_to_phys,
NULL, &kernel_entry, &kernel_low, &kernel_high,
0, EM_ALPHA, 0);
if (size < 0) {
hw_error("could not load kernel '%s'\n", kernel_filename);
exit(1);
}
cpus[0]->env.trap_arg1 = kernel_entry;
param_offset = kernel_low - 0x6000;
if (kernel_cmdline) {
pstrcpy_targphys("cmdline", param_offset, 0x100, kernel_cmdline);
}
if (initrd_filename) {
long initrd_base, initrd_size;
initrd_size = get_image_size(initrd_filename);
if (initrd_size < 0) {
hw_error("could not load initial ram disk '%s'\n",
initrd_filename);
exit(1);
}
initrd_base = (ram_size - initrd_size) & TARGET_PAGE_MASK;
load_image_targphys(initrd_filename, initrd_base,
ram_size - initrd_base);
address_space_stq(&address_space_memory, param_offset + 0x100,
initrd_base + 0xfffffc0000000000ULL,
MEMTXATTRS_UNSPECIFIED,
NULL);
address_space_stq(&address_space_memory, param_offset + 0x108,
initrd_size, MEMTXATTRS_UNSPECIFIED, NULL);
}
}
}
| 1threat |
static int udp_open(URLContext *h, const char *uri, int flags)
{
char hostname[1024], localaddr[1024] = "";
int port, udp_fd = -1, tmp, bind_ret = -1;
UDPContext *s = h->priv_data;
int is_output;
const char *p;
char buf[256];
struct sockaddr_storage my_addr;
int len;
int reuse_specified = 0;
h->is_streamed = 1;
h->max_packet_size = 1472;
is_output = !(flags & AVIO_FLAG_READ);
s->ttl = 16;
s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_MAX_PKT_SIZE;
s->circular_buffer_size = 7*188*4096;
p = strchr(uri, '?');
if (p) {
if (av_find_info_tag(buf, sizeof(buf), "reuse", p)) {
char *endptr = NULL;
s->reuse_socket = strtol(buf, &endptr, 10);
if (buf == endptr)
s->reuse_socket = 1;
reuse_specified = 1;
}
if (av_find_info_tag(buf, sizeof(buf), "overrun_nonfatal", p)) {
char *endptr = NULL;
s->overrun_nonfatal = strtol(buf, &endptr, 10);
if (buf == endptr)
s->overrun_nonfatal = 1;
}
if (av_find_info_tag(buf, sizeof(buf), "ttl", p)) {
s->ttl = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "localport", p)) {
s->local_port = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "pkt_size", p)) {
h->max_packet_size = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "buffer_size", p)) {
s->buffer_size = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "connect", p)) {
s->is_connected = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "fifo_size", p)) {
s->circular_buffer_size = strtol(buf, NULL, 10)*188;
}
if (av_find_info_tag(buf, sizeof(buf), "localaddr", p)) {
av_strlcpy(localaddr, buf, sizeof(localaddr));
}
}
av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri);
if (hostname[0] == '\0' || hostname[0] == '?') {
if (!(flags & AVIO_FLAG_READ))
goto fail;
} else {
if (ff_udp_set_remote_url(h, uri) < 0)
goto fail;
}
if ((s->is_multicast || !s->local_port) && (h->flags & AVIO_FLAG_READ))
s->local_port = port;
udp_fd = udp_socket_create(s, &my_addr, &len, localaddr);
if (udp_fd < 0)
goto fail;
if (s->reuse_socket || (s->is_multicast && !reuse_specified)) {
s->reuse_socket = 1;
if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), sizeof(s->reuse_socket)) != 0)
goto fail;
}
if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE)) {
bind_ret = bind(udp_fd,(struct sockaddr *)&s->dest_addr, len);
}
if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)&my_addr, len) < 0) {
av_log(h, AV_LOG_ERROR, "bind failed: %s\n", strerror(errno));
goto fail;
}
len = sizeof(my_addr);
getsockname(udp_fd, (struct sockaddr *)&my_addr, &len);
s->local_port = udp_port(&my_addr, len);
if (s->is_multicast) {
if (h->flags & AVIO_FLAG_WRITE) {
if (udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr *)&s->dest_addr) < 0)
goto fail;
}
if (h->flags & AVIO_FLAG_READ) {
if (udp_join_multicast_group(udp_fd, (struct sockaddr *)&s->dest_addr) < 0)
goto fail;
}
}
if (is_output) {
tmp = s->buffer_size;
if (setsockopt(udp_fd, SOL_SOCKET, SO_SNDBUF, &tmp, sizeof(tmp)) < 0) {
av_log(h, AV_LOG_ERROR, "setsockopt(SO_SNDBUF): %s\n", strerror(errno));
goto fail;
}
} else {
tmp = s->buffer_size;
if (setsockopt(udp_fd, SOL_SOCKET, SO_RCVBUF, &tmp, sizeof(tmp)) < 0) {
av_log(h, AV_LOG_WARNING, "setsockopt(SO_RECVBUF): %s\n", strerror(errno));
}
ff_socket_nonblock(udp_fd, 1);
}
if (s->is_connected) {
if (connect(udp_fd, (struct sockaddr *) &s->dest_addr, s->dest_addr_len)) {
av_log(h, AV_LOG_ERROR, "connect: %s\n", strerror(errno));
goto fail;
}
}
s->udp_fd = udp_fd;
#if HAVE_PTHREADS
if (!is_output && s->circular_buffer_size) {
int ret;
s->fifo = av_fifo_alloc(s->circular_buffer_size);
ret = pthread_mutex_init(&s->mutex, NULL);
if (ret != 0) {
av_log(h, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", strerror(ret));
goto fail;
}
ret = pthread_cond_init(&s->cond, NULL);
if (ret != 0) {
av_log(h, AV_LOG_ERROR, "pthread_cond_init failed : %s\n", strerror(ret));
goto cond_fail;
}
ret = pthread_create(&s->circular_buffer_thread, NULL, circular_buffer_task, h);
if (ret != 0) {
av_log(h, AV_LOG_ERROR, "pthread_create failed : %s\n", strerror(ret));
goto thread_fail;
}
s->thread_started = 1;
}
#endif
return 0;
#if HAVE_PTHREADS
thread_fail:
pthread_cond_destroy(&s->cond);
cond_fail:
pthread_mutex_destroy(&s->mutex);
#endif
fail:
if (udp_fd >= 0)
closesocket(udp_fd);
av_fifo_free(s->fifo);
return AVERROR(EIO);
}
| 1threat |
Flutter Stack size to sibling : <p>Is there a way to size a stack child automatically to its largest sibling?
I.e. if I have a <code>Stack</code> with a <code>ListTile</code> and a <code>Container</code> on top, how do I make sure the <code>Container</code> covers the entire <code>ListTile</code>?</p>
<p>Example: </p>
<pre><code>new Stack(children: <Widget>[
new ListTile(
leading: new AssetImage('foo.jpg'),
title: new Text('Bar'),
subtitle: new Text('yipeee'),
isThreeLine: true,
),
new Container(color: Colors.grey, child: new Text('foo'))
],
)
</code></pre>
<p>I tried to make it work with <code>Row</code>, <code>Column</code> and <code>Expanded</code> but am running into problems with unbounded constraints.</p>
<p>Is there a way to size the <code>Container</code> (or any other widget such as a <code>GestureDetector</code>) to its largest sibling in the stack?</p>
| 0debug |
Print a circular array c# : I have this situation:
int[] array = new int[] {7, 5, 6}
The value of my index i is 1 and he is pointing at the head of my hypothetical circular list, the value "7" at the zero position is the tail.
My aim is to print:
5,6,7
Do I need a specific structure or can I do it with a simple array ?
| 0debug |
jquery not waiting the confirm messge, it is running all functions : I have a multi select Gridview , If a user for example selected 3 rows in the grid : name 1, name2, name3. i should show the user a popup confirm message, are you sure ?.
the problem in jquery , it doesnt wait the confirm message, it calls all the functions. **what I want is the know the result of the message first then call the functions**
function clickon()
{
var $current = $("#click_on_confirm");
var gridId = $("#Grid_id");
var confirmedArr = new Array;
confirmedArr = gridId.jqGrid('getGridParam','selarrrow');
var n=0;
var i = 0;
var arrayLength = confirmedArr .length;
var user_id;
if($current.is(":checked"))
{
var confirmMsg = "Are you sure "+ confirmedArr [i]
console.log(user_id);
// my problem is here , its not waiting till i click the confirm message
_showConfirmMsg(confirmMsg, ""Are you sure ?", function(confirmChoice, theArgs)
{
user_id = confirmedArr[i];
i++;
}
confirm(confirmedArr);
}
function confirm(confirmedArr)
{
var gridId = $("#Grid_id");
var actionSrc = jQuery.contextPath+"..............";
_showProgressBar(true);
var param="arUser="+confirmedArr;
$.ajax({
url: actionSrc,
type:"post",
dataType:"json",
data: param,
success: function(data)
{
if(typeof data["_error"] == "undefined" || data["_error"] == null)
{
// something to do
}
_showProgressBar(false);
}
});
} | 0debug |
static inline void omap_timer_update(struct omap_mpu_timer_s *timer)
{
int64_t expires;
if (timer->enable && timer->st && timer->rate) {
timer->val = timer->reset_val;
expires = timer->time + muldiv64(timer->val << (timer->ptv + 1),
ticks_per_sec, timer->rate);
qemu_mod_timer(timer->timer, expires);
} else
qemu_del_timer(timer->timer);
}
| 1threat |
How to see all running Amazon EC2 instances across all regions? : <p>I switch instances between different regions frequently and sometimes I forget to turn off my running instance from a different region. I couldn't find any way to see all the running instances on Amazon console.<br>
Is there any way to display all the running instances regardless of region?</p>
| 0debug |
void bdrv_img_create(const char *filename, const char *fmt,
const char *base_filename, const char *base_fmt,
char *options, uint64_t img_size, int flags, bool quiet,
Error **errp)
{
QemuOptsList *create_opts = NULL;
QemuOpts *opts = NULL;
const char *backing_fmt, *backing_file;
int64_t size;
BlockDriver *drv, *proto_drv;
Error *local_err = NULL;
int ret = 0;
drv = bdrv_find_format(fmt);
if (!drv) {
error_setg(errp, "Unknown file format '%s'", fmt);
return;
}
proto_drv = bdrv_find_protocol(filename, true, errp);
if (!proto_drv) {
return;
}
if (!drv->create_opts) {
error_setg(errp, "Format driver '%s' does not support image creation",
drv->format_name);
return;
}
if (!proto_drv->create_opts) {
error_setg(errp, "Protocol driver '%s' does not support image creation",
proto_drv->format_name);
return;
}
create_opts = qemu_opts_append(create_opts, drv->create_opts);
create_opts = qemu_opts_append(create_opts, proto_drv->create_opts);
opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
qemu_opt_set_number(opts, BLOCK_OPT_SIZE, img_size, &error_abort);
if (options) {
qemu_opts_do_parse(opts, options, NULL, &local_err);
if (local_err) {
error_report_err(local_err);
local_err = NULL;
error_setg(errp, "Invalid options for file format '%s'", fmt);
goto out;
}
}
if (base_filename) {
qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, base_filename, &local_err);
if (local_err) {
error_setg(errp, "Backing file not supported for file format '%s'",
fmt);
goto out;
}
}
if (base_fmt) {
qemu_opt_set(opts, BLOCK_OPT_BACKING_FMT, base_fmt, &local_err);
if (local_err) {
error_setg(errp, "Backing file format not supported for file "
"format '%s'", fmt);
goto out;
}
}
backing_file = qemu_opt_get(opts, BLOCK_OPT_BACKING_FILE);
if (backing_file) {
if (!strcmp(filename, backing_file)) {
error_setg(errp, "Error: Trying to create an image with the "
"same filename as the backing file");
goto out;
}
}
backing_fmt = qemu_opt_get(opts, BLOCK_OPT_BACKING_FMT);
size = qemu_opt_get_size(opts, BLOCK_OPT_SIZE, 0);
if (backing_file && !(flags & BDRV_O_NO_BACKING)) {
BlockDriverState *bs;
char *full_backing = g_new0(char, PATH_MAX);
int back_flags;
QDict *backing_options = NULL;
bdrv_get_full_backing_filename_from_filename(filename, backing_file,
full_backing, PATH_MAX,
&local_err);
if (local_err) {
g_free(full_backing);
goto out;
}
back_flags = flags;
back_flags &= ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);
if (backing_fmt) {
backing_options = qdict_new();
qdict_put_str(backing_options, "driver", backing_fmt);
}
bs = bdrv_open(full_backing, NULL, backing_options, back_flags,
&local_err);
g_free(full_backing);
if (!bs && size != -1) {
warn_reportf_err(local_err,
"Could not verify backing image. "
"This may become an error in future versions.\n");
local_err = NULL;
} else if (!bs) {
error_append_hint(&local_err,
"Could not open backing image to determine size.\n");
goto out;
} else {
if (size == -1) {
size = bdrv_getlength(bs);
if (size < 0) {
error_setg_errno(errp, -size, "Could not get size of '%s'",
backing_file);
bdrv_unref(bs);
goto out;
}
qemu_opt_set_number(opts, BLOCK_OPT_SIZE, size, &error_abort);
}
bdrv_unref(bs);
}
}
if (size == -1) {
error_setg(errp, "Image creation needs a size parameter");
goto out;
}
if (!quiet) {
printf("Formatting '%s', fmt=%s ", filename, fmt);
qemu_opts_print(opts, " ");
puts("");
}
ret = bdrv_create(drv, filename, opts, &local_err);
if (ret == -EFBIG) {
const char *cluster_size_hint = "";
if (qemu_opt_get_size(opts, BLOCK_OPT_CLUSTER_SIZE, 0)) {
cluster_size_hint = " (try using a larger cluster size)";
}
error_setg(errp, "The image size is too large for file format '%s'"
"%s", fmt, cluster_size_hint);
error_free(local_err);
local_err = NULL;
}
out:
qemu_opts_del(opts);
qemu_opts_free(create_opts);
error_propagate(errp, local_err);
}
| 1threat |
static int ftp_auth(FTPContext *s)
{
const char *user = NULL, *pass = NULL;
char *end = NULL, buf[CONTROL_BUFFER_SIZE], credencials[CREDENTIALS_BUFFER_SIZE];
int err;
const int user_codes[] = {331, 230, 0};
const int pass_codes[] = {230, 0};
av_strlcpy(credencials, s->credencials, sizeof(credencials));
user = av_strtok(credencials, ":", &end);
pass = av_strtok(end, ":", &end);
if (!user) {
user = "anonymous";
pass = s->anonymous_password ? s->anonymous_password : "nopassword";
}
snprintf(buf, sizeof(buf), "USER %s\r\n", user);
err = ftp_send_command(s, buf, user_codes, NULL);
if (err == 331) {
if (pass) {
snprintf(buf, sizeof(buf), "PASS %s\r\n", pass);
err = ftp_send_command(s, buf, pass_codes, NULL);
} else
return AVERROR(EACCES);
}
if (!err)
return AVERROR(EACCES);
return 0;
}
| 1threat |
Which is best way to clean the innerHTML when working with dinamic content? : What i want i know is what's the best way to clean the innerHTML of an element that is going to be changing over and over, i made a small function that would clean the containers but i do not think that's quite efficient enough, i mean, it does work but only with the containers which it's told to so maybe is better to just make every element to rewrite it's own innerHTML?
(Not sure if duplicate) | 0debug |
Does anyone know what this loop does : <p>Suuupppeeeeerrrrrr noob question, </p>
<p>I am trying to deconstruct some python code, and I can figure out what this line does. I know it cycles thru potentially 28 iterations but I can't figure out what the i%len does to question.</p>
<pre><code>for i in range(t, t + 28):
transmission.append(question[i%len(question)])
</code></pre>
<p>Thanks for your help.</p>
| 0debug |
how to apply for-loop in between string data to create an order in shopify through api : <pre><code>string data = @"
{
""order"": {
""line_items"": [
{
""variant_id"":" + varientid_arr[0] +@",
""quantity"":" + quantity_arr[0] + @"
}
],
""customer"": {
""id"": 2750996643918
},
""financial_status"": ""pending""
}
}
";
</code></pre>
<p>in this code i want to iterate line items(varientid_arr[0], quantity_arr[0] ) for creating order with multiple products in shopify. i want to apply for loop in line items only within string.</p>
| 0debug |
Swift current ViewController dismiss after or before present new ViewController : My scenario, I am trying to create multiple present ViewController. Here, presenting new ViewController after I need to dismiss previous ViewController.
ViewController A (RootViewController) next button click to showing ViewController B then View Controller B next button click to present model ViewController C. Now, If I close ViewController C need to show ViewController A.
NOTE: ViewController A having closing button, If I close it. It will show Tabbar view controller.
[![example][1]][1]
[1]: https://i.stack.imgur.com/CVzW4.png | 0debug |
generate regex to match strings : <p>i want a regex that can matche:</p>
<p><a href="https://share.host.com/" rel="nofollow noreferrer">https://share.host.com/</a></p>
<p><a href="https://media.host.com/" rel="nofollow noreferrer">https://media.host.com/</a></p>
<p><a href="https://lost.host.com/" rel="nofollow noreferrer">https://lost.host.com/</a></p>
<p><a href="https://found.host.com/" rel="nofollow noreferrer">https://found.host.com/</a></p>
<p><a href="https://anything.host.com/" rel="nofollow noreferrer">https://anything.host.com/</a></p>
<p>So basically i want the regex to match https://*.host.com/</p>
<p>Note: Am not asking for some website that can generate the regex and am not asking how to generate it neither am asking to learn how to generate regex. I just need the answer from anybody who is experienced in regex matching.</p>
| 0debug |
static void qtrle_decode_24bpp(QtrleContext *s)
{
int stream_ptr;
int header;
int start_line;
int lines_to_change;
signed char rle_code;
int row_ptr, pixel_ptr;
int row_inc = s->frame.linesize[0];
unsigned char r, g, b;
unsigned char *rgb = s->frame.data[0];
int pixel_limit = s->frame.linesize[0] * s->avctx->height;
if (s->size < 8)
return;
stream_ptr = 4;
CHECK_STREAM_PTR(2);
header = BE_16(&s->buf[stream_ptr]);
stream_ptr += 2;
if (header & 0x0008) {
CHECK_STREAM_PTR(8);
start_line = BE_16(&s->buf[stream_ptr]);
stream_ptr += 4;
lines_to_change = BE_16(&s->buf[stream_ptr]);
stream_ptr += 4;
} else {
start_line = 0;
lines_to_change = s->avctx->height;
}
row_ptr = row_inc * start_line;
while (lines_to_change--) {
CHECK_STREAM_PTR(2);
pixel_ptr = row_ptr + (s->buf[stream_ptr++] - 1) * 3;
while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) {
if (rle_code == 0) {
CHECK_STREAM_PTR(1);
pixel_ptr += (s->buf[stream_ptr++] - 1) * 3;
CHECK_PIXEL_PTR(0);
} else if (rle_code < 0) {
rle_code = -rle_code;
CHECK_STREAM_PTR(3);
r = s->buf[stream_ptr++];
g = s->buf[stream_ptr++];
b = s->buf[stream_ptr++];
CHECK_PIXEL_PTR(rle_code * 3);
while (rle_code--) {
rgb[pixel_ptr++] = r;
rgb[pixel_ptr++] = g;
rgb[pixel_ptr++] = b;
}
} else {
CHECK_STREAM_PTR(rle_code * 3);
CHECK_PIXEL_PTR(rle_code * 3);
while (rle_code--) {
rgb[pixel_ptr++] = s->buf[stream_ptr++];
rgb[pixel_ptr++] = s->buf[stream_ptr++];
rgb[pixel_ptr++] = s->buf[stream_ptr++];
}
}
}
row_ptr += row_inc;
}
}
| 1threat |
static int ram_load_dead(QEMUFile *f, void *opaque)
{
RamDecompressState s1, *s = &s1;
uint8_t buf[10];
ram_addr_t i;
if (ram_decompress_open(s, f) < 0)
return -EINVAL;
for(i = 0; i < last_ram_offset; i+= BDRV_HASH_BLOCK_SIZE) {
if (ram_decompress_buf(s, buf, 1) < 0) {
fprintf(stderr, "Error while reading ram block header\n");
goto error;
}
if (buf[0] == 0) {
if (ram_decompress_buf(s, qemu_get_ram_ptr(i),
BDRV_HASH_BLOCK_SIZE) < 0) {
fprintf(stderr, "Error while reading ram block address=0x%08" PRIx64, (uint64_t)i);
goto error;
}
} else {
error:
printf("Error block header\n");
return -EINVAL;
}
}
ram_decompress_close(s);
return 0;
}
| 1threat |
static inline int draw_glyph_yuv(AVFilterBufferRef *picref, FT_Bitmap *bitmap, unsigned int x,
unsigned int y, unsigned int width, unsigned int height,
const uint8_t yuva_color[4], int hsub, int vsub)
{
int r, c, alpha;
unsigned int luma_pos, chroma_pos1, chroma_pos2;
uint8_t src_val;
for (r = 0; r < bitmap->rows && r+y < height; r++) {
for (c = 0; c < bitmap->width && c+x < width; c++) {
src_val = GET_BITMAP_VAL(r, c);
if (!src_val)
continue;
SET_PIXEL_YUV(picref, yuva_color, src_val, c+x, y+r, hsub, vsub);
}
}
return 0;
}
| 1threat |
how can i make custom popup menu with default width and hight? : <p>I want popup menu with default width and height.</p>
<p><a href="https://i.stack.imgur.com/IIYKC.jpg" rel="nofollow noreferrer">I want this type layout</a></p>
| 0debug |
How to create SparkSession from existing SparkContext : <p>I have a Spark application which using Spark 2.0 new API with <code>SparkSession</code>.
I am building this application on top of the another application which is using <code>SparkContext</code>. I would like to pass <code>SparkContext</code> to my application and initialize <code>SparkSession</code> using existing <code>SparkContext</code>. </p>
<p>However I could not find a way how to do that. I found that <code>SparkSession</code> constructor with <code>SparkContext</code> is private so I can't initialize it in that way and builder does not offer any <code>setSparkContext</code> method. Do you think there exist some workaround? </p>
| 0debug |
How can I properly use for loop in def? : <pre><code>def kolas(lst, n):
for i in range(0, len(lst)):
e = []
x = lst[i] % n
e.append(x)
return x
</code></pre>
<p>I noticed that for loop doesn't affect in def() - <strong>i</strong> is only assigned by the first value of the list. Does exist funcion like for loop that affects in def()?</p>
| 0debug |
Creating and using an Elixir helpers module in Phoenix : <p>I have a group of acceptance tests I've created in my faux blog phoenix app. There's some duplicated logic between them I'd like to move to a helpers module to keep things DRY. </p>
<p>Here is the directory structure:</p>
<pre><code>test/acceptance/post
├── create_test.exs
├── delete_test.exs
├── helpers.exs
├── index_test.exs
└── update_test.exs
</code></pre>
<p>The <code>helpers.exs</code> file is where I'd like to stick the duplicated acceptance test logic. It looks something like:</p>
<pre class="lang-rb prettyprint-override"><code>defmodule Blog.Acceptance.Post.Helpers do
def navigate_to_posts_index_page do
# some code
end
end
</code></pre>
<p>Then in one of my test files, say <code>index_test.exs</code>, I'd like to import the helpers module to use it's methods:</p>
<pre class="lang-rb prettyprint-override"><code>defmodule Blog.Acceptance.Post.IndexTest do
import Blog.Acceptance.Post.Helpers
end
</code></pre>
<p>However, I'm getting this error:</p>
<blockquote>
<p>** (CompileError) test/acceptance/post/index_test.exs:7: module Blog.Acceptance.Post.Helpers is not loaded and could not be found</p>
</blockquote>
<p>How do I get access to or load the helper module in my test files?</p>
| 0debug |
[Android Studio]Could not find com.android.tools.build:aapt2:3.2.0-4818971 : Could not find com.android.tools.build:aapt2:3.2.0-4818971.
Searched in the following locations:
file:/Users/delevinying/Library/Android/sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/Users/delevinying/Library/Android/sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-osx.jar
file:/Users/delevinying/Library/Android/sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/Users/delevinying/Library/Android/sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-osx.jar
file:/Users/delevinying/Library/Android/sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/Users/delevinying/Library/Android/sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-osx.jar
https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-osx.jar
Required by:
project :app | 0debug |
Unusual character when writing to file : <p>I've created a struct with 2 char[] and one int. I created an array of this struct and <code>scanf</code>ed several inputs to store data into the array. Then I used <code>fprintf</code> to write this data to the file. But when I open the file I get <code>û</code> before every new record. Idk why is it happening.</p>
<p>Here's the relevant code:</p>
<pre><code>FILE *outputFile=fopen("1021.txt","ab");
int tickets=0,i=1;
struct air s[30];
printf("\nEnter Number of tickets:");
scanf("%d",&tickets);
for (i=1;i<=tickets;i++)
{
printf("\nEnter the name\t");
scanf("%s",&s[i].name);
printf("\nEnter the phone number\t");
scanf("%s",&s[i].phoneNo);
printf("\n Enter the address\t");
scanf("%s",&s[i].address);
printf("Your ticket is confirmed\t");
getch();
}
for (i=0;i<=tickets;i++)
{
printf("%s", s[i].name);
printf("%s", s[i].phoneNo);
printf("%s", s[i].address);
fprintf(outputFile,"%s",s[i].name);
fprintf(outputFile,"%s",s[i].phoneNo);
fprintf(outputFile,"%s",s[i].address);
}
</code></pre>
<p>Here's what I get in the file:
ûdalla03332228458dallaÈfsÇûÿÿÿÿàrancho03312041265dallabancho</p>
<p>Where are those unusual characters coming from?</p>
| 0debug |
Divide elements on groups in RecyclerView : <p>I need to divide elements in RecyclerView on groups with titles (like in the Inbox app on the picture below) so help me please to figure out what approach would be better for my case:
1) I can use Heterogenous layouts for it but it is not so convenient to insert new elements in groups (because I need check if elements of the same group is already added or I need to add new divider). So in this case I'll wrap all operations with such data structure into a separate class.</p>
<p>2) Theoretically I can wrap each group in its own RecyclerView with label is it a good idea?</p>
<p><a href="https://i.stack.imgur.com/XlxLu.png" rel="noreferrer"><img src="https://i.stack.imgur.com/XlxLu.png" alt="Inbox app"></a></p>
| 0debug |
How to compress image size using UIImagePNGRepresentation - iOS? : <p>I'm using <code>UIImagePNGRepresentation</code> to save an image. The result image is of size 30+ KB and this is BIG in my case. </p>
<p>I tried using <code>UIImageJPEGRepresentation</code> and it allows to compress image, so image saves in < 5KB size, which is great, but saving it in JPEG gives it white background, which i don't want (my image is circular, so I need to save it with transparent background).</p>
<p>How can I compress image size, using <code>UIImagePNGRepresentation</code>?</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.