problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Python3: If ... else .... ignored when checking Json attribute existance : I have the following python3 code to check if a attribute is in a Json (or has a value different than null)
def has_attribute(data, attribute):
return (attribute in data) and (data[attribute] is not None)
This is the function which checks that the attribute is in the json and has a value different than null.
if has_attribute(json_request,"offer_id"):
print("IT IS")
else:
print("NO")
The thing is that when I pass a Json it doesn't print nothing!
Why?
| 0debug
|
uint64_t helper_fres (uint64_t arg)
{
CPU_DoubleU fone, farg;
float32 f32;
fone.ll = 0x3FF0000000000000ULL;
farg.ll = arg;
if (unlikely(float64_is_signaling_nan(farg.d))) {
farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN);
} else if (unlikely(float64_is_zero(farg.d))) {
farg.ll = float_zero_divide_excp(fone.d, farg.d);
} else {
farg.d = float64_div(fone.d, farg.d, &env->fp_status);
f32 = float64_to_float32(farg.d, &env->fp_status);
farg.d = float32_to_float64(f32, &env->fp_status);
}
return farg.ll;
}
| 1threat
|
static int cmp(const void *key, const void *node)
{
return (*(const int64_t *) key) - ((const CacheEntry *) node)->logical_pos;
}
| 1threat
|
void qdev_unplug(DeviceState *dev, Error **errp)
{
DeviceClass *dc = DEVICE_GET_CLASS(dev);
if (!dev->parent_bus->allow_hotplug) {
error_set(errp, QERR_BUS_NO_HOTPLUG, dev->parent_bus->name);
return;
}
assert(dc->unplug != NULL);
qdev_hot_removed = true;
if (dc->unplug(dev) < 0) {
error_set(errp, QERR_UNDEFINED_ERROR);
return;
}
}
| 1threat
|
void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
qemu_irq sci_irq, qemu_irq cmos_s3)
{
memory_region_init(&pm->io, "ich9-pm", ICH9_PMIO_SIZE);
memory_region_set_enabled(&pm->io, false);
memory_region_add_subregion(pci_address_space_io(lpc_pci),
0, &pm->io);
acpi_pm_tmr_init(&pm->acpi_regs, ich9_pm_update_sci_fn, &pm->io);
acpi_pm1_evt_init(&pm->acpi_regs, ich9_pm_update_sci_fn, &pm->io);
acpi_pm1_cnt_init(&pm->acpi_regs, &pm->io);
acpi_gpe_init(&pm->acpi_regs, ICH9_PMIO_GPE0_LEN);
memory_region_init_io(&pm->io_gpe, &ich9_gpe_ops, pm, "apci-gpe0",
ICH9_PMIO_GPE0_LEN);
memory_region_add_subregion(&pm->io, ICH9_PMIO_GPE0_STS, &pm->io_gpe);
memory_region_init_io(&pm->io_smi, &ich9_smi_ops, pm, "apci-smi",
8);
memory_region_add_subregion(&pm->io, ICH9_PMIO_SMI_EN, &pm->io_smi);
pm->irq = sci_irq;
qemu_register_reset(pm_reset, pm);
pm->powerdown_notifier.notify = pm_powerdown_req;
qemu_register_powerdown_notifier(&pm->powerdown_notifier);
}
| 1threat
|
Writing audio to server over TCP socket : <p>I'm trying to transmit real time mic recording to server over TCP socket and server to write input stream to a file.
The connection is established but after some time, I'm getting connection refused error at my clientside.</p>
<p>Server Code:</p>
<pre><code> public class auServer extends Thread{
private static ServerSocket serverSocket;
private static int port = 3333;
public void run()
{
System.out.println("init success");
while(true)
{
try
{
serverSocket = new ServerSocket(port);
serverSocket.setSoTimeout(10000);
Socket clientSoc = serverSocket.accept();
System.out.println("Waiting for client on port " +serverSocket.getLocalPort() + "...");
System.out.println("Just connected to " + clientSoc.getRemoteSocketAddress());
InputStream in = clientSoc.getInputStream();
while(in!=null)
{
writeToFile(in);
}
System.out.println("socket");
clientSoc.close();
}catch(SocketTimeoutException s)
{
System.out.println("Socket timed out!");
break;
}catch(IOException e)
{
e.printStackTrace();
System.out.println("some io");
break;
} catch (Exception e) {
System.out.println("some e");
e.printStackTrace();
}
}
}
private void writeToFile(InputStream in) throws IOException {
// Write the output audio in byte
String filePath = "8k16bitMono1.wav";
short sData[] = new short[1024];
byte[] bData = IOUtils.toByteArray(in);
FileOutputStream os = null;
try {
os = new FileOutputStream(filePath);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
System.out.println("Short wirting to file" + sData.toString());
try {
os.write(bData, 0, 2048);
} catch (IOException e) {
e.printStackTrace();
}
try {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
try
{
Thread serverThread = new auServer();
serverThread.run();
System.out.println("runing");
}catch(IOException e){
e.printStackTrace();
}
}
}
</code></pre>
<p>and Client :</p>
<pre><code>private void streamData(byte[] bData) throws UnknownHostException, IOException, InterruptedException { //bData is byte array to transmit
Thread.sleep(500);
Socket client = new Socket("10.221.40.41",3333);
OutputStream outToServer = client.getOutputStream();
outToServer.write(bData);
if(!isRecording)
client.close();
}
</code></pre>
<p>What could be the problem?
Thanks in advance.</p>
| 0debug
|
lua odd table behaviour : In my code, I set a variable to the contents of a table, like so:
colorTable = {{255, 255, 255}}
color = colorTable[1]
My problem is when I edit the value of `color` it changes the original value in `colorTable`
so in the beginning, `colorTable[1][1]` equals `255`, but after I run this:
color[1] = color[1] - 10
`colorTable[1][1]` equals `245`.
Any help is appreciated.
| 0debug
|
Run opencv scripts as a part of a python program : I wish to run scripts from the OpenCV repository (Specifically from
[https://github.com/opencv/opencv/tree/master/samples/dnn][1]
), as a part of a Python program.
What is the best way doing so?
Can I import the relevant files as a part of the cv package?
thanks
[1]: https://github.com/opencv/opencv/tree/master/samples/dnn
| 0debug
|
Is there any way to get the live chat replay log/history for YouTube streaming video? : <p>Recently I'm doing research for online chat message patterns. I chose YouTube and Twitch.tv for chat message sources.</p>
<p>So I found chat loggers for real-time livestream, but I also need log/history for already broadcasted livestream which allows live chat replay. (like <a href="https://www.youtube.com/watch?v=1JfohG5a8y8" rel="noreferrer">https://www.youtube.com/watch?v=1JfohG5a8y8</a> )</p>
<p>There are tool for Twitch.tv (<a href="https://github.com/jdpurcell/RechatTool" rel="noreferrer">RechatTool from jdpurcell</a>), but I couldn't find any similar one of them for YouTube.</p>
<p>So I checked <a href="https://developers.google.com/youtube/v3/live/docs/liveChatMessages/list" rel="noreferrer"> YouTube API for livestream messages</a>, but I couldn't find any instructions or tips for live chat replay. Is there any possible solutions for this?</p>
| 0debug
|
static void virtio_blk_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->init = virtio_blk_init_pci;
k->exit = virtio_blk_exit_pci;
k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
k->device_id = PCI_DEVICE_ID_VIRTIO_BLOCK;
k->revision = VIRTIO_PCI_ABI_VERSION;
k->class_id = PCI_CLASS_STORAGE_SCSI;
dc->alias = "virtio-blk";
dc->reset = virtio_pci_reset;
dc->props = virtio_blk_properties;
}
| 1threat
|
How to make volumes permanent with Docker Compose v2 : <p><em>I realize other people have had similar questions but this uses v2 compose file format and I didn't find anything for that.</em></p>
<p>I want to make a very simple test app to play around with MemSQL but I can't get volumes to not get deleted after <code>docker-compose down</code>. If I've understood Docker Docs right, volumes shouldn't be deleted without explicitly telling it to. Everything seems to work with <code>docker-compose up</code> but after going down and then up again all data gets deleted from the database.</p>
<p>As recommended as a good practice, I'm using separate memsqldata service as a separate data layer.</p>
<p>Here's my docker-compose.yml:</p>
<pre><code>version: '2'
services:
app:
build: .
links:
- memsql
memsql:
image: memsql/quickstart
volumes_from:
- memsqldata
ports:
- "3306:3306"
- "9000:9000"
memsqldata:
image: memsql/quickstart
command: /bin/true
volumes:
- memsqldatavolume:/data
volumes:
memsqldatavolume:
driver: local
</code></pre>
| 0debug
|
Xcode 9 - Test target X encountered an error (Unable to connect to Test Manager) : <p>I'm trying to run some of my Unit Tests but it kept giving me error:</p>
<pre><code>Showing Recent Issues
Test target X encountered an error (Unable to connect to test manager on d7306c4130298fbc17bc0985ec02f808dcdc1374 If you believe this error represents a bug, please attach the log file at /var/folders/2h/0y4yjs6s7l307mbr6pk1xdl00000gn/T/com.apple.dt.XCTest/IDETestRunSession-CF80FA05-C8ED-4FCE-A04B-4A8070F21059/X-E8F39B10-0CDC-43D5-9BED-CD2D0F6081DA/Session-X-2018-01-08_161733-D3YlRc.log)
</code></pre>
<p>I've tried searching for this type of error but to no avail. Anybody got any ideas? </p>
| 0debug
|
static target_ulong get_psr(void)
{
helper_compute_psr();
#if !defined (TARGET_SPARC64)
return env->version | (env->psr & PSR_ICC) |
(env->psref? PSR_EF : 0) |
(env->psrpil << 8) |
(env->psrs? PSR_S : 0) |
(env->psrps? PSR_PS : 0) |
(env->psret? PSR_ET : 0) | env->cwp;
#else
return env->version | (env->psr & PSR_ICC) |
(env->psref? PSR_EF : 0) |
(env->psrpil << 8) |
(env->psrs? PSR_S : 0) |
(env->psrps? PSR_PS : 0) | env->cwp;
#endif
}
| 1threat
|
Install udunits2 package for R3.3 : <p>I just wasted the whole day trying to figure out how to install the udunits2 package to be able to install the units package to be able to install the ggforce and ggraph packages.</p>
<p>I'm trying to install it on Ubuntu 16.04, and R >= 3.3 since ggforce was built under R 3.3. </p>
<p>I followed these instructions here:
<a href="https://github.com/edzer/units/issues/1" rel="noreferrer">https://github.com/edzer/units/issues/1</a></p>
<p>Although I have libudunits-2.0 and udunits installed on my machine (as sudo apt-get install udunits2 doesn't find a udunits2 package), and the PATH to the libudunits-2 and udunits locations on my $PATH, in R when I try installing udunits2, units or ggforce I'm getting an error that says,</p>
<pre><code>--* installing *source* package ‘udunits2’ ...
** package ‘udunits2’ successfully unpacked and MD5 sums checked
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for XML_ParserCreate in -lexpat... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking udunits2.h usability... no
checking udunits2.h presence... no
checking for udunits2.h... no
checking for ut_read_xml in -ludunits2... no
-----Error: libudunits2.a not found-----
If the udunits2 library is installed in a non-standard location,
use --configure-args='--with-udunits2-lib=/usr/local/lib' for
example,
or --configure-args='--with-udunits2-include=/usr/include/udunits2'
replacing paths with appropriate values for your installation.
You can alternatively use the UDUNITS2_INCLUDE and UDUNITS2_LIB
environment variables.
If udunits2 is not installed, please install it.
It is required for this package.
ERROR: configuration failed for package ‘udunits2’
* removing ‘/home/fjay/R/x86_64-pc-linux-gnu-library/3.3/udunits2’
* restoring previous ‘/home/fjay/R/x86_64-pc-linux-gnu-library
/3.3/udunits2’
The downloaded source packages are in
‘/tmp/Rtmp0syxnJ/downloaded_packages’
Warning message:
In install.packages("udunits2", lib = "/home/fjay/R/x86_64-pc-linux-
gnu-library/3.3") :
installation of package ‘udunits2’ had non-zero exit status
>
</code></pre>
<p>So, umm, it's looking for the udunits2.h and libudunits2.a files....
So, I downloaded udunits2 from CRAN, unpacked it and put it in my R library.
Then, if I put library(udunits2, lib.loc = "my library dir") I get an error saying it's not installed. So, when I install.package('udunits2', repo = NULL, libconfig.args = '--with-udunits2-lib=/home/fjay/R/x86_64-pc-linux-gnu-library/3.3') or install.packages('units',....) or install.packages('ggforce',...) it is still looking for these files...and, after inspection of the udunits2 package these files are not in any of the udunits2 folders.</p>
<p>If anyone knows how to install this udunits2 packages please help me! </p>
| 0debug
|
Puppeteer check through website content/elements : <p>I need to check through the elements of the website for my code, but I can't understand how to do it with puppeteer on Node.JS
<br>Here's the code I tried:</p>
<pre><code>if(page.content('input[data-kwimpalaid="1580983806648-1"]'))
found = true
if(found = true)
console.log("I found it")
if(found = false)
console.log("I didn't found it")
</code></pre>
<p>So what I need basically, I have a website with element ID's ending in 1 to 20, and it can be random, and consecutive. For example it may start at 1, then has 6 ids (1,2,3,4,5,6) or it can start at 5 (5,6,7,8,9,10). I want to check for every ID, and if it exists then change the value of ''found'' to <code>true</code>. If the page doesn't have id 1, try id 2, id 3, id 4, etc.. until it finds an input with that ID/CLASS that exists on that website.</p>
<p><br><br>Shortly, I need to check if the selector element I use exists on the website or not (content).</p>
| 0debug
|
Adding to an array in swift : i'm trying to add a string named "temp" to the end of an array named "fourth_degree" with the following swift code:
fourth_degree.append(temp)
But keep getting the following error:
"Cannot use mutating member on immutable value: "fourth_degree" is a 'let' constant.
| 0debug
|
static void fmod_write_sample (HWVoiceOut *hw, uint8_t *dst, int dst_len)
{
int src_len1 = dst_len;
int src_len2 = 0;
int pos = hw->rpos + dst_len;
st_sample_t *src1 = hw->mix_buf + hw->rpos;
st_sample_t *src2 = NULL;
if (pos > hw->samples) {
src_len1 = hw->samples - hw->rpos;
src2 = hw->mix_buf;
src_len2 = dst_len - src_len1;
pos = src_len2;
}
if (src_len1) {
hw->clip (dst, src1, src_len1);
}
if (src_len2) {
dst = advance (dst, src_len1 << hw->info.shift);
hw->clip (dst, src2, src_len2);
}
hw->rpos = pos % hw->samples;
}
| 1threat
|
excel VBA to find correct formula to get result from hexcode : I have some missing data where I need to workout the formula used to convert a code to a hex file and vice versa. The codes below are some examples of a complete set , I was trying to find a way to get the result from column A to column B , when that is found then compare it with row 2 if that is okay then row 3. when all criteria are matched then provide the formula used. Examples are below
A00875 101AK
A00F82 1027U
A01040 103EC
A01829 105KA
A01DD2 1063U
| 0debug
|
Sql and oracle apex : [THIS IS MY TABLE.][1]
[1]: https://i.stack.imgur.com/eDy9u.png
[AND I WANT A REPORT LIKE THIS.][2]
[2]: https://i.stack.imgur.com/g9WWd.png
| 0debug
|
static int kvm_get_xsave(CPUState *env)
{
#ifdef KVM_CAP_XSAVE
struct kvm_xsave* xsave;
int ret, i;
uint16_t cwd, swd, twd, fop;
if (!kvm_has_xsave())
return kvm_get_fpu(env);
xsave = qemu_memalign(4096, sizeof(struct kvm_xsave));
ret = kvm_vcpu_ioctl(env, KVM_GET_XSAVE, xsave);
if (ret < 0) {
qemu_free(xsave);
return ret;
}
cwd = (uint16_t)xsave->region[0];
swd = (uint16_t)(xsave->region[0] >> 16);
twd = (uint16_t)xsave->region[1];
fop = (uint16_t)(xsave->region[1] >> 16);
env->fpstt = (swd >> 11) & 7;
env->fpus = swd;
env->fpuc = cwd;
for (i = 0; i < 8; ++i)
env->fptags[i] = !((twd >> i) & 1);
env->mxcsr = xsave->region[XSAVE_MXCSR];
memcpy(env->fpregs, &xsave->region[XSAVE_ST_SPACE],
sizeof env->fpregs);
memcpy(env->xmm_regs, &xsave->region[XSAVE_XMM_SPACE],
sizeof env->xmm_regs);
env->xstate_bv = *(uint64_t *)&xsave->region[XSAVE_XSTATE_BV];
memcpy(env->ymmh_regs, &xsave->region[XSAVE_YMMH_SPACE],
sizeof env->ymmh_regs);
qemu_free(xsave);
return 0;
#else
return kvm_get_fpu(env);
#endif
}
| 1threat
|
"The SSL certificate contains a common name (CN) that does not match the hostname." in VSTS Deployment : <p>I am using VSTS to deploy to an Azure VM. In my release definition, I receive the following error when trying to copy files over:</p>
<blockquote>
<p>The SSL certificate contains a common name (CN) that does not match
the hostname. For more information, see the
about_Remote_Troubleshooting Help topic.To fix WinRM connection
related issues, select the 'Enable Copy Prerequisites' option in the
task. If set already, and the target Virtual Machines are backed by a
Load balancer, ensure Inbound NAT rules are configured for target port
(5986). Applicable only for ARM VMs. For more info please refer to
<a href="https://aka.ms/azurefilecopyreadme" rel="noreferrer">https://aka.ms/azurefilecopyreadme</a>};]</p>
</blockquote>
<p>I am not using a load balancer. I noticed that the issue occurs whenever I add a DNS name label for my VM in the Azure portal (in the public IP settings).</p>
| 0debug
|
Jupyter magic to handle notebook exceptions : <p>I have a few long-running experiments in my Jupyter Notebooks. Because I don't know when they will finish, I add an email function to the last cell of the notebook, so I automatically get an email, when the notebook is done.</p>
<p>But when there is a random exception in one of the cells, the whole notebook stops executing and I never get any email. <strong>So I'm wondering if there is some magic function that could execute a function in case of an exception / kernel stop.</strong></p>
<p>Like</p>
<pre><code>def handle_exception(stacktrace):
send_mail_to_myself(stacktrace)
%%in_case_of_notebook_exception handle_exception # <--- this is what I'm looking for
</code></pre>
<p>The other option would be to encapsulate every cell in try-catch, right? But that's soooo tedious.</p>
<p>Thanks in advance for any suggestions.</p>
| 0debug
|
connection.query('SELECT * FROM users WHERE username = ' + input_string)
| 1threat
|
React.js: submit form programmatically does not trigger onSubmit event : <p>I want to submit a React form after a click on a link.</p>
<p>To do so I need to submit the form programmatically if the link is clicked.</p>
<p><strong>my problem is : <code>onSubmit</code> handler is not being fired after the form submit .</strong></p>
<p>Here is a code snipped that I made for this purpose: </p>
<pre><code>var MyForm = React.createClass({
handleSubmit: function(e){
console.log('Form submited');
e.preventDefault();
},
submitForm : function(e){
this.refs.formToSubmit.submit();
},
render: function() {
return (
<form ref="formToSubmit" onSubmit={this.handleSubmit}>
<input name='myInput'/>
<a onClick={this.submitForm}>Validate</a>
</form>);
}
});
ReactDOM.render(
<MyForm name="World" />,
document.getElementById('container')
);
</code></pre>
<p>The <code>handleSubmit</code> is not invoked and the default behavior is executed (the form being submitted).
Is this a ReactJs bug or a normal behavior?
Is there a way to get the onSubmit handler invoked ?</p>
| 0debug
|
static int qxl_post_load(void *opaque, int version)
{
PCIQXLDevice* d = opaque;
uint8_t *ram_start = d->vga.vram_ptr;
QXLCommandExt *cmds;
int in, out, i, newmode;
dprint(d, 1, "%s: start\n", __FUNCTION__);
assert(d->last_release_offset < d->vga.vram_size);
if (d->last_release_offset == 0) {
d->last_release = NULL;
} else {
d->last_release = (QXLReleaseInfo *)(ram_start + d->last_release_offset);
}
d->modes = (QXLModes*)((uint8_t*)d->rom + d->rom->modes_offset);
dprint(d, 1, "%s: restore mode (%s)\n", __FUNCTION__,
qxl_mode_to_string(d->mode));
newmode = d->mode;
d->mode = QXL_MODE_UNDEFINED;
switch (newmode) {
case QXL_MODE_UNDEFINED:
break;
case QXL_MODE_VGA:
qxl_enter_vga_mode(d);
break;
case QXL_MODE_NATIVE:
for (i = 0; i < NUM_MEMSLOTS; i++) {
if (!d->guest_slots[i].active) {
continue;
}
qxl_add_memslot(d, i, 0, QXL_SYNC);
}
qxl_create_guest_primary(d, 1, QXL_SYNC);
cmds = g_malloc0(sizeof(QXLCommandExt) * (NUM_SURFACES + 1));
for (in = 0, out = 0; in < NUM_SURFACES; in++) {
if (d->guest_surfaces.cmds[in] == 0) {
continue;
}
cmds[out].cmd.data = d->guest_surfaces.cmds[in];
cmds[out].cmd.type = QXL_CMD_SURFACE;
cmds[out].group_id = MEMSLOT_GROUP_GUEST;
out++;
}
cmds[out].cmd.data = d->guest_cursor;
cmds[out].cmd.type = QXL_CMD_CURSOR;
cmds[out].group_id = MEMSLOT_GROUP_GUEST;
out++;
qxl_spice_loadvm_commands(d, cmds, out);
g_free(cmds);
break;
case QXL_MODE_COMPAT:
qxl_set_mode(d, d->shadow_rom.mode, 1);
break;
}
dprint(d, 1, "%s: done\n", __FUNCTION__);
return 0;
}
| 1threat
|
Django, Security and Settings : <p>From <a href="https://docs.djangoproject.com/en/1.10/ref/settings/#databases" rel="noreferrer">here</a>, we add all database info as text:</p>
<pre><code>DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'mydatabase',
'USER': 'mydatabaseuser',
'PASSWORD': 'mypassword',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
</code></pre>
<p>Is it a secure way? Is there any way to save this data as Encrypted data?</p>
| 0debug
|
static void virtio_scsi_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
{
VirtIOSCSI *s = (VirtIOSCSI *)vdev;
VirtIOSCSIReq *req;
if (s->ctx && !s->dataplane_started) {
virtio_scsi_dataplane_start(s);
return;
}
while ((req = virtio_scsi_pop_req(s, vq))) {
virtio_scsi_handle_ctrl_req(s, req);
}
}
| 1threat
|
Qt: Program is crashing when deleting central widget of QMainWindow in destructor : <p>I am learning Qt. Currently I stuck at layout stuff for <code>QMainWindow</code>. As suggested in some of examples available on internet i used <code>QWidget</code> to be used in <code>setCentralWidget(QWidget*)</code> method of QMainWindow. But as part of clean up when i am deleting central <code>QWidget</code> the program is crashing.</p>
<p>here is the code for .h</p>
<pre><code>class MyMainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MyMainWindow(QWidget *parent = 0);
~MyMainWindow();
private:
QVBoxLayout m_p1_level_vbox;
QHBoxLayout m_p2_level_vbox;
QHBoxLayout m_p2_level_hbox;
QWidget* m_central_widget;
QPushButton* m_increase_pressure;
QPushButton* m_decrease_pressure;
};
</code></pre>
<p>for .cpp</p>
<pre><code>MyMainWindow::MyMainWindow(QWidget *parent)
: QMainWindow(parent)
, m_central_widget(new QWidget(this))
, m_increase_pressure(new QPushButton("+", this))
, m_decrease_pressure(new QPushButton("-", this))
{
m_p2_level_hbox.addWidget(m_increase_pressure);
m_p2_level_hbox.addWidget(m_decrease_pressure);
m_p1_level_vbox.addLayout(&m_p2_level_hbox);
m_central_widget->setLayout(&m_p1_level_vbox);
setCentralWidget(m_central_widget);
}
MyMainWindow::~MyMainWindow()
{
delete m_central_widget; // commenting this line doesn't crash the program
delete m_increase_pressure;
delete m_decrease_pressure;
}
</code></pre>
<p>main.cpp</p>
<pre><code>int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MyMainWindow w;
w.show();
return a.exec();
}
</code></pre>
<p>In destructor if i don't delete <code>m_central_widget</code> then it works.</p>
<p>What i am doing wrong here?</p>
| 0debug
|
How to fix my non-starting little game app? : <p>I have to do a little game for my school, and I'm stuck in my program. When I launch the app it's working fine, but when I want to start a new game by the menubar, it says that the game is starting, but it isn't. I think the program is stuck in my FenRPS::newGame() function, but I don't know how to fix it.</p>
<pre><code>FenRPS::FenRPS() : wxFrame( NULL, wxID_ANY, "Rock–paper–scissors",
wxDefaultPosition, wxSize(607,650), wxCAPTION|wxCLOSE_BOX|wxCLIP_CHILDREN )
{
this->SetBackgroundColour( wxColor( 240,240,240 ));
this->SetIcon( wxIcon( AppRPS::Icone_xpm ));
//================ MENU ================
wxMenuItem* item;
#define Item( menu, fctEvenement, texte, aide ) \
item = menu->Append( wxID_ANY, texte, aide ); \
menu->Bind( wxEVT_MENU, fctEvenement, this, item->GetId() );
#define Separateur( menu ) menu->AppendSeparator();
menuGame = new wxMenu;
Item( menuGame, newGame, "&New Game", "Create a new game" );
Separateur( menuGame );
Item( menuGame, exit, "Exit", "Exit the game" );
menuAbout = new wxMenu;
Item( menuAbout, about, "&About", "Display app informations" );
menuBar = new wxMenuBar;
menuBar->Append( menuGame, "&Game" );
menuBar->Append( menuAbout, "&About" );
this->SetMenuBar( menuBar );
//=============== BOUTONS ==============
rock_png = new wxStaticBitmap(this, wxID_ANY, wxBitmap("img/rock.png",
wxBITMAP_TYPE_PNG), wxPoint(54,400), wxSize(128,128));
buttonRock.Create( this, wxID_ANY, "R O C K", wxPoint(54,538), wxSize(128,50));
buttonRock.Bind( wxEVT_BUTTON, playedRock, this );
paper_png = new wxStaticBitmap(this, wxID_ANY,
wxBitmap("img/paper.png", wxBITMAP_TYPE_PNG), wxPoint(236,400), wxSize(128,128));
buttonPaper.Create( this, wxID_ANY, "P A P E R", wxPoint(236,538), wxSize(128,50));
buttonPaper.Bind( wxEVT_BUTTON, playedPaper, this );
scissors_png = new wxStaticBitmap(this, wxID_ANY,
wxBitmap("img/scissors.png", wxBITMAP_TYPE_PNG), wxPoint(418,400), wxSize(128,128));
buttonScissors.Create( this, wxID_ANY, "S C I S S O R S", wxPoint(418,538), wxSize(128,50));
buttonScissors.Bind( wxEVT_BUTTON, playedScissors, this );
stTextBox = new wxStaticText;
stTextBox->Create( this, wxID_ANY, "\nWelcome in the Rock-Paper-Scissors game\n\n\n\nNo game is in progress", wxPoint(10,10), wxSize(580,364), wxALIGN_CENTRE_HORIZONTAL);
stTextBox->SetBackgroundColour( *wxLIGHT_GREY );
stTextBox->SetFont( wxFont( wxFontInfo(12).FaceName("Arial").Bold()));
if( hasPlayed )
{
srand(time(0));
choiceBot = (rand()%3)+1;
message << "Round n°" << nbrRound << "\n";
stTextBox->SetLabel( message );
if (choicePlayer == 1 && choiceBot == 1) message << message << "Equality\n\n\n";
else if (choicePlayer == 1 && choiceBot == 2)
{
message << message << "Round lost, the bot has made 'paper'\n\n\n";
scoreBot++;
}
else if (choicePlayer == 1 && choiceBot == 3)
{
message << message << "Round win, the bot had made 'scissors'\n\n\n";
scorePlayer++;
}
else if (choicePlayer == 2 && choiceBot == 1)
{
message << message << "Round win, the bot had made 'rock'\n\n\n";
scorePlayer++;
}
else if (choicePlayer == 2 && choiceBot == 2) message << message << "Equality\n\n\n";
else if (choicePlayer == 2 && choiceBot == 3)
{
message << message << "Round lost, the bot has made 'scissors'\n\n\n";
scoreBot++;
}
else if (choicePlayer == 3 && choiceBot == 1)
{
message << message << "Round lost, the bot has made 'rock'\n\n\n";
scoreBot++;
}
else if (choicePlayer == 3 && choiceBot == 2)
{
message << message << "Round win, the bot had made 'paper'\n\n\n";
scorePlayer++;
}
else if (choicePlayer == 3 && choiceBot == 3) message << message << "Equality\n\n\n";
stTextBox->SetLabel( message );
nbrRound++;
hasPlayed = false;
}
if( nbrRound > 5 )
{
message << "The game is over\n\n"
<< "Score :\n"
<< ">> Player : " << scorePlayer
<< "\n>> Computer : " << scoreBot;
if (scoreBot == scorePlayer)
message << message << "Equality. Try again\n";
else if (scoreBot > scorePlayer)
message << message << "You lost, you'll be luckier next time\n";
else if (scorePlayer > scoreBot)
message << message << "You won, congratulations !\n";
stTextBox->SetLabel( message );
wxSleep(2);
}
}
FenRPS::~FenRPS() {}
void FenRPS::playedRock( wxCommandEvent& ) { choicePlayer = 1; hasPlayed = true; }
void FenRPS::playedPaper( wxCommandEvent& ) { choicePlayer = 2; hasPlayed = true; }
void FenRPS::playedScissors( wxCommandEvent& ) { choicePlayer = 3; hasPlayed = true; }
void FenRPS::newGame( wxCommandEvent& )
{
stTextBox->SetLabel( "\nThe game is starting..." );
}
</code></pre>
| 0debug
|
Windows: Auto start PM2 and node apps : <p>At a Windows AWS server i have a NODE app and
i'm using PM2 to launch the app</p>
<p>I have tried the NPMs: "pm2-windows-startup" and "pm2-windows-service"</p>
<p>But after i restart my AWS instance and run</p>
<pre><code>PM2 ls
</code></pre>
<p>No node app shows up in the list...</p>
<p><strong>I followed the instructions ...</strong></p>
<ol>
<li>Installed the NPM (So PM2 auto start after reboot)</li>
<li>PM2 start myApp.js --name mySuperApp</li>
<li>PM2 save</li>
<li>Reboot</li>
<li>PM2 ls --> no running node apps? :-(</li>
</ol>
<p><strong>The PM2 logs dont contain any thing...</strong></p>
<p>I have not added any ENV variables explicit (when i tried PM2 could not start any more - so i created a fresh AWS windows instance and installed every thing from scratch again...)</p>
<p>PM2 is located the default place (i have not changed any paths)</p>
<pre><code>C:\Users\Administrator\.pm2
</code></pre>
<p><strong>My PM2 file contains:</strong></p>
<p>2017-03-13 07:37:48: ===============================================================================
2017-03-13 07:37:48:
--- New PM2 Daemon started ----------------------------------------------------</p>
<p>2017-03-13 07:37:48: Time : Mon Mar 13 2017 07:37:48 GMT+0000 (Coordinated Universal Time)
2017-03-13 07:37:48:
PM2 version : 2.4.2
2017-03-13 07:37:48: Node.js version : 6.10.0
2017-03-13 07:37:48:
Current arch : x64
2017-03-13 07:37:48: PM2 home : C:\Users\Administrator.pm2
2017-03-13 07:37:48:
PM2 PID file : C:\Users\Administrator.pm2\pm2.pid
2017-03-13 07:37:48:
RPC socket file : \.\pipe\rpc.sock
2017-03-13 07:37:48:
BUS socket file : \.\pipe\pub.sock
2017-03-13 07:37:48:
Application log path : C:\Users\Administrator.pm2\logs
2017-03-13 07:37:48:
Process dump file : C:\Users\Administrator.pm2\dump.pm2
2017-03-13 07:37:48:
Concurrent actions : 2
2017-03-13 07:37:48:
SIGTERM timeout : 1600
2017-03-13 07:37:48: ===============================================================================</p>
<p>2017-03-13 07:37:48: Starting execution sequence in -fork mode- for app name:mySuperApp id:0
2017-03-13 07:37:48:
App name:mySuperApp id:0 online
2017-03-13 07:40:45: ===============================================================================</p>
<p>2017-03-13 07:40:45: --- New PM2 Daemon started ----------------------------------------------------
2017-03-13 07:40:45:
Time : Mon Mar 13 2017 07:40:45 GMT+0000 (Coordinated Universal Time)
2017-03-13 07:40:45:
PM2 version : 2.4.2
2017-03-13 07:40:45: Node.js version : 6.10.0
2017-03-13 07:40:45:
Current arch : x64
2017-03-13 07:40:45: PM2 home : C:\Users\Administrator.pm2
2017-03-13 07:40:45:
PM2 PID file : C:\Users\Administrator.pm2\pm2.pid
2017-03-13 07:40:45: RPC socket file : \.\pipe\rpc.sock
2017-03-13 07:40:45:
BUS socket file : \.\pipe\pub.sock
2017-03-13 07:40:45: Application log path : C:\Users\Administrator.pm2\logs
2017-03-13 07:40:45:
Process dump file : C:\Users\Administrator.pm2\dump.pm2
2017-03-13 07:40:45: Concurrent actions : 2
2017-03-13 07:40:45:
SIGTERM timeout : 1600
2017-03-13 07:40:45: ===============================================================================</p>
<p><strong>My PM2 DUMB file contains:</strong></p>
<p>[
{
"exec_mode": "fork_mode",
"watch": false,
"treekill": true,
"autorestart": true,
"automation": true,
"pmx": true,
"vizion": true,
"name": "mySuperApp",
"node_args": [],
"pm_exec_path": "c:\mypath\mySuperApp\server.js",
"env": {
"windir": "C:\Windows",
"USERPROFILE": "C:\Users\Administrator",
"USERNAME": "Administrator",
"USERDOMAIN_ROAMINGPROFILE": "EC2AMAZ-REBQJDK",
"USERDOMAIN": "EC2AMAZ-REBQJDK",
"TMP": "C:\Users\ADMINI~1\AppData\Local\Temp\2",
"TEMP": "C:\Users\ADMINI~1\AppData\Local\Temp\2",
"SystemRoot": "C:\Windows",
"SystemDrive": "C:",
"SESSIONNAME": "RDP-Tcp#1",
"PUBLIC": "C:\Users\Public",
"PSModulePath": "C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\AWS Tools\PowerShell\",
"PROMPT": "$P$G",
"ProgramW6432": "C:\Program Files",
"ProgramFiles(x86)": "C:\Program Files (x86)",
"ProgramFiles": "C:\Program Files",
"ProgramData": "C:\ProgramData",
"PROCESSOR_REVISION": "3f02",
"PROCESSOR_LEVEL": "6",
"PROCESSOR_IDENTIFIER": "Intel64 Family 6 Model 63 Stepping 2, GenuineIntel",
"PROCESSOR_ARCHITECTURE": "AMD64",
"PM2_USAGE": "CLI",
"PM2_INTERACTOR_PROCESSING": "true",
"PATHEXT": ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JSE;.WSF;.WSH;.MSC",
"Path": "C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Amazon\cfn-bootstrap\;C:\Program Files\nodejs\;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\AppData\Roaming\npm",
"OS": "Windows_NT",
"NUMBER_OF_PROCESSORS": "1",
"LOGONSERVER": "\\EC2AMAZ-REBQJDK",
"LOCALAPPDATA": "C:\Users\Administrator\AppData\Local",
"HOMEPATH": "\Users\Administrator",
"HOMEDRIVE": "C:",
"ComSpec": "C:\Windows\system32\cmd.exe",
"COMPUTERNAME": "EC2AMAZ-REBQJDK",
"CommonProgramW6432": "C:\Program Files\Common Files",
"CommonProgramFiles(x86)": "C:\Program Files (x86)\Common Files",
"CommonProgramFiles": "C:\Program Files\Common Files",
"CLIENTNAME": "THESILVERFOX",
"APPDATA": "C:\Users\Administrator\AppData\Roaming",
"ALLUSERSPROFILE": "C:\ProgramData",
"PM2_HOME": "C:\Users\Administrator\.pm2",
"mySuperApp": {}
},
"pm_cwd": "c:\mypath\mySuperApp",
"exec_interpreter": "node",
"pm_out_log_path": "C:\Users\Administrator\.pm2\logs\mySuperApp-out-0.log",
"pm_err_log_path": "C:\Users\Administrator\.pm2\logs\mySuperApp-error-0.log",
"pm_pid_path": "C:\Users\Administrator\.pm2\pids\mySuperApp-0.pid",
"km_link": false,
"NODE_APP_INSTANCE": 0,
"vizion_running": false,
"windir": "C:\Windows",
"USERPROFILE": "C:\Users\Administrator",
"USERNAME": "Administrator",
"USERDOMAIN_ROAMINGPROFILE": "EC2AMAZ-REBQJDK",
"USERDOMAIN": "EC2AMAZ-REBQJDK",
"TMP": "C:\Users\ADMINI~1\AppData\Local\Temp\2",
"TEMP": "C:\Users\ADMINI~1\AppData\Local\Temp\2",
"SystemRoot": "C:\Windows",
"SystemDrive": "C:",
"SESSIONNAME": "RDP-Tcp#1",
"PUBLIC": "C:\Users\Public",
"PSModulePath": "C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\AWS Tools\PowerShell\",
"PROMPT": "$P$G",
"ProgramW6432": "C:\Program Files",
"ProgramFiles(x86)": "C:\Program Files (x86)",
"ProgramFiles": "C:\Program Files",
"ProgramData": "C:\ProgramData",
"PROCESSOR_REVISION": "3f02",
"PROCESSOR_LEVEL": "6",
"PROCESSOR_IDENTIFIER": "Intel64 Family 6 Model 63 Stepping 2, GenuineIntel",
"PROCESSOR_ARCHITECTURE": "AMD64",
"PM2_USAGE": "CLI",
"PM2_INTERACTOR_PROCESSING": "true",
"PATHEXT": ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JSE;.WSF;.WSH;.MSC",
"Path": "C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Amazon\cfn-bootstrap\;C:\Program Files\nodejs\;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\AppData\Roaming\npm",
"OS": "Windows_NT",
"NUMBER_OF_PROCESSORS": "1",
"LOGONSERVER": "\\EC2AMAZ-REBQJDK",
"LOCALAPPDATA": "C:\Users\Administrator\AppData\Local",
"HOMEPATH": "\Users\Administrator",
"HOMEDRIVE": "C:",
"ComSpec": "C:\Windows\system32\cmd.exe",
"COMPUTERNAME": "EC2AMAZ-REBQJDK",
"CommonProgramW6432": "C:\Program Files\Common Files",
"CommonProgramFiles(x86)": "C:\Program Files (x86)\Common Files",
"CommonProgramFiles": "C:\Program Files\Common Files",
"CLIENTNAME": "THESILVERFOX",
"APPDATA": "C:\Users\Administrator\AppData\Roaming",
"ALLUSERSPROFILE": "C:\ProgramData",
"PM2_HOME": "C:\Users\Administrator\.pm2",
"status": "online",
"pm_uptime": 1489390668484,
"axm_actions": [],
"axm_monitor": {
"Loop delay": {
"alert": {},
"agg_type": "avg",
"value": "36.91ms"
}
},
"axm_options": {
"default_actions": true,
"transactions": false,
"http": false,
"http_latency": 200,
"http_code": 500,
"ignore_routes": [],
"profiling": true,
"errors": true,
"alert_enabled": true,
"custom_probes": true,
"network": false,
"ports": false,
"ignoreFilter": {
"method": [
"OPTIONS"
],
"url": []
},
"excludedHooks": [],
"module_conf": {},
"module_name": "mySuperApp",
"module_version": "2.4.2",
"pmx_version": "1.0.3",
"error": true
},
"axm_dynamic": {},
"created_at": 1489390668484,
"restart_time": 0,
"unstable_restarts": 0,
"versioning": null,
"node_version": "6.10.0"
}
]</p>
| 0debug
|
Flutter: How can I make a Random color generator Background : <blockquote>
<p>Generate random colors </p>
</blockquote>
<pre><code>return new RaisedButton(
padding: EdgeInsets.symmetric(vertical: 30.0),
color: Colors.primaries random List <blue,green>,
</code></pre>
| 0debug
|
void address_space_init_dispatch(AddressSpace *as)
{
AddressSpaceDispatch *d = g_new(AddressSpaceDispatch, 1);
d->phys_map = (PhysPageEntry) { .ptr = PHYS_MAP_NODE_NIL, .is_leaf = 0 };
d->listener = (MemoryListener) {
.begin = mem_begin,
.region_add = mem_add,
.region_nop = mem_add,
.priority = 0,
};
d->as = as;
as->dispatch = d;
memory_listener_register(&d->listener, as);
}
| 1threat
|
Angular 2 - Bindings cannot contain assignments : <p>I need to give a class to a <code><tr></code> if a property of item has the same value as a property from an object in an array.</p>
<p>Here's the <strong>code</strong> I currently have:</p>
<pre><code><tr *ngFor="let item of closingDayGroupsList" [class.inactive]="definitionDetails.Groups.filter(i => i.AbsenceReservationGroupID === item.ID).length > 0">
</code></pre>
<p>however now I receive the <strong>error</strong>:</p>
<pre><code>Bindings cannot contain assignments
</code></pre>
<p>I'm not sure if what I'm doing is bad practice, or if I'm just making syntax errors. </p>
<p>This is the only way I know to achieve what I want, but it's not working</p>
| 0debug
|
static uint64_t musicpal_misc_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
switch (offset) {
case MP_MISC_BOARD_REVISION:
return MP_BOARD_REVISION;
default:
return 0;
}
}
| 1threat
|
What is this error >State updates from the useState() and useReducer() Hooks don't support the second callback argument.? : The sentence that i pasted in the tittle is what i got from my code, im triying to make a change over the state in an array , using hooks, this is my code.
export default function card(){
let array = [true,false]
const [change, setChange]=useState(array)
console.log(change, change.length, camchangebio[0])
function toggleIcon() {
setChange(
...change,
change[0]=!change[0]
)
console.log(change)
}
return(
</Fragment>
{ cambio[0] ? (<p>hi</p>): (<p>bye</p>)}
</Fragment>
)
}
whit this i got the firts change, i change hi to bye... but when i click it again, y got this error MyContracts.js:18
> Uncaught TypeError: change is not iterable
| 0debug
|
ASP.net core MVC catch all route serve static file : <p>Is there a way to make a catch all route serve a static file?</p>
<p>Looking at this <a href="http://blog.nbellocam.me/2016/03/21/routing-angular-2-asp-net-core/" rel="noreferrer">http://blog.nbellocam.me/2016/03/21/routing-angular-2-asp-net-core/</a></p>
<p>I basically want something like this:</p>
<pre><code> app.UseMvc(routes =>
{
routes.MapRoute("default", "{controller}/{action=Index}");
routes.MapRoute("spa", "{*url}"); // This should serve SPA index.html
});
</code></pre>
<p>So any route that doesn't match an MVC controller will serve up <code>wwwroot/index.html</code></p>
| 0debug
|
static void setup_frame_v1(int usig, struct target_sigaction *ka,
target_sigset_t *set, CPUARMState *regs)
{
struct sigframe_v1 *frame;
abi_ulong frame_addr = get_sigframe(ka, regs, sizeof(*frame));
int i;
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
return;
setup_sigcontext(&frame->sc, regs, set->sig[0]);
for(i = 1; i < TARGET_NSIG_WORDS; i++) {
if (__put_user(set->sig[i], &frame->extramask[i - 1]))
goto end;
}
setup_return(regs, ka, &frame->retcode, frame_addr, usig,
frame_addr + offsetof(struct sigframe_v1, retcode));
end:
unlock_user_struct(frame, frame_addr, 1);
}
| 1threat
|
static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val)
{
#define CASE_SET_REG24(name, addr) \
case addr : s->name &= 0xffffff00; s->name |= val; break; \
case addr + 1: s->name &= 0xffff00ff; s->name |= val << 8; break; \
case addr + 2: s->name &= 0xff00ffff; s->name |= val << 16; break;
#define CASE_SET_REG32(name, addr) \
case addr : s->name &= 0xffffff00; s->name |= val; break; \
case addr + 1: s->name &= 0xffff00ff; s->name |= val << 8; break; \
case addr + 2: s->name &= 0xff00ffff; s->name |= val << 16; break; \
case addr + 3: s->name &= 0x00ffffff; s->name |= val << 24; break;
#ifdef DEBUG_LSI_REG
DPRINTF("Write reg %x = %02x\n", offset, val);
#endif
switch (offset) {
case 0x00:
s->scntl0 = val;
if (val & LSI_SCNTL0_START) {
BADF("Start sequence not implemented\n");
}
break;
case 0x01:
s->scntl1 = val & ~LSI_SCNTL1_SST;
if (val & LSI_SCNTL1_IARB) {
BADF("Immediate Arbritration not implemented\n");
}
if (val & LSI_SCNTL1_RST) {
if (!(s->sstat0 & LSI_SSTAT0_RST)) {
BusChild *kid;
QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) {
DeviceState *dev = kid->child;
device_reset(dev);
}
s->sstat0 |= LSI_SSTAT0_RST;
lsi_script_scsi_interrupt(s, LSI_SIST0_RST, 0);
}
} else {
s->sstat0 &= ~LSI_SSTAT0_RST;
}
break;
case 0x02:
val &= ~(LSI_SCNTL2_WSR | LSI_SCNTL2_WSS);
s->scntl2 = val;
break;
case 0x03:
s->scntl3 = val;
break;
case 0x04:
s->scid = val;
break;
case 0x05:
s->sxfer = val;
break;
case 0x06:
if ((val & 0xf) != (s->ssid & 0xf))
BADF("Destination ID does not match SSID\n");
s->sdid = val & 0xf;
break;
case 0x07:
break;
case 0x08:
s->sfbr = val;
break;
case 0x0a: case 0x0b:
return;
case 0x0c: case 0x0d: case 0x0e: case 0x0f:
return;
CASE_SET_REG32(dsa, 0x10)
case 0x14:
s->istat0 = (s->istat0 & 0x0f) | (val & 0xf0);
if (val & LSI_ISTAT0_ABRT) {
lsi_script_dma_interrupt(s, LSI_DSTAT_ABRT);
}
if (val & LSI_ISTAT0_INTF) {
s->istat0 &= ~LSI_ISTAT0_INTF;
lsi_update_irq(s);
}
if (s->waiting == 1 && val & LSI_ISTAT0_SIGP) {
DPRINTF("Woken by SIGP\n");
s->waiting = 0;
s->dsp = s->dnad;
lsi_execute_script(s);
}
if (val & LSI_ISTAT0_SRST) {
lsi_soft_reset(s);
}
break;
case 0x16:
s->mbox0 = val;
break;
case 0x17:
s->mbox1 = val;
break;
case 0x1a:
s->ctest2 = val & LSI_CTEST2_PCICIE;
break;
case 0x1b:
s->ctest3 = val & 0x0f;
break;
CASE_SET_REG32(temp, 0x1c)
case 0x21:
if (val & 7) {
BADF("Unimplemented CTEST4-FBL 0x%x\n", val);
}
s->ctest4 = val;
break;
case 0x22:
if (val & (LSI_CTEST5_ADCK | LSI_CTEST5_BBCK)) {
BADF("CTEST5 DMA increment not implemented\n");
}
s->ctest5 = val;
break;
CASE_SET_REG24(dbc, 0x24)
CASE_SET_REG32(dnad, 0x28)
case 0x2c:
s->dsp &= 0xffffff00;
s->dsp |= val;
break;
case 0x2d:
s->dsp &= 0xffff00ff;
s->dsp |= val << 8;
break;
case 0x2e:
s->dsp &= 0xff00ffff;
s->dsp |= val << 16;
break;
case 0x2f:
s->dsp &= 0x00ffffff;
s->dsp |= val << 24;
if ((s->dmode & LSI_DMODE_MAN) == 0
&& (s->istat1 & LSI_ISTAT1_SRUN) == 0)
lsi_execute_script(s);
break;
CASE_SET_REG32(dsps, 0x30)
CASE_SET_REG32(scratch[0], 0x34)
case 0x38:
if (val & (LSI_DMODE_SIOM | LSI_DMODE_DIOM)) {
BADF("IO mappings not implemented\n");
}
s->dmode = val;
break;
case 0x39:
s->dien = val;
lsi_update_irq(s);
break;
case 0x3a:
s->sbr = val;
break;
case 0x3b:
s->dcntl = val & ~(LSI_DCNTL_PFF | LSI_DCNTL_STD);
if ((val & LSI_DCNTL_STD) && (s->istat1 & LSI_ISTAT1_SRUN) == 0)
lsi_execute_script(s);
break;
case 0x40:
s->sien0 = val;
lsi_update_irq(s);
break;
case 0x41:
s->sien1 = val;
lsi_update_irq(s);
break;
case 0x47:
break;
case 0x48:
s->stime0 = val;
break;
case 0x49:
if (val & 0xf) {
DPRINTF("General purpose timer not implemented\n");
lsi_script_scsi_interrupt(s, 0, LSI_SIST1_GEN);
}
break;
case 0x4a:
s->respid0 = val;
break;
case 0x4b:
s->respid1 = val;
break;
case 0x4d:
s->stest1 = val;
break;
case 0x4e:
if (val & 1) {
BADF("Low level mode not implemented\n");
}
s->stest2 = val;
break;
case 0x4f:
if (val & 0x41) {
BADF("SCSI FIFO test mode not implemented\n");
}
s->stest3 = val;
break;
case 0x56:
s->ccntl0 = val;
break;
case 0x57:
s->ccntl1 = val;
break;
CASE_SET_REG32(mmrs, 0xa0)
CASE_SET_REG32(mmws, 0xa4)
CASE_SET_REG32(sfs, 0xa8)
CASE_SET_REG32(drs, 0xac)
CASE_SET_REG32(sbms, 0xb0)
CASE_SET_REG32(dbms, 0xb4)
CASE_SET_REG32(dnad64, 0xb8)
CASE_SET_REG32(pmjad1, 0xc0)
CASE_SET_REG32(pmjad2, 0xc4)
CASE_SET_REG32(rbc, 0xc8)
CASE_SET_REG32(ua, 0xcc)
CASE_SET_REG32(ia, 0xd4)
CASE_SET_REG32(sbc, 0xd8)
CASE_SET_REG32(csbc, 0xdc)
default:
if (offset >= 0x5c && offset < 0xa0) {
int n;
int shift;
n = (offset - 0x58) >> 2;
shift = (offset & 3) * 8;
s->scratch[n] &= ~(0xff << shift);
s->scratch[n] |= (val & 0xff) << shift;
} else {
BADF("Unhandled writeb 0x%x = 0x%x\n", offset, val);
}
}
#undef CASE_SET_REG24
#undef CASE_SET_REG32
}
| 1threat
|
Enumerate Dictionary.Values vs Dictionary itself : <p>I was exploring the sources of ASP.NET core on GitHub to see what kind of tricks the ASP.NET team used to speed up the framework. I saw something that intrigued me. In the source code of the <a href="https://github.com/aspnet/DependencyInjection/blob/dev/src/Microsoft.Extensions.DependencyInjection/ServiceProvider.cs" rel="noreferrer">ServiceProvider</a>, in the Dispose implementation, they enumerate a dictionary, and they put a comment to indicate a performance trick :</p>
<pre><code>private readonly Dictionary<IService, object> _resolvedServices = new Dictionary<IService, object>();
// Code removed for brevity
public void Dispose()
{
// Code removed for brevity
// PERF: We've enumerating the dictionary so that we don't allocate to enumerate.
// .Values allocates a KeyCollection on the heap, enumerating the dictionary allocates
// a struct enumerator
foreach (var entry in _resolvedServices)
{
(entry.Value as IDisposable)?.Dispose();
}
_resolvedServices.Clear();
}
</code></pre>
<p>What is the difference if the dictionary is enumerated like that ?</p>
<p></p>
<pre><code>foreach (var entry in _resolvedServices.Values)
{
(entry as IDisposable)?.Dispose();
}
</code></pre>
<p>It has a performance impact ? Or it's because allocate a <a href="https://msdn.microsoft.com/en-us/library/x8bctb9c(v=vs.110).aspx" rel="noreferrer">ValueCollection</a> will consume more memory ?</p>
| 0debug
|
window.location.href = 'http://attack.com?user=' + user_input;
| 1threat
|
PHP includ another file, loop over array and run function for each record : PHP loop over array and run function for each record
I would like to access the values of an array in another php file ... loop over it and run a function over each record. I can't seem to access the values though ... I'm getting an internal error. How to properly do this? That's my setup:
contacts.php
<?php
$contacts_de = array(
'name01' => array(
'firstName' => 'FirstName01',
'lastName' => 'LastName01',
'gender' => 'm',
'language' => 'de',
'email' => 'email01'
),
'name02' => array(
'firstName' => 'FirstName02',
'lastName' => 'LastName02',
'gender' => 'f',
'language' => 'de',
'email' => 'email02'
)
);
mail.php
<?php
include('contacts.php');
function renderContacts($arr) {
global $lang,$contacts_de;
$d = '';
foreach($arr as $i) {
if ($i['gender'] == 'm') {
.$d = 'Mr. '.$i['firstName'].' '.$i['lastName']
} else if ($i['gender'] == 'm') {
.$d = 'Ms. '.$i['firstName'].' '.$i['lastName']
}
}
echo $d;
}
renderContacts();
default.js
$('#sendbtn').on('click', function() {
$.ajax({
type: "POST",url: '/mail.php',
success: function(response,textStatus,jqXHR) {
console.log(response);
},
error: function (jqXHR, status, err) {
console.log(err);
}
});
});
Desired Console.log
Mr. FirstName01 LastName01
Ms. FirstName02 LastName02
| 0debug
|
How can i get all my contacts phone numbers into a array? : How can i get all my contacts phone numbers into a array? I need this, to send the array to my Server/DB to check, if one or more numbers exist in the Database.
I still work with swift 2, later also with swift 3.
Thank you for your support.
| 0debug
|
static int has_decode_delay_been_guessed(AVStream *st)
{
return st->codec->codec_id != CODEC_ID_H264 ||
st->codec_info_nb_frames >= 6 + st->codec->has_b_frames;
}
| 1threat
|
pre-commit/hook: No such file or directory : <p>I get this error when I try to commit.</p>
<p>OS - Latest OSX</p>
<p>Git version - git version 2.11.0 (Apple Git-81)</p>
<pre><code>.git/hooks/pre-commit: line 2: ./node_modules/pre-commit/hook: No such file or directory
</code></pre>
| 0debug
|
adjacency matrix sum of corresponding rows and columns : <p>What is the easiest way to sum the rows and columns, of the same index, on an adjacency matrix?</p>
<p>Here is one example:</p>
<pre><code> A B C D
A 1 0 2 1
B 3 - - -
C 0 - - -
D 1 - - -
</code></pre>
<p>where the (-) are entries. How can I sum the A column with A row, B column with B row....</p>
<p>example, for A: (1 + 0 + 2 + 1) + (1 + 3 + 0 + 1) = 9</p>
| 0debug
|
Compare Two String With Optional Characters : consider we have a function (in Django || python) which compares two strings, one is the correct answer and another is student answered string.
correct = '(an) apple (device)'
student_answerd = 'apple device'
I want to check student_answered with the correct string but parentheses are optional it means all the below student_answered is correct:
case 1: an apple device
case 2: an apple
case 3: apple device
notice: we don't have the same correct format for all questions it means the location of parentheses is different for example maybe we just have one parentheses or more.
| 0debug
|
Exporting React component with multiple HOC wrappers? : <p>I have a React component that displays styled text, and I want to have it load a network resource, listen for WebSocket input, and display notifications. In order to do this, I write Higher Order Component wrapper functions for each of these: <code>withResource</code>, <code>withSocket</code>, and <code>withNotifications</code>.</p>
<p>When exporting the component, is this correct?</p>
<pre><code>class TextComponent extends React.Component {
...
}
export default withResource(withSocket(withNotifications(TextComponent)))
</code></pre>
| 0debug
|
Call 2 functions within onChange event : <p>I'm a bit stuck with my component, I need to call onChange from props so</p>
<pre><code><input type="text" value={this.state.text} onChange={this.props.onChange} />
</code></pre>
<p>but also call another function within the component called <code>handleChange()</code> that updates the state.text, I tried</p>
<pre><code> <input type="text" value={this.state.text} onChange={this.props.onChange; this.handleChange} />
</code></pre>
<p>but this doesn't seem to work.</p>
| 0debug
|
int hmp_pcie_aer_inject_error(Monitor *mon,
const QDict *qdict, QObject **ret_data)
{
const char *id = qdict_get_str(qdict, "id");
const char *error_name;
uint32_t error_status;
bool correctable;
PCIDevice *dev;
PCIEAERErr err;
int ret;
ret = pci_qdev_find_device(id, &dev);
if (ret < 0) {
monitor_printf(mon,
"id or pci device path is invalid or device not "
"found. %s\n", id);
return ret;
}
if (!pci_is_express(dev)) {
monitor_printf(mon, "the device doesn't support pci express. %s\n",
id);
return -ENOSYS;
}
error_name = qdict_get_str(qdict, "error_status");
if (pcie_aer_parse_error_string(error_name, &error_status, &correctable)) {
char *e = NULL;
error_status = strtoul(error_name, &e, 0);
correctable = qdict_get_try_bool(qdict, "correctable", 0);
if (!e || *e != '\0') {
monitor_printf(mon, "invalid error status value. \"%s\"",
error_name);
return -EINVAL;
}
}
err.status = error_status;
err.source_id = (pci_bus_num(dev->bus) << 8) | dev->devfn;
err.flags = 0;
if (correctable) {
err.flags |= PCIE_AER_ERR_IS_CORRECTABLE;
}
if (qdict_get_try_bool(qdict, "advisory_non_fatal", 0)) {
err.flags |= PCIE_AER_ERR_MAYBE_ADVISORY;
}
if (qdict_haskey(qdict, "header0")) {
err.flags |= PCIE_AER_ERR_HEADER_VALID;
}
if (qdict_haskey(qdict, "prefix0")) {
err.flags |= PCIE_AER_ERR_TLP_PREFIX_PRESENT;
}
err.header[0] = qdict_get_try_int(qdict, "header0", 0);
err.header[1] = qdict_get_try_int(qdict, "header1", 0);
err.header[2] = qdict_get_try_int(qdict, "header2", 0);
err.header[3] = qdict_get_try_int(qdict, "header3", 0);
err.prefix[0] = qdict_get_try_int(qdict, "prefix0", 0);
err.prefix[1] = qdict_get_try_int(qdict, "prefix1", 0);
err.prefix[2] = qdict_get_try_int(qdict, "prefix2", 0);
err.prefix[3] = qdict_get_try_int(qdict, "prefix3", 0);
ret = pcie_aer_inject_error(dev, &err);
*ret_data = qobject_from_jsonf("{'id': %s, "
"'root_bus': %s, 'bus': %d, 'devfn': %d, "
"'ret': %d}",
id, pci_root_bus_path(dev),
pci_bus_num(dev->bus), dev->devfn,
ret);
assert(*ret_data);
return 0;
}
| 1threat
|
Get content of HTML element without WebBrowser? : <p>How can you extract the content of an element from a webpage such as the possession of Paris Saint-Germain from <a href="https://www.whoscored.com/Statistics" rel="nofollow noreferrer">https://www.whoscored.com/Statistics</a> without the use of WebBrowser?</p>
<p>This data is updated frequently and is not accessible from the source code that can be received by an HTTP request. If possible, I would access such data asynchronously to make the scraping go faster. To my understanding, one WebBrowser object cannot load/open multiple pages at once. In that case, a separate WebBrowser object would then have to be created for each asynchronous process which would probably be a big overhead.</p>
| 0debug
|
static inline uint64_t cksm_overflow(uint64_t cksm)
{
if (cksm > 0xffffffffULL) {
cksm &= 0xffffffffULL;
cksm++;
}
return cksm;
}
| 1threat
|
static int svq1_motion_inter_4v_block(DSPContext *dsp, GetBitContext *bitbuf,
uint8_t *current, uint8_t *previous,
int pitch, svq1_pmv *motion, int x, int y)
{
uint8_t *src;
uint8_t *dst;
svq1_pmv mv;
svq1_pmv *pmv[4];
int i, result;
pmv[0] = &motion[0];
if (y == 0) {
pmv[1] =
pmv[2] = pmv[0];
} else {
pmv[1] = &motion[(x / 8) + 2];
pmv[2] = &motion[(x / 8) + 4];
}
result = svq1_decode_motion_vector(bitbuf, &mv, pmv);
if (result != 0)
return result;
pmv[0] = &mv;
if (y == 0) {
pmv[1] =
pmv[2] = pmv[0];
} else {
pmv[1] = &motion[(x / 8) + 3];
}
result = svq1_decode_motion_vector(bitbuf, &motion[0], pmv);
if (result != 0)
return result;
pmv[1] = &motion[0];
pmv[2] = &motion[(x / 8) + 1];
result = svq1_decode_motion_vector(bitbuf, &motion[(x / 8) + 2], pmv);
if (result != 0)
return result;
pmv[2] = &motion[(x / 8) + 2];
pmv[3] = &motion[(x / 8) + 3];
result = svq1_decode_motion_vector(bitbuf, pmv[3], pmv);
if (result != 0)
return result;
for (i = 0; i < 4; i++) {
int mvx = pmv[i]->x + (i & 1) * 16;
int mvy = pmv[i]->y + (i >> 1) * 16;
if (y + (mvy >> 1) < 0)
mvy = 0;
if (x + (mvx >> 1) < 0)
mvx = 0;
src = &previous[(x + (mvx >> 1)) + (y + (mvy >> 1)) * pitch];
dst = current;
dsp->put_pixels_tab[1][((mvy & 1) << 1) | (mvx & 1)](dst, src, pitch, 8);
if (i & 1)
current += 8 * (pitch - 1);
else
current += 8;
}
return 0;
}
| 1threat
|
Suppress User-facing text should use localized string macro warning : <p>I am using unlocalized strings and getting below warning </p>
<blockquote>
<p>User-facing text should use localized string macro</p>
</blockquote>
<p>How to suppress this warning ?</p>
| 0debug
|
How can I resolve a domain name to an IP address? : I need to resolve any given domain in PHP to its corresponding IP address. [`gethostbyname`][1] appears to perform a reverse DNS (rDNS) and isn't useful for obtaining the IP address of a domestic connection (that doesn't have direct rDNS).
I have the following, which of course doesn't work:
<?php
if (ISSET($_POST["domain"])) {
require_once("/protected/db.php");
echo gethostbyname($_POST["domain"]);
}
echo "Error";
?>
How can I do this?
[1]: http://stackoverflow.com/questions/3830603/php-domain-to-ip
| 0debug
|
Loop between two large numbers in few minutes : <p>I want to loop from <code>0.900000000000000000000000000000</code> to <code>0.999999999999999999999999999999</code> (<strong>30 digit after decimal</strong>) with step of <code>0.000000000000000000000000000001</code> . I used for loop and it takes hours of time. Can it be done in few minutes ? </p>
| 0debug
|
How can I make my website send email after checking captcha : <p>I'm trying to setup a service for my friend where he will post an email request from his site to mine with html form tag and then my site will request a captcha check it's valid then send him the email but I'm not sure how to </p>
<p>I tried some online options but I can't find anything that will request the captcha then redirect to send the message check it's valid then send it</p>
| 0debug
|
C# - How can I correct string case by using HashSet<string> : <p>Given a hash set such as:</p>
<pre><code>HashSet<string> names = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
"Alice",
"Bob",
"Charles",
}
</code></pre>
<p>How can I use this hash set to find the mapped value of a case insensitive string? For example, if I have a string <code>"aLICe"</code>, I want to be able to find <code>"Alice"</code>. </p>
| 0debug
|
void mips_malta_init (ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model)
{
char *filename;
ram_addr_t ram_offset;
ram_addr_t bios_offset;
target_long bios_size;
int64_t kernel_entry;
PCIBus *pci_bus;
ISADevice *isa_dev;
CPUState *env;
RTCState *rtc_state;
fdctrl_t *floppy_controller;
MaltaFPGAState *malta_fpga;
qemu_irq *i8259;
int piix4_devfn;
uint8_t *eeprom_buf;
i2c_bus *smbus;
int i;
DriveInfo *dinfo;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *fd[MAX_FD];
int fl_idx = 0;
int fl_sectors = 0;
for(i = 0; i < 3; i++) {
if (!serial_hds[i]) {
char label[32];
snprintf(label, sizeof(label), "serial%d", i);
serial_hds[i] = qemu_chr_open(label, "null", NULL);
}
}
if (cpu_model == NULL) {
#ifdef TARGET_MIPS64
cpu_model = "20Kc";
#else
cpu_model = "24Kf";
#endif
}
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
qemu_register_reset(main_cpu_reset, env);
if (ram_size > (256 << 20)) {
fprintf(stderr,
"qemu: Too much memory for this machine: %d MB, maximum 256 MB\n",
((unsigned int)ram_size / (1 << 20)));
exit(1);
}
ram_offset = qemu_ram_alloc(ram_size);
bios_offset = qemu_ram_alloc(BIOS_SIZE);
cpu_register_physical_memory(0, ram_size, ram_offset | IO_MEM_RAM);
cpu_register_physical_memory(0x1e000000LL,
BIOS_SIZE, bios_offset | IO_MEM_ROM);
cpu_register_physical_memory(0x1fc00000LL,
BIOS_SIZE, bios_offset | IO_MEM_ROM);
malta_fpga = malta_fpga_init(0x1f000000LL, env->irq[2], serial_hds[2]);
if (kernel_filename) {
loaderparams.ram_size = ram_size;
loaderparams.kernel_filename = kernel_filename;
loaderparams.kernel_cmdline = kernel_cmdline;
loaderparams.initrd_filename = initrd_filename;
kernel_entry = load_kernel(env);
env->CP0_Status &= ~((1 << CP0St_BEV) | (1 << CP0St_ERL));
write_bootloader(env, qemu_get_ram_ptr(bios_offset), kernel_entry);
} else {
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
if (dinfo) {
bios_size = 0x400000;
fl_sectors = bios_size >> 16;
#ifdef DEBUG_BOARD_INIT
printf("Register parallel flash %d size " TARGET_FMT_lx " at "
"offset %08lx addr %08llx '%s' %x\n",
fl_idx, bios_size, bios_offset, 0x1e000000LL,
bdrv_get_device_name(dinfo->bdrv), fl_sectors);
#endif
pflash_cfi01_register(0x1e000000LL, bios_offset,
dinfo->bdrv, 65536, fl_sectors,
4, 0x0000, 0x0000, 0x0000, 0x0000);
fl_idx++;
} else {
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_image_targphys(filename, 0x1fc00000LL,
BIOS_SIZE);
qemu_free(filename);
} else {
bios_size = -1;
}
if ((bios_size < 0 || bios_size > BIOS_SIZE) && !kernel_filename) {
fprintf(stderr,
"qemu: Could not load MIPS bios '%s', and no -kernel argument was specified\n",
bios_name);
exit(1);
}
}
#ifndef TARGET_WORDS_BIGENDIAN
{
uint32_t *addr = qemu_get_ram_ptr(bios_offset);;
uint32_t *end = addr + bios_size;
while (addr < end) {
bswap32s(addr);
}
}
#endif
}
stl_phys(0x1fc00010LL, 0x00000420);
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
i8259 = i8259_init(env->irq[2]);
pci_bus = pci_gt64120_init(i8259);
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
fprintf(stderr, "qemu: too many IDE bus\n");
exit(1);
}
for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) {
hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS);
}
piix4_devfn = piix4_init(pci_bus, 80);
isa_bus_irqs(i8259);
pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1);
usb_uhci_piix4_init(pci_bus, piix4_devfn + 2);
smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100, isa_reserve_irq(9));
eeprom_buf = qemu_mallocz(8 * 256);
for (i = 0; i < 8; i++) {
DeviceState *eeprom;
eeprom = qdev_create((BusState *)smbus, "smbus-eeprom");
qdev_prop_set_uint8(eeprom, "address", 0x50 + i);
qdev_prop_set_ptr(eeprom, "data", eeprom_buf + (i * 256));
qdev_init(eeprom);
}
pit = pit_init(0x40, isa_reserve_irq(0));
DMA_init(0);
isa_dev = isa_create_simple("i8042");
rtc_state = rtc_init(2000);
serial_isa_init(0, serial_hds[0]);
serial_isa_init(1, serial_hds[1]);
if (parallel_hds[0])
parallel_init(0, parallel_hds[0]);
for(i = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
}
floppy_controller = fdctrl_init_isa(fd);
#ifdef HAS_AUDIO
audio_init(pci_bus);
#endif
network_init();
if (cirrus_vga_enabled) {
pci_cirrus_vga_init(pci_bus);
} else if (vmsvga_enabled) {
pci_vmsvga_init(pci_bus);
} else if (std_vga_enabled) {
pci_vga_init(pci_bus, 0, 0);
}
}
| 1threat
|
Why 'which -a cd' command doesn't give any output in linux? : <p>'Which' command gives the full path to the command. All other commands are working except cd command. </p>
| 0debug
|
How to fill array with random numbers limited to 0-20 : <p>I am having trouble placing the random generator in the array, how can I get #20 random numbers from 0-9 in the array? Then you count the occurrences of those numbers.</p>
<p>import java.util.Random;</p>
<p>public class CountDigits {</p>
<pre><code>public static void main(String[] args) {
Random digit = new Random();
int Random[] = new int [20];
int Digits[] = {0,1,2,3,4,5,6,7,8,9};
int Count [] = new int [10];
for ( int i = 0; i < Digits.length; i++) {
for( int j = 0; j < Random.length; j++) {
if ( Digits [i] == Random [j] )
Count[i]++;
}
}
for ( int i = 0; i < Count.length; i++) {
if ( Count[i] == 1)
System.out.printf(" %d occurs 1 time " , Digits[i] );
else
System.out.printf("%d occurs %d times" , Digits[i], Count[i]);
}
</code></pre>
<p>result so far::
0 occurs 20 times1 occurs 0 times2 occurs 0 times3 occurs 0 times4 occurs 0 times5 occurs 0 times6 occurs 0 times7 occurs 0 times8 occurs 0 times9 occurs 0 times</p>
| 0debug
|
How add text in the hover effect of this triangle in svg? : <p>I made a triangle with hover effect, but I can´t add text. How can I add text inside the hover effect of this polygon? </p>
<p>html :</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><svg version="1.0" id="formas" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 792 612" enable-background="new 0 0 792 612" xml:space="preserve">
<linearGradient id="triangulo_apartado_1_1_" gradientUnits="userSpaceOnUse" x1="0" y1="252.5721" x2="117.5039" y2="252.5721">
<stop offset="0" style="stop-color:#5D676A"/>
<stop offset="0.4845" style="stop-color:#808B91"/>
<stop offset="1" style="stop-color:#5D676A"/>
</linearGradient>
<polygon class="triangle" id="triangulo_apartado_1" fill="url(#triangulo_apartado_1_1_)"stroke="#FFFFFF" stroke-miterlimit="10" points="117.504,281.948 0,281.948 58.752,223.196"/>
</svg></code></pre>
</div>
</div>
</p>
<p>style in css:</p>
<pre><code>.triangle{} .triangle:hover{fill:#ffcd00;}
</code></pre>
| 0debug
|
nested scrollview + recyclerview, strange autoscroll behaviour : <p>In a view pager I have several fragments, one of them uses a nested scrollview with a header and a recyclerview : </p>
<pre><code><android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.m360.android.fragment.Members.MemberDetailsFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="20dp">
<header/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:paddingTop="0dp" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</code></pre>
<p>The tag "header" represents a complex layout that I didn't want to post here as it stretches out the code a lot.</p>
<p>when I switch between the tabs, it scrolls strait to the recycler view. The header is hidden, I have to scroll up to see it.</p>
<p>Any ideas on what causes that ? I don't wanna use a type in my adapter if I can avoid it.</p>
| 0debug
|
static BlockDriverAIOCB *raw_aio_readv(BlockDriverState *bs,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque)
{
return bdrv_aio_readv(bs->file, sector_num, qiov, nb_sectors, cb, opaque);
}
| 1threat
|
Docker deamon config path under mac os : <p>I am using docker in Version 1.12.0 (build 10871) on Mac OS (El Capitan 10.11.4) and I want to provide a config file for the docker daemon.</p>
<p>Under Ubuntu you place the config under <code>/etc/default/docker</code> (see <a href="https://docs.docker.com/engine/admin/#/configuring-docker" rel="noreferrer">docs</a>). Unfortunately, I cannot figure out where to place the config in Mac OS</p>
<p>Any ideas?</p>
| 0debug
|
Getting Error while call a method from adapter class.java.lang.IllegalStateException: System services not available to Activities before onCreate() : When I try to call a method from my adapter class, I'm getting a error System services not available to Activities before onCreate();
MainTask.Class
public class MainTask extends AppCompatActivity {
public static final String mypreference = "mypref";
public static String Name = "nameKey";
SharedPreferences taskcount, currenttime;
public static int completask;
long shared_time;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_task);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager);
setupViewPager(viewPager);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabLayout);
tabLayout.setupWithViewPager(viewPager);//setting tab over viewpager
taskcount = getSharedPreferences(mypreference,
MainActivity.MODE_PRIVATE);
completask = taskcount.getInt(Name, 0);
}
public void propertask(){
final NiftyDialogBuilder dialog1 = NiftyDialogBuilder.getInstance(MainTask.this);
Effectstype effect;
effect = Effectstype.SlideBottom;
dialog1.setCancelable(false);
dialog1.isCancelableOnTouchOutside(false)
.withTitle(null)
.withMessage(null)
.withEffect(effect)
.setCustomView(R.layout.proper_task, MainTask.this)
.show();
Button rate = (Button) dialog1.findViewById(R.id.rate_button);
rate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog1.dismiss();
}
});
dialog1.show();
}
GridListAdapter.Java
if(taskvalue==0)
{
MainTask mainTask=new MainTask();
mainTask.propertask();
}
Please help me, how I can access propertask method from my Adapter class.
Thanks in advance.
| 0debug
|
File Upload in Elm : <p>How does one upload a file (image or excel) in Elm? </p>
<p>Can't seem to find any examples.</p>
<p>The answer is fine even if the native code is used. Have seen <code>Data</code> in <code>Elm-Html</code> but it appears files and blobs are not supported. What is the way around this?</p>
| 0debug
|
What is it mean ? Casting address of variable to char. How come? : <p>What is it mean ?</p>
<pre class="lang-c prettyprint-override"><code>int main(int argc, char *argv[]) {
int size = 2048;
char *stack;
stack = (char *) &size; // cast memory address of a variable to char
}
</code></pre>
<p>I really don't understand what it will be if we cast memory address of a variable. </p>
| 0debug
|
parse json by empty property : Am getting set of JSON objects as below in my ajax response
{
"id": 2,
"name": "An ice sculpture",
"price": 12.50,
"tags": ["cold", "ice"],
"dimensions": {
"length": 7.0,
"width": 12.0,
"height": 9.5
},
"warehouseLocation": {
"latitude": -78.75,
"longitude": 20.4
}
},
{
"id": 3,
"name": "A blue mouse",
"price": 25.50,
"dimensions": {
"length": 3.1,
"width": 1.0,
"height": 1.0
},
"warehouseLocation": {
"latitude": 54.4,
"longitude": -32.7
}
}
{
"id": 3,
"name": "A blue mouse",
"price": 25.50,
"dimensions": {
"length": 3.1,
"width": 1.0,
"height": 1.0
},
"warehouseLocation": ""
}
i want to parse these objects by `warehouseLocation` which means i need only json objects of non `warehouseLocation`empty
| 0debug
|
Equivalent for .HasOptional in Entity Framework Core 1 (EF7) : <p>Consider two classes.</p>
<pre><code>public class File
{
[Key]
public string Id { get; set; }
public string Message_Id { get; set; }
internal Message Message { get; set; }
}
public class Message
{
[Key]
public string Id { get; set; }
}
</code></pre>
<p>In EF6, for N : 1..0 relation there was this fluent API.</p>
<pre><code>modelBuilder.Entity<File>()
.HasOptional(e => e.Message ).WithMany().HasForeignKey(e => e.Message_Id);
</code></pre>
<p>What is equivalent in Entiity Framework Core 1?</p>
<p>Thank you</p>
| 0debug
|
I am completely new and don't understand what is wrong with my code. Could you just edit it and then reply it so that I can copy paste it : <p>Please just edit it and reply it.
I don't want to learn any coding but just want to create an app.
This app function is to just display a youtube site with a banner ad and interstitial ads
the errors which it is showing are these
Error:(39, 5) error: illegal start of expression
Error:(39, 12) error: illegal start of expression
Error:(39, 33) error: ';' expected
Error:(53, 5) error: illegal start of expression
Error:(53, 45) error: ';' expected
Error:(66, 2) error: reached end of file while parsing
Error:Execution failed for task ':app:compileReleaseJavaWithJavac'.</p>
<blockquote>
<p>Compilation failed; see the compiler error output for details.</p>
</blockquote>
<p>My code-></p>
<pre><code> package cominfinitygaminghere.wixsite.httpsinfinitygaminghere.mumbojumbo;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.InterstitialAd;
public class MainActivity extends AppCompatActivity {
WebView webView;
private InterstitialAd mInterstitialAd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mInterstitialAd = newInterstitialAd();
loadInterstitial();
AdView adView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.setRequestAgent("android_studio:ad_template").build();
adView.loadAd(adRequest);
webView = (WebView) findViewById(R.id.webview1);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl("https://www.youtube.com/channel/UChFur_NwVSbUozOcF_F2kMg");
public void loadInterstitial() {
AdRequest adRequest = new AdRequest.Builder()
.setRequestAgent("android_studio:ad_template").build();
mInterstitialAd.loadAd(adRequest);
// Show the ad if it's ready. Otherwise toast and reload the ad.
if (mInterstitialAd != null && mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
} else {
//code to go to next level of the app
}
}
private InterstitialAd newInterstitialAd() {
InterstitialAd interstitialAd = new InterstitialAd(this);
interstitialAd.setAdUnitId(getString(R.string.interstitial_ad_unit_id));
interstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
// Code for proceeding to next level here
}
});
return interstitialAd;
}
}
</code></pre>
| 0debug
|
I need to define a function that determines the matching letters between words and returns back as a integer : <p>I need to define a function that compares words which determines matching letters before printing a message to tell the user how many letters of the guessed word are correct. It also needs to return back to the program as an integer. The function should return the number of matching letters and should not print anything</p>
<p>I am unsure how to do this?</p>
<p>def compareWords(word1, word2):</p>
| 0debug
|
Flutter/Dart - Difference between () {} and () => {} : <p>In Flutter/Dart the examples sometimes show fat arrow and sometimes dont. Here are examples:</p>
<pre><code>RaisedButton(
onPressed: () {
setState(() {
_myTxt = "Text Changed";
});
},
</code></pre>
<p>Elsewhere you see:</p>
<pre><code>void main() => runApp(MyApp());
</code></pre>
| 0debug
|
static int usb_bt_handle_control(USBDevice *dev, USBPacket *p,
int request, int value, int index, int length, uint8_t *data)
{
struct USBBtState *s = (struct USBBtState *) dev->opaque;
int ret;
ret = usb_desc_handle_control(dev, p, request, value, index, length, data);
if (ret >= 0) {
switch (request) {
case DeviceRequest | USB_REQ_GET_CONFIGURATION:
s->config = 0;
break;
case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
s->config = 1;
usb_bt_fifo_reset(&s->evt);
usb_bt_fifo_reset(&s->acl);
usb_bt_fifo_reset(&s->sco);
break;
}
return ret;
}
ret = 0;
switch (request) {
case InterfaceRequest | USB_REQ_GET_STATUS:
case EndpointRequest | USB_REQ_GET_STATUS:
data[0] = 0x00;
data[1] = 0x00;
ret = 2;
break;
case InterfaceOutRequest | USB_REQ_CLEAR_FEATURE:
case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:
goto fail;
case InterfaceOutRequest | USB_REQ_SET_FEATURE:
case EndpointOutRequest | USB_REQ_SET_FEATURE:
goto fail;
break;
case InterfaceRequest | USB_REQ_GET_INTERFACE:
if (value != 0 || (index & ~1) || length != 1)
goto fail;
if (index == 1)
data[0] = s->altsetting;
else
data[0] = 0;
ret = 1;
break;
case InterfaceOutRequest | USB_REQ_SET_INTERFACE:
if ((index & ~1) || length != 0 ||
(index == 1 && (value < 0 || value > 4)) ||
(index == 0 && value != 0)) {
printf("%s: Wrong SET_INTERFACE request (%i, %i)\n",
__FUNCTION__, index, value);
goto fail;
}
s->altsetting = value;
ret = 0;
break;
case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_DEVICE) << 8):
if (s->config)
usb_bt_fifo_out_enqueue(s, &s->outcmd, s->hci->cmd_send,
usb_bt_hci_cmd_complete, data, length);
break;
default:
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| 1threat
|
can javascript be inline with webpack? : <p>I need to import a library to my project, the library should is a javascript file, which need to be inlined to html.</p>
<p>for example: </p>
<p>library code:</p>
<pre><code>(function(){
var a = 0;
})();
</code></pre>
<p>I need to make this code inline in html.</p>
<p>html:</p>
<pre><code><html>
<head>
<script>
(function(){
var a = 0;
})();
</script>
</head>
<body>
</body>
</html>
</code></pre>
<p>can I implement this with webpack?
I find <a href="https://github.com/webpack/script-loader">script-loader</a>, but it run the script, not make it inline.</p>
| 0debug
|
void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64],
uint16_t (*qmat16)[2][64],
const uint16_t *quant_matrix,
int bias, int qmin, int qmax, int intra)
{
FDCTDSPContext *fdsp = &s->fdsp;
int qscale;
int shift = 0;
for (qscale = qmin; qscale <= qmax; qscale++) {
int i;
int qscale2;
if (s->q_scale_type) qscale2 = ff_mpeg2_non_linear_qscale[qscale];
else qscale2 = qscale << 1;
if (fdsp->fdct == ff_jpeg_fdct_islow_8 ||
#if CONFIG_FAANDCT
fdsp->fdct == ff_faandct ||
#endif
fdsp->fdct == ff_jpeg_fdct_islow_10) {
for (i = 0; i < 64; i++) {
const int j = s->idsp.idct_permutation[i];
int64_t den = (int64_t) qscale2 * quant_matrix[j];
qmat[qscale][i] = (int)((UINT64_C(2) << QMAT_SHIFT) / den);
}
} else if (fdsp->fdct == ff_fdct_ifast) {
for (i = 0; i < 64; i++) {
const int j = s->idsp.idct_permutation[i];
int64_t den = ff_aanscales[i] * (int64_t) qscale2 * quant_matrix[j];
qmat[qscale][i] = (int)((UINT64_C(2) << (QMAT_SHIFT + 14)) / den);
}
} else {
for (i = 0; i < 64; i++) {
const int j = s->idsp.idct_permutation[i];
int64_t den = (int64_t) qscale2 * quant_matrix[j];
qmat[qscale][i] = (int)((UINT64_C(2) << QMAT_SHIFT) / den);
qmat16[qscale][0][i] = (2 << QMAT_SHIFT_MMX) / den;
if (qmat16[qscale][0][i] == 0 ||
qmat16[qscale][0][i] == 128 * 256)
qmat16[qscale][0][i] = 128 * 256 - 1;
qmat16[qscale][1][i] =
ROUNDED_DIV(bias << (16 - QUANT_BIAS_SHIFT),
qmat16[qscale][0][i]);
}
}
for (i = intra; i < 64; i++) {
int64_t max = 8191;
if (fdsp->fdct == ff_fdct_ifast) {
max = (8191LL * ff_aanscales[i]) >> 14;
}
while (((max * qmat[qscale][i]) >> shift) > INT_MAX) {
shift++;
}
}
}
if (shift) {
av_log(NULL, AV_LOG_INFO,
"Warning, QMAT_SHIFT is larger than %d, overflows possible\n",
QMAT_SHIFT - shift);
}
}
| 1threat
|
static void do_loadvm(Monitor *mon, const QDict *qdict)
{
int saved_vm_running = vm_running;
const char *name = qdict_get_str(qdict, "name");
vm_stop(0);
if (load_vmstate(name) >= 0 && saved_vm_running)
vm_start();
}
| 1threat
|
static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_index, int64_t *pos){
RMDemuxContext *rm = s->priv_data;
ByteIOContext *pb = s->pb;
int len, num, res, i;
AVStream *st;
uint32_t state=0xFFFFFFFF;
while(!url_feof(pb)){
*pos= url_ftell(pb) - 3;
if(rm->remaining_len > 0){
num= rm->current_stream;
len= rm->remaining_len;
*timestamp = AV_NOPTS_VALUE;
*flags= 0;
}else{
state= (state<<8) + get_byte(pb);
if(state == MKBETAG('I', 'N', 'D', 'X')){
len = get_be16(pb) - 6;
if(len<0)
continue;
goto skip;
}
if(state > (unsigned)0xFFFF || state < 12)
continue;
len=state;
state= 0xFFFFFFFF;
num = get_be16(pb);
*timestamp = get_be32(pb);
res= get_byte(pb);
*flags = get_byte(pb);
len -= 12;
}
for(i=0;i<s->nb_streams;i++) {
st = s->streams[i];
if (num == st->id)
break;
}
if (i == s->nb_streams) {
skip:
url_fskip(pb, len);
rm->remaining_len -= len;
continue;
}
*stream_index= i;
return len;
}
return -1;
}
| 1threat
|
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
| 1threat
|
Android nestedScrollView - how to make it horizontal? : <p>I cant seem to find an option for <a href="https://developer.android.com/reference/android/support/v4/widget/NestedScrollView.html" rel="noreferrer">nestedScrollView</a> to make it horizontal instead of vertical. i have been using HorizontalScrollView but i'd like to switch to nested. Is there anyway to do this ? searching the docs i dont see it yet it does say its the same as a scrollview ?</p>
| 0debug
|
Delete files in Windows>Temp>tmp0000* repertories : Windows 8.1 : <p>I do not have enough space on my disk, I would like to know if I can delete the Temp files of the <code>Windows directory>Temp>tmp0000*</code></p>
| 0debug
|
Moving Google Maps Camera to a Location : <p>I'm working with a Google Maps View and I want to add a button to the map that when tapped, will move the camera to a specific location. I currently have a button outlet and an action connected to the button. </p>
<pre><code>@IBAction func locationTapped(_ sender: Any) {
print("tapped")
let location = GMSCameraPosition.camera(withLatitude: place.latitude, longitude: place.longitude, zoom: 17.0)
mapView.camera = location
}
</code></pre>
<p><code>place</code> exists but for some reason, the camera will not budge. I've tried different versions of code and looked at the Google Maps documentation but none of the options are producing results. Can anyone tell me what I'm doing wrong?</p>
| 0debug
|
Why does Webpack's DefinePlugin require us to wrap everything in JSON.stringify? : <pre><code>new webpack.DefinePlugin({
PRODUCTION: JSON.stringify(true),
VERSION: JSON.stringify("5fa3b9"),
BROWSER_SUPPORTS_HTML5: true,
TWO: "1+1",
"typeof window": JSON.stringify("object")
})
</code></pre>
<p><a href="https://github.com/webpack/docs/wiki/list-of-plugins#defineplugin" rel="noreferrer">https://github.com/webpack/docs/wiki/list-of-plugins#defineplugin</a></p>
<p>This seems very unusual, unnecessary and "dev-error-prone".</p>
<p>Is it type-checking concerns?</p>
| 0debug
|
Exception Handling in c# - try catch finally : <p>I am bit confused regarding the finally block. I know that finally block gets executed no matter if there is an exception or not.</p>
<p>I have got 2 scenarios :-</p>
<p>1) If there is an exception in try block and I have not written any catch block for this try block, but I have a finally block, then will the finally block gets executed? Does finally block executed if the exception is unhandled?</p>
<p>Below is an example code :- </p>
<pre><code>static void Main(string[] args)
{
int x = 0;
try
{
int divide = 12 / x;
}
//catch (Exception ex)
//{
// int divide = 12 / x;
// Console.WriteLine(ex.Message);
//}
finally
{
Console.WriteLine("I am finally block");
}
Console.ReadLine();
}
</code></pre>
<p>2) Will the finally block get executed if there is an exception in catch block?
Below is the sample code :-</p>
<pre><code>static void Main(string[] args)
{
int x = 0;
try
{
int divide = 12 / x;
}
catch (Exception ex)
{
int divide = 12 / x; // this will throw exception in catch block
Console.WriteLine(ex.Message);
}
finally
{
Console.WriteLine("I am finally block");
}
Console.ReadLine();
}
</code></pre>
<p>I have tried these codes and I don't see the finally block getting executed.
Please explain me why the finally block is not executed.</p>
| 0debug
|
static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1, Jpeg2000Cblk *cblk, Jpeg2000Tile *tile,
int width, int height, int bandpos, int lev)
{
int pass_t = 2, passno, x, y, max=0, nmsedec, bpno;
int64_t wmsedec = 0;
memset(t1->flags, 0, t1->stride * (height + 2) * sizeof(*t1->flags));
for (y = 0; y < height; y++){
for (x = 0; x < width; x++){
if (t1->data[(y) * t1->stride + x] < 0){
t1->flags[(y+1) * t1->stride + x+1] |= JPEG2000_T1_SGN;
t1->data[(y) * t1->stride + x] = -t1->data[(y) * t1->stride + x];
}
max = FFMAX(max, t1->data[(y) * t1->stride + x]);
}
}
if (max == 0){
cblk->nonzerobits = 0;
bpno = 0;
} else{
cblk->nonzerobits = av_log2(max) + 1 - NMSEDEC_FRACBITS;
bpno = cblk->nonzerobits - 1;
}
ff_mqc_initenc(&t1->mqc, cblk->data);
for (passno = 0; bpno >= 0; passno++){
nmsedec=0;
switch(pass_t){
case 0: encode_sigpass(t1, width, height, bandpos, &nmsedec, bpno);
break;
case 1: encode_refpass(t1, width, height, &nmsedec, bpno);
break;
case 2: encode_clnpass(t1, width, height, bandpos, &nmsedec, bpno);
break;
}
cblk->passes[passno].rate = ff_mqc_flush_to(&t1->mqc, cblk->passes[passno].flushed, &cblk->passes[passno].flushed_len);
wmsedec += (int64_t)nmsedec << (2*bpno);
cblk->passes[passno].disto = wmsedec;
if (++pass_t == 3){
pass_t = 0;
bpno--;
}
}
cblk->npasses = passno;
cblk->ninclpasses = passno;
cblk->passes[passno-1].rate = ff_mqc_flush_to(&t1->mqc, cblk->passes[passno-1].flushed, &cblk->passes[passno-1].flushed_len);
}
| 1threat
|
ERR_TOO_MANY_REDIRECTS wordpress Google chrome : I'm having a weird issue, wordpress homepage has a 302 error (redirection loop) on Google Chrome only, however if I access my admin panel first and then go back to homepage, it works...
I have WPML installed and Yoast SEO.
Installation is in a subfolder.
Would somebody have an idea of what is going on?
Here is the link: [www.scrybs.com][1]
Thanks in advance
[1]: http://www.scrybs.com
| 0debug
|
Javaskript : Simple substraction returns NaN : I have a problem,
my collision detection function sometimes sets entity position to NaN.
When I open console (on chrome) position of entity and collision are valid numbers but substracting them from each other sometimes returns NaN.
updateCollision = function(entity,rect) {
var a = entity.x - rect.x; // a = NaN , entity.x = 3117.2646499953607 , rect.x = 3296.976967651385
var b = entity.y - rect.y; // b = NaN , entity.y = 3024.105915848102 , rect.y = 3144.4270586199345
if( isNaN(a) ) // isNaN(a) = true
{
console.log("not again >:("); // but console doesn't log
}
//the code continues but its not important
[(screenshot of console)][1]
[1]: https://i.stack.imgur.com/sgjco.png
So I am realy confused, and don't know what to do with this issue.
| 0debug
|
How to trigger VSTS build and release when pushing tags? : <p>I have rather simple scenarion, one master branch then when I want to do a production release I want to tag a commit with eg. vX.X.X.</p>
<p>The CI/CD pipeline looks like this</p>
<p>Build -> Staging Environment -> Production Environment</p>
<ol>
<li>Every commit to master is sent to staging environment</li>
<li>When I add a vX.X.X tag to a commit I want the staging and production environment to trigger.</li>
</ol>
<p>I have found this link <a href="https://visualstudio.uservoice.com/forums/330519-visual-studio-team-services/suggestions/13326927-trigger-build-when-pushing-tag-to-git?page=1&per_page=20" rel="noreferrer">Trigger build when pushing tag to git</a>. I just can't figure it out how to make it work. It simply does not work for me.</p>
<p>Is it possible and how do I configure the VSTS to start a build when a tag is added to a commit? </p>
| 0debug
|
Error while running a React js App :
I have just created a new web App in Webstrom, but when i try to run it to show in the web , it throws me an exception.
SyntaxError: Unexpected token import
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
| 0debug
|
Is there any way to increase visibility with a using declaration? : <p>The following code doesn't compile:</p>
<pre><code>class C
{
private:
int m_x;
protected:
C(int t_x) : m_x(t_x) { }
};
class D : public C
{
public:
using C::C;
};
int main(int argc, char **argv)
{
D o(0);
}
</code></pre>
<p>The compiler's objection is that the constructor for C is declared <code>protected</code>, meaning that I can't access it from <code>main</code>. In other words, it seems like the <code>using</code> declaration drags the original visibility of the identifier with it, despite the fact that it lives in the <code>public</code> block.</p>
<p>Two questions:</p>
<ol>
<li>Why does this happen? (Both in terms of the rules for how this works, and the rationale for making those rules).</li>
<li>Is there any way I can get around this without explicitly writing a constructor for <code>D</code>?</li>
</ol>
| 0debug
|
Guava's Immutable filtering via Java 8 parallel stream : Need help in filtering Guava's ImmutableTable via parallel stream and collector
Immutable<fieldA1,fieldB1,Boolean> validEntry;
Immutable<ObjectA, String, ObjectB> tofilter;
ObjectA{
String fieldA1
String fieldA2
}
ObjectB{
String fieldB1
String fieldB2
}
Usecase : iterate over toFilter and remove elements which are not present or entry value is false in validEntry table.
Map<ObjectA, Map<String, ObjectB>> rowMap = toFIlter.rowMap();
//This will result into stream of stream
for(loop over rowMap){
for(Loop over rowMap entry){
if(present in validEntry){
//add entry to new table
}
}
}
build new table
How can i utilize flat map to convert this stream of streams.
| 0debug
|
static void rtas_query_cpu_stopped_state(sPAPREnvironment *spapr,
uint32_t token, uint32_t nargs,
target_ulong args,
uint32_t nret, target_ulong rets)
{
target_ulong id;
CPUState *cpu;
if (nargs != 1 || nret != 2) {
rtas_st(rets, 0, -3);
return;
}
id = rtas_ld(args, 0);
cpu = qemu_get_cpu(id);
if (cpu != NULL) {
if (cpu->halted) {
rtas_st(rets, 1, 0);
} else {
rtas_st(rets, 1, 2);
}
rtas_st(rets, 0, 0);
return;
}
rtas_st(rets, 0, -3);
}
| 1threat
|
static bool addrrange_intersects(AddrRange r1, AddrRange r2)
{
return (r1.start >= r2.start && r1.start < r2.start + r2.size)
|| (r2.start >= r1.start && r2.start < r1.start + r1.size);
}
| 1threat
|
Differentiate between uses of Adapter and Listener in Android? : Working with Android from begging it's hard to differentiate in term Adapter and Listener and it's uses. I know the role of Adapter and Adapter View but is Listener can perform same task as Adapter. Confusing a bit more.I request please give simple explanation to understanding it.
| 0debug
|
static void timerblock_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
timerblock *tb = (timerblock *)opaque;
int64_t old;
switch (addr) {
case 0:
tb->load = value;
case 4:
if ((tb->control & 1) && tb->count) {
qemu_del_timer(tb->timer);
}
tb->count = value;
if (tb->control & 1) {
timerblock_reload(tb, 1);
}
break;
case 8:
old = tb->control;
tb->control = value;
if (((old & 1) == 0) && (value & 1)) {
if (tb->count == 0 && (tb->control & 2)) {
tb->count = tb->load;
}
timerblock_reload(tb, 1);
}
break;
case 12:
tb->status &= ~value;
timerblock_update_irq(tb);
break;
}
}
| 1threat
|
How to run python function after completed other function : my purpose is, when I run "list.py" first step, script will read a target_list.txt and it will create a domain list as "http://testsites.com".
if this process when completed, it means finish the target_list, other function must run. Here's code
example:
import Queue
#!/usr/bin/python
import Queue
targetsite="target_list.txt"
def domaincreate(targetsitelist):
for i in targetsite.readlines():
i = i.strip()
Url="http://"+i
DomainList=open("LiveSite.txt","rb")
DomainList.write(Url)
DomainList.close()
def SiteBrowser():
TargetSite="LiveSite.txt"
Tar=open(TargetSite,"rb")
for Links in Tar.readlines():
Links=Links.strip()
UrlSites="http://www."+Links
browser = webdriver.Firefox()
browser.get(UrlSites)
browser.save_screenshot(Links+".png")
browser.quit()
domaincreate(targetsite)
SiteBrowser()
| 0debug
|
Custom angular directive and custom html tag not working : I am creating an application in Django and Angular. I have created one custom Angular Directive as below:
(function () {
'use strict';
angular.module('scrumboard.demo')
.directive('scrumboardCard', CardDirective);
function CardDirective() {
return {
templateurl: '/static/scrumboard/card.html'
restrict: 'E'
};
}
})();
And called it through custom HTML tag as below:
<ul>
<p ng-repeat="card in list.cards">
<scrumboard-card></scrumboard-card>
</li>
</ul>
However, I can see that the directive is not being called at all. I even tried putting garbage code in the angular directive so as to generate error, but the page just loads without calling that angular directive.
| 0debug
|
static void xen_domain_poll(void *opaque)
{
struct xc_dominfo info;
int rc;
rc = xc_domain_getinfo(xen_xc, xen_domid, 1, &info);
if ((rc != 1) || (info.domid != xen_domid)) {
qemu_log("xen: domain %d is gone\n", xen_domid);
goto quit;
}
if (info.dying) {
qemu_log("xen: domain %d is dying (%s%s)\n", xen_domid,
info.crashed ? "crashed" : "",
info.shutdown ? "shutdown" : "");
goto quit;
}
qemu_mod_timer(xen_poll, qemu_get_clock(rt_clock) + 1000);
return;
quit:
qemu_system_shutdown_request();
return;
}
| 1threat
|
static int64_t nfs_get_allocated_file_size(BlockDriverState *bs)
{
NFSClient *client = bs->opaque;
NFSRPC task = {0};
struct stat st;
if (bdrv_is_read_only(bs) &&
!(bs->open_flags & BDRV_O_NOCACHE)) {
return client->st_blocks * 512;
}
task.st = &st;
if (nfs_fstat_async(client->context, client->fh, nfs_co_generic_cb,
&task) != 0) {
return -ENOMEM;
}
while (!task.complete) {
nfs_set_events(client);
aio_poll(client->aio_context, true);
}
return (task.ret < 0 ? task.ret : st.st_blocks * 512);
}
| 1threat
|
Quartz.Net Dependency Injection .Net Core : <p>In my project I have to use Quartz but I don't know what i do wrong.</p>
<p>JobFactory:</p>
<pre class="lang-cs prettyprint-override"><code>public class IoCJobFactory : IJobFactory
{
private readonly IServiceProvider _factory;
public IoCJobFactory(IServiceProvider factory)
{
_factory = factory;
}
public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
{
return _factory.GetService(bundle.JobDetail.JobType) as IJob;
}
public void ReturnJob(IJob job)
{
var disposable = job as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
</code></pre>
<p>QuartzExtensions:</p>
<pre class="lang-cs prettyprint-override"><code>public static class QuartzExtensions
{
public static void UseQuartz(this IApplicationBuilder app)
{
app.ApplicationServices.GetService<IScheduler>();
}
public static async void AddQuartz(this IServiceCollection services)
{
var props = new NameValueCollection
{
{"quartz.serializer.type", "json"}
};
var factory = new StdSchedulerFactory(props);
var scheduler = await factory.GetScheduler();
var jobFactory = new IoCJobFactory(services.BuildServiceProvider());
scheduler.JobFactory = jobFactory;
await scheduler.Start();
services.AddSingleton(scheduler);
}
}
</code></pre>
<p>And when I try run my Job (class have dependency injection) i always get Exception becouse:
</p>
<pre><code>_factory.GetService(bundle.JobDetail.JobType) as IJob;
</code></pre>
<p>is always null.</p>
<p>My class implement <code>IJob</code> and in startup.cs I add:</p>
<pre class="lang-cs prettyprint-override"><code>services.AddScoped<IJob, HelloJob>();
services.AddQuartz();
</code></pre>
<p>and
</p>
<pre><code>app.UseQuartz();
</code></pre>
<p>I using standard .net Core dependency injection:
</p>
<pre><code>using Microsoft.Extensions.DependencyInjection;
</code></pre>
| 0debug
|
How can I build a python project with osx environment on travis : <p>I am trying to build osx support for a project on Travis. The problem is osx don't ship python virtualenv natively. <a href="https://github.com/travis-ci/travis-ci/issues/2312" rel="noreferrer">Here</a> is the issue for that. I have gone through that issue and modified my travis file accordingly. Still my builds are failing with osx. <a href="https://travis-ci.org/shibasisp/python-casacore/builds/256336916" rel="noreferrer">Here</a> is a travis build link.
Here is my travis.yml file</p>
<pre><code>language: python
matrix:
include:
# Use the built in venv for linux builds
- os: linux
sudo: required
python: "2.7"
dist: trusty
- os: linux
sudo: required
python: "3.5"
dist: trusty
- os: linux
sudo: required
python: "3.6"
dist: trusty
# Use generic language for osx
- os: osx
language: generic
python: "2.7"
- os: osx
language: generic
python: "3.5"
- os: osx
language: generic
python: "3.6"
before_install:
- .travis/before_install.sh
- mkdir $HOME/data
- echo $PWD
- cd $HOME/data && wget ftp://ftp.astron.nl/outgoing/Measures/WSRT_Measures.ztar && tar xf WSRT_Measures.ztar && cd -
- echo $PWD
install:
- export PATH="$HOME/miniconda/bin:$PATH"
- source activate testenv
- export CPATH="$HOME/miniconda/envs/testenv/include:$CPATH"
- echo $CPATH
- python setup.py develop
- pip install -r tests/requirements.txt
- pip install coveralls travis-sphinx
script:
- nosetests --with-coverage
- travis-sphinx --nowarn -s doc build
</code></pre>
<p>and Here is my before_install.sh file.</p>
<pre><code>set -e
set -v
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
brew install python;
virtualenv venv -p python;
source venv/bin/activate;
else
brew install python3;
virtualenv venv -p python3;
source venv/bin/activate;
fi
fi
if [ "$TRAVIS_OS_NAME" = linux ]; then
sudo apt-get update
MINICONDAVERSION="Linux"
else
MINICONDAVERSION="MacOSX"
fi
if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda2-latest-$MINICONDAVERSION-x86_64.sh -O miniconda.sh;
else
wget https://repo.continuum.io/miniconda/Miniconda3-latest-$MINICONDAVERSION-x86_64.sh -O miniconda.sh;
fi
bash miniconda.sh -b -p $HOME/miniconda
export PATH="$HOME/miniconda/bin:$PATH"
hash -r
conda config --set always_yes yes --set changeps1 no
conda update -q conda
conda config --add channels conda-forge
# Useful for debugging any issues with conda
conda info -a
which python
conda create -q -n testenv python=$TRAVIS_PYTHON_VERSION casacore=2.3.0
echo "measures.directory: /home/travis/data" > $HOME/.casarc
</code></pre>
<p>It states the following error when I tried to build a conda environment.</p>
<pre><code>CondaValueError: invalid package specification: python=
</code></pre>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.