problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
VirtIOSCSIReq *virtio_scsi_pop_req_vring(VirtIOSCSI *s,
VirtIOSCSIVring *vring)
{
VirtIOSCSIReq *req = virtio_scsi_init_req(s, NULL);
int r;
req->vring = vring;
r = vring_pop((VirtIODevice *)s, &vring->vring, &req->elem);
if (r < 0) {
virtio_scsi_free_req(req);
req = NULL;
}
return req;
}
| 1threat |
how to increment in number limit of 3 i.e 000 : <p>i have a number limit i.e. 000 now i want to increment it by 1 so the next limit will be '001' but when i try to add it gives me '1',
also if somehow i figure out to maintain it '001', the second problem is after '009' there should be '010'. Advance Thanks for you efforts.</p>
| 0debug |
How to handle click events with @Directive in angular2? : <p>Is it possible to attach click events to the element on or within a directive? (not component) For example.. I have a directive defined as follows:</p>
<pre><code>import { Directive, OnInit, Input, ElementRef, Renderer } from '@angular/core';
declare var $: any; // JQuery
@Directive({
selector: '[gridStack]'
})
export class GridStackDirective implements OnInit {
@Input() w: number;
@Input() animate: boolean;
constructor(
private el: ElementRef,
private renderer: Renderer
) {
renderer.setElementAttribute(el.nativeElement, "class", "grid-stack");
}
ngOnInit() {
let renderer = this.renderer;
let nativeElement = this.el.nativeElement;
let animate: string = this.animate ? "yes" : "no";
renderer.setElementAttribute(nativeElement, "data-gs-width", String(this.w));
if(animate == "yes") {
renderer.setElementAttribute(nativeElement, "data-gs-animate", animate);
}
let options = {
cellHeight: 80,
verticalMargin: 10
};
// TODO: listen to an event here instead of just waiting for the time to expire
setTimeout(function () {
$('.grid-stack').gridstack(options);
}, 300);
}
}
</code></pre>
<p>In the html where I use that directive (index.html, note that I do not have any template associated with the @directive itself, can I include a click event?:</p>
<pre><code><div gridStack>
<div><a (click)="clickEvent()">Click Here</a></div>
</div>
</code></pre>
<p>I know this works if it is a component, but am looking to try to get it working with a directive if it is possible.</p>
| 0debug |
OSX and Safari Problems : <p>I am working with wordpress walkers and putting an icon just above the sub menu list items on primary navigation.</p>
<p>The problem is that with OSX. nothing I do via java or css positions the elements correctly in safari</p>
<p><a href="http://thehaventucson.org/" rel="nofollow noreferrer">http://thehaventucson.org/</a></p>
<p>I am more then willing to give creds to trustworthy peeps as well. </p>
<p>I would like to either get correct positioning or remove the element all together but on in safari.</p>
<p>I have combed through just about every snippet here and nothing seems to work. </p>
| 0debug |
static void audio_encode_example(const char *filename)
{
AVCodec *codec;
AVCodecContext *c= NULL;
AVFrame *frame;
AVPacket pkt;
int i, j, k, ret, got_output;
int buffer_size;
FILE *f;
uint16_t *samples;
float t, tincr;
printf("Encode audio file %s\n", filename);
codec = avcodec_find_encoder(AV_CODEC_ID_MP2);
if (!codec) {
fprintf(stderr, "Codec not found\n");
exit(1);
}
c = avcodec_alloc_context3(codec);
if (!c) {
fprintf(stderr, "Could not allocate audio codec context\n");
exit(1);
}
c->bit_rate = 64000;
c->sample_fmt = AV_SAMPLE_FMT_S16;
if (!check_sample_fmt(codec, c->sample_fmt)) {
fprintf(stderr, "Encoder does not support sample format %s",
av_get_sample_fmt_name(c->sample_fmt));
exit(1);
}
c->sample_rate = select_sample_rate(codec);
c->channel_layout = select_channel_layout(codec);
c->channels = av_get_channel_layout_nb_channels(c->channel_layout);
if (avcodec_open2(c, codec, NULL) < 0) {
fprintf(stderr, "Could not open codec\n");
exit(1);
}
f = fopen(filename, "wb");
if (!f) {
fprintf(stderr, "Could not open %s\n", filename);
exit(1);
}
frame = av_frame_alloc();
if (!frame) {
fprintf(stderr, "Could not allocate audio frame\n");
exit(1);
}
frame->nb_samples = c->frame_size;
frame->format = c->sample_fmt;
frame->channel_layout = c->channel_layout;
buffer_size = av_samples_get_buffer_size(NULL, c->channels, c->frame_size,
c->sample_fmt, 0);
if (!buffer_size) {
fprintf(stderr, "Could not get sample buffer size\n");
exit(1);
}
samples = av_malloc(buffer_size);
if (!samples) {
fprintf(stderr, "Could not allocate %d bytes for samples buffer\n",
buffer_size);
exit(1);
}
ret = avcodec_fill_audio_frame(frame, c->channels, c->sample_fmt,
(const uint8_t*)samples, buffer_size, 0);
if (ret < 0) {
fprintf(stderr, "Could not setup audio frame\n");
exit(1);
}
t = 0;
tincr = 2 * M_PI * 440.0 / c->sample_rate;
for(i=0;i<200;i++) {
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
for (j = 0; j < c->frame_size; j++) {
samples[2*j] = (int)(sin(t) * 10000);
for (k = 1; k < c->channels; k++)
samples[2*j + k] = samples[2*j];
t += tincr;
}
ret = avcodec_encode_audio2(c, &pkt, frame, &got_output);
if (ret < 0) {
fprintf(stderr, "Error encoding audio frame\n");
exit(1);
}
if (got_output) {
fwrite(pkt.data, 1, pkt.size, f);
av_free_packet(&pkt);
}
}
for (got_output = 1; got_output; i++) {
ret = avcodec_encode_audio2(c, &pkt, NULL, &got_output);
if (ret < 0) {
fprintf(stderr, "Error encoding frame\n");
exit(1);
}
if (got_output) {
fwrite(pkt.data, 1, pkt.size, f);
av_free_packet(&pkt);
}
}
fclose(f);
av_freep(&samples);
av_frame_free(&frame);
avcodec_close(c);
av_free(c);
}
| 1threat |
How can I read data from this json using groovy? i am new to this so kindly help me? : please find solution for me
i am new to api testing
[
{
"salesChannelName": "Global Customers",
"customerSegmentName": "Top Global Customers",
"productSolutionName": "Network Solutions",
"topology": "",
"productFamilyName": "Wavelengths",
"customerScenarioName": "",
"productQuestionId": "1"
}
] | 0debug |
How to add state tax in java : I'm trying to assign state tax to transactions but Im really new to java.
Im trying to have a different tax amount by state. Also I dont want it to auto generate the subtotal at $100.
Where am i going wrong im totally lost?
I've tried to add the different tax amount as new if variable but when i do so it gets rid of the tax for all trans.
function taxRate() {
var tax_rate = .07;
var order_taxes = 0;
var tax_percent = 0;
var subtotal = document.getElementById("order_subtotal").innerHTML;
subtotal = parseInt(subtotal);
var total = 0;
var state = document.getElementById("state").value;
if (state === 'NY') {
order_taxes += +(tax_rate * subtotal).toFixed(2);
tax_percent = +(tax_rate * 100).toFixed(2);
}
if (state === 'NJ') {
order_taxes += +(tax_rate * subtotal).toFixed(2);
tax_percent = +(tax_rate * 100).toFixed(2);
}
if (state === 'VA') {
order_taxes += +(tax_rate * subtotal).toFixed(2);
tax_percent = +(tax_rate * 100).toFixed(2);
}
if (state === 'AL') {
order_taxes += +(tax_rate * subtotal).toFixed(2);
tax_percent = +(tax_rate * 100).toFixed(2);
}
var el = document.getElementById('order_tax');
el.textContent = order_taxes;
var total = subtotal + order_taxes;
var el1 = document.getElementById('order_total');
el1.textContent = total;
document.getElementById('tax_percent').value = tax_percent;
}
| 0debug |
weblogic 12c with richfaces 4.0.0 - For <rich:fileupload> Deployment Failed : Issue when I try to deploy in to weblogic 12C
Steps that I followed,
JSTL - 1.2
JSF - 1.2
richfaces-rich-4.5.17.Final
richfaces-a4j-4.5.17.Final
richfaces-core-4.5.17.Final
Also I included,
guava-18.0.jar
cssparser-0.9.19.jar
sac-1.3.jar
annotations-4.0.0.Final.jar
Deployment was successful, but when I tried to upload a file using <rich:fileupload> I got the following error,
**The JSF implementation 1.0.0.0_2-1-5 does not support the RichFaces ExtendedPartialViewContext. Please upgrade to at least Mojarra 2.1.28 or 2.2.6**
Then I upgrade JSF1.2 to jsf-api-2.1.28 and jsf-impl-2.1.28 with Richfaces 4.5.17
When I try to file upload received,
javax.servlet.ServletException: IO Error parsing multipart request
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:242)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:216)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:132)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:352)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:75)
at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:343)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:75)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:302)
at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:367)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:75)
at com.singtel.eshop.filter.SignOnFilter.doFilter(SignOnFilter.java:150)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:75)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:75)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3288)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3254)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2163)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2091)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2074)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1512)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:255)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused by: org.ajax4jsf.exception.FileUploadException: IO Error parsing multipart request
at org.ajax4jsf.request.MultipartRequest.parseRequest(MultipartRequest.java:388)
at org.richfaces.component.FileUploadPhaselistener.beforePhase(FileUploadPhaselistener.java:63)
at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:228)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:99)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
... 29 more
Found The JSF default version of 12.1.1 WLS server is lower than 2.1.28 JSF version, so I changed JSF version to jsf-api-2.0.0 and jsf-impl-2.0.0 and
changed RichFaces version from 4.5.17 to
richfaces-core-api-4.0.0.Final,
richfaces-core-impl-4.0.0.Final,
richfaces-components-ui-4.0.0.Final,
richfaces-components-api-4.0.0.Final.
Deployment Failed
<Critical error during deployment:
com.sun.faces.config.ConfigurationException: The tag named remove from namespace http://java.sun.com/jsf/facelets has a null handler-class defined
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processHandlerClass(FaceletTaglibConfigProcessor.java:415)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processTags(FaceletTaglibConfigProcessor.java:371)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processTagLibrary(FaceletTaglibConfigProcessor.java:314)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.process(FaceletTaglibConfigProcessor.java:263)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:362)
Truncated. see log file for complete stacktrace
>
<Jul 12, 2016 6:29:19 PM SGT> <Warning> <HTTP> <BEA-101162> <User defined listener com.sun.faces.config.ConfigureListener failed: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: The tag named remove from namespace http://java.sun.com/jsf/facelets has a null handler-class defined.
java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: The tag named remove from namespace http://java.sun.com/jsf/facelets has a null handler-class defined
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:292)
at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:582)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
Truncated. see log file for complete stacktrace
Caused By: com.sun.faces.config.ConfigurationException: The tag named remove from namespace http://java.sun.com/jsf/facelets has a null handler-class defined
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processHandlerClass(FaceletTaglibConfigProcessor.java:415)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processTags(FaceletTaglibConfigProcessor.java:371)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processTagLibrary(FaceletTaglibConfigProcessor.java:314)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.process(FaceletTaglibConfigProcessor.java:263)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:362)
Truncated. see log file for complete stacktrace
I changed web.xml header to
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
**Please advice for fileupload in weblogic 12c using RichFaces**
| 0debug |
int ff_mov_read_esds(AVFormatContext *fc, ByteIOContext *pb, MOVAtom atom)
{
AVStream *st;
int tag, len;
if (fc->nb_streams < 1)
return 0;
st = fc->streams[fc->nb_streams-1];
get_be32(pb);
len = mp4_read_descr(fc, pb, &tag);
if (tag == MP4ESDescrTag) {
get_be16(pb);
get_byte(pb);
} else
get_be16(pb);
len = mp4_read_descr(fc, pb, &tag);
if (tag == MP4DecConfigDescrTag) {
int object_type_id = get_byte(pb);
get_byte(pb);
get_be24(pb);
get_be32(pb);
get_be32(pb);
st->codec->codec_id= ff_codec_get_id(ff_mp4_obj_type, object_type_id);
dprintf(fc, "esds object type id 0x%02x\n", object_type_id);
len = mp4_read_descr(fc, pb, &tag);
if (tag == MP4DecSpecificDescrTag) {
dprintf(fc, "Specific MPEG4 header len=%d\n", len);
if((uint64_t)len > (1<<30))
return -1;
st->codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
get_buffer(pb, st->codec->extradata, len);
st->codec->extradata_size = len;
if (st->codec->codec_id == CODEC_ID_AAC) {
MPEG4AudioConfig cfg;
ff_mpeg4audio_get_config(&cfg, st->codec->extradata,
st->codec->extradata_size);
st->codec->channels = cfg.channels;
if (cfg.object_type == 29 && cfg.sampling_index < 3)
st->codec->sample_rate = ff_mpa_freq_tab[cfg.sampling_index];
else if (cfg.ext_sample_rate)
st->codec->sample_rate = cfg.ext_sample_rate;
else
st->codec->sample_rate = cfg.sample_rate;
dprintf(fc, "mp4a config channels %d obj %d ext obj %d "
"sample rate %d ext sample rate %d\n", st->codec->channels,
cfg.object_type, cfg.ext_object_type,
cfg.sample_rate, cfg.ext_sample_rate);
if (!(st->codec->codec_id = ff_codec_get_id(mp4_audio_types,
cfg.object_type)))
st->codec->codec_id = CODEC_ID_AAC;
}
}
}
return 0;
} | 1threat |
Loop in C. The first loop in the program doesn't work and is infinite. : i don't understand why the first loop does not work. It is an infinite loop even if the owed float that is filled in is in fact bigger than 0. Why doesn't the loop work?
#import <cs50.h>
#import <stdio.h>
int main(void)
{
float owed = -1 ;
while (owed < 0)
{
printf("O hai! How much change is owed?\n") ;
float owed = GetFloat() ;
owed = owed * 100 ;
}
int coins = 0 ;
while (owed >= 25)
{
owed = owed - 25 ;
coins = coins + 1 ;
}
while (owed >= 10)
{
owed = owed - 10 ;
coins = coins + 1 ;
}
while (owed >= 5)
{
owed = owed - 5 ;
coins = coins + 1 ;
}
while (owed >= 1)
{
owed = owed - 1 ;
coins = coins + 1 ;
}
printf("%i\n", coins) ;
} | 0debug |
Centering a contact form button using CSS & HTML : <p>I tried posting my code but the system would not allow me to this this without an indent.</p>
<p>My button aligns left on my website yet it is centered properly when I preview it in CSS</p>
<p><a href="http://reverseloansforseniors.com/ppcfbk/" rel="nofollow noreferrer">http://reverseloansforseniors.com/ppcfbk/</a></p>
| 0debug |
Java issues instantiating my LinkedList to my array. Data Structures course : <p>I have scoured the internet and cannot find the answer to my question. I am currently in a data structures course, which is important to this question because I need to make EVERYTHING from scratch. I am currently working on homework and the question is this: </p>
<blockquote>
<p>Using a USet, implement a Bag. A Bag is like a USet—it supports the add(x), remove(x), and find(x) methods—but it allows duplicate elements to be stored. The find(x) operation in a Bag returns some element (if any) that is equal to x. In addition, a Bag supports the findAll(x) operation that returns a list of all elements in the Bag that are equal to x.</p>
</blockquote>
<p>I have done almost all of it and now when I am trying to test my code it throws a null pointer exception right off the bat. I went through the debugger and although I know where it is failing (when trying to create my array list and fill it with linked lists) I just dont know how to fix it. Here is what the error states:</p>
<pre><code>Exception in thread "main" java.lang.NullPointerException
at Bag.<init>(Bag.java:10)
at Bag.main(Bag.java:198)
</code></pre>
<p>because I havent even gotten it to start I obviously dont know of any other errors it will encounter, but I will face those when this is fixed. I appreciate any help. </p>
<p>Reminder: I cannot use pre-built java dictionaries, everything needs to be done from the basics.</p>
<p>Here is my entire code: </p>
<pre><code>public class Bag<T> {
final int ARR_SIZE = 128;
LinkedList[] theArray;
public Bag() {
for (int i = 0; i < ARR_SIZE; i++) {
theArray[i] = new LinkedList();
}
}
public boolean add(T x) {
T element = x;
int hashKey = element.hashCode() % ARR_SIZE;
theArray[hashKey].addFirst(element, hashKey);
return true;
}
public T find(T x) {
T element = x;
int hashKey = element.hashCode() % ARR_SIZE;
return theArray[hashKey].findNode(element).getData();
}
public T findAll(T x) {
T element = x;
int hashKey = element.hashCode() % ARR_SIZE;
System.out.print(theArray[hashKey].findAllElements(element));
return element;
}
public T remove(T x) {
T element = x;
int hashKey = element.hashCode() % ARR_SIZE;
return theArray[hashKey].removeElement(element);
}
public int size() {
return ARR_SIZE;
}
public class Node {
T data;
int key;
Node next;
Node prev;
public Node(T t, int k, Node p, Node n) {
data = t;
key = k;
prev = p;
next = n;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public Node getNext() {
return next;
}
public void setNext(Node next) {
this.next = next;
}
public Node getPrev() {
return prev;
}
public void setPrev(Node prev) {
this.prev = prev;
}
public void display() {
System.out.println(data);
}
}
public class LinkedList {
Node header;
Node trailer;
int size = 0;
public LinkedList() {
header = new Node(null, -1, trailer, null);
trailer = new Node(null, -1, null, null);
header.setNext(trailer);
}
public int size() {
return size;
}
public boolean isEmpty() {
return size() == 0;
}
public void addFirst(T t, int hashKey) {
Node currentLast = header.getNext();
Node newest = new Node(t, hashKey, header, currentLast);
header.setNext(newest);
currentLast.setPrev(newest);
size++;
}
public T add(T t) {
Node currentLast = header.getNext();
Node newest = new Node(t, -1, header, currentLast);
header.setNext(newest);
currentLast.setPrev(newest);
size++;
return newest.getData();
}
public T removeElement(T t) {
if (isEmpty()) {
return null;
}
T element = t;
return removeNode(findNode(element));
}
public T removeNode(Node node) {
if (isEmpty()) {
return null;
}
Node pred = node.getPrev();
Node succ = node.getNext();
pred.setNext(succ);
succ.setPrev(pred);
size--;
return node.getData();
}
public LinkedList findAllElements(T t) {
Node current = header.getNext();
T element = t;
if (isEmpty()) {
return null;
}
LinkedList all = new LinkedList();
while (current != null) {
if (current.getData() == element) {
all.addFirst(element, -1);
} else {
current = current.getNext();
}
}
return all;
}
public Node findNode(T t) {
Node current = header.getNext();
T element = t;
if (isEmpty()) {
return null;
}
while (current.getNext() != null && current.getData() != element) {
current = current.getNext();
}
if (current.getNext() == null && current.getData() != element) {
System.out.println("Does not exist");
}
return current;
}
}
public static void main(String[] args) {
Bag<Integer> bag = new Bag();
bag.add(1);
bag.add(1);
bag.add(2);
bag.add(2);
bag.add(8);
bag.add(5);
bag.add(90);
bag.add(43);
bag.add(43);
bag.add(77);
bag.add(100);
bag.add(88);
bag.add(555);
bag.add(345);
bag.add(555);
bag.add(999);
bag.find(1);
}
}
</code></pre>
| 0debug |
Kotlin kotlinClass.class.getName() cannot return package name but only simple class name : <p>AClass.class.getName();</p>
<p>if AClass is a java class, this method will return package name and class name.
but when i convert AClass java file to Kotlin file ,it will only return a class name. so system cannot find this class path</p>
<p>the code above </p>
| 0debug |
gob not decoding as expected : <p>Here is my playground where I am trying to serialize a list of structures and read back from the file.</p>
<p><a href="https://play.golang.org/p/8x0uciOd1Sq" rel="nofollow noreferrer">https://play.golang.org/p/8x0uciOd1Sq</a></p>
<p>I was expecting the object to be decoded successfully. What am I doing wrong?</p>
| 0debug |
ios keyboard covers the input which is located in the bottom of the screen : <p>ios keyboard covers the input which is located at the bottom of the screen. How can this trouble be solved?</p>
<p>here is the code.</p>
<pre><code> <Content style={styles.content}>
<Form>
<Item style={{borderBottomColor:'#42e8f4'}}>
<Icon active name='mail' style={{color: '#42e8f4'}} />
<Input placeholder='Email'placeholderTextColor= '#42e8f4' style={{color:'#0dc49d'}}/>
</Item>
<Item style={{ borderBottomColor:'#42e8f4'}}>
<Icon active name='lock' style={{color: '#42e8f4'}} />
<Input secureTextEntry={true} placeholder='Password'placeholderTextColor= '#42e8f4' style={{color:'#42e8f4'}}/>
</Item>
</Form>
<ListItem style={{borderBottomWidth:0,borderTopWidth:0,borderBottomColor:'#42e8f4'}}>
<Button transparent onPress={() => this.props.navigation.navigate("Signup")}>
<Text style={{color:'#42e8f4'}}>Create Account</Text>
</Button>
<Button transparent onPress={() => this.props.navigation.navigate("Forgetpass")}>
<Text style={{color:'#42e8f4'}}>Forget Password</Text>
</Button>
</ListItem>
<Button full
style={{backgroundColor:'#42e8f4'}}
onPress={() => this.props.navigation.navigate("Welcome")}>
<Text style={{color: '#FFF'}}>Sign In</Text>
</Button>
</Content>
const styles = {
content:{
position:'absolute',
bottom:10,
left:0,
right:0
},
}
</code></pre>
<p>I am using Native-Base. How can this issue be solved?</p>
| 0debug |
SqlServer Management Studio 2016 High DPI issue : <p>I have installed <strong>SqlServer Management Studio 2016</strong> and <strong>Visual Studio 2015</strong> on the same host with Windows 10.
While text in Visual Studio 2015 (and in Windows at all) is crisp the text in SSMS looks like rendered with blur option.</p>
<p><strong>How to make the text in SSMS sharp?</strong></p>
<p>The current state is in sample below (to see the difference you have to view it in 1:1 scale)..</p>
<p><a href="https://i.stack.imgur.com/WJJX1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WJJX1.png" alt="enter image description here"></a></p>
| 0debug |
av_cold int ff_rv34_decode_init(AVCodecContext *avctx)
{
RV34DecContext *r = avctx->priv_data;
MpegEncContext *s = &r->s;
MPV_decode_defaults(s);
s->avctx= avctx;
s->out_format = FMT_H263;
s->codec_id= avctx->codec_id;
s->width = avctx->width;
s->height = avctx->height;
r->s.avctx = avctx;
avctx->flags |= CODEC_FLAG_EMU_EDGE;
r->s.flags |= CODEC_FLAG_EMU_EDGE;
avctx->pix_fmt = PIX_FMT_YUV420P;
avctx->has_b_frames = 1;
s->low_delay = 0;
if (MPV_common_init(s) < 0)
return -1;
ff_h264_pred_init(&r->h, CODEC_ID_RV40);
r->intra_types_hist = av_malloc(s->b4_stride * 4 * 2 * sizeof(*r->intra_types_hist));
r->intra_types = r->intra_types_hist + s->b4_stride * 4;
r->mb_type = av_mallocz(r->s.mb_stride * r->s.mb_height * sizeof(*r->mb_type));
r->cbp_luma = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_luma));
r->cbp_chroma = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_chroma));
r->deblock_coefs = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->deblock_coefs));
if(!intra_vlcs[0].cbppattern[0].bits)
rv34_init_tables();
return 0;
}
| 1threat |
Remove last string value in foreach loop : <p>I have a loop in php </p>
<pre><code>foreach($Array as $key =>$value)
{
$TotalLine .= " Qualification =".$value." OR ";
}
echo $TotalLine;
</code></pre>
<p>Prints</p>
<pre><code> Qualification =1 OR Qualification =2 OR Qualification =3 OR Qualification =4 OR
</code></pre>
<p>Now i need to remove last <strong>OR</strong> in that line, Desired Output must look like</p>
<pre><code> Qualification =1 OR Qualification =2 OR Qualification =3 OR Qualification =4
</code></pre>
<p>How to do this. Any help appreciated. </p>
| 0debug |
Work with C# Project and Solution programmatically : <p>I am looking for approach add existing C# Project (.csproj) into solution (.sln) programmatically on C#. Will be good if posible escape use “illegal” way like parsing and edit xml document.</p>
<p>At the end of work, result should be like adding existing C# Project via Visual Studio.</p>
<p><a href="https://i.stack.imgur.com/gaEOn.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gaEOn.jpg" alt="enter image description here"></a></p>
| 0debug |
How do I organize my css better so that separate a tags don't get the same styling? : <p>This is how my index.php should <a href="https://codepen.io/SuperN00b/pen/rjKOaP" rel="nofollow noreferrer">look</a> (codepen link)</p>
<p>I'm trying to add javascript functions to the buttons on the right. However, there is a styling issue that messes the buttons up. This is what <a href="https://codepen.io/SuperN00b/pen/zNavYX" rel="nofollow noreferrer">happened</a>.</p>
<p>As you can see the log in button has taken the styling of the a tags for the footer.</p>
<p>I don't know much about javascript and got the code from a tutorial I found. I would rather not change the javascript. I'm sure that I probably need to organize my html or css better. If anyone has any tips, I would really appreciate it. I've been stuck on this for two days. </p>
<p>The only way I was able to move the button was styling it in html button </p>
<p>ex: </p>
<p><code><a id="loginbutton" href="javascript:toggle();" style="top: 220px;">log in</a></code>
I don't like this solution because I'm going to want to make the webpage responsive. I need to be able to make media queries in the stylesheet. </p>
<p>SUMMARY: </p>
<ol>
<li>When I added the javacript, the styling for the footer tag links (a tag) messes up my button styling. </li>
<li>This needs to be styled in the css file, not the html. </li>
</ol>
| 0debug |
g.Draw blinking alot : I'm using this function in a Timer:
```python
IntPtr Handle = FindWindow(null, "Notepad");
if (radioButton1.Checked)
{
using (Graphics g = Graphics.FromHwnd(Handle))
{
Pen PN = new Pen(pictureBox2.BackColor, (Convert.ToInt32(numericUpDown2.Value)));
g.DrawLine(PN, 961, 520, 961, 560);
g.DrawLine(PN, 985, 540, 935, 540);
g.Dispose();
}
}
```
But the draw is blinking alot even if i set the timer interval to 1 | 0debug |
list certificate stored in user credentials : <p>In Android 7 Nougat, user installed certificate goes to "User credentials" instead of "Trusted credentials"(which consists of system credential & user credential).</p>
<p>I used to access "Trusted credentials" by:</p>
<pre><code>KeyStore keystore = KeyStore.getInstance("AndroidCAStore");
</code></pre>
<p>through the above code I can then access system & user trusted credentials.</p>
<p>But now, in Android 7, user installed certificate goes to a separate place called "User credentials" under <code>Settings --> Security --> User credentials</code>. </p>
<p>My question is how can I programmatically list the credentials inside <code>User credentials</code> in Android 7?</p>
| 0debug |
TypeScript never type inference : <p>Can someone please explain me why given the following code:</p>
<pre><code>let f = () => {
throw new Error("Should never get here");
}
let g = function() {
throw new Error("Should never get here");
}
function h() {
throw new Error("Should never get here");
}
</code></pre>
<p>The following types are inferred:</p>
<ul>
<li><code>f</code> is <code>() => never</code></li>
<li><code>g</code> is <code>() => never</code></li>
<li><code>h</code> is <code>() => void</code></li>
</ul>
<p>I would expect the type of <code>h</code> to be <code>() => never</code> as well.</p>
<p>Thanks!</p>
| 0debug |
How to Remove doule backslashes in a string to Single one? : My string is tel:\\99999999999. How i can replace \\ to \ single? I want output like: tel:\99999999999. Double slash not showing into quetion | 0debug |
How to decide whether a number in a dictionary is a str or float? : <p>I am asking this because I saw a dictionary produced from two different sources, in which one number is a float, and the same number is a string.</p>
<p>data = {'name': 'jack', 'confidence': '0.95'}</p>
<p>The 'confidence' is a float in once case, and a str in another case. Why is that? </p>
<pre><code>conf = data.get('confidence')
</code></pre>
| 0debug |
ILI9340/41 cheap 2.4" LCD display SPI - cant read from the controller : I use in one of my projects the cheap 2.4" 320x240 TFT display with ILI9340/41 controller. It works quite good, taking into consideration the price, and I do not have any problems when I display something. But I cant read anything. I think that it uses 4 wire SPI
[![enter image description here][1]][1]
but unfortunately any read attempt is unsuccessful. On the first dummy write I see some strange activity on the MISO line and MISO is driven high.
[![enter image description here][2]][2]
Maybe someone knows where the problem is. I have tried literally everything.
[1]: https://i.stack.imgur.com/HbxHV.jpg
[2]: https://i.stack.imgur.com/JZtRN.png | 0debug |
Flutter: Add box shadow to a transparent Container : <p>I'm trying to make a widget that renders one of the circles shown in this <a href="https://i.stack.imgur.com/JCDVj.png" rel="noreferrer">image</a>. It is a transparent circle with a box-shadow. The circle should show whichever color or background image that is applied to the parent container. The circle is transparent but what I see is <a href="https://i.stack.imgur.com/I10D0.png" rel="noreferrer">this</a>: a black box shadow and not the background color of the parent. Any suggestions?</p>
<p>Here is what I have so far:</p>
<pre><code>class TransParentCircle extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
child: new Center(
child: new Container(
decoration: new BoxDecoration(
border: new Border.all(width: 1.0, color: Colors.black),
shape: BoxShape.circle,
color: Colors.transparent,
boxShadow: <BoxShadow>[
BoxShadow(
color: Colors.black,
offset: Offset(1.0, 6.0),
blurRadius: 40.0,
),
],
),
padding: EdgeInsets.all(16.0),
),
),
width: 320.0,
height: 240.0,
margin: EdgeInsets.only(bottom: 16.0));
}
}
</code></pre>
| 0debug |
foreignObject browser compatibility : <p>I want to use <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/foreignObject" rel="nofollow noreferrer">foreignObject</a> in an svg, to (conditionally) render an input field. In the MDN docs about foreignObject (see link above), a compatibility table shows a question mark on edge.</p>
<p>In other words - could someone with a windows machine and an Edge browser please be so kind and see if the following jsFiddle renders an input in the red circle:</p>
<p><a href="https://jsfiddle.net/sventies/p2osc5nt/" rel="nofollow noreferrer">https://jsfiddle.net/sventies/p2osc5nt/</a></p>
<pre><code><svg width="100%" height="500">
<circle cx="120" cy="120" r="100" fill="red" />
<foreignObject x="50" y="40" width="180" height="180">
<div xmlns="http://www.w3.org/1999/xhtml">
<br/>
<br/>
<input />
</div>
</foreignObject>
</svg>
</code></pre>
| 0debug |
meta random redirect random X seconds : <p>meta random redirect with random seconds.</p>
<pre><code><?php
$offers = array(
"http://www.url1.com",
"http://www.url2.com",
"http://www.url3.com",
"http://www.url4.com"
);
$referer = $_SERVER['HTTP_REFERER'];
if($referer == "") {
$url = $offers[rand(0, count($offers) - 1)];
echo "<meta http-equiv='refresh' content='0;url=$url'>";
}
else
{
echo "<meta http-equiv='refresh' content='0;url=http://www.firstpage.com'>";
}
?>
</code></pre>
<p>i need some one to add the random seconds ..
thank you</p>
| 0debug |
Is there and R function for recording variables? : I’m making the leap from SPSS to R but having a few teething issues.
For example, I’m trying to record a variable but I’m getting error messages. I can select cases easily enough. Is it a similar process?
Here’s the SPSS code I’m trying to translate:
RECODE income (1, 2 = 1) (3, 4 = 2) INTO income2.
EXECUTE.
CROSSTABS income2 by income.
* Recode to String.
STRING sex_values (A8).
RECODE sex (1 = 'Male') (2 = 'Female') INTO sex_values.
EXECUTE.
CROSSTABS sex_values by sex.
Grateful for any pointers as I think I’ve confused myself.
Cheers.
| 0debug |
Remove first item of each array inside of array in Javascript : <p>I have the following array in javascript:</p>
<pre><code>DATA[
[ 3, "Name1" ],
[ 5, "Name2" ],
[ 10, "Name3" ],
[ 55, "Name4" ]
]
</code></pre>
<p>I would like to convert it to:</p>
<pre><code>DATA[ "Name1", "Name2", "Name3", "Name4" ]
</code></pre>
<p>Is it possible in javascript?</p>
<p>Thanks</p>
| 0debug |
"Load" event on script with async and/or defer : <p>When embedding scripts like:</p>
<pre><code><script src="..." async defer></script>
</code></pre>
<p>Is there a way to know when they're finished loading?</p>
<p>Usually when the <code>window.load</code> event is called, one would expect all scripts to be ready as well. But I don't know if that still holds when you load them with <code>async</code> or <code>defer</code>. I've read some docs online but couldn't find anything conclusive on this issue.</p>
| 0debug |
what is the use of final while declaring the string variable? : my compiler was showing error while declaring the string variable but the hints showed that final is missing. after correcting, it worked but what is the use of final?
class outerclass
{
private static string upa = "tobby";
static class a
{
void printmessage(){
System.out.println("who is a good boy?"+upa);
}
}
class b
{
void printagain()
{
System.out.println("who is a bad boy?"+upa);
}
}
}
public class Main {
public static void main(String[] args) {
outerclass.a oa=new outerclass.a();
oa.printmessage();
outerclass outer= new outerclass();
outerclass.b ob= outer.new b();
ob.printagain();
}
}
| 0debug |
Simplest way to cascade styles in react native : <p>I see that in react native if I set a <code>fontFamily</code> in a, for example, a <code>View</code>, the inner elements do not inherit it the property. Is it there a cascade concept available in react native styling? How do I accomplish it?</p>
| 0debug |
What do I need to know about Common Lisp? : <p>I am currently trying to pick up the frustrating world of common lisp. Before I get too deep into this and get too angry at the computer could anyone give me pointers on what to expect and general tips/tricks.</p>
<p>Thanks</p>
| 0debug |
Format date without changing data type to varchar : <p>Today I was working with SQL and I was creating view in sql server , come to know that after convertng and formatting date time value dd-mm-yyyy date data type get changed </p>
<p>So my quest is , is there any way to convert or format date in dd-mm-yyyy without changing data type of column of view in sql server </p>
| 0debug |
Getting Error when installing app from Googl play store : Running app from Android studio on my device for testing working fine. But when i am trying to install same app from google plays store which is published under beta version getting error. I have uninstalling unsigned apk from the device but still not able to install from google play. Even cleared phone cache same result. Please help me out . Find attached Screen shot.
[enter image description here][1]
[1]: http://i.stack.imgur.com/Fepad.jpg | 0debug |
How to add a main method to this program? : <p>Hi I'm fairly new to coding and don't understand the required task I have to complete. How can I run the following code to make sure it works by adding a main method?</p>
<p>Answers and documents will be more than helpful, thank you.</p>
<pre><code>public static boolean approxEqual (double x, double y)
{
//Judge where two numbers are close enough (equal)
final double EPSILON = 1E-10;
if (Math.abs(x-y)<EPSILON)
{
return(true);
}
return(false);
}
</code></pre>
| 0debug |
Order of growth according to Big-O Notation : <p><a href="https://i.stack.imgur.com/0mIwe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0mIwe.png" alt="enter image description here"></a></p>
<p>Hello Stack Users, I am having trouble finishing this growth according to size algorithm problem. I was able to figure out the first two of the problem which are not listed in the picture. That would be 1. O(1) and 3. O(N) I was able to place these into their correct slots. I still cannot figure out how to determine the growth rate for 2,4,5,6 into the slots provided. Any suggestions on how to determine this?</p>
| 0debug |
int avio_close(AVIOContext *s)
{
AVIOInternal *internal;
URLContext *h;
if (!s)
return 0;
avio_flush(s);
internal = s->opaque;
h = internal->h;
av_opt_free(internal);
av_freep(&internal->protocols);
av_freep(&s->opaque);
av_freep(&s->buffer);
av_free(s);
return ffurl_close(h);
}
| 1threat |
How to Connect Mongodb to PHP Please tell me step by step : I am unable to Connect to PHP with mongodb. I have already done the all of process but unknown error is occur again and again.
Fatel error: Mongo Class not Found.
If anyone face this problem and solved it, so please tell me about this and how to fix this problem. | 0debug |
JAVA ISBN-10 Number: Find 10th digit : <p><strong>Question :</strong> </p>
<p>An ISBN-10 consists of 10 digits: d1,d2,d3,d4,d5,d6,d7,d8,d9,d10. The last digit, d10, is a checksum,which is calculated from the other nine digits using
<em>the following formula:</em></p>
<p><strong>(d1 * 1 + d2 * 2 + d3 * 3 + d4 * 4 + d5 * 5 + d6 * 6 + d7 * 7 + d8 * 8 + d9 * 9) % 11</strong></p>
<p>If the checksum is 10, the last digit is denoted as X according to the ISBN-10
convention. </p>
<p>Write a program that prompts the user to enter the first 9 digits and displays the 10-digit ISBN (including leading zeros). Your program should read the input as an integer.</p>
<p><em>Here are sample runs:</em></p>
<p><strong>Enter the first 9 digits of an ISBN as integer: 013601267</strong></p>
<p><strong>The ISBN-10 number is 0136012671</strong></p>
<p><strong>MY CODE:</strong></p>
<pre><code>import java.util.Scanner;
public class ISBN_Number {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int[] num = new int[9];
System.out.println("Enter the first 9 digits of the an ISBN as integer: ");
for (int i = 0; i < num.length; i++) {
for (int j = 1; j < 10; j++) {
num[i] = s.nextInt() * j;
}
}
int sum = 0;
for (int a = 0; a < 10; a++) {
sum += num[a];
}
int d10 = (sum % 11);
System.out.println(d10);
if (d10 == 10) {
System.out.println("The ISBN-10 number is " + num + "X");
} else {
System.out.println("The ISBN-10 number is" + num);
}
}
}
</code></pre>
<p><strong>ISSUE:</strong>
I am new to learning java, hence I am having trouble trying to figure this question out. Can some tell me where I am going wrong because I am not getting the expected outcome. Thank you.</p>
| 0debug |
React fragment shorthand failing to compile : <p>The project in question is using React-16.2.0 which has the capability to use Fragments and the Fragment shorthand.</p>
<p><a href="https://reactjs.org/blog/2017/11/28/react-v16.2.0-fragment-support.html" rel="noreferrer">https://reactjs.org/blog/2017/11/28/react-v16.2.0-fragment-support.html</a></p>
<p>While the full-length syntax works fine...</p>
<pre><code>import React, { Fragment, Component } from 'react';
class TestingFragment extends Component {
render() {
return (
<Fragment>
<span>This is a fragment of text </span>
<div>Another part of the fragment</div>
</Fragment>
)
}
};
export default TestingFragment
</code></pre>
<p>The shorthand fails to compile and I am at a loss as to why this is. Fore example...</p>
<pre><code>import React, { Component } from 'react';
class TestingFragment extends Component {
render() {
return (
<>
<span>This is a fragment of text </span>
<div>Another part of the fragment</div>
</>
)
}
};
export default TestingFragment
</code></pre>
<p>Which fails to compile as follows...</p>
<pre><code>Failed to compile
./src/testingFragments.js
Syntax error: Unexpected token (6:4)
4 | render() {
5 | return (
> 6 | <>
| ^
7 | <span>This is a fragment of text </span>
8 | <div>Another part of the fragment</div>
9 | </>
This error occurred during the build time and cannot be dismissed.
</code></pre>
<p>Is there something here I am missing about the Fragment shorthand syntax?</p>
| 0debug |
static void hpet_set_timer(HPETTimer *t)
{
uint64_t diff;
uint32_t wrap_diff;
uint64_t cur_tick = hpet_get_ticks();
t->wrap_flag = 0;
diff = hpet_calculate_diff(t, cur_tick);
if (t->config & HPET_TN_32BIT && !timer_is_periodic(t)) {
wrap_diff = 0xffffffff - (uint32_t)cur_tick;
if (wrap_diff < (uint32_t)diff) {
diff = wrap_diff;
t->wrap_flag = 1;
}
}
qemu_mod_timer(t->qemu_timer, qemu_get_clock(vm_clock)
+ (int64_t)ticks_to_ns(diff));
}
| 1threat |
Node.js setTimeout not fired after system time change : <p>I have such script </p>
<pre><code>setTimeout(function()
{
console.log("Timeout");
}, 1000 * 60);
</code></pre>
<p>When I run it and change system time back for one hour, the timeout not fires. If I change time forward for one hour, timeout works correctly.</p>
<p>Time is changed by external program which makes call like <code>ioctl( rtcFd, RTC_SET_TIME, &newTime);</code></p>
<p>How to fix this problem?</p>
<p>We use Node.js v0.10.15 on OpenWRT Attitude Adjustment</p>
<p>Thank you</p>
| 0debug |
static void mxf_write_generic_desc(ByteIOContext *pb, const MXFDescriptorWriteTableEntry *desc_tbl, AVStream *st)
{
const MXFCodecUL *codec_ul;
put_buffer(pb, desc_tbl->key, 16);
klv_encode_ber_length(pb, 108);
mxf_write_local_tag(pb, 16, 0x3C0A);
mxf_write_uuid(pb, SubDescriptor, st->index);
mxf_write_local_tag(pb, 4, 0x3006);
put_be32(pb, st->index);
mxf_write_local_tag(pb, 8, 0x3001);
put_be32(pb, st->time_base.den);
put_be32(pb, st->time_base.num);
codec_ul = mxf_get_essence_container_ul(st->codec->codec_id);
mxf_write_local_tag(pb, 16, 0x3004);
put_buffer(pb, codec_ul->uid, 16);
}
| 1threat |
Find string inside string using regular expressions : <p>So I'm trying to find a efficient way of extract a string inside a string, I believe regular expressions would probably be the best approach for this, however I'm not familiar with regular expressions nor with C# & How I would go about constructing that.</p>
<p>I'm currently using a for loop that searches the string for a sequence, then extracts the next 3 entries after that sequence, however it isn't accurate due to entries varying in size etc.</p>
<p>-Example of String</p>
<pre><code> heythereiamexample: 12instackoverflow
</code></pre>
<p>String can vary though in terms of chars between target string</p>
<p>-Example of target string</p>
<pre><code>example: 12
</code></pre>
<p>Now I don't necessarily mind on what I extract, whether it be the digits relative to the string, or the string entirely ( digits included ), but one factor is that the string must end with [0-9]+</p>
<p>So expected output would obviously be,</p>
<pre><code>example: 12
</code></pre>
| 0debug |
Angular app has to clear cache after new deployment : <p>We have an Angular 6 application. It’s served on Nginx. And SSL is on.</p>
<p>When we deploy new codes, most of new features work fine but not for some changes. For example, if the front-end developers update the service connection and deploy it, users have to open incognito window or clear cache to see the new feature.</p>
<p>What type of changes are not updated automatically? Why are they different from others?</p>
<p>What’s the common solution to avoid the issue?</p>
| 0debug |
Java/Gradle reading external config files : <p>My project structure looks like below. I do not want to include the config file as a resource, but instead read it at runtime so that we can simply change settings without having to recompile and deploy. my problem are two things</p>
<ol>
<li>reading the file just isn't working despite various ways i have tried (see current implementation below i am trying)</li>
<li>When using gradle, do i needto tell it how to build/or deploy the file and where? I think that may be part of the problem..that the config file is not getting deployed when doing a gradle build or trying to debug in Eclipse.</li>
</ol>
<p>My project structure:</p>
<pre><code>myproj\
\src
\main
\config
\com\my_app1\
config.dev.properties
config.qa.properties
\java
\com\myapp1\
\model\
\service\
\util\
Config.java
\test
</code></pre>
<p>Config.java:</p>
<pre><code>public Config(){
try {
String configPath = "/config.dev.properties"; //TODO: pass env in as parameter
System.out.println(configPath);
final File configFile = new File(configPath);
FileInputStream input = new FileInputStream(configFile);
Properties prop = new Properties()
prop.load(input);
String prop1 = prop.getProperty("PROP1");
System.out.println(prop1);
} catch (IOException ex) {
ex.printStackTrace();
}
}
</code></pre>
| 0debug |
Setting and getting localStorage with jQuery : <p>I am trying out localStorage and attempting at getting text from a div and storing it in localStorage, however, it sets it as an [object Object] and returns [object Object]. Why is this happening?</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>localStorage.content = $('#test').html('Test');
$('#test').html(localStorage.content);</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="test"></div></code></pre>
</div>
</div>
</p>
| 0debug |
How to convert date to string date in php? : <p>I am trying to convert a date '2019-04-18' to something like this '18 Apr 2019' in php.</p>
<pre><code>$date=date_create("2019-04-18");
echo date_format($date,'jS F Y');
</code></pre>
<p>It is giving me output like this :</p>
<pre><code>18th April 2019
</code></pre>
<p>But i need output to be '18 Apr 2019' ie: 3 letters of month</p>
| 0debug |
Substract two textbox time values and display the result in a third textbox automatically : How would I check time difference from two text-boxes and show the result in third textbox in Javascript?
Two times are in 12 hours format.
![![enter image description here][1]
[1]: http://i.stack.imgur.com/ITcYx.png
| 0debug |
What's that mean each code : struct Physics {
static let smallCoin : UInt32 = 0x1 << 1
static let smallCoin2 : UInt32 = 0x1 << 2
static let ground : UInt32 = 0x1 << 3
}
What that mean
UInt32 = 0x1 << 1 ?
and static let ? | 0debug |
how to pass multiple classes as arguements : public IEnumerable<Project> Get(int id)
{
DataTable dt = new DataTable();
Project_BL projbl = new Project_BL();
dt = projbl.SelectprojectModelBasedProjectID(id);
var tag = dt.AsEnumerable().Select(x => new TAGS
{
tag_id = x.Field<int>("tag_id"),
tag_name = x.Field<string>("tag_name")
// like wise initialize properties here
});
return tag;
}
Here,in Ienumerable<Projects>,Projects is a class.I want another class to be added there. Also in var tag = dt.AsEnumerable().Select(x => new Projects,
here also i want to add multiple class | 0debug |
static void rtas_ibm_configure_connector(PowerPCCPU *cpu,
sPAPRMachineState *spapr,
uint32_t token, uint32_t nargs,
target_ulong args, uint32_t nret,
target_ulong rets)
{
uint64_t wa_addr;
uint64_t wa_offset;
uint32_t drc_index;
sPAPRDRConnector *drc;
sPAPRDRConnectorClass *drck;
sPAPRConfigureConnectorState *ccs;
sPAPRDRCCResponse resp = SPAPR_DR_CC_RESPONSE_CONTINUE;
int rc;
if (nargs != 2 || nret != 1) {
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
return;
}
wa_addr = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 0);
drc_index = rtas_ld(wa_addr, 0);
drc = spapr_drc_by_index(drc_index);
if (!drc) {
trace_spapr_rtas_ibm_configure_connector_invalid(drc_index);
rc = RTAS_OUT_PARAM_ERROR;
goto out;
}
if ((drc->state != SPAPR_DRC_STATE_LOGICAL_UNISOLATE)
&& (drc->state != SPAPR_DRC_STATE_PHYSICAL_UNISOLATE)) {
rc = SPAPR_DR_CC_RESPONSE_NOT_CONFIGURABLE;
goto out;
}
g_assert(drc->fdt);
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
ccs = drc->ccs;
if (!ccs) {
ccs = g_new0(sPAPRConfigureConnectorState, 1);
ccs->fdt_offset = drc->fdt_start_offset;
drc->ccs = ccs;
}
do {
uint32_t tag;
const char *name;
const struct fdt_property *prop;
int fdt_offset_next, prop_len;
tag = fdt_next_tag(drc->fdt, ccs->fdt_offset, &fdt_offset_next);
switch (tag) {
case FDT_BEGIN_NODE:
ccs->fdt_depth++;
name = fdt_get_name(drc->fdt, ccs->fdt_offset, NULL);
wa_offset = CC_VAL_DATA_OFFSET;
rtas_st(wa_addr, CC_IDX_NODE_NAME_OFFSET, wa_offset);
configure_connector_st(wa_addr, wa_offset, name, strlen(name) + 1);
resp = SPAPR_DR_CC_RESPONSE_NEXT_CHILD;
break;
case FDT_END_NODE:
ccs->fdt_depth--;
if (ccs->fdt_depth == 0) {
uint32_t drc_index = spapr_drc_index(drc);
trace_spapr_drc_set_configured(drc_index);
drc->state = drck->ready_state;
g_free(ccs);
drc->ccs = NULL;
ccs = NULL;
resp = SPAPR_DR_CC_RESPONSE_SUCCESS;
} else {
resp = SPAPR_DR_CC_RESPONSE_PREV_PARENT;
}
break;
case FDT_PROP:
prop = fdt_get_property_by_offset(drc->fdt, ccs->fdt_offset,
&prop_len);
name = fdt_string(drc->fdt, fdt32_to_cpu(prop->nameoff));
wa_offset = CC_VAL_DATA_OFFSET;
rtas_st(wa_addr, CC_IDX_PROP_NAME_OFFSET, wa_offset);
configure_connector_st(wa_addr, wa_offset, name, strlen(name) + 1);
wa_offset += strlen(name) + 1,
rtas_st(wa_addr, CC_IDX_PROP_LEN, prop_len);
rtas_st(wa_addr, CC_IDX_PROP_DATA_OFFSET, wa_offset);
configure_connector_st(wa_addr, wa_offset, prop->data, prop_len);
resp = SPAPR_DR_CC_RESPONSE_NEXT_PROPERTY;
break;
case FDT_END:
resp = SPAPR_DR_CC_RESPONSE_ERROR;
default:
break;
}
if (ccs) {
ccs->fdt_offset = fdt_offset_next;
}
} while (resp == SPAPR_DR_CC_RESPONSE_CONTINUE);
rc = resp;
out:
rtas_st(rets, 0, rc);
}
| 1threat |
Swagger: map of <string, Object> : <p>I need to document with Swagger an API that uses, both as input and output, maps of objects, indexed by string keys.</p>
<p>Example:</p>
<pre><code>{
"a_property": {
"foo": {
"property_1": "a string 1",
"property_2": "a string 2"
},
"bar": {
"property_1": "a string 3",
"property_2": "a string 4"
}
}
}
</code></pre>
<p>"foo" and "bar" can be any string keys, but they should be unique among the set of keys.</p>
<p>I know that, with Swagger, I can define an array of objects, but this gives a different API since we then would have something as:</p>
<pre><code>{
"a_property": [
{
"key": "foo"
"property_1": "a string 1",
"property_2": "a string 2"
},
{
"key": "bar"
"property_1": "a string 3",
"property_2": "a string 4"
}
]
}
</code></pre>
<p>I have read the <a href="https://github.com/OAI/OpenAPI-Specification/issues/38" rel="noreferrer">'Open API Specification' - 'Add support for Map data types #38'</a> page. As far as I understand, it recommends to use <strong>additionalProperties, but it doesn't seem to answer my need</strong> (or it doesn't work with Swagger UI 2.1.4 that I use). <strong>Did I miss something?</strong></p>
<p>So far I have found the following work-around (in Swagger JSON):</p>
<pre><code>a_property: {
description: "This is a map that can contain several objects indexed by different keys.",
type: object,
properties: {
key: {
description: "map item",
type: "object",
properties: {
property_1: {
description: "first property",
type: string
},
property_2: {
description: "second property",
type: string
}
}
}
}
}
</code></pre>
<p>This almost does the job, but the reader has to understand that "key" can be any string, and can be repeated several times.</p>
<p><strong>Is there a better way to achieve what I need?</strong></p>
| 0debug |
How to make the map focus on one area? : <p>I am writing an app about Map. I need to add a button that the map go back to the original location after the user click that button. How to make the map focus on one area when the user pressed that button?</p>
| 0debug |
static void do_wav_capture(Monitor *mon, const QDict *qdict)
{
const char *path = qdict_get_str(qdict, "path");
int has_freq = qdict_haskey(qdict, "freq");
int freq = qdict_get_try_int(qdict, "freq", -1);
int has_bits = qdict_haskey(qdict, "bits");
int bits = qdict_get_try_int(qdict, "bits", -1);
int has_channels = qdict_haskey(qdict, "nchannels");
int nchannels = qdict_get_try_int(qdict, "nchannels", -1);
CaptureState *s;
s = qemu_mallocz (sizeof (*s));
freq = has_freq ? freq : 44100;
bits = has_bits ? bits : 16;
nchannels = has_channels ? nchannels : 2;
if (wav_start_capture (s, path, freq, bits, nchannels)) {
monitor_printf(mon, "Faied to add wave capture\n");
qemu_free (s);
}
LIST_INSERT_HEAD (&capture_head, s, entries);
}
| 1threat |
When does create-react-app obfuscate or minify code? : <p>I have kind of a basic question about webpack and react that I can use help with (around code obfuscation/uglification). </p>
<p>I am using <code>create-react-app</code> for my application and it appears to create a bundled build for production (after running <code>yarn build</code>). </p>
<p>And in that file it seems that everything is put into a main.JS file and main.CSS file Etc. I push this live using "firebase deploy" (in my case). I would like my code to be uglified and not be completely readable by any developer out there. </p>
<p>But when I go to look at my apps in Chrome it doesn't show main.JS or any other of the bundles files. It just shows every single individual file and exactly the code that I've written. Any idea why this is? Why doesn't it show the uglified combined main.js file under the 'sources' tab in chrome? Is this to do with the source map?</p>
| 0debug |
Unsubscribe doesn't working : I'm fetching the data from json file in services and subscribing it from my component. I'm doing some condition check with the data, once it matches I want to stop subscribing but it's not working, still its subscribing.
**Service**
getUserData() {
const url = './assets/json/userslist.json';
return this.http.get(url);
}
**Component**
const subscription = this.getuser.getUserData().subscribe(data => {
Object.values(data).forEach((userdetail) => {
// tslint:disable-next-line:max-line-length
if (userdetail.username.indexOf(form.value.email) !== -1 && userdetail.password == form.value.password) {
console.log('asd');
if (userdetail.active == true) {
console.log('asasdfasd');
this.EventEmitterObj.emit(form.value.email);
this.router.navigateByUrl('/home');
} else if (userdetail.active == false) {
console.log('asd23423432');
this.deactivateAlert = 'The account is deactivated';
}
subscription.unsubscribe();
console.log('issue');
} else {
console.log('12341243');
this.deactivateAlert = 'Incorrect Username/Password';
}
});
}); | 0debug |
Is there a vector class or struct (with 3 components) in C#? : <p>Is there a good available vector class or struct (for vectors defined in physics with 3 components) in C#? It is like <code>c++</code>'s <code>std::array<double, 3></code> and better with inner product, cross product and other arithmetic operations.</p>
| 0debug |
Can Spring JPA projections have Collections? : <p>I have a Customer entity from which I only want to select a few fields and their associated CustomerAddresses. I've defined a Spring Data JPA projection interface as follows:</p>
<pre><code>public interface CustomerWithAddresses {
Integer getId();
String getFirstName();
String getLastName();
String getBrandCode();
String getCustomerNumber();
Set<CustomerAddress> getCustomerAddresses();
}
</code></pre>
<p>But from my Repository method:</p>
<pre><code>CustomerWithAddresses findCustomerWithAddressesById(@Param("id") Integer id);
</code></pre>
<p>I keep getting NonUniqueResultException for Customers with multiple CustomerAddresses. Do projections have to have a flat structure, i.e. they don't support Collections the same way true Entities do?</p>
| 0debug |
How to avoid cumbersome if/else constructs? [Something more like an architecture approach, not just switch statement] : <p>I faced a task when I need to process a bunch of conditions and perform an action in the result. Are there any libraries or approaches that can help me building a structure like this? With replaceable/amendable conditions and results?</p>
| 0debug |
static int vp9_superframe_filter(AVBSFContext *ctx, AVPacket *out)
{
BitstreamContext bc;
VP9BSFContext *s = ctx->priv_data;
AVPacket *in;
int res, invisible, profile, marker, uses_superframe_syntax = 0, n;
res = ff_bsf_get_packet(ctx, &in);
if (res < 0)
return res;
marker = in->data[in->size - 1];
if ((marker & 0xe0) == 0xc0) {
int nbytes = 1 + ((marker >> 3) & 0x3);
int n_frames = 1 + (marker & 0x7), idx_sz = 2 + n_frames * nbytes;
uses_superframe_syntax = in->size >= idx_sz && in->data[in->size - idx_sz] == marker;
}
res = bitstream_init8(&bc, in->data, in->size);
if (res < 0)
goto done;
bitstream_read(&bc, 2);
profile = bitstream_read(&bc, 1);
profile |= bitstream_read(&bc, 1) << 1;
if (profile == 3)
profile += bitstream_read(&bc, 1);
if (bitstream_read(&bc, 1)) {
invisible = 0;
} else {
bitstream_read(&bc, 1);
invisible = !bitstream_read(&bc, 1);
}
if (uses_superframe_syntax && s->n_cache > 0) {
av_log(ctx, AV_LOG_ERROR,
"Mixing of superframe syntax and naked VP9 frames not supported");
res = AVERROR(ENOSYS);
goto done;
} else if ((!invisible || uses_superframe_syntax) && !s->n_cache) {
av_packet_move_ref(out, in);
goto done;
} else if (s->n_cache + 1 >= MAX_CACHE) {
av_log(ctx, AV_LOG_ERROR,
"Too many invisible frames");
res = AVERROR_INVALIDDATA;
goto done;
}
s->cache[s->n_cache++] = in;
in = NULL;
if (invisible) {
res = AVERROR(EAGAIN);
goto done;
}
av_assert0(s->n_cache > 0);
if ((res = merge_superframe(s->cache, s->n_cache, out)) < 0)
goto done;
res = av_packet_copy_props(out, s->cache[s->n_cache - 1]);
if (res < 0)
goto done;
for (n = 0; n < s->n_cache; n++)
av_packet_free(&s->cache[n]);
s->n_cache = 0;
done:
if (res < 0)
av_packet_unref(out);
av_packet_free(&in);
return res;
}
| 1threat |
Turning on Bluetooth programatically Swift : I am trying to turn on bluetooth automatically using my app. The usual way would be for user to go to settings and turn on. But i need to to be turned on from the app. And i have went through lots of documentations and they are referring to private APIs but all are very old.I do not mind that it's not going to be approved at App Store. Is there anything online which uses Swift? | 0debug |
Android: EditText widget auto-size : Is a there a method in XML by which I can autoset the size of a widget (as 'EditText') automatically?
I'm asking this because, setting fixed values for width and height, I'm afraid not to respect the screen size of any device in which my app will live.
For example:
I need to set a width that will take a margin of 15dp from left edge, regardless from the device (so the screen size) used.
Someone can help me? | 0debug |
How to call a onclick print funtion and forget it : I wrote a print function and it opening a new tab window for print and then that print button keep active untill I don't close that window by cancel or print. During that I am unable to call my other javascript function on parent page. So my question is , is it possible to open a print window and that print button become inactive again, and windows keep open to print? below is my funtion.
function g_print_div(in_div_id)
{
div_id = in_div_id || 'idprint';
var divElements = document.getElementById(div_id).innerHTML;
var oldPage = document.body.innerHTML;
var printWindow = window.open();
printWindow.document.write('<html>');
printWindow.document.write("<link rel='stylesheet' type='text/css' href='/static/css/print.css') %]' />");
printWindow.document.write('<body >');
printWindow.document.write(divElements);
printWindow.document.write('</body></html>')
printWindow.print();
printWindow.document.close();
printWindow.close();
}
calling with onclick='g_print_div();' funtion, If there is any other method to accomplish this, then let me know.
Thanks | 0debug |
How to overload [] for const object, so that the value assignment would not result in a compilation error : <p>I need to overload [] operator for non-const and const objects. For non-const objects, it should be possible to read and assign values. For const objects, it should be possible to read values, but value assignment should not affect the element. At the same time, the code should be compilable. </p>
<p>The declarations, that I created:</p>
<pre><code>int &operator[](int element_index);
const int &operator[](int element_index) const;
</code></pre>
<p>The problem with this kind of declarations is, that the following code:</p>
<pre><code>const MyObject some_object();
some_object[1] = 100;
</code></pre>
<p>results in a compilation error: "assignment of read-only location" (some_object[1] exists and can be read). The desired behavior is that there would be no compilation error. I tried to find a way to return a copy of an element, but unfortunately, I didn’t find a combination that would work.</p>
| 0debug |
static void decode_plane_bitstream(HYuvContext *s, int count, int plane)
{
int i;
count /= 2;
if (s->bps <= 8) {
OPEN_READER(re, &s->gb);
if (count >= (get_bits_left(&s->gb)) / (32 * 2)) {
for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) {
READ_2PIX_PLANE(s->temp[0][2 * i], s->temp[0][2 * i + 1], plane, OP8bits);
}
} else {
for(i=0; i<count; i++){
READ_2PIX_PLANE(s->temp[0][2 * i], s->temp[0][2 * i + 1], plane, OP8bits);
}
}
CLOSE_READER(re, &s->gb);
} else if (s->bps <= 14) {
OPEN_READER(re, &s->gb);
if (count >= (get_bits_left(&s->gb)) / (32 * 2)) {
for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) {
READ_2PIX_PLANE(s->temp16[0][2 * i], s->temp16[0][2 * i + 1], plane, OP14bits);
}
} else {
for(i=0; i<count; i++){
READ_2PIX_PLANE(s->temp16[0][2 * i], s->temp16[0][2 * i + 1], plane, OP14bits);
}
}
CLOSE_READER(re, &s->gb);
} else {
if (count >= (get_bits_left(&s->gb)) / (32 * 2)) {
for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) {
READ_2PIX_PLANE16(s->temp16[0][2 * i], s->temp16[0][2 * i + 1], plane);
}
} else {
for(i=0; i<count; i++){
READ_2PIX_PLANE16(s->temp16[0][2 * i], s->temp16[0][2 * i + 1], plane);
}
}
}
}
| 1threat |
static int add_doubles_metadata(const uint8_t **buf, int count,
const char *name, const char *sep,
TiffContext *s)
{
char *ap;
int i;
double *dp = av_malloc(count * sizeof(double));
if (!dp)
return AVERROR(ENOMEM);
for (i = 0; i < count; i++)
dp[i] = tget_double(buf, s->le);
ap = doubles2str(dp, count, sep);
av_freep(&dp);
if (!ap)
return AVERROR(ENOMEM);
av_dict_set(&s->picture.metadata, name, ap, AV_DICT_DONT_STRDUP_VAL);
return 0;
}
| 1threat |
What is the best way to add strings to a textview in a for loop. I am using textview.settext and it overwrites the previous string : What is the best way to add strings to a textview in a for loop? I am using the method "setText and it's overwriting the previous string rather than adding to.
Here is my code below:
List<PlaceLikelihood> placeLikelihoodList = placesResult.getPlaceLikelihoods();
int hospitalType = Place.TYPE_HOSPITAL;
if (placeLikelihoodList != null) {
for (int i = 0; i <placeLikelihoodList.size(); i++){
PlaceLikelihood p = placeLikelihoodList.get(i);
List<Integer> types = p.getPlace().getPlaceTypes();}
if (types.get(0).equals(hospitalType)) {
groceryStoreTextView.setText(p.getPlace().getName().toString());
}
}
}
| 0debug |
static int read_header(AVFormatContext *s)
{
BRSTMDemuxContext *b = s->priv_data;
int bom, major, minor, codec, chunk;
int64_t h1offset, pos, toffset;
uint32_t size, asize, start = 0;
AVStream *st;
int ret = AVERROR_EOF;
int loop = 0;
int bfstm = !strcmp("bfstm", s->iformat->name);
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
avio_skip(s->pb, 4);
bom = avio_rb16(s->pb);
if (bom != 0xFEFF && bom != 0xFFFE) {
av_log(s, AV_LOG_ERROR, "invalid byte order: %X\n", bom);
return AVERROR_INVALIDDATA;
}
if (bom == 0xFFFE)
b->little_endian = 1;
if (!bfstm) {
major = avio_r8(s->pb);
minor = avio_r8(s->pb);
avio_skip(s->pb, 4);
size = read16(s);
if (size < 14)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, size - 14);
pos = avio_tell(s->pb);
if (avio_rl32(s->pb) != MKTAG('H','E','A','D'))
return AVERROR_INVALIDDATA;
} else {
uint32_t info_offset = 0;
uint16_t section_count, header_size, i;
header_size = read16(s);
avio_skip(s->pb, 4);
avio_skip(s->pb, 4);
section_count = read16(s);
avio_skip(s->pb, 2);
for (i = 0; avio_tell(s->pb) < header_size
&& !(start && info_offset)
&& i < section_count; i++) {
uint16_t flag = read16(s);
avio_skip(s->pb, 2);
switch (flag) {
case 0x4000:
info_offset = read32(s);
read32(s);
break;
case 0x4001:
avio_skip(s->pb, 4);
avio_skip(s->pb, 4);
break;
case 0x4002:
start = read32(s) + 8;
avio_skip(s->pb, 4);
break;
case 0x4003:
avio_skip(s->pb, 4);
avio_skip(s->pb, 4);
break;
}
}
if (!info_offset || !start)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, info_offset - avio_tell(s->pb));
pos = avio_tell(s->pb);
if (avio_rl32(s->pb) != MKTAG('I','N','F','O'))
return AVERROR_INVALIDDATA;
}
size = read32(s);
if (size < 192)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 4);
h1offset = read32(s);
if (h1offset > size)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 12);
toffset = read32(s) + 16LL;
if (toffset > size)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, pos + h1offset + 8 - avio_tell(s->pb));
codec = avio_r8(s->pb);
switch (codec) {
case 0: codec = AV_CODEC_ID_PCM_S8_PLANAR; break;
case 1: codec = b->little_endian ?
AV_CODEC_ID_PCM_S16LE_PLANAR :
AV_CODEC_ID_PCM_S16BE_PLANAR; break;
case 2: codec = b->little_endian ?
AV_CODEC_ID_ADPCM_THP_LE :
AV_CODEC_ID_ADPCM_THP; break;
default:
avpriv_request_sample(s, "codec %d", codec);
return AVERROR_PATCHWELCOME;
}
loop = avio_r8(s->pb);
st->codec->codec_id = codec;
st->codec->channels = avio_r8(s->pb);
if (!st->codec->channels)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 1);
st->codec->sample_rate = bfstm ? read32(s) : read16(s);
if (!st->codec->sample_rate)
return AVERROR_INVALIDDATA;
if (!bfstm)
avio_skip(s->pb, 2);
if (loop) {
if (av_dict_set_int(&s->metadata, "loop_start",
av_rescale(read32(s), AV_TIME_BASE,
st->codec->sample_rate),
0) < 0)
return AVERROR(ENOMEM);
} else {
avio_skip(s->pb, 4);
}
st->start_time = 0;
st->duration = read32(s);
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
if (!bfstm)
start = read32(s);
b->current_block = 0;
b->block_count = read32(s);
if (b->block_count > UINT16_MAX) {
av_log(s, AV_LOG_WARNING, "too many blocks: %u\n", b->block_count);
return AVERROR_INVALIDDATA;
}
b->block_size = read32(s);
if (b->block_size > UINT32_MAX / st->codec->channels)
return AVERROR_INVALIDDATA;
b->samples_per_block = read32(s);
b->last_block_used_bytes = read32(s);
b->last_block_samples = read32(s);
b->last_block_size = read32(s);
if (b->last_block_size > UINT32_MAX / st->codec->channels)
return AVERROR_INVALIDDATA;
if (b->last_block_used_bytes > b->last_block_size)
return AVERROR_INVALIDDATA;
if (codec == AV_CODEC_ID_ADPCM_THP || codec == AV_CODEC_ID_ADPCM_THP_LE) {
int ch;
avio_skip(s->pb, pos + toffset - avio_tell(s->pb));
if (!bfstm)
toffset = read32(s) + 16LL;
else
toffset = toffset + read32(s) + st->codec->channels * 8 - 8;
if (toffset > size)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, pos + toffset - avio_tell(s->pb));
b->table = av_mallocz(32 * st->codec->channels);
if (!b->table)
return AVERROR(ENOMEM);
for (ch = 0; ch < st->codec->channels; ch++) {
if (avio_read(s->pb, b->table + ch * 32, 32) != 32) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
avio_skip(s->pb, bfstm ? 14 : 24);
}
}
if (size < (avio_tell(s->pb) - pos)) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
avio_skip(s->pb, size - (avio_tell(s->pb) - pos));
while (!avio_feof(s->pb)) {
chunk = avio_rl32(s->pb);
size = read32(s);
if (size < 8) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
size -= 8;
switch (chunk) {
case MKTAG('S','E','E','K'):
case MKTAG('A','D','P','C'):
if (codec != AV_CODEC_ID_ADPCM_THP &&
codec != AV_CODEC_ID_ADPCM_THP_LE)
goto skip;
asize = b->block_count * st->codec->channels * 4;
if (size < asize) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
if (b->adpc) {
av_log(s, AV_LOG_WARNING, "skipping additional ADPC chunk\n");
goto skip;
} else {
b->adpc = av_mallocz(asize);
if (!b->adpc) {
ret = AVERROR(ENOMEM);
goto fail;
}
if (bfstm && codec != AV_CODEC_ID_ADPCM_THP_LE) {
int i;
for (i = 0; i < asize; i += 2) {
b->adpc[i+1] = avio_r8(s->pb);
b->adpc[i] = avio_r8(s->pb);
}
} else {
avio_read(s->pb, b->adpc, asize);
}
avio_skip(s->pb, size - asize);
}
break;
case MKTAG('D','A','T','A'):
if ((start < avio_tell(s->pb)) ||
(!b->adpc && (codec == AV_CODEC_ID_ADPCM_THP ||
codec == AV_CODEC_ID_ADPCM_THP_LE))) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
avio_skip(s->pb, start - avio_tell(s->pb));
if (bfstm && (codec == AV_CODEC_ID_ADPCM_THP ||
codec == AV_CODEC_ID_ADPCM_THP_LE))
avio_skip(s->pb, 24);
b->data_start = avio_tell(s->pb);
if (!bfstm && (major != 1 || minor))
avpriv_request_sample(s, "Version %d.%d", major, minor);
return 0;
default:
av_log(s, AV_LOG_WARNING, "skipping unknown chunk: %X\n", chunk);
skip:
avio_skip(s->pb, size);
}
}
fail:
read_close(s);
return ret;
}
| 1threat |
Generate CRT & KEY ssl files from Let's Encrypt from scratch : <p>I'd like to generate a CRT/KEY couple SSL files with Let's Encrypt (with manual challenge).</p>
<p>I'm trying something like this :</p>
<pre><code>certbot certonly --manual -d mydomain.com
</code></pre>
<p>But I only get these files in my <code>/etc/letsencrypt/live/mydomain.com folder</code> :</p>
<ul>
<li>cert.pem</li>
<li>chain.pem</li>
<li>fullchain.pem</li>
<li>privkey.pem</li>
</ul>
<p>Did I missed something?</p>
| 0debug |
static int read_matrix_params(MLPDecodeContext *m, SubStream *s, GetBitContext *gbp)
{
unsigned int mat, ch;
s->num_primitive_matrices = get_bits(gbp, 4);
m->matrix_changed++;
for (mat = 0; mat < s->num_primitive_matrices; mat++) {
int frac_bits, max_chan;
s->matrix_out_ch[mat] = get_bits(gbp, 4);
frac_bits = get_bits(gbp, 4);
s->lsb_bypass [mat] = get_bits1(gbp);
if (s->matrix_out_ch[mat] > s->max_matrix_channel) {
av_log(m->avctx, AV_LOG_ERROR,
"Invalid channel %d specified as output from matrix.\n",
s->matrix_out_ch[mat]);
return -1;
}
if (frac_bits > 14) {
av_log(m->avctx, AV_LOG_ERROR,
"Too many fractional bits specified.\n");
return -1;
}
max_chan = s->max_matrix_channel;
if (!s->noise_type)
max_chan+=2;
for (ch = 0; ch <= max_chan; ch++) {
int coeff_val = 0;
if (get_bits1(gbp))
coeff_val = get_sbits(gbp, frac_bits + 2);
s->matrix_coeff[mat][ch] = coeff_val << (14 - frac_bits);
}
if (s->noise_type)
s->matrix_noise_shift[mat] = get_bits(gbp, 4);
else
s->matrix_noise_shift[mat] = 0;
}
return 0;
}
| 1threat |
addEventListener inside constructor es6 class get fired ones on init and never agian : <p>I'm new to es6 classes and cant quite understand why the following behaves like it does:</p>
<pre><code> let scrollElement = document.querySelector(".foo");
scrollElement.addEventListener("scroll", logSomething());
logSomething(){
console.log("hi");
}
</code></pre>
<p>Will output "hi" in my console every time I scroll. This is what I want. Now I try to do the same thing but with a designated class to group all the scroll behaviour:</p>
<pre><code> class scrollHelper{
constructor(scrollElement){
scrollElement.addEventListener("scroll", this.logSomething());
}
logSomething(){
console.log("hi");
}
}
let scrollElement = document.querySelector(".foo");
new scrollHelper(scrollElement)
</code></pre>
<p>But instead of logging hi every time I scroll it logs "hi" ones when the class instance is created and never after that.</p>
<p>Could someone tell me why this happens and what I'm doing wrong to get the same result as the first example.</p>
<p>Kinds regards,
Merijn</p>
| 0debug |
how can I make make numerology in python? : I'm trying to make just a simple numerology in pyhton but I cant find a way without creating a variable for any letter like `a=1 b=2 c=3 d=4...`
Please help me. Thanks. | 0debug |
Why does this compile? (unsigned char *thing = (unsigned char *) "YELLOW SUBMARINE";) : <p>I'm struggling to understand why this line of code makes sense:</p>
<pre class="lang-cpp prettyprint-override"><code>unsigned char *thing = (unsigned char *)"YELLOW SUBMARINE";
</code></pre>
<p>An <code>unsigned char</code> holds one byte of data (i.e. 'Y') so an <code>unsigned char*</code> should be a pointer to that single byte of data. </p>
<p>If I try to put more than one character inside, the compiler should, in my thinking, get angry. Yet it doesn't mind that I'm putting 16 bytes here and telling the compiler I'm only pointing to a single <code>unsigned char</code>. Could someone please explain?</p>
<p>My thinking was that the compiler would allocate memory for one <code>unsigned char</code>, then write the whole string into it, overwriting adjacent memory and causing havoc. Yet I'm able to correctly dereference this pointer later on and retrieve the whole string, so there doesn't seem to be a problem.</p>
<p>Context: I'm trying to convert a string to something of this form (<code>unsigned char *</code>).</p>
<p>Thanks in advance!</p>
| 0debug |
static void spapr_machine_2_6_class_options(MachineClass *mc)
{
sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
spapr_machine_2_7_class_options(mc);
smc->dr_cpu_enabled = false;
SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_6);
}
| 1threat |
static void s390_virtio_blk_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass);
k->init = s390_virtio_blk_init;
dc->props = s390_virtio_blk_properties;
}
| 1threat |
How to restrict runners to a specific branch and lock the .gitlab-ci.yml from changes? : <p>Right now, anyone that creates a branch in my project and adds a .gitlab-ci.yml file to it, can execute commands on my server using the runner. How can I make it so that only masters or owners can upload CI config files and make changes to them?</p>
<p>I'm using <a href="https://gitlab.com/gitlab-org/gitlab-ci-multi-runner" rel="noreferrer">https://gitlab.com/gitlab-org/gitlab-ci-multi-runner</a> running on bash.</p>
| 0debug |
from sys import maxsize
def max_sub_array_sum(a,size):
max_so_far = -maxsize - 1
max_ending_here = 0
start = 0
end = 0
s = 0
for i in range(0,size):
max_ending_here += a[i]
if max_so_far < max_ending_here:
max_so_far = max_ending_here
start = s
end = i
if max_ending_here < 0:
max_ending_here = 0
s = i+1
return (end - start + 1) | 0debug |
static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
{
X86CPUClass *xcc = X86_CPU_CLASS(oc);
CPUClass *cc = CPU_CLASS(oc);
DeviceClass *dc = DEVICE_CLASS(oc);
xcc->parent_realize = dc->realize;
dc->realize = x86_cpu_realizefn;
dc->props = x86_cpu_properties;
xcc->parent_reset = cc->reset;
cc->reset = x86_cpu_reset;
cc->reset_dump_flags = CPU_DUMP_FPU | CPU_DUMP_CCOP;
cc->class_by_name = x86_cpu_class_by_name;
cc->parse_features = x86_cpu_parse_featurestr;
cc->has_work = x86_cpu_has_work;
cc->do_interrupt = x86_cpu_do_interrupt;
cc->cpu_exec_interrupt = x86_cpu_exec_interrupt;
cc->dump_state = x86_cpu_dump_state;
cc->set_pc = x86_cpu_set_pc;
cc->synchronize_from_tb = x86_cpu_synchronize_from_tb;
cc->gdb_read_register = x86_cpu_gdb_read_register;
cc->gdb_write_register = x86_cpu_gdb_write_register;
cc->get_arch_id = x86_cpu_get_arch_id;
cc->get_paging_enabled = x86_cpu_get_paging_enabled;
#ifdef CONFIG_USER_ONLY
cc->handle_mmu_fault = x86_cpu_handle_mmu_fault;
#else
cc->get_memory_mapping = x86_cpu_get_memory_mapping;
cc->get_phys_page_debug = x86_cpu_get_phys_page_debug;
cc->write_elf64_note = x86_cpu_write_elf64_note;
cc->write_elf64_qemunote = x86_cpu_write_elf64_qemunote;
cc->write_elf32_note = x86_cpu_write_elf32_note;
cc->write_elf32_qemunote = x86_cpu_write_elf32_qemunote;
cc->vmsd = &vmstate_x86_cpu;
#endif
cc->gdb_num_core_regs = CPU_NB_REGS * 2 + 25;
#ifndef CONFIG_USER_ONLY
cc->debug_excp_handler = breakpoint_handler;
#endif
cc->cpu_exec_enter = x86_cpu_exec_enter;
cc->cpu_exec_exit = x86_cpu_exec_exit;
} | 1threat |
JavaScript regex: add strings (preceding & following) to the matched string : <p>Say I have the following string in JavaScript:</p>
<pre><code>var text = "This is Table1, and the next table is Table2"
</code></pre>
<p>I need to highlight the <code>Table1</code> and <code>Table2</code> bold in HTML by adding <code><b></b></code>, e.g. <code><b>Table1</b></code>. Making it even more difficult is the word preceding/following <code>Table1 or 2</code> varies.</p>
<pre><code>text.replace(/Table\d+/g, "<b>Table</b>"); // how to reserve the number for Table1 or Table2 here?
</code></pre>
<p>Thanks</p>
| 0debug |
Database Sql select statement : [provided the database below how do i solve this question?][1]
[my sql statement is: select ename from employee e inner join certified c on e.eid = c.eid inner join aircraft a on c.aid = a.aid where cruisingrange> 1000 && a.aname not like'%b'][2]
My answer is Jacob and Emily which is wrong. Jacob should not be retrieved. How should i modify or add to the sql statement?
[1]: http://i.stack.imgur.com/Ohghh.jpg
[2]: http://i.stack.imgur.com/Go4f6.jpg | 0debug |
How to add custom git command to zsh completion? : <p>I've read a few guides on zsh completion, but I am still confused. In our development environment we have a custom Git command called <code>git new-branch</code>. I'd like zsh to auto-complete it for me after typing just <code>git ne</code> and a <kbd>Tab</kbd>. How can I do that?</p>
| 0debug |
Docker Compose + Spring Boot + Postgres connection : <p>I have a Java Spring Boot app which works with a Postgres database. I want to use Docker for both of them. I initially put just the Postgres in Docker, and I had a <code>docker-compose.yml</code> file defined like this:</p>
<pre><code>version: '2'
services:
db:
container_name: sample_db
image: postgres:9.5
volumes:
- sample_db:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=sample
- POSTGRES_USER=sample
- POSTGRES_DB=sample
- PGDATA=/var/lib/postgresql/data/pgdata
ports:
- 5432:5432
volumes:
sample_db: {}
</code></pre>
<p>Then, when I issued the commands <code>sudo dockerd</code> and <code>sudo docker-compose -f docker-compose.yml up</code>, it was starting the database. I could connect using <code>pgAdmin</code> for example, by using <code>localhost</code> as server and port <code>5432</code>. Then, in my Spring Boot app, inside the <code>application.properties</code> file I defined the following properties.</p>
<pre><code>spring.datasource.url=jdbc:postgresql://localhost:5432/sample
spring.datasource.username=sample
spring.datasource.password=sample
spring.jpa.generate-ddl=true
</code></pre>
<p>At this point I could run my Spring Boot app locally through Spring Suite, and it all was working fine. Then, I wanted to also add my Spring Boot app as Docker image. I first of all created a Dockerfile in my project directory, which looks like this:</p>
<pre><code>FROM java:8
EXPOSE 8080
ADD /target/manager.jar manager.jar
ENTRYPOINT ["java","-jar","manager.jar"]
</code></pre>
<p>Then, I entered to the directory of the project issued <code>mvn clean</code> followed by <code>mvn install</code>. Next, issued <code>docker build -f Dockerfile -t manager .</code> followed by <code>docker tag 9c6b1e3f1d5e myuser/manager:latest</code> (the id is correct). Finally, I edited my existing <code>docker-compose.yml</code> file to look like this:</p>
<pre><code>version: '2'
services:
web:
image: myuser/manager:latest
ports:
- 8080:8080
depends_on:
- db
db:
container_name: sample_db
image: postgres:9.5
volumes:
- sample_db:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=sample
- POSTGRES_USER=sample
- POSTGRES_DB=sample
- PGDATA=/var/lib/postgresql/data/pgdata
ports:
- 5432:5432
volumes:
sample_db: {}
</code></pre>
<p>But, now if I issue <code>sudo docker-compose -f docker-compose.yml up</code> command, the database again starts correctly, but I get errors and exit code 1 for the web app part. The problem is the connection string. I believe I have to change it to something else, but I don't know what it should be. I get the following error messages:</p>
<pre><code>web_1 | 2017-06-27 22:11:54.418 ERROR 1 --- [ main] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.
web_1 |
web_1 | org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections
</code></pre>
<p>Any ideas?</p>
| 0debug |
static int alac_decode_frame(AVCodecContext *avctx,
void *outbuffer, int *outputsize,
AVPacket *avpkt)
{
const uint8_t *inbuffer = avpkt->data;
int input_buffer_size = avpkt->size;
ALACContext *alac = avctx->priv_data;
int channels;
unsigned int outputsamples;
int hassize;
unsigned int readsamplesize;
int isnotcompressed;
uint8_t interlacing_shift;
uint8_t interlacing_leftweight;
if (!inbuffer || !input_buffer_size)
return input_buffer_size;
if (!alac->context_initialized) {
if (alac->avctx->extradata_size != ALAC_EXTRADATA_SIZE) {
av_log(avctx, AV_LOG_ERROR, "alac: expected %d extradata bytes\n",
ALAC_EXTRADATA_SIZE);
return input_buffer_size;
}
if (alac_set_info(alac)) {
av_log(avctx, AV_LOG_ERROR, "alac: set_info failed\n");
return input_buffer_size;
}
alac->context_initialized = 1;
}
init_get_bits(&alac->gb, inbuffer, input_buffer_size * 8);
channels = get_bits(&alac->gb, 3) + 1;
if (channels > MAX_CHANNELS) {
av_log(avctx, AV_LOG_ERROR, "channels > %d not supported\n",
MAX_CHANNELS);
return input_buffer_size;
}
skip_bits(&alac->gb, 4);
skip_bits(&alac->gb, 12);
hassize = get_bits1(&alac->gb);
alac->wasted_bits = get_bits(&alac->gb, 2) << 3;
isnotcompressed = get_bits1(&alac->gb);
if (hassize) {
outputsamples = get_bits_long(&alac->gb, 32);
if(outputsamples > alac->setinfo_max_samples_per_frame){
av_log(avctx, AV_LOG_ERROR, "outputsamples %d > %d\n", outputsamples, alac->setinfo_max_samples_per_frame);
return -1;
}
} else
outputsamples = alac->setinfo_max_samples_per_frame;
switch (alac->setinfo_sample_size) {
case 16: avctx->sample_fmt = SAMPLE_FMT_S16;
alac->bytespersample = channels << 1;
break;
case 24: avctx->sample_fmt = SAMPLE_FMT_S32;
alac->bytespersample = channels << 2;
break;
default: av_log(avctx, AV_LOG_ERROR, "Sample depth %d is not supported.\n",
alac->setinfo_sample_size);
return -1;
}
if(outputsamples > *outputsize / alac->bytespersample){
av_log(avctx, AV_LOG_ERROR, "sample buffer too small\n");
return -1;
}
*outputsize = outputsamples * alac->bytespersample;
readsamplesize = alac->setinfo_sample_size - (alac->wasted_bits) + channels - 1;
if (readsamplesize > MIN_CACHE_BITS) {
av_log(avctx, AV_LOG_ERROR, "readsamplesize too big (%d)\n", readsamplesize);
return -1;
}
if (!isnotcompressed) {
int16_t predictor_coef_table[MAX_CHANNELS][32];
int predictor_coef_num[MAX_CHANNELS];
int prediction_type[MAX_CHANNELS];
int prediction_quantitization[MAX_CHANNELS];
int ricemodifier[MAX_CHANNELS];
int i, chan;
interlacing_shift = get_bits(&alac->gb, 8);
interlacing_leftweight = get_bits(&alac->gb, 8);
for (chan = 0; chan < channels; chan++) {
prediction_type[chan] = get_bits(&alac->gb, 4);
prediction_quantitization[chan] = get_bits(&alac->gb, 4);
ricemodifier[chan] = get_bits(&alac->gb, 3);
predictor_coef_num[chan] = get_bits(&alac->gb, 5);
for (i = 0; i < predictor_coef_num[chan]; i++)
predictor_coef_table[chan][i] = (int16_t)get_bits(&alac->gb, 16);
}
if (alac->wasted_bits) {
int i, ch;
for (i = 0; i < outputsamples; i++) {
for (ch = 0; ch < channels; ch++)
alac->wasted_bits_buffer[ch][i] = get_bits(&alac->gb, alac->wasted_bits);
}
}
for (chan = 0; chan < channels; chan++) {
bastardized_rice_decompress(alac,
alac->predicterror_buffer[chan],
outputsamples,
readsamplesize,
alac->setinfo_rice_initialhistory,
alac->setinfo_rice_kmodifier,
ricemodifier[chan] * alac->setinfo_rice_historymult / 4,
(1 << alac->setinfo_rice_kmodifier) - 1);
if (prediction_type[chan] == 0) {
predictor_decompress_fir_adapt(alac->predicterror_buffer[chan],
alac->outputsamples_buffer[chan],
outputsamples,
readsamplesize,
predictor_coef_table[chan],
predictor_coef_num[chan],
prediction_quantitization[chan]);
} else {
av_log(avctx, AV_LOG_ERROR, "FIXME: unhandled prediction type: %i\n", prediction_type[chan]);
}
}
} else {
int i, chan;
if (alac->setinfo_sample_size <= 16) {
for (i = 0; i < outputsamples; i++)
for (chan = 0; chan < channels; chan++) {
int32_t audiobits;
audiobits = get_sbits_long(&alac->gb, alac->setinfo_sample_size);
alac->outputsamples_buffer[chan][i] = audiobits;
}
} else {
for (i = 0; i < outputsamples; i++) {
for (chan = 0; chan < channels; chan++) {
alac->outputsamples_buffer[chan][i] = get_bits(&alac->gb,
alac->setinfo_sample_size);
alac->outputsamples_buffer[chan][i] = sign_extend(alac->outputsamples_buffer[chan][i],
alac->setinfo_sample_size);
}
}
}
alac->wasted_bits = 0;
interlacing_shift = 0;
interlacing_leftweight = 0;
}
if (get_bits(&alac->gb, 3) != 7)
av_log(avctx, AV_LOG_ERROR, "Error : Wrong End Of Frame\n");
switch(alac->setinfo_sample_size) {
case 16:
if (channels == 2) {
reconstruct_stereo_16(alac->outputsamples_buffer,
(int16_t*)outbuffer,
alac->numchannels,
outputsamples,
interlacing_shift,
interlacing_leftweight);
} else {
int i;
for (i = 0; i < outputsamples; i++) {
((int16_t*)outbuffer)[i] = alac->outputsamples_buffer[0][i];
}
}
break;
case 24:
if (channels == 2) {
decorrelate_stereo_24(alac->outputsamples_buffer,
outbuffer,
alac->wasted_bits_buffer,
alac->wasted_bits,
alac->numchannels,
outputsamples,
interlacing_shift,
interlacing_leftweight);
} else {
int i;
for (i = 0; i < outputsamples; i++)
((int32_t *)outbuffer)[i] = alac->outputsamples_buffer[0][i] << 8;
}
break;
}
if (input_buffer_size * 8 - get_bits_count(&alac->gb) > 8)
av_log(avctx, AV_LOG_ERROR, "Error : %d bits left\n", input_buffer_size * 8 - get_bits_count(&alac->gb));
return input_buffer_size;
}
| 1threat |
BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, int granularity,
Error **errp)
{
int64_t bitmap_size;
BdrvDirtyBitmap *bitmap;
assert((granularity & (granularity - 1)) == 0);
granularity >>= BDRV_SECTOR_BITS;
assert(granularity);
bitmap_size = bdrv_nb_sectors(bs);
if (bitmap_size < 0) {
error_setg_errno(errp, -bitmap_size, "could not get length of device");
errno = -bitmap_size;
return NULL;
}
bitmap = g_malloc0(sizeof(BdrvDirtyBitmap));
bitmap->bitmap = hbitmap_alloc(bitmap_size, ffs(granularity) - 1);
QLIST_INSERT_HEAD(&bs->dirty_bitmaps, bitmap, list);
return bitmap;
}
| 1threat |
Flutter navigation drawer hamburger icon color change : <p>Hamburger icon color of navigation drawer is not changing. Its black by default. I want to change the this icon color in flutter, I am stuck, help me to change this icon color. here is my code. </p>
<pre><code>class Test extends StatefulWidget {
@override
_TestState createState() => new _TestState();
}
class _TestState extends State<Test> {
@override
Widget build(BuildContext context) {
return new Scaffold(
drawer: new Drawer(),
appBar: new AppBar(
title: new Text("Navigation Drawer")
),
),
);
}
}
</code></pre>
| 0debug |
If is still returning bad array : <p>I am working on script, which have to remove temp. mail users, but if() is still activating array_push</p>
<p>I am using newest xampp on windows, php 7.
I have tryed this if() with smaller amount of <code>||something..</code> and changing</p>
<pre><code>if($emdomain == "google.com" || "gmail.com") {
array_push("google domain");
} else {
array_push("not google domain");
}
</code></pre>
<p>to</p>
<pre><code>if($emdomain != "google.com" || "gmail.com") {
array_push("not google domain");
} else {
array_push("google domain");
}
</code></pre>
<p>But not working..</p>
<pre><code>if($emdomain == "google.com" || "gmail.com") {
array_push("google domain");
} else {
array_push("not google domain");
}
</code></pre>
<p>I am getting "google domain" everytime, so i can use yahoo.com, alzashop.com, anything, and i get "google domain"
Idk why</p>
| 0debug |
void helper_mtc0_pagemask(CPUMIPSState *env, target_ulong arg1)
{
env->CP0_PageMask = arg1 & (0x1FFFFFFF & (TARGET_PAGE_MASK << 1));
}
| 1threat |
Can you redirect someone in javascript with less then 15 characters : <p>Can you redirect someone to a new page in javascript with less then 15 characters? </p>
| 0debug |
VB coding.. Seriously need help ,please and thanks : im doing a vb with access database.. and i wanted to create a button which savebutton with checking where the data that try to insert is duplicated or not compare with my database..so thismy code ,and the problem is whatever i enter it just show the user already exists .So anyone can help?? It's urgent
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MyConn = New OleDbConnection
MyConn.ConnectionString = connString
MyConn.Open()
If (ComboBox2.Text = "") And (ComboBox3.Text = "") And (TextBox3.Text = "") And (ComboBox4.Text = "") Then
MsgBox("Please fill-up all fields!")
Else
Dim theQuery As String = ("SELECT * FROM Table1 WHERE"" [Subject_Code]=@Subject_Code ,[Day]=@Day, [Times]=@Times , [Lecture]=@Lecture and [Class_Room]=@Class_Room""")
Dim cmd1 As OleDbCommand = New OleDbCommand(theQuery, MyConn)
cmd1.Parameters.AddWithValue("@Subject_Code", TextBox6.Text)
cmd1.Parameters.AddWithValue("@Day", ComboBox2.Text)
cmd1.Parameters.AddWithValue("@Times", ComboBox3.Text)
cmd1.Parameters.AddWithValue("@Lecture", TextBox3.Text)
cmd1.Parameters.AddWithValue("@Class_Room", ComboBox4.Text)
Using reader As OleDbDataReader = cmd1.ExecuteReader()
If reader.HasRows Then
' User already exists
MsgBox("User Already Exist!")
Else
Dim Update As String = "INSERT INTO [Table1] ([Subject_Code], [Subject],[Day], [Times], [Level],[Semester], [Lecture],[Class], [Class_Room])VALUES (?,?,?,?,?,?,?,?,?)"
Using cmd = New OleDbCommand(Update, MyConn)
cmd.Parameters.AddWithValue("@p1", TextBox6.Text)
cmd.Parameters.AddWithValue("@p2", TextBox1.Text)
cmd.Parameters.AddWithValue("@p3", ComboBox2.Text)
cmd.Parameters.AddWithValue("@p4", ComboBox3.Text)
cmd.Parameters.AddWithValue("@p5", ComboBox1.Text)
cmd.Parameters.AddWithValue("@p6", ComboBox6.Text)
cmd.Parameters.AddWithValue("@p7", TextBox3.Text)
cmd.Parameters.AddWithValue("@p8", ComboBox5.Text)
cmd.Parameters.AddWithValue("@p9", ComboBox4.Text)
MsgBox("New Data Is Saved")
cmd.ExecuteNonQuery()
End Using
End If
End Using
End If
| 0debug |
Command line dos prompt : How can i combine in my bat file
set FILESPATH1=C:\Temp\Test
set FILESPATH2=C:\Temp\Test\Bas
set FILESPATH3=C:\Temp\Test\Dennis
To one single line of code
Thanks | 0debug |
static void vc1_mc_1mv(VC1Context *v, int dir)
{
MpegEncContext *s = &v->s;
DSPContext *dsp = &v->s.dsp;
H264ChromaContext *h264chroma = &v->h264chroma;
uint8_t *srcY, *srcU, *srcV;
int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
int off, off_uv;
int v_edge_pos = s->v_edge_pos >> v->field_mode;
if ((!v->field_mode ||
(v->ref_field_type[dir] == 1 && v->cur_field_type == 1)) &&
!v->s.last_picture.f.data[0])
return;
mx = s->mv[dir][0][0];
my = s->mv[dir][0][1];
if (s->pict_type == AV_PICTURE_TYPE_P) {
s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0] = mx;
s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1] = my;
}
uvmx = (mx + ((mx & 3) == 3)) >> 1;
uvmy = (my + ((my & 3) == 3)) >> 1;
v->luma_mv[s->mb_x][0] = uvmx;
v->luma_mv[s->mb_x][1] = uvmy;
if (v->field_mode &&
v->cur_field_type != v->ref_field_type[dir]) {
my = my - 2 + 4 * v->cur_field_type;
uvmy = uvmy - 2 + 4 * v->cur_field_type;
}
if (v->fastuvmc && (v->fcm != ILACE_FRAME)) {
uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));
uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));
}
if (v->field_mode) {
if (!dir) {
if ((v->cur_field_type != v->ref_field_type[dir]) && v->second_field) {
srcY = s->current_picture.f.data[0];
srcU = s->current_picture.f.data[1];
srcV = s->current_picture.f.data[2];
} else {
srcY = s->last_picture.f.data[0];
srcU = s->last_picture.f.data[1];
srcV = s->last_picture.f.data[2];
}
} else {
srcY = s->next_picture.f.data[0];
srcU = s->next_picture.f.data[1];
srcV = s->next_picture.f.data[2];
}
} else {
if (!dir) {
srcY = s->last_picture.f.data[0];
srcU = s->last_picture.f.data[1];
srcV = s->last_picture.f.data[2];
} else {
srcY = s->next_picture.f.data[0];
srcU = s->next_picture.f.data[1];
srcV = s->next_picture.f.data[2];
}
}
if(!srcY)
return;
src_x = s->mb_x * 16 + (mx >> 2);
src_y = s->mb_y * 16 + (my >> 2);
uvsrc_x = s->mb_x * 8 + (uvmx >> 2);
uvsrc_y = s->mb_y * 8 + (uvmy >> 2);
if (v->profile != PROFILE_ADVANCED) {
src_x = av_clip( src_x, -16, s->mb_width * 16);
src_y = av_clip( src_y, -16, s->mb_height * 16);
uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8);
uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8);
} else {
src_x = av_clip( src_x, -17, s->avctx->coded_width);
src_y = av_clip( src_y, -18, s->avctx->coded_height + 1);
uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1);
uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
}
srcY += src_y * s->linesize + src_x;
srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
if (v->field_mode && v->ref_field_type[dir]) {
srcY += s->current_picture_ptr->f.linesize[0];
srcU += s->current_picture_ptr->f.linesize[1];
srcV += s->current_picture_ptr->f.linesize[2];
}
if (s->flags & CODEC_FLAG_GRAY) {
srcU = s->edge_emu_buffer + 18 * s->linesize;
srcV = s->edge_emu_buffer + 18 * s->linesize;
}
if (v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP)
|| s->h_edge_pos < 22 || v_edge_pos < 22
|| (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx&3) - 16 - s->mspel * 3
|| (unsigned)(src_y - 1) > v_edge_pos - (my&3) - 16 - 3) {
uint8_t *uvbuf = s->edge_emu_buffer + 19 * s->linesize;
srcY -= s->mspel * (1 + s->linesize);
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize,
17 + s->mspel * 2, 17 + s->mspel * 2,
src_x - s->mspel, src_y - s->mspel,
s->h_edge_pos, v_edge_pos);
srcY = s->edge_emu_buffer;
s->vdsp.emulated_edge_mc(uvbuf , srcU, s->uvlinesize, 8 + 1, 8 + 1,
uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, v_edge_pos >> 1);
s->vdsp.emulated_edge_mc(uvbuf + 16, srcV, s->uvlinesize, 8 + 1, 8 + 1,
uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, v_edge_pos >> 1);
srcU = uvbuf;
srcV = uvbuf + 16;
if (v->rangeredfrm) {
int i, j;
uint8_t *src, *src2;
src = srcY;
for (j = 0; j < 17 + s->mspel * 2; j++) {
for (i = 0; i < 17 + s->mspel * 2; i++)
src[i] = ((src[i] - 128) >> 1) + 128;
src += s->linesize;
}
src = srcU;
src2 = srcV;
for (j = 0; j < 9; j++) {
for (i = 0; i < 9; i++) {
src[i] = ((src[i] - 128) >> 1) + 128;
src2[i] = ((src2[i] - 128) >> 1) + 128;
}
src += s->uvlinesize;
src2 += s->uvlinesize;
}
}
if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {
int i, j;
uint8_t *src, *src2;
src = srcY;
for (j = 0; j < 17 + s->mspel * 2; j++) {
for (i = 0; i < 17 + s->mspel * 2; i++)
src[i] = v->luty[src[i]];
src += s->linesize;
}
src = srcU;
src2 = srcV;
for (j = 0; j < 9; j++) {
for (i = 0; i < 9; i++) {
src[i] = v->lutuv[src[i]];
src2[i] = v->lutuv[src2[i]];
}
src += s->uvlinesize;
src2 += s->uvlinesize;
}
}
srcY += s->mspel * (1 + s->linesize);
}
if (v->field_mode && v->second_field) {
off = s->current_picture_ptr->f.linesize[0];
off_uv = s->current_picture_ptr->f.linesize[1];
} else {
off = 0;
off_uv = 0;
}
if (s->mspel) {
dxy = ((my & 3) << 2) | (mx & 3);
v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off , srcY , s->linesize, v->rnd);
v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8, srcY + 8, s->linesize, v->rnd);
srcY += s->linesize * 8;
v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8 * s->linesize , srcY , s->linesize, v->rnd);
v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8 * s->linesize + 8, srcY + 8, s->linesize, v->rnd);
} else {
dxy = (my & 2) | ((mx & 2) >> 1);
if (!v->rnd)
dsp->put_pixels_tab[0][dxy](s->dest[0] + off, srcY, s->linesize, 16);
else
dsp->put_no_rnd_pixels_tab[0][dxy](s->dest[0] + off, srcY, s->linesize, 16);
}
if (s->flags & CODEC_FLAG_GRAY) return;
uvmx = (uvmx & 3) << 1;
uvmy = (uvmy & 3) << 1;
if (!v->rnd) {
h264chroma->put_h264_chroma_pixels_tab[0](s->dest[1] + off_uv, srcU, s->uvlinesize, 8, uvmx, uvmy);
h264chroma->put_h264_chroma_pixels_tab[0](s->dest[2] + off_uv, srcV, s->uvlinesize, 8, uvmx, uvmy);
} else {
v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1] + off_uv, srcU, s->uvlinesize, 8, uvmx, uvmy);
v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2] + off_uv, srcV, s->uvlinesize, 8, uvmx, uvmy);
}
}
| 1threat |
Vector how might looks in Java : <pre><code>vector<int> g[100001];
main() {
int n, m, v1, v2;
cin >> n >> m;
for(int i = 1; i <= m; i++) {
cin >> v1 >> v2;
g[v1].push_back(v2);
g[v2].push_back(v1);
}
}
</code></pre>
<p>Here is code in C++. <strong>I was wondering how can be implemented this part of using Collections in java</strong></p>
<pre><code> g[v1].push_back(v2);
g[v2].push_back(v1);
</code></pre>
| 0debug |
SQL commend to codeigniter : SELECT COUNT(*) FROM `job_progress` WHERE status='Runing'
**Help Me**: I know sql commend please help me for codeigniter commend. | 0debug |
Should Program class be static? : <p>I am getting the following Warning in Visual Studio 2019, after creating a new ASP.NET Core 3 project:</p>
<p>Warning CA1052
Type 'Program' is a static holder type but is neither static nor NotInheritable</p>
<pre class="lang-cs prettyprint-override"><code>public class Program
{
public static void Main(string[] args)
{
// ...
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
// ...
}
</code></pre>
<p>vs</p>
<pre class="lang-cs prettyprint-override"><code>public static class Program
{
public static void Main(string[] args)
{
// ...
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
// ...
}
</code></pre>
<p>Should I add the static modifier? Why / Why not? Pro's and Cons'?</p>
<p>Edit: This is a ASP.NET Core 3 <strong>API</strong></p>
| 0debug |
add hr whenever there's another value on array element : I have a array of object called elements, and the objects have two values (`name` and `category`).
I want to display all names but add an `<hr>` whenever reaches a new **category**
Please help and thank you of helping.
| 0debug |
static void vector_fmul_vfp(float *dst, const float *src, int len)
{
int tmp;
asm volatile(
"fmrx %[tmp], fpscr\n\t"
"orr %[tmp], %[tmp], #(3 << 16)\n\t"
"fmxr fpscr, %[tmp]\n\t"
"fldmias %[dst_r]!, {s0-s3}\n\t"
"fldmias %[src]!, {s8-s11}\n\t"
"fldmias %[dst_r]!, {s4-s7}\n\t"
"fldmias %[src]!, {s12-s15}\n\t"
"fmuls s8, s0, s8\n\t"
"1:\n\t"
"subs %[len], %[len], #16\n\t"
"fmuls s12, s4, s12\n\t"
"fldmiasge %[dst_r]!, {s16-s19}\n\t"
"fldmiasge %[src]!, {s24-s27}\n\t"
"fldmiasge %[dst_r]!, {s20-s23}\n\t"
"fldmiasge %[src]!, {s28-s31}\n\t"
"fmulsge s24, s16, s24\n\t"
"fstmias %[dst_w]!, {s8-s11}\n\t"
"fstmias %[dst_w]!, {s12-s15}\n\t"
"fmulsge s28, s20, s28\n\t"
"fldmiasgt %[dst_r]!, {s0-s3}\n\t"
"fldmiasgt %[src]!, {s8-s11}\n\t"
"fldmiasgt %[dst_r]!, {s4-s7}\n\t"
"fldmiasgt %[src]!, {s12-s15}\n\t"
"fmulsge s8, s0, s8\n\t"
"fstmiasge %[dst_w]!, {s24-s27}\n\t"
"fstmiasge %[dst_w]!, {s28-s31}\n\t"
"bgt 1b\n\t"
"bic %[tmp], %[tmp], #(7 << 16)\n\t"
"fmxr fpscr, %[tmp]\n\t"
: [dst_w] "+&r" (dst), [dst_r] "+&r" (dst), [src] "+&r" (src), [len] "+&r" (len), [tmp] "=&r" (tmp)
:
: "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
"s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15",
"s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23",
"s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31",
"cc", "memory");
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.