problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
void qemu_fclose(QEMUFile *f)
{
if (f->is_writable)
qemu_fflush(f);
if (f->is_file) {
fclose(f->outfile);
}
qemu_free(f);
}
| 1threat |
Split a cell into two rows while duplicating the rest of the data? : <p>I'm pulling data from our database to send out to a 3rd party according to their template. I need to send guardian information, with each person having their own row. Our database has the guardian information with a "/" and then details by each ID #. I need to split the data according to the Guardian cell while duplicating everything else. </p>
<p><a href="https://i.stack.imgur.com/9xfkZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9xfkZ.jpg" alt="enter image description here"></a></p>
<p>Can this be done in Excel without any special add ons? All help is appreciated. </p>
| 0debug |
Convert hexString to base64 : byte[] ba = Encoding.Default.GetBytes(input);
var hexString = BitConverter.ToString(ba);
hexString = hexString.Replace("-", "");
Console.WriteLine("Or: " + hexString + " in hexadecimal");
So i got this, now how would i convert hexString to a base64 string? i tried [this][1], got "Cannot convert from string to byte[]". If that solution works for anyone else, what am i doing wrong?
[1]: https://stackoverflow.com/questions/7784345/conversion-between-base64string-and-hexadecimal | 0debug |
Using Jupyter notebook for Java : <p>I've used the Jupyter notebook quite a lot for my Python projects, but now I have to work on something in Java. So I was wondering if I could get Jupyter to work with Java?</p>
<p>After some searching I think I understand that you can install different kernels for other languages, with a list of kernels <a href="https://github.com/ipython/ipython/wiki/IPython-kernels-for-other-languages" rel="noreferrer">here.</a> But I don't see one for Java there. The reason I think there is a working solution is <a href="https://athena.brynmawr.edu/jupyter/hub/dblank/public/CS206%20Data%20Structures/2016-Spring/Notebooks/IntroToJava.ipynb" rel="noreferrer">this notebook</a>, showing of a Java 9 notebook. Does anyone know how to set this up?</p>
<p>I'm on macOS Sierra if it matters. </p>
| 0debug |
Making a unique extension id and key for Chrome extension? : <p>I have a Chrome extension I made, but based it on some example found online. Its not in a crx file. The extension ID is the one used in the example. I would like to change it before I upload my extension to the chrome store. My question is how do I change this? Do I just manually change the letters in my manifest.json file? Or does the extension id have to be generated from something because its in a fixed format? Same for the key, can I just randomly change these two before I do anything else now that I'm ready?</p>
<pre><code>{
// Extension ID: rnldjzfmornpzlahmmmgbagdohdnhdic
"key": "MIGfMA3GCSqGSIb3DFEBAQUAA4GNADCBiQKBgQDcBHwzDvyBQ6bDppkIs9MP4ksKqCMyXQ/A52JivHZKh4YO/9vJsT3oaZhSpDCE9RCocOEQvwsHsFReW2nUEc6OLLyoCFFxIb7KkLGsmfakkut/fFdNJYh0xOTbSN8YvLWcqph09XAY2Y/f0AL7vfO1cuCqtkMt8hFrBGWxDdf9CQIDAQAB",
"name": "Name of extension",
...
</code></pre>
| 0debug |
static int ac3_encode_frame(AVCodecContext *avctx, unsigned char *frame,
int buf_size, void *data)
{
AC3EncodeContext *s = avctx->priv_data;
const SampleType *samples = data;
int ret;
if (s->bit_alloc.sr_code == 1)
adjust_frame_size(s);
deinterleave_input_samples(s, samples);
apply_mdct(s);
compute_rematrixing_strategy(s);
scale_coefficients(s);
apply_rematrixing(s);
process_exponents(s);
ret = compute_bit_allocation(s);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "Bit allocation failed. Try increasing the bitrate.\n");
return ret;
}
quantize_mantissas(s);
output_frame(s, frame);
return s->frame_size;
}
| 1threat |
how to pass an intent from fragment class to a service class in android : i am new to android and i am learning the service in android , i created a fragment in which i have a button. on that button click i need to toast a message
this is my service class
public class BackgroundSoundService extends Service {
private static final String TAG = null;
@Override
public void onCreate() {
super.onCreate();
Log.d("tagg", "onCreate: inside service");
Toast.makeText(getApplication(), "This is my Toast message!", Toast.LENGTH_LONG).show();
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
}
i need to toast the message when the button in my fragment class i clicked
this is my fragment class
public class ConnectFragment extends Fragment {
Button service_btn;
public ConnectFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_connect, container, false);
service_btn = (Button) rootView.findViewById(R.id.service_button);
service_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//start_service();
Intent svc = new Intent(getActivity(), BackgroundSoundService.class);
try {
startActivity(svc);
} catch (Exception e) {
Log.d("tagg", "start_service:excception " + e);
}
}
});
return rootView;
}
public void start_service() {
Intent svc = new Intent(getActivity(), BackgroundSoundService.class);
}
}
now i am getting an exception
start_service:excception android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.arjunh.navigationdrawer/com.example.arjunh.navigationdrawer.BackgroundSoundService}; have you declared this activity in your AndroidManifest.xml?
| 0debug |
static void encode_rgb48_10bit(AVCodecContext *avctx, const AVPicture *pic, uint8_t *dst)
{
DPXContext *s = avctx->priv_data;
const uint8_t *src = pic->data[0];
int x, y;
for (y = 0; y < avctx->height; y++) {
for (x = 0; x < avctx->width; x++) {
int value;
if (s->big_endian) {
value = ((AV_RB16(src + 6*x + 4) & 0xFFC0) >> 4)
| ((AV_RB16(src + 6*x + 2) & 0xFFC0) << 6)
| ((AV_RB16(src + 6*x + 0) & 0xFFC0) << 16);
} else {
value = ((AV_RL16(src + 6*x + 4) & 0xFFC0) >> 4)
| ((AV_RL16(src + 6*x + 2) & 0xFFC0) << 6)
| ((AV_RL16(src + 6*x + 0) & 0xFFC0) << 16);
}
write32(dst, value);
dst += 4;
}
src += pic->linesize[0];
}
}
| 1threat |
Why do my code is failing the hidden input test cases? : This is the problem to be solved:
John is assigned a new task today. He is given an array A containing N integers. His task is to update all elements of array to some minimum value x , that is, **A[i]=x;1<=i<=N** ;
such that sum of this new array is strictly greater than the sum of the initial array. Note that x should be as minimum as possible such that sum of the new array is greater than the sum of the initial array.
**Input Format:**
First line of input consists of an integer N denoting the number of elements in the array A.
Second line consists of N space separated integers denoting the array elements.
**Output Format:**
The only line of output consists of the value of x.
**Sample Input:**
5
12345
**Sample Output:**
4
**Explanation:**
Initial sum of array=1+2+3+4+5=15
When we update all elements to 4, sum of array = 4+4+4+4+4=20 which is greater than 15.
Note that if we had updated the array elements to 3,sum=15 which is not greater than 15. So, 4 is the minimum value to which array elements need to be updated.
**==> Here is my code. How can I improve it? or What is the problem in this code?**
import java.util.Scanner;
public class Test2 {
public static void main(String []args){
Scanner s=new Scanner(System.in);
int check=0, sum=0, biggest=0;
int size=s.nextInt();
if(size>=1 && size<=100000) {
int[] arr=new int[size];
for(int i=0; i<size; i++){
int temp=s.nextInt();
if(temp>=1 && temp<=1000) {
arr[i] = temp;
biggest=biggest > temp ? biggest:temp;
sum=sum+temp;
}
else break;
}
for(int i=1; i<biggest; i++){
check=(size*i)>sum ? i:0;
}
System.out.print(check);
}
else System.err.print("Invalid input size");
}
}
| 0debug |
Skip forbidden parameter combinations when using GridSearchCV : <p>I want to greedily search the entire parameter space of my support vector classifier using <a href="http://scikit-learn.org/stable/modules/generated/sklearn.model_selection.GridSearchCV.html" rel="noreferrer">GridSearchCV</a>. However, some combinations of parameters are forbidden by <a href="http://scikit-learn.org/stable/modules/generated/sklearn.svm.LinearSVC.html" rel="noreferrer">LinearSVC</a> and <a href="https://stackoverflow.com/questions/29902190/value-error-happens-when-using-gridsearchcv">throw an exception</a>. In particular, there are mutually exclusive combinations of the <code>dual</code>, <code>penalty</code>, and <code>loss</code> parameters:</p>
<p>For example, this code:</p>
<pre><code>from sklearn import svm, datasets
from sklearn.model_selection import GridSearchCV
iris = datasets.load_iris()
parameters = {'dual':[True, False], 'penalty' : ['l1', 'l2'], \
'loss': ['hinge', 'squared_hinge']}
svc = svm.LinearSVC()
clf = GridSearchCV(svc, parameters)
clf.fit(iris.data, iris.target)
</code></pre>
<p>Returns <code>ValueError: Unsupported set of arguments: The combination of penalty='l2' and loss='hinge' are not supported when dual=False, Parameters: penalty='l2', loss='hinge', dual=False</code></p>
<p>My question is: is it possible to make GridSearchCV skip combinations of parameters which the model forbids? If not, is there an easy way to construct a parameter space which won't violate the rules?</p>
| 0debug |
static av_cold int dsp_init(AVCodecContext *avctx, AACEncContext *s)
{
int ret = 0;
s->fdsp = avpriv_float_dsp_alloc(avctx->flags & CODEC_FLAG_BITEXACT);
if (!s->fdsp)
return AVERROR(ENOMEM);
ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);
ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
ff_init_ff_sine_windows(10);
ff_init_ff_sine_windows(7);
if (ret = ff_mdct_init(&s->mdct1024, 11, 0, 32768.0))
return ret;
if (ret = ff_mdct_init(&s->mdct128, 8, 0, 32768.0))
return ret;
return 0;
}
| 1threat |
Is it possible to transfer data from Python to HTML template/Website (Using Flask) : <p>I am a noob to this topic and this is my first question here.
I want to ask if it is possible to <em>upload a changing variable</em> <em>from python to an HTML</em> textbox/paragraph/forms?
I've seen several methods but can't figure out a one which work.
I'm using <em>Python 3.4 on my raspberry PI 2</em> from which I will be also hosting a web server <em>using flask</em>.
I would preferabbly use flask too for this task too but anyways if it's not possible I can use any other methods as soon as they are easier.</p>
<p>Thanks in Advance ! </p>
| 0debug |
static void pci_msix(void)
{
QVirtioPCIDevice *dev;
QPCIBus *bus;
QVirtQueuePCI *vqpci;
QGuestAllocator *alloc;
QVirtioBlkReq req;
int n_size = TEST_IMAGE_SIZE / 2;
void *addr;
uint64_t req_addr;
uint64_t capacity;
uint32_t features;
uint32_t free_head;
uint8_t status;
char *data;
bus = pci_test_start();
alloc = pc_alloc_init();
dev = virtio_blk_pci_init(bus, PCI_SLOT);
qpci_msix_enable(dev->pdev);
qvirtio_pci_set_msix_configuration_vector(dev, alloc, 0);
addr = dev->addr + VIRTIO_PCI_CONFIG_OFF(true);
capacity = qvirtio_config_readq(&qvirtio_pci, &dev->vdev,
(uint64_t)(uintptr_t)addr);
g_assert_cmpint(capacity, ==, TEST_IMAGE_SIZE / 512);
features = qvirtio_get_features(&qvirtio_pci, &dev->vdev);
features = features & ~(QVIRTIO_F_BAD_FEATURE |
(1u << VIRTIO_RING_F_INDIRECT_DESC) |
(1u << VIRTIO_RING_F_EVENT_IDX) |
(1u << VIRTIO_BLK_F_SCSI));
qvirtio_set_features(&qvirtio_pci, &dev->vdev, features);
vqpci = (QVirtQueuePCI *)qvirtqueue_setup(&qvirtio_pci, &dev->vdev,
alloc, 0);
qvirtqueue_pci_msix_setup(dev, vqpci, alloc, 1);
qvirtio_set_driver_ok(&qvirtio_pci, &dev->vdev);
qmp("{ 'execute': 'block_resize', 'arguments': { 'device': 'drive0', "
" 'size': %d } }", n_size);
qvirtio_wait_config_isr(&qvirtio_pci, &dev->vdev, QVIRTIO_BLK_TIMEOUT_US);
capacity = qvirtio_config_readq(&qvirtio_pci, &dev->vdev,
(uint64_t)(uintptr_t)addr);
g_assert_cmpint(capacity, ==, n_size / 512);
req.type = VIRTIO_BLK_T_OUT;
req.ioprio = 1;
req.sector = 0;
req.data = g_malloc0(512);
strcpy(req.data, "TEST");
req_addr = virtio_blk_request(alloc, &req, 512);
g_free(req.data);
free_head = qvirtqueue_add(&vqpci->vq, req_addr, 16, false, true);
qvirtqueue_add(&vqpci->vq, req_addr + 16, 512, false, true);
qvirtqueue_add(&vqpci->vq, req_addr + 528, 1, true, false);
qvirtqueue_kick(&qvirtio_pci, &dev->vdev, &vqpci->vq, free_head);
qvirtio_wait_queue_isr(&qvirtio_pci, &dev->vdev, &vqpci->vq,
QVIRTIO_BLK_TIMEOUT_US);
status = readb(req_addr + 528);
g_assert_cmpint(status, ==, 0);
guest_free(alloc, req_addr);
req.type = VIRTIO_BLK_T_IN;
req.ioprio = 1;
req.sector = 0;
req.data = g_malloc0(512);
req_addr = virtio_blk_request(alloc, &req, 512);
g_free(req.data);
free_head = qvirtqueue_add(&vqpci->vq, req_addr, 16, false, true);
qvirtqueue_add(&vqpci->vq, req_addr + 16, 512, true, true);
qvirtqueue_add(&vqpci->vq, req_addr + 528, 1, true, false);
qvirtqueue_kick(&qvirtio_pci, &dev->vdev, &vqpci->vq, free_head);
qvirtio_wait_queue_isr(&qvirtio_pci, &dev->vdev, &vqpci->vq,
QVIRTIO_BLK_TIMEOUT_US);
status = readb(req_addr + 528);
g_assert_cmpint(status, ==, 0);
data = g_malloc0(512);
memread(req_addr + 16, data, 512);
g_assert_cmpstr(data, ==, "TEST");
g_free(data);
guest_free(alloc, req_addr);
guest_free(alloc, vqpci->vq.desc);
pc_alloc_uninit(alloc);
qpci_msix_disable(dev->pdev);
qvirtio_pci_device_disable(dev);
g_free(dev);
qpci_free_pc(bus);
test_end();
}
| 1threat |
VueJS newline character is not rendered correctly : <p>I got the following problem, I read data string from an API which contains new line characters <code>\n</code> and I want to display them correctly in my template. </p>
<p>But when I do something like:</p>
<pre><code><p>{{ mytext }}</p>
</code></pre>
<p>The text is display with <code>\n</code> characters in it like normal text.</p>
<p>The text string from the response is in the format of <code>"Hello, \n what's up? \n My name is Joe"</code>.</p>
<p>What am I doing wrong here?</p>
| 0debug |
Figuring out JavaScript libraries for Vim autocompletion with TernJS in .tern_project file : <p>I love vim and want to keep using it to do web development although I am struggling setting up my .tern_project file with the correct libraries I need to do autocompletion. I am relatively new to JavaScript but what I have so far is making it a lot easier to learn.</p>
<p>There aren't many examples that I could find and I have tried to read the <a href="http://ternjs.net/doc/manual.html#configuration" rel="noreferrer">documentation</a> but I do not know enough for it to be helpful. So far my .tern_project file looks like this:</p>
<pre><code>{
"libs": [
"browser",
"ecma6"
],
"plugins": {
"requirejs": {
"baseURL": "./",
"paths": {}
}
}
}
</code></pre>
<p>I don't really know what the plugins do but I left them in for now, in libs the ecma6 really helped me with all the array methods (ie. forEach etc.). Now my question is how do I add stuff like <a href="https://developer.mozilla.org/en-US/docs/Web/API/Console/table" rel="noreferrer">console.table()</a> to autocomplete? </p>
<p>Which library do I need to add to the .tern_project file?</p>
<p>Also, I am open to suggestions for better web development environments.</p>
| 0debug |
static int qdev_add_one_global(QemuOpts *opts, void *opaque)
{
GlobalProperty *g;
ObjectClass *oc;
g = g_malloc0(sizeof(*g));
g->driver = qemu_opt_get(opts, "driver");
g->property = qemu_opt_get(opts, "property");
g->value = qemu_opt_get(opts, "value");
oc = object_class_by_name(g->driver);
if (oc) {
DeviceClass *dc = DEVICE_CLASS(oc);
if (dc->hotpluggable) {
g->not_used = false;
} else {
g->not_used = true;
}
} else {
g->not_used = true;
}
qdev_prop_register_global(g);
return 0;
}
| 1threat |
Disable Firefox Same Origin Policy without installing a plugin : <p>Is there a way to disable the <a href="https://en.wikipedia.org/wiki/Same_origin_policy" rel="noreferrer">same origin policy</a> on the Mozilla Firefox browser <strong>by toggling a flag in the browser</strong>?</p>
<p>This is strictly for development, for not production use.</p>
<hr>
<p>Please note: </p>
<p>A <a href="https://stackoverflow.com/questions/17088609/disable-firefox-same-origin-policy">similar question</a> asked 3+ years ago yielded an accepted answer that recommends users to install a plugin. I consider this less secure and more cumbersome than toggling a flag (e.g. in the about:config, or passing a parameter when starting the browser <a href="https://stackoverflow.com/questions/3102819/disable-same-origin-policy-in-chrome">like in Chrome</a>). </p>
| 0debug |
How to find the database id of a cloud firestore project? : <p>I'm trying to use the Cloud Firestore REST API, but can't seem to find the project id. </p>
| 0debug |
How to get today 00:00 time : <p>how can I get today datetime from 00:00, for example when I Use:</p>
<pre><code>var dt=DateTime.Now; // 2019/1/1 15:22:22
</code></pre>
<p>I need Another extention method to give this string format:</p>
<pre><code>string today = dt.TodayBegining(); // 2019/1/1 00:00:00
</code></pre>
| 0debug |
char *g_strconcat(const char *s, ...)
{
char *s;
s = __coverity_alloc_nosize__();
__coverity_writeall__(s);
__coverity_mark_as_afm_allocated__(s, AFM_free);
return s;
}
| 1threat |
How can I randomly select from prewritten strings in C#? : <p>I have 100 separate strings, and I want the program to display one of them randomly when I push a button.</p>
| 0debug |
Java Spring do scheduled task at a specific time of specific timezone : <p>I'm developing a website with Spring and Hibernate (the website is about stock trading). </p>
<p>At about 12 AM everyday, I need to cancel all orders. Currently my solution is using a scheduled task that runs every hour:</p>
<pre><code> <task:scheduled ref="ordersController" method="timeoutCancelAllOrders" fixed-delay="60*60*1000" />
</code></pre>
<p>Then in the method timeoutCancelAllOrders, I get the current time and check, if it's between 11PM and 12AM then do the task</p>
<p>The way I see it, task schedule starts when I start the Server ( I'm using Tomcat in Eclipse), but when I deploy it on an online hosting ( I'm using Openshift), I have no idea when is the starting time of task schedule.</p>
<h2>My question is:</h2>
<p>1: How to do it more automatic ? Is there anything like myTask.startAt(12AM) ?</p>
<p>2: I'm living in Vietnam but the server (Openshift) is located in US, so here's how I do the check :</p>
<pre><code> Date currentTime = new Date();
DateFormat vnTime = new SimpleDateFormat("hh:mm:ss MM/dd/yyyy ");
vnTime.setTimeZone(TimeZone.getTimeZone("Asia/Ho_Chi_Minh"));
String vietnamCurrentTime = vnTime.format(currentTime);
String currentHourInVietnam = vietnamCurrentTime.substring(0, 2);
System.out.println(currentHourInVietnam);
if(currentHourInVietnam.equals("00")){
// DO MY TASK HERE
}
</code></pre>
<p>That looks stupid. How can I improve my code ?</p>
| 0debug |
int ff_rfps_add_frame(AVFormatContext *ic, AVStream *st, int64_t ts)
{
int i, j;
int64_t last = st->info->last_dts;
if( ts != AV_NOPTS_VALUE && last != AV_NOPTS_VALUE && ts > last
&& ts - (uint64_t)last < INT64_MAX){
double dts= (is_relative(ts) ? ts - RELATIVE_TS_BASE : ts) * av_q2d(st->time_base);
int64_t duration= ts - last;
if (!st->info->duration_error)
st->info->duration_error = av_mallocz(sizeof(st->info->duration_error[0])*2);
if (!st->info->duration_error)
return AVERROR(ENOMEM);
for (i=0; i<MAX_STD_TIMEBASES; i++) {
if (st->info->duration_error[0][1][i] < 1e10) {
int framerate= get_std_framerate(i);
double sdts= dts*framerate/(1001*12);
for(j=0; j<2; j++){
int64_t ticks= llrint(sdts+j*0.5);
double error= sdts - ticks + j*0.5;
st->info->duration_error[j][0][i] += error;
st->info->duration_error[j][1][i] += error*error;
}
}
}
st->info->duration_count++;
if (st->info->duration_count % 10 == 0) {
int n = st->info->duration_count;
for (i=0; i<MAX_STD_TIMEBASES; i++) {
if (st->info->duration_error[0][1][i] < 1e10) {
double a0 = st->info->duration_error[0][0][i] / n;
double error0 = st->info->duration_error[0][1][i] / n - a0*a0;
double a1 = st->info->duration_error[1][0][i] / n;
double error1 = st->info->duration_error[1][1][i] / n - a1*a1;
if (error0 > 0.04 && error1 > 0.04) {
st->info->duration_error[0][1][i] = 2e10;
st->info->duration_error[1][1][i] = 2e10;
}
}
}
}
if (st->info->duration_count > 3 && is_relative(ts) == is_relative(last))
st->info->duration_gcd = av_gcd(st->info->duration_gcd, duration);
}
if (ts != AV_NOPTS_VALUE)
st->info->last_dts = ts;
return 0;
} | 1threat |
updata query from access to sql server : I have this query below from access and I need to convert it into sql server:
UPDATE (CASE_INFO INNER JOIN CASE_PRICE ON CASE_INFO.CASE_TYPE = CASE_PRICE.CASE_TYPE) INNER JOIN [CASECHANGE|INPUT] ON CASE_INFO.CASE_NUMBER = [CASECHANGE|INPUT].CASE_NUMBER SET CASE_INFO.FF_REVENUE_AMT = [FF_Payment], CASE_INFO.CM_REVENUE_AMT = [CM_Payment]
WHERE (((CASE_INFO.SCHEDULED_DATE) Between [CASE_PRICE].[POP_START] And [CASE_PRICE].[POP_END]) AND ((CASE_INFO.DISCONTINUE_30)=No));
| 0debug |
static int protocol_client_msg(VncState *vs, uint8_t *data, size_t len)
{
int i;
uint16_t limit;
switch (data[0]) {
case 0:
if (len == 1)
return 20;
set_pixel_format(vs, read_u8(data, 4), read_u8(data, 5),
read_u8(data, 6), read_u8(data, 7),
read_u16(data, 8), read_u16(data, 10),
read_u16(data, 12), read_u8(data, 14),
read_u8(data, 15), read_u8(data, 16));
break;
case 2:
if (len == 1)
return 4;
if (len == 4)
return 4 + (read_u16(data, 2) * 4);
limit = read_u16(data, 2);
for (i = 0; i < limit; i++) {
int32_t val = read_s32(data, 4 + (i * 4));
memcpy(data + 4 + (i * 4), &val, sizeof(val));
}
set_encodings(vs, (int32_t *)(data + 4), limit);
break;
case 3:
if (len == 1)
return 10;
framebuffer_update_request(vs,
read_u8(data, 1), read_u16(data, 2), read_u16(data, 4),
read_u16(data, 6), read_u16(data, 8));
break;
case 4:
if (len == 1)
return 8;
key_event(vs, read_u8(data, 1), read_u32(data, 4));
break;
case 5:
if (len == 1)
return 6;
pointer_event(vs, read_u8(data, 1), read_u16(data, 2), read_u16(data, 4));
break;
case 6:
if (len == 1)
return 8;
if (len == 8) {
uint32_t dlen = read_u32(data, 4);
if (dlen > 0)
return 8 + dlen;
}
client_cut_text(vs, read_u32(data, 4), data + 8);
break;
case 255:
if (len == 1)
return 2;
switch (read_u8(data, 1)) {
case 0:
if (len == 2)
return 12;
ext_key_event(vs, read_u16(data, 2),
read_u32(data, 4), read_u32(data, 8));
break;
case 1:
if (len == 2)
return 4;
switch (read_u16 (data, 2)) {
case 0:
audio_add(vs);
break;
case 1:
audio_del(vs);
break;
case 2:
if (len == 4)
return 10;
switch (read_u8(data, 4)) {
case 0: vs->as.fmt = AUD_FMT_U8; break;
case 1: vs->as.fmt = AUD_FMT_S8; break;
case 2: vs->as.fmt = AUD_FMT_U16; break;
case 3: vs->as.fmt = AUD_FMT_S16; break;
case 4: vs->as.fmt = AUD_FMT_U32; break;
case 5: vs->as.fmt = AUD_FMT_S32; break;
default:
printf("Invalid audio format %d\n", read_u8(data, 4));
vnc_client_error(vs);
break;
}
vs->as.nchannels = read_u8(data, 5);
if (vs->as.nchannels != 1 && vs->as.nchannels != 2) {
printf("Invalid audio channel coount %d\n",
read_u8(data, 5));
vnc_client_error(vs);
break;
}
vs->as.freq = read_u32(data, 6);
break;
default:
printf ("Invalid audio message %d\n", read_u8(data, 4));
vnc_client_error(vs);
break;
}
break;
default:
printf("Msg: %d\n", read_u16(data, 0));
vnc_client_error(vs);
break;
}
break;
default:
printf("Msg: %d\n", data[0]);
vnc_client_error(vs);
break;
}
vnc_read_when(vs, protocol_client_msg, 1);
return 0;
}
| 1threat |
How to fix Perforce error "Can't clobber writable file" or Perforce Error Message - Can't Clobber Writable File : <p><strong>Error: Can't clobber writable file : //file name//</strong></p>
<p><strong>Solution:</strong> When you try to sync a file, perforce expects your files in workspace will have read-only permissions. But if a file is not checkout,(by p4 edit)but has write permission then it will throw the above error. <strong>Changing the file to read-only and syncing again</strong> will solve the issue. or try removing the workspace and get the latest revision again.</p>
| 0debug |
static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
{
Vp3DecodeContext *s = dst->priv_data, *s1 = src->priv_data;
int qps_changed = 0, i, err;
#define copy_fields(to, from, start_field, end_field) memcpy(&to->start_field, &from->start_field, (char*)&to->end_field - (char*)&to->start_field)
if (!s1->current_frame.data[0]
||s->width != s1->width
||s->height!= s1->height) {
if (s != s1)
copy_fields(s, s1, golden_frame, current_frame);
return -1;
}
if (s != s1) {
if (!s->current_frame.data[0]) {
int y_fragment_count, c_fragment_count;
s->avctx = dst;
err = allocate_tables(dst);
if (err)
return err;
y_fragment_count = s->fragment_width[0] * s->fragment_height[0];
c_fragment_count = s->fragment_width[1] * s->fragment_height[1];
memcpy(s->motion_val[0], s1->motion_val[0], y_fragment_count * sizeof(*s->motion_val[0]));
memcpy(s->motion_val[1], s1->motion_val[1], c_fragment_count * sizeof(*s->motion_val[1]));
}
copy_fields(s, s1, golden_frame, dsp);
for (i = 0; i < 3; i++) {
if (s->qps[i] != s1->qps[1]) {
qps_changed = 1;
memcpy(&s->qmat[i], &s1->qmat[i], sizeof(s->qmat[i]));
}
}
if (s->qps[0] != s1->qps[0])
memcpy(&s->bounding_values_array, &s1->bounding_values_array, sizeof(s->bounding_values_array));
if (qps_changed)
copy_fields(s, s1, qps, superblock_count);
#undef copy_fields
}
update_frames(dst);
return 0;
}
| 1threat |
How to configure IIS 7 for localhost website? : <p>I am new in Asp.Net</p>
<p>I have enabled features of IIS 7 on my windows system and able to see IIS manager.</p>
<p>I created an application but build/run application through visual studio it goes to browser and run the application with different port number. When i stop build/run application through visual studio and again i refresh browser application could not run.</p>
<p>I want to run application without visual studio. How to do this.</p>
<p>It gives this : <code>http://localhost:9864/</code></p>
| 0debug |
java - illegalStateException: Cannot find changelog location: class path resource (liquibase) : <p>I am getting this error when I try to run my spring boot application. I am new to java and spring development. Please let me know if you require more info. I'm not sure what it means by "cannot find changelog location ..."</p>
<pre><code>2017-02-01 16:19:22.543 ERROR 17315 --- [ restartedMain] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration$LiquibaseConfiguration': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Cannot find changelog location: class path resource [db/changelog/db.changelog-master.yaml] (please add changelog or check your Liquibase configuration)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:137)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1575)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:372)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1128)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1022)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:296)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:856)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175)
at com.ccc.Application.main(Application.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.IllegalStateException: Cannot find changelog location: class path resource [db/changelog/db.changelog-master.yaml] (please add changelog or check your Liquibase configuration)
at org.springframework.util.Assert.state(Assert.java:392)
at org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration$LiquibaseConfiguration.checkChangelogExists(LiquibaseAutoConfiguration.java:92)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:366)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:311)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:134)
... 34 common frames omitted
</code></pre>
| 0debug |
Elasticsearch - generic facets structure - calculating aggregations combined with filters : <p>In a new project of ours, we were inspired by this article <a href="http://project-a.github.io/on-site-search-design-patterns-for-e-commerce/#generic-faceted-search" rel="noreferrer">http://project-a.github.io/on-site-search-design-patterns-for-e-commerce/#generic-faceted-search</a> for doing our “facet” structure. And while I have got it working to the extent the article describes, I have run into issues in getting it to work when selecting facets. I hope someone can give a hint as to something to try, so I don’t have to redo all our aggregations into separate aggregation calculations again.</p>
<p>The problem is basically that we are using a single aggregation to calculate all the “facets” at once, but when I add a filter (fx. checking a brand name), then it “removes” all the other brands when returning the aggregates. What I basically want is that it should use that brand as filter when calculating the other facets, but not when calculating the brand aggregations. This is necessary so the user can, for example, choose multiple brands.</p>
<p>Looking at <a href="https://www.contorion.de/search/Metabo_Fein/ou1-ou2?q=Winkelschleifer&c=bovy" rel="noreferrer">https://www.contorion.de/search/Metabo_Fein/ou1-ou2?q=Winkelschleifer&c=bovy</a> (which is the site described in the above article), I have selected the “Metabo” and “Fein” manufacturer (Hersteller), and unfolding the Hersteller menu it shows all manufacturers and not just the ones selected. So I know it’s possible somehow and I hope some one out there has a hint as to how to write the aggregations / filters, so I get the "correct e-commerce facet behavior".</p>
<p>On the products in ES I have the following structure: (the same as in the original article, though “C#’ified” in naming)</p>
<pre><code>"attributeStrings": [
{
"facetName": "Property",
"facetValue": "Organic"
},
{
"facetName": "Property",
"facetValue": "Without parfume"
},
{
"facetName": "Brand",
"facetValue": "Adidas"
}
]
</code></pre>
<p>So the above product has 2 attributes/facet groups – Property with 2 values (Organic, Without parfume) and Brand with 1 value (Adidas).
Without any filters I calculate the aggregations from the following query:</p>
<pre><code> "aggs": {
"agg_attr_strings_filter": {
"filter": {},
"aggs": {
"agg_attr_strings": {
"nested": {
"path": "attributeStrings"
},
"aggs": {
"attr_name": {
"terms": {
"field": "attributeStrings.facetName"
},
"aggs": {
"attr_value": {
"terms": {
"field": "attributeStrings.facetValue",
"size": 1000,
"order": [
{
"_term": "asc"
}
]
} } } } } } } }
</code></pre>
<p>Now if I select Property "Organic" and Brand "Adidas" I build the same aggregation, but with a filter to apply those two constraints (which is were it kind of goes wrong...):</p>
<pre><code> "aggs": {
"agg_attr_strings_filter": {
"filter": {
"bool": {
"filter": [
{
"nested": {
"query": {
"bool": {
"filter": [
{
"term": {
"attributeStrings.facetName": {
"value": "Property"
}
}
},
{
"terms": {
"attributeStrings.facetValue": [
"Organic"
]
}
}
]
}
},
"path": "attributeStrings"
}
},
{
"nested": {
"query": {
"bool": {
"filter": [
{
"term": {
"attributeStrings.facetName": {
"value": "Brand"
}
}
},
{
"terms": {
"attributeStrings.facetValue": [
"Adidas"
]
}
}
]
}
},
"path": "attributeStrings"
}
}
]
}
},
"aggs": {
"agg_attr_strings": {
"nested": {
"path": "attributeStrings"
},
"aggs": {
"attr_name": {
"terms": {
"field": "attributeStrings.facetName",
},
"aggs": {
"attr_value": {
"terms": {
"field": "attributeStrings.facetValue",
"size": 1000,
"order": [
{
"_term": "asc"
}
]
} } } } } } } }
</code></pre>
<p>The only way I can see forward with this model, is to calculate the aggregation for each selected facet and somehow merge the result. But it seems very complex and kind of defeats the point of having the model as described in the article, so I hope there's a more clean solution and someone can give a hint at something to try.</p>
| 0debug |
How to remove all files with specific extension in folder? : <p>I am looking for command to delete all files with a specific extension in a given folder. Both, for windows and mac.</p>
<p>Thanks!</p>
| 0debug |
cannot resolve simbol 'adapter' : I have an error with this code, i don't understand why, but "adapter.notifyDataSetChanged();" don't work, the message of error is: "cannot resolve simbol 'adapter'".
Code:wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
final String URL = "http://example....";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
rv = (RecyclerView)findViewById(R.id.rv);
....
public class PrintA extends AsyncTask<String, String, List<Model>> {
....
@Override
protected void onPostExecute(final List<MyModel> result) {
super.onPostExecute(result);
if (result != null) {
MyAdapter adapter = new MyAdapter(result);
rv.setAdapter(adapter);
}else{
Toast.makeText(getApplicationContext(), "no internet",
}
}
}
new PrintA().execute(URL);
rv.addOnScrollListener(new RecyclerView.OnScrollListener(){
....
public class PrintB extends AsyncTask<String, String, List<Model>> {
....
@Override
protected void onPostExecute(final List<MyModel> result) {
super.onPostExecute(result);
if (result != null) {
....
adapter.notifyDataSetChanged();
}else{
Toast.makeText(getApplicationContext(), "can't add",
}
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy)
{
....
new PrintB().execute(URL);
}
} | 0debug |
BlockAIOCB *bdrv_aio_discard(BlockDriverState *bs,
int64_t sector_num, int nb_sectors,
BlockCompletionFunc *cb, void *opaque)
{
Coroutine *co;
BlockAIOCBCoroutine *acb;
trace_bdrv_aio_discard(bs, sector_num, nb_sectors, opaque);
acb = qemu_aio_get(&bdrv_em_co_aiocb_info, bs, cb, opaque);
acb->need_bh = true;
acb->req.error = -EINPROGRESS;
acb->req.sector = sector_num;
acb->req.nb_sectors = nb_sectors;
co = qemu_coroutine_create(bdrv_aio_discard_co_entry);
qemu_coroutine_enter(co, acb);
bdrv_co_maybe_schedule_bh(acb);
return &acb->common;
}
| 1threat |
static void nvdimm_dsm_func_read_fit(AcpiNVDIMMState *state, NvdimmDsmIn *in,
hwaddr dsm_mem_addr)
{
NvdimmFitBuffer *fit_buf = &state->fit_buf;
NvdimmFuncReadFITIn *read_fit;
NvdimmFuncReadFITOut *read_fit_out;
GArray *fit;
uint32_t read_len = 0, func_ret_status;
int size;
read_fit = (NvdimmFuncReadFITIn *)in->arg3;
le32_to_cpus(&read_fit->offset);
qemu_mutex_lock(&fit_buf->lock);
fit = fit_buf->fit;
nvdimm_debug("Read FIT: offset %#x FIT size %#x Dirty %s.\n",
read_fit->offset, fit->len, fit_buf->dirty ? "Yes" : "No");
if (read_fit->offset > fit->len) {
func_ret_status = 3 ;
goto exit;
}
if (!read_fit->offset) {
fit_buf->dirty = false;
} else if (fit_buf->dirty) {
func_ret_status = 0x100 ;
goto exit;
}
func_ret_status = 0 ;
read_len = MIN(fit->len - read_fit->offset,
4096 - sizeof(NvdimmFuncReadFITOut));
exit:
size = sizeof(NvdimmFuncReadFITOut) + read_len;
read_fit_out = g_malloc(size);
read_fit_out->len = cpu_to_le32(size);
read_fit_out->func_ret_status = cpu_to_le32(func_ret_status);
memcpy(read_fit_out->fit, fit->data + read_fit->offset, read_len);
cpu_physical_memory_write(dsm_mem_addr, read_fit_out, size);
g_free(read_fit_out);
qemu_mutex_unlock(&fit_buf->lock);
}
| 1threat |
Laravel API, how to properly handle errors : <p>Anyone know what is the best way to handle errors in Laravel, there is any rules or something to follow ?</p>
<p>Currently i'm doing this : </p>
<pre><code>public function store(Request $request)
{
$plate = Plate::create($request->all());
if ($plate) {
return $this->response($this->plateTransformer->transform($plate));
} else {
// Error handling ?
// Error 400 bad request
$this->setStatusCode(400);
return $this->responseWithError("Store failed.");
}
}
</code></pre>
<p>And the setStatusCode and responseWithError come from the father of my controller :</p>
<pre><code>public function setStatusCode($statusCode)
{
$this->statusCode = $statusCode;
return $this;
}
public function responseWithError ($message )
{
return $this->response([
'error' => [
'message' => $message,
'status_code' => $this->getStatusCode()
]
]);
}
</code></pre>
<p>But is this a good way to handle the API errors, i see some different way to handle errors on the web, what is the best ?</p>
<p>Thanks.</p>
| 0debug |
Please help in creating a message app filter extension for iPhone : I am developing a message filter app extension.
I searched about it and got to know about identity lookup which is newly introduced concept in ios 11.0.
I came to know that i have to insert keys in info.plist
<key>NSExtension</key>
<dict>
<key>NSExtensionPrincipalClass</key>
<string>MessageFilterExtension</string>
<key>NSExtensionAttributes</key>
<dict>
<key>ILMessageFilterExtensionNetworkURL</key>
<string>https://www.example-sms-filter-application.com/api</string>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.identitylookup.message-filter</string>
</dict>
but after inserting these, when in build app, i am getting black screen.
I have just inserted this code only. nothing else in view controller.swift file and made a file MessageFilterExtension.swift with same class name.
Please help.
Please look at these - https://developer.apple.com/documentation/identitylookup/creating_a_message_filter_app_extension | 0debug |
static void do_dma_memory_set(dma_addr_t addr, uint8_t c, dma_addr_t len)
{
#define FILLBUF_SIZE 512
uint8_t fillbuf[FILLBUF_SIZE];
int l;
memset(fillbuf, c, FILLBUF_SIZE);
while (len > 0) {
l = len < FILLBUF_SIZE ? len : FILLBUF_SIZE;
cpu_physical_memory_rw(addr, fillbuf, l, true);
len -= len;
addr += len;
}
}
| 1threat |
How to calculate the percentage of word using SQL Query? : Actual case is to read the total count difference in percentage basis. Since hello comes in first word its count-'1' but in the 3rd rows Hello count -2. Now i need to calculate the percentage of the word usage like previously it is 1, now it is 2 percentage is 50% increased. so i have to calculate percentage for particular word from previous and current.
No, Text, Word, Totalcount
1, Hello Welcome,Hello,1
2, Hello Text, Text,1
3, Hello Text! Hello, Hello,2
I have formed the following SQL query to calculate the percentage but it leads error.
select Totalcount * 100/SUM(TotalCount) from table where Word = 'Hello'
it leads following issue .
Word is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Am googling but not found the better solution for it.
Suggest me the way the sql querying to do this. Any help appreciated.
| 0debug |
In Python - Can I access functions outside of a class not using inheritance or subclassing? : <p>After creating an instance of a class. If there is a function (I am using function because in this case because it is outside of the class so not a method) that I define outside of the class, can I access it?</p>
| 0debug |
Material-ui: outline version of icon : <p>I'm using material-ui in my react web application. I need the icon 'action/description' in a component but in the <em>outline</em> version. </p>
<p>According to the docs:</p>
<blockquote>
<p>For convenience, the full set of google Material icons are available
in Material-UI as pre-built SVG Icon components.</p>
</blockquote>
<p>So I can do this to get the "filled" version:</p>
<pre><code>import ActionDescription from 'material-ui/svg-icons/action/description'
<div className="number">
<ActionDescription />
</div>
</code></pre>
<p>But how do I get the "outline" version? I tried playing with css but didn't succeed:</p>
<pre><code><div>
<ActionDescription style={{black: "black"}} color="transparent" />
</div>
</code></pre>
| 0debug |
SonarQube rule: "Using command line arguments is security-sensitive" in Spring Boot application : <p>SonarQube is just showing a Critical security issue in the very basic Spring Boot application. In the main method.</p>
<pre><code>@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
</code></pre>
<p>SonarQube wants me to <code>Make sure that command line arguments are used safely here.</code></p>
<p>I searched this on both StackOverflow and Google, and I am surprised that I couldn't find any single comment about this issue. I am almost sure that there are some security checks inside the <code>SpringApplication.run</code> method already. And also, I don't even remember that anyone sanitizes the main method arguments before calling <code>SpringApplication.run</code>. I simply want to tag it as <strong>false positive</strong> and move on.</p>
<p>Part of this question is also asked here: <a href="https://stackoverflow.com/questions/54856544/sonarqube-shows-a-secuirty-error-in-spring-framework-controllers-and-in-spring-f">SonarQube shows a secuirty error in Spring Framework controllers and in Spring Framework Application main class</a></p>
<p>Is it false positive?</p>
| 0debug |
Make Equal-Width SwiftUI Views in List Rows : <p>I have a <code>List</code> that displays days in the current month. Each row in the <code>List</code> contains the abbreviated day, a <code>Divider</code>, and the day number within a <code>VStack</code>. The <code>VStack</code> is then embedded in an <code>HStack</code> so that I can have more text to the right of the day and number.</p>
<pre class="lang-swift prettyprint-override"><code>struct DayListItem : View {
// MARK: - Properties
let date: Date
private let weekdayFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "EEE"
return formatter
}()
private let dayNumberFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "d"
return formatter
}()
var body: some View {
HStack {
VStack(alignment: .center) {
Text(weekdayFormatter.string(from: date))
.font(.caption)
.foregroundColor(.secondary)
Text(dayNumberFormatter.string(from: date))
.font(.body)
.foregroundColor(.red)
}
Divider()
}
}
}
</code></pre>
<p>Instances of <code>DayListItem</code> are used in <code>ContentView</code>:</p>
<pre class="lang-swift prettyprint-override"><code>struct ContentView : View {
// MARK: - Properties
private let dataProvider = CalendricalDataProvider()
private var navigationBarTitle: String {
let formatter = DateFormatter()
formatter.dateFormat = "MMMM YYY"
return formatter.string(from: Date())
}
private var currentMonth: Month {
dataProvider.currentMonth
}
private var months: [Month] {
return dataProvider.monthsInRelativeYear
}
var body: some View {
NavigationView {
List(currentMonth.days.identified(by: \.self)) { date in
DayListItem(date: date)
}
.navigationBarTitle(Text(navigationBarTitle))
.listStyle(.grouped)
}
}
}
</code></pre>
<p>The result of the code is below:</p>
<p><a href="https://i.stack.imgur.com/5notv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5notv.png" alt="Screenshot of app running in Xcode Simulator"></a></p>
<p>It may not be obvious, but the dividers are not lined up because the width of the text can vary from row to row. What I would like to achieve is to have the views that contains the day information be the same width so that they are visually aligned.</p>
<p>I have tried using a <code>GeometryReader</code> and the <code>frame()</code> modifiers to set the minimum width, ideal width, and maximum width, but I need to ensure that the text can shrink and grow with Dynamic Type settings; I chose not to use a width that is a percentage of the parent because I was uncertain how to be sure that localized text would always fit within the allowed width.</p>
<p>How can I modify my views so that each view in the row is the same width, regardless of the width of text?</p>
<p>Regarding Dynamic Type, I will create a different layout to be used when that setting is changed.</p>
| 0debug |
How to build glus.lib with MinGW and Sublime : I am in a similar situation :
http://stackoverflow.com/questions/15754872/eclipse-cpp-and-gnu-following-these-instructions
But i need to build GLUS with MinGW and sublime text.
I am learning C and OpenGL ,so i lake compilation/dependencies logic.
I would just like to undertsand in a simple way.
- how to compile GLUS from those source:
https://github.com/McNopper/OpenGL/tree/master/GLUS/src
- where to install all the files in MinGW folder to setup things correctly.
Glew and Glfw are already configure correctly and works fine.
Thanks for your time.
| 0debug |
parameters in for loop Javascript : 1. I am working on this project for school.
But I can not figure out one problem.
I have 2 lines of boxed both colored, but I use a for loop and in the parameters don't work in the for loop. the lines have both different places and different length. So I have this Question how could I use the parameters in the for loop. Just right so i would work everytime.
This is the code i have so far:
2.
`box('box', 3);
box('box2, 4);
function box(id,aantal){
for(var i = 0; i < aantal.length; i++){
var box = document.createElement("div");
box.style.height = "175px";
box.style.width= "175px";
box.style.borderRadius = "5px";
box.style.backgroundColor = "#e6e6e6";
box.style.marginLeft ="25px";
box.style.marginTop = "-160px";
box.style.float = "left";
document.getElementById(id).appendChild(box);
}
} ` | 0debug |
int loader_exec(const char * filename, char ** argv, char ** envp,
struct target_pt_regs * regs, struct image_info *infop,
struct linux_binprm *bprm)
{
int retval;
int i;
bprm->p = TARGET_PAGE_SIZE*MAX_ARG_PAGES-sizeof(unsigned int);
memset(bprm->page, 0, sizeof(bprm->page));
retval = open(filename, O_RDONLY);
if (retval < 0)
return retval;
bprm->fd = retval;
bprm->filename = (char *)filename;
bprm->argc = count(argv);
bprm->argv = argv;
bprm->envc = count(envp);
bprm->envp = envp;
retval = prepare_binprm(bprm);
if(retval>=0) {
if (bprm->buf[0] == 0x7f
&& bprm->buf[1] == 'E'
&& bprm->buf[2] == 'L'
&& bprm->buf[3] == 'F') {
retval = load_elf_binary(bprm, regs, infop);
#if defined(TARGET_HAS_BFLT)
} else if (bprm->buf[0] == 'b'
&& bprm->buf[1] == 'F'
&& bprm->buf[2] == 'L'
&& bprm->buf[3] == 'T') {
retval = load_flt_binary(bprm,regs,infop);
#endif
} else {
fprintf(stderr, "Unknown binary format\n");
return -1;
}
}
if(retval>=0) {
do_init_thread(regs, infop);
return retval;
}
for (i=0 ; i<MAX_ARG_PAGES ; i++) {
free(bprm->page[i]);
}
return(retval);
}
| 1threat |
Docker: npm install behind proxy : <p>I have this Dockerfile:</p>
<pre><code>FROM node:argon
ENV http_proxy http://user:pass@proxy.company.priv:3128
ENV https_proxy https://user:pass@proxy.company.priv:3128
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install
# Bundle app source
COPY . /usr/src/app
EXPOSE 8080
CMD [ "npm", "start" ]
</code></pre>
<p>But I get this error, in <strong>npm install</strong> step:</p>
<blockquote>
<p>npm info it worked if it ends with ok npm info using npm@2.14.12 npm
info using node@v4.2.6 npm WARN package.json deployer-ui@1.0.0 No
description npm WARN package.json deployer-ui@1.0.0 No repository
field. npm WARN package.json deployer-ui@1.0.0 No README data npm info
preinstall deployer-ui@1.0.0 npm info attempt registry request try #1
at 7:09:23 AM npm http request GET
<a href="https://registry.npmjs.org/body-parser" rel="noreferrer">https://registry.npmjs.org/body-parser</a> npm info attempt registry
request try #1 at 7:09:23 AM npm http request GET
<a href="https://registry.npmjs.org/express" rel="noreferrer">https://registry.npmjs.org/express</a> npm info retry will retry, error on
last attempt: Error: tunneling socket could not be established,
cause=write EPROTO npm info retry will retry, error on last attempt:
Error: tunneling socket could not be established, cause=write EPROTO</p>
</blockquote>
<p>I guess it is due to the proxy. I have also tried to put</p>
<pre><code>RUN npm config set proxy http://user:pass@proxy.company.priv:3128
RUN npm config set https-proxy http://user:pass@proxy.company.priv:3128
</code></pre>
<p>but still getting the same error.</p>
<p>Moreover, in my file <strong>/etc/systemd/system/docker.service.d/http-proxy.conf</strong> I have this:</p>
<pre><code>Environment="HTTP_PROXY=http://user:pass@proxy.company.priv:3128"
Environment="HTTPS_PROXY=https://user:pass@proxy.company.priv:3128"
</code></pre>
<p>Thanks in advance.</p>
| 0debug |
Payment gateway integration problem in redirection from bcackend to front end in web application : In one of my web application which make use of spring boot and angular 6 environment i am trying to intigeate the payu payment gateway. Now the problem is they will post the success capture or failure capture data to whatever url provided by our application.
What is the url we need to give them to post the data. Is it a backend url Or front end url.
If it is backend url, then once data is received in spring boot we will save the data to the db after that how to change the page in the front end. ( in angular)
Please help me and guide me to proceede.
Thanks
| 0debug |
static void do_info_profile(Monitor *mon)
{
int64_t total;
total = qemu_time;
if (total == 0)
total = 1;
monitor_printf(mon, "async time %" PRId64 " (%0.3f)\n",
dev_time, dev_time / (double)ticks_per_sec);
monitor_printf(mon, "qemu time %" PRId64 " (%0.3f)\n",
qemu_time, qemu_time / (double)ticks_per_sec);
monitor_printf(mon, "kqemu time %" PRId64 " (%0.3f %0.1f%%) count=%"
PRId64 " int=%" PRId64 " excp=%" PRId64 " intr=%"
PRId64 "\n",
kqemu_time, kqemu_time / (double)ticks_per_sec,
kqemu_time / (double)total * 100.0,
kqemu_exec_count,
kqemu_ret_int_count,
kqemu_ret_excp_count,
kqemu_ret_intr_count);
qemu_time = 0;
kqemu_time = 0;
kqemu_exec_count = 0;
dev_time = 0;
kqemu_ret_int_count = 0;
kqemu_ret_excp_count = 0;
kqemu_ret_intr_count = 0;
#ifdef CONFIG_KQEMU
kqemu_record_dump();
#endif
}
| 1threat |
static void string_output_append(StringOutputVisitor *sov, int64_t a)
{
Range *r = g_malloc0(sizeof(*r));
r->begin = a;
r->end = a + 1;
sov->ranges = g_list_insert_sorted_merged(sov->ranges, r, range_compare);
}
| 1threat |
What are selectors in redux? : <p>I am trying to follow this <a href="https://github.com/yelouafi/redux-saga/blob/7628def689433e678d78d9dd978c14162a1d45f1/examples/real-world/reducers/selectors.js#L2" rel="noreferrer">code</a> in <code>redux-saga</code></p>
<pre><code>export const getUser = (state, login) => state.entities.users[login]
export const getRepo = (state, fullName) => state.entities.repos[fullName]
</code></pre>
<p>Which is then used in the saga like <a href="https://github.com/yelouafi/redux-saga/blob/master/examples/real-world/sagas/index.js" rel="noreferrer">this</a>:</p>
<pre><code>import { getUser } from '../reducers/selectors'
// load user unless it is cached
function* loadUser(login, requiredFields) {
const user = yield select(getUser, login)
if (!user || requiredFields.some(key => !user.hasOwnProperty(key))) {
yield call(fetchUser, login)
}
}
</code></pre>
<p>This <code>getUser</code> reducer (is it even a reducer) looks very different from what I would normally expect a reducer to look like.</p>
<p>Can anyone explain what a selector is and how <code>getUser</code> is a reducer and how it fits in with redux-saga?</p>
| 0debug |
Calculating the shortest distance between n GPS points : <p>I have for example 4 points: A (latitute1, longitude1), B (latitute2, longitude2), C (latitute3, longitude3), D (latitute4, longitude4).</p>
<p>If I am a driver and I go from point A, I need an algorithm that calculates the most efficient way for me to visit all the points B, C, D starting from A. So that the distance is the smallest possible.</p>
<p>The algorithm should tell me the most effective order: A --> C --> B --> D (for example).</p>
<p>What matters is the total distance traveled is the lowest possible.</p>
<p>Thanks so much!!! :)</p>
| 0debug |
Native Ads In React Native : <p>How do you implement AdMob's Native Ads in React Native? The best I've found is <a href="https://github.com/sbugert/react-native-admob" rel="noreferrer">react-native-admob</a>, but it only does fixed banners and full screen interstitials. How could I implement native ads <em>inside</em> my React Native app with AdMob or any other native ad provider?</p>
| 0debug |
Strange output (C++) : (C++) I have written the following code, but the output is displaying weird values along the lines of 011512EE. I have no idea where this is coming from or how to fix it. [code][1]
[1]: http://i.stack.imgur.com/UDUhr.png | 0debug |
Need help in building functions in javascript : A parking garage charges a $2.00 minimum fee to park for up to three hours. It charges an additional $0.50 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24-hour period is $10.00. Assume that no car parks for longer than 24 hours at a time.
The web page should calculate the entry hour and minute as well as the exit hour and minute with text boxes. Hours will be entered in a 24 hour format. Once the submit button is selected, the webpage should display the charge, total number of charges and running total of charges. Note that the latter two values will be maintained as the page is used repetedly.
Create and use functions calculateTime and calculateCharge, the former to figure the amount of time in the garage and the latter to figure the charge.
I got the HTML running, however I cannot get the values to display on to the textbox. I also cannot figure out how to calculate the charge. Any help would be appreciated! Thank you.
HTML CODE:
<!DOCTYPE html>
<html>
<head>
<title>Parking Charge</title>
</head>
<body><div align="center">
<form id="1"><h1><p style="background-color:black ; color:gold;">Parking Garage Charge Calculator</p></h1><hr>
<p>ENTRY TIME: <input type = "number" name = "EntryTime" id = "entTime"></p>
<p>EXIT TIME : <input type="number" id="extTime" name="ExitTime">
<p>Number of Hours Parked: <input type ="number" name="noOfHours" id="nh"><br><br>
<input type="button" id="calculate" name="calc" value="Calculate" onclick="calculateTime()"/>
<input type="reset" id="resetBtn" value="Clear"><br><br>
<input type="number" id="total" name="totalCost" placeholder="Your Total Payment" readonly/><hr>
</form>
</div>
</body>
<script src="P2JS.js"></script>
</html>
JAVASCRIPT CODE:
function calculateTime(){
var EntryTime = document.getElementById('entTime').value;
var ExitTime = document.getElementById('extTime').value;
var noOfHours = (EntryTime - ExitTime);
document.getElementById("nh").innerHTML = noOfHours;
}
/*Function to calculate the payment on the number of hours parked*/
function calculateCharge(){
var charge = 3.50;
var payment = (noOfHours * charge);
if (noOfHours <= 3){
totalPayment = charge * noOfHours;
return payment;
}
else {
payment = ((noOfHours - 3) * (charge + 0.50)) + (charge * 3);
return payment;
}
} | 0debug |
any tricks if script and script name modified to quit progrom : <p>Some one please provide me hints. If some one modify script name and modify script contents should not run.</p>
<p>Python 2.7</p>
| 0debug |
Is there a way to prevent fastclick from firing “active” state on scroll? : <p>I’m using <a href="https://github.com/ftlabs/fastclick">FastClick</a> on a page with large links because I want to bypass the 300ms delay for taps in mobile browsers. I have a “highlight” style for the links’ <code>:active</code> states and it is properly firing quickly, thanks to FastClick.</p>
<p>My problem is that – in Mobile Safari at least – it also fires while you’re tapping and swiping to scroll the page. This makes it feel like you can’t scroll the page without it thinking you’re trying to tap the links.</p>
<p>Is there a way to prevent it from firing when someone scrolls?</p>
| 0debug |
Please help me!! Gradle Build failed : Information:Gradle tasks [:app:assembleDebug]
C:\Users\davis\AndroidStudioProjects\tester\app\src\main\res\values\dimens.xml
Error:Error: Found item Dimension/abc_alert_dialog_button_bar_height more than one time
Error:Execution failed for task ':app:mergeDebugResources'.
> C:\Users\davis\AndroidStudioProjects\tester\app\src\main\res\values\dimens.xml:
Error: Found item Dimension/abc_alert_dialog_button_bar_height more than one time
Information:BUILD FAILED
Information:Total time: 6.044 secs
Information:2 errors
Information:0 warnings
Information:See complete output in console
please suggest me any IDE or a Solution... | 0debug |
Select an element with Javascript : <p>Hey Stackoverflow developers, I have this code</p>
<pre><code> <div id="1"></div><div id="2"></div><div id="3"></div><div id="4"></div><div id="5"></div><br>
<div id="6"></div><div id="7"></div><div id="8"></div><div id="9"></div><div id="10"></div><br>
<div id="11"></div><div id="12"></div><div id="13"></div><div id="14"></div><div id="15"></div><br>
<div id="16"></div><div id="17"></div><div id="18"></div><div id="19"></div><div id="20"></div><br>
<div id="21"></div><div id="22"></div><div id="23"></div><div id="24"></div><div id="25"></div><br>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.11/p5.min.js"></script>
<script src="../sketch.js"></script>
<script>
document.getElementsByTagName("div")[0].addEventListener("click", displayDate);
function displayDate() {
this.style.backgroundColor = 'red';
}
</script>
</code></pre>
<p>I want to be able to click on a div and for <em>Javascript</em> (not jQuery) to change the background color of <em>only</em> the clicked div. I've tried everything. How do I do it?</p>
| 0debug |
static void qjson_register_types(void)
{
type_register_static(&qjson_type_info);
}
| 1threat |
Making Azure Virtual Machine VPN-Ready : <p>My company is integrating with this company to enable us both consume services built on each other's platform to provide joint services extended to external users.</p>
<p>They recently sent me a file containing their VPN configuration with spaces provided to enter ours as well. Now I am not so savvy about VPNs plus our server is hosted in an Azure VM (windows server 2012 R2). I don't know if our hosting arrangement is VPN-ready by default. How am I supposed to go about this?
Any helpful articles or guidance is a welcome boon at this time.</p>
<p>PS.
My knowledge on networking is next to nothing. Just know the basest of things there.</p>
| 0debug |
How to link push button and a new window by coding using QT? : First of all, I created about 20 push buttons using for loop. And named them using if else loop. Now, I want to connect each push buttons with the new dialog box. If I had used the design mode of QT, it would show me the name of the button when I press connect(ui->pushButton_0, SIGNAl(released()), SLOT(digit_pressed()) something like this. But, I don't know the name of the pushbutton I made as the for and if else loop made it. The connect(ui-> .......) also doesn't show any predictions. How can I link these push buttons and a new dialog box?
Here is my code:
**mainwindow.h**
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
private slots:
void on_pushButton_clicked();
};
#endif // MAINWINDOW_H
**mainwindow.cpp**
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPushButton>
#include <QVBoxLayout>
#include "amputation.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->)
QPixmap pix("/home/skanda/Desktop/D4564.png");
ui->label_2->setPixmap(pix);
setWindowTitle("First Aid");
QVBoxLayout *lay = new QVBoxLayout();
int i;
for(i=0;i<25;i++)
{
if(i==0){
QPushButton *button = new QPushButton("Amputation");
lay->addWidget(button);
}
else if(i==1){
QPushButton *button = new QPushButton("Asthama");
lay->addWidget(button);
}
else if(i==2){
QPushButton *button = new QPushButton("Bleeding");
lay->addWidget(button);
}
else if(i==3){
QPushButton *button = new QPushButton("Burns");
lay->addWidget(button);
}
else if(i==4){
QPushButton *button = new QPushButton("Chest Pain");
lay->addWidget(button);
}
else if(i==5){
QPushButton *button = new QPushButton("Diarrhoea");
lay->addWidget(button);
}
else if(i==6){
QPushButton *button = new QPushButton("Drowning");
lay->addWidget(button);
}
else if(i==7){
QPushButton *button = new QPushButton("Epilepsy");
lay->addWidget(button);
}
else if(i==8){
QPushButton *button = new QPushButton("Fainting");
lay->addWidget(button);
}
else if(i==9){
QPushButton *button = new QPushButton("Fever");
lay->addWidget(button);
}
else if(i==10){
QPushButton *button = new QPushButton("Food Poisoning");
lay->addWidget(button);
}
else if(i==11){
QPushButton *button = new QPushButton("Fracture");
lay->addWidget(button);
}
else if(i==12){
QPushButton *button = new QPushButton("Head Injury");
lay->addWidget(button);
}
else if(i==13){
QPushButton *button = new QPushButton("Muscle Strain");
lay->addWidget(button);
}
else if(i==14){
QPushButton *button = new QPushButton("No breathing");
lay->addWidget(button);
}
else if(i==15){
QPushButton *button = new QPushButton("Nose bleed");
lay->addWidget(button);
}
else if(i==16){
QPushButton *button = new QPushButton("Poisoning");
lay->addWidget(button);
}
else if(i==17){
QPushButton *button = new QPushButton("Snake Bites");
lay->addWidget(button);
}
else if(i==18){
QPushButton *button = new QPushButton("Stroke");
lay->addWidget(button);
}
else if(i==19) {
QPushButton *button = new QPushButton("Sun Burn");
lay->addWidget(button);
}
else if(i==20) {
QPushButton *button = new QPushButton("Testicle Pain");
lay->addWidget(button);
}
else if(i==21) {
QPushButton *button = new QPushButton("Ulcer");
lay->addWidget(button);
}
else if(i==22) {
QPushButton *button = new QPushButton("Child delievery");
lay->addWidget(button);
}
else if(i==23) {
QPushButton *button = new QPushButton("Heart Attack");
lay->addWidget(button);
}
else {
QPushButton *button = new QPushButton("Gastric");
lay->addWidget(button);
}
}
ui->scrollContents->setLayout(lay);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked(){
Amputation amp;
amp.setModal(true);
amp.show();
}
**In these codes, I have tried my luck by creating on_pushButton_clicked() function. But, it was just a try. **
| 0debug |
static void disas_test_b_imm(DisasContext *s, uint32_t insn)
{
unsigned int bit_pos, op, rt;
uint64_t addr;
int label_match;
TCGv_i64 tcg_cmp;
bit_pos = (extract32(insn, 31, 1) << 5) | extract32(insn, 19, 5);
op = extract32(insn, 24, 1);
addr = s->pc + sextract32(insn, 5, 14) * 4 - 4;
rt = extract32(insn, 0, 5);
tcg_cmp = tcg_temp_new_i64();
tcg_gen_andi_i64(tcg_cmp, cpu_reg(s, rt), (1ULL << bit_pos));
label_match = gen_new_label();
tcg_gen_brcondi_i64(op ? TCG_COND_NE : TCG_COND_EQ,
tcg_cmp, 0, label_match);
tcg_temp_free_i64(tcg_cmp);
gen_goto_tb(s, 0, s->pc);
gen_set_label(label_match);
gen_goto_tb(s, 1, addr);
}
| 1threat |
static int qxl_init_primary(PCIDevice *dev)
{
PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, dev);
VGACommonState *vga = &qxl->vga;
PortioList *qxl_vga_port_list = g_new(PortioList, 1);
int rc;
qxl->id = 0;
qxl_init_ramsize(qxl);
vga->vram_size_mb = qxl->vga.vram_size >> 20;
vga_common_init(vga, OBJECT(dev), true);
vga_init(vga, OBJECT(dev),
pci_address_space(dev), pci_address_space_io(dev), false);
portio_list_init(qxl_vga_port_list, OBJECT(dev), qxl_vga_portio_list,
vga, "vga");
portio_list_set_flush_coalesced(qxl_vga_port_list);
portio_list_add(qxl_vga_port_list, pci_address_space_io(dev), 0x3b0);
vga->con = graphic_console_init(DEVICE(dev), 0, &qxl_ops, qxl);
qemu_spice_display_init_common(&qxl->ssd);
rc = qxl_init_common(qxl);
if (rc != 0) {
return rc;
}
qxl->ssd.dcl.ops = &display_listener_ops;
qxl->ssd.dcl.con = vga->con;
register_displaychangelistener(&qxl->ssd.dcl);
return rc;
}
| 1threat |
Is there a way to write a lambda expression inside an IF with everything captured? : <p>It's my understanding that if I use the syntax [&] in a lambda expression, then my lambda expression has access to surrounding variables and parameters of the function.</p>
<p>Therefore, I tried to write the following (simplified) code</p>
<pre><code>if ( [&]()
{
bool b = false;
return b;
}
)
{
// Do something in TRUE part of if statement
}
</code></pre>
<p>but I get the error "Value of type 'lambda at...' is not contextually convertible to 'bool'</p>
<p>Would appreciate some insight into this issue.</p>
<p>Many thanks,
D</p>
| 0debug |
VueJS this in lodash throttled method : <p>I am trying to throttle a method in my VueJS application. I tried the following at first: </p>
<pre><code>export default {
data () {
return {
foo: 'bar'
}
},
methods: {
doSomething () {
console.log('olas')
}
},
created () {
_.throttle(this.doSomething,200)
}
}
</code></pre>
<p>But the <code>doSomething</code> method was just not fired: <a href="https://jsfiddle.net/z4peade0/" rel="noreferrer">https://jsfiddle.net/z4peade0/</a></p>
<p>Then, I tried this:</p>
<pre><code>export default {
data () {
return {
foo: 'bar'
}
},
methods: {
doSomething: _.throttle( () => {
console.log('olas')
},200)
},
created () {
this.doSomething()
}
}
</code></pre>
<p>And the functiong gets triggered: <a href="https://jsfiddle.net/z4peade0/1/" rel="noreferrer">https://jsfiddle.net/z4peade0/1/</a></p>
<p>Problem is, I can't access the <code>foo</code> property inside the throttled method: </p>
<pre><code>export default {
data () {
return {
foo: 'bar'
}
},
methods: {
doSomething: _.throttle( () => {
console.log(this.foo) // undefined
},200)
},
created () {
this.doSomething()
}
}
</code></pre>
<p>I tried to do something like:</p>
<pre><code>const self = {
...
methods: {
doSomething: _.throttle( () => {
console.log(self.foo)
},200)
},
...
}
export default self
</code></pre>
<p>without success</p>
<p><strong>How could I use lodash throttled method on a VueJS method, and using <code>this</code> context?</strong></p>
| 0debug |
Apple rejects app because it can't reach my ASP.NET API : I run my own VPS in Amsterdam where I have a MySQL database that is being populated and maintained using ASP.NET. It's a Windows Server.
I use this API for four of my existing Android apps (published and working) with a few thousand users who never had any issues connecting to the API through those apps. Recently I finished one of the apps on the iOS platform and it got rejected because Apple couldn't get it to load any content, or it would get stuck on loading without ever returning anything (after we implemented a loading progress animation). After a lot of messaging between me and Apple's review team, they ended up accepting my app to be passed through review even though they never got it to work (or so I believe, they just said they would re-review it and it suddenly got approved after 7 rejects). None of my friends, family or users ever experienced any issues like this on either Android or iOS.
A good friend of mine who did most of the work on the API is also from the USA, which makes me doubt it's a location problem.
I must note that pretty much 99.99% of my users are Dutch and all my projects are build for Dutch users.
Does anyone have experience or ideas in this field? I'm about to publish an update for the already published app and I'm afraid they will reject it because of the same issue.
The exact message I got at first was:
`Specifically, upon launch we found that the app failed to load any content.`
| 0debug |
static int protocol_client_init(VncState *vs, uint8_t *data, size_t len)
{
char buf[1024];
VncShareMode mode;
int size;
mode = data[0] ? VNC_SHARE_MODE_SHARED : VNC_SHARE_MODE_EXCLUSIVE;
switch (vs->vd->share_policy) {
case VNC_SHARE_POLICY_IGNORE:
break;
case VNC_SHARE_POLICY_ALLOW_EXCLUSIVE:
if (mode == VNC_SHARE_MODE_EXCLUSIVE) {
VncState *client;
QTAILQ_FOREACH(client, &vs->vd->clients, next) {
if (vs == client) {
continue;
}
if (client->share_mode != VNC_SHARE_MODE_EXCLUSIVE &&
client->share_mode != VNC_SHARE_MODE_SHARED) {
continue;
}
vnc_disconnect_start(client);
}
}
if (mode == VNC_SHARE_MODE_SHARED) {
if (vs->vd->num_exclusive > 0) {
vnc_disconnect_start(vs);
return 0;
}
}
break;
case VNC_SHARE_POLICY_FORCE_SHARED:
if (mode == VNC_SHARE_MODE_EXCLUSIVE) {
vnc_disconnect_start(vs);
return 0;
}
break;
}
vnc_set_share_mode(vs, mode);
if (vs->vd->num_shared > vs->vd->connections_limit) {
vnc_disconnect_start(vs);
return 0;
}
vs->client_width = pixman_image_get_width(vs->vd->server);
vs->client_height = pixman_image_get_height(vs->vd->server);
vnc_write_u16(vs, vs->client_width);
vnc_write_u16(vs, vs->client_height);
pixel_format_message(vs);
if (qemu_name)
size = snprintf(buf, sizeof(buf), "QEMU (%s)", qemu_name);
else
size = snprintf(buf, sizeof(buf), "QEMU");
vnc_write_u32(vs, size);
vnc_write(vs, buf, size);
vnc_flush(vs);
vnc_client_cache_auth(vs);
vnc_qmp_event(vs, QAPI_EVENT_VNC_INITIALIZED);
vnc_read_when(vs, protocol_client_msg, 1);
return 0;
}
| 1threat |
Find text in array use preg_match : <p>I have code :</p>
<pre><code>Array
(
[0] => Array
(
[Time] => 05/24/2016 05:24
[Type] => Income
[Batch] => 134410438
[Currency] => USD
[Amount] => 60.00
[Fee] => 0.00
[Payer Account] => 123213
[Payee Account] => 512321
[Memo] => ,Received Payment 60.00 USD from account 123213. Memo: API Payment. EXCHANGE755531.
)
</code></pre>
<p>How i can find text "EXCHANGE755531" in this array use preg_match ?</p>
| 0debug |
Keras: class weights (class_weight) for one-hot encoding : <p>I'd like to use class_weight argument in keras model.fit to handle the imbalanced training data. By looking at some documents, I understood we can pass a dictionary like this:</p>
<pre><code>class_weight = {0 : 1,
1: 1,
2: 5}
</code></pre>
<p>(In this example, class-2 will get higher penalty in the loss function.)</p>
<p>The problem is that my network's output has one-hot encoding i.e. class-0 = (1, 0, 0), class-1 = (0, 1, 0), and class-3 = (0, 0, 1).</p>
<p>How can we use the class_weight for one-hot encoded output?</p>
<p>By looking at <a href="https://github.com/fchollet/keras/blob/d89afdfd82e6e27b850d910890f4a4059ddea331/keras/engine/training.py#L1307" rel="noreferrer">some codes in Keras</a>, it looks like <code>_feed_output_names</code> contain a list of output classes, but in my case, <code>model.output_names</code>/<code>model._feed_output_names</code> returns <code>['dense_1']</code></p>
<p>Related: <a href="https://datascience.stackexchange.com/questions/13490/how-to-set-class-weights-for-imbalanced-classes-in-keras">How to set class weights for imbalanced classes in Keras?</a></p>
| 0debug |
static void qio_channel_websock_finalize(Object *obj)
{
QIOChannelWebsock *ioc = QIO_CHANNEL_WEBSOCK(obj);
buffer_free(&ioc->encinput);
buffer_free(&ioc->encoutput);
buffer_free(&ioc->rawinput);
buffer_free(&ioc->rawoutput);
object_unref(OBJECT(ioc->master));
if (ioc->io_tag) {
g_source_remove(ioc->io_tag);
}
if (ioc->io_err) {
error_free(ioc->io_err);
}
}
| 1threat |
void ff_put_h264_qpel8_mc10_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_hz_qrt_8w_msa(src - 2, stride, dst, stride, 8, 0);
}
| 1threat |
Use Create-React-App with Material UI : <p>I'm new to Material UI and ReactJS. I've been playing around with <a href="https://github.com/facebookincubator/create-react-app" rel="noreferrer">Create-React-App (CRA)</a> and <a href="https://github.com/reactstrap/reactstrap" rel="noreferrer">reactstrap</a>.
My question is, can I use Material UI and CRA together to build an app?</p>
| 0debug |
Python: Access members of a function from outside that function : <p>Say I had two functions, one belonging to another like so.</p>
<pre><code>def foo():
def bar():
print("im bar")
print("im foo and can call bar")
print("i can call foo, but not bar?")
</code></pre>
<p>How would refer to or call bar?
Would I do <code>foo.bar()</code>?</p>
<p>If <code>bar</code> were not a function like if <code>bar = 1</code> then how would I access that?</p>
<p>I'm aware I could move <code>bar</code> out of <code>foo</code> but is there any other way?</p>
| 0debug |
Insertion order in nested map c++ : <p>I currently have a nested <code>map< int, map < int, char > > m;</code>. I have 2 int values as keys for x,y coordinates and I save a char <code>m[x][y]='A'. I tried inserting the values into a vector</code>map< vector, map< vector, char> > m;` but didn't work. Is there a way to keep track of order of char saved to the map?</p>
| 0debug |
Difference between "ConstraintLayout for android" and "Solver for ConstraintLayout" in android studio SDK tools : <p>There is two option in android studio SDK tools for ConstraintLayout.One is <code>ConstraintLayout for android</code> and another is <code>Solver for ConstraintLayout</code>.</p>
<p>Here is the screenshot:
<a href="https://i.stack.imgur.com/i5hRh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/i5hRh.png" alt="enter image description here"></a></p>
<p>What is the difference between these two option?</p>
| 0debug |
static gboolean serial_xmit(GIOChannel *chan, GIOCondition cond, void *opaque)
{
SerialState *s = opaque;
do {
if (s->tsr_retry <= 0) {
if (s->fcr & UART_FCR_FE) {
if (fifo8_is_empty(&s->xmit_fifo)) {
return FALSE;
}
s->tsr = fifo8_pop(&s->xmit_fifo);
if (!s->xmit_fifo.num) {
s->lsr |= UART_LSR_THRE;
}
} else if ((s->lsr & UART_LSR_THRE)) {
return FALSE;
} else {
s->tsr = s->thr;
s->lsr |= UART_LSR_THRE;
s->lsr &= ~UART_LSR_TEMT;
}
}
if (s->mcr & UART_MCR_LOOP) {
serial_receive1(s, &s->tsr, 1);
} else if (qemu_chr_fe_write(s->chr, &s->tsr, 1) != 1) {
if (s->tsr_retry >= 0 && s->tsr_retry < MAX_XMIT_RETRY &&
qemu_chr_fe_add_watch(s->chr, G_IO_OUT|G_IO_HUP,
serial_xmit, s) > 0) {
s->tsr_retry++;
return FALSE;
}
s->tsr_retry = 0;
} else {
s->tsr_retry = 0;
}
} while ((s->fcr & UART_FCR_FE) && !fifo8_is_empty(&s->xmit_fifo));
s->last_xmit_ts = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
if (s->lsr & UART_LSR_THRE) {
s->lsr |= UART_LSR_TEMT;
s->thr_ipending = 1;
serial_update_irq(s);
}
return FALSE;
}
| 1threat |
How to show errors/warnings by hotkey in VSCode? : <p>I have to show errors/warnings by mouse now. Is there any hotkey or special button? I could find nothing in "Keyboard Shortcuts". Example of error:</p>
<p><a href="https://i.stack.imgur.com/FfNN8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FfNN8.png" alt=""></a></p>
| 0debug |
static void apic_common_class_init(ObjectClass *klass, void *data)
{
ICCDeviceClass *idc = ICC_DEVICE_CLASS(klass);
DeviceClass *dc = DEVICE_CLASS(klass);
dc->vmsd = &vmstate_apic_common;
dc->reset = apic_reset_common;
dc->no_user = 1;
dc->props = apic_properties_common;
idc->init = apic_init_common;
}
| 1threat |
how can i fix this Error in Wamp_Server? : <p><strong>I have problem in my wamp server . I dont know how to fix that . You can see the Error in photo ??</strong>
<a href="https://i.stack.imgur.com/xH0ES.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xH0ES.png" alt="enter image description here"></a></p>
<p><em>help me . Thanks</em></p>
| 0debug |
HTML - Text/Button Alignment (CSS Media) : <blockquote>
<p><a href="https://jsfiddle.net/5d401nso/1/" rel="nofollow noreferrer">https://jsfiddle.net/5d401nso/1/</a></p>
</blockquote>
<pre><code>#mobileview{
/*background-image:url("");
background-size:100% 100%;*/
width:auto;
height:auto;
}
@media(max-width: 768px){
#mobileview{
width:411px;
height:411px;
}
}
@media(max-width: 500px){
#mobileview{
width:411px;
height:411px;
}
}
</code></pre>
<p>Above is the jsfiddle that i have created.</p>
<blockquote>
<p>Current Problem: Not Supporting Mobile View and looking a ways to
change the text and button alignment from center to "left" when in
mobile view</p>
</blockquote>
<p>Solution That i wanted: When in mobile view ( max width 768px or 500px ), the text and button will align to left side instead of center.</p>
| 0debug |
UITabBarItem icon not colored correctly for iOS 13 when a bar tint color is specified in Interface Builder in Xcode 11, beta 2 : <p>I have a problem with the color of my UITabBarItems when I run on iOS 13 simulators, using Xcode 11, beta 2. I have made a sample project from scratch, and everything works correctly when I do not specify a bar tint color. However, when I do specify a custom bar tint color via Interface Builder, I get this:</p>
<p><a href="https://i.stack.imgur.com/W2YfC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/W2YfC.png" alt="Both selected an unselected item icons have highlight color"></a></p>
<p>All items icons in the tab bar have the selected color if I set the "Bar Tint" property in Interface Builder to anything but clear. When it is set to clear, the icons are colored properly. The icons are also colored properly if I compile and run in an iOS 12 simulator.</p>
<p>This seems like a bug in Xcode 11, but maybe I'm missing something?</p>
| 0debug |
static void qxl_log_cmd_draw_copy(PCIQXLDevice *qxl, QXLCopy *copy, int group_id)
{
fprintf(stderr, " src %" PRIx64,
copy->src_bitmap);
qxl_log_image(qxl, copy->src_bitmap, group_id);
fprintf(stderr, " area");
qxl_log_rect(©->src_area);
fprintf(stderr, " rop %d", copy->rop_descriptor);
}
| 1threat |
Python array program not giving correct output : <p>I am using below code for adding an element in array but it is giving me below error while running it</p>
<pre><code>cars = ["Ford", "Volvo", "BMW"]
cars.append("Honda")
cars[4] = "BMWq";
for x in cars:
print(x)
Output error
</code></pre>
<p>List assignment index out of range</p>
<p>Not able to understand reason of this error</p>
| 0debug |
How to read test files one by one in vb.net : i am working on a project in which i need to read text files in programs directory and check for specific keywords in it. Eg. A folder contains files with some name (not specific) and i want to read them one by one to check for specific string in them. until all are checked. ive been looking for method to read files like that but couldnt find any. | 0debug |
i want to use some arabic letters in card view as text in my android app : i want to use some arabic letters in card view as text in my android app , how to achieve this. Anyone please help me. | 0debug |
How to create DateTime from an int6] : The syntax of DateTime: it requires 6 arguments.`DateTime date1 = new DateTime(2008, 1, 1, 6, 32, 0);` If I have `int[] dr = new int[]{2008, 1, 1, 6, 32, 0};` How can I create the DateTime value using the int[] e.g. `DateTime date1 = new DateTime(dr);` ?
` | 0debug |
Why are generics needed when we can do casting to Object class? : <p>We have generics in java using which we can generalize a class.
I know that Object class is the parent class of every class.</p>
<p>When I can typecast to and from Object then why generics are needed?</p>
<pre><code>class Response<T>{
T data;
}
</code></pre>
<pre><code>class Response{
Object data;
}
</code></pre>
<p>Both of the above code snippets will work the same way.</p>
| 0debug |
Which classifier should I use for game automation? : <p>I suppose I have to pick one from this list:</p>
<p><a href="http://scikit-learn.org/stable/modules/scaling_strategies.html" rel="nofollow noreferrer">http://scikit-learn.org/stable/modules/scaling_strategies.html</a></p>
<p>As I need incremental learning.</p>
<p>I'm trying to get machine learning to learn how to play a simple NES game. I'm going to teach the machine some basic data from the game such as player x & y, enemy x & y, points etc.</p>
<p>Based on the data mentioned above the machine should predict which button to press.</p>
<p>So what classifier do you recommend for such project?</p>
| 0debug |
Is it functionally/ practically more efficient to create a CLI program that uses Console.Readline();, or args[i] for input? : <p>When creating a console based app, is it functionally more efficient/ practically more efficient to run off of command line start arguments than it is to use <code>Console.ReadLine();</code>? I have two options, open the program and have it listen to my commands via <code>ReadLine</code> in a console window, or I can use CMD like: <code>C:\MYPROGRAM argument</code> and have it take my commands this way. (think ping.exe for example)</p>
<p>I have used <code>string userCommand = Console.ReadLine();</code> along with <code>if</code> statements in order to control my program. I have also used <code>userCommand = args[x]</code> as a way to command my program from CMD.</p>
<p>Examples:</p>
<pre><code>string userCommand = Console.ReadLine();
if(userCommand == "help")
{
Console.WriteLine(help);
}
</code></pre>
<p>Or</p>
<pre><code>if(args[0] == "help")
{
Console.WriteLine(help);
}
</code></pre>
<p>Both of these methods are working for me, but I do not understand which of these is going to be more efficient in terms of speed/ performance. I also do not understand which one of these is practically a better solution. Is one of these superior to the other for any specific functional/ practical/ potential reason? Note: Google wasn't particularly helpful here.</p>
| 0debug |
There is a way to make a request every .txt file line? : <p>I'm doing a roblox name checker. Only except code works.</p>
<p>I've tried things like with open(...)as f:,etc.</p>
<pre class="lang-py prettyprint-override"><code>with open('usernames.txt') as f:
for line in f:
a=requests.get('https://api.roblox.com/users/get-by-username?username=%s' % line)
r=json.loads(a.content)
try:
if r["success"]== False:
print("Username avaliable ["+line+"]")
f=open("free.txt",'a')
f.write('n')
f.close()
except:
print("Username taken ["+line+"]")
file=open("taken.txt",'a')
file.write(line)
file.close()
</code></pre>
| 0debug |
static int applehttp_close(URLContext *h)
{
AppleHTTPContext *s = h->priv_data;
free_segment_list(s);
free_variant_list(s);
ffurl_close(s->seg_hd);
av_free(s);
return 0;
}
| 1threat |
static int get_cluster_offset(BlockDriverState *bs,
VmdkExtent *extent,
VmdkMetaData *m_data,
uint64_t offset,
bool allocate,
uint64_t *cluster_offset,
uint64_t skip_start_bytes,
uint64_t skip_end_bytes)
{
unsigned int l1_index, l2_offset, l2_index;
int min_index, i, j;
uint32_t min_count, *l2_table;
bool zeroed = false;
int64_t ret;
int64_t cluster_sector;
if (m_data) {
m_data->valid = 0;
}
if (extent->flat) {
*cluster_offset = extent->flat_start_offset;
return VMDK_OK;
}
offset -= (extent->end_sector - extent->sectors) * SECTOR_SIZE;
l1_index = (offset >> 9) / extent->l1_entry_sectors;
if (l1_index >= extent->l1_size) {
return VMDK_ERROR;
}
l2_offset = extent->l1_table[l1_index];
if (!l2_offset) {
return VMDK_UNALLOC;
}
for (i = 0; i < L2_CACHE_SIZE; i++) {
if (l2_offset == extent->l2_cache_offsets[i]) {
if (++extent->l2_cache_counts[i] == 0xffffffff) {
for (j = 0; j < L2_CACHE_SIZE; j++) {
extent->l2_cache_counts[j] >>= 1;
}
}
l2_table = extent->l2_cache + (i * extent->l2_size);
goto found;
}
}
min_index = 0;
min_count = 0xffffffff;
for (i = 0; i < L2_CACHE_SIZE; i++) {
if (extent->l2_cache_counts[i] < min_count) {
min_count = extent->l2_cache_counts[i];
min_index = i;
}
}
l2_table = extent->l2_cache + (min_index * extent->l2_size);
if (bdrv_pread(extent->file,
(int64_t)l2_offset * 512,
l2_table,
extent->l2_size * sizeof(uint32_t)
) != extent->l2_size * sizeof(uint32_t)) {
return VMDK_ERROR;
}
extent->l2_cache_offsets[min_index] = l2_offset;
extent->l2_cache_counts[min_index] = 1;
found:
l2_index = ((offset >> 9) / extent->cluster_sectors) % extent->l2_size;
cluster_sector = le32_to_cpu(l2_table[l2_index]);
if (m_data) {
m_data->valid = 1;
m_data->l1_index = l1_index;
m_data->l2_index = l2_index;
m_data->l2_offset = l2_offset;
m_data->l2_cache_entry = &l2_table[l2_index];
}
if (extent->has_zero_grain && cluster_sector == VMDK_GTE_ZEROED) {
zeroed = true;
}
if (!cluster_sector || zeroed) {
if (!allocate) {
return zeroed ? VMDK_ZEROED : VMDK_UNALLOC;
}
cluster_sector = extent->next_cluster_sector;
extent->next_cluster_sector += extent->cluster_sectors;
ret = get_whole_cluster(bs, extent, cluster_sector * BDRV_SECTOR_SIZE,
offset, skip_start_bytes, skip_end_bytes);
if (ret) {
return ret;
}
}
*cluster_offset = cluster_sector << BDRV_SECTOR_BITS;
return VMDK_OK;
}
| 1threat |
Returning fun messages to different injections : <p>I am developing an web application. Where there is an input box to track the orders and its open for anyone. I want to return funny messages if somebody tries to inject vulnerable scripts. For example, if anyone tries the old school trick</p>
<pre><code>' OR '1'='1
</code></pre>
<p>it may return <strong>'Seems you're a beginner! Please study more and try again'</strong>.
Will I have to check the inputs with RegEx ? or there is other nicer way? Anybody developed some scripts like this?</p>
| 0debug |
grab all observations from a data set that are present in a second data set based on a linker ID using %in% function R : <p>So, say I have two data sets: </p>
<pre><code>d1<- data.frame(seq(1:10),rnorm(10))
colnames(d1) <- c('id','x1')
d2<- data.frame(seq(3:7),rnorm(5))
colnames(d2) <- c('id','x2')
</code></pre>
<p>Now, say I want a new dataset, <code>d3</code>, that is the data from <code>d1</code> with values of <code>id</code> that are also present in <code>d2</code>. I'd like to use a really simple function, something like:</p>
<pre><code>d3 <- d1[id %in% d2$id]
</code></pre>
<p>Except this is printing an error for me. What is a simple one liner to accomplish this?</p>
| 0debug |
Make tab labels stretch to full width in material design for angular : <p>I would like to get tabs to stretch to the full width of their parent div. Anyone know how to do this?</p>
<pre><code><div class="tabs-header">
<mat-tab-group>
<mat-tab label="Signup">Content 1</mat-tab>
<mat-tab label="Login">Content 2</mat-tab>
</mat-tab-group>
</div>
</code></pre>
<p>As of now it looks like this:</p>
<p><a href="https://i.stack.imgur.com/Wxtic.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Wxtic.png" alt="enter image description here"></a></p>
<p>I did some research it looks like there used to be a way to do this with something like <code><md-stretch-tabs></code> but that doesn't seem to be a feature and there is no documentation on it.</p>
| 0debug |
Write something in .txt file using javascript : <p>How do I write something in a .txt file using javascript?</p>
<p>I created a variable holding a specific value and now I want to safe it into a .txt file</p>
| 0debug |
how can i add values with the same "account title" and display this in my gridview using vb.net / aspx : [This is the source grid view with a sql datasource named trialbalance][1]
[1]: http://i.stack.imgur.com/bA2jO.jpg
[Output gridview should look like this...][2]
[2]: http://i.stack.imgur.com/M9Qmd.jpg | 0debug |
How would I generate a random and unique title in cpp : <p>im kind of new to cpp coding. Anyway I was wondering how I would add random and unique titles to my program that change every time I open it, EG: If i sent a friend a file it might be called <strong>2377213</strong> the first time he opens it but then second time: <strong>234h234j23bg43v202</strong></p>
<p>So it's randomized
Would it be possible to do with this and if so how? </p>
<p><code>SetConsoleTitleA();</code></p>
| 0debug |
Detect AND, OR in the sentence and split it : <p>I have the following user queries:</p>
<pre><code>Boeing AND Airbus OR twitter
Boeing AND Airbus
</code></pre>
<p>I need to split words in them by AND, OR so, in the end, I will have something like this:</p>
<pre><code>"Boeing" AND "Airbus"
"Boeing" AND "Airbus" OR "twitter"
</code></pre>
<p>How can I do this with split or any other method? </p>
| 0debug |
I have 4 SQL tables that all i am using same primary key i need below condition SQL Quey : I have 4 [ client,clientmanager,Employee,project] tables in sql that all tables i am using primarykey for same (clientid) so i like to count list of projects,Employee,clients mangers using 'clientid " | 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.