problem
stringlengths
26
131k
labels
class label
2 classes
Is this nested function problem solvable in C? : <p>Given g(x) = cos(log(2.21-x)) and that x = 0.99, estimate the value given by the nested g(g(g(x)... equation as the nesting approaches infinity (you don't have to actually go to infinity, but just set up a way to recurse this nesting n times or so).</p> <p>I've tried some basic stuff like g(x) = cos(log(2.21-x)) and then creating a for loop defined by g(x) = g(g(x)). None of this works. </p> <p>In these attempts I've gotten end of void errors and overflow errors. If anyone can figure out if this question is viable in C, even though C doesn't support "nested" functions, I will be amazed and very thankful.</p>
0debug
static void test_visitor_out_no_string(TestOutputVisitorData *data, const void *unused) { char *string = NULL; QObject *obj; visit_type_str(data->ov, NULL, &string, &error_abort); obj = visitor_get(data); g_assert(qobject_type(obj) == QTYPE_QSTRING); g_assert_cmpstr(qstring_get_str(qobject_to_qstring(obj)), ==, ""); }
1threat
def smallest_num(xs): return min(xs)
0debug
Matplotlib scatter plot with unknown error : <p>I am attempting to create a scatter plot. I have a list of numbers from 0 - 17 as well as an array with 18 values. I can plot the data as a line plot but when I try to plot as a scatter I get an error message I do not understand: <code>TypeError: ufunc 'sqrt' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''</code></p> <p>What does this error message mean and how can I get the data to plot as a scatter?</p> <pre><code>import numpy as np import matplotlib.pyplot as plt y = [7316.0, 7453.25, 7518.25, 7711.5, 7448.0, 7210.25, 7416.75, 6960.75, 7397.75, 6397.5, 5522.75, 5139.0, 5034.75, 4264.75, 5106.0, 3489.5, 4712.0, 4770.0] x = np.arange(0,18,1) plt.rcParams['legend.loc'] = 'best' plt.figure(1) plt.xlim(0, 20) plt.ylim(0, 10000) plt.scatter(x, y, 'r') plt.show() </code></pre>
0debug
static void glfs_clear_preopened(glfs_t *fs) { ListElement *entry = NULL; if (fs == NULL) { return; } QLIST_FOREACH(entry, &glfs_list, list) { if (entry->saved.fs == fs) { if (--entry->saved.ref) { return; } QLIST_REMOVE(entry, list); glfs_fini(entry->saved.fs); g_free(entry->saved.volume); g_free(entry); } } }
1threat
Fisher exact test taks so long in R :( : My table has 770,000 rows and what I did is > mydata <- dbGetQuery(mydb, "select * from table") > mydata$pvalue <- apply(as.matrix(mydata[, c(3,5,4,6)]), 1, function(x) fisher.test(matrix(x, nrow=2))$p.value) to get pvalues. But it takes so long. (it has been over 24hours and it is still running) Should I use other method?
0debug
save the result of a function getDistanceMatrix in a variable : <p>I am trying to save the result of a function in a variable </p> <pre><code>let myDistance = (()=&gt;{ let service = new google.maps.DistanceMatrixService(); service.getDistanceMatrix( { origins: [{lat: 55.93, lng: -3.118}], destinations: [{lat: 50.087, lng: 14.421}], travelMode: google.maps.TravelMode.DRIVING, avoidHighways: false, avoidTolls: false }, callback ); function callback(response, status) { let distance = 0; if(status=="OK") { distance = response.rows[0].elements[0].distance.value; } else { alert("Error: " + status); } return distance; } })(); console.log(myDistance) </code></pre> <p>But not working I use Google Maps Api v3 - Distance Matrix section</p> <pre><code>&lt;script async defer src="https://maps.googleapis.com/maps/api/jskey=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk"&gt; &lt;/script&gt; </code></pre>
0debug
Sort data in python, such that missing data points are filled with NaNs : In the metaanalysis of a drug interference study, I am analyzing the influence on patients of drugs at several concentations at different time points. Now for some patients, data are available for only some of the drug concentrations. I use a vector as follows to filter the data for each patient by available drug concentrations: vec_conc = ['none','1nM','10nM','100nM','1uM','10uM','100uM'] When enumerating over this "concentration vector", obviously 0 = none, 1 = 1nM, ..., 4 = 1uM, ..., 6 = 100uM. My script so far returns arrays "influence" for each patient (e.g. below), where influence[i,0] are the above mentioned "concentration counts" and [i,1:] are the results at concentration i for the various time points. E.g. in the following patient, data only for concentations 0, 2, 3, 5 are available: [[ 0. 1. 0.73475787 0.36224658 0.08579446 -0.11767365 -0.09927562 0.17444341 0.47212111 1.00584593 1.69147789 1.89421069 1.4718292 ] [ 2. 1. 0.68744907 0.38420843 0.25922927 0.04719614 0.00841919 0.21967246 0.22183329 0.28910002 0.54637077 -0.04389335 -1.33445338] [ 3. 1. 0.77854922 0.41093192 0.0713814 -0.08194854 -0.07885753 0.1491798 0.56297583 1.0759857 1.57149366 1.37958867 0.64409152] [ 5. 1. 0.09182989 0.14988215 -0.1272845 0.12154707 -0.01194815 -0.06136953 0.18783772 0.46631855 0.78850281 0.64755372 0.69757144]] Now, for my later metaanalysis of all patients I would like to have the "influence" arrays to have all NaNs included for missing concentrations. In the above example, I would like to have [[ 0. 1. 0.73475787 0.36224658 0.08579446 -0.11767365 -0.09927562 0.17444341 0.47212111 1.00584593 1.69147789 1.89421069 1.4718292 ] [[ 1. NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ] [ 2. 1. 0.68744907 0.38420843 0.25922927 0.04719614 0.00841919 0.21967246 0.22183329 0.28910002 0.54637077 -0.04389335 -1.33445338] [ 3. 1. 0.77854922 0.41093192 0.0713814 -0.08194854 -0.07885753 0.1491798 0.56297583 1.0759857 1.57149366 1.37958867 0.64409152] [[ 4. NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ] [ 5. 1. 0.09182989 0.14988215 -0.1272845 0.12154707 -0.01194815 -0.06136953 0.18783772 0.46631855 0.78850281 0.64755372 0.69757144]] [[ 6. NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ] To re-sort my influence vectors I have tried the following: influence_incl_missing = np.ones((len(vec_conc),len(results)+1)) for i, conc in enumerate(vec_conc): if i == influence[i,0]: influence_incl_missing[i,:] = influence[i,:] else: influence_incl_missing[i,1:] = np.full(len(results),np.nan) influence_incl_missing[i,0] = i This gives me the obvious error IndexError: index 4 is out of bounds for axis 0 with size 4 since len(influence) < len(vec_conc). How can I do this in python? Many thanks!!
0debug
How to get string / line between 2 strings using Regex in C# : I am bit new for Regex class in C#. I have use case like I have some file where we have data in following format :-- ----string1 abc cde --string1 efg hjk -string1 xyz string1 Now when I am using like string1(.+?)string1 as pattern I am getting following 2 result :-- "abc", cde and xyz. But I want abc, cde, efg, hjk and xyz. Can you suggest how can I do it ? There is one more issue - how to handle variable numbers of "-" as right now I am ignoring it (in my above example) but I have to handle it later on. Thanks for help.
0debug
remove unnecessary white space, auto detect header, and sorted by name in datagrib from csv file. C# : I know my title is confuse and not clear, now i going to explain what i need.<br/> In the end of the program, it will be able to input csv file, calculate and output the result.<br/> For now i m doing it step by step.<br/> **1)** Able to import csv to datagribview (done)<br/> **2)** Remove unnecessary white space, sort it by name (in progress) <br/> **3)** Calculation <br/> To makes my question clear and easy to understand, here is the csv file sample. [![enter image description here][1]][1] As you can see that there are repeated 'lotID' is every section, and 2 type to lotID. And here is what i have done so far. let's call this pic a.I successfully filter out lotID of the 1st type lotID. [![enter image description here][2]][2] this is pic B , as u can see the 'LotID' of section type of lot ID is appear again in each section[![enter image description here][3]][3] [1]: https://i.stack.imgur.com/bKSWd.png [2]: https://i.stack.imgur.com/LFc7f.png [3]: https://i.stack.imgur.com/LCEl1.png As you can see in PIC A, the lotID of each section is not repeated, and it white space appear in each section.<br/> This is the first thing i try want to fix.<br/> Secondly, i want to filter out the 'LotID' header of second type lotid.<br/> Here is the code.<br/> using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace test2 { public partial class Form1 : Form { OpenFileDialog openFile = new OpenFileDialog(); public Form1() { InitializeComponent(); } private void Button1_Click(object sender, EventArgs e) { if (openFile.ShowDialog() == DialogResult.OK) { List<string[]> rows = File.ReadLines(openFile.FileName).Select(x => x.Split(',')).ToList(); DataTable dt = new DataTable(); List<string> headerNames = rows[0].ToList(); foreach (var headers in rows[0]) { dt.Columns.Add(headers); } foreach (var x in rows.Skip(1)) { if (x.SequenceEqual(headerNames)) //linq to check if 2 lists are have the same elements (perfect for strings) continue; //skip the row with repeated headers dt.Rows.Add(x); } dataGridView1.DataSource = dt; } } private void Form1_Load_1(object sender, EventArgs e) { openFile.Filter = "CSV|*.csv"; } } } I hope that my question can helps the other if they having same problem like me too! <br/> Appreciate.
0debug
QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state) { QEMUFileBuffered *s; s = g_malloc0(sizeof(*s)); s->migration_state = migration_state; s->xfer_limit = migration_state->bandwidth_limit / 10; s->file = qemu_fopen_ops(s, &buffered_file_ops); s->timer = qemu_new_timer_ms(rt_clock, buffered_rate_tick, s); qemu_mod_timer(s->timer, qemu_get_clock_ms(rt_clock) + 100); return s->file; }
1threat
how to remove error: expected primary-expression before '.' token : <p>please help me remove this error i made these two structures and when i try to use the cin it shows this error how can i remove this error and please also tell me how to take a string in input using cin.getline and gets().</p> <pre><code>#include &lt;iostream&gt; using namespace std; struct Date //Date structure { int day; int month; int year; }; struct Employee //employee structure { int Id; char Name[40]; int Date; char Gender; char Des[40]; }; void Setter(Employee E) //function for setting value in Employees { cout&lt;&lt;"Enter Id:"; cin&gt;&gt;Employee.Id; cout&lt;&lt;"Enter Name:"; cin&gt;&gt;Employee.Name; cout&lt;&lt;"Enter Gender:"; cin&gt;&gt;Employee.Gender; cout&lt;&lt;"Enter Designation:"; cin&gt;&gt;Employee.Des; cout&lt;&lt;"Enter Date of joining(DD/MM/YYYY):"; cin&gt;&gt;Employee.Date.day&gt;&gt;Employee.Date.month&gt;&gt;Employee.Date.year; } int main() //main { Employee el; Setter(el); //calling function return 0; } </code></pre>
0debug
static void xen_exit_notifier(Notifier *n, void *data) { XenIOState *state = container_of(n, XenIOState, exit); xc_evtchn_close(state->xce_handle); xs_daemon_close(state->xenstore); }
1threat
can i use lan wire color combination like 1=Light Orange , 2=Orange, 3=Light Blue, 4 and 5 null and 6=Blue : can i use lan wire color combination like 1=Light Orange , 2=Orange, 3=Light Blue, 4 and 5 null and 6=Blue. Intsted of1=Light Orange , 2=Orange, 3=Light Green, 4 and 5 null and 6=Green In Lan Wire connection ? is it work [lan pin connection ][1] [1]: https://i.stack.imgur.com/8v2QG.jpg
0debug
How may Refresh my page when only mysql databases update using php : <p>Actually am developing online ordering system and i need when an order has approved by manager shown automatically on quicken department screen without refreshing a page and notice with beep sound! please is there any idea? </p>
0debug
What is the difference between .nextLine() and .next()? : <p>I am making a program and am using user input. When I am getting a String I have always used .nextLine(), but I have also used .next() and it does the same thing. What is the difference? </p> <pre><code>Scanner input = new Scanner(System.in); String h = input.nextLine(); String n = input.next(); </code></pre> <p>What is the difference? </p>
0debug
How to excecute script every 6 hours? JQUERY : I need to refresh token every 6hours so then I can use an api without doing login again. I'm trying like this: setInterval(function(){ var code = window.location.href.split("=").pop(); var xhr = new XMLHttpRequest(); xhr.open("POST", "https://api.mercadolibre.com/oauth/token?grant_type=authorization_code&client_id="+appID+"&client_secret="+secretKey+"&code="+code+"&redirect_uri="+redirectUri, true); xhr.onload = function () { console.log(xhr.responseText); }; xhr.send(); } }, 21600); Any Idea how could achieve this?
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
HADOOP INSTAllATION ERROR ON RUNNING COMMAND FORMATING NAMENODE : I'm installing hadoop on remote server(centos) I've installed hadoop successfully in local mode and trying to install it in pseudo-distributed mode but after all the configuration changes in core-site.xml and mapred-site.xml when i run hdfd namenode -format i get following errors: [][1] [1]: http://i.stack.imgur.com/9bzWg.png
0debug
Group by columns and summarize a column into a list : <p>I have a dataframe like this: </p> <pre><code>sample_df&lt;-data.frame( client=c('John', 'John','Mary','Mary'), date=c('2016-07-13','2016-07-13','2016-07-13','2016-07-13'), cluster=c('A','B','A','A')) #sample data frame client date cluster 1 John 2016-07-13 A 2 John 2016-07-13 B 3 Mary 2016-07-13 A 4 Mary 2016-07-13 A </code></pre> <p>I would like to transform it into different format, which will be like:</p> <pre><code>#ideal data frame client date cluster 1 John 2016-07-13 c('A,'B') 2 Mary 2016-07-13 A </code></pre> <p>For the 'cluster' column, it will be a list if some client is belong to different cluster on the same date.</p> <p>I thought I can do it with dplyr package with commend as below</p> <pre><code>library(dplyr) ideal_df&lt;-sample %&gt;% group_by(client, date) %&gt;% summarize( #some anonymous function) </code></pre> <p>However, I don't know how to write the anonymous function in this situation. Is there a way to transform the data into the ideal format?</p>
0debug
Is any better syntax to perform this code? : <p>Below is my code</p> <pre><code> if(!chineseName) { alert("chineseName is not correct"); } else if(!IDN){ alert("IDN is not correct"); } else if(!mobileNumber){ alert("number is not correct"); } else if(hasAccount){ if(!isAccountNumberValid) { alert("account number is not correct"); } else { check(); } } else { check(); } function check() { if(!check1 &amp;&amp; !check2) { alert("Please read NOTE and check the read box."); } else { alert("Everything is good to go!!"); } } </code></pre> <p>Now, this code is working correct. However, I would like to know if there any better syntax to perform same thing?</p> <p>Thanks.</p>
0debug
i want to add 10% service tax and 13 % vat but i am unabble to do so please anybody help me. Beside this i have to print the bill for 5 users : You are required to create an MVP (Minimal Viable Product) to take customer orders for a local ethnic food restaurant in Kathmandu. The restaurant offers 10 different types of food dishes, taken from the local ethnic food culture. The restaurant operates with limited dishes and limited staff. You are required to create a prototype of order taking system to ease the working process within the restaurant. Your program should have the following functionalities: • The program should display the menu at the start (with 10 dishes) • Each customer will make an order based on the menu shown. For each order, the system should calculate the total bill. • For each bill, after adding the sum total of the prices of the dishes, the sum total would be subject to 10% service Tax and 13% VAT. • For every new instance where a customer (new or repeating) makes an order, a new bill is generated. • Altering a confirmed order would not be a necessary feature for the MVP phase of the system. • Your MVP should be able to manage order and billing of 5 customers at once. • The menu prices and the dishes in them could be initially hardwired into your MVP for test purposes (in a file or an array) public class Array { //class name public static void main(String args[]) { Scanner input = new Scanner(System.in); int choice; double total = 0; double tax = 0.10; //Array for storing prices double[] Price = new double[10]; Price[0] = 120; Price[1] = 80; Price[2] = 40; Price[3] = 100; Price[4] = 50; Price[5] = 60; Price[6] = 90; Price[7] = 45; Price[8] = 70; Price[9] = 60; //Menu item array String[] FoodItem = new String[10]; FoodItem[0] = "Momo"; FoodItem[1] = "Chawmin"; FoodItem[2] = "Sausages"; FoodItem[3] = "Pizza"; FoodItem[4] = "Burger"; FoodItem[5] = "Buff Sekuwa"; FoodItem[6] = "Chicken Sekuwa"; FoodItem[7] = "Alu Paratha"; FoodItem[8] = "Chicken Chilly"; FoodItem[9] = "Fry Rice"; //Welcome user and gather their menu selection System.out.println("Welcome to PurpleHaze ! Please enjoy!"); // System.out.printf("The average pricing for our drinks is: %.2f \n", + cafeAvg( cafePrice)); System.out.println("Please enter a menu selection:\n" + "0. Momo -- 120\n" + "1. Chawmin -- 80\n" + "2. Sausages -- 40\n" + "3. Pizza -- 100\n" + "4. Burger -- 50\n" + "5. Buff Sekuwa -- 60\n" + "6. Chicken Sekuwa -- 90\n" + "7. Alu Paratha -- 45\n" + "8. Chicken Chilly -- 70\n" + "9. Fry Rice -- 60"); choice = input.nextInt(); //Add up the total total = Price[choice] + tax; System.out.println("Your total is: " + total + tax); } } // i want to add 13% VAT and 10% charge. //Also the should be able to manage order and billing of 5 customers at once.
0debug
static void *kvm_cpu_thread_fn(void *arg) { CPUState *env = arg; int r; qemu_mutex_lock(&qemu_global_mutex); qemu_thread_self(env->thread); r = kvm_init_vcpu(env); if (r < 0) { fprintf(stderr, "kvm_init_vcpu failed: %s\n", strerror(-r)); exit(1); } qemu_kvm_init_cpu_signals(env); env->created = 1; qemu_cond_signal(&qemu_cpu_cond); while (!qemu_system_ready) qemu_cond_timedwait(&qemu_system_cond, &qemu_global_mutex, 100); while (1) { if (cpu_can_run(env)) qemu_cpu_exec(env); qemu_kvm_wait_io_event(env); } return NULL; }
1threat
in C how to pass local function variable value to another function and print value without errors : <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; int give_options(); int give_options(){ printf("===== MENU 1 =====\n"); printf("&gt; store new customer :\t\tenter 1\n"); printf("&gt; view a customer :\t\tenter 2\n"); printf("&gt; view all customers :\t\tenter 3\n"); printf("&gt; exit program :\t\tenter 4\n "); int ipt = malloc(sizeof(int)); scanf("%d",&amp;ipt); return ipt; } int main(){ int dec = give_options(); printf("decision is: %d", dec); getchar(); } </code></pre> <p>Ive started to code in C recently in Ubuntu im trying to return the value a local variable of one function and have it passed to another function. I have read that since local variables are assigned to stack the value will no longer exist after function returns, and that I have to allocate memory in heap using malloc.</p> <p>when I compile I get this warning: </p> <pre><code>initialization makes integer from pointer without a cast [-Wint-conversion] int ipt = malloc(sizeof(int)); </code></pre> <p>when I adjust this to int ipt = (int)malloc(sizeof(int)); -I get:</p> <pre><code>warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] int ipt = (int)malloc(sizeof(int)); </code></pre> <p>What is the correct thing to do here?</p> <p>I'm also having trouble with scanf since I switched to coding in Ubuntu. I tried a different way, trying to use pointers:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; int* give_options(); int* give_options(){ printf("===== MENU 1 =====\n"); printf("&gt; store new customer :\t\tenter 1\n"); printf("&gt; view a customer :\t\tenter 2\n"); printf("&gt; view all customers :\t\tenter 3\n"); printf("&gt; exit program :\t\tenter 4\n "); int* ipt; ipt = malloc(sizeof(int)); scanf("d",&amp;ipt); return ipt; } int main(){ int* dec = give_options(); printf("decision is: %d", dec); getchar(); } </code></pre> <p>compiling this gives me following errors:</p> <pre><code>warning: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘int **’ [-Wformat=] scanf("%d",&amp;ipt); warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int *’ [-Wformat=] printf("decision is: %d", dec); </code></pre> <p>which approach is right and which one works?</p>
0debug
Microservices: Atomic Events : <p>I'm learning about microservice data replication right now, and one thing I'm having trouble with is coming up with the right architecture for ensuring event atomicity. The way I understand it, the basic flow is:</p> <ol> <li>Commit changes to a database.</li> <li>Publish an event detailing the changes on the global message bus.</li> </ol> <p>But what if, for example, a power outage occurred in-between Steps 1 and 2? In a naively-built system, that would mean the changes persist but the event detailing them will never be published. I've pondered the following ideas to create better guarantees, but I'm not quite sure of all the pros and cons of each:</p> <p>A: Use an embedded database (like SQLite) in my microservice instance to track the full transaction, from the commit to the main database to the event publishing.</p> <p>B: Create an Events table in my main database, using database transactions to insert the Event and commit the relevant changes at the same time. The service would then push the Event to the bus, and then make another commit to the main database to mark the Event as Published.</p> <p>C: As above, create an Events table in my main database, using database transactions to insert the Event and commit the relevant changes at the same time. Then, notify (either manually via REST/Messages from within the service or via database hooks) a dedicated EventPusher service that a new event has been appended. The EventPusher service will query the Events table and push the events to the bus, marking each one as Published upon acknowledgement. Should a certain amount of time pass without any notification, the EventPusher will do a manual query.</p> <p>What are the pros and cons of each of the choices above? Is there another superior option I have yet to consider?</p>
0debug
Change label value Using jQuery : This my first question,On My Form, i want change Color to Choose Color <label for="ProductSelect-option-0">Color</label> output will be <label for="ProductSelect-option-0">Choose Color</label> Without add class or ID. How possible to do with jQuery?
0debug
Losing widget state when switching pages in a Flutter PageView : <p>I have a series of stateful widgets in a PageView managed by a PageController. I am using <code>pageController.jumpToPage(index)</code> to switch pages. When switching pages all state appears to be lost in the widget, as if it was recreated from scratch. I have tried using <code>keepPage: true</code> in the PageController but that doesn't seem to have any effect. Is this the intended behavior of a PageView or am I doing something wrong? Any suggestions appreciated, thanks!</p>
0debug
static void arm_gic_common_reset(DeviceState *dev) { GICState *s = ARM_GIC_COMMON(dev); int i; memset(s->irq_state, 0, GIC_MAXIRQ * sizeof(gic_irq_state)); for (i = 0 ; i < s->num_cpu; i++) { if (s->revision == REV_11MPCORE) { s->priority_mask[i] = 0xf0; } else { s->priority_mask[i] = 0; } s->current_pending[i] = 1023; s->running_irq[i] = 1023; s->running_priority[i] = 0x100; s->cpu_enabled[i] = false; } for (i = 0; i < GIC_NR_SGIS; i++) { GIC_SET_ENABLED(i, ALL_CPU_MASK); GIC_SET_EDGE_TRIGGER(i); } if (s->num_cpu == 1) { for (i = 0; i < GIC_MAXIRQ; i++) { s->irq_target[i] = 1; } } s->ctlr = 0; }
1threat
Show and hide divs with js - Help me please : I have 5 `<a>`... <a id="showtrips">TRIPS</a> <a id="showeats">EATS</a> <a id="showfilms">FILMS</a> <a id="showmusic">MUSIC</a> <a id="showtravels">TRAVELS</a> ...and I have 5 `<div>` and each div have the content of the `<a>` names. I want show all `<a>` and show only a `<div>`, so I want click on a `<a>` and hide the others divs showing only the selected div. Im searching and searching but I can´t find this exactly I found similar things but impossible to integrate to this problem.
0debug
With knexjs, how do I compare two columns in the .where() function? : <p>Using knexjs only (no bookshelf) I would like to do something like the following query:</p> <pre><code>select * from table1 where column1 &lt; column2 </code></pre> <p>However, when I do this:</p> <pre><code>.table("table1").select().where("column1", "&lt;", "column2") </code></pre> <p>The SQL that knexjs generates is:</p> <pre><code>select * from table1 where column1 &lt; 'column2' </code></pre> <p>Which doesn't give the desired result b/c it's not comparing the value from the column, it's comparing the value of the string, 'column2'.</p> <p>Anyone know how to do what I'm wanting? Thanks!</p>
0debug
Disable Upgrade-Insecure-Requests in Firefox and Chrome : <p>I run a PHP+Apache2 application locally - for development purposes.</p> <p>The app is running at <a href="http://x.dev" rel="noreferrer">http://x.dev</a> (a virtual host + an entry in hosts file)</p> <p>After Firefox updated it seems that I can no longer access <a href="http://x.dev" rel="noreferrer">http://x.dev</a> as the address in address bar is changed, by the browser, in <a href="https://x.dev" rel="noreferrer">https://x.dev</a> which obviously is not configured.</p> <p>I used older version of Firefox (49) vs the new one (59.0.2) and the difference seems to be a new header "Upgrade-Insecure-Requests" that was added to the request.</p> <p>This seems to force http to https, thus causing an issue.</p> <p>Bellow is what I got after I try to access <a href="http://x.dev" rel="noreferrer">http://x.dev</a> :</p> <p><a href="https://i.stack.imgur.com/4tvwO.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/4tvwO.jpg" alt="enter image description here"></a></p> <p>I saw the same behavior in Chrome. Edge seems to not be "plagued" by this one.</p> <p>AFAIK this new header was added to improve security (I'm fine with that), but is there any method (configure Firefox) to get back to old behavior (not sending this value)? Or any change on server side to ignore that request?</p>
0debug
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; const uint8_t *buf_end = avpkt->data + avpkt->size; int buf_size = avpkt->size; DPXContext *const s = avctx->priv_data; AVFrame *picture = data; AVFrame *const p = &s->picture; uint8_t *ptr; int magic_num, offset, endian; int x, y; int w, h, stride, bits_per_color, descriptor, elements, target_packet_size, source_packet_size; unsigned int rgbBuffer; if (avpkt->size <= 1634) { av_log(avctx, AV_LOG_ERROR, "Packet too small for DPX header\n"); return AVERROR_INVALIDDATA; } magic_num = AV_RB32(buf); buf += 4; if (magic_num == AV_RL32("SDPX")) { endian = 0; } else if (magic_num == AV_RB32("SDPX")) { endian = 1; } else { av_log(avctx, AV_LOG_ERROR, "DPX marker not found\n"); return -1; } offset = read32(&buf, endian); if (avpkt->size <= offset) { av_log(avctx, AV_LOG_ERROR, "Invalid data start offset\n"); return AVERROR_INVALIDDATA; } buf = avpkt->data + 0x304; w = read32(&buf, endian); h = read32(&buf, endian); buf += 20; descriptor = buf[0]; buf += 3; avctx->bits_per_raw_sample = bits_per_color = buf[0]; buf += 825; avctx->sample_aspect_ratio.num = read32(&buf, endian); avctx->sample_aspect_ratio.den = read32(&buf, endian); if (avctx->sample_aspect_ratio.num > 0 && avctx->sample_aspect_ratio.den > 0) av_reduce(&avctx->sample_aspect_ratio.num, &avctx->sample_aspect_ratio.den, avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den, 0x10000); else avctx->sample_aspect_ratio = (AVRational){ 0, 0 }; switch (descriptor) { case 51: elements = 4; break; case 50: elements = 3; break; default: av_log(avctx, AV_LOG_ERROR, "Unsupported descriptor %d\n", descriptor); return -1; } switch (bits_per_color) { case 8: if (elements == 4) { avctx->pix_fmt = PIX_FMT_RGBA; } else { avctx->pix_fmt = PIX_FMT_RGB24; } source_packet_size = elements; target_packet_size = elements; break; case 10: avctx->pix_fmt = PIX_FMT_RGB48; target_packet_size = 6; source_packet_size = 4; break; case 12: case 16: if (endian) { avctx->pix_fmt = elements == 4 ? PIX_FMT_RGBA64BE : PIX_FMT_RGB48BE; } else { avctx->pix_fmt = elements == 4 ? PIX_FMT_RGBA64LE : PIX_FMT_RGB48LE; } target_packet_size = source_packet_size = elements * 2; break; default: av_log(avctx, AV_LOG_ERROR, "Unsupported color depth : %d\n", bits_per_color); return -1; } if (s->picture.data[0]) avctx->release_buffer(avctx, &s->picture); if (av_image_check_size(w, h, 0, avctx)) return -1; if (w != avctx->width || h != avctx->height) avcodec_set_dimensions(avctx, w, h); if (avctx->get_buffer(avctx, p) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } buf = avpkt->data + offset; ptr = p->data[0]; stride = p->linesize[0]; if (source_packet_size*avctx->width*avctx->height > buf_end - buf) { av_log(avctx, AV_LOG_ERROR, "Overread buffer. Invalid header?\n"); return -1; } switch (bits_per_color) { case 10: for (x = 0; x < avctx->height; x++) { uint16_t *dst = (uint16_t*)ptr; for (y = 0; y < avctx->width; y++) { rgbBuffer = read32(&buf, endian); *dst++ = make_16bit(rgbBuffer >> 16); *dst++ = make_16bit(rgbBuffer >> 6); *dst++ = make_16bit(rgbBuffer << 4); } ptr += stride; } break; case 8: case 12: case 16: if (source_packet_size == target_packet_size) { for (x = 0; x < avctx->height; x++) { memcpy(ptr, buf, target_packet_size*avctx->width); ptr += stride; buf += source_packet_size*avctx->width; } } else { for (x = 0; x < avctx->height; x++) { uint8_t *dst = ptr; for (y = 0; y < avctx->width; y++) { memcpy(dst, buf, target_packet_size); dst += target_packet_size; buf += source_packet_size; } ptr += stride; } } break; } *picture = s->picture; *data_size = sizeof(AVPicture); return buf_size; }
1threat
Will it be possible to annotate lambda expression in Java 9? : <p><a href="https://stackoverflow.com/questions/22375891/annotating-the-functional-interface-of-a-lambda-expression">This question</a> is now over 3 years old and specifically addressed Java 8, with the accepted answer also citing the <a href="http://download.oracle.com/otndocs/jcp/java_se-8-fr-eval-spec/index.html" rel="noreferrer">Java SE 8 Final Specification</a>.</p> <p>I would be interested if something regarding this question will change in Java 9: Is there any way to annotate a lambda expression similar to annotating a corresponding anonymous class?</p> <hr> <p><strong>Example:</strong></p> <p>Annotation:</p> <pre><code>@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE_USE) public @interface MyTypeAnnotation { public String value(); } </code></pre> <p>Working annotation of anonymous class:</p> <pre><code>Consumer&lt;String&gt; consumer = new @MyTypeAnnotation("Hello ") Consumer&lt;String&gt;() { @Override public void accept(String str) { System.out.println(str); } }; </code></pre> <p>Annotating a lamba expression, currently not working in Java 8:</p> <pre><code>Consumer&lt;String&gt; myAnnotatedConsumer = @MyTypeAnnotation("Hello") (p -&gt; System.out.println(p)); </code></pre>
0debug
static uint64_t pxa2xx_ssp_read(void *opaque, hwaddr addr, unsigned size) { PXA2xxSSPState *s = (PXA2xxSSPState *) opaque; uint32_t retval; switch (addr) { case SSCR0: return s->sscr[0]; case SSCR1: return s->sscr[1]; case SSPSP: return s->sspsp; case SSTO: return s->ssto; case SSITR: return s->ssitr; case SSSR: return s->sssr | s->ssitr; case SSDR: if (!s->enable) return 0xffffffff; if (s->rx_level < 1) { printf("%s: SSP Rx Underrun\n", __FUNCTION__); return 0xffffffff; } s->rx_level --; retval = s->rx_fifo[s->rx_start ++]; s->rx_start &= 0xf; pxa2xx_ssp_fifo_update(s); return retval; case SSTSA: return s->sstsa; case SSRSA: return s->ssrsa; case SSTSS: return 0; case SSACD: return s->ssacd; default: printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr); break; } return 0; }
1threat
Complier cannot find .h files (code blocks) : Hey all I am trying to include a few libraries in code blocks, however when I add the path of the .h files to the search directory, it only seems to identify the ones in the main file and I think that is due to the fact that in the main file they are included as such (for example) #include "qtcpsocket.h", whereas in the .h file they are included as (for example) #include <QtNetwork/qabstractsocket.h>. Apart from the fact that one includes the folder in which it is located, what is the major different? Why it may not work? and what do it need to do to change it? one more thing i'm sure the file are in the folder. Here are a few code snippets if this helps [location of file[\]\[1\]][1] [enter image description here][2] [2]: [https://i.stack.imgur.com/5Odpe.jpg][2] [1]: https://i.stack.imgur.com/8oEpl.jpg [2]: https://i.stack.imgur.com/EXz9j.jpg
0debug
void virtio_scsi_dataplane_notify(VirtIODevice *vdev, VirtIOSCSIReq *req) { if (virtio_should_notify(vdev, req->vq)) { event_notifier_set(virtio_queue_get_guest_notifier(req->vq)); } }
1threat
how to remove all + sign from array using jquery : i have `array` like this, i want to remove `+` sign only from the below `array` var arr = ['+(91)-80-411311015','+(91)-80-411311456','+(91)-80-411311016']; i have tried this but not working var toRemove = "+"; arr = arr.filter(function(el){ return !toRemove.includes(el); }); my question is how to remove all `+` sign from the `array` thanks alot in advance
0debug
int ff_ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile) { int mbn, blk, num_blocks, num_coeffs, blk_size, scan_pos, run, val, pos, is_intra, mc_type, mv_x, mv_y, col_mask; uint8_t col_flags[8]; int32_t prev_dc, trvec[64]; uint32_t cbp, sym, lo, hi, quant, buf_offs, q; IVIMbInfo *mb; RVMapDesc *rvmap = band->rv_map; void (*mc_with_delta_func)(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type); void (*mc_no_delta_func) (int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type); const uint16_t *base_tab; const uint8_t *scale_tab; prev_dc = 0; blk_size = band->blk_size; col_mask = blk_size - 1; num_blocks = (band->mb_size != blk_size) ? 4 : 1; num_coeffs = blk_size * blk_size; if (blk_size == 8) { mc_with_delta_func = ff_ivi_mc_8x8_delta; mc_no_delta_func = ff_ivi_mc_8x8_no_delta; } else { mc_with_delta_func = ff_ivi_mc_4x4_delta; mc_no_delta_func = ff_ivi_mc_4x4_no_delta; } for (mbn = 0, mb = tile->mbs; mbn < tile->num_MBs; mb++, mbn++) { is_intra = !mb->type; cbp = mb->cbp; buf_offs = mb->buf_offs; quant = av_clip(band->glob_quant + mb->q_delta, 0, 23); base_tab = is_intra ? band->intra_base : band->inter_base; scale_tab = is_intra ? band->intra_scale : band->inter_scale; if (scale_tab) quant = scale_tab[quant]; if (!is_intra) { mv_x = mb->mv_x; mv_y = mb->mv_y; if (!band->is_halfpel) { mc_type = 0; } else { mc_type = ((mv_y & 1) << 1) | (mv_x & 1); mv_x >>= 1; mv_y >>= 1; } } for (blk = 0; blk < num_blocks; blk++) { if (blk & 1) { buf_offs += blk_size; } else if (blk == 2) { buf_offs -= blk_size; buf_offs += blk_size * band->pitch; } if (cbp & 1) { scan_pos = -1; memset(trvec, 0, num_coeffs*sizeof(trvec[0])); memset(col_flags, 0, sizeof(col_flags)); while (scan_pos <= num_coeffs) { sym = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1); if (sym == rvmap->eob_sym) break; if (sym == rvmap->esc_sym) { run = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1) + 1; lo = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1); hi = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1); val = IVI_TOSIGNED((hi << 6) | lo); } else { if (sym >= 256U) { av_log(NULL, AV_LOG_ERROR, "Invalid sym encountered: %d.\n", sym); return -1; } run = rvmap->runtab[sym]; val = rvmap->valtab[sym]; } scan_pos += run; if (scan_pos >= num_coeffs) break; pos = band->scan[scan_pos]; if (!val) av_dlog(NULL, "Val = 0 encountered!\n"); q = (base_tab[pos] * quant) >> 9; if (q > 1) val = val * q + FFSIGN(val) * (((q ^ 1) - 1) >> 1); trvec[pos] = val; col_flags[pos & col_mask] |= !!val; } if (scan_pos >= num_coeffs && sym != rvmap->eob_sym) return -1; if (is_intra && band->is_2d_trans) { prev_dc += trvec[0]; trvec[0] = prev_dc; col_flags[0] |= !!prev_dc; } band->inv_transform(trvec, band->buf + buf_offs, band->pitch, col_flags); if (!is_intra) mc_with_delta_func(band->buf + buf_offs, band->ref_buf + buf_offs + mv_y * band->pitch + mv_x, band->pitch, mc_type); } else { if (is_intra && band->dc_transform) { band->dc_transform(&prev_dc, band->buf + buf_offs, band->pitch, blk_size); } else mc_no_delta_func(band->buf + buf_offs, band->ref_buf + buf_offs + mv_y * band->pitch + mv_x, band->pitch, mc_type); } cbp >>= 1; } } align_get_bits(gb); return 0; }
1threat
static int xen_domain_watcher(void) { int qemu_running = 1; int fd[2], i, n, rc; char byte; if (pipe(fd) != 0) { qemu_log("%s: Huh? pipe error: %s\n", __FUNCTION__, strerror(errno)); return -1; } if (fork() != 0) return 0; n = getdtablesize(); for (i = 3; i < n; i++) { if (i == fd[0]) continue; if (i == xen_xc) continue; close(i); } signal(SIGINT, SIG_IGN); signal(SIGTERM, SIG_IGN); while (qemu_running) { rc = read(fd[0], &byte, 1); switch (rc) { case -1: if (errno == EINTR) continue; qemu_log("%s: Huh? read error: %s\n", __FUNCTION__, strerror(errno)); qemu_running = 0; break; case 0: qemu_running = 0; break; default: qemu_log("%s: Huh? data on the watch pipe?\n", __FUNCTION__); break; } } qemu_log("%s: destroy domain %d\n", __FUNCTION__, xen_domid); xc_domain_destroy(xen_xc, xen_domid); _exit(0); }
1threat
static int swf_probe(AVProbeData *p) { if (p->buf_size <= 16) return 0; if ((p->buf[0] == 'F' || p->buf[0] == 'C') && p->buf[1] == 'W' && p->buf[2] == 'S') return AVPROBE_SCORE_MAX; else return 0; }
1threat
static inline int svq3_mc_dir(SVQ3Context *s, int size, int mode, int dir, int avg) { int i, j, k, mx, my, dx, dy, x, y; const int part_width = ((size & 5) == 4) ? 4 : 16 >> (size & 1); const int part_height = 16 >> ((unsigned)(size + 1) / 3); const int extra_width = (mode == PREDICT_MODE) ? -16 * 6 : 0; const int h_edge_pos = 6 * (s->h_edge_pos - part_width) - extra_width; const int v_edge_pos = 6 * (s->v_edge_pos - part_height) - extra_width; for (i = 0; i < 16; i += part_height) for (j = 0; j < 16; j += part_width) { const int b_xy = (4 * s->mb_x + (j >> 2)) + (4 * s->mb_y + (i >> 2)) * s->b_stride; int dxy; x = 16 * s->mb_x + j; y = 16 * s->mb_y + i; k = (j >> 2 & 1) + (i >> 1 & 2) + (j >> 1 & 4) + (i & 8); if (mode != PREDICT_MODE) { svq3_pred_motion(s, k, part_width >> 2, dir, 1, &mx, &my); } else { mx = s->next_pic->motion_val[0][b_xy][0] << 1; my = s->next_pic->motion_val[0][b_xy][1] << 1; if (dir == 0) { mx = mx * s->frame_num_offset / s->prev_frame_num_offset + 1 >> 1; my = my * s->frame_num_offset / s->prev_frame_num_offset + 1 >> 1; } else { mx = mx * (s->frame_num_offset - s->prev_frame_num_offset) / s->prev_frame_num_offset + 1 >> 1; my = my * (s->frame_num_offset - s->prev_frame_num_offset) / s->prev_frame_num_offset + 1 >> 1; } } mx = av_clip(mx, extra_width - 6 * x, h_edge_pos - 6 * x); my = av_clip(my, extra_width - 6 * y, v_edge_pos - 6 * y); if (mode == PREDICT_MODE) { dx = dy = 0; } else { dy = get_interleaved_se_golomb(&s->gb_slice); dx = get_interleaved_se_golomb(&s->gb_slice); if (dx != (int16_t)dx || dy != (int16_t)dy) { av_log(s->avctx, AV_LOG_ERROR, "invalid MV vlc\n"); return -1; } } if (mode == THIRDPEL_MODE) { int fx, fy; mx = (mx + 1 >> 1) + dx; my = (my + 1 >> 1) + dy; fx = (unsigned)(mx + 0x30000) / 3 - 0x10000; fy = (unsigned)(my + 0x30000) / 3 - 0x10000; dxy = (mx - 3 * fx) + 4 * (my - 3 * fy); svq3_mc_dir_part(s, x, y, part_width, part_height, fx, fy, dxy, 1, dir, avg); mx += mx; my += my; } else if (mode == HALFPEL_MODE || mode == PREDICT_MODE) { mx = (unsigned)(mx + 1 + 0x30000) / 3 + dx - 0x10000; my = (unsigned)(my + 1 + 0x30000) / 3 + dy - 0x10000; dxy = (mx & 1) + 2 * (my & 1); svq3_mc_dir_part(s, x, y, part_width, part_height, mx >> 1, my >> 1, dxy, 0, dir, avg); mx *= 3; my *= 3; } else { mx = (unsigned)(mx + 3 + 0x60000) / 6 + dx - 0x10000; my = (unsigned)(my + 3 + 0x60000) / 6 + dy - 0x10000; svq3_mc_dir_part(s, x, y, part_width, part_height, mx, my, 0, 0, dir, avg); mx *= 6; my *= 6; } if (mode != PREDICT_MODE) { int32_t mv = pack16to32(mx, my); if (part_height == 8 && i < 8) { AV_WN32A(s->mv_cache[dir][scan8[k] + 1 * 8], mv); if (part_width == 8 && j < 8) AV_WN32A(s->mv_cache[dir][scan8[k] + 1 + 1 * 8], mv); } if (part_width == 8 && j < 8) AV_WN32A(s->mv_cache[dir][scan8[k] + 1], mv); if (part_width == 4 || part_height == 4) AV_WN32A(s->mv_cache[dir][scan8[k]], mv); } fill_rectangle(s->cur_pic->motion_val[dir][b_xy], part_width >> 2, part_height >> 2, s->b_stride, pack16to32(mx, my), 4); } return 0; }
1threat
Writing a numpy matrix to a text file : I am trying to write a numpy array to a text file. But it deos not work. My problem follows. I am trying to get the RGB pixel values of a picture using `matplotlib.image` and save the values obtained from my program to some file for future use. The values are returned in the form of an array, which I tried to write to a text file using the following code. But the file does not open. Nor does it show an error message. import matplotlib.pyplot as plt import matplotlib.image as mpimg import numpy as np img=mpimg.imread('kitten5.jpeg') print(img) f=open('kitten.dat','w') f.write(img) f.close() imgplot=plt.imshow(img) plt.show() Can someone help? It is not mandatory that the data has to be saved to a text file alone. Other suggestions are equally welcome.
0debug
How can i cat all txt files to terminal using python? : <p>I want to cat txt files from a folder and cat results should be shown in terminal (Obviously). I have tried using listdir() it but it doesn't work. Required some help!</p>
0debug
static inline void yuv2yuvXinC(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize, int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize, uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW) { int i; for (i=0; i<dstW; i++) { int val=1<<18; int j; for (j=0; j<lumFilterSize; j++) val += lumSrc[j][i] * lumFilter[j]; dest[i]= av_clip_uint8(val>>19); } if (uDest) for (i=0; i<chrDstW; i++) { int u=1<<18; int v=1<<18; int j; for (j=0; j<chrFilterSize; j++) { u += chrSrc[j][i] * chrFilter[j]; v += chrSrc[j][i + 2048] * chrFilter[j]; } uDest[i]= av_clip_uint8(u>>19); vDest[i]= av_clip_uint8(v>>19); } }
1threat
how to make spectrum color button/ color picker button : <p>I need to build a button that will display color spectrum onclick, and by clicking on a spot inside the color spectum, the spot color will be picked and the text color will change according to the picked color.</p> <p>This is kind of what I need</p> <p><a href="https://i.stack.imgur.com/HdPGj.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HdPGj.jpg" alt="enter image description here"></a></p> <p>Thanks in advance</p> <p>p.s Spectrum color area need to accessible with keyboard as well.</p>
0debug
String in to list Python : <p>I have a string, something like:</p> <pre><code>a = "[1, 2, 3]" </code></pre> <p>If there an easy way to convert it in to a list, without using .split(), join() etc.</p> <p>Thanks for any replies.</p>
0debug
static int rm_assemble_video_frame(AVFormatContext *s, RMContext *rm, AVPacket *pkt, int len) { ByteIOContext *pb = &s->pb; int hdr, seq, pic_num, len2, pos; int type; int ssize; hdr = get_byte(pb); len--; type = hdr >> 6; switch(type){ case 0: case 2: seq = get_byte(pb); len--; len2 = get_num(pb, &len); pos = get_num(pb, &len); pic_num = get_byte(pb); len--; rm->remaining_len = len; break; case 1: seq = get_byte(pb); len--; if(av_new_packet(pkt, len + 9) < 0) return AVERROR(EIO); pkt->data[0] = 0; AV_WL32(pkt->data + 1, 1); AV_WL32(pkt->data + 5, 0); get_buffer(pb, pkt->data + 9, len); rm->remaining_len = 0; return 0; case 3: len2 = get_num(pb, &len); pos = get_num(pb, &len); pic_num = get_byte(pb); len--; rm->remaining_len = len - len2; if(av_new_packet(pkt, len2 + 9) < 0) return AVERROR(EIO); pkt->data[0] = 0; AV_WL32(pkt->data + 1, 1); AV_WL32(pkt->data + 5, 0); get_buffer(pb, pkt->data + 9, len2); return 0; } if((seq & 0x7F) == 1 || rm->curpic_num != pic_num){ rm->slices = ((hdr & 0x3F) << 1) + 1; ssize = len2 + 8*rm->slices + 1; rm->videobuf = av_realloc(rm->videobuf, ssize); rm->videobufsize = ssize; rm->videobufpos = 8*rm->slices + 1; rm->cur_slice = 0; rm->curpic_num = pic_num; rm->pktpos = url_ftell(pb); } if(type == 2){ len = FFMIN(len, pos); pos = len2 - pos; } if(++rm->cur_slice > rm->cur_slice) return 1; AV_WL32(rm->videobuf - 7 + 8*rm->cur_slice, 1); AV_WL32(rm->videobuf - 3 + 8*rm->cur_slice, rm->videobufpos - 8*rm->slices - 1); if(rm->videobufpos + len > rm->videobufsize) return 1; if (get_buffer(pb, rm->videobuf + rm->videobufpos, len) != len) return AVERROR(EIO); rm->videobufpos += len, rm->remaining_len-= len; if(type == 2 || (rm->videobufpos) == rm->videobufsize){ memmove(rm->videobuf + 1 + 8*rm->cur_slice, rm->videobuf + 1 + 8*rm->slices, rm->videobufsize - 1 - 8*rm->slices); ssize = rm->videobufsize - 8*(rm->slices - rm->cur_slice); rm->videobuf[0] = rm->cur_slice-1; if(av_new_packet(pkt, ssize) < 0) return AVERROR(ENOMEM); memcpy(pkt->data, rm->videobuf, ssize); pkt->pts = AV_NOPTS_VALUE; pkt->pos = rm->pktpos; return 0; } return 1; }
1threat
static int xenfb_map_fb(struct XenFB *xenfb) { struct xenfb_page *page = xenfb->c.page; char *protocol = xenfb->c.xendev.protocol; int n_fbdirs; unsigned long *pgmfns = NULL; unsigned long *fbmfns = NULL; void *map, *pd; int mode, ret = -1; pd = page->pd; mode = sizeof(unsigned long) * 8; if (!protocol) { uint32_t *ptr32 = NULL; uint32_t *ptr64 = NULL; #if defined(__i386__) ptr32 = (void*)page->pd; ptr64 = ((void*)page->pd) + 4; #elif defined(__x86_64__) ptr32 = ((void*)page->pd) - 4; ptr64 = (void*)page->pd; #endif if (ptr32) { if (ptr32[1] == 0) { mode = 32; pd = ptr32; } else { mode = 64; pd = ptr64; } } #if defined(__x86_64__) } else if (strcmp(protocol, XEN_IO_PROTO_ABI_X86_32) == 0) { mode = 32; pd = ((void*)page->pd) - 4; #elif defined(__i386__) } else if (strcmp(protocol, XEN_IO_PROTO_ABI_X86_64) == 0) { mode = 64; pd = ((void*)page->pd) + 4; #endif } if (xenfb->pixels) { munmap(xenfb->pixels, xenfb->fbpages * XC_PAGE_SIZE); xenfb->pixels = NULL; } xenfb->fbpages = (xenfb->fb_len + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE; n_fbdirs = xenfb->fbpages * mode / 8; n_fbdirs = (n_fbdirs + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE; pgmfns = g_malloc0(sizeof(unsigned long) * n_fbdirs); fbmfns = g_malloc0(sizeof(unsigned long) * xenfb->fbpages); xenfb_copy_mfns(mode, n_fbdirs, pgmfns, pd); map = xc_map_foreign_pages(xen_xc, xenfb->c.xendev.dom, PROT_READ, pgmfns, n_fbdirs); if (map == NULL) goto out; xenfb_copy_mfns(mode, xenfb->fbpages, fbmfns, map); munmap(map, n_fbdirs * XC_PAGE_SIZE); xenfb->pixels = xc_map_foreign_pages(xen_xc, xenfb->c.xendev.dom, PROT_READ | PROT_WRITE, fbmfns, xenfb->fbpages); if (xenfb->pixels == NULL) goto out; ret = 0; out: g_free(pgmfns); g_free(fbmfns); return ret; }
1threat
static int block_crypto_open_generic(QCryptoBlockFormat format, QemuOptsList *opts_spec, BlockDriverState *bs, QDict *options, int flags, Error **errp) { BlockCrypto *crypto = bs->opaque; QemuOpts *opts = NULL; Error *local_err = NULL; int ret = -EINVAL; QCryptoBlockOpenOptions *open_opts = NULL; unsigned int cflags = 0; bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, false, errp); if (!bs->file) { return -EINVAL; } opts = qemu_opts_create(opts_spec, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (local_err) { error_propagate(errp, local_err); goto cleanup; } open_opts = block_crypto_open_opts_init(format, opts, errp); if (!open_opts) { goto cleanup; } if (flags & BDRV_O_NO_IO) { cflags |= QCRYPTO_BLOCK_OPEN_NO_IO; } crypto->block = qcrypto_block_open(open_opts, block_crypto_read_func, bs, cflags, errp); if (!crypto->block) { ret = -EIO; goto cleanup; } bs->encrypted = true; bs->valid_key = true; ret = 0; cleanup: qapi_free_QCryptoBlockOpenOptions(open_opts); return ret; }
1threat
pyspark: ValueError: Some of types cannot be determined after inferring : <p>I have a pandas data frame <code>my_df</code>, and <code>my_df.dtypes</code> gives us:</p> <pre><code>ts int64 fieldA object fieldB object fieldC object fieldD object fieldE object dtype: object </code></pre> <p>Then I am trying to convert the pandas data frame <code>my_df</code> to a spark data frame by doing below:</p> <pre><code>spark_my_df = sc.createDataFrame(my_df) </code></pre> <p>However, I got the following errors:</p> <pre><code>ValueErrorTraceback (most recent call last) &lt;ipython-input-29-d4c9bb41bb1e&gt; in &lt;module&gt;() ----&gt; 1 spark_my_df = sc.createDataFrame(my_df) 2 spark_my_df.take(20) /usr/local/spark-latest/python/pyspark/sql/session.py in createDataFrame(self, data, schema, samplingRatio) 520 rdd, schema = self._createFromRDD(data.map(prepare), schema, samplingRatio) 521 else: --&gt; 522 rdd, schema = self._createFromLocal(map(prepare, data), schema) 523 jrdd = self._jvm.SerDeUtil.toJavaArray(rdd._to_java_object_rdd()) 524 jdf = self._jsparkSession.applySchemaToPythonRDD(jrdd.rdd(), schema.json()) /usr/local/spark-latest/python/pyspark/sql/session.py in _createFromLocal(self, data, schema) 384 385 if schema is None or isinstance(schema, (list, tuple)): --&gt; 386 struct = self._inferSchemaFromList(data) 387 if isinstance(schema, (list, tuple)): 388 for i, name in enumerate(schema): /usr/local/spark-latest/python/pyspark/sql/session.py in _inferSchemaFromList(self, data) 318 schema = reduce(_merge_type, map(_infer_schema, data)) 319 if _has_nulltype(schema): --&gt; 320 raise ValueError("Some of types cannot be determined after inferring") 321 return schema 322 ValueError: Some of types cannot be determined after inferring </code></pre> <p>Does anyone know what the above error mean? Thanks!</p>
0debug
static void add_bytes_l2_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w) { long i; for (i = 0; i <= w - sizeof(long); i += sizeof(long)) { long a = *(long *)(src1 + i); long b = *(long *)(src2 + i); *(long *)(dst + i) = ((a & pb_7f) + (b & pb_7f)) ^ ((a ^ b) & pb_80); } for (; i < w; i++) dst[i] = src1[i] + src2[i]; }
1threat
How to initialize a char member variable of a class? : <p>I am having trouble assigning value to a character class member:</p> <pre><code>class Node { public: char c; }; void main(void) { Node *node; node-&gt;c = 'a'; } </code></pre>
0debug
typings vs @types NPM scope : <p>In some cases <code>typings</code> is used for handling TypeScript definitions (e.g. <a href="https://github.com/angular/angular2-seed">angular/angular2-seed</a>).</p> <p>In other cases scoped NPM <code>@types</code> packages are used with no <code>typings</code> involved (e.g. <a href="https://github.com/AngularClass/angular2-webpack-starter">AngularClass/angular2-webpack-starter</a>).</p> <p>What are the practical differences between them? Does one of them offer benefits for TypeScript development that the other doesn't?</p>
0debug
Vector Drawable VS PNG : <p>What is Vector Drawable? How it differs from PNG? Is it possible to convert an PNG to vector Drawable in Android?</p> <p>Below is the one vector Drawable, I have created in Studio.</p> <pre><code>&lt;vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportHeight="24.0" android:viewportWidth="24.0"&gt; &lt;path android:fillColor="#FF000000" android:pathData="M22,16V4c0,-1.1 -0.9,-2 -2,-2H8c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2zm-11,-4l2.03,2.71L16,11l4,5H8l3,-4zM2,6v14c0,1.1 0.9,2 2,2h14v-2H4V6H2z" /&gt; &lt;/vector&gt; </code></pre> <p>What is the path data here?? How can I get that for PNG?</p>
0debug
START_TEST(qint_destroy_test) { QInt *qi = qint_from_int(0); QDECREF(qi); }
1threat
Illegal Characters in Path for XSLT Tranformation : <p>I am writing an XSLT transformation to translate a XML credit report. </p> <p>When I run the following code I am getting "Illegal Characters in Path" error. Not sure what I am missing. I want this method to return a HTML string.</p> <p>I have tested the XSLT transform on the XML and it works. This code fails on the transform.Load function with the "Illegal Characters in Path" error. </p> <p>What am I missing here?</p> <pre><code> private string FormatCreditReport(string inputXml) { var xsltTransform = new XslCompiledTransform(); var webRootPath = HostingEnvironment.ApplicationPhysicalPath; var path = webRootPath + "XSLT_Stylesheets" + Path.DirectorySeparatorChar + "CreditReportTransform.xslt"; var xsltTemplate = File.ReadAllText(path); xsltTransform.Load(xsltTemplate); StringWriter results = new StringWriter(); using (var reader = XmlReader.Create(new StringReader(inputXml))) { xsltTransform.Transform(reader, null, results); } return results.ToString(); } </code></pre> <p>XSLT Document:</p> <p></p> <pre><code>&lt;xsl:template match="/"&gt; &lt;html&gt; &lt;body&gt; &lt;table border ="1"&gt; &lt;tr&gt; &lt;th&gt;&lt;h2&gt;Credit File&lt;/h2&gt;&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;File Since Date&lt;/td&gt; &lt;td&gt;&lt;xsl:value-of select="EfxTransmit/EfxReport/USConsumerCreditReports/USConsumerCreditReport/USHeader/CreditFile/FileSinceDate"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Date of Last Activity&lt;/td&gt; &lt;td&gt;&lt;xsl:value-of select="EfxTransmit/EfxReport/USConsumerCreditReports/USConsumerCreditReport/USHeader/CreditFile/DateOfLastActivity"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Date of Request&lt;/td&gt; &lt;td&gt;&lt;xsl:value-of select="EfxTransmit/EfxReport/USConsumerCreditReports/USConsumerCreditReport/USHeader/CreditFile/DateOfRequest"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;/tr&gt; &lt;tr&gt; &lt;th&gt;&lt;h2&gt;Subject&lt;/h2&gt;&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Last Name&lt;/td&gt; &lt;td&gt;&lt;xsl:value-of select="EfxTransmit/EfxReport/USConsumerCreditReports/USConsumerCreditReport/USHeader/Subject/LastName"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; &lt;/xsl:template&gt; </code></pre> <p></p>
0debug
Can i use Meteor.js WITHOUT any React and Angular and Blaze? I want use my own library : <p>Can i use Meteor.js <strong>WITHOUT</strong> any React and Angular and Blaze? I want use my own library</p>
0debug
Is there a way to change the CSS resize corner's position? : <p>So this is a bit of a strange question. Programming a web application with a resizable div. I'm using the CSS resize property at the moment as it seemed like it was the easiest way to do it. The problem is my box has a locked bottom and left position (which I want to maintain), but the resize corner chosen by default is the lower right one, which produces weird results for resizing the top. Looked around online but couldn't find a way to move that corner to the upper right instead of the bottom right. Any advice on how to produce this result? Also not opposed to using a different method of resizing. Here's the current style being applied to the box:</p> <pre><code>display: block; font-size: 9pt; position: absolute; bottom: 50px; left: 20px; padding: 10px; min-height: 0; min-width: 0; border: solid 1px black; width:400px; height:400px; resize: both; overflow-x: auto; overflow-y: hidden; </code></pre> <p>And here's a picture of the div in question with the corner that currently has the resize tool on it boxed. Any advice would be greatly appreciated. I'm more than happy to elaborate on things I might've missed as well. Thanks! </p> <p><a href="http://i.stack.imgur.com/rxa8R.png" rel="noreferrer">Box I want to resize in question</a></p>
0debug
var result = string.split('').forEach(...); Doesn't work in JavaScript : <p>In Javascript, why is result below <code>undefined</code>? </p> <pre><code>var x = "happy"; var result = x.split('').forEach(function(val,index,array){ array[index] = "0"; }); console.log(result); </code></pre> <p>The output is:</p> <pre><code>undefined </code></pre>
0debug
How to fix problem with double T[] - result NullPointerException : I'm doing a program that uses the divide and conquer methods. Unfortunately, I can not use the "find" method. I have no idea what to do instead of null in this line: "find (null, 0, 100, 34)". Thank you in advance. public class Main { static int find (double T[], int left, int right, double numToSearch) { if(left <= right) { int middle = (left + right)/2; if(T[middle]==numToSearch) { return middle; } if(T[middle]<numToSearch) { return find(T, middle+1, right, numToSearch); } return find(T, left, middle-1, numToSearch); } return -1; } public static void main(String[] args) { System.out.println(find(null(OR WHAT HERE TO MAKE IT WORK), 0, 100, 34)); }
0debug
static void tcx_invalidate_cursor_position(TCXState *s) { int ymin, ymax, start, end; ymin = s->cursy; if (ymin >= s->height) { return; } ymax = MIN(s->height, ymin + 32); start = ymin * 1024; end = ymax * 1024; memory_region_set_dirty(&s->vram_mem, start, end-start); }
1threat
Is it possible to bring the variable value even if is there some mismatch in variable in ruby : <pre><code>variable_123_abc = 20 </code></pre> <p>If I search with variable_345_abc it should bring the value 20 is it possible in ruby?</p>
0debug
static int scsi_disk_emulate_mode_sense(SCSIDiskReq *r, uint8_t *outbuf) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); uint64_t nb_sectors; int page, dbd, buflen, ret, page_control; uint8_t *p; uint8_t dev_specific_param; dbd = r->req.cmd.buf[1] & 0x8; page = r->req.cmd.buf[2] & 0x3f; page_control = (r->req.cmd.buf[2] & 0xc0) >> 6; DPRINTF("Mode Sense(%d) (page %d, xfer %zd, page_control %d)\n", (r->req.cmd.buf[0] == MODE_SENSE) ? 6 : 10, page, r->req.cmd.xfer, page_control); memset(outbuf, 0, r->req.cmd.xfer); p = outbuf; if (bdrv_is_read_only(s->qdev.conf.bs)) { dev_specific_param = 0x80; } else { dev_specific_param = 0x00; } if (r->req.cmd.buf[0] == MODE_SENSE) { p[1] = 0; p[2] = dev_specific_param; p[3] = 0; p += 4; } else { p[2] = 0; p[3] = dev_specific_param; p[6] = p[7] = 0; p += 8; } bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors); if (!dbd && s->qdev.type == TYPE_DISK && nb_sectors) { if (r->req.cmd.buf[0] == MODE_SENSE) { outbuf[3] = 8; } else { outbuf[7] = 8; } nb_sectors /= (s->qdev.blocksize / 512); if (nb_sectors > 0xffffff) { nb_sectors = 0; } p[0] = 0; p[1] = (nb_sectors >> 16) & 0xff; p[2] = (nb_sectors >> 8) & 0xff; p[3] = nb_sectors & 0xff; p[4] = 0; p[5] = 0; p[6] = s->qdev.blocksize >> 8; p[7] = 0; p += 8; } if (page_control == 3) { scsi_check_condition(r, SENSE_CODE(SAVING_PARAMS_NOT_SUPPORTED)); return -1; } if (page == 0x3f) { for (page = 0; page <= 0x3e; page++) { mode_sense_page(s, page, &p, page_control); } } else { ret = mode_sense_page(s, page, &p, page_control); if (ret == -1) { return -1; } } buflen = p - outbuf; if (r->req.cmd.buf[0] == MODE_SENSE) { outbuf[0] = buflen - 1; } else { outbuf[0] = ((buflen - 2) >> 8) & 0xff; outbuf[1] = (buflen - 2) & 0xff; } if (buflen > r->req.cmd.xfer) { buflen = r->req.cmd.xfer; } return buflen; }
1threat
Typescript: Property 'src' does not exist on type 'HTMLElement' : <p>I get a error from Typescript and I am not sure how to correct it. The code works fine when "compiled" but I can't correct the error. I have extracted the parts that involve the error from my code. I guess I have to predifine the src but not sure how.</p> <p>Error msg in Editor and on Gulp compile: </p> <p><strong><em>"Property 'src' does not exist on type 'HTMLElement'.at line 53 col 17"</em></strong></p> <pre><code>... element:HTMLElement; /* Defining element */ ''' this.element = document.createElement('img'); /*creating a img*/ ''' </code></pre> <p>This is the method I run to render the element, position, top and left all works with out giving a error. </p> <pre><code>display() { this.element.src = this.file; /*This is the line that gives the error*/ this.element.style.position = "absolute"; this.element.style.top = this.pointX.toString() + "px"; this.element.style.left = this.pointY.toString() + "px"; document.body.appendChild(this.element); }; </code></pre>
0debug
Regex for nested pattern : <p>I have a pattern like this:</p> <pre><code>#alphanumericX(anythingY){ anythingZ }# </code></pre> <p>It can be nested like this:</p> <pre><code>#alphanumeric1(anything1){ #alphanumericX(anythingY){ anythingZ }# }# </code></pre> <p>Or like this:</p> <pre><code>#alphanumeric1(anything1){ anything2 #alphanumericX(anythingY){ anythingZ }# }# </code></pre> <p>The patterns can be written not just once, but multiple like this:</p> <pre><code>#alphanumericX(anythingY){ anythingZ }# #alphanumeric1(anything1){ anything1 }# </code></pre> <p>I want a regex to match the the patterns above, so it will return like this:</p> <pre><code>#alphanumericX(anythingY){ anythingZ }# </code></pre> <p>How to achieve that?</p> <p>Here is my current regex: <code>/#(.*?)\((.*?)\)\{(.*?)\}#/sm</code></p>
0debug
NullReferenceException on DevExpress 16.2.1 XtraReport generation via ReportService on WebForms : <p>When using <code>ReportService</code> as report provider for <code>AspxDocumentViewer</code> in <em>DevExpress 2016 ver.1.2</em> <code>"Object reference not set to an instance of an object"</code> is shown as JS alert in browser when trying to show report.</p> <p>Caught internal exception has next info:</p> <pre><code>Object reference not set to an instance of an object. at DevExpress.XtraReports.Web.Native.ReportRenderHelper.GetPreparedOptions() at DevExpress.XtraReports.Web.Native.DocumentViewer.RemoteReportRenderHelper.CreatePageWebControl(IImageRepository imageRepository, Int32 pageIndex) at DevExpress.XtraReports.Web.Native.ReportRenderHelper.WritePage(Int32 pageIndex) at DevExpress.XtraReports.Web.Native.DocumentViewer.DocumentViewerReportWebRemoteMediator.&lt;&gt;c__DisplayClass2.b__1(PrintingSystemBase printingSystem) at DevExpress.XtraReports.Web.Native.DocumentViewer.DocumentViewerRemoteHelper.DoWithRemoteDocument[T](Byte[] bytes, Int32 pageIndex, Int32 pageCount, Func`2 func) at DevExpress.XtraReports.Web.Native.DocumentViewer.DocumentViewerReportWebRemoteMediator.GetPage(ReportViewer viewer, RemoteDocumentInformation documentInformation, Int32 pageIndex) at DevExpress.XtraReports.Web.Native.DocumentViewer.DocumentViewerReportViewer.CallbackRemotePage()\r\n at DevExpress.XtraReports.Web.ReportViewer.GetCallbackResult() at DevExpress.XtraReports.Web.ASPxDocumentViewer.GetCallbackResult() at DevExpress.Web.ASPxWebControl.System.Web.UI.ICallbackEventHandler.GetCallbackResult() </code></pre> <p>During small investigation 've noticed that report generation crashes after request to <code>ReportService.GetPages</code> method somewhere in inner DevExpress code. </p> <p>Pay attention, that same solution works ok using <em>DevExpress 15.2.7</em> so it's some kind of breaking changes between two versions.</p> <p>Same solution also works in current version when report is set directly to <code>AspxDocumentViewer.Report</code> (not using <code>ReportServiceClientFactory</code> and <code>ReportService</code>), so it seems to be a <code>ReportService</code> issue.</p> <p>ASP.Net WebForms application, report is as simple as possible (empty, no data usage).</p> <p>Was created <a href="https://www.devexpress.com/Support/Center/Question/Details/T418299" rel="nofollow" title="Ticket">ticket</a> on DevExpress site and it has in attach sample application to reproduce problem.</p>
0debug
C# export data from database into excel. Without any of DLL or open source dlll or any kind of free dll : <p>Please provide way to export data into excel without any DLL or free open source DLL or any kind of DLL.</p> <p>Help me programmers,</p>
0debug
av_cold void ff_mlpdsp_init_arm(MLPDSPContext *c) { int cpu_flags = av_get_cpu_flags(); if (have_armv5te(cpu_flags)) { c->mlp_filter_channel = ff_mlp_filter_channel_arm; } }
1threat
What is the connection String to connect to the DB MS SQL in web.config : my files in image [enter image description here][1] [1]: https://i.stack.imgur.com/fgK5K.jpg What is the connection String in web.config to connect to the DB MS SQL using asp.net Please help me.
0debug
Spring WebFlux (Flux): how to publish dynamically : <p>I am new to Reactive programming and Spring WebFlux. I want to make my App 1 publish Server Sent event through Flux and my App 2 listen on it continuously.</p> <p>I want Flux publish on-demand (e.g. when something happens). All the example I found is to use Flux.interval to periodically publish event, and there seems no way to append/modify the content in Flux once it is created.</p> <p>How can I achieve my goal? Or I am totally wrong conceptually.</p>
0debug
CSS: content url with "title" : I want to replace a text with URL in CSS. So far I get: .myclass { visibility: hidden; } .myclass:before { content: 'My page: ' url(http://www.myawesomepage.com) 'myawesomepage'; visibility:visible; } This is what I got: My page: myawesomepage This is what I want: My page: <a href="http://www.myawesomepage.com">myawesomepage</a> What did I wrong?
0debug
How can I run an executable and take input from a text file on Linux? : <p>How can I run an executable and take input from a text file on Linux? I was trying to use: ./(name of my executable) TextFile.txt but it does not work.</p>
0debug
Final variable in java : <pre><code> class Test { public static final int x; public static void main (String[] args) { Test.x = 42; } } </code></pre> <p>I have declared a static final variable, and when i compiled it the following error shown up.</p> <pre><code> error: cannot assign a value to final variable x Test.x = 42; </code></pre> <p>i think i have reached to the solution but i want to check if i am right or not?</p> <p>I know that a static variable if not initialized is provided a default value. As it is a static final int variable it will be assigned a value of 0. later on, i tried to change the value to 42 which is not possible because the variable is final and cannot be changed from 0.</p> <p>am i right or is there some other answer to it?</p>
0debug
static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) { Mpeg4DecContext *ctx = avctx->priv_data; MpegEncContext * const s = &ctx->m; struct vaapi_context * const vactx = avctx->hwaccel_context; VAPictureParameterBufferMPEG4 *pic_param; VAIQMatrixBufferMPEG4 *iq_matrix; int i; av_dlog(avctx, "vaapi_mpeg4_start_frame()\n"); vactx->slice_param_size = sizeof(VASliceParameterBufferMPEG4); pic_param = ff_vaapi_alloc_pic_param(vactx, sizeof(VAPictureParameterBufferMPEG4)); if (!pic_param) return -1; pic_param->vop_width = s->width; pic_param->vop_height = s->height; pic_param->forward_reference_picture = VA_INVALID_ID; pic_param->backward_reference_picture = VA_INVALID_ID; pic_param->vol_fields.value = 0; pic_param->vol_fields.bits.short_video_header = avctx->codec->id == AV_CODEC_ID_H263; pic_param->vol_fields.bits.chroma_format = CHROMA_420; pic_param->vol_fields.bits.interlaced = !s->progressive_sequence; pic_param->vol_fields.bits.obmc_disable = 1; pic_param->vol_fields.bits.sprite_enable = ctx->vol_sprite_usage; pic_param->vol_fields.bits.sprite_warping_accuracy = s->sprite_warping_accuracy; pic_param->vol_fields.bits.quant_type = s->mpeg_quant; pic_param->vol_fields.bits.quarter_sample = s->quarter_sample; pic_param->vol_fields.bits.data_partitioned = s->data_partitioning; pic_param->vol_fields.bits.reversible_vlc = ctx->rvlc; pic_param->vol_fields.bits.resync_marker_disable = !ctx->resync_marker; pic_param->no_of_sprite_warping_points = ctx->num_sprite_warping_points; for (i = 0; i < ctx->num_sprite_warping_points && i < 3; i++) { pic_param->sprite_trajectory_du[i] = ctx->sprite_traj[i][0]; pic_param->sprite_trajectory_dv[i] = ctx->sprite_traj[i][1]; } pic_param->quant_precision = s->quant_precision; pic_param->vop_fields.value = 0; pic_param->vop_fields.bits.vop_coding_type = s->pict_type - AV_PICTURE_TYPE_I; pic_param->vop_fields.bits.backward_reference_vop_coding_type = s->pict_type == AV_PICTURE_TYPE_B ? s->next_picture.f.pict_type - AV_PICTURE_TYPE_I : 0; pic_param->vop_fields.bits.vop_rounding_type = s->no_rounding; pic_param->vop_fields.bits.intra_dc_vlc_thr = mpeg4_get_intra_dc_vlc_thr(ctx); pic_param->vop_fields.bits.top_field_first = s->top_field_first; pic_param->vop_fields.bits.alternate_vertical_scan_flag = s->alternate_scan; pic_param->vop_fcode_forward = s->f_code; pic_param->vop_fcode_backward = s->b_code; pic_param->vop_time_increment_resolution = avctx->time_base.den; pic_param->num_macroblocks_in_gob = s->mb_width * ff_h263_get_gob_height(s); pic_param->num_gobs_in_vop = (s->mb_width * s->mb_height) / pic_param->num_macroblocks_in_gob; pic_param->TRB = s->pb_time; pic_param->TRD = s->pp_time; if (s->pict_type == AV_PICTURE_TYPE_B) pic_param->backward_reference_picture = ff_vaapi_get_surface_id(&s->next_picture.f); if (s->pict_type != AV_PICTURE_TYPE_I) pic_param->forward_reference_picture = ff_vaapi_get_surface_id(&s->last_picture.f); if (pic_param->vol_fields.bits.quant_type) { iq_matrix = ff_vaapi_alloc_iq_matrix(vactx, sizeof(VAIQMatrixBufferMPEG4)); if (!iq_matrix) return -1; iq_matrix->load_intra_quant_mat = 1; iq_matrix->load_non_intra_quant_mat = 1; for (i = 0; i < 64; i++) { int n = s->dsp.idct_permutation[ff_zigzag_direct[i]]; iq_matrix->intra_quant_mat[i] = s->intra_matrix[n]; iq_matrix->non_intra_quant_mat[i] = s->inter_matrix[n]; } } return 0; }
1threat
I'm novice in python programming, and i have a issue that how can i re-written SSN such that the first five numbers are hidden from view? : I want to rewrite the SSN # such that the first five numbers are hidden from view. The following csv file like the below : Emp ID,Name,DOB,SSN,State 15,Samantha Lara,1993-09-08,848-80-7526,Colorado expected data : 15,Samantha,Lara,09/08/1993,***-**-7526,CO # create a list to store the data from csv file empl_ssn = [] reform_ssn = row["3"] reform_ssn = ........ I don't know how to modify it.
0debug
Check land or water in google map Andriod : i am generating random latitude and longitude.but i am unable to find land or water for random lat and longitude.i checked with google API,i am not finding and i searched in google.but i cannot find solution.help me.i used this (https://onwater.io/users/sign_up )url.it gives only 15 request per minute.i need 50 lat and long to check whether it is land or water.
0debug
def common_prefix_util(str1, str2): result = ""; n1 = len(str1) n2 = len(str2) i = 0 j = 0 while i <= n1 - 1 and j <= n2 - 1: if (str1[i] != str2[j]): break result += str1[i] i += 1 j += 1 return (result) def common_prefix (arr, n): prefix = arr[0] for i in range (1, n): prefix = common_prefix_util(prefix, arr[i]) return (prefix)
0debug
How to prevent launchSettings.json from being created in Visual Studio 2017 : <p>VS 2017 creates a file for ASP.NET Core MVC projects, called <code>launchSettings.json</code>, which contains information about IIS Express and Kestrel AMAIK.</p> <p>We host our projects in IIS even on development machines, thus we don't really need these files.</p> <p>We delete them, yet they keep coming back and each time we open up a solution, they show up.</p> <p>Is there a way to prevent VS from creating those files?</p>
0debug
Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<int> to 'int' : Im selecting an id from an Linq query so it is an int but when i try to use it again it is giving me the error Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<int> to 'int' var costcentre = company.CompanyCostCentres.Where(cc => cc.Name.ToLower() == CostCentre.ToLower()).Select(cid => cid.CompanyCostCentreId).ToList(); if (costcentre != null) { person.PersonInCompanyCostCentres.Add (new Core.Data.PersonInCompanyCostCentre { CompanyCostCentreId = costcentre, UserId = person.UserId, CompanyId = company.CompanyId, RecordCreated = DateTime.Now, RecordModified = DateTime.Now }); }
0debug
weighting scale integration with c# winform : I want to get weighting scale value in textbox in c# windows application on button click event. i've used following code but get no result, `using System; using System.IO.Ports; //<-- necessary to use "SerialPort" using System.Windows.Forms; namespace ComPortTests { public partial class Form1 : Form { private SerialPort _serialPort; //<-- declares a SerialPort Variable to be used throughout the form private const int BaudRate = 9600; //<-- BaudRate Constant. 9600 seems to be the scale-units default value public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { string[] portNames = SerialPort.GetPortNames(); //<-- Reads all available comPorts foreach (var portName in portNames) { comboBox1.Items.Add(portName); //<-- Adds Ports to combobox } comboBox1.SelectedIndex = 0; //<-- Selects first entry (convenience purposes) } private void button1_Click(object sender, EventArgs e) { //<-- This block ensures that no exceptions happen if(_serialPort != null && _serialPort.IsOpen) _serialPort.Close(); if (_serialPort != null) _serialPort.Dispose(); //<-- End of Block _serialPort = new SerialPort(comboBox1.Text, BaudRate, Parity.None, 8, StopBits.One); //<-- Creates new SerialPort using the name selected in the combobox _serialPort.DataReceived += SerialPortOnDataReceived; //<-- this event happens everytime when new data is received by the ComPort _serialPort.Open(); //<-- make the comport listen textBox1.Text = "Listening on " + _serialPort.PortName + "...\r\n"; } private delegate void Closure(); private void SerialPortOnDataReceived(object sender, SerialDataReceivedEventArgs serialDataReceivedEventArgs) { if (InvokeRequired) //<-- Makes sure the function is invoked to work properly in the UI-Thread BeginInvoke(new Closure(() => { SerialPortOnDataReceived(sender, serialDataReceivedEventArgs); })); //<-- Function invokes itself else { while (_serialPort.BytesToRead > 0) //<-- repeats until the In-Buffer is empty { textBox1.Text += string.Format("{0:X2} ", _serialPort.ReadByte()); //<-- bytewise adds inbuffer to textbox } } } } }`
0debug
Uncaught Error: Call to undefined function : <p>It was working but now it stops working why? it soppiest to write into a file and save it. it was working yesterday but today it stops and I can't figure out why a search the internet but still nothing I can't .</p> <p>Thanks in advanced</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Contact us&lt;/title&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"&gt;&lt;/script&gt; &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" /&gt; &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;nav class="navbar navbar-default"&gt; &lt;div class="container-fluid"&gt; &lt;!-- Brand and toggle get grouped for better mobile display --&gt; &lt;div class="navbar-header"&gt; &lt;button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"&gt; &lt;span class="sr-only"&gt;Toggle navigation&lt;/span&gt; &lt;span class="icon-bar"&gt;&lt;/span&gt; &lt;span class="icon-bar"&gt;&lt;/span&gt; &lt;span class="icon-bar"&gt;&lt;/span&gt; &lt;/button&gt; &lt;/div&gt; &lt;!-- Collect the nav links, forms, and other content for toggling --&gt; &lt;div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"&gt; &lt;ul class="nav navbar-nav"&gt; &lt;li&gt;&lt;a href="aboutus.html"&gt;About US&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="contactus.php"&gt;Contact Us&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="property.php"&gt;Propertys&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt;&lt;!-- /.navbar-collapse --&gt; &lt;/div&gt;&lt;!-- /.container-fluid --&gt; &lt;/nav&gt; &lt;h1&gt;Contact us&lt;/h1&gt; &lt;form method="post" action="contactus.php" &gt; &lt;label&gt;Email&lt;/label&gt; &lt;input type="text" name="email" required&gt; &lt;br&gt; &lt;label&gt;Mobile number&lt;/label&gt; &lt;input type="number" name="number" required&gt; &lt;br&gt; &lt;textarea name="comments" required&gt;&lt;/textarea&gt; &lt;button name="submit" type="submit"&gt; submit&lt;/button&gt; &lt;/form&gt; &lt;?php if(isset($_POST['submit'])){ $number = $_POST["number"]; $email = $_POST["email"]; $trueemail; $massage = $_POST["comments"]; if(isset($number)){ if (strlen($number) == 8) { $truenumber = true; }else{ echo "Input your mobile number"; } } if(isset($email)){ if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { echo "&lt;br&gt;"; echo "Enter a valid email"; }else{ $trueemail = true; } } if($trueemail == true &amp;&amp; $truenumber == true){ writeToFile($email,$number,$massage); function writeToFile($trueemail,$truenumber,$massage) { $myfile = fopen("contectus.txt", "w") or die("Unable to open file!"); fwrite($myfile, $trueemail . PHP_EOL); fwrite($myfile, $truenumber . PHP_EOL); fwrite($myfile, $massage . PHP_EOL); fclose($myfile); } } } ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
0debug
how to populate treeview two tables using vb.net : Hello i have this two table [Department Table][1] [subDepartment table][2] then i want this result using treeview **id** **department** **category** 1 MIS System 1 MIS Networking 1 MIS Programmer 2 Audit Operations 2 Audit DS 3 HRD PA 3 HRD PayBen 3 HRD PS 3 HRD PLD 4 Acounting Sup 4 Acounting FMCG 5 Procurement NULL or like this MIS -System -Networking -Programmer AUDIT -Operations -DS HRD -PA -PayBen -PS -PLD Acounting -Sup -FMCG can please guide me thank you. im having trouble finding any solution in the internet. and im newbei in vb.net language. [1]: http://i.stack.imgur.com/DwXUN.jpg [2]: http://i.stack.imgur.com/QIICZ.jpg [3]: http://i.stack.imgur.com/zy89e.jpg
0debug
int css_do_hsch(SubchDev *sch) { SCSW *s = &sch->curr_status.scsw; PMCW *p = &sch->curr_status.pmcw; int ret; if (!(p->flags & (PMCW_FLAGS_MASK_DNV | PMCW_FLAGS_MASK_ENA))) { ret = -ENODEV; goto out; } if (((s->ctrl & SCSW_CTRL_MASK_STCTL) == SCSW_STCTL_STATUS_PEND) || (s->ctrl & (SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY | SCSW_STCTL_ALERT))) { ret = -EINPROGRESS; goto out; } if (s->ctrl & (SCSW_FCTL_HALT_FUNC | SCSW_FCTL_CLEAR_FUNC)) { ret = -EBUSY; goto out; } s->ctrl |= SCSW_FCTL_HALT_FUNC; s->ctrl &= ~SCSW_FCTL_START_FUNC; if (((s->ctrl & SCSW_CTRL_MASK_ACTL) == (SCSW_ACTL_SUBCH_ACTIVE | SCSW_ACTL_DEVICE_ACTIVE)) && ((s->ctrl & SCSW_CTRL_MASK_STCTL) == SCSW_STCTL_INTERMEDIATE)) { s->ctrl &= ~SCSW_STCTL_STATUS_PEND; } s->ctrl |= SCSW_ACTL_HALT_PEND; do_subchannel_work(sch, NULL); ret = 0; out: return ret; }
1threat
Set is not removing the duplicates : <p>I am having trouble putting a file of words into a set. I can read the file and the words go into the set but the set doesn't discard the repeated words. Here is the snippet of code that I believe is causing the problem. </p> <pre><code>using namespace std; while(readText &gt;&gt; line){ set&lt;string&gt; wordSet; wordSet.insert(line); for (std::set&lt;std::string&gt;::iterator i = wordSet.begin(); i != wordSet.end(); i++) { cout &lt;&lt; *i &lt;&lt; " "; } } </code></pre> <p>the sample file is this 1 2 2 3 4 5 5</p> <p>and the output is exactly the same</p>
0debug
Trying to move data from Google Bigquery to Blob : I am trying to move data from Google bigquery to Blob incrementally, can anyone help me with this?
0debug
Remove A string from B string : <p>I have manufacture name and a product name which has manufacture name and I want to remove manufacture name form product name, I use the following code but didn't work</p> <p>I tried both sub and replace methods but didn't work</p> <pre><code>import re menufacture_name = "AMPHENOL ICC (COMMERCIAL PRODUCTS)" product_name = "AMPHENOL ICC (COMMERCIAL PRODUCTS) - D-SUB CONNECTOR, PLUG, 9POS" // product_name = re.sub(menufacture_name + " - ", "", product_name) product_name.replace(menufacture_name + " - ", '') print("Product name : " + product_name) </code></pre> <p>This should be the result Product name : D-SUB CONNECTOR, PLUG, 9POS</p>
0debug
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
Python code : explain plz : 1. first_num = raw input ("Please input first number. ") 2. sec_num = raw input (" Please input second number:") 3 4. answer = into( first_num) +into( sec_num) 5. 6. print " Now I will add your two numbers : ", answer 7. 8. print " Pretty cool. huh ? 9 10. print " Now I'll count backwards from ",answer 11 12. counter = answer 13 14. while (counter >=0): 15. print counter 16. counter = counter-1 17 18. print. " All done !" I think the first half in a command to add first and second numbers to get sum and the second half is a command to return to start or zero out. I don't know python language. Thanks for your help.
0debug
How to correctly generate SHA-256 checksum for a string in scala? : <p>I need to generate an SHA-256 checksum from a string that will be sent as a <em>get</em> param.</p> <p>If found <a href="https://stackoverflow.com/questions/5531455/how-to-hash-some-string-with-sha256-in-java">this link</a> to generate the checksum.</p> <p>Genrating the checksum like so:</p> <pre><code> val digest = MessageDigest.getInstance("SHA-256"); private def getCheckSum() = { println(new String(digest.digest(("Some String").getBytes(StandardCharsets.UTF_8)))) } </code></pre> <p>prints checksum similar to this:</p> <pre><code>*║┼¼┬]9AòdJb:#↓o6↓T╞B5C♀¼O~╟╙àÿG </code></pre> <p>The API that we need to send this to says the checksum should look like this:</p> <pre><code>45e00158bc8454049b7208e76670466d49a5dfb2db4196 </code></pre> <p>What am I doing wrong?</p> <p>Please advise. Thanks.</p>
0debug
Effect of class_weight and sample_weight in Keras : <p>Can someone tell me mathematically how sample_weight and class_weight are used in Keras in the calculation of loss function and metrics? A simple mathematical express will be great.</p>
0debug
Remove data from list while iterating kotlin : <p>I am new to kotlin programming. What I want is that I want to remove a particular data from a list while iterating through it, but when I am doing that my app is crashing. </p> <pre><code>for ((pos, i) in listTotal!!.withIndex()) { if (pos != 0 &amp;&amp; pos != listTotal!!.size - 1) { if (paymentsAndTagsModel.tagName == i.header) { //listTotal!!.removeAt(pos) listTotal!!.remove(i) } } } </code></pre> <p>OR</p> <pre><code> for ((pos,i) in listTotal!!.listIterator().withIndex()){ if (i.header == paymentsAndTagsModel.tagName){ listTotal!!.listIterator(pos).remove() } } </code></pre> <p>The exception which I am getting</p> <pre><code>java.lang.IllegalStateException </code></pre>
0debug
SEO optimization of Angular.JS project : <p>guys! Need the help. I am developing a project on Angular and my PM asked me to perform its SEO optimization. I don`t know where to start. Can you provide me with a code example, please?</p>
0debug
Application Crashes when creating multiple tables in android studio : The Application works fine when only the first table is being created but crashes when creating multiple tables. The following is the code for my DatabaseHelper class public class DatabaseHelper extends SQLiteOpenHelper{ public static final String DATABASE_NAME = "TrainingSet.db"; //Column Names for selectLocation class table public static final String TABLE_NAME = "PrimaryLocation"; public static final String ID = "ID"; public static final String LOCATION_NAME = "LOCATION_NAME"; public static final String MAC_1 = "MAC_ADDRESS_1"; public static final String MAC_2 = "MAC_ADDRESS_2"; public static final String MAC_3 = "MAC_ADDRESS_3"; //Column Names for TrainingSet class table public static final String TABLE_NAME_TRAINING = "TrainingSet"; public static final String TRAINING_ID = "ID"; public static final String X_VALUE = "X"; public static final String Y_VALUE = "Y"; public static final String RSS_M1 = "M1"; public static final String RSS_M2 = "M2"; public static final String RSS_M3 = "M3"; public DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, 4); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE TABLE " + TABLE_NAME + " (" + ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "+ LOCATION_NAME + " TEXT, " + MAC_1 +" TEXT, "+ MAC_2 +" TEXT, "+ MAC_3 +" TEXT);"); db.execSQL("CREATE TABLE " + TABLE_NAME_TRAINING + " (" + TRAINING_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "+ X_VALUE + " INTEGER, " + Y_VALUE +" INTEGER, "+ RSS_M1 +" INTEGER, "+ RSS_M2 +" INTEGER, "+ RSS_M3 +" INTEGER, "+ ID +" INTEGER);"); //db.execSQL("create table " + TABLE_NAME_TRAINING + " (" + TRAINING_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "+ X_VALUE + " INTEGER, " + Y_VALUE +" INTEGER, "+ RSS_M1 +" INTEGER, "+ RSS_M2 +" INTEGER, "+ RSS_M3 +" INTEGER, "+ ID +" INTEGER, " + " FOREIGN KEY ("+ID+") REFERENCES "+TABLE_NAME+"("+ID+"));"); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME); db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME_TRAINING); onCreate(db); } //METHODS FOR TrainingSet class TABLES /*public boolean insertDataTraining(int x, int y, int rss_m1, int rss_m2, int rss_m3, int i){ SQLiteDatabase db = this.getWritableDatabase(); ContentValues contentValues = new ContentValues(); contentValues.put(X_VALUE, x); contentValues.put(Y_VALUE, y); contentValues.put(RSS_M1, rss_m1); contentValues.put(RSS_M2, rss_m2); contentValues.put(RSS_M3, rss_m3); contentValues.put(ID, i); long result = db.insert(TABLE_NAME_TRAINING, null, contentValues); if(result == -1) return false; else return true; } public Cursor getAllDataTraining(int i){ SQLiteDatabase db = this.getWritableDatabase(); Cursor res = db.rawQuery("SELECT " + X_VALUE + " , " + Y_VALUE + " FROM " + TABLE_NAME_TRAINING + " WHERE " + ID + " = " + i , null); return res; }*/ //METHODS FOR selectLocation class TABLES public int deleteData(int id){ SQLiteDatabase db = this.getWritableDatabase(); //delete returns the number of rows affected int res = db.delete(TABLE_NAME, "ID=?", new String[]{String.valueOf(id)}); return res; } public boolean insertData(String locationname, String mac1,String mac2, String mac3){ SQLiteDatabase db = this.getWritableDatabase(); ContentValues contentValues = new ContentValues(); contentValues.put(LOCATION_NAME, locationname); contentValues.put(MAC_1, mac1); contentValues.put(MAC_2, mac2); contentValues.put(MAC_3, mac3); long result = db.insert(TABLE_NAME, null, contentValues); if(result == -1) return false; else return true; } public Cursor getAllData(){ SQLiteDatabase db = this.getWritableDatabase(); Cursor res = db.rawQuery("select * from " + TABLE_NAME, null); return res; } } I have incremented the database version number and have also uninstalled and reinstalled the app which gives me the same error. Also I am trying to create a one to many relationship from "PrimaryLocation" table to "TrainingSet" table. For this purpose, I have added a foreign key relationship while creating the second table(which I have commented out). Is the syntax correct? Any help would be appreciated. Thanks in advance.
0debug
lambda with multiple arguments for apply function : <p>I am having following function. Here I have lambda which takes multiple arguments row and float value. While I am running I am geeting error what is the cause?</p> <pre><code>def func(): Top15 = create_frame() total_citations = Top15['Citations'].sum() ratioof_selfcitations_to_totalcitations = Top15.apply(lambda (row, total): (row['Self-citations']/total), total_citations) return ratioof_selfcitations_to_totalcitations </code></pre> <p>func</p>
0debug
what is the meaning of init method in objective c? : i am new in objective c and from java background, i want to know what is the meaning of `init()` method/function in objective c in a base class while achieving inheritance ? Is this is a kind of constructor like in java ? and is this is essential to use only `init()` method for creating and using objects? can we use other methods also instead of using `init()`. and at last why is the return type of the `init()` is `id` ?
0debug
simple Logistic regression : everyone, i tried to solve a simple linear regression problem of two-dimensional classification. Here I have a feature matrix X_expanded, which has a shape of [826,6], To classify objects we will obtain probability of object belongs to class '1'. To predict probability we will use output of linear model and logistic function. And here is the function of compute probability. def probability(X, w): """ Given input features and weights return predicted probabilities of y==1 given x, P(y=1|x), see description above Don't forget to use expand(X) function (where necessary) in this and subsequent functions. :param X: feature matrix X of shape [n_samples,6] (expanded) :param w: weight vector w of shape [6] for each of the expanded features :returns: an array of predicted probabilities in [0,1] interval. """ # TODO:<your code here> X = X_expanded m = X.shape[0] w = np.zeros((m,1)) Z = np.dot(w.T,X) P = 1./(1+np.exp(-Z)) return P For a simple test: dummy_weights = np.linspace(-1, 1, 6) ans_part1 = probability(X_expanded[:1, :], dummy_weights)[0] But it always returns array([ 0.5, 0.5, 0.5, 0.5, 0.5, 0.5]). Any Suggestion? Thank you very much.
0debug
How to provide user login with a username and NOT an email? : <p>I'd like to use Firebase for my web app that is for people with dementia in a care home. They do not have email or social network accounts so will need a simple username / password sign up / sign in.</p> <p>What is the easiest way to do this? From what I can see in the docs I'd have to use a custom auth flow but I do not have an existing auth server.</p> <p>If I do need ot do this what is the easiest way to provide the token? In Azure there is Functions and AWS has Lambda but I see nothing here is Firebase</p>
0debug
Print page without modal : <p>I have a page with a modal. One option in this modal is to print the page using <code>window.print()</code>. </p> <p>This prints the modal and not the page.</p> <p>How can I print just the page and not the modal?</p>
0debug
failed to download file from mysql server : I am new with JSP and servlets. Please help me with my problem. I have done code for uploading multiple files to MySQL database and it is successful. I have one jsp page("**filelist.jsp**") which contains all uploaded files by user. So I want to **Search** particular file using more filter options in jsp. I also tried using filtering and now it is partially completed. I have one ("**Search.jsp**") page where user searched data will be displayed. I also have "**Download**" column in my code so that user can download that file. **But the problem is that I am not able to download particular file from search.jsp page**.i am using netbeans8, tomcat 8. This is my filelist.jsp Page <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <%-- Document : filelist Created on : 22 Oct, 2019, 7:48:04 PM Author : Z0009289 --%> <%@page import="java.sql.DriverManager"%> <%@page import="java.sql.Statement"%> <%@page import="com.servlet.db.DB"%> <%@page import="java.sql.ResultSet"%> <%@page import="java.sql.PreparedStatement"%> <%@page import="java.sql.Connection"%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <% %> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link href="bootstrap.css" rel="stylesheet" type="text/css"> <title>file_list Page</title> <style> tr,td,th{ padding: 20px; text-align: center; } .container { position:"absolute"; padding: 16px 0px; top:0; right:0; display: flex; justify-content: space-between; align-items: center; } form.form-inline{ float: right; } #ddl{ width:150px; } #ddl2{ width:150px; } #cat{ width:175px; } </style> </head> <body> <!-- <form action="" method="POST"> <div class="container"> <div class="form-group"> <div class="input-group"> <input type="text" name="search" class="form-control" placeholder="Search here..." autocomplete="off"/> <button type="submit" value="Search" class="btn btn-primary">Search</button> </div> </div> </div> </form> --> <h3>Search here..</h3> <form action="logout.jsp" align="right"> <input type="submit" value="Logout"/> </form> <form name="empForm" action="search.jsp" method="post"> <div> <table border="1" colspan="2"> <thead> <tr> <th style="alignment-adjust: auto">Z ID:</th> <td><input type="text" name="zid" value="" /></td> </tr> <tr> <th>First Name :</th> <td><input type="text" name="firstname" value="" /></td> </tr> <tr> <th>Last Name:</th> <td><input type="text" name="lastname" value=""/></td> </tr> <tr style="display:none"> <th>Division:</th> <td><input type="text" name="division" value=""/></td> </tr> <tr style="display:none"> <th>Reporting Unit:</th> <td><input type="text" name="reportingunit" value=""/></td> </tr> <tr style="display:none"> <th>Document No.</th> <td><input type="text" name="documentnumber" value=""/></td> </tr> <tr style="display:none"> <th>Document Name:</th> <td><input type="text" name="documentname" value=""/></td> </tr> <tr style="display:none"> <th>Document Uploader:</th> <td><input type="text" name="documentuploader" value=""/></td> </tr> <tr style="display:none"> <th>Document Owner:</th> <td><input type="text" name="documentowner" value=""/></td> </tr> <tr> <th>Document Type</th> <td> <select name="documenttype"> <option value=""></option> <option value="Agreement">Agreement</option> <option value="Contract">Contract</option> <option value="PO">PO</option> <option value="Invoice">Invoice</option> <option value="COA">COA</option> <option value="Lease Deed">Lease Deed</option> <option value="AMC">AMC</option> <option value="Direct Material">Direct Material</option> <option value="Indirect Material/Services">Indirect Material/Services</option> </select> </td> </tr> <tr> <th>Document Category</th> <td> <select name="documentcategory" id="cat"> <option value=""></option> <option value="Customer">Customer</option> <option value="Vendor">Vendor</option> <option value="Internal">Internal</option> </select> </td> </tr> <tr style="display:none"> <th>By Function:</th> <td><input type="text" name="byfunction" value=""/></td> </tr> <tr style="display:none"> <th>Creator:</th> <td><input type="text" name="creator" value=""/></td> </tr> <tr style="display:none"> <th>Modifier:</th> <td><input type="text" name="modifier" value=""/></td> </tr> <tr style="display:none"> <th>Approver:.</th> <td><input type="text" name="approver" value=""/></td> </tr> <tr style="display:none"> <th>Mail Id:</th> <td><input type="text" name="mailid" value=""/></td> </tr> <tr style="display:none"> <th>Added Date:</th> <td><input type="text" name="added_date" value=""/></td> </tr> <tr style="display:none"> <th>Download:</th> <td><input type="text" name="download" value=""/></td> </tr> <tr> <td colspan="3" > <center> <input type="submit" value="Get File(s)" /></center> </td> </tr> </thead> </table> </div> </form> <br><br> <center> <table border="2"> <tr> <th style="width: 20%">ID</th> <th style="width: 20%">First Name</th> <th style="width: 20%">Last Name</th> <th style="width: 20%">File Name</th> <th style="width: 20%">File Path</th> <th style="width: 20%">division</th> <th style="width: 20%">Reporting Unit</th> <th style="width: 20%">Document No.</th> <th style="width: 20%">Document Name</th> <th style="width: 20%">Document Uploader</th> <th style="width: 20%">Document Owner</th> <th style="width: 20%">Document Type</th> <th style="width: 20%">Document Category</th> <th style="width: 20%">By Function</th> <th style="width: 20%">Creator</th> <th style="width: 20%">Modifier</th> <th style="width: 20%">Approver</th> <th style="width: 20%">Z ID</th> <th style="width: 20%">Mail ID</th> <th style="width: 20%">Added Date</th> <th style="width: 20%">Download</th> </tr> <% Connection con = null; PreparedStatement ps = null; ResultSet rs = null; %> <% Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/newfieldsadded","root",""); String sql = "select * from newfiles"; ps = con.prepareStatement(sql); Statement stmt = con.createStatement(); String query = request.getParameter("search"); String data; if(query != null){ data = "select * from newfiles where id like'%"+query+"%' or firstname like'%"+query+"%' or lastname like'%"+query+"%' or filename like'%"+query+"%' or division like'%"+query+"%' or reportingunit like'%"+query+"%' or documentnumber like'%"+query+"%' or documentname like'%"+query+"%' or documentuploader like'%"+query+"%' or documentowner like'%"+query+"%' or documenttype like'%"+query+"%' or documentcategory like'%"+query+"%' or byfunction like'%"+query+"%' or creator like'%"+query+"%' or modifier like'%"+query+"%' or approver like'%"+query+"%' or zid like'%"+query+"%' or mailid like'%"+query+"%'"; } else{ data = "select * from newfiles order by 1 asc"; } rs = stmt.executeQuery(data); while(rs.next()){ %> <tr> <td><%=rs.getInt("id")%></td> <td><%=rs.getString("firstname")%></td> <td><%=rs.getString("lastname")%></td> <td><%=rs.getString("filename")%></td> <td><%=rs.getString("path")%></td> <td><%=rs.getString("division")%></td> <td><%=rs.getString("reportingunit")%></td> <td><%=rs.getString("documentnumber")%></td> <td><%=rs.getString("documentname")%></td> <td><%=rs.getString("documentuploader")%></td> <td><%=rs.getString("documentowner")%></td> <td><%=rs.getString("documenttype")%></td> <td><%=rs.getString("documentcategory")%></td> <td><%=rs.getString("byfunction")%></td> <td><%=rs.getString("creator")%></td> <td><%=rs.getString("modifier")%></td> <td><%=rs.getString("approver")%></td> <td><%=rs.getString("zid")%></td> <td><%=rs.getString("mailid")%></td> <td><%=rs.getTimestamp("added_date")%></td> <td><a href="DownloadServletClass?fileName=<%=rs.getString(4)%>">Download</a></td> </tr> <% } %> </table><br> <a href="index.jsp">Home</a> </center> </body> </html> <!-- end snippet --> [enter image description here][1] This is my Search.jsp page <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <%-- Document : search Created on : 12 Dec, 2019, 4:08:29 PM Author : Z0009289 --%> <%@ page import="java.io.*,java.util.*,java.sql.*"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> <%@ page isELIgnored="false"%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <sql:setDataSource var="emp" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/newfieldsadded" user="root" password="" /> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Search Page</title> </head> <body> <h1>Searched Data</h1> <form name="empForm" action="index.jsp" method="post"> <div> <table border="2" style="width:100%"> <tr> <th style="width:70%">Z ID</th> <th style="width:70%">First Name</th> <th>Last Name</th> <th>Division</th> <th>Reporting Unit</th> <th>Document No.</th> <th>Document Name</th> <th>Document Uploader</th> <th>Document Owner</th> <th>Document Type</th> <th>Document Category</th> <th>By Function</th> <th>Creator</th> <th>Modifier</th> <th>Approver</th> <th>Mail Id</th> <th>Added date</th> <th>Download</th> </tr> <tbody> <% // out.println("select * from newfiles emp where emp.zid like '%"+request.getParameter("zid")+"%' and " // + " emp.firstname like '%"+request.getParameter("firstname")+"%' and" + " emp.lastname like '%"+request.getParameter("lastname")+"%' and" + " emp.documenttype like '%"+request.getParameter("documenttype")+"%' and" // + " emp.documentcategory like '%"+request.getParameter("documentcategory")+"%' "); //out.println("select count(*) from newfiles"); %> <sql:query var="empData" dataSource="${emp}"> select * from newfiles emp where emp.zid like '% <%=request.getParameter("zid")%>%' and emp.firstname like '% <%=request.getParameter("firstname")%>%' and emp.lastname like '% <%=request.getParameter("lastname")%>%' and emp.division like '% <%=request.getParameter("division")%>%' and emp.reportingunit like '% <%=request.getParameter("reportingunit")%>%' and emp.documentnumber like '% <%=request.getParameter("documentnumber")%>%' and emp.documentname like '% <%=request.getParameter("documentname")%>%' and emp.documentuploader like '% <%=request.getParameter("documentuploader")%>%' and emp.documentowner like '% <%=request.getParameter("documentowner")%>%' and emp.documenttype like '% <%=request.getParameter("documenttype")%>%' and emp.documentcategory like '% <%=request.getParameter("documentcategory")%>%' and emp.byfunction like '% <%=request.getParameter("byfunction")%>%' and emp.creator like '% <%=request.getParameter("creator")%>%' and emp.modifier like '% <%=request.getParameter("modifier")%>%' and emp.approver like '% <%=request.getParameter("approver")%>%' and emp.mailid like '% <%=request.getParameter("mailid")%>%' and emp.added_date like '% <%=request.getParameter("added_date")%>%' </sql:query> <c:forEach var="row" items="${empData.rows}"> <tr> <td> <c:out value="${row.zid}" /> </td> <td> <c:out value="${row.firstname}" /> </td> <td> <c:out value="${row.lastname}" /> </td> <td> <c:out value="${row.division}" /> </td> <td> <c:out value="${row.reportingunit}" /> </td> <td> <c:out value="${row.documentnumber}" /> </td> <td> <c:out value="${row.documentname}" /> </td> <td> <c:out value="${row.documentuploader}" /> </td> <td> <c:out value="${row.documentowner}" /> </td> <td> <c:out value="${row.documenttype}" /> </td> <td> <c:out value="${row.documentcategory}" /> </td> <td> <c:out value="${row.byfunction}" /> </td> <td> <c:out value="${row.creator}" /> </td> <td> <c:out value="${row.modifier}" /> </td> <td> <c:out value="${row.approver}" /> </td> <td> <c:out value="${row.mailid}" /> </td> <td> <c:out value="${row.added_date}" /> </td> <td><a href="DownloadServletClass?fileName=<%=request.getParameter(" filename ") %>">Download</a></td> </tr> </c:forEach> </tbody> </table> </div> </form> <br> <center> <a href="index.jsp">Home</a></center> </body> </html> <!-- end snippet --> [1]: https://i.stack.imgur.com/HQh2N.png
0debug
Deploying Common Lisp Web Applications : <p>I am wondering how one goes about deploying a Common Lisp web application written in, say, Hunchentoot, Wookie, Woo, or even Clack.</p> <p>That is, suppose I write an app that contains some files, packages, etc. Typically when I am working locally, I simply run a command in REPL that starts the server and then visit it using <code>localhost:8000</code> or something like that.</p> <p>However, I am a bit puzzled as to what the process is for deploying an app to a production server like AWS EC2. In what form should I deploy the Lisp code? Are there different options? What happens if the server needs to be restarted or is experiencing problems? </p>
0debug