problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
What if in java I override "equals()" but not hashCode()? : <p>[Core java programming] says if I overrides Object.equals(), then I should override Object.hashCode() at the same time.</p>
<p>This is quite odd to me, if I don't override hashCode() at the same time, is there any possibility that something wrong could happen in logic?</p>
<p>Would you help to give such an example to indicate?</p>
<p>Thanks a lot.</p>
| 0debug |
How is text extracted from a PDF 'seen' in Python? : <p>When text is read from a PDF, how is it recognized in Python3? I want to know how Python3 'sees' it so I can tell it what information to look for, keep, etc.</p>
<p>My ultimate goal is to read a PDF, find certain text from the read information, and create a new document with only the rows of information that match the criteria. As a rough example (in pseudo code):</p>
<p>-Read the PDF, if column 4 has an 'x' in it, copy that ROW to a separate file (skip if it doesn't contain 'x'), continue through until end of PDF.</p>
<p>-Read NEW doc, if column 1 has 'n', keep row, otherwise delete it.</p>
<p>I know it isn't the most ideal way to do it and I plan on fixing that part later.</p>
| 0debug |
how do i make my search bar actually search pages in my site? : so i put a search bar into my website and i dont know how to make it actually search pages within my site. I dobt want a google search bar where you can search anything. I already have the search bar in my site, but nothing happens when you press search. Help is much appreciated.
here is the html to my search bar:
<div class="search">
<form class="form-wrapper-2 cf">
<input type="text" placeholder="Search Yacht..." required>
<button type="submit">Search</button>
</form>
</div> | 0debug |
How to minify JavaScript like Google Analytics? : <p>Most of you are probably familiar with this little tracking code offered by Google Analytics.</p>
<pre><code><script>
(
function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
}
)(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-00000000-0', 'auto');
ga('send', 'pageview');
</script>
</code></pre>
<p>The interesting part is that this little excerpt contains arguments that form the word isogram. This script also uses arguments to declare variables to shave off some bits from the final file size. Arguably, you would not use this pattern when writing the code (?), so my question is, how does Google minify its code and are these techniques available to mere mortals, too?</p>
<p>I found online this <a href="http://code.stephenmorley.org/javascript/understanding-the-google-analytics-tracking-code/" rel="noreferrer">example</a> by Stephen Morley that includes a code that looks like something you'd write before minifying it. I took that code and run it through Google's very own <a href="https://closure-compiler.appspot.com/home" rel="noreferrer">Closure Compiler</a> on advanced optimisation. As expected, the resulting code is nothing like the actual script used by Google Analytics.</p>
<pre><code>(function(){window.b="ga";"ga"in window||(window.a=function(){window.a.q.push(arguments)},window.a.q=[]);window.a.c=(new Date).getTime();var c=document.createElement("script");c.src="//www.google-analytics.com/analytics.js";c.async=!0;var d=document.getElementsByTagName("script")[0];d.parentNode.insertBefore(c,d)})();
</code></pre>
<p>This time, the code is less DRY and bigger, even without the two extra commands.</p>
<p>So to clarify, I am curious how the Google engineers arrived to the above result (I do not think their code actually looks like the one in Stephen's example), and could this process be replicated even if you are not a part of Google? Thank you in advance!</p>
| 0debug |
Download/install code from github for python? : <p>So I do not really understand <em>what</em> github is, but I would like to implement the function described in this paper:
<a href="https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=4717949" rel="nofollow noreferrer">https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=4717949</a></p>
<p>where the github files are uploaded here:
<a href="https://github.com/SantiagoEG/FCBF_module" rel="nofollow noreferrer">https://github.com/SantiagoEG/FCBF_module</a></p>
<p>I am very new to python, and am at a loss for how to be able to use this without copying/pasting their function into my notebook.</p>
<p>Any help?</p>
| 0debug |
How to put my api online? : <p>I've created an api using Slim framework. It's locally and i need to put it online, but I don't know how. I'm using mysql database to store the data, this api will be used for mobile application and website.</p>
<p>What is the best solution? And how I could do that?</p>
| 0debug |
How money do I get if the app reach 1 million downloads without any adds : <p>Guys I need know one thing that if an app reach to 1 million downloads or more than 1 million downloads without any ads how much money do I get . And also if I got money it's one time payment or it continues every month....plz replay for this question ....and thnx for your replay</p>
| 0debug |
static void rocker_io_writel(void *opaque, hwaddr addr, uint32_t val)
{
Rocker *r = opaque;
if (rocker_addr_is_desc_reg(r, addr)) {
unsigned index = ROCKER_RING_INDEX(addr);
unsigned offset = addr & ROCKER_DMA_DESC_MASK;
switch (offset) {
case ROCKER_DMA_DESC_ADDR_OFFSET:
r->lower32 = (uint64_t)val;
break;
case ROCKER_DMA_DESC_ADDR_OFFSET + 4:
desc_ring_set_base_addr(r->rings[index],
((uint64_t)val) << 32 | r->lower32);
r->lower32 = 0;
break;
case ROCKER_DMA_DESC_SIZE_OFFSET:
desc_ring_set_size(r->rings[index], val);
break;
case ROCKER_DMA_DESC_HEAD_OFFSET:
if (desc_ring_set_head(r->rings[index], val)) {
rocker_msix_irq(r, desc_ring_get_msix_vector(r->rings[index]));
}
break;
case ROCKER_DMA_DESC_CTRL_OFFSET:
desc_ring_set_ctrl(r->rings[index], val);
break;
case ROCKER_DMA_DESC_CREDITS_OFFSET:
if (desc_ring_ret_credits(r->rings[index], val)) {
rocker_msix_irq(r, desc_ring_get_msix_vector(r->rings[index]));
}
break;
default:
DPRINTF("not implemented dma reg write(l) addr=0x" TARGET_FMT_plx
" val=0x%08x (ring %d, addr=0x%02x)\n",
addr, val, index, offset);
break;
}
return;
}
switch (addr) {
case ROCKER_TEST_REG:
r->test_reg = val;
break;
case ROCKER_TEST_REG64:
case ROCKER_TEST_DMA_ADDR:
case ROCKER_PORT_PHYS_ENABLE:
r->lower32 = (uint64_t)val;
break;
case ROCKER_TEST_REG64 + 4:
r->test_reg64 = ((uint64_t)val) << 32 | r->lower32;
r->lower32 = 0;
break;
case ROCKER_TEST_IRQ:
rocker_msix_irq(r, val);
break;
case ROCKER_TEST_DMA_SIZE:
r->test_dma_size = val;
break;
case ROCKER_TEST_DMA_ADDR + 4:
r->test_dma_addr = ((uint64_t)val) << 32 | r->lower32;
r->lower32 = 0;
break;
case ROCKER_TEST_DMA_CTRL:
rocker_test_dma_ctrl(r, val);
break;
case ROCKER_CONTROL:
rocker_control(r, val);
break;
case ROCKER_PORT_PHYS_ENABLE + 4:
rocker_port_phys_enable_write(r, ((uint64_t)val) << 32 | r->lower32);
r->lower32 = 0;
break;
default:
DPRINTF("not implemented write(l) addr=0x" TARGET_FMT_plx
" val=0x%08x\n", addr, val);
break;
}
}
| 1threat |
How to know which user answered a Jenkins-Pipeline input step? : <p>I have a Jenkinsfile script that tests for the possibility to perform an SVN merge and then asks the user for the permission to commit the merge.</p>
<p>I would like to know the username that answers the "input" step in order to write it into the commit message.</p>
<p>Is this possibile?</p>
<p>This is what hypothetically I would like to do:</p>
<pre><code>outcome = input message: 'Merge trunk into branch?', ok: 'Merge'
echo "User that allowed merge: ${outcome.user}"
</code></pre>
| 0debug |
int xen_hvm_init(void)
{
int i, rc;
unsigned long ioreq_pfn;
XenIOState *state;
state = g_malloc0(sizeof (XenIOState));
state->xce_handle = xen_xc_evtchn_open(NULL, 0);
if (state->xce_handle == XC_HANDLER_INITIAL_VALUE) {
perror("xen: event channel open");
return -errno;
}
state->xenstore = xs_daemon_open();
if (state->xenstore == NULL) {
perror("xen: xenstore open");
return -errno;
}
state->exit.notify = xen_exit_notifier;
qemu_add_exit_notifier(&state->exit);
state->suspend.notify = xen_suspend_notifier;
qemu_register_suspend_notifier(&state->suspend);
xc_get_hvm_param(xen_xc, xen_domid, HVM_PARAM_IOREQ_PFN, &ioreq_pfn);
DPRINTF("shared page at pfn %lx\n", ioreq_pfn);
state->shared_page = xc_map_foreign_range(xen_xc, xen_domid, XC_PAGE_SIZE,
PROT_READ|PROT_WRITE, ioreq_pfn);
if (state->shared_page == NULL) {
hw_error("map shared IO page returned error %d handle=" XC_INTERFACE_FMT,
errno, xen_xc);
}
xc_get_hvm_param(xen_xc, xen_domid, HVM_PARAM_BUFIOREQ_PFN, &ioreq_pfn);
DPRINTF("buffered io page at pfn %lx\n", ioreq_pfn);
state->buffered_io_page = xc_map_foreign_range(xen_xc, xen_domid, XC_PAGE_SIZE,
PROT_READ|PROT_WRITE, ioreq_pfn);
if (state->buffered_io_page == NULL) {
hw_error("map buffered IO page returned error %d", errno);
}
state->ioreq_local_port = g_malloc0(smp_cpus * sizeof (evtchn_port_t));
for (i = 0; i < smp_cpus; i++) {
rc = xc_evtchn_bind_interdomain(state->xce_handle, xen_domid,
xen_vcpu_eport(state->shared_page, i));
if (rc == -1) {
fprintf(stderr, "bind interdomain ioctl error %d\n", errno);
return -1;
}
state->ioreq_local_port[i] = rc;
}
xen_map_cache_init();
xen_ram_init(ram_size);
qemu_add_vm_change_state_handler(xen_hvm_change_state_handler, state);
state->memory_listener = xen_memory_listener;
QLIST_INIT(&state->physmap);
memory_listener_register(&state->memory_listener);
state->log_for_dirtybit = NULL;
if (xen_be_init() != 0) {
fprintf(stderr, "%s: xen backend core setup failed\n", __FUNCTION__);
exit(1);
}
xen_be_register("console", &xen_console_ops);
xen_be_register("vkbd", &xen_kbdmouse_ops);
xen_be_register("qdisk", &xen_blkdev_ops);
xen_read_physmap(state);
return 0;
}
| 1threat |
Why does ToString() on generic types have square brackets? : <p>Why does <code>new List<string>().ToString();</code> return the following:?</p>
<pre><code>System.Collections.Generic.List`1[System.String]
</code></pre>
<p>Why wouldn't it just bring back <code>System.Collections.Generic.List<System.String></code>.
What's with the strange non C# syntax?</p>
| 0debug |
int av_thread_message_queue_alloc(AVThreadMessageQueue **mq,
unsigned nelem,
unsigned elsize)
{
#if HAVE_THREADS
AVThreadMessageQueue *rmq;
int ret = 0;
if (nelem > INT_MAX / elsize)
return AVERROR(EINVAL);
if (!(rmq = av_mallocz(sizeof(*rmq))))
return AVERROR(ENOMEM);
if ((ret = pthread_mutex_init(&rmq->lock, NULL))) {
av_free(rmq);
return AVERROR(ret);
}
if ((ret = pthread_cond_init(&rmq->cond, NULL))) {
pthread_mutex_destroy(&rmq->lock);
av_free(rmq);
return AVERROR(ret);
}
if (!(rmq->fifo = av_fifo_alloc(elsize * nelem))) {
pthread_cond_destroy(&rmq->cond);
pthread_mutex_destroy(&rmq->lock);
av_free(rmq);
return AVERROR(ret);
}
rmq->elsize = elsize;
*mq = rmq;
return 0;
#else
*mq = NULL;
return AVERROR(ENOSYS);
#endif
}
| 1threat |
static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb,
AVStream *st, MOVStreamContext *sc)
{
uint8_t codec_name[32];
int64_t stsd_start;
unsigned int len;
stsd_start = avio_tell(pb) - 16;
avio_rb16(pb);
avio_rb16(pb);
avio_rb32(pb);
avio_rb32(pb);
avio_rb32(pb);
st->codecpar->width = avio_rb16(pb);
st->codecpar->height = avio_rb16(pb);
avio_rb32(pb);
avio_rb32(pb);
avio_rb32(pb);
avio_rb16(pb);
len = avio_r8(pb);
if (len > 31)
len = 31;
mov_read_mac_string(c, pb, len, codec_name, sizeof(codec_name));
if (len < 31)
avio_skip(pb, 31 - len);
if (codec_name[0])
av_dict_set(&st->metadata, "encoder", codec_name, 0);
if (!memcmp(codec_name, "Planar Y'CbCr 8-bit 4:2:0", 25)) {
st->codecpar->codec_tag = MKTAG('I', '4', '2', '0');
st->codecpar->width &= ~1;
st->codecpar->height &= ~1;
}
if (st->codecpar->codec_tag == MKTAG('H','2','6','3') &&
!memcmp(codec_name, "Sorenson H263", 13))
st->codecpar->codec_id = AV_CODEC_ID_FLV1;
st->codecpar->bits_per_coded_sample = avio_rb16(pb);
avio_seek(pb, stsd_start, SEEK_SET);
if (ff_get_qtpalette(st->codecpar->codec_id, pb, sc->palette)) {
st->codecpar->bits_per_coded_sample &= 0x1F;
sc->has_palette = 1;
}
}
| 1threat |
C++ Getting a strange output when overloading postfix increment operator : <p>I threw everything I had into a single source file and uploaded it to <a href="https://pastebin.com/Pqn2cLPR" rel="nofollow noreferrer">pastebin</a> for easy debugging.</p>
<p>My problem is with the postfix increment operator.<br/>In my output, I get this:<br/></p>
<pre><code>Preincrement expressions:
(-11 - 2i)
(-117 + 44i)
Postincrement expressions:
(-1.07374e+08 - 1.07374e+08i)
(-1.07374e+08 - 1.07374e+08i)
After postincrement expressions:
(-1199 - 718i)
(-922077 + 1.72176e+06i)
</code></pre>
<p>When I am expecting this:<br/></p>
<pre><code>Preincrement expressions:
(-11 - 2i)
(-117 + 44i)
Postincrement expressions:
(-11 - 2i)
(-117 + 44i)
After postincrement expressions:
(-1199 - 718i)
(-922077 + 1.72176e+06i)
</code></pre>
<p>I am getting a strange output for "Preincrement expressions". During debugging I can see that the values stored in the temporary object are correct until it comes time to format and output them.<br/><br/> Any help on this would be greatly appreciated!</p>
| 0debug |
reg ex for searching filenames : <p>I want to select the files, whose names ends with <code>_90.jpeg|_180.jpeg|_270.jpeg|_90.jpg|_180.jpg|_270.jpg</code>.</p>
<p>currently I am using the following approach</p>
<pre class="lang-py prettyprint-override"><code>pattern = re.compile('_90.jpeg|_180.jpeg|_270.jpeg|_90.jpg|_180.jpg|_270.jpg')
pattern.search(filename)
</code></pre>
<p>Is there any cleaner way to represent the _xxx.yyyy in regular expression. </p>
| 0debug |
What makes ValueTuple covariant? : <p>This compiles correctly in C# 7.3 (Framework 4.8):</p>
<pre><code>(string, string) s = ("a", "b");
(object, string) o = s;
</code></pre>
<p>I know that this is syntactic sugar for the following, which also compiles correctly:</p>
<pre><code>ValueTuple<string, string> s = new ValueTuple<string, string>("a", "b");
ValueTuple<object, string> o = s;
</code></pre>
<p>So, it appears that ValueTuples can be assigned <a href="https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)" rel="noreferrer">covariantly</a>, <em>which is awesome</em>!</p>
<p>Unfortunately, I don't understand <em>why</em>: I was under the impression that C# <a href="https://stackoverflow.com/a/19094386/87698">only supported covariance on interfaces and delegates</a>. <code>ValueType</code> is neither.</p>
<p>In fact, when I try to duplicate this feature with my own code, I fail:</p>
<pre><code>struct MyValueTuple<A, B>
{
public A Item1;
public B Item2;
public MyValueTuple(A item1, B item2)
{
Item1 = item1;
Item2 = item2;
}
}
...
MyValueTuple<string, string> s = new MyValueTuple<string, string>("a", "b");
MyValueTuple<object, string> o = s;
// ^ Cannot implicitly convert type 'MyValueTuple<string, string>' to 'MyValueTuple<object, string>'
</code></pre>
<p>So, why can <code>ValueTuple</code>s be assigned covariantly, but <code>MyValueTuple</code>s can't?</p>
| 0debug |
My script its udpating all fields when i just edit one : my problem its im trying to develop a backend where i need to update but my problem its , when I update one field my script update all fields and all data of my mysqli database.
My code for now its that :
<html>
<body>
<?php
ini_set('display_errors', 1);
error_reporting(~0);
$serverName = "localhost";
$userName = "root";
$userPassword = "";
$dbName = "hotel_vaniet";
$strCustomerID = null;
if(isset($_GET["cod"]))
{
$cod = $_GET["cod"];
}
$serverName = "localhost";
$userName = "root";
$userPassword = "";
$dbName = "hotel_vaniet";
$conn = mysqli_connect($serverName,$userName,$userPassword,$dbName);
$sql = "SELECT * FROM quartos WHERE cod=$cod";
$query = mysqli_query($conn,$sql);
$result=mysqli_fetch_array($query,MYSQLI_ASSOC);
?>
<div id="main">
<form action="editar_quartos_final.php" name="frmAdd" method="post">
<br><h1>Página de Edição</h1>
<br><hr/>
<div id="login2">
<table width="284" border="1">
<tr>
<th width="120">Tipo</th>
<td width="238"><input type="text" name="tipo" size="50" value="<?php echo $result["tipo"];?>"></td>
</tr>
<tr>
<th width="120">Capacidade</th>
<td><input type="text" name="capacidade" size="50" value="<?php echo $result["capacidade"];?>"></td>
</tr>
<tr>
<th width="120">Preço p/ Noite</th>
<td><input type="text" name="preco" size="50" value="<?php echo $result["preco"];?>"></td>
</tr>
<tr>
<th width="120">Reservado</th>
<td><input type="text" name="reservado" size="50" value="<?php echo $result["reservado"];?>"></td>
</tr>
</table>
<br><input id="submitbuttoneditar" type="submit" value=" Editar " name="submit"/><br />
</div>
</form>
<?php
mysqli_close($conn);
?>
</body>
</html>
This the first page ,this page send me to another where makes all changes. The second page :
<html>
<head>
<title>Página de Edição do Cliente</title>
</head>
<body>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "hotel_vaniet";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "UPDATE quartos SET
tipo = '".$_POST["tipo"]."' ,
capacidade = '".$_POST["capacidade"]."' ,
preco = '".$_POST["preco"]."' ,
reservado = '".$_POST["reservado"]."'
WHERE cod=cod";
if ($conn->query($sql) === TRUE) {
echo "Dados actualizados com sucesso!";
header("Location: quartos.php");
} else {
echo "Erro na edição dos dados! " . $conn->error;
header("Location: quartos.php");
}
$conn->close();
?>
</body>
</html>
Thanks for your help ! | 0debug |
static int ram_save_block(QEMUFile *f, bool last_stage)
{
RAMBlock *block = last_seen_block;
ram_addr_t offset = last_offset;
bool complete_round = false;
int bytes_sent = 0;
MemoryRegion *mr;
ram_addr_t current_addr;
if (!block)
block = QTAILQ_FIRST(&ram_list.blocks);
while (true) {
mr = block->mr;
offset = migration_bitmap_find_and_reset_dirty(mr, offset);
if (complete_round && block == last_seen_block &&
offset >= last_offset) {
break;
}
if (offset >= block->length) {
offset = 0;
block = QTAILQ_NEXT(block, next);
if (!block) {
block = QTAILQ_FIRST(&ram_list.blocks);
complete_round = true;
ram_bulk_stage = false;
}
} else {
int ret;
uint8_t *p;
int cont = (block == last_sent_block) ?
RAM_SAVE_FLAG_CONTINUE : 0;
p = memory_region_get_ram_ptr(mr) + offset;
bytes_sent = -1;
ret = ram_control_save_page(f, block->offset,
offset, TARGET_PAGE_SIZE, &bytes_sent);
if (ret != RAM_SAVE_CONTROL_NOT_SUPP) {
if (ret != RAM_SAVE_CONTROL_DELAYED) {
if (bytes_sent > 0) {
acct_info.norm_pages++;
} else if (bytes_sent == 0) {
acct_info.dup_pages++;
}
}
} else if (is_zero_range(p, TARGET_PAGE_SIZE)) {
acct_info.dup_pages++;
bytes_sent = save_block_hdr(f, block, offset, cont,
RAM_SAVE_FLAG_COMPRESS);
qemu_put_byte(f, 0);
bytes_sent++;
} else if (!ram_bulk_stage && migrate_use_xbzrle()) {
current_addr = block->offset + offset;
bytes_sent = save_xbzrle_page(f, p, current_addr, block,
offset, cont, last_stage);
if (!last_stage) {
p = get_cached_data(XBZRLE.cache, current_addr);
}
}
if (bytes_sent == -1) {
bytes_sent = save_block_hdr(f, block, offset, cont, RAM_SAVE_FLAG_PAGE);
qemu_put_buffer_async(f, p, TARGET_PAGE_SIZE);
bytes_sent += TARGET_PAGE_SIZE;
acct_info.norm_pages++;
}
if (bytes_sent > 0) {
last_sent_block = block;
break;
}
}
}
last_seen_block = block;
last_offset = offset;
return bytes_sent;
}
| 1threat |
How float the html elements in small blocks but when one block is expand others should align propertly? : i have created list of divs 50px height and 50px width which are floated in main div. but when i expand only on div to 100px height below div will move to next place but there is an empty space before the div which has height 100px | 0debug |
static bool is_iso_bc_entry_compatible(IsoBcSection *s)
{
return true;
}
| 1threat |
couldnt save to access database c# : the values staring vith cmb is a combo box.
when i click the save button it throws an error
my code is below
`cn.Open();`
`OleDbCommand command = new OleDbCommand();`
`command.Connection = cn;`
`command.CommandText = "insert into TblProductDetails(ProductID,ProductName,Category,Section,UOM,CostPrice,SellingPrice1,SellingPrice2,DiscountPercentage,DiscountAmount,MinimumPrice,Vendor,Stock) values ('" + txtProductID.Text + "','" + txtName.Text + "','" + category + "','" + section + "','" + uom + "','" + txtCostprice.Text + "','" + txtSellingPrice1.Text + "','" + txtSellingPrice2.Text + "','" + txtDiscountpercentage.Text + "','" + txtDiscountAmount.Text + "','" + txtMinimumPrice.Text + "','" + vendor + "','" + txtBeginingStock.Text + "')";`
`command.ExecuteNonQuery();`
`cn.Close();`
| 0debug |
google maps API for C# : <p>im really new in to using APIs so after looking on google maps Api page im not sure if there are APIs designed to be used for C#. I dont need a google maps to be show on my app all i need to know if i can use the google maps API on C#.
<a href="https://developers.google.com/maps/documentation/directions/" rel="noreferrer">This is the one i will like to use</a></p>
<p>Ive look for it on many places but all i could find was alternatives to using Gmaps but thats not what i want.</p>
<p>¿It is possible to use it?</p>
| 0debug |
How to route from one application to another application in angular 2+ : <p>I have two different application in angular 7 and I want to navigate between them. How do I achieve it by using angular routing?</p>
| 0debug |
static int ram_load(QEMUFile *f, void *opaque, int version_id)
{
ram_addr_t addr;
int flags;
if (version_id != 3)
return -EINVAL;
do {
addr = qemu_get_be64(f);
flags = addr & ~TARGET_PAGE_MASK;
addr &= TARGET_PAGE_MASK;
if (flags & RAM_SAVE_FLAG_MEM_SIZE) {
if (addr != last_ram_offset)
return -EINVAL;
}
if (flags & RAM_SAVE_FLAG_COMPRESS) {
uint8_t ch = qemu_get_byte(f);
memset(qemu_get_ram_ptr(addr), ch, TARGET_PAGE_SIZE);
#ifndef _WIN32
if (ch == 0 &&
(!kvm_enabled() || kvm_has_sync_mmu())) {
madvise(qemu_get_ram_ptr(addr), TARGET_PAGE_SIZE, MADV_DONTNEED);
}
#endif
} else if (flags & RAM_SAVE_FLAG_PAGE) {
qemu_get_buffer(f, qemu_get_ram_ptr(addr), TARGET_PAGE_SIZE);
}
if (qemu_file_has_error(f)) {
return -EIO;
}
} while (!(flags & RAM_SAVE_FLAG_EOS));
return 0;
}
| 1threat |
Is it possible to use an AND operator in grepl()? : <p>I want to search for anything that begins with <code>55</code> and anything that has the word <code>Roof</code> (case-sensitive, for those who are curious) in it.</p>
<p>So far I have been unsuccessful, as I can only seem to use the <code>OR</code> operator:</p>
<pre><code>grepl("*^55|*Roof", dataset$longname)
</code></pre>
<p>Ultimately, I want to achieve something like this:</p>
<pre><code>grepl("*^55&&*Roof", dataset$longname)
</code></pre>
<p>or</p>
<pre><code>grepl("*^55&*Roof", dataset$longname)
</code></pre>
<p>(Clearly, neither of these work - they're for illustration only.)</p>
<p>I want my results to show anything that begins with <code>55</code> and which has the word <code>Roof</code> anywhere in it.</p>
<p>For example, I would expect both of these results to be picked up by the <code>grepl()</code> function:</p>
<pre><code>55 - Roof Structure
</code></pre>
<p>and</p>
<pre><code>55-Wall to Roof
</code></pre>
<p>Is there an <code>AND</code> operator that can be used with <code>grepl()</code>?</p>
| 0debug |
REST APIs and messaging : <p>I have a system that exposes a REST API with a rich set of CRUD endpoints to manage different resources.
The REST API is used also by a front-end application that executes calls by using Ajax.</p>
<p>I would like to make some of these calls asynchronous and add reliability.</p>
<p>The obvious choice seems a message broker (ActiveMQ, RabbitMQ, etc...).</p>
<p>Never used message brokers before and I am wondering if they can be "put in front of" the REST API without having to rewrite them. </p>
<p>I do not want to access the REST API only through the messaging system: for some endpoints, a call must always be synchronous and the reliability is less important (mainly because in case of error the user receives an immediate feedback).</p>
<p>Would a full ESB be a better option for this use case?</p>
| 0debug |
static void pxa2xx_gpio_write(void *opaque, hwaddr offset,
uint64_t value, unsigned size)
{
PXA2xxGPIOInfo *s = (PXA2xxGPIOInfo *) opaque;
int bank;
if (offset >= 0x200)
return;
bank = pxa2xx_gpio_regs[offset].bank;
switch (pxa2xx_gpio_regs[offset].reg) {
case GPDR:
s->dir[bank] = value;
pxa2xx_gpio_handler_update(s);
break;
case GPSR:
s->olevel[bank] |= value;
pxa2xx_gpio_handler_update(s);
break;
case GPCR:
s->olevel[bank] &= ~value;
pxa2xx_gpio_handler_update(s);
break;
case GRER:
s->rising[bank] = value;
break;
case GFER:
s->falling[bank] = value;
break;
case GAFR_L:
s->gafr[bank * 2] = value;
break;
case GAFR_U:
s->gafr[bank * 2 + 1] = value;
break;
case GEDR:
s->status[bank] &= ~value;
pxa2xx_gpio_irq_update(s);
break;
default:
hw_error("%s: Bad offset " REG_FMT "\n", __FUNCTION__, offset);
}
}
| 1threat |
Use non-local numbers to receive messages : <p>Can I use a Canadian number to send and receive SMS from US numbers?
And also a German number, which is marked as international, for receiving and sending SMS in Europe?</p>
| 0debug |
How do I remove specific byte sequences with sed using hex addresses? : I've got a string, looks like this in VIM
> PFLUGERVILLE TX 7x691 227 12515 <83>¨¨ x Research Boulevard
I go over the `<83>` and type `ga`, I get this
<<83>> 131, Hex 0083, Octal 203
If I type `g8`, I get
c2 83
I would have thought that
sed -e's/\x00\x83//g' ./file.csv
would work, but no joy. | 0debug |
How to display two tabs inside the page/panel in sencha : How to **display two tabs inside the page/panel in sencha mobile application ** and **one should be active default**.
Please me thanks in advance. | 0debug |
Ternary operator on style with React Js Es 6 : <p>I am trying to add the following ternary operator to show my button if I am logged in and If I am not to hide it. The following below keeps throwing me an error.</p>
<pre><code><img src={this.state.photo} alt="" style="{isLoggedIn ? 'display:' : 'display:none'}" />
</code></pre>
| 0debug |
def sum_Natural(n):
sum = (n * (n + 1))
return int(sum)
def sum_Even(l,r):
return (sum_Natural(int(r / 2)) - sum_Natural(int((l - 1) / 2))) | 0debug |
how can i get html that is generated via AJAX? : I am trying parse Web Page. part of that page generated via AJAX,
WebClient.DownloadString i can get whole HTML except that code which is generated via AJAX? can you someone help me please?
my code is:
var client = new WebClient();
client .Headers.Add(HttpRequestHeader.UserAgent, "UserAgent,Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20100101 Firefox/14.0.1");
client.Headers.Add(HttpRequestHeader.Cookie, "USER_PW= xxxxxxxxx; PHPSESSID= xxxxxxxxx");
var html = client.DownloadString("string.example.com");
i need list of vacancies...
thank you so much | 0debug |
static int kvmppc_put_books_sregs(PowerPCCPU *cpu)
{
CPUPPCState *env = &cpu->env;
struct kvm_sregs sregs;
int i;
sregs.pvr = env->spr[SPR_PVR];
sregs.u.s.sdr1 = env->spr[SPR_SDR1];
#ifdef TARGET_PPC64
for (i = 0; i < ARRAY_SIZE(env->slb); i++) {
sregs.u.s.ppc64.slb[i].slbe = env->slb[i].esid;
if (env->slb[i].esid & SLB_ESID_V) {
sregs.u.s.ppc64.slb[i].slbe |= i;
}
sregs.u.s.ppc64.slb[i].slbv = env->slb[i].vsid;
}
#endif
for (i = 0; i < 16; i++) {
sregs.u.s.ppc32.sr[i] = env->sr[i];
}
for (i = 0; i < 8; i++) {
sregs.u.s.ppc32.dbat[i] = ((uint64_t)env->DBAT[0][i] << 32)
| env->DBAT[1][i];
sregs.u.s.ppc32.ibat[i] = ((uint64_t)env->IBAT[0][i] << 32)
| env->IBAT[1][i];
}
return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_SREGS, &sregs);
}
| 1threat |
Can anyone help me to move to the delete button and click on that : [![enter image description here][1]][1][![enter image description here][2]][2]This is actually a salesforce lightening page and while deleting the object i am getting a modal dialog box where i am unable to move to click on that.
Alert class is not working to move onto the page.
please find the attached screenshot.[![enter image description here][3]][3]
[1]: https://i.stack.imgur.com/631Dx.png
[2]: https://i.stack.imgur.com/dOzvO.png
[3]: https://i.stack.imgur.com/168aa.png | 0debug |
Objective-C equal distribution from 5 different NSMutablearrays : i have the following problem/situation:
###Example:
In Sqlite Database i have a table with the following rows: a1,a2,a3,a4,a5,b1,b2,b3,c1,c2,c3,c4,c5,d1,d2,e1
I have create 5 groups (NSMutablearrays) with objects:
- NSMutablearray1: 5 objects with values "a1","a2","a3","a4","a5"
- NSMutablearray2: 3 objects with values "b1","b2","b3"
- NSMutablearray3: 5 objects with values "c1","c2","c3","c4","c5"
- NSMutablearray4: 2 objects with values "d1","d2"
- NSMutablearray5: 1 objects with value "e1"
x = count of groups(arrays) for equal distribution
in this example is x = 3 (3 groups)
###Round 1 (x1 starts):
- x1= random object out of NSMutablearray1
- x2= random object out of NSMutablearray1
- x3= random object out of NSMutablearray1
###Round 2 (x3 starts):
- x3= random object out of NSMutablearray1
- x2= random object out of NSMutablearray1
- x1= random object out of NSMutablearray2
###Round 3 (x1 starts):
- x1= random object out of NSMutablearray2
- x2= random object out of NSMutablearray2
- x3= random object out of NSMutablearray3
###Round 4 (x3 starts):
- x3= random object out of NSMutablearray3
- x2= random object out of NSMutablearray3
- x1= random object out of NSMutablearray3
###Round 5 (x1 starts):
- x1= random object out of NSMutablearray3
- x2= random object out of NSMutablearray3
- x3= random object out of NSMutablearray4
###Round 6 (x3 starts):
- x3= random object out of NSMutablearray4
- x2= random object out of NSMutablearray5
###This is my expected result:
- x1=a3,b3,b1,c3,c2,
- x2=a2,a1,b2,c1,c4,e1
- x3=a5,a4,b3,c5,d2,d1
How can i implement this in objective-c ?
I have the arrays and the groups but i dont now how can i fill the groups randomly with equal distrubution?
Thanks | 0debug |
static void qmp_input_type_null(Visitor *v, const char *name, Error **errp)
{
QmpInputVisitor *qiv = to_qiv(v);
QObject *qobj = qmp_input_get_object(qiv, name, true, errp);
if (!qobj) {
return;
}
if (qobject_type(qobj) != QTYPE_QNULL) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"null");
}
}
| 1threat |
parse json file using c# : <p>I need to parse a JSON file using C# into smaller parts.
I would like to know how can I parse the JSON to get each product like below from "product"(since I need to store each smaller json in other places)? What kind of code I need to write?</p>
<pre><code>"76V3SF2FJC3ZR3GH" : {
"id" : "76V3SF2FJC3ZR3GH",
"attribute1": "AAAAA",
"attribute2": "BBBBB",
"attribute3": "CCCCC"
}
</code></pre>
<p>Example of JSON is like:</p>
<pre><code>{
"A" : "XXXXX",
"B" : "XXXXX",
"C" : "XXXXXX",
"D" : "XXXXX",
"products" : {
"76V3SF2FJC3ZR3GH" : {
"id" : "76V3SF2FJC3ZR3GH",
"attribute1": "AAAAA",
"attribute2": "BBBBB",
"attribute3": "CCCCC"
},
"RDXNGJU5DRW4G5ZK" : {
"id" : "RDXNGJU5DRW4G5ZK",
"attribute1": "AAAAA",
"attribute2": "BBBBB",
"attribute3": "CCCCC"
},
......
}
}
</code></pre>
| 0debug |
unable to access git remote repository : <pre><code>C:\Users\sai\Downloads\mycomputer\STUDY\CI\second>git remote add origin https://github.com/saikrishnamelam94/helloworld.git
C:\Users\sai\Downloads\mycomputer\STUDY\CI\second>git push -u origin master
remote: Permission to saikrishnamelam94/helloworld.git denied to saikrishnamelam.
fatal: unable to access 'https://github.com/saikrishnamelam94/helloworld.git/': The requested URL returned error: 403
C:\Users\sai\Downloads\mycomputer\STUDY\CI\second>
</code></pre>
<p>can any one tell me whats wrong here ?</p>
| 0debug |
static void qmp_input_pop(QmpInputVisitor *qiv, Error **errp)
{
StackObject *tos = &qiv->stack[qiv->nb_stack - 1];
assert(qiv->nb_stack > 0);
if (qiv->strict) {
GHashTable *const top_ht = tos->h;
if (top_ht) {
GHashTableIter iter;
const char *key;
g_hash_table_iter_init(&iter, top_ht);
if (g_hash_table_iter_next(&iter, (void **)&key, NULL)) {
error_setg(errp, QERR_QMP_EXTRA_MEMBER, key);
}
g_hash_table_unref(top_ht);
}
tos->h = NULL;
}
qiv->nb_stack--;
}
| 1threat |
Array to string conversion : <p>I have view like this</p>
<pre><code> <?php foreach((array)$query as $row): ?>
<tr>
<td></td>
<td><?php echo $row->id_jeans ?></td>
<td><?php echo $row->nama ?></td>
<td><?php echo $row->ket ?></td>
<td><?php echo $row->tglmulai ?></td>
<td><?php echo $row->tglselesai ?></td>
<?php $cari = $this->db->query("select sum(bahanbenang.biaya)
FROM bahanbenang WHERE id_benang IN('$row->benang')"); ?>
<td><?php echo $cari->result_array();?></td>
</code></pre>
<p>and error</p>
<p>A PHP Error was encountered</p>
<p>Severity: Notice</p>
<p>Message: Array to string conversion</p>
<p>I anyone help me?</p>
| 0debug |
static int qcow2_check(BlockDriverState *bs, BdrvCheckResult *result,
BdrvCheckMode fix)
{
int ret = qcow2_check_refcounts(bs, result, fix);
if (ret < 0) {
return ret;
}
if (fix && result->check_errors == 0 && result->corruptions == 0) {
return qcow2_mark_clean(bs);
}
return ret;
}
| 1threat |
rewrite seo friendly url in yii2 : How can I rewrite urls in Yii2. I want to rewrite url
<b>category/index?id=1</b>
to
<b>fenlei/pingmiansheji</b>
| 0debug |
What are the retry strategy/ mechanism for WorkManager's OneTimeWorkRequest : <p>I have the following one-time worker.</p>
<pre><code>// Create a Constraints that defines when the task should run
Constraints constraints = new Constraints.Builder()
.setRequiredNetworkType(NetworkType.UNMETERED)
.setRequiresBatteryNotLow(true)
// Many other constraints are available, see the
// Constraints.Builder reference
.build();
OneTimeWorkRequest oneTimeWorkRequest =
new OneTimeWorkRequest.Builder(SyncWorker.class)
.setConstraints(constraints)
.addTag(SyncWorker.TAG)
.build();
</code></pre>
<p>According to <a href="https://developer.android.com/topic/libraries/architecture/workmanager" rel="noreferrer">https://developer.android.com/topic/libraries/architecture/workmanager</a></p>
<pre><code>// (Returning RETRY tells WorkManager to try this task again
// later; FAILURE says not to try again.)
</code></pre>
<p>I was wondering, if <code>SyncWorker</code> keep returning <code>RETRY</code>, what is the retry strategy of <code>WorkManager</code>? For instance, what is the maximum retry count for <code>WorkManager</code>? The documentation isn't clear on this.</p>
| 0debug |
What should i choose for command like application between Ruby or python : <p>This is very first I am writing command line tool apps. Apps has few custom command which forks a repo from github and CD's into it. Command can also submit new code and rise new pull request. There might be also some application login before submit/pull-request also.</p>
<p>After few research i found , there are serval options such as
- Bash
- <strong>Ruby</strong>
- python</p>
<p>(i know python but don't have any problem learning ruby as well. It hard to write business logic in Bash, so bash is not i am looking for)</p>
<p>Ruby seems to be more rich when it come to command like tool. Thor
is a famous lib for doing this in ruby</p>
<p>Python can also do same stuff with command line with Cement Framework and click.</p>
<p>Wanted to know which one is preferred when it comes to writing command line apps like this. </p>
| 0debug |
static int epzs_motion_search(MpegEncContext * s,
int *mx_ptr, int *my_ptr,
int P[5][2], int pred_x, int pred_y,
int xmin, int ymin, int xmax, int ymax)
{
int best[2]={0, 0};
int d, dmin;
UINT8 *new_pic, *old_pic;
const int pic_stride= s->linesize;
const int pic_xy= (s->mb_y*pic_stride + s->mb_x)*16;
UINT16 *mv_penalty= s->mv_penalty[s->f_code] + MAX_MV;
int quant= s->qscale;
const int shift= 1+s->quarter_sample;
new_pic = s->new_picture[0] + pic_xy;
old_pic = s->last_picture[0] + pic_xy;
dmin = pix_abs16x16(new_pic, old_pic, pic_stride, 16);
if(dmin<Z_THRESHOLD){
*mx_ptr= 0;
*my_ptr= 0;
return dmin;
}
if ((s->mb_y == 0 || s->first_slice_line || s->first_gob_line)) {
CHECK_MV(P[1][0]>>shift, P[1][1]>>shift)
}else{
CHECK_MV(P[4][0]>>shift, P[4][1]>>shift)
if(dmin<Z_THRESHOLD){
*mx_ptr= P[4][0]>>shift;
*my_ptr= P[4][1]>>shift;
return dmin;
}
CHECK_MV(P[1][0]>>shift, P[1][1]>>shift)
CHECK_MV(P[2][0]>>shift, P[2][1]>>shift)
CHECK_MV(P[3][0]>>shift, P[3][1]>>shift)
}
CHECK_MV(P[0][0]>>shift, P[0][1]>>shift)
dmin= small_diamond_search(s, best, dmin, new_pic, old_pic, pic_stride,
pred_x, pred_y, mv_penalty, quant, xmin, ymin, xmax, ymax, shift);
*mx_ptr= best[0];
*my_ptr= best[1];
return dmin;
}
| 1threat |
window.location.href = 'http://attack.com?user=' + user_input; | 1threat |
Android:How to sand data Activity to Fragment using Broadcast Receiver : Sand data from Activity to Fragment in Android using broadcast receiver.I know there is varies way to communicate activity to fragment.
but i don't know how to sand data and receive using broadcast receiver.I'm new in android development
please give me your voluble Suggestions
Thank you
| 0debug |
void sth_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint16_t val)
{
val = tswap16(val);
spapr_tce_dma_write(dev, taddr, &val, sizeof(val));
}
| 1threat |
how to convert negative float number into binary vector in java : Can anyone please tell me how can I convert this float number: -2.25 to binary?
I know how to convert the "2" but not the 0.25 nor the negative sign
this is my method and I stuck there I could not know how to enhance it to give me correct result when converting float, negative int or negative float number
p
ublic class MinimizeRastriginFunction {
public static String binary="";
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
//float x=(float) 2.5;
int x =5 ;
System.out.println("Before :" + x);
decToBin(x);
System.out.println("After :" + binary);
}
private static Object decToBin(int dec) {
// TODO Auto-generated method stub
int num;
if (dec <=1) {
binary +=dec;
return null; // KICK OUT OF THE RECURSION
}
num= dec %2;
decToBin(dec >>1);
binary += num;
return null;
}
| 0debug |
How to get the format of a date passed as string in Java : <p>I Am passing date as string
Input: "8 Aug 2016"</p>
<p>I want output as format of above date i.e.</p>
<p>Output: DD MMM YYYY</p>
<p>Can anyone help here? </p>
| 0debug |
React Native code doesn't work without Remote Debugger enabled : <p>This a weird question, but since I'm really curious about this I wanted to ask. I have a piece of code that works in the iOS Simulator when I enable Remote Debugging but it stops working without it. This is the code:</p>
<pre><code> let filtered = []
let dueDate
const dateNow = new Date(Date.now())
for (let item of this.props.listData) {
dueDate = new Date(item.dueDate)
if (!item.paid && (dueDate < dateNow)) {
filtered.push(item)
}
}
if (filtered.length > 0) {
this.setState({
dataSource: this.state.dataSource.cloneWithRows(filtered)
})
}
</code></pre>
<p>(item.dueDate is a string like "12.02.2016")</p>
<p>Obviously the code would work (and it works) if I supplied the date in a correct format (like ISO "2016-02-12"). What interests me is why does it work even with the wrong format when I enable Remote Debugging (which fires up a Google Chrome instance)? Because when I console.log the dates in Chrome they are converted normally. Thanks in advance!</p>
| 0debug |
ow can i populate a combox from database through jstl : <p>Can any one assist me am trying to populate a dropdown box with data in my database using jstl but unable to get the solution. below is my code </p>
<p>
SELECT MarketPlace from tblmarketplace
</p>
<pre><code> <c:forEach var = "row" items = "${carsList1.rows}">
<c:set var="MarketPlace" value="${row.MarketPlace}"/>
</c:forEach>
</code></pre>
<p>Payment Method
</p>
<pre><code> <option style="width : 150px;" rows="6" value="CASH">CASH</option>
<option style="width : 150px;" rows="6"items="${MarketPlace}">${MarketPlace}</option></select><br><br>
</code></pre>
| 0debug |
fdctrl_t *fdctrl_init (qemu_irq irq, int dma_chann, int mem_mapped,
target_phys_addr_t io_base,
BlockDriverState **fds)
{
fdctrl_t *fdctrl;
int io_mem;
int i;
FLOPPY_DPRINTF("init controller\n");
fdctrl = qemu_mallocz(sizeof(fdctrl_t));
if (!fdctrl)
return NULL;
fdctrl->fifo = qemu_memalign(512, FD_SECTOR_LEN);
if (fdctrl->fifo == NULL) {
qemu_free(fdctrl);
return NULL;
}
fdctrl->result_timer = qemu_new_timer(vm_clock,
fdctrl_result_timer, fdctrl);
fdctrl->version = 0x90;
fdctrl->irq = irq;
fdctrl->dma_chann = dma_chann;
fdctrl->io_base = io_base;
fdctrl->config = 0x60;
fdctrl->sun4m = 0;
if (fdctrl->dma_chann != -1) {
fdctrl->dma_en = 1;
DMA_register_channel(dma_chann, &fdctrl_transfer_handler, fdctrl);
} else {
fdctrl->dma_en = 0;
}
for (i = 0; i < 2; i++) {
fd_init(&fdctrl->drives[i], fds[i]);
}
fdctrl_reset(fdctrl, 0);
fdctrl->state = FD_CTRL_ACTIVE;
if (mem_mapped) {
io_mem = cpu_register_io_memory(0, fdctrl_mem_read, fdctrl_mem_write,
fdctrl);
cpu_register_physical_memory(io_base, 0x08, io_mem);
} else {
register_ioport_read((uint32_t)io_base + 0x01, 5, 1, &fdctrl_read,
fdctrl);
register_ioport_read((uint32_t)io_base + 0x07, 1, 1, &fdctrl_read,
fdctrl);
register_ioport_write((uint32_t)io_base + 0x01, 5, 1, &fdctrl_write,
fdctrl);
register_ioport_write((uint32_t)io_base + 0x07, 1, 1, &fdctrl_write,
fdctrl);
}
register_savevm("fdc", io_base, 1, fdc_save, fdc_load, fdctrl);
qemu_register_reset(fdctrl_external_reset, fdctrl);
for (i = 0; i < 2; i++) {
fd_revalidate(&fdctrl->drives[i]);
}
return fdctrl;
}
| 1threat |
static int parse_read_intervals(const char *intervals_spec)
{
int ret, n, i;
char *p, *spec = av_strdup(intervals_spec);
if (!spec)
return AVERROR(ENOMEM);
for (n = 0, p = spec; *p; p++)
if (*p == ',')
n++;
n++;
read_intervals = av_malloc(n * sizeof(*read_intervals));
if (!read_intervals) {
ret = AVERROR(ENOMEM);
goto end;
}
read_intervals_nb = n;
p = spec;
for (i = 0; i < n; i++) {
char *next = strchr(p, ',');
if (next)
*next++ = 0;
read_intervals[i].id = i;
ret = parse_read_interval(p, &read_intervals[i]);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Error parsing read interval #%d '%s'\n",
i, p);
goto end;
}
av_log(NULL, AV_LOG_VERBOSE, "Parsed log interval ");
log_read_interval(&read_intervals[i], NULL, AV_LOG_VERBOSE);
p = next;
av_assert0(i <= read_intervals_nb);
}
av_assert0(i == read_intervals_nb);
end:
av_free(spec);
return ret;
}
| 1threat |
Full screen IOS : <p>I just started on Xcode, and i have a little problem
I would like to display the application on the entire screen</p>
<p><a href="http://i.stack.imgur.com/NyXJ1.jpg" rel="nofollow">enter image description here</a></p>
| 0debug |
How is "a monoid on applicative functors" different than "a monoid in the category of endofunctors"? : <p>Perhaps neither of these statements are categorically precise, but a monad is often defined as "a monoid in the category of endofunctors"; a Haskell <a href="https://hackage.haskell.org/package/base-4.11.1.0/docs/Control-Applicative.html#t:Alternative" rel="noreferrer"><code>Alternative</code></a> is defined as "a monoid on applicative functors", where an <a href="https://hackage.haskell.org/package/base-4.11.1.0/docs/Control-Applicative.html" rel="noreferrer">applicative functor</a> is a "strong lax monoidal functor". Now these two definitions sound pretty similar to the ignorant (me), but work out significantly differently. The neutral element for alternative has type <code>f a</code> and is thus "empty", and for monad has type <code>a -> m a</code> and thus has the sense "non-empty"; the operation for alternative has type <code>f a -> f a -> f a</code>, and the operation for monad has type <code>(a -> f b) -> (b -> f c) -> (a -> f c)</code>. It seems to me that the real important detail is <em>in the category of endofunctors</em> versus <em>over endofunctors</em>, though perhaps the "strong lax" detail in alternative is important; but that's where I get confused because within Haskell at least, monads end up being alternatives: and I see that I do not yet have a precise categorical understanding of all the details here.</p>
<p>How can it be precisely expresseed what the difference is between alternative and monad, such that they are both monoids relating to endofunctors, and yet the one has an "empty" neutral and the other has a "non-empty" neutral element?</p>
| 0debug |
Split delimited string and remove escape sequences : <p>I need to split a comma separated string, which contents are sometimes between quotes. An example could be:</p>
<blockquote>
<p>1,"TEST",22345,"18,95", Ab"cde</p>
</blockquote>
<p>The first problem here is to split the string only when the comma is not surrounded by quotes like "18,95". I've done that with a simple Regex. The next problem is to cut out the quotes, where they surround the content. For "TEST" and "18,95" the quotes should be removed.The quote in Ab"cde should be left untouched. Here is my code so far:</p>
<pre><code>List<string> results = Regex.Matches(this.Content, @"[\""](.+?)[\""]|[^,]+")
.Cast<Match>()
.Select(m => m.Value)
.Select(s => s.StartsWith("\"") && s.EndsWith("\"") ? s.Remove(1,1).Remove(s.Length-1,1) : s)
.ToList();
</code></pre>
<p>For the second <code>Select</code> I get an <code>ArgumentOutOfRangeException</code> since the second <code>Remove</code> doesn't work with <code>s</code> anymore. I thought it should work, but somehow doesn't.</p>
<p>If there is a better way to do this I would be happy to learn about it.</p>
| 0debug |
static int64_t getutime(void)
{
#ifdef HAVE_GETRUSAGE
struct rusage rusage;
getrusage(RUSAGE_SELF, &rusage);
return (rusage.ru_utime.tv_sec * 1000000LL) + rusage.ru_utime.tv_usec;
#elif defined(__MINGW32__)
return av_gettime();
#endif
}
| 1threat |
Removing cached files after a py.test run : <p>I'm using a <code>joblib.Memory</code> to cache expensive computations when running tests with <code>py.test</code>. The code I'm using reduces to the following,</p>
<pre><code>from joblib import Memory
memory = Memory(cachedir='/tmp/')
@memory.cache
def expensive_function(x):
return x**2 # some computationally expensive operation here
def test_other_function():
input_ds = expensive_function(x=10)
## run some tests with input_ds
</code></pre>
<p>which works fine. I'm aware this could be possibly more elegantly done with <a href="http://docs.pytest.org/en/latest/tmpdir.html" rel="noreferrer"><code>tmpdir_factory</code></a> fixture but that's beside the point.</p>
<p>The issue I'm having is how to clean the cached files once all the tests run,</p>
<ul>
<li>is it possible to share a global variable among all tests (which would contains e.g. a list of path to the cached objects) ?</li>
<li>is there a mechanism in py.test to call some command once all the tests are run (whether they succeed or not)?</li>
</ul>
| 0debug |
int av_cold ff_ivi_init_tiles(IVIPlaneDesc *planes, int tile_width, int tile_height)
{
int p, b, x, y, x_tiles, y_tiles, t_width, t_height;
IVIBandDesc *band;
IVITile *tile, *ref_tile;
for (p = 0; p < 3; p++) {
t_width = !p ? tile_width : (tile_width + 3) >> 2;
t_height = !p ? tile_height : (tile_height + 3) >> 2;
if (!p && planes[0].num_bands == 4) {
t_width >>= 1;
t_height >>= 1;
}
for (b = 0; b < planes[p].num_bands; b++) {
band = &planes[p].bands[b];
x_tiles = IVI_NUM_TILES(band->width, t_width);
y_tiles = IVI_NUM_TILES(band->height, t_height);
band->num_tiles = x_tiles * y_tiles;
av_freep(&band->tiles);
band->tiles = av_mallocz(band->num_tiles * sizeof(IVITile));
if (!band->tiles)
return AVERROR(ENOMEM);
tile = band->tiles;
ref_tile = planes[0].bands[0].tiles;
for (y = 0; y < band->height; y += t_height) {
for (x = 0; x < band->width; x += t_width) {
tile->xpos = x;
tile->ypos = y;
tile->width = FFMIN(band->width - x, t_width);
tile->height = FFMIN(band->height - y, t_height);
tile->is_empty = tile->data_size = 0;
tile->num_MBs = IVI_MBs_PER_TILE(tile->width, tile->height,
band->mb_size);
av_freep(&tile->mbs);
tile->mbs = av_malloc(tile->num_MBs * sizeof(IVIMbInfo));
if (!tile->mbs)
return AVERROR(ENOMEM);
tile->ref_mbs = 0;
if (p || b) {
tile->ref_mbs = ref_tile->mbs;
ref_tile++;
}
tile++;
}
}
}
}
return 0;
} | 1threat |
Data.table - group by with custom functions that returns a matrix : I have below Data.table
library(data.table)
DT = as.data.table(data.frame(Z=c("abc","abc","def","abc"), column=c(1,2,3,4), someOtherColumn=c(5,6,7,8)))
Fn = function(DT1) {
Value = as.numeric(DT1[1, 2])
Calc = sapply(DT1[, c("Z"):=NULL], sum) - Value
return(matrix(Calc, nr = 1, nc = length(Calc)))
}
Now, I want to apply `Fn()` to each group formed by `'Z'`, and get a resulting matrix with 2 rows (because there are 2 unique members in `DT$Z`) and 2 rows
DT[, Fn(.SD), by = Z, .SDcols = c('Z', 'column', 'someOtherColumn')]
But with that I am getting error as
Error in `[.data.table`(DT1, , `:=`(c("Z"), NULL)) :
.SD is locked. Using := in .SD's j is reserved for possible future use; a tortuously flexible way to modify by group. Use := in j directly to modify by group by reference.
Any pointer towards the right approach to achieve that same will be helpful.
I have a quick big `DT, so am looking for some efficient method.` | 0debug |
static void gen_muldiv (DisasContext *ctx, uint32_t opc,
int rs, int rt)
{
const char *opn = "mul/div";
TCGv t0, t1;
unsigned int acc;
switch (opc) {
case OPC_DIV:
case OPC_DIVU:
#if defined(TARGET_MIPS64)
case OPC_DDIV:
case OPC_DDIVU:
#endif
t0 = tcg_temp_local_new();
t1 = tcg_temp_local_new();
break;
default:
t0 = tcg_temp_new();
t1 = tcg_temp_new();
break;
}
gen_load_gpr(t0, rs);
gen_load_gpr(t1, rt);
switch (opc) {
case OPC_DIV:
{
int l1 = gen_new_label();
int l2 = gen_new_label();
tcg_gen_ext32s_tl(t0, t0);
tcg_gen_ext32s_tl(t1, t1);
tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
tcg_gen_brcondi_tl(TCG_COND_NE, t0, INT_MIN, l2);
tcg_gen_brcondi_tl(TCG_COND_NE, t1, -1, l2);
tcg_gen_mov_tl(cpu_LO[0], t0);
tcg_gen_movi_tl(cpu_HI[0], 0);
tcg_gen_br(l1);
gen_set_label(l2);
tcg_gen_div_tl(cpu_LO[0], t0, t1);
tcg_gen_rem_tl(cpu_HI[0], t0, t1);
tcg_gen_ext32s_tl(cpu_LO[0], cpu_LO[0]);
tcg_gen_ext32s_tl(cpu_HI[0], cpu_HI[0]);
gen_set_label(l1);
}
opn = "div";
break;
case OPC_DIVU:
{
int l1 = gen_new_label();
tcg_gen_ext32u_tl(t0, t0);
tcg_gen_ext32u_tl(t1, t1);
tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
tcg_gen_divu_tl(cpu_LO[0], t0, t1);
tcg_gen_remu_tl(cpu_HI[0], t0, t1);
tcg_gen_ext32s_tl(cpu_LO[0], cpu_LO[0]);
tcg_gen_ext32s_tl(cpu_HI[0], cpu_HI[0]);
gen_set_label(l1);
}
opn = "divu";
break;
case OPC_MULT:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
acc = ((ctx->opcode) >> 11) & 0x03;
if (acc != 0) {
check_dsp(ctx);
}
tcg_gen_ext_tl_i64(t2, t0);
tcg_gen_ext_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[acc], t0);
tcg_gen_ext32s_tl(cpu_HI[acc], t1);
}
opn = "mult";
break;
case OPC_MULTU:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
acc = ((ctx->opcode) >> 11) & 0x03;
if (acc != 0) {
check_dsp(ctx);
}
tcg_gen_ext32u_tl(t0, t0);
tcg_gen_ext32u_tl(t1, t1);
tcg_gen_extu_tl_i64(t2, t0);
tcg_gen_extu_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[acc], t0);
tcg_gen_ext32s_tl(cpu_HI[acc], t1);
}
opn = "multu";
break;
#if defined(TARGET_MIPS64)
case OPC_DDIV:
{
int l1 = gen_new_label();
int l2 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
tcg_gen_brcondi_tl(TCG_COND_NE, t0, -1LL << 63, l2);
tcg_gen_brcondi_tl(TCG_COND_NE, t1, -1LL, l2);
tcg_gen_mov_tl(cpu_LO[0], t0);
tcg_gen_movi_tl(cpu_HI[0], 0);
tcg_gen_br(l1);
gen_set_label(l2);
tcg_gen_div_i64(cpu_LO[0], t0, t1);
tcg_gen_rem_i64(cpu_HI[0], t0, t1);
gen_set_label(l1);
}
opn = "ddiv";
break;
case OPC_DDIVU:
{
int l1 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
tcg_gen_divu_i64(cpu_LO[0], t0, t1);
tcg_gen_remu_i64(cpu_HI[0], t0, t1);
gen_set_label(l1);
}
opn = "ddivu";
break;
case OPC_DMULT:
gen_helper_dmult(cpu_env, t0, t1);
opn = "dmult";
break;
case OPC_DMULTU:
gen_helper_dmultu(cpu_env, t0, t1);
opn = "dmultu";
break;
#endif
case OPC_MADD:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
acc = ((ctx->opcode) >> 11) & 0x03;
if (acc != 0) {
check_dsp(ctx);
}
tcg_gen_ext_tl_i64(t2, t0);
tcg_gen_ext_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_gen_concat_tl_i64(t3, cpu_LO[acc], cpu_HI[acc]);
tcg_gen_add_i64(t2, t2, t3);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[acc], t0);
tcg_gen_ext32s_tl(cpu_HI[acc], t1);
}
opn = "madd";
break;
case OPC_MADDU:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
acc = ((ctx->opcode) >> 11) & 0x03;
if (acc != 0) {
check_dsp(ctx);
}
tcg_gen_ext32u_tl(t0, t0);
tcg_gen_ext32u_tl(t1, t1);
tcg_gen_extu_tl_i64(t2, t0);
tcg_gen_extu_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_gen_concat_tl_i64(t3, cpu_LO[acc], cpu_HI[acc]);
tcg_gen_add_i64(t2, t2, t3);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[acc], t0);
tcg_gen_ext32s_tl(cpu_HI[acc], t1);
}
opn = "maddu";
break;
case OPC_MSUB:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
acc = ((ctx->opcode) >> 11) & 0x03;
if (acc != 0) {
check_dsp(ctx);
}
tcg_gen_ext_tl_i64(t2, t0);
tcg_gen_ext_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_gen_concat_tl_i64(t3, cpu_LO[acc], cpu_HI[acc]);
tcg_gen_sub_i64(t2, t3, t2);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[acc], t0);
tcg_gen_ext32s_tl(cpu_HI[acc], t1);
}
opn = "msub";
break;
case OPC_MSUBU:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
acc = ((ctx->opcode) >> 11) & 0x03;
if (acc != 0) {
check_dsp(ctx);
}
tcg_gen_ext32u_tl(t0, t0);
tcg_gen_ext32u_tl(t1, t1);
tcg_gen_extu_tl_i64(t2, t0);
tcg_gen_extu_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_gen_concat_tl_i64(t3, cpu_LO[acc], cpu_HI[acc]);
tcg_gen_sub_i64(t2, t3, t2);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[acc], t0);
tcg_gen_ext32s_tl(cpu_HI[acc], t1);
}
opn = "msubu";
break;
default:
MIPS_INVAL(opn);
generate_exception(ctx, EXCP_RI);
goto out;
}
(void)opn;
MIPS_DEBUG("%s %s %s", opn, regnames[rs], regnames[rt]);
out:
tcg_temp_free(t0);
tcg_temp_free(t1);
}
| 1threat |
How to insert PHP inside Javascript inside HTML inside PHP? : <p>I have the following script who list some sql values in a table</p>
<pre><code>while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC)) {
$idOfUrl = $row['2'];
echo("<tr onclick='window.location.href = \"
// how can i insert here a php value ? --> $idOfUrl
\"';>");
echo("<td>");
echo $row['1'];
echo("</td>");
echo ("</tr>");
echo("</a>");
}
</code></pre>
<p>I want to make the entire row clickable to a page with an ID whos from the SQL table. </p>
<p>Thank you in advance !</p>
| 0debug |
using pip3: module "importlib._bootstrap" has no attribute "SourceFileLoader" : <p>I have installed pip for python 3.6 on Ubuntu 14. After I run</p>
<pre><code>sudo apt-get install python3-pip
</code></pre>
<p>to install pip3, it works very well. However, after installation, when I am trying to run</p>
<pre><code>pip3 install packagename
</code></pre>
<p>to install a new package, something strange occurs:</p>
<pre><code>File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1479, in <module>
register_loader-type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module "importlib._bootstrap" has no attribute "SourceFileLoader"
</code></pre>
<p>It seems that I did nothing wrong, and I really cannot figure out the reason.</p>
| 0debug |
Android app with sqlite database : <p>I am developing an android app in which I have to use sqlite database.I have implemented several codes but didn't worked.So, Please give me a sample code for a sample app based on Sqlite.</p>
| 0debug |
static void digic_uart_write(void *opaque, hwaddr addr, uint64_t value,
unsigned size)
{
DigicUartState *s = opaque;
unsigned char ch = value;
addr >>= 2;
switch (addr) {
case R_TX:
if (s->chr) {
qemu_chr_fe_write_all(s->chr, &ch, 1);
}
break;
case R_ST:
break;
default:
qemu_log_mask(LOG_UNIMP,
"digic-uart: write access to unknown register 0x"
TARGET_FMT_plx, addr << 2);
}
} | 1threat |
What are python's equivalents of std::lower_bound and std::upper_bound C++ algorithms? : <p>Does python provide functions for performing binary search on sorted lists, analogous to the <code>std::lower_bound</code> and <code>std::upper_bound</code> algorithms of the C++ Standard Library?</p>
| 0debug |
Hey guys, I've got a Syntax Error while doing SQL, Heres my code : SELECT Title AS 'Title of Item', PubYear AS 'Year of Publication', Round(ReplacementCost/1.1 AS 'ReplacementCost(Actual)', 1), Round(LostFee/1.1 AS 'LostFee(Actual)', 1)
FROM Item
WHERE PubYear IN (2001, 2002)
Sorry about the formatting of my SELECT query, It's quite long | 0debug |
Bootstraps Valitor ? : I'm using Bootstraps frameworks to build a website and I woud like to know if some kind of "validator" tool exist. (kind of like html 4 valitor form W3C)
I search on google I didn't find what I was looking for.
Thanks guys. | 0debug |
Aligning <div> in vertically center : <p>I cannot align <code>#container</code> and its content in the center vertically. I thought adding further <code><div></code> tags would be a problematic and I cannot control them.</p>
<p>I want the text and <code>#container</code> to be aligned in the center of <code>.content</code> vertically without adding any extra space.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>#container {
display: grid;
padding: 20px;
grid-template-areas: 'sideone sideone sidetwo sidetwo sidethree sidethree';
grid-gap: 20px;
text-align: center;
}
.content {
display: table;
margin: 15px;
height: 500px;
width: 100%;
transition-duration: 0.15s;
border: 2px solid #3B3B3B;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="content">
<div id="container">
<div style="grid-area: sideone;">
<p>あ - ა</p>
<p>い - ი</p>
<p>う - უ</p>
<p>え - ე</p>
<p>お - ო</p>
</div>
<div style="grid-area: sidetwo">
<p>か - კა</p>
<p>さ - სა</p>
<p>た - ტა</p>
<p>な - მა</p>
<p>は - ჰა</p>
</div>
<div style="grid-area: sidethree">
<p>き - კი</p>
<p>し - ში</p>
<p>ち - ჩი</p>
<p>に - ნი</p>
<p>み - მი</p>
</div>
</div>
</div></code></pre>
</div>
</div>
</p>
| 0debug |
Is asp.net mvc and asp.net mvc core is same or merged : I want to start learning `ASP.NET MVC`just after reading first article I got doubt that
Is `asp.net mvc` and `asp.net mvc core` is totally different and using different code functionalities OR these two are same now?
I know that `core` is new release of *Microsoft*, so is it running separate or directly merged to `mvc`. I am thinking if core is different than we have four types of different applications to develop like `asp.net`, `asp.net core`, `asp.net mvc`, `asp.net core`.
If I am learning `mvc` does it mean I am learning `mvc core` or do `mvc core` have different tutorials, code, projects etc.. | 0debug |
Is it possible to filter options requests in chrome inspector? : <p>I'm building a web application which uses CORS to communicate with it's server.</p>
<p>This means that every request is preceded by one with OPTIONS method.</p>
<p>Is it possible to filter those out in inspector? It makes a lot of unnecessary clutter on network tab.</p>
| 0debug |
DOS script to change names with some logic : I have a directory with the following layout :
1 януари 2012
2 февруари 2012
1 януари 2013
and I want it to look like this yyyy-mm-dd:
2012-01-01
2012-02-01
2013-01-01
**Януари / февруари** are Cyrillic names of months so they map easily to numbers - **01 / 02**.
The script basically has to :
1. take a dir name
2. rename it in the correct format
I am very new to DOS scripting so if you could help me it would be great.
Thank you
| 0debug |
How to use search(in google map) between 2 activities using intent(or something) : <p>i want a make application </p>
<ol>
<li>MainActivity( EditText )
<ul>
<li>put address</li>
</ul></li>
<li>SearchActivity( google map )
<ul>
<li>searching and movecamera using address from MainActivity</li>
</ul></li>
</ol>
<p>like this.</p>
<p>but i can't find any way....</p>
| 0debug |
static void disas_cc(DisasContext *s, uint32_t insn)
{
unsigned int sf, op, y, cond, rn, nzcv, is_imm;
int label_continue = -1;
TCGv_i64 tcg_tmp, tcg_y, tcg_rn;
if (!extract32(insn, 29, 1)) {
unallocated_encoding(s);
return;
}
if (insn & (1 << 10 | 1 << 4)) {
unallocated_encoding(s);
return;
}
sf = extract32(insn, 31, 1);
op = extract32(insn, 30, 1);
is_imm = extract32(insn, 11, 1);
y = extract32(insn, 16, 5);
cond = extract32(insn, 12, 4);
rn = extract32(insn, 5, 5);
nzcv = extract32(insn, 0, 4);
if (cond < 0x0e) {
int label_match = gen_new_label();
label_continue = gen_new_label();
arm_gen_test_cc(cond, label_match);
tcg_tmp = tcg_temp_new_i64();
tcg_gen_movi_i64(tcg_tmp, nzcv << 28);
gen_set_nzcv(tcg_tmp);
tcg_temp_free_i64(tcg_tmp);
tcg_gen_br(label_continue);
gen_set_label(label_match);
}
if (is_imm) {
tcg_y = new_tmp_a64(s);
tcg_gen_movi_i64(tcg_y, y);
} else {
tcg_y = cpu_reg(s, y);
}
tcg_rn = cpu_reg(s, rn);
tcg_tmp = tcg_temp_new_i64();
if (op) {
gen_sub_CC(sf, tcg_tmp, tcg_rn, tcg_y);
} else {
gen_add_CC(sf, tcg_tmp, tcg_rn, tcg_y);
}
tcg_temp_free_i64(tcg_tmp);
if (cond < 0x0e) {
gen_set_label(label_continue);
}
}
| 1threat |
START_TEST(qfloat_from_double_test)
{
QFloat *qf;
const double value = -42.23423;
qf = qfloat_from_double(value);
fail_unless(qf != NULL);
fail_unless(qf->value == value);
fail_unless(qf->base.refcnt == 1);
fail_unless(qobject_type(QOBJECT(qf)) == QTYPE_QFLOAT);
g_free(qf);
}
| 1threat |
Basic vue.js 2 and vue-resource http get with variable assignment : <p>I'm really struggling to get the most basic REST functionality to work in vue.js 2.</p>
<p>I'd like to get data from some endpoint and assign the returned value to a variable of my Vue instance. Here's how far I got.</p>
<pre><code>var link = 'https://jsonplaceholder.typicode.com/users';
var users;
Vue.http.get(link).then(function(response){
users = response.data;
}, function(error){
console.log(error.statusText);
});
new Vue ({
el: '#user-list',
data: {
list: users
}
});
</code></pre>
<p>Inside the promise, I can access the response data, but I cannot seem to assign it to users or even to data of the Vue instance.</p>
<p>Needless to say, I'm completely new to vue.js and thankful for any help.</p>
<p>Stack: vue.js 2.03, vue-resource 1.0.3</p>
<p>Cheers!</p>
| 0debug |
Android 5+ custom notification XML layout with RemoteViews, set correct icon tint for ImageButton : <p>My app is using a custom Notification layout with RemoteViews.</p>
<p>To display text, the layout is using the following system styles:</p>
<p><code>android:TextAppearance.Material.Notification.Title</code>
<code>android:TextAppearance.Material.Notification</code></p>
<p>This works fine.</p>
<p>However, the TextAppearance style can't be used to set the value of <code>android:tint</code>, so I had to hardcode the color.</p>
<p>To my best knowledge, there's no special system style for setting notification ImageButton tint.</p>
<p>Hardcoded colors work fine on the current Android 5+ systems, but some users install custom ROMs with custom dark themes, and the notification looks wrong, i.e. black icons on black background.</p>
<p>Is there any way to get the system notification icon / imagebutton color, and apply it from an XML layout?</p>
<p>Or maybe there's another way to achieve this?</p>
| 0debug |
Join myql query with array : i have mysql table like this
table test
| idx| name | year | month |
+----+--------+------+-------+
| 1 | foo-u | 2019 | 1 |
| 2 | foo-v | 2019 | 2 |
| 3 | foo-w | 2019 | 3 |
| 4 | foo-x | 2019 | 1 |
| 5 | foo-y | 2019 | 2 |
| 6 | foo-z | 2019 | 3 |
and array like this
$qty = array("1"=>"42", "4"=>"44", "5"=>"54"); //result from unserialize data
how can i join mysql query and $qty array with result like this
| idx| name | year | month | qty |
+----+--------+------+-------+------+
| 1 | foo-u | 2019 | 1 | 42 |
| 4 | foo-x | 2019 | 1 | 44 |
| 5 | foo-y | 2019 | 2 | 54 |
i tried like this
<?php
foreach ($qty as $quantity=>$value){
$product .= $quantity.',';
}
$produk2 = rtrim($product,',');
$sql = "select * from test where idx in ($produk2)";
?>
how can i improve my sql query to inject qty(array value) in my result
thanks
| 0debug |
target_ulong helper_rdhwr_synci_step(CPUMIPSState *env)
{
if ((env->hflags & MIPS_HFLAG_CP0) ||
(env->CP0_HWREna & (1 << 1)))
return env->SYNCI_Step;
else
do_raise_exception(env, EXCP_RI, GETPC());
return 0;
}
| 1threat |
Converting a void to return something : <p>I have this void function in c++</p>
<pre><code>void DrawFace(cv::Mat img, Window face)
{
int x1 = face.x;
int y1 = face.y;
int x2 = face.width + face.x - 1;
int y2 = face.width + face.y - 1;
int centerX = (x1 + x2) / 2;
int centerY = (y1 + y2) / 2;
std::vector<cv::Point> pointList;
pointList.push_back(RotatePoint(x1, y1, centerX, centerY, face.angle));
pointList.push_back(RotatePoint(x1, y2, centerX, centerY, face.angle));
pointList.push_back(RotatePoint(x2, y2, centerX, centerY, face.angle));
pointList.push_back(RotatePoint(x2, y1, centerX, centerY, face.angle));
DrawLine(img, pointList);
}
</code></pre>
<p>i wanted this to return me just the pointList vector for which i made this change </p>
<pre><code>void Drawface(cv::Mat img, Window face)
{
int x1 = face.x;
int y1 = face.y;
int x2 = face.width + face.x - 1;
int y2 = face.width + face.y - 1;
int centerX = (x1 + x2) / 2;
int centerY = (y1 + y2) / 2;
std::vector<cv::Point> pointList;
pointList.push_back(RotatePoint(x1, y1, centerX, centerY, face.angle));
pointList.push_back(RotatePoint(x1, y2, centerX, centerY, face.angle));
pointList.push_back(RotatePoint(x2, y2, centerX, centerY, face.angle));
pointList.push_back(RotatePoint(x2, y1, centerX, centerY, face.angle));
return pointList
}
</code></pre>
<p>It would be really helpful if somebody could point out where i have gone wrong and what changes i could make.</p>
<p>Thanks in advance </p>
| 0debug |
defining functions and index in PostgreSQL : I have 2 questions in Postgres:
1- How can I define(create) these functions?
- AnyElement(s): which returns any element.
- FirstElement(s): which returns the first element.
- lastElement(s): which returns the last element.
- ithElement(s): which returns the ith element.
- currentElement(s): which returns current element.
2- How can I define(create) index?
| 0debug |
static int kvm_put_sregs(CPUState *env)
{
struct kvm_sregs sregs;
memset(sregs.interrupt_bitmap, 0, sizeof(sregs.interrupt_bitmap));
if (env->interrupt_injected >= 0) {
sregs.interrupt_bitmap[env->interrupt_injected / 64] |=
(uint64_t)1 << (env->interrupt_injected % 64);
}
if ((env->eflags & VM_MASK)) {
set_v8086_seg(&sregs.cs, &env->segs[R_CS]);
set_v8086_seg(&sregs.ds, &env->segs[R_DS]);
set_v8086_seg(&sregs.es, &env->segs[R_ES]);
set_v8086_seg(&sregs.fs, &env->segs[R_FS]);
set_v8086_seg(&sregs.gs, &env->segs[R_GS]);
set_v8086_seg(&sregs.ss, &env->segs[R_SS]);
} else {
set_seg(&sregs.cs, &env->segs[R_CS]);
set_seg(&sregs.ds, &env->segs[R_DS]);
set_seg(&sregs.es, &env->segs[R_ES]);
set_seg(&sregs.fs, &env->segs[R_FS]);
set_seg(&sregs.gs, &env->segs[R_GS]);
set_seg(&sregs.ss, &env->segs[R_SS]);
}
set_seg(&sregs.tr, &env->tr);
set_seg(&sregs.ldt, &env->ldt);
sregs.idt.limit = env->idt.limit;
sregs.idt.base = env->idt.base;
sregs.gdt.limit = env->gdt.limit;
sregs.gdt.base = env->gdt.base;
sregs.cr0 = env->cr[0];
sregs.cr2 = env->cr[2];
sregs.cr3 = env->cr[3];
sregs.cr4 = env->cr[4];
sregs.cr8 = cpu_get_apic_tpr(env->apic_state);
sregs.apic_base = cpu_get_apic_base(env->apic_state);
sregs.efer = env->efer;
return kvm_vcpu_ioctl(env, KVM_SET_SREGS, &sregs);
}
| 1threat |
void QEMU_NORETURN do_unassigned_access(target_phys_addr_t addr, int is_write,
int is_exec, int unused, int size)
{
env->trap_arg0 = addr;
env->trap_arg1 = is_write;
dynamic_excp(EXCP_MCHK, 0);
}
| 1threat |
Android Google maps java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion : <p>I am using Google maps Android SDK 11.6.2(Also tried 15.0.1),but I get following crash before map shows. Already checked API key in manifest,it is available, but still this issue occurs. I am having targetSDk version as 28.Is it causes this issue.</p>
<pre><code>java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion;
at el.b(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):3)
at ek.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):4)
at em.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):51)
at com.google.maps.api.android.lib6.drd.ap.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):11)
at dw.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):16)
at dw.run(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):61)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.ProtocolVersion" on path: DexPathList[[zip file "/system/priv-app/PrebuiltGmsCorePi/app_chimera/m/MapsDynamite.apk"],nativeLibraryDirectories=[/data/user_de/0/com.google.android.gms/app_chimera/m/00000036/MapsDynamite.apk!/lib/armeabi-v7a, /data/user_de/0/com.google.android.gms/app_chimera/m/00000036/MapsDynamite.apk!/lib/armeabi, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:126)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at ad.loadClass(:com.google.android.gms.dynamite_dynamiteloader@12848063@12.8.48 (100408-196123505):25)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at el.b(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):3)
at ek.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):4)
at em.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):51)
at com.google.maps.api.android.lib6.drd.ap.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):11)
at dw.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):16)
at dw.run(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):61)
</code></pre>
| 0debug |
TypeError: Converting circular structure to JSON when trying to POST request : <p>I am getting the error in the title and here is the full stack trace, i am not sure what it is, any insight is welcomed!</p>
<pre><code>browser_adapter.js:84 EXCEPTION: Error in ./ParametersFormComponent class ParametersFormComponent - inline template:3:31BrowserDomAdapter.logError @ browser_adapter.js:84BrowserDomAdapter.logGroup @ browser_adapter.js:94ExceptionHandler.call @ exception_handler.js:65next @ application_ref.js:348schedulerFn @ async.js:89SafeSubscriber.__tryOrUnsub @ Subscriber.js:225SafeSubscriber.next @ Subscriber.js:174Subscriber._next @ Subscriber.js:124Subscriber.next @ Subscriber.js:88Subject._finalNext @ Subject.js:128Subject._next @ Subject.js:120Subject.next @ Subject.js:77EventEmitter.emit @ async.js:77onError @ ng_zone.js:124onHandleError @ ng_zone_impl.js:74ZoneDelegate.handleError @ zone.js:327Zone.runGuarded @ zone.js:233NgZoneImpl.runInnerGuarded @ ng_zone_impl.js:86NgZone.runGuarded @ ng_zone.js:240outsideHandler @ dom_events.js:27ZoneDelegate.invokeTask @ zone.js:356Zone.runTask @ zone.js:256ZoneTask.invoke @ zone.js:423
browser_adapter.js:84 ORIGINAL EXCEPTION: TypeError: Converting circular structure to JSONBrowserDomAdapter.logError @ browser_adapter.js:84ExceptionHandler.call @ exception_handler.js:74next @ application_ref.js:348schedulerFn @ async.js:89SafeSubscriber.__tryOrUnsub @ Subscriber.js:225SafeSubscriber.next @ Subscriber.js:174Subscriber._next @ Subscriber.js:124Subscriber.next @ Subscriber.js:88Subject._finalNext @ Subject.js:128Subject._next @ Subject.js:120Subject.next @ Subject.js:77EventEmitter.emit @ async.js:77onError @ ng_zone.js:124onHandleError @ ng_zone_impl.js:74ZoneDelegate.handleError @ zone.js:327Zone.runGuarded @ zone.js:233NgZoneImpl.runInnerGuarded @ ng_zone_impl.js:86NgZone.runGuarded @ ng_zone.js:240outsideHandler @ dom_events.js:27ZoneDelegate.invokeTask @ zone.js:356Zone.runTask @ zone.js:256ZoneTask.invoke @ zone.js:423
browser_adapter.js:84 ORIGINAL STACKTRACE:BrowserDomAdapter.logError @ browser_adapter.js:84ExceptionHandler.call @ exception_handler.js:77next @ application_ref.js:348schedulerFn @ async.js:89SafeSubscriber.__tryOrUnsub @ Subscriber.js:225SafeSubscriber.next @ Subscriber.js:174Subscriber._next @ Subscriber.js:124Subscriber.next @ Subscriber.js:88Subject._finalNext @ Subject.js:128Subject._next @ Subject.js:120Subject.next @ Subject.js:77EventEmitter.emit @ async.js:77onError @ ng_zone.js:124onHandleError @ ng_zone_impl.js:74ZoneDelegate.handleError @ zone.js:327Zone.runGuarded @ zone.js:233NgZoneImpl.runInnerGuarded @ ng_zone_impl.js:86NgZone.runGuarded @ ng_zone.js:240outsideHandler @ dom_events.js:27ZoneDelegate.invokeTask @ zone.js:356Zone.runTask @ zone.js:256ZoneTask.invoke @ zone.js:423
browser_adapter.js:84 TypeError: Converting circular structure to JSON
at Object.stringify (native)
at ParametersFormComponent.onSubmit (http://localhost:4200/main.bundle.js:61451:25)
at DebugAppView._View_ParametersFormComponent0._handle_ngSubmit_7_0 (ParametersFormComponent.ngfactory.js:1809:28)
at http://localhost:4200/main.bundle.js:57019:24
at SafeSubscriber.schedulerFn [as _next] (http://localhost:4200/main.bundle.js:11839:54)
at SafeSubscriber.__tryOrUnsub (http://localhost:4200/main.bundle.js:48280:16)
at SafeSubscriber.next (http://localhost:4200/main.bundle.js:48229:22)
at Subscriber._next (http://localhost:4200/main.bundle.js:48179:26)
at Subscriber.next (http://localhost:4200/main.bundle.js:48143:18)
at EventEmitter.Subject._finalNext (http://localhost:4200/main.bundle.js:9733:30)
at EventEmitter.Subject._next (http://localhost:4200/main.bundle.js:9725:18)
at EventEmitter.Subject.next (http://localhost:4200/main.bundle.js:9682:14)BrowserDomAdapter.logError @ browser_adapter.js:84ExceptionHandler.call @ exception_handler.js:78next @ application_ref.js:348schedulerFn @ async.js:89SafeSubscriber.__tryOrUnsub @ Subscriber.js:225SafeSubscriber.next @ Subscriber.js:174Subscriber._next @ Subscriber.js:124Subscriber.next @ Subscriber.js:88Subject._finalNext @ Subject.js:128Subject._next @ Subject.js:120Subject.next @ Subject.js:77EventEmitter.emit @ async.js:77onError @ ng_zone.js:124onHandleError @ ng_zone_impl.js:74ZoneDelegate.handleError @ zone.js:327Zone.runGuarded @ zone.js:233NgZoneImpl.runInnerGuarded @ ng_zone_impl.js:86NgZone.runGuarded @ ng_zone.js:240outsideHandler @ dom_events.js:27ZoneDelegate.invokeTask @ zone.js:356Zone.runTask @ zone.js:256ZoneTask.invoke @ zone.js:423
browser_adapter.js:84 ERROR CONTEXT:BrowserDomAdapter.logError @ browser_adapter.js:84ExceptionHandler.call @ exception_handler.js:81next @ application_ref.js:348schedulerFn @ async.js:89SafeSubscriber.__tryOrUnsub @ Subscriber.js:225SafeSubscriber.next @ Subscriber.js:174Subscriber._next @ Subscriber.js:124Subscriber.next @ Subscriber.js:88Subject._finalNext @ Subject.js:128Subject._next @ Subject.js:120Subject.next @ Subject.js:77EventEmitter.emit @ async.js:77onError @ ng_zone.js:124onHandleError @ ng_zone_impl.js:74ZoneDelegate.handleError @ zone.js:327Zone.runGuarded @ zone.js:233NgZoneImpl.runInnerGuarded @ ng_zone_impl.js:86NgZone.runGuarded @ ng_zone.js:240outsideHandler @ dom_events.js:27ZoneDelegate.invokeTask @ zone.js:356Zone.runTask @ zone.js:256ZoneTask.invoke @ zone.js:423
browser_adapter.js:84 DebugContext {_view: _View_ParametersFormComponent0, _nodeIndex: 7, _tplRow: 3, _tplCol: 31}BrowserDomAdapter.logError @ browser_adapter.js:84ExceptionHandler.call @ exception_handler.js:82next @ application_ref.js:348schedulerFn @ async.js:89SafeSubscriber.__tryOrUnsub @ Subscriber.js:225SafeSubscriber.next @ Subscriber.js:174Subscriber._next @ Subscriber.js:124Subscriber.next @ Subscriber.js:88Subject._finalNext @ Subject.js:128Subject._next @ Subject.js:120Subject.next @ Subject.js:77EventEmitter.emit @ async.js:77onError @ ng_zone.js:124onHandleError @ ng_zone_impl.js:74ZoneDelegate.handleError @ zone.js:327Zone.runGuarded @ zone.js:233NgZoneImpl.runInnerGuarded @ ng_zone_impl.js:86NgZone.runGuarded @ ng_zone.js:240outsideHandler @ dom_events.js:27ZoneDelegate.invokeTask @ zone.js:356Zone.runTask @ zone.js:256ZoneTask.invoke @ zone.js:423
:4200/polyfills.bundle.js:3327 Uncaught EXCEPTION: Error in ./ParametersFormComponent class ParametersFormComponent - inline template:3:31
ORIGINAL EXCEPTION: TypeError: Converting circular structure to JSON
ORIGINAL STACKTRACE:
TypeError: Converting circular structure to JSON
at Object.stringify (native)
at ParametersFormComponent.onSubmit (http://localhost:4200/main.bundle.js:61451:25)
at DebugAppView._View_ParametersFormComponent0._handle_ngSubmit_7_0 (ParametersFormComponent.ngfactory.js:1809:28)
at http://localhost:4200/main.bundle.js:57019:24
at SafeSubscriber.schedulerFn [as _next] (http://localhost:4200/main.bundle.js:11839:54)
at SafeSubscriber.__tryOrUnsub (http://localhost:4200/main.bundle.js:48280:16)
at SafeSubscriber.next (http://localhost:4200/main.bundle.js:48229:22)
at Subscriber._next (http://localhost:4200/main.bundle.js:48179:26)
at Subscriber.next (http://localhost:4200/main.bundle.js:48143:18)
at EventEmitter.Subject._finalNext (http://localhost:4200/main.bundle.js:9733:30)
at EventEmitter.Subject._next (http://localhost:4200/main.bundle.js:9725:18)
at EventEmitter.Subject.next (http://localhost:4200/main.bundle.js:9682:14)
ERROR CONTEXT:
[object Object]
Navigated to http://localhost:4200/?
</code></pre>
<p>component</p>
<pre><code>import {Component} from '@angular/core';
import { FormGroup, FormControl, REACTIVE_FORM_DIRECTIVES, Validators, AbstractControl, Control } from '@angular/forms';
import { Headers, Http, Response } from '@angular/http';
@Component({
selector: 'parameters-form',
directives: [REACTIVE_FORM_DIRECTIVES],
templateUrl: 'form.template.html'
})
export class ParametersFormComponent {
response: {};
myForm: FormGroup;
systemParameters: AbstractControl;
param: AbstractControl;
liftOperator: AbstractControl;
restrictOperator: AbstractControl;
xInitial: AbstractControl;
system_arr: number[];
param_arr: number[];
restrict_arr: number[];
lift_arr: number[];
xinitial_arr: number[];
constructor(private http: Http) {
this.myForm = new FormGroup({
'realisations' : new FormControl('', Validators.required),
'numConstSteps' : new FormControl('', Validators.required),
'timeHorizon': new FormControl('', Validators.required),
'continuationStep' : new FormControl('', Validators.required),
'continuationStepSign' : new FormControl('', Validators.required),
'numberOfModelParameters' : new FormControl('', Validators.required),
'systemParameters' : new FormControl(''),
'param' : new FormControl(''),
'netLogoFile' : new FormControl('', Validators.required),
'numberOfModelVariables' : new FormControl('', Validators.required),
'restrictOperator' : new FormControl(''),
'liftOperator' : new FormControl(''),
'xInitial' : new FormControl('')
});
this.system_arr = [];
this.param_arr = [];
this.restrict_arr = [];
this.lift_arr = [];
this.xinitial_arr = [];
this.param = this.myForm.controls["param"];
this.systemParameters = this.myForm.controls['systemParameters'];
this.restrictOperator = this.myForm.controls['restrictOperator'];
this.liftOperator = this.myForm.controls['liftOperator'];
this.xInitial = this.myForm.controls['xInitial'];
}
addToArray(event, value: number, target: string): void {
if (event.which === 13) {
switch (target) {
case 'systemParameters':
this.system_arr.push(value);
(<Control>this.systemParameters).updateValue('');
break;
case 'param':
this.param_arr.push(value);
(<Control>this.param).updateValue('');
break;
case 'liftOperator':
this.lift_arr.push(value);
(<Control>this.liftOperator).updateValue('');
break;
case 'restrictOperator':
this.restrict_arr.push(value);
(<Control>this.restrictOperator).updateValue('');
break;
case 'xInitial':
this.xinitial_arr.push(value);
(<Control>this.xInitial).updateValue('');
break;
}
}
}
deleteItem(value: any, target: string): void {
let pos = 0;
switch (target) {
case 'systemParameters':
pos = this.system_arr.indexOf(value);
this.system_arr.splice(pos, 1);
break;
case 'param':
pos = this.param_arr.indexOf(value);
this.param_arr.splice(pos, 1);
break;
case 'liftOperator':
pos = this.lift_arr.indexOf(value);
this.lift_arr.splice(pos, 1);
break;
case 'restrictOperator':
pos = this.restrict_arr.indexOf(value);
this.restrict_arr.splice(pos, 1);
break;
case 'xInitial':
pos = this.xinitial_arr.indexOf(value);
this.xinitial_arr.splice(pos, 1);
break;
}
}
isFullfilled(m: number, n: number) {
if (
m == this.restrict_arr.length
&& m == this.xinitial_arr.length
&& m == this.lift_arr.length
&& n == this.param_arr.length
&& n == this.system_arr.length
) {
if (m != 0 && n != 0 ){
return true;
}
}
return null;
}
onSubmit() {
this.myForm.value.systemParameters = this.system_arr;
this.myForm.value.liftOperator = this.lift_arr;
this.myForm.value.restrictOperator = this.restrict_arr;
this.myForm.value.param = this.param_arr;
this.myForm.value.xInitial = this.xinitial_arr;
let Form = JSON.stringify(this.myForm);
let headers = new Headers();
headers.append('Content-Type', 'application/json');
this.http.post('http://localhost:3000/webhook', Form, { headers: headers })
.map((data: Response) => data.json())
.subscribe(
data => this.response = data,
error => console.log(error)
);
console.log('your submitted value:', this.myForm.value);
}
}
</code></pre>
<p>Was working fine before i ported it from Beta to RC5</p>
| 0debug |
Usage of Java 9 collection factories : <p>In the context of the comments and answers given at <a href="https://stackoverflow.com/questions/39400238">List.of() or Collections.emptyList()</a> and <a href="https://stackoverflow.com/questions/39385658">List.of(...) or Collections.unmodifiableList()</a> I came up with two following rules of thumb (which also apply to <code>Set</code> and <code>Map</code> factories accordingly).</p>
<ol>
<li>Don't replace all occurrences</li>
</ol>
<p>Keep using <code>Collections.emptyList()</code> for readability and when e.g. initializing lazy field members like:</p>
<pre><code>class Bean {
private List<Bean> beans = Collection.emptyList();
public List<Bean> getBeans() {
if (beans == Collections.EMPTY_LIST) { beans = new ArrayList<>(); }
return beans;
}
}
</code></pre>
<ol start="2">
<li>Use new factories as method argument builders</li>
</ol>
<p>Use new factories <code>List.of()</code> and variants as quick and less-to-type version, when calling an executable with <code>List</code> parameter(s). Here are my current substitution patterns:</p>
<pre><code>Collections.emptyList() --> List.of()
Collections.singletonList(a) --> List.of(a)
Arrays.asList(a, ..., z) --> List.of(a, ..., z)
</code></pre>
<p>In a fictional usage of <code>Collections.indexOfSubList</code>, the following lines</p>
<pre><code>Collections.indexOfSubList(Arrays.asList(1, 2, 3), Collections.emptyList());
Collections.indexOfSubList(Arrays.asList(1, 2, 3), Collections.singletonList(1));
Collections.indexOfSubList(Arrays.asList(1, 2, 3), Arrays.asList(1));
Collections.indexOfSubList(Arrays.asList(1, 2, 3), Arrays.asList(2, 3));
Collections.indexOfSubList(Arrays.asList(1, 2, 3), Arrays.asList(1, 2, 3));
</code></pre>
<p>will read</p>
<pre><code>Collections.indexOfSubList(List.of(1, 2, 3), List.of());
Collections.indexOfSubList(List.of(1, 2, 3), List.of(1));
Collections.indexOfSubList(List.of(1, 2, 3), List.of(1));
Collections.indexOfSubList(List.of(1, 2, 3), List.of(2, 3));
Collections.indexOfSubList(List.of(1, 2, 3), List.of(1, 2, 3));
</code></pre>
<p>Do you (dis-)agree?</p>
| 0debug |
32 bit limitation of MUL in ARM Assembly : <p>In ARM Assembly each register can contain 32 bits/1 word of information stored in it. That's why when you try to store a value larger than 255 it gives you an error</p>
<p>However, the MUL instruction seems to not have this limitation. You can multiply two registers, each of them having the value of 255 for instance, and store the result in a third register without any errors. How does this happen? Shouldn't the destination register be unable to store values beyond 255?</p>
| 0debug |
Is there a way to find the minimum value across multiple data frames? : <p>I have around 20 data frames that have the exact same format and dimensions with six columns. The only difference between each data frame is the different values in the sixth column. I want to run a loop through all the data frames so that I can get the minimum value across all data frames for the sixth column. My plan is to list all the data frames in a vector and then loop through the vector and then loop through each line of the data frames, though I'm not sure how I can implement something like that. I would appreciate any advice. </p>
| 0debug |
Starting Activity Performs onResume? : <p>Ok so I have this code in onCreate and onResume</p>
<pre><code>@Override
public void onResume()
{ // After a pause OR at startup
super.onResume();
Intent intent = getIntent();
String name2 = intent.getStringExtra(MyAdapter.KEY_VNAME);
if (name2 == null){
name2 = intent.getStringExtra(MainVoterView.KEY_VNAME2);
}
String Simage = intent.getStringExtra(MyAdapter.KEY_SUGGEST_IMAGE);
if (Simage == null){
Simage = intent.getStringExtra(MainVoterView.KEY_SUGGEST_IMAGE2);
}
layoutManager = new LinearLayoutManager(Suggestion.this);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setHasFixedSize(true);
suggestList = new ArrayList<>();
requestQueue = Volley.newRequestQueue(Suggestion.this);
getData();
adapter = new SuggestListAdapter(suggestList, Suggestion.this, name2, Simage);
recyclerView.setAdapter(adapter);
}
</code></pre>
<p>When I start the activity my suggestion feed is doubled.. and when I Pause the Application and then resumes it. The suggestion feed is fixed. What I'd like to ask is does onResume Activates when starting activity. </p>
<p>And if yes What method should I use ? </p>
<p>Why would they call it onResume if every time the Activity is called the onResume executes. For what I know that's not resuming.</p>
<p>Please do enlighten me</p>
| 0debug |
static void id3v2_parse(AVFormatContext *s, int len, uint8_t version,
uint8_t flags, ID3v2ExtraMeta **extra_meta)
{
int isv34, unsync;
unsigned tlen;
char tag[5];
int64_t next, end = avio_tell(s->pb) + len;
int taghdrlen;
const char *reason = NULL;
AVIOContext pb;
AVIOContext *pbx;
unsigned char *buffer = NULL;
int buffer_size = 0;
const ID3v2EMFunc *extra_func = NULL;
unsigned char *uncompressed_buffer = NULL;
int uncompressed_buffer_size = 0;
av_log(s, AV_LOG_DEBUG, "id3v2 ver:%d flags:%02X len:%d\n", version, flags, len);
switch (version) {
case 2:
if (flags & 0x40) {
reason = "compression";
goto error;
}
isv34 = 0;
taghdrlen = 6;
break;
case 3:
case 4:
isv34 = 1;
taghdrlen = 10;
break;
default:
reason = "version";
goto error;
}
unsync = flags & 0x80;
if (isv34 && flags & 0x40) {
int extlen = get_size(s->pb, 4);
if (version == 4)
extlen -= 4;
if (extlen < 0) {
reason = "invalid extended header length";
goto error;
}
avio_skip(s->pb, extlen);
len -= extlen + 4;
if (len < 0) {
reason = "extended header too long.";
goto error;
}
}
while (len >= taghdrlen) {
unsigned int tflags = 0;
int tunsync = 0;
int tcomp = 0;
int tencr = 0;
unsigned long dlen;
if (isv34) {
avio_read(s->pb, tag, 4);
tag[4] = 0;
if (version == 3) {
tlen = avio_rb32(s->pb);
} else
tlen = get_size(s->pb, 4);
tflags = avio_rb16(s->pb);
tunsync = tflags & ID3v2_FLAG_UNSYNCH;
} else {
avio_read(s->pb, tag, 3);
tag[3] = 0;
tlen = avio_rb24(s->pb);
}
if (tlen > (1<<28))
break;
len -= taghdrlen + tlen;
if (len < 0)
break;
next = avio_tell(s->pb) + tlen;
if (!tlen) {
if (tag[0])
av_log(s, AV_LOG_DEBUG, "Invalid empty frame %s, skipping.\n",
tag);
continue;
}
if (tflags & ID3v2_FLAG_DATALEN) {
if (tlen < 4)
break;
dlen = avio_rb32(s->pb);
tlen -= 4;
} else
dlen = tlen;
tcomp = tflags & ID3v2_FLAG_COMPRESSION;
tencr = tflags & ID3v2_FLAG_ENCRYPTION;
if (tencr || (!CONFIG_ZLIB && tcomp)) {
const char *type;
if (!tcomp)
type = "encrypted";
else if (!tencr)
type = "compressed";
else
type = "encrypted and compressed";
av_log(s, AV_LOG_WARNING, "Skipping %s ID3v2 frame %s.\n", type, tag);
avio_skip(s->pb, tlen);
} else if (tag[0] == 'T' ||
(extra_meta &&
(extra_func = get_extra_meta_func(tag, isv34)))) {
pbx = s->pb;
if (unsync || tunsync || tcomp) {
av_fast_malloc(&buffer, &buffer_size, tlen);
if (!buffer) {
av_log(s, AV_LOG_ERROR, "Failed to alloc %d bytes\n", tlen);
goto seek;
}
}
if (unsync || tunsync) {
int64_t end = avio_tell(s->pb) + tlen;
uint8_t *b;
b = buffer;
while (avio_tell(s->pb) < end && b - buffer < tlen && !s->pb->eof_reached) {
*b++ = avio_r8(s->pb);
if (*(b - 1) == 0xff && avio_tell(s->pb) < end - 1 &&
b - buffer < tlen &&
!s->pb->eof_reached ) {
uint8_t val = avio_r8(s->pb);
*b++ = val ? val : avio_r8(s->pb);
}
}
ffio_init_context(&pb, buffer, b - buffer, 0, NULL, NULL, NULL,
NULL);
tlen = b - buffer;
pbx = &pb;
}
#if CONFIG_ZLIB
if (tcomp) {
int err;
av_log(s, AV_LOG_DEBUG, "Compresssed frame %s tlen=%d dlen=%ld\n", tag, tlen, dlen);
av_fast_malloc(&uncompressed_buffer, &uncompressed_buffer_size, dlen);
if (!uncompressed_buffer) {
av_log(s, AV_LOG_ERROR, "Failed to alloc %ld bytes\n", dlen);
goto seek;
}
if (!(unsync || tunsync)) {
err = avio_read(s->pb, buffer, tlen);
if (err < 0) {
av_log(s, AV_LOG_ERROR, "Failed to read compressed tag\n");
goto seek;
}
tlen = err;
}
err = uncompress(uncompressed_buffer, &dlen, buffer, tlen);
if (err != Z_OK) {
av_log(s, AV_LOG_ERROR, "Failed to uncompress tag: %d\n", err);
goto seek;
}
ffio_init_context(&pb, uncompressed_buffer, dlen, 0, NULL, NULL, NULL, NULL);
tlen = dlen;
pbx = &pb;
}
#endif
if (tag[0] == 'T')
read_ttag(s, pbx, tlen, &s->metadata, tag);
else
extra_func->read(s, pbx, tlen, tag, extra_meta);
} else if (!tag[0]) {
if (tag[1])
av_log(s, AV_LOG_WARNING, "invalid frame id, assuming padding\n");
avio_skip(s->pb, tlen);
break;
}
seek:
avio_seek(s->pb, next, SEEK_SET);
}
if (version == 4 && flags & 0x10)
end += 10;
error:
if (reason)
av_log(s, AV_LOG_INFO, "ID3v2.%d tag skipped, cannot handle %s\n",
version, reason);
avio_seek(s->pb, end, SEEK_SET);
av_free(buffer);
av_free(uncompressed_buffer);
return;
}
| 1threat |
ChartJS canvas not displaying rgba colors in IE, Safari and Firefox : <p>Im using ChartJS to display some data but it's not rendering the canvas element correctly in IE, Firefox and Safari. </p>
<p>My guess is that the background color property lacks any of the used prefixes for the other browser since it works fine in Chrome.</p>
<p>Anyone else had this issue? </p>
<p><strong>Chrome</strong>: </p>
<p><a href="https://i.stack.imgur.com/WXPgx.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WXPgx.png" alt="enter image description here"></a></p>
<p><strong>Firefox, Safari and IE:</strong>
<a href="https://i.stack.imgur.com/ZtW4T.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZtW4T.png" alt="enter image description here"></a></p>
<p>The code: </p>
<pre><code> window.onload = function() {
var ctx = document.getElementById("canvas");
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug"],
datasets: [{
label: '# of Value',
data: [12, 19, 3, 5, 2, 3, 10, 29],
backgroundColor: [
'rgba(33, 145, 81, 0.2)',
'rgba(33, 145, 81, 0.2)',
'rgba(33, 145, 81, 0.2)',
'rgba(33, 145, 81, 0.2)',
'rgba(33, 145, 81, 0.2)',
'rgba(33, 145, 81, 0.2)',
'rgba(33, 145, 81, 0.2)',
'rgba(33, 145, 81, 0.2)'
],
borderColor: [
'rgba(33, 145, 81, 1)',
'rgba(33, 145, 81, 0.2)',
'rgba(33, 145, 81, 0.2)',
'rgba(33, 145, 81, 0.2)',
'rgba(33, 145, 81, 0.2)',
'rgba(33, 145, 81, 0.2)',
'rgba(33, 145, 81, 0.2)',
'rgba(33, 145, 81, 0.2)'
],
borderWidth: 1
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
}
}
});
};
});
</code></pre>
| 0debug |
Check if PHP string contains operation characters : <p>I want to check it a sting has any of operations for calculations ex:</p>
<pre><code>$str = "part1+part2"
</code></pre>
<p>Check if <strong>$str</strong> contains any of those characters: <strong>+</strong>, <strong>-</strong>, <strong>/</strong>, or <strong>*</strong></p>
<p>Then assign each part of the sting to a variable</p>
<pre><code>$p1 = "part1";
$p2 = "part2";
$opr = "+";
</code></pre>
| 0debug |
Make qmake use qt5 by default : <p>I have both qt4 and qt5 on my Linux system. qt4 is used by default. What is a clean way to change that so that qmake uses qmake-qt5 by default?</p>
| 0debug |
Add down arrow to hover dropdown menu : I'm implementing this dropdown menu: http://www.w3schools.com/howto/howto_css_dropdown.asp
I want to add an arrow to the dropdown to indicate it's a hover item. How do I do this? I've tried adding
> content: ' ▾';
to the .dropbtn class but it did not work. | 0debug |
Concer laravel Eloquent query :
Could your any one help me how i will convert like this query
SELECT * FROM prize_frequency WHERE SYSDATE() BETWEEN start_time AND end_time
| 0debug |
How to sniff HTTP response headers in Chrome? for "attachment" content? : <p>Usually I'm able to sniff my HTTP requests using Chrome Dev Tools - network tab.</p>
<p>But it's not happening for download-files (i.e. when <code>Content-Dsiplosition</code> is set to <code>Attachment;filename=xxx</code>) - then Chrome just downloads the file and nothing is shown on the network tab.</p>
<p>How do I see those? I mean, in Chrome, without any 3rd party tools like PostMan.</p>
<p>PS. I need to see the headers my server sends, there's some debugging info I need.</p>
| 0debug |
How to save desktop background image to a file in c#? : <p>I want to save my desktop background to a file and use it in the code. I couldn't find an solution on the internet.</p>
| 0debug |
static void rtsp_send_cmd(AVFormatContext *s,
const char *cmd, RTSPHeader *reply,
unsigned char **content_ptr)
{
RTSPState *rt = s->priv_data;
char buf[4096], buf1[1024], *q;
unsigned char ch;
const char *p;
int content_length, line_count;
unsigned char *content = NULL;
memset(reply, 0, sizeof(RTSPHeader));
rt->seq++;
pstrcpy(buf, sizeof(buf), cmd);
snprintf(buf1, sizeof(buf1), "CSeq: %d\r\n", rt->seq);
pstrcat(buf, sizeof(buf), buf1);
if (rt->session_id[0] != '\0' && !strstr(cmd, "\nIf-Match:")) {
snprintf(buf1, sizeof(buf1), "Session: %s\r\n", rt->session_id);
pstrcat(buf, sizeof(buf), buf1);
}
pstrcat(buf, sizeof(buf), "\r\n");
#ifdef DEBUG
printf("Sending:\n%s--\n", buf);
#endif
url_write(rt->rtsp_hd, buf, strlen(buf));
line_count = 0;
rt->last_reply[0] = '\0';
for(;;) {
q = buf;
for(;;) {
if (url_read(rt->rtsp_hd, &ch, 1) == 0)
break;
if (ch == '\n')
break;
if (ch != '\r') {
if ((q - buf) < sizeof(buf) - 1)
*q++ = ch;
}
}
*q = '\0';
#ifdef DEBUG
printf("line='%s'\n", buf);
#endif
if (buf[0] == '\0')
break;
p = buf;
if (line_count == 0) {
get_word(buf1, sizeof(buf1), &p);
get_word(buf1, sizeof(buf1), &p);
reply->status_code = atoi(buf1);
} else {
rtsp_parse_line(reply, p);
pstrcat(rt->last_reply, sizeof(rt->last_reply), p);
pstrcat(rt->last_reply, sizeof(rt->last_reply), "\n");
}
line_count++;
}
if (rt->session_id[0] == '\0' && reply->session_id[0] != '\0')
pstrcpy(rt->session_id, sizeof(rt->session_id), reply->session_id);
content_length = reply->content_length;
if (content_length > 0) {
content = av_malloc(content_length + 1);
url_read(rt->rtsp_hd, content, content_length);
content[content_length] = '\0';
}
if (content_ptr)
*content_ptr = content;
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.