problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
def minimum_Length(s) :
maxOcc = 0
n = len(s)
arr = [0]*26
for i in range(n) :
arr[ord(s[i]) -ord('a')] += 1
for i in range(26) :
if arr[i] > maxOcc :
maxOcc = arr[i]
return n - maxOcc
| 0debug
|
How can i return two integer from function : <p>I want create a function and return two integers: i and c. How can i do this?
Thanks in advance</p>
<pre><code>a++ ;
if(i == 288){
a = 0 ;
i-- ;
b++ ;
c++ ;
}
if(c == 5000) {
i = 0 ;
c = 0 ;
}
if(a == 1 ){
P2OUT = 0xFF ;
a = 0 ;
}
if (b == 1){
P2OUT= 0x00 ;
b = 0 ;
}
</code></pre>
| 0debug
|
How can I get the events for a Facebook page? : <p>Using the latest version (2.12) of the Facebook API I'm trying to get (public) events for a page, using the Graph API Explorer.</p>
<p>However, I can't seem to get it working:</p>
<p><a href="https://i.stack.imgur.com/Xy0JG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Xy0JG.png" alt="enter image description here"></a></p>
<p>When I hover over the greyed out "id" or "name" on the left, it says "Field is empty or disallowed by the access token".</p>
<p>Now the page I'm using as an exmple here is Techcrunch, and they have plenty of events coming up. So "empty" doesn't seem to be the issue.</p>
<p>On the "disallowed" side I've checked the API reference and on <a href="https://developers.facebook.com/docs/graph-api/reference/page/events/" rel="noreferrer">https://developers.facebook.com/docs/graph-api/reference/page/events/</a>.</p>
<p>However, I can't seem to find any issue here either. It says "Reading Page events requires a valid Page access token or User access token with basic permissions.".</p>
<p>What am I missing here? Any hints are greatly appreciated!</p>
| 0debug
|
static void mpc8_parse_seektable(AVFormatContext *s, int64_t off)
{
MPCContext *c = s->priv_data;
int tag;
int64_t size, pos, ppos[2];
uint8_t *buf;
int i, t, seekd;
GetBitContext gb;
avio_seek(s->pb, off, SEEK_SET);
mpc8_get_chunk_header(s->pb, &tag, &size);
if(tag != TAG_SEEKTABLE){
av_log(s, AV_LOG_ERROR, "No seek table at given position\n");
if(!(buf = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE)))
avio_read(s->pb, buf, size);
init_get_bits(&gb, buf, size * 8);
size = gb_get_v(&gb);
if(size > UINT_MAX/4 || size > c->samples/1152){
av_log(s, AV_LOG_ERROR, "Seek table is too big\n");
seekd = get_bits(&gb, 4);
for(i = 0; i < 2; i++){
pos = gb_get_v(&gb) + c->header_pos;
ppos[1 - i] = pos;
av_add_index_entry(s->streams[0], pos, i, 0, 0, AVINDEX_KEYFRAME);
for(; i < size; i++){
t = get_unary(&gb, 1, 33) << 12;
t += get_bits(&gb, 12);
if(t & 1)
t = -(t & ~1);
pos = (t >> 1) + ppos[0]*2 - ppos[1];
av_add_index_entry(s->streams[0], pos, i << seekd, 0, 0, AVINDEX_KEYFRAME);
ppos[1] = ppos[0];
ppos[0] = pos;
av_free(buf);
| 1threat
|
I need the html table for the following table structure. Can any one help me? : I need the html table for the following table structure.
[Table structure][1]
[1]: https://i.stack.imgur.com/DRC8d.png
| 0debug
|
void css_generate_css_crws(uint8_t cssid)
{
if (!channel_subsys.sei_pending) {
css_queue_crw(CRW_RSC_CSS, CRW_ERC_EVENT, 0, cssid);
}
channel_subsys.sei_pending = true;
}
| 1threat
|
Enter age javascript error : <p>Can anyone tell me what's wrong with this specific code and how can I fix it? Thanks in advance. </p>
<pre><code><script language=javascript type="text/javascript">
toDays(21);
function toDays(years)
{
var time;
time = 365*years;
return time;
}
document.write("My age is " + time);
</script>
</code></pre>
| 0debug
|
static int buf_put_buffer(void *opaque, const uint8_t *buf,
int64_t pos, int size)
{
QEMUBuffer *s = opaque;
return qsb_write_at(s->qsb, buf, pos, size);
}
| 1threat
|
How link INPUT button display:none behavior with the label : I would link an INPUT display: none button to a label so that when I click on the label, I want to have the same behavior of my hidden INPUT button. How do you do that? Thank you in advance for your answer.
Below my html5 code
<label for="model1" class="uploadFile">File...</label>
<input id="model1" type="file" name="model1" class="model1"
style="display:none;" th:required="true" />
| 0debug
|
i have an unidenified problem with my code : i am trying to fetch a json. while the code used to work i changed it a little and now it doesn't work. the code is supposed to exchange money. it's my first time posting so i really don't know what to do. i have almost zero experience. i am posting it because i need it for my school project.
sendjsonrequest();
assert tv != null;
//Request a string response from the URL resource
StringRequest stringRequest = new StringRequest(Request.Method.GET, "https://free.currencyconverterapi.com/api/v6/convert?q=EUR_ILS&compact=ultra&apiKey=6f4b50fae0c5c91a84bd",
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
// Display the response string.
tv.setText("Response is: " + Float.parseFloat(response) * Float.parseFloat(et1.getText().toString()));
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
tv.setText("Oops! That didn't work!");
}
});
//Instantiate the RequestQueue and add the request to the queue
RequestQueue queue = Volley.newRequestQueue(getApplicationContext());
queue.add(stringRequest);
String str1 = et1.getText().toString();
str = Float.parseFloat(str1);
float e = f * str;
String ef = Float.toString(e);
tv.setText(ef);
}
});
button = findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(Main2Activity.this, MainActivity.class);
startActivity(intent);
}
});
}
public void sendjsonrequest() {//sends the request to the website and retrieves specififc data (exchange rate between EUR to ILS)
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
tv1 = response.getString("EUR_ILS");
f = Float.parseFloat(tv1);
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
rq.add(jsonObjectRequest);
}
}
| 0debug
|
const uint8_t *get_submv_prob(uint32_t left, uint32_t top)
{
if (left == top)
return vp8_submv_prob[4 - !!left];
if (!top)
return vp8_submv_prob[2];
return vp8_submv_prob[1 - !!left];
}
| 1threat
|
SQL Server: Cannot execute existing scalar function from within table-valued function : <p>I created this scalar function, without any problems.<br>
But I can't execute it from another function (inline table-valued).</p>
<pre><code>USE [test]
GO
/****** Object: UserDefinedFunction [dbo].[NameFromEnumerationID] Script Date: 10/9/2018 6:46:22 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[NameFromEnumerationID]
(
@EnumerationIDParam INT NOT NULL
)
RETURNS NVARCHAR ( 48 )
WITH NATIVE_COMPILATION ,
SCHEMABINDING
AS BEGIN ATOMIC WITH ( TRANSACTION ISOLATION LEVEL = SNAPSHOT ,
LANGUAGE = N'English' )
RETURN CHOOSE ( @EnumerationIDParam ,
CAST ( N'ExampleName1' AS NVARCHAR ( 48 ) ) ,
CAST ( N'ExampleName2' AS NVARCHAR ( 48 ) ) ,
CAST ( N'ExampleName3' AS NVARCHAR ( 48 ) ) ,
CAST ( N'ExampleName4' AS NVARCHAR ( 48 ) ) ,
CAST ( N'ExampleName5' AS NVARCHAR ( 48 ) ) ,
CAST ( N'ExampleName6' AS NVARCHAR ( 48 ) ) ) ;
END
GO
</code></pre>
<p>When I try to create another function that executes the above function, I receive the error:<br>
<code>'NameFromEnumerationID' is not a recognized built-in function name.</code></p>
<pre><code>CREATE FUNCTION [dbo].[NamesFromEnumerationIDs]
(
@EnumerationIDListParam [IntList] NOT NULL READONLY
)
RETURNS TABLE AS RETURN
(
SELECT [Value] AS [ID] ,
/* ERROR */ NameFromEnumerationID ( [Value] ) AS [EnumerationName] ,
UPPER ( [NameFromEnumerationID] ( [Value] ) ) AS [EnumerationNameUpper] ,
[IsEnumerationIDValid] ( [Value] ) AS [IsValid]
FROM @EnumerationIDListParam
)
GO
</code></pre>
<p>For the parameter to the second function, the <code>IntList</code> type is very simple:</p>
<pre><code>USE [test]
GO
/****** Object: UserDefinedTableType [dbo].[IntList] Script Date: 10/9/2018 6:55:56 AM ******/
CREATE TYPE [dbo].[IntList] AS TABLE(
[Value] [int] NOT NULL
)
GO
</code></pre>
<p>How do I execute the first function as part of the query in the second function?</p>
| 0debug
|
Is there any way to have text size change with window size? : <p>I need <code>font-size</code> to be relative to the windows size. Is there any way that I can do that?</p>
| 0debug
|
I need help to put url in javascript code in framwork codeignitor. see following code. Kindly reply me I need this one. : $.ajax({
url:"....???.....",
method:"POST",
data:{from_date:from_date, to_date:to_date},
success:function(data)
{
$('#order_table').html(data);
}
});
}
else
{
alert("Please Select Date");
}
| 0debug
|
HI there i am trying to use the friend function but I am unable to access the private data members of my 2nd class : Hello there I am trying to access the private members of the class through the friend function here below my code is code is in complete
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
class time;
class date{
void friend mixdatetime(date &c, time &d);
int day;
int month;
int year;
public:
date(int day, int month, int year){
this->day = day;
this->month = month;
this->year = year;
}};
class time{
int hours;
int minutes;
int seconds;
public:
time(int hours, int minutes, int seconds){
this->hours = hours;
this->minutes = minutes;
this->seconds = seconds;}
void print(){};} ;
void mixdatetime(date &c, time &d){
c.day; // accessable
// why //d.minutes // inacccess able };};
In this code when i try to access d.minutes or d.hours // i can not because it is inaccessible why ? I am unable to access the private members kindly tell me appropriate solution
| 0debug
|
Is it possible to use OAuth 2.0 without a redirect server? : <p>I'm trying to create a local Java-based client that interacts with the SurveyMonkey API.</p>
<p>SurveyMonkey requires a long-lived access token using OAuth 2.0, which I'm not very familiar with.</p>
<p>I've been googling this for hours, and I think the answer is no, but I just want to be sure:</p>
<p>Is it possible for me to write a simple Java client that interacts with the SurveyMonkey, <strong>without setting up my own redirect server in some cloud</strong>?</p>
<p>I feel like having my own online service is mandatory to be able to receive the bearer tokens generated by OAuth 2.0. Is it possible that I can't have SurveyMonkey send bearer tokens directly to my client?</p>
<p>And if I were to set up my own custom Servlet somewhere, and use it as a redirect_uri, then the correct flow would be as follows:</p>
<ol>
<li>Java-client request bearer token from SurveyMonkey, with
redirect_uri being my own custom servlet URL. </li>
<li>SurveyMonkey sends token to my custom servlet URL. </li>
<li>Java-client polls custom servlet URL until a token is available?</li>
</ol>
<p>Is this correct?</p>
| 0debug
|
using PowerShell Compare row with next row in CSV : how to compare the line with next line and delete the duplicate.
a. if the record before is different. (i.e. the column B change)
b. and if the other of the record before changes (i.e. the column C change)
either a or b condition happen the line will be keep , if the line and next line are same will be delete. its not checking for duplicate , is every line compare with next line.
for example original CSV
COLUMN A COLUMN B COLUMN C
-------- -------- --------
A A1 1
B A1 2
C A1 1
D B1 3
E B1 3
B B1 1
Expected result will be :
COLUMN A COLUMN B COLUMN C
-------- -------- --------
A A1 1
B A1 2
C A1 1
D B1 3
B B1 1
| 0debug
|
Can't run unit tests in Xcode 8 with earlier unit test configuration : <p>I ran into this issue after upgrading to Xcode 8. When running the tests I get this error at run time:</p>
<p><code>/Users/<me>/work/<appname>/Build/Intermediates/<appname>.build/Debug-iphonesimulator/<appname>UnitTests.build/Script-231C35D610AC1F5000D830C2.sh: line 3: /Applications/Xcode.app/Contents/Developer/Tools/RunUnitTests: No such file or directory</code></p>
<p>The sh script in the error message is trying to access the RunUnitTests tool and fails. I assume this tool has been removed in Xcode 8. It seems that for my project Xcode tries to run tests in a way that is no longer supported. If I create a brand new project no such script is created and I can run tests.</p>
<p>Any idea what settings I need to update in my project to get the tests running again? I tried the 'Update to recommended settings' checklist but it doesn't solve this issue.</p>
| 0debug
|
How to typecast a struct field in Go lang : My struct:
type User struct {
FirstName string `json:"firstname, omitempty" validate:"required"`
LastName string `json:"lastname, omitempty" validate:"required"`
NumberofDays int `json:"numberofdays, string" validate:"min=0,max=100"`
}
Value for NumberofDays is passed as string from the server but I want to check if it is within range and store as int.
Ex: user := &User{"Michael","Msk","3"}
I'm getting 'cannot unmarshal string into Go value of type int'.
I'm not sure how to typecast to int and do the validation
| 0debug
|
void machine_register_compat_props(MachineState *machine)
{
MachineClass *mc = MACHINE_GET_CLASS(machine);
int i;
GlobalProperty *p;
if (!mc->compat_props) {
return;
}
for (i = 0; i < mc->compat_props->len; i++) {
p = g_array_index(mc->compat_props, GlobalProperty *, i);
p->errp = &error_abort;
qdev_prop_register_global(p);
}
}
| 1threat
|
Convert csv to parquet file using python : <p>I am trying to convert a .csv file to a .parquet file.<br>
The csv file (<code>Temp.csv</code>) has the following format </p>
<pre><code>1,Jon,Doe,Denver
</code></pre>
<p>I am using the following python code to convert it into parquet</p>
<pre><code>from pyspark import SparkContext
from pyspark.sql import SQLContext
from pyspark.sql.types import *
import os
if __name__ == "__main__":
sc = SparkContext(appName="CSV2Parquet")
sqlContext = SQLContext(sc)
schema = StructType([
StructField("col1", IntegerType(), True),
StructField("col2", StringType(), True),
StructField("col3", StringType(), True),
StructField("col4", StringType(), True)])
dirname = os.path.dirname(os.path.abspath(__file__))
csvfilename = os.path.join(dirname,'Temp.csv')
rdd = sc.textFile(csvfilename).map(lambda line: line.split(","))
df = sqlContext.createDataFrame(rdd, schema)
parquetfilename = os.path.join(dirname,'output.parquet')
df.write.mode('overwrite').parquet(parquetfilename)
</code></pre>
<p>The result is only a folder named, <code>output.parquet</code> and not a parquet file that I'm looking for, followed by the following error on the console. </p>
<p><a href="https://i.stack.imgur.com/WWDID.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WWDID.png" alt="CSV to Parquet Error"></a></p>
<p>I have also tried running the following code to face a similar issue. </p>
<pre><code>from pyspark.sql import SparkSession
import os
spark = SparkSession \
.builder \
.appName("Protob Conversion to Parquet") \
.config("spark.some.config.option", "some-value") \
.getOrCreate()
# read csv
dirname = os.path.dirname(os.path.abspath(__file__))
csvfilename = os.path.join(dirname,'Temp.csv')
df = spark.read.csv(csvfilename)
# Displays the content of the DataFrame to stdout
df.show()
parquetfilename = os.path.join(dirname,'output.parquet')
df.write.mode('overwrite').parquet(parquetfilename)
</code></pre>
<p>How to best do it? Using windows, python 2.7.</p>
| 0debug
|
Angular - DialogRef - Unsubscribe - Do I need to unsubscribe from afterClosed? : <p>I got asked by one of my colleagues if we need to unsubscribe from the afterClosed() Observable of a Dialog.</p>
<p>We are using the takeUntil pattern to unsubscribe from all Observables on ngOnDestroy().</p>
<pre><code>this.backEvent = fromEvent(window, 'popstate')
.pipe(
takeUntil(this.destroy$)
)
.subscribe(
() => {
this.navigationService.backClicked = true;
this.navigationService.navigateBackToDirectoryCenter();
}
);
</code></pre>
<p>ngOnDestroy()</p>
<pre><code>ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
}
</code></pre>
<p>So is it necessary to unsubscribe from afterClosed() Observable?</p>
<pre><code>dialogRef.afterClosed().subscribe(
(data) => {
console.log(data);
}
},
);
</code></pre>
<p>or?</p>
<pre><code>dialogRef.afterClosed()
.pipe(
takeUntil(this.destroy$)
)
.subscribe(
(data) => {
console.log(data);
},
);
</code></pre>
| 0debug
|
static void read_tree(GetBitContext *gb, Tree *tree)
{
uint8_t tmp1[16], tmp2[16], *in = tmp1, *out = tmp2;
int i, t, len;
tree->vlc_num = get_bits(gb, 4);
if (!tree->vlc_num) {
for (i = 0; i < 16; i++)
tree->syms[i] = i;
return;
}
if (get_bits1(gb)) {
len = get_bits(gb, 3);
memset(tmp1, 0, sizeof(tmp1));
for (i = 0; i <= len; i++) {
tree->syms[i] = get_bits(gb, 4);
tmp1[tree->syms[i]] = 1;
}
for (i = 0; i < 16; i++)
if (!tmp1[i])
tree->syms[++len] = i;
} else {
len = get_bits(gb, 2);
for (i = 0; i < 16; i++)
in[i] = i;
for (i = 0; i <= len; i++) {
int size = 1 << i;
for (t = 0; t < 16; t += size << 1)
merge(gb, out + t, in + t, size);
FFSWAP(uint8_t*, in, out);
}
memcpy(tree->syms, in, 16);
}
}
| 1threat
|
void vnc_write(VncState *vs, const void *data, size_t len)
{
buffer_reserve(&vs->output, len);
if (buffer_empty(&vs->output)) {
qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, vnc_client_write, vs);
}
buffer_append(&vs->output, data, len);
}
| 1threat
|
What is ** in Java? : What does the following statement mean?
INT_MAX**1/3
For context I saw this in an Android coding challenge, where it also treats `2^11` as meaning '2 to the power of 11' (instead of 2 XOR 11), so it is possible it's pseudocode
| 0debug
|
want sql query for this senario : tbl_employee
empid empname openingbal
2 jhon 400
3 smith 500
tbl_transection1
tid empid amount creditdebit date
1 2 100 1 2016-01-06 00:00:00.000
2 2 200 1 2016-01-08 00:00:00.000
3 2 100 2 2016-01-11 00:00:00.000
4 2 700 1 2016-01-15 00:00:00.000
5 3 100 1 2016-02-03 00:00:00.000
6 3 200 2 2016-02-06 00:00:00.000
7 3 400 1 2016-02-07 00:00:00.000
tbl_transection2
tid empid amount creditdebit date
1 2 100 1 2016-01-07 00:00:00.000
2 2 200 1 2016-01-08 00:00:00.000
3 2 100 2 2016-01-09 00:00:00.000
4 2 700 1 2016-01-14 00:00:00.000
5 3 100 1 2016-02-04 00:00:00.000
6 3 200 2 2016-02-05 00:00:00.000
7 3 400 1 2016-02-08 00:00:00.000
here 1 stand for credit and 2 for debit
i want oput put like
empid empname details debitamount creditamount balance Dr/Cr date
2 jhon opening Bal 400 Cr
2 jhon transection 1 100 500 Cr 2016-01-06 00:00:00.000
2 jhon transection 2 100 600 Cr 2016-01-07 00:00:00.000
2 jhon transection 1 200 800 Cr 2016-01-08 00:00:00.000
2 jhon transection 2 200 1000 Cr 2016-01-08 00:00:00.000
2 jhon transection 2 100 900 Dr 2016-01-09 00:00:00.000
2 jhon transection 1 100 800 Dr 2016-01-11 00:00:00.000
2 jhon transection 2 700 1500 Cr 2016-01-14 00:00:00.000
2 jhon transection 1 700 2200 Cr 2016-01-15 00:00:00.000
3 smith opening Bal 500 Cr
3 smith transection 1 100 600 Cr 2016-02-03 00:00:00.000
3 smith transection 2 100 700 Cr 2016-02-04 00:00:00.000
3 smith transection 2 200 500 Dr 2016-02-05 00:00:00.000
3 smith transection 1 200 300 Dr 2016-02-06 00:00:00.000
3 smith transection 1 400 700 Cr 2016-02-07 00:00:00.000
3 smith transection 2 400 1100 Cr 2016-02-08 00:00:00.000
| 0debug
|
AudioContext how to play the notes in a sequence : <p>I have followed this <a href="http://marcgg.com/blog/2016/11/01/javascript-audio/" rel="noreferrer">tutorial</a> and come up with that code:</p>
<pre><code>context = new AudioContext();
play(frequency) {
const o = this.context.createOscillator();
const g = this.context.createGain();
o.connect(g);
g.connect(this.context.destination);
g.gain.exponentialRampToValueAtTime(
0.00001, this.context.currentTime + 1
);
o.frequency.value = frequency;
o.start(0);
}
</code></pre>
<p>This way I can play any notes from <a href="http://marcgg.com/blog/2016/11/01/javascript-audio/" rel="noreferrer">tutorial</a> table by passing the values <code>1175</code>, <code>2794</code>, etc</p>
<p>I decided to create an array of notes and just called my <code>play</code> function in the loop and it is just didn't work as all the notes just played at once with no delay.</p>
<p>How would you play the array of notes in a sequence? </p>
<p>I also was looking in to that <a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createBuffer" rel="noreferrer">article</a> but still cant figure out how I can adapt my code above to that.</p>
| 0debug
|
static int on2avc_decode_band_types(On2AVCContext *c, GetBitContext *gb)
{
int bits_per_sect = c->is_long ? 5 : 3;
int esc_val = (1 << bits_per_sect) - 1;
int num_bands = c->num_bands * c->num_windows;
int band = 0, i, band_type, run_len, run;
while (band < num_bands) {
band_type = get_bits(gb, 4);
run_len = 1;
do {
run = get_bits(gb, bits_per_sect);
run_len += run;
} while (run == esc_val);
if (band + run_len > num_bands) {
av_log(c->avctx, AV_LOG_ERROR, "Invalid band type run\n");
return AVERROR_INVALIDDATA;
}
for (i = band; i < band + run_len; i++) {
c->band_type[i] = band_type;
c->band_run_end[i] = band + run_len;
}
band += run_len;
}
return 0;
}
| 1threat
|
How to covert java into Kotlin. : I have this issue to convert java into kotlin in Android Studio if someone can help.
> final EditText etAge = (EditText()) findViewById(R.id.etAge)
I need to convert this into kotlin and i doesn't know a way to convert it easily.
| 0debug
|
What is Callback URL in Facebook webhook page subscription? : <p>I'm trying to stream the real time public feeds using Facebook Web-hook API. Here I'm trying to set up a page subscription in Web-hook console. There is a field called Callback URL. What is this URL about?</p>
<p>I have also tried going through the documentation for Setting up callback URL. but I Couldn't figure out. </p>
<p><a href="https://developers.facebook.com/docs/graph-api/webhooks#setup" rel="noreferrer">https://developers.facebook.com/docs/graph-api/webhooks#setup</a></p>
<p>Cant the callback URL be SSL localhost? Whenever I try to give a localhost URL i get a error message "Unable to verify provided URL". </p>
| 0debug
|
static int parse_vtrk(AVFormatContext *s,
FourxmDemuxContext *fourxm, uint8_t *buf, int size,
int left)
{
AVStream *st;
if (size != vtrk_SIZE || left < size + 8) {
return AVERROR_INVALIDDATA;
}
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 60, 1, fourxm->fps);
fourxm->video_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_4XM;
st->codec->extradata_size = 4;
st->codec->extradata = av_malloc(4);
AV_WL32(st->codec->extradata, AV_RL32(buf + 16));
st->codec->width = AV_RL32(buf + 36);
st->codec->height = AV_RL32(buf + 40);
return 0;
}
| 1threat
|
static inline void write_back_motion(H264Context *h, int mb_type){
MpegEncContext * const s = &h->s;
const int b_xy = 4*s->mb_x + 4*s->mb_y*h->b_stride;
const int b8_xy= 2*s->mb_x + 2*s->mb_y*h->b8_stride;
int list;
if(!USES_LIST(mb_type, 0))
fill_rectangle(&s->current_picture.ref_index[0][b8_xy], 2, 2, h->b8_stride, (uint8_t)LIST_NOT_USED, 1);
for(list=0; list<2; list++){
int y;
if(!USES_LIST(mb_type, list))
continue;
for(y=0; y<4; y++){
*(uint64_t*)s->current_picture.motion_val[list][b_xy + 0 + y*h->b_stride]= *(uint64_t*)h->mv_cache[list][scan8[0]+0 + 8*y];
*(uint64_t*)s->current_picture.motion_val[list][b_xy + 2 + y*h->b_stride]= *(uint64_t*)h->mv_cache[list][scan8[0]+2 + 8*y];
}
if( h->pps.cabac ) {
if(IS_SKIP(mb_type))
fill_rectangle(h->mvd_table[list][b_xy], 4, 4, h->b_stride, 0, 4);
else
for(y=0; y<4; y++){
*(uint64_t*)h->mvd_table[list][b_xy + 0 + y*h->b_stride]= *(uint64_t*)h->mvd_cache[list][scan8[0]+0 + 8*y];
*(uint64_t*)h->mvd_table[list][b_xy + 2 + y*h->b_stride]= *(uint64_t*)h->mvd_cache[list][scan8[0]+2 + 8*y];
}
}
{
int8_t *ref_index = &s->current_picture.ref_index[list][b8_xy];
ref_index[0+0*h->b8_stride]= h->ref_cache[list][scan8[0]];
ref_index[1+0*h->b8_stride]= h->ref_cache[list][scan8[4]];
ref_index[0+1*h->b8_stride]= h->ref_cache[list][scan8[8]];
ref_index[1+1*h->b8_stride]= h->ref_cache[list][scan8[12]];
}
}
if(h->slice_type == B_TYPE && h->pps.cabac){
if(IS_8X8(mb_type)){
uint8_t *direct_table = &h->direct_table[b8_xy];
direct_table[1+0*h->b8_stride] = IS_DIRECT(h->sub_mb_type[1]) ? 1 : 0;
direct_table[0+1*h->b8_stride] = IS_DIRECT(h->sub_mb_type[2]) ? 1 : 0;
direct_table[1+1*h->b8_stride] = IS_DIRECT(h->sub_mb_type[3]) ? 1 : 0;
}
}
}
| 1threat
|
Is it possible to open a specific app page by mail link? : <p>I'm developing an hybrid application by using Angular and Ionic and I need to setup a "reset password" flow: once the user clicks on a "reset password" button they receive a mail link to reset.</p>
<p>If the mail link is clicked and the user has the app installed I'd like to open the app and show a password creation page.
Is this possible? Does it work on both ios and android?</p>
| 0debug
|
static int64_t ogg_read_timestamp(AVFormatContext *s, int stream_index,
int64_t *pos_arg, int64_t pos_limit)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + stream_index;
AVIOContext *bc = s->pb;
int64_t pts = AV_NOPTS_VALUE;
int i;
avio_seek(bc, *pos_arg, SEEK_SET);
ogg_reset(ogg);
while (avio_tell(bc) < pos_limit && !ogg_packet(s, &i, NULL, NULL, pos_arg)) {
if (i == stream_index) {
pts = ogg_calc_pts(s, i, NULL);
if (os->keyframe_seek && !(os->pflags & AV_PKT_FLAG_KEY))
pts = AV_NOPTS_VALUE;
}
if (pts != AV_NOPTS_VALUE)
break;
}
ogg_reset(ogg);
return pts;
}
| 1threat
|
React - What's the best practice to refresh a list of data after adding a new element there? : <p>I am building a simple todo list. I have a form for adding a new todo list item and under it are listed all items in the todo list. When I add a new item through a form, I want to refresh the list of existing todo list items.</p>
<p>Items.jsx:</p>
<pre><code>class Items extends React.Component {
constructor(props) {
super(props);
this.state = {
items: [],
loading: true
};
}
componentDidMount() {
axios.get('/api/v1/items')
.then(response => {
this.setState({ items: response.data, loading: false });
});
console.log('state.items: '+this.state.items);
}
componentDidUpdate() {
axios.get('/api/v1/items')
.then(response => {
this.setState({ items: response.data, loading: false });
});
console.log('componentDidUpdate: '+this.state.items);
}
render() {
return (
<ItemSE.Group>
{
this.state.items.map(item => {
return <Item key={item.id} data={item} />
})
}
</ItemSE.Group>
);
}
}
export default Items
</code></pre>
<p>App.jsx:</p>
<pre><code>class App extends Component {
constructor () {
super();
this.state = {
item_msg: ''
}
this.handleInputChange = this.handleInputChange.bind(this);
}
handleSubmit(e){
e.preventDefault();
console.log(this.state.item_msg);
axios.post('/api/v1/items', {
item: this.state.item_msg
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
}
handleInputChange(e) {
this.setState({ item_msg: e.target.value });
console.log('item_msg: '+this.state.item_msg);
}
render() {
return (
<div className="App">
<MainHeaderr />
<Container>
<NewItemForm
send_form={this.handleSubmit.bind(this)}
onInputChange={this.handleInputChange}
typed={this.state.item_msg} />
<Items />
</Container>
</div>
);
}
}
export default App;
</code></pre>
<p>I added <code>componentDidUpdate</code> to the <code>Items.jsx</code> file - when I add a new todo list, this new todo will indeed display immediately to the list - that's cool. However, I don't really feel this is the best practice.
When I look to the JS console, I see there hundreds of <code>componentDidUpdate:</code>.</p>
<p>Thus, what's the best way to refresh a list to todos?</p>
| 0debug
|
How can handle principal/mirror status in for-each and switch condition in powershell : i am new in powershell i have one query
# Load SMO extension
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null;
# Servers to check
#$sqlservers = @("$svr","$svr\$inst");
$sqlservers = get-content 'servers.txt'
foreach($server in $sqlservers)
{
$srv = New-Object "Microsoft.SqlServer.Management.Smo.Server" $server;
# Get mirrored databases
$databases = $srv.Databases | Where-Object {$_.IsMirroringEnabled -eq $true};
#Write-Host $databases;
Write-Host "==================================";
# $test= $databases | Select-Object -Property Name, MirroringStatus| Format-Table -AutoSize;
$databases | Select-Object -Property MirroringStatus | Format-Table -AutoSize ;
Foreach ($status in $databases) {Switch ($databases.MirroringPartnerInstance)
{
1{ $status. + "Disconnected" }
2{ $status. + "Suspended" }
2{ $status. + "Synchronizing" }
3{ $status. + "Not Synchronized" }
}
}
i want code like this is some one know pls help me it is an urgent
| 0debug
|
How to convert String e.g. "01/01/2019" to date in Java 8 : <p>I'm trying to use Java 8's DateTimeFormatter to turn strings such as "17/01/2019" into dates of exactly the same format.</p>
<p>I'm currently using:</p>
<pre><code>DateTimeFormatter format = DateTimeFormatter.ofPattern("dd/MM/yyyy", Locale.ENGLISH);
LocalDateTime dExpCompletionDate = LocalDateTime.parse(sExpCompletionDate, format);
LocalDateTime dExpCommencementDate = LocalDateTime.parse(sExpCommencementDate, format);
</code></pre>
<p>and getting the error:</p>
<blockquote>
<p>java.time.format.DateTimeParseException: Text '' could not be parsed at index 0</p>
</blockquote>
<p>Which would suggest there's something wrong with my format.</p>
<p>Currently, I've tried using the default format as well as using LocalDate instead of LocalDateTime</p>
| 0debug
|
def find_even_Pair(A,N):
evenPair = 0
for i in range(0,N):
for j in range(i+1,N):
if ((A[i] ^ A[j]) % 2 == 0):
evenPair+=1
return evenPair;
| 0debug
|
int net_init_vde(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan)
{
const char *sock;
const char *group;
int port, mode;
sock = qemu_opt_get(opts, "sock");
group = qemu_opt_get(opts, "group");
port = qemu_opt_get_number(opts, "port", 0);
mode = qemu_opt_get_number(opts, "mode", 0700);
if (net_vde_init(vlan, "vde", name, sock, port, group, mode) == -1) {
return -1;
}
if (vlan) {
vlan->nb_host_devs++;
}
return 0;
}
| 1threat
|
static gboolean vtd_hash_remove_by_page(gpointer key, gpointer value,
gpointer user_data)
{
VTDIOTLBEntry *entry = (VTDIOTLBEntry *)value;
VTDIOTLBPageInvInfo *info = (VTDIOTLBPageInvInfo *)user_data;
uint64_t gfn = info->gfn & info->mask;
return (entry->domain_id == info->domain_id) &&
((entry->gfn & info->mask) == gfn);
}
| 1threat
|
connection.query('SELECT * FROM users WHERE username = ' + input_string)
| 1threat
|
void helper_memalign(uint32_t addr, uint32_t dr, uint32_t wr, uint32_t mask)
{
if (addr & mask) {
qemu_log("unaligned access addr=%x mask=%x, wr=%d\n",
addr, mask, wr);
if (!(env->sregs[SR_MSR] & MSR_EE)) {
return;
}
env->sregs[SR_ESR] = ESR_EC_UNALIGNED_DATA | (wr << 10) \
| (dr & 31) << 5;
if (mask == 3) {
env->sregs[SR_ESR] |= 1 << 11;
}
helper_raise_exception(EXCP_HW_EXCP);
}
}
| 1threat
|
Keras confusion about number of layers : <p>I'm a bit confused about the number of layers that are used in Keras models. The documentation is rather opaque on the matter.</p>
<p>According to Jason Brownlee the first layer technically consists of two layers, the input layer, specified by <code>input_dim</code> and a hidden layer. See the first questions on <a href="http://machinelearningmastery.com/tutorial-first-neural-network-python-keras/" rel="noreferrer">his blog</a>.</p>
<p>In all of the Keras documentation the first layer is generally specified as
<code>model.add(Dense(number_of_neurons, input_dim=number_of_cols_in_input, activtion=some_activation_function))</code>.</p>
<p>The most basic model we could make would therefore be:</p>
<pre><code> model = Sequential()
model.add(Dense(1, input_dim = 100, activation = None))
</code></pre>
<p>Does this model consist of a single layer, where 100 dimensional input is passed through a single input neuron, or does it consist of two layers, first a 100 dimensional input layer and second a 1 dimensional hidden layer?</p>
<p>Further, if I were to specify a model like this, how many layers does it have?</p>
<pre><code>model = Sequential()
model.add(Dense(32, input_dim = 100, activation = 'sigmoid'))
model.add(Dense(1)))
</code></pre>
<p>Is this a model with 1 input layer, 1 hidden layer, and 1 output layer or is this a model with 1 input layer and 1 output layer?</p>
| 0debug
|
void virtio_net_set_config_size(VirtIONet *n, uint32_t host_features)
{
int i, config_size = 0;
host_features |= (1 << VIRTIO_NET_F_MAC);
for (i = 0; feature_sizes[i].flags != 0; i++) {
if (host_features & feature_sizes[i].flags) {
config_size = MAX(feature_sizes[i].end, config_size);
}
}
n->config_size = config_size;
}
| 1threat
|
static int usbredir_get_bufpq(QEMUFile *f, void *priv, size_t unused)
{
struct endp_data *endp = priv;
USBRedirDevice *dev = endp->dev;
struct buf_packet *bufp;
int i;
endp->bufpq_size = qemu_get_be32(f);
for (i = 0; i < endp->bufpq_size; i++) {
bufp = g_malloc(sizeof(struct buf_packet));
bufp->len = qemu_get_be32(f);
bufp->status = qemu_get_be32(f);
bufp->offset = 0;
bufp->data = qemu_oom_check(malloc(bufp->len));
bufp->free_on_destroy = bufp->data;
qemu_get_buffer(f, bufp->data, bufp->len);
QTAILQ_INSERT_TAIL(&endp->bufpq, bufp, next);
DPRINTF("get_bufpq %d/%d len %d status %d\n", i + 1, endp->bufpq_size,
bufp->len, bufp->status);
}
return 0;
}
| 1threat
|
Where can I find documentation on the pyparsing module? : <p>I am working through some code to integrate Anaconda environments with ArcGIS. The tutorial I'm following makes use of the pyparsing module. I'd like to better understand the module but am having difficulty finding a good overview of the commands within it. Where can I find documentation for the module?</p>
| 0debug
|
static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
uint16_t insn_hw1, int *is_branch)
{
int32_t offset;
uint16_t insn;
int rt, rs, rd, rr;
int16_t imm;
uint32_t op, minor, mips32_op;
uint32_t cond, fmt, cc;
insn = lduw_code(ctx->pc + 2);
ctx->opcode = (ctx->opcode << 16) | insn;
rt = (ctx->opcode >> 21) & 0x1f;
rs = (ctx->opcode >> 16) & 0x1f;
rd = (ctx->opcode >> 11) & 0x1f;
rr = (ctx->opcode >> 6) & 0x1f;
imm = (int16_t) ctx->opcode;
op = (ctx->opcode >> 26) & 0x3f;
switch (op) {
case POOL32A:
minor = ctx->opcode & 0x3f;
switch (minor) {
case 0x00:
minor = (ctx->opcode >> 6) & 0xf;
switch (minor) {
case SLL32:
mips32_op = OPC_SLL;
goto do_shifti;
case SRA:
mips32_op = OPC_SRA;
goto do_shifti;
case SRL32:
mips32_op = OPC_SRL;
goto do_shifti;
case ROTR:
mips32_op = OPC_ROTR;
do_shifti:
gen_shift_imm(env, ctx, mips32_op, rt, rs, rd);
break;
default:
goto pool32a_invalid;
}
break;
case 0x10:
minor = (ctx->opcode >> 6) & 0xf;
switch (minor) {
case ADD:
mips32_op = OPC_ADD;
goto do_arith;
case ADDU32:
mips32_op = OPC_ADDU;
goto do_arith;
case SUB:
mips32_op = OPC_SUB;
goto do_arith;
case SUBU32:
mips32_op = OPC_SUBU;
goto do_arith;
case MUL:
mips32_op = OPC_MUL;
do_arith:
gen_arith(env, ctx, mips32_op, rd, rs, rt);
break;
case SLLV:
mips32_op = OPC_SLLV;
goto do_shift;
case SRLV:
mips32_op = OPC_SRLV;
goto do_shift;
case SRAV:
mips32_op = OPC_SRAV;
goto do_shift;
case ROTRV:
mips32_op = OPC_ROTRV;
do_shift:
gen_shift(env, ctx, mips32_op, rd, rs, rt);
break;
case AND:
mips32_op = OPC_AND;
goto do_logic;
case OR32:
mips32_op = OPC_OR;
goto do_logic;
case NOR:
mips32_op = OPC_NOR;
goto do_logic;
case XOR32:
mips32_op = OPC_XOR;
do_logic:
gen_logic(env, mips32_op, rd, rs, rt);
break;
case SLT:
mips32_op = OPC_SLT;
goto do_slt;
case SLTU:
mips32_op = OPC_SLTU;
do_slt:
gen_slt(env, mips32_op, rd, rs, rt);
break;
default:
goto pool32a_invalid;
}
break;
case 0x18:
minor = (ctx->opcode >> 6) & 0xf;
switch (minor) {
case MOVN:
mips32_op = OPC_MOVN;
goto do_cmov;
case MOVZ:
mips32_op = OPC_MOVZ;
do_cmov:
gen_cond_move(env, mips32_op, rd, rs, rt);
break;
case LWXS:
gen_ldxs(ctx, rs, rt, rd);
break;
default:
goto pool32a_invalid;
}
break;
case INS:
gen_bitops(ctx, OPC_INS, rt, rs, rr, rd);
return;
case EXT:
gen_bitops(ctx, OPC_EXT, rt, rs, rr, rd);
return;
case POOL32AXF:
gen_pool32axf(env, ctx, rt, rs, is_branch);
break;
case 0x07:
generate_exception(ctx, EXCP_BREAK);
break;
default:
pool32a_invalid:
MIPS_INVAL("pool32a");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case POOL32B:
minor = (ctx->opcode >> 12) & 0xf;
switch (minor) {
case CACHE:
break;
case LWC2:
case SWC2:
generate_exception_err(ctx, EXCP_CpU, 2);
break;
case LWP:
case SWP:
#ifdef TARGET_MIPS64
case LDP:
case SDP:
#endif
gen_ldst_pair(ctx, minor, rt, rs, SIMM(ctx->opcode, 0, 12));
break;
case LWM32:
case SWM32:
#ifdef TARGET_MIPS64
case LDM:
case SDM:
#endif
gen_ldst_multiple(ctx, minor, rt, rs, SIMM(ctx->opcode, 0, 12));
break;
default:
MIPS_INVAL("pool32b");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case POOL32F:
if (env->CP0_Config1 & (1 << CP0C1_FP)) {
minor = ctx->opcode & 0x3f;
check_cp1_enabled(ctx);
switch (minor) {
case ALNV_PS:
mips32_op = OPC_ALNV_PS;
goto do_madd;
case MADD_S:
mips32_op = OPC_MADD_S;
goto do_madd;
case MADD_D:
mips32_op = OPC_MADD_D;
goto do_madd;
case MADD_PS:
mips32_op = OPC_MADD_PS;
goto do_madd;
case MSUB_S:
mips32_op = OPC_MSUB_S;
goto do_madd;
case MSUB_D:
mips32_op = OPC_MSUB_D;
goto do_madd;
case MSUB_PS:
mips32_op = OPC_MSUB_PS;
goto do_madd;
case NMADD_S:
mips32_op = OPC_NMADD_S;
goto do_madd;
case NMADD_D:
mips32_op = OPC_NMADD_D;
goto do_madd;
case NMADD_PS:
mips32_op = OPC_NMADD_PS;
goto do_madd;
case NMSUB_S:
mips32_op = OPC_NMSUB_S;
goto do_madd;
case NMSUB_D:
mips32_op = OPC_NMSUB_D;
goto do_madd;
case NMSUB_PS:
mips32_op = OPC_NMSUB_PS;
do_madd:
gen_flt3_arith(ctx, mips32_op, rd, rr, rs, rt);
break;
case CABS_COND_FMT:
cond = (ctx->opcode >> 6) & 0xf;
cc = (ctx->opcode >> 13) & 0x7;
fmt = (ctx->opcode >> 10) & 0x3;
switch (fmt) {
case 0x0:
gen_cmpabs_s(ctx, cond, rt, rs, cc);
break;
case 0x1:
gen_cmpabs_d(ctx, cond, rt, rs, cc);
break;
case 0x2:
gen_cmpabs_ps(ctx, cond, rt, rs, cc);
break;
default:
goto pool32f_invalid;
}
break;
case C_COND_FMT:
cond = (ctx->opcode >> 6) & 0xf;
cc = (ctx->opcode >> 13) & 0x7;
fmt = (ctx->opcode >> 10) & 0x3;
switch (fmt) {
case 0x0:
gen_cmp_s(ctx, cond, rt, rs, cc);
break;
case 0x1:
gen_cmp_d(ctx, cond, rt, rs, cc);
break;
case 0x2:
gen_cmp_ps(ctx, cond, rt, rs, cc);
break;
default:
goto pool32f_invalid;
}
break;
case POOL32FXF:
gen_pool32fxf(env, ctx, rt, rs);
break;
case 0x00:
switch ((ctx->opcode >> 6) & 0x7) {
case PLL_PS:
mips32_op = OPC_PLL_PS;
goto do_ps;
case PLU_PS:
mips32_op = OPC_PLU_PS;
goto do_ps;
case PUL_PS:
mips32_op = OPC_PUL_PS;
goto do_ps;
case PUU_PS:
mips32_op = OPC_PUU_PS;
goto do_ps;
case CVT_PS_S:
mips32_op = OPC_CVT_PS_S;
do_ps:
gen_farith(ctx, mips32_op, rt, rs, rd, 0);
break;
default:
goto pool32f_invalid;
}
break;
case 0x08:
switch ((ctx->opcode >> 6) & 0x7) {
case LWXC1:
mips32_op = OPC_LWXC1;
goto do_ldst_cp1;
case SWXC1:
mips32_op = OPC_SWXC1;
goto do_ldst_cp1;
case LDXC1:
mips32_op = OPC_LDXC1;
goto do_ldst_cp1;
case SDXC1:
mips32_op = OPC_SDXC1;
goto do_ldst_cp1;
case LUXC1:
mips32_op = OPC_LUXC1;
goto do_ldst_cp1;
case SUXC1:
mips32_op = OPC_SUXC1;
do_ldst_cp1:
gen_flt3_ldst(ctx, mips32_op, rd, rd, rt, rs);
break;
default:
goto pool32f_invalid;
}
break;
case 0x18:
fmt = (ctx->opcode >> 9) & 0x3;
switch ((ctx->opcode >> 6) & 0x7) {
case RSQRT2_FMT:
switch (fmt) {
case FMT_SDPS_S:
mips32_op = OPC_RSQRT2_S;
goto do_3d;
case FMT_SDPS_D:
mips32_op = OPC_RSQRT2_D;
goto do_3d;
case FMT_SDPS_PS:
mips32_op = OPC_RSQRT2_PS;
goto do_3d;
default:
goto pool32f_invalid;
}
break;
case RECIP2_FMT:
switch (fmt) {
case FMT_SDPS_S:
mips32_op = OPC_RECIP2_S;
goto do_3d;
case FMT_SDPS_D:
mips32_op = OPC_RECIP2_D;
goto do_3d;
case FMT_SDPS_PS:
mips32_op = OPC_RECIP2_PS;
goto do_3d;
default:
goto pool32f_invalid;
}
break;
case ADDR_PS:
mips32_op = OPC_ADDR_PS;
goto do_3d;
case MULR_PS:
mips32_op = OPC_MULR_PS;
do_3d:
gen_farith(ctx, mips32_op, rt, rs, rd, 0);
break;
default:
goto pool32f_invalid;
}
break;
case 0x20:
cc = (ctx->opcode >> 13) & 0x7;
fmt = (ctx->opcode >> 9) & 0x3;
switch ((ctx->opcode >> 6) & 0x7) {
case MOVF_FMT:
switch (fmt) {
case FMT_SDPS_S:
gen_movcf_s(rs, rt, cc, 0);
break;
case FMT_SDPS_D:
gen_movcf_d(ctx, rs, rt, cc, 0);
break;
case FMT_SDPS_PS:
gen_movcf_ps(rs, rt, cc, 0);
break;
default:
goto pool32f_invalid;
}
break;
case MOVT_FMT:
switch (fmt) {
case FMT_SDPS_S:
gen_movcf_s(rs, rt, cc, 1);
break;
case FMT_SDPS_D:
gen_movcf_d(ctx, rs, rt, cc, 1);
break;
case FMT_SDPS_PS:
gen_movcf_ps(rs, rt, cc, 1);
break;
default:
goto pool32f_invalid;
}
break;
case PREFX:
break;
default:
goto pool32f_invalid;
}
break;
#define FINSN_3ARG_SDPS(prfx) \
switch ((ctx->opcode >> 8) & 0x3) { \
case FMT_SDPS_S: \
mips32_op = OPC_##prfx##_S; \
goto do_fpop; \
case FMT_SDPS_D: \
mips32_op = OPC_##prfx##_D; \
goto do_fpop; \
case FMT_SDPS_PS: \
mips32_op = OPC_##prfx##_PS; \
goto do_fpop; \
default: \
goto pool32f_invalid; \
}
case 0x30:
switch ((ctx->opcode >> 6) & 0x3) {
case ADD_FMT:
FINSN_3ARG_SDPS(ADD);
break;
case SUB_FMT:
FINSN_3ARG_SDPS(SUB);
break;
case MUL_FMT:
FINSN_3ARG_SDPS(MUL);
break;
case DIV_FMT:
fmt = (ctx->opcode >> 8) & 0x3;
if (fmt == 1) {
mips32_op = OPC_DIV_D;
} else if (fmt == 0) {
mips32_op = OPC_DIV_S;
} else {
goto pool32f_invalid;
}
goto do_fpop;
default:
goto pool32f_invalid;
}
break;
case 0x38:
switch ((ctx->opcode >> 6) & 0x3) {
case MOVN_FMT:
FINSN_3ARG_SDPS(MOVN);
break;
case MOVZ_FMT:
FINSN_3ARG_SDPS(MOVZ);
break;
default:
goto pool32f_invalid;
}
break;
do_fpop:
gen_farith(ctx, mips32_op, rt, rs, rd, 0);
break;
default:
pool32f_invalid:
MIPS_INVAL("pool32f");
generate_exception(ctx, EXCP_RI);
break;
}
} else {
generate_exception_err(ctx, EXCP_CpU, 1);
}
break;
case POOL32I:
minor = (ctx->opcode >> 21) & 0x1f;
switch (minor) {
case BLTZ:
mips32_op = OPC_BLTZ;
goto do_branch;
case BLTZAL:
mips32_op = OPC_BLTZAL;
goto do_branch;
case BLTZALS:
mips32_op = OPC_BLTZALS;
goto do_branch;
case BGEZ:
mips32_op = OPC_BGEZ;
goto do_branch;
case BGEZAL:
mips32_op = OPC_BGEZAL;
goto do_branch;
case BGEZALS:
mips32_op = OPC_BGEZALS;
goto do_branch;
case BLEZ:
mips32_op = OPC_BLEZ;
goto do_branch;
case BGTZ:
mips32_op = OPC_BGTZ;
do_branch:
gen_compute_branch(ctx, mips32_op, 4, rs, -1, imm << 1);
*is_branch = 1;
break;
case TLTI:
mips32_op = OPC_TLTI;
goto do_trapi;
case TGEI:
mips32_op = OPC_TGEI;
goto do_trapi;
case TLTIU:
mips32_op = OPC_TLTIU;
goto do_trapi;
case TGEIU:
mips32_op = OPC_TGEIU;
goto do_trapi;
case TNEI:
mips32_op = OPC_TNEI;
goto do_trapi;
case TEQI:
mips32_op = OPC_TEQI;
do_trapi:
gen_trap(ctx, mips32_op, rs, -1, imm);
break;
case BNEZC:
case BEQZC:
gen_compute_branch(ctx, minor == BNEZC ? OPC_BNE : OPC_BEQ,
4, rs, 0, imm << 1);
break;
case LUI:
gen_logic_imm(env, OPC_LUI, rs, -1, imm);
break;
case SYNCI:
break;
case BC2F:
case BC2T:
generate_exception_err(ctx, EXCP_CpU, 2);
break;
case BC1F:
mips32_op = (ctx->opcode & (1 << 16)) ? OPC_BC1FANY2 : OPC_BC1F;
goto do_cp1branch;
case BC1T:
mips32_op = (ctx->opcode & (1 << 16)) ? OPC_BC1TANY2 : OPC_BC1T;
goto do_cp1branch;
case BC1ANY4F:
mips32_op = OPC_BC1FANY4;
goto do_cp1mips3d;
case BC1ANY4T:
mips32_op = OPC_BC1TANY4;
do_cp1mips3d:
check_cop1x(ctx);
check_insn(env, ctx, ASE_MIPS3D);
do_cp1branch:
gen_compute_branch1(env, ctx, mips32_op,
(ctx->opcode >> 18) & 0x7, imm << 1);
*is_branch = 1;
break;
case BPOSGE64:
case BPOSGE32:
default:
MIPS_INVAL("pool32i");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case POOL32C:
minor = (ctx->opcode >> 12) & 0xf;
switch (minor) {
case LWL:
mips32_op = OPC_LWL;
goto do_ld_lr;
case SWL:
mips32_op = OPC_SWL;
goto do_st_lr;
case LWR:
mips32_op = OPC_LWR;
goto do_ld_lr;
case SWR:
mips32_op = OPC_SWR;
goto do_st_lr;
#if defined(TARGET_MIPS64)
case LDL:
mips32_op = OPC_LDL;
goto do_ld_lr;
case SDL:
mips32_op = OPC_SDL;
goto do_st_lr;
case LDR:
mips32_op = OPC_LDR;
goto do_ld_lr;
case SDR:
mips32_op = OPC_SDR;
goto do_st_lr;
case LWU:
mips32_op = OPC_LWU;
goto do_ld_lr;
case LLD:
mips32_op = OPC_LLD;
goto do_ld_lr;
#endif
case LL:
mips32_op = OPC_LL;
goto do_ld_lr;
do_ld_lr:
gen_ld(env, ctx, mips32_op, rt, rs, SIMM(ctx->opcode, 0, 12));
break;
do_st_lr:
gen_st(ctx, mips32_op, rt, rs, SIMM(ctx->opcode, 0, 12));
break;
case SC:
gen_st_cond(ctx, OPC_SC, rt, rs, SIMM(ctx->opcode, 0, 12));
break;
#if defined(TARGET_MIPS64)
case SCD:
gen_st_cond(ctx, OPC_SCD, rt, rs, SIMM(ctx->opcode, 0, 12));
break;
#endif
case PREF:
break;
default:
MIPS_INVAL("pool32c");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case ADDI32:
mips32_op = OPC_ADDI;
goto do_addi;
case ADDIU32:
mips32_op = OPC_ADDIU;
do_addi:
gen_arith_imm(env, ctx, mips32_op, rt, rs, imm);
break;
case ORI32:
mips32_op = OPC_ORI;
goto do_logici;
case XORI32:
mips32_op = OPC_XORI;
goto do_logici;
case ANDI32:
mips32_op = OPC_ANDI;
do_logici:
gen_logic_imm(env, mips32_op, rt, rs, imm);
break;
case SLTI32:
mips32_op = OPC_SLTI;
goto do_slti;
case SLTIU32:
mips32_op = OPC_SLTIU;
do_slti:
gen_slt_imm(env, mips32_op, rt, rs, imm);
break;
case JALX32:
offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 2;
gen_compute_branch(ctx, OPC_JALX, 4, rt, rs, offset);
*is_branch = 1;
break;
case JALS32:
offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 1;
gen_compute_branch(ctx, OPC_JALS, 4, rt, rs, offset);
*is_branch = 1;
break;
case BEQ32:
gen_compute_branch(ctx, OPC_BEQ, 4, rt, rs, imm << 1);
*is_branch = 1;
break;
case BNE32:
gen_compute_branch(ctx, OPC_BNE, 4, rt, rs, imm << 1);
*is_branch = 1;
break;
case J32:
gen_compute_branch(ctx, OPC_J, 4, rt, rs,
(int32_t)(ctx->opcode & 0x3FFFFFF) << 1);
*is_branch = 1;
break;
case JAL32:
gen_compute_branch(ctx, OPC_JAL, 4, rt, rs,
(int32_t)(ctx->opcode & 0x3FFFFFF) << 1);
*is_branch = 1;
break;
case LWC132:
mips32_op = OPC_LWC1;
goto do_cop1;
case LDC132:
mips32_op = OPC_LDC1;
goto do_cop1;
case SWC132:
mips32_op = OPC_SWC1;
goto do_cop1;
case SDC132:
mips32_op = OPC_SDC1;
do_cop1:
gen_cop1_ldst(env, ctx, mips32_op, rt, rs, imm);
break;
case ADDIUPC:
{
int reg = mmreg(ZIMM(ctx->opcode, 23, 3));
int offset = SIMM(ctx->opcode, 0, 23) << 2;
gen_addiupc(ctx, reg, offset, 0, 0);
}
break;
case LB32:
mips32_op = OPC_LB;
goto do_ld;
case LBU32:
mips32_op = OPC_LBU;
goto do_ld;
case LH32:
mips32_op = OPC_LH;
goto do_ld;
case LHU32:
mips32_op = OPC_LHU;
goto do_ld;
case LW32:
mips32_op = OPC_LW;
goto do_ld;
#ifdef TARGET_MIPS64
case LD32:
mips32_op = OPC_LD;
goto do_ld;
case SD32:
mips32_op = OPC_SD;
goto do_st;
#endif
case SB32:
mips32_op = OPC_SB;
goto do_st;
case SH32:
mips32_op = OPC_SH;
goto do_st;
case SW32:
mips32_op = OPC_SW;
goto do_st;
do_ld:
gen_ld(env, ctx, mips32_op, rt, rs, imm);
break;
do_st:
gen_st(ctx, mips32_op, rt, rs, imm);
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
}
| 1threat
|
static int cudaupload_query_formats(AVFilterContext *ctx)
{
static const enum AVPixelFormat input_pix_fmts[] = {
AV_PIX_FMT_NV12, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P,
AV_PIX_FMT_NONE,
};
static const enum AVPixelFormat output_pix_fmts[] = {
AV_PIX_FMT_CUDA, AV_PIX_FMT_NONE,
};
AVFilterFormats *in_fmts = ff_make_format_list(input_pix_fmts);
AVFilterFormats *out_fmts = ff_make_format_list(output_pix_fmts);
ff_formats_ref(in_fmts, &ctx->inputs[0]->out_formats);
ff_formats_ref(out_fmts, &ctx->outputs[0]->in_formats);
return 0;
}
| 1threat
|
Mod Rewrite - htaccess - Making a "masked/pretty" query string to be sent to a Perl script (RewriteRule RewriteCondition) : I have tried for two days to no avail. I tried and modded every RewriteRule and Condition example I could find. This sounds so simple but, not for me. Very frustrated.
I know it is possible to use mod rewrite in my htaccess to:
Take:
http://example.com/directory/perlscript.pl?base64encodedquery=jhfkjdshfsdf78fs8y7sd8
Make a shorter URL:
http://example.com/? whatever just want to make it prettier
Incoming: I am using `use CGI;` thus `$qry->param('base64encodedquery'));`
Then I use `use MIME::Base64` to decode the query string (encoded previously).
I don't really need to encode and decode the query but, I am learning and just desire to mask / hide my query string that contains up to 15 short params.
I am resorting to asking here because all my attempts have failed. I would like to blame my severe Parkinsons but, I don't think I had the skills initially! I even read mod rewrite for beginners and it just does not make sense to me to the point of writing my own.
Thanks for any assistance.
| 0debug
|
document.write('<script src="evil.js"></script>');
| 1threat
|
Please Help I am getting Segmentation Fault in this code : > Question---**Interseting Merge Sort
Input--abc//first string
> def//second string
Output-- adbecf
Input 2-- abc
> defgh
Output adbecfgh**
I am getting segmentation fault in my code i don't know why i don't think my code points to any invalid pointer so please help me remove this code
Here is my Solution code in C
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
char *mergeTwo(char *a,char *b)
{ char *c;int k=0,i=0;
while(1)
{
if(a[i]!='\0' && b[i]!='\0')
{
if(a[i]>=b[i])
{
c[k++]=b[i];
c[k++]=a[i];
}
else
{ c[k++]=a[i];
c[k++]=b[i];
}
}
else if(a[i]!='\0' && b[i]=='\0')
{
c[k++]=a[i];
}
else if(a[i]=='\0' && b[i]!='\0')
{
c[k++]=b[i];
}
else if(a[i]=='\0' && b[i]=='\0')
{
c[k]='\0';
break;
}i++;
}
return c;
}
int main() {
char str1[100],str2[100],*str3;
gets(str1);
gets(str2);
str3= mergeTwo(str1,str2);
puts(str3);
return 0;
}
ERROR--
IN IMAGE
[ERROR][1]
[1]: https://i.stack.imgur.com/weGl2.png
| 0debug
|
static int net_slirp_init(Monitor *mon, VLANState *vlan, const char *model,
const char *name, int restricted,
const char *vnetwork, const char *vhost,
const char *vhostname, const char *tftp_export,
const char *bootfile, const char *vdhcp_start,
const char *vnameserver, const char *smb_export,
const char *vsmbserver)
{
struct in_addr net = { .s_addr = htonl(0x0a000200) };
struct in_addr mask = { .s_addr = htonl(0xffffff00) };
struct in_addr host = { .s_addr = htonl(0x0a000202) };
struct in_addr dhcp = { .s_addr = htonl(0x0a00020f) };
struct in_addr dns = { .s_addr = htonl(0x0a000203) };
#ifndef _WIN32
struct in_addr smbsrv = { .s_addr = 0 };
#endif
SlirpState *s;
char buf[20];
uint32_t addr;
int shift;
char *end;
struct slirp_config_str *config;
if (!tftp_export) {
tftp_export = legacy_tftp_prefix;
}
if (!bootfile) {
bootfile = legacy_bootp_filename;
}
if (vnetwork) {
if (get_str_sep(buf, sizeof(buf), &vnetwork, '/') < 0) {
if (!inet_aton(vnetwork, &net)) {
return -1;
}
addr = ntohl(net.s_addr);
if (!(addr & 0x80000000)) {
mask.s_addr = htonl(0xff000000);
} else if ((addr & 0xfff00000) == 0xac100000) {
mask.s_addr = htonl(0xfff00000);
} else if ((addr & 0xc0000000) == 0x80000000) {
mask.s_addr = htonl(0xffff0000);
} else if ((addr & 0xffff0000) == 0xc0a80000) {
mask.s_addr = htonl(0xffff0000);
} else if ((addr & 0xffff0000) == 0xc6120000) {
mask.s_addr = htonl(0xfffe0000);
} else if ((addr & 0xe0000000) == 0xe0000000) {
mask.s_addr = htonl(0xffffff00);
} else {
mask.s_addr = htonl(0xfffffff0);
}
} else {
if (!inet_aton(buf, &net)) {
return -1;
}
shift = strtol(vnetwork, &end, 10);
if (*end != '\0') {
if (!inet_aton(vnetwork, &mask)) {
return -1;
}
} else if (shift < 4 || shift > 32) {
return -1;
} else {
mask.s_addr = htonl(0xffffffff << (32 - shift));
}
}
net.s_addr &= mask.s_addr;
host.s_addr = net.s_addr | (htonl(0x0202) & ~mask.s_addr);
dhcp.s_addr = net.s_addr | (htonl(0x020f) & ~mask.s_addr);
dns.s_addr = net.s_addr | (htonl(0x0203) & ~mask.s_addr);
}
if (vhost && !inet_aton(vhost, &host)) {
return -1;
}
if ((host.s_addr & mask.s_addr) != net.s_addr) {
return -1;
}
if (vdhcp_start && !inet_aton(vdhcp_start, &dhcp)) {
return -1;
}
if ((dhcp.s_addr & mask.s_addr) != net.s_addr ||
dhcp.s_addr == host.s_addr || dhcp.s_addr == dns.s_addr) {
return -1;
}
if (vnameserver && !inet_aton(vnameserver, &dns)) {
return -1;
}
if ((dns.s_addr & mask.s_addr) != net.s_addr ||
dns.s_addr == host.s_addr) {
return -1;
}
#ifndef _WIN32
if (vsmbserver && !inet_aton(vsmbserver, &smbsrv)) {
return -1;
}
#endif
s = qemu_mallocz(sizeof(SlirpState));
s->slirp = slirp_init(restricted, net, mask, host, vhostname,
tftp_export, bootfile, dhcp, dns, s);
QTAILQ_INSERT_TAIL(&slirp_stacks, s, entry);
for (config = slirp_configs; config; config = config->next) {
if (config->flags & SLIRP_CFG_HOSTFWD) {
slirp_hostfwd(s, mon, config->str,
config->flags & SLIRP_CFG_LEGACY);
} else {
slirp_guestfwd(s, mon, config->str,
config->flags & SLIRP_CFG_LEGACY);
}
}
#ifndef _WIN32
if (!smb_export) {
smb_export = legacy_smb_export;
}
if (smb_export) {
slirp_smb(s, mon, smb_export, smbsrv);
}
#endif
s->vc = qemu_new_vlan_client(vlan, model, name, NULL, slirp_receive, NULL,
net_slirp_cleanup, s);
snprintf(s->vc->info_str, sizeof(s->vc->info_str),
"net=%s, restricted=%c", inet_ntoa(net), restricted ? 'y' : 'n');
return 0;
}
| 1threat
|
Is it possible to show warnings instead of errors on ALL of eslint rules? : <p>As the title says, would it be possible for eslint to show warnings instead of errors on ALL of the rules? I'm using Standard JS, if that information is relevant. </p>
<p>Thanks!</p>
| 0debug
|
NSAttributedString tail truncation in UILabel : <p>I'm using <a href="https://github.com/michaelloistl/ContextLabel" rel="noreferrer">ContextLabel</a> to parse @ , # and URL's. This is the best solution i found, cause it sizes correctly and dont affect performance. It firstly parses string at input and than converts it to <code>NSAttributedString</code> and after this assigns it to <code>attributedText</code> property of <code>UILabel</code>. Everything works as expected, except tail truncation - it's very incorrect ( see pic below ) </p>
<p><a href="https://i.stack.imgur.com/w6rT0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/w6rT0.png" alt="enter image description here"></a></p>
<p>Where shall i start digging - is it wrong attributes on attributed string? Or label layout issue? Thanks! </p>
| 0debug
|
Jest beforeAll() share between multiple test files : <p>I have a Node.js project that I'm testing using Jest. I have several test files that have the same setup requirement. Previously, all these tests were in one file, so I just had a <code>beforeAll(...)</code> that performed the common setup. Now, with the tests split into multiple files, it seems like I have to copy/paste that <code>beforeAll(...)</code> code into each of the files. That seems inelegant - is there a better way to do this, ideally where I can just write my <code>beforeAll(...)</code>/setup logic once, and "require" it from multiple test files? Note that there are other tests in my test suite that don't require this setup functionality, so I don't want to make <em>all</em> my tests run this setup (just a particular subset of test files).</p>
| 0debug
|
Slow SecureRandom initialization : <p>Suppose you do simple thing:</p>
<pre><code>public class Main {
public static void main(String[] args) {
long started = System.currentTimeMillis();
try {
new URL(args[0]).openConnection();
} catch (Exception ignore) {
}
System.out.println(System.currentTimeMillis() - started);
}
}
</code></pre>
<p>Now run it with <a href="http://localhost" rel="noreferrer">http://localhost</a> as <code>args[0]</code></p>
<p>It takes <code>~100 msec</code> to complete.</p>
<p>Now try <a href="https://localhost" rel="noreferrer">https://localhost</a></p>
<p>It takes <code>5000+ msec</code>. </p>
<p>Now run the same thing on linux or in docker:</p>
<ul>
<li>http: <code>~100 msec</code></li>
<li>https: <code>~350 msec</code></li>
</ul>
<p>Why is this?
Why such a huge difference between platforms?
What can you do about it?</p>
<p>For long-running application servers and applications with their own long and heavy initialization sequence, these 5 seconds may not matter.</p>
<p>However, there are plenty of applications where this initial 5sec "hang" matters and may become frustrating...</p>
| 0debug
|
webpack loaders and include : <p>I'm new to webpack and I'm trying to understand loaders as well as its properties such as test, loader, include etc.</p>
<p>Here is a sample snippet of webpack.config.js that I found in google.</p>
<pre><code>module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
include: [
path.resolve(__dirname, 'index.js'),
path.resolve(__dirname, 'config.js'),
path.resolve(__dirname, 'lib'),
path.resolve(__dirname, 'app'),
path.resolve(__dirname, 'src')
],
exclude: [
path.resolve(__dirname, 'test', 'test.build.js')
],
cacheDirectory: true,
query: {
presets: ['es2015']
}
},
]
}
</code></pre>
<ol>
<li><p>Am I right that test: /.js$/ will be used only for files with extension .js?</p></li>
<li><p>The loader: 'babel-loader', is the loader we install using npm</p></li>
<li><p>The include: I have many questions on this. Am I right that anything we put inside the array will be transpiled? That means, index.js, config.js, and all *.js files in lib, app and src will be transpiled.</p></li>
<li><p>More questions on the include: When files get transpiled, do the *.js files get concatenated into one big file?</p></li>
<li><p>I think exclude is self explanatory. It will not get transpiled.</p></li>
<li><p>What does query: { presets: ['es2015'] } do?</p></li>
</ol>
| 0debug
|
VS 2017 immediate window shows "Internal error in the C# compiler" : <p>I use Visual Studio 2017 (15.6.6). When debugging, I try to evaluate simple expressions like <code>int a = 2;</code> in the immediate window. An error</p>
<blockquote>
<p>Internal error in the C# compiler</p>
</blockquote>
<p>is thrown.</p>
<p>I tried to enable <code>Use Managed Compatibility Mode</code> as hinted at in <a href="https://stackoverflow.com/questions/48572079">this question</a> but it didn't help.</p>
<p>Thanks for any help.</p>
| 0debug
|
How to reference .Net standard in T4 file? : <p>I have a .Net standard 2.0 library. In this library I have a T4 file. The file contains these rows.</p>
<pre><code><#
foreach (MessageType enumValue in Enum.GetValues(typeof(MessageType)))
{
var name = Enum.GetName(typeof(MessageType), enumValue);
#>
</code></pre>
<p>I get the following error in Visual Studio. </p>
<blockquote>
<p>Compiling transformation: The type 'Enum' is defined in an assembly
that is not referenced. You must add a reference to assembly
'netstandard, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=cc7b13ffcd2ddd51'.</p>
</blockquote>
<p>How can I add a reference to 'netstandard'?</p>
| 0debug
|
static int sdp_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
RTSPState *rt = s->priv_data;
RTSPStream *rtsp_st;
int size, i, err;
char *content;
char url[1024];
content = av_malloc(SDP_MAX_SIZE);
size = get_buffer(s->pb, content, SDP_MAX_SIZE - 1);
if (size <= 0) {
av_free(content);
return AVERROR_INVALIDDATA;
}
content[size] ='\0';
sdp_parse(s, content);
av_free(content);
for(i=0;i<rt->nb_rtsp_streams;i++) {
rtsp_st = rt->rtsp_streams[i];
snprintf(url, sizeof(url), "rtp:
inet_ntoa(rtsp_st->sdp_ip),
rtsp_st->sdp_port,
rtsp_st->sdp_port,
rtsp_st->sdp_ttl);
if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) {
err = AVERROR_INVALIDDATA;
goto fail;
}
if ((err = rtsp_open_transport_ctx(s, rtsp_st)))
goto fail;
}
return 0;
fail:
rtsp_close_streams(rt);
return err;
}
| 1threat
|
I am trying to consolidate information from Sheet1(supplier) to master Sheet1 and Sheet2(supplier) to MasterSheet2 : Friends ,need Some Help on VBA(Macros for excel)
While trying to Copy SupplierFile1,File2(sheet2) to Masterfile(Sheet2)
After Using Dir to Access the supplier file and copying the data from sheet2 I am doing this
ActiveWorkbook.Worksheets("Sheet2").Activate
erow = Sheet2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Paste Destination:=Worksheets("Sheet2").Range(Cells(erow, 1), Cells(erow, 5)) "This part is showing error"
I am Not a programmer and tried the solutions available online and YouTube but nothing is working and need to get this right urgently.. any help would be greatly appreciated (any reference article would also help)
I am Not a programmer and tried the solutions available online and youtube but nothing is working and need to get this right urgently.. any help would be greatly appreciated (any reference article would also help)
| 0debug
|
int ff_default_query_formats(AVFilterContext *ctx)
{
return default_query_formats_common(ctx, ff_all_channel_layouts);
}
| 1threat
|
Finding a faster way of checking characters in js : <p>I'm trying to make something that gives an output based on your input. I would like it to take every letter and produce something with the next letter in the alphabet. So if I entered "Hello" it would produce "Ifmmp". The only way I can think to do this is with a series of ifs and else ifs, but I would like to know if there is a faster way.</p>
| 0debug
|
WebContentNotFound on refreshing page of SPA deployed as Azure Blob Static Website with CDN : <p>I have a SPA (built with angular) and deployed to Azure Blob Storage. Everything works fine and well as you go from the default domain but the moment I refresh any of the pages/routes, index.html no longer gets loaded and instead getting the error "the requested content does not exist"</p>
<p>Googling that term results in 3 results total so I'm at a loss trying to diagnose & fix this.</p>
| 0debug
|
How to add the view in browser option back into Visual Studio 2017 context menu? : <p>I've just upgraded to VS 2017 and unless I'm missing something the view in browser option on the right click menu seems to have vanished.</p>
<p>Anyone know how to get it back?</p>
| 0debug
|
Runable caller does not terminate : I'v made a runable which download a big file and called it in onCreate.
But it seems like onCreate is waiting for the runable to terminate.
Can any one tell me what is wrong?
private Handler Download_taskHandler = new Handler();
Download_taskHandler.postDelayed(Download_task, 0);
Thanks:)
| 0debug
|
Importing postman collection in python : <p>I have received a of postman collection.
It is basically a set of json files describing REST API calling methods in detail.</p>
<p>Now I would like to get rid of postman and use python libraries for these api calls e.g. requests</p>
<p>How to read the structured postman data in an easy way in python?
Any binding available?</p>
| 0debug
|
emulator: ERROR: A snapshot operation for 'Nexus_4_API_27' is pending and timeout has expired. Exiting : <pre><code>emulator: ERROR: A snapshot operation for 'Nexus_4_API_27' is pending and timeout has expired. Exiting...
</code></pre>
<p>I am getting this error when I am trying to open emulator from <strong>command-line</strong> with this bellow command.</p>
<pre><code>anjan@anjan-HP-Laptop-15-bs0xx:~/Android/Sdk/emulator$ ./emulator -avd Nexus_4_API_27
</code></pre>
<p>How to solve this problem?</p>
| 0debug
|
Formatting Joda Time LocalDate to MMddyyyy : <p>I am attempting to format a desired joda time LocalDate type to a mmddyyy format and I am running into trouble and not sure how to proceed. I've tried a couple different things so far and had no luck.</p>
<p>So I pretty much want to take a date like 04-15-2016 and get a LocalDate type from it in format, 04152016, but it still needs to be in the LocalDate format, not a string.</p>
<pre><code>DateTimeFormatter dtf = DateTimeFormat.forPattern("MMddyyyy");
LocalDate currentDate = LocalDate.parse("04152016", dtf);
System.out.println(currentDate);
</code></pre>
<p>The date comes out as 2016-04-15. If anyone could help me I would greatly appreciate it. Perhaps I am missing something fundamental when it comes to the Joda Time library.</p>
<p>THank you.</p>
| 0debug
|
when i press on bottom part of the button not working? : [![enter image description here][1]][1]
I made a custom view xib file with 2 buttons and i call it in my view controller but when I press the buttons the bottom part is not clickable only when I press the top part as in the image .. how can i resolve it?
thanks in advance
[1]: https://i.stack.imgur.com/hmT3I.png
| 0debug
|
void tlb_fill(CPUState *env1, target_ulong addr, int is_write, int mmu_idx,
void *retaddr)
{
TranslationBlock *tb;
CPUState *saved_env;
unsigned long pc;
int ret;
saved_env = env;
ret = cpu_arm_handle_mmu_fault(env, addr, is_write, mmu_idx);
if (unlikely(ret)) {
if (retaddr) {
pc = (unsigned long)retaddr;
tb = tb_find_pc(pc);
if (tb) {
cpu_restore_state(tb, env, pc);
}
}
raise_exception(env->exception_index);
}
env = saved_env;
}
| 1threat
|
static int usb_ehci_initfn(PCIDevice *dev)
{
EHCIState *s = DO_UPCAST(EHCIState, dev, dev);
uint8_t *pci_conf = s->dev.config;
int i;
pci_set_byte(&pci_conf[PCI_CLASS_PROG], 0x20);
pci_set_byte(&pci_conf[PCI_CAPABILITY_LIST], 0x00);
pci_set_byte(&pci_conf[PCI_INTERRUPT_PIN], 4);
pci_set_byte(&pci_conf[PCI_MIN_GNT], 0);
pci_set_byte(&pci_conf[PCI_MAX_LAT], 0);
pci_set_byte(&pci_conf[USB_SBRN], USB_RELEASE_2);
pci_set_byte(&pci_conf[0x61], 0x20);
pci_set_word(&pci_conf[0x62], 0x00);
pci_conf[0x64] = 0x00;
pci_conf[0x65] = 0x00;
pci_conf[0x66] = 0x00;
pci_conf[0x67] = 0x00;
pci_conf[0x68] = 0x01;
pci_conf[0x69] = 0x00;
pci_conf[0x6a] = 0x00;
pci_conf[0x6b] = 0x00;
pci_conf[0x6c] = 0x00;
pci_conf[0x6d] = 0x00;
pci_conf[0x6e] = 0x00;
pci_conf[0x6f] = 0xc0;
s->mmio[0x00] = (uint8_t) OPREGBASE;
s->mmio[0x01] = 0x00;
s->mmio[0x02] = 0x00;
s->mmio[0x03] = 0x01;
s->mmio[0x04] = NB_PORTS;
s->mmio[0x05] = 0x00;
s->mmio[0x06] = 0x00;
s->mmio[0x07] = 0x00;
s->mmio[0x08] = 0x80;
s->mmio[0x09] = 0x68;
s->mmio[0x0a] = 0x00;
s->mmio[0x0b] = 0x00;
s->irq = s->dev.irq[3];
usb_bus_new(&s->bus, &ehci_bus_ops, &s->dev.qdev);
for(i = 0; i < NB_PORTS; i++) {
usb_register_port(&s->bus, &s->ports[i], s, i, &ehci_port_ops,
USB_SPEED_MASK_HIGH);
s->ports[i].dev = 0;
}
s->frame_timer = qemu_new_timer_ns(vm_clock, ehci_frame_timer, s);
s->async_bh = qemu_bh_new(ehci_async_bh, s);
QTAILQ_INIT(&s->aqueues);
QTAILQ_INIT(&s->pqueues);
usb_packet_init(&s->ipacket);
qemu_register_reset(ehci_reset, s);
memory_region_init_io(&s->mem, &ehci_mem_ops, s, "ehci", MMIO_SIZE);
pci_register_bar(&s->dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mem);
return 0;
}
| 1threat
|
Unhandled rejection SequelizeUniqueConstraintError: Validation error : <p>I'm getting this error:</p>
<pre><code>Unhandled rejection SequelizeUniqueConstraintError: Validation error
</code></pre>
<p>How can I fix this?</p>
<p>This is my models/user.js</p>
<pre><code>"use strict";
module.exports = function(sequelize, DataTypes) {
var User = sequelize.define("User", {
id: { type: DataTypes.INTEGER, autoIncrement: true, primaryKey: true},
name: DataTypes.STRING,
environment_hash: DataTypes.STRING
}, {
tableName: 'users',
underscored: false,
timestamps: false
}
);
return User;
};
</code></pre>
<p>And this is my routes.js:</p>
<pre><code>app.post('/signup', function(request, response){
console.log(request.body.email);
console.log(request.body.password);
User
.find({ where: { name: request.body.email } })
.then(function(err, user) {
if (!user) {
console.log('No user has been found.');
User.create({ name: request.body.email }).then(function(user) {
// you can now access the newly created task via the variable task
console.log('success');
});
}
});
});
</code></pre>
| 0debug
|
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
int *got_sub_ptr,
AVPacket *avpkt)
{
int i, ret = 0;
if (!avpkt->data && avpkt->size) {
av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n");
return AVERROR(EINVAL);
}
if (!avctx->codec)
return AVERROR(EINVAL);
if (avctx->codec->type != AVMEDIA_TYPE_SUBTITLE) {
av_log(avctx, AV_LOG_ERROR, "Invalid media type for subtitles\n");
return AVERROR(EINVAL);
}
*got_sub_ptr = 0;
get_subtitle_defaults(sub);
if ((avctx->codec->capabilities & AV_CODEC_CAP_DELAY) || avpkt->size) {
AVPacket pkt_recoded;
AVPacket tmp = *avpkt;
int did_split = av_packet_split_side_data(&tmp);
if (did_split) {
memset(tmp.data + tmp.size, 0,
FFMIN(avpkt->size - tmp.size, AV_INPUT_BUFFER_PADDING_SIZE));
}
pkt_recoded = tmp;
ret = recode_subtitle(avctx, &pkt_recoded, &tmp);
if (ret < 0) {
*got_sub_ptr = 0;
} else {
avctx->internal->pkt = &pkt_recoded;
if (avctx->pkt_timebase.den && avpkt->pts != AV_NOPTS_VALUE)
sub->pts = av_rescale_q(avpkt->pts,
avctx->pkt_timebase, AV_TIME_BASE_Q);
ret = avctx->codec->decode(avctx, sub, got_sub_ptr, &pkt_recoded);
av_assert1((ret >= 0) >= !!*got_sub_ptr &&
!!*got_sub_ptr >= !!sub->num_rects);
if (sub->num_rects && !sub->end_display_time && avpkt->duration &&
avctx->pkt_timebase.num) {
AVRational ms = { 1, 1000 };
sub->end_display_time = av_rescale_q(avpkt->duration,
avctx->pkt_timebase, ms);
}
for (i = 0; i < sub->num_rects; i++) {
if (sub->rects[i]->ass && !utf8_check(sub->rects[i]->ass)) {
av_log(avctx, AV_LOG_ERROR,
"Invalid UTF-8 in decoded subtitles text; "
"maybe missing -sub_charenc option\n");
avsubtitle_free(sub);
return AVERROR_INVALIDDATA;
}
}
if (tmp.data != pkt_recoded.data) {
pkt_recoded.side_data = NULL;
pkt_recoded.side_data_elems = 0;
av_packet_unref(&pkt_recoded);
}
if (avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB)
sub->format = 0;
else if (avctx->codec_descriptor->props & AV_CODEC_PROP_TEXT_SUB)
sub->format = 1;
avctx->internal->pkt = NULL;
}
if (did_split) {
av_packet_free_side_data(&tmp);
if(ret == tmp.size)
ret = avpkt->size;
}
if (*got_sub_ptr)
avctx->frame_number++;
}
return ret;
}
| 1threat
|
Composer update memory limit : <p>I need to run composer update at my hosting so I log in with ssh and try to run comand:</p>
<pre><code>composer update
</code></pre>
<p>inside /www folder where I have laravel and composer instalation</p>
<p>but I get error:
<a href="https://i.stack.imgur.com/FGC01.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FGC01.png" alt="enter image description here"></a></p>
<p>in contact with my hosting provider they tell me to run command:</p>
<pre><code>php -d memory_limit=512M composer update
</code></pre>
<p>I run this command but I get: "Could not open file: composer" </p>
<p>What to do? What is the soluton here?</p>
| 0debug
|
How to pad all strings in a comma separated set of strings : <p>Is there a way to pad each individual string in a comma separated string in one shot?</p>
<p>I can split the comma separated string, go through each string and pad it (with 0, for 3 character) and join the array elements again but not sure if it can be done in one shot.</p>
<p>For instance, if I have:</p>
<pre><code>var someString = "01,002,7";
</code></pre>
<p>how can I end up with "001,002,007"?</p>
<p>I can do this client side (jQuery) or server side (C#)</p>
| 0debug
|
create-react-app, installation error ("command not found") : <p>I have installed create-react-app exactly as instructed on the facebook instruction page (<a href="https://facebook.github.io/react/blog/2016/07/22/create-apps-with-no-configuration.html" rel="noreferrer">https://facebook.github.io/react/blog/2016/07/22/create-apps-with-no-configuration.html</a>):</p>
<blockquote>
<p>First, install the global package:</p>
<p><code>npm install -g create-react-app</code></p>
</blockquote>
<p>I did this. It appeared to work fine - the file was installed to </p>
<pre><code>users/*name*/.node_modules_global/lib/node_modules/create-react-app
</code></pre>
<p>I'm not really sure why global install takes it to this path, but there you have it.</p>
<p>Next instruction:</p>
<blockquote>
<p>Now you can use it to create a new app:</p>
<p><code>create-react-app hello-world</code></p>
</blockquote>
<p>Couldn't be simpler, right? But Terminal spits out this at me:</p>
<pre><code>-bash: create-react-app: command not found
</code></pre>
<p>It's probably something very simple I'm missing but I don't really know where to look. If anyone can help I'd really appreciate it!</p>
<p>Thanks in advance.</p>
<p><strong>Note: I'm using Node v6.3.1, and npm v3.10.3</strong></p>
| 0debug
|
I don't know why my code won't run for no reason : I have been studying programmin for 3 months and I don't have a lot of experience so my question maybe silly for someone. This code I wrote in order to read the number in reverse won't run and there is no syntac errors.
public class fdujfdryujhftyh {
public static void main(String[] args) {
int a=8023;
int rev=a%10;
a=a/10;
while(a!=0); {
rev=rev*10+a%10;
a=a/10;
}
System.out.println("Reverse number is"+rev);
// TODO Auto-generated method stub
}
}
| 0debug
|
int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
void *logctx, int is_nalff, int nal_length_size,
enum AVCodecID codec_id)
{
int consumed, ret = 0;
const uint8_t *next_avc = buf + (is_nalff ? 0 : length);
pkt->nb_nals = 0;
while (length >= 4) {
H2645NAL *nal;
int extract_length = 0;
int skip_trailing_zeros = 1;
if (buf == next_avc) {
int i;
for (i = 0; i < nal_length_size; i++)
extract_length = (extract_length << 8) | buf[i];
if (extract_length > length) {
av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit size.\n");
return AVERROR_INVALIDDATA;
}
buf += nal_length_size;
length -= nal_length_size;
next_avc = buf + extract_length;
} else {
int buf_index = find_next_start_code(buf, next_avc);
buf += buf_index;
length -= buf_index;
if (buf == next_avc)
continue;
if (length > 0) {
extract_length = length;
} else if (pkt->nb_nals == 0) {
av_log(logctx, AV_LOG_ERROR, "No NAL unit found\n");
return AVERROR_INVALIDDATA;
} else {
break;
}
}
if (pkt->nals_allocated < pkt->nb_nals + 1) {
int new_size = pkt->nals_allocated + 1;
H2645NAL *tmp = av_realloc_array(pkt->nals, new_size, sizeof(*tmp));
if (!tmp)
return AVERROR(ENOMEM);
pkt->nals = tmp;
memset(pkt->nals + pkt->nals_allocated, 0,
(new_size - pkt->nals_allocated) * sizeof(*tmp));
pkt->nals_allocated = new_size;
}
nal = &pkt->nals[pkt->nb_nals++];
consumed = ff_h2645_extract_rbsp(buf, extract_length, nal);
if (consumed < 0)
return consumed;
if (consumed < length - 3 &&
buf[consumed] == 0x00 && buf[consumed + 1] == 0x00 &&
buf[consumed + 2] == 0x01 && buf[consumed + 3] == 0xE0)
skip_trailing_zeros = 0;
nal->size_bits = get_bit_length(nal, skip_trailing_zeros);
ret = init_get_bits(&nal->gb, nal->data, nal->size_bits);
if (ret < 0)
return ret;
if (codec_id == AV_CODEC_ID_HEVC)
ret = hevc_parse_nal_header(nal, logctx);
else
ret = h264_parse_nal_header(nal, logctx);
if (ret <= 0) {
if (ret < 0) {
av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit %d, skipping.\n",
nal->type);
}
pkt->nb_nals--;
}
buf += consumed;
length -= consumed;
}
return 0;
}
| 1threat
|
Spring/Postman Content type 'application/octet-stream' not supported : <p>I'm using Postman to send the following request:
<a href="https://i.stack.imgur.com/RYHai.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RYHai.png" alt="enter image description here"></a></p>
<p>My controller looks like this:</p>
<pre><code>@RestController
@RequestMapping(path = RestPath.CHALLENGE)
public class ChallengeController {
private final ChallengeService<Challenge> service;
@Autowired
public ChallengeController(ChallengeService service) {
this.service = service;
}
@ApiOperation(value = "Creates a new challenge in the system")
@RequestMapping(method = RequestMethod.POST, consumes = {MediaType.MULTIPART_FORM_DATA_VALUE, MediaType.APPLICATION_OCTET_STREAM_VALUE},
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public ChallengeDto create(@ApiParam(value = "The details of the challenge to create") @RequestPart("challengeCreate") @Valid @NotNull @NotBlank ChallengeCreateDto challengeCreate,
@ApiParam(value = "The challenge file") @RequestPart("file") @Valid @NotNull @NotBlank MultipartFile file) {
return service.create(challengeCreate, file);
}
}
</code></pre>
<p>I already tried to change the "consumes" to delete the APPLICATION_OCTET_STREAM_VALUE to MULTIPART_FORM_DATA_VALUE and also tried to delete it, but none of these helped.</p>
<p>Please tell me if you need more information.
Thanks.</p>
| 0debug
|
void helper_lret_protected(int shift, int addend)
{
helper_ret_protected(shift, 0, addend);
#ifdef CONFIG_KQEMU
if (kqemu_is_ok(env)) {
env->exception_index = -1;
cpu_loop_exit();
}
#endif
}
| 1threat
|
PHP PROXY GRABBER CHECKER WITH CURL BULK FREE PROXIES :
**I am No PHP expert and I am learning all I can. Self-taught so far. Over time I am more and more understanding the logic of code. My code of choice is PHP and Curl. I like it much more than anything else I have played with.**
This is a proxy grabber and tester script that I put together a couple of years ago. I think one of the main reasons others choose Python and JavaScript because PHP processing can be a bit slow for certain things.
I tried many things. I like Rolling Curl but I can not seem to get it working with this. Is there anyway to speed this up or maybe throttle it with JavaScript? The processing time and resources are way too high! If so can anyone provide some Examples? ***HERE IS THE CODE:***
//Settings
error_reporting(E_ALL);
ini_set('max_execution_time', 0);
require_once ('classes/class.multicurl.php');
set_time_limit(0);
//Short Delay
$delay = rand(2,4);
//Long Delay
$longdelay = rand(4,7);
//Checking Proxies
$fileName = "leeched/proxies.txt";
//where to save successful proxies
$success = "goodproxies/success.txt";
$source = file('sources/sources.txt');
//SET Cookie
$c = new Curl;
foreach($source as $sources) {
//Request To Delete Duplicate Proxies
$c->addRequest(trim($sources));
}
$c->chunk(25);
$c->perform();
$proxies = array();
foreach( $c->results as $url => $res ) {
//REGEX MATCH
preg_match_all('@[0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}:[0-9] {1,6}@', $res, $m);
$eachproxy = stream_get_contents($res);
$proxies[$url]= $m[0];
{
while ($proxies == time() && $eachproxy > 4) { // go into "waiting" when we going to fast
usleep(100000); // wait .1 second and ask again
}
if ($proxies != time()) { // remember to reset this second and the cnt
$proxies = time();
$eachproxy = 0;
}
}
foreach($proxies as $url => $parr) {
$str = implode("\n", $parr);
file_put_contents( 'leeched/proxies.txt',$str);
$k = count($parr);
$str2 = date('h:i:s d m')." | \t".$k."\t".$url."\n";
file_put_contents('logs/counts.txt', $str2, FILE_APPEND);
}
$uar = file('leeched/proxies.txt');
$uar = array_unique($uar);
$str = implode("\n", $uar)."\n";
$str = preg_replace('/^\h*\v+/m', '', $str);
file_put_contents( 'leeched/proxies.txt',$str);
}
//Proxy Testing
if(!is_file($fileName)) die ('Proxy file not available');
$proxies = file($fileName);
for($p=0; $p<count($proxies);$p++) {
$ch = curl_init(); //initizlize and set url
curl_setopt ($ch, CURLOPT_URL, "http://www.yordomain.com/check.php");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HTTPGET,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 7);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_PROXY, trim($proxies[$p]));
$data = curl_exec($ch);
usleep(100000);
if (strpos($data, 'Anonymous') !== false) {
usleep(100000);
echo "<img src=\"images/good.png\"> <font color=\"#7CFC00\"><strong>" .$proxies[$p] . " </font></strong><font color=\"#FFFFE0\"><strong> THIS IS A WORKING ANONYMOUS PROXY SAVED TO /goodproxies/success.txt</font></strong><font color=\"yellow\"><strong> " . "Total time: " .curl_getinfo($ch, CURLINFO_TOTAL_TIME)." seconds!</font></strong><img src=\"images/small.png\"> <br/><br/>";
$f=fopen($success, "a");
fwrite($f, $proxies[$p]);
fclose($f);
}
elseif (curl_errno($ch)) {
usleep(100000);
echo "<img src=\"images/bad.png\"> <font color=\"white\"><strong>" .$proxies[$p] . " </font></strong><font color=\"red\"><strong>ERROR:</font></strong><font color=\"#00FFFF\"><strong> ".curl_error($ch)." </font></strong><img src=\"images/redx.png\"> <br/><br/>";
}
else {
echo "<img src=\"images/warning.png\"> <font color=\"#7CFC00\"><strong> " .$proxies[$p] . " </font></strong><font color=\"white\"><strong> THERE WAS NO ERROR CONNECTING BUT THIS PROXY IS NOT ANONYMOUS! NOT SAVED</font></strong> <font color=\"#FF69B4\"><strong>(No content from source)</font></strong><img src=\"images/redx.png\"> <br/><br/>";
}
flush();
curl_close($ch);
}
$done = "done";
echo $done;
| 0debug
|
DateDiff return different result for each timezones : <p>I have problem with PHP DateDiff, i dont understand why each timezone returns different results, for example in this case Prague return 0 month, and US return 1 month.</p>
<p>What do this difference and how i return 1 month (instead 30 days, when i adding 1 month) as expected?</p>
<p>code Europe/Prague:</p>
<pre><code>date_default_timezone_set("Europe/Prague");
$from = new \DateTimeImmutable('2016-09-01');
$to = $from->add(new \DateInterval('P1M'));
var_dump($from);
var_dump($to);
var_dump($from->diff($to)->m);
var_dump($from->diff($to)->d);
</code></pre>
<p>result Europe/Prague:</p>
<pre><code>object(DateTimeImmutable)#1 (3) {
["date"]=>
string(26) "2016-09-01 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(13) "Europe/Prague"
}
object(DateTimeImmutable)#3 (3) {
["date"]=>
string(26) "2016-10-01 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(13) "Europe/Prague"
}
int(0)
int(30)
</code></pre>
<p>--</p>
<p>code US/Pacific:</p>
<pre><code>date_default_timezone_set("US/Pacific");
$from = new \DateTimeImmutable('2016-09-01');
$to = $from->add(new \DateInterval('P1M'));
var_dump($from);
var_dump($to);
var_dump($from->diff($to)->m);
var_dump($from->diff($to)->d);
</code></pre>
<p>result US/Pacific:</p>
<pre><code>object(DateTimeImmutable)#2 (3) {
["date"]=>
string(26) "2016-09-01 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(10) "US/Pacific"
}
object(DateTimeImmutable)#4 (3) {
["date"]=>
string(26) "2016-10-01 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(10) "US/Pacific"
}
int(1)
int(0)
</code></pre>
| 0debug
|
Two constructor calls inside one constructor in C# : <p>I know how to call another constructor for a constructor from the same class or the base class, but how can I do both at once? Here is an example of what I am looking to achieve, noting that in a real case we might want to do something more complex than just set a property:</p>
<pre><code>public class BaseClass
{
public BaseClass(object param)
{
// base constructor
}
}
public class DerivedClass
{
DateTime Date { get; private set; }
public DerivedClass()
{
Date = GenerateDate();
}
public DerivedClass(object param) : base(param)
{
// How do I make it call DerivedClass() ?
}
}
</code></pre>
| 0debug
|
static void dec_div(DisasContext *dc)
{
unsigned int u;
u = dc->imm & 2;
LOG_DIS("div\n");
if (!(dc->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK)
&& !((dc->env->pvr.regs[0] & PVR0_USE_DIV_MASK))) {
tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP);
t_gen_raise_exception(dc, EXCP_HW_EXCP);
}
if (u)
gen_helper_divu(cpu_R[dc->rd], *(dec_alu_op_b(dc)), cpu_R[dc->ra]);
else
gen_helper_divs(cpu_R[dc->rd], *(dec_alu_op_b(dc)), cpu_R[dc->ra]);
if (!dc->rd)
tcg_gen_movi_tl(cpu_R[dc->rd], 0);
}
| 1threat
|
getting the most 32 significant bits from unsigned long long error : <p>I am trying to store the most significant 32 bits that is stored in unsigned long long into unsigned int.
I can simply use the code below I got from Stack Overflow:</p>
<pre><code>uint64_t temp;
uint32_t msw, lsw;
msw = (temp & 0xFFFFFFFF00000000) >> 32;
lsw = temp & 0x00000000FFFFFFFF;
</code></pre>
<p>However, I've used an array to do a similar thing:</p>
<pre><code>unsigned long long * bits64 = new unsigned long long[1];
*(bits64 + 0) = 18446744073709551615;
unsigned int * first32 = (*(bits64 + 0) & 0xFFFFFFFF00000000) >> 32;
</code></pre>
<p>Why am I getting</p>
<blockquote>
<p>'Cannot initialize a variable of type 'unsigned int *' with an rvalue
of type unsigned long long'</p>
</blockquote>
<p>How do I fix this?</p>
| 0debug
|
static int ff_vp56_decode_mbs(AVCodecContext *avctx, void *data,
int jobnr, int threadnr)
{
VP56Context *s0 = avctx->priv_data;
int is_alpha = (jobnr == 1);
VP56Context *s = is_alpha ? s0->alpha_context : s0;
AVFrame *const p = s->frames[VP56_FRAME_CURRENT];
int mb_row, mb_col, mb_row_flip, mb_offset = 0;
int block, y, uv;
ptrdiff_t stride_y, stride_uv;
int res;
int damaged = 0;
if (p->key_frame) {
p->pict_type = AV_PICTURE_TYPE_I;
s->default_models_init(s);
for (block=0; block<s->mb_height*s->mb_width; block++)
s->macroblocks[block].type = VP56_MB_INTRA;
} else {
p->pict_type = AV_PICTURE_TYPE_P;
vp56_parse_mb_type_models(s);
s->parse_vector_models(s);
s->mb_type = VP56_MB_INTER_NOVEC_PF;
}
if (s->parse_coeff_models(s))
goto next;
memset(s->prev_dc, 0, sizeof(s->prev_dc));
s->prev_dc[1][VP56_FRAME_CURRENT] = 128;
s->prev_dc[2][VP56_FRAME_CURRENT] = 128;
for (block=0; block < 4*s->mb_width+6; block++) {
s->above_blocks[block].ref_frame = VP56_FRAME_NONE;
s->above_blocks[block].dc_coeff = 0;
s->above_blocks[block].not_null_dc = 0;
}
s->above_blocks[2*s->mb_width + 2].ref_frame = VP56_FRAME_CURRENT;
s->above_blocks[3*s->mb_width + 4].ref_frame = VP56_FRAME_CURRENT;
stride_y = p->linesize[0];
stride_uv = p->linesize[1];
if (s->flip < 0)
mb_offset = 7;
for (mb_row=0; mb_row<s->mb_height; mb_row++) {
if (s->flip < 0)
mb_row_flip = s->mb_height - mb_row - 1;
else
mb_row_flip = mb_row;
for (block=0; block<4; block++) {
s->left_block[block].ref_frame = VP56_FRAME_NONE;
s->left_block[block].dc_coeff = 0;
s->left_block[block].not_null_dc = 0;
}
memset(s->coeff_ctx, 0, sizeof(s->coeff_ctx));
memset(s->coeff_ctx_last, 24, sizeof(s->coeff_ctx_last));
s->above_block_idx[0] = 1;
s->above_block_idx[1] = 2;
s->above_block_idx[2] = 1;
s->above_block_idx[3] = 2;
s->above_block_idx[4] = 2*s->mb_width + 2 + 1;
s->above_block_idx[5] = 3*s->mb_width + 4 + 1;
s->block_offset[s->frbi] = (mb_row_flip*16 + mb_offset) * stride_y;
s->block_offset[s->srbi] = s->block_offset[s->frbi] + 8*stride_y;
s->block_offset[1] = s->block_offset[0] + 8;
s->block_offset[3] = s->block_offset[2] + 8;
s->block_offset[4] = (mb_row_flip*8 + mb_offset) * stride_uv;
s->block_offset[5] = s->block_offset[4];
for (mb_col=0; mb_col<s->mb_width; mb_col++) {
if (!damaged) {
int ret = vp56_decode_mb(s, mb_row, mb_col, is_alpha);
if (ret < 0)
damaged = 1;
}
if (damaged)
vp56_conceal_mb(s, mb_row, mb_col, is_alpha);
for (y=0; y<4; y++) {
s->above_block_idx[y] += 2;
s->block_offset[y] += 16;
}
for (uv=4; uv<6; uv++) {
s->above_block_idx[uv] += 1;
s->block_offset[uv] += 8;
}
}
}
next:
if (p->key_frame || s->golden_frame) {
av_frame_unref(s->frames[VP56_FRAME_GOLDEN]);
if ((res = av_frame_ref(s->frames[VP56_FRAME_GOLDEN], p)) < 0)
return res;
}
av_frame_unref(s->frames[VP56_FRAME_PREVIOUS]);
FFSWAP(AVFrame *, s->frames[VP56_FRAME_CURRENT],
s->frames[VP56_FRAME_PREVIOUS]);
return 0;
}
| 1threat
|
I need to rename files based on a matching string in another file : <p>I have a list of files like this</p>
<pre><code>186866-Total-Respondents.csv
343764-Total-Respondents.csv
415612-Total-Respondents.csv
761967-Total-Respondents.csv
</code></pre>
<p>And I want to rename them by matching the first string of numbers above to the same string of numbers in a file called data.txt which is in the same directory.</p>
<p>The contents of data.txt is below</p>
<pre><code>2018-09-Client-1-761967-Brand-1-Total-Respondents
2018-09-Client-1-415612-Brand-2-Two-Total-Respondents
2018-09-Client-1-186866-Brand-Three-Total-Respondents
2018-09-Client-2-343764-Brand1-Total-Respondents
2018-09-Client-3-347654-No-Name-Brand-Total-Respondents
2018-09-Client-3-109321-House-Brand-Total-Respondents
</code></pre>
<p>The end result is that the 4 matching files above will be renamed to</p>
<pre><code>2018-09-Client-1-186866-Brand-Three-Total-Respondents.csv
2018-09-Client-2-343764-Brand1-Total-Respondents.csv
2018-09-Client-1-415612-Brand-2-Two-Total-Respondents.csv
2018-09-Client-1-761967-Brand-1-Total-Respondents.csv
</code></pre>
<p>I have found a <a href="https://stackoverflow.com/questions/24071114/rename-part-of-file-name-based-on-exact-match-in-contents-of-another-file">similar question</a> which uses sed and regex but I can't edit the regex to rename successfully.</p>
<p>I'm guessing that sed or awk would work well here?</p>
| 0debug
|
Load reCAPTCHA dynamically : <p>There are several ways to load reCAPTCHA using javascript such as below:</p>
<pre><code><html>
<head>
<title>Loading captcha with JavaScript</title>
<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<script type='text/javascript'>
var captchaContainer = null;
var loadCaptcha = function() {
captchaContainer = grecaptcha.render('captcha_container', {
'sitekey' : 'Your sitekey',
'callback' : function(response) {
console.log(response);
}
});
};
</script>
</head>
<body>
<div id="captcha_container"></div>
<input type="button" id="MYBTN" value="MYBTN">
<script src="https://www.google.com/recaptcha/api.js?onload=loadCaptcha&render=explicit" async defer></script>
</body>
</html>
</code></pre>
<p>This code load captcha on pageload. I want load reCAPTCHA just when clicked on "MYBTN". So the code changes into:</p>
<pre><code><html>
<head>
<title>Loading captcha with JavaScript</title>
<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<script type='text/javascript'>
$('#MYBTN').on('click',function(){
var captchaContainer = null;
var loadCaptcha = function() {
captchaContainer = grecaptcha.render('captcha_container', {
'sitekey' : 'Your sitekey',
'callback' : function(response) {
console.log(response);
}
});
};
});
</script>
</head>
<body>
<div id="captcha_container"></div>
<input type="button" id="MYBTN" value="MYBTN">
<script src="https://www.google.com/recaptcha/api.js?onload=loadCaptcha&render=explicit" async defer></script>
</body>
</html>
</code></pre>
<p>But this code didn't work when I click on "MYBTN" and reCAPTCHA not load.
Help me plz. Thanks.</p>
| 0debug
|
C++ , while loop wont continue : while (Day == 1);
{
cout << Day << " ";
userNum = Day / 2;
cin >> Day;
}
Hi guys , int Day and Day = 20. I don't get why the loop doesn't work , any help and if possible with explanation . Thanks
| 0debug
|
Transpiling Array.prototype.flat away with @babel? : <p>I inadvertently introduced a backwards compatibility issue in my React app by using <code>Array.prototype.flat</code>. I was very surprised this didn't get resolved by transpiling - I thought this would result in es2015 compatible code.</p>
<p>How can I get Babel 7 to transpile this? (If my reading of the sources is right in Babel 6 there was still a plugin for this but since this has begun to roll out to browsers support has been dropped?)</p>
<p>Tools:</p>
<ul>
<li>@babel/core@7.0.0</li>
<li>webpack@4.18.0</li>
</ul>
<p>My top-level configuration files look like this:</p>
<h3>webpack.config.js</h3>
<pre><code>var path = require('path')
module.exports = {
entry: "./src/index.js",
output: {
path: path.join(__dirname, 'dist', 'assets'),
filename: "bundle.js",
sourceMapFilename: "bundle.map"
},
devtool: '#source-map',
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules)/,
loader: 'babel-loader'
}
]
}}
</code></pre>
<h3>.babelrc</h3>
<pre><code>{
"presets": [ "@babel/preset-env", "@babel/react" ],
"plugins": [["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal" }]]
}
</code></pre>
<h3>.browserslistrc</h3>
<pre><code>chrome 58
ie 11
</code></pre>
| 0debug
|
Free function that gives a lexicographically bigger string each time : <p>I am implementing a toy db, and I need a <em>free</em> function that gives me a lexicophgraically bigger string each time it's called. It's for naming segment files. </p>
<p>Let's assume I have a max of 1000 files, and I'd prefer if the string was less than 10 characters long.</p>
<p>Could someone give me the easiest example of such a function in python? I'd really like to be a free function as I don't want to introduce complexity with state. </p>
| 0debug
|
static void do_tb_flush(CPUState *cpu, void *data)
{
unsigned tb_flush_req = (unsigned) (uintptr_t) data;
tb_lock();
if (tcg_ctx.tb_ctx.tb_flush_count != tb_flush_req) {
goto done;
}
#if defined(DEBUG_FLUSH)
printf("qemu: flush code_size=%ld nb_tbs=%d avg_tb_size=%ld\n",
(unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer),
tcg_ctx.tb_ctx.nb_tbs, tcg_ctx.tb_ctx.nb_tbs > 0 ?
((unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer)) /
tcg_ctx.tb_ctx.nb_tbs : 0);
#endif
if ((unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer)
> tcg_ctx.code_gen_buffer_size) {
cpu_abort(cpu, "Internal error: code buffer overflow\n");
}
CPU_FOREACH(cpu) {
int i;
for (i = 0; i < TB_JMP_CACHE_SIZE; ++i) {
atomic_set(&cpu->tb_jmp_cache[i], NULL);
}
}
tcg_ctx.tb_ctx.nb_tbs = 0;
qht_reset_size(&tcg_ctx.tb_ctx.htable, CODE_GEN_HTABLE_SIZE);
page_flush_tb();
tcg_ctx.code_gen_ptr = tcg_ctx.code_gen_buffer;
atomic_mb_set(&tcg_ctx.tb_ctx.tb_flush_count,
tcg_ctx.tb_ctx.tb_flush_count + 1);
done:
tb_unlock();
}
| 1threat
|
static void vertical_filter(unsigned char *first_pixel, int stride,
int *bounding_values)
{
int i;
int filter_value;
for (i = 0; i < 8; i++, first_pixel++) {
filter_value =
(first_pixel[-(2 * stride)] * 1) -
(first_pixel[-(1 * stride)] * 3) +
(first_pixel[ (0 )] * 3) -
(first_pixel[ (1 * stride)] * 1);
filter_value = bounding_values[(filter_value + 4) >> 3];
first_pixel[-(1 * stride)] = SATURATE_U8(first_pixel[-(1 * stride)] + filter_value);
first_pixel[0] = SATURATE_U8(first_pixel[0] - filter_value);
}
}
| 1threat
|
Java - text not showing when for() is executing : Below is the example demonstrates that the text ("A","B","C" and "testing in progress...") for each Label and TextArea will not showing when a for() is executing. It will shows simultaneously once for() is finished....!
Any solution to overcome this 'phenomenon'?
Example:-
public class Test1Controller
{
@FXML
private Label l1;
@FXML
private Label l2;
@FXML
private Label l3;
@FXML
private TextArea info;
@FXML
private Button B1;
@FXML
void B1_runing(ActionEvent event)
{
l1.setText("A");
l2.setText("B");
l3.setText("C");
info.appendText("testing in progress...\n");
B1.setDisable(true);
for( int i=0; i<800; i++ )
{
for( int x=0; x<10000000; x++ );
}
info.appendText("end...\n");
}
}
| 0debug
|
Why I could not access localhost folder by using Xampp? : <p>my Xampp is working fine.ports are like this <code>Apache:81,MySql:3307</code>.But I could not access localhost by typing <code>http://localhost</code></p>
<p>Then get this error <a href="https://i.stack.imgur.com/ZoCUX.png" rel="nofollow noreferrer">error</a></p>
<p>How I solve this error.</p>
| 0debug
|
Trying to pass value through Forms, but not working correctly : Dim form As New Mainuser(TextBox1.Text)
For some reason, even though TextBox1 exists, it still says it's not declared.
Also, in my other part of the code, `Mainuser.Show()`, it says can not be simplified. Here is my full code if you want to help me with that:
Login.vb:
`Dim form As New Mainuser(TextBox1.Text)
If TextBox8.Text = My.Settings.username AndAlso TextBox9.Text = My.Settings.password Then
MessageBox.Show("You have successfully been logged in!", "Login Successfull")
Close()
Mainuser.Show()`
Mainuser.vb:
Public Class Mainuser
Public Sub New(ByVal value As String)
InitializeComponent()
Label1.Text = value
End Sub
Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles PictureBox2.Click
HTML_Editor.Show()
End Sub
End Class
@Bugs I'm hoping you can suggest something.
Like I said before if this doesn't make any sense I'll comment below what you want.
| 0debug
|
Print the following 1 2 3 4 Bus 6 7 8 9 bUs 11 12 13 14 buS : <pre><code>Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
for(i=1; i<=n; i++)
{
if(i%3==2 && i%5==0)
{
System.out.println("Bus");
}
if(i%3==1 && i%5==0)
{
System.out.println("bUs");
}
if(i%3==0 && i%5==0)
{
System.out.println("buS");
}
System.out.println(i+" ");
}
</code></pre>
<p>The above program is also printing the number 5,10,15 but these should not print </p>
| 0debug
|
HOW TO FREE a MALLOC'd attribute of a STACK ALLOCATED STRUCT : typedef struct {
int s;
...
char* temp_status;
...
} param;
pararm MQK;
MQK.temp_status = (char*) malloc(sizeof(char)*14);
...
free(&(MQK.temp_status)); <<< ERROR
// E R R O R R E P O R T //
gcc ...
csim.c: In function ‘main’:
csim.c:348:9: error: attempt to free a non-heap object ‘MQK’ [- Werror=free-nonheap-object]
free(&(MQK.temp_status));
^
cc1: all warnings being treated as errors
How should I free it?
I have to FREE a MALLOC'd attribute of a STACK ALLOCATED STRUCT.
The below is the error. Any aha-ers! help mE!
| 0debug
|
Excel VBA: Split Numbers and Text from a string into Columns : <p>I have a column in my excel in the following format:</p>
<pre><code>Column A
1.2kg
100ml
2m
200
</code></pre>
<p>I need to run the VBA to split the numbers and text separately into two columns as:</p>
<pre><code>Column A | Column B
1.2 | kg
100 | ml
2 | m
200 |
</code></pre>
<p>I've also found a similar question in this site, however it isn't work for my VBA. Can anyone help me on this? </p>
<p>PS. I use excel 2007</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.