problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
how to create a dict from row and sublist? : > I have this data :
[enter image description here][1]
[1]: https://i.stack.imgur.com/CmvIP.png
I would like create a dictionary like :
a={'Group':['Wo', 'Me','CHi']}
but in the case column 'group' row 5 the value of column 'Me' is 2 ,how I can make to see its value like :
a={5:[0, [1,1],0]}
Like create another list if the value is > 1:
| 0debug
|
Extend SwiftUI Keyboard with Custom Button : <p>I'm trying to find a way to add a key or button to the SwiftUI numberPad. The only
references I have found say it is not possible. In the Swift world I added a toolbar
with a button to dismiss the keyboard or perform some other function.</p>
<p>I would even build a ZStack view with the button on top but I can't find a way to add the
numberPad to my own view.</p>
<p>All I'm really trying to do in this case is dismiss the numberPad when the data is
entered. I first attempted to modify the SceneDelegate to dismiss on taps, but that
only works if I tap in another text or textfield view not in open space on the view.</p>
<pre><code>window.rootViewController = UIHostingController(rootView: contentView.onTapGesture {
window.endEditing(true)
})
</code></pre>
<p>Ideally, I'd add a Done key to the lower left space. Second best add a toolbar if
it can be done in SwiftUI.</p>
<p><a href="https://i.stack.imgur.com/tDT8M.png" rel="noreferrer"><img src="https://i.stack.imgur.com/tDT8M.png" alt="enter image description here"></a></p>
<p>Any guidance would be appreciated.</p>
<p>Xcode Version 11.2.1 (11B500)</p>
| 0debug
|
How to declare multiple similar variables in python? : <p>How can I declare multiple (about 50) variables that count from slider1 to slider50 ? Is there an efficient way, like looping with for?</p>
<pre><code>slider1 = models.IntegerField(widget=widgets.Slider, default=50, label="")
slider2 = models.IntegerField(widget=widgets.Slider, default=50, label="")
slider3 = models.IntegerField(widget=widgets.Slider, default=50, label="")
slider4 = models.IntegerField(widget=widgets.Slider, default=50, label="")
slider5 = models.IntegerField(widget=widgets.Slider, default=50, label="")
slider6 = models.IntegerField(widget=widgets.Slider, default=50, label="")
slider7 = models.IntegerField(widget=widgets.Slider, default=50, label="")
slider8 = models.IntegerField(widget=widgets.Slider, default=50, label="")
slider9 = models.IntegerField(widget=widgets.Slider, default=50, label="")
slider10 = models.IntegerField(widget=widgets.Slider, default=50, label="")
</code></pre>
| 0debug
|
Get windows taskbar items : <p>Any idea how to get all task bar items details in windows .I am looking for a notification if some thing new process came on task bar list</p>
| 0debug
|
Ajax Post PHP Variable : <p>I am sending some data using AJAX, I can get most of it working apart from the final data value.</p>
<p>I would like to declare a PHP variable at the beginning of my HTML file, then reference this in the AJAX post - is this possible?</p>
<p>MY code is;</p>
<pre><code><?php
$location = 'My Office';
?>
$.ajax({
url: "my url",
type: "post",
data: {
Feedback: feedbackVal,
Date: date,
Time: time,
Location: <?php echo $location; ?>
}
});
</code></pre>
<p>The error I receive in the console is;</p>
<blockquote>
<p>Uncaught SyntaxError: Unexpected identifier</p>
</blockquote>
<p>Screenshot of console;</p>
<p><a href="https://i.stack.imgur.com/NJzTy.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NJzTy.jpg" alt="enter image description here"></a></p>
<p>When I remove <code>Location</code> from the AJAX post the remaining data sends successfully. </p>
<p>Any help is appreciated.</p>
| 0debug
|
size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset,
ram_addr_t offset, size_t size, int *bytes_sent)
{
if (f->ops->save_page) {
int ret = f->ops->save_page(f, f->opaque, block_offset,
offset, size, bytes_sent);
if (ret != RAM_SAVE_CONTROL_DELAYED) {
if (*bytes_sent > 0) {
qemu_update_position(f, *bytes_sent);
} else if (ret < 0) {
qemu_file_set_error(f, ret);
}
}
return ret;
}
return RAM_SAVE_CONTROL_NOT_SUPP;
}
| 1threat
|
How to merge csv files using batch : <p>I have to merge some .csv files into one .xls file using batch.
The problem is that I have to take the .csv file column by column and put in the .xls file like that.
Can I do this using a batch or do you have some better suggestion? I should specify that there are two columns in every file and one of them is text and the other decimal number.
Thank you! </p>
| 0debug
|
Convert Java Code to Swift : I wanna convert java code to swift facing an issue . Any help is appreciated .
Java Code :
for(String s: str){
char arr[] = new char[26]
for(int i =0;i< s.length(); i++){
arr[s.charAt(i) -'a']++;
}
}
Swift Code :
Below are extenions and classes.
extension String {
var asciiArray: [UInt32] {
return unicodeScalars.filter{$0.isASCII}.map{$0.value}
}
}
extension Character {
var asciiValue: UInt32? {
return String(self).unicodeScalars.filter{$0.isASCII}.first?.value
}
}
class GroupXXX{
func groupXXX(strList: [String]){
for str in strList{
var charArray = [Character?](repeating: nil, count: 26)
var s = str.characters.map { $0 }
for i in 0..<s.count{
charArray[(s[i].asciiValue)! - ('a'.asciiValue)!]++
}
}
}
}
| 0debug
|
How to Test a Global Event Bus With Vue Test Utils? : <p>I am trying to learn how to test events emitted through a global Event Bus. Here's the code with some comments in the places I don't know what to do.</p>
<pre class="lang-js prettyprint-override"><code>// EvtBus.js
import Vue from 'vue';
export const EvtBus = new Vue();
</code></pre>
<pre class="lang-html prettyprint-override"><code><!-- CouponCode.vue -->
<template>
<div>
<input
class="coupon-code"
type="text"
v-model="code"
@input="validate">
<p v-if="valid">
Coupon Redeemed: {{ message }}
</p>
</div>
</template>
<script>
import { EvtBus } from '../EvtBus.js';
export default {
data () {
return {
code: '',
valid: false,
coupons: [
{
code: '50OFF',
discount: 50,
message: '50% Off!'
},
{
code: 'FREE',
discount: 100,
message: 'Entirely Free!'
}
]
};
},
created () {
EvtBus.$on('coupon-applied', () => {
//console.info('had a coupon applied event on component');
});
},
methods: {
validate () {
// Extract the coupon codes into an array and check if that array
// includes the typed in coupon code.
this.valid = this.coupons.map(coupon => coupon.code).includes(this.code);
if (this.valid) {
this.$emit('applied');
// I NEVER see this on the coupon-code.spec.js
EvtBus.$emit('coupon-applied');
}
}
},
computed: {
message () {
return this.coupons.find(coupon => coupon.code === this.code).message;
}
}
}
</script>
</code></pre>
<pre class="lang-js prettyprint-override"><code>// tests/coupon-code.spec.js
import expect from 'expect';
import { mount } from '@vue/test-utils';
import CouponCode from '../src/components/CouponCode.vue';
import { EvtBus } from '../src/EvtBus.js';
describe('Reminders', () => {
let wrp;
beforeEach(() => {
wrp = mount(CouponCode);
});
it('broadcasts the percentage discount when a valid coupon code is applied', () => {
let code = wrp.find('input.coupon-code');
code.element.value = '50OFF';
code.trigger('input');
console.log(wrp.emitted('applied'));
//
// I NEVER see this on the outpout.
// How can I test it through a global event bus rather than
// an event emitted from the component instance?
//
EvtBus.$on('coupon-applied', () => {
console.log('coupon was applied through event bus');
});
// Passes, but not using EvtBus instance.
expect(wrp.emitted('applied')).toBeTruthy;
});
});
</code></pre>
<p>So, my doubt is how to test that the global event bus is emitting and listening to events inside components that use that event bus.</p>
<p>So, is it possible to test the global Event Bus using Vue Test Utils or I should use another approach?</p>
| 0debug
|
Can I make that code shorter? : as in title. Im new in android programing/development and have just basic knowledge of Java but many years in different languages such as PHP, JavaScript and some c#.. Im just wondering can I make this code shorter like into one line? Without making another variable called "test" just for test purposes.. and then use that one variable for whatever I would like to such as auth system.
public void signIn(View view) {
EditText username = (EditText) findViewById(R.id.usernameField);
String test = username.getText().toString();
Toast.makeText(MainActivity.this, test, Toast.LENGTH_SHORT).show();
}
| 0debug
|
Manipulate every second row as a particular column value in R dataframe : <p>I have a dataframe where every second row from column <code>X1</code>(which is the address) should going to column <code>x3</code> in its previous row. Below is the actaul dataframe structure.How could I do that in <code>r</code>.</p>
<pre><code>structure(list(X1 = c("(512) Brewing Company", "407 Radam LnSte F200Austin, Texas, 78745-1197United States(512) 921-1545",
"0 Mile Brewing Company", "11 W 2nd StHummelstown, Pennsylvania, 17036-1506United States(717) 319-0133",
"10 Barrel Brewing", "1501 E StSan Diego, California, 92101United States"
), X2 = c("(512) Brewing Company", "407 Radam LnSte F200Austin, Texas, 78745-1197United States(512) 921-1545",
"0 Mile Brewing Company", "11 W 2nd StHummelstown, Pennsylvania, 17036-1506United States(717) 319-0133",
"10 Barrel Brewing", "1501 E StSan Diego, California, 92101United States"
), X3 = c("-", "407 Radam LnSte F200Austin, Texas, 78745-1197United States(512) 921-1545",
"-", "11 W 2nd StHummelstown, Pennsylvania, 17036-1506United States(717) 319-0133",
"-", "1501 E StSan Diego, California, 92101United States"), X4 = c("-",
"407 Radam LnSte F200Austin, Texas, 78745-1197United States(512) 921-1545",
"-", "11 W 2nd StHummelstown, Pennsylvania, 17036-1506United States(717) 319-0133",
"-", "1501 E StSan Diego, California, 92101United States"), X5 = c("3.84",
"Brewery, Bar", "-", "Brewery", "-", "Brewery, Bar, Eatery"),
X6 = c("37", "Brewery, Bar", "4", "Brewery", "0", "Brewery, Bar, Eatery"
)), row.names = 4:9, class = "data.frame")
</code></pre>
| 0debug
|
How do I click browser button in PHP : I have a contact.php file in website. When user submit contact form, the message is displayed with browser at www.myurl/contact.php. I want user to be redirected to myurl home page.
Here is the PHP code in the contact.php file:
if ($_POST) {
if ($result) echo 'Thank you! We have received your message.';
else echo 'Sorry, unexpected error. Please try again later';
How will I do that?
| 0debug
|
How to create a categorical variable in R with unequal categoris : <p>I am trying to create categories of credit bureau scores. I have indiviudal scores for clients but I would like to create categories as follows: -1, 0, 1 - 50, 51 - 150, 151 - 250, 251+ I use R</p>
| 0debug
|
How to give user input for array of arraylist? : <p>I would like to use input an array of arraylist, where the first input is the number of arrays of arraylist and the next line represents the input for each array. Please let me know where am going wrong. Please find below the code for the same:</p>
<pre><code>public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int a = input.nextInt();
ArrayList[] al = new ArrayList[a];
for( int i =0; i<a; i++){
while(input.hasNextLine())
{
al[i].add(input.nextInt());
}
}
System.out.print("result is"+al[0]);
}
</code></pre>
| 0debug
|
static int read_write_object(int fd, char *buf, uint64_t oid, int copies,
unsigned int datalen, uint64_t offset,
bool write, bool create, bool cache)
{
SheepdogObjReq hdr;
SheepdogObjRsp *rsp = (SheepdogObjRsp *)&hdr;
unsigned int wlen, rlen;
int ret;
memset(&hdr, 0, sizeof(hdr));
if (write) {
wlen = datalen;
rlen = 0;
hdr.flags = SD_FLAG_CMD_WRITE;
if (create) {
hdr.opcode = SD_OP_CREATE_AND_WRITE_OBJ;
} else {
hdr.opcode = SD_OP_WRITE_OBJ;
}
} else {
wlen = 0;
rlen = datalen;
hdr.opcode = SD_OP_READ_OBJ;
}
if (cache) {
hdr.flags |= SD_FLAG_CMD_CACHE;
}
hdr.oid = oid;
hdr.data_length = datalen;
hdr.offset = offset;
hdr.copies = copies;
ret = do_req(fd, (SheepdogReq *)&hdr, buf, &wlen, &rlen);
if (ret) {
error_report("failed to send a request to the sheep");
return ret;
}
switch (rsp->result) {
case SD_RES_SUCCESS:
return 0;
default:
error_report("%s", sd_strerror(rsp->result));
return -EIO;
}
}
| 1threat
|
static VFIOGroup *vfio_get_group(int groupid)
{
VFIOGroup *group;
char path[32];
struct vfio_group_status status = { .argsz = sizeof(status) };
QLIST_FOREACH(group, &group_list, next) {
if (group->groupid == groupid) {
return group;
}
}
group = g_malloc0(sizeof(*group));
snprintf(path, sizeof(path), "/dev/vfio/%d", groupid);
group->fd = qemu_open(path, O_RDWR);
if (group->fd < 0) {
error_report("vfio: error opening %s: %m", path);
goto free_group_exit;
}
if (ioctl(group->fd, VFIO_GROUP_GET_STATUS, &status)) {
error_report("vfio: error getting group status: %m");
goto close_fd_exit;
}
if (!(status.flags & VFIO_GROUP_FLAGS_VIABLE)) {
error_report("vfio: error, group %d is not viable, please ensure "
"all devices within the iommu_group are bound to their "
"vfio bus driver.", groupid);
goto close_fd_exit;
}
group->groupid = groupid;
QLIST_INIT(&group->device_list);
if (vfio_connect_container(group)) {
error_report("vfio: failed to setup container for group %d", groupid);
goto close_fd_exit;
}
if (QLIST_EMPTY(&group_list)) {
qemu_register_reset(vfio_pci_reset_handler, NULL);
}
QLIST_INSERT_HEAD(&group_list, group, next);
vfio_kvm_device_add_group(group);
return group;
close_fd_exit:
close(group->fd);
free_group_exit:
g_free(group);
return NULL;
}
| 1threat
|
Maven plugin for Tomcat 9 : <p>I didn't find any tomcat-maven-plugin other than tomcat7-maven-plugin.
Can I use it with apache-tomcat-9.0.0.M15?</p>
| 0debug
|
static void dhcp_decode(const struct bootp_t *bp, int *pmsg_type,
const struct in_addr **preq_addr)
{
const uint8_t *p, *p_end;
int len, tag;
*pmsg_type = 0;
*preq_addr = NULL;
p = bp->bp_vend;
p_end = p + DHCP_OPT_LEN;
if (memcmp(p, rfc1533_cookie, 4) != 0)
return;
p += 4;
while (p < p_end) {
tag = p[0];
if (tag == RFC1533_PAD) {
p++;
} else if (tag == RFC1533_END) {
break;
} else {
p++;
if (p >= p_end)
break;
len = *p++;
DPRINTF("dhcp: tag=%d len=%d\n", tag, len);
switch(tag) {
case RFC2132_MSG_TYPE:
if (len >= 1)
*pmsg_type = p[0];
break;
case RFC2132_REQ_ADDR:
if (len >= 4)
*preq_addr = (struct in_addr *)p;
break;
default:
break;
}
p += len;
}
}
if (*pmsg_type == DHCPREQUEST && !*preq_addr && bp->bp_ciaddr.s_addr) {
*preq_addr = &bp->bp_ciaddr;
}
}
| 1threat
|
window.location.href = 'http://attack.com?user=' + user_input;
| 1threat
|
What is the difference between input function and eval function on python : <p>I don't have o picture but I am asking did question because I am a beginner using python</p>
| 0debug
|
What is the size of the buffer that I need to define while I use fscanf? : <p>Given a file with only the following line: </p>
<blockquote>
<p>abc </p>
<hr>
</blockquote>
<p>The second line is empty. </p>
<p>How can I read it with fscanf? </p>
<p>Option 1: </p>
<pre><code>FILE* f = fopen("f","r");
char str[3];
fscanf(f , "%s" , str);
</code></pre>
<p>Option 2: </p>
<pre><code>FILE* f = fopen("f","r");
char str[4];
fscanf(f , "%s" , str);
</code></pre>
<p>What is the correct way?</p>
| 0debug
|
How to sort a column from ascending order for EACH ID in R : <p>If I want to sort the Chrom# from ascending order (1 to 23) for each unique ID (as shown below there's multiple rows of same IDs, how to write the R code for it? eg) MB-0002, chrom from 1,1,1,2,4,22... etc. 1 chrom per row. I am new to R so any help would be appreciated. Thanks so much!</p>
<p><a href="http://i.stack.imgur.com/Rms6M.png" rel="nofollow">sample dataset</a></p>
| 0debug
|
Three operator causes StackOverflowException : <p>I know, I could simply use abs in this case, but I'm just curious: why is this happening?</p>
<pre><code>public float maxThrotle{
set { maxThrotle = value < 0 ? -value : value; //this line causes problem
}
get { return maxThrotle; }
}
</code></pre>
| 0debug
|
setLevel okhttp LoggingInterceptor deprecated : <p>setLevel(okhttp3.logging.HttpLoggingInterceptor.Level)' is deprecated</p>
<p>what should replace with setLevel? to remove the deprecated issue</p>
| 0debug
|
Count the number of letters : <p>I block completely on a small problem. I want to count the number of letters for each names. My problem is here I think.</p>
<pre><code>System.out.println("The name " + tab[i] + "contains " + length.tab[i] + " letters");
</code></pre>
<p>Here is my code below : </p>
<pre><code>String[] tab = {"Jean-Michel", "Marc", "Vanessa", "Anne", "Maximilien", "Alexandre-Benoît", "Louise"};
int i = 0;
while(i < tab.length){
System.out.println("The name " + tab[i] + "contains " + length.tab[i] + " letters");
i = i +1;
}
</code></pre>
| 0debug
|
how can i get return value from stored procedure and use it in script task using OLE DB Command Task(Provider, Providerlocation) in ssis : [enter image description here][1]
[1]: https://i.stack.imgur.com/LZZfR.png
How to get return value from OLE DB Command Task and use it in Script task?
| 0debug
|
What is Frontend? should it have WEB server and WEB framework? : I'm newbie in Web field.
I plan to build Web application which's structure is
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/iloS2.png
| 0debug
|
Why doesn't this code work ??<!DOCTYPE html> <html> <head> <base target="_top"> </head> <body> Hello, World! </body> </html> :
Does not perform this operation. When you run the code, the program outputs a blank page, and should display Hello, World !. Please correct the error!
| 0debug
|
Calculate sklearn.roc_auc_score for multi-class : <p>I would like to calculate AUC, precision, accuracy for my classifier.
I am doing supervised learning:</p>
<p>Here is my working code.
This code is working fine for binary class, but not for multi class.
Please assume that you have a dataframe with binary classes:</p>
<pre><code>sample_features_dataframe = self._get_sample_features_dataframe()
labeled_sample_features_dataframe = retrieve_labeled_sample_dataframe(sample_features_dataframe)
labeled_sample_features_dataframe, binary_class_series, multi_class_series = self._prepare_dataframe_for_learning(labeled_sample_features_dataframe)
k = 10
k_folds = StratifiedKFold(binary_class_series, k)
for train_indexes, test_indexes in k_folds:
train_set_dataframe = labeled_sample_features_dataframe.loc[train_indexes.tolist()]
test_set_dataframe = labeled_sample_features_dataframe.loc[test_indexes.tolist()]
train_class = binary_class_series[train_indexes]
test_class = binary_class_series[test_indexes]
selected_classifier = RandomForestClassifier(n_estimators=100)
selected_classifier.fit(train_set_dataframe, train_class)
predictions = selected_classifier.predict(test_set_dataframe)
predictions_proba = selected_classifier.predict_proba(test_set_dataframe)
roc += roc_auc_score(test_class, predictions_proba[:,1])
accuracy += accuracy_score(test_class, predictions)
recall += recall_score(test_class, predictions)
precision += precision_score(test_class, predictions)
</code></pre>
<p>In the end I divided the results in K of course for getting average AUC, precision, etc.
This code is working fine.
However, I cannot calculate the same for multi class: </p>
<pre><code> train_class = multi_class_series[train_indexes]
test_class = multi_class_series[test_indexes]
selected_classifier = RandomForestClassifier(n_estimators=100)
selected_classifier.fit(train_set_dataframe, train_class)
predictions = selected_classifier.predict(test_set_dataframe)
predictions_proba = selected_classifier.predict_proba(test_set_dataframe)
</code></pre>
<p>I found that for multi class I have to add the parameter "weighted" for average.</p>
<pre><code> roc += roc_auc_score(test_class, predictions_proba[:,1], average="weighted")
</code></pre>
<p>I got an error: raise ValueError("{0} format is not supported".format(y_type))</p>
<p>ValueError: multiclass format is not supported</p>
| 0debug
|
static uint32_t pm_ioport_readw(void *opaque, uint32_t addr)
{
VT686PMState *s = opaque;
uint32_t val;
addr &= 0x0f;
switch (addr) {
case 0x00:
val = acpi_pm1_evt_get_sts(&s->ar, s->ar.tmr.overflow_time);
break;
case 0x02:
val = s->ar.pm1.evt.en;
break;
case 0x04:
val = s->ar.pm1.cnt.cnt;
break;
default:
val = 0;
break;
}
DPRINTF("PM readw port=0x%04x val=0x%02x\n", addr, val);
return val;
}
| 1threat
|
static inline void mix_3f_2r_to_dolby(AC3DecodeContext *ctx)
{
int i;
float (*output)[256] = ctx->audio_block.block_output;
for (i = 0; i < 256; i++) {
output[1][i] += (output[2][i] - output[4][i] - output[5][i]);
output[2][i] += (output[3][i] + output[4][i] + output[5][i]);
}
memset(output[3], 0, sizeof(output[3]));
memset(output[4], 0, sizeof(output[4]));
memset(output[5], 0, sizeof(output[5]));
}
| 1threat
|
How to edit the link in a slack notification from Grafana : <p>We are using Grafana 4 and have implemented alert notifications to a slack channel through an Incoming Webhook. The notifications are sent as and wen expected, except that the link in the notification points to the wrong place. For instance, if you take the following test notification:</p>
<p><a href="https://i.stack.imgur.com/Uad1q.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Uad1q.png" alt="enter image description here"></a></p>
<p>Then I would expect the link in <code>[Alerting] Test notification</code> to point to the Grafana server. However, the host in that link is localhost. I thought it might be just a problem with test notifications, but this also happens with real notifications: the path will be correct, but the host and port will be wrong (localhost:62033, for full details).</p>
<p>I have tried to find the place where this host/port is configured, with no luck. Any tips so as to how to fix this?</p>
<p>Thanks in advance.</p>
| 0debug
|
How can I format the following date : The line System.out.print("End of rental: "+endDate); produces the following really long calendar. How can I format this down to dd/mm/yyyy
End of rental: java.util.GregorianCalendar[time=1495050625200,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/London",offset=0,dstSavings=3600000,useDaylight=true,transitions=242,lastRule=java.util.SimpleTimeZone[id=Europe/London,offset=0,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=2017,MONTH=4,WEEK_OF_YEAR=20,WEEK_OF_MONTH=3,DAY_OF_MONTH=17,DAY_OF_YEAR=137,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=3,AM_PM=1,HOUR=8,HOUR_OF_DAY=20,MINUTE=50,SECOND=25,MILLISECOND=200,ZONE_OFFSET=0,DST_OFFSET=3600000]
| 0debug
|
void qemu_cpu_kick(void *_env)
{
CPUState *env = _env;
qemu_cond_broadcast(env->halt_cond);
qemu_thread_signal(env->thread, SIG_IPI);
}
| 1threat
|
Getting Error with this message Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host : Getting below error while calling Web Api through console application using HTTP client.
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host
In Background Service does work but application get crash with this message.
Can anyone help me out on this as this is very urgent for me.
I tried lots of solution but no one as worked out.
| 0debug
|
static uint64_t imx_avic_read(void *opaque,
target_phys_addr_t offset, unsigned size)
{
IMXAVICState *s = (IMXAVICState *)opaque;
DPRINTF("read(offset = 0x%x)\n", offset >> 2);
switch (offset >> 2) {
case 0:
return s->intcntl;
case 1:
return s->intmask;
case 2:
case 3:
return 0;
case 4:
return s->enabled >> 32;
case 5:
return s->enabled & 0xffffffffULL;
case 6:
return s->is_fiq >> 32;
case 7:
return s->is_fiq & 0xffffffffULL;
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
return s->prio[15-(offset>>2)];
case 16:
{
uint64_t flags = s->pending & s->enabled & ~s->is_fiq;
int i;
int prio = -1;
int irq = -1;
for (i = 63; i >= 0; --i) {
if (flags & (1ULL<<i)) {
int irq_prio = imx_avic_prio(s, i);
if (irq_prio > prio) {
irq = i;
prio = irq_prio;
}
}
}
if (irq >= 0) {
imx_avic_set_irq(s, irq, 0);
return irq << 16 | prio;
}
return 0xffffffffULL;
}
case 17:
{
uint64_t flags = s->pending & s->enabled & s->is_fiq;
int i = ctz64(flags);
if (i < 64) {
imx_avic_set_irq(opaque, i, 0);
return i;
}
return 0xffffffffULL;
}
case 18:
return s->pending >> 32;
case 19:
return s->pending & 0xffffffffULL;
case 20:
case 21:
return 0;
case 22:
return (s->pending & s->enabled & ~s->is_fiq) >> 32;
case 23:
return (s->pending & s->enabled & ~s->is_fiq) & 0xffffffffULL;
case 24:
return (s->pending & s->enabled & s->is_fiq) >> 32;
case 25:
return (s->pending & s->enabled & s->is_fiq) & 0xffffffffULL;
case 0x40:
return 0x4;
default:
IPRINTF("imx_avic_read: Bad offset 0x%x\n", (int)offset);
return 0;
}
}
| 1threat
|
Please help to correct my humble code. Social security number validation : I am trying to validate ssn, that should be in format: xxxCd1d2m1m2y1y2. "xxx" are consecutively assigned digits, "C" is the checksum digit, "dd" donates the day, "mm" the month and "yy" the year of birth.
c == (x1*3 + x2*7 + x3*9 + d1*5 + d2*8 + m1*4 + m2*2 + y1*1 + y2*6) % 11
Here is what i've got so far:
from datetime import datetime
def is_valid(digit_list):
ssn=list(digit_list)
x1, x2, x3, c, d1, d2, m1, m2, y1, y2 = [int(digit) for digit in digit_list]
date=digit_list[4:]
if len(ssn) == 10 and c == (x1*3 + x2*7 + x3*9 + d1*5 + d2*8 + m1*4 + m2*2 + y1*1 + y2*6) % 11 and date==datetime.strptime(date,'%d%m%y'):
print(True)
else:
print(False)
Example of valid number: 5446180993
| 0debug
|
Get file path from URI on Android 10, : <p>I need to pick files from the device, </p>
<p>Here is my code, </p>
<pre><code> Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
String[] mimeTypes = {"image/*", "application/pdf"};
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
startActivityForResult(intent, PICK);
</code></pre>
<p>The picked URIs url always like this on Android 10 devices, </p>
<pre><code>content://com.android.providers.downloads.documents/document/msf:75878
</code></pre>
<p>I tried many different solutions to get the file path from this URI but with no luck, </p>
<p>Note: my app works perfectly on pre-Android 10 devices and I am able to get the picked files paths.</p>
| 0debug
|
onKeyDown method is not working in android studio : I am trying to bind the android's keyboard enter button as submit/go button But it is showing that the onKeyDown method is not defined in this scope, below is attached the snapshot of my code[enter image description here][1]
[1]: https://i.stack.imgur.com/9JeiL.jpg
Actually I am trying to build a browser and I need the keyboard button as submit button.
| 0debug
|
ORA-00920: invalid relational operator i obtain that please help me : INSERT INTO DIM_TEMPS (ID_DATE, DATE_DU_JOUR, ANNEE_CALENDAIRE, SEMESTRE, LIBELLE_SEMESTRE, TRIMESTRE, LIBELLE_TRIMESTRE, ANNEE_MOIS,MOIS, LIBELLE_MOIS, SEMAINE, JOUR, LIBELLE_JOUR, JOUR_FERIE, JOUR_OUVRE, QUANTIEME_JOUR) SELECT TO_NUMBER(TO_CHAR(DT_CAL, "YYYYMMDD")) AS ID_CALENDRIER, DT_CAL AS DATE_DU_JOUR, TO_NUMBER(TO_CHAR(DT_CAL, "YYYY")) AS ANNEE_CALENDAIRE, ROUND(TO_NUMBER(TO_CHAR(DT_CAL, "Q"))/2) AS SEMESTRE, CASE ROUND(TO_NUMBER(TO_CHAR(DT_CAL, "Q"))/2) WHEN 1 THEN "1er semestre" ELSE "2ème semestre" END AS LIBELLE_SEMESTRE, TO_NUMBER(TO_CHAR(DT_CAL, "Q")) AS TRIMESTRE, CASE TO_NUMBER(TO_CHAR(DT_CAL, "Q")) WHEN 1 THEN "1er trimestre" ELSE TO_NUMBER(TO_CHAR(DT_CAL, "Q")) || "ème trimestre" END AS LIBELLE_TRIMESTRE, TO_NUMBER(TO_NUMBER(TO_CHAR(DT_CAL, "YYYY")) || LPAD(TO_CHAR(DT_CAL, "MM"), 2, "0")) AS ANNEE_MOIS, TO_NUMBER(TO_CHAR(DT_CAL, "MM")) AS MOIS, TO_CHAR(DT_CAL, "Month") AS LIBELLE_MOIS, TO_NUMBER(TO_CHAR(DT_CAL, "IW")) AS SEMAINE, TO_NUMBER(TO_CHAR(DT_CAL, "DD")) AS JOUR, TO_CHAR(DT_CAL, "Day") AS LIBELLE_JOUR, CASE WHEN TO_CHAR(DT_CAL, "D") IN ("6", "7") THEN "Oui" ELSE "Non" END AS JOUR_FERIE, CASE WHEN TO_CHAR(DT_CAL, "D") IN ("6", "7") THEN "Non" ELSE "Oui" END AS JOUR_OUVRE, NUM_JOUR AS QUANTIEME_JOUR FROM ( SELECT to_date("19000101","YYYYMMDD") + (rownum - 1) AS DT_CAL, rownum AS NUM_JOUR FROM dual connect BY to_date("19000101","YYYYMMDD") + (rownum - 1) <= to_date('29991231','YYYYMMDD') ); COMMIT;
| 0debug
|
Methods and Math.Max to return the value from user prompt : <p>I am trying to return the Max value from asking a user to input a first and second value. I am also trying to utilize the Math.Max function.</p>
<pre><code>class Return_Values
{
public void RunExercise()
{
Console.WriteLine("First value?");
int firstNumber = Int32.Parse(Console.ReadLine());
Console.WriteLine("Second value?");
int secondNumber = Int32.Parse(Console.ReadLine());
int theMax;
Max m = new Max();
m.returnMax(firstNumber, secondNumber);
Console.WriteLine("The max of {0} and {1} is {2}", firstNumber, secondNumber, theMax);
}
}
class Max
{
public int returnMax(int firstNumber, int secondNumber)
{
int theMax = Math.Max(firstNumber, secondNumber);
return theMax;
}
}
</code></pre>
<p>I keep getting the error, Use of unassigned local variable 'theMax'.</p>
| 0debug
|
In most of cases machine learning algorithm gets over-fit. Anyone can explain me in clear way : <p>when it gets over-fit most articles say, algorithm tries to memories, the data points which are give as train input.In a clear way could anyone explain how algorithm memorizes?</p>
| 0debug
|
What return type should be used for setTimeout in TypeScript? : <p>Consider following code:</p>
<pre><code>const timer: number = setTimeout(() => '', 1000);
</code></pre>
<p>Typescript throws an error: <code>Type 'Timer' is not assignable to type 'number'.</code> Quick lookup tells me that <code>setTimeout</code> returns <code>NodeJS.Timer</code>.</p>
<p>But if I am doing <strong>browser-based development</strong>, using <code>NodeJS.Timer</code> feels wrong. Which is the correct type definition or return type for making <code>setTimeout</code> work without resorting to <code>any</code> declaration?</p>
| 0debug
|
Wordpress redirected automatically to other site : <p>My wordpress website was redirecting to other site. It was hacked. I just delete the folder cache in wp-content folder. And it resolved.</p>
<p>Can u tell me where was exact problem?</p>
| 0debug
|
Formatting a Date String in React Native : <p>I'm trying to format a Date String in React Native.</p>
<p>Ex: 2016-01-04 10:34:23</p>
<p>Following is the code I'm using.</p>
<pre><code>var date = new Date("2016-01-04 10:34:23");
console.log(date);
</code></pre>
<p>My problem is, when I'm emulating this on a iPhone 6S, it'll print Mon <code>Jan 04 2016 10:34:23 GMT+0530 (IST)</code> without any problem. But if I try with the iPhone 5S it prints nothing. And if you try to get the month by using a method like <code>date.getMonth()</code> it'll print <code>"NaN"</code>.</p>
<p>Why is this? What is the workaround?</p>
| 0debug
|
mssql which is the syntax 'if' : <p>I have this code in mssql:</p>
<pre><code>SELECT
t1.Id,
t2.Id,
t1.QuantityIn,
t1.PriceIn,
t2.QuantityOut,
(If (t2.QuantityOut - t1.QuantityIn)=0
THEN t2.QuantityOut
Else t2.QuantityOut - t1.QuantityIn ) AS Quant,
t2.PriceOut
FROM t1
LEFT JOIN t2 ON t2.Id = t1.Id
</code></pre>
<p>In software MsSql Server Management Studio error is </p>
<blockquote>
<p>Incorrect syntax near the keyword 'If'.</p>
</blockquote>
<p>What is the correct syntax for 'if' in my case?</p>
<p>Thank you!</p>
| 0debug
|
Flask app context for sqlalchemy : <p>I am working on a small rest api in flask. Api has route that registers a request and spawn separate thread to run in background. Here is the code:</p>
<pre><code>def dostuff(scriptname):
new_thread = threading.Thread(target=executescript,args=(scriptname,))
new_thread.start()
</code></pre>
<p>Thread starts but it errors out when I try to insert into db from executescript function. It complains about db object not registered with the app.</p>
<p>I am dynamically creating my app (with api as Blueprint).</p>
<p>Here is the structure of the app</p>
<pre><code>-run.py ## runner script
-config
-development.py
-prod.py
-app
-__init__.py
- auth.py
- api_v1
- __init__.py
- routes.py
- models.py
</code></pre>
<p>here is my runner script <code>run.py</code> :</p>
<pre><code>from app import create_app, db
if __name__ == '__main__':
app = create_app(os.environ.get('FLASK_CONFIG', 'development'))
with app.app_context():
db.create_all()
app.run()
</code></pre>
<p>Here is the code from <code>app/__init__.py</code> which creates the app:</p>
<pre><code>from flask import Flask, jsonify, g
from flask.ext.sqlalchemy import SQLAlchemy
db = SQLAlchemy()
def create_app(config_name):
"""Create an application instance."""
app = Flask(__name__)
# apply configuration
cfg = os.path.join(os.getcwd(), 'config', config_name + '.py')
app.config.from_pyfile(cfg)
# initialize extensions
db.init_app(app)
# register blueprints
from .api_v1 import api as api_blueprint
app.register_blueprint(api_blueprint, url_prefix='/api/')
return app
</code></pre>
<p>All I need to know is how do I extend app context in <code>routes.py</code>. I can not import app there directly and if I do the following, I get <code>RuntimeError: working outside of application context</code></p>
<pre><code>def executescript(scriptname):
with current_app.app_context():
test_run = Testrun(pid=989, exit_status=988,comments="Test TestStarted")
db.session.add(test_run)
db.session.commit()
</code></pre>
| 0debug
|
How to use puppeteer to dump WebSocket data : <p>I want to get websocket data in this page <a href="https://upbit.com/exchange?code=CRIX.UPBIT.KRW-BTC" rel="noreferrer">https://upbit.com/exchange?code=CRIX.UPBIT.KRW-BTC</a>, its websocket URL is dynamic and only valid during the first connection, the second time you connect to it it will not send data anymore.</p>
<p><a href="https://i.stack.imgur.com/DLWy7.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/DLWy7.jpg" alt="enter image description here"></a></p>
<p>So I wonder that maybe headless chrome can help me to monitor the websocket data. </p>
<p>Any ideas? Thanks!</p>
| 0debug
|
How to get Max rating post in cakephp : hi i new in php i did'nt understand how to get only that post which have maximum rating
$all= $this->Post ->find('all', array('conditions' => array('id'), 'recursive' => -1, 'limit' => 2));
i want only show that Post which have maximum number of rating
[0] => Array
(
[Post ] => Array
(
[id] => 1
[name] => Gramercy Tavern
[contact] =>
[cuisine] =>
[rslug] => gramercy-tavern
[state] => NY
[rating] => 2
[created_date_time] => 2017-10-14 16:42:10
)
)
| 0debug
|
import cmath
def angle_complex(a,b):
cn=complex(a,b)
angle=cmath.phase(a+b)
return angle
| 0debug
|
static int field_end(H264Context *h, int in_setup)
{
MpegEncContext *const s = &h->s;
AVCodecContext *const avctx = s->avctx;
int err = 0;
s->mb_y = 0;
if (!in_setup && !s->dropable)
ff_thread_report_progress(&s->current_picture_ptr->f,
(16 * s->mb_height >> FIELD_PICTURE) - 1,
s->picture_structure == PICT_BOTTOM_FIELD);
if (CONFIG_H264_VDPAU_DECODER &&
s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
ff_vdpau_h264_set_reference_frames(s);
if (in_setup || !(avctx->active_thread_type & FF_THREAD_FRAME)) {
if (!s->dropable) {
err = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
h->prev_poc_msb = h->poc_msb;
h->prev_poc_lsb = h->poc_lsb;
}
h->prev_frame_num_offset = h->frame_num_offset;
h->prev_frame_num = h->frame_num;
h->outputed_poc = h->next_outputed_poc;
}
if (avctx->hwaccel) {
if (avctx->hwaccel->end_frame(avctx) < 0)
av_log(avctx, AV_LOG_ERROR,
"hardware accelerator failed to decode picture\n");
}
if (CONFIG_H264_VDPAU_DECODER &&
s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
ff_vdpau_h264_picture_complete(s);
if (!FIELD_PICTURE)
ff_er_frame_end(s);
ff_MPV_frame_end(s);
h->current_slice = 0;
return err;
}
| 1threat
|
Get string between string/ and / : <p>Ive been trying for ages to get the id <code>30393</code> from the below string.</p>
<p><code>https://example.com/service_requests/30393/journey</code></p>
<p>Any ideas how? Its the <code>/</code> causing me issues. Been trying <code>(?<=/).*?(?=/)</code> but obviously it doesn't work.</p>
| 0debug
|
How do I get consistent values with influxdb non_negative_derivative? : <p>Using grafana with influxdb, I am trying to show the per-second rate of some value that is a counter. If I use the <code>non_negative_derivative(1s)</code> function, the value of the rate seems to change dramatically depending on the time width of the grafana view. I'm using the <code>last</code> selector (but could also use <code>max</code> which is the same value since it is a counter).</p>
<p>Specifically, I'm using:</p>
<p><code>SELECT non_negative_derivative(last("my_counter"), 1s) FROM ...</code></p>
<p>According to the <a href="https://docs.influxdata.com/influxdb/v0.13/query_language/functions/#non-negative-derivative" rel="noreferrer">influxdb docs non-negative-derivative</a>:</p>
<blockquote>
<p>InfluxDB calculates the difference between chronological field values and converts those results into the rate of change per unit.</p>
</blockquote>
<p>So to me, that means that the value at a given point should not change that much when expanding the time view, since the value should be <em>rate of change per unit</em> (1s in my example query above).</p>
<p>In graphite, they have the specific <code>perSecond</code> function, which works much better:</p>
<p><code>perSecond(consolidateBy(my_counter, 'max'))</code></p>
<p>Any ideas on what I'm doing wrong with the influx query above?</p>
| 0debug
|
static MemoryRegionSection *address_space_lookup_region(AddressSpaceDispatch *d,
hwaddr addr,
bool resolve_subpage)
{
MemoryRegionSection *section;
subpage_t *subpage;
section = phys_page_find(d->phys_map, addr, d->map.nodes, d->map.sections);
if (resolve_subpage && section->mr->subpage) {
subpage = container_of(section->mr, subpage_t, iomem);
section = &d->map.sections[subpage->sub_section[SUBPAGE_IDX(addr)]];
}
return section;
}
| 1threat
|
static int decode_band_types(AACContext *ac, enum BandType band_type[120],
int band_type_run_end[120], GetBitContext *gb,
IndividualChannelStream *ics)
{
int g, idx = 0;
const int bits = (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) ? 3 : 5;
for (g = 0; g < ics->num_window_groups; g++) {
int k = 0;
while (k < ics->max_sfb) {
uint8_t sect_end = k;
int sect_len_incr;
int sect_band_type = get_bits(gb, 4);
if (sect_band_type == 12) {
av_log(ac->avctx, AV_LOG_ERROR, "invalid band type\n");
return -1;
}
do {
sect_len_incr = get_bits(gb, bits);
sect_end += sect_len_incr;
if (get_bits_left(gb) < 0) {
av_log(ac->avctx, AV_LOG_ERROR, overread_err);
return -1;
}
if (sect_end > ics->max_sfb) {
av_log(ac->avctx, AV_LOG_ERROR,
"Number of bands (%d) exceeds limit (%d).\n",
sect_end, ics->max_sfb);
return -1;
}
} while (sect_len_incr == (1 << bits) - 1);
for (; k < sect_end; k++) {
band_type [idx] = sect_band_type;
band_type_run_end[idx++] = sect_end;
}
}
}
return 0;
}
| 1threat
|
Stuck with this JavaScript function? No JQuery : I'm really stuck with this Script. I don't know how to solve my problem. I'm new to JavaScript. I can't use JQuery
The thing is, i have a table and i want to highlight the selected row on the onClick event, and at the same time i have to change the value of an input field, but for some reason when i first click the row the highlight effect gets stucked on that row, and also the value only changes after i click a row for the first time. It's really weird.
Here is the jsfiddle:
https://jsfiddle.net/n32d72ve/4/
And the JavaScript code:
var preEl ;
var orgBColor;
var orgTColor;
function HighLightTR(el, backColor,textColor){
if(typeof(preEl)!='undefined') {
preEl.bgColor=orgBColor;
try{ChangeTextColor(preEl,orgTColor);}catch(e){;}
}
orgBColor = el.bgColor;
orgTColor = el.style.color;
el.bgColor=backColor;
try{ChangeTextColor(el,textColor);}catch(e){;}
preEl = el;
addRowHandlers();
}
function ChangeTextColor(a_obj,a_color){ ;
for (i=0;i<a_obj.cells.length;i++)
a_obj.cells(i).style.color=a_color;
}
function addRowHandlers() {
var table = document.getElementById("table-organizaciones");
var rows = table.getElementsByTagName("tr");
for (i = 0; i < rows.length; i++) {
var currentRow = table.rows[i];
var createClickHandler =
function(row)
{
return function() {
var cell = row.getElementsByTagName("td")[3];
var id = cell.innerHTML;
alert("id:" + id);
document.getElementById('id_org').value = id;
};
};
currentRow.onclick = createClickHandler(currentRow);
}
}
The html:
<table id="table-organizaciones">
<thead>
<tr>
<th class="col-xs-4">Nombre</th><th class="col-xs-4">Razon social</th><th class="col-xs-4">Pais</th>
</tr>
</thead>
<tbody>
<tr onClick="HighLightTR(this,'#c9cc99','cc3333');">
<td class="col-xs-4">Lo que sea</td><td class="col-xs-4">Lo que sea </td><td class="col-xs-4">Colombia</td><td>maybe</td>
</tr>
<tr onClick="HighLightTR(this,'#c9cc99','cc3333');">
<td class="col-xs-4">Lo que sea</td><td class="col-xs-4">Lo que sea </td><td class="col-xs-4">Colombia</td><td>no</td>
</tr>
<tr onClick="HighLightTR(this,'#c9cc99','cc3333');">
<td class="col-xs-4">Lo que sea</td><td class="col-xs-4">Lo que sea </td><td class="col-xs-4">Colombia</td><td>yes</td>
</tr>
</tbody>
</table>
<input name="id" id="id_org" value="id">
| 0debug
|
int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset,
int bytes)
{
BdrvTrackedRequest req;
int max_pdiscard, ret;
int head, tail, align;
return -ENOMEDIUM;
if (bdrv_has_readonly_bitmaps(bs)) {
return -EPERM;
ret = bdrv_check_byte_request(bs, offset, bytes);
if (ret < 0) {
return ret;
} else if (bs->read_only) {
return -EPERM;
assert(!(bs->open_flags & BDRV_O_INACTIVE));
if (!(bs->open_flags & BDRV_O_UNMAP)) {
return 0;
if (!bs->drv->bdrv_co_pdiscard && !bs->drv->bdrv_aio_pdiscard) {
return 0;
align = MAX(bs->bl.pdiscard_alignment, bs->bl.request_alignment);
assert(align % bs->bl.request_alignment == 0);
head = offset % align;
tail = (offset + bytes) % align;
bdrv_inc_in_flight(bs);
tracked_request_begin(&req, bs, offset, bytes, BDRV_TRACKED_DISCARD);
ret = notifier_with_return_list_notify(&bs->before_write_notifiers, &req);
if (ret < 0) {
max_pdiscard = QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_pdiscard, INT_MAX),
align);
assert(max_pdiscard >= bs->bl.request_alignment);
while (bytes > 0) {
int num = bytes;
if (head) {
num = MIN(bytes, align - head);
if (!QEMU_IS_ALIGNED(num, bs->bl.request_alignment)) {
num %= bs->bl.request_alignment;
head = (head + num) % align;
assert(num < max_pdiscard);
} else if (tail) {
if (num > align) {
num -= tail;
} else if (!QEMU_IS_ALIGNED(tail, bs->bl.request_alignment) &&
tail > bs->bl.request_alignment) {
tail %= bs->bl.request_alignment;
num -= tail;
if (num > max_pdiscard) {
num = max_pdiscard;
if (bs->drv->bdrv_co_pdiscard) {
ret = bs->drv->bdrv_co_pdiscard(bs, offset, num);
} else {
BlockAIOCB *acb;
CoroutineIOCompletion co = {
.coroutine = qemu_coroutine_self(),
};
acb = bs->drv->bdrv_aio_pdiscard(bs, offset, num,
bdrv_co_io_em_complete, &co);
if (acb == NULL) {
ret = -EIO;
} else {
qemu_coroutine_yield();
ret = co.ret;
if (ret && ret != -ENOTSUP) {
offset += num;
bytes -= num;
ret = 0;
out:
atomic_inc(&bs->write_gen);
bdrv_set_dirty(bs, req.offset, req.bytes);
tracked_request_end(&req);
bdrv_dec_in_flight(bs);
return ret;
| 1threat
|
struct does not name a type : <p>I'm having a problem with a struct declaration. Any help would be appreciated. Code below.</p>
<pre><code> //in 8puzz.h
#include string
using namespace std;
struct state{
state();
int cval;
string board;
state* parent;
state* previous;
state* next;
};
state starter;
state* open;
state* closed;
string start;
//in 8puzz.cpp
#include "8puzz.h"
using namespace std;
state::state(){
board="";
cval=0;
parent=NULL;
previous=NULL;
next=NULL;
};
//in main.cpp
#include "8puzz.cpp"
using namespace std;
starter.cval=Heuristic(start);
open= &starter;
closed= &starter;
//end code
</code></pre>
<p>Heuristic() is a function that takes a string and returns an int. Will post if needed, but I believe it is irrelevant; replacing it with an int does not change the outcome.</p>
<p>The error I'm getting is "starter does not name a type." Same for "open" and "closed." I have seen other questions about this error, but all of those are for a struct inside a class and it seems the solution always has to do with qualifying the class and struct names. I don't think this can be the problem here since the struct is declared independently. I have tried many permutations; declaring everything inside 8puzz.cpp, with the constructor, without the constructor, constructor at the beginning of the struct declaration, constructor at the end, constructor defined with the definition, constructor defined separately. I've included this version because, based on everything I've read, I believe it follows best practices, but every version has given me the same error. Any help would be great. Thank you in advance! </p>
| 0debug
|
Detect when reCaptcha does not load : <p>What is the best way to detect if a reCaptcha v2 does not load? I would like to alert users when they need to use the captcha to continue, but it was unable to load.</p>
| 0debug
|
Which .net builtin functions use the params keyword? : <p>I am explaining the purpose and usage of the C# <code>params</code> (C++CLI <code>...array</code>) keyword to my colleague and wanted to show him some functions of .net that make use of it. But right know I don't remember any.</p>
<p>For those who want to answer: Feel free to list as many as you know. But I would be happy with one already.</p>
| 0debug
|
Need recommendations of an exception tracking system : <p>We need a recommendation for tracking exceptions in our web app. Our front-end is using Angular 1 or 2, back-end is using ColdFusion. We found <a href="https://bugsnag.com/" rel="nofollow">BugSnag</a>, but this company cannot do annual billing. </p>
<p>Does anyone know any other similar product?</p>
<p>Thanks a lot!</p>
| 0debug
|
deleting first node of linked list (C++) : i want to know whether this code deletes the first node correctly or should i necessarily pass list's head as a pointer?
void List::deleteFirst()
{
temp = head;
head = head->next;
delete temp;
}
this is the class List
class List
{
private:
struct node
{
int data;
node * next;
};
node * head;
node * curr;
node * temp;
public:
//List();
//void AddNode(int addData);
//void DeleteNode(int delData);
void deleteFirst();
//void PrintList();
};
| 0debug
|
DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
{
const char *buf;
const char *file = NULL;
char devname[128];
const char *serial;
const char *mediastr = "";
BlockInterfaceType type;
enum { MEDIA_DISK, MEDIA_CDROM } media;
int bus_id, unit_id;
int cyls, heads, secs, translation;
BlockDriver *drv = NULL;
int max_devs;
int index;
int ro = 0;
int bdrv_flags = 0;
int on_read_error, on_write_error;
const char *devaddr;
DriveInfo *dinfo;
int snapshot = 0;
int ret;
translation = BIOS_ATA_TRANSLATION_AUTO;
if (default_to_scsi) {
type = IF_SCSI;
pstrcpy(devname, sizeof(devname), "scsi");
} else {
type = IF_IDE;
pstrcpy(devname, sizeof(devname), "ide");
}
media = MEDIA_DISK;
bus_id = qemu_opt_get_number(opts, "bus", 0);
unit_id = qemu_opt_get_number(opts, "unit", -1);
index = qemu_opt_get_number(opts, "index", -1);
cyls = qemu_opt_get_number(opts, "cyls", 0);
heads = qemu_opt_get_number(opts, "heads", 0);
secs = qemu_opt_get_number(opts, "secs", 0);
snapshot = qemu_opt_get_bool(opts, "snapshot", 0);
ro = qemu_opt_get_bool(opts, "readonly", 0);
file = qemu_opt_get(opts, "file");
serial = qemu_opt_get(opts, "serial");
if ((buf = qemu_opt_get(opts, "if")) != NULL) {
pstrcpy(devname, sizeof(devname), buf);
for (type = 0; type < IF_COUNT && strcmp(buf, if_name[type]); type++)
;
if (type == IF_COUNT) {
error_report("unsupported bus type '%s'", buf);
return NULL;
}
}
max_devs = if_max_devs[type];
if (cyls || heads || secs) {
if (cyls < 1 || (type == IF_IDE && cyls > 16383)) {
error_report("invalid physical cyls number");
return NULL;
}
if (heads < 1 || (type == IF_IDE && heads > 16)) {
error_report("invalid physical heads number");
return NULL;
}
if (secs < 1 || (type == IF_IDE && secs > 63)) {
error_report("invalid physical secs number");
return NULL;
}
}
if ((buf = qemu_opt_get(opts, "trans")) != NULL) {
if (!cyls) {
error_report("'%s' trans must be used with cyls,heads and secs",
buf);
return NULL;
}
if (!strcmp(buf, "none"))
translation = BIOS_ATA_TRANSLATION_NONE;
else if (!strcmp(buf, "lba"))
translation = BIOS_ATA_TRANSLATION_LBA;
else if (!strcmp(buf, "auto"))
translation = BIOS_ATA_TRANSLATION_AUTO;
else {
error_report("'%s' invalid translation type", buf);
return NULL;
}
}
if ((buf = qemu_opt_get(opts, "media")) != NULL) {
if (!strcmp(buf, "disk")) {
media = MEDIA_DISK;
} else if (!strcmp(buf, "cdrom")) {
if (cyls || secs || heads) {
error_report("'%s' invalid physical CHS format", buf);
return NULL;
}
media = MEDIA_CDROM;
} else {
error_report("'%s' invalid media", buf);
return NULL;
}
}
if ((buf = qemu_opt_get(opts, "cache")) != NULL) {
if (!strcmp(buf, "off") || !strcmp(buf, "none")) {
bdrv_flags |= BDRV_O_NOCACHE;
} else if (!strcmp(buf, "writeback")) {
bdrv_flags |= BDRV_O_CACHE_WB;
} else if (!strcmp(buf, "unsafe")) {
bdrv_flags |= BDRV_O_CACHE_WB;
bdrv_flags |= BDRV_O_NO_FLUSH;
} else if (!strcmp(buf, "writethrough")) {
} else {
error_report("invalid cache option");
return NULL;
}
}
#ifdef CONFIG_LINUX_AIO
if ((buf = qemu_opt_get(opts, "aio")) != NULL) {
if (!strcmp(buf, "native")) {
bdrv_flags |= BDRV_O_NATIVE_AIO;
} else if (!strcmp(buf, "threads")) {
} else {
error_report("invalid aio option");
return NULL;
}
}
#endif
if ((buf = qemu_opt_get(opts, "format")) != NULL) {
if (strcmp(buf, "?") == 0) {
error_printf("Supported formats:");
bdrv_iterate_format(bdrv_format_print, NULL);
error_printf("\n");
return NULL;
}
drv = bdrv_find_whitelisted_format(buf);
if (!drv) {
error_report("'%s' invalid format", buf);
return NULL;
}
}
on_write_error = BLOCK_ERR_STOP_ENOSPC;
if ((buf = qemu_opt_get(opts, "werror")) != NULL) {
if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) {
error_report("werror is not supported by this bus type");
return NULL;
}
on_write_error = parse_block_error_action(buf, 0);
if (on_write_error < 0) {
return NULL;
}
}
on_read_error = BLOCK_ERR_REPORT;
if ((buf = qemu_opt_get(opts, "rerror")) != NULL) {
if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) {
error_report("rerror is not supported by this bus type");
return NULL;
}
on_read_error = parse_block_error_action(buf, 1);
if (on_read_error < 0) {
return NULL;
}
}
if ((devaddr = qemu_opt_get(opts, "addr")) != NULL) {
if (type != IF_VIRTIO) {
error_report("addr is not supported by this bus type");
return NULL;
}
}
if (index != -1) {
if (bus_id != 0 || unit_id != -1) {
error_report("index cannot be used with bus and unit");
return NULL;
}
bus_id = drive_index_to_bus_id(type, index);
unit_id = drive_index_to_unit_id(type, index);
}
if (unit_id == -1) {
unit_id = 0;
while (drive_get(type, bus_id, unit_id) != NULL) {
unit_id++;
if (max_devs && unit_id >= max_devs) {
unit_id -= max_devs;
bus_id++;
}
}
}
if (max_devs && unit_id >= max_devs) {
error_report("unit %d too big (max is %d)",
unit_id, max_devs - 1);
return NULL;
}
if (drive_get(type, bus_id, unit_id) != NULL) {
error_report("drive with bus=%d, unit=%d (index=%d) exists",
bus_id, unit_id, index);
return NULL;
}
dinfo = qemu_mallocz(sizeof(*dinfo));
if ((buf = qemu_opts_id(opts)) != NULL) {
dinfo->id = qemu_strdup(buf);
} else {
dinfo->id = qemu_mallocz(32);
if (type == IF_IDE || type == IF_SCSI)
mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd";
if (max_devs)
snprintf(dinfo->id, 32, "%s%i%s%i",
devname, bus_id, mediastr, unit_id);
else
snprintf(dinfo->id, 32, "%s%s%i",
devname, mediastr, unit_id);
}
dinfo->bdrv = bdrv_new(dinfo->id);
dinfo->devaddr = devaddr;
dinfo->type = type;
dinfo->bus = bus_id;
dinfo->unit = unit_id;
dinfo->opts = opts;
dinfo->refcount = 1;
if (serial)
strncpy(dinfo->serial, serial, sizeof(dinfo->serial) - 1);
QTAILQ_INSERT_TAIL(&drives, dinfo, next);
bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error);
switch(type) {
case IF_IDE:
case IF_SCSI:
case IF_XEN:
case IF_NONE:
switch(media) {
case MEDIA_DISK:
if (cyls != 0) {
bdrv_set_geometry_hint(dinfo->bdrv, cyls, heads, secs);
bdrv_set_translation_hint(dinfo->bdrv, translation);
}
break;
case MEDIA_CDROM:
bdrv_set_removable(dinfo->bdrv, 1);
dinfo->media_cd = 1;
break;
}
break;
case IF_SD:
case IF_FLOPPY:
bdrv_set_removable(dinfo->bdrv, 1);
break;
case IF_PFLASH:
case IF_MTD:
break;
case IF_VIRTIO:
opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
qemu_opt_set(opts, "driver", "virtio-blk");
qemu_opt_set(opts, "drive", dinfo->id);
if (devaddr)
qemu_opt_set(opts, "addr", devaddr);
break;
default:
abort();
}
if (!file || !*file) {
return dinfo;
}
if (snapshot) {
bdrv_flags &= ~BDRV_O_CACHE_MASK;
bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH);
}
if (media == MEDIA_CDROM) {
ro = 1;
} else if (ro == 1) {
if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY && type != IF_NONE) {
error_report("readonly not supported by this bus type");
goto err;
}
}
bdrv_flags |= ro ? 0 : BDRV_O_RDWR;
ret = bdrv_open(dinfo->bdrv, file, bdrv_flags, drv);
if (ret < 0) {
error_report("could not open disk image %s: %s",
file, strerror(-ret));
goto err;
}
if (bdrv_key_required(dinfo->bdrv))
autostart = 0;
return dinfo;
err:
bdrv_delete(dinfo->bdrv);
qemu_free(dinfo->id);
QTAILQ_REMOVE(&drives, dinfo, next);
qemu_free(dinfo);
return NULL;
}
| 1threat
|
Get the next row of a dataframe in r programming : I am working on a r programming project..
I have a dataframe (df) with about 790 observations in. I am trying to extract certain rows from the dataframe. The only simularity with the row i am trying to extract with the row above, which are all named S_NAME:
<LI>1 cat </li>
<li>2 hat </li>
<li>3 S_NAME </li>
<li>4 tin </li>
<li>5 sin </li>
<li>6 S_NAME </li>
<li>7 foo </li>
<li>8 sin </li>
<li>9 S_NAME </li>
<li>10 tinn </li>
So for example, I would want to extract row 4,7 and 10 which all follow S_NAME
I am unsure of how to do this, any help will be great thanks. I know i have tagged python, although that code might help me understand.
Thanks
| 0debug
|
static bool net_tx_pkt_do_sw_fragmentation(struct NetTxPkt *pkt,
NetClientState *nc)
{
struct iovec fragment[NET_MAX_FRAG_SG_LIST];
size_t fragment_len = 0;
bool more_frags = false;
void *l2_iov_base, *l3_iov_base;
size_t l2_iov_len, l3_iov_len;
int src_idx = NET_TX_PKT_PL_START_FRAG, dst_idx;
size_t src_offset = 0;
size_t fragment_offset = 0;
l2_iov_base = pkt->vec[NET_TX_PKT_L2HDR_FRAG].iov_base;
l2_iov_len = pkt->vec[NET_TX_PKT_L2HDR_FRAG].iov_len;
l3_iov_base = pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base;
l3_iov_len = pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_len;
fragment[NET_TX_PKT_FRAGMENT_L2_HDR_POS].iov_base = l2_iov_base;
fragment[NET_TX_PKT_FRAGMENT_L2_HDR_POS].iov_len = l2_iov_len;
fragment[NET_TX_PKT_FRAGMENT_L3_HDR_POS].iov_base = l3_iov_base;
fragment[NET_TX_PKT_FRAGMENT_L3_HDR_POS].iov_len = l3_iov_len;
do {
fragment_len = net_tx_pkt_fetch_fragment(pkt, &src_idx, &src_offset,
fragment, &dst_idx);
more_frags = (fragment_offset + fragment_len < pkt->payload_len);
eth_setup_ip4_fragmentation(l2_iov_base, l2_iov_len, l3_iov_base,
l3_iov_len, fragment_len, fragment_offset, more_frags);
eth_fix_ip4_checksum(l3_iov_base, l3_iov_len);
net_tx_pkt_sendv(pkt, nc, fragment, dst_idx);
fragment_offset += fragment_len;
} while (more_frags);
return true;
}
| 1threat
|
static void data_plane_blk_insert_notifier(Notifier *n, void *data)
{
VirtIOBlockDataPlane *s = container_of(n, VirtIOBlockDataPlane,
insert_notifier);
assert(s->conf->conf.blk == data);
data_plane_set_up_op_blockers(s);
}
| 1threat
|
static void raw_aio_remove(RawAIOCB *acb)
{
RawAIOCB **pacb;
pacb = &posix_aio_state->first_aio;
for(;;) {
if (*pacb == NULL) {
fprintf(stderr, "raw_aio_remove: aio request not found!\n");
break;
} else if (*pacb == acb) {
*pacb = acb->next;
qemu_aio_release(acb);
break;
}
pacb = &(*pacb)->next;
}
}
| 1threat
|
How to find the executation time of code in C? : I found this code [here][1]. If i divite `(t2-t1)/CLOCK_PER_SEC`will i get time in seconds? How to I find CLOCK_PER_SEC? Is there any better way to find the executation time of a code or a function?
#include<time.h>
main()
{
clock_t t1=clock();
// Your code that takes more than 1 sec;
clock_t t2=clock();
printf("The time taken is.. %g ", (t2-t1));
[1]: http://stackoverflow.com/questions/13171846/c-program-measure-execution-time-for-an-instruction
| 0debug
|
void ff_h264_remove_all_refs(H264Context *h)
{
int i;
for (i = 0; i < 16; i++) {
remove_long(h, i, 0);
}
assert(h->long_ref_count == 0);
if (h->short_ref_count && !h->last_pic_for_ec.f->data[0]) {
ff_h264_unref_picture(h, &h->last_pic_for_ec);
if (h->short_ref[0]->f->buf[0])
ff_h264_ref_picture(h, &h->last_pic_for_ec, h->short_ref[0]);
}
for (i = 0; i < h->short_ref_count; i++) {
unreference_pic(h, h->short_ref[i], 0);
h->short_ref[i] = NULL;
}
h->short_ref_count = 0;
memset(h->default_ref, 0, sizeof(h->default_ref));
}
| 1threat
|
How to access the getter from another vuex module? : <p>Within a vuex getter I know it is possible to access the state from another vuex module like so:</p>
<pre><code>pages: (state, getters, rootState) => {
console.log(rootState);
}
</code></pre>
<p>How can I access a getter from another vuex module instead of the state though? </p>
<p>I have another vuex module called <strong>filters</strong> that I need to access, I have tried this:</p>
<pre><code>rootState.filters.activeFilters
</code></pre>
<p>Where <code>activeFilters</code> is my getter but this does not work. using <code>rootState.filters.getters.activeFilters</code> also does not work.</p>
| 0debug
|
static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
DCAEncContext *c = avctx->priv_data;
const int32_t *samples;
int ret, i;
if ((ret = ff_alloc_packet2(avctx, avpkt, c->frame_size , 0)) < 0)
return ret;
samples = (const int32_t *)frame->data[0];
subband_transform(c, samples);
if (c->lfe_channel)
lfe_downsample(c, samples);
calc_masking(c, samples);
find_peaks(c);
assign_bits(c);
calc_scales(c);
quantize_all(c);
shift_history(c, samples);
init_put_bits(&c->pb, avpkt->data, avpkt->size);
put_frame_header(c);
put_primary_audio_header(c);
for (i = 0; i < SUBFRAMES; i++)
put_subframe(c, i);
flush_put_bits(&c->pb);
avpkt->pts = frame->pts;
avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples);
avpkt->size = c->frame_size + 1;
*got_packet_ptr = 1;
return 0;
}
| 1threat
|
void xen_invalidate_map_cache_entry(uint8_t *buffer)
{
MapCacheEntry *entry = NULL, *pentry = NULL;
MapCacheRev *reventry;
target_phys_addr_t paddr_index;
target_phys_addr_t size;
int found = 0;
if (mapcache->last_address_vaddr == buffer) {
mapcache->last_address_index = -1;
}
QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) {
if (reventry->vaddr_req == buffer) {
paddr_index = reventry->paddr_index;
size = reventry->size;
found = 1;
break;
}
}
if (!found) {
DPRINTF("%s, could not find %p\n", __func__, buffer);
QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) {
DPRINTF(" "TARGET_FMT_plx" -> %p is present\n", reventry->paddr_index, reventry->vaddr_req);
}
return;
}
QTAILQ_REMOVE(&mapcache->locked_entries, reventry, next);
g_free(reventry);
entry = &mapcache->entry[paddr_index % mapcache->nr_buckets];
while (entry && (entry->paddr_index != paddr_index || entry->size != size)) {
pentry = entry;
entry = entry->next;
}
if (!entry) {
DPRINTF("Trying to unmap address %p that is not in the mapcache!\n", buffer);
return;
}
entry->lock--;
if (entry->lock > 0 || pentry == NULL) {
return;
}
pentry->next = entry->next;
if (munmap(entry->vaddr_base, entry->size) != 0) {
perror("unmap fails");
exit(-1);
}
g_free(entry->valid_mapping);
g_free(entry);
}
| 1threat
|
TypeError: an integer is required (got type tuple)? : <p>This code was working few days ago. But now getting typeerror </p>
<p>CODE: </p>
<pre><code>import cv2
import numpy as np
import pytesseract
from langdetect import detect_langs
from pytesseract import *
from flask import Flask,request
import requests
try:
from PIL import Image
except ImportError:
import Image
#pytesseract.pytesseract.tesseract_cmd = 'C:/Program Files/Tesseract-OCR/tesseract.exe'
img = Image.open('G:/Agrima/example_code_API/OCR/FDA.png')
#h, w, c = img.shape
d = pytesseract.image_to_data(img,output_type=Output.DICT)
detected_ocr = image_to_string(img)
points = []
n_boxes = len(d['text'])
for i in range(n_boxes):
if int(d['conf'][i]) > 60:
(x, y, w, h) = (d['left'][i], d['top'][i], d['width'][i],d['height'][i])
img = cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)
mark = {'x':x,'y':y,'width':w,'height':h}
points.append({'mark':mark})
# print(points)
cv2.imshow('img', img)
cv2.waitKey(0)
</code></pre>
<p>Error in <code>img = cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)</code></p>
<p>Also tried changing to <code>img = cv2.rectangle(img, int((x, y)), int((x + w, y + h)), (0, 255, 0), 2)</code></p>
<p>Error log : </p>
<blockquote>
<p>img = cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)
TypeError: an integer is required (got type tuple)</p>
</blockquote>
| 0debug
|
how to store xml tag values in database using java : I have written a code to read an xml file without specifying tagnames. I have used getElementBytagname(*) which reads every tag and give me output. But now i want to insert those tag values in database columns. For eg. Suppose i have a tagname <merchantId>101</merchantId> this value need to be stored in database column name as merchantId. Can somebody please help me out?
| 0debug
|
(C++) Passing a vector of objects to a constructor : <pre><code>class A {
public:
int value;
A(int value){
this->value = value;
}
};
class Relation{
vector<A> items;
Relation(vector<A> items){
this->items = items;
}
}
int main(){
vector<A> items;
items.push_back(A(1));
Relation r1(items);
}
</code></pre>
<p>How do I pass a vector of my new object to a constructor of another object? In line 13, I get an error "no matching function for call to 'A::A()' "</p>
| 0debug
|
i need proper mysql query to fetch record from mysql : i have THREE tables.
Table : products column : id, productname
Table :attribute_master column : id, attributename
Table : assignedproductfilter column : id productid <-- this is from products table filterid <-- this is from attribute_master
table "assignedproductfilter" may contain same productid with multiple filterid.
Example :
id productid filterid
1 105 56
2 105 50
3 105 34
4 200 56
5 201 22
Now suppose i want to get all those products where filterid is 56,50 and 34. All these three filter id should be assigned to products.
How to write query for this in mysql ?
| 0debug
|
In the expression left() = right(), why is right() sequenced first? : <p>In C++, the expression <code>left() = right()</code> evaluates</p>
<ol>
<li><code>right()</code></li>
<li><code>left()</code></li>
</ol>
<p>in that sequence. The <code>right()</code> goes first, as has been discussed <a href="https://stackoverflow.com/q/52762511/1275653">here.</a></p>
<p>I cannot think of a reason for <code>right()</code> to go first. Can you? I presume that there exists a reason. Otherwise, the standard would hardly say what it says, but consider: <code>right()</code> will return some result. At the machine-code level, does the CPU not need to know where to put the result <code>right()</code> will return before asking <code>right()</code> to return it?</p>
<p>If you happen to know what the standard committee was thinking (because you were in the room or have read the memo), that's great: I'd like to read your answer. However, my actual question is more modest. All I want to know is whether there exists a plausible reason and what that reason might be.</p>
| 0debug
|
static int afx_init1(SysBusDevice *dev)
{
AFXState *s = TCX_AFX(dev);
memory_region_init_ram(&s->mem, OBJECT(s), "sun4m.afx", 4, &error_abort);
vmstate_register_ram_global(&s->mem);
sysbus_init_mmio(dev, &s->mem);
return 0;
}
| 1threat
|
static void qpci_pc_config_writel(QPCIBus *bus, int devfn, uint8_t offset, uint32_t value)
{
outl(0xcf8, (1 << 31) | (devfn << 8) | offset);
outl(0xcfc, value);
}
| 1threat
|
confusion in if else logic condition in c# :
if (filesxt.Extension.ToString()==".rar")
{
NUnrar.Archive.RarArchive.WriteToDirectory(Sourcepath, Destination, NUnrar.Common.ExtractOptions.ExtractFullPath | NUnrar.Common.ExtractOptions.Overwrite);
}
else if (filesxt.Extension.ToString() == ".zip")
{
UnZipFromMTAThread(Sourcepath, Destination);
}
but if it is .rar and the above method gives error then it should perform this method
ExtractFile(Sourcepath, Destination);
What would be the logic? Can anyone help?
Thanks
| 0debug
|
jQuery erroring when using .split : I am trying to split this string down into sections:
2 h 3 12 s
From this I am trying to create a longer string such as:
00020312
DDHHMMSS
I am getting an error on line 3:
Cannot read property split of undefined
```
if(hasHours[1] === undefined){
var downTimeH = downTime.split(" h")[0];
downTime = downTime.split(" h ")[1];
if(downTimeH <=9){
downTimeH = downTimeH.toString(downTimeD);
downTimeH = '0' + downTimeH;
};
}
```
| 0debug
|
yuv2mono_2_c_template(SwsContext *c, const uint16_t *buf0,
const uint16_t *buf1, const uint16_t *ubuf0,
const uint16_t *ubuf1, const uint16_t *vbuf0,
const uint16_t *vbuf1, const uint16_t *abuf0,
const uint16_t *abuf1, uint8_t *dest, int dstW,
int yalpha, int uvalpha, int y,
enum PixelFormat target)
{
const uint8_t * const d128 = dither_8x8_220[y & 7];
uint8_t *g = c->table_gU[128] + c->table_gV[128];
int yalpha1 = 4095 - yalpha;
int i;
for (i = 0; i < dstW - 7; i += 8) {
int acc = g[((buf0[i ] * yalpha1 + buf1[i ] * yalpha) >> 19) + d128[0]];
acc += acc + g[((buf0[i + 1] * yalpha1 + buf1[i + 1] * yalpha) >> 19) + d128[1]];
acc += acc + g[((buf0[i + 2] * yalpha1 + buf1[i + 2] * yalpha) >> 19) + d128[2]];
acc += acc + g[((buf0[i + 3] * yalpha1 + buf1[i + 3] * yalpha) >> 19) + d128[3]];
acc += acc + g[((buf0[i + 4] * yalpha1 + buf1[i + 4] * yalpha) >> 19) + d128[4]];
acc += acc + g[((buf0[i + 5] * yalpha1 + buf1[i + 5] * yalpha) >> 19) + d128[5]];
acc += acc + g[((buf0[i + 6] * yalpha1 + buf1[i + 6] * yalpha) >> 19) + d128[6]];
acc += acc + g[((buf0[i + 7] * yalpha1 + buf1[i + 7] * yalpha) >> 19) + d128[7]];
output_pixel(*dest++, acc);
}
}
| 1threat
|
def max_volume (s):
maxvalue = 0
i = 1
for i in range(s - 1):
j = 1
for j in range(s):
k = s - i - j
maxvalue = max(maxvalue, i * j * k)
return maxvalue
| 0debug
|
filter unique values conditional on groups : I have the following table:
`id L1 L2
1 A B
1 A C
1 A D
1 B B
1 B C
1 B D
2 D A
2 D F`
I want to filter out any L2 value that's in L1, but only within same id group. So for id=1, we filter out L2=B, but keep L2=D. For id=2, we keep L2=A.
Output should be like:
`id L1 L2
1 A C
1 A D
1 B C
1 B D
2 D A
2 D F`
| 0debug
|
Possible to use Php's mail() function to send 1 million plus mails? : <p>I was wondering if it would be feasible to send over 1 million emails (stored in an array or some sql database) using php's mail function. Is this farfetched. I'm new to php and curious of the function's limitations. Thank you so much! I'm not looking to necessarily use a SMTP service like MailChimp at this point.</p>
| 0debug
|
static void special_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
qemu_log("pci: special write cycle");
}
| 1threat
|
python calling funcion to another funcion : this is simplified example of my problem. I need to use variable which i created in first definition in another definition, but putting global before variable dont work. Please can you help me ?
x = 10
def one():
global x
a = x +2
b = a/2
print (b)
def two():
one()
c = int(input())
def three() :
global a
global c
d = c + a
print(b)
two()
three()
| 0debug
|
Using Malloc() to create an integer array using pointer : <p>I'm trying to create an integer array using the defined ADT below using the malloc() function. I want it to return a pointer to a newly allocated integer array of type intarr_t. If it doesn't work - I want it to return a null pointer. </p>
<p>This is what I have so far - </p>
<pre><code>//The ADT structure
typedef struct {
int* data;
unsigned int len;
} intarr_t;
//the function
intarr_t* intarr_create( unsigned int len ){
intarr_t* ia = malloc(sizeof(intarr_t)*len);
if (ia == 0 )
{
printf( "Warning: failed to allocate memory for an image structure\n" );
return 0;
}
return ia;
}
</code></pre>
<p>The test from our system is giving me this error </p>
<pre><code>intarr_create(): null pointer in the structure's data field
stderr
(empty)
</code></pre>
<p>Where abouts have I gone wrong here?</p>
| 0debug
|
static void init_proc_970MP (CPUPPCState *env)
{
gen_spr_ne_601(env);
gen_spr_7xx(env);
gen_tbl(env);
spr_register(env, SPR_HID0, "HID0",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_clear,
0x60000000);
spr_register(env, SPR_HID1, "HID1",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_750_HID2, "HID2",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_970_HID5, "HID5",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
POWERPC970_HID5_INIT);
gen_low_BATs(env);
spr_register(env, SPR_MMUCFG, "MMUCFG",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, SPR_NOACCESS,
0x00000000);
spr_register(env, SPR_MMUCSR0, "MMUCSR0",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_HIOR, "SPR_HIOR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0xFFF00000);
#if !defined(CONFIG_USER_ONLY)
env->excp_prefix = 0xFFF00000;
#endif
#if !defined(CONFIG_USER_ONLY)
env->slb_nr = 32;
#endif
init_excp_970(env);
env->dcache_line_size = 128;
env->icache_line_size = 128;
ppc970_irq_init(env);
}
| 1threat
|
Docker php-fpm/nginx set-up: php-fpm throwing blank 500, no error logs : <p>Git repo of project: <a href="https://github.com/tombusby/docker-laravel-experiments" rel="noreferrer">https://github.com/tombusby/docker-laravel-experiments</a> (HEAD at time of writing is 823fd22).</p>
<p>Here is my docker-compose.yml:</p>
<pre><code>nginx:
image: nginx:stable
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
volumes_from:
- php
links:
- php:php
ports:
- 80:80
php:
image: php:5.6-fpm
volumes:
- ./src:/var/www/html
expose:
- 9000
</code></pre>
<p>Into src/ I've created a fresh laravel project. This all functions correctly if I swap out index.php for one with a basic <code>echo "hello world";</code> and if I use <code>echo "called";exit();</code> I can identify that part of laravel's index.php does get executed.</p>
<p>It dies at line 53:</p>
<pre><code>$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
</code></pre>
<p>I have no idea why this happens, and I've tried using <code>docker exec -it <cid> bash</code> to have a look around my php-fpm container for error logs. All the logs are redirected to stderr/stdout (which is collected by docker).</p>
<p>Here is the output that docker collects:</p>
<pre><code>php_1 | 172.17.0.3 - 06/May/2016:12:09:34 +0000 "GET /index.php" 500
nginx_1 | 192.168.99.1 - - [06/May/2016:12:09:34 +0000] "GET /index.php HTTP/1.1" 500 5 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36" "-"
</code></pre>
<p>As you can see "500" does pretty much nothing to help me work out why there was an error, but I can't find any way of getting the stack trace or anything like the proper error logs that apache's php extension would have produced.</p>
| 0debug
|
I need to know why the follwing MySQL is not giving me the Stings I AES_ENCRYPTed : Here's the Schema for MySQL:
CREATE TABLE prevent(
remoteAddr TINYBLOB NOT NULL,
logTime TINYBLOB NOT NULL
)ENGINE=InnoDB;
INSERT prevent VALUES (
AES_ENCRYPT('just a lame test','Wt@F4z5u#r'),
AES_ENCRYPT(NOW(),'b$Do^rK32C')
);
Now the Simple query:
SELECT AES_DECRYPT(remoteAddr,'Wt@F4z5u#r') remoteAddr,
AES_DECRYPT(logTime,'Wt@F4z5u#r') logTime FROM prevent;
But look at the results here: http://sqlfiddle.com/#!9/3c507a/2
My question is, why are those AES_DECRYPT values not the same as the Strings I INSERTed?
| 0debug
|
JavaScript:nodeJS: how to get result data from an async method inside a non-async method : i had read several posting,and even some guide in google and tried. however its not solving my problem.
please kindly help me get through this.
lets get into the code :
i would need to be able to print the result data in line 12 at least
but currently it return me null
and if possible, could i get my result in line 15?
var serialport = require('serialport');
var i=0;
processGpsData();
function processGpsData() {
getData().then(result => {
console.log("result: "+result); //<<<<line 12
});
// await getData(i);
console.log(result);// line 15
console.log("done");
process.exit();
}
async function getData(){
var port = new serialport("/dev/ttyACM0",{baudRate: 9600});
port.on('open', function () {
process.stdin.resume();
process.stdin.setEncoding('utf8');
});
port.on('error', function (err) {
console.error(err);
process.exit(1);
});
var test="";
var counter=0;
port.on("data",function(data){
counter++;
test +=data;
if(counter>30){
console.log("test1: "+test);
// return test; //need return this, but not working
port.close();
// resolve(test);
return test;
}
});
// return new Promise(resolve => port.on("close", resolve));
}
| 0debug
|
static void ict_int(void *_src0, void *_src1, void *_src2, int csize)
{
int32_t *src0 = _src0, *src1 = _src1, *src2 = _src2;
int32_t i0, i1, i2;
int i;
for (i = 0; i < csize; i++) {
i0 = *src0 + (((i_ict_params[0] * *src2) + (1 << 15)) >> 16);
i1 = *src0 - (((i_ict_params[1] * *src1) + (1 << 15)) >> 16)
- (((i_ict_params[2] * *src2) + (1 << 15)) >> 16);
i2 = *src0 + (((i_ict_params[3] * *src1) + (1 << 15)) >> 16);
*src0++ = i0;
*src1++ = i1;
*src2++ = i2;
}
}
| 1threat
|
how can i make asp.net serialize dateTime into number of ticks in asp.net / newtonsoft.json? : In my ASP.NET web service I need all my dates to be serialized to JSON as numbers which represent a number of milliseconds passed since 1970 please. I'm using Newtonsoft.Json serializer. What do I need to do to set it up this way?
| 0debug
|
Broadcast a dictionary to rdd in PySpark : <p>I am just getting the hang of Spark, and I have function that needs to be mapped to an <code>rdd</code>, but uses a global dictionary:</p>
<pre><code>from pyspark import SparkContext
sc = SparkContext('local[*]', 'pyspark')
my_dict = {"a": 1, "b": 2, "c": 3, "d": 4} # at no point will be modified
my_list = ["a", "d", "c", "b"]
def my_func(letter):
return my_dict[letter]
my_list_rdd = sc.parallelize(my_list)
result = my_list_rdd.map(lambda x: my_func(x)).collect()
print result
</code></pre>
<p>The above gives the expected result; however, I am really not sure about my use of the global variable <code>my_dict</code>. It seems that a copy of the dictionary is made with every partition. And it just does not feel right..</p>
<p>It looked like <a href="http://spark.apache.org/docs/latest/programming-guide.html#broadcast-variables">broadcast</a> is what I am looking for. However, when I try to use it:</p>
<pre><code>my_dict_bc = sc.broadcast(my_dict)
def my_func(letter):
return my_dict_bc[letter]
</code></pre>
<p>I get the following error:</p>
<pre><code>TypeError: 'Broadcast' object has no attribute '__getitem__
</code></pre>
<p>This seems to imply that I cannot broadcast a dictionary.</p>
<p>My question: If I have a function that uses a global dictionary, that needs to be mapped to <code>rdd</code>, what is the proper way to do it?</p>
<p>My example is very simple, but in reality <code>my_dict</code> and <code>my_list</code> are much larger, and <code>my_func</code> is more complicated.</p>
| 0debug
|
Join Lines Matching + Sign, Number of lines with plus sign will differ. : <p>I having the following output and i want to join the lines which is having plus sign. Number of lines with plus sign will differ. I wanted to achieve this in Linux using sed or awk or any other tool. </p>
<p>From</p>
<pre><code>----------------------------------
lab-test
0193 +
8000 +
0126 +
----------------------------------
prod-test
0295 +
13000 +
0869 +
0118 +
----------------------------------
</code></pre>
<p>Change it to</p>
<pre><code>----------------------------------
lab-test
0193 + 8000 + 0126 +
----------------------------------
prod-test
0295 + 13000 + 0869 + 0118 +
----------------------------------
</code></pre>
| 0debug
|
ASP.NET Core Identity 2.2: How to expose the users in my classes (model), or list all in my views? : I would like to expose the users in my classes (model) in order to assign an action to a user that I can select from the list of users.
> public abstract class Issue
{
public Guid IssueId { get; set; }
public IssueType IssueType { get; set; }
public string Code { get; set; }
public string Comments { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDatePrevision { get; set; }
public bool IsExtrajudicial { get; set; }
public IEnumerable<Action> Actions { get; set; }
}
I want to have a reference of users or list of users inside this class.
| 0debug
|
static void vt82c686b_init_ports(PCIIDEState *d) {
int i;
struct {
int iobase;
int iobase2;
int isairq;
} port_info[] = {
{0x1f0, 0x3f6, 14},
{0x170, 0x376, 15},
};
for (i = 0; i < 2; i++) {
ide_bus_new(&d->bus[i], &d->dev.qdev, i);
ide_init_ioport(&d->bus[i], port_info[i].iobase, port_info[i].iobase2);
ide_init2(&d->bus[i], isa_reserve_irq(port_info[i].isairq));
bmdma_init(&d->bus[i], &d->bmdma[i]);
d->bmdma[i].bus = &d->bus[i];
qemu_add_vm_change_state_handler(d->bus[i].dma->ops->restart_cb,
&d->bmdma[i].dma);
}
}
| 1threat
|
Write xml with c# ? : I create a form so I use textbox and I would like when I push the button "send" he filled xml :
for exemple 1 time :
<?xml version="1.0" encoding="utf-8"?>
<DonneesLocale>
<Donnee>
<id>1</id>
<libelle>bla </libelle>
<email_asso>bla@</email_asso>
<login>bla</login>
<psw>bla</psw>
<site>bla</site>
<description>bla</description>
<data_1_lib></data_1_lib>
<data_1_val></data_1_val>
<data_2_lib></data_2_lib>
<data_2_val></data_2_val>
</Donnee>
</DonneesLocale>
and 2nd time when I push the button:
<?xml version="1.0" encoding="utf-8"?>
<DonneesLocale>
<Donnee>
<id>1</id>
<libelle>bla </libelle>
<email_asso>bla@</email_asso>
<login>bla</login>
<psw>bla</psw>
<site>bla</site>
<description>bla</description>
<data_1_lib></data_1_lib>
<data_1_val></data_1_val>
<data_2_lib></data_2_lib>
<data_2_val></data_2_val>
</Donnee>
<DonneesLocale>
<Donnee>
<id>2</id>
<libelle>hello</libelle>
<email_asso>hello@</email_asso>
<login>hello</login>
<psw>hello</psw>
<site>hello</site>
<description>hello</description>
<data_1_lib></data_1_lib>
<data_1_val></data_1_val>
<data_2_lib></data_2_lib>
<data_2_val></data_2_val>
</Donnee>
</DonneesLocale>
Someone can help me please ?
(Sorry for my English !)
Thanks !
| 0debug
|
static FILE *probe_splashfile(char *filename, int *file_sizep, int *file_typep)
{
FILE *fp = NULL;
int fop_ret;
int file_size;
int file_type = -1;
unsigned char buf[2] = {0, 0};
unsigned int filehead_value = 0;
int bmp_bpp;
fp = fopen(filename, "rb");
if (fp == NULL) {
error_report("failed to open file '%s'.", filename);
fseek(fp, 0L, SEEK_END);
file_size = ftell(fp);
if (file_size < 2) {
error_report("file size is less than 2 bytes '%s'.", filename);
fseek(fp, 0L, SEEK_SET);
fop_ret = fread(buf, 1, 2, fp);
filehead_value = (buf[0] + (buf[1] << 8)) & 0xffff;
if (filehead_value == 0xd8ff) {
file_type = JPG_FILE;
} else {
if (filehead_value == 0x4d42) {
file_type = BMP_FILE;
if (file_type < 0) {
error_report("'%s' not jpg/bmp file,head:0x%x.",
filename, filehead_value);
if (file_type == BMP_FILE) {
fseek(fp, 28, SEEK_SET);
fop_ret = fread(buf, 1, 2, fp);
bmp_bpp = (buf[0] + (buf[1] << 8)) & 0xffff;
if (bmp_bpp != 24) {
error_report("only 24bpp bmp file is supported.");
*file_sizep = file_size;
*file_typep = file_type;
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.