problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
C# HTTP Reader get values from JSON format : <p>I have a C# application getting a string from an HTTP listener. The data is sent to my application in the JSON format, and I am trying to get the specific values.</p>
<p>Right now, I read the data sent to me using: </p>
<pre><code> HttpListenerContext context = listener.GetContext();
var request = context.Request;
string message;
using (var reader = new StreamReader(request.InputStream,
request.ContentEncoding))
{
message = reader.ReadToEnd();
}
</code></pre>
<p>The string message = { "message": "I've been shot!", "phoneNumber": "12345?", "position": "???", "anon": "???", "job": "ambulance" }</p>
<p>How would I go about getting these specific values and setting a string equal to the message, phonenumber, position, etc. Instead of just using the reader.ReadToEnd()</p>
<p>Thanks!</p>
| 0debug
|
void parse_numa_opts(MachineState *ms)
{
int i;
const CPUArchIdList *possible_cpus;
MachineClass *mc = MACHINE_GET_CLASS(ms);
for (i = 0; i < MAX_NODES; i++) {
numa_info[i].node_cpu = bitmap_new(max_cpus);
}
if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, ms, NULL)) {
exit(1);
}
assert(max_numa_nodeid <= MAX_NODES);
for (i = max_numa_nodeid - 1; i >= 0; i--) {
if (!numa_info[i].present) {
error_report("numa: Node ID missing: %d", i);
exit(1);
}
}
assert(nb_numa_nodes == max_numa_nodeid);
if (nb_numa_nodes > 0) {
uint64_t numa_total;
if (nb_numa_nodes > MAX_NODES) {
nb_numa_nodes = MAX_NODES;
}
for (i = 0; i < nb_numa_nodes; i++) {
if (numa_info[i].node_mem != 0) {
break;
}
}
if (i == nb_numa_nodes) {
assert(mc->numa_auto_assign_ram);
mc->numa_auto_assign_ram(mc, numa_info, nb_numa_nodes, ram_size);
}
numa_total = 0;
for (i = 0; i < nb_numa_nodes; i++) {
numa_total += numa_info[i].node_mem;
}
if (numa_total != ram_size) {
error_report("total memory for NUMA nodes (0x%" PRIx64 ")"
" should equal RAM size (0x" RAM_ADDR_FMT ")",
numa_total, ram_size);
exit(1);
}
for (i = 0; i < nb_numa_nodes; i++) {
QLIST_INIT(&numa_info[i].addr);
}
numa_set_mem_ranges();
if (!mc->cpu_index_to_instance_props || !mc->possible_cpu_arch_ids) {
error_report("default CPUs to NUMA node mapping isn't supported");
exit(1);
}
possible_cpus = mc->possible_cpu_arch_ids(ms);
for (i = 0; i < possible_cpus->len; i++) {
if (possible_cpus->cpus[i].props.has_node_id) {
break;
}
}
if (i == possible_cpus->len) {
for (i = 0; i < max_cpus; i++) {
CpuInstanceProperties props;
props = mc->cpu_index_to_instance_props(ms, i);
props.has_node_id = true;
set_bit(i, numa_info[props.node_id].node_cpu);
machine_set_cpu_numa_node(ms, &props, &error_fatal);
}
}
validate_numa_cpus();
if (have_numa_distance) {
validate_numa_distance();
complete_init_numa_distance();
}
} else {
numa_set_mem_node_id(0, ram_size, 0);
}
}
| 1threat
|
static void test_validate_struct_nested(TestInputVisitorData *data,
const void *unused)
{
UserDefTwo *udp = NULL;
Visitor *v;
v = validate_test_init(data, "{ 'string0': 'string0', "
"'dict1': { 'string1': 'string1', "
"'dict2': { 'userdef': { 'integer': 42, "
"'string': 'string' }, 'string': 'string2'}}}");
visit_type_UserDefTwo(v, NULL, &udp, &error_abort);
qapi_free_UserDefTwo(udp);
}
| 1threat
|
What is the easiest way to grab product description in WooCommerce programmatically? : I saw this, https://stackoverflow.com/questions/19763915/woocommerce-get-the-product-description-by-product-id
But I was hoping there's a shorter way to grab the product description? Any idea? I'm using WooCommerce 3.0 and above.
| 0debug
|
uint32_t virtio_config_readl(VirtIODevice *vdev, uint32_t addr)
{
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
uint32_t val;
k->get_config(vdev, vdev->config);
if (addr > (vdev->config_len - sizeof(val)))
return (uint32_t)-1;
val = ldl_p(vdev->config + addr);
return val;
}
| 1threat
|
static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *pkt)
{
DiracContext *s = avctx->priv_data;
DiracFrame *picture = data;
uint8_t *buf = pkt->data;
int buf_size = pkt->size;
int i, data_unit_size, buf_idx = 0;
for (i = 0; i < MAX_FRAMES; i++)
if (s->all_frames[i].avframe.data[0] && !s->all_frames[i].avframe.reference) {
avctx->release_buffer(avctx, &s->all_frames[i].avframe);
memset(s->all_frames[i].interpolated, 0, sizeof(s->all_frames[i].interpolated));
}
s->current_picture = NULL;
*data_size = 0;
if (buf_size == 0)
return get_delayed_pic(s, (AVFrame *)data, data_size);
for (;;) {
for (; buf_idx + DATA_UNIT_HEADER_SIZE < buf_size; buf_idx++) {
if (buf[buf_idx ] == 'B' && buf[buf_idx+1] == 'B' &&
buf[buf_idx+2] == 'C' && buf[buf_idx+3] == 'D')
break;
}
if (buf_idx + DATA_UNIT_HEADER_SIZE >= buf_size)
break;
data_unit_size = AV_RB32(buf+buf_idx+5);
if (buf_idx + data_unit_size > buf_size || !data_unit_size) {
if(buf_idx + data_unit_size > buf_size)
av_log(s->avctx, AV_LOG_ERROR,
"Data unit with size %d is larger than input buffer, discarding\n",
data_unit_size);
buf_idx += 4;
continue;
}
if (dirac_decode_data_unit(avctx, buf+buf_idx, data_unit_size))
{
av_log(s->avctx, AV_LOG_ERROR,"Error in dirac_decode_data_unit\n");
return -1;
}
buf_idx += data_unit_size;
}
if (!s->current_picture)
return 0;
if (s->current_picture->avframe.display_picture_number > s->frame_number) {
DiracFrame *delayed_frame = remove_frame(s->delay_frames, s->frame_number);
s->current_picture->avframe.reference |= DELAYED_PIC_REF;
if (add_frame(s->delay_frames, MAX_DELAY, s->current_picture)) {
int min_num = s->delay_frames[0]->avframe.display_picture_number;
av_log(avctx, AV_LOG_ERROR, "Delay frame overflow\n");
delayed_frame = s->delay_frames[0];
for (i = 1; s->delay_frames[i]; i++)
if (s->delay_frames[i]->avframe.display_picture_number < min_num)
min_num = s->delay_frames[i]->avframe.display_picture_number;
delayed_frame = remove_frame(s->delay_frames, min_num);
add_frame(s->delay_frames, MAX_DELAY, s->current_picture);
}
if (delayed_frame) {
delayed_frame->avframe.reference ^= DELAYED_PIC_REF;
*(AVFrame*)data = delayed_frame->avframe;
*data_size = sizeof(AVFrame);
}
} else if (s->current_picture->avframe.display_picture_number == s->frame_number) {
*(AVFrame*)data = s->current_picture->avframe;
*data_size = sizeof(AVFrame);
}
if (*data_size)
s->frame_number = picture->avframe.display_picture_number + 1;
return buf_idx;
}
| 1threat
|
Composer: how to know a package by what other package is required : <p>I've found <code>nesbo/carbon</code> in my <code>vendor</code> folder. It is a really useful library and I'm curious to know which other package I installed requires it.</p>
<p>How can I know this?</p>
| 0debug
|
Cakephp3: How can I return json data? : <p>I am having a ajax post call to a cakePhp Controller:</p>
<pre><code>$.ajax({
type: "POST",
url: 'locations/add',
data: {
abbreviation: $(jqInputs[0]).val(),
description: $(jqInputs[1]).val()
},
success: function (response) {
if(response.status === "success") {
// do something with response.message or whatever other data on success
console.log('success');
} else if(response.status === "error") {
// do something with response.message or whatever other data on error
console.log('error');
}
}
});
</code></pre>
<p>When I try this I get the following error message:</p>
<blockquote>
<p>Controller actions can only return Cake\Network\Response or null. </p>
</blockquote>
<p>Within the AppController I have this</p>
<pre><code>$this->loadComponent('RequestHandler');
</code></pre>
<p>enabled.</p>
<p>the Controller function looks like this:</p>
<pre><code>public function add()
{
$this->autoRender = false; // avoid to render view
$location = $this->Locations->newEntity();
if ($this->request->is('post')) {
$location = $this->Locations->patchEntity($location, $this->request->data);
if ($this->Locations->save($location)) {
//$this->Flash->success(__('The location has been saved.'));
//return $this->redirect(['action' => 'index']);
return json_encode(array('result' => 'success'));
} else {
//$this->Flash->error(__('The location could not be saved. Please, try again.'));
return json_encode(array('result' => 'error'));
}
}
$this->set(compact('location'));
$this->set('_serialize', ['location']);
}
</code></pre>
<p>What do I miss here? Is there any additional settings needed?</p>
| 0debug
|
static void mcf_fec_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
mcf_fec_state *s = (mcf_fec_state *)opaque;
switch (addr & 0x3ff) {
case 0x004:
s->eir &= ~value;
break;
case 0x008:
s->eimr = value;
break;
case 0x010:
if ((s->ecr & FEC_EN) && !s->rx_enabled) {
DPRINTF("RX enable\n");
mcf_fec_enable_rx(s);
}
break;
case 0x014:
if (s->ecr & FEC_EN) {
mcf_fec_do_tx(s);
}
break;
case 0x024:
s->ecr = value;
if (value & FEC_RESET) {
DPRINTF("Reset\n");
mcf_fec_reset(s);
}
if ((s->ecr & FEC_EN) == 0) {
s->rx_enabled = 0;
}
break;
case 0x040:
s->mmfr = value;
break;
case 0x044:
s->mscr = value & 0xfe;
break;
case 0x064:
break;
case 0x084:
s->rcr = value & 0x07ff003f;
break;
case 0x0c4:
s->tcr = value;
if (value & 1)
s->eir |= FEC_INT_GRA;
break;
case 0x0e4:
s->conf.macaddr.a[0] = value >> 24;
s->conf.macaddr.a[1] = value >> 16;
s->conf.macaddr.a[2] = value >> 8;
s->conf.macaddr.a[3] = value;
break;
case 0x0e8:
s->conf.macaddr.a[4] = value >> 24;
s->conf.macaddr.a[5] = value >> 16;
break;
case 0x0ec:
break;
case 0x118:
case 0x11c:
case 0x120:
case 0x124:
break;
case 0x144:
s->tfwr = value & 3;
break;
case 0x14c:
break;
case 0x150:
s->rfsr = (value & 0x3fc) | 0x400;
break;
case 0x180:
s->erdsr = value & ~3;
s->rx_descriptor = s->erdsr;
break;
case 0x184:
s->etdsr = value & ~3;
s->tx_descriptor = s->etdsr;
break;
case 0x188:
s->emrbr = value & 0x7f0;
break;
default:
hw_error("mcf_fec_write Bad address 0x%x\n", (int)addr);
}
mcf_fec_update(s);
}
| 1threat
|
static void pxa2xx_screen_dump(void *opaque, const char *filename)
{
}
| 1threat
|
Here are some codes in keras. I don't understand what "(x)" means : output_tensor = layers.Dense(10, activation='softmax')(x)
Here are some codes in keras. I don't understand what "(x)" means, can anybody help me ? Thanks a lot.
| 0debug
|
What is "e" in onChange(e)? : <p>I've been using it for quite some time but i still don't know - what is the <code>e</code> object you have access to when passing it over to <code>onChange</code> or <code>onSubmit</code>?</p>
| 0debug
|
static int dxtory_decode_v1_410(AVCodecContext *avctx, AVFrame *pic,
const uint8_t *src, int src_size)
{
int h, w;
uint8_t *Y1, *Y2, *Y3, *Y4, *U, *V;
int ret;
if (src_size < avctx->width * avctx->height * 9L / 8) {
av_log(avctx, AV_LOG_ERROR, "packet too small\n");
return AVERROR_INVALIDDATA;
}
avctx->pix_fmt = AV_PIX_FMT_YUV410P;
if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
return ret;
Y1 = pic->data[0];
Y2 = pic->data[0] + pic->linesize[0];
Y3 = pic->data[0] + pic->linesize[0] * 2;
Y4 = pic->data[0] + pic->linesize[0] * 3;
U = pic->data[1];
V = pic->data[2];
for (h = 0; h < avctx->height; h += 4) {
for (w = 0; w < avctx->width; w += 4) {
AV_COPY32(Y1 + w, src);
AV_COPY32(Y2 + w, src + 4);
AV_COPY32(Y3 + w, src + 8);
AV_COPY32(Y4 + w, src + 12);
U[w >> 2] = src[16] + 0x80;
V[w >> 2] = src[17] + 0x80;
src += 18;
}
Y1 += pic->linesize[0] << 2;
Y2 += pic->linesize[0] << 2;
Y3 += pic->linesize[0] << 2;
Y4 += pic->linesize[0] << 2;
U += pic->linesize[1];
V += pic->linesize[2];
}
return 0;
}
| 1threat
|
Kendo UI datepicker incompatible with Chrome 56 : <p>After updating Chrome to its last version 56.0.2924.76 (64-bit), our Kendo datepickers started not to work properly.</p>
<p>All datepickers were binded using ViewModels, and now they don't show their values. If we inspect them we see the value is set, but it's not been shown.</p>
<p>For example:</p>
<pre><code>@(Html.Kendo().DatePicker()
.Name("DateFrom")
.Start(CalendarView.Month)
.Depth(CalendarView.Month)
.Format("MM/dd/yyyy")
.HtmlAttributes(new { @id = "ClosingStartDate", @placeholder = "enter date from", @class = "masked-date" }))
</code></pre>
<p>If I inspect this element with Chrome's Developer tool I have this result:</p>
<pre><code><input class="k-input masked-date" id="ClosingStartDate" name="DateFrom" placeholder="enter date from" type="text" value="12/21/2016" data-role="datepicker" readonly="" disabled="disabled" maxlength="20" style="width: 100%;">
</code></pre>
<p><a href="https://i.stack.imgur.com/g1RLC.png">But it's show like this</a></p>
<p>When we bind property value with KnockOut all datepickers work fine.</p>
<p>Our Kendo version is: Kendo UI Complete v2012.2.913</p>
<p>Is there another way to bind it? What we should change using Chrome v.56?</p>
| 0debug
|
Getting full tweet text from "user_timeline" with tweepy : <p>I am using tweepy to fetch tweets from a user's timeline using the script included <a href="https://gist.github.com/yanofsky/5436496" rel="noreferrer">here</a>. However, the tweets are coming in truncated:</p>
<pre><code>auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_key, access_secret)
api = tweepy.API(auth)
new_tweets = api.user_timeline(screen_name = screen_name,count=200, full_text=True)
</code></pre>
<p>Returns:</p>
<pre><code>Status(contributors=None,
truncated=True,
text=u"#Hungary's new bill allows the detention of asylum seekers
&amp; push backs to #Serbia. We've seen push backs before so\u2026 https://
t.co/iDswEs3qYR",
is_quote_status=False,
...
</code></pre>
<p>That is, for some <code>i</code>, <code>new_tweets[i].text.encode("utf-8")</code> appears like</p>
<pre><code>#Hungary's new bill allows the detention of asylum seekers &amp;
push backs to #Serbia. We've seen push backs before so…https://t.co/
iDswEs3qYR
</code></pre>
<p>Where the <code>...</code> in the latter replaces text that would normally be displayed on Twitter.</p>
<p>Does anyone know how I can override <code>truncated=True</code> to get the full text on my request?</p>
| 0debug
|
How to initialize public Spinner array in Android : Why can't I initialize this Spinner array in this way? I need to access the content inside the array in another method not included here, that is why the array is declared public.
public class AnotherActivity extends AppCompatActivity{
public Spinner [] jobSites;
Spinner x, y;
@Override
protected void OnCreate(Bundle savedInstanceState){
x= findViewById(R.id.job1);
y= findViewById(R.id.job2);
jobSites = {x,y};
}
| 0debug
|
C# library for connecting different RDBMS : <p>I'm currently working on one project. I want to analyze a few things in the database, to see which is faster, more reliable, less resource-consuming.</p>
<p>I would like to create one program in C# and connect five databases. From that program, I will call the procedures and measure the time of execution.</p>
<p>Which library do I use in C# to connect: Microsoft SQL Server, Oracle, MySQL, PostgreSQL, IBM Db2 with Visual Studio?
I have found this library on the internet: <a href="http://dbnetdata.codeplex.com/" rel="nofollow noreferrer">http://dbnetdata.codeplex.com/</a>
Has anyone used it? Does anyone know about another library?</p>
| 0debug
|
I cant update composer.json in laravel 5.3 : I had issue when i add code "laravelcollective/html": "5.3.*" in composer.json, and then i try to update composer via command line in windows and show this in my command line.
PLEASE HELP ME GUYS, THANKS :))
https://i.stack.imgur.com/n4265.png
| 0debug
|
ReactJS - Lifting state up vs keeping a local state : <p>At my company we're migrating the front-end of a web application to ReactJS.
We are working with create-react-app (updated to v16), without Redux.
Now I'm stuck on a page which structure can be simplified by the following image:</p>
<p><a href="https://i.stack.imgur.com/B1gM0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/B1gM0.png" alt="Page structure"></a></p>
<p>The data displayed by the three components (SearchableList, SelectableList and Map) is retrieved with the same backend request in the <code>componentDidMount()</code> method of MainContainer. The result of this request is then stored in the state of MainContainer and has a structure more or less like this:</p>
<pre><code>state.allData = {
left: {
data: [ ... ]
},
right: {
data: [ ... ],
pins: [ ... ]
}
}
</code></pre>
<p>LeftContainer receives as prop <code>state.allData.left</code> from MainContainer and passes <code>props.left.data</code> to SearchableList, once again as prop.</p>
<p>RightContainer receives as prop <code>state.allData.right</code> from MainContainer and passes <code>props.right.data</code> to SelectableList and <code>props.right.pins</code> to Map.</p>
<p>SelectableList displays a checkbox to allow actions on its items. Whenever an action occur on an item of SelectableList component it may have side effects on Map pins.</p>
<p>I've decided to store in the state of RightContainer a list that keeps all the ids of items displayed by SelectableList; this list is passed as props to both SelectableList and Map. Then I pass to SelectableList a callback, that whenever a selection is made updates the list of ids inside RightContainer; new props arrive in both SelectableList and Map, and so <code>render()</code> is called in both components.</p>
<p>It works fine and helps to keep everything that may happen to SelectableList and Map inside RightContainer, but I'm asking if this is correct for the <strong>lifting-state-up</strong> and <strong>single-source-of-truth</strong> concepts.</p>
<p>As feasible alternative I thought of adding a <code>_selected</code> property to each item in <code>state.right.data</code> in MainContainer and pass the select callback three levels down to SelectableList, handling all the possible actions in MainContainer. But as soon as a selection event occurs this will eventually force the loading of LeftContainer and RightContainer, introducing the need of implementing logics like <code>shouldComponentUpdate()</code> to avoid useless <code>render()</code> especially in LeftContainer.</p>
<p><strong>Which is / could be the best solution to optimise this page from an architectural and performance point of view?</strong></p>
<p>Below you have an extract of my components to help you understand the situation.</p>
<p><strong>MainContainer.js</strong></p>
<pre><code>class MainContainer extends React.Component {
constructor(props) {
super(props);
this.state = {
allData: {}
};
}
componentDidMount() {
fetch( ... )
.then((res) => {
this.setState({
allData: res
});
});
}
render() {
return (
<div className="main-container">
<LeftContainer left={state.allData.left} />
<RightContainer right={state.allData.right} />
</div>
);
}
}
export default MainContainer;
</code></pre>
<p><strong>RightContainer.js</strong></p>
<pre><code>class RightContainer extends React.Component {
constructor(props) {
super(props);
this.state = {
selectedItems: [ ... ]
};
}
onDataSelection(e) {
const itemId = e.target.id;
// ... handle itemId and selectedItems ...
}
render() {
return (
<div className="main-container">
<SelectableList
data={props.right.data}
onDataSelection={e => this.onDataSelection(e)}
selectedItems={this.state.selectedItems}
/>
<Map
pins={props.right.pins}
selectedItems={this.state.selectedItems}
/>
</div>
);
}
}
export default RightContainer;
</code></pre>
<p>Thanks in advance!</p>
| 0debug
|
How to fix a css navigation flashing issue : <p>I have a react app using reactstrap(bootstrap4). I created a simple layout using react-router for the navigation. I cannot figure out why the navbar items flash when you click on one. I am using a built-in NavLink from react-router-dom that keeps the selected NavItem highlighted. </p>
<p>Here is link to the website
<a href="https://stardesigns.azurewebsites.net/" rel="noreferrer">Website</a></p>
<p>Header Component</p>
<pre><code>import {
Collapse,
Navbar,
NavbarToggler,
Nav,
NavItem,
NavbarBrand,
NavLink } from 'reactstrap'
import { NavLink as RRNavLink } from 'react-router-dom'
const Item = ({link, label}) => (
<NavItem>
<NavLink exact activeClassName='active-tab' to={link} tag={RRNavLink}>{label}</NavLink>
</NavItem>
)
const ROUTES = []
export default class extends React.Component {
render () {
return (
<div className='header-bkg'>
<Navbar color='faded' light expand='md'>
<NavbarBrand className='text-white'>Star Designs</NavbarBrand>
<NavbarToggler onClick={this._onToggle} />
<Collapse isOpen={this.state.isOpen} navbar>
<Nav className='ml-auto' navbar>
{ROUTES.map((x, i) => (
<Item key={i} {...x} />
))}
</Nav>
</Collapse>
</Navbar>
</div>
)
}
}
</code></pre>
<p>CSS</p>
<pre><code> .header-bkg {
box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.6), inset 0 -1px 1px rgba(0, 0, 0, 0.6), 0 0 5px rgba(0, 0, 0, 0.6);
border-top: 0 solid rgba(47, 46, 46, 1);
border-bottom: 0 solid rgba(47, 46, 46, 1);
background-color: #d7a29e;
}
.nav-link:hover,
.nav-link:active {
background-color: #ede9e2;
}
.nav-link {
text-transform: uppercase;
}
.active-tab {
background-color: #ede9e2;
}
:focus {
outline: -webkit-focus-ring-color auto 0;
}
@media (max-width: 575px) {
}
@media (max-width: 767px) {
}
@media (max-width: 991px) {
}
@media (max-width: 1199px) {
}
</code></pre>
| 0debug
|
The difference between (a -> Bool) and (a -> a -> Bool) in Haskell? : <p>I am currently learning Haskell and came across a type signature that confused me. </p>
<p>I know that:</p>
<pre><code>(a -> Bool)
</code></pre>
<p>Is how a predicate is assigned in the type signature when using (Ord a) but I came across a type signature that is declared as:</p>
<pre><code>(a -> a -> Bool)
</code></pre>
<p>Which according to what I found online is a type signature for inequalities but I am confused as to if they are for adding an inequality to a predicate, ie:</p>
<pre><code>(> p x == True)
</code></pre>
<p>Or if they are just to declare inequalities by themselves.</p>
<p>Thanks.</p>
| 0debug
|
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
| 1threat
|
Why does Enum.ToString not support precisision specifiers like "X2"? : Is there a specific reason, that `Enum.ToString(string)` does not support precision specifiers like `X2` or `D5`? I don't see why I have to explicitely cast it to `int` before being able to convert it to string.
public enum Number
{
Ten = 10
}
Console.WriteLine(Number.Ten); //OK: Ten
Console.WriteLine(Number.Ten.ToString()); //OK: Ten
Console.WriteLine(Number.Ten.ToString("D")); //OK: 10
Console.WriteLine(Number.Ten.ToString("D5")); //Expected 00010 - Failed: System.FormatException, can only be "G","g","X","x","F","f","D" or
Console.WriteLine(Number.Ten.ToString("X")); //OK: 0000000A
Console.WriteLine(Number.Ten.ToString("X2")); //Expected 0A - Failed: System.FormatException, can only be "G","g","X","x","F","f","D" or "d"
Console.WriteLine(10.ToString("X2")); //OK: 0A
Console.WriteLine(10.ToString("D5")); //OK: 00010
Console.WriteLine(((int)Number.Ten).ToString("X2"));//OK: 0A
| 0debug
|
Response MIME type for Spring Boot actuator endpoints : <p>I have updated a Spring Boot application from 1.4.x to 1.5.1 and the Spring Actuator endpoints return a different MIME type now:</p>
<p>For example, <code>/health</code> is now <code>application/vnd.spring-boot.actuator.v1+json</code> instead simply <code>application/json</code>.</p>
<p>How can I change this back?</p>
| 0debug
|
how to add a new c# file to a project using dotnet-cli : <p>I'm learning how to use dotnet-cli with VSCode. I've seen many commands on how to create solution, projects, add reference to projects... but I don't see anywhere in the documentation how to add a file. If remember, in RubyOnRails it was possible to add file from the command line. </p>
<p>Thanks for helping</p>
| 0debug
|
React Native: "Auto" width for text node : <p>I have a text element inside a view:</p>
<p><code><View><Text>hello world foo bar</Text></View></code></p>
<p>as part of a flex grid.</p>
<p>I want this view to have an auto width based on the content i.e. length of the text.</p>
<p>How do I achieve this?</p>
| 0debug
|
I am trying to open a file that is a json. and store it as an json object. : <p>I am trying to open a file that has a json extension and store it as an object. However, keep getting an error message that the file name was not declared in the scope. I'm new to working with json files. do you treat them differently than normal text files? </p>
<pre><code>#include "json.hpp"
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <string>
int main(int argc, char** argv) {
std::ifstream file;
file.open(test.json);
nlohmann::json jsonObject;
// Store the contents filename into jsonObject
if (file.is_open()) {
file >> jsonObject;
}
file.close();
}
</code></pre>
| 0debug
|
What Port Does AWS S3 Use? : <p>I have a question because of error which I Faced due to configs some other person made in aws :</p>
<p>Short Question is what port Does <strong>AWS S3</strong> use to communicate to ec2-instance ? </p>
| 0debug
|
int gdbserver_start(int port)
{
gdbserver_fd = gdbserver_open(port);
if (gdbserver_fd < 0)
return -1;
gdb_accept (NULL);
return 0;
}
| 1threat
|
Could not find method ndk() for arguments : <p>I'm following <a href="https://codelabs.developers.google.com/codelabs/android-studio-jni/index.html?index=..%2F..%2Findex#3" rel="noreferrer">Create Hello-JNI With Android Studio</a>.</p>
<p>MAC OX 10.11.5</p>
<p>Android Studio 2.2 stable</p>
<p>java version: 1.7.0_79</p>
<p>gradle-2.14.1</p>
<p>Here's my app.gradle:</p>
<pre><code>apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.chenql.helloandroidjni"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
ndk {
moduleName "hello-android-jni"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
testCompile 'junit:junit:4.12'
}
</code></pre>
<p>Here's the error:
<a href="https://i.stack.imgur.com/kBvXi.png" rel="noreferrer">The Error Message</a></p>
<pre><code>Error:(20, 0) Could not find method ndk() for arguments [build_13jh6qtzl4f08f8c1of3mvsys$_run_closure1$_closure5@5b127949] on project ':app' of type org.gradle.api.Project.
</code></pre>
<p>Open File</p>
| 0debug
|
Using limit in group by (SQL) : This is my table.
Financials:
Date
CountryID
ProductID
Revenue
Cost
I need to find the top 5 products by revenue for each country. Some products will be listed more than once, so I need to sum the revenue for each product.
SELECT Financials.CountryID, Financials.ProductID, sum(Financials.Revenue) as total
FROM Financials
INNER JOIN
(SELECT CountryID, GROUP_CONCAT(ProductID ORDER BY Revenue DESC) grouped_ID
FROM Financials
GROUP by CountryID) group_max
on Financials.CountryID = group_max.CountryID
AND FIND_IN_SET(ProductID, grouped_ID) BETWEEN 1 AND 6
GROUP BY Financials.ProductID
ORDER BY Financials.CountryID, total desc
This what I have so far. It isn't working. Help?
| 0debug
|
static int mov_write_int8_metadata(AVFormatContext *s, AVIOContext *pb,
const char *name, const char *tag,
int len)
{
AVDictionaryEntry *t = NULL;
uint8_t num;
if (!(t = av_dict_get(s->metadata, tag, NULL, 0)))
return 0;
num = t ? atoi(t->value) : 0;
avio_wb32(pb, len+8);
ffio_wfourcc(pb, name);
if (len==4) avio_wb32(pb, num);
else avio_w8 (pb, num);
return len+8;
}
| 1threat
|
Android M FingerprintManager.isHardwareDetected() returns false on a Samsung Galaxy S5 : <p>I have just updated a Verizion Samsung Galaxy S5 (SM-G900V) to the G900VVRU2DPD1 version via the manual instructions listed at <a href="http://www.androidofficer.com/2016/06/g900vvru2dpd1-android-601-marshmallow.html">http://www.androidofficer.com/2016/06/g900vvru2dpd1-android-601-marshmallow.html</a> </p>
<p>When I run the code below, isHardwareDetected() returns 'false'. I would expect it to return 'true'.</p>
<p>The Googling I have done does not resulted in any information one way or the other as to the S5 fingerprint reader being supported under Marshmallow.</p>
<p>Does anyone have any information about the S5's fingerprint reader being supported?</p>
<pre><code> FingerprintManager manager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
if (manager != null) {
if (ActivityCompat.checkSelfPermission(this, permission.USE_FINGERPRINT) !=
PackageManager.PERMISSION_GRANTED) {
retVal.append(INDENT).append("Fingerprint permission was not granted")
.append(EOL);
} else {
retVal.append(INDENT).append("Fingerprint hardware detected: ")
.append(manager.isHardwareDetected()).append(EOL);
retVal.append(INDENT).append("Has Enrolled Fingerprint(s): ")
.append(manager.hasEnrolledFingerprints()).append(EOL);
}
} else {
retVal.append(INDENT).append("no FingerprintManager available").append(EOL);
}
</code></pre>
| 0debug
|
jQuery 3.x child selector : <p>In jQuery 1.10.2 you could do <a href="http://api.jquery.com/child-selector/" rel="nofollow noreferrer">this.</a> </p>
<pre><code>$("parent > child")
</code></pre>
<p>Now in jQuery 3.1.1 this doesn't work...</p>
<p>Get this error: </p>
<pre><code>$("button[tooltip] ^ span")
jquery-3.1.1.min.js:2 Uncaught Error: Syntax error, unrecognized expression: button[tooltip] ^ span
at Function.ga.error (jquery-3.1.1.min.js:2)
at ga.tokenize (jquery-3.1.1.min.js:2)
at ga.select (jquery-3.1.1.min.js:2)
at Function.ga [as find] (jquery-3.1.1.min.js:2)
at r.fn.init.find (jquery-3.1.1.min.js:2)
at new r.fn.init (jquery-3.1.1.min.js:2)
at r (jquery-3.1.1.min.js:2)
at <anonymous>:1:1
</code></pre>
<p>What is the correct way to select child in jQuery 3.x?</p>
| 0debug
|
JS - document.createElement does not work : <p>I have the following code:</p>
<pre><code>function icon(link) {
var iccon = document.createElement('div');
var iccons = document.createElement('td');
iccon.setAttribute('id', 'icon');
icons.appendChild(iccons);
iccon.setAttribute('onclick', 'window.open("' + link + '");');
iccons.appendChild(iccon);
var icons = document.getElementById('icons');
};
</code></pre>
<p>The HTML code is <a href="http://codepen.io/bacas/pen/RGBvjW" rel="nofollow">here</a>.</p>
| 0debug
|
how to set or get value from cache in symfony2.8? : in my service.yml
cache:
class: Doctrine\Common\Cache\PhpFileCache
arguments: [%kernel.cache_dir%]
////////////////////
and in my controller
$cache = $this->get('cache');
if ($cache->fetch($cache_key) != NULL) {
///mycode
}
///////////////
my SilencedError is
1-include(\app\cache\dev\30\446f637472696e654e616d65737061636543616368654b65795b5d.doctrinecache.php): failed to open stream: No such file or directory
| 0debug
|
How to make a part of HTML file not updated under a certain condition : <p>I have a HTML file which is updated every 30 seconds. It is rendered by Jinja2 from a certain python file to pass variables. Is there any way to omit updating of some elements?</p>
<p>The code looks like that:</p>
<pre><code><html>
<head>
<title>My site</title>
<meta http-equiv="refresh" content="30">
<style>
b.value {
position: absolute;
border: 2px solid black;
text-align: center;
padding: 20px;
}
.head {
position: absolute;
}
</style>
</head>
<body>
<b class="value" style="left:920px;">{{ var1 }} %</b></h2>
<h3 style="padding-left:860px;padding-top:200px;"> Text 2: under me is the part I want to update only when the condition is true</h3>
{% if var2 != 0 %}
<b class="head" style="padding-left:900px;">{{ var2 }}</b>
{% endif %}
</body>
</html>
</code></pre>
<p>I want to refresh the variable <em>var2</em> only if it is not equal to 0 and not every 30s, as the rest of page is updated.</p>
<p>Thank you for the tips,
Kaki</p>
| 0debug
|
How to enable .NET Core 3 preview SDK in VS2019? : <p>I wanted to try out Blazor. I've installed .NET Core 3.0 preview 5 SDK, Blazor VS extension to enable project templates. I can create Blazor project, but I can't run it - I constantly get this notification.
<a href="https://i.stack.imgur.com/d3eBN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/d3eBN.png" alt="enter image description here"></a></p>
<p>In some tutorials I see that there should be a checkbox in VS options - to enable using of preview SDKs.</p>
<p>But it's not there in VS2019! Version is 16.1.1</p>
<p><a href="https://i.stack.imgur.com/TQST1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TQST1.png" alt="enter image description here"></a></p>
| 0debug
|
Explicit default constructors in C++17 : <p>In C++17, empty tag types in the standard library now have default constructors which are marked <code>explicit</code>, and are also <code>= default</code>. For example, <a href="http://en.cppreference.com/w/cpp/utility/piecewise_construct_t" rel="noreferrer"><code>std::piecewise_construct_t</code></a> is now defined as</p>
<pre><code>struct piecewise_construct_t { explicit piecewise_construct_t() = default; };
</code></pre>
<p>My question is simply, what is the reason for this change from C++14? What does an explicitly defaulted explicit default constructor (!) mean for an empty class?</p>
<p>(To avoid being marked as a dupe: <a href="https://stackoverflow.com/questions/2836939/purpose-of-explicit-default-constructors">this question</a> from 2010 asks about the purpose of explicit default constructors, but that was pre-C++11 and a long time ago now so things have likely changed. <a href="https://stackoverflow.com/questions/33522985/explicit-defaulted-default-constructor-and-aggregates">This question</a> is more recent, but the answer seems to suggest that aggregate initialization will be performed regardless of the presence of the defaulted constructor, so I'm curious as to the reason for this change in the latest standard.)</p>
| 0debug
|
Html File Input on Android 5.1.1 doesn't show gallery : <p>This is what I'we tried:</p>
<pre><code><input id="capture" name="capture" type="file" accept="image/*" capture="camera">
<input id="capture" name="capture" type="file" accept="image/*" capture>
<input id="capture" name="capture" type="file" accept="image/*;capture=camera">
<input id="capture" name="capture" type="file" accept="image/*;capture=camera" capture>
</code></pre>
<p>This is the user agent string: </p>
<blockquote>
<p><code>Mozilla/5.0+(Linux;+Android+5.1.1;+SM-J320FN+Build/LMY47V)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/53.0.2785.124+Mobile+Safari/537.36</code></p>
</blockquote>
<p>The problem i'm facing is that for some reason this android device goes directly to camera (opens camera), without showing any options to choose a file from the gallery or take a picture by using camera.</p>
<p>Any suggestion how to overcome this?</p>
| 0debug
|
How to reduce the size of RHEL/Centos/Fedora Docker image : <p>The base image from Red Hat is quite small, on the order of 196M for RHEL 7.4. However it tends to be missing a lot of the bits and pieces that are required by the products I want to build new images for.</p>
<p>The moment I do a "yum install Xxx" on top of it the image size blows out to by +500M-800M.</p>
<p>Is there a way to reduce the size of the image?</p>
| 0debug
|
Best framework to design cross-plat library : <p>I need to build a library(not an app) which can be used in iOS apps, Android apps, Web pages(and probably Windows apps later). The library exposes a function which accepts a few parameters, like for example, a <code>string topic</code>. The function accesses few device info, if applicable, like the advertising id of the device and queries the back-end service for data. Once the data is ready, the function invokes a callback/sends an Event back to the native application(iOS app/Android app/Web page) indicating that the data is ready along with the data. The data might be an object or a WebView. </p>
<p><code>void getTopVotedArticle(string topic)</code> </p>
<p>Which framework do you recommend?
Currently, I am considering using React Native. However, the documentation around the communication from native platform to RN components is very poor. Almost all the examples of RN assumes that an app or a part of the app is build using RN. Is it possible to build a library using RN which would satisfy the above requirement? Also, are there any examples of such libraries written using RN.
Please feel free to recommend any other approach/framework to use.</p>
| 0debug
|
I am getting a class, interface, or enum epected error in blue jay : I am using Blue Jay and want to just create a simple rectangle. I tried adding a class to use the method Canvas but it does not seem to work.
java.lang.Object;
java.awt.Component;
java.awt.Canvas;
/**
* Write a description of class test here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Canvas
{
// instance variables - replace the example below with your own
private int x;
/**
* Constructor for objects of class test
*/
public test()
{
// initialise instance variables
//Going to insert the code right here
}
/**
* An example of a method - replace this comment with your own
*
* @param y a sample parameter for a method
* @return the sum of x and y
*/
public int sampleMethod(int y)
{
// put your code here
return x + y;
}
}
| 0debug
|
Android. Is WorkManager running when app is closed? : <p>I want to schedule nightly database updates. So I use new Android WorkManager. My understanding is that once scheduled it will always run in the background independently from the app's lifecycle.
Is that right? My first tests show that Work is only being performed when the app is running.</p>
<pre><code>val locationWork = PeriodicWorkRequest.Builder(UpdateDatabaseWorker::class.java, 24, TimeUnit.HOURS)
.addTag("DATABASE_UPDATE_SERVICE")
.build()
WorkManager.getInstance().enqueue(locationWork)
</code></pre>
| 0debug
|
LIKE operator not working in SQL (MS-Access) : <pre><code>SELECT FirstName, LastName
FROM Customers
WHERE FirstName LIKE 'A%';
</code></pre>
<p>I am trying to extract all the customers whose name starts with A, but when I run this code, I get an empty query, although there are people whose name starts with A. </p>
| 0debug
|
How to removed pined marker and set it new location google javascript api : How to i clear the old pined `marker` location and place it on new location? Am using google javascript api map with autocomplete search. When i search for a location the marker will pin on the location in map, if i type new location it will add another `marker`, but i don't want it that way, i want it to add `marker` to new location and clear the old pined location.
Sample image
[![enter image description here][1]][1]
From the above image, i want only one green marker on current typed location, if location change it will be place only on new one not create multiple markers.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
var autocomplete;
var countryRestrict = {'country': 'us'};
var MARKER_PATH = 'https://developers.google.com/maps/documentation/javascript/images/marker_green';
var componentForm = {
route: 'long_name',
locality: 'long_name',
administrative_area_level_1: 'short_name',
country: 'long_name'
};
var initOptions = {
'current': {
center: {lat: 2.9248795999999997, lng: 101.63688289999999},
zoom: 15,
country: 'MY',
componentRestrictions: {'country': 'us'}
}
};
var customLabel = {
restaurant: {
label: 'R'
},
bar: {
label: 'B'
}
};
function initGoogleMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: initOptions['current'].zoom,
center: initOptions['current'].center,
mapTypeControl: false,
panControl: false,
zoomControl: false,
streetViewControl: false,
clickableIcons: false,
fullscreenControl: false
});
var input = document.getElementById('SeachLOcationToBuy');
autocomplete = new google.maps.places.Autocomplete(input);
autocomplete.bindTo('bounds', map);
/*map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);*/
autocomplete.setComponentRestrictions({'country': initOptions['current'].country});
var markerLetter = String.fromCharCode('A'.charCodeAt(0) + (1 % 26));
var markerIcon = MARKER_PATH + markerLetter + '.png';
var infoWindow = new google.maps.InfoWindow;
autocomplete.addListener('place_changed', function() {
var place = autocomplete.getPlace();
if (!place.geometry) {
return;
}
if (place.geometry.viewport) {
map.fitBounds(place.geometry.viewport);
} else {
map.setCenter(place.geometry.location);
map.setZoom(17);
}
var point = new google.maps.LatLng(place.geometry.location.lat(), place.geometry.location.lng());
var marker = new google.maps.Marker({
map: map,
position: point,
icon: markerIcon,
label: 'P'
});
fillInAddress(place);
document.getElementById('UpdateFoodAddress').disabled = false;
document.getElementById('full_address').value = input.value;
/*Set the position of the marker using the place ID and location.*/
marker.setPlace({
placeId: place.place_id,
location: place.geometry.location
});
marker.setVisible(true);
});
downloadUrl("_api/setGeoXmlLocation.php?geolocate=true", function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName('marker');
var counts = xml.documentElement.getElementsByTagName('counter')[0].childNodes[0];
Array.prototype.forEach.call(markers, function(markerElem) {
var id = markerElem.getAttribute('id');
var name = markerElem.getAttribute('name');
var logo = markerElem.getAttribute('logo');
var address = markerElem.getAttribute('address');
var type = markerElem.getAttribute('type');
var page = markerElem.getAttribute('page');
var point = new google.maps.LatLng(
parseFloat(markerElem.getAttribute('lat')),
parseFloat(markerElem.getAttribute('lng'))
);
var infowincontent = document.createElement('div');
var strong = document.createElement('strong');
var img = document.createElement('img');
var imgbox = document.createElement('div');
var br = document.createElement('br');
var span = document.createElement('span');
var text = document.createElement('text');
/*WINDOW*/
infowincontent.setAttribute("class", "app-map-info-window");
text.textContent = address;
infowincontent.appendChild(text);
var icon = customLabel[type] || {};
var marker = new google.maps.Marker({
map: map,
position: point,
label: icon.label
});
marker.addListener('click', function() {
infoWindow.setContent(infowincontent);
infoWindow.open(map, marker);
});
});
});
}
function fillInAddress(place) {
for (var component in componentForm) {
document.getElementById(component).value = '';
document.getElementById(component).disabled = false;
}
for (var i = 0; i < place.address_components.length; i++) {
var addressType = place.address_components[i].types[0];
if (componentForm[addressType]) {
var val = place.address_components[i][componentForm[addressType]];
document.getElementById(addressType).value = val;
}
}
}
function geolocate() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var geolocation = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
var circle = new google.maps.Circle({
center: geolocation,
radius: position.coords.accuracy
});
autocomplete.setBounds(circle.getBounds());
});
}
}
function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;
request.onreadystatechange = function() {
if (request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request, request.status);
}
};
request.open('GET', url, true);
request.send(null);
}
function doNothing(){
}
initGoogleMap();
<!-- language: lang-html -->
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAkkzv-gkVsQSAUDOjUdEBmXVqmaDphVjc&libraries=places&callback=initMap"></script>
<input id="SeachLOcationToBuy" class="map-form-control form-control" type="text" name="setMyNewAddress" placeholder="Enter your address" onFocus="geolocate()" value=""/>
<div class="PageBodyContainerMap">
<span class="container">
<span class="GeoMap">
<div id="map"></div>
<div id="infowindow-content">
<span id="place-name" class="title"></span><br>
Place ID <span id="place-id"></span><br>
<span id="place-address"></span>
</div>
</span>
</span>
</div>
<!-- end snippet -->
[1]: https://i.stack.imgur.com/jdIMy.png
| 0debug
|
static void usb_msd_command_complete(SCSIBus *bus, int reason, uint32_t tag,
uint32_t arg)
{
MSDState *s = DO_UPCAST(MSDState, dev.qdev, bus->qbus.parent);
USBPacket *p = s->packet;
if (tag != s->tag) {
fprintf(stderr, "usb-msd: Unexpected SCSI Tag 0x%x\n", tag);
}
if (reason == SCSI_REASON_DONE) {
DPRINTF("Command complete %d\n", arg);
s->residue = s->data_len;
s->result = arg != 0;
if (s->packet) {
if (s->data_len == 0 && s->mode == USB_MSDM_DATAOUT) {
usb_msd_send_status(s, p);
s->mode = USB_MSDM_CBW;
} else {
if (s->data_len) {
s->data_len -= s->usb_len;
if (s->mode == USB_MSDM_DATAIN)
memset(s->usb_buf, 0, s->usb_len);
s->usb_len = 0;
}
if (s->data_len == 0)
s->mode = USB_MSDM_CSW;
}
s->packet = NULL;
usb_packet_complete(&s->dev, p);
} else if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
}
return;
}
s->scsi_len = arg;
s->scsi_buf = s->scsi_dev->info->get_buf(s->scsi_dev, tag);
if (p) {
usb_msd_copy_data(s);
if (s->usb_len == 0) {
DPRINTF("Packet complete %p\n", p);
s->packet = NULL;
usb_packet_complete(&s->dev, p);
}
}
}
| 1threat
|
static int qemu_rdma_write_flush(QEMUFile *f, RDMAContext *rdma)
{
int ret;
if (!rdma->current_length) {
return 0;
}
ret = qemu_rdma_write_one(f, rdma,
rdma->current_index, rdma->current_addr, rdma->current_length);
if (ret < 0) {
return ret;
}
if (ret == 0) {
rdma->nb_sent++;
DDDPRINTF("sent total: %d\n", rdma->nb_sent);
}
rdma->current_length = 0;
rdma->current_addr = 0;
return 0;
}
| 1threat
|
Random like order with mysql and PHP : <p>I use PHP and Mysql. I have a table that looks kind of like this:</p>
<pre><code>id title
----------
1 my title
2 another title
3 The last title
</code></pre>
<p>Now I want to select them with a random like order.</p>
<ul>
<li>I will need to use LIMIT because of the query size.</li>
<li>The random like order should always be the same random order every time.</li>
</ul>
<h2>Example result, every time</h2>
<pre><code>3 The last title
1 my title
2 another title
</code></pre>
<p>Do another query run:</p>
<pre><code>3 The last title
1 my title
2 another title
</code></pre>
<p>The same random like result appear.</p>
<h2>Possible solutions</h2>
<ul>
<li>Add a real random number stored as a new column generated by insert.</li>
<li>Some fancy SELECT query that does some magic.</li>
<li>Something else?</li>
</ul>
<p>Why I want this is that I insert products, first from one site, then from another. In the result I want to present them as a mix.</p>
| 0debug
|
static void handle_port_status_write(EHCIState *s, int port, uint32_t val)
{
uint32_t *portsc = &s->portsc[port];
USBDevice *dev = s->ports[port].dev;
*portsc &= ~(val & PORTSC_RWC_MASK);
*portsc &= val | ~PORTSC_PED;
handle_port_owner_write(s, port, val);
val &= PORTSC_RO_MASK;
if ((val & PORTSC_PRESET) && !(*portsc & PORTSC_PRESET)) {
trace_usb_ehci_port_reset(port, 1);
}
if (!(val & PORTSC_PRESET) &&(*portsc & PORTSC_PRESET)) {
trace_usb_ehci_port_reset(port, 0);
if (dev) {
usb_attach(&s->ports[port], dev);
usb_send_msg(dev, USB_MSG_RESET);
*portsc &= ~PORTSC_CSC;
}
if (dev && (dev->speedmask & USB_SPEED_MASK_HIGH)) {
val |= PORTSC_PED;
}
}
*portsc &= ~PORTSC_RO_MASK;
*portsc |= val;
}
| 1threat
|
matroska_ebmlnum_uint (uint8_t *data,
uint32_t size,
uint64_t *num)
{
int len_mask = 0x80, read = 1, n = 1, num_ffs = 0;
uint64_t total;
if (size <= 0)
return AVERROR_INVALIDDATA;
total = data[0];
while (read <= 8 && !(total & len_mask)) {
read++;
len_mask >>= 1;
}
if (read > 8)
return AVERROR_INVALIDDATA;
if ((total &= (len_mask - 1)) == len_mask - 1)
num_ffs++;
if (size < read)
return AVERROR_INVALIDDATA;
while (n < read) {
if (data[n] == 0xff)
num_ffs++;
total = (total << 8) | data[n];
n++;
}
if (!total)
return AVERROR_INVALIDDATA;
if (read == num_ffs)
*num = (uint64_t)-1;
else
*num = total;
return read;
}
| 1threat
|
Modify Last item in list : <p>I have a <code>List<string, int></code> and I want to modify the int of the last Item.</p>
<p>How do I do this?</p>
<p>I've found the method <code>.Last<T></code> But I cant see how to use it.</p>
| 0debug
|
static int adb_mouse_poll(ADBDevice *d, uint8_t *obuf)
{
MouseState *s = ADB_MOUSE(d);
int dx, dy;
if (s->last_buttons_state == s->buttons_state &&
s->dx == 0 && s->dy == 0)
return 0;
dx = s->dx;
if (dx < -63)
dx = -63;
else if (dx > 63)
dx = 63;
dy = s->dy;
if (dy < -63)
dy = -63;
else if (dy > 63)
dy = 63;
s->dx -= dx;
s->dy -= dy;
s->last_buttons_state = s->buttons_state;
dx &= 0x7f;
dy &= 0x7f;
if (!(s->buttons_state & MOUSE_EVENT_LBUTTON))
dy |= 0x80;
if (!(s->buttons_state & MOUSE_EVENT_RBUTTON))
dx |= 0x80;
obuf[0] = dy;
obuf[1] = dx;
return 2;
}
| 1threat
|
ASAuthorizationAppleIDRequest with name and mail scope returns nil values : <p>I'm implementing Sign in with Apple and noticed that the <code>email</code> and <code>fullName</code> properties of the returned <code>ASAuthorizationAppleIDCredential</code> are only filled on the very first Sign-In for this Apple ID. On all subsequent Sign-Ins those properties are nil.</p>
<p>Is this a bug on iOS 13 or expected behaviour?</p>
<p>Here is the code I'm using to start the request:</p>
<pre><code>@available(iOS 13.0, *)
dynamic private func signInWithAppleClicked() {
let request = ASAuthorizationAppleIDProvider().createRequest()
request.requestedScopes = [.fullName, .email]
let controller = ASAuthorizationController(authorizationRequests: [request])
controller.delegate = self
controller.presentationContextProvider = self
controller.performRequests()
}
</code></pre>
<p>I'm receiving the credential in this delegate method:</p>
<pre><code>public func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
guard let credential = authorization.credential as? ASAuthorizationAppleIDCredential else { return }
let userIdentifier = credential.user
let token = credential.identityToken
let authCode = credential.authorizationCode
let realUserStatus = credential.realUserStatus
let mail = credential.email // nil
let name = credential.fullName // nil
}
</code></pre>
| 0debug
|
static void hda_audio_exit(HDACodecDevice *hda)
{
HDAAudioState *a = HDA_AUDIO(hda);
HDAAudioStream *st;
int i;
dprint(a, 1, "%s\n", __FUNCTION__);
for (i = 0; i < ARRAY_SIZE(a->st); i++) {
st = a->st + i;
if (st->node == NULL) {
continue;
}
if (st->output) {
AUD_close_out(&a->card, st->voice.out);
} else {
AUD_close_in(&a->card, st->voice.in);
}
}
AUD_remove_card(&a->card);
}
| 1threat
|
static int postcopy_start(MigrationState *ms, bool *old_vm_running)
{
int ret;
QIOChannelBuffer *bioc;
QEMUFile *fb;
int64_t time_at_stop = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
bool restart_block = false;
int cur_state = MIGRATION_STATUS_ACTIVE;
if (!migrate_pause_before_switchover()) {
migrate_set_state(&ms->state, MIGRATION_STATUS_ACTIVE,
MIGRATION_STATUS_POSTCOPY_ACTIVE);
}
trace_postcopy_start();
qemu_mutex_lock_iothread();
trace_postcopy_start_set_run();
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
*old_vm_running = runstate_is_running();
global_state_store();
ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
if (ret < 0) {
goto fail;
}
ret = migration_maybe_pause(ms, &cur_state,
MIGRATION_STATUS_POSTCOPY_ACTIVE);
if (ret < 0) {
goto fail;
}
ret = bdrv_inactivate_all();
if (ret < 0) {
goto fail;
}
restart_block = true;
qemu_savevm_state_complete_precopy(ms->to_dst_file, true, false);
if (migrate_postcopy_ram()) {
if (ram_postcopy_send_discard_bitmap(ms)) {
error_report("postcopy send discard bitmap failed");
goto fail;
}
}
qemu_file_set_rate_limit(ms->to_dst_file, INT64_MAX);
if (migrate_postcopy_ram()) {
qemu_savevm_send_ping(ms->to_dst_file, 2);
}
bioc = qio_channel_buffer_new(4096);
qio_channel_set_name(QIO_CHANNEL(bioc), "migration-postcopy-buffer");
fb = qemu_fopen_channel_output(QIO_CHANNEL(bioc));
object_unref(OBJECT(bioc));
qemu_savevm_send_postcopy_listen(fb);
qemu_savevm_state_complete_precopy(fb, false, false);
if (migrate_postcopy_ram()) {
qemu_savevm_send_ping(fb, 3);
}
qemu_savevm_send_postcopy_run(fb);
ret = qemu_file_get_error(ms->to_dst_file);
if (ret) {
error_report("postcopy_start: Migration stream errored (pre package)");
goto fail_closefb;
}
restart_block = false;
if (qemu_savevm_send_packaged(ms->to_dst_file, bioc->data, bioc->usage)) {
goto fail_closefb;
}
qemu_fclose(fb);
ms->postcopy_after_devices = true;
notifier_list_notify(&migration_state_notifiers, ms);
ms->downtime = qemu_clock_get_ms(QEMU_CLOCK_REALTIME) - time_at_stop;
qemu_mutex_unlock_iothread();
if (migrate_postcopy_ram()) {
qemu_savevm_send_ping(ms->to_dst_file, 4);
}
if (migrate_release_ram()) {
ram_postcopy_migrated_memory_release(ms);
}
ret = qemu_file_get_error(ms->to_dst_file);
if (ret) {
error_report("postcopy_start: Migration stream errored");
migrate_set_state(&ms->state, MIGRATION_STATUS_POSTCOPY_ACTIVE,
MIGRATION_STATUS_FAILED);
}
return ret;
fail_closefb:
qemu_fclose(fb);
fail:
migrate_set_state(&ms->state, MIGRATION_STATUS_POSTCOPY_ACTIVE,
MIGRATION_STATUS_FAILED);
if (restart_block) {
Error *local_err = NULL;
bdrv_invalidate_cache_all(&local_err);
if (local_err) {
error_report_err(local_err);
}
}
qemu_mutex_unlock_iothread();
return -1;
}
| 1threat
|
Create a heavy CSV line by line with R : <p>I'm working with Terabytes of memory and I have to create a CSV from another CSV of 15 GB but without some lines.
What I do to read the CSV is:
line <- readLines(con, n = 1)
each time I execute that function I get the next line but when I write them with writeLines(line, connection) each line overwrites the last one so I only get one line in the new CSV. Anyone know how to write the CSV line by line without overwriting?
Thanks</p>
| 0debug
|
R filtering table and inserting information : <p>I currently have following table structure</p>
<p><strong>Table1</strong></p>
<pre><code>id a
11 4
11 3
22 1
22 3
22 5
33 2
33 1
44 6
44 8
66 5
66 7
77 6
</code></pre>
<p><strong>Table2</strong></p>
<pre><code>id score
11 12
33 22
44 20
</code></pre>
<p>I want to delete every row from Table1, that does not contain any of the id in Table2$id. <code>unique(Table2$id)</code> should generate such an unique id list. Further, I need to write the <em>score</em> from Table2 into each corresponding id of Table1. The desired dataframe would be:</p>
<p><strong>Result</strong></p>
<pre><code>id a score
11 4 12
11 3 12
33 2 22
33 1 22
44 6 20
44 8 20
</code></pre>
| 0debug
|
static int read_channel_data(ALSDecContext *ctx, ALSChannelData *cd, int c)
{
GetBitContext *gb = &ctx->gb;
ALSChannelData *current = cd;
unsigned int channels = ctx->avctx->channels;
int entries = 0;
while (entries < channels && !(current->stop_flag = get_bits1(gb))) {
current->master_channel = get_bits_long(gb, av_ceil_log2(channels));
if (current->master_channel >= channels) {
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid master channel!\n");
return -1;
}
if (current->master_channel != c) {
current->time_diff_flag = get_bits1(gb);
current->weighting[0] = als_weighting(gb, 1, 16);
current->weighting[1] = als_weighting(gb, 2, 14);
current->weighting[2] = als_weighting(gb, 1, 16);
if (current->time_diff_flag) {
current->weighting[3] = als_weighting(gb, 1, 16);
current->weighting[4] = als_weighting(gb, 1, 16);
current->weighting[5] = als_weighting(gb, 1, 16);
current->time_diff_sign = get_bits1(gb);
current->time_diff_index = get_bits(gb, ctx->ltp_lag_length - 3) + 3;
}
}
current++;
entries++;
}
if (entries == channels) {
av_log(ctx->avctx, AV_LOG_ERROR, "Damaged channel data!\n");
return -1;
}
align_get_bits(gb);
return 0;
}
| 1threat
|
bool hbitmap_get(const HBitmap *hb, uint64_t item)
{
uint64_t pos = item >> hb->granularity;
unsigned long bit = 1UL << (pos & (BITS_PER_LONG - 1));
return (hb->levels[HBITMAP_LEVELS - 1][pos >> BITS_PER_LEVEL] & bit) != 0;
}
| 1threat
|
How to convert this code from vb6 to delphi : <pre><code>Private Sub acak ( )
Dim random As New Random ( )
Dim a, c, m, i, y As Byte
Dim x( ) As Byte = {0,1,2,3,4,5,6,7,8,9,10}
a = 5
c = 7
m = 8
x (0) = random.Next (1, 16)
For i = 1 To 16
x(i) = (a*x(i-1)+c) Mod m
If x(i) = 0 Then
y = i
End if
Next
Button1.Text = x(16)
acakbutton ()
</code></pre>
<p>End sub</p>
<p>Please help me because i can't use vb and i can't convert it because i'm still newbie</p>
| 0debug
|
static int mirror_do_read(MirrorBlockJob *s, int64_t sector_num,
int nb_sectors)
{
BlockBackend *source = s->common.blk;
int sectors_per_chunk, nb_chunks;
int ret = nb_sectors;
MirrorOp *op;
sectors_per_chunk = s->granularity >> BDRV_SECTOR_BITS;
nb_sectors = MIN(s->buf_size >> BDRV_SECTOR_BITS, nb_sectors);
assert(nb_sectors);
if (s->cow_bitmap) {
ret += mirror_cow_align(s, §or_num, &nb_sectors);
}
assert(nb_sectors << BDRV_SECTOR_BITS <= s->buf_size);
assert(!(sector_num % sectors_per_chunk));
nb_chunks = DIV_ROUND_UP(nb_sectors, sectors_per_chunk);
while (s->buf_free_count < nb_chunks) {
trace_mirror_yield_in_flight(s, sector_num, s->in_flight);
mirror_wait_for_io(s);
}
op = g_new(MirrorOp, 1);
op->s = s;
op->sector_num = sector_num;
op->nb_sectors = nb_sectors;
qemu_iovec_init(&op->qiov, nb_chunks);
while (nb_chunks-- > 0) {
MirrorBuffer *buf = QSIMPLEQ_FIRST(&s->buf_free);
size_t remaining = nb_sectors * BDRV_SECTOR_SIZE - op->qiov.size;
QSIMPLEQ_REMOVE_HEAD(&s->buf_free, next);
s->buf_free_count--;
qemu_iovec_add(&op->qiov, buf, MIN(s->granularity, remaining));
}
s->in_flight++;
s->sectors_in_flight += nb_sectors;
trace_mirror_one_iteration(s, sector_num, nb_sectors);
blk_aio_preadv(source, sector_num * BDRV_SECTOR_SIZE, &op->qiov,
nb_sectors * BDRV_SECTOR_SIZE,
mirror_read_complete, op);
return ret;
}
| 1threat
|
Should Comparable ever compare to another type? : <p>I'm wondering if there's ever a valid use case for the following:</p>
<pre><code>class Base {}
class A implements Comparable<Base> {
//...
}
</code></pre>
<p>It seems to be a common pattern (see <a href="https://docs.oracle.com/javase/8/docs/api/java/util/Collections.html" rel="noreferrer">Collections</a> for a number of examples) to accept a collection of type <code>T</code>, where <code>T extends Comparable<? super T></code>.</p>
<p>But it seems technically impossible to fulfill the contract of <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Comparable.html#compareTo-T-" rel="noreferrer"><code>compareTo()</code></a> when comparing to a base class, because there's no way to ensure that another class doesn't extend the base with a contradictory comparison. Consider the following example:</p>
<pre><code>class Base {
final int foo;
Base(int foo) {
this.foo = foo;
}
}
class A extends Base implements Comparable<Base> {
A(int foo) {
super(foo);
}
public int compareTo(Base that) {
return Integer.compare(this.foo, that.foo); // sort by foo ascending
}
}
class B extends Base implements Comparable<Base> {
B(int foo) {
super(foo);
}
public int compareTo(Base that) {
return -Integer.compare(this.foo, that.foo); // sort by foo descending
}
}
</code></pre>
<p>We have two classes extending <code>Base</code> using comparisons that don't follow a common rule (if there were a common rule, it would almost certainly be implemented in <code>Base</code>). Yet the following broken sort will compile:</p>
<pre><code>Collections.sort(Arrays.asList(new A(0), new B(1)));
</code></pre>
<p>Wouldn't it be safer to only accept <code>T extends Comparable<T></code>? Or is there some use case that would validate the wildcard?</p>
| 0debug
|
alert('Hello ' + user_input);
| 1threat
|
must call Vue.use(Vuex) before creating a store instance : <p>I cant't figure out why I am getting this error. Everything looks properly.
Import store to the component like this.</p>
<pre><code>import store from './store';
new Vue({
components: {
SomeComponent
},
store
});
</code></pre>
<p>My store looks like this </p>
<pre><code>import Vue from 'vue';
import Vuex from 'vuex';
import * as getters from './getters';
import * as actions from './actions';
import mutations from './mutations';
Vue.use(Vuex);
export default new Vuex.Store({
state: {
something
}
})
</code></pre>
<p>Please any help.
Thanks </p>
<blockquote>
<p>Uncaught Error: [vuex] must call Vue.use(Vuex) before creating a store instance. </p>
</blockquote>
| 0debug
|
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def max_height(node):
if node is None:
return 0 ;
else :
left_height = max_height(node.left)
right_height = max_height(node.right)
if (left_height > right_height):
return left_height+1
else:
return right_height+1
| 0debug
|
static void ibm_40p_init(MachineState *machine)
{
CPUPPCState *env = NULL;
uint16_t cmos_checksum;
PowerPCCPU *cpu;
DeviceState *dev;
SysBusDevice *pcihost;
Nvram *m48t59 = NULL;
PCIBus *pci_bus;
ISABus *isa_bus;
void *fw_cfg;
int i;
uint32_t kernel_base = 0, initrd_base = 0;
long kernel_size = 0, initrd_size = 0;
char boot_device;
if (!machine->cpu_model) {
machine->cpu_model = "604";
}
cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, machine->cpu_model));
if (!cpu) {
error_report("could not initialize CPU '%s'",
machine->cpu_model);
exit(1);
}
env = &cpu->env;
if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
error_report("only 6xx bus is supported on this machine");
exit(1);
}
if (env->flags & POWERPC_FLAG_RTC_CLK) {
cpu_ppc_tb_init(env, 7812500UL);
} else {
cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
}
qemu_register_reset(ppc_prep_reset, cpu);
dev = qdev_create(NULL, "raven-pcihost");
if (!bios_name) {
bios_name = BIOS_FILENAME;
}
qdev_prop_set_string(dev, "bios-name", bios_name);
qdev_prop_set_uint32(dev, "elf-machine", PPC_ELF_MACHINE);
pcihost = SYS_BUS_DEVICE(dev);
object_property_add_child(qdev_get_machine(), "raven", OBJECT(dev), NULL);
qdev_init_nofail(dev);
pci_bus = PCI_BUS(qdev_get_child_bus(dev, "pci.0"));
if (!pci_bus) {
error_report("could not create PCI host controller");
exit(1);
}
dev = DEVICE(pci_create_simple(pci_bus, PCI_DEVFN(11, 0), "i82378"));
qdev_connect_gpio_out(dev, 0,
cpu->env.irq_inputs[PPC6xx_INPUT_INT]);
sysbus_connect_irq(pcihost, 0, qdev_get_gpio_in(dev, 15));
sysbus_connect_irq(pcihost, 1, qdev_get_gpio_in(dev, 13));
sysbus_connect_irq(pcihost, 2, qdev_get_gpio_in(dev, 15));
sysbus_connect_irq(pcihost, 3, qdev_get_gpio_in(dev, 13));
isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
dev = DEVICE(isa_create(isa_bus, "rs6000-mc"));
qdev_prop_set_uint32(dev, "ram-size", machine->ram_size);
qdev_init_nofail(dev);
cmos_checksum = 0x6aa9;
qbus_walk_children(BUS(isa_bus), prep_set_cmos_checksum, NULL, NULL, NULL,
&cmos_checksum);
if (defaults_enabled()) {
isa_create_simple(isa_bus, "i8042");
m48t59 = NVRAM(isa_create_simple(isa_bus, "isa-m48t59"));
dev = DEVICE(isa_create(isa_bus, "cs4231a"));
qdev_prop_set_uint32(dev, "iobase", 0x830);
qdev_prop_set_uint32(dev, "irq", 10);
qdev_init_nofail(dev);
dev = DEVICE(isa_create(isa_bus, "pc87312"));
qdev_prop_set_uint32(dev, "config", 12);
qdev_init_nofail(dev);
dev = DEVICE(isa_create(isa_bus, "prep-systemio"));
qdev_prop_set_uint32(dev, "ibm-planar-id", 0xfc);
qdev_prop_set_uint32(dev, "equipment", 0xc0);
qdev_init_nofail(dev);
pci_create_simple(pci_bus, PCI_DEVFN(1, 0), "lsi53c810");
pci_vga_init(pci_bus);
for (i = 0; i < nb_nics; i++) {
pci_nic_init_nofail(&nd_table[i], pci_bus, "pcnet",
i == 0 ? "3" : NULL);
}
}
fw_cfg = fw_cfg_init_mem(CFG_ADDR, CFG_ADDR + 2);
if (machine->kernel_filename) {
kernel_base = KERNEL_LOAD_ADDR;
kernel_size = load_image_targphys(machine->kernel_filename,
kernel_base,
machine->ram_size - kernel_base);
if (kernel_size < 0) {
error_report("could not load kernel '%s'",
machine->kernel_filename);
exit(1);
}
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
if (machine->initrd_filename) {
initrd_base = INITRD_LOAD_ADDR;
initrd_size = load_image_targphys(machine->initrd_filename,
initrd_base,
machine->ram_size - initrd_base);
if (initrd_size < 0) {
error_report("could not load initial ram disk '%s'",
machine->initrd_filename);
exit(1);
}
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_base);
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size);
}
if (machine->kernel_cmdline && *machine->kernel_cmdline) {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE,
machine->kernel_cmdline);
fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA,
machine->kernel_cmdline);
fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE,
strlen(machine->kernel_cmdline) + 1);
}
boot_device = 'm';
} else {
boot_device = machine->boot_order[0];
}
fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)machine->ram_size);
fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_PREP);
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width);
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height);
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled());
if (kvm_enabled()) {
#ifdef CONFIG_KVM
uint8_t *hypercall;
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq());
hypercall = g_malloc(16);
kvmppc_get_hypercall(env, hypercall, 16);
fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid());
#endif
} else {
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, NANOSECONDS_PER_SECOND);
}
fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, boot_device);
qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
if (m48t59) {
PPC_NVRAM_set_params(m48t59, NVRAM_SIZE, "PREP", ram_size,
boot_device,
kernel_base, kernel_size,
machine->kernel_cmdline,
initrd_base, initrd_size,
0,
graphic_width, graphic_height, graphic_depth);
}
}
| 1threat
|
Placing the equal sign (=) when merging the data frame and final writing the file writeLines or write.table : <p>I have a data frame given below. there 29 variables and its values. I want to write it with <code>write.table</code> or <code>writeLine</code>, but I want to place the equal sign <code>(=)</code> between them.</p>
<pre><code> Variable 2
1 HYDRUS_Version 4
2 WaterFlow 0
3 SoluteTransport 0
4 Unsatchem 0
5 Unsatchem 0
6 HP1 0
7 HeatTransport 0
8 EquilibriumAdsorption 0
9 MobileImmobile 0
10 RootWaterUptake 0
11 RootGrowth 0
12 MaterialNumbers 0
13 SubregionNumbers 0
14 SpaceUnit cm
15 TimeUnit days
16 PrintTimes 160
17 NumberOfSolutes 0
18 InitialCondition 1
19 NumberOfNodes 101
20 ProfileDepth 120
21 ObservationNodes 160
22 GridVisible 160
23 SnapToGrid 160
24 ProfileWidth 160
25 LeftMargin 160
26 GridOrgX 160
27 GridOrgY 160
28 GridDX 160
29 GridDY 160
</code></pre>
<p>I need output like this in text file.</p>
<pre><code>HYDRUS_Version=4
WaterFlow=0
SoluteTransport=0
Unsatchem=0
Unsatchem=0
HP1=0
HeatTransport=0
EquilibriumAdsorption=0
MobileImmobile=0
RootWaterUptake=0
RootGrowth=0
MaterialNumbers=0
SubregionNumbers=0
SpaceUnit=cm
TimeUnit=days
PrintTimes=160
NumberOfSolutes=0
InitialCondition=1
NumberOfNodes=101
ProfileDepth=120
ObservationNodes=160
GridVisible=160
SnapToGrid=160
ProfileWidth=160
LeftMargin=160
GridOrgX=160
GridOrgY=160
GridDX=160
GridDY=160
</code></pre>
<p>further I will will split this file into parts and write some characters between these two parts and will get the final <code>.txt</code> file.</p>
| 0debug
|
swift "Backslash" how to use it : there are some code:
let noteNamesWithSharps = ["C", "C♯", "D", "D♯", "E", "F", "F♯", "G", "G♯", "A", "A♯", "B"]
let randomIndex = Int(arc4random_uniform(UInt32(noteNamesWithSharps.count)))
lhsinterval.text = "Backslash(noteNamesWithSharps[randomIndex])"
i am a beginner to learn swift, Backslash in swift is use for what?
thanks a lot
| 0debug
|
convert associate array to normal array : <p>This is my array </p>
<pre><code>$array = array(
1 => 'A',
2 => 'B',
3 => 'C',
4 => 'D',
5 => 'E',
);
</code></pre>
<p>I want to Convert it like this </p>
<pre><code>array('A','B','C','D','E');
</code></pre>
| 0debug
|
How to concatenate a table resulting from a query into another temporary table on a procedure stored on mysql ? : I have a temporary query, e.g :
CREATE TEMPORARY TABLE IF NOT EXISTS table4 AS (select * from table1)
and then, i have a another table resulting from a query, like:
select column from table2
what I would to do is to concatenated this column as a new column on the temparary table. Inner join would not work because they dont have a commom column
This would be like the concatenate() on python with axis=0.
I would appreciate any help
| 0debug
|
populate with mongoose pagination : <p>i tried to fetch data using <code>npm</code> <code>mongoose-paginate</code> but populate is not working </p>
<p>here is my <code>UsersSchema.js</code></p>
<pre><code>var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var usersSchema = new Schema({
name : String,
created_at : { type : Date, default : Date.now }
});
module.exports = mongoose.model('users',usersSchema);
</code></pre>
<p><strong>here is post schema</strong></p>
<pre><code>var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var mongoosePaginate = require('mongoose-paginate');
var postsSchema = new Schema({
user : { type: Schema.Types.ObjectId, ref: 'users' },
post : String,
created_at : { type : Date, default : Date.now }
});
postsSchema.plugin(mongoosePaginate);
module.exports = mongoose.model('posts',postsSchema);
</code></pre>
<p><strong>here is my query</strong> </p>
<pre><code>var options = {
sort: { created_at: -1 },
lean: true,
offset: offset,
populate : 'users',
limit: 10
};
postsSchema.paginate({user:user},options,function(err,posts){
if(err){
console.log(err)
return false;
}
console.log(posts)
});
</code></pre>
<p>user provide objectID not a users data.
i.e </p>
<pre><code>[{
user : objectID(987654ff11aa),
post : 'post'
}]
</code></pre>
| 0debug
|
ImageMagick path error on Sierra (beta) : <p>I'm trying to put watermark on iOS app's appIcon. For that I'm following <a href="https://www.raywenderlich.com/105641/change-app-icon-build-time">Ray's</a> blog and I installed ImageMagick using binary release from <a href="http://www.imagemagick.org/script/binary-releases.php#macosx">here</a>. I also added <strong>/bin</strong> and <strong>/lib</strong> in my paths using <code>sudo nano /etc/paths</code> so convert command seems to be working. </p>
<p>The problem statement:
when I use <strong>convert</strong> command from tutorial I get the following error</p>
<pre><code>dyld: Library not loaded: /ImageMagick-7.0.1/lib/libMagickCore-7.Q16HDRI.0.dylib
Referenced from: /Users/Username/Library/ImageMagick-7.0.1/bin/convert
Reason: image not found
Abort trap: 6
</code></pre>
<p>Even though the image is there the error is "image not found." Any idea community ?</p>
| 0debug
|
static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
{
ARMCPU *cpu = s->cpu;
uint32_t val;
switch (offset) {
case 4:
return ((s->num_irq - NVIC_FIRST_IRQ) / 32) - 1;
case 0xd00:
return cpu->midr;
case 0xd04:
val = cpu->env.v7m.exception;
val |= (s->vectpending & 0xff) << 12;
if (nvic_isrpending(s)) {
val |= (1 << 22);
}
if (nvic_rettobase(s)) {
val |= (1 << 11);
}
if (s->vectors[ARMV7M_EXCP_SYSTICK].pending) {
val |= (1 << 26);
}
if (s->vectors[ARMV7M_EXCP_PENDSV].pending) {
val |= (1 << 28);
}
if (s->vectors[ARMV7M_EXCP_NMI].pending) {
val |= (1 << 31);
}
return val;
case 0xd08:
return cpu->env.v7m.vecbase[attrs.secure];
case 0xd0c:
return 0xfa050000 | (s->prigroup << 8);
case 0xd10:
return 0;
case 0xd14:
return cpu->env.v7m.ccr;
case 0xd24:
val = 0;
if (s->vectors[ARMV7M_EXCP_MEM].active) {
val |= (1 << 0);
}
if (s->vectors[ARMV7M_EXCP_BUS].active) {
val |= (1 << 1);
}
if (s->vectors[ARMV7M_EXCP_USAGE].active) {
val |= (1 << 3);
}
if (s->vectors[ARMV7M_EXCP_SVC].active) {
val |= (1 << 7);
}
if (s->vectors[ARMV7M_EXCP_DEBUG].active) {
val |= (1 << 8);
}
if (s->vectors[ARMV7M_EXCP_PENDSV].active) {
val |= (1 << 10);
}
if (s->vectors[ARMV7M_EXCP_SYSTICK].active) {
val |= (1 << 11);
}
if (s->vectors[ARMV7M_EXCP_USAGE].pending) {
val |= (1 << 12);
}
if (s->vectors[ARMV7M_EXCP_MEM].pending) {
val |= (1 << 13);
}
if (s->vectors[ARMV7M_EXCP_BUS].pending) {
val |= (1 << 14);
}
if (s->vectors[ARMV7M_EXCP_SVC].pending) {
val |= (1 << 15);
}
if (s->vectors[ARMV7M_EXCP_MEM].enabled) {
val |= (1 << 16);
}
if (s->vectors[ARMV7M_EXCP_BUS].enabled) {
val |= (1 << 17);
}
if (s->vectors[ARMV7M_EXCP_USAGE].enabled) {
val |= (1 << 18);
}
return val;
case 0xd28:
return cpu->env.v7m.cfsr;
case 0xd2c:
return cpu->env.v7m.hfsr;
case 0xd30:
return cpu->env.v7m.dfsr;
case 0xd34:
return cpu->env.v7m.mmfar;
case 0xd38:
return cpu->env.v7m.bfar;
case 0xd3c:
qemu_log_mask(LOG_UNIMP,
"Aux Fault status registers unimplemented\n");
return 0;
case 0xd40:
return 0x00000030;
case 0xd44:
return 0x00000200;
case 0xd48:
return 0x00100000;
case 0xd4c:
return 0x00000000;
case 0xd50:
return 0x00000030;
case 0xd54:
return 0x00000000;
case 0xd58:
return 0x00000000;
case 0xd5c:
return 0x00000000;
case 0xd60:
return 0x01141110;
case 0xd64:
return 0x02111000;
case 0xd68:
return 0x21112231;
case 0xd6c:
return 0x01111110;
case 0xd70:
return 0x01310102;
case 0xd90:
return cpu->pmsav7_dregion << 8;
break;
case 0xd94:
return cpu->env.v7m.mpu_ctrl;
case 0xd98:
return cpu->env.pmsav7.rnr[attrs.secure];
case 0xd9c:
case 0xda4:
case 0xdac:
case 0xdb4:
{
int region = cpu->env.pmsav7.rnr[attrs.secure];
if (arm_feature(&cpu->env, ARM_FEATURE_V8)) {
int aliasno = (offset - 0xd9c) / 8;
if (aliasno) {
region = deposit32(region, 0, 2, aliasno);
}
if (region >= cpu->pmsav7_dregion) {
return 0;
}
return cpu->env.pmsav8.rbar[attrs.secure][region];
}
if (region >= cpu->pmsav7_dregion) {
return 0;
}
return (cpu->env.pmsav7.drbar[region] & 0x1f) | (region & 0xf);
}
case 0xda0:
case 0xda8:
case 0xdb0:
case 0xdb8:
{
int region = cpu->env.pmsav7.rnr[attrs.secure];
if (arm_feature(&cpu->env, ARM_FEATURE_V8)) {
int aliasno = (offset - 0xda0) / 8;
if (aliasno) {
region = deposit32(region, 0, 2, aliasno);
}
if (region >= cpu->pmsav7_dregion) {
return 0;
}
return cpu->env.pmsav8.rlar[attrs.secure][region];
}
if (region >= cpu->pmsav7_dregion) {
return 0;
}
return ((cpu->env.pmsav7.dracr[region] & 0xffff) << 16) |
(cpu->env.pmsav7.drsr[region] & 0xffff);
}
case 0xdc0:
if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
goto bad_offset;
}
return cpu->env.pmsav8.mair0[attrs.secure];
case 0xdc4:
if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
goto bad_offset;
}
return cpu->env.pmsav8.mair1[attrs.secure];
default:
bad_offset:
qemu_log_mask(LOG_GUEST_ERROR, "NVIC: Bad read offset 0x%x\n", offset);
return 0;
}
}
| 1threat
|
ImageIO.read() works in Eclipse runtime but not as runnable jar file : <p>I've got a problem with loading images implemented in a jar file. Here's my file tree:</p>
<pre><code> -graphics
-ImageFiles
-animation
-image.jpg
-mathspace
-META-INF
</code></pre>
<p>Now I wanna load this image:</p>
<pre><code> ImageIO.read(getClass().getResource("/ImageFiles/animation/image.jpg"));
</code></pre>
<p>This works well in the eclipse runtime but when I start it as a runnable jar File a NullPointerException gets triggered. Thanks for help!</p>
| 0debug
|
need help on my code (im not that good at coding) : I am currently working on this code:
import time
import webbrowser
while True:
user_inputq3 = raw_input("Which model of phone is it? ")
import csv
words=user_inputq3.split(" ")
reader=csv.reader(open("task3worksheet.csv"))
problemlist=[row for row in reader]
for x in range(0,len(words)):
for y in range(0,len(problemlist)-1,2):
if(words[x].lower() in problemlist[y]):
print(problemlist[y+1][0])
break
elif user_inputq3 == "exit":
print("The programme will now shut down.")
time.sleep(5)
exit(0)
break
else:
print("This troubleshooting programme will only support iPhone 3-7.")
print("Make sure you type in iphone then the model of iPhone. (e.g iphone4)")
print("If you do not have these versions of the iPhone, please type in exit when prompted with the question again.")
break
The "task3worksheet" is a excel worksheet which is full of keywords and a response. So for example when "iphone4" is typed, "next question" should come up. However, when I type in "iphone4", it says next question and loops back to the question again. How do I make it so that it doesnt move back to the question again, I want it so the current loop ends when the valid input is entered, so I can move on to other code. Thank you. (Obviously the code is structured properly in python, just imagine it is structured with proper spacing, thanks).
| 0debug
|
int cpu_load(QEMUFile *f, void *opaque, int version_id)
{
CPUState *env = opaque;
int i;
uint32_t tmp;
if (version_id != 5)
return -EINVAL;
for(i = 0; i < 8; i++)
qemu_get_betls(f, &env->gregs[i]);
qemu_get_be32s(f, &env->nwindows);
for(i = 0; i < env->nwindows * 16; i++)
qemu_get_betls(f, &env->regbase[i]);
for(i = 0; i < TARGET_FPREGS; i++) {
union {
float32 f;
uint32_t i;
} u;
u.i = qemu_get_be32(f);
env->fpr[i] = u.f;
}
qemu_get_betls(f, &env->pc);
qemu_get_betls(f, &env->npc);
qemu_get_betls(f, &env->y);
tmp = qemu_get_be32(f);
env->cwp = 0;
PUT_PSR(env, tmp);
qemu_get_betls(f, &env->fsr);
qemu_get_betls(f, &env->tbr);
tmp = qemu_get_be32(f);
env->interrupt_index = tmp;
qemu_get_be32s(f, &env->pil_in);
#ifndef TARGET_SPARC64
qemu_get_be32s(f, &env->wim);
for (i = 0; i < 32; i++)
qemu_get_be32s(f, &env->mmuregs[i]);
#else
qemu_get_be64s(f, &env->lsu);
for (i = 0; i < 16; i++) {
qemu_get_be64s(f, &env->immuregs[i]);
qemu_get_be64s(f, &env->dmmuregs[i]);
}
for (i = 0; i < 64; i++) {
qemu_get_be64s(f, &env->itlb[i].tag);
qemu_get_be64s(f, &env->itlb[i].tte);
qemu_get_be64s(f, &env->dtlb[i].tag);
qemu_get_be64s(f, &env->dtlb[i].tte);
}
qemu_get_be32s(f, &env->mmu_version);
for (i = 0; i < MAXTL_MAX; i++) {
qemu_get_be64s(f, &env->ts[i].tpc);
qemu_get_be64s(f, &env->ts[i].tnpc);
qemu_get_be64s(f, &env->ts[i].tstate);
qemu_get_be32s(f, &env->ts[i].tt);
}
qemu_get_be32s(f, &env->xcc);
qemu_get_be32s(f, &env->asi);
qemu_get_be32s(f, &env->pstate);
qemu_get_be32s(f, &env->tl);
env->tsptr = &env->ts[env->tl & MAXTL_MASK];
qemu_get_be32s(f, &env->cansave);
qemu_get_be32s(f, &env->canrestore);
qemu_get_be32s(f, &env->otherwin);
qemu_get_be32s(f, &env->wstate);
qemu_get_be32s(f, &env->cleanwin);
for (i = 0; i < 8; i++)
qemu_get_be64s(f, &env->agregs[i]);
for (i = 0; i < 8; i++)
qemu_get_be64s(f, &env->bgregs[i]);
for (i = 0; i < 8; i++)
qemu_get_be64s(f, &env->igregs[i]);
for (i = 0; i < 8; i++)
qemu_get_be64s(f, &env->mgregs[i]);
qemu_get_be64s(f, &env->fprs);
qemu_get_be64s(f, &env->tick_cmpr);
qemu_get_be64s(f, &env->stick_cmpr);
qemu_get_ptimer(f, env->tick);
qemu_get_ptimer(f, env->stick);
qemu_get_be64s(f, &env->gsr);
qemu_get_be32s(f, &env->gl);
qemu_get_be64s(f, &env->hpstate);
for (i = 0; i < MAXTL_MAX; i++)
qemu_get_be64s(f, &env->htstate[i]);
qemu_get_be64s(f, &env->hintp);
qemu_get_be64s(f, &env->htba);
qemu_get_be64s(f, &env->hver);
qemu_get_be64s(f, &env->hstick_cmpr);
qemu_get_be64s(f, &env->ssr);
qemu_get_ptimer(f, env->hstick);
#endif
tlb_flush(env, 1);
return 0;
}
| 1threat
|
How do I use the native JUnit 5 support in Gradle with the Kotlin DSL? : <p>I want to use the built-in JUnit 5 with the Gradle Kotlin DSL, because during build I get this warning:</p>
<pre><code>WARNING: The junit-platform-gradle-plugin is deprecated and will be discontinued in JUnit Platform 1.3.
Please use Gradle's native support for running tests on the JUnit Platform (requires Gradle 4.6 or higher):
https://junit.org/junit5/docs/current/user-guide/#running-tests-build-gradle
</code></pre>
<p>That links tells me to put</p>
<pre><code>test {
useJUnitPlatform()
}
</code></pre>
<p>in my <code>build.gradle</code>, but what is the syntax for <code>build.gradle.kts</code>?</p>
<p>My current build file is</p>
<pre><code>import org.gradle.api.plugins.ExtensionAware
import org.junit.platform.gradle.plugin.FiltersExtension
import org.junit.platform.gradle.plugin.EnginesExtension
import org.junit.platform.gradle.plugin.JUnitPlatformExtension
group = "com.example"
version = "0.0"
// JUnit 5
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath("org.junit.platform:junit-platform-gradle-plugin:1.2.0")
}
}
apply {
plugin("org.junit.platform.gradle.plugin")
}
// Kotlin configuration.
plugins {
val kotlinVersion = "1.2.41"
application
kotlin("jvm") version kotlinVersion
java // Required by at least JUnit.
// Plugin which checks for dependency updates with help/dependencyUpdates task.
id("com.github.ben-manes.versions") version "0.17.0"
// Plugin which can update Gradle dependencies, use help/useLatestVersions
id("se.patrikerdes.use-latest-versions") version "0.2.1"
}
application {
mainClassName = "com.example.HelloWorld"
}
dependencies {
compile(kotlin("stdlib"))
// To "prevent strange errors".
compile(kotlin("reflect"))
// Kotlin reflection.
compile(kotlin("test"))
compile(kotlin("test-junit"))
// JUnit 5
testImplementation("org.junit.jupiter:junit-jupiter-api:5.2.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.2.0")
testRuntime("org.junit.platform:junit-platform-console:1.2.0")
// Kotlintest
testCompile("io.kotlintest:kotlintest-core:3.1.0-RC2")
testCompile("io.kotlintest:kotlintest-assertions:3.1.0-RC2")
testCompile("io.kotlintest:kotlintest-runner-junit5:3.1.0-RC2")
}
repositories {
mavenCentral()
mavenLocal()
jcenter()
}
</code></pre>
<p>(The following is some blabla because this question 'contains mostly code').
I tried to find documentation on how to customize tasks in the Kotlin DSL, but I couldn't find any. In normal Groovy you can just write the name of the task and then change things in the block, but the Kotlin DSL doesn't recognise the task as such, unresolved reference.</p>
<p>Also, this question is related but asks for creating of <em>new</em> tasks, instead of customize existing tasks: <a href="https://stackoverflow.com/questions/48553029/how-do-i-overwrite-a-task-in-gradle-kotlin-dsl">How do I overwrite a task in gradle kotlin-dsl</a></p>
<p><a href="https://stackoverflow.com/a/49014534/4126843">Here is a solution for normal Gradle.</a></p>
| 0debug
|
static uint64_t e1000_io_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
E1000State *s = opaque;
(void)s;
return 0;
}
| 1threat
|
When would you use Storyboard vs Nib/Xib vs Coding from scratch? : <p>what are the pro's and con's of each, and what would be the proper way to responde to a question like this in an interview :</p>
<p>When would you use Storyboard vs Nib/Xib vs Coding from scratch?</p>
| 0debug
|
Add a function to a button made with userscript : <p>I know how to create a button with userscript, but I don't know how to attach a function to the button with userscript. How do I attach a function to the button with userscript? I would also like to add an "id" to the button with userscript. How do I do that? Thanks. </p>
<pre><code>var button = document.createElement("BUTTON"); // Create a <button> element
var text = document.createTextNode("CLICK ME"); // Create a text node
button.appendChild(text); // Append the text to <button>
document.body.appendChild(button);
function clickMe() {
alert("Hi");
} //end of function clickMe()
</code></pre>
| 0debug
|
go version command shows old version number after update to 1.8 : <p>Pretty much the title. I downloaded/installed Go 1.8 for OS X, but when I go</p>
<pre><code>$ go version
go version go1.7.5 darwin/amd64
</code></pre>
<p>My .bashrc look like the following</p>
<pre><code># some exports omitted
NPM_PACKAGES=/Users/<me>/.npm-packages
NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"
export PATH=~/Library/Python/3.4/bin:$PATH
export GOPATH=$HOME/Go
export PATH=$PATH:/usr/local/go/bin
</code></pre>
<p>My workspace is in a directory called "Go" in my home folder. </p>
<p>What I have checked so far:</p>
<ul>
<li><p>I've checked the files in /usr/local/go/bin, and the VERSION file states "1.8", so I know the installation was successful.</p></li>
<li><p>I have also renewed my terminal session, I even rebooted my pc to make sure no other processes were interfering with it.</p></li>
<li><p>I use Webstorm as my IDE, and it correctly recognized 1.8 as the working version</p></li>
<li><p>It's not a bug in the version number itself, as I can't use the "NextResultSet()" sql functionality, introduced in version 1.8</p></li>
</ul>
<p>I believe the culprit might be a wrong configuration in the .bashrc file above, as only the terminal is stuck on the old version, but I can't figure out what is wrong with it.</p>
| 0debug
|
Scanf is not taking input.I am using the following code and scanf is not taking input . I am taking double as scanf input : this is the code i am running
#include <stdio.h>
#include <math.h>
void main()
{
int i=0;
double kl,x0,x1,xk;
printf("enter kl");
scanf("%lf",&kl);
printf("hello");
for(x1=kl;((x1-x0)>2) || ((x1-x0)<-2);x0 );
{
x0=x1;
x1=(x0/2.0)+(kl/(2.0*x0));
}
printf("%lf",x1);
printf(" %lf ",(sqrt(kl)-x1));
}
after running scanf is not taking input. hello is not printed.
| 0debug
|
void *mcf_uart_init(qemu_irq irq, CharDriverState *chr)
{
mcf_uart_state *s;
s = g_malloc0(sizeof(mcf_uart_state));
s->chr = chr;
s->irq = irq;
if (chr) {
qemu_chr_add_handlers(chr, mcf_uart_can_receive, mcf_uart_receive,
mcf_uart_event, s);
}
mcf_uart_reset(s);
return s;
}
| 1threat
|
Extra bottom space/padding on iPhone X? : <p>On the iPhone X in portrait mode, if you set a bottom constraint to safe area to 0, you will end up with an extra space at the bottom of the screen.
How do you get programmatically the height of this extra padding ?</p>
<p>I managed to manually determine the height of this padding which is 34 and here is how I managed to implement it with iPhone X detection:</p>
<p><strong>Swift 4.0 and Xcode 9.0</strong></p>
<pre><code>if UIDevice().userInterfaceIdiom == .phone
{
switch UIScreen.main.nativeBounds.height
{
case 2436: //iPhone X
self.keyboardInAppOffset.constant = -34.0
default:
self.keyboardInAppOffset.constant = 0
}
}
</code></pre>
<p>Is there a cleaner way to detect the height of this padding ?</p>
| 0debug
|
gdb_handlesig(CPUState *cpu, int sig)
{
GDBState *s;
char buf[256];
int n;
s = gdbserver_state;
if (gdbserver_fd < 0 || s->fd < 0) {
return sig;
}
cpu_single_step(cpu, 0);
tb_flush(cpu);
if (sig != 0) {
snprintf(buf, sizeof(buf), "S%02x", target_signal_to_gdb(sig));
put_packet(s, buf);
}
if (s->fd < 0) {
return sig;
}
sig = 0;
s->state = RS_IDLE;
s->running_state = 0;
while (s->running_state == 0) {
n = read(s->fd, buf, 256);
if (n > 0) {
int i;
for (i = 0; i < n; i++) {
gdb_read_byte(s, buf[i]);
}
} else if (n == 0 || errno != EAGAIN) {
return sig;
}
}
sig = s->signal;
s->signal = 0;
return sig;
}
| 1threat
|
Rename a TeamCity Build Agent : <p>I have inherited a TeamCity server and I am reviewing the configuration. To make it a little easier, I would like to rename a build agent from a long random name to something a little more easily identifiable. </p>
<p>However, I cannot find any options to change the name in the Agent Summary page.</p>
<p>Has anyone got a way to change the build agent name?</p>
| 0debug
|
Mysqli query and close within a foreach loop : <p>Within a foreach loop I have a SQL query insert. This query should run two times because I am looping through my session that contains two elements, keys or whatever you prefer to call it. It works fine and it makes a new query for every new iteration. But when I put in mysqli_close in the code it only makes the first insert, and then on the next iteration it gets an error. Why does it not "reopen" the query on the next iteration when it loops through it again?</p>
<p>I know there are better ways to make "multiple" querys, I was just playing around and noticed this, and then I got curious. Any thoughts?</p>
<p>Take care</p>
| 0debug
|
def concatenate_elements(list):
ans = ' '
for i in list:
ans = ans+ ' '+i
return (ans)
| 0debug
|
int inet_listen_opts(QemuOpts *opts, int port_offset)
{
struct addrinfo ai,*res,*e;
const char *addr;
char port[33];
char uaddr[INET6_ADDRSTRLEN+1];
char uport[33];
int slisten,rc,to,try_next;
memset(&ai,0, sizeof(ai));
ai.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
ai.ai_family = PF_UNSPEC;
ai.ai_socktype = SOCK_STREAM;
if (qemu_opt_get(opts, "port") == NULL) {
fprintf(stderr, "%s: host and/or port not specified\n", __FUNCTION__);
return -1;
}
pstrcpy(port, sizeof(port), qemu_opt_get(opts, "port"));
addr = qemu_opt_get(opts, "host");
to = qemu_opt_get_number(opts, "to", 0);
if (qemu_opt_get_bool(opts, "ipv4", 0))
ai.ai_family = PF_INET;
if (qemu_opt_get_bool(opts, "ipv6", 0))
ai.ai_family = PF_INET6;
if (port_offset)
snprintf(port, sizeof(port), "%d", atoi(port) + port_offset);
rc = getaddrinfo(strlen(addr) ? addr : NULL, port, &ai, &res);
if (rc != 0) {
fprintf(stderr,"getaddrinfo(%s,%s): %s\n", addr, port,
gai_strerror(rc));
return -1;
}
if (sockets_debug)
inet_print_addrinfo(__FUNCTION__, res);
for (e = res; e != NULL; e = e->ai_next) {
getnameinfo((struct sockaddr*)e->ai_addr,e->ai_addrlen,
uaddr,INET6_ADDRSTRLEN,uport,32,
NI_NUMERICHOST | NI_NUMERICSERV);
slisten = socket(e->ai_family, e->ai_socktype, e->ai_protocol);
if (slisten < 0) {
fprintf(stderr,"%s: socket(%s): %s\n", __FUNCTION__,
inet_strfamily(e->ai_family), strerror(errno));
continue;
}
setsockopt(slisten,SOL_SOCKET,SO_REUSEADDR,(void*)&on,sizeof(on));
#ifdef IPV6_V6ONLY
if (e->ai_family == PF_INET6) {
setsockopt(slisten,IPPROTO_IPV6,IPV6_V6ONLY,(void*)&off,
sizeof(off));
}
#endif
for (;;) {
if (bind(slisten, e->ai_addr, e->ai_addrlen) == 0) {
if (sockets_debug)
fprintf(stderr,"%s: bind(%s,%s,%d): OK\n", __FUNCTION__,
inet_strfamily(e->ai_family), uaddr, inet_getport(e));
goto listen;
}
try_next = to && (inet_getport(e) <= to + port_offset);
if (!try_next || sockets_debug)
fprintf(stderr,"%s: bind(%s,%s,%d): %s\n", __FUNCTION__,
inet_strfamily(e->ai_family), uaddr, inet_getport(e),
strerror(errno));
if (try_next) {
inet_setport(e, inet_getport(e) + 1);
continue;
}
break;
}
closesocket(slisten);
}
fprintf(stderr, "%s: FAILED\n", __FUNCTION__);
freeaddrinfo(res);
return -1;
listen:
if (listen(slisten,1) != 0) {
perror("listen");
closesocket(slisten);
freeaddrinfo(res);
return -1;
}
snprintf(uport, sizeof(uport), "%d", inet_getport(e) - port_offset);
qemu_opt_set(opts, "host", uaddr);
qemu_opt_set(opts, "port", uport);
qemu_opt_set(opts, "ipv6", (e->ai_family == PF_INET6) ? "on" : "off");
qemu_opt_set(opts, "ipv4", (e->ai_family != PF_INET6) ? "on" : "off");
freeaddrinfo(res);
return slisten;
}
| 1threat
|
static void mpeg_decode_extension(AVCodecContext *avctx,
UINT8 *buf, int buf_size)
{
Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
int ext_type;
init_get_bits(&s->gb, buf, buf_size);
ext_type = get_bits(&s->gb, 4);
switch(ext_type) {
case 0x1:
mpeg_decode_sequence_extension(s);
break;
case 0x3:
mpeg_decode_quant_matrix_extension(s);
break;
case 0x8:
mpeg_decode_picture_coding_extension(s);
break;
}
}
| 1threat
|
Database model for car-service : <p>I am working on a project for car-service(denting, painting). In this app user will select their location and then select car brand,model and fuel type.After this he will see a list of services and add them to cart . Then he can make order for services.
So, How to design database for this.I am stuck with how store services which can be change in price for different car and location.</p>
| 0debug
|
Sanitize JSON with php : <p>I always use filter_var($var, FILTER, FLAG); when I get data from $_GET, $_POST and so on, but now this data is a JSON string but I didn't find any filter to sanitize JSON. Anyone know how to implement this filter?</p>
<p>PHP filter_var(): <a href="http://php.net/manual/en/function.filter-var.php" rel="noreferrer">http://php.net/manual/en/function.filter-var.php</a></p>
<p>PHP FILTER CONST: <a href="http://php.net/manual/en/filter.filters.sanitize.php" rel="noreferrer">http://php.net/manual/en/filter.filters.sanitize.php</a></p>
| 0debug
|
Associate a color palette with ggplot2 theme : <p>I want my ggplot2 theme to use a specific set of colors, but don't see how to avoid a separate line outside of the theme.</p>
<p>I have this data:</p>
<pre><code>library(ggplot2)
mycars <- mtcars
mycars$cyl <- as.factor(mycars$cyl)
</code></pre>
<p>And here's a dummy theme I plot with:</p>
<pre><code>mytheme <- theme(panel.grid.major = element_line(size = 2))
ggplot(mycars, aes(x = wt, y = mpg)) +
geom_point(aes(color = cyl)) +
mytheme
</code></pre>
<p><a href="https://i.stack.imgur.com/sQaY2m.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sQaY2m.png" alt="without custom colors"></a></p>
<p>I want the point colors to default to my custom palette:</p>
<pre><code>mycolors <- c("deeppink", "chartreuse", "midnightblue")
</code></pre>
<p>Can I somehow add that to my ggplot2 theme so that I don't constantly repeat this extra line of code at the end:</p>
<pre><code>ggplot(mycars, aes(x = wt, y = mpg)) +
geom_point(aes(color = cyl)) +
mytheme +
scale_color_manual(values = mycolors)
</code></pre>
<p><a href="https://i.stack.imgur.com/wy6SCm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wy6SCm.png" alt="with colors"></a></p>
<p>I tried:</p>
<pre><code>mytheme2 <- mytheme + scale_color_manual(values = mycolors)
</code></pre>
<p>But got:</p>
<blockquote>
<p>Error: Don't know how to add scale_color_manual(values = mycolors) to
a theme object</p>
</blockquote>
| 0debug
|
Trouble in R with abline : it's my first time using R - I've only used SPSS before and this is all very confusing for me.
I'm having trouble plotting 2 ablines on a graph of the log10 Brain mass and log10 body mass. I'm following someone else's script but it just doesn't work for me. This is what I have: [Click me][1]
(I've taken a screenshot of it because when I write it out here it comes out all weird ;_;)
This is the graph produced:
[Click me!][2]
Why are the lines off there like that? Are the values I'm getting for the intercept and slope incorrect, or am I using the wrong ones? I've done other examples of this and its worked ok, but I've always ended up using the first model, never the second one so I'm not sure if I'm using the right values.
Thank you :)
[1]: http://i.stack.imgur.com/pjWTl.png
[2]: http://i.stack.imgur.com/I0Cla.png
| 0debug
|
first time asking, need a little help here on java loop : Can anyone please tell me which part output the number in front of the * signs?
is it the methods or the output?
import java.util.*;
public class PrintTriangle3 {
public static void main(String [] args) {
Scanner sc = new Scanner(System.in);
System.out.println("enter number");
int number = sc.nextInt();
int i = 1;
while( i <= number)
{
System.out.println(printLine(number));
number--;
}
i++;
}
public static int printLine(int number)
{
for(int j = 1; j <= number; j++)
{
System.out.print("*");
}
return number;
}
}
| 0debug
|
I can't even remotely figure out how to do this : I have to make a method to print out the elements in an array, separated by ‘‘|’’
@param values, an array of integers.
Essentially its suppose to take user input, and then from there separate it with |. This is what I have so far. Any help chaps?
int [] scans = new int [3];
System.out.println("Enter 4 Numbers into the array: " );
Scanner scanner = new Scanner(System.in);
int s = scanner.nextInt();
for (int i = 0; i < scans.length; i++)
{
scans [i] = scanner.nextInt();
}
| 0debug
|
static inline int onenand_load_spare(OneNANDState *s, int sec, int secn,
void *dest)
{
uint8_t buf[512];
if (s->blk_cur) {
if (blk_read(s->blk_cur, s->secs_cur + (sec >> 5), buf, 1) < 0) {
return 1;
}
memcpy(dest, buf + ((sec & 31) << 4), secn << 4);
} else if (sec + secn > s->secs_cur) {
return 1;
} else {
memcpy(dest, s->current + (s->secs_cur << 9) + (sec << 4), secn << 4);
}
return 0;
}
| 1threat
|
static void gd_connect_signals(GtkDisplayState *s)
{
g_signal_connect(s->show_tabs_item, "activate",
G_CALLBACK(gd_menu_show_tabs), s);
g_signal_connect(s->window, "key-press-event",
G_CALLBACK(gd_window_key_event), s);
g_signal_connect(s->window, "delete-event",
G_CALLBACK(gd_window_close), s);
#if GTK_CHECK_VERSION(3, 0, 0)
g_signal_connect(s->drawing_area, "draw",
G_CALLBACK(gd_draw_event), s);
#else
g_signal_connect(s->drawing_area, "expose-event",
G_CALLBACK(gd_expose_event), s);
#endif
g_signal_connect(s->drawing_area, "motion-notify-event",
G_CALLBACK(gd_motion_event), s);
g_signal_connect(s->drawing_area, "button-press-event",
G_CALLBACK(gd_button_event), s);
g_signal_connect(s->drawing_area, "button-release-event",
G_CALLBACK(gd_button_event), s);
g_signal_connect(s->drawing_area, "scroll-event",
G_CALLBACK(gd_scroll_event), s);
g_signal_connect(s->drawing_area, "key-press-event",
G_CALLBACK(gd_key_event), s);
g_signal_connect(s->drawing_area, "key-release-event",
G_CALLBACK(gd_key_event), s);
g_signal_connect(s->pause_item, "activate",
G_CALLBACK(gd_menu_pause), s);
g_signal_connect(s->reset_item, "activate",
G_CALLBACK(gd_menu_reset), s);
g_signal_connect(s->powerdown_item, "activate",
G_CALLBACK(gd_menu_powerdown), s);
g_signal_connect(s->quit_item, "activate",
G_CALLBACK(gd_menu_quit), s);
g_signal_connect(s->full_screen_item, "activate",
G_CALLBACK(gd_menu_full_screen), s);
g_signal_connect(s->zoom_in_item, "activate",
G_CALLBACK(gd_menu_zoom_in), s);
g_signal_connect(s->zoom_out_item, "activate",
G_CALLBACK(gd_menu_zoom_out), s);
g_signal_connect(s->zoom_fixed_item, "activate",
G_CALLBACK(gd_menu_zoom_fixed), s);
g_signal_connect(s->zoom_fit_item, "activate",
G_CALLBACK(gd_menu_zoom_fit), s);
g_signal_connect(s->vga_item, "activate",
G_CALLBACK(gd_menu_switch_vc), s);
g_signal_connect(s->grab_item, "activate",
G_CALLBACK(gd_menu_grab_input), s);
g_signal_connect(s->notebook, "switch-page",
G_CALLBACK(gd_change_page), s);
g_signal_connect(s->drawing_area, "enter-notify-event",
G_CALLBACK(gd_enter_event), s);
g_signal_connect(s->drawing_area, "leave-notify-event",
G_CALLBACK(gd_leave_event), s);
g_signal_connect(s->drawing_area, "focus-out-event",
G_CALLBACK(gd_focus_out_event), s);
}
| 1threat
|
Checking a string for punctuation using loops : <p>How do you check if a string has punctuation by using a loop. I was told to use the in operator </p>
<pre><code>string = input("Enter a string")
for char in string:
if char in "'.,;:?!":
print("that string contains punctuation")
break
else:
print("that string contains punctuation")
break
</code></pre>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.