problem
stringlengths
26
131k
labels
class label
2 classes
Using PHP to split url : <p>I'm trying to split my url and have them in two variables.</p> <p>For Example:</p> <p>url = <a href="https://example.com/page@01" rel="nofollow noreferrer">https://example.com/page@01</a></p> <p>I want to be able split this url into two and create two variable.</p> <pre><code>$part_1 = example.com; $part_2 = page@01 </code></pre> <p>Thank you.</p>
0debug
Quiz project stuck : My quiz is getting caught and wont pass through on to the next question when the right answer is given. Im very new to Javascript, this is the first thing ive really tried to write. Any help (and explanation) would be massively appreciated! HTML: <!DOCTYPE> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <link rel="stylesheet" type="text/css" href="quiz-css.css" /> <link rel="stylesheet" type="text/javascript" href="quiz-css.css" /> </head> <body onload=""> <div> <h1 id="quizTitle">My JavaScript Quiz </h1> <p id="theQuestions">Click NEXT to start quiz.. </p> <form id="" action="#" method="post"> <!-- Form Needs Columns --> <div id=""> <label for="theAnswer"></label> <input type="text" id="theAnswer" tabindex="1"> </div> </form> <span id="pageNum"> </span> <button onclick="questFunc()">NEXT</button> </div> <script src="quiz-js.js"></script> </body> </html> JS: //loop through questions when right answer is given function questFunc() { "use strict"; //create array with my questions var qArray = ["What is the answer to the sum 1 + 1?", "If I have two eggs and I drop one how many do I have left?", "What are the three primary colors?"]; var aArray = ["2", "1", "What are the three primary colors?"]; //create variables var pageCounter = 1; var qCounter = 0; var aCounter = 0; var theQuestions = document.getElementById("theQuestions"); var pageNum = document.getElementById("pageNum"); var theAnswer = document.getElementById("theAnswer").value; if (qCounter < qArray.length) { theQuestions.innerHTML = qArray[qCounter]; pageNum.innerHTML = pageCounter; //not working - not allowing questions to move on when right answer is given. if (theAnswer === aArray[aCounter]) { qCounter++; aCounter++; pageCounter++; } } else if (qCounter >= qArray.length) { theQuestions.innerHTML = "Well Done!"; pageNum.style.display = "none"; } } Thank you in advance.
0debug
static void test_flush_event_notifier(void) { EventNotifierTestData data = { .n = 0, .active = 10, .auto_set = true }; event_notifier_init(&data.e, false); aio_set_event_notifier(ctx, &data.e, event_ready_cb, event_active_cb); g_assert(aio_poll(ctx, false)); g_assert_cmpint(data.n, ==, 0); g_assert_cmpint(data.active, ==, 10); event_notifier_set(&data.e); g_assert(aio_poll(ctx, false)); g_assert_cmpint(data.n, ==, 1); g_assert_cmpint(data.active, ==, 9); g_assert(aio_poll(ctx, false)); wait_for_aio(); g_assert_cmpint(data.n, ==, 10); g_assert_cmpint(data.active, ==, 0); g_assert(!aio_poll(ctx, false)); aio_set_event_notifier(ctx, &data.e, NULL, NULL); g_assert(!aio_poll(ctx, false)); event_notifier_cleanup(&data.e); }
1threat
My slider is not working ( please help me ) : Hello everybody I recently tried to add one slider but it not working,PLEASE IF YOU help me I AM OFFERING A REWARD .. THIS IS SLIDER : ht tps://codepen.io/amitasaurus/pen/OMbmPO THIS IS SITE INDEX : ht tps://code pen.io/GARDFIELD3/pen/oBVzLP And look what comes out me when I combine them ht tps://code pen.io/GARDFIELD3/pen/jyJMVr ****unites link codepen****
0debug
regex sorting from vertical into horizontal : <p>Thank you in advance if you could help me save a huge amount of time.</p> <p>I have tests that look like this:</p> <pre><code>These questions refer to the audio file 001_TOEIC_part3.mp3 1). Where is the conversation taking place? (A) In a church (B) In an office (C) In a classroom (D) In a park 2). What problem does the woman have? (A) She will be late for work. (B) She cannot make the meeting. (C) She is struggling with her presentation. (D) She worked late yesterday. 3). What does the man offer? (A) To help (B) To write her report (C) To get coffee (D) To make copies These questions refer to the audio file 002_TOEIC_part3.mp3 1). What does the man plan to do? (A) Have a party (B) Buy office supplies (C) Take a vacation (D) Ask the woman out 2). Why does the man call the woman? (A) To inquire about prices (B) To sell her food (C) To invite her to a party (D) To order food and drinks 3). Where will the party be held? (A) In a city park (B) At the man's company (C) On the beach (D) In a theater </code></pre> <p>And I would like them to look like this:</p> <pre><code>These questions refer to the audio file 001_TOEIC_part3.mp3 1). Where is the conversation taking place? (A) In a church (B) In an office (C) In a classroom (D) In a park 2). What problem does the woman have? (A) She will be late for work. (B) She cannot make the meeting. (C) She is struggling with her presentation. (D) She worked late yesterday. 3). What does the man offer? (A) To help (B) To write her report (C) To get coffee (D) To make copies These questions refer to the audio file 002_TOEIC_part3.mp3 1). What does the man plan to do? (A) Have a party (B) Buy office supplies (C) Take a vacation (D) Ask the woman out 2). Why does the man call the woman? (A) To inquire about prices (B) To sell her food (C) To invite her to a party (D) To order food and drinks 3). Where will the party be held? (A) In a city park (B) At the man's company (C) On the beach (D) In a theater </code></pre> <p>So I would like to sort the answer options from (A) to (D) from vertical to horizontal in Notepad++. Each audio file has got three questions, each question has four options to chose from (A), (B), (C), (D) The source file look exactly the same as the one that I inserted here. I really appreciate any help. Regards Aron</p>
0debug
static void enable_device(PIIX4PMState *s, int slot) { s->ar.gpe.sts[0] |= PIIX4_PCI_HOTPLUG_STATUS; s->pci0_status.up |= (1 << slot); }
1threat
Javascript/Jquery Identify every row in a textdocument : <p>What I need to be able to do is a to identify every row in a textfield or a text-file. So I can print any single row I want. For example push every row into an array (like this [row1][row2][row3]). I have no idea how to do this or if it's even possible. If it is i would appriciate some guidance, if it's not possible is there any other solution for my problem? Thank you!</p>
0debug
RuntimeError: Expected object of type torch.DoubleTensor but found type torch.FloatTensor for argument #2 'weight' : <p>My input tensor is torch.DoubleTensor type. But I got the RuntimeError below:</p> <pre><code>RuntimeError: Expected object of type torch.DoubleTensor but found type torch.FloatTensor for argument #2 'weight' </code></pre> <p>I didn't specify the type of the weight explicitly(i.e. I did not init my weight by myself. The weight is created by pytorch). What will influence the type of weight in the forward process?</p> <p>Thanks a lot!! </p>
0debug
How to do a javascript array sort based on the count of a character in a string? : I have a couple of strings in an array for example: String 1: "path/to/file" String 2: "path" String 3: "path/to/" String 4: "path2/to/file" String 5: "path2/to/file" String 5: "path2/to" etc... The thing that i would like to achieve is to sort the array based on the the count of the slash. So the less count slashes on top. So it would be like: String 1: "path" String 2: "path/to/" String 3: "path2/to" String 4: "path/to/file" String 5: "path2/to/file" String 6: "path2/to/file" Thank you for the sollution
0debug
Spark Data Frame Random Splitting : <p>I have a spark data frame which I want to divide into train, validation and test in the ratio 0.60, 0.20,0.20. </p> <p>I used the following code for the same: </p> <pre><code>def data_split(x): global data_map_var d_map = data_map_var.value data_row = x.asDict() import random rand = random.uniform(0.0,1.0) ret_list = () if rand &lt;= 0.6: ret_list = (data_row['TRANS'] , d_map[data_row['ITEM']] , data_row['Ratings'] , 'train') elif rand &lt;=0.8: ret_list = (data_row['TRANS'] , d_map[data_row['ITEM']] , data_row['Ratings'] , 'test') else: ret_list = (data_row['TRANS'] , d_map[data_row['ITEM']] , data_row['Ratings'] , 'validation') return ret_list ​ ​ split_sdf = ratings_sdf.map(data_split) train_sdf = split_sdf.filter(lambda x : x[-1] == 'train').map(lambda x :(x[0],x[1],x[2])) test_sdf = split_sdf.filter(lambda x : x[-1] == 'test').map(lambda x :(x[0],x[1],x[2])) validation_sdf = split_sdf.filter(lambda x : x[-1] == 'validation').map(lambda x :(x[0],x[1],x[2])) ​ print "Total Records in Original Ratings RDD is {}".format(split_sdf.count()) ​ print "Total Records in training data RDD is {}".format(train_sdf.count()) ​ print "Total Records in validation data RDD is {}".format(validation_sdf.count()) ​ print "Total Records in test data RDD is {}".format(test_sdf.count()) ​ ​ #help(ratings_sdf) Total Records in Original Ratings RDD is 300001 Total Records in training data RDD is 180321 Total Records in validation data RDD is 59763 Total Records in test data RDD is 59837 </code></pre> <p>My original data frame is ratings_sdf which I use to pass a mapper function which does the splitting. </p> <p>If you check the total sum of train, validation and test does not sum to split (original ratings) count. And these numbers change at every run of the code. </p> <p>Where is the remaining records going and why the sum is not equal?</p>
0debug
How to access web api from visual c++ : <p>Does anybody have an idea about how to get data from web api in visual c++? Thanks.</p>
0debug
Android SharedPreference - Please help me improve my method : I want to run another application whose package name is obtained from EditText in AlertDialog. My problem is that I want to display Dialog only when PackageName has not been specified or when the application is not available. Here is my code: public static final String mypref="mypref"; public static final String packagename="text"; private SharedPreferences pref; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); gpref(); Button b=(Button)findViewById(R.id.btn); b.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View p1) { // TODO: Implement this method String s=pref.getString(packagename); if(s!=""){ Intent i=getPackageManager().getLaunchIntentForPackage(s); if(i!=null){ startActivity(i); } else{ sd();} } else{ sd(); } } }); } public void sd(){ final EditText et=new EditText(this); AlertDialog ad=new AlertDialog.Builder(MainActivity.this).create(); ad.setView(et); ad.setButton(AlertDialog.BUTTON_POSITIVE, "Set", new DialogInterface.OnClickListener(){ @Override public void onClick(DialogInterface p1, int p2) { // TODO: Implement this method String s=et.getText().toString(); spref(s); } }); } public void gpref(){ pref=getSharedPreferences(mypref,MODE_PRIVATE); } public void spref(String s){ gpref(); SharedPreferences.Editor spedit=pref.edit(); spedit.putString(packagename,s); spedit.apply(); }
0debug
static uint32_t virtio_net_bad_features(VirtIODevice *vdev) { uint32_t features = 0; features |= (1 << VIRTIO_NET_F_MAC); features |= (1 << VIRTIO_NET_F_GUEST_CSUM); features |= (1 << VIRTIO_NET_F_GUEST_TSO4); features |= (1 << VIRTIO_NET_F_GUEST_TSO6); features |= (1 << VIRTIO_NET_F_GUEST_ECN); return features & virtio_net_get_features(vdev); }
1threat
How to send hidden info to database : <p>so I have a Dropbox and I have 3 selections. </p> <pre><code>car boat plane </code></pre> <p>The value of each one is an image which sends to the database, and reads correctly, by displaying the image of their choice on my page. However, I would like to insert into the database the name of each one too, this will also display under the image. I have a separate column on the table for the hidden info to be input, but am unsure of how to do this that will correspond with the choice they made. Is it possible to do such a thing?</p>
0debug
I don't know how to fix the error. [Lines 207 to 219] : // ZakAttack.cpp--A program for calculating student grades and // displaying the overall GPA // Shaheen Fathima Abdul Jamal Nazar, CISP 360 // Instructor: Professor Fowler // Date: 04/27/2018 #include <iomanip> #include <iostream> #include <limits> #include <string> using namespace std; // Variable Declarations string stName; int scores[50]; int *ptr = scores; int count = 0; // Function Prototypes void results(); void gradeAdd(); void mainMenu(); int getUserChoice(); void mainEvent(); int main() { // Program Greeting cout << " Hi! Welcome to the Zak Attack Program!\n" << endl; cout << " This program calculates the grades for a\n" << endl; cout << " specific number of quizzes taken by a student.\n" << endl; cout << " It also displays the overall grades along with\n" << endl; cout << " the letters (A-F) based on the scores attained by the student! " << endl; cout << endl; cout << " Enter the name of the student (First and Last): "; getline(cin, stName); cout << endl; mainEvent(); return 0; } void mainEvent() { int userInput; bool task = false; do { mainMenu(); cout << "\nEnter your choice: "; userInput = getUserChoice(); if (userInput == 1) { gradeAdd(); } else if (userInput == 2) { results(); break; } else if (userInput == 3) { task = true; } } while (task == false); } void results() { // variables to be used int tem, sNum, rNum, pNum; bool swapNum; int scCopy[50]; int *ptrCopy = scCopy; int lowScore[15]; int *ptrLow = lowScore; double gpAvg = 0; char rChoice; cout << " Name of Student: " << stName << endl; // Copying scores[] to scCopy[] array for (int i = 0; i < count; i++) { *(ptrCopy + i) = *(ptr + i); } do { swapNum = false; for (int j = 0; j < count; j++) { if (*(ptrCopy + j) > *(ptrCopy + (j + 1))) { tem = *(ptrCopy + j); *(ptrCopy + j) = *(ptrCopy + (j + 1)); *(ptrCopy + (j + 1)) = tem; swapNum = true; } } } while (swapNum); sNum = (count * 0.3); rNum = count; pNum = sNum; for (int i = 0; i < sNum; i++) { *(ptrLow + i) = *(ptrCopy + i); *(ptrCopy + i) = 0; pNum--; } // Display the grades as letters and overall GPA for (int i = 0; i < count; i++) { if (*(ptrCopy + i) >= 94) { cout << *(ptrCopy + i) << ": A " << endl; gpAvg += 4; } else if (*(ptrCopy + i) >= 90 && *(ptrCopy + i) < 94) { cout << *(ptrCopy + i) << ": A- " << endl; gpAvg += 3.7; } else if (*(ptrCopy + i) >= 87 && *(ptrCopy + i) < 90) { cout << *(ptrCopy + i) << ": B+ " << endl; gpAvg += 3.3; } else if (*(ptrCopy + i) >= 83 && *(ptrCopy + i) < 87) { cout << *(ptrCopy + i) << ": B " << endl; gpAvg += 3; } else if (*(ptrCopy + i) >= 80 && *(ptrCopy + i) < 83) { cout << *(ptrCopy + i) << ": B- " << endl; gpAvg += 2.7; } else if (*(ptrCopy + i) >= 77 && *(ptrCopy + i) < 80) { cout << *(ptrCopy + i) << ": C+ " << endl; gpAvg += 2.3; } else if (*(ptrCopy + i) >= 73 && *(ptrCopy + i) < 77) { cout << *(ptrCopy + i) << ": C " << endl; gpAvg += 2; } else if (*(ptrCopy + i) >= 70 && *(ptrCopy + i) < 73) { cout << *(ptrCopy + i) << ": C- " << endl; gpAvg += 1.7; } else if (*(ptrCopy + i) >= 67 && *(ptrCopy + i) < 70) { cout << *(ptrCopy + i) << ": D+ " << endl; gpAvg += 1.3; } else if (*(ptrCopy + i) >= 60 && *(ptrCopy + i) < 67) { cout << *(ptrCopy + i) << ": D " << endl; gpAvg += 1; } else if (*(ptrCopy + i) > 1 && *(ptrCopy + i) < 60) { cout << *(ptrCopy + i) << ": F " << endl; } } cout << "*******************" << endl; // Dropped scores for (int i = 0; i < sNum; i++) cout << *(ptrLow + i) << " [Dropped Score] " << endl; // Calculation of GPA and displaying results rNum -= sNum; cout << fixed << setprecision(2) << endl; gpAvg = (gpAvg / rNum); cout << " Grade Point Average (GPA): " << gpAvg << endl; cout << endl; if (gpAvg == 4) { cout << " Grade: A" << endl << endl; cout << " Excellent Job! " << endl; cout << " Keep up the good progress! " << endl; } else if (gpAvg < 4 && gpAvg > 3.67) { cout << " Grade: A-" << endl << endl; cout << " Good Score! " << endl; cout << " Keep Going! " << endl; } else if (gpAvg < 3.67 && gpAvg > 3.33) { cout << " Grade: B+" << endl << endl; cout << " Good Work! " << endl; cout << " Study a little more. " << endl; } else if (gpAvg < 3.33 && gpAvg > 3) { cout << " Grade: B" << endl << endl; cout << " Good " << endl; cout << " Need to study even more! " << endl; } else if (gpAvg < 3 && gpAvg > 2.67) { cout << " Grade: B- " << endl << endl; cout << " Well done " << endl; cout << " but need to work hard, " << endl; cout << " since you are close to a C! " << endl; } else if (gpAvg < 2.67 && gpAvg > 2.33) { cout << " Grade: C+ " << endl << endl; cout << " Looks like the grades are slipping " << endl; cout << " Need to spend more time studying! " << endl; } else if (gpAvg < 2.33 && gpAvg > 2) { cout << " Grade: C " << endl << endl; cout << " Getting low! " << endl; cout << " Need to work even harder! " << endl; } else if (gpAvg < 2 && gpAvg > 1.67) { cout << " Grade: C- " << endl << endl; cout << " Risky! Gotta study even more! " << endl; } else if (gpAvg < 1.67 && gpAvg > 1.33) { cout << " Grade: D+ " << endl << endl; cout << " Going low on your " << endl; cout << " chances of passing! " << endl; cout << " Work even more harder! " << endl; } else if (gpAvg < 1.33 && gpAvg > 1) { cout << " Grade: D " << endl; cout << " Chances of passing the class " << endl; cout << " are getting even lower! " << endl; cout << " Concentrate and study or seek help " << endl; cout << " from a tutor! " << endl; } else if (gpAvg < 1 && gpAvg > 0.67) { cout << " Grade: D- " << endl; cout << " Nearly no chances of passing! " << endl; } else if (gpAvg < 0.67) { cout << " Grade: F " << endl; cout << " Disappointing and dejecting! " << endl; cout << " Try Again or Opt for something else " << endl; } cout << " Would you like to enter the grades for another student?"; cin >> rChoice; if (rChoice == 'Y') { cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), '\n'); cout << " Enter name of the student (First and Last): "; getline(cin, stName); cin.clear(); cin.ignore(); mainEvent(); } else if (rChoice == 'N') { cout << " Good Bye! " << endl; } } void gradeAdd() { cout << "\nEnter quiz # " << (count + 1) << " score: "; cin >> *(ptr + count); while (*(ptr + count) > 100 || *(ptr + count) < 0) { cout << " Sorry! Invalid Input! Please enter a value from 0-100: " << endl; cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), '\n'); cin >> *(ptr + count); } count++; } void mainMenu() { cout << "1. Add a grade" << endl; cout << "2. Display Results" << endl; cout << "3. Quit" << endl; } int getUserChoice() { int userInput; cin >> userInput; while (userInput != 1 && userInput != 2 && userInput != 3) { cout << " Invalid Choice! Please enter a choice from 1 to 3: " << endl; cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), '\n'); cin >> userInput; } return userInput; } [Click here for Original Source Code][1] [1]: https://repl.it/@Shaheen_Fathima/EducatedJubilantBusiness I don't know how to fix the error right after the prompt asking the user to enter another student's name. Like the code compiles and prompts another student's name but the grades when they are displayed they appear as a cumulative grade from the previous student's grades as the new student's grade. It's part of homework, and I only have a few hours left to submit it. I need help as soon as possible please!
0debug
Trick to loop/autorefresh docker ps view like top/htop in bash : <p>Is it possible - and if yes, how - to have a self-refreshing view of current Docker containers printed by "docker ps" alike top/htop utilities?</p>
0debug
how to get frame rate of video in android os? : <p>I want to get frame rate of video, but i don't want to use FFMPEG,JAVACV lib. is that possible to get frame rate of video in android?</p> <p>I read <a href="https://developer.android.com/reference/android/media/MediaFormat.html#KEY_FRAME_RATE" rel="noreferrer">KEY_FRAME_RATE</a> it's says that,"Specifically, MediaExtractor provides an integer value corresponding to the frame rate information of the track if specified and non-zero." but i don't know how to use it?</p> <p>if you know about how to get frame rate from video then answer here.</p>
0debug
BottomNavigationView - How to get selected menu item? : <p>I used BottomNavigationView to switch fragments. How to get currently selected menu item, to prevent reopening fragment ? </p> <pre><code> BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_navigation); bottomNavigationView.setOnNavigationItemSelectedListener( new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.action_1: // open fragment 1 break; case R.id.action_2: // open fragment 2 break; case R.id.action_3: // open fragment 3 break; } return false; } }); } </code></pre>
0debug
Is it possible to embed a clickable url into certain part of a image? : <p>For example i have a jpeg image of a man standing on a table. I want to insert a clickable url to his shirt and also the table which he is standing. Is it possible to do?</p>
0debug
why the "?>" tag won't close the php part? : <p>So I was writing some PHP scripts and also some HTML codes but this was what happened:</p> <pre><code>&lt;?php /* some php scripts */ $q = "SELECT * FROM users WHERE id='1' AND username='test' AND pass='123'; /* the last line of php */ ?&gt; </code></pre> <p>this was the last code that I used and after that I closed the php and started the html part:</p> <pre><code>&lt;!doctype html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; </code></pre> <p>so at this point when I check localhost and my database I get an error:</p> <blockquote> <p>Parse error: syntax error, unexpected 'utf' (T_STRING) in F:\wamp64\www\Login2.php on line 47</p> </blockquote> <p>and it's because of the HTML code I used. although I closed the PHP with ?> it's still counting HTML codes as PHP!</p>
0debug
Chrome debugger doesn't show Fetch requests : <p>I don't see my <a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch" rel="noreferrer">Fetch</a> AJAX data requests in the Chrome debugger? Where are they?</p>
0debug
Erro pattern output : I have a shell script which writes sqlplus errors to a log with the following output. I only want to capture @DB with errors and redirect to output to a error log. any tips? : @DB_1 ERROR-123 ORA-123 @DB_2 @DB_3 @DB_4 ERROR-2222 ORA-3333 thx.
0debug
What is the simplest way to make a button press to start a method repeatedly (infinite time) in JavaFX? : <p>It would be nice, if I could use a simple timer (seconds or milliseconds) for the repeated method invocation. </p> <p>If it is possible, I would use another button to stop this method if necessary.</p> <pre><code>@FXML private void handleinfiniteActionButton(ActionEvent event) { methodToRunInfiniteTime(); } </code></pre>
0debug
LATEST RECORD AND SUM SQL : I'm looking for solution for this problem. Kindly need anyone help. Thanks. Table: [table set][1] i want this output (show latest tier based on maximum transaction id) [output][2] [1]: https://i.stack.imgur.com/76lYu.jpg [2]: https://i.stack.imgur.com/NqhwO.jpg Thanks all
0debug
Divide by zero and no error? : <p>Just threw together a simple test, not for any particular reason other than I like to try to have tests for all my methods even though this one is quite straightforward, or so I thought.</p> <pre><code> [TestMethod] public void Test_GetToolRating() { var rating = GetToolRating(45.5, 0); Assert.IsNotNull(rating); } private static ToolRating GetToolRating(double total, int numberOf) { var ratingNumber = 0.0; try { var tot = total / numberOf; ratingNumber = Math.Round(tot, 2); } catch (Exception ex) { var errorMessage = ex.Message; //log error here //var logger = new Logger(); //logger.Log(errorMessage); } return GetToolRatingLevel(ratingNumber); } </code></pre> <p>As you can see in the test method, I AM dividing by zero. The problem is, it doesn't generate an error. See the error window display below.</p> <p><a href="https://i.stack.imgur.com/Fjx6O.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Fjx6O.png" alt="Error List View from VS2017"></a></p> <p>Instead of an error it is giving a value of infinity? What am I missing?So I googled and found that doubles divided by zero DON'T generate an error they either give null or infinity. The question becomes then, how does one test for an Infinity return value?</p>
0debug
static void dca_exss_parse_header(DCAContext *s) { int asset_size[8]; int ss_index; int blownup; int num_audiop = 1; int num_assets = 1; int active_ss_mask[8]; int i, j; int start_posn; int hdrsize; uint32_t mkr; if (get_bits_left(&s->gb) < 52) return; start_posn = get_bits_count(&s->gb) - 32; skip_bits(&s->gb, 8); ss_index = get_bits(&s->gb, 2); blownup = get_bits1(&s->gb); hdrsize = get_bits(&s->gb, 8 + 4 * blownup) + 1; skip_bits(&s->gb, 16 + 4 * blownup); s->static_fields = get_bits1(&s->gb); if (s->static_fields) { skip_bits(&s->gb, 2); skip_bits(&s->gb, 3); if (get_bits1(&s->gb)) skip_bits_long(&s->gb, 36); num_audiop = get_bits(&s->gb, 3) + 1; if (num_audiop > 1) { avpriv_request_sample(s->avctx, "Multiple DTS-HD audio presentations"); return; } num_assets = get_bits(&s->gb, 3) + 1; if (num_assets > 1) { avpriv_request_sample(s->avctx, "Multiple DTS-HD audio assets"); return; } for (i = 0; i < num_audiop; i++) active_ss_mask[i] = get_bits(&s->gb, ss_index + 1); for (i = 0; i < num_audiop; i++) for (j = 0; j <= ss_index; j++) if (active_ss_mask[i] & (1 << j)) skip_bits(&s->gb, 8); s->mix_metadata = get_bits1(&s->gb); if (s->mix_metadata) { int mix_out_mask_size; skip_bits(&s->gb, 2); mix_out_mask_size = (get_bits(&s->gb, 2) + 1) << 2; s->num_mix_configs = get_bits(&s->gb, 2) + 1; for (i = 0; i < s->num_mix_configs; i++) { int mix_out_mask = get_bits(&s->gb, mix_out_mask_size); s->mix_config_num_ch[i] = dca_exss_mask2count(mix_out_mask); } } } for (i = 0; i < num_assets; i++) asset_size[i] = get_bits_long(&s->gb, 16 + 4 * blownup); for (i = 0; i < num_assets; i++) { if (dca_exss_parse_asset_header(s)) return; } j = get_bits_count(&s->gb); if (start_posn + hdrsize * 8 > j) skip_bits_long(&s->gb, start_posn + hdrsize * 8 - j); for (i = 0; i < num_assets; i++) { start_posn = get_bits_count(&s->gb); mkr = get_bits_long(&s->gb, 32); if (mkr == 0x655e315e) { dca_xbr_parse_frame(s); } else if (mkr == 0x47004a03) { dca_xxch_decode_frame(s); s->core_ext_mask |= DCA_EXT_XXCH; } else { av_log(s->avctx, AV_LOG_DEBUG, "DTS-ExSS: unknown marker = 0x%08x\n", mkr); } j = get_bits_count(&s->gb); if (start_posn + asset_size[i] * 8 > j) skip_bits_long(&s->gb, start_posn + asset_size[i] * 8 - j); } }
1threat
How to increase icon size in android bottom navigation layout? : <p>I am using the bottom layout navigation style in android that was recently introduced by google in design library 25. In all the tutorials and questions i see, the images in their icons are a normal size, but mine are extra small, despite the fact that the image I'm saving to drawable folder is 72x72. Here is a screenshot:</p> <p><a href="https://i.stack.imgur.com/6HgS5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/6HgS5.png" alt="enter image description here"></a></p> <p>The icons should be at least 2, maybe even 3 times that size. How can I do it? Here is my code in my bottom_layout.xml:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"&gt; &lt;item android:id="@+id/menu_home" android:title="test" android:icon="@drawable/tabbarglossary" app:showAsAction="always|withText" /&gt; &lt;item android:id="@+id/menu_search" android:title="test2" android:icon="@drawable/mediationtabbar" app:showAsAction="always|withText" /&gt; &lt;item android:id="@+id/menu_notifications" android:title="test3" android:icon="@drawable/ic_action_name" app:showAsAction="always|withText" /&gt; &lt;/menu&gt; </code></pre> <p>and in my activity_main.xml:</p> <pre><code> &lt;android.support.design.widget.BottomNavigationView android:id="@+id/navigation" android:layout_width="match_parent" android:layout_height="80dp" android:layout_alignParentBottom="true" android:layout_gravity="bottom" android:layout_marginBottom="0dp" android:layout_marginLeft="0dp" android:layout_marginRight="0dp" android:focusable="false" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" design:menu="@menu/bottom_layout" /&gt; </code></pre> <p>Thanks</p>
0debug
Object has no attribute '.__dict__' in python3 : <p>I have a test that passes in Python2 and fails in Python3, I'm trying to find out why. The test fails at the following line:</p> <pre><code>self._timeseries[0].resource.__dict__ </code></pre> <p>With the error:</p> <pre><code>AttributeError: 'Resource' object has no attribute '__dict__' </code></pre> <p>If I debug the test, and print the object in the debugger, I can see the following:</p> <pre><code>(Pdb) p self._timeseries[0].resource.__dict__ OrderedDict([('type', 'type_value'), ('labels', {'label1': 'value1', 'label2': 'value2', 'label3': 'value3'})]) </code></pre> <p>If I do the same in Python3 debugger, I get this:</p> <pre><code>(Pdb) p self._timeseries[0].resource.__dict__ *** AttributeError: 'Resource' object has no attribute '__dict__' </code></pre> <p>Any ideas why this might be happening? The object looks exactly the same if I print it in the debugger without the <code>.__dict__</code>, why is this failing for Python3?</p>
0debug
How to replace and matches a specific String with input string : <p>My database table column contains several Strings like below mentioned:</p> <pre><code>--------------------------- id | string | --------------------------- 1 | I love C# Code | --------------------------- 2 | I love Java Code | --------------------------- 3 | I love python Code| --------------------------- 4 | hello java | --------------------------- 5 | hello c# | --------------------------- </code></pre> <p>In c# each row at a time will be fetched from data base and I want to check my given pattern is matches or not.</p> <p>My pattern is: <code>I love &lt;anything&gt; Code</code></p> <p>And I also want to replace by another String.</p> <p>I have tried: </p> <pre><code>foreach( string record in stringsFromDB){ boolean isMatches=Regex.Matches(record, "I love .+? Code"); if(isMatches){ Console.Writeline("String matches"); }else{ Console.Writeline("String not matches"); } string newString= Regex.Replace(record, "I love .+? Code","",, RegexOptions.IgnoreCase); Console.Writeline(newString); } </code></pre> <p>Expected Result:</p> <p>For matching: For first three records it will print: String matches. For the else two print: String not matches.</p> <p>And</p> <p>For replacing: For first three records it will print: I love Code. For the else two print as it is. </p> <p>But nothing happen when i write code.</p> <p>Please help.</p> <p>Thanks.</p>
0debug
void error_set_field(Error *err, const char *field, const char *value) { QDict *dict = qdict_get_qdict(err->obj, "data"); return qdict_put(dict, field, qstring_from_str(value)); }
1threat
OOP concepts abstraction and encapsulation : <p>I am learning about OOP and I was wondering about abstraction and encapsulation. Would it be correct to say that abstraction is to chose what information to show and encapsulation is the way it is achieved? If I said this in an interview would it be a correct way to explain it?</p>
0debug
How to make round corners for image with percent icon? : How to make round corners for image with percent icon? I try to use negative margin for imageView but is not works. Thx. <LinearLayout android:gravity="center_vertical" android:layout_marginTop="15dp" android:layout_gravity="top|center" android:background="@drawable/rounded_background_white" android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content"> <ImageView android:src="@drawable/ic_discount_percent" android:layout_marginLeft="-3dp" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <TextView android:textColor="@android:color/black" android:layout_marginLeft="8dp" android:text="Скидка 10%" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> [![I need this][1]][1] [![Problem this][2]][2] [1]: https://i.stack.imgur.com/lG63U.png [2]: https://i.stack.imgur.com/0wVM6.png
0debug
so I need to pick the cube vaules between 1 and 100 : cubos = [valor**3 for valor in range(1,101)]#creates a list the cubes from 1 to 100 for cubo in cubos:#loop and create the internal values if cubo >= 100:#pick the values bigger then 100 del cubo #delete them print (cubos)#print the values lower then 100
0debug
Divide by zero error input into tkinter message for a calculator : I built a calculator in python and it works, except that if someone tries to a number divided by zero, they don't receive an "Invalid Syntax!" error in the calculator input. How could I make it so the message "Invalid Syntax!" shows in the calculator input? #-*-coding: utf-8-*- from tkinter import * import math class calc: def getandreplace(self): self.expression = self.e.get() self.newtext=self.expression.replace(self.div,'/') self.newtext=self.newtext.replace('x','*') def equals(self): self.getandreplace() try: self.value= eval(self.newtext) except SyntaxError or NameError: self.e.delete(0,END) self.e.insert(0,'Invalid Syntax!') else: self.e.delete(0,END) self.e.insert(0,self.value) def squareroot(self): self.getandreplace() try: self.value= eval(self.newtext) except SyntaxError or NameError: self.e.delete(0,END) self.e.insert(0,'Invalid Syntax!') else: self.sqrtval=math.sqrt(self.value) self.e.delete(0,END) self.e.insert(0,self.sqrtval) def square(self): self.getandreplace() try: self.value= eval(self.newtext) except SyntaxError or NameError: self.e.delete(0,END) self.e.insert(0,'Invalid Syntax!') else: self.sqval=math.pow(self.value,2) self.e.delete(0,END) self.e.insert(0,self.sqval) def clearall(self): self.e.delete(0,END) def clear1(self): self.txt=self.e.get()[:-1] self.e.delete(0,END) self.e.insert(0,self.txt) def action(self,argi): self.e.insert(END,argi) def __init__(self,master): master.title('PyCalc') master.geometry() self.e = Entry(master) self.e.grid(row=0,column=0,columnspan=6,pady=3) self.e.focus_set() self.div='/' Button(master,text="=",width=11, bg="red", fg="white", command=lambda:self.equals()).grid(row=4, column=4,columnspan=2) Button(master,text='AC',width=4, bg="orange", fg="white", command=lambda:self.clearall()).grid(row=1, column=4) Button(master,text='C',width=4, bg="orange", fg="white", command=lambda:self.clear1()).grid(row=1, column=5) Button(master,text="+", bg="grey", fg="white", width=4,command=lambda:self.action('+')).grid(row=4, column=3) Button(master,text="x",width=4, bg = "grey", fg="white", command=lambda:self.action('x')).grid(row=2, column=3) Button(master,text="-",width=4, bg="grey", fg="white", command=lambda:self.action('-')).grid(row=3, column=3) Button(master,text="÷",width=4, bg ="grey", fg="white", command=lambda:self.action(self.div)).grid(row=1, column=3) Button(master,text="%",width=4, bg="grey", fg="white", command=lambda:self.action('%')).grid(row=4, column=2) Button(master,text="7",width=4,command=lambda:self.action(7)).grid(row=1, column=0) Button(master,text="8",width=4,command=lambda:self.action(8)).grid(row=1, column=1) Button(master,text="9",width=4,command=lambda:self.action(9)).grid(row=1, column=2) Button(master,text="4",width=4,command=lambda:self.action(4)).grid(row=2, column=0) Button(master,text="5",width=4,command=lambda:self.action(5)).grid(row=2, column=1) Button(master,text="6",width=4,command=lambda:self.action(6)).grid(row=2, column=2) Button(master,text="1",width=4,command=lambda:self.action(1)).grid(row=3, column=0) Button(master,text="2",width=4,command=lambda:self.action(2)).grid(row=3, column=1) Button(master,text="3",width=4,command=lambda:self.action(3)).grid(row=3, column=2) Button(master,text="0",width=4,command=lambda:self.action(0)).grid(row=4, column=0) Button(master,text=".", width=4, bg="grey", fg="white", command=lambda:self.action('.')).grid(row=4, column=1) Button(master,text="(",width=4, bg="grey", fg="white", command=lambda:self.action('(')).grid(row=2, column=4) Button(master,text=")",width=4, bg="grey", fg="white", command=lambda:self.action(')')).grid(row=2, column=5) Button(master,text="√",width=4, bg="grey", fg="white", command=lambda:self.squareroot()).grid(row=3, column=4) Button(master,text="x²",width=4, bg="grey", fg="white",command=lambda:self.square()).grid(row=3, column=5) #Main root = Tk() obj=calc(root) root.configure(background="lightblue") root.resizable(width=False, height=False) root.mainloop() If you have any suggestions for something to add on, feel free to add onto your answer.
0debug
How to create smooth transition (animation) of layouts : <p>I have designed my app for both Android and iOS. Now I need to create smooth transitions like in this app. <a href="https://www.youtube.com/watch?v=gFUQ182HT0g" rel="nofollow noreferrer">Video of app</a> .I need it for both devices. Can anyone link me some tutorial, video or just documentation? Because everything what I have managed to do was flashy animations, no the smooth one. Thanks for answers.</p>
0debug
to write a python code that that takes a positive integer argument and returns True if the integer is square free, and False otherwise : enter code here def squarefree(n): for i in range (2,n-1): if n%(i**2)==0: return False else: return True
0debug
void DMA_run (void) { }
1threat
Select areas of an image with Jquery : <p>I started a web application with C# and mvc5.</p> <p>In my application I read images from database and show them in an image slider.</p> <p>I want to add a button to the page and when user click on this button User can click on one area of image and I save this x and y of area to the database.</p> <p>my problem is I dont know how can I get the x and y with any resolution of devices. Maybe user use Iphone maybe Ipad or maybe imac.</p>
0debug
Determine months with 5 or more Sundays using Calendar module in Python? : <p>I need to write a code to find which month in a year 2018 for example has 5 or more Sundays? I want to use calendar module in Python and save the resulting months in abbreviated form. I saw documentation for calendar module but couldnt figure out the code.</p>
0debug
OpenGL shader error with wxwidgets : I'm writing an openGL program using the wxWidgets library, I have it mostly working, but I am getting shader compilation errors due to bad characters being inserted (I think), only I can't find where the characters are or what is causing them. The error is : error 0(1) : error C0000: syntax error, unexpected $undefined at token "<undefined>" I'm not sure why though, since I can't see any errors when I cout the string. Here is what is being fed to glshadersource() : #version 430 core layout(location =0) in vec3 vpos; //out vec3 fragmentColor; uniform mat4 MVP; void main(void) { gl_Position = MVP * vec4(vpos,1); };" Here are the shader compiler functions I use: void GL_set::compileAndLink() { GLint Result = GL_FALSE; int InfoLogLength = 0; // Create vertex shader, attach source code, compile vertexShader = glCreateShader(GL_VERTEX_SHADER); const GLchar* adapter[1]; adapter[0] = readShaderCode("Vshader.glsl").c_str(); glShaderSource(vertexShader, 1, adapter, NULL); glCompileShader(vertexShader); // Check vertex shader for errors glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &Result); glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &InfoLogLength); if (InfoLogLength > 0) { char vertexError[1000]; glGetShaderInfoLog(vertexShader, InfoLogLength, NULL, &vertexError[0]); std::cout << &vertexError[0]; } // Create fragment shader, attach source code, compile fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); adapter[0] = readShaderCode("Fshader.glsl").c_str(); glShaderSource(fragmentShader, 1, adapter, NULL); glCompileShader(fragmentShader); // Check fragment shader for errors glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &Result); glGetShaderiv(fragmentShader, GL_INFO_LOG_LENGTH, &InfoLogLength); if (InfoLogLength > 0) { char fragmentError[1000]; glGetShaderInfoLog(fragmentShader, InfoLogLength, NULL, &fragmentError[0]); std::cout << &fragmentError[0]; } // Create program and attach shaders program = glCreateProgram(); glAttachShader(program, vertexShader); glAttachShader(program, fragmentShader); glLinkProgram(program); //check program for errors glGetProgramiv(program, GL_LINK_STATUS, &Result); glGetProgramiv(program, GL_INFO_LOG_LENGTH, &InfoLogLength); if (InfoLogLength > 0) { char programError[1000]; glGetProgramInfoLog(program, InfoLogLength, NULL, &programError[0]); std::cout << &programError[0]; } } std::string GL_set::readShaderCode(const char* fileName) { printf("passing %s to readShaderCode() \n", fileName); std::ifstream input(fileName); if(!input.good()) { std::cout << "failed to load file " << fileName; exit(1); } std::string code = std::string( std::istreambuf_iterator<char>(input), std::istreambuf_iterator<char>() ); // output the code to cout for error checking std::cout << "Read shader input: \n" << code << "\n" << std::endl; return code; } Here is the full console output: normal display attribs are supported calling gl_init() gl_set construtor called setting buffers passing Vshader.glsl to readShaderCode() Read shader input: #version 430 core layout(location =0) in vec3 vpos; //out vec3 fragmentColor; uniform mat4 MVP; void main(void) { //output position of the vertex in clip space MVP*position gl_Position = MVP * vec4(vpos,1); }; 0(1) : error C0000: syntax error, unexpected $undefined at token "<undefined>" passing Fshader.glsl to readShaderCode() Read shader input: #version 430 core in vec3 fragmentColor; out vec3 color; void main() { color = fragmentColor; }; 0(1) : error C0000: syntax error, unexpected $undefined at token "<undefined>" Vertex info ----------- 0(1) : error C0000: syntax error, unexpected $undefined at token " <undefined>" (0) : error C2003: incompatible options for link Fragment info ------------- 0(1) : error C0000: syntax error, unexpected $undefined at token "<undefined>" (0) : error C2003: incompatible options for link Loading OBJ file mod.obj... Here is the rest of the class: #include "GL_set.h" GL_set::GL_set() { std::cout << "gl_set construtor called" << std::endl; GL_set::setBuffers(); } void GL_set::setBuffers() { std::cout << "setting buffers" << std::endl; glGenVertexArrays(1, &vao); glBindVertexArray(vao); //create shaders and attach them to the program object GL_set::compileAndLink(); loadOBJ("mod.obj", vdata); // use OBJ loader glGenBuffers(1, &vertexbuffer); glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer); glBufferData(GL_ARRAY_BUFFER, vdata.size()*sizeof(glm::vec3), &vdata[0], GL_STATIC_DRAW); //vertex buffer glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer); glVertexAttribPointer( 0, //index 3, //size GL_FLOAT, //type GL_FALSE, //normalized? 0, //stride 0 //array buffer offset ); } void GL_set::draw() { glBindVertexArray(vao); GLuint matrixID = glGetUniformLocation(program, "MVP"); ////////////////////////////matrix operations///////////////////////////////////////// //projection matrix 45 degree FoV, 4:3 ratio, display range 0.1 - 100 glm::mat4 projection = glm::perspective(45.0f, 4.0f/3.0f, 0.1f, 100.0f); //camera matrix glm::mat4 view = glm::lookAt( glm::vec3(8, 8, 8), //camera posiiton glm::vec3(0, 1, 0), //camera looks at this point glm::vec3(0, 1, 0) //head up position ); //model matrix identity matrix glm::mat4 model = glm::mat4(1.0f); //rotate model = glm::rotate(model, 1.0f, glm::vec3(1,1,1)); //model-view-projection glm::mat4 MVP = projection * view * model; ///////////////////////////////////////////////////////// glUniformMatrix4fv(matrixID, 1, GL_FALSE, &MVP[0][0]); glDrawArrays(GL_TRIANGLES, 0, vdata.size()*sizeof(glm::vec3)); } I think the wxWidgets related code I have is okay, the window interface loads with a blank white screen, presumably caused by the shader errors. I can post more if needed, thanks.
0debug
Write the SQL code that will list Physician-Person appointments only ONCE. : This one is confusing me? This is what I have so far : <code>SELECT DISTINCT Appointment_date_time FROM Appointment INNER JOIN Person ON Appointment.Person_ID = Person.Person_ID INNER JOIN Physician ON Physician.Physician_ID = Person.Physician_ID HAVING COUNT(*) < 1</code>
0debug
Reverse iterator returns garbage when optimized : <p>I have a <code>AsIterator</code> template class which takes a numeric-like type, in this example just an <code>int</code>, and converts it into an iterator (<code>++</code> and <code>--</code> increment and decrement the number, and <code>operator*</code> just returns a reference to it).</p> <p>This works fine <strong>unless it's wrapped into a <code>std::reverse_iterator</code> and compiled with any optimization</strong> (<code>-O</code> is enough). When I optimize the binary, the compiler strips out the dereference call to the <code>reverse_iterator</code> and replaces it with some weird value. It must be noted that it still <strong>makes the correct number of iterations</strong>. It's just the value obtained by reverse iterator that is garbage.</p> <p>Consider the following code:</p> <pre class="lang-cpp prettyprint-override"><code>#include &lt;iterator&gt; #include &lt;cstdio&gt; template&lt;typename T&gt; class AsIterator : public std::iterator&lt;std::bidirectional_iterator_tag, T&gt; { T v; public: AsIterator(const T &amp; init) : v(init) {} T &amp;operator*() { return v; } AsIterator &amp;operator++() { ++v; return *this; } AsIterator operator++(int) { AsIterator copy(*this); ++(*this); return copy; } AsIterator &amp;operator--() { --v; return *this; } AsIterator operator--(int) { AsIterator copy(*this); --(*this); return copy; } bool operator!=(const AsIterator &amp;other) const {return v != other.v;} bool operator==(const AsIterator &amp;other) const {return v == other.v;} }; typedef std::reverse_iterator&lt;AsIterator&lt;int&gt;&gt; ReverseIt; int main() { int a = 0, b = 0; printf("Insert two integers: "); scanf("%d %d", &amp;a, &amp;b); if (b &lt; a) std::swap(a, b); AsIterator&lt;int&gt; real_begin(a); AsIterator&lt;int&gt; real_end(b); for (ReverseIt rev_it(real_end); rev_it != ReverseIt(real_begin); ++rev_it) { printf("%d\n", *rev_it); } return 0; } </code></pre> <p>This should supposingly loop down from the highest inserted number to the lowest and print them, such as in this run (compiled with <code>-O0</code>):</p> <pre><code>Insert two integers: 1 4 3 2 1 </code></pre> <p>What I get with <code>-O</code> is instead:</p> <pre><code>Insert two integers: 1 4 1 0 0 </code></pre> <p>You can <a href="http://cpp.sh/3htz">try it online here</a>; the numbers may vary but they're always "wrong" when optimizing the binary.</p> <hr> <p>What I've tried:</p> <ul> <li>hardcoding the input integers is enough to produce the same result;</li> <li>the issue persists with <em>gcc 5.4.0</em> and <em>clang 3.8.0</em>, also when using <em>libc++</em>;</li> <li>making all the objects <code>const</code> (i.e. returning <code>const int &amp;</code>, and declaring all variables as such) doesn't fix it;</li> <li>using the <code>reverse_iterator</code> in the same way on for example some <code>std::vector&lt;int&gt;</code> works fine;</li> <li>if I just use <code>AsIterator&lt;int&gt;</code> for a normal forward or backward loop it works fine.</li> <li>in my tests, the constant <code>0</code> that is printed is actually <em>hardcoded</em> by the compiler, the calls to <code>printf</code> all look like this when compiled with <code>-S -O</code>:</li> </ul> <pre><code> movl $.L.str.2, %edi # .L.str.2 is "%d\n" xorl %eax, %eax callq printf </code></pre> <p>Given the consistency of <em>clang</em> and <em>gcc</em>'s behavior here I am pretty sure they're doing it right and I misunderstood, but I really can't see it.</p>
0debug
How to fix 'Uncaught ReferenceError: $ is not defined' : <p>This is for a navigation header and it works, but I still get an error on line 2. VM4582 header.js:2 Uncaught ReferenceError: $ is not defined I don't understand why it says $(window) is not defined.</p> <pre><code>// Sticky Header $(window).scroll(function() { if ($(window).scrollTop() &gt; 100) { $('.main_h').addClass('sticky'); } else { $('.main_h').removeClass('sticky'); } }); // Mobile Navigation $('.mobile-toggle').click(function() { if ($('.main_h').hasClass('open-nav')) { $('.main_h').removeClass('open-nav'); } else { $('.main_h').addClass('open-nav'); } }); $('.main_h li a').click(function() { if ($('.main_h').hasClass('open-nav')) { $('.navigation').removeClass('open-nav'); $('.main_h').removeClass('open-nav'); } }); // navigation scroll lijepo radi materem $('nav a').click(function(event) { var id = $(this).attr("href"); var offset = 70; var target = $(id).offset().top - offset; $('html, body').animate({ scrollTop: target }, 500); event.preventDefault(); }); </code></pre>
0debug
loop through arguments, setting as object properties : <p>I have defined a class which uses a constructor that's meant to allow any number of a set of properties be attributed:</p> <pre><code>class CalendarEvent: """Represents a macOS calendar event.""" def __init__(self, **keyword_arguments): self.__allowed_properties = ["starts", "ends", "repeat", "end_repeat", "travel_time", "alert", "notes", "invitees"] for key, value in keyword_arguments: if key in self.__allowed_properties: setattr(self, key, value) </code></pre> <p>When I try to create a <code>CalendarEvent</code> though,</p> <pre><code>party_tomorrow = CalendarEvent( starts = datetime.datetime.today() + datetime.timedelta(days = 1), ends = datetime.datetime.today() + datetime.timedelta(days = 1, hours = 5), repeat = None, end_repeat = None, travel_time = datetime.timedelta(hours = 1), alert = None, notes = "This is gonna be a load of fun.", invitees = None ) </code></pre> <p>I get the error:</p> <pre><code>Traceback (most recent call last): File "/Users/George/Library/FlashlightPlugins/calendarquery.bundle/plugin.py", line 62, in test_CalendarEvent invitees = None File "/Users/George/Library/FlashlightPlugins/calendarquery.bundle/plugin.py", line 12, in __init__ for key, value in keyword_arguments: ValueError: too many values to unpack (expected 2) </code></pre>
0debug
Prevent program from getting terminated after exception handling : <p>Is there anyway to handle the exceptions in Java and prevent the program from getting terminated? For instance when the user enters an invalid number into a calculator, zero in this example for division in the denominator, I don't want the program to get terminated and show the handled exception message. I want the program to continue and ask for another input.<br/> Could anyone clarify it with a practical example for me?</p>
0debug
Sample program for GDbus signals : <p>I am new to GDbus programming. I need to implement a simple Dbus send-receive message (Signals) using Dbus Glib. I tried to google some sample programs, but couldn't find.</p> <p>Can anyone post any such sample program or point me to some sample program tutorial?</p> <p>Thanks in advance...</p> <p>Thanks, SB</p>
0debug
With binomial prediction where the output is either 1 or 0 the h2o based randomforest predict model build on java pojo always returns 1. : With binomial prediction where the output is either 1 or 0 the h2o based randomforest predict model build on java pojo always returns 1?
0debug
doing many to many join in oracle : I have these tables in oracle TABLE A ID GROUP NUMBER1 1 CAT1 0.4 2 CAT2 0.5 TABLE B ID VALUE1 VALUE2 1 5 9 1 6 10 2 7 11 2 8 12 TABLE C ID NUM1 NUM2 1 13 17 1 14 18 2 15 19 2 16 20 How can I join all 3 tables so that I get out put that looks like this ID GRUP NUMBER1 VALUE1 VALUE2 NUM1 NUM2 1 CAT1 0.4 5 9 13 17 1 CAT1 0.4 6 10 14 18 2 CAT2 0.5 7 11 15 19 2 CAT2 0.5 8 12 16 20 currently I do select group, number1, value1, value2, num2, num2 from tablea a inner join tableb b inner join a.id = b.id inner join tablec inner join c.id = a.id and i am getting many duplicate rows
0debug
What is the best approach database structure for teacher, students and address table? : <p>I have the following tables in my database</p> <ul> <li>students</li> <li>teachers </li> <li>address</li> </ul> <p>I Want to store basic information about students and teacher in its own table, but the address and contact information in address table. If I store the <code>student_id</code> or <code>teacher_id</code> in address table, the student might have same <code>id</code> as any teacher. If I try to query any teacher address by <code>teacher_id</code>. It will query the student who has the same <code>id</code> as well. </p> <p>So what the best way to figure out this problem? should I create any other table as well or .... </p> <p>Please suggest me an easiest and best approach.</p> <p>thanks.</p>
0debug
a document (a buffer of ASCII bytes) which has the CRC32 hash (the gzip variant of CRC32), of 0xbbd1264f : <p>so i had a homework to get a document (a buffer of ASCII bytes) which has the CRC32 hash (the gzip variant of CRC32), of 0xbbd1264f and unti now i don't know how to get it so if someone know how to do that please answer</p>
0debug
WampServer - mysqld.exe can't start because MSVCR120.dll is missing : <p>I've tried to run wampserver on my local side, but mysql server doesn't run. when I try to <strong>install service</strong>, it give me error. I searched the answer all day and found some answers on here and there.</p> <p>but any solution doesn't work for me. I tried to install warpserver on windows7 home OS vmware</p> <p>Any help for me?</p>
0debug
variable in C# SQL Query not working : So I have a loop in which I grab certain ID's to make a call in a database. There are 2 variable within the query. The first one works fine but the second one returns nothing. I have tested it a lot and know that the correct value is coming through to the query. Not sure what I am doing wrong here. I replace the variable with a hard coded value that I know is returning and it works fine. Here is my code: SqlDataAdapter d8; d8 = new SqlDataAdapter("select SUM(CAST(AMOUNT AS BIGINT)) AS NEW_AMOUNT FROM ddb_proc_log_base where ( PROVID = "+docId+" AND CHART_STATUS = 90 AND YEAR(PLDATE) = 2016 AND CLASS = 2 AND ORD = " + defer + ") OR (ORD = " + defer + " AND PROVID = " + this.getDocHygDS.Tables[0].Rows[t]["HYG_ID"] + " AND CHART_STATUS = 90 AND YEAR(PLDATE) = 2016 AND CLASS = 2)", conn3); cmdBuilder5 = new SqlCommandBuilder(d8); d8.Fill(this.balances);
0debug
How to delete or replace ´ in JavaScript? : <p>I get this string</p> <pre><code>var cadena = "I´m from Mexico" </code></pre> <p>And need replace or delete ´ </p> <pre><code>var cadena = "Im from Mexico " </code></pre>
0debug
Is there a comprehensive list of all Linq Statements? : <p>I would like to have a list of all Linq Staments (Methods and Queryies) I have googled for a while but with no results. So is there a list with all LinQ statements somewhere? It doesn't even need explanations, just all the features listed.</p>
0debug
int target_to_host_signal(int sig) { if (sig >= _NSIG) return sig; return target_to_host_signal_table[sig]; }
1threat
void MPV_common_init_altivec(MpegEncContext *s) { if (s->avctx->lowres==0) { if ((s->avctx->idct_algo == FF_IDCT_AUTO) || (s->avctx->idct_algo == FF_IDCT_ALTIVEC)) { s->dsp.idct_put = idct_put_altivec; s->dsp.idct_add = idct_add_altivec; s->dsp.idct_permutation_type = FF_TRANSPOSE_IDCT_PERM; } } if ((((long)(s->q_intra_matrix) & 0x0f) != 0) || (((long)(s->q_inter_matrix) & 0x0f) != 0)) { av_log(s->avctx, AV_LOG_INFO, "Internal Error: q-matrix blocks must be 16-byte aligned " "to use AltiVec DCT. Reverting to non-AltiVec version.\n"); return; } if (((long)(s->intra_scantable.inverse) & 0x0f) != 0) { av_log(s->avctx, AV_LOG_INFO, "Internal Error: scan table blocks must be 16-byte aligned " "to use AltiVec DCT. Reverting to non-AltiVec version.\n"); return; } if ((s->avctx->dct_algo == FF_DCT_AUTO) || (s->avctx->dct_algo == FF_DCT_ALTIVEC)) { #if 0 s->dct_quantize = dct_quantize_altivec; #endif s->dct_unquantize_h263_intra = dct_unquantize_h263_altivec; s->dct_unquantize_h263_inter = dct_unquantize_h263_altivec; } }
1threat
How to pull with rebase by default in IntelliJ Idea? : <p>By company policy, all pulls unless agreed with tech lead must be done with rebase rather than merge.</p> <p>I use Eclipse and successfully set the default pull mode to rebase to all my branches (despite Eclipse suggests merge as default mode).</p> <p>My deskmate, working on my same project, uses IntelliJ Idea. Guess what? He always forgets to check pull-with-rebase when pulling, ending up in endless merge commits.</p> <p>I often have to complain with him for violating the rule I took so long to make a standard, then I need to do force pushing to fix the tree from the mess. Only 2 people here use IntelliJ, other use Eclipse and have no problems with Git.</p> <p>How do I set the default pull mode in IntelliJ Idea?</p>
0debug
Global and Ambient Dependencies - typings : <p>I am really confused between the ambient and global dependencies. I understood the concept of global dependencies, which means that installing the dependencies globally. But coming to ambient dependencies, I did not understand what it is and now typings recently declared that <a href="https://www.npmjs.com/package/typings">ambient is now global</a>. I am completely lost.</p> <p>Can someone please help me clear this confusion.</p>
0debug
static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl) { const int mb_x = h->mb_x; const int mb_y = h->mb_y; const int mb_xy = h->mb_xy; const int mb_type = h->cur_pic.mb_type[mb_xy]; uint8_t *dest_y, *dest_cb, *dest_cr; int linesize, uvlinesize ; int i, j; int *block_offset = &h->block_offset[0]; const int transform_bypass = !SIMPLE && (sl->qscale == 0 && h->sps.transform_bypass); const int is_h264 = !CONFIG_SVQ3_DECODER || SIMPLE || h->avctx->codec_id == AV_CODEC_ID_H264; void (*idct_add)(uint8_t *dst, int16_t *block, int stride); const int block_h = 16 >> h->chroma_y_shift; const int chroma422 = CHROMA422(h); dest_y = h->cur_pic.f.data[0] + ((mb_x << PIXEL_SHIFT) + mb_y * h->linesize) * 16; dest_cb = h->cur_pic.f.data[1] + (mb_x << PIXEL_SHIFT) * 8 + mb_y * h->uvlinesize * block_h; dest_cr = h->cur_pic.f.data[2] + (mb_x << PIXEL_SHIFT) * 8 + mb_y * h->uvlinesize * block_h; h->vdsp.prefetch(dest_y + (h->mb_x & 3) * 4 * h->linesize + (64 << PIXEL_SHIFT), h->linesize, 4); h->vdsp.prefetch(dest_cb + (h->mb_x & 7) * h->uvlinesize + (64 << PIXEL_SHIFT), dest_cr - dest_cb, 2); h->list_counts[mb_xy] = sl->list_count; if (!SIMPLE && MB_FIELD(h)) { linesize = sl->mb_linesize = h->linesize * 2; uvlinesize = sl->mb_uvlinesize = h->uvlinesize * 2; block_offset = &h->block_offset[48]; if (mb_y & 1) { dest_y -= h->linesize * 15; dest_cb -= h->uvlinesize * (block_h - 1); dest_cr -= h->uvlinesize * (block_h - 1); } if (FRAME_MBAFF(h)) { int list; for (list = 0; list < sl->list_count; list++) { if (!USES_LIST(mb_type, list)) continue; if (IS_16X16(mb_type)) { int8_t *ref = &sl->ref_cache[list][scan8[0]]; fill_rectangle(ref, 4, 4, 8, (16 + *ref) ^ (h->mb_y & 1), 1); } else { for (i = 0; i < 16; i += 4) { int ref = sl->ref_cache[list][scan8[i]]; if (ref >= 0) fill_rectangle(&sl->ref_cache[list][scan8[i]], 2, 2, 8, (16 + ref) ^ (h->mb_y & 1), 1); } } } } } else { linesize = sl->mb_linesize = h->linesize; uvlinesize = sl->mb_uvlinesize = h->uvlinesize; } if (!SIMPLE && IS_INTRA_PCM(mb_type)) { if (PIXEL_SHIFT) { const int bit_depth = h->sps.bit_depth_luma; int j; GetBitContext gb; init_get_bits(&gb, sl->intra_pcm_ptr, ff_h264_mb_sizes[h->sps.chroma_format_idc] * bit_depth); for (i = 0; i < 16; i++) { uint16_t *tmp_y = (uint16_t *)(dest_y + i * linesize); for (j = 0; j < 16; j++) tmp_y[j] = get_bits(&gb, bit_depth); } if (SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { if (!h->sps.chroma_format_idc) { for (i = 0; i < block_h; i++) { uint16_t *tmp_cb = (uint16_t *)(dest_cb + i * uvlinesize); for (j = 0; j < 8; j++) tmp_cb[j] = 1 << (bit_depth - 1); } for (i = 0; i < block_h; i++) { uint16_t *tmp_cr = (uint16_t *)(dest_cr + i * uvlinesize); for (j = 0; j < 8; j++) tmp_cr[j] = 1 << (bit_depth - 1); } } else { for (i = 0; i < block_h; i++) { uint16_t *tmp_cb = (uint16_t *)(dest_cb + i * uvlinesize); for (j = 0; j < 8; j++) tmp_cb[j] = get_bits(&gb, bit_depth); } for (i = 0; i < block_h; i++) { uint16_t *tmp_cr = (uint16_t *)(dest_cr + i * uvlinesize); for (j = 0; j < 8; j++) tmp_cr[j] = get_bits(&gb, bit_depth); } } } } else { for (i = 0; i < 16; i++) memcpy(dest_y + i * linesize, sl->intra_pcm_ptr + i * 16, 16); if (SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { if (!h->sps.chroma_format_idc) { for (i = 0; i < block_h; i++) { memset(dest_cb + i * uvlinesize, 128, 8); memset(dest_cr + i * uvlinesize, 128, 8); } } else { const uint8_t *src_cb = sl->intra_pcm_ptr + 256; const uint8_t *src_cr = sl->intra_pcm_ptr + 256 + block_h * 8; for (i = 0; i < block_h; i++) { memcpy(dest_cb + i * uvlinesize, src_cb + i * 8, 8); memcpy(dest_cr + i * uvlinesize, src_cr + i * 8, 8); } } } } } else { if (IS_INTRA(mb_type)) { if (h->deblocking_filter) xchg_mb_border(h, sl, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 1, 0, SIMPLE, PIXEL_SHIFT); if (SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { h->hpc.pred8x8[sl->chroma_pred_mode](dest_cb, uvlinesize); h->hpc.pred8x8[sl->chroma_pred_mode](dest_cr, uvlinesize); } hl_decode_mb_predict_luma(h, sl, mb_type, is_h264, SIMPLE, transform_bypass, PIXEL_SHIFT, block_offset, linesize, dest_y, 0); if (h->deblocking_filter) xchg_mb_border(h, sl, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 0, 0, SIMPLE, PIXEL_SHIFT); } else if (is_h264) { if (chroma422) { FUNC(hl_motion_422)(h, sl, dest_y, dest_cb, dest_cr, h->qpel_put, h->h264chroma.put_h264_chroma_pixels_tab, h->qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab, h->h264dsp.weight_h264_pixels_tab, h->h264dsp.biweight_h264_pixels_tab); } else { FUNC(hl_motion_420)(h, sl, dest_y, dest_cb, dest_cr, h->qpel_put, h->h264chroma.put_h264_chroma_pixels_tab, h->qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab, h->h264dsp.weight_h264_pixels_tab, h->h264dsp.biweight_h264_pixels_tab); } } hl_decode_mb_idct_luma(h, sl, mb_type, is_h264, SIMPLE, transform_bypass, PIXEL_SHIFT, block_offset, linesize, dest_y, 0); if ((SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) && (sl->cbp & 0x30)) { uint8_t *dest[2] = { dest_cb, dest_cr }; if (transform_bypass) { if (IS_INTRA(mb_type) && h->sps.profile_idc == 244 && (sl->chroma_pred_mode == VERT_PRED8x8 || sl->chroma_pred_mode == HOR_PRED8x8)) { h->hpc.pred8x8_add[sl->chroma_pred_mode](dest[0], block_offset + 16, sl->mb + (16 * 16 * 1 << PIXEL_SHIFT), uvlinesize); h->hpc.pred8x8_add[sl->chroma_pred_mode](dest[1], block_offset + 32, sl->mb + (16 * 16 * 2 << PIXEL_SHIFT), uvlinesize); } else { idct_add = h->h264dsp.h264_add_pixels4_clear; for (j = 1; j < 3; j++) { for (i = j * 16; i < j * 16 + 4; i++) if (sl->non_zero_count_cache[scan8[i]] || dctcoef_get(sl->mb, PIXEL_SHIFT, i * 16)) idct_add(dest[j - 1] + block_offset[i], sl->mb + (i * 16 << PIXEL_SHIFT), uvlinesize); if (chroma422) { for (i = j * 16 + 4; i < j * 16 + 8; i++) if (sl->non_zero_count_cache[scan8[i + 4]] || dctcoef_get(sl->mb, PIXEL_SHIFT, i * 16)) idct_add(dest[j - 1] + block_offset[i + 4], sl->mb + (i * 16 << PIXEL_SHIFT), uvlinesize); } } } } else { if (is_h264) { int qp[2]; if (chroma422) { qp[0] = sl->chroma_qp[0] + 3; qp[1] = sl->chroma_qp[1] + 3; } else { qp[0] = sl->chroma_qp[0]; qp[1] = sl->chroma_qp[1]; } if (sl->non_zero_count_cache[scan8[CHROMA_DC_BLOCK_INDEX + 0]]) h->h264dsp.h264_chroma_dc_dequant_idct(sl->mb + (16 * 16 * 1 << PIXEL_SHIFT), h->dequant4_coeff[IS_INTRA(mb_type) ? 1 : 4][qp[0]][0]); if (sl->non_zero_count_cache[scan8[CHROMA_DC_BLOCK_INDEX + 1]]) h->h264dsp.h264_chroma_dc_dequant_idct(sl->mb + (16 * 16 * 2 << PIXEL_SHIFT), h->dequant4_coeff[IS_INTRA(mb_type) ? 2 : 5][qp[1]][0]); h->h264dsp.h264_idct_add8(dest, block_offset, sl->mb, uvlinesize, sl->non_zero_count_cache); } else if (CONFIG_SVQ3_DECODER) { h->h264dsp.h264_chroma_dc_dequant_idct(sl->mb + 16 * 16 * 1, h->dequant4_coeff[IS_INTRA(mb_type) ? 1 : 4][sl->chroma_qp[0]][0]); h->h264dsp.h264_chroma_dc_dequant_idct(sl->mb + 16 * 16 * 2, h->dequant4_coeff[IS_INTRA(mb_type) ? 2 : 5][sl->chroma_qp[1]][0]); for (j = 1; j < 3; j++) { for (i = j * 16; i < j * 16 + 4; i++) if (sl->non_zero_count_cache[scan8[i]] || sl->mb[i * 16]) { uint8_t *const ptr = dest[j - 1] + block_offset[i]; ff_svq3_add_idct_c(ptr, sl->mb + i * 16, uvlinesize, ff_h264_chroma_qp[0][sl->qscale + 12] - 12, 2); } } } } } } }
1threat
static int proxy_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat *stbuf) { int retval; retval = v9fs_request(fs_ctx->private, T_LSTAT, stbuf, "s", fs_path); if (retval < 0) { errno = -retval; return -1; } return retval; }
1threat
difference between 'global varName' and 'self.varName' in python : <p>what is the use of writing 'global varName' in the body of constructor ? I mean we can achive the same goal by writting 'self.varName' ? For Example</p> <pre><code>class Mine_Global: def __init__(self): global varName varName = 3 self.newInsVar = 7 if __name__ == "__main__": global varName obj1 = Mine_Global() print varName, obj1.newInsVar; varName = varName + 2 print varName, obj1.newInsVar; obj2 = Mine_Global() print varName, obj2.newInsVar </code></pre>
0debug
static void iothread_complete(UserCreatable *obj, Error **errp) { IOThread *iothread = IOTHREAD(obj); iothread->stopping = false; iothread->ctx = aio_context_new(); iothread->thread_id = -1; qemu_mutex_init(&iothread->init_done_lock); qemu_cond_init(&iothread->init_done_cond); qemu_thread_create(&iothread->thread, "iothread", iothread_run, iothread, QEMU_THREAD_JOINABLE); qemu_mutex_lock(&iothread->init_done_lock); while (iothread->thread_id == -1) { qemu_cond_wait(&iothread->init_done_cond, &iothread->init_done_lock); } qemu_mutex_unlock(&iothread->init_done_lock); }
1threat
Cordova / Ionic build android Gradle error: Minimum supported Gradle version is 2.14.1. Current version is 2.13 : <p>This is a solution to the above error that I want to document. I found other similar posts, but none described how this error can be associated with Cordova or Ionic.</p> <p>If you are not careful, there can be a mismatch between the version of Gradle that Android Studio uses and the version of Gradle that Cordova / cordova-android specifies in its auto-generated application code. As you know, running</p> <pre><code>$ cordova platform add android </code></pre> <p>(or <code>$ ionic platform add android</code>, if you are building an Ionic app) creates the native application code at the-project/platforms/android. </p> <p>Inside that folder, the file: /the-project/platforms/android/cordova/lib/builders/GradleBuilder.js exports a variable as shown below:</p> <pre><code>var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'http\\://services.gradle.org/distributions/gradle-x.y-all.zip'; </code></pre> <p>Where x and y depened on which version of Cordova / cordova-android are being used to build the native application code. </p> <p>When you run</p> <pre><code>$ cordova build android </code></pre> <p>The version of Gradle specified in the <code>distributionUrl</code> var is the version used for the build.</p> <p>Now here comes the tricky part. When you import the project into Android Studio, you will most likely get a message strongly recommending that you upgrade Gradle to a newer version, as shown below: </p> <p><a href="https://i.stack.imgur.com/N1ytd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/N1ytd.png" alt="enter image description here"></a> If you do this, Android Studio will download a new version of Gradle and store it locally and configure the project to use the newly download local Gradle distribution, which is the radio option below the selected “Use default grade wrapper”, which I ended up deselecting because this will cause errors.</p> <p><a href="https://i.stack.imgur.com/geQN9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/geQN9.png" alt="enter image description here"></a> </p> <p>This will cause problems because Android Studio and Cordova will now be attempting to build the application with different versions of Gradle and you will get build errors within Android Studio and also with </p> <pre><code>$ cordova build android </code></pre> <p>in the command line. The solution with Cordova apps is to always keep the Android Studio project set to "Use default gradle wrapper" and ignore the tempting messages to upgrade. If you do want to use a newer version of Gradle, you can always change the distributionUrl var in the file mentioned above (however Cordova strongly discourages modifying code within the platforms folder since it is easily overwritten). At the time of writing this, I cannot tell is there is a way to set the Gradle version at the </p> <pre><code>$ cordova platform add android </code></pre> <p>step, which is when you would want to do it so you are never directly modifiying code inside of the-project/platforms</p>
0debug
confused with babel preset configs between @babel/env and @babel/preset-env : <p>I try to config a environment to develop javascript with babel and webpack.</p> <p>But I don't understand babel configuration about <code>presets</code>.</p> <p>In <a href="https://babeljs.io/docs/en/usage" rel="noreferrer">Usage Guide</a>, we can see that presets with <code>"@babel/env"</code>.</p> <p>But other places in document, I cannot see such a configuration more, instead of <code>"@babel/preset-env"</code>. for example here <a href="https://babeljs.io/docs/en/babel-preset-env" rel="noreferrer">https://babeljs.io/docs/en/babel-preset-env</a></p> <p>I can not find out the difference between <code>"@babel/env"</code> and <code>"@babel/preset-env"</code> everywhere with my poor English, I do really read document again and again, without luck.</p> <p>Maybe they are same?</p> <p>Btw, targets sets seems not work, remove targets also can run normally in ie9+(or what's it default targets), if I wish my es6 script can be transformed to compatibility ie8, thus it not most important.</p> <p>here is my project <a href="https://github.com/whidy/sdk-dev-env/tree/for-es6-without-babel/polyfill" rel="noreferrer">sdk-dev-env</a></p> <pre><code>// https://babeljs.io/docs/en/configuration const presets = [ [ '@babel/env', { // https://babeljs.io/docs/en/babel-preset-env#targets // TODO: how to compatibilite with ie 8 targets: { ie: '8', edge: '17', firefox: '60', chrome: '67', safari: '11.1' /** * you can also set browsers in package.json * "browserslist": ["last 3 versions"] * relative links: * https://github.com/browserslist/browserslist */ }, corejs: '3', // corejs: { version: 3, proposals: true }, /** * https://babeljs.io/docs/en/usage#polyfill * https://github.com/zloirock/core-js#babelpreset-env * "usage" will practically apply the last optimization mentioned above where you only include the polyfills you need */ useBuiltIns: 'usage' } ] ] const plugins = [] if (process.env['ENV'] === 'prod') { // plugins.push(...); } module.exports = { presets, plugins } </code></pre> <p>I hope to know they are same or not, if not, what different.</p> <p>And the best way to use babeljs 7.4 with core-js 3</p>
0debug
Dart MD5 From String : <p>How to generate md5 hash from string?</p> <pre><code>import 'package:crypto/crypto.dart' as crypto; ///Generate MD5 hash generateMd5(String data) { var content = UTF8.encode(data); var md5 = crypto.md5; } </code></pre> <p>I have no idea what next to do</p>
0debug
static int bdrv_check_request(BlockDriverState *bs, int64_t sector_num, int nb_sectors) { return bdrv_check_byte_request(bs, sector_num * BDRV_SECTOR_SIZE, nb_sectors * BDRV_SECTOR_SIZE);
1threat
Why won't my C code compile? : <p>I'm running "gcc foo.c"</p> <p>foo.c:</p> <pre><code>#include "foo.h" FILE* foo(char* fileName) { ... } </code></pre> <p>foo.h:</p> <pre><code>#ifndef FOO_H #def FOO_H #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; FILE* foo(char* fileName); #endif </code></pre> <p>The error is:</p> <pre><code>foo.c:5:1: error: expected '=', ',', ';', 'asm', or '__attribute__' before '{' token { </code></pre> <p>Baffled here. Is there something wrong in the way I'm using headers? I've pored over this code for a while and can't find anything. Could it be a bad gcc statement in the command line?</p>
0debug
static int protocol_client_vencrypt_init(VncState *vs, uint8_t *data, size_t len) { if (data[0] != 0 || data[1] != 2) { VNC_DEBUG("Unsupported VeNCrypt protocol %d.%d\n", (int)data[0], (int)data[1]); vnc_write_u8(vs, 1); vnc_flush(vs); vnc_client_error(vs); } else { VNC_DEBUG("Sending allowed auth %d\n", vs->vd->subauth); vnc_write_u8(vs, 0); vnc_write_u8(vs, 1); vnc_write_u32(vs, vs->vd->subauth); vnc_flush(vs); vnc_read_when(vs, protocol_client_vencrypt_auth, 4); } return 0; }
1threat
asp.net web form client with identity server 4 : <p>I have a asp.net solution which consists of</p> <pre><code>1). asp.net identity server rc 3 2). asp.net Core web api 3). asp.net webform ( not in asp.net core, client) </code></pre> <p>I don't see any sample with identity server 4 and web form client. Can you please suggest how to authenticate web form user using identity server with asp.net identity and then call api with the access token ?</p> <p>I don't see identity server 4 sample with <a href="https://github.com/IdentityServer/IdentityServer4.Samples/tree/dev/Clients/src" rel="noreferrer">web form client</a> or <a href="https://github.com/IdentityServer/IdentityServer4.Samples/tree/dev/Quickstarts" rel="noreferrer">sample</a> </p> <p>identity server 3 has a <a href="https://github.com/IdentityServer/IdentityServer3.Samples/tree/master/source/Clients/WebFormsClient" rel="noreferrer">sample</a> but it is doing everything in <a href="https://github.com/IdentityServer/IdentityServer3.Samples/blob/master/source/Clients/WebFormsClient/Startup.cs" rel="noreferrer">startup</a> </p> <p>When i see <a href="https://github.com/IdentityServer/IdentityServer4.Samples/blob/dev/Quickstarts/6_AspNetIdentity/src/MvcClient/Startup.cs" rel="noreferrer">mvc client</a> for identity server 4, it has all settings in configure method and then calls it like <a href="https://github.com/IdentityServer/IdentityServer4.Samples/blob/dev/Quickstarts/6_AspNetIdentity/src/MvcClient/Controllers/HomeController.cs" rel="noreferrer">this</a></p> <p>How will i apply Authorize attribute in webform so that i am redirected to identity server 4 for login and then after login when i call api like this:</p> <p>how to change client for webform ?</p> <pre><code> new Client() { ClientId = "mvcClient", ClientName = "MVC Client", AllowedGrantTypes = GrantTypes.HybridAndClientCredentials, ClientSecrets = new List&lt;Secret&gt;() { new Secret("secret".Sha256()) }, RequireConsent = false; // where to redirect to after login RedirectUris = { "http://localhost:5002/signin-oidc" }, // where to redirect to after logout PostLogoutRedirectUris = { "http://localhost:5002" }, AllowedScopes = { StandardScopes.OpenId.Name, StandardScopes.Profile.Name, StandardScopes.OfflineAccess.Name, StandardScopes.Roles.Name, "API" } } new InMemoryUser() { Subject = "1", Username = "testuser", Password = "password", Claims = new List&lt;Claim&gt;() { new Claim("name", "Alice"), new Claim("Website", "http://alice.com"), new Claim(JwtClaimTypes.Role, "admin") } } return new List&lt;Scope&gt;() { StandardScopes.OpenId, // subject id StandardScopes.Profile, // first name, last name StandardScopes.OfflineAccess, StandardScopes.Roles, new Scope() { Name = "API", Description = "API desc", Type = ScopeType.Resource, Emphasize = true, IncludeAllClaimsForUser = true, Claims = new List&lt;ScopeClaim&gt; { new ScopeClaim(ClaimTypes.Name), new ScopeClaim(ClaimTypes.Role) } } }; public void CallApiUsingClientCredentials() { var tokenClient = new TokenClient("http://localhost:5000/connect/token", "mvc", "secret"); var tokenResponse = await tokenClient.RequestClientCredentialsAsync("api1"); var client = new HttpClient(); client.SetBearerToken(tokenResponse.AccessToken); var content = await client.GetStringAsync("http://localhost:5001/identity"); var result = JArray.Parse(content).ToString(); } [Authorize(Roles="admin)] [HttpGet] public IActionResult Get() { return new JsonResult(from c in User.Claims select new { c.Type, c.Value }); } </code></pre>
0debug
static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) { AVFilterContext *ctx = inlink->dst; AVFilterLink *outlink = ctx->outputs[0]; ShowCQTContext *s = ctx->priv; int remaining, step, ret, x, i, j, m; float *audio_data; AVFrame *out = NULL; if (!insamples) { while (s->remaining_fill < s->fft_len / 2) { memset(&s->fft_data[s->fft_len - s->remaining_fill], 0, sizeof(*s->fft_data) * s->remaining_fill); ret = plot_cqt(ctx, &out); if (ret < 0) return ret; step = s->step + (s->step_frac.num + s->remaining_frac) / s->step_frac.den; s->remaining_frac = (s->step_frac.num + s->remaining_frac) % s->step_frac.den; for (x = 0; x < (s->fft_len-step); x++) s->fft_data[x] = s->fft_data[x+step]; s->remaining_fill += step; if (out) return ff_filter_frame(outlink, out); } return AVERROR_EOF; } remaining = insamples->nb_samples; audio_data = (float*) insamples->data[0]; while (remaining) { i = insamples->nb_samples - remaining; j = s->fft_len - s->remaining_fill; if (remaining >= s->remaining_fill) { for (m = 0; m < s->remaining_fill; m++) { s->fft_data[j+m].re = audio_data[2*(i+m)]; s->fft_data[j+m].im = audio_data[2*(i+m)+1]; } ret = plot_cqt(ctx, &out); if (ret < 0) { av_frame_free(&insamples); return ret; } remaining -= s->remaining_fill; if (out) { int64_t pts = av_rescale_q(insamples->pts, inlink->time_base, av_make_q(1, inlink->sample_rate)); pts += insamples->nb_samples - remaining - s->fft_len/2; pts = av_rescale_q(pts, av_make_q(1, inlink->sample_rate), outlink->time_base); if (FFABS(pts - out->pts) > PTS_TOLERANCE) { av_log(ctx, AV_LOG_DEBUG, "changing pts from %"PRId64" (%.3f) to %"PRId64" (%.3f).\n", out->pts, out->pts * av_q2d(outlink->time_base), pts, pts * av_q2d(outlink->time_base)); out->pts = pts; s->next_pts = pts + PTS_STEP; } ret = ff_filter_frame(outlink, out); if (ret < 0) { av_frame_free(&insamples); return ret; } out = NULL; } step = s->step + (s->step_frac.num + s->remaining_frac) / s->step_frac.den; s->remaining_frac = (s->step_frac.num + s->remaining_frac) % s->step_frac.den; for (m = 0; m < s->fft_len-step; m++) s->fft_data[m] = s->fft_data[m+step]; s->remaining_fill = step; } else { for (m = 0; m < remaining; m++) { s->fft_data[j+m].re = audio_data[2*(i+m)]; s->fft_data[j+m].im = audio_data[2*(i+m)+1]; } s->remaining_fill -= remaining; remaining = 0; } } av_frame_free(&insamples); return 0; }
1threat
Having some problems : so I have some problems with my dictionaries in python. For example I have dictionary d1 = {123456:xyz, 892019:kjl, 102930491:{[plm,kop]} d2= {xyz:987, kjl: 0902, plm: 019240, kop:09829} And I would like to have nested dictionary that looks something like that. d={123456 :{xyz:987}, 892019:{kjl:0902}, 102930491:{plm:019240,kop:09829}} is this possible? I was searching for nested dictionaries but nothing works for me.
0debug
How to use new c# 8.0 features in Razor views : <p>I've updated my ASP.NET Mvc 5 web application to use the new c# 8.0 features through Visual Studio 2019 and everything works fine until I try to use these new features inside a Razor view.</p> <p>For example, if I try to use the new switch expression:</p> <pre class="lang-cs prettyprint-override"><code>@{ ViewBag.Title = "About"; var foo = 1; var bar = foo switch { 1 =&gt; "one", 2 =&gt; "two", _ =&gt; string.Empty }; } &lt;h2&gt;@ViewBag.Title.&lt;/h2&gt; &lt;h3&gt;@ViewBag.Message&lt;/h3&gt; &lt;p&gt;Use this area to provide additional information.&lt;/p&gt; </code></pre> <p>The compiler won't complain until I try to reach the page, giving me a compilation error.</p> <p><a href="https://i.stack.imgur.com/SDb21.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SDb21.png" alt="Compilation error"></a></p> <p>I suspect that <code>Microsoft.CodeDom.Providers.DotNetCompilerPlatform</code> must be updated but it seems that there is no update available.</p> <p>Is there any way to use c# 8.0 language features in Razor views?</p>
0debug
void qpci_device_foreach(QPCIBus *bus, int vendor_id, int device_id, void (*func)(QPCIDevice *dev, int devfn, void *data), void *data) { int slot; for (slot = 0; slot < 32; slot++) { int fn; for (fn = 0; fn < 8; fn++) { QPCIDevice *dev; dev = qpci_device_find(bus, QPCI_DEVFN(slot, fn)); if (!dev) { continue; } if (vendor_id != -1 && qpci_config_readw(dev, PCI_VENDOR_ID) != vendor_id) { continue; } if (device_id != -1 && qpci_config_readw(dev, PCI_DEVICE_ID) != device_id) { continue; } func(dev, QPCI_DEVFN(slot, fn), data); } } }
1threat
the receiving end does not support push options : <p>At first my server's git version was 2.7.4 and the error was accurate. Afterwards, however, I updated and have confirmed this with git version:</p> <p>Server</p> <pre><code>$ git --version git version 2.13.0 </code></pre> <p>Client</p> <pre><code>$ git --version git version 2.11.0 (Apple Git-81) </code></pre> <p>Yet when I try to push this happens:</p> <pre><code>$ git push --push-option=test fatal: the receiving end does not support push options fatal: The remote end hung up unexpectedly </code></pre> <p>Even though according to documentation this should be supported in both the client version and server version:<br> <a href="https://git-scm.com/docs/git-push/2.11.0#git-push--o" rel="noreferrer">2.11.0</a><br> <a href="https://git-scm.com/docs/git-push/2.13.0#git-push--o" rel="noreferrer">2.13.0</a></p> <p>I even created two new local repositories on each and then tried to push to the other local repository from the other (so it isn't even communicating between a different server) yet I still get that error. Is there something I have to enable? I can't find anything about having to do that on the docs.</p>
0debug
static void set_next_tick(rc4030State *s) { qemu_irq_lower(s->timer_irq); uint32_t hz; hz = 1000 / (s->itr + 1); qemu_mod_timer(s->periodic_timer, qemu_get_clock(vm_clock) + ticks_per_sec / hz); }
1threat
ubuntu-16.10 unable to locate package : <p>I have recently setup Ubuntu 16.10 and am trying to install PuTTY but keep getting an 'E: Unable to locate package putty' error. I have run both 'sudo apt-get update' and 'sudo apt-get upgrade'. Both complete with success. I have verified that 'main', 'universe', 'restricted', and 'multiverse' are all enabled. But I continue to get the error when trying to install PuTTY. This is the command I'm using 'sudo apt install putty'. Any thoughts on what might be going on?</p>
0debug
C++ Random doubles from -1 to 1 : <p>I need to randomly generate numbers (using random()) from -1 to 1 that are doubles. For example the output would be something like:</p> <p>1, -0.3324, 0.7821, 0.9823, -0.111</p> <p>etc... this is what I was trying to do <code>walk_Length = (double)rand()%2 - 1;</code></p>
0debug
c# is there a better or more efficient way of displaying database entries to textboxes? : foreach (DataRow dr in ds.Tables["Login"].Rows) { textBox1.Text = dr["Id"].ToString(); textBox2.Text = dr["username"].ToString(); textBox3.Text = dr["u_password"].ToString(); textBox4.Text = dr["exp"].ToString(); textBox5.Text = dr["salary"].ToString(); SqlCommandBuilder builder = new SqlCommandBuilder(adpt); } This is what I've got at the moment.Obviously, this is just a smaller scope workaround and is not efficient enough for a whole management system.
0debug
What is the name of the code? : Does somebody know about the following code D00077B4-EBFB-4BD8-9E3F-1F3943CBCE35 How to generate the code like this using Java program and What can we use to generate the code like the above mentioned using programming language?
0debug
Rendering dynamic HTML dropdown client-side VS server-side? : I always find it difficult to decide if I should render my HTML server-side or client-side. Let's say I want to render a dynamic HTML dropdown with following requirements: - Shows records from a database table at page load - Must stay up-to-date (users can add/remove records from the database table using the website) I can't decide between 1.1 Render template with empty drop down server-side 1.2 Populate dropdown client-side using ajax requests (JSON) 1.3 Update dropdown client-side using ajax requests (JSON) Concern: Rendering empty elements before populating feels ugly to me AND 2.1 Render populated dropdown server-side 2.2 Update dropdown client-side using ajax requests (JSON) Concern: Why would you render server-side if you are still updating it client-side? What solution is more commonly used in web development? Feel free to share different approaches...
0debug
Building one web project breaks the compiled version of the second in solution : <p>I have a big solution with 30 projects of which 2 are web projects (MVC and WebAPI) with a bunch of background class library projects.</p> <p>I have visual studio set up to host the web projects in IIS.</p> <p>If I do a clean build, followed by a full build of the entire solution, then accessing both projects via a browser works fine. (they are in diff folders and hosted on diff 'domains' in iis) </p> <p>If I make NO code changes, simply rebuild one of the 2 web projects, the OTHER one stops working. </p> <p>To be clear, rebuilding the WebAPI project causes the MVC project to have errors. And vice versa.</p> <p>The error I get is saying that System.Web.Http.Formatter is not found. The detail says that the located assembly version is different from the reference version. Checking the bin folder shows that that is not the case. </p>
0debug
static uint32_t nam_readb (void *opaque, uint32_t addr) { PCIAC97LinkState *d = opaque; AC97LinkState *s = &d->ac97; dolog ("U nam readb %#x\n", addr); s->cas = 0; return ~0U; }
1threat
static void free_picture(MpegEncContext *s, Picture *pic){ int i; if(pic->data[0] && pic->type!=FF_BUFFER_TYPE_SHARED){ free_frame_buffer(s, pic); } av_freep(&pic->mb_var); av_freep(&pic->mc_mb_var); av_freep(&pic->mb_mean); av_freep(&pic->mbskip_table); av_freep(&pic->qscale_table); av_freep(&pic->mb_type_base); av_freep(&pic->dct_coeff); av_freep(&pic->pan_scan); pic->mb_type= NULL; for(i=0; i<2; i++){ av_freep(&pic->motion_val_base[i]); av_freep(&pic->ref_index[i]); } if(pic->type == FF_BUFFER_TYPE_SHARED){ for(i=0; i<4; i++){ pic->base[i]= pic->data[i]= NULL; } pic->type= 0; } }
1threat
void syscall_init(void) { IOCTLEntry *ie; const argtype *arg_type; int size; int i; #define STRUCT(name, ...) thunk_register_struct(STRUCT_ ## name, #name, struct_ ## name ## _def); #define STRUCT_SPECIAL(name) thunk_register_struct_direct(STRUCT_ ## name, #name, &struct_ ## name ## _def); #include "syscall_types.h" #undef STRUCT #undef STRUCT_SPECIAL for (i = 0; i < ERRNO_TABLE_SIZE; i++) { target_to_host_errno_table[host_to_target_errno_table[i]] = i; } ie = ioctl_entries; while (ie->target_cmd != 0) { if (((ie->target_cmd >> TARGET_IOC_SIZESHIFT) & TARGET_IOC_SIZEMASK) == TARGET_IOC_SIZEMASK) { arg_type = ie->arg_type; if (arg_type[0] != TYPE_PTR) { fprintf(stderr, "cannot patch size for ioctl 0x%x\n", ie->target_cmd); exit(1); } arg_type++; size = thunk_type_size(arg_type, 0); ie->target_cmd = (ie->target_cmd & ~(TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT)) | (size << TARGET_IOC_SIZESHIFT); } #if (defined(__i386__) && defined(TARGET_I386) && defined(TARGET_ABI32)) || \ (defined(__x86_64__) && defined(TARGET_X86_64)) if (unlikely(ie->target_cmd != ie->host_cmd)) { fprintf(stderr, "ERROR: ioctl(%s): target=0x%x host=0x%x\n", ie->name, ie->target_cmd, ie->host_cmd); } #endif ie++; } }
1threat
React-Native cannot write first letter with noncapital : <p>I have some trouble with react-native. I have an Input component(like textfield) for user to enter his email address, but the thing is that, first letter always comes as capital letter default and it is impossible to make it non-capital. How can I change it like first letter can be small, as well? <a href="https://i.stack.imgur.com/ja4B7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ja4B7.png" alt="enter image description here"></a></p>
0debug
static int vnc_display_get_addresses(QemuOpts *opts, bool reverse, SocketAddress ***retsaddr, size_t *retnsaddr, SocketAddress ***retwsaddr, size_t *retnwsaddr, Error **errp) { SocketAddress *saddr = NULL; SocketAddress *wsaddr = NULL; QemuOptsIter addriter; const char *addr; int to = qemu_opt_get_number(opts, "to", 0); bool has_ipv4 = qemu_opt_get(opts, "ipv4"); bool has_ipv6 = qemu_opt_get(opts, "ipv6"); bool ipv4 = qemu_opt_get_bool(opts, "ipv4", false); bool ipv6 = qemu_opt_get_bool(opts, "ipv6", false); size_t i; int displaynum = -1; int ret = -1; *retsaddr = NULL; *retnsaddr = 0; *retwsaddr = NULL; *retnwsaddr = 0; addr = qemu_opt_get(opts, "vnc"); if (addr == NULL || g_str_equal(addr, "none")) { ret = 0; goto cleanup; } if (qemu_opt_get(opts, "websocket") && !qcrypto_hash_supports(QCRYPTO_HASH_ALG_SHA1)) { error_setg(errp, "SHA1 hash support is required for websockets"); goto cleanup; } qemu_opt_iter_init(&addriter, opts, "vnc"); while ((addr = qemu_opt_iter_next(&addriter)) != NULL) { int rv; rv = vnc_display_get_address(addr, false, reverse, 0, to, has_ipv4, has_ipv6, ipv4, ipv6, &saddr, errp); if (rv < 0) { goto cleanup; } if (displaynum == -1) { displaynum = rv; } *retsaddr = g_renew(SocketAddress *, *retsaddr, *retnsaddr + 1); (*retsaddr)[(*retnsaddr)++] = saddr; } if (*retnsaddr > 1) { displaynum = -1; } qemu_opt_iter_init(&addriter, opts, "websocket"); while ((addr = qemu_opt_iter_next(&addriter)) != NULL) { if (vnc_display_get_address(addr, true, reverse, displaynum, to, has_ipv4, has_ipv6, ipv4, ipv6, &wsaddr, errp) < 0) { goto cleanup; } if (*retnsaddr == 1 && (*retsaddr)[0]->type == SOCKET_ADDRESS_TYPE_INET && wsaddr->type == SOCKET_ADDRESS_TYPE_INET && g_str_equal(wsaddr->u.inet.host, "") && !g_str_equal((*retsaddr)[0]->u.inet.host, "")) { g_free(wsaddr->u.inet.host); wsaddr->u.inet.host = g_strdup((*retsaddr)[0]->u.inet.host); } *retwsaddr = g_renew(SocketAddress *, *retwsaddr, *retnwsaddr + 1); (*retwsaddr)[(*retnwsaddr)++] = wsaddr; } ret = 0; cleanup: if (ret < 0) { for (i = 0; i < *retnsaddr; i++) { qapi_free_SocketAddress((*retsaddr)[i]); } g_free(*retsaddr); for (i = 0; i < *retnwsaddr; i++) { qapi_free_SocketAddress((*retwsaddr)[i]); } g_free(*retwsaddr); *retsaddr = *retwsaddr = NULL; *retnsaddr = *retnwsaddr = 0; } return ret; }
1threat
type parameter `U` of call of method `then`. Missing annotation : <p>I have an object which might contain a promise property declared thus:</p> <pre><code>type PromiseAction = { +type: string, promise: ?Promise&lt;any&gt;, }; </code></pre> <p>The <code>action</code> argument to a function is declared to be of type PromiseAction:</p> <pre><code>(action: PromiseAction) =&gt; </code></pre> <p>Later on I check whether the received <code>action</code> object does have a <code>promise</code> property and if <code>action.promise</code> has a <code>then</code>:</p> <pre><code>if (action.promise &amp;&amp; typeof action.promise.then === 'function') { </code></pre> <p>If it does then I hook onto the promise chain:</p> <pre><code>return promise.then( </code></pre> <p>At which point I get the error: "type parameter <code>U</code> of call of method <code>then</code>. Missing annotation"</p> <p>I can see in the <a href="https://github.com/facebook/flow/blob/v0.56.0/lib/core.js#L600" rel="noreferrer">source for flow</a> that the <code>then</code> property of a <code>Promise</code> has a <code>U</code> parameter which, I assume, is the one being asked for.</p> <p>How can an provide that <code>U</code> annotation if I only have only one parameter <code>Promise&lt;+R&gt;</code> in the type declaration?</p>
0debug
RxJS observable which emits both previous and current value starting from first emission : <p>I have a <a href="http://reactivex.io/rxjs/manual/overview.html#behaviorsubject" rel="noreferrer">BehaviorSubject</a> which emits JavaScript objects periodically. I want to construct another observable which will emit both previous and current values of the underlying observable in order to compare two objects and determine the delta.</p> <p>The <a href="http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html#instance-method-pairwise" rel="noreferrer"><code>pairwise()</code></a> or <a href="http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html#instance-method-bufferCount" rel="noreferrer"><code>bufferCount(2, 1)</code></a> operators are looking like a good fit, but they start emitting only after buffer is filled, but I require this observable to start emitting from the first event of the underlying observable.</p> <pre><code>subject.someBufferingOperator() .subscribe([previousValue, currentValue] =&gt; { /** Do something */ }) ; </code></pre> <blockquote> <p>On first emission the <code>previousValue</code> could be just <code>null</code>.</p> </blockquote> <p>Is there some built-in operators that I can use to achieve the desired result?</p>
0debug
static av_cold int v4l2_decode_init(AVCodecContext *avctx) { V4L2m2mContext *s = avctx->priv_data; V4L2Context *capture = &s->capture; V4L2Context *output = &s->output; int ret; output->height = capture->height = avctx->coded_height; output->width = capture->width = avctx->coded_width; output->av_codec_id = avctx->codec_id; output->av_pix_fmt = AV_PIX_FMT_NONE; capture->av_codec_id = AV_CODEC_ID_RAWVIDEO; capture->av_pix_fmt = avctx->pix_fmt; ret = ff_v4l2_m2m_codec_init(avctx); if (ret) { av_log(avctx, AV_LOG_ERROR, "can't configure decoder\n"); return ret; } return v4l2_prepare_decoder(s); }
1threat
"pod init" giving error "-bash: pod: command not found" : <p>I am trying to create a Podfile for my Xcode project for Firebase compatibility, but when I try to create it within the same file that my Xcode project is stored in, using my terminal and typing "pod init", it throws the error "-bash: pod: command not found".</p> <p>I am up to date on OSX as far as I'm aware, using Sierra 10.12.1, but I am unfamiliar with the use of Podfiles, so any help here would be great, thanks.</p>
0debug
How i can make an array of the five most popular elements in an another array? : `int[] a ={1, 2, 5, 2, 4, 6, 8, 9, 1, 19}; int[] fiveMostPopular = new int[5]; for(int i=0; i<5;i++){ System.out.println(fiveMostPopular[i]); }`
0debug
Displayb the node value of given xml in proper format as mentioned with thier tag : <!DOCTYPE html> <html> <body> <p>I am normal</p> <p style="color:red;">I am<b> r<i>e</i>d</b></p> <p style="color:blue;">I am <b>blue</b></p> <p><b>I am <i>big</i></b></p> </body> </html>
0debug
CSS center div with <p> to parent div, vertically and horizontally : <p>I have the following HTML/CSS where I try to center a <code>div</code> with some <code>&lt;p&gt;</code> to their parent <code>div</code> wrapper. I tried to use the well known <code>translate(-50%, -50%)</code> solution, but it does not work. I also tried to use <code>margin: 0 auto</code>, also without success. I think I am missing a point, but I dont get it. Could someone tell me?</p> <p>Hint: This is an MCVE constructed from only the relevant HTML and CSS rules, there are a lot of more so dont be confused about some <code>display:block</code> or an <code>!important</code>. I coloured the background and borders for better visualization.</p> <p>Here is the snippet: </p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.half-width { width:50%; height: 795px; } div, p { border: 1px solid red; } .container { font-family: 'IBMPlexSans'; } .container &gt; div { box-sizing:border-box; border: 1px solid green; background-color: inherit; } .container{ display:flex; padding: 0; width: 100%; background-color: aqua; flex-wrap: nowrap; flex-direction: column; } .mobile-only{ display: block; width: 100%; } /** for switching between mobile and desktop rules **/ .desktop-only{ display: none; } .background-black{ background-color: #4E4E4E !important; width: 650px !important; border-radius: 20px; } .size-35{ font-size: 35px; height: 526px; text-transform: uppercase; } .size-25{ font-size: 25px; width: 335px; height: 95px; } .size-19{ font-size: 19px; width: 335px; height: 350px; margin-top: -25px; } /** center container div to an unknown body, works fine **/ .center-to-bg{ margin-left: auto; margin-right: auto; } .height-495{ height: 495px; } .height-526{ height: 526px; } .desc-text &gt; p{ display: block; } /** center the content div with the text to its parent, horizontally AND vertically, does not work**/ .center-text{ position: relative; text-align: center; top: 50%; left: 50%; transform: translate(-50%, -50%); } .center-text &gt; p{ display: block; } .center-h{ display: block !important; left: 50%; } .half-width{ width: 100vw; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt; &lt;div class="half-width mobile-only background-black height-526 center-to-bg"&gt; &lt;div class="center-text color-white size-35" id="section2"&gt; &lt;p&gt;ThIS IS &lt;/p&gt; &lt;p&gt;Á PARAGRAPH&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="half-width mobile-only center-to-bg"&gt; &lt;div class="center-text color-white size-19"&gt; &lt;div class="desc-text"&gt; &lt;p&gt;This is a long text that needs to be centered over multiple lines&lt;/p&gt; &lt;p&gt; Because mobile devices are not that width &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
0debug
int spapr_ovec_populate_dt(void *fdt, int fdt_offset, sPAPROptionVector *ov, const char *name) { uint8_t vec[OV_MAXBYTES + 1]; uint16_t vec_len; unsigned long lastbit; int i; g_assert(ov); lastbit = find_last_bit(ov->bitmap, OV_MAXBITS); vec_len = (lastbit == OV_MAXBITS) ? 1 : lastbit / BITS_PER_BYTE + 1; g_assert_cmpint(vec_len, <=, OV_MAXBYTES); vec[0] = vec_len - 1; for (i = 1; i < vec_len + 1; i++) { vec[i] = guest_byte_from_bitmap(ov->bitmap, (i - 1) * BITS_PER_BYTE); if (vec[i]) { DPRINTFN("encoding guest vector byte %3d / %3d: 0x%.2x", i, vec_len, vec[i]); } } return fdt_setprop(fdt, fdt_offset, name, vec, vec_len); }
1threat
Why is only one table row updated? (MySQL & PHP) : I'm trying to update the `rank` column in the `users` table in MySQL using PHP, but when i try to change the values and press the `update` button, **only the last one** of the table rows is actually being updated. [Here][1] is an image of what the PHP table looks like on the webpage. Here is the code: <html> <head> </head> <body> <?php include '../db/connect.php'; $con = $MySQLi_CON; if (!$con){ die("Can not connect: " . mysql_error()); } if(isset($_POST['update'])){ $UpdateQuery = "UPDATE users SET rank='$_POST[rank]' WHERE user_id='$_POST[hidden]'"; $con->query($UpdateQuery); } //$sql = "SELECT * from users"; //$myData = mysql_query($sql, $con); $result = $MySQLi_CON->query("SELECT * FROM users") or die(mysql_error()); echo "<table border=1> <tr> <th>ID</th> <th>Username</th> <th>Email</th> <th>Rank</th> </tr>"; while($record = $result->fetch_array()){ echo "<form action='test3.php' method='post'"; echo '<tr>'; echo '<td>' . $record['user_id'] . '</td>'; echo '<td>' . $record['username'] . '</td>'; echo '<td>' . $record['email'] . '</td>'; echo '<td>' . '<input type="number" name="rank" min="0" max="100" value="' . $record['rank'] . '"></td>'; echo '<td>' . '<input type="hidden" name="hidden" value="' . $record['user_id'] . '"</td>'; echo '<td>' . '<input type="submit" name="update" value="update"' . '</td></tr>'; } echo "</table>"; $con->close(); [1]: http://i.stack.imgur.com/T9ESy.png
0debug
ssize_t nbd_send_request(QIOChannel *ioc, NBDRequest *request) { uint8_t buf[NBD_REQUEST_SIZE]; TRACE("Sending request to server: " "{ .from = %" PRIu64", .len = %" PRIu32 ", .handle = %" PRIu64 ", .flags = %" PRIx16 ", .type = %" PRIu16 " }", request->from, request->len, request->handle, request->flags, request->type); stl_be_p(buf, NBD_REQUEST_MAGIC); stw_be_p(buf + 4, request->flags); stw_be_p(buf + 6, request->type); stq_be_p(buf + 8, request->handle); stq_be_p(buf + 16, request->from); stl_be_p(buf + 24, request->len); return write_sync(ioc, buf, sizeof(buf), NULL); }
1threat
static int config_props(AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; AVFilterLink *inlink = outlink->src->inputs[0]; ScaleContext *scale = ctx->priv; int64_t w, h; double var_values[VARS_NB], res; char *expr; int ret; var_values[VAR_PI] = M_PI; var_values[VAR_PHI] = M_PHI; var_values[VAR_E] = M_E; var_values[VAR_IN_W] = var_values[VAR_IW] = inlink->w; var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h; var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN; var_values[VAR_OUT_H] = var_values[VAR_OH] = NAN; var_values[VAR_DAR] = var_values[VAR_A] = (float) inlink->w / inlink->h; var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ? (float) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1; var_values[VAR_HSUB] = 1<<av_pix_fmt_descriptors[inlink->format].log2_chroma_w; var_values[VAR_VSUB] = 1<<av_pix_fmt_descriptors[inlink->format].log2_chroma_h; av_expr_parse_and_eval(&res, (expr = scale->w_expr), var_names, var_values, NULL, NULL, NULL, NULL, NULL, 0, ctx); scale->w = var_values[VAR_OUT_W] = var_values[VAR_OW] = res; if ((ret = av_expr_parse_and_eval(&res, (expr = scale->h_expr), var_names, var_values, NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0) goto fail; scale->h = var_values[VAR_OUT_H] = var_values[VAR_OH] = res; if ((ret = av_expr_parse_and_eval(&res, (expr = scale->w_expr), var_names, var_values, NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0) goto fail; scale->w = res; w = scale->w; h = scale->h; if (w < -1 || h < -1) { av_log(ctx, AV_LOG_ERROR, "Size values less than -1 are not acceptable.\n"); return AVERROR(EINVAL); } if (w == -1 && h == -1) scale->w = scale->h = 0; if (!(w = scale->w)) w = inlink->w; if (!(h = scale->h)) h = inlink->h; if (w == -1) w = av_rescale(h, inlink->w, inlink->h); if (h == -1) h = av_rescale(w, inlink->h, inlink->w); if (w > INT_MAX || h > INT_MAX || (h * inlink->w) > INT_MAX || (w * inlink->h) > INT_MAX) av_log(ctx, AV_LOG_ERROR, "Rescaled value for width or height is too big.\n"); outlink->w = w; outlink->h = h; av_log(ctx, AV_LOG_INFO, "w:%d h:%d fmt:%s -> w:%d h:%d fmt:%s flags:0x%0x\n", inlink ->w, inlink ->h, av_pix_fmt_descriptors[ inlink->format].name, outlink->w, outlink->h, av_pix_fmt_descriptors[outlink->format].name, scale->flags); scale->input_is_pal = av_pix_fmt_descriptors[inlink->format].flags & PIX_FMT_PAL; if (scale->sws) sws_freeContext(scale->sws); scale->sws = sws_getContext(inlink ->w, inlink ->h, inlink ->format, outlink->w, outlink->h, outlink->format, scale->flags, NULL, NULL, NULL); if (!scale->sws) return AVERROR(EINVAL); if (inlink->sample_aspect_ratio.num) outlink->sample_aspect_ratio = av_mul_q((AVRational){outlink->h*inlink->w, outlink->w*inlink->h}, inlink->sample_aspect_ratio); else outlink->sample_aspect_ratio = inlink->sample_aspect_ratio; return 0; fail: av_log(NULL, AV_LOG_ERROR, "Error when evaluating the expression '%s'\n", expr); return ret; }
1threat
Laravel Distinct Count : <p>Any way to make this query work using laravel? DB::raw or Eloquent usage doesn't matter.</p> <pre><code>SELECT count(DISTINCT name) FROM tablename; </code></pre> <p>Here's what i've tried but cannot get the proper output:</p> <pre><code>EloquentTableName::select(DB::raw('count(DISTINCT name) as name_count'))-&gt;get(); </code></pre> <p>This returns something like this and i'd like to fix that:</p> <pre><code>([{"name_count":"15"}]) </code></pre> <p>I just want to get count 15.</p>
0debug
static int y41p_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { AVFrame *pic = data; uint8_t *src = avpkt->data; uint8_t *y, *u, *v; int i, j, ret; if (avpkt->size < 3LL * avctx->height * avctx->width / 2) { av_log(avctx, AV_LOG_ERROR, "Insufficient input data.\n"); return AVERROR(EINVAL); } if ((ret = ff_get_buffer(avctx, pic, 0)) < 0) return ret; pic->key_frame = 1; pic->pict_type = AV_PICTURE_TYPE_I; for (i = avctx->height - 1; i >= 0 ; i--) { y = &pic->data[0][i * pic->linesize[0]]; u = &pic->data[1][i * pic->linesize[1]]; v = &pic->data[2][i * pic->linesize[2]]; for (j = 0; j < avctx->width; j += 8) { *(u++) = *src++; *(y++) = *src++; *(v++) = *src++; *(y++) = *src++; *(u++) = *src++; *(y++) = *src++; *(v++) = *src++; *(y++) = *src++; *(y++) = *src++; *(y++) = *src++; *(y++) = *src++; *(y++) = *src++; } } *got_frame = 1; return avpkt->size; }
1threat
React Navigation - navigating to another tab and reset stack : <p>I'm trying to route from one StackNavigator to another, both of which are inside a TabNavigator. I'm currently able to get there by simply doing:</p> <pre><code>this.props.navigation.navigate('Screen3') </code></pre> <p>But I also want to reset that tab when I go to it. Here is how my app navigators are generally set up:</p> <pre><code>- Main (StackNavigator) - LoginScreen - MainTabs (TabNavigator) - Tab1 (StackNavigator) - Screen1 - Screen2 - Tab2 (StackNavigator) - Screen3 - Screen4 </code></pre> <p>How could I navigate to <code>Screen3</code> but also reset the StackNavigator <code>Tab2</code>?</p> <p>I've also tried doing this, to no avail:</p> <pre><code>let resetAction = NavigationActions.reset({ index: 0, key: 'Tab2', actions: [ NavigationActions.navigate({ routeName: 'Screen3' }) ], }); this.props.navigation.dispatch(resetAction); </code></pre>
0debug