problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
Site URL is re-directing to local server URL after remote database import and file upload via FTP : I dropped my remote database in order to import a new one and, at the same time, re-uploaded my wordpress woocommerce site via FTP (File Zilla).
The problem is that my live site (www.site.com) is now re-directing to my local URL (www.site.dev.cc)
Does anyone have any idea how to fix this? I changed site URL in wp_settings in the remote database to www.site.com but that doesn't seem to have helped.
Any ideas welcome! | 0debug |
Cannot import an andriod code sample in Andriod Studio : I am trying to import an Andriod Code Sample using the Andrio Studio.
But i get this error. Please suggest the cause or whats missing.
[enter image description here][1]
Thanks,
Asha
[1]: http://i.stack.imgur.com/BsJ3v.jpg | 0debug |
Each row sharey individually? : <p>I have a two-by-two plot that I am creating dynamically. In the first row I want to plot density functions, in the second row CDFs. I want </p>
<ul>
<li>each of the columns to share x</li>
<li>each of the rows to share y</li>
</ul>
<p>That is, two objects aligned vertically have the same x-axis, and two plots aligned horizontally have the same y-axis.</p>
<p>However, <code>sharex</code> and <code>sharey</code> force them to be the same for all of the subplots. How can I fix this sort of axes sharing? I understand that I could be manually giving each axes a share partner, but that wouldn't work with the generic structure that follows: </p>
<pre><code>fig, axes = plt.subplots(nrows=2, ncols=2, sharex=True)
for i, lam in enumerate(lams):
axesNow = [axs[i] for axs in axes] # pick the ith column from axes
for i, Param.p in enumerate(pp):
axesNow[0].plot(somethingWithPDF)
axesNow[1].plot(somethingWithCDF)
for ax in axes.flatten(): ax.legend()
</code></pre>
<p><a href="https://i.stack.imgur.com/7SxTV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7SxTV.png" alt="enter image description here"></a></p>
| 0debug |
how can i remove the extra bottom tab bar created in my tabs page : i'm using xcode and swift to create an iOS app.now i want to create a side bar menu using swreveale framework and i try to add it in one of of bottom tabs pages but when i switch to that tab i have an extra space of bottom tab and i cant remove it.can anyone help?
http://s9.picofile.com/file/8305617242/Screen_Shot_1396_06_14_at_16_23_27.png
i mean this black tab above of home tab
thanks! | 0debug |
Java Optional if object is not null - returns the method result, if null - returns default value : <p>Is it possible to transform this code to java 8 Optional one-line expression?</p>
<pre><code>long lastPollTime;
if (object != null) {
lastPollTime = object.getTime();
} else {
lastPollTime = 0;
}
</code></pre>
<p>i.e. if some object is not null, I need to call object method and return its result, or else return 0.
Optional.ofNullable().orElse() is not suitable, as it returns the object of the same type, but i need the result of method call or some default value. </p>
| 0debug |
Mongo service start or restart always fail : <p>I've installed mongodb then I've created a mongo service: </p>
<pre><code> [Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
[Install]
WantedBy=multi-user.target
</code></pre>
<p>But When I launch the service and then I check the status, I get always this error:</p>
<pre><code>● mongodb.service - High-performance, schema-free document-oriented database
Loaded: loaded (/etc/systemd/system/mongodb.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2017-04-24 13:08:55 UTC; 6min ago
Process: 1094 ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf (code=exited, status=48)
Main PID: 1094 (code=exited, status=48)
Apr 24 13:08:54 ip-172-31-37-163 systemd[1]: Started High-performance, schema-free document-oriented database.
Apr 24 13:08:55 ip-172-31-37-163 systemd[1]: mongodb.service: Main process exited, code=exited, status=48/n/a
Apr 24 13:08:55 ip-172-31-37-163 systemd[1]: mongodb.service: Unit entered failed state.
Apr 24 13:08:55 ip-172-31-37-163 systemd[1]: mongodb.service: Failed with result 'exit-code'.
</code></pre>
| 0debug |
static void io_watch_poll_finalize(GSource *source)
{
IOWatchPoll *iwp = io_watch_poll_from_source(source);
g_source_destroy(iwp->src);
g_source_unref(iwp->src);
iwp->src = NULL;
}
| 1threat |
static void vp8_decode_flush_impl(AVCodecContext *avctx, int force, int is_close)
{
VP8Context *s = avctx->priv_data;
int i;
if (!avctx->is_copy || force) {
for (i = 0; i < 5; i++)
if (s->frames[i].data[0])
vp8_release_frame(s, &s->frames[i], is_close);
}
memset(s->framep, 0, sizeof(s->framep));
free_buffers(s);
s->maps_are_invalid = 1;
}
| 1threat |
static int32_t ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
IDEState *s = &ad->port.ifs[0];
if (ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset) == -1) {
DPRINTF(ad->port_no, "ahci_dma_prepare_buf failed.\n");
return -1;
}
s->io_buffer_size = s->sg.size;
DPRINTF(ad->port_no, "len=%#x\n", s->io_buffer_size);
return s->io_buffer_size;
}
| 1threat |
Can you please help me find a problem in my code? : Im trying to do homework for my IT classes and we just started programming a bit. We have 2 classes, Main and Okej. It is just a simple code where the getters and setters have to check if the user input the right number. But the IF statements just do not work. Can you please help?
package okej;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner program = new Scanner(System.in);
System.out.println("Please, type your Name.");
String name = program.nextLine();
System.out.println("Please, type your age.");
int age = program.nextInt();
System.out.println("Please, type your weight.");
double weight = program.nextDouble();
Okej you = new Okej(name, age, weight);
System.out.print(you);
}
}
----------------------------------------------------------------------
package okej;
import java.util.Scanner;
public class Okej {
String name = "";
int age = 0;
double weight = 0.0;
public Okej(String name, int age, double weight) {
this.name = name;
this.age = age;
this.weight = weight;
}
public String getName() {
return name;
}
public void setName(String name) {
System.out.println("Okay, your name is " + name + ".");
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
if (age > 18) {
if (age < 99) {
this.age = age;
System.out.println("Okay, your age is " + age + ".");
}
}
else {
System.out.println("You have put an invalid age for this program.");
System.out.println("Setting the number to 20.");
this.age = 20;
}
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
if (weight > 30) {
if (weight < 300) {
this.weight = weight;
System.out.println("Okay, your weight is " + weight + ".");
}
}
else {
System.out.println("You have put an invalid weight for this program.");
System.out.println("Setting the number to 50.");
this.weight = 50;
}
}
@Override
public String toString() {
return "Okay, your name is " + name + ", your age is " + age + ", and you weight "+ weight +".";
}
} | 0debug |
How to prevent first/last bars from being cut off in a chart with time scale : <p>How do I prevent the first and last bars from being cut off (showing half)?</p>
<p>I need to show the short month names on the x-axis. I've tried playing around with various min/max settings, but I can't seem to get it right.</p>
<p><a href="https://i.stack.imgur.com/qWwkI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/qWwkI.png" alt="Example"></a></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var graphData = {
dates: [
'2016-06-01',
'2016-07-01',
'2016-08-01',
'2016-09-01',
'2016-10-01',
'2016-11-01',
'2016-12-01',
'2017-01-01',
'2017-02-01',
'2017-03-01',
'2017-04-01',
'2017-05-01'
],
wins: [23, 5, 13, 24, 8, 11, 23, 5, 13, 24, 8, 11],
draws: [2, 1, 2, 0, 2, 2, 3, 1, 2, 4, 0, 1],
losses: [3, 1, 2, 10, 8, 8, 3, 1, 2, 10, 8, 8],
winRates: [50, 40, 72, 30, 46, 80, 50, 40, 72, 30, 46, 80]
};
var winsMax = Math.max.apply(Math, graphData.wins);
var lossesMax = Math.max.apply(Math, graphData.losses);
var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
type: "bar",
data: {
labels: graphData.dates.map((date) => moment(date)),
datasets: [
{
type: "bar",
backgroundColor: "green",
hoverBackgroundColor: "green",
data: graphData.wins,
yAxisID: "winsAndLosses"
},
{
type: "bar",
backgroundColor: "red",
hoverBackgroundColor: "red",
data: graphData.losses.map((i) => -i),
yAxisID: "winsAndLosses"
},
{
type: "line",
data: graphData.winRates,
fill: true,
backgroundColor: "gray",
pointRadius: 0,
pointHoverRadius: 0,
yAxisID: "winRate"
}
]
},
options: {
legend: {
display: false
},
scales: {
xAxes: [{
type: "time",
time: {
unit: "month",
displayFormats: {
month: "MMM"
}
},
stacked: true,
gridLines: {
display: false
},
ticks: {
callback: (label) => label.toUpperCase(),
fontSize: 10
}
}],
yAxes: [
{
id: "winsAndLosses",
stacked: true,
ticks: {
min: (lossesMax + 10) * -1,
max: winsMax + 10,
callback: (label) => Math.abs(label) // TODO: Localization (number formatting).
},
display: false
},
{
id: "winRate",
ticks: {
min: 0,
max: 100,
stepSize: 10,
callback: (label) => label + "%", // TODO: Localization (number formatting).
fontSize: 10
}
}
]
}
}
});</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>.myChartDiv {
max-width: 800px;
max-height: 400px;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://npmcdn.com/chart.js@latest/dist/Chart.bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
<html>
<body>
<div class="myChartDiv">
<canvas id="myChart" width="800" height="400"></canvas>
</div>
</body>
</html></code></pre>
</div>
</div>
</p>
| 0debug |
What is the difference between watchOptions.ignored and webpack.WatchIgnorePlugin : <p>When using webpack with watch, such as when using <code>webpack-dev-server</code> there seem to be (at least) two different ways of excluding files from watching. I can't really find any documentation on the difference between these two configurations and why they are different. Does anyone know why? Is one method preferred? Should I open an issue and/or pull request to improve documentation?</p>
<p>The case I recently ran into where watch was being triggered multiple times on first run was fixed by adding <code>watchIgnorePlugin</code> and not fixed by <code>watchOptions.ignored</code></p>
<h3>webpack.WatchIgnorePlugin</h3>
<blockquote>
<p>Ignore the specified files, i.e. those matching the provided paths or regular expressions, while in watch mode.</p>
<pre><code>new webpack.WatchIgnorePlugin(paths)
</code></pre>
<p><strong>Options</strong></p>
<ul>
<li>paths (array): A list of RegExps or absolute paths to directories or'
files that should be ignored.</li>
</ul>
<hr>
<p><a href="https://webpack.js.org/plugins/watch-ignore-plugin/" rel="noreferrer">https://webpack.js.org/plugins/watch-ignore-plugin/</a></p>
</blockquote>
<h3>watchOptions.ignored</h3>
<blockquote>
<p>For some systems, watching many file systems can result in a lot of CPU or
memory usage. It is possible to exclude a huge folder like <code>node_modules</code>:</p>
<pre><code> ignored: /node_modules/
</code></pre>
<p>It is also possible to use <a href="https://github.com/es128/anymatch" rel="noreferrer">anymatch</a> patterns:</p>
<pre><code> ignored: "files/**/*.js"
</code></pre>
<hr>
<p><a href="https://webpack.js.org/configuration/watch/" rel="noreferrer">https://webpack.js.org/configuration/watch/</a></p>
</blockquote>
| 0debug |
VBA - Select filtering and applying quantity amount to listed percentages : I tried to search but didn't find anything that was exact to what I was looking for. Let's say that I have the Investment$$ and I want to allocate that amount to only Items = to Toy Story and where Character begins with TS. The Investment $$ should only be applied to "Toy Story" and where character begins with "TS".
Apologies on not being able to embed the pictorial example to this message.
I need to write this in VBA. My questions is, is the best way to do this through a vlookup (programmed via VBA)? I want to avoid having the $1000 applied to the wrong movie title and even when it is applied to the right one (Toy Story) I want to make sure it's applied to the right ("TS") ones.
I'll also experiment on my end as well.
Thanks for any advice.
[Pixar Movie Example][1]
[1]: https://i.stack.imgur.com/oxfvz.png | 0debug |
Unfortunately app has stopped. when run on real device : <p><strong>When i run Contact List Project at that time it occurs.</strong> I do not know why it occurs please help.</p>
| 0debug |
Read-only Slack channel : <p>Is it possible to configure a Slack channel to be public but read-only for all and only e.g. Jenkins user can write messages in it?</p>
<p><em>(Apologies if it is off-topic for SO)</em></p>
| 0debug |
Opacity of div container affecting child : <p>I have a container with a background and opacity set. In it, I have a child. I want the child to appear to be on top of the container, but it isn't, the opacity affects the child. </p>
<p><a href="https://i.stack.imgur.com/1wvdu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1wvdu.png" alt="enter image description here"></a></p>
<p>Here's the HTML</p>
<pre><code><div class="container">
<div class="child">some label</div>
</div>
</code></pre>
<p>And CSS:</p>
<pre><code>.container {
position: absolute;
top: 0;
width: 200px;
height: 200px;
opacity: 0.5;
background-color: lightblue;
z-index: 10;
</code></pre>
<p>}</p>
<pre><code>.child {
position: absolute;
right: 0;
bottom: 0;
}
</code></pre>
<p>For other reasons, the container must have a position of absolute. </p>
<p>The jsfiddle is <a href="https://jsfiddle.net/jv0tt5rz/1/" rel="nofollow noreferrer">here</a>.</p>
<p>How can I avoid the opacity of the container affecting the child?</p>
| 0debug |
class Pair(object):
def __init__(self, a, b):
self.a = a
self.b = b
def max_chain_length(arr, n):
max = 0
mcl = [1 for i in range(n)]
for i in range(1, n):
for j in range(0, i):
if (arr[i].a > arr[j].b and
mcl[i] < mcl[j] + 1):
mcl[i] = mcl[j] + 1
for i in range(n):
if (max < mcl[i]):
max = mcl[i]
return max | 0debug |
Not able to run the application : Not able to run the application.
Get Error:
The remote Debugger was unable to locate a resource dll (vsdebugeng.impl.resources.dll). please ensure that the complete remote debugger folder was copied or installed on the target computer. | 0debug |
long to wide format aggregate R tidyverse : <p>Hi given the following dataframe</p>
<pre><code>library(tidyverse)
df <- data.frame(READS=rep(c('READa', 'READb', 'READc'),each=3) ,GENE=rep(c('GENEa', 'GENEb', 'GENEc'), each=3), COMMENT=rep(c('CommentA', 'CommentA', 'CommentA'),each=3))
> df
READS GENE COMMENT
1 READa GENEa CommentA
2 READa GENEa CommentA
3 READa GENEa CommentA
4 READb GENEb CommentA
5 READb GENEb CommentA
6 READb GENEb CommentA
7 READc GENEc CommentA
8 READc GENEc CommentA
9 READc GENEc CommentA
</code></pre>
<p>I want to convert from long to wide format aggregating by Gene Column so that i get the following</p>
<pre><code> GENEa GENEb GENEc
READSa 3 3 3
READSb 3 3 3
</code></pre>
<p>I have tried with no success:</p>
<pre><code> library(tidyverse)
df %>%
group_by(GENE) %>%
select(-COMMENT) %>%
spread(READS)
</code></pre>
<p>Note that the original dataframe is huge so any optimized code would help.</p>
<p>Thanks for your help.</p>
| 0debug |
Array.map() produces '[T]', not the expected contextual result type '[String: Any?]' : <p>I'm writing an extension to bridge the dictionary values between FirebaseDatabase and <a href="https://github.com/xmartlabs/Eureka" rel="noreferrer">Eureka</a>.</p>
<pre><code>private extension Dictionary {
func firebaseFriendlyDictionary() -> [String: Any?] {
return self.map({ (key: String, value: Any?) -> (String, Any?) in
if value is NSDate {
return (key, (value as! NSDate).timeIntervalSince1970)
}
return (key, value)
})
}
}
</code></pre>
<p>But I get thrown this error when I try to build:</p>
<p><code>map produces '[T]', not the expected contextual result type '[String: Any?]'</code></p>
| 0debug |
Can a normal variable hold address of another varibale? : My problem is quite crazy, but listen i created two normal variable just like this int a,b and then i assigned the address of b variable to the a and when i print the address of both a and &b it show a random number but same for both.
how it is possible?
while a is not a pointer variable.
int main()
{
int a,b;
a = &b;
printf("%u %u",a,&b);
return 0;
}
i got a number that must be address.and both are same. | 0debug |
Undefined symbols for architecture i386: _FlutterMethodNotImplemented : <p>I am trying to run my flutter app on ios simulator which has few plugins such as connectivity, flutter_webview, fluttertoast etc.
When I am trying to run these I am getting following error on all of these plugins.</p>
<pre><code>Undefined symbols for architecture i386:
"_FlutterMethodNotImplemented", referenced from:
-[FluttertoastPlugin handleMethodCall:result:] in FluttertoastPlugin.o
"_OBJC_CLASS_$_FlutterMethodChannel", referenced from:
objc-class-ref in FluttertoastPlugin.o
</code></pre>
<p>Things are running smoothly on android.</p>
<p>I have tried</p>
<pre><code>flutter clean
pod install
</code></pre>
<p>Still the error persists.
Anyone facing similar error? If anyone has solution to this please help me with this. Thanks</p>
<p>flutter doctor -v output </p>
<pre><code>[✓] Flutter (Channel beta, v0.11.9, on Mac OS X 10.14.1 18B75, locale en-IN)
• Flutter version 0.11.9 at /Users/vipin/Downloads/soft/flutter
• Framework revision d48e6e433c (5 days ago), 2018-11-20 22:05:23 -0500
• Engine revision 5c8147450d
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
• Android SDK at /Users/vipin/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = /Users/vipin/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
• All Android licenses accepted.
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.1, Build version 10B61
• ios-deploy 1.9.4
• CocoaPods version 1.5.3
[✓] Android Studio (version 3.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 30.0.1
• Dart plugin version 181.5656
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
[✓] Connected device (1 available)
• iPhone XR • DAE7804F-C35A-4847-94AF-BC094BE584DC • ios • iOS 12.1 (simulator)
• No issues found!
</code></pre>
| 0debug |
How does the unlink() in linux works? : <p>We call unlink() on file on USB disk. Will the place it was using become available for reuse (which conditions must be satisfied)?</p>
| 0debug |
What is difference between Class class object and object of a class in Java? : <p>Can someone please explain me difference between Class class object and object of a class in Java.If possible with a simple example.</p>
| 0debug |
How to merge duplicates in an array of objects and sum a specific property? : <p>I have this array of objects:</p>
<pre><code>var arr = [
{
name: 'John',
contributions: 2
},
{
name: 'Mary',
contributions: 4
},
{
name: 'John',
contributions: 1
},
{
name: 'Mary',
contributions: 1
}
];
</code></pre>
<p>... and I want to merge duplicates but sum their contributions. The result would be like the following:</p>
<pre><code>var arr = [
{
name: 'John',
contributions: 3
},
{
name: 'Mary',
contributions: 5
}
];
</code></pre>
<p>How could I achieve that with JavaScript?</p>
| 0debug |
GIT: How can I prevent foxtrot merges in my 'master' branch? : <p>A foxtrot merge is a merge where 'origin/master' merges in as a 2nd (or later) parent, like so:</p>
<p><a href="https://i.stack.imgur.com/yZMCS.png"><img src="https://i.stack.imgur.com/yZMCS.png" alt="Commit 'D' is a foxtrot merge because 'origin/master' is its 2nd parent."></a></p>
<p><sup><i>Commit 'D' is a foxtrot merge because 'origin/master' is its 2nd parent. Notice how first-parent history from 'origin/master' contains commit 'B' at this moment. </i></sup></p>
<p>But in my git repo I need all merges involving 'origin/master' to keep 'origin/master' as the 1st parent. Unfortunately git doesn't care about parent-order when it evaluates whether a commit is eligible for fast-forward. This causes the first parent history on my master branch to sometimes lose commits that used to be there (e.g., output of "git log --first-parent").</p>
<p>Here's what happens when commit 'D' from the earlier diagram is pushed:</p>
<p><a href="https://i.stack.imgur.com/ACgpr.png"><img src="https://i.stack.imgur.com/ACgpr.png" alt="How can I prevent this push? First-parent history of 'origin/master' no longer contains commit 'B' after the foxtrot merge is pushed!"></a></p>
<p><sup><i>How can I prevent this push? First-parent history of 'origin/master' no longer contains commit 'B' after the foxtrot merge is pushed!</i></sup></p>
<p>Obviously no commits or work are actually lost, it's just that in my environment I really need "git log --first-parent" to be a stable accumulative record of commits - if you like, a kind of "Write-Once Read-Many" (WORM) database. I have scripts and processes that use "git log --first-parent" to generate changelogs and release notes, as well as to manage ticket transitions in my ticketing system (JIRA). Foxtrot merges are breaking my scripts!</p>
<p>Is there some kind of pre-receive hook I could install in my git repositories to prevent foxtrot merges from getting pushed?</p>
<p><sup><i>p.s. The commit graphs in this stackoverflow question were generated using <a href="http://bit-booster.com/graph.html">http://bit-booster.com/graph.html</a>.</sup></i></p>
| 0debug |
static void raw_eject(BlockDriverState *bs, bool eject_flag)
{
bdrv_eject(bs->file->bs, eject_flag);
}
| 1threat |
Remove particular elements from an array using php : <p>I have one array like below</p>
<pre><code>Array
(
[AllocationPool] => TEST do not USE
[Quarter] => 2016-Q4
[Segment] => Storage
[Region] =>
[SubRegion] =>
[Country] =>
[typeofrec] => 0
[TotalAllocations] => 100
[TotalTransfersOut] => 75
[TotalTransfersIn] => 0
[StartOfAllocation] => 25
[ApprovedActivities] => 0
[AvailableBalance] => 25
[TotalApprovedClaims] => 0
[Balance] => 25
[TotalUnApprovedClaims] => 0
[Exposure] => 25
)
</code></pre>
<p>I need to remove some elements from this array and formatted to new structure.</p>
<p>I need to change below structure after format my array </p>
<pre><code>Array
(
[AllocationPool] => TEST do not USE
[Quarter] => 2016-Q4
[Segment] => Storage
[Region] =>
[SubRegion] =>
[Country] =>
)
</code></pre>
<p>Is any method available in php for remove some elements in an array using php?</p>
| 0debug |
static int mode_sense_page(SCSIDiskState *s, int page, uint8_t **p_outbuf,
int page_control)
{
static const int mode_sense_valid[0x3f] = {
[MODE_PAGE_HD_GEOMETRY] = (1 << TYPE_DISK),
[MODE_PAGE_FLEXIBLE_DISK_GEOMETRY] = (1 << TYPE_DISK),
[MODE_PAGE_CACHING] = (1 << TYPE_DISK) | (1 << TYPE_ROM),
[MODE_PAGE_CAPABILITIES] = (1 << TYPE_ROM),
};
BlockDriverState *bdrv = s->bs;
int cylinders, heads, secs;
uint8_t *p = *p_outbuf;
if ((mode_sense_valid[page] & (1 << s->qdev.type)) == 0) {
return -1;
}
p[0] = page;
switch (page) {
case MODE_PAGE_HD_GEOMETRY:
p[1] = 0x16;
if (page_control == 1) {
break;
}
bdrv_get_geometry_hint(bdrv, &cylinders, &heads, &secs);
p[2] = (cylinders >> 16) & 0xff;
p[3] = (cylinders >> 8) & 0xff;
p[4] = cylinders & 0xff;
p[5] = heads & 0xff;
p[6] = (cylinders >> 16) & 0xff;
p[7] = (cylinders >> 8) & 0xff;
p[8] = cylinders & 0xff;
p[9] = (cylinders >> 16) & 0xff;
p[10] = (cylinders >> 8) & 0xff;
p[11] = cylinders & 0xff;
p[12] = 0;
p[13] = 200;
p[14] = 0xff;
p[15] = 0xff;
p[16] = 0xff;
p[20] = (5400 >> 8) & 0xff;
p[21] = 5400 & 0xff;
break;
case MODE_PAGE_FLEXIBLE_DISK_GEOMETRY:
p[1] = 0x1e;
if (page_control == 1) {
break;
}
p[2] = 5000 >> 8;
p[3] = 5000 & 0xff;
bdrv_get_geometry_hint(bdrv, &cylinders, &heads, &secs);
p[4] = heads & 0xff;
p[5] = secs & 0xff;
p[6] = s->cluster_size * 2;
p[8] = (cylinders >> 8) & 0xff;
p[9] = cylinders & 0xff;
p[10] = (cylinders >> 8) & 0xff;
p[11] = cylinders & 0xff;
p[12] = (cylinders >> 8) & 0xff;
p[13] = cylinders & 0xff;
p[14] = 0;
p[15] = 1;
p[16] = 1;
p[17] = 0;
p[18] = 1;
p[19] = 1;
p[20] = 1;
p[28] = (5400 >> 8) & 0xff;
p[29] = 5400 & 0xff;
break;
case MODE_PAGE_CACHING:
p[0] = 8;
p[1] = 0x12;
if (page_control == 1) {
break;
}
if (bdrv_enable_write_cache(s->bs)) {
p[2] = 4;
}
break;
case MODE_PAGE_CAPABILITIES:
p[1] = 0x14;
if (page_control == 1) {
break;
}
p[2] = 3;
p[3] = 0;
p[4] = 0x7f;
p[5] = 0xff;
p[6] = 0x2d | (s->tray_locked ? 2 : 0);
p[7] = 0;
p[8] = (50 * 176) >> 8;
p[9] = (50 * 176) & 0xff;
p[10] = 0 >> 8;
p[11] = 0 & 0xff;
p[12] = 2048 >> 8;
p[13] = 2048 & 0xff;
p[14] = (16 * 176) >> 8;
p[15] = (16 * 176) & 0xff;
p[18] = (16 * 176) >> 8;
p[19] = (16 * 176) & 0xff;
p[20] = (16 * 176) >> 8; current
p[21] = (16 * 176) & 0xff;
break;
default:
return -1;
}
*p_outbuf += p[1] + 2;
return p[1] + 2;
}
| 1threat |
Can't enable migrations for Entity Framework on VS 2017 .NET Core : <p>I just installed VS 2017 and created a new Core project. Inside it, I added:</p>
<ul>
<li>Microsoft.EntityFrameworkCore (1.1.0)</li>
<li>Microsoft.NETCore.App (1.1.0)</li>
</ul>
<p>I also created a folder called Models with a class in it. Then, I went to the Package Manager Console and executed <em>enable-migrations</em> so that VS will create the files needed for me. However, instead of the needed files, I got the following error.</p>
<blockquote>
<p>The term 'enable-migration' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.</p>
</blockquote>
<p>What am I supposed to do here?</p>
<p>I seem to be out of luck googling. It's a very unusual combination (Core VS17 and EF) so there's virtually no info on the subject. Some guides talk about editing package.json by hand which is kind of hard because VS 2017 seems to upgrade the Core so that <em>dotnet restore</em> doesn't look for it but rather for a <em>xxx.csproj</em>.</p>
<p>In summary, I'm confused and quite uncertain how to bite the problem.</p>
| 0debug |
How does the line with two backslashes fool C preprocessor? : <p>I decided to take a look into the source of a standard Haskell module <a href="https://hackage.haskell.org/package/base-4.3.1.0/docs/src/Data-List.html" rel="noreferrer">Data.List</a> an found something interesting. The code is obviously firstly processed by C preprocessor, as a bunch of <code>#ifdef</code>s suggest, and only after that is compiled by Haskell compiler. However, C preprocessor is not very friendly to the source code different from C itself, as pointed out in the <a href="https://gcc.gnu.org/onlinedocs/cpp/Overview.html#Overview" rel="noreferrer">documentation</a>:</p>
<blockquote>
<p>The C preprocessor is intended to be used only with C, C++, and Objective-C source code. In the past, it has been abused as a general text processor. It will choke on input which does not obey C's lexical rules. For example, apostrophes will be interpreted as the beginning of character constants, and cause errors. Also, you cannot rely on it preserving characteristics of the input which are not significant to C-family languages. If a Makefile is preprocessed, all the hard tabs will be removed, and the Makefile will not work. </p>
</blockquote>
<p>But somehow Haskell code is still preserved under C preprocessing? Probably this snippet gives a clue:</p>
<pre><code>#ifdef __GLASGOW_HASKELL__
import GHC.Num
import GHC.Real
import GHC.List
import GHC.Base
#endif
infix 5 \\ -- comment to fool cpp
-- -----------------------------------------------------------------------------
-- List functions
</code></pre>
<p>How does this <code>comment to fool cpp</code> work? Looks like an interesting hack, but I could not google anything on the topic. In Haskell this line declares an infix operator <code>\\</code> with priority 5, and all the text after <code>--</code> is ignored. But what does it do with C preprocessor and in which way is it actually "fooled"?</p>
| 0debug |
Prepared statement in PHP/HTML website doesn't write to database but works in php-myAdmin : I have to write a html/php News-Website where you can add news if you're logged in, the news get sent to a MySQL Database and from there I want them to be displayed on the website. The problem right now is that although my prepared statement is beeing executed and all the variables are filled with the right values, the data doesn't get written to the SQL table. I tried using the same query as the prepared statement but not as a prepared statement but with the values typed out and it worked perfectly. I am very confused an would love some help from you guys.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<!DOCTYPE html>
<html>
<head>
<title>News hinzufügen</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<script src="https://cloud.tinymce.com/5/tinymce.min.js"></script>
<script>tinymce.init({ selector:'textarea' });</script>
</head>
<body>
<form action="add_news.php" method="POST" enctype="multipart/form-data">
<input type="text" name="title" placeholder="Titel" class="titlestyle" required="required">
<select name="kategorie" class="kategoriestyle">
<option value="1">Kategorie 1</option>
<option value="2">Kategorie 2</option>
<option value="3">Kategorie 3</option>
</select>
Gültig von <input type="date" name="vondate"> bis <input type="date" name="bisdate" required="required">
<textarea name="news" class="textareastyle" required="required">
</textarea>
<input type="file" name="imageUpload" id="imageUpload">
<input type="text" name="bildbeschreibung" placeholder="Beschreiben Sie Ihr Bild"> <br>
<input type="text" name="link" placeholder="Link">
<input type="text" name="linkbeschreibung" placeholder="Beschreiben Sie Ihren Link" > <br>
<input type="submit" name="submit" value="Fertigstellen" class="submitstyle">
</form>
</body>
</html>
<!-- end snippet -->
And here is the PHP-Code:
<?php session_start(); ?>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<?php
$dbserver = 'localhost';
$dbusername = 'root';
$dbpassword = '';
$dbname = 'm151db';
$titel = "";
$text = "";
$kategorie;
$vondatum = "";
$bidatum = "";
$bild = "";
$bildbeschr = "";
$link = "";
$linkbeschr = "";
$autor = $_SESSION["username"];
$error = "";
if (isset($_POST['submit'])) {
$conn = mysqli_connect($dbserver, $dbusername, $dbpassword, $dbname);
if ($conn->connect_error) {
die('Connection Error: Es gab ein Problem mit dem Verbindungsaufbau. ('.$conn->connect_errno.')'.$conn->connect_error);
}
$stmt = $conn->prepare("INSERT INTO news (name, beschreibung, kategorie_id, von, bis, bild, bildbeschreibung, link, linkbeschreibung, author) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param("ssssssssss", $titel, $text, $kategorie, $vondatum, $bisdatum, $bild, $bildbeschr, $link, $linkbeschr, $autor);
if(isset($_POST['title'])) {
$titel = trim($_POST['title']);
echo "$titel";
}
if(isset($_POST['news'])) {
$text = trim($_POST['news']);
echo "$text";
}
if(isset($_POST['kategorie'])) {
$katerorie = $_POST['kategorie'];
echo "$kategorie";
}
if(isset($_POST['vondate'])) {
$vondatum = $_POST['vondate'];
echo "$vondatum";
}
if(isset($_POST['bisdate'])) {
$bisdatum = $_POST['bisdate'];
echo "$bisdatum";
}
if(isset($_POST['bildbeschreibung'])) {
$bildbeschr = trim($_POST['bildbeschreibung']);
echo "$bildbeschr";
}
if(isset($_POST['link'])) {
$link = trim($_POST['link']);
echo "$link";
}
if(isset($_POST['linkbeschreibung'])) {
$linkbeschr = trim($_POST['linkbeschreibung']);
echo "$linkbeschr";
}
if(isset($_FILES['imageUpload'])) {
echo "0";
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["imageUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
$check = getimagesize($_FILES["imageUpload"]["tmp_name"]);
if($check == true) {
$uploadOk = 1;
echo "1";
}
else { ?>
<div class="alertbox">
<span class="closebtn"onclick="this.parentElement.style.display='none';">×</span>
Es können nur Bilddateien hochgeladen werden.
</div>
<?php $uploadOk = 0;
}
if(file_exists($target_file)) { ?>
<div class="alertbox">
<span class="closebtn"onclick="this.parentElement.style.display='none';">×</span>
Dieses Bild wurde bereits hochgeladen.
</div>
<?php $uploadOk = 0;
}
if($_FILES["imageUpload"]["size"] > 500000) { ?>
<div class="alertbox">
<span class="closebtn"onclick="this.parentElement.style.display='none';">×</span>
Das Bild ist zu gross. Wähle ein Bild unter 500kb aus.
</div>
<?php $uploadOk = 0;
}
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg") { ?>
<div class="alertbox">
<span class="closebtn"onclick="this.parentElement.style.display='none';">×</span>
Wähle ein PNG-/JPG-/JPEG-Bild aus.
</div>
<?php $uploadOk = 0;
}
if($uploadOk == 0) { ?>
<div class="alertbox">
<span class="closebtn"onclick="this.parentElement.style.display='none';">×</span>
Es ist ein Fehler beim hochladen ihres Bildes aufgetreten. Versuchen sie es erneut.
</div>
<?php
}
else {
if(move_uploaded_file($_FILES["imageUpload"]["tmp_name"], $target_file)) {
//echo "The file has been uploaded.";
}
else { ?>
<div class="alertbox">
<span class="closebtn"onclick="this.parentElement.style.display='none';">×</span>
Es ist ein Fehler beim hochladen ihres Bildes aufgetreten. Versuchen sie es erneut.
</div>
<?php }
$bild = $target_file;
echo "$bild";
}
$stmt->execute();
if ($stmt == true) {
echo "stmt executed";
}
else {
echo "stmt not executed";
}
}
}
?>
PS: The echos are just checkpoints so that I see what was executed and what wasn't. | 0debug |
Finding the null rate of the column deice_id : I'm trying to write a code that will display the null count for a column in a table
I wrote the code below but i've been running into a syntax issue
SELECT device_id AS FIELD, COUNT (*) FROM (SELECT * FROM TABLE WHERE
TRIM(UPPER(device_id) IN ('','NULL',) OR device_id IS NULL OR SUBSTRING(TRIM(UPPER(device_id)), 1,1) = '-')
AND (event_date between '2019-05-20' AND '2019-05-27'));
I've been experiencing a syntax error | 0debug |
Why do we need exclude in pom : <p>Pom.xml have this elements and I am curious why do we need exclude <code>commons-logging</code> from <code>spring-core</code>? And how do it works?</p>
<pre><code><dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.0.5.RELEASE</version>
<type>jar</type>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- next is log4j dependencie -->
</code></pre>
| 0debug |
CAGradientLayer diagonal gradient : <p><a href="https://i.stack.imgur.com/UYqru.png" rel="noreferrer"><img src="https://i.stack.imgur.com/UYqru.png" alt="enter image description here"></a></p>
<p>I use the following CAGradientLayer:</p>
<pre><code>let layer = CAGradientLayer()
layer.colors = [
UIColor.redColor().CGColor,
UIColor.greenColor().CGColor,
UIColor.blueColor().CGColor
]
layer.startPoint = CGPointMake(0, 1)
layer.endPoint = CGPointMake(1, 0)
layer.locations = [0.0, 0.6, 1.0]
</code></pre>
<p>But when I set bounds property for the layer, it just stretches a square gradient. I need a result like in Sketch 3 app image (see above).</p>
<p>How can I achieve this?</p>
| 0debug |
void qdev_prop_set_drive(DeviceState *dev, const char *name, DriveInfo *value)
{
qdev_prop_set(dev, name, &value, PROP_TYPE_DRIVE);
}
| 1threat |
Reference assemblies should not be loaded for execution : <p>All of a sudden my website is throwing this error message when I try to debug it within Visual Studio. If I deploy the website, it works without any errors.</p>
<p>Any suggestions to resolve this error.</p>
<pre>
[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.Win32.Primitives' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +738
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +217
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +92
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +290
System.Web.Compilation.BuildManager.ExecutePreAppStart() +157
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +531
[HttpException (0x80004005): Could not load file or assembly 'Microsoft.Win32.Primitives' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9946132
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +90
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +261
</pre>
| 0debug |
static uint32_t sdhci_read_dataport(SDHCIState *s, unsigned size)
{
uint32_t value = 0;
int i;
if ((s->prnsts & SDHC_DATA_AVAILABLE) == 0) {
ERRPRINT("Trying to read from empty buffer\n");
return 0;
}
for (i = 0; i < size; i++) {
value |= s->fifo_buffer[s->data_count] << i * 8;
s->data_count++;
if ((s->data_count) >= (s->blksize & 0x0fff)) {
DPRINT_L2("All %u bytes of data have been read from input buffer\n",
s->data_count);
s->prnsts &= ~SDHC_DATA_AVAILABLE;
s->data_count = 0;
if (s->trnmod & SDHC_TRNS_BLK_CNT_EN) {
s->blkcnt--;
}
if ((s->trnmod & SDHC_TRNS_MULTI) == 0 ||
((s->trnmod & SDHC_TRNS_BLK_CNT_EN) && (s->blkcnt == 0)) ||
(s->stopped_state == sdhc_gap_read &&
!(s->prnsts & SDHC_DAT_LINE_ACTIVE))) {
SDHCI_GET_CLASS(s)->end_data_transfer(s);
} else {
SDHCI_GET_CLASS(s)->read_block_from_card(s);
}
break;
}
}
return value;
}
| 1threat |
Getting git-revision hash with webpack : <p>I'm trying to create archive with webpack with suffix by git-revision. Could you tell me please what is good way to do it?</p>
| 0debug |
void watchdog_perform_action(void)
{
switch (watchdog_action) {
case WDT_RESET:
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_RESET, &error_abort);
qemu_system_reset_request();
break;
case WDT_SHUTDOWN:
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_SHUTDOWN, &error_abort);
qemu_system_powerdown_request();
break;
case WDT_POWEROFF:
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_POWEROFF, &error_abort);
exit(0);
case WDT_PAUSE:
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_PAUSE, &error_abort);
vm_stop(RUN_STATE_WATCHDOG);
break;
case WDT_DEBUG:
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_DEBUG, &error_abort);
fprintf(stderr, "watchdog: timer fired\n");
break;
case WDT_NONE:
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_NONE, &error_abort);
break;
}
}
| 1threat |
Can someone give a explanation and a solution to fix this issue? : In Jupyter Notebook I run this code without any errors. but in VScode there is an error ***"Unable to import 'PIL'pylint(import-error)"***. I've already install Pillow. But still, there is the error.
import os
from PIL import Image
# open an image file (.bmp,.jpg,.png,.gif) you have in the working folder
imageFile = "Cat.jpg"
im1 = Image.open(imageFile)
# adjust width and height to your needs
width = 480
height = 300
# use one of these filter options to resize the image
im2 = im1.resize((width, height), Image.NEAREST)
ext = ".jpg"
im2.save("NEAREST" + ext)
os.system("d:/python24/i_view32.exe %s" % "BILINEAR.jpg") | 0debug |
void slavio_serial_ms_kbd_init(target_phys_addr_t base, qemu_irq irq,
int disabled, int clock, int it_shift)
{
DeviceState *dev;
SysBusDevice *s;
dev = qdev_create(NULL, "escc");
qdev_prop_set_uint32(dev, "disabled", disabled);
qdev_prop_set_uint32(dev, "frequency", clock);
qdev_prop_set_uint32(dev, "it_shift", it_shift);
qdev_prop_set_chr(dev, "chrB", NULL);
qdev_prop_set_chr(dev, "chrA", NULL);
qdev_prop_set_uint32(dev, "chnBtype", mouse);
qdev_prop_set_uint32(dev, "chnAtype", kbd);
qdev_init(dev);
s = sysbus_from_qdev(dev);
sysbus_connect_irq(s, 0, irq);
sysbus_connect_irq(s, 1, irq);
sysbus_mmio_map(s, 0, base);
}
| 1threat |
static void test_cdrom_dma(void)
{
static const size_t len = ATAPI_BLOCK_SIZE;
char *pattern = g_malloc(ATAPI_BLOCK_SIZE * 16);
char *rx = g_malloc0(len);
uintptr_t guest_buf;
PrdtEntry prdt[1];
FILE *fh;
ide_test_start("-drive if=none,file=%s,media=cdrom,format=raw,id=sr0,index=0 "
"-device ide-cd,drive=sr0,bus=ide.0", tmp_path);
qtest_irq_intercept_in(global_qtest, "ioapic");
guest_buf = guest_alloc(guest_malloc, len);
prdt[0].addr = cpu_to_le32(guest_buf);
prdt[0].size = cpu_to_le32(len | PRDT_EOT);
generate_pattern(pattern, ATAPI_BLOCK_SIZE * 16, ATAPI_BLOCK_SIZE);
fh = fopen(tmp_path, "w+");
fwrite(pattern, ATAPI_BLOCK_SIZE, 16, fh);
fclose(fh);
send_dma_request(CMD_PACKET, 0, 1, prdt, 1, send_scsi_cdb_read10);
memread(guest_buf, rx, len);
g_assert_cmpint(memcmp(pattern, rx, len), ==, 0);
g_free(pattern);
g_free(rx);
test_bmdma_teardown();
}
| 1threat |
static char *var_read_string(AVIOContext *pb, int size)
{
int n;
char *str = av_malloc(size + 1);
if (!str)
return NULL;
n = avio_get_str(pb, size, str, size + 1);
if (n < size)
avio_skip(pb, size - n);
return str;
}
| 1threat |
Subclass.fetchRequest() Swift 3.0, extension not really helping 100%? : <p>according to the new Core Data changes, Xcode generates this subclass for me:</p>
<pre><code>extension Person {
@nonobjc public class func fetchRequest() -> NSFetchRequest<Person> {
return NSFetchRequest<Person>(entityName: "Person");
}
@NSManaged public var name: String?
}
</code></pre>
<p>then in code I was expecting to have this one line working:</p>
<pre><code>let fr = Person.fetchRequest()
</code></pre>
<p>This line of code above however gives me an error:</p>
<pre><code>"Ambiguous use of 'fetchRequest'
</code></pre>
<p>This fixes the issue:</p>
<pre><code>let fr: NSFetchRequest<Person> = Person.fetchRequest()
</code></pre>
<p>So then, I am confused what is the:</p>
<pre><code>NSFetchRequest<Person>
</code></pre>
<p>in the:</p>
<pre><code>@nonobjc public class func fetchRequest() -> NSFetchRequest<Person> {
</code></pre>
<p>return type doing at all?</p>
<p>Shouldn't the return type allow me not to have to specify the:</p>
<pre><code>NSFetchRequest<Person>
</code></pre>
<p>in the let definition??</p>
<pre><code>let fr: NSFetchRequest<Person> = Person.fetchRequest()
</code></pre>
<p>Can anybody help me understand why it is needed even though it's part of the return type already?</p>
| 0debug |
Issue regarding calculation of sinx using Taylor series : I am trying to calculate the value of sin(x) without using the predefined function.
Instead I am trying to calculate it using Taylor series.
The issue is that the program produces correct values for small values of x(lesser than 10 to be precise).
As the value of x increases I start to get wrong values of sin(x) [ for example greater than 100.]
I have included 1000 iterations of the series but still the program produces wrong answers for large values of x.
float e,x,p=2;
int a;
float sum1;
cout<<"enter the value x for sinx"<<endl;
cin>>x;
e=x;
sum1=x;
for(a=1;a<1000;a++)
{
[enter image description here][1] x=x*(e/p)*(e/(p+1))*(-1); //MULTIPLYING PREVIOUS TERM to -1*e/p * e/p+1 to get the next term.
sum1=sum1+x;
p=p+2;
}
cout<<sum1<<endl;
return 0;
AND FOR LARGE VALUES OF X( ie X>100) I GET THE NaN output WHICH MEANS NOT A NUMBER.
`
HERE IS A SAMPLE OUTPUT.
[1]: https://i.stack.imgur.com/4Smeo.png
PLEASE HELP!! , I'm curious to know what went wrong. | 0debug |
No non-OData HTTP route registered : <p>I followed <a href="https://docs.microsoft.com/en-US/azure/app-service-web/web-sites-dotnet-rest-service-aspnet-api-sql-database" rel="noreferrer">this</a> tutorial to create a WebAPI REST service.</p>
<p>After that, I could load the list of all contacts by pointing at <code>http://baseaddress/api/Contacts</code>.</p>
<p>Then I added the following code in the <code>Register</code> method in WebApiConfig.cs in order to enable an OData endpoint:</p>
<pre><code>config.Count().Filter().OrderBy().Expand().Select().MaxTop(null);
ODataModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<Contact>("Contacts");
config.MapODataServiceRoute(
routeName: "OData",
routePrefix: "odata",
model: builder.GetEdmModel());
</code></pre>
<p>And also added the <code>[EnableQuery]</code> parameter on the <code>Contact.GetContacts()</code> method. That way, I am able to query for particular contacts like this:</p>
<pre><code>http://baseaddress/odata/Contacts?$filter=startswith(Name,'A')
</code></pre>
<p>and it works like charm.</p>
<p>Unfortunately, when I put the <code>[EnableQuery]</code>, the WebAPI endpoint stops working, showing instead the following error:</p>
<pre><code>No non-OData HTTP route registered.
in System.Web.OData.Extensions.HttpConfigurationExtensions.GetNonODataRootContainer(HttpConfiguration configuration)
in System.Web.OData.Extensions.HttpRequestMessageExtensions.GetRootContainer(HttpRequestMessage request, String routeName)
in System.Web.OData.Extensions.HttpRequestMessageExtensions.CreateRequestScope(HttpRequestMessage request, String routeName)
in System.Web.OData.Extensions.HttpRequestMessageExtensions.CreateRequestContainer(HttpRequestMessage request, String routeName)
...
</code></pre>
<p>What should I do to fix this?</p>
| 0debug |
static void jpeg2000_flush(Jpeg2000DecoderContext *s)
{
if (*s->buf == 0xff)
s->buf++;
s->bit_index = 8;
s->buf++;
}
| 1threat |
static void pc_dimm_realize(DeviceState *dev, Error **errp)
{
PCDIMMDevice *dimm = PC_DIMM(dev);
if (!dimm->hostmem) {
error_setg(errp, "'" PC_DIMM_MEMDEV_PROP "' property is not set");
return;
}
if (dimm->node >= nb_numa_nodes) {
error_setg(errp, "'DIMM property " PC_DIMM_NODE_PROP " has value %"
PRIu32 "' which exceeds the number of numa nodes: %d",
dimm->node, nb_numa_nodes);
return;
}
}
| 1threat |
static int ftp_flush_control_input(FTPContext *s)
{
char buf[CONTROL_BUFFER_SIZE];
int err, ori_block_flag = s->conn_control_block_flag;
s->conn_control_block_flag = 1;
do {
err = ftp_get_line(s, buf, sizeof(buf));
} while (!err);
s->conn_control_block_flag = ori_block_flag;
if (err < 0 && err != AVERROR_EXIT)
return err;
return 0;
}
| 1threat |
static void yuv2nv12X_c(SwsContext *c, const int16_t *lumFilter,
const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrUSrc,
const int16_t **chrVSrc, int chrFilterSize,
const int16_t **alpSrc, uint8_t *dest, uint8_t *uDest,
uint8_t *vDest, uint8_t *aDest,
int dstW, int chrDstW)
{
enum PixelFormat dstFormat = c->dstFormat;
int i;
for (i=0; i<dstW; i++) {
int val=1<<18;
int j;
for (j=0; j<lumFilterSize; j++)
val += lumSrc[j][i] * lumFilter[j];
dest[i]= av_clip_uint8(val>>19);
}
if (!uDest)
return;
if (dstFormat == PIX_FMT_NV12)
for (i=0; i<chrDstW; i++) {
int u=1<<18;
int v=1<<18;
int j;
for (j=0; j<chrFilterSize; j++) {
u += chrUSrc[j][i] * chrFilter[j];
v += chrVSrc[j][i] * chrFilter[j];
}
uDest[2*i]= av_clip_uint8(u>>19);
uDest[2*i+1]= av_clip_uint8(v>>19);
}
else
for (i=0; i<chrDstW; i++) {
int u=1<<18;
int v=1<<18;
int j;
for (j=0; j<chrFilterSize; j++) {
u += chrUSrc[j][i] * chrFilter[j];
v += chrVSrc[j][i] * chrFilter[j];
}
uDest[2*i]= av_clip_uint8(v>>19);
uDest[2*i+1]= av_clip_uint8(u>>19);
}
}
| 1threat |
What is window.origin? : <p>What is <code>window.origin</code>? It doesn't seem to be documented in <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/origin" rel="noreferrer">the usual place</a>.</p>
<p>It looks like it might be very similar to <code>window.location.origin</code> - for example, here on Stack Overflow, both return</p>
<blockquote>
<pre><code>https://stackoverflow.com
</code></pre>
</blockquote>
<p>But inside an <code>iframe</code>, they're different:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>console.log(window.location.origin);
console.log(window.origin);</code></pre>
</div>
</div>
</p>
<blockquote>
<pre><code>https://stacksnippets.net
null
</code></pre>
</blockquote>
<p>The embedded snippet is inside an <code>iframe</code> <em>without</em> <code>allow-same-origin</code>. If you change the iframe, for example, if you edit Stack Overflow's HTML and manually add the attribute:</p>
<pre><code><iframe name="313b857b-943a-7ffd-4663-3d9060cf4cb6" sandbox="allow-same-origin allow-forms allow-modals allow-scripts" class="snippet-box-edit" frameborder="0" style="">
^^^^^^^^^^^^^^^^^^
</code></pre>
<p>and then run the snippet, you get:</p>
<blockquote>
<pre><code>https://stacksnippets.net
https://stacksnippets.net
</code></pre>
</blockquote>
<p>The same sort of behavior is exhibited on other sites with <code><iframe></code>s.</p>
<p><a href="https://www.google.com/search?q=window.origin" rel="noreferrer">Google</a> does not appear to have any authoritative links on the subject. Searching for the <a href="https://www.google.com/search?q=%22window.origin%22+javascript" rel="noreferrer">exact phrase</a> + Javascript gives many results related to <code>iframe</code>s and <code>postMessage</code>, but no precise description of what <code>window.origin</code> <em>actually is</em>.</p>
<p>Calling <code>postMessage</code> from a child <code>iframe</code> appears to result in the parent window receiving a message with the <code>origin</code> property matching the <code>window.origin</code> of the child frame - without <code>allow-same-origin</code>, it's <code>null</code>, otherwise it looks like it's the same as the <code>window.location.origin</code> of the child.</p>
<p>The above is what I <em>think</em> I've figured out from guessing-and-checking, but I'm nowhere near certain. I'd appreciate a confirmation/explanation, preferably with a link to an authoritative source.</p>
| 0debug |
can you explain me to how functions operate : <p>how do you use functions because i am big confusion at the moment and really want learn how to code </p>
| 0debug |
I need an algorithm to create vouchers based on date and amount of time : <p>I need an algorithm that creates vouchers that is based on an internet kiosk timer. Basically, voucher should have the amount of time allowed encrypted into it. I was thinking of having the amount of time in hex at the start with a few random chars after it then a checksum at the end. However any other ideas are welcome</p>
| 0debug |
static int proxy_remove(FsContext *ctx, const char *path)
{
int retval;
V9fsString name;
v9fs_string_init(&name);
v9fs_string_sprintf(&name, "%s", path);
retval = v9fs_request(ctx->private, T_REMOVE, NULL, "s", &name);
v9fs_string_free(&name);
if (retval < 0) {
errno = -retval;
}
return retval;
}
| 1threat |
static void DBDMA_run (DBDMA_channel *ch)
{
int channel;
for (channel = 0; channel < DBDMA_CHANNELS; channel++, ch++) {
uint32_t status = be32_to_cpu(ch->regs[DBDMA_STATUS]);
if (!ch->processing && (status & RUN) && (status & ACTIVE))
channel_run(ch);
}
}
| 1threat |
yuv2422_2_c_template(SwsContext *c, const int16_t *buf[2],
const int16_t *ubuf[2], const int16_t *vbuf[2],
const int16_t *abuf[2], uint8_t *dest, int dstW,
int yalpha, int uvalpha, int y,
enum PixelFormat target)
{
const int16_t *buf0 = buf[0], *buf1 = buf[1],
*ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
*vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
int yalpha1 = 4095 - yalpha;
int uvalpha1 = 4095 - uvalpha;
int i;
for (i = 0; i < ((dstW + 1) >> 1); i++) {
int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19;
int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
Y1 = av_clip_uint8(Y1);
Y2 = av_clip_uint8(Y2);
U = av_clip_uint8(U);
V = av_clip_uint8(V);
output_pixels(i * 4, Y1, U, Y2, V);
}
}
| 1threat |
Update mouse cursor without moving mouse with changed CSS cursor property : <p>I currently have a C# host that mirrors the screen and mouse on a website, the connection works totally fine, and when the mouse changes on the host, it changes the CSS almost immediatly. This way I can mirror the mouse too.</p>
<p><strong>So here is the problem:</strong></p>
<p><em>The mouse only updates when I move the mouse on the client website.</em></p>
<p>Speed and performance is very important here, a quick fix would be to refresh the canvas, or move the page/mouse a little bit, but I'd rather have a more sophisticated approach.</p>
| 0debug |
How to compare user input with text? : <p>i wanted to compare user input with text in c, but i dont know exactly how. Please help me.</p>
<pre><code>#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
char len_input[16];
int input;
void name() {
printf("Enter your name\n");
input = fgets(len_input, sizeof(len_input), stdin);
input;
if (input == "Osas") {
printf("What a stupid name...\n");
}
else {
printf("Cool name dude!\n");
}
}
int main(int argc, char **argv) {
name();
}
</code></pre>
<p>I tried this but its not working. Please show it how to do it correctly becaus im new to c. Thanks</p>
| 0debug |
Kubernetes Minikube with local persistent storage : <p>I am currently trying to deploy the following on Minikube. I used the configuration files to use a hostpath as a persistent storage on minikube node.</p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
name: "pv-volume"
spec:
capacity:
storage: "20Gi"
accessModes:
- "ReadWriteOnce"
hostPath:
path: /data
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: "orientdb-pv-claim"
spec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: "20Gi"
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: orientdbservice
spec:
#replicas: 1
template:
metadata:
name: orientdbservice
labels:
run: orientdbservice
test: orientdbservice
spec:
containers:
- name: orientdbservice
image: orientdb:latest
env:
- name: ORIENTDB_ROOT_PASSWORD
value: "rootpwd"
ports:
- containerPort: 2480
name: orientdb
volumeMounts:
- name: orientdb-config
mountPath: /data/orientdb/config
- name: orientdb-databases
mountPath: /data/orientdb/databases
- name: orientdb-backup
mountPath: /data/orientdb/backup
volumes:
- name: orientdb-config
persistentVolumeClaim:
claimName: orientdb-pv-claim
- name: orientdb-databases
persistentVolumeClaim:
claimName: orientdb-pv-claim
- name: orientdb-backup
persistentVolumeClaim:
claimName: orientdb-pv-claim
---
apiVersion: v1
kind: Service
metadata:
name: orientdbservice
labels:
run: orientdbservice
spec:
type: NodePort
selector:
run: orientdbservice
ports:
- protocol: TCP
port: 2480
name: http
</code></pre>
<p>which results in following</p>
<pre><code>#kubectl get pv
NAME CAPACITY ACCESSMODES RECLAIMPOLICY STATUS CLAIM STORAGECLASS REASON AGE
pv-volume 20Gi RWO Retain Available 4h
pvc-cd14d593-78fc-11e7-a46d-1277ec3dd2b5 20Gi RWO Delete Bound default/orientdb-pv-claim standard 4h
#kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESSMODES STORAGECLASS AGE
orientdb-pv-claim Bound pvc-cd14d593-78fc-11e7-a46d-1277ec3dd2b5 20Gi RWO
#kubectl get svc
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
orientdbservice 10.0.0.16 <nodes> 2480:30552/TCP 4h
#kubectl get pods
NAME READY STATUS RESTARTS AGE
orientdbservice-458328598-zsmw5 0/1 ContainerCreating 0 4h
#kubectl describe pod orientdbservice-458328598-zsmw5
Events:
FirstSeen LastSeen Count From SubObjectPath TypeReason Message
--------- -------- ----- ---- ------------- -------- ------ -------
4h 1m 37 kubelet, minikube Warning FailedMount Unable to mount volumes for pod "orientdbservice-458328598-zsmw5_default(392b1298-78ff-11e7-a46d-1277ec3dd2b5)": timeout expired waiting for volumes to attach/mount for pod "default"/"orientdbservice-458328598-zsmw5". list of unattached/unmounted volumes=[orientdb-databases]
4h 1m 37 kubelet, minikube Warning FailedSync Error syncing pod
</code></pre>
<p>I see the following error</p>
<pre><code>Unable to mount volumes for pod,timeout expired waiting for volumes to attach/mount for pod
</code></pre>
<p>Is there something incorrect in way I am creating Persistent Volume and PersistentVolumeClaim on my node.</p>
<pre><code>minikube version: v0.20.0
</code></pre>
<p>Appreciate all the help</p>
| 0debug |
static int ppc_hash64_pte_prot(PowerPCCPU *cpu,
ppc_slb_t *slb, ppc_hash_pte64_t pte)
{
CPUPPCState *env = &cpu->env;
unsigned pp, key;
int prot = 0;
key = !!(msr_pr ? (slb->vsid & SLB_VSID_KP)
: (slb->vsid & SLB_VSID_KS));
pp = (pte.pte1 & HPTE64_R_PP) | ((pte.pte1 & HPTE64_R_PP0) >> 61);
if (key == 0) {
switch (pp) {
case 0x0:
case 0x1:
case 0x2:
prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
break;
case 0x3:
case 0x6:
prot = PAGE_READ | PAGE_EXEC;
break;
}
} else {
switch (pp) {
case 0x0:
case 0x6:
break;
case 0x1:
case 0x3:
prot = PAGE_READ | PAGE_EXEC;
break;
case 0x2:
prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
break;
}
}
if (!(pte.pte1 & HPTE64_R_N) || (pte.pte1 & HPTE64_R_G)
|| (slb->vsid & SLB_VSID_N)) {
prot |= PAGE_EXEC;
}
return prot;
}
| 1threat |
Do deleted Amazon S3 Bucket names become available for re-use : <p>If I delete a Bucket from my Amazon S3 account, does the name become available for use elsewhere?
I setup a bucket named "WXY234" in my S3 account, but now I'd like to have that bucket name in a different account. If I delete it from my account, will the name be released into the wild so I can use it elsewhere? If so, how long does it take for the released name to become available?</p>
| 0debug |
Permission denied error in Google Tagmanager Android : <p>In google tag manager, I have created one <code>container(Android legacy)</code> to push data to <code>Google Analytics (Added as tag)</code>. When I am trying to download current version (published one) it throwing error</p>
<pre><code> )]}',
{"default":{"errorCode":7,"errorMessage":"Permission Denied.","fieldError":[],
"compilerError":[],"syncError":[],"vendorTemplateError":[]}}
</code></pre>
<p>Above is the content of json file (which is an invalid json). I checked for the permission and it has <code>publish</code> permission which is the highest permission.</p>
<p>Please help</p>
| 0debug |
Error while compiling a C++ program with G++ : <p>v This is <code>main.cpp</code>:</p>
<pre><code>#include <stdio.h>
using namespace std;
int main() {
cout << "Hello, World!" << endl;
return 0;
}
</code></pre>
<p>To compile it, I go into cmd and type <code>g++ main.cpp</code> but it gives me 2 errors, saying that both <code>cout</code> and <code>endl</code> aren't declared. I can only imagine that it's because it can't find the namespace <code>std</code> or can't include <code><stdio.h></code>. How would I make this work?</p>
| 0debug |
Apply CSS to all browsers except IE using media query : <p>I found a way to apply media queries to IE using:</p>
<pre><code>@media (-ms-high-contrast: none), (-ms-high-contrast: active) {
}
</code></pre>
<p>Is there a way do the same to apply CSS to all browsers but IE? Something like:</p>
<pre><code>@media not( (-ms-high-contrast: none), (-ms-high-contrast: active) ) {
}
</code></pre>
<p>I'd like to avoid using the HTML tags.</p>
| 0debug |
R Markdown similar feature to "newcommand" in LaTex? : <p>Does R Markdown have a similar construct to LaTex's "newcommand"? I would like to be able to define things like <code>\var</code> to be <code>\mathrm{Var}</code> to avoid the extra typing in math mode. If not, what do people do to reduce repetition in typesetting equations in markdown?</p>
| 0debug |
Println vs Printf vs Print in Go : <p>I come from a land of JS and have mostly used things like <code>console.log</code> or <code>console.error</code></p>
<p>Now, the tutorial I am following, the instructor over there did something like this</p>
<pre><code>package main
import "fmt"
func main() {
var FirstName = "Varun"
var lastName = "bindal"
fmt.Println(FirstName, lastName)
fmt.Printf("%T", FirstName)
}
</code></pre>
<p>Here he did PrintF to check type instead of Println. Initially, I thought that println prints in new Line so I changed my</p>
<pre><code>fmt.Printf("%T", FirstName)
</code></pre>
<p>to </p>
<pre><code>fmt.Println("%T", FirstName)
</code></pre>
<p>but this logged <code>%T Varun</code> instead of telling me the type.</p>
<p>I went to their <a href="https://golang.org/pkg/fmt/" rel="noreferrer">site to figure it out</a> and was either unable to comprehend it or wasn't able to find it out. </p>
<p>Googling lead me know that there are three ways to log/print in Go</p>
<ol>
<li>Println</li>
<li>Printf</li>
<li>Print</li>
</ol>
<p>So, If someone call tell the difference between three of them?</p>
| 0debug |
Role based authorization with IdentityServer4 : <p>I am trying to implement "Role Based Authorization" using IdentityServer4 to give access to my API based on the user roles. </p>
<p>For example , I want to have two roles for the user i.e. FreeUser and PaidUser and want to give access to the API through the Authorize Attribute using [Authorize(Roles = "FreeUser"))], Kindly help me that How can I achieve this.</p>
<p>I have the following solution structure :</p>
<ol>
<li>IdentityServer</li>
<li>WebApi</li>
<li>Javascript Client</li>
</ol>
<p>I have registered my Javascript client as follows:</p>
<pre><code> new Client
{
ClientId = "js",
ClientName = "javascript client",
AllowedGrantTypes = GrantTypes.Implicit,
AllowAccessTokensViaBrowser= true,
RedirectUris = {"http://localhost:5004/callback.html"},
PostLogoutRedirectUris = {"http://localhost:5004/index.html"},
AllowedCorsOrigins = {"http://localhost:5004"},
AllowedScopes =
{
StandardScopes.OpenId.Name,
StandardScopes.Profile.Name,
"api1",
"role",
StandardScopes.AllClaims.Name
}
}
</code></pre>
<p><strong>Scopes</strong></p>
<pre><code> return new List<Scope>
{
StandardScopes.OpenId,
StandardScopes.Profile,
new Scope
{
Name = "api1",
Description = "My API"
},
new Scope
{
Enabled = true,
Name = "role",
DisplayName = "Role(s)",
Description = "roles of user",
Type = ScopeType.Identity,
Claims = new List<ScopeClaim>
{
new ScopeClaim("role",false)
}
},
StandardScopes.AllClaims
};
</code></pre>
<p><strong>Users</strong></p>
<pre><code> return new List<InMemoryUser>
{
new InMemoryUser
{
Subject = "1",
Username = "alice",
Password = "password",
Claims = new List<Claim>
{
new Claim("name", "Alice"),
new Claim("website", "https://alice.com"),
new Claim("role","FreeUser")
}
},
new InMemoryUser
{
Subject = "2",
Username = "bob",
Password = "password",
Claims = new List<Claim>
{
new Claim("name", "Bob"),
new Claim("website", "https://bob.com"),
new Claim("role","PaidUser")
}
}
};
</code></pre>
<p><strong>WebApi Startup.cs</strong> </p>
<pre><code> public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
app.UseCors("default");
app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{
Authority = "http://localhost:5000",
ScopeName = "api1",
// AdditionalScopes = new List<string> { "openid","profile", "role" },
RequireHttpsMetadata = false
});
app.UseMvc();
}
</code></pre>
<p><strong>Web Api controller</strong></p>
<pre><code>namespace Api.Controllers
{
[Route("[controller]")]
public class IdentityController : ControllerBase
{
[HttpGet]
[Authorize(Roles = "PaidUser")]
public IActionResult Get()
{
return new JsonResult(from c in User.Claims select new { c.Type, c.Value });
}
[Authorize(Roles = "FreeUser")]
[HttpGet]
[Route("getfree")]
public IActionResult GetFreeUser()
{
return new JsonResult(from c in User.Claims select new { c.Type, c.Value });
}
}
}
</code></pre>
<p><strong>Javascript Client app.js</strong>
Here I am trying to login the user through IdentityServer and make an API Request.</p>
<pre><code>var mgr = new Oidc.UserManager(config);
mgr.getUser().then(function (user) {
if (user) {
log("User logged in", user.profile);
} else {
log("User is not logged in.");
}
});
function login() {
mgr.signinRedirect();
}
function api() {
mgr.getUser().then(function (user) {
var url = "http://localhost:5001/identity/getfree";
var xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.onload = function () {
log(xhr.status, JSON.parse(xhr.responseText));
};
xhr.setRequestHeader("Authorization", "Bearer " + user.access_token);
xhr.send();
});
}
function logout() {
mgr.signoutRedirect();
}
</code></pre>
<p>The Login flow works fine and I can login successfully, and I can receive the role in the access token.</p>
<p><a href="https://i.stack.imgur.com/zV3i2.png" rel="noreferrer"><img src="https://i.stack.imgur.com/zV3i2.png" alt="enter image description here"></a></p>
<p>When I make a request to the API by clicking the button (Call Api) then I get the following error..
<a href="https://i.stack.imgur.com/OHlv0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/OHlv0.png" alt="enter image description here"></a></p>
| 0debug |
pvscsi_init_msi(PVSCSIState *s)
{
int res;
PCIDevice *d = PCI_DEVICE(s);
res = msi_init(d, PVSCSI_MSI_OFFSET(s), PVSCSI_MSIX_NUM_VECTORS,
PVSCSI_USE_64BIT, PVSCSI_PER_VECTOR_MASK);
if (res < 0) {
trace_pvscsi_init_msi_fail(res);
s->msi_used = false;
} else {
s->msi_used = true;
}
}
| 1threat |
static void adb_kbd_initfn(Object *obj)
{
ADBDevice *d = ADB_DEVICE(obj);
d->devaddr = ADB_DEVID_KEYBOARD;
}
| 1threat |
static inline void RENAME(yuv2packed2)(SwsContext *c, uint16_t *buf0, uint16_t *buf1, uint16_t *uvbuf0, uint16_t *uvbuf1,
uint8_t *dest, int dstW, int yalpha, int uvalpha, int y)
{
int yalpha1=yalpha^4095;
int uvalpha1=uvalpha^4095;
int i;
#if 0
if(flags&SWS_FULL_CHR_H_INT)
{
switch(dstFormat)
{
#ifdef HAVE_MMX
case PIX_FMT_RGB32:
asm volatile(
FULL_YSCALEYUV2RGB
"punpcklbw %%mm1, %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"movq %%mm3, %%mm1 \n\t"
"punpcklwd %%mm0, %%mm3 \n\t"
"punpckhwd %%mm0, %%mm1 \n\t"
MOVNTQ(%%mm3, (%4, %%REGa, 4))
MOVNTQ(%%mm1, 8(%4, %%REGa, 4))
"add $4, %%"REG_a" \n\t"
"cmp %5, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" ((long)dstW),
"m" (yalpha1), "m" (uvalpha1)
: "%"REG_a
);
break;
case PIX_FMT_BGR24:
asm volatile(
FULL_YSCALEYUV2RGB
"punpcklbw %%mm1, %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"movq %%mm3, %%mm1 \n\t"
"punpcklwd %%mm0, %%mm3 \n\t"
"punpckhwd %%mm0, %%mm1 \n\t"
"movq %%mm3, %%mm2 \n\t"
"psrlq $8, %%mm3 \n\t"
"pand "MANGLE(bm00000111)", %%mm2\n\t"
"pand "MANGLE(bm11111000)", %%mm3\n\t"
"por %%mm2, %%mm3 \n\t"
"movq %%mm1, %%mm2 \n\t"
"psllq $48, %%mm1 \n\t"
"por %%mm1, %%mm3 \n\t"
"movq %%mm2, %%mm1 \n\t"
"psrld $16, %%mm2 \n\t"
"psrlq $24, %%mm1 \n\t"
"por %%mm2, %%mm1 \n\t"
"mov %4, %%"REG_b" \n\t"
"add %%"REG_a", %%"REG_b" \n\t"
#ifdef HAVE_MMX2
"movntq %%mm3, (%%"REG_b", %%"REG_a", 2)\n\t"
"movntq %%mm1, 8(%%"REG_b", %%"REG_a", 2)\n\t"
#else
"movd %%mm3, (%%"REG_b", %%"REG_a", 2) \n\t"
"psrlq $32, %%mm3 \n\t"
"movd %%mm3, 4(%%"REG_b", %%"REG_a", 2) \n\t"
"movd %%mm1, 8(%%"REG_b", %%"REG_a", 2) \n\t"
#endif
"add $4, %%"REG_a" \n\t"
"cmp %5, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), "m" (dstW),
"m" (yalpha1), "m" (uvalpha1)
: "%"REG_a, "%"REG_b
);
break;
case PIX_FMT_BGR555:
asm volatile(
FULL_YSCALEYUV2RGB
#ifdef DITHER1XBPP
"paddusb "MANGLE(g5Dither)", %%mm1\n\t"
"paddusb "MANGLE(r5Dither)", %%mm0\n\t"
"paddusb "MANGLE(b5Dither)", %%mm3\n\t"
#endif
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"psrlw $3, %%mm3 \n\t"
"psllw $2, %%mm1 \n\t"
"psllw $7, %%mm0 \n\t"
"pand "MANGLE(g15Mask)", %%mm1 \n\t"
"pand "MANGLE(r15Mask)", %%mm0 \n\t"
"por %%mm3, %%mm1 \n\t"
"por %%mm1, %%mm0 \n\t"
MOVNTQ(%%mm0, (%4, %%REGa, 2))
"add $4, %%"REG_a" \n\t"
"cmp %5, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW),
"m" (yalpha1), "m" (uvalpha1)
: "%"REG_a
);
break;
case PIX_FMT_BGR565:
asm volatile(
FULL_YSCALEYUV2RGB
#ifdef DITHER1XBPP
"paddusb "MANGLE(g6Dither)", %%mm1\n\t"
"paddusb "MANGLE(r5Dither)", %%mm0\n\t"
"paddusb "MANGLE(b5Dither)", %%mm3\n\t"
#endif
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"psrlw $3, %%mm3 \n\t"
"psllw $3, %%mm1 \n\t"
"psllw $8, %%mm0 \n\t"
"pand "MANGLE(g16Mask)", %%mm1 \n\t"
"pand "MANGLE(r16Mask)", %%mm0 \n\t"
"por %%mm3, %%mm1 \n\t"
"por %%mm1, %%mm0 \n\t"
MOVNTQ(%%mm0, (%4, %%REGa, 2))
"add $4, %%"REG_a" \n\t"
"cmp %5, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW),
"m" (yalpha1), "m" (uvalpha1)
: "%"REG_a
);
break;
#endif
case PIX_FMT_BGR32:
#ifndef HAVE_MMX
case PIX_FMT_RGB32:
#endif
if(dstFormat==PIX_FMT_RGB32)
{
int i;
#ifdef WORDS_BIGENDIAN
dest++;
#endif
for(i=0;i<dstW;i++){
int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);
int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
dest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)];
dest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)];
dest[2]=clip_table[((Y + yuvtab_3343[V]) >>13)];
dest+= 4;
}
}
else if(dstFormat==PIX_FMT_BGR24)
{
int i;
for(i=0;i<dstW;i++){
int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);
int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
dest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)];
dest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)];
dest[2]=clip_table[((Y + yuvtab_3343[V]) >>13)];
dest+= 3;
}
}
else if(dstFormat==PIX_FMT_BGR565)
{
int i;
for(i=0;i<dstW;i++){
int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);
int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
((uint16_t*)dest)[i] =
clip_table16b[(Y + yuvtab_40cf[U]) >>13] |
clip_table16g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] |
clip_table16r[(Y + yuvtab_3343[V]) >>13];
}
}
else if(dstFormat==PIX_FMT_BGR555)
{
int i;
for(i=0;i<dstW;i++){
int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);
int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
((uint16_t*)dest)[i] =
clip_table15b[(Y + yuvtab_40cf[U]) >>13] |
clip_table15g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] |
clip_table15r[(Y + yuvtab_3343[V]) >>13];
}
}
}
else
{
#endif
#ifdef HAVE_MMX
switch(c->dstFormat)
{
case PIX_FMT_RGB32:
asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5)
WRITEBGR32(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
"a" (&c->redDither)
);
return;
case PIX_FMT_BGR24:
asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5)
WRITEBGR24(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
"a" (&c->redDither)
);
return;
case PIX_FMT_BGR555:
asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5)
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g5Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR15(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
"a" (&c->redDither)
);
return;
case PIX_FMT_BGR565:
asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5)
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g6Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR16(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
"a" (&c->redDither)
);
return;
case PIX_FMT_YUYV422:
asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2PACKED(%%REGBP, %5)
WRITEYUY2(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
"a" (&c->redDither)
);
return;
default: break;
}
#endif
YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB2_C, YSCALE_YUV_2_PACKED2_C)
}
| 1threat |
mysql complex joins within a table : I have a mysql session table with below entries
sessionid conversationid agentid Reason
s1 c1 a1 r1
s2 c1 a1 r2
s3 c2 a2 r1
s4 c3 a3 r2
i want sesionid for the rows where agentid and conversationid's are same and first occurance of reason is r1.
Expected output:
sessionid conversationid agentid Reason
s1 c1 a1 r1
s2 c1 a1 r2
Kinly help. | 0debug |
static void print_report(const char *op, struct timeval *t, int64_t offset,
int64_t count, int64_t total, int cnt, int Cflag)
{
char s1[64], s2[64], ts[64];
timestr(t, ts, sizeof(ts), Cflag ? VERBOSE_FIXED_TIME : 0);
if (!Cflag) {
cvtstr((double)total, s1, sizeof(s1));
cvtstr(tdiv((double)total, *t), s2, sizeof(s2));
printf("%s %"PRId64"/%"PRId64" bytes at offset %" PRId64 "\n",
op, total, count, offset);
printf("%s, %d ops; %s (%s/sec and %.4f ops/sec)\n",
s1, cnt, ts, s2, tdiv((double)cnt, *t));
} else {
printf("%"PRId64",%d,%s,%.3f,%.3f\n",
total, cnt, ts,
tdiv((double)total, *t),
tdiv((double)cnt, *t));
}
}
| 1threat |
Add startsWith in IE 11 : <p>IE 11 does not support <code>startsWith</code> with strings. (<a href="https://kangax.github.io/compat-table/es6/" rel="noreferrer">Look here</a>)</p>
<p>How do you add a prototype so that it supports the method?</p>
| 0debug |
void gen_intermediate_code_internal(XtensaCPU *cpu,
TranslationBlock *tb, bool search_pc)
{
CPUState *cs = CPU(cpu);
CPUXtensaState *env = &cpu->env;
DisasContext dc;
int insn_count = 0;
int j, lj = -1;
uint16_t *gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;
int max_insns = tb->cflags & CF_COUNT_MASK;
uint32_t pc_start = tb->pc;
uint32_t next_page_start =
(pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
if (max_insns == 0) {
max_insns = CF_COUNT_MASK;
}
dc.config = env->config;
dc.singlestep_enabled = cs->singlestep_enabled;
dc.tb = tb;
dc.pc = pc_start;
dc.ring = tb->flags & XTENSA_TBFLAG_RING_MASK;
dc.cring = (tb->flags & XTENSA_TBFLAG_EXCM) ? 0 : dc.ring;
dc.lbeg = env->sregs[LBEG];
dc.lend = env->sregs[LEND];
dc.is_jmp = DISAS_NEXT;
dc.ccount_delta = 0;
dc.debug = tb->flags & XTENSA_TBFLAG_DEBUG;
dc.icount = tb->flags & XTENSA_TBFLAG_ICOUNT;
dc.cpenable = (tb->flags & XTENSA_TBFLAG_CPENABLE_MASK) >>
XTENSA_TBFLAG_CPENABLE_SHIFT;
init_litbase(&dc);
init_sar_tracker(&dc);
reset_used_window(&dc);
if (dc.icount) {
dc.next_icount = tcg_temp_local_new_i32();
}
gen_tb_start();
if (tb->flags & XTENSA_TBFLAG_EXCEPTION) {
tcg_gen_movi_i32(cpu_pc, dc.pc);
gen_exception(&dc, EXCP_DEBUG);
}
do {
check_breakpoint(env, &dc);
if (search_pc) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j) {
tcg_ctx.gen_opc_instr_start[lj++] = 0;
}
}
tcg_ctx.gen_opc_pc[lj] = dc.pc;
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = insn_count;
}
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_debug_insn_start(dc.pc);
}
++dc.ccount_delta;
if (insn_count + 1 == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
}
if (dc.icount) {
int label = gen_new_label();
tcg_gen_addi_i32(dc.next_icount, cpu_SR[ICOUNT], 1);
tcg_gen_brcondi_i32(TCG_COND_NE, dc.next_icount, 0, label);
tcg_gen_mov_i32(dc.next_icount, cpu_SR[ICOUNT]);
if (dc.debug) {
gen_debug_exception(&dc, DEBUGCAUSE_IC);
}
gen_set_label(label);
}
if (dc.debug) {
gen_ibreak_check(env, &dc);
}
disas_xtensa_insn(env, &dc);
++insn_count;
if (dc.icount) {
tcg_gen_mov_i32(cpu_SR[ICOUNT], dc.next_icount);
}
if (cs->singlestep_enabled) {
tcg_gen_movi_i32(cpu_pc, dc.pc);
gen_exception(&dc, EXCP_DEBUG);
break;
}
} while (dc.is_jmp == DISAS_NEXT &&
insn_count < max_insns &&
dc.pc < next_page_start &&
dc.pc + xtensa_insn_len(env, &dc) <= next_page_start &&
tcg_ctx.gen_opc_ptr < gen_opc_end);
reset_litbase(&dc);
reset_sar_tracker(&dc);
if (dc.icount) {
tcg_temp_free(dc.next_icount);
}
if (tb->cflags & CF_LAST_IO) {
gen_io_end();
}
if (dc.is_jmp == DISAS_NEXT) {
gen_jumpi(&dc, dc.pc, 0);
}
gen_tb_end(tb, insn_count);
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(env, pc_start, dc.pc - pc_start, 0);
qemu_log("\n");
}
#endif
if (search_pc) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
memset(tcg_ctx.gen_opc_instr_start + lj + 1, 0,
(j - lj) * sizeof(tcg_ctx.gen_opc_instr_start[0]));
} else {
tb->size = dc.pc - pc_start;
tb->icount = insn_count;
}
}
| 1threat |
static int rv20_decode_picture_header(RVDecContext *rv)
{
MpegEncContext *s = &rv->m;
int seq, mb_pos, i;
int rpr_bits;
#if 0
GetBitContext gb= s->gb;
for(i=0; i<64; i++){
av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&gb));
if(i%4==3) av_log(s->avctx, AV_LOG_DEBUG, " ");
}
av_log(s->avctx, AV_LOG_DEBUG, "\n");
#endif
#if 0
av_log(s->avctx, AV_LOG_DEBUG, "%3dx%03d/%02Xx%02X ", s->width, s->height, s->width/4, s->height/4);
for(i=0; i<s->avctx->extradata_size; i++){
av_log(s->avctx, AV_LOG_DEBUG, "%02X ", ((uint8_t*)s->avctx->extradata)[i]);
if(i%4==3) av_log(s->avctx, AV_LOG_DEBUG, " ");
}
av_log(s->avctx, AV_LOG_DEBUG, "\n");
#endif
i= get_bits(&s->gb, 2);
switch(i){
case 0: s->pict_type= AV_PICTURE_TYPE_I; break;
case 1: s->pict_type= AV_PICTURE_TYPE_I; break;
case 2: s->pict_type= AV_PICTURE_TYPE_P; break;
case 3: s->pict_type= AV_PICTURE_TYPE_B; break;
default:
av_log(s->avctx, AV_LOG_ERROR, "unknown frame type\n");
return -1;
}
if(s->last_picture_ptr==NULL && s->pict_type==AV_PICTURE_TYPE_B){
av_log(s->avctx, AV_LOG_ERROR, "early B pix\n");
return -1;
}
if (get_bits1(&s->gb)){
av_log(s->avctx, AV_LOG_ERROR, "reserved bit set\n");
return -1;
}
s->qscale = get_bits(&s->gb, 5);
if(s->qscale==0){
av_log(s->avctx, AV_LOG_ERROR, "error, qscale:0\n");
return -1;
}
if(RV_GET_MINOR_VER(rv->sub_id) >= 2)
s->loop_filter = get_bits1(&s->gb);
if(RV_GET_MINOR_VER(rv->sub_id) <= 1)
seq = get_bits(&s->gb, 8) << 7;
else
seq = get_bits(&s->gb, 13) << 2;
rpr_bits = s->avctx->extradata[1] & 7;
if(rpr_bits){
int f, new_w, new_h;
rpr_bits = FFMIN((rpr_bits >> 1) + 1, 3);
f = get_bits(&s->gb, rpr_bits);
if(f){
new_w= 4*((uint8_t*)s->avctx->extradata)[6+2*f];
new_h= 4*((uint8_t*)s->avctx->extradata)[7+2*f];
}else{
new_w= s->orig_width ;
new_h= s->orig_height;
}
if(new_w != s->width || new_h != s->height){
AVRational old_aspect = s->avctx->sample_aspect_ratio;
av_log(s->avctx, AV_LOG_DEBUG, "attempting to change resolution to %dx%d\n", new_w, new_h);
if (av_image_check_size(new_w, new_h, 0, s->avctx) < 0)
return -1;
ff_MPV_common_end(s);
if (!old_aspect.num)
old_aspect = (AVRational){1, 1};
if (2 * new_w * s->height == new_h * s->width)
s->avctx->sample_aspect_ratio = av_mul_q(old_aspect, (AVRational){2, 1});
if (new_w * s->height == 2 * new_h * s->width)
s->avctx->sample_aspect_ratio = av_mul_q(old_aspect, (AVRational){1, 2});
avcodec_set_dimensions(s->avctx, new_w, new_h);
s->width = new_w;
s->height = new_h;
if (ff_MPV_common_init(s) < 0)
return -1;
}
if(s->avctx->debug & FF_DEBUG_PICT_INFO){
av_log(s->avctx, AV_LOG_DEBUG, "F %d/%d\n", f, rpr_bits);
}
} else if (av_image_check_size(s->width, s->height, 0, s->avctx) < 0)
return AVERROR_INVALIDDATA;
mb_pos = ff_h263_decode_mba(s);
seq |= s->time &~0x7FFF;
if(seq - s->time > 0x4000) seq -= 0x8000;
if(seq - s->time < -0x4000) seq += 0x8000;
if(seq != s->time){
if(s->pict_type!=AV_PICTURE_TYPE_B){
s->time= seq;
s->pp_time= s->time - s->last_non_b_time;
s->last_non_b_time= s->time;
}else{
s->time= seq;
s->pb_time= s->pp_time - (s->last_non_b_time - s->time);
if(s->pp_time <=s->pb_time || s->pp_time <= s->pp_time - s->pb_time || s->pp_time<=0){
av_log(s->avctx, AV_LOG_DEBUG, "messed up order, possible from seeking? skipping current b frame\n");
return FRAME_SKIPPED;
}
ff_mpeg4_init_direct_mv(s);
}
}
s->no_rounding= get_bits1(&s->gb);
if(RV_GET_MINOR_VER(rv->sub_id) <= 1 && s->pict_type == AV_PICTURE_TYPE_B)
skip_bits(&s->gb, 5);
s->f_code = 1;
s->unrestricted_mv = 1;
s->h263_aic= s->pict_type == AV_PICTURE_TYPE_I;
s->modified_quant=1;
if(!s->avctx->lowres)
s->loop_filter=1;
if(s->avctx->debug & FF_DEBUG_PICT_INFO){
av_log(s->avctx, AV_LOG_INFO, "num:%5d x:%2d y:%2d type:%d qscale:%2d rnd:%d\n",
seq, s->mb_x, s->mb_y, s->pict_type, s->qscale, s->no_rounding);
}
assert(s->pict_type != AV_PICTURE_TYPE_B || !s->low_delay);
return s->mb_width*s->mb_height - mb_pos;
}
| 1threat |
The activity not responding in the android studio : I have been working on developing an application which needed login and signup screen. My register activity is not working peoperly. The application is unable to take user from the start screen to the register activity, first the error arose of absence of intent filter then I included the intent filter in the manifest file but it seems like my app is ignoring the register activity. I am attaching both manifest file and the activity code please have a look.[enter image description here][1]
[enter image description here][2]
[enter image description here][3]
[1]: https://i.stack.imgur.com/etRTO.png
[2]: https://i.stack.imgur.com/BB6TA.png
[3]: https://i.stack.imgur.com/z7Koe.png | 0debug |
Significance of Application Insights csproj file modifications : <p>When I use the "Add Application Insights Telemetry..." menu option available from right-clicking an ASP.NET application in the Solution Explorer in Visual Studio to point an application to an existing Application Insights resource, the resulting file changes include the addition of two items to the <code>.csproj</code> file:</p>
<pre><code><ApplicationInsightsResourceId>/subscriptions/$guid/resourcegroups/$rgname>/providers/microsoft.insights/components/$name</ApplicationInsightsResourceId>
<ApplicationInsightsAnnotationResourceId>/subscriptions/$guid/resourcegroups/$rgname/providers/microsoft.insights/components/$name</ApplicationInsightsAnnotationResourceId>
</code></pre>
<p>I have elided some information - <code>$guid</code> is the Azure subscription GUID and <code>$rgname</code> and <code>$name</code> are the names given to the Application Insights resource group and resource respectively.</p>
<ol>
<li><p>What is the difference between each element? They seem to have the same information.</p></li>
<li><p>If I want to send telemetry to different Application Insights resources in difference environments, the documentation tells me I need to set the instrumentation key for each environment in code - which is fine - but what about these settings? Are they used for anything other than driving the context-sensitive menu options in Visual Studio? Do I need to worry about them in other environments?</p></li>
</ol>
| 0debug |
static int multiple_resample(ResampleContext *c, AudioData *dst, int dst_size, AudioData *src, int src_size, int *consumed){
int i, ret= -1;
int av_unused mm_flags = av_get_cpu_flags();
int need_emms = c->format == AV_SAMPLE_FMT_S16P && ARCH_X86_32 &&
(mm_flags & (AV_CPU_FLAG_MMX2 | AV_CPU_FLAG_SSE2)) == AV_CPU_FLAG_MMX2;
int64_t max_src_size = (INT64_MAX/2 / c->phase_count) / c->src_incr;
if (c->compensation_distance)
dst_size = FFMIN(dst_size, c->compensation_distance);
src_size = FFMIN(src_size, max_src_size);
for(i=0; i<dst->ch_count; i++){
ret= swri_resample(c, dst->ch[i], src->ch[i],
consumed, src_size, dst_size, i+1==dst->ch_count);
}
if(need_emms)
emms_c();
if (c->compensation_distance) {
c->compensation_distance -= ret;
if (!c->compensation_distance) {
c->dst_incr = c->ideal_dst_incr;
c->dst_incr_div = c->dst_incr / c->src_incr;
c->dst_incr_mod = c->dst_incr % c->src_incr;
}
}
return ret;
}
| 1threat |
feed data into a tf.contrib.data.Dataset like a queue : <p>About the <code>tf.contrib.data.Dataset</code> (from TensorFlow 1.2, see <a href="https://www.tensorflow.org/versions/r1.2/api_docs/python/tf/contrib/data" rel="noreferrer">here</a> and <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/data/README.md" rel="noreferrer">here</a>) usage:
The way how to get data doesn't really fit any way how I get the data usually. In my case, I have a thread and I receive data there and I don't know in advance when it will end but I see when it ends. Then I wait until I processed all the buffers and then I have finished one epoch. How can I get this logic with the <code>Dataset</code>?</p>
<p>Note that I prefer the <code>Dataset</code> interface over the <code>QueueBase</code> interface because it gives me the iterator interface which I can reinitialize and even reset to a different <code>Dataset</code>. This is more powerful compared to queues which cannot be reopened currently after they are closed (see <a href="https://stackoverflow.com/questions/41187745/tensorflow-how-can-i-evaluate-a-validation-data-queue-multiple-times-during-tra">here</a> and <a href="https://github.com/tensorflow/tensorflow/issues/4535" rel="noreferrer">here</a>).</p>
<p>Maybe a similar question, or the same question: How can I wrap around a <code>Dataset</code> over a queue? I have some thread with reads some data from somewhere and which can feed it and queue it somehow. How do I get the data into the <code>Dataset</code>? I could repeat some dummy tensor infinite times and then use <code>map</code> to just return my <code>queue.dequeue()</code> but that really only gets me back to all the original problems with the queue, i.e. how to reopen the queue.</p>
| 0debug |
How to disable sparse checkout after enabled? : <p>I enabled a sparse checkout </p>
<pre><code>git init
git remote add <url>
git config --global core.sparseCheckout true
echo "assets" >> .git/info/sparse-checkout
git pull origin master
</code></pre>
<p>Git checked out only the assets folder for me</p>
<p>But now, I want to enable full branch checkout again (checkout folders/files), but it doesn't seem to work.</p>
<p>1) first I disabled config </p>
<pre><code>git config --global core.sparseCheckout false
</code></pre>
<p>2) removed the entries in .git/info/sparse-checkout</p>
<p>But git didn't checkout any of the other folders/files for me, it seems it is sticking to 'assets' folder.</p>
<p>Could anyone tell me how can I reset/disable this sparse checkout without creating a new repo.?</p>
| 0debug |
set position of row by own on SQL : <p>I have a result of SQL like this </p>
<pre><code>status || value
green 3
blue 39
pink 2
black 300
</code></pre>
<p>I want to change the row of blue and pink </p>
<p>I want to sort like this from <code>green, pink, blue, and black</code> for that row and value also
is that possible to the condition that row to be by own? </p>
<p>so the result will be like this </p>
<pre><code>status || value
green 3
pink 2
blue 39
black 300
</code></pre>
| 0debug |
Retrieve data for display in a specific format : <p>i have two mysql tables <code>order</code> and <code>orderitems</code>.<br>
now i want to display these data using angularjs on a separate monitor.<br>
My table structure:<br>
Table <code>order</code> contains <code>id, table_id, date_time</code><br>
Table <code>orderitems</code> contains <code>order_id, food_item, item_qty, dalivery</code><br></p>
<p>Now i want to display these data inside seperate html div's. <code>table_id</code> as Heading and <code>orderitems</code> as contents.<br></p>
<p>For that i want a data structure like this<br></p>
<pre><code>[{
table_id,
date_time,
items: [
{
food_item,
item_qty,
delivery
},
{
food_item,
item_qty,
delivery
}
]
}]
</code></pre>
<p><br>
So how do i make query using codeigniter or MySQL?</p>
| 0debug |
Linq to SQL: Inner select query and performance : Consider the following query, will it causes multiple trips to db to execute the inner select statement?
Table1.Select(x=> new{
x.T1_Name,
x.T1_Id,
x.Table2.Select(y=> new {
y.T2_Name,
y.T2_Value
}
}).ToList();
My guess is it would not since it's still an `IQueryable` and the whole query would be run on DB and the final result would be passed to client.
In `LinqPad` the inner query triggers multiple times. | 0debug |
Can you help me how to change the password in MVC PHP : this is my MODEL:
public function editNewPassword($data){
// $user_name = $data['user_name'];
$user_id = $data['id'];
$user_oldpass = $data['password'];
$user_newpass = $data['newpass'];
$sql = "UPDATE user SET password = '".md5($user_newpass)."' WHERE password = 'md5($user_oldpass)' ";
$query = $this->db->prepare($sql);
$query->execute();
}
public function getUser(){
return $this->db->select("SELECT * FROM 'users'");
}
This is my CONTROLLER:
function changePassword(){
if(isset ($_POST['edit_password'])){
$user_oldpass = ($_POST['user_oldpass']);
$user_id = ($_POST['user_id']);
$user_name = ($_POST['user_name']);
$user_newpass = ($_POST['user_newpass']);
$this->model->editNewPassword($data);
}
}
this is for my VIEW code:
<form role="form">
<!-- <input typ e="text" name="username" id="username" placeholder="Enter Your Username"><br> -->
<input type="text" name="old_password" id="old_password" placeholder="Enter Your Old Password"><br>
<input type="text" name="new_password" id="new_password" placeholder="Enter Your New Password"><br>
<input type="text" name="con_newpassword" id="con_newmpassword" placeholder="Enter Confirm Password"><br>
<span id='message'></span>
<input type="hidden" id="edit_password_id">
<button id="edit_password" style="background-color:#008000">Submit</button>
</form>
This is my javascript code:
$('#edit_password').on('click', function(){
// alert('Password changed successfully!')
var
user_id = $('#edit_password_id').val();
user_name = $('#username').val();
user_oldpass = $('#oldpassword').val();
user_newpass = $('#newpassword').val();
$.ajax({
url: URL+'changepassword/changePassword',
type: "post",
data: {
id : id,
name : name,
password : password,
newpass : newpass
},
success: function(response){
$('#edit_password_id').modal('toggle');
location.reload();
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
}
});
});
My problem is my password won't change even no error and I don't know where is the error to my code. if anyone know to solve this please help me
PS: I am new to this ;-) | 0debug |
Back to Top Button in footer : <p>i Have a Question About How To Create a Scroll Back To Top Button fixed in footer ?
like this one </p>
<p><a href="https://www.graphicsprings.com/" rel="nofollow noreferrer">Link </a></p>
<p><a href="https://i.stack.imgur.com/dqIua.png" rel="nofollow noreferrer">img</a></p>
| 0debug |
Rotate UIImage in swift : <p>I want to rotate UIImage in clockwise direction. But my current code do not perform function accurate some time it rotate and some time its skip rotation. I want my UIImage will continuously rotate clockwise on my action button.
Here is my current code:</p>
<pre><code>imageView.image = imageView.image!.imageRotatedByDegrees(angle, flip: false)
angle = angle + 90
if angle > 360{
angle = 0
}
</code></pre>
| 0debug |
please help hide yandex logo from map? yandex mapkit android : There is no method in the documentation that hides the logo from the map.
https://i.stack.imgur.com/ua4ns.jpg | 0debug |
php if else if statements : <p>I am trying to output the variable above to output in html so I can use to report status in one column of my html tables. I have the following code but it doesn't seem to be working because i keep getting the "unexprected" error. </p>
<pre><code><?php
$st = $row_all_students['mem_review_stat'];
if ($st == "Pending") {
echo "<span class="label label-info">Pending</span>";
} elseif ($st == "on hold") {
echo "<span class="label label-danger">Suspended</span>";
} else {
echo "<span class="label label-success">Reviewed</span>";
}
?>
</code></pre>
<p>Can someone help me with the right syntax please?
Thanks in advance!</p>
| 0debug |
static inline void acpi_build_tables_cleanup(AcpiBuildTables *tables, bool mfre)
{
void *linker_data = bios_linker_loader_cleanup(tables->linker);
if (mfre) {
g_free(linker_data);
}
g_array_free(tables->rsdp, mfre);
g_array_free(tables->table_data, mfre);
g_array_free(tables->tcpalog, mfre);
}
| 1threat |
static void scsi_req_xfer_mode(SCSIRequest *req)
{
switch (req->cmd.buf[0]) {
case WRITE_6:
case WRITE_10:
case WRITE_VERIFY:
case WRITE_12:
case WRITE_VERIFY_12:
case WRITE_16:
case WRITE_VERIFY_16:
case COPY:
case COPY_VERIFY:
case COMPARE:
case CHANGE_DEFINITION:
case LOG_SELECT:
case MODE_SELECT:
case MODE_SELECT_10:
case SEND_DIAGNOSTIC:
case WRITE_BUFFER:
case FORMAT_UNIT:
case REASSIGN_BLOCKS:
case SEARCH_EQUAL:
case SEARCH_HIGH:
case SEARCH_LOW:
case UPDATE_BLOCK:
case WRITE_LONG:
case WRITE_SAME:
case SEARCH_HIGH_12:
case SEARCH_EQUAL_12:
case SEARCH_LOW_12:
case MEDIUM_SCAN:
case SEND_VOLUME_TAG:
case WRITE_LONG_2:
case PERSISTENT_RESERVE_OUT:
case MAINTENANCE_OUT:
req->cmd.mode = SCSI_XFER_TO_DEV;
break;
default:
if (req->cmd.xfer)
req->cmd.mode = SCSI_XFER_FROM_DEV;
else {
req->cmd.mode = SCSI_XFER_NONE;
}
break;
}
}
| 1threat |
How to fix unchecked type cast : <p>I am having trouble with unchecked casting. I know this happens because <code>T</code> is an <code>Object</code> but not every <code>Object</code> is a <code>T</code>. My question is how would I fix this to implement <code>T</code> in <code>ArrayList<T></code> without suppressing warnings?</p>
<pre><code>public class AdjMatrix <T extends Object> implements Blah<T>
{
public T[] vertex;
public AdjMatrix()
{
this.vertex = (T[])(new Object[RANDOM_NUMBER]);
}
public ArrayList<T> neighbours(T vertLabel)
{
ArrayList<T> neighbours = new ArrayList<T>();
neighbours.add(vertex[SOME_NUMBER]);
return neighbours;
}
}
</code></pre>
<p>Thanks for you help!</p>
| 0debug |
Laravel Socialite Facebook error: "POST https://graph.facebook.com/oauth/access_token resulted in a `400 Bad Request` " : <p>I've made social login using <code>Laravel Socialite</code> for facebook and it was working fine. I haaven't changed anything and now it's not working. It shows this error when trying to login:</p>
<p><code>Client error:</code>POST <a href="https://graph.facebook.com/oauth/access_token" rel="noreferrer">https://graph.facebook.com/oauth/access_token</a><code>resulted in a</code>400 Bad Request<code>response:
{"error":{"message":"This IP can't make requests for that application.","type":"OAuthException","code":5,"fbtrace_id":"D (truncated...)</code></p>
<p>I haven't changed setting in my facebook app, nor in my code.
My code is the following:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>Route::get('login', ['as' =>'getLogin', 'uses'=>'Auth\AuthController@getLogin']);
Route::get('handleProviderCallback/{provider}', 'Auth\AuthController@handleProviderCallback');</code></pre>
</div>
</div>
</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>public function login($provider = false)
{
if(!$provider) {
$user = Input::all();
$auth_user = new AuthenticateUser();
$is_logged = $auth_user->findByEmailOrCreate($user, false);
if($is_logged) {
Session::put('user', Auth::user());
Session::put('user_id', Auth::user()->id);
Session::put('email', Auth::user()->email);
Session::put('name', Auth::user()->name);
return redirect()->intended('dashboard');
}
return redirect('/')->withInput()->with('error', 'Wrong username or password!');
}
return \Socialite::with('facebook')->redirect();
}
public function handleProviderCallback($provider=false) {
if(Input::has('code')) {
$user = \Socialite::with($provider)->user();
$auth_user = new AuthenticateUser();
$provider_user = $auth_user->findByEmailOrCreate($user, $provider);
Session::put("user", array($provider_user));
Session::put('user_id', $provider_user->id);
Session::put('email',$provider_user->email);
Session::put('name',$provider_user->name);
return redirect('dashboard');
}
}</code></pre>
</div>
</div>
</p>
<p>Problem appears in <code>handleProviderCallback</code> method in this line:</p>
<p><code>$user = \Socialite::with($provider)->user();</code>.</p>
<p>When I only dump this:
<code>$user = \Socialite::with($provider)</code></p>
<p>it shows data but when it is used like that to get user data it returns the error:</p>
<p><code>$user = \Socialite::with($provider)->user();</code></p>
<p>In <code>config/services.php</code> I've set settings like this example:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code> 'facebook' => [
'client_id' => 'my-client-id-from-fb-app',
'client_secret' => 'my-secret-code-from-fb-app',
'redirect' => 'http://my-example-domain/my-site/handleProviderCallback/facebook'
],</code></pre>
</div>
</div>
</p>
<p>In my facebook app I've set in settings:</p>
<p><code>App Domains: my-example-domain,
Privacy Policy URL: http://my-example-domain/my-site/,
Site URL: http://my-example-domain/my-site/handleProviderCallback/facebook,
Valid OAuth redirect URIs: http://my-example-domain/my-site/handleProviderCallback/facebook</code></p>
| 0debug |
Excel VBA saving Values : I'm writing on a little programm which selects a Employee out of an Employeepool with a seed. The Employees are defined by their names ("Thomas", "Christoph" etc.) and the image of the selected employee shows up in a userframe.
I'd like the programm to once selected a employee save his name for the hole day. So even if I restart the programm 2 hours later, the selected employee stays. On the next day the programm selects a new employee with the seed, who also stays selected the hole day.
Now my question is, how do I once a employee is selected, save his value for the hole day?
Example:
Start programm -> start seed -> selected employee: Thomas -> show Thomas' image
2 hours later:
Start programm -> selected employee: Thomas -> stil show Thomas' image
next day:
Start programm -> start seed -> selected employee: Christoph -> show Christoph image
If you have any ideas or helpfull answers i'd be very thankfull!!! | 0debug |
Search the position in column SQL : I am searching... and i don't find how i can now in sql what is the position of an item in the column.
When i use ROW_NUMBER() i get: ERROR: near "(": synthax error (code 1)
Other question how to know which item is in position 2 (or other number) in the column.
Thanks for your answer
| 0debug |
Python tkinter .get() error : I am trying to make a applycation on tkinter and when i try to output with .get() i get an missing argument error.
thats my code:
from tkinter import *
root = Tk()
root.title('Wiki Scrape')
root.geometry('640x640+0+0')
heading = Label(root, text = "WELCOME", font =('arial', 30, 'bold')).pack()
label1 = Label(root, text = 'Please type a link from Wikipedia: ', font=
('arial', 10, 'bold'), fg='black').place(x=10, y=200)
name = StringVar
entrybox = Entry(root, textvariable=name, width = 25,
bg='lightgrey').place(x=250, y=202)
def do_it():
print(name.get())
work = Button(root, text='Done', width=15, height=1,
command=do_it).place(x=400, y=198)
root.mainloop()
and thats the error i get
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\et400\AppData\Local\Programs\Python\Python36-
32\lib\tkinter\__init__.py", line 1699, in __call__
return self.func(*args)
File "C:/Users/et400/Downloads/Coding/Python/WebScraping/WikiScrape.py",
line 18, in do_it
print(name.get())
TypeError: get() missing 1 required positional argument: 'self'
Help ? | 0debug |
static void test_dummy_createcmdl(void)
{
QemuOpts *opts;
DummyObject *dobj;
Error *err = NULL;
const char *params = TYPE_DUMMY \
",id=dev0," \
"bv=yes,sv=Hiss hiss hiss,av=platypus";
qemu_add_opts(&qemu_object_opts);
opts = qemu_opts_parse(&qemu_object_opts, params, true, &err);
g_assert(err == NULL);
g_assert(opts);
dobj = DUMMY_OBJECT(user_creatable_add_opts(opts, &err));
g_assert(err == NULL);
g_assert(dobj);
g_assert_cmpstr(dobj->sv, ==, "Hiss hiss hiss");
g_assert(dobj->bv == true);
g_assert(dobj->av == DUMMY_PLATYPUS);
user_creatable_del("dev0", &err);
g_assert(err == NULL);
error_free(err);
}
| 1threat |
VBA code to add blank row above specific text : Need help to add a blank row on a file above the word "Costumer". Found the below one but can't make it work on the specific worksheet on the workbook. thanks in advance
Dim c As Range
For Each c In Range("A:A")
If c.Value Like "Customer account" Then
c.Offset(1, 0).EntireRow.Insert
End If
Next c | 0debug |
Strange chars printed on exceeding bounds of undefined length char array : <p>I am pretty new to C and I have tried the following code</p>
<pre><code>#include <stdio.h>
int main ()
{
char str[] = "a";
for(int x = 0; x < 20; x++)
{
printf("%c\t%d\n", str[x],str[x]);
}
return 0;
}
</code></pre>
<p>For which I get the following output</p>
<pre><code>a 97
0
0
s 115
< 60
� -62
) 41
P 80
� -42
� -128
0 48
� -41
> 62
� -119
� -88
U 85
0
0
� -105
� -85
</code></pre>
<p>After <code>str[2]</code> the chars are random for each execution, can someone please explain this behavior.</p>
| 0debug |
how do I use f-string with regex in Python : <p>This code works if I use raw strings only but as soon as I add f to r. It stops working. Is there a way to make f-strings work with raw strings for re?</p>
<pre><code>import re
lines = '''
04/20/2009; 04/20/09; 4/20/09; 4/3/09
Mar-20-2009; Mar 20, 2009; March 20, 2009; Mar. 20, 2009; Mar 20 2009;
20 Mar 2009; 20 March 2009; 20 Mar. 2009; 20 March, 2009
Mar 20th, 2009; Mar 21st, 2009; Mar 22nd, 2009
Feb 2009; Sep 2009; Oct 2010
6/2008; 12/2009
2009; 2010
'''
rmonth = 'a'
regex = fr'(\d{1,2})/(\d{1,2})/(\d{4}|\d{2})'
date_found = re.findall(regex, lines)
date_found
</code></pre>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.