problem
stringlengths
26
131k
labels
class label
2 classes
Can i initialize static variable after the initialization ?? : what is the problem with below code? class test {static int a; a=10; } if i'm writing like this i'm getting compile time error.(above one) class test { static int a=10;a=4;} for the 2nd i'm n't getting any error.
0debug
Required java.lang.string : > Want java.lang.string but it is getting array type how to resolve this problem String actionFilms = Arrays.asList(context.getResources().getString(R.string.hom)); expandableListData.put(filmGenres.get(0), actionFilms);
0debug
connection.query('SELECT * FROM users WHERE username = ' + input_string)
1threat
How to pass extended parameter to a function? : <p>I'm trying to pass a parameter to a function so that I can call my array object elements multiple times (since I have them quite a lot, returned from the sql query).</p> <pre><code>removeDuplicates(arr, x){ var tmp = []; var tmp2=[]; for(let i = 0; i &lt; 50; i++){ if(tmp.indexOf(arr[i].id) == -1){ tmp.push(arr[i].id); //always id tmp2.push(arr[i].x); //for example arr[i].name } } return tmp2; } </code></pre> <p>If I do it like that and call the method like this:</p> <pre><code> removeDuplicates(arraytag2, arraytag2.name); </code></pre> <p>it doesn't work.</p>
0debug
static int qemu_rbd_send_pipe(BDRVRBDState *s, RADOSCB *rcb) { int ret = 0; while (1) { fd_set wfd; int fd = s->fds[RBD_FD_WRITE]; ret = write(fd, (void *)&rcb, sizeof(rcb)); if (ret >= 0) { break; } if (errno == EINTR) { continue; } if (errno != EAGAIN) { break; } FD_ZERO(&wfd); FD_SET(fd, &wfd); do { ret = select(fd + 1, NULL, &wfd, NULL, NULL); } while (ret < 0 && errno == EINTR); } return ret; }
1threat
static void encode_rgb_frame(FFV1Context *s, uint8_t *src[3], int w, int h, int stride[3]) { int x, y, p, i; const int ring_size = s->avctx->context_model ? 3 : 2; int16_t *sample[4][3]; int lbd = s->bits_per_raw_sample <= 8; int bits = s->bits_per_raw_sample > 0 ? s->bits_per_raw_sample : 8; int offset = 1 << bits; s->run_index = 0; memset(s->sample_buffer, 0, ring_size * MAX_PLANES * (w + 6) * sizeof(*s->sample_buffer)); for (y = 0; y < h; y++) { for (i = 0; i < ring_size; i++) for (p = 0; p < MAX_PLANES; p++) sample[p][i]= s->sample_buffer + p*ring_size*(w+6) + ((h+i-y)%ring_size)*(w+6) + 3; for (x = 0; x < w; x++) { int b, g, r, av_uninit(a); if (lbd) { unsigned v = *((uint32_t*)(src[0] + x*4 + stride[0]*y)); b = v & 0xFF; g = (v >> 8) & 0xFF; r = (v >> 16) & 0xFF; a = v >> 24; } else { b = *((uint16_t*)(src[0] + x*2 + stride[0]*y)); g = *((uint16_t*)(src[1] + x*2 + stride[1]*y)); r = *((uint16_t*)(src[2] + x*2 + stride[2]*y)); } b -= g; r -= g; g += (b + r) >> 2; b += offset; r += offset; sample[0][0][x] = g; sample[1][0][x] = b; sample[2][0][x] = r; sample[3][0][x] = a; } for (p = 0; p < 3 + s->transparency; p++) { sample[p][0][-1] = sample[p][1][0 ]; sample[p][1][ w] = sample[p][1][w-1]; if (lbd) encode_line(s, w, sample[p], (p + 1) / 2, 9); else encode_line(s, w, sample[p], (p + 1) / 2, bits + 1); } } }
1threat
static uint64_t bonito_ldma_readl(void *opaque, target_phys_addr_t addr, unsigned size) { uint32_t val; PCIBonitoState *s = opaque; val = ((uint32_t *)(&s->bonldma))[addr/sizeof(uint32_t)]; return val; }
1threat
static int read_password(char *buf, int buf_size) { int c, i; printf("Password: "); fflush(stdout); i = 0; for(;;) { c = getchar(); if (c == '\n') break; if (i < (buf_size - 1)) buf[i++] = c; } buf[i] = '\0'; return 0; }
1threat
Mongoose text-search with partial string : <p>Hi i'm using <strong>mongoose</strong> to search for persons in my collection.</p> <pre><code>/*Person model*/ { name: { first: String, last: String } } </code></pre> <p>Now i want to search for persons with a query:</p> <pre><code>let regex = new RegExp(QUERY,'i'); Person.find({ $or: [ {'name.first': regex}, {'name.last': regex} ] }).exec(function(err,persons){ console.log(persons); }); </code></pre> <p>If i search for <strong>John</strong> i get results (event if i search for <strong>Jo</strong>). But if i search for <strong>John Doe</strong> i am not getting any results obviously.</p> <p>If i change <strong>QUERY</strong> to <strong>John|Doe</strong> i get results, but it returns all persons who either have <strong>John</strong> or <strong>Doe</strong> in their last-/firstname.</p> <p>The next thing was to try with mongoose textsearch:</p> <p>First add fields to index:</p> <pre><code>PersonSchema.index({ name: { first: 'text', last: 'text' } },{ name: 'Personsearch index', weights: { name: { first : 10, last: 10 } } }); </code></pre> <p>Then modify the Person query:</p> <pre><code>Person.find({ $text : { $search : QUERY } }, { score:{$meta:'textScore'} }) .sort({ score : { $meta : 'textScore' } }) .exec(function(err,persons){ console.log(persons); }); </code></pre> <p>This works just fine! <strong>But</strong> now it is only returning persons that match with the whole first-/lastname: </p> <p>-> <strong>John</strong> returns value</p> <p>-> <strong>Jo</strong> returns no value</p> <p>Is there a way to solve this? </p> <p>Answers <strong>without external plugins</strong> are preferred but others are wished too.</p>
0debug
Pandas groupby with pct_change : <p>I'm trying to find the period over period growth in value for each unique group, grouped by Company, Group, and Date. </p> <pre><code>Company Group Date Value A X 2015-01 1 A X 2015-02 2 A X 2015-03 1.5 A XX 2015-01 1 A XX 2015-02 1.5 A XX 2015-03 0.75 A XX 2015-04 1 B Y 2015-01 1 B Y 2015-02 1.5 B Y 2015-03 2 B Y 2015-04 3 B YY 2015-01 2 B YY 2015-02 2.5 B YY 2015-03 3 </code></pre> <p>I've tried:</p> <pre><code>df.groupby(['Date','Company','Group']).pct_change() </code></pre> <p>but this returns all NaN.</p> <p>The result I'm looking for is:</p> <pre><code>Company Group Date Value/People A X 2015-01 NaN A X 2015-02 1.0 A X 2015-03 -0.25 A XX 2015-01 NaN A XX 2015-02 0.5 A XX 2015-03 -0.5 A XX 2015-04 0.33 B Y 2015-01 NaN B Y 2015-02 0.5 B Y 2015-03 0.33 B Y 2015-04 0.5 B YY 2015-01 NaN B YY 2015-02 0.25 B YY 2015-03 0.2 </code></pre>
0debug
import math def round_up(a, digits): n = 10**-digits return round(math.ceil(a / n) * n, digits)
0debug
I have a very huge while wend loop in my excel vba : I have a very huge while wend loop in my excel vba previous in the code I set a variable (strMode) to true or false if it is false then in my while condition I want to set while var1 + var1previous > 1 and if it is true while var1 + var1previous > 1 or var1previous + var1 > 1 How can I do that, if I don't what to "double" the while wend code, for my if statement?
0debug
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
How to retrieve values at key =2 into NSString? : How to retrieve values at key =2 of a NSMutableDictionary into NSString?
0debug
If condition inside of map() React : <p>I have a <code>map()</code>function that needs to display views based on a condition. I've looked at the React documentation on how to write conditions and this is how you can write a condition:</p> <pre><code>{if (loggedIn) ? ( // Hello! ) : ( // ByeBye! )} </code></pre> <p>Here's the link: <a href="https://facebook.github.io/react/docs/conditional-rendering.html#inline-if-else-with-conditional-operator" rel="noreferrer">https://facebook.github.io/react/docs/conditional-rendering.html#inline-if-else-with-conditional-operator</a> </p> <p>So, I tried to take that knowledge and implemant it in my React app. And it turned out like this:</p> <pre><code>render() { return ( &lt;div&gt; &lt;div className="box"&gt; {this.props.collection.ids .filter( id =&gt; // note: this is only passed when in top level of document this.props.collection.documents[id][ this.props.schema.foreignKey ] === this.props.parentDocumentId ) .map(id =&gt; {if (this.props.schema.collectionName.length &lt; 0 ? ( &lt;Expandable&gt; &lt;ObjectDisplay key={id} parentDocumentId={id} schema={schema[this.props.schema.collectionName]} value={this.props.collection.documents[id]} /&gt; &lt;/Expandable&gt; ) : ( &lt;h1&gt;hejsan&lt;/h1&gt; )} )} &lt;/div&gt; &lt;/div&gt; ) } </code></pre> <p>But it doesn't work..! Here's the error:</p> <p><a href="https://i.stack.imgur.com/4Ywnd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4Ywnd.png" alt="Screenshot"></a></p> <p>I appreciate all the help I can get!</p>
0debug
How to make mosquitto_sub print topic and message when subscribed to # : <p>The following command shows all the messages published to topics that match the regex but not the exact topic itself.</p> <pre><code>mosquitto_sub -h localhost -u user -P pass -t 'devices/#' {"value":"50"} {"value":"45"} </code></pre> <p>For example the above json messages were published to topic devices/1234/transducer/46364/ but I could not figure any way to print the topic as well using mosquitto_sub.</p>
0debug
Can one reduce the number of type parameters? : <p>I find it annoying that one has to specify the types of both Foo and FooFactory in the call to RunTest below. After all, if the test knows the type of the Factory, the type the Factory is creating is implied. Assuming I want to run a lot of different factory tests for factories of different classes, that's a lot of angle brackets, and it gets worse with richer type hierarchies. I'm wondering if it is possible to restructure this so that the test is more concise.</p> <pre><code>public class Foo { } public interface IFactory&lt;T&gt; { T Create(); } public class FooFactory : IFactory&lt;Foo&gt; { public Foo Create() =&gt; new Foo(); } public class FactoryTest { internal void RunTest&lt;TFactory, T&gt;(TFactory factory) where TFactory : IFactory&lt;T&gt; { T t = factory.Create(); Assert.NotEqual(default(T), t); } [Fact] public void FooFactoryWorks() { RunTest&lt;FooFactory, Foo&gt;(new FooFactory()); } } </code></pre>
0debug
How is python running faster than C and C++? : <p>I have made simple program which just prints 1 million numbers on screen, python was taking about 5.2 seconds. I thought C and C++ should do it faster but both are taking about 8 seconds every time I run. How these are slower than python?</p> <p>python code:</p> <pre><code>import time start = time.time() i = 0 while i &lt; 1000000: print(i) i += 1 time_taken = time.time() - start print(("Program took %s seconds." % (time_taken))) </code></pre> <blockquote> <p>Program took 5.204254150390625 seconds.</p> </blockquote> <p>C code:</p> <pre><code>#include&lt;stdio.h&gt; int main() { for( int i = 0 ; i &lt; 1000000 ; ++i ) printf("%d\n", i); } </code></pre> <blockquote> <p>Time taken: 8.582 seconds.</p> </blockquote> <p>C++ code:</p> <pre><code>#include&lt;iostream&gt; using namespace std; int main() { for( int i = 0 ; i &lt; 1000000 ; ++i) cout&lt;&lt;i&lt;&lt;endl; } </code></pre> <blockquote> <p>Time taken: 8.778 seconds.</p> </blockquote> <p>While when I run this:</p> <pre><code>import time start = time.time() print(*range(1000000)) time_taken = time.time() - start print(("Program took %s seconds." % (time_taken))) </code></pre> <blockquote> <p>Program took 60.77405118942261 seconds.</p> </blockquote> <p>How is python's built in function is working slower than trivial version of program?</p>
0debug
static void pollfds_poll(GArray *pollfds, int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds) { int i; for (i = 0; i < pollfds->len; i++) { GPollFD *pfd = &g_array_index(pollfds, GPollFD, i); int fd = pfd->fd; int revents = 0; if (FD_ISSET(fd, rfds)) { revents |= G_IO_IN | G_IO_HUP | G_IO_ERR; } if (FD_ISSET(fd, wfds)) { revents |= G_IO_OUT | G_IO_ERR; } if (FD_ISSET(fd, xfds)) { revents |= G_IO_PRI; } pfd->revents = revents & pfd->events; } }
1threat
How to calculate precision and recall in Keras : <p>I am building a multi-class classifier with Keras 2.02 (with Tensorflow backend),and I do not know how to calculate precision and recall in Keras. Please help me.</p>
0debug
parsing error syntax with []byte using strconv.Atoi : I'm currently trying to convert a byte array to an int so i proceed like that : var d = []byte{0x01} val, err := strconv.Atoi(string(d)) and i get this error : > strconv.Atoi: parsing "\x01": invalid syntax I've tried a lot of way without success yet.. Any one got an idea ?
0debug
C# change color for each line in RichTextBox : <p>I have a text, that have lines, statring with "#". How can i make all text black, and only these lines green?</p>
0debug
Angular currency pipe no decimal value : <p>I am trying to use the currency pipe in angular to display a whole number price, I don't need it to add .00 to my number, the thing is, its not formatting it according to my instructions. here is my HTML:</p> <pre><code> &lt;h5 class="price"&gt;&lt;span&gt;{{billingInfo.amount | currency:billingInfo.currencyCode:'1.0-0'}}&lt;/span&gt; {{billingInfo.period}}&lt;/h5&gt; </code></pre> <p>here is my ts:</p> <pre><code>ngOnInit() { this.billingInfo = {amount: 100, currencyCode: 'USD', period: 'Hour'}; } </code></pre> <p>and here is the output:</p> <pre><code>$100.00 Hour </code></pre> <p>things I tried to do:</p> <p>1.use the decimal number pipe(no good, the currency pipe turns it into a string)</p> <p>2.add number formater(:1.0-0) to my currencyPipe but it seems to be ignored</p> <p>what am I missing?</p>
0debug
[C#][Visual2k17] How to retrieve data from a previous form? : I really need your help right now. I want to **disable** a button in a form when the user **is log as** "operator" and enable it when he is an "admin". I have 3 form : first one => **login page** where i have the **"User" and "password"** parameters, second one => **menu** where i have a **label on the top** saying who is currently connect (operator or admin), third one => the **repair** **page**. The problem is that when i click on the button "Back" on my third form, and **i get back** on the second form, the button **is enable**. So even "Operator" can access it through this glitch / bug. Code for my login page: public partial class Login : Form { public Login() { InitializeComponent(); } public void button2_Click(object sender, EventArgs e) { Main form2 = new Main(this); try { SqlConnection con = new SqlConnection("Server=(local); Database= Seica_Takaya;Integrated Security = SSPI; "); SqlDataAdapter sda = new SqlDataAdapter("SELECT count(*) FROM Loginmdp WHERE util='" + textBox1.Text + "' AND mdp='" + textBox2.Text + "'", con); DataTable dt = new DataTable(); sda.Fill(dt); if (dt.Rows[0][0].ToString() == "1") { MessageBox.Show("Connexion réussie ! "); this.Hide(); form2.Show(); con.Close(); } else { MessageBox.Show("Identifiant / Mot de passe faux. Veuillez resaisir votre identifiant et mot de passe."); con.Close(); } } catch(SqlException ex) { MessageBox.Show("SQL EXCEPTION : " + ex.Message); } } private void button1_Click(object sender, EventArgs e) { this.Close(); } } Here is my code for the menu : public partial class Main : Form { private Login login; public Main() { InitializeComponent(); } public Main(Login login) { InitializeComponent(); label3.Text = login.textBox1.Text; this.login = login; if (login.textBox1.Text == "admin" && login.textBox2.Text == "root") { button2.Enabled = true; } else { button2.Enabled = false; } } private void button1_Click(object sender, EventArgs e) { Repair form3 = new Repair(); this.Hide(); form3.Show(); } private void button2_Click(object sender, EventArgs e) { Admin form4 = new Admin(); this.Hide(); form4.Show(); } private void button3_Click(object sender, EventArgs e) { new Login().Show(); this.Hide(); MessageBox.Show("Vous êtes déconnecté"); } } Code for the repair page : public partial class Repair : Form { public Repair() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { SqlConnection maConnexion = new SqlConnection("Server= localhost; Database= Seica_Takaya;Integrated Security = SSPI; "); maConnexion.Open(); string Var1 = textBox1.Text; SqlCommand command = maConnexion.CreateCommand(); command.Parameters.AddWithValue("@BoardName", Var1); command.Parameters.AddWithValue("@Machine", Var1); command.Parameters.AddWithValue("@SerialNum", Var1); command.Parameters.AddWithValue("@FComponent", Var1); command.CommandText = "SELECT * FROM FailOnly WHERE BoardName=@BoardName OR Machine=@Machine OR SerialNum=@SerialNum OR FComponent=@FComponent AND ReportingOperator != NULL"; SqlDataAdapter sda = new SqlDataAdapter(command); DataSet ds = new DataSet(); sda.Fill(ds); dataGridView1.DataSource = ds.Tables[0]; } private void button2_Click(object sender, EventArgs e) { this.Hide(); Main ff = new Main(); ff.Show(); } private void textBox1_TextChanged(object sender, EventArgs e) { /** BindingSource bs = new BindingSource(); bs.DataSource = dataGridView1.DataSource; bs.Filter = string.Format("BoardName LIKE '%{0}%'",textBox1.Text.Replace("'","''")); dataGridView1.DataSource = bs;**/ } } Step by step pictures now : [First][1] [Second][2] [1]: https://i.stack.imgur.com/cB5Oe.png [2]: https://i.stack.imgur.com/4h1TI.jpg
0debug
static Visitor *visitor_input_test_init_internal(TestInputVisitorData *data, const char *json_string, va_list *ap) { visitor_input_teardown(data, NULL); data->obj = qobject_from_jsonv(json_string, ap); g_assert(data->obj); data->qiv = qmp_input_visitor_new(data->obj, false); g_assert(data->qiv); return data->qiv; }
1threat
un able to insert data into database using php : <p>this php code is written at the end of of my file </p> <pre><code> &lt;?php if(isset($_POST['submit'])) { $Jobtitle = $_POST['jobtitle']; $Firstname = $_POST['firstname']; $Lastname = $_POST['lastname']; $Name=$Firstname+$Lastname; $Sin = $_POST['sin']; $Phone = $_POST['phone']; $Email = $_POST['email']; $Address = $_POST['address']; $Postal = $_POST['postal']; $State = $_POST['state']; $Country = $_POST['country']; $Skill = $_POST['skill']; $Owntransport = $_POST['owntransport']; $ADate = $_POST['a-date']; $Workpermit = $_POST['workpermit']; $Daysavailable = $_POST['days-available']; $Strength = $_POST['strength']; $eFirstname = $_POST['efirstname']; $eLastname = $_POST['elastname']; $eName=$eFirstname+$eLastname; $ePhone = $_POST['ephone']; $query=" INSERT INTO `general`(`jobtitle`, `name`, `sin`, `pno`, `email`, `address`, `doc`, `skills`, `transport`, `avadate`, `authorize`, `days`, `strength`, `ename`, `ephone`) VALUES ('{$Jobtitle}','{$Name}','{$Sin}','{$Phone}','{$Email}','{$Address}','{$Postal}','{$State}','{$Country}','{$Skill}','{$Owntransport}','{$ADate}','{$Workpermit}','{$Daysavailable}','{$Strength}','{$eName}','{$ePhone}')"; // $query = "INSERT INTO info (name,password,gender,hobby,phone no,dob,message) VALUES ('{$Name}','{$Password}','{$Gender}','{$Hobby}','{$Phone}','{$Dob}','{$Message}')"; $result = mysql_query($query); if($result) { echo "data entered"; } unset($_POST); } else{ echo "error in entering data"; } </code></pre> <p>?></p> <p>this is the button tag</p> <pre><code>&lt;button type="button" class="btn btn-primary"name="submit"value="submit" id="submit"&gt;Submit&lt;/button&gt; </code></pre> <p>this is the form tag</p> <pre><code>&lt;form method="post" id="contactform" action="#" role="form"&gt; </code></pre> <p>connection .php file giving me the connection to database but I am unable to store the data in databse it gives me the error that data is not entered</p>
0debug
array_diff_assoc() or foreach()? Which can I use? : I have two arrays, for example $session and $post with 100+ values. I will compare the $post array values with $session array. If post is different then it will be taken to result array else not. We can try this using `array_diff_assoc($post, $session) and foreach()` But which is faster?
0debug
Am I creating lossless PNG images? : <p>I am doing image processing in a scientific context. Whenever I need to save an image to the hard drive, I want to be able to reopen it at a later time and get exactly the data that I had before saving it. I exclusively use the PNG format, having always been under the impression that it is a lossless format. Is this always correct, provided I am not using the wrong bit-depth? Should encoder and decoder play no role at all? Specifically, the images I save </p> <ul> <li>are present as 2D numpy arrays</li> <li>have integer values from 0 to 255</li> <li>are encoded with the OpenCV <code>imwrite()</code> function, e.g. <code>cv2.imwrite("image.png", array)</code></li> </ul>
0debug
static bool cmd_data_set_management(IDEState *s, uint8_t cmd) { switch (s->feature) { case DSM_TRIM: if (s->bs) { ide_sector_start_dma(s, IDE_DMA_TRIM); return false; } break; } ide_abort_command(s); return true; }
1threat
How to tell if any command in bash script failed (non-zero exit status) : <p>I want to know whether any commands in a bash script exited with a non-zero status.</p> <p>I want something similar to <code>set -e</code> functionality, except that I don't want it to exit when a command exits with a non-zero status. I want it to run the whole script, and then I want to know that either:</p> <p>a) all commands exited with exit status 0<br> -or-<br> b) one or more commands exited with a non-zero status</p> <p><br/> e.g., given the following:</p> <pre><code>#!/bin/bash command1 # exits with status 1 command2 # exits with status 0 command3 # exits with status 0 </code></pre> <p>I want all three commands to run. After running the script, I want an indication that at least one of the commands exited with a non-zero status.</p>
0debug
Matlab convolution code in C : <p>I'm trying to make the MATLAB conv function in C. So far I have this:</p> <pre><code>int n=Length(SignalArray); int m=Length(FilterArray); TempX=[SignalArray,Zeros(1,FilterArray)]; TempH=[FilterArray,Zeros(1,SignalArray)]; for(int i=0;i&lt;n+m-1;i++){ ResultArray(i)=0; for(int j=0;j&lt;=m-1;j++){ if(i-j+1&gt;0){ int TempVal=ResultArray(i)+TempX(j)*TempH(i-j); ResultArray(i)=TempVal; } } } </code></pre> <p>The first elements of the convolution result come out to be fine but the last element either comes out to be right or is shown to be a really high number ( something like 10 to the power 9).</p> <p>Please help.</p>
0debug
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
How can i make N label? : Because this isn't work: int z = 0; for (int k = 0; k <5; k++) { Label l = new Label(); l.Name = string.Format("betu{0}", k); l.Text = "_"; l.Height = 75; l.Width = 25; l.Location = new Point(300 + z, 10); this.Controls.Add(l); z += 10; } This make only 1, and I would like to create more label, right to the last.
0debug
How add time local of my computer in may page html : <p>I like to display my time local in my page html , javascript , and i can use momentjs ? Please who can help me ?</p>
0debug
void s390_init_cpus(const char *cpu_model) { int i; if (cpu_model == NULL) { cpu_model = "host"; } ipi_states = g_malloc(sizeof(S390CPU *) * smp_cpus); for (i = 0; i < smp_cpus; i++) { S390CPU *cpu; CPUState *cs; cpu = cpu_s390x_init(cpu_model); cs = CPU(cpu); ipi_states[i] = cpu; cs->halted = 1; cs->exception_index = EXCP_HLT; } }
1threat
cannot export const arrow function : <p>new to ES6, I was trying to make a React simple functional component like this</p> <pre><code>// ./Todo.jsx export default const Todo = ({ todos, onTodoClick, }) =&gt; ( &lt;ul&gt; {todos.map( (todo, i) =&gt; &lt;li key = {i} onClick = {() =&gt; onTodoClick(i) } style = {{textDecoration: todo.completed ? 'line-through': 'none' }} &gt; {todo.text} &lt;/li&gt; )} &lt;/ul&gt; ) </code></pre> <p>But </p> <pre><code>// Another file import Todo from './Todos.jsx'; console.log(Todo) // undefined </code></pre> <p>did not yield the arrow function.</p> <p>but if I leave off the "const todo =" part in the export link, like so</p> <pre><code> export default ({ todos, onTodoClick, }) =&gt; (...) </code></pre> <p>It gets successfully imported. </p> <p>Why is that?</p>
0debug
POST csv/Text file using cURL : <p>How can I send POST request with a csv or a text file to the server running on a <code>localhost</code> using <code>cURL</code>. </p> <p>I have tried <code>curl -X POST -d @file.csv http://localhost:5000/upload</code> but I get </p> <blockquote> <p>{ "message": "The browser (or proxy) sent a request that this server could not understand." }</p> </blockquote> <p>My server is <code>flask_restful API</code>. Thanks a lot in advance.</p>
0debug
void qemu_fflush(QEMUFile *f) { ssize_t ret = 0; if (!qemu_file_is_writable(f)) { return; } if (f->ops->writev_buffer) { if (f->iovcnt > 0) { ret = f->ops->writev_buffer(f->opaque, f->iov, f->iovcnt, f->pos); } } else { if (f->buf_index > 0) { ret = f->ops->put_buffer(f->opaque, f->buf, f->pos, f->buf_index); } } if (ret >= 0) { f->pos += ret; } f->buf_index = 0; f->iovcnt = 0; if (ret < 0) { qemu_file_set_error(f, ret); } }
1threat
how naming file txt same with value in list dictionary python : for example I have list inside dictionary {'results':[{'name':'sarah','age':'18'}]} ----------------------------------------- I want make a text file but the of file must be value of dict 'name' ex: sarah.txt how should I code it in python?
0debug
How to create dynamic tag based on props with Vue 2 : <p>How can I make a component similar to vue-router <code>router-link</code> where I get the tag via props to render my template ?</p> <pre><code>&lt;my-component tag="ul"&gt; &lt;/my-component&gt; </code></pre> <p>Would render:</p> <pre><code>&lt;ul&gt; anything inside my-component &lt;/ul&gt; </code></pre>
0debug
allow semi colons in javascript eslint : <p>I have following <code>.eslintrc</code></p> <pre><code>{ "extends": "standard" } </code></pre> <p>I have following code in my javascript file</p> <pre><code>import React from 'react'; </code></pre> <p>Above line of code is incorrect according to eslint. It gives following complain.</p> <pre><code>"; Extra semicolon </code></pre> <p>How can I allow semi colons in eslint?</p>
0debug
static void apic_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val) { DeviceState *d; APICCommonState *s; int index = (addr >> 4) & 0xff; if (addr > 0xfff || !index) { apic_send_msi(addr, val); return; } d = cpu_get_current_apic(); if (!d) { return; } s = DO_UPCAST(APICCommonState, busdev.qdev, d); trace_apic_mem_writel(addr, val); switch(index) { case 0x02: s->id = (val >> 24); break; case 0x03: break; case 0x08: if (apic_report_tpr_access) { cpu_report_tpr_access(s->cpu_env, TPR_ACCESS_WRITE); } s->tpr = val; apic_sync_vapic(s, SYNC_TO_VAPIC); apic_update_irq(s); break; case 0x09: case 0x0a: break; case 0x0b: apic_eoi(s); break; case 0x0d: s->log_dest = val >> 24; break; case 0x0e: s->dest_mode = val >> 28; break; case 0x0f: s->spurious_vec = val & 0x1ff; apic_update_irq(s); break; case 0x10 ... 0x17: case 0x18 ... 0x1f: case 0x20 ... 0x27: case 0x28: break; case 0x30: s->icr[0] = val; apic_deliver(d, (s->icr[1] >> 24) & 0xff, (s->icr[0] >> 11) & 1, (s->icr[0] >> 8) & 7, (s->icr[0] & 0xff), (s->icr[0] >> 15) & 1); break; case 0x31: s->icr[1] = val; break; case 0x32 ... 0x37: { int n = index - 0x32; s->lvt[n] = val; if (n == APIC_LVT_TIMER) { apic_timer_update(s, qemu_get_clock_ns(vm_clock)); } else if (n == APIC_LVT_LINT0 && apic_check_pic(s)) { apic_update_irq(s); } } break; case 0x38: s->initial_count = val; s->initial_count_load_time = qemu_get_clock_ns(vm_clock); apic_timer_update(s, s->initial_count_load_time); break; case 0x39: break; case 0x3e: { int v; s->divide_conf = val & 0xb; v = (s->divide_conf & 3) | ((s->divide_conf >> 1) & 4); s->count_shift = (v + 1) & 7; } break; default: s->esr |= ESR_ILLEGAL_ADDRESS; break; } }
1threat
static void *av_mallocz_static(unsigned int size) { void *ptr = av_mallocz(size); if(ptr){ array_static =av_fast_realloc(array_static, &allocated_static, sizeof(void*)*(last_static+1)); if(!array_static) return NULL; array_static[last_static++] = ptr; } return ptr; }
1threat
static void file_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, int size) { QEMUFileStdio *s = opaque; fseek(s->outfile, pos, SEEK_SET); fwrite(buf, 1, size, s->outfile); }
1threat
PHP Float subtraction returning wrong results : <p>When i try to do <strong>(50.00 - 49.99)</strong> it returns to me <strong>0.009999999999998</strong>, why? How do i solve this?</p>
0debug
static void rtas_ibm_get_system_parameter(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { target_ulong parameter = rtas_ld(args, 0); target_ulong buffer = rtas_ld(args, 1); target_ulong length = rtas_ld(args, 2); target_ulong ret; switch (parameter) { case RTAS_SYSPARM_SPLPAR_CHARACTERISTICS: { char *param_val = g_strdup_printf("MaxEntCap=%d," "DesMem=%llu," "DesProcs=%d," "MaxPlatProcs=%d", max_cpus, current_machine->ram_size / M_BYTE, smp_cpus, max_cpus); ret = sysparm_st(buffer, length, param_val, strlen(param_val) + 1); g_free(param_val); break; } case RTAS_SYSPARM_DIAGNOSTICS_RUN_MODE: { uint8_t param_val = DIAGNOSTICS_RUN_MODE_DISABLED; ret = sysparm_st(buffer, length, &param_val, sizeof(param_val)); break; } case RTAS_SYSPARM_UUID: ret = sysparm_st(buffer, length, qemu_uuid, (qemu_uuid_set ? 16 : 0)); break; default: ret = RTAS_OUT_NOT_SUPPORTED; } rtas_st(rets, 0, ret); }
1threat
REST API GET with sensitive data : <p>I'm designing api with method that should be an <strong>idempotent</strong>, and should not modify any data on the server. It should be method that process request and return response for given parameters. </p> <p>One of the parameters is sensitive data. It's not an option to use additional encryption. Data is already encrypted, but security requirements are very demanding and even encrypted data should be treated very carefully.</p> <p>According to REST spec, idempotent query method should be implemented as a GET HTTP method. Problem in this case is sensitive data that shouldn't be pass as a GET parameter in URL. Only option in HTTP standard is to pass sensitive data in a body part of HTTP request.</p> <p>My question is what is better? Broke rest api design, and send query request as a POST, or pass encrypted data in URL? Maybe is there better solution I don't see?</p>
0debug
static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb) { CPUArchState *env = cpu->env_ptr; uintptr_t ret; TranslationBlock *last_tb; int tb_exit; uint8_t *tb_ptr = itb->tc_ptr; qemu_log_mask_and_addr(CPU_LOG_EXEC, itb->pc, "Trace %p [" TARGET_FMT_lx "] %s\n", itb->tc_ptr, itb->pc, lookup_symbol(itb->pc)); #if defined(DEBUG_DISAS) if (qemu_loglevel_mask(CPU_LOG_TB_CPU) && qemu_log_in_addr_range(itb->pc)) { #if defined(TARGET_I386) log_cpu_state(cpu, CPU_DUMP_CCOP); #elif defined(TARGET_M68K) cpu_m68k_flush_flags(env, env->cc_op); env->cc_op = CC_OP_FLAGS; env->sr = (env->sr & 0xffe0) | env->cc_dest | (env->cc_x << 4); log_cpu_state(cpu, 0); #else log_cpu_state(cpu, 0); #endif } #endif cpu->can_do_io = !use_icount; ret = tcg_qemu_tb_exec(env, tb_ptr); cpu->can_do_io = 1; last_tb = (TranslationBlock *)(ret & ~TB_EXIT_MASK); tb_exit = ret & TB_EXIT_MASK; trace_exec_tb_exit(last_tb, tb_exit); if (tb_exit > TB_EXIT_IDX1) { CPUClass *cc = CPU_GET_CLASS(cpu); qemu_log_mask_and_addr(CPU_LOG_EXEC, last_tb->pc, "Stopped execution of TB chain before %p [" TARGET_FMT_lx "] %s\n", last_tb->tc_ptr, last_tb->pc, lookup_symbol(last_tb->pc)); if (cc->synchronize_from_tb) { cc->synchronize_from_tb(cpu, last_tb); } else { assert(cc->set_pc); cc->set_pc(cpu, last_tb->pc); } } if (tb_exit == TB_EXIT_REQUESTED) { cpu->tcg_exit_req = 0; } return ret; }
1threat
Using multiple javascript service workers at the same domain but different folders : <p>My website offers an array of web apps for each client. Each client has a different mix of apps that can be used.</p> <p>Each web app is a hosted in a different folder.</p> <p>So I need to cache for each client only it's allowed web apps instead of caching all the apps, many of them he the user, will not use at all.</p> <p>I naively created a global service worker for the shell of the website and custom named service worker for each folder or app. </p> <p>However I noticed that after the first service worker, say sw_global.js service worker registers, installs, activates, fetches succesfully and creates a cache named cache-global, the second service worker, say sw_app1,js, which creates it's own cache cache-app1, clears all cache-global. </p> <p>How can I use custom service worker for each folder?. Please keep in mind that each folder is a microservice or a web app which is not necesarilly allowed for all users, so it's imperative to not cache all content from a unique service worker. </p> <p>Actually I code on vanilla.js, no angular, no react, no vue, no nada.</p>
0debug
how to make a gradient button in the footer of UICollectionView in swift : i have encountered a problem. i am making an app where i need to make a button that has gradient color on it inside the footer of UICollectionView, and the problem is i can not make it via storyboard, so i have to make it programmatically within the footer of UICollectionView. But i don't know how to make it. the thing is i have tried to make it, i have accomplished to make the basic structure of UIButton inside UICollectionView's Footer. case UICollectionView.elementKindSectionFooter: let footer = outerMainCollectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "Footer", for: indexPath) as! headerReusableView let button = UIButton(frame: CGRect(x: 0, y: 0, width: collectionView.frame.width - 50, height: 40)) if isGuest { button.backgroundColor = .red } else { button.backgroundColor = .black } button.setTitle("ALL", for: .normal) button.setTitleColor(COLORWHITE, for: .normal) button.addTarget(self, action: #selector(footerButton), for: .touchUpInside) footer.addSubview(button) footer.backgroundColor = UIColor.green return footer i want to make it gradient between light Orange and dark Orange, use any hex values for instance. and i want to make it center height of 40, and margins from all sides - top, bottom, left, right. Thank you in advance. :-)
0debug
static void put_frame( AVFormatContext *s, ASFStream *stream, int timestamp, const uint8_t *buf, int m_obj_size ) { ASFContext *asf = s->priv_data; int m_obj_offset, payload_len, frag_len1; m_obj_offset = 0; while (m_obj_offset < m_obj_size) { payload_len = m_obj_size - m_obj_offset; if (asf->packet_timestamp_start == -1) { asf->multi_payloads_present = (payload_len < MULTI_PAYLOAD_CONSTANT); if (asf->multi_payloads_present){ asf->packet_size_left = PACKET_SIZE; asf->packet_size_left = PACKET_SIZE - PACKET_HEADER_MIN_SIZE - 1; frag_len1 = MULTI_PAYLOAD_CONSTANT - 1; } else { asf->packet_size_left = PACKET_SIZE - PACKET_HEADER_MIN_SIZE; frag_len1 = SINGLE_PAYLOAD_DATA_LENGTH; } if (asf->prev_packet_sent_time > timestamp) asf->packet_timestamp_start = asf->prev_packet_sent_time; else asf->packet_timestamp_start = timestamp; } else { frag_len1 = asf->packet_size_left - PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS; if (asf->prev_packet_sent_time > timestamp) asf->packet_timestamp_start = asf->prev_packet_sent_time; else if (asf->packet_timestamp_start >= timestamp) asf->packet_timestamp_start = timestamp; } if (frag_len1 > 0) { if (payload_len > frag_len1) payload_len = frag_len1; else if (payload_len == (frag_len1 - 1)) payload_len = frag_len1 - 2; put_payload_header(s, stream, timestamp+preroll_time, m_obj_size, m_obj_offset, payload_len); put_buffer(&asf->pb, buf, payload_len); if (asf->multi_payloads_present) asf->packet_size_left -= (payload_len + PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS); else asf->packet_size_left -= (payload_len + PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD); asf->packet_timestamp_end = timestamp; asf->packet_nb_payloads++; } else { payload_len = 0; } m_obj_offset += payload_len; buf += payload_len; if (!asf->multi_payloads_present) flush_packet(s); else if (asf->packet_size_left <= (PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS + 1)) flush_packet(s); } stream->seq++; }
1threat
create a class that derives from string builder to append any number of strings : i want to create a class that derives from string builder to append any number of strings. My Program should allow the user input their own number of strings example usage: //Format Post Data //Format Post Data StringBuilder postData = new StringBuilder(); postData.Append("dst"); postData.Append("&popup=true"); postData.Append(String.Format("&username={0}", USERNAME_Validate1));// reads username from username textbox postData.Append(String.Format("&password={0}", PASSWORD_Validate1));// reads password from password textbox //Write Post Data To Server using (StreamWriter writer = new StreamWriter(request.GetRequestStream())) writer.Write(postData);
0debug
Looping through POST variables from Form : <p>I'm sure this is quite simple but all my searches have thrown up complicated answers that don't seem quite on point.</p> <p>I have an array from a form and want to echo it back to a customer with an option to confirm the order.</p> <p>The array looks like this:-</p> <pre><code> POST:- Array ( [choice] =&gt; Array ( [0] =&gt; Array ( [quantity] =&gt; 4 [price] =&gt; 7.50 [itemname] =&gt; Margherita Pizza [merchant] =&gt; 3000 [itemid] =&gt; 2000 ) [1] =&gt; Array ( [quantity] =&gt; 2 [price] =&gt; 3.50 [itemname] =&gt; Garlic Bread [merchant] =&gt; 3000 [itemid] =&gt; 2001 ) ) [submit] =&gt; Submit ) </code></pre> <p>and the code I'm using to extract is:-</p> <pre><code> $_cp_i=0; foreach($_POST['choice'] as $mychoice) { $itemname[$_cp_i]=$mychoice['itemname'][$_cp_i]; $quantity[$_cp_i]=$mychoice['quantity'][$_cp_i]; $price[$_cp_i]=$mychoice['price'][$_cp_i]; $_cp_i++; echo "&lt;tr&gt;&lt;td&gt;$itemname&lt;/td&gt;&lt;td&gt;$quantity[$_cp_i]&lt;/td&gt; &lt;td&gt;$price[$_cp_i]&lt;/td&gt;&lt;/tr&gt;"; } </code></pre> <p>The itemname just shows as Array and the other two fields are blank.</p>
0debug
static int net_tap_init(VLANState *vlan, const char *model, const char *name, const char *ifname1, const char *setup_script, const char *down_script) { TAPState *s; int fd; char ifname[128]; if (ifname1 != NULL) pstrcpy(ifname, sizeof(ifname), ifname1); else ifname[0] = '\0'; TFR(fd = tap_open(ifname, sizeof(ifname))); if (fd < 0) return -1; if (!setup_script || !strcmp(setup_script, "no")) setup_script = ""; if (setup_script[0] != '\0') { if (launch_script(setup_script, ifname, fd)) return -1; } s = net_tap_fd_init(vlan, model, name, fd); if (!s) return -1; snprintf(s->vc->info_str, sizeof(s->vc->info_str), "ifname=%s,script=%s,downscript=%s", ifname, setup_script, down_script); if (down_script && strcmp(down_script, "no")) { snprintf(s->down_script, sizeof(s->down_script), "%s", down_script); snprintf(s->down_script_arg, sizeof(s->down_script_arg), "%s", ifname); } return 0; }
1threat
Job Scheduler not running on Android N : <p>Job Scheduler is working as expected on Android Marshmallow and Lollipop devices, but it is not running and Nexus 5x (Android N Preview). </p> <p>Code for scheduling the job</p> <pre><code> ComponentName componentName = new ComponentName(MainActivity.this, TestJobService.class.getName()); JobInfo.Builder builder; builder = new JobInfo.Builder(JOB_ID, componentName); builder.setPeriodic(5000); JobInfo jobInfo; jobScheduler = (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE); jobInfo = builder.build(); int jobId = jobScheduler.schedule(jobInfo); </code></pre> <p>Service is defined in manifest as:</p> <pre><code>&lt;service android:name=".TestJobService" android:permission="android.permission.BIND_JOB_SERVICE" /&gt; </code></pre> <p>Is any one having this issue on Android N (Preview)?</p>
0debug
Why is static Used in Importing Libraries : <p><a href="https://i.stack.imgur.com/bd12r.png" rel="nofollow noreferrer">What is the purpose of using static in importing libraries</a></p>
0debug
i cant stablish my connection to MS SQL server. (newbie) : im studying VB.net with ms sql server, and im doing this [tutorial][1] but when i run the program, an errror shows. i already try to solve it myself and saw some remedy in the comment section in the youtube. but still i cant resolve it myself. here are the [pics][2] [1]: https://www.youtube.com/watch?v=odrntJn2o98 [2]: https://i.stack.imgur.com/1gHMz.png
0debug
go / golang get the response from the POST type method from restful API : [enter image description here][1] [1]: https://i.stack.imgur.com/rVl8N.png Quick review refer the enclosed image. Concern: How to fetch the json response from the POST method. Note, Currently only able to fetch Status - 401 Unauthorized and StatusCode - 401 Expected: To fetch the json response { "errorMessages": [ "You do not have the permission to see the specified issue.", "Login Required" ], "errors": {} } url := "https://www.example.com" byt := []byte(` { "transition":{"id":"2"} }`) resp, err := postUrl(url, byt) if err != nil { log.Fatal(err) } statusCode := resp.StatusCode return statusCode func postUrl(url string, byt []byte) (*http.Response, error) { tr := &http.Transport{ DisableCompression: true, } client := &http.Client{Transport: tr, Timeout: 10 * time.Second} req, err := http.NewRequest("POST", url, bytes.NewBuffer(byt)) req.Header.Set("X-Custom-Header", "myvalue") req.Header.Set("Content-Type", "application/json") req.Header.Add("Authorization", "Basic "+basicAuth("username", enter code here"password")) resp, err := client.Do(req) return resp, err } Above code produce the out put - { "errorMessages": [ "You do not have the permission to see the specified issue.", "Login Required" ], "errors": {} }
0debug
Webserver attack solutions? : <p>I own an Apache webserver on a Debian 8 VPS, and i got errors like this in my error log What kind of attack is that? Is there any solution against?</p> <pre><code>[Sat Feb 02 07:05:49.618301 2019] [:error] [pid 7679] [client RANDOM_IP_ADDRESS:58746] script '/var/www/html/info1.php' not found or unable to stat [Sat Feb 02 07:05:49.876335 2019] [:error] [pid 7679] [client RANDOM_IP_ADDRESS:58746] script '/var/www/html/aaaaaa1.php' not found or unable to stat [Sat Feb 02 07:05:50.134024 2019] [:error] [pid 7679] [client RANDOM_IP_ADDRESS:58746] script '/var/www/html/up.php' not found or unable to stat [Sat Feb 02 07:05:50.392310 2019] [:error] [pid 7679] [client RANDOM_IP_ADDRESS:58746] script '/var/www/html/test123.php' not found or unable to stat </code></pre> <p>(and other 300+ errors with random path)</p>
0debug
using for-loop with datasnapshot ,can't get the value i want plz help thanks : <p> hi I am new in android studio , having a question,and confusing me whole afternoon.**strong text**I want to get value in picture col,</p> `DatabaseReference GetDestination_Order = FirebaseDatabase.getInstance().getReference("results").child(x).child("destination_order"); GetDestination_Order.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { destination_order.clear(); for (DataSnapshot Snapshot : dataSnapshot.getChildren()) { int data = Snapshot.getValue(Integer.class); String im_or = String.valueOf(data); destination_order.add(im_or); } pass_Destination_order(destination_order); } @Override public void onCancelled(DatabaseError databaseError) { throw databaseError.toException(); } });` <p>I can get destination_order like destination_order: [81, 95, 93, 96, 2] destination_order: [0, 1, 2, 3, 4, 5, 6]</p> `public void pass_Destination_order(final ArrayList<String> destination_order) { for (int n = 0; n < destination_order.size(); n++) { String x = destination_order.get(n); DatabaseReference myRef1 = FirebaseDatabase.getInstance("---firebaseurl---").getReference("travel").child("0").child("result").child(x).child("picture"); Log.e("url-x", x); ValueEventListener valueEventListener = myRef1.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { murl=""; datatest = dataSnapshot.getValue(String.class); Log.e("url", String.valueOf(datatest)); if (count == 0) { murl += datatest; getImages(murl);`enter code here` } if(count==destination_order.size()-1){ count=0;} else count++; } @Override public void onCancelled(DatabaseError databaseError) { throw databaseError.toException(); } }); }` <p>I hope to get the picture url ordered by [81, 95, 93, 96, 2] ,but the myurl i get was messed. why not first myurl belong to 81? the output/log is below. thanks!</p> [logcatpicture][1] [1]: https://i.stack.imgur.com/EZCTn.jpg
0debug
Adding more then one client to the Spring OAuth2 Auth Server : <p>I have Spring OAuth Authorization server and I want to add support for more then one client(id). I configured clients like this:</p> <pre><code>clients .inMemory().withClient(client).secret(clientSecret) .resourceIds(resourceId) .authorizedGrantTypes("client_credentials", "password", "refresh_token", "implicit", "authorization_code") .authorities("ROLE_USER") .scopes("read", "write") .autoApprove(true) .and() .inMemory().withClient("acme").secret("acmesecret") .resourceIds(resourceId) .authorizedGrantTypes("client_credentials", "password", "refresh_token", "implicit", "authorization_code") .authorities("ROLE_USER_ACME") .scopes("read", "write") .autoApprove(true); </code></pre> <p>I can get access token with first client, but i get this error when trying to get access token with second client:</p> <pre><code>{ "timestamp": 1456822249638, "status": 401, "error": "Unauthorized", "message": "Bad credentials", "path": "/oauth/token" } </code></pre> <p>Is it possible to add more then one client and how to do it? Allso, how to read clients from a database?</p>
0debug
jQuery Autocomplete performance going down with each search : <p>I am having an issue with jQuery Autocomplete plugin.</p> <p>By searching mutltiple times with term "item", at first it works okay: css classes on mouseover are added nicely and everything is smooth. By clicking outside of the popup to close it and typing again each time everything seems to work slower:</p> <p>I tested it on Chrome which gets very slow and on Firefox which seem to handle it a bit better but also has a performance degradation.</p> <p>Here is a fiddle with very simple code: <a href="https://jsfiddle.net/re9psbxy/1/" rel="noreferrer">https://jsfiddle.net/re9psbxy/1/</a></p> <p>And the code:</p> <pre><code>var suggestionList = []; for (var i = 0; i &lt; 200; i++) { suggestionList.push({ label: 'item' + i, value: i }); } //initialize jQueryUI Autocomplete jQuery('#autocomplete').autocomplete({ source: suggestionList }); </code></pre> <p>HTML:</p> <pre><code>&lt;input type="text" id="autocomplete"/&gt; </code></pre>
0debug
c++ program for address and variables : the output for this code is : >9 and i'm not sure what does it change in the function add1 and also what does this &n mean and what it do when we assign the **i** to **&n** #include <iostream> using namespace std; int add1(int &n){ n++; return n; } int main(){ int m = 0; for (int i = 0; i < 5; i++){ m += add1(i); } cout << m ; cout << "\n\n"; return 0; }
0debug
int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt, int has_alpha) { const PixFmtInfo *pf, *ps; int loss; ps = &pix_fmt_info[src_pix_fmt]; pf = &pix_fmt_info[dst_pix_fmt]; loss = 0; pf = &pix_fmt_info[dst_pix_fmt]; if (pf->depth < ps->depth) loss |= FF_LOSS_DEPTH; if (pf->x_chroma_shift >= ps->x_chroma_shift || pf->y_chroma_shift >= ps->y_chroma_shift) loss |= FF_LOSS_RESOLUTION; switch(pf->color_type) { case FF_COLOR_RGB: if (ps->color_type != FF_COLOR_RGB && ps->color_type != FF_COLOR_GRAY) loss |= FF_LOSS_COLORSPACE; break; case FF_COLOR_GRAY: if (ps->color_type != FF_COLOR_GRAY) loss |= FF_LOSS_COLORSPACE; break; case FF_COLOR_YUV: if (ps->color_type != FF_COLOR_YUV) loss |= FF_LOSS_COLORSPACE; break; case FF_COLOR_YUV_JPEG: if (ps->color_type != FF_COLOR_YUV_JPEG && ps->color_type != FF_COLOR_YUV) loss |= FF_LOSS_COLORSPACE; break; default: if (ps->color_type != pf->color_type) loss |= FF_LOSS_COLORSPACE; break; } if (pf->color_type == FF_COLOR_GRAY && ps->color_type != FF_COLOR_GRAY) loss |= FF_LOSS_CHROMA; if (!pf->is_alpha && (ps->is_alpha && has_alpha)) loss |= FF_LOSS_ALPHA; if (pf->is_paletted && (!ps->is_paletted && ps->color_type != FF_COLOR_GRAY)) loss |= FF_LOSS_COLORQUANT; return loss; }
1threat
Why do juavascript functions work this way? : so i have a good grasp of most static typed languages mainly C and C++. But when I went into javascript i noticed something that bummed me out. I learned to write this function to interact with inner HTML: document.getElementById("SomeHTML").onclick = function(){ document.getElementById("AnotherHTML").innerHTML = "<p> Joe has a cat </p>"; } that is all fine and well but there is a problem, how am i supposed to reuse this and keep it readable?... coming from a C++, I was always taught to write code in this way: function MyFunc() { document.getElementById("AnotherHTML").innerHTML = "<p> Joe has a cat </p>"; } document.getElementById("SomeHTML").onclick = MyFunc(); The latter code being cleaner (at least to me) and I can reuse the function, but it doesnt work ... I am able to write this way in every programming language yet in javascript it produces an error. I dont know what i am missing, i know its something simple. Can someone please help me understand why I cant write javascript functions in this way? Or if I can please tell me how, because i much prefer the latter than the former. thanx in advance.
0debug
Javascript timer shouldn't reset : I want to reload the page and timer Shouldn't be rest on page reload to next part , is there any way to achieve this functionality ?
0debug
How to delete rows that have up to 6 variables that are nont NA in R : <p>Hello so I want to delete some rows from a data frame. In the dataframe 5 of the variables have value always. And the others may have or have NA value. So I want to keep only the rows that Have at least 6 variables with value. </p> <p>I tried using dropna(df, thresh=6) but this I think works only in python and I couldnt find the syntax for the R. </p> <p>Thank you</p>
0debug
static av_cold int movie_init(AVFilterContext *ctx, const char *args) { MovieContext *movie = ctx->priv; AVInputFormat *iformat = NULL; int64_t timestamp; int nb_streams, ret, i; char default_streams[16], *stream_specs, *spec, *cursor; char name[16]; AVStream *st; movie->class = &movie_class; av_opt_set_defaults(movie); if (args) movie->file_name = av_get_token(&args, ":"); if (!movie->file_name || !*movie->file_name) { av_log(ctx, AV_LOG_ERROR, "No filename provided!\n"); return AVERROR(EINVAL); } if (*args++ == ':' && (ret = av_set_options_string(movie, args, "=", ":")) < 0) return ret; movie->seek_point = movie->seek_point_d * 1000000 + 0.5; stream_specs = movie->stream_specs; if (!stream_specs) { snprintf(default_streams, sizeof(default_streams), "d%c%d", !strcmp(ctx->filter->name, "amovie") ? 'a' : 'v', movie->stream_index); stream_specs = default_streams; } for (cursor = stream_specs, nb_streams = 1; *cursor; cursor++) if (*cursor == '+') nb_streams++; if (movie->loop_count != 1 && nb_streams != 1) { av_log(ctx, AV_LOG_ERROR, "Loop with several streams is currently unsupported\n"); return AVERROR_PATCHWELCOME; } av_register_all(); iformat = movie->format_name ? av_find_input_format(movie->format_name) : NULL; movie->format_ctx = NULL; if ((ret = avformat_open_input(&movie->format_ctx, movie->file_name, iformat, NULL)) < 0) { av_log(ctx, AV_LOG_ERROR, "Failed to avformat_open_input '%s'\n", movie->file_name); return ret; } if ((ret = avformat_find_stream_info(movie->format_ctx, NULL)) < 0) av_log(ctx, AV_LOG_WARNING, "Failed to find stream info\n"); if (movie->seek_point > 0) { timestamp = movie->seek_point; if (movie->format_ctx->start_time != AV_NOPTS_VALUE) { if (timestamp > INT64_MAX - movie->format_ctx->start_time) { av_log(ctx, AV_LOG_ERROR, "%s: seek value overflow with start_time:%"PRId64" seek_point:%"PRId64"\n", movie->file_name, movie->format_ctx->start_time, movie->seek_point); return AVERROR(EINVAL); } timestamp += movie->format_ctx->start_time; } if ((ret = av_seek_frame(movie->format_ctx, -1, timestamp, AVSEEK_FLAG_BACKWARD)) < 0) { av_log(ctx, AV_LOG_ERROR, "%s: could not seek to position %"PRId64"\n", movie->file_name, timestamp); return ret; } } for (i = 0; i < movie->format_ctx->nb_streams; i++) movie->format_ctx->streams[i]->discard = AVDISCARD_ALL; movie->st = av_calloc(nb_streams, sizeof(*movie->st)); if (!movie->st) return AVERROR(ENOMEM); for (i = 0; i < nb_streams; i++) { spec = av_strtok(stream_specs, "+", &cursor); if (!spec) return AVERROR_BUG; stream_specs = NULL; st = find_stream(ctx, movie->format_ctx, spec); if (!st) return AVERROR(EINVAL); st->discard = AVDISCARD_DEFAULT; movie->st[i].st = st; movie->max_stream_index = FFMAX(movie->max_stream_index, st->index); } if (av_strtok(NULL, "+", &cursor)) return AVERROR_BUG; movie->out_index = av_calloc(movie->max_stream_index + 1, sizeof(*movie->out_index)); if (!movie->out_index) return AVERROR(ENOMEM); for (i = 0; i <= movie->max_stream_index; i++) movie->out_index[i] = -1; for (i = 0; i < nb_streams; i++) movie->out_index[movie->st[i].st->index] = i; for (i = 0; i < nb_streams; i++) { AVFilterPad pad = { 0 }; snprintf(name, sizeof(name), "out%d", i); pad.type = movie->st[i].st->codec->codec_type; pad.name = av_strdup(name); pad.config_props = movie_config_output_props; pad.request_frame = movie_request_frame; ff_insert_outpad(ctx, i, &pad); ret = open_stream(ctx, &movie->st[i]); if (ret < 0) return ret; if ( movie->st[i].st->codec->codec->type == AVMEDIA_TYPE_AUDIO && !movie->st[i].st->codec->channel_layout) { ret = guess_channel_layout(&movie->st[i], i, ctx); if (ret < 0) return ret; } } if (!(movie->frame = avcodec_alloc_frame()) ) { av_log(log, AV_LOG_ERROR, "Failed to alloc frame\n"); return AVERROR(ENOMEM); } av_log(ctx, AV_LOG_VERBOSE, "seek_point:%"PRIi64" format_name:%s file_name:%s stream_index:%d\n", movie->seek_point, movie->format_name, movie->file_name, movie->stream_index); return 0; }
1threat
static void decode_lowdelay(DiracContext *s) { AVCodecContext *avctx = s->avctx; int slice_x, slice_y, bytes, bufsize; const uint8_t *buf; struct lowdelay_slice *slices; int slice_num = 0; slices = av_mallocz_array(s->lowdelay.num_x, s->lowdelay.num_y * sizeof(struct lowdelay_slice)); align_get_bits(&s->gb); buf = s->gb.buffer + get_bits_count(&s->gb)/8; bufsize = get_bits_left(&s->gb); for (slice_y = 0; bufsize > 0 && slice_y < s->lowdelay.num_y; slice_y++) for (slice_x = 0; bufsize > 0 && slice_x < s->lowdelay.num_x; slice_x++) { bytes = (slice_num+1) * s->lowdelay.bytes.num / s->lowdelay.bytes.den - slice_num * s->lowdelay.bytes.num / s->lowdelay.bytes.den; slices[slice_num].bytes = bytes; slices[slice_num].slice_x = slice_x; slices[slice_num].slice_y = slice_y; init_get_bits(&slices[slice_num].gb, buf, bufsize); slice_num++; buf += bytes; bufsize -= bytes*8; } avctx->execute(avctx, decode_lowdelay_slice, slices, NULL, slice_num, sizeof(struct lowdelay_slice)); intra_dc_prediction(&s->plane[0].band[0][0]); intra_dc_prediction(&s->plane[1].band[0][0]); intra_dc_prediction(&s->plane[2].band[0][0]); av_free(slices); }
1threat
static void synthfilt_build_sb_samples (QDM2Context *q, GetBitContext *gb, int length, int sb_min, int sb_max) { int sb, j, k, n, ch, run, channels; int joined_stereo, zero_encoding, chs; int type34_first; float type34_div = 0; float type34_predictor; float samples[10], sign_bits[16]; if (length == 0) { for (sb=sb_min; sb < sb_max; sb++) build_sb_samples_from_noise (q, sb); return; } for (sb = sb_min; sb < sb_max; sb++) { FIX_NOISE_IDX(q->noise_idx); channels = q->nb_channels; if (q->nb_channels <= 1 || sb < 12) joined_stereo = 0; else if (sb >= 24) joined_stereo = 1; else joined_stereo = (BITS_LEFT(length,gb) >= 1) ? get_bits1 (gb) : 0; if (joined_stereo) { if (BITS_LEFT(length,gb) >= 16) for (j = 0; j < 16; j++) sign_bits[j] = get_bits1 (gb); for (j = 0; j < 64; j++) if (q->coding_method[1][sb][j] > q->coding_method[0][sb][j]) q->coding_method[0][sb][j] = q->coding_method[1][sb][j]; fix_coding_method_array(sb, q->nb_channels, q->coding_method); channels = 1; } for (ch = 0; ch < channels; ch++) { zero_encoding = (BITS_LEFT(length,gb) >= 1) ? get_bits1(gb) : 0; type34_predictor = 0.0; type34_first = 1; for (j = 0; j < 128; ) { switch (q->coding_method[ch][sb][j / 2]) { case 8: if (BITS_LEFT(length,gb) >= 10) { if (zero_encoding) { for (k = 0; k < 5; k++) { if ((j + 2 * k) >= 128) break; samples[2 * k] = get_bits1(gb) ? dequant_1bit[joined_stereo][2 * get_bits1(gb)] : 0; } } else { n = get_bits(gb, 8); for (k = 0; k < 5; k++) samples[2 * k] = dequant_1bit[joined_stereo][random_dequant_index[n][k]]; } for (k = 0; k < 5; k++) samples[2 * k + 1] = SB_DITHERING_NOISE(sb,q->noise_idx); } else { for (k = 0; k < 10; k++) samples[k] = SB_DITHERING_NOISE(sb,q->noise_idx); } run = 10; break; case 10: if (BITS_LEFT(length,gb) >= 1) { float f = 0.81; if (get_bits1(gb)) f = -f; f -= noise_samples[((sb + 1) * (j +5 * ch + 1)) & 127] * 9.0 / 40.0; samples[0] = f; } else { samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx); } run = 1; break; case 16: if (BITS_LEFT(length,gb) >= 10) { if (zero_encoding) { for (k = 0; k < 5; k++) { if ((j + k) >= 128) break; samples[k] = (get_bits1(gb) == 0) ? 0 : dequant_1bit[joined_stereo][2 * get_bits1(gb)]; } } else { n = get_bits (gb, 8); for (k = 0; k < 5; k++) samples[k] = dequant_1bit[joined_stereo][random_dequant_index[n][k]]; } } else { for (k = 0; k < 5; k++) samples[k] = SB_DITHERING_NOISE(sb,q->noise_idx); } run = 5; break; case 24: if (BITS_LEFT(length,gb) >= 7) { n = get_bits(gb, 7); for (k = 0; k < 3; k++) samples[k] = (random_dequant_type24[n][k] - 2.0) * 0.5; } else { for (k = 0; k < 3; k++) samples[k] = SB_DITHERING_NOISE(sb,q->noise_idx); } run = 3; break; case 30: if (BITS_LEFT(length,gb) >= 4) samples[0] = type30_dequant[qdm2_get_vlc(gb, &vlc_tab_type30, 0, 1)]; else samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx); run = 1; break; case 34: if (BITS_LEFT(length,gb) >= 7) { if (type34_first) { type34_div = (float)(1 << get_bits(gb, 2)); samples[0] = ((float)get_bits(gb, 5) - 16.0) / 15.0; type34_predictor = samples[0]; type34_first = 0; } else { samples[0] = type34_delta[qdm2_get_vlc(gb, &vlc_tab_type34, 0, 1)] / type34_div + type34_predictor; type34_predictor = samples[0]; } } else { samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx); } run = 1; break; default: samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx); run = 1; break; } if (joined_stereo) { float tmp[10][MPA_MAX_CHANNELS]; for (k = 0; k < run; k++) { tmp[k][0] = samples[k]; tmp[k][1] = (sign_bits[(j + k) / 8]) ? -samples[k] : samples[k]; } for (chs = 0; chs < q->nb_channels; chs++) for (k = 0; k < run; k++) if ((j + k) < 128) q->sb_samples[chs][j + k][sb] = q->tone_level[chs][sb][((j + k)/2)] * tmp[k][chs]; } else { for (k = 0; k < run; k++) if ((j + k) < 128) q->sb_samples[ch][j + k][sb] = q->tone_level[ch][sb][(j + k)/2] * samples[k]; } j += run; } } } }
1threat
static void gen_ld(DisasContext *ctx, uint32_t opc, int rt, int base, int16_t offset) { TCGv t0, t1, t2; int mem_idx = ctx->mem_idx; if (rt == 0 && ctx->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F)) { return; } t0 = tcg_temp_new(); gen_base_offset_addr(ctx, t0, base, offset); switch (opc) { #if defined(TARGET_MIPS64) case OPC_LWU: tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEUL | ctx->default_tcg_memop_mask); gen_store_gpr(t0, rt); break; case OPC_LD: tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEQ | ctx->default_tcg_memop_mask); gen_store_gpr(t0, rt); break; case OPC_LLD: case R6_OPC_LLD: op_ld_lld(t0, t0, mem_idx, ctx); gen_store_gpr(t0, rt); break; case OPC_LDL: t1 = tcg_temp_new(); tcg_gen_qemu_ld_tl(t1, t0, mem_idx, MO_UB); tcg_gen_andi_tl(t1, t0, 7); #ifndef TARGET_WORDS_BIGENDIAN tcg_gen_xori_tl(t1, t1, 7); #endif tcg_gen_shli_tl(t1, t1, 3); tcg_gen_andi_tl(t0, t0, ~7); tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEQ); tcg_gen_shl_tl(t0, t0, t1); t2 = tcg_const_tl(-1); tcg_gen_shl_tl(t2, t2, t1); gen_load_gpr(t1, rt); tcg_gen_andc_tl(t1, t1, t2); tcg_temp_free(t2); tcg_gen_or_tl(t0, t0, t1); tcg_temp_free(t1); gen_store_gpr(t0, rt); break; case OPC_LDR: t1 = tcg_temp_new(); tcg_gen_qemu_ld_tl(t1, t0, mem_idx, MO_UB); tcg_gen_andi_tl(t1, t0, 7); #ifdef TARGET_WORDS_BIGENDIAN tcg_gen_xori_tl(t1, t1, 7); #endif tcg_gen_shli_tl(t1, t1, 3); tcg_gen_andi_tl(t0, t0, ~7); tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEQ); tcg_gen_shr_tl(t0, t0, t1); tcg_gen_xori_tl(t1, t1, 63); t2 = tcg_const_tl(0xfffffffffffffffeull); tcg_gen_shl_tl(t2, t2, t1); gen_load_gpr(t1, rt); tcg_gen_and_tl(t1, t1, t2); tcg_temp_free(t2); tcg_gen_or_tl(t0, t0, t1); tcg_temp_free(t1); gen_store_gpr(t0, rt); break; case OPC_LDPC: t1 = tcg_const_tl(pc_relative_pc(ctx)); gen_op_addr_add(ctx, t0, t0, t1); tcg_temp_free(t1); tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEQ); gen_store_gpr(t0, rt); break; #endif case OPC_LWPC: t1 = tcg_const_tl(pc_relative_pc(ctx)); gen_op_addr_add(ctx, t0, t0, t1); tcg_temp_free(t1); tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TESL); gen_store_gpr(t0, rt); break; case OPC_LWE: case OPC_LW: tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TESL | ctx->default_tcg_memop_mask); gen_store_gpr(t0, rt); break; case OPC_LHE: case OPC_LH: tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TESW | ctx->default_tcg_memop_mask); gen_store_gpr(t0, rt); break; case OPC_LHUE: case OPC_LHU: tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEUW | ctx->default_tcg_memop_mask); gen_store_gpr(t0, rt); break; case OPC_LBE: case OPC_LB: tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_SB); gen_store_gpr(t0, rt); break; case OPC_LBUE: case OPC_LBU: tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_UB); gen_store_gpr(t0, rt); break; case OPC_LWLE: case OPC_LWL: t1 = tcg_temp_new(); tcg_gen_qemu_ld_tl(t1, t0, mem_idx, MO_UB); tcg_gen_andi_tl(t1, t0, 3); #ifndef TARGET_WORDS_BIGENDIAN tcg_gen_xori_tl(t1, t1, 3); #endif tcg_gen_shli_tl(t1, t1, 3); tcg_gen_andi_tl(t0, t0, ~3); tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEUL); tcg_gen_shl_tl(t0, t0, t1); t2 = tcg_const_tl(-1); tcg_gen_shl_tl(t2, t2, t1); gen_load_gpr(t1, rt); tcg_gen_andc_tl(t1, t1, t2); tcg_temp_free(t2); tcg_gen_or_tl(t0, t0, t1); tcg_temp_free(t1); tcg_gen_ext32s_tl(t0, t0); gen_store_gpr(t0, rt); break; case OPC_LWR: t1 = tcg_temp_new(); tcg_gen_qemu_ld_tl(t1, t0, mem_idx, MO_UB); tcg_gen_andi_tl(t1, t0, 3); #ifdef TARGET_WORDS_BIGENDIAN tcg_gen_xori_tl(t1, t1, 3); #endif tcg_gen_shli_tl(t1, t1, 3); tcg_gen_andi_tl(t0, t0, ~3); tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEUL); tcg_gen_shr_tl(t0, t0, t1); tcg_gen_xori_tl(t1, t1, 31); t2 = tcg_const_tl(0xfffffffeull); tcg_gen_shl_tl(t2, t2, t1); gen_load_gpr(t1, rt); tcg_gen_and_tl(t1, t1, t2); tcg_temp_free(t2); tcg_gen_or_tl(t0, t0, t1); tcg_temp_free(t1); tcg_gen_ext32s_tl(t0, t0); gen_store_gpr(t0, rt); break; case OPC_LLE: case OPC_LL: case R6_OPC_LL: op_ld_ll(t0, t0, mem_idx, ctx); gen_store_gpr(t0, rt); break; } tcg_temp_free(t0); }
1threat
Python : How to create dictionary of unique words out of list of strings where words are mixed with symbols and numbers : <p>Lets say I have list = ["1 I love , you / hey", "0 Because . you / are cute ", ....]</p> <p>I want to create a set of unique words, avoiding digits and symbols. What would be the best way of doing it?</p> <p>Thanks</p>
0debug
static int proxy_close(FsContext *ctx, V9fsFidOpenState *fs) { return close(fs->fd); }
1threat
OpenGL points drawn disappear, draw call and swap buffer issue? c++ : I cannot figure out what I have done wrong here...I am wanting to draw points on screen from the vertex data already sent to the GPU using GL_POINTS. At the moment they are drawn for a split second and then disappear. I am using a time-dependent loop as I want the points to appear sequentially... if (currentTime > insertionRateTime) { cout << "insertionRateTime = " << insertionRateTime << "index" << index << endl; insertionRateTime += insertionRate; glDrawArrays(GL_POINTS, index, 1); index += 1; } glfwSwapBuffers(window); glfwPollEvents(); Can anybody shed any light here? If I place the glDrawArrays outside of the if statement then the points drawn remain until the next point is drawn :( Thanks,
0debug
Android: get child of Object : <p>My code is :</p> <pre><code>Object value = tasks.get(key); </code></pre> <p>result <code>value</code> is : <code>[{"name":"one","family":"yes"},{"name":"two","family":"no"}]</code></p> <p>Now i want get child of <code>value</code> in foreach</p> <pre><code>foreach(...){ String name = ... String family = ... } </code></pre>
0debug
Why does this recursive code print "1 2 3 4 5"? : <p>I am new to Recursion in Java and came across this code in a textbook. After running the code it prints "1 2 3 4 5" and am wondering why it doesn't print "5 4 3 2 1"?</p> <pre><code>public class Test { public static void main(String[] args) { xMethod(5); } public static void xMethod(int n) { if (n &gt; 0) { xMethod(n - 1); System.out.print(n + " "); } } } </code></pre>
0debug
static char *qio_channel_websock_handshake_entry(const char *handshake, size_t handshake_len, const char *name) { char *begin, *end, *ret = NULL; char *line = g_strdup_printf("%s%s: ", QIO_CHANNEL_WEBSOCK_HANDSHAKE_DELIM, name); begin = g_strstr_len(handshake, handshake_len, line); if (begin != NULL) { begin += strlen(line); end = g_strstr_len(begin, handshake_len - (begin - handshake), QIO_CHANNEL_WEBSOCK_HANDSHAKE_DELIM); if (end != NULL) { ret = g_strndup(begin, end - begin); } } g_free(line); return ret; }
1threat
vpc_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { BDRVVPCState *s = bs->opaque; int ret; int64_t image_offset; int64_t n_bytes; int64_t bytes_done = 0; VHDFooter *footer = (VHDFooter *) s->footer_buf; QEMUIOVector local_qiov; if (be32_to_cpu(footer->type) == VHD_FIXED) { return bdrv_co_preadv(bs->file, offset, bytes, qiov, 0); } qemu_co_mutex_lock(&s->lock); qemu_iovec_init(&local_qiov, qiov->niov); while (bytes > 0) { image_offset = get_image_offset(bs, offset, false); n_bytes = MIN(bytes, s->block_size - (offset % s->block_size)); if (image_offset == -1) { qemu_iovec_memset(qiov, bytes_done, 0, n_bytes); } else { qemu_iovec_reset(&local_qiov); qemu_iovec_concat(&local_qiov, qiov, bytes_done, n_bytes); ret = bdrv_co_preadv(bs->file, image_offset, n_bytes, &local_qiov, 0); if (ret < 0) { goto fail; } } bytes -= n_bytes; offset += n_bytes; bytes_done += n_bytes; } ret = 0; fail: qemu_iovec_destroy(&local_qiov); qemu_co_mutex_unlock(&s->lock); return ret; }
1threat
when i change my orientation from portrait to landscape it replays the splash screen : when i change my orientation from portrait to landscape it replays the splash screen then loads my weburl but is there a way to just let it continue where it was so it doesn't replay the whole process i have tried "android:configChanges="orientation|screenSize" but nothing seems to be working which is why im making a new post.
0debug
Microsoft SQL: Update multiple Rows using combined Values and compare them to Values from another Table : I have two Tables im my MS-SQL Database: Table 1 looks like this: ---------- <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <table> <tr> <th>Material</th> <th>Semifinished</th> <th>Number</th> </tr> <tr> <td>Steel</td> <td>Flat 1x2</td> <td></td> </tr> <tr> <td>Iron</td> <td>Round 100x200</td> <td></td> </tr> </table> <!-- end snippet --> ---------- Table 2 looks like this: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <table> <tr> <th>Material</th> <th>Semifinished</th> <th>Number</th> </tr> <tr> <td>Steel</td> <td>Flat 1x2</td> <td>8991</td> </tr> <tr> <td>Iron</td> <td>Round 100x200</td> <td>1234</td> </tr> </table> <!-- end snippet --> ---------- Now i want to insert the values of the collumn "Number" from Table 2 into the Collumn "Number" from Table 1. The criteria for that should be the combination of columne "Material" and columne "Semifinished" I tried this before: update T1 set T1.NUMBER = T2.NUMBER FROM TABLE1 AS T1 INNER JOIN TABLE2 AS T2 ON T1.MATERIAL + T1.SEMIFINISHED = T2.MATERIAL + T2.SEMIFINISHED WHERE T1.MATERIAL + T1.SEMIFINISHED = T2.MATERIAL + T2.SEMIFINISHED I also tried this one: ALTER TABLE TABLE1 ADD [NEWCOL] varchar(100) ALTER TABLE TABLE2 ADD [NEWCOL] varchar(100) update TABLE1 set NEWCOL = MATERIAL + SEMIFINISHED update TABLE2 set NEWCOL = MATERIAL + SEMIFINISHED update T1 set T1.NUMBER = T2.NUMBER FROM TABLE1 AS T1 INNER JOIN TABLE2 AS T2 ON T1.NEWCOL = T2.NEWCOL WHERE T1.NEWCOL = T2.NEWCOL
0debug
PCIBus *pci_grackle_init(uint32_t base, qemu_irq *pic) { DeviceState *dev; SysBusDevice *s; GrackleState *d; dev = qdev_create(NULL, "grackle"); qdev_init(dev); s = sysbus_from_qdev(dev); d = FROM_SYSBUS(GrackleState, s); d->host_state.bus = pci_register_bus(&d->busdev.qdev, "pci", pci_grackle_set_irq, pci_grackle_map_irq, pic, 0, 4); pci_create_simple(d->host_state.bus, 0, "grackle"); sysbus_mmio_map(s, 0, base); sysbus_mmio_map(s, 1, base + 0x00200000); return d->host_state.bus; }
1threat
How to get exact date if i change device date : Now the exact date is 8-Jun-2018 But if I change the device date to future or past (i.e 21-Jun-2018 or 21-Feb-2018) How to get exact date i.e 8-Jun-2018
0debug
static void init_parse_context(OptionParseContext *octx, const OptionGroupDef *groups, int nb_groups) { static const OptionGroupDef global_group = { "global" }; int i; memset(octx, 0, sizeof(*octx)); octx->nb_groups = nb_groups; octx->groups = av_mallocz(sizeof(*octx->groups) * octx->nb_groups); if (!octx->groups) exit(1); for (i = 0; i < octx->nb_groups; i++) octx->groups[i].group_def = &groups[i]; octx->global_opts.group_def = &global_group; octx->global_opts.arg = ""; init_opts(); }
1threat
regular express quetion - what's wrong with my expression? : i have a difficult by build a regex. Suppose there is a html clip as under. I want to use Javascript to cut the <tbody> part with the link of "apple"(which <a> is inside of the <td class="by">) I make the expression : /<tbody.*?text[\s\S]*?<td class="by"[\s\S]*?<a.*?>apple<\/a>[\s\S]*?<\/tbody>/g But the result is different as i wanted. Each match contains more than one block of <tbody>. How it should be? Regards!!!! <tbody id="text_0"> <td class="by"> <a href="xxx">cat</a> </td> </tbody> <tbody id="text_1"> <td class="by"> <a href="xxx">apple</a> </td> </tbody> <tbody id="text_2"> <td class="by"> <a href="xxx">cat</a> </td> </tbody> <tbody id="text_3"> <td class="by"> <a href="xxx">tiger</a> </td> </tbody> <tbody id="text_4"> <td class="by"> <a href="xxx">banana</a> </td> </tbody> <tbody id="text_5"> <td class="by"> <a href="xxx">peach</a> </td> </tbody> <tbody id="text_6"> <td class="by"> <a href="xxx">apple</a> </td> </tbody> <tbody id="text_7"> <td class="by"> <a href="xxx">banana</a> </td> </tbody>
0debug
Python Pros. Extreme Need. For people who know how to use groupby() : I'm new to python, can anybody break down the process here per line? What does the highlighted numbers use is for? Thank you [enter image description here][1] [1]: https://i.stack.imgur.com/scwpy.png
0debug
static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag, uint8_t *cmd, int lun) { SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, d); SCSIGenericReq *r; SCSIBus *bus; int ret; if (cmd[0] != REQUEST_SENSE && (lun != s->lun || (cmd[1] >> 5) != s->lun)) { DPRINTF("Unimplemented LUN %d\n", lun ? lun : cmd[1] >> 5); s->sensebuf[0] = 0x70; s->sensebuf[1] = 0x00; s->sensebuf[2] = ILLEGAL_REQUEST; s->sensebuf[3] = 0x00; s->sensebuf[4] = 0x00; s->sensebuf[5] = 0x00; s->sensebuf[6] = 0x00; s->senselen = 7; s->driver_status = SG_ERR_DRIVER_SENSE; bus = scsi_bus_from_device(d); bus->ops->complete(bus, SCSI_REASON_DONE, tag, CHECK_CONDITION); return 0; } r = scsi_find_request(s, tag); if (r) { BADF("Tag 0x%x already in use %p\n", tag, r); scsi_cancel_io(d, tag); } r = scsi_new_request(d, tag, lun); if (-1 == scsi_req_parse(&r->req, cmd)) { BADF("Unsupported command length, command %x\n", cmd[0]); scsi_remove_request(r); return 0; } scsi_req_fixup(&r->req); DPRINTF("Command: lun=%d tag=0x%x len %zd data=0x%02x", lun, tag, r->req.cmd.xfer, cmd[0]); #ifdef DEBUG_SCSI { int i; for (i = 1; i < r->req.cmd.len; i++) { printf(" 0x%02x", cmd[i]); } printf("\n"); } #endif if (r->req.cmd.xfer == 0) { if (r->buf != NULL) qemu_free(r->buf); r->buflen = 0; r->buf = NULL; ret = execute_command(s->bs, r, SG_DXFER_NONE, scsi_command_complete); if (ret == -1) { scsi_command_complete(r, -EINVAL); return 0; } return 0; } if (r->buflen != r->req.cmd.xfer) { if (r->buf != NULL) qemu_free(r->buf); r->buf = qemu_malloc(r->req.cmd.xfer); r->buflen = r->req.cmd.xfer; } memset(r->buf, 0, r->buflen); r->len = r->req.cmd.xfer; if (r->req.cmd.mode == SCSI_XFER_TO_DEV) { r->len = 0; return -r->req.cmd.xfer; } return r->req.cmd.xfer; }
1threat
error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually : <p>This error came up after upgrading to React Native 0.60.</p> <p>I've tried to manually unlink each manually linked dependency using <code>react-native unlink &lt;dependency&gt;</code> as suggested in the error message, but the problem still persists.</p> <p>The error message is as follows:</p> <pre><code>error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually: - react-native-admob (to unlink run: "react-native unlink react-native-admob") - react-native-facebook-account-kit (to unlink run: "react-native unlink react-native-facebook-account-kit") - react-native-fbsdk (to unlink run: "react-native unlink react-native-fbsdk") - react-native-gesture-handler (to unlink run: "react-native unlink react-native-gesture-handler") - react-native-linear-gradient (to unlink run: "react-native unlink react-native-linear-gradient") - react-native-localization (to unlink run: "react-native unlink react-native-localization") - react-native-restart (to unlink run: "react-native unlink react-native-restart") - react-native-vector-icons (to unlink run: "react-native unlink react-native-vector-icons") - react-native-webview (to unlink run: "react-native unlink react-native-webview") This is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via "react-native unlink &lt;dependency&gt;" and it will be included in your app automatically. If a library isn't compatible with autolinking, disregard this message and notify the library maintainers. Read more about autolinking: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md </code></pre>
0debug
creating background drawable using layer-list, icon getting stretched : <p>Hi I am trying to create a background <code>drawable</code> for my splash screen which I'll be setting in theme itself. But the bitmap drawable used to keep in the center is getting stretched and I am not able to figure how to keep it normal. Below is my drawable code: <strong>splash_screen_bg.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;layer-list xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item&gt; &lt;shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"&gt; &lt;gradient android:angle="360" android:centerColor="@color/colorAccentXDark" android:endColor="@color/Black" android:gradientRadius="500dp" android:startColor="@color/colorAccentXDark" android:type="radial" android:useLevel="false" /&gt; &lt;/shape&gt; &lt;/item&gt; &lt;item android:bottom="50dp" android:top="50dp"&gt; &lt;shape xmlns:android="http://schemas.android.com/apk/res/android" android:innerRadius="500dp" android:innerRadiusRatio="1" android:shape="oval"&gt; &lt;gradient android:angle="360" android:centerColor="@color/colorAccentXDark" android:endColor="@color/colorAccentXDark" android:gradientRadius="400dp" android:startColor="@color/colorAccent" android:type="radial" android:useLevel="false" /&gt; &lt;/shape&gt; &lt;/item&gt; &lt;item android:gravity="center"&gt; &lt;bitmap android:src="@drawable/ty_logo" /&gt; &lt;/item&gt; &lt;/layer-list&gt; </code></pre> <p>Here is code where I am setting this drawable as background of an activity:</p> <pre><code> &lt;style name="TYTheme" parent="SearchActivityTheme.NoActionBar"&gt; &lt;item name="colorPrimaryDark"&gt;@color/colorAccentXDark&lt;/item&gt; &lt;item name="android:alertDialogTheme"&gt;@style/AlertDialogTheme&lt;/item&gt; &lt;item name="android:windowBackground"&gt;@drawable/splash_screen_bg&lt;/item&gt; &lt;/style&gt; </code></pre> <p>So here the bitmap drawable <code>ty_logo</code> is an <code>png</code> is getting stretched in my phone. Since there is no <code>scaleType</code> option with <code>bitmapDrawable</code> I don't know how to handle it. </p>
0debug
Alternative of Dictionary<String,Any> in Swift3? : I know that my Dictionary will be either `<String,String>` or it will be `<String,NSNumber>` , Is there any way i can tell this to Swift compiler at the declaration time , rather than declaring `<String,Any>` or `<String,AnyObject>` ?
0debug
Why only interfaces can be delegated to in kotlin? : <p>I have seen few similar questions, but none had explained why delegation is limited to interfaces?</p> <p>Most of the time in practice we have something that has actually no interface at all, it is a class that implements nothing but provides some functionality or implements an abstract class.</p> <p>Is there any fundamental limitation that forces this to be limited to interfaces or can we expect kotlin to have unrestricted delegation in the future?</p> <p>This is especially useful if we want to extend functionality of a class using composition not inheritance.</p> <pre><code>class A {} class B(val a: A) : A by a {} </code></pre>
0debug
PHP Operators, how do I make the code shorter? : Original code: if(mimeType == 'image/jpeg' or mimeType == 'image/png' or mimeType == 'image/gif' && filename) I tried this, but it will include unwanted *pdf. if (mimeType == ('image/jpeg' ||'image/png' ||'image/gif') && $part->filename) How do I make the code shorter ? Thank you.
0debug
Docker mount S3 container : <p>What is your best practise for mounting an S3 container inside of a docker host? Is there a way to do this transparently? Or do I rather need to mount volume to the host drive using the VOLUME directive, and then backup files to S3 with CRON manually?</p>
0debug
static int escape124_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { int buf_size = avpkt->size; Escape124Context *s = avctx->priv_data; AVFrame *frame = data; GetBitContext gb; unsigned frame_flags, frame_size; unsigned i; unsigned superblock_index, cb_index = 1, superblock_col_index = 0, superblocks_per_row = avctx->width / 8, skip = -1; uint16_t* old_frame_data, *new_frame_data; unsigned old_stride, new_stride; int ret; if ((ret = init_get_bits8(&gb, avpkt->data, avpkt->size)) < 0) return ret; if (get_bits_left(&gb) < 64) return -1; frame_flags = get_bits_long(&gb, 32); frame_size = get_bits_long(&gb, 32); if (!(frame_flags & 0x114) || !(frame_flags & 0x7800000)) { if (!s->frame->data[0]) av_log(avctx, AV_LOG_DEBUG, "Skipping frame\n"); *got_frame = 1; if ((ret = av_frame_ref(frame, s->frame)) < 0) return ret; return frame_size; for (i = 0; i < 3; i++) { if (frame_flags & (1 << (17 + i))) { unsigned cb_depth, cb_size; if (i == 2) { cb_size = get_bits_long(&gb, 20); if (!cb_size) { av_log(avctx, AV_LOG_ERROR, "Invalid codebook size 0.\n"); cb_depth = av_log2(cb_size - 1) + 1; } else { cb_depth = get_bits(&gb, 4); if (i == 0) { cb_size = 1 << cb_depth; } else { cb_size = s->num_superblocks << cb_depth; av_freep(&s->codebooks[i].blocks); s->codebooks[i] = unpack_codebook(&gb, cb_depth, cb_size); if (!s->codebooks[i].blocks) return -1; if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0) return ret; new_frame_data = (uint16_t*)frame->data[0]; new_stride = frame->linesize[0] / 2; old_frame_data = (uint16_t*)s->frame->data[0]; old_stride = s->frame->linesize[0] / 2; for (superblock_index = 0; superblock_index < s->num_superblocks; superblock_index++) { MacroBlock mb; SuperBlock sb; unsigned multi_mask = 0; if (skip == -1) { skip = decode_skip_count(&gb); if (skip) { copy_superblock(new_frame_data, new_stride, old_frame_data, old_stride); } else { copy_superblock(sb.pixels, 8, old_frame_data, old_stride); while (get_bits_left(&gb) >= 1 && !get_bits1(&gb)) { unsigned mask; mb = decode_macroblock(s, &gb, &cb_index, superblock_index); mask = get_bits(&gb, 16); multi_mask |= mask; for (i = 0; i < 16; i++) { if (mask & mask_matrix[i]) { insert_mb_into_sb(&sb, mb, i); if (!get_bits1(&gb)) { unsigned inv_mask = get_bits(&gb, 4); for (i = 0; i < 4; i++) { if (inv_mask & (1 << i)) { multi_mask ^= 0xF << i*4; } else { multi_mask ^= get_bits(&gb, 4) << i*4; for (i = 0; i < 16; i++) { if (multi_mask & mask_matrix[i]) { mb = decode_macroblock(s, &gb, &cb_index, superblock_index); insert_mb_into_sb(&sb, mb, i); } else if (frame_flags & (1 << 16)) { while (get_bits_left(&gb) >= 1 && !get_bits1(&gb)) { mb = decode_macroblock(s, &gb, &cb_index, superblock_index); insert_mb_into_sb(&sb, mb, get_bits(&gb, 4)); copy_superblock(new_frame_data, new_stride, sb.pixels, 8); superblock_col_index++; new_frame_data += 8; if (old_frame_data) old_frame_data += 8; if (superblock_col_index == superblocks_per_row) { new_frame_data += new_stride * 8 - superblocks_per_row * 8; if (old_frame_data) old_frame_data += old_stride * 8 - superblocks_per_row * 8; superblock_col_index = 0; skip--; av_log(avctx, AV_LOG_DEBUG, "Escape sizes: %i, %i, %i\n", frame_size, buf_size, get_bits_count(&gb) / 8); av_frame_unref(s->frame); if ((ret = av_frame_ref(s->frame, frame)) < 0) return ret; *got_frame = 1; return frame_size;
1threat
Website database not updating automatically : <p>I have a script which i made myself, it's doing the following: -Crawl database to see if current date equals date of a value in the database if true: Add +7 days to the date and then get the Ascending value of a date. It's supposed to update each sunday</p> <p>but the problem is: The crawling and updating only happends if someone visits the website specifically on the date where it's supposed to be updated.</p> <p>So for instance if there is a date in the database which equals 2019/1/11 and the current date is 2019/1/11 , it's updating it to that date + 7 days. </p> <p>BUT only updates when visiting the site on 2019/1/11. If visiting the site on 2019/1/12 the updating does not work anymore</p> <p>How can i make it update itself / running the php code without someone having to visit it for it to update?</p>
0debug
Two way binding in RxSwift : <p>I read the two way binding operator in sample code of RxSwift.</p> <pre><code>func &lt;-&gt; &lt;T&gt;(property: ControlProperty&lt;T&gt;, variable: Variable&lt;T&gt;) -&gt; Disposable { let bindToUIDisposable = variable.asObservable() .bindTo(property) let bindToVariable = property .subscribe(onNext: { n in variable.value = n }, onCompleted: { bindToUIDisposable.dispose() }) return StableCompositeDisposable.create(bindToUIDisposable, bindToVariable) } </code></pre> <p>When <code>property</code> changed, it will notify variable, and set the variable's value, while the variable's value is set, it will notify the property. I think it will lead to endless loop...</p>
0debug
Angular 2: Iterate over reactive form controls : <p>I would like to <code>markAsDirty</code> all the controls inside of a <code>FormGroup</code>.</p>
0debug
alert('Hello ' + user_input);
1threat
Bulk Insert with format file NOT skipping column in destination table with 146 fields as it should be : <p>Here is the full error:</p> <p>Msg 4864, Level 16, State 1, Line 3 Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 5 (FK_User_CreatedBy).</p> <p>And here is the existential snapshot of my pain :)</p> <p><a href="https://i.stack.imgur.com/lEEYd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lEEYd.png" alt="enter image description here"></a></p> <p><strong>Many questions touch on these issues, <a href="https://msdn.microsoft.com/en-gb/library/ms179250.aspx" rel="noreferrer">but none of them do the trick...</a></strong></p> <p>I suspect my problem is something like described <a href="https://social.msdn.microsoft.com/Forums/sqlserver/en-US/3e6ac2df-5f80-4bc9-bce3-7009d7908400/how-to-bulk-insert-rows-from-text-file-into-a-wide-table-which-has-1400-columns?forum=transactsql" rel="noreferrer">here</a>, but I am not sure. The destination table column that is not being skipped properly is NOT sparse.</p> <p><a href="https://i.stack.imgur.com/ATGPs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ATGPs.png" alt="enter image description here"></a></p> <p>Here is the two row data file for import (.csv) open in notepad and notepad++: (Yes I am aware that the row terminator is \r\n and the field/column terminator is \t or ',')</p> <p><a href="https://i.stack.imgur.com/tlFK3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/tlFK3.png" alt="enter image description here"></a></p> <p>Here it is in plain text:</p> <pre><code>1,fArty,Padul,1,10/1/1962,Head of ,Australia,AU Talavera Centre,NSW,7 CSU,farty.randy@gummibaer.com 2,mifsm,Jodel,1,10/1/1970,Chief Officer,Australia,AU ,NSW,8 CSU,midsm@gummibaer.com </code></pre> <p><strong>CONTEXT/BACKGROUND:</strong> <strong>Test on Small Table and Input File with Few Records</strong> (remember it is column skipping on a table with many columns that ends up hurting)...</p> <p>The import WORKS perfectly for a small database table that looks like this:</p> <p><a href="https://i.stack.imgur.com/UCtNW.png" rel="noreferrer"><img src="https://i.stack.imgur.com/UCtNW.png" alt="enter image description here"></a></p> <p>And is created thus:</p> <p><a href="https://i.stack.imgur.com/32e3r.png" rel="noreferrer"><img src="https://i.stack.imgur.com/32e3r.png" alt="enter image description here"></a></p> <p>Here is the code for the table create:</p> <pre><code> DROP TABLE dbo.tbl_Person_Importtest CREATE TABLE dbo.tbl_Person_Importtest ( ID int PRIMARY KEY NOT NULL, LastName varchar(100) NOT NULL, FirstName varchar(100) NOT NULL, FK_Gender varchar(4) NOT NULL, DateOfBirth date NOT NULL, JobTitle varchar(200) NOT NULL, Address1Country varchar(50) NOT NULL, Location varchar(200) NOT NULL, Address1StateOrProvince varchar(50) NOT NULL, Department varchar(200) NOT NULL, EMailAddress1 varchar(200) NOT NULL ) </code></pre> <p>The .xml bulk insert format file looks like this:</p> <p><a href="https://i.stack.imgur.com/eiroi.png" rel="noreferrer"><img src="https://i.stack.imgur.com/eiroi.png" alt="enter image description here"></a></p> <p>Note that it also works if I skip the ID (PK + index) column since the database table is empty and the import file does not have an index. This is working fine for the small destination table, as the database is generating the primary key index.</p> <p>Here the format file as text ():</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;BCPFORMAT xmlns="http://schemas.microsoft.com/sqlserver/2004/bulkload/format" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt; &lt;RECORD&gt; &lt;FIELD ID="1" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="12"/&gt; &lt;FIELD ID="2" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="100" COLLATION="Latin1_General_CI_AS"/&gt; &lt;FIELD ID="3" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="100" COLLATION="Latin1_General_CI_AS"/&gt; &lt;FIELD ID="4" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="4" COLLATION="Latin1_General_CI_AS"/&gt; &lt;FIELD ID="5" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="11"/&gt; &lt;FIELD ID="6" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="200" COLLATION="Latin1_General_CI_AS"/&gt; &lt;FIELD ID="7" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="50" COLLATION="Latin1_General_CI_AS"/&gt; &lt;FIELD ID="8" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="200" COLLATION="Latin1_General_CI_AS"/&gt; &lt;FIELD ID="9" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="50" COLLATION="Latin1_General_CI_AS"/&gt; &lt;FIELD ID="10" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="200" COLLATION="Latin1_General_CI_AS"/&gt; &lt;FIELD ID="11" xsi:type="CharTerm" TERMINATOR="\r\n" MAX_LENGTH="200" COLLATION="Latin1_General_CI_AS"/&gt; &lt;/RECORD&gt; &lt;ROW&gt; &lt;COLUMN SOURCE="1" NAME="ID" xsi:type="SQLINT"/&gt; &lt;COLUMN SOURCE="2" NAME="LastName" xsi:type="SQLVARYCHAR"/&gt; &lt;COLUMN SOURCE="3" NAME="FirstName" xsi:type="SQLVARYCHAR"/&gt; &lt;COLUMN SOURCE="4" NAME="FK_Gender" xsi:type="SQLVARYCHAR"/&gt; &lt;COLUMN SOURCE="5" NAME="DateOfBirth" xsi:type="SQLDATE"/&gt; &lt;COLUMN SOURCE="6" NAME="JobTitle" xsi:type="SQLVARYCHAR"/&gt; &lt;COLUMN SOURCE="7" NAME="Address1Country" xsi:type="SQLVARYCHAR"/&gt; &lt;COLUMN SOURCE="8" NAME="Location" xsi:type="SQLVARYCHAR"/&gt; &lt;COLUMN SOURCE="9" NAME="Address1StateOrProvince" xsi:type="SQLVARYCHAR"/&gt; &lt;COLUMN SOURCE="10" NAME="Department" xsi:type="SQLVARYCHAR"/&gt; &lt;COLUMN SOURCE="11" NAME="EMailAddress1" xsi:type="SQLVARYCHAR"/&gt; &lt;/ROW&gt; &lt;/BCPFORMAT&gt; </code></pre> <p>And it was created using bcp at the command line like this:</p> <p><a href="https://i.stack.imgur.com/UTxfz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/UTxfz.png" alt="enter image description here"></a></p> <p>Here is the bcp command line in text:</p> <p>bcp YFP..tbl_Person_Importtest format nul -f PersonImportMapFile.xml -c -x -T</p> <p>Now when I execute the import with all of these files against the empty small table, all is good:</p> <p><a href="https://i.stack.imgur.com/jnjNu.png" rel="noreferrer"><img src="https://i.stack.imgur.com/jnjNu.png" alt="enter image description here"></a></p> <p>If I insert more rows again, no problem... <a href="https://i.stack.imgur.com/SoCQs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SoCQs.png" alt="enter image description here"></a> <a href="https://i.stack.imgur.com/CNOzC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/CNOzC.png" alt="enter image description here"></a></p> <p><strong>THE LARGE TABLE</strong> I cannot include a full description due to intellectual property issues, but the large destination table has 146 fields with no sparse fields and plenty of DATETIME and DATE fields, as well as stacks of foreign keys (mostly INT) some of which are nullable. Here is the map file as generated by bcp (With Field names truncated and some removed):</p> <pre><code> CREATE TABLE [dbo].[tbl_Person]( [ID] [int] IDENTITY(1,1) NOT NULL, [RecordTitle] [nvarchar](250) NULL, [SecurityCode] [nvarchar](250) NULL, [DateCreated] [smalldatetime] NOT NULL, [FK_User_CreatedBy] [int] NULL, [wning] [int] NULL, [ssigned] [int] NULL, [ollowup] [int] NULL, [sation_Owning] [int] NULL, [wning] [int] NULL, [pdate] [smalldatetime] NULL, [astUpdate] [int] NULL, [tatus] [bit] NULL, [ive] [smalldatetime] NULL, [eason] [nvarchar](250) NULL, [tatus] [bit] NULL, [ion] [smalldatetime] NULL, [Titles] [int] NULL, [LastName] [varchar](50) NOT NULL, [FirstName] [varchar](50) NOT NULL, [MiddleName] [nvarchar](50) NULL, [DateOfBirth] [datetime] NULL, [ion] [ntext] NULL, [Code] [nvarchar](50) NULL, [r] [int] NULL, [] [nvarchar](100) NULL, [nt] [nvarchar](100) NULL, [ame] [nvarchar](100) NULL, [hone] [nvarchar](50) NULL, [tName] [nvarchar](100) NULL, [e1] [nvarchar](50) NULL, [e2] [nvarchar](50) NULL, [one1] [nvarchar](50) NULL, [Moe2] [nvarchar](50) NULL, [Fax] [nvarchar](50) NULL, [e1] [nvarchar](250) NULL, [e2] [nvarchar](250) NULL, [e3] [nvarchar](250) NULL, [Address1CityOrSuburb] [nvarchar](50) NULL, [Address1StateOrProvince] [nvarchar](50) NULL, [Address1Country] [nvarchar](50) NULL, [Address1PostalCode] [nvarchar](20) NULL, [Line1] [nvarchar](250) NULL, [Line2] [nvarchar](250) NULL, [Line3] [nvarchar](250) NULL, [CityOrSuburb] [nvarchar](50) NULL, [StateOrProvince] [nvarchar](50) NULL, [Country] [nvarchar](50) NULL, [PostalCode] [nvarchar](20) NULL, [RL] [nvarchar](200) NULL, [ress1] [nvarchar](100) NULL, [ress2] [nvarchar](100) NULL, [ne] [bit] NULL, [] [bit] NULL, [il] [bit] NULL, [tail] [bit] NULL, [kEl] [bit] NULL, [kPalMail] [bit] NULL, [dMM] [bit] NULL, [_Preferred] [int] NULL, [] [int] NULL, [onStatus] [int] NULL, [1] [money] NULL, [2] [money] NULL, [3] [money] NULL, [4] [money] NULL, [5] [money] NULL, [6] [money] NULL, [ncome] [money] NULL, [rInc1] [money] NULL, [rInc2] [money] NULL, [rInc3] [money] NULL, [rInc4] [money] NULL, [rInc5] [money] NULL, [rInc6] [money] NULL, [artner] [money] NULL, [1] [money] NULL, [2] [money] NULL, [3] [money] NULL, [4] [money] NULL, [5] [money] NULL, [6] [money] NULL, [7] [money] NULL, [8] [money] NULL, [ud] [money] NULL, [] [money] NULL, [] [money] NULL, [] [money] NULL, [] [money] NULL, [] [money] NULL, [] [money] NULL, [lAss] [money] NULL, [1] [money] NULL, [2] [money] NULL, [3] [money] NULL, [4] [money] NULL, [5] [money] NULL, [lDebt] [money] NULL, [rganisation_Provider] [int] NULL, [Insurance] [money] NULL, [ver] [money] NULL, [itd] [nvarchar](250) NULL, [veod] [nvarchar](250) NULL, [fiNominated] [bit] NULL, [ [money] NULL, [idD] [nvarchar](50) NULL, [ccs] [int] NULL, [mpus] [int] NULL, [ry] [money] NULL, [feInsurance] [bit] NULL, [Cor] [bit] NULL, [ov] [money] NULL, [DCer] [bit] NULL, [mous] [int] NULL, [iftatus] [int] NULL, [PCos] [int] NULL, [PDCus] [int] NULL, [ersned] [int] NULL, [ueKey] [uniqueidentifier] NULL, [rified] [bit] NULL, [Actr] [smalldatetime] NULL, [embpe] [int] NULL, [etAult] [money] NULL, [t7] [money] NULL, [t8] [money] NULL, [6] [money] NULL, [7] [money] NULL, [8] [money] NULL, [onalScore] [nvarchar](10) NULL, [] [int] NULL, [rganment] [int] NULL, [rac] [int] NULL, [kerpdate] [datetime] NULL, [keriew] [datetime] NULL, [ari] [int] NULL, [] [int] NULL, [Q1] [int] NULL, [Q2] [int] NULL, [Q3] [int] NULL, [Q4] [int] NULL, [Q5] [int] NULL, [Q6] [int] NULL, [Q7] [int] NULL, [Q8] [int] NULL, [Q9] [int] NULL, [Q10] [int] NULL, CONSTRAINT [PK_tbl_Person] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] </code></pre> <p><strong>Outcome</strong></p> <p>I should be able to import into this table using the same data file as I specified for the example with the smaller table above, but I am getting the error specified at the beginning of this question.</p> <p>The field it is picking on is indeed the fifth field/column in the table, but it is supposed to be skipping to the fields named in the map only, according to <a href="https://msdn.microsoft.com/en-gb/library/ms179250.aspx" rel="noreferrer">this MS tutorial</a>.</p> <p>IT just looks like I will need to use a staging table or other programmatic approach wit middleware or SQLBulkCopy (c# .NET), and I would prefer not to do this at this stage. I would just like the map file to work.</p> <p><strong>Did I miss something, or is it a case of shoot the BULK INSERT with-map-file for-large-table horse and get a different ride?</strong></p>
0debug
Application does not implement dagger.android.HasDispatchingActivityInjector : <p>I have a subclass of Application that I am conforming to HasDispatchingActivityInjector, but when I try and run my app it will crash, saying:</p> <pre><code>Unable to start activity ComponentInfo{com.test.testing/com.test.testing.ui.main.MainActivity}: java.lang.RuntimeException: android.app.Application does not implement dagger.android.HasDispatchingActivityInjector </code></pre> <p>This is my Application subclass:</p> <pre><code>class MyApplication : Application(), HasDispatchingActivityInjector { @Inject lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector&lt;Activity&gt; override fun onCreate() { super.onCreate() DaggerAppComponent.create().inject(this) } override fun activityInjector(): DispatchingAndroidInjector&lt;Activity&gt; { return dispatchingAndroidInjector } </code></pre> <p>Has anyone else experienced this error before?</p> <p>Thanks</p>
0debug
How to unit test ActionFilterAttribute : <p>I'm looking to test an ActionFilterAttribute in a .NET Core 2.0 API project and wondering the best way to go about it. Note, I'm not trying to test this through a controller action, merely test the ActionFilterAttribute itself.</p> <p>How might I go about testing this:</p> <pre><code> public class ValidateModelAttribute : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext context) { if (!context.ModelState.IsValid) { context.Result = new BadRequestObjectResult(context.ModelState); } } } </code></pre>
0debug