problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Why kotlin allows to declare variable with the same name as parameter inside the method? : <p>Why kotlin allows to declare variable with the same name as parameter inside the method?
And is there any way to access 'hidden' parameter then?</p>
<p>Example:</p>
<pre><code>fun main(args: Array<String>) {
val args = Any()
}
</code></pre>
| 0debug
|
static CharDriverState *qmp_chardev_open_parallel(const char *id,
ChardevBackend *backend,
ChardevReturn *ret,
Error **errp)
{
ChardevHostdev *parallel = backend->u.parallel;
int fd;
fd = qmp_chardev_open_file_source(parallel->device, O_RDWR, errp);
if (fd < 0) {
return NULL;
}
return qemu_chr_open_pp_fd(fd, errp);
}
| 1threat
|
MYSQL: How to written multiple where clouse in one line while join two tables : Error on my query
SELECT a.`id`, a.`name`, b.`email` FROM `table_1` a, `table_2` b WHERE a.`id`, b.`id` = 5
| 0debug
|
Occurance by Month : I want to count, how many times the item has been used in a years period and the criteria is month. For example item x has been used in January, February and August.
Data in my table is arranged :
A:A - all dates during 2018
B:B - all item numbers
C:C - item numbers without duplicates
| 0debug
|
static void port92_write(void *opaque, hwaddr addr, uint64_t val,
unsigned size)
{
Port92State *s = opaque;
int oldval = s->outport;
DPRINTF("port92: write 0x%02" PRIx64 "\n", val);
s->outport = val;
qemu_set_irq(*s->a20_out, (val >> 1) & 1);
if ((val & 1) && !(oldval & 1)) {
qemu_system_reset_request();
}
}
| 1threat
|
void os_setup_post(void)
{
int fd = 0;
if (daemonize) {
uint8_t status = 0;
ssize_t len;
again1:
len = write(daemon_pipe, &status, 1);
if (len == -1 && (errno == EINTR)) {
goto again1;
}
if (len != 1) {
exit(1);
}
if (chdir("/")) {
perror("not able to chdir to /");
exit(1);
}
TFR(fd = qemu_open("/dev/null", O_RDWR));
if (fd == -1) {
exit(1);
}
}
change_root();
change_process_uid();
if (daemonize) {
dup2(fd, 0);
dup2(fd, 1);
dup2(fd, 2);
close(fd);
}
}
| 1threat
|
xcode 8 Debugger 'Could not resolve type' : <p>In Xcode 8, When any break point is hit, and I try to print any object in the Xcode debugger, it always prints <strong>"Could not resolve type"</strong>. I have searched enough on the internet. I have checked if EditScheme->Run->Info->BuildConfiguration is set to 'Debug'. Build setting->Optimisation level is set to 'None'. But no clues on why this happens. Could anyone help me out here? Thanks in advance. </p>
<p><a href="https://i.stack.imgur.com/pdwf0.png"><img src="https://i.stack.imgur.com/pdwf0.png" alt="Xcode8 Debugger"></a></p>
| 0debug
|
Calculating operation count for Big Oh : `void G(....)
{`
`for ( int k = n/2; k > 0; k /= 2 )
{`
` for ( int m = 0; m < n; m++)`
a[(k+m)%n]=k+m; }
}
Ok guys, thanks in advance for your help. I'm unsure how to count the loop operations when the loop initiator and increment is like (n/2) and (k/=2) respectively..and so on. Running this code on a compiler for different values of n gave me interesting results, such as if n is 2^x then the iterations are n * x for values of n until 2^(x+1) -1. Now I'm stuck and don't know which Big Oh function to classify this as. Any answers/feedback/suggested learning methods/explanations welcome! Thank you!
| 0debug
|
How to create a data grid with sortable header and a scroll bar in GWT? : <p>I want to create a data grid in GWT. It should have some features like, </p>
<ul>
<li>sortable headers</li>
<li>automatic scroll bar </li>
<li>custom styling for selected row in the grid.</li>
<li>custom styling for selected cell in the grid.</li>
</ul>
| 0debug
|
javascript innerhtml to print for loop : I have just started HTML and JavaScript and got stuck here.I am trying to validate form in case of empty field and print the corresponding output using for loop .Below is the jsp page and javascript code.
<!-- begin snippet: js hide: false -->
<!-- language: lang-js -->
< script >
var err = new Array();
var i = 0,
flag = 0;
function validateForm() {
var x = document.forms["RegistrationController"]["firstname"].value;
if (x == null || x == "") {
err[i++] = "First name cannot be empty";
flag = 1;
}
var a = document.forms["RegistrationController"]["dob"].value;
if (a == null || a == "") {
err[i++] = "Date of birth cannot be empty";
flag = 1;
}
var b = document.forms["RegistrationController"]["address_line_1"].value;
if (b == null || b == "") {
err[i++] = "Address cannot be empty";
flag = 1;
}
var c = document.forms["RegistrationController"]["city"].value;
if (c == null || c == "") {
err[i++] = "city cannot be empty";
flag = 1;
}
var d = document.forms["RegistrationController"]["pincode"].value;
if (d == null || d == "") {
err[i++] = "pincode cannot be empty";
flag = 1;
}
var e = document.forms["RegistrationController"]["mobile_no"].value;
if (e == null || e == "") {
err[i++] = "mobile no cannot be empty";
flag = 1;
}
var f = document.forms["RegistrationController"]["email"].value;
if (f == null || f == "") {
err[i++] = "email cannot be empty";
flag = 1;
}
if (flag == 1) {
var string = "";
for (j = 0; j < err.length; j++) {
document.getElementById("error").innerHTML = err[i];
return false;
}
}
} < /script>
<!-- language: lang-html -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Registration</title>
</head>
<body>
<div class="error" id="error"></div>
<h1>Registration Form</h1>
<div class="ex">
<form name="RegistrationController" method="post" onsubmit="return validateForm()">
<table style="with: 50%">
<tr>
<td>First name</td>
<td>
<input type="text" name="firstname" />
</td>
</tr>
<tr>
<td>Last name</td>
<td>
<input type="text" name="lastname" />
</td>
</tr>
<tr>
<td>Date of Birth</td>
<td>
<input type="text" name="dob" />
</td>
</tr>
<tr>
<td>Address Line 1</td>
<td>
<input type="text" name="address_line_1" />
</td>
</tr>
<tr>
<td>Address Line 2</td>
<td>
<input type="text" name="address_line_2" />
</td>
</tr>
<tr>
<td>state</td>
<td>
<input type="text" name="state" />
</td>
</tr>
<tr>
<td>city</td>
<td>
<input type="text" name="city" />
</td>
</tr>
<tr>
<td>pincode</td>
<td>
<input type="text" name="pincode" />
</td>
</tr>
<tr>
<td>Mobile no</td>
<td>
<input type="text" name="mobile_no" />
</td>
</tr>
<tr>
<td>email</td>
<td>
<input type="text" name="email" />
</td>
</tr>
<tr>
<td>gender</td>
<td>
<input type="radio" name="gender" />Male</td>
<td>
<input type="radio" name="gender" />Female</td>
</tr>
</table>
<input type="submit" value="register" />
</form>
</div>
</body>
</html>
<!-- end snippet -->
| 0debug
|
SpringBoot external properties not loaded : I'm starting with SpringBoot, so am first going through the [SpringBoot reference Guide][1]
I'm currently having a look at the [Externalized Configuration][2]
My goal is to have a simple Component to read the value out of `application.properties`, which, if I'm not mistaken, should be loaded automatically, without any further configuration.
The example in the reference is as follows:
import org.springframework.stereotype.*
import org.springframework.beans.factory.annotation.*
@Component
public class MyBean {
@Value("${name}")
private String name;
// ...
}
with the following explanation:
> On your application classpath (e.g. inside your jar) you can have an
> application.properties that provides a sensible default property value
> for name. When running in a new environment, an application.properties
> can be provided outside of your jar that overrides the name; and for
> one-off testing, you can launch with a specific command line switch
> (e.g. java -jar app.jar --name="Spring").
Seems simple enough. So, I have created following Component:
@Component
public class Admin {
@Value("${name}")
private String name;
public String getName(){
return "ReadName_" + name;
}
}
And, in my `recources` folder, the following `application.properties` file (which, I verified, is copied into my .jar)
> name=myName
So, if I follow the logic in the reference (which is also mentioned in this post: [Read application.properties][3], and run my application.
The code compiles and runs without error, but each time I print the value of `getName()` from an instance of `Admin` on my screen, it just gives a "ReadName_null" instead of "ReadName_myName", the value in the properties file.
As the reference states, in 24.2:
> By default SpringApplication will convert any command line option
> arguments (starting with ‘--’, e.g. --server.port=9000) to a property
> and add it to the Spring Environment. As mentioned above, command line
> properties always take precedence over other property sources.
So, just to check, I run my .jar file with both the `application.properties` with the key present, and add `--name=passedName` as a command line argument.
Even though this value should be automatically added to the environment, and overrule anything (or in my case: nothing) that is currently there, and I expect the getName() to return "ReadName_passedName", it still returns "ReadName_null".
EDIT: I print the command line arguments I pass while booting, so I know that the argument is indeed read by the system as "--name=passedName"
Is there anything obvious I'm missing here?
[1]: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/
[2]: https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html
[3]: https://stackoverflow.com/questions/34956752/read-properties-file-in-spring-boot
| 0debug
|
can you explain me this function? : i don't understand what this function do, can you explain me in detail please?
char *my_getline(FILE *stream) {
char *line = NULL;
size_t pos = 0;
int c;
while ((c = getc(stream)) != EOF) {
char *newp = realloc(line, pos + 2);
if (newp == NULL) {
free(line);
return NULL;
}
line = newp;
if (c == '\n')
break;
line[pos++] = (char)c;
}
if (line) {
line[pos] = '\0';
}
return line;
}
if we can add a comment on my code, i think this should be perfect, i try to found a substring in a string and i found this function
this is the main
int main(void) {
char *str, *sub;
size_t len1, len2, i, count = 0;
printf("Insert string :\n");
str = my_getline(stdin);
printf("insert substring :\n");
sub = my_getline(stdin);
if (str && sub) {
len1 = strlen(str);
len2 = strlen(sub);
for (i = 0; i + len2 <= len1; i++) {
if (!memcmp(str + i, sub, len2)) {
count++;
printf("Substring found at index : %d\n", i);
}
}
printf("in the number of: %d\n", count);
if (count == 0) {
printf("Substring not found\n");
}
}
free(str);
free(sub);
return 0;
}
i understand the main but the function no, can anyone explain me?
| 0debug
|
Range copying - error #1004 : I need everyone help on the below codes:
`Set s1= workbooks(xxx.xlz).worksheets(abc)
S1.range("A1", Range("A1").end(xldown)).copy`
Why am i seeing error 1004 here?
| 0debug
|
static uint64_t ehci_opreg_read(void *ptr, hwaddr addr,
unsigned size)
{
EHCIState *s = ptr;
uint32_t val;
val = s->opreg[addr >> 2];
trace_usb_ehci_opreg_read(addr + s->opregbase, addr2str(addr), val);
return val;
}
| 1threat
|
static int parse_inputs(const char **buf, AVFilterInOut **curr_inputs,
AVFilterInOut **open_outputs, AVClass *log_ctx)
{
int pad = 0;
while (**buf == '[') {
char *name = parse_link_name(buf, log_ctx);
AVFilterInOut *match;
if (!name)
return -1;
match = extract_inout(name, open_outputs);
if (match) {
av_free(name);
} else {
match = av_mallocz(sizeof(AVFilterInOut));
match->name = name;
match->pad_idx = pad;
}
insert_inout(curr_inputs, match);
*buf += strspn(*buf, WHITESPACES);
pad++;
}
return pad;
}
| 1threat
|
bool qemu_peer_has_ufo(NetClientState *nc)
{
if (!nc->peer || !nc->peer->info->has_ufo) {
return false;
}
return nc->peer->info->has_ufo(nc->peer);
}
| 1threat
|
Run a Maven Project using IntelliJ IDEA : <p>I'm new to IntelliJ IDEA and I would like to run a simple Maven Quickstart project using it.</p>
<p>I followed all the instructions, the project was sucessfully built. But when I try to compile and run it , the <code>Run</code> button is not activated.</p>
<p>It looks like IntelliJ IDEA couldn't figure out where the main class is.</p>
<p>This is a picture of the project's hierarchy.</p>
<p><a href="https://i.stack.imgur.com/64AOZ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/64AOZ.png" alt="enter image description here"></a></p>
<p>What is the problem ? And how can I fix it ?</p>
<p>Thanks !</p>
| 0debug
|
Google vision API Bar code Scanner remove camera view : Currently I am developing a bar code reader android app with Google vision API. I need to start camera preview when button click and until the button click screen should be empty white color screen. When i Try to do this camera preview start the same time screen appear how to solve this problem please help me.
[![Screen before Start scanner][1]][1]
[![Screen After start Scanner][2]][2]
[1]: https://i.stack.imgur.com/1vQTv.png
[2]: https://i.stack.imgur.com/OkJ2k.png
| 0debug
|
vue.js - change text within a button after an event : <p>I'm playing with vue.js for learning purposes consisting of different components, one of them being a classic to do list. For now, everything is within one component.</p>
<p>I want to change the text of a button after it is clicked to hide an element from "hide" to "show" - I'm going about this by setting a text data object and then changing it in a function.</p>
<p>See below:</p>
<pre><code><div id="app">
<ul>
<li v-for="todo in todos">
{{ todo.text }}
</li>
</ul>
<input type="text" id="list-input">
<input type="submit" id="list-submit" v-on:click="addItem">
<span id="error" style="color: red; display: none;">Please Enter Text</span>
<ul>
<todoitem></todoitem>
<todoitem></todoitem>
<todoitem></todoitem>
</ul>
<h2 v-if="seen">SEEN</h2>
<button id="hide-seen" v-on:click="toggleSeen">{{ button.text }}</button>
</div>
<script type="text/javascript">
// components
Vue.component('todoitem', {
template: "<li>Test Item</li>"
})
// app code
var app = new Vue({
el: '#app',
data: {
todos: [
{ text: 'Sample Item 1' },
{ text: 'Sample Item 2' },
{ text: 'Sample Item 3' }
],
button: [
{ text: 'Hide'}
],
seen: true
},
methods: {
addItem: function() {
let item = document.getElementById("list-input").value;
let error = document.getElementById("error");
if (item == "") {
error.style.display = "block";
} else {
app.todos.push({ text: item });
error.style.display = "none";
}
},
toggleSeen: function() {
app.seen = false
app.button.push({ text: 'Show' });
}
}
})
</script>
</code></pre>
<p>Unexpectedly, the button is blank on both hide and show states. Being new to vue, this seems like a strange way to go about doing it. Is changing data in this context bad practice? I don't understand how to fix this, as I have no errors in my console. </p>
| 0debug
|
void address_space_rw(AddressSpace *as, hwaddr addr, uint8_t *buf,
int len, bool is_write)
{
AddressSpaceDispatch *d = as->dispatch;
int l;
uint8_t *ptr;
uint32_t val;
hwaddr page;
MemoryRegionSection *section;
while (len > 0) {
page = addr & TARGET_PAGE_MASK;
l = (page + TARGET_PAGE_SIZE) - addr;
if (l > len)
l = len;
section = phys_page_find(d, page >> TARGET_PAGE_BITS);
if (is_write) {
if (!memory_region_is_ram(section->mr)) {
hwaddr addr1;
addr1 = memory_region_section_addr(section, addr);
if (l >= 4 && ((addr1 & 3) == 0)) {
val = ldl_p(buf);
io_mem_write(section->mr, addr1, val, 4);
l = 4;
} else if (l >= 2 && ((addr1 & 1) == 0)) {
val = lduw_p(buf);
io_mem_write(section->mr, addr1, val, 2);
l = 2;
} else {
val = ldub_p(buf);
io_mem_write(section->mr, addr1, val, 1);
l = 1;
}
} else if (!section->readonly) {
ram_addr_t addr1;
addr1 = memory_region_get_ram_addr(section->mr)
+ memory_region_section_addr(section, addr);
ptr = qemu_get_ram_ptr(addr1);
memcpy(ptr, buf, l);
invalidate_and_set_dirty(addr1, l);
}
} else {
if (!(memory_region_is_ram(section->mr) ||
memory_region_is_romd(section->mr))) {
hwaddr addr1;
addr1 = memory_region_section_addr(section, addr);
if (l >= 4 && ((addr1 & 3) == 0)) {
val = io_mem_read(section->mr, addr1, 4);
stl_p(buf, val);
l = 4;
} else if (l >= 2 && ((addr1 & 1) == 0)) {
val = io_mem_read(section->mr, addr1, 2);
stw_p(buf, val);
l = 2;
} else {
val = io_mem_read(section->mr, addr1, 1);
stb_p(buf, val);
l = 1;
}
} else {
ptr = qemu_get_ram_ptr(section->mr->ram_addr
+ memory_region_section_addr(section,
addr));
memcpy(buf, ptr, l);
}
}
len -= l;
buf += l;
addr += l;
}
}
| 1threat
|
static void kvmppc_host_cpu_class_init(ObjectClass *oc, void *data)
{
PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
uint32_t vmx = kvmppc_get_vmx();
uint32_t dfp = kvmppc_get_dfp();
if (vmx != -1) {
alter_insns(&pcc->insns_flags, PPC_ALTIVEC, vmx > 0);
alter_insns(&pcc->insns_flags2, PPC2_VSX, vmx > 1);
}
if (dfp != -1) {
alter_insns(&pcc->insns_flags2, PPC2_DFP, dfp);
}
if (dcache_size != -1) {
pcc->l1_dcache_size = dcache_size;
}
if (icache_size != -1) {
pcc->l1_icache_size = icache_size;
}
}
| 1threat
|
How to mock window.location.href with Jest + Vuejs? : <p>Currently, I am implementing unit test for my project and there is a file that contained <code>window.location.href</code>.</p>
<p>I want to mock this to test and here is my sample code:</p>
<pre><code>it("method A should work correctly", () => {
const url = "http://dummy.com";
Object.defineProperty(window.location, "href", {
value: url,
writable: true
});
const data = {
id: "123",
name: null
};
window.location.href = url;
wrapper.vm.methodA(data);
expect(window.location.href).toEqual(url);
});
</code></pre>
<p>But I get this error:</p>
<pre><code>TypeError: Cannot redefine property: href
at Function.defineProperty (<anonymous>)
</code></pre>
<p>I had tried some solutions but not resolve it. I need some hints to help me get out of this trouble. Plz help.</p>
| 0debug
|
static void padzero(unsigned long elf_bss)
{
unsigned long nbyte;
char * fpnt;
nbyte = elf_bss & (host_page_size-1);
if (nbyte) {
nbyte = host_page_size - nbyte;
fpnt = (char *) elf_bss;
do {
*fpnt++ = 0;
} while (--nbyte);
}
}
| 1threat
|
Sql server error Code : Declare @ParmDefinition Nvarchar(1000),@St Nvarchar(500),@TTable varchar(30)
Set @TTable='[0Detail]'
Declare @TTempStore Table (
Iden Int,
Row_ Int,
Accs_iden int,
Am_Bed Money,
Am_Bes Money,
Doc_No Decimal(15,0),
Desc_ Nvarchar(500),
Checked bit,
Error_ int)
SET @ParmDefinition = N'@alaki table(Iden Int,
Row_ Int,
Accs_iden int,
Am_Bed Money,
Am_Bes Money,
Doc_No Decimal(15,0),
Desc_ Nvarchar(500),Checked bit,Error_ int) OUTPUT '
Set @St=N' Select * into @alaki from '+@TTable
EXECUTE sp_executesql @St,@ParmDefinition,@alaki=@TTempStore
Select * from @TTempStore
Error Code
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'table'.
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '@alaki'.
| 0debug
|
How to transfer selected text from input textbox to textarea box? : I have no idea how to transfer text from each input textbox to text area line by line in JavaScript. Please help me! I'm beginner to programming and this is my first question :) [form design click here][1]
[1]: http://i.stack.imgur.com/oKv5p.png
| 0debug
|
AWS Java SDK 2.0 create a presigned URL for a S3 object : <p>I know with version 1.x of the SDK it's as simple as per the <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/ShareObjectPreSignedURLJavaSDK.html" rel="noreferrer">docs</a></p>
<pre><code>java.util.Date expiration = new java.util.Date();
long msec = expiration.getTime();
msec += 1000 * 60 * 60; // Add 1 hour.
expiration.setTime(msec);
GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest(bucketName, objectKey);
generatePresignedUrlRequest.setMethod(HttpMethod.PUT);
generatePresignedUrlRequest.setExpiration(expiration);
URL s = s3client.generatePresignedUrl(generatePresignedUrlRequest);
</code></pre>
<p>However looking at the <a href="http://aws-java-sdk-javadoc.s3-website-us-west-2.amazonaws.com/latest/" rel="noreferrer">2.0 docs</a> but I can't find anything close to the <code>GeneratePresignedUrlRequest</code>. </p>
<p>Hopefully there is another simple pattern for this?</p>
| 0debug
|
Display popup when user visits the pages on the site for the first time : <p>I want to display pop-us on few pages when the user visits them for the first time. I don't want the values to be stored in the cookies or local storage as the count of the pages is may vary.</p>
| 0debug
|
static ExitStatus trans_fop_weww_0c(DisasContext *ctx, uint32_t insn,
const DisasInsn *di)
{
unsigned rt = extract32(insn, 0, 5);
unsigned rb = extract32(insn, 16, 5);
unsigned ra = extract32(insn, 21, 5);
return do_fop_weww(ctx, rt, ra, rb, di->f_weww);
}
| 1threat
|
How to browse the document file in iOS : <p>Am building an iOS app that requires user uploading pdf files. I want to create a button that after the user clicks it, it opens the file directory to search for the specific file to upload to the server.
I will appreciate if anyone can tell me how to do it using swift.
Thank you</p>
| 0debug
|
Does Java Garbage Collect always has to "Stop-the-World"? : <p>I am trying to understand Java's garbage collection more deeply.</p>
<p>In HotSpot JVM generational collection, in the heap, there are three areas (Young generation, Old generation and permanent generation). Also, there are two kinds of algorithms:</p>
<p>1) <strong>Mark Sweep Compact</strong>.</p>
<p>2) <strong>Concurrent Mark and Sweep</strong>.</p>
<p>Is that true whether GC needs "Stop-the-world" depends on the algorithm it uses rather than which generation it operates on? In another word, if I use 1) as GC algorithm on all three areas, STW will always happen ?</p>
<p>Also, I understand the difference is the second GC algorithm doesn't require Compaction which will result in fragmentation eventually. So the second question comes to why the compaction needs a STW pause?</p>
| 0debug
|
How to install TypeScript 2.2 onto Visual Studio 2017 : <p>Some people in our team have both Visual Studio 2015 and Visual Studio 2017 installed. Others only have the latest Visual Studio 2017 (15.5). With the latter, we noticed that our TypeScript project in the IDE is generating all kinds of unexpected errors due to all kinds of lib.es2015.d.ts issues.</p>
<p>Our projects use TypeScript 2.2, whereas the latest Visual Studio 2017 (15.5) comes with TypeScript 2.5.</p>
<p>We discovered that the Visual Studio TypeScript SDK is installed in the following path:</p>
<ul>
<li><code>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2</code></li>
<li><code>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.5</code></li>
</ul>
<p>We noticed that 15.5 comes with a new property in the csproj property screen which allows direct mutation of the wanted TypeScript version. As the project requires 2.2 which is not installed, the dropdown states the missing 2.2 bits.</p>
<p>What we have tried to fix this:</p>
<ol>
<li>Installed the TypeScript 2.2 SDK for Visual Studio 2015 (for 2017 there is no separate install). Unfortunately it looks like this package does not come with the language service <code>tsserver.js</code>. Did not work. Url: <a href="http://download.microsoft.com/download/6/D/8/6D8381B0-03C1-4BD2-AE65-30FF0A4C62DA/TS-2.2-dev14update3-20170221.2/TypeScript_Dev14Full.exe" rel="noreferrer">http://download.microsoft.com/download/6/D/8/6D8381B0-03C1-4BD2-AE65-30FF0A4C62DA/TS-2.2-dev14update3-20170221.2/TypeScript_Dev14Full.exe</a></li>
<li>Played with the NuGet-package <code>Microsoft.TypeScript.Compiler</code> and installed 2.2.1 (no 2.2.2 available?). This didn't seem to solve anything. Not clear to us how this package really integrates into something. Even after adding the specific property <code>TypeScriptNuGetToolsVersion</code>. </li>
<li>Played with the NuGet-package <code>Microsoft.TypeScript.MSBuild</code> and installed version 2.2.2. Unfortunately, this only influences the MSBuild process and not the editor experience. MSBuild is not relevant to us as we are using the Angular CLI for really building / watching the TypeScript source code.</li>
<li>Copied over the 2.2 bits of one of our Visual Studio 2015 installations. This enabled the 2.2 menu option in the csproj property screen. But, we still experience clashes with lib.es2015.d.ts. What we discovered is that the SDK seems to always use the latest version, in our case 2.5. We also installed 2.6, and then it started to use 2.6.</li>
<li>Ultimately we just removed the 2.6 folder completely and created a copy of the 2.2 folder with the name 2.6. And now it works. But this really feels like a hack!</li>
</ol>
<p>To summarize our questions:</p>
<ul>
<li>What is the best way to install TypeScript SDK 2.2 onto Visual Studio 2017 (15.5)?</li>
<li>What is the best way to really enforce the usage of lib.es2015.d.ts from version 2.2?</li>
</ul>
| 0debug
|
Can create-react-app be used with TypeScript : <p>Is it possible to use TypeScript with create-react-app? If so, how would you do it?</p>
| 0debug
|
How to get the list with the highest last value in a list of lists : <p>I'm trying to get the list which has the highest value in a list of lists. I have something like this:</p>
<pre><code>Lists = [[0,7,6,8],[1,4,6,5], [12,1,8,3]]
</code></pre>
<p>And I want to retrieve the list that has the highest last value, first list in this case. How should I go about this?</p>
| 0debug
|
Need to parse xml file and print element with checking an empty tag : <p>I need to write a perl script to parse through a XML file. If SpecialData tag has value, then I need to print the Name. I could write this
for the following file.</p>
<p>For the following xml file, output should be Name-abc</p>
<pre><code><Data>
<Name>abc</Name>
<SpecialData>Properties</SpecialData>
</Data>
<Data>
<Name>mnp</Name>
</Data>
</code></pre>
<p>But in a xml file as mentioned below, SpecialData tag has an empty tag Properties. I need to write a perl script that will print the name, if SpecialData tag is there. Here the difference is Properties is an inner tag, not a value as the 1st problem. Can anyone help me to write a perl script to do this?</p>
<p>For the following xml file, output should be Name- abc</p>
<pre><code><Data>
<Name>abc</Name>
<SpecialData>
<Properties />
</SpecialData>
</Data>
<Data>
<Name>mnp</Name>
</Data>
</code></pre>
| 0debug
|
query = 'SELECT * FROM customers WHERE email = ' + email_input
| 1threat
|
Function to normalize any number from 0 - 1 : <p>I'm trying to make a function that takes a number and normalizes it from 0 - 1 between its min and max bounds. For example: </p>
<p>If I want to normalize a value of 10 between 5 to 15, I call this:</p>
<p><code>val = 10; normalize(val, 5, 15);</code> Returns 0.5</p>
<p>normalizing a value 0 between -10 and 5</p>
<p><code>val = 0; normalize(val, -10, 5);</code> Returns 0.666</p>
<p>This is the function I came up with:</p>
<pre><code>function normalize(val, min, max){
// Shift to positive to avoid issues when crossing the 0 line
if(min < 0){
max += 0 - min;
val += 0 - min;
min = 0;
}
// Shift values from 0 - max
val = val - min;
max = max - min;
return Math.max(0, Math.min(1, val / max));
}
</code></pre>
<p>My question is: Is this the most efficient method to normalize a 1-dimensional value? I'm going to be calling this function a few thousand times per frame at 60fps, so I'd like to have it as optimized as possible to reduce the burden of calculation. I've looked for normalization formulas, but all I find are 2- or 3-dimensional solutions.</p>
| 0debug
|
static uint16_t nvme_rw(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd,
NvmeRequest *req)
{
NvmeRwCmd *rw = (NvmeRwCmd *)cmd;
uint32_t nlb = le32_to_cpu(rw->nlb) + 1;
uint64_t slba = le64_to_cpu(rw->slba);
uint64_t prp1 = le64_to_cpu(rw->prp1);
uint64_t prp2 = le64_to_cpu(rw->prp2);
uint8_t lba_index = NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas);
uint8_t data_shift = ns->id_ns.lbaf[lba_index].ds;
uint64_t data_size = nlb << data_shift;
uint64_t aio_slba = slba << (data_shift - BDRV_SECTOR_BITS);
int is_write = rw->opcode == NVME_CMD_WRITE ? 1 : 0;
if ((slba + nlb) > ns->id_ns.nsze) {
return NVME_LBA_RANGE | NVME_DNR;
}
if (nvme_map_prp(&req->qsg, prp1, prp2, data_size, n)) {
return NVME_INVALID_FIELD | NVME_DNR;
}
assert((nlb << data_shift) == req->qsg.size);
dma_acct_start(n->conf.bs, &req->acct, &req->qsg, is_write ?
BLOCK_ACCT_WRITE : BLOCK_ACCT_READ);
req->aiocb = is_write ?
dma_bdrv_write(n->conf.bs, &req->qsg, aio_slba, nvme_rw_cb, req) :
dma_bdrv_read(n->conf.bs, &req->qsg, aio_slba, nvme_rw_cb, req);
return NVME_NO_COMPLETE;
}
| 1threat
|
Convert tab file data to csv or excel format using java : <p>How to extract data from a tab file which has text data in form of rows and column and export it to csv or excel file format? Which language will be best to achieve this?</p>
| 0debug
|
How to modify the Verilog code? : module make_counter(h, clk, P);
input wire h;
input wire clk;
output wire P;
reg r=1'b1;
reg[9:0] n=0;
always @(negedge clk)
always @(posedge h)
begin
n=0;
end
begin
if(n<600)
n=n+1'b1;
if(n==106)
r<=1'b0;
else if(n==517)
r<=1'b1;
else
;
end
assign P=r;
endmodule
Error (10170): Verilog HDL syntax error at main.v(115) near text "always"; expecting ";"
Error (10170): Verilog HDL syntax error at main.v(119) near text "begin"; expecting "endmodule"
| 0debug
|
Using ReactCSSTransitionGroup with styled-component : <p>I'm using <a href="https://github.com/styled-components/styled-components" rel="noreferrer">styled-components</a> instead of tradition way of css. But I don't know how it can work together with <a href="https://facebook.github.io/react/docs/animation.html" rel="noreferrer">ReactCSSTransitionGroup</a>.</p>
<p>Basically, <code>ReactCSSTransitionGroup</code> looks for certain classnames in css resource, then apply to a component throughout its lifecycle. However, with <code>styled-components</code>, there are not any class names, styles are applied to components directly.</p>
<p>I know I can choose not to use <code>ReactCSSTransitionGroup</code> because the two technique doesn't look compatible. But when I use only <code>styled-components</code>, seems I can't render any animation when a component is unmounted - it's pure css, can't access component's lifecycle.</p>
<p>Any help or recommendation is appreciated.</p>
| 0debug
|
Date function in excel? : <p>I have an excel file that a column with a date. the date is structured like this:20160711. I want the date to look like this: 07/11/2016 any easy way to do this?</p>
| 0debug
|
static unsigned __stdcall win32_start_routine(void *arg)
{
struct QemuThreadData data = *(struct QemuThreadData *) arg;
QemuThread *thread = data.thread;
free(arg);
TlsSetValue(qemu_thread_tls_index, thread);
DuplicateHandle(GetCurrentProcess(), GetCurrentThread(),
GetCurrentProcess(), &thread->thread,
0, FALSE, DUPLICATE_SAME_ACCESS);
qemu_thread_exit(data.start_routine(data.arg));
abort();
}
| 1threat
|
static inline void t_gen_mov_preg_TN(DisasContext *dc, int r, TCGv tn)
{
if (r < 0 || r > 15)
fprintf(stderr, "wrong register write $p%d\n", r);
if (r == PR_BZ || r == PR_WZ || r == PR_DZ)
return;
else if (r == PR_SRS)
tcg_gen_andi_tl(cpu_PR[r], tn, 3);
else {
if (r == PR_PID)
tcg_gen_helper_0_1(helper_tlb_flush_pid, tn);
if (dc->tb_flags & S_FLAG && r == PR_SPC)
tcg_gen_helper_0_1(helper_spc_write, tn);
else if (r == PR_CCS)
dc->cpustate_changed = 1;
tcg_gen_mov_tl(cpu_PR[r], tn);
}
}
| 1threat
|
Create JSON data in specific format in android : <p>i know there are many useful threads which teaches us how to make JSON data in a specific format. I have been looking into some useful threads but i am unable to achieve a specific format that i want. Can someone help me to achieve this format?</p>
<pre><code>{"properties" : [
{"marker": {"point":new GLatLng(40.266044,-74.718479) },
{lastvisit: "Timestamp":"2016-10-31 13:55"}
]}
</code></pre>
<p>I need to make data in this format and after then i will send it to the server as a POST request.</p>
| 0debug
|
Java 8 stream vs List : <p>I have a set of private methods that are used in a main public method (that receive a list) of a class, these methods will mainly use java 8 classic stream operations as <code>filter</code>, <code>map</code>, <code>count</code> e.t.c. I am wondering if creating stream single time in public api and passing to others method instead of passing list have any performance benefits or considerations as <code>.stream()</code> is called single time. </p>
| 0debug
|
Angular app with firebase auth and node.js / mongodb : <p>I am just planning architecture for my web app and I just wanted to ask you, if it is good idea to use Firebase auth with Angular and mongoDB as a database. (I don't want to use Firestore realtime database)</p>
<p>Is a good idea to use queries directly from my Angular client or do I need some node.js/express backend for this? What would be the best solution?</p>
<p>Thanks for your advices.</p>
| 0debug
|
static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
{
struct video_data *s = s1->priv_data;
AVStream *st;
int width, height;
int res, frame_rate, frame_rate_base;
uint32_t desired_format, capabilities;
if (ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0) {
av_log(s1, AV_LOG_ERROR, "Missing/Wrong width, height or framerate\n");
return -1;
}
width = ap->width;
height = ap->height;
frame_rate = ap->time_base.den;
frame_rate_base = ap->time_base.num;
if((unsigned)width > 32767 || (unsigned)height > 32767) {
av_log(s1, AV_LOG_ERROR, "Wrong size %dx%d\n", width, height);
return -1;
}
st = av_new_stream(s1, 0);
if (!st) {
return AVERROR(ENOMEM);
}
av_set_pts_info(st, 64, 1, 1000000);
s->width = width;
s->height = height;
s->frame_rate = frame_rate;
s->frame_rate_base = frame_rate_base;
capabilities = 0;
s->fd = device_open(s1, &capabilities);
if (s->fd < 0) {
av_free(st);
return AVERROR(EIO);
}
av_log(s1, AV_LOG_INFO, "[%d]Capabilities: %x\n", s->fd, capabilities);
desired_format = fmt_ff2v4l(ap->pix_fmt);
if (desired_format == 0 || (device_init(s1, &width, &height, desired_format) < 0)) {
int i, done;
done = 0; i = 0;
while (!done) {
desired_format = fmt_conversion_table[i].v4l2_fmt;
if (device_init(s1, &width, &height, desired_format) < 0) {
desired_format = 0;
i++;
} else {
done = 1;
}
if (i == sizeof(fmt_conversion_table) / sizeof(struct fmt_map)) {
done = 1;
}
}
}
if (desired_format == 0) {
av_log(s1, AV_LOG_ERROR, "Cannot find a proper format.\n");
close(s->fd);
av_free(st);
return AVERROR(EIO);
}
s->frame_format = desired_format;
if( v4l2_set_parameters( s1, ap ) < 0 )
return AVERROR(EIO);
st->codec->pix_fmt = fmt_v4l2ff(desired_format);
s->frame_size = avpicture_get_size(st->codec->pix_fmt, width, height);
if (capabilities & V4L2_CAP_STREAMING) {
s->io_method = io_mmap;
res = mmap_init(s1);
if (res == 0) {
res = mmap_start(s1);
}
} else {
s->io_method = io_read;
res = read_init(s1);
}
if (res < 0) {
close(s->fd);
av_free(st);
return AVERROR(EIO);
}
s->top_field_first = first_field(s->fd);
st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_RAWVIDEO;
st->codec->width = width;
st->codec->height = height;
st->codec->time_base.den = frame_rate;
st->codec->time_base.num = frame_rate_base;
st->codec->bit_rate = s->frame_size * 1/av_q2d(st->codec->time_base) * 8;
return 0;
}
| 1threat
|
How insert edge on graph without source and target? JS : <p>I want to add solely the line on the graph.How insert edge on graph without source and target?Or tell me how using JS, add a line to the graph</p>
| 0debug
|
Robust endless loop for server written in Python : <p>I write a server which handles events and uncaught exceptions during handling the event must not terminate the server.</p>
<p>The server is a single non-threaded python process.</p>
<p>I want to terminate on these errors types:</p>
<ul>
<li>KeyboardInterrupt</li>
<li>MemoryError</li>
<li>...</li>
</ul>
<p>The list of built in exceptions is long: <a href="https://docs.python.org/2/library/exceptions.html" rel="noreferrer">https://docs.python.org/2/library/exceptions.html</a></p>
<p>I don't want to re-invent this exception handling, since I guess it was done several times before.</p>
<p>How to proceed? </p>
<ol>
<li>Have a white-list: A list of exceptions which are ok and processing the next event is the right choice</li>
<li>Have a black-list: A list of exceptions which indicate that terminating the server is the right choice.</li>
</ol>
<p>Hint: This question is not about running a unix daemon in background. It is not about double fork and not about redirecting stdin/stdout :-)</p>
| 0debug
|
static void adx_encode(unsigned char *adx,const short *wav,PREV *prev)
{
int scale;
int i;
int s0,s1,s2,d;
int max=0;
int min=0;
int data[32];
s1 = prev->s1;
s2 = prev->s2;
for(i=0;i<32;i++) {
s0 = wav[i];
d = ((s0<<14) - SCALE1*s1 + SCALE2*s2)/BASEVOL;
data[i]=d;
if (max<d) max=d;
if (min>d) min=d;
s2 = s1;
s1 = s0;
}
prev->s1 = s1;
prev->s2 = s2;
if (max==0 && min==0) {
memset(adx,0,18);
return;
}
if (max/7>-min/8) scale = max/7;
else scale = -min/8;
if (scale==0) scale=1;
adx[0] = scale>>8;
adx[1] = scale;
for(i=0;i<16;i++) {
adx[i+2] = ((data[i*2]/scale)<<4) | ((data[i*2+1]/scale)&0xf);
}
}
| 1threat
|
Apollo is not assignable to parameter of type 'VueClass<Vue> : <p>I'm building nuxt.js app with typescript. This is my code:</p>
<pre><code><script lang='ts'>
import {Component, Vue} from 'nuxt-property-decorator';
import {LOCATION} from '~/constants/graphql/location';
@Component({
apollo: {
getLocation: {
query: LOCATION,
variables(): object {
return {
id: 10,
};
},
prefetch: true,
},
},
})
export default class Home extends Vue {
}
</script>
</code></pre>
<p>I have error:</p>
<pre><code>Argument of type '{ apollo: { getLocation: { query: any; variables(): object; prefetch: boolean; }; }; }' is not assignable to parameter of type 'VueClass<Vue>'.
</code></pre>
<p>Object literal may only specify known properties, and 'apollo' does not exist in type 'VueClass'.</p>
<p>I know it's come from TS but how to fix it?</p>
| 0debug
|
How to add country flag in the html input tag? : <p>I want to add country flag in html input tag and yeah bootstrap helper can do it. But i do not know how to add the links and scripts exactly that would solve my issue. So any help ?</p>
| 0debug
|
void qdev_free(DeviceState *dev)
{
#if 0
if (dev->info->vmsd)
vmstate_unregister(dev->info->vmsd, dev);
#endif
if (dev->info->reset)
qemu_unregister_reset(dev->info->reset, dev);
LIST_REMOVE(dev, sibling);
qemu_free(dev);
}
| 1threat
|
Read external JSON with Swift : <p>How would I read JSON from a website, example: <code>https://example.com/checkifexists.php?name=test</code>, which would return something like this: <code>[{"exists":"true"}]</code> or <code>[{"exists":"false"}]</code>. I want to check if that exists and get the value true or false using swift.
Thanks :)</p>
| 0debug
|
How to make sure a React state using useState() hook has been updated? : <p>I had a class component named <code><BasicForm></code> that I used to build forms with. It handles validation and all the form <code>state</code>. It provides all the necessary functions (<code>onChange</code>, <code>onSubmit</code>, etc) to the inputs (rendered as <code>children</code> of <code>BasicForm</code>) via React context.</p>
<p>It works just as intended. The problem is that now that I'm converting it to use React Hooks, I'm having doubts when trying to replicate the following behavior that I did when it was a class:</p>
<pre><code>class BasicForm extends React.Component {
...other code...
touchAllInputsValidateAndSubmit() {
// CREATE DEEP COPY OF THE STATE'S INPUTS OBJECT
let inputs = {};
for (let inputName in this.state.inputs) {
inputs = Object.assign(inputs, {[inputName]:{...this.state.inputs[inputName]}});
}
// TOUCH ALL INPUTS
for (let inputName in inputs) {
inputs[inputName].touched = true;
}
// UPDATE STATE AND CALL VALIDATION
this.setState({
inputs
}, () => this.validateAllFields()); // <---- SECOND CALLBACK ARGUMENT
}
... more code ...
}
</code></pre>
<p>When the user clicks the submit button, <code>BasicForm</code> should 'touch' all inputs and only then call <code>validateAllFields()</code>, because validation errors will only show if an input has been touched. So if the user hasn't touched any, <code>BasicForm</code> needs to make sure to 'touch' every input before calling the <code>validateAllFields()</code> function.</p>
<p>And when I was using classes, the way I did this, was by using the second callback argument on the <code>setState()</code> function as you can see from the code above. And that made sure that <code>validateAllField()</code> only got called after the state update (the one that touches all fields).</p>
<p>But when I try to use that second callback parameter with state hooks <code>useState()</code>, I get this error:</p>
<pre><code>const [inputs, setInputs] = useState({});
... some other code ...
setInputs(auxInputs, () => console.log('Inputs updated!'));
</code></pre>
<blockquote>
<p>Warning: State updates from the useState() and useReducer() Hooks
don't support the second callback argument. To execute a side effect
after rendering, declare it in the component body with useEffect().</p>
</blockquote>
<p>So, according to the error message above, I'm trying to do this with the <code>useEffect()</code> hook. But this makes me a little bit confused, because as far as I know, <code>useEffect()</code> is not based on state updates, but in render execution. It executes after every render. And I know React can queue some state updates before re-rendering, so I feel like I don't have full control of exactly when my <code>useEffect()</code> hook will be executed as I did have when I was using classes and the <code>setState()</code> second callback argument.</p>
<p>What I got so far is (it seems to be working):</p>
<pre><code>function BasicForm(props) {
const [inputs, setInputs] = useState({});
const [submitted, setSubmitted] = useState(false);
... other code ...
function touchAllInputsValidateAndSubmit() {
const shouldSubmit = true;
// CREATE DEEP COPY OF THE STATE'S INPUTS OBJECT
let auxInputs = {};
for (let inputName in inputs) {
auxInputs = Object.assign(auxInputs, {[inputName]:{...inputs[inputName]}});
}
// TOUCH ALL INPUTS
for (let inputName in auxInputs) {
auxInputs[inputName].touched = true;
}
// UPDATE STATE
setInputs(auxInputs);
setSubmitted(true);
}
// EFFECT HOOK TO CALL VALIDATE ALL WHEN SUBMITTED = 'TRUE'
useEffect(() => {
if (submitted) {
validateAllFields();
}
setSubmitted(false);
});
... some more code ...
}
</code></pre>
<p>I'm using the <code>useEffect()</code> hook to call the <code>validateAllFields()</code> function. And since <code>useEffect()</code> is executed on <strong>every render</strong> I needed a way to know when to call <code>validateAllFields()</code> since I don't want it on every render. Thus, I created the <code>submitted</code> state variable so I can know when I need that effect.</p>
<p>Is this a good solution? What other possible solutions you might think of? It just feels really weird.</p>
<p>Imagine that <code>validateAllFields()</code> is a function that CANNOT be called twice under no circunstances. How do I know that on the next render my <code>submitted</code> state will be already 'false' 100% sure?</p>
<p>Can I rely on React performing every queued state update before the next render? Is this guaranteed?</p>
| 0debug
|
vb .net Picturebox will not display image :
I'm writing a program that will create and load pictureboxs at run time. The problem is that they will not show up or display anything. Not sure what i'm doing wrong. i have checked and the full path for the images are correct.
Sub DrawScreen()
'Call g.DrawImage to draw whatever you want in here
Dim layers(Me.ListBox1.Items.Count) As PictureBox
For i = 0 To ListBox1.Items.Count - 1
'Create New Layer as picturebox
layers(i) = New PictureBox
layers(i).Parent = Me.picWatch
layers(i).BackColor = Color.Transparent
layers(i).Visible = True
Select Case ListBox1.Items(i)
Case "image"
'Debug.Print(ListofLayers(i).Full_Path)
layers(i).Image = Image.FromFile(ListofLayers(i).Full_Path)
layers(i).Top = ListofLayers(i).X
picWatch.Controls.Add(layers(i))
Case "shape"
'Dim g As Graphics
'g.DrawRectangle()
Case "text"
Dim g As Graphics = layers(i).CreateGraphics
g.DrawString(ListofLayers(i).Text, New Font("Arial", 12), Brushes.White, ListofLayers(i).X, ListofLayers(i).Y)
Case Else
Debug.Print(ListBox1.Items(i))
End Select
Next
Me.Refresh()
End Sub
| 0debug
|
static void gen_dmtc0(DisasContext *ctx, TCGv arg, int reg, int sel)
{
const char *rn = "invalid";
if (sel != 0)
check_insn(ctx, ISA_MIPS64);
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
}
switch (reg) {
case 0:
switch (sel) {
case 0:
gen_helper_mtc0_index(cpu_env, arg);
rn = "Index";
case 1:
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_mvpcontrol(cpu_env, arg);
rn = "MVPControl";
CP0_CHECK(ctx->insn_flags & ASE_MT);
rn = "MVPConf0";
CP0_CHECK(ctx->insn_flags & ASE_MT);
rn = "MVPConf1";
CP0_CHECK(ctx->vp);
rn = "VPControl";
default:
goto cp0_unimplemented;
}
case 1:
switch (sel) {
case 0:
rn = "Random";
case 1:
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_vpecontrol(cpu_env, arg);
rn = "VPEControl";
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_vpeconf0(cpu_env, arg);
rn = "VPEConf0";
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_vpeconf1(cpu_env, arg);
rn = "VPEConf1";
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_yqmask(cpu_env, arg);
rn = "YQMask";
case 5:
CP0_CHECK(ctx->insn_flags & ASE_MT);
tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_VPESchedule));
rn = "VPESchedule";
case 6:
CP0_CHECK(ctx->insn_flags & ASE_MT);
tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_VPEScheFBack));
rn = "VPEScheFBack";
case 7:
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_vpeopt(cpu_env, arg);
rn = "VPEOpt";
default:
goto cp0_unimplemented;
}
switch (sel) {
case 0:
gen_helper_dmtc0_entrylo0(cpu_env, arg);
rn = "EntryLo0";
case 1:
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_tcstatus(cpu_env, arg);
rn = "TCStatus";
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_tcbind(cpu_env, arg);
rn = "TCBind";
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_tcrestart(cpu_env, arg);
rn = "TCRestart";
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_tchalt(cpu_env, arg);
rn = "TCHalt";
case 5:
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_tccontext(cpu_env, arg);
rn = "TCContext";
case 6:
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_tcschedule(cpu_env, arg);
rn = "TCSchedule";
case 7:
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_tcschefback(cpu_env, arg);
rn = "TCScheFBack";
default:
goto cp0_unimplemented;
}
switch (sel) {
case 0:
gen_helper_dmtc0_entrylo1(cpu_env, arg);
rn = "EntryLo1";
case 1:
CP0_CHECK(ctx->vp);
rn = "GlobalNumber";
default:
goto cp0_unimplemented;
}
switch (sel) {
case 0:
gen_helper_mtc0_context(cpu_env, arg);
rn = "Context";
case 1:
rn = "ContextConfig";
goto cp0_unimplemented;
CP0_CHECK(ctx->ulri);
tcg_gen_st_tl(arg, cpu_env,
offsetof(CPUMIPSState, active_tc.CP0_UserLocal));
rn = "UserLocal";
default:
goto cp0_unimplemented;
}
case 5:
switch (sel) {
case 0:
gen_helper_mtc0_pagemask(cpu_env, arg);
rn = "PageMask";
case 1:
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_pagegrain(cpu_env, arg);
rn = "PageGrain";
default:
goto cp0_unimplemented;
}
case 6:
switch (sel) {
case 0:
gen_helper_mtc0_wired(cpu_env, arg);
rn = "Wired";
case 1:
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_srsconf0(cpu_env, arg);
rn = "SRSConf0";
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_srsconf1(cpu_env, arg);
rn = "SRSConf1";
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_srsconf2(cpu_env, arg);
rn = "SRSConf2";
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_srsconf3(cpu_env, arg);
rn = "SRSConf3";
case 5:
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_srsconf4(cpu_env, arg);
rn = "SRSConf4";
default:
goto cp0_unimplemented;
}
case 7:
switch (sel) {
case 0:
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_hwrena(cpu_env, arg);
ctx->bstate = BS_STOP;
rn = "HWREna";
default:
goto cp0_unimplemented;
}
case 8:
switch (sel) {
case 0:
rn = "BadVAddr";
case 1:
rn = "BadInstr";
rn = "BadInstrP";
default:
goto cp0_unimplemented;
}
case 9:
switch (sel) {
case 0:
gen_helper_mtc0_count(cpu_env, arg);
rn = "Count";
default:
goto cp0_unimplemented;
}
ctx->bstate = BS_STOP;
case 10:
switch (sel) {
case 0:
gen_helper_mtc0_entryhi(cpu_env, arg);
rn = "EntryHi";
default:
goto cp0_unimplemented;
}
case 11:
switch (sel) {
case 0:
gen_helper_mtc0_compare(cpu_env, arg);
rn = "Compare";
default:
goto cp0_unimplemented;
}
ctx->bstate = BS_STOP;
case 12:
switch (sel) {
case 0:
save_cpu_state(ctx, 1);
gen_helper_mtc0_status(cpu_env, arg);
gen_save_pc(ctx->pc + 4);
ctx->bstate = BS_EXCP;
rn = "Status";
case 1:
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_intctl(cpu_env, arg);
ctx->bstate = BS_STOP;
rn = "IntCtl";
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_srsctl(cpu_env, arg);
ctx->bstate = BS_STOP;
rn = "SRSCtl";
check_insn(ctx, ISA_MIPS32R2);
gen_mtc0_store32(arg, offsetof(CPUMIPSState, CP0_SRSMap));
ctx->bstate = BS_STOP;
rn = "SRSMap";
default:
goto cp0_unimplemented;
}
case 13:
switch (sel) {
case 0:
save_cpu_state(ctx, 1);
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_mtc0_cause(cpu_env, arg);
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_end();
}
ctx->bstate = BS_STOP;
rn = "Cause";
default:
goto cp0_unimplemented;
}
case 14:
switch (sel) {
case 0:
tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_EPC));
rn = "EPC";
default:
goto cp0_unimplemented;
}
case 15:
switch (sel) {
case 0:
rn = "PRid";
case 1:
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_ebase(cpu_env, arg);
rn = "EBase";
default:
goto cp0_unimplemented;
}
case 16:
switch (sel) {
case 0:
gen_helper_mtc0_config0(cpu_env, arg);
rn = "Config";
ctx->bstate = BS_STOP;
case 1:
rn = "Config1";
gen_helper_mtc0_config2(cpu_env, arg);
rn = "Config2";
ctx->bstate = BS_STOP;
gen_helper_mtc0_config3(cpu_env, arg);
rn = "Config3";
ctx->bstate = BS_STOP;
rn = "Config4";
case 5:
gen_helper_mtc0_config5(cpu_env, arg);
rn = "Config5";
ctx->bstate = BS_STOP;
default:
rn = "Invalid config selector";
goto cp0_unimplemented;
}
case 17:
switch (sel) {
case 0:
gen_helper_mtc0_lladdr(cpu_env, arg);
rn = "LLAddr";
case 1:
CP0_CHECK(ctx->mrp);
gen_helper_mtc0_maar(cpu_env, arg);
rn = "MAAR";
CP0_CHECK(ctx->mrp);
gen_helper_mtc0_maari(cpu_env, arg);
rn = "MAARI";
default:
goto cp0_unimplemented;
}
case 18:
switch (sel) {
case 0 ... 7:
gen_helper_0e1i(mtc0_watchlo, arg, sel);
rn = "WatchLo";
default:
goto cp0_unimplemented;
}
case 19:
switch (sel) {
case 0 ... 7:
gen_helper_0e1i(mtc0_watchhi, arg, sel);
rn = "WatchHi";
default:
goto cp0_unimplemented;
}
case 20:
switch (sel) {
case 0:
check_insn(ctx, ISA_MIPS3);
gen_helper_mtc0_xcontext(cpu_env, arg);
rn = "XContext";
default:
goto cp0_unimplemented;
}
case 21:
CP0_CHECK(!(ctx->insn_flags & ISA_MIPS32R6));
switch (sel) {
case 0:
gen_helper_mtc0_framemask(cpu_env, arg);
rn = "Framemask";
default:
goto cp0_unimplemented;
}
case 22:
rn = "Diagnostic";
case 23:
switch (sel) {
case 0:
gen_helper_mtc0_debug(cpu_env, arg);
gen_save_pc(ctx->pc + 4);
ctx->bstate = BS_EXCP;
rn = "Debug";
case 1:
ctx->bstate = BS_STOP;
rn = "TraceControl";
goto cp0_unimplemented;
ctx->bstate = BS_STOP;
rn = "TraceControl2";
goto cp0_unimplemented;
ctx->bstate = BS_STOP;
rn = "UserTraceData";
goto cp0_unimplemented;
ctx->bstate = BS_STOP;
rn = "TraceBPC";
goto cp0_unimplemented;
default:
goto cp0_unimplemented;
}
case 24:
switch (sel) {
case 0:
tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_DEPC));
rn = "DEPC";
default:
goto cp0_unimplemented;
}
case 25:
switch (sel) {
case 0:
gen_helper_mtc0_performance0(cpu_env, arg);
rn = "Performance0";
case 1:
rn = "Performance1";
goto cp0_unimplemented;
rn = "Performance2";
goto cp0_unimplemented;
rn = "Performance3";
goto cp0_unimplemented;
rn = "Performance4";
goto cp0_unimplemented;
case 5:
rn = "Performance5";
goto cp0_unimplemented;
case 6:
rn = "Performance6";
goto cp0_unimplemented;
case 7:
rn = "Performance7";
goto cp0_unimplemented;
default:
goto cp0_unimplemented;
}
case 26:
switch (sel) {
case 0:
gen_helper_mtc0_errctl(cpu_env, arg);
ctx->bstate = BS_STOP;
rn = "ErrCtl";
default:
goto cp0_unimplemented;
}
case 27:
switch (sel) {
case 0 ... 3:
rn = "CacheErr";
default:
goto cp0_unimplemented;
}
case 28:
switch (sel) {
case 0:
case 6:
gen_helper_mtc0_taglo(cpu_env, arg);
rn = "TagLo";
case 1:
case 5:
case 7:
gen_helper_mtc0_datalo(cpu_env, arg);
rn = "DataLo";
default:
goto cp0_unimplemented;
}
case 29:
switch (sel) {
case 0:
case 6:
gen_helper_mtc0_taghi(cpu_env, arg);
rn = "TagHi";
case 1:
case 5:
case 7:
gen_helper_mtc0_datahi(cpu_env, arg);
rn = "DataHi";
default:
rn = "invalid sel";
goto cp0_unimplemented;
}
case 30:
switch (sel) {
case 0:
tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_ErrorEPC));
rn = "ErrorEPC";
default:
goto cp0_unimplemented;
}
case 31:
switch (sel) {
case 0:
gen_mtc0_store32(arg, offsetof(CPUMIPSState, CP0_DESAVE));
rn = "DESAVE";
case 2 ... 7:
CP0_CHECK(ctx->kscrexist & (1 << sel));
tcg_gen_st_tl(arg, cpu_env,
offsetof(CPUMIPSState, CP0_KScratch[sel-2]));
rn = "KScratch";
default:
goto cp0_unimplemented;
}
ctx->bstate = BS_STOP;
default:
goto cp0_unimplemented;
}
trace_mips_translate_c0("dmtc0", rn, reg, sel);
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_end();
ctx->bstate = BS_STOP;
}
return;
cp0_unimplemented:
qemu_log_mask(LOG_UNIMP, "dmtc0 %s (reg %d sel %d)\n", rn, reg, sel);
}
| 1threat
|
QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops)
{
QEMUFile *f;
f = g_malloc0(sizeof(QEMUFile));
f->opaque = opaque;
f->ops = ops;
f->is_write = 0;
return f;
}
| 1threat
|
BlockDeviceInfoList *bdrv_named_nodes_list(Error **errp)
{
BlockDeviceInfoList *list, *entry;
BlockDriverState *bs;
list = NULL;
QTAILQ_FOREACH(bs, &graph_bdrv_states, node_list) {
BlockDeviceInfo *info = bdrv_block_device_info(bs, errp);
if (!info) {
qapi_free_BlockDeviceInfoList(list);
return NULL;
}
entry = g_malloc0(sizeof(*entry));
entry->value = info;
entry->next = list;
list = entry;
}
return list;
}
| 1threat
|
void qmp_drive_mirror(DriveMirror *arg, Error **errp)
{
BlockDriverState *bs;
BlockBackend *blk;
BlockDriverState *source, *target_bs;
AioContext *aio_context;
BlockMirrorBackingMode backing_mode;
Error *local_err = NULL;
QDict *options = NULL;
int flags;
int64_t size;
const char *format = arg->format;
blk = blk_by_name(arg->device);
if (!blk) {
error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", arg->device);
return;
}
aio_context = blk_get_aio_context(blk);
aio_context_acquire(aio_context);
if (!blk_is_available(blk)) {
error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, arg->device);
goto out;
}
bs = blk_bs(blk);
if (!arg->has_mode) {
arg->mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
}
if (!arg->has_format) {
format = (arg->mode == NEW_IMAGE_MODE_EXISTING
? NULL : bs->drv->format_name);
}
flags = bs->open_flags | BDRV_O_RDWR;
source = backing_bs(bs);
if (!source && arg->sync == MIRROR_SYNC_MODE_TOP) {
arg->sync = MIRROR_SYNC_MODE_FULL;
}
if (arg->sync == MIRROR_SYNC_MODE_NONE) {
source = bs;
}
size = bdrv_getlength(bs);
if (size < 0) {
error_setg_errno(errp, -size, "bdrv_getlength failed");
goto out;
}
if (arg->has_replaces) {
BlockDriverState *to_replace_bs;
AioContext *replace_aio_context;
int64_t replace_size;
if (!arg->has_node_name) {
error_setg(errp, "a node-name must be provided when replacing a"
" named node of the graph");
goto out;
}
to_replace_bs = check_to_replace_node(bs, arg->replaces, &local_err);
if (!to_replace_bs) {
error_propagate(errp, local_err);
goto out;
}
replace_aio_context = bdrv_get_aio_context(to_replace_bs);
aio_context_acquire(replace_aio_context);
replace_size = bdrv_getlength(to_replace_bs);
aio_context_release(replace_aio_context);
if (size != replace_size) {
error_setg(errp, "cannot replace image with a mirror image of "
"different size");
goto out;
}
}
if (arg->mode == NEW_IMAGE_MODE_ABSOLUTE_PATHS) {
backing_mode = MIRROR_SOURCE_BACKING_CHAIN;
} else {
backing_mode = MIRROR_OPEN_BACKING_CHAIN;
}
if ((arg->sync == MIRROR_SYNC_MODE_FULL || !source)
&& arg->mode != NEW_IMAGE_MODE_EXISTING)
{
assert(format);
bdrv_img_create(arg->target, format,
NULL, NULL, NULL, size, flags, &local_err, false);
} else {
switch (arg->mode) {
case NEW_IMAGE_MODE_EXISTING:
break;
case NEW_IMAGE_MODE_ABSOLUTE_PATHS:
bdrv_img_create(arg->target, format,
source->filename,
source->drv->format_name,
NULL, size, flags, &local_err, false);
break;
default:
abort();
}
}
if (local_err) {
error_propagate(errp, local_err);
goto out;
}
options = qdict_new();
if (arg->has_node_name) {
qdict_put(options, "node-name", qstring_from_str(arg->node_name));
}
if (format) {
qdict_put(options, "driver", qstring_from_str(format));
}
target_bs = bdrv_open(arg->target, NULL, options,
flags | BDRV_O_NO_BACKING, errp);
if (!target_bs) {
goto out;
}
bdrv_set_aio_context(target_bs, aio_context);
blockdev_mirror_common(arg->has_job_id ? arg->job_id : NULL, bs, target_bs,
arg->has_replaces, arg->replaces, arg->sync,
backing_mode, arg->has_speed, arg->speed,
arg->has_granularity, arg->granularity,
arg->has_buf_size, arg->buf_size,
arg->has_on_source_error, arg->on_source_error,
arg->has_on_target_error, arg->on_target_error,
arg->has_unmap, arg->unmap,
&local_err);
bdrv_unref(target_bs);
error_propagate(errp, local_err);
out:
aio_context_release(aio_context);
}
| 1threat
|
Rails: uniq vs. distinct : <p>Can someone briefly explain to me the difference in use between the methods <code>uniq</code> and <code>distinct</code>?</p>
<p>I've seen both used in similar context, but the difference isnt quite clear to me.</p>
| 0debug
|
Should i use express.js or is node.js sufficient? : I'm building a web-app where the event from html is translated as a query to the node js server. The node has to query the mongo and send back the response as json file.
My question is how can I write a json file from the result of the query? Should i use express framework to achieve this?
| 0debug
|
int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max){
AVRational a0={0,1}, a1={1,0};
int sign= (nom<0) ^ (den<0);
int64_t gcd= ff_gcd(FFABS(nom), FFABS(den));
nom = FFABS(nom)/gcd;
den = FFABS(den)/gcd;
if(nom<=max && den<=max){
a1= (AVRational){nom, den};
den=0;
}
while(den){
int64_t x = nom / den;
int64_t next_den= nom - den*x;
int64_t a2n= x*a1.num + a0.num;
int64_t a2d= x*a1.den + a0.den;
if(a2n > max || a2d > max){
if(a1.num) x= (max - a0.num) / a1.num;
if(a1.den) x= FFMIN(x, (max - a0.den) / a1.den);
if (den*(2*x*a1.den + a0.den) > nom*a1.den)
a1 = (AVRational){x*a1.num + a0.num, x*a1.den + a0.den};
break;
}
a0= a1;
a1= (AVRational){a2n, a2d};
nom= den;
den= next_den;
}
assert(ff_gcd(a1.num, a1.den) == 1);
*dst_nom = sign ? -a1.num : a1.num;
*dst_den = a1.den;
return den==0;
}
| 1threat
|
Uploading Image into R Markdown : <p>I have an image stored on my hard drive and I want to import it into an R-Markdown document I have.</p>
<p>I have 2 copies in both PNG and JPEG format, but for the life of me I cannot figure out how the read functions work in the "png" and "jpg" packages.</p>
<p>Can someone please help?</p>
| 0debug
|
static void avc_loopfilter_luma_intra_edge_hor_msa(uint8_t *data,
uint8_t alpha_in,
uint8_t beta_in,
uint32_t img_width)
{
v16u8 p2_asub_p0, q2_asub_q0, p0_asub_q0;
v16u8 alpha, beta;
v16u8 is_less_than, is_less_than_beta, negate_is_less_than_beta;
v16u8 p2, p1, p0, q0, q1, q2;
v16u8 p3_org, p2_org, p1_org, p0_org, q0_org, q1_org, q2_org, q3_org;
v8i16 p1_org_r, p0_org_r, q0_org_r, q1_org_r;
v8i16 p1_org_l, p0_org_l, q0_org_l, q1_org_l;
v8i16 p2_r = { 0 };
v8i16 p1_r = { 0 };
v8i16 p0_r = { 0 };
v8i16 q0_r = { 0 };
v8i16 q1_r = { 0 };
v8i16 q2_r = { 0 };
v8i16 p2_l = { 0 };
v8i16 p1_l = { 0 };
v8i16 p0_l = { 0 };
v8i16 q0_l = { 0 };
v8i16 q1_l = { 0 };
v8i16 q2_l = { 0 };
v16u8 tmp_flag;
v16i8 zero = { 0 };
alpha = (v16u8) __msa_fill_b(alpha_in);
beta = (v16u8) __msa_fill_b(beta_in);
p1_org = LOAD_UB(data - (img_width << 1));
p0_org = LOAD_UB(data - img_width);
q0_org = LOAD_UB(data);
q1_org = LOAD_UB(data + img_width);
{
v16u8 p1_asub_p0, q1_asub_q0, is_less_than_alpha;
p0_asub_q0 = __msa_asub_u_b(p0_org, q0_org);
p1_asub_p0 = __msa_asub_u_b(p1_org, p0_org);
q1_asub_q0 = __msa_asub_u_b(q1_org, q0_org);
is_less_than_alpha = (p0_asub_q0 < alpha);
is_less_than_beta = (p1_asub_p0 < beta);
is_less_than = is_less_than_beta & is_less_than_alpha;
is_less_than_beta = (q1_asub_q0 < beta);
is_less_than = is_less_than_beta & is_less_than;
}
if (!__msa_test_bz_v(is_less_than)) {
q2_org = LOAD_UB(data + (2 * img_width));
p3_org = LOAD_UB(data - (img_width << 2));
p2_org = LOAD_UB(data - (3 * img_width));
p1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p1_org);
p0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p0_org);
q0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q0_org);
p1_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) p1_org);
p0_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) p0_org);
q0_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) q0_org);
tmp_flag = alpha >> 2;
tmp_flag = tmp_flag + 2;
tmp_flag = (p0_asub_q0 < tmp_flag);
p2_asub_p0 = __msa_asub_u_b(p2_org, p0_org);
is_less_than_beta = (p2_asub_p0 < beta);
is_less_than_beta = is_less_than_beta & tmp_flag;
negate_is_less_than_beta = __msa_xori_b(is_less_than_beta, 0xff);
is_less_than_beta = is_less_than_beta & is_less_than;
negate_is_less_than_beta = negate_is_less_than_beta & is_less_than;
{
v8u16 is_less_than_beta_l, is_less_than_beta_r;
q1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q1_org);
is_less_than_beta_r =
(v8u16) __msa_sldi_b((v16i8) is_less_than_beta, zero, 8);
if (!__msa_test_bz_v((v16u8) is_less_than_beta_r)) {
v8i16 p3_org_r;
p3_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p3_org);
p2_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p2_org);
AVC_LOOP_FILTER_P0P1P2_OR_Q0Q1Q2(p3_org_r, p0_org_r,
q0_org_r, p1_org_r,
p2_r, q1_org_r,
p0_r, p1_r, p2_r);
}
q1_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) q1_org);
is_less_than_beta_l =
(v8u16) __msa_sldi_b(zero, (v16i8) is_less_than_beta, 8);
if (!__msa_test_bz_v((v16u8) is_less_than_beta_l)) {
v8i16 p3_org_l;
p3_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) p3_org);
p2_l = (v8i16) __msa_ilvl_b(zero, (v16i8) p2_org);
AVC_LOOP_FILTER_P0P1P2_OR_Q0Q1Q2(p3_org_l, p0_org_l,
q0_org_l, p1_org_l,
p2_l, q1_org_l,
p0_l, p1_l, p2_l);
}
}
if (!__msa_test_bz_v(is_less_than_beta)) {
p0 = (v16u8) __msa_pckev_b((v16i8) p0_l, (v16i8) p0_r);
p1 = (v16u8) __msa_pckev_b((v16i8) p1_l, (v16i8) p1_r);
p2 = (v16u8) __msa_pckev_b((v16i8) p2_l, (v16i8) p2_r);
p0_org = __msa_bmnz_v(p0_org, p0, is_less_than_beta);
p1_org = __msa_bmnz_v(p1_org, p1, is_less_than_beta);
p2_org = __msa_bmnz_v(p2_org, p2, is_less_than_beta);
STORE_UB(p1_org, data - (2 * img_width));
STORE_UB(p2_org, data - (3 * img_width));
}
{
v8u16 negate_is_less_than_beta_r, negate_is_less_than_beta_l;
negate_is_less_than_beta_r =
(v8u16) __msa_sldi_b((v16i8) negate_is_less_than_beta, zero, 8);
if (!__msa_test_bz_v((v16u8) negate_is_less_than_beta_r)) {
AVC_LOOP_FILTER_P0_OR_Q0(p0_org_r, q1_org_r, p1_org_r, p0_r);
}
negate_is_less_than_beta_l =
(v8u16) __msa_sldi_b(zero, (v16i8) negate_is_less_than_beta, 8);
if (!__msa_test_bz_v((v16u8) negate_is_less_than_beta_l)) {
AVC_LOOP_FILTER_P0_OR_Q0(p0_org_l, q1_org_l, p1_org_l, p0_l);
}
}
if (!__msa_test_bz_v(negate_is_less_than_beta)) {
p0 = (v16u8) __msa_pckev_b((v16i8) p0_l, (v16i8) p0_r);
p0_org = __msa_bmnz_v(p0_org, p0, negate_is_less_than_beta);
}
STORE_UB(p0_org, data - img_width);
q3_org = LOAD_UB(data + (3 * img_width));
q2_asub_q0 = __msa_asub_u_b(q2_org, q0_org);
is_less_than_beta = (q2_asub_q0 < beta);
is_less_than_beta = is_less_than_beta & tmp_flag;
negate_is_less_than_beta = __msa_xori_b(is_less_than_beta, 0xff);
is_less_than_beta = is_less_than_beta & is_less_than;
negate_is_less_than_beta = negate_is_less_than_beta & is_less_than;
{
v8u16 is_less_than_beta_l, is_less_than_beta_r;
is_less_than_beta_r =
(v8u16) __msa_sldi_b((v16i8) is_less_than_beta, zero, 8);
if (!__msa_test_bz_v((v16u8) is_less_than_beta_r)) {
v8i16 q3_org_r;
q3_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q3_org);
q2_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q2_org);
AVC_LOOP_FILTER_P0P1P2_OR_Q0Q1Q2(q3_org_r, q0_org_r,
p0_org_r, q1_org_r,
q2_r, p1_org_r,
q0_r, q1_r, q2_r);
}
is_less_than_beta_l =
(v8u16) __msa_sldi_b(zero, (v16i8) is_less_than_beta, 8);
if (!__msa_test_bz_v((v16u8) is_less_than_beta_l)) {
v8i16 q3_org_l;
q3_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) q3_org);
q2_l = (v8i16) __msa_ilvl_b(zero, (v16i8) q2_org);
AVC_LOOP_FILTER_P0P1P2_OR_Q0Q1Q2(q3_org_l, q0_org_l,
p0_org_l, q1_org_l,
q2_l, p1_org_l,
q0_l, q1_l, q2_l);
}
}
if (!__msa_test_bz_v(is_less_than_beta)) {
q0 = (v16u8) __msa_pckev_b((v16i8) q0_l, (v16i8) q0_r);
q1 = (v16u8) __msa_pckev_b((v16i8) q1_l, (v16i8) q1_r);
q2 = (v16u8) __msa_pckev_b((v16i8) q2_l, (v16i8) q2_r);
q0_org = __msa_bmnz_v(q0_org, q0, is_less_than_beta);
q1_org = __msa_bmnz_v(q1_org, q1, is_less_than_beta);
q2_org = __msa_bmnz_v(q2_org, q2, is_less_than_beta);
STORE_UB(q1_org, data + img_width);
STORE_UB(q2_org, data + 2 * img_width);
}
{
v8u16 negate_is_less_than_beta_r, negate_is_less_than_beta_l;
negate_is_less_than_beta_r =
(v8u16) __msa_sldi_b((v16i8) negate_is_less_than_beta, zero, 8);
if (!__msa_test_bz_v((v16u8) negate_is_less_than_beta_r)) {
AVC_LOOP_FILTER_P0_OR_Q0(q0_org_r, p1_org_r, q1_org_r, q0_r);
}
negate_is_less_than_beta_l =
(v8u16) __msa_sldi_b(zero, (v16i8) negate_is_less_than_beta, 8);
if (!__msa_test_bz_v((v16u8) negate_is_less_than_beta_l)) {
AVC_LOOP_FILTER_P0_OR_Q0(q0_org_l, p1_org_l, q1_org_l, q0_l);
}
}
if (!__msa_test_bz_v(negate_is_less_than_beta)) {
q0 = (v16u8) __msa_pckev_b((v16i8) q0_l, (v16i8) q0_r);
q0_org = __msa_bmnz_v(q0_org, q0, negate_is_less_than_beta);
}
STORE_UB(q0_org, data);
}
}
| 1threat
|
static int vtd_remap_irq_get(IntelIOMMUState *iommu, uint16_t index, VTDIrq *irq)
{
VTD_IRTE irte = {};
int ret = 0;
ret = vtd_irte_get(iommu, index, &irte);
if (ret) {
return ret;
}
irq->trigger_mode = irte.trigger_mode;
irq->vector = irte.vector;
irq->delivery_mode = irte.delivery_mode;
irq->dest = le32_to_cpu(irte.dest_id);
if (!iommu->intr_eime) {
#define VTD_IR_APIC_DEST_MASK (0xff00ULL)
#define VTD_IR_APIC_DEST_SHIFT (8)
irq->dest = (irq->dest & VTD_IR_APIC_DEST_MASK) >>
VTD_IR_APIC_DEST_SHIFT;
}
irq->dest_mode = irte.dest_mode;
irq->redir_hint = irte.redir_hint;
VTD_DPRINTF(IR, "remapping interrupt index %d: trig:%u,vec:%u,"
"deliver:%u,dest:%u,dest_mode:%u", index,
irq->trigger_mode, irq->vector, irq->delivery_mode,
irq->dest, irq->dest_mode);
return 0;
}
| 1threat
|
tableview with radio buttons got problem in objective c : <p>I have a tableview in that I have 17 rows(cells) in each cell I have 2 radio buttons id I click on 1st row radio button it automatically changed radio button image in 7th,12th,17th row.how to solve this</p>
| 0debug
|
int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size,
bool exact_size)
{
BDRVQcowState *s = bs->opaque;
int new_l1_size2, ret, i;
uint64_t *new_l1_table;
int64_t old_l1_table_offset, old_l1_size;
int64_t new_l1_table_offset, new_l1_size;
uint8_t data[12];
if (min_size <= s->l1_size)
return 0;
if (min_size > INT_MAX / sizeof(uint64_t)) {
return -EFBIG;
}
if (exact_size) {
new_l1_size = min_size;
} else {
new_l1_size = s->l1_size;
if (new_l1_size == 0) {
new_l1_size = 1;
}
while (min_size > new_l1_size) {
new_l1_size = (new_l1_size * 3 + 1) / 2;
}
}
if (new_l1_size > INT_MAX / sizeof(uint64_t)) {
return -EFBIG;
}
#ifdef DEBUG_ALLOC2
fprintf(stderr, "grow l1_table from %d to %" PRId64 "\n",
s->l1_size, new_l1_size);
#endif
new_l1_size2 = sizeof(uint64_t) * new_l1_size;
new_l1_table = g_malloc0(align_offset(new_l1_size2, 512));
memcpy(new_l1_table, s->l1_table, s->l1_size * sizeof(uint64_t));
BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_ALLOC_TABLE);
new_l1_table_offset = qcow2_alloc_clusters(bs, new_l1_size2);
if (new_l1_table_offset < 0) {
g_free(new_l1_table);
return new_l1_table_offset;
}
ret = qcow2_cache_flush(bs, s->refcount_block_cache);
if (ret < 0) {
goto fail;
}
ret = qcow2_pre_write_overlap_check(bs, 0, new_l1_table_offset,
new_l1_size2);
if (ret < 0) {
goto fail;
}
BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_WRITE_TABLE);
for(i = 0; i < s->l1_size; i++)
new_l1_table[i] = cpu_to_be64(new_l1_table[i]);
ret = bdrv_pwrite_sync(bs->file, new_l1_table_offset, new_l1_table, new_l1_size2);
if (ret < 0)
goto fail;
for(i = 0; i < s->l1_size; i++)
new_l1_table[i] = be64_to_cpu(new_l1_table[i]);
BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_ACTIVATE_TABLE);
cpu_to_be32w((uint32_t*)data, new_l1_size);
stq_be_p(data + 4, new_l1_table_offset);
ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, l1_size), data,sizeof(data));
if (ret < 0) {
goto fail;
}
g_free(s->l1_table);
old_l1_table_offset = s->l1_table_offset;
s->l1_table_offset = new_l1_table_offset;
s->l1_table = new_l1_table;
old_l1_size = s->l1_size;
s->l1_size = new_l1_size;
qcow2_free_clusters(bs, old_l1_table_offset, old_l1_size * sizeof(uint64_t),
QCOW2_DISCARD_OTHER);
return 0;
fail:
g_free(new_l1_table);
qcow2_free_clusters(bs, new_l1_table_offset, new_l1_size2,
QCOW2_DISCARD_OTHER);
return ret;
}
| 1threat
|
static void fw_cfg_data_mem_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
{
FWCfgState *s = opaque;
uint8_t buf[8];
unsigned i;
switch (size) {
case 1:
buf[0] = value;
break;
case 2:
stw_he_p(buf, value);
break;
case 4:
stl_he_p(buf, value);
break;
case 8:
stq_he_p(buf, value);
break;
default:
abort();
}
for (i = 0; i < size; ++i) {
fw_cfg_write(s, buf[i]);
}
}
| 1threat
|
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
int *got_sub_ptr,
AVPacket *avpkt)
{
int i, ret = 0;
if (avctx->codec->type != AVMEDIA_TYPE_SUBTITLE) {
av_log(avctx, AV_LOG_ERROR, "Invalid media type for subtitles\n");
return AVERROR(EINVAL);
}
*got_sub_ptr = 0;
avcodec_get_subtitle_defaults(sub);
if (avpkt->size) {
AVPacket pkt_recoded;
AVPacket tmp = *avpkt;
int did_split = av_packet_split_side_data(&tmp);
pkt_recoded = tmp;
ret = recode_subtitle(avctx, &pkt_recoded, &tmp);
if (ret < 0) {
*got_sub_ptr = 0;
} else {
avctx->pkt = &pkt_recoded;
if (avctx->pkt_timebase.den && avpkt->pts != AV_NOPTS_VALUE)
sub->pts = av_rescale_q(avpkt->pts,
avctx->pkt_timebase, AV_TIME_BASE_Q);
ret = avctx->codec->decode(avctx, sub, got_sub_ptr, &pkt_recoded);
av_assert1((ret >= 0) >= !!*got_sub_ptr &&
!!*got_sub_ptr >= !!sub->num_rects);
if (sub->num_rects && !sub->end_display_time && avpkt->duration &&
avctx->pkt_timebase.num) {
AVRational ms = { 1, 1000 };
sub->end_display_time = av_rescale_q(avpkt->duration,
avctx->pkt_timebase, ms);
}
for (i = 0; i < sub->num_rects; i++) {
if (sub->rects[i]->ass && !utf8_check(sub->rects[i]->ass)) {
av_log(avctx, AV_LOG_ERROR,
"Invalid UTF-8 in decoded subtitles text; "
"maybe missing -sub_charenc option\n");
avsubtitle_free(sub);
return AVERROR_INVALIDDATA;
}
}
if (tmp.data != pkt_recoded.data) {
pkt_recoded.side_data = NULL;
pkt_recoded.side_data_elems = 0;
av_free_packet(&pkt_recoded);
}
sub->format = !(avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB);
avctx->pkt = NULL;
}
if (did_split) {
ff_packet_free_side_data(&tmp);
if(ret == tmp.size)
ret = avpkt->size;
}
if (*got_sub_ptr)
avctx->frame_number++;
}
return ret;
}
| 1threat
|
While loop isn't looping : <p>I have a while loop which I would like to keep prompting a user to enter a number until the user types "exit". Unfortunately when the user enters anything, they aren't prompted to enter another number, and the procedure doesn't end. I'm using Pycharm as my IDE. Here is my code:</p>
<pre><code>a = []
num = ""
newa = []
def makelist():
num = input("Type a number! Or if you want to exit, type 'exit' ")
while num != "exit":
if int(num):
a.append(num)
num
def firstandlast():
newa.append(a[0]) and newa.append([len(a)])
print("Here are the first and last numbers you typed:")
print(newa)
makelist()
firstandlast()
</code></pre>
| 0debug
|
static void print_sdp(void)
{
char sdp[16384];
int i;
AVFormatContext **avc = av_malloc(sizeof(*avc) * nb_output_files);
if (!avc)
exit(1);
for (i = 0; i < nb_output_files; i++)
avc[i] = output_files[i]->ctx;
av_sdp_create(avc, nb_output_files, sdp, sizeof(sdp));
printf("SDP:\n%s\n", sdp);
fflush(stdout);
av_freep(&avc);
}
| 1threat
|
Linux, Android, Lack of Compatablility with C : <p>If android is based on the linux kernel and is basicly a linux distro why can't it run C in front end apps. Why can't you download linux apps onto android with out special compilers and software. Should it not be built into the system. In some way i know it is becuase look at NetHunter. Its Kali backend with android frontend. So how dose this work? (Im a newb with Linux, just starting, need help, looking for a mentor) Are .DEB files cross platform and can i take a linux app and compile it as a .APK and it will work on android? Help me plz</p>
| 0debug
|
How to export previous logs in Stackdriver : <p>I have a log in Stackdriver that logs every request goes into my api and failed, and I want to write a script to count on the number of times each error message appears. The problem is, the export feature in Stackdriver V2 only allow me to sink upcoming error messages, but I only care about the logs entries that already lives in the log. Is there a way to download the complete log from Stackdriver?</p>
| 0debug
|
static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[32][2], int is34)
{
float power[34][PS_QMF_TIME_SLOTS] = {{0}};
float transient_gain[34][PS_QMF_TIME_SLOTS];
float *peak_decay_nrg = ps->peak_decay_nrg;
float *power_smooth = ps->power_smooth;
float *peak_decay_diff_smooth = ps->peak_decay_diff_smooth;
float (*delay)[PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2] = ps->delay;
float (*ap_delay)[PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2] = ps->ap_delay;
const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20;
const float peak_decay_factor = 0.76592833836465f;
const float transient_impact = 1.5f;
const float a_smooth = 0.25f;
int i, k, m, n;
int n0 = 0, nL = 32;
static const int link_delay[] = { 3, 4, 5 };
static const float a[] = { 0.65143905753106f,
0.56471812200776f,
0.48954165955695f };
if (is34 != ps->is34bands_old) {
memset(ps->peak_decay_nrg, 0, sizeof(ps->peak_decay_nrg));
memset(ps->power_smooth, 0, sizeof(ps->power_smooth));
memset(ps->peak_decay_diff_smooth, 0, sizeof(ps->peak_decay_diff_smooth));
memset(ps->delay, 0, sizeof(ps->delay));
memset(ps->ap_delay, 0, sizeof(ps->ap_delay));
}
for (n = n0; n < nL; n++) {
for (k = 0; k < NR_BANDS[is34]; k++) {
int i = k_to_i[k];
power[i][n] += s[k][n][0] * s[k][n][0] + s[k][n][1] * s[k][n][1];
}
}
for (i = 0; i < NR_PAR_BANDS[is34]; i++) {
for (n = n0; n < nL; n++) {
float decayed_peak = peak_decay_factor * peak_decay_nrg[i];
float denom;
peak_decay_nrg[i] = FFMAX(decayed_peak, power[i][n]);
power_smooth[i] += a_smooth * (power[i][n] - power_smooth[i]);
peak_decay_diff_smooth[i] += a_smooth * (peak_decay_nrg[i] - power[i][n] - peak_decay_diff_smooth[i]);
denom = transient_impact * peak_decay_diff_smooth[i];
transient_gain[i][n] = (denom > power_smooth[i]) ?
power_smooth[i] / denom : 1.0f;
}
}
for (k = 0; k < NR_ALLPASS_BANDS[is34]; k++) {
int b = k_to_i[k];
float g_decay_slope = 1.f - DECAY_SLOPE * (k - DECAY_CUTOFF[is34]);
float ag[PS_AP_LINKS];
g_decay_slope = av_clipf(g_decay_slope, 0.f, 1.f);
memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0]));
memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0]));
for (m = 0; m < PS_AP_LINKS; m++) {
memcpy(ap_delay[k][m], ap_delay[k][m]+numQMFSlots, 5*sizeof(ap_delay[k][m][0]));
ag[m] = a[m] * g_decay_slope;
}
for (n = n0; n < nL; n++) {
float in_re = delay[k][n+PS_MAX_DELAY-2][0] * phi_fract[is34][k][0] -
delay[k][n+PS_MAX_DELAY-2][1] * phi_fract[is34][k][1];
float in_im = delay[k][n+PS_MAX_DELAY-2][0] * phi_fract[is34][k][1] +
delay[k][n+PS_MAX_DELAY-2][1] * phi_fract[is34][k][0];
for (m = 0; m < PS_AP_LINKS; m++) {
float a_re = ag[m] * in_re;
float a_im = ag[m] * in_im;
float link_delay_re = ap_delay[k][m][n+5-link_delay[m]][0];
float link_delay_im = ap_delay[k][m][n+5-link_delay[m]][1];
float fractional_delay_re = Q_fract_allpass[is34][k][m][0];
float fractional_delay_im = Q_fract_allpass[is34][k][m][1];
ap_delay[k][m][n+5][0] = in_re;
ap_delay[k][m][n+5][1] = in_im;
in_re = link_delay_re * fractional_delay_re - link_delay_im * fractional_delay_im - a_re;
in_im = link_delay_re * fractional_delay_im + link_delay_im * fractional_delay_re - a_im;
ap_delay[k][m][n+5][0] += ag[m] * in_re;
ap_delay[k][m][n+5][1] += ag[m] * in_im;
}
out[k][n][0] = transient_gain[b][n] * in_re;
out[k][n][1] = transient_gain[b][n] * in_im;
}
}
for (; k < SHORT_DELAY_BAND[is34]; k++) {
memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0]));
memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0]));
for (n = n0; n < nL; n++) {
out[k][n][0] = transient_gain[k_to_i[k]][n] * delay[k][n+PS_MAX_DELAY-14][0];
out[k][n][1] = transient_gain[k_to_i[k]][n] * delay[k][n+PS_MAX_DELAY-14][1];
}
}
for (; k < NR_BANDS[is34]; k++) {
memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0]));
memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0]));
for (n = n0; n < nL; n++) {
out[k][n][0] = transient_gain[k_to_i[k]][n] * delay[k][n+PS_MAX_DELAY-1][0];
out[k][n][1] = transient_gain[k_to_i[k]][n] * delay[k][n+PS_MAX_DELAY-1][1];
}
}
}
| 1threat
|
static void bdrv_mirror_top_refresh_filename(BlockDriverState *bs, QDict *opts)
{
bdrv_refresh_filename(bs->backing->bs);
pstrcpy(bs->exact_filename, sizeof(bs->exact_filename),
bs->backing->bs->filename);
| 1threat
|
How to call a method which assigns a new value to argument if it's null in Java? : <p>I'm thinking about <code>validateEntity</code>. What do you think about it?</p>
<pre><code>T validateEntity(@Nullable T entity)
{
if (entity == null)
{
entity = DEFAULT_ENTITY;
}
return entity;
}
</code></pre>
| 0debug
|
How to integrate Capistrano with Docker for deployment? : <p>I am not sure my question is relevant as I may try to mix tools (Capistrano and Docker) that should not be mixed.</p>
<p>I have recently dockerized an application that is deployed with Capistrano. Docker compose is used both for development and staging environments.</p>
<p>This is how my project looks like (the application files are not shown):</p>
<pre><code>Capfile
docker-compose.yml
docker-compose.staging.yml
config/
deploy.rb
deploy
staging.rb
</code></pre>
<p>The Docker Compose files creates all the necessary containers (Nginx, PHP, MongoDB, Elasticsearch, etc.) to run the app in development or staging environment (hence some specific parameters defined in <code>docker-compose.staging.yml</code>).</p>
<p>The app is deployed to the staging environment with this command:</p>
<pre><code>cap staging deploy
</code></pre>
<p>The folder architecture on the server is the one of Capistrano:</p>
<pre><code>current
releases
20160912150720
20160912151003
20160912153905
shared
</code></pre>
<p>The following command has been run in the <code>current</code> directory of the staging server to instantiate all the necessary containers to run the app:</p>
<pre><code>docker-compose -f docker-compose.yml -f docker-compose.staging.yml up -d
</code></pre>
<p>So far so good. Things get more complicated on the next deploy: the <code>current</code> symlink will point to a new directory of the <code>releases</code> directory:</p>
<ul>
<li>If <code>deploy.rb</code> defines commands that need to be executed inside containers (like <code>docker-compose exec php composer install</code> for PHP), Docker tells that the containers don't exist yet (because the existing ones were created on the previous release folder).</li>
<li>If a <code>docker-compose up -d</code> command is executed in the Capistrano deployment process, I get some errors because of port conflicts (the previous containers still exist).</li>
</ul>
<p>Do you have an idea on how to solve this issue? Should I move away from Capistrano and do something different?</p>
<p>The idea would be to keep the (near) zero-downtime deployment that Capistrano offers with the flexibility of Docker containers (providing several PHP versions for various apps on the same server for instance).</p>
| 0debug
|
FragmentManager in android : Ok i Moved the NavigationTabbedActivity from one project to another but, im getting this Error `setSupportActionBar` method cannot be found.Ive tried replacing the the import widget.toolbar with
`import android.support.v7.widget.Toolbar;`
but it Doesnt solve the problem , and im having problem with
`getSupportFragmentManager` this method cannot be found , Actually it needs the class to extend with Activity but in my case the Class already extends an CustomActivity which inturn Extends default AndroidActivity,i tried extending the customActivity with AppCombatActivity but it didnt work either.Is this error because i copied the file ?where am i wrong?
| 0debug
|
How to Create SQLite Database Outside an Android Application? : <p>So far, tutorials I have found create databases and tables inside Android applications.</p>
<p>Usually, (in other languages) I created a database and tables, then simply used them in an application.</p>
<p>Can I do it in an Android application?</p>
<p>I do not want to create them in an application, however, I want to create a database and tables beforehand I use them in the application.</p>
<p>For example, can I access to SQLite of an application (in a device) from the terminal?</p>
<p>How can I do?</p>
<p>Thank you!</p>
| 0debug
|
static void esp_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
{
ESPState *s = opaque;
uint32_t saddr;
saddr = (addr >> s->it_shift) & (ESP_REGS - 1);
DPRINTF("write reg[%d]: 0x%2.2x -> 0x%2.2x\n", saddr, s->wregs[saddr],
val);
switch (saddr) {
case ESP_TCLO:
case ESP_TCMID:
s->rregs[ESP_RSTAT] &= ~STAT_TC;
break;
case ESP_FIFO:
if (s->do_cmd) {
s->cmdbuf[s->cmdlen++] = val & 0xff;
} else if ((s->rregs[ESP_RSTAT] & STAT_PIO_MASK) == 0) {
uint8_t buf;
buf = val & 0xff;
s->ti_size--;
fprintf(stderr, "esp: PIO data write not implemented\n");
} else {
s->ti_size++;
s->ti_buf[s->ti_wptr++] = val & 0xff;
}
break;
case ESP_CMD:
s->rregs[saddr] = val;
if (val & CMD_DMA) {
s->dma = 1;
s->rregs[ESP_TCLO] = s->wregs[ESP_TCLO];
s->rregs[ESP_TCMID] = s->wregs[ESP_TCMID];
} else {
s->dma = 0;
}
switch(val & CMD_CMD) {
case CMD_NOP:
DPRINTF("NOP (%2.2x)\n", val);
break;
case CMD_FLUSH:
DPRINTF("Flush FIFO (%2.2x)\n", val);
s->rregs[ESP_RINTR] = INTR_FC;
s->rregs[ESP_RSEQ] = 0;
s->rregs[ESP_RFLAGS] = 0;
break;
case CMD_RESET:
DPRINTF("Chip reset (%2.2x)\n", val);
esp_reset(s);
break;
case CMD_BUSRESET:
DPRINTF("Bus reset (%2.2x)\n", val);
s->rregs[ESP_RINTR] = INTR_RST;
if (!(s->wregs[ESP_CFG1] & CFG1_RESREPT)) {
esp_raise_irq(s);
}
break;
case CMD_TI:
handle_ti(s);
break;
case CMD_ICCS:
DPRINTF("Initiator Command Complete Sequence (%2.2x)\n", val);
write_response(s);
break;
case CMD_MSGACC:
DPRINTF("Message Accepted (%2.2x)\n", val);
write_response(s);
s->rregs[ESP_RINTR] = INTR_DC;
s->rregs[ESP_RSEQ] = 0;
break;
case CMD_SATN:
DPRINTF("Set ATN (%2.2x)\n", val);
break;
case CMD_SELATN:
DPRINTF("Set ATN (%2.2x)\n", val);
handle_satn(s);
break;
case CMD_SELATNS:
DPRINTF("Set ATN & stop (%2.2x)\n", val);
handle_satn_stop(s);
break;
case CMD_ENSEL:
DPRINTF("Enable selection (%2.2x)\n", val);
break;
default:
DPRINTF("Unhandled ESP command (%2.2x)\n", val);
break;
}
break;
case ESP_WBUSID ... ESP_WSYNO:
break;
case ESP_CFG1:
s->rregs[saddr] = val;
break;
case ESP_WCCF ... ESP_WTEST:
break;
case ESP_CFG2:
s->rregs[saddr] = val & CFG2_MASK;
break;
case ESP_CFG3 ... ESP_RES4:
s->rregs[saddr] = val;
break;
default:
break;
}
s->wregs[saddr] = val;
}
| 1threat
|
What is StringTokenizer in Java : <p>I have a problem like this.What does StringTokenizer do than split method for white spaces in java. According to <a href="https://docs.oracle.com/javase/7/docs/api/java/util/StringTokenizer.html" rel="nofollow noreferrer">Class StringTokenizer</a>
how is it better to use split method instead of using StringTokenizer. </p>
| 0debug
|
Can't solve the Javascript error : <p>I am writing a code in which if we hover over the pictures they will be seen in the div tag and also their alt text instead of the tag in div.
The HTML code is:</p>
<pre><code><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Photo Gallery</title>
<link rel="stylesheet" href="css/gallery.css">
<script src = "js/gallery.js"></script>
</head>
<body>
<div id = "image">
Hover over an image below to display here.
</div>
<img class = "preview" alt = "Styling with a Bandana" src = "https://s3-us-west-2.amazonaws.com/s.cdpn.io/389177/bacon.jpg" onmouseover = "upDate(this)" onmouseout = "unDo()">
<img class = "preview" alt = "With My Boy" src = "https://s3-us-west-2.amazonaws.com/s.cdpn.io/389177/bacon2.JPG" onmouseover = "upDate(this)" onmouseout = "unDo()">
<img class = "preview" src = "https://s3-us-west-2.amazonaws.com/s.cdpn.io/389177/bacon3.jpg" alt = "Young Puppy" onmouseover = "upDate(this)" onmouseout = "unDo()">
</body>
</html>
</code></pre>
<blockquote>
<p>Here is the CSS code:</p>
</blockquote>
<pre><code>body{
margin: 2%;
border: 1px solid black;
background-color: #b3b3b3;
}
#image{
line-height:650px;
width: 575px;
height: 650px;
border:5px solid black;
margin:0 auto;
background-color: #8e68ff;
background-image: url('');
background-repeat: no-repeat;
color:#FFFFFF;
text-align: center;
background-size: 100%;
margin-bottom:25px;
font-size: 150%;
}
.preview{
width:10%;
margin-left:17%;
border: 10px solid black;
}
img{
width:95%;
}
</code></pre>
<blockquote>
<p>The Javascript code is:</p>
</blockquote>
<pre><code>function upDate(previewPic){
/* In this function you should
1) change the url for the background image of the div with the id = "image"
to the source file of the preview image
2) Change the text of the div with the id = "image"
to the alt text of the preview image
*/
var urlString = 'url(previewPic.src)';
document.getElementById("image").style.backgroundImage = urlString;
document.getElementById("image").innerHTML = previewPic.alt;
}
function unDo(){
/* In this function you should
1) Update the url for the background image of the div with the id = "image"
back to the orginal-image. You can use the css code to see what that original URL was
2) Change the text of the div with the id = "image"
back to the original text. You can use the html code to see what that original text was
*/
var urlString = 'url(image)';
document.getElementById("image").style.backgroundImage = urlString;
document.getElementById("image").innerHTML = image.div;
}
</code></pre>
<p>I have to only know what's wrong with my Javascript code.I have used the debugger already and it's showing errors yet I cannot understand how to solve them.</p>
<p>All the things that need to be done has been given in the comments.When I hover over the picture the text inside the div is updated but it doesn't get undone when I hover outside the picture.And the picture doesn't get updated and undone.So if I could get any help.</p>
| 0debug
|
static int init_output_stream(OutputStream *ost, char *error, int error_len)
{
int ret = 0;
if (ost->encoding_needed) {
AVCodec *codec = ost->enc;
AVCodecContext *dec = NULL;
InputStream *ist;
ret = init_output_stream_encode(ost);
if (ret < 0)
return ret;
if ((ist = get_input_stream(ost)))
dec = ist->dec_ctx;
if (dec && dec->subtitle_header) {
ost->enc_ctx->subtitle_header = av_malloc(dec->subtitle_header_size);
if (!ost->enc_ctx->subtitle_header)
return AVERROR(ENOMEM);
memcpy(ost->enc_ctx->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);
ost->enc_ctx->subtitle_header_size = dec->subtitle_header_size;
}
if (!av_dict_get(ost->encoder_opts, "threads", NULL, 0))
av_dict_set(&ost->encoder_opts, "threads", "auto", 0);
if (ost->filter && ost->filter->filter->inputs[0]->hw_frames_ctx) {
ost->enc_ctx->hw_frames_ctx = av_buffer_ref(ost->filter->filter->inputs[0]->hw_frames_ctx);
if (!ost->enc_ctx->hw_frames_ctx)
return AVERROR(ENOMEM);
}
if ((ret = avcodec_open2(ost->enc_ctx, codec, &ost->encoder_opts)) < 0) {
if (ret == AVERROR_EXPERIMENTAL)
abort_codec_experimental(codec, 1);
snprintf(error, error_len,
"Error while opening encoder for output stream #%d:%d - "
"maybe incorrect parameters such as bit_rate, rate, width or height",
ost->file_index, ost->index);
return ret;
}
assert_avoptions(ost->encoder_opts);
if (ost->enc_ctx->bit_rate && ost->enc_ctx->bit_rate < 1000)
av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low."
"It takes bits/s as argument, not kbits/s\n");
ret = avcodec_parameters_from_context(ost->st->codecpar, ost->enc_ctx);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL,
"Error initializing the output stream codec context.\n");
exit_program(1);
}
if (ost->enc_ctx->nb_coded_side_data) {
int i;
ost->st->side_data = av_realloc_array(NULL, ost->enc_ctx->nb_coded_side_data,
sizeof(*ost->st->side_data));
if (!ost->st->side_data)
return AVERROR(ENOMEM);
for (i = 0; i < ost->enc_ctx->nb_coded_side_data; i++) {
const AVPacketSideData *sd_src = &ost->enc_ctx->coded_side_data[i];
AVPacketSideData *sd_dst = &ost->st->side_data[i];
sd_dst->data = av_malloc(sd_src->size);
if (!sd_dst->data)
return AVERROR(ENOMEM);
memcpy(sd_dst->data, sd_src->data, sd_src->size);
sd_dst->size = sd_src->size;
sd_dst->type = sd_src->type;
ost->st->nb_side_data++;
}
}
ost->st->time_base = ost->enc_ctx->time_base;
} else if (ost->stream_copy) {
ret = init_output_stream_streamcopy(ost);
if (ret < 0)
return ret;
ret = avcodec_parameters_to_context(ost->parser_avctx, ost->st->codecpar);
if (ret < 0)
return ret;
}
ret = init_output_bsfs(ost);
if (ret < 0)
return ret;
ost->mux_timebase = ost->st->time_base;
ost->initialized = 1;
ret = check_init_output_file(output_files[ost->file_index], ost->file_index);
if (ret < 0)
return ret;
return ret;
}
| 1threat
|
void add_codec(FFStream *stream, AVCodecContext *av)
{
AVStream *st;
switch(av->codec_type) {
case CODEC_TYPE_AUDIO:
if (av->bit_rate == 0)
av->bit_rate = 64000;
if (av->sample_rate == 0)
av->sample_rate = 22050;
if (av->channels == 0)
av->channels = 1;
break;
case CODEC_TYPE_VIDEO:
if (av->bit_rate == 0)
av->bit_rate = 64000;
if (av->frame_rate == 0)
av->frame_rate = 5 * FRAME_RATE_BASE;
if (av->width == 0 || av->height == 0) {
av->width = 160;
av->height = 128;
}
if (av->bit_rate_tolerance == 0)
av->bit_rate_tolerance = av->bit_rate / 4;
if (av->qmin == 0)
av->qmin = 3;
if (av->qmax == 0)
av->qmax = 31;
if (av->max_qdiff == 0)
av->max_qdiff = 3;
av->qcompress = 0.5;
av->qblur = 0.5;
break;
default:
abort();
}
st = av_mallocz(sizeof(AVStream));
if (!st)
return;
stream->streams[stream->nb_streams++] = st;
memcpy(&st->codec, av, sizeof(AVCodecContext));
}
| 1threat
|
What is the purpose of a makefile? : <p>What does it do? Do you just run make on the command line? Is the makefile just like a list of commands to execute and at the end of the make command you have a bunch of executable files?</p>
| 0debug
|
static int ehci_fill_queue(EHCIPacket *p)
{
USBEndpoint *ep = p->packet.ep;
EHCIQueue *q = p->queue;
EHCIqtd qtd = p->qtd;
uint32_t qtdaddr;
for (;;) {
if (NLPTR_TBIT(qtd.next) != 0) {
qtdaddr = qtd.next;
QTAILQ_FOREACH(p, &q->packets, next) {
if (p->qtdaddr == qtdaddr) {
goto leave;
if (get_dwords(q->ehci, NLPTR_GET(qtdaddr),
(uint32_t *) &qtd, sizeof(EHCIqtd) >> 2) < 0) {
return -1;
ehci_trace_qtd(q, NLPTR_GET(qtdaddr), &qtd);
if (!(qtd.token & QTD_TOKEN_ACTIVE)) {
p = ehci_alloc_packet(q);
p->qtdaddr = qtdaddr;
p->qtd = qtd;
if (ehci_execute(p, "queue") == -1) {
return -1;
assert(p->packet.status == USB_RET_ASYNC);
p->async = EHCI_ASYNC_INFLIGHT;
leave:
usb_device_flush_ep_queue(ep->dev, ep);
return 1;
| 1threat
|
Invalid argument supplied for foreach php ftp : Would someone mind checking the php code below. https://www.linuxliteos.com/test_info/download.php returns:
Warning: Invalid argument supplied for foreach() in /home/myhosthere/public_html/test_info/download.php on line 27
<?
ini_set('max_execution_time', '18000');
require_once('config.php');
$ftp_server = 'ftpipaddresshere';
$ftp_user_name = 'user';
$ftp_user_pass = 'password';
$conn_id = @ftp_connect($ftp_server, 21);
if(!$conn_id)
{
echo 'Error: Some problem in Connecting to Server!';
}
else
{
ftp_pasv($conn_id, true);
$login_result = @ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
if(!$login_result)
{
$error_msg = 'Error: Some problem in Connecting to Vendor Server! Cron Job failed on '.date('m/d/Y H:i:s');
}
else
{
$arr_files = ftp_rawlist($conn_id, './upload');
$arr_list = array();
if(count($arr_files))
{
foreach($arr_files as $str_file)
{
preg_match('|-rw-r--r-- 1 hwdb hwdb.+ (\d+) ([a-zA-Z]{3} .+\d+ \d+\:\d+) (.*)|', trim($str_file), $arr_details);
$arr_list[] = $arr_details[3];
}
}
$arr_final_list = array();
foreach($arr_list as $file_name)
{
if (@ftp_get($conn_id, '/home/myhost/public_html/test_info/upload/'.$file_name, 'upload/'.$file_name, FTP_BINARY)) {
$arr_final_list[] = $file_name;
//chmod('upload/'.$file_name, 0666);
echo "processed";
//Now do ftp delete
ftp_rename($conn_id, 'upload/'.$file_name, 'processed/'.$file_name);
}
else
{
echo "error";
}
}
}
}
?>
config.php
<?
$host="localhost";
$user="dbuser";
$password="password";
$database="db";
$conn = mysqli_connect($host,$user,$password,$database);
?>
Thank you in advance.
| 0debug
|
int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque,
int abort_on_failure)
{
QemuOpt *opt;
int rc = 0;
TAILQ_FOREACH(opt, &opts->head, next) {
rc = func(opt->name, opt->str, opaque);
if (abort_on_failure && rc != 0)
break;
}
return rc;
}
| 1threat
|
Read A bigges XML file : I know how to read a simple XML file in java using getelementbyTag
but here i want to read the mac address from here which is
01-0C-CD-01-00-34 in java
can anyone help me please.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<Address>
<P type="MAC-Address"xsi:type="tP_MACAddress">010C-CD-01-00-34</P>
<P type="VLAN-ID" xsi:type="tP_VLAN-ID">000</P>
<P type="VLAN-PRIORITY" xsi:type="tP_VLAN-PRIORITY">4</P>
<P type="APPID" xsi:type="tP_APPID">0001</P>
</Address>
<!-- end snippet -->
| 0debug
|
void armv7m_nvic_complete_irq(void *opaque, int irq)
{
nvic_state *s = (nvic_state *)opaque;
if (irq >= 16)
irq += 16;
gic_complete_irq(&s->gic, 0, irq);
}
| 1threat
|
How to match a int less than 50 in regx : <p>I want to match a url like "index.html\index_1.html\index_12.html\index_49.html\index_n.html
and the n must <50 not be 50</p>
| 0debug
|
void bdrv_set_on_error(BlockDriverState *bs, BlockdevOnError on_read_error,
BlockdevOnError on_write_error)
{
bs->on_read_error = on_read_error;
bs->on_write_error = on_write_error;
}
| 1threat
|
How to format single textview like below in android? : This is my first textview
This is my second
textview this
is my third
textview
| 0debug
|
innerHTML of null error : <p>Using <code>console.log</code> I am able to see value coming from another page, but when I am placing this value using <code>document.getElementById('abc').innerHTML = xyz.age;</code> it's giving me error of <code>Uncaught TypeError: Cannot set property 'innerHTML' of null</code></p>
<p>My JS</p>
<pre><code>xyz = JSON.parse(sessionStorage.getItem("details"));
document.getElementById('abc').innerHTML = xyz.age; //getting error from here
console.log(xyz.age);
</code></pre>
<p>Can you guyz help me out</p>
| 0debug
|
How to join 2 tables but same data's? : Is it possible to join to tables like in the picture,[example picture][1]
there are no foreign key in svotes but there are the same records.
In the select option tag I putted the school_year and the option are `2015-2016,2016-2017`. If I click the 2016 it should that the other table svotes can display the year of 2016 can it be possible? and How?
Here's my code:
<script type="text/javascript">
function getyr(str) {
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("result").innerHTML=xmlhttp.responseText;
}
}
//this part will be handle
xmlhttp.open("GET","get_winner.php?no="+str,true);
xmlhttp.send();
}
</script>
<select style="margin-left:-313px;" name="sy_no" onchange="getyr(this.value)">
<option></option>
<?php
include('../connect.php');
$sql2 = mysql_query("SELECT * FROM school_year");
while ($row1=mysql_fetch_array($sql2)){
echo "<option value=".$row1['syearid'].">".$row1['from_year'].'-'.$row1['to_year']."</option>";
}
?>
</select>
get_winner.php
<?php
include('../connect.php');
$no = $_GET['no'];
//this is where I get the year
$stud = mysql_query("SELECT * FROM studentvotes,school_year WHERE school_year.from_year = studentvotes.year AND studentvotes.year = '$no' ") or die(mysql_error());
echo"<center>";
echo "<form action='' method='POST' enctype='multipart/form-data' >";
echo " <table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
echo "<tr>";
echo "<th>IDno</th>";
echo "<th>Action</th>";
echo "</tr>";
while ($row=mysql_fetch_array($stud)){
$result = mysql_query("SELECT * FROM studenvotes,school_year WHERE studenvotes.year = school_year.from_year") or die(mysql_error());
$r1 = mysql_fetch_assoc($result);
?>
<tr class="headings">
<td><?php echo $row['idno']; ?></td>
<td> <a href="editcandidate.php?candid=<?php echo $row['candid']; ?> "style="border:1px solid grey; background:grey; border-radius:10%; padding:5px 14px; color:white; text-decoration:none; "> Edit </a></td>
<?php
}
?>
[1]: http://i.stack.imgur.com/bg4e8.png
| 0debug
|
Add Elements to an ArrayList within a HashMap : <p>How to add an Element to an ArrayList within a HashMap?</p>
<p>This is a question, that I have asked myself many times and forgot it after solving it. I guess many have the same one so here is the simple answer to it.</p>
<pre><code>// Example
HashMap<String, ArrayList<String>> someElements = new HashMap<String, ArrayList<String>>();
</code></pre>
| 0debug
|
Can someone please help me to built a simple music player webpage using django? : I want to create a webpage where admin can add music from backend and users can play the song and add to fevorite using Django. Thats all i want please someone help me
| 0debug
|
Monitor a log file(log rotation is daily), if there is exception in log file need to send alert using script : Need some guidance
Monitor a application log file(log rotation is daily), if exception in log file need to send alert using script
Thanks
| 0debug
|
What is the difference between read() and readline() in python? : <p>I am learning file handling in python right now. If i write read() method , it does work same as readline() method . There must be a difference between them and i want to learn that</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.