problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
Why In custom listview listview is not working with setOnItemClickListner in android? : I have a list view with two text view and one edit text in each row , list view setOnItemClickListener() is not working. | 0debug |
static void tap_cleanup(VLANClientState *nc)
{
TAPState *s = DO_UPCAST(TAPState, nc, nc);
if (s->vhost_net) {
vhost_net_cleanup(s->vhost_net);
}
qemu_purge_queued_packets(nc);
if (s->down_script[0])
launch_script(s->down_script, s->down_script_arg, s->fd);
tap_read_poll(s, 0);
tap_write_poll(s, 0);
close(s->fd);
} | 1threat |
static int mig_save_device_dirty(QEMUFile *f, BlkMigDevState *bmds,
int is_async)
{
BlkMigBlock *blk;
int64_t total_sectors = bmds->total_sectors;
int64_t sector;
int nr_sectors;
int ret = -EIO;
for (sector = bmds->cur_dirty; sector < bmds->total_sectors;) {
blk_mig_lock();
if (bmds_aio_inflight(bmds, sector)) {
blk_mig_unlock();
bdrv_drain_all();
} else {
blk_mig_unlock();
}
if (bdrv_get_dirty(bmds->bs, bmds->dirty_bitmap, sector)) {
if (total_sectors - sector < BDRV_SECTORS_PER_DIRTY_CHUNK) {
nr_sectors = total_sectors - sector;
} else {
nr_sectors = BDRV_SECTORS_PER_DIRTY_CHUNK;
}
blk = g_new(BlkMigBlock, 1);
blk->buf = g_malloc(BLOCK_SIZE);
blk->bmds = bmds;
blk->sector = sector;
blk->nr_sectors = nr_sectors;
if (is_async) {
blk->iov.iov_base = blk->buf;
blk->iov.iov_len = nr_sectors * BDRV_SECTOR_SIZE;
qemu_iovec_init_external(&blk->qiov, &blk->iov, 1);
blk->aiocb = bdrv_aio_readv(bmds->bs, sector, &blk->qiov,
nr_sectors, blk_mig_read_cb, blk);
blk_mig_lock();
block_mig_state.submitted++;
bmds_set_aio_inflight(bmds, sector, nr_sectors, 1);
blk_mig_unlock();
} else {
ret = bdrv_read(bmds->bs, sector, blk->buf, nr_sectors);
if (ret < 0) {
goto error;
}
blk_send(f, blk);
g_free(blk->buf);
g_free(blk);
}
bdrv_reset_dirty(bmds->bs, sector, nr_sectors);
break;
}
sector += BDRV_SECTORS_PER_DIRTY_CHUNK;
bmds->cur_dirty = sector;
}
return (bmds->cur_dirty >= bmds->total_sectors);
error:
DPRINTF("Error reading sector %" PRId64 "\n", sector);
g_free(blk->buf);
g_free(blk);
return ret;
}
| 1threat |
static void cpu_exec_nocache(CPUArchState *env, int max_cycles,
TranslationBlock *orig_tb)
{
CPUState *cpu = ENV_GET_CPU(env);
TranslationBlock *tb;
target_ulong pc = orig_tb->pc;
target_ulong cs_base = orig_tb->cs_base;
uint64_t flags = orig_tb->flags;
if (max_cycles > CF_COUNT_MASK)
max_cycles = CF_COUNT_MASK;
tb_phys_invalidate(orig_tb, -1);
tb = tb_gen_code(cpu, pc, cs_base, flags,
max_cycles);
cpu->current_tb = tb;
trace_exec_tb_nocache(tb, tb->pc);
cpu_tb_exec(cpu, tb->tc_ptr);
cpu->current_tb = NULL;
tb_phys_invalidate(tb, -1);
tb_free(tb);
}
| 1threat |
static int v9fs_complete_rename(V9fsState *s, V9fsRenameState *vs)
{
int err = 0;
char *old_name, *new_name;
char *end;
if (vs->newdirfid != -1) {
V9fsFidState *dirfidp;
dirfidp = lookup_fid(s, vs->newdirfid);
if (dirfidp == NULL) {
err = -ENOENT;
goto out;
}
BUG_ON(dirfidp->fid_type != P9_FID_NONE);
new_name = qemu_mallocz(dirfidp->path.size + vs->name.size + 2);
strcpy(new_name, dirfidp->path.data);
strcat(new_name, "/");
strcat(new_name + dirfidp->path.size, vs->name.data);
} else {
old_name = vs->fidp->path.data;
end = strrchr(old_name, '/');
if (end) {
end++;
} else {
end = old_name;
}
new_name = qemu_mallocz(end - old_name + vs->name.size + 1);
strncat(new_name, old_name, end - old_name);
strncat(new_name + (end - old_name), vs->name.data, vs->name.size);
}
v9fs_string_free(&vs->name);
vs->name.data = qemu_strdup(new_name);
vs->name.size = strlen(new_name);
if (strcmp(new_name, vs->fidp->path.data) != 0) {
if (v9fs_do_rename(s, &vs->fidp->path, &vs->name)) {
err = -errno;
} else {
V9fsFidState *fidp;
for (fidp = s->fid_list; fidp; fidp = fidp->next) {
if (vs->fidp == fidp) {
continue;
}
if (!strncmp(vs->fidp->path.data, fidp->path.data,
strlen(vs->fidp->path.data))) {
v9fs_fix_path(&fidp->path, &vs->name,
strlen(vs->fidp->path.data));
}
}
v9fs_string_copy(&vs->fidp->path, &vs->name);
}
}
out:
v9fs_string_free(&vs->name);
return err;
}
| 1threat |
Trying to add array list for android project : I am new in androide programming and I cant understand the proplem
[proplem 1][1]
[1]: https://i.stack.imgur.com/BtOw6.png
and another one here
[proplem 2][2]
[2]: https://i.stack.imgur.com/mOb0M.png | 0debug |
Cannot find module 'csstype' : <p>I'm new in react with typescript. I installed react, react-dom; then installed @types/react, @types/react-dom, everything fine, everything works, except that I get error <code>ERROR in [at-loader] ./node_modules/@types/react/index.d.ts:55:22</code> <code>Cannot find module 'csstype'</code>. So I looked to the file in this path, and notice that vscode underlines line - <code>import * as CSS from 'csstype';</code> with red line and marks as cannot find module. I tried <code>yarn add csstype</code>, <code>yarn add csstype -D</code>, did not help. Any idea how fix error? [App works with error]. </p>
| 0debug |
Need help combining two python codes together for raspberry pi with a servo and ldr sensor : I have a python code running on my raspberry pi 2b and a light sensor, which measures the amount of time it takes for the capacitor of the light sensor to charge and send the pin high:
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
pin_to_circuit = 7
def rc_time (pin_to_circuit):
count = 0
#Output on the pin for
GPIO.setup(pin_to_circuit, GPIO.OUT)
GPIO.output(pin_to_circuit, GPIO.LOW)
time.sleep(0.1)
#Change the pin back to input
GPIO.setup(pin_to_circuit, GPIO.IN)
#Count until the pin goes high
while (GPIO.input(pin_to_circuit) == GPIO.LOW):
count += 1
if count > 1000000:
return True
else:
return count
#Catch when script is interrupted, cleanup correctly
try:
# Main loop
while True:
print rc_time(pin_to_circuit)
except KeyboardInterrupt:
pass
finally:
GPIO.cleanup()
What I want it to do is when the count goes higher than 1000000, a MG90S, that I have also connected to the pi and a 4AA battery pack, moves about 90 degrees.
The code I was trying to integrate to move the servo:
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(12, GPIO.OUT)
p.ChangeDutyCycle(7.5) # turn towards 90 degree
time.sleep(1) # sleep 1 second
p.stop()
GPIO.cleanup()
Could somebody help me combine these two python codes. I tried for a bit, but I have almost no python experience. It's probably quite easy to do, but I'm not able to do it myself. Thanks for the response in advance! | 0debug |
static int sl_nand_init(SysBusDevice *dev)
{
SLNANDState *s = SL_NAND(dev);
DriveInfo *nand;
s->ctl = 0;
nand = drive_get(IF_MTD, 0, 0);
s->nand = nand_init(nand ? blk_bs(blk_by_legacy_dinfo(nand)) : NULL,
s->manf_id, s->chip_id);
memory_region_init_io(&s->iomem, OBJECT(s), &sl_ops, s, "sl", 0x40);
sysbus_init_mmio(dev, &s->iomem);
return 0;
}
| 1threat |
im having this error : im a beginner and also a diploma student... i have created database using localhost... im having problem viewing my database... please help me... i hope u can help me with a full code... this is the ERROR...
Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in C:\xampp\htdocs\SLR\View S110 PC01.php on line 10
cannot select DB
this is my code...
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="slr"; // Database name
$tbl_name="s110_pc01"; // Table name
// Connect to server and select databse.
mysqli_connect("$host", "$username", "$password")or die("cannot connect");
mysqli_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name";
$result=mysqli_query($sql);
$count=mysqli_num_rows($result);
?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><form name="form1" method="post" action="">
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF"> </td>
<td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF">#</td>
<td align="center" bgcolor="#FFFFFF"><strong>Software ID</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Software Name</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Installed Date</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Expiry Date</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Product Key</strong></td>
</tr>
<?php
while($rows=mysqli_fetch_array($result)){
?>
<tr>
<td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td>
<td bgcolor="#FFFFFF"><? echo $rows['soft_id']; ?></td>
<td bgcolor="#FFFFFF"><? echo $rows['soft_name']; ?></td>
<td bgcolor="#FFFFFF"><? echo $rows['installed_date']; ?></td>
<td bgcolor="#FFFFFF"><? echo $rows['expiry_date']; ?></td>
<td bgcolor="#FFFFFF"><? echo $rows['product_key']; ?></td>
</tr>
<?php
}
?>
<tr>
<td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td>
</tr>
<?php
// Check if delete button active, start this
if($delete){
for($i=0;$i<$count;$i++){
$del_id = $checkbox[$i];
$sql = "DELETE FROM $tbl_name WHERE soft_id='$soft_id'";
$result = mysqli_query($sql);
}
// if successful redirect to delete_multiple.php
if($result){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=View S110 PC01.php\">";
}
}
mysqli_close();
?>
</table>
</form>
</td>
</tr>
</table> | 0debug |
static inline ioreq_t *xen_vcpu_ioreq(shared_iopage_t *shared_page, int vcpu)
{
return &shared_page->vcpu_iodata[vcpu].vp_ioreq;
}
| 1threat |
static uint8_t send_read_command(void)
{
uint8_t drive = 0;
uint8_t head = 0;
uint8_t cyl = 0;
uint8_t sect_addr = 1;
uint8_t sect_size = 2;
uint8_t eot = 1;
uint8_t gap = 0x1b;
uint8_t gpl = 0xff;
uint8_t msr = 0;
uint8_t st0;
uint8_t ret = 0;
floppy_send(CMD_READ);
floppy_send(head << 2 | drive);
g_assert(!get_irq(FLOPPY_IRQ));
floppy_send(cyl);
floppy_send(head);
floppy_send(sect_addr);
floppy_send(sect_size);
floppy_send(eot);
floppy_send(gap);
floppy_send(gpl);
uint8_t i = 0;
uint8_t n = 2;
for (; i < n; i++) {
msr = inb(FLOPPY_BASE + reg_msr);
if (msr == 0xd0) {
break;
}
sleep(1);
}
if (i >= n) {
return 1;
}
st0 = floppy_recv();
if (st0 != 0x40) {
ret = 1;
}
floppy_recv();
floppy_recv();
floppy_recv();
floppy_recv();
floppy_recv();
floppy_recv();
return ret;
}
| 1threat |
C++ append to existing file : <p>I'm trying to take data from multiple files and append them into one file using fstream, however whenever I try to output to an existing file using</p>
<pre><code> std::ofstream Out("mushroom.csv", std::ofstream::app);
</code></pre>
<p>it outputs to the end of the file, I want it to append to the same line, for example if this is the previous file:</p>
<pre><code> 1,2,3,4,5,6,7
8,9,10,11,12,13
</code></pre>
<p>I want it to become:</p>
<pre><code> 1,2,3,4,5,6,7,a,b,c
8,9,10,11,12,13,c,d,e
</code></pre>
| 0debug |
What is the write way to fetch user data and permissions before any component Loads? : We are building an angular application. Which will be behind and authentication server. So we are not building any login forms. We have rest endpoint which will give me currently logged in user info and their permissions to view pages in angular for which I have created gaurds. I written a sevice to fetch the details as well.
Now My problem is app component is loaded before I fetch the details and display content to user.
What is recommended way for these situations.
Thanks,
Mahesh B | 0debug |
ARKIT: Move Object with PanGesture (the right way) : <p>I've been reading plenty of StackOverflow answers on how to move an object by dragging it across the screen. Some use hit tests against .featurePoints some use the gesture translation or just keeping track of the lastPosition of the object. But honestly.. none work the way everyone is expecting it to work. </p>
<p>Hit testing against .featurePoints just makes the object jump all around, because you dont always hit a featurepoint when dragging your finger. I dont understand why everyone keeps suggesting this.</p>
<p>Solutions like this one work: <a href="https://stackoverflow.com/questions/44729610/dragging-scnnode-in-arkit-using-scenekit">Dragging SCNNode in ARKit Using SceneKit</a></p>
<p>But the object doesnt really follow your finger, and the moment you take a few steps or change the angle of the object or the camera.. and try to move the object.. the x,z are all inverted.. and makes total sense to do that. </p>
<p>I really want to move objects as good as the Apple Demo, but I look at the code from Apple... and is insanely weird and overcomplicated I cant even understand a bit. Their technique to move the object so beautifly is not even close to what everyone propose online.
<a href="https://developer.apple.com/documentation/arkit/handling_3d_interaction_and_ui_controls_in_augmented_reality" rel="noreferrer">https://developer.apple.com/documentation/arkit/handling_3d_interaction_and_ui_controls_in_augmented_reality</a></p>
<p>There's gotta be a simpler way to do it. </p>
| 0debug |
in C, cannot read string created by malloc : I have a function which receive a pointer of char array as an argument(char** messageErreur). That pointer is created in the main, but no memory is allocated, as it is created only if necessary (error message to display) (no choice here, the method comes from an unchangeable .h file).
here is the code where I get segmentation fault:
imageMsgErr (messageErreur, "error message");
printf("erreur1 P2\n");
printf("message erreur %s\n", *messageErreur); //**where i get the seg fault
void imageMsgErr (char** messageErreur, char* msg){
messageErreur= (char**)malloc(sizeof(char*));
messageErreur[0]= (char*)malloc(sizeof (char) * 100);
if (*messageErreur){
printf("before strcpy\n");
strcpy(*messageErreur, msg);
printf("message erreur %s\n", *messageErreur);
}
return;
I have tried several similar code with the same result: segmentation fault when it execute the line: printf("message erreur %s\n", *messageErreur);
Help!!!
| 0debug |
void compute_images_mse(PSNRContext *s,
const uint8_t *main_data[4], const int main_linesizes[4],
const uint8_t *ref_data[4], const int ref_linesizes[4],
int w, int h, double mse[4])
{
int i, c, j;
for (c = 0; c < s->nb_components; c++) {
const int outw = s->planewidth[c];
const int outh = s->planeheight[c];
const uint8_t *main_line = main_data[c];
const uint8_t *ref_line = ref_data[c];
const int ref_linesize = ref_linesizes[c];
const int main_linesize = main_linesizes[c];
int m = 0;
for (i = 0; i < outh; i++) {
for (j = 0; j < outw; j++)
m += pow2(main_line[j] - ref_line[j]);
ref_line += ref_linesize;
main_line += main_linesize;
}
mse[c] = m / (double)(outw * outh);
}
}
| 1threat |
static av_cold int ffat_close_decoder(AVCodecContext *avctx)
{
ATDecodeContext *at = avctx->priv_data;
if (at->converter)
AudioConverterDispose(at->converter);
av_packet_unref(&at->new_in_pkt);
av_packet_unref(&at->in_pkt);
av_free(at->decoded_data);
av_free(at->extradata);
return 0;
}
| 1threat |
Inserting data into table via store procedue : I created a table and store procs to insert data into table via GUI on reportnet but data is not being inserted so i came back to check if there is any error in my insert store proc. I tried to excecute the proc as
EXEC DBO.Tablename 'param1','Param2', etc. I dont know if i excuted right but it errors out as one more column should be supplied. COuld some one help me how to excute the proc to insert values | 0debug |
static bool is_zero_sectors(BlockDriverState *bs, int64_t start,
uint32_t count)
{
int nr;
BlockDriverState *file;
int64_t res;
if (!count) {
return true;
res = bdrv_get_block_status_above(bs, NULL, start, count,
&nr, &file);
return res >= 0 && (res & BDRV_BLOCK_ZERO) && nr == count; | 1threat |
How long does Firebase throttle you? : <p>Even with debug enabled for RemoteConfig, I still managed to get the following:</p>
<blockquote>
<p>Error fetching remote config values Optional(Error Domain=com.google.remoteconfig.ErrorDomain Code=8002 "(null)"
UserInfo={error_throttled_end_time_seconds=1483110267.054194})</p>
</blockquote>
<p>Here is my debug code:</p>
<pre><code>let debug = FIRRemoteConfigSettings(developerModeEnabled: true)
FIRRemoteConfig.remoteConfig().configSettings = debug!
</code></pre>
<p>Shouldn't the above prevent throttling?</p>
<p>How long will the throttle error remain in effect?</p>
| 0debug |
dispatch multiple actions in one effect : <p>I would like to diapatch two actions in one effect.
Currently I have to declare two effects to achieve this :</p>
<pre><code> // first effect
@Effect() action1$ = this.actions$
.ofType(CoreActionTypes.MY_ACTION)
.map(res => {
return { type: "ACTION_ONE"}
})
.catch(() => Observable.of({
type: CoreActionTypes.MY_ACTION_FAILED
}));
// second effect
@Effect() action2$ = this.actions$
.ofType(CoreActionTypes.MY_ACTION)
.map(res => {
return { type: "ACTION_TWO"}
})
.catch(() => Observable.of({
type: CoreActionTypes.MY_ACTION_FAILED
}));
</code></pre>
<p>Is it possible to have one action, be the source of two actions via a single effect ? </p>
| 0debug |
How to use Insert query in php code : [enter image description here][1]
[1]: https://i.stack.imgur.com/wjGz6.png
I do not understand what is going wrong with this code. The result is get is
"connected successfully successQuery failed". I tried few combinations and i get the same result. Please help me in solving this. Thankz in advance, | 0debug |
int nbd_send_request(int csock, struct nbd_request *request)
{
uint8_t buf[4 + 4 + 8 + 8 + 4];
cpu_to_be32w((uint32_t*)buf, NBD_REQUEST_MAGIC);
cpu_to_be32w((uint32_t*)(buf + 4), request->type);
cpu_to_be64w((uint64_t*)(buf + 8), request->handle);
cpu_to_be64w((uint64_t*)(buf + 16), request->from);
cpu_to_be32w((uint32_t*)(buf + 24), request->len);
TRACE("Sending request to client: "
"{ .from = %" PRIu64", .len = %u, .handle = %" PRIu64", .type=%i}",
request->from, request->len, request->handle, request->type);
if (write_sync(csock, buf, sizeof(buf)) != sizeof(buf)) {
LOG("writing to socket failed");
errno = EINVAL;
return -1;
}
return 0;
}
| 1threat |
how to pass string from intent to secendactivity(not working) : I send my string with intent but when I run program stobed.
here is my mainActivivty
list = (ListView) findViewById(R.id.list);
list.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,int position, long arg3)
{
Intent intent =new Intent(getApplicationContext(),LAstActivity.class);
intent.putExtra("name",notes.get(position));
startActivity(intent,my);
}
});
and secendActivivty
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_last);
TextView tv=findViewById(R.id.textView5);
Intent intent = getIntent();
String data = intent.getStringExtra("name");
tv.setText(data);
} | 0debug |
Obfuscate text using JavaScript? : <p>I'm looking to obfuscate (to make obscure, unclear, or unintelligible) paragraph text. Essentially </p>
<ul>
<li>I need to be able to control where it starts and stops.</li>
<li>I don't want people previewing the source and getting the original text where it is hidden.</li>
<li>The obfuscated text needs to follow the original formatting - keeping the spacing, line breaks, capitalisation and punctuation etc.</li>
<li>Alphabetical characters need swapping with another random alphabetical character.</li>
</ul>
<p>I'm trying to hide text in an article. What would be the best way to do this using javascript?</p>
<p><strong>Example</strong></p>
<p>See the following example from the <a href="https://makebook.io/" rel="nofollow noreferrer">Make book</a></p>
<p><a href="https://i.stack.imgur.com/bz7fJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bz7fJ.png" alt="enter image description here"></a></p>
<p>Note: I came across the <a href="https://camwiegert.github.io/baffle/#demo" rel="nofollow noreferrer">baffle library</a> does something similar but doesn't quite do the job... </p>
| 0debug |
How to find attribute data-comp value usign jquery find() : <pre><code><div id="container">
<div data-comp="component"></div>
</div>
</code></pre>
<p>I want it to find from the selector container
something like
$('#container').find('[data-comp]');
I want the output like
'component' </p>
| 0debug |
Why is my code skipping a whole for loop? : <p>I'm still learning the basics of C and I had this assignment of coding a program that shows the product of two 2D arrays entered by the user. The idea is to not make use of memory functions like malloc. </p>
<p>The code worked fine but when I added an if statement to check that the rows of the first array are equal to the columns of the next one during the run-time the whole part for entering the data of the first array and showing it is skipped and it goes directly to asking for the next array. I've tried to clean the buffer and use getch() trying to force the compiler to execute that part but it keeps being skipped.</p>
<p>Here's the whole code : </p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <conio.h>
int main(void);
int main (void)
#define MAXR 36
#define MAXC 18
{
int Rows_A,Columns_A,Rows_B,Columns_B,Rows_C,Columns_C;
int Counter_Rows=0,Counter_Columns=0,Counter_Multiplier=0;
int Matrix_A[MAXR][MAXC],Matrix_B[MAXR][MAXC],Results_Matrix_C[MAXR][MAXC];
printf("\n\tTo multiply two matrices both have to be the same size of rows from the first matrix and the columns from the next one. \n\tPlease enter the size of the matrices:\n");
printf("\n\tMatrix A:\n\tNumber of rows :\t\t");
scanf(" %d",&Rows_A);
printf("\n\tNumber of columns :\t\t");
scanf(" %d",&Columns_A);
printf("\n\tMatrix B:\n\tNumber of rows :\t\t");
fflush(stdin);
scanf(" %d",&Rows_B);
printf("\n\tNumber of columns :\t\t");
scanf(" %d",&Columns_B);
if (Rows_A=!Columns_B)
{
printf("\n\tMatrix B number of columns and Matrix A number of rows are not the same therefore they cannot be multiplied.");
return 0;
}
else
{
Rows_C=Rows_A;
Columns_C=Columns_B;
printf("\n\tEnter the data for Matrix A:");
for (Counter_Rows=0;Counter_Rows < Rows_A;Counter_Rows++)
{
for(Counter_Columns=0;Counter_Columns < Columns_A; Counter_Columns++)
{
printf("\n\tEnter the value of the position [%d][%d] of the matrix A: ",Counter_Rows+1,Counter_Columns+1);
scanf(" %d",&Matrix_A[Counter_Rows][Counter_Columns]);
}
}
printf("\n\tMatrix A.\n\t");//Matrix A
for (Counter_Rows= 0; Counter_Rows < Rows_A; Counter_Rows++)
{
for (Counter_Columns= 0; Counter_Columns < Columns_A; Counter_Columns++)
{
printf("[%d] ",Matrix_A[Counter_Rows][Counter_Columns]);
}
printf("\n\t");
}
fflush(stdin);
printf("\n\tEnter the data for Matrix B:");
for (Counter_Rows=0;Counter_Rows < Rows_B;Counter_Rows++)
{
for(Counter_Columns=0;Counter_Columns < Columns_B; Counter_Columns++)
{
printf("\n\tEnter the value of the position [%d][%d] of the matrix B: ",Counter_Rows+1,Counter_Columns+1);
scanf(" %d",&Matrix_B[Counter_Rows][Counter_Columns]);
}
}
printf("\n\tMatrix B.\n\t");//Matrix B.
for (Counter_Rows= 0; Counter_Rows < Rows_B; Counter_Rows++)
{
for (Counter_Columns= 0; Counter_Columns < Columns_B; Counter_Columns++)
{
printf("[%d] ",Matrix_B[Counter_Rows][Counter_Columns]);
}
printf("\n\t");
}
//Calculating product matrix C.
for (Counter_Rows=0;Counter_Rows < Rows_C;Counter_Rows++)
{
for(Counter_Columns=0;Counter_Columns < Columns_C; Counter_Columns++)
{
//initializes the Matrix C in 0's
Results_Matrix_C[Counter_Rows][Counter_Columns]=0;
for(Counter_Multiplier=0; Counter_Multiplier < Columns_A; Counter_Multiplier++)
{
Results_Matrix_C[Counter_Rows][Counter_Columns]=Results_Matrix_C[Counter_Rows][Counter_Columns]+(Matrix_A[Counter_Rows][Counter_Multiplier]*Matrix_B[Counter_Multiplier][Counter_Columns]);
}
}
}
printf("\n\tProduct Matrix C:\n\t");//Matrix B.
for (Counter_Rows= 0; Counter_Rows < Rows_C; Counter_Rows++)
{
for (Counter_Columns= 0; Counter_Columns < Columns_C; Counter_Columns++)
{
printf("[%d] ",Results_Matrix_C[Counter_Rows][Counter_Columns]);
}
printf("\n\t");
}
}
return 0;
</code></pre>
<p>}</p>
<p>This is the part that is skipped : </p>
<pre><code>printf("\n\tEnter the data for Matrix A:");
for (Counter_Rows=0;Counter_Rows < Rows_A;Counter_Rows++)
{
for(Counter_Columns=0;Counter_Columns < Columns_A; Counter_Columns++)
{
printf("\n\tEnter the value of the position [%d][%d] of the matrix A: ",Counter_Rows+1,Counter_Columns+1);
scanf(" %d",&Matrix_A[Counter_Rows][Counter_Columns]);
}
}
printf("\n\tMatrix A.\n\t");//Matrix A
for (Counter_Rows= 0; Counter_Rows < Rows_A; Counter_Rows++)
{
for (Counter_Columns= 0; Counter_Columns < Columns_A; Counter_Columns++)
{
printf("[%d] ",Matrix_A[Counter_Rows][Counter_Columns]);
}
printf("\n\t");
}
</code></pre>
| 0debug |
av_cold void ff_blockdsp_init_x86(BlockDSPContext *c,
AVCodecContext *avctx)
#else
av_cold void ff_blockdsp_init_x86(BlockDSPContext *c)
#endif
{
#if HAVE_INLINE_ASM
int cpu_flags = av_get_cpu_flags();
if (INLINE_MMX(cpu_flags)) {
c->clear_block = clear_block_mmx;
c->clear_blocks = clear_blocks_mmx;
}
#if FF_API_XVMC
FF_DISABLE_DEPRECATION_WARNINGS
if (CONFIG_MPEG_XVMC_DECODER && avctx->xvmc_acceleration > 1)
return;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if (INLINE_SSE(cpu_flags)) {
c->clear_block = clear_block_sse;
c->clear_blocks = clear_blocks_sse;
}
#endif
}
| 1threat |
How can I make an Array of Objects from n properties of n arrays in JS? : <p>I have two arrays like this:</p>
<pre class="lang-js prettyprint-override"><code>const opciones = ['A', 'B', 'C', 'D'];
const valoracion = [true, false, false, false];
</code></pre>
<p>And the, I want to create a new Array of Objects from these two arrays, like this:</p>
<pre class="lang-js prettyprint-override"><code>const respuestas = [
{opc: 'A', val: true},
{opc: 'B', val: false},
{opc: 'C', val: false},
{opc: 'D', val: false},
]
</code></pre>
| 0debug |
npm install from git repo subfolder : <p>I have a repo with various components and I want to be able to include the components as individual dependencies (but I don't want to create a repo per component).</p>
<p><strong>Is it a way to use a subfolder of a github repo as the path for a dependency in npm</strong> ? (that will not involve creating separate branches per component)</p>
<p>Something like</p>
<p><code>dropdown: git+https://git@github.com/me/mycomponents.git/components/dropdown</code></p>
| 0debug |
how can i know what is the SDK verson? : I know its might be very simple
but i really need know what is the SDK verson ?
| 0debug |
what is the difference between static SQL and dynamic SQL? : <p>What is the actual difference between static and dynamic sql? I'm not getting a clear picture about it. Is this just using the sql statements in inline queries and in stored procedures? Expecting a clear answer with example.</p>
| 0debug |
void qmp_transaction(BlockdevActionList *dev_list, Error **errp)
{
int ret = 0;
BlockdevActionList *dev_entry = dev_list;
BlkTransactionStates *states, *next;
QSIMPLEQ_HEAD(snap_bdrv_states, BlkTransactionStates) snap_bdrv_states;
QSIMPLEQ_INIT(&snap_bdrv_states);
bdrv_drain_all();
while (NULL != dev_entry) {
BlockdevAction *dev_info = NULL;
BlockDriver *proto_drv;
BlockDriver *drv;
int flags;
enum NewImageMode mode;
const char *new_image_file;
const char *device;
const char *format = "qcow2";
dev_info = dev_entry->value;
dev_entry = dev_entry->next;
states = g_malloc0(sizeof(BlkTransactionStates));
QSIMPLEQ_INSERT_TAIL(&snap_bdrv_states, states, entry);
switch (dev_info->kind) {
case BLOCKDEV_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC:
device = dev_info->blockdev_snapshot_sync->device;
if (!dev_info->blockdev_snapshot_sync->has_mode) {
dev_info->blockdev_snapshot_sync->mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
}
new_image_file = dev_info->blockdev_snapshot_sync->snapshot_file;
if (dev_info->blockdev_snapshot_sync->has_format) {
format = dev_info->blockdev_snapshot_sync->format;
}
mode = dev_info->blockdev_snapshot_sync->mode;
break;
default:
abort();
}
drv = bdrv_find_format(format);
if (!drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
goto delete_and_fail;
}
states->old_bs = bdrv_find(device);
if (!states->old_bs) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
goto delete_and_fail;
}
if (!bdrv_is_inserted(states->old_bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
goto delete_and_fail;
}
if (bdrv_in_use(states->old_bs)) {
error_set(errp, QERR_DEVICE_IN_USE, device);
goto delete_and_fail;
}
if (!bdrv_is_read_only(states->old_bs)) {
if (bdrv_flush(states->old_bs)) {
error_set(errp, QERR_IO_ERROR);
goto delete_and_fail;
}
}
flags = states->old_bs->open_flags;
proto_drv = bdrv_find_protocol(new_image_file);
if (!proto_drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
goto delete_and_fail;
}
if (mode != NEW_IMAGE_MODE_EXISTING) {
ret = bdrv_img_create(new_image_file, format,
states->old_bs->filename,
states->old_bs->drv->format_name,
NULL, -1, flags);
if (ret) {
error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file);
goto delete_and_fail;
}
}
states->new_bs = bdrv_new("");
ret = bdrv_open(states->new_bs, new_image_file,
flags | BDRV_O_NO_BACKING, drv);
if (ret != 0) {
error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file);
goto delete_and_fail;
}
}
QSIMPLEQ_FOREACH(states, &snap_bdrv_states, entry) {
bdrv_append(states->new_bs, states->old_bs);
}
goto exit;
delete_and_fail:
QSIMPLEQ_FOREACH(states, &snap_bdrv_states, entry) {
if (states->new_bs) {
bdrv_delete(states->new_bs);
}
}
exit:
QSIMPLEQ_FOREACH_SAFE(states, &snap_bdrv_states, entry, next) {
g_free(states);
}
return;
} | 1threat |
Connect To SQL Server With Windows Authentication From A Linux Machine Through JDBC : <p>I want to be able to connect to a SQL Server using jdbc and windows authentication.
I saw some answers on the internet saying i should add the following property to the connection string:</p>
<pre><code>integratedSecurity=true;
</code></pre>
<p>And also add</p>
<pre><code>sqljdbc_auth.dll
</code></pre>
<p>To the java path.</p>
<p>But this, as far as i understand applies only when i'm connecting from a Windows machine.
When i try this on a Linux machine i get:</p>
<pre><code>java.sql.SQLException: This driver is not configured for integrated authentication
</code></pre>
<p>My question is how do I do it from a Linux machine.</p>
<p>Thanks</p>
| 0debug |
TS1128: Declaration or statement expected (end of file) : <p>folks. Working on a TypeScript/React project (just getting used to it, haven't written React in a year, etc.), and having an issue.</p>
<p>When I wrote this component, I followed some docs that I found, but I'm getting a TS1128 (Declaration or statement expected) error at the end of this file, and I can't figure out why:</p>
<pre><code>import * as React from 'react';
import Count from './CountDisplay';
interface State {
count: number;
}
class Counter extends React.Component<{}, State> {
state: State = {count: 0};
increment() {
this.setState({
count: (this.state.count + 1)
});
}
decrement() {
this.setState({
count: (this.state.count - 1)
});
}
render(): JSX.Element {
return (
<div>
<Count count={this.state.count}/>
<button onClick={this.increment}>Increment</button>
<button onClick={this.decrement}>Decrement</button>
</div>
);
}
}
export default Counter;
</code></pre>
<p>Dunno why I keep getting an error, because the code looks fine (or so I thought), but I could be wrong.</p>
<p>Below is my TSConfig.json, because I figured maybe it's relevant to the issue:</p>
<pre><code>{
"compilerOptions": {
"outDir": "./dist",
"sourceMap": true,
"noImplicitAny": true,
"module": "commonjs",
"target": "es6",
"jsx": "react"
}
}
</code></pre>
<p>Any help would be great appreciated, I've been beating my head against this for a short while now, sorta stuck.</p>
| 0debug |
cannot use file (type *multipart.FileHeader) as type []byte in argument to ioutil.WriteFile : I'm trying to upload multiple files in the same golang function. Here is my code:
func PhotoCreatePOST(w http.ResponseWriter, r *http.Request) {
var err error
r.ParseMultipartForm(32 << 20) // 32MB is the default used by FormFile
fhs := r.MultipartForm.File["files"]
var fileNames []string
var filename string
var ext string
for _, file := range fhs { //Iterate over multiple uploaded files
if err != nil {
log.Fatal(err)
} else {
dir, err := os.Getwd()
if err != nil {
log.Fatal(err)
}
ext = strings.ToLower(path.Ext(file.Filename))
filename = path.Join(random.RandString(10) + ext)
destFolder := "/media/photos"
if _, err := os.Stat(destFolder); os.IsNotExist(err) {
os.Mkdir(destFolder, 0755)
}
//destination Path. The string which is Saving in DB
savePath := destFolder + "/" + filename
err = ioutil.WriteFile(savePath, file, 0777) //<--Here is the problem
if err != nil {
log.Println(err)
io.WriteString(w, err.Error())
return
}
}
}
//Add file url to the slice
fileNames = append(fileNames, filename)
}
How can I fix this?
| 0debug |
static inline void RENAME(bgr15ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
{
int i;
assert(src1==src2);
for(i=0; i<width; i++)
{
int d0= ((uint32_t*)src1)[i];
int dl= (d0&0x03E07C1F);
int dh= ((d0>>5)&0x03E0F81F);
int dh2= (dh>>11) + (dh<<21);
int d= dh2 + dl;
int b= d&0x7F;
int r= (d>>10)&0x7F;
int g= d>>21;
dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+1-3)) + 128;
dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+1-3)) + 128;
}
}
| 1threat |
How does the typeof method works in Javascript? : <pre><code>if(typeof(variable) === "boolean"){
// variable is a boolean
}
</code></pre>
<p><strong>Which one of the two code samples below is equivalent to the one above ?</strong></p>
<p>Sample 1</p>
<pre><code>if(variable === true || variable === false){
// variable is a boolean
}
</code></pre>
<p>Sample 2</p>
<pre><code>if(variable == true || variable == false){
// variable is a boolean
}
</code></pre>
| 0debug |
c++ win 32, I want to add list of items into a combo box. how do i do it. : I want the user to select from a drop-down list of items in a combo box.
This is what I have
CreateWindow (TEXT("STATIC"), TEXT ("MODEL"),
WS_VISIBLE | WS_CHILD | WS_DISABLED,
10, 20, 70, 17,
hwnd,(HMENU) NULL, NULL, NULL
); | 0debug |
Trying to Center Top Navigation Bar : <p>Making adjustments to the following bigcommerce theme: <a href="https://cornerstone-light-demo.mybigcommerce.com" rel="nofollow noreferrer">https://cornerstone-light-demo.mybigcommerce.com</a> and I cant seem to get the top nav (nav.navuser) to center align. I've tried various combinations of text-align:center;, and margin:0 auto; to no avail. </p>
| 0debug |
SQL Join on Table with Duplicates, add condition to get unique values : <p>I need to join Table B to Table A using SQL in order to get Table B's column called "Reservoir". They both have a unique ID to join on called "Well_ID" but the issue is that Table B has duplicate ids. Table B has a column called "Qualifier" and another called "CreatedDate". Qualifier "Dallas" has precedence over qualifier "Houston" and the latest CreatedDate is needed to find the unique Reservoir value.</p>
<p><a href="https://i.stack.imgur.com/biKhn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/biKhn.png" alt="enter image description here"></a></p>
<p>Since I'm unsure how to do the condition, all I have is the join statement so far: </p>
<pre><code>SELECT a.*
,b.[Reservoir]
,b.[CreatedDateTime]
,b.[Qualifier]
FROM TableA a
INNER JOIN TableB b on a.Well_ID = b.Well_ID
</code></pre>
| 0debug |
Capturing unused fields while decoding a JSON object with circe : <p>Suppose I have a case class like the following, and I want to decode a JSON object into it, with all of the fields that haven't been used ending up in a special member for the leftovers:</p>
<pre><code>import io.circe.Json
case class Foo(a: Int, b: String, leftovers: Json)
</code></pre>
<p>What's the best way to do this in Scala with circe?</p>
<p>(Note: I've seen questions like this <a href="https://gitter.im/circe/circe?at=5b4b0058582aaa63076beb77" rel="noreferrer">a few times</a>, so I'm Q-and-A-ing it for posterity.)</p>
| 0debug |
static int open_self_cmdline(void *cpu_env, int fd)
{
int fd_orig = -1;
bool word_skipped = false;
fd_orig = open("/proc/self/cmdline", O_RDONLY);
if (fd_orig < 0) {
return fd_orig;
}
while (true) {
ssize_t nb_read;
char buf[128];
char *cp_buf = buf;
nb_read = read(fd_orig, buf, sizeof(buf));
if (nb_read < 0) {
int e = errno;
fd_orig = close(fd_orig);
errno = e;
return -1;
} else if (nb_read == 0) {
break;
}
if (!word_skipped) {
cp_buf = memchr(buf, 0, sizeof(buf));
if (cp_buf) {
cp_buf++;
nb_read -= cp_buf - buf;
word_skipped = true;
}
}
if (word_skipped) {
if (write(fd, cp_buf, nb_read) != nb_read) {
int e = errno;
close(fd_orig);
errno = e;
return -1;
}
}
}
return close(fd_orig);
}
| 1threat |
Want to add none as value in select multiple : <p>I am using chosen.jquery.js for select field</p>
<pre><code><select chosen multiple data-placeholder="Select Body Part(s)"
ng-options="option.Name as option.Name for option in BodyPartList" ng-model="Body_Part">
<option value="" disabled>Select Body Part(s)</option>
</select>
</code></pre>
<p>But It shows only data-placeholder value in case of no data in model.
I want to show "Select Body Part(s)" as a option in list.
And user must not select this. Reason is that, I want to add dynamic "Unknown" value in list of Body_Parts. But it not reflect in list.</p>
<p>Same work for select having single selection.</p>
| 0debug |
too many errors in R program : I have just started studying R in second sem of my undergrad. It is hard to figure out a lot of things here. I hope if you can point me in right direction?
initially i was not sure why require lines were giving error, then i figured they were trying to load packages which were not in my RStudio installation, so i got them on. I also figured that the data given to me was to be put in a file named auto_mpg.txt. But the errors after that line are hard to figure.
can you pl help me understand this?
ty.
R version 3.4.1 (2017-06-30) -- "Single Candle"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
[Workspace loaded from ~/R/my_project/.RData]
> #################################################################
> ################# NIKITA TIWARI ############################
> #################################################################
> ################# DATA SUMMARY PJ1 ############################
> ## mpg cyl wt region
> ## Min. : 9.00 Min. :3.000 Min. :1613 Min. :1.000
> ## 1st Qu.:17.50 1st Qu.:4.000 1st Qu.:2224 1st Qu.:1.000
> ## Median :23.00 Median :4.000 Median :2804 Median :1.000
> ## Mean :23.51 Mean :5.455 Mean :2970 Mean :1.573
> ## 3rd Qu.:29.00 3rd Qu.:8.000 3rd Qu.:3608 3rd Qu.:2.000
> ## Max. :46.60 Max. :8.000 Max. :5140 Max. :3.000
> ##
> ## model
> ## ford pinto : 6
> ## amc matador : 5
> ## ford maverick : 5
> ## toyota corolla: 5
> ## amc gremlin : 4
> ## amc hornet : 4
> ## (Other) :369
> #################################################################
> #################################################################
>
> require(gridExtra) #given to me
Loading required package: gridExtra
Warning message:
package ‘gridExtra’ was built under R version 3.4.2
> require(ggplot2) #given to me
Loading required package: ggplot2
Warning message:
package ‘ggplot2’ was built under R version 3.4.2
>
>
> auto <- read.table("auto_mpg.txt", sep="\t", header = TRUE) #given to me
> head(auto)
mpg.............cyl..............wt...........region
1 Min. : 9.00 Min. :3.000 Min. :1613 Min. :1.000
2 1st Qu.:17.50 1st Qu.:4.000 1st Qu.:2224 1st Qu.:1.000
3 Median :23.00 Median :4.000 Median :2804 Median :1.000
4 Mean :23.51 Mean :5.455 Mean :2970 Mean :1.573
5 3rd Qu.:29.00 3rd Qu.:8.000 3rd Qu.:3608 3rd Qu.:2.000
6 Max. :46.60 Max. :8.000 Max. :5140 Max. :3.000
> summary(auto) #given to me
mpg.............cyl..............wt...........region
1st Qu.:17.50 1st Qu.:4.000 1st Qu.:2224 1st Qu.:1.000 :1
3rd Qu.:29.00 3rd Qu.:8.000 3rd Qu.:3608 3rd Qu.:2.000 :1
Max. :46.60 Max. :8.000 Max. :5140 Max. :3.000 :1
Mean :23.51 Mean :5.455 Mean :2970 Mean :1.573 :1
Median :23.00 Median :4.000 Median :2804 Median :1.000 :1
Min. : 9.00 Min. :3.000 Min. :1613 Min. :1.000 :1
>
>
> auto$cyl <- as.factor(auto$cyl)
Error in `$<-.data.frame`(`*tmp*`, cyl, value = integer(0)) :
replacement has 0 rows, data has 6
> auto$region <- as.factor(auto$region)
Error in `$<-.data.frame`(`*tmp*`, region, value = integer(0)) :
replacement has 0 rows, data has 6
> auto$cyl[auto$cyl == 1] <- "USA"
Error in `$<-.data.frame`(`*tmp*`, cyl, value = character(0)) :
replacement has 0 rows, data has 6
> auto$cyl[auto$cyl == 2] <- "EUR"
Error in `$<-.data.frame`(`*tmp*`, cyl, value = character(0)) :
replacement has 0 rows, data has 6
> auto$cyl[auto$cyl == 3] <- "ASIA"
Error in `$<-.data.frame`(`*tmp*`, cyl, value = character(0)) :
replacement has 0 rows, data has 6
> auto$region[auto$region == 1] <- "USA"
Error in `$<-.data.frame`(`*tmp*`, region, value = character(0)) :
replacement has 0 rows, data has 6
> auto$region[auto$region == 2] <- "EUR"
Error in `$<-.data.frame`(`*tmp*`, region, value = character(0)) :
replacement has 0 rows, data has 6
> auto$region[auto$region == 3] <- "ASIA"
Error in `$<-.data.frame`(`*tmp*`, region, value = character(0)) :
replacement has 0 rows, data has 6
>
> auto$cyl <- factor(auto$cyl, levels=c("USA","EUR","ASIA"))
Error in `$<-.data.frame`(`*tmp*`, cyl, value = integer(0)) :
replacement has 0 rows, data has 6
> auto$region <- factor(auto$region, levels=c("USA","EUR","ASIA"))
Error in `$<-.data.frame`(`*tmp*`, region, value = integer(0)) :
replacement has 0 rows, data has 6
> summary(auto)
mpg.............cyl..............wt...........region
1st Qu.:17.50 1st Qu.:4.000 1st Qu.:2224 1st Qu.:1.000 :1
3rd Qu.:29.00 3rd Qu.:8.000 3rd Qu.:3608 3rd Qu.:2.000 :1
Max. :46.60 Max. :8.000 Max. :5140 Max. :3.000 :1
Mean :23.51 Mean :5.455 Mean :2970 Mean :1.573 :1
Median :23.00 Median :4.000 Median :2804 Median :1.000 :1
Min. : 9.00 Min. :3.000 Min. :1613 Min. :1.000 :1
>
> ###################################################################
> # calculate the mean mpg for cars, broken out by the number of
> # cylinders in the car.
> ###################################################################
>
>
> ###################################################################
> #Provide a description of what you notice above
> ###################################################################
> # write a line describing the purpose of the next code chunk
> ###################################################################
>
>
> ###################################################################
> #provide a dsecriptiojn of what you notice above
> ###################################################################
> # Histograms
> ###################################################################
> # the next chunk of code is creating bar graphs and filling them
> # with either region or cyl , with count on the y axis and
> # mpg on the x axis
> ###################################################################
> ggplot(auto, aes(x = mpg, y = count, fill = cyl)) + geom_bar()
Don't know how to automatically pick scale for object of type tbl_df/tbl/data.frame. Defaulting to continuous.
Error in FUN(X[[i]], ...) : object 'count' not found
> ggplot(auto, aes(x = mpg, y = count, fill = region)) + geom_bar()
Don't know how to automatically pick scale for object of type tbl_df/tbl/data.frame. Defaulting to continuous.
Error in FUN(X[[i]], ...) : object 'count' not found
> ###################################################################
> # provide a description of what you notice above
> ###################################################################
> # write a line describe the purpose of the next chunck of code
> ###################################################################
> b1 <- ggplot(auto, aes(x=cyl, fill=cyl)) + geom_bar()
> b2 <- ggplot(auto, aes(x=region, fill=region)) + geom_bar()
> ###################################################################
> # the above code is used to creat a specific bar graph and it's
> # x axis is the same a the fill so that it is more clear
> ###################################################################
> # the next chunck of code is used to fill the graph with the bars
> ###################################################################
> b3 <- ggplot(auto, aes(x = cyl, fill = region)) + geom_bar(position = "fill")
> b4 <- ggplot(auto, aes(x = region, fill = cyl)) + geom_bar(position = "fill")
> grid.arrange(b1, b2 ,b3, b4, ncol= 4)
Error in FUN(X[[i]], ...) : object 'cyl' not found
> ###################################################################
> # provide a description of what you notice above
> ###################################################################
> # the code below is going to make box plots of the data
> ###################################################################
> bp1 <- ggplot ( auto, aes(x = cyl, y = mpg, fill = cyl)) + geom_boxplot()
> bp2 <- ggplot ( auto, aes(x = region, y = mpg, fill = region)) + geom_boxplot()
> grid.arrange(bp1, bp2, ncol = 2)
Don't know how to automatically pick scale for object of type tbl_df/tbl/data.frame. Defaulting to continuous.
Error in FUN(X[[i]], ...) : object 'cyl' not found
> ###################################################################
> # provide a description of what you notice above
> ###################################################################
> # the code below is going to make box plots of the data spilt into
> # 3, 4, ,5, 6, 8 data with mpg being y axis, region being x axis
> # and region being the fill
> ###################################################################
>
>
>
>
> ###################################################################
> # provide a description of what you notice above
> ###################################################################
> # the code below is going to a jitter plot so basically its just a
> # lot dots on a graph
> ###################################################################
> jp1 <- ggplot ( auto, aes(x = wt, y = mpg, fill = cyl)) + geom_jitter()
> jp2 <- ggplot ( auto, aes(x = wt, y = mpg, fill = region)) + geom_jitter()
> grid.arrange(jp1, jp2, ncol = 2)
Don't know how to automatically pick scale for object of type tbl_df/tbl/data.frame. Defaulting to continuous.
Error in FUN(X[[i]], ...) : object 'wt' not found
> ###################################################################
> # provide a description of what you notice above
> ###################################################################
> # the code below is going to a jitter plot but separate the graphs
> # into the different regions and only that region shows up on the
> # graph
> ###################################################################
> fg1 <- ggplot ( auto, aes(x = wt, y = mpg, fill = cyl)) + geom_jitter()
> + facet_grid(region)
Error in facet_grid(region) : object 'region' not found
> fg1
Don't know how to automatically pick scale for object of type tbl_df/tbl/data.frame. Defaulting to continuous.
Error in FUN(X[[i]], ...) : object 'wt' not found
>
>
> ###################################################################
> # provide a description of what you notice above
> ###################################################################
> # the code below is going to a jitter plot but separate the graphs
> # into the different regions and into different cyl and only that
> # cyl and that region show up in that graph
> ###################################################################
> | 0debug |
Using the contents of a Textbox as arguments for Process.Select : I'm a new programmer who is just getting into Visual Basic. I'm trying to create a simple application that would let me mount ISO files using the built in Windows PowerShell.
My Code is here:
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
If OpenFileDialog1.ShowDialog = DialogResult.OK Then
TextBox1.Text = OpenFileDialog1.FileName
Me.ErrorProvider1.SetError(Me.TextBox1, "Looks Valid")
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If ErrorProvider1.GetError(TextBox1) = "Looks Valid" Then
Process.Start("powershell", "Mount-DiskImage 'C:\ISO\MY Magic ISO.iso'")
Else
Me.ErrorProvider1.SetError(Me.TextBox1, "Please Select a Valid File")
End If
End Sub
My program is simple, you pick a file from the dialog, and if the file is valid, it is mounted with powershell.
My question is how I would go about dynamically changing the "C:\ISO\MY Magic ISO.iso" filepath, using the contents of Textbox1. Is this possible? Any help would be greatly appreciated, and I am incredibly sorry if this has been asked before!
Cheers!
| 0debug |
Using a function to return a value on a plotLine [HighCharts] : <p>I want to return a value in form of a plotLine in my chart.</p>
<pre><code>plotLines: [{
color: 'red',
value: resp.data.res0.map(function(a){
sum += parseInt(a[1]);
return sum;
}),
width: '1',
zIndex: 2
}]
},
</code></pre>
<p>The value of sum here is not that important, just that it is a number. But I am not sure how I am supposed to render it to the chart. The response in a[1] is JSON.</p>
| 0debug |
swift if statement, condition will never be executed : I thought I was good with if statements but apparently Im still missing something. In the following the **timer.invalidate()** line returns a "**Will never be executed**". As far as I can tell my syntax is correct..
xcode 9 beta6
@IBAction func button(_ sender: Any) {
let timer = Timer.scheduledTimer(timeInterval:0.2 , target: self, selector: #selector(ViewController.imageSwitch) , userInfo: nil, repeats: true)
var buttonState = false
if buttonState == true {
timer.invalidate()
buttonState = false
}
if buttonState == false {
timer.fire()
buttonState = true
}
} | 0debug |
void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque)
{
SaveStateEntry *se, *new_se;
char id[256] = "";
if (dev) {
char *path = qdev_get_dev_path(dev);
if (path) {
pstrcpy(id, sizeof(id), path);
pstrcat(id, sizeof(id), "/");
g_free(path);
}
}
pstrcat(id, sizeof(id), idstr);
QTAILQ_FOREACH_SAFE(se, &savevm_state.handlers, entry, new_se) {
if (strcmp(se->idstr, id) == 0 && se->opaque == opaque) {
QTAILQ_REMOVE(&savevm_state.handlers, se, entry);
if (se->compat) {
g_free(se->compat);
}
g_free(se->ops);
g_free(se);
}
}
}
| 1threat |
Sequelize composite unique constraint : <p>Defining model:</p>
<pre><code>export default function(sequelize, DataTypes) {
return sequelize.define('Item', {
minor: DataTypes.INTEGER,
major: DataTypes.INTEGER,
});
}
</code></pre>
<p>Can I define the pair minor and major as a composite UNIQUE constraint?</p>
| 0debug |
Program won't run properly : <p>So I wrote this program but for some reason my else statement won't work.
If i input "e" for example my program will simply crash... when its actually supposed to return "Invalid Input"
Can someone please help me?</p>
<p>=========================================================================</p>
<pre><code>import java.util.Scanner;
public class AbsValue2 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter a number:");
String num = input.nextLine();
Double num2 = new Double(Double.parseDouble(num));
Double abs_val = new Double(Math.sqrt(num2 * num2));
if (num.matches("[+-]?[\\d]+[.]*"))
System.out.println("The absolute value of " + num + " is |" + abs_val + "|");
else if (num.matches("[+-]?[\\d]*.[\\d]+"))
System.out.println("The absolute value of " + num + " is |" + abs_val + "|");
else
System.out.println("Invalid input");
}
}
</code></pre>
| 0debug |
Can someone help me understand != in Ruby? : <p>I'm working on learning Ruby on codecademy. I've gotten to comparators and am sure I'm not understanding !=.
The directions say, exactly "You can also check to see if two values are not equal using the != comparator."
What's the need to check whether something is specifically NOT equal to something else? Does this only apply to numbers? Would anyone be willing to give me 2-3 examples? </p>
| 0debug |
static int scale_vaapi_query_formats(AVFilterContext *avctx)
{
enum AVPixelFormat pix_fmts[] = {
AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE,
};
ff_formats_ref(ff_make_format_list(pix_fmts),
&avctx->inputs[0]->out_formats);
ff_formats_ref(ff_make_format_list(pix_fmts),
&avctx->outputs[0]->in_formats);
return 0;
}
| 1threat |
How can I generate NSManagedObject classes in Swift instead of Objective C in Xcode 8? : <p>I'm building a Core Data application using Swift 3 and Xcode 8 beta and when I generate the NSManagedObject subclasses Xcode gives me Objective-C files instead of Swift.</p>
<p>While I am very aware that I can simply write my own NSManagedObject subclasses in Swift I'd like to know how to switch the language of the generated code from Objective-C to Swift.</p>
<h2>Question</h2>
<p>How can I generate NSManagedObject classes in Swift instead of Objective C in Xcode 8?</p>
| 0debug |
Gem::LoadError: can't activate pg (~> 0.18), already activated pg-1.0.0 : <p>I've been doing the Rails tutorial found <a href="http://guides.rubyonrails.org/getting_started.html" rel="noreferrer">here</a> and have been successful up to the point of having to migrate the Comments migration using <strong>$ rails db:migrate</strong>. Prior to this point, I've been able to generate the Article model and migrate the Articles create migration with no issues. In between these two migrations, nothing has changed in my Gemfile, so I'm not sure what it is Bundler is having an issue with. </p>
<p>Here are the errors, followed by the full command-line output, along with my Gemfile and schema.rb:</p>
<pre><code>Gem::LoadError: can't activate pg (~> 0.18), already activated pg-1.0.0.
Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
</code></pre>
<p><strong>Full command-line output</strong></p>
<pre><code>xxx:gangelo: ~/dev/rails/test/blog (master*) ☠ rbenv exec rails db:migrate
rails aborted!
Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/connection_specification.rb:188:in `rescue in spec'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/connection_specification.rb:185:in `spec'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:880:in `establish_connection'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/connection_handling.rb:58:in `establish_connection'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/railtie.rb:124:in `block (2 levels) in <class:Railtie>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:69:in `instance_eval'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:60:in `with_execution_control'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:65:in `execute_hook'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:50:in `block in run_load_hooks'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:49:in `each'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:49:in `run_load_hooks'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/base.rb:326:in `<module:ActiveRecord>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/base.rb:25:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/mysql_database_tasks.rb:6:in `<class:MySQLDatabaseTasks>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/mysql_database_tasks.rb:3:in `<module:Tasks>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/mysql_database_tasks.rb:2:in `<module:ActiveRecord>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/mysql_database_tasks.rb:1:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:74:in `<module:DatabaseTasks>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:35:in `<module:Tasks>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:2:in `<module:ActiveRecord>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:1:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/railtie.rb:34:in `block (3 levels) in <class:Railtie>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:21:in `block in perform'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/railties-5.1.4/lib/rails/command.rb:46:in `invoke'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/bin/rails:9:in `require'
/Users/gangelo/dev/rails/test/blog/bin/rails:9:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Caused by:
Gem::LoadError: can't activate pg (~> 0.18), already activated pg-1.0.0. Make sure all dependencies are added to Gemfile.
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:2:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/connection_specification.rb:186:in `spec'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:880:in `establish_connection'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/connection_handling.rb:58:in `establish_connection'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/railtie.rb:124:in `block (2 levels) in <class:Railtie>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:69:in `instance_eval'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:60:in `with_execution_control'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:65:in `execute_hook'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:50:in `block in run_load_hooks'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:49:in `each'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:49:in `run_load_hooks'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/base.rb:326:in `<module:ActiveRecord>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/base.rb:25:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/mysql_database_tasks.rb:6:in `<class:MySQLDatabaseTasks>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/mysql_database_tasks.rb:3:in `<module:Tasks>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/mysql_database_tasks.rb:2:in `<module:ActiveRecord>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/mysql_database_tasks.rb:1:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:74:in `<module:DatabaseTasks>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:35:in `<module:Tasks>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:2:in `<module:ActiveRecord>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:1:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/railtie.rb:34:in `block (3 levels) in <class:Railtie>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:21:in `block in perform'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/railties-5.1.4/lib/rails/command.rb:46:in `invoke'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/bin/rails:9:in `require'
/Users/gangelo/dev/rails/test/blog/bin/rails:9:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => db:migrate => db:load_config
(See full trace by running task with --trace)
</code></pre>
<p><strong>Gemfile</strong></p>
<pre><code>source 'https://rubygems.org'
ruby '2.3.1'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.4'
# Use sqlite3 as the database for Active Record
# gem 'sqlite3'
# Use postgres as the database for Active Record
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'
end
# gma - start
group :development, :test do
gem 'rspec-rails', '~> 3.5', '>= 3.5.2'
gem 'rspec-activemodel-mocks', '~> 1.0', '>= 1.0.3'
gem 'shoulda-matchers', '~> 3.1', '>= 3.1.1'
gem 'factory_bot_rails', '~> 4.8', '>= 4.8.2'
gem 'ffaker', '~> 2.2'
# gem 'timecop', '~> 0.8.1'
end
# gma - end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
</code></pre>
<p><strong>Schema.rb</strong></p>
<pre><code>ActiveRecord::Schema.define(version: 20180110153949) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "articles", force: :cascade do |t|
t.string "title"
t.text "text"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
end
</code></pre>
<p><strong>Migration file</strong></p>
<pre><code>class CreateComments < ActiveRecord::Migration[5.1]
def change
create_table :comments do |t|
t.string :commenter
t.text :body
t.references :article, foreign_key: true
t.timestamps
end
end
end
</code></pre>
| 0debug |
How to unzip .gz files in a new directory in hadoop? : <p>I have a bunch of .gz files in a folder in hdfs. I want to unzip all of these .gz files to a new folder in hdfs. How should i do this?</p>
| 0debug |
Mysqli result while loop returns null : <p>This code used to work last time i checked then i made some changes (but didn't change the core actions) and now it doesn't and i can't understand why, is there something i'm missing?</p>
<pre><code>require("./dbAccess.php");
mysqli_set_charset($dbConnection, 'utf8mb4');
if($query = mysqli_query($dbConnection,
"SELECT * FROM table")){
mysqli_close($dbConnection);
while($row = mysqli_fetch_assoc($query));
{
var_dump($row);
}
}
else {echo (mysqli_error($dbConnection)); mysqli_close($dbConnection);}
</code></pre>
<p>The table has 2 rows, mysqli_num_rows confirms it and if i var_dump without the loop i correctly get the first row but as soon as it goes through the loop the var_dump results null.</p>
<p>Thanks</p>
| 0debug |
Android Play Billing Library: onSkuDetailsResponse responseCode is 0, but the size of skuDetailsList is also 0 : <p>I'm now using the new Play Billing Library</p>
<p>Basically, I followed the documentation to query available items to purchase</p>
<pre><code> SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder();
params.setSkusList(skuList).setType(itemType);
mBillingClient.querySkuDetailsAsync(params.build(),
new SkuDetailsResponseListener() {
@Override
public void onSkuDetailsResponse(int responseCode,
List<SkuDetails> skuDetailsList) {
listener.onSkuDetailsResponse(responseCode, skuDetailsList);
}
</code></pre>
<p>However, the responseCode is 0 and the list is also empty. But I checked onBillingSetupFinished is successful. The skuList that provided to SkuDetailsParams.Builder is not empty, and the values inside the skuList (sku_id) is also same as Product ID that specifies on Google Play Console. </p>
<p>Does anyone know the reason? Thanks!!</p>
| 0debug |
static void noise_scale(int *coefs, int scale, int band_energy, int len)
{
int ssign = scale < 0 ? -1 : 1;
int s = FFABS(scale);
unsigned int round;
int i, out, c = exp2tab[s & 3];
int nlz = 0;
while (band_energy > 0x7fff) {
band_energy >>= 1;
nlz++;
}
c /= band_energy;
s = 21 + nlz - (s >> 2);
if (s > 0) {
round = 1 << (s-1);
for (i=0; i<len; i++) {
out = (int)(((int64_t)coefs[i] * c) >> 32);
coefs[i] = ((int)(out+round) >> s) * ssign;
}
}
else {
s = s + 32;
round = 1 << (s-1);
for (i=0; i<len; i++) {
out = (int)((int64_t)((int64_t)coefs[i] * c + round) >> s);
coefs[i] = out * ssign;
}
}
}
| 1threat |
Hi, guys I need help solving this question that involves function and optionals : Im done with the first part, I need help with second question that involves updating the function to return an Int. Ive tried to solve it but what I get is an error
If an app asks for a user's age, it may be because the app requires a user to be over a certain age to use some of the services it provides. Write a function called checkAge that takes one parameter of type String. The function should try to convert this parameter into an Int value and then check if the user is over 18 years old. If he/she is old enough, print "Welcome!", otherwise print "Sorry, but you aren't old enough to use our app." If the String parameter cannot be converted into an Int value, print "Sorry, something went wrong. Can you please re-enter your age?" Call the function and pass in userInputAge below as the single parameter. Then call the function and pass in a string that can be converted to an integer.
Go back and update your function to return the age as an integer. Will your function always return a value? Make sure your return type accurately reflects this. Call the function and print the return value.
func checkage(age: String)->Int?
{
if let age_type = Int(age)
{
if age_type > 18 {
return "Welcome!"
}
else if age_type < 18 {
return"Sorry, but you aren't old enough to use our app."
}
}
else {
return "Sorry, something went wrong. Can you please re-enter your age?"
}
return age_type
}
print(checkage(age:"23"))
error: 3. Exercise - Functions and Optionals.xcplaygroundpage:20:12: error: use of unresolved identifier 'age_type'
return age_type
^~~~~~~~ | 0debug |
static coroutine_fn void nbd_read_reply_entry(void *opaque)
{
NBDClientSession *s = opaque;
uint64_t i;
int ret;
for (;;) {
assert(s->reply.handle == 0);
ret = nbd_receive_reply(s->ioc, &s->reply);
if (ret < 0) {
break;
}
i = HANDLE_TO_INDEX(s, s->reply.handle);
if (i >= MAX_NBD_REQUESTS || !s->recv_coroutine[i]) {
break;
}
aio_co_wake(s->recv_coroutine[i]);
qemu_coroutine_yield();
}
s->read_reply_co = NULL;
}
| 1threat |
Database Denormalization? : <p>Just to provide some context, I am working on a realtime chat application using Pusher(Websocket Service over cloud), where each messaged is logged in my server before it is pushed to the websocket server which in turn pushes the data to the client.So I am using a MySQL for storing the messages.</p>
<p>So one such table is my messages, which has the following fields <code>id,chat_payload,message_time,user_id,room_id</code>.</p>
<p>For populating the initial chatroom I would need to retrieve the message history, wherein each message object would include the <code>username,useravatar,chat_payload,timestamp</code>.But the <code>useravatar,username</code> is stored in <code>users, user_meta</code> tables respectively.So fetching the data on the run using joins clearly seems expensive since <code>user_meta</code> table grows very <a href="https://codex.wordpress.org/Database_Description" rel="nofollow">fast</a>.And clearly storing username,useravatar in <code>messages</code> table doesn't seem right as it would pose updation problems.</p>
<p>So considering the above scenario could anyone please suggest an appropriate DB/Application Design for the same? </p>
| 0debug |
send text from one android device to another through wifi : <p>I'm tryng to do an apk to use my company's wifi conection to comunicate betwen us but I don't know how to conect with the other device</p>
| 0debug |
static int IRQ_get_next(OpenPICState *opp, IRQ_queue_t *q)
{
if (q->next == -1) {
IRQ_check(opp, q);
}
return q->next;
}
| 1threat |
How to use custom logger to log access log in spring boot : <p>Currently in spring boot 1.3, we could only log access log to a file in the filesystem. Is there any way to actually use the custom logger (like log4j2) to log the access log?</p>
<p>I am currently using undertow with spring boot, but after checking the spring boot source code, the undertow logger is initialized with DefaultAccessLogReceiver which is writing to file. I would like to use the AccessLogHandler if possible, and avoid writing a web filter which logs the access.</p>
<p>Is there any easy way around this? (except writing a pull request)</p>
| 0debug |
static int rtl8139_config_writable(RTL8139State *s)
{
if (s->Cfg9346 & Cfg9346_Unlock)
{
return 1;
}
DPRINTF("Configuration registers are write-protected\n");
return 0;
}
| 1threat |
SyntaxError: Strict mode does not allow function declarations in a lexically nested statement on a newly created app : <p>I got this error today, then I uninstall react-native-cli and reinstall it, the problem's still there. I even run the reset-cache command! I tried to create a new react-native app and still see the error.
I don't want to reinstall my os for this...</p>
| 0debug |
static void net_socket_update_fd_handler(NetSocketState *s)
{
qemu_set_fd_handler2(s->fd,
s->read_poll ? net_socket_can_send : NULL,
s->read_poll ? s->send_fn : NULL,
s->write_poll ? net_socket_writable : NULL,
s);
}
| 1threat |
Babel not transpiling ES6 computed property names : <p>Babel is not transpiling ES6 computed property names. It compiles everything else though. Not sure what's going on. Using the latest version of cli. </p>
<pre><code>var name = "John";
var age = 12;
var count = 5;
var postfix = 'age';
var person = {
name,
age,
count,
postfix,
printName(){
console.log(this.name);
this.count--;
while(this.count){
this.printName();
}
},
['print' + this.postfix]: function(){
console.log(this.age);
}
};
person.printName();
person.printAge();
</code></pre>
<p><strong>Babel output</strong> </p>
<pre><code>var name = "John";
var age = 12;
var count = 5;
var postfix = 'age';
var person = _defineProperty({
name: name,
age: age,
count: count,
postfix: postfix,
printName: function printName() {
console.log(this.name);
this.count--;
while (this.count) {
this.printName();
}
}
}, 'print' + postfix, function () { // Look here
console.log(this.age);
});
</code></pre>
| 0debug |
(Python) number of list's element : <pre><code>print(circles)
</code></pre>
<p>output</p>
<pre><code>[[[282 132 121]
[712 380 121]
[280 628 121]
[138 380 122]
[570 132 121]
[568 628 120]]]
</code></pre>
<p>I want to reach number of list's element = 6</p>
<pre><code> print(len(circles)) # gives me "1"
</code></pre>
| 0debug |
What's the purpose of Kafka's key/value pair-based messaging? : <p>All of the <a href="https://www.google.com/#q=kafka+producer+key+value" rel="noreferrer">examples</a> of <a href="https://kafka.apache.org/090/javadoc/index.html?org/apache/kafka/clients/producer/KafkaProducer.html" rel="noreferrer">Kafka</a> | <a href="https://www.tutorialspoint.com/apache_kafka/apache_kafka_simple_producer_example.htm" rel="noreferrer">producers</a> show the <code>ProducerRecord</code>'s key/value pair as not only being the same type (all examples show <code><String,String></code>), but the same <strong>value</strong>. For example:</p>
<pre><code>producer.send(new ProducerRecord<String, String>("someTopic", Integer.toString(i), Integer.toString(i)));
</code></pre>
<p>But in the Kafka docs, I can't seem to find where the key/value concept (and its underlying purpose/utility) is explained. In traditional messaging (ActiveMQ, RabbitMQ, etc.) I've always fired a message at a particular topic/queue/exchange. But Kafka is the first broker that seems to require key/value pairs instead of just a regulare 'ole string message.</p>
<p>So I ask: <strong>What is the purpose/usefulness of requiring producers to send KV pairs?</strong></p>
| 0debug |
What is the advantage of using bash -c over using a here string : <p>Is there any real benefit to using <code>bash -c 'some command'</code> over using <code>bash <<< 'some command'</code></p>
<p>They seem to achieve the same effect.</p>
| 0debug |
int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset,
int nb_clusters)
{
BDRVQcowState *s = bs->opaque;
uint64_t cluster_index;
uint64_t old_free_cluster_index;
uint64_t i;
int refcount, ret;
assert(nb_clusters >= 0);
if (nb_clusters == 0) {
return 0;
}
cluster_index = offset >> s->cluster_bits;
for(i = 0; i < nb_clusters; i++) {
refcount = get_refcount(bs, cluster_index++);
if (refcount < 0) {
return refcount;
} else if (refcount != 0) {
break;
}
}
old_free_cluster_index = s->free_cluster_index;
s->free_cluster_index = cluster_index + i;
ret = update_refcount(bs, offset, i << s->cluster_bits, 1,
QCOW2_DISCARD_NEVER);
if (ret < 0) {
return ret;
}
s->free_cluster_index = old_free_cluster_index;
return i;
}
| 1threat |
void qdev_property_add_child(DeviceState *dev, const char *name,
DeviceState *child, Error **errp)
{
gchar *type;
type = g_strdup_printf("child<%s>", child->info->name);
qdev_property_add(dev, name, type, qdev_get_child_property,
NULL, NULL, child, errp);
qdev_ref(child);
g_assert(child->parent == NULL);
child->parent = dev;
g_free(type);
}
| 1threat |
static int sd_parse_uri(BDRVSheepdogState *s, const char *filename,
char *vdi, uint32_t *snapid, char *tag)
{
URI *uri;
QueryParams *qp = NULL;
int ret = 0;
uri = uri_parse(filename);
if (!uri) {
return -EINVAL;
}
if (!strcmp(uri->scheme, "sheepdog")) {
s->is_unix = false;
} else if (!strcmp(uri->scheme, "sheepdog+tcp")) {
s->is_unix = false;
} else if (!strcmp(uri->scheme, "sheepdog+unix")) {
s->is_unix = true;
} else {
ret = -EINVAL;
goto out;
}
if (uri->path == NULL || !strcmp(uri->path, "/")) {
ret = -EINVAL;
goto out;
}
if (g_strlcpy(vdi, uri->path + 1, SD_MAX_VDI_LEN) >= SD_MAX_VDI_LEN) {
ret = -EINVAL;
goto out;
}
qp = query_params_parse(uri->query);
if (qp->n > 1 || (s->is_unix && !qp->n) || (!s->is_unix && qp->n)) {
ret = -EINVAL;
goto out;
}
if (s->is_unix) {
if (uri->server || uri->port || strcmp(qp->p[0].name, "socket")) {
ret = -EINVAL;
goto out;
}
s->host_spec = g_strdup(qp->p[0].value);
} else {
s->host_spec = g_strdup_printf("%s:%d", uri->server ?: SD_DEFAULT_ADDR,
uri->port ?: SD_DEFAULT_PORT);
}
if (uri->fragment) {
if (!sd_parse_snapid_or_tag(uri->fragment, snapid, tag)) {
ret = -EINVAL;
goto out;
}
} else {
*snapid = CURRENT_VDI_ID;
}
out:
if (qp) {
query_params_free(qp);
}
uri_free(uri);
return ret;
}
| 1threat |
static av_cold int bmp_encode_init(AVCodecContext *avctx){
switch (avctx->pix_fmt) {
case AV_PIX_FMT_BGR24:
avctx->bits_per_coded_sample = 24;
break;
case AV_PIX_FMT_RGB555:
case AV_PIX_FMT_RGB565:
case AV_PIX_FMT_RGB444:
avctx->bits_per_coded_sample = 16;
break;
case AV_PIX_FMT_RGB8:
case AV_PIX_FMT_BGR8:
case AV_PIX_FMT_RGB4_BYTE:
case AV_PIX_FMT_BGR4_BYTE:
case AV_PIX_FMT_GRAY8:
case AV_PIX_FMT_PAL8:
avctx->bits_per_coded_sample = 8;
break;
case AV_PIX_FMT_MONOBLACK:
avctx->bits_per_coded_sample = 1;
break;
default:
av_log(avctx, AV_LOG_INFO, "unsupported pixel format\n");
return -1;
}
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
return 0;
}
| 1threat |
how to grab everything before a 3rd occurrence of a character in sql query : how can i grab all the data before the 3rd '-'
below i have the sample data.
000700- - - 8
015111- - 005 -
019999- - 005 -
A01- 01200- 0 - 5
A01-012000- - 5
A02-015450- - 5
A02-015450- 003 - 1
D08-020700- - 8
D08-020710- - 5
D08-020710- 013 - 1
D08-020710- 013 - 3 | 0debug |
How to get comma separated values in java from string : i have a string like
[comment=null, mapping={client_unique_id=0, email=1, first_name=2, last_name=3, batch_id=4}, recordNumber=2, values=[sdsd, asdsdf.com, jjj, hhh, 24]]
Now i need to fetch only **sdsd, asdsdf.com, jjj, hhh, 24** from values.
How could i do this.
| 0debug |
static int img_check(int argc, char **argv)
{
int c, ret;
OutputFormat output_format = OFORMAT_HUMAN;
const char *filename, *fmt, *output, *cache;
BlockBackend *blk;
BlockDriverState *bs;
int fix = 0;
int flags = BDRV_O_FLAGS | BDRV_O_CHECK;
ImageCheck *check;
bool quiet = false;
fmt = NULL;
output = NULL;
cache = BDRV_DEFAULT_CACHE;
for(;;) {
int option_index = 0;
static const struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{"format", required_argument, 0, 'f'},
{"repair", required_argument, 0, 'r'},
{"output", required_argument, 0, OPTION_OUTPUT},
{0, 0, 0, 0}
};
c = getopt_long(argc, argv, "hf:r:T:q",
long_options, &option_index);
if (c == -1) {
break;
}
switch(c) {
case '?':
case 'h':
help();
break;
case 'f':
fmt = optarg;
break;
case 'r':
flags |= BDRV_O_RDWR;
if (!strcmp(optarg, "leaks")) {
fix = BDRV_FIX_LEAKS;
} else if (!strcmp(optarg, "all")) {
fix = BDRV_FIX_LEAKS | BDRV_FIX_ERRORS;
} else {
error_exit("Unknown option value for -r "
"(expecting 'leaks' or 'all'): %s", optarg);
}
break;
case OPTION_OUTPUT:
output = optarg;
break;
case 'T':
cache = optarg;
break;
case 'q':
quiet = true;
break;
}
}
if (optind != argc - 1) {
error_exit("Expecting one image file name");
}
filename = argv[optind++];
if (output && !strcmp(output, "json")) {
output_format = OFORMAT_JSON;
} else if (output && !strcmp(output, "human")) {
output_format = OFORMAT_HUMAN;
} else if (output) {
error_report("--output must be used with human or json as argument.");
return 1;
}
ret = bdrv_parse_cache_flags(cache, &flags);
if (ret < 0) {
error_report("Invalid source cache option: %s", cache);
return 1;
}
blk = img_open("image", filename, fmt, flags, true, quiet);
if (!blk) {
return 1;
}
bs = blk_bs(blk);
check = g_new0(ImageCheck, 1);
ret = collect_image_check(bs, check, filename, fmt, fix);
if (ret == -ENOTSUP) {
error_report("This image format does not support checks");
ret = 63;
goto fail;
}
if (check->corruptions_fixed || check->leaks_fixed) {
int corruptions_fixed, leaks_fixed;
leaks_fixed = check->leaks_fixed;
corruptions_fixed = check->corruptions_fixed;
if (output_format == OFORMAT_HUMAN) {
qprintf(quiet,
"The following inconsistencies were found and repaired:\n\n"
" %" PRId64 " leaked clusters\n"
" %" PRId64 " corruptions\n\n"
"Double checking the fixed image now...\n",
check->leaks_fixed,
check->corruptions_fixed);
}
ret = collect_image_check(bs, check, filename, fmt, 0);
check->leaks_fixed = leaks_fixed;
check->corruptions_fixed = corruptions_fixed;
}
switch (output_format) {
case OFORMAT_HUMAN:
dump_human_image_check(check, quiet);
break;
case OFORMAT_JSON:
dump_json_image_check(check, quiet);
break;
}
if (ret || check->check_errors) {
ret = 1;
goto fail;
}
if (check->corruptions) {
ret = 2;
} else if (check->leaks) {
ret = 3;
} else {
ret = 0;
}
fail:
qapi_free_ImageCheck(check);
blk_unref(blk);
return ret;
}
| 1threat |
static uint64_t a9_scu_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
a9mp_priv_state *s = (a9mp_priv_state *)opaque;
switch (offset) {
case 0x00:
return s->scu_control;
case 0x04:
return (((1 << s->num_cpu) - 1) << 4) | (s->num_cpu - 1);
case 0x08:
return s->scu_status;
case 0x09:
return s->scu_status >> 8;
case 0x0a:
return s->scu_status >> 16;
case 0x0b:
return s->scu_status >> 24;
case 0x0c:
return 0;
case 0x40:
case 0x44:
return 0;
case 0x50:
case 0x54:
default:
return 0;
}
}
| 1threat |
from collections import Counter
from itertools import chain
def freq_element(nums):
result = Counter(chain.from_iterable(nums))
return result | 0debug |
Storing multiple nested objects in redis : <p>I would like to store multiple complex json data in redis but am not sure how</p>
<p>THis is my json structure</p>
<pre><code>"users":{
"user01":{username:"ally", email:"all@gmail.com"},
"user02":{username:"user2".....}
},
"trucks":{
"truck01":{reg_no:"azn102", make:"subaru" .......},
"truck02":{reg_no:"kcaher3".....}
}
</code></pre>
<p>I have checked on
<a href="https://stackoverflow.com/questions/8810036/complex-data-structures-redis">THis question</a> which provides a way to store the users but i would like to store users(01, 02) inside users then trucks(01, 02) in trucks so that if i want to retrieve users i can simply do </p>
<pre><code>hmget users
</code></pre>
<p>and similar case for trucks</p>
<p>Later i would also want to get user01 in users but am confused on how to store such data in redis</p>
| 0debug |
static void RENAME(yuv2yuv1_ar)(SwsContext *c, const int16_t *lumSrc,
const int16_t *chrUSrc, const int16_t *chrVSrc,
const int16_t *alpSrc,
uint8_t *dest, uint8_t *uDest, uint8_t *vDest,
uint8_t *aDest, int dstW, int chrDstW)
{
int p= 4;
const int16_t *src[4]= { alpSrc + dstW, lumSrc + dstW, chrUSrc + chrDstW, chrVSrc + chrDstW };
uint8_t *dst[4]= { aDest, dest, uDest, vDest };
x86_reg counter[4]= { dstW, dstW, chrDstW, chrDstW };
while (p--) {
if (dst[p]) {
__asm__ volatile(
"mov %2, %%"REG_a" \n\t"
"pcmpeqw %%mm7, %%mm7 \n\t"
"psrlw $15, %%mm7 \n\t"
"psllw $6, %%mm7 \n\t"
".p2align 4 \n\t"
"1: \n\t"
"movq (%0, %%"REG_a", 2), %%mm0 \n\t"
"movq 8(%0, %%"REG_a", 2), %%mm1 \n\t"
"paddsw %%mm7, %%mm0 \n\t"
"paddsw %%mm7, %%mm1 \n\t"
"psraw $7, %%mm0 \n\t"
"psraw $7, %%mm1 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
MOVNTQ(%%mm0, (%1, %%REGa))
"add $8, %%"REG_a" \n\t"
"jnc 1b \n\t"
:: "r" (src[p]), "r" (dst[p] + counter[p]),
"g" (-counter[p])
: "%"REG_a
);
}
}
}
| 1threat |
Typescript : how to loop through enum values for display in radio buttons? : <p>What is the proper way to loop through litterals of an enum in Typescript ?
(Currently using typescrip 1.8.1)</p>
<p>I've got the following enum :</p>
<pre><code>export enum MotifIntervention {
Intrusion,
Identification,
AbsenceTest,
Autre
}
export class InterventionDetails implements OnInit
{
constructor( private interService: InterventionService )
{
let i:number = 0;
for (let motif in MotifIntervention) {
console.log( motif );
}
}
</code></pre>
<p>The result displayed is a list</p>
<pre><code>0
1
2
3
Intrusion,
Identification,
AbsenceTest,
Autre
</code></pre>
<p>I do want only 4 iterations in the loop as there are only 4 elements in the enum, I don't want to have 0 1 2 and 3 that seem to be index numbers of the enum.</p>
| 0debug |
An Issue with pushing elements to a nested JSON : In the following code, I want to push new elements to JSON array:
var temp = [];
for(var i in resultDb){
temp.push({'ID':resultDb[i].ID});
temp.push({'Label':resultDb[i].Label});
temp.push({'User':[{'Name':resultDb[i].Name , 'ScreenName':resultDb[i].ScreenName}]});
temp.push({'TDate':resultDb[i].TDate});
}
for(var i in temp){
console.log(temp[i].User.ScreenName);
}
The result that I got is `Cannot read property 'ScreenName' of undefined`. The problem specifically is with `User` but the others are fine; they can be printed. | 0debug |
Interchange of Function in OpenCV 3.0 : Want these function in OpenCV 3.0 Java
**
**Mat imageHSV = new Mat(image.size(), Core.DEPTH_MASK_8U); Mat imageBlurr = new Mat(image.size(), Core.DEPTH_MASK_8U);
new Mat(image.size(), Core.DEPTH_MASK_ALL);
Mat imageA =new Mat(image.size(), Core.DEPTH_MASK_ALL);
**
| 0debug |
Finding how many times an item has appeared in an array = explaining the code : <p>Could you please explain how does this code work ?
I can not understand how this code works. </p>
<pre><code> HashMap<String, Integer> countMap = new HashMap<String, Integer>();
for (String string : strArray) {
if (!countMap.containsKey(string)) {
countMap.put(string, 1);
} else {
Integer count = countMap.get(string);
count = count + 1;
countMap.put(string, count);
}
}
printCount(countMap);
}
private static void printCount(HashMap<String, Integer> countMap) {
Set<String> keySet = countMap.keySet();
for (String string : keySet) {
System.out.println(string + " : " + countMap.get(string));
}
}
}
</code></pre>
| 0debug |
int ff_probe_input_buffer(ByteIOContext **pb, AVInputFormat **fmt,
const char *filename, void *logctx,
unsigned int offset, unsigned int max_probe_size)
{
AVProbeData pd = { filename ? filename : "", NULL, -offset };
unsigned char *buf = NULL;
int ret = 0, probe_size;
if (!max_probe_size) {
max_probe_size = PROBE_BUF_MAX;
} else if (max_probe_size > PROBE_BUF_MAX) {
max_probe_size = PROBE_BUF_MAX;
} else if (max_probe_size < PROBE_BUF_MIN) {
return AVERROR(EINVAL);
}
if (offset >= max_probe_size) {
return AVERROR(EINVAL);
}
for(probe_size= PROBE_BUF_MIN; probe_size<=max_probe_size && !*fmt && ret >= 0; probe_size<<=1){
int ret, score = probe_size < max_probe_size ? AVPROBE_SCORE_MAX/4 : 0;
int buf_offset = (probe_size == PROBE_BUF_MIN) ? 0 : probe_size>>1;
if (probe_size < offset) {
continue;
}
buf = av_realloc(buf, probe_size + AVPROBE_PADDING_SIZE);
if ((ret = get_buffer(*pb, buf + buf_offset, probe_size - buf_offset)) < 0) {
if (ret != AVERROR_EOF) {
av_free(buf);
return ret;
}
score = 0;
ret = 0;
}
pd.buf_size += ret;
pd.buf = &buf[offset];
memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE);
*fmt = av_probe_input_format2(&pd, 1, &score);
if(*fmt){
if(score <= AVPROBE_SCORE_MAX/4){
av_log(logctx, AV_LOG_WARNING, "Format detected only with low score of %d, misdetection possible!\n", score);
}else
av_log(logctx, AV_LOG_DEBUG, "Probed with size=%d and score=%d\n", probe_size, score);
}
}
av_free(buf);
if (url_fseek(*pb, 0, SEEK_SET) < 0) {
url_fclose(*pb);
if (url_fopen(pb, filename, URL_RDONLY) < 0)
return AVERROR(EIO);
}
return 0;
}
| 1threat |
static void ide_atapi_cmd_reply(IDEState *s, int size, int max_size)
{
if (size > max_size)
size = max_size;
s->lba = -1;
s->packet_transfer_size = size;
s->io_buffer_size = size;
s->elementary_transfer_size = 0;
s->io_buffer_index = 0;
if (s->atapi_dma) {
block_acct_start(bdrv_get_stats(s->bs), &s->acct, size,
BLOCK_ACCT_READ);
s->status = READY_STAT | SEEK_STAT | DRQ_STAT;
ide_start_dma(s, ide_atapi_cmd_read_dma_cb);
} else {
s->status = READY_STAT | SEEK_STAT;
ide_atapi_cmd_reply_end(s);
}
}
| 1threat |
Error "You must not call setTag() on a view Glide is targeting" when use Glide : <p>I use <a href="https://github.com/bumptech/glide">Glide</a> library inner custom adapter view in my apps. But I have Error :</p>
<pre><code>"You must not call setTag() on a view Glide is targeting"
</code></pre>
<p>This part of my code :</p>
<pre><code> @Override
public View getView(int position, View view, ViewGroup container) {
ViewHolder holder;
if (view == null) {
holder = new ViewHolder();
view = holder.imageView = new ImageView(context);
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
holder.imageView.setAdjustViewBounds(true);
LinearLayout.LayoutParams vp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
holder.imageView .setLayoutParams(vp);
holder.imageView .setScaleType(ImageView.ScaleType.CENTER_CROP);
String var_news_article_images = imageIdList.get(getPosition(position));
Glide.with(context)
.load(var_news_article_images)
.placeholder(R.drawable.placeholder)
.into(holder.imageView);
return view;
}
</code></pre>
<p>so how to fix it ?</p>
| 0debug |
num++ marked as syntax error in python - why? : <p>Consider the following xml file (lieferungen2.xml):</p>
<pre><code><?xml version="1.0"?>
<lieferungen>
<artikel id="1">
<name>apple</name>
<preis >2</preis>
<lieferant>Friedman</lieferant>
</artikel>
</lieferungen>
</code></pre>
<p>With the following code, I wanted to print "apple" to the command line:</p>
<pre><code>import xml.dom.minidom
dom = xml.dom.minidom.parse("lieferungen2.xml")
a = dom.getElementsByTagName("artikel")
num=0
while(True):
if a[0].childNodes[num].nodeName != "name":
num++
else:
break
print(a[0].childNodes[num].childNodes[0].nodeValue)
</code></pre>
<p>However, I get the following error message:</p>
<pre><code> num++
^
SyntaxError: invalid syntax
</code></pre>
<p>To me this syntax looks perfectly fine? What's wrong here?</p>
| 0debug |
Could not find com.android.tools.lint:lint-gradle:26.1.1 : <p>While generating APK, It's showing build failed, this is the error message : </p>
<pre><code> Could not find com.android.tools.lint:lint-gradle:26.1.1.
Searched in the following locations:
file:/C:/Users/Abde/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.pom
file:/C:/Users/Abde/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.jar
file:/C:/Users/Abde/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.pom
file:/C:/Users/Abde/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.jar
file:/C:/Users/Abde/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.pom
file:/C:/Users/Abde/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.jar
https://jcenter.bintray.com/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.pom
https://jcenter.bintray.com/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.jar
Required by:
project :app
</code></pre>
<p>Help me !
thank you</p>
| 0debug |
How to get assets img url in Symfony controller : <p>I'm using assets in Symfony 2.7.10 and I want to generate an image url in the controller. </p>
<p>In the symfony config.yml file I have added the following setting:</p>
<pre><code>framework:
assets:
version: '311nk2'
version_format: '%%s?v=%%s'
base_path: /bundles/myBundleName
</code></pre>
<p>In twig the generating of an url works ok, so with the following twig code:</p>
<pre><code>{{ asset('images/logo.png') }}
</code></pre>
<p>It generates:</p>
<pre><code>/bundles/myBundleName/images/logo.png?v=311nk2
</code></pre>
<p>Now I want to generate the same url in a controller, how is this possible?</p>
| 0debug |
use variables in dict python 3 : <p>I want, use variables in dict, how can I?
ex:</p>
<pre><code>field_one= input("Please Enter Field Name? ==> ")
field_two= input("Please Enter Field Name? ==> ")
fields_data = dict(field_one=data_one, field_two=data_two)
print (fields_data)
</code></pre>
<p>my problem is, the output not show user input, just show:</p>
<pre><code>'field_one' = 'data_one'
'field_two' = 'data_two'
</code></pre>
| 0debug |
int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque)
{
WaitObjects *w = &wait_objects;
if (w->num >= MAXIMUM_WAIT_OBJECTS)
return -1;
w->events[w->num] = handle;
w->func[w->num] = func;
w->opaque[w->num] = opaque;
w->num++;
return 0;
}
| 1threat |
How to fix indentation errors? : <p>I am getting an indentation error. I have already tried converting all tabs to spaces with my code editor and using autopep8</p>
<p>I am getting the following error: </p>
<pre><code>return (imgstring)
^
IndentationError: unexpected indent
</code></pre>
<p>Below is the code:</p>
<pre><code>def Barchart(id, title, data):
bar_chart = pygal.Bar()
bar_chart.title = title
data_cols = data.split(':')
for x in range(0, len(data_cols)):
data_num = []
data_cols_split = data_cols[x].split(',')
for y in range(1, len(data_cols_split)):
print(data_cols_split[y])
data_num.append(int(data_cols_split[y]))
bar_chart.add(str(data_cols_split[0]), data_num)
bar_chart.render_to_png('barchart.png')
s3 = session.resource('s3')
data = open('barchart.png', 'rb')
amazonname = str(id) + '.png'
s3.Bucket(bucket).put_object(Key=amazonname, Body=data)
data.close()
with open("barchart.png", "rb") as imageFile:
imgstring = base64.b64encode(imageFile.read())
return (imgstring)
</code></pre>
| 0debug |
How can I check if my AVPlayer is buffering? : <p>I want to detect if my AVPlayer is buffering for the current location, so that I can show a loader or something. But I can't seem to find anything in the documentation for AVPlayer.</p>
| 0debug |
static void free_stream(AVStream **pst)
{
AVStream *st = *pst;
int i;
if (!st)
return;
for (i = 0; i < st->nb_side_data; i++)
av_freep(&st->side_data[i].data);
av_freep(&st->side_data);
if (st->parser)
av_parser_close(st->parser);
if (st->attached_pic.data)
av_packet_unref(&st->attached_pic);
if (st->internal) {
avcodec_free_context(&st->internal->avctx);
for (i = 0; i < st->internal->nb_bsfcs; i++) {
av_bsf_free(&st->internal->bsfcs[i]);
av_freep(&st->internal->bsfcs);
}
av_bsf_free(&st->internal->extract_extradata.bsf);
av_packet_free(&st->internal->extract_extradata.pkt);
}
av_freep(&st->internal);
av_dict_free(&st->metadata);
avcodec_parameters_free(&st->codecpar);
av_freep(&st->probe_data.buf);
av_freep(&st->index_entries);
#if FF_API_LAVF_AVCTX
FF_DISABLE_DEPRECATION_WARNINGS
av_freep(&st->codec->extradata);
av_freep(&st->codec->subtitle_header);
av_freep(&st->codec);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
av_freep(&st->priv_data);
if (st->info)
av_freep(&st->info->duration_error);
av_freep(&st->info);
av_freep(&st->recommended_encoder_configuration);
av_freep(&st->priv_pts);
av_freep(pst);
}
| 1threat |
Handling try and throws in Swift 3 : <p>Before Swift 3 I was using:</p>
<pre><code>guard let data = Data(contentsOf: url) else {
print("There was an error!)
return
}
</code></pre>
<p>However I now have to use <code>do</code>, <code>try</code> and <code>catch</code>. I'm not familiar with this syntax. How would I replicate this behaviour?</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.