problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
Should I need to remove the app already installed before using brew cask? : <p>I am a Mac user and I download apps on website through installing .dmg files. Recently, I find the Homebrew cask which is simplicity for installing app on Mac. Therefore, I want to switch to download some apps through Homebrew cask. However, I am wondering if there is an app I already installed by .dmg file on website, can I install it again through Homebrew cask, or should I uninstall it first before download the existed app?</p>
<p>For example, I already download sublime text by .dmg file on their official website. If I want to download sublime text through Homebrew cask next time. Should I uninstalled it first, then use cask to install, or I can install it directly by homebrew cask, if so, will I get duplicate files my on disk?</p>
| 0debug |
"pg_dump: invalid option -- i" when migrating : <p>When I run <code>rake db:migrate</code> on my Rails project (3.2.22.2) I get <code>pg_dump: invalid option -- i</code>. Here's the full trace:</p>
<pre><code>Celluloid 0.17.1.1 is running in BACKPORTED mode. [ http://git.io/vJf3J ]
[DEPRECATION] `last_comment` is deprecated. Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated. Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated. Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated. Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated. Please use `last_description` instead.
pg_dump: invalid option -- i
Try "pg_dump --help" for more information.
rake aborted!
Error dumping database
/Users/jasonswett/.rvm/gems/ruby-2.1.4@bm43/gems/activerecord-3.2.22.2/lib/active_record/railties/databases.rake:429:in `block (3 levels) in <top (required)>'
/Users/jasonswett/.rvm/gems/ruby-2.1.4@bm43/gems/activerecord-3.2.22.2/lib/active_record/railties/databases.rake:202:in `block (2 levels) in <top (required)>'
/Users/jasonswett/.rvm/gems/ruby-2.1.4@bm43/gems/activerecord-3.2.22.2/lib/active_record/railties/databases.rake:196:in `block (2 levels) in <top (required)>'
/Users/jasonswett/.rvm/gems/ruby-2.1.4@bm43/bin/ruby_executable_hooks:15:in `eval'
/Users/jasonswett/.rvm/gems/ruby-2.1.4@bm43/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:structure:dump
(See full trace by running task with --trace)
</code></pre>
<p>I notice that there's a <a href="https://github.com/rails/rails/pull/21931">bugfix in Rails</a> pertaining to this issue. The bugfix seems not to have been applied to Rails versions < 4 since it's not a security fix, which makes sense.</p>
<p>What I don't understand is what I'm supposed to do now. If there's a fix for 3.2.x, I haven't been able to find it yet. I guess if there's no fix for 3.2.x, I guess that means I have to upgrade to Rails 4.x, which seems a bit drastic. I doubt that's really the only solution. And why did the issue only recently pop up out of nowhere?</p>
<p>Any suggestions are appreciated.</p>
| 0debug |
Component not showing its content on lazy loading : <p>I am having trouble sharing components in modules in Angular 8. I was trying to build a stackblitz but I got stuck in some problem. I don't know if the problem is related to Angular or stackblitz itselft.
My example can be accessed here</p>
<p><a href="https://stackblitz.com/edit/angular-jdw21n" rel="nofollow noreferrer">here</a></p>
<p>When you click the link, to simulate a successful login you go to the home component. it has content but nothing appears.</p>
| 0debug |
AVAudioEngine inputNode installTap crash when restarting recording : <p>I am implementing Speech Recognition in my app. When I first present the view controller with the speech recognition logic, everything works fine. However, when I try present the view controller again, I get the following crash:</p>
<pre><code>ERROR: [0x190bf000] >avae> AVAudioNode.mm:568: CreateRecordingTap: required condition is false: IsFormatSampleRateAndChannelCountValid(format)
*** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: IsFormatSampleRateAndChannelCountValid(format)'
</code></pre>
<p>Here is the code used for starting and stopping recording:</p>
<pre><code>@available(iOS 10.0, *)
extension DictationViewController {
fileprivate func startRecording() throws {
guard let recognizer = speechRecognizer else {
debugLog(className, message: "Not supported for the device's locale")
return
}
guard recognizer.isAvailable else {
debugLog(className, message: "Recognizer is not available right now")
return
}
mostRecentlyProcessedSegmentDuration = 0
guard let node = audioEngine.inputNode else {
debugLog(className, message: "Could not get an input node")
return
}
let recordingFormat = node.outputFormat(forBus: 0)
node.installTap(onBus: 0, bufferSize: 1024, format: recordingFormat) { [weak self] (buffer, _) in
self?.request.append(buffer)
}
audioEngine.prepare()
try audioEngine.start()
recognitionTask = recognizer.recognitionTask(with: request, resultHandler: {/***/})
}
fileprivate func stopRecording() {
audioEngine.stop()
audioEngine.inputNode?.removeTap(onBus: 0)
request.endAudio()
recognitionTask?.cancel()
}
}
</code></pre>
<p><code>startRecording()</code> is called in viewDidLoad once we have requested authorization. <code>stopRecording()</code> is called when the view controller is dismissed.</p>
<p>Please assist. I'm struggling to find a solution to this crash</p>
| 0debug |
static void ehci_advance_state(EHCIState *ehci, int async)
{
EHCIQueue *q = NULL;
int again;
do {
switch(ehci_get_state(ehci, async)) {
case EST_WAITLISTHEAD:
again = ehci_state_waitlisthead(ehci, async);
break;
case EST_FETCHENTRY:
again = ehci_state_fetchentry(ehci, async);
break;
case EST_FETCHQH:
q = ehci_state_fetchqh(ehci, async);
if (q != NULL) {
assert(q->async == async);
again = 1;
} else {
again = 0;
}
break;
case EST_FETCHITD:
again = ehci_state_fetchitd(ehci, async);
break;
case EST_FETCHSITD:
again = ehci_state_fetchsitd(ehci, async);
break;
case EST_ADVANCEQUEUE:
assert(q != NULL);
again = ehci_state_advqueue(q);
break;
case EST_FETCHQTD:
assert(q != NULL);
again = ehci_state_fetchqtd(q);
break;
case EST_HORIZONTALQH:
assert(q != NULL);
again = ehci_state_horizqh(q);
break;
case EST_EXECUTE:
assert(q != NULL);
again = ehci_state_execute(q);
if (async) {
ehci->async_stepdown = 0;
}
break;
case EST_EXECUTING:
assert(q != NULL);
if (async) {
ehci->async_stepdown = 0;
}
again = ehci_state_executing(q);
break;
case EST_WRITEBACK:
assert(q != NULL);
again = ehci_state_writeback(q);
if (!async) {
ehci->periodic_sched_active = PERIODIC_ACTIVE;
}
break;
default:
fprintf(stderr, "Bad state!\n");
again = -1;
g_assert_not_reached();
break;
}
if (again < 0) {
fprintf(stderr, "processing error - resetting ehci HC\n");
ehci_reset(ehci);
again = 0;
}
}
while (again);
}
| 1threat |
static inline void RENAME(yuv2yuvX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)
{
#ifdef HAVE_MMX
if(uDest != NULL)
{
asm volatile(
YSCALEYUV2YV12X(0, CHR_MMX_FILTER_OFFSET)
:: "r" (&c->redDither),
"r" (uDest), "p" ((long)chrDstW)
: "%"REG_a, "%"REG_d, "%"REG_S
);
asm volatile(
YSCALEYUV2YV12X(4096, CHR_MMX_FILTER_OFFSET)
:: "r" (&c->redDither),
"r" (vDest), "p" ((long)chrDstW)
: "%"REG_a, "%"REG_d, "%"REG_S
);
}
asm volatile(
YSCALEYUV2YV12X(0, LUM_MMX_FILTER_OFFSET)
:: "r" (&c->redDither),
"r" (dest), "p" ((long)dstW)
: "%"REG_a, "%"REG_d, "%"REG_S
);
#else
#ifdef HAVE_ALTIVEC
yuv2yuvX_altivec_real(lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
dest, uDest, vDest, dstW, chrDstW);
#else
yuv2yuvXinC(lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
dest, uDest, vDest, dstW, chrDstW);
#endif
#endif
}
| 1threat |
Unknow index of session : <p>Ok guys when I try to run my simple php code I get this error: Notice: Undefined index: Status, here is my code:</p>
<pre><code><?php
session_start();
?>
<!DOCTYPE HTML>
<html>
<head>
--->All links
</head>
<body>
<?php
if($_SESSION['Status']=='1'){
?>
...--->NAV1
?>
<?php
}else{
?>
...NAV2--->
<?php
}
?>
</nav>
</body>
</code></pre>
<p>The error is on " <code>if($_SESSION['Status']=='1'){</code>", this code will check if user is logged or not then shows a proper navbar.</p>
| 0debug |
static int ipmovie_probe(AVProbeData *p)
{
if (p->buf_size < IPMOVIE_SIGNATURE_SIZE)
return 0;
if (strncmp(p->buf, IPMOVIE_SIGNATURE, IPMOVIE_SIGNATURE_SIZE) != 0)
return 0;
return AVPROBE_SCORE_MAX;
}
| 1threat |
Find out who is the admin(s) for a git repo : <p>I am a contributor for a git repo in github for a company.</p>
<p>I want to find out who among the contributors are the admins.</p>
<p>How do I find out who is the admin besides going around and asking everyone in the company?</p>
| 0debug |
Handling scroll views with (custom, interactive) view controller presentation and dismissal : <p>I have been experimenting with custom interactive view controller presentation and dismissal (using a combination of <code>UIPresentationController</code>, <code>UIPercentDrivenInteractiveTransition</code>, <code>UIViewControllerAnimatedTransitioning</code>, and <code>UIViewControllerTransitioningDelegate</code>) and have mostly gotten things working well for my needs.</p>
<p>However, there is one common scenario that I've yet to find addressed in any of the tutorials or documentation that I've read, leading me to the following question:</p>
<p>...</p>
<p><strong>What is the proper way of handling custom interactive view controller dismissal, via a pan gesture, when the dismissed view contains a UIScrollView (ie. UITableView, UICollectionView, WKWebView, etc)?</strong></p>
<p>...</p>
<p>Basically, what I'd like is for the following:</p>
<ol>
<li><p>View controllers are interactively dismissible by panning them down. This is common UX in many apps.</p></li>
<li><p>If the dismissed view controller contains a (vertically-scrolling) scroll view, panning down scrolls that view as expected until the user reaches the top, after which the scrolling ceases and the pan-to-dismiss occurs.</p></li>
<li><p>Scroll views should otherwise behave as normal.</p></li>
</ol>
<p>I know that this is <em>technically</em> possible - I've seen it in other apps, such as Overcast and Apple's own Music app - but I've not been able to find the key to coordinating the behavior of my pan gesture with that of the scroll view(s).</p>
<p>Most of my own attempts center on trying to conditionally enable/disable the scrollview (or its associated pan gesture recognizer) based on its <code>contentOffset.y</code> while scrolling and having the view controller dismissal's pan gesture recognizer take over from there, but this has been fraught with problems and I fear that I am overthinking it.</p>
<p>I feel like the secret mostly lies in the following pan gesture recognizer delegate method:</p>
<pre><code>func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
// ...
}
</code></pre>
<p>I have created a reduced sample project which should demonstrate the scenario more clearly. Any code suggestions are highly welcome!</p>
<p><a href="https://github.com/Darchmare/SlidePanel-iOS" rel="noreferrer">https://github.com/Darchmare/SlidePanel-iOS</a></p>
| 0debug |
I am using multiple firebase projects in an Android App. I am getting this error : Missing google_app_id. Firebase Analytics disabled : <p>I have added following code to initialise there projects. </p>
<pre><code>FirebaseOptions options = new FirebaseOptions.Builder()
.setApplicationId("1:129574837465:android:0123456773a52cf4f6") // Required for Analytics.
.setApiKey("iubdeibneh8gzDt7Xn9f-jdjjdjdjdj") // Required for Auth.
.setDatabaseUrl("https://databasename-d7r7.firebaseio.com") // Required for RTDB.
.build();
FirebaseApp.initializeApp(context /* Context */, options, "secondary");
FirebaseOptions options2 = new FirebaseOptions.Builder()
.setApplicationId("1:129574837465:android:0123456773a52cf4f6") // Required for Analytics.
.setApiKey("iubdeibneh8gzDt7Xn9f-jdjjdjdjdj") // Required for Auth.
.setDatabaseUrl("https://databasename2-d7r7.firebaseio.com") // Required for RTDB.
.build();
FirebaseApp.initializeApp(context /* Context */, options2, "secondary2");
FirebaseOptions options3 = new FirebaseOptions.Builder()
.setApplicationId("1:129574837465:android:0123456773a52cf4f6") // Required for Analytics.
.setApiKey("kjdkj-o_3nk4jn4k3kjk23j") // Required for Auth.
.setDatabaseUrl("https://databasename3-d7r7.firebaseio.com") // Required for RTDB.
.build();
FirebaseApp.initializeApp(context /* Context */, options3, "secondary3");
</code></pre>
<p>After initialisation my app is running fine. I can use FirebaseAuth, and FirebaseRTDB just fine but it is throwing error when it has to access firebase_Application_Id for analytics. </p>
<p>I have cross checked the ids from google-services.json files of all the projects. I don't know why but it throws error saying:</p>
<pre><code>Missing google_app_id. Firebase Analytics disabled.
</code></pre>
<p>I couldn't figure out the root of this error.</p>
| 0debug |
remove sign () in textview :
I have textview, and when displaying text there is a sign () in the text, I want to eliminate it, this is my coding
self.txtpstn.text = "\(self.no_pstn.self as NSArray)"
self.txtmobile.text = "\(self.no_mobile.self as NSArray)"
this is the display on the application
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/SAe1Z.png | 0debug |
Getting error variable is inaccessible : <p>I've been writing some code for a small console based game that features a player and some enemies. So far I have only written one of the methods for my player class.
The player class is a child class of a parent class called entity that also has a child class called enemy. In a method of player.cpp, <code>void player::takeInput()</code>, I attempt to modify the value <code>this->xCoordinate</code> where <code>int xCoordinate</code> is a public member of the entity class. Whenever I compile this code, I am given the error:</p>
<pre><code>include\entity.h line 31 error: 'int entity::xCoordinate' is inaccessible
C:\Users....\ line 72 error: 'error within this context'
</code></pre>
<p>Note that on line 72 the code is:</p>
<pre><code>int newX = this->xCoordinate;
</code></pre>
<p>This error is repeated for all of the other (many) calls I make to <code>this->xCoordinate</code> or <code>this->yCoordinate</code> each time with the error on line 31 of entity.h and the error: 'error within this context'.</p>
<p>I think that this error is something to do with how the classes inherit from each other. The only solution I was able to find, was addressing a problem where the member was labelled private, which doesn't apply to this issue as I have labelled my member as public.</p>
<p>I'm not a super experienced programmer and would only rate myself as intermediate, so please excuse the code if it contains more than a few mistakes!</p>
<p>Thanks in advance for any help!
Here's the source code, note that I haven't done too much work on the rest of the project yet:</p>
<p>main.cpp:</p>
<pre><code>#include <iostream>
#include <stdlib.h>
#include "entity.h"
#include "player.h"
#include "enemy.h"
#include <vector>
using namespace std;
int playerX;
int playerY;
int noEnemies;
void initGrid()
{
return;
}
void dispGrid()
{
return;
}
int verifyMove(int x, int y)
{
return 0;
}
void aiTurn()
{
return;
}
int main()
{
return 0;
}
</code></pre>
<p>entity.h:</p>
<pre><code>#ifndef ENTITY_H
#define ENTITY_H
#include <iostream>
#include <vector>
using namespace std;
enum direction
{
NORTH,
SOUTH,
EAST,
WEST
};
enum weaponClass
{
PISTOL,
SWORD,
RIFLE,
SHOTGUN
};
class entity
{
public:
weaponClass currentWeapon;
int health;
int weaponStrength;
int xCoordinate;
int yCoordinate;
string spritePath;
string name;
protected:
private:
};
#endif // ENTITY_H
</code></pre>
<p>entity.cpp contains no code as it has no methods. It is merely used as a grouping for enemy.h and player.h</p>
<p>player.h:</p>
<pre><code>#ifndef PLAYER_H
#define PLAYER_H
#include "entity.h"
#include <iostream>
class player : public entity
{
public:
direction nextMoveDir;
direction attackDir;
int ammunition;
player();
virtual ~player();
virtual void addToGrid();
virtual void draw();
void takeInput();
void restoreHealth();
void makeMove();
int health;
protected:
private:
};
#endif // PLAYER_H
</code></pre>
<p>player.cpp: (sorry for the huge amount of code!)</p>
<pre><code>#include "player.h"
#include "entity.h"
#include "enemy.h"
#include <iostream>
#include <vector>
using namespace std;
player::player()
{
//ctor
}
player::~player()
{
//dtor
}
vector<enemy*> listOfEntities;
void player::takeInput()
{
cout << "Would you like to move (1), or attack (2)?" << endl;
int input;
cin >> input;
if(input == 1)
{
bool cont = false;
while(!cont)
{
cont = true;
// Moving
cout << "In which direction would you like to move:" << endl;
cout << "1) North, 2) South, 3) East, 4) West." << endl;
int newX = this->xCoordinate;
int newY = this->yCoordinate;
cin >> input;
switch(input)
{
case 1:
this->nextMoveDir = NORTH;
newX++;
break;
case 2:
this->nextMoveDir = SOUTH;
newX--;
break;
case 3:
this->nextMoveDir = EAST;
newY++;
break;
case 4:
this->nextMoveDir = WEST;
newY--;
break;
default:
cont = false;
cout << "Invalid selection." << endl;
break;
}
for(int i = 0; i < listOfEntities.size(); i++)
{
int itrX = listOfEntities[i]->xCoordinate;
int itrY = listOfEntities[i]->yCoordinate;
if(((newX == this->xCoordinate) && (newY = this->yCoordinate))) )
{
// tile is occupied
cout << "That tile is occupied!" << endl;
cont = false;
break;
}
}
}
}
else if(input == 2)
{
// Attacking
bool cont = false;
while(!cont)
{
cont = true;
switch(this->currentWeapon)
{
case SWORD:
cout << "Your current weapon is a sword that has a range of 1 and a damage rating of 5." << endl;
cout << "In which direction do you wish to attack:" << endl;
cout << "1) North, 2) South, 3) East, 4) West." << endl;
int input;
cin >> input;
enemy *enemyToAttack;
switch(input)
{
case 1:
this->attackDir = NORTH;
for(int i = 0; i < listOfEntities.size(); i++)
{
int xCor = listOfEntities[i]->xCoordinate;
int yCor = listOfEntities[i]->yCoordinate;
if((xCor == this->xCoordinate) && (xCor = this->yCoordinate+1))
{
enemyToAttack = listOfEntities[i];
}
}
break;
case 2:
this->attackDir = SOUTH;
for(int i = 0; i < listOfEntities.size(); i++)
{
int xCor = listOfEntities[i]->xCoordinate;
int yCor = listOfEntities[i]->yCoordinate;
if((xCor == this->xCoordinate) && (xCor = this->yCoordinate-1))
{
enemyToAttack = listOfEntities[i];
}
}
break;
case 3:
this->attackDir = EAST;
for(int i = 0; i < listOfEntities.size(); i++)
{
int xCor = listOfEntities[i]->xCoordinate;
int yCor = listOfEntities[i]->yCoordinate;
if((xCor == this->xCoordinate+1) && (xCor = this->yCoordinate))
{
enemyToAttack = listOfEntities[i];
}
}
break;
case 4:
this->attackDir = WEST;
for(int i = 0; i < listOfEntities.size(); i++)
{
int xCor = listOfEntities[i]->xCoordinate;
int yCor = listOfEntities[i]->yCoordinate;
if((xCor == this->xCoordinate-1) && (xCor = this->yCoordinate))
{
enemyToAttack = listOfEntities[i];
}
}
break;
default:
cont = false;
cout << "Invalid selection." << endl;
break;
}
if(enemyToAttack == NULL)
{
player::takeInput();
}
enemyToAttack->health = health - 5;
cout << "You attack the enemy for 5 damage!" << endl;
cout << "They are now on " << enemyToAttack->health << "HP." << endl;
break;
case PISTOL:
cout << "Your current weapon is a pistol that has a range of 4 and a damage rating of 3 with " << this->ammunition << " bullets remaining." << endl;
cout << "In which direction do you wish to attack:" << endl;
cout << "1) North, 2) South, 3) East, 4) West." << endl;
cin >> input;
switch(input)
{
case 1:
this->attackDir = NORTH;
for(int i = 0; i < 4; i++)
{
for(int j = 0; j < listOfEntities.size(); j++)
{
int xCor = listOfEntities[j]->xCoordinate;
int yCor = listOfEntities[j]->yCoordinate;
if((xCor == this->xCoordinate) && (xCor = this->yCoordinate+i))
{
enemyToAttack = listOfEntities[j];
}
}
break;
}
cout << "Your attack missed!" << endl;
break;
case 2:
this->attackDir = SOUTH;
for(int i = 0; i < 4; i++)
{
for(int j = 0; j < listOfEntities.size(); j++)
{
int xCor = listOfEntities[j]->xCoordinate;
int yCor = listOfEntities[j]->yCoordinate;
if((xCor == this->xCoordinate) && (xCor = this->yCoordinate-i))
{
enemyToAttack = listOfEntities[j];
}
}
break;
}
cout << "Your attack missed!" << endl;
break;
case 3:
this->attackDir = EAST;
for(int i = 0; i < 4; i++)
{
for(int j = 0; j < listOfEntities.size(); j++)
{
int xCor = listOfEntities[j]->xCoordinate;
int yCor = listOfEntities[j]->yCoordinate;
if((xCor == this->xCoordinate+i) && (xCor = this->yCoordinate))
{
enemyToAttack = listOfEntities[j];
}
}
break;
}
cout << "Your attack missed!" << endl;
break;
case 4:
this->attackDir = WEST;
for(int i = 0; i < 4; i++)
{
for(int j = 0; j < listOfEntities.size(); j++)
{
int xCor = listOfEntities[j]->xCoordinate;
int yCor = listOfEntities[j]->yCoordinate;
if((xCor == this->xCoordinate-i) && (xCor = this->yCoordinate))
{
enemyToAttack = listOfEntities[j];
}
}
break;
}
cout << "Your attack missed!" << endl;
break;
default:
cont = false;
cout << "Invalid selection." << endl;
break;
}
if(enemyToAttack == NULL)
{
cout << "Your attack missed!" << endl;
break;
}
enemyToAttack->health = health - 3;
cout << "You attack the enemy for 3 damage!" << endl;
cout << "They are now on " << enemyToAttack->health << "HP." << endl;
break;
case RIFLE:
cout << "Your current weapon is a rifle that has a range of 10 and a damage rating of 6 with " << this->ammunition << " bullets remaining." << endl;
cout << "In which direction do you wish to attack:" << endl;
cout << "1) North, 2) South, 3) East, 4) West." << endl;
cin >> input;
switch(input)
{
case 1:
this->attackDir = NORTH;
for(int i = 0; i < 10; i++)
{
for(int j = 0; j < listOfEntities.size(); j++)
{
int xCor = listOfEntities[j]->xCoordinate;
int yCor = listOfEntities[j]->yCoordinate;
if((xCor == this->xCoordinate) && (xCor = this->yCoordinate+1))
{
enemyToAttack = listOfEntities[j];
}
}
break;
}
cout << "Your attack missed!" << endl;
break;
case 2:
this->attackDir = SOUTH;
for(int i = 0; i < 10; i++)
{
for(int j = 0; j < listOfEntities.size(); j++)
{
int xCor = listOfEntities[j]->xCoordinate;
int yCor = listOfEntities[j]->yCoordinate;
if((xCor == this->xCoordinate) && (xCor = this->yCoordinate+1))
{
enemyToAttack = listOfEntities[j];
}
}
break;
}
cout << "Your attack missed!" << endl;
break;
case 3:
this->attackDir = EAST;
for(int i = 0; i < 10; i++)
{
for(int j = 0; j < listOfEntities.size(); j++)
{
int xCor = listOfEntities[j]->xCoordinate;
int yCor = listOfEntities[j]->yCoordinate;
if((xCor == this->xCoordinate+i) && (xCor = this->yCoordinate))
{
enemyToAttack = listOfEntities[j];
}
}
break;
}
cout << "Your attack missed!" << endl;
break;
// Confirm that there is nothing in the way of the move.se 4:
this->attackDir = WEST;
for(int i = 0; i < 10; i++)
{
for(int j = 0; j < listOfEntities.size(); j++)
{
int xCor = listOfEntities[j]->xCoordinate;
int yCor = listOfEntities[j]->yCoordinate;
if((xCor == this->xCoordinate-i) && (xCor = this->yCoordinate))
{
enemyToAttack = listOfEntities[j];
}
}
break;
}
cout << "Your attack missed!" << endl;
break;
default:
cont = false;
cout << "Invalid selection." << endl;
break;
}
if(enemyToAttack == NULL)
{
cout << "Your attack missed!" << endl;
break;
}
enemyToAttack->health = health - 6;
cout << "You attack the enemy for 6 damage!" << endl;
cout << "They are now on " << enemyToAttack->health << "HP." << endl;
break;
case SHOTGUN:
cout << "Your current weapon is a shotgun that has a range of 2 and a damage rating of 10 with " << this->ammunition << " cartridges remaining." << endl;
cout << "In which direction do you wish to attack:" << endl;
cout << "1) North, 2) South, 3) East, 4) West." << endl;
cin >> input;
switch(input)
{
case 1:
this->attackDir = NORTH;
for(int i = 0; i < 2; i++)
{
for(int j = 0; j < listOfEntities.size(); j++)
{
int xCor = listOfEntities[j]->xCoordinate;
int yCor = listOfEntities[j]->yCoordinate;
if((xCor == this->xCoordinate) && (xCor = this->yCoordinate+1))
{
enemyToAttack = listOfEntities[j];
}
}
break;
}
cout << "Your attack missed!" << endl;
break;
case 2:
this->attackDir = SOUTH;
for(int i = 0; i < 2; i++)
{
for(int j = 0; j < listOfEntities.size(); j++)
{
int xCor = listOfEntities[j]->xCoordinate;
int yCor = listOfEntities[j]->yCoordinate;
if((xCor == this->xCoordinate) && (xCor = this->yCoordinate-1))
{
enemyToAttack = listOfEntities[j];
}
}
break;
}
cout << "Your attack missed!" << endl;
break;
case 3:
this->attackDir = EAST;
for(int i = 0; i < 2; i++)
{
for(int j = 0; j < listOfEntities.size(); j++)
{
int xCor = listOfEntities[j]->xCoordinate;
int yCor = listOfEntities[j]->yCoordinate;
if((xCor == this->xCoordinate+1) && (xCor = this->yCoordinate))
{
enemyToAttack = listOfEntities[j];
}
}
break;
}
cout << "Your attack missed!" << endl;
break;
case 4:
this->attackDir = WEST;
for(int i = 0; i < 2; i++)
{
for(int j = 0; j < listOfEntities.size(); j++)
{
int xCor = listOfEntities[j]->xCoordinate;
int yCor = listOfEntities[j]->yCoordinate;
if((xCor == this->xCoordinat-1) && (xCor = this->yCoordinate))
{
enemyToAttack = listOfEntities[j];
}
}
break;
}
cout << "Your attack missed!" << endl;
break;
default:
cont = false;
cout << "Invalid selection." << endl;
break;
}
if(enemyToAttack == NULL)
{
cout << "Your attack missed!" << endl;
break;
}
enemyToAttack->health = health - 10;
cout << "You attack the enemy for 5 damage!" << endl;
cout << "They are now on " << enemyToAttack->health << "HP." << endl;
break;
}
}
}
}
</code></pre>
<p>enemy.h:</p>
<pre><code>#ifndef ENEMY_H
#define ENEMY_H
#include "entity.h"
#include <iostream>
class enemy : entity
{
public:
enemy();
virtual ~enemy();
void attackPlayer();
void upgradeHealth();
void upgradeWeapons();
int health;
protected:
private:
};
#endif // ENEMY_H
</code></pre>
<p>enemy.cpp has no code yet.
I am using the GNU Compiler with Code::Blocks
Thanks!</p>
| 0debug |
Is it possible to post files to Slack using the incoming Webhook? : <p>I am trying out the Slack's API using the incoming webhook feature, posting messages works flawlessly, but it doesn't seem to allow any file attachments.</p>
<p>Looking through I understand I have to use a completely different OAuth based API, but creating more tokens just for the purpose of uploading a file seems odd when posting messages works well, is there no way to upload files to slack with the incoming webook?</p>
| 0debug |
How do I trim space in an input field? : <p>I am using an input field and when someone types in it they can add spaces as general behavior. I do not want anyone to add spaces into the field and even if someone adds one it should trim there and then.</p>
<p>Can someone please help on how to achieve this?</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><input type="text"></code></pre>
</div>
</div>
</p>
| 0debug |
void put_string(PutBitContext * pbc, char *s)
{
while(*s){
put_bits(pbc, 8, *s);
s++;
}
put_bits(pbc, 8, 0);
}
| 1threat |
static float **alloc_audio_arrays(int channels, int frame_size)
{
float **audio = av_mallocz_array(channels, sizeof(float *));
if (!audio)
return NULL;
for (int ch = 0; ch < channels; ch++) {
audio[ch] = av_mallocz_array(frame_size, sizeof(float));
if (!audio[ch]) {
for (ch--; ch >= 0; ch--)
av_free(audio[ch]);
av_free(audio);
return NULL;
}
}
return audio;
}
| 1threat |
Converting a number string to a number? : <p>I have a number string:</p>
<pre><code>$1,000,000
</code></pre>
<p>Is there an easy way to convert it to a number figure soit can be worked with as a number.</p>
<pre><code>1000000
</code></pre>
| 0debug |
How to convert string dd-MMM-yyyy HH:mm int0 datetime format in javascript : <p>I have string value like "26-APR-2019 16:40". I want to convert this in to date time in java script. Please help me.</p>
| 0debug |
Screen of an Old App in iPhone X iOS 11 Adjustment : <p>We updated today to xCode 9 and our Visual Studio for Xamarin Development.
I tested my apps on iPhone X and it has a spaces on upper and lower portion. Any idea and work around to update the app? </p>
<p>using Visual Studio Xamarin Forms.</p>
<p><a href="https://i.stack.imgur.com/WrQcq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WrQcq.png" alt="enter image description here"></a></p>
| 0debug |
How to convert String List to String in flutter? : <p>I need to convert List into string in dart.</p>
<p>i want to extract the value of list from preferences. I have tried this implementation but it is only giving me the last value.</p>
<pre><code> Future<List<String>>
services=SharedPrefSignUp.getSelectedServices();
services.then((onValue){
List<String>servicesList=onValue;
selectServicesText=servicesList.join(",");
});
</code></pre>
| 0debug |
vcard_emul_find_vreader_from_slot(PK11SlotInfo *slot)
{
VReaderList *reader_list = vreader_get_reader_list();
VReaderListEntry *current_entry = NULL;
if (reader_list == NULL) {
return NULL;
}
for (current_entry = vreader_list_get_first(reader_list); current_entry;
current_entry = vreader_list_get_next(current_entry)) {
VReader *reader = vreader_list_get_reader(current_entry);
VReaderEmul *reader_emul = vreader_get_private(reader);
if (reader_emul->slot == slot) {
return reader;
}
vreader_free(reader);
}
return NULL;
} | 1threat |
void commit_active_start(const char *job_id, BlockDriverState *bs,
BlockDriverState *base, int64_t speed,
BlockdevOnError on_error,
BlockCompletionFunc *cb,
void *opaque, Error **errp)
{
int64_t length, base_length;
int orig_base_flags;
int ret;
Error *local_err = NULL;
orig_base_flags = bdrv_get_flags(base);
if (bdrv_reopen(base, bs->open_flags, errp)) {
return;
}
length = bdrv_getlength(bs);
if (length < 0) {
error_setg_errno(errp, -length,
"Unable to determine length of %s", bs->filename);
goto error_restore_flags;
}
base_length = bdrv_getlength(base);
if (base_length < 0) {
error_setg_errno(errp, -base_length,
"Unable to determine length of %s", base->filename);
goto error_restore_flags;
}
if (length > base_length) {
ret = bdrv_truncate(base, length);
if (ret < 0) {
error_setg_errno(errp, -ret,
"Top image %s is larger than base image %s, and "
"resize of base image failed",
bs->filename, base->filename);
goto error_restore_flags;
}
}
mirror_start_job(job_id, bs, base, NULL, speed, 0, 0,
MIRROR_LEAVE_BACKING_CHAIN,
on_error, on_error, false, cb, opaque, &local_err,
&commit_active_job_driver, false, base);
if (local_err) {
error_propagate(errp, local_err);
goto error_restore_flags;
}
return;
error_restore_flags:
bdrv_reopen(base, orig_base_flags, NULL);
return;
}
| 1threat |
Persistent Warning: "Multiple packages failed to uninstall." : <p>I have a warning message that came to dinner but now won't leave.</p>
<blockquote>
<p>Multiple packages failed to uninstall. Restart Visual Studio to finish the process.</p>
</blockquote>
<p><a href="https://i.stack.imgur.com/T8Qui.png" rel="noreferrer"><img src="https://i.stack.imgur.com/T8Qui.png" alt="enter image description here"></a></p>
<p>Unfortunately, however, restarting Visual Studio has no effect—the warning remains.</p>
<p>I've tried cleaning the solution as well as the project; all of my projects' assembly references are intact. I've also issued an <code>Update-Package -Reinstall</code> command—which succeeded—to no avail.</p>
<p>How can I set about fixing this?</p>
| 0debug |
how to update data by using id in php & mysql i update but data not updated data should be deleted why : [enter image description here][1]
I share one image that image contain program. i try to update data by using that program but data is not updated in the table but it shows that data is updated successfully but data is not updated. when i try to execute that program data is deleted.then how can i update data.
jalsjflajflkasjdlkfjsadlkjflkasdjflksadjlkfjsdalkfjsdalkjfal
[enter image description here][enter image description here][1]
[1]: https://i.stack.imgur.com/BJK8r.png | 0debug |
Beginner's Python- What is my Mistake? : <p>This is Sheldon Cooper's Friendship Algorithm.
Python code.
Please help me find the mistake.
I doubled checked it x200 times but can't seem to find it.
I'm in high school so this would be pretty easy for all of you.
.</p>
<pre><code>print("The Friendship Algorithm \n By Dr. Sheldon Cooper Ph.D")
print("Place a phone call")
home = input("Are they home?")
if home == "yes":
print("Ask, would you like to share a meal?")
meal = input("What is their response?")
</code></pre>
<p>.</p>
<pre><code>if meal == "yes":
print("Dine together")
print("Begin friendship!")
elif meal == "no":
print("Ask, do you enjoy a hot beverage?")
</code></pre>
<p>.</p>
<pre><code> hot_beverage = input("What is their response?")
if hot_beverage == "yes":
beverage = input("Tea, coffee or cocoa?")
if beverage == "tea":
print("Have tea")
print("Begin friendship!")
elif beverage == "coffee":
print("Have coffee")
print("Begin friendship!")
elif beverage == "cocoa":
print("Have cocoa")
print("Begin friendship!")
else:
print("That is not an option")
</code></pre>
<p>.</p>
<pre><code> elif hot_beverage == "no":
while interest_cycle:
print("Recreational activities: \n Tell me one of your interests.")
interest = input("Do you share that interest?")
if n > 6:
print("Choose least objectional interest")
interest_cycle = False
elif interest == "no":
print("Ask for another")
n = n + 1
elif interest == "yes":
interest_cycle = False
print("Ask, why don't we do that together?")
print("Partake in interest")
print("Begin friendship!")
</code></pre>
<p>.</p>
<pre><code>else:
print("That is not an option")
</code></pre>
<p>.</p>
<pre><code>elif home == "no":
print("Leave message")
print("Wait for callback")
else:
print("That is not an option")
</code></pre>
| 0debug |
static int usb_serial_initfn(USBDevice *dev)
{
USBSerialState *s = DO_UPCAST(USBSerialState, dev, dev);
s->dev.speed = USB_SPEED_FULL;
qemu_chr_add_handlers(s->cs, usb_serial_can_read, usb_serial_read,
usb_serial_event, s);
usb_serial_handle_reset(dev);
return 0; | 1threat |
math program with uninitialized local variable choice : <pre><code> void main()
{
int choice;
//printf("You have selected the choice %d",menu());
if (choice == 1)
{
printf("You have selected addition\n");
additionmenu();
}
else if (choice == 2)
{
printf("You have selected subtraction\n");
subtractionmenu();
}
else if (choice == 3)
{
printf("You have selected multiplication\n");
multiplicationmenu();
}
else
{
printf("Invalid choice\n");
}
system("pause");
</code></pre>
<p>its show uninitialized local variable choice used,its it have anything to do with another choice that i declare as char choice?</p>
| 0debug |
How can I solve No 'Access-Control-Allow-Origin' header is present on the requested resource in axios? : <p>My vue script like this :</p>
<pre><code><script>
export default {
...
methods : {
login() {
// uri -> http://my-app.test/login?email=test@gmail.com&password=1234
this.axios.get(uri).then((response) => {
console.log(response)
...
},
...
}
}
}
</script>
</code></pre>
<p>When login method executed, on the console exist error like this :</p>
<blockquote>
<p>Failed to load
<a href="http://my-app.test/login?email=test@gmail.com&password=1234" rel="nofollow noreferrer">http://my-app.test/login?email=test@gmail.com&password=1234</a>: No
'Access-Control-Allow-Origin' header is present on the requested
resource. Origin '<a href="http://localhost:8080" rel="nofollow noreferrer">http://localhost:8080</a>' is therefore not allowed
access.</p>
</blockquote>
<p>How can I solve the error?</p>
| 0debug |
Node.js setTimeout in forever loop : <p>Can't explain nodejs behavior. I have code:</p>
<pre><code>while (true) {
setTimeout(() => console.log(1), 0)
}
</code></pre>
<p>And this script just hanging...</p>
<p>How come? I've been thinking <code>setTimeout</code> is non-blocking and asynchronous, and nodejs use <code>timers</code> event loop phase for scheduling <code>setTimeout</code> callbacks... but it seems like event loop blocked...</p>
| 0debug |
How do I work with the alphavantage API to fetch the currency exchange data using either JSON or php? : https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=USD&to_currency=JPY&apikey=demo
DATA AS FOLLOWS:-
Realtime Currency Exchange Rate
1. From_Currency Code "USD"
2. From_Currency Name "United States Dollar"
3. To_Currency Code "JPY"
4. To_Currency Name "Japanese Yen"
5. Exchange Rate "108.99000000"
6. Last Refreshed "2020-01-28 14:27:02"
7. Time Zone "UTC"
8. Bid Price "108.99000000"
9. Ask Price "108.99000000" | 0debug |
Google Chrome clears CSS styles for current page when opening link in new tab or opening a new window : <p>This is odd one, I was troubleshooting for 3 days.</p>
<p>Only happening in <code>Chrome Version 53.0.2785.116 m (64-bit)</code> on Windows.</p>
<p>Web server must have header set (meta tag doesn't work in this case):</p>
<p>Apache's .htaccess: <code>Header set Cache-Control "no-cache"</code>
or nginx: <code>add_header Cache-Control no-cache;</code> </p>
<p>You can't recreate it using jsfiddle or built-in code snippet, because css file must be loaded separately using <code><link href='style.css' rel='stylesheet' type='text/css'></code>. (but I will include code in snippet anyways).</p>
<p>Steps to recreate:</p>
<ol>
<li>Visit: <a href="http://test.xmpsoft.net/">http://test.xmpsoft.net/</a></li>
<li>Click on link 1 (should reload the page);</li>
<li>Click on link 2 (should bring up new tab with the same page);</li>
<li>Switch to the original tab and repeat same steps;</li>
<li>All CSS styles are gone from the original tab.</li>
<li>If not, repeat same steps again.</li>
</ol>
<p>Please assist to make sure where is nothing wrong with the code before I submit it to Google.</p>
<p>Thanks.</p>
<p>P.S. There is another way or recreating it (that's why I mentioned 'new window' in my Title: Visit same page, reload it, right click -> Inspect (new Development Tools window opens), switch back to the page (repeat if not able to recreate).</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.menu div {
display: inline-block;
width: 15em;
height: 15em;
}
.red {
background-color: red;
}
.yellow {
background-color: yellow;
}
.green {
background-color: green;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<title>Chrome bug</title>
<link href='style.css' rel='stylesheet' type='text/css'>
</head>
<body>
<div class='menu'>
<div class='red'>Red</div>
<div class='yellow'>Yellow</div>
<div class='green'>Green</div>
</div>
<a href='/'>1. Reload this page</a><br>
<a href='/' target='_blank'>2. Open same page in new tab</a>
</body>
</html></code></pre>
</div>
</div>
</p>
| 0debug |
can any one please let me know about ratings and reviews of appstore? : <blockquote>
<p>In Itunes, I got 248 ratings for my app, but still it is showing only 6 rating in appstore.Can any one please let me know about ratings and reviews of appstore???</p>
</blockquote>
| 0debug |
output video/gif file css or javascript animations : <p>Is there any possibility to convert css animations or javascript libraries like (threejs, tweenmax, ... or even simple js) into a video or a gif and output it as a file by code?</p>
| 0debug |
How to break flow of code in Swift? : <p>I am unable to break the execution of code using 'return' keyword in Swift language. Please suggest the another way around for how to break the code execution flow if need be in Swift.</p>
| 0debug |
I'm learning multidimensional arrays and trying to write them out with for. I found it, but I don't understand how it works : <p>so I'm learning Java nad now I'm on multidimensional arrays. I think I understand how they work. And I found how to write them out with for, but the whing is what happens with for and why we need two for's. This is the code:</p>
<pre><code>int[][] myNumbers = { {1, 2, 3, 4}, {5, 6, 7} };
for (int i = 0; i < myNumbers.length; i++) {
for (int j = 0; j < myNumbers[i].length; j++) {
System.out.println(myNumbers[i][j]);
}
}
</code></pre>
| 0debug |
how to return opposite of true or false : I was interview in company and i was asked a question , question was bti strange so wanted to ask with expert guys.
The question suppose i have function which returns bool type, Lets say this :
public bool func(int param)
{
bool retVal;
//here is some algorithm which as a result either set the retVal to false or true, It doesnt matter what is algo, the only thing important is it either do retVal=false or retVal=true
// The question is i have to write the algo here which in case if the previous algo gives us retVal=fale then it should return true and if retVal=true then return flase
}
**What should be that algo ?* | 0debug |
How to upload files in Laravel directly into public folder? : <p>The server which I'm hosting my website does not support <code>links</code> so I cannot run the <code>php artisan storage:link</code> to link my storage directory into the public directory. I tried to remake the disk configuration in the <strong>filesystems.php</strong> to directly reference the <code>public</code> folder but it didn't seems to work either. Is there a way to upload a file using Laravel libraries directly into the public folder or will I have to use a php method? Thanks in advance.</p>
| 0debug |
Let's say I have a list. What's the difference between lst[0] and [lst[0]]? : <p>I know what lst[x] means in Python, which is basically the element in that index. But i'm not sure what [lst[x]] means.</p>
<p>new to programming btw so go ez</p>
| 0debug |
Replace Validation Monitors with tf.train.SessionRunHook when using Estimators : <p>I am running a DNNClassifier, for which I am monitoring accuracy while training. monitors.ValidationMonitor from contrib/learn has been working great, in my implementation I define it:</p>
<pre><code>validation_monitor = skflow.monitors.ValidationMonitor(input_fn=lambda: input_fn(A_test, Cl2_test), eval_steps=1, every_n_steps=50)
</code></pre>
<p>and then use call from:</p>
<pre><code>clf.fit(input_fn=lambda: input_fn(A, Cl2),
steps=1000, monitors=[validation_monitor])
</code></pre>
<p>where: </p>
<pre><code>clf = tensorflow.contrib.learn.DNNClassifier(...
</code></pre>
<p>This works fine. That said, validation monitors appear to be deprecated and a similar functionality to be replaced with <code>tf.train.SessionRunHook</code>. </p>
<p>I am a newbie in TensorFlow, and it does not seem trivial to me how such a replacing implementation would look like. Any suggestion are highly appreciated. Again, I need to validate the training after a specific number of steps.
Thanks very much in advance.</p>
| 0debug |
static uint64_t uart_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
UartState *s = (UartState *)opaque;
uint32_t c = 0;
offset >>= 2;
if (offset >= R_MAX) {
return 0;
} else if (offset == R_TX_RX) {
uart_read_rx_fifo(s, &c);
return c;
}
return s->r[offset];
}
| 1threat |
Remove unnecessary part of a filename in powershell : <p>I'm sorry, I know this is a noob question, but I've researched for more than 5 hours now and can't figure out how to achieve what I want.</p>
<p>I have a folder with lots files in the form of:</p>
<p>"Artist - Song Tttle (ft. Ruth B) (Prod. Blulake)-28GpKacWLWI.mp4"<br>
"Some other Artist - Song Tittle [HD]-ZN9cJvl-P4c.mp4"<br>
"DNMO & Sub Urban - Broken (Official Lyric Video)-KZT-_VW-k38.mp4" </p>
<p>And I want to rename them all to:
"Artist - Song Tttle (ft. Ruth B) (Prod. Blulake).mp4"<br>
"Some other Artist - Song Tittle [HD].mp4"<br>
"DNMO & Sub Urban - Broken (Official Lyric Video).mp4" </p>
<p>Please help!</p>
| 0debug |
How to bind json data : <p>I've json response from server looks like that</p>
<pre><code>{
"117":{
"09:00":5,
"10:00":5,
"11:00":5,
"12:00":5,
"13:00":5,
"14:00":5,
"15:00":5,
"16:00":5,
"17:00":5,
"18:00":5,
"19:00":5
}
}
</code></pre>
<p>How I can bind this to normal select to looks like that</p>
<pre><code><select name="time" id="time">
<option value="5">09:00</option>
<option value="5">10:00</option>
<option value="5">11:00</option>
</select>
</code></pre>
<p>Hours are not always the same, could be from 11:00 to 21:00.
Any idea how to display this in php or bind by jquery.
Thank you for response</p>
| 0debug |
int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush){
AVPacketList *pktl;
int stream_count=0, noninterleaved_count=0;
int64_t delta_dts_max = 0;
int i;
if(pkt){
ff_interleave_add_packet(s, pkt, ff_interleave_compare_dts);
}
for(i=0; i < s->nb_streams; i++) {
if (s->streams[i]->last_in_packet_buffer) {
++stream_count;
} else if(s->streams[i]->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
++noninterleaved_count;
}
}
if (s->nb_streams == stream_count) {
flush = 1;
} else if (!flush){
for(i=0; i < s->nb_streams; i++) {
if (s->streams[i]->last_in_packet_buffer) {
int64_t delta_dts =
av_rescale_q(s->streams[i]->last_in_packet_buffer->pkt.dts,
s->streams[i]->time_base,
AV_TIME_BASE_Q) -
av_rescale_q(s->packet_buffer->pkt.dts,
s->streams[s->packet_buffer->pkt.stream_index]->time_base,
AV_TIME_BASE_Q);
delta_dts_max= FFMAX(delta_dts_max, delta_dts);
}
}
if(s->nb_streams == stream_count+noninterleaved_count &&
delta_dts_max > 20*AV_TIME_BASE) {
av_log(s, AV_LOG_DEBUG, "flushing with %d noninterleaved\n", noninterleaved_count);
flush = 1;
}
}
if(stream_count && flush){
pktl= s->packet_buffer;
*out= pktl->pkt;
s->packet_buffer= pktl->next;
if(!s->packet_buffer)
s->packet_buffer_end= NULL;
if(s->streams[out->stream_index]->last_in_packet_buffer == pktl)
s->streams[out->stream_index]->last_in_packet_buffer= NULL;
av_freep(&pktl);
return 1;
}else{
av_init_packet(out);
return 0;
}
}
| 1threat |
static int msvideo1_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
Msvideo1Context *s = avctx->priv_data;
int ret;
s->buf = buf;
s->size = buf_size;
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
return ret;
if (s->mode_8bit) {
int size;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
if (pal && size == AVPALETTE_SIZE) {
memcpy(s->pal, pal, AVPALETTE_SIZE);
s->frame->palette_has_changed = 1;
} else if (pal) {
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
if (s->mode_8bit)
msvideo1_decode_8bit(s);
else
msvideo1_decode_16bit(s);
if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
*got_frame = 1;
return buf_size; | 1threat |
Can't git push to Bitbucket: Unauthorized - fatal: Could not read from remote repository : <p>I can't push to Bitbucket and this is the error message:</p>
<blockquote>
<p>> git push origin master:master<br>
Unauthorized<br>
fatal: Could not read from remote repository.</p>
<p>Please make sure you have the correct access rights and the repository
exists.</p>
</blockquote>
<p>Debugging, I receive this message when I ssh to bitbucket:</p>
<blockquote>
<p>> ssh -T bitbucket.org<br>
authenticated via a deploy key.</p>
<p>You can use git or hg to connect to Bitbucket. Shell access is
disabled.</p>
<p>This deploy key has read access to the following repositories:<br>
my-username/my-repository</p>
</blockquote>
<p>The <strong>read access</strong> part of this message is suspicious.</p>
<p>PS: I know there are dozens of similar questions, but I couldn't find the exact error message here and only got <a href="https://community.atlassian.com/t5/Bitbucket-questions/Unable-to-push-code-to-my-private-repo/qaq-p/708507" rel="noreferrer">the solution outside</a>. That's why I'm self answering this to help others.</p>
| 0debug |
Python argparse : How can I get Namespace objects for argument groups separately? : <p>I have some command line arguments categorized in groups as follows:</p>
<pre><code>cmdParser = argparse.ArgumentParser()
cmdParser.add_argument('mainArg')
groupOne = cmdParser.add_argument_group('group one')
groupOne.add_argument('-optA')
groupOne.add_argument('-optB')
groupTwo = cmdParser.add_argument_group('group two')
groupTwo.add_argument('-optC')
groupTwo.add_argument('-optD')
</code></pre>
<p>How can I parse the above, such that I end up with three different Namespace objects?</p>
<pre><code>global_args - containing all the arguments not part of any group
groupOne_args - containing all the arguments in groupOne
groupTwo_args - containing all the arguments in groupTwo
</code></pre>
<p>Thank you!</p>
| 0debug |
static int monitor_check_qmp_args(const mon_cmd_t *cmd, QDict *args)
{
int err;
const char *p;
CmdArgs cmd_args;
QemuOptsList *opts_list;
if (cmd->args_type == NULL) {
return (qdict_size(args) == 0 ? 0 : -1);
}
err = 0;
cmd_args_init(&cmd_args);
opts_list = NULL;
for (p = cmd->args_type;; p++) {
if (*p == ':') {
cmd_args.type = *++p;
p++;
if (cmd_args.type == '-') {
cmd_args.flag = *p++;
cmd_args.optional = 1;
} else if (cmd_args.type == 'O') {
opts_list = qemu_find_opts(qstring_get_str(cmd_args.name));
assert(opts_list);
} else if (*p == '?') {
cmd_args.optional = 1;
p++;
}
assert(*p == ',' || *p == '\0');
if (opts_list) {
err = check_opts(opts_list, args);
opts_list = NULL;
} else {
err = check_arg(&cmd_args, args);
QDECREF(cmd_args.name);
cmd_args_init(&cmd_args);
}
if (err < 0) {
break;
}
} else {
qstring_append_chr(cmd_args.name, *p);
}
if (*p == '\0') {
break;
}
}
QDECREF(cmd_args.name);
return err;
}
| 1threat |
static void *file_ram_alloc(RAMBlock *block,
ram_addr_t memory,
const char *path,
Error **errp)
{
bool unlink_on_error = false;
char *filename;
char *sanitized_name;
char *c;
void *area = MAP_FAILED;
int fd = -1;
int64_t file_size;
if (kvm_enabled() && !kvm_has_sync_mmu()) {
error_setg(errp,
"host lacks kvm mmu notifiers, -mem-path unsupported");
return NULL;
}
for (;;) {
fd = open(path, O_RDWR);
if (fd >= 0) {
break;
}
if (errno == ENOENT) {
fd = open(path, O_RDWR | O_CREAT | O_EXCL, 0644);
if (fd >= 0) {
unlink_on_error = true;
break;
}
} else if (errno == EISDIR) {
sanitized_name = g_strdup(memory_region_name(block->mr));
for (c = sanitized_name; *c != '\0'; c++) {
if (*c == '/') {
*c = '_';
}
}
filename = g_strdup_printf("%s/qemu_back_mem.%s.XXXXXX", path,
sanitized_name);
g_free(sanitized_name);
fd = mkstemp(filename);
if (fd >= 0) {
unlink(filename);
g_free(filename);
break;
}
g_free(filename);
}
if (errno != EEXIST && errno != EINTR) {
error_setg_errno(errp, errno,
"can't open backing store %s for guest RAM",
path);
goto error;
}
}
block->page_size = qemu_fd_getpagesize(fd);
block->mr->align = block->page_size;
#if defined(__s390x__)
if (kvm_enabled()) {
block->mr->align = MAX(block->mr->align, QEMU_VMALLOC_ALIGN);
}
#endif
file_size = get_file_size(fd);
if (memory < block->page_size) {
error_setg(errp, "memory size 0x" RAM_ADDR_FMT " must be equal to "
"or larger than page size 0x%zx",
memory, block->page_size);
goto error;
}
if (file_size > 0 && file_size < memory) {
error_setg(errp, "backing store %s size 0x%" PRIx64
" does not match 'size' option 0x" RAM_ADDR_FMT,
path, file_size, memory);
goto error;
}
memory = ROUND_UP(memory, block->page_size);
if (!file_size && ftruncate(fd, memory)) {
perror("ftruncate");
}
area = qemu_ram_mmap(fd, memory, block->mr->align,
block->flags & RAM_SHARED);
if (area == MAP_FAILED) {
error_setg_errno(errp, errno,
"unable to map backing store for guest RAM");
goto error;
}
if (mem_prealloc) {
os_mem_prealloc(fd, area, memory, errp);
if (errp && *errp) {
goto error;
}
}
block->fd = fd;
return area;
error:
if (area != MAP_FAILED) {
qemu_ram_munmap(area, memory);
}
if (unlink_on_error) {
unlink(path);
}
if (fd != -1) {
close(fd);
}
return NULL;
}
| 1threat |
How can I let the gitlab-ci-runner DinD image cache intermediate images? : <p>I have a Dockerfile that starts with installing the texlive-full package, which is huge and takes a long time. If I <code>docker build</code> it locally, the intermedate image created after installation is cached, and subsequent builds are fast.</p>
<p>However, if I push to my own GitLab install and the GitLab-CI build runner starts, this always seems to start from scratch, redownloading the <code>FROM</code> image, and doing the apt-get install again. This seems like a huge waste to me, so I'm trying to figure out how to get the GitLab DinD image to cache the intermediate images between builds, without luck so far.</p>
<p>I have tried using the <code>--cache-dir</code> and <code>--docker-cache-dir</code> for the <code>gitlab-runner register</code> command, to no avail.</p>
<p>Is this even something the gitlab-runner DinD image is supposed to be able to do?</p>
<p>My <code>.gitlab-ci.yml</code>:</p>
<pre><code>build_job:
script:
- docker build --tag=example/foo .
</code></pre>
<p>My <code>Dockerfile</code>:</p>
<pre><code>FROM php:5.6-fpm
MAINTAINER Roel Harbers <roel.harbers@example.com>
RUN apt-get update && apt-get install -qq -y --fix-missing --no-install-recommends texlive-full
RUN echo Do other stuff that has to be done every build.
</code></pre>
<p>I use GitLab CE 8.4.0 and gitlab/gitlab-runner:latest as runner, started as</p>
<pre><code>docker run -d --name gitlab-runner --restart always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/local/gitlab-ci-runner/config:/etc/gitlab-runner \
gitlab/gitlab-runner:latest \
; \
</code></pre>
<p>The runner is registered using:</p>
<pre><code>docker exec -it gitlab-runner gitlab-runner register \
--name foo.example.com \
--url https://gitlab.example.com/ci \
--cache-dir /cache/build/ \
--executor docker \
--docker-image gitlab/dind:latest \
--docker-privileged \
--docker-disable-cache false \
--docker-cache-dir /cache/docker/ \
; \
</code></pre>
<p>This creates the following <code>config.toml</code>:</p>
<pre><code>concurrent = 1
[[runners]]
name = "foo.example.com"
url = "https://gitlab.example.com/ci"
token = "foobarsldkflkdsjfkldsj"
tls-ca-file = ""
executor = "docker"
cache_dir = "/cache/build/"
[runners.docker]
image = "gitlab/dind:latest"
privileged = true
disable_cache = false
volumes = ["/cache"]
cache_dir = "/cache/docker/"
</code></pre>
<p>(I have experimented with different values for <code>cache_dir</code>, <code>docker_cache_dir</code> and <code>disable_cache</code>, all with the same result: no caching whatsoever)</p>
| 0debug |
How to use a loop to get the following result in R through loop functions that summarizes my dates with my value box ? : [This is the current form of input data which I want to convert into the other image here][1]
[This is the expected output][2]
[1]: https://i.stack.imgur.com/WWlRv.png
[2]: https://i.stack.imgur.com/n1YBw.png | 0debug |
How to add the chrome binary to run e.g. Karma tests on headless chrome on a CI server : <p>I like to run my karma unit tests on a headless chrome. Using karma-chrome-launcher and setting the browser to "ChromeHeadless" works on my machine. But on the CI server it fails with the message "No binary for ChromeHeadless browser on your platform."
Installing chrome on the CI machine is not possible. Is there another way to load the chrome binaries?
for example the google puppeteer module seems to load that when run. from the docs: "Puppeteer downloads and uses a specific version of Chromium". How can i achieve the same?</p>
| 0debug |
int qemu_sendv(int sockfd, struct iovec *iov, int len, int iov_offset)
{
return do_sendv_recvv(sockfd, iov, len, iov_offset, 1);
}
| 1threat |
static int megasas_dcmd_ld_get_list(MegasasState *s, MegasasCmd *cmd)
{
struct mfi_ld_list info;
size_t dcmd_size = sizeof(info), resid;
uint32_t num_ld_disks = 0, max_ld_disks = s->fw_luns;
uint64_t ld_size;
BusChild *kid;
memset(&info, 0, dcmd_size);
if (cmd->iov_size < dcmd_size) {
trace_megasas_dcmd_invalid_xfer_len(cmd->index, cmd->iov_size,
dcmd_size);
return MFI_STAT_INVALID_PARAMETER;
}
if (megasas_is_jbod(s)) {
max_ld_disks = 0;
}
QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) {
SCSIDevice *sdev = DO_UPCAST(SCSIDevice, qdev, kid->child);
BlockConf *conf = &sdev->conf;
if (num_ld_disks >= max_ld_disks) {
break;
}
bdrv_get_geometry(conf->bs, &ld_size);
info.ld_list[num_ld_disks].ld.v.target_id = sdev->id;
info.ld_list[num_ld_disks].ld.v.lun_id = sdev->lun;
info.ld_list[num_ld_disks].state = MFI_LD_STATE_OPTIMAL;
info.ld_list[num_ld_disks].size = cpu_to_le64(ld_size);
num_ld_disks++;
}
info.ld_count = cpu_to_le32(num_ld_disks);
trace_megasas_dcmd_ld_get_list(cmd->index, num_ld_disks, max_ld_disks);
resid = dma_buf_read((uint8_t *)&info, dcmd_size, &cmd->qsg);
cmd->iov_size = dcmd_size - resid;
return MFI_STAT_OK;
}
| 1threat |
void sclp_print(const char *str)
{
int len = _strlen(str);
WriteEventData *sccb = (void*)_sccb;
sccb->h.length = sizeof(WriteEventData) + len;
sccb->h.function_code = SCLP_FC_NORMAL_WRITE;
sccb->ebh.length = sizeof(EventBufferHeader) + len;
sccb->ebh.type = SCLP_EVENT_ASCII_CONSOLE_DATA;
sccb->ebh.flags = 0;
_memcpy(sccb->data, str, len);
sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb);
}
| 1threat |
Is there a way to handle generic function in go : <p>I am new to go, and wanted to implement a scheduler that will recieve tasks(i.e interval + handler).
I got stuck in the part where I should get the handlers as go is a static language(I can't get a generic function signature).
I came up with the following solution:
each "handler" func will get wrapped by empty-interface:</p>
<pre><code>type GenericFunc interface{}
add_task(GenericFunc(my_func), p1, p2,...)
</code></pre>
<p>which will result in the following struct as for saving the handler and its params:</p>
<pre><code>type Task struct {
handler reflect.Value
params []reflect.Value
...
}
</code></pre>
<p>Tasks execution would be invoked by:</p>
<pre><code>func (t *Task) execute() {
t.handler.Call(t.params)
}
</code></pre>
<p>My question is this the right way to treat generic functions or is there a more idiomatic solution I'm missing?
thx.</p>
| 0debug |
VSCode Integrated Terminal Doesn't Load .bashrc or .bash_profile : <p>I have the following files to handle shell configuration:</p>
<pre><code>#~/.bash_profile
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
</code></pre>
<p>and</p>
<pre><code>#~/.bashrc
... configure shell
</code></pre>
<p>If I open VSCode from the command line using <code>code</code>, my <code>.bashrc</code> is loaded whenever I add a new instance of the integrated shell.</p>
<p>However if I open VSCode via its icon, only my <code>.profile</code> is loaded. </p>
<p><strong>How can I ensure my <code>.bashrc</code> is loaded instead?</strong></p>
<p>I've tried various settings for the <code>terminal.integrated.shellArgs.osx</code> setting without any luck.</p>
| 0debug |
Layouts in xamarin : How to check layout in cross platform application of app1.android.like I m saying without creating cross platform we can check layout in resources-Layout and xaml file,but in cross platform android with pcl I can't check my current layout of label in this middle of the form,In layout in app1.android there are 2 xaml files.Tabbar.xaml or toolbar.xaml,they both don't show way I m doing mainpage.xaml,it don't show like I write label and button,but when I debug it's shows currect output wat I written in mainpage.xaml.How I can see coding with design in it | 0debug |
Invalid zip file after creating it with System.IO.Compression : <p>I'm trying to create a zip file that contains one or more files.<br/>
I'm using the .NET framework 4.5 and more specifically System.IO.Compression namespace.<br/>
The objective is to allow a user to download a zip file through a ASP.NET MVC application.<br/>
The zip file is being generated and sent to the client but when I try to open it by doing double click on it I get the following error:<br/>
Windows cannot open the folder.
The compressed (zipped) folder ... is invalid.<br/>
Here's my code:</p>
<pre><code>[HttpGet]
public FileResult Download()
{
var fileOne = CreateFile(VegieType.POTATO);
var fileTwo = CreateFile(VegieType.ONION);
var fileThree = CreateFile(VegieType.CARROT);
IEnumerable<FileContentResult> files = new List<FileContentResult>() { fileOne, fileTwo, fileThree };
var zip = CreateZip(files);
return zip;
}
private FileContentResult CreateFile(VegieType vType)
{
string fileName = string.Empty;
string fileContent = string.Empty;
switch (vType)
{
case VegieType.BATATA:
fileName = "batata.csv";
fileContent = "THIS,IS,A,POTATO";
break;
case VegieType.CEBOLA:
fileName = "cebola.csv";
fileContent = "THIS,IS,AN,ONION";
break;
case VegieType.CENOURA:
fileName = "cenoura.csv";
fileContent = "THIS,IS,A,CARROT";
break;
default:
break;
}
var fileBytes = Encoding.GetEncoding(1252).GetBytes(fileContent);
return File(fileBytes, MediaTypeNames.Application.Octet, fileName);
}
private FileResult CreateZip(IEnumerable<FileContentResult> files)
{
byte[] retVal = null;
if (files.Any())
{
using (MemoryStream zipStream = new MemoryStream())
{
using (ZipArchive archive = new ZipArchive(zipStream, ZipArchiveMode.Create, false))
{
foreach (var f in files)
{
var entry = archive.CreateEntry(f.FileDownloadName, CompressionLevel.Fastest);
using (var entryStream = entry.Open())
{
entryStream.Write(f.FileContents, 0, f.FileContents.Length);
entryStream.Close();
}
}
zipStream.Position = 0;
retVal = zipStream.ToArray();
}
}
}
return File(retVal, MediaTypeNames.Application.Zip, "horta.zip");
}
</code></pre>
<p>Can anyone please shed some light on why is windows saying that my zip file is invalid when I double click on it.<br/>
A final consideration, I can open it using 7-Zip.</p>
| 0debug |
Angular2 retrieve all elements with class name : <p>Can anyone help with how to find 'All' Elements with a particular class name in Angular 2? I thought it would be trivial but it's giving me more problems that was prepared for. </p>
<pre><code><span class="classImLookingFor">foo</span>
<span class="classImLookingFor">Voo</span>
<span class="classImLookingFor">Moo</span>
</code></pre>
<p>I thought by doing what I have below would return all the elements with class "classImLookingFor" but it only returns the first instance. </p>
<pre><code>constructor(private renderer: Renderer){}
ngAfterViewInit(){
const el = this.renderer.selectRootElement('.classImLookingFor');
this.renderer.setElementAttribute(el, 'tabindex', 0);
}
</code></pre>
<p>Afterwards, my markup looks like this.</p>
<pre><code><span class="classImLookingFor" tabindex="0">foo</span>
<span class="classImLookingFor">Voo</span>
<span class="classImLookingFor">Moo</span>
</code></pre>
<p>It seems like I should be able to create a Renderer array, but that doesn't seem to work either. I need to manipulate each element with that class name. Thanks in Advance</p>
| 0debug |
Cannot assign value of type '[String]?' to type 'String?' (Swift) : This is the var `var types: [String]?` and here i get this error `myLabel3.text = place.types` how can i adjust it? I looked to other similar questions but not find something that is the same to my problem. | 0debug |
static int tag_tree_decode(Jpeg2000DecoderContext *s, Jpeg2000TgtNode *node,
int threshold)
{
Jpeg2000TgtNode *stack[30];
int sp = -1, curval = 0;
while (node && !node->vis) {
stack[++sp] = node;
node = node->parent;
}
if (node)
curval = node->val;
else
curval = stack[sp]->val;
while (curval < threshold && sp >= 0) {
if (curval < stack[sp]->val)
curval = stack[sp]->val;
while (curval < threshold) {
int ret;
if ((ret = get_bits(s, 1)) > 0) {
stack[sp]->vis++;
break;
} else if (!ret)
curval++;
else
return ret;
}
stack[sp]->val = curval;
sp--;
}
return curval;
} | 1threat |
static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
int i, AVIOContext *pb)
{
AVStream *st = s->streams[i];
AVCodecContext *codec = st->codec;
ebml_master subinfo, track;
int native_id = 0;
int qt_id = 0;
int bit_depth = av_get_bits_per_sample(codec->codec_id);
int sample_rate = codec->sample_rate;
int output_sample_rate = 0;
int j, ret;
AVDictionaryEntry *tag;
avpriv_set_pts_info(st, 64, 1, 1000);
if (codec->codec_type == AVMEDIA_TYPE_ATTACHMENT) {
mkv->have_attachments = 1;
return 0;
}
if (!bit_depth)
bit_depth = av_get_bytes_per_sample(codec->sample_fmt) << 3;
if (codec->codec_id == AV_CODEC_ID_AAC)
get_aac_sample_rates(s, codec, &sample_rate, &output_sample_rate);
track = start_ebml_master(pb, MATROSKA_ID_TRACKENTRY, 0);
put_ebml_uint (pb, MATROSKA_ID_TRACKNUMBER , i + 1);
put_ebml_uint (pb, MATROSKA_ID_TRACKUID , i + 1);
put_ebml_uint (pb, MATROSKA_ID_TRACKFLAGLACING , 0);
if ((tag = av_dict_get(st->metadata, "title", NULL, 0)))
put_ebml_string(pb, MATROSKA_ID_TRACKNAME, tag->value);
tag = av_dict_get(st->metadata, "language", NULL, 0);
put_ebml_string(pb, MATROSKA_ID_TRACKLANGUAGE, tag ? tag->value:"und");
if (!(st->disposition & AV_DISPOSITION_DEFAULT))
put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGDEFAULT, !!(st->disposition & AV_DISPOSITION_DEFAULT));
if (codec->codec_type == AVMEDIA_TYPE_AUDIO && codec->initial_padding) {
mkv->tracks[i].ts_offset = av_rescale_q(codec->initial_padding,
(AVRational){ 1, codec->sample_rate },
st->time_base);
put_ebml_uint(pb, MATROSKA_ID_CODECDELAY,
av_rescale_q(codec->initial_padding,
(AVRational){ 1, codec->sample_rate },
(AVRational){ 1, 1000000000 }));
}
for (j = 0; ff_mkv_codec_tags[j].id != AV_CODEC_ID_NONE; j++) {
if (ff_mkv_codec_tags[j].id == codec->codec_id) {
put_ebml_string(pb, MATROSKA_ID_CODECID, ff_mkv_codec_tags[j].str);
native_id = 1;
break;
}
}
if (mkv->mode == MODE_WEBM && !(codec->codec_id == AV_CODEC_ID_VP8 ||
codec->codec_id == AV_CODEC_ID_VP9 ||
codec->codec_id == AV_CODEC_ID_OPUS ||
codec->codec_id == AV_CODEC_ID_VORBIS)) {
av_log(s, AV_LOG_ERROR,
"Only VP8 or VP9 video and Vorbis or Opus audio are supported for WebM.\n");
return AVERROR(EINVAL);
}
switch (codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_VIDEO);
if (st->avg_frame_rate.num > 0 && st->avg_frame_rate.den > 0)
put_ebml_uint(pb, MATROSKA_ID_TRACKDEFAULTDURATION, 1E9 / av_q2d(st->avg_frame_rate));
if (!native_id &&
ff_codec_get_tag(ff_codec_movvideo_tags, codec->codec_id) &&
(!ff_codec_get_tag(ff_codec_bmp_tags, codec->codec_id) ||
codec->codec_id == AV_CODEC_ID_SVQ1 ||
codec->codec_id == AV_CODEC_ID_SVQ3 ||
codec->codec_id == AV_CODEC_ID_CINEPAK))
qt_id = 1;
if (qt_id)
put_ebml_string(pb, MATROSKA_ID_CODECID, "V_QUICKTIME");
else if (!native_id) {
put_ebml_string(pb, MATROSKA_ID_CODECID, "V_MS/VFW/FOURCC");
mkv->tracks[i].write_dts = 1;
}
subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKVIDEO, 0);
put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELWIDTH , codec->width);
put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELHEIGHT, codec->height);
ret = mkv_write_stereo_mode(s, pb, st, mkv->mode);
if (ret < 0)
return ret;
end_ebml_master(pb, subinfo);
break;
case AVMEDIA_TYPE_AUDIO:
put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_AUDIO);
if (!native_id)
put_ebml_string(pb, MATROSKA_ID_CODECID, "A_MS/ACM");
subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKAUDIO, 0);
put_ebml_uint (pb, MATROSKA_ID_AUDIOCHANNELS , codec->channels);
put_ebml_float (pb, MATROSKA_ID_AUDIOSAMPLINGFREQ, sample_rate);
if (output_sample_rate)
put_ebml_float(pb, MATROSKA_ID_AUDIOOUTSAMPLINGFREQ, output_sample_rate);
if (bit_depth)
put_ebml_uint(pb, MATROSKA_ID_AUDIOBITDEPTH, bit_depth);
end_ebml_master(pb, subinfo);
break;
case AVMEDIA_TYPE_SUBTITLE:
put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_SUBTITLE);
if (!native_id) {
av_log(s, AV_LOG_ERROR, "Subtitle codec %d is not supported.\n", codec->codec_id);
return AVERROR(ENOSYS);
}
break;
default:
av_log(s, AV_LOG_ERROR, "Only audio, video, and subtitles are supported for Matroska.\n");
break;
}
ret = mkv_write_codecprivate(s, pb, codec, native_id, qt_id);
if (ret < 0)
return ret;
end_ebml_master(pb, track);
return 0;
}
| 1threat |
looping over AWK commands doesn't work : <p>I have a huge dictionary file that contains each word in each line, and would like to split the files by the first character of the words. </p>
<p>a.txt --> only contains the words that start with a</p>
<p>I used this awk commands to successfully extract words that start with b.</p>
<pre><code> awk 'tolower($0)~/^b/{print}' titles-sorted.txt > b.txt
</code></pre>
<p>Now I wanted to iterate this for all alphabets</p>
<pre><code> for alphabet in {a..z}
do
awk 'tolower($0)~/^alphabet/{print}' titles-sorted.txt > titles-links/^alphabet.txt
done
</code></pre>
<p>But the result files contain no contents. What did I do wrong? I don't even know how to debug this. Thanks! </p>
| 0debug |
I have two csv files having 3 columns i have to read this and compare this using hashmap() multiple hashmap) please help me with this code : I have two csv files having 3 columns i have to read this and compare this using hashmap() multiple hashmap) please help me with this code
Name,Value, Address
aaa,1,sdasdasd
bbb,2,sadasdasd
ccc,3,dsadasds | 0debug |
Azure DocumentDB Owner resource does not exist : <p>I having the same error icrosoft.Azure.Documents.DocumentClientException: Message: {"Errors":["Owner resource does not exist"]} , this is my scenario. When I deployed my webapp to Azure and try to get some document from docDb it throws this error. The docdb exists in azure and contains the document that i looking for.</p>
<p>The weird is that from my local machine(running from VS) this works fine. I'm using the same settings in Azure and local. Somebody have and idea about this.</p>
<p>Thanks</p>
| 0debug |
static void ioq_init(LaioQueue *io_q)
{
QSIMPLEQ_INIT(&io_q->pending);
io_q->plugged = 0;
io_q->n = 0;
io_q->blocked = false;
}
| 1threat |
understanding code in c++ : <p>This question arose while studying NS-3 codes. There is a for loop as below</p>
<pre><code>enter code here
for (NetDeviceContainer::Iterator i = periDevice.Begin ();
i != periDevice.End ();
i++)
{
(*i)->GetObject<BleNetDevice> ()->GetLinkLayer ()->SetAdvInterval (Time("1s"));
(*i)->GetObject<BleNetDevice> ()->GetLinkLayer ()->SetRole (BleLinkLayer::ADVERTISER);
(*i)->GetObject<BleNetDevice> ()->GetLinkLayer ()->SetAdvMode (BleLinkLayer::GENERAL_ADV);
}
</code></pre>
<p>What is the meaning of above code?<br>
What is Iterator ?
What is (*i)->xxx ? </p>
<p>Which c++ concept is used here.</p>
<p>Thank you in advance. </p>
| 0debug |
Type for parameter in TypeScript Arrow Function : <p>With </p>
<pre><code>"noImplicitAny": true
</code></pre>
<p>TypeScript will give the error:</p>
<p><em>Parameter 'x' implicitly has an 'any' type</em></p>
<p>for</p>
<pre><code>.do(x => console.log(x));
</code></pre>
<p>and error</p>
<p><em>',' expected</em></p>
<p>for:</p>
<pre><code>.do(x: any => console.log(x));
</code></pre>
| 0debug |
How to show Spinning Wheel or Busy Icon while waiting in Shiny : <p>Hey i've just started working with R and Shiny.
Trying to make a dashboard which displays different charts.
As there is a lot of data to process, the plots or charts take some time to display after the action button is clicked i.e. "launch Campaign'
Is there anyway i could show a spinning wheel or a loading icon in the white blank space, while this delay takes place? <a href="https://i.stack.imgur.com/TRPJ4.jpg" rel="noreferrer">Dashboard with blank space on the right</a> </p>
| 0debug |
Format Exception - input string was not in a correct format : <p>I found a problem - when I run this program, Visual Studio throws an exception - Format exception: Input string was not in a correct format. </p>
<pre><code> string name = Console.ReadLine();
int age = int.Parse(Console.ReadLine());
int id = int.Parse(Console.ReadLine());
double salary = double.Parse(Console.ReadLine());
Console.WriteLine($"Name: {name}");
Console.WriteLine($"Age: {age}");
Console.WriteLine($"Employee ID: {id:D8}");
Console.WriteLine($"Salary: {salary:F2}");
</code></pre>
<p>Unfortunately, I can't find a mistake here. Can you help me, please? Or this is a bug in Visual Studio?</p>
| 0debug |
Set value in dependency of Helm chart : <p>I want to use the <a href="https://github.com/helm/charts/tree/master/stable/postgresql" rel="noreferrer">postgresql chart</a> as a requirements for my Helm chart.</p>
<p>My <code>requirements.yaml</code> file hence looks like this:</p>
<pre><code>dependencies:
- name: "postgresql"
version: "3.10.0"
repository: "@stable"
</code></pre>
<p>In the postgreSQL Helm chart I now want to set the username with the property <code>postgresqlUsername</code> (see <a href="https://github.com/helm/charts/tree/master/stable/postgresql" rel="noreferrer">https://github.com/helm/charts/tree/master/stable/postgresql</a> for all properties).</p>
<p>Where do I have to specify this property in my project so that it gets propagated to the postgreSQL dependency?</p>
| 0debug |
static void posix_aio_read(void *opaque)
{
PosixAioState *s = opaque;
ssize_t len;
for (;;) {
char bytes[16];
len = read(s->rfd, bytes, sizeof(bytes));
if (len == -1 && errno == EINTR)
continue;
if (len == sizeof(bytes))
continue;
break;
}
posix_aio_process_queue(s);
}
| 1threat |
static target_ulong h_put_tce(PowerPCCPU *cpu, sPAPREnvironment *spapr,
target_ulong opcode, target_ulong *args)
{
target_ulong liobn = args[0];
target_ulong ioba = args[1];
target_ulong tce = args[2];
sPAPRTCETable *tcet = spapr_tce_find_by_liobn(liobn);
if (liobn & 0xFFFFFFFF00000000ULL) {
hcall_dprintf("spapr_vio_put_tce on out-of-boundsw LIOBN "
TARGET_FMT_lx "\n", liobn);
return H_PARAMETER;
}
ioba &= ~(SPAPR_TCE_PAGE_SIZE - 1);
if (tcet) {
return put_tce_emu(tcet, ioba, tce);
}
#ifdef DEBUG_TCE
fprintf(stderr, "%s on liobn=" TARGET_FMT_lx
" ioba 0x" TARGET_FMT_lx " TCE 0x" TARGET_FMT_lx "\n",
__func__, liobn, ioba, tce);
#endif
return H_PARAMETER;
}
| 1threat |
av_cold int ff_intrax8_common_init(IntraX8Context *w, IDCTDSPContext *idsp,
MpegEncContext *const s)
{
int ret = x8_vlc_init();
if (ret < 0)
return ret;
w->idsp = *idsp;
w->s = s;
w->prediction_table = av_mallocz(s->mb_width * 2 * 2);
if (!w->prediction_table)
return AVERROR(ENOMEM);
ff_init_scantable(w->idsp.idct_permutation, &w->scantable[0],
ff_wmv1_scantable[0]);
ff_init_scantable(w->idsp.idct_permutation, &w->scantable[1],
ff_wmv1_scantable[2]);
ff_init_scantable(w->idsp.idct_permutation, &w->scantable[2],
ff_wmv1_scantable[3]);
ff_intrax8dsp_init(&w->dsp);
return 0;
}
| 1threat |
How do you test the effects of dns-prefetch and preconnect : <p>I'm trying out the <code><link rel="dns-prefetch"></code> and <code><link rel="preconnect"></code> tags and I'm trying to see whether they help for my site. I can't find any online resources about how verify if these hints are working using browser dev tools, extensions, or other software. It seems like you just evaluate whether they may be useful to you based on some criteria and then drop them in and hope for the best.</p>
<p>In my case, I have a single page app that renders the entire contents of the <code><body></code> in the browser, so the browser can't really scan the initial HTML to lookahead for domains to resolve so it seemed like this might be useful for me.</p>
| 0debug |
How to merge/combine columns in pandas? : <p>I have a (example-) dataframe with 4 columns:</p>
<pre><code>data = {'A': ['a', 'b', 'c', 'd', 'e', 'f'],
'B': [42, 52, np.nan, np.nan, np.nan, np.nan],
'C': [np.nan, np.nan, 31, 2, np.nan, np.nan],
'D': [np.nan, np.nan, np.nan, np.nan, 62, 70]}
df = pd.DataFrame(data, columns = ['A', 'B', 'C', 'D'])
A B C D
0 a 42.0 NaN NaN
1 b 52.0 NaN NaN
2 c NaN 31.0 NaN
3 d NaN 2.0 NaN
4 e NaN NaN 62.0
5 f NaN NaN 70.0
</code></pre>
<p>I would now like to merge/combine columns B, C, and D to a new column E like in this example:</p>
<pre><code>data2 = {'A': ['a', 'b', 'c', 'd', 'e', 'f'],
'E': [42, 52, 31, 2, 62, 70]}
df2 = pd.DataFrame(data2, columns = ['A', 'E'])
A E
0 a 42
1 b 52
2 c 31
3 d 2
4 e 62
5 f 70
</code></pre>
<p>I found a quite similar question <a href="https://stackoverflow.com/questions/39276249/merge-two-dataframe-columns-into-1-in-pandas">here</a> but this adds the merged colums B, C, and D at the end of column A:</p>
<pre><code>0 a
1 b
2 c
3 d
4 e
5 f
6 42
7 52
8 31
9 2
10 62
11 70
dtype: object
</code></pre>
<p>Thanks for help.</p>
| 0debug |
Bootstrap button tooltip hide on click : <p>On my site I have some buttons. When a user clicks the button, a modal opens. When a user hovers the button, a tooltip is shown.</p>
<p>Is use this code:</p>
<pre><code><button type="button" rel="tooltip" title="Tooltip content" class="btn btn-sm btn-default" data-toggle="modal" data-target="#DeleteUserModal">
<span class="glyphicon glyphicon-remove"></span>
</button>
<div>modal</div>
<script>
$(document).ready(function(){
$('[rel="tooltip"]').tooltip();
});
</script>
</code></pre>
<p>This works, but the only problem is that the tooltip stays visible after the button is clicked, and the modal is shown. As soon as the modal is closed, the tooltip is hidden again.</p>
<p>How to prevent this? I only want the tooltip to be shown on hover, and not all the time when the related modal is visible.</p>
| 0debug |
static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb,
TranslationBlock **last_tb, int *tb_exit)
{
uintptr_t ret;
int32_t insns_left;
if (unlikely(atomic_read(&cpu->exit_request))) {
return;
}
trace_exec_tb(tb, tb->pc);
ret = cpu_tb_exec(cpu, tb);
tb = (TranslationBlock *)(ret & ~TB_EXIT_MASK);
*tb_exit = ret & TB_EXIT_MASK;
if (*tb_exit != TB_EXIT_REQUESTED) {
*last_tb = tb;
return;
}
*last_tb = NULL;
insns_left = atomic_read(&cpu->icount_decr.u32);
atomic_set(&cpu->icount_decr.u16.high, 0);
if (insns_left < 0) {
smp_mb();
return;
}
assert(use_icount);
#ifndef CONFIG_USER_ONLY
if (cpu->icount_extra) {
cpu->icount_extra += insns_left;
insns_left = MIN(0xffff, cpu->icount_extra);
cpu->icount_extra -= insns_left;
cpu->icount_decr.u16.low = insns_left;
} else {
if (insns_left > 0) {
cpu_exec_nocache(cpu, insns_left, tb, false);
}
}
#endif
}
| 1threat |
sofcantrcvmore(struct socket *so)
{
if ((so->so_state & SS_NOFDREF) == 0) {
shutdown(so->s,0);
if(global_writefds) {
FD_CLR(so->s,global_writefds);
}
}
so->so_state &= ~(SS_ISFCONNECTING);
if (so->so_state & SS_FCANTSENDMORE) {
so->so_state &= SS_PERSISTENT_MASK;
so->so_state |= SS_NOFDREF;
} else {
so->so_state |= SS_FCANTRCVMORE;
}
}
| 1threat |
The given artifact contains a string literal with a package reference 'android.support.v4.content' that cannot be safely rewritten. for androidx : <p>I upgraded my <code>android studio to 3.4 canary</code> and now I cannot successfully build anymore due to the following error: </p>
<pre><code>The given artifact contains a string literal with a package reference 'android.support.v4.content' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.
</code></pre>
<p>More details:</p>
<pre><code>Caused by: java.lang.RuntimeException: Failed to transform '.gradle/caches/modules-2/files-2.1/com.jakewharton/butterknife-compiler/9.0.0-SNAPSHOT/732f93940c74cf32a7c5ddcc5ef66e53be052352/butterknife-compiler-9.0.0-SNAPSHOT.jar' using Jetifier. Reason: The given artifact contains a string literal with a package reference 'android.support.v4.content' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.. (Run with --stacktrace for more details.)
</code></pre>
<p>Clearly, its something to do with <code>Butterknife, androidx and Jetifier</code></p>
<p>Do anybody know how to fix this?</p>
| 0debug |
infinite loop when dispatching in componentWillReceiveProps : <p>I have a Profile component that is loaded by react-router (path="profile/:username") and the component itself looks like this:</p>
<pre><code>...
import { fetchUser } from '../actions/user';
class Profile extends Component {
constructor(props) {
super(props);
}
componentDidMount() {
const { username } = this.props;
this.fetchUser(username);
}
componentWillReceiveProps(nextProps) {
const { username } = nextProps.params;
this.fetchUser(username);
}
fetchUser(username) {
const { dispatch } = this.props;
dispatch(fetchUser(username));
}
render() {...}
}
export default connect((state, ownProps) => {
return {
username: ownProps.params.username,
isAuthenticated: state.auth.isAuthenticated
};
})(Profile);
</code></pre>
<p>And the fetchUser action looks like this (redux-api-middleware):</p>
<pre><code>function fetchUser(id) {
let token = localStorage.getItem('jwt');
return {
[CALL_API]: {
endpoint: `http://localhost:3000/api/users/${id}`,
method: 'GET',
headers: { 'x-access-token': token },
types: [FETCH_USER_REQUEST, FETCH_USER_SUCCESS, FETCH_USER_FAILURE]
}
}
}
</code></pre>
<p>The reason I added componentWillReceiveProps function is to react when the URL changes to another :username and to load that users profile info. At a first glance everything seems to work but then I noticed while debugging that componentWillReceiveProps function is called in a infinite loop and I don't know why. If I remove componentWillReceiveProps then the profile doesn't get updated with the new username but then I have no loops problem. Any ideas?</p>
| 0debug |
Can't figure out how to Add some CRUD to my app : Im a begginer I would like to add (some CRUD fucntionality to my Console app) Im struggling right now since I want to add, remove and display then a Object of type fish and an Object of type Reptile to an array and then print them and I want to make it possible by using a Menu wich I've created but I can't figure out how to do that and the basic tests that I do to add objects from code throws me the error that it's out of bounds, Im kinda very confused right now and Im preety sure my question is being poorly exaplained but I hope someone understood what I need help with here are my classes
**Here is the class that has the functions to Add An animal, or to Remove and to Display, this one include also the menu**
public class ZooManagement
{
public Animal[] AnimalsList;
public int length = 0;
public int max_size;
public void DisplayMenu() {
int choice;
try
{
do
{
Console.Write("Welcome to our zoo menu\n\n");
Console.Write("1. To add Animal\t");
Console.Write("2. To remove Animal\t");
Console.Write("3. To Display Animals ");
choice = int.Parse(Console.ReadLine());
switch (choice)
{
case 1:
x.Add();
break;
case 2:
x.Remove();
break;
case 3:
x.Display();
break;
default:
Console.WriteLine("You've pressed something elss");
break;
}
Console.Write("\n\n\t\t\tNow press any button");
Console.ReadLine();
Console.Clear();
}
while (choice != 3);
}
catch (Exception ex)
{
Console.WriteLine("Dont't be like that");
}
}
public ZooManagement(int x)
{
this.AnimalsList = new Animal[x];
max_size = x;
}
//public void Array(int x)
//{
// this.AnimalsList = new Animal[x];
// max_size = x;
//}
public void Add(Animal x)
{
if (this.length > this.max_size)
{
Console.WriteLine("Out of bound Exception, Array full");
}
else
{
this.AnimalsList[this.length] = x;
this.length++;
}
}
public void Add(int h, Animal x)
{
if (h > this.length || h < 0)
{
Console.WriteLine("Out of bound Exception");
}
else
{
for (int i = (this.length); i >= h; i--) {
this.AnimalsList[i + 1] = this.AnimalsList[i];
}
this.AnimalsList[h] = x;
this.length++;
}
}
public void Remove(Animal x)
{
int FoundAt = -1;
for (int i = 0; i < this.length; i++)
{
if (this.AnimalsList[i] == x)
{
FoundAt = i;
break;
}
}
if (FoundAt != -1)
{
for (int i = FoundAt; i < this.length; i++)
{
this.AnimalsList[i] = this.AnimalsList[i + 1];
}
this.length--;
}
}
public void Remove(int x)
{
if (x > this.length || x < 0)
{
Console.WriteLine("Out of bounds exception");
}
else
{
this.AnimalsList[x] = null;
for (int i = x; i < this.length; i++)
{
this.AnimalsList[i] = this.AnimalsList[i + 1];
}
this.length--;
}
}
public Animal GetAnimal(string reign)
{
if ("fish".Equals(reign))
{
return new Fish("", 0, 0, "", "");
}
else if ("reptile".Equals(reign))
{
return new Reptile("", 0, 0, "", "");
}
return null;
}
public Animal Get(int x)
{
if (x > this.length || x < 0)
{
Console.WriteLine("Out of bounds Exeption");
return null;
}
else
{
return this.AnimalsList[x];
}
}
public void Set(int h, Animal x)
{
if (h > this.length || h < 0)
{
Console.WriteLine("Out of bounds Exeption");
}
else
{
this.AnimalsList[h] = x;
}
}
public void Swap(int x, int y)
{
if (x >= 0 && x < length && y >= 0 && y < length)
{
Animal temp = AnimalsList[x];
AnimalsList[x] = AnimalsList[y];
AnimalsList[y] = temp;
}
else
{
Console.WriteLine("Out of bounds exception");
}
}
public void Swap(Animal x, Animal y)
{
int FoundAtA = -1;
int FoundAtB = -1;
for(int i = 0; i <this.length; i++)
{
if(this.AnimalsList[i] == x)
{
FoundAtA = i;
if(FoundAtA != -1 && FoundAtB != -1)
{
break;
}
}
else if(this.AnimalsList[i] == y)
{
FoundAtB = i;
if(FoundAtA != -1 && FoundAtB != -1)
{
break;
}
}
}
if (FoundAtA != -1 && FoundAtB != -1)
{
this.Swap(FoundAtA, FoundAtB);
}
else
{
Console.WriteLine("Out of bounds Exeption");
}
}
public void Display()
{
for (int i = 0; i < this.length; i++)
{
Console.WriteLine(this.AnimalsList[i]);
}
}
}
//public static double AnimalWeight(int weight, int size)
//{
// return (weight * 703) / (size * size);
//}
}
*** Here is the main***
public class Program
{
static void Main(string[] args)
{
ZooManagement x = new ZooManagement(10);
Console.WriteLine("\n");
Animal petru = new Fish("Piranha", 22, 33, "M", "round");
Animal petra = new Reptile("Snake", 33, 44, "F", "long");
x.Add(4, petru);
x.Add(5, petra);
x.Display();
x.Swap(petru, petra);
x.Display();
Console.ReadKey();
x.DisplayMenu();
}
}
**And here is the fish class that has some stats and behaviours from abstract Animl class**
class Fish : Animal, IFood ,ILimbless
{
public string shape;
private string v;
public string Shape { get; set; }
private string GetFishShape(string shape)
{
return shape;
}
public override string Behavior()
{
return "Passive";
}
public void Eats()
{
Console.WriteLine( "Eats alges and fish");
}
public override string MakeNoise()
{
return "Doesnt make noises LOL";
}
public void Slither(string w)
{
Console.WriteLine("It is limbless that's why it slithers");
}
public Fish(string raceInfo, int weight, double size, string sex, string shape) : base(raceInfo, weight, size, sex)
{
this.raceInfo = raceInfo;
this.weight = weight;
this.size = size;
this.sex = sex;
this.shape = shape;
}
}
}
| 0debug |
Returning a 1 or 0 for checkbox , wheter checked or unchecked in HTML5 : I declared a var and want to pass the status of the checkbox to the dhcp_addr variable and set it to 1 when the checkbox is checked and 0 when its unchecked. Need some help in returning a value to the variable.
var dhcp_addr = $('#dhcp').change(function(){
if(dhcp.checked){
console.log("checked");
}
else{
console.log("unchecked");
}
});
| 0debug |
static void cpu_x86_fill_host(x86_def_t *x86_cpu_def)
{
uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
x86_cpu_def->name = "host";
host_cpuid(0x0, 0, &eax, &ebx, &ecx, &edx);
x86_cpu_def->level = eax;
x86_cpu_def->vendor1 = ebx;
x86_cpu_def->vendor2 = edx;
x86_cpu_def->vendor3 = ecx;
host_cpuid(0x1, 0, &eax, &ebx, &ecx, &edx);
x86_cpu_def->family = ((eax >> 8) & 0x0F) + ((eax >> 20) & 0xFF);
x86_cpu_def->model = ((eax >> 4) & 0x0F) | ((eax & 0xF0000) >> 12);
x86_cpu_def->stepping = eax & 0x0F;
x86_cpu_def->ext_features = ecx;
x86_cpu_def->features = edx;
if (kvm_enabled() && x86_cpu_def->level >= 7) {
x86_cpu_def->cpuid_7_0_ebx_features = kvm_arch_get_supported_cpuid(kvm_state, 0x7, 0, R_EBX);
} else {
x86_cpu_def->cpuid_7_0_ebx_features = 0;
}
host_cpuid(0x80000000, 0, &eax, &ebx, &ecx, &edx);
x86_cpu_def->xlevel = eax;
host_cpuid(0x80000001, 0, &eax, &ebx, &ecx, &edx);
x86_cpu_def->ext2_features = edx;
x86_cpu_def->ext3_features = ecx;
cpu_x86_fill_model_id(x86_cpu_def->model_id);
x86_cpu_def->vendor_override = 0;
if (x86_cpu_def->vendor1 == CPUID_VENDOR_VIA_1 &&
x86_cpu_def->vendor2 == CPUID_VENDOR_VIA_2 &&
x86_cpu_def->vendor3 == CPUID_VENDOR_VIA_3) {
host_cpuid(0xC0000000, 0, &eax, &ebx, &ecx, &edx);
if (eax >= 0xC0000001) {
x86_cpu_def->xlevel2 = eax;
host_cpuid(0xC0000001, 0, &eax, &ebx, &ecx, &edx);
x86_cpu_def->ext4_features = edx;
}
}
x86_cpu_def->svm_features = -1;
}
| 1threat |
ssize_t nbd_send_request(QIOChannel *ioc, struct nbd_request *request)
{
uint8_t buf[NBD_REQUEST_SIZE];
ssize_t ret;
TRACE("Sending request to server: "
"{ .from = %" PRIu64", .len = %" PRIu32 ", .handle = %" PRIu64
", .type=%" PRIu32 " }",
request->from, request->len, request->handle, request->type);
stl_be_p(buf, NBD_REQUEST_MAGIC);
stl_be_p(buf + 4, request->type);
stq_be_p(buf + 8, request->handle);
stq_be_p(buf + 16, request->from);
stl_be_p(buf + 24, request->len);
ret = write_sync(ioc, buf, sizeof(buf));
if (ret < 0) {
return ret;
}
if (ret != sizeof(buf)) {
LOG("writing to socket failed");
return -EINVAL;
}
return 0;
}
| 1threat |
Hashicorp Vault cli return 403 when trying to use kv : <p>I set up vault backed by a consul cluster. I secured it with https and am trying to use the cli on a separate machine to get and set secrets in the kv engine. I am using version 1.0.2 of both the CLI and Vault server.</p>
<p>I have logged in with the root token so I should have access to everything. I have also set my VAULT_ADDR appropriately.</p>
<p>Here is my request:</p>
<p><code>vault kv put secret/my-secret my-value=yea</code></p>
<p>Here is the response:</p>
<pre><code>Error making API request.
URL: GET https://{my-vault-address}/v1/sys/internal/ui/mounts/secret/my-secret
Code: 403. Errors:
* preflight capability check returned 403, please ensure client's policies grant access to path "secret/my-secret/"
</code></pre>
<p>I don't understand what is happening here. I am able to set and read secrets in the kv engine no problem from the vault ui. What am I missing?</p>
| 0debug |
Check if randomly generated value already exists in hash : <p>If I have a Perl hash, and I randomly generated a numeric value, how can I get my code to check if the randomly generated value already exists in the hash?</p>
| 0debug |
void av_thread_message_queue_free(AVThreadMessageQueue **mq)
{
#if HAVE_THREADS
if (*mq) {
av_thread_message_flush(*mq);
av_fifo_freep(&(*mq)->fifo);
pthread_cond_destroy(&(*mq)->cond);
pthread_mutex_destroy(&(*mq)->lock);
av_freep(mq);
}
#endif
}
| 1threat |
QEMUTimerList *timerlist_new(QEMUClockType type,
QEMUTimerListNotifyCB *cb,
void *opaque)
{
QEMUTimerList *timer_list;
QEMUClock *clock = qemu_clock_ptr(type);
timer_list = g_malloc0(sizeof(QEMUTimerList));
qemu_event_init(&timer_list->timers_done_ev, true);
timer_list->clock = clock;
timer_list->notify_cb = cb;
timer_list->notify_opaque = opaque;
qemu_mutex_init(&timer_list->active_timers_lock);
QLIST_INSERT_HEAD(&clock->timerlists, timer_list, list);
return timer_list;
}
| 1threat |
static int encode_hq_slice(AVCodecContext *avctx, void *arg)
{
SliceArgs *slice_dat = arg;
VC2EncContext *s = slice_dat->ctx;
PutBitContext *pb = &slice_dat->pb;
const int slice_x = slice_dat->x;
const int slice_y = slice_dat->y;
const int quant_idx = slice_dat->quant_idx;
const int slice_bytes_max = slice_dat->bytes;
uint8_t quants[MAX_DWT_LEVELS][4];
int p, level, orientation;
memset(put_bits_ptr(pb), 0, s->prefix_bytes);
skip_put_bytes(pb, s->prefix_bytes);
put_bits(pb, 8, quant_idx);
for (level = 0; level < s->wavelet_depth; level++)
for (orientation = !!level; orientation < 4; orientation++)
quants[level][orientation] = FFMAX(quant_idx - s->quant[level][orientation], 0);
for (p = 0; p < 3; p++) {
int bytes_start, bytes_len, pad_s, pad_c;
bytes_start = put_bits_count(pb) >> 3;
put_bits(pb, 8, 0);
for (level = 0; level < s->wavelet_depth; level++) {
for (orientation = !!level; orientation < 4; orientation++) {
encode_subband(s, pb, slice_x, slice_y,
&s->plane[p].band[level][orientation],
quants[level][orientation]);
}
}
avpriv_align_put_bits(pb);
bytes_len = (put_bits_count(pb) >> 3) - bytes_start - 1;
if (p == 2) {
int len_diff = slice_bytes_max - (put_bits_count(pb) >> 3);
pad_s = FFALIGN((bytes_len + len_diff), s->size_scaler)/s->size_scaler;
pad_c = (pad_s*s->size_scaler) - bytes_len;
} else {
pad_s = FFALIGN(bytes_len, s->size_scaler)/s->size_scaler;
pad_c = (pad_s*s->size_scaler) - bytes_len;
}
pb->buf[bytes_start] = pad_s;
flush_put_bits(pb);
skip_put_bytes(pb, pad_c);
}
return 0;
} | 1threat |
Beginning C and I have a bug that is killing me : <p>I am writing some code and I have a prompt in the program driven by a while loop where you make a choice. However, it prints the prompt twice every time it goes through the loop and I just can't figure it out.</p>
<pre><code> while (choice != 'x');
{
printf("\nChoice (a)dd (v)iew e(X)it [ ]\b\b");
scanf("%c",&choice);
if (choice == 'a') add_record();
if (choice == 'v') view_record();
}
</code></pre>
<p>The printf line is the one that prints twice. Thanks in advance for any help.</p>
| 0debug |
access MONGODB on remote server : <p>i am a newbie.. i know coding language such as python and mongodb(pymongo)..
Now i want to make a web based ui to get and display records on the client pc.. there maybe some queries the client enters to get desired records...
the mongodb is on a server... I need to know what tools are there that i will require to send the queries and also to query the db on the server..
I ggoled and found node.js ,rest etc.. but couldn't understand exactly... pls help me to understand exactly what things i will need to see to help me build it...</p>
| 0debug |
Reading matrices of unkown dimension : <p>I'm trying to read a matrix from a file formatted in this way</p>
<pre>
1 2 3 4
4 5 6 7
8 9 10 11
*
1 0 1
0 1 1
1 1 1]
</pre>
<p>but I don't know how to pass the multidimensional array with its dimension given by rows[] and cols[] arrays to the function read_matrix().</p>
<p>I am able to get the correct dimension of the two matrices</p>
<pre><code>#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
int get_dim(char *file, int *r, int *col);
/*gets the dimension and type of operation*/
void read_matrix(char *file, int (*matA)[], int(*matB)[], int *m, int *n);
int main (int argc, char *argv[]){
int i,j;
int rows[2]= {0,1}; /* The last line of the file does not contain '\n' */
int cols[2]= {0,0};
int operation; /*type of operation 1 for * and 2 for + */
operation = get_dim(argv[1], rows, cols);
int A[rows[0]][cols[0]];
int B[rows[1]][cols[1]];
printf("A is a matrix %d x %d\n",rows[0], cols[0]);
if(operation != 0)
printf("B is a matrix %d x %d\n", rows[1], cols[1]);
read_matrix(argv[1], A, B, rows, cols);
/*printing the matrices */
for(i = 0; i < rows[0]; i++){
for(j=0; j < cols[0]; j++){
printf("%d ", A[i][j]);
}
printf("\n");
}
printf("*\n");
for(i = 0; i < rows[1]; i++){
for(j=0; j< cols[1]; j++){
printf("%2d ", B[i][j]);
}
printf("\n");
}
return 0;
}
int get_dim(char *file, int *r, int *col){
FILE *fp;
int c;
int op=0;
int n =0; /*to check all coefficients in a row */
/* opening file for reading */
fp = fopen(file, "r");
if(fp == NULL) {
perror("Error opening file");
}
while ( (c = getc(fp)) != ']')
{
if(isdigit(c) && n==0){
if(op == 0)
col[0]++;
else
col[1]++;
}
//Count whenever new line is encountered
if (c == '\n'){
n=1;
if(op == 0)
r[0]++;
else
r[1]++;
}
if(c == '*'){
op=1;
n =0;
c = getc(fp);
}
else if(c == '+'){
op=2;
c = getc(fp);
}
//take next character from file.
}
fclose(fp);
return op;
}
void read_matrix(char *file, int (*matA)[], int(*matB)[], int *m, int *n){
int i,j;
FILE *fp;
if( (fp = fopen(file, "r")) != NULL ){
for(i=0; i < m[0]; i++)
for(j=0; j < n[0]; j++)
fscanf(fp, "%d", &matA[i][j]);
/*skip the line containing the character operator */
while ( fgetc(fp) != '\n')
fgetc(fp);
for(i=0; i < m[1]; i++)
for(j=0; j < n[1]; j++)
fscanf(fp, "%d", &matB[i][j]);
}
fclose(fp);
}
</code></pre>
<p>I should define the pointers this way: int(*matA)[cols[0]] and int(*matB)[cols[1]].
In read_matrix() by declaring this pointer: int(*matB)[] I get the error : invalid use of array with unspecified bounds, that I understand. But the bound is determined by the get_dim() function.</p>
| 0debug |
framework not found GoogleMapsCore Error : <p>I'm using cocoapods in my project and I have googlemaps(2.5.0) and googleplaces(2.5.0) in my podfile(which I've installed with 'pod install'). </p>
<p>However, I'm getting this error when I try to build:</p>
<pre><code>ld: framework not found GoogleMapsCore
clang: error: linker command failed with exit code 1 (use -v to see invocation)
</code></pre>
<p>I've changed 'Build Active Architecture Only' to NO in my Build Settings. I'm also in my project.xcworkspace NOT my project.xcodeproj file. I've even tried changing my valid architectures but none of this is working.</p>
<p>It might be helpful to note that, inside my workspace Project Navigator, for some reason I have my project.xcodeproj file in red. project.xcodeproj is usually never there let alone red.</p>
| 0debug |
static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
int ret, entries;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams - 1];
sc = st->priv_data;
avio_r8(pb);
avio_rb24(pb);
entries = avio_rb32(pb);
if (entries <= 0) {
av_log(c->fc, AV_LOG_ERROR, "invalid STSD entries %d\n", entries);
return AVERROR_INVALIDDATA;
}
if (sc->extradata) {
av_log(c->fc, AV_LOG_ERROR,
"Duplicate stsd found in this track.\n");
return AVERROR_INVALIDDATA;
}
sc->extradata = av_mallocz_array(entries, sizeof(*sc->extradata));
if (!sc->extradata)
return AVERROR(ENOMEM);
sc->extradata_size = av_mallocz_array(entries, sizeof(*sc->extradata_size));
if (!sc->extradata_size) {
ret = AVERROR(ENOMEM);
goto fail;
}
ret = ff_mov_read_stsd_entries(c, pb, entries);
if (ret < 0)
goto fail;
sc->stsd_count = entries;
av_freep(&st->codecpar->extradata);
st->codecpar->extradata_size = sc->extradata_size[0];
if (sc->extradata_size[0]) {
st->codecpar->extradata = av_mallocz(sc->extradata_size[0] + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
memcpy(st->codecpar->extradata, sc->extradata[0], sc->extradata_size[0]);
}
return mov_finalize_stsd_codec(c, pb, st, sc);
fail:
av_freep(&sc->extradata);
av_freep(&sc->extradata_size);
return ret;
}
| 1threat |
Instant Run missing in Android Studio 3.3 : <p>Currently, in the Android Studio version 3.3, the shortcut for "Apply Changes" option is missing which allows Instant Run. There is another option called "Update Running Application" which does not provide the same functionality.</p>
<p>This option was available in older versions like 3.1 as seen in the screenshot</p>
<p><a href="https://i.stack.imgur.com/IgiBe.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IgiBe.png" alt="comparision"></a></p>
<p>I am unable to use Instant Run feature in version 3.3.</p>
<p>Is there a workaround for this?</p>
| 0debug |
static void colo_old_packet_check(void *opaque)
{
CompareState *s = opaque;
g_queue_foreach(&s->conn_list, colo_old_packet_check_one_conn, NULL);
}
| 1threat |
Is there any way to select some rows in data set whose for some columns they reapet more than once? : <p>I have a data set with 10000 rows and 32 columns. I am wondering is it possible we choose some rows whose have the same value for some features? </p>
<p>Here is an example which make my question more clear. </p>
<pre><code>col1 col2 col3 col4 col5
1 2 3 4 5
3 4 3 6 8
2 2 5 4 5
4 2 7 4 5
5 4 `8 6 8`
2 3 1 0 9
3 4 1 5 2
</code></pre>
<p>In this data set there are 5 columns. Suppose I want to select some rows whose have same value in column 2,4 and 5. </p>
<p>As it can be seen, the first, third and forth row have same value in col2 , col4 and col5 also second and 5-th rows have same value in those columns. So I will pick these rows and new data set will be</p>
<pre><code> col1 col2 col3 col4 col5
1 2 3 4 5
3 4 3 6 8
2 2 5 4 5
4 2 7 4 5
5 4 `8 6 8`
</code></pre>
| 0debug |
static void show_packets(AVFormatContext *fmt_ctx)
{
AVPacket pkt;
av_init_packet(&pkt);
while (!av_read_frame(fmt_ctx, &pkt))
show_packet(fmt_ctx, &pkt);
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.