problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
How do I split a string at only some commas, not all? : <p>I'm pretty inexperienced at programming, and I've been doing a lot of practice problems recently. I'm currently attempting to find the sum of the x and y values of the two closest points in <a href="https://d18l82el6cdm1i.cloudfront.net/uploads/documents/points-oWGbRs2l1v.txt" rel="nofollow noreferrer">this</a>
set of points. The problem I'm having, is because there are commas separating the points but also in the points, I don't know how to split the string to make a list of the points</p>
<p>This is my code right now:</p>
<pre><code>import csv
with open('points.csv') as f:
reader = csv.reader(f)
header_row = next(reader)
print(header_row)
</code></pre>
<p>and the output is:</p>
<pre><code>['{{253', ' 146}', ' {3', ' 845}', ' {-841', ' 337}', -SNIP- ' {-918', ' -736}', ' {269', ' 212}', ' {126', ' 146}}']
</code></pre>
<p>How do I change this code so it splits at only some commas, not all of them?</p>
| 0debug |
how can I add value to my fields in database : I want to change field values in database but there are not any option to do that as you see in the picture below(I'm using mamp in Mac os Catalina),there aren't any option,[this is picture of my problem][1]
I want to know how can I add the options, I will upload another picture below for to understand what I want to do
[I want to have these options][2]
[1]: https://i.stack.imgur.com/jn3iZ.png
[2]: https://i.stack.imgur.com/f5kPn.png | 0debug |
pandas:how to change all column names with erasing specific letters : <p>I am using Anaconda to read table from hive and all my column names have been automaticly added a prefix like test.age,test.sex,test.degree...
How to use pandas to erase all the prefix 'test.'?</p>
| 0debug |
Deploy web app in docker data container vs volume : <p>I'm confused about common consensus that one shouldn't use data containers. I have specific use case that I want to accomplish.</p>
<p>I want to have docker nginx container and behind it some other container with application. To run newest version of my app I want to download ready container from my private docker registry. The application is for now purely static html, javascript something.</p>
<p>So my plan is to create docker image which will hold the files, and will specify a named volume in some /webapp folder. The nginx container will serve this volume. I do not see any other way how to move bunch of files to remote system the "docker containerized" way. <strong>Am I not actually creating cursed data container?</strong></p>
<p>Anyway what happens during app containers exchange? When I stop the app container the volume remains accesible, as it is placed on host. When I pull and start new version of app container. The volume will be created again and prefiled with image files stored at the same location, replacing the content on host so the nginx container will server from now new version of the application.Right? What happens when I will reference volume that does not exist yet from the nginx container.</p>
<p>It seem that named values are not automatically filed with the content of the image. As well I'm not sure how to create named volume in docker file as this syntax taken from <a href="https://boxboat.com/2016/06/18/docker-data-containers-and-named-volumes/">here</a> doesn't work </p>
<pre><code>FROM training/webapp
VOLUME webapp:/webapp
</code></pre>
| 0debug |
void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
{
void (*start_frame)(AVFilterLink *, AVFilterBufferRef *);
AVFilterPad *dst = link->dstpad;
FF_DPRINTF_START(NULL, start_frame); ff_dprintf_link(NULL, link, 0); dprintf(NULL, " "); ff_dprintf_ref(NULL, picref, 1);
if (!(start_frame = dst->start_frame))
start_frame = avfilter_default_start_frame;
if ((dst->min_perms & picref->perms) != dst->min_perms ||
dst->rej_perms & picref->perms) {
av_log(link->dst, AV_LOG_DEBUG,
"frame copy needed (have perms %x, need %x, reject %x)\n",
picref->perms,
link->dstpad->min_perms, link->dstpad->rej_perms);
link->cur_buf = avfilter_get_video_buffer(link, dst->min_perms, link->w, link->h);
link->src_buf = picref;
avfilter_copy_buffer_ref_props(link->cur_buf, link->src_buf);
}
else
link->cur_buf = picref;
start_frame(link, link->cur_buf);
}
| 1threat |
Create a JSON object from HTML using jQuery and javascript : I would like to create JSON from HTML code using jQuery.
I have number of divs with class row, each div contains divs with class header and body.
Now, i would like to read the value of inputs from header and body and create a json object like below.
**HTML:**
<form id="myForm">
<div class="row">
<div class="header">
<input type="checkbox" value="1">
</div>
<div class="body">
<input type="checkbox" value="11">
<input type="checkbox" value="12">
</div>
</div>
<div class="row">
<div class="header">
<input type="checkbox" value="2">
</div>
<div class="body">
<input type="checkbox" value="21">
<input type="checkbox" value="22">
</div>
</div>
<div class="row">
<div class="header">
<input type="checkbox" value="3">
</div>
<div class="body">
<input type="checkbox" value="31">
<input type="checkbox" value="32">
</div>
</div>
</form>
**Desired Output
I want to generate (with jQuery) a JSON object similar to the following:**
[
{
"line1": 1,
"line2": [11, 12]
},
{
"line1": 2,
"line2": [21, 22]
},
{
"line1": 3,
"line2": [31, 32]
}
] | 0debug |
SQL I have to dipaly the digist 123.34 as 123.3400000000000 ie., 13 digit after the decimal point without loosing any values : Running query from Java code no chance to change the global preferences. I have to print 123.34 as 123.3400000000000 ie., 13 digit after the decimal point without loosing any values CAST(SUM(F.TOTAL_DOCUMENT_CHARS) AS DECIMAL(18,0))/1000 AS "DOC CHARS" by changing global preferences to default format getting 14891.4530000000000.., without that as well I need to get
Expected output : 123.3400000000000 | 0debug |
How can i delete my .db file from WPF application? : I have a slight problem that I'm trying to solve. I am using SQLite database and i created my database *Schedule.db* automatically when application starts for the first time(if .db does not already exists).
On a button_click i want to delete it so i can create new one when i start my application again.
The problem is, every time i try to delete it i get an error:
**"Additional information: The process cannot access the file '/filePath.../Scheduler.db' because it is being used by another process."**
I understand that i cant delete it because my application is already using it but is there any solution to my current problem?
string databasePath = AppDomain.CurrentDomain.BaseDirectory + "Scheduler.db";
if (MessageBox.Show("Do you want to delete database: [Scheduler.db]?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.Yes) == MessageBoxResult.Yes)
{
if (File.Exists(databasePath))
{
File.Delete(databasePath);
MessageBox.Show("Database deleted: [Scheduler] ");
Application.Current.Shutdown();
}
else
{
MessageBox.Show("There is no database: [Scheduler]!");
}
} | 0debug |
Return ++a is different than return a++, why? : <p>I was experimenting with some code when I discovered something odd. I had the following code:</p>
<pre><code>#include <iostream>
int add_one_return(int a) {
return a++;
}
void add_one_ref(int &a) {
a++;
}
int main(int argc, char const *argv[]) {
int a1 = 5;
int a2 = 5;
a1 = add_one_return(a1);
add_one_ref(a2);
std::cout << a1 << " " << a2 << std::endl;
return 0;
}
</code></pre>
<p>But when I ran it the program printed <code>5 6</code>. I went back and changed <code>add_one_return</code> to:</p>
<pre><code>int add_one_return(int a) {
return ++a;
}
</code></pre>
<p>and it worked! Why does <code>++a</code> work but not <code>a++</code>? Is there ever an advantage to <code>a++</code>, because I also hear that in a for loop you want to use <code>for(int i = 0; i < someVar; ++i) {}</code>, so why <code>a++</code> at all?</p>
| 0debug |
Which Java Version required for Junit 4.1 : <p>Working with Cucumber FrameWork, Need to know Which Java Version required for Junit 4.1 version</p>
| 0debug |
See contents of long value in local storage in Safari : <p>I'm trying to see the entire contents of a single value held in local storage in Safari (it's a long JSON object). When I view the key/value pair, the value is too long for the screen, and copying the row only copies the visible portion of the value. Is there a way to see the whole line?</p>
| 0debug |
static void bmdma_map(PCIDevice *pci_dev, int region_num,
pcibus_t addr, pcibus_t size, int type)
{
PCIIDEState *d = DO_UPCAST(PCIIDEState, dev, pci_dev);
int i;
for(i = 0;i < 2; i++) {
BMDMAState *bm = &d->bmdma[i];
d->bus[i].bmdma = bm;
bm->bus = d->bus+i;
qemu_add_vm_change_state_handler(ide_dma_restart_cb, bm);
register_ioport_write(addr, 1, 1, bmdma_cmd_writeb, bm);
register_ioport_write(addr + 1, 3, 1, bmdma_writeb, bm);
register_ioport_read(addr, 4, 1, bmdma_readb, bm);
register_ioport_write(addr + 4, 4, 1, bmdma_addr_writeb, bm);
register_ioport_read(addr + 4, 4, 1, bmdma_addr_readb, bm);
register_ioport_write(addr + 4, 4, 2, bmdma_addr_writew, bm);
register_ioport_read(addr + 4, 4, 2, bmdma_addr_readw, bm);
register_ioport_write(addr + 4, 4, 4, bmdma_addr_writel, bm);
register_ioport_read(addr + 4, 4, 4, bmdma_addr_readl, bm);
addr += 8;
}
} | 1threat |
Input user defined variables in select statement : <p>I want to store user defined variables in sql select statement and use that variable in sub query like the following:</p>
<pre><code>select user_id, @user_gender:=user_gender
where user_id in (select user_id from post where post_gender=@user_gender);
</code></pre>
<p>So what I want to do here is I want to store the user_gender value into a variable and use it in a subquery. I know what I am tryinig to do here can be achieved by joins, but what I am posting this example, because I want to know how to actually store value from a row into a user defined variable. </p>
<p>Also, I am having hard time finding good resources that explains how to use user defined variables. Any recommendations?</p>
| 0debug |
static void dma_aio_cancel(BlockDriverAIOCB *acb)
{
DMAAIOCB *dbs = container_of(acb, DMAAIOCB, common);
if (dbs->acb) {
bdrv_aio_cancel(dbs->acb);
}
}
| 1threat |
static void sigp_set_prefix(CPUState *cs, run_on_cpu_data arg)
{
S390CPU *cpu = S390_CPU(cs);
SigpInfo *si = arg.host_ptr;
uint32_t addr = si->param & 0x7fffe000u;
cpu_synchronize_state(cs);
if (!address_space_access_valid(&address_space_memory, addr,
sizeof(struct LowCore), false)) {
set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER);
return;
}
if (s390_cpu_get_state(cpu) != CPU_STATE_STOPPED) {
set_sigp_status(si, SIGP_STAT_INCORRECT_STATE);
return;
}
cpu->env.psa = addr;
cpu_synchronize_post_init(cs);
si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;
}
| 1threat |
AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base, int64_t start, int64_t end, const char *title)
{
AVChapter *chapter = NULL;
int i;
for(i=0; i<s->nb_chapters; i++)
if(s->chapters[i]->id == id)
chapter = s->chapters[i];
if(!chapter){
chapter= av_mallocz(sizeof(AVChapter));
if(!chapter)
return NULL;
dynarray_add(&s->chapters, &s->nb_chapters, chapter);
}
if(chapter->title)
av_free(chapter->title);
chapter->title = av_strdup(title);
chapter->id = id;
chapter->time_base= time_base;
chapter->start = start;
chapter->end = end;
return chapter;
}
| 1threat |
How do I configure goland to recognize 'mod' packages? : <p>I am taking go1.11rc1 for a spin and the first thing I noticed is that goland does not recognize imports. </p>
<p>The <a href="https://blog.jetbrains.com/go/2018/07/25/goland-2018-2/" rel="noreferrer">goland version announcement</a> says: "support for Go modules out of the box (formerly known as vgo)"</p>
<p>Anyone know how to fix this?</p>
<p>Problem: </p>
<ol>
<li>Packages like "github.com/urfave/cli" colored red and hover text says: "Cannot resolve directory..."</li>
<li>Imported package items like "NewApp" in "app := cli.NewApp()" colored red and hover text says: "Unresolved reference ..."</li>
</ol>
<p>Steps to reproduce:</p>
<ol>
<li>Install go1.11rc1: remove the current install, install 1.11rc1, check version.</li>
<li>Create a new project directory outside the go path: <code>mkdir pjg && cd pjg</code></li>
<li>Create a <code>go.mod</code> file: <code>go mod init github.com/stevetarver/pjg</code></li>
<li>Add a package to the project: <code>go get github.com/urfave/cli</code></li>
</ol>
<p><code>go.mod</code> file now looks like:</p>
<pre><code>module github.com/stevetarver/pjg/v1
require github.com/urfave/cli v1.20.0 // indirect
</code></pre>
<p>Create <code>main.go</code>:</p>
<pre><code>package main
import (
"fmt"
"log"
"os"
"github.com/urfave/cli"
)
func main() {
app := cli.NewApp()
app.Name = "boom"
app.Usage = "make an explosive entrance"
app.Action = func(c *cli.Context) error {
fmt.Println("boom! I say!")
return nil
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}
</code></pre>
<p>View <code>main.go</code> in goland, and hover over red text to see problem.</p>
<ul>
<li>mod packages are stored in <code>$GOPATH/pkg/mod/</code></li>
<li>goland version: 2018.2.1</li>
<li>go version: go1.11rc1 darwin/amd64</li>
</ul>
<p>Notes:</p>
<ul>
<li><code>$GOPATH</code> is set correctly - <code>go get</code> put the package in the right place, GOPATH in env matches goland preferences.</li>
<li>Setting goland preferences Go -> GOPATH -> Module GOPATH to <code>/Users/starver/code/go/pkg/mod</code> did not fix this.</li>
</ul>
| 0debug |
Unable to click on href element <a href="" ng-click="selectPage(totalPages)" class="ng-binding">Last</a> using VBA : I have the following code on VBA:
driver.FindElementByXPath(".//span[text()='Next']").Click
which says element not found.
to click on
link [source page][1]
Any help?
[1]: https://i.stack.imgur.com/vsmax.png | 0debug |
neo4j: Cypher: grouping/relationships : am new to Cypher/graph DBs. I created a example to understand traversals but not quite getting it.
//Cypher below to create nodes.
(`0` :Person {id:'74474',Name:"Mr. Dan"}) ,
(`1` :Company {id:'1234',Name:"Company A"}) ,
(`2` :Company {id:'1111',Name:"Company B"}) ,
(`3` :Person {id:'0844',Name:"Mr.X"}) ,
(`4` :Person {id:'3455',Name:"Mr. Jack"}) ,
(`5` :Person {id:'748222',Name:"Mr.Y"}) ,
(`0`)-[:`owns` {amt:'50%'}]->(`1`),
(`4`)-[:`owns` {amt:'30%'}]->(`1`),
(`2`)-[:`owns` {amt:'20%'}]->(`1`),
(`3`)-[:`owns` {amt:'30%'}]->(`2`),
(`5`)-[:`owns` {amt:'70%'}]->(`2`)
// end
Query :
MATCH (p:Person)-[o:owns*]->(c:Company)
where c.Name="Company A"
return p, o
//this gives me all "Persons" who own "Company A" but I want to get the "% ownership" of each Person. I cant seem to extract or aggregate the values in the relationship "o". Seemed easy but I seem challenged!
Any suggestions? | 0debug |
static int nbd_receive_request(int csock, struct nbd_request *request)
{
uint8_t buf[4 + 4 + 8 + 8 + 4];
uint32_t magic;
if (read_sync(csock, buf, sizeof(buf)) != sizeof(buf)) {
LOG("read failed");
errno = EINVAL;
return -1;
}
magic = be32_to_cpup((uint32_t*)buf);
request->type = be32_to_cpup((uint32_t*)(buf + 4));
request->handle = be64_to_cpup((uint64_t*)(buf + 8));
request->from = be64_to_cpup((uint64_t*)(buf + 16));
request->len = be32_to_cpup((uint32_t*)(buf + 24));
TRACE("Got request: "
"{ magic = 0x%x, .type = %d, from = %" PRIu64" , len = %u }",
magic, request->type, request->from, request->len);
if (magic != NBD_REQUEST_MAGIC) {
LOG("invalid magic (got 0x%x)", magic);
errno = EINVAL;
return -1;
}
return 0;
}
| 1threat |
Button Styling on WPF : <p>I'm designing a dashboard on wpf and I have to make buttons like this.</p>
<p><a href="https://imgur.com/jEcSPiA" rel="nofollow noreferrer">https://imgur.com/jEcSPiA</a></p>
<p>This is a button; there is an image in the middle, a content in the top right corner and a content in the bottom.</p>
<p>How can I do ?</p>
| 0debug |
if clause teminates the workflow in JavaScript? : <p>When I look at the following code, I think "CheckChoice(IntSelect)" will always execute no matter "if (isNaN(IntSelect))" will execute or not.</p>
<p>If I input a NaN and the CheckChoice function worked, the alert("The value supplied is out of range!"); should also display as the "default" branch. But it does not happen as I expected.</p>
<p>I do not understand what happens when input is a NaN, can anybody explain it please.</p>
<p>Thank you.</p>
<pre><code><!DOCTYPE html>
<html>
<head>
<title>Using the Default Clause</title>
<script language="JavaScript">
function CheckChoice(option)
{
// Make a selection.
switch (option)
{
case 1:
document.getElementById("Result").innerHTML =
"You chose Item A.";
break;
case 2:
document.getElementById("Result").innerHTML =
"You chose Item B.";
break;
case 3:
document.getElementById("Result").innerHTML =
"You chose Item C.";
break;
default:
// Display an error dialog.
alert("The value supplied is out of range!");
break;
}
}
function MakeAChoice()
{
// Ask the user to provide input.
var Selection = prompt("Type a menu option.");
// Convert the string to a number.
var IntSelect = parseInt(Selection);
// Verify the user has provided a number.
if (isNaN(IntSelect))
{
// Display an error dialog.
alert("Please provide numeric input!");
// Return without doing anything more.
return;
}
// Call the selection function.
CheckChoice(IntSelect);
}
</script>
</head>
<body>
<h1>Using the Default Clause</h1>
<p>Menu Options:</p>
<ol>
<li>Item A</li>
<li>Item B</li>
<li>Item C</li>
</ol>
<input type="button"
value="Choose a Menu Item"
onclick="MakeAChoice()" />
<p id="Result"></p>
</body>
</html>
</code></pre>
| 0debug |
Refresh fragment when change between tabs : <p>App open on first fragment and there is 2 tabs i want to refresh second fragment
when i move to it but i don't want to refresh first fragment </p>
<h2>MainActivity</h2>
<pre><code>protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
viewPager = (ViewPager) findViewById(R.id.viewpager);
setupViewPager(viewPager);
tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
}
private void setupViewPager(ViewPager viewPager) {
ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
adapter.addFragment(new Main_Button(), "Main");
adapter.addFragment(new TwoFragment(), "Main2");
viewPager.setAdapter(adapter);
}
class ViewPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>();
private final List<String> mFragmentTitleList = new ArrayList<>();
public ViewPagerAdapter(FragmentManager manager) {
super(manager);
}
@Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}
@Override
public int getCount() {
return mFragmentList.size();
}
public void addFragment(Fragment fragment, String title) {
mFragmentList.add(fragment);
mFragmentTitleList.add(title);
}
@Override
public CharSequence getPageTitle(int position) {
return mFragmentTitleList.get(position);
}
}
</code></pre>
<p>please explain your answer because i'm new in android and i don't know how i can do that</p>
| 0debug |
JavaScript access to Json : <p>Hi i want to access to value of <code>id</code> in this Json :</p>
<pre><code>{
"arguments":
{
"torrent-added":
{
"hashString":"2c8cacb3183f5209804449bbd5573ffaab7a7072",
"id":59,
"name":"slackware64-13.1-iso"
}
},
"result":"success"
}
</code></pre>
<p>Im tryed this way :</p>
<pre><code>var id = decoded.arguments.torrent_added.id;
</code></pre>
<p>But its not working why ?</p>
<p>How can do this ?</p>
| 0debug |
what is the use of Zone.js in Angular 2 : <p>Currently am learning <strong>Angular</strong> <strong>2.0</strong> and i come accross the file <strong>Zone.js</strong>, and i would like to know what is the purpose of the file Zone.js and how will it make my application better.</p>
| 0debug |
static void mirror_exit(BlockJob *job, void *opaque)
{
MirrorBlockJob *s = container_of(job, MirrorBlockJob, common);
MirrorExitData *data = opaque;
AioContext *replace_aio_context = NULL;
BlockDriverState *src = blk_bs(s->common.blk);
BlockDriverState *target_bs = blk_bs(s->target);
bdrv_ref(src);
if (s->to_replace) {
replace_aio_context = bdrv_get_aio_context(s->to_replace);
aio_context_acquire(replace_aio_context);
}
if (s->should_complete && data->ret == 0) {
BlockDriverState *to_replace = src;
if (s->to_replace) {
to_replace = s->to_replace;
}
if (bdrv_get_flags(target_bs) != bdrv_get_flags(to_replace)) {
bdrv_reopen(target_bs, bdrv_get_flags(to_replace), NULL);
}
bdrv_drained_begin(target_bs);
bdrv_replace_in_backing_chain(to_replace, target_bs);
bdrv_drained_end(target_bs);
blk_remove_bs(job->blk);
blk_insert_bs(job->blk, src);
}
if (s->to_replace) {
bdrv_op_unblock_all(s->to_replace, s->replace_blocker);
error_free(s->replace_blocker);
bdrv_unref(s->to_replace);
}
if (replace_aio_context) {
aio_context_release(replace_aio_context);
}
g_free(s->replaces);
bdrv_op_unblock_all(target_bs, s->common.blocker);
blk_unref(s->target);
block_job_completed(&s->common, data->ret);
g_free(data);
bdrv_drained_end(src);
if (qemu_get_aio_context() == bdrv_get_aio_context(src)) {
aio_enable_external(iohandler_get_aio_context());
}
bdrv_unref(src);
}
| 1threat |
static int coroutine_fn nfs_co_readv(BlockDriverState *bs,
int64_t sector_num, int nb_sectors,
QEMUIOVector *iov)
{
NFSClient *client = bs->opaque;
NFSRPC task;
nfs_co_init_task(client, &task);
task.iov = iov;
if (nfs_pread_async(client->context, client->fh,
sector_num * BDRV_SECTOR_SIZE,
nb_sectors * BDRV_SECTOR_SIZE,
nfs_co_generic_cb, &task) != 0) {
return -ENOMEM;
}
while (!task.complete) {
nfs_set_events(client);
qemu_coroutine_yield();
}
if (task.ret < 0) {
return task.ret;
}
if (task.ret < iov->size) {
qemu_iovec_memset(iov, task.ret, 0, iov->size - task.ret);
}
return 0;
}
| 1threat |
Why Scala creators decided to re-implement Java collections? : <p>What are the main differences between Java collections and Scala collections? Why the Scala creators decided to create a whole new set of classes instead of building on top of the existing ones?</p>
| 0debug |
Elbow method findig number of clusters for 90 different kmeans(weka) : I am doing incremental learning and i have to do clustering for every iteration. And i am doing 90 different clustering with simple kmeans on weka in java. How can find number of clusters for every clustering process? I can find wss easily so i thought elbow method can be solve this problem but i could not implement that. I am doing this in java code with weka library. | 0debug |
error: ‘cast’ does not name a type void setCastDescription(std::string desc) cast.description = desc; } : <pre><code>player.h:155:43: error: expected ‘;’ at end of member declaration
void setCastDescription(std::string desc) cast.description = desc; }
player.h:155:45: error: ‘cast’ does not name a type
void setCastDescription(std::string desc) cast.description = desc; }
player.h: In member function ‘bool Player::getCastingState() const’:
player.h:148:39: error: ‘cast’ was not declared in this scope
bool getCastingState() const {return cast.isCasting; };
^
player.h: In member function ‘virtual const string& Player::getCastingPassword() const’:
player.h:149:65: error: ‘cast’ was not declared in this scope
virtual const std::string & getCastingPassword() const {return cast.password; };
^
player.h: In member function ‘PlayerCast Player::getCast()’:
player.h:150:31: error: ‘cast’ was not declared in this scope
PlayerCast getCast() {return cast; }
^
player.h: In member function ‘void Player::setCastPassword(std::string)’:
player.h:153:39: error: ‘cast’ was not declared in this scope
void setCastPassword(std::string p) {cast.password = p; };
^
player.h: At global scope:
player.h:156:28: error: expected initializer before ‘&’ token
virtual const std::string & getCastDescription() const return cast.description; }
^
player.h:156:82: error: expected declaration before ‘}’ token
virtual const std::string & getCastDescription() const return cast.description; }
^
</code></pre>
<p>this is my code what im trying to compile.. it is very large so im only going to post the lines where i get the error... </p>
<pre><code>bool getCastingState() const {return cast.isCasting; };
virtual const std::string & getCastingPassword() const {return cast.password; };
PlayerCast getCast() {return cast; }
void setCasting(bool c);
void setCastPassword(std::string p) {cast.password = p; };
void setCastDescription(std::string desc) cast.description = desc; }
virtual const std::string & getCastDescription() const return cast.description; }
</code></pre>
<p>i already did search everywhere to find something similar but i dont get anything since yesterday i'm trying to find out a solution, i hope someone here can help me </p>
| 0debug |
Function to check if version string is newer (1.2.5 > 1.1.10 for example) : <p>I'm looking for a simple function that checks 2 version strings to each other.
What I've done now is explode it on the . and check each number from right to left. But I feel like it could be a lot simpler.</p>
<p>Hope to hear.
Kind regards,
Kevin Walter</p>
| 0debug |
Why doesn't my newly-created docker have a digest? : <p>I have been following the <a href="https://docs.docker.com/engine/tutorials/dockerimages/#/image-digests" rel="noreferrer">Docker tutorial here</a>, and built a test image on my local OSX machine by committing changes to an existing image and tagging it with three different labels:</p>
<pre><code># docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
adamatan/sinatra devel fccb6b4d21b4 8 minutes ago 469.5 MB
adamatan/sinatra junk fccb6b4d21b4 8 minutes ago 469.5 MB
adamatan/sinatra latest fccb6b4d21b4 8 minutes ago 469.5 MB
</code></pre>
<p>However, none of these images has a digest:</p>
<pre><code># docker images --digests adamatan/sinatra
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
adamatan/sinatra devel <none> fccb6b4d21b4 9 minutes ago 469.5 MB
adamatan/sinatra junk <none> fccb6b4d21b4 9 minutes ago 469.5 MB
adamatan/sinatra latest <none> fccb6b4d21b4 9 minutes ago 469.5 MB
</code></pre>
<p>Other test images I have created with a Dockerfile do have a digest.</p>
<p><strong>Why do some images have a digest and some don't? Is it related to the way the images were created (Dockerfile or not)?</strong></p>
| 0debug |
Is it possible to use an IF statement in PHP along with differnet sql queries? : Basically I want to update a value in the table if the date field is equal to todays date, otherwise I'd like to insert a new row into the table if the date is not equal to today. Say for example something like (I know syntax is wrong here) -
if($date == $today){
$sql = $con->query("UPDATE table SET field= 'field+$value', field2='field2 + $value2' WHERE id=2")
}else{
$sql = $con->query("INSERT INTO table (field1, field,2,field3)VALUES('{$value1}', '{$value2}', '{$value3}')");
}
How would I go about doing something like this? is using an if statement like this in php/SQL queries possible? or is there a different way that it has to be done?
Cheers. | 0debug |
Haskell: Can this code be optimized? : <p>I have the following code. I want to know whether there is any way it can be optimized so that it runs faster.</p>
<p>I wanted to solve it using a <code>SegmentTree</code> but I am not well versed with Haskell, which is why I took the following list (non-tree) approach.</p>
<pre><code>-- Program execution begins here
main :: IO()
main = do
_ <- getLine
arr <- map (read :: String -> Integer) . words <$> getLine
queryList <- readData
let queries = map (read :: String -> Integer) queryList
putStrLn ""
mapM_ print $ compute queries arr
-- Construct a sublist
sublist :: Integer -> Integer -> [Integer] -> [Integer]
sublist start end list = take (fromInteger end - fromInteger start) . drop (fromInteger start) $ list
-- Calculate the resulting list
compute :: [Integer] -> [Integer] -> [Integer]
compute [_] [_] = []
compute [_] [] = []
compute [_] (_:_) = []
compute [] (_:_) = []
compute [] [] = []
compute (x1:x2:xs) list = result : compute xs list where
result = frequency $ sublist x1 x2 list
-- Read query list, end at terminating condition
readData :: IO [String]
readData = do
x <- getLine
if x == "0"
then return []
else do xs <- readData
return (words x ++ xs)
-- Return count of the most frequent element in a list
frequency :: [Integer] -> Integer
frequency list = toInteger (snd $ maximumBy (compare `on` snd) counts) where
counts = nub [(element, count) | element <- list, let count = length (filter (element ==) list)]
</code></pre>
<p>Thanks.</p>
| 0debug |
Does Collections.unmodifiableList(list) require a lock? : <p>I have a <code>productList</code> maintained in a file named <code>Products.java</code></p>
<pre><code>private List<String> productList = Collections.synchronizedList(new ArrayList());
</code></pre>
<p>Now creating a synchronized list, will ensure that operations like add/remove will have a implicit lock and I don't need to lock these operations explicitily.</p>
<p>I have a function exposed which returns an <code>unmodifiableList</code> of this list.</p>
<pre><code>public List getProductList(){
return Collections.unmodifiableList(productList);
}
</code></pre>
<p>In my application, various threads can call this function at the same time. So do I need to put a <code>synchronized</code> block when converting a List into an unmodifiable List or will this be already taken care of since I am using a sychronizedList ?</p>
<p>TIA.</p>
| 0debug |
static void fw_cfg_initfn(Object *obj)
{
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
FWCfgState *s = FW_CFG(obj);
memory_region_init_io(&s->ctl_iomem, OBJECT(s), &fw_cfg_ctl_mem_ops, s,
"fwcfg.ctl", FW_CFG_SIZE);
sysbus_init_mmio(sbd, &s->ctl_iomem);
memory_region_init_io(&s->data_iomem, OBJECT(s), &fw_cfg_data_mem_ops, s,
"fwcfg.data", FW_CFG_DATA_SIZE);
sysbus_init_mmio(sbd, &s->data_iomem);
memory_region_init_io(&s->comb_iomem, OBJECT(s), &fw_cfg_comb_mem_ops, s,
"fwcfg", FW_CFG_SIZE);
}
| 1threat |
static void gen_advance_ccount(DisasContext *dc)
{
if (dc->ccount_delta > 0) {
TCGv_i32 tmp = tcg_const_i32(dc->ccount_delta);
dc->ccount_delta = 0;
gen_helper_advance_ccount(cpu_env, tmp);
tcg_temp_free(tmp);
}
}
| 1threat |
static void do_test_validate_qmp_introspect(TestInputVisitorData *data,
const char *schema_json)
{
SchemaInfoList *schema = NULL;
Visitor *v;
v = validate_test_init_raw(data, schema_json);
visit_type_SchemaInfoList(v, NULL, &schema, &error_abort);
g_assert(schema);
qapi_free_SchemaInfoList(schema);
}
| 1threat |
i can't solve my Error i'm doing CHECKBOX in recyclerview : '''
package com.example.project.Holder;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.example.project.Model.User;
import com.example.project.R;
import java.util.List;
public class AttendanceViewHolder {
private Context mContext;
private UserAdapter userAdapter;
public void setConfig(RecyclerView recyclerView,Context context,List<User> users,List<String> keys){
mContext=context;
userAdapter=new UserAdapter(users,keys);
recyclerView.setLayoutManager(new LinearLayoutManager(context));
recyclerView.setAdapter(userAdapter);
}
class UserItemView extends RecyclerView.ViewHolder {
public ImageView attendanceitem_imageview;
private TextView attendanceitem_textview;
private String key;
public CheckBox attendance_checkBox;
public UserItemView(ViewGroup parent) {
super(LayoutInflater.from(mContext).
inflate(R.layout.item_attendance_bottom, parent, false));
attendanceitem_imageview = (ImageView) itemView.findViewById(R.id.attendanceitem_imageview);
attendanceitem_textview = (TextView) itemView.findViewById(R.id.attendanceitem_textview);
attendance_checkBox =(CheckBox) itemView.findViewById(R.id.attendance_checkBox);
}
public void bind(User user, String key) {
attendanceitem_textview.setText(user.getUsername());
this.key = key;
}
}
class UserAdapter extends RecyclerView.Adapter<UserItemView> {
List<User> userList;
private List<String> mkeys;
public UserAdapter(List<User> userList, List<String> mkeys) {
this.userList = userList;
this.mkeys = mkeys;
}
@NonNull
@Override
public UserItemView onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new UserItemView(parent);
}
@Override
public void onBindViewHolder(@NonNull UserItemView holder, int position) {
final int pos = position;
holder.attendance_checkBox.setChecked(userList.get(position).isCheckBox());
holder.attendance_checkBox.setTag(userList.get(position));
holder.bind(userList.get(position),mkeys.get(position));
Glide.with(holder.attendanceitem_imageview.getContext())
.load(userList.get(position).profileImageUrl)
.apply(new RequestOptions())
.into(holder.attendanceitem_imageview);
holder.attendance_checkBox.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
CheckBox attendance_checkBox = (CheckBox) view;
User contact = (User) attendance_checkBox.getTag();
contact.setCheckBox(attendance_checkBox.isChecked());
userList.get(pos).setCheckBox(attendance_checkBox.isChecked());
}
});
}
@Override
public int getItemCount() {
return userList.size();
}
}
}
'''
package com.example.project.Model;
import android.net.Uri;
import android.widget.ImageView;
public class User {
public String email;
public String profileImageUrl;
public String username;
public String uid;
public String pushToken;
public String job;
public String comment;
public Boolean checkBox;
public User() {
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getProfileImageUrl() {
return profileImageUrl;
}
public void setProfileImageUrl(String profileImageUrl) {
this.profileImageUrl = profileImageUrl;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getPushToken() {
return pushToken;
}
public void setPushToken(String pushToken) {
this.pushToken = pushToken;
}
public String getJob() {
return job;
}
public void setJob(String job) {
this.job = job;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public boolean isCheckBox() {
return checkBox;
}
public void setCheckBox(Boolean chechBox) {
this.checkBox = chechBox;
}
}
'''
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference
at com.example.project.Model.User.isCheckBox(User.java:77)
at com.example.project.Holder.AttendanceViewHolder$UserAdapter.onBindViewHolder(AttendanceViewHolder.java:80)
at com.example.project.Holder.AttendanceViewHolder$UserAdapter.onBindViewHolder(AttendanceViewHolder.java:58)
at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6937)
at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6979)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5896)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6163)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6002)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5998)
at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2226)
at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1558)
at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1518)
at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:613)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4033)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3750)
at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4303)
at android.view.View.layout(View.java:21927)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
at android.view.View.layout(View.java:21927)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at android.view.View.layout(View.java:21927)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
at android.view.View.layout(View.java:21927)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:779)
at android.view.View.layout(View.java:21927)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3080)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2590)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1721)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7598)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:966)
at android.view.Choreographer.doCallbacks(Choreographer.java:790)
at android.view.Choreographer.doFrame(Choreographer.java:725)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:951)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
''' | 0debug |
.NET Core API Conditional Authentication attributes for Development & Production : <p>Long story short, Is it possible to place an environment based authorization attribute on my API so that the authorization restriction would be turned off in development and turned back on in Production? </p>
<p>I have a separate Angular 2 project that I wish to call a .NET Core API with. We created a separate project so we could open the Angular 2 project in vscode and debug the typescript. When we are finished, we will build the project and place it inside the .NET Core project for security reasons. </p>
<p>Our problem is that during the debugging stages, we are unable to connect to the API because they are two separate projects and our Angular 2 project does not have Active Directory. The .NET Core project currently has Authentication Attributes and wont allow access (401) to the API. It would be nice if we could turn that off during development and back on during production.</p>
<p>I'm also open to any other suggestions on how we can best solve this problem.</p>
<pre><code>[Authorize: (Only in Production)] <-- // something like this???
[Route("api/[controller]")]
public class TestController : Controller
{
...
</code></pre>
| 0debug |
static USBDevice *usb_host_device_open_addr(int bus_num, int addr, const char *prod_name)
{
int fd = -1, ret;
USBDevice *d = NULL;
USBHostDevice *dev;
struct usbdevfs_connectinfo ci;
char buf[1024];
printf("husb: open device %d.%d\n", bus_num, addr);
if (!usb_host_device_path) {
perror("husb: USB Host Device Path not set");
goto fail;
}
snprintf(buf, sizeof(buf), "%s/%03d/%03d", usb_host_device_path,
bus_num, addr);
fd = open(buf, O_RDWR | O_NONBLOCK);
if (fd < 0) {
perror(buf);
goto fail;
}
dprintf("husb: opened %s\n", buf);
d = usb_create(NULL , "USB Host Device");
dev = DO_UPCAST(USBHostDevice, dev, d);
dev->bus_num = bus_num;
dev->addr = addr;
dev->fd = fd;
dev->descr_len = read(fd, dev->descr, sizeof(dev->descr));
if (dev->descr_len <= 0) {
perror("husb: reading device data failed");
goto fail;
}
#ifdef DEBUG
{
int x;
printf("=== begin dumping device descriptor data ===\n");
for (x = 0; x < dev->descr_len; x++)
printf("%02x ", dev->descr[x]);
printf("\n=== end dumping device descriptor data ===\n");
}
#endif
if (!usb_host_claim_interfaces(dev, -1))
goto fail;
ret = ioctl(fd, USBDEVFS_CONNECTINFO, &ci);
if (ret < 0) {
perror("usb_host_device_open: USBDEVFS_CONNECTINFO");
goto fail;
}
printf("husb: grabbed usb device %d.%d\n", bus_num, addr);
ret = usb_linux_update_endp_table(dev);
if (ret)
goto fail;
if (ci.slow)
dev->dev.speed = USB_SPEED_LOW;
else
dev->dev.speed = USB_SPEED_HIGH;
if (!prod_name || prod_name[0] == '\0')
snprintf(dev->dev.devname, sizeof(dev->dev.devname),
"host:%d.%d", bus_num, addr);
else
pstrcpy(dev->dev.devname, sizeof(dev->dev.devname),
prod_name);
qemu_set_fd_handler(dev->fd, NULL, async_complete, dev);
hostdev_link(dev);
qdev_init(&d->qdev);
return (USBDevice *) dev;
fail:
if (d)
qdev_free(&d->qdev);
if (fd != -1)
close(fd);
return NULL;
}
| 1threat |
Cannot find symbol java netbeans : <p>Can someone tell me why I'm getting the error Cannot find symbol when I'm creating an object? in <code>bank_account Christine = new bank_account();</code> </p>
<pre><code>public class BankAccountTester
{
public static void main (String []args)
{
bank_account Christine = new bank_account();
Christine.deposit(10000);
Christine.withdraw(2000);
System.out.println(Christine.getBalance());
}
}
</code></pre>
<p>this is my class</p>
<pre><code>public class bank_account{
private double balance;
public bank_account()
{
balance = 0;
}
public bank_account (double initialBalance)
{
balance = initialBalance;
}
public void deposit(double amount)
{
balance = balance + amount;
}
public void withdraw (double amount)
{
balance = balance - amount;
}
public double getBalance()
{
return balance;
}
}
</code></pre>
| 0debug |
restore_sigcontext(CPUX86State *env, struct target_sigcontext *sc, int *peax)
{
unsigned int err = 0;
abi_ulong fpstate_addr;
unsigned int tmpflags;
cpu_x86_load_seg(env, R_GS, tswap16(sc->gs));
cpu_x86_load_seg(env, R_FS, tswap16(sc->fs));
cpu_x86_load_seg(env, R_ES, tswap16(sc->es));
cpu_x86_load_seg(env, R_DS, tswap16(sc->ds));
env->regs[R_EDI] = tswapl(sc->edi);
env->regs[R_ESI] = tswapl(sc->esi);
env->regs[R_EBP] = tswapl(sc->ebp);
env->regs[R_ESP] = tswapl(sc->esp);
env->regs[R_EBX] = tswapl(sc->ebx);
env->regs[R_EDX] = tswapl(sc->edx);
env->regs[R_ECX] = tswapl(sc->ecx);
env->eip = tswapl(sc->eip);
cpu_x86_load_seg(env, R_CS, lduw_p(&sc->cs) | 3);
cpu_x86_load_seg(env, R_SS, lduw_p(&sc->ss) | 3);
tmpflags = tswapl(sc->eflags);
env->eflags = (env->eflags & ~0x40DD5) | (tmpflags & 0x40DD5);
fpstate_addr = tswapl(sc->fpstate);
if (fpstate_addr != 0) {
if (!access_ok(VERIFY_READ, fpstate_addr,
sizeof(struct target_fpstate)))
goto badframe;
cpu_x86_frstor(env, fpstate_addr, 1);
}
*peax = tswapl(sc->eax);
return err;
badframe:
return 1;
}
| 1threat |
MacIONVRAMState *macio_nvram_init (target_phys_addr_t size,
unsigned int it_shift)
{
MacIONVRAMState *s;
s = g_malloc0(sizeof(MacIONVRAMState));
s->data = g_malloc0(size);
s->size = size;
s->it_shift = it_shift;
memory_region_init_io(&s->mem, &macio_nvram_ops, s, "macio-nvram",
size << it_shift);
vmstate_register(NULL, -1, &vmstate_macio_nvram, s);
qemu_register_reset(macio_nvram_reset, s);
return s;
}
| 1threat |
I got error when i was installing django.Pls Help me? : >>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named django
>>>
[enter image description here][1]
[1]: http://i.stack.imgur.com/OveNv.png | 0debug |
How do I use printf to print arraylist of different variables : I have an arraylist filled with different variables, how would I print this arraylist out using the **printf** flag in Java?
public class mendietaRAL {
public static void theArrayList() {
ArrayList<Object> theList = new ArrayList<Object>();
theList.add(123);
theList.add("Java");
theList.add(3.75);
theList.add("Summer C");
theList.add(2018);
for (int i = 0; i < theList.size(); i++) {
System.out.printf(theList.get(i));
}
theList.remove(1);
theList.remove(3);
System.out.println();
for (int i = 0; i < theList.size(); i++) {
System.out.printf(theList.get(i));
}
}
}
| 0debug |
Converted website into android app | pop window is not opening in android app : I am not the coder. But I have converted my already well built website into android app.
One problem is: Popup window doesnt open in app. It opens in desktop version and it also opens perfect in mobile browsers. In app, it simply stays on the same page. What to do? | 0debug |
Write palindrome in JavaScript : <p>How to write a JavaScript program that returns the largest number-palindrome, which is the product of two prime five-digit numbers and returns the multipliers themselves ?</p>
<p>My head feel empty...</p>
| 0debug |
static int pcm_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
PCMDecode *s = avctx->priv_data;
int n;
short *samples;
uint8_t *src;
samples = data;
src = buf;
switch(avctx->codec->id) {
case CODEC_ID_PCM_S16LE:
n = buf_size >> 1;
for(;n>0;n--) {
*samples++ = src[0] | (src[1] << 8);
src += 2;
}
break;
case CODEC_ID_PCM_S16BE:
n = buf_size >> 1;
for(;n>0;n--) {
*samples++ = (src[0] << 8) | src[1];
src += 2;
}
break;
case CODEC_ID_PCM_U16LE:
n = buf_size >> 1;
for(;n>0;n--) {
*samples++ = (src[0] | (src[1] << 8)) - 0x8000;
src += 2;
}
break;
case CODEC_ID_PCM_U16BE:
n = buf_size >> 1;
for(;n>0;n--) {
*samples++ = ((src[0] << 8) | src[1]) - 0x8000;
src += 2;
}
break;
case CODEC_ID_PCM_S8:
n = buf_size;
for(;n>0;n--) {
*samples++ = src[0] << 8;
src++;
}
break;
case CODEC_ID_PCM_U8:
n = buf_size;
for(;n>0;n--) {
*samples++ = ((int)src[0] - 128) << 8;
src++;
}
break;
case CODEC_ID_PCM_ALAW:
case CODEC_ID_PCM_MULAW:
n = buf_size;
for(;n>0;n--) {
*samples++ = s->table[src[0]];
src++;
}
break;
default:
return -1;
}
*data_size = (uint8_t *)samples - (uint8_t *)data;
return src - buf;
} | 1threat |
How to detect dns server and ip-adresses in PHP : <p>I want to program a DNS-leaktester in PHP. Is it possible? or do I have to use other languages like python etc. to get the information.</p>
| 0debug |
Unspecified number of parameters in a function : <p>I have an Array of Arrays and a method that expects N arguments of type Array.</p>
<p>For example, if I have:
<code>let arr = [[0, 1], [2, 3], [4, 5]];</code></p>
<p><code>arr</code> has 3 arrays inside, so I could do this:</p>
<pre><code>theFunction(arr[0]);
theFunction(arr[0], arr[1]);
theFunction(arr[0], arr[1], arr[2]);
</code></pre>
<p>The question is: How can I accomplish this if I don't know the number of arrays?</p>
| 0debug |
How to iterate through a binary number in c++? in my following function I'm getting invalid operands to binary conversion (bitset<8> and int) : This is the function in my code, which is getting the stated error
int value(int x)
{ int temp=0,counter=0;
bitset<8> i(x);
while (i != 0) {
temp = i % 10;
if(temp == 1)
{counter++;
}
i = i/10;
}
return counter;
} | 0debug |
Beginner needs some guidence C : I'm trying to make a code where a user chooses a number(lets call it A) and then it checks whether if A divided by i * i leaves any remainder, if it doesn't it must display just i number, u get this i number from loops. i'm getting an error saying that the number cant be divided by zero and i can't find out where that zero is coming from.
i have tried doing somethings with the code but ended up with the same error or totally wrong numbers
this is my code: http://pastebin.com/dzTKeavF
| 0debug |
Automatically open html links in new tab : <p>I have a html document with 100 html-links. When I open the document in a browser I want all the links in the document to open automatically in 100 different tabs in the same browser. Alternatively I want to do this some other way with the terminal in OS X or with cmd.exe in Windows. This is just for data collection and not web development.</p>
| 0debug |
using integer variables in switch statements in java : <p>I recently encountered a situation that is somewhat similar to this.</p>
<pre><code>Scanner sc = new Scanner(System.in);
int a = sc.nextInt(), ... , g = sc.nextInt(), x = sc.nextInt(), y = sc.nextInt(), z;
z = x * y;
switch (z) {
case a : //print something
break;
.
.
.
case g : //print something
break;
default : //print something
break;
}
</code></pre>
<p>I encountered an error for all the case labels. I checked through some tutorials and have not got all the answers. I need to know if I can make it work with switch statement since it is a constraint I must use.</p>
| 0debug |
Using Boto3 to interact with amazon Aurora on RDS : <p>I have set up a database in Amazon RDS using Amazon Aurora and would like to interact with the database using Python - the obvious choice is to use Boto.</p>
<p>However, their documentation is awful and does nopt cover ways in which I can interact with the databse to:</p>
<ul>
<li>Run queries with SQL statements</li>
<li>Interact with the tables in the database</li>
<li>etc</li>
</ul>
<p>Does anyone have an links to some examples/tutorials, or know how to do these tasks?</p>
| 0debug |
my interpreter don't recognize December as the winter month (if/else) : <p>I'm fairly new to Python. I'm using PyCharm for practice. When I typed "December" in month's input and the interpreter recognize December as the autumn month. Why is this happening? (Look at the bottom if you don't understand what I mean)</p>
<pre><code>Winter = ['December', 'January', 'February']
Spring = ['March', 'April', 'May']
Summer = ['June', 'July', 'August']
Autumn = ['September', 'October', 'November']
month = input('What is the current month? ')
if month == Winter:
print('%s is in the Winter' % month)
elif month == Spring:
print('%s is in the Spring' % month)
elif month == Summer:
print('%s is in the Summer' % month)
else:
print('%s is in the Autumn' % month)
What is the current month? December
December is in the Autumn
</code></pre>
| 0debug |
How to clear mat-datepicker in Angular 5 : <p>How can I clear an Angular Material Datepicker with an button click?</p>
<p>I've tried
.date
.value
.clear
.reset
.resetDate</p>
<p>None of them seem to clear the Datepicker.</p>
<p>HTML:</p>
<pre><code> <mat-form-field>
<input matInput [matDatepicker]="fromDatePicker" placeholder="From Date" disabled>
<mat-datepicker-toggle matSuffix [for]="fromDatePicker"></mat-datepicker-toggle>
<mat-datepicker #fromDatePicker disabled="false"></mat-datepicker>
</mat-form-field>
<mat-form-field>
<input matInput [matDatepicker]="toDatePicker" placeholder="To Date" disabled>
<mat-datepicker-toggle matSuffix [for]="toDatePicker"></mat-datepicker-toggle>
<mat-datepicker #toDatePicker disabled="false"></mat-datepicker>
</mat-form-field>
<button mat-raised-button (click)="resetForm()">Reset</button>
</code></pre>
<p>Typescript:</p>
<pre><code> @ViewChild('fromDatePicker') fromDate: any;
@ViewChild('toDatePicker') toDate: any;
resetForm() {
this.searchString.nativeElement.value = "";
this.fromDate.value = undefined;
this.fromDate.date = null;
this.toDate.date = undefined;
};
</code></pre>
| 0debug |
int usb_desc_msos(const USBDesc *desc, USBPacket *p,
int index, uint8_t *dest, size_t len)
{
void *buf = g_malloc0(4096);
int length = 0;
switch (index) {
case 0x0004:
length = usb_desc_msos_compat(desc, buf);
break;
case 0x0005:
length = usb_desc_msos_prop(desc, buf);
break;
}
if (length > len) {
length = len;
}
memcpy(dest, buf, length);
free(buf);
p->actual_length = length;
return 0;
}
| 1threat |
How to create a P2P network without a server? : <p>First I'd like to share a little of WHY I want to create this which seems to be complex:</p>
<p>I've seen that in my city there's a lot of trouble with "lost pets". Since I lost my best companion for 11 years (My dog) I want to contribute my small city by developing a mobile application to allow people upload pictures to a public FTP server (Which I can find for free with a huge amount of storage) and then, create a file format such as JSON o XML and share data information such as: Pet name, location, characteristics, details of how it got lost, special details, picture URLs to show them in the application.</p>
<p>I can contribute with this but I cannot spend time by asking for donations to raise a server nor to maintain it. What I want is to create a simple Peer-To-Peer application to keep updating and sharing XML/JSON files so actually the application would never die and will be 0 server dependent. I have read a lot about P2P programming and that it's the most complex task to do but I really want to do this because I haven't found my best friend and I think this would be really helpful for others (The application is destined to be used just in my city).</p>
<p>What can I use to practice? Are the open source mobile P2P projects to read?</p>
| 0debug |
How To Group and Sort Array element base Specific Character : <p>i have an array Like This :</p>
<pre><code>array("10", "1001","12", "1201","1002", "1202","120101", "120201","13");
</code></pre>
<p>i need Loop in Php to sort and group with Two Character of value to output Like This :</p>
<pre>
-10
--1001
--1002
-12
--1201
--- 120101
--1202
--- 120201
-13
</pre>
<p>Thanks!</p>
| 0debug |
How to create a Dynamic Associative array in PHP, from $_POST values? : I am trying to create php array (associative) declaration for non-empty key-value pairs only, which I am getting from $_POST. Any guesses, how to do this ?
$my_array = [
"k1"=>"$val1",
"k2"=>"$val2",
"k3"=>"$val3",
"k4"=>"$val4"
];
But, if $val4 & $val3 are empty / NULL / does'nt exist, then :
$my_array = [
"k1"=>"$val1",
"k2"=>"$val2"
];
Thanks | 0debug |
SQL INSERT with LEFT JOIN : $sql3="INSERT INTO users_addresses (ua_user_id,ua_address_id) LEFT JOIN users ON users_addresses.ua_user_id=users.user_id LEFT JOIN addresses ON users_addresses.ua_address_id=addresses.address_id"
I want when the forms are completed to fill the users_addresses with the id of the user and the id from the address tables.But for now the sql doesn't fill nothing in the table users_addresses[These are my tables][1]
[1]: https://i.stack.imgur.com/Qg9B4.jpg | 0debug |
static int ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band,
IVITile *tile, int32_t mv_scale)
{
int x, y, need_mc, mbn, blk, num_blocks, mv_x, mv_y, mc_type;
int offs, mb_offset, row_offset;
IVIMbInfo *mb, *ref_mb;
const int16_t *src;
int16_t *dst;
void (*mc_no_delta_func)(int16_t *buf, const int16_t *ref_buf, uint32_t pitch,
int mc_type);
if (tile->num_MBs != IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size)) {
av_log(avctx, AV_LOG_ERROR, "Allocated tile size %d mismatches "
"parameters %d in ivi_process_empty_tile()\n",
tile->num_MBs, IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size));
return AVERROR_INVALIDDATA;
}
offs = tile->ypos * band->pitch + tile->xpos;
mb = tile->mbs;
ref_mb = tile->ref_mbs;
row_offset = band->mb_size * band->pitch;
need_mc = 0;
for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) {
mb_offset = offs;
for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) {
mb->xpos = x;
mb->ypos = y;
mb->buf_offs = mb_offset;
mb->type = 1;
mb->cbp = 0;
if (!band->qdelta_present && !band->plane && !band->band_num) {
mb->q_delta = band->glob_quant;
mb->mv_x = 0;
mb->mv_y = 0;
}
if (band->inherit_qdelta && ref_mb)
mb->q_delta = ref_mb->q_delta;
if (band->inherit_mv) {
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
} else {
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
}
need_mc |= mb->mv_x || mb->mv_y;
}
mb++;
if (ref_mb)
ref_mb++;
mb_offset += band->mb_size;
}
offs += row_offset;
}
if (band->inherit_mv && need_mc) {
num_blocks = (band->mb_size != band->blk_size) ? 4 : 1;
mc_no_delta_func = (band->blk_size == 8) ? ff_ivi_mc_8x8_no_delta
: ff_ivi_mc_4x4_no_delta;
for (mbn = 0, mb = tile->mbs; mbn < tile->num_MBs; mb++, mbn++) {
mv_x = mb->mv_x;
mv_y = mb->mv_y;
if (!band->is_halfpel) {
mc_type = 0;
} else {
mc_type = ((mv_y & 1) << 1) | (mv_x & 1);
mv_x >>= 1;
mv_y >>= 1;
}
for (blk = 0; blk < num_blocks; blk++) {
offs = mb->buf_offs + band->blk_size * ((blk & 1) + !!(blk & 2) * band->pitch);
mc_no_delta_func(band->buf + offs,
band->ref_buf + offs + mv_y * band->pitch + mv_x,
band->pitch, mc_type);
}
}
} else {
src = band->ref_buf + tile->ypos * band->pitch + tile->xpos;
dst = band->buf + tile->ypos * band->pitch + tile->xpos;
for (y = 0; y < tile->height; y++) {
memcpy(dst, src, tile->width*sizeof(band->buf[0]));
src += band->pitch;
dst += band->pitch;
}
}
return 0;
}
| 1threat |
Error in sql devloper : create table Blog
(
blog_id NUMBER(8,0),
blog_name VARCHAR2(255) not null,
status VARCHAR2(50) DEFAULT 'PENDING',
create_date DATE default sysDate,
description CLOB not null,
no_of_likes NUMBER(5),
no_of comments NUMBER(5),
no_of_views NUMBER(5),
user_id NUMBER(8,0),
CONSTRAINT pk_blog_blog_id PRIMARY KEY (blog_id),
CONSTRAINT fk_blog_user_id FOREIGN KEY (user_id) REFERENCES USER_DETAILS (user_id)
);
-------------------------------------------------------------
Error starting at line : 1 in command -
create table Blog
(
blog_id NUMBER(8,0),
blog_name VARCHAR2(255) not null,
status VARCHAR2(50) DEFAULT 'PENDING',
create_date DATE default sysDate,
description CLOB not null,
no_of_likes NUMBER(5),
no_of comments NUMBER(5),
no_of_views NUMBER(5),
user_id NUMBER(8,0),
CONSTRAINT pk_blog_blog_id PRIMARY KEY (blog_id),
CONSTRAINT fk_blog_user_id FOREIGN KEY (user_id) REFERENCES USER_DETAILS (user_id)
)
Error report -
ORA-00907: missing right parenthesis
00907. 00000 - "missing right parenthesis"
*Cause:
*Action:
| 0debug |
How can I extract the specific words from a string in Python? : I need a program to accept a string and extract specific words get an output like this in Python?
Input string:
My name is somename. I am from India and I'm an Engineer.
Output should be:
Name : Somename
Locaion : India
Profession : Engineer
Please can anyone help me regarding this. | 0debug |
static ExitStatus gen_mfpr(TCGv va, int regno)
{
int data = cpu_pr_data(regno);
if (regno == 250 || regno == 249) {
void (*helper)(TCGv) = gen_helper_get_walltime;
if (regno == 249) {
helper = gen_helper_get_vmtime;
}
if (use_icount) {
gen_io_start();
helper(va);
gen_io_end();
return EXIT_PC_STALE;
} else {
helper(va);
return NO_EXIT;
}
}
if (data == 0) {
tcg_gen_movi_i64(va, 0);
} else if (data & PR_BYTE) {
tcg_gen_ld8u_i64(va, cpu_env, data & ~PR_BYTE);
} else if (data & PR_LONG) {
tcg_gen_ld32s_i64(va, cpu_env, data & ~PR_LONG);
} else {
tcg_gen_ld_i64(va, cpu_env, data);
}
return NO_EXIT;
}
| 1threat |
Problem with my SQLite (SQLiteOpenHelper) : I am creating a sqlite database with android studio. My application closes at the call of my method "Insertprofile () " in my main.
My DatabaseManager :
public class DatabaseManager extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "Userx.db";
private static final int DATABASE_VERSION = 1;
SQLiteDatabase db;
public DatabaseManager( Context context ) {
super( context, DATABASE_NAME, null, DATABASE_VERSION );
}
@Override
public void onCreate(SQLiteDatabase db) {
String strSql = "create table User ("
+ " id integer primary key autoincrement,"
+ " mission integer not null,"
+ " day integer not null"
+ ")";
db.execSQL( strSql );
Log.i( "DATABASE", "onCreate invoked" );
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
public void insertProfil( int mission, int day ) {
//name = name.replace( "'", "''" );
String strSql = "INSERT INTO User (mission, day) VALUES ("
+ mission + ", " + day + ")";
this.getWritableDatabase().execSQL( strSql );
Log.i( "DATABASE", "insertScore invoked" );
}
public Profil readData() {
Profil profil = null;
//REQUEST
String strSql = "SELECT * from User";
//CREATE CURSOR WITH REQUEST
Cursor cursor = this.getReadableDatabase().rawQuery(strSql, null);
//PUT IN TOP
cursor.moveToFirst();
if (!cursor.isAfterLast()) {
//RECEPT DATA AND CREATE VALUES THIS
Integer id = cursor.getInt(0);
Integer mission = cursor.getInt(1);
Integer day = cursor.getInt(2);
profil = new Profil(id, mission, day);
//POSSIBLE CREATE LIST WITH WHILE
}
cursor.close();
return profil;
}
public void modifyData(int mission){
SQLiteDatabase db = this.getWritableDatabase();
String strSql = "UPDATE User SET mission = " + mission + " WHERE id = " + "1";
db.execSQL( strSql );
}
public void deleteData(){
String strSql = "DELETE FROM User" ;
this.getWritableDatabase().execSQL( strSql );
}
}
And my Main:
public class MainActivity extends AppCompatActivity {
private TextView profil_text;
private DatabaseManager databaseManager;
Profil profil;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
profil_text = (TextView) findViewById( R.id.profil_text);
Log.d("**************1", "onCreate: ");
databaseManager = new DatabaseManager(this);
Log.d("**************2", "onCreate: ");
Log.d("**************3", "onCreate: ");
databaseManager.modifyData(80);
Log.d("**************4", "onCreate: ");
profil = databaseManager.readData();
Log.d("**************5", "onCreate: ");
profil_text.setText(Integer.toString(profil.getMission()));
databaseManager.close();
}
And my class profil is just simple classe with getter and setter and constructor.
PS: I'm french, my English is bad. | 0debug |
Do we have to unsubscribe when using switchMap operator in rxjs in Angular 2? : <p>In Angular 2 there are some observables that you do not need to unsubscribe from. For example http requests and activatedRoute.params.</p>
<p><a href="https://stackoverflow.com/questions/38008334/angular-rxjs-when-should-i-unsubscribe-from-subscription">Angular/RxJs When should I unsubscribe from `Subscription`</a></p>
<p>But what happens when I use switchMap on for example activatedRoute.params and inside that switchMap I access a service that returns an observable that would need to be unsubscribed if subscribed to in the usual way.</p>
<p>Something like this:</p>
<pre><code>this.activatedRoute.params
.switchMap((params: Params) => this.userService.getUser(+params['id']))
.subscribe((user: User) => this.user = user);
</code></pre>
<p>If I called this.userService without the switchMap and without activatedRoute.params I would have to unsubscribe from it.</p>
<pre><code>// userService.getUser() takes in optional id?: number.
this.subscription = this.userService.getUser().subscribe(
(user: User) => {
this.user = user;
}
);
</code></pre>
<p>And then later..</p>
<pre><code>this.subscription.unsubscribe();
</code></pre>
<p>My question is, do I need to unsubscribe from activatedRoute.params if I use switchMap on it and call a service that would need to be unsubscribed otherwise?</p>
| 0debug |
.next() not work for .toggle() : I using jquery function Toggle() to create a Pull down menu
But I will add many sub menu in this project.
I need th click the `a.sub_open` to toggle the `div.submenu`
https://jsfiddle.net/mr6b4k53/
js code:
$(document).ready(function(){
$( ".sub_open" ).click(function() {
$(".sub_menu").next.toggle("blind", 0, 500);
});
});
any suggest? | 0debug |
e1000e_set_pbaclr(E1000ECore *core, int index, uint32_t val)
{
int i;
core->mac[PBACLR] = val & E1000_PBACLR_VALID_MASK;
if (msix_enabled(core->owner)) {
return;
}
for (i = 0; i < E1000E_MSIX_VEC_NUM; i++) {
if (core->mac[PBACLR] & BIT(i)) {
msix_clr_pending(core->owner, i);
}
}
}
| 1threat |
ActionCable Not Receiving Data : <p>I created the following using ActionCable but not able to receive any data that is being broadcasted.</p>
<p><strong>Comments Channel</strong>:</p>
<pre><code>class CommentsChannel < ApplicationCable::Channel
def subscribed
comment = Comment.find(params[:id])
stream_for comment
end
end
</code></pre>
<p><strong>JavaScript</strong>:</p>
<pre><code>var cable = Cable.createConsumer('ws://localhost:3000/cable');
var subscription = cable.subscriptions.create({
channel: "CommentsChannel",
id: 1
},{
received: function(data) {
console.log("Received data")
}
});
</code></pre>
<p>It connects fine and I can see the following in the logs:</p>
<pre><code>CommentsChannel is streaming from comments:Z2lkOi8vdHJhZGUtc2hvdy9FdmVudC8x
</code></pre>
<p>I then broadcast to that stream:</p>
<pre><code>ActionCable.server.broadcast "comments:Z2lkOi8vdHJhZGUtc2hvdy9FdmVudC8x", { test: '123' }
</code></pre>
<p>The issue is that the <code>received</code> function is never called. Am I doing something wrong?</p>
<p>Note: I'm using the <code>actioncable</code> npm package to connect from a BackboneJS application.</p>
| 0debug |
Wordpress cronjob every 3 minutes : <p>there are many post on stackoverflow with this topic but (i dont know why) nothing will work for me.</p>
<p>What i have</p>
<pre><code>function isa_add_every_three_minutes( $schedules ) {
$schedules['every_three_minutes'] = array(
'interval' => 180,
'display' => __( 'Every 3 Minutes', 'textdomain' )
);
return $schedules;
}
add_filter( 'cron_schedules', 'isa_add_every_three_minutes' );
function every_three_minutes_event_func()
{
// do something
}
wp_schedule_event( time(), 'every_three_minutes', 'every_three_minutes_event_func' );
</code></pre>
<p>Any ideas what i'm doing wrong?</p>
| 0debug |
python basic: how to sort a list only by considering the number? : <p>I admit I dont know how to give this question a better title. :-( Anybody has a better idea for the title? </p>
<p>Here is my problem: </p>
<p>I want to sort this list:</p>
<pre><code>a = ['at10', 'at11', 'at12', 'at13', 'at9', 'at1', 'at8']
</code></pre>
<p>Every item from the list begins with two letters and has some numbers.</p>
<p>The desired result is as followings. The list is sorted by numbers.</p>
<pre><code>['at1', 'at8', 'at9', 'at10', 'at11', 'at12', 'at13']
</code></pre>
<p>I tried with <code>sorted(a)</code> and many of its <code>key</code> settings. But I could not get the result. Anybody please help me out? Thanks in advance! </p>
| 0debug |
I was wondering if This is the Best Way to Use #define : Hello everyone (my first post on this website),
I am teaching myself C language by reading the **"C by example"** book by **Greg Perry**, and I just finished chapter 6 **"Preprocessor Directives".**
At the end of each chapter, there are review exercises to complete (in order to make sure you understand what the topic is talking about and how to apply it.
I am on the 4th review exercise for chapter 6, and I was wondering if this is the right way to do it **(The exercise is written at the top of the picture)**:
[The code I wrote for the exercise][1]
[1]: http://i.stack.imgur.com/2VAov.png
My question: Is this the best way to complete the exercise, or is there an easier way which is a lot more efficient?
Thank you in advance for the help :) | 0debug |
PythonL: invalid syntax file "<fstring>", line 1 : <p>When doing <code>python3 Webhook.py</code> (<a href="https://github.com/camielverdult/dis-nv-updatechecker.py/blob/master/Webhook.py" rel="noreferrer">this</a> is the file), it gives me the error:
<code>
File "<fstring>", line 1
(%X - %x)
^
SyntaxError: invalid syntax
</code></p>
<p>I've tried to print out the raw contents of the file and I also used a hex editor, there is nothing on line 1 that should be causing erorrs. I also did:
<code>
import time, os, aiohttp, plistlib, discord, asyncio, json, subprocess
</code>
In the Terminal.app version of Python3 and I had no errors, my version was 3.6.3 but updated to 3.6.5 to check if the issue would go away, which didn't. Can anyone help?</p>
| 0debug |
static void update(Real288_internal *glob)
{
float buffer1[40], temp1[37];
float buffer2[8], temp2[11];
memcpy(buffer1 , glob->output + 20, 20*sizeof(*buffer1));
memcpy(buffer1 + 20, glob->output , 20*sizeof(*buffer1));
do_hybrid_window(36, 40, 35, buffer1, temp1, glob->st1a, glob->st1b,
syn_window);
if (eval_lpc_coeffs(temp1, glob->st1, 36))
colmult(glob->pr1, glob->st1, table1a, 36);
memcpy(buffer2 , glob->history + 4, 4*sizeof(*buffer2));
memcpy(buffer2 + 4, glob->history , 4*sizeof(*buffer2));
do_hybrid_window(10, 8, 20, buffer2, temp2, glob->st2a, glob->st2b,
gain_window);
if (eval_lpc_coeffs(temp2, glob->st2, 10))
colmult(glob->pr2, glob->st2, table2a, 10);
}
| 1threat |
static void fill_prefetch_fifo(struct omap_gpmc_s *s)
{
int fptr;
int cs = prefetch_cs(s->prefetch.config1);
int is16bit = (((s->cs_file[cs].config[0] >> 12) & 3) != 0);
int bytes;
bytes = 64 - s->prefetch.fifopointer;
if (bytes > s->prefetch.count) {
bytes = s->prefetch.count;
s->prefetch.count -= bytes;
s->prefetch.fifopointer += bytes;
fptr = 64 - s->prefetch.fifopointer;
while (fptr < (64 - bytes)) {
s->prefetch.fifo[fptr] = s->prefetch.fifo[fptr + bytes];
fptr++;
while (fptr < 64) {
uint32_t v = omap_nand_read(&s->cs_file[cs], 0, 2);
s->prefetch.fifo[fptr++] = v & 0xff;
s->prefetch.fifo[fptr++] = (v >> 8) & 0xff;
} else {
s->prefetch.fifo[fptr++] = omap_nand_read(&s->cs_file[cs], 0, 1);
if (s->prefetch.startengine && (s->prefetch.count == 0)) {
s->irqst |= 2;
s->prefetch.startengine = 0;
if (s->prefetch.fifopointer != 0) {
omap_gpmc_dma_update(s, 1);
omap_gpmc_int_update(s); | 1threat |
How to convert data from monthly to annual in R? : <p>I need to convert monthly observations into annual -- year-country instead of month-country. </p>
<p>This is how the data looks: </p>
<pre><code>year month countrycode troop
1990 1 USA 6
1990 2 USA 4
1990 3 CANADA 3
1990 4 CANADA 6
1991 1 USA 5
1991 2 USA 6
1991 3 CANADA 3
1991 4 CANADA 6
</code></pre>
<p>I would like to convert this into: </p>
<pre><code>year countrycode troop
1990 USA 10
1990 CANADA 9
1991 USA 11
1991 CANADA 9
</code></pre>
<p>I have no clue how to start so I'm grateful for all suggestions! </p>
| 0debug |
How to split an ansible role's `defaults/main.yml` file into multiple files? : <p>In some ansible roles (e.g. <code>roles/my-role/</code>) I've got quite some big default variables files (<code>defaults/main.yml</code>). I'd like to split the <code>main.yml</code> into several smaller files. Is it possible to do that?</p>
<p>I've tried creating the files <code>defaults/1.yml</code> and <code>defaults/2.yml</code>, but they aren't loaded by ansible.</p>
| 0debug |
String a = "x"; then String x = a.substring(1) Wouldn't there be an error like indexOutOfRange? : <p>I am so confused. I thought to use str.substring(1), str has to be at least 2 characters, otherwise there should be index of of bound. But when I typed in, Java doesn't give any error. Why?</p>
| 0debug |
Why does a*a match aaa? : <p>I am using python3 re module - I find that <code>a*a</code> matches <code>aaa</code>. I thought that regex was greedy by default (unless we override it to be lazy with <code>?</code>) - so, <code>a*</code> would have matched the entire string, and the trailing <code>a</code> in the pattern would fail. However, it matches:</p>
<pre><code>$ import re
$ re.match(r'a*a', 'aaa')
<_sre.SRE_Match object; span=(0, 3), match='aaa'>
</code></pre>
<p>Should this not fail?</p>
| 0debug |
how to remove several positions in an array : <p>I want remove specific positions in an array (I saw similar question, but removing values, not the positions), and I'm having some problems. Let's say I have:</p>
<pre><code> myval <- runif(1:1805)
pos <- c(240,601,962,1323,1684) #positions to remove
</code></pre>
<p>if I do: </p>
<pre><code> myval[pos] <- NULL
</code></pre>
<p>it doesn't work..
And neither with </p>
<pre><code> myval[myval!=myval[pos]]
</code></pre>
<p>Any suggestion??</p>
<p>Thanks!</p>
| 0debug |
CompletableFuture supplyAsync : <p>I've just started exploring some concurrency features of Java 8. One thing confused me a bit is these two static methods:</p>
<pre><code>CompletableFuture<Void> runAsync(Runnable runnable)
CompletableFuture<U> supplyAsync(Supplier<U> supplier)
</code></pre>
<p>Do anyone know why they choose to use interface Supplier? Isn't it more natural to use Callable, which is the analogy of Runnable that returns a value? Is that because Supplier doesn't throw an Exception that couldn't be handled?</p>
| 0debug |
static int bdrv_wr_badreq_bytes(BlockDriverState *bs,
int64_t offset, int count)
{
int64_t size = bs->total_sectors << SECTOR_BITS;
if (count < 0 ||
offset < 0)
return 1;
if (offset > size - count) {
if (bs->autogrow)
bs->total_sectors = (offset + count + SECTOR_SIZE - 1) >> SECTOR_BITS;
else
return 1;
}
return 0;
}
| 1threat |
check http status code using nightwatch : <p>how do I check the HTTP status code using nightwatch.js? I tried </p>
<pre><code> browser.url(function (response) {
browser.assert.equal(response.statusCode, 200);
});
</code></pre>
<p>but of course that does not work.</p>
| 0debug |
Docker for Windows error: "Hardware assisted virtualization and data execution protection must be enabled in the BIOS" : <p>I've installed Docker and I'm getting this error when I run the GUI:</p>
<blockquote>
<p>Hardware assisted virtualization and data execution protection must
be enabled in the BIOS</p>
</blockquote>
<p>Seems like a bug since Docker works like a charm from the command line, but I'm wondering if anyone has a clue about why this is happening?</p>
<p>Before you ask, yes, I've enabled virtualization in the BIOS and the Intel Processor Identification Utility confirms that it's activated. Docker, docker-machine and docker-compose all work from the command line, Virtualbox works, running Docker from a Debian or Ubuntu VM works.</p>
<p>There's just this weird issue about the GUI.</p>
<p>My specs:</p>
<ul>
<li>Windows 10 Pro x64 Anniversary Edition</li>
<li>Intel core i5-6300HQ @ 2.30GHz</li>
</ul>
| 0debug |
How to compare old password from migrated data using bycrypt : I recently migrated my users table from sql server to mongodb using pentaho etl tool.The password field is binary data type but i am using bycrypt to hash password in nodejs for all new user creation so how do i compare my old users password with bycrypt since that is encrypted using sql server ? Any help would be really appreciated,Thanks. | 0debug |
Android Studio - Update to 2.3 - Studio doesn't have write access : <p>I didn't have this problem before. When i am trying to update Android Studio to 2.3, i get this:</p>
<pre><code>Studio does not have write access to /private/var/folders/00/n4yy8fsx0njck05bfll1t3_w0000gn/T/AppTranslocation/2D9E214E-60BE-41D9-9843-3536E011FD7E/d/Android Studio.app/Contents. Please run it by a privileged user to update.
</code></pre>
<p>The account that i am in is Admin account and i also tried to give full access to that directory.</p>
<pre><code>chmod -R 777 /private/var/....
</code></pre>
<p>but nothing worked. Any help will be much appreciated.</p>
| 0debug |
write if condition with two execution statement in single line python : Here is what I am looking for:
if 1: print("hello")
hello
But when I tried something like this:
>>> if 1: print("hello") print("end")
File "<stdin>", line 1
if 1: print("hello") print("end")
^
SyntaxError: invalid syntax
Why there is a syntax error? What is the right way to write multiple execution statement in single line with the `if` condition? | 0debug |
How to put two child of Kendo grid hierarchy into tab : I have one parent table and two child table in hierarchy. what I want is to have a design that the child table was in seperate tab.
This is the sample of what I've already tried. https://dojo.telerik.com/ubiZewAh
| 0debug |
static int v9fs_synth_rename(FsContext *ctx, const char *oldpath,
const char *newpath)
{
errno = EPERM;
return -1;
}
| 1threat |
No integration defined for method - Choose a stage where your API will be deployed : <p>I'm working with AWS API Gateway and AWS Lambda. Often I face this type of error message when attempt to deploy API. The error message says to select a deployment stage. But I still selecting and trying to deploy! but same error occur!</p>
<p><a href="https://i.stack.imgur.com/OAmZd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/OAmZd.png" alt="Screenshot of pop up error message"></a></p>
<p>In this API I have multiple resources with multiple methods. Previously I succeed to deploy this same API with the same way. But now I can't deploy it.</p>
<p>Please anyone help me to fix it. For addition: I don't use AWS CLI tool, just use AWS web dashboard.</p>
| 0debug |
Draws a Xmas tree on the screen of using size : I've been trying draw a Xmas tree by using size which is input from user and I also have been trying to find out the logic such as spaces would it take. Any hint for me would be fantastic. Also, this lab requires only one "for" loop and have to call the method write-pattern which I provide below. Thank you so much.
Sorry if the code was too long. It's just to make sure that you guys can understand it.
for (int i=0; i <=size; i++) {
writePattern (' ','*',' ', ' ',' ',size -i,i,0,0,0,size+2);
writePattern (' ','*','*',' ',' ',size -i,i,i,0,0,size+2);
}
This is the wrirePattern that I mentioned above.
private void writePattern(char ch1, char ch2, char ch3, char ch4, char ch5, int n1, int n2, int n3, int n4, int n5, int length)
{
while ((n1 > 0) && (length > 0)) {
System.out.print(ch1);
n1--;
length--;
}
while ((n2 > 0) && (length > 0)) {
System.out.print(ch2);
n2--;
length--;
}
while ((n3 > 0) && (length > 0)) {
System.out.print(ch3);
n3--;
length--;
}
while ((n4 > 0) && (length > 0)) {
System.out.print(ch4);
n4--;
length--;
}
while ((n5 > 0) && (length > 0)) {
System.out.print(ch5);
n5--;
length--;
}
System.out.println();
}
This is from another class which uses to give the output:
`drawer.drawXmasTree();
System.out.println("\n");`;
| 0debug |
When scale the data, why the train dataset use 'fit' and 'transform', but the test dataset only use 'transform'? : <p>When scale the data, why the train dataset use 'fit' and 'transform', but the test dataset only use 'transform'?</p>
<pre><code>SAMPLE_COUNT = 5000
TEST_COUNT = 20000
seed(0)
sample = list()
test_sample = list()
for index, line in enumerate(open('covtype.data','rb')):
if index < SAMPLE_COUNT:
sample.append(line)
else:
r = randint(0,index)
if r < SAMPLE_COUNT:
sample[r] = line
else:
k = randint(0,index)
if k < TEST_COUNT:
if len(test_sample) < TEST_COUNT:
test_sample.append(line)
else:
test_sample[k] = line
from sklearn.preprocessing import StandardScaler
for n, line in enumerate(sample):
sample[n] = map(float, line.strip().split(','))
y = np.array(sample)[:,-1]
scaling = StandardScaler()
X = scaling.fit_transform(np.array(sample)[:,:-1]) ##here use fit and transform
for n,line in enumerate(test_sample):
test_sample[n] = map(float,line.strip().split(','))
yt = np.array(test_sample)[:,-1]
Xt = scaling.transform(np.array(test_sample)[:,:-1])##why here only use transform
</code></pre>
<p>As the annotation says, why Xt only use transform but no fit?</p>
| 0debug |
Regular expression to get data between two strings in java : <p>I am trying to get data between the two strings "Account:" and "Account" from the below string using regular expression.</p>
<pre><code> String str= "Order Confirmation Account: Sample Account ID: 1111"
</code></pre>
<p>The regular expression I used is:</p>
<pre><code> Pattern pattern = Pattern.compile("Account:(.*)Account");
Matcher matcher = pattern.matcher(str);
System.out.println("Account name is:"+matcher.group(1));
</code></pre>
<p>The actual output I get is:</p>
<pre><code>java.lang.IllegalStateException: No match found
at java.util.regex.Matcher.group(Unknown Source)
at WorkingProgram$1.run(WorkingProgram.java:102)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown Source)
at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
</code></pre>
<p>The expected output is:</p>
<pre><code>Sample
</code></pre>
<p>What is wrong with my regular expression?</p>
| 0debug |
int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
{
char buf1[32], tuple_type[32];
int h, w, depth, maxval;
pnm_get(s, buf1, sizeof(buf1));
s->type= buf1[1]-'0';
if(buf1[0] != 'P')
return AVERROR_INVALIDDATA;
if (s->type==1 || s->type==4) {
avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
} else if (s->type==2 || s->type==5) {
if (avctx->codec_id == AV_CODEC_ID_PGMYUV)
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
else
avctx->pix_fmt = AV_PIX_FMT_GRAY8;
} else if (s->type==3 || s->type==6) {
avctx->pix_fmt = AV_PIX_FMT_RGB24;
} else if (s->type==7) {
w = -1;
h = -1;
maxval = -1;
depth = -1;
tuple_type[0] = '\0';
for (;;) {
pnm_get(s, buf1, sizeof(buf1));
if (!strcmp(buf1, "WIDTH")) {
pnm_get(s, buf1, sizeof(buf1));
w = strtol(buf1, NULL, 10);
} else if (!strcmp(buf1, "HEIGHT")) {
pnm_get(s, buf1, sizeof(buf1));
h = strtol(buf1, NULL, 10);
} else if (!strcmp(buf1, "DEPTH")) {
pnm_get(s, buf1, sizeof(buf1));
depth = strtol(buf1, NULL, 10);
} else if (!strcmp(buf1, "MAXVAL")) {
pnm_get(s, buf1, sizeof(buf1));
maxval = strtol(buf1, NULL, 10);
} else if (!strcmp(buf1, "TUPLTYPE") ||
!strcmp(buf1, "TUPLETYPE")) {
pnm_get(s, tuple_type, sizeof(tuple_type));
} else if (!strcmp(buf1, "ENDHDR")) {
break;
} else {
return AVERROR_INVALIDDATA;
}
}
if (w <= 0 || h <= 0 || maxval <= 0 || depth <= 0 || tuple_type[0] == '\0' || av_image_check_size(w, h, 0, avctx) || s->bytestream >= s->bytestream_end)
return AVERROR_INVALIDDATA;
avctx->width = w;
avctx->height = h;
s->maxval = maxval;
if (depth == 1) {
if (maxval == 1) {
avctx->pix_fmt = AV_PIX_FMT_MONOBLACK;
} else if (maxval < 256) {
avctx->pix_fmt = AV_PIX_FMT_GRAY8;
} else {
avctx->pix_fmt = AV_PIX_FMT_GRAY16;
}
} else if (depth == 2) {
if (maxval == 255)
avctx->pix_fmt = AV_PIX_FMT_GRAY8A;
} else if (depth == 3) {
if (maxval < 256) {
avctx->pix_fmt = AV_PIX_FMT_RGB24;
} else {
avctx->pix_fmt = AV_PIX_FMT_RGB48;
}
} else if (depth == 4) {
if (maxval < 256) {
avctx->pix_fmt = AV_PIX_FMT_RGBA;
} else {
avctx->pix_fmt = AV_PIX_FMT_RGBA64;
}
} else {
return AVERROR_INVALIDDATA;
}
return 0;
} else {
return AVERROR_INVALIDDATA;
}
pnm_get(s, buf1, sizeof(buf1));
w = atoi(buf1);
pnm_get(s, buf1, sizeof(buf1));
h = atoi(buf1);
if(w <= 0 || h <= 0 || av_image_check_size(w, h, 0, avctx) || s->bytestream >= s->bytestream_end)
return AVERROR_INVALIDDATA;
avctx->width = w;
avctx->height = h;
if (avctx->pix_fmt != AV_PIX_FMT_MONOWHITE && avctx->pix_fmt != AV_PIX_FMT_MONOBLACK) {
pnm_get(s, buf1, sizeof(buf1));
s->maxval = atoi(buf1);
if (s->maxval <= 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid maxval: %d\n", s->maxval);
s->maxval = 255;
}
if (s->maxval >= 256) {
if (avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
avctx->pix_fmt = AV_PIX_FMT_GRAY16;
} else if (avctx->pix_fmt == AV_PIX_FMT_RGB24) {
avctx->pix_fmt = AV_PIX_FMT_RGB48;
} else if (avctx->pix_fmt == AV_PIX_FMT_YUV420P && s->maxval < 65536) {
if (s->maxval < 512)
avctx->pix_fmt = AV_PIX_FMT_YUV420P9;
else if (s->maxval < 1024)
avctx->pix_fmt = AV_PIX_FMT_YUV420P10;
else
avctx->pix_fmt = AV_PIX_FMT_YUV420P16;
} else {
av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format\n");
avctx->pix_fmt = AV_PIX_FMT_NONE;
return AVERROR_INVALIDDATA;
}
}
}else
s->maxval=1;
if (av_pix_fmt_desc_get(avctx->pix_fmt)->flags & AV_PIX_FMT_FLAG_PLANAR) {
if ((avctx->width & 1) != 0)
return AVERROR_INVALIDDATA;
h = (avctx->height * 2);
if ((h % 3) != 0)
return AVERROR_INVALIDDATA;
h /= 3;
avctx->height = h;
}
return 0;
}
| 1threat |
static int colo_packet_compare_other(Packet *spkt, Packet *ppkt)
{
trace_colo_compare_main("compare other");
if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {
char pri_ip_src[20], pri_ip_dst[20], sec_ip_src[20], sec_ip_dst[20];
strcpy(pri_ip_src, inet_ntoa(ppkt->ip->ip_src));
strcpy(pri_ip_dst, inet_ntoa(ppkt->ip->ip_dst));
strcpy(sec_ip_src, inet_ntoa(spkt->ip->ip_src));
strcpy(sec_ip_dst, inet_ntoa(spkt->ip->ip_dst));
trace_colo_compare_ip_info(ppkt->size, pri_ip_src,
pri_ip_dst, spkt->size,
sec_ip_src, sec_ip_dst);
}
return colo_packet_compare_common(ppkt, spkt, 0);
}
| 1threat |
Matlab make matrix from calculation : <p>so i have this code,
clc
data=[1;3;4;3;5;2;5]
cnt=size(data,1)</p>
<pre><code> for i=2:cnt;
im=(data(i)-(data(i-1)))
end
im
</code></pre>
<p>i need a matrix output from that code</p>
<p>but my output still like this</p>
<pre><code>data =
1
3
4
3
5
2
5
cnt =
7
im =
2
im =
1
im =
-1
im =
2
im =
-3
im =
3
</code></pre>
<p>how to make this kind of output?</p>
<pre><code>im =
2
1
-1
2
-3
3
</code></pre>
<p>i still confused to got an output like that?</p>
| 0debug |
how to perform regex for password validation without special character? : <p>Regex for password of minimum length-7 without special characters , atleast one uppercase and one number .</p>
<p>In my case, regex which satisfies:</p>
<p><strong>Killer1 - atleast one uppercase (K), atleast one number (1) , minumum length - 7</strong></p>
<p><strong>Melbourne123- valid</strong></p>
<p><strong>London24 - valid</strong></p>
<p>Thanks in advance.</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.