problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Three SQL TABLES Payment, Appointment, Doctor Find average salary of each patient : Create Table Doctor(
doctorID varchar(50) Primary key,
doctorFName varchar(50),
);
Create Table Appointment(
appID varchar(50) Primary Key,
doctorID varchar(50) Foreign Key References Doctor(doctorID),
);
Create Table Payment(
paymentID varchar(50) Primary Key,
paymentAmount int,
appID varchar(50) Foreign Key References Appointment(appID),
);
paymentAmount is also known as payment for each appointment
How can i get the average payment amount of each doctor?
| 0debug
|
JavaScript - Create a loading bar : <p>I'm trying to create a loading bar, that I'll use when I'll open links or images. I mean, while the page/image isn't loaded yet, a would like to show a loading bar like the one I shown you.<br>
I know how to create the bar in fact, but I don't know how to get the status of the load of the page/image. I imagine that I need to use JavaScript or jQuery, but if you know any way to do this in PHP it would help me.</p>
<p><a href="https://i.stack.imgur.com/51I95.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/51I95.jpg" alt="Loading Bar"></a></p>
<p>Thanks!</p>
| 0debug
|
Send on Pi1 using SSH a command that let run a .py script on another raspberry pi : I am trying to let my raspberrypi run a script that triggers a ssh command to another raspberry pi on my lan network that runs another script. I am stuck for 2 days and can't find any solutions. How do I go about connecting them?
| 0debug
|
static void init_dequant4_coeff_table(H264Context *h){
int i,j,q,x;
const int transpose = (h->h264dsp.h264_idct_add != ff_h264_idct_add_c);
for(i=0; i<6; i++ ){
h->dequant4_coeff[i] = h->dequant4_buffer[i];
for(j=0; j<i; j++){
if(!memcmp(h->pps.scaling_matrix4[j], h->pps.scaling_matrix4[i], 16*sizeof(uint8_t))){
h->dequant4_coeff[i] = h->dequant4_buffer[j];
break;
}
}
if(j<i)
continue;
for(q=0; q<52; q++){
int shift = div6[q] + 2;
int idx = rem6[q];
for(x=0; x<16; x++)
h->dequant4_coeff[i][q][transpose ? (x>>2)|((x<<2)&0xF) : x] =
((uint32_t)dequant4_coeff_init[idx][(x&1) + ((x>>2)&1)] *
h->pps.scaling_matrix4[i][x]) << shift;
}
}
}
| 1threat
|
static void compute_frame_duration(int *pnum, int *pden, AVStream *st,
AVCodecParserContext *pc, AVPacket *pkt)
{
int frame_size;
*pnum = 0;
*pden = 0;
switch(st->codec.codec_type) {
case CODEC_TYPE_VIDEO:
if(st->time_base.num*1000 > st->time_base.den){
*pnum = st->time_base.num;
*pden = st->time_base.den;
}else if(st->codec.time_base.num*1000 > st->codec.time_base.den){
*pnum = st->codec.time_base.num;
*pden = st->codec.time_base.den;
if (pc && pc->repeat_pict) {
*pden *= 2;
*pnum = (*pnum) * (2 + pc->repeat_pict);
}
}
break;
case CODEC_TYPE_AUDIO:
frame_size = get_audio_frame_size(&st->codec, pkt->size);
if (frame_size < 0)
break;
*pnum = frame_size;
*pden = st->codec.sample_rate;
break;
default:
break;
}
}
| 1threat
|
RxJava- RxAndroid form validation on dynamic EditText : <p>I have form that can have variable number of <code>EditText</code> that needs to be validated before form submission. I can perform validation check if <code>EditText</code>s are fixed in number like following - </p>
<pre><code>Observable<CharSequence> emailObservable = RxTextView.textChanges(editEmail).skip(1);
Observable<CharSequence> passwordObservable = RxTextView.textChanges(editPassword).skip(1);
mFormValidationSubscription = Observable.combineLatest(emailObservable, passwordObservable,
(newEmail, newPassword) -> {
boolean emailValid = !TextUtils.isEmpty(newEmail) && android.util.Patterns.EMAIL_ADDRESS.matcher(newEmail).matches();
if(!emailValid) {
emailInputLayout.setError(getString(R.string.error_invalid_email));
emailInputLayout.setErrorEnabled(true);
}else {
emailInputLayout.setError(null);
emailInputLayout.setErrorEnabled(false);
}
boolean passValid = !TextUtils.isEmpty(newPassword) && newPassword.length() > 4;
if (!passValid) {
passwordInputLayout.setError(getString(R.string.error_invalid_password));
passwordInputLayout.setErrorEnabled(true);
} else {
passwordInputLayout.setError(null);
passwordInputLayout.setErrorEnabled(true);
}
return emailValid && passValid;
}).subscribe(isValid ->{
mSubmitButton.setEnabled(isValid);
});
</code></pre>
<p>But now as there are variable number of inputs I tried creating a list of <code>Observable<CharSequence></code> and <code>Observable.combineLatest()</code> but I'm stuck as to proceed with that. </p>
<pre><code>List<Observable<CharSequence>> observableList = new ArrayList<>();
for(InputRule inputRule : mMaterial.getRules()) {
View vInputRow = inflater.inflate(R.layout.item_material_input_row, null, false);
StyledEditText styledEditText = ((StyledEditText)vInputRow.findViewById(R.id.edit_input));
styledEditText.setHint(inputRule.getName());
Observable<CharSequence> observable = RxTextView.textChanges(styledEditText).skip(1);
observableList.add(observable);
linearLayout.addView(vInputRow);
}
Observable.combineLatest(observableList,......); // What should go in place of these "......"
</code></pre>
<p>How can I perform checks for a valid charsequence for each input field. I looked into <code>flatMap()</code>, <code>map()</code>, <code>filter()</code> methods but I don't know how to use them. </p>
| 0debug
|
static int protocol_client_auth(VncState *vs, char *data, size_t len)
{
if (data[0] != vs->auth) {
VNC_DEBUG("Reject auth %d\n", (int)data[0]);
vnc_write_u32(vs, 1);
if (vs->minor >= 8) {
static const char err[] = "Authentication failed";
vnc_write_u32(vs, sizeof(err));
vnc_write(vs, err, sizeof(err));
}
vnc_client_error(vs);
} else {
VNC_DEBUG("Client requested auth %d\n", (int)data[0]);
switch (vs->auth) {
case VNC_AUTH_NONE:
VNC_DEBUG("Accept auth none\n");
vnc_write_u32(vs, 0);
vnc_read_when(vs, protocol_client_init, 1);
break;
case VNC_AUTH_VNC:
VNC_DEBUG("Start VNC auth\n");
return start_auth_vnc(vs);
#if CONFIG_VNC_TLS
case VNC_AUTH_VENCRYPT:
VNC_DEBUG("Accept VeNCrypt auth\n");;
return start_auth_vencrypt(vs);
#endif
default:
VNC_DEBUG("Reject auth %d\n", vs->auth);
vnc_write_u8(vs, 1);
if (vs->minor >= 8) {
static const char err[] = "Authentication failed";
vnc_write_u32(vs, sizeof(err));
vnc_write(vs, err, sizeof(err));
}
vnc_client_error(vs);
}
}
return 0;
}
| 1threat
|
int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar)
{
CPUS390XState *env = &cpu->env;
uint32_t fh;
ZpciFib fib;
S390PCIBusDevice *pbdev;
uint32_t data;
uint64_t cc = ZPCI_PCI_LS_OK;
if (env->psw.mask & PSW_MASK_PSTATE) {
program_interrupt(env, PGM_PRIVILEGED, 6);
return 0;
}
fh = env->regs[r1] >> 32;
if (fiba & 0x7) {
program_interrupt(env, PGM_SPECIFICATION, 6);
return 0;
}
pbdev = s390_pci_find_dev_by_fh(fh);
if (!pbdev) {
setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
}
memset(&fib, 0, sizeof(fib));
switch (pbdev->state) {
case ZPCI_FS_RESERVED:
case ZPCI_FS_STANDBY:
setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
case ZPCI_FS_DISABLED:
if (fh & FH_MASK_ENABLE) {
setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
}
goto out;
case ZPCI_FS_ERROR:
fib.fc |= 0x20;
case ZPCI_FS_BLOCKED:
fib.fc |= 0x40;
case ZPCI_FS_ENABLED:
fib.fc |= 0x80;
if (pbdev->iommu_enabled) {
fib.fc |= 0x10;
}
if (!(fh & FH_MASK_ENABLE)) {
env->regs[r1] |= 1ULL << 63;
}
break;
case ZPCI_FS_PERMANENT_ERROR:
setcc(cpu, ZPCI_PCI_LS_ERR);
s390_set_status_code(env, r1, ZPCI_STPCIFC_ST_PERM_ERROR);
return 0;
}
stq_p(&fib.pba, pbdev->pba);
stq_p(&fib.pal, pbdev->pal);
stq_p(&fib.iota, pbdev->g_iota);
stq_p(&fib.aibv, pbdev->routes.adapter.ind_addr);
stq_p(&fib.aisb, pbdev->routes.adapter.summary_addr);
stq_p(&fib.fmb_addr, pbdev->fmb_addr);
data = ((uint32_t)pbdev->isc << 28) | ((uint32_t)pbdev->noi << 16) |
((uint32_t)pbdev->routes.adapter.ind_offset << 8) |
((uint32_t)pbdev->sum << 7) | pbdev->routes.adapter.summary_offset;
stl_p(&fib.data, data);
out:
if (s390_cpu_virt_mem_write(cpu, fiba, ar, (uint8_t *)&fib, sizeof(fib))) {
return 0;
}
setcc(cpu, cc);
return 0;
}
| 1threat
|
static int mpegts_raw_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
MpegTSContext *ts = s->priv_data;
int ret, i;
int64_t pcr_h, next_pcr_h, pos;
int pcr_l, next_pcr_l;
uint8_t pcr_buf[12];
if (av_new_packet(pkt, TS_PACKET_SIZE) < 0)
return AVERROR(ENOMEM);
pkt->pos= url_ftell(s->pb);
ret = read_packet(s->pb, pkt->data, ts->raw_packet_size);
if (ret < 0) {
av_free_packet(pkt);
return ret;
}
if (ts->mpeg2ts_compute_pcr) {
if (parse_pcr(&pcr_h, &pcr_l, pkt->data) == 0) {
pos = url_ftell(s->pb);
for(i = 0; i < MAX_PACKET_READAHEAD; i++) {
url_fseek(s->pb, pos + i * ts->raw_packet_size, SEEK_SET);
get_buffer(s->pb, pcr_buf, 12);
if (parse_pcr(&next_pcr_h, &next_pcr_l, pcr_buf) == 0) {
ts->pcr_incr = ((next_pcr_h - pcr_h) * 300 + (next_pcr_l - pcr_l)) /
(i + 1);
break;
}
}
url_fseek(s->pb, pos, SEEK_SET);
ts->cur_pcr = pcr_h * 300 + pcr_l;
}
pkt->pts = ts->cur_pcr;
pkt->duration = ts->pcr_incr;
ts->cur_pcr += ts->pcr_incr;
}
pkt->stream_index = 0;
return 0;
}
| 1threat
|
Digest authentication in ASP.NET Core / Kestrel : <p>Is it possible to use <a href="https://en.wikipedia.org/wiki/Digest_access_authentication" rel="noreferrer">digest authentication</a> in ASP.NET Core / Kestrel? If it is, how do I enable and use it?</p>
<p>I know that <a href="https://en.wikipedia.org/wiki/Basic_access_authentication" rel="noreferrer">basic authentication</a> is not and will not be implemented because <a href="https://github.com/aspnet/Security#notes" rel="noreferrer">it's considered insecure and slow</a>, but I can't find anything at all about digest.</p>
<p>I don't want to use IIS' authentication because I don't want to be tied to Windows accounts, I want use a custom credentials validation logic.</p>
| 0debug
|
SQLAlchemy eager loading multiple relationships : <p>SQLAlchemy supports eager load for relationship, it is basically a <code>JOIN</code> statement. However, if a model has two or more relationships, it could be a very huge join. For example,</p>
<pre><code>class Product(Base):
__tablename__ = 'product'
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(String(255), nullable=False)
orders = relationship('Order', backref='product', cascade='all')
tags = relationship('Tag', secondary=product_tag_map)
class Order(Base):
__tablename__ = 'order'
id = Column(Integer, primary_key=True, autoincrement=True)
date = Column(TIMESTAMP, default=datetime.now())
class Tag(Base):
__tablename__ = 'tag'
id = Column(Integer, primary_key=True, autoincrement=True)
tag_type = Column(String(255), nullable=False)
tag_value = Column(String(255), nullable=False)
q = session.query(Product).join(User.addresses)\
.options(joinedload(Product.orders))\
.options(joinedload(Product.tags)).all()
</code></pre>
<p>The performance of this query is really bad, because the <code>JOIN</code> of <code>Order</code> and <code>Tag</code> will generate a huge table. But the <code>Order</code> and <code>Tag</code> has no relationship in here, so they should not be <code>JOIN</code>. It should be two separated queries. And because the session has some level of caching, so I changed my query to this.</p>
<pre><code>session.query(Product).join(Product.order) \
.options(joinedload(Product.tags)).all()
q = session.query(Product).join(User.addresses) \
.options(joinedload(Product.cases)).all()
</code></pre>
<p>This time the performance is way much better. However, I am not convinced that this is the correct to do it. I am not sure if the caches of tags will be expired when the session ends.</p>
<p>Please let me know the appropriate way for this kind of query. Thank you!</p>
| 0debug
|
How to acess different date format in js : I have 2 variables
var myDate1 = "3.6.2015" AND var myDate2 = "6.2014"
var date1= new Date(myDate1);
var date2= new Date(myDate2);
Here myDate2 donot contain days. It contains only year and month. I can't `alter(date2)`.
How to do that.I am very new to js
**Plz help**
| 0debug
|
Alamofire 4.0 RequestRetrier should(_,retry,with,completion) not being called : <p>I am using the <code>RequestRetrier</code> of Alamofire 4.0 to control the retrying of requests for expired access token. I am following the documentation <a href="https://github.com/Alamofire/Alamofire#adapting-and-retrying-requests" rel="noreferrer">here</a>.</p>
<p>I have a very similar implementation to the example available in the documentation <code>OAuth2Handler</code> which implements <code>RequestAdapter</code> and <code>RequestRetrier</code>. </p>
<p>The issue I am encountering is that <code>func should(_ manager: SessionManager, retry request: Request, with error: Error, completion: @escaping RequestRetryCompletion)</code> is never being called. The <code>adapt</code> method of the <code>RequestAdapter</code> implementation does get called though.</p>
<p>Debugging, I see that <code>SessionDelegate</code> only calls <code>should(_,retry,with,completion)</code> when there is an error, but requests that return status codes related to Authorization issues, don't seem to generate errors, so that method never gets called.</p>
<p>Am I missing something here?</p>
| 0debug
|
static int pollfds_fill(GArray *pollfds, fd_set *rfds, fd_set *wfds,
fd_set *xfds)
{
int nfds = -1;
int i;
for (i = 0; i < pollfds->len; i++) {
GPollFD *pfd = &g_array_index(pollfds, GPollFD, i);
int fd = pfd->fd;
int events = pfd->events;
if (events & (G_IO_IN | G_IO_HUP | G_IO_ERR)) {
FD_SET(fd, rfds);
nfds = MAX(nfds, fd);
}
if (events & (G_IO_OUT | G_IO_ERR)) {
FD_SET(fd, wfds);
nfds = MAX(nfds, fd);
}
if (events & G_IO_PRI) {
FD_SET(fd, xfds);
nfds = MAX(nfds, fd);
}
}
return nfds;
}
| 1threat
|
PHP Registry has a deprecated constructor Error : <p>I am having <code>Registry has a deprecated constructor</code>Error while running a php script.it shows the error on line 261. Going to that line I am having below codes.How to avoid this error.</p>
<pre><code>class Registry {
function Registry() {
define("CWD", ($getcwd = getcwd() ? $getcwd : "."));
$config = array();
include INCLUDES . "config.php";
if (sizeof($config) == 0) {
if (file_exists(INCLUDES . "config.php")) {
exit( "<div style=\"border: 1px dashed #cc0000;font-family:Tahoma;background-color:#FBEEEB;width:100%;padding:10px;color:#cc0000;\"><strong>Welcome to EvolutionScript 5.1 FULL</strong><a></a><br>Before you can begin using EvolutionScript you need to perform the installation procedure. <a href=\"" . (file_exists( "install/install.php" ) ? "" : "../") . "install/install.php\" style=\"color:#000;\">Click here to begin ...</a><br></div>" );
}
else {
exit("<br /><br /><strong>Configuration</strong>: includes/config.php does not exist. Please fill out the data in config.php.new and rename it to config.php");
}
}
$this->config = $config;
define("TABLE_PREFIX", trim($this->config['Database']['tableprefix']));
define("COOKIE_PREFIX", (empty($this->config['Misc']['cookieprefix']) ? "ptc" : $this->config['Misc']['cookieprefix']) . "_");
}
}
</code></pre>
| 0debug
|
please help me with #1452 error : i am new to php coding and donn know much of it..pls help me...
Cannot delete or update a parent row: a foreign key constraint fails (`sponge`.`taxonomy`, CONSTRAINT `taxonomy_ibfk_1` FOREIGN KEY (`organism_id`) REFERENCES `organism` (`organism_id`))
i am getting this error while deleting entire record.Actually i wanted to deleted entire record from all table associated by Organism_id in spong DB.
my Organism Table is:-
CREATE TABLE IF NOT EXISTS `organism` (
`organism_id` int(11) NOT NULL AUTO_INCREMENT,
`experts_id` int(11) NOT NULL,
`literature_id` int(11) NOT NULL,
`genus` varchar(255) NOT NULL,
`species` varchar(255) NOT NULL,
`scientific_name` varchar(255) NOT NULL,
`organism_type` varchar(255) NOT NULL,
`author_org` varchar(255) NOT NULL,
`found_year` varchar(255) NOT NULL,
`curated_year` date NOT NULL,
`curated_status` varchar(10) NOT NULL,
PRIMARY KEY (`organism_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=60 ;
and Taxonomy table is:
CREATE TABLE IF NOT EXISTS `taxonomy` (
`taxonomy_id` int(11) NOT NULL AUTO_INCREMENT,
`organism_id` int(11) NOT NULL,
`kingdom` varchar(255) NOT NULL,
`phylum` varchar(255) NOT NULL,
`class` varchar(255) NOT NULL,
`order_tax` varchar(255) NOT NULL,
`family` varchar(255) NOT NULL,
PRIMARY KEY (`taxonomy_id`),
KEY `organism_id` (`organism_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=50 ;
but when i am using delete query:-
SELECT a.*,u.*,s.*,b.*,c.*,d.*,e.*,i.*,m.*
FROM organism a
JOIN taxonomy u
ON u.organism_id = a.organism_id
JOIN synonym s
ON s.organism_id = u.organism_id_id
JOIN biogeography b
ON b.organism_id = s.organism_id_id
JOIN common_name c
ON c.organism_id = b.organism_id_id
JOIN description d
ON d.organism_id = c.organism_id_id
JOIN ecology e
ON e.organism_id = d.organism_id_id
JOIN economic_importance i
ON i.organism_id = e.organism_id_id
JOIN images m
ON m.organism_id = i.organism_id_id
WHERE m.organism_id = 59
i am getting above error...
please help to write delete query and how to remove above #1452 error...
please help me...
| 0debug
|
static int check_for_block_signature(BlockDriverState *bs, const uint8_t *buf)
{
static const uint8_t signatures[][4] = {
{ 'Q', 'F', 'I', 0xfb },
{ 'C', 'O', 'W', 'D' },
{ 'V', 'M', 'D', 'K' },
{ 'O', 'O', 'O', 'M' },
{}
};
int i;
for (i = 0; signatures[i][0] != 0; i++) {
if (memcmp(buf, signatures[i], 4) == 0) {
return 1;
}
}
return 0;
}
| 1threat
|
static int detect_stream_specific(AVFormatContext *avf, int idx)
{
ConcatContext *cat = avf->priv_data;
AVStream *st = cat->avf->streams[idx];
ConcatStream *cs = &cat->cur_file->streams[idx];
AVBitStreamFilterContext *bsf;
int ret;
if (cat->auto_convert && st->codecpar->codec_id == AV_CODEC_ID_H264 &&
(st->codecpar->extradata_size < 4 || AV_RB32(st->codecpar->extradata) != 1)) {
av_log(cat->avf, AV_LOG_INFO,
"Auto-inserting h264_mp4toannexb bitstream filter\n");
if (!(bsf = av_bitstream_filter_init("h264_mp4toannexb"))) {
av_log(avf, AV_LOG_ERROR, "h264_mp4toannexb bitstream filter "
"required for H.264 streams\n");
return AVERROR_BSF_NOT_FOUND;
}
cs->bsf = bsf;
cs->avctx = avcodec_alloc_context3(NULL);
if (!cs->avctx)
return AVERROR(ENOMEM);
av_freep(&st->codecpar->extradata);
st->codecpar->extradata_size = 0;
ret = avcodec_parameters_to_context(cs->avctx, st->codecpar);
if (ret < 0) {
avcodec_free_context(&cs->avctx);
return ret;
}
}
return 0;
}
| 1threat
|
Laravel: Check with Observer if Column was Changed on Update : <p>I am using an <a href="https://laravel.com/docs/5.5/eloquent#observers" rel="noreferrer">Observer</a> to watch if a user was updated.</p>
<p>Whenever a user is <code>updated</code> I would like to check if his <code>email</code> has been changed. </p>
<p>Is something like this possible?</p>
<pre><code>class UserObserver
{
/**
* Listen to the User created event.
*
* @param \App\User $user
* @return void
*/
public function updating(User $user)
{
// if($user->hasChangedEmailInThisUpdate()) ?
}
}
</code></pre>
| 0debug
|
static void pxa2xx_ssp_fifo_update(PXA2xxSSPState *s)
{
s->sssr &= ~(0xf << 12);
s->sssr &= ~(0xf << 8);
s->sssr &= ~SSSR_TNF;
if (s->enable) {
s->sssr |= ((s->rx_level - 1) & 0xf) << 12;
if (s->rx_level >= SSCR1_RFT(s->sscr[1]))
s->sssr |= SSSR_RFS;
else
s->sssr &= ~SSSR_RFS;
if (0 <= SSCR1_TFT(s->sscr[1]))
s->sssr |= SSSR_TFS;
else
s->sssr &= ~SSSR_TFS;
if (s->rx_level)
s->sssr |= SSSR_RNE;
else
s->sssr &= ~SSSR_RNE;
s->sssr |= SSSR_TNF;
}
pxa2xx_ssp_int_update(s);
}
| 1threat
|
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
| 1threat
|
i want to make constructor take url for use this class in many activity but it not works help me please : `$`i want to make constructor take url for use the class in many activity but it not works help me please
there is my code
class BackgroundTask extends AsyncTask<Void, Void, String> {
String url1;
there i want to take url from oncreate in main but not work
public BackgroundTask(String json_url) {
super();
this.url1=json_url;
}
@Override
protected String doInBackground(Void... voids) {
try {
URL url =new URL(url1);
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
InputStream inputStream = httpURLConnection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder stringBuilder = new StringBuilder();
while ((JSON_STRING_Doctor = bufferedReader.readLine()) != null) {
stringBuilder.append(JSON_STRING_Doctor + "\n");
}
bufferedReader.close();
inputStream.close();
httpURLConnection.disconnect();
return stringBuilder.toString().trim();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onProgressUpdate(Void... values) {
super.onProgressUpdate(values);
}
@Override
protected void onPostExecute(String res) {
json_string = res;
}
}
and
in oncreate i call first a new backgroudTask with url and after i call excute methode but no result json_string is null i need some help here
`$`please can any one help me
| 0debug
|
List returned from function is 0, Python3 : I'm writing a program in Python to better understand my linear algebra course.
I'm trying to use a function to get the RREF form of an input matrix. The function works and prints what it should. When I return what it printed ( code below ) and access that returned value, it will not provide a list. Instead, it returns 0.
How can I access the returned value as a list?
Here's the function:
`global rref_matrix
rref_matrix = [[c for c in matrix_given[i]] for i in range(len(matrix_given))]
print(rref_matrix)
leading_one = 0
rowCount = len(rref_matrix)
columnCount = len(rref_matrix[0])
for row in range(rowCount):
if columnCount <= leading_one:
break
r = row
while rref_matrix[r][leading_one] == 0:
r += 1
if rowCount == r:
r = row
leading_one += 1
if columnCount == leading_one:
print(rref_matrix)
return 0
rref_matrix[r], rref_matrix[row] = rref_matrix[row], rref_matrix[r]
if rref_matrix[row][leading_one] != 0:
rref_matrix[row][:] = [x / rref_matrix[row][leading_one] for x in rref_matrix[row]]
for new_row in range(len(rref_matrix)):
if new_row != row:
rref_matrix[new_row][:] = [x - (rref_matrix[new_row][leading_one] * rref_matrix[row][rref_matrix[new_row].index(x)]) for x in rref_matrix[new_row]]
leading_one += 1
print(rref_matrix)
return rref_matrix`
And I access it as follows:
` rref_transposed = [row for row in rref(list(zip(*matrix)))]
print(rref_transposed)`
It prints 0.
What am I not seeing?
Thanks in advance!
| 0debug
|
int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
{
void *dst, *target_obj;
const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);
uint8_t *bin, buf[128];
int len, i, ret;
if (!o || !target_obj)
return AVERROR_OPTION_NOT_FOUND;
dst = (uint8_t*)target_obj + o->offset;
buf[0] = 0;
switch (o->type) {
case AV_OPT_TYPE_FLAGS: ret = snprintf(buf, sizeof(buf), "0x%08X", *(int *)dst);break;
case AV_OPT_TYPE_INT: ret = snprintf(buf, sizeof(buf), "%d" , *(int *)dst);break;
case AV_OPT_TYPE_INT64: ret = snprintf(buf, sizeof(buf), "%"PRId64, *(int64_t*)dst);break;
case AV_OPT_TYPE_FLOAT: ret = snprintf(buf, sizeof(buf), "%f" , *(float *)dst);break;
case AV_OPT_TYPE_DOUBLE: ret = snprintf(buf, sizeof(buf), "%f" , *(double *)dst);break;
case AV_OPT_TYPE_RATIONAL: ret = snprintf(buf, sizeof(buf), "%d/%d", ((AVRational*)dst)->num, ((AVRational*)dst)->den);break;
case AV_OPT_TYPE_STRING:
if (*(uint8_t**)dst)
*out_val = av_strdup(*(uint8_t**)dst);
else
*out_val = av_strdup("");
return 0;
case AV_OPT_TYPE_BINARY:
len = *(int*)(((uint8_t *)dst) + sizeof(uint8_t *));
if ((uint64_t)len*2 + 1 > INT_MAX)
return AVERROR(EINVAL);
if (!(*out_val = av_malloc(len*2 + 1)))
return AVERROR(ENOMEM);
bin = *(uint8_t**)dst;
for (i = 0; i < len; i++)
snprintf(*out_val + i*2, 3, "%02X", bin[i]);
return 0;
default:
return AVERROR(EINVAL);
}
if (ret >= sizeof(buf))
return AVERROR(EINVAL);
*out_val = av_strdup(buf);
return 0;
}
| 1threat
|
How much do you have to pay for publishing apps? : <p>I saw you have to pay a developer fee to publish your apps on the google play store and the app store. For the app store you pay $99 and for the google play store $25. But do you have to pay this amount for each app you publish ? Or is this for your account once in a lifetime or do you have to pay this amount each year ?</p>
<p>Thanks in advance !</p>
| 0debug
|
java.lang.NoClassDefFoundError: org/glassfish/jersey/internal/inject/Binder when started Tomcat Server : <p>I am building REST API in Java with Jersey and Maven. I used Tomcat 9 as my server. Everything works fine until I tried to install <strong>RestAssured,</strong> <strong>Hamcrest,</strong> and <strong>JUnit</strong> today. Suddenly all of my endpoints threw out 500 Internal server errors. The root cause of the 500 error is <code>java.lang.NoClassDefFoundError: org/glassfish/jersey/internal/inject/Binder.</code></p>
<p>What I have done this 2 hours: </p>
<ul>
<li>I have tried to find this class: <code>org/glassfish/jersey/internal/inject/Binder</code> on google, but no avail. </li>
<li>I have tried to uninstall <strong>RestAssured</strong>, <strong>Hamcrest</strong>, and <strong>JUnit</strong> but it didn't help. </li>
</ul>
<p>This problem makes me frustrated. Any idea why this errors happened? Thanks in advance!</p>
<p>Here is the excerpt of the server log:</p>
<blockquote>
<p><strong>SEVERE: Allocate exception for servlet Jersey Web Application java.lang.ClassNotFoundException: org.glassfish.jersey.internal.inject.Binder</strong>
at
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1275)
at
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1109)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:178)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:370)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1183)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1099)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:779)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:133)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:475)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:498)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:796)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1368)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)</p>
</blockquote>
<p>Below is my <code>pom.xml</code> file: (with RestAssured, Hamcrest, and JUnit)</p>
<pre><code><dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- artifactId>jersey-container-servlet</artifactId -->
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId>
<version>2.9.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</code></pre>
<p>Below is my web.xml file:</p>
<pre><code><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.accelbyte.vincent.emailist.resources</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/webapi/*</url-pattern>
</servlet-mapping>
</code></pre>
<p></p>
<p>Below is my project structure: </p>
<p><a href="https://i.stack.imgur.com/s95Al.png" rel="noreferrer">Email list project structure</a></p>
| 0debug
|
Firebase Android Default Setup and User Privacy : <p>I followed the setup steps mentioned in Firebase docs in order to setup Firebase in my android app:
<a href="https://firebase.google.com/docs/android/setup" rel="noreferrer">https://firebase.google.com/docs/android/setup</a></p>
<p>However, after monitoring the outgoing http connections using Charles, I found the following URLs being accessed:</p>
<p><a href="https://play.googleapis.com" rel="noreferrer">https://play.googleapis.com</a></p>
<p><a href="https://www.googleapis.com" rel="noreferrer">https://www.googleapis.com</a></p>
<p><a href="https://ssl.google-analytics.com" rel="noreferrer">https://ssl.google-analytics.com</a></p>
<p>So my questions are:</p>
<ol>
<li><p>Which of these URLs are used for Firebase analytics (I have read that Firebase analytics automatically collects information without doing any explicit call to Firebase analytics api)?</p></li>
<li><p>Is there any possibility to turn off sending information to Firebase? so I can control exactly the sent information for user privacy requirements? I have read in the documentation that it is possible to de-activate analytics by setting "firebase_analytics_collection_deactivated" to true:
<a href="https://firebase.google.com/support/guides/disable-analytics" rel="noreferrer">https://firebase.google.com/support/guides/disable-analytics</a></p></li>
</ol>
<p>So does setting this flag to true prevents automatic upload of data?</p>
<p><a href="https://i.stack.imgur.com/LfcWq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LfcWq.png" alt="enter image description here"></a></p>
| 0debug
|
static int ra288_decode_frame(AVCodecContext * avctx, void *data,
int *data_size, const uint8_t * buf,
int buf_size)
{
int16_t *out = data;
int i, j;
RA288Context *ractx = avctx->priv_data;
GetBitContext gb;
if (buf_size < avctx->block_align) {
av_log(avctx, AV_LOG_ERROR,
"Error! Input buffer is too small [%d<%d]\n",
buf_size, avctx->block_align);
return 0;
}
init_get_bits(&gb, buf, avctx->block_align * 8);
for (i=0; i < 32; i++) {
float gain = amptable[get_bits(&gb, 3)];
int cb_coef = get_bits(&gb, 6 + (i&1));
decode(ractx, gain, cb_coef);
for (j=0; j < 5; j++)
*(out++) = 8 * ractx->sp_block[4 - j];
if ((i & 7) == 3)
backward_filter(ractx);
}
*data_size = (char *)out - (char *)data;
return avctx->block_align;
}
| 1threat
|
static av_always_inline void hl_decode_mb_idct_luma(H264Context *h, int mb_type,
int is_h264, int simple,
int transform_bypass,
int pixel_shift,
int *block_offset,
int linesize,
uint8_t *dest_y, int p)
{
void (*idct_add)(uint8_t *dst, int16_t *block, int stride);
int i;
block_offset += 16 * p;
if (!IS_INTRA4x4(mb_type)) {
if (is_h264) {
if (IS_INTRA16x16(mb_type)) {
if (transform_bypass) {
if (h->sps.profile_idc == 244 &&
(h->intra16x16_pred_mode == VERT_PRED8x8 ||
h->intra16x16_pred_mode == HOR_PRED8x8)) {
h->hpc.pred16x16_add[h->intra16x16_pred_mode](dest_y, block_offset,
h->mb + (p * 256 << pixel_shift),
linesize);
} else {
for (i = 0; i < 16; i++)
if (h->non_zero_count_cache[scan8[i + p * 16]] ||
dctcoef_get(h->mb, pixel_shift, i * 16 + p * 256))
h->h264dsp.h264_add_pixels4(dest_y + block_offset[i],
h->mb + (i * 16 + p * 256 << pixel_shift),
linesize);
}
} else {
h->h264dsp.h264_idct_add16intra(dest_y, block_offset,
h->mb + (p * 256 << pixel_shift),
linesize,
h->non_zero_count_cache + p * 5 * 8);
}
} else if (h->cbp & 15) {
if (transform_bypass) {
const int di = IS_8x8DCT(mb_type) ? 4 : 1;
idct_add = IS_8x8DCT(mb_type) ? h->h264dsp.h264_add_pixels8
: h->h264dsp.h264_add_pixels4;
for (i = 0; i < 16; i += di)
if (h->non_zero_count_cache[scan8[i + p * 16]])
idct_add(dest_y + block_offset[i],
h->mb + (i * 16 + p * 256 << pixel_shift),
linesize);
} else {
if (IS_8x8DCT(mb_type))
h->h264dsp.h264_idct8_add4(dest_y, block_offset,
h->mb + (p * 256 << pixel_shift),
linesize,
h->non_zero_count_cache + p * 5 * 8);
else
h->h264dsp.h264_idct_add16(dest_y, block_offset,
h->mb + (p * 256 << pixel_shift),
linesize,
h->non_zero_count_cache + p * 5 * 8);
}
}
} else if (CONFIG_SVQ3_DECODER) {
for (i = 0; i < 16; i++)
if (h->non_zero_count_cache[scan8[i + p * 16]] || h->mb[i * 16 + p * 256]) {
uint8_t *const ptr = dest_y + block_offset[i];
ff_svq3_add_idct_c(ptr, h->mb + i * 16 + p * 256, linesize,
h->qscale, IS_INTRA(mb_type) ? 1 : 0);
}
}
}
}
| 1threat
|
How to use Thymeleaf th:text in reactJS : <p>I am running a springboot application with Thymeleaf and reactJS. All the HTML text are read from message.properties by using th:text in the pages, but when I have th:text in reactJS HTML block, reactJS seems angry about it. </p>
<pre><code>render() {
return (
<input type="text" th:text="#{home.welcome}">
)
}
</code></pre>
<p>The error is:</p>
<pre><code>Namespace tags are not supported. ReactJSX is not XML.
</code></pre>
<p>Is there a walkaround besides using dangerouslySetInnerHTML?</p>
<p>Thank you!</p>
| 0debug
|
Modify state in Redux DevTools Extension : <p>In my application state there are values set as initialState.</p>
<p>With the <a href="https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en" rel="noreferrer">React Developer Tools</a> it's very easy to directly modify some state value.</p>
<p>Is anything similar possible in <a href="https://chrome.google.com/webstore/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd?hl=en" rel="noreferrer">Redux DevTools Extension</a>, i.e. click and insert a new value for a specific property?</p>
<p>In <a href="https://stackoverflow.com/a/42344692/1417223">this</a> SO anwer it's stated that it's possible to "change whatever you want", but I cannot find how.</p>
<p>In the State -> Raw pane (see pic below) one can overwrite values but it doesn't seem to be applied.</p>
<p><a href="https://i.stack.imgur.com/XRrvA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/XRrvA.png" alt="enter image description here"></a></p>
| 0debug
|
How can I write unit tests for private clojure functions? : <p>I would like to write unit tests for functions defined as private using defn-. How can I do this?</p>
| 0debug
|
PERL - Switch output to Variable (String) : I started to programming with Perl and have a problem to put the Output from a Switch (Cisco) in a variable.
Example:
I want to send the Command show version to the Switch ($easy->send_command("show version");
and then put the Response from switch in a String (not in a other File)
After then i will search in the string to compare versions (i declare at begin a string (this ist the other variable for comparing) for Example $version = "bootflash:cat4500-ipbasek9-mz.122-50.SG2.bin";)
At the moment i don't now how i can put the Output from the Switch in a String after i send the command Show version to them.
Can anyone help me?
| 0debug
|
static void interface_get_init_info(QXLInstance *sin, QXLDevInitInfo *info)
{
SimpleSpiceDisplay *ssd = container_of(sin, SimpleSpiceDisplay, qxl);
info->memslot_gen_bits = MEMSLOT_GENERATION_BITS;
info->memslot_id_bits = MEMSLOT_SLOT_BITS;
info->num_memslots = NUM_MEMSLOTS;
info->num_memslots_groups = NUM_MEMSLOTS_GROUPS;
info->internal_groupslot_id = 0;
info->qxl_ram_size = ssd->bufsize;
info->n_surfaces = ssd->num_surfaces;
}
| 1threat
|
int cpu_ppc_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
int is_user, int is_softmmu)
{
mmu_ctx_t ctx;
int exception = 0, error_code = 0;
int access_type;
int ret = 0;
if (rw == 2) {
rw = 0;
access_type = ACCESS_CODE;
} else {
access_type = ACCESS_INT;
}
ret = get_physical_address(env, &ctx, address, rw, access_type, 1);
if (ret == 0) {
ret = tlb_set_page(env, address & TARGET_PAGE_MASK,
ctx.raddr & TARGET_PAGE_MASK, ctx.prot,
is_user, is_softmmu);
} else if (ret < 0) {
#if defined (DEBUG_MMU)
if (loglevel != 0)
cpu_dump_state(env, logfile, fprintf, 0);
#endif
if (access_type == ACCESS_CODE) {
exception = EXCP_ISI;
switch (ret) {
case -1:
switch (env->mmu_model) {
case POWERPC_MMU_SOFT_6xx:
exception = EXCP_I_TLBMISS;
env->spr[SPR_IMISS] = address;
env->spr[SPR_ICMP] = 0x80000000 | ctx.ptem;
error_code = 1 << 18;
goto tlb_miss;
case POWERPC_MMU_SOFT_4xx:
case POWERPC_MMU_SOFT_4xx_Z:
exception = EXCP_40x_ITLBMISS;
error_code = 0;
env->spr[SPR_40x_DEAR] = address;
env->spr[SPR_40x_ESR] = 0x00000000;
break;
case POWERPC_MMU_32B:
error_code = 0x40000000;
break;
#if defined(TARGET_PPC64)
case POWERPC_MMU_64B:
cpu_abort(env, "MMU model not implemented\n");
return -1;
case POWERPC_MMU_64BRIDGE:
cpu_abort(env, "MMU model not implemented\n");
return -1;
#endif
case POWERPC_MMU_601:
cpu_abort(env, "MMU model not implemented\n");
return -1;
case POWERPC_MMU_BOOKE:
cpu_abort(env, "MMU model not implemented\n");
return -1;
case POWERPC_MMU_BOOKE_FSL:
cpu_abort(env, "MMU model not implemented\n");
return -1;
case POWERPC_MMU_REAL_4xx:
cpu_abort(env, "PowerPC 401 should never raise any MMU "
"exceptions\n");
return -1;
default:
cpu_abort(env, "Unknown or invalid MMU model\n");
return -1;
}
break;
case -2:
error_code = 0x08000000;
break;
case -3:
error_code = 0x10000000;
break;
case -4:
error_code = 0x10000000;
break;
case -5:
exception = EXCP_ISEG;
error_code = 0;
break;
}
} else {
exception = EXCP_DSI;
switch (ret) {
case -1:
switch (env->mmu_model) {
case POWERPC_MMU_SOFT_6xx:
if (rw == 1) {
exception = EXCP_DS_TLBMISS;
error_code = 1 << 16;
} else {
exception = EXCP_DL_TLBMISS;
error_code = 0;
}
env->spr[SPR_DMISS] = address;
env->spr[SPR_DCMP] = 0x80000000 | ctx.ptem;
tlb_miss:
error_code |= ctx.key << 19;
env->spr[SPR_HASH1] = ctx.pg_addr[0];
env->spr[SPR_HASH2] = ctx.pg_addr[1];
goto out;
case POWERPC_MMU_SOFT_4xx:
case POWERPC_MMU_SOFT_4xx_Z:
exception = EXCP_40x_DTLBMISS;
error_code = 0;
env->spr[SPR_40x_DEAR] = address;
if (rw)
env->spr[SPR_40x_ESR] = 0x00800000;
else
env->spr[SPR_40x_ESR] = 0x00000000;
break;
case POWERPC_MMU_32B:
error_code = 0x40000000;
break;
#if defined(TARGET_PPC64)
case POWERPC_MMU_64B:
cpu_abort(env, "MMU model not implemented\n");
return -1;
case POWERPC_MMU_64BRIDGE:
cpu_abort(env, "MMU model not implemented\n");
return -1;
#endif
case POWERPC_MMU_601:
cpu_abort(env, "MMU model not implemented\n");
return -1;
case POWERPC_MMU_BOOKE:
cpu_abort(env, "MMU model not implemented\n");
return -1;
case POWERPC_MMU_BOOKE_FSL:
cpu_abort(env, "MMU model not implemented\n");
return -1;
case POWERPC_MMU_REAL_4xx:
cpu_abort(env, "PowerPC 401 should never raise any MMU "
"exceptions\n");
return -1;
default:
cpu_abort(env, "Unknown or invalid MMU model\n");
return -1;
}
break;
case -2:
error_code = 0x08000000;
break;
case -4:
switch (access_type) {
case ACCESS_FLOAT:
exception = EXCP_ALIGN;
error_code = EXCP_ALIGN_FP;
break;
case ACCESS_RES:
error_code = 0x04000000;
break;
case ACCESS_EXT:
error_code = 0x04100000;
break;
default:
printf("DSI: invalid exception (%d)\n", ret);
exception = EXCP_PROGRAM;
error_code = EXCP_INVAL | EXCP_INVAL_INVAL;
break;
}
break;
case -5:
exception = EXCP_DSEG;
error_code = 0;
break;
}
if (exception == EXCP_DSI && rw == 1)
error_code |= 0x02000000;
env->spr[SPR_DAR] = address;
env->spr[SPR_DSISR] = error_code;
}
out:
#if 0
printf("%s: set exception to %d %02x\n",
__func__, exception, error_code);
#endif
env->exception_index = exception;
env->error_code = error_code;
ret = 1;
}
return ret;
}
| 1threat
|
How can I block hidden buton on HTML : I am worknig on a html which already works integrated on a application. On this html there was 3 buttons and I add new one. This 3 button showen together when you click anyone on screen but new one do not seem. How can its possible. How can I solve this problem.
[Fourth button added. ][1] (When you on navigation page all buttons are seem.)
[When You click Second button][2] (When you slick search button, last button do not seem)
[When you click Third button][3] (Same problem valid too when click view button)
For this html there was a ready html and I add new button on it.
<div id="tabcontainer">
<div id="tabs" class="nav">
<span><a id="navtab" href="#" class="btn-highlight">Navigation</a></span>
<span><a id="searchtab" href="/solr/select" class="btn">Search</a></span>
<span><a id="viewtab" href="#" class="btn">View</a></span>
<span><a id="180DayDocumentstab" href="#" class="btn">180 Day Documents</a></span></span>
<div class="outer-container"><div class="container">
<div id="navigationContainer"><div class="navSection">
<div class="outer-container"><div class="container">
<div class="header navigationPMTitle"><span class="crumb" id="crumb">
[2]: https://i.stack.imgur.com/mVb9j.jpg
[3]: https://i.stack.imgur.com/94Oz5.jpg
| 0debug
|
c programming looping with rows and columns : I am trying to make a programme that gets `3 inputs` from the user. row/columns count and numbers range.
In my case and for example lets say `4 1 16` so it means `4 rows and columns` print `numbers from` `1-16`.
I have a problem accomplishing something.
#include <stdio.h>
#include <stdlib.h>
int num1,num2,count,i,y;
int main()
{
count = 4;
num1 = 1;
num2 = 16;
for(i=1; i<=count; i++){
for(y=1; y<=count; y++){
printf("%d ",y);
}
printf("\n");
}
return 0;
}
The output is
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
Whereas I want my output to be:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
| 0debug
|
What does this line in javascript in html mean? : <p>What does this line in javascript mean? Its located in an html file</p>
<pre><code><script src="js/main.js"></script>
</code></pre>
| 0debug
|
Angular Should I use the vendorChunk in production : <p>I am using Angular6 and I was wondering if it was better to set <code>"vendorChunk"</code> to <code>true</code> or <code>false</code> in production. I know what it does, but I am not sure of the best value to use in production.</p>
| 0debug
|
query = 'SELECT * FROM customers WHERE email = ' + email_input
| 1threat
|
Comparing two dataframe from history checking in Apache Saprk using scala : I have adataframe with following structure
EmployeeDF
id name date code
1 John 2015-4-14 C11
2 Roy 2011-5-20 C11
3 John 2010-5-20 C11
4 John 2012-5-20 C10
No i want to check history that if same code is apply to same employee two year ago. How can i do that. It is only sample data i have million of data in the dataframe and i want to achieve performance. Joining the dataframe slow down the performance because row are repeated so i make Cartesian and duplicate the rows during self join. I want to achieve with something like map.
| 0debug
|
Xcode 11 PDF image assets "Preserve Vector Data" not working in SwiftUI? : <p>I'm trying to use vector-based PDF images using "Single-Scale" in an app I'm working on using SwiftUI in Xcode 11, but the image always looks blurry when I scale it up in size. </p>
<p>I had no trouble with this in UIKit in Xcode 11. I created a dummy app with 2 scenes, both displaying the same vector image. I created the first scene in a storyboard, then used a HostingViewController to embed an identical scene made in SwiftUI. When I ran the app, the first scene (UIKit) displayed a crisp, non blurry image. The second (SwiftUI) scene however, was blurry and didn't appear to be using vector data, despite using the same source image asset.</p>
<p>I was able to "work around" this by creating a UIImage with the vector image, then using this UIImage extension to resize the UIImage before it's passed into <code>Image</code>. However, the size I enter in the <code>resized(to:)</code> method makes no difference at runtime, so I also have to add <code>.frame(w:,h:)</code> to <code>image</code> in 'var body' to make it show the correct size.</p>
<pre><code>let uiImage = UIImage(named: "Logo-vector")!
var image: Image {
Image(uiImage: uiImage.resized(to: CGSize(width: 500, height: 500)))
.resizable()
}
var body: some View {
NavigationView {
VStack(alignment: .center, spacing: 8) {
Spacer()
Text("Logo vector SwiftUI")
image
.frame(width: 240, height: 216)
...
}
...
}
}
}
extension UIImage {
func resized(to size: CGSize) -> UIImage {
return UIGraphicsImageRenderer(size: size).image { _ in
draw(in: CGRect(origin: .zero, size: size))
}
}
}
</code></pre>
<p>The image is clear and properly resized at runtime with this workaround, but it feels like a bit of a hack.</p>
<p>I've looked everywhere online for a different solution or anyone else having this issue specifically with SwiftUI, but haven't found anything at all.</p>
<p>Has anyone else had this issue or does anyone have a better solution?</p>
| 0debug
|
bool cpu_exec_all(void)
{
int ret = 0;
if (next_cpu == NULL)
next_cpu = first_cpu;
for (; next_cpu != NULL && !exit_request; next_cpu = next_cpu->next_cpu) {
CPUState *env = next_cpu;
qemu_clock_enable(vm_clock,
(env->singlestep_enabled & SSTEP_NOTIMER) == 0);
if (qemu_alarm_pending())
break;
if (cpu_can_run(env))
ret = qemu_cpu_exec(env);
else if (env->stop)
break;
if (ret == EXCP_DEBUG) {
gdb_set_stop_cpu(env);
debug_requested = EXCP_DEBUG;
break;
}
}
exit_request = 0;
return any_cpu_has_work();
}
| 1threat
|
How To get url parameter from url in jquery? : <p>I want to get parameter from url.
Following is my url.
I wnt to get "uid" parameter from my url.</p>
<pre><code>http://localhost:8080/mydemoproject/#/tables/view?uid=71
</code></pre>
| 0debug
|
Stopping a CSS fade animation slideshow on last frame : <p>I'm working on a CSS animation fade effect for a background image. The animation proceed normally but is coming back to the first frame. Is there a way to stop it after the last frame?</p>
<pre><code> **
#slideshow {
list-style: none;
margin: 0;
padding: 0;
position: relative;
width:100%;
height:100%;
display: inline-block;
}
.elemnt,.elemnt1,.elemnt2,.elemnt3 {
position: absolute;
left: 0;
width: 100%;
background-repeat: no-repeat;
background-size: cover;
height: 100%;
display: inline-block;
text-align: center;
}
.elemnt {
animation: xfade 50s 4s ;
background-image: url('flip_data/2w.png');
}
.elemnt1 {
animation: xfade 50s 3s;
background-image: url('flip_data/2f2.png');
}
.elemnt2 {
animation: xfade 50s 2s;
background-image: url('flip_data/2f1.png');
}
.elemnt3 {
animation: xfade 50s 0s;
animation-fill-mode: forwards;
background-image: url('flip_data/page_finale_web_flip.png');**
</code></pre>
| 0debug
|
Decision tree learning: Basic idea : <p>As given in the textbook <strong>Machine Learning</strong> by <em>Tom M. Mitchell</em>, the first statement about decision tree states that, "Decision tree leaning is a method for approximating discrete valued functions". Could someone kindly elaborate this statement, probably even justify it with an example. Thanks in advance :) :) </p>
| 0debug
|
How to search and get result from database using php : <p>I have 2 tables in the same database:
Table1: with follow a field named "mark_allow"</p>
<p>Table2: with the following fields: "header", "title", "comments"</p>
<p>How can I use the result of what I get "mark_allow" in Table 1 and search for the corresponding content of "comments" in Table 2 using php?</p>
<p>Regards,</p>
| 0debug
|
static int mov_write_tmcd_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = avio_tell(pb);
#if 1
int frame_duration = av_rescale(track->timescale, track->enc->time_base.num, track->enc->time_base.den);
int nb_frames = ROUNDED_DIV(track->enc->time_base.den, track->enc->time_base.num);
AVDictionaryEntry *t = NULL;
if (nb_frames > 255) {
av_log(NULL, AV_LOG_ERROR, "fps %d is too large\n", nb_frames);
return AVERROR(EINVAL);
}
avio_wb32(pb, 0);
ffio_wfourcc(pb, "tmcd");
avio_wb32(pb, 0);
avio_wb32(pb, 1);
avio_wb32(pb, 0);
avio_wb32(pb, track->timecode_flags);
avio_wb32(pb, track->timescale);
avio_wb32(pb, frame_duration);
avio_w8(pb, nb_frames);
avio_w8(pb, 0);
if (track->st)
t = av_dict_get(track->st->metadata, "reel_name", NULL, 0);
if (t && utf8len(t->value))
mov_write_source_reference_tag(pb, track, t->value);
else
avio_wb16(pb, 0);
#else
avio_wb32(pb, 0);
ffio_wfourcc(pb, "tmcd");
avio_wb32(pb, 0);
avio_wb32(pb, 1);
if (track->enc->extradata_size)
avio_write(pb, track->enc->extradata, track->enc->extradata_size);
#endif
return update_size(pb, pos);
}
| 1threat
|
Date to Day conversion R : <p>Im trying to convert a Date column in a csv file to a new column <code>Day</code> using R. Day in terms of Monday Tuesday etc. Apparently yday gives day of the year. Any solution?</p>
| 0debug
|
static int qcow2_set_key(BlockDriverState *bs, const char *key)
{
BDRVQcow2State *s = bs->opaque;
uint8_t keybuf[16];
int len, i;
Error *err = NULL;
memset(keybuf, 0, 16);
len = strlen(key);
if (len > 16)
len = 16;
for(i = 0;i < len;i++) {
keybuf[i] = key[i];
}
assert(bs->encrypted);
qcrypto_cipher_free(s->cipher);
s->cipher = qcrypto_cipher_new(
QCRYPTO_CIPHER_ALG_AES_128,
QCRYPTO_CIPHER_MODE_CBC,
keybuf, G_N_ELEMENTS(keybuf),
&err);
if (!s->cipher) {
error_free(err);
return -1;
}
return 0;
}
| 1threat
|
How to adjust branch lengths of dendrogram in matplotlib (like in astrodendro)? [Python] : <p>Here is my resulting plot below but I would like it to look like the truncated dendrograms in <code>astrodendro</code> such as <a href="https://media.readthedocs.org/pdf/dendrograms/latest/dendrograms.pdf" rel="noreferrer">this</a>:</p>
<p><a href="https://i.stack.imgur.com/cPEIc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cPEIc.png" alt="enter image description here"></a></p>
<p>There is also a really cool looking dendrogram from <a href="https://elifesciences.org/articles/21887" rel="noreferrer">this paper</a> that I would like to recreate in <code>matplotlib</code>.</p>
<p><a href="https://i.stack.imgur.com/98brn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/98brn.png" alt="enter image description here"></a></p>
<p>Below is the code for generating an <code>iris</code> data set with noise variables and plotting the dendrogram in <code>matplotlib</code>.</p>
<p><strong>Does anyone know how to either: (1) truncate the branches like in the example figures; and/or (2) to use <code>astrodendro</code> with a custom linkage matrix and labels?</strong> </p>
<pre><code>import pandas as pd
import numpy as np
from sklearn.datasets import load_iris
import astrodendro
from scipy.cluster.hierarchy import dendrogram, linkage
from scipy.spatial import distance
def iris_data(noise=None, palette="hls", desat=1):
# Iris dataset
X = pd.DataFrame(load_iris().data,
index = [*map(lambda x:f"iris_{x}", range(150))],
columns = [*map(lambda x: x.split(" (cm)")[0].replace(" ","_"), load_iris().feature_names)])
y = pd.Series(load_iris().target,
index = X.index,
name = "Species")
c = map_colors(y, mode=1, palette=palette, desat=desat)#y.map(lambda x:{0:"red",1:"green",2:"blue"}[x])
if noise is not None:
X_noise = pd.DataFrame(
np.random.RandomState(0).normal(size=(X.shape[0], noise)),
index=X_iris.index,
columns=[*map(lambda x:f"noise_{x}", range(noise))]
)
X = pd.concat([X, X_noise], axis=1)
return (X, y, c)
def dism2linkage(DF_dism, method="ward"):
"""
Input: A (m x m) dissimalrity Pandas DataFrame object where the diagonal is 0
Output: Hierarchical clustering encoded as a linkage matrix
Further reading:
http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.cluster.hierarchy.linkage.html
https://pypi.python.org/pypi/fastcluster
"""
#Linkage Matrix
Ar_dist = distance.squareform(DF_dism.as_matrix())
return linkage(Ar_dist,method=method)
# Get data
X_iris_with_noise, y_iris, c_iris = iris_data(50)
# Get distance matrix
df_dism = 1- X_iris_with_noise.corr().abs()
# Get linkage matrix
Z = dism2linkage(df_dism)
#Create dendrogram
with plt.style.context("seaborn-white"):
fig, ax = plt.subplots(figsize=(13,3))
D_dendro = dendrogram(
Z,
labels=df_dism.index,
color_threshold=3.5,
count_sort = "ascending",
#link_color_func=lambda k: colors[k]
ax=ax
)
ax.set_ylabel("Distance")
</code></pre>
<p><a href="https://i.stack.imgur.com/BjvVo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BjvVo.png" alt="enter image description here"></a></p>
| 0debug
|
int av_get_cpu_flags(void)
{
int flags = cpu_flags;
if (flags == -1) {
flags = get_cpu_flags();
cpu_flags = flags;
}
return flags;
}
| 1threat
|
static void amdvi_iommu_notify_flag_changed(MemoryRegion *iommu,
IOMMUNotifierFlag old,
IOMMUNotifierFlag new)
{
AMDVIAddressSpace *as = container_of(iommu, AMDVIAddressSpace, iommu);
hw_error("device %02x.%02x.%x requires iommu notifier which is not "
"currently supported", as->bus_num, PCI_SLOT(as->devfn),
PCI_FUNC(as->devfn));
}
| 1threat
|
static void FUNCC(pred8x8l_horizontal_add)(uint8_t *_pix, const int16_t *_block,
ptrdiff_t stride)
{
int i;
pixel *pix = (pixel*)_pix;
const dctcoef *block = (const dctcoef*)_block;
stride >>= sizeof(pixel)-1;
for(i=0; i<8; i++){
pixel v = pix[-1];
pix[0]= v += block[0];
pix[1]= v += block[1];
pix[2]= v += block[2];
pix[3]= v += block[3];
pix[4]= v += block[4];
pix[5]= v += block[5];
pix[6]= v += block[6];
pix[7]= v + block[7];
pix+= stride;
block+= 8;
}
}
| 1threat
|
Can you explain an Azure subscription? : <p>New to Azure. I just don't understand what is an Azure subscription.</p>
| 0debug
|
Is there anyway I can check which R objects takes too much memory? : <p>Now I am using R to integrate different stock information(like RCurl for Web info and quantmod for financial report and trade info)</p>
<p>After I get data I put them in MySQL database.</p>
<p>The program works find BUT after loop some time the R session consumes too much memory(some 1000 stocks takes 4GB memory)</p>
<p>Is there anyway in R I can check which objects takes the most memory? Or is there any tools I can check the possible memory leak problem? Thanks! </p>
| 0debug
|
static void gen_mfdcrx(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
return;
}
gen_update_nip(ctx, ctx->nip - 4);
gen_helper_load_dcr(cpu_gpr[rD(ctx->opcode)], cpu_env,
cpu_gpr[rA(ctx->opcode)]);
#endif
}
| 1threat
|
Is there a way to pass a variable after 5 seconds? : <p>I'm creating a desktop app with Swift and I need to pass a <code>stop</code> boolean after 5 seconds. How do I do this?</p>
| 0debug
|
static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
TCGArg *args, TCGOpDef *tcg_op_defs)
{
int i, nb_ops, op_index, nb_temps, nb_globals, nb_call_args;
TCGOpcode op;
const TCGOpDef *def;
TCGArg *gen_args;
TCGArg tmp;
nb_temps = s->nb_temps;
nb_globals = s->nb_globals;
memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info));
nb_ops = tcg_opc_ptr - gen_opc_buf;
gen_args = args;
for (op_index = 0; op_index < nb_ops; op_index++) {
op = gen_opc_buf[op_index];
def = &tcg_op_defs[op];
if (!(def->flags & (TCG_OPF_CALL_CLOBBER | TCG_OPF_SIDE_EFFECTS))) {
assert(op != INDEX_op_call);
for (i = def->nb_oargs; i < def->nb_oargs + def->nb_iargs; i++) {
if (temps[args[i]].state == TCG_TEMP_COPY) {
args[i] = temps[args[i]].val;
}
}
}
switch (op) {
CASE_OP_32_64(add):
CASE_OP_32_64(mul):
CASE_OP_32_64(and):
CASE_OP_32_64(or):
CASE_OP_32_64(xor):
CASE_OP_32_64(eqv):
CASE_OP_32_64(nand):
CASE_OP_32_64(nor):
if (temps[args[1]].state == TCG_TEMP_CONST) {
tmp = args[1];
args[1] = args[2];
args[2] = tmp;
}
break;
CASE_OP_32_64(brcond):
if (temps[args[0]].state == TCG_TEMP_CONST
&& temps[args[1]].state != TCG_TEMP_CONST) {
tmp = args[0];
args[0] = args[1];
args[1] = tmp;
args[2] = tcg_swap_cond(args[2]);
}
break;
CASE_OP_32_64(setcond):
if (temps[args[1]].state == TCG_TEMP_CONST
&& temps[args[2]].state != TCG_TEMP_CONST) {
tmp = args[1];
args[1] = args[2];
args[2] = tmp;
args[3] = tcg_swap_cond(args[3]);
}
break;
default:
break;
}
switch (op) {
CASE_OP_32_64(shl):
CASE_OP_32_64(shr):
CASE_OP_32_64(sar):
CASE_OP_32_64(rotl):
CASE_OP_32_64(rotr):
if (temps[args[1]].state == TCG_TEMP_CONST
&& temps[args[1]].val == 0) {
gen_opc_buf[op_index] = op_to_movi(op);
tcg_opt_gen_movi(gen_args, args[0], 0, nb_temps, nb_globals);
args += 3;
gen_args += 2;
continue;
}
break;
default:
break;
}
switch (op) {
CASE_OP_32_64(add):
CASE_OP_32_64(sub):
CASE_OP_32_64(shl):
CASE_OP_32_64(shr):
CASE_OP_32_64(sar):
CASE_OP_32_64(rotl):
CASE_OP_32_64(rotr):
CASE_OP_32_64(or):
CASE_OP_32_64(xor):
if (temps[args[1]].state == TCG_TEMP_CONST) {
break;
}
if (temps[args[2]].state == TCG_TEMP_CONST
&& temps[args[2]].val == 0) {
if ((temps[args[0]].state == TCG_TEMP_COPY
&& temps[args[0]].val == args[1])
|| args[0] == args[1]) {
gen_opc_buf[op_index] = INDEX_op_nop;
} else {
gen_opc_buf[op_index] = op_to_mov(op);
tcg_opt_gen_mov(gen_args, args[0], args[1],
nb_temps, nb_globals);
gen_args += 2;
}
args += 3;
continue;
}
break;
default:
break;
}
switch (op) {
CASE_OP_32_64(and):
CASE_OP_32_64(mul):
if ((temps[args[2]].state == TCG_TEMP_CONST
&& temps[args[2]].val == 0)) {
gen_opc_buf[op_index] = op_to_movi(op);
tcg_opt_gen_movi(gen_args, args[0], 0, nb_temps, nb_globals);
args += 3;
gen_args += 2;
continue;
}
break;
default:
break;
}
switch (op) {
CASE_OP_32_64(or):
CASE_OP_32_64(and):
if (args[1] == args[2]) {
if (args[1] == args[0]) {
gen_opc_buf[op_index] = INDEX_op_nop;
} else {
gen_opc_buf[op_index] = op_to_mov(op);
tcg_opt_gen_mov(gen_args, args[0], args[1], nb_temps,
nb_globals);
gen_args += 2;
}
args += 3;
continue;
}
break;
default:
break;
}
switch (op) {
CASE_OP_32_64(mov):
if ((temps[args[1]].state == TCG_TEMP_COPY
&& temps[args[1]].val == args[0])
|| args[0] == args[1]) {
args += 2;
gen_opc_buf[op_index] = INDEX_op_nop;
break;
}
if (temps[args[1]].state != TCG_TEMP_CONST) {
tcg_opt_gen_mov(gen_args, args[0], args[1],
nb_temps, nb_globals);
gen_args += 2;
args += 2;
break;
}
op = op_to_movi(op);
gen_opc_buf[op_index] = op;
args[1] = temps[args[1]].val;
CASE_OP_32_64(movi):
tcg_opt_gen_movi(gen_args, args[0], args[1], nb_temps, nb_globals);
gen_args += 2;
args += 2;
break;
CASE_OP_32_64(not):
CASE_OP_32_64(neg):
CASE_OP_32_64(ext8s):
CASE_OP_32_64(ext8u):
CASE_OP_32_64(ext16s):
CASE_OP_32_64(ext16u):
case INDEX_op_ext32s_i64:
case INDEX_op_ext32u_i64:
if (temps[args[1]].state == TCG_TEMP_CONST) {
gen_opc_buf[op_index] = op_to_movi(op);
tmp = do_constant_folding(op, temps[args[1]].val, 0);
tcg_opt_gen_movi(gen_args, args[0], tmp, nb_temps, nb_globals);
} else {
reset_temp(args[0], nb_temps, nb_globals);
gen_args[0] = args[0];
gen_args[1] = args[1];
}
gen_args += 2;
args += 2;
break;
CASE_OP_32_64(add):
CASE_OP_32_64(sub):
CASE_OP_32_64(mul):
CASE_OP_32_64(or):
CASE_OP_32_64(and):
CASE_OP_32_64(xor):
CASE_OP_32_64(shl):
CASE_OP_32_64(shr):
CASE_OP_32_64(sar):
CASE_OP_32_64(rotl):
CASE_OP_32_64(rotr):
CASE_OP_32_64(andc):
CASE_OP_32_64(orc):
CASE_OP_32_64(eqv):
CASE_OP_32_64(nand):
CASE_OP_32_64(nor):
if (temps[args[1]].state == TCG_TEMP_CONST
&& temps[args[2]].state == TCG_TEMP_CONST) {
gen_opc_buf[op_index] = op_to_movi(op);
tmp = do_constant_folding(op, temps[args[1]].val,
temps[args[2]].val);
tcg_opt_gen_movi(gen_args, args[0], tmp, nb_temps, nb_globals);
gen_args += 2;
} else {
reset_temp(args[0], nb_temps, nb_globals);
gen_args[0] = args[0];
gen_args[1] = args[1];
gen_args[2] = args[2];
gen_args += 3;
}
args += 3;
break;
CASE_OP_32_64(setcond):
if (temps[args[1]].state == TCG_TEMP_CONST
&& temps[args[2]].state == TCG_TEMP_CONST) {
gen_opc_buf[op_index] = op_to_movi(op);
tmp = do_constant_folding_cond(op, temps[args[1]].val,
temps[args[2]].val, args[3]);
tcg_opt_gen_movi(gen_args, args[0], tmp, nb_temps, nb_globals);
gen_args += 2;
} else {
reset_temp(args[0], nb_temps, nb_globals);
gen_args[0] = args[0];
gen_args[1] = args[1];
gen_args[2] = args[2];
gen_args[3] = args[3];
gen_args += 4;
}
args += 4;
break;
CASE_OP_32_64(brcond):
if (temps[args[0]].state == TCG_TEMP_CONST
&& temps[args[1]].state == TCG_TEMP_CONST) {
if (do_constant_folding_cond(op, temps[args[0]].val,
temps[args[1]].val, args[2])) {
memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info));
gen_opc_buf[op_index] = INDEX_op_br;
gen_args[0] = args[3];
gen_args += 1;
} else {
gen_opc_buf[op_index] = INDEX_op_nop;
}
} else {
memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info));
reset_temp(args[0], nb_temps, nb_globals);
gen_args[0] = args[0];
gen_args[1] = args[1];
gen_args[2] = args[2];
gen_args[3] = args[3];
gen_args += 4;
}
args += 4;
break;
case INDEX_op_call:
nb_call_args = (args[0] >> 16) + (args[0] & 0xffff);
if (!(args[nb_call_args + 1] & (TCG_CALL_CONST | TCG_CALL_PURE))) {
for (i = 0; i < nb_globals; i++) {
reset_temp(i, nb_temps, nb_globals);
}
}
for (i = 0; i < (args[0] >> 16); i++) {
reset_temp(args[i + 1], nb_temps, nb_globals);
}
i = nb_call_args + 3;
while (i) {
*gen_args = *args;
args++;
gen_args++;
i--;
}
break;
case INDEX_op_set_label:
case INDEX_op_jmp:
case INDEX_op_br:
memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info));
for (i = 0; i < def->nb_args; i++) {
*gen_args = *args;
args++;
gen_args++;
}
break;
default:
for (i = 0; i < def->nb_oargs; i++) {
reset_temp(args[i], nb_temps, nb_globals);
}
for (i = 0; i < def->nb_args; i++) {
gen_args[i] = args[i];
}
args += def->nb_args;
gen_args += def->nb_args;
break;
}
}
return gen_args;
}
| 1threat
|
static int rtc_load(QEMUFile *f, void *opaque, int version_id)
{
RTCState *s = opaque;
if (version_id != 1)
return -EINVAL;
qemu_get_buffer(f, s->cmos_data, 128);
qemu_get_8s(f, &s->cmos_index);
s->current_tm.tm_sec=qemu_get_be32(f);
s->current_tm.tm_min=qemu_get_be32(f);
s->current_tm.tm_hour=qemu_get_be32(f);
s->current_tm.tm_wday=qemu_get_be32(f);
s->current_tm.tm_mday=qemu_get_be32(f);
s->current_tm.tm_mon=qemu_get_be32(f);
s->current_tm.tm_year=qemu_get_be32(f);
qemu_get_timer(f, s->periodic_timer);
s->next_periodic_time=qemu_get_be64(f);
s->next_second_time=qemu_get_be64(f);
qemu_get_timer(f, s->second_timer);
qemu_get_timer(f, s->second_timer2);
return 0;
}
| 1threat
|
My Java regular expression can't find a simple string literal but String.indexOf indicates it's present : <p>I have some SQL that starts as follows: </p>
<pre><code>String sql = "SELECT "+
" SI.SITE_ID "; ....
</code></pre>
<p><em>Eventually</em> I want to write a regular expression which, based on the literal string (column name) "SITE_ID", will find the <em>fully qualified</em> column name (with the "SI." on front). After writing what I thought would work for that purpose (<code>Pattern.compile("\\s+\\w+\\." + "SITE_ID" + "\\s+")</code> and then, eventually, extract a capture) but it not returning the result I expected, I decided to simplify.</p>
<p>Now though even though I have simplified as much as I can possibly think to do, simply to search for the string literal "SITE_ID" in the <code>sql</code> variable, it still returns false, but <code>sql.indexOf()</code> returns a value greater than -1, so <code>sql</code> <em>does</em> contain the string:</p>
<pre><code>boolean foundSiteId = Pattern.compile("SITE_ID").matcher(sql).matches(); // false
int siteIdPos = sql.indexOf("SITE_ID"); // 12
</code></pre>
<p>I find this surprising; it's not as though I'm trying to anchor "SITE_ID" to the front with <code>^</code> or the end with <code>$</code>. Additionally I have gone out to <a href="https://www.freeformatter.com/java-regex-tester.html" rel="nofollow noreferrer">https://www.freeformatter.com/java-regex-tester.html</a> (because re-compiling code over and over is time consuming) to try, and if I enter both "SITE_ID" (without the quotes) as the "Java Regular Expression" and "Entry to test against" it does return true. However if I provide " SITE_ID " with a leading and trailing space to test against, it returns true.</p>
<p>I guess I must just have some fundamental mis-understanding of Java regular expressions, though I am reasonably versed in them from other languages. What am I doing wrong, thanks.</p>
| 0debug
|
void sh4_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
{
int i;
for (i = 0; i < ARRAY_SIZE(sh4_defs); i++)
(*cpu_fprintf)(f, "%s\n", sh4_defs[i].name);
}
| 1threat
|
PHP contact form white screen : <p>my php contact form works and sends me an email when people fill it out. what is happinging though is when they click submit, the screen goes white and nothing happens. I want the page to refresh or redirect to another page. How Can I get it to refresh?</p>
<p>here is my PHP:</p>
<pre><code><?php
// define variables and set to empty values
$name_error = $email_error = "";
$name = $email = $message = $success = "";
//form is submitted with POST method
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"])) {
$name_error = "Name is required";
} else {
$name = test_input($_POST["name"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
$name_error = "Only letters and white space allowed";
}
}
if (empty($_POST["email"])) {
$email_error = "Email is required";
} else {
$email = test_input($_POST["email"]);
// check if e-mail address is well-formed
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$email_error = "Invalid email format";
}
}
if (empty($_POST["message"])) {
$message = "";
} else {
$message = test_input($_POST["message"]);
}
if ($name_error == '' and $email_error == '' ){
$message_body = '';
unset($_POST['submit']);
foreach ($_POST as $key => $value){
$message_body .= "$key: $value\n";
}
$to = 'whitandr@oregonstate.edu';
$subject = 'Contact Form Submit';
if (mail($to, $subject, $message_body)){
$success = "Message sent, thank you!";
$name = $email = $message = '';
}
}
</code></pre>
<p>}</p>
<pre><code>function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
</code></pre>
<p>}</p>
| 0debug
|
static void build_fadt(GArray *table_data, BIOSLinker *linker,
VirtMachineState *vms, unsigned dsdt_tbl_offset)
{
AcpiFadtDescriptorRev5_1 *fadt = acpi_data_push(table_data, sizeof(*fadt));
unsigned dsdt_entry_offset = (char *)&fadt->dsdt - table_data->data;
uint16_t bootflags;
switch (vms->psci_conduit) {
case QEMU_PSCI_CONDUIT_DISABLED:
bootflags = 0;
break;
case QEMU_PSCI_CONDUIT_HVC:
bootflags = ACPI_FADT_ARM_PSCI_COMPLIANT | ACPI_FADT_ARM_PSCI_USE_HVC;
break;
case QEMU_PSCI_CONDUIT_SMC:
bootflags = ACPI_FADT_ARM_PSCI_COMPLIANT;
break;
default:
g_assert_not_reached();
}
fadt->flags = cpu_to_le32(1 << ACPI_FADT_F_HW_REDUCED_ACPI);
fadt->arm_boot_flags = cpu_to_le16(bootflags);
fadt->minor_revision = 0x1;
bios_linker_loader_add_pointer(linker,
ACPI_BUILD_TABLE_FILE, dsdt_entry_offset, sizeof(fadt->dsdt),
ACPI_BUILD_TABLE_FILE, dsdt_tbl_offset);
build_header(linker, table_data,
(void *)fadt, "FACP", sizeof(*fadt), 5, NULL, NULL);
}
| 1threat
|
WebSocket SyntaxError: An invalid or illegal string was specified : <p>I'm getting a <code>SyntaxError: An invalid or illegal string was specified</code>, while trying to connect to a WebSocket on Firefox.</p>
<pre><code><!doctype html>
<html>
<head><meta charset="utf-8"></head>
<body>
<script>
var socket = new WebSocket('127.0.0.1:1234');
</script>
</body>
</html>
</code></pre>
<p>Why do I get this error?</p>
| 0debug
|
How to use Observable.fromCallable() with a checked Exception? : <p><code>Observable.fromCallable()</code> is great for converting a single function into an Observable. But how do you handle checked exceptions that might be thrown by the function?</p>
<p>Most of the examples I've seen use lambdas and "just work". But how would you do this without lambdas? For example, see the quote below from <a href="http://artemzin.com/blog/rxjava-defer-execution-of-function-via-fromcallable/">this great article</a>:</p>
<pre><code>Observable.fromCallable(() -> downloadFileFromNetwork());
</code></pre>
<blockquote>
<p>It's a one-liner now! It deals with checked exceptions, no more weird Observable.just() and Observable.error() for such easy thing as deferring code execution!</p>
</blockquote>
<p>When I attempt to implement the above Observable without a lambda expression, based on other examples I've seen, and how Android Studio auto-completes, I get the following:</p>
<pre><code>Observable.fromCallable(new Func0<File>() {
@Override
public File call() {
return downloadFileFromNetwork();
}
}
</code></pre>
<p>But if <code>downloadFileFromNetwork()</code> throws a checked exception, I have to try-catch it and wrap it in a <code>RuntimeException</code>. There's got to be a better way! How does the above lambda support this?!?!</p>
| 0debug
|
static uint16_t nvme_map_prp(QEMUSGList *qsg, QEMUIOVector *iov, uint64_t prp1,
uint64_t prp2, uint32_t len, NvmeCtrl *n)
{
hwaddr trans_len = n->page_size - (prp1 % n->page_size);
trans_len = MIN(len, trans_len);
int num_prps = (len >> n->page_bits) + 1;
if (!prp1) {
return NVME_INVALID_FIELD | NVME_DNR;
} else if (n->cmbsz && prp1 >= n->ctrl_mem.addr &&
prp1 < n->ctrl_mem.addr + int128_get64(n->ctrl_mem.size)) {
qsg->nsg = 0;
qemu_iovec_init(iov, num_prps);
qemu_iovec_add(iov, (void *)&n->cmbuf[prp1 - n->ctrl_mem.addr], trans_len);
} else {
pci_dma_sglist_init(qsg, &n->parent_obj, num_prps);
qemu_sglist_add(qsg, prp1, trans_len);
}
len -= trans_len;
if (len) {
if (!prp2) {
goto unmap;
}
if (len > n->page_size) {
uint64_t prp_list[n->max_prp_ents];
uint32_t nents, prp_trans;
int i = 0;
nents = (len + n->page_size - 1) >> n->page_bits;
prp_trans = MIN(n->max_prp_ents, nents) * sizeof(uint64_t);
nvme_addr_read(n, prp2, (void *)prp_list, prp_trans);
while (len != 0) {
uint64_t prp_ent = le64_to_cpu(prp_list[i]);
if (i == n->max_prp_ents - 1 && len > n->page_size) {
if (!prp_ent || prp_ent & (n->page_size - 1)) {
goto unmap;
}
i = 0;
nents = (len + n->page_size - 1) >> n->page_bits;
prp_trans = MIN(n->max_prp_ents, nents) * sizeof(uint64_t);
nvme_addr_read(n, prp_ent, (void *)prp_list,
prp_trans);
prp_ent = le64_to_cpu(prp_list[i]);
}
if (!prp_ent || prp_ent & (n->page_size - 1)) {
goto unmap;
}
trans_len = MIN(len, n->page_size);
if (qsg->nsg){
qemu_sglist_add(qsg, prp_ent, trans_len);
} else {
qemu_iovec_add(iov, (void *)&n->cmbuf[prp_ent - n->ctrl_mem.addr], trans_len);
}
len -= trans_len;
i++;
}
} else {
if (prp2 & (n->page_size - 1)) {
goto unmap;
}
if (qsg->nsg) {
qemu_sglist_add(qsg, prp2, len);
} else {
qemu_iovec_add(iov, (void *)&n->cmbuf[prp2 - n->ctrl_mem.addr], trans_len);
}
}
}
return NVME_SUCCESS;
unmap:
qemu_sglist_destroy(qsg);
return NVME_INVALID_FIELD | NVME_DNR;
}
| 1threat
|
how can i create a data type in c++ (like a data type named digit which can store an integer of 12 byte or more as required) : I am using long type for storing values but it doesn't store a number with more than 10 digits so what can I do ! Is there any way to make a new integer type with extended memory size
| 0debug
|
need help mysql joining table : i have 4 table and want to join it
student
id_student name angkatan
s_1 iyan a_1
s_2 teo a_1
s_3 mirna a_2
angkatan
id_angkatan name
a_1 angkatan 1
a_2 angkatan 2
sub
id_sub name payment
sub_1 bag 1000
sub_2 book 2000
resume
id angkatan sub
1 a_1 sub_1
2 a_1 sub_2
3 a_2 sub_2
from resume table i want to the new table has result like this
if in table resume it says angkatan = ang_1 it will select all student with angkatan = ang_1 with sub
nim name angkatan sub
s_1 iyan a_1 bag
s_2 teo a_1 bag
s_1 iyan a_1 book
s_2 teo a_1 book
s_3 mirna a_2 book
how to do that? i trying but still couldnot found how
thanks for help
| 0debug
|
How to run aws configure in a travis deploy script? : <p>I am trying to get <a href="https://travis-ci.com" rel="noreferrer">travis-ci</a> to run a custom deploy script that uses <a href="https://aws.amazon.com/cli/" rel="noreferrer"><code>awscli</code></a> to push a deployment up to my staging server.</p>
<p>In my <code>.travis.yml</code> file I have this:</p>
<pre><code>before_deploy:
- 'curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"'
- 'unzip awscli-bundle.zip'
- './awscli-bundle/install -b ~/bin/aws'
- 'export PATH=~/bin:$PATH'
- 'aws configure'
</code></pre>
<p>And I have set up the following environment variables:</p>
<pre><code>AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION
</code></pre>
<p>with their correct values in the <code>travis-ci</code> web interface.</p>
<p>However when the <code>aws configure</code> runs, it stops and waits for user input. How can I tell it to use the environment variables I have defined?</p>
| 0debug
|
datetime-local CAN NOT SET VALUE : I couldn't set value of input type="datetime-local" this is my code
document.getElementById("time_Out").defaultValue = document.getElementById("DateOut"+id).innerHTML;
| 0debug
|
Parse error: syntax error in PHP : <p>I try to store a string to a PHP variable. But it shows an error "Parse error: syntax error, unexpected '='"
Here is the code</p>
<pre><code>$page-title = "Home Page";
</code></pre>
| 0debug
|
Invert shift operation : Is it possible to invert a shift operation of a base two variable without using a dedicated function? I am looking for the variable y. x and z are known.
Example:
x << y = z
1 << 7 = 64
y = 64 ???
There are many solutions including log(64)/log(2), but therefore I would have to use math.h, however I am looking for some sort of bitwise operation.
Thank you.
| 0debug
|
Detect Ctrl + C and Ctrl + V in an input from browsers : <p>I am using the direct following and I do not detect the copy and paste with the keys inside the input, would someone know how? Thank you!</p>
<pre><code>export class OnlyNumberDirective {
// Allow decimal numbers. The \, is only allowed once to occur
private regex: RegExp = new RegExp(/[0-9]+(\,[0-9]{0,1}){0,1}$/g);
// Allow key codes for special events. Reflect :
// Backspace, tab, end, home
private specialKeys: Array<string> = [ 'Backspace', 'Tab', 'End', 'Home', 'Delete', 'Del', 'Ctrl', 'ArrowLeft', 'ArrowRight', 'Left', 'Right' ];
constructor(private el: ElementRef) {
}
@HostListener('keydown', [ '$event' ])
onKeyDown(event: KeyboardEvent): string {
// Allow Backspace, tab, end, and home keys
if (this.specialKeys.indexOf(event.key) !== -1) {
return null;
}
// Do not use event.keycode this is deprecated.
// See: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode
let current: string = this.el.nativeElement.value;
// We need this because the current value on the DOM element
// is not yet updated with the value from this event
let next: string = current.concat(event.key);
if (next && !String(next).match(this.regex)) {
event.preventDefault();
return null;
} else {
return next;
}
}
}
</code></pre>
| 0debug
|
Realm Migration doesn't work : <pre><code> let config = Realm.Configuration(
// Set the new schema version. This must be greater than the previously used
// version (if you've never set a schema version before, the version is 0).
schemaVersion: 1,
// Set the block which will be called automatically when opening a Realm with
// a schema version lower than the one set above
migrationBlock: { migration, oldSchemaVersion in
// We haven’t migrated anything yet, so oldSchemaVersion == 0
if (oldSchemaVersion < 1) {
// Nothing to do!
// Realm will automatically detect new properties and removed properties
// And will update the schema on disk automatically
}
})
// Tell Realm to use this new configuration object for the default Realm
Realm.Configuration.defaultConfiguration = config
// Now that we've told Realm how to handle the schema change, opening the file
// will automatically perform the migration
let realm = try! Realm()
</code></pre>
<p>This was put in application(application:didFinishLaunchingWithOptions:)</p>
<p>In my test program, I have changed the fields in my object. I would like to remove everything in the database, and move to the new field types. I've copied the code above from the documentation, but it appears to do nothing. I still get these errors:</p>
<pre><code>fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=0 "Migration is required due to the following errors:
- Property types for 'unit' property do not match. Old type 'string', new type 'int'
- Property 'reps' has been added to latest object model." UserInfo={NSLocalizedDescription=Migration is required due to the following errors:
- Property types for 'unit' property do not match. Old type 'string', new type 'int'
- Property 'reps' has been added to latest object model.}: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-700.1.101.15/src/swift/stdlib/public/core/
</code></pre>
<p>Any ideas?</p>
| 0debug
|
AngularJs check weather Array containing an item or not : <p>I have array of name:<br>
<code>$scope.myArray</code> with some values.<br>
Now I want to check an Item is present in array or not,<br>
If it is not present then I want to push that item into array and If that item is already in array then I don't want to push it.<br>
Please tell me how to do this ?</p>
| 0debug
|
What does this regular expression maens "/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/" : <p>Found this technique to verify if the email address is in correct form of not.</p>
<pre><code>function check_email($email) {
if( (preg_match('/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/', $email)) ||
(preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/',$email)) ) {
return true;
} else {
return false;
}
}
</code></pre>
<p>I Am a newbie in php. What this big regex commands mean? </p>
| 0debug
|
What's the faster, most efficient way to toggle > 10000 checkboxes with Javascript/JQuery? : I have a `div` with more than 10000 checkboxes in it.
```html
<div class="well well-sm" style="min-height: 100px; max-height: 360px; overflow: auto; background-color: #f7f7f7;">
<label>
<input type="checkbox" class="checkbox-item" name="some_name" value="28" checked="checked"> Item 1
</label><br />
<!-- another 10000 of these -->
</div>
```
and this JQuery code that activates when specific buttons are pressed.
```JavaScript
$('.select-all').click(function () {
$(this).parent().find(':checkbox:visible').prop('checked', true).change();
});
$('.unselect-all').click(function () {
$(this).parent().find(':checkbox:visible').prop('checked', false).change();
});
$('.select-inverse').click(function () {
$(this).parent().find(':checkbox:visible').click();
});
```
(Ignore the `:visible` part as the list could be filtered)
When the number of checkboxes is in the thousands the whole thing gets too slow, especially when ~10000 checkboxes need to be toggled.
I was wondering if there's a faster (not necessarily better) way to toggle all of them at the same time (mostly for select/unselect all, as inverse selection can be removed altogether)
| 0debug
|
int bdrv_enable_write_cache(BlockDriverState *bs)
{
return bs->enable_write_cache;
}
| 1threat
|
SDState *sd_init(BlockDriverState *bs, bool is_spi)
{
SDState *sd;
if (bdrv_is_read_only(bs)) {
fprintf(stderr, "sd_init: Cannot use read-only drive\n");
return NULL;
}
sd = (SDState *) g_malloc0(sizeof(SDState));
sd->buf = qemu_blockalign(bs, 512);
sd->spi = is_spi;
sd->enable = true;
sd_reset(sd, bs);
if (sd->bdrv) {
bdrv_attach_dev_nofail(sd->bdrv, sd);
bdrv_set_dev_ops(sd->bdrv, &sd_block_ops, sd);
}
vmstate_register(NULL, -1, &sd_vmstate, sd);
return sd;
}
| 1threat
|
Large UL LI html file loading very slow : <p>I have a 'menu' HTML page. The Menu contains Book names and its chapters. It is designed like a tree like structure, built using tags UL & LI. The file is 2.6mb. The file is loading very slow on to the website. Are there any suggestions to improve its load time. Thank you.</p>
| 0debug
|
void qemu_spice_display_resize(SimpleSpiceDisplay *ssd)
{
dprint(1, "%s:\n", __FUNCTION__);
pthread_mutex_lock(&ssd->lock);
memset(&ssd->dirty, 0, sizeof(ssd->dirty));
qemu_pf_conv_put(ssd->conv);
ssd->conv = NULL;
pthread_mutex_unlock(&ssd->lock);
qemu_spice_destroy_host_primary(ssd);
qemu_spice_create_host_primary(ssd);
pthread_mutex_lock(&ssd->lock);
memset(&ssd->dirty, 0, sizeof(ssd->dirty));
ssd->notify++;
pthread_mutex_unlock(&ssd->lock);
}
| 1threat
|
in my android application landscape mode of my image is congested how solve it? : in the android application landscape mode of the image is congested how solve it? code snippent as folows
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="mat`enter code here`ch_parent"
android:fillViewport="true">
<ImageView
android:id="@+id/imgOne"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</HorizontalScrollView>
| 0debug
|
C# Cannot inplicitly convert form to from : So i am trying to store my main form and open a new one however i get this error, here is the code:
I have this at form level
public static frmAddBook frmkeepBooks = null;
public frmMain()
{
InitializeComponent();
frmkeepBooks = this;
}
The error underlines "this" saying it "Cannot inplicitly convert type Books.frmMain to Books.frmAddBook"
| 0debug
|
.net static Datatable method with parameter : I need to bind an asp repeater with a sql query, that includes a parameter but im using a public Static method, so i dont know how to pass a variable to this method :
Code behind aspx webfile :
protected void Page_Load(object sender, EventArgs e)
{
this.DataAdmin();
}
public void DataAdmin()
{
/****Resultado is the repeater name */
Datatable dataAdmin = DescargarDocumentos.SolicitarDatosDocumento() ;
Resultados.DataSource = dataAdmin;
Resultados.DataBind();
}
Code behind the class
public class DescargaDocumentos
{
public static DataTable SolicitarDatosDocumentos()
{
/* */
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
SqlDataReader reader;
conn.Open();
SqlCommand vistadocumentos = new SqlCommand("ultimasolicitud", conn);
vistadocumentos.CommandType = CommandType.StoredProcedure;
/* i need to add the parameter here */
vistadocumentos.Parameters.AddWithValue("@numero",numero);/*error is here because i cant get pass this parameter to a static method*/
reader = vistadocumentos.ExecuteReader();
DataTable test = null;
if (reader.HasRows)
{
test = new DataTable("test");
test.Load(reader);
}
reader.Close();
conn.Close();
return test;
}
}
The error is on the variable number because i cant "pass the variable numero" to a static method, is it possible to do it?
btw this is the stored procedure (should return file names according to the order number)
alter procedure documentlist (
@numero int
)
as
begin
select
tipo_de_documento.tipo_documento,detalle_documentos.nombre_documento
from tipo_de_documento inner join has_tipo on
tipo_de_documento.numero=has_tipo.numero_tipo inner join
detalle_documentos
on has_tipo.id_detalle= detalle_documentos.id_detalle inner join
Documentos
on detalle_documentos.num_documento= documentos.num_documento where
documentos.num_solicitud=@numero
end
| 0debug
|
How to include JSON response body in Spring Boot Actuator's Trace? : <p>Spring Boot Actuator's <code>Trace</code> does a good job of capturing input/output HTTP params, headers, users, etc. I'd like to expand it to also capture the body of the HTTP response, that way I can have a full view of what is coming in and going out of the the web layer. Looking at the <code>TraceProperties</code>, doesn't look like there is a way to configure response body capturing. Is there a "safe" way to capture the response body without messing up whatever character stream it is sending back?</p>
| 0debug
|
static int blk_prw(BlockBackend *blk, int64_t offset, uint8_t *buf,
int64_t bytes, CoroutineEntry co_entry,
BdrvRequestFlags flags)
{
AioContext *aio_context;
QEMUIOVector qiov;
struct iovec iov;
Coroutine *co;
BlkRwCo rwco;
iov = (struct iovec) {
.iov_base = buf,
.iov_len = bytes,
};
qemu_iovec_init_external(&qiov, &iov, 1);
rwco = (BlkRwCo) {
.blk = blk,
.offset = offset,
.qiov = &qiov,
.flags = flags,
.ret = NOT_DONE,
};
co = qemu_coroutine_create(co_entry);
qemu_coroutine_enter(co, &rwco);
aio_context = blk_get_aio_context(blk);
while (rwco.ret == NOT_DONE) {
aio_poll(aio_context, true);
}
return rwco.ret;
}
| 1threat
|
python3/mock: run functinon and only mock its return code? : Using mock's capabilities within python3, I want to wrap a function and have it perform all of its normal functionality, and I simply want to mock its return value. In other words, I don't want to mock the entire function, just its return value, and I don't know how to make that happen.
def func():
# do something
# do something else
# do lots of other things
retval = 123
return retval
with mock.patch('func') as mocked:
mocked.return_value = 456
# And now, I want to run the function so that when
# it's called, "do something", "do something else",
# and "do lots of other things" still get performed,
# but that 456 gets returned instead of 123.
I apologize in advance if this is documented somewhere and that I just overlooked or misunderstood those docs. If so, a pointer to the appropriate docs will be more than sufficient and much appreciated.
| 0debug
|
static unsigned int dec_move_sr(DisasContext *dc)
{
DIS(fprintf (logfile, "move $s%u, $r%u\n", dc->op2, dc->op1));
cris_cc_mask(dc, 0);
tcg_gen_helper_0_2(helper_movl_reg_sreg,
tcg_const_tl(dc->op1), tcg_const_tl(dc->op2));
return 2;
}
| 1threat
|
Swift UISlider multiple track colors : <p>I am trying to create a UISlider with a track broken up into sections. Is it possible to break up the track and have each section be a different color? Rather than just min track and max track</p>
| 0debug
|
Check two first elements of char array and send to an integer : <p>I have credit fictitious credit card numbers stored as char array and long long. In order to check if the card is VISA, MASTER or AMEX, I have to check first two digits either of this long long or of this string.
MasterCard numbers all start with 51, 52, 53, 54, or 55
American Express numbers all start with 34 or 37
Visa numbers all start with 4</p>
<p>Any idea how to do so?
I've tried to put in two separate integers and check later with if/else, but I guess there might be a better way to solve this.
Thanks for the help.</p>
| 0debug
|
static void pc_dimm_check_memdev_is_busy(const Object *obj, const char *name,
Object *val, Error **errp)
{
Error *local_err = NULL;
if (host_memory_backend_is_mapped(MEMORY_BACKEND(val))) {
char *path = object_get_canonical_path_component(val);
error_setg(&local_err, "can't use already busy memdev: %s", path);
g_free(path);
} else {
qdev_prop_allow_set_link_before_realize(obj, name, val, &local_err);
}
error_propagate(errp, local_err);
}
| 1threat
|
static void handle_user_command(Monitor *mon, const char *cmdline)
{
QDict *qdict;
const mon_cmd_t *cmd;
qdict = qdict_new();
cmd = monitor_parse_command(mon, cmdline, qdict);
if (!cmd)
goto out;
if (monitor_handler_is_async(cmd)) {
user_async_cmd_handler(mon, cmd, qdict);
} else if (monitor_handler_ported(cmd)) {
monitor_call_handler(mon, cmd, qdict);
} else {
cmd->mhandler.cmd(mon, qdict);
}
if (monitor_has_error(mon))
monitor_print_error(mon);
out:
QDECREF(qdict);
}
| 1threat
|
get source path of an image file from HTML input file tag : <p>I have been looking for an answer & reading since 24hrs that for security reasons this is not allowed by most of the browser but</p>
<p>What I am trying to do -
I want to upload an image using HTML input file tag. When I select the image using file browser, I want to get the path of the chosen file to work on it into the code.</p>
<p>I am able to get the name of the file but not the path.</p>
<p>How do I get the path of the selected file?</p>
<pre><code><script type="text/javascript">
function fileSelected(){
var name = document.getElementById("fileToUpload").files[0].name;
console.log(name); //gives the name of the selected file
var val = document.getElementById("fileToUpload").files[0].value;
console.log(val); //gives undefined
}
</script>
<form action="vanilla.php" method="post" enctype="multipart/form-data">
<input type="file" name="fileToUpload" id="fileToUpload" onchange="fileSelected();">
</form>
</code></pre>
<p>OR you can suggest any other way to upload a file using PHP</p>
<p>Thanks!</p>
| 0debug
|
static unsigned long copy_strings(int argc,char ** argv,unsigned long *page,
unsigned long p)
{
char *tmp, *tmp1, *pag = NULL;
int len, offset = 0;
if (!p) {
return 0;
}
while (argc-- > 0) {
if (!(tmp1 = tmp = get_user(argv+argc))) {
fprintf(stderr, "VFS: argc is wrong");
exit(-1);
}
while (get_user(tmp++));
len = tmp - tmp1;
if (p < len) {
return 0;
}
while (len) {
--p; --tmp; --len;
if (--offset < 0) {
offset = p % TARGET_PAGE_SIZE;
pag = (char *) page[p/TARGET_PAGE_SIZE];
if (!pag) {
pag = (char *)get_free_page();
page[p/TARGET_PAGE_SIZE] = (unsigned long)pag;
if (!pag)
return 0;
}
}
if (len == 0 || offset == 0) {
*(pag + offset) = get_user(tmp);
}
else {
int bytes_to_copy = (len > offset) ? offset : len;
tmp -= bytes_to_copy;
p -= bytes_to_copy;
offset -= bytes_to_copy;
len -= bytes_to_copy;
memcpy_fromfs(pag + offset, tmp, bytes_to_copy + 1);
}
}
}
return p;
}
| 1threat
|
def rombus_perimeter(a):
perimeter=4*a
return perimeter
| 0debug
|
How to use java class without main method : <p>I was looking for a code of "Whale_optimization_algorithm" in Java and I found it on a site but when I am trying to run it. It shows the error of "could not find or load Main class Whale_optimization_algorithm.java"
But it compiled successfully.</p>
<p>Here is the Code</p>
<pre><code>package test;
import java.io.*;
abstract class f_xj
{
abstract double func(double x[]);
}
public class Whale_optimization_algorithm {
double A;
double C;
double a;
double a2;
double b;
double l;
double p;
double r1;
double r2;
double Leader_score;
double[] Leader_pos;
double D_Leader;
double distance2Leader;
double[] Lower;
double[] Upper;
double[] X_rand;
double D_X_rand;
int Maxiter;
int rand_leader_index;
double[][] Positions;
double[] Fitness;
int N;
int D;
f_xj ff;
public Whale_optimization_algorithm(f_xj iff, int iMaxiter, double[] iLower, double[] iUpper, int iN)
{
ff=iff;
Maxiter=iMaxiter;
Lower=iLower;
Upper=iUpper;
D=Lower.length;
N=iN;
Positions=new double[N][D];
Fitness=new double[N];
Leader_pos=new double[D];
X_rand=new double[D];
Leader_score=100000000000.0;
}
void init()
{
for(int i=0;i<N;i++)
{for(int j=0;j<D;j++)
{Positions[i][j]=Lower[j]+((Upper[j]-Lower[j])*Math.random());}}
}
double[][] solution()
{
init();
int iter=0;
while(iter<Maxiter)
{
for(int i=0;i<N;i++)
{
for(int j=0;j<D;j++)
{if ((Positions[i][j]<Lower[j]) || (Positions[i][j]>Upper[j]))
{Positions[i][j]=Lower[j]+((Upper[j]-Lower[j])*Math.random());}}
Fitness[i]=ff.func(Positions[i]);
if(Fitness[i]<Leader_score)
{
Leader_score=Fitness[i];
for(int j=0;j<D;j++)
{Leader_pos[j]=Positions[i][j];}
}
}
a=2.0 - (double)iter*(2.0/(double)Maxiter);
a2= -1.0 + (double)iter*(-1.0/(double)Maxiter);
for(int i=0;i<N;i++)
{
r1=Math.random();
r2=Math.random();
A=2.0*a*r1-a;
C=2.0*r2;
b=1.0;
l=(a2-1.0)*Math.random() + 1.0;
p=Math.random();
for(int j=0;j<D;j++)
{
if (p<0.5)
{
if (Math.abs(A)>=1.0)
{
rand_leader_index=(int)Math.floor((double)N*Math.random());
X_rand[j]=Positions[rand_leader_index][j];
D_X_rand=Math.abs(C*X_rand[j] - Positions[i][j]);
Positions[i][j]=X_rand[j] - A*D_X_rand;
}
else if (Math.abs(A)<1)
{
D_Leader=Math.abs(C*Leader_pos[j] - Positions[i][j]);
Positions[i][j]=Leader_pos[j]-A*D_Leader;
}
}
else if (p>=0.5)
{
distance2Leader=Math.abs(Leader_pos[j] - Positions[i][j]);
Positions[i][j]=distance2Leader*Math.exp(b*l)*Math.cos(l*2.0*Math.PI) + Leader_pos[j];
}
}
}
iter++;
}
double out[][]=new double[2][D];
out[0][0]=Leader_score;
for(int i=0;i<D;i++)
{out[1][i]=Leader_pos[i];}
return out;
}
void toStringnew()
{
double[][] out=solution();
System.out.println("Optimized value = "+out[0][0]);
for(int i=0;i<D;i++)
{System.out.println("x["+i+"] = "+out[1][i]);}
}
void toTxtfile()
{ String named="whale_plateframe_f36_ackley.txt";
String line="";
int lineNo;
try
{
FileWriter fw=new FileWriter(named,true);
BufferedWriter bw=new BufferedWriter(fw);
LineNumberReader lnr=new LineNumberReader(new FileReader(named));
lnr.setLineNumber(1);
for(int i=1;i<=lnr.getLineNumber();i++)
{bw.newLine();}
double[][] dd=solution();
Double d1d=new Double(dd[0][0]);
String s1=d1d.toString();
int nn=dd[1].length;
Double[] val=new Double[nn];
String[] str=new String[nn];
for(int i=0;i<nn;i++)
{val[i]=new Double(dd[1][i]);}
for(int i=0;i<nn;i++)
{str[i]=val[i].toString();}
bw.write(s1+" ");
for(int i=0;i<nn;i++)
{bw.write(str[i]+" ");}
bw.close();
lnr.close();
}catch(IOException e)
{e.printStackTrace();}
}
}
</code></pre>
<p>Please Help me. I am new to Java.
If i've to add method how can i add it or call this class in method?</p>
| 0debug
|
Which one is more reliable for Server sent events Firebase Realtime DB or FCM? : <p>We want to send some realtime server sent events to our client apps so we decided to use Firebase cloud services. Which one is more reliable for sending realtime events Firebase Realtime DB or FCM?
We need to make a decision because our requirement can be solved in both cases but FCM is free where as Realtime DB is paid. What are the cons If I opt for FCM over Realtime DB?
Thank You</p>
| 0debug
|
int kvm_has_sync_mmu(void)
{
#ifdef KVM_CAP_SYNC_MMU
KVMState *s = kvm_state;
return kvm_check_extension(s, KVM_CAP_SYNC_MMU);
#else
return 0;
#endif
}
| 1threat
|
Sketch How to open same file in multiple windows/tabs? : <p>Is it possible to open the same <code>.sketch</code> file in multiple tabs/windows?</p>
<p>I tried <code>File -> Open Recents -> Myfile</code> and also opening it multiple times from the Finder but it just keep opening the same windows</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.