problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
Before and After pseudo classes used with styled-components : <p>What is the proper way to apply <code>:before</code> and <code>:after</code> pseudo classes to styled components?</p>
<p>I know that you can use </p>
<p><code>&:hover {}</code></p>
<p>to apply the <code>:hover</code> pseudo class to a styled-component. </p>
<p>Does this work for All pseudo elements like before and after? </p>
<p>I have tried using the <code>&:before</code> and <code>&:after</code> strategy with some rather complex examples and i'm not sure if my attempts are not working because i've got something wrong with my example or it just doesn't work like that. </p>
<p>Does someone have some insight on this? Thank you.</p>
| 0debug |
int ff_wmv2_decode_secondary_picture_header(MpegEncContext *s)
{
Wmv2Context *const w = (Wmv2Context *) s;
if (s->pict_type == AV_PICTURE_TYPE_I) {
if (w->j_type_bit)
w->j_type = get_bits1(&s->gb);
else
w->j_type = 0;
if (!w->j_type) {
if (w->per_mb_rl_bit)
s->per_mb_rl_table = get_bits1(&s->gb);
else
s->per_mb_rl_table = 0;
if (!s->per_mb_rl_table) {
s->rl_chroma_table_index = decode012(&s->gb);
s->rl_table_index = decode012(&s->gb);
}
s->dc_table_index = get_bits1(&s->gb);
}
s->inter_intra_pred = 0;
s->no_rounding = 1;
if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
av_log(s->avctx, AV_LOG_DEBUG,
"qscale:%d rlc:%d rl:%d dc:%d mbrl:%d j_type:%d \n",
s->qscale, s->rl_chroma_table_index, s->rl_table_index,
s->dc_table_index, s->per_mb_rl_table, w->j_type);
}
} else {
int cbp_index;
w->j_type = 0;
parse_mb_skip(w);
cbp_index = decode012(&s->gb);
w->cbp_table_index = wmv2_get_cbp_table_index(s, cbp_index);
if (w->mspel_bit)
s->mspel = get_bits1(&s->gb);
else
s->mspel = 0;
if (w->abt_flag) {
w->per_mb_abt = get_bits1(&s->gb) ^ 1;
if (!w->per_mb_abt)
w->abt_type = decode012(&s->gb);
}
if (w->per_mb_rl_bit)
s->per_mb_rl_table = get_bits1(&s->gb);
else
s->per_mb_rl_table = 0;
if (!s->per_mb_rl_table) {
s->rl_table_index = decode012(&s->gb);
s->rl_chroma_table_index = s->rl_table_index;
}
s->dc_table_index = get_bits1(&s->gb);
s->mv_table_index = get_bits1(&s->gb);
s->inter_intra_pred = 0;
s->no_rounding ^= 1;
if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
av_log(s->avctx, AV_LOG_DEBUG,
"rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d mspel:%d "
"per_mb_abt:%d abt_type:%d cbp:%d ii:%d\n",
s->rl_table_index, s->rl_chroma_table_index,
s->dc_table_index, s->mv_table_index,
s->per_mb_rl_table, s->qscale, s->mspel,
w->per_mb_abt, w->abt_type, w->cbp_table_index,
s->inter_intra_pred);
}
}
s->esc3_level_length = 0;
s->esc3_run_length = 0;
s->picture_number++;
if (w->j_type) {
ff_intrax8_decode_picture(&w->x8, &s->current_picture,
&s->gb, &s->mb_x, &s->mb_y,
2 * s->qscale, (s->qscale - 1) | 1,
s->loop_filter, s->low_delay);
ff_er_add_slice(&w->s.er, 0, 0,
(w->s.mb_x >> 1) - 1, (w->s.mb_y >> 1) - 1,
ER_MB_END);
return 1;
}
return 0;
}
| 1threat |
def first_Factorial_Divisible_Number(x):
i = 1;
fact = 1;
for i in range(1,x):
fact = fact * i
if (fact % x == 0):
break
return i | 0debug |
Using IF in BigQuery SQL : <p><strong>Case</strong>: I have Sales table in BQ and item_num column contains values 1, -1 and 0. I want to count how many cases I have for each value.</p>
<p>Tried a simple query below, but count returns exactly the same number for each case.. What I am missing?</p>
<pre><code>SELECT
count(if(item_num > 0,1, 0)) as buysplus,
count(if(item_num < 0,1, 0)) as buysminus,
count(if(item_num = 0,1, 0)) as buyszero
from MyShop.Sales
</code></pre>
<p>thanks</p>
| 0debug |
How can i check so that the letters in the beginning are three specific letters? : <p>My problem is that i need something that can check if an string got Three specific letters in the beginning. How would you guys do this?</p>
| 0debug |
How do you install a mac of any kind (dual boot, vm, etc) on a windows 10 computer? : <p>I am trying to create apps, but obviously you can't on windows. I have searched on youtube so many times and I just need a solution. I tried Yosimite on VMware and it told me the virtual CPU would not work. (Also I have access to a mac if needed for install procedure). Thank you! </p>
| 0debug |
static void migration_end(void)
{
if (migration_bitmap) {
memory_global_dirty_log_stop();
g_free(migration_bitmap);
migration_bitmap = NULL;
}
if (XBZRLE.cache) {
cache_fini(XBZRLE.cache);
g_free(XBZRLE.cache);
g_free(XBZRLE.encoded_buf);
g_free(XBZRLE.current_buf);
g_free(XBZRLE.decoded_buf);
XBZRLE.cache = NULL;
}
} | 1threat |
Changing color of a element in HTML Based on MYSQL . : <p>So I will try to give you as much detail as possible so you understand what I'm thinking.
I am working on home automation for my home. I have a web interface and now I want to add a temperature feed to it. But that too in the form of a thermometer or in form of bars. For eg if temp. is above 40 C then color should be RED if it is below 40 It should be a lower gradient than red and below 20 means blue. Is it possible ?
If yes , I beg your help. ! </p>
| 0debug |
Cannot implicitly convert typre 'string' to 'short' : protected void btnAdd_Click(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(Request.QueryString["id"]))
{
string kundeID = "-1";
int id = Convert.ToInt32(Request.QueryString["id"]);
int totalsum = Convert.ToInt32(ddlAmount.SelectedValue);
Handlevogn handlevogn = new Handlevogn
{
TotalSum = totalsum,
KundeID = kundeID,
Dato = DateTime.Now,
ErIHandlevogn = true,
ProduktID = id
};
HandlevognModell modell = new HandlevognModell();
lblResult.Text = modell.InsertHandlevogn(handlevogn);
}
Keep getting the error
> Cannot implicitly convert typre 'string' to 'short'
for the local variable kundeID.
| 0debug |
Combobox Name in Chart : I am trying to build an interactive Chart in excel, what my problem is that i have included an Form Control Combo Box in my chart but I am not able to get get the name of that combobox so that i can access that in my VBA code. I have attached an screenshot of the chart.[![enter image description here][1]][1]
What i want to know is that what code i can use to access the selected value of this combobox in the screenshot.
[1]: http://i.stack.imgur.com/9R1as.png | 0debug |
Javascript comparing two datasets : I have to datasets and i would like to return true is the same Id exists in both the datasets.
I tried implementing it using the ES6 feature "some" but could not get it to work.
let found = dataLog.some(dataLog=> dataLog.includes(dataLog2))
dataLog:{
0: {id: 12489, addedOn: "2019-02-04T15:19:54}
1: {id: 12489, addedOn: "2019-02-04T15:19:54}
2: {id: 12489, addedOn: "2019-02-04T15:19:54}
3: {id: 12489, addedOn: "2019-02-04T15:19:54}
4: {id: 12489, addedOn: "2019-02-04T15:19:54}
5: {id: 12489, addedOn: "2019-02-04T15:19:54}
}
dataLog2:{
0: {id: 12489, addedOn: "2019-02-04T15:19:54}
0: {id: 15000, addedOn: "2019-02-04T15:19:54}
0: {id: 15100, addedOn: "2019-02-04T15:19:54}
0: {id: 15200, addedOn: "2019-02-04T15:19:54}
0: {id: 15300, addedOn: "2019-02-04T15:19:54}
0: {id: 15400, addedOn: "2019-02-04T15:19:54}
}
Thanks. | 0debug |
static int inc_refcounts(BlockDriverState *bs,
BdrvCheckResult *res,
void **refcount_table,
int64_t *refcount_table_size,
int64_t offset, int64_t size)
{
BDRVQcow2State *s = bs->opaque;
uint64_t start, last, cluster_offset, k, refcount;
int ret;
if (size <= 0) {
return 0;
}
start = start_of_cluster(s, offset);
last = start_of_cluster(s, offset + size - 1);
for(cluster_offset = start; cluster_offset <= last;
cluster_offset += s->cluster_size) {
k = cluster_offset >> s->cluster_bits;
if (k >= *refcount_table_size) {
ret = realloc_refcount_array(s, refcount_table,
refcount_table_size, k + 1);
if (ret < 0) {
res->check_errors++;
return ret;
}
}
refcount = s->get_refcount(*refcount_table, k);
if (refcount == s->refcount_max) {
fprintf(stderr, "ERROR: overflow cluster offset=0x%" PRIx64
"\n", cluster_offset);
res->corruptions++;
continue;
}
s->set_refcount(*refcount_table, k, refcount + 1);
}
return 0;
} | 1threat |
static int pulse_write_packet(AVFormatContext *h, AVPacket *pkt)
{
PulseData *s = h->priv_data;
int size = pkt->size;
uint8_t *buf = pkt->data;
int error;
if (s->stream_index != pkt->stream_index)
return 0;
if ((error = pa_simple_write(s->pa, buf, size, &error))) {
av_log(s, AV_LOG_ERROR, "pa_simple_write failed: %s\n", pa_strerror(error));
return AVERROR(EIO);
}
return 0;
}
| 1threat |
Conver Sql query to ruby : i need to query in ruby on rails
select p.name from shoppe_products p
join shoppe_product_categorizations ca on (p.id = ca.product_id)
join shoppe_product_categories c on (c.id = ca.product_category_id)
where c.id = 2
I use Ruby version 2.1.5, Rails version 4 and PG 9.4
Thanks very much for your assistance. | 0debug |
Can't get My Data Inserted in Database : i am new here. I am working on a school Project and can't get registration page done right. It just don't insert the data in table.[Here is a screenshot for database and table][1]
<?php
$con=mysqli_connect('localhost','root','123456789','eedb');
if ($con)
{
if (isset($_POST['sub']))
{
$n= $_POST['name'];
$un=$_POST['username'];
$p=$_POST['password'];
$cp=$_POST['confirm-pass'];
$e=$_POST['email'];
$pn=$_POST['phone-no'];
$g=$_POST['gender'];
$s=$_POST['state'];
mysqli_query($con,"SELECT * FORM `register` ");
$insert= mysqli_query($con,"INSERT INTO `register`(`name`, `username`, `password`, `confirm-pass`, `email`, `phone-no`, `gender`, `state`) VALUES ('$n','$un','$p','$cp','$e','$pn','$g','$s'))");
if ($insert)
{
echo "<center>Data Successfully Submitted</center>";
}
else
{
echo "<center>Data Not Submitted</center>";
}
}
}
else
{
echo "connection error";
}
[1]: http://i.stack.imgur.com/jJhZv.png | 0debug |
Save and Read Integer Firestore Android : <p>I'm trying to create a simple Stats activity for my Android game. I'm using the new Firestore database. I have been able to save a document to my Firestore database with a total score, recent score, avg score, total games, and high score, but when i try to read the data back from the database it returns a null.</p>
<pre><code>public void readFromDB(){
statsDoc.get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
@Override
public void onSuccess(DocumentSnapshot documentSnapshot) {
if(documentSnapshot.exists()){
UserData userdata = documentSnapshot.toObject(UserData.class);
}
}
</code></pre>
<p>My Userdata class:</p>
<pre><code>/* Copyright statement */
package com.squidstudios.android.balloonpopper.utils;
import com.google.firebase.database.IgnoreExtraProperties;
/**
* UserData.java
*
* This class represents a single user's data including username, email, number of points earned,
* a saved state of their progress towards earning a single point, and their password.
*/
@IgnoreExtraProperties
public class UserData {
public String email;
public int total_points;
public int avg_score;
public int high_score;
public int total_games;
public int prev_score;
public UserData() {
// Default constructor required for calls to DataSnapshot.getValue(UserData.class)
}
public int getTotal_games() {
return total_games;
}
public void setTotal_games(int total_games) {
this.total_games = total_games;
}
public int getTotal_points() {
return total_points;
}
public void setTotal_points(int total_points) {
this.total_points = total_points;
}
public int getAvg_score() {
return avg_score;
}
public void setAvg_score(int avg_score) {
this.avg_score = avg_score;
}
public int getHigh_score() {
return high_score;
}
public void setHigh_score(int high_score) {
this.high_score = high_score;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public int getPrev_score() {
return prev_score;
}
public void setPrev_score(int prev_score) {
this.prev_score = prev_score;
}
}
</code></pre>
<p>It works fine when I test it out with string but for some reason integers are not working. Thanks in advance!</p>
| 0debug |
second add to cart link : <p>in functions.php of my templatefolder, I add this code to be able to have a second link on the product page.</p>
<p>but the result is an error 500.</p>
<p>I guess the product id part is wrong. Does anybody see how to solve this?</p>
<p>Woocommerce Version 3.4.5</p>
<pre><code>
function my_extra_button_on_product_page() {
global $product;
echo '<a class="single_add_to_cart_button button alt" href="?add-to-cart'<?=$product->get_id() ?>'">Second Link</a>';
}
</code></pre>
<p>I expect that the link that gets generated, has the add-to-cart=['product_id'] of course with the correct Product_id </p>
<p>But I get error 500</p>
| 0debug |
Task orphaned for request in react-native – what does it mean? : <p>I am trying to build a grid system for tiles with buttons and other actions. I forked trying with the react native playground grid images source, that you can find <a href="https://rnplay.org/apps/sXriww" rel="noreferrer">here</a>. It produces the following "stacktrace" and error when adding <code>zIndex</code> to individual pics. Images are never portrayed.</p>
<p><a href="https://i.stack.imgur.com/9MIIk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9MIIk.png" alt="enter image description here"></a></p>
<p>In case you are interested this is the exact component I am using:</p>
<pre><code>export default class GridLayout extends Component {
constructor () {
super()
const { width, height } = Dimensions.get('window')
this.state = {
currentScreenWidth: width,
currentScreenHeight: height
}
}
handleRotation (event) {
var layout = event.nativeEvent.layout
this.setState({ currentScreenWidth: layout.width, currentScreenHeight: layout.height })
}
calculatedSize () {
var size = this.state.currentScreenWidth / IMAGES_PER_ROW
return { width: size, height: size }
}
renderRow (images) {
return images.map((uri, i) => {
return (
<Image key={i} style={[styles.image, this.calculatedSize()]} source={{uri: uri}} />
)
})
}
renderImagesInGroupsOf (count) {
return _.chunk(IMAGE_URLS, IMAGES_PER_ROW).map((imagesForRow) => {
console.log('row being painted')
return (
<View key={uuid.v4()} style={styles.row}>
{this.renderRow(imagesForRow)}
</View>
)
})
}
render () {
return (
<ScrollView style={styles.grid} onLayout={(ev) => this.handleRotation(ev)} contentContainerStyle={styles.scrollView}>
{this.renderImagesInGroupsOf(IMAGES_PER_ROW)}
</ScrollView>
)
}
}
var styles = StyleSheet.create({
grid: {
flex: 1,
backgroundColor: 'blue'
},
row: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'flex-start',
backgroundColor: 'magenta'
},
image: {
zIndex: 2000
}
})
</code></pre>
| 0debug |
static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, int flv_codecid) {
AVCodecContext *vcodec = vstream->codec;
switch(flv_codecid) {
case FLV_CODECID_H263 : vcodec->codec_id = CODEC_ID_FLV1 ; break;
case FLV_CODECID_REALH263: vcodec->codec_id = CODEC_ID_H263 ; break;
case FLV_CODECID_SCREEN: vcodec->codec_id = CODEC_ID_FLASHSV; break;
case FLV_CODECID_SCREEN2: vcodec->codec_id = CODEC_ID_FLASHSV2; break;
case FLV_CODECID_VP6 : vcodec->codec_id = CODEC_ID_VP6F ;
case FLV_CODECID_VP6A :
if(flv_codecid == FLV_CODECID_VP6A)
vcodec->codec_id = CODEC_ID_VP6A;
if(vcodec->extradata_size != 1) {
vcodec->extradata_size = 1;
vcodec->extradata = av_malloc(1);
}
vcodec->extradata[0] = avio_r8(s->pb);
return 1;
case FLV_CODECID_H264:
vcodec->codec_id = CODEC_ID_H264;
return 3;
case FLV_CODECID_MPEG4:
vcodec->codec_id = CODEC_ID_MPEG4;
return 3;
default:
av_log(s, AV_LOG_INFO, "Unsupported video codec (%x)\n", flv_codecid);
vcodec->codec_tag = flv_codecid;
}
return 0;
}
| 1threat |
Python- How to print a varied amount? : So i have a list and a for loop (still a beginner sorry) and i want to print every item in the list and everything before that index.
for example:
list = ["A", "B", "C"]
for i in range(3): #I know i can use for each in list: but i want it to repeat a number of times just incase i would like to addapt my code.
How can i make it so A will be printed and then B and A, and finally C and B and A.
PS: Would like as few lines as possible (im able to do it in 8 lines but would like at least 3-4) :/
| 0debug |
Get all Value of Form Field : <p>I want to get All data that are in form field once time<br>
I have 60 field in my form<br>
is there any way to collect theme Together؟</p>
| 0debug |
static uint64_t bonito_readl(void *opaque, hwaddr addr,
unsigned size)
{
PCIBonitoState *s = opaque;
uint32_t saddr;
saddr = (addr - BONITO_REGBASE) >> 2;
DPRINTF("bonito_readl "TARGET_FMT_plx"\n", addr);
switch (saddr) {
case BONITO_INTISR:
return s->regs[saddr];
default:
return s->regs[saddr];
}
}
| 1threat |
How to use a div tag to create a layout and make it responsive : <p>Hi I have tried craeting a layout below</p>
<p><a href="https://i.stack.imgur.com/LqFgC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LqFgC.png" alt="enter image description here"></a></p>
<p>I have created using a table tag. But the layout is not responsive . I want to use the div tag but i do not know how to do it? I'm placing react component inside those layouts.</p>
<p>Any suggestion is helpful.</p>
| 0debug |
karma phantomjs not capturing in docker container : <p>I'm having trouble getting phantomjs to capture karma in an alpine docker container. I'm using node 6.10.2. I've installed phantomjs alpine from <a href="https://github.com/Overbryd/docker-phantomjs-alpine/releases" rel="noreferrer">here</a>. I'm using the following versions:</p>
<pre><code>"karma": "^1.6.0",
"karma-coverage": "^1.1.1",
"karma-mocha": "^1.0.1",
"karma-mocha-reporter": "^2.0.0",
"karma-phantomjs-launcher": "^1.0.4",
"karma-webpack": "^2.0.3",
</code></pre>
<p>Inside my container when I run my tests I see the following output. (timestamps removed)</p>
<pre><code>INFO [karma]: Karma v1.6.0 server started at http://0.0.0.0:9876/
INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
INFO [launcher]: Starting browser PhantomJS
DEBUG [temp-dir]: Creating temp dir at /workspace/karma-1981971
DEBUG [launcher]: /usr/bin/phantomjs /workspace/karma-1981971/capture.js
WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.
</code></pre>
<p>It then fails 2 times before exiting.</p>
<p>When I look at the contents of the tmp file <code>capture.js</code> it shows it is trying to open <code>localhost:9876/?id=18274999</code> and inside my container I try to <code>wget http://0.0.0.0:9876/</code> which does indeed succeed.</p>
<p>So I am very confused why PhantomJs fails to capture when I can indeed connect from within my container.</p>
<p>How should I go about debugging this? Any suggestions are greatly appreciated</p>
| 0debug |
def word_len(s):
s = s.split(' ')
for word in s:
if len(word)%2==0:
return True
else:
return False | 0debug |
How to use index(of: Object) subscript for array of models to replace the object at index? : If there is an `Array` as below containing `User` instances.
class User {
var id: String
var name: String
init(id: String, name: String) {
self.id = id
self.name = name
}
}
Now if there are 5 user models having ids from 1 to 5 and are stored in the array as below (no matter what the name is)
var userModels = [user1,user2,user3,user4,user5]
Now suppose there is an instance I am creating manually with id ```1```
let latestUser = User(id: "1", name: "Updated Name") //id 1 is already there but this is the updated model
is there any way to find the index of the user model whose index is 1 without `filter` so that I can replace the instance like this
Using Array extension or anything.Can we have the constraint for ```index(of: )``` for property id ???
let indexOfUser1 = userModels.index(of: latestUser) // It should return 1.
Like this (as we do the `subscript`)
extension Array where Element: User {
//TODO: indexOf constraint for specific property
} | 0debug |
How to catch and deal with "WebSocket is already in CLOSING or CLOSED state" in Node : <p>I've been searching for a solution to the issue "WebSocket is already in CLOSING or CLOSED state" and found this:</p>
<ol>
<li><a href="https://stackoverflow.com/questions/40259972/meteor-websocket-is-already-in-closing-or-closed-state-error">Meteor WebSocket is already in CLOSING or CLOSED state error</a></li>
<li><a href="https://stackoverflow.com/questions/25266009/websocket-is-already-in-closing-or-closed-state">WebSocket is already in CLOSING or CLOSED state.</a></li>
</ol>
<p>Answer #1 is for strictly related to Meteor and #2 has no answers... I have a Node server app with a socket:</p>
<pre><code>const WebSocket = require('ws');
const wss = new WebSocket.Server({ server });
wss.on('connection', function connection(socket) {
socket.on('message', function incoming(data) {
console.log('Incoming data ', data);
});
});
</code></pre>
<p>And clients connect like this:</p>
<pre><code>const socket = new WebSocket('ws://localhost:3090'); //Create WebSocket connection
//Connection opened
socket.addEventListener('open', function(event) {
console.log("Connected to server");
});
//Listen to messages
socket.addEventListener('message', function(event) {
console.log('Message from server ', event);
});
</code></pre>
<p>However after a few minutes, clients randomly disconnect and the function</p>
<pre><code>socket.send(JSON.stringify(data));
</code></pre>
<p>Will then throw a "WebSocket is already in CLOSING or CLOSED state.".</p>
<p>I am looking for a way to detect and deal these disconnections and immediately attempt to connect again.</p>
<p><strong>What is the most correct and efficient way to do this?</strong></p>
| 0debug |
Modify an instance variable value defined in a constructorwithin the main Class : I would like to be able to modify the value of a local variable defined in a constructor within the class via the main driver class at some point while running the program. How would I be able to achieve this?
Here is a sample of a constructor that I am using.
public Scale()
{
weight = 0;
unit = "kg";
}
I'd like to modify the value of weight at a point while running the program in the driver. | 0debug |
React.js - Syntax error: this is a reserved word in render() function : <p>I'm stuck on a error for the reserved keyword "this". In my React Component below shows me passing in a state from a my main component "App.js" to my "RecipeList.js" component to then map the data and render each RecipeItem Component. I just don't understand why I get this error</p>
<blockquote>
<p>React.js - Syntax error: this is a reserved word</p>
</blockquote>
<p>The error is called in RecipeList inside the render return method; If anybody could help that would great! </p>
<p>Thanks</p>
<p><strong>App.js</strong></p>
<pre><code>//main imports
import React, { Component } from 'react';
//helper imports
import {Button} from 'reactstrap'
import RecipeItem from './components/RecipeItem';
import RecipeList from './components/RecipeList';
import './App.css';
const recipes = [
{
recipeName: 'Hamburger',
ingrediants: 'ground meat, seasoning'
},
{
recipeName: 'Crab Legs',
ingrediants: 'crab, Ole Bay seasoning,'
}
];
class App extends Component {
constructor(props){
super(props);
this.state = {
recipes
};
}
render() {
return (
<div className="App">
<div className = "container-fluid">
<h2>Recipe Box</h2>
<div>
<RecipeList recipes = {this.state.recipes}/>
</div>
</div>
<div className = "AddRecipe">
<Button>Add Recipe</Button>
</div>
</div>
);
}
}
export default App;
</code></pre>
<p><strong>RecipeLists.js</strong></p>
<pre><code>import React, {Component} from 'react';
import _ from 'lodash';
import RecipeItem from './RecipeItem';
class RecipeList extends Component {
renderRecipeItems() {
return _.map(this.props.recipes, recipeItem => <RecipeItem key = {i} {...recipes} />);
}
render() {
return (
{ this.renderRecipeItems() }
);
}
}
export default RecipeList
</code></pre>
| 0debug |
static void qjson_finalizefn(Object *obj)
{
QJSON *json = QJSON(obj);
qobject_decref(QOBJECT(json->str));
}
| 1threat |
Why Image not reflecting in page properties of touch ui dialog in AEM 6.2 after reloading? : When i reload the page and open page properties, instead of an image which i uploaded ,i find the path of that image(i.e of content folder). Can anyone suggest where i am doing wrong? | 0debug |
int spapr_h_cas_compose_response(sPAPRMachineState *spapr,
target_ulong addr, target_ulong size,
bool cpu_update,
sPAPROptionVector *ov5_updates)
{
void *fdt, *fdt_skel;
sPAPRDeviceTreeUpdateHeader hdr = { .version_id = 1 };
size -= sizeof(hdr);
fdt_skel = g_malloc0(size);
_FDT((fdt_create(fdt_skel, size)));
_FDT((fdt_begin_node(fdt_skel, "")));
_FDT((fdt_end_node(fdt_skel)));
_FDT((fdt_finish(fdt_skel)));
fdt = g_malloc0(size);
_FDT((fdt_open_into(fdt_skel, fdt, size)));
g_free(fdt_skel);
if (cpu_update) {
_FDT((spapr_fixup_cpu_dt(fdt, spapr)));
}
if (spapr_dt_cas_updates(spapr, fdt, ov5_updates)) {
return -1;
}
_FDT((fdt_pack(fdt)));
if (fdt_totalsize(fdt) + sizeof(hdr) > size) {
trace_spapr_cas_failed(size);
return -1;
}
cpu_physical_memory_write(addr, &hdr, sizeof(hdr));
cpu_physical_memory_write(addr + sizeof(hdr), fdt, fdt_totalsize(fdt));
trace_spapr_cas_continue(fdt_totalsize(fdt) + sizeof(hdr));
g_free(fdt);
return 0;
}
| 1threat |
c# validate string input : <p>i ve written the following method that will do several validation checks on
an input string, the problem i have is with checking if the string containts any of the "invalid characters". See below.</p>
<pre><code>public static bool ValidateString(string string1)
{
// Check for length
if (string1.Length > 100)
{
Console.WriteLine("String too Long");
return false;
}
else if (!(!string1.Equals(string1.ToLower())))
{
//Check for min 1 uppercase
Console.WriteLine("Requres at least one uppercase");
return false;
}
else if (check for presence of invalid characters)
{
}
else
{
Console.WriteLine("All tests succesful");
return true;
}
}
</code></pre>
<p>Invalid characters would be : !@#$%^&*()-</p>
<p>Thanks in advance!</p>
| 0debug |
static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, int source_index)
{
AVStream *st;
OutputStream *ost;
AVCodecContext *video_enc;
char *frame_rate = NULL, *frame_aspect_ratio = NULL;
ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO, source_index);
st = ost->st;
video_enc = ost->enc_ctx;
MATCH_PER_STREAM_OPT(frame_rates, str, frame_rate, oc, st);
if (frame_rate && av_parse_video_rate(&ost->frame_rate, frame_rate) < 0) {
av_log(NULL, AV_LOG_FATAL, "Invalid framerate value: %s\n", frame_rate);
exit_program(1);
}
if (frame_rate && video_sync_method == VSYNC_PASSTHROUGH)
av_log(NULL, AV_LOG_ERROR, "Using -vsync 0 and -r can produce invalid output files\n");
MATCH_PER_STREAM_OPT(frame_aspect_ratios, str, frame_aspect_ratio, oc, st);
if (frame_aspect_ratio) {
AVRational q;
if (av_parse_ratio(&q, frame_aspect_ratio, 255, 0, NULL) < 0 ||
q.num <= 0 || q.den <= 0) {
av_log(NULL, AV_LOG_FATAL, "Invalid aspect ratio: %s\n", frame_aspect_ratio);
exit_program(1);
}
ost->frame_aspect_ratio = q;
}
MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, st);
MATCH_PER_STREAM_OPT(filters, str, ost->filters, oc, st);
if (!ost->stream_copy) {
const char *p = NULL;
char *frame_size = NULL;
char *frame_pix_fmt = NULL;
char *intra_matrix = NULL, *inter_matrix = NULL;
char *chroma_intra_matrix = NULL;
int do_pass = 0;
int i;
MATCH_PER_STREAM_OPT(frame_sizes, str, frame_size, oc, st);
if (frame_size && av_parse_video_size(&video_enc->width, &video_enc->height, frame_size) < 0) {
av_log(NULL, AV_LOG_FATAL, "Invalid frame size: %s.\n", frame_size);
exit_program(1);
}
video_enc->bits_per_raw_sample = frame_bits_per_raw_sample;
MATCH_PER_STREAM_OPT(frame_pix_fmts, str, frame_pix_fmt, oc, st);
if (frame_pix_fmt && *frame_pix_fmt == '+') {
ost->keep_pix_fmt = 1;
if (!*++frame_pix_fmt)
frame_pix_fmt = NULL;
}
if (frame_pix_fmt && (video_enc->pix_fmt = av_get_pix_fmt(frame_pix_fmt)) == AV_PIX_FMT_NONE) {
av_log(NULL, AV_LOG_FATAL, "Unknown pixel format requested: %s.\n", frame_pix_fmt);
exit_program(1);
}
st->sample_aspect_ratio = video_enc->sample_aspect_ratio;
if (intra_only)
video_enc->gop_size = 0;
MATCH_PER_STREAM_OPT(intra_matrices, str, intra_matrix, oc, st);
if (intra_matrix) {
if (!(video_enc->intra_matrix = av_mallocz(sizeof(*video_enc->intra_matrix) * 64))) {
av_log(NULL, AV_LOG_FATAL, "Could not allocate memory for intra matrix.\n");
exit_program(1);
}
parse_matrix_coeffs(video_enc->intra_matrix, intra_matrix);
}
MATCH_PER_STREAM_OPT(chroma_intra_matrices, str, chroma_intra_matrix, oc, st);
if (chroma_intra_matrix) {
uint16_t *p = av_mallocz(sizeof(*video_enc->chroma_intra_matrix) * 64);
if (!p) {
av_log(NULL, AV_LOG_FATAL, "Could not allocate memory for intra matrix.\n");
exit_program(1);
}
av_codec_set_chroma_intra_matrix(video_enc, p);
parse_matrix_coeffs(p, chroma_intra_matrix);
}
MATCH_PER_STREAM_OPT(inter_matrices, str, inter_matrix, oc, st);
if (inter_matrix) {
if (!(video_enc->inter_matrix = av_mallocz(sizeof(*video_enc->inter_matrix) * 64))) {
av_log(NULL, AV_LOG_FATAL, "Could not allocate memory for inter matrix.\n");
exit_program(1);
}
parse_matrix_coeffs(video_enc->inter_matrix, inter_matrix);
}
MATCH_PER_STREAM_OPT(rc_overrides, str, p, oc, st);
for (i = 0; p; i++) {
int start, end, q;
int e = sscanf(p, "%d,%d,%d", &start, &end, &q);
if (e != 3) {
av_log(NULL, AV_LOG_FATAL, "error parsing rc_override\n");
exit_program(1);
}
video_enc->rc_override =
av_realloc_array(video_enc->rc_override,
i + 1, sizeof(RcOverride));
video_enc->rc_override[i].start_frame = start;
video_enc->rc_override[i].end_frame = end;
if (q > 0) {
video_enc->rc_override[i].qscale = q;
video_enc->rc_override[i].quality_factor = 1.0;
}
else {
video_enc->rc_override[i].qscale = 0;
video_enc->rc_override[i].quality_factor = -q/100.0;
}
p = strchr(p, '/');
if (p) p++;
}
video_enc->rc_override_count = i;
if (do_psnr)
video_enc->flags|= CODEC_FLAG_PSNR;
MATCH_PER_STREAM_OPT(pass, i, do_pass, oc, st);
if (do_pass) {
if (do_pass & 1) {
video_enc->flags |= CODEC_FLAG_PASS1;
av_dict_set(&ost->encoder_opts, "flags", "+pass1", AV_DICT_APPEND);
}
if (do_pass & 2) {
video_enc->flags |= CODEC_FLAG_PASS2;
av_dict_set(&ost->encoder_opts, "flags", "+pass2", AV_DICT_APPEND);
}
}
MATCH_PER_STREAM_OPT(passlogfiles, str, ost->logfile_prefix, oc, st);
if (ost->logfile_prefix &&
!(ost->logfile_prefix = av_strdup(ost->logfile_prefix)))
exit_program(1);
MATCH_PER_STREAM_OPT(forced_key_frames, str, ost->forced_keyframes, oc, st);
if (ost->forced_keyframes)
ost->forced_keyframes = av_strdup(ost->forced_keyframes);
MATCH_PER_STREAM_OPT(force_fps, i, ost->force_fps, oc, st);
ost->top_field_first = -1;
MATCH_PER_STREAM_OPT(top_field_first, i, ost->top_field_first, oc, st);
ost->avfilter = get_ost_filters(o, oc, ost);
if (!ost->avfilter)
exit_program(1);
} else {
MATCH_PER_STREAM_OPT(copy_initial_nonkeyframes, i, ost->copy_initial_nonkeyframes, oc ,st);
}
if (ost->stream_copy)
check_streamcopy_filters(o, oc, ost, AVMEDIA_TYPE_VIDEO);
return ost;
}
| 1threat |
JavaScript: Merge multiple Arrays object in to single Array of objects : <p>I am receiving the following data in the variable </p>
<pre><code>let data = [
[{option: “foo0", value: “bar0”}],
[{option: “foo1", value: “bar1”}],
[{option: “foo2", value: “bar2”}],
[{option: “foo3", value: “bar3”}],
]
</code></pre>
<p>and I need to change the response to</p>
<pre><code>[
{option: “foo0", value: “bar0”},
{option: “foo1", value: “bar1”},
{option: “foo2", value: “bar2”},
{option: “foo3", value: “bar3”},
]
</code></pre>
<p>how can i do it in JS</p>
| 0debug |
static int mpc_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
{
AVStream *st = s->streams[stream_index];
MPCContext *c = s->priv_data;
AVPacket pkt1, *pkt = &pkt1;
int ret;
int index = av_index_search_timestamp(st, timestamp - DELAY_FRAMES, flags);
uint32_t lastframe;
if (index >= 0){
c->curframe = st->index_entries[index].pos;
return 0;
}
if(timestamp < 0 || timestamp >= c->fcount)
return -1;
timestamp -= DELAY_FRAMES;
lastframe = c->curframe;
if(c->frames_noted) c->curframe = c->frames_noted - 1;
while(c->curframe < timestamp){
ret = av_read_frame(s, pkt);
if (ret < 0){
c->curframe = lastframe;
return ret;
}
av_free_packet(pkt);
}
return 0;
}
| 1threat |
static void dynticks_rearm_timer(struct qemu_alarm_timer *t)
{
timer_t host_timer = (timer_t)(long)t->priv;
struct itimerspec timeout;
int64_t nearest_delta_us = INT64_MAX;
int64_t current_us;
if (!active_timers[QEMU_TIMER_REALTIME] &&
!active_timers[QEMU_TIMER_VIRTUAL])
return;
nearest_delta_us = qemu_next_deadline_dyntick();
if (timer_gettime(host_timer, &timeout)) {
perror("gettime");
fprintf(stderr, "Internal timer error: aborting\n");
exit(1);
}
current_us = timeout.it_value.tv_sec * 1000000 + timeout.it_value.tv_nsec/1000;
if (current_us && current_us <= nearest_delta_us)
return;
timeout.it_interval.tv_sec = 0;
timeout.it_interval.tv_nsec = 0;
timeout.it_value.tv_sec = nearest_delta_us / 1000000;
timeout.it_value.tv_nsec = (nearest_delta_us % 1000000) * 1000;
if (timer_settime(host_timer, 0 , &timeout, NULL)) {
perror("settime");
fprintf(stderr, "Internal timer error: aborting\n");
exit(1);
}
}
| 1threat |
Can't access A Path on powershell : so i follow [this][1] guide to delete steam cloud profile, and i have to clc a folder [Steam\userdata\95925904\381210\remote], and whenever i try to clc i get an access denied error, picture of the errror - https://gyazo.com/cbab29f1daa2506b474683af42696ec1. i follow this
i tried to open the powershell as administrator and it didnt help, also i couldnt find solutions on google so i decided to open a new thread | 0debug |
static int h264_set_parameter_from_sps(H264Context *h)
{
if (h->flags & CODEC_FLAG_LOW_DELAY ||
(h->sps.bitstream_restriction_flag &&
!h->sps.num_reorder_frames)) {
if (h->avctx->has_b_frames > 1 || h->delayed_pic[0])
av_log(h->avctx, AV_LOG_WARNING, "Delayed frames seen. "
"Reenabling low delay requires a codec flush.\n");
else
h->low_delay = 1;
if (h->avctx->has_b_frames < 2)
h->avctx->has_b_frames = !h->low_delay;
if (h->avctx->bits_per_raw_sample != h->sps.bit_depth_luma ||
h->cur_chroma_format_idc != h->sps.chroma_format_idc) {
if (h->avctx->codec &&
h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU &&
(h->sps.bit_depth_luma != 8 || h->sps.chroma_format_idc > 1)) {
av_log(h->avctx, AV_LOG_ERROR,
"VDPAU decoding does not support video colorspace.\n");
return AVERROR_INVALIDDATA;
if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
h->avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
h->cur_chroma_format_idc = h->sps.chroma_format_idc;
h->pixel_shift = h->sps.bit_depth_luma > 8;
ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma,
h->sps.chroma_format_idc);
ff_h264chroma_init(&h->h264chroma, h->sps.bit_depth_chroma);
ff_h264qpel_init(&h->h264qpel, h->sps.bit_depth_luma);
ff_h264_pred_init(&h->hpc, h->avctx->codec_id, h->sps.bit_depth_luma,
h->sps.chroma_format_idc);
h->dsp.dct_bits = h->sps.bit_depth_luma > 8 ? 32 : 16;
ff_dsputil_init(&h->dsp, h->avctx);
ff_videodsp_init(&h->vdsp, h->sps.bit_depth_luma);
} else {
av_log(h->avctx, AV_LOG_ERROR, "Unsupported bit depth: %d\n",
h->sps.bit_depth_luma);
return AVERROR_INVALIDDATA;
return 0; | 1threat |
What is the working logic of '==' while comparing two objects? : <p>What logic works when we compare two objects using '==' ? This logic is written in which file ? FYI I am aware that JVM checks if both reference variable point to the same object; I want to know what code must be there to determine if both reference point to same object ?</p>
| 0debug |
C# Splitting same line into 2 strings? : <p>I am making a project, But i need to be able to split 1 row of text into 2 strings.
How would i go about doing this?</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Threading;
using System.Linq;
using System.IO;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Console.Title = "Stinger";
Console.Write("Configuration FIle.... ");
Thread.Sleep(1000);
if (System.IO.File.Exists(@"C:\Stinger\Configuration\config.cfg"))
{
Console.Write("Found");
Thread.Sleep(1000);
Console.WriteLine("\r\n");
Console.WriteLine("--Configuration--");
string[] readText = File.ReadAllLines(@"C:\Stinger\Configuration\config.cfg");
foreach (string s in readText)
{
Console.WriteLine(s);
Thread.Sleep(1000);
}
}
else // Configuration File Else Statement
{
Console.WriteLine("Missing");
Thread.Sleep(4000);
}
}
}
</code></pre>
<p>And here is my Config Contents </p>
<pre><code>fullscreen 1
</code></pre>
<p>I want to be able to make "fullscreen" and "1" part of the row 2 strings.
I've done continuous googling and reading articles on how to split.
But it's not making any sense to me.
Any help?</p>
| 0debug |
How to display data between 2 dates in Listview andriod : How to display data between 2 dates in List view android..real time search.please help me.Any suggestions are welcomed. | 0debug |
int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,
BlockCompletionFunc *completion_cb,
void *opaque)
{
Error *local_err = NULL;
int err;
bdrv_add_key(bs, NULL, &local_err);
if (!local_err) {
if (completion_cb)
completion_cb(opaque, 0);
return 0;
}
if (monitor_ctrl_mode(mon)) {
qerror_report_err(local_err);
return -1;
}
monitor_printf(mon, "%s (%s) is encrypted.\n", bdrv_get_device_name(bs),
bdrv_get_encrypted_filename(bs));
mon->password_completion_cb = completion_cb;
mon->password_opaque = opaque;
err = monitor_read_password(mon, bdrv_password_cb, bs);
if (err && completion_cb)
completion_cb(opaque, err);
return err;
} | 1threat |
def same_Length(A,B):
while (A > 0 and B > 0):
A = A / 10;
B = B / 10;
if (A == 0 and B == 0):
return True;
return False; | 0debug |
dshow_cycle_pins(AVFormatContext *avctx, enum dshowDeviceType devtype,
IBaseFilter *device_filter, IPin **ppin)
{
struct dshow_ctx *ctx = avctx->priv_data;
IEnumPins *pins = 0;
IPin *device_pin = NULL;
IPin *pin;
int r;
const GUID *mediatype[2] = { &MEDIATYPE_Video, &MEDIATYPE_Audio };
const char *devtypename = (devtype == VideoDevice) ? "video" : "audio";
int set_format = (devtype == VideoDevice && (ctx->video_size || ctx->framerate))
|| (devtype == AudioDevice && (ctx->channels || ctx->sample_rate));
int format_set = 0;
r = IBaseFilter_EnumPins(device_filter, &pins);
if (r != S_OK) {
av_log(avctx, AV_LOG_ERROR, "Could not enumerate pins.\n");
return AVERROR(EIO);
}
if (!ppin) {
av_log(avctx, AV_LOG_INFO, "DirectShow %s device options\n",
devtypename);
}
while (IEnumPins_Next(pins, 1, &pin, NULL) == S_OK && !device_pin) {
IKsPropertySet *p = NULL;
IEnumMediaTypes *types = NULL;
PIN_INFO info = {0};
AM_MEDIA_TYPE *type;
GUID category;
DWORD r2;
IPin_QueryPinInfo(pin, &info);
IBaseFilter_Release(info.pFilter);
if (info.dir != PINDIR_OUTPUT)
goto next;
if (IPin_QueryInterface(pin, &IID_IKsPropertySet, (void **) &p) != S_OK)
goto next;
if (IKsPropertySet_Get(p, &ROPSETID_Pin, AMPROPERTY_PIN_CATEGORY,
NULL, 0, &category, sizeof(GUID), &r2) != S_OK)
goto next;
if (!IsEqualGUID(&category, &PIN_CATEGORY_CAPTURE))
goto next;
if (!ppin) {
char *buf = dup_wchar_to_utf8(info.achName);
av_log(avctx, AV_LOG_INFO, " Pin \"%s\"\n", buf);
av_free(buf);
dshow_cycle_formats(avctx, devtype, pin, NULL);
goto next;
}
if (set_format) {
dshow_cycle_formats(avctx, devtype, pin, &format_set);
if (!format_set) {
goto next;
}
}
if (IPin_EnumMediaTypes(pin, &types) != S_OK)
goto next;
IEnumMediaTypes_Reset(types);
while (IEnumMediaTypes_Next(types, 1, &type, NULL) == S_OK && !device_pin) {
if (IsEqualGUID(&type->majortype, mediatype[devtype])) {
device_pin = pin;
goto next;
}
CoTaskMemFree(type);
}
next:
if (types)
IEnumMediaTypes_Release(types);
if (p)
IKsPropertySet_Release(p);
if (device_pin != pin)
IPin_Release(pin);
}
IEnumPins_Release(pins);
if (ppin) {
if (set_format && !format_set) {
av_log(avctx, AV_LOG_ERROR, "Could not set %s options\n", devtypename);
return AVERROR(EIO);
}
if (!device_pin) {
av_log(avctx, AV_LOG_ERROR,
"Could not find output pin from %s capture device.\n", devtypename);
return AVERROR(EIO);
}
*ppin = device_pin;
}
return 0;
}
| 1threat |
perl: find the index of the nth occurrence of a character in a string : I've found `index` and `rindex` for finding the first or last occurrence of a character (or substring) in a string. I'm also aware that they have an `offset` that can be used to start at a certain index.
What I want to know is if there is a simple way to find the index `n`th occurrence of a character or substring in a string. I'd prefer not to have to do it regex and would prefer not to have to write a loop that just repeatedly calls `index` with an offset. | 0debug |
static inline int decode_mb(MDECContext *a, DCTELEM block[6][64]){
int i;
const int block_index[6]= {5,4,0,1,2,3};
a->dsp.clear_blocks(block[0]);
for(i=0; i<6; i++){
if( mdec_decode_block_intra(a, block[ block_index[i] ], block_index[i]) < 0)
return -1;
}
return 0;
}
| 1threat |
How to calculate the average values of a year from quarterly data? : <p>I have this dataframe and I want to calculate the average number of each year</p>
<pre><code>index cath_date
1 2017Q4 111
2 2017Q3 107
3 2018Q2 105
4 2017Q2 105
5 2017Q1 101
7 2018Q3 98
8 2016Q3 97
9 2018Q1 94
10 2018Q4 91
11 2016Q1 91
12 2015Q4 85
13 2016Q4 83
14 2016Q2 81
15 2015Q3 80
16 2015Q2 67
18 2015Q1 28
</code></pre>
<p>Finally to have a dataframe like this</p>
<pre><code>index cath_date
1 2015 28
2 2016 87
3 2017 87
4 2018 97
</code></pre>
| 0debug |
Jenkins delete builds older than latest 20 builds for all jobs : <p>I am in the process of cleaning up Jenkins (it was setup incorrectly) and I need to delete builds that are older than the latest 20 builds for every job.</p>
<p>Is there any way to automate this using a script or something?</p>
<p>I found many solutions to delete certain builds for specific jobs, but I can't seem to find anything for all jobs at once.</p>
<p>Any help is much appreciated.</p>
| 0debug |
bool qvirtio_wait_config_isr(const QVirtioBus *bus, QVirtioDevice *d,
uint64_t timeout)
{
do {
clock_step(100);
if (bus->get_config_isr_status(d)) {
break;
}
} while (--timeout);
return timeout != 0;
}
| 1threat |
The output of this program seems to print 5 0 1 instead of 5 1 1. I'm unable to figure out why : So this program's printing 5 0 and 1. Shouldn't it be 5 1 1? data1++ does increment f1.data1 to 1. Where really does the 0 come from? I'm using multiple functions because I've just started learning Objects and Classes and am trying to make as many possibilities as possible. This is really confusing me.
#include <iostream>
using namespace std;
class foo
{
private:
int data1; //private data member
public:
foo(): data1(0) //Constructor initialising it to 0.
{ }
void func(foo,foo);
void display(foo fg) const
{
cout<<data1;
cout<<endl;
cout<<fg.data1;
}
};
void foo::func(foo ff,foo fg)
{
ff.data1=5;
data1++;
ff.display(fg);
cout<<endl<<data1<<endl;
}
int main()
{
foo f1,f2;
f1.func(f2,f1);
return 0;
} | 0debug |
document.getElementById('input').innerHTML = user_input; | 1threat |
Grouping and flattening array of objects by multiple keys : <p>I'm trying to group by and flatten this array of objects:</p>
<pre><code>const data = [
{ RoleId: 1, RoleName: 'Admin', Permissions: 1 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 38 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 4 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 18 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 4001 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 30 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 20 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 2 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 10 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 99 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 5 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 22 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 4002 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 34 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 32 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 3 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 14 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 6 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 26 },
{ RoleId: 2, RoleName: 'AgencyAdmin', Permissions: 10 },
{ RoleId: 2, RoleName: 'AgencyAdmin', Permissions: 3 },
{ RoleId: 2, RoleName: 'AgencyAdmin', Permissions: 4001 },
{ RoleId: 2, RoleName: 'AgencyAdmin', Permissions: 18 },
{ RoleId: 2, RoleName: 'AgencyAdmin', Permissions: 4002 },
{ RoleId: 2, RoleName: 'AgencyAdmin', Permissions: 30 },
{ RoleId: 2, RoleName: 'AgencyAdmin', Permissions: 2 },
{ RoleId: 3, RoleName: 'InstituteAdmin', Permissions: 30 },
{ RoleId: 3, RoleName: 'InstituteAdmin', Permissions: 6 },
{ RoleId: 3, RoleName: 'InstituteAdmin', Permissions: 10 },
{ RoleId: 3, RoleName: 'InstituteAdmin', Permissions: 2 },
{ RoleId: 3, RoleName: 'InstituteAdmin', Permissions: 4002 },
{ RoleId: 3, RoleName: 'InstituteAdmin', Permissions: 18 },
{ RoleId: 3, RoleName: 'InstituteAdmin', Permissions: 3 },
{ RoleId: 3, RoleName: 'InstituteAdmin', Permissions: 4001 }
];
</code></pre>
<p>I've tried using lodash's groupBy method but I am unable to group by multiple keys and tried using zipObject as well but I was unable to get the expected results</p>
<pre><code>groupBy(data, 'RoleId')
</code></pre>
<p>Gives me an array that's grouped by the RoleId but the same doesn't work using an array of keys</p>
<p>What I want the resulting array to look like is as follows:</p>
<pre><code>[
{RoleId: 1, RoleName:'Admin', Permissions: [1, 38, 4, 18, ...]},
{RoleId: 2, RoleName:'AgencyAdmin', Permissions: [1, 38, 4, 18, ...]},
{RoleId: 3, RoleName:'InstituteAdmin', Permissions: [1, 38, 4, 18, ...]},
]
</code></pre>
<p>Does someone know how I can tackle this problem? Any help would be appreciated. Thank you!</p>
| 0debug |
static void write_codec_attr(AVStream *st, VariantStream *vs) {
int codec_strlen = strlen(vs->codec_attr);
char attr[32];
if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)
return;
if (vs->attr_status == CODEC_ATTRIBUTE_WILL_NOT_BE_WRITTEN)
return;
if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
uint8_t *data = st->codecpar->extradata;
if ((data[0] | data[1] | data[2]) == 0 && data[3] == 1 && (data[4] & 0x1F) == 7) {
snprintf(attr, sizeof(attr),
"avc1.%02x%02x%02x", data[5], data[6], data[7]);
} else {
goto fail;
}
} else if (st->codecpar->codec_id == AV_CODEC_ID_MP2) {
snprintf(attr, sizeof(attr), "mp4a.40.33");
} else if (st->codecpar->codec_id == AV_CODEC_ID_MP3) {
snprintf(attr, sizeof(attr), "mp4a.40.34");
} else if (st->codecpar->codec_id == AV_CODEC_ID_AAC) {
snprintf(attr, sizeof(attr), "mp4a.40.2");
} else if (st->codecpar->codec_id == AV_CODEC_ID_AC3) {
snprintf(attr, sizeof(attr), "ac-3");
} else if (st->codecpar->codec_id == AV_CODEC_ID_EAC3) {
snprintf(attr, sizeof(attr), "ec-3");
} else {
goto fail;
}
if (!av_stristr(vs->codec_attr, attr)) {
snprintf(vs->codec_attr + codec_strlen,
sizeof(vs->codec_attr) - codec_strlen,
"%s%s", codec_strlen ? "," : "", attr);
}
return;
fail:
vs->codec_attr[0] = '\0';
vs->attr_status = CODEC_ATTRIBUTE_WILL_NOT_BE_WRITTEN;
return;
}
| 1threat |
Convert RGB to sRGB? : <p>I am trying to convert an RGB to the perceptually uniform color space, CIELAB. Wikipedia states: </p>
<blockquote>
<p>"The RGB or CMYK values first must be transformed to a specific
absolute color space, such as sRGB or Adobe RGB. This adjustment will
be device-dependent, but the resulting data from the transform will be
device-independent, allowing data to be transformed to the CIE 1931
color space and then transformed into L*a * b*."</p>
</blockquote>
<p>I know there are some straightforward transformations once converting to sRGB, but I have not found any material to go from RGB to sRGB. So, what methods exist to do such a conversion?</p>
| 0debug |
A or input in navigation bar ? Why? : I don't know what I should use in my nav bar
<li><a> </a></li>
or
<li><input> </li>
In all tutorials is a but why ? In nav bar I have link to the next page and this solution is correct ? But what if button in nav-bar open popup window ? In this situation i should use input or still a ? | 0debug |
static int decode_frame(AVCodecContext * avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MPADecodeContext *s = avctx->priv_data;
uint32_t header;
int out_size;
OUT_INT *out_samples = data;
if(buf_size < HEADER_SIZE)
return -1;
header = AV_RB32(buf);
if(ff_mpa_check_header(header) < 0){
av_log(avctx, AV_LOG_ERROR, "Header missing\n");
return -1;
}
if (ff_mpegaudio_decode_header((MPADecodeHeader *)s, header) == 1) {
s->frame_size = -1;
return -1;
}
avctx->channels = s->nb_channels;
avctx->bit_rate = s->bit_rate;
avctx->sub_id = s->layer;
if(*data_size < 1152*avctx->channels*sizeof(OUT_INT))
return -1;
if(s->frame_size<=0 || s->frame_size > buf_size){
av_log(avctx, AV_LOG_ERROR, "incomplete frame\n");
return -1;
}else if(s->frame_size < buf_size){
av_log(avctx, AV_LOG_ERROR, "incorrect frame size\n");
buf_size= s->frame_size;
}
out_size = mp_decode_frame(s, out_samples, buf, buf_size);
if(out_size>=0){
*data_size = out_size;
avctx->sample_rate = s->sample_rate;
}else
av_log(avctx, AV_LOG_DEBUG, "Error while decoding MPEG audio frame.\n");
s->frame_size = 0;
return buf_size;
} | 1threat |
db.execute('SELECT * FROM employees WHERE id = ' + user_input) | 1threat |
static abi_long do_socketcall(int num, abi_ulong vptr)
{
static const unsigned ac[] = {
[SOCKOP_socket] = 3,
[SOCKOP_bind] = 3,
[SOCKOP_connect] = 3,
[SOCKOP_listen] = 2,
[SOCKOP_accept] = 3,
[SOCKOP_accept4] = 4,
[SOCKOP_getsockname] = 3,
[SOCKOP_getpeername] = 3,
[SOCKOP_socketpair] = 4,
[SOCKOP_send] = 4,
[SOCKOP_recv] = 4,
[SOCKOP_sendto] = 6,
[SOCKOP_recvfrom] = 6,
[SOCKOP_shutdown] = 2,
[SOCKOP_sendmsg] = 3,
[SOCKOP_recvmsg] = 3,
[SOCKOP_sendmmsg] = 4,
[SOCKOP_recvmmsg] = 4,
[SOCKOP_setsockopt] = 5,
[SOCKOP_getsockopt] = 5,
};
abi_long a[6];
if (num >= 0 && num < ARRAY_SIZE(ac)) {
unsigned i;
assert(ARRAY_SIZE(a) >= ac[num]);
for (i = 0; i < ac[num]; ++i) {
if (get_user_ual(a[i], vptr + i * sizeof(abi_long)) != 0) {
return -TARGET_EFAULT;
}
}
}
switch (num) {
case SOCKOP_socket:
return do_socket(a[0], a[1], a[2]);
case SOCKOP_bind:
return do_bind(a[0], a[1], a[2]);
case SOCKOP_connect:
return do_connect(a[0], a[1], a[2]);
case SOCKOP_listen:
return get_errno(listen(a[0], a[1]));
case SOCKOP_accept:
return do_accept4(a[0], a[1], a[2], 0);
case SOCKOP_accept4:
return do_accept4(a[0], a[1], a[2], a[3]);
case SOCKOP_getsockname:
return do_getsockname(a[0], a[1], a[2]);
case SOCKOP_getpeername:
return do_getpeername(a[0], a[1], a[2]);
case SOCKOP_socketpair:
return do_socketpair(a[0], a[1], a[2], a[3]);
case SOCKOP_send:
return do_sendto(a[0], a[1], a[2], a[3], 0, 0);
case SOCKOP_recv:
return do_recvfrom(a[0], a[1], a[2], a[3], 0, 0);
case SOCKOP_sendto:
return do_sendto(a[0], a[1], a[2], a[3], a[4], a[5]);
case SOCKOP_recvfrom:
return do_recvfrom(a[0], a[1], a[2], a[3], a[4], a[5]);
case SOCKOP_shutdown:
return get_errno(shutdown(a[0], a[1]));
case SOCKOP_sendmsg:
return do_sendrecvmsg(a[0], a[1], a[2], 1);
case SOCKOP_recvmsg:
return do_sendrecvmsg(a[0], a[1], a[2], 0);
case SOCKOP_sendmmsg:
return do_sendrecvmmsg(a[0], a[1], a[2], a[3], 1);
case SOCKOP_recvmmsg:
return do_sendrecvmmsg(a[0], a[1], a[2], a[3], 0);
case SOCKOP_setsockopt:
return do_setsockopt(a[0], a[1], a[2], a[3], a[4]);
case SOCKOP_getsockopt:
return do_getsockopt(a[0], a[1], a[2], a[3], a[4]);
default:
gemu_log("Unsupported socketcall: %d\n", num);
return -TARGET_ENOSYS;
}
}
| 1threat |
static void virtio_gpu_set_scanout(VirtIOGPU *g,
struct virtio_gpu_ctrl_command *cmd)
{
struct virtio_gpu_simple_resource *res;
struct virtio_gpu_scanout *scanout;
pixman_format_code_t format;
uint32_t offset;
int bpp;
struct virtio_gpu_set_scanout ss;
VIRTIO_GPU_FILL_CMD(ss);
trace_virtio_gpu_cmd_set_scanout(ss.scanout_id, ss.resource_id,
ss.r.width, ss.r.height, ss.r.x, ss.r.y);
if (ss.scanout_id >= g->conf.max_outputs) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: illegal scanout id specified %d",
__func__, ss.scanout_id);
cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_SCANOUT_ID;
return;
}
g->enable = 1;
if (ss.resource_id == 0) {
scanout = &g->scanout[ss.scanout_id];
if (scanout->resource_id) {
res = virtio_gpu_find_resource(g, scanout->resource_id);
if (res) {
res->scanout_bitmask &= ~(1 << ss.scanout_id);
}
}
if (ss.scanout_id == 0) {
qemu_log_mask(LOG_GUEST_ERROR,
"%s: illegal scanout id specified %d",
__func__, ss.scanout_id);
cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_SCANOUT_ID;
return;
}
dpy_gfx_replace_surface(g->scanout[ss.scanout_id].con, NULL);
scanout->ds = NULL;
scanout->width = 0;
scanout->height = 0;
return;
}
res = virtio_gpu_find_resource(g, ss.resource_id);
if (!res) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: illegal resource specified %d\n",
__func__, ss.resource_id);
cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;
return;
}
if (ss.r.x > res->width ||
ss.r.y > res->height ||
ss.r.width > res->width ||
ss.r.height > res->height ||
ss.r.x + ss.r.width > res->width ||
ss.r.y + ss.r.height > res->height) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: illegal scanout %d bounds for"
" resource %d, (%d,%d)+%d,%d vs %d %d\n",
__func__, ss.scanout_id, ss.resource_id, ss.r.x, ss.r.y,
ss.r.width, ss.r.height, res->width, res->height);
cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;
return;
}
scanout = &g->scanout[ss.scanout_id];
format = pixman_image_get_format(res->image);
bpp = (PIXMAN_FORMAT_BPP(format) + 7) / 8;
offset = (ss.r.x * bpp) + ss.r.y * pixman_image_get_stride(res->image);
if (!scanout->ds || surface_data(scanout->ds)
!= ((uint8_t *)pixman_image_get_data(res->image) + offset) ||
scanout->width != ss.r.width ||
scanout->height != ss.r.height) {
pixman_image_t *rect;
void *ptr = (uint8_t *)pixman_image_get_data(res->image) + offset;
rect = pixman_image_create_bits(format, ss.r.width, ss.r.height, ptr,
pixman_image_get_stride(res->image));
pixman_image_ref(res->image);
pixman_image_set_destroy_function(rect, virtio_unref_resource,
res->image);
scanout->ds = qemu_create_displaysurface_pixman(rect);
if (!scanout->ds) {
cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
return;
}
dpy_gfx_replace_surface(g->scanout[ss.scanout_id].con, scanout->ds);
}
res->scanout_bitmask |= (1 << ss.scanout_id);
scanout->resource_id = ss.resource_id;
scanout->x = ss.r.x;
scanout->y = ss.r.y;
scanout->width = ss.r.width;
scanout->height = ss.r.height;
} | 1threat |
static int select_input_file(uint8_t *no_packet)
{
int64_t ipts_min = INT64_MAX;
int i, file_index = -1;
for (i = 0; i < nb_input_streams; i++) {
InputStream *ist = input_streams[i];
int64_t ipts = ist->pts;
if (ist->discard || no_packet[ist->file_index])
continue;
if (!input_files[ist->file_index]->eof_reached) {
if (ipts < ipts_min) {
ipts_min = ipts;
file_index = ist->file_index;
}
}
}
return file_index;
}
| 1threat |
What is the difference between Google Compute Engine, App Engine and Container Engine in Google Cloud? : <p>What is the actual difference between Google Compute Engine, App Engine and Container Engine in Google Cloud Compute? When to use what?</p>
<p>Is there any good example to understand all of these three engines?</p>
| 0debug |
static void do_mac_write(lan9118_state *s, int reg, uint32_t val)
{
switch (reg) {
case MAC_CR:
if ((s->mac_cr & MAC_CR_RXEN) != 0 && (val & MAC_CR_RXEN) == 0) {
s->int_sts |= RXSTOP_INT;
}
s->mac_cr = val & ~MAC_CR_RESERVED;
DPRINTF("MAC_CR: %08x\n", val);
break;
case MAC_ADDRH:
s->conf.macaddr.a[4] = val & 0xff;
s->conf.macaddr.a[5] = (val >> 8) & 0xff;
lan9118_mac_changed(s);
break;
case MAC_ADDRL:
s->conf.macaddr.a[0] = val & 0xff;
s->conf.macaddr.a[1] = (val >> 8) & 0xff;
s->conf.macaddr.a[2] = (val >> 16) & 0xff;
s->conf.macaddr.a[3] = (val >> 24) & 0xff;
lan9118_mac_changed(s);
break;
case MAC_HASHH:
s->mac_hashh = val;
break;
case MAC_HASHL:
s->mac_hashl = val;
break;
case MAC_MII_ACC:
s->mac_mii_acc = val & 0xffc2;
if (val & 2) {
DPRINTF("PHY write %d = 0x%04x\n",
(val >> 6) & 0x1f, s->mac_mii_data);
do_phy_write(s, (val >> 6) & 0x1f, s->mac_mii_data);
} else {
s->mac_mii_data = do_phy_read(s, (val >> 6) & 0x1f);
DPRINTF("PHY read %d = 0x%04x\n",
(val >> 6) & 0x1f, s->mac_mii_data);
}
break;
case MAC_MII_DATA:
s->mac_mii_data = val & 0xffff;
break;
case MAC_FLOW:
s->mac_flow = val & 0xffff0000;
break;
case MAC_VLAN1:
break;
default:
hw_error("lan9118: Unimplemented MAC register write: %d = 0x%x\n",
s->mac_cmd & 0xf, val);
}
}
| 1threat |
Getting more hardware profiles in to Android Studio : <p>I have been looking for some time now for where to obtain and how to import new hardware profiles in to Android Studio, or manually build new ones, but have been unsuccessful. Can someone point me to a resource that would allow me to do this? Specifically, I am talking about this area within Android Studio.</p>
<p><a href="https://i.stack.imgur.com/g1R3Y.png" rel="noreferrer"><img src="https://i.stack.imgur.com/g1R3Y.png" alt="enter image description here"></a></p>
| 0debug |
Get the size of the window in Shiny : <p>I Would like to determine the size of the browser window in Shiny to help me layout my plot divs better. Specifically I would like to determine the aspect ratio of the window to see how many divs I should spread across the screen and it still look nice. My initial thought would be that the number of plots would be <code>floor(width/(height-navbar_height))</code>. </p>
<p>I did some looking for this and I am currently unable to locate a possible solution and am currently lead to believe that this feature is simply not present in the clientData structure. Any thoughts?</p>
| 0debug |
static void json_message_process_token(JSONLexer *lexer, QString *token, JSONTokenType type, int x, int y)
{
JSONMessageParser *parser = container_of(lexer, JSONMessageParser, lexer);
QDict *dict;
if (type == JSON_OPERATOR) {
switch (qstring_get_str(token)[0]) {
case '{':
parser->brace_count++;
break;
case '}':
parser->brace_count--;
break;
case '[':
parser->bracket_count++;
break;
case ']':
parser->bracket_count--;
break;
default:
break;
}
}
dict = qdict_new();
qdict_put(dict, "type", qint_from_int(type));
QINCREF(token);
qdict_put(dict, "token", token);
qdict_put(dict, "x", qint_from_int(x));
qdict_put(dict, "y", qint_from_int(y));
parser->token_size += token->length;
qlist_append(parser->tokens, dict);
if (type == JSON_ERROR) {
goto out_emit_bad;
} else if (parser->brace_count < 0 ||
parser->bracket_count < 0 ||
(parser->brace_count == 0 &&
parser->bracket_count == 0)) {
goto out_emit;
} else if (parser->token_size > MAX_TOKEN_SIZE ||
parser->bracket_count > MAX_NESTING ||
parser->brace_count > MAX_NESTING) {
goto out_emit;
}
return;
out_emit_bad:
QDECREF(parser->tokens);
parser->tokens = NULL;
out_emit:
parser->brace_count = 0;
parser->bracket_count = 0;
parser->emit(parser, parser->tokens);
if (parser->tokens) {
QDECREF(parser->tokens);
}
parser->tokens = qlist_new();
parser->token_size = 0;
}
| 1threat |
Where to find git release notes? : <p>I'm having trouble finding what's new in the latest release of git. For example, I could not find any info on git's main github <a href="https://github.com/git/git" rel="nofollow noreferrer">page</a>.</p>
<p>Where can one find git's release notes (ideally for all releases, but at least the latest one)?</p>
| 0debug |
Remove readonly attribute from all input box using jquery.? : I have multiple input text boxs all are by default read-only,So what i want is on-click on edit button remove read-only from all the text box.
**Html :**
<input type="text" name="fistname" readonly="true">
<input type="text" name="lastname" readonly="true">
<input type="text" name="emailaddres" readonly="true">
<input type="text" name="password" readonly="true">
<input type="button" name="edit" id="edit">
**Jquery :**
$(document).ready(function(e){
$(document).on("click","#edit",function(e){
// What should i do here..?
});
});
| 0debug |
static int bytes_left(ByteIOContext *bc)
{
return bc->buf_end - bc->buf_ptr;
}
| 1threat |
a tag inside span xpath selenium : I need to have an xpath wherein I could have a result of
**User xyz Successfully Created**.
Please help.
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/LhcqP.png | 0debug |
increase count from given id number : Working with 2 sheets in Google Sheets. I would like to have a script attached to a button that would take an id number generated in cell "H2" on sheet2, lookup/find the id in column B on sheet1, select that row, and then increase the value by 1 for the cell in column E of the selected row.
I do know how to create a button and attach the script.
Thanks for the help! | 0debug |
static int aea_read_header(AVFormatContext *s)
{
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avio_skip(s->pb, 264);
st->codec->channels = avio_r8(s->pb);
avio_skip(s->pb, 1783);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_ATRAC1;
st->codec->sample_rate = 44100;
st->codec->bit_rate = 292000;
if (st->codec->channels != 1 && st->codec->channels != 2) {
av_log(s,AV_LOG_ERROR,"Channels %d not supported!\n",st->codec->channels);
return -1;
}
st->codec->channel_layout = (st->codec->channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;
st->codec->block_align = AT1_SU_SIZE * st->codec->channels;
return 0;
}
| 1threat |
void alpha_translate_init(void)
{
#define DEF_VAR(V) { &cpu_##V, #V, offsetof(CPUAlphaState, V) }
typedef struct { TCGv *var; const char *name; int ofs; } GlobalVar;
static const GlobalVar vars[] = {
DEF_VAR(pc),
DEF_VAR(lock_addr),
DEF_VAR(lock_st_addr),
DEF_VAR(lock_value),
DEF_VAR(unique),
#ifndef CONFIG_USER_ONLY
DEF_VAR(sysval),
DEF_VAR(usp),
#endif
};
#undef DEF_VAR
static const char greg_names[31][4] = {
"v0", "t0", "t1", "t2", "t3", "t4", "t5", "t6",
"t7", "s0", "s1", "s2", "s3", "s4", "s5", "fp",
"a0", "a1", "a2", "a3", "a4", "a5", "t8", "t9",
"t10", "t11", "ra", "t12", "at", "gp", "sp"
};
static const char freg_names[31][4] = {
"f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
"f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
"f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
"f24", "f25", "f26", "f27", "f28", "f29", "f30"
};
static bool done_init = 0;
int i;
if (done_init) {
return;
}
done_init = 1;
cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
for (i = 0; i < 31; i++) {
cpu_ir[i] = tcg_global_mem_new_i64(TCG_AREG0,
offsetof(CPUAlphaState, ir[i]),
greg_names[i]);
}
for (i = 0; i < 31; i++) {
cpu_fir[i] = tcg_global_mem_new_i64(TCG_AREG0,
offsetof(CPUAlphaState, fir[i]),
freg_names[i]);
}
for (i = 0; i < ARRAY_SIZE(vars); ++i) {
const GlobalVar *v = &vars[i];
*v->var = tcg_global_mem_new_i64(TCG_AREG0, v->ofs, v->name);
}
}
| 1threat |
Javascript - Function Not Changing Global Variable : <p>My Code (Javascript):</p>
<pre><code>var num = 0;
function change(){
var num = 10;
}
change();
document.write(num);
</code></pre>
<p>The result should be <b>10</b> but it is showing 0. Why?<br>
If the code is wrong, what is the correct way to do this?</p>
| 0debug |
how to predict the demand for electrician,plumber etc : <p>We have a platform where user comes and book services like plumber,electrician service and choose a slot for service,we wanted to predict the demand of this system so that we can adjust the supply.
we are currently calculating and feeding supply for city a category b hub c time-slot combinations.
We would like to introduce a self learning algorithm that can calculate the capacity in these combinations and also tell us about the expected demand so we can build up supply accordingly</p>
| 0debug |
AWS: What does 0.0.0.0/0 and ::/0 mean? : <p>In security group, every inbound port I add, two rules are added, one for 0.0.0.0/0, the other ::/0. What do they each mean?</p>
| 0debug |
int avio_put_str16le(AVIOContext *s, const char *str)
{
const uint8_t *q = str;
int ret = 0;
while (*q) {
uint32_t ch;
uint16_t tmp;
GET_UTF8(ch, *q++, break;)
PUT_UTF16(ch, tmp, avio_wl16(s, tmp); ret += 2;)
}
avio_wl16(s, 0);
ret += 2;
return ret;
}
| 1threat |
Calling specific lines from a text file and storing them in an variable : #include <iostream>
#include <string>
#include <vector>
#include <fstream>
#define ORGANISATIONALRECORDSFILE "organisation.txt"
#define HRRECORDSFILE "HR_records.txt"
#define PAYROLLRECORDSFILE "payroll_records.txt"
using namespace std;
class OrganisationRecord
{
private:
public:
string name;
string occupation;
string department;
};
class HRRecord
{
private:
public:
string address;
string phonenumber;
string ninumber;
};
class PayrollRecord
{
private:
public:
string ninumber;
double salary;
};
class PayrollProcessing
{
private:
ifstream inputfile;
ofstream outputfile;
vector<OrganisationRecord> OrganisationRecords;
vector<HRRecord> HRRecords;
vector<PayrollRecord> PayrollRecords;
public:
void loadOrganisationRecords(string filename);
void loadHRRecords(string filename);
void loadPayrollRecords(string filename);
void displayEmployeeOfSalaryGTE(double salary);
//GTE = greater than or equal to
};
void PayrollProcessing::loadOrganisationRecords(string filename)
{
inputfile.open(ORGANISATIONALRECORDSFILE);
if (!inputfile)
{
cout << "the organisation records file does not exist" << endl;
return;
}
OrganisationRecord _organisationrecord;
int employeenumber;
while (inputfile >> employeenumber)
{
while (inputfile >> _organisationrecord.name)
{
cout << _organisationrecord.name;
//cout << _organisationrecord.occupation;
//cout << _organisationrecord.department <<endl;
}
OrganisationRecords.push_back(_organisationrecord);
}
}
int main(void)
{
PayrollProcessing database1;
database1.loadOrganisationRecords(ORGANISATIONALRECORDSFILE);
return 0;
}
i'd like to show the employee number, name, occupation, and department of employees from a text file called "organisation.txt", and save them in the variables declared in the class "organisation record". the file is as follows:
0001
Stephen Jones
Sales Clerk
Sales
0002
John Smith
Programmer
OS Development
0003
Fred Blogs
Project Manager
Outsourcing
| 0debug |
document.write('<script src="evil.js"></script>'); | 1threat |
Spring Boot: How to use multiple schemas and dynamically choose which one to use at runtime : <p>I have the same question as below, but I want to know the answer.
<a href="https://stackoverflow.com/questions/37602272/spring-boot-how-to-use-multiple-schemas-and-dynamically-choose-which-one-to-use#">Spring Boot: How to use multiple schemas and dynamically choose which one to use for every request at runtime</a></p>
<p>Please help me in finding answer for </p>
<p>How can I have one database connection and specify a different schema for every request?</p>
<p>Thank you in advance.</p>
| 0debug |
Building msbuild 15 project programmatically :
<p>I'm trying to build a simple C# 7 class library project created with VS2017. </p>
<p>MSBuild from framework assemblies is outdated, so I'm referencing <code>Microsoft.Build</code>, <code>Microsoft.Build.Engine</code> and <code>Microsoft.Build.Framework</code> from MSBuild folder within visual studio (<code>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin</code>).</p>
<p>Still, when I do this:</p>
<pre class="lang-cs prettyprint-override"><code>using (var collection = new ProjectCollection())
{
var proj = collection.LoadProject(@"c:\projects\Sample\Sample.csproj"); // <-- exception
proj.Build(new[] {new ConsoleLogger()});
}
</code></pre>
<p>I'm getting <code>InvalidProjectFileException: The tools version "15.0" is unrecognized. Available tools versions are "4.0", "2.0".</code></p>
<p>Is there programmatic way to invoke build using the latest build tools and C# 7 compiler?</p>
| 0debug |
Database operations in IntentService results into application halt,become unresponsive and giving ANR : <p>I am using an IntentService in a alarm manager to trigger it after every 15 seconds.
I have to continuously send large amount data to server and receiving large amount of data in response in background.
I have to follow beneath process : </p>
<ol>
<li><p>I am reading data from Database through queries.</p></li>
<li><p>Then converting it in Json through POJO architecture.</p></li>
<li><p>Sending this JSON in request to server using Retrofit Library.</p></li>
<li><p>Receiving data in response.</p></li>
<li><p>Inserting this data to my database through certain queries if any updation in the database.</p></li>
</ol>
<p>Is there any alternate approach? As i am facing ANR.
If data is less, its working fine. But as data size is becoming large, UI halts and Application becomes unresponsive.</p>
| 0debug |
'File name differs from already included file name only in casing' on relative path with same casing : <blockquote>
<p>Error TS1149: File name 'C:/Project/frontend/scripts/State.ts' differs from already included file name '../frontend/scripts/State.ts' only in casing.</p>
</blockquote>
<p>I've triple checked the casing in our references and the actual files have the correct casing as well. As far as I can tell, this is solely because the relative path uses incorrect casing, or perhaps it's just because of the relative path itself?</p>
<p>The thing is, it compiles just fine on Mac and Linux, but throws this error on Windows.</p>
<p>If it helps, <code>forceConsistentCasingInFileNames</code> is enabled in the tsconfig, and we're using tsify to compile.</p>
| 0debug |
Different layouts for single activity : <p>I want to create different view states for error and success of login page. For that I want to create the singe activity (login), Which will have email and password fields. After submitting the data if I'm getting success/error then I want to display different layout (not in different activity). How can I achieve that ? Simpy.. I need to display multiple layouts on single activity on changing its states. </p>
| 0debug |
Reassigning Variables via Destructuring : <p>I love Kotlin's destructuring features, they help me to declutter code and focus on the essential.</p>
<p>I encountered a case for which I could not figure out the correct syntax, how can I reassign variables via destructing?</p>
<pre><code>var (start, end) = startEndDate(198502)
// intellij neither accept this ...
start, end = startEndDate(200137)
// ... nor this
(start, end) = startEndDate(200137)
</code></pre>
| 0debug |
void qmp_block_passwd(bool has_device, const char *device,
bool has_node_name, const char *node_name,
const char *password, Error **errp)
{
Error *local_err = NULL;
BlockDriverState *bs;
int err;
bs = bdrv_lookup_bs(has_device ? device : NULL,
has_node_name ? node_name : NULL,
&local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
err = bdrv_set_key(bs, password);
if (err == -EINVAL) {
error_set(errp, QERR_DEVICE_NOT_ENCRYPTED, bdrv_get_device_name(bs));
return;
} else if (err < 0) {
error_set(errp, QERR_INVALID_PASSWORD);
return;
}
}
| 1threat |
static void generate_noise(G723_1_Context *p)
{
int i, j, idx, t;
int off[SUBFRAMES];
int signs[SUBFRAMES / 2 * 11], pos[SUBFRAMES / 2 * 11];
int tmp[SUBFRAME_LEN * 2];
int16_t *vector_ptr;
int64_t sum;
int b0, c, delta, x, shift;
p->pitch_lag[0] = cng_rand(&p->cng_random_seed, 21) + 123;
p->pitch_lag[1] = cng_rand(&p->cng_random_seed, 19) + 123;
for (i = 0; i < SUBFRAMES; i++) {
p->subframe[i].ad_cb_gain = cng_rand(&p->cng_random_seed, 50) + 1;
p->subframe[i].ad_cb_lag = cng_adaptive_cb_lag[i];
}
for (i = 0; i < SUBFRAMES / 2; i++) {
t = cng_rand(&p->cng_random_seed, 1 << 13);
off[i * 2] = t & 1;
off[i * 2 + 1] = ((t >> 1) & 1) + SUBFRAME_LEN;
t >>= 2;
for (j = 0; j < 11; j++) {
signs[i * 11 + j] = (t & 1) * 2 - 1 << 14;
t >>= 1;
}
}
idx = 0;
for (i = 0; i < SUBFRAMES; i++) {
for (j = 0; j < SUBFRAME_LEN / 2; j++)
tmp[j] = j;
t = SUBFRAME_LEN / 2;
for (j = 0; j < pulses[i]; j++, idx++) {
int idx2 = cng_rand(&p->cng_random_seed, t);
pos[idx] = tmp[idx2] * 2 + off[i];
tmp[idx2] = tmp[--t];
}
}
vector_ptr = p->audio + LPC_ORDER;
memcpy(vector_ptr, p->prev_excitation,
PITCH_MAX * sizeof(*p->excitation));
for (i = 0; i < SUBFRAMES; i += 2) {
ff_g723_1_gen_acb_excitation(vector_ptr, vector_ptr,
p->pitch_lag[i >> 1], &p->subframe[i],
p->cur_rate);
ff_g723_1_gen_acb_excitation(vector_ptr + SUBFRAME_LEN,
vector_ptr + SUBFRAME_LEN,
p->pitch_lag[i >> 1], &p->subframe[i + 1],
p->cur_rate);
t = 0;
for (j = 0; j < SUBFRAME_LEN * 2; j++)
t |= FFABS(vector_ptr[j]);
t = FFMIN(t, 0x7FFF);
if (!t) {
shift = 0;
} else {
shift = -10 + av_log2(t);
if (shift < -2)
shift = -2;
}
sum = 0;
if (shift < 0) {
for (j = 0; j < SUBFRAME_LEN * 2; j++) {
t = vector_ptr[j] << -shift;
sum += t * t;
tmp[j] = t;
}
} else {
for (j = 0; j < SUBFRAME_LEN * 2; j++) {
t = vector_ptr[j] >> shift;
sum += t * t;
tmp[j] = t;
}
}
b0 = 0;
for (j = 0; j < 11; j++)
b0 += tmp[pos[(i / 2) * 11 + j]] * signs[(i / 2) * 11 + j];
b0 = b0 * 2 * 2979LL + (1 << 29) >> 30;
c = p->cur_gain * (p->cur_gain * SUBFRAME_LEN >> 5);
if (shift * 2 + 3 >= 0)
c >>= shift * 2 + 3;
else
c <<= -(shift * 2 + 3);
c = (av_clipl_int32(sum << 1) - c) * 2979LL >> 15;
delta = b0 * b0 * 2 - c;
if (delta <= 0) {
x = -b0;
} else {
delta = square_root(delta);
x = delta - b0;
t = delta + b0;
if (FFABS(t) < FFABS(x))
x = -t;
}
shift++;
if (shift < 0)
x >>= -shift;
else
x <<= shift;
x = av_clip(x, -10000, 10000);
for (j = 0; j < 11; j++) {
idx = (i / 2) * 11 + j;
vector_ptr[pos[idx]] = av_clip_int16(vector_ptr[pos[idx]] +
(x * signs[idx] >> 15));
}
memcpy(vector_ptr + PITCH_MAX, vector_ptr,
sizeof(*vector_ptr) * SUBFRAME_LEN * 2);
vector_ptr += SUBFRAME_LEN * 2;
}
memcpy(p->prev_excitation, p->audio + LPC_ORDER + FRAME_LEN,
PITCH_MAX * sizeof(*p->excitation));
}
| 1threat |
static int add_rule(QemuOpts *opts, void *opaque)
{
struct add_rule_data *d = opaque;
BDRVBlkdebugState *s = d->s;
const char* event_name;
BlkDebugEvent event;
struct BlkdebugRule *rule;
event_name = qemu_opt_get(opts, "event");
if (!event_name || get_event_by_name(event_name, &event) < 0) {
return -1;
}
rule = g_malloc0(sizeof(*rule));
*rule = (struct BlkdebugRule) {
.event = event,
.action = d->action,
.state = qemu_opt_get_number(opts, "state", 0),
};
switch (d->action) {
case ACTION_INJECT_ERROR:
rule->options.inject.error = qemu_opt_get_number(opts, "errno", EIO);
rule->options.inject.once = qemu_opt_get_bool(opts, "once", 0);
rule->options.inject.immediately =
qemu_opt_get_bool(opts, "immediately", 0);
rule->options.inject.sector = qemu_opt_get_number(opts, "sector", -1);
break;
case ACTION_SET_STATE:
rule->options.set_state.new_state =
qemu_opt_get_number(opts, "new_state", 0);
break;
case ACTION_SUSPEND:
rule->options.suspend.tag =
g_strdup(qemu_opt_get(opts, "tag"));
break;
};
QLIST_INSERT_HEAD(&s->rules[event], rule, next);
return 0;
}
| 1threat |
how to share image through inten : how to image share though intent
enter code here
Bundle intent = getIntent().getExtras();`
cardView=(CardView)findViewById(R.id.card);
final String quary = intent.getString("Query1");
db = new DataBaseHelper(Image.this);
Cursor c = db.getData(quary);
if (c.getCount() != 0) {
c.moveToFirst();
do {
image = c.getString(5);
title=c.getString(3);
} while (c.moveToNext());
}
txt.setText(title);
img.setImageDrawable(getResources().getDrawable(getResources().getIdentifier(image, "drawable", getPackageName())));
| 0debug |
Why the correct output of this java code is 22? Not 12? : <p>I was solving some java-tasks and had a problem with that one:</p>
<pre><code>What is the output of this code?
public class Test {
public static int test(int i) {
try {
if (i == 0) throw new Exception();
return i;
} catch (Exception e) {
return 1;
} finally {
return 2;
}
}
public static void main(String[] args) {
System.out.print(test(0));
System.out.print(test(3));
}
}
</code></pre>
<p>The correct answer of that code is 22.</p>
<p>Could someone, please, explain to me, why 22? Why not 12?</p>
<p>Thanks!</p>
| 0debug |
how i add "read more" to my blog : i have HTML template then i convert my tamplet to wordpress theme, but i can't add "read more" to home page.
i use this code in functions.php:
function the_content_limit($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
$content = strip_tags($content);
if (strlen($_GET['p']) > 0) {
echo "<p>";
echo $content;
echo "</p>";
}
else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) {
$content = substr($content, 0, $espacio);
$content = $content;
echo "<p>";
echo $content;
echo "...";
echo "</p>";
}
else {
echo "<p>";
echo $content;
echo "</p>";
}
}
and i use this code in index.php
<div class="text_home"><?php the_content_limit(300); ?></div>
please, help me .. | 0debug |
Understanding how Lambda function works : <p>Help me understand Lambda functions, I checked a lot of codes but I still can't manage to understand it. Maybe with a simple example, thanks in advance.</p>
| 0debug |
Call a nodejs script within another one : <p>I have a two files written in javascript (node.js): server.js and extra.js</p>
<p>In server.js. I need to call extra.js using this</p>
<p>node extra 123456</p>
<p>123456 is <code>process.argv[2]</code> of extra.js in this case</p>
<p>I would like to know which module should I use in order to make this call</p>
| 0debug |
uint32_t HELPER(neon_max_f32)(uint32_t a, uint32_t b)
{
float32 f0 = make_float32(a);
float32 f1 = make_float32(b);
return (float32_compare_quiet(f0, f1, NFS) == 1) ? a : b;
}
| 1threat |
Linux driver: ioctl or sysfs? : <p>I'm writing a driver to control some custom hardware.</p>
<p>In the old days (i.e. 15yrs ago) I was doing this with <code>ioctls</code>, but am now digging into <code>sysfs</code> as a possible alternative.</p>
<ul>
<li>As I understand it, ioctls aren't totally deprecated, but sysfs is preferred (?)</li>
<li>I need to read/write sets of values simultaneously i.e. through one sysfs entry. I've read that this isn't ideal, but is acceptable if necessary (?)</li>
<li>There needs to be '<code>mutex</code>' protection on the driver, so that only one app can write to it at a time. (I do have some read-only 'info' entries which I'd prefer to keep accessible to all at all times).</li>
</ul>
<p>Given the above, what would be the best way to proceed - ioctl or sysfs?</p>
<p>If sysfs, then how can I implement exclusive access? </p>
<p>If sysfs, then if the driver has no read/write/ioctl fops, does it need open/release?!</p>
<p>(This is a 'private' driver, so I don't care massively ;), but figured if the new ways are more applicable then I might as well get to grips with them!)</p>
<p>Thanks.</p>
| 0debug |
static void h264_v_loop_filter_chroma_intra_c(uint8_t *pix, int stride, int alpha, int beta)
{
h264_loop_filter_chroma_intra_c(pix, stride, 1, alpha, beta);
}
| 1threat |
static void replication_start(ReplicationState *rs, ReplicationMode mode,
Error **errp)
{
BlockDriverState *bs = rs->opaque;
BDRVReplicationState *s;
BlockDriverState *top_bs;
int64_t active_length, hidden_length, disk_length;
AioContext *aio_context;
Error *local_err = NULL;
BlockJob *job;
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
s = bs->opaque;
if (s->stage != BLOCK_REPLICATION_NONE) {
error_setg(errp, "Block replication is running or done");
aio_context_release(aio_context);
return;
}
if (s->mode != mode) {
error_setg(errp, "The parameter mode's value is invalid, needs %d,"
" but got %d", s->mode, mode);
aio_context_release(aio_context);
return;
}
switch (s->mode) {
case REPLICATION_MODE_PRIMARY:
break;
case REPLICATION_MODE_SECONDARY:
s->active_disk = bs->file;
if (!s->active_disk || !s->active_disk->bs ||
!s->active_disk->bs->backing) {
error_setg(errp, "Active disk doesn't have backing file");
aio_context_release(aio_context);
return;
}
s->hidden_disk = s->active_disk->bs->backing;
if (!s->hidden_disk->bs || !s->hidden_disk->bs->backing) {
error_setg(errp, "Hidden disk doesn't have backing file");
aio_context_release(aio_context);
return;
}
s->secondary_disk = s->hidden_disk->bs->backing;
if (!s->secondary_disk->bs || !bdrv_has_blk(s->secondary_disk->bs)) {
error_setg(errp, "The secondary disk doesn't have block backend");
aio_context_release(aio_context);
return;
}
active_length = bdrv_getlength(s->active_disk->bs);
hidden_length = bdrv_getlength(s->hidden_disk->bs);
disk_length = bdrv_getlength(s->secondary_disk->bs);
if (active_length < 0 || hidden_length < 0 || disk_length < 0 ||
active_length != hidden_length || hidden_length != disk_length) {
error_setg(errp, "Active disk, hidden disk, secondary disk's length"
" are not the same");
aio_context_release(aio_context);
return;
}
if (!s->active_disk->bs->drv->bdrv_make_empty ||
!s->hidden_disk->bs->drv->bdrv_make_empty) {
error_setg(errp,
"Active disk or hidden disk doesn't support make_empty");
aio_context_release(aio_context);
return;
}
reopen_backing_file(bs, true, &local_err);
if (local_err) {
error_propagate(errp, local_err);
aio_context_release(aio_context);
return;
}
error_setg(&s->blocker,
"Block device is in use by internal backup job");
top_bs = bdrv_lookup_bs(s->top_id, s->top_id, NULL);
if (!top_bs || !bdrv_is_root_node(top_bs) ||
!check_top_bs(top_bs, bs)) {
error_setg(errp, "No top_bs or it is invalid");
reopen_backing_file(bs, false, NULL);
aio_context_release(aio_context);
return;
}
bdrv_op_block_all(top_bs, s->blocker);
bdrv_op_unblock(top_bs, BLOCK_OP_TYPE_DATAPLANE, s->blocker);
job = backup_job_create(NULL, s->secondary_disk->bs, s->hidden_disk->bs,
0, MIRROR_SYNC_MODE_NONE, NULL, false,
BLOCKDEV_ON_ERROR_REPORT,
BLOCKDEV_ON_ERROR_REPORT, BLOCK_JOB_INTERNAL,
backup_job_completed, bs, NULL, &local_err);
if (local_err) {
error_propagate(errp, local_err);
backup_job_cleanup(bs);
aio_context_release(aio_context);
return;
}
block_job_start(job);
break;
default:
aio_context_release(aio_context);
abort();
}
s->stage = BLOCK_REPLICATION_RUNNING;
if (s->mode == REPLICATION_MODE_SECONDARY) {
secondary_do_checkpoint(s, errp);
}
s->error = 0;
aio_context_release(aio_context);
} | 1threat |
Sql Triggers-Implementation Issue : Hi guys i am making 2 tables for implementing triggers--
create table emp(id int primary key identity(1,1),
name char(40),
salary varchar(50),
gender char(40),
departmentid int);
insert into emp(name,salary,gender,departmentid) values ('jimmi',4800,'Male',4);
create table emp_audit
(
id int primary key identity(1,1),
audit varchar(60)
);
alter trigger trigger_em_update on emp for update
as begin
Declare @Id int
Declare @oldname char(40),@newname char(40)
Declare @oldsal int,@newsal int
Declare @oldgen char(40),@newgen char(40)
Declare @olddeptid int,@newdeptid int
Declare @auditstring nvarchar(max)
--select * from deleted;
select * into #temptable from inserted;
while(Exists(select id from #temptable)) --boolean condition if there are rows are not
Begin
set @auditstring =''
--if there are many rows we still select the first one
select Top 1 @Id =id,@newname=name,@newgen=gender,@newsal=salary,@newdeptid=departmentid
from #temptable;
select Top 1 @Id =id,@oldname=name,@oldgen=gender,@oldsal=salary,@olddeptid=departmentid
from deleted where @Id=id;
set @auditstring=' Employee with id= '+CAST(@Id as varchar(20))+ ' changed '
if(@oldname<>@newname)
set @auditstring=@auditstring + 'name from '+ @oldname +' to' +@newname
if(@oldsal<>@newsal)
set @auditstring=@auditstring + ' salary from '+ @oldsal +' to ' +@newsal
if(@oldgen<>@newgen)
set @auditstring=@auditstring + ' gender from ' + @oldgen + ' to ' + @newgen
-- if(@olddeptid<>@newdeptid)
--set @auditstring=@auditstring + ' departmentid from ' + cast(@olddeptid as nvarchar(5))+' to '
insert into emp_audit values(@auditstring)
delete from #temptable where id=@Id
end
end
when i use update query
update emp set name='vishi',gender='male',salary='4000',departmentid=3 where id=3;
it gives an error "Conversion failed when converting the nvarchar value ' Employee with id= 3 changed name from james tovishi salary from ' to data type int.
"
i don't know how to solve this..can you solve this..
| 0debug |
static void ahci_shutdown(AHCIQState *ahci)
{
QOSState *qs = ahci->parent;
ahci_clean_mem(ahci);
free_ahci_device(ahci->dev);
g_free(ahci);
qtest_shutdown(qs);
}
| 1threat |
After creating the second object the constructor program wont ask what I use getline for : <p>So I am relatively new to C++ and I was doing a small project where I have the user enter a movie title, rating, and year. For the first run through, the program works well. After the user enters the desired information I print it back to the screen with no problem. However, when I create a second movie object to do the same thing during the same run it skips the section where it asks for the Title and goes directly to the rating. Any ideas? It's most likely a noob error. My Code is below.</p>
<p>MovieProject.cpp</p>
<pre><code>#include "stdafx.h"
#include "Movie.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
Movie starwars;
starwars.MovieTeller(starwars);
Movie FerrisBueller;
FerrisBueller.MovieTeller(FerrisBueller);
Movie TheFoxandTheHound;
TheFoxandTheHound.MovieTeller(TheFoxandTheHound);
return 0;
}
</code></pre>
<p>Movie.cpp</p>
<pre><code> #include "stdafx.h"
#include "Movie.h"
#include <string>
#include <iostream>
using namespace std;
Movie::Movie()
{
cout << "What is the title of your movie:";
getline(cin,Title);
cout << "What is the Rating:";
getline(cin,Rating);
cout << "What year was it made:";
cin >> Year;
cout << "\n" << endl;
if (Year > 2016) {
cout << "Comon Dude stop messing around" << endl;
exit(404);
}
}
void Movie::MovieTeller(Movie a) {
cout << "Title:" << Title << "\n" << "Rating:" << Rating << "\n" << "Year:" << Year << "\n" << endl;
}
Movie::~Movie()
{
}
</code></pre>
<p>Movie.h</p>
<pre><code>#pragma once
#include <iostream>
using namespace std;
class Movie
{
public:
Movie();
~Movie();
void MovieTeller(Movie a);
private:
string Title;
string Rating;
int Year;
};
</code></pre>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.