problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Why Java Calendary don't execute some lines? : Java don't execute some lines of my code when I use Calendary library.
I'm trying to get the date of monday before 1 of actual month.
//Today is Tuesday, 2 January of 2019 (29/01/2019)
1. Calendar cp1 = GregorianCalendar.getInstance();
2. cp1.set(Calendar.DAY_OF_MONTH, 1); //THIS LINE DON'T WORKS
3. cp1.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
4. SimpleDateFormat sdf=new SimpleDateFormat ("dd/MM/yyyy");
5. System.out.println(sdf.format (cp1.getTime()));
//return 28/01/2019 instead of 31/12/2018.
//IF I ADD System.out.println (cp1) after line 2 java don't jump line 2 and works well.
//Today is Tuesday, 2 January of 2019 (29/01/2019)
1. Calendar cp1 = GregorianCalendar.getInstance();
2. cp1.set(Calendar.DAY_OF_MONTH, 1); //THIS LINE WORKS NOW
3. System.out.println (cp1);
4. cp1.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
5. SimpleDateFormat sdf=new SimpleDateFormat ("dd/MM/yyyy");
6. System.out.println(sdf.format (cp1.getTime()));
//return 31/12/2018 that is the correct date.
//Why java didn't execute 2nd line in my first code? Is a java bug?
Expected result "31/12/2018".
Actual result "28/01/2019".
| 0debug
|
document.getElementById('input').innerHTML = user_input;
| 1threat
|
Robolectric fails on command line but succeeds in Android Studio : <p>I have a test where I use Robolectric which succeeds in Android Studio, but does not on the command line.</p>
<p>I use Robolectric 4.2 and the test involves a cipher which I partially mock for this test.</p>
<pre><code>//How the cipher is created
val mockCipher = object : Cipher(MockCipherSpi(), null, null) {}
</code></pre>
<p>The MockCipher basically just returns the unencrypted input:</p>
<pre><code>class MockCipherSpi : CipherSpi() {
...
private val algorithmParametersSpi: AlgorithmParametersSpi? = object : AlgorithmParametersSpi() {
...
override fun <T : AlgorithmParameterSpec?> engineGetParameterSpec(paramSpec: Class<T>?): T {
return IvParameterSpec(byteArrayOf()) as T
}
}
...
override fun engineGetParameters(): AlgorithmParameters {
return object : AlgorithmParameters(algorithmParametersSpi, null, null) {
init {
init(byteArrayOf())
}
}
}
}
</code></pre>
<p>The reason my test fails is that I get a null pointer exception when I try to get the IV from the cipher:</p>
<pre><code>cipher.parameters.getParameterSpec(IvParameterSpec::class.java).iv
</code></pre>
<p>This works perfectly fine for Android Studio and I can even debug it, but running it from the command line with <code>./gradlew test</code> this fails.</p>
<pre><code>java.lang.NullPointerException
at javax.crypto.Cipher.<init>(Cipher.java:268)
at the place where I try to access the iv
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:601)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:260)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:130)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:42)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.robolectric.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:84)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:116)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:59)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:39)
at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:66)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy1.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:146)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:128)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:748)
</code></pre>
<p>It seems there are two <code>javax.crypto.Cipher</code> one from the in the android.jar and one in the jce.jar I assume that AS is using one and the gradle command the other.</p>
<p>Do I have to tell gradle to use an other jar or can I solve this problem otherwise? </p>
| 0debug
|
$("#imageform").ajaxForm({ target: '#preview' }).submit().done(function( data ) { alert( "Data Loaded: " + data ); }); : <form id="imageform" method="post" enctype="multipart/form-data" action='<?php echo HTTP_INDEX ?>demo_upload/upload'>
I am using ajax to upload an image file. It is running successfully.But i am facing issue with to get values after successfully uploaded.Want to get some values from backend in javascript variabe. As we get success on ajax call. Please revert me back as soon as possible.
| 0debug
|
static uint32_t virtio_ioport_read(VirtIOPCIProxy *proxy, uint32_t addr)
{
VirtIODevice *vdev = proxy->vdev;
uint32_t ret = 0xFFFFFFFF;
switch (addr) {
case VIRTIO_PCI_HOST_FEATURES:
ret = vdev->get_features(vdev);
ret |= vdev->binding->get_features(proxy);
break;
case VIRTIO_PCI_GUEST_FEATURES:
ret = vdev->guest_features;
break;
case VIRTIO_PCI_QUEUE_PFN:
ret = virtio_queue_get_addr(vdev, vdev->queue_sel)
>> VIRTIO_PCI_QUEUE_ADDR_SHIFT;
break;
case VIRTIO_PCI_QUEUE_NUM:
ret = virtio_queue_get_num(vdev, vdev->queue_sel);
break;
case VIRTIO_PCI_QUEUE_SEL:
ret = vdev->queue_sel;
break;
case VIRTIO_PCI_STATUS:
ret = vdev->status;
break;
case VIRTIO_PCI_ISR:
ret = vdev->isr;
vdev->isr = 0;
qemu_set_irq(proxy->pci_dev.irq[0], 0);
break;
case VIRTIO_MSI_CONFIG_VECTOR:
ret = vdev->config_vector;
break;
case VIRTIO_MSI_QUEUE_VECTOR:
ret = virtio_queue_vector(vdev, vdev->queue_sel);
break;
default:
break;
}
return ret;
}
| 1threat
|
c# - 'an unhandled exception of type 'System.NullReferenceException' : <p>i'm a newbie in MVVM, I have a Model.cs which contains a few property of 'ID' and 'PositionName' and i got View.cs which contains DataGrid with SelectedItems={Binding Items} and ItemSource={Binding Position} and a button with a Command={Binding SHowEdits} after clicking that i encountered a NullReference error at 'Items.PositionName == null '.<br>
here's my code.</p>
<p><strong>ViewModel.cs</strong></p>
<pre><code>class PositionVM : INotifyPropertyChanged
{
private ObservableCollection<PositionModel> _position;
private PositionModel _items;
private ICommand _showedits;
public ObservableCollection<PositionModel> Position
{
get
{
return _position;
}
set
{
_position = value;
NotifyProperty("Position");
}
}
public PositionModel Items
{
get
{
return _items;
}
set
{
_items = value;
NotifyProperty("Items");
}
}
public ICommand ShowEdits
{
get
{
if (_showedits == null)
_showedits = new ShowEdit();
return _showedits;
}
set
{
_showedits = value;
}
}
public PositionVM()
{
Position = new ObservableCollection<PositionModel>();
Position.Add(new PositionModel()
{
ID = 1,
PositionName = "asd"
});
}
public void ShowEditDialog()
{
if (Items.PositionName == null)
{
MessageBox.Show("ERROR");
}
else
{
PositionView view = new PositionView();
Data.ID = view.txtid.Text;
var z = new PositionView();
z.ShowDialog();
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyProperty(String info)
{
if(PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
}
</code></pre>
<p>Why am i getting this error? and How can i avoid it? Thanksss</p>
| 0debug
|
static void restore_native_fp_frstor(CPUState *env)
{
int fptag, i, j;
struct fpstate fp1, *fp = &fp1;
fp->fpuc = env->fpuc;
fp->fpus = (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11;
fptag = 0;
for (i=7; i>=0; i--) {
fptag <<= 2;
if (env->fptags[i]) {
fptag |= 3;
} else {
}
}
fp->fptag = fptag;
j = env->fpstt;
for(i = 0;i < 8; i++) {
memcpy(&fp->fpregs1[i * 10], &env->fpregs[j].d, 10);
j = (j + 1) & 7;
}
asm volatile ("frstor %0" : "=m" (*fp));
}
| 1threat
|
Remove value arraylist java from input : <p>I have an array like this:</p>
<pre><code>1101 "TV"
5531 "Baju Baru"
1425 "Mesin Cuci"
</code></pre>
<p>Then i want to remove "TV" from my Arraylist. So i must type "1101" then the value is remove. But if i'm wrong it show "code is invalid".</p>
<p>Here is my code:</p>
<pre><code>for (int i = 0; i < listBarang.size(); i++) {
System.out.println(listBarang.get(i));
}
System.out.println("Your code stuff: ");
int code = Integer.parseInt(input.next());
listBarang.remove(i);
</code></pre>
<p>Any answer?</p>
| 0debug
|
GeoJson FIle for INDIA : I am trying to make a map in D3 like this, but for INDIA :
http://bl.ocks.org/NPashaP/a74faf20b492ad377312
Here, they have json file for the us-states as on this location **(uStates.js)** :
https://gist.github.com/NPashaP/a74faf20b492ad377312
Now, I am unable to get json file in this format for states of india. I have few shapes file and other geojson files, but none matches the data like this.
Can anyone let me know if they know of how can i make a similar map for INDIA.
| 0debug
|
if statements in an arrow function : <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>storyWords.filter(word => if (unnecessaryWords.includes(word)){
continue;
}
else{
betterWords.push(word);
}) ; </code></pre>
</div>
</div>
</p>
<p>I keep getting an error "Unexpected token if", I was wondering if when you use an arrow function the syntax for if statements is different than in a regular function.</p>
| 0debug
|
Sieb des Eratosthenes : I need to programm the sieve of eratosthenes in Delphi 5 as a school homework till tomorrow.
But I am kind of new to it and we didn't get much informations.
This is what i currently have:
https://pastebin.com/CtXNxPXi
But there is one problem:
At the end of the last for-"loop"
it says`"if zahl[i] then write(i:8);"`
I suppose it should give out the content but what I need is the following:
It adding the number in the array, if the content of the array is yes, to an edit.
Can anyone help?
| 0debug
|
Module's function auto running? : <p>I can't figure out why the function that I've called auto runs when I run the script, without pressing the button.</p>
<pre><code>import tkinter
from tkinter import filedialog
root = tkinter.Tk ()
root.title("fool")
root.geometry("300x300")
br = tkinter.Button(root, text ="Carica File", command = filedialog.askopenfile(mode="r"))
br.pack()
</code></pre>
| 0debug
|
void dump_exec_info(FILE *f,
int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
{
int i, target_code_size, max_target_code_size;
int direct_jmp_count, direct_jmp2_count, cross_page;
TranslationBlock *tb;
target_code_size = 0;
max_target_code_size = 0;
cross_page = 0;
direct_jmp_count = 0;
direct_jmp2_count = 0;
for(i = 0; i < nb_tbs; i++) {
tb = &tbs[i];
target_code_size += tb->size;
if (tb->size > max_target_code_size)
max_target_code_size = tb->size;
if (tb->page_addr[1] != -1)
cross_page++;
if (tb->tb_next_offset[0] != 0xffff) {
direct_jmp_count++;
if (tb->tb_next_offset[1] != 0xffff) {
direct_jmp2_count++;
}
}
}
cpu_fprintf(f, "Translation buffer state:\n");
cpu_fprintf(f, "gen code size %ld/%ld\n",
code_gen_ptr - code_gen_buffer, code_gen_buffer_max_size);
cpu_fprintf(f, "TB count %d/%d\n",
nb_tbs, code_gen_max_blocks);
cpu_fprintf(f, "TB avg target size %d max=%d bytes\n",
nb_tbs ? target_code_size / nb_tbs : 0,
max_target_code_size);
cpu_fprintf(f, "TB avg host size %d bytes (expansion ratio: %0.1f)\n",
nb_tbs ? (code_gen_ptr - code_gen_buffer) / nb_tbs : 0,
target_code_size ? (double) (code_gen_ptr - code_gen_buffer) / target_code_size : 0);
cpu_fprintf(f, "cross page TB count %d (%d%%)\n",
cross_page,
nb_tbs ? (cross_page * 100) / nb_tbs : 0);
cpu_fprintf(f, "direct jump count %d (%d%%) (2 jumps=%d %d%%)\n",
direct_jmp_count,
nb_tbs ? (direct_jmp_count * 100) / nb_tbs : 0,
direct_jmp2_count,
nb_tbs ? (direct_jmp2_count * 100) / nb_tbs : 0);
cpu_fprintf(f, "\nStatistics:\n");
cpu_fprintf(f, "TB flush count %d\n", tb_flush_count);
cpu_fprintf(f, "TB invalidate count %d\n", tb_phys_invalidate_count);
cpu_fprintf(f, "TLB flush count %d\n", tlb_flush_count);
tcg_dump_info(f, cpu_fprintf);
}
| 1threat
|
python list slicing error : Can someone help me with my code?
I am just starting out my question is this:
in this code: https://pastebin.com/mQkpxdeV
wordlist[overticker] = thesentence[0:spaces]
I can't figure out why it just keeps saying list index out of range?
The program seems to work but it gives an error, what am I doing wrong please help I am on a deadline(it's a long story)
I have looked through this book by mark lutz for an answer and I can't find one
| 0debug
|
static int dash_flush(AVFormatContext *s, int final, int stream)
{
DASHContext *c = s->priv_data;
int i, ret = 0;
const char *proto = avio_find_protocol_name(s->filename);
int use_rename = proto && !strcmp(proto, "file");
int cur_flush_segment_index = 0;
if (stream >= 0)
cur_flush_segment_index = c->streams[stream].segment_index;
for (i = 0; i < s->nb_streams; i++) {
OutputStream *os = &c->streams[i];
AVStream *st = s->streams[i];
char filename[1024] = "", full_path[1024], temp_path[1024];
int range_length, index_length = 0;
if (!os->packets_written)
continue;
if (stream >= 0 && i != stream) {
if (s->streams[i]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO)
continue;
if (c->has_video && os->segment_index > cur_flush_segment_index)
continue;
}
if (!os->init_range_length) {
flush_init_segment(s, os);
}
if (!c->single_file) {
ff_dash_fill_tmpl_params(filename, sizeof(filename), c->media_seg_name, i, os->segment_index, os->bit_rate, os->start_pts);
snprintf(full_path, sizeof(full_path), "%s%s", c->dirname, filename);
snprintf(temp_path, sizeof(temp_path), use_rename ? "%s.tmp" : "%s", full_path);
ret = s->io_open(s, &os->out, temp_path, AVIO_FLAG_WRITE, NULL);
if (ret < 0)
break;
if (!strcmp(os->format_name, "mp4"))
write_styp(os->ctx->pb);
} else {
snprintf(full_path, sizeof(full_path), "%s%s", c->dirname, os->initfile);
}
ret = flush_dynbuf(os, &range_length);
if (ret < 0)
break;
os->packets_written = 0;
if (c->single_file) {
find_index_range(s, full_path, os->pos, &index_length);
} else {
ff_format_io_close(s, &os->out);
if (use_rename) {
ret = avpriv_io_move(temp_path, full_path);
if (ret < 0)
break;
}
}
if (!os->bit_rate) {
int64_t bitrate = (int64_t) range_length * 8 * AV_TIME_BASE / av_rescale_q(os->max_pts - os->start_pts,
st->time_base,
AV_TIME_BASE_Q);
if (bitrate >= 0) {
os->bit_rate = bitrate;
snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
" bandwidth=\"%d\"", os->bit_rate);
}
}
add_segment(os, filename, os->start_pts, os->max_pts - os->start_pts, os->pos, range_length, index_length);
av_log(s, AV_LOG_VERBOSE, "Representation %d media segment %d written to: %s\n", i, os->segment_index, full_path);
os->pos += range_length;
}
if (c->window_size || (final && c->remove_at_exit)) {
for (i = 0; i < s->nb_streams; i++) {
OutputStream *os = &c->streams[i];
int j;
int remove = os->nb_segments - c->window_size - c->extra_window_size;
if (final && c->remove_at_exit)
remove = os->nb_segments;
if (remove > 0) {
for (j = 0; j < remove; j++) {
char filename[1024];
snprintf(filename, sizeof(filename), "%s%s", c->dirname, os->segments[j]->file);
unlink(filename);
av_free(os->segments[j]);
}
os->nb_segments -= remove;
memmove(os->segments, os->segments + remove, os->nb_segments * sizeof(*os->segments));
}
}
}
if (ret >= 0)
ret = write_manifest(s, final);
return ret;
}
| 1threat
|
static int read_dct_coeffs(BitstreamContext *bc, int32_t block[64],
const uint8_t *scan,
const int32_t quant_matrices[16][64], int q)
{
int coef_list[128];
int mode_list[128];
int i, t, bits, ccoef, mode;
int list_start = 64, list_end = 64, list_pos;
int coef_count = 0;
int coef_idx[64];
int quant_idx;
const int32_t *quant;
coef_list[list_end] = 4; mode_list[list_end++] = 0;
coef_list[list_end] = 24; mode_list[list_end++] = 0;
coef_list[list_end] = 44; mode_list[list_end++] = 0;
coef_list[list_end] = 1; mode_list[list_end++] = 3;
coef_list[list_end] = 2; mode_list[list_end++] = 3;
coef_list[list_end] = 3; mode_list[list_end++] = 3;
for (bits = bitstream_read(bc, 4) - 1; bits >= 0; bits--) {
list_pos = list_start;
while (list_pos < list_end) {
if (!(mode_list[list_pos] | coef_list[list_pos]) || !bitstream_read_bit(bc)) {
list_pos++;
continue;
}
ccoef = coef_list[list_pos];
mode = mode_list[list_pos];
switch (mode) {
case 0:
coef_list[list_pos] = ccoef + 4;
mode_list[list_pos] = 1;
case 2:
if (mode == 2) {
coef_list[list_pos] = 0;
mode_list[list_pos++] = 0;
}
for (i = 0; i < 4; i++, ccoef++) {
if (bitstream_read_bit(bc)) {
coef_list[--list_start] = ccoef;
mode_list[ list_start] = 3;
} else {
if (!bits) {
t = 1 - (bitstream_read_bit(bc) << 1);
} else {
t = bitstream_read(bc, bits) | 1 << bits;
t = bitstream_apply_sign(bc, t);
}
block[scan[ccoef]] = t;
coef_idx[coef_count++] = ccoef;
}
}
break;
case 1:
mode_list[list_pos] = 2;
for (i = 0; i < 3; i++) {
ccoef += 4;
coef_list[list_end] = ccoef;
mode_list[list_end++] = 2;
}
break;
case 3:
if (!bits) {
t = 1 - (bitstream_read_bit(bc) << 1);
} else {
t = bitstream_read(bc, bits) | 1 << bits;
t = bitstream_apply_sign(bc, t);
}
block[scan[ccoef]] = t;
coef_idx[coef_count++] = ccoef;
coef_list[list_pos] = 0;
mode_list[list_pos++] = 0;
break;
}
}
}
if (q == -1) {
quant_idx = bitstream_read(bc, 4);
} else {
quant_idx = q;
}
if (quant_idx >= 16)
return AVERROR_INVALIDDATA;
quant = quant_matrices[quant_idx];
block[0] = (block[0] * quant[0]) >> 11;
for (i = 0; i < coef_count; i++) {
int idx = coef_idx[i];
block[scan[idx]] = (block[scan[idx]] * quant[idx]) >> 11;
}
return 0;
}
| 1threat
|
What is the difference between Firebase push-notifications and FCM messages? : <p>Heloo, I am building an app where I am using push notifications via Firebase Console. I want to know what is a difference between simply push-notification and cloud message?
Is it that messages from cloud messaging are data messages(have key and value) and notifications are just text without key and value?Am I right?</p>
| 0debug
|
How can I write reusable classes to make http async requests in android : I am novice to android development. I have a project where I want to write some functions that use internet service to get the data from MySQL server. These functions are inside some non-activity classes. I intend to call these functions from different activities. I use AsyncTask to make http requests. Following is the skeleton of my design.
public class MyLibrary{
String myData;
protected String getMyData(String param){
HashMap<String, String> params = new HashMap<>();
params.put("param1", apicall);
params.put("param2", param);
MyAsyncClass myAsyncClass = new MyAsyncClass(params);
myAsyncClass.execute();
/* Here after finishing the task I want to return the data to the caller */
return myData;
}
private class MyAsyncClass extends AsyncTask<String, Integer, String> {
MyAsyncClass(HashMap<String, String> params) {
this.postData = params;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
RequestHandler requestHandler = new RequestHandler();
return requestHandler.sendPostRequest(GlobalConstants.myurl, postData);
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
/* parse code here ... */
}
}
}
This class will be accessed by my activities like following.
public class SampleActivity extends AppCompatActivity{
String returnedData;
@Override
protected void onCreate(Bundle savedInstanceState) {
MyLibrary myLibraryObject = new MyLibrary();
returnedData = myLibraryObject.getMyData("cih");
/* do something with returnedData */
}
}
Any suggestions would be huge help to me. As I am novice, this might be stupid question, but my concept is to reuse codes.
Thanks in advance!
| 0debug
|
iOS constraint style: addConstraints vs .isActive = true : <p>I have some code which is creating auto-layout constraints programatically, and adding them to a view.</p>
<p>There are two ways to do this - call <code>addConstraints</code> on the superView, or set <code>.isActive = true</code> on each constraint (which internally calls addConstraint)</p>
<p>Option 1:</p>
<pre><code>parent.addConstraints([
child.topAnchor.constraint(equalTo: parent.topAnchor, constant: 20),
child.leftAnchor.constraint(equalTo: parent.leftAnchor, constant: 5) ])
</code></pre>
<p>Option 2:</p>
<pre><code>child.topAnchor.constraint(equalTo: parent.topAnchor, constant: 20).isActive = true
child.leftAnchor.constraint(equalTo: parent.leftAnchor, constant: 5).isActive = true
</code></pre>
<p>My question is, is there any benefit to doing one over the other? (performance/etc) or does it come purely down to style.</p>
<p><em>(I don't think constraints are evaluated until the next layout pass, so I don't think it should matter that we add them one-by-one instead of in a block??)</em></p>
<p>If it is just style, what's the "more preferred" style by the community??</p>
<p><em>(personally I prefer addConstraints, however it's very close and I could be easily swayed to .isActive)</em></p>
| 0debug
|
Microservices Java : <p>I am learning about microservices using Java technology (Spring Boot) , I can not find a good book or tutorials.
I want to learn about microservices in details.If any one can guide in this it will be great.</p>
| 0debug
|
Kotlin Realm: Class must declare a public constructor with no arguments if it contains custom constructors : <p>I'm creating a <strong>Realm</strong> object in <strong>Kotlin</strong>.</p>
<p><strong>Realm Object:</strong></p>
<pre><code>open class PurposeModel(var _id: Long?,
var purposeEn: String?,
var purposeAr: String?) : RealmObject()
</code></pre>
<p>When I compile the above code I'm getting this error:</p>
<pre><code>error: Class "PurposeModel" must declare a public constructor with no arguments if it contains custom constructors.
</code></pre>
<p>I can't find any question related to this in Kotlin. How do I resolve this?</p>
| 0debug
|
How to create an if statement for the following error? : <p>I would like to know how to add an if statement for the following error:</p>
<pre><code>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
at Calendar.main(Calendar.java:14)
</code></pre>
<p>In other words, I would like to display the following text when the following error is triggered, "Error. Please enter the missing elements."</p>
| 0debug
|
JAVA - read binary file with header (trying to transfer c++ code) : i have some old C code that does what i need, with the file type i'm working with, but i need to get it into Java. i've been reading up on binary I/O but i can't figure out how to deal with the header and i don't understand the C code enough to know what it's doing
i would appreciate any assistance - mostly with understanding what the C code means when it uses br.readInt32() and such and how to emulate that with Java which (as i understand it) reads the binary differently
i don't understand binary files very well (nor do i want to, this is a one off code piece), i just want to get the data out then i can work on the code that i understand better.
thanks
C snippet:
[code]
public void ConvertEVDtoCSV(string fileName)
{
string[] fileArray = File.ReadAllLines(fileName);
float minX = 0;
float maxX = 0;
try
{
FileStream fs = new FileStream(fileName, FileMode.Open);
BinaryReader br = new BinaryReader(fs);
/*
16 + n*80*6 = sizeof(header) where n is the 9th nibble of the file (beginning of the 5th byte)
*/
//Reads "EVIS"
br.ReadBytes(4);
//Reads numDataSets
int numDataSets = br.ReadInt32();
//Reads lngNumPlotSurfaces
int lngNumPlotSurfaces = br.ReadInt32();
//Reads headerEvisive length
int headerEvisive = br.ReadInt32();
//skip all six title and axes text lines.
int remainingHeader = (lngNumPlotSurfaces * 6 * 80) + headerEvisive;
br.ReadBytes(remainingHeader); //could also use seek(remainingHeader+16), but streams don't support seek?
long dataSize = numDataSets * (2 + lngNumPlotSurfaces); //meb 6-8-2016: +2 for X and Y
string[] dataForCSVFile = new string[dataSize];
for (long cnt = 0; cnt < numDataSets; cnt++)
{
for (int j = 0; j < 2 + lngNumPlotSurfaces; j++) //+2 for X and Y
{
//don't read past the end of file
if (br.BaseStream.Position<br.BaseStream.Length) {
//This is where the data needs to be read in and converted from 32-bit single-precision floating point to strings for the csv file
float answerLittle = br.ReadSingle();
if (j == 0 && answerLittle > maxX)
maxX = answerLittle;
if (j == 0 && answerLittle < minX)
minX = answerLittle;
if (j > lngNumPlotSurfaces)
dataForCSVFile[cnt * (2 + lngNumPlotSurfaces) + j] = answerLittle.ToString() + "\r\n";
else
dataForCSVFile[cnt * (2 + lngNumPlotSurfaces) + j] = answerLittle.ToString() + ",";
}
}
}
fs.Close();
textBox_x_max.Text = (maxX).ToString("F2");
textBox_x_min.Text = (minX).ToString("F2");
StreamWriter sw = new StreamWriter(tempfile);
for (int i = 0; i < dataForCSVFile.Length; i++)
{
sw.Write(dataForCSVFile[i]);
}
sw.Close();
}
catch (Exception ex)
{ Console.WriteLine("Error reading data past eof."); }
}
| 0debug
|
Session cleared, yet page still recognizes the user : <p>I'm using the simple chat code from here <a href="https://code.tutsplus.com/tutorials/how-to-create-a-simple-web-based-chat-application--net-5931" rel="nofollow noreferrer">https://code.tutsplus.com/tutorials/how-to-create-a-simple-web-based-chat-application--net-5931</a></p>
<p>It works, but the problem is that I want to show login form every time the user refreshes the page or closes the tab and then re-opens it.
Currently, I see login form only the first time I open the page and subsequently, the browser (both Chrome and Firefox) recognize the user.</p>
<p>Clearing cookies hasn't help.
Clearing the session in PHP ($_SESSION = array();) hasn't helped either.</p>
<p>Please, advise how to show the login form every time the user refreshes or closes and re-opens the tab.
Thank you!</p>
| 0debug
|
GAChannel *ga_channel_new(GAChannelMethod method, const gchar *path,
GAChannelCallback cb, gpointer opaque)
{
GAChannel *c = g_malloc0(sizeof(GAChannel));
SECURITY_ATTRIBUTES sec_attrs;
if (!ga_channel_open(c, method, path)) {
g_critical("error opening channel");
g_free(c);
return NULL;
}
c->cb = cb;
c->user_data = opaque;
sec_attrs.nLength = sizeof(SECURITY_ATTRIBUTES);
sec_attrs.lpSecurityDescriptor = NULL;
sec_attrs.bInheritHandle = false;
c->rstate.buf_size = QGA_READ_COUNT_DEFAULT;
c->rstate.buf = g_malloc(QGA_READ_COUNT_DEFAULT);
c->rstate.ov.hEvent = CreateEvent(&sec_attrs, FALSE, FALSE, NULL);
c->source = ga_channel_create_watch(c);
g_source_attach(c->source, NULL);
return c;
}
| 1threat
|
python - self - required positional argument : <p>here is my code: </p>
<p>my file which I start:</p>
<pre><code> from SQLhandler import SQLhandler
D = SQLhandler.loadProject(4711)
</code></pre>
<p>a part of my SQLhandler file:</p>
<pre><code>class SQLhandler(object):
db = pymysql.connect(... )
def loadProject(self, project_id):
#do some stuff
</code></pre>
<p>I want to use db in other functions, so I put it on the class level and added a "self" to loadProject. Now the second line in my start file throws an error:</p>
<pre><code>"loadProject() missing 1 required positional argument: 'project_id'"
</code></pre>
<p>What's wrong with my code? </p>
| 0debug
|
int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block,
int n, int coded, const uint8_t *scan_table)
{
int level, i, last, run, run_diff;
int av_uninit(dc_pred_dir);
RLTable *rl;
RL_VLC_ELEM *rl_vlc;
int qmul, qadd;
if (s->mb_intra) {
qmul=1;
qadd=0;
level = msmpeg4_decode_dc(s, n, &dc_pred_dir);
if (level < 0){
av_log(s->avctx, AV_LOG_ERROR, "dc overflow- block: %d qscale: %d
if(s->inter_intra_pred) level=0;
else return -1;
}
if (n < 4) {
rl = &ff_rl_table[s->rl_table_index];
if(level > 256*s->y_dc_scale){
av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ L qscale: %d
if(!s->inter_intra_pred) return -1;
}
} else {
rl = &ff_rl_table[3 + s->rl_chroma_table_index];
if(level > 256*s->c_dc_scale){
av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ C qscale: %d
if(!s->inter_intra_pred) return -1;
}
}
block[0] = level;
run_diff = s->msmpeg4_version >= 4;
i = 0;
if (!coded) {
goto not_coded;
}
if (s->ac_pred) {
if (dc_pred_dir == 0)
scan_table = s->intra_v_scantable.permutated;
else
scan_table = s->intra_h_scantable.permutated;
} else {
scan_table = s->intra_scantable.permutated;
}
rl_vlc= rl->rl_vlc[0];
} else {
qmul = s->qscale << 1;
qadd = (s->qscale - 1) | 1;
i = -1;
rl = &ff_rl_table[3 + s->rl_table_index];
if(s->msmpeg4_version==2)
run_diff = 0;
else
run_diff = 1;
if (!coded) {
s->block_last_index[n] = i;
return 0;
}
if(!scan_table)
scan_table = s->inter_scantable.permutated;
rl_vlc= rl->rl_vlc[s->qscale];
}
{
OPEN_READER(re, &s->gb);
for(;;) {
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 0);
if (level==0) {
int cache;
cache= GET_CACHE(re, &s->gb);
if (s->msmpeg4_version==1 || (cache&0x80000000)==0) {
if (s->msmpeg4_version==1 || (cache&0x40000000)==0) {
if(s->msmpeg4_version!=1) LAST_SKIP_BITS(re, &s->gb, 2);
UPDATE_CACHE(re, &s->gb);
if(s->msmpeg4_version<=3){
last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
run= SHOW_UBITS(re, &s->gb, 6); SKIP_CACHE(re, &s->gb, 6);
level= SHOW_SBITS(re, &s->gb, 8);
SKIP_COUNTER(re, &s->gb, 1+6+8);
}else{
int sign;
last= SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1);
if(!s->esc3_level_length){
int ll;
av_dlog(s->avctx, "ESC-3 %X at %d %d\n",
show_bits(&s->gb, 24), s->mb_x, s->mb_y);
if(s->qscale<8){
ll= SHOW_UBITS(re, &s->gb, 3); SKIP_BITS(re, &s->gb, 3);
if(ll==0){
ll= 8+SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1);
}
}else{
ll=2;
while(ll<8 && SHOW_UBITS(re, &s->gb, 1)==0){
ll++;
SKIP_BITS(re, &s->gb, 1);
}
if(ll<8) SKIP_BITS(re, &s->gb, 1);
}
s->esc3_level_length= ll;
s->esc3_run_length= SHOW_UBITS(re, &s->gb, 2) + 3; SKIP_BITS(re, &s->gb, 2);
UPDATE_CACHE(re, &s->gb);
}
run= SHOW_UBITS(re, &s->gb, s->esc3_run_length);
SKIP_BITS(re, &s->gb, s->esc3_run_length);
sign= SHOW_UBITS(re, &s->gb, 1);
SKIP_BITS(re, &s->gb, 1);
level= SHOW_UBITS(re, &s->gb, s->esc3_level_length);
SKIP_BITS(re, &s->gb, s->esc3_level_length);
if(sign) level= -level;
}
#if 0
{
const int abs_level= FFABS(level);
const int run1= run - rl->max_run[last][abs_level] - run_diff;
if(abs_level<=MAX_LEVEL && run<=MAX_RUN){
if(abs_level <= rl->max_level[last][run]){
av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, vlc encoding possible\n");
return DECODING_AC_LOST;
}
if(abs_level <= rl->max_level[last][run]*2){
av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, esc 1 encoding possible\n");
return DECODING_AC_LOST;
}
if(run1>=0 && abs_level <= rl->max_level[last][run1]){
av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, esc 2 encoding possible\n");
return DECODING_AC_LOST;
}
}
}
#endif
if (level>0) level= level * qmul + qadd;
else level= level * qmul - qadd;
#if 0
if(level>2048 || level<-2048){
av_log(s->avctx, AV_LOG_ERROR, "|level| overflow in 3. esc\n");
return DECODING_AC_LOST;
}
#endif
i+= run + 1;
if(last) i+=192;
#ifdef ERROR_DETAILS
if(run==66)
av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code in ESC3 level=%d\n", level);
else if((i>62 && i<192) || i>192+63)
av_log(s->avctx, AV_LOG_ERROR, "run overflow in ESC3 i=%d run=%d level=%d\n", i, run, level);
#endif
} else {
SKIP_BITS(re, &s->gb, 2);
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
i+= run + rl->max_run[run>>7][level/qmul] + run_diff;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
#ifdef ERROR_DETAILS
if(run==66)
av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code in ESC2 level=%d\n", level);
else if((i>62 && i<192) || i>192+63)
av_log(s->avctx, AV_LOG_ERROR, "run overflow in ESC2 i=%d run=%d level=%d\n", i, run, level);
#endif
}
} else {
SKIP_BITS(re, &s->gb, 1);
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
i+= run;
level = level + rl->max_level[run>>7][(run-1)&63] * qmul;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
#ifdef ERROR_DETAILS
if(run==66)
av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code in ESC1 level=%d\n", level);
else if((i>62 && i<192) || i>192+63)
av_log(s->avctx, AV_LOG_ERROR, "run overflow in ESC1 i=%d run=%d level=%d\n", i, run, level);
#endif
}
} else {
i+= run;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
#ifdef ERROR_DETAILS
if(run==66)
av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code level=%d\n", level);
else if((i>62 && i<192) || i>192+63)
av_log(s->avctx, AV_LOG_ERROR, "run overflow i=%d run=%d level=%d\n", i, run, level);
#endif
}
if (i > 62){
i-= 192;
if(i&(~63)){
const int left= get_bits_left(&s->gb);
if(((i+192 == 64 && level/qmul==-1) || !(s->err_recognition&(AV_EF_BITSTREAM|AV_EF_COMPLIANT))) && left>=0){
av_log(s->avctx, AV_LOG_ERROR, "ignoring overflow at %d %d\n", s->mb_x, s->mb_y);
i = 63;
break;
}else{
av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
}
block[scan_table[i]] = level;
break;
}
block[scan_table[i]] = level;
}
CLOSE_READER(re, &s->gb);
}
not_coded:
if (s->mb_intra) {
ff_mpeg4_pred_ac(s, block, n, dc_pred_dir);
if (s->ac_pred) {
i = 63;
}
}
if(s->msmpeg4_version>=4 && i>0) i=63;
s->block_last_index[n] = i;
return 0;
}
| 1threat
|
php yii2 MongoDB Aggregation Error “each item in the pipeline must be a document” : $collection=Yii::$app->mongodb->getCollection("lc_executive_allocate"); $result=$collection->aggregate(array(array('$match'=>array('stage'=>'2','completed'=>'1','status'=>'1','assignedOn'=>array('$gte'=>'2018-03-01','$lte'=>'2018-03-29'))), array('$group'=>array('_id'=>array('userId'=>'$userId','count'=>array('$sum'=>'1')))),array('$sort'=>array('count'=>'-1')),array('$limit'=>'1'),'cursor'=>array()));
| 0debug
|
How to implement Bottom Sheets using new design support library 23.2 : <p>Google release the new update to support library 23.2 in that they added bottom sheet feature. Can any one tell how to implement that bottom sheet using that library.</p>
| 0debug
|
Printing Different Paterns in Single Program : Here User enter X Coordinate, Y coordinate ,Length L,number n. if user enters n
we have to print "stright Line" with (x,y) cordinates, if n=2 print bisecting Lines if n=3 print triangle like.... Here Length purpose is to Print Length of side is equal to L. Is there any solutions for this question please comment because it was asked me for interview?
| 0debug
|
static av_always_inline void encode_mb_internal(MpegEncContext *s,
int motion_x, int motion_y,
int mb_block_height,
int mb_block_count)
{
int16_t weight[8][64];
int16_t orig[8][64];
const int mb_x = s->mb_x;
const int mb_y = s->mb_y;
int i;
int skip_dct[8];
int dct_offset = s->linesize * 8;
uint8_t *ptr_y, *ptr_cb, *ptr_cr;
ptrdiff_t wrap_y, wrap_c;
for (i = 0; i < mb_block_count; i++)
skip_dct[i] = s->skipdct;
if (s->adaptive_quant) {
const int last_qp = s->qscale;
const int mb_xy = mb_x + mb_y * s->mb_stride;
s->lambda = s->lambda_table[mb_xy];
update_qscale(s);
if (!(s->mpv_flags & FF_MPV_FLAG_QP_RD)) {
s->qscale = s->current_picture_ptr->qscale_table[mb_xy];
s->dquant = s->qscale - last_qp;
if (s->out_format == FMT_H263) {
s->dquant = av_clip(s->dquant, -2, 2);
if (s->codec_id == AV_CODEC_ID_MPEG4) {
if (!s->mb_intra) {
if (s->pict_type == AV_PICTURE_TYPE_B) {
if (s->dquant & 1 || s->mv_dir & MV_DIRECT)
s->dquant = 0;
}
if (s->mv_type == MV_TYPE_8X8)
s->dquant = 0;
}
}
}
}
ff_set_qscale(s, last_qp + s->dquant);
} else if (s->mpv_flags & FF_MPV_FLAG_QP_RD)
ff_set_qscale(s, s->qscale + s->dquant);
wrap_y = s->linesize;
wrap_c = s->uvlinesize;
ptr_y = s->new_picture.f.data[0] +
(mb_y * 16 * wrap_y) + mb_x * 16;
ptr_cb = s->new_picture.f.data[1] +
(mb_y * mb_block_height * wrap_c) + mb_x * 8;
ptr_cr = s->new_picture.f.data[2] +
(mb_y * mb_block_height * wrap_c) + mb_x * 8;
if (mb_x * 16 + 16 > s->width || mb_y * 16 + 16 > s->height) {
uint8_t *ebuf = s->edge_emu_buffer + 32;
s->vdsp.emulated_edge_mc(ebuf, ptr_y,
wrap_y, wrap_y,
16, 16, mb_x * 16, mb_y * 16,
s->width, s->height);
ptr_y = ebuf;
s->vdsp.emulated_edge_mc(ebuf + 18 * wrap_y, ptr_cb,
wrap_c, wrap_c,
8, mb_block_height, mb_x * 8, mb_y * 8,
s->width >> 1, s->height >> 1);
ptr_cb = ebuf + 18 * wrap_y;
s->vdsp.emulated_edge_mc(ebuf + 18 * wrap_y + 8, ptr_cr,
wrap_c, wrap_c,
8, mb_block_height, mb_x * 8, mb_y * 8,
s->width >> 1, s->height >> 1);
ptr_cr = ebuf + 18 * wrap_y + 8;
}
if (s->mb_intra) {
if (s->flags & CODEC_FLAG_INTERLACED_DCT) {
int progressive_score, interlaced_score;
s->interlaced_dct = 0;
progressive_score = s->dsp.ildct_cmp[4](s, ptr_y,
NULL, wrap_y, 8) +
s->dsp.ildct_cmp[4](s, ptr_y + wrap_y * 8,
NULL, wrap_y, 8) - 400;
if (progressive_score > 0) {
interlaced_score = s->dsp.ildct_cmp[4](s, ptr_y,
NULL, wrap_y * 2, 8) +
s->dsp.ildct_cmp[4](s, ptr_y + wrap_y,
NULL, wrap_y * 2, 8);
if (progressive_score > interlaced_score) {
s->interlaced_dct = 1;
dct_offset = wrap_y;
wrap_y <<= 1;
if (s->chroma_format == CHROMA_422)
wrap_c <<= 1;
}
}
}
s->dsp.get_pixels(s->block[0], ptr_y , wrap_y);
s->dsp.get_pixels(s->block[1], ptr_y + 8 , wrap_y);
s->dsp.get_pixels(s->block[2], ptr_y + dct_offset , wrap_y);
s->dsp.get_pixels(s->block[3], ptr_y + dct_offset + 8 , wrap_y);
if (s->flags & CODEC_FLAG_GRAY) {
skip_dct[4] = 1;
skip_dct[5] = 1;
} else {
s->dsp.get_pixels(s->block[4], ptr_cb, wrap_c);
s->dsp.get_pixels(s->block[5], ptr_cr, wrap_c);
if (!s->chroma_y_shift) {
s->dsp.get_pixels(s->block[6],
ptr_cb + (dct_offset >> 1), wrap_c);
s->dsp.get_pixels(s->block[7],
ptr_cr + (dct_offset >> 1), wrap_c);
}
}
} else {
op_pixels_func (*op_pix)[4];
qpel_mc_func (*op_qpix)[16];
uint8_t *dest_y, *dest_cb, *dest_cr;
dest_y = s->dest[0];
dest_cb = s->dest[1];
dest_cr = s->dest[2];
if ((!s->no_rounding) || s->pict_type == AV_PICTURE_TYPE_B) {
op_pix = s->hdsp.put_pixels_tab;
op_qpix = s->dsp.put_qpel_pixels_tab;
} else {
op_pix = s->hdsp.put_no_rnd_pixels_tab;
op_qpix = s->dsp.put_no_rnd_qpel_pixels_tab;
}
if (s->mv_dir & MV_DIR_FORWARD) {
ff_MPV_motion(s, dest_y, dest_cb, dest_cr, 0,
s->last_picture.f.data,
op_pix, op_qpix);
op_pix = s->hdsp.avg_pixels_tab;
op_qpix = s->dsp.avg_qpel_pixels_tab;
}
if (s->mv_dir & MV_DIR_BACKWARD) {
ff_MPV_motion(s, dest_y, dest_cb, dest_cr, 1,
s->next_picture.f.data,
op_pix, op_qpix);
}
if (s->flags & CODEC_FLAG_INTERLACED_DCT) {
int progressive_score, interlaced_score;
s->interlaced_dct = 0;
progressive_score = s->dsp.ildct_cmp[0](s, dest_y,
ptr_y, wrap_y,
8) +
s->dsp.ildct_cmp[0](s, dest_y + wrap_y * 8,
ptr_y + wrap_y * 8, wrap_y,
8) - 400;
if (s->avctx->ildct_cmp == FF_CMP_VSSE)
progressive_score -= 400;
if (progressive_score > 0) {
interlaced_score = s->dsp.ildct_cmp[0](s, dest_y,
ptr_y,
wrap_y * 2, 8) +
s->dsp.ildct_cmp[0](s, dest_y + wrap_y,
ptr_y + wrap_y,
wrap_y * 2, 8);
if (progressive_score > interlaced_score) {
s->interlaced_dct = 1;
dct_offset = wrap_y;
wrap_y <<= 1;
if (s->chroma_format == CHROMA_422)
wrap_c <<= 1;
}
}
}
s->dsp.diff_pixels(s->block[0], ptr_y, dest_y, wrap_y);
s->dsp.diff_pixels(s->block[1], ptr_y + 8, dest_y + 8, wrap_y);
s->dsp.diff_pixels(s->block[2], ptr_y + dct_offset,
dest_y + dct_offset, wrap_y);
s->dsp.diff_pixels(s->block[3], ptr_y + dct_offset + 8,
dest_y + dct_offset + 8, wrap_y);
if (s->flags & CODEC_FLAG_GRAY) {
skip_dct[4] = 1;
skip_dct[5] = 1;
} else {
s->dsp.diff_pixels(s->block[4], ptr_cb, dest_cb, wrap_c);
s->dsp.diff_pixels(s->block[5], ptr_cr, dest_cr, wrap_c);
if (!s->chroma_y_shift) {
s->dsp.diff_pixels(s->block[6], ptr_cb + (dct_offset >> 1),
dest_cb + (dct_offset >> 1), wrap_c);
s->dsp.diff_pixels(s->block[7], ptr_cr + (dct_offset >> 1),
dest_cr + (dct_offset >> 1), wrap_c);
}
}
if (s->current_picture.mc_mb_var[s->mb_stride * mb_y + mb_x] <
2 * s->qscale * s->qscale) {
if (s->dsp.sad[1](NULL, ptr_y , dest_y,
wrap_y, 8) < 20 * s->qscale)
skip_dct[0] = 1;
if (s->dsp.sad[1](NULL, ptr_y + 8,
dest_y + 8, wrap_y, 8) < 20 * s->qscale)
skip_dct[1] = 1;
if (s->dsp.sad[1](NULL, ptr_y + dct_offset,
dest_y + dct_offset, wrap_y, 8) < 20 * s->qscale)
skip_dct[2] = 1;
if (s->dsp.sad[1](NULL, ptr_y + dct_offset + 8,
dest_y + dct_offset + 8,
wrap_y, 8) < 20 * s->qscale)
skip_dct[3] = 1;
if (s->dsp.sad[1](NULL, ptr_cb, dest_cb,
wrap_c, 8) < 20 * s->qscale)
skip_dct[4] = 1;
if (s->dsp.sad[1](NULL, ptr_cr, dest_cr,
wrap_c, 8) < 20 * s->qscale)
skip_dct[5] = 1;
if (!s->chroma_y_shift) {
if (s->dsp.sad[1](NULL, ptr_cb + (dct_offset >> 1),
dest_cb + (dct_offset >> 1),
wrap_c, 8) < 20 * s->qscale)
skip_dct[6] = 1;
if (s->dsp.sad[1](NULL, ptr_cr + (dct_offset >> 1),
dest_cr + (dct_offset >> 1),
wrap_c, 8) < 20 * s->qscale)
skip_dct[7] = 1;
}
}
}
if (s->quantizer_noise_shaping) {
if (!skip_dct[0])
get_visual_weight(weight[0], ptr_y , wrap_y);
if (!skip_dct[1])
get_visual_weight(weight[1], ptr_y + 8, wrap_y);
if (!skip_dct[2])
get_visual_weight(weight[2], ptr_y + dct_offset , wrap_y);
if (!skip_dct[3])
get_visual_weight(weight[3], ptr_y + dct_offset + 8, wrap_y);
if (!skip_dct[4])
get_visual_weight(weight[4], ptr_cb , wrap_c);
if (!skip_dct[5])
get_visual_weight(weight[5], ptr_cr , wrap_c);
if (!s->chroma_y_shift) {
if (!skip_dct[6])
get_visual_weight(weight[6], ptr_cb + (dct_offset >> 1),
wrap_c);
if (!skip_dct[7])
get_visual_weight(weight[7], ptr_cr + (dct_offset >> 1),
wrap_c);
}
memcpy(orig[0], s->block[0], sizeof(int16_t) * 64 * mb_block_count);
}
assert(s->out_format != FMT_MJPEG || s->qscale == 8);
{
for (i = 0; i < mb_block_count; i++) {
if (!skip_dct[i]) {
int overflow;
s->block_last_index[i] = s->dct_quantize(s, s->block[i], i, s->qscale, &overflow);
if (overflow)
clip_coeffs(s, s->block[i], s->block_last_index[i]);
} else
s->block_last_index[i] = -1;
}
if (s->quantizer_noise_shaping) {
for (i = 0; i < mb_block_count; i++) {
if (!skip_dct[i]) {
s->block_last_index[i] =
dct_quantize_refine(s, s->block[i], weight[i],
orig[i], i, s->qscale);
}
}
}
if (s->luma_elim_threshold && !s->mb_intra)
for (i = 0; i < 4; i++)
dct_single_coeff_elimination(s, i, s->luma_elim_threshold);
if (s->chroma_elim_threshold && !s->mb_intra)
for (i = 4; i < mb_block_count; i++)
dct_single_coeff_elimination(s, i, s->chroma_elim_threshold);
if (s->mpv_flags & FF_MPV_FLAG_CBP_RD) {
for (i = 0; i < mb_block_count; i++) {
if (s->block_last_index[i] == -1)
s->coded_score[i] = INT_MAX / 256;
}
}
}
if ((s->flags & CODEC_FLAG_GRAY) && s->mb_intra) {
s->block_last_index[4] =
s->block_last_index[5] = 0;
s->block[4][0] =
s->block[5][0] = (1024 + s->c_dc_scale / 2) / s->c_dc_scale;
}
if (s->alternate_scan && s->dct_quantize != ff_dct_quantize_c) {
for (i = 0; i < mb_block_count; i++) {
int j;
if (s->block_last_index[i] > 0) {
for (j = 63; j > 0; j--) {
if (s->block[i][s->intra_scantable.permutated[j]])
break;
}
s->block_last_index[i] = j;
}
}
}
switch(s->codec_id){
case AV_CODEC_ID_MPEG1VIDEO:
case AV_CODEC_ID_MPEG2VIDEO:
if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)
ff_mpeg1_encode_mb(s, s->block, motion_x, motion_y);
break;
case AV_CODEC_ID_MPEG4:
if (CONFIG_MPEG4_ENCODER)
ff_mpeg4_encode_mb(s, s->block, motion_x, motion_y);
break;
case AV_CODEC_ID_MSMPEG4V2:
case AV_CODEC_ID_MSMPEG4V3:
case AV_CODEC_ID_WMV1:
if (CONFIG_MSMPEG4_ENCODER)
ff_msmpeg4_encode_mb(s, s->block, motion_x, motion_y);
break;
case AV_CODEC_ID_WMV2:
if (CONFIG_WMV2_ENCODER)
ff_wmv2_encode_mb(s, s->block, motion_x, motion_y);
break;
case AV_CODEC_ID_H261:
if (CONFIG_H261_ENCODER)
ff_h261_encode_mb(s, s->block, motion_x, motion_y);
break;
case AV_CODEC_ID_H263:
case AV_CODEC_ID_H263P:
case AV_CODEC_ID_FLV1:
case AV_CODEC_ID_RV10:
case AV_CODEC_ID_RV20:
if (CONFIG_H263_ENCODER)
ff_h263_encode_mb(s, s->block, motion_x, motion_y);
break;
case AV_CODEC_ID_MJPEG:
if (CONFIG_MJPEG_ENCODER)
ff_mjpeg_encode_mb(s, s->block);
break;
default:
assert(0);
}
}
| 1threat
|
SimpleDateFormat parse incorrect return : <p>formatter allways return January. But if you convert back it's all good.</p>
<pre><code>SimpleDateFormat formatter = new SimpleDateFormat("mm-dd-yyyy", Locale.ENGLISH);
Date date = formatter.parse(changeDate);
Log.d("Tag", changeDate);
Log.d("Tag", date.toString());
Log.d("Tag", formatter.format(date));
</code></pre>
<p>LOG:
01-29-2017
Sun Jan 29 00:01:00 GMT+03:00 2017
01-29-2017</p>
<pre><code>02-13-2017
Fri Jan 13 00:02:00 GMT+03:00 2017
02-13-2017
06-08-2017
Sun Jan 08 00:06:00 GMT+03:00 2017
06-08-2017
</code></pre>
| 0debug
|
void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp)
{
int i, j = 0;
const int mb_block_count = 4 + (1 << s->chroma_format);
cbp <<= 12-mb_block_count;
for (i = 0; i < mb_block_count; i++) {
if (cbp & (1 << 11))
s->pblocks[i] = &s->block[j++];
else
s->pblocks[i] = NULL;
cbp += cbp;
}
}
| 1threat
|
How can I get data from a database to my iOS app? : <p><strong>I've designed my app in Xcode</strong></p>
<p>But , it doesn't have any data ! And I want to get data from a database .</p>
<p>I don't know where to start ? And what should I use ?</p>
<pre><code>*php , sql , json ?*
</code></pre>
| 0debug
|
Can I impement Html-Code as Css-Content? : How can I get $the variable **$text**
See the code example below
<?php
header('Content-type: text/css');
$background = "#ffafff";
$color = "#000000";
$green = "#16a86f";
**$text**= '<h1>TestText</h1>';
?>
body {
background-color: <?=$background?>;
}
#logo::before{content: "<?php echo($text);?>";}
#logo {
color: <?=$green?>;
font-weight: bold;
}
#slogan {
color: <?=$color?>;
}
#rahmen {
border: 0.1em solid <?=$green?>;
text-align: center;
}
as HTML-tag..
In the moment i get The Output:
[1]: http://i.stack.imgur.com/HVREJ.jpg
| 0debug
|
Spring Swagger UI: what is difference between io.swagger, io.springfox, and com.mangofactory : <p>I am working on integrating the swagger UI with a spring boot MVC app and I am curious as to the differences between these libraries. </p>
<p>I looked at each on mvnrepository.com and they are all done by different groups but seem to do the same thing. I am hoping to get a clear idea of the differences between these and if one is recommended over the others. I notice the swagger-core module by io.swagger has the most usages. </p>
<p>Thanks!</p>
| 0debug
|
Replace element with class from javascript string : I have javascript string
var str = <div><p class="">Deleted content <span class="del cts-2">example</span></p></div>
I want to replace <span class="del cts-2"> with <h4>.
How can I do with pure javascript?
| 0debug
|
static int test_vector_dmac_scalar(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp,
const double *v1, const double *src0, double scale)
{
LOCAL_ALIGNED(32, double, cdst, [LEN]);
LOCAL_ALIGNED(32, double, odst, [LEN]);
int ret;
memcpy(cdst, v1, LEN * sizeof(*v1));
memcpy(odst, v1, LEN * sizeof(*v1));
cdsp->vector_dmac_scalar(cdst, src0, scale, LEN);
fdsp->vector_dmac_scalar(odst, src0, scale, LEN);
if (ret = compare_doubles(cdst, odst, LEN, ARBITRARY_DMAC_SCALAR_CONST))
av_log(NULL, AV_LOG_ERROR, "vector_dmac_scalar failed\n");
return ret;
}
| 1threat
|
How can I create Instagram like profile page in Swift : <p>I'm currently creating iOS app and having a problem with the usage of UICollectionView.
When you create Instagram-like profile page, the simple way of doing is, I guess, having a UIView on top of VC which contains user data and having a collectionView below that. But in my case, problem comes up when I scroll down collectionView. it doesn't scroll all of VC but only collectionView area scrolls down. And I have no idea how can I implement the scroll action correctly.
Thanks for your help!!</p>
| 0debug
|
Haw can I make multiple view render in Laravel : This is my code, but it is not correct to render five times in one controller, how can I get best result for this ?
public static function index($path,$data,$data_nav,$data_content)
{
$view=view($path.'.preheader_view',$data)->render();
$view.=view($path.'.header_view')->render();
$view.=view($path.'.main_navigation_view',$data_nav)->render();
$view.=view($path.'.main_content_view',$data_content)->render();
$view.=view($path.'.main_aside_view',$data)->render();
$view.=view($path.'.footer_view',$data)->render();
return $view;
}
Please show an exemple
| 0debug
|
Get public key from SSH server : <p>I'm looking for this for a long time.</p>
<p>I need to extract and get modulus and exponent from SSH server.</p>
<p>For example, I know, that on server xxx.xxx.xxx.xxx is running ssh (I can connect to this server / ping) but I dont know user name and password so cannot log in.</p>
<p>I need to get modulus and exponent of public RSA key of this server.</p>
<p>I found, that ssh-keyscan can get modulus + exponent (from documentation) but only if ssh-rsa1 is used. If I try to get ssh-rsa(2) public key with ssh-keyscan, I cannot retrieve from output modulus and exponent.</p>
<p>Is it possible ? </p>
| 0debug
|
int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, i, err;
AVStream *st;
for (;;) {
AVPacketList *pktl = s->internal->raw_packet_buffer;
if (pktl) {
*pkt = pktl->pkt;
st = s->streams[pkt->stream_index];
if (s->internal->raw_packet_buffer_remaining_size <= 0)
if ((err = probe_codec(s, st, NULL)) < 0)
return err;
if (st->request_probe <= 0) {
s->internal->raw_packet_buffer = pktl->next;
s->internal->raw_packet_buffer_remaining_size += pkt->size;
av_free(pktl);
return 0;
}
}
pkt->data = NULL;
pkt->size = 0;
av_init_packet(pkt);
ret = s->iformat->read_packet(s, pkt);
if (ret < 0) {
if (ret == FFERROR_REDO)
continue;
if (!pktl || ret == AVERROR(EAGAIN))
return ret;
for (i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
if (st->probe_packets)
if ((err = probe_codec(s, st, NULL)) < 0)
return err;
av_assert0(st->request_probe <= 0);
}
continue;
}
if (!pkt->buf) {
AVPacket tmp = { 0 };
ret = av_packet_ref(&tmp, pkt);
if (ret < 0)
return ret;
*pkt = tmp;
}
if ((s->flags & AVFMT_FLAG_DISCARD_CORRUPT) &&
(pkt->flags & AV_PKT_FLAG_CORRUPT)) {
av_log(s, AV_LOG_WARNING,
"Dropped corrupted packet (stream = %d)\n",
pkt->stream_index);
av_packet_unref(pkt);
continue;
}
if (pkt->stream_index >= (unsigned)s->nb_streams) {
av_log(s, AV_LOG_ERROR, "Invalid stream index %d\n", pkt->stream_index);
continue;
}
st = s->streams[pkt->stream_index];
if (update_wrap_reference(s, st, pkt->stream_index, pkt) && st->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET) {
if (!is_relative(st->first_dts))
st->first_dts = wrap_timestamp(st, st->first_dts);
if (!is_relative(st->start_time))
st->start_time = wrap_timestamp(st, st->start_time);
if (!is_relative(st->cur_dts))
st->cur_dts = wrap_timestamp(st, st->cur_dts);
}
pkt->dts = wrap_timestamp(st, pkt->dts);
pkt->pts = wrap_timestamp(st, pkt->pts);
force_codec_ids(s, st);
if (s->use_wallclock_as_timestamps)
pkt->dts = pkt->pts = av_rescale_q(av_gettime(), AV_TIME_BASE_Q, st->time_base);
if (!pktl && st->request_probe <= 0)
return ret;
err = add_to_pktbuf(&s->internal->raw_packet_buffer, pkt,
&s->internal->raw_packet_buffer_end, 0);
if (err)
return err;
s->internal->raw_packet_buffer_remaining_size -= pkt->size;
if ((err = probe_codec(s, st, pkt)) < 0)
return err;
}
}
| 1threat
|
how do i compare password and confirm password? please help me out : here is the code please help out.I am getting error in [final EditText etregpassword = (EditText)findViewById(R.id.etregpassword);]and please help me out with the comparsion of password and confirm password and to display the error in password miss match.thank you!!
public class RegisterActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
final EditText etregname = (EditText)findViewById(R.id.etregname);
final EditText etregemailid = (EditText)findViewById(R.id.etregemailid);
final EditText etregpassword = (EditText)findViewById(R.id.etregpassword);
final EditText etconfirmregpassword = (EditText)findViewById(R.id.etconfirmregpassword);
final Button regbutton = (Button) findViewById(R.id.regbutton);
regbutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final String User_name = etregname.getText().toString();
final String Email_id = etregemailid.getText().toString();
final String Password = etregpassword.getText().toString();
final String Confirm_password = etconfirmregpassword.getText().toString();
Response.Listener<String> responseListner = new Response.Listener<String>(){
@Override
public void onResponse(String response) {
try {
JSONObject jsonObject = new JSONObject(response);
boolean SUCCESS = jsonObject.getBoolean("success");
if(SUCCESS){
Intent intent = new Intent(RegisterActivity.this,LoginActivity.class);
RegisterActivity.this.startActivity(intent);
}
else{
AlertDialog.Builder builder = new AlertDialog.Builder(RegisterActivity.this);
builder.setMessage("Register Failed")
.setNegativeButton("Retry",null)
.create()
.show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
};
RegisterRequest registerRequest = new RegisterRequest(User_name,Email_id,Password,Confirm_password,responseListner);
RequestQueue queue= Volley.newRequestQueue(RegisterActivity.this);
queue.add(registerRequest);
}
});
}
}
| 0debug
|
static int dv_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
RawDVContext *c = s->priv_data;
c->dv_demux = dv_init_demux(s);
return c->dv_demux ? 0 : -1;
}
| 1threat
|
static void set_alarm (m48t59_t *NVRAM, struct tm *tm)
{
NVRAM->alarm = mktime(tm);
if (NVRAM->alrm_timer != NULL) {
qemu_del_timer(NVRAM->alrm_timer);
NVRAM->alrm_timer = NULL;
}
if (NVRAM->alarm - time(NULL) > 0)
qemu_mod_timer(NVRAM->alrm_timer, NVRAM->alarm * 1000);
}
| 1threat
|
void helper_vmexit(CPUX86State *env, uint32_t exit_code, uint64_t exit_info_1)
{
CPUState *cs = CPU(x86_env_get_cpu(env));
uint32_t int_ctl;
qemu_log_mask(CPU_LOG_TB_IN_ASM, "vmexit(%08x, %016" PRIx64 ", %016"
PRIx64 ", " TARGET_FMT_lx ")!\n",
exit_code, exit_info_1,
ldq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb,
control.exit_info_2)),
env->eip);
if (env->hflags & HF_INHIBIT_IRQ_MASK) {
stl_phys(cs->as,
env->vm_vmcb + offsetof(struct vmcb, control.int_state),
SVM_INTERRUPT_SHADOW_MASK);
env->hflags &= ~HF_INHIBIT_IRQ_MASK;
} else {
stl_phys(cs->as,
env->vm_vmcb + offsetof(struct vmcb, control.int_state), 0);
}
svm_save_seg(env, env->vm_vmcb + offsetof(struct vmcb, save.es),
&env->segs[R_ES]);
svm_save_seg(env, env->vm_vmcb + offsetof(struct vmcb, save.cs),
&env->segs[R_CS]);
svm_save_seg(env, env->vm_vmcb + offsetof(struct vmcb, save.ss),
&env->segs[R_SS]);
svm_save_seg(env, env->vm_vmcb + offsetof(struct vmcb, save.ds),
&env->segs[R_DS]);
stq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.gdtr.base),
env->gdt.base);
stl_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.gdtr.limit),
env->gdt.limit);
stq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.idtr.base),
env->idt.base);
stl_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.idtr.limit),
env->idt.limit);
stq_phys(cs->as,
env->vm_vmcb + offsetof(struct vmcb, save.efer), env->efer);
stq_phys(cs->as,
env->vm_vmcb + offsetof(struct vmcb, save.cr0), env->cr[0]);
stq_phys(cs->as,
env->vm_vmcb + offsetof(struct vmcb, save.cr2), env->cr[2]);
stq_phys(cs->as,
env->vm_vmcb + offsetof(struct vmcb, save.cr3), env->cr[3]);
stq_phys(cs->as,
env->vm_vmcb + offsetof(struct vmcb, save.cr4), env->cr[4]);
int_ctl = ldl_phys(cs->as,
env->vm_vmcb + offsetof(struct vmcb, control.int_ctl));
int_ctl &= ~(V_TPR_MASK | V_IRQ_MASK);
int_ctl |= env->v_tpr & V_TPR_MASK;
if (cs->interrupt_request & CPU_INTERRUPT_VIRQ) {
int_ctl |= V_IRQ_MASK;
}
stl_phys(cs->as,
env->vm_vmcb + offsetof(struct vmcb, control.int_ctl), int_ctl);
stq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.rflags),
cpu_compute_eflags(env));
stq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.rip),
env->eip);
stq_phys(cs->as,
env->vm_vmcb + offsetof(struct vmcb, save.rsp), env->regs[R_ESP]);
stq_phys(cs->as,
env->vm_vmcb + offsetof(struct vmcb, save.rax), env->regs[R_EAX]);
stq_phys(cs->as,
env->vm_vmcb + offsetof(struct vmcb, save.dr7), env->dr[7]);
stq_phys(cs->as,
env->vm_vmcb + offsetof(struct vmcb, save.dr6), env->dr[6]);
stb_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, save.cpl),
env->hflags & HF_CPL_MASK);
env->hflags2 &= ~(HF2_HIF_MASK | HF2_VINTR_MASK);
env->hflags &= ~HF_SVMI_MASK;
env->intercept = 0;
env->intercept_exceptions = 0;
cs->interrupt_request &= ~CPU_INTERRUPT_VIRQ;
env->tsc_offset = 0;
env->gdt.base = ldq_phys(cs->as, env->vm_hsave + offsetof(struct vmcb,
save.gdtr.base));
env->gdt.limit = ldl_phys(cs->as, env->vm_hsave + offsetof(struct vmcb,
save.gdtr.limit));
env->idt.base = ldq_phys(cs->as, env->vm_hsave + offsetof(struct vmcb,
save.idtr.base));
env->idt.limit = ldl_phys(cs->as, env->vm_hsave + offsetof(struct vmcb,
save.idtr.limit));
cpu_x86_update_cr0(env, ldq_phys(cs->as,
env->vm_hsave + offsetof(struct vmcb,
save.cr0)) |
CR0_PE_MASK);
cpu_x86_update_cr4(env, ldq_phys(cs->as,
env->vm_hsave + offsetof(struct vmcb,
save.cr4)));
cpu_x86_update_cr3(env, ldq_phys(cs->as,
env->vm_hsave + offsetof(struct vmcb,
save.cr3)));
cpu_load_efer(env, ldq_phys(cs->as, env->vm_hsave + offsetof(struct vmcb,
save.efer)));
env->eflags = 0;
cpu_load_eflags(env, ldq_phys(cs->as,
env->vm_hsave + offsetof(struct vmcb,
save.rflags)),
~(CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C | DF_MASK |
VM_MASK));
CC_OP = CC_OP_EFLAGS;
svm_load_seg_cache(env, env->vm_hsave + offsetof(struct vmcb, save.es),
R_ES);
svm_load_seg_cache(env, env->vm_hsave + offsetof(struct vmcb, save.cs),
R_CS);
svm_load_seg_cache(env, env->vm_hsave + offsetof(struct vmcb, save.ss),
R_SS);
svm_load_seg_cache(env, env->vm_hsave + offsetof(struct vmcb, save.ds),
R_DS);
env->eip = ldq_phys(cs->as,
env->vm_hsave + offsetof(struct vmcb, save.rip));
env->regs[R_ESP] = ldq_phys(cs->as, env->vm_hsave +
offsetof(struct vmcb, save.rsp));
env->regs[R_EAX] = ldq_phys(cs->as, env->vm_hsave +
offsetof(struct vmcb, save.rax));
env->dr[6] = ldq_phys(cs->as,
env->vm_hsave + offsetof(struct vmcb, save.dr6));
env->dr[7] = ldq_phys(cs->as,
env->vm_hsave + offsetof(struct vmcb, save.dr7));
cpu_x86_set_cpl(env, 0);
stq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, control.exit_code),
exit_code);
stq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, control.exit_info_1),
exit_info_1);
stl_phys(cs->as,
env->vm_vmcb + offsetof(struct vmcb, control.exit_int_info),
ldl_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb,
control.event_inj)));
stl_phys(cs->as,
env->vm_vmcb + offsetof(struct vmcb, control.exit_int_info_err),
ldl_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb,
control.event_inj_err)));
stl_phys(cs->as,
env->vm_vmcb + offsetof(struct vmcb, control.event_inj), 0);
env->hflags2 &= ~HF2_GIF_MASK;
cs->exception_index = -1;
env->error_code = 0;
env->old_exception = -1;
cpu_loop_exit(cs);
}
| 1threat
|
static int read_seek(AVFormatContext *s, int stream_index,
int64_t pts, int flags)
{
NUTContext *nut = s->priv_data;
AVStream *st = s->streams[stream_index];
Syncpoint dummy = { .ts = pts * av_q2d(st->time_base) * AV_TIME_BASE };
Syncpoint nopts_sp = { .ts = AV_NOPTS_VALUE, .back_ptr = AV_NOPTS_VALUE };
Syncpoint *sp, *next_node[2] = { &nopts_sp, &nopts_sp };
int64_t pos, pos2, ts;
int i;
if (nut->flags & NUT_PIPE) {
return AVERROR(ENOSYS);
}
if (st->index_entries) {
int index = av_index_search_timestamp(st, pts, flags);
if (index < 0)
index = av_index_search_timestamp(st, pts, flags ^ AVSEEK_FLAG_BACKWARD);
if (index < 0)
return -1;
pos2 = st->index_entries[index].pos;
ts = st->index_entries[index].timestamp;
} else {
av_tree_find(nut->syncpoints, &dummy, (void *) ff_nut_sp_pts_cmp,
(void **) next_node);
av_log(s, AV_LOG_DEBUG, "%"PRIu64"-%"PRIu64" %"PRId64"-%"PRId64"\n",
next_node[0]->pos, next_node[1]->pos, next_node[0]->ts,
next_node[1]->ts);
pos = ff_gen_search(s, -1, dummy.ts, next_node[0]->pos,
next_node[1]->pos, next_node[1]->pos,
next_node[0]->ts, next_node[1]->ts,
AVSEEK_FLAG_BACKWARD, &ts, nut_read_timestamp);
if (!(flags & AVSEEK_FLAG_BACKWARD)) {
dummy.pos = pos + 16;
next_node[1] = &nopts_sp;
av_tree_find(nut->syncpoints, &dummy, (void *) ff_nut_sp_pos_cmp,
(void **) next_node);
pos2 = ff_gen_search(s, -2, dummy.pos, next_node[0]->pos,
next_node[1]->pos, next_node[1]->pos,
next_node[0]->back_ptr, next_node[1]->back_ptr,
flags, &ts, nut_read_timestamp);
if (pos2 >= 0)
pos = pos2;
}
dummy.pos = pos;
sp = av_tree_find(nut->syncpoints, &dummy, (void *) ff_nut_sp_pos_cmp,
NULL);
av_assert0(sp);
pos2 = sp->back_ptr - 15;
}
av_log(NULL, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos2);
pos = find_startcode(s->pb, SYNCPOINT_STARTCODE, pos2);
avio_seek(s->pb, pos, SEEK_SET);
nut->last_syncpoint_pos = pos;
av_log(NULL, AV_LOG_DEBUG, "SP: %"PRId64"\n", pos);
if (pos2 > pos || pos2 + 15 < pos)
av_log(NULL, AV_LOG_ERROR, "no syncpoint at backptr pos\n");
for (i = 0; i < s->nb_streams; i++)
nut->stream[i].skip_until_key_frame = 1;
nut->last_resync_pos = 0;
return 0;
}
| 1threat
|
virtio_crypto_sym_op_helper(VirtIODevice *vdev,
struct virtio_crypto_cipher_para *cipher_para,
struct virtio_crypto_alg_chain_data_para *alg_chain_para,
struct iovec *iov, unsigned int out_num)
{
VirtIOCrypto *vcrypto = VIRTIO_CRYPTO(vdev);
CryptoDevBackendSymOpInfo *op_info;
uint32_t src_len = 0, dst_len = 0;
uint32_t iv_len = 0;
uint32_t aad_len = 0, hash_result_len = 0;
uint32_t hash_start_src_offset = 0, len_to_hash = 0;
uint32_t cipher_start_src_offset = 0, len_to_cipher = 0;
size_t max_len, curr_size = 0;
size_t s;
if (cipher_para) {
iv_len = ldl_le_p(&cipher_para->iv_len);
src_len = ldl_le_p(&cipher_para->src_data_len);
dst_len = ldl_le_p(&cipher_para->dst_data_len);
} else if (alg_chain_para) {
iv_len = ldl_le_p(&alg_chain_para->iv_len);
src_len = ldl_le_p(&alg_chain_para->src_data_len);
dst_len = ldl_le_p(&alg_chain_para->dst_data_len);
aad_len = ldl_le_p(&alg_chain_para->aad_len);
hash_result_len = ldl_le_p(&alg_chain_para->hash_result_len);
hash_start_src_offset = ldl_le_p(
&alg_chain_para->hash_start_src_offset);
cipher_start_src_offset = ldl_le_p(
&alg_chain_para->cipher_start_src_offset);
len_to_cipher = ldl_le_p(&alg_chain_para->len_to_cipher);
len_to_hash = ldl_le_p(&alg_chain_para->len_to_hash);
} else {
return NULL;
}
max_len = iv_len + aad_len + src_len + dst_len + hash_result_len;
if (unlikely(max_len > vcrypto->conf.max_size)) {
virtio_error(vdev, "virtio-crypto too big length");
return NULL;
}
op_info = g_malloc0(sizeof(CryptoDevBackendSymOpInfo) + max_len);
op_info->iv_len = iv_len;
op_info->src_len = src_len;
op_info->dst_len = dst_len;
op_info->aad_len = aad_len;
op_info->digest_result_len = hash_result_len;
op_info->hash_start_src_offset = hash_start_src_offset;
op_info->len_to_hash = len_to_hash;
op_info->cipher_start_src_offset = cipher_start_src_offset;
op_info->len_to_cipher = len_to_cipher;
if (op_info->iv_len > 0) {
DPRINTF("iv_len=%" PRIu32 "\n", op_info->iv_len);
op_info->iv = op_info->data + curr_size;
s = iov_to_buf(iov, out_num, 0, op_info->iv, op_info->iv_len);
if (unlikely(s != op_info->iv_len)) {
virtio_error(vdev, "virtio-crypto iv incorrect");
goto err;
}
iov_discard_front(&iov, &out_num, op_info->iv_len);
curr_size += op_info->iv_len;
}
if (op_info->aad_len > 0) {
DPRINTF("aad_len=%" PRIu32 "\n", op_info->aad_len);
op_info->aad_data = op_info->data + curr_size;
s = iov_to_buf(iov, out_num, 0, op_info->aad_data, op_info->aad_len);
if (unlikely(s != op_info->aad_len)) {
virtio_error(vdev, "virtio-crypto additional auth data incorrect");
goto err;
}
iov_discard_front(&iov, &out_num, op_info->aad_len);
curr_size += op_info->aad_len;
}
if (op_info->src_len > 0) {
DPRINTF("src_len=%" PRIu32 "\n", op_info->src_len);
op_info->src = op_info->data + curr_size;
s = iov_to_buf(iov, out_num, 0, op_info->src, op_info->src_len);
if (unlikely(s != op_info->src_len)) {
virtio_error(vdev, "virtio-crypto source data incorrect");
goto err;
}
iov_discard_front(&iov, &out_num, op_info->src_len);
curr_size += op_info->src_len;
}
op_info->dst = op_info->data + curr_size;
curr_size += op_info->dst_len;
DPRINTF("dst_len=%" PRIu32 "\n", op_info->dst_len);
if (hash_result_len > 0) {
DPRINTF("hash_result_len=%" PRIu32 "\n", hash_result_len);
op_info->digest_result = op_info->data + curr_size;
}
return op_info;
err:
g_free(op_info);
return NULL;
}
| 1threat
|
void avfilter_default_start_frame(AVFilterLink *link, AVFilterPicRef *picref)
{
AVFilterLink *out = NULL;
if(link->dst->output_count)
out = link->dst->outputs[0];
if(out) {
out->outpic = avfilter_get_video_buffer(out, AV_PERM_WRITE, link->w, link->h);
out->outpic->pts = picref->pts;
avfilter_start_frame(out, avfilter_ref_pic(out->outpic, ~0));
}
}
| 1threat
|
Running Python script via ansible : <p>I'm trying to run a python script from an ansible script. I would think this would be an easy thing to do, but I can't figure it out. I've got a project structure like this:</p>
<pre><code>playbook-folder
roles
stagecode
files
mypythonscript.py
tasks
main.yml
release.yml
</code></pre>
<p>I'm trying to run mypythonscript.py within a task in main.yml (which is a role used in release.yml). Here's the task:</p>
<pre><code>- name: run my script!
command: ./roles/stagecode/files/mypythonscript.py
args:
chdir: /dir/to/be/run/in
delegate_to: 127.0.0.1
run_once: true
</code></pre>
<p>I've also tried ../files/mypythonscript.py. I thought the path for ansible would be relative to the playbook, but I guess not?</p>
<p>I also tried debugging to figure out where I am in the middle of the script, but no luck there either.</p>
<pre><code>- name: figure out where we are
stat: path=.
delegate_to: 127.0.0.1
run_once: true
register: righthere
- name: print where we are
debug: msg="{{righthere.stat.path}}"
delegate_to: 127.0.0.1
run_once: true
</code></pre>
<p>That just prints out ".". So helpful ...</p>
| 0debug
|
(Noob) files in a .txt sorted out. : I am a really noob when it comes to this kind off stuff. I hope I can ask this question here.
I have a txt file in the txt file there are 200 names of .zip.
In my folder there are 4000.zip files. Is there a way to read the .txt and copy the 200 .zip files? I search and came with this:
$Files = Get-Content filename.txt
$Dest = "PathTo:\Desired\Folder"
foreach ($File in $Files) {
Copy-Item $File $Dest
}
This is a PowerShell, so I tried that, I don't have permission or something. So is there a .bat someone knows?
If I ask the wrong question here, I am sorry.
| 0debug
|
Alamofire network calls not being run in background thread : <p>It is my understanding that by default, Alamofire requests run in a background thread. </p>
<p>When I tried running this code:</p>
<pre><code>let productsEndPoint: String = "http://api.test.com/Products?username=testuser"
Alamofire.request(productsEndPoint, method: .get)
.responseJSON { response in
// check for errors
guard response.result.error == nil else {
// got an error in getting the data, need to handle it
print("Inside error guard")
print(response.result.error!)
return
}
// make sure we got some JSON since that's what we expect
guard let json = response.result.value as? [String: Any] else {
print("didn't get products as JSON from API")
print("Error: \(response.result.error)")
return
}
// get and print the title
guard let products = json["products"] as? [[String: Any]] else {
print("Could not get products from JSON")
return
}
print(products)
}
</code></pre>
<p>The UI was unresponsive until all the items from the network call have finished printing; so I tried using GCD with Alamofire:</p>
<pre><code>let queue = DispatchQueue(label: "com.test.api", qos: .background, attributes: .concurrent)
queue.async {
let productsEndPoint: String = "http://api.test.com/Products?username=testuser"
Alamofire.request(productsEndPoint, method: .get)
.responseJSON { response in
// check for errors
guard response.result.error == nil else {
// got an error in getting the data, need to handle it
print("Inside error guard")
print(response.result.error!)
return
}
// make sure we got some JSON since that's what we expect
guard let json = response.result.value as? [String: Any] else {
print("didn't get products as JSON from API")
print("Error: \(response.result.error)")
return
}
// get and print the title
guard let products = json["products"] as? [[String: Any]] else {
print("Could not get products from JSON")
return
}
print(products)
}
}
</code></pre>
<p>and the UI is still unresponsive as it was before.</p>
<p>Am I doing anything wrong here, or does the fault lie with Alamofire?</p>
| 0debug
|
How can I choose between Client or Pool for node-postgres : <p>From <a href="https://node-postgres.com/features/connecting" rel="noreferrer">https://node-postgres.com/features/connecting</a> , seems like we can choose between <code>Pool</code> or <code>Client</code> to perform query</p>
<pre><code>pool.query('SELECT NOW()', (err, res) => {
console.log(err, res)
pool.end()
})
</code></pre>
<hr>
<pre><code>client.query('SELECT NOW()', (err, res) => {
console.log(err, res)
client.end()
})
</code></pre>
<hr>
<p>Their functionalities look very much the same. But, the documentation doesn't explain much the difference between <code>Pool</code> and <code>Client</code>.</p>
<p>May I know, what thing I should consider, before choosing between <code>Pool</code> or <code>Client</code>?</p>
| 0debug
|
How to create 3 different types of custom cells in UITableView? : <p>I have 3 different types of custom cell, how to create teble view with different types of custom cells. </p>
| 0debug
|
Swift - Import my swift class : <p>This question is asked several times, but I can't find the right solution for my problem. I'm trying to import my <code>Player.swift</code> class in my <code>MainScene.swift</code> (I've used Cocos2D - SpriteBuilder to setup the project; Now using Xcode).</p>
<p>This is my folder structure:</p>
<p><a href="https://i.stack.imgur.com/3xiE0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3xiE0.png" alt="enter image description here"></a></p>
<p>I've tried to use <code>import Player;</code> and <code>import Player.swift;</code>, but when I tried I got this error: <strong>No such module 'Player.swift'</strong></p>
<p>How do I import it correctly?</p>
<p>Thanks!</p>
<p>By the way, I'm a beginner in Swift, so don't expect that I know all of the terms</p>
| 0debug
|
document.getElementById('input').innerHTML = user_input;
| 1threat
|
ı can't get match string with regex in nodejs : I have a string like this : <ns2:NewsPaper unitid="112234"> . I need just this part : unitid="112234" . I write a piece of code. But it returns null. Here is my code :
var value = "<ns2:NewsPaper unitid="112234">";
let abc = /NewsPaper>(\*)</.exec(value);
console.log(abc);
It returns null. Why ?
| 0debug
|
What is an opaque type in Elm and why is it valuable? : <p>I've used types before but don't know what an opaque type is. I've seen it mentioned as well. Is it better to expose an opaque type than a type alias?</p>
| 0debug
|
Reverse order blogger comments : <p>Good morning. How can I show blog comments, created with bloggers, in reverse order: from the latest to the oldest. Only for some posts. thank you</p>
| 0debug
|
static int usb_host_handle_control(USBHostDevice *s, USBPacket *p)
{
struct usbdevfs_urb *urb;
AsyncURB *aurb;
int ret, value, index;
value = le16_to_cpu(s->ctrl.req.wValue);
index = le16_to_cpu(s->ctrl.req.wIndex);
dprintf("husb: ctrl type 0x%x req 0x%x val 0x%x index %u len %u\n",
s->ctrl.req.bRequestType, s->ctrl.req.bRequest, value, index,
s->ctrl.len);
if (s->ctrl.req.bRequestType == 0) {
switch (s->ctrl.req.bRequest) {
case USB_REQ_SET_ADDRESS:
return usb_host_set_address(s, value);
case USB_REQ_SET_CONFIGURATION:
return usb_host_set_config(s, value & 0xff);
}
}
if (s->ctrl.req.bRequestType == 1 &&
s->ctrl.req.bRequest == USB_REQ_SET_INTERFACE)
return usb_host_set_interface(s, index, value);
aurb = async_alloc();
aurb->hdev = s;
aurb->packet = p;
urb = &aurb->urb;
urb->type = USBDEVFS_URB_TYPE_CONTROL;
urb->endpoint = p->devep;
urb->buffer = &s->ctrl.req;
urb->buffer_length = 8 + s->ctrl.len;
urb->usercontext = s;
ret = ioctl(s->fd, USBDEVFS_SUBMITURB, urb);
dprintf("husb: submit ctrl. len %u aurb %p\n", urb->buffer_length, aurb);
if (ret < 0) {
dprintf("husb: submit failed. errno %d\n", errno);
async_free(aurb);
switch(errno) {
case ETIMEDOUT:
return USB_RET_NAK;
case EPIPE:
default:
return USB_RET_STALL;
}
}
usb_defer_packet(p, async_cancel, aurb);
return USB_RET_ASYNC;
}
| 1threat
|
PPC_OP(extsb)
{
T0 = (int32_t)((int8_t)(Ts0));
RETURN();
}
| 1threat
|
static void usb_serial_handle_data(USBDevice *dev, USBPacket *p)
{
USBSerialState *s = (USBSerialState *)dev;
uint8_t devep = p->ep->nr;
struct iovec *iov;
uint8_t header[2];
int i, first_len, len;
switch (p->pid) {
case USB_TOKEN_OUT:
if (devep != 2)
goto fail;
for (i = 0; i < p->iov.niov; i++) {
iov = p->iov.iov + i;
qemu_chr_fe_write(s->cs, iov->iov_base, iov->iov_len);
}
p->actual_length = p->iov.size;
break;
case USB_TOKEN_IN:
if (devep != 1)
goto fail;
first_len = RECV_BUF - s->recv_ptr;
len = p->iov.size;
if (len <= 2) {
p->status = USB_RET_NAK;
break;
}
header[0] = usb_get_modem_lines(s) | 1;
if (s->event_trigger && s->event_trigger & FTDI_BI) {
s->event_trigger &= ~FTDI_BI;
header[1] = FTDI_BI;
usb_packet_copy(p, header, 2);
break;
} else {
header[1] = 0;
}
len -= 2;
if (len > s->recv_used)
len = s->recv_used;
if (!len) {
p->status = USB_RET_NAK;
break;
}
if (first_len > len)
first_len = len;
usb_packet_copy(p, header, 2);
usb_packet_copy(p, s->recv_buf + s->recv_ptr, first_len);
if (len > first_len)
usb_packet_copy(p, s->recv_buf, len - first_len);
s->recv_used -= len;
s->recv_ptr = (s->recv_ptr + len) % RECV_BUF;
break;
default:
DPRINTF("Bad token\n");
fail:
p->status = USB_RET_STALL;
break;
}
}
| 1threat
|
Git Help PLEASE : I am taking a front-end dev course on udacity.com. Currently learning git and I am stuck.
I was working on a project and I thought I was following instructions and making a branch called 'include-andras-destinations. Somehow, this branch is now part of my home directory, but I want to use a different directory to store my git projects and inside the parentheses it should be: (master), like in the attached pic.
Anyone knows how can I reset my default home directory/branch and get rid of "include-andras-destination"?
I would like udacity-git-course folder to be my master. (is that right?)
If I type:
cd /Users/ruxandravasilescu/Desktop/udacity-git-course
I get:
ruxandravasilescu (include-andras-destinations) udacity-git-course
I don't understand why is that branch always present! Otherwise, git seems set-up okay. I work on a mac.
Please help!
Below is a little infor from my terminal
ruxandravasilescu (include-andras-destinations) ~
$ cd
ruxandravasilescu (include-andras-destinations) ~
$ git init
Reinitialized existing Git repository in /Users/ruxandravasilescu/.git/
ruxandravasilescu (include-andras-destinations) ~
$ pwd
/Users/ruxandravasilescu
ruxandravasilescu (include-andras-destinations) ~
$ git status
On branch include-andras-destinations
Untracked files:
(use "git add <file>..." to include in what will be committed)
[udacity's git setup on mac looks like this and that's how my terminal initially looked also [1]
[1]: https://i.stack.imgur.com/wKhpz.png
| 0debug
|
Can I have multiple GOPATH directories? : <p>I set my GOPATH to</p>
<pre><code>/Users/me/dev/go
</code></pre>
<p>and I have</p>
<pre><code>/Users/me/dev/go/src/client1
/Users/me/dev/go/src/client2
/Users/me/dev/go/src/client3
</code></pre>
<p>and also</p>
<pre><code>/Users/me/dev/client1/rails_project
/Users/me/dev/client2/php_project
etc.
</code></pre>
<p>I don't like how in my root dev folder I'm forced to have this general "go" dir that holds many different client's go projects.</p>
| 0debug
|
Z-Index Placing Text in Front of Image : I have a section with 3 columns, the middle column has an GIF image within it, but the text at either side is behind it rather than in front.
I've tried a few z-index options with no luck, not sure where I'm going wrong on the correct way I should be using this property.
Heres what I have - I've removed z-index from CSS:
<div class="row">
<i class="icon ion-md-exit"></i>
<h2>TEXT</h2>
<p>TEXT</p>
</div>
</div>
<div class="col span-1-of-3">
<img src="resources/css/img/gif.gif">
</div>
<div class="col span-1-of-3">
<div class="row">
<i class="icon ion-md-exit"></i>
<h2>TEXT</h2>
<p>TEXT</p>
</div>
CSS
.section-all-design {
height: 100vh;
background-color: #fbfbfb;
padding: 5%;
}
.section-all-design img {
width: 190%;
margin-left: -50%;
}
Also- Whilst I'm here, I'm looking to vertically align these text boxes along each side of my GIF image, what properties do I need to add to my vertical-align to make this happen? Line-height doesn't help me.
Thanks!
| 0debug
|
avrdude: ser_open(): can't open device "/dev/ttyACM0": Device or resource busy : <p>I am Linux Mint user.I am dealing with Arduino Yun.I am compiling Arduino program.After that I am uploading to Arduino Yun.Then I get these error.Can you help me?</p>
| 0debug
|
php format json to get only values : I have an output something like in the below within an array.
Array
>Array ( [0] => Array ( [0] => T )[1] => Array ( [0] => T )) "Type";sArray ( [0] => Array ( [0] => A )[1] => Array ( [0] => A )) "Article";sArray ( [0] => Array ( [0] => B [1] => P )[1] => Array ( [0] => B [1] => P )) "Blog Post";sArray ( [0] => Array ( [0] => A [1] => M )[1] => Array ( [0] => A [1] => M )) "Artists & Makers";sArray ( [0] => Array ( [0] => V )[1] => Array ( [0] => V )) "Videos";sArray ( [0] => Array ( [0] => I [1] => T [2] => P )[1] => Array ( [0] => I [1] => T [2] => P )) "In The Press";sArray ( [0] => Array ( [0] => D [1] => Y [2] => K )[1] => Array ( [0] => D [1] => Y [2] => K )) "Did You Know ?";sArray ( [0] => Array ( [0] => G [1] => A [2] => Z )[1] => Array ( [0] => G [1] => A [2] => Z )) "Glossary A - Z";
How to format this to get only values like:
**Article**
**In The Press**
**Artists & Makers**
**Videos**
**In The Press** etc
| 0debug
|
int pt_removexattr(FsContext *ctx, const char *path, const char *name)
{
char *buffer;
int ret;
buffer = rpath(ctx, path);
ret = lremovexattr(path, name);
g_free(buffer);
return ret;
}
| 1threat
|
How to decorate text stroke in Flutter? : <p>How to decorate text stroke in Flutter?
It's like <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-text-stroke" rel="noreferrer">-webkit-text-stroke - CSS</a></p>
| 0debug
|
PHP :Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, string given : <p>i am trying to fetch data as per following query </p>
<pre><code>$query= "SELECT * FROM residential ";
if($type!=""){
$query.=" AND type='$type'";
}
if($unit_type!=""){
$query.=" AND unit_type='$unit_type'";
}
if(($min_price!="") && ($max_price!="")){
$query.=" AND price BETWEEN '$min_price' AND '$max_price' ";
}
if(($min_bedrooms!="") && ($max_bedrooms!="")){
$query.=" AND bedrooms BETWEEN '$min_bedrooms' AND '$max_bedrooms'";
}
if($query==FALSE){
echo mysqli_error($connect);
die;
}
$result= mysqli_query($connect,$query);
</code></pre>
<p>this is how i use it </p>
<pre><code><div class="row">
<?php if(mysqli_num_rows($query)>0):?>
<?php while($row= mysqli_fetch_assoc($query)):
print_r($row);
die;
?>
<div class="col-md-4 col-sm-4 col-xs-12">
<div class="row property-listing">
<div class="col-md-6 col-sm-6 col-xs-12">
<img src="images/1.png" class="img-responsive full-width">
</div>
<div class="col-md-6 col-sm-6 col-xs-12 property-desc">
<h3>AED<br/> <?php echo $row['price'];?></h3>
<h5>Unit Type: <?php echo $row['unit_type'];?></h5>
<h5>Available for :<?php echo $row['type'];?></h5>
<h5>Location :<?php echo $row['area'];?></h5>
<h5>Bedrooms :<?php echo $row['bedrooms'];?></h5>
</div>
</div>
</div>
<?php endwhile;?>
<?php else:
echo 'We found no record for your search criteria ';
echo '<a href="index.html">Refine Search</a>'
?>
<?php endif;?>
</div>
</code></pre>
<p>This is what i get as error </p>
<blockquote>
<p>( ! ) Warning: mysqli_num_rows() expects parameter 1 to be
mysqli_result, string given</p>
</blockquote>
<p>values being posted and fetched are correct but something is wrong with query , Please help me sort it out </p>
<p>Thanks </p>
| 0debug
|
What to solve Gradle sync failed? : What to solve the problem of Gradle sync failed?
I have try to click the website and dowmload jar file.
And then, I have put it in the folder, the address is:
C:\Users\TW\AndroidStudioProjects\ZenboSDK_and_SampleCode_v1.0.67.1808 test1\gradle\wrapper
Then, I open the Android Studio and build apk file. They still show this message.
Gradle sync failed: Could not find tracker.jar (com.android.tools.analytics-library:tracker:26.1.2).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/analytics-library/tracker/26.1.2/tracker-26.1.2.jar
Consult IDE log for more details (Help | Show Log) (26s 606ms)
I hope you can help me!! Thank you~~
| 0debug
|
How can I update an arrayList that contains multiple values?? Thanks : I am creating a basket that stores into an arraylist (Item key, qty and the price of the item). How can I update just the quantity and not to create another line with the same Item key.
Here is the outcome that the program below does. Thanks for your help!!1
Java Book 1 £48.90
Samsung Galaxy S7 1 £639.50
Speakers 3 £59.80
Java Book 2 £48.90
Samsung Galaxy S7 2 £639.50
//////////////////////////////////////////////////
private void ItemsBasket(String name, int qty, String key) throws HeadlessException {
if (name == null) {
JOptionPane.showMessageDialog(null, "Please Selecet a key");
String imageFileName = "./images/" + key + ".png";
File imageFile = new File(imageFileName);
if (!imageFile.exists()) {
imageFileName = "./images/empty.png";
}
} else if (qty <= StockData.getQuantity(key)) {
arList.add(StockData.getName(key) + "\t\t " + qty + " " + pounds.format(StockData.getPrice(key)));
bagtotal += StockData.getPrice(key) * qty;
JOptionPane.showMessageDialog(null, "Sucessfully added to the basket");
} else {
JOptionPane.showMessageDialog(null, "Insuffcient stock");
JOptionPane.showMessageDialog(null, "Available items qty : " + "**" + StockData.getQuantity(key) + "**");
}
}
| 0debug
|
npm package.json main and project structure : <p>I have a issue with npm and the main field. I see the documentation and as of my understanding I point main to be a different entry point than ./index.js. I already tested the package where all dist files are inside the root folder. I ignore src and test during pack phase using .npmignore but I did not like the point that building and packing the project to verify the structure pul all my files into the package root folder. So i changed the output to be dist instead.</p>
<p>If i use npm pack and extract the file I get the following structure:</p>
<pre><code>/
dist
-- index.js
-- moduleA
-- index.js
package.json
README.md
</code></pre>
<p>So for so good. But now I am forced to import it as follows:</p>
<pre><code>import {moduleA} from "myNpmModule/dist/moduleA";
</code></pre>
<p>But I dont want to have the dist folder in my import. So I set main in package.json</p>
<pre><code>"main": "dist/index.js"
</code></pre>
<p>But still it does not work and only works if I import with dist.
I use npm 3.10.7 and node 6.7.0.</p>
<p>Can anyone help?</p>
<p>Regards</p>
| 0debug
|
Need help for building a transition system in java : I'm programming a model checker in java but im stuck in designing the transition system. An object of type (int, bool, string[] or set, int[] or set) is supposed to be added to a list of states, being the transition system. It supposed to be printing the list of states and transitions like (statenumber, bool, string[] transition, new int[] state). Right now is printing only the transition object and some memoryid i guess. Looks like this : Transition@11abc1234. My question is which further improvements shall I implements to make it print (int, bool, string[] or set, int[] or set) ? Thanks in advance! Here is my code :`import java.util.*;
public class TS
{
private int i;
private boolean bool;
private static List<Transition> transitions;
State initial;
private int[] state;
TS(State initial, boolean bool, List<Transition> transitions, int[] state)
{
this.initial = initial;
this.bool = bool;
TS.transitions = transitions;
this.state = state;
}
public State getNextState(Set<Condition> conditions) {
for(Transition transition : transitions) {
//boolean currentStateMatches = transition.old.equals(initial);
//boolean conditionsMatch = transition.accepted.equals(accepted);
if(Transition.from.equals(initial) && Transition.conditions.equals(conditions)
) {
return transition.to;
}
}
return null;
}
public static void main(String[] args)
{
transitions = new Transition(1, true, new String[] {"v"}, new int[] {2});
transitions = new Transition(2, false, new String[] {"v"}, new int[] {1, 4});
transitions = new Transition(3, false, new String[] {"c"}, new int[] {3});
transitions = new Transition(4, false, new String[] {"c"}, new int[] {4});
System.out.println(transitions);
}
}
import java.util.*;
public class Transition implements List<Transition> {
private int i;
private boolean b;
private String[] strings;
private int[] js;
public Transition(int i, boolean b, String[] strings, int[] js) {
this.i = i;
this.b = b;
this.strings = strings;
this.js = js;
}
public static State from;
public static Set<Condition> conditions;
public State to;
@Override
public boolean add(Transition e) {
// TODO Auto-generated method stub
return false;
}
@Override
public void add(int index, Transition element) {
// TODO Auto-generated method stub
}
@Override
public boolean addAll(Collection<? extends Transition> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean addAll(int index, Collection<? extends Transition> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public void clear() {
// TODO Auto-generated method stub
}
@Override
public boolean contains(Object o) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean containsAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public Transition get(int index) {
// TODO Auto-generated method stub
return null;
}
@Override
public int indexOf(Object o) {
// TODO Auto-generated method stub
return 0;
}
@Override
public boolean isEmpty() {
// TODO Auto-generated method stub
return false;
}
@Override
public Iterator<Transition> iterator() {
// TODO Auto-generated method stub
return null;
}
@Override
public int lastIndexOf(Object o) {
// TODO Auto-generated method stub
return 0;
}
@Override
public ListIterator<Transition> listIterator() {
// TODO Auto-generated method stub
return null;
}
@Override
public ListIterator<Transition> listIterator(int index) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean remove(Object o) {
// TODO Auto-generated method stub
return false;
}
@Override
public Transition remove(int index) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean removeAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean retainAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public Transition set(int index, Transition element) {
// TODO Auto-generated method stub
return null;
}
@Override
public int size() {
// TODO Auto-generated method stub
return 0;
}
@Override
public List<Transition> subList(int fromIndex, int toIndex) {
// TODO Auto-generated method stub
return null;
}
@Override
public Object[] toArray() {
// TODO Auto-generated method stub
return null;
}
@Override
public <T> T[] toArray(T[] a) {
// TODO Auto-generated method stub
return null;
}
}
import java.util.*;
public class State
{
String state;
}
public class Condition {
String condition;
}
| 0debug
|
Node.js http: Parse "index of" : <p>I need to write a Node.js function that finds all available Node.js versions on the official website. To do this, I wanted to receive the content of this link: <a href="https://nodejs.org/download/release/" rel="nofollow">https://nodejs.org/download/release/</a>, but in form of an array. Is there a way how I can automagically receive and parse the available URLs via some module or do I need to request the site via <code>http</code> and then somehow parse the content manually, and if so, how?</p>
| 0debug
|
Finding all words with lenght 0 - 4 for a regular expression (method?) : my task is to do the following:
I have an alphabet consisting of 0 and 1 and a regular expression, for example: 1*(011+)*1*. Now I shall find all words of the language that have the length 0 - 4 and fit the regular expression. So the output would be:
"","1","11","011","111" ... etc.
I should not give a list of words or numbers as a parameter, but the method should generate all these words by itself.
Is there a function or method in the re. module which does exactly that?
| 0debug
|
SVG transform="rotate(180)" does not work in Safari 11 : <p>For some reason element </p>
<pre><code><svg width="1000" height="500" transform="rotate(180)">...</svg>
</code></pre>
<p>is shown as not rotated in Safari 11. </p>
<p>Chrome 63 renders it properly.</p>
<p>What's the problem?</p>
<p>Thanks!</p>
| 0debug
|
static inline void RENAME(bgr24ToUV_mmx)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src, int width, enum PixelFormat srcFormat)
{
__asm__ volatile(
"movq 24+%4, %%mm6 \n\t"
"mov %3, %%"REG_a" \n\t"
"pxor %%mm7, %%mm7 \n\t"
"1: \n\t"
PREFETCH" 64(%0) \n\t"
"movd (%0), %%mm0 \n\t"
"movd 2(%0), %%mm1 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq %%mm1, %%mm3 \n\t"
"pmaddwd %4, %%mm0 \n\t"
"pmaddwd 8+%4, %%mm1 \n\t"
"pmaddwd 16+%4, %%mm2 \n\t"
"pmaddwd %%mm6, %%mm3 \n\t"
"paddd %%mm1, %%mm0 \n\t"
"paddd %%mm3, %%mm2 \n\t"
"movd 6(%0), %%mm1 \n\t"
"movd 8(%0), %%mm3 \n\t"
"add $12, %0 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"movq %%mm1, %%mm4 \n\t"
"movq %%mm3, %%mm5 \n\t"
"pmaddwd %4, %%mm1 \n\t"
"pmaddwd 8+%4, %%mm3 \n\t"
"pmaddwd 16+%4, %%mm4 \n\t"
"pmaddwd %%mm6, %%mm5 \n\t"
"paddd %%mm3, %%mm1 \n\t"
"paddd %%mm5, %%mm4 \n\t"
"movq "MANGLE(ff_bgr24toUVOffset)", %%mm3 \n\t"
"paddd %%mm3, %%mm0 \n\t"
"paddd %%mm3, %%mm2 \n\t"
"paddd %%mm3, %%mm1 \n\t"
"paddd %%mm3, %%mm4 \n\t"
"psrad $15, %%mm0 \n\t"
"psrad $15, %%mm2 \n\t"
"psrad $15, %%mm1 \n\t"
"psrad $15, %%mm4 \n\t"
"packssdw %%mm1, %%mm0 \n\t"
"packssdw %%mm4, %%mm2 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"packuswb %%mm2, %%mm2 \n\t"
"movd %%mm0, (%1, %%"REG_a") \n\t"
"movd %%mm2, (%2, %%"REG_a") \n\t"
"add $4, %%"REG_a" \n\t"
" js 1b \n\t"
: "+r" (src)
: "r" (dstU+width), "r" (dstV+width), "g" ((x86_reg)-width), "m"(ff_bgr24toUV[srcFormat == PIX_FMT_RGB24][0])
: "%"REG_a
);
}
| 1threat
|
GcmListenerService is not called When Application is in Background : <p>GcmListenerService is not called when application is in background or when phone is locked or in sleep mode but notification is fired. How this will be called
When App is in foreground its working ideally.
Code for GcmListenerService is following </p>
<pre><code> public class MyGcmListenerService extends GcmListenerService {
private static final String TAG = "MyGcmListenerService";
LocalDataBaseManager mDbManager;
String message;
Random randomNumber;
long ID;
/**
* Called when message is received.
*
* @param from SenderID of the sender.
* @param data Data bundle containing message data as key/value pairs.
* For Set of keys use data.keySet().
*/
// [START receive_message]
@Override
public void onMessageReceived(String from, Bundle data) {
String message ;
String title;
// ID = Utils.getIDForPush("pushId",this);
// if(ID == 0){
// ID = 1;
// }else {
// ID += 1;
// }
// Utils.saveIDForPush("pushId",ID,this);
Bundle bundle = data.getBundle("notification");
if(bundle!= null){
message = bundle.getString("body");
title = bundle.getString("title");
Log.d(TAG, "From: " + from);
Log.d(TAG, "Message: " + message);}
else {
message ="";
title = "NCMS";
}
mDbManager = LocalDataBaseManager.getInstance(this);
if (from.startsWith("/topics/")) {
Calendar c = Calendar.getInstance();
SimpleDateFormat s = new SimpleDateFormat("ddMMyyyyhhmmss");
String format = s.format(new Date());
ID = Long.parseLong(format);
String date = new SimpleDateFormat("dd-MM-yyyy HH:mm", Locale.ENGLISH).format(new Date());
Warnings warnings = new Warnings();
warnings.setWARNING_ID(ID);
warnings.setWARNING_EN(message);
warnings.setWARNING_AR(message);
warnings.setSTART_DATE_TIME(date);
warnings.setNotification_type(String.valueOf(Constant.NotificationType.PUSH));
warnings.setSEVERITY("");
warnings.setEND_DATE_TIME("");
warnings.setUPDATE_NO("");
mDbManager.insertNotificationInfo(warnings);
// message received from some topic.
} else {
// normal downstream message.
}
// [START_EXCLUDE]
/**
* Production applications would usually process the message here.
* Eg: - Syncing with server.
* - Store message in local database.
* - Update UI.
*/
/**
* In some cases it may be useful to show a notification indicating to the user
* that a message was received.
*/
// KeyguardManager km = (KeyguardManager) this.getSystemService(Context.KEYGUARD_SERVICE);
// boolean locked = km.inKeyguardRestrictedInputMode();
//
// String release = android.os.Build.VERSION.RELEASE;
//
//
// if (Integer.parseInt(String.valueOf(release.charAt(0))) < 5 && locked) {
//
// this.stopService(new Intent(this, NotificationService.class));
// Intent serviceIntent = new Intent(this, NotificationService.class);
// this.startService(serviceIntent);
//
// }
sendNotification(title,message);
// [END_EXCLUDE]
}
// [END receive_message]
/**
* Create and show a simple notification containing the received GCM message.
*
* @param message GCM message received.
*/
private void sendNotification(String title,String message) {
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra("message",message);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ncms_launcher)
.setContentTitle(title)
.setContentText(message)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}
}
</code></pre>
<p>Manifest info for this service is following</p>
<pre><code> <service
android:name=".gcm.MyGcmListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
</code></pre>
<p>What I am missing here.</p>
| 0debug
|
What is the comment syntax in Yesod (hamlet) templates? : <p>I just can not find how to comment line in hamlet template. Is there some syntax for comments? Like</p>
<pre><code>-- <p>Some code should be ignored by template
</code></pre>
<p>or something?</p>
| 0debug
|
uint32_t ldl_phys(target_phys_addr_t addr)
{
return ldl_phys_internal(addr, DEVICE_NATIVE_ENDIAN);
}
| 1threat
|
static void test_dealloc_partial(void)
{
static const char text[] = "don't leak me";
UserDefTwo *ud2 = NULL;
Error *err = NULL;
{
QDict *ud2_dict;
QmpInputVisitor *qiv;
ud2_dict = qdict_new();
qdict_put_obj(ud2_dict, "string0", QOBJECT(qstring_from_str(text)));
qiv = qmp_input_visitor_new(QOBJECT(ud2_dict));
visit_type_UserDefTwo(qmp_input_get_visitor(qiv), &ud2, NULL, &err);
qmp_input_visitor_cleanup(qiv);
QDECREF(ud2_dict);
}
assert(ud2 != NULL);
assert(ud2->string0 != NULL);
assert(strcmp(ud2->string0, text) == 0);
assert(ud2->dict1 == NULL);
assert(err != NULL);
error_free(err);
qapi_free_UserDefTwo(ud2);
}
| 1threat
|
Difference between angular submit and ngSubmit events? : <p>I'm building a form in an Angular 2 application.</p>
<p>Html gives me the submit event. In Angular I could listen to this event using a (submit) event binding. On top of that, Angular adds the ngSubmit event, which I could listen to, using (ngSubmit).</p>
<p>I understand that submit comes from html, and ngSubmit from Angular. What I don't understand is why I would need to listen to a special ngSubmit event, instead of the normal submit event.</p>
<p>I created a <a href="https://plnkr.co/edit/p8XsiS2YKtNAHjuwZHqx?p=preview" rel="noreferrer">plunker</a> that listens to both events and both seem to do the same thing.</p>
<p>What is the difference between listening to (submit) and (ngSubmit)?</p>
<pre><code>@Component({
selector: 'my-app',
template: `
<form (submit)='onSubmit(form)' (ngSubmit)='onNgSubmit(form)' novalidate #form='ngForm'>
<input type='text' name='input' [(ngModel)]='input' required>
<input type='submit' value='Submit' required>
</form>
`,
})
export class App {
input : string;
onSubmit(form): void {
console.log(`submit: ${this.input}, valid: ${form.valid}`);
}
onNgSubmit(form): void {
console.log(`ng-submit: ${this.input}, valid: ${form.valid}`);
}
}
</code></pre>
| 0debug
|
int ff_pulse_audio_get_devices(AVDeviceInfoList *devices, const char *server, int output)
{
pa_mainloop *pa_ml = NULL;
pa_mainloop_api *pa_mlapi = NULL;
pa_operation *pa_op = NULL;
pa_context *pa_ctx = NULL;
enum pa_operation_state op_state;
enum PulseAudioContextState loop_state = PULSE_CONTEXT_INITIALIZING;
PulseAudioDeviceList dev_list = { 0 };
int i;
dev_list.output = output;
dev_list.devices = devices;
if (!devices)
return AVERROR(EINVAL);
devices->nb_devices = 0;
devices->devices = NULL;
if (!(pa_ml = pa_mainloop_new()))
return AVERROR(ENOMEM);
if (!(pa_mlapi = pa_mainloop_get_api(pa_ml))) {
dev_list.error_code = AVERROR_EXTERNAL;
goto fail;
}
if (!(pa_ctx = pa_context_new(pa_mlapi, "Query devices"))) {
dev_list.error_code = AVERROR(ENOMEM);
goto fail;
}
pa_context_set_state_callback(pa_ctx, pa_state_cb, &loop_state);
if (pa_context_connect(pa_ctx, server, 0, NULL) < 0) {
dev_list.error_code = AVERROR_EXTERNAL;
goto fail;
}
while (loop_state == PULSE_CONTEXT_INITIALIZING)
pa_mainloop_iterate(pa_ml, 1, NULL);
if (loop_state == PULSE_CONTEXT_FINISHED) {
dev_list.error_code = AVERROR_EXTERNAL;
goto fail;
}
if (output)
pa_op = pa_context_get_sink_info_list(pa_ctx, pulse_audio_sink_device_cb, &dev_list);
else
pa_op = pa_context_get_source_info_list(pa_ctx, pulse_audio_source_device_cb, &dev_list);
while ((op_state = pa_operation_get_state(pa_op)) == PA_OPERATION_RUNNING)
pa_mainloop_iterate(pa_ml, 1, NULL);
if (op_state != PA_OPERATION_DONE)
dev_list.error_code = AVERROR_EXTERNAL;
pa_operation_unref(pa_op);
if (dev_list.error_code < 0)
goto fail;
pa_op = pa_context_get_server_info(pa_ctx, pulse_server_info_cb, &dev_list);
while ((op_state = pa_operation_get_state(pa_op)) == PA_OPERATION_RUNNING)
pa_mainloop_iterate(pa_ml, 1, NULL);
if (op_state != PA_OPERATION_DONE)
dev_list.error_code = AVERROR_EXTERNAL;
pa_operation_unref(pa_op);
if (dev_list.error_code < 0)
goto fail;
devices->default_device = -1;
for (i = 0; i < devices->nb_devices; i++) {
if (!strcmp(devices->devices[i]->device_name, dev_list.default_device)) {
devices->default_device = i;
break;
}
}
fail:
av_free(dev_list.default_device);
if(pa_ctx)
pa_context_disconnect(pa_ctx);
if (pa_ctx)
pa_context_unref(pa_ctx);
if (pa_ml)
pa_mainloop_free(pa_ml);
return dev_list.error_code;
}
| 1threat
|
Form input submit to table with this data : <p>Helou,
I have a form like this </p>
<pre><code><form id="some" data-request="checkout" class="checkoutForm">
<div class="form-group mb10">
<label for="firstName" class="col-sm-12">Name <span class="color-main">*</span></label>
<input class="form-control checkout-form-border" id="firstName" value="" type="text">
</div>
<div class="form-group mb10">
<label for="Address" class="col-sm-12">Address <span class="color-main">*</span></label>
<input class="form-control checkout-form-border" id="address" value="" type="text">
</div>
etc etc ....
</form>
</code></pre>
<p>Now, I want on submit button show new page with collected data from this form in a table body.
Can I do this via php and jquery or new custom component?
Thanx</p>
| 0debug
|
sentence substitution with ruby using .gsub : Now what if I'm trying to change just parts of a word? Like "Car" to "cah", or vise versa in "Martha" to "Marther". In the second case, if I just did an if like this:
`<if sentance.include? "er"
user_input.gsub!(/er/, "a")
end >`
It would take all "a"'s in "MArthA", which is not what I want.
Any ideas?
For other examples.
http://stackoverflow.com/questions/8381499/replace-words-in-string-ruby/39671330?noredirect=1#comment66644316_39671330
| 0debug
|
I don't understand why "Null pointer Exception" in Unity? : <p>in my C# lives class I have a class attribute:
public int life = 0;
and in my C# loose class (so, another script), I want to access to my life attribute of my lives class, but i don't succeed, how to do it ?</p>
<p>When I do</p>
<pre><code>var lv = new lives ();
int lv1 = lv.life;
</code></pre>
<p>It shows me that Unity does not allow. I MUST use GetComponent</p>
<p>so I do with get component</p>
<pre><code>var lv = gameObject.GetComponent<lives> ();
int lv1 = lv.life;
</code></pre>
<p>And I have a null pointer exception, so it is not understandable ?</p>
| 0debug
|
static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev,
struct XenDevOps *ops)
{
struct XenDevice *xendev;
char *dom0;
xendev = xen_be_find_xendev(type, dom, dev);
if (xendev) {
return xendev;
}
xendev = g_malloc0(ops->size);
xendev->type = type;
xendev->dom = dom;
xendev->dev = dev;
xendev->ops = ops;
dom0 = xs_get_domain_path(xenstore, 0);
snprintf(xendev->be, sizeof(xendev->be), "%s/backend/%s/%d/%d",
dom0, xendev->type, xendev->dom, xendev->dev);
snprintf(xendev->name, sizeof(xendev->name), "%s-%d",
xendev->type, xendev->dev);
free(dom0);
xendev->debug = debug;
xendev->local_port = -1;
xendev->evtchndev = xen_xc_evtchn_open(NULL, 0);
if (xendev->evtchndev == XC_HANDLER_INITIAL_VALUE) {
xen_be_printf(NULL, 0, "can't open evtchn device\n");
g_free(xendev);
return NULL;
}
fcntl(xc_evtchn_fd(xendev->evtchndev), F_SETFD, FD_CLOEXEC);
if (ops->flags & DEVOPS_FLAG_NEED_GNTDEV) {
xendev->gnttabdev = xen_xc_gnttab_open(NULL, 0);
if (xendev->gnttabdev == XC_HANDLER_INITIAL_VALUE) {
xen_be_printf(NULL, 0, "can't open gnttab device\n");
xc_evtchn_close(xendev->evtchndev);
g_free(xendev);
return NULL;
}
} else {
xendev->gnttabdev = XC_HANDLER_INITIAL_VALUE;
}
QTAILQ_INSERT_TAIL(&xendevs, xendev, next);
if (xendev->ops->alloc) {
xendev->ops->alloc(xendev);
}
return xendev;
}
| 1threat
|
Why does Gradle not look in the local maven repository for plugins? : <p>I have built a Gradle plugin and published it to the local maven repository. I can see it in my ~/.m2/repository. However, when I run a Gradle project to use this plugin, it does not even look in the local repository...at least, not based on the output.</p>
<p>It reports this when running from the command-line:</p>
<blockquote>
<p>FAILURE: Build failed with an exception.</p>
<p>Where: Build file 'D:\Work\MuseProject\update4j-gradle-plugin\example\build.gradle'
line: 15</p>
<p>What went wrong: Plugin [id: 'net.christophermerrill.gradle.update4j', version: '0.1'] was not
found in any of the following sources:</p>
<p>-- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)</p>
<p>-- Plugin Repositories (could not resolve plugin artifact 'net.christophermerrill.gradle.update4j:net.christophermerrill.gradle.update4j.gradle.plugin:0.1')</p>
<p>Searched in the following repositories:
Gradle Central Plugin Repository</p>
</blockquote>
<p>I have added mavenLocal() to the buildscript configuration. I also tried adding the specific dependency (as was suggested elsewhere) with no effect</p>
<pre><code>buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath 'net.christophermerrill:update4j-gradle-plugin:0.1'
}
}
</code></pre>
<p>Best I can tell from the output, it is not even looking in the local repository, but I am not 100% sure. Using the --scan and --info options does not provide any additional insights - they appear to do nothing at all, which I suspect is because the failure appears before the plugins finish loading (just guessing).</p>
<p>Is there a way to determine if Gradle is looking in the local Maven repo? I am trying to eliminate this as a possibility. The alternative, of course, is that my plugin is not published correctly. That will be my next question, after I settle this one :)</p>
| 0debug
|
Get timezone from users browser using moment(timezone).js : <p>What is the best way to get client's timezone and convert it to some other timezone when using moment.js and moment-timezone.js</p>
<p>I want to find out what is clients timezone and later convert his date and time into some other timezone.</p>
<p>Does anybody has experience with this?</p>
| 0debug
|
int av_grow_packet(AVPacket *pkt, int grow_by)
{
int new_size;
av_assert0((unsigned)pkt->size <= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE);
if ((unsigned)grow_by >
INT_MAX - (pkt->size + AV_INPUT_BUFFER_PADDING_SIZE))
return -1;
new_size = pkt->size + grow_by + AV_INPUT_BUFFER_PADDING_SIZE;
if (pkt->buf) {
size_t data_offset;
uint8_t *old_data = pkt->data;
if (pkt->data == NULL) {
data_offset = 0;
pkt->data = pkt->buf->data;
} else {
data_offset = pkt->data - pkt->buf->data;
if (data_offset > INT_MAX - new_size)
return -1;
}
if (new_size + data_offset > pkt->buf->size) {
int ret = av_buffer_realloc(&pkt->buf, new_size + data_offset);
if (ret < 0) {
pkt->data = old_data;
return ret;
}
pkt->data = pkt->buf->data + data_offset;
}
} else {
pkt->buf = av_buffer_alloc(new_size);
if (!pkt->buf)
return AVERROR(ENOMEM);
memcpy(pkt->buf->data, pkt->data, pkt->size);
pkt->data = pkt->buf->data;
}
pkt->size += grow_by;
memset(pkt->data + pkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
return 0;
}
| 1threat
|
Move Image from one DB to another MySQL with PHP : I need to move an image (blob field) from a MySQL database to another that are located on two different servers.
I tried to get blob field from the first database and I tried to upload the second, but something went wrong (no errors showing, btw).
```php
/* SERVER #1 */
/* connection to server1... */
$sql_u="SELECT PHOTO, PHOTO_NAME FROM database1 WHERE ID='1'";
$query_u = mysqli_query($conn, $sql_u);
$record_u = mysqli_fetch_array($query_u);
$photo = $record_u['PHOTO'];
$photo_name = $record_u['PHOTO_NAME'];
/* SERVER #2 */
/* connection to server2... */
$sql_i = "UPDATE database2 SET PHOTO = '$photo', PHOTO_NAME = '$photo_name' WHERE ID='1'";
$query_i = mysqli_query($conn, $sql_i);
```
I need to update the second database with the BLOB field of the first one. I tried to use base64_encode() but still not work. I think I have to handle the BLOB field in some way, but I don't know how.
PHOTO : BLOB TYPE
PHOTO_NAME : VARCHAR TYPE
| 0debug
|
Glide Cache does not persist when app is killed : <p>I'm monitoring my web calls with Charles.</p>
<p>I have a GlideModule changing cache folder by overriding applyOption(...) like this : </p>
<pre><code> @Override
public void applyOptions(Context context, GlideBuilder builder) {
builder.setDiskCache(
new InternalCacheDiskCacheFactory(context, "/media/", 1500000)
);
}
</code></pre>
<p>Then, I do my Glide images loads and the cache works just fine while I'm in the app. Here is an example : </p>
<pre><code>Glide.with(this)
.load("http://www.wired.com/wp-content/uploads/2015/09/google-logo.jpg")
.into(mImageView);
</code></pre>
<p>Only the first call make a web call and then it use cache to retrieve it.
However, if I kill the app then relaunch it, instead of continuing to use the cache, the app make a new web call.
Isn't the cache supposed to be persistent inside the Internal storage ? </p>
| 0debug
|
static void RENAME(mix8to2)(SAMPLE **out, const SAMPLE **in, COEFF *coeffp, integer len){
int i;
for(i=0; i<len; i++) {
INTER t = in[2][i]*coeffp[0*8+2] + in[3][i]*coeffp[0*8+3];
out[0][i] = R(t + in[0][i]*(INTER)coeffp[0*8+0] + in[4][i]*(INTER)coeffp[0*8+4] + in[6][i]*(INTER)coeffp[0*8+6]);
out[1][i] = R(t + in[1][i]*(INTER)coeffp[1*8+1] + in[5][i]*(INTER)coeffp[1*8+5] + in[7][i]*(INTER)coeffp[1*8+7]);
}
}
| 1threat
|
Module 'tensorflow' has no attribute 'contrib' : <p>I am trying to train my own custom object detector using Tensorflow Object-Detection-API </p>
<p>I installed the tensorflow using "pip install tensorflow" in my google compute engine. Then I followed all the instructions on this site: <a href="https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html" rel="noreferrer">https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html</a> </p>
<p>When I try to use train.py I am getting this error message:</p>
<blockquote>
<p>Traceback (most recent call last):
File "train.py", line 49, in
from object_detection.builders import dataset_builder
File "/usr/local/lib/python3.6/dist-packages/object_detection-0.1->py3.6.egg/object_detection/builders/dataset_builder.py", line 27, in
from object_detection.data_decoders import tf_example_decoder
File "/usr/local/lib/python3.6/dist-packages/object_detection-0.1-py3.6.egg/object_detection/data_decoders/tf_example_decoder.py", line 27, in
slim_example_decoder = tf.contrib.slim.tfexample_decoder
AttributeError: module 'tensorflow' has no attribute 'contrib'</p>
</blockquote>
<p>Also I am getting different results when I try to learn version of tensorflow.</p>
<blockquote>
<p>python3 -c 'import tensorflow as tf; print(tf.<strong>version</strong>)' : 2.0.0-dev20190422</p>
</blockquote>
<p>and when I use</p>
<blockquote>
<p>pip3 show tensorflow: </p>
<p>Name: tensorflow
Version: 1.13.1
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: <a href="https://www.tensorflow.org/" rel="noreferrer">https://www.tensorflow.org/</a>
Author: Google Inc.
Author-email: opensource@google.com
License: Apache 2.0
Location: /usr/local/lib/python3.6/dist-packages
Requires: gast, astor, absl-py, tensorflow-estimator, keras-preprocessing, grpcio, six, keras-applications, wheel, numpy, tensorboard, protobuf, termcolor
Required-by: </p>
</blockquote>
<pre><code> sudo python3 train.py --logtostderr --train_dir=training/ --
pipeline_config_path=training/ssd_inception_v2_coco.config
</code></pre>
<p>What should I do to solve this problem? I couldn't find anything about this error message except this: <a href="https://stackoverflow.com/questions/38238192/tensorflow-module-object-has-no-attribute-contrib">tensorflow 'module' object has no attribute 'contrib'</a></p>
| 0debug
|
Why i am getting unsinged integer after adding two 16 bit integers : I am a newbie to golang, actually, I am new to type based programming. I have only knowledge of JS.
While to going through simple examples in golang tuts. I found that adding a1 + a2 provides a unsgined integer value ?
var a1 int16 = 127
var a2 int16 = 32767
var rr int16 = a1 + a2
fmt.Println(rr)
Result:
-32642
Excepted:
1. The compiler will throw an error as a exceeded the int16 max.
2. ( OR ) GO automatically convert the int16 to int32.
3. 32,894
Can you guys explain why it is showing -32642.
| 0debug
|
Which is the best way to make web application? : <p>I'm new to web development and I want to make some small web applications like a video downloaders, an document converter, and that sort of apps. I know that I can use either a JavaScript framework (react, vue, or angular) or php (laravel) but I'm confused which one is best suited for this situation.</p>
<p>I don't know if the this is the right place to ask this kind of questions but I want to know your opinion, so should I go with JavaScript or go the php route? I'll appreciate you help guys and thanks.</p>
| 0debug
|
For loop is executed asynchronously in javascript? : <p>In my example below, why does it log 512, rather than 1? I understand javascript is synchronous, so shouldn't the logging occur long before the for loop completes? For this reason, I was expecting result = 1 when logged.</p>
<pre><code>let result = 1;
for (counter = 1; counter < 10; counter ++) {
result = result * 2;
}
console.log(result);
</code></pre>
| 0debug
|
.txt function not linking to main function : <p>I am making a program with a list of baby names but I've decided to make a seperate function to open the file, this is what I have got so far.</p>
<pre><code>#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void open_file(ifstream& in, char fileName[]);
void find_name(ifstream& in, string name, int numNames);
int main() {
const int NUMNAMES = 1000;
ifstream inStream;
char fileName[30];
string name;
cout << "Enter the name of the file that contains the names: " << endl;
open_file(inStream, fileName);
cout << "Enter the name to search for (capitalize first letter): " << endl;
cin >> name;
find_name(inStream, name, NUMNAMES);
inStream.close();
}
void open_file(ifstream& ) {
string line;
ifstream myfile ("babyNames.txt");
if (myfile.is_open())
{
while ( getline (myfile,line) )
{
cout << line << '\n';
}
myfile.close();
}
else cout << "I/O failure opening file babyNames";
}
</code></pre>
<p>Does anyone know why I am getting so many error messages:</p>
<pre><code>Undefined symbols for architecture x86_64:
"find_name(std::__1::basic_ifstream<char, std::__1::char_traits<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int)", referenced from:
_main in Untitled-1b6d2e.o
"open_file(std::__1::basic_ifstream<char, std::__1::char_traits<char> >&, char*)", referenced from:
_main in Untitled-1b6d2e.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
</code></pre>
<p>Does anyone know what I am doing wrong, I feel like it is relatively close I'm just fairly new to streams in c++.</p>
| 0debug
|
static GuestPCIAddress *get_pci_info(char *guid, Error **errp)
{
HDEVINFO dev_info;
SP_DEVINFO_DATA dev_info_data;
DWORD size = 0;
int i;
char dev_name[MAX_PATH];
char *buffer = NULL;
GuestPCIAddress *pci = NULL;
char *name = g_strdup(&guid[4]);
if (!QueryDosDevice(name, dev_name, ARRAY_SIZE(dev_name))) {
error_setg_win32(errp, GetLastError(), "failed to get dos device name");
goto out;
}
dev_info = SetupDiGetClassDevs(&GUID_DEVINTERFACE_VOLUME, 0, 0,
DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
if (dev_info == INVALID_HANDLE_VALUE) {
error_setg_win32(errp, GetLastError(), "failed to get devices tree");
goto out;
}
dev_info_data.cbSize = sizeof(SP_DEVINFO_DATA);
for (i = 0; SetupDiEnumDeviceInfo(dev_info, i, &dev_info_data); i++) {
DWORD addr, bus, slot, func, dev, data, size2;
while (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data,
SPDRP_PHYSICAL_DEVICE_OBJECT_NAME,
&data, (PBYTE)buffer, size,
&size2)) {
size = MAX(size, size2);
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
g_free(buffer);
buffer = g_malloc(size * 2);
} else {
error_setg_win32(errp, GetLastError(),
"failed to get device name");
goto out;
}
}
if (g_strcmp0(buffer, dev_name)) {
continue;
}
if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data,
SPDRP_BUSNUMBER, &data, (PBYTE)&bus, size, NULL)) {
break;
}
if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data,
SPDRP_ADDRESS, &data, (PBYTE)&addr, size, NULL)) {
break;
}
if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data,
SPDRP_UI_NUMBER, &data, (PBYTE)&slot, size, NULL)) {
break;
}
func = addr & 0x0000FFFF;
dev = (addr >> 16) & 0x0000FFFF;
pci = g_malloc0(sizeof(*pci));
pci->domain = dev;
pci->slot = slot;
pci->function = func;
pci->bus = bus;
break;
}
out:
g_free(buffer);
g_free(name);
return pci;
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.