problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
static av_cold int dnxhd_decode_init_thread_copy(AVCodecContext *avctx)
{
DNXHDContext *ctx = avctx->priv_data;
ctx->cid = -1;
ctx->rows = av_mallocz_array(avctx->thread_count, sizeof(RowContext));
if (!ctx->rows)
return AVERROR(ENOMEM);
return 0;
} | 1threat |
static inline void flash_sync_area(Flash *s, int64_t off, int64_t len)
{
QEMUIOVector *iov = g_new(QEMUIOVector, 1);
if (!s->blk || blk_is_read_only(s->blk)) {
return;
}
assert(!(len % BDRV_SECTOR_SIZE));
qemu_iovec_init(iov, 1);
qemu_iovec_add(iov, s->storage + off, len);
blk_aio_pwritev(s->blk, off, iov, 0, blk_sync_complete, iov);
}
| 1threat |
Throwing an array local to a try block : <p>From C++ Primer 18.1.1:</p>
<blockquote>
<p>If the [thrown] expression has an array or function type, the expression is
converted to its corresponding pointer type.</p>
</blockquote>
<p>How is it that this program can produce correct output of <code>9876543210</code> (g++ 5.2.0)?</p>
<pre><code>#include <iostream>
using namespace std;
int main(){
try{
int a[10] = {9,8,7,6,5,4,3,2,1,0};
throw a;
}
catch(int* b) { for(int i = 0; i < 10; ++i) cout << *(b+i); }
}
</code></pre>
<p>From the quote, <code>throw a</code> would create an exception object of type <code>int*</code> which is a pointer to the first element of the array. But surely the array elements of <code>a</code> would be destroyed when we exit the <code>try</code> block and enter the catch clause since we change block scope? Am I getting a false positive or are the array elements "left alone" (not deleted) during the duration of the catch clause?</p>
| 0debug |
iTextsharp PDF Generation : I am using iTextSharp to create PDF in a .NET application. I do not need to save/write the PDF to a server for storage. Just create a file to the users local machine. Posted controller below. Not sure where I am going wrong.
[HttpPost]
public FileResult DailyReport(string path ="")
{
path = !String.IsNullOrWhiteSpace(path) ? path : String.Format("~/downloads/daily-report.pdf");
var report = new Document(PageSize.LETTER, 10, 10, 10, 10);
PdfWriter.GetInstance(report, new FileStream(MapPath(path), FileMode.OpenOrCreate));
report.Open();
var table = new Table(2, 1) { Width = 100, Border = 0, Cellpadding = 2 };
table.AddCell(
new Cell(new Paragraph("Daily Schedule", new Font(Font.TIMES_ROMAN, 18, Font.BOLD)))
{
Border = 0,
HorizontalAlignment = Element.ALIGN_CENTER,
Colspan = 2
});
table.AddCell(new Cell { Colspan = 2, Border = 0, Leading = 2 });
report.Add(table);
report.Close();
return path;
}
public static string MapPath(string path)
{
return (path.StartsWith("~") ? System.Web.HttpContext.Current.Server.MapPath(path) : path);
} | 0debug |
Upgraded Firebase - Now Getting Swift Compile Error : <p>I upgraded Firebase yesterday and now am having a very unusual problem. When I run the simulator, I get a swift compile error "Segmentation fault: 11" The are hundreds of lines of code describing the error, but they are absolutely no help. From the error, the only thing I see that might be giving clues is at the bottom. It says:</p>
<pre><code> 1. While loading members for 'ProfileTableViewController' at <invalid loc>
2. While deserializing decl #101 (PATTERN_BINDING_DECL)
3. While deserializing decl #2 (VAR_DECL)
</code></pre>
<p>Oddly, the errors I just typed above are not consistent. The view controller mentioned rotates between the three view controllers where I am using Firebase.</p>
<p>To try to solve the problem, I commented out all of the code in the ProfileTableViewController class, but I still got an error referencing that view controller. The only code running in the view controller was:</p>
<pre><code> import UIKit
import Firebase
import FirebaseDatabase
</code></pre>
<p>(I'm also using FirebaseAuth in other view controllers).</p>
<p>What does work to fix the problem is to hit "clean", restart xcode, clean again on launch and then run the program. Everything will work fine unless I make any changes to the code in the program. Even if all I do is add a comment, the error will reappear.</p>
<p>I don't want to have to close xcode and restart every time I write a couple lines of code, and I am worried that I will run into problems when uploading to the app store. </p>
<p>I am using XCode 7.3.1 and my deployment target is 9.3</p>
<p>Any insight you can give is greatly appreciated! Thank you!</p>
| 0debug |
Is Materialize Navbar height adjustment possible? : <p>Is it possible to adjust the height of the Navbar in Materialize?</p>
<p>64px is a bit too much for my site. I was going for 30px before I decided to materialize it.</p>
| 0debug |
python numpy log2 returns -inf when using Popen : <p>I am trying to run this line:</p>
<pre><code>print(np.log2( (ngram_list.count(('i',)) + 1 )/( 100000 + len(set(n1gram_list)) )))
</code></pre>
<p>When I run my script from terminal I get -1.54814270552.
But when I run the same script via subprocess.Popen I get -inf.
Basically every time the output of log2 is positive I get the right output in both method but for negative values I get -inf only when using Popen.</p>
| 0debug |
pd.Timestamp versus np.datetime64: are they interchangeable for selected uses? : <p>This question is motivated by <a href="https://stackoverflow.com/a/49719901/9209546">an answer</a> to a <a href="https://stackoverflow.com/questions/49719627/boolean-mask-from-pandas-datetime-index-using-loc-accessor">question on improving performance</a> when performing comparisons with <code>DatetimeIndex</code> in <code>pandas</code>.</p>
<p>The solution converts the <code>DatetimeIndex</code> to a <code>numpy</code> array via <code>df.index.values</code> and compares the array to a <code>np.datetime64</code> object. This appears to be the most efficient way to retrieve the Boolean array from this comparison.</p>
<p>The feedback on this question from one of the developers of <code>pandas</code> was: "These are not the same generally. Offering up a numpy solution is often a special case and not recommended."</p>
<p>My questions are:</p>
<ol>
<li>Are they interchangeable for a subset of operations? I appreciate
<code>DatetimeIndex</code> offers more functionality, but I require only basic functionality such as slicing and indexing.</li>
<li>Are there any documented differences in <em>result</em> for operations that are translatable to <code>numpy</code>?</li>
</ol>
<p>In my research, I found some posts which mention "not always compatible" - but none of them seem to have any conclusive references / documentation, or specify why/when generally they are incompatible. Many other posts use the <code>numpy</code> representation without comment.</p>
<ul>
<li><a href="https://stackoverflow.com/questions/38676418/pandas-datetimeindex-indexing-dtype-datetime64-vs-timestamp">Pandas DatetimeIndex indexing dtype: datetime64 vs Timestamp</a></li>
<li><a href="https://stackoverflow.com/questions/13227865/how-to-convert-from-pandas-datetimeindex-to-numpy-datetime64">How to convert from pandas.DatetimeIndex to numpy.datetime64?</a></li>
</ul>
| 0debug |
static TPMVersion tpm_passthrough_get_tpm_version(TPMBackend *tb)
{
return TPM_VERSION_1_2;
}
| 1threat |
static int64_t coroutine_fn vvfat_co_get_block_status(BlockDriverState *bs,
int64_t sector_num, int nb_sectors, int *n, BlockDriverState **file)
{
BDRVVVFATState* s = bs->opaque;
*n = s->sector_count - sector_num;
if (*n > nb_sectors) {
*n = nb_sectors;
} else if (*n < 0) {
return 0;
}
return BDRV_BLOCK_DATA;
}
| 1threat |
R - Remove blanks from data frame : <p>An example of the data frame I have is:</p>
<pre><code>Index TimeDifference
1
2
3 20
4
5 67
</code></pre>
<p>I want to delete all rows that are blank (these are blank and NOT na). Hence the following data frame I want is:</p>
<pre><code>Index TimeDifference
3 20
5 67
</code></pre>
<p>Thanks</p>
| 0debug |
QInt *qobject_to_qint(const QObject *obj)
{
if (qobject_type(obj) != QTYPE_QINT)
return NULL;
return container_of(obj, QInt, base);
}
| 1threat |
int ff_frame_thread_init(AVCodecContext *avctx)
{
int thread_count = avctx->thread_count;
const AVCodec *codec = avctx->codec;
AVCodecContext *src = avctx;
FrameThreadContext *fctx;
int i, err = 0;
#if HAVE_W32THREADS
w32thread_init();
#endif
if (!thread_count) {
int nb_cpus = av_cpu_count();
av_log(avctx, AV_LOG_DEBUG, "detected %d logical cores\n", nb_cpus);
if (nb_cpus > 1)
thread_count = avctx->thread_count = FFMIN(nb_cpus + 1, MAX_AUTO_THREADS);
else
thread_count = avctx->thread_count = 1;
}
if (thread_count <= 1) {
avctx->active_thread_type = 0;
return 0;
}
avctx->internal->thread_ctx = fctx = av_mallocz(sizeof(FrameThreadContext));
fctx->threads = av_mallocz(sizeof(PerThreadContext) * thread_count);
pthread_mutex_init(&fctx->buffer_mutex, NULL);
fctx->delaying = 1;
for (i = 0; i < thread_count; i++) {
AVCodecContext *copy = av_malloc(sizeof(AVCodecContext));
PerThreadContext *p = &fctx->threads[i];
pthread_mutex_init(&p->mutex, NULL);
pthread_mutex_init(&p->progress_mutex, NULL);
pthread_cond_init(&p->input_cond, NULL);
pthread_cond_init(&p->progress_cond, NULL);
pthread_cond_init(&p->output_cond, NULL);
p->frame = av_frame_alloc();
if (!p->frame) {
err = AVERROR(ENOMEM);
goto error;
}
p->parent = fctx;
p->avctx = copy;
if (!copy) {
err = AVERROR(ENOMEM);
goto error;
}
*copy = *src;
copy->internal = av_malloc(sizeof(AVCodecInternal));
if (!copy->internal) {
err = AVERROR(ENOMEM);
goto error;
}
*copy->internal = *src->internal;
copy->internal->thread_ctx = p;
copy->internal->pkt = &p->avpkt;
if (!i) {
src = copy;
if (codec->init)
err = codec->init(copy);
update_context_from_thread(avctx, copy, 1);
} else {
copy->priv_data = av_malloc(codec->priv_data_size);
if (!copy->priv_data) {
err = AVERROR(ENOMEM);
goto error;
}
memcpy(copy->priv_data, src->priv_data, codec->priv_data_size);
copy->internal->is_copy = 1;
if (codec->init_thread_copy)
err = codec->init_thread_copy(copy);
}
if (err) goto error;
if (!pthread_create(&p->thread, NULL, frame_worker_thread, p))
p->thread_init = 1;
}
return 0;
error:
ff_frame_thread_free(avctx, i+1);
return err;
} | 1threat |
What does the `and` keyword mean in OCaml? : <p>I'm mystified by the <code>and</code> keyword in OCaml. Looking through <a href="https://github.com/facebook/hhvm/blob/master/hphp/hack/src/typing/typing_env.ml#L61" rel="noreferrer">this code</a>, I see</p>
<pre><code>type env = {
(* fields for a local environment described here *)
}
and genv {
(* fields for a global environment here *)
}
</code></pre>
<p>then <a href="https://github.com/facebook/hhvm/blob/master/hphp/hack/src/typing/typing_env.ml#L336" rel="noreferrer">later</a>,</p>
<pre><code>let rec debug stack env (r, ty) = (* a function definition *)
and debugl stack env x = (* another function definition *)
</code></pre>
<p>What's going on here? Does the <code>and</code> keyword just copy the last <code>type</code>, <code>let</code>, or <code>let rec</code> statement? Is there such thing as an <code>and rec</code> statement? Why would I want to use <code>and</code> instead of just typing <code>let</code> or <code>type</code>, making my code less brittle to refactoring? Is there anything else I should know about?</p>
| 0debug |
Primary Disk vs Swap Disk : <p>I am using Google Compute Engine with 90GB of SSD. As my site is growing, cost has also shooted up. I tried shifting to <a href="https://www.vpb.com" rel="nofollow noreferrer">https://www.vpb.com</a> but they gave me </p>
<p>30GB Primary Disk and 60GB Swap Disk (Both are SSDs as they said). </p>
<p>The proposed cost has also decreased to 50%. My RAM is just 8GB.</p>
<p>Is above configuration different from 90GB SSD disk in Google Compute Engine?</p>
| 0debug |
not found: value assertThrows : <p>I have the following test class:</p>
<pre><code>import org.scalatest.FunSuite
@RunWith(classOf[JUnitRunner])
class NodeScalaSuite extends FunSuite {
</code></pre>
<p>With this test method:</p>
<pre><code> test("Now doesn't terminate future that's not done") {
val testFuture: Future[Int] = Future{
wait(1000)
10
}
assertThrows[NoSuchElementException]{
testFuture.now
}
}
</code></pre>
<p>I am getting this error:</p>
<pre><code>not found: value assertThrows
</code></pre>
<p>I looked over the ScalaTest documentation from here <a href="http://doc.scalatest.org/3.0.0/#org.scalatest.FunSuite" rel="noreferrer">http://doc.scalatest.org/3.0.0/#org.scalatest.FunSuite</a> and the code that's similar to mine seems to work fine.</p>
<p>What's the issue?</p>
| 0debug |
static void spitz_init(int ram_size, int vga_ram_size, int boot_device,
DisplayState *ds, const char **fd_filename, int snapshot,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model)
{
spitz_common_init(ram_size, vga_ram_size, ds, kernel_filename,
kernel_cmdline, initrd_filename, spitz, 0x2c9);
}
| 1threat |
How to select fırst element and last element of row in flex design? : How can I select first and last item in a row , in flex design?
[I mean : like in this photo , first and lastin row][1]
[1]: https://i.stack.imgur.com/Fr8ND.png
(Unfortunately , however I tried a lot, I could not put embeded photo) | 0debug |
who define variable in function and use in class : i want create new variable in class by function:
CLASS book{
public function set($name){
newvar($name);
}
}
function newvar($str){
***????
/// what is code for here***
}
--------------------------
example:
$x = new BOOK();
$x->set('title');
$x->title = 'jack';
echo 'book title is: ' . $x->title;
echo '<br>-----------------------------<br>';
$x->set('writer');
$x->writer = 'tom';
echo 'book writer is: ' . $x->writer;
result:
book title is jack;
----------------------------------
book writer is tom; | 0debug |
Bootstrap negative margin on rows : <p>Bootstrap rows has a <code>margin</code> (left and right) of <code>-15px</code>. </p>
<p>As far as I know this is mainly by two reasons:</p>
<ol>
<li>The <code>.container</code> has a <code>padding</code> (left and right) of <code>15px</code></li>
<li>The <code>col-*</code> have a gutter of <code>15px</code>. </li>
</ol>
<p>So in order to avoid the blank space created by the gutter on the first column (on its left side) and the space created by the gutter on the last column (on its right side) the row has a <code>margin</code> (left and right) of <code>-15px</code>. </p>
<p>I'm just wondering, why not to remove the <code>padding</code> of the container and just set the padding/margin of a row to 0?</p>
<p>It will produce the same effect, the first column will have <code>15px</code> of distance to the <code>.container</code>, and the same for the last column.</p>
<p>What I'm missing?</p>
<p>I've checked: <a href="https://stackoverflow.com/questions/47785921/negative-left-and-right-margin-of-row-class-in-bootstrap">Negative left and right margin of .row class in Bootstrap</a> and <a href="https://stackoverflow.com/questions/32657663/bootstraps-row-margin-left-15px-why-is-it-outdented-from-the-docs">Bootstrap's .row margin-left: -15px - why is it outdented (from the docs)</a> but I don't see any reason to use negative margins instead of 0 <code>padding</code>.</p>
| 0debug |
How to use Hadoop and Hive technologies in website to be developed using PHP : I want to build a project where the data's velocity and volume is going to be really large. So, I'll have to use Big data concepts to implement it.
But I don't know how and where to use them.
Through a lot of research I did install Hadoop and Hive and also got
basic knowledge in Hive but don't know how to proceed.
Can someone please give me clear cut idea of what Technologies to use where and is it good to use PHP or should I use some other language.
Any input will be helpful.
Thanks in advance. | 0debug |
Command Line Git Problems : <p>I'm not fully understanding git. I have a repository on github.com which I checkout by cloning. Then I add a file called index.html and commit via command line. Then nothing happens on github.com. I cannot see the new file updating nor do I see any of the new branches I create. What am I doing wrong?</p>
| 0debug |
Notice: Undefined index: video_code in C:\xampp\htdocs\home_teacher_upload.php on line 12 : <p>Hi so I keep running into this error and I was wondering how can I fix it! It is very important because this project is for a school degree.</p>
<p>This form basically will be used for uploading youtube embed codes and call them in another page!
I am using strip_tags but it seems it will not work because it says undefined variables both $video_title and $video_code.So this is what the page looks like when i first open it:<a href="https://imgur.com/a/hTsW7" rel="nofollow noreferrer">http://imgur.com/a/hTsW7</a>
and this is when i click the submit button:
<a href="https://imgur.com/a/ToVV8" rel="nofollow noreferrer">http://imgur.com/a/ToVV8</a>
I know its a duplicate but I have tried so many options found here but none seems to work!I tried isset(); , I tried $_POST[] but no better results.I also tried to change the whole registration and login form but still nothing!
What are those errors and why
I am new into PHP so sorry for the bad explanation!</p>
<p>This is the home_teacher_upload.php :</p>
<pre><code><?php
require_once("session.php");
require_once("class.user.php");
$teacher = new USER();
if(isset($_POST['btn-submit']))
{
$video_title = strip_tags($_GET['video_title']);
$video_code = strip_tags($_GET['video_code']);
if ($video_title == "") {
$error[]="Duhet të vendosni titullin fillimisht!";
}
echo "<h3>Videoja u ngarkua me sukses!</h3>";
}
try {
$stmt = $teacher->runQuery("SELECT video_title, video_code FROM videos WHERE video_title=:video_title OR video_code=:video_code");
$stmt->execute(array(':video_title'=>$video_title, ':video_code'=>$video_code));
$row=$stmt->fetch(PDO::FETCH_ASSOC);
if($row['video_title']==$video_title) {
echo "<h3>Ky titull është jo valid!</h3>";
}
else if($row['video_code']==$video_code) {
$error[] = "Kjo video aktualisht është e ngarkuar";
}
else
{
$teacher->submit_video($video_title,$video_code);
}
}
catch (PDOException $e) {
echo $e->getMessage();
}
?>
<link href="img/favicon.png" rel="shortcut icon" />
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Cookie">
<link rel="stylesheet" href="css/user.css">
<link rel="stylesheet" href="bootstrap/fonts/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Fjalla+One" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Patua+One" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Bree+Serif" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Anton" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Hammersmith+One" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="css/bootstrap-theme.min.css" rel="stylesheet" media="screen">
<script type="text/javascript" src="jquery-1.11.3-jquery.min.js"></script>
<link rel="stylesheet" href="style.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="css/user.css">
<title>Ngarkoni video!</title>
</head>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" style="
font-family: Bree Serif;">IB-Learning </a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
<span class="glyphicon glyphicon-user"></span>&nbsp;&nbsp;<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="profile.php"><span class="glyphicon glyphicon-user"></span>&nbsp;Profili</a></li>
<li><a href="logout.php?logout=true"><span class="glyphicon glyphicon-log-out"></span>&nbsp;Dilni</a></li>
</ul>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="clearfix"></div>
<div class="container-fluid" style="margin-top:80px;">
</div>
<div class="wanna" style="text-align: center;">
<h3 style="font-family: Hammersmith One;">Ngarkoni një video</h3></div>
<div class="form" style="text-align: center; margin-left: 431px;
padding-top: 13px;">
<form class="submit_video" method="POST" style="text-align: center;">
<div class="form-group" style="font-family: Bree Serif; width: 28%;">
<input type="text" class="form-control" name="video_title" required placeholder="Titulli i videos" style="text-align: center;"/>
</div>
<div class="form-group" style="font-family: Bree Serif;margin-left: -37px;">
<textarea name="video_code" class="form-control" style="width: 240px; margin: 0px 337px 0px 0px; height: 165px; text-align: center;" form="code" placeholder="Embed code i videos" required="true"></textarea>
</div>
<div class="button_form-group">
<button type="submit" class="btn btn-primary" style="margin-right: 415px;font-family: Bree Serif;" name="btn-submit">
Submit
</button>
</div>
</form>
</div>
<?php include('footer.php');?>
<script src="bootstrap/js/bootstrap.min.js"></script>
<style type="text/css">
h3{
font-family: Bree Serif;
text-align: center;
padding-left: 20px;
}
</style>
</body>
</html>
</code></pre>
<p>This is session.php : </p>
<pre><code><?php
session_start();
require_once 'class.user.php';
$session = new USER();
// if user session is not active(not loggedin) this page will help 'home.php and profile.php' to redirect to login page
// put this file within secured pages that users (users can't access without login)
if(!$session->is_loggedin())
{
// session no set redirects to login page
$session->redirect('login.php');
}
</code></pre>
<p>and this is class.user.php : </p>
<pre><code><?php
require_once('dbconfig.php');
class USER
{
private $conn;
public function __construct()
{
$database = new Database();
$db = $database->dbConnection();
$this->conn = $db;
}
public function runQuery($sql)
{
$stmt = $this->conn->prepare($sql);
return $stmt;
}
public function register($uname,$umail,$upass)
{
try
{
$new_password = password_hash($upass, PASSWORD_DEFAULT);
$stmt = $this->conn->prepare("INSERT INTO tik_students(user_name,user_email,user_pass)
VALUES(:uname, :umail, :upass)");
$stmt->bindparam(":uname", $uname);
$stmt->bindparam(":umail", $umail);
$stmt->bindparam(":upass", $new_password);
$stmt->execute();
return $stmt;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
public function register_teacher($t_uname,$t_umail,$t_upass)
{
try
{
$new_password = password_hash($upass, PASSWORD_DEFAULT);
$stmt = $this->conn->prepare("INSERT INTO tik_teachers(user_name,user_email,user_pass)
VALUES(:uname, :umail, :upass)");
$stmt->bindparam(":uname", $t_uname);
$stmt->bindparam(":umail", $t_umail);
$stmt->bindparam(":upass", $t_new_password);
$stmt->execute();
return $stmt;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
public function doLogin($uname,$umail,$upass)
{
try
{
$stmt = $this->conn->prepare("SELECT user_id, user_name, user_email, user_pass FROM tik_students WHERE user_name=:uname OR user_email=:umail ");
$stmt->execute(array(':uname'=>$uname, ':umail'=>$umail));
$userRow=$stmt->fetch(PDO::FETCH_ASSOC);
if($stmt->rowCount() == 1)
{
if(password_verify($upass, $userRow['user_pass']))
{
$_SESSION['user_session'] = $userRow['user_id'];
return true;
}
else
{
return false;
}
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
public function doLogin_teacher($t_uname,$t_umail,$t_upass)
{
try
{
$stmt = $this->conn->prepare("SELECT user_id, user_name, user_email, user_pass FROM tik_teachers WHERE user_name=:uname OR user_email=:umail ");
$stmt->execute(array(':uname'=>$t_uname, ':umail'=>$t_umail));
$userRow=$stmt->fetch(PDO::FETCH_ASSOC);
if($stmt->rowCount() == 1)
{
if(password_verify($t_upass, $userRow['user_pass']))
{
$_SESSION['user_session'] = $userRow['user_id'];
return true;
}
else
{
return false;
}
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
public function submit_video($video_title,$video_code)
{
try
{
$stmt = $this->conn->prepare("INSERT INTO videos(video_title, video_code)
VALUES(:video_title, :video_code)");
$stmt->bindparam(":video_title", $video_title);
$stmt->bindparam(":video_code", $video_code);
$stmt->execute();
return $stmt;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
public function is_t_loggedin()
{
if(isset($_SESSION['user_session']))
{
return true;
}
}
public function is_loggedin()
{
if(isset($_SESSION['user_session']))
{
return true;
}
}
public function redirect($url)
{
header("Location: $url");
}
public function doLogout()
{
session_destroy();
unset($_SESSION['user_session']);
return true;
}
}
?>
</code></pre>
<p>Help would be appreciated</p>
| 0debug |
static void mvc_fast_memset(CPUS390XState *env, uint32_t l, uint64_t dest,
uint8_t byte)
{
S390CPU *cpu = s390_env_get_cpu(env);
hwaddr dest_phys;
hwaddr len = l;
void *dest_p;
uint64_t asc = env->psw.mask & PSW_MASK_ASC;
int flags;
if (mmu_translate(env, dest, 1, asc, &dest_phys, &flags)) {
cpu_stb_data(env, dest, byte);
cpu_abort(CPU(cpu), "should never reach here");
}
dest_phys |= dest & ~TARGET_PAGE_MASK;
dest_p = cpu_physical_memory_map(dest_phys, &len, 1);
memset(dest_p, byte, len);
cpu_physical_memory_unmap(dest_p, 1, len, len);
}
| 1threat |
What are the ways to secure Azure functions : <p>I have written 5 Azure functions in Azure Portal using c#.</p>
<p>Below are the steps to install my application:-</p>
<ul>
<li>Copy deployment scripts to the Edge node of the cluster</li>
<li>Deployment
scripts to do the following
<ul>
<li>Call Azure functions to do get my application builds from WASB.</li>
<li>Install my application on Edge node</li>
<li>Call Azure functions to do some updation.</li>
</ul></li>
</ul>
<p>Above process will be executed on the Customer Edge node. </p>
<p>The authorization using “<a href="https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-http-webhook#keys" rel="noreferrer">keys</a>” described here is just to provide another layer of API key authorization and is not applicable when my script needs to be called by a public client (like edge node) since it is discover-able there. </p>
<p>What are the best ways to secure the Azure Functions in my scenario?</p>
| 0debug |
Error while using Intent Extras : <p>I am using an app where initially , there is a intro screen which runs only when the app is started for the first time. At the last slide , I have two buttons namely signInAsCustomer and signInAsSeller . Both the intents take you to the same activity , but passes two different intent extras . signInAsCustomer passes extra with key "type" and value "customer" while signInAsSeler passes an extra with key "type" and value "seller" . When the second activity is started , I get the extra and depending on the extra , I set some text in a specific text view. The code for the SignInActivity is below.</p>
<p><strong>SignInActivity</strong></p>
<pre><code>private String type;
private TextView tv_seller_or_customer , forgot_password , guest_login ;
private EditText email , password ;
private Button login , signUp;
private FirebaseAuth mAuth;
private FirebaseAuth.AuthStateListener mAuthStateListener;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_in);
// Initialising Firebase Auth Object
mAuth = FirebaseAuth.getInstance();
// This is the Auth state listener . It checks if the user is aldready signed In or not
mAuthStateListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null)
{
// User is signed in
// Goes to a new activity
Intent i = new Intent(SignInActivity.this , MainActivity.class);
startActivity(i);
}else
{
// User is signed out
// Shows sign in page to the user
signInUser();
}
}
};
}
@Override
protected void onResume() {
super.onResume();
mAuth.addAuthStateListener(mAuthStateListener);
}
@Override
protected void onPause() {
super.onPause();
if (mAuthStateListener != null)
{
mAuth.removeAuthStateListener(mAuthStateListener);
}
}
public void signInUser()
{
// This method initialises all the views in the signInPage
initialiseViews();
// Getting the intent extras and changing the activity depending upon the button pressed in the Intro Slider
Intent i = getIntent();
if (i != null) {
type = i.getStringExtra("type");
if (type.equals("seller")) {
tv_seller_or_customer.setText("Seller");
initialiseViews();
guest_login.setVisibility(View.GONE);
} else {
tv_seller_or_customer.setText("Customer");
initialiseViews();
}
}else
{
tv_seller_or_customer.setVisibility(View.GONE);
}
// Listener for loging in
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String emailString = email.getText().toString();
String passwordString = password.getText().toString().trim();
if (!Is_Valid_Email(emailString))
{
Toast.makeText(SignInActivity.this , "Please enter a valid Email ID", Toast.LENGTH_SHORT).show();
}else {
loginUser(emailString , passwordString);
}
}
});
}
public boolean Is_Valid_Email(String email_check) {
return !email_check.isEmpty() && isEmailValid(email_check);
}
boolean isEmailValid(CharSequence email) {
return android.util.Patterns.EMAIL_ADDRESS.matcher(email)
.matches();
}
public void loginUser(String emailLogin , String passwordLogin)
{
mAuth.signInWithEmailAndPassword(emailLogin , passwordLogin)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (!task.isSuccessful())
{
Log.w("sign in", "Failed" , task.getException());
}else
{
Intent i = new Intent(SignInActivity.this , MainActivity.class);
startActivity(i);
}
}
});
}
public void initialiseViews()
{
forgot_password = (TextView) findViewById(R.id.forgotPassword);
guest_login = (TextView) findViewById(R.id.guest_tv);
email = (EditText) findViewById(R.id.email_edt);
password = (EditText) findViewById(R.id.pass_edt);
login = (Button) findViewById(R.id.login_button);
signUp = (Button) findViewById(R.id.sign_up_btn);
}}
</code></pre>
<p>The error I'm getting </p>
<pre><code> E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ankit_pc.pharmahouse, PID: 15750
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
at com.example.ankit_pc.pharmahouse.SignInActivity.signInUser(SignInActivity.java:78)
at com.example.ankit_pc.pharmahouse.SignInActivity$1.onAuthStateChanged(SignInActivity.java:48)
at com.google.firebase.auth.FirebaseAuth$1.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) Application terminated.
</code></pre>
<p>Where have I gone wrong?</p>
| 0debug |
static void external_snapshot_prepare(BlkTransactionState *common,
Error **errp)
{
BlockDriver *drv;
int flags, ret;
QDict *options = NULL;
Error *local_err = NULL;
bool has_device = false;
const char *device;
bool has_node_name = false;
const char *node_name;
bool has_snapshot_node_name = false;
const char *snapshot_node_name;
const char *new_image_file;
const char *format = "qcow2";
enum NewImageMode mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
ExternalSnapshotState *state =
DO_UPCAST(ExternalSnapshotState, common, common);
TransactionAction *action = common->action;
g_assert(action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC);
has_device = action->blockdev_snapshot_sync->has_device;
device = action->blockdev_snapshot_sync->device;
has_node_name = action->blockdev_snapshot_sync->has_node_name;
node_name = action->blockdev_snapshot_sync->node_name;
has_snapshot_node_name =
action->blockdev_snapshot_sync->has_snapshot_node_name;
snapshot_node_name = action->blockdev_snapshot_sync->snapshot_node_name;
new_image_file = action->blockdev_snapshot_sync->snapshot_file;
if (action->blockdev_snapshot_sync->has_format) {
format = action->blockdev_snapshot_sync->format;
}
if (action->blockdev_snapshot_sync->has_mode) {
mode = action->blockdev_snapshot_sync->mode;
}
drv = bdrv_find_format(format);
if (!drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
return;
}
state->old_bs = bdrv_lookup_bs(has_device ? device : NULL,
has_node_name ? node_name : NULL,
&local_err);
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
return;
}
if (has_node_name && !has_snapshot_node_name) {
error_setg(errp, "New snapshot node name missing");
return;
}
if (has_snapshot_node_name && bdrv_find_node(snapshot_node_name)) {
error_setg(errp, "New snapshot node name already existing");
return;
}
if (!bdrv_is_inserted(state->old_bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return;
}
if (bdrv_in_use(state->old_bs)) {
error_set(errp, QERR_DEVICE_IN_USE, device);
return;
}
if (!bdrv_is_read_only(state->old_bs)) {
if (bdrv_flush(state->old_bs)) {
error_set(errp, QERR_IO_ERROR);
return;
}
}
if (!bdrv_is_first_non_filter(state->old_bs)) {
error_set(errp, QERR_FEATURE_DISABLED, "snapshot");
return;
}
flags = state->old_bs->open_flags;
if (mode != NEW_IMAGE_MODE_EXISTING) {
bdrv_img_create(new_image_file, format,
state->old_bs->filename,
state->old_bs->drv->format_name,
NULL, -1, flags, &local_err, false);
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
return;
}
}
if (has_snapshot_node_name) {
options = qdict_new();
qdict_put(options, "node-name",
qstring_from_str(snapshot_node_name));
}
state->new_bs = bdrv_new("");
ret = bdrv_open(state->new_bs, new_image_file, options,
flags | BDRV_O_NO_BACKING, drv, &local_err);
if (ret != 0) {
error_propagate(errp, local_err);
}
QDECREF(options);
}
| 1threat |
How can i get all Classes which implements a custom interface : i want to get all classes which implements the `IFeature` Interface. I find java Refelctions but it dont work the way i want
IFeature feature = new Landing();
Class<?>[] cls = Character.class.getInterfaces();
for(Class<?> c : cls ){
System.out.println(c.toString());
}
the output
run:
interface java.io.Serializable
interface java.lang.Comparable
BUILD SUCCESSFUL (total time: 0 seconds)
my interface...
public interface IFeature {
public abstract void update(HashMap<QueueIdentifier, Queue<Measurement>> messageMap);
public abstract List<QueueIdentifier> getQIdList();
public abstract int getCountSamples();
}
| 0debug |
How can I make my program work : So today I made this program that is supposed to encrypt a password that you put into it. But when ever I run it it comes up with this:
Password = float(input('Enter Password: '))
ValueError: could not convert string to float: 'Banana' (the word I chose for this test)
I have asked some of my friends but they don't know. Any suggestions on how I could fix this.
Please keep in mind that I am a noob at this so I might have made some mistakes.
#Macchiat0
#10 May 2016
#This program will encrypt and decrypt user passwords.
#init
encryptionlist = (('a','q'), ('b','w'), ('c','e'), ('d','r'), ('e','t'), ('f','y'), ('g','u'), ('h','i'), ('i','o'), ('j','p'), ('k','a'), ('l','s'), ('m','d'), ('n','f'), ('o','g'), ('p','h'), ('q','j'), ('r','k'), ('s','l'), ('t','z'), ('u','x'), ('v','c'), ('w','v'), ('x','b'), ('y','n'), ('z','m'))
print('This program will encrypt and decrypt user passwords')
#Program Menu
ans=True
while True:
print('1. Enter 1 to encrypt a password: ')
print('2. Enter 2 to decrypt a password: ')
print('3. Exit/Quit')
ans = input('What do you want to do? ')
if ans=="1":
print("\n Enter 1 to encrypt a password: ")
Password = float(input('Enter Password: '))
print('Your new encryptid password is:',Password,'')
if ans=="2":
print("\n Enter 2 to decrypt a password: ")
Password = float(input('Enter Password: '))
print('Your new decryptid password is:',Password,'')
elif ans=="3":
print("\n Goodbye")
break
else:
print("\n Not Valid Choice Try Again")
| 0debug |
Using new Unity VideoPlayer and VideoClip API to play video : <p><a href="https://docs.unity3d.com/ScriptReference/MovieTexture.html" rel="noreferrer"><em>MovieTexture</em></a> is finally deprecated after Unity 5.6.0b1 release and new API that plays video on both Desktop and Mobile devices is now released.</p>
<p><a href="https://docs.unity3d.com/560/Documentation/ScriptReference/Video.VideoPlayer.html" rel="noreferrer"><em>VideoPlayer</em></a> and <a href="https://docs.unity3d.com/560/Documentation/ScriptReference/Video.VideoClip.html" rel="noreferrer"><em>VideoClip</em></a> can be used to play video and retrieve texture for each frame if needed.</p>
<p>I've managed to get the video working but coduldn't get the audio to play as-well from the Editor on Windows 10. Anyone know why audio is not playing?</p>
<pre><code>//Raw Image to Show Video Images [Assign from the Editor]
public RawImage image;
//Video To Play [Assign from the Editor]
public VideoClip videoToPlay;
private VideoPlayer videoPlayer;
private VideoSource videoSource;
//Audio
private AudioSource audioSource;
// Use this for initialization
void Start()
{
Application.runInBackground = true;
StartCoroutine(playVideo());
}
IEnumerator playVideo()
{
//Add VideoPlayer to the GameObject
videoPlayer = gameObject.AddComponent<VideoPlayer>();
//Add AudioSource
audioSource = gameObject.AddComponent<AudioSource>();
//Disable Play on Awake for both Video and Audio
videoPlayer.playOnAwake = false;
audioSource.playOnAwake = false;
//We want to play from video clip not from url
videoPlayer.source = VideoSource.VideoClip;
//Set video To Play then prepare Audio to prevent Buffering
videoPlayer.clip = videoToPlay;
videoPlayer.Prepare();
//Wait until video is prepared
while (!videoPlayer.isPrepared)
{
Debug.Log("Preparing Video");
yield return null;
}
Debug.Log("Done Preparing Video");
//Set Audio Output to AudioSource
videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
//Assign the Audio from Video to AudioSource to be played
videoPlayer.EnableAudioTrack(0, true);
videoPlayer.SetTargetAudioSource(0, audioSource);
//Assign the Texture from Video to RawImage to be displayed
image.texture = videoPlayer.texture;
//Play Video
videoPlayer.Play();
//Play Sound
audioSource.Play();
Debug.Log("Playing Video");
while (videoPlayer.isPlaying)
{
Debug.LogWarning("Video Time: " + Mathf.FloorToInt((float)videoPlayer.time));
yield return null;
}
Debug.Log("Done Playing Video");
}
</code></pre>
| 0debug |
How do you pass in a dynamic form name in redux form? : <p>Im trying to use this code to pass a dynamic form name into reduxForm.</p>
<p>Here is the code that I found:</p>
<pre><code>let FormAddress = compose(connect((state, props) => ({form: props.form})), reduxForm({destroyOnUnmount: false, asyncBlurFields: []}))(ValidationForm);
</code></pre>
<p>From this article:
<a href="https://github.com/erikras/redux-form/issues/603#issuecomment-254271319" rel="noreferrer">https://github.com/erikras/redux-form/issues/603#issuecomment-254271319</a></p>
<p>But I'm not really sure whats going on.</p>
<p>This is how I'm currently doing it:</p>
<pre><code>const formName = 'shippingAddress';
const form = reduxForm({
form: formName
});
export default connect(mapStateToProps)(CityStateZip);
</code></pre>
<p>But I would like to be able to pass it in using props, like this:</p>
<pre><code>const formName = 'shippingAddress';
const form = reduxForm({
form: props.form
// validate
});
export default connect(mapStateToProps)(CityStateZip);
</code></pre>
<p>But when I try that, it complains that it doesnt know what props is - because I believe it's outside the scope of the function above.</p>
<p>Can someone help me?</p>
| 0debug |
create a new column or field with PHP PDO : I have found this platform very educative and have helped me this far in coding with pdo, please help with this:
How do i create a new column or field (idnew) in an existing access database (resultdb) using PHP PDO?. | 0debug |
void qmp_drive_backup(const char *device, const char *target,
bool has_format, const char *format,
enum MirrorSyncMode sync,
bool has_mode, enum NewImageMode mode,
bool has_speed, int64_t speed,
bool has_on_source_error, BlockdevOnError on_source_error,
bool has_on_target_error, BlockdevOnError on_target_error,
Error **errp)
{
BlockDriverState *bs;
BlockDriverState *target_bs;
BlockDriverState *source = NULL;
AioContext *aio_context;
BlockDriver *drv = NULL;
Error *local_err = NULL;
int flags;
int64_t size;
int ret;
if (!has_speed) {
speed = 0;
}
if (!has_on_source_error) {
on_source_error = BLOCKDEV_ON_ERROR_REPORT;
}
if (!has_on_target_error) {
on_target_error = BLOCKDEV_ON_ERROR_REPORT;
}
if (!has_mode) {
mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
}
bs = bdrv_find(device);
if (!bs) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return;
}
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
if (!bdrv_is_inserted(bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
goto out;
}
if (!has_format) {
format = mode == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name;
}
if (format) {
drv = bdrv_find_format(format);
if (!drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
goto out;
}
}
if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_BACKUP_SOURCE, errp)) {
goto out;
}
flags = bs->open_flags | BDRV_O_RDWR;
if (sync == MIRROR_SYNC_MODE_TOP) {
source = bs->backing_hd;
if (!source) {
sync = MIRROR_SYNC_MODE_FULL;
}
}
if (sync == MIRROR_SYNC_MODE_NONE) {
source = bs;
}
size = bdrv_getlength(bs);
if (size < 0) {
error_setg_errno(errp, -size, "bdrv_getlength failed");
goto out;
}
if (mode != NEW_IMAGE_MODE_EXISTING) {
assert(format && drv);
if (source) {
bdrv_img_create(target, format, source->filename,
source->drv->format_name, NULL,
size, flags, &local_err, false);
} else {
bdrv_img_create(target, format, NULL, NULL, NULL,
size, flags, &local_err, false);
}
}
if (local_err) {
error_propagate(errp, local_err);
goto out;
}
target_bs = NULL;
ret = bdrv_open(&target_bs, target, NULL, NULL, flags, drv, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
goto out;
}
bdrv_set_aio_context(target_bs, aio_context);
backup_start(bs, target_bs, speed, sync, on_source_error, on_target_error,
block_job_cb, bs, &local_err);
if (local_err != NULL) {
bdrv_unref(target_bs);
error_propagate(errp, local_err);
goto out;
}
out:
aio_context_release(aio_context);
} | 1threat |
How can I create five pointed stars in canvas using function? : <p>how can I create this 3 stars in canvas using </p>
<pre><code>function filledStar(x,y,a){code}
filledStar(40,50,75);
filledStar(130,120,100);
filledStar(250,220,150);
</code></pre>
<p>should show:</p>
<p><a href="https://i.stack.imgur.com/Kw0Of.jpg" rel="nofollow noreferrer">3starsIMG</a></p>
<p>Thanks</p>
| 0debug |
strtoupper isn't working in my code : <pre><code><?php
if(!empty($_POST['code'])){
$code = strtoupper($code);
$param[':code'] = $_POST['code'];
$sql .= 'AND `code` = :code';
}
?>
</code></pre>
<p>strtoupper don't working. Why? Any advices?</p>
| 0debug |
Angular2 router 2.0.0 not reloading components when same url loaded with different parameters? : <p>I have this in my .routing.ts file</p>
<pre><code>export const routing = RouterModule.forChild([
{
path: 'page/:id',
component: PageComponent
}]);
</code></pre>
<p>My <code>PageComponent</code> file checks the id parameter and loads the data accordingly. In previous versions of the router, if i went from /page/4 to /page/25, the page would "reload" and the components would update.</p>
<p>Now when i try navigating to /page/X where X is the id, it only ever loads the first time, then the url changes, but the components do not "reload" again.</p>
<p>Is there something that needs to be passed in to force my components to reload, and call the ngOnInit event?</p>
| 0debug |
static av_cold int vdadec_init(AVCodecContext *avctx)
{
VDADecoderContext *ctx = avctx->priv_data;
struct vda_context *vda_ctx = &ctx->vda_ctx;
OSStatus status;
int ret;
ctx->h264_initialized = 0;
if (!ff_h264_vda_decoder.pix_fmts) {
if (kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber10_7)
ff_h264_vda_decoder.pix_fmts = vda_pixfmts_prior_10_7;
else
ff_h264_vda_decoder.pix_fmts = vda_pixfmts;
}
memset(vda_ctx, 0, sizeof(struct vda_context));
vda_ctx->width = avctx->width;
vda_ctx->height = avctx->height;
vda_ctx->format = 'avc1';
vda_ctx->use_sync_decoding = 1;
vda_ctx->use_ref_buffer = 1;
ctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts);
switch (ctx->pix_fmt) {
case AV_PIX_FMT_UYVY422:
vda_ctx->cv_pix_fmt_type = '2vuy';
break;
case AV_PIX_FMT_YUYV422:
vda_ctx->cv_pix_fmt_type = 'yuvs';
break;
case AV_PIX_FMT_NV12:
vda_ctx->cv_pix_fmt_type = '420v';
break;
case AV_PIX_FMT_YUV420P:
vda_ctx->cv_pix_fmt_type = 'y420';
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format: %d\n", avctx->pix_fmt);
goto failed;
}
status = ff_vda_create_decoder(vda_ctx,
avctx->extradata, avctx->extradata_size);
if (status != kVDADecoderNoErr) {
av_log(avctx, AV_LOG_ERROR,
"Failed to init VDA decoder: %d.\n", status);
goto failed;
}
avctx->hwaccel_context = vda_ctx;
avctx->get_format = get_format;
avctx->get_buffer2 = get_buffer2;
#if FF_API_GET_BUFFER
avctx->get_buffer = NULL;
#endif
ret = ff_h264_decoder.init(avctx);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to open H.264 decoder.\n");
goto failed;
}
ctx->h264_initialized = 1;
return 0;
failed:
vdadec_close(avctx);
return -1;
}
| 1threat |
Electron IPC and nodeIntegration : <p>So, I've followed a number of guides to set up Webpack, Electron, and React to make a desktop application. After finishing the setup, I got to work, and learned that I needed to require an IPC mechanism from the main and renderer in order to communicate.</p>
<p><code>import {ipcRenderer} from "electron";</code>
Adding this to my renderer.js file causes the error <code>Uncaught ReferenceError: require is not defined</code>.</p>
<p>After taking my problem to some colleagues, it was suggested that in my main.js file I should change</p>
<pre><code>webPreferences: {
nodeIntegration: false,
}
</code></pre>
<p>to</p>
<pre><code>webPreferences: {
nodeIntegration: true,
}
</code></pre>
<p>Everywhere I've read on google has said very clearly that if safety is something you care about, this is <em>not</em> something you should do. However, every resource I've been able to come across for electron ipc has used the ipcRenderer.</p>
<p>Now, does every example on the internet have huge security flaws, or am I missing some key part here?</p>
<p>My questions are as follows.</p>
<ol>
<li>Is it possible to use ipcRenderer without enabling nodeIntegration?</li>
<li>If it is, how do I do it, and why would so many resources exclude this information?</li>
<li>If it is not, what do I use?</li>
</ol>
<p>If I'm asking the wrong question, or I missed something, or there are any other clear problems with the way I've asked this question please let me know, otherwise thanks in advance.</p>
| 0debug |
static void decode_hrd(HEVCContext *s, int common_inf_present,
int max_sublayers)
{
GetBitContext *gb = &s->HEVClc.gb;
int nal_params_present = 0, vcl_params_present = 0;
int subpic_params_present = 0;
int i;
if (common_inf_present) {
nal_params_present = get_bits1(gb);
vcl_params_present = get_bits1(gb);
if (nal_params_present || vcl_params_present) {
subpic_params_present = get_bits1(gb);
if (subpic_params_present) {
skip_bits(gb, 8);
skip_bits(gb, 5);
skip_bits(gb, 1);
skip_bits(gb, 5);
}
skip_bits(gb, 4);
skip_bits(gb, 4);
if (subpic_params_present)
skip_bits(gb, 4);
skip_bits(gb, 5);
skip_bits(gb, 5);
skip_bits(gb, 5);
}
}
for (i = 0; i < max_sublayers; i++) {
int low_delay = 0;
int nb_cpb = 1;
int fixed_rate = get_bits1(gb);
if (!fixed_rate)
fixed_rate = get_bits1(gb);
if (fixed_rate)
get_ue_golomb_long(gb);
else
low_delay = get_bits1(gb);
if (!low_delay)
nb_cpb = get_ue_golomb_long(gb) + 1;
if (nal_params_present)
decode_sublayer_hrd(s, nb_cpb, subpic_params_present);
if (vcl_params_present)
decode_sublayer_hrd(s, nb_cpb, subpic_params_present);
}
}
| 1threat |
How to pass vaule of cell of datagridview to another form : There are two forms.In first form there is a textbox and a picture box.When picture box is clicked it opens the second form which contains a datagridview.What i want is when i clicked on the cell of a datagridview its value should be shown in the textbox of first form.I do not want to create object of first form in second form because data of grid views has to be passed to multiple forms | 0debug |
How to get Python function that prints a word to print on same line with for loop? : <p>I've got a function in Python</p>
<pre><code>def wordPrint():
print "word"
</code></pre>
<p>I want to use it to print 3 times on the same line using a for loop.</p>
<p>I would expect this code</p>
<pre><code>for x in range(0,3):
wordPrint(),
</code></pre>
<p>to output this</p>
<p><code>word word word</code></p>
<p>But I get them on new lines</p>
| 0debug |
have a difficulty using dictionaries to translate normal text to morse code : ^
actually i´m writing a program that translate normal text to Morse code
and i´ve written the core program that translate single letters to morse code but i´m still can´t figure out how to translate whole words and text here´s the code that i´ve written i´ve just started python 2 weeks ago so i´m somehow just a beginner
from tkinter import *
#key down function
def click():
entered_text=textentry.get() #this wil collect the text from the text entry box
outpout.delete(0.0, END)
try:
definition = my_dictionary[entered_text]
except:
definition= "sorry an error occured"
outpout.insert(END, definition)
#### main
window = Tk()
window.title("THIS IS A SIMPLE TITLE")
window.configure(background="yellow")
[here´s the gui app][1]
#create label
Label (window,text="Enter a text here.", bg="YELLOW", fg="BLACK", font="arial 30 bold italic" ) .grid(row=1, column=0, sticky=W)
#create a text entry box
textentry= Entry(window, width=20, bg="WHITE")
textentry.grid(row=2, column=0, sticky=W)
#add a submit button
Button(window, text="SUBMIT", width=6, command=click) .grid(row=3 ,column=0, sticky=W)
#create another label
Label (window,text="THE ENCRYPTED TEXT IS:", bg="YELLOW", fg="BLACK", font="arial 10 bold" ) .grid(row=4, column=0, sticky=W)
#create a text box
outpout = Text(window, width=75, height=6, wrap=WORD, bg="WHITE")
outpout.grid(row=5, column=0, columnspan=2, sticky=W)
#the dictionary
my_dictionary = {
"A" : ".-",
"B" : "-...",
"C" : "-.-.",
"D" : "-..",
"E" : ".",
"F" : "..-.",
"G" : "--.",
"H" : "....",
"I" : "..",
"J" : ".---",
"K" : "-.-",
"L" : ".-..",
"M" : "--",
"N" : "-.",
"O" : "---",
"P" : ".--.",
"Q" : "--.-",
"R" : ".-.",
"S" : "...",
"T" : "-",
"U" : "..-",
"V" : "...-",
"W" : ".--",
"X" : "-..-",
"Y" : "-.--",
"Z" : "--..",
" " : "/"
}
#run the main loop
window.mainloop()
[1]: https://i.stack.imgur.com/qme59.png | 0debug |
Undefined property: PDOStatement::$num_rows : <p>This doesn't work:</p>
<p>// Extract data items from dataset</p>
<p>I've been all over the web for two days, including previous answers here</p>
<pre><code> if ($result-> num_rows > 0)
{
while($row = $result-> fetch_assoc())
</code></pre>
<p>Connected successfully
Notice: Undefined property: PDOStatement::$num_rows in E:\web\peoplespoll\htdocs\TableTest.php on line 64
0 result
Fatal error: Uncaught Error: Call to undefined method PDO::close() in E:\web\peoplespoll\htdocs\TableTest.php:83 Stack trace: #0 {main} thrown in E:\web\peoplespoll\htdocs\TableTest.php on line 83</p>
| 0debug |
Hackerrank challenge timout : <p>hey i am just trying to solve a challenge on hackerrank but in some test cases the code timeouts and i don't know why. <a href="https://www.hackerrank.com/challenges/circular-array-rotation" rel="nofollow noreferrer">This is the challenge</a>.</p>
<p>And here is my code:</p>
<pre><code>#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
int main(){
int n, k, q;
scanf("%d %d %d",&n,&k,&q);
int qs[q];
int a[n];
for(int i = 0; i < n; i++){
scanf("%d", &a[i]);
}
for(int i = 0; i < q; i++){
scanf("%d",&qs[i]);
}
int lastNbr = a[n-1];
for(int i = 0; i < k; i++){
lastNbr = a[n-1];
for(int j = n - 1; j > -1; j--){
a[j] = (j-1 >= 0) ? a[j-1] : lastNbr;
}
}
for(int i = 0; i < q; i++){
printf("%d\n", a[qs[i]]);
}
return 0;
}
</code></pre>
| 0debug |
Can someone explain the StartCoroutine Unity : <p>I know it is used for delays like WaitUntil or WaitSeconds, but what is the real use for it.</p>
| 0debug |
static inline void fill_caches(H264Context *h, int mb_type, int for_deblock){
MpegEncContext * const s = &h->s;
const int mb_xy= s->mb_x + s->mb_y*s->mb_stride;
int topleft_xy, top_xy, topright_xy, left_xy[2];
int topleft_type, top_type, topright_type, left_type[2];
int left_block[4];
int i;
if(h->sps.mb_aff){
topleft_xy = 0;
top_xy = 0;
topright_xy = 0;
}else{
topleft_xy = mb_xy-1 - s->mb_stride;
top_xy = mb_xy - s->mb_stride;
topright_xy= mb_xy+1 - s->mb_stride;
left_xy[0] = mb_xy-1;
left_xy[1] = mb_xy-1;
left_block[0]= 0;
left_block[1]= 1;
left_block[2]= 2;
left_block[3]= 3;
}
if(for_deblock){
topleft_type = h->slice_table[topleft_xy ] < 255 ? s->current_picture.mb_type[topleft_xy] : 0;
top_type = h->slice_table[top_xy ] < 255 ? s->current_picture.mb_type[top_xy] : 0;
topright_type= h->slice_table[topright_xy] < 255 ? s->current_picture.mb_type[topright_xy]: 0;
left_type[0] = h->slice_table[left_xy[0] ] < 255 ? s->current_picture.mb_type[left_xy[0]] : 0;
left_type[1] = h->slice_table[left_xy[1] ] < 255 ? s->current_picture.mb_type[left_xy[1]] : 0;
}else{
topleft_type = h->slice_table[topleft_xy ] == h->slice_num ? s->current_picture.mb_type[topleft_xy] : 0;
top_type = h->slice_table[top_xy ] == h->slice_num ? s->current_picture.mb_type[top_xy] : 0;
topright_type= h->slice_table[topright_xy] == h->slice_num ? s->current_picture.mb_type[topright_xy]: 0;
left_type[0] = h->slice_table[left_xy[0] ] == h->slice_num ? s->current_picture.mb_type[left_xy[0]] : 0;
left_type[1] = h->slice_table[left_xy[1] ] == h->slice_num ? s->current_picture.mb_type[left_xy[1]] : 0;
}
if(IS_INTRA(mb_type)){
h->topleft_samples_available=
h->top_samples_available=
h->left_samples_available= 0xFFFF;
h->topright_samples_available= 0xEEEA;
if(!IS_INTRA(top_type) && (top_type==0 || h->pps.constrained_intra_pred)){
h->topleft_samples_available= 0xB3FF;
h->top_samples_available= 0x33FF;
h->topright_samples_available= 0x26EA;
}
for(i=0; i<2; i++){
if(!IS_INTRA(left_type[i]) && (left_type[i]==0 || h->pps.constrained_intra_pred)){
h->topleft_samples_available&= 0xDF5F;
h->left_samples_available&= 0x5F5F;
}
}
if(!IS_INTRA(topleft_type) && (topleft_type==0 || h->pps.constrained_intra_pred))
h->topleft_samples_available&= 0x7FFF;
if(!IS_INTRA(topright_type) && (topright_type==0 || h->pps.constrained_intra_pred))
h->topright_samples_available&= 0xFBFF;
if(IS_INTRA4x4(mb_type)){
if(IS_INTRA4x4(top_type)){
h->intra4x4_pred_mode_cache[4+8*0]= h->intra4x4_pred_mode[top_xy][4];
h->intra4x4_pred_mode_cache[5+8*0]= h->intra4x4_pred_mode[top_xy][5];
h->intra4x4_pred_mode_cache[6+8*0]= h->intra4x4_pred_mode[top_xy][6];
h->intra4x4_pred_mode_cache[7+8*0]= h->intra4x4_pred_mode[top_xy][3];
}else{
int pred;
if(!top_type || (IS_INTER(top_type) && h->pps.constrained_intra_pred))
pred= -1;
else{
pred= 2;
}
h->intra4x4_pred_mode_cache[4+8*0]=
h->intra4x4_pred_mode_cache[5+8*0]=
h->intra4x4_pred_mode_cache[6+8*0]=
h->intra4x4_pred_mode_cache[7+8*0]= pred;
}
for(i=0; i<2; i++){
if(IS_INTRA4x4(left_type[i])){
h->intra4x4_pred_mode_cache[3+8*1 + 2*8*i]= h->intra4x4_pred_mode[left_xy[i]][left_block[0+2*i]];
h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= h->intra4x4_pred_mode[left_xy[i]][left_block[1+2*i]];
}else{
int pred;
if(!left_type[i] || (IS_INTER(left_type[i]) && h->pps.constrained_intra_pred))
pred= -1;
else{
pred= 2;
}
h->intra4x4_pred_mode_cache[3+8*1 + 2*8*i]=
h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= pred;
}
}
}
}
constraint_intra_pred & partitioning & nnz (lets hope this is just a typo in the spec)
if(top_type){
h->non_zero_count_cache[4+8*0]= h->non_zero_count[top_xy][0];
h->non_zero_count_cache[5+8*0]= h->non_zero_count[top_xy][1];
h->non_zero_count_cache[6+8*0]= h->non_zero_count[top_xy][2];
h->non_zero_count_cache[7+8*0]= h->non_zero_count[top_xy][3];
h->non_zero_count_cache[1+8*0]= h->non_zero_count[top_xy][7];
h->non_zero_count_cache[2+8*0]= h->non_zero_count[top_xy][8];
h->non_zero_count_cache[1+8*3]= h->non_zero_count[top_xy][10];
h->non_zero_count_cache[2+8*3]= h->non_zero_count[top_xy][11];
h->top_cbp= h->cbp_table[top_xy];
}else{
h->non_zero_count_cache[4+8*0]=
h->non_zero_count_cache[5+8*0]=
h->non_zero_count_cache[6+8*0]=
h->non_zero_count_cache[7+8*0]=
h->non_zero_count_cache[1+8*0]=
h->non_zero_count_cache[2+8*0]=
h->non_zero_count_cache[1+8*3]=
h->non_zero_count_cache[2+8*3]= h->pps.cabac && !IS_INTRA(mb_type) ? 0 : 64;
if(IS_INTRA(mb_type)) h->top_cbp= 0x1C0;
else h->top_cbp= 0;
}
if(left_type[0]){
h->non_zero_count_cache[3+8*1]= h->non_zero_count[left_xy[0]][6];
h->non_zero_count_cache[3+8*2]= h->non_zero_count[left_xy[0]][5];
h->non_zero_count_cache[0+8*1]= h->non_zero_count[left_xy[0]][9]; left_block
h->non_zero_count_cache[0+8*4]= h->non_zero_count[left_xy[0]][12];
h->left_cbp= h->cbp_table[left_xy[0]]; interlacing
}else{
h->non_zero_count_cache[3+8*1]=
h->non_zero_count_cache[3+8*2]=
h->non_zero_count_cache[0+8*1]=
h->non_zero_count_cache[0+8*4]= h->pps.cabac && !IS_INTRA(mb_type) ? 0 : 64;
if(IS_INTRA(mb_type)) h->left_cbp= 0x1C0; interlacing
else h->left_cbp= 0;
}
if(left_type[1]){
h->non_zero_count_cache[3+8*3]= h->non_zero_count[left_xy[1]][4];
h->non_zero_count_cache[3+8*4]= h->non_zero_count[left_xy[1]][3];
h->non_zero_count_cache[0+8*2]= h->non_zero_count[left_xy[1]][8];
h->non_zero_count_cache[0+8*5]= h->non_zero_count[left_xy[1]][11];
}else{
h->non_zero_count_cache[3+8*3]=
h->non_zero_count_cache[3+8*4]=
h->non_zero_count_cache[0+8*2]=
h->non_zero_count_cache[0+8*5]= h->pps.cabac && !IS_INTRA(mb_type) ? 0 : 64;
}
#if 1
direct mb can skip much of this
if(IS_INTER(mb_type) || (IS_DIRECT(mb_type) && h->direct_spatial_mv_pred)){
int list;
for(list=0; list<2; list++){
if((!IS_8X8(mb_type)) && !USES_LIST(mb_type, list) && !IS_DIRECT(mb_type)){
/*if(!h->mv_cache_clean[list]){
memset(h->mv_cache [list], 0, 8*5*2*sizeof(int16_t)); clean only input? clean at all?
memset(h->ref_cache[list], PART_NOT_AVAILABLE, 8*5*sizeof(int8_t));
h->mv_cache_clean[list]= 1;
}*/
continue;
}
h->mv_cache_clean[list]= 0;
if(IS_INTER(topleft_type)){
const int b_xy = h->mb2b_xy[topleft_xy] + 3 + 3*h->b_stride;
const int b8_xy= h->mb2b8_xy[topleft_xy] + 1 + h->b8_stride;
*(uint32_t*)h->mv_cache[list][scan8[0] - 1 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy];
h->ref_cache[list][scan8[0] - 1 - 1*8]= s->current_picture.ref_index[list][b8_xy];
}else{
*(uint32_t*)h->mv_cache[list][scan8[0] - 1 - 1*8]= 0;
h->ref_cache[list][scan8[0] - 1 - 1*8]= topleft_type ? LIST_NOT_USED : PART_NOT_AVAILABLE;
}
if(IS_INTER(top_type)){
const int b_xy= h->mb2b_xy[top_xy] + 3*h->b_stride;
const int b8_xy= h->mb2b8_xy[top_xy] + h->b8_stride;
*(uint32_t*)h->mv_cache[list][scan8[0] + 0 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + 0];
*(uint32_t*)h->mv_cache[list][scan8[0] + 1 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + 1];
*(uint32_t*)h->mv_cache[list][scan8[0] + 2 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + 2];
*(uint32_t*)h->mv_cache[list][scan8[0] + 3 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + 3];
h->ref_cache[list][scan8[0] + 0 - 1*8]=
h->ref_cache[list][scan8[0] + 1 - 1*8]= s->current_picture.ref_index[list][b8_xy + 0];
h->ref_cache[list][scan8[0] + 2 - 1*8]=
h->ref_cache[list][scan8[0] + 3 - 1*8]= s->current_picture.ref_index[list][b8_xy + 1];
}else{
*(uint32_t*)h->mv_cache [list][scan8[0] + 0 - 1*8]=
*(uint32_t*)h->mv_cache [list][scan8[0] + 1 - 1*8]=
*(uint32_t*)h->mv_cache [list][scan8[0] + 2 - 1*8]=
*(uint32_t*)h->mv_cache [list][scan8[0] + 3 - 1*8]= 0;
*(uint32_t*)&h->ref_cache[list][scan8[0] + 0 - 1*8]= ((top_type ? LIST_NOT_USED : PART_NOT_AVAILABLE)&0xFF)*0x01010101;
}
if(IS_INTER(topright_type)){
const int b_xy= h->mb2b_xy[topright_xy] + 3*h->b_stride;
const int b8_xy= h->mb2b8_xy[topright_xy] + h->b8_stride;
*(uint32_t*)h->mv_cache[list][scan8[0] + 4 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy];
h->ref_cache[list][scan8[0] + 4 - 1*8]= s->current_picture.ref_index[list][b8_xy];
}else{
*(uint32_t*)h->mv_cache [list][scan8[0] + 4 - 1*8]= 0;
h->ref_cache[list][scan8[0] + 4 - 1*8]= topright_type ? LIST_NOT_USED : PART_NOT_AVAILABLE;
}
unify cleanup or sth
if(IS_INTER(left_type[0])){
const int b_xy= h->mb2b_xy[left_xy[0]] + 3;
const int b8_xy= h->mb2b8_xy[left_xy[0]] + 1;
*(uint32_t*)h->mv_cache[list][scan8[0] - 1 + 0*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[0]];
*(uint32_t*)h->mv_cache[list][scan8[0] - 1 + 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[1]];
h->ref_cache[list][scan8[0] - 1 + 0*8]=
h->ref_cache[list][scan8[0] - 1 + 1*8]= s->current_picture.ref_index[list][b8_xy + h->b8_stride*(left_block[0]>>1)];
}else{
*(uint32_t*)h->mv_cache [list][scan8[0] - 1 + 0*8]=
*(uint32_t*)h->mv_cache [list][scan8[0] - 1 + 1*8]= 0;
h->ref_cache[list][scan8[0] - 1 + 0*8]=
h->ref_cache[list][scan8[0] - 1 + 1*8]= left_type[0] ? LIST_NOT_USED : PART_NOT_AVAILABLE;
}
if(IS_INTER(left_type[1])){
const int b_xy= h->mb2b_xy[left_xy[1]] + 3;
const int b8_xy= h->mb2b8_xy[left_xy[1]] + 1;
*(uint32_t*)h->mv_cache[list][scan8[0] - 1 + 2*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[2]];
*(uint32_t*)h->mv_cache[list][scan8[0] - 1 + 3*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[3]];
h->ref_cache[list][scan8[0] - 1 + 2*8]=
h->ref_cache[list][scan8[0] - 1 + 3*8]= s->current_picture.ref_index[list][b8_xy + h->b8_stride*(left_block[2]>>1)];
}else{
*(uint32_t*)h->mv_cache [list][scan8[0] - 1 + 2*8]=
*(uint32_t*)h->mv_cache [list][scan8[0] - 1 + 3*8]= 0;
h->ref_cache[list][scan8[0] - 1 + 2*8]=
h->ref_cache[list][scan8[0] - 1 + 3*8]= left_type[0] ? LIST_NOT_USED : PART_NOT_AVAILABLE;
}
if(for_deblock)
continue;
h->ref_cache[list][scan8[5 ]+1] =
h->ref_cache[list][scan8[7 ]+1] =
h->ref_cache[list][scan8[13]+1] = remove past 3 (init somewher else)
h->ref_cache[list][scan8[4 ]] =
h->ref_cache[list][scan8[12]] = PART_NOT_AVAILABLE;
*(uint32_t*)h->mv_cache [list][scan8[5 ]+1]=
*(uint32_t*)h->mv_cache [list][scan8[7 ]+1]=
*(uint32_t*)h->mv_cache [list][scan8[13]+1]= remove past 3 (init somewher else)
*(uint32_t*)h->mv_cache [list][scan8[4 ]]=
*(uint32_t*)h->mv_cache [list][scan8[12]]= 0;
if( h->pps.cabac ) {
if(IS_INTER(topleft_type)){
const int b_xy = h->mb2b_xy[topleft_xy] + 3 + 3*h->b_stride;
*(uint32_t*)h->mvd_cache[list][scan8[0] - 1 - 1*8]= *(uint32_t*)h->mvd_table[list][b_xy];
}else{
*(uint32_t*)h->mvd_cache[list][scan8[0] - 1 - 1*8]= 0;
}
if(IS_INTER(top_type)){
const int b_xy= h->mb2b_xy[top_xy] + 3*h->b_stride;
*(uint32_t*)h->mvd_cache[list][scan8[0] + 0 - 1*8]= *(uint32_t*)h->mvd_table[list][b_xy + 0];
*(uint32_t*)h->mvd_cache[list][scan8[0] + 1 - 1*8]= *(uint32_t*)h->mvd_table[list][b_xy + 1];
*(uint32_t*)h->mvd_cache[list][scan8[0] + 2 - 1*8]= *(uint32_t*)h->mvd_table[list][b_xy + 2];
*(uint32_t*)h->mvd_cache[list][scan8[0] + 3 - 1*8]= *(uint32_t*)h->mvd_table[list][b_xy + 3];
}else{
*(uint32_t*)h->mvd_cache [list][scan8[0] + 0 - 1*8]=
*(uint32_t*)h->mvd_cache [list][scan8[0] + 1 - 1*8]=
*(uint32_t*)h->mvd_cache [list][scan8[0] + 2 - 1*8]=
*(uint32_t*)h->mvd_cache [list][scan8[0] + 3 - 1*8]= 0;
}
if(IS_INTER(left_type[0])){
const int b_xy= h->mb2b_xy[left_xy[0]] + 3;
*(uint32_t*)h->mvd_cache[list][scan8[0] - 1 + 0*8]= *(uint32_t*)h->mvd_table[list][b_xy + h->b_stride*left_block[0]];
*(uint32_t*)h->mvd_cache[list][scan8[0] - 1 + 1*8]= *(uint32_t*)h->mvd_table[list][b_xy + h->b_stride*left_block[1]];
}else{
*(uint32_t*)h->mvd_cache [list][scan8[0] - 1 + 0*8]=
*(uint32_t*)h->mvd_cache [list][scan8[0] - 1 + 1*8]= 0;
}
if(IS_INTER(left_type[1])){
const int b_xy= h->mb2b_xy[left_xy[1]] + 3;
*(uint32_t*)h->mvd_cache[list][scan8[0] - 1 + 2*8]= *(uint32_t*)h->mvd_table[list][b_xy + h->b_stride*left_block[2]];
*(uint32_t*)h->mvd_cache[list][scan8[0] - 1 + 3*8]= *(uint32_t*)h->mvd_table[list][b_xy + h->b_stride*left_block[3]];
}else{
*(uint32_t*)h->mvd_cache [list][scan8[0] - 1 + 2*8]=
*(uint32_t*)h->mvd_cache [list][scan8[0] - 1 + 3*8]= 0;
}
*(uint32_t*)h->mvd_cache [list][scan8[5 ]+1]=
*(uint32_t*)h->mvd_cache [list][scan8[7 ]+1]=
*(uint32_t*)h->mvd_cache [list][scan8[13]+1]= remove past 3 (init somewher else)
*(uint32_t*)h->mvd_cache [list][scan8[4 ]]=
*(uint32_t*)h->mvd_cache [list][scan8[12]]= 0;
if(h->slice_type == B_TYPE){
fill_rectangle(&h->direct_cache[scan8[0]], 4, 4, 8, 0, 1);
if(IS_DIRECT(top_type)){
*(uint32_t*)&h->direct_cache[scan8[0] - 1*8]= 0x01010101;
}else if(IS_8X8(top_type)){
int b8_xy = h->mb2b8_xy[top_xy] + h->b8_stride;
h->direct_cache[scan8[0] + 0 - 1*8]= h->direct_table[b8_xy];
h->direct_cache[scan8[0] + 2 - 1*8]= h->direct_table[b8_xy + 1];
}else{
*(uint32_t*)&h->direct_cache[scan8[0] - 1*8]= 0;
}
interlacing
if(IS_DIRECT(left_type[0])){
h->direct_cache[scan8[0] - 1 + 0*8]=
h->direct_cache[scan8[0] - 1 + 2*8]= 1;
}else if(IS_8X8(left_type[0])){
int b8_xy = h->mb2b8_xy[left_xy[0]] + 1;
h->direct_cache[scan8[0] - 1 + 0*8]= h->direct_table[b8_xy];
h->direct_cache[scan8[0] - 1 + 2*8]= h->direct_table[b8_xy + h->b8_stride];
}else{
h->direct_cache[scan8[0] - 1 + 0*8]=
h->direct_cache[scan8[0] - 1 + 2*8]= 0;
}
}
}
}
}
#endif
}
| 1threat |
Pythod Code to Print multiple user input string in one string : <p>I have a python code below:</p>
<pre><code>import os
import glob
NumberofAlphabets = input('Enter Number of Alphabets:')
NF = int(NumberofAlphabets)
Input = 1
while Input < NF+1:
AlphabetName = input('Enter Alphabet Name:')
tempF += AlphabetName
Input += 1
print(tempF)
</code></pre>
<p>i want result like this:- </p>
<p>Enter Number of Alphabets: 2<br>
Enter 1 Alphabet Name: a<br>
Enter 2 Alphabet Name: b<br>
Result is a b</p>
| 0debug |
Why can't I still move/delete long file paths in Windows Explorer after enabling the Group Policy in Windows 10? : <p>I have a source code folder with a lot of files and subfolders nested in it. Windows 10 can now supposedly handle long file paths via the Group Policy Editor. I've enabled it already and restarted my computer multiple times.</p>
<p><a href="https://i.stack.imgur.com/jHCyo.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jHCyo.jpg" alt="enter image description here"></a></p>
<p>But trying to delete the source code folder still give this error.</p>
<p><a href="https://i.stack.imgur.com/yyQLQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yyQLQ.jpg" alt="enter image description here"></a></p>
<p>Does anyone know how exactly the new Group Policy works? I was assuming it would work on Windows Explorer itself. I'm using 64-bit Pro Windows 10.</p>
| 0debug |
React-intl multi language app: changing languages and translations storage : <p>I have react-router app and would like to add i18n. In react-intl <a href="https://github.com/yahoo/react-intl#example" rel="noreferrer">example</a> root component wrapped in IntlProvider:</p>
<pre><code>ReactDOM.render(
<IntlProvider locale="en">
<App />
</IntlProvider>,
document.getElementById('container')
</code></pre>
<p>);</p>
<p>But there is only one locale. How to update app for adding other languages and how is the best way to store translations? </p>
| 0debug |
What would the propType be of a JSX prop in react : <p>In react you can set the propType of the props that come into a component. For one of my props I want the value to either be null or a line of JSX. The React docs don't cover what propType should be used for JSX.</p>
<p>When testing this I found that it wouldn't throw errors when using the propTypes of object or element. When using another such as symbol I would get an error that said it was an object. If it was an object surely it should complain when it's an element. </p>
<p>What is the correct propType for JSX?</p>
| 0debug |
Performance issues running nginx in a docker container : <p>I'm using ApacheBench (ab) to measure the performance of two nginx on Linux. They have same config file. The Only difference is one of nginx is running in a docker container.</p>
<p><strong>Nginx on Host System:</strong></p>
<pre><code>Running: ab -n 50000 -c 1000 http://172.17.0.2:7082/
Concurrency Level: 1000
Time taken for tests: 9.376 seconds
Complete requests: 50000
Failed requests: 0
Total transferred: 8050000 bytes
HTML transferred: 250000 bytes
Requests per second: 5332.94 [#/sec] (mean)
Time per request: 187.514 [ms] (mean)
Time per request: 0.188 [ms] (mean, across all concurrent requests)
Transfer rate: 838.48 [Kbytes/sec] received
</code></pre>
<p><strong>Nginx in docker container:</strong></p>
<pre><code>Running: ab -n 50000 -c 1000 http://172.17.0.2:6066/
Concurrency Level: 1000
Time taken for tests: 31.274 seconds
Complete requests: 50000
Failed requests: 0
Total transferred: 8050000 bytes
HTML transferred: 250000 bytes
Requests per second: 1598.76 [#/sec] (mean)
Time per request: 625.484 [ms] (mean)
Time per request: 0.625 [ms] (mean, across all concurrent requests)
Transfer rate: 251.37 [Kbytes/sec] received
</code></pre>
<p>Just wondering why the container one has such a poor performance</p>
<p>nginx.conf:</p>
<pre><code>worker_processes auto;
worker_rlimit_nofile 10240;
events {
use epoll;
multi_accept on;
worker_connections 4096;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 10;
client_header_timeout 10;
client_body_timeout 10;
send_timeout 10;
tcp_nopush on;
tcp_nodelay on;
server {
listen 80;
server_name localhost;
location / {
return 200 'hello';
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
</code></pre>
| 0debug |
Current Date to milliseconds with 10 digits in Swift : <p>I need to convert current date into milliseconds with 10 digits only
for example: 26/09/2019 current date to 1569592800 milliseconds in swift and store it in variable to use it in project<br>
I want to use it in this function: </p>
<pre><code>func fetchPopularGames(for platform: Platform, completion: @escaping (Result<[Game], Error>) -> Void) {
iGDB.apiRequest(endpoint: .GAMES, apicalypseQuery: "fields name, first_release_date, id, popularity, rating, involved_companies.company.name, cover.image_id; where (platforms = (49,130,48,6) & first_release_date > 1569592800); sort first_release_date asc; limit 50;", dataResponse: { bytes in
guard let gameResults = try? Proto_GameResult(serializedData: bytes) else {
return
}
let games = gameResults.games.map { Game(game: $0) }
DispatchQueue.main.async {
completion(.success(games))
}
}, errorResponse: { error in
DispatchQueue.main.async {
completion(.failure(error))
}
})
}
</code></pre>
<p>especially in this part in the query
first_release_date > 1569592800 </p>
| 0debug |
How can I use OOP PHP in this contact form? : <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code> <div class="form">
<div id="errormessage"></div>
<form action="" method="post" role="form" class="contactForm">
<div class="form-row">
<div class="form-group col-md-6">
<input type="text" name="name" class="form-control" id="name" placeholder="Your Name" data-rule="minlen:4" data-msg="Please enter at least 4 chars" />
<div class="validation"></div>
</div>
<div class="form-group col-md-6">
<input type="email" class="form-control" name="email" id="email" placeholder="Your Email" data-rule="email" data-msg="Please enter a valid email" />
<div class="validation"></div>
</div>
</div>
<div class="form-group">
<input type="text" class="form-control" name="subject" id="subject" placeholder="Subject" data-rule="minlen:4" data-msg="Please enter at least 8 chars of subject" />
<div class="validation"></div>
</div>
<div class="form-group">
<textarea class="form-control" name="message" rows="5" data-rule="required" data-msg="Please write something for us" placeholder="Message"></textarea>
<div class="validation"></div>
</div>
<div class="text-center"><button type="submit" name="btnsubmit">Send Message</button></div>
</form>
</div>
</div>
</section></code></pre>
</div>
</div>
</p>
<p>This is the contact for I have database name msolution and table user
how can I use OOP PHP for this contact form
Please if any one can help me in this by providing the code and thank you for your help </p>
| 0debug |
Why does it take double args when calling my class for my class to work? : I am running Python 3.3.4 on Windows 10
The following is my class Code-
class Curl():
def __init__(self):
self.file7 = file7
self.Days1 = Days1
def readfile(self):
ticknum = 0
read_ticker = []
ins = open(file7, "r" )
for line in ins:
if line.endswith('\n'):
line=line[:-1]
read_ticker.append(line)
ticknum =+1
ins.close()
return read_ticker
def CalcDates(self, Days1): # Determine dates
calculated_dates = dict()
Run_Time = (time.strftime("%H/%M/%S"))
calculated_dates['Run_Time']= Run_Time
Today = date.today()
calculated_dates['Today'] = Today
End_Date = (Today - timedelta(days=Days1))
calculated_dates ['Start_Date'] = Today
Start_Day = str(Today.strftime("%d"))
calculated_dates['Start_Day'] = Start_Day
Start_Month = str(Today.strftime("%m"))
calculated_dates['Start_Month'] = Start_Month
Start_Year = str(Today.strftime("%Y"))
calculated_dates['Start_Year']= Start_Year
End_Day = str(End_Date.strftime("%d"))
calculated_dates['End_Day'] = End_Day
End_Month = str(End_Date.strftime("%m"))
calculated_dates['End_Month']= End_Month
End_Year = str(End_Date.strftime("%Y"))
calculated_dates['End_Year']= End_Year
return calculated_dates
It runs if i do the following;
file7 = 'C:\\...\\file1.txt'
fileList = Curl.readfile(file7)
print('readTickers is complete')
print(fileList)
D1= Curl.CalcDates( 90, 90)
print(D1)
I want it to run if i change the line D1 as follows;
D1= Curl.CalcDates(90)
but it doesn't- I get the following error;
Traceback (most recent call last):
File "C:\Users\Edge\Desktop\readTICKR class432.py", line 56, in <module>
D1= Curl.CalcDates(90)
TypeError: CalcDates() missing 1 required positional argument: 'Days1'
Why does it require me to put double arguements when I call Curl.CalcDates ?
How can I fix it so that I can use a single arguement? | 0debug |
alert('Hello ' + user_input); | 1threat |
Max running time : So i's trying to solve a problem and ive run into a bit of an issue
So i have to find the running average of a series of numbers
for input 4 2 7
output 4 3 4.3333
Now heres the problem although i get the answer its not the precise answer
[accuracy difference shown in the image][1]
i cant find whats wrong , some help would be highly appreciated !
#include<stdio.h>
main(){
int n;
printf("set:");
scanf("%d",&n);
float arr[n],resarr[n];
float sum=0;
for(int i=1; i<=n; i++){
scanf("%f",&arr[i]);
sum=arr[i]+sum;
float res= sum/(float)i;
resarr[i]=res;
}
int i=1;
while(i<=n){
printf("%0.10f\n",resarr[i]);
i++;
}
return 0;
}
[1]: https://i.stack.imgur.com/REO0W.png | 0debug |
static int kvm_client_migration_log(struct CPUPhysMemoryClient *client,
int enable)
{
return kvm_set_migration_log(enable);
}
| 1threat |
how to change backgound color for edittext(android) if input is filled or present in that editbox : [I want to apply same yellow color background as their in second input box for the first input box where input is already given inshort how to give same input colour when editbox is focused or input present here is my code i did it for if focused ][1]
[1]: https://i.stack.imgur.com/FoDNB.jpg | 0debug |
how to create python alert box without using Tkinter : I need to create a message box in python without using python Tkinter library so that i can use that before using exit() function this will display the message and ans soon as user press okay user gets out of program. | 0debug |
Understanding compose functions in redux : <p>I was trying to create a store in redux for which I am currently using following syntax:-</p>
<pre><code>const middlewares = [
thunk,
logger
]
const wlStore = createStore(
rootReducer,
initialState
compose(applyMiddleware(...middlewares))
)
</code></pre>
<p>The above works fine for me and I can access the store, but I lately I bumped into another syntax:-</p>
<pre><code>const wlStore=applyMiddleware(thunk,logger)(createStore)(rootReducer)
</code></pre>
<p>Both of them seem to be doing the same job.</p>
<p>Is there any reason because of which I should prefer one over another? Pros/Cons?</p>
| 0debug |
What does the keyword 'TYPE' mean proceeding a parameter in procedure? : I am very new to SQL and tried searching for this online with no avail - I would appreciate any help!
I am looking a procedure in Oracle SQL Developer that looks like something along the lines of this:
PROCEDURE pProcedureOne
(pDateOne DATE,
pDateTwo tableA.DateTwo%TYPE,
pDateThree tableB.DateThree%TYPE,
pTypeOne tableC.TypeOne%TYPE,
pTestId tableD.TestIdentifier%TYPE DEFAULT NULL,
pShouldChange BOOLEAN DEFAULT FALSE)
IS
What does `'%TYPE'` keyword mean in this context? | 0debug |
Python: using def : I'm trying to make a program which calculates how much kilometers a ship passes in one day.
It should look like this:
def journey():
journey_calc = speed * 1852 / 1000 * 24
journey_calc = round(journey_calc)
return journey
speed = 5
print("Ship passes: " +str(journey) " kilometers in one day")
Any suggestions please ?
| 0debug |
Build: Cannot use JSX unless the '--jsx' flag is provided : <p>I am using VS 2013 and tsx files with react. I can build my project manually just fine. (Right click and build solution)</p>
<p>But when I try to publish on Azure, VS tries to build again but at that time I am getting all bunch of errors stated as:</p>
<pre><code>Error 2 Build: Cannot use JSX unless the '--jsx' flag is provided.
</code></pre>
<p>and points to my tsx files.</p>
<p>Seems like Azure Publish using different kind of build steps than VS 2013 does.</p>
<p>How can I fix this issue?</p>
<p><a href="https://i.stack.imgur.com/0yeMs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0yeMs.png" alt="Azure publish error"></a></p>
<p><a href="https://i.stack.imgur.com/HCeVJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HCeVJ.png" alt="VS 2013 errors"></a></p>
| 0debug |
static TargetFdAddrFunc fd_trans_target_to_host_addr(int fd)
{
if (fd < target_fd_max && target_fd_trans[fd]) {
return target_fd_trans[fd]->target_to_host_addr;
}
return NULL;
}
| 1threat |
Run some code php from other file : I have two files
In a.php
<?php echo "one"; include 'b.php'; echo "three"; ?>
In b.php
<?php echo"one"; echo"two"; echo"three"; echo"four"; echo"five"; ?>
My question is how get only (echo"two";) from b.php and what i must write in a.php
I hope anyone understand | 0debug |
how can i do a word wide search on mapkit and not just in certain parameters : I am new to programming and I am trying to do a world wide search for countries and cities.
[this is my location search table][1]
[this is my main VC][2]
[1]: https://i.stack.imgur.com/7pd3w.png
[2]: https://i.stack.imgur.com/cXY9a.png | 0debug |
How can I mock an Observable.throw in an Angular2 test? : <p>I want to test the error handling in my Angular2 component and therefore want to mock a service to return an Observable.throw('error'). How can that be done using Jasmine and Karma and Angular 2?</p>
| 0debug |
Angular2: CoreModule vs SharedModule : <p>Could somebody explain what's a <code>SharedModule</code> and a <code>CoreModule</code> stand for?</p>
<p>I've been watching several project out there are using this approach in order to build its angular projects.</p>
<ol>
<li>Why do I need two modules?</li>
<li>When should I import each one?</li>
<li>Which <code>imports</code>, <code>exports</code>, <code>declarations</code> should each one have?</li>
</ol>
| 0debug |
How can I use gremlin-console to remotely create and access variables? : <p>I remotely connect to a gremlin server using gremlin-console(which is janusgraph), but when I create a variable and access it, it doesn't work. My ultimate goal is to use gremlin-console to create index...</p>
<pre><code>gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Configured localhost/127.0.0.1:8182
gremlin> :remote console
==>All scripts will now be sent to Gremlin Server -
[localhost/127.0.0.1:8182] - type ':remote console' to return to local mode
gremlin> a = "b"
==>b
gremlin> a
No such property: a for class: Script3
Type ':help' or ':h' for help.
</code></pre>
| 0debug |
How to get to the bottom of ScrollView after amount of time in android with Rxjava? : <p>I want to get to the bottom of an scroll view after some button has clicked, but I had trouble doing it:(.
thanks in advance</p>
| 0debug |
Java sorting numbers using algorithm : <p>I have a task to sort ints in ascending order. Task is designed to practice algorithms... but i used basic array sort method like this:</p>
<pre><code>BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int a = Integer.parseInt((reader.readLine()));
int b = Integer.parseInt((reader.readLine()));
int c = Integer.parseInt((reader.readLine()));
int d = Integer.parseInt((reader.readLine()));
int e = Integer.parseInt((reader.readLine()));
int[] ints = {a, b, c, d, e};
Arrays.sort(ints);
for(int i = 0; i<5;i++)
{
System.out.println(ints[i]);
}
</code></pre>
<p>Its not an algorithm for sure. How could i do this without sort method?</p>
| 0debug |
TK Framework double implementation issue : <p>I am testing out creating a GUI using the Tkinter module. I was trying to add an image to the GUI using PIL. My code looks like this:</p>
<pre><code>import Tkinter as tk
from PIL import Image, ImageTk
root = tk.Tk()
root.title('background image')
imfile = "foo.png"
im = Image.open(imfile)
im1 = ImageTk.PhotoImage(im)
</code></pre>
<p>When I run this code, I come up with some errors that lead to a segfault.</p>
<pre><code>objc[5431]: Class TKApplication is implemented in both/Users/sykeoh/anaconda/lib/libtk8.5.dylib and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
objc[5431]: Class TKMenu is implemented in both /Users/sykeoh/anaconda/lib/libtk8.5.dylib and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
objc[5431]: Class TKContentView is implemented in both /Users/sykeoh/anaconda/lib/libtk8.5.dylib and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
objc[5431]: Class TKWindow is implemented in both /Users/sykeoh/anaconda/lib/libtk8.5.dylib and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
Segmentation fault: 11
</code></pre>
<p>I've looked online and it looks to be an issue with the Tk framework in my Systems library and the other in the anaconda library. However, none of the solutions really seemed to work. Any possible solutions or workarounds?</p>
<p>The issue comes with running ImageTk.Photoimage. If I remove that line of code, there is no issues.</p>
| 0debug |
static int handle_cmd(AHCIState *s, int port, int slot)
{
IDEState *ide_state;
uint32_t opts;
uint64_t tbl_addr;
AHCICmdHdr *cmd;
uint8_t *cmd_fis;
dma_addr_t cmd_len;
if (s->dev[port].port.ifs[0].status & (BUSY_STAT|DRQ_STAT)) {
DPRINTF(port, "engine busy\n");
return -1;
}
cmd = &((AHCICmdHdr *)s->dev[port].lst)[slot];
if (!s->dev[port].lst) {
DPRINTF(port, "error: lst not given but cmd handled");
return -1;
}
s->dev[port].cur_cmd = cmd;
opts = le32_to_cpu(cmd->opts);
tbl_addr = le64_to_cpu(cmd->tbl_addr);
cmd_len = 0x80;
cmd_fis = dma_memory_map(s->as, tbl_addr, &cmd_len,
DMA_DIRECTION_FROM_DEVICE);
if (!cmd_fis) {
DPRINTF(port, "error: guest passed us an invalid cmd fis\n");
return -1;
}
ide_state = &s->dev[port].port.ifs[0];
if (!ide_state->bs) {
DPRINTF(port, "error: guest accessed unused port");
goto out;
}
debug_print_fis(cmd_fis, 0x90);
switch (cmd_fis[0]) {
case SATA_FIS_TYPE_REGISTER_H2D:
break;
default:
DPRINTF(port, "unknown command cmd_fis[0]=%02x cmd_fis[1]=%02x "
"cmd_fis[2]=%02x\n", cmd_fis[0], cmd_fis[1],
cmd_fis[2]);
goto out;
break;
}
switch (cmd_fis[1]) {
case SATA_FIS_REG_H2D_UPDATE_COMMAND_REGISTER:
break;
case 0:
break;
default:
DPRINTF(port, "unknown command cmd_fis[0]=%02x cmd_fis[1]=%02x "
"cmd_fis[2]=%02x\n", cmd_fis[0], cmd_fis[1],
cmd_fis[2]);
goto out;
break;
}
switch (s->dev[port].port_state) {
case STATE_RUN:
if (cmd_fis[15] & ATA_SRST) {
s->dev[port].port_state = STATE_RESET;
}
break;
case STATE_RESET:
if (!(cmd_fis[15] & ATA_SRST)) {
ahci_reset_port(s, port);
}
break;
}
if (cmd_fis[1] == SATA_FIS_REG_H2D_UPDATE_COMMAND_REGISTER) {
if ((cmd_fis[2] == READ_FPDMA_QUEUED) ||
(cmd_fis[2] == WRITE_FPDMA_QUEUED)) {
process_ncq_command(s, port, cmd_fis, slot);
goto out;
}
ide_state->nsector = (int64_t)((cmd_fis[13] << 8) | cmd_fis[12]);
ide_state->feature = cmd_fis[3];
if (!ide_state->nsector) {
ide_state->nsector = 256;
}
if (ide_state->drive_kind != IDE_CD) {
ide_set_sector(ide_state, ((uint64_t)cmd_fis[10] << 40)
| ((uint64_t)cmd_fis[9] << 32)
| ((uint64_t)cmd_fis[8] << 24)
| ((uint64_t)(cmd_fis[7] & 0xf) << 24)
| ((uint64_t)cmd_fis[6] << 16)
| ((uint64_t)cmd_fis[5] << 8)
| cmd_fis[4]);
}
if (opts & AHCI_CMD_ATAPI) {
memcpy(ide_state->io_buffer, &cmd_fis[AHCI_COMMAND_TABLE_ACMD], 0x10);
ide_state->lcyl = 0x14;
ide_state->hcyl = 0xeb;
debug_print_fis(ide_state->io_buffer, 0x10);
ide_state->feature = IDE_FEATURE_DMA;
s->dev[port].done_atapi_packet = false;
}
ide_state->error = 0;
cmd->status = 0;
ide_exec_cmd(&s->dev[port].port, cmd_fis[2]);
}
out:
dma_memory_unmap(s->as, cmd_fis, cmd_len, DMA_DIRECTION_FROM_DEVICE,
cmd_len);
if (s->dev[port].port.ifs[0].status & (BUSY_STAT|DRQ_STAT)) {
s->dev[port].busy_slot = slot;
return -1;
}
return 0;
}
| 1threat |
static uint32_t ecc_mem_readb(void *opaque, target_phys_addr_t addr)
{
printf("ECC: Unsupported read 0x" TARGET_FMT_plx " 00\n", addr);
return 0;
}
| 1threat |
Difference between Model and ModelAndView in Spring MVC :
@RequestMapping(value = "/testmap", method = RequestMethod.GET)
public ModelAndView testmap(ModelAndView model) {
ModelMap map=new ModelMap();
String greetings = "Greetings, Spring MVC! testinggg";
model.setViewName("welcome");
map.addAttribute("message", greetings);
return model;
}
Why this code does not print the attribute message? | 0debug |
document.write('<script src="evil.js"></script>'); | 1threat |
bootstrap-select do not submit select : **I have this form:**
<script src="./bootstrap-select/js/bootstrap-select.js"></script>
<form action="rec.php" name="submit">
<select name="all[]" class="form-control">
<?php
for($i = 0; $i < 10; $i++) {
?>
<option value="details<?=$i?>"><?=$i?></option>
<?php } ?>
</select>
<?php
for($i = 0; $i < 10; $i++) {
?>
<input type = "hidden" name="infos[]" value="<?=$i?>">
<?php } ?>
<input type="submit" vale="submit" name="submitit">
</form>
**rec.php:**
<?php
print_r($_REQUEST);
?>
When i submit the form i get only Arrays of `infos[]`, and nothing about `all[]`, when i remove `bootstrap-select` and resubmit the form, i get all the results.
How to fix bootstrap-select in order to solve my problem please ?
**I am using:**
Bootstrap-select v1.10.0 (http://silviomoreto.github.io/bootstrap-select) | 0debug |
static int try_decode_video_frame(AVCodecContext *codec_ctx, AVPacket *pkt, int decode)
{
int ret = 0;
int got_frame = 0;
AVFrame *frame = NULL;
int skip_frame = codec_ctx->skip_frame;
if (!avcodec_is_open(codec_ctx)) {
const AVCodec *codec = avcodec_find_decoder(codec_ctx->codec_id);
ret = avcodec_open2(codec_ctx, codec, NULL);
if (ret < 0) {
av_log(codec_ctx, AV_LOG_ERROR, "Failed to open codec\n");
goto end;
}
}
frame = av_frame_alloc();
if (!frame) {
av_log(NULL, AV_LOG_ERROR, "Failed to allocate frame\n");
goto end;
}
if (!decode && codec_ctx->codec->caps_internal & FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM) {
codec_ctx->skip_frame = AVDISCARD_ALL;
}
do {
ret = avcodec_decode_video2(codec_ctx, frame, &got_frame, pkt);
av_assert0(decode || (!decode && !got_frame));
if (ret < 0)
break;
pkt->data += ret;
pkt->size -= ret;
if (got_frame) {
break;
}
} while (pkt->size > 0);
end:
codec_ctx->skip_frame = skip_frame;
av_frame_free(&frame);
return ret;
}
| 1threat |
Is 500 xml files and java files too large? : <p>I have around 500 java file and and another 500 xml files in my android studio project. Is that consider large? Is it possible to put on the apps store?</p>
| 0debug |
Input ignoring first array : So, I'm trying to figure out why my program isnt working the right way. I want to save stuff in an array, but the first input always gets ignored. For example, I ask the user "do you want to enter more xy?" and then an yes comes, I ask how many and the users types in 2 the first one gets ignored, the second is showing. If its only one it doesnt even show.
Here's my code
import java.util.*;
public class TriangleType {
public static void main(String[] args) {
// TODO Auto-generated method stub
int a , b ,c ,result , total,count;
int x=9;
String triangle = null;
String[] output=new String[110];
//Dreiecktypen und deren anzahl fuer die Statistikanzeige
String[][] triangleTypes={{"gleichseitig","0"} ,{"gleichschenklig","0"},{"spitzwinklig","0"},{"rechtwinklig","0"},{"stumpwinkling","0"}};
//2D array um die seiten die dreiecke zu speichern
int[][] sides=new int[110][3];
sides[0][0]=2; sides[0][1]=2; sides[0][2]=4;
sides[1][0]=3; sides[1][1]=4; sides[1][2]=5;
sides[2][0]=5; sides[2][1]=5; sides[2][2]=5;
sides[3][0]=8; sides[3][1]=6; sides[3][2]=10;
sides[4][0]=10; sides[4][1]=10; sides[4][2]=2;
sides[5][0]=2; sides[5][1]=4; sides[5][2]=9;
sides[6][0]=12; sides[6][1]=36; sides[6][2]=4;
sides[7][0]=5; sides[7][1]=6; sides[7][2]=7;
sides[8][0]=7; sides[8][1]=9; sides[8][2]=12;
//User eingabe
System.out.println("Moechten Sie mehr Dreiecke hinzufuegen? (1/Ja/; 0/Nein/)");
Scanner input = new Scanner(System.in);
String s = input.nextLine();
int equivalent=Integer.parseInt(s);
if(equivalent==1){
System.out.println("Wie viele Dreiecke moechten Sie hinzufuegen?");
Scanner inputt = new Scanner(System.in);
String ss = input.nextLine();
total=Integer.parseInt(ss);
for (int i=0; i<total; i++){
System.out.println("Seite a von Dreieck "+(8+i+1)+" eingeben:");
Scanner input1 = new Scanner(System.in);
String s1 = input1.nextLine();
System.out.println("Seite b von Dreieck "+(8+i+1)+" eingeben:"); Scanner input2 = new Scanner(System.in);
String s2 = input2.nextLine();
System.out.println("Seite c von Dreieck "+(8+i+1)+" eingeben:"); Scanner input3 = new Scanner(System.in);
String s3 = input3.nextLine();
a=Integer.parseInt(s1);
b=Integer.parseInt(s2);
c=Integer.parseInt(s3);
x=9+i;
sides[9+i][0]=a;
sides[9+i][1]=b;
sides[9+i][2]=c;
}}
for(int j=0; j<x; j++){
triangle=evaluateTriangle(sides[j][0], sides[j][1], sides[j][2]);
output[j]=triangle;
System.out.println(sides[j][0]+" "+sides[j][1]+" "+sides[j][2] + " "+triangle);
}
for(int k=0; k<output.length; k++)
{
//pruefe ob das zurückgegebene Dreieck mit einem in der triangleType Array definirten uebereinstimmt
for(int l=0; l<triangleTypes.length; l++ ){
if(output[k]==triangleTypes[l][0])
{ //wenn ja, erhoehe den zaehler fuer den typ
count=(Integer.parseInt(triangleTypes[l][1]));
count=count+1;
triangleTypes[l][1]=Integer.toString(count);
}
}
}
//Statistiken zeigen
System.out.println("======STATISTIK=======");
System.out.println("Dreieckstyp Anzahl");
for(int m=0; m<triangleTypes.length; m++)
{
System.out.println(triangleTypes[m][0]+" "+triangleTypes[m][1]);
}
}
//Dreieckstyp bestimmen
public static String evaluateTriangle(int side1 , int side2 , int side3){
int a,b,c;
a=side1;
b=side2;
c=side3;
if(a <= 0 || b <= 0 || c <= 0)
{return "kein gültiges Dreieck";}
else if(a == b && b == c)
{return "gleichseitiges Dreieck";}
else if((a*a)+(b*b)==(c*c))
{return "rechtwinkliges Dreieck";}
else if((a*a)+(b*b)>(c*c))
{ return "spitzwinkliges Dreieck";}
else if((a*a)+(b*b)<(c*c))
{ return "stumpwinklinges Dreieck";}
else if (a == b || b == c || c == a)
{return "gleichschenkliges Dreieck";}
else return "undefiniert";
}
}
Sorry for the long code but I'm desperate here (also super new to java).
Thankks in advance! | 0debug |
static int init_resampler(AVCodecContext *input_codec_context,
AVCodecContext *output_codec_context,
SwrContext **resample_context)
{
if (input_codec_context->sample_fmt != output_codec_context->sample_fmt ||
input_codec_context->channels != output_codec_context->channels) {
int error;
*resample_context = swr_alloc_set_opts(NULL,
av_get_default_channel_layout(output_codec_context->channels),
output_codec_context->sample_fmt,
output_codec_context->sample_rate,
av_get_default_channel_layout(input_codec_context->channels),
input_codec_context->sample_fmt,
input_codec_context->sample_rate,
0, NULL);
if (!*resample_context) {
fprintf(stderr, "Could not allocate resample context\n");
return AVERROR(ENOMEM);
}
av_assert0(output_codec_context->sample_rate == input_codec_context->sample_rate);
if ((error = swr_init(*resample_context)) < 0) {
fprintf(stderr, "Could not open resample context\n");
swr_free(resample_context);
return error;
}
}
return 0;
}
| 1threat |
static inline void dv_guess_qnos(EncBlockInfo* blks, int* qnos)
{
int size[5];
int i, j, k, a, prev, a2;
EncBlockInfo* b;
size[4]= 1<<24;
do {
b = blks;
for (i=0; i<5; i++) {
if (!qnos[i])
continue;
qnos[i]--;
size[i] = 0;
for (j=0; j<6; j++, b++) {
for (a=0; a<4; a++) {
if (b->area_q[a] != dv_quant_shifts[qnos[i] + dv_quant_offset[b->cno]][a]) {
b->bit_size[a] = 1;
b->area_q[a]++;
prev= b->prev[a];
for (k= b->next[prev] ; k<mb_area_start[a+1]; k= b->next[k]) {
b->mb[k] >>= 1;
if (b->mb[k]) {
b->bit_size[a] += dv_rl2vlc_size(k - prev - 1, b->mb[k]);
prev= k;
} else {
if(b->next[k] >= mb_area_start[a+1] && b->next[k]<64){
for(a2=a+1; b->next[k] >= mb_area_start[a2+1]; a2++);
assert(a2<4);
assert(b->mb[b->next[k]]);
b->bit_size[a2] += dv_rl2vlc_size(b->next[k] - prev - 1, b->mb[b->next[k]])
-dv_rl2vlc_size(b->next[k] - k - 1, b->mb[b->next[k]]);
}
b->next[prev] = b->next[k];
}
}
b->prev[a+1]= prev;
}
size[i] += b->bit_size[a];
}
}
if(vs_total_ac_bits >= size[0] + size[1] + size[2] + size[3] + size[4])
return;
}
} while (qnos[0]|qnos[1]|qnos[2]|qnos[3]|qnos[4]);
for(a=2; a==2 || vs_total_ac_bits < size[0]; a+=a){
b = blks;
size[0] = 5*6*4;
for (j=0; j<6*5; j++, b++) {
prev= b->prev[0];
for (k= b->next[prev]; k<64; k= b->next[k]) {
if(b->mb[k] < a && b->mb[k] > -a){
b->next[prev] = b->next[k];
}else{
size[0] += dv_rl2vlc_size(k - prev - 1, b->mb[k]);
prev= k;
}
}
}
}
}
| 1threat |
uint32_t ldl_be_phys(target_phys_addr_t addr)
{
return ldl_phys_internal(addr, DEVICE_BIG_ENDIAN);
}
| 1threat |
Can I write PowerShell binary cmdlet with .NET Core? : <p>I'm trying to create a basic PowerShell Module with a binary Cmdlet internals, cause writing things in PowerShell only doesn't look as convenient as in C#.</p>
<p>Following <a href="https://msdn.microsoft.com/en-us/library/dd878342(v=vs.85).aspx">this</a> guide, it looks like I have to:</p>
<ul>
<li>add <a href="https://powershell.myget.org/feed/powershell-core/package/nuget/Microsoft.PowerShell.SDK">Microsoft.PowerShell.SDK</a> to my <code>project.json</code></li>
<li>mark my cmdlet class with required attributes</li>
<li>write manifest file, with <code>RootModule</code>, targeting my <code>.dll</code></li>
<li>put that <code>.dll</code> nearby manifest</li>
<li>put both under <code>PSModulePath</code></li>
</ul>
<p>but, when I'm trying to <code>Import-Module</code>, PowerShell core complains on missing runtime:</p>
<pre><code>Import-Module : Could not load file or assembly 'System.Runtime, Version=4.1.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system
cannot find the file specified.
At line:1 char:1
</code></pre>
<p>Am I doing something wrong, or such tricky things are not supported yet as well?</p>
| 0debug |
static void pci_apb_iowritew (void *opaque, target_phys_addr_t addr,
uint32_t val)
{
cpu_outw(addr & IOPORTS_MASK, bswap16(val));
}
| 1threat |
When i install the android studio in window 10 there is error is occurred . : like you can see in image also.the error is regarding android studio not able to find the jdk, but jdk is aleady install in PC.i used JAVA_HOME and give path name all that, but still error is occurred . Please help me>>>>>>>>
[enter image description here][1]
[1]: http://i.stack.imgur.com/3wwzC.png | 0debug |
I have stored few items in the form of multidimensional arrays in userdata and want to access them.Well new to CI please help me out : Code below is basically what i did in actual. here lets say i want to access : array at index 3 and 4th element of that same array
<?php
$data = array( array('1','2','3'),
'4', '5',
array('abc', 'klm','xyz'),
array('1', '2', '88908', '3', '4')
);
$this->session->set_userdata('data', $data);
print_r($this->session->userdata('data["5"]["4"]'));
?>
i want to access only 88908
| 0debug |
Qt Quick Controls 2.0 Text Field Cannot Select Text : <p>I'm having difficulty with selecting text on a <a href="http://doc.qt.io/qt-5/qml-qtquick-controls2-textfield.html" rel="noreferrer">TextField</a> from Qt Quick Controls 2.0 with a mouse. When I hover over the TextField the cursor does not change from the cursor arrow to the cursor I beam and I am unable to select text. I verified text selection is possible by using the keyboard shortcut Ctrl+A. I also tested this with the <a href="http://doc.qt.io/qt-5/qml-qtquick-controls-textfield.html" rel="noreferrer">TextField</a> from Qt Quick Controls 1.4, and it works as expected (the mouse cursor changes to an I beam and I can select text). I think I must be missing something obvious because this seems like basic text field functionality. Does anyone have any ideas? Below is my code:</p>
<pre><code>import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
TextField {
anchors.centerIn: parent
height: 50
width: 100
}
}
</code></pre>
| 0debug |
Xcode 8 - Variable used within its own initial value : func presentLoggedInScreen() {
let stroyboard:UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let logginedInVCViewController:LogginedInVCViewController = storyboard.instantiateViewController(withIdentifier: "LogginedInVCViewController" as! LogginedInVCViewController,
self.present(logginedInVCViewController, animated: true, completion: nil))
How can I avoid this “variable used within its own initial value” error?
| 0debug |
static void test_visitor_in_int_overflow(TestInputVisitorData *data,
const void *unused)
{
int64_t res = 0;
Error *err = NULL;
Visitor *v;
v = visitor_input_test_init(data, "%f", DBL_MAX);
visit_type_int(v, NULL, &res, &err);
error_free_or_abort(&err);
}
| 1threat |
Getting values from strings.xml in andoid studio : I want to get the item value from strings.xml file in android studio. I have set up spinners and buttons. I have found many ways to parse the document which could not answer my questions. If I am allowed to ask a noob question can it be this? Thank you.
<string-array name="angles">
<item value="1">Radian</item>
<item value="(Math.PI/3200)">Mil</item>
<item value="(Math.PI/200)">Grad</item>
</string-array> | 0debug |
static void vnc_dpy_resize(DisplayChangeListener *dcl,
DisplayState *ds)
{
VncDisplay *vd = ds->opaque;
VncState *vs;
vnc_abort_display_jobs(vd);
qemu_pixman_image_unref(vd->server);
vd->server = pixman_image_create_bits(VNC_SERVER_FB_FORMAT,
ds_get_width(ds),
ds_get_height(ds),
NULL, 0);
#if 0
if (ds_get_bytes_per_pixel(ds) != vd->guest.ds->pf.bytes_per_pixel)
console_color_init(ds);
#endif
qemu_pixman_image_unref(vd->guest.fb);
vd->guest.fb = pixman_image_ref(ds->surface->image);
vd->guest.format = ds->surface->format;
memset(vd->guest.dirty, 0xFF, sizeof(vd->guest.dirty));
QTAILQ_FOREACH(vs, &vd->clients, next) {
vnc_colordepth(vs);
vnc_desktop_resize(vs);
if (vs->vd->cursor) {
vnc_cursor_define(vs);
}
memset(vs->dirty, 0xFF, sizeof(vs->dirty));
}
}
| 1threat |
static struct dpll_ctl_s *omap_dpll_init(MemoryRegion *memory,
target_phys_addr_t base, omap_clk clk)
{
struct dpll_ctl_s *s = g_malloc0(sizeof(*s));
memory_region_init_io(&s->iomem, &omap_dpll_ops, s, "omap-dpll", 0x100);
s->dpll = clk;
omap_dpll_reset(s);
memory_region_add_subregion(memory, base, &s->iomem);
return s;
}
| 1threat |
How to optimize this query - replace/optimize NOT IN : <p>The query should return values that are not included in the top - for example - 10.
Anyway to optimize it? Maybe replace NOT IN?</p>
<pre><code>CREATE PROCEDURE procName
@ClientId char(36)
, @Top int
, @StartDate datetime
, @EndDate datetime
AS
BEGIN
SELECT
'Outside' AS LocationName
, SUM(Copies * Pages) AS TotalPages
FROM table1 tb1
INNER JOIN table2 tb2 ON tb2.Tb2Id = tb1.Tb2Id
INNER JOIN [table3] tb3 ON tb3.LocationId = tb2.LocationId
WHERE tb1.ClientId = @ClientId AND tb1.TimeOrdered BETWEEN @StartDate AND @EndDate
AND tb3.[Name] NOT IN (
SELECT TOP(@Top)
tb3.[Name] AS LocationName
FROM table1 tb1
INNER JOIN table2 tb2 ON tb2.Tb2Id = tb1.Tb2Id
INNER JOIN [table3] a ON tb3.LocationId = tb2.LocationId
WHERE tb1.ClientId = @ClientId AND tb1.TimeOrdered BETWEEN @StartDate AND @EndDate
GROUP BY tb3.Name
ORDER BY SUM(tb1.Copies * tb1.Pages) DESC
)
END
</code></pre>
| 0debug |
Kubernetes how to make Deployment to update image : <p>I do have deployment with single pod, with my custom docker image like:</p>
<pre><code>containers:
- name: mycontainer
image: myimage:latest
</code></pre>
<p>During development I want to push new latest version and make Deployment updated.
Can't find how to do that, without explicitly defining tag/version and increment it for each build, and do</p>
<pre><code>kubectl set image deployment/my-deployment mycontainer=myimage:1.9.1
</code></pre>
| 0debug |
void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
qtest_qmpv_discard_response(s, fmt, ap);
va_end(ap);
}
| 1threat |
cursor.execute('SELECT * FROM users WHERE username = ' + user_input) | 1threat |
def merge(lst):
return [list(ele) for ele in list(zip(*lst))] | 0debug |
static int aac_sync(uint64_t state, AACAC3ParseContext *hdr_info,
int *need_next_header, int *new_frame_start)
{
GetBitContext bits;
int size, rdb, ch, sr;
union {
uint64_t u64;
uint8_t u8[8];
} tmp;
tmp.u64 = be2me_64(state);
init_get_bits(&bits, tmp.u8+8-AAC_HEADER_SIZE, AAC_HEADER_SIZE * 8);
if(get_bits(&bits, 12) != 0xfff)
return 0;
skip_bits1(&bits);
skip_bits(&bits, 2);
skip_bits1(&bits);
skip_bits(&bits, 2);
sr = get_bits(&bits, 4);
if(!ff_mpeg4audio_sample_rates[sr])
return 0;
skip_bits1(&bits);
ch = get_bits(&bits, 3);
if(!ff_mpeg4audio_channels[ch])
return 0;
skip_bits1(&bits);
skip_bits1(&bits);
skip_bits1(&bits);
skip_bits1(&bits);
size = get_bits(&bits, 13);
if(size < AAC_HEADER_SIZE)
return 0;
skip_bits(&bits, 11);
rdb = get_bits(&bits, 2);
hdr_info->channels = ff_mpeg4audio_channels[ch];
hdr_info->sample_rate = ff_mpeg4audio_sample_rates[sr];
hdr_info->samples = (rdb + 1) * 1024;
hdr_info->bit_rate = size * 8 * hdr_info->sample_rate / hdr_info->samples;
*need_next_header = 0;
*new_frame_start = 1;
return size;
}
| 1threat |
connection.query('SELECT * FROM users WHERE username = ' + input_string) | 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.