problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
sorting an array List : <p>i am trying to sort an list array that has Strings that contain Integers and letters but when i do it the regular way i get some wierd output:
relevant code:</p>
<pre><code>List<String> words = new ArrayList<>();
words.add("9 hello");
words.add("98 food");
words.add("105 cat");
words.add("2514 human");
words.add("3 pencil");
words.sort(Comparator.reverseOrder());
</code></pre>
<p>i am expecting :</p>
<pre><code>"2514 human"
"105 cat"
"98 food"
"9 hello"
"3 pencil"
</code></pre>
<p>but i am getting something like this:</p>
<pre><code>"98 food"
"9 hello"
"3 pencil"
"2514 human"
"105 cat"
</code></pre>
<p>any suggestions?</p>
| 0debug |
Angular 1 ng-repeat filter with comma saprater string within json array : I used the ng-repeat to append the json array value ,the problem is pictureURLS object is having the string value of images what i am looking separate the pictureURLS string value' and display the images
javascript
var results= [
{
"title": Album1,
"pictureURLS": "pirul.jpg,picurl2.jpg,picurl3.jpg",
"ApprovalStatus": "2",
},
{
"title": Album2,
"pictureURLS": "pirul.jpg,picurl2.jpg,picurl3.jpg",
"ApprovalStatus": "2",
},
{
"title": Album3,
"AlbumPictureURLS": null,
]
HTML
<div ng-repeat="photo in results">
<h4>{{photo.title}}</h4>
<img src="{{photo.pictureURLS}}" />
</div> | 0debug |
Can i use this fitness function? : i am working on a project using a genetic algorithm, and i try now to formulate a fitness function, my questions are :
what is the effect of fitness formula choice on a GA ?
it is possible to make the fitness function equals directly the number of violation (in case of minimisation) ?
thanks you in advance .. | 0debug |
Espresso --> Java.lang.SecurityException: test fails due to Package does not belong to <process> : <p>I have an Android Espresso code that attempts to click a button and it fails with a security error.</p>
<p>This is the Espresso command:</p>
<pre><code>Espresso.onData(Matchers.allOf(Matchers.is(Matchers.instanceOf(Preference.class)), withKey(PreferenceKey.pref_custom_server_base_url.toString()), withSummaryText(Configurations.DEFAULT_SERVER_URL))).check(matches(isCompletelyDisplayed()));
</code></pre>
<p>This is the error I am receiving:</p>
<pre><code>java.lang.SecurityException: Package xxx.xxx.test does not belong to 10095
at android.os.Parcel.readException(Parcel.java:2004)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
at android.content.ContentProviderProxy.call(ContentProviderNative.java:651)
at android.provider.Settings$NameValueCache.getStringForUser(Settings.java:1924)
at android.provider.Settings$Global.getStringForUser(Settings.java:10362)
at android.provider.Settings$Global.getString(Settings.java:10351)
at android.provider.Settings$Global.getFloat(Settings.java:10695)
at android.support.test.espresso.base.DefaultFailureHandler.getGlobalSetting(DefaultFailureHandler.java:178)
at android.support.test.espresso.base.DefaultFailureHandler.getSetting(DefaultFailureHandler.java:154)
at android.support.test.espresso.base.DefaultFailureHandler.getTransitionAnimationScale(DefaultFailureHandler.java:124)
at android.support.test.espresso.base.DefaultFailureHandler.isAnimationAndTransitionDisabled(DefaultFailureHandler.java:112)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:69)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:52)
at xxx.xxx.test.instruments.failure.ScreenshotFailureHandler.handle(ScreenshotFailureHandler.java:36)
at android.support.test.espresso.ViewInteraction.waitForAndHandleInteractionResults(ViewInteraction.java:312)
at android.support.test.espresso.ViewInteraction.desugaredPerform(ViewInteraction.java:167)
at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:110)
at android.support.test.espresso.DataInteraction$DisplayDataMatcher$1.apply(DataInteraction.java:206)
at android.support.test.espresso.DataInteraction$DisplayDataMatcher$1.apply(DataInteraction.java:203)
at android.support.test.espresso.DataInteraction$DisplayDataMatcher.<init>(DataInteraction.java:223)
at android.support.test.espresso.DataInteraction$DisplayDataMatcher.<init>(DataInteraction.java:198)
at android.support.test.espresso.DataInteraction$DisplayDataMatcher.displayDataMatcher(DataInteraction.java:241)
at android.support.test.espresso.DataInteraction.makeTargetMatcher(DataInteraction.java:143)
at android.support.test.espresso.DataInteraction.check(DataInteraction.java:137)
at xxx.xxx.test.steps.ChangeServerUrlSteps.checkSettingsSaved(ChangeServerUrlSteps.java:112)
at xxx.xxx.test.steps.Prerequisites.serverConfigPrerequisites(Prerequisites.java:38)
at ✽.Given I am connected (features/001_login.feature:8)
</code></pre>
<p>Any idea why this may happen?
Thanks!
The code runs on Emulators and Cloud devices with the same error.</p>
| 0debug |
static int xv_write_header(AVFormatContext *s)
{
XVContext *xv = s->priv_data;
unsigned int num_adaptors;
XvAdaptorInfo *ai;
XvImageFormatValues *fv;
int num_formats = 0, j;
AVCodecContext *encctx = s->streams[0]->codec;
if ( s->nb_streams > 1
|| encctx->codec_type != AVMEDIA_TYPE_VIDEO
|| encctx->codec_id != AV_CODEC_ID_RAWVIDEO) {
av_log(s, AV_LOG_ERROR, "Only supports one rawvideo stream\n");
return AVERROR(EINVAL);
}
xv->display = XOpenDisplay(xv->display_name);
if (!xv->display) {
av_log(s, AV_LOG_ERROR, "Could not open the X11 display '%s'\n", xv->display_name);
return AVERROR(EINVAL);
}
xv->image_width = encctx->width;
xv->image_height = encctx->height;
if (!xv->window_width && !xv->window_height) {
xv->window_width = encctx->width;
xv->window_height = encctx->height;
}
xv->window = XCreateSimpleWindow(xv->display, DefaultRootWindow(xv->display),
xv->window_x, xv->window_y,
xv->window_width, xv->window_height,
0, 0, 0);
if (!xv->window_title) {
if (!(xv->window_title = av_strdup(s->filename)))
return AVERROR(ENOMEM);
}
XStoreName(xv->display, xv->window, xv->window_title);
XMapWindow(xv->display, xv->window);
if (XvQueryAdaptors(xv->display, DefaultRootWindow(xv->display), &num_adaptors, &ai) != Success)
return AVERROR_EXTERNAL;
xv->xv_port = ai[0].base_id;
if (encctx->pix_fmt != AV_PIX_FMT_YUV420P) {
av_log(s, AV_LOG_ERROR,
"Unsupported pixel format '%s', only yuv420p is currently supported\n",
av_get_pix_fmt_name(encctx->pix_fmt));
return AVERROR_PATCHWELCOME;
}
fv = XvListImageFormats(xv->display, xv->xv_port, &num_formats);
if (!fv)
return AVERROR_EXTERNAL;
for (j = 0; j < num_formats; j++) {
if (fv[j].id == MKTAG('I','4','2','0')) {
break;
}
}
XFree(fv);
if (j >= num_formats) {
av_log(s, AV_LOG_ERROR,
"Device does not support pixel format yuv420p, aborting\n");
return AVERROR(EINVAL);
}
xv->gc = XCreateGC(xv->display, xv->window, 0, 0);
xv->image_width = encctx->width;
xv->image_height = encctx->height;
xv->yuv_image = XvShmCreateImage(xv->display, xv->xv_port,
MKTAG('I','4','2','0'), 0,
xv->image_width, xv->image_height, &xv->yuv_shminfo);
xv->yuv_shminfo.shmid = shmget(IPC_PRIVATE, xv->yuv_image->data_size,
IPC_CREAT | 0777);
xv->yuv_shminfo.shmaddr = (char *)shmat(xv->yuv_shminfo.shmid, 0, 0);
xv->yuv_image->data = xv->yuv_shminfo.shmaddr;
xv->yuv_shminfo.readOnly = False;
XShmAttach(xv->display, &xv->yuv_shminfo);
XSync(xv->display, False);
shmctl(xv->yuv_shminfo.shmid, IPC_RMID, 0);
return 0;
} | 1threat |
Include local web app into react native webview : <p>Within my react-native app I want to show a webview, that loads a local html5 web application (single page app, SPA).</p>
<p>I am able to load an html file, that is located within the relative folder <code>webapp</code> using</p>
<pre><code>var webapp = require('./webapp/index.html');
</code></pre>
<p>and</p>
<pre><code><WebView source={webapp}></WebView>
</code></pre>
<p>as I have stated in this thread: <a href="https://stackoverflow.com/questions/33506908/react-native-webview-load-from-device-local-file-system">react native webview load from device local file system</a></p>
<p>Unfortunately, the assets of this local webapp like the .js and .css files, aren't loaded by the webapp.</p>
<p>During development of the react-native app, these files are available via the development server. Though, when the app is packed and run on an iOS device, the assets aren't available (I get a 404 error in Safari developer tools).</p>
<p>How can I make sure, that all of the assets (JS, CSS, etc.) within the <code>webapp</code> folder are available in the packaged app local.</p>
| 0debug |
Android PagedList updates : <p>My question is how to update item in PagedList?</p>
<p>In my case, there are ListActivity and DetailsActivity.
List activity is using Paging component to get posts from network(only) and shows it in recycler view using paged adapter.
When user is pressing on some post, I need to get post details and show it at the DetailsActivity. I am making another request to the server and it returns me post details. After that call, server increases viewsCount value of that post and when user returns to the posts list, I need to update that counter at the list item. </p>
<p>The question is, how to update single item (post), in that PagedList, cause I don't need to reload all list from the beginning just to update one single item.</p>
| 0debug |
Jenkins pipeline template : <p>We have several Java projects. Each project has its own delivery pipeline.</p>
<p>All pipelines have the following steps in common (simplified):</p>
<ul>
<li>Build project</li>
<li>Release project</li>
<li>Deploy to test environment</li>
<li>Deploy to production environment</li>
</ul>
<p>The project pipelines only differ in project specific properties such as service names or the IP addresses of test and production environment.</p>
<p>The questions are: How could we avoid the boilerplate that all projects have in common? Does Jenkins "Pipeline as code" provide something like pipeline templates?</p>
<p>I could imagine that a template would save a lot of redundant code/steps in our project pipelines. Therefore it would be much easier to setup a new project, maintain the pipeline, keep the pipeline in sync...</p>
| 0debug |
How to force Pods/Deployments to Master nodes? : <p>I've setup a Kubernetes 1.5 cluster with the three master nodes tainted <em>dedicated=master:NoSchedule</em>. Now I want to deploy the Nginx Ingress Controller on the Master nodes only so I've added tolerations:</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-ingress-controller
namespace: kube-system
labels:
kubernetes.io/cluster-service: "true"
spec:
replicas: 3
template:
metadata:
labels:
k8s-app: nginx-ingress-lb
name: nginx-ingress-lb
annotations:
scheduler.alpha.kubernetes.io/tolerations: |
[
{
"key": "dedicated",
"operator": "Equal",
"value": "master",
"effect": "NoSchedule"
}
]
spec:
[…]
</code></pre>
<p>Unfortunately this does not have the desired effect: Kubernetes schedules all Pods on the workers. When scaling the number of replicas to a larger number the Pods are deployed on the workers, too. </p>
<p>How can I achieve scheduling to the Master nodes only?</p>
<p>Thanks for your help.</p>
| 0debug |
Factorial (JAVA) : in my code below it will show the following output:
for example number = 5:
5! = 120
but how to do it if I want this output . .
5! = 5*4*3*2*1 = 120
WITHOUT USING LOOP
Thank you!
public class FF{
public FF()
{
DataInputStream T=new DataInputStream(System.in);
int fact=1;
try{
System.out.print("Enter a number: ");
int number=Integer.parseInt(T.readLine());
fact = factorial(number);
System.out.println(number + "! = " + fact);
}
catch (Exception e)
{
System.out.println("Invalid Input");
}
}
public static int factorial(int n)
{
if ((n == 1) || (n == 0))
return 1;
else
return(n * factorial(n-1));
}
public static void main(String args[]){
FF n=new FF();
}
}
| 0debug |
Grouping tests in pytest: Classes vs plain functions : <p>I'm using pytest to test my app.
pytest supports 2 approaches (that I'm aware of) of how to write tests:</p>
<ol>
<li>In classes:</li>
</ol>
<blockquote>
<p>test_feature.py -> class TestFeature -> def test_feature_sanity</p>
</blockquote>
<ol start="2">
<li>In functions:
<blockquote>
<p>test_feature.py -> def test_feature_sanity</p>
</blockquote></li>
</ol>
<p>Is the approach of grouping tests in class are needed? Is it allowed to backport unittest builtin module?
Which approach would you say is better and why?</p>
<p>Thanks in advance!</p>
| 0debug |
What does the Interface object means in the function parameters : <p>I am not able to understand what is the meaning of having any model or interface object into the method parameters.
For example, </p>
<pre><code>public function checkRights(CommentInterface $comment)
{
return true;
}
</code></pre>
<p>so here what does CommentInterface do? why we are not only passing $comment here? How do you name this kind of thing in programming language?</p>
<p>I am new to object oriented php
Thanks.</p>
| 0debug |
Is it really so difficult to draw smooth lines in Unity? : <p>I been trying for a while to draw smooth lines in Unity but with Line Renderer I obtained only jagged lines with the corners not rounded, in particular when the angle of curvature is really small . I incresed the value of antialiasing in quality settings and tried different materials but nothing changed. I also tried to instantiate a sphere every time the mouse move but it creates some gaps between the various spheres, in particular when the mouse go fast. I know there is a plugin called Vectrosity for this but there is a way to achieve this whitout it?</p>
| 0debug |
static void sparc_cpu_realizefn(DeviceState *dev, Error **errp)
{
SPARCCPUClass *scc = SPARC_CPU_GET_CLASS(dev);
scc->parent_realize(dev, errp);
} | 1threat |
Excel formula, COUNTIF two conditions : <p>I need a formula in Excel or VBA function, which will allow me to count the answers aggregated according to previously question. Table below will help me to explain this:</p>
<pre><code>+-----------+-------------+
| A | B |
+-----------+-------------+
| Question1 | Question2 |
| d | a,b,c,d |
| a | a,b,c,d,e,f |
| a | a,b |
| b | a,e |
| c | b,e,h,k |
| d | b,f |
| d | b,g,j |
| b | c,d,e |
| a | a,c,j |
+-----------+-------------+
</code></pre>
<p>Question1 column will be treated as profilling question, for example company size. a - small, b - medium, c - big, d - enterprise. I need on my output to count question2 answers aggregated to company size. For example, how many small companies have ticked answer a etc. I know how to count overall percentage of each question in answers, but I need compare it to profiling Question1. I do not know how to combine COUNTIF function which addotional condition - IF column A contains "a" pass it to COUNTIF(). I am considering VBA solution too.</p>
<p>Kind Regards</p>
| 0debug |
Python 2 string intersection uncommon part with pandas csv : If you had two strings,
string1 = "Rahul 123 Mumbai Shivani 234 Mumbai Akash 345 Mumbai Rahul 456 Bangalore"
string2 = "Rahul 123 Mumbai"
How do you find out the intersection?
As in, the final output should be -
Output -
Shivani 234 Mumbai Akash 345 Mumbai Rahul 456 Bangalore
I tried using str.strip(), but it's giving me incorrect answers. | 0debug |
static void mov_text_new_line_cb(void *priv, int forced)
{
MovTextContext *s = priv;
av_strlcpy(s->ptr, "\n", FFMIN(s->end - s->ptr, 2));
s->ptr++;
}
| 1threat |
xaringan slide separator not separating slides : <p>In this example <code>xaringan</code> presentation, why are both the <code>## blank page</code> and the <code>leaflet</code> map on the same slide, given I've separated them by the new-slide separator <code>---</code> ?</p>
<pre><code>---
title: "map test"
output:
xaringan::moon_reader:
css: ["default"]
nature:
highlightLines: true
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## blank page
content
---
leaflet page
```{r}
library(leaflet)
leaflet() %>%
addTiles()
```
---
</code></pre>
<p><a href="https://i.stack.imgur.com/AunFv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/AunFv.png" alt="enter image description here"></a></p>
| 0debug |
Convert from 2018-10-23T06:01:10.806Z to 10-May-2018 and a seperate string for time : <p>have to extract a separate date and time from the same string i.e)2018-10-23T06:01:10.806Z, the date must be in the format of 10-May-2018 and the time must be in 12 hours format i.e) 08:00 PM </p>
| 0debug |
Cannot boot Windows guest in VirtualBox without kernel module error : <p>I'm running Vagrant (1.8.1) + VirtualBox (5.0.12) on Windows 7 and trying to boot up a Windows 7 image (modernIE/w7-ie8). However, I get this error:</p>
<pre><code>---------------------------
VirtualBox - Error In supR3HardenedWinReSpawn
---------------------------
<html><b>NtCreateFile(\Device\VBoxDrvStub) failed: 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND (0 retries) (rc=-101)</b><br/><br/>Make sure the kernel module has been loaded successfully.<br><br><!--EOM-->where: supR3HardenedWinReSpawn
what: 3
VERR_OPEN_FAILED (-101) - File/Device open failed.
Driver is probably stuck stopping/starting. Try 'sc.exe query vboxdrv' to get more information about its state. Rebooting may actually help.</html>
---------------------------
OK
---------------------------
</code></pre>
<p>I ran the query command, but the service "is not found".</p>
<pre><code>> sc.exe query vboxdrv
[SC] EnumQueryServicesStatus:OpenService FAILED 1060:
The specified service does not exist as an installed service.
</code></pre>
<p>I tried rebooting, too. Nothing.</p>
| 0debug |
Is a date in same week, month, year of another date in swift : <p>What is the best way to know if a date is in the same week (or year or month) as another, preferably with an extension, and <strong>solely using Swift</strong>?</p>
<p>As an example, in Objective-C I have</p>
<pre><code>- (BOOL)isSameWeekAs:(NSDate *)date {
NSDateComponents *otherDay = [[NSCalendar currentCalendar] components:NSCalendarUnitEra | NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay fromDate:self];
NSDateComponents *today = [[NSCalendar currentCalendar] components:NSCalendarUnitEra | NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay fromDate:date];
return ([today weekOfYear] == [otherDay weekOfYear] &&
[today year] == [otherDay year] &&
[today era] == [otherDay era]);
}
</code></pre>
<p>Please don't propose solutions bridging <code>Date</code> to <code>NSDate</code></p>
| 0debug |
int float32_lt( float32 a, float32 b STATUS_PARAM )
{
flag aSign, bSign;
if ( ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) )
|| ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) )
) {
float_raise( float_flag_invalid STATUS_VAR);
return 0;
}
aSign = extractFloat32Sign( a );
bSign = extractFloat32Sign( b );
if ( aSign != bSign ) return aSign && ( (bits32) ( ( a | b )<<1 ) != 0 );
return ( a != b ) && ( aSign ^ ( a < b ) );
}
| 1threat |
HTTP CLIENT -what does mean http client? : I'm studying curl in laravel to send http request somewhere
this is mentioned that curl is the best http client
I wanna know the meaning of this sentence. | 0debug |
QEMU_BUILD_BUG_ON(ARRAY_SIZE(monitor_event_names) != QEVENT_MAX)
void monitor_protocol_event(MonitorEvent event, QObject *data)
{
QDict *qmp;
const char *event_name;
Monitor *mon;
assert(event < QEVENT_MAX);
event_name = monitor_event_names[event];
assert(event_name != NULL);
qmp = qdict_new();
timestamp_put(qmp);
qdict_put(qmp, "event", qstring_from_str(event_name));
if (data) {
qobject_incref(data);
qdict_put_obj(qmp, "data", data);
}
QLIST_FOREACH(mon, &mon_list, entry) {
if (monitor_ctrl_mode(mon) && qmp_cmd_mode(mon)) {
monitor_json_emitter(mon, QOBJECT(qmp));
}
}
QDECREF(qmp);
}
| 1threat |
Creating a show-more/show-less info box with + and - sign : <p>I want to create a box that has information in it that expands onclick of a '+' icon at the top right. The box should expand and include more information about that specific section and the '+' should transition into a '-' to allow the user to collapse the box to the original format that it was before.</p>
<p>The animation would be similar to <a href="https://www.w3schools.com/howto/howto_css_menu_icon.asp" rel="nofollow noreferrer">https://www.w3schools.com/howto/howto_css_menu_icon.asp</a> </p>
<p>In simple terms: I need a "show-more/show-less" box that expands/collapses but with a '+' and '-' sign instead of 'show-more' or 'show-less'</p>
<p>How can I achieve this?</p>
| 0debug |
xcode is showing error compiling the codes : <p>Here:-</p>
<p>import UIKit</p>
<p>class ViewController : UIViewController,UIPickerViewDataSource,UIPickerViewDelegate {
@IBOutlet weak var statePicker: UIPickerView!</p>
<pre><code>@IBOutlet weak var statepickerbtn: UIButton!
let states = ["alaska","alabama","akansas","california","maine","new york"]
override func viewDidLoad() {
super.viewDidLoad()
statePicker.dataSource = self
statePicker.delegate = self
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func statebtnpressed(_ sender: Any) {
func numberOfComponents(in: <#T##UIPickerView#>)-> Int
{
return 1
}
func pickerView(<#T##pickerView: UIPickerView##UIPickerView#>, numberOfRowsInComponent: <#T##Int#>)->Int
{
return states.count
}
func pickerView(<#T##pickerView: UIPickerView##UIPickerView#>, titleForRow: <#T##Int#>, forComponent: <#T##Int#>) -> String?
{
return states[row]
}
}
</code></pre>
<p>}</p>
| 0debug |
How to build a release test apk for Android with Gradle? : <p>I know, with the Gradle command <code>assembleAndroidTest</code> I can build a test APK.
But I can use this test APK only for debug builds of my app, right? If I use it with a release build, I get error messages like <code>"[SDR.handleImages] Unable to find test for com.xxx.xxx (packagename)"</code></p>
<p>How can I build a test APK in release mode with Gradle?</p>
| 0debug |
static int64_t raw_getlength(BlockDriverState *bs)
{
int64_t len;
BDRVRawState *s = bs->opaque;
len = bdrv_getlength(bs->file->bs);
if (len < 0) {
return len;
}
if (len < s->offset) {
s->size = 0;
} else {
if (s->has_size) {
s->size = MIN(s->size, len - s->offset);
} else {
s->size = len - s->offset;
}
}
return s->size;
}
| 1threat |
How can we make a div visible over another div while hover : <p>How can we make a div visible over another div while hover . While hover the div is hiding .</p>
<p>Please check it <a href="http://development.hostroom.in/australiancapitalcollege/" rel="nofollow noreferrer">here</a> - the DOWNLOAD button in the footer section - just above the footer widget . </p>
<p>Please help me to make that download hover drop down visible while hover</p>
<p>Thanks in advance</p>
| 0debug |
Finding the closest span with a specific class inside a div using jquery : I want to find the closest span with class error_span how will i do that using jquery
<div class="form-group row">
<div class="col-sm-4"><label for="reimburse_price" class="control label">Amount</label></div>
<div class="col-sm-8">
<div><input type="text" name="reimburse_price" min="1" placeholder='0.00' class="form-control numberOnly" id="reimburse_price" required></div>
<div><span class="small text-danger error_span"></span></div>
</div>
</div> | 0debug |
What's the postDelayed() uses in kotlin : <p>As I know postDelayed() have two argument runnable and duration delay.
What actually does below code in kotlin:</p>
<pre><code>Handler().postDelayed({
sendMessage(MSG, params.id)
taskFinished(params, false)
}, duration)
</code></pre>
<p>Here 1st is two function calling and 2nd is duration delay. Where is runnable? Does this something like lambda for kotlin? Any anyone please explain this?</p>
| 0debug |
C# method running with worksheet : <p>Maybe it is a beginner question but I can not seem to figure it out. How do I run the method as seen in the picture?</p>
<p>[[image]: <a href="https://i.stack.imgur.com/1QlnL.png][1]" rel="nofollow noreferrer">https://i.stack.imgur.com/1QlnL.png][1]</a></p>
| 0debug |
Flutter Navigation Drawer that actually navigates : <p>I have a simple <code>Scaffold</code> with a drawer and a body. I want to select an item in the drawer and have the scaffold's body navigate to a new view.</p>
<p>Most approaches that i found (<a href="https://stackoverflow.com/questions/47953410/flutter-drawer-widget-change-scaffold-body-content">like this</a>) just use a stateful widget and change its state when the drawer item is tapped.</p>
<p>However this completely ignores the navigation stack of the app, and pressing back does not return to the previous view as expected.</p>
<p>On the other hand, using <code>Navigator.of(context).push...</code> when an item is clicked uses the navigation stack, but changes the whole screen, which is also not what i want.</p>
<p>I tried to create a new custom navigator for the scaffold's body, but had issues accessing the <code>NavigatorState</code> from the Drawer.</p>
<p>This seems like a common problem to me (for instance, all google apps work that way) and i am a bit confused on how to implement this correctly.
Is a custom navigator the correct approach? Are there some examples available?</p>
| 0debug |
PHP - remove empty strings of array doesn't work : I've got an array by scrape an website. It contains some **empty strings** and I want to remove that array-elements. I tried already apply_filter($array). Also I tried to iterate and filter out this elements manually, but it doesn't work. Now I found out, that I can't access this elements at all:
foreach($array as $elem){
if($elem == " " || $elem == " ")
echo "Want access this: " . elem . "<br>";
//No Output here
}
So maybe this elements are not empty Strings? But what else could it be? Here the output of var_dump of the Array:
array(47) { [0]=> string(31) "16.11.2016" [1]=> string(23) " " [2]=> string(21) "" [3]=> string(21) "" [4]=> string(21) "" [5]=> string(21) "" [6]=> string(21) "" [7]=> string(21) "" [8]=> string(31) "18.01.2017" [9]=> string(148) "
"Therapie des fortgeschrittenen Prostatakarzinoms" - Online-Vortrag von Prof. Dr. Thomas Steuber, Martiniklinik Hamburg
" [10]=> string(21) "" [11]=> string(21) "" [12]=> string(31) "15.02.2017" [13]=> string(139) "Gesprächsabend mit Prof. Dr. Christiansen (onkologische Strahlentherapie) und Prof. Dr. Bengel (Nuklearmedizin) - MHH" [14]=> string(21) "" [15]=> string(21) "" [16]=> string(21) "" [17]=> string(23) " " [18]=> string(21) "" [19]=> string(21) "" [20]=> string(31) "15.03.2017" [21]=> string(83) "Komplementärmedizin - Integrative Medizin - Alternativmedizin" [22]=> string(21) "" [23]=> string(21) "" [24]=> string(21) "" [25]=> string(23) " " [26]=> string(21) "" [27]=> string(21) "" [28]=> string(19) "19.04.2017" [29]=> string(21) "" [30]=> string(21) "" [31]=> string(21) "" [32]=> string(21) "" [33]=> string(40) "10.05.2017 " [34]=> string(142) "
Kontinenztherapie nach Prostata-OP - Referent Prof. Dr. U. Otto, Quellentalklinik Reinhardshausen (Onlinevortrag)
" [35]=> string(42) "21.06.2017 " [36]=> string(20) "19.07.2017 " [37]=> string(32) "16.08.2017 " [38]=> string(32) "20.09.2017 " [39]=> string(160) "
Internetbasierte Informations- und Entscheidungshilfe für Patienten mit nicht-metastasiertem Prostatakrebs (Internetseite des BPS)
" [40]=> string(32) "18.10.2017 " [41]=> string(116) "
Fatigue - Referentin: Frau Sabine Malinka, Krebsberatungszentrum Hannover im [ka:punkt]
" [42]=> string(31) "15.11.2017" [43]=> string(21) "" [44]=> string(20) "20.12.2017 " [45]=> string(19) "17.01.2018" [46]=> string(9) "" }
| 0debug |
How to use ViewDataDictionary with Html.Partial in asp.net core? : <p>My case looks like this:</p>
<p>Model:</p>
<pre><code>public class Book
{
public string Id { get; set; }
public string Name { get; set; }
}
public class Comment
{
public string Id { get; set; }
public string BookId { get; set; }
public string Content { get; set; }
}
</code></pre>
<p>Controller:</p>
<pre><code>public IActionResult Detail(string id)
{
ViewData["DbContext"] = _context; // DbContext
var model = ... // book model
return View(model);
}
</code></pre>
<p>View:</p>
<p>Detail view:</p>
<pre><code>@if (Model?.Count > 0)
{
var context = (ApplicationDbContext)ViewData["DbContext"];
IEnumerable<Comment> comments = context.Comments.Where(x => x.BookId == Model.Id);
@Html.Partial("_Comment", comments)
}
</code></pre>
<p>Comment partial view:</p>
<pre><code>@model IEnumerable<Comment>
@if (Model?.Count > 0)
{
<!-- display comments here... -->
}
<-- How to get "BookId" here if Model is null? -->
</code></pre>
<p>I've tried this:</p>
<pre><code>@Html.Partial("_Comment", comments, new ViewDataDictionary { { "BookId", Model.Id } })
</code></pre>
<p>Then</p>
<pre><code>@{
string bookid = ViewData["BookId"]?.ToString() ?? "";
}
@if (Model?.Count() > 0)
{
<!-- display comments here... -->
}
<div id="@bookid">
other implements...
</div>
</code></pre>
<p>But error:</p>
<blockquote>
<p>'ViewDataDictionary' does not contain a constructor that takes 0
arguments</p>
</blockquote>
<p>When I select <code>ViewDataDictionary</code> and press <code>F12</code>, it hits to:</p>
<pre><code>namespace Microsoft.AspNetCore.Mvc.ViewFeatures
{
public ViewDataDictionary(IModelMetadataProvider metadataProvider, ModelStateDictionary modelState);
}
</code></pre>
<p>I don't know what are <code>IModelMetadataProvider</code> and <code>ModelStateDictionary</code>?</p>
<p>My goal: Send model <code>comments</code> from view <code>Detail.cshtml</code> to partial view <code>_Comment.cshtml</code> with a <code>ViewDataDictionary</code> which contains <code>BookId</code>.</p>
<p>My question: How can I do that?</p>
| 0debug |
How to seed Django project ? - insert a bunch of data into the project for initialization : <p>I'ved been developing in Django and was wondering if there is a way to seed data into the database in Django.</p>
<p>In ruby on rails, I use seed.rb and then run "rake db:seed" in command line. </p>
<p>Main reason I want to seed some data on statuses, types, etc for the project initialization.</p>
<p>Is there something similar ?</p>
| 0debug |
variable initialization using class meber function : why the head is not NULL at the beginning if I initialized it with the class member function. It is a tricky part. Thanks in advance.
#include <iostream>
using namespace std;
struct node
{
int data;
node *next;
};
class linked_list
{
private:
node *head;
public:
// linked_list();
// ~linked_list();
void push(node *head, int data);
void printList(node *head);
void printMiddle(node *head);
void makeHeadNull();
};
void linked_list::push(node *head, int data)
{
node *newNode=new node;
if(head==NULL)
{
head=newNode;
}
else {
newNode->data = data;
newNode->next = head;
head = newNode;
}
}
//linked_list::linked_list():head(NULL)
//{
//
//}
//linked_list::~linked_list() {
// delete head;
//}
//void linked_list::printMiddle(node *head)
//{
// int count=0;
// node *temp=head;
// while(temp!=NULL)
// {
// temp=temp->next;
// count++;
//
// }
// int i=0;
// while(i<count/2)
// {
// head=head->next;
// i++;
// }
// if(head->next!=NULL)
// {
// cout<<head->next->data<<" ";
// }
//}
void linked_list::printMiddle(node *head)
{
node *slow_ptr = head;
node *fast_ptr = head;
if (head!=NULL)
{
while (fast_ptr != NULL && fast_ptr->next != NULL)
{
fast_ptr = fast_ptr->next->next;
slow_ptr = slow_ptr->next;
}
printf("The middle element is [%d]\n\n", slow_ptr->data);
}
}
void linked_list::printList(node *head)
{
while(head!=NULL)
{
cout<<head->data<<" ";
head=head->next;
}
}
void linked_list::makeHeadNull()
{
head=NULL;
}
int main()
{
node *head;
linked_list l;
l.makeHeadNull();
l.push(head, 0);
l.push(head, 1);
l.push(head, 2);
l.push(head, 3);
l.push(head, 4);
l.printMiddle(head);
}
I wanted to initialize head inside a constructor, but when I initialized head like that, the head node has always been NULL inside main. When I initialize head in the constructor and then I want to pass it as a parameter of a function push I get errors. | 0debug |
Log messages in android studio junit test : <p>Is there a way to print out Logcat (Log.i, Log.d) messages when running a JUnit (method) test in Android Studio?</p>
<p>I can see System.out.print message but no logcat printouts.</p>
<p>In the runconfiguration (GUI window of Android Studio) there are logcat options for tests under Android tests but not for JUnit tests.</p>
<p>Is this possible somehow? Thanks for any hints!</p>
| 0debug |
Service Fabric Actor or Service Becomes Inaccessible at Random after Upgrading to SDK 2.3.301 : <p>After upgrading from Service Fabric SDK 2.0.135 to 2.3.301, we have started encountering situations where a Service Fabric actor or service is inaccessible in spite of showing as healthy in Service Fabric Explorer. Once in this state, any call to the actor or service via the ActorProxy or ServiceProxy will hang for 5 minutes before finally giving a TimeoutException. Once in this state, the actor or service never recovers on its own – even if left for an hour. The only solution is to reset the node(s) on which the actor or service resides, redeploy the actor or service (exact same EXE), reset the entire cluster or reboot all of the cluster machines. </p>
<p>It usually gets into this state after deploying or re-deploying a SF application.</p>
<p>In the last year of working with Service Fabric (since SDK v1.3), we have never had this problem. It only started after moving to 2.3.301.</p>
<p>It seems to happen randomly and inconsistently. Which of our 13 SF applications within our solution get effected is also random.</p>
<p>Does anyone have any ideas on how we might be able to resolve this? It seems like a bug in the latest version of Service Fabric but perhaps we are doing something wrong on our end. </p>
<p>Any help is appreciated.</p>
<p>Below is a lot of extra information that I hope will be useful in understanding what we're facing with this issue. </p>
<p>Many thanks</p>
<p><strong>Steps</strong></p>
<p>I don't really have steps to consistently reproduce the issue. This is simply what I observe sometimes.</p>
<ol>
<li>I compiled and then re-deployed my SF project from Visual Studio (Debug -> Start Without Debugging)</li>
<li>Visual Studio says it successfully deployed the project</li>
<li>Service Fabric Explorer shows all of my services as Healthy, including Data-Binding</li>
<li>The SF project in question has 2 actors that are part of a single EXE. Service Fabric Explorer shows each of these actors running on different nodes.</li>
<li>Windows Task Manager shows two running copies of the EXE, which makes sense since there are two nodes running the EXE.</li>
</ol>
<p>Likewise, our QA experiences the issue after deploying to Azure using PowerShell directly. (He doesn't deploy from Visual Studio.)</p>
<p><strong>To recap</strong></p>
<ul>
<li>Visual Studio says the deployment was successful</li>
<li>Service Fabric Explorer shows that everything is healthy</li>
<li>Task Manager shows two running copies of the EXE</li>
</ul>
<p><strong>When I See The Failure</strong></p>
<p>I have one SF Service calling another SF Service using the ServiceProxy or ActorProxy classes. We do this throughout our solution with a combination of 13 different applications and about 25 different Services & Actors. It has worked successfully since we started working with Service Fabric SDK v1.3 in November 2015.</p>
<p>Now, after upgrading to 2.3.301, we have the periodic occurrence of a random Actor or Service getting into a state where it fails to respond to a call to a method when called from ServiceProxy or ActorProxy. After 5 minutes of hanging, we receive a System.Timeout exception with the following message:</p>
<blockquote>
<p>This can happen if message is dropped when service is busy or its long
running operation and taking more time than configured Operation
Timeout.</p>
</blockquote>
<p>Note that the service is NOT busy, nor is it performing a long-running operation. As an actor, the service doesn’t do any on-going operations at all. It simply exposes public methods that other services can consume. It fails from the very first call.</p>
<p>In fact, tracing shows us that even the first line of the method in the actor <em>never</em> gets called. It's as if the Service Fabric communication infrastructure fails to deliver the message.</p>
<p><strong>When This Started</strong></p>
<p>In the past 12 months, we had never seen this issue. </p>
<p>Now, we are seeing this issue frequently and under a variety of conditions since upgrading Service Fabric last week.</p>
<p>We upgrade to Service Fabric SDK 2.3.301.9590 and Service Fabric 5.3.301.9590.</p>
<p>At first, each developer in the team encountered the issue independently and each thought it was a transient issue with just our machines. Service Fabric does have some issues so we just accept this and move on. But then we started to complain to each other and realized that we are all seeing it. Even our QAs are seeing it in the cloud on our environment that is soon to be production.</p>
<p>Again, this only started when we upgraded to the latest version of Service Fabric last week.</p>
<p>Previously, we were running Service Fabric SDK 2.0.135.</p>
<p>We upgraded our codebase by installing SDK v 2.3.301, opening each of our solutions and allowing Visual Studio to conduct the upgrade.</p>
<p><strong>The Environment</strong></p>
<p>I’m running a fresh install of Windows 10 Enterprise (installed it less than 2 weeks ago) on an i7 with 16 gigs of RAM. I have a fresh install of Visual Studio 2015 Update 3 and SF 2.3.301.9590. I installed everything clean. No upgrades.</p>
<p>This is also happening on all of my colleagues machines (of varying ages, configurations and “freshnesses”). It happens sporadically to each of us. </p>
<p>Most critically, this is also happening on our Service Fabric VMs on Azure. These are machines that our QA created about a month ago using the standard templates for Service Fabric VMs on Azure. It had 5.3.301.9590 pre-installed. He did not manually install any updates to Service Fabric. Our SF-based application did not encounter this problem on Azure (or our own dev machines) until after the developers upgraded to the new version.</p>
<p>This is not a my machine thing, nor is it isolated to just the development environment. The only consistent change for all of us is the update of the SF version.</p>
<p><strong>The Cause</strong></p>
<p>We have no idea what causes it. </p>
<p>It usually happens immediately after deploying a new SF application. Yes, we do wait for the usual 2 or 3 minutes it takes for SF to "figure itself out" after deploying. We have left it for an hour or more and it just never works.</p>
<p>Anecdotally, I <em>think</em> I've had a SF Service that was working fine and then suddenly stopped working but this was before we realized there was an issue so I wasn't looking for it. I can't be certain.</p>
<p><strong>The Work-Arounds</strong></p>
<p>Once we have a SF service in that “inaccessible” state, Service Fabric will not get itself back out of that state again. The application is completely unusable. With varying degrees of success, we do the following:</p>
<ul>
<li>Re-deploy the inaccessible SF application</li>
<li>Restart the nodes (through Service Fabric Explorer by going to the
node, clicking the ellipsis button and clicking the “Restart” option)
that host the inaccessible SF services & actors</li>
<li>Restart the entire SF cluster (Stop then Start)</li>
<li>Restart all of the machines running a SF node</li>
<li>Reset the entire cluster and re-deploy everything (last resort but it
has been necessary a few times)</li>
</ul>
<p>Interestingly, what does not help is using Task Manager to kill the offending processes. If I kill the offending process, Service Fabric restarts it (as expected) but it still won't respond to messages.</p>
<p>Thus, the issue seems to be with Service Fabric itself and not with the EXEs.</p>
<p>Of course, these aren’t “solutions” at all because they leave our entire application inaccessible until SF can restart/rebalance. Even restarting a few of the nodes knocks a bunch of stuff off-line.</p>
<p>Essentially, this is a show-stopper for us. We can’t possibly put our application into production (or even beta) with Service Fabric behaving like this.</p>
<p>The C# Exception when Using the Service Proxy or Actor Proxy:</p>
<p><strong>JSON rendering of the Exception Thrown by ActorProxy or ServicePRoxy</strong></p>
<pre><code>"exception": {
"ClassName": "System.TimeoutException",
"Message": "This can happen if message is dropped when service is busy or its long running operation and taking more time than configured Operation Timeout.",
"Data": null,
"InnerException": null,
"HelpURL": null,
"StackTraceString": " at Microsoft.ServiceFabric.Services.Communication.Client.ServicePartitionClient`1.<InvokeWithRetryAsync>d__7`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Services.Remoting.Client.ServiceRemotingPartitionClient.<InvokeAsync>d__8.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Services.Remoting.Builder.ProxyBase.<InvokeAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Services.Remoting.Builder.ProxyBase.<ContinueWithResult>d__7`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at RenderingCachingEngine.RenderingCachingEngine.<Render>d__10.MoveNext() in C:\\Code\\Ink\\Dev\\Current\\Source\\Rendering Service Fabric\\RenderingCachingEngine\\RenderingCachingEngine.cs:line 381",
"RemoteStackTraceString": null,
"RemoteStackIndex": 0,
"ExceptionMethod": "8\nMoveNext\nMicrosoft.ServiceFabric.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\nMicrosoft.ServiceFabric.Services.Communication.Client.ServicePartitionClient`1+<InvokeWithRetryAsync>d__7`1\nVoid MoveNext()",
"HResult": -2146233083,
"Source": "Microsoft.ServiceFabric.Services",
"WatsonBuckets": null
}
</code></pre>
<p>Here is a JSON rendering of the Service Fabric Info:</p>
<pre><code> "serviceFabricInfo": {
"serviceFabricServiceName": "fabric:/Rendering/RenderingCachingEngine",
"serviceFabricServiceTypeName": "RenderingCachingEngineType",
"serviceFabricReplicaId": 131225099453058851,
"serviceFabricPartitionId": "e400087d-8a08-4dab-bcdd-1f5ce82f374f",
"serviceFabricApplicationName": "fabric:/Rendering",
"serviceFabricApplicationTypeName": "RenderingType",
"serviceFabricNodeName": "_Node_4"
}
</code></pre>
<p><strong>The Event Viewer Logs When Re-Deploying</strong></p>
<p>Windows Event Viewer does show some note-worthy logs under “Applications and Services Logs -> Microsoft-Service Fabric -> Admin”.</p>
<p>The following logs happened while I was re-deploying an updated version of my application (note that DataBinding.exe is the name of the EXE containing my two SF actors):</p>
<pre><code>Log Name: Microsoft-ServiceFabric/Admin
Source: Microsoft-ServiceFabric
Date: 11/2/2016 2:38:53 PM
Event ID: 256
Task Category: Common
Level: Error
Keywords: Default
User: NETWORK SERVICE
Computer: shayward10.ovx.local
Description:
WriteNode failed. HRESULT=-2147467259, Output=CustomOutput
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Microsoft-ServiceFabric" Guid="{CBD93BC2-71E5-4566-B3A7-595D8EECA6E8}" />
<EventID>256</EventID>
<Version>0</Version>
<Level>2</Level>
<Task>1</Task>
<Opcode>0</Opcode>
<Keywords>0x8000000000000001</Keywords>
<TimeCreated SystemTime="2016-11-02T18:38:53.678587200Z" />
<EventRecordID>7620</EventRecordID>
<Correlation />
<Execution ProcessID="4440" ThreadID="7360" />
<Channel>Microsoft-ServiceFabric/Admin</Channel>
<Computer>shayward10.ovx.local</Computer>
<Security UserID="S-1-5-20" />
</System>
<EventData>
<Data Name="id">
</Data>
<Data Name="type">XmlLiteWriter</Data>
<Data Name="text">WriteNode failed. HRESULT=-2147467259, Output=CustomOutput</Data>
</EventData>
</Event>
Log Name: Microsoft-ServiceFabric/Admin
Source: Microsoft-ServiceFabric
Date: 11/2/2016 2:38:54 PM
Event ID: 23073
Task Category: Hosting
Level: Warning
Keywords: Default
User: SYSTEM
Computer: shayward10.ovx.local
Description:
ServiceHostProcess: DataBinding.exe for ApplicationId 805915c7-456c-49d3-af95-62cc44650664 terminated unexpectedly with exit code 3221225786 on node id bf865279ba277deb864a976fbf4c200e
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Microsoft-ServiceFabric" Guid="{CBD93BC2-71E5-4566-B3A7-595D8EECA6E8}" />
<EventID>23073</EventID>
<Version>0</Version>
<Level>3</Level>
<Task>90</Task>
<Opcode>0</Opcode>
<Keywords>0x8000000000000001</Keywords>
<TimeCreated SystemTime="2016-11-02T18:38:54.820567800Z" />
<EventRecordID>7621</EventRecordID>
<Correlation />
<Execution ProcessID="6944" ThreadID="3812" />
<Channel>Microsoft-ServiceFabric/Admin</Channel>
<Computer>shayward10.ovx.local</Computer>
<Security UserID="S-1-5-18" />
</System>
<EventData>
<Data Name="id">bf865279ba277deb864a976fbf4c200e</Data>
<Data Name="AppId">805915c7-456c-49d3-af95-62cc44650664</Data>
<Data Name="ReturnCode">3221225786</Data>
<Data Name="ProcessName">DataBinding.exe</Data>
</EventData>
</Event>
Log Name: Microsoft-ServiceFabric/Admin
Source: Microsoft-ServiceFabric
Date: 11/2/2016 2:38:56 PM
Event ID: 256
Task Category: Common
Level: Error
Keywords: Default
User: NETWORK SERVICE
Computer: shayward10.ovx.local
Description:
WriteNode failed. HRESULT=-2147467259, Output=CustomOutput
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Microsoft-ServiceFabric" Guid="{CBD93BC2-71E5-4566-B3A7-595D8EECA6E8}" />
<EventID>256</EventID>
<Version>0</Version>
<Level>2</Level>
<Task>1</Task>
<Opcode>0</Opcode>
<Keywords>0x8000000000000001</Keywords>
<TimeCreated SystemTime="2016-11-02T18:38:56.261857600Z" />
<EventRecordID>7627</EventRecordID>
<Correlation />
<Execution ProcessID="4440" ThreadID="8564" />
<Channel>Microsoft-ServiceFabric/Admin</Channel>
<Computer>shayward10.ovx.local</Computer>
<Security UserID="S-1-5-20" />
</System>
<EventData>
<Data Name="id">
</Data>
<Data Name="type">XmlLiteWriter</Data>
<Data Name="text">WriteNode failed. HRESULT=-2147467259, Output=CustomOutput</Data>
</EventData>
</Event>
</code></pre>
<p><strong>The Event Viewer Logs when it Times Out</strong></p>
<p>Once the service is in an inaccessible state, trying to call it yields the following log on each request (after waiting for 5 minutes):</p>
<pre><code>Log Name: Microsoft-ServiceFabric/Admin
Source: Microsoft-ServiceFabric
Date: 11/2/2016 2:44:55 PM
Event ID: 44289
Task Category: FabricTransport
Level: Warning
Keywords: Default
User: NETWORK SERVICE
Computer: shayward10.ovx.local
Description:
Error While Sending Message : FABRIC_E_TIMEOUT
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Microsoft-ServiceFabric" Guid="{CBD93BC2-71E5-4566-B3A7-595D8EECA6E8}" />
<EventID>44289</EventID>
<Version>0</Version>
<Level>3</Level>
<Task>173</Task>
<Opcode>0</Opcode>
<Keywords>0x8000000000000001</Keywords>
<TimeCreated SystemTime="2016-11-02T18:44:55.349048200Z" />
<EventRecordID>7629</EventRecordID>
<Correlation />
<Execution ProcessID="18600" ThreadID="8076" />
<Channel>Microsoft-ServiceFabric/Admin</Channel>
<Computer>shayward10.ovx.local</Computer>
<Security UserID="S-1-5-20" />
</System>
<EventData>
<Data Name="id">
</Data>
<Data Name="type">ServiceCommunicationClient</Data>
<Data Name="text">Error While Sending Message : FABRIC_E_TIMEOUT</Data>
</EventData>
</Event>
</code></pre>
| 0debug |
DeviceState *exynos4210_uart_create(target_phys_addr_t addr,
int fifo_size,
int channel,
CharDriverState *chr,
qemu_irq irq)
{
DeviceState *dev;
SysBusDevice *bus;
const char chr_name[] = "serial";
char label[ARRAY_SIZE(chr_name) + 1];
dev = qdev_create(NULL, "exynos4210.uart");
if (!chr) {
if (channel >= MAX_SERIAL_PORTS) {
hw_error("Only %d serial ports are supported by QEMU.\n",
MAX_SERIAL_PORTS);
}
chr = serial_hds[channel];
if (!chr) {
snprintf(label, ARRAY_SIZE(label), "%s%d", chr_name, channel);
chr = qemu_chr_new(label, "null", NULL);
if (!(chr)) {
hw_error("Can't assign serial port to UART%d.\n", channel);
}
}
}
qdev_prop_set_chr(dev, "chardev", chr);
qdev_prop_set_uint32(dev, "channel", channel);
qdev_prop_set_uint32(dev, "rx-size", fifo_size);
qdev_prop_set_uint32(dev, "tx-size", fifo_size);
bus = sysbus_from_qdev(dev);
qdev_init_nofail(dev);
if (addr != (target_phys_addr_t)-1) {
sysbus_mmio_map(bus, 0, addr);
}
sysbus_connect_irq(bus, 0, irq);
return dev;
}
| 1threat |
I need urgent help for know one thing : I want urgent help!!!!
Today my exam paper was showed and I failed in ICT subject. I wrote 2 question's answer about html sloving!(or u can say I had to write HTMl for those question in answer paper).
In the question's detail there was wrote:-
A boy designed a web page where he used a 500*400p image named sunset.png . If the browser can not able to show that pic then it will show "missing" text in the browser window. Then he showed this to his friend. Then his friend do something so when click in the picture then he will go to youtube.
Question no.1:-
Write the html code that the 1st boy used.
Question no.2:-
Write the HTML code that 2nd boy used.
for the 1st question I wrote:-
<!DOCTYPE html>
<html lang="en">
<head>
<title>My webpage</title>
</head>
<body>
<p><img src="sunset.png" width="500" height="300" alt="missing"></p>
</body>
</html>
for the 2nd question I wrote:-
<!DOCTYPE html>
<html lang="en">
<head>
<title>My webpage</title>
</head>
<body>
<p> <a href="https://www.youtube.com"> <img src="sunset.png" width="500"height="300" alt="missing"> </a> </p>
</body>
</html>
My sir told my mistook was <p> tag. I can not use paragraph tag outside of image. so, Out of 7 I got "0" marks.
So, I want to know that was true? Then why the browser showing the pic?
Plz, comment to help me out and plz if u have any reference that day u can use <p> outside of <img> tag plz give me that site's link too. so, I can take screen shot and show him.
Plz help me out! Or, I will be fail in result card!!!
Sorry for disturbing and wasting ur time .... | 0debug |
Mysql display only if result bigger than 0 : <p>I am running the following query to search products in MySQL, it display everything but I need it to display only the products with more than 0 ( at least 1) in stock</p>
<pre><code> $result=mysqli_query($datacenter,"
SELECT * FROM productos
WHERE codigo like '%$terminos%'
or sku like '%$terminos%'
or producto like '%$terminos%'
or marca like '%$terminos%'
or modelo like '%$terminos%'
AND cantidad > 0
ORDER BY `$orden`
$emplazamiento
limit $visualizar");
</code></pre>
<p>The problem is that it display even those with 0 in stock ... Any idea why?</p>
| 0debug |
angular 2 - how to set <select> default selected option : <p>My template is like this</p>
<pre><code><select>
<option>AM</option>
<option>PM</option>
</select>
</code></pre>
<p>How can I set option AM selected by default?</p>
| 0debug |
Advanced regex for unordered characters and numbers : <p>This seems simple but I've been struggling for hours now. The pattern is simple, a telephone number that optionally starts with a +, has 10-15 digits, and optionally has spaces, dashes or parentheses. The numbers and characters should be in no particular order.</p>
<p>I've tried using non-matching groups and seen so many different ways of validating phone numbers, but to no avail.</p>
<p>The best I have so far is <code>^\+?([0-9]{10-15}[)( -]*)$</code>, but it only accepts the other characters if they're at the end of the pattern. This expression will be used in a Java context.</p>
| 0debug |
static av_cold int nvenc_setup_surfaces(AVCodecContext *avctx)
{
NvencContext *ctx = avctx->priv_data;
int i, res;
ctx->surfaces = av_mallocz_array(ctx->nb_surfaces, sizeof(*ctx->surfaces));
if (!ctx->surfaces)
return AVERROR(ENOMEM);
ctx->timestamp_list = av_fifo_alloc(ctx->nb_surfaces * sizeof(int64_t));
if (!ctx->timestamp_list)
return AVERROR(ENOMEM);
ctx->unused_surface_queue = av_fifo_alloc(ctx->nb_surfaces * sizeof(NvencSurface*));
if (!ctx->unused_surface_queue)
return AVERROR(ENOMEM);
ctx->output_surface_queue = av_fifo_alloc(ctx->nb_surfaces * sizeof(NvencSurface*));
if (!ctx->output_surface_queue)
return AVERROR(ENOMEM);
ctx->output_surface_ready_queue = av_fifo_alloc(ctx->nb_surfaces * sizeof(NvencSurface*));
if (!ctx->output_surface_ready_queue)
return AVERROR(ENOMEM);
res = nvenc_push_context(avctx);
if (res < 0)
return res;
for (i = 0; i < ctx->nb_surfaces; i++) {
if ((res = nvenc_alloc_surface(avctx, i)) < 0)
{
nvenc_pop_context(avctx);
return res;
}
}
res = nvenc_pop_context(avctx);
if (res < 0)
return res;
return 0;
}
| 1threat |
Prometheus vs ElasticSearch. Which is better for container and server monitoring? : <p>ElasticSearch is a document store and more of a search engine, I think ElasticSearch is not good choice for monitoring high dimensional data as it consumes lot of resources. On the other hand prometheus is a TSDB which is designed for capturing high dimensional data. </p>
<p>Anyone experienced in this please let me know what's the best tool to go with for container and server monitoring. </p>
| 0debug |
How to read/interrogate a filesystem and file structure : <p>As a first time programming using vi with a raw Linux terminal in C++, what is the simplest way to recurse through a filesystem and get results such as file size, date, directory date etc?</p>
<p>I imagine I'm missing a library or two that would handle this pretty cleanly which would be great to know. Even better would be knowing where to find a solid reference for the basics like this.</p>
| 0debug |
void ff_avg_h264_qpel16_mc13_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_hv_qrt_and_aver_dst_16x16_msa(src + stride - 2,
src - (stride * 2),
stride, dst, stride);
}
| 1threat |
Retain Objects Value After Refreshing JSP Page : My program has to go through a learning step that takes around 15 mins to complete. The result of this learning is two Models stored into two public objects which will be then used in other classes. I put this learning step in the method `public void init()` so as to be performed at the start of the server. The problem is, every time I refresh the page or send different GET parameter, the server re-do the learning step.. I have to wait another 15 minutes just to see the effect of a small change. I was wondering if there is a way to retain the value of some objects throughout the running of the program and the server.
public static Model model1;
public static Model model2;
@Override
public void init()
{
model1= readModel(source1)
model2= readModel(source2)
}
PS. I am using Servlets with JSP pages and Tomcat Server. | 0debug |
bool timerlist_run_timers(QEMUTimerList *timer_list)
{
QEMUTimer *ts;
int64_t current_time;
bool progress = false;
QEMUTimerCB *cb;
void *opaque;
if (!atomic_read(&timer_list->active_timers)) {
return false;
}
qemu_event_reset(&timer_list->timers_done_ev);
if (!timer_list->clock->enabled) {
goto out;
}
switch (timer_list->clock->type) {
case QEMU_CLOCK_REALTIME:
break;
default:
case QEMU_CLOCK_VIRTUAL:
if (!replay_checkpoint(CHECKPOINT_CLOCK_VIRTUAL)) {
goto out;
}
break;
case QEMU_CLOCK_HOST:
if (!replay_checkpoint(CHECKPOINT_CLOCK_HOST)) {
goto out;
}
break;
case QEMU_CLOCK_VIRTUAL_RT:
if (!replay_checkpoint(CHECKPOINT_CLOCK_VIRTUAL_RT)) {
goto out;
}
break;
}
current_time = qemu_clock_get_ns(timer_list->clock->type);
for(;;) {
qemu_mutex_lock(&timer_list->active_timers_lock);
ts = timer_list->active_timers;
if (!timer_expired_ns(ts, current_time)) {
qemu_mutex_unlock(&timer_list->active_timers_lock);
break;
}
timer_list->active_timers = ts->next;
ts->next = NULL;
ts->expire_time = -1;
cb = ts->cb;
opaque = ts->opaque;
qemu_mutex_unlock(&timer_list->active_timers_lock);
cb(opaque);
progress = true;
}
out:
qemu_event_set(&timer_list->timers_done_ev);
return progress;
}
| 1threat |
Limit of c^n (with c<1) is 0 (Isabelle) : Does anyone know a rule for showing
"c<1 ==> (λn. c^n) ---> 0"
in the reals? | 0debug |
int migrate_use_xbzrle(void)
{
MigrationState *s;
s = migrate_get_current();
return s->enabled_capabilities[MIGRATION_CAPABILITY_XBZRLE];
}
| 1threat |
int vncws_decode_frame(Buffer *input, uint8_t **payload,
size_t *payload_size, size_t *frame_size)
{
unsigned char opcode = 0, fin = 0, has_mask = 0;
size_t header_size = 0;
uint32_t *payload32;
WsHeader *header = (WsHeader *)input->buffer;
WsMask mask;
int i;
if (input->offset < WS_HEAD_MIN_LEN + 4) {
return 0;
}
fin = (header->b0 & 0x80) >> 7;
opcode = header->b0 & 0x0f;
has_mask = (header->b1 & 0x80) >> 7;
*payload_size = header->b1 & 0x7f;
if (opcode == WS_OPCODE_CLOSE) {
return -1;
}
if (!fin || !has_mask || opcode != WS_OPCODE_BINARY_FRAME) {
VNC_DEBUG("Received faulty/unsupported Websocket frame\n");
return -2;
}
if (*payload_size < 126) {
header_size = 6;
mask = header->u.m;
} else if (*payload_size == 126 && input->offset >= 8) {
*payload_size = be16_to_cpu(header->u.s16.l16);
header_size = 8;
mask = header->u.s16.m16;
} else if (*payload_size == 127 && input->offset >= 14) {
*payload_size = be64_to_cpu(header->u.s64.l64);
header_size = 14;
mask = header->u.s64.m64;
} else {
return 0;
}
*frame_size = header_size + *payload_size;
if (input->offset < *frame_size) {
return 0;
}
*payload = input->buffer + header_size;
payload32 = (uint32_t *)(*payload);
for (i = 0; i < *payload_size / 4; i++) {
payload32[i] ^= mask.u;
}
for (i *= 4; i < *payload_size; i++) {
(*payload)[i] ^= mask.c[i % 4];
}
return 1;
}
| 1threat |
static void sun4m_load_kernel(long vram_size, int ram_size, int boot_device,
const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
int machine_id)
{
int ret, linux_boot;
char buf[1024];
unsigned int i;
long prom_offset, initrd_size, kernel_size;
linux_boot = (kernel_filename != NULL);
prom_offset = ram_size + vram_size;
cpu_register_physical_memory(PROM_ADDR,
(PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK,
prom_offset | IO_MEM_ROM);
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, PROM_FILENAME);
ret = load_elf(buf, 0, NULL, NULL, NULL);
if (ret < 0) {
fprintf(stderr, "qemu: could not load prom '%s'\n",
buf);
exit(1);
}
kernel_size = 0;
if (linux_boot) {
kernel_size = load_elf(kernel_filename, -0xf0000000, NULL, NULL, NULL);
if (kernel_size < 0)
kernel_size = load_aout(kernel_filename, phys_ram_base + KERNEL_LOAD_ADDR);
if (kernel_size < 0)
kernel_size = load_image(kernel_filename, phys_ram_base + KERNEL_LOAD_ADDR);
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
kernel_filename);
exit(1);
}
initrd_size = 0;
if (initrd_filename) {
initrd_size = load_image(initrd_filename, phys_ram_base + INITRD_LOAD_ADDR);
if (initrd_size < 0) {
fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
initrd_filename);
exit(1);
}
}
if (initrd_size > 0) {
for (i = 0; i < 64 * TARGET_PAGE_SIZE; i += TARGET_PAGE_SIZE) {
if (ldl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i)
== 0x48647253) {
stl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i + 16, INITRD_LOAD_ADDR);
stl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i + 20, initrd_size);
break;
}
}
}
}
nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
boot_device, ram_size, kernel_size, graphic_width,
graphic_height, graphic_depth, machine_id);
}
| 1threat |
static int fourxm_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
FourxmDemuxContext *fourxm = s->priv_data;
ByteIOContext *pb = s->pb;
unsigned int fourcc_tag;
unsigned int size, out_size;
int ret = 0;
unsigned int track_number;
int packet_read = 0;
unsigned char header[8];
int audio_frame_count;
while (!packet_read) {
if ((ret = get_buffer(s->pb, header, 8)) < 0)
return ret;
fourcc_tag = AV_RL32(&header[0]);
size = AV_RL32(&header[4]);
if (url_feof(pb))
return AVERROR(EIO);
switch (fourcc_tag) {
case LIST_TAG:
fourxm->video_pts ++;
get_le32(pb);
break;
case ifrm_TAG:
case pfrm_TAG:
case cfrm_TAG:
case ifr2_TAG:
case pfr2_TAG:
case cfr2_TAG:
if (size + 8 < size || av_new_packet(pkt, size + 8))
return AVERROR(EIO);
pkt->stream_index = fourxm->video_stream_index;
pkt->pts = fourxm->video_pts;
pkt->pos = url_ftell(s->pb);
memcpy(pkt->data, header, 8);
ret = get_buffer(s->pb, &pkt->data[8], size);
if (ret < 0){
av_free_packet(pkt);
}else
packet_read = 1;
break;
case snd__TAG:
track_number = get_le32(pb);
out_size= get_le32(pb);
size-=8;
if (track_number < fourxm->track_count) {
ret= av_get_packet(s->pb, pkt, size);
if(ret<0)
return AVERROR(EIO);
pkt->stream_index =
fourxm->tracks[track_number].stream_index;
pkt->pts = fourxm->tracks[track_number].audio_pts;
packet_read = 1;
audio_frame_count = size;
if (fourxm->tracks[track_number].adpcm)
audio_frame_count -=
2 * (fourxm->tracks[track_number].channels);
audio_frame_count /=
fourxm->tracks[track_number].channels;
if (fourxm->tracks[track_number].adpcm){
audio_frame_count *= 2;
}else
audio_frame_count /=
(fourxm->tracks[track_number].bits / 8);
fourxm->tracks[track_number].audio_pts += audio_frame_count;
} else {
url_fseek(pb, size, SEEK_CUR);
}
break;
default:
url_fseek(pb, size, SEEK_CUR);
break;
}
}
return ret;
}
| 1threat |
Using App namespace in style : <p>I am going to give an example to demonstrate the greater point.</p>
<p>Imagine my app has a number of FloatingActionButtons. Consequently, I want to create one style and reuse it. So I do the following:</p>
<pre><code><style name="FabStyle” parent ="Widget.Design.FloatingActionButton">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_margin">16dp</item>
<item name="app:backgroundTint">@color/accent</item>
<item name="app:layout_anchorGravity">end|bottom</item>
</style>
</code></pre>
<p>The problem I am having is that the code is not compiling because it is complaining about</p>
<pre><code>Error:(40, 5) No resource found that matches the given name: attr 'app:backgroundTint'.
</code></pre>
<p>I tried bringing the namespace in through the <code>resources</code> tag but that is not working</p>
<pre><code><resources
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
>
</code></pre>
<p>Any ideas how I might get this to work?</p>
| 0debug |
Why can't a string be nil in Go? : <p>The program <a href="https://play.golang.org/p/2gLydmLeHf" rel="noreferrer">available on The Go Playground</a> reads</p>
<pre><code>package main
import "fmt"
func main() {
var name string = nil
fmt.Println(name)
}
</code></pre>
<p>and yields an error</p>
<pre><code>prog.go:6: cannot use nil as type string in assignment
</code></pre>
<p>I understand <a href="https://tour.golang.org/basics/12" rel="noreferrer"><code>""</code> is the "zero value" for strings</a>. I don't understand why I cannot assign <code>nil</code> to my <code>string</code>.</p>
| 0debug |
private messaging (Android) : <p>I am developing an android app, it is a social media app with many features. One of the features is a private messaging between users. What is the best way to do it.
Note: I'm using PHP for the backend of the app.</p>
| 0debug |
SEND EMAIL FROM GOOGLE SHEET AS A TABLE WITHOUT USING SHEET CONVERTER : Please check the spreadsheet below:
spreadsheethttps://docs.google.com/spreadsheets/d/1QFPO4bQfYPM4rRJ_6PYxUrYsFgVeUFx89_nZ1mNaLew/edit#gid=0
The script that I'm currently using is working fine thanks to the posts I've seen here. I just wanted to send it in a better way. I've already checked other posts and I even saw the SheetConverter but is too complicated for me.
Current Result:
https://drive.google.com/file/d/1-OQqnsRwIJaoXOnYZEtPxHy6r3buB8H7/view?usp=sharing
Please check image for the desired result. Thanks!
https://drive.google.com/file/d/1p7cJBTyaZ1ZqI5Jv5WWOGg6_Q-JegfHj/view?usp=sharing | 0debug |
static int ehci_state_executing(EHCIQueue *q)
{
EHCIPacket *p = QTAILQ_FIRST(&q->packets);
assert(p != NULL);
assert(p->qtdaddr == q->qtdaddr);
ehci_execute_complete(q);
if (!q->async) {
int transactCtr = get_field(q->qh.epcap, QH_EPCAP_MULT);
transactCtr--;
set_field(&q->qh.epcap, transactCtr, QH_EPCAP_MULT);
, bottom of page 82, should exit this state when transaction
}
if (p->usb_status == USB_RET_NAK) {
ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);
} else {
ehci_set_state(q->ehci, q->async, EST_WRITEBACK);
}
ehci_flush_qh(q);
return 1;
}
| 1threat |
How to update/display data (for example image) based on the time range in Swift? : For example I want the Image named "Something" to be displayed from 9:00 till 11:00. Then, Image will be changed, and a new Image "Something else" will be displayed from 11:00 till 13:00 and so on.
I found some related solutions : [here][1] and [here][2], but they have old syntax and a having a bit different purpose.
Could You help me please.
Thank You in advance.
[1]: http://stackoverflow.com/questions/38701071/swift-displaying-the-time-or-date-based-on-timestamp
[2]: http://stackoverflow.com/questions/37870076/how-to-display-an-alert-controller-when-nsdate-to-a-time-for-example-1200-a | 0debug |
AWS Codebuild puting all artifacts in root of S3 bucket : <p>I'm building a project that puts all of it's files in a 'dist' folder, and running it through CodeBuild. I'm trying to get it to put all of the files and folders in 'dist' into the root of the s3 bucket, but I'm having trouble figuring out how to make that work.</p>
<p>My 'dist' folder looks something like this:</p>
<p><code>
- index.html
- somecssfiles.css
- fonts/
- - some fonts or w/e
- js/
- - some javascript files
</code></p>
<p>I've tried a lot of different stuff, but can't seem to get it to just drop 'dist/*' into the root of the s3 bucket. Here's the current iteration of my <code>artifacts</code> property in the buildspec.yml file:</p>
<p><code>
artifacts:
files:
- '*'
discard-paths: yes
base-directory: 'dist'
</code></p>
<p>I thought that would probably work, but it ignores the folders. Any help is appreciated, thanks for reading.</p>
| 0debug |
i am trying to create a function with arguments and call it from another function in reactJS any help pls : errorLog(props){
if (props.errors) {
return (
<div className="alert alert-danger" role="alert">
<p>{props.message}</p>
</div>
)
}else{
return null
}
}
verifyUser(){
this.errorLog({errors: true, message: 'Sorry try something else'})
}
// this is my code but verifyUser wont work i dont know why that wont work any help pls | 0debug |
Python OOP sprite.Sprite.kill does really remove it : <p>I am using Python 2.7 and pygame to create Asteroid game using OOP and sprite class. I have a player and asteroids. When I detect a collision between a player and any asteroid using spritecollide, asteroid is removed from the group and I remove the player using kill. The player disappears from the screen but it is still there hidden. When another asteroid passes through where player used to be, it registers a collision and disappears as if player is still there. Is this the correct behavior? How do I remove the player from the game completely? Or do I just move it out of the game frame?</p>
| 0debug |
How to access class within class : <p>My question is how do you access "A_Numer", "A_String", "A_Property" from Class1.
(Whatever I try typing in Class1 I get 'type does not exist in current context' Which is funny, because everything is public.) Thank You!</p>
<pre><code>public class Class1
{
public class Class2
{
public int A_Number = 0;
public string A_String(int fdsa)
{
return "dssdaff";
}
public string A_Property { get; set; }
}
}
</code></pre>
| 0debug |
Posting on Facebook Page with video id : <p>What are the parameters to post on a Facebook page with an already uploaded video using Graph API. I have the video id.</p>
| 0debug |
Reading multiline ints using scnaf() in C form standard input : 5
3 2 3 1 2
input looks like this
1.first line is an int what tels how many ints will i get in the second line of input(the number is <=200)
2.Second line ints should be feeded into an int type array
| 0debug |
Randomly merge value of same coloumn in MSSQL : I have a table of Names and their genders like this,
+------------+----------+-------+
| id | name | gender|
+------------+----------+-------+
| 1 | James | M |
| 2 | Tom | M |
| 3 | Bill | M |
| 4 | Philip | M |
| 5 | Steve | M |
+------------+----------+-------+
And I want this result,
+------------+--------------------+
| id | name |
+------------+--------------------+
| 1 | James Steve |
| 2 | Tom Philip |
| 3 | Steve James |
| 4 | Bill Tom |
| 5 | Steve Tom |
+------------+--------------------+
It should pick any random name from the column and merge it with another value from same column. | 0debug |
static void spr_read_hdecr(DisasContext *ctx, int gprn, int sprn)
{
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_load_hdecr(cpu_gpr[gprn], cpu_env);
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_end();
gen_stop_exception(ctx);
}
}
| 1threat |
How to have an Event on setScene : How can I make a custom Event that triggers on `Stage.setScene()`?
In my code, the button switches the Scenes and that works fine. However I would like to extend the Stage to have an additional Event that is triggered when a button or possibly any other Element triggers a setScene.
Example:
```sql
package sample;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage stage) {
Group g1 = new Group();
Button b1 = new Button("2");
g1.getChildren().setAll(b1);
Scene scene1 = new Scene(g1, 50, 50);
Group g2 = new Group();
Button b2 = new Button("1");
g2.getChildren().setAll(b2);
Scene scene2 = new Scene(g2, 50, 50);
stage.setScene(scene1);
stage.setTitle("JavaFX Application Life Cycle");
b1.setOnAction(actionEvent -> {
System.out.println("1");
stage.setScene(scene2);
});
b2.setOnAction(actionEvent -> {
System.out.println("2");
stage.setScene(scene1);
});
stage.show();
}
}
| 0debug |
I get the error CS1061 in unity (are you missing a using directive or an assembly reference?) : <p>The error message was like this :
'GameObject' does not contain a definition for 'Transform' and no accessible extension method 'Transform' accepting a first argument of type 'GameObject' could be found (are you missing a using directive or an assembly reference?)</p>
<p>this is my code
(<a href="https://i.stack.imgur.com/VY6iZ.png" rel="nofollow noreferrer">https://i.stack.imgur.com/VY6iZ.png</a>)
.
.
This is my error message
(<a href="https://i.stack.imgur.com/oMvh1.png" rel="nofollow noreferrer">https://i.stack.imgur.com/oMvh1.png</a>)</p>
| 0debug |
static uint16_t shpc_get_status(SHPCDevice *shpc, int slot, uint16_t msk)
{
uint8_t *status = shpc->config + SHPC_SLOT_STATUS(slot);
return (pci_get_word(status) & msk) >> (ffs(msk) - 1);
}
| 1threat |
static void chroma_4mv_motion(MpegEncContext *s,
uint8_t *dest_cb, uint8_t *dest_cr,
uint8_t **ref_picture,
op_pixels_func *pix_op,
int mx, int my)
{
uint8_t *ptr;
int src_x, src_y, dxy, emu = 0;
ptrdiff_t offset;
mx = ff_h263_round_chroma(mx);
my = ff_h263_round_chroma(my);
dxy = ((my & 1) << 1) | (mx & 1);
mx >>= 1;
my >>= 1;
src_x = s->mb_x * 8 + mx;
src_y = s->mb_y * 8 + my;
src_x = av_clip(src_x, -8, (s->width >> 1));
if (src_x == (s->width >> 1))
dxy &= ~1;
src_y = av_clip(src_y, -8, (s->height >> 1));
if (src_y == (s->height >> 1))
dxy &= ~2;
offset = src_y * s->uvlinesize + src_x;
ptr = ref_picture[1] + offset;
if ((unsigned)src_x > FFMAX((s->h_edge_pos >> 1) - (dxy & 1) - 8, 0) ||
(unsigned)src_y > FFMAX((s->v_edge_pos >> 1) - (dxy >> 1) - 8, 0)) {
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr,
s->uvlinesize, s->uvlinesize,
9, 9, src_x, src_y,
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
ptr = s->edge_emu_buffer;
emu = 1;
}
pix_op[dxy](dest_cb, ptr, s->uvlinesize, 8);
ptr = ref_picture[2] + offset;
if (emu) {
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr,
s->uvlinesize, s->uvlinesize,
9, 9, src_x, src_y,
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
ptr = s->edge_emu_buffer;
}
pix_op[dxy](dest_cr, ptr, s->uvlinesize, 8);
}
| 1threat |
AttributeError: 'NoneType' object has no attribute 'loader' : <p>having an issue today when I started up my laptop (Ubuntu 18.4) and trying to use pip to install packages, I'm met with this error:</p>
<pre><code>Error processing line 3 of /home/cjones/.local/lib/python3.6/site-packages/googleapis_common_protos-1.5.8-py3.6-nspkg.pth:
Traceback (most recent call last):
File "/usr/lib/python3.6/site.py", line 174, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "<frozen importlib._bootstrap>", line 568, in module_from_spec
AttributeError: 'NoneType' object has no attribute 'loader'
Remainder of file ignored
</code></pre>
<p>I don't think I changed anything since last successful boot but it seems as though something is missing... can anyone help?</p>
| 0debug |
Replace a part of a word using c# : <p>I need to change the string "DT1OutPassFail" as "DT4OutPassFail". I need to find "DT1" in the input string and replace it with "DT4" to get the output string. I need to do this using c#. "DT1" is the value in textbox1 and "DT4" is the value in textbox2. I tried the following options. But it dosent work.</p>
<pre><code>string input = "DT1OutPassFail";
string newstring;
newstring = input.Replace(textbox1.Text, textbox2.Text);
newstring = Regex.Replace(input,textbox1.Text, textbox2.Text);
</code></pre>
| 0debug |
Java Getting values of 0 in Array When is not supposed to be 0 Help D: : So i have to make a beer pong game for my class but when i try to print out the values i inserted in the array cups1[#], cups2[#] they all come out as if i inserted a number 0 which i do not get because i do not have anything inserting a 0 into the array and every time i print i see lots of 0 s in the console. Each ball i insert in the cup has to have a number and that's why i want to print which ball went to which cup my cups are my cups array, i will add an for loop to print the numbers in array but as in right know i want to know why the array is only getting 0 s inserted. D:
this are my codes.
http://prntscr.com/n67ivn <---an image of my output,
public static void main(String[] args) {
int cups1[] = new int[9];
int cups2[] = new int[9];
int cup1=1;
int cup2=1;
int balls=1;
for(int i=0; i<1000; i++) {
int random = (int)(Math.random()*2);
if (random==0) {
cups1[cup1]=balls;
cup1++;
balls++;
System.out.println(cups1[cup1]);
}
if (random==1) {
cups2[cup2]=balls;
cup2++;
balls++;
System.out.println(cups2[cup2]);
}
if (cups1[0]>=1 && cups2[0]>=1) {
break;
}
}
}
} | 0debug |
Finding nth power of integer m through C program : C program to find nth power of integer m.
Input:
m=3 n=2
output:
9.000
---------END OF QUESTION---------------------
The question seems simple but i need to satisfy these additional test case as well.
1)For negative M
Input : -2 3
output : -8.000
2)For negative N
Input : 2 -3
output : 0.125000
3)For negative M and N
Input : -2 -3
output : -0.125000
However my below programs doesn't give correct output.
void main()
{
signed int m, n;
int i;
float p;
clrscr();
printf("Enter the number and its power (exponent)\n");
scanf("%d%d",&m,&n);
p=1;
if (n==0)
{
printf("%d raised to %d is: %f",m,n,p);
}
if (n>0)
{
for( i = 0 ; i < n ; i++ )
p*=m;
if(m>0)
printf("%d raised to %d is: %f",m,n,p);
if(m<0)
printf("%d raised to %d is: %f",m,n,-p);
}
if (n<0)
{
n=-n;
for( i = 0 ; i < n ; i++ )
p*=m;
if(m>0)
printf("%d raised to %d is: %f",m,-n,1/p);
if(m<0)
printf("%d raised to %d is: %f",m,-n,-(1/p));
}
getch();
}
Can u kindly provide the correct program for the test cases?
Also i cant declare signed float as it gives an error.
| 0debug |
errors occuring while compiling the code for histogram equalization : <p>I'm trying to implement my own Histogram equalization without using the library routine for histogram equalization in opencv c++ 2.4.13.2 version.
I compiled the program in terminal as follows:</p>
<pre><code>g++ `pkg-config --cflags opencv` histogram_Equalization.cpp `pkg-config --libs opencv` -o histeq
</code></pre>
<p>i'm getting the errors as given below:<a href="https://i.stack.imgur.com/DQU02.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DQU02.png" alt="errors"></a></p>
<p>Here is the code of mine:</p>
<pre><code>#include <opencv2/opencv.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/core/core.hpp>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
using namespace cv;
Mat *calculateHist(Mat &M, Mat &He)
{
float P[256]={0};
int i, j, k, r;
float sum = 0.0;
float T[256]={0};
int S[256]={0};
for(i=0;i<M.rows;i++)
{
for(j=0;j<M.cols;j++)
{
int tmp = M.at<uchar>(i,j);
P[tmp] = P[tmp] +1; //[(M.at<uchar>(i,j))] + 1;
}
}
for (i=0;i<M.rows;i++)
{
for(j=0;j<M.cols;j++)
{
sum = sum + P[(M.at<uchar>(i,j))];
}
}
//int num_pixel = (M.rows)*(M.cols)
for(i=0;i<256;i++)
{
P[i] = P[i]/(sum);
}
T[0] = P[0];
for( k=1; k<256;k++)
{
T[k] = T[k-1] + P[k];
}
for( r=0; r< 256; r++)
{
S[r] = cvRound(T[r]*255);
}
for(i=0;i<M.rows;i++)
{
for(j=0;j<M.cols;j++)
{
r = M.at<uchar>(i, j);
He.at<uchar>(i,j) = S[r];
}
}
return (&He);
}
int main(int argc, char *argv[])
{
Mat image = imread(argv[1],0);
Mat He(image.size,image.type);
He = calculateHist(image, He);
imshow("original_image", image);
imshow( "histogram_equalized", He );
waitKey(0);
return 0;
}
</code></pre>
| 0debug |
Andriod App using facebook Api : I am new to use Facebook API in andriod app.I m trying to access all public images from facebook using facebook api where user can get all pictures with given location from facebook.how it is possible
| 0debug |
Why is float('nan') not equal to itself in python : <pre><code>In [6]: a = float('nan')
In [7]: a == a
Out[7]: False
</code></pre>
<p>Why?</p>
| 0debug |
How to do it use switch statement? : I have a problem using switch statement when I tried to deal with a special situation. For example, I have 3 cases: A, B, C.
for A, I want to do statement_1 and statement_3.
for B, I want to do statement_2 and statement_3.
for C, I want to do nothing
if I use if-else statement, it will look like this:
if ( not Car){
do statement_3
if Bag
do statement 2
else if Apple
do statement 1
}
when i try to do it from switch statement im getting trouble
switch (variable){
case A: do statement_1
case B: do statement_2
// how to do statement 3 here?
}
| 0debug |
static void qemu_fill_buffer(QEMUFile *f)
{
int len;
int pending;
assert(!qemu_file_is_writable(f));
pending = f->buf_size - f->buf_index;
if (pending > 0) {
memmove(f->buf, f->buf + f->buf_index, pending);
}
f->buf_index = 0;
f->buf_size = pending;
len = f->ops->get_buffer(f->opaque, f->buf + pending, f->pos,
IO_BUF_SIZE - pending);
if (len > 0) {
f->buf_size += len;
f->pos += len;
} else if (len == 0) {
qemu_file_set_error(f, -EIO);
} else if (len != -EAGAIN) {
qemu_file_set_error(f, len);
}
}
| 1threat |
RTCState *rtc_init(int base_year)
{
ISADevice *dev;
dev = isa_create("mc146818rtc");
qdev_prop_set_int32(&dev->qdev, "base_year", base_year);
qdev_init(&dev->qdev);
return DO_UPCAST(RTCState, dev, dev);
}
| 1threat |
Difference between import React and import { Component } syntax : <p>Say, we are using React with ES6. We import React and Component as</p>
<pre><code>import React from 'react'
import { Component } from 'react'
</code></pre>
<p>Why the syntax difference? Can't we use as specified below?</p>
<pre><code>import Component from 'react'
</code></pre>
| 0debug |
static QObject *parse_array(JSONParserContext *ctxt, QList **tokens, va_list *ap)
{
QList *list = NULL;
QObject *token, *peek;
QList *working = qlist_copy(*tokens);
token = qlist_pop(working);
if (token == NULL) {
goto out;
}
if (!token_is_operator(token, '[')) {
goto out;
}
qobject_decref(token);
token = NULL;
list = qlist_new();
peek = qlist_peek(working);
if (peek == NULL) {
parse_error(ctxt, NULL, "premature EOI");
goto out;
}
if (!token_is_operator(peek, ']')) {
QObject *obj;
obj = parse_value(ctxt, &working, ap);
if (obj == NULL) {
parse_error(ctxt, token, "expecting value");
goto out;
}
qlist_append_obj(list, obj);
token = qlist_pop(working);
if (token == NULL) {
parse_error(ctxt, NULL, "premature EOI");
goto out;
}
while (!token_is_operator(token, ']')) {
if (!token_is_operator(token, ',')) {
parse_error(ctxt, token, "expected separator in list");
goto out;
}
qobject_decref(token);
token = NULL;
obj = parse_value(ctxt, &working, ap);
if (obj == NULL) {
parse_error(ctxt, token, "expecting value");
goto out;
}
qlist_append_obj(list, obj);
token = qlist_pop(working);
if (token == NULL) {
parse_error(ctxt, NULL, "premature EOI");
goto out;
}
}
qobject_decref(token);
token = NULL;
} else {
token = qlist_pop(working);
qobject_decref(token);
token = NULL;
}
QDECREF(*tokens);
*tokens = working;
return QOBJECT(list);
out:
qobject_decref(token);
QDECREF(working);
QDECREF(list);
return NULL;
}
| 1threat |
How to show uses of function in Visual Studio Code? : <p>I am used from Pycharm to be able to press ctrl + click on a function definition and see the uses. Is there an equivalent in VSC?</p>
| 0debug |
PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size,
ram_addr_t above_4g_mem_size)
{
PcGuestInfoState *guest_info_state = g_malloc0(sizeof *guest_info_state);
PcGuestInfo *guest_info = &guest_info_state->info;
guest_info->pci_info.w32.end = IO_APIC_DEFAULT_ADDRESS;
if (sizeof(hwaddr) == 4) {
guest_info->pci_info.w64.begin = 0;
guest_info->pci_info.w64.end = 0;
} else {
guest_info->pci_info.w64.begin =
ROUND_UP((0x1ULL << 32) + above_4g_mem_size, 0x1ULL << 30);
guest_info->pci_info.w64.end = guest_info->pci_info.w64.begin +
(0x1ULL << 62);
assert(guest_info->pci_info.w64.begin <= guest_info->pci_info.w64.end);
}
guest_info_state->machine_done.notify = pc_guest_info_machine_done;
qemu_add_machine_init_done_notifier(&guest_info_state->machine_done);
return guest_info;
}
| 1threat |
static target_ulong h_protect(PowerPCCPU *cpu, sPAPRMachineState *spapr,
target_ulong opcode, target_ulong *args)
{
CPUPPCState *env = &cpu->env;
target_ulong flags = args[0];
target_ulong pte_index = args[1];
target_ulong avpn = args[2];
uint64_t token;
target_ulong v, r, rb;
if (!valid_pte_index(env, pte_index)) {
return H_PARAMETER;
}
token = ppc_hash64_start_access(cpu, pte_index);
v = ppc_hash64_load_hpte0(cpu, token, 0);
r = ppc_hash64_load_hpte1(cpu, token, 0);
ppc_hash64_stop_access(token);
if ((v & HPTE64_V_VALID) == 0 ||
((flags & H_AVPN) && (v & ~0x7fULL) != avpn)) {
return H_NOT_FOUND;
}
r &= ~(HPTE64_R_PP0 | HPTE64_R_PP | HPTE64_R_N |
HPTE64_R_KEY_HI | HPTE64_R_KEY_LO);
r |= (flags << 55) & HPTE64_R_PP0;
r |= (flags << 48) & HPTE64_R_KEY_HI;
r |= flags & (HPTE64_R_PP | HPTE64_R_N | HPTE64_R_KEY_LO);
rb = compute_tlbie_rb(v, r, pte_index);
ppc_hash64_store_hpte(cpu, pte_index,
(v & ~HPTE64_V_VALID) | HPTE64_V_HPTE_DIRTY, 0);
ppc_tlb_invalidate_one(env, rb);
ppc_hash64_store_hpte(cpu, pte_index, v | HPTE64_V_HPTE_DIRTY, r);
return H_SUCCESS;
}
| 1threat |
How to launch the Hufmman Algorithm Haskell code? : I have founded some code of Huffman algorithm, bud don't know how to launch this. Some functions are working: for ex:
a = freqList "lol"
build list a
But how I can take the Huffman code of this string? encode and encode' functions use Bits argument.
Original code with comments:https://gist.github.com/kirelagin/3886243
module Huffman where
import Control.Arrow
import Data.List
import qualified Data.Map as M
import Data.Function
class Eq a => Bits a where
zer :: a
one :: a
instance Bits Int where
zer = 0
one = 1
instance Bits Bool where
zer = False
one = True
type Codemap a = M.Map Char [a]
data HTree = Leaf Char Int
| Fork HTree HTree Int
deriving (Show)
weight :: HTree -> Int
weight (Leaf _ w) = w
weight (Fork _ _ w) = w
merge t1 t2 = Fork t1 t2 (weight t1 + weight t2)
freqList :: String -> [(Char, Int)]
freqList = M.toList . M.fromListWith (+) . map (flip (,) 1)
buildTree :: [(Char, Int)] -> HTree
buildTree = bld . map (uncurry Leaf) . sortBy (compare `on` snd)
where bld (t:[]) = t
bld (a:b:cs) = bld $ insertBy (compare `on` weight) (merge a b) cs
buildCodemap :: Bits a => HTree -> Codemap a
buildCodemap = M.fromList . buildCodelist
where buildCodelist (Leaf c w) = [(c, [])]
buildCodelist (Fork l r w) = map (addBit zer) (buildCodelist l) ++ map (addBit one) (buildCodelist r)
where addBit b = second (b :)
stringTree :: String -> HTree
stringTree = buildTree . freqList
stringCodemap :: Bits a => String -> Codemap a
stringCodemap = buildCodemap . stringTree
encode :: Bits a => Codemap a -> String -> [a]
encode m = concat . map (m M.!)
encode' :: Bits a => HTree -> String -> [a]
encode' t = encode $ buildCodemap t
decode :: Bits a => HTree -> [a] -> String
decode tree = dcd tree
where dcd (Leaf c _) [] = [c]
dcd (Leaf c _) bs = c : dcd tree bs
dcd (Fork l r _) (b:bs) = dcd (if b == zer then l else r) bs | 0debug |
static void char_socket_finalize(Object *obj)
{
Chardev *chr = CHARDEV(obj);
SocketChardev *s = SOCKET_CHARDEV(obj);
tcp_chr_free_connection(chr);
if (s->reconnect_timer) {
g_source_remove(s->reconnect_timer);
s->reconnect_timer = 0;
}
qapi_free_SocketAddressLegacy(s->addr);
if (s->listen_tag) {
g_source_remove(s->listen_tag);
s->listen_tag = 0;
}
if (s->listen_ioc) {
object_unref(OBJECT(s->listen_ioc));
}
if (s->tls_creds) {
object_unref(OBJECT(s->tls_creds));
}
qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
}
| 1threat |
Firebase stop listening onAuthStateChanged : <p>As of version ^3.0.0, I'm having a difficult time removing the auth state change listener. </p>
<p>To start the listener per the documentation: </p>
<pre><code>firebase.auth().onAuthStateChanged(function (user) {
// handle it
});
</code></pre>
<p>However, I cannot find anywhere in the documentation that refers to a remove auth state change listener. There is peculiar function on the Firebase.Auth class called <code>removeAuthTokenListener</code>. Unfortunately it's not documented (<a href="https://firebase.google.com/docs/reference/js/index-all" rel="noreferrer">firebase docs reference</a>). </p>
<p>Via your browser's web console. </p>
<pre><code>var auth = firebase.auth();
auth.removeAuthTokenListener;
</code></pre>
<p>prints a function definition that takes one parameter. I tried to do the following:</p>
<pre><code>this.authListener = firebase.auth().onAuthStateChanged(function (user) {...});
firebase.auth().removeAuthTokenListener(this.authListener);
</code></pre>
<p>but that didn't do anything. </p>
| 0debug |
Overloading structs with template call operator and generic lambdas - gcc vs clang : <p>I have discovered a code snippet that compiles and works properly in <strong>clang++ 4 (and trunk)</strong> but fails to compile in <strong>g++ 7 (and trunk)</strong>. Let's assume I have the following <code>struct</code> types:</p>
<pre><code>struct a { void foo() { } };
struct b { void bar() { } };
struct c { void bar() { } };
</code></pre>
<p>I want to create an <em>overload set</em> out of lambdas which handles <code>a</code> explicitly, while <code>b</code> and <code>c</code> are "caught" with a generic lambda using an <code>auto</code> parameter:</p>
<pre><code>auto ol = overload([](a x) { x.foo(); },
[](auto x){ x.bar(); })
</code></pre>
<p>When I invoke <code>ol(a{})</code>:</p>
<ul>
<li><p><strong>clang++</strong> compiles and behaves as expected: <code>a</code> "matches" the first lambda, while <code>b</code> and <code>c</code> match the second one.</p></li>
<li><p><strong>g++</strong> fails to compile, with the following error:</p>
<pre><code>error: 'struct a' has no member named 'bar'
[](auto x){ x.bar(); };
~~^~~
</code></pre>
<p>It seems that the compiler tries to instantiate the second lambda even though the first one is a way better match. Hopefully this is a bug, as it seems unintuitive to me.</p></li>
</ul>
<hr>
<p>Note both compilers work properly if instead of <em>lambda expressions</em> I use some old-fashioned <code>struct</code> instances:</p>
<pre><code>struct s0
{
auto operator()(a x) const { x.foo(); }
};
struct s1
{
template <typename T>
auto operator()(T x) const { x.bar(); }
};
auto os = overload(s0{}, s1{});
os(a{}); // OK!
</code></pre>
<p>I would expect the lambdas to be roughly equivalent to <code>s0</code> and <code>s1</code>, so this is even more surprising.</p>
<hr>
<p>This is the way I'm producing the overload set:</p>
<pre><code>template <typename... Fs>
struct overloader : Fs...
{
template <typename... FFwds>
overloader(FFwds&&... fs) : Fs{std::forward<FFwds>(fs)}...
{
}
using Fs::operator()...;
};
template <typename... Fs>
auto overload(Fs&&... fs)
{
return overloader<std::decay_t<Fs>...>{std::forward<Fs>(fs)...};
}
</code></pre>
<p>And here's a <a href="https://godbolt.org/g/maHfcb" rel="noreferrer"><strong>live example on <code>gcc.godbolt.org</code></strong></a>, showing the different behavior between the compilers.</p>
<hr>
<p><strong>Is this a g++ bug?</strong> Or is there something in the standard that makes lambdas behave differently from <code>struct</code> instances in this situation?</p>
| 0debug |
static void update_stream_timings(AVFormatContext *ic)
{
int64_t start_time, start_time1, start_time_text, end_time, end_time1;
int64_t duration, duration1, filesize;
int i;
AVStream *st;
AVProgram *p;
start_time = INT64_MAX;
start_time_text = INT64_MAX;
end_time = INT64_MIN;
duration = INT64_MIN;
for(i = 0;i < ic->nb_streams; i++) {
st = ic->streams[i];
if (st->start_time != AV_NOPTS_VALUE && st->time_base.den) {
start_time1= av_rescale_q(st->start_time, st->time_base, AV_TIME_BASE_Q);
if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE || st->codec->codec_type == AVMEDIA_TYPE_DATA) {
if (start_time1 < start_time_text)
start_time_text = start_time1;
} else
start_time = FFMIN(start_time, start_time1);
end_time1 = AV_NOPTS_VALUE;
if (st->duration != AV_NOPTS_VALUE) {
end_time1 = start_time1
+ av_rescale_q(st->duration, st->time_base, AV_TIME_BASE_Q);
end_time = FFMAX(end_time, end_time1);
}
for(p = NULL; (p = av_find_program_from_stream(ic, p, i)); ){
if(p->start_time == AV_NOPTS_VALUE || p->start_time > start_time1)
p->start_time = start_time1;
if(p->end_time < end_time1)
p->end_time = end_time1;
}
}
if (st->duration != AV_NOPTS_VALUE) {
duration1 = av_rescale_q(st->duration, st->time_base, AV_TIME_BASE_Q);
duration = FFMAX(duration, duration1);
}
}
if (start_time == INT64_MAX || (start_time > start_time_text && start_time - start_time_text < AV_TIME_BASE))
start_time = start_time_text;
else if(start_time > start_time_text)
av_log(ic, AV_LOG_VERBOSE, "Ignoring outlier non primary stream starttime %f\n", start_time_text / (float)AV_TIME_BASE);
if (start_time != INT64_MAX) {
ic->start_time = start_time;
if (end_time != INT64_MIN) {
if (ic->nb_programs) {
for (i=0; i<ic->nb_programs; i++) {
p = ic->programs[i];
if(p->start_time != AV_NOPTS_VALUE && p->end_time > p->start_time)
duration = FFMAX(duration, p->end_time - p->start_time);
}
} else
duration = FFMAX(duration, end_time - start_time);
}
}
if (duration != INT64_MIN && duration > 0 && ic->duration == AV_NOPTS_VALUE) {
ic->duration = duration;
}
if (ic->pb && (filesize = avio_size(ic->pb)) > 0 && ic->duration != AV_NOPTS_VALUE) {
ic->bit_rate = (double)filesize * 8.0 * AV_TIME_BASE /
(double)ic->duration;
}
}
| 1threat |
Find white spaces in the string using RegExp : <pre><code>/route/some pic name.jpg
</code></pre>
<p>I need to find all white spaces beetwen <code>route/</code> and <code>.jpg</code> using RexExp. </p>
| 0debug |
static void usb_net_handle_destroy(USBDevice *dev)
{
USBNetState *s = (USBNetState *) dev;
qemu_del_vlan_client(s->vc);
rndis_clear_responsequeue(s);
qemu_free(s);
}
| 1threat |
static int host_pci_config_read(int pos, int len, uint32_t val)
{
char path[PATH_MAX];
int config_fd;
ssize_t size = sizeof(path);
int rc = snprintf(path, size, "/sys/bus/pci/devices/%04x:%02x:%02x.%d/%s",
0, 0, 0, 0, "config");
if (rc >= size || rc < 0) {
return -ENODEV;
}
config_fd = open(path, O_RDWR);
if (config_fd < 0) {
return -ENODEV;
}
if (lseek(config_fd, pos, SEEK_SET) != pos) {
return -errno;
}
do {
rc = read(config_fd, (uint8_t *)&val, len);
} while (rc < 0 && (errno == EINTR || errno == EAGAIN));
if (rc != len) {
return -errno;
}
return 0;
}
| 1threat |
static void smc91c111_receive(void *opaque, const uint8_t *buf, size_t size)
{
smc91c111_state *s = (smc91c111_state *)opaque;
int status;
int packetsize;
uint32_t crc;
int packetnum;
uint8_t *p;
if ((s->rcr & RCR_RXEN) == 0 || (s->rcr & RCR_SOFT_RST))
return;
if (size < 64)
packetsize = 64;
else
packetsize = (size & ~1);
packetsize += 6;
crc = (s->rcr & RCR_STRIP_CRC) == 0;
if (crc)
packetsize += 4;
if (packetsize > 2048)
return;
packetnum = smc91c111_allocate_packet(s);
if (packetnum == 0x80)
return;
s->rx_fifo[s->rx_fifo_len++] = packetnum;
p = &s->data[packetnum][0];
status = 0;
if (size > 1518)
status |= RS_TOOLONG;
if (size & 1)
status |= RS_ODDFRAME;
*(p++) = status & 0xff;
*(p++) = status >> 8;
*(p++) = packetsize & 0xff;
*(p++) = packetsize >> 8;
memcpy(p, buf, size & ~1);
p += (size & ~1);
if (size < 64) {
int pad;
if (size & 1)
*(p++) = buf[size - 1];
pad = 64 - size;
memset(p, 0, pad);
p += pad;
size = 64;
}
if (crc) {
crc = crc32(~0, buf, size);
*(p++) = crc & 0xff; crc >>= 8;
*(p++) = crc & 0xff; crc >>= 8;
*(p++) = crc & 0xff; crc >>= 8;
*(p++) = crc & 0xff; crc >>= 8;
}
if (size & 1) {
*(p++) = buf[size - 1];
*(p++) = 0x60;
} else {
*(p++) = 0;
*(p++) = 0x40;
}
s->int_level |= INT_RCV;
smc91c111_update(s);
}
| 1threat |
PROTO4(_pack_2ch_)
PROTO4(_pack_6ch_)
PROTO4(_unpack_2ch_)
av_cold void swri_audio_convert_init_x86(struct AudioConvert *ac,
enum AVSampleFormat out_fmt,
enum AVSampleFormat in_fmt,
int channels){
int mm_flags = av_get_cpu_flags();
ac->simd_f= NULL;
#define MULTI_CAPS_FUNC(flag, cap) \
if (mm_flags & flag) {\
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S16 || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16P)\
ac->simd_f = ff_int16_to_int32_a_ ## cap;\
if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S32P)\
ac->simd_f = ff_int32_to_int16_a_ ## cap;\
}
MULTI_CAPS_FUNC(AV_CPU_FLAG_MMX, mmx)
MULTI_CAPS_FUNC(AV_CPU_FLAG_SSE2, sse2)
if(mm_flags & AV_CPU_FLAG_MMX) {
if(channels == 6) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_6ch_float_to_float_a_mmx;
}
}
if(mm_flags & AV_CPU_FLAG_SSE2) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_int32_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S16 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16P)
ac->simd_f = ff_int16_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_float_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_float_to_int16_a_sse2;
if(channels == 2) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_2ch_int32_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_S16P)
ac->simd_f = ff_pack_2ch_int16_to_int16_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S16P)
ac->simd_f = ff_pack_2ch_int16_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_2ch_int32_to_int16_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S32)
ac->simd_f = ff_unpack_2ch_int32_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_int16_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S32)
ac->simd_f = ff_unpack_2ch_int32_to_int16_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_2ch_int32_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_pack_2ch_float_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S16P)
ac->simd_f = ff_pack_2ch_int16_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_pack_2ch_float_to_int16_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32)
ac->simd_f = ff_unpack_2ch_int32_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLT)
ac->simd_f = ff_unpack_2ch_float_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLT)
ac->simd_f = ff_unpack_2ch_float_to_int16_a_sse2;
}
}
if(mm_flags & AV_CPU_FLAG_SSSE3) {
if(channels == 2) {
if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_int16_a_ssse3;
if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_int32_a_ssse3;
if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_float_a_ssse3;
}
}
if(mm_flags & AV_CPU_FLAG_SSE4) {
if(channels == 6) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_6ch_float_to_float_a_sse4;
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_6ch_int32_to_float_a_sse4;
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_pack_6ch_float_to_int32_a_sse4;
}
}
if(HAVE_AVX_EXTERNAL && mm_flags & AV_CPU_FLAG_AVX) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_int32_to_float_a_avx;
if(channels == 6) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_6ch_float_to_float_a_avx;
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_6ch_int32_to_float_a_avx;
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_pack_6ch_float_to_int32_a_avx;
}
}
}
| 1threat |
How come I don't see any spaces between words on my website using Internet Explorer on Windows? : <p>When I click inspect element, I see spaces between words. But when the html is rendered on the web page, I see no spaces between words, like "thebestvrexperience"</p>
| 0debug |
Why Does Every Letter in my String get Replaced Instead of Vowels? : <p>I have the following code:</p>
<pre><code>def replace_vowel(text):
text = list(text)
for i in range(0, len(text)):
if text[i] == 'A' or 'a' or 'E' or 'e' or 'I' or 'i' or 'O' or 'o' or 'U' or 'u':
text[i] = ''
print ''.join(text)
return ''.join(text)
replace_vowel("HeylookWords!")
</code></pre>
<p>The code is supposed to replace every vowel, but instead, every letter gets replaced with ''. Why does this happen? </p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.