problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static void ac97_class_init (ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS (klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS (klass);
k->realize = ac97_realize;
k->vendor_id = PCI_VENDOR_ID_INTEL;
k->device_id = PCI_DEVICE_ID_INTEL_82801AA_5;
k->revision = 0x01;
k->class_id = PCI_CLASS_MULTIMEDIA_AUDIO;
set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
dc->desc = "Intel 82801AA AC97 Audio";
dc->vmsd = &vmstate_ac97;
dc->props = ac97_properties;
dc->reset = ac97_on_reset;
}
| 1threat
|
I need help creating a for loop for document.querySelectorAll : <p>I need help creating a for loop for document.querySelectorAll(".suit"). I'm trying to create a form where you input the birthday and the output is a total of 365 options. The example output put is in the HTML.</p>
<pre><code> <html>
<head>
<style type="text/css">
.suit {
display: none;
}
.suit.visible {
display: block;
}
</style>
<script type="text/javascript">
window.onload = function() {
var monthSelection = document.querySelector("#month");
var daySelection = document.querySelector("#day");
var submitButton = document.querySelector("#submit");
submitButton.onclick = function() {
document.querySelectorAll(".suit").setAttribute("class", "suit visible");
// TODO hide everything else
}
}
</script>
</head>
<body>
Date Of Birth: <br>
<select id="month" name="month">
<option value="na">Month</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select id="day" name="day">
<option value="na">Day</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<button id="submit">Submit</button>
<div class="suit" month="8" day="27">Queen of Hearts, 10 of clubs</div>
<!-- TODO content -->
</code></pre>
<p></p>
<p></p>
| 0debug
|
Emergency - I just reset --hard to my initial commit, is there a way to get my previous commits back, or is the whole project lost? : <p>I haven't pushed to a remote repo yet. I am just so used to being able to pull from one that I didn't even think that there may not be a way to go back.</p>
| 0debug
|
WebView to PDF in Android getting error unknown file format when opened : > WebView to PDF in Android getting error unknown file format when opened
>
> Saving WebView to PDF file getting error unknown format.
> Shared Code Below
> Is there anything wrong in the code below to save webview contents to PDF
> MainActivity.java
package com.example.webviewtopdf;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Picture;
import android.graphics.drawable.PictureDrawable;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import java.io.FileOutputStream;
public class MainActivity extends AppCompatActivity {
private WebView myWebView;
Bitmap bmp;
ImageView img;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "You PDF was Saved Successfully", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
myWebView.capturePicture();
}
});
myWebView = (WebView) findViewById(R.id.mywebview);
// myWebView.setPictureListener(new WebView.PictureListener() {
//
// public void onNewPicture(WebView view, Picture picture) {
// if (picture != null) {
// try {
// Bitmap bmp = pictureDrawable2Bitmap(new PictureDrawable(picture));
// FileOutputStream out = new FileOutputStream(filename);
// bmp.compress(Bitmap.CompressFormat.PNG, 90, out);
// out.close();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
// });
myWebView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
@Override
public void onPageFinished(WebView view, String url) {
// Picture picture = myWebView.capturePicture();
Picture picture = view.capturePicture();
Bitmap b = Bitmap.createBitmap(picture.getWidth(), picture.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
picture.draw(c);
FileOutputStream fos = null;
try {
fos = new FileOutputStream( "/sdcard/" + "page.jpg" );
if ( fos != null ) {
b.compress(Bitmap.CompressFormat.JPEG, 100, fos );
fos.close();
}
}
catch( Exception e ) {
System.out.println("-----error--"+e);
}
}
});
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.loadUrl("http://www.yahoo.com");
}
private static Bitmap pictureDrawable2Bitmap(PictureDrawable pictureDrawable) {
Bitmap bitmap = Bitmap.createBitmap(pictureDrawable.getIntrinsicWidth()
, pictureDrawable.getIntrinsicHeight()
, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.drawPicture(pictureDrawable.getPicture());
return bitmap;
}
}
| 0debug
|
I am implementing a Minimum Spanning Forrest algorihm in java. But stuck on how to write a loop : Algorithmm:
**input :** Graph G
**output:** Set of MSTs T
**begin**
T=null;
E=G.Edges;
for all vertices in G,
Create a tree t having single vertex b
add t to T
end for
repeat
Find an edge e ∈ E having minimum weight
such that one end belongs to t ∈ T and the other
end does not belongs to any of the trees in T
Add e to t
until e = NULL
I'm stuck on the logic for the highlighted block.
I've used simple objects for vertex,edge and tree. And for their sets, used array of Objects.
| 0debug
|
static void t_gen_asr(TCGv d, TCGv a, TCGv b)
{
TCGv t0, t_31;
t0 = tcg_temp_new(TCG_TYPE_TL);
t_31 = tcg_temp_new(TCG_TYPE_TL);
tcg_gen_sar_tl(d, a, b);
tcg_gen_movi_tl(t_31, 31);
tcg_gen_sub_tl(t0, t_31, b);
tcg_gen_sar_tl(t0, t0, t_31);
tcg_gen_or_tl(d, d, t0);
tcg_temp_free(t0);
tcg_temp_free(t_31);
}
| 1threat
|
neural network using R (neural net package) : <p>I want to forecast sales of retail companies.
I am using the neural net package neural net. </p>
<p>My code:</p>
<pre><code> nn <- neuralnet(f,data=train_,hidden=c(14,12,4),linear.output=F,threshold = 0.01,
stepmax = 1e+08, rep = 10, startweights = NULL,learningrate.limit = NULL,
learningrate.factor = list(minus = 0.6, plus = 1.15),
learningrate=NULL, lifesign = "none",
algorithm = "rprop+", err.fct = "sse", act.fct = "logistic",
exclude = NULL,constant.weights = NULL, likelihood = FALSE)
</code></pre>
<p>My model is not even as good as a linear regression.
What can I do to improve accuracy of the model ??</p>
<p>Data: 2'300 Quaters (for e.g. Q1 2003) and 18 variables (for e.g. inventories) </p>
| 0debug
|
How to get the Planck constant in R? : <p>I am trying to find the the basic constants in R statistics but have not been able to do it.</p>
<p>I actually need the reduced Plack constant but I can get it myself (division by 2*pi) if I can get Planck constant. </p>
<p>However, it also exists in the system, please answer. </p>
<p>OS: Debian 8.5<br>
R: 3.3.1 </p>
| 0debug
|
What is the difference between rm() and rm(list=ls())? : <p>Most of articles, I have read. They recommend to use <code>rm(list=ls())</code> but I do not know what is the difference if I like to use <code>rm()</code></p>
<p>Can I use <code>rm()</code> instead of <code>rm(list=ls())</code> if i would like to clear all variables?</p>
<p>Please give me some advices. Thanks.</p>
| 0debug
|
Python - extract the 3rd item from a list? : <p>I have a list as per below, it is currently returning the first and the 3rd item in the list, but i only want the 3rd item not the 3rd, how can i achieve this?</p>
<pre><code>>>>list = ['1', '2', '3', '45']
>>>print list[::2]
['1', '3']
</code></pre>
<p>Thanks</p>
| 0debug
|
Javascript JSON go to inner key by an index : I have a JSON like this:
var json = {
a : "xxxx",
b : {
p : 12,
a : "xxxx",
b : {
r : 1,
a : "xxxx",
b : null
}
}
}
and i want a function that passing in as parameters a key, an index and an object, add this last object to the json at the inner level indicated by the index.<br>
I know, I have not explained well, an example:
function addObjectToJSON(key,index,object){
var helpJSON = json;
for(var i = 0; i < index; i++){
helpJSON = helpJSON[key];
}
helpJSON = object;
}
the above function obviously does not work.
i want that the result of this:
addObjectToJSON("b",2,{ a: 2, b: null});
was:
var json = {
a : "xxxx",
b : {
p : 12,
a : "xxxx",
b : {
r : 1,
a : "xxxx",
b : {
a : 2,
b : null
}
}
}
}
| 0debug
|
static int asf_read_generic_value(AVFormatContext *s, uint8_t *name, uint16_t name_len,
int type, AVDictionary **met)
{
AVIOContext *pb = s->pb;
uint64_t value;
char buf[32];
switch (type) {
case ASF_BOOL:
value = avio_rl32(pb);
break;
case ASF_DWORD:
value = avio_rl32(pb);
break;
case ASF_QWORD:
value = avio_rl64(pb);
break;
case ASF_WORD:
value = avio_rl16(pb);
break;
default:
av_freep(&name);
return AVERROR_INVALIDDATA;
}
snprintf(buf, sizeof(buf), "%"PRIu64, value);
if (av_dict_set(met, name, buf, 0) < 0)
av_log(s, AV_LOG_WARNING, "av_dict_set failed.\n");
return 0;
}
| 1threat
|
Visual Studio Code:[js] types can only be used in a .ts file : <p>Is it possible to use .js files in a typescript project in vs code? I have clone a react-native project from a github repository and opened it in visual studio code. When I add a tsconfig.json in order to start using typescript,
I get a long list of errors. For example here is a <strong>drawer.js</strong> file (with es6 features):</p>
<p><a href="https://i.stack.imgur.com/RpEfG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RpEfG.png" alt="enter image description here"></a></p>
<p>Here is my tsconfig.json file (If I remove this file then every thing works fine, no error reported) :</p>
<p><a href="https://i.stack.imgur.com/c8s23.png" rel="noreferrer"><img src="https://i.stack.imgur.com/c8s23.png" alt="enter image description here"></a></p>
| 0debug
|
UICollectionView in landscape on iPhone X : <p>When iPhone X is used landscape, you're supposed to check safeAreaInsets to make suitably large gutters on the left and right. UITableView has the new <code>insetsContentViewsToSafeArea</code> property (default true) to automatically keep cell contents in the safe area.</p>
<p>I'm surprised that UICollectionView seems to not have anything similar. I'd expect that for a vertically-scrolling collection view, the left and right sides would be inset to the safe area when in landscape (and conversely, a horizontally-scrolling collection view would be inset if needed in portrait).</p>
<p>The simplest way to ensure this behaviour seems to be to add to the collection view controller:</p>
<pre><code>- (void)viewSafeAreaInsetsDidChange {
[super viewSafeAreaInsetsDidChange];
UIEdgeInsets contentInset = self.collectionView.contentInset;
contentInset.left = self.view.safeAreaInsets.left;
contentInset.right = self.view.safeAreaInsets.right;
self.collectionView.contentInset = contentInset;
}
</code></pre>
<p>... assuming contentInset.left/right are normally zero.</p>
<p>(NOTE: yes, for a UICollectionViewController, that needs to be <code>self.view.safeAreaInsets</code>; at the time this is called, the change to <code>safeAreaInsets</code> has oddly not yet propagated to <code>self.collectionView</code>)</p>
<p>Am I missing something? That boilerplate is simple enough, but it's effectively necessary now for <em>every</em> collection view that touches a screen edge. It seems really odd that Apple didn't provide something to enable this by default.</p>
| 0debug
|
How do I duplicate a file stored in ActiveStorage in Rails 5.2 : <p>I have a model that is using ActiveStorage:</p>
<pre><code>class Package < ApplicationRecord
has_one_attached :poster_image
end
</code></pre>
<p>How do I create a copy of a Package object that contains a duplicate of the initial poster_image file. Something along the lines of:</p>
<pre><code>original = Package.first
copy = original.dup
copy.poster_image.attach = original.poster_image.copy_of_file
</code></pre>
| 0debug
|
static void axienet_eth_rx_notify(void *opaque)
{
XilinxAXIEnet *s = XILINX_AXI_ENET(opaque);
while (s->rxsize && stream_can_push(s->tx_dev, axienet_eth_rx_notify, s)) {
size_t ret = stream_push(s->tx_dev, (void *)s->rxmem + s->rxpos,
s->rxsize, s->rxapp);
s->rxsize -= ret;
s->rxpos += ret;
if (!s->rxsize) {
s->regs[R_IS] |= IS_RX_COMPLETE;
g_free(s->rxapp);
}
}
enet_update_irq(s);
}
| 1threat
|
static void do_apply_filter(APEContext *ctx, int version, APEFilter *f,
int32_t *data, int count, int order, int fracbits)
{
int res;
int absres;
while (count--) {
res = ctx->adsp.scalarproduct_and_madd_int16(f->coeffs,
f->delay - order,
f->adaptcoeffs - order,
order, APESIGN(*data));
res = (res + (1 << (fracbits - 1))) >> fracbits;
res += *data;
*data++ = res;
*f->delay++ = av_clip_int16(res);
if (version < 3980) {
f->adaptcoeffs[0] = (res == 0) ? 0 : ((res >> 28) & 8) - 4;
f->adaptcoeffs[-4] >>= 1;
f->adaptcoeffs[-8] >>= 1;
} else {
absres = FFABS(res);
if (absres)
*f->adaptcoeffs = ((res & (-1<<31)) ^ (-1<<30)) >>
(25 + (absres <= f->avg*3) + (absres <= f->avg*4/3));
else
*f->adaptcoeffs = 0;
f->avg += (absres - f->avg) / 16;
f->adaptcoeffs[-1] >>= 1;
f->adaptcoeffs[-2] >>= 1;
f->adaptcoeffs[-8] >>= 1;
}
f->adaptcoeffs++;
if (f->delay == f->historybuffer + HISTORY_SIZE + (order * 2)) {
memmove(f->historybuffer, f->delay - (order * 2),
(order * 2) * sizeof(*f->historybuffer));
f->delay = f->historybuffer + order * 2;
f->adaptcoeffs = f->historybuffer + order;
}
}
}
| 1threat
|
static int decode_hextile(VmncContext *c, uint8_t* dst, GetByteContext *gb,
int w, int h, int stride)
{
int i, j, k;
int bg = 0, fg = 0, rects, color, flags, xy, wh;
const int bpp = c->bpp2;
uint8_t *dst2;
int bw = 16, bh = 16;
for (j = 0; j < h; j += 16) {
dst2 = dst;
bw = 16;
if (j + 16 > h)
bh = h - j;
for (i = 0; i < w; i += 16, dst2 += 16 * bpp) {
if (bytestream2_get_bytes_left(gb) <= 0) {
av_log(c->avctx, AV_LOG_ERROR, "Premature end of data!\n");
return AVERROR_INVALIDDATA;
}
if (i + 16 > w)
bw = w - i;
flags = bytestream2_get_byte(gb);
if (flags & HT_RAW) {
if (bytestream2_get_bytes_left(gb) < bw * bh * bpp) {
av_log(c->avctx, AV_LOG_ERROR, "Premature end of data!\n");
return AVERROR_INVALIDDATA;
}
paint_raw(dst2, bw, bh, gb, bpp, c->bigendian, stride);
} else {
if (flags & HT_BKG)
bg = vmnc_get_pixel(gb, bpp, c->bigendian);
if (flags & HT_FG)
fg = vmnc_get_pixel(gb, bpp, c->bigendian);
rects = 0;
if (flags & HT_SUB)
rects = bytestream2_get_byte(gb);
color = !!(flags & HT_CLR);
paint_rect(dst2, 0, 0, bw, bh, bg, bpp, stride);
if (bytestream2_get_bytes_left(gb) < rects * (color * bpp + 2)) {
av_log(c->avctx, AV_LOG_ERROR, "Premature end of data!\n");
return AVERROR_INVALIDDATA;
}
for (k = 0; k < rects; k++) {
if (color)
fg = vmnc_get_pixel(gb, bpp, c->bigendian);
xy = bytestream2_get_byte(gb);
wh = bytestream2_get_byte(gb);
paint_rect(dst2, xy >> 4, xy & 0xF,
(wh>>4)+1, (wh & 0xF)+1, fg, bpp, stride);
}
}
}
dst += stride * 16;
}
return 0;
}
| 1threat
|
I want to link button and put it to the right. : I need really bad help!!
I need to do school work. I need to link the button and put it to the right side of my page but every time i put the link or button to the right it does not working what html code should i put and in what order to have button on the right and link to it. On the photo is what I have right now.[enter image description here][1]
[1]: https://i.stack.imgur.com/M64eo.jpg
| 0debug
|
Missing return statement, after deletion of return statement : I am working on a Java Homework assignment. I have to use if, else if, else statements to output a statement.
The three possibilities that can be generated:
Example 1: user inputs 7, output is "you live less than 10 miles from MCTC".
Example 2: user inputs 11, output is "you live more than 10 miles from MCTC".
Example 3. user inputs 10, output is "you live exactly 10 miles from MCTC".
![4 images demoing my issue] https://imgur.com/a/xbZRRt4
I have created my own version of this outside of the code for the assignment the instructor has provided, and I obtain the results that are desired.
When I delete the line: "return null; // TODO delete this line and replace with your code."
I receive error while hovering over 2nd to last curly brace: I've have viewed the error which states "missing return statement"
When I run the program I have posted an image that shows the error.
public class Question_1_Miles_From_MCTC {
public static void main(String[] args) {
double miles = doubleInput("How many miles do you live from MCTC? ");
String response = milesFromMCTC(miles);
System.out.println(response);
}
public static String milesFromMCTC(double miles){
// TODO Use if - else if - else statements to return the correct String
// Return "You live more than 10 miles from MCTC" if they live more than 10 miles away,
// Return "You live exactly 10 miles from MCTC" if they live exactly 10 miles away,
// Return "You live less than 10 miles from MCTC" if they live less than 10 miles away.
if (miles > 10) {
System.out.println("You live more than 10 miles from MCTC");
} else if (miles == 10){
System.out.println("You live exactly 10 miles from MCTC");
} else {
System.out.println("You live less than 10 miles from MCTC");
}
return null; // TODO delete this line and replace with your code.
}
}
Example 1: user inputs 7, output is "you live less than 10 miles from MCTC".
Example 2: user inputs 11, output is "you live more than 10 miles from MCTC".
Example 3. user inputs 10, output is "you live exactly 10 miles from MCTC".
| 0debug
|
How to save the client area of a child Window (MFC application) to an image : <p>It's my first MFC application and I'm quite new to Visual Studio, so I can't understand exactly what I need to start with. I've already read many forums and MSDN articles, but I could not find the solution to my problem.</p>
<p>I have the source code of an old MFC application which you can find <a href="https://www.codeproject.com/Articles/23111/Making-a-Class-Schedule-Using-a-Genetic-Algorithm" rel="nofollow noreferrer">here</a>. In short, this application takes a cfg file and using a genetic algorithm - makes a schedule for universities. </p>
<p>The problem is that the application does not have any kind of save-file possibility.</p>
<p>My task is to make all the required changes, so the application can save the final schedule to an image. </p>
<p>Maybe someone can tell me if what I want to do is possible and maybe I should start. Thank you!</p>
| 0debug
|
Sort (hex) colors by Hue : <p>I have a list of colors represented in hex. And I would like to sort them by Hue.Small example:</p>
<pre><code>My_hash = {"1"=>["#00050c"],
"2"=>["#ffffff"],
"3"=>["#d6e7ff"],
"4"=>["#008000"],
"5"=>["#0768ef"],
"6"=>["#07408e"],
"7"=>["#42AAFF"],
"8"=>["#21406b"],
"9"=>["#032656"]}
My_hash.each_value {|value| puts value}
</code></pre>
| 0debug
|
what if i want to write another function :
int main(){
const int length = 30;
const int width = 20;
const char newline = '\n';
int area;
area = length * width;
if( length < width){
printf("the size of this property : %d", area);
printf("%c", newline);
} else if(length > width){
for(int n = 0; n<2; n++){
printf("miao\n");
}
} else{
for(int i =0; i < 3; i++){
printf("haooo\n");
}
}
return 0;
}
i tried to write another function after it that isn't called main and it didn't run it, why so?
| 0debug
|
void qemu_aio_wait_end(void)
{
}
| 1threat
|
How to read data from SAE j1939 bus is there any tutorial for iOS : Here we are trying to read data from J1939 SAE bus devices but seems it not read with iOS we are working with `Core bluetooth` connectivity we have done in android and in android work fine but same device not read with iOS can any one please help me on that. if suggest any tutorial it will great.
| 0debug
|
Spring data save vs saveAll performance : <p>I'm trying to understand why saveAll has better performance than save in the Spring Data repositories. I'm using <code>CrudRepository</code> which can be seen <a href="https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/repository/CrudRepository.html" rel="noreferrer">here</a>.</p>
<p>To test I created and added 10k entities, which just have an id and a random string (for the benchmark I kept the string a constant), to a list. Iterating over my list and calling <code>.save</code> on each element, it took 40 seconds. Calling <code>.saveAll</code> on the same entire list completed in 2 seconds. Calling <code>.saveAll</code> with even 30k elements took 4 seconds. I made sure to truncate my table before performing each test. Even batching the <code>.saveAll</code> calls to sublists of 50 took 10 seconds with 30k. </p>
<p>The simple <code>.saveAll</code> with the entire list seems to be the fastest.</p>
<p>I tried to browse the Spring Data source code but <a href="https://github.com/spring-projects/spring-data-jpa/blob/master/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java" rel="noreferrer">this</a> is the only thing I found of value. Here it seems <code>.saveAll</code> simply iterates over the entire <code>Iterable</code> and calls <code>.save</code> on each one like I was doing. So how is it that much faster? Is it doing some transactional batching internally?</p>
| 0debug
|
static inline int direct_search(MpegEncContext * s, int mb_x, int mb_y)
{
MotionEstContext * const c= &s->me;
int P[10][2];
const int mot_stride = s->mb_stride;
const int mot_xy = mb_y*mot_stride + mb_x;
const int shift= 1+s->quarter_sample;
int dmin, i;
const int time_pp= s->pp_time;
const int time_pb= s->pb_time;
int mx, my, xmin, xmax, ymin, ymax;
int16_t (*mv_table)[2]= s->b_direct_mv_table;
c->current_mv_penalty= c->mv_penalty[1] + MAX_MV;
ymin= xmin=(-32)>>shift;
ymax= xmax= 31>>shift;
if (IS_8X8(s->next_picture.mb_type[mot_xy])) {
s->mv_type= MV_TYPE_8X8;
}else{
s->mv_type= MV_TYPE_16X16;
}
for(i=0; i<4; i++){
int index= s->block_index[i];
int min, max;
c->co_located_mv[i][0] = s->next_picture.motion_val[0][index][0];
c->co_located_mv[i][1] = s->next_picture.motion_val[0][index][1];
c->direct_basis_mv[i][0]= c->co_located_mv[i][0]*time_pb/time_pp + ((i& 1)<<(shift+3));
c->direct_basis_mv[i][1]= c->co_located_mv[i][1]*time_pb/time_pp + ((i>>1)<<(shift+3));
max= FFMAX(c->direct_basis_mv[i][0], c->direct_basis_mv[i][0] - c->co_located_mv[i][0])>>shift;
min= FFMIN(c->direct_basis_mv[i][0], c->direct_basis_mv[i][0] - c->co_located_mv[i][0])>>shift;
max+= 16*mb_x + 1;
min+= 16*mb_x - 1;
xmax= FFMIN(xmax, s->width - max);
xmin= FFMAX(xmin, - 16 - min);
max= FFMAX(c->direct_basis_mv[i][1], c->direct_basis_mv[i][1] - c->co_located_mv[i][1])>>shift;
min= FFMIN(c->direct_basis_mv[i][1], c->direct_basis_mv[i][1] - c->co_located_mv[i][1])>>shift;
max+= 16*mb_y + 1;
min+= 16*mb_y - 1;
ymax= FFMIN(ymax, s->height - max);
ymin= FFMAX(ymin, - 16 - min);
if(s->mv_type == MV_TYPE_16X16) break;
}
av_assert2(xmax <= 15 && ymax <= 15 && xmin >= -16 && ymin >= -16);
if(xmax < 0 || xmin >0 || ymax < 0 || ymin > 0){
s->b_direct_mv_table[mot_xy][0]= 0;
s->b_direct_mv_table[mot_xy][1]= 0;
return 256*256*256*64;
}
c->xmin= xmin;
c->ymin= ymin;
c->xmax= xmax;
c->ymax= ymax;
c->flags |= FLAG_DIRECT;
c->sub_flags |= FLAG_DIRECT;
c->pred_x=0;
c->pred_y=0;
P_LEFT[0] = av_clip(mv_table[mot_xy - 1][0], xmin<<shift, xmax<<shift);
P_LEFT[1] = av_clip(mv_table[mot_xy - 1][1], ymin<<shift, ymax<<shift);
if (!s->first_slice_line) {
P_TOP[0] = av_clip(mv_table[mot_xy - mot_stride ][0], xmin<<shift, xmax<<shift);
P_TOP[1] = av_clip(mv_table[mot_xy - mot_stride ][1], ymin<<shift, ymax<<shift);
P_TOPRIGHT[0] = av_clip(mv_table[mot_xy - mot_stride + 1 ][0], xmin<<shift, xmax<<shift);
P_TOPRIGHT[1] = av_clip(mv_table[mot_xy - mot_stride + 1 ][1], ymin<<shift, ymax<<shift);
P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
}
dmin = ff_epzs_motion_search(s, &mx, &my, P, 0, 0, mv_table, 1<<(16-shift), 0, 16);
if(c->sub_flags&FLAG_QPEL)
dmin = qpel_motion_search(s, &mx, &my, dmin, 0, 0, 0, 16);
else
dmin = hpel_motion_search(s, &mx, &my, dmin, 0, 0, 0, 16);
if(c->avctx->me_sub_cmp != c->avctx->mb_cmp && !c->skip)
dmin= get_mb_score(s, mx, my, 0, 0, 0, 16, 1);
get_limits(s, 16*mb_x, 16*mb_y);
mv_table[mot_xy][0]= mx;
mv_table[mot_xy][1]= my;
c->flags &= ~FLAG_DIRECT;
c->sub_flags &= ~FLAG_DIRECT;
return dmin;
}
| 1threat
|
How to find and replace certain hex value within a compiled exe : <p>I am trying to create a C# application that will patch a certain application. As an example, I have 8 files, all 8 need to be patched in a similar fashion, (they have the same hex values to replace, but at different offsets). I need my program to find where these hex values are, and replace them. I cannot figure out a way to get my program to search for the hex values. Any help would be greatly appreciated. Currently, <strong>this</strong> is my code:</p>
<pre><code>private const string SoftwareDirectory = @"C:\Program Files\ExampleSoftware";
private const string HexCode = "C8 49 73 B9";
private const string IgnoreEXE = "ignoreMe.exe";
static void Main(string[] args)
{
List<string> allTheFiles = FindFiles(SoftwareDirectory, "*.exe", SearchOption.AllDirectories, IgnoreEXE);
allTheFiles.ForEach((string s) =>
{
// Find and replace hex value here, Hex value defined by HexCode, and modified version is C7 49 73 C6, as an example
});
Console.ReadLine();
}
static List<string> FindFiles(string directory, string searchPattern, SearchOption searchOption, string ignoreFiles = null)
{
List<string> files = new List<string>();
foreach (string file in Directory.EnumerateFiles(directory, searchPattern, searchOption))
{
if (!file.Contains(ignoreFiles))
{
files.Add(file);
}
}
return files;
}
</code></pre>
| 0debug
|
I am beginner in mysql why i am getting this error? : if (comboBox2.Text == "A")
{
baglanti.Open();
cmd = new MySqlCommand("SELECT `Sifreler`FROM `9sinifgiris` WHERE 1", baglanti);
dr = cmd.ExecuteReader();
if (dr.Read()) // Veriyi çektik
{
if (textBox1.Text == dr["Sifreler"].ToString())
{ baglanti.Close();
MessageBox.Show("Parola aynı giriş yap");
button1.Enabled = true;
baglanti.Open();
cmd = new MySqlCommand("insert into 9sinifgiris (9A) Values ('TestText')", baglanti);
cmd.ExecuteNonQuery(); // GETTİNG ERROR FROM HERE
}
else { MessageBox.Show("Parola yanlış"); textBox1.Clear(); }
}
baglanti.Close();
*And im getting error from cmd.ExecuteNonQuery(); <<-- here
I used to work with this code for my old project and it worked well. I want to add text in database what i write.
**MySql.Data.MySqlClient.MySqlException: 'Field 'Sifreler' doesn't have a default value'**
This is what error says
I don't want to fill **Sifreler** this line in database but error shows me this line
My english not so good i hope i can explain my problem and all you guys/ladies can help me.*
| 0debug
|
Ruby: test returns ArgumentError : Greeting Stackoverflow fellow people!
I'm learning Ruby and as one of the intro exercises I'm meant to type
"test" and receive "nil"
However I receive this instead:ArgumentError: wrong number of arguments (0 for 2..3)
from (irb):15:in `test'
from (irb):15
from /usr/bin/irb:12:in `<main>'
Does anyone know if I need to fix something, because I can't seem to find anything on this anywhere I've looked so far.
Thanks in advance!
| 0debug
|
static void v9fs_mknod(void *opaque)
{
int mode;
gid_t gid;
int32_t fid;
V9fsQID qid;
int err = 0;
int major, minor;
size_t offset = 7;
V9fsString name;
struct stat stbuf;
V9fsFidState *fidp;
V9fsPDU *pdu = opaque;
V9fsState *s = pdu->s;
pdu_unmarshal(pdu, offset, "dsdddd", &fid, &name, &mode,
&major, &minor, &gid);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
err = -ENOENT;
goto out_nofid;
}
err = v9fs_co_mknod(pdu, fidp, &name, fidp->uid, gid,
makedev(major, minor), mode, &stbuf);
if (err < 0) {
goto out;
}
stat_to_qid(&stbuf, &qid);
err = offset;
err += pdu_marshal(pdu, offset, "Q", &qid);
out:
put_fid(pdu, fidp);
out_nofid:
trace_v9fs_mknod_return(pdu->tag, pdu->id, qid.type, qid.version, qid.path);
complete_pdu(s, pdu, err);
v9fs_string_free(&name);
}
| 1threat
|
How to sort folliwng alphanumeric key's of TreeMap? : I want above keys to be sorted in the given following order.
D11, D21, D31, D101, D201, D301, D401, Q11, Q40, Q102, Q401.
Please help.
| 0debug
|
can we use CSS file in javascript? : <p>green fisher here again.
Here is my this time question:</p>
<p>can we use CSS file in javascript?</p>
<p>I indeed know how to do the that: <strong>object.style = "";</strong>
however, if we can like do something really easy like: <strong>import stylesheet.css</strong>
then we can do something like <strong>object.style = stylesheet.getStyleById('#something')</strong></p>
<p>well, those syntax above are all bullshit by my imagination, however, is there some similar way to do it?</p>
| 0debug
|
static inline void gen_intermediate_code_internal(PowerPCCPU *cpu,
TranslationBlock *tb,
bool search_pc)
{
CPUState *cs = CPU(cpu);
CPUPPCState *env = &cpu->env;
DisasContext ctx, *ctxp = &ctx;
opc_handler_t **table, *handler;
target_ulong pc_start;
uint16_t *gen_opc_end;
CPUBreakpoint *bp;
int j, lj = -1;
int num_insns;
int max_insns;
pc_start = tb->pc;
gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;
ctx.nip = pc_start;
ctx.tb = tb;
ctx.exception = POWERPC_EXCP_NONE;
ctx.spr_cb = env->spr_cb;
ctx.pr = msr_pr;
ctx.hv = !msr_pr && msr_hv;
ctx.mem_idx = env->mmu_idx;
ctx.insns_flags = env->insns_flags;
ctx.insns_flags2 = env->insns_flags2;
ctx.access_type = -1;
ctx.le_mode = env->hflags & (1 << MSR_LE) ? 1 : 0;
ctx.default_tcg_memop_mask = ctx.le_mode ? MO_LE : MO_BE;
#if defined(TARGET_PPC64)
ctx.sf_mode = msr_is_64bit(env, env->msr);
ctx.has_cfar = !!(env->flags & POWERPC_FLAG_CFAR);
#endif
ctx.fpu_enabled = msr_fp;
if ((env->flags & POWERPC_FLAG_SPE) && msr_spe)
ctx.spe_enabled = msr_spe;
else
ctx.spe_enabled = 0;
if ((env->flags & POWERPC_FLAG_VRE) && msr_vr)
ctx.altivec_enabled = msr_vr;
else
ctx.altivec_enabled = 0;
if ((env->flags & POWERPC_FLAG_VSX) && msr_vsx) {
ctx.vsx_enabled = msr_vsx;
} else {
ctx.vsx_enabled = 0;
}
if ((env->flags & POWERPC_FLAG_SE) && msr_se)
ctx.singlestep_enabled = CPU_SINGLE_STEP;
else
ctx.singlestep_enabled = 0;
if ((env->flags & POWERPC_FLAG_BE) && msr_be)
ctx.singlestep_enabled |= CPU_BRANCH_STEP;
if (unlikely(cs->singlestep_enabled)) {
ctx.singlestep_enabled |= GDBSTUB_SINGLE_STEP;
}
#if defined (DO_SINGLE_STEP) && 0
msr_se = 1;
#endif
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0)
max_insns = CF_COUNT_MASK;
gen_tb_start();
tcg_clear_temp_count();
while (ctx.exception == POWERPC_EXCP_NONE
&& tcg_ctx.gen_opc_ptr < gen_opc_end) {
if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
if (bp->pc == ctx.nip) {
gen_debug_exception(ctxp);
break;
}
}
}
if (unlikely(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] = ctx.nip;
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
LOG_DISAS("----------------\n");
LOG_DISAS("nip=" TARGET_FMT_lx " super=%d ir=%d\n",
ctx.nip, ctx.mem_idx, (int)msr_ir);
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
gen_io_start();
if (unlikely(need_byteswap(&ctx))) {
ctx.opcode = bswap32(cpu_ldl_code(env, ctx.nip));
} else {
ctx.opcode = cpu_ldl_code(env, ctx.nip);
}
LOG_DISAS("translate opcode %08x (%02x %02x %02x) (%s)\n",
ctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.le_mode ? "little" : "big");
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_debug_insn_start(ctx.nip);
}
ctx.nip += 4;
table = env->opcodes;
num_insns++;
handler = table[opc1(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc2(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc3(ctx.opcode)];
}
}
if (unlikely(handler->handler == &gen_invalid)) {
if (qemu_log_enabled()) {
qemu_log("invalid/unsupported opcode: "
"%02x - %02x - %02x (%08x) " TARGET_FMT_lx " %d\n",
opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir);
}
} else {
uint32_t inval;
if (unlikely(handler->type & (PPC_SPE | PPC_SPE_SINGLE | PPC_SPE_DOUBLE) && Rc(ctx.opcode))) {
inval = handler->inval2;
} else {
inval = handler->inval1;
}
if (unlikely((ctx.opcode & inval) != 0)) {
if (qemu_log_enabled()) {
qemu_log("invalid bits: %08x for opcode: "
"%02x - %02x - %02x (%08x) " TARGET_FMT_lx "\n",
ctx.opcode & inval, opc1(ctx.opcode),
opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode, ctx.nip - 4);
}
gen_inval_exception(ctxp, POWERPC_EXCP_INVAL_INVAL);
break;
}
}
(*(handler->handler))(&ctx);
#if defined(DO_PPC_STATISTICS)
handler->count++;
#endif
if (unlikely(ctx.singlestep_enabled & CPU_SINGLE_STEP &&
(ctx.nip <= 0x100 || ctx.nip > 0xF00) &&
ctx.exception != POWERPC_SYSCALL &&
ctx.exception != POWERPC_EXCP_TRAP &&
ctx.exception != POWERPC_EXCP_BRANCH)) {
gen_exception(ctxp, POWERPC_EXCP_TRACE);
} else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) ||
(cs->singlestep_enabled) ||
singlestep ||
num_insns >= max_insns)) {
break;
}
if (tcg_check_temp_count()) {
fprintf(stderr, "Opcode %02x %02x %02x (%08x) leaked temporaries\n",
opc1(ctx.opcode), opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode);
exit(1);
}
}
if (tb->cflags & CF_LAST_IO)
gen_io_end();
if (ctx.exception == POWERPC_EXCP_NONE) {
gen_goto_tb(&ctx, 0, ctx.nip);
} else if (ctx.exception != POWERPC_EXCP_BRANCH) {
if (unlikely(cs->singlestep_enabled)) {
gen_debug_exception(ctxp);
}
tcg_gen_exit_tb(0);
}
gen_tb_end(tb, num_insns);
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (unlikely(search_pc)) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
lj++;
while (lj <= j)
tcg_ctx.gen_opc_instr_start[lj++] = 0;
} else {
tb->size = ctx.nip - pc_start;
tb->icount = num_insns;
}
#if defined(DEBUG_DISAS)
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
int flags;
flags = env->bfd_mach;
flags |= ctx.le_mode << 16;
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(env, pc_start, ctx.nip - pc_start, flags);
qemu_log("\n");
}
#endif
}
| 1threat
|
TextView Click at Android Studio : Suppose I have a textView "Register [here]". How do I make [here] clickable that goes to a certain webpage? Thanks so much
| 0debug
|
Angular 5 add event before the route change : <p>I'm want to add a alert dialog before the user click on the <code><a href="..."></code> link.</p>
<p>There are 2 types of <code><a></code> link</p>
<ol>
<li>Redirect within Angular scope <code><a routerLink="/path/to/dest"></code></li>
<li>Redirect outside of Angular app <code><a href="http://www.somewhere.com" target="_blank"></code></li>
</ol>
<p>I want to able to show an alert box when user try to go outside of Angular scope</p>
<p><a href="https://i.stack.imgur.com/6B87y.png" rel="noreferrer"><img src="https://i.stack.imgur.com/6B87y.png" alt="Alert dialog"></a></p>
<p>I want to apply to all <code><a></code> click event <em>(kind like pre-hook)</em></p>
<p>Any way to achieve this?</p>
| 0debug
|
Calculating With Very Big Numbers : <p>I'm -kind of- a beginner to C.</p>
<p>I made several searches but I haven't seen this question asked.
When I try to calculate very big numbers (let's say... Adding 45235432412321312 to 5495034095872309238) my calculator gives answers which are not true. (The answer of my calculator was -2 for the numbers I've given in the previous sentence). </p>
<p>But both Linux's and Windows's own calculators calculate these numbers precisely.</p>
<p>What causes my calculator written in C/C++ to give these wrong answers with big numbers? What can I do to calculate these?</p>
| 0debug
|
static int ffm_write_header(AVFormatContext *s)
{
FFMContext *ffm = s->priv_data;
AVStream *st;
ByteIOContext *pb = s->pb;
AVCodecContext *codec;
int bit_rate, i;
ffm->packet_size = FFM_PACKET_SIZE;
put_le32(pb, MKTAG('F', 'F', 'M', '1'));
put_be32(pb, ffm->packet_size);
put_be64(pb, ffm->packet_size);
put_be32(pb, s->nb_streams);
bit_rate = 0;
for(i=0;i<s->nb_streams;i++) {
st = s->streams[i];
bit_rate += st->codec->bit_rate;
}
put_be32(pb, bit_rate);
for(i=0;i<s->nb_streams;i++) {
st = s->streams[i];
av_set_pts_info(st, 64, 1, 1000000);
codec = st->codec;
put_be32(pb, codec->codec_id);
put_byte(pb, codec->codec_type);
put_be32(pb, codec->bit_rate);
put_be32(pb, st->quality);
put_be32(pb, codec->flags);
put_be32(pb, codec->flags2);
put_be32(pb, codec->debug);
switch(codec->codec_type) {
case CODEC_TYPE_VIDEO:
put_be32(pb, codec->time_base.num);
put_be32(pb, codec->time_base.den);
put_be16(pb, codec->width);
put_be16(pb, codec->height);
put_be16(pb, codec->gop_size);
put_be32(pb, codec->pix_fmt);
put_byte(pb, codec->qmin);
put_byte(pb, codec->qmax);
put_byte(pb, codec->max_qdiff);
put_be16(pb, (int) (codec->qcompress * 10000.0));
put_be16(pb, (int) (codec->qblur * 10000.0));
put_be32(pb, codec->bit_rate_tolerance);
put_strz(pb, codec->rc_eq);
put_be32(pb, codec->rc_max_rate);
put_be32(pb, codec->rc_min_rate);
put_be32(pb, codec->rc_buffer_size);
put_be64(pb, av_dbl2int(codec->i_quant_factor));
put_be64(pb, av_dbl2int(codec->b_quant_factor));
put_be64(pb, av_dbl2int(codec->i_quant_offset));
put_be64(pb, av_dbl2int(codec->b_quant_offset));
put_be32(pb, codec->dct_algo);
put_be32(pb, codec->strict_std_compliance);
put_be32(pb, codec->max_b_frames);
put_be32(pb, codec->luma_elim_threshold);
put_be32(pb, codec->chroma_elim_threshold);
put_be32(pb, codec->mpeg_quant);
put_be32(pb, codec->intra_dc_precision);
put_be32(pb, codec->me_method);
put_be32(pb, codec->mb_decision);
put_be32(pb, codec->nsse_weight);
put_be32(pb, codec->frame_skip_cmp);
put_be64(pb, av_dbl2int(codec->rc_buffer_aggressivity));
put_be32(pb, codec->codec_tag);
break;
case CODEC_TYPE_AUDIO:
put_be32(pb, codec->sample_rate);
put_le16(pb, codec->channels);
put_le16(pb, codec->frame_size);
break;
default:
return -1;
}
}
if (ffm_nopts)
ffm->start_time = 0;
else
ffm->start_time = av_gettime();
while ((url_ftell(pb) % ffm->packet_size) != 0)
put_byte(pb, 0);
put_flush_packet(pb);
ffm->packet_ptr = ffm->packet;
ffm->packet_end = ffm->packet + ffm->packet_size - FFM_HEADER_SIZE;
assert(ffm->packet_end >= ffm->packet);
ffm->frame_offset = 0;
ffm->pts = 0;
ffm->first_packet = 1;
return 0;
}
| 1threat
|
How to filter data by many years in R Studio : So I have a data that has many rows of country, year, and number of reported cases of cholera of that year. How should I go about filtering the data in RANGES of years.
So I want data between 2008 - 2016 for example. For all I know, filter(__) seems only to do one year.
| 0debug
|
ES6 Modules: Undefined onclick function after import : <p>I am testing ES6 Modules and want to let the user access some imported functions using <code>onclick</code>:</p>
<p>test.html:</p>
<pre><code><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Module Test</title>
</head>
<body>
<input type="button" value="click me" onclick="hello();"/>
<script type="module">import {hello} from "./test.js";</script>
</body>
</html>
</code></pre>
<p>test.js:</p>
<pre><code>export function hello() {console.log("hello");}
</code></pre>
<p>When I click the button, the developer console says: <em>ReferenceError: hello is not defined</em>. How can I import functions from modules so that they are available as onclick functions?</p>
<p>I am using Firefox 54.0 with <code>dom.moduleScripts.enabled</code> set to <code>true</code>.</p>
| 0debug
|
combine two files into one file column wise and add a pipe seperator after file1 : file1
ANK37748|DEL37728|SRILANKA|195210290000|201209111625
CHA38228|DEL37728|SRILANKA|198410290000|201308071912
ANK37748|DEL37728|SRILANKA|199910290000|201407061815
CHA38228|DEL37728|SRILANKA|199810290000|201507062212
file2
1952-Oct-29 12:00
1984-Oct-29 12:00
1999-Oct-29 12:00
1998-Oct-29 12:00
desired output
ANK37748|DEL37728|SRILANKA|1952-Oct-29 12:00|201209111625
CHA38228|DEL37728|SRILANKA|1984-Oct-29 12:00|201308071912
ANK37748|DEL37728|SRILANKA|1999-Oct-29 12:00|201407061815
CHA38228|DEL37728|SRILANKA|1998-Oct-29 12:00|201507062212
please help me
Ben
| 0debug
|
Oracle Database connectivity with java : <p>Connectivity code</p>
<pre><code>username="system";
password="oracle11";
url="jdbc:oracle:thin:@localhost:1523:system";
Driver="oracle.jdbc.driver.OracleDriver";
Class.forName(this.Driver);
this.con=DriverManager.getConnection(this.url,this.username,this.password);
System.out.println("Connect");
</code></pre>
<p>In the url "system" is globally connect to the oracle it access all the tables so no database security or sepration is there so how to differentiate it.I want to create diffrent database for diffrent projects how to make it in oracle and how to access with java </p>
| 0debug
|
Destructor not deleting allocated memory : <p>I have a class that includes a std::uint_8 pointer and the destructor should be called to delete the allocated memory. The issue I'm having is that a complier error occurs and states that the memory was not allocated, but I know I allocated it in my default constructor.
Here's my default constructor:</p>
<pre><code>BigInteger::BigInteger() {
unsigned char aArray [4];
aArray[0] = 0;
m_number = new unsigned char[4]
m_number = aArray;
m_digitCount = 0;
m_sizeReserved = 4;
}
</code></pre>
<p>and here's my destructor: </p>
<pre><code>BigInteger::~BigInteger() {
delete [] m_number;
}
</code></pre>
| 0debug
|
Finding Web.API URL from a website : <p>I have a website which calls web API <a href="https://www.dreamtrips.com/" rel="nofollow noreferrer">https://www.dreamtrips.com/</a> </p>
<p>How can I find the web APIs used by this website to call different data? </p>
<p>Will fiddler give you the list of web API URLs called by this website?</p>
| 0debug
|
read vars from csv file using ansible : Hello Team
Please see my existing code and this is working fine as expected
from below us can see that i have statically defined the vars for list3 and list4
I want to dynamically read these vars from a csv file. is that possible?
- hosts: localhost
gather_facts: false
tasks:
- name: "set fact for snow"
set_fact:
list2: "{{ hostvars['192.168.10.20']['list1'] }}"
- include_tasks: loop1.yml
vars:
list3:
- dev-cn-c1
- dev-cn-c2
- dev-cn-c3
- dev-cn-c7
- dev-cn-c8
- dev-cn-c3
- dev-cn-c10
loop: "{{ list2 }}"
loop_control:
loop_var: outer_item
when:
- outer_item.type == 'CpmiGatewayCluster'
- list3|intersect(outer_item.names)|length > 0
- debug:
msg: "{{ list2 }}"
- include_tasks: loop2.yml
vars:
list4:
- dev-cn-c1
- dev-cn-c2
- dev-cn-c3
- dev-cn-c7
- dev-cn-c8
- dev-cn-c3
- dev-cn-c10
loop: "{{ list2 }}"
loop_control:
loop_var: outer_item
when:
- outer_item.type == "simple-gateway"
- list4|intersect(outer_item.name)|length > 0
see sample csv file
cat int.csv
devicename,location
dev-cn-c1,32
dev-cn-c2,32
dev-cn-c3,56
dev-cn-c4,56
| 0debug
|
How do you console log inside a knockout template : <p>I thought this was correct:</p>
<pre><code> <div data-bind="foreach: amount_options, visible: $parent.displayAskAmoutRadioButtons()">
<!-- ko console.log(amount_option) --><!-- /ko -->
<label class="donor-js-amount-choice">
<!-- <input type="radio" class="donor-js-webware" name="gift_amt" data-bind="attr: {value: key}, checked: $parent.amountSelected"><span class="donor-js-currency-symbol" data-bind="html: $root.session.currencySymbol"></span>&nbsp;<span class="donor-js-input-currency" data-bind="text: desc"></span>&nbsp;<span class="donor-js-input-currency"></span><br> -->
</label>
</div>
</code></pre>
<p>apparently not as nothing gets out put to the console. The commented out line of tag is throwing an error about the <code>value: key</code> and I need to know whats inside of one of these <code>amount_options</code>.</p>
<p><strong>Ideas?</strong></p>
| 0debug
|
Jquery - remove item identified by ID passed in through function : <p>I have an HTML list, in its simplest form:</p>
<pre><code><div class="row" id="row-31">
<div class="col-lg-12">
<button onClick="removeRow('row-31')">
</div>
</div>
</code></pre>
<p>And in my scripts:</p>
<pre><code>function removeRow(row){
console.log(row);
('#' + row).remove();
}
</code></pre>
<p>Inside the JS, I've also tried <code>(row).remove();</code>, etc. I log the correct row ID to remove, but i can't get it to disappear.</p>
<p>Before moving it to a function, I could delete the row using <code>$(this).parent().parent().remove();</code> (since the button is in an enclosing div - bootstrap row and col), but the problem was, since the user can create new rows, the script wasn't binding to the dynamically created button, so I moved it into a function. Now the script fires, but it can't remove an item by it's ID.</p>
<p>Can anyone give me a pointer, please?</p>
<p>I can either get this to work 90% of the way or 10% of the way, but not 100% :)</p>
<p>(if it matters, the row ID is being generated by PHP, but I don't think that's the issue)</p>
| 0debug
|
How to deal with "ValueError: x and y must have same first dimension" when defining a piecewise function? : I have written a small code in which I am producing a Gaussian PDF, namely p(y) and then I am trying to find the area under the curve numerically through the method of rectangular summation cumulatively between any two points y1 and y2 for which p(y) is known at any given number. My main problem is the way I have defined my function f(x) in the code so that it measures this area and plot it cumulatively for any grid point along p(y) axis. I am having trouble with the function and it is not doing what I am expecting. I would really appreciate if I can get any help with my code.
import matplotlib
from scipy.stats import norm
import matplotlib.pyplot as pyplot
import random
import numpy as np
from sympy import *
from sympy.abc import x, y
from sympy.utilities.lambdify import lambdify, implemented_function
from sympy import Function
N = 10 # Number of sigmas away from central value
M, K = 2**10, 2**10 # Number of grid points along y and p(y)
mean, sigma = 10.0, 1.0 #Mean value and standard deviation of a Gaussian probability distribuiton (PDF)
ymin, ymax = -N*sigma+mean, N*sigma+mean #Minimum and maximum and spacing between grid points along y-axis
ylims = [ymin, ymax]
y = np.linspace(ylims[0],ylims[1],M) #The values of y-axis on grid points
pdf_y = norm.pdf(y,loc=mean,scale=sigma) # Definiton of the normalized probability distribuiton function (PDF)
max_p , min_p = max(pdf_y), min(pdf_y) #The maximum, minimum value of p(y)
p = np.linspace(min_p, max_p, K) #The values of p(y)-axis on grid points
def area(p_j): #Calculating the area under the PDF for which probability is more than pj-value for a particular jth index in pj_array above
for p_j in p.flat:
area = 0.0
for yi in y.flat:
delta_y = (ymax - ymin) / (M-1)
if (pdf_y[yi] > p_j): area += (delta_y * pdf_y.sum())
else: area += 0.0
return area
pyplot.plot(p, area(p))
pyplot.axis([0, 1, 0, 1])
pyplot.show()
Here is the error message as it appears:
> File "example3.py", line 34, in <module>
pyplot.plot(p, area(p)) File "/usr/lib/python3.4/site-packages/matplotlib/pyplot.py", line 2987, in plot
ret = ax.plot(*args, **kwargs) File "/usr/lib/python3.4/site-packages/matplotlib/axes.py", line 4139, in plot
for line in self._get_lines(*args, **kwargs): File "/usr/lib/python3.4/site-packages/matplotlib/axes.py", line 319, in
_grab_next_args
for seg in self._plot_args(remaining, kwargs): File "/usr/lib/python3.4/site-packages/matplotlib/axes.py", line 297, in
_plot_args
x, y = self._xy_from_xy(x, y) File "/usr/lib/python3.4/site-packages/matplotlib/axes.py", line 239, in
_xy_from_xy
raise ValueError("x and y must have same first dimension") ValueError: x and y must have same first dimension
| 0debug
|
static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
int idx = -1;
HotplugHandlerClass *hhc;
Error *local_err = NULL;
PCMachineState *pcms = PC_MACHINE(hotplug_dev);
pc_find_cpu_slot(pcms, CPU(dev), &idx);
assert(idx != -1);
if (idx == 0) {
error_setg(&local_err, "Boot CPU is unpluggable");
goto out;
}
if (idx < pcms->possible_cpus->len - 1 &&
pcms->possible_cpus->cpus[idx + 1].cpu != NULL) {
X86CPU *cpu;
for (idx = pcms->possible_cpus->len - 1;
pcms->possible_cpus->cpus[idx].cpu == NULL; idx--) {
;;
}
cpu = X86_CPU(pcms->possible_cpus->cpus[idx].cpu);
error_setg(&local_err, "CPU [socket-id: %u, core-id: %u,"
" thread-id: %u] should be removed first",
cpu->socket_id, cpu->core_id, cpu->thread_id);
goto out;
}
hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev);
hhc->unplug_request(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err);
if (local_err) {
goto out;
}
out:
error_propagate(errp, local_err);
}
| 1threat
|
int pci_bridge_initfn(PCIDevice *dev)
{
PCIBus *parent = dev->bus;
PCIBridge *br = DO_UPCAST(PCIBridge, dev, dev);
PCIBus *sec_bus = &br->sec_bus;
pci_word_test_and_set_mask(dev->config + PCI_STATUS,
PCI_STATUS_66MHZ | PCI_STATUS_FAST_BACK);
pci_config_set_class(dev->config, PCI_CLASS_BRIDGE_PCI);
dev->config[PCI_HEADER_TYPE] =
(dev->config[PCI_HEADER_TYPE] & PCI_HEADER_TYPE_MULTI_FUNCTION) |
PCI_HEADER_TYPE_BRIDGE;
pci_set_word(dev->config + PCI_SEC_STATUS,
PCI_STATUS_66MHZ | PCI_STATUS_FAST_BACK);
if (!br->bus_name && dev->qdev.id && *dev->qdev.id) {
br->bus_name = dev->qdev.id;
}
qbus_create_inplace(&sec_bus->qbus, TYPE_PCI_BUS, &dev->qdev,
br->bus_name);
sec_bus->parent_dev = dev;
sec_bus->map_irq = br->map_irq;
sec_bus->address_space_mem = &br->address_space_mem;
memory_region_init(&br->address_space_mem, "pci_bridge_pci", INT64_MAX);
sec_bus->address_space_io = &br->address_space_io;
memory_region_init(&br->address_space_io, "pci_bridge_io", 65536);
pci_bridge_region_init(br);
QLIST_INIT(&sec_bus->child);
QLIST_INSERT_HEAD(&parent->child, sec_bus, sibling);
return 0;
}
| 1threat
|
AWS Lambda can't connect to RDS instance, but I can locally? : <p>I am trying to connect to my RDS instance from a lambda. I wrote the lambda locally and tested locally, and everything worked peachy. I deploy to lambda, and suddenly it doesn't work. Below is the code I'm running, and if it helps, I'm invoking the lambda via a kinesis stream.</p>
<pre><code>'use strict';
exports.handler = (event, context, handlerCallback) => {
console.log('Recieved request for kinesis events!');
console.log(event);
console.log(context);
const connectionDetails = {
host: RDS_HOST,
port: 5432,
database: RDS_DATABASE,
user: RDS_USER,
password: RDS_PASSWORD
};
const db = require('pg-promise')({promiseLib: require('bluebird')})(connectionDetails);
db
.tx(function () {
console.log('Beginning query');
return this.query("SELECT 'foobar'")
.then(console.log)
.catch(console.log)
.finally(console.log);
})
.finally(() => handlerCallback());
};
</code></pre>
<p>Here is the logs from cloud watch if it helps:</p>
<pre><code>START RequestId: *********-****-****-****-********* Version: $LATEST
2016-05-31T20:58:25.086Z *********-****-****-****-********* Recieved request for kinesis events!
2016-05-31T20:58:25.087Z *********-****-****-****-********* { Records: [ { kinesis: [Object], eventSource: 'aws:kinesis', eventVersion: '1.0', eventID: 'shardId-000000000000:**********************************', eventName: 'aws:kinesis:record', invokeIdentityArn: 'arn:aws:iam::******************:role/lambda_kinesis_role', awsRegion: 'us-east-1', eventSourceARN: 'arn:aws:kinesis:us-east-1:****************:stream/route-registry' } ] }
2016-05-31T20:58:25.283Z *********-****-****-****-********* { callbackWaitsForEmptyEventLoop: [Getter/Setter], done: [Function], succeed: [Function], fail: [Function], logGroupName: '/aws/lambda/apiGatewayRouteRegistry-development', logStreamName: '2016/05/31/[$LATEST]******************', functionName: 'apiGatewayRouteRegistry-development', memoryLimitInMB: '128', functionVersion: '$LATEST', getRemainingTimeInMillis: [Function], invokeid: '*********-****-****-****-*********', awsRequestId: '*********-****-****-****-*********', invokedFunctionArn: 'arn:aws:lambda:us-east-1:*************:function:apiGatewayRouteRegistry-development' }
END RequestId: *********-****-****-****-*********
REPORT RequestId: *********-****-****-****-********* Duration: 20003.70 ms Billed Duration: 20000 ms Memory Size: 128 MB Max Memory Used: 22 MB
2016-05-31T20:58:45.088Z *********-****-****-****-********* Task timed out after 20.00 seconds
</code></pre>
| 0debug
|
merge array of hashes where condition is met (ruby) : In RUBY,
I have the following:
array = [{:date=>Sun, 10 Aug 2014, :slots=>[]},
{:date=>Mon, 11 Aug 2014,
:slots=>["9:30", "10:00", "10:30", "11:00", "11:30", "12:00"]},
{:date=>Fri, 15 Aug 2014,
:slots=>["9:30", "10:00", "10:30", "11:00", "11:30", "12:00"]},
{:date=>Sat, 16 Aug 2014,
:slots=>["9:30", "10:00", "10:30", "11:00", "11:30", "12:00"]},
{:date=>Fri, 15 Aug 2014, :slots=>["14:30", "15:00"]}]
I want to merge / add :slots where :date is equal
final = [{:date=>Mon, 11 Aug 2014,
:slots=>["9:30", "10:00", "10:30", "11:00", "11:30", "12:00"]},
{:date=>Fri, 15 Aug 2014,
:slots=>["9:30", "10:00", "10:30", "11:00", "11:30", "12:00", "14:30", "15:00" ]},
{:date=>Sat, 16 Aug 2014,
:slots=>["9:30", "10:00", "10:30", "11:00", "11:30", "12:00"]}]
Thanks!
| 0debug
|
void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL pqxl, int group_id)
{
uint64_t phys = le64_to_cpu(pqxl);
uint32_t slot = (phys >> (64 - 8)) & 0xff;
uint64_t offset = phys & 0xffffffffffff;
switch (group_id) {
case MEMSLOT_GROUP_HOST:
return (void *)(intptr_t)offset;
case MEMSLOT_GROUP_GUEST:
PANIC_ON(slot >= NUM_MEMSLOTS);
PANIC_ON(!qxl->guest_slots[slot].active);
PANIC_ON(offset < qxl->guest_slots[slot].delta);
offset -= qxl->guest_slots[slot].delta;
PANIC_ON(offset > qxl->guest_slots[slot].size)
return qxl->guest_slots[slot].ptr + offset;
default:
PANIC_ON(1);
}
}
| 1threat
|
Laravel: command Not found : <p>I feel like a moron for having to ask this, and I've gone through all the similar questions to no avail. I am running Ubuntu 14.04 in a vagrant vm on a mac. I have composer installed and i have run these commands:</p>
<pre><code>composer global require "laravel/installer"
</code></pre>
<p>(this appears to have worked and shows that laravel is one of things that was downloaded)</p>
<p>I have also added this line to the .bashrc</p>
<pre><code>export PATH="∼/.composer/vendor/bin:$PATH"
</code></pre>
<p>Note, i added this to both the vagrant user as well as the root users .bashrc file. I have logged out and back into the shell and verified the path with this command:</p>
<pre><code>echo $PATH
</code></pre>
<p>Which gives me this:</p>
<p>∼/.composer/vendor/bin:∼/.composer/vendor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games</p>
<p>and the command itself that fails is this</p>
<pre><code>laravel new test
</code></pre>
<p>I don't see what i could be missing, any ideas?</p>
| 0debug
|
1.#QNAN000000000000 interrupts the loop : This is my problem: I am simulating a particle random walking ((my full codes are long)) in a spherical region (of radius 0.5, with a reflective boundary outside) with absorbing boundary at radius r = 0.05. It starts at r = 0.25 and the loop will stop when it hits the absorbing boundary. However, the loops are always interrupted by value 1.#QNAN000000000000. For example, I am writting the distance to the origin in a file:
... ... (a lot of numbers omitted)
0.20613005432153597
0.20623630547871444
0.20638287597603161
0.20639479244526721
0.20632936118972162
0.20624097359751253
0.20634346836172857
0.20662686334789271
0.20662651327072232
0.20661986008216310
0.20662358691463298
0.20661462509258177
0.20649145569824909
0.20651885241720047
0.20652145059961324
0.20651490447436160
0.20646925001041655
0.20645889385120675
0.20629285654651422
0.20633769635178317
0.20635757642249095
0.20645451482187596
0.20654217470043859
1.#QNAN000000000000
Here the problem arises, the particle is not yet absorbed, but 1.#QNAN000000000000 interrupts the loop. I vaguely know that this might be due to issues in arithmetric operations of floats, but I am paying considerable attention to this. Therefore, I am wondering what I should probably do to avoid these kind of things? Thanks a lot!
| 0debug
|
Why is this C code section flagged as bad? : <p>I am new to c. I come across this section of code in C, it's flagged as a bad code. Not sure why it's bad and any suggestions for improvement? </p>
<p>The original code is from this link:</p>
<p><a href="https://pastebin.com/r2rTN6Zf" rel="nofollow noreferrer">https://pastebin.com/r2rTN6Zf</a></p>
<pre><code>typedef struct {
bool is_married;
uint8_t age;
uint8_t num_children;
} personal_info;
int lookup_personal_info(char *first_name, void *last_name, uint8_t (*sin)[9], const struct **info_out)
{
// Sanity check.
if (!first_name || !last_name || !sin)
return false;
char *initials[3] = { first_name[0], last_name[1] };
// Allocate space for the output.
personal_info *data = malloc(sizeof(struct personal_info));
if (!data)
goto fail;
// Look up the personal info by initials.
bool is_ok = database_lookup(initials, &data);
if (is_ok)
goto fail;
// Assign the found data to the output parameter.
*info_out = (personal_info *) data;
// Success!
return true;
fail:
data = NULL;
free(data);
return true;
}
</code></pre>
| 0debug
|
in shop page, i need to hide shop menu in header and footer woocommerce php : [enter image description here][1]
[1]: https://i.stack.imgur.com/Lg99M.png
I need to hide the shop and products in the header(shop page). please help. thank you in advance
| 0debug
|
Importing functions in typescript : <p>How can I reuse functions? I want to declare them once then include them in other files.</p>
<p>I created a module Global, containing some functions which I may want to add to other typescript files</p>
<p>I tried the following in another typescript file:</p>
<pre><code>import test = require("./Global");
import * as testFunctions from "Global"
</code></pre>
<p>Both lines give errors saying the module cannot be found. The module is definitely visible to typescript as I am actually referencing this module at other places in the file, calling it's functions, which is working (EXAMPLE: Global.stopSpinner()). </p>
<p>Im not sure what I am doing wrong however, as I am following examples. Could someone explain me the correct way?</p>
| 0debug
|
Task Scheduler failed to start. Additional Data: Error Value: 2147943726 : <p>I am using windows 10 task scheduler to run tasks that require me using my personal user account (its necessary to use my user and not system user because of permission issues - I am part of an organization).
In windows 7 computers everything worked fine but as we upgraded to win 10 I cant run the tasks without using the System user (as mentioned before it doesn't work because of permissions).
I get the following error </p>
<p><strong>Additional Data: Error Value: 2147943726</strong></p>
<p>all I found online was an advice to use the system user other then that nothing :-(</p>
<p>please save my day.</p>
<p>here is a picture of the settings that I want to change. </p>
<p><a href="https://i.stack.imgur.com/MVhVc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/MVhVc.png" alt="img of the task scheduler"></a></p>
| 0debug
|
When to use GraphQLID instead of GraphQLInt? : <p>It is not clear when to use <a href="http://graphql.org/docs/api-reference-type-system/#graphqlid" rel="noreferrer"><code>GraphQLID</code></a> instead of <a href="http://graphql.org/docs/api-reference-type-system/#graphqlint" rel="noreferrer"><code>GraphQLInt</code></a>.</p>
<p>Consider the following schema:</p>
<pre><code>type User {
id: Int!
firstName: String!
lastName: String!
}
type Query {
user (id: ID!): User
}
</code></pre>
<p>In case of <code>Query.user</code>, it seem to make no difference whether to use <code>GraphQLID</code> or <code>GraphQLInt</code>.</p>
<p>In case of <code>User.id</code>, using <code>GraphQLID</code> will cast the input to string. Using <code>GraphQLInt</code> will ensure that the input is an integer.</p>
<p>This makes the query and type system inconsistent.</p>
<p>The <a href="/questions/tagged/graphql-js" class="post-tag" title="show questions tagged 'graphql-js'" rel="tag">graphql-js</a> <a href="http://graphql.org/docs/api-reference-type-system/#graphqlid" rel="noreferrer">spec</a> simply says:</p>
<blockquote>
<p>A <code>GraphQLScalarType</code> that represents an ID.</p>
</blockquote>
<p>Is this an implementation detail (e.g. should GraphQL client cast <code>GraphQLID</code> to an integer when it can), or is it expected that <code>ID</code> is always a string in <a href="/questions/tagged/graphql" class="post-tag" title="show questions tagged 'graphql'" rel="tag">graphql</a>?</p>
| 0debug
|
How to interpret increase in both loss and accuracy : <p>I have run deep learning models(CNN's) using tensorflow. Many times during the epoch, i have observed that both loss and accuracy have increased, or both have decreased. My understanding was that both are always inversely related. What could be scenario where both increase or decrease simultaneously.</p>
| 0debug
|
static int acpi_checksum(const uint8_t *data, int len)
{
int sum, i;
sum = 0;
for(i = 0; i < len; i++)
sum += data[i];
return (-sum) & 0xff;
}
| 1threat
|
Please can anyone explain me this recursion code? : <pre><code>#include <stdio.h>
int fun(int,int *);
int main()
{
int x = 5; // variable x and its value is 5
printf("%d,the value of fun is:",fun(5,&x));
return 0;
}
int fun(int n,int *fp)
{
int t,f;
if(n <=1)
{
*fp = 1;
return 1;
}
t = fun(n-1,fp);
f = t + *fp;
*fp = t;
return (f);
}
</code></pre>
<p>I had a test in which this code output was being asked.
Output is 8.But i am not being able to understand the logic of this code. </p>
| 0debug
|
static void qmp_input_push(QmpInputVisitor *qiv, QObject *obj, Error **errp)
{
GHashTable *h;
StackObject *tos = &qiv->stack[qiv->nb_stack];
assert(obj);
if (qiv->nb_stack >= QIV_STACK_SIZE) {
error_setg(errp, "An internal buffer overran");
return;
}
tos->obj = obj;
assert(!tos->h);
assert(!tos->entry);
if (qiv->strict && qobject_type(obj) == QTYPE_QDICT) {
h = g_hash_table_new(g_str_hash, g_str_equal);
qdict_iter(qobject_to_qdict(obj), qdict_add_key, h);
tos->h = h;
} else if (qobject_type(obj) == QTYPE_QLIST) {
tos->entry = qlist_first(qobject_to_qlist(obj));
tos->first = true;
}
qiv->nb_stack++;
}
| 1threat
|
Open GL ES tutorials : <p>Hello firstly sorry for asking like this. I want to know about openGL ES in android is there any detailed tutorials. I google it but i found some of them with direct projects but i need to know from basic level can any one help me with this please</p>
| 0debug
|
ASP.NET Core WebAPI Cookie + JWT Authentication : <p>we have a SPA (Angular) with API backend (ASP.NET Core WebAPI):</p>
<p>SPA is listens on <code>app.mydomain.com</code>, API on <code>app.mydomain.com/API</code></p>
<p>We use JWT for Authentication with built-in <code>Microsoft.AspNetCore.Authentication.JwtBearer</code>; I have a controller <code>app.mydomain.com/API/auth/jwt/login</code> which creates tokens. SPA saves them into local storage. All works perfect. After a security audit, we have been told to switch local storage for cookies.</p>
<p>The problem is, that API on <code>app.mydomain.com/API</code> is used by SPA but also by a mobile app and several customers server-2-server solutions.</p>
<p>So, we have to keep JWT as is, but add Cookies. I found several articles which combines Cookies and JWT on different controllers, but I need them work side-by-side on each controller.</p>
<p>If client sends cookies, authenticate via cookies. If client sends JWT bearer, authenticate via JWT.</p>
<p>Is this achievable via built-in ASP.NET authentication or DIY middleware?</p>
<p>Thanks!</p>
| 0debug
|
static void check_ieee_exceptions(CPUSPARCState *env)
{
target_ulong status;
status = get_float_exception_flags(&env->fp_status);
if (status) {
if (status & float_flag_invalid) {
env->fsr |= FSR_NVC;
}
if (status & float_flag_overflow) {
env->fsr |= FSR_OFC;
}
if (status & float_flag_underflow) {
env->fsr |= FSR_UFC;
}
if (status & float_flag_divbyzero) {
env->fsr |= FSR_DZC;
}
if (status & float_flag_inexact) {
env->fsr |= FSR_NXC;
}
if ((env->fsr & FSR_CEXC_MASK) & ((env->fsr & FSR_TEM_MASK) >> 23)) {
env->fsr |= FSR_FTT_IEEE_EXCP;
helper_raise_exception(env, TT_FP_EXCP);
} else {
env->fsr |= (env->fsr & FSR_CEXC_MASK) << 5;
}
}
}
| 1threat
|
void error_set(Error **errp, const char *fmt, ...)
{
Error *err;
va_list ap;
if (errp == NULL) {
return;
}
assert(*errp == NULL);
err = g_malloc0(sizeof(*err));
va_start(ap, fmt);
err->obj = qobject_to_qdict(qobject_from_jsonv(fmt, &ap));
va_end(ap);
err->msg = qerror_format(fmt, err->obj);
*errp = err;
}
| 1threat
|
static CCPrepare gen_prepare_eflags_c(DisasContext *s, TCGv reg)
{
TCGv t0, t1;
int size, shift;
switch (s->cc_op) {
case CC_OP_SUBB ... CC_OP_SUBQ:
size = s->cc_op - CC_OP_SUBB;
t1 = gen_ext_tl(cpu_tmp0, cpu_cc_src, size, false);
t0 = TCGV_EQUAL(t1, cpu_cc_src) ? cpu_tmp0 : reg;
tcg_gen_add_tl(t0, cpu_cc_dst, cpu_cc_src);
gen_extu(size, t0);
goto add_sub;
case CC_OP_ADDB ... CC_OP_ADDQ:
size = s->cc_op - CC_OP_ADDB;
t1 = gen_ext_tl(cpu_tmp0, cpu_cc_src, size, false);
t0 = gen_ext_tl(reg, cpu_cc_dst, size, false);
add_sub:
return (CCPrepare) { .cond = TCG_COND_LTU, .reg = t0,
.reg2 = t1, .mask = -1, .use_reg2 = true };
case CC_OP_SBBB ... CC_OP_SBBQ:
size = s->cc_op - CC_OP_SBBB;
t1 = gen_ext_tl(cpu_tmp0, cpu_cc_src, size, false);
if (TCGV_EQUAL(t1, reg) && TCGV_EQUAL(reg, cpu_cc_src)) {
tcg_gen_mov_tl(cpu_tmp0, cpu_cc_src);
t1 = cpu_tmp0;
}
tcg_gen_add_tl(reg, cpu_cc_dst, cpu_cc_src);
tcg_gen_addi_tl(reg, reg, 1);
gen_extu(size, reg);
t0 = reg;
goto adc_sbb;
case CC_OP_ADCB ... CC_OP_ADCQ:
size = s->cc_op - CC_OP_ADCB;
t1 = gen_ext_tl(cpu_tmp0, cpu_cc_src, size, false);
t0 = gen_ext_tl(reg, cpu_cc_dst, size, false);
adc_sbb:
return (CCPrepare) { .cond = TCG_COND_LEU, .reg = t0,
.reg2 = t1, .mask = -1, .use_reg2 = true };
case CC_OP_LOGICB ... CC_OP_LOGICQ:
return (CCPrepare) { .cond = TCG_COND_NEVER, .mask = -1 };
case CC_OP_INCB ... CC_OP_INCQ:
case CC_OP_DECB ... CC_OP_DECQ:
return (CCPrepare) { .cond = TCG_COND_NE, .reg = cpu_cc_src,
.mask = -1, .no_setcond = true };
case CC_OP_SHLB ... CC_OP_SHLQ:
size = s->cc_op - CC_OP_SHLB;
shift = (8 << size) - 1;
return (CCPrepare) { .cond = TCG_COND_NE, .reg = cpu_cc_src,
.mask = (target_ulong)1 << shift };
case CC_OP_MULB ... CC_OP_MULQ:
return (CCPrepare) { .cond = TCG_COND_NE,
.reg = cpu_cc_src, .mask = -1 };
case CC_OP_EFLAGS:
case CC_OP_SARB ... CC_OP_SARQ:
return (CCPrepare) { .cond = TCG_COND_NE,
.reg = cpu_cc_src, .mask = CC_C };
default:
gen_update_cc_op(s);
gen_helper_cc_compute_c(cpu_tmp2_i32, cpu_env, cpu_cc_op);
tcg_gen_extu_i32_tl(reg, cpu_tmp2_i32);
return (CCPrepare) { .cond = TCG_COND_NE, .reg = reg,
.mask = -1, .no_setcond = true };
}
}
| 1threat
|
int mov_write_ftyp_tag(ByteIOContext *pb, AVFormatContext *s)
{
put_be32(pb, 0x14 );
put_tag(pb, "ftyp");
if (!strcmp("3gp", s->oformat->name))
put_tag(pb, "3gp4");
else
put_tag(pb, "isom");
put_be32(pb, 0x200 );
if (!strcmp("3gp", s->oformat->name))
put_tag(pb, "3gp4");
else
put_tag(pb, "mp41");
return 0x14;
}
| 1threat
|
static unsigned decode_skip_count(GetBitContext* gb)
{
unsigned value;
if (!can_safely_read(gb, 1))
return -1;
value = get_bits1(gb);
if (!value)
return value;
value += get_bits(gb, 3);
if (value != (1 + ((1 << 3) - 1)))
return value;
value += get_bits(gb, 7);
if (value != (1 + ((1 << 3) - 1)) + ((1 << 7) - 1))
return value;
return value + get_bits(gb, 12);
}
| 1threat
|
Fix "Couldn't desugar invokedynamic" when running androidConnectedTest : <p>My Android app uses Java 8 lambdas like so:</p>
<pre><code>myView.setOnClickListener(view -> someMethod());
</code></pre>
<p>Everything works fine with the above when building the app or running unit tests. However, when I run <code>./gradlew connectedAndroidTest</code>, I get the following error:</p>
<pre><code>Execution failed for task ':myModule:transformClassesWithDesugarForDebugAndroidTest'.
Exception in thread "main" java.lang.IllegalStateException: Couldn't desugar invokedynamic for com/.../MyActivity.onClick using java/lang/invoke/LambdaMetafactory.metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; (6) with arguments [(Landroid/view/View;)V, com/.../MyActivity.lambda$onViewBound$0(Landroid/view/View;)V (7), (Landroid/view/View;)V]
at com.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.visitInvokeDynamicInsn(LambdaDesugaring.java:474)
at org.objectweb.asm.ClassReader.readCode(ClassReader.java:1623)
at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1126)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:698)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:500)
at com.google.devtools.build.android.desugar.Desugar.desugarClassesInInput(Desugar.java:477)
at com.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:361)
at com.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:314)
at com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:711)
Caused by: java.lang.IllegalAccessException: no such method: com...MyActivity.lambda$onViewBound$0(View)void/invokeSpecial
at java.lang.invoke.MemberName.makeAccessException(MemberName.java:867)
at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:1003)
at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:1386)
at java.lang.invoke.MethodHandles$Lookup.findSpecial(MethodHandles.java:1004)
at com.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.toMethodHandle(LambdaDesugaring.java:670)
at com.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.toJvmMetatype(LambdaDesugaring.java:647)
at com.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.visitInvokeDynamicInsn(LambdaDesugaring.java:408)
... 8 more
Caused by: java.lang.NoClassDefFoundError: com/.../databinding/MyActivityBinding
at java.lang.invoke.MethodHandleNatives.resolve(Native Method)
at java.lang.invoke.MemberName$Factory.resolve(MemberName.java:975)
at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:1000)
... 13 more
Caused by: java.lang.ClassNotFoundException: Class com...databinding.MyActivityBinding not found
at com.google.devtools.build.android.desugar.HeaderClassLoader.findClass(HeaderClassLoader.java:53)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 16 more
</code></pre>
<p>Note that removing the lambda makes it build again. Any idea on what could be happening and how to fix it?</p>
| 0debug
|
Installing drupal7 on ibm bluemix : How to install drupal7 on IBM blue mix ? I tried to install using cf but not able to connect with mysql or any db.
| 0debug
|
Getting "best-guess" coordinates from a location name in Python : <p>I'm looking for a way to take a rough location string (ex. "Buddy's Pub in City, State"), and convert it to the best-guess set of coordinates. I've looked at GeoPy and Google's Geocoding API, but they are not exactly what I'm looking for. Any help would be appreciated.</p>
| 0debug
|
static int need_output(void)
{
int i;
for (i = 0; i < nb_output_streams; i++) {
OutputStream *ost = output_streams[i];
OutputFile *of = output_files[ost->file_index];
AVFormatContext *os = output_files[ost->file_index]->ctx;
if (ost->is_past_recording_time ||
(os->pb && avio_tell(os->pb) >= of->limit_filesize))
continue;
if (ost->frame_number >= ost->max_frames) {
int j;
for (j = 0; j < of->ctx->nb_streams; j++)
output_streams[of->ost_index + j]->is_past_recording_time = 1;
continue;
}
return 1;
}
return 0;
}
| 1threat
|
Webpack external not cacheable : <p>I'm using webpack to bundle node.js web server based on Express.js framework.</p>
<p>Webpack build works fine, but at the end it gives me two red messages:</p>
<p>[1] external "express" 42 bytes {0} [not cacheable]</p>
<p>[2] external "path" 42 bytes {0} [not cacheable]</p>
<p>What does that mean and should I fix it? If yes then how to fix it?</p>
<p>My webpack config is here:</p>
<pre><code>var server = {
devtool: 'source-map',
entry: './src/server.ts',
target: 'node',
// Config for our build files
output: {
path: root('dist/server'),
filename: '[name].bundle.js',
sourceMapFilename: '[name].map',
chunkFilename: '[id].chunk.js'
},
externals: nodeModules,
module: {
preLoaders: [
// { test: /\.ts$/, loader: 'tslint-loader', exclude: [ root('node_modules') ] },
// TODO(gdi2290): `exclude: [ root('node_modules/rxjs') ]` fixed with rxjs 5 beta.2 release
{ test: /\.js$/, loader: "source-map-loader", exclude: [ root('node_modules/rxjs') ] }
],
loaders: [
// Support for .ts files.
{ test: /\.ts$/, loader: 'ts-loader', exclude: [ /\.(spec|e2e|async)\.ts$/ ] }
]
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(true),
// replace
new webpack.DefinePlugin({
'process.env': {
'ENV': JSON.stringify(metadata.ENV),
'NODE_ENV': JSON.stringify(metadata.ENV)
}
})
],
};
</code></pre>
<p>My server.ts module:</p>
<pre><code>console.log('Starting web server...');
import * as path from 'path';
import * as express from 'express';
let app = express();
let root = path.join(path.resolve(__dirname, '..'));
var port = process.env.PORT || 8080; // set our port
var router = express.Router();
router.get('/', function(req, res) {
res.json({ message: 'hooray! welcome to our api!' });
});
app.use('/api', router);
app.listen(port);
console.log('Server started on port ' + port);
</code></pre>
| 0debug
|
def number_of_substrings(str):
str_len = len(str);
return int(str_len * (str_len + 1) / 2);
| 0debug
|
How can I delete all full-black images from a folder by python : After cropping and saving images, I found that there are many full black images (RGB = 0,0,0). I want to delete these images
The followings are the codes I have tried
```
import os, glob
from PIL import image
def CleanUp_images():
for filename in glob.glob('/Users/Xin/Desktop/TestFolder/*.jpg'):
im = Image.open(filename)
pix = list(im.getdata())
if pix == [(0,0,0)]:
os.remove(im)
CleanUp_images()
```
However, the above codes didnt work out
Can anyone give me a help?
thanks a lot!!!
| 0debug
|
static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE], int total_gain){
int v, bsize, ch, coef_nb_bits, parse_exponents;
float mdct_norm;
int nb_coefs[MAX_CHANNELS];
static const int fixed_exp[25]={20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20};
if (s->use_variable_block_len) {
assert(0);
}else{
s->next_block_len_bits = s->frame_len_bits;
s->prev_block_len_bits = s->frame_len_bits;
s->block_len_bits = s->frame_len_bits;
}
s->block_len = 1 << s->block_len_bits;
bsize = s->frame_len_bits - s->block_len_bits;
v = s->coefs_end[bsize] - s->coefs_start;
for(ch = 0; ch < s->nb_channels; ch++)
nb_coefs[ch] = v;
{
int n4 = s->block_len / 2;
mdct_norm = 1.0 / (float)n4;
if (s->version == 1) {
mdct_norm *= sqrt(n4);
}
}
if (s->nb_channels == 2) {
put_bits(&s->pb, 1, !!s->ms_stereo);
}
for(ch = 0; ch < s->nb_channels; ch++) {
s->channel_coded[ch] = 1;
if (s->channel_coded[ch]) {
init_exp(s, ch, fixed_exp);
}
}
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
WMACoef *coefs1;
float *coefs, *exponents, mult;
int i, n;
coefs1 = s->coefs1[ch];
exponents = s->exponents[ch];
mult = pow(10, total_gain * 0.05) / s->max_exponent[ch];
mult *= mdct_norm;
coefs = src_coefs[ch];
if (s->use_noise_coding && 0) {
assert(0);
} else {
coefs += s->coefs_start;
n = nb_coefs[ch];
for(i = 0;i < n; i++){
double t= *coefs++ / (exponents[i] * mult);
if(t<-32768 || t>32767)
return -1;
coefs1[i] = lrint(t);
}
}
}
}
v = 0;
for(ch = 0; ch < s->nb_channels; ch++) {
int a = s->channel_coded[ch];
put_bits(&s->pb, 1, a);
v |= a;
}
if (!v)
return 1;
for(v= total_gain-1; v>=127; v-= 127)
put_bits(&s->pb, 7, 127);
put_bits(&s->pb, 7, v);
coef_nb_bits= ff_wma_total_gain_to_bits(total_gain);
if (s->use_noise_coding) {
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
int i, n;
n = s->exponent_high_sizes[bsize];
for(i=0;i<n;i++) {
put_bits(&s->pb, 1, s->high_band_coded[ch][i]= 0);
if (0)
nb_coefs[ch] -= s->exponent_high_bands[bsize][i];
}
}
}
}
parse_exponents = 1;
if (s->block_len_bits != s->frame_len_bits) {
put_bits(&s->pb, 1, parse_exponents);
}
if (parse_exponents) {
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
if (s->use_exp_vlc) {
encode_exp_vlc(s, ch, fixed_exp);
} else {
assert(0);
}
}
}
} else {
assert(0);
}
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
int run, tindex;
WMACoef *ptr, *eptr;
tindex = (ch == 1 && s->ms_stereo);
ptr = &s->coefs1[ch][0];
eptr = ptr + nb_coefs[ch];
run=0;
for(;ptr < eptr; ptr++){
if(*ptr){
int level= *ptr;
int abs_level= FFABS(level);
int code= 0;
if(abs_level <= s->coef_vlcs[tindex]->max_level){
if(run < s->coef_vlcs[tindex]->levels[abs_level-1])
code= run + s->int_table[tindex][abs_level-1];
}
assert(code < s->coef_vlcs[tindex]->n);
put_bits(&s->pb, s->coef_vlcs[tindex]->huffbits[code], s->coef_vlcs[tindex]->huffcodes[code]);
if(code == 0){
if(1<<coef_nb_bits <= abs_level)
return -1;
if(abs_level == 0x71B && (s->avctx->flags & CODEC_FLAG_BITEXACT)) abs_level=0x71A;
put_bits(&s->pb, coef_nb_bits, abs_level);
put_bits(&s->pb, s->frame_len_bits, run);
}
put_bits(&s->pb, 1, level < 0);
run=0;
}else{
run++;
}
}
if(run)
put_bits(&s->pb, s->coef_vlcs[tindex]->huffbits[1], s->coef_vlcs[tindex]->huffcodes[1]);
}
if (s->version == 1 && s->nb_channels >= 2) {
avpriv_align_put_bits(&s->pb);
}
}
return 0;
}
| 1threat
|
static int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame)
{
AVCodecInternal *avci = avctx->internal;
DecodeSimpleContext *ds = &avci->ds;
AVPacket *pkt = ds->in_pkt;
AVPacket tmp;
int got_frame, actual_got_frame, did_split;
int ret;
if (!pkt->data && !avci->draining) {
av_packet_unref(pkt);
ret = ff_decode_get_packet(avctx, pkt);
if (ret < 0 && ret != AVERROR_EOF)
return ret;
}
if (avci->draining_done)
return AVERROR_EOF;
if (!pkt->data &&
!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY ||
avctx->active_thread_type & FF_THREAD_FRAME))
return AVERROR_EOF;
tmp = *pkt;
#if FF_API_MERGE_SD
FF_DISABLE_DEPRECATION_WARNINGS
did_split = av_packet_split_side_data(&tmp);
if (did_split) {
ret = extract_packet_props(avctx->internal, &tmp);
if (ret < 0)
return ret;
ret = apply_param_change(avctx, &tmp);
if (ret < 0)
return ret;
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
got_frame = 0;
if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) {
ret = ff_thread_decode_frame(avctx, frame, &got_frame, &tmp);
} else {
ret = avctx->codec->decode(avctx, frame, &got_frame, &tmp);
if (!(avctx->codec->caps_internal & FF_CODEC_CAP_SETS_PKT_DTS))
frame->pkt_dts = pkt->dts;
if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
if(!avctx->has_b_frames)
frame->pkt_pos = pkt->pos;
if (!(avctx->codec->capabilities & AV_CODEC_CAP_DR1)) {
if (!frame->sample_aspect_ratio.num) frame->sample_aspect_ratio = avctx->sample_aspect_ratio;
if (!frame->width) frame->width = avctx->width;
if (!frame->height) frame->height = avctx->height;
if (frame->format == AV_PIX_FMT_NONE) frame->format = avctx->pix_fmt;
}
}
}
emms_c();
actual_got_frame = got_frame;
if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
if (frame->flags & AV_FRAME_FLAG_DISCARD)
got_frame = 0;
if (got_frame)
frame->best_effort_timestamp = guess_correct_pts(avctx,
frame->pts,
frame->pkt_dts);
} else if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
uint8_t *side;
int side_size;
uint32_t discard_padding = 0;
uint8_t skip_reason = 0;
uint8_t discard_reason = 0;
if (ret >= 0 && got_frame) {
frame->best_effort_timestamp = guess_correct_pts(avctx,
frame->pts,
frame->pkt_dts);
if (frame->format == AV_SAMPLE_FMT_NONE)
frame->format = avctx->sample_fmt;
if (!frame->channel_layout)
frame->channel_layout = avctx->channel_layout;
if (!frame->channels)
frame->channels = avctx->channels;
if (!frame->sample_rate)
frame->sample_rate = avctx->sample_rate;
}
side= av_packet_get_side_data(pkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size);
if(side && side_size>=10) {
avctx->internal->skip_samples = AV_RL32(side) * avctx->internal->skip_samples_multiplier;
discard_padding = AV_RL32(side + 4);
av_log(avctx, AV_LOG_DEBUG, "skip %d / discard %d samples due to side data\n",
avctx->internal->skip_samples, (int)discard_padding);
skip_reason = AV_RL8(side + 8);
discard_reason = AV_RL8(side + 9);
}
if ((frame->flags & AV_FRAME_FLAG_DISCARD) && got_frame &&
!(avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) {
avctx->internal->skip_samples = FFMAX(0, avctx->internal->skip_samples - frame->nb_samples);
got_frame = 0;
}
if (avctx->internal->skip_samples > 0 && got_frame &&
!(avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) {
if(frame->nb_samples <= avctx->internal->skip_samples){
got_frame = 0;
avctx->internal->skip_samples -= frame->nb_samples;
av_log(avctx, AV_LOG_DEBUG, "skip whole frame, skip left: %d\n",
avctx->internal->skip_samples);
} else {
av_samples_copy(frame->extended_data, frame->extended_data, 0, avctx->internal->skip_samples,
frame->nb_samples - avctx->internal->skip_samples, avctx->channels, frame->format);
if(avctx->pkt_timebase.num && avctx->sample_rate) {
int64_t diff_ts = av_rescale_q(avctx->internal->skip_samples,
(AVRational){1, avctx->sample_rate},
avctx->pkt_timebase);
if(frame->pts!=AV_NOPTS_VALUE)
frame->pts += diff_ts;
#if FF_API_PKT_PTS
FF_DISABLE_DEPRECATION_WARNINGS
if(frame->pkt_pts!=AV_NOPTS_VALUE)
frame->pkt_pts += diff_ts;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if(frame->pkt_dts!=AV_NOPTS_VALUE)
frame->pkt_dts += diff_ts;
if (frame->pkt_duration >= diff_ts)
frame->pkt_duration -= diff_ts;
} else {
av_log(avctx, AV_LOG_WARNING, "Could not update timestamps for skipped samples.\n");
}
av_log(avctx, AV_LOG_DEBUG, "skip %d/%d samples\n",
avctx->internal->skip_samples, frame->nb_samples);
frame->nb_samples -= avctx->internal->skip_samples;
avctx->internal->skip_samples = 0;
}
}
if (discard_padding > 0 && discard_padding <= frame->nb_samples && got_frame &&
!(avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) {
if (discard_padding == frame->nb_samples) {
got_frame = 0;
} else {
if(avctx->pkt_timebase.num && avctx->sample_rate) {
int64_t diff_ts = av_rescale_q(frame->nb_samples - discard_padding,
(AVRational){1, avctx->sample_rate},
avctx->pkt_timebase);
frame->pkt_duration = diff_ts;
} else {
av_log(avctx, AV_LOG_WARNING, "Could not update timestamps for discarded samples.\n");
}
av_log(avctx, AV_LOG_DEBUG, "discard %d/%d samples\n",
(int)discard_padding, frame->nb_samples);
frame->nb_samples -= discard_padding;
}
}
if ((avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL) && got_frame) {
AVFrameSideData *fside = av_frame_new_side_data(frame, AV_FRAME_DATA_SKIP_SAMPLES, 10);
if (fside) {
AV_WL32(fside->data, avctx->internal->skip_samples);
AV_WL32(fside->data + 4, discard_padding);
AV_WL8(fside->data + 8, skip_reason);
AV_WL8(fside->data + 9, discard_reason);
avctx->internal->skip_samples = 0;
}
}
}
#if FF_API_MERGE_SD
if (did_split) {
av_packet_free_side_data(&tmp);
if(ret == tmp.size)
ret = pkt->size;
}
#endif
if (avctx->codec->type == AVMEDIA_TYPE_AUDIO &&
!avci->showed_multi_packet_warning &&
ret >= 0 && ret != pkt->size && !(avctx->codec->capabilities & AV_CODEC_CAP_SUBFRAMES)) {
av_log(avctx, AV_LOG_WARNING, "Multiple frames in a packet.\n");
avci->showed_multi_packet_warning = 1;
}
if (!got_frame)
av_frame_unref(frame);
if (ret >= 0 && avctx->codec->type == AVMEDIA_TYPE_VIDEO && !(avctx->flags & AV_CODEC_FLAG_TRUNCATED))
ret = pkt->size;
#if FF_API_AVCTX_TIMEBASE
if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1}));
#endif
if (avctx->internal->draining && !actual_got_frame) {
if (ret < 0) {
int nb_errors_max = 20 + (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME ?
avctx->thread_count : 1);
if (avci->nb_draining_errors++ >= nb_errors_max) {
av_log(avctx, AV_LOG_ERROR, "Too many errors when draining, this is a bug. "
"Stop draining and force EOF.\n");
avci->draining_done = 1;
ret = AVERROR_BUG;
}
} else {
avci->draining_done = 1;
}
}
avci->compat_decode_consumed += ret;
if (ret >= pkt->size || ret < 0) {
av_packet_unref(pkt);
} else {
int consumed = ret;
pkt->data += consumed;
pkt->size -= consumed;
avci->last_pkt_props->size -= consumed;
pkt->pts = AV_NOPTS_VALUE;
pkt->dts = AV_NOPTS_VALUE;
avci->last_pkt_props->pts = AV_NOPTS_VALUE;
avci->last_pkt_props->dts = AV_NOPTS_VALUE;
}
if (got_frame)
av_assert0(frame->buf[0]);
return ret < 0 ? ret : 0;
}
| 1threat
|
Doing concatenation usong concat operation in String or + operator : Can someone clear one of my doubt, I know about the immutability of String.
What will be the output and why for the below piece of code:
String str1="my string";
System.out.println(str1);
System.out.println(str1.concat(" gets appended"));
System.out.println(str1+" getting updated");
Cause, as per my understanding str1 should not get changed due to its immutability nature. Thus, for all case output should be my string.
Thanks in advance
| 0debug
|
int nbd_trip(BlockDriverState *bs, int csock, off_t size,
uint64_t dev_offset, uint32_t nbdflags,
uint8_t *data)
{
struct nbd_request request;
struct nbd_reply reply;
int ret;
TRACE("Reading request.");
if (nbd_receive_request(csock, &request) == -1)
return -1;
if (request.len + NBD_REPLY_SIZE > NBD_BUFFER_SIZE) {
LOG("len (%u) is larger than max len (%u)",
request.len + NBD_REPLY_SIZE, NBD_BUFFER_SIZE);
errno = EINVAL;
return -1;
}
if ((request.from + request.len) < request.from) {
LOG("integer overflow detected! "
"you're probably being attacked");
errno = EINVAL;
return -1;
}
if ((request.from + request.len) > size) {
LOG("From: %" PRIu64 ", Len: %u, Size: %" PRIu64
", Offset: %" PRIu64 "\n",
request.from, request.len, (uint64_t)size, dev_offset);
LOG("requested operation past EOF--bad client?");
errno = EINVAL;
return -1;
}
TRACE("Decoding type");
reply.handle = request.handle;
reply.error = 0;
switch (request.type & NBD_CMD_MASK_COMMAND) {
case NBD_CMD_READ:
TRACE("Request type is READ");
ret = bdrv_read(bs, (request.from + dev_offset) / 512,
data + NBD_REPLY_SIZE,
request.len / 512);
if (ret < 0) {
LOG("reading from file failed");
reply.error = -ret;
request.len = 0;
}
TRACE("Read %u byte(s)", request.len);
cpu_to_be32w((uint32_t*)data, NBD_REPLY_MAGIC);
cpu_to_be32w((uint32_t*)(data + 4), reply.error);
cpu_to_be64w((uint64_t*)(data + 8), reply.handle);
TRACE("Sending data to client");
if (write_sync(csock, data,
request.len + NBD_REPLY_SIZE) !=
request.len + NBD_REPLY_SIZE) {
LOG("writing to socket failed");
errno = EINVAL;
return -1;
}
break;
case NBD_CMD_WRITE:
TRACE("Request type is WRITE");
TRACE("Reading %u byte(s)", request.len);
if (read_sync(csock, data, request.len) != request.len) {
LOG("reading from socket failed");
errno = EINVAL;
return -1;
}
if (nbdflags & NBD_FLAG_READ_ONLY) {
TRACE("Server is read-only, return error");
reply.error = 1;
} else {
TRACE("Writing to device");
ret = bdrv_write(bs, (request.from + dev_offset) / 512,
data, request.len / 512);
if (ret < 0) {
LOG("writing to file failed");
reply.error = -ret;
request.len = 0;
}
if (request.type & NBD_CMD_FLAG_FUA) {
ret = bdrv_flush(bs);
if (ret < 0) {
LOG("flush failed");
reply.error = -ret;
}
}
}
if (nbd_send_reply(csock, &reply) == -1)
return -1;
break;
case NBD_CMD_DISC:
TRACE("Request type is DISCONNECT");
errno = 0;
return 1;
case NBD_CMD_FLUSH:
TRACE("Request type is FLUSH");
ret = bdrv_flush(bs);
if (ret < 0) {
LOG("flush failed");
reply.error = -ret;
}
if (nbd_send_reply(csock, &reply) == -1)
return -1;
break;
case NBD_CMD_TRIM:
TRACE("Request type is TRIM");
ret = bdrv_discard(bs, (request.from + dev_offset) / 512,
request.len / 512);
if (ret < 0) {
LOG("discard failed");
reply.error = -ret;
}
if (nbd_send_reply(csock, &reply) == -1)
return -1;
break;
default:
LOG("invalid request type (%u) received", request.type);
errno = EINVAL;
return -1;
}
TRACE("Request/Reply complete");
return 0;
}
| 1threat
|
External Backups/Snapshots for Google Cloud Spanner : <p>Is it possible to snapshot a Google Cloud Spanner Database/table(s)? For compliance reasons we have to have daily snapshots of the current database that can be rolled back to in the event of a disaster: is this possible in Spanner? Is there intention to support it if not?</p>
<p>For those who might ask why we would need it as Spanner is replicated/redundant etc - it doesn't guard against human error (dropping a table by accident) or sabotage/espionage hence the question and requirement.</p>
<p>Thanks, M</p>
| 0debug
|
static int console_init(SCLPEvent *event)
{
static bool console_available;
SCLPConsole *scon = DO_UPCAST(SCLPConsole, event, event);
if (console_available) {
error_report("Multiple VT220 operator consoles are not supported");
return -1;
}
console_available = true;
if (scon->chr) {
qemu_chr_add_handlers(scon->chr, chr_can_read,
chr_read, NULL, scon);
}
scon->irq_read_vt220 = *qemu_allocate_irqs(trigger_ascii_console_data,
NULL, 1);
return 0;
}
| 1threat
|
How to forward domain to Cloudfront URL without showing target URL in browser? : <p>I have a domain which I want to redirect to a AWS cloud front URL. </p>
<p>If I only add a redirect at my domain provider then browser shows the cloud front URL in address bar which looks ugly.</p>
<p>I can create a CNAME record with the cloud front URL to a sub-domain, but not directly to the domain, but I do not want user to type the complete sub-domain name.</p>
<p>I tried adding a combination of (1)a redirect from domain to the sub-domain and (2) a CNAME record from that sub-domain to the cloud-front URL. But, of course, I get "too many redirects".</p>
<p>What is the correct solution for this? Will any Route53 service fix this problem?</p>
| 0debug
|
USBDevice *usb_host_device_open(USBBus *bus, const char *devname)
{
struct USBAutoFilter filter;
USBDevice *dev;
char *p;
dev = usb_create(bus, "usb-host");
if (strstr(devname, "auto:")) {
if (parse_filter(devname, &filter) < 0) {
goto fail;
}
} else {
p = strchr(devname, '.');
if (p) {
filter.bus_num = strtoul(devname, NULL, 0);
filter.addr = strtoul(p + 1, NULL, 0);
filter.vendor_id = 0;
filter.product_id = 0;
} else {
p = strchr(devname, ':');
if (p) {
filter.bus_num = 0;
filter.addr = 0;
filter.vendor_id = strtoul(devname, NULL, 16);
filter.product_id = strtoul(p + 1, NULL, 16);
} else {
goto fail;
}
}
}
qdev_prop_set_uint32(&dev->qdev, "hostbus", filter.bus_num);
qdev_prop_set_uint32(&dev->qdev, "hostaddr", filter.addr);
qdev_prop_set_uint32(&dev->qdev, "vendorid", filter.vendor_id);
qdev_prop_set_uint32(&dev->qdev, "productid", filter.product_id);
qdev_init_nofail(&dev->qdev);
return dev;
fail:
object_unparent(OBJECT(dev));
return NULL;
}
| 1threat
|
C# WYSIWYG HTML Editor in a Windows Forms Application : <p><a href="https://i.stack.imgur.com/obkjB.png" rel="nofollow noreferrer">Sample Html Editor</a></p>
<p>There is an html editor like the one in the picture. I searched a lot but I could not find a way .. Please Help. :(</p>
| 0debug
|
uint32 float64_to_uint32_round_to_zero( float64 a STATUS_PARAM )
{
int64_t v;
uint32 res;
v = float64_to_int64_round_to_zero(a STATUS_VAR);
if (v < 0) {
res = 0;
float_raise( float_flag_invalid STATUS_VAR);
} else if (v > 0xffffffff) {
res = 0xffffffff;
float_raise( float_flag_invalid STATUS_VAR);
} else {
res = v;
}
return res;
}
| 1threat
|
BrowserslistError: Unknown browser kaios : <p>I have updated my project to use the last versions of node and yarn, after this upgrade now my react project doesn't want to work with "browserslist". </p>
<p>I run "yarn start" and get this error:</p>
<pre><code>./src/assets/css/material-dashboard-react.css?v=1.2.0 (./node_modules/css-loader??ref--6-oneOf-3-1!./node_modules/postcss-loader/src??postcss!./src/assets/css/material-dashboard-react.css?v=1.2.0)
BrowserslistError: Unknown browser kaios
at Array.reduce (<anonymous>)
at Array.some (<anonymous>)
at Array.filter (<anonymous>)
at new Promise (<anonymous>)
</code></pre>
<p>I have the following versions:</p>
<ul>
<li>node v10.15.3</li>
<li>npm 6.9.0</li>
<li>yarn v1.15.2</li>
</ul>
<p>And my package.json its</p>
<pre><code>{
"name": "frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "3.9.3",
"@material-ui/icons": "3.0.2",
"axios": "0.18.0",
"classnames": "2.2.6",
"html2canvas": "^1.0.0-alpha.12",
"immutable": "3.8.2",
"jspdf": "^1.4.1",
"jspdf-autotable": "^2.3.5",
"moment": "2.22.2",
"npm-run-all": "4.1.5",
"perfect-scrollbar": "1.4.0",
"plotly.js": "1.47.1",
"react": "^16.6.3",
"react-currency-format": "1.0.0",
"react-dates": "18.2.2",
"react-dom": "^16.6.3",
"react-excel-workbook": "0.0.4",
"react-google-maps": "9.4.5",
"react-plotly.js": "2.3.0",
"react-redux": "6.0.0",
"react-router": "4.3.1",
"react-router-dom": "4.3.1",
"react-scripts": "2.1.8",
"react-select": "2.1.2",
"react-swipeable-views": "0.13.1",
"redux": "4.0.1",
"redux-immutable": "4.0.0",
"redux-persist": "5.10.0",
"redux-thunk": "2.3.0",
"weather-icons": "^1.3.2"
},
"scripts": {
"start": "react-scripts --max-old-space-size=8192 start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"browserslist": [
">1%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
</code></pre>
<p>For me the issue it's related to css-loader, I try solving the issue and add css-loader@2.1.1 to the package.json. I try with other solution but no ones work.</p>
| 0debug
|
static void an5206_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
M68kCPU *cpu;
CPUM68KState *env;
int kernel_size;
uint64_t elf_entry;
hwaddr entry;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *sram = g_new(MemoryRegion, 1);
if (!cpu_model) {
cpu_model = "m5206";
}
cpu = M68K_CPU(cpu_generic_init(TYPE_M68K_CPU, cpu_model));
if (!cpu) {
error_report("Unable to find m68k CPU definition");
exit(1);
}
env = &cpu->env;
env->vbr = 0;
env->mbar = AN5206_MBAR_ADDR | 1;
env->rambar0 = AN5206_RAMBAR_ADDR | 1;
memory_region_allocate_system_memory(ram, NULL, "an5206.ram", ram_size);
memory_region_add_subregion(address_space_mem, 0, ram);
memory_region_init_ram(sram, NULL, "an5206.sram", 512, &error_fatal);
memory_region_add_subregion(address_space_mem, AN5206_RAMBAR_ADDR, sram);
mcf5206_init(address_space_mem, AN5206_MBAR_ADDR, cpu);
if (!kernel_filename) {
if (qtest_enabled()) {
return;
}
fprintf(stderr, "Kernel image must be specified\n");
exit(1);
}
kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry,
NULL, NULL, 1, EM_68K, 0, 0);
entry = elf_entry;
if (kernel_size < 0) {
kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL,
NULL, NULL);
}
if (kernel_size < 0) {
kernel_size = load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR,
ram_size - KERNEL_LOAD_ADDR);
entry = KERNEL_LOAD_ADDR;
}
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename);
exit(1);
}
env->pc = entry;
}
| 1threat
|
When to use concat and append? : <p>I started learning java and always had this bugging my mind.<br>
When to use concat() and when to use append() operations.<br>
Do they perform the same operation and what of their return types?</p>
| 0debug
|
In C programming, does %d randomly generate numbers? : <p>I'm learning C programming now (I'm new to it), and I'm trying various things as well to understand how things work. So, I'm well aware that the following code isn't proper code; but I still tried it out to understand how it would be compiled:</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
int {
printf("I think C will give me %d %d %d %d %d.", 20);
return 0;
}
</code></pre>
<p>And I'm getting this in the command line:</p>
<pre>
I think C will give me 20 8 108 108 2.
Process returned 0 (0x0) execution time : 0.234 s
Press any key to continue.
</pre>
<p>Where from the numbers 8, 108, 108 and 2? How were they generated?</p>
<p>I'm just trying to understand how it works. Thanks.</p>
| 0debug
|
beginner: how can i convert int to a decimal with comma :
Console.Write("Hoeveel worpen wil je simuleren: ");
int worpen = int.Parse(Console.ReadLine());
Random r = new Random(worpen);
int willekeur = r.Next(1, worpen);
double willekeur1 = willekeur;
Math.Round(willekeur1);
for (int i = 1; i <= 12; i++)
{
Console.WriteLine("ik gooide "+willekeur+" ("+Math.Round(willekeur1,2,)+")");
willekeur = r.Next(1, worpen);
}
Console.ReadLine();
I want that ' willekeur1 ' a number which contains a decimal comma is. so example: 12456--> 12,456
| 0debug
|
av_cold void ff_init_lls_x86(LLSModel *m)
{
int cpu_flags = av_get_cpu_flags();
if (EXTERNAL_SSE2(cpu_flags)) {
m->update_lls = ff_update_lls_sse2;
if (m->indep_count >= 4)
m->evaluate_lls = ff_evaluate_lls_sse2;
}
if (EXTERNAL_AVX(cpu_flags)) {
m->update_lls = ff_update_lls_avx;
}
}
| 1threat
|
How to use AWS IoT to send/receive messages to/from Web Browser : <p>We are trying to use Amazon Web Services Internet of Things (AWS IoT) to send messages from/to a Web Browser (e.g: . Given that the AWS IoT supports JavaScript we <em>expect</em> that this is <em>possible</em> ...</p>
<p>We have searched at the AWS IoT Documentation but <em>only found <strong>server-side examples</em></strong> <em>(which expose AWS secrets/keys...)</em></p>
<p>Are there any good <em>working</em> examples or tutorials for using AWS IoT to send/receive messages via WebSockets/MQTT in the browser <em>(e.g: authenticating with AWS Cognito)</em>? Thanks!</p>
| 0debug
|
static void coroutine_fn wait_for_overlapping_requests(BlockDriverState *bs,
BdrvTrackedRequest *self, int64_t offset, unsigned int bytes)
{
BdrvTrackedRequest *req;
int64_t cluster_offset;
unsigned int cluster_bytes;
bool retry;
round_bytes_to_clusters(bs, offset, bytes, &cluster_offset, &cluster_bytes);
do {
retry = false;
QLIST_FOREACH(req, &bs->tracked_requests, list) {
if (req == self) {
continue;
}
if (tracked_request_overlaps(req, cluster_offset, cluster_bytes)) {
assert(qemu_coroutine_self() != req->co);
qemu_co_queue_wait(&req->wait_queue);
retry = true;
break;
}
}
} while (retry);
}
| 1threat
|
What will be the output of this Python 2.x program? : <p>Here is the program:</p>
<pre><code>score = raw_input("Enter your score between 0.0 and 1.0: ")
try:
fscore = float(score)
except:
print "Enter a numerical value for score."
exit()
if fscore >= 0.0 and fscore <= 1.0:
if fscore >= 0.9:
print "A"
elif fscore >= 0.8:
print "B"
elif fscore >= 0.7:
print "C"
elif fscore >= 0.6:
print "D"
elif score >= 0.5:
print "E"
elif score < 0.5:
print "F"
else:
print "Score is out of range."
</code></pre>
<p>This is a simple program to give grades to students based on their score. If you notice carefully, I have made a semantic error in the 4th <code>elif</code> statement. Instead of writing <code>elif fscore >= 0.5</code>, I have written <code>elif score >= 0.5</code>.</p>
<p>What's intriguing me is if I pass <code>0.4</code> in <code>score</code>, this program gives me output <code>E</code>. Shouldn't I receive an error? And even if I am not receiving an error, why <code>E</code>? Why not <code>A</code> or <code>B</code> or anything else?</p>
| 0debug
|
void virtqueue_map(VirtQueueElement *elem)
{
virtqueue_map_iovec(elem->in_sg, elem->in_addr, &elem->in_num,
VIRTQUEUE_MAX_SIZE, 1);
virtqueue_map_iovec(elem->out_sg, elem->out_addr, &elem->out_num,
VIRTQUEUE_MAX_SIZE, 0);
}
| 1threat
|
alert('Hello ' + user_input);
| 1threat
|
Ruby method with one string and one array as arguments returning a modified merged array : I have recently started to learn Ruby. Now, I have to build a method whose arguments are one array ([Boston Celtics, LA Lakers, Chicago Bulls] and one string ("Utah Jazz"). The method should return an array with three elements: the one coming from the string should be at index[0] and the last element of the first array should not be included in the final array. Output --> [Utah Jazz, Boston Celtics, LA Lakers].
Any ideas? Thanks for helping.
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.