problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Quick keyword search : Simple code here, I'm trying to write a code that can pick up on specific keywords, but I'm not having a lot of luck. Here's the code:
#include <iostream>
int main(){
std::string input;
bool isUnique = true;
std::cout<<"Please type a word: ";
std::cin>>input;
if(input == "the" || "me" || "it"){
isUnique = false;
}
if(isUnique){
std::cout<<"UNIQUE!!"<<std::endl;
}
else
std::cout<<"COMMON"<<std::endl;
}
If you type in any of those three words (in the if statement), you'll get the proper output from the program ("COMMON"). However, if you type anything else, you'll get that same exact output. If I limit the program to only search for one word (ie: "the") and then test it, everything works as it should, but as soon as there are two or more keywords, the program just lists everything as "COMMON". I've also tried replacing the or statements with commas but that also didn't do anything. The code I'm trying to implement this into is going to have 50+ keywords so I'm trying to find the most efficient way to search for these words.
| 0debug
|
Android Studio: Canvas added to activity_main.xml crashes app : My problem:
I have been trying to make an app where a ball bounces around based on orientation change. I had some problems with that so I started this project differently. The ball moves up/down/right/left when I use arrow keys. The ball itself moves great, the text is seen on the screen (at least I saw it at one point!) but I can't get these two on the screen together.
**Every time I add BouncingBall to activity_main.xml the app starts to crash and nothing is seen on the screen.** When I remove the BouncingBall from activity_main.xml, I see the ball again and also can move it but cannot see the text. What seems to be the officer, problem? My brain isn't working properly anymore and there might be something funny in the code that I just don't see.
**activity_main.xml**:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.maija.pomppupallo.MainActivity">
<com.example.maija.pomppupallo.BouncingBallView
android:id="@+id/bouncingBallView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/hellou"
android:layout_width="195dp"
android:layout_height="70dp"
android:text="@string/hello"
android:textColor="@color/colorAccent"
android:textSize="30sp"
android:translationZ="100dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textorientation"
android:layout_width="287dp"
android:layout_height="50dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="64dp"
android:text="@string/orientation"
android:textColor="@android:color/holo_red_dark"
android:textSize="30sp"
android:translationZ="100dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.506"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
**Main Activity.java**:
package com.example.maija.pomppupallo;
import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
TextView tv1, tv2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView(R.layout.activity_main);
View BouncingBallView = new BouncingBallView(this);
setContentView (BouncingBallView);
}
}
**BouncingBallView.java**:
package com.example.maija.pomppupallo;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.view.KeyEvent;
import android.view.View;
public class BouncingBallView extends View {
private int xMin = 0;
private int xMax;
private int yMin = 0;
private int yMax;
private float ballRadius = 130;
private float ballX = ballRadius + 20;
private float ballY = ballRadius + 40;
private float ballSpeedX = 0;
private float ballSpeedY = 0;
private RectF ballBounds;
private Paint paint;
public BouncingBallView(Context context) {
super (context);
ballBounds = new RectF();
paint = new Paint();
this.setFocusable(true);
this.requestFocus();
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
switch (keyCode){
case KeyEvent.KEYCODE_DPAD_RIGHT:
ballSpeedY=0;
if (ballSpeedX > 0) {
;
}
else ballSpeedX = 20;
break;
case KeyEvent.KEYCODE_DPAD_LEFT:
ballSpeedY=0;
if (ballSpeedX < 0) {
;
}
else ballSpeedX = -20;
break;
case KeyEvent.KEYCODE_DPAD_UP:
ballSpeedX=0;
if (ballSpeedY < 0) {
;
}
else ballSpeedY = -20;
break;
case KeyEvent.KEYCODE_DPAD_DOWN:
ballSpeedX=0;
if (ballSpeedY > 0) {
;
}
else ballSpeedY = 20;
break;
case KeyEvent.KEYCODE_DPAD_CENTER:
ballSpeedX=0;
ballSpeedY=0;
break;
case KeyEvent.KEYCODE_A:
float maxRadius = (xMax>yMax) ? yMax/2*0.9f : xMax/2*0.9f;
if (ballRadius < maxRadius) {ballRadius*=1.05;}
break;
case KeyEvent.KEYCODE_Z:
if (ballRadius > 20){ballRadius*=0.95;}
break;
}
return true;
}
@Override
protected void onDraw(Canvas canvas) {
ballBounds.set (ballX-ballRadius, ballY-ballRadius, ballX+ballRadius, ballY+ballRadius);
paint.setColor (Color.CYAN);
canvas.drawOval (ballBounds, paint);
update();
try {
Thread.sleep (30);
}catch (InterruptedException e){}
invalidate ();
}
private void update(){
ballX+=ballSpeedX;
ballY+=ballSpeedY;
if(ballX+ballRadius > xMax){
ballSpeedX = -ballSpeedX;
ballX = xMax-ballRadius;
}else if (ballX-ballRadius < xMin){
ballSpeedX = -ballSpeedX;
ballX = xMin+ballRadius;
}
if(ballY+ballRadius > yMax){
ballSpeedY = -ballSpeedY;
ballY = yMax-ballRadius;
}else if (ballY-ballRadius < yMin){
ballSpeedY = -ballSpeedY;
ballY = yMin+ballRadius;
}
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
xMax = w-1;
yMax = h-1;
}
}
**AndroidOrientationSensor.java**:
package com.example.maija.pomppupallo;
import android.app.Activity;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.view.OrientationEventListener;
import android.widget.TextView;
import android.widget.Toast;
public class AndroidOrientationSensor extends Activity{
TextView textviewOrientation, tv1, tv2;
OrientationEventListener myOrientationEventListener;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textviewOrientation = (TextView)findViewById(R.id.textorientation);
tv1 = (TextView) findViewById (R.id.textorientation);
tv2 = (TextView) findViewById (R.id.hellou);
myOrientationEventListener
= new OrientationEventListener(this, SensorManager.SENSOR_DELAY_NORMAL){
@Override
public void onOrientationChanged(int arg0) {
// TODO Auto-generated method stub
textviewOrientation.setText("Orientation is: " + String.valueOf(arg0));
}};
if (myOrientationEventListener.canDetectOrientation()){
Toast.makeText(this, "Can DetectOrientation", Toast.LENGTH_LONG).show();
myOrientationEventListener.enable();
}
else{
Toast.makeText(this, "Can't DetectOrientation", Toast.LENGTH_LONG).show();
finish();
}
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
myOrientationEventListener.disable();
}
}
Okay. I hope someone understands what the problem is here! Thank you in advance!
*Note: The Sensor-file isn't ready yet, there is some errors.*
| 0debug
|
windows 7 entreprise .bat double click doesn t work Windows can t find file : When i double click on a file .bat it display: Windows can t find file ..bat. If i use cmd or right click run as administrator it works. On collegue's computer it works, the double click. I verify the regedit i have the same of my collegues. Do you have any ideas?
Thanks
| 0debug
|
Embed UIViewController inside a UIView : <p>I want to embed a UIViewController inside a UIView. I want to create this programmatically. I have created the UIViewController inside the storyboard.</p>
<p>My code to create a empty UIView:</p>
<pre><code>let myNewView=UIView(frame: CGRect(x: (0 + screenHeight / 2), y: leftView.frame.origin.y, width: screenHeight / 2, height: leftView.frame.height))
myNewView.backgroundColor=UIColor.lightGray
self.view.addSubview(myNewView)
</code></pre>
<p>And the code to append the UIViewController to the view: </p>
<pre><code>let storyboard = UIStoryboard(name: "Main", bundle: nil)
var controller: UIViewController = storyboard.instantiateViewController(withIdentifier: "testView") as UIViewController
myNewView.addSubview(controller.view)
</code></pre>
<p>This displays the view inside my UIView, but not at the correct way. The UIView is in this case 512 pixels wide. While the (embeded) UIViewcontroller thinks that is is 1024 pixels wide (the full screen width).</p>
<p>How can I fix it that the embeded view gets the width and height from its parent (the UIView)?</p>
| 0debug
|
static CharDriverState *qmp_chardev_open_udp(const char *id,
ChardevBackend *backend,
ChardevReturn *ret,
Error **errp)
{
ChardevUdp *udp = backend->u.udp;
ChardevCommon *common = qapi_ChardevUdp_base(udp);
QIOChannelSocket *sioc = qio_channel_socket_new();
if (qio_channel_socket_dgram_sync(sioc,
udp->local, udp->remote,
errp) < 0) {
object_unref(OBJECT(sioc));
return NULL;
}
return qemu_chr_open_udp(sioc, common, errp);
}
| 1threat
|
void *get_mmap_addr(unsigned long size)
{
return NULL;
}
| 1threat
|
void qemu_spice_init(void)
{
QemuOpts *opts = QTAILQ_FIRST(&qemu_spice_opts.head);
const char *password, *str, *x509_dir, *addr,
*x509_key_password = NULL,
*x509_dh_file = NULL,
*tls_ciphers = NULL;
char *x509_key_file = NULL,
*x509_cert_file = NULL,
*x509_cacert_file = NULL;
int port, tls_port, len, addr_flags;
spice_image_compression_t compression;
spice_wan_compression_t wan_compr;
if (!opts) {
return;
port = qemu_opt_get_number(opts, "port", 0);
tls_port = qemu_opt_get_number(opts, "tls-port", 0);
if (!port && !tls_port) {
return;
password = qemu_opt_get(opts, "password");
if (tls_port) {
x509_dir = qemu_opt_get(opts, "x509-dir");
if (NULL == x509_dir) {
x509_dir = ".";
len = strlen(x509_dir) + 32;
str = qemu_opt_get(opts, "x509-key-file");
if (str) {
x509_key_file = qemu_strdup(str);
} else {
x509_key_file = qemu_malloc(len);
snprintf(x509_key_file, len, "%s/%s", x509_dir, X509_SERVER_KEY_FILE);
str = qemu_opt_get(opts, "x509-cert-file");
if (str) {
x509_cert_file = qemu_strdup(str);
} else {
x509_cert_file = qemu_malloc(len);
snprintf(x509_cert_file, len, "%s/%s", x509_dir, X509_SERVER_CERT_FILE);
str = qemu_opt_get(opts, "x509-cacert-file");
if (str) {
x509_cacert_file = qemu_strdup(str);
} else {
x509_cacert_file = qemu_malloc(len);
snprintf(x509_cacert_file, len, "%s/%s", x509_dir, X509_CA_CERT_FILE);
x509_key_password = qemu_opt_get(opts, "x509-key-password");
x509_dh_file = qemu_opt_get(opts, "x509-dh-file");
tls_ciphers = qemu_opt_get(opts, "tls-ciphers");
addr = qemu_opt_get(opts, "addr");
addr_flags = 0;
if (qemu_opt_get_bool(opts, "ipv4", 0)) {
addr_flags |= SPICE_ADDR_FLAG_IPV4_ONLY;
} else if (qemu_opt_get_bool(opts, "ipv6", 0)) {
addr_flags |= SPICE_ADDR_FLAG_IPV6_ONLY;
spice_server = spice_server_new();
spice_server_set_addr(spice_server, addr ? addr : "", addr_flags);
if (port) {
spice_server_set_port(spice_server, port);
if (tls_port) {
spice_server_set_tls(spice_server, tls_port,
x509_cacert_file,
x509_cert_file,
x509_key_file,
x509_key_password,
x509_dh_file,
tls_ciphers);
if (password) {
spice_server_set_ticket(spice_server, password, 0, 0, 0);
if (qemu_opt_get_bool(opts, "disable-ticketing", 0)) {
auth = "none";
spice_server_set_noauth(spice_server);
#if SPICE_SERVER_VERSION >= 0x000801
if (qemu_opt_get_bool(opts, "disable-copy-paste", 0)) {
spice_server_set_agent_copypaste(spice_server, false);
compression = SPICE_IMAGE_COMPRESS_AUTO_GLZ;
str = qemu_opt_get(opts, "image-compression");
if (str) {
compression = parse_compression(str);
spice_server_set_image_compression(spice_server, compression);
wan_compr = SPICE_WAN_COMPRESSION_AUTO;
str = qemu_opt_get(opts, "jpeg-wan-compression");
if (str) {
wan_compr = parse_wan_compression(str);
spice_server_set_jpeg_compression(spice_server, wan_compr);
wan_compr = SPICE_WAN_COMPRESSION_AUTO;
str = qemu_opt_get(opts, "zlib-glz-wan-compression");
if (str) {
wan_compr = parse_wan_compression(str);
spice_server_set_zlib_glz_compression(spice_server, wan_compr);
#if SPICE_SERVER_VERSION >= 0x000600
str = qemu_opt_get(opts, "streaming-video");
if (str) {
int streaming_video = parse_stream_video(str);
spice_server_set_streaming_video(spice_server, streaming_video);
spice_server_set_agent_mouse
(spice_server, qemu_opt_get_bool(opts, "agent-mouse", 1));
spice_server_set_playback_compression
(spice_server, qemu_opt_get_bool(opts, "playback-compression", 1));
#endif
qemu_opt_foreach(opts, add_channel, NULL, 0);
spice_server_init(spice_server, &core_interface);
using_spice = 1;
migration_state.notify = migration_state_notifier;
add_migration_state_change_notifier(&migration_state);
qemu_spice_input_init();
qemu_spice_audio_init();
qemu_free(x509_key_file);
qemu_free(x509_cert_file);
qemu_free(x509_cacert_file);
| 1threat
|
Pass base class as an argument in a member function of the derived : <p>I have a derived class from an abstract class, and I am trying to pass it as an argument of a member class of the derived one. I also have a forward declaration issue. Any suggestions?</p>
<pre><code>class base;
void print(*base);
class base {
public:
const int number = 5;
// ... virtual funcs etc.
};
class derived:public base {
public:
void test() {
print(&base); // I guess here is the mistake
};
void print(*base) {
cout << base->number << endl;
}
</code></pre>
| 0debug
|
tsc - ignore errors at command line : <p>I have this:</p>
<pre><code>$ tsc -m amd --outFile dist/out.js lib/index.ts
</code></pre>
<blockquote>
<p>lib/index.ts(87,48): error TS1005: ';' expected.</p>
</blockquote>
<p>Is there a command line option I can use to ignore errors?</p>
| 0debug
|
how to convert a Series of arrays into a single matrix in pandas/numpy? : <p>I somehow got a <code>pandas.Series</code> which contains a bunch of arrays in it, as the <code>s</code> in the code below.</p>
<pre><code>data = [[1,2,3],[2,3,4],[3,4,5],[2,3,4],[3,4,5],[2,3,4],
[3,4,5],[2,3,4],[3,4,5],[2,3,4],[3,4,5]]
s = pd.Series(data = data)
s.shape # output ---> (11L,)
# try to convert s to matrix
sm = s.as_matrix()
# but...
sm.shape # output ---> (11L,)
</code></pre>
<p>How can I convert the <code>s</code> into a matrix with shape (11,3)? Thanks!</p>
| 0debug
|
Rewrite rules and let abstraction in GHC : <p>I have a rewrite rule that looks like this:</p>
<pre><code>{-# RULES
"modify/fusedModify" forall f g key book. modify key f (modify key g book) = fusedModify key f g book
#-}
</code></pre>
<p>Which fires in the following function:</p>
<pre><code>pb :: PersonB
pb = ...
fusionB' :: PersonB
fusionB' =
let l x = (modify #name ('c':) (modify #name ('a':) x))
in l pb
</code></pre>
<p>However, without let (and presumably let-abstraction?) it does not fire:</p>
<pre><code>fusionB :: PersonB
fusionB = modify #name ('c':) (modify #name ('a':) pb)
</code></pre>
<p>If it went the <em>other</em> way - that is, if the let-abstracted version didn't cause a firing, but <code>fusionB</code> did - I think I'd understand. It could be that in the specific case, <code>fusedModify</code> has the right type signature, but in the general (more polymorphic) case, it doesn't. But why in the world am I seeing this? </p>
<p>For what it's worth, the definition of <code>fusedModify</code> is <a href="https://github.com/turingjump/bookkeeper/blob/fusion/bookkeeper/src/Bookkeeper/Internal.hs#L127" rel="noreferrer">here</a>, and the file with <code>fusionB</code> and <code>fusionB'</code> is <a href="https://github.com/turingjump/bookkeeper/blob/fusion/bookkeeper/bench/Main.hs" rel="noreferrer">here</a>. I've tried <code>unsafeCoercing</code> type equalities to get both signatures to match up (in reality, though GHC doesn't realize it, they do always match), but somehow that doesn't help either. </p>
<p><em>EDIT</em>: I should perhaps mention that I'm using GHC 8.0.1.</p>
| 0debug
|
I am unable to figure out where to add a while-loop to my already finished code to get the min and max to work correctly : My issue is not knowing how to properly configure this section of coding to get the max and min to work properly.
"For the max/min logic to work correctly,
it had to be placed WITHIN a loop, not after it.
Due to that, a WHILE loop would have been preferred.
(Or use correctly the max() and min() methods.)"
I have tried moving the if statements that include the max and min statements around to no avail. Python 3.7.3, using IDLE.
def user_grade(statistic = None):
f = []
for grade in range(5):
if statistic == "max":
print('Max: {}'.format(max(f)))
if statistic == "min":
print('Min: {}'.format(min(f)))
f.append(float(input("Enter Grade (percentage): ")))
else:
print('Average: {}'.format(sum(f)/len(f)))
Expected Output: #Numbers will vary depending on user input.
Enter Grade (percentage): 99
Enter Grade (percentage): 98
Enter Grade (percentage): 97
Enter Grade (percentage): 96
Enter Grade (percentage): 95
Max: 99.0
Average: 97.0
None #The 'min" should be here instead of None.
#Current Output
Traceback (most recent call last):
line 22, in <module>
print(user_grade('max'))
line 13, in user_grade
print('Max: {}'.format(max(f)))
ValueError: max() arg is an empty sequence
| 0debug
|
I don't why my android app keep crashing : I am build a voce recognition app that does something when I say a specific word such as "open" and it opens something etc. but the problem is that my app keep crashing when I run it on my phone and I tap the speak button. I don't know what else to do? I tried giving it internet and voice recognition permission but it still doesn't help
here is the code in java (android studio)
public class MainActivity extends Activity {
private static final int VOICE_RECOGNITION_REQUEST_CODE = 1234;
private TextView resultText;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button speakButton = (Button) findViewById(R.id.SpeakButton);
speakButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view)
{
startVoiceRecognitionActivity();
}
});
}
void startVoiceRecognitionActivity(){
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getClass().getPackage().getName());
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 5);
startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);
}
@Override
protected void onActivityResult (int requestCode,int resultCode, Intent data){
String wordStr = null;
String[] words = null;
String firstWord = null;
String secondWord = null;
if (requestCode == VOICE_RECOGNITION_REQUEST_CODE && resultCode == RESULT_OK)
{
ArrayList<String> matches = data
.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
wordStr = matches.get(0);
words = wordStr.split(" ");
firstWord = words[0];
secondWord = words[1];
}
if (firstWord.equals("open"))
{
resultText = (TextView)findViewById(R.id.ResultText);
resultText.setText("Results: Open Command Works");
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.starlinginteractivesoftworks.musiccompanion">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I look at the log and it said:
08-07 20:12:57.813 14350-14350/? E/BoostFramework: BoostFramework() : Exception_1 = java.lang.ClassNotFoundException: Didn't find class "com.qualcomm.qti.Performance" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib64, /vendor/lib64]]
08-07 20:12:58.509 14350-14350/com.starlinginteractivesoftworks.musiccompanion E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.starlinginteractivesoftworks.musiccompanion, PID: 14350
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.speech.action.RECOGNIZE_SPEECH launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } (has extras) }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1839)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1531)
at android.app.Activity.startActivityForResult(Activity.java:4399)
at android.app.Activity.startActivityForResult(Activity.java:4358)
at com.starlinginteractivesoftworks.musiccompanion.MainActivity.startVoiceRecognitionActivity(MainActivity.java:55)
at com.starlinginteractivesoftworks.musiccompanion.MainActivity$1.onClick(MainActivity.java:43)
at android.view.View.performClick(View.java:6205)
at android.widget.TextView.performClick(TextView.java:11103)
at android.view.View$PerformClick.run(View.java:23653)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
| 0debug
|
.Net Framework 4.6.1 not defaulting to TLS 1.2 : <p>Our client have recently upgrade the security protocol to TLS 1.2. Therefore We have our application upgraded to 4.6.1 expecting the security protocol will be default to TLS 1.2 but it is not. Any idea why?</p>
| 0debug
|
void ff_compute_frame_duration(AVFormatContext *s, int *pnum, int *pden, AVStream *st,
AVCodecParserContext *pc, AVPacket *pkt)
{
AVRational codec_framerate = s->iformat ? st->codec->framerate :
av_inv_q(st->codec->time_base);
int frame_size;
*pnum = 0;
*pden = 0;
switch (st->codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
if (st->r_frame_rate.num && !pc) {
*pnum = st->r_frame_rate.den;
*pden = st->r_frame_rate.num;
} else if (st->time_base.num * 1000LL > st->time_base.den) {
*pnum = st->time_base.num;
*pden = st->time_base.den;
} else if (codec_framerate.den * 1000LL > codec_framerate.num) {
*pnum = codec_framerate.den;
*pden = codec_framerate.num;
*pden *= st->codec->ticks_per_frame;
av_assert0(st->codec->ticks_per_frame);
if (pc && pc->repeat_pict) {
av_assert0(s->iformat);
if (*pnum > INT_MAX / (1 + pc->repeat_pict))
*pden /= 1 + pc->repeat_pict;
else
*pnum *= 1 + pc->repeat_pict;
}
if (st->codec->ticks_per_frame > 1 && !pc)
*pnum = *pden = 0;
}
break;
case AVMEDIA_TYPE_AUDIO:
frame_size = av_get_audio_frame_duration(st->codec, pkt->size);
if (frame_size <= 0 || st->codec->sample_rate <= 0)
break;
*pnum = frame_size;
*pden = st->codec->sample_rate;
break;
default:
break;
}
}
| 1threat
|
Is there a way to edit css of new google forms? : <p>Before I used to be able to just copy the source code of the form and paste the part between <code><form></form></code> into the page and add my own styling. But this doesn't seem to work anymore.
Has anyone found a way to still be able to customize google forms?</p>
| 0debug
|
golang, how to find out if 'map[string][][]int' has a value? : golang, how to find out if 'map[string][][]int' has a value?
var a map[string][][]int
var aa map[string][][]int = map[string][][]int{"a": [][]int{{10, 10}, {20, 20}}}
var bb map[string][][]int = map[string][][]int{"b": [][]int{{30, 30}, {40, 40}}}
fmt.Println(aa) // >> map[a:[[10 10] [20 20]] b:[[10 10] [20 20]]]
then,
How do i know if '[30, 30]' is in 'aa'?
I want to check, whether 'aa' has '[30 30]'.
please help me.
| 0debug
|
Why there is dependencies when i copy a List<T> in a List<List<T>>? : <p>I'm creating a little C# apps using List of an object and i have a very noob question :</p>
<p><strong>First i'm filling my object 'A' , then i add in my list named 'lstA' :</strong></p>
<pre><code>List<List<A>> Lst_LstA = new List<List<A>>(); // List of List<A>
List<A> lstA = new List<A>(); // List of my object <A>
A myA = new A();
A.xxx = xx;
A.yyy = yy;
lstA.Add(A);
Lst_LstA.Add(lstA);
lstA.Clear();
</code></pre>
<p>What is my problem ? Very simple : When i call <strong>lstA.Clear()</strong>, it clear my <strong>lstA</strong> list, perfect, but...it clear too the element in my <strong>lst_LstA<></strong> list.</p>
<p>I need to clear the <strong>lstA</strong> List, but only these list.</p>
<p>Why the Clear() modify too the other list ? How solve this simply ?</p>
<p>Thanks a lot,</p>
<p>best regards,</p>
| 0debug
|
Python, get the name of the variable in an array, to be used as part of another statement : Im fairly new with Python, and I was creating a new script in which I generate an array that contains a list of strings(g='g_o.DisplacementMultiplier_'+str(y+1), where y varies from 0 to 400).
This later has to be used to set four properties in a third party software, but I see that the syntax im using set the properties for the variable g and not for g_o.DisplacementMultiplier_#)
Attached is the code
thank you.
import smtplib
import math
import time
import imp
import numpy as np
s_o,g_o=new_server
s_o.new()
# Geometry
Bench = 5 # Crest bench
Angle = 23
Height = 15.3
# Frequencies
fz=[]
Tmin=0.01
Tmax=4
Tstep=0.01
Ts = np.arange(Tmin, (Tmax+Tstep), Tstep)
fz = float(1)/Ts
# Calculate x-lenght of slope
dtot= Height / math.tan(math.pi*Angle/180)
# Calculate xmax
xmax = (2 * dtot)+ Bench
# Displacement
g_o.linedispl (0, 0, xmax, 0)
g_o.set(g_o.Line_1.LineDisplacement.Displacement_x, "Prescribed")
g_o.set(g_o.Line_1.LineDisplacement.Displacement_y, "Fixed")
g_o.set(g_o.Line_1.LineDisplacement.ux_start, 1)
# Generate displc multipliers
for y in range (0, len(fz)):
g_o.displmultiplier()
g='g_o.DisplacementMultiplier_'+str(y+1)
g_o.set(g[y].Amplitude, 10)
g_o.set(g[y].DataType, "Accelerations")
g_o.set(g[y].Frequency, fz[y])
The error id get form that code is g_o.set(g[y].Amplitude, 10)
AttributeError: 'str' object has no attribute 'Amplitude'
| 0debug
|
org.json.JSONException: End of input at character BUG json android : hello everyone i know that this issue is very known but i can't solucionate so far :(! after of all, i have a project and the data is stored perfectly in the DB (localhost) im using www.000webhost.com. so the problem it isnt the php files or something with the connection of my app. the issue happens with
> JSONObject jsonResponse = new JSONObject(response);
in this stackover issue http://stackoverflow.com/questions/14036847/org-json-jsonexception-end-of-input-at-character somebody wrote that the solution is this:
Change
JSONObject jsonObject = new JSONObject(result);
to
result=getJSONUrl(url); //<< get json string from server
JSONObject jsonObject = new JSONObject(result);
but in my app the method getJSONUrl doesn't exists so that option doesnt work for me :( some advice my friends?
## RegisterActivity.java
package com.tonikamitv.loginregister;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.toolbox.Volley;
import org.json.JSONException;
import org.json.JSONObject;
public class RegisterActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
final EditText etAge = (EditText) findViewById(R.id.etAge);
final EditText etName = (EditText) findViewById(R.id.etName);
final EditText etUsername = (EditText) findViewById(R.id.etUsername);
final EditText etPassword = (EditText) findViewById(R.id.etPassword);
final Button bRegister = (Button) findViewById(R.id.bRegister);
bRegister.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final String name = etName.getText().toString();
final String username = etUsername.getText().toString();
final int age = Integer.parseInt(etAge.getText().toString());
final String password = etPassword.getText().toString();
Response.Listener<String> responseListener = new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonResponse = new JSONObject(response);
boolean success = jsonResponse.getBoolean("success");
if (success) {
Intent intent = new Intent(RegisterActivity.this, LoginActivity.class);
RegisterActivity.this.startActivity(intent);
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(RegisterActivity.this);
builder.setMessage("Register Failed")
.setNegativeButton("Retry", null)
.create()
.show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
};
RegisterRequest registerRequest = new RegisterRequest(name, username, age, password, responseListener);
RequestQueue queue = Volley.newRequestQueue(RegisterActivity.this);
queue.add(registerRequest);
}
});
}
}
## the error in the console
5-02 22:17:35.391 1041-1041/com.tonikamitv.loginregister W/System.err: org.json.JSONException: End of input at character 0 of
05-02 22:17:35.391 1041-1041/com.tonikamitv.loginregister W/System.err: at org.json.JSONTokener.syntaxError(JSONTokener.java:450)
05-02 22:17:35.391 1041-1041/com.tonikamitv.loginregister W/System.err: at org.json.JSONTokener.nextValue(JSONTokener.java:97)
05-02 22:17:35.391 1041-1041/com.tonikamitv.loginregister W/System.err: at org.json.JSONObject.<init>(JSONObject.java:156)
05-02 22:17:35.391 1041-1041/com.tonikamitv.loginregister W/System.err: at org.json.JSONObject.<init>(JSONObject.java:173)
05-02 22:17:35.391 1041-1041/com.tonikamitv.loginregister W/System.err: at com.tonikamitv.loginregister.RegisterActivity$1$1.onResponse(RegisterActivity.java:43)
05-02 22:17:35.391 1041-1041/com.tonikamitv.loginregister W/System.err: at com.tonikamitv.loginregister.RegisterActivity$1$1.onResponse(RegisterActivity.java:39)
05-02 22:17:35.391 1041-1041/com.tonikamitv.loginregister W/System.err: at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:60)
05-02 22:17:35.391 1041-1041/com.tonikamitv.loginregister W/System.err: at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
05-02 22:17:35.391 1041-1041/com.tonikamitv.loginregister W/System.err: at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
05-02 22:17:35.391 1041-1041/com.tonikamitv.loginregister W/System.err: at android.os.Handler.handleCallback(Handler.java:739)
05-02 22:17:35.391 1041-1041/com.tonikamitv.loginregister W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
05-02 22:17:35.391 1041-1041/com.tonikamitv.loginregister W/System.err: at android.os.Looper.loop(Looper.java:135)
05-02 22:17:35.391 1041-1041/com.tonikamitv.loginregister W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5910)
05-02 22:17:35.391 1041-1041/com.tonikamitv.loginregister W/System.err: at java.lang.reflect.Method.invoke(Native Method)
05-02 22:17:35.391 1041-1041/com.tonikamitv.loginregister W/System.err: at java.lang.reflect.Method.invoke(Method.java:372)
05-02 22:17:35.391 1041-1041/com.tonikamitv.loginregister W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
05-02 22:17:35.391 1041-1041/com.tonikamitv.loginregister W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
05-02 22:24:07.721 1041-1041/com.tonikamitv.loginregister D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
05-02 22:25:31.951 1041-1041/com.tonikamitv.loginregister W/IInputConnectionWrapper: showStatusIcon on inactive InputConnection
| 0debug
|
Can I choose where my conda environment is stored? : <p>Can I change the path /Users/nolan/miniconda/envs/ to another one when creating a virtual environment ? I'd like it to be specific to my project directory. (As we can do with virtualenv)</p>
<pre><code>$conda info -e
Using Anaconda Cloud api site https://api.anaconda.org
# conda environments:
#
_build /Users/nolan/miniconda/envs/_build
myen3 /Users/nolan/miniconda/envs/myen3
nolanemirot /Users/nolan/miniconda/envs/nolanemirot
root * /Users/nolan/miniconda
</code></pre>
| 0debug
|
which one is faster data types in .net or data types in c#? : <p>Hi to all first of all i am sorry because my first language is not english
I want understand which one is faster C# data types or .net data types
i try to understand by below code and i think .net data types is faster(is this correct?)
i test this code both with x86 and x64 platform</p>
<pre><code> SW.Start();
for (Int32 i = 0; i < 99999; i++)
{
for (Int32 j = 0; j < 999; j++)
{
Int32 a = 37;
Int32 b = 37;
Double c = Math.Pow(a, b);
String d = "abcde";
String e = "abcde";
String f = d + e;
}
}
Console.WriteLine(SW.Elapsed.TotalMilliseconds);
SW.Stop();
Console.ReadKey();
</code></pre>
<p>and my second code</p>
<pre><code>
Stopwatch SW = new Stopwatch();
SW.Start();
for (int i = 0; i < 99999; i++)
{
for (int j = 0; j < 999; j++)
{
int a = 37;
int b = 37;
double c = Math.Pow(a, b);
string d = "abcde";
string e = "abcde";
string f = d + e;
}
}
Console.WriteLine(SW.Elapsed.TotalMilliseconds);
SW.Stop();
Console.ReadKey();
</code></pre>
<p>thank a lot</p>
| 0debug
|
How to set SameSite cookie attribute to explicit None ASP NET Core : <p>Chrome 76 will begin to support an explicit <code>SameSite: None</code> attribute </p>
<p><a href="https://web.dev/samesite-cookies-explained/" rel="noreferrer">https://web.dev/samesite-cookies-explained/</a></p>
<p>I found that the current implementation of ASP.NET Core treats <code>SameSiteMode.None</code> as a no-op and does not send any attribute. How can I add a custom attribute to a cookie and thereby add an explicit <code>SameSite: None</code> to the cookie text?</p>
<p>Appending the attribute to the cookie value does not work as HttpResponse.Cookies.Append url-encodes the cookie value.</p>
| 0debug
|
void vnc_display_init(DisplayState *ds)
{
VncState *vs;
vs = qemu_mallocz(sizeof(VncState));
if (!vs)
exit(1);
ds->opaque = vs;
vnc_state = vs;
vs->display = NULL;
vs->password = NULL;
vs->lsock = -1;
vs->csock = -1;
vs->depth = 4;
vs->last_x = -1;
vs->last_y = -1;
vs->ds = ds;
if (!keyboard_layout)
keyboard_layout = "en-us";
vs->kbd_layout = init_keyboard_layout(keyboard_layout);
if (!vs->kbd_layout)
exit(1);
vs->timer = qemu_new_timer(rt_clock, vnc_update_client, vs);
vs->ds->data = NULL;
vs->ds->dpy_update = vnc_dpy_update;
vs->ds->dpy_resize = vnc_dpy_resize;
vs->ds->dpy_refresh = NULL;
memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row));
vnc_dpy_resize(vs->ds, 640, 400);
}
| 1threat
|
Spliting a string between "," : This is my original string,
required:true,validType:'timegt['#timeofdaymeterslotonebegintime,#timeofdaymeterslotoneendtime']
I want to split into two. the output will be like
required:true
validType:'timegt['#timeofdaymeterslotonebegintime,#timeofdaymeterslotoneendtime']
Can someone help me out with this.
| 0debug
|
Guys i don't get why am i getting this output in this php code? Can you explain please? : <?php $i = 0; $func1 = function() use ($i) { echo "$i"; };$func2 = function() use (&$i) { echo "$i"; }; for ( $i=1; $i<=5; $i++ ) { $func1(); $func2(); } ?>
output: 0 1 0 2 0 3 0 4 0 5
| 0debug
|
(Java) How can I get input from command prompt? : <p>I have been able to open the command prompt, but how would I get what the user types from it?
And how would I "print" to the command prompt? </p>
| 0debug
|
static inline int64_t add64(const int64_t a, const int64_t b)
{
return a + b;
}
| 1threat
|
What is the difference between primaryColor and primarySwatch in Flutter? : <p>In Flutter, one can apply a theme to the app using ThemeData class. But there two propeties of this class that confuses me: <code>primaryColor</code> and <code>primarySwatch</code>. What's the difference between these two properties and when to use one or the other? Thanks.</p>
| 0debug
|
static void pl181_fifo_run(pl181_state *s)
{
uint32_t bits;
uint32_t value;
int n;
int limit;
int is_read;
is_read = (s->datactrl & PL181_DATA_DIRECTION) != 0;
if (s->datacnt != 0 && (!is_read || sd_data_ready(s->card))
&& !s->linux_hack) {
limit = is_read ? PL181_FIFO_LEN : 0;
n = 0;
value = 0;
while (s->datacnt && s->fifo_len != limit) {
if (is_read) {
value |= (uint32_t)sd_read_data(s->card) << (n * 8);
n++;
if (n == 4) {
pl181_fifo_push(s, value);
value = 0;
n = 0;
}
} else {
if (n == 0) {
value = pl181_fifo_pop(s);
n = 4;
}
sd_write_data(s->card, value & 0xff);
value >>= 8;
n--;
}
s->datacnt--;
}
if (n && is_read) {
pl181_fifo_push(s, value);
}
}
s->status &= ~(PL181_STATUS_RX_FIFO | PL181_STATUS_TX_FIFO);
if (s->datacnt == 0) {
s->status |= PL181_STATUS_DATAEND;
s->status |= PL181_STATUS_DATABLOCKEND;
DPRINTF("Transfer Complete\n");
}
if (s->datacnt == 0 && s->fifo_len == 0) {
s->datactrl &= ~PL181_DATA_ENABLE;
DPRINTF("Data engine idle\n");
} else {
bits = PL181_STATUS_TXACTIVE | PL181_STATUS_RXACTIVE;
if (s->fifo_len == 0) {
bits |= PL181_STATUS_TXFIFOEMPTY;
bits |= PL181_STATUS_RXFIFOEMPTY;
} else {
bits |= PL181_STATUS_TXDATAAVLBL;
bits |= PL181_STATUS_RXDATAAVLBL;
}
if (s->fifo_len == 16) {
bits |= PL181_STATUS_TXFIFOFULL;
bits |= PL181_STATUS_RXFIFOFULL;
}
if (s->fifo_len <= 8) {
bits |= PL181_STATUS_TXFIFOHALFEMPTY;
}
if (s->fifo_len >= 8) {
bits |= PL181_STATUS_RXFIFOHALFFULL;
}
if (s->datactrl & PL181_DATA_DIRECTION) {
bits &= PL181_STATUS_RX_FIFO;
} else {
bits &= PL181_STATUS_TX_FIFO;
}
s->status |= bits;
}
}
| 1threat
|
int aio_bh_poll(AioContext *ctx)
{
QEMUBH *bh, **bhp, *next;
int ret;
bool deleted = false;
qemu_lockcnt_inc(&ctx->list_lock);
ret = 0;
for (bh = atomic_rcu_read(&ctx->first_bh); bh; bh = next) {
next = atomic_rcu_read(&bh->next);
if (atomic_xchg(&bh->scheduled, 0)) {
if (!bh->idle) {
ret = 1;
}
bh->idle = 0;
aio_bh_call(bh);
}
if (bh->deleted) {
deleted = true;
}
}
if (!deleted) {
qemu_lockcnt_dec(&ctx->list_lock);
return ret;
}
if (qemu_lockcnt_dec_and_lock(&ctx->list_lock)) {
bhp = &ctx->first_bh;
while (*bhp) {
bh = *bhp;
if (bh->deleted && !bh->scheduled) {
*bhp = bh->next;
g_free(bh);
} else {
bhp = &bh->next;
}
}
qemu_lockcnt_unlock(&ctx->list_lock);
}
return ret;
}
| 1threat
|
int av_new_packet(AVPacket *pkt, int size)
{
uint8_t *data;
if((unsigned)size > (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
return AVERROR(ENOMEM);
data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!data)
return AVERROR(ENOMEM);
memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
av_init_packet(pkt);
pkt->data = data;
pkt->size = size;
pkt->destruct = av_destruct_packet;
return 0;
}
| 1threat
|
Postgres column doesn't exist error on update : <p>I am trying to run the query below but I am getting an error <strong>ERROR: column "test.pdf" does not exist</strong> . I dont know why I am getting this error. I search for various links on stackover but none solved my problem like this <a href="https://stackoverflow.com/questions/33614625/postgresql-query-column-does-not-exist/33614701">PostgreSQL query -- column does not exist</a>, <a href="https://stackoverflow.com/questions/30764963/postgres-error-updating-column-data">Postgres error updating column data</a>. Please help me find the problem. </p>
<p>bill is a type string field in bills table.</p>
<pre><code>update bills
set bill = "test.pdf"
where id=3;
</code></pre>
| 0debug
|
convert D/M/YYYY to YYYY/MM/DD (ex : 1/6/2015 --> 2015/06/01 not 2015/6/1) : Hello i have to convert a date like D/M/YYYY to YYYY/MM/DD Ex : 1/6/2015 --> 2015/06/01 not 2015/6/1
I have some conditions to be met :
- when it convert the month like Jan "1" must give : 01
Feb "2" must give : 02 etc
- i have to use Date()
<!-- begin snippet: js hide: false -->
<!-- language: lang-js -->
var st = "D/M/YYYY"
var dt = new Date(st);
var maFonction = function (userdate){
var day = st.getDate();
var month = st.getMonth();
var year = st.getFullYear();
var maDate = year + "/" + day + "/" + month;
return maDate;
}
console.log(maFonction(st));
<!-- end snippet -->
I tried but it doesn't works :
I am a beginner so explain to me :)
Thanks a lot !
| 0debug
|
create-react-app generates function instead of class in App.js : <p>I'm trying to create react app using create-react-app command,
and it's generating the App.js file as function (es5 syntax without class)
instead of class (Example in the following code):</p>
<pre><code>import React from 'react';
import logo from './logo.svg';
import './App.css';
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
export default App;
</code></pre>
<p>How can I force create-react-app to generate class instead?</p>
| 0debug
|
'Serilog' already has a dependency defined for 'Microsoft.CSharp' : <p>I am trying to install serilog and I'm getting error</p>
<blockquote>
<p>PM> Install-Package Serilog<br>
Install-Package : 'Serilog' already has a<br>
dependency defined for 'Microsoft.CSharp'. At line:1 char:1<br>
+ Install-Package Serilog<br>
+ ~~~~~~~~~~~~~~~~~~~~~~~<br>
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException<br>
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand </p>
</blockquote>
<p><code>Microsoft.CSharp</code> is already referenced in my project</p>
| 0debug
|
can any one suggest me why datetimepiker giving error in data retrieve? : string querySql = "Select Admission_Date,Name,Father_name,Date_of_birth,NIC_No,Present_Adress,Age,Contact_No,Weight,Height,Image from Admform WHERE Member_ID=@memid";
using (SqlConnection conSql = new SqlConnection("Data Source=azeem;Initial Catalog=ittihadgym;Integrated Security=True"))
{
using (SqlCommand command = new SqlCommand(querySql, conSql))
{
conSql.Open();
command.Parameters.AddWithValue("@memid", textBoxmember.Text);
SqlDataReader reader = command.ExecuteReader();
if (reader.Read())
{
dateTimePicker1.Value=reader[0].ToString();
textBoxname.Text = reader[1].ToString();
textBoxfname.Text = reader[2].ToString();
dateTimePicker2.Value=reader[3].ToString();
textBoxnic.Text = reader[4].ToString();
textBoxadress.Text=reader[5].ToString();
textBoxage.Text=reader[6].ToString();
textBoxcntct.Text=reader[7].ToString();
textBoxweight.Text=reader[8].ToString();
textBoxheight.Text=reader[9].ToString();
byte[] img = (byte[])(reader[10]);
if (img == null)
pictureBox1.Image = null;
else
{
MemoryStream ms = new MemoryStream(img);
pictureBox1.Image = Image.FromStream(ms);
}
}
else
{
MessageBox.Show("This is does not exist.");
cn.Close();
| 0debug
|
Split the array values into 3 columns in php? : $data =( [01] => 0 [02] => 0 [03] => 1 [04] => 0 [05] => 0 [06] => 0 [07] => 0 [08] => 0 [09] => 1 [10] => 0 [11] => 0 [12] => 0 [13] => 0 [14] => 0 [15] => 0 [16] => 0 [17] => 0 [18] => 0 [19] => 0 [20] => 0 [21] => 0 [22] => 0 [23] => 0 [24] => 0 [25] => 0 [26] => 0 [27] => 0 [28] => 0 [29] => 0 [30] => 0 [31] => 0)
Expecting O/p :
0=>([01]=>0 [11]=>0 [21]=>0)
1=>([02]=>0 [12]=>0 [22]=>0)
2=>([03]=>0 [13]=>0 [23]=>0)
upto
10=>([10]=>0 [20]=>0 [30]=>0)
| 0debug
|
How to Convert an Integer to a String without Integer.toString Function : <p>This is an extension to a previous question of mine, but I'm required to do this problem without this function. I have to use recursion only. Any thoughts?</p>
<p>An example; 20A would be:</p>
<p>2 x 12^2 + 0 x 12^1 + 10 x 12^0 = 2 x 144 + 0 x 12 + 10 x 1 = 288 + 0 + 10 = 298</p>
<pre><code>public class Duodecimal {
public static String toBase12(int n) {
if (n < 10)
return Integer.toString(n);
if (n == 10)
return "A";
if (n == 11)
return "B";
return toBase12(n / 12) + toBase12(n % 12);
}
}
</code></pre>
| 0debug
|
Docker multiple environments : <p>I'm trying to wrap my head around Docker, but I'm having a hard time figuring it out. I tried to implement it in my small project (MERN stack), and I was thinking how do you distinct between development, (maybe staging), and production environments.</p>
<p>I saw one <a href="https://github.com/Hashnode/mern-starter" rel="noreferrer">example</a> where they used 2 Docker files, and 2 docker-compose files, (each pair for one env, so Dockerfile + docker-compose.yml for prod, Dockerfile-dev + docker-compose-dev.yml for dev).</p>
<p>But this just seems like a bit of an overkill for me. I would prefer to have it only in two files.</p>
<p>Also one of the problem is that e.g. for development I want to install nodemon globally, but not for poduction.</p>
<p>In perfect solution I imagine running something like that</p>
<pre><code>docker-compose -e ENV=dev build
docker-compose -e ENV=dev up
</code></pre>
<p>Keep in mind, that I still don't fully get docker, so if you caught some of mine misconceptions about docker, you can point them out.</p>
| 0debug
|
static int mxf_read_source_clip(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
MXFStructuralComponent *source_clip = arg;
switch(tag) {
case 0x0202:
source_clip->duration = avio_rb64(pb);
break;
case 0x1201:
source_clip->start_position = avio_rb64(pb);
break;
case 0x1101:
avio_skip(pb, 16);
avio_read(pb, source_clip->source_package_uid, 16);
break;
case 0x1102:
source_clip->source_track_id = avio_rb32(pb);
break;
}
return 0;
}
| 1threat
|
char *g_strdup(const char *s)
{
char *dup;
size_t i;
if (!s) {
return NULL;
}
__coverity_string_null_sink__(s);
__coverity_string_size_sink__(s);
dup = __coverity_alloc_nosize__();
__coverity_mark_as_afm_allocated__(dup, AFM_free);
for (i = 0; (dup[i] = s[i]); i++) ;
return dup;
}
| 1threat
|
static void virtio_gpu_cleanup_mapping(struct virtio_gpu_simple_resource *res)
{
virtio_gpu_cleanup_mapping_iov(res->iov, res->iov_cnt);
g_free(res->iov);
res->iov = NULL;
res->iov_cnt = 0;
}
| 1threat
|
static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
unsigned int i, entries;
int64_t duration=0;
int64_t total_sample_count=0;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
avio_r8(pb);
avio_rb24(pb);
entries = avio_rb32(pb);
av_dlog(c->fc, "track[%i].stts.entries = %i\n",
c->fc->nb_streams-1, entries);
if (entries >= UINT_MAX / sizeof(*sc->stts_data))
return -1;
sc->stts_data = av_malloc(entries * sizeof(*sc->stts_data));
if (!sc->stts_data)
return AVERROR(ENOMEM);
sc->stts_count = entries;
for (i=0; i<entries; i++) {
int sample_duration;
int sample_count;
sample_count=avio_rb32(pb);
sample_duration = avio_rb32(pb);
sc->stts_data[i].count= sample_count;
sc->stts_data[i].duration= sample_duration;
av_dlog(c->fc, "sample_count=%d, sample_duration=%d\n",
sample_count, sample_duration);
duration+=(int64_t)sample_duration*sample_count;
total_sample_count+=sample_count;
}
st->nb_frames= total_sample_count;
if (duration)
st->duration= duration;
return 0;
}
| 1threat
|
static void sigp_initial_cpu_reset(void *arg)
{
CPUState *cpu = arg;
S390CPUClass *scc = S390_CPU_GET_CLASS(cpu);
cpu_synchronize_state(cpu);
scc->initial_cpu_reset(cpu);
cpu_synchronize_post_reset(cpu);
}
| 1threat
|
My php file deleted automatically from c panel : <p>Hey friends in my hosting my base_facebook.php file is deleted continuously I talked with customer care he says that hosting antivirus detected your file as a virus but same file I tried to other hosting and it is fine what I do?
What is the problem in my file and how to fix <a href="http://jioliker.com" rel="nofollow noreferrer">this</a></p>
<p><a href="https://drive.google.com/file/d/0B9Ibh3LNs0DSVWhhbkVFa2RPMDQ/view?usp=drivesdk" rel="nofollow noreferrer"> Here is my file</a></p>
| 0debug
|
How to make a WordPress grid with text overlay : <p>I'm trying to make a 2 column grid in WordPress where each row has a grid item filled with an image, and a grid item filled with text/a clickable button and a background image. </p>
<p>I'm also using Visual Composer. I'm creating a full width row, and then splitting it into two 50% columns. Then I make one an HTML block, and add the image simply enough. But the other is more difficult...</p>
<p>If I make it an HTML block and write out the text and set a background image, then the background image is only going to cover the text area. I need the grid items to be the same size, I will attach a mock-up I'm trying to recreate. I can't post a link because it's for a client and that is against our contract.</p>
<p>Thank you!!</p>
<p><a href="http://i.stack.imgur.com/d3WtF.png" rel="nofollow">Mock-up</a></p>
| 0debug
|
Dynamically created Button added to Dictionary made exception when i try use it. WPF : <p>I create Button in my c# kod and add this button to dictionary. I have method to run buttons. When i run this method in Task it make exception:</p>
<blockquote>
<p>The calling thread cannot access this object because it belongs to a different thread.</p>
</blockquote>
<pre><code>private void RefreshTags()
{
var r = new Random();
lock (dictTagModel)
{
foreach (var item in dictTagModel)
{
Canvas.SetLeft(item.Value, r.Next(1, 1400));
}
}
}
private void btn1_Click(object sender, RoutedEventArgs e)
{
var r = new Random();
listTagModel.Add(new TagModel { TagMac = r.Next(1, 10) });
lock (dictTagModel)
{
foreach (var tag in listTagModel)
{
if (!dictTagModel.ContainsKey(tag.TagMac))
{
var button1 = new Button
{
//Name = item.Angle.ToString(),
Background = Brushes.Black,
Height = 8,
Width = 8,
Content = 0.ToString(),
FontSize = 10,
};
Canvas.SetLeft(button1, 100);
Canvas.SetTop(button1, tagHight);
canvas.Children.Add(button1);
dictTagModel.Add(tag.TagMac, button1);
tagHight -= 10;
}
}
}
if(tagHight == 325)
{
Task.Run(() =>
{
while (true)
{
Thread.Sleep(1000);
RefreshTags();
}
});
}
}
</code></pre>
<p>When it isnt in Task and i only run 1 time this method it work.</p>
| 0debug
|
static void frame_end(MpegEncContext *s)
{
int i;
if (s->unrestricted_mv &&
s->current_picture.reference &&
!s->intra_only) {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
int hshift = desc->log2_chroma_w;
int vshift = desc->log2_chroma_h;
s->mpvencdsp.draw_edges(s->current_picture.f->data[0], s->linesize,
s->h_edge_pos, s->v_edge_pos,
EDGE_WIDTH, EDGE_WIDTH,
EDGE_TOP | EDGE_BOTTOM);
s->mpvencdsp.draw_edges(s->current_picture.f->data[1], s->uvlinesize,
s->h_edge_pos >> hshift,
s->v_edge_pos >> vshift,
EDGE_WIDTH >> hshift,
EDGE_WIDTH >> vshift,
EDGE_TOP | EDGE_BOTTOM);
s->mpvencdsp.draw_edges(s->current_picture.f->data[2], s->uvlinesize,
s->h_edge_pos >> hshift,
s->v_edge_pos >> vshift,
EDGE_WIDTH >> hshift,
EDGE_WIDTH >> vshift,
EDGE_TOP | EDGE_BOTTOM);
}
emms_c();
s->last_pict_type = s->pict_type;
s->last_lambda_for [s->pict_type] = s->current_picture_ptr->f->quality;
if (s->pict_type!= AV_PICTURE_TYPE_B)
s->last_non_b_pict_type = s->pict_type;
if (s->encoding) {
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
if (!s->picture[i].reference)
ff_mpeg_unref_picture(s->avctx, &s->picture[i]);
}
}
s->avctx->coded_frame = s->current_picture_ptr->f;
}
| 1threat
|
format text in javascript : how to Write a parser/method in javascript which would parse below
digraph "com.a:test:jar:1.0" {
"com.a:test:jar:1.0" ->
"org.apache.httpcomponents:httpclient:jar:4.5.5:compile";
"com.a:test:jar:1.0" -> "com.google.code.gson:gson:jar:2.8.2:compile";
"com.a:test:jar:1.0" -> "info.picocli:picocli:jar:2.3.0:compile";
"com.a:test:jar:1.0" -> "log4j:log4j:jar:1.2.17:compile";
"com.a:test:jar:1.0" -> "org.xerial:sqlite-jdbc:jar:3.21.0:compile";
"org.apache.httpcomponents:httpclient:jar:4.5.5:compile" ->
"org.apache.httpcomponents:httpcore:jar:4.4.9:compile" ;
"org.apache.httpcomponents:httpclient:jar:4.5.5:compile" -> "commons-logging:commons-logging:jar:1.2:compile" ;
"org.apache.httpcomponents:httpclient:jar:4.5.5:compile" -> "commons-codec:commons-codec:jar:1.10:compile" ;
}
into
digraph "com.a:test:jar:1.0" {
"com.a:test:jar:1.0" ->
"org.apache.httpcomponents:httpclient:jar:4.5.5:compile";
"com.a:test:jar:1.0" -> "com.google.code.gson:gson:jar:2.8.2:compile";
"com.a:test:jar:1.0" -> "info.picocli:picocli:jar:2.3.0:compile";
"com.a:test:jar:1.0" -> "log4j:log4j:jar:1.2.17:compile";
"com.a:test:jar:1.0" -> "org.xerial:sqlite-jdbc:jar:3.21.0:compile";
}
i.e anything appearing next to diagraph "com.a:test:jar:1.0" if it appears before (LHS) `->` have it else omit it.
Note: there can be multiple blocks of digraph.
| 0debug
|
static void xen_set_memory(struct MemoryListener *listener,
MemoryRegionSection *section,
bool add)
{
XenIOState *state = container_of(listener, XenIOState, memory_listener);
hwaddr start_addr = section->offset_within_address_space;
ram_addr_t size = int128_get64(section->size);
bool log_dirty = memory_region_is_logging(section->mr);
hvmmem_type_t mem_type;
if (section->mr == &ram_memory) {
return;
} else {
if (add) {
xen_map_memory_section(xen_xc, xen_domid, state->ioservid,
section);
} else {
xen_unmap_memory_section(xen_xc, xen_domid, state->ioservid,
section);
}
}
if (!memory_region_is_ram(section->mr)) {
return;
}
if (log_dirty != add) {
return;
}
trace_xen_client_set_memory(start_addr, size, log_dirty);
start_addr &= TARGET_PAGE_MASK;
size = TARGET_PAGE_ALIGN(size);
if (add) {
if (!memory_region_is_rom(section->mr)) {
xen_add_to_physmap(state, start_addr, size,
section->mr, section->offset_within_region);
} else {
mem_type = HVMMEM_ram_ro;
if (xc_hvm_set_mem_type(xen_xc, xen_domid, mem_type,
start_addr >> TARGET_PAGE_BITS,
size >> TARGET_PAGE_BITS)) {
DPRINTF("xc_hvm_set_mem_type error, addr: "TARGET_FMT_plx"\n",
start_addr);
}
}
} else {
if (xen_remove_from_physmap(state, start_addr, size) < 0) {
DPRINTF("physmapping does not exist at "TARGET_FMT_plx"\n", start_addr);
}
}
}
| 1threat
|
build_rsdp(GArray *rsdp_table, BIOSLinker *linker, unsigned rsdt_tbl_offset)
{
AcpiRsdpDescriptor *rsdp = acpi_data_push(rsdp_table, sizeof *rsdp);
unsigned rsdt_pa_size = sizeof(rsdp->rsdt_physical_address);
unsigned rsdt_pa_offset =
(char *)&rsdp->rsdt_physical_address - rsdp_table->data;
bios_linker_loader_alloc(linker, ACPI_BUILD_RSDP_FILE, rsdp_table, 16,
true );
memcpy(&rsdp->signature, "RSD PTR ", sizeof(rsdp->signature));
memcpy(rsdp->oem_id, ACPI_BUILD_APPNAME6, sizeof(rsdp->oem_id));
rsdp->length = cpu_to_le32(sizeof(*rsdp));
rsdp->revision = 0x02;
bios_linker_loader_add_pointer(linker,
ACPI_BUILD_RSDP_FILE, rsdt_pa_offset, rsdt_pa_size,
ACPI_BUILD_TABLE_FILE, rsdt_tbl_offset);
rsdp->checksum = 0;
bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE,
rsdp, sizeof *rsdp,
&rsdp->checksum);
return rsdp_table;
}
| 1threat
|
static inline int svq3_decode_block(GetBitContext *gb, DCTELEM *block,
int index, const int type)
{
static const uint8_t *const scan_patterns[4] =
{ luma_dc_zigzag_scan, zigzag_scan, svq3_scan, chroma_dc_scan };
int run, level, sign, vlc, limit;
const int intra = 3 * type >> 2;
const uint8_t *const scan = scan_patterns[type];
for (limit = (16 >> intra); index < 16; index = limit, limit += 8) {
for (; (vlc = svq3_get_ue_golomb(gb)) != 0; index++) {
if (vlc == INVALID_VLC)
return -1;
sign = (vlc & 0x1) - 1;
vlc = vlc + 1 >> 1;
if (type == 3) {
if (vlc < 3) {
run = 0;
level = vlc;
} else if (vlc < 4) {
run = 1;
level = 1;
} else {
run = vlc & 0x3;
level = (vlc + 9 >> 2) - run;
}
} else {
if (vlc < 16) {
run = svq3_dct_tables[intra][vlc].run;
level = svq3_dct_tables[intra][vlc].level;
} else if (intra) {
run = vlc & 0x7;
level = (vlc >> 3) +
((run == 0) ? 8 : ((run < 2) ? 2 : ((run < 5) ? 0 : -1)));
} else {
run = vlc & 0xF;
level = (vlc >> 4) +
((run == 0) ? 4 : ((run < 3) ? 2 : ((run < 10) ? 1 : 0)));
}
}
if ((index += run) >= limit)
return -1;
block[scan[index]] = (level ^ sign) - sign;
}
if (type != 2) {
break;
}
}
return 0;
}
| 1threat
|
How to give the object back upon failure? : I have the following code in Rust:
```rust
pub struct PropertySet
{
color: Color,
properties: Vec<Box<dyn Property>>,
}
impl PropertySet
{
// ...
/// This function will panic if a card is added and the set is already full, so
/// you should always check the set size first.
fn add<T: Property>(&mut self, card: T)
{
if self.properties.len() + 1 < self.color.set_size() {
self.properties.push(Box::new(property))
} else {
panic!("The card could not be added to the set; it is full.")
}
}
// ...
}
```
This `impl` is for a struct which is intended to hold a list of cards, but has a maximum number of cards that can be added to it. Panicking seems like an unnecessarily drastic response to the error of trying to add a card to a full set, so I would like to return an `Err` instead, but that presents a problem because this method moves `card`. `card` has to be passed by value because this is the only way I can add it to the `Vec`.
Is there a way to simply give `card` back to the caller if the method fails, instead of panicking?
| 0debug
|
.Net Core and NuGet : <p>I <a href="https://dotnet.github.io/getting-started/">installed .net core from this site</a>. Playing with it led to a number of related package management questions:</p>
<ol>
<li>The <code>dotnet restore</code> command proceeded to "install" .net core NuGet packages. Where were those packages "installed"? A new folder was not created.</li>
<li>The <code>dotnet restore</code> for the "hello world" minimal example required about a hundred NuGet packages, where 99% were presumably irrelevant to the "hello world" app. Granted, a .net native build will remove all that is not needed - but I expected that the <code>restore</code> also would have grabbed very little (three or four packages, not a hundred). Why this behavior?</li>
<li>I created a second "hello world" project and again ran <code>dotnet restore</code>. This time no packages were installed at all. It seems all the packages installed the first time-around went into some global location to be shared. I thought .Net Core didn't work that way. I thought .Net Core projects kept all their dependencies locally. The only framework I targeted was <code>dnxcore50</code>. Why this behavior? </li>
<li>I would like to "uninstall" all these global packages, and try again (just for learning purposes). How might that be accomplished? Remember, as stated in question #1, I don't know where all those files were installed.</li>
<li>Almost all of the packages installed via the <code>restore</code> command were listed as beta. Odd. I thought .Net Core was in RC1, not beta. Confused by this. Why this behavior?</li>
</ol>
<p>I'm also curious of what documentation could/would have explained all this to me. I tried googling for each of these questions, and found nothing (perhaps just horrible google-fu?).</p>
| 0debug
|
static int local_utimensat(FsContext *s, V9fsPath *fs_path,
const struct timespec *buf)
{
char buffer[PATH_MAX];
char *path = fs_path->data;
return qemu_utimens(rpath(s, path, buffer), buf);
}
| 1threat
|
Why does my JS function not return any results in Chrome Dev Console? : <p>My function compPlay() does not return any results in console. I have the function written to what I believe is correct as far as syntax goes and proper use of "Math random" and "Math" floor. Please help me.</p>
<pre><code> <!doctype html>
<html lang="en-us">
<head>
<meta charset="UTF-8">
<title>Rock Paper Scissor Game</title>
<!-- CSS, STYLESHEET -->
<link rel="stylesheet" type="text/css" href="assets/css/style2.css">
<!-- BOOTSTRAP -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<!-- JQUERY, 3.2.1 -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js">
function compPlay {
const choices = ["rock", "paper", "scissors"]
return choices([Math.floor(Math.random() * choice.length)];
}
</code></pre>
<p><a href="https://i.stack.imgur.com/ymmrQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ymmrQ.jpg" alt="enter image description here"></a></p>
| 0debug
|
static int sd_schedule_bh(QEMUBHFunc *cb, SheepdogAIOCB *acb)
{
if (acb->bh) {
error_report("bug: %d %d\n", acb->aiocb_type, acb->aiocb_type);
return -EIO;
}
acb->bh = qemu_bh_new(cb, acb);
if (!acb->bh) {
error_report("oom: %d %d\n", acb->aiocb_type, acb->aiocb_type);
return -EIO;
}
qemu_bh_schedule(acb->bh);
return 0;
}
| 1threat
|
How to retry the request n times when an item gets an empty field? : <p>I'm trying to scrap a range of webpages but I got holes, sometimes it looks like the website fails to send the html response correctly. This results in the csv output file to have empty lines. How would one do to retry n times the request and the parse when the xpath selector on the response is empty ? Note that I don't have any HTTP errors.</p>
| 0debug
|
static int get_physical_address(CPUState *env, target_phys_addr_t *physical,
int *prot, int *access_index,
target_ulong address, int rw, int mmu_idx)
{
int access_perms = 0;
target_phys_addr_t pde_ptr;
uint32_t pde;
int error_code = 0, is_dirty, is_user;
unsigned long page_offset;
is_user = mmu_idx == MMU_USER_IDX;
if ((env->mmuregs[0] & MMU_E) == 0) {
if (rw == 2 && (env->mmuregs[0] & env->def->mmu_bm)) {
*physical = env->prom_addr | (address & 0x7ffffULL);
*prot = PAGE_READ | PAGE_EXEC;
return 0;
}
*physical = address;
*prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
return 0;
}
*access_index = ((rw & 1) << 2) | (rw & 2) | (is_user? 0 : 1);
*physical = 0xffffffffffff0000ULL;
pde_ptr = (env->mmuregs[1] << 4) + (env->mmuregs[2] << 2);
pde = ldl_phys(pde_ptr);
switch (pde & PTE_ENTRYTYPE_MASK) {
default:
case 0:
return 1 << 2;
case 2:
case 3:
return 4 << 2;
case 1:
pde_ptr = ((address >> 22) & ~3) + ((pde & ~3) << 4);
pde = ldl_phys(pde_ptr);
switch (pde & PTE_ENTRYTYPE_MASK) {
default:
case 0:
return (1 << 8) | (1 << 2);
case 3:
return (1 << 8) | (4 << 2);
case 1:
pde_ptr = ((address & 0xfc0000) >> 16) + ((pde & ~3) << 4);
pde = ldl_phys(pde_ptr);
switch (pde & PTE_ENTRYTYPE_MASK) {
default:
case 0:
return (2 << 8) | (1 << 2);
case 3:
return (2 << 8) | (4 << 2);
case 1:
pde_ptr = ((address & 0x3f000) >> 10) + ((pde & ~3) << 4);
pde = ldl_phys(pde_ptr);
switch (pde & PTE_ENTRYTYPE_MASK) {
default:
case 0:
return (3 << 8) | (1 << 2);
case 1:
case 3:
return (3 << 8) | (4 << 2);
case 2:
page_offset = (address & TARGET_PAGE_MASK) &
(TARGET_PAGE_SIZE - 1);
}
break;
case 2:
page_offset = address & 0x3ffff;
}
break;
case 2:
page_offset = address & 0xffffff;
}
}
is_dirty = (rw & 1) && !(pde & PG_MODIFIED_MASK);
if (!(pde & PG_ACCESSED_MASK) || is_dirty) {
pde |= PG_ACCESSED_MASK;
if (is_dirty)
pde |= PG_MODIFIED_MASK;
stl_phys_notdirty(pde_ptr, pde);
}
access_perms = (pde & PTE_ACCESS_MASK) >> PTE_ACCESS_SHIFT;
error_code = access_table[*access_index][access_perms];
if (error_code && !((env->mmuregs[0] & MMU_NF) && is_user))
return error_code;
*prot = perm_table[is_user][access_perms];
if (!(pde & PG_MODIFIED_MASK)) {
*prot &= ~PAGE_WRITE;
}
*physical = ((target_phys_addr_t)(pde & PTE_ADDR_MASK) << 4) + page_offset;
return error_code;
}
| 1threat
|
AccessDeniedException: User is not authorized to perform: lambda:InvokeFunction : <p>I'm trying to invoke a lambda function from node.</p>
<pre><code>var aws = require('aws-sdk');
var lambda = new aws.Lambda({
accessKeyId: 'id',
secretAccessKey: 'key',
region: 'us-west-2'
});
lambda.invoke({
FunctionName: 'test1',
Payload: JSON.stringify({
key1: 'Arjun',
key2: 'kom',
key3: 'ath'
})
}, function(err, data) {
if (err) console.log(err, err.stack);
else console.log(data);
});
</code></pre>
<p>The keys are for an IAM user. The user has <code>AWSLambdaExecute</code> and <code>AWSLambdaBasicExecutionRole</code> policies attached.</p>
<p>I get a permission error:
<code>AccessDeniedException: User: arn:aws:iam::1221321312:user/cli is not authorized to perform: lambda:InvokeFunction on resource: arn:aws:lambda:us-west-2:1221321312:function:test1</code></p>
<p>I read the docs and several blogs, but I'm unable to authorise this user to invoke the lambda function. How do get this user to invoke lambda?</p>
<p>Thanks.</p>
| 0debug
|
Setting up tsconfig with spec/test folder : <p>Say I put my code under <code>src</code> and tests under <code>spec</code>:</p>
<pre><code>+ spec
+ --- classA.spec.ts
+ src
+ --- classA.ts
+ --- classB.ts
+ --- index.ts
+ tsconfig.json
</code></pre>
<p>I want to only transpile <code>src</code> to the <code>dist</code> folder. Since <code>index.ts</code> is the entry point of my package, my <code>tsconfig.json</code> look like this:</p>
<pre><code>{
"compileOptions": {
"module": "commonjs"
"outDir": "dist"
},
"files": {
"src/index.ts",
"typings/main.d.ts"
}
}
</code></pre>
<p>However, this <code>tsconfig.json</code> does not include the test files so I could not resolve dependencies in them.</p>
<p>On the other hand, if I include the test files into <code>tsconfig.json</code> then they are also transpiled to <code>dist</code> folder.</p>
<p>How do I solve this problem?</p>
| 0debug
|
window.location.href = 'http://attack.com?user=' + user_input;
| 1threat
|
Flutter Navigator.replace() example : <p>I need to replace my current screen and found <code>replace</code> method in Navigator's API. But I didn't find any example for it. Maybe somebody knows hot to use it.
Thanks.</p>
| 0debug
|
static int ppc_hash64_pte_prot(CPUPPCState *env,
ppc_slb_t *slb, ppc_hash_pte64_t pte)
{
unsigned pp, key;
int prot = 0;
key = !!(msr_pr ? (slb->vsid & SLB_VSID_KP)
: (slb->vsid & SLB_VSID_KS));
pp = (pte.pte1 & HPTE64_R_PP) | ((pte.pte1 & HPTE64_R_PP0) >> 61);
if (key == 0) {
switch (pp) {
case 0x0:
case 0x1:
case 0x2:
prot = PAGE_READ | PAGE_WRITE;
break;
case 0x3:
case 0x6:
prot = PAGE_READ;
break;
}
} else {
switch (pp) {
case 0x0:
case 0x6:
prot = 0;
break;
case 0x1:
case 0x3:
prot = PAGE_READ;
break;
case 0x2:
prot = PAGE_READ | PAGE_WRITE;
break;
}
}
if (!(pte.pte1 & HPTE64_R_N) || (pte.pte1 & HPTE64_R_G)) {
prot |= PAGE_EXEC;
}
return prot;
}
| 1threat
|
How to navigate to a different directory in Jupyter Notebook? : <p>I have recently installed Anaconda 5 and with it Jupyter Notebook. I am excited with its rich functionality but I can not find a way to navigate to directories which are not children. More specifically I have tried to double-click the folder icon but that resulted in the same View.</p>
<p><a href="https://i.stack.imgur.com/bgVKk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bgVKk.png" alt="enter image description here"></a></p>
<p>Your advice will be appreciated.</p>
| 0debug
|
How to scrape email and phone numbers from a list of websites using Python? : I have a file with name and links of the websites, how do I write a program in Python that helps me scrape phone number and email from all the websites?'
[enter image description here][1]
[1]: https://i.stack.imgur.com/QyIEq.png
| 0debug
|
Hi Guys I am working on android and I want to Embed Google Maps to my App : But to do that I need Google Maps v2 API key and to get that from the Google console I have to enter SHA1 of my app.
What the problem is I can't get the SHA1 of the app because I am developing it using AIDE.
I saw a solution on Google plus blog-it suggest to use zipSigner app to get it but I can't understand it as it isn't proofed.
So how can I get the SHA1 on AIDE?
Tanx for your help.....
| 0debug
|
static int qemu_rdma_post_recv_control(RDMAContext *rdma, int idx)
{
struct ibv_recv_wr *bad_wr;
struct ibv_sge sge = {
.addr = (uint64_t)(rdma->wr_data[idx].control),
.length = RDMA_CONTROL_MAX_BUFFER,
.lkey = rdma->wr_data[idx].control_mr->lkey,
};
struct ibv_recv_wr recv_wr = {
.wr_id = RDMA_WRID_RECV_CONTROL + idx,
.sg_list = &sge,
.num_sge = 1,
};
if (ibv_post_recv(rdma->qp, &recv_wr, &bad_wr)) {
return -1;
}
return 0;
}
| 1threat
|
static int sdp_read_header(AVFormatContext *s)
{
RTSPState *rt = s->priv_data;
RTSPStream *rtsp_st;
int size, i, err;
char *content;
char url[1024];
if (!ff_network_init())
return AVERROR(EIO);
if (s->max_delay < 0)
s->max_delay = DEFAULT_REORDERING_DELAY;
if (rt->rtsp_flags & RTSP_FLAG_CUSTOM_IO)
rt->lower_transport = RTSP_LOWER_TRANSPORT_CUSTOM;
content = av_malloc(SDP_MAX_SIZE);
size = avio_read(s->pb, content, SDP_MAX_SIZE - 1);
if (size <= 0) {
av_free(content);
return AVERROR_INVALIDDATA;
}
content[size] ='\0';
err = ff_sdp_parse(s, content);
av_freep(&content);
if (err) goto fail;
for (i = 0; i < rt->nb_rtsp_streams; i++) {
char namebuf[50];
rtsp_st = rt->rtsp_streams[i];
if (!(rt->rtsp_flags & RTSP_FLAG_CUSTOM_IO)) {
AVDictionary *opts = map_to_opts(rt);
getnameinfo((struct sockaddr*) &rtsp_st->sdp_ip, sizeof(rtsp_st->sdp_ip),
namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST);
ff_url_join(url, sizeof(url), "rtp", NULL,
namebuf, rtsp_st->sdp_port,
"?localport=%d&ttl=%d&connect=%d&write_to_source=%d",
rtsp_st->sdp_port, rtsp_st->sdp_ttl,
rt->rtsp_flags & RTSP_FLAG_FILTER_SRC ? 1 : 0,
rt->rtsp_flags & RTSP_FLAG_RTCP_TO_SOURCE ? 1 : 0);
append_source_addrs(url, sizeof(url), "sources",
rtsp_st->nb_include_source_addrs,
rtsp_st->include_source_addrs);
append_source_addrs(url, sizeof(url), "block",
rtsp_st->nb_exclude_source_addrs,
rtsp_st->exclude_source_addrs);
err = ffurl_open(&rtsp_st->rtp_handle, url, AVIO_FLAG_READ_WRITE,
&s->interrupt_callback, &opts);
av_dict_free(&opts);
if (err < 0) {
err = AVERROR_INVALIDDATA;
goto fail;
}
}
if ((err = ff_rtsp_open_transport_ctx(s, rtsp_st)))
goto fail;
}
return 0;
fail:
ff_rtsp_close_streams(s);
ff_network_close();
return err;
}
| 1threat
|
Android Studio 3.0 - Settings are not saved : <p>I've increased the "Right margin (columns)" in File->Settings->Editor->Code Style from default 100 to 140. Unfortunately the margin is reset after each time I restart Android Studio. I also tried to export and import my settings but this does not prevent the right margin to be reset.</p>
<p>Hopefully someone can tell me how to save the margin.</p>
| 0debug
|
ValueError: Length of values does not match length of index | Pandas DataFrame.unique() : <p>I am trying to get a new dataset, or change the value of the current dataset columns to their unique values.
Here is an example of what I am trying to get : </p>
<pre><code> A B
-----
0| 1 1
1| 2 5
2| 1 5
3| 7 9
4| 7 9
5| 8 9
Wanted Result Not Wanted Result
A B A B
----- -----
0| 1 1 0| 1 1
1| 2 5 1| 2 5
2| 7 9 2|
3| 8 3| 7 9
4|
5| 8
</code></pre>
<p>I don't really care about the index but it seems to be the problem.
My code so far is pretty simple, I tried 2 approaches, 1 with a new dataFrame and one without. </p>
<pre><code>#With New DataFrame
def UniqueResults(dataframe):
df = pd.DataFrame()
for col in dataframe:
S=pd.Series(dataframe[col].unique())
df[col]=S.values
return df
#Without new DataFrame
def UniqueResults(dataframe):
for col in dataframe:
dataframe[col]=dataframe[col].unique()
return dataframe
</code></pre>
<p>I have the error "Length of Values does not match length of index" both times.</p>
| 0debug
|
static int doTest(uint8_t *ref[3], int refStride[3], int w, int h, int srcFormat, int dstFormat,
int srcW, int srcH, int dstW, int dstH, int flags){
uint8_t *src[3];
uint8_t *dst[3];
uint8_t *out[3];
int srcStride[3], dstStride[3];
int i;
uint64_t ssdY, ssdU, ssdV;
struct SwsContext *srcContext, *dstContext, *outContext;
int res;
res = 0;
for (i=0; i<3; i++){
if (srcFormat==PIX_FMT_RGB24 || srcFormat==PIX_FMT_BGR24)
srcStride[i]= srcW*3;
else
srcStride[i]= srcW*4;
if (dstFormat==PIX_FMT_RGB24 || dstFormat==PIX_FMT_BGR24)
dstStride[i]= dstW*3;
else
dstStride[i]= dstW*4;
src[i]= (uint8_t*) malloc(srcStride[i]*srcH);
dst[i]= (uint8_t*) malloc(dstStride[i]*dstH);
out[i]= (uint8_t*) malloc(refStride[i]*h);
if (!src[i] || !dst[i] || !out[i]) {
perror("Malloc");
res = -1;
goto end;
}
}
dstContext = outContext = NULL;
srcContext= sws_getContext(w, h, PIX_FMT_YUV420P, srcW, srcH, srcFormat, flags, NULL, NULL, NULL);
if (!srcContext) {
fprintf(stderr, "Failed to get %s ---> %s\n",
sws_format_name(PIX_FMT_YUV420P),
sws_format_name(srcFormat));
res = -1;
goto end;
}
dstContext= sws_getContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat, flags, NULL, NULL, NULL);
if (!dstContext) {
fprintf(stderr, "Failed to get %s ---> %s\n",
sws_format_name(srcFormat),
sws_format_name(dstFormat));
res = -1;
goto end;
}
outContext= sws_getContext(dstW, dstH, dstFormat, w, h, PIX_FMT_YUV420P, flags, NULL, NULL, NULL);
if (!outContext) {
fprintf(stderr, "Failed to get %s ---> %s\n",
sws_format_name(dstFormat),
sws_format_name(PIX_FMT_YUV420P));
res = -1;
goto end;
}
sws_scale(srcContext, ref, refStride, 0, h , src, srcStride);
sws_scale(dstContext, src, srcStride, 0, srcH, dst, dstStride);
sws_scale(outContext, dst, dstStride, 0, dstH, out, refStride);
ssdY= getSSD(ref[0], out[0], refStride[0], refStride[0], w, h);
ssdU= getSSD(ref[1], out[1], refStride[1], refStride[1], (w+1)>>1, (h+1)>>1);
ssdV= getSSD(ref[2], out[2], refStride[2], refStride[2], (w+1)>>1, (h+1)>>1);
if (srcFormat == PIX_FMT_GRAY8 || dstFormat==PIX_FMT_GRAY8) ssdU=ssdV=0;
ssdY/= w*h;
ssdU/= w*h/4;
ssdV/= w*h/4;
printf(" %s %dx%d -> %s %4dx%4d flags=%2d SSD=%5lld,%5lld,%5lld\n",
sws_format_name(srcFormat), srcW, srcH,
sws_format_name(dstFormat), dstW, dstH,
flags, ssdY, ssdU, ssdV);
fflush(stdout);
end:
sws_freeContext(srcContext);
sws_freeContext(dstContext);
sws_freeContext(outContext);
for (i=0; i<3; i++){
free(src[i]);
free(dst[i]);
free(out[i]);
}
return res;
}
| 1threat
|
Error #2032: Stream Error. URL: http://www.fashionboxpk.com/Test2.php"] : openHandler: [Event type="open" bubbles=false cancelable=false eventPhase=2]
progressHandler loaded:384 total: 384
Error opening URL 'http://www.fashionboxpk.com/Test2.php'
httpStatusHandler: [HTTPStatusEvent type="httpStatus" bubbles=false cancelable=false eventPhase=2 status=406 responseURL=null]
ioErrorHandler: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://www.fashionboxpk.com/Test2.php"]
| 0debug
|
MS-Dos how do I convert one line at a time in a .txt from one varable to an other : I have a document with some random letters in it for example
line 1: k
line 2: l
line 3: m
line 4: n
and I want to read one line and change the letter which I have a script to do that already using below.
> if "%name%"=="k" (goto k)
then I have this to set the new variable.
> :k
> SET name=a
> goto echo
then I have it to output into the other document using
> :echo
> ECHO %name%>>newvarables.txt
> goto getinput
is there a way I can convert the lines of the first document into other variables based on the system I have already?
thanks in advance.
| 0debug
|
SchroVideoFormatEnum ff_get_schro_video_format_preset(AVCodecContext *avctx)
{
unsigned int num_formats = sizeof(ff_schro_video_formats) /
sizeof(ff_schro_video_formats[0]);
unsigned int idx = get_video_format_idx(avctx);
return (idx < num_formats) ? ff_schro_video_formats[idx] :
SCHRO_VIDEO_FORMAT_CUSTOM;
}
| 1threat
|
How to logging file system input output operations? : How to logging file system input-output operations?
The reason is to find hot and cold file system blocks. Could you suggest me what API or OS subsystems to use from C#?
| 0debug
|
int attribute_align_arg sws_scale(struct SwsContext *c,
const uint8_t * const srcSlice[],
const int srcStride[], int srcSliceY,
int srcSliceH, uint8_t *const dst[],
const int dstStride[])
{
int i, ret;
const uint8_t *src2[4];
uint8_t *dst2[4];
uint8_t *rgb0_tmp = NULL;
if (!srcStride || !dstStride || !dst || !srcSlice) {
av_log(c, AV_LOG_ERROR, "One of the input parameters to sws_scale() is NULL, please check the calling code\n");
return 0;
if (c->gamma_flag && c->cascaded_context[0]) {
ret = sws_scale(c->cascaded_context[0],
srcSlice, srcStride, srcSliceY, srcSliceH,
c->cascaded_tmp, c->cascaded_tmpStride);
if (ret < 0)
return ret;
if (c->cascaded_context[2])
ret = sws_scale(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp, c->cascaded_tmpStride, srcSliceY, srcSliceH, c->cascaded1_tmp, c->cascaded1_tmpStride);
else
ret = sws_scale(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp, c->cascaded_tmpStride, srcSliceY, srcSliceH, dst, dstStride);
if (ret < 0)
return ret;
if (c->cascaded_context[2]) {
ret = sws_scale(c->cascaded_context[2],
(const uint8_t * const *)c->cascaded1_tmp, c->cascaded1_tmpStride, c->cascaded_context[1]->dstY - ret, c->cascaded_context[1]->dstY,
dst, dstStride);
return ret;
if (c->cascaded_context[0] && srcSliceY == 0 && srcSliceH == c->cascaded_context[0]->srcH) {
ret = sws_scale(c->cascaded_context[0],
srcSlice, srcStride, srcSliceY, srcSliceH,
c->cascaded_tmp, c->cascaded_tmpStride);
if (ret < 0)
return ret;
ret = sws_scale(c->cascaded_context[1],
(const uint8_t * const * )c->cascaded_tmp, c->cascaded_tmpStride, 0, c->cascaded_context[0]->dstH,
dst, dstStride);
return ret;
memcpy(src2, srcSlice, sizeof(src2));
memcpy(dst2, dst, sizeof(dst2));
if (srcSliceH == 0)
return 0;
if (!check_image_pointers(srcSlice, c->srcFormat, srcStride)) {
av_log(c, AV_LOG_ERROR, "bad src image pointers\n");
return 0;
if (!check_image_pointers((const uint8_t* const*)dst, c->dstFormat, dstStride)) {
av_log(c, AV_LOG_ERROR, "bad dst image pointers\n");
return 0;
if (c->sliceDir == 0 && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) {
av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n");
return 0;
if (c->sliceDir == 0) {
if (srcSliceY == 0) c->sliceDir = 1; else c->sliceDir = -1;
if (usePal(c->srcFormat)) {
for (i = 0; i < 256; i++) {
int r, g, b, y, u, v, a = 0xff;
if (c->srcFormat == AV_PIX_FMT_PAL8) {
uint32_t p = ((const uint32_t *)(srcSlice[1]))[i];
a = (p >> 24) & 0xFF;
r = (p >> 16) & 0xFF;
g = (p >> 8) & 0xFF;
b = p & 0xFF;
} else if (c->srcFormat == AV_PIX_FMT_RGB8) {
r = ( i >> 5 ) * 36;
g = ((i >> 2) & 7) * 36;
b = ( i & 3) * 85;
} else if (c->srcFormat == AV_PIX_FMT_BGR8) {
b = ( i >> 6 ) * 85;
g = ((i >> 3) & 7) * 36;
r = ( i & 7) * 36;
} else if (c->srcFormat == AV_PIX_FMT_RGB4_BYTE) {
r = ( i >> 3 ) * 255;
g = ((i >> 1) & 3) * 85;
b = ( i & 1) * 255;
} else if (c->srcFormat == AV_PIX_FMT_GRAY8 || c->srcFormat == AV_PIX_FMT_GRAY8A) {
r = g = b = i;
} else {
av_assert1(c->srcFormat == AV_PIX_FMT_BGR4_BYTE);
b = ( i >> 3 ) * 255;
g = ((i >> 1) & 3) * 85;
r = ( i & 1) * 255;
#define RGB2YUV_SHIFT 15
#define BY ( (int) (0.114 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define BV (-(int) (0.081 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define BU ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define GY ( (int) (0.587 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define GV (-(int) (0.419 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define GU (-(int) (0.331 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define RY ( (int) (0.299 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define RV ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define RU (-(int) (0.169 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
y = av_clip_uint8((RY * r + GY * g + BY * b + ( 33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
u = av_clip_uint8((RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
v = av_clip_uint8((RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
c->pal_yuv[i]= y + (u<<8) + (v<<16) + ((unsigned)a<<24);
switch (c->dstFormat) {
case AV_PIX_FMT_BGR32:
#if !HAVE_BIGENDIAN
case AV_PIX_FMT_RGB24:
#endif
c->pal_rgb[i]= r + (g<<8) + (b<<16) + ((unsigned)a<<24);
break;
case AV_PIX_FMT_BGR32_1:
#if HAVE_BIGENDIAN
case AV_PIX_FMT_BGR24:
#endif
c->pal_rgb[i]= a + (r<<8) + (g<<16) + ((unsigned)b<<24);
break;
case AV_PIX_FMT_RGB32_1:
#if HAVE_BIGENDIAN
case AV_PIX_FMT_RGB24:
#endif
c->pal_rgb[i]= a + (b<<8) + (g<<16) + ((unsigned)r<<24);
break;
case AV_PIX_FMT_RGB32:
#if !HAVE_BIGENDIAN
case AV_PIX_FMT_BGR24:
#endif
default:
c->pal_rgb[i]= b + (g<<8) + (r<<16) + ((unsigned)a<<24);
if (c->src0Alpha && !c->dst0Alpha && isALPHA(c->dstFormat)) {
uint8_t *base;
int x,y;
rgb0_tmp = av_malloc(FFABS(srcStride[0]) * srcSliceH + 32);
if (!rgb0_tmp)
return AVERROR(ENOMEM);
base = srcStride[0] < 0 ? rgb0_tmp - srcStride[0] * (srcSliceH-1) : rgb0_tmp;
for (y=0; y<srcSliceH; y++){
memcpy(base + srcStride[0]*y, src2[0] + srcStride[0]*y, 4*c->srcW);
for (x=c->src0Alpha-1; x<4*c->srcW; x+=4) {
base[ srcStride[0]*y + x] = 0xFF;
src2[0] = base;
if (c->srcXYZ && !(c->dstXYZ && c->srcW==c->dstW && c->srcH==c->dstH)) {
uint8_t *base;
rgb0_tmp = av_malloc(FFABS(srcStride[0]) * srcSliceH + 32);
if (!rgb0_tmp)
return AVERROR(ENOMEM);
base = srcStride[0] < 0 ? rgb0_tmp - srcStride[0] * (srcSliceH-1) : rgb0_tmp;
xyz12Torgb48(c, (uint16_t*)base, (const uint16_t*)src2[0], srcStride[0]/2, srcSliceH);
src2[0] = base;
if (!srcSliceY && (c->flags & SWS_BITEXACT) && c->dither == SWS_DITHER_ED && c->dither_error[0])
for (i = 0; i < 4; i++)
memset(c->dither_error[i], 0, sizeof(c->dither_error[0][0]) * (c->dstW+2));
if (c->sliceDir == 1) {
int srcStride2[4] = { srcStride[0], srcStride[1], srcStride[2],
srcStride[3] };
int dstStride2[4] = { dstStride[0], dstStride[1], dstStride[2],
dstStride[3] };
reset_ptr(src2, c->srcFormat);
reset_ptr((void*)dst2, c->dstFormat);
if (srcSliceY + srcSliceH == c->srcH)
c->sliceDir = 0;
ret = c->swscale(c, src2, srcStride2, srcSliceY, srcSliceH, dst2,
dstStride2);
} else {
int srcStride2[4] = { -srcStride[0], -srcStride[1], -srcStride[2],
-srcStride[3] };
int dstStride2[4] = { -dstStride[0], -dstStride[1], -dstStride[2],
-dstStride[3] };
src2[0] += (srcSliceH - 1) * srcStride[0];
if (!usePal(c->srcFormat))
src2[1] += ((srcSliceH >> c->chrSrcVSubSample) - 1) * srcStride[1];
src2[2] += ((srcSliceH >> c->chrSrcVSubSample) - 1) * srcStride[2];
src2[3] += (srcSliceH - 1) * srcStride[3];
dst2[0] += ( c->dstH - 1) * dstStride[0];
dst2[1] += ((c->dstH >> c->chrDstVSubSample) - 1) * dstStride[1];
dst2[2] += ((c->dstH >> c->chrDstVSubSample) - 1) * dstStride[2];
dst2[3] += ( c->dstH - 1) * dstStride[3];
reset_ptr(src2, c->srcFormat);
reset_ptr((void*)dst2, c->dstFormat);
if (!srcSliceY)
c->sliceDir = 0;
ret = c->swscale(c, src2, srcStride2, c->srcH-srcSliceY-srcSliceH,
srcSliceH, dst2, dstStride2);
if (c->dstXYZ && !(c->srcXYZ && c->srcW==c->dstW && c->srcH==c->dstH)) {
rgb48Toxyz12(c, (uint16_t*)dst2[0], (const uint16_t*)dst2[0], dstStride[0]/2, ret);
av_free(rgb0_tmp);
return ret;
| 1threat
|
static void encode_rgb_frame(FFV1Context *s, uint8_t *src[3], int w, int h, int stride[3]){
int x, y, p, i;
const int ring_size= s->avctx->context_model ? 3 : 2;
int16_t *sample[4][3];
int lbd= s->avctx->bits_per_raw_sample <= 8;
int bits= s->avctx->bits_per_raw_sample > 0 ? s->avctx->bits_per_raw_sample : 8;
int offset= 1 << bits;
s->run_index=0;
memset(s->sample_buffer, 0, ring_size*4*(w+6)*sizeof(*s->sample_buffer));
for(y=0; y<h; y++){
for(i=0; i<ring_size; i++)
for(p=0; p<4; p++)
sample[p][i]= s->sample_buffer + p*ring_size*(w+6) + ((h+i-y)%ring_size)*(w+6) + 3;
for(x=0; x<w; x++){
int b,g,r,a;
if(lbd){
unsigned v= *((uint32_t*)(src[0] + x*4 + stride[0]*y));
b= v&0xFF;
g= (v>>8)&0xFF;
r= (v>>16)&0xFF;
a= v>>24;
}else{
b= *((uint16_t*)(src[0] + x*2 + stride[0]*y));
g= *((uint16_t*)(src[1] + x*2 + stride[1]*y));
r= *((uint16_t*)(src[2] + x*2 + stride[2]*y));
}
b -= g;
r -= g;
g += (b + r)>>2;
b += offset;
r += offset;
sample[0][0][x]= g;
sample[1][0][x]= b;
sample[2][0][x]= r;
sample[3][0][x]= a;
}
for(p=0; p<3 + s->transparency; p++){
sample[p][0][-1]= sample[p][1][0 ];
sample[p][1][ w]= sample[p][1][w-1];
if (lbd)
encode_line(s, w, sample[p], (p+1)/2, 9);
else
encode_line(s, w, sample[p], (p+1)/2, bits+1);
}
}
}
| 1threat
|
c# - SQL update statement : <p>I need help with my SQL connection. I have this code:</p>
<pre><code> SqlConnection myConnection2 = new SqlConnection("server=c1212\\SQLEXPRESS;" +
"Trusted_Connection=yes;" +
"database=SPZ; " +
"connection timeout=30");
try
{
myConnection2.Open();
SqlCommand myCommand2 = new SqlCommand();
myCommand2.CommandText = "UPDATE SPZ set Datum='" + textBox1.Text+"' , ČasP='"+textBox5.Text+"', ČasO='"+textBox6.Text+"', SPZ='"+textBox2.Text+"', Příjmení='"+textBox3.Text+"', Firma='"+textBox4.Text+"', Poznámka='"+textBox7.Text+"', Kontrola='"+textBox8.Text+ "'
where Datum='" + textBox9.Text + "' and ČasP='" + textBox13.Text + "' and ČasO='" + textBox14.Text + "' and SPZ='" + textBox10.Text + "' and Příjmení='" + textBox11.Text + "' and Firma='" + textBox12.Text + "' and Poznámka='" + textBox15.Text + "' and Kontrola='" + textBox16.Text + "'";
myCommand2.ExecuteNonQuery();
// myConnection.Close();
}
catch (SqlException ex)
{
MessageBox.Show("Připojení do databáze selhalo! " + ex.Message);
}
</code></pre>
<p>I can't find what is wrong, can someone help me? </p>
| 0debug
|
how to use regular expressions in python 3 : pattern = r"(Mon|Tues|Wednes|Thurs|Fri)day, (February|March) [0-9]{2}, [0-9]{4}\s*Day [0-9]{1}"
line = """
Wednesday, February 28, 2018
Day 4 3:00 Dismissal
All Day
Thursday, March 01, 2018
Day 5 1:30PM Dismissal
All Day
Friday, March 02, 2018
Day 6 3:00 Dismissal
All Day
Monday, March 05, 2018
Day 1 1:30 Dismissal
All Day
Tuesday, March 06, 2018
Day 2 3:00 Dismissal
All Day
Tuesday, March 06, 2018"""
result = re.findall(pattern, line)
print(result)
won't work
| 0debug
|
Take values from input text area and place them in a div angularjs : HTML Code
<form novalidate>
<div class="list">
<div class="list list-inset" >
<label class="item item-input" id="descriptions">
<input type="text" height:"90" class="description" placeholder="Description ..." ng-model="describe" >
</label>
<label input="email" class="item item-input" id="email" ng-model="email" >
<span class="input-label">Email</span>
<input type="email">
</label>
<label class="item item-input" ng-model="date">
<span class="input-label">Date</span>
<input type="date">
</label>
</div>
<button class="button button-block button-balanced" ng-click="insertData(describe,email, date); AddItem()">Add Task</button>
<button class="button button-block button-assertive" ng-click="closeModal()"> cancel</button>
</div>
</form>
I want to have a function that takes the values of these input text areas and pases them in a div when the add task button is clicked.
| 0debug
|
Alibaba android app causes crash when you try to open an URL : <p>When you try to open a link, from example from whatsapp, the app (in this case whatsapp) crashes. This only happens if you have alibaba app installed in your device.
Reproduction path:</p>
<ol>
<li>install alibaba app (<a href="https://play.google.com/store/apps/details?id=com.alibaba.intl.android.apps.poseidon&hl=en">https://play.google.com/store/apps/details?id=com.alibaba.intl.android.apps.poseidon&hl=en</a>)</li>
<li>try to open url </li>
<li><p>app crashes (or it can't find any
other activities to open the link, even not the chrome browser.)</p>
<p>The crash what we see in our app is:</p>
<p>Fatal Exception: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.VIEW dat=<a href="http://www.nu.nl">http://www.nu.nl</a> cmp=com.alibaba.intl.android.apps.poseidon/com.alibaba.android.intl.weex.activity.WeexPageActivity VirtualScreenParam=Params{mDisplayId=-1, null, mFlags=0x00000000)} } from ProcessRecord{7307f55 18243:.../u0a226} (pid=18243, uid=10226) not exported from uid 10207</p></li>
</ol>
| 0debug
|
static void vfio_pci_load_rom(VFIODevice *vdev)
{
struct vfio_region_info reg_info = {
.argsz = sizeof(reg_info),
.index = VFIO_PCI_ROM_REGION_INDEX
};
uint64_t size;
off_t off = 0;
size_t bytes;
if (ioctl(vdev->fd, VFIO_DEVICE_GET_REGION_INFO, ®_info)) {
error_report("vfio: Error getting ROM info: %m");
return;
}
DPRINTF("Device %04x:%02x:%02x.%x ROM:\n", vdev->host.domain,
vdev->host.bus, vdev->host.slot, vdev->host.function);
DPRINTF(" size: 0x%lx, offset: 0x%lx, flags: 0x%lx\n",
(unsigned long)reg_info.size, (unsigned long)reg_info.offset,
(unsigned long)reg_info.flags);
vdev->rom_size = size = reg_info.size;
vdev->rom_offset = reg_info.offset;
if (!vdev->rom_size) {
error_report("vfio-pci: Cannot read device rom at "
"%04x:%02x:%02x.%x\n",
vdev->host.domain, vdev->host.bus, vdev->host.slot,
vdev->host.function);
error_printf("Device option ROM contents are probably invalid "
"(check dmesg).\nSkip option ROM probe with rombar=0, "
"or load from file with romfile=\n");
return;
}
vdev->rom = g_malloc(size);
memset(vdev->rom, 0xff, size);
while (size) {
bytes = pread(vdev->fd, vdev->rom + off, size, vdev->rom_offset + off);
if (bytes == 0) {
break;
} else if (bytes > 0) {
off += bytes;
size -= bytes;
} else {
if (errno == EINTR || errno == EAGAIN) {
continue;
}
error_report("vfio: Error reading device ROM: %m");
break;
}
}
}
| 1threat
|
Adding a key-value pair in evelry json multi-dimensional array : I have a list of JSON objects and I want every object to be inserted by a certain key value. Please take note that it is an angularjs $scope. I'm aware that this can be done by
Here is the code:
$scope.Items = [
{name:'Jani',country:'Norway'},
{name:'Hege',country:'Sweden'},
{name:'Kai',country:'Denmark'},
];
But what I want is to make it from that to this:
$scope.Items = [
{name:'Jani',country:'Norway', edit:false},
{name:'Hege',country:'Sweden', edit:false},
{name:'Kai',country:'Denmark', edit:false},
];
| 0debug
|
static int dca_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int channel_mask;
int channel_layout;
int lfe_samples;
int num_core_channels = 0;
int i, ret;
float **samples_flt;
float *src_chan;
float *dst_chan;
DCAContext *s = avctx->priv_data;
int core_ss_end;
int channels, full_channels;
float scale;
int achan;
int chset;
int mask;
int lavc;
int posn;
int j, k;
int endch;
s->xch_present = 0;
s->dca_buffer_size = ff_dca_convert_bitstream(buf, buf_size, s->dca_buffer,
DCA_MAX_FRAME_SIZE + DCA_MAX_EXSS_HEADER_SIZE);
if (s->dca_buffer_size == AVERROR_INVALIDDATA) {
av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\n");
}
init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8);
if ((ret = dca_parse_frame_header(s)) < 0) {
return ret;
}
avctx->sample_rate = s->sample_rate;
avctx->bit_rate = s->bit_rate;
s->profile = FF_PROFILE_DTS;
for (i = 0; i < (s->sample_blocks / 8); i++) {
if ((ret = dca_decode_block(s, 0, i))) {
av_log(avctx, AV_LOG_ERROR, "error decoding block\n");
return ret;
}
}
num_core_channels = s->prim_channels;
if (s->ext_coding)
s->core_ext_mask = dca_ext_audio_descr_mask[s->ext_descr];
else
s->core_ext_mask = 0;
core_ss_end = FFMIN(s->frame_size, s->dca_buffer_size) * 8;
if (s->core_ext_mask < 0 || s->core_ext_mask & (DCA_EXT_XCH | DCA_EXT_XXCH)) {
s->core_ext_mask = FFMAX(s->core_ext_mask, 0);
skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31);
while (core_ss_end - get_bits_count(&s->gb) >= 32) {
uint32_t bits = get_bits_long(&s->gb, 32);
switch (bits) {
case 0x5a5a5a5a: {
int ext_amode, xch_fsize;
s->xch_base_channel = s->prim_channels;
xch_fsize = show_bits(&s->gb, 10);
if ((s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize) &&
(s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize + 1))
continue;
skip_bits(&s->gb, 10);
s->core_ext_mask |= DCA_EXT_XCH;
if ((ext_amode = get_bits(&s->gb, 4)) != 1) {
av_log(avctx, AV_LOG_ERROR, "XCh extension amode %d not"
" supported!\n", ext_amode);
continue;
}
if (s->xch_base_channel < 2) {
av_log_ask_for_sample(avctx, "XCh with fewer than 2 base channels is not supported\n");
continue;
}
dca_parse_audio_coding_header(s, s->xch_base_channel, 0);
for (i = 0; i < (s->sample_blocks / 8); i++)
if ((ret = dca_decode_block(s, s->xch_base_channel, i))) {
av_log(avctx, AV_LOG_ERROR, "error decoding XCh extension\n");
continue;
}
s->xch_present = 1;
break;
}
case 0x47004a03:
s->core_ext_mask |= DCA_EXT_XXCH;
dca_xxch_decode_frame(s);
break;
case 0x1d95f262: {
int fsize96 = show_bits(&s->gb, 12) + 1;
if (s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + fsize96)
continue;
av_log(avctx, AV_LOG_DEBUG, "X96 extension found at %d bits\n",
get_bits_count(&s->gb));
skip_bits(&s->gb, 12);
av_log(avctx, AV_LOG_DEBUG, "FSIZE96 = %d bytes\n", fsize96);
av_log(avctx, AV_LOG_DEBUG, "REVNO = %d\n", get_bits(&s->gb, 4));
s->core_ext_mask |= DCA_EXT_X96;
break;
}
}
skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31);
}
} else {
skip_bits_long(&s->gb, core_ss_end - get_bits_count(&s->gb));
}
if (s->core_ext_mask & DCA_EXT_X96)
s->profile = FF_PROFILE_DTS_96_24;
else if (s->core_ext_mask & (DCA_EXT_XCH | DCA_EXT_XXCH))
s->profile = FF_PROFILE_DTS_ES;
if (s->dca_buffer_size - s->frame_size > 32 &&
get_bits_long(&s->gb, 32) == DCA_HD_MARKER)
dca_exss_parse_header(s);
avctx->profile = s->profile;
full_channels = channels = s->prim_channels + !!s->lfe;
if (!(s->core_ext_mask & DCA_EXT_XXCH)
|| (s->core_ext_mask & DCA_EXT_XXCH && avctx->request_channels > 0
&& avctx->request_channels
< num_core_channels + !!s->lfe + s->xxch_chset_nch[0]))
{
if (s->amode < 16) {
avctx->channel_layout = dca_core_channel_layout[s->amode];
if (s->xch_present && (!avctx->request_channels ||
avctx->request_channels
> num_core_channels + !!s->lfe)) {
avctx->channel_layout |= AV_CH_BACK_CENTER;
if (s->lfe) {
avctx->channel_layout |= AV_CH_LOW_FREQUENCY;
s->channel_order_tab = dca_channel_reorder_lfe_xch[s->amode];
} else {
s->channel_order_tab = dca_channel_reorder_nolfe_xch[s->amode];
}
} else {
channels = num_core_channels + !!s->lfe;
s->xch_present = 0;
if (s->lfe) {
avctx->channel_layout |= AV_CH_LOW_FREQUENCY;
s->channel_order_tab = dca_channel_reorder_lfe[s->amode];
} else
s->channel_order_tab = dca_channel_reorder_nolfe[s->amode];
}
if (channels > !!s->lfe &&
s->channel_order_tab[channels - 1 - !!s->lfe] < 0)
if (av_get_channel_layout_nb_channels(avctx->channel_layout) != channels) {
av_log(avctx, AV_LOG_ERROR, "Number of channels %d mismatches layout %d\n", channels, av_get_channel_layout_nb_channels(avctx->channel_layout));
}
if (avctx->request_channels == 2 && s->prim_channels > 2) {
channels = 2;
s->output = DCA_STEREO;
avctx->channel_layout = AV_CH_LAYOUT_STEREO;
}
else if (avctx->request_channel_layout & AV_CH_LAYOUT_NATIVE) {
static const int8_t dca_channel_order_native[9] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
s->channel_order_tab = dca_channel_order_native;
}
s->lfe_index = dca_lfe_index[s->amode];
} else {
av_log(avctx, AV_LOG_ERROR,
"Non standard configuration %d !\n", s->amode);
}
s->xxch_dmix_embedded = 0;
} else {
channel_mask = s->xxch_core_spkmask;
if (avctx->request_channels > 0
&& avctx->request_channels < s->prim_channels) {
channels = num_core_channels + !!s->lfe;
for (i = 0; i < s->xxch_chset && channels + s->xxch_chset_nch[i]
<= avctx->request_channels; i++) {
channels += s->xxch_chset_nch[i];
channel_mask |= s->xxch_spk_masks[i];
}
} else {
channels = s->prim_channels + !!s->lfe;
for (i = 0; i < s->xxch_chset; i++) {
channel_mask |= s->xxch_spk_masks[i];
}
}
channel_layout = 0;
for (i = 0; i < s->xxch_nbits_spk_mask; ++i) {
if (channel_mask & (1 << i)) {
channel_layout |= map_xxch_to_native[i];
}
}
if (av_popcount(channel_mask) != av_popcount(channel_layout)) {
av_log(avctx, AV_LOG_DEBUG,
"DTS-XXCH: Inconsistant avcodec/dts channel layouts\n");
}
avctx->channel_layout = channel_layout;
if (!(avctx->request_channel_layout & AV_CH_LAYOUT_NATIVE)) {
for (chset = -1, j = 0; chset < s->xxch_chset; ++chset) {
mask = chset >= 0 ? s->xxch_spk_masks[chset]
: s->xxch_core_spkmask;
for (i = 0; i < s->xxch_nbits_spk_mask; i++) {
if (mask & ~(DCA_XXCH_LFE1 | DCA_XXCH_LFE2) & (1 << i)) {
lavc = map_xxch_to_native[i];
posn = av_popcount(channel_layout & (lavc - 1));
s->xxch_order_tab[j++] = posn;
}
}
}
s->lfe_index = av_popcount(channel_layout & (AV_CH_LOW_FREQUENCY-1));
} else {
for (i = 0; i < channels; i++)
s->xxch_order_tab[i] = i;
s->lfe_index = channels - 1;
}
s->channel_order_tab = s->xxch_order_tab;
}
if (avctx->channels != channels) {
if (avctx->channels)
av_log(avctx, AV_LOG_INFO, "Number of channels changed in DCA decoder (%d -> %d)\n", avctx->channels, channels);
avctx->channels = channels;
}
s->frame.nb_samples = 256 * (s->sample_blocks / 8);
if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
samples_flt = (float **) s->frame.extended_data;
if (avctx->channels < full_channels) {
ret = av_samples_get_buffer_size(NULL, full_channels - channels,
s->frame.nb_samples,
avctx->sample_fmt, 0);
if (ret < 0)
return ret;
av_fast_malloc(&s->extra_channels_buffer,
&s->extra_channels_buffer_size, ret);
if (!s->extra_channels_buffer)
return AVERROR(ENOMEM);
ret = av_samples_fill_arrays((uint8_t **)s->extra_channels, NULL,
s->extra_channels_buffer,
full_channels - channels,
s->frame.nb_samples, avctx->sample_fmt, 0);
if (ret < 0)
return ret;
}
for (i = 0; i < (s->sample_blocks / 8); i++) {
int ch;
for (ch = 0; ch < channels; ch++)
s->samples_chanptr[ch] = samples_flt[ch] + i * 256;
for (; ch < full_channels; ch++)
s->samples_chanptr[ch] = s->extra_channels[ch - channels] + i * 256;
dca_filter_channels(s, i);
if ((s->source_pcm_res & 1) && s->xch_present) {
float *back_chan = s->samples_chanptr[s->channel_order_tab[s->xch_base_channel]];
float *lt_chan = s->samples_chanptr[s->channel_order_tab[s->xch_base_channel - 2]];
float *rt_chan = s->samples_chanptr[s->channel_order_tab[s->xch_base_channel - 1]];
s->fdsp.vector_fmac_scalar(lt_chan, back_chan, -M_SQRT1_2, 256);
s->fdsp.vector_fmac_scalar(rt_chan, back_chan, -M_SQRT1_2, 256);
}
if (s->xxch_dmix_embedded) {
ch = num_core_channels;
for (chset = 0; chset < s->xxch_chset; chset++) {
endch = ch + s->xxch_chset_nch[chset];
mask = s->xxch_dmix_embedded;
for (j = ch; j < endch; j++) {
if (mask & (1 << j)) {
src_chan = s->samples_chanptr[s->channel_order_tab[j]];
for (k = 0; k < endch; k++) {
achan = s->channel_order_tab[k];
scale = s->xxch_dmix_coeff[j][k];
if (scale != 0.0) {
dst_chan = s->samples_chanptr[achan];
s->fdsp.vector_fmac_scalar(dst_chan, src_chan,
-scale, 256);
}
}
}
}
if ((mask & (1 << ch)) && s->xxch_dmix_sf[chset] != 1.0f) {
scale = s->xxch_dmix_sf[chset];
for (j = 0; j < ch; j++) {
src_chan = s->samples_chanptr[s->channel_order_tab[j]];
for (k = 0; k < 256; k++)
src_chan[k] *= scale;
}
if (s->lfe) {
src_chan = s->samples_chanptr[s->lfe_index];
for (k = 0; k < 256; k++)
src_chan[k] *= scale;
}
}
ch = endch;
}
}
}
lfe_samples = 2 * s->lfe * (s->sample_blocks / 8);
for (i = 0; i < 2 * s->lfe * 4; i++)
s->lfe_data[i] = s->lfe_data[i + lfe_samples];
*got_frame_ptr = 1;
*(AVFrame *) data = s->frame;
return buf_size;
}
| 1threat
|
void checkasm_check_h264qpel(void)
{
LOCAL_ALIGNED_16(uint8_t, buf0, [BUF_SIZE]);
LOCAL_ALIGNED_16(uint8_t, buf1, [BUF_SIZE]);
LOCAL_ALIGNED_16(uint8_t, dst0, [BUF_SIZE]);
LOCAL_ALIGNED_16(uint8_t, dst1, [BUF_SIZE]);
H264QpelContext h;
int op, bit_depth, i, j;
for (op = 0; op < 2; op++) {
qpel_mc_func (*tab)[16] = op ? h.avg_h264_qpel_pixels_tab : h.put_h264_qpel_pixels_tab;
const char *op_name = op ? "avg" : "put";
for (bit_depth = 8; bit_depth <= 10; bit_depth++) {
ff_h264qpel_init(&h, bit_depth);
for (i = 0; i < (op ? 3 : 4); i++) {
int size = 16 >> i;
for (j = 0; j < 16; j++)
if (check_func(tab[i][j], "%s_h264_qpel_%d_mc%d%d_%d", op_name, size, j & 3, j >> 2, bit_depth)) {
randomize_buffers();
call_ref(dst0, src0, (ptrdiff_t)size * SIZEOF_PIXEL);
call_new(dst1, src1, (ptrdiff_t)size * SIZEOF_PIXEL);
if (memcmp(buf0, buf1, BUF_SIZE) || memcmp(dst0, dst1, BUF_SIZE))
fail();
bench_new(dst1, src1, (ptrdiff_t)size * SIZEOF_PIXEL);
}
}
}
report("%s", op_name);
}
}
| 1threat
|
static void mxf_write_random_index_pack(AVFormatContext *s)
{
MXFContext *mxf = s->priv_data;
AVIOContext *pb = s->pb;
uint64_t pos = avio_tell(pb);
int i;
avio_write(pb, random_index_pack_key, 16);
klv_encode_ber_length(pb, 28 + 12*mxf->body_partitions_count);
if (mxf->edit_unit_byte_count)
avio_wb32(pb, 1);
else
avio_wb32(pb, 0);
avio_wb64(pb, 0);
for (i = 0; i < mxf->body_partitions_count; i++) {
avio_wb32(pb, 1);
avio_wb64(pb, mxf->body_partition_offset[i]);
}
avio_wb32(pb, 0); of footer partition
avio_wb64(pb, mxf->footer_partition_offset);
avio_wb32(pb, avio_tell(pb) - pos + 4);
}
| 1threat
|
How to Pass Parameter to SQL Query After Conditional Split : I am fairly new at working with SSIS, and everything was straight forward until I came across this. I have a system that has data everywhere and I am trying to clean everything up by normalizing it. Now my issue is, in my SSIS I have a conditional split, what what I would like to do is to take that value which I just split it up and pass it as a parameter to a query I already have.
Thanks a lot in advance!
| 0debug
|
static int xen_pt_msgaddr64_reg_write(XenPCIPassthroughState *s,
XenPTReg *cfg_entry, uint32_t *val,
uint32_t dev_value, uint32_t valid_mask)
{
XenPTRegInfo *reg = cfg_entry->reg;
uint32_t writable_mask = 0;
uint32_t old_addr = cfg_entry->data;
if (!(s->msi->flags & PCI_MSI_FLAGS_64BIT)) {
XEN_PT_ERR(&s->dev,
"Can't write to the upper address without 64 bit support\n");
return -1;
}
writable_mask = reg->emu_mask & ~reg->ro_mask & valid_mask;
cfg_entry->data = XEN_PT_MERGE_VALUE(*val, cfg_entry->data, writable_mask);
s->msi->addr_hi = cfg_entry->data;
*val = XEN_PT_MERGE_VALUE(*val, dev_value, 0);
if (cfg_entry->data != old_addr) {
if (s->msi->mapped) {
xen_pt_msi_update(s);
}
}
return 0;
}
| 1threat
|
int ff_dirac_golomb_read_16bit(DiracGolombLUT *lut_ctx, const uint8_t *buf,
int bytes, uint8_t *_dst, int coeffs)
{
int i, b, c_idx = 0;
int16_t *dst = (int16_t *)_dst;
DiracGolombLUT *future[4], *l = &lut_ctx[2*LUT_SIZE + buf[0]];
INIT_RESIDUE(res);
for (b = 1; b <= bytes; b++) {
future[0] = &lut_ctx[buf[b]];
future[1] = future[0] + 1*LUT_SIZE;
future[2] = future[0] + 2*LUT_SIZE;
future[3] = future[0] + 3*LUT_SIZE;
if ((c_idx + 1) > coeffs)
return c_idx;
if (res_bits && l->sign) {
int32_t coeff = 1;
APPEND_RESIDUE(res, l->preamble);
for (i = 0; i < (res_bits >> 1) - 1; i++) {
coeff <<= 1;
coeff |= (res >> (RSIZE_BITS - 2*i - 2)) & 1;
}
dst[c_idx++] = l->sign * (coeff - 1);
}
for (i = 0; i < LUT_BITS; i++)
dst[c_idx + i] = l->ready[i];
c_idx += l->ready_num;
APPEND_RESIDUE(res, l->leftover);
l = future[l->need_s ? 3 : !res_bits ? 2 : res_bits & 1];
}
return c_idx;
}
| 1threat
|
document.getElementById('input').innerHTML = user_input;
| 1threat
|
when fixing bugs, how can I be sure I'm fixing the right bug? : <p>So this question is fairly generic and open. I have no specific example to hand right now, but have long been wondering how do most people out there approach bug fixing with regards to root causing the issue, rather than fixing the symptoms?</p>
| 0debug
|
iTerm2 v3 conversion of tabs to spaces on paste : <p>When pasting text containing tabs into a terminal window, iTerm2 (version 3) asked if I wanted to change the tabs into spaces. I agreed and set that as the default. Now, I need iTerm2 to stop converting the tabs into spaces. How do I do this?</p>
<p>I've looked through the preferences and hidden settings but couldn't find anything obvious. Even the preference to suppress the prompt t convert tabs to spaces is set to "No".</p>
| 0debug
|
How to code a javvascript to indicate item in a list clicked? : This javascript fails to show the line number of item clicked.
<!DOCTYPE html>
<html>
<body>
<script>
function registerHandlers() {
var as = document.getElementsByTagName('a');
for (var i = 0; i < as.length; i++) {
as[i].onclick = function() {
alert(i);
return true;
}
}
}
</script>
In my life, I used the following web search engines:<br/>
<a href="//www.yahoo.com">Yahoo!</a><br/>
<a href="//www.altavista.com">AltaVista</a><br/>
<a href="//www.google.com">Google</a><br/>
</body>
</html>
| 0debug
|
Mysql field type for </textarea>? : <p>I have a mysql field type "tinytext" and am using performing and update via my form with following extract:</p>
<pre><code><!-- Text input
<div class="control-group">
<label class="control-label" for="myinput"> Input code</label>
<div class="controls">
<textarea class="form-control" id="myinput" name="myinput" rows="4" ><?php echo $myinput;?> </textarea>
</div>
</div>
</code></pre>
<p>However the field is not recieving the data properly.
What mysql field type do I use for a textarea of about 4 lines?</p>
| 0debug
|
how to define dynamic nested loop python function : <pre><code>a = [1]
b = [2,3]
c = [4,5,6]
d = [a,b,c]
for x0 in d[0]:
for x1 in d[1]:
for x2 in d[2]:
print(x0,x1,x2)
</code></pre>
<p>Result:</p>
<pre><code>1 2 4
1 2 5
1 2 6
1 3 4
1 3 5
1 3 6
</code></pre>
<p>Perfect, now my question is how to define this to function, considering ofcourse there could be more lists with values. The idea is to get function, which would dynamicaly produce same result.</p>
<p>Is there a way to explain to python: "do 8 nested loops for example"?</p>
| 0debug
|
How to write a function that takes an argument and adds it to an array? : <p>I'm trying writing a function that takes an argument the user inputs into the console, adds it to the array and returns it.
This is my code.</p>
<pre><code>function Album(){
this.listPhotos=["bee", "ladybug", "caterpillar", "ant"];
this.addPhoto = function(x){
listPhotos.push("x");
console.log (x.listPhotos);
}
}
</code></pre>
| 0debug
|
Vuetify download previous version 1.5 : <p>The Vuetify CDN updated to the latest 2.0 version. How do I access version 1.5 via CDN? Or download the min.js file? I can't find any links on the Vuetify site to get previous versions. </p>
<p>Thanks,
Donnie</p>
| 0debug
|
int ff_jpeg2000_init_component(Jpeg2000Component *comp,
Jpeg2000CodingStyle *codsty,
Jpeg2000QuantStyle *qntsty,
int cbps, int dx, int dy,
AVCodecContext *avctx)
{
uint8_t log2_band_prec_width, log2_band_prec_height;
int reslevelno, bandno, gbandno = 0, ret, i, j;
uint32_t csize = 1;
if (!codsty->nreslevels2decode) {
av_log(avctx, AV_LOG_ERROR, "nreslevels2decode uninitialized\n");
return AVERROR_INVALIDDATA;
}
if (ret = ff_jpeg2000_dwt_init(&comp->dwt, comp->coord,
codsty->nreslevels2decode - 1,
codsty->transform))
return ret;
csize = (comp->coord[0][1] - comp->coord[0][0]) *
(comp->coord[1][1] - comp->coord[1][0]);
comp->data = av_malloc_array(csize, sizeof(*comp->data));
if (!comp->data)
return AVERROR(ENOMEM);
comp->reslevel = av_malloc_array(codsty->nreslevels, sizeof(*comp->reslevel));
if (!comp->reslevel)
return AVERROR(ENOMEM);
for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++) {
int declvl = codsty->nreslevels - reslevelno;
Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno;
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
reslevel->coord[i][j] =
ff_jpeg2000_ceildivpow2(comp->coord_o[i][j], declvl - 1);
reslevel->log2_prec_width = codsty->log2_prec_widths[reslevelno];
reslevel->log2_prec_height = codsty->log2_prec_heights[reslevelno];
if (reslevelno == 0)
reslevel->nbands = 1;
else
reslevel->nbands = 3;
if (reslevel->coord[0][1] == reslevel->coord[0][0])
reslevel->num_precincts_x = 0;
else
reslevel->num_precincts_x =
ff_jpeg2000_ceildivpow2(reslevel->coord[0][1],
reslevel->log2_prec_width) -
(reslevel->coord[0][0] >> reslevel->log2_prec_width);
if (reslevel->coord[1][1] == reslevel->coord[1][0])
reslevel->num_precincts_y = 0;
else
reslevel->num_precincts_y =
ff_jpeg2000_ceildivpow2(reslevel->coord[1][1],
reslevel->log2_prec_height) -
(reslevel->coord[1][0] >> reslevel->log2_prec_height);
reslevel->band = av_malloc_array(reslevel->nbands, sizeof(*reslevel->band));
if (!reslevel->band)
return AVERROR(ENOMEM);
for (bandno = 0; bandno < reslevel->nbands; bandno++, gbandno++) {
Jpeg2000Band *band = reslevel->band + bandno;
int cblkno, precno;
int nb_precincts;
switch (qntsty->quantsty) {
uint8_t gain;
int numbps;
case JPEG2000_QSTY_NONE:
numbps = cbps +
lut_gain[codsty->transform][bandno + reslevelno > 0];
band->stepsize = (float)SHL(2048 + qntsty->mant[gbandno],
2 + numbps - qntsty->expn[gbandno]);
break;
case JPEG2000_QSTY_SI:
band->stepsize = (float) (1 << 13);
break;
case JPEG2000_QSTY_SE:
gain = cbps;
band->stepsize = pow(2.0, gain - qntsty->expn[gbandno]);
band->stepsize *= (float)qntsty->mant[gbandno] / 2048.0 + 1.0;
band->stepsize *= 0.5;
break;
default:
band->stepsize = 0;
av_log(avctx, AV_LOG_ERROR, "Unknown quantization format\n");
break;
}
if (avctx->flags & CODEC_FLAG_BITEXACT)
band->stepsize = (int32_t)(band->stepsize * (1 << 16));
if (reslevelno == 0) {
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
band->coord[i][j] =
ff_jpeg2000_ceildivpow2(comp->coord_o[i][j],
declvl - 1);
log2_band_prec_width = reslevel->log2_prec_width;
log2_band_prec_height = reslevel->log2_prec_height;
band->log2_cblk_width = FFMIN(codsty->log2_cblk_width,
reslevel->log2_prec_width);
band->log2_cblk_height = FFMIN(codsty->log2_cblk_height,
reslevel->log2_prec_height);
} else {
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
band->coord[i][j] =
ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] -
(((bandno + 1 >> i) & 1) << declvl - 1),
declvl);
band->log2_cblk_width = FFMIN(codsty->log2_cblk_width,
reslevel->log2_prec_width - 1);
band->log2_cblk_height = FFMIN(codsty->log2_cblk_height,
reslevel->log2_prec_height - 1);
log2_band_prec_width = reslevel->log2_prec_width - 1;
log2_band_prec_height = reslevel->log2_prec_height - 1;
}
band->prec = av_malloc_array(reslevel->num_precincts_x *
reslevel->num_precincts_y,
sizeof(*band->prec));
if (!band->prec)
return AVERROR(ENOMEM);
nb_precincts = reslevel->num_precincts_x * reslevel->num_precincts_y;
for (precno = 0; precno < nb_precincts; precno++) {
Jpeg2000Prec *prec = band->prec + precno;
prec->coord[0][0] = (precno % reslevel->num_precincts_x) *
(1 << log2_band_prec_width);
prec->coord[0][0] = FFMAX(prec->coord[0][0], band->coord[0][0]);
prec->coord[1][0] = (precno / reslevel->num_precincts_x) *
(1 << log2_band_prec_height);
prec->coord[1][0] = FFMAX(prec->coord[1][0], band->coord[1][0]);
prec->coord[0][1] = prec->coord[0][0] +
(1 << log2_band_prec_width);
prec->coord[0][1] = FFMIN(prec->coord[0][1], band->coord[0][1]);
prec->coord[1][1] = prec->coord[1][0] +
(1 << log2_band_prec_height);
prec->coord[1][1] = FFMIN(prec->coord[1][1], band->coord[1][1]);
prec->nb_codeblocks_width =
ff_jpeg2000_ceildivpow2(prec->coord[0][1] -
prec->coord[0][0],
band->log2_cblk_width);
prec->nb_codeblocks_height =
ff_jpeg2000_ceildivpow2(prec->coord[1][1] -
prec->coord[1][0],
band->log2_cblk_height);
prec->cblkincl =
ff_jpeg2000_tag_tree_init(prec->nb_codeblocks_width,
prec->nb_codeblocks_height);
if (!prec->cblkincl)
return AVERROR(ENOMEM);
prec->zerobits =
ff_jpeg2000_tag_tree_init(prec->nb_codeblocks_width,
prec->nb_codeblocks_height);
if (!prec->zerobits)
return AVERROR(ENOMEM);
prec->cblk = av_malloc_array(prec->nb_codeblocks_width *
prec->nb_codeblocks_height,
sizeof(*prec->cblk));
if (!prec->cblk)
return AVERROR(ENOMEM);
for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) {
Jpeg2000Cblk *cblk = prec->cblk + cblkno;
uint16_t Cx0, Cy0;
Cx0 = (prec->coord[0][0] >> band->log2_cblk_width) << band->log2_cblk_width;
Cx0 = Cx0 + ((cblkno % prec->nb_codeblocks_width) << band->log2_cblk_width);
cblk->coord[0][0] = FFMAX(Cx0, prec->coord[0][0]);
Cy0 = (prec->coord[1][0] >> band->log2_cblk_height) << band->log2_cblk_height;
Cy0 = Cy0 + ((cblkno / prec->nb_codeblocks_width) << band->log2_cblk_height);
cblk->coord[1][0] = FFMAX(Cy0, prec->coord[1][0]);
cblk->coord[0][1] = FFMIN(Cx0 + (1 << band->log2_cblk_width),
prec->coord[0][1]);
cblk->coord[1][1] = FFMIN(Cy0 + (1 << band->log2_cblk_height),
prec->coord[1][1]);
cblk->zero = 0;
cblk->lblock = 3;
cblk->length = 0;
cblk->lengthinc = 0;
cblk->npasses = 0;
}
}
}
}
return 0;
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.