problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Python convert list to dict with multiple key value : <p>I have a list something like below and want to convert it to dict</p>
<pre><code>my_list = ['key1=value1', 'key2=value2', 'key3=value3-1', 'value3-2', 'value3-3', 'key4=value4', 'key5=value5', 'value5-1', 'value5-2', 'key6=value6']
</code></pre>
<p>How can I convert above list to dict something like below</p>
<pre><code>my_dict = {
'key1': 'value1',
'key2': 'value2',
'key3': ['value3-1', 'value3-2', 'value3-3'],
'key4': 'value4',
'key5': ['value5', 'value5-1', 'value5-2'],
'key6': 'value6'
}
</code></pre>
| 0debug
|
void gd_egl_scanout(DisplayChangeListener *dcl,
uint32_t backing_id, bool backing_y_0_top,
uint32_t x, uint32_t y,
uint32_t w, uint32_t h)
{
VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
vc->gfx.x = x;
vc->gfx.y = y;
vc->gfx.w = w;
vc->gfx.h = h;
vc->gfx.tex_id = backing_id;
vc->gfx.y0_top = backing_y_0_top;
eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
vc->gfx.esurface, vc->gfx.ectx);
if (vc->gfx.tex_id == 0 || vc->gfx.w == 0 || vc->gfx.h == 0) {
gtk_egl_set_scanout_mode(vc, false);
return;
}
gtk_egl_set_scanout_mode(vc, true);
if (!vc->gfx.fbo_id) {
glGenFramebuffers(1, &vc->gfx.fbo_id);
}
glBindFramebuffer(GL_FRAMEBUFFER_EXT, vc->gfx.fbo_id);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_TEXTURE_2D, vc->gfx.tex_id, 0);
}
| 1threat
|
MSTest cannot find TestAdapter.dll : <p>I'm using the built-in Visual Studio test tools (<code>Test -> Run -> etc</code> in the menu). I just started having a problem where I get the following error when I try to run tests</p>
<p><code>[3/29/2018 1:39:14 PM Error] System.IO.FileNotFoundException: C:\Users\brubin\AppData\Local\Temp\VisualStudioTestExplorerExtensions\MSTest.TestAdapter.1.1.18/build/_common/Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll
at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.PerformShadowCopy(IEnumerable'1 testExtensions)</code></p>
<p>That's followed by some errors that say</p>
<p><code>Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.</code></p>
<p>When I look at the folder <code>C:\Users\brubin\AppData\Local\Temp\VisualStudioTestExplorerExtensions\MSTest.TestAdapter.1.1.18/build/_common/</code>, there are no files in that folder. However, I haven't knowingly changed anything about my test setup and this was working several days ago, so I don't know why it would have stopped working.</p>
<p>My projects are using the MSTest.TestFramework (MSTest V2) version v1.2 NuGet package.</p>
<p>One thing I noticed that may have caused this problem is that if I go to <code>Tools -> Extensions and Updates</code>, I see that my Microsoft Visual Studio Test Platform was updated a few days ago, on 3/23 (I think that's when I installed a Visual Studio update). However, if that broke something, I have no idea where to look to see what's broken, or how to fix it.</p>
<p><a href="https://i.stack.imgur.com/Wa25J.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Wa25J.png" alt="enter image description here"></a></p>
| 0debug
|
static void pci_change_irq_level(PCIDevice *pci_dev, int irq_num, int change)
{
PCIBus *bus;
for (;;) {
bus = pci_dev->bus;
irq_num = bus->map_irq(pci_dev, irq_num);
if (bus->set_irq)
break;
pci_dev = bus->parent_dev;
}
bus->irq_count[irq_num] += change;
bus->set_irq(bus->irq_opaque, irq_num, bus->irq_count[irq_num] != 0);
}
| 1threat
|
static void spatial_compose53i(IDWTELEM *buffer, int width, int height, int stride){
dwt_compose_t cs;
spatial_compose53i_init(&cs, buffer, height, stride);
while(cs.y <= height)
spatial_compose53i_dy(&cs, buffer, width, height, stride);
}
| 1threat
|
int kvm_arch_on_sigbus(int code, void *addr)
{
#ifdef KVM_CAP_MCE
if ((first_cpu->mcg_cap & MCG_SER_P) && addr && code == BUS_MCEERR_AO) {
ram_addr_t ram_addr;
target_phys_addr_t paddr;
if (qemu_ram_addr_from_host(addr, &ram_addr) ||
!kvm_physical_memory_addr_from_ram(first_cpu->kvm_state, ram_addr,
&paddr)) {
fprintf(stderr, "Hardware memory error for memory used by "
"QEMU itself instead of guest system!: %p\n", addr);
return 0;
}
kvm_mce_inject(first_cpu, paddr, code);
} else
#endif
{
if (code == BUS_MCEERR_AO) {
return 0;
} else if (code == BUS_MCEERR_AR) {
hardware_memory_error();
} else {
return 1;
}
}
return 0;
}
| 1threat
|
how to read excel files datas and write into csv file using java? : <p>could you please anyone assist me how to read excel files datas and write into csv file using java????</p>
<p>Please give Code for this scenario</p>
<p>Thanks in Advance</p>
<p>Regards
Kumar </p>
| 0debug
|
static bool blit_region_is_unsafe(struct CirrusVGAState *s,
int32_t pitch, int32_t addr)
{
if (pitch < 0) {
int64_t min = addr
+ ((int64_t)s->cirrus_blt_height-1) * pitch;
int32_t max = addr
+ s->cirrus_blt_width;
if (min < 0 || max >= s->vga.vram_size) {
return true;
}
} else {
int64_t max = addr
+ ((int64_t)s->cirrus_blt_height-1) * pitch
+ s->cirrus_blt_width;
if (max >= s->vga.vram_size) {
return true;
}
}
return false;
}
| 1threat
|
Building a html, css & javascript pages for wordpress without php? : <p>So as the titles already states, is it possible to build a fully functioning wordpress page layout/theme using only frontend languages? And how will I incorporate it into wordpress without php?</p>
<p>Thanks!!!</p>
| 0debug
|
What is the best way to create an Observable which directly emits after creation? : <p>I am asking myself what would be the most proper and semantically correct way to create an observable which emits directly after creation?</p>
<p>Of course I can always do something like this <code>of(unkown)</code>, <code>of(undefined)</code>, <code>of(null)</code>, <code>of(true)</code> and so on, but what would be the "correct" way to do this, is there any reference? </p>
| 0debug
|
How to send binary data back to client using GraphQL : <p>I have a GraphQL server, hosted on express. I want to return images to the client by sending back nodejs buffer objects. How can i config graphql server, to return bytes, instead of json? I don't wish to do this through base64, as the image are large in size. </p>
| 0debug
|
BlockDeviceInfoList *bdrv_named_nodes_list(void)
{
BlockDeviceInfoList *list, *entry;
BlockDriverState *bs;
list = NULL;
QTAILQ_FOREACH(bs, &graph_bdrv_states, node_list) {
entry = g_malloc0(sizeof(*entry));
entry->value = bdrv_block_device_info(bs);
entry->next = list;
list = entry;
}
return list;
}
| 1threat
|
my running c++ baclground : i've re installed my dev c++ and now i have problem that when i run the app of this simple code:
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
cout<<"hi mateen";
return 0;
}
it shows me this:
[![enter image description here][1]][1]
how can i delete this?it wasnt showing before alwaays used to use
getche()
but even when i use
return 0;
the problem is still the same.
thanks
[1]: http://i.stack.imgur.com/GNvTn.png
| 0debug
|
static void parse_waveformatex(AVIOContext *pb, AVCodecParameters *par)
{
ff_asf_guid subformat;
par->bits_per_coded_sample = avio_rl16(pb);
par->channel_layout = avio_rl32(pb);
ff_get_guid(pb, &subformat);
if (!memcmp(subformat + 4,
(const uint8_t[]){ FF_MEDIASUBTYPE_BASE_GUID }, 12)) {
par->codec_tag = AV_RL32(subformat);
par->codec_id = ff_wav_codec_get_id(par->codec_tag,
par->bits_per_coded_sample);
} else {
par->codec_id = ff_codec_guid_get_id(ff_codec_wav_guids, subformat);
if (!par->codec_id)
av_log(pb, AV_LOG_WARNING,
"unknown subformat:"FF_PRI_GUID"\n",
FF_ARG_GUID(subformat));
}
}
| 1threat
|
void swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSampleFormat noise_fmt) {
double scale = s->dither.noise_scale;
#define TMP_EXTRA 2
double *tmp = av_malloc_array(len + TMP_EXTRA, sizeof(double));
int i;
for(i=0; i<len + TMP_EXTRA; i++){
double v;
seed = seed* 1664525 + 1013904223;
switch(s->dither.method){
case SWR_DITHER_RECTANGULAR: v= ((double)seed) / UINT_MAX - 0.5; break;
default:
av_assert0(s->dither.method < SWR_DITHER_NB);
v = ((double)seed) / UINT_MAX;
seed = seed*1664525 + 1013904223;
v-= ((double)seed) / UINT_MAX;
break;
}
tmp[i] = v;
}
for(i=0; i<len; i++){
double v;
switch(s->dither.method){
default:
av_assert0(s->dither.method < SWR_DITHER_NB);
v = tmp[i];
break;
case SWR_DITHER_TRIANGULAR_HIGHPASS :
v = (- tmp[i] + 2*tmp[i+1] - tmp[i+2]) / sqrt(6);
break;
}
v*= scale;
switch(noise_fmt){
case AV_SAMPLE_FMT_S16P: ((int16_t*)dst)[i] = v; break;
case AV_SAMPLE_FMT_S32P: ((int32_t*)dst)[i] = v; break;
case AV_SAMPLE_FMT_FLTP: ((float *)dst)[i] = v; break;
case AV_SAMPLE_FMT_DBLP: ((double *)dst)[i] = v; break;
default: av_assert0(0);
}
}
av_free(tmp);
}
| 1threat
|
int net_init_socket(const Netdev *netdev, const char *name,
NetClientState *peer, Error **errp)
{
Error *err = NULL;
const NetdevSocketOptions *sock;
assert(netdev->type == NET_CLIENT_DRIVER_SOCKET);
sock = &netdev->u.socket;
if (sock->has_fd + sock->has_listen + sock->has_connect + sock->has_mcast +
sock->has_udp != 1) {
error_report("exactly one of fd=, listen=, connect=, mcast= or udp="
" is required");
return -1;
}
if (sock->has_localaddr && !sock->has_mcast && !sock->has_udp) {
error_report("localaddr= is only valid with mcast= or udp=");
return -1;
}
if (sock->has_fd) {
int fd;
fd = monitor_fd_param(cur_mon, sock->fd, &err);
if (fd == -1) {
error_report_err(err);
return -1;
}
qemu_set_nonblock(fd);
if (!net_socket_fd_init(peer, "socket", name, fd, 1)) {
return -1;
}
return 0;
}
if (sock->has_listen) {
if (net_socket_listen_init(peer, "socket", name, sock->listen) == -1) {
return -1;
}
return 0;
}
if (sock->has_connect) {
if (net_socket_connect_init(peer, "socket", name, sock->connect) ==
-1) {
return -1;
}
return 0;
}
if (sock->has_mcast) {
if (net_socket_mcast_init(peer, "socket", name, sock->mcast,
sock->localaddr) == -1) {
return -1;
}
return 0;
}
assert(sock->has_udp);
if (!sock->has_localaddr) {
error_report("localaddr= is mandatory with udp=");
return -1;
}
if (net_socket_udp_init(peer, "socket", name, sock->udp, sock->localaddr) ==
-1) {
return -1;
}
return 0;
}
| 1threat
|
Dealing with dead letters in RabbitMQ : <p>TL;DR: I need to "replay" dead letter messages back into their original queues once I've fixed the consumer code that was originally causing the messages to be rejected.</p>
<p>I have configured the Dead Letter Exchange (DLX) for RabbitMQ and am successfully routing rejected messages to a dead letter queue. But now I want to look at the messages in the dead letter queue and try to decide what to do with each of them. Some (many?) of these messages should be replayed (requeued) to their original queues (available in the "x-death" headers) once the offending consumer code has been fixed. But how do I actually go about doing this? Should I write a one-off program that reads messages from the dead letter queue and allows me to specify a target queue to send them to? And what about searching the dead letter queue? What if I know that a message (let's say which is encoded in JSON) has a certain attribute that I want to search for and replay? For example, I fix a defect which I know will allow message with PacketId: 1234 to successfully process now. I could also write a one-off program for this I suppose.</p>
<p>I certainly can't be the first one to encounter these problems and I'm wondering if anyone else has already solved them. It seems like there should be some sort of Swiss Army Knife for this sort of thing. I did a pretty extensive search on Google and Stack Overflow but didn't really come up with much. The closest thing I could find were shovels but that doesn't really seem like the right tool for the job.</p>
| 0debug
|
No overload for method 'ToString' takes 1 arguements : Making a mod for a game, and I'm trying to get the name of the character always, when it spawns, Matt.
However, this didn't go well for me. Despite the countless problems I fixed by myself, I can't find a way around "No overload for method 'ToString' takes 1 arguements." Here's the code:
switch (WorldGen.genRand.Next(0))
{
case 0:
return ToString("Matt");
}
| 0debug
|
static ssize_t block_crypto_write_func(QCryptoBlock *block,
size_t offset,
const uint8_t *buf,
size_t buflen,
Error **errp,
void *opaque)
{
struct BlockCryptoCreateData *data = opaque;
ssize_t ret;
ret = blk_pwrite(data->blk, offset, buf, buflen, 0);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not write encryption header");
return ret;
}
return ret;
}
| 1threat
|
How to use adaptive launcher icons with a progressive web app : <p>The new Android 8.0 standard for <a href="https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive" rel="noreferrer">adaptive launcher icons</a> leaves my PWA's icon in a white box or circle, depending on what icon shape is set on a user's device. I would like to include an adaptive icon with my PWA but am not finding any documentation around this at all.</p>
<p>Is there a way to include meta and different icons for different shapes or a way to include the necessary layers for an adaptive icon?</p>
| 0debug
|
static int rtmp_open(URLContext *s, const char *uri, int flags)
{
RTMPContext *rt = s->priv_data;
char proto[8], hostname[256], path[1024], auth[100], *fname;
char *old_app;
uint8_t buf[2048];
int port;
AVDictionary *opts = NULL;
int ret;
if (rt->listen_timeout > 0)
rt->listen = 1;
rt->is_input = !(flags & AVIO_FLAG_WRITE);
av_url_split(proto, sizeof(proto), auth, sizeof(auth),
hostname, sizeof(hostname), &port,
path, sizeof(path), s->filename);
if (auth[0]) {
char *ptr = strchr(auth, ':');
if (ptr) {
*ptr = '\0';
av_strlcpy(rt->username, auth, sizeof(rt->username));
av_strlcpy(rt->password, ptr + 1, sizeof(rt->password));
}
}
if (rt->listen && strcmp(proto, "rtmp")) {
av_log(s, AV_LOG_ERROR, "rtmp_listen not available for %s\n",
proto);
return AVERROR(EINVAL);
}
if (!strcmp(proto, "rtmpt") || !strcmp(proto, "rtmpts")) {
if (!strcmp(proto, "rtmpts"))
av_dict_set(&opts, "ffrtmphttp_tls", "1", 1);
ff_url_join(buf, sizeof(buf), "ffrtmphttp", NULL, hostname, port, NULL);
} else if (!strcmp(proto, "rtmps")) {
if (port < 0)
port = RTMPS_DEFAULT_PORT;
ff_url_join(buf, sizeof(buf), "tls", NULL, hostname, port, NULL);
} else if (!strcmp(proto, "rtmpe") || (!strcmp(proto, "rtmpte"))) {
if (!strcmp(proto, "rtmpte"))
av_dict_set(&opts, "ffrtmpcrypt_tunneling", "1", 1);
ff_url_join(buf, sizeof(buf), "ffrtmpcrypt", NULL, hostname, port, NULL);
rt->encrypted = 1;
} else {
if (port < 0)
port = RTMP_DEFAULT_PORT;
if (rt->listen)
ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port,
"?listen&listen_timeout=%d",
rt->listen_timeout * 1000);
else
ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL);
}
reconnect:
if ((ret = ffurl_open(&rt->stream, buf, AVIO_FLAG_READ_WRITE,
&s->interrupt_callback, &opts)) < 0) {
av_log(s , AV_LOG_ERROR, "Cannot open connection %s\n", buf);
goto fail;
}
if (rt->swfverify) {
if ((ret = rtmp_calc_swfhash(s)) < 0)
goto fail;
}
rt->state = STATE_START;
if (!rt->listen && (ret = rtmp_handshake(s, rt)) < 0)
goto fail;
if (rt->listen && (ret = rtmp_server_handshake(s, rt)) < 0)
goto fail;
rt->out_chunk_size = 128;
rt->in_chunk_size = 128;
rt->state = STATE_HANDSHAKED;
old_app = rt->app;
rt->app = av_malloc(APP_MAX_LENGTH);
if (!rt->app) {
ret = AVERROR(ENOMEM);
goto fail;
}
if (!strncmp(path, "/ondemand/", 10)) {
fname = path + 10;
memcpy(rt->app, "ondemand", 9);
} else {
char *next = *path ? path + 1 : path;
char *p = strchr(next, '/');
if (!p) {
fname = next;
rt->app[0] = '\0';
} else {
char *c = strchr(p + 1, ':');
fname = strchr(p + 1, '/');
if (!fname || (c && c < fname)) {
fname = p + 1;
av_strlcpy(rt->app, path + 1, p - path);
} else {
fname++;
av_strlcpy(rt->app, path + 1, fname - path - 1);
}
}
}
if (old_app) {
av_free(rt->app);
rt->app = old_app;
}
if (!rt->playpath) {
int len = strlen(fname);
rt->playpath = av_malloc(PLAYPATH_MAX_LENGTH);
if (!rt->playpath) {
ret = AVERROR(ENOMEM);
goto fail;
}
if (!strchr(fname, ':') && len >= 4 &&
(!strcmp(fname + len - 4, ".f4v") ||
!strcmp(fname + len - 4, ".mp4"))) {
memcpy(rt->playpath, "mp4:", 5);
} else if (len >= 4 && !strcmp(fname + len - 4, ".flv")) {
fname[len - 4] = '\0';
} else {
rt->playpath[0] = 0;
}
av_strlcat(rt->playpath, fname, PLAYPATH_MAX_LENGTH);
}
if (!rt->tcurl) {
rt->tcurl = av_malloc(TCURL_MAX_LENGTH);
if (!rt->tcurl) {
ret = AVERROR(ENOMEM);
goto fail;
}
ff_url_join(rt->tcurl, TCURL_MAX_LENGTH, proto, NULL, hostname,
port, "/%s", rt->app);
}
if (!rt->flashver) {
rt->flashver = av_malloc(FLASHVER_MAX_LENGTH);
if (!rt->flashver) {
ret = AVERROR(ENOMEM);
goto fail;
}
if (rt->is_input) {
snprintf(rt->flashver, FLASHVER_MAX_LENGTH, "%s %d,%d,%d,%d",
RTMP_CLIENT_PLATFORM, RTMP_CLIENT_VER1, RTMP_CLIENT_VER2,
RTMP_CLIENT_VER3, RTMP_CLIENT_VER4);
} else {
snprintf(rt->flashver, FLASHVER_MAX_LENGTH,
"FMLE/3.0 (compatible; %s)", LIBAVFORMAT_IDENT);
}
}
rt->client_report_size = 1048576;
rt->bytes_read = 0;
rt->last_bytes_read = 0;
rt->server_bw = 2500000;
av_log(s, AV_LOG_DEBUG, "Proto = %s, path = %s, app = %s, fname = %s\n",
proto, path, rt->app, rt->playpath);
if (!rt->listen) {
if ((ret = gen_connect(s, rt)) < 0)
goto fail;
} else {
if (read_connect(s, s->priv_data) < 0)
goto fail;
rt->is_input = 1;
}
do {
ret = get_packet(s, 1);
} while (ret == EAGAIN);
if (ret < 0)
goto fail;
if (rt->do_reconnect) {
ffurl_close(rt->stream);
rt->stream = NULL;
rt->do_reconnect = 0;
rt->nb_invokes = 0;
memset(rt->prev_pkt, 0, sizeof(rt->prev_pkt));
free_tracked_methods(rt);
goto reconnect;
}
if (rt->is_input) {
rt->flv_size = 13;
rt->flv_data = av_realloc(rt->flv_data, rt->flv_size);
rt->flv_off = 0;
memcpy(rt->flv_data, "FLV\1\5\0\0\0\011\0\0\0\0", rt->flv_size);
} else {
rt->flv_size = 0;
rt->flv_data = NULL;
rt->flv_off = 0;
rt->skip_bytes = 13;
}
s->max_packet_size = rt->stream->max_packet_size;
s->is_streamed = 1;
return 0;
fail:
av_dict_free(&opts);
rtmp_close(s);
return ret;
}
| 1threat
|
While Launching browser Second time in flow getting below Exception : **Listening on port 6942
Jul 23, 2018 12:50:22 PM org.openqa.selenium.os.UnixProcess checkForError
SEVERE: **org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
Exception in thread "main"** org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
| 0debug
|
Why does copying a >= 16 GB Numpy array set all its elements to 0? : <p>On my Anaconda Python distribution, copying a Numpy array that is exactly 16 GB or larger (regardless of dtype) sets all elements of the copy to 0:</p>
<pre><code>>>> np.arange(2 ** 31 - 1).copy() # works fine
array([ 0, 1, 2, ..., 2147483644, 2147483645,
2147483646])
>>> np.arange(2 ** 31).copy() # wait, what?!
array([0, 0, 0, ..., 0, 0, 0])
>>> np.arange(2 ** 32 - 1, dtype=np.float32).copy()
array([ 0.00000000e+00, 1.00000000e+00, 2.00000000e+00, ...,
4.29496730e+09, 4.29496730e+09, 4.29496730e+09], dtype=float32)
>>> np.arange(2 ** 32, dtype=np.float32).copy()
array([ 0., 0., 0., ..., 0., 0., 0.], dtype=float32)
</code></pre>
<p>Here is <code>np.__config__.show()</code> for this distribution:</p>
<pre><code>blas_opt_info:
library_dirs = ['/users/username/.anaconda3/lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['/users/username/.anaconda3/include']
libraries = ['mkl_rt', 'pthread']
lapack_opt_info:
library_dirs = ['/users/username/.anaconda3/lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['/users/username/.anaconda3/include']
libraries = ['mkl_rt', 'pthread']
mkl_info:
library_dirs = ['/users/username/.anaconda3/lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['/users/username/.anaconda3/include']
libraries = ['mkl_rt', 'pthread']
openblas_lapack_info:
NOT AVAILABLE
lapack_mkl_info:
library_dirs = ['/users/username/.anaconda3/lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['/users/username/.anaconda3/include']
libraries = ['mkl_rt', 'pthread']
blas_mkl_info:
library_dirs = ['/users/username/.anaconda3/lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['/users/username/.anaconda3/include']
libraries = ['mkl_rt', 'pthread']
</code></pre>
<p>For comparison, here is <code>np.__config__.show()</code> for my system Python distribution, which does not have this problem:</p>
<pre><code>blas_opt_info:
define_macros = [('HAVE_CBLAS', None)]
libraries = ['openblas', 'openblas']
language = c
library_dirs = ['/usr/local/lib']
openblas_lapack_info:
define_macros = [('HAVE_CBLAS', None)]
libraries = ['openblas', 'openblas']
language = c
library_dirs = ['/usr/local/lib']
openblas_info:
define_macros = [('HAVE_CBLAS', None)]
libraries = ['openblas', 'openblas']
language = c
library_dirs = ['/usr/local/lib']
lapack_opt_info:
define_macros = [('HAVE_CBLAS', None)]
libraries = ['openblas', 'openblas']
language = c
library_dirs = ['/usr/local/lib']
blas_mkl_info:
NOT AVAILABLE
</code></pre>
<p>I'm wondering if the MKL acceleration is the problem. I've reproduced the bug on both Python 2 and 3.</p>
| 0debug
|
my code keeps on giving me segfauls when I try to break it up into three smaller functions : I've tried passing the values by reference. the program reads a single line every time the function get_next_line is called and returns 1 if a line is found, 0 if a line is not found and -1 for other errors such as failed memory allocation. the code leaks but for now my main problem is breaking up the get_next_line function.
========================================================================
#include "get_next_line.h"
char *ft_strnew(size_t size)
{
char *str;
str = (char *)malloc(size + 1);
if (!str)
return (NULL);
str[strlen(str) + 1] = '\0';
return (str);
}
void *ft_memset(void *start, int init, size_t size)
{
unsigned char *ptr;
ptr = (unsigned char*)start;
while (size > 0)
{
*ptr++ = (unsigned char)init;
size--;
}
return (start);
}
void ft_bzero(void *s, size_t size)
{
ft_memset(s, '\0', size);
}
char *ft_strjoin(char const *s1, char const *s2)
{
char *new;
size_t len;
if (!s1 || !s2)
return (NULL);
len = strlen((char *)s1) + strlen((char *)s2);
new = (char *)malloc(len + 1);
if (!new)
return (NULL);
while (*s1 != '\0')
*new++ = *s1++;
while (*s2 != '\0')
*new++ = *s2++;
*new = '\0';
return (new - len);
}
char *ft_strdup(const char *str)
{
char *strdup;
int i;
strdup = (char *)malloc(strlen(str) + 1);
if (strdup == NULL)
return (NULL);
i = 0;
while (str[i] != '\0')
{
strdup[i] = str[i];
i++;
}
strdup[i] = '\0';
return (strdup);
}
static char *read_line(int f, int fd, char *buff, char *temp)
{
int i;
i = 0;
while (f > 0)
{
if (buff[i] == '\n'){
break;
}
else if (i == BUFF_SIZE)
{
f = read(fd, buff, BUFF_SIZE);
if (f == 0)
{
if (BUFF_SIZE == 1)
return (temp);
return ((char *)LINE_NOT_FOUND);
}
temp = ft_strjoin(temp, buff);
i = -1;
}
i++;
}
return (temp);
}
int get_next_line(const int fd, char **line)
{
static t_var var;
char buff[BUFF_SIZE + 1];
char *new;
int i;
int f = 0;
int s = 0;
int w = 0;
i = 0;
if (fd < 0 || line == NULL)
return (INVALID);
ft_bzero(buff, BUFF_SIZE + 1);
if (var.j > 0)
{
new = (char *)malloc(sizeof(char) * (var.j + 1));
if (!new)
return (INVALID);
s = strlen(var.temp) - var.j;
f = s;
w = var.j;
while (var.temp[s] != '\0')
{
new[i] = var.temp[s];
if (var.temp[s] == '\n')
{
if(!(*line = (char *)malloc(sizeof(char) * (i + 1))))
return (INVALID);
*line = strncpy(*line, new, i);
var.j--;
return (LINE_FOUND);
}
s++;
var.j--;
i++;
}
s = f;
var.temp = ft_strdup(new);
}//first read after this if statement
if (w == 0)
var.temp = ft_strnew(BUFF_SIZE);
f = read(fd, buff, BUFF_SIZE);
if (f == 0)
return (LINE_NOT_FOUND);
var.temp = ft_strjoin(var.temp, buff);
var.temp = read_line(f, fd, buff, var.temp);//function call
if (var.temp == (char *)LINE_NOT_FOUND)
return (0);
s = 0;
if (var.temp[s])
{
while (var.temp[s] != '\n')
s++;
}
s++;
if(var.j == 0)
*line = (char *)malloc(sizeof(char) * (s + 1));
*line = strncat(*line, var.temp, s - 1);
var.j = strlen(var.temp) - s;
return (LINE_FOUND);
}
#include <fcntl.h>
int main(int argc, char **argv)
{
int fd;
char *line;
int x = 1;
if (argc > 1)
{
fd = open(argv[1], O_RDONLY);
while (x == 1)
{
x = get_next_line(fd, &line);
if (x > 0)
printf("%s\n", line);
}
close(fd);
}
return (0);
| 0debug
|
Java program won't print out the smallest number in an array. : I'm trying to find the largest and smallest number in my array however, it only seems to print out the largest and not the smallest, I'm fairly new so all help is appreciated, thank you.
import java.util.Scanner;
public class Ex1 {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
int[] numbers = new int[11];
int largest = numbers[0];
int smallest = numbers[0];
System.out.println("Enter 10 numbers = ");
for (int i = 1; i < numbers.length; i++) {
numbers[i] = keyboard.nextInt();
System.out.println("Number " + i + " = " + numbers[i]);
for (int y = 1; y < numbers.length; y++) {
if (numbers[y] > largest)
{
largest = numbers[y];
}
}
for (int x = 1; x < numbers.length; x++)
{
if (numbers[x] < smallest)
{
smallest = numbers[x];
}
}
}
System.out.println("Largest number = " + largest);
System.out.println("Smallest number = " + smallest);
} // main
} // class
| 0debug
|
Create a folder and subfolder when selecting a cell in excel (VBA) : I am a total newbie in VBA so I hope you could help me with this.
I want to create a folder inside a given path. Inside the folder, I want a subfolder. The name of the folder will be indicated in column A and of the subfolder in column B of an excel worksheet. The path will be in column C.
[enter image description here][1]
I would like to be able to click on a cell on column D which would activate a macro who will then create the folder and subfolder. I was hoping to be able to achieve this by using this code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Target, Range("c2:c10000")) Is Nothing Then Call CreatePath
End Sub
So I need the function CreatePath. When a cell is selected on Column D, the CreatePath function should identify the row of the selected cell from column D, take from that row the corresponding name of the folder, subfolder and the path and create the folder and subfolder.
Any idea how this function should look like? Please keep in mind that I have started to "play" two days ago with VBA so my know-how is very limited.
Thank you all for your support.
[1]: https://i.stack.imgur.com/nOluY.png
| 0debug
|
How to delete a line from a text file with line break and copy the content to another file? : <p>What I need are:-</p>
<ol>
<li>delete a line from file <strong>with line break</strong>.</li>
<li>copy the content to another file.</li>
</ol>
<p>Assume the file content is as the following:-</p>
<pre><code>sometextsometextsometext
sometextsometextsometext
sometextsometextsometext
sometextsometextsometext
111111111
sometextsometextsometext
sometextsometextsometext
</code></pre>
<p>I wanna delete the line that contains <code>111111111</code> so I used the next code:-</p>
<pre><code>string content = File.ReadAllText(sOutputPathFileFrom);
content = content.Replace("111111111", "");
File.AppendAllText(sOutputPathFileTo, content);
</code></pre>
<p>The result of sOutputPathFileTo is as following:-</p>
<pre><code>sometextsometextsometext
sometextsometextsometext
sometextsometextsometext
sometextsometextsometext
sometextsometextsometext
sometextsometextsometext
</code></pre>
<p>The desired result is as next:-</p>
<pre><code>sometextsometextsometext
sometextsometextsometext
sometextsometextsometext
sometextsometextsometext
sometextsometextsometext
sometextsometextsometext
</code></pre>
<p>Note:-
<code>sOutputPathFileFrom</code> & <code>sOutputPathFileFrom</code> are variables carries the paths of from and to files.</p>
| 0debug
|
static const char *search_keyval(const TiffGeoTagKeyName *keys, int n, int id)
{
return ((TiffGeoTagKeyName*)bsearch(&id, keys, n, sizeof(keys[0]), cmp_id_key))->name;
}
| 1threat
|
static void ics_base_realize(DeviceState *dev, Error **errp)
{
ICSStateClass *icsc = ICS_BASE_GET_CLASS(dev);
ICSState *ics = ICS_BASE(dev);
Object *obj;
Error *err = NULL;
obj = object_property_get_link(OBJECT(dev), ICS_PROP_XICS, &err);
if (!obj) {
error_setg(errp, "%s: required link '" ICS_PROP_XICS "' not found: %s",
__func__, error_get_pretty(err));
return;
}
ics->xics = XICS_FABRIC(obj);
if (icsc->realize) {
icsc->realize(dev, errp);
}
}
| 1threat
|
Yet another web.py name collision : <p>I'm trying to make a simple Hello World web page in Python 3.7.4 and web.py <code>0.40-dev1</code> (which is supposed to be compatible) and I'm running into</p>
<blockquote>
<p>AttributeError: module 'web' has no attribute 'applications'</p>
</blockquote>
<p>error. I've googled enough to know that is a name collision, but for the love of God I can't trace it.</p>
<p>Here's the full code:</p>
<pre><code>import web
urls = (
'/', 'index'
)
application = web.applications(urls, globals())
class index:
def GET(self):
greeting = 'Hello world'
return greeting
if __name__ == "__main__":
application.run
</code></pre>
<p>And here's the full Python interpreter output:</p>
<pre><code>Traceback (most recent call last):
File "bin\app.py", line 7, in <module>
application = web.applications(urls, globals())
AttributeError: module 'web' has no attribute 'applications'
</code></pre>
| 0debug
|
Regex for any name : <p>I want regex with at least 2 characters start with any alphabet or any digit not matters.But It can accept - and _ .
Ex : ABD , Abc_123 , 12, A-_ , A1 etc.</p>
| 0debug
|
Python Remove Spanish Words : <p>I have a list of tokens such as <code>["Adiós", "John", "Salud", "Love"]</code> and my task is to delete the word if it is recognized as Spanish.</p>
<p>I have tried <code>enchant</code> and <code>polyglot</code> but they just cannot connect to <code>aspell</code>.</p>
<p>Are there any other easier modules or methods to detect Spanish words and delete them?</p>
<p>Thanks!</p>
| 0debug
|
how to summarise only numerical columns in R : <p>I want to have summary of only numerical columns of R dataframe. I am doing following</p>
<pre><code>numeric_var <- names(df)[which(sapply(df, is.numeric))]
summary(df[,.SD, .SDcols = numeric_var])
</code></pre>
<p>But, I get following error</p>
<pre><code>Error in `[.data.frame`(df, , .SD, .SDcols = numeric_var) :
unused argument (.SDcols = numeric_var)
</code></pre>
<p>How can I do it in R?</p>
| 0debug
|
multiplying a decimal by a floating point number : <p>Im trying to get 75% of the CTotal but as it is a decimal number it is rounding 0.75 to 0, does anyone know of a work around </p>
<pre><code> decimal refundtot = order.CTotal;
//change it as it is making it = 0
refundtot = (75 / 100) * refundtot;
refund.RefundTotal = refundtot;
</code></pre>
| 0debug
|
Oracle Perfromance Tuning : I need some help with wildcard search with % operator at both ends. The no of records are nearly 7 million.
Is there any option to setup an index for this. I already created an index of index type CTXSYS which works well for single % operator at one end.
Please help.
| 0debug
|
int vnc_tls_set_x509_creds_dir(VncDisplay *vd,
const char *certdir)
{
if (vnc_set_x509_credential(vd, certdir, X509_CA_CERT_FILE, &vd->tls.x509cacert, 0) < 0)
goto cleanup;
if (vnc_set_x509_credential(vd, certdir, X509_CA_CRL_FILE, &vd->tls.x509cacrl, 1) < 0)
goto cleanup;
if (vnc_set_x509_credential(vd, certdir, X509_SERVER_CERT_FILE, &vd->tls.x509cert, 0) < 0)
goto cleanup;
if (vnc_set_x509_credential(vd, certdir, X509_SERVER_KEY_FILE, &vd->tls.x509key, 0) < 0)
goto cleanup;
return 0;
cleanup:
g_free(vd->tls.x509cacert);
g_free(vd->tls.x509cacrl);
g_free(vd->tls.x509cert);
g_free(vd->tls.x509key);
vd->tls.x509cacert = vd->tls.x509cacrl = vd->tls.x509cert = vd->tls.x509key = NULL;
return -1;
}
| 1threat
|
python - sum of cubes using formula : How to compute the sum of cubes of first 100 integers in Python using formula
\frac{n^2(n+1)^2}{4}.
I've tried
s=0
for n in range (0,1001):
s+=(int)((n*(n+1))/2)**2
print("Sum is:",s)
but it does not seem to work.
Thank you for your time!
| 0debug
|
query = 'SELECT * FROM customers WHERE email = ' + email_input
| 1threat
|
How to use HttpClientBuilder with Http proxy? : <p>I am trying to set proxy for a request I am making using <code>HttpClientBuilder</code> as follows:</p>
<pre><code> CredentialsProvider credsProvider = new BasicCredentialsProvider();
UsernamePasswordCredentials usernamePasswordCredentials = new UsernamePasswordCredentials(proxyUser, proxyPassword);
credsProvider.setCredentials(new AuthScope(proxyHost, proxyPort), usernamePasswordCredentials);
builder.useSystemProperties();
builder.setProxy(new HttpHost(proxyHost, proxyPort));
builder.setDefaultCredentialsProvider(credsProvider);
builder.setProxyAuthenticationStrategy(new ProxyAuthenticationStrategy());
</code></pre>
<p>where builder is:</p>
<pre><code> HttpClientBuilder builder = HttpClientBuilder.create();
</code></pre>
<p>However, I get this exception when I execute this request:</p>
<pre><code>java.lang.RuntimeException: org.apache.http.conn.UnsupportedSchemeException: http protocol is not supported
Caused by: org.apache.http.conn.UnsupportedSchemeException: http protocol is not supported
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:108) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.conn.BasicHttpClientConnectionManager.connect(BasicHttpClientConnectionManager.java:338) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:388) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55) ~[httpclient-4.5.1.jar:4.5.1]
</code></pre>
<p>(exception shortened for brevity)</p>
<p>Since this is an HTTP proxy, I don't want to change the scheme to HTTPS, which anyways won't work. How do I get this working?</p>
| 0debug
|
How can i get some data in 'onActivityResult'? : in my app, i use default album app for get image.
select image, i set that image at imageview in gridView.
public void getImageFromAlbum(int position){
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType(MediaStore.Images.Media.CONTENT_TYPE);
startActivityForResult(intent, PICK_IMAGE_FROM_ALBUM);
}
i need 'position' value in onActivityResult!
if i use my custom activity, i use putExtra. but this case, it cant.
i think position value save class value. it will be run, but i dont want it...
| 0debug
|
static inline void RENAME(hyscale)(uint16_t *dst, long dstWidth, uint8_t *src, int srcW, int xInc,
int flags, int canMMX2BeUsed, int16_t *hLumFilter,
int16_t *hLumFilterPos, int hLumFilterSize, void *funnyYCode,
int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,
int32_t *mmx2FilterPos)
{
if(srcFormat==IMGFMT_YUY2)
{
RENAME(yuy2ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_UYVY)
{
RENAME(uyvyToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_BGR32)
{
RENAME(bgr32ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_BGR24)
{
RENAME(bgr24ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_BGR16)
{
RENAME(bgr16ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_BGR15)
{
RENAME(bgr15ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_RGB32)
{
RENAME(rgb32ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_RGB24)
{
RENAME(rgb24ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
#ifdef HAVE_MMX
if(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed))
#else
if(!(flags&SWS_FAST_BILINEAR))
#endif
{
RENAME(hScale)(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize);
}
else
{
#if defined(ARCH_X86) || defined(ARCH_X86_64)
#ifdef HAVE_MMX2
int i;
if(canMMX2BeUsed)
{
asm volatile(
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
#ifdef ARCH_X86_64
#define FUNNY_Y_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"movl (%%"REG_b", %%"REG_a"), %%esi\n\t"\
"add %%"REG_S", %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#else
#define FUNNY_Y_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"addl (%%"REG_b", %%"REG_a"), %%"REG_c"\n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#endif
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
:: "m" (src), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos),
"m" (funnyYCode)
: "%"REG_a, "%"REG_b, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
);
for(i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) dst[i] = src[srcW-1]*128;
}
else
{
#endif
long xInc_shr16 = xInc >> 16;
uint16_t xInc_mask = xInc & 0xffff;
asm volatile(
"xor %%"REG_a", %%"REG_a" \n\t"
"xor %%"REG_b", %%"REG_b" \n\t"
"xorl %%ecx, %%ecx \n\t"
ASMALIGN16
"1: \n\t"
"movzbl (%0, %%"REG_b"), %%edi \n\t"
"movzbl 1(%0, %%"REG_b"), %%esi \n\t"
"subl %%edi, %%esi \n\t" - src[xx]
"imull %%ecx, %%esi \n\t"
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, (%%"REG_D", %%"REG_a", 2)\n\t"
"addw %4, %%cx \n\t"
"adc %3, %%"REG_b" \n\t"
"movzbl (%0, %%"REG_b"), %%edi \n\t"
"movzbl 1(%0, %%"REG_b"), %%esi \n\t"
"subl %%edi, %%esi \n\t" - src[xx]
"imull %%ecx, %%esi \n\t"
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, 2(%%"REG_D", %%"REG_a", 2)\n\t"
"addw %4, %%cx \n\t"
"adc %3, %%"REG_b" \n\t"
"add $2, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (src), "m" (dst), "m" (dstWidth), "m" (xInc_shr16), "m" (xInc_mask)
: "%"REG_a, "%"REG_b, "%ecx", "%"REG_D, "%esi"
);
#ifdef HAVE_MMX2
}
#endif
#else
int i;
unsigned int xpos=0;
for(i=0;i<dstWidth;i++)
{
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha;
xpos+=xInc;
}
#endif
}
}
| 1threat
|
how do i return values of variables from a function in python 2.7 : https://www.dropbox.com/s/ws6fofpexdi382a/rpg.py?dl=0
^above is the code: I don't know how to put the code in the question: i tried for an hour^
in the above code, there is a function called clas(). in that function, there are 8 variables about the player and ai stats. I want those variables to copy to the variables at lines 10-18, but im not sure how. any help is appreciated.
| 0debug
|
Module parse failed: Parenthesized pattern You may need an appropriate loader to handle this file type : <p>I have created a brand new angular 2 application using these commands: </p>
<pre><code>ng init
ng server
</code></pre>
<p>I get this error output: </p>
<pre><code>chunk {1} styles.bundle.js, styles.bundle.map (styles) 9.96 kB {3} [initial] [rendered]
chunk {2} vendor.bundle.js, vendor.bundle.map (vendor) 2.65 MB [initial] [rendered]
chunk {3} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] [rendered]
ERROR in ./~/@angular/core/src/util/decorators.js
Module parse failed: /Users/nikolaschou/Dev/coziv/sandbox01/blockhowapp/temp/node_modules/@angular/core/src/util/decorators.js Parenthesized pattern (156:12)
You may need an appropriate loader to handle this file type.
|if (clsDef.hasOwnProperty('extends')) {
| if (typeof clsDef.extends === 'function') {
</code></pre>
<p>Can anyone explain why I might get this error? I see a lot of similar errors reported, but not exactly this variation. </p>
<p><strong>More details</strong></p>
<p>I can say that ng serve works well from another angular-2 application folder on the same machine and I have compared these two folders but don't see any obvious differences that can explain this behavior. </p>
<p>I use a Mac with latest iOS and this is the output from ng --version: </p>
<pre><code>angular-cli: 1.0.0-beta.26
node: 6.6.0
os: darwin x64
@angular/common: 2.4.5
@angular/compiler: 2.4.5
@angular/core: 2.4.5
@angular/forms: 2.4.5
@angular/http: 2.4.5
@angular/platform-browser: 2.4.5
@angular/platform-browser-dynamic: 2.4.5
@angular/router: 3.4.5
@angular/compiler-cli: 2.4.5
</code></pre>
| 0debug
|
Javascript- Uncaught SyntaxError: Unexpected token if : I'm new to Javascript!
if (fname == null || fname == "") {
Getting uncaught syntax error:unexpected token if in line 13. It says "SyntaxError: missing variable name" in Javascript lint
function validateregistration()
{
var emailRegex = /^[A-Za-z0-9._]*\@[A-Za-z]*\.[A-Za-z]{2,5}$/;
var fname = document.form.user_firstname.value,
lname = document.form.user_lastname.value,
uname = document.form.username.value,
femail = document.form.email.value,
freemail = document.form.verify_email.value,
fpassword = document.form.password.value,
if (fname == null || fname == "") {
document.form.user_firstname.focus();
document.getElementById("errorBox")
.innerHTML = "enter the first name";
return false;
}
if (lname == null || lname == "") {
document.form.user_lastname.focus();
document.getElementById("errorBox")
.innerHTML = "enter the last name";
return false;
}
if (femail == null || femail == "") {
document.form.email.focus();
document.getElementById("errorBox")
.innerHTML = "enter the email";
return false;
} else if (!emailRegex.test(femail)) {
document.form.Email.focus();
document.getElementById("errorBox")
.innerHTML = "enter the valid email";
return false;
}
if (freemail == null || freemail == "") {
document.form.verify_email.focus();
document.getElementById("errorBox")
.innerHTML = "Re-enter the email";
return false;
} else if (!emailRegex.test(freemail)) {
document.form.enterEmail.focus();
document.getElementById("errorBox")
.innerHTML = "Re-enter the valid email";
return false;
}
if (fpassword == null || fpassword == "") {
document.form.password.focus();
document.getElementById("errorBox")
.innerHTML = "enter the password";
return false;
}
}
| 0debug
|
static int ioreq_runio_qemu_aio(struct ioreq *ioreq)
{
struct XenBlkDev *blkdev = ioreq->blkdev;
if (ioreq->req.nr_segments && ioreq_map(ioreq) == -1) {
goto err_no_map;
}
ioreq->aio_inflight++;
if (ioreq->presync) {
bdrv_aio_flush(ioreq->blkdev->bs, qemu_aio_complete, ioreq);
return 0;
}
switch (ioreq->req.operation) {
case BLKIF_OP_READ:
block_acct_start(bdrv_get_stats(blkdev->bs), &ioreq->acct,
ioreq->v.size, BLOCK_ACCT_READ);
ioreq->aio_inflight++;
bdrv_aio_readv(blkdev->bs, ioreq->start / BLOCK_SIZE,
&ioreq->v, ioreq->v.size / BLOCK_SIZE,
qemu_aio_complete, ioreq);
break;
case BLKIF_OP_WRITE:
case BLKIF_OP_FLUSH_DISKCACHE:
if (!ioreq->req.nr_segments) {
break;
}
block_acct_start(bdrv_get_stats(blkdev->bs), &ioreq->acct,
ioreq->v.size, BLOCK_ACCT_WRITE);
ioreq->aio_inflight++;
bdrv_aio_writev(blkdev->bs, ioreq->start / BLOCK_SIZE,
&ioreq->v, ioreq->v.size / BLOCK_SIZE,
qemu_aio_complete, ioreq);
break;
case BLKIF_OP_DISCARD:
{
struct blkif_request_discard *discard_req = (void *)&ioreq->req;
ioreq->aio_inflight++;
bdrv_aio_discard(blkdev->bs,
discard_req->sector_number, discard_req->nr_sectors,
qemu_aio_complete, ioreq);
break;
}
default:
goto err;
}
qemu_aio_complete(ioreq, 0);
return 0;
err:
ioreq_unmap(ioreq);
err_no_map:
ioreq_finish(ioreq);
ioreq->status = BLKIF_RSP_ERROR;
return -1;
}
| 1threat
|
Slirp *slirp_init(int restricted, struct in_addr vnetwork,
struct in_addr vnetmask, struct in_addr vhost,
const char *vhostname, const char *tftp_path,
const char *bootfile, struct in_addr vdhcp_start,
struct in_addr vnameserver, void *opaque)
{
Slirp *slirp = qemu_mallocz(sizeof(Slirp));
slirp_init_once();
slirp->restricted = restricted;
if_init(slirp);
ip_init(slirp);
m_init(slirp);
slirp->vnetwork_addr = vnetwork;
slirp->vnetwork_mask = vnetmask;
slirp->vhost_addr = vhost;
if (vhostname) {
pstrcpy(slirp->client_hostname, sizeof(slirp->client_hostname),
vhostname);
}
if (tftp_path) {
slirp->tftp_prefix = qemu_strdup(tftp_path);
}
if (bootfile) {
slirp->bootp_filename = qemu_strdup(bootfile);
}
slirp->vdhcp_startaddr = vdhcp_start;
slirp->vnameserver_addr = vnameserver;
slirp->opaque = opaque;
register_savevm("slirp", 0, 3, slirp_state_save, slirp_state_load, slirp);
TAILQ_INSERT_TAIL(&slirp_instances, slirp, entry);
return slirp;
}
| 1threat
|
How does `() -> delegate` wrap a Stream? : <p>Not sure how to write the question, but I saw the following construct in <a href="https://stackoverflow.com/a/45971597/242042">https://stackoverflow.com/a/45971597/242042</a></p>
<pre><code>public interface MyStream<T> {
Stream<T> stream();
static <T> MyStream<T> of(Stream<T> stream) {
return () -> stream;
}
}
</code></pre>
<p>Which I used in my answer <a href="https://softwareengineering.stackexchange.com/a/400492/42195">https://softwareengineering.stackexchange.com/a/400492/42195</a></p>
<p>The <code>of</code> method returns a Callable that returns the delegate stream. But how did that even translate to <code><T> MyStream <T></code> ?</p>
| 0debug
|
ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend,
Error **errp)
{
ChardevReturn *ret = g_new0(ChardevReturn, 1);
CharDriverState *base, *chr = NULL;
chr = qemu_chr_find(id);
if (chr) {
error_setg(errp, "Chardev '%s' already exists", id);
g_free(ret);
return NULL;
}
switch (backend->kind) {
case CHARDEV_BACKEND_KIND_FILE:
chr = qmp_chardev_open_file(backend->file, errp);
break;
case CHARDEV_BACKEND_KIND_SERIAL:
chr = qmp_chardev_open_serial(backend->serial, errp);
break;
case CHARDEV_BACKEND_KIND_PARALLEL:
chr = qmp_chardev_open_parallel(backend->parallel, errp);
break;
case CHARDEV_BACKEND_KIND_SOCKET:
chr = qmp_chardev_open_socket(backend->socket, errp);
break;
#ifdef HAVE_CHARDEV_TTY
case CHARDEV_BACKEND_KIND_PTY:
{
QemuOpts *opts;
opts = qemu_opts_create_nofail(qemu_find_opts("chardev"));
chr = qemu_chr_open_pty(opts);
ret->pty = g_strdup(qemu_opt_get(opts, "path"));
ret->has_pty = true;
qemu_opts_del(opts);
break;
}
#endif
case CHARDEV_BACKEND_KIND_NULL:
chr = qemu_chr_open_null();
break;
case CHARDEV_BACKEND_KIND_MUX:
base = qemu_chr_find(backend->mux->chardev);
if (base == NULL) {
error_setg(errp, "mux: base chardev %s not found",
backend->mux->chardev);
break;
}
chr = qemu_chr_open_mux(base);
break;
case CHARDEV_BACKEND_KIND_MSMOUSE:
chr = qemu_chr_open_msmouse();
break;
#ifdef CONFIG_BRLAPI
case CHARDEV_BACKEND_KIND_BRAILLE:
chr = chr_baum_init();
break;
#endif
case CHARDEV_BACKEND_KIND_STDIO:
chr = qemu_chr_open_stdio(backend->stdio);
break;
default:
error_setg(errp, "unknown chardev backend (%d)", backend->kind);
break;
}
if (chr == NULL && !error_is_set(errp)) {
error_setg(errp, "Failed to create chardev");
}
if (chr) {
chr->label = g_strdup(id);
chr->avail_connections =
(backend->kind == CHARDEV_BACKEND_KIND_MUX) ? MAX_MUX : 1;
QTAILQ_INSERT_TAIL(&chardevs, chr, next);
return ret;
} else {
g_free(ret);
return NULL;
}
}
| 1threat
|
Why can't i see true or false in console : <p>I've wroten a bIt code and I got help a bit. I thing code is working correctly but I can't see true or false In the console why? it should give one of them(true or false). Maybe i'm calling method a wrong way. Could you please explain where am i doing wrong.</p>
<pre><code>public static void main(String[] args) {
int[][] array = new int[4][4];
Scanner input = new Scanner(System.in);
System.out.println("enter a number");
for(int i =0; i<array.length; i++)
{
for(int j=0; j<array[i].length; j++ )
{
array[i][j] = input.nextInt();
}
}
for(int[] rad : array)
{
for(int column: rad)
{
System.out.print(column+" ");
}
System.out.println();
}
symetrisk(array);
}
public static boolean symetrisk(int[][] f){
for (int out = 0; out < f.length; out++) {
for (int in = 0; in < f[out].length; in++) {
if (f.length != f[out].length || (f[out][in] != f[in][out])) {
return false;
}
}
}
return true;
}
</code></pre>
<p>}</p>
| 0debug
|
can we extract only year in the string "04.07.2019 16:56:21" without using for loop? : <p>I am trying to extract the year from a date and time string something like "04.07.2019 16:56:21". Can I extract only year without using for loop in batch script?</p>
| 0debug
|
Would it be possible to convert a NodeJS function to plain Javascript : <p>Im currently playing with the following thing: <a href="http://cgbystrom.com/articles/deconstructing-spotifys-builtin-http-server/" rel="nofollow">http://cgbystrom.com/articles/deconstructing-spotifys-builtin-http-server/</a>, I want to be able to access the SpotifyWebHelper with Javascript, people have build this in NodeJS but I wonder if this is possible in plain JavaScript. Can anyone give me some pointers to start with? Or is this not possible at all?</p>
<p>NodeJS version:
<a href="https://github.com/onetune/spotify-web-helper/blob/master/index.js" rel="nofollow">https://github.com/onetune/spotify-web-helper/blob/master/index.js</a></p>
| 0debug
|
Does pandas need to close connection? : <p>When using pandas "read_sql_query", do I need to close the connection? Or should I use a "with" statement? Or can I just use the following and be good?</p>
<pre><code>from sqlalchemy import create_engine
import pandas as pd
sql = """
SELECT * FROM Table_Name;
"""
engine = create_engine('blah')
df = pd.read_sql_query(sql, engine)
print df.head()
</code></pre>
| 0debug
|
void parse_options(int argc, char **argv, const OptionDef *options,
void (* parse_arg_function)(const char*))
{
const char *opt, *arg;
int optindex, handleoptions=1;
const OptionDef *po;
optindex = 1;
while (optindex < argc) {
opt = argv[optindex++];
if (handleoptions && opt[0] == '-' && opt[1] != '\0') {
int bool_val = 1;
if (opt[1] == '-' && opt[2] == '\0') {
handleoptions = 0;
continue;
}
opt++;
po= find_option(options, opt);
if (!po->name && opt[0] == 'n' && opt[1] == 'o') {
po = find_option(options, opt + 2);
if (!(po->name && (po->flags & OPT_BOOL)))
goto unknown_opt;
bool_val = 0;
}
if (!po->name)
po= find_option(options, "default");
if (!po->name) {
unknown_opt:
fprintf(stderr, "%s: unrecognized option '%s'\n", argv[0], opt);
exit(1);
}
arg = NULL;
if (po->flags & HAS_ARG) {
arg = argv[optindex++];
if (!arg) {
fprintf(stderr, "%s: missing argument for option '%s'\n", argv[0], opt);
exit(1);
}
}
if (po->flags & OPT_STRING) {
char *str;
str = av_strdup(arg);
*po->u.str_arg = str;
} else if (po->flags & OPT_BOOL) {
*po->u.int_arg = bool_val;
} else if (po->flags & OPT_INT) {
*po->u.int_arg = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX);
} else if (po->flags & OPT_INT64) {
*po->u.int64_arg = parse_number_or_die(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX);
} else if (po->flags & OPT_FLOAT) {
*po->u.float_arg = parse_number_or_die(opt, arg, OPT_FLOAT, -1.0/0.0, 1.0/0.0);
} else if (po->flags & OPT_FUNC2) {
if(po->u.func2_arg(opt, arg)<0)
goto unknown_opt;
} else {
po->u.func_arg(arg);
}
if(po->flags & OPT_EXIT)
exit(0);
} else {
if (parse_arg_function)
parse_arg_function(opt);
}
}
}
| 1threat
|
Clojure: Unable to find static field : <p>Given the following piece of code:</p>
<pre><code>(map Integer/parseInt ["1" "2" "3" "4"])
</code></pre>
<p>Why do I get the following exception unless I wrap <code>Integer/parseInt</code> in an anonymous function and call it manually (<code>#(Integer/parseInt %)</code>)?</p>
<pre><code>clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to find static field: parseInt in class java.lang.Integer
</code></pre>
| 0debug
|
static void do_video_out(AVFormatContext *s,
AVOutputStream *ost,
AVInputStream *ist,
AVPicture *picture1)
{
int n1, n2, nb, i, ret, frame_number;
AVPicture *picture, *picture2, *pict;
AVPicture picture_tmp1, picture_tmp2;
UINT8 video_buffer[128*1024];
UINT8 *buf = NULL, *buf1 = NULL;
AVCodecContext *enc, *dec;
enc = &ost->st->codec;
dec = &ist->st->codec;
frame_number = ist->frame_number;
n1 = ((INT64)frame_number * enc->frame_rate) / dec->frame_rate;
n2 = (((INT64)frame_number + 1) * enc->frame_rate) / dec->frame_rate;
nb = n2 - n1;
if (nb <= 0)
return;
if (do_deinterlace) {
int size;
size = avpicture_get_size(dec->pix_fmt, dec->width, dec->height);
buf1 = malloc(size);
if (!buf1)
return;
picture2 = &picture_tmp2;
avpicture_fill(picture2, buf1, dec->pix_fmt, dec->width, dec->height);
if (avpicture_deinterlace(picture2, picture1,
dec->pix_fmt, dec->width, dec->height) < 0) {
free(buf1);
buf1 = NULL;
picture2 = picture1;
}
} else {
picture2 = picture1;
}
if (enc->pix_fmt != dec->pix_fmt) {
int size;
size = avpicture_get_size(enc->pix_fmt, dec->width, dec->height);
buf = malloc(size);
if (!buf)
return;
pict = &picture_tmp1;
avpicture_fill(pict, buf, enc->pix_fmt, dec->width, dec->height);
if (img_convert(pict, enc->pix_fmt,
picture2, dec->pix_fmt,
dec->width, dec->height) < 0) {
fprintf(stderr, "pixel format conversion not handled\n");
goto the_end;
}
} else {
pict = picture2;
}
if (ost->video_resample) {
picture = &ost->pict_tmp;
img_resample(ost->img_resample_ctx, picture, pict);
} else {
picture = pict;
}
for(i=0;i<nb;i++) {
if (enc->codec_id != CODEC_ID_RAWVIDEO) {
if (same_quality) {
enc->quality = dec->quality;
}
ret = avcodec_encode_video(enc,
video_buffer, sizeof(video_buffer),
picture);
s->format->write_packet(s, ost->index, video_buffer, ret);
} else {
write_picture(s, ost->index, picture, enc->pix_fmt, enc->width, enc->height);
}
}
the_end:
if (buf)
free(buf);
if (buf1)
free(buf1);
}
| 1threat
|
What is the best way to execute form submission? : <p>Please excuse any ignorant or ametuer perspective that I may seem to have. I am indeed an aspiring web developer :)</p>
<p>The only thing that I need to achieve right now is having the user fill out a form with only two fields and have that information end up in my inbox.</p>
<p>After much searching and different solutions/opinions from a WIDE variety of sources and dev types, I still cannot seem to find a step by step process of how to best implement this seemingly simple issue I'm having. </p>
<p>Now, I'm willing to learn what I may need to, but I have no idea where to start. I've been told PHP, Django(Python), JavaScript and a whole slew of others.</p>
<p>I can build the form with out an issue. It's getting that information to my email that I'm stuck on!</p>
<p>Any and all feedback is much appreciated. Thank you!</p>
| 0debug
|
Merging a feature branch that is based off another feature branch : <p>A few days ago I had a <code>master</code> branch with a completely linear history. Then I created a feature branch, which we'll call <code>feat/feature-a</code>. I worked on that branch, then submitted it for code review to be merged into <code>master</code>.</p>
<p>While <code>feat/feature-a</code> was being reviewed, I wanted to work on another feature that relied on some code introduced by <code>feat/feature-a</code>. So I created a <code>feat/feature-b</code> branch from the <code>feat/feature-a</code> branch.</p>
<p>While I was working on <code>feat/feature-b</code>, <code>feat/feature-a</code> got merged into master. So now master has the code introduced by <code>feat/feature-a</code>. I now want to merge <code>feat/feature-b</code> into master, but I get a lot of merge conflicts that look like this:</p>
<pre><code><<<<<<< HEAD
=======
// Some code that was introduced by feat/feature-b
>>>>>>> c948094... My commit message from feat/feature-b
</code></pre>
<p>My guess is that because I took <code>feat/feature-a</code> changes into my <code>feat/feature-b</code> branch, I'm now trying to "duplicate" those changes which is ending in merge conflicts.</p>
<p>I can resolve these manually, but they exist multiple times over tens of files, so I'd like to know a better solution if there is one.</p>
| 0debug
|
static int g726_init(AVCodecContext * avctx)
{
AVG726Context* c = (AVG726Context*)avctx->priv_data;
if (avctx->sample_rate != 8000 || avctx->channels != 1 ||
(avctx->bit_rate != 16000 && avctx->bit_rate != 24000 &&
avctx->bit_rate != 32000 && avctx->bit_rate != 40000)) {
av_log(avctx, AV_LOG_ERROR, "G726: unsupported audio format\n");
return -1;
}
g726_reset(&c->c, avctx->bit_rate);
c->code_size = c->c.tbls->bits;
c->bit_buffer = 0;
c->bits_left = 0;
return 0;
}
| 1threat
|
mysql fetch row and undefined variable error : I keep getting the following errors. The $query produces a 1300 result list. When I echo $query I get the mysql statement.
[25-Aug-2016 21:38:32 America/New_York] PHP Warning: mysql_fetch_row() expects parameter 1 to be resource, null given in song.php on line 285
[25-Aug-2016 21:38:32 America/New_York] PHP Notice: Undefined variable: song_hash in song.php on line 292
$query = "select " . $query_data . " from " . $query_tables . " where " . $query_where;
//echo $query;
$result = mysql_query($query,$database);
while($row = mysql_fetch_row($result)){
$key = $row[0];
$song_hash[$key] = ($song_hash[$key] + 1);
}
$largest = max($song_hash);
| 0debug
|
static void gen_rfe(DisasContext *s, TCGv pc, TCGv cpsr)
{
gen_set_cpsr(cpsr, 0xffffffff);
dead_tmp(cpsr);
store_reg(s, 15, pc);
s->is_jmp = DISAS_UPDATE;
}
| 1threat
|
inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth, const uint8_t *src1, const uint8_t *src2,
int srcW, int xInc, const int16_t *hChrFilter,
const int16_t *hChrFilterPos, int hChrFilterSize,
uint8_t *formatConvBuffer,
uint32_t *pal)
{
src1 += c->chrSrcOffset;
src2 += c->chrSrcOffset;
if (c->chrToYV12) {
c->chrToYV12(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
src1= formatConvBuffer;
src2= formatConvBuffer+VOFW;
}
if (c->hScale16) {
c->hScale16(dst , dstWidth, (uint16_t*)src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize, av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1);
c->hScale16(dst+VOFW, dstWidth, (uint16_t*)src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize, av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1);
} else if (!c->hcscale_fast) {
c->hScale(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
c->hScale(dst+VOFW, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
} else {
c->hcscale_fast(c, dst, dstWidth, src1, src2, srcW, xInc);
}
if (c->chrConvertRange)
c->chrConvertRange(dst, dstWidth);
}
| 1threat
|
What is the maximum size of 2 dimensional array that we can use in c++ programming? : <p>I tried using 10^6 by 10^6 array ,it is giving me segmentation fault </p>
| 0debug
|
Why is Python unable to retrieve value of an environment variable even though that variable has value when tested via bash? : <p>I want to use a value from an environment variable. I have set it in the <code>~/.bashrc</code> file and I am able to see that in the new shells and in the current shell(obviously, after <code>source</code>ing it). However, when I import the same variable in Python3 shell(both in the existing and in the new shells), the value returned is always <code>None</code>.</p>
<p>I read a lot and found a <a href="https://stackoverflow.com/questions/31993885/why-cant-python-see-environment-variables">relatable answer</a> but it did not solve my problem or rather, I could not understand it.</p>
<p>My bashrc file is:</p>
<pre><code>SLACK_URL="https://hooks.slack.com/"
</code></pre>
<p>I am able to see the value in the terminal but not in the Python shell:</p>
<pre><code>ubuntu@ip-A.B.C.D:~$ echo $SLACK_URL
https://hooks.slack.com/
ubuntu@ip-A.B.C.D:~$ python3
Python 3.6.8 (default, Jan 14 2019, 11:02:34)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.getenv('SLACK_URL')
>>>
</code></pre>
<p>I expect to see the actual variable's value but instead I am getting <code>None</code>.</p>
| 0debug
|
i am doing CRUD Operation i Angular using WebApi :
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
employee.component.ts
import { Component, OnInit } from "@angular/core";
import { EmployeeService } from "../Shared/employee.service";
import { NgForm } from "@angular/forms";
@Component({
selector: "app-employe",
templateUrl: "./employe.component.html",
styleUrls: ["./employe.component.css"]
})
export class EmployeComponent implements OnInit {
constructor(private employeeService: EmployeeService) {}
ngOnInit() {
this.resetForm();
}
resetForm(form?: NgForm) {
if (form != null) form.reset();
this.employeeService.SelectedEmployee = {
EmpId: null,
FirstName: "",
LastName: "",
EmpCode: "",
Position: "",
Office: ""
};
}
onSubmit(form ?:NgForm){
this.employeeService.postEmployee(form.value).subscribe(data =>{
this.resetForm(form);
})
}
}
Employee.service.ts
import { Injectable } from "@angular/core";
import { Employee } from "./employee.model";
import {
Http,
Response,
Headers,
RequestOptions,
RequestMethod
} from "@angular/http";
import { Observable } from "rxjs/Observable";
import 'rxjs/add/operator/map';
import "rxjs/add/operator/toPromise";
import 'rxjs/add/operator/catch';
import { map } from 'rxjs/operators';
import 'rxjs/add/operator/map';
@Injectable({
providedIn: "root"
})
export class EmployeeService {
SelectedEmployee: Employee;
constructor(private http: Http) {}
postEmployee(emp : Employee){
var body = JSON.stringify(emp);
var headerOptions = new Headers({'Content-Type':'application/json'});
var requestOptions = new RequestOptions({method : RequestMethod.Post,headers : headerOptions});
return this.http.post('http://localhost:3184/api/Emp',body,requestOptions).map(x => x.json());
}
}
<!-- language: lang-html -->
<form class="emp-form" #employeForm="ngForm" >
<input type="hidden" name="EmployeeID" #EmployeeID="ngModel" [(ngModel)]="employeeService.SelectedEmployee.EmpID">
<div class="form-row">
<div class="form-group col-md-6">
<input class="form-control" name="FirstName" #FirstName="ngModel" [(ngModel)]="employeeService.SelectedEmployee.FirstName"
placeholder="First Name" required>
<div class="validation-error" *ngIf="FirstName.invalid && FirstName.touched">This Field is Required.</div>
</div>
<div class="form-group col-md-6">
<input class="form-control" name="LastName" #LastName="ngModel" [(ngModel)]="employeeService.SelectedEmployee.LastName" placeholder="Last Name"
required>
<div class="validation-error" *ngIf="LastName.invalid && LastName.touched">This Field is Required.</div>
</div>
</div>
<div class="form-group">
<input class="form-control" name="Position" #Position="ngModel" [(ngModel)]="employeeService.SelectedEmployee.Position" placeholder="Position">
</div>
<div class="form-row">
<div class="form-group col-md-6">
<input class="form-control" name="EmpCode" #EmpCode="ngModel" [(ngModel)]="employeeService.SelectedEmployee.EmpCode" placeholder="Emp Code">
</div>
<div class="form-group col-md-6">
<input class="form-control" name="Office" #Office="ngModel" [(ngModel)]="employeeService.SelectedEmployee.Office" placeholder="Office">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-8">
<button [disabled]="!employeForm.valid" type="submit" class="btn btn-lg btn-block btn-info" (click)="onSubmit(employeForm)">
<i class="fa fa-floppy-o"></i> Submit</button>
</div>
<div class="form-group col-md-4">
<button type="button" class="btn btn-lg btn-block btn-secondary" (click)="resetForm(employeForm)">
<i class="fa fa-repeat"></i> Reset</button>
</div>
</div>
</form>
<!-- end snippet -->
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using System.Web.Http.Cors;
namespace WebDemo
{
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
config.EnableCors(new EnableCorsAttribute("http://localhost:4200", headers: "*", methods: "*"));
// methods:'Access-Control-Request-Method',
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
}
<!-- end snippet -->
Here i tried to use Post Data on SqlServer on Button Press and its gives me
> Failed to load resource: the server responded with a status of 400 (Bad Request)
localhost/:1 Access to XMLHttpRequest at 'http://localhost:3184/api/Emp' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Plz help me to resolve thanks in advance i used the reference[enter link description here][1]
[1]: http://www.codaffection.com/angular-5-tutorial/angular-5-with-web-api-crud-application/
| 0debug
|
static int local_open2(FsContext *ctx, const char *path, int flags, mode_t mode)
{
return open(rpath(ctx, path), flags, mode);
}
| 1threat
|
Google Cloud API - Application Default Credentials : <p>I have the following code, modified from <a href="https://developers.google.com/identity/protocols/application-default-credentials" rel="noreferrer">Google's documentation</a>:</p>
<pre><code> $GOOGLE_APPLICATION_CREDENTIALS = "./[path].json";
$_ENV["GOOGLE_APPLICATION_CREDENTIALS"] = "./[path].json";
$_SERVER["GOOGLE_APPLICATION_CREDENTIALS"] = "./[path].json";
$projectId = "[my project's ID']";
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->setScopes(['https://www.googleapis.com/auth/books']);
$service = new Google_Service_Books($client);
$results = $service->volumes->listVolumes('Henry David Thoreau');
</code></pre>
<p>Yet when I run it it returns the error:</p>
<pre><code>PHP Fatal error: Uncaught exception 'DomainException' with message 'Could not load the default credentials. Browse to https://developers.google.com/accounts/docs/application-default-credentials for more information'
</code></pre>
<p>I have tried various configurations, for example changing the path of the file. As you see, I've also done the three different forms of variables that I could immediately think of (two environment, one not).</p>
<p>I'm not quite sure where to look next. Should I look into different ways of setting the environment variable or should I define the path in a different way? What are the correct ways of doing this? Is there any other reason for the error?</p>
| 0debug
|
def max_occurrences(nums):
max_val = 0
result = nums[0]
for i in nums:
occu = nums.count(i)
if occu > max_val:
max_val = occu
result = i
return result
| 0debug
|
how to close Modal while clicking outside of the modal using jquery : how to close Modal while clicking outside of the modal using jquery
$(document).ready(function () {
$("body").click(function (e) {
var x = e.pageX - e.target.offsetLeft;
var y = e.pageY - e.target.offsetTop;
if ((x < 75) || (x > 1275)) {
$('.modal-backdrop').fadeOut();
$('.modal').fadeOut("fast");
}
});
});
| 0debug
|
Detecting events/retrieving data from existing commercial applications : <p>I am attempting to do an unofficial integration with some already existing commercial Windows software. The goal is to detect when a certain textbox and/or label is visible on the screen via our service running on the machine, and then grab the text from said box/label and do something with it in the service. There is no external API we can leverage here.</p>
<p>My research has led me to see about intercepting Windows messages, but I have read a lot of conflicting information about how to go about this (I have never tried this before).</p>
<p>Is there a good way to accomplish my goal? Third party tools are acceptable, but the license must allow distribution to client sites.</p>
| 0debug
|
static int pcibus_reset(BusState *qbus)
{
pci_bus_reset(DO_UPCAST(PCIBus, qbus, qbus));
return 1;
}
| 1threat
|
static int filter_packet(void *log_ctx, AVPacket *pkt,
AVFormatContext *fmt_ctx, AVBitStreamFilterContext *bsf_ctx)
{
AVCodecContext *enc_ctx = fmt_ctx->streams[pkt->stream_index]->codec;
int ret;
while (bsf_ctx) {
AVPacket new_pkt = *pkt;
ret = av_bitstream_filter_filter(bsf_ctx, enc_ctx, NULL,
&new_pkt.data, &new_pkt.size,
pkt->data, pkt->size,
pkt->flags & AV_PKT_FLAG_KEY);
if (ret == 0 && new_pkt.data != pkt->data && new_pkt.destruct) {
if ((ret = av_copy_packet(&new_pkt, pkt)) < 0)
break;
ret = 1;
}
if (ret > 0) {
av_free_packet(pkt);
new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size,
av_buffer_default_free, NULL, 0);
if (!new_pkt.buf)
break;
}
*pkt = new_pkt;
bsf_ctx = bsf_ctx->next;
}
if (ret < 0) {
av_log(log_ctx, AV_LOG_ERROR,
"Failed to filter bitstream with filter %s for stream %d in file '%s' with codec %s\n",
bsf_ctx->filter->name, pkt->stream_index, fmt_ctx->filename,
avcodec_get_name(enc_ctx->codec_id));
}
return ret;
}
| 1threat
|
On WebView long click change the selected text background color in Android : I am trying to create a app in which webview load a html file from assets.Now i am trying to add a functionality like that if webview long click pressed then change the background color of the selected text.How is it possible?
| 0debug
|
Webpack: Throw error on missing member import : <p>I have an import something like this:</p>
<pre><code>import { foo } from 'bar';
</code></pre>
<p>Is there a way to get Webpack to throw an error if <code>foo</code> is not defined?</p>
<p><em>Note that I'm using Babel if that makes a difference.</em></p>
| 0debug
|
static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
{
Error *local_err = NULL;
int64_t bytes = 0;
int64_t objsize;
int obj_order = 0;
const char *pool, *name, *conf, *clientname, *keypairs;
const char *secretid;
rados_t cluster;
rados_ioctx_t io_ctx;
QDict *options = NULL;
QemuOpts *rbd_opts = NULL;
int ret = 0;
secretid = qemu_opt_get(opts, "password-secret");
bytes = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),
BDRV_SECTOR_SIZE);
objsize = qemu_opt_get_size_del(opts, BLOCK_OPT_CLUSTER_SIZE, 0);
if (objsize) {
if ((objsize - 1) & objsize) {
error_setg(errp, "obj size needs to be power of 2");
ret = -EINVAL;
goto exit;
}
if (objsize < 4096) {
error_setg(errp, "obj size too small");
ret = -EINVAL;
goto exit;
}
obj_order = ctz32(objsize);
}
options = qdict_new();
qemu_rbd_parse_filename(filename, options, &local_err);
if (local_err) {
ret = -EINVAL;
error_propagate(errp, local_err);
goto exit;
}
rbd_opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(rbd_opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto exit;
}
pool = qemu_opt_get(rbd_opts, "pool");
conf = qemu_opt_get(rbd_opts, "conf");
clientname = qemu_opt_get(rbd_opts, "user");
name = qemu_opt_get(rbd_opts, "image");
keypairs = qemu_opt_get(rbd_opts, "keyvalue-pairs");
ret = rados_create(&cluster, clientname);
if (ret < 0) {
error_setg_errno(errp, -ret, "error initializing");
goto exit;
}
ret = rados_conf_read_file(cluster, conf);
if (conf && ret < 0) {
error_setg_errno(errp, -ret, "error reading conf file %s", conf);
ret = -EIO;
goto shutdown;
}
ret = qemu_rbd_set_keypairs(cluster, keypairs, errp);
if (ret < 0) {
ret = -EIO;
goto shutdown;
}
if (qemu_rbd_set_auth(cluster, secretid, errp) < 0) {
ret = -EIO;
goto shutdown;
}
ret = rados_connect(cluster);
if (ret < 0) {
error_setg_errno(errp, -ret, "error connecting");
goto shutdown;
}
ret = rados_ioctx_create(cluster, pool, &io_ctx);
if (ret < 0) {
error_setg_errno(errp, -ret, "error opening pool %s", pool);
goto shutdown;
}
ret = rbd_create(io_ctx, name, bytes, &obj_order);
if (ret < 0) {
error_setg_errno(errp, -ret, "error rbd create");
}
rados_ioctx_destroy(io_ctx);
shutdown:
rados_shutdown(cluster);
exit:
QDECREF(options);
qemu_opts_del(rbd_opts);
return ret;
}
| 1threat
|
c# write to file try catches : <p>This code works perfectly well. No issues with it.</p>
<p>The issue is that I would like to put a try catch block around it. This is what I have come up with. Can any suggest any more catches? Or is it fine the way it is?</p>
<pre><code>String strFileLine1 = "This is a folder that will be used by the Virtual Flashcard program.";
String strFileLine2 = "Please do not delete.";
String myFilePath;
.
.
.
SaveFileDialog saveFile = new SaveFileDialog();
saveFile.FileName = "FlashCard.txt";
saveFile.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
saveFile.ShowDialog();
myFilePath = Path.GetDirectoryName(saveFile.FileName);
label2.Text = myFilePath;
try
{
using (StreamWriter fileWrite = new StreamWriter(saveFile.FileName))
{
fileWrite.WriteLine(strFileLine1);
fileWrite.WriteLine(strFileLine2);
}
}
catch (Exception ex)
{
MessageBox.Show("There is a problem");
}
</code></pre>
| 0debug
|
PHP For Loop Working : <p>I have few lines of code that I think will work normally in any language. But this is not working in PHP. In my case I want to print numbers in ascending order. The code I have written is below:</p>
<pre><code>$i = 0;
printf("<p>Numbers in Ascending Order : ");
for (;++i <= 10;) {
printf("%3d", $i);
printf("\n\n");
}
</code></pre>
<p>But I get a syntax error which is given below:</p>
<blockquote>
<p>Parse error: syntax error, unexpected '<=' (T_IS_SMALLER_OR_EQUAL),
expecting</p>
</blockquote>
<p>Why is PHP displaying an error message like this ?</p>
| 0debug
|
How C# handles workload with using statement? : <p>I am currently cleaning up the code for my project and trying to improve its performance. As a part of improvement, I thought of removing unused "using" statements from all files. I would like to figure out if that would indeed improve the performance, so here is my question.</p>
<p>Through the "using" statement, is an external library/resource loaded when <strong>any method from the file is executed</strong> (READ: When file itself is loaded) OR the external library is loaded <strong>only when calling a specific method is actually using this library</strong>?</p>
| 0debug
|
static int hls_slice_header(HEVCContext *s)
{
GetBitContext *gb = &s->HEVClc->gb;
SliceHeader *sh = &s->sh;
int i, ret;
sh->first_slice_in_pic_flag = get_bits1(gb);
if ((IS_IDR(s) || IS_BLA(s)) && sh->first_slice_in_pic_flag) {
s->seq_decode = (s->seq_decode + 1) & 0xff;
s->max_ra = INT_MAX;
if (IS_IDR(s))
ff_hevc_clear_refs(s);
}
sh->no_output_of_prior_pics_flag = 0;
if (IS_IRAP(s))
sh->no_output_of_prior_pics_flag = get_bits1(gb);
sh->pps_id = get_ue_golomb_long(gb);
if (sh->pps_id >= HEVC_MAX_PPS_COUNT || !s->ps.pps_list[sh->pps_id]) {
av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id);
return AVERROR_INVALIDDATA;
}
if (!sh->first_slice_in_pic_flag &&
s->ps.pps != (HEVCPPS*)s->ps.pps_list[sh->pps_id]->data) {
av_log(s->avctx, AV_LOG_ERROR, "PPS changed between slices.\n");
return AVERROR_INVALIDDATA;
}
s->ps.pps = (HEVCPPS*)s->ps.pps_list[sh->pps_id]->data;
if (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos == 1)
sh->no_output_of_prior_pics_flag = 1;
if (s->ps.sps != (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data) {
const HEVCSPS *sps = (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data;
const HEVCSPS *last_sps = s->ps.sps;
enum AVPixelFormat pix_fmt;
if (last_sps && IS_IRAP(s) && s->nal_unit_type != HEVC_NAL_CRA_NUT) {
if (sps->width != last_sps->width || sps->height != last_sps->height ||
sps->temporal_layer[sps->max_sub_layers - 1].max_dec_pic_buffering !=
last_sps->temporal_layer[last_sps->max_sub_layers - 1].max_dec_pic_buffering)
sh->no_output_of_prior_pics_flag = 0;
}
ff_hevc_clear_refs(s);
pix_fmt = get_format(s, sps);
if (pix_fmt < 0)
return pix_fmt;
ret = set_sps(s, sps, pix_fmt);
if (ret < 0)
return ret;
s->seq_decode = (s->seq_decode + 1) & 0xff;
s->max_ra = INT_MAX;
}
sh->dependent_slice_segment_flag = 0;
if (!sh->first_slice_in_pic_flag) {
int slice_address_length;
if (s->ps.pps->dependent_slice_segments_enabled_flag)
sh->dependent_slice_segment_flag = get_bits1(gb);
slice_address_length = av_ceil_log2(s->ps.sps->ctb_width *
s->ps.sps->ctb_height);
sh->slice_segment_addr = get_bitsz(gb, slice_address_length);
if (sh->slice_segment_addr >= s->ps.sps->ctb_width * s->ps.sps->ctb_height) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid slice segment address: %u.\n",
sh->slice_segment_addr);
return AVERROR_INVALIDDATA;
}
if (!sh->dependent_slice_segment_flag) {
sh->slice_addr = sh->slice_segment_addr;
s->slice_idx++;
}
} else {
sh->slice_segment_addr = sh->slice_addr = 0;
s->slice_idx = 0;
s->slice_initialized = 0;
}
if (!sh->dependent_slice_segment_flag) {
s->slice_initialized = 0;
for (i = 0; i < s->ps.pps->num_extra_slice_header_bits; i++)
skip_bits(gb, 1);
sh->slice_type = get_ue_golomb_long(gb);
if (!(sh->slice_type == HEVC_SLICE_I ||
sh->slice_type == HEVC_SLICE_P ||
sh->slice_type == HEVC_SLICE_B)) {
av_log(s->avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n",
sh->slice_type);
return AVERROR_INVALIDDATA;
}
if (IS_IRAP(s) && sh->slice_type != HEVC_SLICE_I) {
av_log(s->avctx, AV_LOG_ERROR, "Inter slices in an IRAP frame.\n");
return AVERROR_INVALIDDATA;
}
sh->pic_output_flag = 1;
if (s->ps.pps->output_flag_present_flag)
sh->pic_output_flag = get_bits1(gb);
if (s->ps.sps->separate_colour_plane_flag)
sh->colour_plane_id = get_bits(gb, 2);
if (!IS_IDR(s)) {
int poc, pos;
sh->pic_order_cnt_lsb = get_bits(gb, s->ps.sps->log2_max_poc_lsb);
poc = ff_hevc_compute_poc(s->ps.sps, s->pocTid0, sh->pic_order_cnt_lsb, s->nal_unit_type);
if (!sh->first_slice_in_pic_flag && poc != s->poc) {
av_log(s->avctx, AV_LOG_WARNING,
"Ignoring POC change between slices: %d -> %d\n", s->poc, poc);
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
poc = s->poc;
}
s->poc = poc;
sh->short_term_ref_pic_set_sps_flag = get_bits1(gb);
pos = get_bits_left(gb);
if (!sh->short_term_ref_pic_set_sps_flag) {
ret = ff_hevc_decode_short_term_rps(gb, s->avctx, &sh->slice_rps, s->ps.sps, 1);
if (ret < 0)
return ret;
sh->short_term_rps = &sh->slice_rps;
} else {
int numbits, rps_idx;
if (!s->ps.sps->nb_st_rps) {
av_log(s->avctx, AV_LOG_ERROR, "No ref lists in the SPS.\n");
return AVERROR_INVALIDDATA;
}
numbits = av_ceil_log2(s->ps.sps->nb_st_rps);
rps_idx = numbits > 0 ? get_bits(gb, numbits) : 0;
sh->short_term_rps = &s->ps.sps->st_rps[rps_idx];
}
sh->short_term_ref_pic_set_size = pos - get_bits_left(gb);
pos = get_bits_left(gb);
ret = decode_lt_rps(s, &sh->long_term_rps, gb);
if (ret < 0) {
av_log(s->avctx, AV_LOG_WARNING, "Invalid long term RPS.\n");
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
sh->long_term_ref_pic_set_size = pos - get_bits_left(gb);
if (s->ps.sps->sps_temporal_mvp_enabled_flag)
sh->slice_temporal_mvp_enabled_flag = get_bits1(gb);
else
sh->slice_temporal_mvp_enabled_flag = 0;
} else {
s->sh.short_term_rps = NULL;
s->poc = 0;
}
if (sh->first_slice_in_pic_flag && s->temporal_id == 0 &&
s->nal_unit_type != HEVC_NAL_TRAIL_N &&
s->nal_unit_type != HEVC_NAL_TSA_N &&
s->nal_unit_type != HEVC_NAL_STSA_N &&
s->nal_unit_type != HEVC_NAL_RADL_N &&
s->nal_unit_type != HEVC_NAL_RADL_R &&
s->nal_unit_type != HEVC_NAL_RASL_N &&
s->nal_unit_type != HEVC_NAL_RASL_R)
s->pocTid0 = s->poc;
if (s->ps.sps->sao_enabled) {
sh->slice_sample_adaptive_offset_flag[0] = get_bits1(gb);
if (s->ps.sps->chroma_format_idc) {
sh->slice_sample_adaptive_offset_flag[1] =
sh->slice_sample_adaptive_offset_flag[2] = get_bits1(gb);
}
} else {
sh->slice_sample_adaptive_offset_flag[0] = 0;
sh->slice_sample_adaptive_offset_flag[1] = 0;
sh->slice_sample_adaptive_offset_flag[2] = 0;
}
sh->nb_refs[L0] = sh->nb_refs[L1] = 0;
if (sh->slice_type == HEVC_SLICE_P || sh->slice_type == HEVC_SLICE_B) {
int nb_refs;
sh->nb_refs[L0] = s->ps.pps->num_ref_idx_l0_default_active;
if (sh->slice_type == HEVC_SLICE_B)
sh->nb_refs[L1] = s->ps.pps->num_ref_idx_l1_default_active;
if (get_bits1(gb)) {
sh->nb_refs[L0] = get_ue_golomb_long(gb) + 1;
if (sh->slice_type == HEVC_SLICE_B)
sh->nb_refs[L1] = get_ue_golomb_long(gb) + 1;
}
if (sh->nb_refs[L0] > HEVC_MAX_REFS || sh->nb_refs[L1] > HEVC_MAX_REFS) {
av_log(s->avctx, AV_LOG_ERROR, "Too many refs: %d/%d.\n",
sh->nb_refs[L0], sh->nb_refs[L1]);
return AVERROR_INVALIDDATA;
}
sh->rpl_modification_flag[0] = 0;
sh->rpl_modification_flag[1] = 0;
nb_refs = ff_hevc_frame_nb_refs(s);
if (!nb_refs) {
av_log(s->avctx, AV_LOG_ERROR, "Zero refs for a frame with P or B slices.\n");
return AVERROR_INVALIDDATA;
}
if (s->ps.pps->lists_modification_present_flag && nb_refs > 1) {
sh->rpl_modification_flag[0] = get_bits1(gb);
if (sh->rpl_modification_flag[0]) {
for (i = 0; i < sh->nb_refs[L0]; i++)
sh->list_entry_lx[0][i] = get_bits(gb, av_ceil_log2(nb_refs));
}
if (sh->slice_type == HEVC_SLICE_B) {
sh->rpl_modification_flag[1] = get_bits1(gb);
if (sh->rpl_modification_flag[1] == 1)
for (i = 0; i < sh->nb_refs[L1]; i++)
sh->list_entry_lx[1][i] = get_bits(gb, av_ceil_log2(nb_refs));
}
}
if (sh->slice_type == HEVC_SLICE_B)
sh->mvd_l1_zero_flag = get_bits1(gb);
if (s->ps.pps->cabac_init_present_flag)
sh->cabac_init_flag = get_bits1(gb);
else
sh->cabac_init_flag = 0;
sh->collocated_ref_idx = 0;
if (sh->slice_temporal_mvp_enabled_flag) {
sh->collocated_list = L0;
if (sh->slice_type == HEVC_SLICE_B)
sh->collocated_list = !get_bits1(gb);
if (sh->nb_refs[sh->collocated_list] > 1) {
sh->collocated_ref_idx = get_ue_golomb_long(gb);
if (sh->collocated_ref_idx >= sh->nb_refs[sh->collocated_list]) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid collocated_ref_idx: %d.\n",
sh->collocated_ref_idx);
return AVERROR_INVALIDDATA;
}
}
}
if ((s->ps.pps->weighted_pred_flag && sh->slice_type == HEVC_SLICE_P) ||
(s->ps.pps->weighted_bipred_flag && sh->slice_type == HEVC_SLICE_B)) {
pred_weight_table(s, gb);
}
sh->max_num_merge_cand = 5 - get_ue_golomb_long(gb);
if (sh->max_num_merge_cand < 1 || sh->max_num_merge_cand > 5) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid number of merging MVP candidates: %d.\n",
sh->max_num_merge_cand);
return AVERROR_INVALIDDATA;
}
}
sh->slice_qp_delta = get_se_golomb(gb);
if (s->ps.pps->pic_slice_level_chroma_qp_offsets_present_flag) {
sh->slice_cb_qp_offset = get_se_golomb(gb);
sh->slice_cr_qp_offset = get_se_golomb(gb);
} else {
sh->slice_cb_qp_offset = 0;
sh->slice_cr_qp_offset = 0;
}
if (s->ps.pps->chroma_qp_offset_list_enabled_flag)
sh->cu_chroma_qp_offset_enabled_flag = get_bits1(gb);
else
sh->cu_chroma_qp_offset_enabled_flag = 0;
if (s->ps.pps->deblocking_filter_control_present_flag) {
int deblocking_filter_override_flag = 0;
if (s->ps.pps->deblocking_filter_override_enabled_flag)
deblocking_filter_override_flag = get_bits1(gb);
if (deblocking_filter_override_flag) {
sh->disable_deblocking_filter_flag = get_bits1(gb);
if (!sh->disable_deblocking_filter_flag) {
int beta_offset_div2 = get_se_golomb(gb);
int tc_offset_div2 = get_se_golomb(gb) ;
if (beta_offset_div2 < -6 || beta_offset_div2 > 6 ||
tc_offset_div2 < -6 || tc_offset_div2 > 6) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid deblock filter offsets: %d, %d\n",
beta_offset_div2, tc_offset_div2);
return AVERROR_INVALIDDATA;
}
sh->beta_offset = beta_offset_div2 * 2;
sh->tc_offset = tc_offset_div2 * 2;
}
} else {
sh->disable_deblocking_filter_flag = s->ps.pps->disable_dbf;
sh->beta_offset = s->ps.pps->beta_offset;
sh->tc_offset = s->ps.pps->tc_offset;
}
} else {
sh->disable_deblocking_filter_flag = 0;
sh->beta_offset = 0;
sh->tc_offset = 0;
}
if (s->ps.pps->seq_loop_filter_across_slices_enabled_flag &&
(sh->slice_sample_adaptive_offset_flag[0] ||
sh->slice_sample_adaptive_offset_flag[1] ||
!sh->disable_deblocking_filter_flag)) {
sh->slice_loop_filter_across_slices_enabled_flag = get_bits1(gb);
} else {
sh->slice_loop_filter_across_slices_enabled_flag = s->ps.pps->seq_loop_filter_across_slices_enabled_flag;
}
} else if (!s->slice_initialized) {
av_log(s->avctx, AV_LOG_ERROR, "Independent slice segment missing.\n");
return AVERROR_INVALIDDATA;
}
sh->num_entry_point_offsets = 0;
if (s->ps.pps->tiles_enabled_flag || s->ps.pps->entropy_coding_sync_enabled_flag) {
unsigned num_entry_point_offsets = get_ue_golomb_long(gb);
if (num_entry_point_offsets > get_bits_left(gb)) {
av_log(s->avctx, AV_LOG_ERROR, "num_entry_point_offsets %d is invalid\n", num_entry_point_offsets);
return AVERROR_INVALIDDATA;
}
sh->num_entry_point_offsets = num_entry_point_offsets;
if (sh->num_entry_point_offsets > 0) {
int offset_len = get_ue_golomb_long(gb) + 1;
if (offset_len < 1 || offset_len > 32) {
sh->num_entry_point_offsets = 0;
av_log(s->avctx, AV_LOG_ERROR, "offset_len %d is invalid\n", offset_len);
return AVERROR_INVALIDDATA;
}
av_freep(&sh->entry_point_offset);
av_freep(&sh->offset);
av_freep(&sh->size);
sh->entry_point_offset = av_malloc_array(sh->num_entry_point_offsets, sizeof(unsigned));
sh->offset = av_malloc_array(sh->num_entry_point_offsets, sizeof(int));
sh->size = av_malloc_array(sh->num_entry_point_offsets, sizeof(int));
if (!sh->entry_point_offset || !sh->offset || !sh->size) {
sh->num_entry_point_offsets = 0;
av_log(s->avctx, AV_LOG_ERROR, "Failed to allocate memory\n");
return AVERROR(ENOMEM);
}
for (i = 0; i < sh->num_entry_point_offsets; i++) {
unsigned val = get_bits_long(gb, offset_len);
sh->entry_point_offset[i] = val + 1;
}
if (s->threads_number > 1 && (s->ps.pps->num_tile_rows > 1 || s->ps.pps->num_tile_columns > 1)) {
s->enable_parallel_tiles = 0;
s->threads_number = 1;
} else
s->enable_parallel_tiles = 0;
} else
s->enable_parallel_tiles = 0;
}
if (s->ps.pps->slice_header_extension_present_flag) {
unsigned int length = get_ue_golomb_long(gb);
if (length*8LL > get_bits_left(gb)) {
av_log(s->avctx, AV_LOG_ERROR, "too many slice_header_extension_data_bytes\n");
return AVERROR_INVALIDDATA;
}
for (i = 0; i < length; i++)
skip_bits(gb, 8);
}
sh->slice_qp = 26U + s->ps.pps->pic_init_qp_minus26 + sh->slice_qp_delta;
if (sh->slice_qp > 51 ||
sh->slice_qp < -s->ps.sps->qp_bd_offset) {
av_log(s->avctx, AV_LOG_ERROR,
"The slice_qp %d is outside the valid range "
"[%d, 51].\n",
sh->slice_qp,
-s->ps.sps->qp_bd_offset);
return AVERROR_INVALIDDATA;
}
sh->slice_ctb_addr_rs = sh->slice_segment_addr;
if (!s->sh.slice_ctb_addr_rs && s->sh.dependent_slice_segment_flag) {
av_log(s->avctx, AV_LOG_ERROR, "Impossible slice segment.\n");
return AVERROR_INVALIDDATA;
}
if (get_bits_left(gb) < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"Overread slice header by %d bits\n", -get_bits_left(gb));
return AVERROR_INVALIDDATA;
}
s->HEVClc->first_qp_group = !s->sh.dependent_slice_segment_flag;
if (!s->ps.pps->cu_qp_delta_enabled_flag)
s->HEVClc->qp_y = s->sh.slice_qp;
s->slice_initialized = 1;
s->HEVClc->tu.cu_qp_offset_cb = 0;
s->HEVClc->tu.cu_qp_offset_cr = 0;
return 0;
}
| 1threat
|
Double trouble, subtracting : <p>Im getting totally wrong when calling CorrectDecimals with the following parameters:</p>
<p>203,30 - 203,00. Gives me: 0.30000000000001137 (the variable double d). With my mathematical skills it should just be 0.3</p>
<pre><code>string a = CorrectDecimals("203,30", "203,00", "12");
public static string CorrectDecimals(string unitPrice, string netAmount, string length)
{
double unitP = (Double.Parse(unitPrice));
double netAmoun = (Double.Parse(netAmount));
double d = unitP - netAmoun;
</code></pre>
| 0debug
|
static void ebus_mmio_mapfunc(PCIDevice *pci_dev, int region_num,
pcibus_t addr, pcibus_t size, int type)
{
EBUS_DPRINTF("Mapping region %d registers at %" FMT_PCIBUS "\n",
region_num, addr);
switch (region_num) {
case 0:
isa_mmio_init(addr, 0x1000000);
break;
case 1:
isa_mmio_init(addr, 0x800000);
break;
}
}
| 1threat
|
Access current req object everywhere in Node.js Express : <p>I wonder how to access req object if there's no 'req' parameter in callback.</p>
<p>This is the scenario:<br>
In ExpressJs, I have a common function, it uses to handle something with 'req' object, but not pass req into it.</p>
<pre><code>module.exports = {
get: function(){
var req = global.currentRequest;
//do something...
}
}
</code></pre>
<p>My current solution is that I write a middleware for all request, I put the 'req' in global variable, then I can access the 'req' everywhere with 'global.currentRequest'. </p>
<pre><code>// in app.js
app.use(function (req, res, next) {
global.currentRequest= req;
next();
});
</code></pre>
<p>But I don't know if it's good? Can anyone have suggestions?<br>
Thanks a lot!</p>
| 0debug
|
static void get_sensor_reading(IPMIBmcSim *ibs,
uint8_t *cmd, unsigned int cmd_len,
uint8_t *rsp, unsigned int *rsp_len,
unsigned int max_rsp_len)
{
IPMISensor *sens;
IPMI_CHECK_CMD_LEN(3);
if ((cmd[2] > MAX_SENSORS) ||
!IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) {
rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;
return;
}
sens = ibs->sensors + cmd[2];
IPMI_ADD_RSP_DATA(sens->reading);
IPMI_ADD_RSP_DATA(IPMI_SENSOR_GET_RET_STATUS(sens));
IPMI_ADD_RSP_DATA(sens->states & 0xff);
if (IPMI_SENSOR_IS_DISCRETE(sens)) {
IPMI_ADD_RSP_DATA((sens->states >> 8) & 0xff);
}
}
| 1threat
|
Eager load model using with but giving it another name - Laravel 5.2 : <p>Is it possible to use eager loading using the with method but giving it another name? Something like:</p>
<pre><code>->with('documents as product', 'documents.documents as categories')
</code></pre>
<p>I have a documents table that can be product or categories, eager loading is working but not that friendly to retrieve the documents by just the document name instead of what it really is.</p>
| 0debug
|
How can I move an responsive Navbar from top to bottom when resizing? would you use CSS media or Jquery ? Thanks in advance:-) : How could I move a responsive Navbar from top to bottom when resizing? would you use CSS media or Jquery? Thanks in advance:-)
| 0debug
|
I am trying to extract data from mongodb using bottle in python and use d3.js to visualize it!Mongodb-->Python-->d3.js : import bottle, pymongo
from pymongo import MongoClient
client = pymongo.MongoClient(some URI)
db = client['database']
dbcoll = db['collection']
@bottle.route('/hello')
def grab_record(name):
bottle.response.headers['Access-Control-Allow-Origin'] = '*'
return dbcoll.find_one({'_id':False})
bottle.run(host='localhost', port=8080, debug=True)
On opening http://localhost:8080/hello, this is the error I get
[![enter image description here][1]][1]
[1]: http://i.stack.imgur.com/QbyC0.png
Both bottle.py and this file are on my Desktop! What should I do? This is urgent!
| 0debug
|
static void cb_hmp_change_bdrv_pwd(Monitor *mon, const char *password,
void *opaque)
{
Error *encryption_err = opaque;
Error *err = NULL;
const char *device;
device = error_get_field(encryption_err, "device");
qmp_block_passwd(device, password, &err);
hmp_handle_error(mon, &err);
error_free(encryption_err);
monitor_read_command(mon, 1);
}
| 1threat
|
My for loop is not working on my On-Click Event in javascript : i am facing an issue on for loop on a On-Click Event,
the Loop is always displaying me the last value.
can someone please help me here...
I have pasted the code below, in Array i got 10 values.
i have tried for loop and foreach, both are giving me same results
function getArray(){<br>
for(var i=0;i<Array_Name.length;i++){<br>
document.getElementById("p2").innerHTML=Array_Name[i]; <br>
}}
<br>
[ input type="submit" value="CalC" onclick="getArray()" ]
i want all the 10 values to be displayed on a button click event
| 0debug
|
How do I set a background transparency I want in CSS? : <p>I try to put a photo under a block of text, but the colors of the photo are too strong and no longer understood what is written.
I tried with comand : "opacity:0.5" but it doesn't work..</p>
| 0debug
|
How to read json file in jupyter notebook? : import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib as plt
from ast import literal_eval
import json
%matplotlib inline
with open('today.json') as f:
data = literal_eval(f.read())
df = pd.DataFrame(data)
print(df)
Error:
File "<ipython-input-16-6c3ee58610d7>", line 10
data = literal_eval(f.read())
^
IndentationError: expected an indented block
| 0debug
|
What does "No binary rubies available" mean? : <p>Whenever I use <code>rvm install x.x.x</code>, I get this warning even in successful installation:</p>
<pre><code>No binary rubies available for: osx/10.12/x86_64/ruby-2.4.0.
Continuing with compilation. Please read 'rvm help mount' to get more
information on binary rubies.
</code></pre>
<p>I tried to read <code>rvm help mount</code>, but it was beyond the scope of my knowledge. </p>
<p>Can someone explain this warning in simple English? Thanks!</p>
| 0debug
|
static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
{
H264Context *h = &s->h;
int i, j, k, m, dir, mode;
int cbp = 0;
uint32_t vlc;
int8_t *top, *left;
const int mb_xy = h->mb_xy;
const int b_xy = 4 * h->mb_x + 4 * h->mb_y * h->b_stride;
h->top_samples_available = (h->mb_y == 0) ? 0x33FF : 0xFFFF;
h->left_samples_available = (h->mb_x == 0) ? 0x5F5F : 0xFFFF;
h->topright_samples_available = 0xFFFF;
if (mb_type == 0) {
if (h->pict_type == AV_PICTURE_TYPE_P ||
s->next_pic->mb_type[mb_xy] == -1) {
svq3_mc_dir_part(s, 16 * h->mb_x, 16 * h->mb_y, 16, 16,
0, 0, 0, 0, 0, 0);
if (h->pict_type == AV_PICTURE_TYPE_B)
svq3_mc_dir_part(s, 16 * h->mb_x, 16 * h->mb_y, 16, 16,
0, 0, 0, 0, 1, 1);
mb_type = MB_TYPE_SKIP;
} else {
mb_type = FFMIN(s->next_pic->mb_type[mb_xy], 6);
if (svq3_mc_dir(s, mb_type, PREDICT_MODE, 0, 0) < 0)
return -1;
if (svq3_mc_dir(s, mb_type, PREDICT_MODE, 1, 1) < 0)
return -1;
mb_type = MB_TYPE_16x16;
}
} else if (mb_type < 8) {
if (s->thirdpel_flag && s->halfpel_flag == !get_bits1(&h->gb))
mode = THIRDPEL_MODE;
else if (s->halfpel_flag &&
s->thirdpel_flag == !get_bits1(&h->gb))
mode = HALFPEL_MODE;
else
mode = FULLPEL_MODE;
for (m = 0; m < 2; m++) {
if (h->mb_x > 0 && h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1] + 6] != -1) {
for (i = 0; i < 4; i++)
AV_COPY32(h->mv_cache[m][scan8[0] - 1 + i * 8],
h->cur_pic.motion_val[m][b_xy - 1 + i * h->b_stride]);
} else {
for (i = 0; i < 4; i++)
AV_ZERO32(h->mv_cache[m][scan8[0] - 1 + i * 8]);
}
if (h->mb_y > 0) {
memcpy(h->mv_cache[m][scan8[0] - 1 * 8],
h->cur_pic.motion_val[m][b_xy - h->b_stride],
4 * 2 * sizeof(int16_t));
memset(&h->ref_cache[m][scan8[0] - 1 * 8],
(h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1, 4);
if (h->mb_x < h->mb_width - 1) {
AV_COPY32(h->mv_cache[m][scan8[0] + 4 - 1 * 8],
h->cur_pic.motion_val[m][b_xy - h->b_stride + 4]);
h->ref_cache[m][scan8[0] + 4 - 1 * 8] =
(h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride + 1] + 6] == -1 ||
h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1;
} else
h->ref_cache[m][scan8[0] + 4 - 1 * 8] = PART_NOT_AVAILABLE;
if (h->mb_x > 0) {
AV_COPY32(h->mv_cache[m][scan8[0] - 1 - 1 * 8],
h->cur_pic.motion_val[m][b_xy - h->b_stride - 1]);
h->ref_cache[m][scan8[0] - 1 - 1 * 8] =
(h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride - 1] + 3] == -1) ? PART_NOT_AVAILABLE : 1;
} else
h->ref_cache[m][scan8[0] - 1 - 1 * 8] = PART_NOT_AVAILABLE;
} else
memset(&h->ref_cache[m][scan8[0] - 1 * 8 - 1],
PART_NOT_AVAILABLE, 8);
if (h->pict_type != AV_PICTURE_TYPE_B)
break;
}
if (h->pict_type == AV_PICTURE_TYPE_P) {
if (svq3_mc_dir(s, mb_type - 1, mode, 0, 0) < 0)
return -1;
} else {
if (mb_type != 2) {
if (svq3_mc_dir(s, 0, mode, 0, 0) < 0)
return -1;
} else {
for (i = 0; i < 4; i++)
memset(h->cur_pic.motion_val[0][b_xy + i * h->b_stride],
0, 4 * 2 * sizeof(int16_t));
}
if (mb_type != 1) {
if (svq3_mc_dir(s, 0, mode, 1, mb_type == 3) < 0)
return -1;
} else {
for (i = 0; i < 4; i++)
memset(h->cur_pic.motion_val[1][b_xy + i * h->b_stride],
0, 4 * 2 * sizeof(int16_t));
}
}
mb_type = MB_TYPE_16x16;
} else if (mb_type == 8 || mb_type == 33) {
memset(h->intra4x4_pred_mode_cache, -1, 8 * 5 * sizeof(int8_t));
if (mb_type == 8) {
if (h->mb_x > 0) {
for (i = 0; i < 4; i++)
h->intra4x4_pred_mode_cache[scan8[0] - 1 + i * 8] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1] + 6 - i];
if (h->intra4x4_pred_mode_cache[scan8[0] - 1] == -1)
h->left_samples_available = 0x5F5F;
}
if (h->mb_y > 0) {
h->intra4x4_pred_mode_cache[4 + 8 * 0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride] + 0];
h->intra4x4_pred_mode_cache[5 + 8 * 0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride] + 1];
h->intra4x4_pred_mode_cache[6 + 8 * 0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride] + 2];
h->intra4x4_pred_mode_cache[7 + 8 * 0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride] + 3];
if (h->intra4x4_pred_mode_cache[4 + 8 * 0] == -1)
h->top_samples_available = 0x33FF;
}
for (i = 0; i < 16; i += 2) {
vlc = svq3_get_ue_golomb(&h->gb);
if (vlc >= 25U) {
av_log(h->avctx, AV_LOG_ERROR, "luma prediction:%d\n", vlc);
return -1;
}
left = &h->intra4x4_pred_mode_cache[scan8[i] - 1];
top = &h->intra4x4_pred_mode_cache[scan8[i] - 8];
left[1] = svq3_pred_1[top[0] + 1][left[0] + 1][svq3_pred_0[vlc][0]];
left[2] = svq3_pred_1[top[1] + 1][left[1] + 1][svq3_pred_0[vlc][1]];
if (left[1] == -1 || left[2] == -1) {
av_log(h->avctx, AV_LOG_ERROR, "weird prediction\n");
return -1;
}
}
} else {
for (i = 0; i < 4; i++)
memset(&h->intra4x4_pred_mode_cache[scan8[0] + 8 * i], DC_PRED, 4);
}
write_back_intra_pred_mode(h);
if (mb_type == 8) {
ff_h264_check_intra4x4_pred_mode(h);
h->top_samples_available = (h->mb_y == 0) ? 0x33FF : 0xFFFF;
h->left_samples_available = (h->mb_x == 0) ? 0x5F5F : 0xFFFF;
} else {
for (i = 0; i < 4; i++)
memset(&h->intra4x4_pred_mode_cache[scan8[0] + 8 * i], DC_128_PRED, 4);
h->top_samples_available = 0x33FF;
h->left_samples_available = 0x5F5F;
}
mb_type = MB_TYPE_INTRA4x4;
} else {
dir = i_mb_type_info[mb_type - 8].pred_mode;
dir = (dir >> 1) ^ 3 * (dir & 1) ^ 1;
if ((h->intra16x16_pred_mode = ff_h264_check_intra_pred_mode(h, dir, 0)) == -1) {
av_log(h->avctx, AV_LOG_ERROR, "check_intra_pred_mode = -1\n");
return -1;
}
cbp = i_mb_type_info[mb_type - 8].cbp;
mb_type = MB_TYPE_INTRA16x16;
}
if (!IS_INTER(mb_type) && h->pict_type != AV_PICTURE_TYPE_I) {
for (i = 0; i < 4; i++)
memset(h->cur_pic.motion_val[0][b_xy + i * h->b_stride],
0, 4 * 2 * sizeof(int16_t));
if (h->pict_type == AV_PICTURE_TYPE_B) {
for (i = 0; i < 4; i++)
memset(h->cur_pic.motion_val[1][b_xy + i * h->b_stride],
0, 4 * 2 * sizeof(int16_t));
}
}
if (!IS_INTRA4x4(mb_type)) {
memset(h->intra4x4_pred_mode + h->mb2br_xy[mb_xy], DC_PRED, 8);
}
if (!IS_SKIP(mb_type) || h->pict_type == AV_PICTURE_TYPE_B) {
memset(h->non_zero_count_cache + 8, 0, 14 * 8 * sizeof(uint8_t));
}
if (!IS_INTRA16x16(mb_type) &&
(!IS_SKIP(mb_type) || h->pict_type == AV_PICTURE_TYPE_B)) {
if ((vlc = svq3_get_ue_golomb(&h->gb)) >= 48U){
av_log(h->avctx, AV_LOG_ERROR, "cbp_vlc=%d\n", vlc);
return -1;
}
cbp = IS_INTRA(mb_type) ? golomb_to_intra4x4_cbp[vlc]
: golomb_to_inter_cbp[vlc];
}
if (IS_INTRA16x16(mb_type) ||
(h->pict_type != AV_PICTURE_TYPE_I && s->adaptive_quant && cbp)) {
h->qscale += svq3_get_se_golomb(&h->gb);
if (h->qscale > 31u) {
av_log(h->avctx, AV_LOG_ERROR, "qscale:%d\n", h->qscale);
return -1;
}
}
if (IS_INTRA16x16(mb_type)) {
AV_ZERO128(h->mb_luma_dc[0] + 0);
AV_ZERO128(h->mb_luma_dc[0] + 8);
if (svq3_decode_block(&h->gb, h->mb_luma_dc[0], 0, 1)) {
av_log(h->avctx, AV_LOG_ERROR,
"error while decoding intra luma dc\n");
return -1;
}
}
if (cbp) {
const int index = IS_INTRA16x16(mb_type) ? 1 : 0;
const int type = ((h->qscale < 24 && IS_INTRA4x4(mb_type)) ? 2 : 1);
for (i = 0; i < 4; i++)
if ((cbp & (1 << i))) {
for (j = 0; j < 4; j++) {
k = index ? (1 * (j & 1) + 2 * (i & 1) +
2 * (j & 2) + 4 * (i & 2))
: (4 * i + j);
h->non_zero_count_cache[scan8[k]] = 1;
if (svq3_decode_block(&h->gb, &h->mb[16 * k], index, type)) {
av_log(h->avctx, AV_LOG_ERROR,
"error while decoding block\n");
return -1;
}
}
}
if ((cbp & 0x30)) {
for (i = 1; i < 3; ++i)
if (svq3_decode_block(&h->gb, &h->mb[16 * 16 * i], 0, 3)) {
av_log(h->avctx, AV_LOG_ERROR,
"error while decoding chroma dc block\n");
return -1;
}
if ((cbp & 0x20)) {
for (i = 1; i < 3; i++) {
for (j = 0; j < 4; j++) {
k = 16 * i + j;
h->non_zero_count_cache[scan8[k]] = 1;
if (svq3_decode_block(&h->gb, &h->mb[16 * k], 1, 1)) {
av_log(h->avctx, AV_LOG_ERROR,
"error while decoding chroma ac block\n");
return -1;
}
}
}
}
}
}
h->cbp = cbp;
h->cur_pic.mb_type[mb_xy] = mb_type;
if (IS_INTRA(mb_type))
h->chroma_pred_mode = ff_h264_check_intra_pred_mode(h, DC_PRED8x8, 1);
return 0;
}
| 1threat
|
How does this string formatting trick work? : I've recently seen this string formatting example:
>>> from datetime import date
>>> 'Today is {0:%A}'.format(date.today())
'Today is Thursday'
I'm wondering how it works.
| 0debug
|
interactive ussd session(multi step) does not work on android 8(Oreo) : <p>I am currently working with Telephony Manager(USSD response) available in android api level 26(Nexus 6P). For single step ussd session, it's working.</p>
<p>reference:
<a href="http://codedrago.com/q/140674/android-telephony-telephonymanager-ussd-android-8-0-oreo-does-android-8-0-api-26-support-sending-and-repying-to-ussd-messages" rel="noreferrer">http://codedrago.com/q/140674/android-telephony-telephonymanager-ussd-android-8-0-oreo-does-android-8-0-api-26-support-sending-and-repying-to-ussd-messages</a></p>
<p>example:</p>
<p>USSD request : "A" (ussd session initiates)</p>
<p>USSD response : "X" (ussd session terminates)</p>
<pre><code> TelephonyManager = telephonyManager(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
Handler handler = new Handler();
TelephonyManager.UssdResponseCallback callback = new TelephonyManager.UssdResponseCallback() {
@Override
public void onReceiveUssdResponse(TelephonyManager telephonyManager, String request, CharSequence response) {
super.onReceiveUssdResponse(telephonyManager, request, response);
Log.e("ussd",response.toString());
}
@Override
public void onReceiveUssdResponseFailed(TelephonyManager telephonyManager, String request, int failureCode) {
super.onReceiveUssdResponseFailed(telephonyManager, request, failureCode);
Log.e("ussd","failed with code " + Integer.toString(failureCode));
}
};
try {
Log.e("ussd","trying to send ussd request");
telephonyManager.sendUssdRequest("*123#",
callback,
handler);
}catch (Exception e){
String msg= e.getMessage();
Log.e("DEBUG",e.toString());
e.printStackTrace();
}
</code></pre>
<p>but for interactive ussd request-response(multi-step), it's not working.
Multi step scenario is as follows:</p>
<p>step # 1. </p>
<p>USSD request : "A" (ussd session initiates)</p>
<p>USSD response : "X"</p>
<p>step # 2.</p>
<p>USSD request : "B" (ussd session continues) </p>
<p>USSD response : "Y"</p>
<p>step # 3.</p>
<p>USSD request : "C" </p>
<p>USSD response : "Z" (ussd session terminates)</p>
| 0debug
|
ie cant get data from input type text : I have input type text like this:
<input type="text" class="f_taskname" value=""/>
When user writes something into it and push enter the next script works:
var task_name=$('#filter_body').find('.f_taskname').val();
and call ajax with parameters:
url:url,
dataType: 'text',
type:'get',
data: { task_name: task_name},
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
It work in FF, Google, but isnt working in IE.
Ive made log file and it is getting data from task_name variable in php script
$f1=fopen('log.txt', 'w');
$output=$task_name.PHP_EOL;
fwrite($f1, $output);
fclose($f1);
It work fine with english words, but with russian it doesnt work and in log file i see things like chianise symbols.
What is wrong?
| 0debug
|
c++ input array of char after input int : <p>I have an array of characters with variable size which is received from user input. From there I input the array with for loop based on the size but it seems like the variable holding the size is changing and I'm stuck in infinite loop.</p>
<pre><code>char arr_1[] = {};
int array_size;
cout << "Array size: ";
cin >> array_size;
for (int i = 0; i < array_size; i++)
{
cout << "Input: ";
cin >> arr_1[i];
}
</code></pre>
| 0debug
|
static void parallels_close(BlockDriverState *bs)
{
BDRVParallelsState *s = bs->opaque;
g_free(s->catalog_bitmap);
}
| 1threat
|
get value from JavaScript object, if first 8 digits of property matched with argument? : <p>Here i need get a value from JavaScript object, if the first 8 digits of property is matched with argument.</p>
<p>Here is what I'm tried...</p>
<pre><code>var input = { 4546546512349: {}, 7200000000007: {}, 9399543200000: {} }
function find_key(query){
$.each(input, function(k, v) {
if (k.substring(0,8) == query){
console.log(k);
return k
}
});
}
find_key(45465465);
</code></pre>
<p>Is there any best solution for this. Thanks in advance.</p>
| 0debug
|
Choosing Machine Learning algorithms for Data : <p>I have several numerical and categorical features in my data and the label is a continuous numerical value. What are the algorithms that I should focus on that pertain to this type of data? (I understand that this is a regression problem).</p>
| 0debug
|
How to use atoi with an int and malloc? : <p>When I try and use atoi with an int and malloc I get a bunch of errors and key is given the wrong value, what am I doing wrong?</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct arguments {
int key;
};
void argument_handler(int argc, char **argv, struct arguments *settings);
int main(int argc, char **argv) {
argv[1] = 101; //makes testing faster
struct arguments *settings = (struct arguments*)malloc(sizeof(struct arguments));
argument_handler(argc, argv, settings);
free(settings);
return 0;
}
void argument_handler(int argc, char **argv, struct arguments *settings) {
int *key = malloc(sizeof(argv[1]));
*key = argv[1];
settings->key = atoi(key);
printf("%d\n", settings->key);
free(key);
}
</code></pre>
| 0debug
|
static int mov_read_chan(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
if (atom.size < 16)
return 0;
ff_mov_read_chan(c->fc, st, atom.size - 4);
return 0;
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.