problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
Django manage.py --no-input . Yes or no? : <p>I can't find this in the docs. When I run <code>python manage.py collecstatic --no-input</code> does it mean it will answer "yes" to any prompt that would pop up in the process? The same for <code>python manage.py migrate --no-input</code>. </p>
| 0debug |
static void free_duplicate_context(MpegEncContext *s)
{
if (s == NULL)
return;
av_freep(&s->edge_emu_buffer);
av_freep(&s->me.scratchpad);
s->me.temp =
s->rd_scratchpad =
s->b_scratchpad =
s->obmc_scratchpad = NULL;
av_freep(&s->dct_error_sum);
av_freep(&s->me.map);
av_freep(&s->me.score_map);
av_freep(&s->blocks);
av_freep(&s->ac_val_base);
s->block = NULL;
}
| 1threat |
Managing events in flutter's TextFormField : <p>In Flutter project, I need to listen to the input text in TextFormField and do certain actions, especially when user put some character (eg. space) in this filed or when he request focus. When this kind of event happen, I need to modify filed's value.
I know there is a property <code>called controller</code> but I don't know how to use it in this case.</p>
<p>Thank you in advance.</p>
| 0debug |
JavaScript getBoundingClientRect() vs offsetHeight while calculate element height : <p>What is the best way to get element height:</p>
<pre><code>var myElement = document.querySelector('.some-class');
var height = myElement.getBoundingClientRect().height;
</code></pre>
<p>or</p>
<pre><code>var myElement = document.querySelector('.some-class');
var height = myElement.offsetHeight;
</code></pre>
| 0debug |
static void m68k_cpu_realizefn(DeviceState *dev, Error **errp)
{
M68kCPU *cpu = M68K_CPU(dev);
M68kCPUClass *mcc = M68K_CPU_GET_CLASS(dev);
m68k_cpu_init_gdb(cpu);
cpu_reset(CPU(cpu));
mcc->parent_realize(dev, errp);
}
| 1threat |
Hoverable sidebar manu or right side : <p>I am searching for sidebar manu on right side. I want a hidden sidebar which appears when you scroll on it.
Very similar sidebar to that of <a href="https://www.psx.com.pk" rel="nofollow noreferrer">https://www.psx.com.pk</a></p>
| 0debug |
static void handle_notify(EventNotifier *e)
{
VirtIOBlockDataPlane *s = container_of(e, VirtIOBlockDataPlane,
host_notifier);
VirtIOBlock *vblk = VIRTIO_BLK(s->vdev);
event_notifier_test_and_clear(&s->host_notifier);
blk_io_plug(s->conf->conf.blk);
for (;;) {
MultiReqBuffer mrb = {};
int ret;
vring_disable_notification(s->vdev, &s->vring);
for (;;) {
VirtIOBlockReq *req = virtio_blk_alloc_request(vblk);
ret = vring_pop(s->vdev, &s->vring, &req->elem);
if (ret < 0) {
virtio_blk_free_request(req);
break;
}
trace_virtio_blk_data_plane_process_request(s, req->elem.out_num,
req->elem.in_num,
req->elem.index);
virtio_blk_handle_request(req, &mrb);
}
if (mrb.num_reqs) {
virtio_blk_submit_multireq(s->conf->conf.blk, &mrb);
}
if (likely(ret == -EAGAIN)) {
if (vring_enable_notification(s->vdev, &s->vring)) {
break;
}
} else {
break;
}
}
blk_io_unplug(s->conf->conf.blk);
}
| 1threat |
How do I find the language declaration for this Chinese website? : <p>I need to record some detailed info for a number of web pages. Most of this info I've been finding by inspecting each page's HTML code.</p>
<p>For the language attribute, I've been searching 'lang', 'language', and 'content-language' if the info isn't readily available in the metadata or header. Which until now has been working.</p>
<p>I'm stumped on a Chinese site. I've scrolled though a lot of the site's code, but I'm not familiar with HTML or XML or website programming in general, so I don't know whether I'm looking in the wrong spot or if I should be looking for something else entirely.</p>
<p>This is the individual <a href="http://zhushou.360.cn/detail/index/soft_id/2844111?recrefer=SE_D_%E5%A5%A5%E6%96%AF%E5%8D%A1" rel="nofollow noreferrer">product page</a> I started at. I've looked at the code for the <a href="http://zhushou.360.cn/" rel="nofollow noreferrer">main site</a> too with no luck.</p>
| 0debug |
static void destroy_l2_mapping(PhysPageEntry *lp, unsigned level)
{
unsigned i;
PhysPageEntry *p;
if (lp->ptr == PHYS_MAP_NODE_NIL) {
return;
}
p = phys_map_nodes[lp->ptr];
for (i = 0; i < L2_SIZE; ++i) {
if (!p[i].is_leaf) {
destroy_l2_mapping(&p[i], level - 1);
} else {
destroy_page_desc(p[i].ptr);
}
}
lp->is_leaf = 0;
lp->ptr = PHYS_MAP_NODE_NIL;
}
| 1threat |
Why am I getting "LinAlgError: Singular matrix" from grangercausalitytests? : <p>I am trying to run <code>grangercausalitytests</code> on two time series:</p>
<pre><code>import numpy as np
import pandas as pd
from statsmodels.tsa.stattools import grangercausalitytests
n = 1000
ls = np.linspace(0, 2*np.pi, n)
df1 = pd.DataFrame(np.sin(ls))
df2 = pd.DataFrame(2*np.sin(1+ls))
df = pd.concat([df1, df2], axis=1)
df.plot()
grangercausalitytests(df, maxlag=20)
</code></pre>
<p>However, I am getting</p>
<pre class="lang-none prettyprint-override"><code>Granger Causality
number of lags (no zero) 1
ssr based F test: F=272078066917221398041264652288.0000, p=0.0000 , df_denom=996, df_num=1
ssr based chi2 test: chi2=272897579166972095424217743360.0000, p=0.0000 , df=1
likelihood ratio test: chi2=60811.2671, p=0.0000 , df=1
parameter F test: F=272078066917220553616334520320.0000, p=0.0000 , df_denom=996, df_num=1
Granger Causality
number of lags (no zero) 2
ssr based F test: F=7296.6976, p=0.0000 , df_denom=995, df_num=2
ssr based chi2 test: chi2=14637.3954, p=0.0000 , df=2
likelihood ratio test: chi2=2746.0362, p=0.0000 , df=2
parameter F test: F=13296850090491009488285469769728.0000, p=0.0000 , df_denom=995, df_num=2
...
/usr/local/lib/python3.5/dist-packages/numpy/linalg/linalg.py in _raise_linalgerror_singular(err, flag)
88
89 def _raise_linalgerror_singular(err, flag):
---> 90 raise LinAlgError("Singular matrix")
91
92 def _raise_linalgerror_nonposdef(err, flag):
LinAlgError: Singular matrix
</code></pre>
<p>and I am not sure why this is the case. </p>
| 0debug |
How i know QTimer time since start value? : How i know QTimer time since start value ??
"timer->interval()" this method is not counting...
I need about timer since start counting value.
please help me..
| 0debug |
static int http_send_data(HTTPContext *c)
{
int len, ret;
for(;;) {
if (c->buffer_ptr >= c->buffer_end) {
ret = http_prepare_data(c);
if (ret < 0)
return -1;
else if (ret != 0)
break;
} else {
if (c->is_packetized) {
len = c->buffer_end - c->buffer_ptr;
if (len < 4) {
fail1:
c->buffer_ptr = c->buffer_end;
return 0;
}
len = (c->buffer_ptr[0] << 24) |
(c->buffer_ptr[1] << 16) |
(c->buffer_ptr[2] << 8) |
(c->buffer_ptr[3]);
if (len > (c->buffer_end - c->buffer_ptr))
goto fail1;
if ((get_packet_send_clock(c) - get_server_clock(c)) > 0) {
return 0;
}
c->data_count += len;
update_datarate(&c->datarate, c->data_count);
if (c->stream)
c->stream->bytes_served += len;
if (c->rtp_protocol == RTSP_LOWER_TRANSPORT_TCP) {
AVIOContext *pb;
int interleaved_index, size;
uint8_t header[4];
HTTPContext *rtsp_c;
rtsp_c = c->rtsp_c;
if (!rtsp_c)
return -1;
if (rtsp_c->state != RTSPSTATE_WAIT_REQUEST)
break;
if (avio_open_dyn_buf(&pb) < 0)
goto fail1;
interleaved_index = c->packet_stream_index * 2;
if (c->buffer_ptr[1] == 200)
interleaved_index++;
header[0] = '$';
header[1] = interleaved_index;
header[2] = len >> 8;
header[3] = len;
avio_write(pb, header, 4);
c->buffer_ptr += 4;
avio_write(pb, c->buffer_ptr, len);
size = avio_close_dyn_buf(pb, &c->packet_buffer);
rtsp_c->packet_buffer_ptr = c->packet_buffer;
rtsp_c->packet_buffer_end = c->packet_buffer + size;
c->buffer_ptr += len;
len = send(rtsp_c->fd, rtsp_c->packet_buffer_ptr,
rtsp_c->packet_buffer_end - rtsp_c->packet_buffer_ptr, 0);
if (len > 0)
rtsp_c->packet_buffer_ptr += len;
if (rtsp_c->packet_buffer_ptr < rtsp_c->packet_buffer_end) {
rtsp_c->state = RTSPSTATE_SEND_PACKET;
break;
} else
av_freep(&c->packet_buffer);
} else {
c->buffer_ptr += 4;
ffurl_write(c->rtp_handles[c->packet_stream_index],
c->buffer_ptr, len);
c->buffer_ptr += len;
}
} else {
len = send(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr, 0);
if (len < 0) {
if (ff_neterrno() != AVERROR(EAGAIN) &&
ff_neterrno() != AVERROR(EINTR))
return -1;
else
return 0;
} else
c->buffer_ptr += len;
c->data_count += len;
update_datarate(&c->datarate, c->data_count);
if (c->stream)
c->stream->bytes_served += len;
break;
}
}
}
return 0;
}
| 1threat |
static void do_sdl_resize(int new_width, int new_height, int bpp)
{
int flags;
flags = SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL|SDL_RESIZABLE;
if (gui_fullscreen)
flags |= SDL_FULLSCREEN;
if (gui_noframe)
flags |= SDL_NOFRAME;
width = new_width;
height = new_height;
real_screen = SDL_SetVideoMode(width, height, bpp, flags);
if (!real_screen) {
fprintf(stderr, "Could not open SDL display (%dx%dx%d): %s\n", width,
height, bpp, SDL_GetError());
exit(1);
}
}
| 1threat |
Never saw this operator before : <p>I was reading a source from laravel project and then i found this line:</p>
<pre><code>$this->crawler() ?: $this->response->getContent()
</code></pre>
<p>Does <code>?:</code> do something special? In php?</p>
<p>I dont remember seeing that in any other place</p>
| 0debug |
void helper_stsw(CPUPPCState *env, target_ulong addr, uint32_t nb,
uint32_t reg)
{
int sh;
for (; nb > 3; nb -= 4) {
cpu_stl_data(env, addr, env->gpr[reg]);
reg = (reg + 1) % 32;
addr = addr_add(env, addr, 4);
}
if (unlikely(nb > 0)) {
for (sh = 24; nb > 0; nb--, sh -= 8) {
cpu_stb_data(env, addr, (env->gpr[reg] >> sh) & 0xFF);
addr = addr_add(env, addr, 1);
}
}
}
| 1threat |
static void tap_send(void *opaque)
{
TAPState *s = opaque;
int size;
do {
uint8_t *buf = s->buf;
size = tap_read_packet(s->fd, s->buf, sizeof(s->buf));
if (size <= 0) {
break;
}
if (s->host_vnet_hdr_len && !s->using_vnet_hdr) {
buf += s->host_vnet_hdr_len;
size -= s->host_vnet_hdr_len;
}
size = qemu_send_packet_async(&s->nc, buf, size, tap_send_completed);
if (size == 0) {
tap_read_poll(s, false);
}
} while (size > 0 && qemu_can_send_packet(&s->nc));
}
| 1threat |
react native how to call multiple functions when onPress is clicked : <p>I am trying to call multiple functions when I click <code>onPress</code> using <code>TouchableOpacity</code></p>
<p>For example:</p>
<pre><code>functionOne(){
// do something
}
functionTwo(){
// do someting
}
<TouchableHighlight onPress{() => this.functionOne()}/>
</code></pre>
<p>What if I want to call two functions when <code>onPress</code> is clicked? Is there a way I could call multiple functions?</p>
| 0debug |
How to schedule send message in Quickblox android : I want create scheduled send message function in my chat application. Quickblox Android support to do it? | 0debug |
How to set objects around circle correctly on UIView : <p>I've write some code to place objects around circle that locate on center of the Custom view, but it not perfectly around the circle. I don't know where of the code is wrong.</p>
<p><a href="https://i.stack.imgur.com/HfTDD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HfTDD.png" alt="enter image description here"></a></p>
<p>Here is the code:</p>
<pre><code>func createObjectsAroundCircle() {
let center = CGPointMake(bounds.width/2 ,bounds.height/2)
let radius : CGFloat = 100
let count = 20
var angle = CGFloat(2 * M_PI)
let step = CGFloat(2 * M_PI) / CGFloat(count)
let circlePath = UIBezierPath(arcCenter: center, radius: radius, startAngle: CGFloat(0), endAngle:CGFloat(M_PI * 2), clockwise: true)
let shapeLayer = CAShapeLayer()
shapeLayer.path = circlePath.CGPath
shapeLayer.fillColor = UIColor.clearColor().CGColor
shapeLayer.strokeColor = UIColor.redColor().CGColor
shapeLayer.lineWidth = 3.0
self.layer.addSublayer(shapeLayer)
// set objects around circle
for var index = 0; index < count ; index++ {
let x = cos(angle) * radius + center.x
let y = sin(angle) * radius + center.y
let label = UILabel()
label.text = "\(index)"
label.frame.origin.x = x
label.frame.origin.y = y
label.font = UIFont(name: "Arial", size: 20)
label.textColor = UIColor.blackColor()
label.sizeToFit()
self.addSubview(label)
angle += step
}
}
</code></pre>
| 0debug |
How to install SQL server 2012 in freshly installed 64-bit windows 7? : Please advise how to install sql server 2012 on freshly installed 64-bit Windows 7. I was trying to install, but couldn't do so because of some system error.
1. Do I have to install Visual Studio?
2. Can it run without MS visual Studio?
Below is the error that occurs while installing please advise.
TITLE: Microsoft SQL Server 2012 Setup
------------------------------
The following error has occurred:SQL Server Setup has encountered an error when running a Windows Installer file. Windows Installer error message: The system cannot find the file specified.
Windows Installer file: e:\f6022cc40a039c86e714c5717dd648\redist\VisualStudioShell\VC10SP1\vc_red.msi
Windows Installer log file: C:\Program Files (x86)\Microsoft SQL Server\110\Setup Bootstrap\Log\20170722_213946\VC10Redist_Cpu64_1_ComponentUpdate.log
Click 'Retry' to retry the failed action, or click 'Cancel' to cancel this action and continue setup.
For help, click: http://go.microsoft.com/fwlink?LinkID=20476&ProdName=Microsoft%20SQL%20Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=11.0.2100.60&EvtType=0xC24842DB
------------------------------
BUTTONS:
&Retry
Cancel
------------------------------
[enter image description here][1]
[1]: https://i.stack.imgur.com/Fr6PQ.jpg | 0debug |
Exporting Video in full screen with AVAssetExportSession : <p>i'm trying to do some animations to a video (after recording) and then export it.
but before any animation i had the problem with the orientation which became landscape (without export it was portrait) and it is solved not but now i have problem with making it full screen.in iphone 6,7 plus its full screen how ever in ipad it is not.</p>
<p>here is my method :</p>
<pre><code>func export(_ url : URL) {
let composition = AVMutableComposition()
let asset = AVURLAsset(url: url, options: nil)
let track = asset.tracks(withMediaType : AVMediaTypeVideo)
let videoTrack:AVAssetTrack = track[0] as AVAssetTrack
let timerange = CMTimeRangeMake(kCMTimeZero, asset.duration)
let compositionVideoTrack:AVMutableCompositionTrack = composition.addMutableTrack(withMediaType: AVMediaTypeVideo, preferredTrackID: CMPersistentTrackID())
do {
try compositionVideoTrack.insertTimeRange(timerange, of: videoTrack, at: kCMTimeZero)
} catch {
print(error)
}
let compositionAudioTrack:AVMutableCompositionTrack = composition.addMutableTrack(withMediaType: AVMediaTypeAudio, preferredTrackID: CMPersistentTrackID())
for audioTrack in asset.tracks(withMediaType: AVMediaTypeAudio) {
do {
try compositionAudioTrack.insertTimeRange(audioTrack.timeRange, of: audioTrack, at: kCMTimeZero)
} catch {
print(error)
}
}
let size = self.view.bounds.size
let videolayer = CALayer()
videolayer.frame = CGRect(x: 0, y: 0, width: size.width, height: size.height)
let parentlayer = CALayer()
parentlayer.frame = CGRect(x: 0, y: 0, width: size.width, height: size.height)
parentlayer.addSublayer(videolayer)
let layercomposition = AVMutableVideoComposition()
layercomposition.frameDuration = CMTimeMake(1, 30)
layercomposition.renderSize = self.view.bounds.size
layercomposition.animationTool = AVVideoCompositionCoreAnimationTool(postProcessingAsVideoLayer: videolayer, in: parentlayer)
let instruction = AVMutableVideoCompositionInstruction()
instruction.timeRange = CMTimeRangeMake(kCMTimeZero, asset.duration)
let videotrack = composition.tracks(withMediaType: AVMediaTypeVideo)[0] as AVAssetTrack
let layerinstruction = AVMutableVideoCompositionLayerInstruction(assetTrack: videotrack)
let ratio = size.height / videoTrack.naturalSize.width
composition.naturalSize = videoTrack.naturalSize
layerinstruction.setTransform(videoTrack.preferredTransform.scaledBy(x: 0.645 , y: ratio).translatedBy(x: self.view.bounds.height, y: 0), at: kCMTimeZero)
instruction.layerInstructions = [layerinstruction]
layercomposition.instructions = [instruction]
let filePath = self.fileName()
let movieUrl = URL(fileURLWithPath: filePath)
guard let assetExport = AVAssetExportSession(asset: composition, presetName:AVAssetExportPresetHighestQuality) else {return}
assetExport.videoComposition = layercomposition
assetExport.outputFileType = AVFileTypeMPEG4
assetExport.outputURL = movieUrl
assetExport.exportAsynchronously(completionHandler: {
switch assetExport.status {
case .completed:
print("success")
let player = AVPlayer(url: movieUrl)
let playerViewController = AVPlayerViewController()
playerViewController.player = player
self.present(playerViewController, animated: true) {
playerViewController.player!.play()
}
break
case .cancelled:
print("cancelled")
break
case .exporting:
print("exporting")
break
case .failed:
print("failed: \(String(describing: assetExport.error))")
break
case .unknown:
print("unknown")
break
case .waiting:
print("waiting")
break
}
})
}
</code></pre>
| 0debug |
int ff_pre_estimate_p_frame_motion(MpegEncContext * s,
int mb_x, int mb_y)
{
int mx, my, range, dmin;
int xmin, ymin, xmax, ymax;
int rel_xmin, rel_ymin, rel_xmax, rel_ymax;
int pred_x=0, pred_y=0;
int P[10][2];
const int shift= 1+s->quarter_sample;
uint16_t * const mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV;
const int mv_stride= s->mb_width + 2;
const int xy= mb_x + 1 + (mb_y + 1)*mv_stride;
assert(s->quarter_sample==0 || s->quarter_sample==1);
s->me.pre_penalty_factor = get_penalty_factor(s, s->avctx->me_pre_cmp);
get_limits(s, &range, &xmin, &ymin, &xmax, &ymax, s->f_code);
rel_xmin= xmin - mb_x*16;
rel_xmax= xmax - mb_x*16;
rel_ymin= ymin - mb_y*16;
rel_ymax= ymax - mb_y*16;
s->me.skip=0;
P_LEFT[0] = s->p_mv_table[xy + 1][0];
P_LEFT[1] = s->p_mv_table[xy + 1][1];
if(P_LEFT[0] < (rel_xmin<<shift)) P_LEFT[0] = (rel_xmin<<shift);
if (mb_y == s->mb_height-1) {
pred_x= P_LEFT[0];
pred_y= P_LEFT[1];
P_TOP[0]= P_TOPRIGHT[0]= P_MEDIAN[0]=
P_TOP[1]= P_TOPRIGHT[1]= P_MEDIAN[1]= 0;
} else {
P_TOP[0] = s->p_mv_table[xy + mv_stride ][0];
P_TOP[1] = s->p_mv_table[xy + mv_stride ][1];
P_TOPRIGHT[0] = s->p_mv_table[xy + mv_stride - 1][0];
P_TOPRIGHT[1] = s->p_mv_table[xy + mv_stride - 1][1];
if(P_TOP[1] < (rel_ymin<<shift)) P_TOP[1] = (rel_ymin<<shift);
if(P_TOPRIGHT[0] > (rel_xmax<<shift)) P_TOPRIGHT[0]= (rel_xmax<<shift);
if(P_TOPRIGHT[1] < (rel_ymin<<shift)) P_TOPRIGHT[1]= (rel_ymin<<shift);
P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
pred_x = P_MEDIAN[0];
pred_y = P_MEDIAN[1];
}
dmin = s->me.pre_motion_search(s, 0, &mx, &my, P, pred_x, pred_y, rel_xmin, rel_ymin, rel_xmax, rel_ymax,
&s->last_picture, s->p_mv_table, (1<<16)>>shift, mv_penalty);
s->p_mv_table[xy][0] = mx<<shift;
s->p_mv_table[xy][1] = my<<shift;
return dmin;
}
| 1threat |
static int opus_decode_packet(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
OpusContext *c = avctx->priv_data;
AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int coded_samples = 0;
int decoded_samples = 0;
int i, ret;
if (buf) {
OpusPacket *pkt = &c->streams[0].packet;
ret = ff_opus_parse_packet(pkt, buf, buf_size, c->nb_streams > 1);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error parsing the packet header.\n");
return ret;
coded_samples += pkt->frame_count * pkt->frame_duration;
c->streams[0].silk_samplerate = get_silk_samplerate(pkt->config);
frame->nb_samples = coded_samples + c->streams[0].delayed_samples;
if (!frame->nb_samples) {
*got_frame_ptr = 0;
return 0;
ret = ff_get_buffer(avctx, frame, 0);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
frame->nb_samples = 0;
for (i = 0; i < avctx->channels; i++) {
ChannelMap *map = &c->channel_maps[i];
if (!map->copy)
c->streams[map->stream_idx].out[map->channel_idx] = (float*)frame->extended_data[i];
for (i = 0; i < c->nb_streams; i++)
c->streams[i].out_size = frame->linesize[0];
for (i = 0; i < c->nb_streams; i++) {
OpusStreamContext *s = &c->streams[i];
if (i && buf) {
ret = ff_opus_parse_packet(&s->packet, buf, buf_size, i != c->nb_streams - 1);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error parsing the packet header.\n");
return ret;
s->silk_samplerate = get_silk_samplerate(s->packet.config);
ret = opus_decode_subpacket(&c->streams[i], buf,
s->packet.data_size, coded_samples);
if (ret < 0)
return ret;
if (decoded_samples && ret != decoded_samples) {
av_log(avctx, AV_LOG_ERROR, "Different numbers of decoded samples "
"in a multi-channel stream\n");
decoded_samples = ret;
buf += s->packet.packet_size;
buf_size -= s->packet.packet_size;
for (i = 0; i < avctx->channels; i++) {
ChannelMap *map = &c->channel_maps[i];
if (map->copy) {
memcpy(frame->extended_data[i],
frame->extended_data[map->copy_idx],
frame->linesize[0]);
} else if (map->silence) {
memset(frame->extended_data[i], 0, frame->linesize[0]);
if (c->gain_i) {
c->fdsp.vector_fmul_scalar((float*)frame->extended_data[i],
(float*)frame->extended_data[i],
c->gain, FFALIGN(decoded_samples, 8));
frame->nb_samples = decoded_samples;
*got_frame_ptr = !!decoded_samples;
return avpkt->size; | 1threat |
bash script- change string in a file in all directories : <p>how can i write a <strong>script in bash</strong>
that:
go to a directory A
run on all directories in A and look for another directory B (which is in part of these directories in A)
after find B need to change a string with another string in a clj file</p>
<p>thank's</p>
| 0debug |
QemuOptsList *qemu_opts_append(QemuOptsList *dst,
QemuOptsList *list)
{
size_t num_opts, num_dst_opts;
QemuOptDesc *desc;
bool need_init = false;
if (!list) {
return dst;
}
if (!dst) {
need_init = true;
}
num_opts = count_opts_list(dst);
num_dst_opts = num_opts;
num_opts += count_opts_list(list);
dst = g_realloc(dst, sizeof(QemuOptsList) +
(num_opts + 1) * sizeof(QemuOptDesc));
if (need_init) {
dst->name = NULL;
dst->implied_opt_name = NULL;
QTAILQ_INIT(&dst->head);
dst->merge_lists = false;
}
dst->desc[num_dst_opts].name = NULL;
if (list) {
desc = list->desc;
while (desc && desc->name) {
if (find_desc_by_name(dst->desc, desc->name) == NULL) {
dst->desc[num_dst_opts++] = *desc;
dst->desc[num_dst_opts].name = NULL;
}
desc++;
}
}
return dst;
}
| 1threat |
void cpu_interrupt(CPUState *env, int mask)
{
int old_mask;
old_mask = env->interrupt_request;
env->interrupt_request |= mask;
#ifndef CONFIG_USER_ONLY
if (!qemu_cpu_self(env)) {
qemu_cpu_kick(env);
return;
}
#endif
if (use_icount) {
env->icount_decr.u16.high = 0xffff;
#ifndef CONFIG_USER_ONLY
if (!can_do_io(env)
&& (mask & ~old_mask) != 0) {
cpu_abort(env, "Raised interrupt while not in I/O function");
}
#endif
} else {
cpu_unlink_tb(env);
}
}
| 1threat |
Efficiently reading and writing mixed data types in C++-11 : <p>Efficient way of writing and reading mixed datatypes (viz. unsigned integer, double, uint64_t, string) on file in c++.</p>
<p>I need to write and read a data containing mixed data-types on disk. I used the following method to write data. However it is turning out to be very slow. </p>
<pre><code>fstream myFile;
myFile.open("myFile", ios::binary, ios::out);
double x; //with appropriate initialization
myFile<<x;
int y;
myFile<<y;
uint64_t z;
myFile<<z;
string myString;
myFile<<myString;
</code></pre>
<p>However, this method is turning out to be very inefficient for large data of size 20 GB. Can someone please suggest as to how I can quickly read and write mixed datatypes in c++</p>
| 0debug |
static int stdio_fclose(void *opaque)
{
QEMUFileStdio *s = opaque;
int ret = 0;
if (qemu_file_is_writable(s->file)) {
int fd = fileno(s->stdio_file);
struct stat st;
ret = fstat(fd, &st);
if (ret == 0 && S_ISREG(st.st_mode)) {
ret = fsync(fd);
if (ret != 0) {
ret = -errno;
return ret;
}
}
}
if (fclose(s->stdio_file) == EOF) {
ret = -errno;
}
g_free(s);
return ret;
}
| 1threat |
static int get_qcc(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q,
uint8_t *properties)
{
int compno;
if (s->buf_end - s->buf < 1)
return AVERROR(EINVAL);
compno = bytestream_get_byte(&s->buf);
properties[compno] |= HAD_QCC;
return get_qcx(s, n - 1, q + compno);
}
| 1threat |
static GtkWidget *gd_create_menu_view(GtkDisplayState *s, GtkAccelGroup *accel_group)
{
GSList *group = NULL;
GtkWidget *view_menu;
GtkWidget *separator;
int i;
view_menu = gtk_menu_new();
gtk_menu_set_accel_group(GTK_MENU(view_menu), accel_group);
s->full_screen_item =
gtk_image_menu_item_new_from_stock(GTK_STOCK_FULLSCREEN, NULL);
gtk_menu_item_set_accel_path(GTK_MENU_ITEM(s->full_screen_item),
"<QEMU>/View/Full Screen");
gtk_accel_map_add_entry("<QEMU>/View/Full Screen", GDK_KEY_f, GDK_CONTROL_MASK | GDK_MOD1_MASK);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->full_screen_item);
separator = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), separator);
s->zoom_in_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_IN, NULL);
gtk_menu_item_set_accel_path(GTK_MENU_ITEM(s->zoom_in_item),
"<QEMU>/View/Zoom In");
gtk_accel_map_add_entry("<QEMU>/View/Zoom In", GDK_KEY_plus, GDK_CONTROL_MASK | GDK_MOD1_MASK);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->zoom_in_item);
s->zoom_out_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_OUT, NULL);
gtk_menu_item_set_accel_path(GTK_MENU_ITEM(s->zoom_out_item),
"<QEMU>/View/Zoom Out");
gtk_accel_map_add_entry("<QEMU>/View/Zoom Out", GDK_KEY_minus, GDK_CONTROL_MASK | GDK_MOD1_MASK);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->zoom_out_item);
s->zoom_fixed_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_100, NULL);
gtk_menu_item_set_accel_path(GTK_MENU_ITEM(s->zoom_fixed_item),
"<QEMU>/View/Zoom Fixed");
gtk_accel_map_add_entry("<QEMU>/View/Zoom Fixed", GDK_KEY_0, GDK_CONTROL_MASK | GDK_MOD1_MASK);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->zoom_fixed_item);
s->zoom_fit_item = gtk_check_menu_item_new_with_mnemonic(_("Zoom To _Fit"));
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->zoom_fit_item);
separator = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), separator);
s->grab_on_hover_item = gtk_check_menu_item_new_with_mnemonic(_("Grab On _Hover"));
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->grab_on_hover_item);
s->grab_item = gtk_check_menu_item_new_with_mnemonic(_("_Grab Input"));
gtk_menu_item_set_accel_path(GTK_MENU_ITEM(s->grab_item),
"<QEMU>/View/Grab Input");
gtk_accel_map_add_entry("<QEMU>/View/Grab Input", GDK_KEY_g, GDK_CONTROL_MASK | GDK_MOD1_MASK);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->grab_item);
separator = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), separator);
s->vga_item = gtk_radio_menu_item_new_with_mnemonic(group, "_VGA");
group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(s->vga_item));
gtk_menu_item_set_accel_path(GTK_MENU_ITEM(s->vga_item),
"<QEMU>/View/VGA");
gtk_accel_map_add_entry("<QEMU>/View/VGA", GDK_KEY_1, GDK_CONTROL_MASK | GDK_MOD1_MASK);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->vga_item);
for (i = 0; i < nb_vcs; i++) {
VirtualConsole *vc = &s->vc[i];
group = gd_vc_init(s, vc, i, group, view_menu);
s->nb_vcs++;
}
separator = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), separator);
s->show_tabs_item = gtk_check_menu_item_new_with_mnemonic(_("Show _Tabs"));
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->show_tabs_item);
return view_menu;
}
| 1threat |
How to parse ISO 8601 into date and time format using Moment js in Javascript? : <p>I am currently using Moment js to parse an ISO 8601 string into date and time, but it is not working properly. What am I doing wrong? And I would take any other easier solutions as well. </p>
<p>The ISO 8601 I would like to parse: <code>"2011-04-11T10:20:30Z"</code> into date in string: <code>"2011-04-11"</code> and time in string: <code>"10:20:30"</code></p>
<p>And tried <code>console.log(moment("2011-04-11T10:20:30Z" ,moment.ISO_8601))</code> and <code>console.log(moment("2011-04-11T10:20:30Z" , ["YYYY",moment.ISO_8601])</code> as a test, but it just returns an object with all different kinds of properties. </p>
| 0debug |
No console output with MongoDB : <p>I have connected MongoDB to .NET and I'm trying to save data into the database. The program works fine and my data is inserted into the database, but my understanding from the documentation is that I should be able to see everything that is occurring in the console window as well. This is my sample program that I'm working on.</p>
<pre><code>static void Main(string[] args)
{
MainAsync().Wait();
Console.ReadLine();
}
static async Task MainAsync()
{
var client = new MongoClient("mongodb://localhost:27017");
IMongoDatabase db = client.GetDatabase("machines");
var collection = db.GetCollection<BsonDocument>("cranes");
var document = new BsonDocument
{
{ "code", BsonValue.Create("0x657")},
{ "departments", new BsonArray(new[] {"Mech", "Forge"}) },
};
await collection.InsertOneAsync(document);
}
</code></pre>
<p>This is the console output I am seeing when running the program.</p>
<p><a href="https://i.stack.imgur.com/6dWM9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6dWM9.png" alt="console_output"></a></p>
<p>I can see that the data has been succesffully added in MongoDB Compass, but I do not have any feedback in the console window.</p>
| 0debug |
Android Studio: Re-download dependencies and sync project : <p>I downloaded an open source game "<a href="https://github.com/tvbarthel/ChaseWhisplyProject" rel="noreferrer">ChaseWhisplyProject</a>" source code from Github.</p>
<p>I imported the project in my Android Studio (Version 1.5.1). </p>
<p>It shows following error message:</p>
<p>Error:Failed to open zip file.<br>
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)<br>
Re-download dependencies and sync project (requires network)<br>
Re-download dependencies and sync project (requires network)</p>
<p>I changed all the dependency versions to latest one bu still it is showing the same message.</p>
<p>It has two modules under the main project 1) BaseGameUtils & 2)ChaseWhisply.
The above modules are not shown in bold letters (I think it should be shown in bold letters like module "app").</p>
<p>Following are the gradle files.</p>
<p>1) Root Gradle:</p>
<pre><code>// Top-level build file where you can add configuration options common to all sub-projects/modules.
allprojects {
repositories {
jcenter()
}
}
</code></pre>
<p>2) BaseGameUtils Module Gradle</p>
<pre><code>apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
dependencies {
compile 'com.android.support:support-v4:23.1.1'
compile 'com.google.android.gms:play-services:8.4.0'
}
</code></pre>
<p>3) ChaseWhisply Module Gradle:</p>
<pre><code>buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
apply plugin: 'com.android.application'
dependencies {
compile 'com.android.support:gridlayout-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.nineoldandroids:library:2.4.0'
compile project(':BaseGameUtils')
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
lintOptions {
// TODO fix and remove !
disable 'MissingTranslation', 'DuplicateIds', 'ExtraTranslation'
}
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 22
versionName "0.3.6"
}
}
</code></pre>
<p>4) Settings.gradle</p>
<pre><code>include ':ChaseWhisply', ':BaseGameUtils'
</code></pre>
<p>What is wrong over here? Please help.</p>
| 0debug |
Timer counter in finite loop in php : <p>I want a timer counter in php example 1567 which will increment every second
and it goes till infinite even if some body refresh the page it counter will not starts from 1567 .but it should starts for where its is end.</p>
| 0debug |
textbox value cannot be change using javascript : <pre><code> document.getElementById("name").value = data;
</code></pre>
<p>it shows Uncaught TypeError: Cannot set property 'value' of null. why is this happen?</p>
<p>the data have the value.</p>
| 0debug |
static struct omap_mpu_timer_s *omap_mpu_timer_init(MemoryRegion *system_memory,
target_phys_addr_t base,
qemu_irq irq, omap_clk clk)
{
struct omap_mpu_timer_s *s = (struct omap_mpu_timer_s *)
g_malloc0(sizeof(struct omap_mpu_timer_s));
s->irq = irq;
s->clk = clk;
s->timer = qemu_new_timer_ns(vm_clock, omap_timer_tick, s);
s->tick = qemu_bh_new(omap_timer_fire, s);
omap_mpu_timer_reset(s);
omap_timer_clk_setup(s);
memory_region_init_io(&s->iomem, &omap_mpu_timer_ops, s,
"omap-mpu-timer", 0x100);
memory_region_add_subregion(system_memory, base, &s->iomem);
return s;
}
| 1threat |
write a trigger to dsiallow an employee joining between 6PM and 10 AM on weekdays :
CREATE TABLE JOINING_DETAILS(EMPNAME VARCHAR2(20),HIREDATE DATE);
CREATE OR REPLACE TRIGGER TERW<BR>
BEFORE INSERT ON JOINING_DETAILS<BR>
FOR EACH ROW
BEGIN
IF to_char(:NEW.HIREDATE,'HH24' )BETWEEN 18 AND 24 AND to_char(:NEW.HIREDATE,'HH24' ) BETWEEN 00 AND 10 THEN
RAISE_APPLICATION_ERROR(-20037,'NOT BETWEEN 6 PM TO 10 AM');
END IF;<BR>
END;
TRIGGER EXECUTED BUT I TRY TO INSERT VALUE FOR TIMING 20 IT INSERT INTO JOINING_DETAILS TABLE.....
INSERT INTO JOINING_DETAILS VALUES('PANDI',TO_DATE('20','HH24') );
HOW CAN I OVERCOME THIS....
| 0debug |
static void kvm_mce_inj_srar_dataload(CPUState *env, target_phys_addr_t paddr)
{
struct kvm_x86_mce mce = {
.bank = 9,
.status = MCI_STATUS_VAL | MCI_STATUS_UC | MCI_STATUS_EN
| MCI_STATUS_MISCV | MCI_STATUS_ADDRV | MCI_STATUS_S
| MCI_STATUS_AR | 0x134,
.mcg_status = MCG_STATUS_MCIP | MCG_STATUS_EIPV,
.addr = paddr,
.misc = (MCM_ADDR_PHYS << 6) | 0xc,
};
int r;
r = kvm_set_mce(env, &mce);
if (r < 0) {
fprintf(stderr, "kvm_set_mce: %s\n", strerror(errno));
abort();
}
kvm_mce_broadcast_rest(env);
}
| 1threat |
nvdimm_build_structure_memdev(GArray *structures, DeviceState *dev)
{
NvdimmNfitMemDev *nfit_memdev;
uint64_t addr = object_property_get_int(OBJECT(dev), PC_DIMM_ADDR_PROP,
NULL);
uint64_t size = object_property_get_int(OBJECT(dev), PC_DIMM_SIZE_PROP,
NULL);
int slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP,
NULL);
uint32_t handle = nvdimm_slot_to_handle(slot);
nfit_memdev = acpi_data_push(structures, sizeof(*nfit_memdev));
nfit_memdev->type = cpu_to_le16(1
);
nfit_memdev->length = cpu_to_le16(sizeof(*nfit_memdev));
nfit_memdev->nfit_handle = cpu_to_le32(handle);
nfit_memdev->spa_index = cpu_to_le16(nvdimm_slot_to_spa_index(slot));
nfit_memdev->dcr_index = cpu_to_le16(nvdimm_slot_to_dcr_index(slot));
nfit_memdev->region_len = cpu_to_le64(size);
nfit_memdev->region_dpa = cpu_to_le64(addr);
nfit_memdev->interleave_ways = cpu_to_le16(1);
}
| 1threat |
static MemTxResult memory_region_write_with_attrs_accessor(MemoryRegion *mr,
hwaddr addr,
uint64_t *value,
unsigned size,
unsigned shift,
uint64_t mask,
MemTxAttrs attrs)
{
uint64_t tmp;
tmp = (*value >> shift) & mask;
if (mr->subpage) {
trace_memory_region_subpage_write(get_cpu_index(), mr, addr, tmp, size);
} else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) {
hwaddr abs_addr = memory_region_to_absolute_addr(mr, addr);
trace_memory_region_ops_write(get_cpu_index(), mr, abs_addr, tmp, size);
}
return mr->ops->write_with_attrs(mr->opaque, addr, tmp, size, attrs);
} | 1threat |
Simple PHP IF/ELSE code not working properly with html markup : <p>I have started to learn some basic PHP. So far everything worked perfectly until I tried to run some IF/ELSE statements embedded into the markup as you can see in the snipet bellow:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><?php
$msg = 0;
echo $msg;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test</title>
</head>
<body>
<?php if ($msg = 5){ ?>
<h1>5</h1>
<?php } elseif ($msg = 0) { ?>
<h1> 0 </h1>
<?php } else { ?>
<h1>Whatever</h1>
<?php } ?>
</body>
</html> </code></pre>
</div>
</div>
</p>
<p>The result is always the first if statement, even if it doesn't meet the condition. In this case the result is:</p>
<p>0</p>
<p><strong>5</strong></p>
<p>Tried everything I knew and searched a lot without any results. What am I doing wrong here?</p>
| 0debug |
Is it possible to wrap a function and retain its types? : <p>I'm trying to create a generic wrapper function which will wrap any function passed to it.</p>
<p>At the very basic the wrapper function would look something like</p>
<pre><code>function wrap<T extends Function>(fn: T) {
return (...args) => {
return fn(...args)
};
}
</code></pre>
<p>I'm trying to use it like:</p>
<pre><code>function foo(a: string, b: number): [string, number] {
return [a, b];
}
const wrappedFoo = wrap(foo);
</code></pre>
<p>Right now <code>wrappedFoo</code> is getting a type of <code>(...args: any[]) => any</code></p>
<p>Is it possible to get <code>wrappedFoo</code> to mimic the types of the function its wrapping?</p>
| 0debug |
String Manipulation [PYTHON] : Say if i converted a string into lowercase, how would I convert it back to the original string the user entered ? [PYTHON] I have been searching for a particular python function that will convert the string back to the original string. I have used .swapcase() but unfortunately it didn't work. Please bare in mind that the .lower() is needed.
Thank you.
| 0debug |
static int t37(InterplayACMContext *s, unsigned ind, unsigned col)
{
GetBitContext *gb = &s->gb;
unsigned i, b;
int n1, n2;
for (i = 0; i < s->rows; i++) {
b = get_bits(gb, 7);
n1 = (mul_2x11[b] & 0x0F) - 5;
n2 = ((mul_2x11[b] >> 4) & 0x0F) - 5;
set_pos(s, i++, col, n1);
if (i >= s->rows)
break;
set_pos(s, i, col, n2);
return 0;
| 1threat |
c# index was out of the bounds of the array : this is my program with error"index was out of the bounds of array"
need help
using System;
using System.Collections.Generic;
using System.Text;
namespace command
{
class Program
{
static void Main(string[] args)
Console.WriteLine("First Name is " + args[0]);
Console.WriteLine("Last Name is " + args[1]);
Console.ReadLine();
}
} | 0debug |
Jenkins pipeline if else not working : <p>I am creating a sample jenkins pipeline, here is the code.</p>
<pre><code>pipeline {
agent any
stages {
stage('test') {
steps {
sh 'echo hello'
}
}
stage('test1') {
steps {
sh 'echo $TEST'
}
}
stage('test3') {
if (env.BRANCH_NAME == 'master') {
echo 'I only execute on the master branch'
} else {
echo 'I execute elsewhere'
}
}
}
}
</code></pre>
<p>this pipeline fails with following error logs</p>
<pre><code>Started by user admin
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 15: Not a valid stage section definition: "if (env.BRANCH_NAME == 'master') {
echo 'I only execute on the master branch'
} else {
echo 'I execute elsewhere'
}". Some extra configuration is required. @ line 15, column 9.
stage('test3') {
^
WorkflowScript: 15: Nothing to execute within stage "test3" @ line 15, column 9.
stage('test3') {
^
</code></pre>
<p>But when i execute the following example <a href="https://jenkins.io/doc/book/pipeline/syntax/#declarative-steps" rel="noreferrer">from this url</a>, it executes successfully and print the else part.</p>
<pre><code>node {
stage('Example') {
if (env.BRANCH_NAME == 'master') {
echo 'I only execute on the master branch'
} else {
echo 'I execute elsewhere'
}
}
}
</code></pre>
<p>The only difference i can see is that in the working example there is no <code>stages</code> but in my case it has.</p>
<p>What is wrong here, can anyone please suggest?</p>
| 0debug |
Is this a bug in Kotlin or I missing something? : <p>I don't have to much experience in multi-threading. So not sure if I got right the following Java code decompiled from Kotlin.</p>
<p>Here is the Kotlin code:</p>
<pre><code>companion object {
@Volatile private var INSTANCE: SomeDatabase? = null
fun getInstance(context: Context): SomeDatabase =
INSTANCE ?: synchronized(this) {
INSTANCE ?: buildDatabase(context).also { INSTANCE = it }
}
}
</code></pre>
<p>Here is the decompiled code in Java:</p>
<pre><code> SomeDatabase var10000 = ((SomeDatabase.Companion)this).getINSTANCE();
if (var10000 == null) {
synchronized(this){}
SomeDatabase var4;
try {
var10000 = SomeDatabase.Companion.getINSTANCE();
if (var10000 == null) {
...
var10000 = var4;
}
return var10000;
</code></pre>
<p>Doesn't this mean that code is actually not synchronized because of empty block in <code>synchronized(this){}</code>?</p>
| 0debug |
struct pxa2xx_gpio_info_s *pxa2xx_gpio_init(target_phys_addr_t base,
CPUState *env, qemu_irq *pic, int lines)
{
int iomemtype;
struct pxa2xx_gpio_info_s *s;
s = (struct pxa2xx_gpio_info_s *)
qemu_mallocz(sizeof(struct pxa2xx_gpio_info_s));
memset(s, 0, sizeof(struct pxa2xx_gpio_info_s));
s->base = base;
s->pic = pic;
s->lines = lines;
s->cpu_env = env;
iomemtype = cpu_register_io_memory(0, pxa2xx_gpio_readfn,
pxa2xx_gpio_writefn, s);
cpu_register_physical_memory(base, 0x00000fff, iomemtype);
register_savevm("pxa2xx_gpio", 0, 0,
pxa2xx_gpio_save, pxa2xx_gpio_load, s);
return s;
}
| 1threat |
How to read image from firebase using opencv python : Is there any idea for reading image from firebase using OpenCV Python ? Or do I have to download the pictures first and then do the cv.imread function from the local folder ?
Is there any way that I could just cv.imread(link_of_picture_from_firebase) ??? | 0debug |
ios unique identifier across installs : <p>We need to uniquely identify the device and it has to be same across installs (reinstall). We have been using identifier stored in keychain till now so it persists across installs. Now with 10.3 beta the key chain is auto deleted when the app is uninstalled.
Ref: <a href="https://forums.developer.apple.com/thread/72271" rel="noreferrer">https://forums.developer.apple.com/thread/72271</a></p>
<p>Can we use AdIdentifier as unique identifier. We have ads served and we are at the moment using it for the same.</p>
| 0debug |
Hi, I am trying to write a program that shows whether a year is a leap or not and if it is what the sum of those digits are : I understand the line of code that is used to determine if something is a leap year or not and I've seen the line of code to determine the sum of numbers but I don't know how to combine the two. When I run it I get an error saying
"In function amaina:
error. aelsea without a previous aifa
error. aelsea without a previous aifa"
#include <stdio.h>
int main()
{
int year,sum=0,r;
;
printf("Enter a year to check if it is a leap year\n");
scanf("%d", &year);
if ( year%400 == 0)
for(;year!=0;year=year/10){
r=year%10;
sum=sum+r;
}
printf("%d is a leap year and the sum is %d.\n", year,sum);
else if ( year%100 == 0)
printf("%d is not a leap year.\n", year);
else if ( year%4 == 0 )
for(;year!=0;year=year/10){
r=year%10;
sum=sum+r;
}
printf("%d is a leap year and the sum is %d.\n", year,sum);
else
printf("%d is not a leap year.\n", year);
return 0;
} | 0debug |
static void spr_write_ibatu_h (void *opaque, int sprn)
{
DisasContext *ctx = opaque;
gen_op_store_ibatu((sprn - SPR_IBAT4U) / 2);
RET_STOP(ctx);
}
| 1threat |
static void multipath_pr_init(void)
{
static struct udev *udev;
udev = udev_new();
mpath_lib_init(udev);
}
| 1threat |
uppercase characters in a string cannot be converted to lowercase and substracting their ASCII value doesnt make them in alphabetical index : I am a beginner trying to learn to code.
Currently I am doing CS50 course, I have encountered a problem with a Vigenere cipher problem, please see my code on a github link below.
[github gist][1] - https://gist.github.com/adamstraka/dc2356d411aeae129f9a7ecc522cc274
The issues are as following:
1.] if you pass an argument in upercase letters in a key, the values are weird and the conversion doesnt work, the idea is to take each character in a string key and substracting 65 if uppercase, or 97 if lowercase, so their ASCII value would go to 0 - 26. I then can make a use of them in a Vigenere cipher formula: cipher[i index] = (plaintext[i index] + key[j index]) % 26
2.] doesnt handle lack of argv[1], even though there is an IF condition (!argc == 2), so it shouldt go trough if you doesnt pass anything.
"failed to execute program due to segmentation fault".
I have tried everything in my capability, I am pretty tired, maybe tomorrow the solution will popuout instantly.
I ask you to give me some hints, possibly not revealing everything, but maybe guiding me, so I can learn from it.
Thank you!
[1]: https://gist.github.com/adamstraka/dc2356d411aeae129f9a7ecc522cc274 | 0debug |
why this output in multiprogramming C : #include<stdio.h>
#include<pthread.h>
#define NUM_THREAD (5)
int sum=0;
void* runner(void * param);
int main(int argc,char **argv){
pthread_t tid[NUM_THREAD];
pthread_attr_t attr;
for(i=0;i<NUM_THREAD;i++){
pthread_create(&tid[i],&attr,runner,NULL);
}
for(i=0;i<NUM_THREAD;i++){
pthread_join(tid[i],NULL);
}
printf("After threading %d",sum);
return 0;
}
void * runner(void *param){
for(int j = 0;j<10;j++) sum+=j;
pthread_exit(0);
}
**output**: 225
In the following code, the output is 225. But the correct should be 45
I know threads share global variables!. so this function should correctly ouput right. But adding that sum=0 inside only gives correct output. Whats happening here i dont understand!
void * runner(void *param){
sum=0; // MY DOUBT
for(int j = 0;j<10;j++) sum+=j;
pthread_exit(0);
}
**output**: 45 | 0debug |
static void usb_host_realize(USBDevice *udev, Error **errp)
{
USBHostDevice *s = USB_HOST_DEVICE(udev);
if (s->match.vendor_id > 0xffff) {
error_setg(errp, "vendorid out of range");
return;
}
if (s->match.product_id > 0xffff) {
error_setg(errp, "productid out of range");
return;
}
if (s->match.addr > 127) {
error_setg(errp, "hostaddr out of range");
return;
}
loglevel = s->loglevel;
udev->flags |= (1 << USB_DEV_FLAG_IS_HOST);
udev->auto_attach = 0;
QTAILQ_INIT(&s->requests);
QTAILQ_INIT(&s->isorings);
s->exit.notify = usb_host_exit_notifier;
qemu_add_exit_notifier(&s->exit);
QTAILQ_INSERT_TAIL(&hostdevs, s, next);
usb_host_auto_check(NULL);
}
| 1threat |
net_rx_pkt_pull_data(struct NetRxPkt *pkt,
const struct iovec *iov, int iovcnt,
size_t ploff)
{
if (pkt->vlan_stripped) {
net_rx_pkt_iovec_realloc(pkt, iovcnt + 1);
pkt->vec[0].iov_base = pkt->ehdr_buf;
pkt->vec[0].iov_len = sizeof(pkt->ehdr_buf);
pkt->tot_len =
iov_size(iov, iovcnt) - ploff + sizeof(struct eth_header);
pkt->vec_len = iov_copy(pkt->vec + 1, pkt->vec_len_total - 1,
iov, iovcnt, ploff, pkt->tot_len);
} else {
net_rx_pkt_iovec_realloc(pkt, iovcnt);
pkt->tot_len = iov_size(iov, iovcnt) - ploff;
pkt->vec_len = iov_copy(pkt->vec, pkt->vec_len_total,
iov, iovcnt, ploff, pkt->tot_len);
}
eth_get_protocols(pkt->vec, pkt->vec_len, &pkt->isip4, &pkt->isip6,
&pkt->isudp, &pkt->istcp,
&pkt->l3hdr_off, &pkt->l4hdr_off, &pkt->l5hdr_off,
&pkt->ip6hdr_info, &pkt->ip4hdr_info, &pkt->l4hdr_info);
trace_net_rx_pkt_parsed(pkt->isip4, pkt->isip6, pkt->isudp, pkt->istcp,
pkt->l3hdr_off, pkt->l4hdr_off, pkt->l5hdr_off);
}
| 1threat |
With momentjs, how do I tell if 2 moments represent the same day (not, necessarily, the same time)? : <p>I have 2 momentjs objects, <code>moment1</code> and <code>moment2</code>:</p>
<p><a href="https://i.stack.imgur.com/qliEc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/qliEc.png" alt="enter image description here"></a></p>
<p>Why is <code>moment1.isSame(moment2, 'date')</code> returning false??</p>
<p>My understanding is that checking <code>moment1.isSame(moment2, 'day')</code> returns whether they are the same day <em>of the week</em> (at least, that's what it looks like from the docs). So if both 'day' and 'date' don't work, what is the correct way to determine if the 2 dates represent the same day?</p>
<p>I could have sworn I've used <code>moment1.isSame(moment2, 'date')</code> in the past, but I must be remembering incorrectly...</p>
| 0debug |
static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
uint16_t **refcount_table, int64_t *refcount_table_size, int64_t l2_offset,
int flags)
{
BDRVQcowState *s = bs->opaque;
uint64_t *l2_table, l2_entry;
uint64_t next_contiguous_offset = 0;
int i, l2_size, nb_csectors, ret;
l2_size = s->l2_size * sizeof(uint64_t);
l2_table = g_malloc(l2_size);
ret = bdrv_pread(bs->file, l2_offset, l2_table, l2_size);
if (ret < 0) {
fprintf(stderr, "ERROR: I/O error in check_refcounts_l2\n");
res->check_errors++;
goto fail;
}
for(i = 0; i < s->l2_size; i++) {
l2_entry = be64_to_cpu(l2_table[i]);
switch (qcow2_get_cluster_type(l2_entry)) {
case QCOW2_CLUSTER_COMPRESSED:
if (l2_entry & QCOW_OFLAG_COPIED) {
fprintf(stderr, "ERROR: cluster %" PRId64 ": "
"copied flag must never be set for compressed "
"clusters\n", l2_entry >> s->cluster_bits);
l2_entry &= ~QCOW_OFLAG_COPIED;
res->corruptions++;
}
nb_csectors = ((l2_entry >> s->csize_shift) &
s->csize_mask) + 1;
l2_entry &= s->cluster_offset_mask;
ret = inc_refcounts(bs, res, refcount_table, refcount_table_size,
l2_entry & ~511, nb_csectors * 512);
if (ret < 0) {
goto fail;
}
if (flags & CHECK_FRAG_INFO) {
res->bfi.allocated_clusters++;
res->bfi.compressed_clusters++;
res->bfi.fragmented_clusters++;
}
break;
case QCOW2_CLUSTER_ZERO:
if ((l2_entry & L2E_OFFSET_MASK) == 0) {
break;
}
case QCOW2_CLUSTER_NORMAL:
{
uint64_t offset = l2_entry & L2E_OFFSET_MASK;
if (flags & CHECK_FRAG_INFO) {
res->bfi.allocated_clusters++;
if (next_contiguous_offset &&
offset != next_contiguous_offset) {
res->bfi.fragmented_clusters++;
}
next_contiguous_offset = offset + s->cluster_size;
}
ret = inc_refcounts(bs, res, refcount_table, refcount_table_size,
offset, s->cluster_size);
if (ret < 0) {
goto fail;
}
if (offset_into_cluster(s, offset)) {
fprintf(stderr, "ERROR offset=%" PRIx64 ": Cluster is not "
"properly aligned; L2 entry corrupted.\n", offset);
res->corruptions++;
}
break;
}
case QCOW2_CLUSTER_UNALLOCATED:
break;
default:
abort();
}
}
g_free(l2_table);
return 0;
fail:
g_free(l2_table);
return ret;
}
| 1threat |
.NET Core debugging with VS Code - "Only 64-bit processes can be debugged" : <p>I don't have VS 2017, and I'll be building a web front-end in VS Code anyway so I want to use VS Code.</p>
<p>Until .NET Standard 2.0 comes out, our libraries are also in 4.6.1, so I'm targetting net461 in my .NET Core csproj:</p>
<pre><code><Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
</ItemGroup>
</Project>
</code></pre>
<p>The project is the simplest <code>dotnet new webapi</code> starter app. I can build and run with <code>dotnet build</code> and <code>dotnet run</code>. I've also got the latest ms-vscode.csharp extension 1.8.1.</p>
<p>However, when I try attaching or debugging this application with VS Code I get the error</p>
<blockquote>
<p>Failed to attach to process: Only 64-bit processes can be debugged</p>
</blockquote>
<p>Even running from console, then attaching with the very simple configuration:</p>
<pre><code>{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
</code></pre>
<p>And selecting the process fails with this error. I've tried building the exe targeting x64 with:</p>
<pre><code><PropertyGroup>
<TargetFramework>net461</TargetFramework>
<Platform>x64</Platform>
</PropertyGroup>
</code></pre>
<p>But it produces the same error. Anyone know a fix? It seems to be because I'm targetting net461, does debugging .Net Core not support targeting other frameworks?</p>
| 0debug |
static void nand_realize(DeviceState *dev, Error **errp)
{
int pagesize;
NANDFlashState *s = NAND(dev);
s->buswidth = nand_flash_ids[s->chip_id].width >> 3;
s->size = nand_flash_ids[s->chip_id].size << 20;
if (nand_flash_ids[s->chip_id].options & NAND_SAMSUNG_LP) {
s->page_shift = 11;
s->erase_shift = 6;
} else {
s->page_shift = nand_flash_ids[s->chip_id].page_shift;
s->erase_shift = nand_flash_ids[s->chip_id].erase_shift;
}
switch (1 << s->page_shift) {
case 256:
nand_init_256(s);
break;
case 512:
nand_init_512(s);
break;
case 2048:
nand_init_2048(s);
break;
default:
error_setg(errp, "Unsupported NAND block size %#x\n",
1 << s->page_shift);
return;
}
pagesize = 1 << s->oob_shift;
s->mem_oob = 1;
if (s->bdrv) {
if (bdrv_is_read_only(s->bdrv)) {
error_setg(errp, "Can't use a read-only drive");
return;
}
if (bdrv_getlength(s->bdrv) >=
(s->pages << s->page_shift) + (s->pages << s->oob_shift)) {
pagesize = 0;
s->mem_oob = 0;
}
} else {
pagesize += 1 << s->page_shift;
}
if (pagesize) {
s->storage = (uint8_t *) memset(g_malloc(s->pages * pagesize),
0xff, s->pages * pagesize);
}
s->ioaddr = s->io;
}
| 1threat |
yuv2gray16_1_c_template(SwsContext *c, const uint16_t *buf0,
const uint16_t *ubuf0, const uint16_t *ubuf1,
const uint16_t *vbuf0, const uint16_t *vbuf1,
const uint16_t *abuf0, uint8_t *dest, int dstW,
int uvalpha, enum PixelFormat dstFormat,
int flags, int y, enum PixelFormat target)
{
int i;
for (i = 0; i < (dstW >> 1); i++) {
const int i2 = 2 * i;
int Y1 = buf0[i2 ] << 1;
int Y2 = buf0[i2+1] << 1;
output_pixel(&dest[2 * i2 + 0], Y1);
output_pixel(&dest[2 * i2 + 2], Y2);
}
}
| 1threat |
cursor.execute('SELECT * FROM users WHERE username = ' + user_input) | 1threat |
void ff_dsputil_init_arm(DSPContext* c, AVCodecContext *avctx)
{
const int high_bit_depth = avctx->bits_per_raw_sample > 8;
int cpu_flags = av_get_cpu_flags();
ff_put_pixels_clamped = c->put_pixels_clamped;
ff_add_pixels_clamped = c->add_pixels_clamped;
if (avctx->bits_per_raw_sample <= 8) {
if(avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_ARM){
c->idct_put = j_rev_dct_arm_put;
c->idct_add = j_rev_dct_arm_add;
c->idct = ff_j_rev_dct_arm;
c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
} else if (avctx->idct_algo == FF_IDCT_SIMPLEARM){
c->idct_put = simple_idct_arm_put;
c->idct_add = simple_idct_arm_add;
c->idct = ff_simple_idct_arm;
c->idct_permutation_type = FF_NO_IDCT_PERM;
}
}
c->add_pixels_clamped = ff_add_pixels_clamped_arm;
if (!high_bit_depth) {
c->put_pixels_tab[0][0] = ff_put_pixels16_arm;
c->put_pixels_tab[0][1] = ff_put_pixels16_x2_arm;
c->put_pixels_tab[0][2] = ff_put_pixels16_y2_arm;
c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_arm;
c->put_pixels_tab[1][0] = ff_put_pixels8_arm;
c->put_pixels_tab[1][1] = ff_put_pixels8_x2_arm;
c->put_pixels_tab[1][2] = ff_put_pixels8_y2_arm;
c->put_pixels_tab[1][3] = ff_put_pixels8_xy2_arm;
c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_arm;
c->put_no_rnd_pixels_tab[0][1] = ff_put_no_rnd_pixels16_x2_arm;
c->put_no_rnd_pixels_tab[0][2] = ff_put_no_rnd_pixels16_y2_arm;
c->put_no_rnd_pixels_tab[0][3] = ff_put_no_rnd_pixels16_xy2_arm;
c->put_no_rnd_pixels_tab[1][0] = ff_put_pixels8_arm;
c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_arm;
c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_arm;
c->put_no_rnd_pixels_tab[1][3] = ff_put_no_rnd_pixels8_xy2_arm;
}
if (have_armv5te(cpu_flags)) ff_dsputil_init_armv5te(c, avctx);
if (have_armv6(cpu_flags)) ff_dsputil_init_armv6(c, avctx);
if (have_vfp(cpu_flags)) ff_dsputil_init_vfp(c, avctx);
if (have_neon(cpu_flags)) ff_dsputil_init_neon(c, avctx);
}
| 1threat |
static void ehci_flush_qh(EHCIQueue *q)
{
uint32_t *qh = (uint32_t *) &q->qh;
uint32_t dwords = sizeof(EHCIqh) >> 2;
uint32_t addr = NLPTR_GET(q->qhaddr);
put_dwords(addr + 3 * sizeof(uint32_t), qh + 3, dwords - 3);
}
| 1threat |
Can anyone assist me with this question from Project Euler. Which Algorithm would i use? : Given a list containing Province, CustomerName and SalesValue (sorted by Province and CustomerName), describe an algorithm you could use that would output each CustomerName and SalesValue with the total SalesValue per Province. | 0debug |
Get API response error message using Web Client Mono in Spring Boot : <p>I am using webflux Mono (in Spring boot 5) to consume an external API. I am able to get data well when the API response status code is 200, but when the API returns an error I am not able to retrieve the error message from the API. Spring webclient error handler always display the message as </p>
<p><code>ClientResponse has erroneous status code: 500 Internal Server Error</code>, but when I use PostMan the API returns this JSON response with status code 500.</p>
<pre><code>{
"error": {
"statusCode": 500,
"name": "Error",
"message":"Failed to add object with ID:900 as the object exists",
"stack":"some long message"
}
}
</code></pre>
<p>My request using WebClient is as follows</p>
<pre><code>webClient.getWebClient()
.post()
.uri("/api/Card")
.body(BodyInserters.fromObject(cardObject))
.retrieve()
.bodyToMono(String.class)
.doOnSuccess( args -> {
System.out.println(args.toString());
})
.doOnError( e ->{
e.printStackTrace();
System.out.println("Some Error Happend :"+e);
});
</code></pre>
<p>My question is, how can I get access to the JSON response when the API returns an Error with status code of 500?</p>
| 0debug |
Component definition is missing display name react/display-name : <p>How do I add a display name to this?</p>
<pre><code>export default () =>
<Switch>
<Route path="/login" exact component={LoginApp}/>
<Route path="/faq" exact component={FAQ}/>
<Route component={NotFound} />
</Switch>;
</code></pre>
| 0debug |
static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)
{
ASFContext *asf = s->priv_data;
ASFStream *stream;
int64_t duration;
AVCodecContext *codec;
int64_t packet_st, pts;
int start_sec, i;
int flags = pkt->flags;
codec = s->streams[pkt->stream_index]->codec;
stream = &asf->streams[pkt->stream_index];
if (codec->codec_type == AVMEDIA_TYPE_AUDIO)
flags &= ~AV_PKT_FLAG_KEY;
pts = (pkt->pts != AV_NOPTS_VALUE) ? pkt->pts : pkt->dts;
if (pts < 0) {
av_log(s, AV_LOG_ERROR,
"Negative dts not supported stream %d, dts %"PRId64"\n",
pkt->stream_index, pts);
return AVERROR(ENOSYS);
}
assert(pts != AV_NOPTS_VALUE);
duration = pts * 10000;
asf->duration = FFMAX(asf->duration, duration + pkt->duration * 10000);
packet_st = asf->nb_packets;
put_frame(s, stream, s->streams[pkt->stream_index],
pkt->dts, pkt->data, pkt->size, flags);
if ((!asf->is_streamed) && (flags & AV_PKT_FLAG_KEY)) {
start_sec = (int)(duration / INT64_C(10000000));
if (start_sec != (int)(asf->last_indexed_pts / INT64_C(10000000))) {
for (i = asf->nb_index_count; i < start_sec; i++) {
if (i >= asf->nb_index_memory_alloc) {
asf->nb_index_memory_alloc += ASF_INDEX_BLOCK;
asf->index_ptr = (ASFIndex *)av_realloc(asf->index_ptr,
sizeof(ASFIndex) *
asf->nb_index_memory_alloc);
}
asf->index_ptr[i].packet_number = (uint32_t)packet_st;
asf->index_ptr[i].packet_count = (uint16_t)(asf->nb_packets - packet_st);
asf->maximum_packet = FFMAX(asf->maximum_packet,
(uint16_t)(asf->nb_packets - packet_st));
}
asf->nb_index_count = start_sec;
asf->last_indexed_pts = duration;
}
}
return 0;
}
| 1threat |
int cpu_get_dump_info(ArchDumpInfo *info,
const struct GuestPhysBlockList *guest_phys_blocks)
{
PowerPCCPU *cpu = POWERPC_CPU(first_cpu);
PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
info->d_machine = PPC_ELF_MACHINE;
info->d_class = ELFCLASS;
if ((*pcc->interrupts_big_endian)(cpu)) {
info->d_endian = ELFDATA2MSB;
} else {
info->d_endian = ELFDATA2LSB;
}
if (strncmp(object_get_typename(qdev_get_machine()),
"pseries-", 8) == 0) {
info->page_size = (1U << 16);
}
return 0;
}
| 1threat |
Entering cat h block of http post of angular : I have a function as below in angular:
getData(payload):any {
return this.http.post(url,payload).catch(err => this.handleerror());
}
How do i Write test case to enter the catch block using jasmine | 0debug |
define a diagonal matrix from a matrix : I need a help plz
I want to construct a diagonal matrix D from a matrix A
the first element of the diagonal matrix D must be the product of all elements in the subdiagonal of the matrix A, the second element in the diagonal matrix D must be the product of all elements in the subdiagonal of the matrix A except the first one , the third element in the diagonal matrix D must be the product of all elements in the subdiagonal of the matrix A expect the first and the second one,.... , and the last element of the diagonal matrix D must be 1 | 0debug |
void do_store_601_batu (int nr)
{
do_store_ibatu(env, nr, T0);
env->DBAT[0][nr] = env->IBAT[0][nr];
env->DBAT[1][nr] = env->IBAT[1][nr];
}
| 1threat |
Measure voltage using transistor with strange behaviour : <p>I'm facing a problem that is completely strange for me.
This is simple, I build a small electronics device and in that one I just set up a voltage bridge devider to obtain battery voltage to be able to indicate what is the level of the battery.</p>
<p><strong>Problem description</strong></p>
<p><strong>Behaviour</strong>:
It works quite fine, means that when battery voltage is decreasing, it decreases on the input ADC on the MCU. The main problem, is that it discharges the battery same when the circuit is turned off.</p>
<p><strong>What we tryed</strong>:
Ok, we have to find a system that permits to turn off the bridge divider when I turn off the circuit. That's why I simply added a transistor which is driven by the 3.3v regulator of the circuit:</p>
<ul>
<li>When circuit is ON, 3.3v from the regulator drives a transistor <strong>BC547A (just for test)</strong> on the Base with a 10k resistor.</li>
<li>The transistor becomes "passing" (sorry for my english), and provide battery voltage to the bridge divider.</li>
<li>We read VBAT2 on the MCU, when system is powered</li>
</ul>
<p><strong>Strange behaviour</strong>: But... this is not working, we observe that the transistor is acting like a regulator because it seems to be not "passing" enough to provide the voltage variation from the battery. This is the circuit that we are trying.</p>
<p><strong>Schematic:</strong> <a href="http://i.stack.imgur.com/xdqLF.jpg" rel="nofollow">Schematic tested using transitor</a></p>
<p>And when we measure variation at the input of the MCU, the transistor seems acting like a regulator O_o. It meens that when battery voltage decreases slowly, voltage on the MCU input stay completely constant and stable.</p>
<p>Here are the measure that i've done: <a href="http://i.stack.imgur.com/fHhVb.jpg" rel="nofollow">Measure of voltage</a>
The blue line is VBAT2 (the one that goes to the MCU), and the red one is the probe that is on the battery +.</p>
<p>The battery is a standard single cell lithium ion polymer, whith battery voltage that move from 4.15v (full charge) and 3.1v (discharded).</p>
<p>Does someone can help me to solve this problem or explain to me why I observe this behaviour?</p>
<p>Thanks for your help.</p>
| 0debug |
what's wrong with this line of code? Why it isn't passing parameter to update function : <p>Here is my line of code:</p>
<pre><code>Response.Write(String.Format("<td id = {0} onclick = 'update({0})' >", studentid));
</code></pre>
<p>JavaScript function is being called but the parameter is not being passed. What went wrong?
Any ideas?</p>
| 0debug |
Post amount must be in increments of 50 PHP : <p>i collect data using GET.</p>
<pre><code>product=shoes&amount=30
</code></pre>
<p>so i collect the data</p>
<pre><code>$amount = $_GET['amount'];
</code></pre>
<p>How do i echo out a message if the amount is not in increments of 10, so for example if amount was 25, i want to echo out saying "Amount needs to be in increments of 10".
I have no code examples as i have tried to google this and can't find anything and i don't know where to even begin.</p>
<p>So i have not tried anything.</p>
| 0debug |
Dynamic struct array in function in C : <p>I'm trying to create adjacency list to represent a graph from a list of edges in file "input.txt". I know the basics of how pointers work but I have problem with dynamic struct array which consists of singly linked lists.</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
struct list {
int vertex;
struct list *next;
};
void create_list(int v, struct list* **array);
int main()
{
int i, v = 5;
struct list *ptr, **array = (struct list **)malloc(sizeof(struct list *) * v);
for (i = 0; i < v; i++)
array[i] = NULL;
array[i] = NULL;
create_list(v, &array);
for(i = 0; i < v; i++) {
ptr = array[i];
printf("%d: ", i);
while(ptr != NULL) {
printf(" ->%d", ptr->vertex);
ptr = ptr->next;
}
printf("\n");
}
return 0;
}
void create_list(int v, struct list* **array)
{
int m, n;
struct list *ptr, *tmp;
FILE *luki;
luki = fopen("input.txt", "r");
while(fscanf(luki, "%d %d\n", &m, &n) == 2) {
tmp = (struct lista*)malloc(sizeof(struct list));
tmp->vertex = n;
tmp->next = NULL;
if (*array[m] == NULL) //Here my program crashes when m changes from 0 to 1
*array[m] = tmp;
else {
ptr = array[m];
while(ptr->next != NULL)
ptr = ptr->next;
ptr->next = tmp;
}
}
fclose(luki);
}
</code></pre>
<p>Could you please help me figure out how it should look like?</p>
<p>Also, at first I made the function without using pointer to array:</p>
<pre><code>void create_list(int v, struct list **array)
create_list(v, array);
</code></pre>
<p>And it worked really good when debugging and (I'm using CodeBlocks):</p>
<pre><code>0: 4 ->3 ->1
1: 2
2: 3
3:
4:
</code></pre>
<p>but while running the program normally I got this:</p>
<pre><code>0:
1:
2:
3:
4:
</code></pre>
<p>Why the output while debugging was right if passing array to function create_list was wrong?</p>
| 0debug |
Host a static site single page app in Google Cloud Storage with routes : <p>There are guides and questions all over the place on how to do this, but never really a concrete answer that is satisfactory. Basically, I'm wondering if it's possible to host a static SPA (HTML/CSS/JS) in GCP Cloud Storage. </p>
<p><strong>The main caveat of this is that the SPA has its own routing system (ReactRouter) so I want all paths to be served by index.html.</strong></p>
<p>Most guides will tell you to set the ErrorDocument to <code>index.html</code> instead of <code>404.html</code>. While this is a clever hack, it causes the site's HTTP response code to be 404 which is a disaster for SEO or monitoring tools. So that will work, as long as I can change the response code.</p>
<p>Is there any way to make this work? I have CloudFlare up and running too but from what I can tell there are no ways to trim the path or change the response status from there.</p>
| 0debug |
setup_sigcontext(struct target_sigcontext *sc,
CPUState *env, unsigned long mask)
{
int err = 0;
__put_user_error(env->regs[0], &sc->arm_r0, err);
__put_user_error(env->regs[1], &sc->arm_r1, err);
__put_user_error(env->regs[2], &sc->arm_r2, err);
__put_user_error(env->regs[3], &sc->arm_r3, err);
__put_user_error(env->regs[4], &sc->arm_r4, err);
__put_user_error(env->regs[5], &sc->arm_r5, err);
__put_user_error(env->regs[6], &sc->arm_r6, err);
__put_user_error(env->regs[7], &sc->arm_r7, err);
__put_user_error(env->regs[8], &sc->arm_r8, err);
__put_user_error(env->regs[9], &sc->arm_r9, err);
__put_user_error(env->regs[10], &sc->arm_r10, err);
__put_user_error(env->regs[11], &sc->arm_fp, err);
__put_user_error(env->regs[12], &sc->arm_ip, err);
__put_user_error(env->regs[13], &sc->arm_sp, err);
__put_user_error(env->regs[14], &sc->arm_lr, err);
__put_user_error(env->regs[15], &sc->arm_pc, err);
#ifdef TARGET_CONFIG_CPU_32
__put_user_error(cpsr_read(env), &sc->arm_cpsr, err);
#endif
__put_user_error( 0, &sc->trap_no, err);
__put_user_error( 0, &sc->error_code, err);
__put_user_error( 0, &sc->fault_address, err);
__put_user_error(mask, &sc->oldmask, err);
return err;
}
| 1threat |
VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
{
V9fsState *s;
int i, len;
struct stat stat;
FsTypeEntry *fse;
s = (V9fsState *)virtio_common_init("virtio-9p",
VIRTIO_ID_9P,
sizeof(struct virtio_9p_config)+
MAX_TAG_LEN,
sizeof(V9fsState));
QLIST_INIT(&s->free_list);
for (i = 0; i < (MAX_REQ - 1); i++) {
QLIST_INSERT_HEAD(&s->free_list, &s->pdus[i], next);
}
s->vq = virtio_add_queue(&s->vdev, MAX_REQ, handle_9p_output);
fse = get_fsdev_fsentry(conf->fsdev_id);
if (!fse) {
fprintf(stderr, "Virtio-9p device couldn't find fsdev "
"with the id %s\n", conf->fsdev_id);
exit(1);
}
if (!fse->path || !conf->tag) {
fprintf(stderr, "fsdev with id %s needs path "
"and Virtio-9p device needs mount_tag arguments\n",
conf->fsdev_id);
exit(1);
}
if (!strcmp(fse->security_model, "passthrough")) {
s->ctx.fs_sm = SM_PASSTHROUGH;
} else if (!strcmp(fse->security_model, "mapped")) {
s->ctx.fs_sm = SM_MAPPED;
} else if (!strcmp(fse->security_model, "none")) {
s->ctx.fs_sm = SM_NONE;
} else {
fprintf(stderr, "Default to security_model=none. You may want"
" enable advanced security model using "
"security option:\n\t security_model=passthrough \n\t "
"security_model=mapped\n");
s->ctx.fs_sm = SM_NONE;
}
if (lstat(fse->path, &stat)) {
fprintf(stderr, "share path %s does not exist\n", fse->path);
exit(1);
} else if (!S_ISDIR(stat.st_mode)) {
fprintf(stderr, "share path %s is not a directory \n", fse->path);
exit(1);
}
s->ctx.fs_root = qemu_strdup(fse->path);
len = strlen(conf->tag);
if (len > MAX_TAG_LEN) {
len = MAX_TAG_LEN;
}
s->tag = qemu_malloc(len);
memcpy(s->tag, conf->tag, len);
s->tag_len = len;
s->ctx.uid = -1;
s->ops = fse->ops;
s->vdev.get_features = virtio_9p_get_features;
s->config_size = sizeof(struct virtio_9p_config) +
s->tag_len;
s->vdev.get_config = virtio_9p_get_config;
return &s->vdev;
}
| 1threat |
Java Lambda create a filter with a predicate function which determines if the Levenshtine distnace is greater than 2 : With my low knowledge in lambda, I would appreciate if someone could help me to change my "query". I have a query to get the most similar value. Well I need to define the minimum Levenshtine distnace result. If the score is more than 2, I don't want to see the value as part of the recommendation.
String recommendation = candidates.parallelStream()
.map(String::trim)
.filter(s -> !s.equals(search))
.min((a, b) -> Integer.compare(
cache.computeIfAbsent(a, k -> StringUtils.getLevenshteinDistance(Arrays.stream(search.split(" ")).sorted().toString(), Arrays.stream(k.split(" ")).sorted().toString()) ),
cache.computeIfAbsent(b, k -> StringUtils.getLevenshteinDistance(Arrays.stream(search.split(" ")).sorted().toString(), Arrays.stream(k.split(" ")).sorted().toString()))))
.get();
Thank you! | 0debug |
static inline void gen_branch2(DisasContext *dc, target_ulong pc1,
target_ulong pc2, TCGv r_cond)
{
int l1;
l1 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_EQ, r_cond, 0, l1);
gen_goto_tb(dc, 0, pc1, pc1 + 4);
gen_set_label(l1);
gen_goto_tb(dc, 1, pc2, pc2 + 4);
}
| 1threat |
static void fifo_trigger_update(void *opaque)
{
CadenceUARTState *s = opaque;
s->r[R_CISR] |= UART_INTR_TIMEOUT;
uart_update_status(s);
}
| 1threat |
Cordova installation error: path issue (?) - error code ENOENT : <p>After installing Xcode & NodeJS I am now trying to install Cordova but I am getting the following error regarding a missing file (wrong path?).</p>
<pre><code>Luciens-MacBook-Pro:~ lucientavano$ npm cache clean
Luciens-MacBook-Pro:~ lucientavano$ sudo npm install -g cordova
Password:
npm WARN deprecated npmconf@2.1.2: this package has been reintegrated into npm and is now out of date with respect to npm
/usr/local/lib
└── (empty)
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "cordova"
npm ERR! node v4.2.6
npm ERR! npm v3.6.0
npm ERR! path /usr/local/lib/node_modules/.staging/abbrev-ef9cc920
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/abbrev-ef9cc920' -> '/usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/abbrev'
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/abbrev-ef9cc920' -> '/usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/abbrev'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! /Users/lucientavano/npm-debug.log
npm ERR! code 1
Luciens-MacBook-Pro:~ lucientavano$ tail -10 /Users/lucientavano/npm-debug.log
21365 error npm v3.6.0
21366 error path /usr/local/lib/node_modules/.staging/abbrev-ef9cc920
21367 error code ENOENT
21368 error errno -2
21369 error syscall rename
21370 error enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/abbrev-ef9cc920' -> '/usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/abbrev'
21371 error enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/abbrev-ef9cc920' -> '/usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/abbrev'
21371 error enoent This is most likely not a problem with npm itself
21371 error enoent and is related to npm not being able to find a file.
21372 verbose exit [ -2, true ]
</code></pre>
<p>Have you run into a similar issue? Thank you in advance for any suggestion you may have.</p>
| 0debug |
static inline void gen_intermediate_code_internal(CPUState *env,
TranslationBlock *tb,
int search_pc)
{
DisasContext dc1, *dc = &dc1;
CPUBreakpoint *bp;
uint16_t *gen_opc_end;
int j, lj;
target_ulong pc_start;
uint32_t next_page_start;
int num_insns;
int max_insns;
num_temps = 0;
pc_start = tb->pc;
dc->tb = tb;
gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;
dc->is_jmp = DISAS_NEXT;
dc->pc = pc_start;
dc->singlestep_enabled = env->singlestep_enabled;
dc->condjmp = 0;
dc->thumb = ARM_TBFLAG_THUMB(tb->flags);
dc->condexec_mask = (ARM_TBFLAG_CONDEXEC(tb->flags) & 0xf) << 1;
dc->condexec_cond = ARM_TBFLAG_CONDEXEC(tb->flags) >> 4;
#if !defined(CONFIG_USER_ONLY)
dc->user = (ARM_TBFLAG_PRIV(tb->flags) == 0);
#endif
dc->vfp_enabled = ARM_TBFLAG_VFPEN(tb->flags);
dc->vec_len = ARM_TBFLAG_VECLEN(tb->flags);
dc->vec_stride = ARM_TBFLAG_VECSTRIDE(tb->flags);
cpu_F0s = tcg_temp_new_i32();
cpu_F1s = tcg_temp_new_i32();
cpu_F0d = tcg_temp_new_i64();
cpu_F1d = tcg_temp_new_i64();
cpu_V0 = cpu_F0d;
cpu_V1 = cpu_F1d;
cpu_M0 = tcg_temp_new_i64();
next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
lj = -1;
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0)
max_insns = CF_COUNT_MASK;
gen_icount_start();
if (dc->condexec_mask || dc->condexec_cond)
{
TCGv tmp = new_tmp();
tcg_gen_movi_i32(tmp, 0);
store_cpu_field(tmp, condexec_bits);
}
do {
#ifdef CONFIG_USER_ONLY
if (dc->pc >= 0xffff0000) {
gen_exception(EXCP_KERNEL_TRAP);
dc->is_jmp = DISAS_UPDATE;
break;
}
#else
if (dc->pc >= 0xfffffff0 && IS_M(env)) {
gen_exception(EXCP_EXCEPTION_EXIT);
dc->is_jmp = DISAS_UPDATE;
break;
}
#endif
if (unlikely(!QTAILQ_EMPTY(&env->breakpoints))) {
QTAILQ_FOREACH(bp, &env->breakpoints, entry) {
if (bp->pc == dc->pc) {
gen_exception_insn(dc, 0, EXCP_DEBUG);
dc->pc += 2;
goto done_generating;
break;
}
}
}
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
gen_opc_instr_start[lj++] = 0;
}
gen_opc_pc[lj] = dc->pc;
gen_opc_condexec_bits[lj] = (dc->condexec_cond << 4) | (dc->condexec_mask >> 1);
gen_opc_instr_start[lj] = 1;
gen_opc_icount[lj] = num_insns;
}
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
gen_io_start();
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP))) {
tcg_gen_debug_insn_start(dc->pc);
}
if (dc->thumb) {
disas_thumb_insn(env, dc);
if (dc->condexec_mask) {
dc->condexec_cond = (dc->condexec_cond & 0xe)
| ((dc->condexec_mask >> 4) & 1);
dc->condexec_mask = (dc->condexec_mask << 1) & 0x1f;
if (dc->condexec_mask == 0) {
dc->condexec_cond = 0;
}
}
} else {
disas_arm_insn(env, dc);
}
if (num_temps) {
fprintf(stderr, "Internal resource leak before %08x\n", dc->pc);
num_temps = 0;
}
if (dc->condjmp && !dc->is_jmp) {
gen_set_label(dc->condlabel);
dc->condjmp = 0;
}
num_insns ++;
} while (!dc->is_jmp && gen_opc_ptr < gen_opc_end &&
!env->singlestep_enabled &&
!singlestep &&
dc->pc < next_page_start &&
num_insns < max_insns);
if (tb->cflags & CF_LAST_IO) {
if (dc->condjmp) {
cpu_abort(env, "IO on conditional branch instruction");
}
gen_io_end();
}
if (unlikely(env->singlestep_enabled)) {
if (dc->condjmp) {
gen_set_condexec(dc);
if (dc->is_jmp == DISAS_SWI) {
gen_exception(EXCP_SWI);
} else {
gen_exception(EXCP_DEBUG);
}
gen_set_label(dc->condlabel);
}
if (dc->condjmp || !dc->is_jmp) {
gen_set_pc_im(dc->pc);
dc->condjmp = 0;
}
gen_set_condexec(dc);
if (dc->is_jmp == DISAS_SWI && !dc->condjmp) {
gen_exception(EXCP_SWI);
} else {
gen_exception(EXCP_DEBUG);
}
} else {
gen_set_condexec(dc);
switch(dc->is_jmp) {
case DISAS_NEXT:
gen_goto_tb(dc, 1, dc->pc);
break;
default:
case DISAS_JUMP:
case DISAS_UPDATE:
tcg_gen_exit_tb(0);
break;
case DISAS_TB_JUMP:
break;
case DISAS_WFI:
gen_helper_wfi();
break;
case DISAS_SWI:
gen_exception(EXCP_SWI);
break;
}
if (dc->condjmp) {
gen_set_label(dc->condlabel);
gen_set_condexec(dc);
gen_goto_tb(dc, 1, dc->pc);
dc->condjmp = 0;
}
}
done_generating:
gen_icount_end(tb, num_insns);
*gen_opc_ptr = INDEX_op_end;
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(pc_start, dc->pc - pc_start, dc->thumb);
qemu_log("\n");
}
#endif
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
lj++;
while (lj <= j)
gen_opc_instr_start[lj++] = 0;
} else {
tb->size = dc->pc - pc_start;
tb->icount = num_insns;
}
}
| 1threat |
int av_opencl_buffer_read_image(uint8_t **dst_data, int *plane_size, int plane_num,
cl_mem src_cl_buf, size_t cl_buffer_size)
{
int i,buffer_size = 0,ret = 0;
uint8_t *temp;
void *mapped;
cl_int status;
if ((unsigned int)plane_num > 8) {
return AVERROR(EINVAL);
}
for (i = 0;i < plane_num;i++) {
buffer_size += plane_size[i];
}
if (buffer_size > cl_buffer_size) {
av_log(&openclutils, AV_LOG_ERROR, "Cannot write image to CPU buffer: OpenCL buffer too small\n");
return AVERROR(EINVAL);
}
mapped = clEnqueueMapBuffer(gpu_env.command_queue, src_cl_buf,
CL_TRUE,CL_MAP_READ, 0, buffer_size,
0, NULL, NULL, &status);
if (status != CL_SUCCESS) {
av_log(&openclutils, AV_LOG_ERROR, "Could not map OpenCL buffer: %s\n", opencl_errstr(status));
return AVERROR_EXTERNAL;
}
temp = mapped;
if (ret >= 0) {
for (i = 0;i < plane_num;i++) {
memcpy(dst_data[i], temp, plane_size[i]);
temp += plane_size[i];
}
}
status = clEnqueueUnmapMemObject(gpu_env.command_queue, src_cl_buf, mapped, 0, NULL, NULL);
if (status != CL_SUCCESS) {
av_log(&openclutils, AV_LOG_ERROR, "Could not unmap OpenCL buffer: %s\n", opencl_errstr(status));
return AVERROR_EXTERNAL;
}
return 0;
}
| 1threat |
Pandas DataFrame How to query the closest datetime index? : <p>How do i query for the closest index from a Pandas DataFrame? The index is DatetimeIndex</p>
<pre><code>2016-11-13 20:00:10.617989120 7.0 132.0
2016-11-13 22:00:00.022737152 1.0 128.0
2016-11-13 22:00:28.417561344 1.0 132.0
</code></pre>
<p>I tried this:</p>
<pre><code>df.index.get_loc(df.index[0], method='nearest')
</code></pre>
<p>but it give me <code>InvalidIndexError: Reindexing only valid with uniquely valued Index objects</code></p>
<p>Same error if I tried this:</p>
<pre><code>dt =datetime.datetime.strptime("2016-11-13 22:01:25", "%Y-%m-%d %H:%M:%S")
df.index.get_loc(dt, method='nearest')
</code></pre>
<p>But if I remove <code>method='nearest'</code> it works, but that is not I want, I want to find the closest index from my query datetime</p>
| 0debug |
HMAC PHP output not matching with one in Java - Urgent : I'm trying to set up an API Connection which requires HMAC and encryption.
The documentation and sample output / code given to me is in Java but my website is in PHP. I'm on PHP 7.
What should I do so that my php output matches with that in Java sample output given in the API documentation.
I have tried to base64, utf8 and utf16 encoding on my php hmac output but still the value is not matching
PHP Code:
$sb = '4a275929e0eba4445bc7f9a80c6361a2351119a27b51eebb2c259f68f72efd5f';
$keyToEncode = 'c0814229c201ab1022070741d15eda7af2189db64a2c88699c6481dbb83521afd8640d9af6d984602037d2e4f90c4f9a12915899290d944f385192b658829ec1;
$sb3 = hash_hmac('sha256',$sb, $keyToEncode);
Java Code:
**HMAC_SHA256(sb.toString(), keyToEncode);**
Output in PHP:
**2bea1f99897a8fd2e836e9d8f7820a28c03b76bf37daf04527f6f5d279c97fd7**
Expected output in Java:
**gWzlCNzu7fNN4z/uwvrgk574dTJqLQ8+25UMXCh+4tU=**
| 0debug |
How to open remote files in sublime text 3 : <p>I am connecting to remote server using "mRemoteNG" and want to open remote server files in my local sublime text editor. During my research, I found this relevant blog <a href="https://wrgms.com/editing-files-remotely-via-ssh-on-sublimetext-3/" rel="noreferrer">https://wrgms.com/editing-files-remotely-via-ssh-on-sublimetext-3/</a> and followed the instructions but it is not working for me.
Does, anybody know how can I open remote files in my Sublime?</p>
| 0debug |
How to get InfluxDB version via shell : <p>The influx shell has a <code>-version</code> flag, but not influx server:</p>
<pre><code>/path/to/bin/influx -version
InfluxDB shell version: 1.1.1
/path/to/bin/influxd -version
flag provided but not defined: -version
/path/to/bin/influxd -v
flag provided but not defined: -v
</code></pre>
<p>Should I assume that influx shell and influx server will always have the same version ? </p>
| 0debug |
Questions about hyperparameter tuning in Keras/Tensorflow : <p>I am studying deep learning recently, mainly rely on Andrew Ng's Deep Learning Specialization on Coursera. </p>
<p>And I want to build my own model to classify <code>MNIST</code> with 99% accuracy (simple MLP model, not CNN). So I use <code>KerasClassifier</code> to wrap my model and use <code>GridsearchCV</code> to fine tune the hyperparameters (including hidden layer number, units number, dropout rate, etc.)</p>
<p>However, when I google "fine tuning", the majority of the results are mainly on "transfer learning", which are just tuning the learning rate, output layer number or freeze layer number.</p>
<p>I know these famous models are capable to deal with many problems with just a little changes. But what if I want to build a tiny model from scratch to handle a special question, what are the common/best practice?</p>
<p>So my questions are mainly about the common/best practice of fine tuning model:</p>
<ol>
<li>What is the common/best way to fine tuning? (I have seen people tune hyperparameters manually, or using scikit-learn's <code>RandomizedSearchCV</code>/<code>GridSearchCV</code>, or <code>hyperas</code>)</li>
<li>Should I use k-fold cross validation? (Because it's the default set of <code>GridSearchCV</code>, and it extremely increases the training time but helps little)</li>
<li>Is it enough to solve most problems by slightly modifying the off-the-shelf models? If not, to what direction should I move on?</li>
</ol>
<p>Thanks!</p>
| 0debug |
Xamarin Forms LocalNotification when button clicked : I am a novice in Xamarin , I am trying to activate a notification When I clicked on a button.
I have installed this plugin:
-https://github.com/B1naryStudio/Xamarin.LocalNotifications
-https://www.nuget.org/packages/Xam.Plugin.LocalNotifications/
The things is the plugin does not working , and I have followed everything but I cannot see why I still have nothing
here my Xaml:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="LeafWords.Classes.SettingsLeaf.WordSettings">
<ContentPage.Content>
<StackLayout>
<Button Clicked="WordNotif" Text="Local Notification"></Button>
</StackLayout>
</ContentPage.Content>
</ContentPage>
Here is my method:
void WordNotif() {
// Handle when your app starts
var notification = new LocalNotification
{
Text = "Hello Plugin",
Title = "Nbation Plugin",
Id = 2,
NotifyTime = DateTime.Now.AddSeconds(10)
};
var notifier = CrossLocalNotifications.CreateLocalNotifier();
notifier.Notify(notification);
}
Thanks
| 0debug |
void coroutine_fn qemu_coroutine_yield(void)
{
Coroutine *self = qemu_coroutine_self();
Coroutine *to = self->caller;
trace_qemu_coroutine_yield(self, to);
if (!to) {
fprintf(stderr, "Co-routine is yielding to no one\n");
abort();
}
self->caller = NULL;
coroutine_swap(self, to);
}
| 1threat |
How to put image on UIActionSheet? : How to put image on `UIActionSheet` on right position of text. Like given in apple music player.
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/koP7P.jpg
Any help will be appreciated.
Note: Don't answer with custom view, if it is possible in `UIActionSheet`, Kindly let us know.
Thank you | 0debug |
Dont include last child while using li:after : <p>I would like to add "|" after every li elements but not include last li. How could I do?</p>
<p><a href="https://jsfiddle.net/atahta/s9x05ks9/" rel="nofollow noreferrer">fiddle</a></p>
<p>HTML</p>
<pre><code><nav class="footer-menu">
<ul>
<li><a href="">Blog</a></li>
<li ><a href="#">Page B</a></li>
<li><a href="">Page A</a></li>
</ul>
</code></pre>
<p></p>
<p>CSS</p>
<pre><code>.footer-menu ul li{display: inline-table;}
.footer-menu {text-align: center; background: #FFF;}
.footer-menu ul li:after {
font-size: 13px;
color: #999;
width: 100%;
content:"|";
}
</code></pre>
| 0debug |
static ssize_t qemu_enqueue_packet_iov(VLANClientState *sender,
const struct iovec *iov, int iovcnt,
NetPacketSent *sent_cb)
{
VLANPacket *packet;
size_t max_len = 0;
int i;
max_len = calc_iov_length(iov, iovcnt);
packet = qemu_malloc(sizeof(VLANPacket) + max_len);
packet->sender = sender;
packet->sent_cb = sent_cb;
packet->size = 0;
for (i = 0; i < iovcnt; i++) {
size_t len = iov[i].iov_len;
memcpy(packet->data + packet->size, iov[i].iov_base, len);
packet->size += len;
}
TAILQ_INSERT_TAIL(&sender->vlan->send_queue, packet, entry);
return packet->size;
}
| 1threat |
static struct URLProtocol *url_find_protocol(const char *filename)
{
URLProtocol *up = NULL;
char proto_str[128], proto_nested[128], *ptr;
size_t proto_len = strspn(filename, URL_SCHEME_CHARS);
if (filename[proto_len] != ':' &&
(filename[proto_len] != ',' || !strchr(filename + proto_len + 1, ':')) ||
is_dos_path(filename))
strcpy(proto_str, "file");
else
av_strlcpy(proto_str, filename,
FFMIN(proto_len + 1, sizeof(proto_str)));
if ((ptr = strchr(proto_str, ',')))
*ptr = '\0';
av_strlcpy(proto_nested, proto_str, sizeof(proto_nested));
if ((ptr = strchr(proto_nested, '+')))
*ptr = '\0';
while (up = ffurl_protocol_next(up)) {
if (!strcmp(proto_str, up->name))
break;
if (up->flags & URL_PROTOCOL_FLAG_NESTED_SCHEME &&
!strcmp(proto_nested, up->name))
break;
}
return up;
}
| 1threat |
C++ Text Based Inventory Pt.2 : <p>I'd first like to start off by thanking everyone who helped me yesterday with another error. My teacher is currently off of work due to an accident and we don't use any reference books in the class (not provided), so please bear with me here if my post isn't formatted correctly or if my problem is quite obvious to everyone else. I'm now getting two errors in my code after adding some more lines (using this <a href="https://stackoverflow.com/questions/31093180/c-text-rpg-inventory-system">post</a> as a reference for my own project.) The two errors I get are:</p>
<pre><code>Error (active) E0349 no operator "=" matches these operands operand types are: Item = std::string line 76
</code></pre>
<p>and </p>
<pre><code>Error C2679 binary '=': no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion) line 76
</code></pre>
<p>Like I stated early in this post, we were assigned this RPG project in class but my teacher got into an accident, and there is no help available (our substitute is a retired lady who is basically a career substitute with no coding experience).</p>
<p>Here is all my code: </p>
<pre><code>// clunkinv.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include "pch.h"
#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <ostream>
#include <Windows.h>
#include <string>
#include <cstring>
#include <cctype>
using namespace std;
struct Item {
string name; //Item name.
int slot; //Head, Torso, Hands
int attack;
int knowledge;
int defense;
int hp;
int speed;
int charisma;
};
std::ostream &operator<<(std::ostream &os, const Item& item) {
os << item.name;
return os;
}
int main()
{
//Variables, Strings, etc.
int itemcounter = 0, counter = 0;
string search;
//"Empty" Item
Item Empty{ "<Empty>", 0, 0, 0 };
Item Sword{
"Paper Cutter Sword", //This item name is 'Short Sword'.
3, //Slot
3, //Attack
0,
0,
0,
0,
0,
};
vector<Item> Equipment = { 6, Empty }; //Current Equipment, 6 empty slots.
vector<Item> Inventory = { }; //Inventory
string InventorySlots[] = { "Head" "Torso", "Hands" }; //Player slots where items can be equiped.
cout << "You sit your bag down and take a look inside." << " You have:" << endl;
cout << "Enter 'Equip' to equip an item, or 'inventory' to see full inventory" << endl;
for (int i = 0; i < itemcounter; i++)
{
cout << InventorySlots[i];
if (Equipment[i].name == "Empty ")
{
cout << " " << Equipment[i].name << endl << endl;
}
}
if (search == "inventory") {
cout << "What do you want to equip? ";
cin >> search;
for (unsigned i = 0; i < Inventory.size(); i++) {
//Search for item player want to equip, put it in right slot.
if (search == Inventory[i].name) {
Equipment[Inventory[i].slot] = Inventory[i].name;
cout << "Successfully equiped!" << endl;
}
}
}
if (search == "inventory") {
for (unsigned i = 0; i < Inventory.size(); i++) {
cout << "______________________________________________________________" << endl;
cout << "| " << Inventory[i].name << endl;
cout << "| Carried items " << Inventory.size() << " / " << 20 << endl;
cout << "|_____________________________________________________________" << endl;
}
}
}
</code></pre>
| 0debug |
Get response from axios with await/async : <p>I'm trying to get JSON object from <strong>axios</strong></p>
<pre><code>'use strict'
async function getData() {
try {
var ip = location.host;
await axios({
url: http() + ip + '/getData',
method: 'POST',
timeout: 8000,
headers: {
'Content-Type': 'application/json',
}
}).then(function (res) {
console.dir(res); // we are good here, the res has the JSON data
return res;
}).catch(function (err) {
console.error(err);
})
}
catch (err) {
console.error(err);
}
}
</code></pre>
<p>Now I need to fetch the <strong>res</strong></p>
<pre><code>let dataObj;
getData().then(function (result) {
console.dir(result); // Ooops, the result is undefined
dataObj = result;
});
</code></pre>
<p>The code is blocking and waits for the result, but I'm getting undefined instead of object</p>
| 0debug |
static void openpic_save_IRQ_queue(QEMUFile* f, IRQ_queue_t *q)
{
unsigned int i;
for (i = 0; i < BF_WIDTH(MAX_IRQ); i++)
qemu_put_be32s(f, &q->queue[i]);
qemu_put_sbe32s(f, &q->next);
qemu_put_sbe32s(f, &q->priority);
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.