problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
SQL Query - Help on Query : Table has 3 fields and sample data.
customerid,ordertype,countoforders
1, APP, 10
1, WEB, 20
2, APP, 10
3, WEB, 10
4, APP, 30
5, APP, 40
5, WEB, 10
I want to retrieve only APP order customers and its counts. Can you please let me know how to write the query for the same.
For example from above table APP only customers are 2 and 4. Please assist me.
| 0debug |
update and override the image using codeignater : **I'm stuck on a problem with updating image. i did upload the multiple image and inserted in database but i can not override these images in database or my upload folder how can i override the images in my upload folder and my database 'm stuck on a problem with updating image. i did upload the multiple image and inserted in database but i can not override these images in database or my upload folder how can i override the images in my upload folder and my database**
public function edit_package($package_id){
$pname = $this->input->post('pname');
$pdur = $this->input->post('pdur');
$pdelprice = $this->input->post('pdelprice');
$price = $this->input->post('price');
$pcat = $this->input->post('pcat');
$pc = $this->input->post('pc');
$ploc = $this->input->post('ploc');
$pcat = $this->input->post('pcat');
$accom1 = $this->input->post('accom1');
$accom2 = $this->input->post('accom2');
$accom3 = $this->input->post('accom3');
$accom4 = $this->input->post('accom4');
$accom5 = $this->input->post('accom5');
$accom6 = $this->input->post('accom6');
// Displaying Errors in view
$this->form_validation->set_error_delimiters('<span style="color:red;">', '</span>');
$this->form_validation->set_rules('pname', 'Package Name', 'required');
$this->form_validation->set_rules('pdur', 'Package Duration', 'required');
$this->form_validation->set_rules('price', 'Package Price', 'required');
$this->form_validation->set_rules('pdelprice', 'Package offer Price', 'required');
$this->form_validation->set_rules('pc', 'Places Covered', 'required');
$this->form_validation->set_rules('pcat', 'Package Category', 'required');
$this->form_validation->set_rules('ploc', 'Package Location', 'required');
if ($this->form_validation->run() == False)
{
$data['editPackage'] = $this->Packages_model->editPackageVlaues($package_id);
$data['editPackage'] = $this->Packages_model->editPackageVlaues($package_id);
$data['editLocation'] = $this->Packages_model->edit_location();
$data['editPackCate'] = $this->Packages_model->getCategoryName();
$data['pkg_cat'] = $this->Packages_model->get_pkg_cat();
$data['pkg_loc'] = $this->Api_location_model->get_locations();
$this->load->view('Admin_panel/admin_assets');
$this->load->view('Admin_panel/panel');
$this->load->view('Admin_panel/Packages/edit_package',$data);
$this->load->view('Admin_panel/footer');
}
extract($_POST);
if(isset($update_package))
{
$filesCount = count($_FILES['pkg_img']['name']);
for($i = 0; $i < $filesCount; $i++)
{
$_FILES['userFile']['name'] = $_FILES['pkg_img']['name'][$i];
$_FILES['userFile']['type'] = $_FILES['pkg_img']['type'][$i];
$_FILES['userFile']['tmp_name'] = $_FILES['pkg_img']['tmp_name'][$i];
$_FILES['userFile']['error'] = $_FILES['pkg_img']['error'][$i];
$_FILES['userFile']['size'] = $_FILES['pkg_img']['size'][$i];
$config['upload_path'] = 'resources/neeraj/';
$config['allowed_types'] = 'gif|jpg|png|jpeg|GIF|JPEG|PNG|JPG';
$config['overwrite'] = TRUE;
$config['max_size'] = 2048000;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$this->upload->initialize($config);
if($this->upload->do_upload())
{
$fileData[] = $this->upload->data();
$fileName = $fileData['file_name'];
$images[] = $fileName;
$error = array('error' => $this->upload->display_errors());
$fileName = $this->upload->data('file_name');
if($this->Packages_model->update_packages($package_id,$pname,$pdur,$pdelprice,$price,$pcat,$ploc,$pc,$accom1,$accom2,$accom3,$accom4,$accom5,$accom6,$fileName))
{
$this->session->set_flashdata('package_update','Package Updated successfully');
redirect('Packages_ctrl/display_packages');
}
else
{
//upload the new image
$upload_data = $this->upload->data();
$fileName = $upload_data['file_name'];
if($_POST){
$data = array('pkg_img'=>$fileName);
//update
$this->Packages_model->update_packages($data);
}
echo "<script> alert('Please Select the Hotel Image');
window.location.href='add_packages';
</script>";
}
}
}
}
} | 0debug |
int read_targphys(int fd, target_phys_addr_t dst_addr, size_t nbytes)
{
uint8_t buf[4096];
target_phys_addr_t dst_begin = dst_addr;
size_t want, did;
while (nbytes) {
want = nbytes > sizeof(buf) ? sizeof(buf) : nbytes;
did = read(fd, buf, want);
if (did != want) break;
cpu_physical_memory_write_rom(dst_addr, buf, did);
dst_addr += did;
nbytes -= did;
}
return dst_addr - dst_begin;
}
| 1threat |
Non-consumable In App Purchases for 30k items : **Problem**
I am working on app that has 30k digital items . I want to implement **InAppPurchases** for this . So as this is digital content and only once unlock-able/Purchase-able.
**What i have already done.**
I tried to do this via consumable for same price tier but apple rejected my app and forcing to use **non-consumable.
**How to handle the following:**
1 - Do i need to create 30k in App Purchases at iTunes ???? (I read somewhere there is a limit of 10k)
2- Is there a way to reuse one in app purchase for type non-consumable.
Thanks in advance. | 0debug |
how to pass jsp parameters in sql query? : I want to write sql query wch contain parameters from jsp.
I tried to code like
String sqlstring = "\"select"+Activity+" from backgroundcost where onpremprice =' "+service+" '\"";
pstmt ps = con.preparestatment(sqlstring);
Resultset rs = ps.executeQuery();
I m getting error, can i get solution for this | 0debug |
Error date_modify() expects parameter 1 to be DateTime : <p>Full code :</p>
<pre><code>$ngayhientai = date("d/m/Y");
$ngaygiao = date_create($ngayhientai,timezone_open("Asia/Ho_Chi_Minh"));
$ngaygiao = date_modify($ngayhientai,"+3 days");
$ngaygiao = date_format($ngayhientai,"d/m/Y") ;
echo $ngaygiao;
</code></pre>
<p>Error :</p>
<pre><code>Warning: date_modify() expects parameter 1 to be DateTime, string given in C:\xampp\htdocs\weblazada\dulieu.php on line 8
Warning: date_format() expects parameter 1 to be DateTimeInterface, string given in C:\xampp\htdocs\weblazada\dulieu.php on line 9
</code></pre>
<p>Help me!Thank you everybody</p>
| 0debug |
int kvm_init(void)
{
static const char upgrade_note[] =
"Please upgrade to at least kernel 2.6.29 or recent kvm-kmod\n"
"(see http:
KVMState *s;
const KVMCapabilityInfo *missing_cap;
int ret;
int i;
int max_vcpus;
s = g_malloc0(sizeof(KVMState));
assert(TARGET_PAGE_SIZE <= getpagesize());
#ifdef KVM_CAP_SET_GUEST_DEBUG
QTAILQ_INIT(&s->kvm_sw_breakpoints);
#endif
for (i = 0; i < ARRAY_SIZE(s->slots); i++) {
s->slots[i].slot = i;
}
s->vmfd = -1;
s->fd = qemu_open("/dev/kvm", O_RDWR);
if (s->fd == -1) {
fprintf(stderr, "Could not access KVM kernel module: %m\n");
ret = -errno;
goto err;
}
ret = kvm_ioctl(s, KVM_GET_API_VERSION, 0);
if (ret < KVM_API_VERSION) {
if (ret > 0) {
ret = -EINVAL;
}
fprintf(stderr, "kvm version too old\n");
goto err;
}
if (ret > KVM_API_VERSION) {
ret = -EINVAL;
fprintf(stderr, "kvm version not supported\n");
goto err;
}
max_vcpus = kvm_max_vcpus(s);
if (smp_cpus > max_vcpus) {
ret = -EINVAL;
fprintf(stderr, "Number of SMP cpus requested (%d) exceeds max cpus "
"supported by KVM (%d)\n", smp_cpus, max_vcpus);
goto err;
}
if (max_cpus > max_vcpus) {
ret = -EINVAL;
fprintf(stderr, "Number of hotpluggable cpus requested (%d) exceeds max cpus "
"supported by KVM (%d)\n", max_cpus, max_vcpus);
goto err;
}
s->vmfd = kvm_ioctl(s, KVM_CREATE_VM, 0);
if (s->vmfd < 0) {
#ifdef TARGET_S390X
fprintf(stderr, "Please add the 'switch_amode' kernel parameter to "
"your host kernel command line\n");
#endif
ret = s->vmfd;
goto err;
}
missing_cap = kvm_check_extension_list(s, kvm_required_capabilites);
if (!missing_cap) {
missing_cap =
kvm_check_extension_list(s, kvm_arch_required_capabilities);
}
if (missing_cap) {
ret = -EINVAL;
fprintf(stderr, "kvm does not support %s\n%s",
missing_cap->name, upgrade_note);
goto err;
}
s->coalesced_mmio = kvm_check_extension(s, KVM_CAP_COALESCED_MMIO);
s->broken_set_mem_region = 1;
ret = kvm_check_extension(s, KVM_CAP_JOIN_MEMORY_REGIONS_WORKS);
if (ret > 0) {
s->broken_set_mem_region = 0;
}
#ifdef KVM_CAP_VCPU_EVENTS
s->vcpu_events = kvm_check_extension(s, KVM_CAP_VCPU_EVENTS);
#endif
s->robust_singlestep =
kvm_check_extension(s, KVM_CAP_X86_ROBUST_SINGLESTEP);
#ifdef KVM_CAP_DEBUGREGS
s->debugregs = kvm_check_extension(s, KVM_CAP_DEBUGREGS);
#endif
#ifdef KVM_CAP_XSAVE
s->xsave = kvm_check_extension(s, KVM_CAP_XSAVE);
#endif
#ifdef KVM_CAP_XCRS
s->xcrs = kvm_check_extension(s, KVM_CAP_XCRS);
#endif
#ifdef KVM_CAP_PIT_STATE2
s->pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2);
#endif
#ifdef KVM_CAP_IRQ_ROUTING
s->direct_msi = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0);
#endif
s->intx_set_mask = kvm_check_extension(s, KVM_CAP_PCI_2_3);
s->irq_set_ioctl = KVM_IRQ_LINE;
if (kvm_check_extension(s, KVM_CAP_IRQ_INJECT_STATUS)) {
s->irq_set_ioctl = KVM_IRQ_LINE_STATUS;
}
#ifdef KVM_CAP_READONLY_MEM
kvm_readonly_mem_allowed =
(kvm_check_extension(s, KVM_CAP_READONLY_MEM) > 0);
#endif
ret = kvm_arch_init(s);
if (ret < 0) {
goto err;
}
ret = kvm_irqchip_create(s);
if (ret < 0) {
goto err;
}
kvm_state = s;
memory_listener_register(&kvm_memory_listener, &address_space_memory);
memory_listener_register(&kvm_io_listener, &address_space_io);
s->many_ioeventfds = kvm_check_many_ioeventfds();
cpu_interrupt_handler = kvm_handle_interrupt;
return 0;
err:
if (s->vmfd >= 0) {
close(s->vmfd);
}
if (s->fd != -1) {
close(s->fd);
}
g_free(s);
return ret;
}
| 1threat |
static void store_slice_c(uint8_t *dst, const uint16_t *src,
int dst_linesize, int src_linesize,
int width, int height, int log2_scale,
const uint8_t dither[8][8])
{
int y, x;
#define STORE(pos) do { \
temp = ((src[x + y*src_linesize + pos] << log2_scale) + d[pos]) >> 6; \
if (temp & 0x100) \
temp = ~(temp >> 31); \
dst[x + y*dst_linesize + pos] = temp; \
} while (0)
for (y = 0; y < height; y++) {
const uint8_t *d = dither[y];
for (x = 0; x < width; x += 8) {
int temp;
STORE(0);
STORE(1);
STORE(2);
STORE(3);
STORE(4);
STORE(5);
STORE(6);
STORE(7);
}
}
}
| 1threat |
static BusState *qbus_find(const char *path)
{
DeviceState *dev;
BusState *bus;
char elem[128];
int pos, len;
if (path[0] == '/') {
bus = sysbus_get_default();
pos = 0;
} else {
if (sscanf(path, "%127[^/]%n", elem, &len) != 1) {
assert(!path[0]);
elem[0] = len = 0;
}
bus = qbus_find_recursive(sysbus_get_default(), elem, NULL);
if (!bus) {
qerror_report(QERR_BUS_NOT_FOUND, elem);
return NULL;
} else if (qbus_is_full(bus)) {
qerror_report(ERROR_CLASS_GENERIC_ERROR, "Bus '%s' is full",
elem);
return NULL;
}
pos = len;
}
for (;;) {
assert(path[pos] == '/' || !path[pos]);
while (path[pos] == '/') {
pos++;
}
if (path[pos] == '\0') {
return bus;
}
if (sscanf(path+pos, "%127[^/]%n", elem, &len) != 1) {
g_assert_not_reached();
elem[0] = len = 0;
}
pos += len;
dev = qbus_find_dev(bus, elem);
if (!dev) {
qerror_report(QERR_DEVICE_NOT_FOUND, elem);
if (!monitor_cur_is_qmp()) {
qbus_list_dev(bus);
}
return NULL;
}
assert(path[pos] == '/' || !path[pos]);
while (path[pos] == '/') {
pos++;
}
if (path[pos] == '\0') {
switch (dev->num_child_bus) {
case 0:
qerror_report(ERROR_CLASS_GENERIC_ERROR,
"Device '%s' has no child bus", elem);
return NULL;
case 1:
return QLIST_FIRST(&dev->child_bus);
default:
qerror_report(ERROR_CLASS_GENERIC_ERROR,
"Device '%s' has multiple child busses", elem);
if (!monitor_cur_is_qmp()) {
qbus_list_bus(dev);
}
return NULL;
}
}
if (sscanf(path+pos, "%127[^/]%n", elem, &len) != 1) {
g_assert_not_reached();
elem[0] = len = 0;
}
pos += len;
bus = qbus_find_bus(dev, elem);
if (!bus) {
qerror_report(QERR_BUS_NOT_FOUND, elem);
if (!monitor_cur_is_qmp()) {
qbus_list_bus(dev);
}
return NULL;
}
}
}
| 1threat |
hello, I have a question about Flutter navigator/MaterialPageRoute , please help me : I have a BUTTON ,here is some code:
[enter image description here][1]
and i got the error like this:[enter image description here][2]
i never met the error like this, but when i add the 'dynamic' like this:[enter image description here][3]
[1]: https://i.stack.imgur.com/meoic.png
[2]: https://i.stack.imgur.com/0o4aD.png
[3]: https://i.stack.imgur.com/0UXkO.png
i am so confusing ! plz help ! | 0debug |
How to set the default working directory for run configurations in PyCharm : <p>When I want to run one of our many python scripts I hit run, which creates a new run configuration. The working directory for that configuration is the folder in which the python script file resides. Instead, it should run from a project wide fixed folder. I'd like to set that somehow but I really cannot figure out why, which is a bit odd as I'd expect many people to want to have this functionality.
Do you know how to pull this off?</p>
| 0debug |
beforeunload not working in Safari 9.1 after the page reloads on clicking leave page button : <p>In safari 9.1,jquery beforeunload browser pop up doesnt show up for the second time.
Once the user clicks on leave page button in the pop up the page reloads.But after this the pop up never comes up though the controls goes to the code. Unless the browser is reopened again the pop up never shows up.
PFB the code</p>
<pre><code>window.addEventListener("beforeunload", function (e) {
if(condition) {
e.returnValue=""; // for chrome
return "message";
}
});
</code></pre>
| 0debug |
Euclidean GCD function returns type None instead of int : <p>I'm getting back into mathematics, algorithms, and data structures. Today, I spent time studying up on the Euclidean algorithm and greatest common divisors. </p>
<p>Below, I implemented a function to demonstrate what I learned: </p>
<pre><code>from math import floor
def euclidian(a: int, b: int):
# a = b * q + r
_q: int = int(floor(a / b))
print(f"Quotient: {_q}")
r: int = a % b
print(f"Remainder: {r}")
a = b
print(f"A = B({a})")
b = r
print(f"B = R({b})")
if a != 0 and b != 0:
euclidian(a, b)
# a = 0; gcd(0, b) = b
elif a == 0:
print(f"Returning value a({b}) | type: {type(b)}")
return b
# b = 0; gcd(a, 0) = a
elif b == 0:
print(f"Returning value a({a}) | type: {type(a)}")
return a
a: int = 270
b: int = 192
gcd: int = euclidian(a, b)
print(f"GCD type: {type(gcd)}")
print(f"GCD({a}, {b}) = {gcd}")
</code></pre>
<p>This recursive function goes through a couple iterations, and ends up returning these results: </p>
<pre><code>Quotient: 6
Remainder: 0
A = B(6)
B = R(0)
Returning value a(6) | type: <class 'int'>
GCD type: <class 'NoneType'>
GCD(270, 192) = None
</code></pre>
<p>It's getting later in the day, so perhaps I just need a cup of tea to wake myself up. But I can't seem to wrap my head around why the variable <code>gcd</code> is <code>None</code> and not the integer value of <code>a</code>. What am I missing? </p>
<p>Thanks.</p>
| 0debug |
How to configure Kubernetes to encrypt the traffic between nodes, and pods? : <p>In preparation for HIPAA compliance, we are transitioning our Kubernetes cluster to use secure endpoints across the fleet (between all pods). Since the cluster is composed of about 8-10 services currently using HTTP connections, it would be super useful to have this taken care of by Kubernetes. </p>
<p>The specific attack vector we'd like to address with this is packet sniffing between nodes (physical servers).</p>
<p>This question breaks down into two parts:</p>
<ul>
<li>Does Kubernetes encrypts the traffic between pods & nodes by default?</li>
<li>If not, is there a way to configure it such?</li>
</ul>
<p>Many thanks!</p>
| 0debug |
not work indexOf() for array that is from ajax text file data : jQuery version 1.4.4
aaa.txt
includes just 3row
01000
01001
01139
$.ajax({
url: "aaa.txt",
success: function(result){
console.log(result);
var rArr = result.split("\n");
var ee = rArr.indexOf("01001");
console.log(ee);
}
});
return -1.
i guess it should return 1.
all the type are string.
i can't understand why this situation happens.
please give me answers you good guys thank you very much. | 0debug |
Can I use the Blade templating engine outside of Laravel? : <p>i'm want to creating a design pattern and use the "Blade templating engine".
Can I use the Blade templating engine outside of Laravel and use it in my new pattern ?</p>
| 0debug |
What is the diffrence between android api 17 and 23? : <p>So, i made a simple game in android studio and everything worked fine on my api 17 device. For some reason it doesn't want to work on my other device with api 23. It instantly stops working. I'm pretty sure it has nothing to do with permissions (that was the only thing that i found on google). My app uses only Google game services and sharedprefernces. I'm quiete new so dont hate if the question doesn't makes sense or something.</p>
| 0debug |
select all elements after element without jquery : I need to acces to all elements after certain element to change some attributes. I know there is nextAll() but I can't use jquery.
[i need to erase first answer and answer 2 to be updated to 1][1]
Thanks for the help.
[1]: https://i.stack.imgur.com/X1Yx8.png | 0debug |
Python Max value for each key in a list : Given:
`scooby = [1,4,1,4,1,4,1,1,4]
snacks = [6,28,14,3,9,8,18,6,7]
scoobysnacks = zip(scooby,snack)`
How do I run max(scoobysnacks) to get:
(1,18) and (4,28) as a result?
| 0debug |
void arm_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
{
int i;
(*cpu_fprintf)(f, "Available CPUs:\n");
for (i = 0; arm_cpu_names[i].name; i++) {
(*cpu_fprintf)(f, " %s\n", arm_cpu_names[i].name);
}
}
| 1threat |
Can anyone help me out with this, i got this error while executing the below script : from selenium import webdriver
driver = webdriver.Chrome()
driver = webdriver.Chrome(r'C:\Users\New User
prof\Downloads\chromedriver_win32.zip\chromedriver.exe')
driver.get ("https://www.google.com/webmasters/tools/url-removal?
hl=en&siteUrl=https://www.greatbuyz.com/&mesd=AB9YKzIL4DBt4yX8SVayjC2kUq8yeXctK_u2WGH4KlESTcjXkcOsdBvVP7TnX4S4bBF4PADFQzZAxIqcxMiVerW67kTw-UGIWjHVftlzX5DNcJjm3Uz5wBpWxkDYY7IIFlVMdiEvTsAG_GwgA_DqO7Exg5w80HGHX_lk4okr-Ay7vrCG63zKVLrMGmyNMUPGEESjX2rJF-Xx&authuser=2")
driver.find_element_by_xpath("//button[@class='goog-inline-block jfk-button
jfk-button-standard']").click()
Error:
Traceback (most recent call last):
File "/root/pythonnk/my_env/lib64/python3.6/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/usr/lib64/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/usr/lib64/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver': 'chromedriver'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "bot.py", line 4, in <module>
driver = webdriver.Chrome()
File "/root/pythonnk/my_env/lib64/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/root/pythonnk/my_env/lib64/python3.6/site-packages/selenium/webdriver/common/service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
| 0debug |
Is JS input spinners exists? NO JQUERY : <p>I'm looking for js spinners as on picture below (left & right control keys).
But i don't want to use jquery in my project. If you have any snippets, useful links - please paste it here. :) Simple short code is preferred.. :)
Maybe it has another name (not spinner, but.. ?)? </p>
<p><a href="https://i.stack.imgur.com/5sy6A.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5sy6A.jpg" alt="enter image description here"></a></p>
| 0debug |
How can I make a Grafana template with a variable reference another variable using Prometheus as a datasource? : <p>I have a Grafana dashboard with template variables for <code>services</code> and <code>instances</code>. When I select a service how can I make it filter the second template variable list based on the first?</p>
| 0debug |
Prevent TensorFlow from accessing the GPU? : <p>Is there a way to run TensorFlow purely on the CPU. All of the memory on my machine is hogged by a separate process running TensorFlow. I have tried setting the per_process_memory_fraction to 0, unsuccessfully.</p>
| 0debug |
How to loop the following inside a script, till they all deleted then continue? [Python] [Selenium] [Helium] : How to loop the following inside a script, till they all deleted then continue?
e.g. if there are X, then deleted X and conitue ( X = dynamic ) and so on.
if Text("Remove").exists():
click("Remove")
| 0debug |
Please how do you make a button click event bring about random labels : I tried making arrays labels but it seemed unsuccessful | 0debug |
extract data from csv and rename files : <p>I have files in a folder.</p>
<p>Filenames in this folder are available in a .csv file's column B.</p>
<p>Column A contains new file name.</p>
<p>Eg,</p>
<p>Attached pic.
<a href="https://i.stack.imgur.com/oXOVY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oXOVY.png" alt="enter image description here"></a></p>
<p>How do I rename files in the folder based on column A using VB.NET ?</p>
| 0debug |
Bash. getopts command. option that will do smth in the end of the program : Problem:
If my program takes option '-v' it should print "Good bye!" in the end of the program. I can do this, buy it will print is in the beginning. So i need some command that will execute it in the end, if any. Or how can i do this?
getopts "v" opt
case ${opt} in
v) echo "Good bye!"
esac | 0debug |
Passing an arraylist of object from servlet to jsp failed : <p>this things is giving me headache for the past 3 days already. I tried to store the resultset that i get from the database and store inside an arraylist of object then pass it to the jsp for display, but after running the program, it gave me this error:
<a href="http://i.stack.imgur.com/c2hI6.png" rel="nofollow">enter image description here</a></p>
<p>anyone have any idea how to solve this problem? Thanks in advance!
below is my code:
menu.java</p>
<pre><code>@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
try {
Class.forName("com.mysql.jdbc.Driver");
//Create connection object
conn = DriverManager.getConnection(request.getServletContext().getInitParameter("url"), request.getServletContext().getInitParameter("username"), request.getServletContext().getInitParameter("password"));
String sql = "select name,price,imageurl from food";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
class food {
String name;
double price;
String imageurl;
}
ArrayList<food> foodDetail = new ArrayList<food>();
while (rs.next()) {
food temp = new food();
temp.name = rs.getString("name");
temp.price = rs.getDouble("price");
temp.imageurl = rs.getString("imageurl");
foodDetail.add(temp);
}
request.setAttribute("menu", foodDetail);
RequestDispatcher req = request.getRequestDispatcher("menu.jsp");
req.forward(request, response);
} catch (ClassNotFoundException ex) {
Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException ex) {
Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
rs.close();
stmt.close();
conn.close();
} catch (SQLException ex) {
}
}
</code></pre>
<p>menu.jsp</p>
<pre><code><%
class food {
String name;
double price;
String imageurl;
}
ArrayList<food> foodDetail = (ArrayList<food>) request.getAttribute("menu");
food temp = new food();
java.util.Iterator it = foodDetail.iterator();
while (it.hasNext()) {
food z = (food) it.next();
out.println(z.getName());
}
%>
</code></pre>
| 0debug |
How can i use pandas to parse dataframe with specific column and write to sheets in one excel file : I uesed this but it won't work
for group in z3.group:
group=z3[z3['group']==group]
group.to_csv('group.csv',encoding='gbk') | 0debug |
how to show query while using query annotations with MongoRepository with spring data : <p>I'm using MongoRepository in spring boot to access mongo:</p>
<pre><code>public interface MongoReadRepository extends MongoRepository<User, String> {
@Query(value = "{$where: 'this.name == ?0'}", count = true)
public Long countName(String name);
}
</code></pre>
<p>and it could work, but i wonder know the exactly query it accessing mongo</p>
<p>how to do that?</p>
<p>i try to adding some config at properties like below:</p>
<pre><code>logging.level.org.springframework.data.mongodb.core.MongoTemplate=DEBUG
logging.level.org.springframework.data.mongodb.repository.Query=DEBUG
</code></pre>
<p>and don't work.</p>
<p>could somebody help?</p>
| 0debug |
Click on an element if a condition is true Angular js : I have an Angular js view.html page where I am passing a string called **datadict** from the $scope method of controller.
Value {{ datadict.days }} is displaying value **Nearly everyday** and {{ datadict.days.includes('Nearly everyday') }} is showing result **true**.
Here is my code :
<div class="some_class">
<ul class="ex1">
<li><a ng-click ="datadict.days.includes('Not applicable')" class="mdcl-tab1">Not applicable</a> </li>
<li><a ng-click ="datadict.days.includes('Several Days')" class="mdcl-tab1">Several Days</a> </li>
<li><a ng-click ="datadict.days.includes('More than half the days')" class="mdcl-tab1">More than half the days</a> </li>
<li><a ng-click ="datadict.days.includes('Nearly everyday')" class="mdcl-tab1">Nearly everyday</a> </li>
</ul>
</div>
The problem is I want to click on the <a> element which satisfies the above condition that's why I added this condition **ng-click ="datadict.days.includes('Nearly everyday')"** but I am not getting the desired result. What am I doing wrong ? | 0debug |
cursor.execute('SELECT * FROM users WHERE username = ' + user_input) | 1threat |
static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)
{
int32_t offset;
int rs, rt, rd, sa;
uint32_t op, op1, op2;
int16_t imm;
if (ctx->pc & 0x3) {
env->CP0_BadVAddr = ctx->pc;
generate_exception(ctx, EXCP_AdEL);
return;
}
if ((ctx->hflags & MIPS_HFLAG_BMASK_BASE) == MIPS_HFLAG_BL) {
int l1 = gen_new_label();
MIPS_DEBUG("blikely condition (" TARGET_FMT_lx ")", ctx->pc + 4);
tcg_gen_brcondi_tl(TCG_COND_NE, bcond, 0, l1);
tcg_gen_movi_i32(hflags, ctx->hflags & ~MIPS_HFLAG_BMASK);
gen_goto_tb(ctx, 1, ctx->pc + 4);
gen_set_label(l1);
}
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_debug_insn_start(ctx->pc);
}
op = MASK_OP_MAJOR(ctx->opcode);
rs = (ctx->opcode >> 21) & 0x1f;
rt = (ctx->opcode >> 16) & 0x1f;
rd = (ctx->opcode >> 11) & 0x1f;
sa = (ctx->opcode >> 6) & 0x1f;
imm = (int16_t)ctx->opcode;
switch (op) {
case OPC_SPECIAL:
op1 = MASK_SPECIAL(ctx->opcode);
switch (op1) {
case OPC_SLL:
case OPC_SRA:
gen_shift_imm(ctx, op1, rd, rt, sa);
break;
case OPC_SRL:
switch ((ctx->opcode >> 21) & 0x1f) {
case 1:
if (ctx->insn_flags & ISA_MIPS32R2) {
op1 = OPC_ROTR;
}
case 0:
gen_shift_imm(ctx, op1, rd, rt, sa);
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_MOVN:
case OPC_MOVZ:
check_insn(ctx, ISA_MIPS4 | ISA_MIPS32 |
INSN_LOONGSON2E | INSN_LOONGSON2F);
gen_cond_move(ctx, op1, rd, rs, rt);
break;
case OPC_ADD ... OPC_SUBU:
gen_arith(ctx, op1, rd, rs, rt);
break;
case OPC_SLLV:
case OPC_SRAV:
gen_shift(ctx, op1, rd, rs, rt);
break;
case OPC_SRLV:
switch ((ctx->opcode >> 6) & 0x1f) {
case 1:
if (ctx->insn_flags & ISA_MIPS32R2) {
op1 = OPC_ROTRV;
}
case 0:
gen_shift(ctx, op1, rd, rs, rt);
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_SLT:
case OPC_SLTU:
gen_slt(ctx, op1, rd, rs, rt);
break;
case OPC_AND:
case OPC_OR:
case OPC_NOR:
case OPC_XOR:
gen_logic(ctx, op1, rd, rs, rt);
break;
case OPC_MULT:
case OPC_MULTU:
if (sa) {
check_insn(ctx, INSN_VR54XX);
op1 = MASK_MUL_VR54XX(ctx->opcode);
gen_mul_vr54xx(ctx, op1, rd, rs, rt);
} else {
gen_muldiv(ctx, op1, rd & 3, rs, rt);
}
break;
case OPC_DIV:
case OPC_DIVU:
gen_muldiv(ctx, op1, 0, rs, rt);
break;
case OPC_JR ... OPC_JALR:
gen_compute_branch(ctx, op1, 4, rs, rd, sa);
*is_branch = 1;
break;
case OPC_TGE ... OPC_TEQ:
case OPC_TNE:
gen_trap(ctx, op1, rs, rt, -1);
break;
case OPC_MFHI:
case OPC_MFLO:
gen_HILO(ctx, op1, rs & 3, rd);
break;
case OPC_MTHI:
case OPC_MTLO:
gen_HILO(ctx, op1, rd & 3, rs);
break;
case OPC_PMON:
#ifdef MIPS_STRICT_STANDARD
MIPS_INVAL("PMON / selsl");
generate_exception(ctx, EXCP_RI);
#else
gen_helper_0e0i(pmon, sa);
#endif
break;
case OPC_SYSCALL:
generate_exception(ctx, EXCP_SYSCALL);
ctx->bstate = BS_STOP;
break;
case OPC_BREAK:
generate_exception(ctx, EXCP_BREAK);
break;
case OPC_SPIM:
#ifdef MIPS_STRICT_STANDARD
MIPS_INVAL("SPIM");
generate_exception(ctx, EXCP_RI);
#else
MIPS_INVAL("spim (unofficial)");
generate_exception(ctx, EXCP_RI);
#endif
break;
case OPC_SYNC:
break;
case OPC_MOVCI:
check_insn(ctx, ISA_MIPS4 | ISA_MIPS32);
if (env->CP0_Config1 & (1 << CP0C1_FP)) {
check_cp1_enabled(ctx);
gen_movci(ctx, rd, rs, (ctx->opcode >> 18) & 0x7,
(ctx->opcode >> 16) & 1);
} else {
generate_exception_err(ctx, EXCP_CpU, 1);
}
break;
#if defined(TARGET_MIPS64)
case OPC_DSLL:
case OPC_DSRA:
case OPC_DSLL32:
case OPC_DSRA32:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_shift_imm(ctx, op1, rd, rt, sa);
break;
case OPC_DSRL:
switch ((ctx->opcode >> 21) & 0x1f) {
case 1:
if (ctx->insn_flags & ISA_MIPS32R2) {
op1 = OPC_DROTR;
}
case 0:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_shift_imm(ctx, op1, rd, rt, sa);
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_DSRL32:
switch ((ctx->opcode >> 21) & 0x1f) {
case 1:
if (ctx->insn_flags & ISA_MIPS32R2) {
op1 = OPC_DROTR32;
}
case 0:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_shift_imm(ctx, op1, rd, rt, sa);
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_DADD ... OPC_DSUBU:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_arith(ctx, op1, rd, rs, rt);
break;
case OPC_DSLLV:
case OPC_DSRAV:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_shift(ctx, op1, rd, rs, rt);
break;
case OPC_DSRLV:
switch ((ctx->opcode >> 6) & 0x1f) {
case 1:
if (ctx->insn_flags & ISA_MIPS32R2) {
op1 = OPC_DROTRV;
}
case 0:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_shift(ctx, op1, rd, rs, rt);
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_DMULT ... OPC_DDIVU:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_muldiv(ctx, op1, 0, rs, rt);
break;
#endif
default:
MIPS_INVAL("special");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_SPECIAL2:
op1 = MASK_SPECIAL2(ctx->opcode);
switch (op1) {
case OPC_MADD ... OPC_MADDU:
case OPC_MSUB ... OPC_MSUBU:
check_insn(ctx, ISA_MIPS32);
gen_muldiv(ctx, op1, rd & 3, rs, rt);
break;
case OPC_MUL:
gen_arith(ctx, op1, rd, rs, rt);
break;
case OPC_CLO:
case OPC_CLZ:
check_insn(ctx, ISA_MIPS32);
gen_cl(ctx, op1, rd, rs);
break;
case OPC_SDBBP:
check_insn(ctx, ISA_MIPS32);
if (!(ctx->hflags & MIPS_HFLAG_DM)) {
generate_exception(ctx, EXCP_DBp);
} else {
generate_exception(ctx, EXCP_DBp);
}
break;
case OPC_DIV_G_2F:
case OPC_DIVU_G_2F:
case OPC_MULT_G_2F:
case OPC_MULTU_G_2F:
case OPC_MOD_G_2F:
case OPC_MODU_G_2F:
check_insn(ctx, INSN_LOONGSON2F);
gen_loongson_integer(ctx, op1, rd, rs, rt);
break;
#if defined(TARGET_MIPS64)
case OPC_DCLO:
case OPC_DCLZ:
check_insn(ctx, ISA_MIPS64);
check_mips_64(ctx);
gen_cl(ctx, op1, rd, rs);
break;
case OPC_DMULT_G_2F:
case OPC_DMULTU_G_2F:
case OPC_DDIV_G_2F:
case OPC_DDIVU_G_2F:
case OPC_DMOD_G_2F:
case OPC_DMODU_G_2F:
check_insn(ctx, INSN_LOONGSON2F);
gen_loongson_integer(ctx, op1, rd, rs, rt);
break;
#endif
default:
MIPS_INVAL("special2");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_SPECIAL3:
op1 = MASK_SPECIAL3(ctx->opcode);
switch (op1) {
case OPC_EXT:
case OPC_INS:
check_insn(ctx, ISA_MIPS32R2);
gen_bitops(ctx, op1, rt, rs, sa, rd);
break;
case OPC_BSHFL:
check_insn(ctx, ISA_MIPS32R2);
op2 = MASK_BSHFL(ctx->opcode);
gen_bshfl(ctx, op2, rt, rd);
break;
case OPC_RDHWR:
gen_rdhwr(ctx, rt, rd);
break;
case OPC_FORK:
check_insn(ctx, ASE_MT);
{
TCGv t0 = tcg_temp_new();
TCGv t1 = tcg_temp_new();
gen_load_gpr(t0, rt);
gen_load_gpr(t1, rs);
gen_helper_fork(t0, t1);
tcg_temp_free(t0);
tcg_temp_free(t1);
}
break;
case OPC_YIELD:
check_insn(ctx, ASE_MT);
{
TCGv t0 = tcg_temp_new();
save_cpu_state(ctx, 1);
gen_load_gpr(t0, rs);
gen_helper_yield(t0, cpu_env, t0);
gen_store_gpr(t0, rd);
tcg_temp_free(t0);
}
break;
case OPC_DIV_G_2E ... OPC_DIVU_G_2E:
case OPC_MOD_G_2E ... OPC_MODU_G_2E:
case OPC_MULT_G_2E ... OPC_MULTU_G_2E:
if ((ctx->insn_flags & ASE_DSPR2) && (op1 == OPC_MULT_G_2E)) {
op2 = MASK_ADDUH_QB(ctx->opcode);
switch (op2) {
case OPC_ADDUH_QB:
case OPC_ADDUH_R_QB:
case OPC_ADDQH_PH:
case OPC_ADDQH_R_PH:
case OPC_ADDQH_W:
case OPC_ADDQH_R_W:
case OPC_SUBUH_QB:
case OPC_SUBUH_R_QB:
case OPC_SUBQH_PH:
case OPC_SUBQH_R_PH:
case OPC_SUBQH_W:
case OPC_SUBQH_R_W:
gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt);
break;
case OPC_MUL_PH:
case OPC_MUL_S_PH:
case OPC_MULQ_S_W:
case OPC_MULQ_RS_W:
gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 1);
break;
default:
MIPS_INVAL("MASK ADDUH.QB");
generate_exception(ctx, EXCP_RI);
break;
}
} else if (ctx->insn_flags & INSN_LOONGSON2E) {
gen_loongson_integer(ctx, op1, rd, rs, rt);
} else {
generate_exception(ctx, EXCP_RI);
}
break;
case OPC_LX_DSP:
op2 = MASK_LX(ctx->opcode);
switch (op2) {
#if defined(TARGET_MIPS64)
case OPC_LDX:
#endif
case OPC_LBUX:
case OPC_LHX:
case OPC_LWX:
gen_mipsdsp_ld(ctx, op2, rd, rs, rt);
break;
default:
MIPS_INVAL("MASK LX");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_ABSQ_S_PH_DSP:
op2 = MASK_ABSQ_S_PH(ctx->opcode);
switch (op2) {
case OPC_ABSQ_S_QB:
case OPC_ABSQ_S_PH:
case OPC_ABSQ_S_W:
case OPC_PRECEQ_W_PHL:
case OPC_PRECEQ_W_PHR:
case OPC_PRECEQU_PH_QBL:
case OPC_PRECEQU_PH_QBR:
case OPC_PRECEQU_PH_QBLA:
case OPC_PRECEQU_PH_QBRA:
case OPC_PRECEU_PH_QBL:
case OPC_PRECEU_PH_QBR:
case OPC_PRECEU_PH_QBLA:
case OPC_PRECEU_PH_QBRA:
gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt);
break;
case OPC_BITREV:
case OPC_REPL_QB:
case OPC_REPLV_QB:
case OPC_REPL_PH:
case OPC_REPLV_PH:
gen_mipsdsp_bitinsn(ctx, op1, op2, rd, rt);
break;
default:
MIPS_INVAL("MASK ABSQ_S.PH");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_ADDU_QB_DSP:
op2 = MASK_ADDU_QB(ctx->opcode);
switch (op2) {
case OPC_ADDQ_PH:
case OPC_ADDQ_S_PH:
case OPC_ADDQ_S_W:
case OPC_ADDU_QB:
case OPC_ADDU_S_QB:
case OPC_ADDU_PH:
case OPC_ADDU_S_PH:
case OPC_SUBQ_PH:
case OPC_SUBQ_S_PH:
case OPC_SUBQ_S_W:
case OPC_SUBU_QB:
case OPC_SUBU_S_QB:
case OPC_SUBU_PH:
case OPC_SUBU_S_PH:
case OPC_ADDSC:
case OPC_ADDWC:
case OPC_MODSUB:
case OPC_RADDU_W_QB:
gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt);
break;
case OPC_MULEU_S_PH_QBL:
case OPC_MULEU_S_PH_QBR:
case OPC_MULQ_RS_PH:
case OPC_MULEQ_S_W_PHL:
case OPC_MULEQ_S_W_PHR:
case OPC_MULQ_S_PH:
gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 1);
break;
default:
MIPS_INVAL("MASK ADDU.QB");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_CMPU_EQ_QB_DSP:
op2 = MASK_CMPU_EQ_QB(ctx->opcode);
switch (op2) {
case OPC_PRECR_SRA_PH_W:
case OPC_PRECR_SRA_R_PH_W:
gen_mipsdsp_arith(ctx, op1, op2, rt, rs, rd);
break;
case OPC_PRECR_QB_PH:
case OPC_PRECRQ_QB_PH:
case OPC_PRECRQ_PH_W:
case OPC_PRECRQ_RS_PH_W:
case OPC_PRECRQU_S_QB_PH:
gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt);
break;
case OPC_CMPU_EQ_QB:
case OPC_CMPU_LT_QB:
case OPC_CMPU_LE_QB:
case OPC_CMP_EQ_PH:
case OPC_CMP_LT_PH:
case OPC_CMP_LE_PH:
gen_mipsdsp_add_cmp_pick(ctx, op1, op2, rd, rs, rt, 0);
break;
case OPC_CMPGU_EQ_QB:
case OPC_CMPGU_LT_QB:
case OPC_CMPGU_LE_QB:
case OPC_CMPGDU_EQ_QB:
case OPC_CMPGDU_LT_QB:
case OPC_CMPGDU_LE_QB:
case OPC_PICK_QB:
case OPC_PICK_PH:
case OPC_PACKRL_PH:
gen_mipsdsp_add_cmp_pick(ctx, op1, op2, rd, rs, rt, 1);
break;
default:
MIPS_INVAL("MASK CMPU.EQ.QB");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_SHLL_QB_DSP:
gen_mipsdsp_shift(ctx, op1, rd, rs, rt);
break;
case OPC_DPA_W_PH_DSP:
op2 = MASK_DPA_W_PH(ctx->opcode);
switch (op2) {
case OPC_DPAU_H_QBL:
case OPC_DPAU_H_QBR:
case OPC_DPSU_H_QBL:
case OPC_DPSU_H_QBR:
case OPC_DPA_W_PH:
case OPC_DPAX_W_PH:
case OPC_DPAQ_S_W_PH:
case OPC_DPAQX_S_W_PH:
case OPC_DPAQX_SA_W_PH:
case OPC_DPS_W_PH:
case OPC_DPSX_W_PH:
case OPC_DPSQ_S_W_PH:
case OPC_DPSQX_S_W_PH:
case OPC_DPSQX_SA_W_PH:
case OPC_MULSAQ_S_W_PH:
case OPC_DPAQ_SA_L_W:
case OPC_DPSQ_SA_L_W:
case OPC_MAQ_S_W_PHL:
case OPC_MAQ_S_W_PHR:
case OPC_MAQ_SA_W_PHL:
case OPC_MAQ_SA_W_PHR:
case OPC_MULSA_W_PH:
gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 0);
break;
default:
MIPS_INVAL("MASK DPAW.PH");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_INSV_DSP:
op2 = MASK_INSV(ctx->opcode);
switch (op2) {
case OPC_INSV:
check_dsp(ctx);
{
TCGv t0, t1;
if (rt == 0) {
MIPS_DEBUG("NOP");
break;
}
t0 = tcg_temp_new();
t1 = tcg_temp_new();
gen_load_gpr(t0, rt);
gen_load_gpr(t1, rs);
gen_helper_insv(cpu_gpr[rt], cpu_env, t1, t0);
tcg_temp_free(t0);
tcg_temp_free(t1);
break;
}
default:
MIPS_INVAL("MASK INSV");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_APPEND_DSP:
gen_mipsdsp_append(env, ctx, op1, rt, rs, rd);
break;
case OPC_EXTR_W_DSP:
op2 = MASK_EXTR_W(ctx->opcode);
switch (op2) {
case OPC_EXTR_W:
case OPC_EXTR_R_W:
case OPC_EXTR_RS_W:
case OPC_EXTR_S_H:
case OPC_EXTRV_S_H:
case OPC_EXTRV_W:
case OPC_EXTRV_R_W:
case OPC_EXTRV_RS_W:
case OPC_EXTP:
case OPC_EXTPV:
case OPC_EXTPDP:
case OPC_EXTPDPV:
gen_mipsdsp_accinsn(ctx, op1, op2, rt, rs, rd, 1);
break;
case OPC_RDDSP:
gen_mipsdsp_accinsn(ctx, op1, op2, rd, rs, rt, 1);
break;
case OPC_SHILO:
case OPC_SHILOV:
case OPC_MTHLIP:
case OPC_WRDSP:
gen_mipsdsp_accinsn(ctx, op1, op2, rd, rs, rt, 0);
break;
default:
MIPS_INVAL("MASK EXTR.W");
generate_exception(ctx, EXCP_RI);
break;
}
break;
#if defined(TARGET_MIPS64)
case OPC_DEXTM ... OPC_DEXT:
case OPC_DINSM ... OPC_DINS:
check_insn(ctx, ISA_MIPS64R2);
check_mips_64(ctx);
gen_bitops(ctx, op1, rt, rs, sa, rd);
break;
case OPC_DBSHFL:
check_insn(ctx, ISA_MIPS64R2);
check_mips_64(ctx);
op2 = MASK_DBSHFL(ctx->opcode);
gen_bshfl(ctx, op2, rt, rd);
break;
case OPC_DDIV_G_2E ... OPC_DDIVU_G_2E:
case OPC_DMULT_G_2E ... OPC_DMULTU_G_2E:
case OPC_DMOD_G_2E ... OPC_DMODU_G_2E:
check_insn(ctx, INSN_LOONGSON2E);
gen_loongson_integer(ctx, op1, rd, rs, rt);
break;
case OPC_ABSQ_S_QH_DSP:
op2 = MASK_ABSQ_S_QH(ctx->opcode);
switch (op2) {
case OPC_PRECEQ_L_PWL:
case OPC_PRECEQ_L_PWR:
case OPC_PRECEQ_PW_QHL:
case OPC_PRECEQ_PW_QHR:
case OPC_PRECEQ_PW_QHLA:
case OPC_PRECEQ_PW_QHRA:
case OPC_PRECEQU_QH_OBL:
case OPC_PRECEQU_QH_OBR:
case OPC_PRECEQU_QH_OBLA:
case OPC_PRECEQU_QH_OBRA:
case OPC_PRECEU_QH_OBL:
case OPC_PRECEU_QH_OBR:
case OPC_PRECEU_QH_OBLA:
case OPC_PRECEU_QH_OBRA:
case OPC_ABSQ_S_OB:
case OPC_ABSQ_S_PW:
case OPC_ABSQ_S_QH:
gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt);
break;
case OPC_REPL_OB:
case OPC_REPL_PW:
case OPC_REPL_QH:
case OPC_REPLV_OB:
case OPC_REPLV_PW:
case OPC_REPLV_QH:
gen_mipsdsp_bitinsn(ctx, op1, op2, rd, rt);
break;
default:
MIPS_INVAL("MASK ABSQ_S.QH");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_ADDU_OB_DSP:
op2 = MASK_ADDU_OB(ctx->opcode);
switch (op2) {
case OPC_RADDU_L_OB:
case OPC_SUBQ_PW:
case OPC_SUBQ_S_PW:
case OPC_SUBQ_QH:
case OPC_SUBQ_S_QH:
case OPC_SUBU_OB:
case OPC_SUBU_S_OB:
case OPC_SUBU_QH:
case OPC_SUBU_S_QH:
case OPC_SUBUH_OB:
case OPC_SUBUH_R_OB:
case OPC_ADDQ_PW:
case OPC_ADDQ_S_PW:
case OPC_ADDQ_QH:
case OPC_ADDQ_S_QH:
case OPC_ADDU_OB:
case OPC_ADDU_S_OB:
case OPC_ADDU_QH:
case OPC_ADDU_S_QH:
case OPC_ADDUH_OB:
case OPC_ADDUH_R_OB:
gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt);
break;
case OPC_MULEQ_S_PW_QHL:
case OPC_MULEQ_S_PW_QHR:
case OPC_MULEU_S_QH_OBL:
case OPC_MULEU_S_QH_OBR:
case OPC_MULQ_RS_QH:
gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 1);
break;
default:
MIPS_INVAL("MASK ADDU.OB");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_CMPU_EQ_OB_DSP:
op2 = MASK_CMPU_EQ_OB(ctx->opcode);
switch (op2) {
case OPC_PRECR_SRA_QH_PW:
case OPC_PRECR_SRA_R_QH_PW:
gen_mipsdsp_arith(ctx, op1, op2, rt, rs, rd);
break;
case OPC_PRECR_OB_QH:
case OPC_PRECRQ_OB_QH:
case OPC_PRECRQ_PW_L:
case OPC_PRECRQ_QH_PW:
case OPC_PRECRQ_RS_QH_PW:
case OPC_PRECRQU_S_OB_QH:
gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt);
break;
case OPC_CMPU_EQ_OB:
case OPC_CMPU_LT_OB:
case OPC_CMPU_LE_OB:
case OPC_CMP_EQ_QH:
case OPC_CMP_LT_QH:
case OPC_CMP_LE_QH:
case OPC_CMP_EQ_PW:
case OPC_CMP_LT_PW:
case OPC_CMP_LE_PW:
gen_mipsdsp_add_cmp_pick(ctx, op1, op2, rd, rs, rt, 0);
break;
case OPC_CMPGDU_EQ_OB:
case OPC_CMPGDU_LT_OB:
case OPC_CMPGDU_LE_OB:
case OPC_CMPGU_EQ_OB:
case OPC_CMPGU_LT_OB:
case OPC_CMPGU_LE_OB:
case OPC_PACKRL_PW:
case OPC_PICK_OB:
case OPC_PICK_PW:
case OPC_PICK_QH:
gen_mipsdsp_add_cmp_pick(ctx, op1, op2, rd, rs, rt, 1);
break;
default:
MIPS_INVAL("MASK CMPU_EQ.OB");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_DAPPEND_DSP:
gen_mipsdsp_append(env, ctx, op1, rt, rs, rd);
break;
case OPC_DEXTR_W_DSP:
op2 = MASK_DEXTR_W(ctx->opcode);
switch (op2) {
case OPC_DEXTP:
case OPC_DEXTPDP:
case OPC_DEXTPDPV:
case OPC_DEXTPV:
case OPC_DEXTR_L:
case OPC_DEXTR_R_L:
case OPC_DEXTR_RS_L:
case OPC_DEXTR_W:
case OPC_DEXTR_R_W:
case OPC_DEXTR_RS_W:
case OPC_DEXTR_S_H:
case OPC_DEXTRV_L:
case OPC_DEXTRV_R_L:
case OPC_DEXTRV_RS_L:
case OPC_DEXTRV_S_H:
case OPC_DEXTRV_W:
case OPC_DEXTRV_R_W:
case OPC_DEXTRV_RS_W:
gen_mipsdsp_accinsn(ctx, op1, op2, rt, rs, rd, 1);
break;
case OPC_DMTHLIP:
case OPC_DSHILO:
case OPC_DSHILOV:
gen_mipsdsp_accinsn(ctx, op1, op2, rd, rs, rt, 0);
break;
default:
MIPS_INVAL("MASK EXTR.W");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_DPAQ_W_QH_DSP:
op2 = MASK_DPAQ_W_QH(ctx->opcode);
switch (op2) {
case OPC_DPAU_H_OBL:
case OPC_DPAU_H_OBR:
case OPC_DPSU_H_OBL:
case OPC_DPSU_H_OBR:
case OPC_DPA_W_QH:
case OPC_DPAQ_S_W_QH:
case OPC_DPS_W_QH:
case OPC_DPSQ_S_W_QH:
case OPC_MULSAQ_S_W_QH:
case OPC_DPAQ_SA_L_PW:
case OPC_DPSQ_SA_L_PW:
case OPC_MULSAQ_S_L_PW:
gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 0);
break;
case OPC_MAQ_S_W_QHLL:
case OPC_MAQ_S_W_QHLR:
case OPC_MAQ_S_W_QHRL:
case OPC_MAQ_S_W_QHRR:
case OPC_MAQ_SA_W_QHLL:
case OPC_MAQ_SA_W_QHLR:
case OPC_MAQ_SA_W_QHRL:
case OPC_MAQ_SA_W_QHRR:
case OPC_MAQ_S_L_PWL:
case OPC_MAQ_S_L_PWR:
case OPC_DMADD:
case OPC_DMADDU:
case OPC_DMSUB:
case OPC_DMSUBU:
gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 0);
break;
default:
MIPS_INVAL("MASK DPAQ.W.QH");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_DINSV_DSP:
op2 = MASK_INSV(ctx->opcode);
switch (op2) {
case OPC_DINSV:
{
TCGv t0, t1;
if (rt == 0) {
MIPS_DEBUG("NOP");
break;
}
check_dsp(ctx);
t0 = tcg_temp_new();
t1 = tcg_temp_new();
gen_load_gpr(t0, rt);
gen_load_gpr(t1, rs);
gen_helper_dinsv(cpu_gpr[rt], cpu_env, t1, t0);
break;
}
default:
MIPS_INVAL("MASK DINSV");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_SHLL_OB_DSP:
gen_mipsdsp_shift(ctx, op1, rd, rs, rt);
break;
#endif
default:
MIPS_INVAL("special3");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_REGIMM:
op1 = MASK_REGIMM(ctx->opcode);
switch (op1) {
case OPC_BLTZ ... OPC_BGEZL:
case OPC_BLTZAL ... OPC_BGEZALL:
gen_compute_branch(ctx, op1, 4, rs, -1, imm << 2);
*is_branch = 1;
break;
case OPC_TGEI ... OPC_TEQI:
case OPC_TNEI:
gen_trap(ctx, op1, rs, -1, imm);
break;
case OPC_SYNCI:
check_insn(ctx, ISA_MIPS32R2);
break;
case OPC_BPOSGE32:
#if defined(TARGET_MIPS64)
case OPC_BPOSGE64:
#endif
check_dsp(ctx);
gen_compute_branch(ctx, op1, 4, -1, -2, (int32_t)imm << 2);
*is_branch = 1;
break;
default:
MIPS_INVAL("regimm");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_CP0:
check_cp0_enabled(ctx);
op1 = MASK_CP0(ctx->opcode);
switch (op1) {
case OPC_MFC0:
case OPC_MTC0:
case OPC_MFTR:
case OPC_MTTR:
#if defined(TARGET_MIPS64)
case OPC_DMFC0:
case OPC_DMTC0:
#endif
#ifndef CONFIG_USER_ONLY
gen_cp0(env, ctx, op1, rt, rd);
#endif
break;
case OPC_C0_FIRST ... OPC_C0_LAST:
#ifndef CONFIG_USER_ONLY
gen_cp0(env, ctx, MASK_C0(ctx->opcode), rt, rd);
#endif
break;
case OPC_MFMC0:
#ifndef CONFIG_USER_ONLY
{
TCGv t0 = tcg_temp_new();
op2 = MASK_MFMC0(ctx->opcode);
switch (op2) {
case OPC_DMT:
check_insn(ctx, ASE_MT);
gen_helper_dmt(t0);
gen_store_gpr(t0, rt);
break;
case OPC_EMT:
check_insn(ctx, ASE_MT);
gen_helper_emt(t0);
gen_store_gpr(t0, rt);
break;
case OPC_DVPE:
check_insn(ctx, ASE_MT);
gen_helper_dvpe(t0, cpu_env);
gen_store_gpr(t0, rt);
break;
case OPC_EVPE:
check_insn(ctx, ASE_MT);
gen_helper_evpe(t0, cpu_env);
gen_store_gpr(t0, rt);
break;
case OPC_DI:
check_insn(ctx, ISA_MIPS32R2);
save_cpu_state(ctx, 1);
gen_helper_di(t0, cpu_env);
gen_store_gpr(t0, rt);
ctx->bstate = BS_STOP;
break;
case OPC_EI:
check_insn(ctx, ISA_MIPS32R2);
save_cpu_state(ctx, 1);
gen_helper_ei(t0, cpu_env);
gen_store_gpr(t0, rt);
ctx->bstate = BS_STOP;
break;
default:
MIPS_INVAL("mfmc0");
generate_exception(ctx, EXCP_RI);
break;
}
tcg_temp_free(t0);
}
#endif
break;
case OPC_RDPGPR:
check_insn(ctx, ISA_MIPS32R2);
gen_load_srsgpr(rt, rd);
break;
case OPC_WRPGPR:
check_insn(ctx, ISA_MIPS32R2);
gen_store_srsgpr(rt, rd);
break;
default:
MIPS_INVAL("cp0");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_ADDI:
case OPC_ADDIU:
gen_arith_imm(ctx, op, rt, rs, imm);
break;
case OPC_SLTI:
case OPC_SLTIU:
gen_slt_imm(ctx, op, rt, rs, imm);
break;
case OPC_ANDI:
case OPC_LUI:
case OPC_ORI:
case OPC_XORI:
gen_logic_imm(ctx, op, rt, rs, imm);
break;
case OPC_J ... OPC_JAL:
offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 2;
gen_compute_branch(ctx, op, 4, rs, rt, offset);
*is_branch = 1;
break;
case OPC_BEQ ... OPC_BGTZ:
case OPC_BEQL ... OPC_BGTZL:
gen_compute_branch(ctx, op, 4, rs, rt, imm << 2);
*is_branch = 1;
break;
case OPC_LB ... OPC_LWR:
case OPC_LL:
gen_ld(ctx, op, rt, rs, imm);
break;
case OPC_SB ... OPC_SW:
case OPC_SWR:
gen_st(ctx, op, rt, rs, imm);
break;
case OPC_SC:
gen_st_cond(ctx, op, rt, rs, imm);
break;
case OPC_CACHE:
check_cp0_enabled(ctx);
check_insn(ctx, ISA_MIPS3 | ISA_MIPS32);
break;
case OPC_PREF:
check_insn(ctx, ISA_MIPS4 | ISA_MIPS32);
break;
case OPC_LWC1:
case OPC_LDC1:
case OPC_SWC1:
case OPC_SDC1:
gen_cop1_ldst(env, ctx, op, rt, rs, imm);
break;
case OPC_CP1:
if (env->CP0_Config1 & (1 << CP0C1_FP)) {
check_cp1_enabled(ctx);
op1 = MASK_CP1(ctx->opcode);
switch (op1) {
case OPC_MFHC1:
case OPC_MTHC1:
check_insn(ctx, ISA_MIPS32R2);
case OPC_MFC1:
case OPC_CFC1:
case OPC_MTC1:
case OPC_CTC1:
gen_cp1(ctx, op1, rt, rd);
break;
#if defined(TARGET_MIPS64)
case OPC_DMFC1:
case OPC_DMTC1:
check_insn(ctx, ISA_MIPS3);
gen_cp1(ctx, op1, rt, rd);
break;
#endif
case OPC_BC1ANY2:
case OPC_BC1ANY4:
check_cop1x(ctx);
check_insn(ctx, ASE_MIPS3D);
case OPC_BC1:
gen_compute_branch1(ctx, MASK_BC1(ctx->opcode),
(rt >> 2) & 0x7, imm << 2);
*is_branch = 1;
break;
case OPC_S_FMT:
case OPC_D_FMT:
case OPC_W_FMT:
case OPC_L_FMT:
case OPC_PS_FMT:
gen_farith(ctx, ctx->opcode & FOP(0x3f, 0x1f), rt, rd, sa,
(imm >> 8) & 0x7);
break;
default:
MIPS_INVAL("cp1");
generate_exception (ctx, EXCP_RI);
break;
}
} else {
generate_exception_err(ctx, EXCP_CpU, 1);
}
break;
case OPC_LWC2:
case OPC_LDC2:
case OPC_SWC2:
case OPC_SDC2:
generate_exception_err(ctx, EXCP_CpU, 2);
break;
case OPC_CP2:
check_insn(ctx, INSN_LOONGSON2F);
gen_loongson_multimedia(ctx, sa, rd, rt);
break;
case OPC_CP3:
if (env->CP0_Config1 & (1 << CP0C1_FP)) {
check_cp1_enabled(ctx);
op1 = MASK_CP3(ctx->opcode);
switch (op1) {
case OPC_LWXC1:
case OPC_LDXC1:
case OPC_LUXC1:
case OPC_SWXC1:
case OPC_SDXC1:
case OPC_SUXC1:
gen_flt3_ldst(ctx, op1, sa, rd, rs, rt);
break;
case OPC_PREFX:
break;
case OPC_ALNV_PS:
case OPC_MADD_S:
case OPC_MADD_D:
case OPC_MADD_PS:
case OPC_MSUB_S:
case OPC_MSUB_D:
case OPC_MSUB_PS:
case OPC_NMADD_S:
case OPC_NMADD_D:
case OPC_NMADD_PS:
case OPC_NMSUB_S:
case OPC_NMSUB_D:
case OPC_NMSUB_PS:
gen_flt3_arith(ctx, op1, sa, rs, rd, rt);
break;
default:
MIPS_INVAL("cp3");
generate_exception (ctx, EXCP_RI);
break;
}
} else {
generate_exception_err(ctx, EXCP_CpU, 1);
}
break;
#if defined(TARGET_MIPS64)
case OPC_LWU:
case OPC_LDL ... OPC_LDR:
case OPC_LLD:
case OPC_LD:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_ld(ctx, op, rt, rs, imm);
break;
case OPC_SDL ... OPC_SDR:
case OPC_SD:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_st(ctx, op, rt, rs, imm);
break;
case OPC_SCD:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_st_cond(ctx, op, rt, rs, imm);
break;
case OPC_DADDI:
case OPC_DADDIU:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_arith_imm(ctx, op, rt, rs, imm);
break;
#endif
case OPC_JALX:
check_insn(ctx, ASE_MIPS16 | ASE_MICROMIPS);
offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 2;
gen_compute_branch(ctx, op, 4, rs, rt, offset);
*is_branch = 1;
break;
case OPC_MDMX:
check_insn(ctx, ASE_MDMX);
default:
MIPS_INVAL("major opcode");
generate_exception(ctx, EXCP_RI);
break;
}
}
| 1threat |
Visual Studio 2017 15.3.0 git changes include "storage.ide" even though .vs/ in .gitignore : <p>I upgraded VS 2017 to 15.3.0 a few days ago. Since then file "storage.ide" has remained in my modified files, even through I have used <a href="https://github.com/github/gitignore/blob/master/VisualStudio.gitignore" rel="noreferrer">a suggested .gitignore for VS</a>, which includes the .vs/ folder. This includes the following.</p>
<pre><code># Visual Studio 2015 cache/options directory
.vs/
</code></pre>
<p>I then added the following to be more specific about ignoring this from the list of files to be tracked</p>
<pre><code>.vs/SIASAWeb/v15/sqlite3/storage.ide
.vs/**/storage.ide
</code></pre>
<p>The Changes in the Team Explorer shows the following:</p>
<pre><code><project folder>
.vs/<project>/v15/sqlite3
storage.ide
</code></pre>
<p>I have tried to git reset this file, but this then returns on the next commit, and also exists in all branches which I open, resulting in this then preventing the easy shift from one branch to another even if no changes were made.</p>
<p>In the Solution Explorer the "applicationhost.config" and ".suo" files are marked as "ignored", but "storage.ide" is marked as "pending edit".</p>
<p>I have tried committing, synced to the GitHub server, closing and re-opened VS, and even rebooting the computer.</p>
<p>My question is why this file is being maintained as a modified file, even though it should be ignored for git.</p>
| 0debug |
static int mkv_write_trailer(AVFormatContext *s)
{
MatroskaMuxContext *mkv = s->priv_data;
AVIOContext *pb = s->pb;
int64_t currentpos, cuespos;
int ret;
if (mkv->cur_audio_pkt.size > 0) {
ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt, 0);
av_free_packet(&mkv->cur_audio_pkt);
if (ret < 0) {
av_log(s, AV_LOG_ERROR,
"Could not write cached audio packet ret:%d\n", ret);
return ret;
}
}
if (mkv->dyn_bc) {
end_ebml_master(mkv->dyn_bc, mkv->cluster);
mkv_flush_dynbuf(s);
} else if (mkv->cluster_pos != -1) {
end_ebml_master(pb, mkv->cluster);
}
if (mkv->mode != MODE_WEBM) {
ret = mkv_write_chapters(s);
if (ret < 0)
return ret;
}
if (pb->seekable) {
if (mkv->cues->num_entries) {
if (mkv->reserve_cues_space) {
int64_t cues_end;
currentpos = avio_tell(pb);
avio_seek(pb, mkv->cues_pos, SEEK_SET);
cuespos = mkv_write_cues(s, mkv->cues, mkv->tracks, s->nb_streams);
cues_end = avio_tell(pb);
if (cues_end > cuespos + mkv->reserve_cues_space) {
av_log(s, AV_LOG_ERROR,
"Insufficient space reserved for cues: %d "
"(needed: %" PRId64 ").\n",
mkv->reserve_cues_space, cues_end - cuespos);
return AVERROR(EINVAL);
}
if (cues_end < cuespos + mkv->reserve_cues_space)
put_ebml_void(pb, mkv->reserve_cues_space -
(cues_end - cuespos));
avio_seek(pb, currentpos, SEEK_SET);
} else {
cuespos = mkv_write_cues(s, mkv->cues, mkv->tracks, s->nb_streams);
}
ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CUES,
cuespos);
if (ret < 0)
return ret;
}
mkv_write_seekhead(pb, mkv->main_seekhead);
av_log(s, AV_LOG_DEBUG, "end duration = %" PRIu64 "\n", mkv->duration);
currentpos = avio_tell(pb);
avio_seek(pb, mkv->duration_offset, SEEK_SET);
put_ebml_float(pb, MATROSKA_ID_DURATION, mkv->duration);
if (mkv->stream_durations) {
int i;
for (i = 0; i < s->nb_streams; ++i) {
AVStream *st = s->streams[i];
double duration_sec = mkv->stream_durations[i] * av_q2d(st->time_base);
char duration_string[20] = "";
av_log(s, AV_LOG_DEBUG, "stream %d end duration = %" PRIu64 "\n", i,
mkv->stream_durations[i]);
if (!mkv->is_live && mkv->stream_duration_offsets[i] > 0) {
avio_seek(pb, mkv->stream_duration_offsets[i], SEEK_SET);
snprintf(duration_string, 20, "%02d:%02d:%012.9f",
(int) duration_sec / 3600, ((int) duration_sec / 60) % 60,
fmod(duration_sec, 60));
put_ebml_binary(pb, MATROSKA_ID_TAGSTRING, duration_string, 20);
}
}
}
avio_seek(pb, currentpos, SEEK_SET);
}
if (!mkv->is_live) {
end_ebml_master(pb, mkv->segment);
}
av_freep(&mkv->tracks);
av_freep(&mkv->cues->entries);
av_freep(&mkv->cues);
av_freep(&mkv->stream_durations);
av_freep(&mkv->stream_duration_offsets);
return 0;
}
| 1threat |
How to create higher order components in Angular 2 : <p>Higher Order Components (HOC) is a pattern common among React community. See <a href="https://medium.com/@franleplant/react-higher-order-components-in-depth-cf9032ee6c3e#.m111af95l" rel="noreferrer">this article</a> if you don't know what's a HOC</p>
<p>Do they make sense in Angular 2?
How to make a HOC?
Any examples?</p>
| 0debug |
Looping through downloaded files to print specific file and overall folder name : All i am trying to do is have a simple for-loop go through my documents and provide me with a dataframe that consists of a column of folder names, and then another column of the files within that folder.
For example, lets say i have a folder called "Muffins" which has a lot of different recipes for muffins (e.g., banana, blueberry, etc.) which would be the file names. I want the for-loop to to shoot out a dataframe that has Column 1 = muffins and Column 2 = to the individual recipe name.
Food Recipe
Muffins Banana
Muffins Blueberry
Muffins Chocolate
etc. etc.
I know this is really simple, but i have been at this for 3 hours now and have been out of the R game for awhile. Please help! | 0debug |
static int flac_probe(AVProbeData *p)
{
uint8_t *bufptr = p->buf;
if(ff_id3v2_match(bufptr))
bufptr += ff_id3v2_tag_len(bufptr);
if(memcmp(bufptr, "fLaC", 4)) return 0;
else return AVPROBE_SCORE_MAX / 2;
}
| 1threat |
mysqldump via SSH to local computer : <p>I have an SSH access to production server of the Rails app.</p>
<p>I want to make a mysqldump of production database to my Mac. Please help me to achieve this.</p>
| 0debug |
Disable frozen string literal comment checking : <p>I'm newbie in Rails. I am using 'Rubocop' for checking standards, however I'm bothered with the way it checks the 'frozen string literal'. It keeps on saying on my files: </p>
<pre><code>Missing frozen string literal comment.
</code></pre>
<p>Is there a way to disable the checking of this on rubocop? Or is it a bad idea to disable it?</p>
<p>I tried this on rubocop.yml but didn't work</p>
<pre><code>frozen_string_literal: false
</code></pre>
| 0debug |
static void *aio_thread(void *unused)
{
pid_t pid;
sigset_t set;
pid = getpid();
if (sigfillset(&set)) die("sigfillset");
if (sigprocmask(SIG_BLOCK, &set, NULL)) die("sigprocmask");
while (1) {
struct qemu_paiocb *aiocb;
size_t ret = 0;
qemu_timeval tv;
struct timespec ts;
qemu_gettimeofday(&tv);
ts.tv_sec = tv.tv_sec + 10;
ts.tv_nsec = 0;
mutex_lock(&lock);
while (TAILQ_EMPTY(&request_list) &&
!(ret == ETIMEDOUT)) {
ret = cond_timedwait(&cond, &lock, &ts);
}
if (TAILQ_EMPTY(&request_list))
break;
aiocb = TAILQ_FIRST(&request_list);
TAILQ_REMOVE(&request_list, aiocb, node);
aiocb->active = 1;
idle_threads--;
mutex_unlock(&lock);
switch (aiocb->aio_type) {
case QEMU_PAIO_READ:
case QEMU_PAIO_WRITE:
ret = handle_aiocb_rw(aiocb);
break;
case QEMU_PAIO_IOCTL:
ret = handle_aiocb_ioctl(aiocb);
break;
default:
fprintf(stderr, "invalid aio request (0x%x)\n", aiocb->aio_type);
ret = -EINVAL;
break;
}
mutex_lock(&lock);
aiocb->ret = ret;
idle_threads++;
mutex_unlock(&lock);
if (kill(pid, aiocb->ev_signo)) die("kill failed");
}
idle_threads--;
cur_threads--;
mutex_unlock(&lock);
return NULL;
}
| 1threat |
static int read_filter_params(MLPDecodeContext *m, GetBitContext *gbp,
unsigned int channel, unsigned int filter)
{
FilterParams *fp = &m->channel_params[channel].filter_params[filter];
const int max_order = filter ? MAX_IIR_ORDER : MAX_FIR_ORDER;
const char fchar = filter ? 'I' : 'F';
int i, order;
assert(filter < 2);
m->filter_changed[channel][filter]++;
order = get_bits(gbp, 4);
if (order > max_order) {
av_log(m->avctx, AV_LOG_ERROR,
"%cIR filter order %d is greater than maximum %d.\n",
fchar, order, max_order);
return -1;
}
fp->order = order;
if (order > 0) {
int coeff_bits, coeff_shift;
fp->shift = get_bits(gbp, 4);
coeff_bits = get_bits(gbp, 5);
coeff_shift = get_bits(gbp, 3);
if (coeff_bits < 1 || coeff_bits > 16) {
av_log(m->avctx, AV_LOG_ERROR,
"%cIR filter coeff_bits must be between 1 and 16.\n",
fchar);
return -1;
}
if (coeff_bits + coeff_shift > 16) {
av_log(m->avctx, AV_LOG_ERROR,
"Sum of coeff_bits and coeff_shift for %cIR filter must be 16 or less.\n",
fchar);
return -1;
}
for (i = 0; i < order; i++)
fp->coeff[i] = get_sbits(gbp, coeff_bits) << coeff_shift;
if (get_bits1(gbp)) {
int state_bits, state_shift;
if (filter == FIR) {
av_log(m->avctx, AV_LOG_ERROR,
"FIR filter has state data specified.\n");
return -1;
}
state_bits = get_bits(gbp, 4);
state_shift = get_bits(gbp, 4);
for (i = 0; i < order; i++)
fp->state[i] = get_sbits(gbp, state_bits) << state_shift;
}
}
return 0;
}
| 1threat |
Jquery href contains a DOT : How can I check if a href contains a string with a dot. I tried doing the following and it doesn't work:
$("a[href*=9.0]").hide();
Any ideas on how I should do this? | 0debug |
JQuery script method to ignore the execution of the event listener function and execute it only if I press the Enter key on the keyboard : I need to create a JQuery script method to ignore the execution of the keyup or keypress event listener function and execute it only if I press the Enter key on the keyboard.
$(document).on("keypress","input", function(e) {
var keyCode = e.keyCode || e.which;
if (keyCode != 13) {
console.log('Not enter')
}else{
}
}); | 0debug |
How do I display the largest number in an array in Ruby? : <p><strong>I have a homework assignment that I need to finish. I think most of the code is working but I am having trouble with the last part. I need to display the largest number that a user enters (into an array). Below is the code I have so far. I am open to any suggestions. Thanks in advance.</strong></p>
<p>Here's the description of the assignment:
Write a Ruby application that allows a user to input a series of 10 integers and determines and prints the largest integer. Your program should use at least the following three variables:
a) counter: A counter to count to 10 (i.e., to keep track of how many numbers have been input and to determine when all 10 numbers have been processed).
b) number: The integer most recently input by the user.
c) largest: The largest number found so far.</p>
<pre><code>class Screen
def cls
puts ("\n")
puts "\a"
end
def pause
STDIN.gets
end
end
class Script
def display_instructions
Console_Screen.cls
print "This script will take the user input of 10 integers and then
will
print the largest."
print "\n\nPress enter to continue."
Console_Screen.cls
Console_Screen.pause
end
def getNumber #accepts user input
list = Array.new
10.times do
Console_Screen.cls
print "This script accepts 10 integers."
print "\n\nPlease type an integer and press enter."
input = STDIN.gets
input.chop!
list.push(input)
end
end
def display_largest(number) #displays the largest integer entered by the
user
Console_Screen.cls
print "The largest integer is " +
end
def runScript
number = getNumber
Console_Screen.cls
display_largest(number)
end
end
#Main Script Logic
Console_Screen = Screen.new
LargestNum = Script.new
answer = ""
loop do
Console_Screen.cls
print "Are you ready to start the script? (y/n): "
print "\n\nWould you like instructions on how this script works? (h): "
answer = STDIN.gets
answer.chop!
break if answer =~ /y|n|h/i
end
if answer == "h" or answer == "H"
LargestNum.display_instructions
print "Are you ready to start the script? (y/n): "
answer = STDIN.gets
answer.chop!
end
if answer == "n" or answer == "N"
Console_Screen.cls
puts "Okay, maybe another time.\n\n"
Console_Screen.pause
else
loop do
LargestNum.runScript
print "\n\nEnter Q to quit or press any key to run the script again: "
runAgain = STDIN.gets
runAgain.chop!
break if runAgain =~ /Q/i
end
end
</code></pre>
| 0debug |
C++ | Is there any variable like BigInteger, but as floating point? : I saw, that there are libarys, that offer data types like BigInterger, but I need one, that contains a variable type, taht is "big" (means: that can handle very high values) but also I need the possibility to divide it by another high number, so it wouldn't work with BigInterger.. | 0debug |
animateLayoutChanges="true" in BottomSheetView showing unexpected behaviour : <p>I have a <code>BottomSheetView</code> which has <code>animateLayoutChanges="true"</code>. Initially it shows up fine. But if change the <code>visibility</code> of a view (inside <code>BottomSheetView</code>) from <code>GONE</code> to <code>VISIBLE</code>, the app messes up calculations and my <code>BottomSheetView</code> moves to the top of the screen. i have tried setting <code>layout_gravity=bottom</code> at the root of the <code>BottomSheetView</code> layout. But no success. </p>
<p>Here I have the image of my <code>BottomSheetView</code> before changing the visibility of any view. (Click image for full size)</p>
<p><a href="https://i.stack.imgur.com/K4vGv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/K4vGvm.png" alt="enter image description here"></a></p>
<p>After I change the visibility of a view (<code>GONE</code> to <code>VISIBLE</code> or <code>VISIBLE</code> to <code>GONE</code>), my BottomSheetView moves to the top. (Click image for full size)</p>
<p><a href="https://i.stack.imgur.com/eV4mf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/eV4mfm.png" alt="enter image description here"></a></p>
<p>I guess, Android is messing up while making calculations about the measurement of view <code>width</code> and <code>height</code>. Any way to solve this??</p>
<p>I also tried to make my BottomSheetView extend fully to match the parent view, but somehow that is making the <code>height</code> of the <code>BottomSheetView</code> longer than the phone screen and in-tun creating scrolling issues. </p>
<p><strong>Expected solutions:</strong></p>
<p>1> Prevent <code>BottomSheetView</code> from changing its position even when the <code>visibility</code> of a view is changed. </p>
<p>OR</p>
<p>2>Make the <code>BottomSheetView</code> match parent so that it does not look bad after messing up with the calculations. </p>
| 0debug |
static void peer_test_vnet_hdr(VirtIONet *n)
{
NetClientState *nc = qemu_get_queue(n->nic);
if (!nc->peer) {
return;
}
n->has_vnet_hdr = qemu_peer_has_vnet_hdr(nc);
}
| 1threat |
Match string using perl : <p>I have stored a piece of string "Strawberry Hill" in a variable. However I am trying to use a regular expression to see if the string matches a particular format. If the string matches I would like to store it in a variable. However nothing gets stored in the variable. I tested the regular expression in the same script outside of the if statement and it worked.</p>
<pre><code> my $address="STRAWBERRY HILL";
if($address=~ m/(\w+\s+\w+)/)
{
my $scheme_name=$1;
}
print " Scheme Name: $scheme_name";
</code></pre>
| 0debug |
Typescript - Allowed values for a property : <p>What it the best way in Typescript to only allow a number of value for a property ?</p>
<pre class="lang-js prettyprint-override"><code>class Foo {
public type:string;
// Possible values for type: ['foo1', 'foo2', 'foo3']
constructor() {}
}
</code></pre>
<p>I'd like to make those types the only allowed types, preventing me to put a wrong type when extending Foo class.</p>
| 0debug |
Why is docker build taking so long to run? : <p>I'm running docker build and it's taking an awfully long time to run. Infact, it doesn't complete and I have to CTRL + C to quit.</p>
<p>Last night things were working fine. When I returned to the computer and tried to rebuild it started acting strange.</p>
<p>Here's my command:</p>
<pre><code>docker build -t mywebsite/backend .
</code></pre>
<p>When I ran it I noticed this:</p>
<pre><code>Sending build context to Docker daemon 213.8 MB
Step 1 : FROM ubuntu:14.04
</code></pre>
<p>I have no idea why the file size was 213.8. The only directory that is large is <code>node_modules</code> and that contains <code>.dockerignore</code> so it shouldn't be touching that directory.</p>
<p>After that ran I had an error, so I fixed it and reran:</p>
<pre><code>docker build -t mywebsite/backend .
</code></pre>
<p>This time it just hung. And continues to do so.</p>
<p>Here is my <code>Dockerfile</code></p>
<pre><code>FROM ubuntu:14.04
# Set env. variables
ENV DEBIAN_FRONTEND noninteractive
# Application
ENV APP_PORT 3000
# Amazon
ENV AMAZON_BUCKET mybucket
ENV AMAZON_ACCESS_KEY_ID mykey
ENV AMAZON_SECRET_ACCESS_KEY mytoken
# Set working directory
WORKDIR ~/vms
# Install NodeJS
RUN apt-get update; apt-get install -y curl;
RUN curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
RUN apt-get install -y nodejs
# Install node dependencies
ADD package.json package.json
RUN npm install --production
# Copy files to the container
ADD src src
EXPOSE 3000
# Start application
RUN npm start
</code></pre>
<p>The directory I am in when I run the command is the one that contains the Dockerfile:</p>
<pre><code>- backend
- node_modules
- src
- config
- routes
- views
index.js
Dockerfile
package.json
</code></pre>
<p>I'm running docker on Ubuntu 14.04</p>
| 0debug |
Use default predicate in WHERE method : <p>Can I use a default predicate in the <code>where</code> method?</p>
<p>In my db I have a column <code>IsDeleted</code> for every tables. Is there a way when i get some data like this</p>
<pre><code>_dbContext.Person.Where(x => x.Age > 35).FirstOrDefault();
</code></pre>
<p>it will also use another predicate like <code>x.IsDeleted == false</code> by default?</p>
| 0debug |
Given a string / filename produce a hash in R? : <p>I have a set of file names:</p>
<pre><code>f <- c("a", "b", "c")
</code></pre>
<p>I have found <code>digest</code> function to do this, can you please advise if have chosen the right function for the task?</p>
| 0debug |
static uint8_t qvirtio_pci_config_readb(QVirtioDevice *d, uint64_t off)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
return qpci_io_readb(dev->pdev, CONFIG_BASE(dev) + off);
}
| 1threat |
How can I build a binary image with random sequence of 80% 1s and 20% 0s? : <p>I want to implement an algorithm for generating a binary image having random sequence of 80% 1s and 20% 0s in it with python-opencv.</p>
| 0debug |
Implement something similar to C++'s `std::remove_reference` in Rust? : <p>I'd like to have a tool to remove the reference from a type if the type is a reference. Something like this (pseudo code):</p>
<pre><code>remove_ref(i32) == i32
remove_ref(&i32) == i32
remove_ref(&&i32) == i32
remove_ref(&mut i32) == i32
</code></pre>
<p>C++ has <a href="http://www.cplusplus.com/reference/type_traits/remove_reference/" rel="noreferrer"><code>std::remove_reference</code></a> in the standard library which can do exactly what I want. I tried to implement the same in Rust, but I can't get it working. Right now, the only way to "output" types in Rust are associated types on traits (I think). I tried something like this (<a href="https://play.rust-lang.org/?gist=1d77c235aaefd325612ff742029bbc3b&version=nightly&mode=debug" rel="noreferrer">Playground</a>):</p>
<pre><code>#![feature(specialization)]
trait RemoveRef {
type WithoutRef;
}
default impl<T> RemoveRef for T {
type WithoutRef = T;
}
impl<'a, T: RemoveRef> RemoveRef for &'a T {
type WithoutRef = T::WithoutRef;
}
</code></pre>
<p>And in fact this compiles. Promising! (yes, this doesn't account for mutable references yet). However, everything explodes when I try to use it:</p>
<pre><code>let _: <i32 as RemoveRef>::WithoutRef = 3;
let _: <&i32 as RemoveRef>::WithoutRef = 3;
let _: <&&i32 as RemoveRef>::WithoutRef = 3;
</code></pre>
<p>The first line leads to "overflow evaluating the requirement <code>i32: RemoveRef</code>". The other two lines produce the error "the trait bound <code>&i32: RemoveRef</code> is not satisfied". I'm not sure if I just don't understand this or if specialization is broken. (Related: I got another strange error with very similar code <a href="https://stackoverflow.com/questions/51022636/mismatch-between-associated-type-and-type-parameter-only-when-impl-is-marked-de">here</a>)</p>
<p>I was thinking about other possibilities to implement this: maybe put a type parameter on the trait? Maybe GATs could help here? Are there other features in the language that allow mapping from one type to another type?</p>
<p><strong>Is there any way to implement something like this in Rust?</strong></p>
| 0debug |
void hmp_info_snapshots(Monitor *mon, const QDict *qdict)
{
BlockDriverState *bs, *bs1;
QEMUSnapshotInfo *sn_tab, *sn, s, *sn_info = &s;
int nb_sns, i, ret, available;
int total;
int *available_snapshots;
bs = find_vmstate_bs();
if (!bs) {
monitor_printf(mon, "No available block device supports snapshots\n");
return;
}
nb_sns = bdrv_snapshot_list(bs, &sn_tab);
if (nb_sns < 0) {
monitor_printf(mon, "bdrv_snapshot_list: error %d\n", nb_sns);
return;
}
if (nb_sns == 0) {
monitor_printf(mon, "There is no snapshot available.\n");
return;
}
available_snapshots = g_new0(int, nb_sns);
total = 0;
for (i = 0; i < nb_sns; i++) {
sn = &sn_tab[i];
available = 1;
bs1 = NULL;
while ((bs1 = bdrv_next(bs1))) {
if (bdrv_can_snapshot(bs1) && bs1 != bs) {
ret = bdrv_snapshot_find(bs1, sn_info, sn->id_str);
if (ret < 0) {
available = 0;
break;
}
}
}
if (available) {
available_snapshots[total] = i;
total++;
}
}
if (total > 0) {
bdrv_snapshot_dump((fprintf_function)monitor_printf, mon, NULL);
monitor_printf(mon, "\n");
for (i = 0; i < total; i++) {
sn = &sn_tab[available_snapshots[i]];
bdrv_snapshot_dump((fprintf_function)monitor_printf, mon, sn);
monitor_printf(mon, "\n");
}
} else {
monitor_printf(mon, "There is no suitable snapshot available\n");
}
g_free(sn_tab);
g_free(available_snapshots);
}
| 1threat |
static void set_pixel_format(VncState *vs,
int bits_per_pixel, int depth,
int big_endian_flag, int true_color_flag,
int red_max, int green_max, int blue_max,
int red_shift, int green_shift, int blue_shift)
{
if (!true_color_flag) {
vnc_client_error(vs);
return;
}
vs->clientds = vs->serverds;
vs->clientds.pf.rmax = red_max;
count_bits(vs->clientds.pf.rbits, red_max);
vs->clientds.pf.rshift = red_shift;
vs->clientds.pf.rmask = red_max << red_shift;
vs->clientds.pf.gmax = green_max;
count_bits(vs->clientds.pf.gbits, green_max);
vs->clientds.pf.gshift = green_shift;
vs->clientds.pf.gmask = green_max << green_shift;
vs->clientds.pf.bmax = blue_max;
count_bits(vs->clientds.pf.bbits, blue_max);
vs->clientds.pf.bshift = blue_shift;
vs->clientds.pf.bmask = blue_max << blue_shift;
vs->clientds.pf.bits_per_pixel = bits_per_pixel;
vs->clientds.pf.bytes_per_pixel = bits_per_pixel / 8;
vs->clientds.pf.depth = bits_per_pixel == 32 ? 24 : bits_per_pixel;
vs->clientds.flags = big_endian_flag ? QEMU_BIG_ENDIAN_FLAG : 0x00;
set_pixel_conversion(vs);
vga_hw_invalidate();
vga_hw_update();
}
| 1threat |
how to pull information from one table into text boxs based on primary key from another table? : protected void custo_search_Click(object sender, EventArgs e)
{
conn.Open();
if (appo_fname.Text != null || appo_lname.Text != null || appo_num.Text != null)
{
DataTable dt = new DataTable();
MySqlDataReader myReader = null;
MySqlCommand myCommand = new MySqlCommand("SELECT customers.First_name,customers.Last_name,customers.Phone_num From customers INNER JOIN appointments On customers.Phone_num=appointments.Phone_num Where customers.Phone_num='" + search_txt.Text+"' ", conn);
myReader = myCommand.ExecuteReader();
while (myReader.Read())
{
appo_fname.Text = (myReader["customers.First_name"].ToString());
appo_lname.Text = (myReader["customers.Last_name"].ToString());
appo_num.Text = (myReader["customers.Phone_num"].ToString());
}
conn.Close();
}
Hi,
i am trying to connent between 2 tables with the same primary key,so when i put a phone number in search textbox it will check if the number exist in the other table and if it is so i will get f.name,l.name and phone into other text boxs in order to insert the customer information without typing all over but somting is not working in my code,it skeep over the code inside the "while" | 0debug |
Connection Pool for rails 5 : <p>I am having this issue with rails 5 rc1. Does anyone have any idea how to configure it in the environment files and what is the default connection pool size for rails 5 active record.</p>
<pre><code> Puma caught this error: could not obtain a connection from the pool within 5.000 seconds (waited 5.000 seconds); all pooled connections were in use (ActiveRecord::ConnectionTimeoutError)
/home/bsethi/.rvm/gems/ruby-2.2.2/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:202:in `block in wait_poll'
/home/bsethi/.rvm/gems/ruby-2.2.2/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:193:in `loop'
/home/bsethi/.rvm/gems/ruby-2.2.2/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:193:in `wait_poll'
/home/bsethi/.rvm/gems/ruby-2.2.2/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:154:in `internal_poll'
/home/bsethi/.rvm/gems/ruby-2.2.2/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:278:in `internal_poll'
/home/bsethi/.rvm/gems/ruby-2.2.2/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:148:in `block in poll'
</code></pre>
| 0debug |
unsigned int av_codec_get_tag(const AVCodecTag *tags[4], enum CodecID id)
{
int i;
for(i=0; i<4 && tags[i]; i++){
int tag= codec_get_tag(tags[i], id);
if(tag) return tag;
}
return 0;
}
| 1threat |
static void wavpack_decode_flush(AVCodecContext *avctx)
{
WavpackContext *s = avctx->priv_data;
int i;
for (i = 0; i < s->fdec_num; i++)
wv_reset_saved_context(s->fdec[i]);
}
| 1threat |
C- find a series with recursion : im trying to write a **RECURSION** function that gets an array by pointer and its size, and return the number of longest series in the array (assume that there is a series),
for exemple:
array: {1 2 3 3 4 5 6 6 6 6 7 8}
returns-->: 4
but i dont know whats worng with my function i think i got the all thing worng
any idea how to fix it?
#include <stdio.h>
#include <stdlib.h>
int LongestSeries(int* arr, int size, int* count, int* maxcount);
int main()
{
int i, size, *arr, count=0, maxcount=0;
// allocation an array (unknow size)
{
printf("Enter Size of the Array-->:");
scanf("%d", &size);
arr = (int*)malloc(size * sizeof(int));
if (arr == NULL)
{
printf("Error!!");
exit(1);
}
printf("Enter Numbers for the Array:\n");
for (i = 0; i < size; i++)
{
printf("Enter a Number-->:");
scanf("%d", &arr[i]);
}
}
for (i = 0; i < size; i++)
printf(" %d ", arr[i]);
printf("\n");
printf(" %d \n", LongestSeries(arr, size, count, maxcount));
free(arr);
return 0;
}
int LongestSeries(int* arr, int size, int* count, int* maxcount)
{
if (arr[size-1] == arr[size-2])
count++;
if (maxcount<count)
maxcount = count;
LongestSeries(arr, size - 1, count, maxcount);
if (*arr==arr[0])
return maxcount;
} | 0debug |
int ff_v4l2_context_dequeue_packet(V4L2Context* ctx, AVPacket* pkt)
{
V4L2Buffer* avbuf = NULL;
avbuf = v4l2_dequeue_v4l2buf(ctx, ctx_to_m2mctx(ctx)->draining ? 200 : -1);
if (!avbuf) {
if (ctx->done)
return AVERROR_EOF;
return AVERROR(EAGAIN);
}
return ff_v4l2_buffer_buf_to_avpkt(pkt, avbuf);
}
| 1threat |
static void bdrv_assign_node_name(BlockDriverState *bs,
const char *node_name,
Error **errp)
{
if (!node_name) {
return;
}
if (node_name[0] == '\0') {
error_setg(errp, "Empty node name");
return;
}
if (bdrv_find(node_name)) {
error_setg(errp, "node-name=%s is conflicting with a device id",
node_name);
return;
}
if (bdrv_find_node(node_name)) {
error_setg(errp, "Duplicate node name");
return;
}
pstrcpy(bs->node_name, sizeof(bs->node_name), node_name);
QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list);
}
| 1threat |
Attempting to unmarshal a json byte array in golang 1.12 : <p>I am getting a json byte array and simply attempting to unmarshal it into a struct for later use.</p>
<pre><code>type Event struct {
category string `json:"category"`
service string `json:"service"`
timestamp string `json:"timestamp"`
value string `json:"value"`
}
ba := []byte(`
{
"category": "category1",
"service" : "service1",
"timestamp": "06-21-2019T10:08:00",
"value": "5"
}`)
var event Event
err := json.Unmarshal(ba, &event)
if err != nil {
log.Panicln(err)
}
log.Printf("%+v", event)
</code></pre>
<p>I was expecting:</p>
<p>2019/06/21 12:21:13 {category:category1 service:service1 timestamp:06-21-2019T10:08:00 value:5 }</p>
<p>but instead I'm getting:</p>
<p>2019/06/21 12:21:13 {category: service: timestamp: value:}</p>
| 0debug |
static inline void update_rice(APERice *rice, int x)
{
rice->ksum += ((x + 1) / 2) - ((rice->ksum + 16) >> 5);
if (rice->k == 0)
rice->k = 1;
else if (rice->ksum < (1 << (rice->k + 4)))
rice->k--;
else if (rice->ksum >= (1 << (rice->k + 5)))
rice->k++;
}
| 1threat |
To Re arrange the columns of dataframe from csv : I need to read a csv file in python and then re arrange the columns of csv and make a new dataframe made of the rearranged columns
I tried using list, but it might work slow..
Any alternative using numpy or pandas? | 0debug |
how to get same id different values in javascript json array object : how to get same id different values in javascript json array object and push it in array.
This is actual json data,
var data = [{
"areaid": 25,
"wardid": 5
},
{
"areaid": 24,
"wardid": 5
},
{
"areaid": 23,
"wardid": 5
},
{
"areaid": 22,
"wardid": 5
},
{
"areaid": 21,
"wardid": 4
},
{
"areaid": 20,
"wardid": 4
},
{
"areaid": 19,
"wardid": 4
},
{
"areaid": 18,
"wardid": 3
},
{
"areaid": 17,
"wardid": 3
},
{
"areaid": 16,
"wardid": 3
}];
And the output i want,
for wardid: 3
[{
"areaid": 18
},{
"areaid": 17
},{
"areaid": 16
}]
for wardid: 4
[{
"areaid": 21
},{
"areaid": 20
},{
"areaid": 19
}]
| 0debug |
SQl Querry converting to Linq : select COUNT(prosold.Product_ID) as c,prosold.Product_ID,ProImg.ImagePath from ProductSold as ProSold,ProductImages as ProImg where ProSold.Product_ID=ProImg.Product_ID group by ProSold.Product_ID,ProImg.ImagePath order by c desc | 0debug |
Best practice calling scalar functions with Entity Framework Core (2.1) : <p>I often need to call scalar functions that are defined on a SQL Server from my web applications (ASP.NET Core / EF Core). Since these functions are just simple helper functions and I also use a lot of them I use a general pattern for calling these scalar functions - with the help of the new query types available from EF Core 2.1.
Since I am relatively new to EF Core my question is if this pattern might cause problems and/or if there is a better solution or best practice for calling scalar functions. The solution works and I cannot observe any problems so far but for example I wondered if using the same query type for different functions might lead to unexpected values or weird behaviour due to caching/tracking behaviour, etc. within EF Core - it's more of a gut feeling.</p>
<p>So here's the pattern:
Instead of defining different entity types for every single scalar function I simply define one generic type:</p>
<pre><code>public class PrimitiveDto<T>
{
public T Value { get; set; }
}
</code></pre>
<p>In my context class I register these types for every return type I expect from the scalar functions I want to use - so for all scalar functions returning 'int' the context class would have one additional entry like this:</p>
<pre><code>public virtual DbQuery<PrimitiveDto<int>> BasicIntDto { get; set; }
</code></pre>
<p>In every part of the application where I want to call a scalar function returning 'int' I simply use the same following pattern:</p>
<pre><code>context.BasicIntDto.FromSql("SELECT <FUNCTION> AS Value")
</code></pre>
<p>By using this pattern I can call any number of functions the same way without defining additional types or extending the context class.</p>
<p>Please let me know if I could run into a trap through this pattern. Thank you very much.</p>
| 0debug |
static int vnc_tls_initialize(void)
{
static int tlsinitialized = 0;
if (tlsinitialized)
return 1;
if (gnutls_global_init () < 0)
return 0;
if (gnutls_dh_params_init (&dh_params) < 0)
return 0;
if (gnutls_dh_params_generate2 (dh_params, DH_BITS) < 0)
return 0;
#if defined(_VNC_DEBUG) && _VNC_DEBUG >= 2
gnutls_global_set_log_level(10);
gnutls_global_set_log_function(vnc_debug_gnutls_log);
#endif
tlsinitialized = 1;
return 1;
}
| 1threat |
(C#) How to remove the "Hello World" line when starting a new console application : <p>I am using Visual Studio 2017. When I start a new Console App(.NET Core) it comes with a Console.WriteLine("Hello World!") by default. My question is if there is a way to permanently remove this line instead of deleting it every single time? </p>
| 0debug |
how to fix andriod java ListViewAdapter : Please i need help to fix is problem with my ListView Adapter, when i scroll down the list of country change to only one country.
this my
Nraeby_ListViewAdapter
public class Nraeby_ListViewAdapter extends BaseAdapter {
private String Liked;
Context mContext;
// Declare Variables
LayoutInflater inflater;
private ArrayList<HashMap<String, String>> data;
ImageLoader imageLoader;
HashMap<String, String> resultp = new HashMap<String, String>();
public Nraeby_ListViewAdapter(Context context,
ArrayList<HashMap<String, String>> arraylist) {
this.data = arraylist;
mContext = context;
imageLoader = new ImageLoader(mContext);
inflater = LayoutInflater.from(mContext);
}
@Override
public int getCount() {
return data.size();
}
@Override
public Object getItem(int position) {
return data.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
public class ViewHolder {
// Declare Variables
TextView rank;
TextView country;
TextView population;
test.Droidlogin.CircleImage flag;
test.Droidlogin.material.AnimateCheckBox checkBox;
ImageButton btnFavourite;
}
public View getView(final int position, View view, ViewGroup parent) {
final ViewHolder holder;
if (view == null) {
holder = new ViewHolder();
view = inflater.inflate(R.layout.nearby_listview_item, null);
// Get the position
resultp = data.get(position);
// Locate the TextViews in nearby_listview_item.xmltem.xml
holder.rank = (TextView) view.findViewById(R.id.rank);
holder.country = (TextView) view.findViewById(R.id.country);
// Locate the ImageView in nearby_listview_item.xmltem.xml
holder.flag = (test.Droidlogin.CircleImage) view.findViewById(R.id.flag);
holder.checkBox = (test.Droidlogin.material.AnimateCheckBox) view.findViewById(R.id.checkbox);
holder.btnFavourite = (ImageButton) view.findViewById(R.id.like);
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
// Capture position and set results to the TextViews
holder.rank.setText(resultp.get(NearbyUsers.RANK));
holder.country.setText(resultp.get(NearbyUsers.COUNTRY));
// Capture position and set results to the ImageView
// Passes flag images URL into ImageLoader.class
imageLoader.DisplayImage(resultp.get(NearbyUsers.FLAG), holder.flag);
TinyDB tinydb = new TinyDB(mContext);
Liked = tinydb.getString("MyUsers");
//This handle and change icon when click on.
holder.btnFavourite.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
TinyDB tinydb = new TinyDB(mContext);
holder.btnFavourite.setImageResource(R.drawable.icon_liked);
tinydb.putString("MyUsers",resultp.get(NearbyUsers.COUNTRY));
holder.btnFavourite.setImageResource(R.drawable.icon_liked);
}
});
// Capture ListView item click
view.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// Get the position
Intent intent = new Intent(mContext, SingleItemViewNearbyProfile.class);
// Pass all data rank
intent.putExtra("rank", resultp.get(NearbyUsers.RANK));
// Pass all data country
intent.putExtra("country", resultp.get(NearbyUsers.COUNTRY));
// Pass all data population
intent.putExtra("population",resultp.get(NearbyUsers.POPULATION));
// Pass all data flag
intent.putExtra("flag", resultp.get(NearbyUsers.FLAG));
// Start SingleItemView Class
mContext.startActivity(intent);
}
});
return view;
}
}
pls i need help on how to fix the error
so that when scroll down it will show the list of all country and a button
| 0debug |
javascript; What is the difference between two pieces of codes below : <p>I am trying to understand how are these two pieces of code different.</p>
<pre><code>var bill=10.25+3.99+7.15;
var tip = bill*0.15;
var total=bill+tip;
total = total.toFixed(2);
console.log("$"+total);
</code></pre>
<p>And</p>
<pre><code>var bill=10.25+3.99+7.15;
var tip = bill*0.15;
var total=bill+tip;
console.log("$"+total.toFixed(2));
</code></pre>
| 0debug |
static void synth_block_fcb_acb(WMAVoiceContext *s, GetBitContext *gb,
int block_idx, int size,
int block_pitch_sh2,
const struct frame_type_desc *frame_desc,
float *excitation)
{
static const float gain_coeff[6] = {
0.8169, -0.06545, 0.1726, 0.0185, -0.0359, 0.0458
};
float pulses[MAX_FRAMESIZE / 2], pred_err, acb_gain, fcb_gain;
int n, idx, gain_weight;
AMRFixed fcb;
assert(size <= MAX_FRAMESIZE / 2);
memset(pulses, 0, sizeof(*pulses) * size);
fcb.pitch_lag = block_pitch_sh2 >> 2;
fcb.pitch_fac = 1.0;
fcb.no_repeat_mask = 0;
fcb.n = 0;
if (frame_desc->fcb_type == FCB_TYPE_AW_PULSES) {
aw_pulse_set1(s, gb, block_idx, &fcb);
aw_pulse_set2(s, gb, block_idx, &fcb);
} else {
int offset_nbits = 5 - frame_desc->log_n_blocks;
fcb.no_repeat_mask = -1;
for (n = 0; n < 5; n++) {
float sign;
int pos1, pos2;
sign = get_bits1(gb) ? 1.0 : -1.0;
pos1 = get_bits(gb, offset_nbits);
fcb.x[fcb.n] = n + 5 * pos1;
fcb.y[fcb.n++] = sign;
if (n < frame_desc->dbl_pulses) {
pos2 = get_bits(gb, offset_nbits);
fcb.x[fcb.n] = n + 5 * pos2;
fcb.y[fcb.n++] = (pos1 < pos2) ? -sign : sign;
}
}
}
ff_set_fixed_vector(pulses, &fcb, 1.0, size);
idx = get_bits(gb, 7);
fcb_gain = expf(avpriv_scalarproduct_float_c(s->gain_pred_err,
gain_coeff, 6) -
5.2409161640 + wmavoice_gain_codebook_fcb[idx]);
acb_gain = wmavoice_gain_codebook_acb[idx];
pred_err = av_clipf(wmavoice_gain_codebook_fcb[idx],
-2.9957322736 ,
1.6094379124 );
gain_weight = 8 >> frame_desc->log_n_blocks;
memmove(&s->gain_pred_err[gain_weight], s->gain_pred_err,
sizeof(*s->gain_pred_err) * (6 - gain_weight));
for (n = 0; n < gain_weight; n++)
s->gain_pred_err[n] = pred_err;
if (frame_desc->acb_type == ACB_TYPE_ASYMMETRIC) {
int len;
for (n = 0; n < size; n += len) {
int next_idx_sh16;
int abs_idx = block_idx * size + n;
int pitch_sh16 = (s->last_pitch_val << 16) +
s->pitch_diff_sh16 * abs_idx;
int pitch = (pitch_sh16 + 0x6FFF) >> 16;
int idx_sh16 = ((pitch << 16) - pitch_sh16) * 8 + 0x58000;
idx = idx_sh16 >> 16;
if (s->pitch_diff_sh16) {
if (s->pitch_diff_sh16 > 0) {
next_idx_sh16 = (idx_sh16) &~ 0xFFFF;
} else
next_idx_sh16 = (idx_sh16 + 0x10000) &~ 0xFFFF;
len = av_clip((idx_sh16 - next_idx_sh16) / s->pitch_diff_sh16 / 8,
1, size - n);
} else
len = size;
ff_acelp_interpolatef(&excitation[n], &excitation[n - pitch],
wmavoice_ipol1_coeffs, 17,
idx, 9, len);
}
} else {
int block_pitch = block_pitch_sh2 >> 2;
idx = block_pitch_sh2 & 3;
if (idx) {
ff_acelp_interpolatef(excitation, &excitation[-block_pitch],
wmavoice_ipol2_coeffs, 4,
idx, 8, size);
} else
av_memcpy_backptr((uint8_t *) excitation, sizeof(float) * block_pitch,
sizeof(float) * size);
}
ff_weighted_vector_sumf(excitation, excitation, pulses,
acb_gain, fcb_gain, size);
}
| 1threat |
How to set conditions .each : I have here such a section of code
<% @portfolio.shuffle.each do |portfo| %>
How can I specify in the condition that the code in this block should be executed 6 times? | 0debug |
static void ich9_apm_ctrl_changed(uint32_t val, void *arg)
{
ICH9LPCState *lpc = arg;
acpi_pm1_cnt_update(&lpc->pm.acpi_regs,
val == ICH9_APM_ACPI_ENABLE,
val == ICH9_APM_ACPI_DISABLE);
if (val == ICH9_APM_ACPI_ENABLE || val == ICH9_APM_ACPI_DISABLE) {
return;
}
if (lpc->pm.smi_en & ICH9_PMIO_SMI_EN_APMC_EN) {
cpu_interrupt(current_cpu, CPU_INTERRUPT_SMI);
}
}
| 1threat |
Javascript incompatible type error in android studio : [error in javascript][1]
[1]: https://i.stack.imgur.com/8na9r.png
javascript error shows when i build the gradle second time after opening the project, at first time the gradle build does not shows any errors. Can Someone plz help me in this error???? | 0debug |
How To Disable 2nd Saturday 4th Saturday ,Sunday And Holiday Date Using JQuery Calendar : i want to Disable 2nd Saturday 4th saturday, Sunday And Public Holiday Date Using jQuery calendar
All year of 2nd Saturday And 4th Saturday ,Sunday Disable from Calendar
Please Help Me | 0debug |
Swift 3 / Xcode 8 Upgrade - 100's of DerivedData files missing from working copy errors : <p>I have just upgraded to the latest Beta version of XCode and Swift but after using the converter my app project now has over 200 build time yellow errors all stating /"projectDirectoy"/DerivedData/XXXXXXXXX/XXXX/XXX/xXXX/xXX is missing from working copy... where by the XXXXX's represent various file paths in the DerivedData folder.</p>
<p>I have tried deleting the DerivedData folder from the location mentioned in the errors. </p>
<p>I have tried deleting everything in the DerivedData folder in ~/Library/.</p>
<p>I have tried multiple times to clean the project, reboot and do a fresh build.</p>
<p>I have tried turning off source control in preferences but I don't see why I should turn this off as it was on before I updated so I want it left on.</p>
<p>These errors just won't seem to go away.</p>
<p>Any ideas?</p>
| 0debug |
Why kotlin gradle plugin cannot build with 1.8 target? : <p>I have the simplest gradle project configured using intellij for kotlin 1.2.10. Here is my build.gradle file:</p>
<pre><code>buildscript {
ext.kotlin_version = '1.2.10'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
group 'com.ali'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'kotlin'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
testCompile group: 'junit', name: 'junit', version: '4.12'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
</code></pre>
<p>And I have a simple java interface:</p>
<pre><code>public interface MyMath {
static int myAbs(int input) {
return Math.abs(input);
}
}
</code></pre>
<p>When I import this interface and try to call <code>myAbs</code> method it fails with this error:</p>
<pre><code>Error:(6, 12) Kotlin: Calls to static methods in Java interfaces are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'
</code></pre>
<p>I have created an intellij kotlin app and it was working correctly. Is it a bug in new Kotlin gradle plugin?</p>
| 0debug |
I can run my PHP program and I received several errors.. Please see my attached images : [This is the warning I got][1]
[My logintest php code][2]
[][3]
[1]: http://i.stack.imgur.com/XDM3e.png
[2]: http://i.stack.imgur.com/m8Fqd.png
database name = portfolio
table name = admin | 0debug |
void PREFIX_h264_chroma_mc8_altivec(uint8_t * dst, uint8_t * src,
int stride, int h, int x, int y) {
POWERPC_PERF_DECLARE(PREFIX_h264_chroma_mc8_num, 1);
DECLARE_ALIGNED_16(signed int, ABCD[4]) =
{((8 - x) * (8 - y)),
(( x) * (8 - y)),
((8 - x) * ( y)),
(( x) * ( y))};
register int i;
vec_u8 fperm;
const vec_s32 vABCD = vec_ld(0, ABCD);
const vec_s16 vA = vec_splat((vec_s16)vABCD, 1);
const vec_s16 vB = vec_splat((vec_s16)vABCD, 3);
const vec_s16 vC = vec_splat((vec_s16)vABCD, 5);
const vec_s16 vD = vec_splat((vec_s16)vABCD, 7);
LOAD_ZERO;
const vec_s16 v32ss = vec_sl(vec_splat_s16(1),vec_splat_u16(5));
const vec_u16 v6us = vec_splat_u16(6);
register int loadSecond = (((unsigned long)src) % 16) <= 7 ? 0 : 1;
register int reallyBadAlign = (((unsigned long)src) % 16) == 15 ? 1 : 0;
vec_u8 vsrcAuc, vsrcBuc, vsrcperm0, vsrcperm1;
vec_u8 vsrc0uc, vsrc1uc;
vec_s16 vsrc0ssH, vsrc1ssH;
vec_u8 vsrcCuc, vsrc2uc, vsrc3uc;
vec_s16 vsrc2ssH, vsrc3ssH, psum;
vec_u8 vdst, ppsum, vfdst, fsum;
POWERPC_PERF_START_COUNT(PREFIX_h264_chroma_mc8_num, 1);
if (((unsigned long)dst) % 16 == 0) {
fperm = (vec_u8){0x10, 0x11, 0x12, 0x13,
0x14, 0x15, 0x16, 0x17,
0x08, 0x09, 0x0A, 0x0B,
0x0C, 0x0D, 0x0E, 0x0F};
} else {
fperm = (vec_u8){0x00, 0x01, 0x02, 0x03,
0x04, 0x05, 0x06, 0x07,
0x18, 0x19, 0x1A, 0x1B,
0x1C, 0x1D, 0x1E, 0x1F};
}
vsrcAuc = vec_ld(0, src);
if (loadSecond)
vsrcBuc = vec_ld(16, src);
vsrcperm0 = vec_lvsl(0, src);
vsrcperm1 = vec_lvsl(1, src);
vsrc0uc = vec_perm(vsrcAuc, vsrcBuc, vsrcperm0);
if (reallyBadAlign)
vsrc1uc = vsrcBuc;
else
vsrc1uc = vec_perm(vsrcAuc, vsrcBuc, vsrcperm1);
vsrc0ssH = (vec_s16)vec_mergeh(zero_u8v,(vec_u8)vsrc0uc);
vsrc1ssH = (vec_s16)vec_mergeh(zero_u8v,(vec_u8)vsrc1uc);
if (ABCD[3]) {
if (!loadSecond) {
for (i = 0 ; i < h ; i++) {
vsrcCuc = vec_ld(stride + 0, src);
vsrc2uc = vec_perm(vsrcCuc, vsrcCuc, vsrcperm0);
vsrc3uc = vec_perm(vsrcCuc, vsrcCuc, vsrcperm1);
CHROMA_MC8_ALTIVEC_CORE
}
} else {
vec_u8 vsrcDuc;
for (i = 0 ; i < h ; i++) {
vsrcCuc = vec_ld(stride + 0, src);
vsrcDuc = vec_ld(stride + 16, src);
vsrc2uc = vec_perm(vsrcCuc, vsrcDuc, vsrcperm0);
if (reallyBadAlign)
vsrc3uc = vsrcDuc;
else
vsrc3uc = vec_perm(vsrcCuc, vsrcDuc, vsrcperm1);
CHROMA_MC8_ALTIVEC_CORE
}
}
} else {
const vec_s16 vE = vec_add(vB, vC);
if (ABCD[2]) {
if (!loadSecond) {
for (i = 0 ; i < h ; i++) {
vsrcCuc = vec_ld(stride + 0, src);
vsrc1uc = vec_perm(vsrcCuc, vsrcCuc, vsrcperm0);
CHROMA_MC8_ALTIVEC_CORE_SIMPLE
vsrc0uc = vsrc1uc;
}
} else {
vec_u8 vsrcDuc;
for (i = 0 ; i < h ; i++) {
vsrcCuc = vec_ld(stride + 0, src);
vsrcDuc = vec_ld(stride + 15, src);
vsrc1uc = vec_perm(vsrcCuc, vsrcDuc, vsrcperm0);
CHROMA_MC8_ALTIVEC_CORE_SIMPLE
vsrc0uc = vsrc1uc;
}
}
} else {
if (!loadSecond) {
for (i = 0 ; i < h ; i++) {
vsrcCuc = vec_ld(0, src);
vsrc0uc = vec_perm(vsrcCuc, vsrcCuc, vsrcperm0);
vsrc1uc = vec_perm(vsrcCuc, vsrcCuc, vsrcperm1);
CHROMA_MC8_ALTIVEC_CORE_SIMPLE
}
} else {
vec_u8 vsrcDuc;
for (i = 0 ; i < h ; i++) {
vsrcCuc = vec_ld(0, src);
vsrcDuc = vec_ld(15, src);
vsrc0uc = vec_perm(vsrcCuc, vsrcDuc, vsrcperm0);
if (reallyBadAlign)
vsrc1uc = vsrcDuc;
else
vsrc1uc = vec_perm(vsrcCuc, vsrcDuc, vsrcperm1);
CHROMA_MC8_ALTIVEC_CORE_SIMPLE
}
}
}
}
POWERPC_PERF_STOP_COUNT(PREFIX_h264_chroma_mc8_num, 1);
}
| 1threat |
Read a conditon from a file java : i wrote this java codes and i want the conditions to be read from a file.
is it possible? if you have any tutorial. or anything that will help me understand how to do it.
i have tried putting each condition in a file and read form that.
if(con == 1){
Scanner myScanner = new Scanner(new File("con.txt"));
}
else if(con == 2){
Scanner myScanner = new Scanner(new File("con2.txt"));
}
else if(con == 3){
Scanner myScanner = new Scanner(new File("con3.txt"));
}
else{
System.out.println("You did not choose one of the 3 con");
}
<code>
but it didnt work because in each if statement there is 2 conditions that need to be meet.
I hope it makes sense
| 0debug |
int qmp_pc_dimm_device_list(Object *obj, void *opaque)
{
MemoryDeviceInfoList ***prev = opaque;
if (object_dynamic_cast(obj, TYPE_PC_DIMM)) {
DeviceState *dev = DEVICE(obj);
if (dev->realized) {
MemoryDeviceInfoList *elem = g_new0(MemoryDeviceInfoList, 1);
MemoryDeviceInfo *info = g_new0(MemoryDeviceInfo, 1);
PCDIMMDeviceInfo *di = g_new0(PCDIMMDeviceInfo, 1);
DeviceClass *dc = DEVICE_GET_CLASS(obj);
PCDIMMDevice *dimm = PC_DIMM(obj);
if (dev->id) {
di->has_id = true;
di->id = g_strdup(dev->id);
}
di->hotplugged = dev->hotplugged;
di->hotpluggable = dc->hotpluggable;
di->addr = dimm->addr;
di->slot = dimm->slot;
di->node = dimm->node;
di->size = object_property_get_int(OBJECT(dimm), PC_DIMM_SIZE_PROP,
NULL);
di->memdev = object_get_canonical_path(OBJECT(dimm->hostmem));
info->dimm = di;
elem->value = info;
elem->next = NULL;
**prev = elem;
*prev = &elem->next;
}
}
object_child_foreach(obj, qmp_pc_dimm_device_list, opaque);
return 0;
}
| 1threat |
How do I insert text into a Monaco Editor? : <p>I have a monaco code editor embedded in my app.</p>
<p>How do I programmatically insert text on a particular line?</p>
<pre><code>var editor = monaco.editor.create(document.getElementById("container"), {
value: "// First line\nfunction hello() {\n\talert('Hello world!');\n}\n// Last line",
language: "javascript",
lineNumbers: false,
roundedSelection: false,
scrollBeyondLastLine: false,
readOnly: false,
theme: "vs-dark",
});
// how do I do this?
editor.insertText("FOO");
</code></pre>
| 0debug |
SVG Fill Color Not Working : <p>I'm new to using SVGs and can't figure out what I'm doing wrong here. For most of them, if I want to change the color, I use:</p>
<pre><code>svg path {
fill: blue;
}
</code></pre>
<p>But for this one - and other's I've come across - for some reason this way doesn't work. </p>
<p><a href="https://jsfiddle.net/kevmon/ddb4k2vq/1/" rel="noreferrer">Here's a fiddle demonstrating the problem</a></p>
<p>HTML</p>
<pre><code><div class="logo-wrapper">
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg id="logo-personal-care" width="100%" height="100%" viewBox="0 0 159 42" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;"><g id="Pest-Peeve-Personal-Care-Logo"><g id="PERSONAL-CARE"><text x="19.199px" y="41px" style="font-family:Lucida Grande;font-size:11px;font-weight:500;fill:#fff;">P<tspan x="25.609px 31.901px 39.187px 45.441px 54.316px 62.773px 70.692px 76.887px 80.698px 88.639px 96.558px " y="41px 41px 41px 41px 41px 41px 41px 41px 41px 41px 41px ">ERSONAL CAR</tspan></text><text x="103.503px" y="41.007px" style="font-family:Lucida Grande;font-size:11px;font-weight:500;fill:#fff;">E</text></g><g id="PPLogo"><path id="Fill-1" d="M158.737,16.764l0,1.884c0,0.428 -0.348,0.777 -0.776,0.777l-12.385,0c-0.429,0 -0.777,-0.349 -0.777,-0.777l0,-15.298c0,-0.428 0.348,-0.776 0.777,-0.776l11.771,0c0.238,0 0.454,0.106 0.593,0.291c0.138,0.185 0.18,0.422 0.113,0.65l-0.552,1.897c-0.1,0.347 -0.436,0.599 -0.797,0.599l-8.178,0l0,3.437l6.969,0c0.428,0 0.776,0.348 0.776,0.777l0,1.772c0,0.428 -0.348,0.776 -0.776,0.776l-6.969,0l0,3.215l9.435,0c0.428,0 0.776,0.348 0.776,0.776M143.064,0.321c0.212,0.323 0.096,0.588 -0.215,1.295l-0.061,0.138l-7.178,16.408c-0.337,0.772 -0.434,0.979 -0.644,1.118c-0.146,0.095 -0.309,0.145 -0.472,0.145l-2.487,0c-0.325,0 -0.649,-0.207 -0.787,-0.502l-5.916,-12.756c-0.106,-0.229 -0.092,-0.489 0.039,-0.693c0.131,-0.205 0.36,-0.327 0.612,-0.327l2.688,0c0.331,0 0.656,0.212 0.789,0.515l3.785,8.588l5.486,-12.976c0.329,-0.778 0.424,-0.987 0.636,-1.128c0.144,-0.096 0.308,-0.146 0.473,-0.146l2.643,0c0.249,0 0.477,0.12 0.609,0.321M122.64,16.764l0,1.884c0,0.428 -0.349,0.777 -0.777,0.777l-11.771,0c-0.428,0 -0.777,-0.349 -0.777,-0.777l0,-15.298c0,-0.428 0.349,-0.776 0.777,-0.776l11.771,0c0.238,0 0.454,0.105 0.592,0.29c0.139,0.185 0.181,0.421 0.115,0.649l-0.553,1.899c-0.1,0.347 -0.436,0.599 -0.797,0.599l-8.177,0l0,3.437l6.968,0c0.428,0 0.776,0.348 0.776,0.777l0,1.772c0,0.428 -0.348,0.776 -0.776,0.776l-6.968,0l0,3.215l8.82,0c0.428,0 0.777,0.348 0.777,0.776M105.724,16.764l0,1.884c0,0.428 -0.348,0.777 -0.777,0.777l-11.771,0c-0.428,0 -0.777,-0.349 -0.777,-0.777l0,-15.298c0,-0.428 0.349,-0.776 0.777,-0.776l11.771,0c0.238,0 0.454,0.106 0.593,0.291c0.139,0.185 0.18,0.422 0.114,0.65l-0.553,1.897c-0.101,0.347 -0.436,0.599 -0.797,0.599l-8.178,0l0,3.437l6.969,0c0.428,0 0.776,0.348 0.776,0.777l0,1.772c0,0.428 -0.348,0.776 -0.776,0.776l-6.969,0l0,3.215l8.821,0c0.429,0 0.777,0.348 0.777,0.776M85.303,8.901c0,1.823 -0.924,2.6 -3.091,2.6l-3.895,0l0,-5.49l3.895,0c2.167,0 3.091,0.864 3.091,2.89M82.212,2.574l-6.845,0c-0.429,0 -0.777,0.348 -0.777,0.776l0,15.298c0,0.428 0.348,0.777 0.777,0.777l2.174,0c0.428,0 0.776,-0.349 0.776,-0.777l0,-3.709l3.895,0c4.44,0 6.886,-2.145 6.886,-6.038c0,-4.08 -2.446,-6.327 -6.886,-6.327M66.42,2.923c0.125,0.219 0.12,0.487 -0.014,0.715l-1.122,1.908c-0.156,0.265 -0.467,0.442 -0.774,0.442l-4.365,0l0,12.66c0,0.428 -0.348,0.777 -0.776,0.777l-2.175,0c-0.428,0 -0.776,-0.349 -0.776,-0.777l0,-12.66l-5.629,0c-0.429,0 -0.777,-0.348 -0.777,-0.776l0,-1.862c0,-0.428 0.348,-0.776 0.777,-0.776l15.008,0c0.264,0 0.498,0.13 0.623,0.349M48.228,14.481c0,2.552 -1.896,5.278 -7.22,5.278c-4.576,0 -6.712,-1.734 -7.257,-2.266c-0.134,-0.133 -0.218,-0.308 -0.238,-0.497c-0.028,-0.271 0.076,-0.457 0.52,-1.203l0.24,-0.402c0.411,-0.691 0.549,-0.924 0.899,-0.975c0.211,-0.032 0.429,0.032 0.597,0.175c0.473,0.4 2.253,1.709 5.239,1.709c0.772,0 3.292,-0.116 3.292,-1.618c0,-0.824 -0.14,-1.214 -3.47,-1.829c-3.504,-0.612 -6.93,-1.526 -6.93,-5.313c-0.012,-1.252 0.455,-2.395 1.351,-3.299c0.885,-0.893 2.613,-1.957 5.824,-1.957c3.644,0 5.978,1.23 6.606,1.607c0.338,0.203 0.478,0.632 0.327,0.998l-0.768,1.864c-0.085,0.207 -0.255,0.364 -0.466,0.43c-0.211,0.066 -0.442,0.032 -0.633,-0.092c-0.462,-0.3 -2.19,-1.281 -5.044,-1.281c-0.983,0 -3.27,0.148 -3.27,1.529c0,0.832 0.606,1.451 3.618,1.961c3.711,0.629 6.783,1.453 6.783,5.181M31.133,16.764l0,1.884c0,0.428 -0.348,0.777 -0.776,0.777l-11.772,0c-0.428,0 -0.776,-0.349 -0.776,-0.777l0,-15.298c0,-0.428 0.348,-0.776 0.776,-0.776l11.772,0c0.238,0 0.454,0.106 0.593,0.291c0.138,0.185 0.18,0.422 0.113,0.65l-0.552,1.897c-0.101,0.347 -0.436,0.599 -0.798,0.599l-8.177,0l0,3.437l6.968,0c0.428,0 0.777,0.348 0.777,0.777l0,1.772c0,0.428 -0.349,0.776 -0.777,0.776l-6.968,0l0,3.215l8.821,0c0.428,0 0.776,0.348 0.776,0.776M10.713,8.901c0,1.823 -0.924,2.6 -3.091,2.6l-3.895,0l0,-5.49l3.895,0c2.167,0 3.091,0.864 3.091,2.89M7.622,2.574l-6.846,0c-0.428,0 -0.776,0.348 -0.776,0.776l0,15.298c0,0.428 0.348,0.777 0.776,0.777l2.175,0c0.428,0 0.776,-0.349 0.776,-0.777l0,-3.709l3.895,0c4.44,0 6.885,-2.145 6.885,-6.038c0,-4.08 -2.445,-6.327 -6.885,-6.327" style="fill:#fff;"/></g></g></svg>
</div>
</code></pre>
<p>CSS</p>
<pre><code>.logo-wrapper svg {
width: 300px;
}
.logo-wrapper svg path{
fill: green;
}
</code></pre>
<p>Thanks</p>
| 0debug |
node.js require from parent folder : <p>I have the following structure:</p>
<pre><code>-- node_modules
-- websites
---- common
------- config.js
---- testing
------- test.js
</code></pre>
<p>Inside config I have some variables set, which are being exported using module.export.</p>
<p>I am trying to retrieve those variables when running <code>node test.js</code> from config.js using the following codes:</p>
<pre><code>var configData = require('./common/config.js')
var configData = require('../common/config.js')
</code></pre>
<p>None of them work. What can I do to retrieve the data from the other folder?</p>
| 0debug |
int64 float32_to_int64_round_to_zero( float32 a STATUS_PARAM )
{
flag aSign;
int16 aExp, shiftCount;
bits32 aSig;
bits64 aSig64;
int64 z;
aSig = extractFloat32Frac( a );
aExp = extractFloat32Exp( a );
aSign = extractFloat32Sign( a );
shiftCount = aExp - 0xBE;
if ( 0 <= shiftCount ) {
if ( a != 0xDF000000 ) {
float_raise( float_flag_invalid STATUS_VAR);
if ( ! aSign || ( ( aExp == 0xFF ) && aSig ) ) {
return LIT64( 0x7FFFFFFFFFFFFFFF );
}
}
return (sbits64) LIT64( 0x8000000000000000 );
}
else if ( aExp <= 0x7E ) {
if ( aExp | aSig ) STATUS(float_exception_flags) |= float_flag_inexact;
return 0;
}
aSig64 = aSig | 0x00800000;
aSig64 <<= 40;
z = aSig64>>( - shiftCount );
if ( (bits64) ( aSig64<<( shiftCount & 63 ) ) ) {
STATUS(float_exception_flags) |= float_flag_inexact;
}
if ( aSign ) z = - z;
return z;
}
| 1threat |
Convert an int** array into a char** array of a different size / composition : <p>I'm trying to convert an int** array that looks like the below, into a char** array that is made up from the number of rows and is comma seperated. </p>
<pre><code>1 2 3 4
5 6 7 8
9 3 2 1
</code></pre>
<p>An example of what I would like the char** array to be represented as would be something like [['1','1','2','3','4'], ['2','5','6','7','8'] , ['3','9','3','2','1']] where every 0'th index is represented as the row number. I'm not really sure how I would be able to achieve this, is there any known methods that are good for converting an int** into something like this? Thanks.</p>
| 0debug |
cursor.execute('SELECT * FROM users WHERE username = ' + user_input) | 1threat |
async await in image loading : <p><strong>Temp.js</strong> </p>
<pre><code>export default class Temp {
async addImageProcess(src){
let img = new Image();
img.src = src;
return img.onload = await function(){
return this.height;
}
}
}
</code></pre>
<p><strong>anotherfile.js</strong></p>
<pre><code>import Temp from '../../classes/Temp'
let tmp = new Temp()
imageUrl ="https://www.google.co.in/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png"
let image = tmp.addImageProcess(imageUrl);
console.log(image)
</code></pre>
<p>Above is my code. I have a image url and tried to get image's properties using async await but it's not working, don't understand what I missed.</p>
| 0debug |
How to change all elements with the same IDs javascript/html? : <p>I will be working on a table and wanted to change one column with different img src icon.</p>
<p>Here's my sample code:</p>
<p>Html</p>
<pre><code><img src="" id="mytext">
<img src="" id="mytext">
<img src="" id="mytext">
</code></pre>
<p>Javascript</p>
<pre><code>var test = "https://www.datatables.net/media/images/nav-dt.png";
document.getElementById("mytext").src = test;
</code></pre>
<p>When i run this it only changes the src of the first instance.
How can i change them all?</p>
| 0debug |
static uint64_t gem_read(void *opaque, target_phys_addr_t offset, unsigned size)
{
GemState *s;
uint32_t retval;
s = (GemState *)opaque;
offset >>= 2;
retval = s->regs[offset];
DB_PRINT("offset: 0x%04x read: 0x%08x\n", offset*4, retval);
switch (offset) {
case GEM_ISR:
qemu_set_irq(s->irq, 0);
break;
case GEM_PHYMNTNC:
if (retval & GEM_PHYMNTNC_OP_R) {
uint32_t phy_addr, reg_num;
phy_addr = (retval & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT;
if (phy_addr == BOARD_PHY_ADDRESS) {
reg_num = (retval & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT;
retval &= 0xFFFF0000;
retval |= gem_phy_read(s, reg_num);
} else {
retval |= 0xFFFF;
}
}
break;
}
s->regs[offset] &= ~(s->regs_rtc[offset]);
retval &= ~(s->regs_wo[offset]);
DB_PRINT("0x%08x\n", retval);
return retval;
}
| 1threat |
Excel vba set styl in new sheet with a table : How do I rectify this code?
Sub test()
Sheets("new").DeleteSheets.Add.Name = "new"
ActiveSheet.Range(ActiveSheet.Cells(1, 1), ActiveSheet.Cells(3, 3)) = "f"
ActiveSheet.ListObjects.Add(xlSrcRange, Range(ActiveSheet.Cells(1, 1), ActiveSheet.Cells(3, 3)), , xlYes, , "TableStyleMedium7").Name = "sk"
End Sub | 0debug |
static AVFrame *do_vmaf(AVFilterContext *ctx, AVFrame *main, const AVFrame *ref)
{
LIBVMAFContext *s = ctx->priv;
pthread_mutex_lock(&s->lock);
while (s->frame_set != 0) {
pthread_cond_wait(&s->cond, &s->lock);
}
av_frame_ref(s->gref, ref);
av_frame_ref(s->gmain, main);
s->frame_set = 1;
pthread_cond_signal(&s->cond);
pthread_mutex_unlock(&s->lock);
return main;
}
| 1threat |
void rgb15tobgr32(const uint8_t *src, uint8_t *dst, unsigned int src_size)
{
const uint16_t *end;
uint8_t *d = (uint8_t *)dst;
const uint16_t *s = (const uint16_t *)src;
end = s + src_size/2;
while(s < end)
{
register uint16_t bgr;
bgr = *s++;
*d++ = (bgr&0x7C00)>>7;
*d++ = (bgr&0x3E0)>>2;
*d++ = (bgr&0x1F)<<3;
*d++ = 0;
}
}
| 1threat |
No repeat randomizing in objective C (Xcode) : i am lost. So i need any help.
I wrote this code for a simple game. It is randomizing a number and then do something with SWITCH. It is simple but i want to have a task only once in one round. In my case round is 3 task. After a round is done, i want to reset my variables and start a new round again. So it is random, but task wonn't happen twice in one round.
I wrote this code but it didn't work. If i click on button which will start rand(), it will do 1st task, then i click again, it will do 2nd task, but when i click 3rd times nothing is happening. 3rd task works for 4th click. Thank's for any help and sorry for my english :)
int text;
int x=3; //this is number of tasks in one round, so in switch i have 3 tasks
int z=9999;
int x0=1; //this mean's that task 0 can happen only once in one round
int x1=1;
int x2=1;
-(void)reset{ // this is rof checking if x is <1, then it will reset all variables (start a new round)
if (x<1) {
x=3;
x0=1;
x1=1;
x2=1;
}
}
-(void)randomize{
text = rand() % 3; //this wil get me a random number for switch
while(text==z) //this is because i don't want to have same number consecutively
{text = rand() % 3;}
}
- (IBAction)random:(id)sender {
[self randomize];
switch (text) {
case 0:
if (x0!=0){
//something will happen
z=0;
x0--;
x--;
[self reset];
break;
}
else {
[self randomize];
}
case 1:
if (x1!=0) {
//something will happen
z=1;
x1--;
x--;
[self reset];
break;
}
else {
[self randomize];
break;
}
case 2:
if (x2!=0) {
//something will happen
z=2;
x2--;
x--;
[self reset];
}
else {
[self randomize];
}
}
}
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.