problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
void qemu_free(void *ptr)
{
free(ptr);
}
| 1threat |
static int xan_decode_frame_type0(AVCodecContext *avctx)
{
XanContext *s = avctx->priv_data;
uint8_t *ybuf, *prev_buf, *src = s->scratch_buffer;
unsigned chroma_off, corr_off;
int cur, last;
int i, j;
int ret;
chroma_off = bytestream2_get_le32(&s->gb);
corr_off = bytestream2_get_le32(&s->gb);
if ((ret = xan_decode_chroma(avctx, chroma_off)) != 0)
return ret;
if (corr_off >= bytestream2_size(&s->gb)) {
av_log(avctx, AV_LOG_WARNING, "Ignoring invalid correction block position\n");
corr_off = 0;
}
bytestream2_seek(&s->gb, 12, SEEK_SET);
ret = xan_unpack_luma(s, src, s->buffer_size >> 1);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "Luma decoding failed\n");
return ret;
}
ybuf = s->y_buffer;
last = *src++;
ybuf[0] = last << 1;
for (j = 1; j < avctx->width - 1; j += 2) {
cur = (last + *src++) & 0x1F;
ybuf[j] = last + cur;
ybuf[j+1] = cur << 1;
last = cur;
}
ybuf[j] = last << 1;
prev_buf = ybuf;
ybuf += avctx->width;
for (i = 1; i < avctx->height; i++) {
last = ((prev_buf[0] >> 1) + *src++) & 0x1F;
ybuf[0] = last << 1;
for (j = 1; j < avctx->width - 1; j += 2) {
cur = ((prev_buf[j + 1] >> 1) + *src++) & 0x1F;
ybuf[j] = last + cur;
ybuf[j+1] = cur << 1;
last = cur;
}
if(j < avctx->width)
ybuf[j] = last << 1;
prev_buf = ybuf;
ybuf += avctx->width;
}
if (corr_off) {
int dec_size;
bytestream2_seek(&s->gb, 8 + corr_off, SEEK_SET);
dec_size = xan_unpack(s, s->scratch_buffer, s->buffer_size);
if (dec_size < 0)
dec_size = 0;
else
dec_size = FFMIN(dec_size, s->buffer_size/2 - 1);
for (i = 0; i < dec_size; i++)
s->y_buffer[i*2+1] = (s->y_buffer[i*2+1] + (s->scratch_buffer[i] << 1)) & 0x3F;
}
src = s->y_buffer;
ybuf = s->pic.data[0];
for (j = 0; j < avctx->height; j++) {
for (i = 0; i < avctx->width; i++)
ybuf[i] = (src[i] << 2) | (src[i] >> 3);
src += avctx->width;
ybuf += s->pic.linesize[0];
}
return 0;
}
| 1threat |
Search a file in all directories with c# : I have a question. I need to find the file also return the address of the file. I already tried but it does not work. Do you have any idea how to do this?
I was using this code:
var files = new List<string>();
//@Stan R. suggested an improvement to handle floppy drives...
//foreach (DriveInfo d in DriveInfo.GetDrives())
foreach (DriveInfo d in DriveInfo.GetDrives().Where(x => x.IsReady == true))
{
files.AddRange(Directory.GetFiles(d.RootDirectory.FullName, actualFile, SearchOption.AllDirectories));
}
Please, help me. | 0debug |
i won't able to call the method of supper class : import java.util.*; class supers { int x,y; supers(int a,int b) { x=a; y=b; } final void volume() { System.out.println("area is "+x*y); } } class sub extends supers { int z; sub(int a,int b,int c) { super(a,b); z=c; } /*void volume() { System.out.println("volume is "+x*y*z); } /* } class m { public static void main(String args[]) { sub obj = new sub(1,2,3); obj.volume(); } } | 0debug |
Game development: Are in-game interrupts ever used? : <p>I'm learning game development, and the tutorials tell me to put everything in a while (1) loop. However, this is discouraged in embedded systems, where it's better if everything is treated as an interrupt. </p>
<p>Does this same concept apply in game development? I feel as if adding everything into a continuous loop would slow down a game significantly.</p>
| 0debug |
static AioContext *thread_pool_get_aio_context(BlockAIOCB *acb)
{
ThreadPoolElement *elem = (ThreadPoolElement *)acb;
ThreadPool *pool = elem->pool;
return pool->ctx;
}
| 1threat |
Facebook SDK iOS - User photos doesn't retrieving in release build but works perfectly in Debug build. : <p>I am facing a weird bug with Facebook SDK. When i trying to request user photos from the SDK it works perfect with Debug mode. When i tried with Release mode it fails to retrieve the photos(But still works with iPad 4,iPhone 5 and old devices). I doubt whether the issue is with arm64. Moreover my App status is live and it is available for public.</p>
| 0debug |
Rounded Corner Crop Image Using Jquery : <p>Does anyone knows a library to crop an image to achieve a rounded corner output? I've found this <a href="https://foliotek.github.io/Croppie/" rel="nofollow">https://foliotek.github.io/Croppie/</a> but it only crops the image to cicrle.
I want to crop the image to this shape: <a href="http://harboarts.com/shirtdesigner/jpg_design_exports/square_rounded_corners%20_vector-graphic_1331986667453.jpg" rel="nofollow">http://harboarts.com/shirtdesigner/jpg_design_exports/square_rounded_corners%20_vector-graphic_1331986667453.jpg</a></p>
| 0debug |
static int mm_decode_pal(MmContext *s)
{
int i;
bytestream2_skip(&s->gb, 4);
for (i = 0; i < 128; i++) {
s->palette[i] = 0xFF << 24 | bytestream2_get_be24(&s->gb);
s->palette[i+128] = s->palette[i]<<2;
}
return 0;
}
| 1threat |
how do i can join two or more selects values in one span? : i want to join or combine two or more select options in one span using jquery or Javascript, like this:
<body>
<label>Product:</label> <select id='Product' value='Product'>
<option value=" " selected>--Select your Product--</option>
<option>Option 1</option>
<option>Option 2</option>
</select>
<label>Subproduct:</label> <select id='SubProd' value='SubProd'>
<option value=" " selected>--Select your Subproduct--</option>
<option>Sub 1</option>
<option>Sub 2</option>
</select>
<br>
<span id="joined"></span>
</body>
in the span i want that the output shows "Product1/Sub1" depending on the option selected. i've been searching but i can't find something useful for me
thanks in advance and i'm sorry if i have grammar errors. | 0debug |
How to enable cross origin requests in ASP.NET MVC : <p>I am trying to create a web application which works with cross-origin requests (CORS) in MVC 5. I have tried everything without any result.</p>
<p><strong>With an attribute</strong> </p>
<pre><code>public class AllowCrossSiteJsonAttribute: ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
filterContext.RequestContext.HttpContext.Response.AddHeader("Access-Control-Allow-Origin", "*");
base.OnActionExecuting(filterContext);
}
}
</code></pre>
<p><strong>With EnableCors attribute</strong> </p>
<pre><code> [EnableCors("*")]
</code></pre>
<p>Nothing works I'm starting to think that it is impossible</p>
| 0debug |
static inline void RENAME(rgb32tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
{
uint8_t *dest = dst;
const uint8_t *s = src;
const uint8_t *end;
const uint8_t *mm_end;
end = s + src_size;
__asm__ volatile(PREFETCH" %0"::"m"(*s):"memory");
mm_end = end - 31;
while (s < mm_end) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq 8%1, %%mm1 \n\t"
"movq 16%1, %%mm4 \n\t"
"movq 24%1, %%mm5 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq %%mm1, %%mm3 \n\t"
"movq %%mm4, %%mm6 \n\t"
"movq %%mm5, %%mm7 \n\t"
STORE_BGR24_MMX
:"=m"(*dest)
:"m"(*s)
:"memory");
dest += 24;
s += 32;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
while (s < end) {
*dest++ = *s++;
*dest++ = *s++;
*dest++ = *s++;
s++;
}
}
| 1threat |
how to open next form base on select query base on flag : Iam creating one application my requirment is what when coloumn name Status is N in Registration table then current form should hide and Login form should be open
if Status is not N then its should be open Registration_Form im trying but its giving me error Error creating window handle.on rf.Show()
string connectionString = null;
connectionString = ConfigurationManager.ConnectionStrings["AccessConnectionString"].ConnectionString;
con.ConnectionString = connectionString;
string Comparing="N";
string query = "select Status from Registration where Status='N'";
con.Open();
OleDbCommand cmd = new OleDbCommand(query, con);
string compare = Convert.ToString(cmd.ExecuteScalar());
con.Close();
if (compare == Comparing)
{
this.Hide();
Login_Page lp = new Login_Page();
lp.Show();
}
else if (compare != Comparing)
{
Registration_Form rf = new Registration_Form();
rf.Show(); --error coming this line
} | 0debug |
def max_Abs_Diff(arr,n):
minEle = arr[0]
maxEle = arr[0]
for i in range(1, n):
minEle = min(minEle,arr[i])
maxEle = max(maxEle,arr[i])
return (maxEle - minEle) | 0debug |
void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
{
const char *device = qdict_get_str(qdict, "device");
const char *filename = qdict_get_str(qdict, "target");
const char *format = qdict_get_try_str(qdict, "format");
int reuse = qdict_get_try_bool(qdict, "reuse", 0);
int full = qdict_get_try_bool(qdict, "full", 0);
enum NewImageMode mode;
Error *errp = NULL;
if (!filename) {
error_set(&errp, QERR_MISSING_PARAMETER, "target");
hmp_handle_error(mon, &errp);
return;
}
if (reuse) {
mode = NEW_IMAGE_MODE_EXISTING;
} else {
mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
}
qmp_drive_mirror(device, filename, !!format, format,
full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP,
true, mode, false, 0, &errp);
hmp_handle_error(mon, &errp);
}
| 1threat |
How to output the name in their id : I have a problem, I want that each id in the foreign key can output the name instead of their id. [Here's the image][1]
Here's my code :
<table class="altrowstable" data-responsive="table" >
<thead >
<tr>
<th> IDno</th>
<th> Lastname </th>
<th> Firstname </th>
<th> Department </th>
<th> Program </th>
<th> Action</th>
</tr>
</thead>
<tbody>
<div style="text-align:center; line-height:50px;">
<?php
include('../connection/connect.php');
$YearNow=Date('Y');
$result = $db->prepare("SELECT * FROM student,school_year where user_type =3 AND student.syearid = school_year.syearid AND school_year.from_year like $YearNow ");
$result->execute();
for($i=0; $row = $result->fetch(); $i++){
?>
<tr class="record">
<td><?php echo $row['idno']; ?></td>
<td><?php echo $row['lastname']; ?></td>
<td><?php echo $row['firstname']; ?></td>
//name belong's to their id's
<td><?php echo $row['dept_id']; ?></td>
<td><?php echo $row['progid']; ?></td>
<td><a style="border:1px solid grey; background:grey; border-radius:10%; padding:7px 12px; color:white; text-decoration:none; " href="addcandidates.php?idno=<?php echo $row['idno']; ?>" > Running</a></div></td>
</tr>
<?php
}
?>
</tbody>
</table>
Thanks guys need a help
[1]: http://i.stack.imgur.com/aOWkd.png
| 0debug |
How to use context api with react router v4? : <p>I'm trying here on my application to do some tests with the new context API from React 16.3 but I can't understand why my redirect never works.</p>
<pre><code><ContextA>
<Switch>
<Route exact path='/route1' component={ Component1 } />
<ContextB>
<Route exact path='/route2' component={ Component2 } />
<Route exact path='/route3' component={ Component3 } />
</ContextB>
<Redirect from='/' to='/route1' />
</Switch>
</ContextA>
</code></pre>
<p>I don't want to have my ContextB available for all the routes, just 2 and 3. How can I do this?</p>
| 0debug |
PHP bug? Two functions with different names announced as redeclaration : <p>I need to declare two functions with different names (small 'i' and big "I").</p>
<pre><code>function i() {
echo 'Small i';
}
function I() {
echo 'Big I';
}
</code></pre>
<p>PHP's output is:</p>
<pre><code>PHP Fatal error: Cannot redeclare I()
</code></pre>
<p>Why? Small "i" is not big "I".</p>
<p>I tested it in Linux and in Windows.</p>
| 0debug |
andorid: simple adapter null pointer : i have an app that i want to retrive data from my server with php json and get method , i use simple adapter and json downloader and json parser for this app ,
i have problem with my simple adapter to show my data in my listView ,
when i run my project it occure with crash and show some errors
this is in main activity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTextMessage = (TextView) findViewById(R.id.message);
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
set_bedehkariha_list();
}
public void set_bedehkariha_list(){
JSONDownloader jsdl = new JSONDownloader();
String temp = jsdl.downloadURL( "http://famila1.ir/khabgah/get_khabgah_cash.php");
List<HashMap<String,Object>> cash = new ArrayList<HashMap<String, Object>>();
cashParser cashparse = new cashParser();
cash= cashparse.parse(temp);
String[] from = {"hazine","tozihat","hazine_shareTo","who_paid","date"};
int[] to = {R.id.mablaq_hazine,R.id.babate_hazine,R.id.moshtarak_ba,R.id.pardakhtaz,R.id.tarikh_hazine};
SimpleAdapter myadapter = new SimpleAdapter(MainActivity.this,cash, R.layout.cash_list_row,from,to);
ListView lv = (ListView) findViewById(R.id.list_bedehkariha);
lv.setAdapter(myadapter);
}
this is jsonDownloader:
public class JSONDownloader
{
public String downloadURL( String strUrl )
{
String data = "";
try
{
URL url = new URL( strUrl );
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setReadTimeout(10000);
connection.setConnectTimeout(15000);
connection.setRequestMethod("GET");
connection.setDoInput(true);
connection.connect();
InputStream myStream = connection.getInputStream();
BufferedReader br = new BufferedReader( new InputStreamReader( myStream ) );
StringBuilder sb = new StringBuilder();
String line;
while ( ( line = br.readLine() ) != null )
{
sb.append( line );
}
data = sb.toString();
br.close();
connection.disconnect();
myStream.close();
}
catch ( Exception e )
{
/*
*Log.i( "MatiMessage" , "error in JSONDownloader in downloadURL() -> " + e.toString() );
*/
}
return data;
}
and this is my JsonParser:
public List<HashMap<String , Object>> parse( String json )
{
List<HashMap<String , Object>> all_cash = new ArrayList<>();
try
{
JSONObject jObj = new JSONObject( json );
JSONArray jArr = jObj.getJSONArray( "cash" );
for( int i = 0; i < jArr.length(); i ++ )
{
JSONObject temp = jArr.getJSONObject( i );
HashMap<String , Object> cash = new HashMap<String , Object>();
cash.put( "id" , temp.getString( "id" ) );
cash.put( "member_id" , temp.getString( "member_id" ) );
cash.put( "hazine" , temp.getString( "hazine" ) );
cash.put( "date" , temp.getString( "date" ) );
cash.put( "hazine_shareTo" , "hazine_shareTo" );
cash.put( "tozihat" , temp.getString( "tozihat" ) );
cash.put( "who_paid" , temp.getString( "who_paid" ) );
all_cash.add( cash );
}
}
catch ( Exception e )
{
/*
* Log.i( "MatiMessage" , "error in cashParser in parse() -> " + e.toString() );
*/
}
return ( all_cash );
}
and this is my error in main activity when i run the app :
> java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.aqamamad.myapplication/com.example.aqamamad.myapplication.MainActivity}:
> java.lang.NullPointerException: Attempt to invoke virtual method 'void
> android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a
> null object reference
| 0debug |
Rise4Fun.com is down. How else can I get documentation for Z3? : <p>I have a project that's supposed to be using Z3 but the docs are all on Rise4Fun.com which has been down since Friday. I can't find any information at all about why it is down, if it will be back up, or where other docs might be stored. Does anyone have any information?</p>
| 0debug |
How to use break in if (Command) : <p>I am using <strong><em>$i</em></strong> string for limit in foreach loop.</p>
<pre><code>$i = 0;
foreach($string as $menu){
$i++;
if($i == 6){
break;
}
$menu_name = $menu['name'];
$menu_style = $menu['style'];
// i want to show total 5 menu names.
if($menu_style == 'magazine'){
// i have 5+ menus names (magazine style)
// butt here i want to show just one last magazine
echo $menu_name;
}
if($menu_style == 'normal'){
// i have 5+ names menus (normal style)
// butt here i want to show 4 last normal style
echo $menu_name.'<br>';
}
}
</code></pre>
<p>I can't want to use LIMIT in SQL query.</p>
<blockquote>
<p>And tell me when i use <em>if($i == 5){ break; }</em> then code display just 4
menu name</p>
</blockquote>
<p>Tell me how is display menu name as my required.</p>
| 0debug |
flipping array element data in C using nested loops : <p>How can I flip the element of an array using a nested loops as shown below ?</p>
<pre><code>-1 -2 -3 3 2 1
4 5 6 --------> 4 5 6
1 2 3 -3 -2 -1
</code></pre>
<p>Many thanks ^_^ </p>
| 0debug |
How do I remove grid lines from a Bokeh plot? : <p>I would like to remove the grid lines from a Bokeh plot. What is the best way to do this?</p>
| 0debug |
REGX pattern in javascript : I need regx javascript pattern for following
I tried regexp("^([a-za-z0-9-|](4)[a-za-z0-9-|](5)[a-za-z0-9-|](3)+)$") like this.
**test|test|test1234** | 0debug |
I wanna add an input field to get **day and month** from user , i don't want the year , how can i do that in HTML? : <p>Can someone help me to get <strong>day and month</strong> from user as Increment Date of an Employee?</p>
| 0debug |
Composition vs Inner Classes : <p>What are the differences and the similarities between composition and inner classes?
I am trying to learn the principles of Java and try to figure out the whole image. For me is better to make analogies and to see the differences and similarities between concepts, in order to use them corectly.</p>
<p>Definition of composition:
"Composition is the design technique to implement has-a relationship in classes".
"Java composition is achieved by using instance variables that refers to other objects"</p>
<p>Definition of inner class(or member class,not anonymous):
"A member class is also defined as a member of an enclosing class, but is not declared with the static modifier. This type of inner class is analogous to an instance method or field. An instance of a member class is always associated with an instance of the enclosing class, and the code of a member class has access to all the fields and methods"</p>
<p>So, by confronting the two definitions, i see some similarities:</p>
<pre><code>1. Both have HAS-A relationship
2. Both are strictly dependent on the outer class lifetime
3. can be declared private
</code></pre>
<p>Differences:</p>
<pre><code>1. Inner classes uses classes, composition use instances (?!)
2. In composition no restriction to use the variables of the "outer" class
</code></pre>
<p>Please correct me if I am totally wrong, I need to trace better the limits of two concepts.</p>
| 0debug |
UIPickerView data notshowing in a subview : i have a container view in which i am showing text field in which picker view is connected . picker view not showing data in container view
@IBOutlet var txtfield: UITextField!
var pickerView = UIPickerView()
pickerView.delegate = self
pickerView.dataSource = self
tYear.inputView = pickerViewYear <----- Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value | 0debug |
Php search filter showing all rows without filtering : <p>While displaying the filtered data, this sql can filter data as per $locationone and $locationtwo.</p>
<p>But it is failing to filter data as per <strong>$cate</strong></p>
<p>I mean its displaying all the rows from both locations and failing to filter it as per <strong>science(topic)</strong></p>
<pre><code>$cat= "science";
$cate= preg_replace("#[^0-9a-z]#i","", $cat);
$locationone= "dhk";
$locationtwo= "ctg";
preg_replace("#[^0-9a-z]#i","", $locationone);
preg_replace("#[^0-9a-z]#i","", $locationtwo);
$sql= "SELECT * FROM post INNER JOIN user ON post.user_id= user.id
WHERE post.topic LIKE '%$cate%'
AND post.location LIKE '%$locationone%'
OR post.location LIKE '%$locationtwo%'
order by post_id desc";
</code></pre>
| 0debug |
PHP object entity - remove unused public methods or not : <p>We have a tiny team row over whether or not to remove unused public methods from an entity. Let us say we have an entity with over 50 public methods (getters predominantly). Currently, only about 10 are actively used. Part of the team is for removing the unused ones (add them in the future if they are to be used) as it could be a code smell leaving them scattered around. Another part of the team is for keeping them as they are as some of them may become needed one day. ... Is there THE right way?</p>
| 0debug |
alert('Hello ' + user_input); | 1threat |
static AVFilterContext *parse_filter(const char **buf, AVFilterGraph *graph,
int index, AVClass *log_ctx)
{
char *opts = NULL;
char *name = consume_string(buf);
if(**buf == '=') {
(*buf)++;
opts = consume_string(buf);
}
return create_filter(graph, index, name, opts, log_ctx);
}
| 1threat |
Find subnet mask from ip : In my lan i've two subnet:
- 255.255.255.0
- 255.255.255.128
Is there a method to scan all lan's IP to know in wich subnet mask are? | 0debug |
Variable value different outside of if statement : <p>In this block of code, at line thirteen, I incremented correctAnswers by 1. However, once the if statement has broke, The value is just one (or zero sometimes) when it prints the percentage. Can anyone tell me what is wrong with my code?</p>
<pre><code>private static void multiplicationTest(int maxNumber, int minNumber) {
int i = 1;
while(i != 11) {
int firstNumber = (minNumber + (int)(Math.random() * ((maxNumber - minNumber) + 1)) ), secondNumber = (minNumber + (int)(Math.random() * ((maxNumber - minNumber) + 1)) );
int inputAnswer, answer = (firstNumber * secondNumber);
int correctAnswers = 0;
System.out.print("Question " + i + ".)\t" + firstNumber + " * " + secondNumber + " = ");
inputAnswer = input.nextInt();
if(inputAnswer == answer) {
correctAnswers++;
System.out.print("\tcorrect\n");
} else {
System.out.print("\tincorrect --- " + firstNumber + " * " + secondNumber + " = " + answer + "\n");
} if(i == 10) {
System.out.println("\nYou scored " + correctAnswers + " out of 10 - " + (correctAnswers * 10) + "%.");
}
i++;
}
}
</code></pre>
| 0debug |
How to Take Database Backup without using phpmyadmin? : <p>How can I take backup of all tables of a database from ftp without using phpmyadmin and get the backup as a .sql file ??</p>
| 0debug |
static void dump_regs(struct ucontext *uc)
{
}
| 1threat |
I am new in java please help when i run my code it shows an error like. : public class PhraseOMatic {
public void main (String[] args) {
String [] wordListOne = {"24/7","multitier","Akshay","Aalok","teslaBoys","Team"};
String[] wordListTwo = {"empowered","positivity","money","foucused","welth","strenth"};
String[] wordListThree = {"ok","dear","priorityies","love","Dreams","sapne"};
int oneLength = wordListOne.length;
int twoLength = wordListTwo.length;
int threeLength = wordListThree.length;
int rand1 = (int) (Math.random() * oneLength);
int rand2 = (int) (Math.random() * twoLength);
int rand3 = (int) (Math.random() * threeLength);
String phrase = wordListOne[rand1] + " " + wordListTwo[rand2] + " " + wordListThree[rand3];
System.out.println("What we need is a " + phrase);
}
}
// error
Main.java:1: error: class PhraseOMatic is public, should be declared in a file named PhraseOMatic.java public class PhraseOMatic { ^ 1 error | 0debug |
Error: EACCES: permission denied, access '/usr/lib/node_modules' : <p>I am trying install typescript with command <code>npm install -g typescript</code>, and returns this error :</p>
<pre><code> npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR! at Error (native)
npm ERR! { Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR! at Error (native)
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/lib/node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Linux 4.4.0-93-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "typescript"
npm ERR! node v6.11.2
npm ERR! npm v3.10.10
npm ERR! path npm-debug.log.1024969454
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall open
npm ERR! Error: EACCES: permission denied, open 'npm-debug.log.1024969454'
npm ERR! at Error (native)
npm ERR! { Error: EACCES: permission denied, open 'npm-debug.log.1024969454'
npm ERR! at Error (native)
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'open',
npm ERR! path: 'npm-debug.log.1024969454' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! /npm-debug.log
jramirez@jramirez:/$ ^C
jramirez@jramirez:/$ npm install typescript
npm WARN checkPermissions Missing write access to /
/
└── typescript@2.5.2
npm WARN enoent ENOENT: no such file or directory, open '/package.json'
npm WARN !invalid#1 No description
npm WARN !invalid#1 No repository field.
npm WARN !invalid#1 No README data
npm WARN !invalid#1 No license field.
npm ERR! Linux 4.4.0-93-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "typescript"
npm ERR! node v6.11.2
npm ERR! npm v3.10.10
npm ERR! path /
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/'
npm ERR! at Error (native)
npm ERR! { Error: EACCES: permission denied, access '/'
npm ERR! at Error (native) errno: -13, code: 'EACCES', syscall: 'access', path: '/' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Linux 4.4.0-93-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "typescript"
npm ERR! node v6.11.2
npm ERR! npm v3.10.10
npm ERR! path npm-debug.log.2387664261
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall open
npm ERR! Error: EACCES: permission denied, open 'npm-debug.log.2387664261'
npm ERR! at Error (native)
npm ERR! { Error: EACCES: permission denied, open 'npm-debug.log.2387664261'
npm ERR! at Error (native)
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'open',
npm ERR! path: 'npm-debug.log.2387664261' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! /npm-debug.log
</code></pre>
<p>Additionaly I run also <code>npm install typescript</code> (without -g), but doesnt' work, or exists anything other way to install typescript?
My OS is Linux Ubuntu 16.04.
I seldom use <code>node</code> and don't know like to fix this issue.</p>
<p>My question is : Exactly, what directories needs that permmisions ?</p>
| 0debug |
Create special vectors with R commands : <p>I want to create the vectors with R commands:
(4, 6, 3, 4, 6, 3, ..., 4, 6, 3, 4, 6) where there are 10 occurrences of 4, 10 occurrences of 6, and 9 occurrences of 3. </p>
| 0debug |
Four 1byte char to One 4byte int? : <p>I have an char array of 1000 bytes. I want to convert it into int array such that four elements of char array (each of one byte) is equal to one element of int array (each of four bytes).</p>
<pre><code>e.g.:
char_array[0] = '0'
char_array[1] = '9'
char_array[2] = '2'
char_array[3] = '8'
it should be converted to
int_array[0] = 928 or 0928.
</code></pre>
<p>How should I do that?</p>
| 0debug |
rvalues with copy operator : <p>Consider this simple class</p>
<pre><code>class Foo
{
public:
Foo() = default;
Foo(const Foo &) = default;
Foo & operator=(const Foo & rhs)
{
return *this;
}
Foo & operator=(Foo && rhs) = delete;
};
Foo getFoo()
{
Foo f;
return f;
}
int main()
{
Foo f;
Foo & rf = f;
rf = getFoo(); // Use of deleted move assignment.
return 0;
}
</code></pre>
<p>When I compile the example above I get <code>error: use of deleted function 'Foo& Foo::operator=(Foo&&)'</code></p>
<p>From the <a href="http://en.cppreference.com/w/cpp/language/copy_assignment">Copy Assignment</a>:</p>
<blockquote>
<p>If only the copy assignment is provided, all argument categories select it (as long as it takes its argument by value or as reference to const, since rvalues can bind to const references), which makes copy assignment the fallback for move assignment, when move is unavailable.</p>
</blockquote>
<p>Why doesn't the compiler fallback to copy assignment when const lvalue reference can bind to rvalue and <code>const Foo & f = getFoo();</code> works.</p>
<p>Compiler - gcc 4.7.2.</p>
| 0debug |
Is it possible to have an executable file not run after a certain date? : <p>I am learning to code with c++. I recently made a magic 8 ball script. I was wondering, when people share .exe files with others. Is it possible to write a command so that the .exe file won't work after a week? </p>
<p>I have not tried it, because I do not know where to start.</p>
| 0debug |
Chage value in R : Have ped1.txt and ped2.txt. sep= tab or space
ped1.txt
222 333 444
333 458 458
458 774 556
500K lines...
ped2.txt
222 -12006
333 -11998
I need to recode numbers in file 1 using key from file 2, for all data.
Result should be like:
-12006 -11998 444
-11998 458 458
458 774 556
500K lines...
How to do it?
Thanks.
| 0debug |
İf-elif-else statement in Bash : <p>I trying to control that my file exist or not in directory using if-elif-else statement in for loop. But in if and elif command line gives me this error: No command</p>
<p>Below is an example of the codes:</p>
<pre><code>#! /bin/bash
controlfile="String"
firstfile="String"
lastfile="String"
nsolve=false
for i in $(ls $file1| grep /*.png)
do
firstfile=${i:0:21} #satır 10
if ["$firstfile"!="$file2"]; then #ERROR LINE
#something doing...
nsolve=false
for j in $(ls $file2| grep /*.jpeg)
do
if [${j:0:31}==${controlfile:0:31}]; then #.if already jpeg file exist like png
nsolve=true
continue
else
nsolve=false
fi
done
elif [$nsolve==true] #ERROR LINE
then
#something doing...
continue
fi
lastfile=${i:0:21}
done
printf "%s\n" "Successfully"
</code></pre>
| 0debug |
void cpu_inject_ext(S390CPU *cpu, uint32_t code, uint32_t param,
uint64_t param64)
{
CPUS390XState *env = &cpu->env;
if (env->ext_index == MAX_EXT_QUEUE - 1) {
return;
}
env->ext_index++;
assert(env->ext_index < MAX_EXT_QUEUE);
env->ext_queue[env->ext_index].code = code;
env->ext_queue[env->ext_index].param = param;
env->ext_queue[env->ext_index].param64 = param64;
env->pending_int |= INTERRUPT_EXT;
cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD);
}
| 1threat |
static void gen_stswi(DisasContext *ctx)
{
TCGv t0;
TCGv_i32 t1, t2;
int nb = NB(ctx->opcode);
gen_set_access_type(ctx, ACCESS_INT);
gen_update_nip(ctx, ctx->nip - 4);
t0 = tcg_temp_new();
gen_addr_register(ctx, t0);
if (nb == 0)
nb = 32;
t1 = tcg_const_i32(nb);
t2 = tcg_const_i32(rS(ctx->opcode));
gen_helper_stsw(cpu_env, t0, t1, t2);
tcg_temp_free(t0);
tcg_temp_free_i32(t1);
tcg_temp_free_i32(t2);
}
| 1threat |
How to parse TextBox to arguments to run a exe : <p>I need to parse login and password from textbox to arguments to run a exe</p>
<pre><code> private void button1_Click(object sender, EventArgs e)
{
string username = textBox1.Text;
string password = textBox2.Text;
Process p = new Process();
p.StartInfo.FileName = "Main.exe";
p.StartInfo.Arguments = "-IFZUpdatedOk_K0 -gna -login @username -pwd @password";
p.Start();
p.WaitForExit();
// System.Diagnostics.Process.Start("Main.exe", " -IFZUpdatedOk_K0 -gna -login email@email.com -pwd mypassword");
}``
</code></pre>
| 0debug |
av_cold int ff_rv34_decode_init(AVCodecContext *avctx)
{
RV34DecContext *r = avctx->priv_data;
MpegEncContext *s = &r->s;
int ret;
ff_MPV_decode_defaults(s);
s->avctx = avctx;
s->out_format = FMT_H263;
s->codec_id = avctx->codec_id;
s->width = avctx->width;
s->height = avctx->height;
r->s.avctx = avctx;
avctx->flags |= CODEC_FLAG_EMU_EDGE;
r->s.flags |= CODEC_FLAG_EMU_EDGE;
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
avctx->has_b_frames = 1;
s->low_delay = 0;
if ((ret = ff_MPV_common_init(s)) < 0)
return ret;
ff_h264_pred_init(&r->h, AV_CODEC_ID_RV40, 8, 1);
#if CONFIG_RV30_DECODER
if (avctx->codec_id == AV_CODEC_ID_RV30)
ff_rv30dsp_init(&r->rdsp);
#endif
#if CONFIG_RV40_DECODER
if (avctx->codec_id == AV_CODEC_ID_RV40)
ff_rv40dsp_init(&r->rdsp);
#endif
if ((ret = rv34_decoder_alloc(r)) < 0)
return ret;
if(!intra_vlcs[0].cbppattern[0].bits)
rv34_init_tables();
avctx->internal->allocate_progress = 1;
return 0;
}
| 1threat |
How to delegate creation of some classes from Guice injector to another factory? : <p>For instance, RESTEasy's ResteasyWebTarget class has a method <code>proxy(Class<T> clazz)</code>, just like Injector's <code>getInstance(Class<T> clazz)</code>. Is there a way to tell Guice that creation of some classes should be delegated to some instance?</p>
<p>My goal is the following behavior of Guice: when the injector is asked for a new instance of class A, try to instantiate it; if instantiation is impossible, ask another object (e. g. ResteasyWebTarget instance) to instantiate the class.</p>
<p>I'd like to write a module like this:</p>
<pre><code>@Override
protected void configure() {
String apiUrl = "https://api.example.com";
Client client = new ResteasyClientBuilder().build();
target = (ResteasyWebTarget) client.target(apiUrl);
onFailureToInstantiateClass(Matchers.annotatedWith(@Path.class)).delegateTo(target);
}
</code></pre>
<p>instead of</p>
<pre><code>@Override
protected void configure() {
String apiUrl = "https://api.example.com";
Client client = new ResteasyClientBuilder().build();
target = (ResteasyWebTarget) client.target(apiUrl);
bind(Service1.class).toProvider(() -> target.proxy(Service1.class);
bind(Service2.class).toProvider(() -> target.proxy(Service2.class);
bind(Service3.class).toProvider(() -> target.proxy(Service3.class);
}
</code></pre>
<p>I've thought about implementing Injector interface and use that implementation as a child injector, but the interface has too much methods.</p>
<p>I <strong>can</strong> write a method enumerating all annotated interfaces in some package and telling Guice to use provider for them, but that's the backup approach.</p>
| 0debug |
static void tty_serial_init(int fd, int speed,
int parity, int data_bits, int stop_bits)
{
struct termios tty;
speed_t spd;
#if 0
printf("tty_serial_init: speed=%d parity=%c data=%d stop=%d\n",
speed, parity, data_bits, stop_bits);
#endif
tcgetattr (fd, &tty);
oldtty = tty;
#define check_speed(val) if (speed <= val) { spd = B##val; break; }
speed = speed * 10 / 11;
do {
check_speed(50);
check_speed(75);
check_speed(110);
check_speed(134);
check_speed(150);
check_speed(200);
check_speed(300);
check_speed(600);
check_speed(1200);
check_speed(1800);
check_speed(2400);
check_speed(4800);
check_speed(9600);
check_speed(19200);
check_speed(38400);
check_speed(57600);
check_speed(115200);
#ifdef B230400
check_speed(230400);
#endif
#ifdef B460800
check_speed(460800);
#endif
#ifdef B500000
check_speed(500000);
#endif
#ifdef B576000
check_speed(576000);
#endif
#ifdef B921600
check_speed(921600);
#endif
#ifdef B1000000
check_speed(1000000);
#endif
#ifdef B1152000
check_speed(1152000);
#endif
#ifdef B1500000
check_speed(1500000);
#endif
#ifdef B2000000
check_speed(2000000);
#endif
#ifdef B2500000
check_speed(2500000);
#endif
#ifdef B3000000
check_speed(3000000);
#endif
#ifdef B3500000
check_speed(3500000);
#endif
#ifdef B4000000
check_speed(4000000);
#endif
spd = B115200;
} while (0);
cfsetispeed(&tty, spd);
cfsetospeed(&tty, spd);
tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
|INLCR|IGNCR|ICRNL|IXON);
tty.c_oflag |= OPOST;
tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN|ISIG);
tty.c_cflag &= ~(CSIZE|PARENB|PARODD|CRTSCTS|CSTOPB);
switch(data_bits) {
default:
case 8:
tty.c_cflag |= CS8;
break;
case 7:
tty.c_cflag |= CS7;
break;
case 6:
tty.c_cflag |= CS6;
break;
case 5:
tty.c_cflag |= CS5;
break;
}
switch(parity) {
default:
case 'N':
break;
case 'E':
tty.c_cflag |= PARENB;
break;
case 'O':
tty.c_cflag |= PARENB | PARODD;
break;
}
if (stop_bits == 2)
tty.c_cflag |= CSTOPB;
tcsetattr (fd, TCSANOW, &tty);
}
| 1threat |
int64_t bdrv_get_block_status_above(BlockDriverState *bs,
BlockDriverState *base,
int64_t sector_num,
int nb_sectors, int *pnum,
BlockDriverState **file)
{
Coroutine *co;
BdrvCoGetBlockStatusData data = {
.bs = bs,
.base = base,
.file = file,
.sector_num = sector_num,
.nb_sectors = nb_sectors,
.pnum = pnum,
.done = false,
};
if (qemu_in_coroutine()) {
bdrv_get_block_status_above_co_entry(&data);
} else {
AioContext *aio_context = bdrv_get_aio_context(bs);
co = qemu_coroutine_create(bdrv_get_block_status_above_co_entry,
&data);
qemu_coroutine_enter(co);
while (!data.done) {
aio_poll(aio_context, true);
}
}
return data.ret;
}
| 1threat |
Compare two Columns using index position in R : [![The dataframe][1]][1]
I have a scenario where I have to compare two columns in a dataframe. The condition is that the Field1 column has a set of values. Field2 column has few values and the remaining are NA. There is another column called Field3. So, the work here is to compare the Field1 values with Field2. The conditions to compare are as follows.
1. If Field1 has a corresponding row in Field2. Copy the row value of Field2.
Ex. Location and Place. So, I have to copy Place.
2. If Field1 does not have a corresponding Field2 value. Then compare Field1
with Field3. Copy the Field3 value to Field2.
Kindly suggest a way to go about this.`dft = data.frame(Field1 = c("Location","Time","Date","Problem"), Field2 = c("Place","Balance","NA","NA"),
Field3 = c("NA","NA","Pay","NA"))`
[1]: https://i.stack.imgur.com/nPTpt.png
| 0debug |
static void hpdmc_write(void *opaque, target_phys_addr_t addr, uint64_t value,
unsigned size)
{
MilkymistHpdmcState *s = opaque;
trace_milkymist_hpdmc_memory_write(addr, value);
addr >>= 2;
switch (addr) {
case R_SYSTEM:
case R_BYPASS:
case R_TIMING:
s->regs[addr] = value;
break;
case R_IODELAY:
break;
default:
error_report("milkymist_hpdmc: write access to unknown register 0x"
TARGET_FMT_plx, addr << 2);
break;
}
}
| 1threat |
static int roq_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
RoqContext *enc = avctx->priv_data;
int size, ret;
enc->avctx = avctx;
enc->frame_to_enc = frame;
if (frame->quality)
enc->lambda = frame->quality - 1;
else
enc->lambda = 2*ROQ_LAMBDA_SCALE;
size = ((enc->width * enc->height / 64) * 138 + 7) / 8 + 256 * (6 + 4) + 8;
if ((ret = ff_alloc_packet(pkt, size)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet with size %d.\n", size);
return ret;
}
enc->out_buf = pkt->data;
if (enc->framesSinceKeyframe == avctx->gop_size)
enc->framesSinceKeyframe = 0;
if (enc->first_frame) {
if (ff_get_buffer(avctx, enc->current_frame, 0) ||
ff_get_buffer(avctx, enc->last_frame, 0)) {
av_log(avctx, AV_LOG_ERROR, " RoQ: get_buffer() failed\n");
return -1;
}
roq_write_video_info_chunk(enc);
enc->first_frame = 0;
}
roq_encode_video(enc);
pkt->size = enc->out_buf - pkt->data;
if (enc->framesSinceKeyframe == 1)
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
| 1threat |
void scsi_req_cancel_async(SCSIRequest *req, Notifier *notifier)
{
trace_scsi_req_cancel(req->dev->id, req->lun, req->tag);
if (notifier) {
notifier_list_add(&req->cancel_notifiers, notifier);
}
if (req->io_canceled) {
return;
}
scsi_req_ref(req);
scsi_req_dequeue(req);
req->io_canceled = true;
if (req->aiocb) {
bdrv_aio_cancel_async(req->aiocb);
}
}
| 1threat |
How can I read current zoom level of Mapbox? : <p>I have a back to home function</p>
<pre><code>function panToHome(){
latLng = [current.lat, current.lng];
map.setView(latLng, 8);
}
</code></pre>
<p>I want to save the current view as history, so user can switch back as they might click mistakely. So the question is how can I know the current latlng on Mapbox?!</p>
| 0debug |
static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb,
AVStream *st, MOVStreamContext *sc,
int size)
{
if (st->codec->codec_tag == MKTAG('t','m','c','d')) {
st->codec->extradata_size = size;
st->codec->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
avio_read(pb, st->codec->extradata, size);
} else {
avio_skip(pb, size);
}
return 0;
}
| 1threat |
int unix_listen_opts(QemuOpts *opts, Error **errp)
{
struct sockaddr_un un;
const char *path = qemu_opt_get(opts, "path");
int sock, fd;
sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0);
if (sock < 0) {
error_setg_errno(errp, errno, "Failed to create socket");
return -1;
}
memset(&un, 0, sizeof(un));
un.sun_family = AF_UNIX;
if (path && strlen(path)) {
snprintf(un.sun_path, sizeof(un.sun_path), "%s", path);
} else {
char *tmpdir = getenv("TMPDIR");
snprintf(un.sun_path, sizeof(un.sun_path), "%s/qemu-socket-XXXXXX",
tmpdir ? tmpdir : "/tmp");
fd = mkstemp(un.sun_path); close(fd);
qemu_opt_set(opts, "path", un.sun_path);
}
unlink(un.sun_path);
if (bind(sock, (struct sockaddr*) &un, sizeof(un)) < 0) {
error_setg_errno(errp, errno, "Failed to bind socket");
goto err;
}
if (listen(sock, 1) < 0) {
error_setg_errno(errp, errno, "Failed to listen on socket");
goto err;
}
return sock;
err:
closesocket(sock);
return -1;
}
| 1threat |
Pushing to a different git repo : <p>I have a repo called <code>react</code>.
I cloned it into a different repo locally called <code>different-repo</code>.</p>
<p>How can I then get <code>different-repo</code> to push remotely to different-repo because currently it is pushing to <code>react</code>.</p>
<p>Effectively I want to clone many times from <code>react</code> into different named repos but then when i push from those repos they push to their own repo.</p>
| 0debug |
AVAES *av_aes_init(uint8_t *key, int key_bits, int decrypt) {
AVAES *a;
int i, j, t, rconpointer = 0;
uint8_t tk[8][4];
int KC= key_bits>>5;
int rounds= KC + 6;
uint8_t log8[256];
uint8_t alog8[512];
if(!sbox[255]){
j=1;
for(i=0; i<255; i++){
alog8[i]=
alog8[i+255]= j;
log8[j]= i;
j^= j+j;
if(j>255) j^= 0x11B;
}
for(i=0; i<256; i++){
j= i ? alog8[255-log8[i]] : 0;
j ^= (j<<1) ^ (j<<2) ^ (j<<3) ^ (j<<4);
j = (j ^ (j>>8) ^ 99) & 255;
inv_sbox[j]= i;
sbox [i]= j;
}
init_multbl2(dec_multbl[0], (int[4]){0xe, 0x9, 0xd, 0xb}, log8, alog8, inv_sbox);
init_multbl2(enc_multbl[0], (int[4]){0x2, 0x1, 0x1, 0x3}, log8, alog8, sbox);
}
if(key_bits!=128 && key_bits!=192 && key_bits!=256)
return NULL;
a= av_malloc(sizeof(AVAES));
a->rounds= rounds;
memcpy(tk, key, KC*4);
for(t= 0; t < (rounds+1)*4;) {
memcpy(a->round_key[0][t], tk, KC*4);
t+= KC;
for(i = 0; i < 4; i++)
tk[0][i] ^= sbox[tk[KC-1][(i+1)&3]];
tk[0][0] ^= rcon[rconpointer++];
for(j = 1; j < KC; j++){
if(KC != 8 || j != KC>>1)
for(i = 0; i < 4; i++) tk[j][i] ^= tk[j-1][i];
else
for(i = 0; i < 4; i++) tk[j][i] ^= sbox[tk[j-1][i]];
}
}
if(decrypt){
for(i=1; i<rounds; i++){
for(j=0; j<16; j++)
a->round_key[i][0][j]= sbox[a->round_key[i][0][j]];
mix(a->round_key[i], dec_multbl);
}
}else{
for(i=0; i<(rounds+1)>>1; i++){
for(j=0; j<16; j++)
FFSWAP(int, a->round_key[i][0][j], a->round_key[rounds-i][0][j]);
}
}
return a;
}
| 1threat |
Kafka Streaming Concurrency? : <p>I have some basic Kafka Streaming code that reads records from one topic, does some processing, and outputs records to another topic.</p>
<p>How does Kafka streaming handle concurrency? Is everything run in a single thread? I don't see this mentioned in the documentation.</p>
<p>If it's single threaded, I would like options for multi-threaded processing to handle high volumes of data.</p>
<p>If it's multi-threaded, I need to understand how this works and how to handle resources, like SQL database connections should be shared in different processing threads.</p>
<p>Is Kafka's built-in streaming API not recommended for high volume scenarios relative to other options (Spark, Akka, Samza, Storm, etc)?</p>
| 0debug |
How to add number with variable name? : <p>Hi I want to change the variable name like stop1, stop2, stop3 etc in a loop.
I tried using for loop with stop + i but it didnt work
Please help</p>
| 0debug |
slack webhook html table : <p>I have a html table that I am trying to post to slack via webhook. Is there a way to post html table to slack? Below is the html code -</p>
<pre><code><!DOCTYPE html>
<html>
<head>
<title>HTML Tables</title>
</head>
<body>
<table border="1">
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>
</body>
</html>
</code></pre>
| 0debug |
static void check_pointer_type_change(Notifier *notifier, void *data)
{
VncState *vs = container_of(notifier, VncState, mouse_mode_notifier);
int absolute = qemu_input_is_absolute();
if (vnc_has_feature(vs, VNC_FEATURE_POINTER_TYPE_CHANGE) && vs->absolute != absolute) {
vnc_lock_output(vs);
vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);
vnc_write_u8(vs, 0);
vnc_write_u16(vs, 1);
vnc_framebuffer_update(vs, absolute, 0,
surface_width(vs->vd->ds),
surface_height(vs->vd->ds),
VNC_ENCODING_POINTER_TYPE_CHANGE);
vnc_unlock_output(vs);
vnc_flush(vs);
}
vs->absolute = absolute;
}
| 1threat |
static int get_metadata(AVFormatContext *s,
const char *const tag,
const unsigned data_size)
{
uint8_t *buf = ((data_size + 1) == 0) ? NULL : av_malloc(data_size + 1);
if (!buf)
return AVERROR(ENOMEM);
if (avio_read(s->pb, buf, data_size) < 0) {
av_free(buf);
return AVERROR(EIO);
}
buf[data_size] = 0;
av_dict_set(&s->metadata, tag, buf, AV_DICT_DONT_STRDUP_VAL);
return 0;
}
| 1threat |
Failure Trace in Selenium : Guys, could you advice, what can we do in situation, when tests are running OK, but in the end of the tests there are alot of error in Failure Trace in Selenium. Any help?
I have imported java.util still problem exists.
Here are some pics
[FailureTrace1][1]
[Code][2]
[1]: https://i.stack.imgur.com/jTZkl.png
[2]: https://i.stack.imgur.com/UITb9.png | 0debug |
static void qjson_initfn(Object *obj)
{
QJSON *json = QJSON(obj);
json->str = qstring_from_str("{ ");
json->omit_comma = true;
}
| 1threat |
static int64_t qemu_icount_delta(void)
{
if (!use_icount) {
return 5000 * (int64_t) 1000000;
} else if (use_icount == 1) {
return 0;
} else {
return cpu_get_icount() - cpu_get_clock();
}
}
| 1threat |
no suitable method to override - Unity : Iam trying some stuff with Unity and geting lot of this error where is always „no suitable method to override“. For example: Assets/Standard Assets/Effects/ImageEffects/Scripts/Antialiasing.cs(86,30): error CS0115: `UnityStandardAssets.ImageEffects.Antialiasing.CheckResources()' is marked as an override but no suitable method found to override. Its look like that error is trivial, but i dont know c++ basic, so dont know what with this. Can you show at this example, how fix this? Thanks!
public override bool CheckResources()
{
CheckSupport(false);
materialFXAAPreset2 = CreateMaterial(shaderFXAAPreset2, materialFXAAPreset2);
materialFXAAPreset3 = CreateMaterial(shaderFXAAPreset3, materialFXAAPreset3);
materialFXAAII = CreateMaterial(shaderFXAAII, materialFXAAII);
materialFXAAIII = CreateMaterial(shaderFXAAIII, materialFXAAIII);
nfaa = CreateMaterial(nfaaShader, nfaa);
ssaa = CreateMaterial(ssaaShader, ssaa);
dlaa = CreateMaterial(dlaaShader, dlaa);
if (!ssaaShader.isSupported)
{
NotSupported();
ReportAutoDisable();
}
return isSupported;
}
| 0debug |
How to get data from an array inside an object in javascript? : <p>My data structure is as follows</p>
<pre><code>var processArray = [];
for(i = 0;i < someProcess.length;i++){
processArray.push({
id: i,
processName: someProcess[i],
processType: someType[i]
});
}
//someProcess and someType are arrays from database.
</code></pre>
<p>I use this processArray to populate a HTML list. After some operations by the user (eg:- adding more data or deleting some), I need to extract all processName from processArray and store them in another array, lets say newProcessList. How can I do it?</p>
| 0debug |
R: Explanation needed for v <- 2*x + y + 1 : I am learning R Programming language.The below code says 2*x will do 2.2 times, but what I can understand is 2*x says 2 multiplied with every element of X vector.
But manual says 2.2 times , why that 0.2 times coming here or may be I am looking at it in wrong way.
> v <- 2*x + y + 1
generates a new vector v of length 11 constructed by adding together, element by element, 2*x
repeated 2.2 times, y repeated just once, and 1 repeated 11 times.
Please help understanding this expression. | 0debug |
How can I adapt this javascript to return a postcode less the last 2 characters? : <pre><code>function() {
var address = $("#postcode").val();
var postcode = address.split(' ');
postcode = "Postcode:"+postcode[(postcode.length-2)];
return postcode;
}
</code></pre>
<p>This js pulls a postcode value from an online form when the user runs a query. I need to know how I get it to deliver the postcode less the last 2 characters. for example, SP10 2RB needs to return SP102.</p>
| 0debug |
def min_Ops(arr,n,k):
max1 = max(arr)
res = 0
for i in range(0,n):
if ((max1 - arr[i]) % k != 0):
return -1
else:
res += (max1 - arr[i]) / k
return int(res) | 0debug |
Can someone explain this ruby sytax to me? : Can someone explain this code to me? What does the pipeline syntax mean and how it works
array = [1, 2, 3, 4, 5, 3, 6, 7, 2, 8, 1, 9]
array.each_with_index.reduce({}) { |hash, (item, index)|
hash[item] = (hash[item] || []) << index
hash
}.select { |key, value|
value.size > 1
} | 0debug |
How to confirm on navigating away from page : <p>I recently looked up how to do this, and it took <em>way</em> too long to find it. So here you guys go, I'm sharing how to make an "<code>ARE YOU SURE YOU WANT TO LEAVE THIS PAGE?</code>" dialog.</p>
| 0debug |
static int vnc_start_vencrypt_handshake(struct VncState *vs) {
int ret;
if ((ret = gnutls_handshake(vs->tls.session)) < 0) {
if (!gnutls_error_is_fatal(ret)) {
VNC_DEBUG("Handshake interrupted (blocking)\n");
if (!gnutls_record_get_direction(vs->tls.session))
qemu_set_fd_handler(vs->csock, vnc_tls_handshake_io, NULL, vs);
else
qemu_set_fd_handler(vs->csock, NULL, vnc_tls_handshake_io, vs);
return 0;
}
VNC_DEBUG("Handshake failed %s\n", gnutls_strerror(ret));
vnc_client_error(vs);
return -1;
}
if (vs->vd->tls.x509verify) {
if (vnc_tls_validate_certificate(vs) < 0) {
VNC_DEBUG("Client verification failed\n");
vnc_client_error(vs);
return -1;
} else {
VNC_DEBUG("Client verification passed\n");
}
}
VNC_DEBUG("Handshake done, switching to TLS data mode\n");
qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, vnc_client_write, vs);
start_auth_vencrypt_subauth(vs);
return 0;
}
| 1threat |
static int mov_write_trailer(AVFormatContext *s)
{
MOVMuxContext *mov = s->priv_data;
AVIOContext *pb = s->pb;
int res = 0;
int i;
int64_t moov_pos = avio_tell(pb);
if (!(mov->flags & FF_MOV_FLAG_FRAGMENT)) {
if (mov->mdat_size + 8 <= UINT32_MAX) {
avio_seek(pb, mov->mdat_pos, SEEK_SET);
avio_wb32(pb, mov->mdat_size + 8);
} else {
avio_seek(pb, mov->mdat_pos - 8, SEEK_SET);
avio_wb32(pb, 1);
ffio_wfourcc(pb, "mdat");
avio_wb64(pb, mov->mdat_size + 16);
}
avio_seek(pb, mov->reserved_moov_size ? mov->reserved_moov_pos : moov_pos, SEEK_SET);
mov_write_moov_tag(pb, mov, s);
if(mov->reserved_moov_size){
int64_t size= mov->reserved_moov_size - (avio_tell(pb) - mov->reserved_moov_pos);
if(size < 8){
av_log(s, AV_LOG_ERROR, "reserved_moov_size is too small, needed %"PRId64" additional\n", 8-size);
return -1;
}
avio_wb32(pb, size);
ffio_wfourcc(pb, "free");
for(i=0; i<size; i++)
avio_w8(pb, 0);
avio_seek(pb, moov_pos, SEEK_SET);
}
} else {
mov_flush_fragment(s);
mov_write_mfra_tag(pb, mov);
}
if (mov->chapter_track)
av_freep(&mov->tracks[mov->chapter_track].enc);
for (i=0; i<mov->nb_streams; i++) {
if (mov->tracks[i].tag == MKTAG('r','t','p',' '))
ff_mov_close_hinting(&mov->tracks[i]);
else if (mov->tracks[i].tag == MKTAG('t','m','c','d'))
av_freep(&mov->tracks[i].enc);
if (mov->flags & FF_MOV_FLAG_FRAGMENT &&
mov->tracks[i].vc1_info.struct_offset && s->pb->seekable) {
int64_t off = avio_tell(pb);
uint8_t buf[7];
if (mov_write_dvc1_structs(&mov->tracks[i], buf) >= 0) {
avio_seek(pb, mov->tracks[i].vc1_info.struct_offset, SEEK_SET);
avio_write(pb, buf, 7);
avio_seek(pb, off, SEEK_SET);
}
}
av_freep(&mov->tracks[i].cluster);
av_freep(&mov->tracks[i].frag_info);
if (mov->tracks[i].vos_len)
av_free(mov->tracks[i].vos_data);
}
avio_flush(pb);
av_freep(&mov->tracks);
return res;
}
| 1threat |
How to generate sitemap with react router : <p>I'm trying to figure out how to dynamically generate sitemap in reactJS server side (express) web app. I'm using react router. </p>
| 0debug |
static void gen_sraiq(DisasContext *ctx)
{
int sh = SH(ctx->opcode);
int l1 = gen_new_label();
TCGv t0 = tcg_temp_new();
TCGv t1 = tcg_temp_new();
tcg_gen_shri_tl(t0, cpu_gpr[rS(ctx->opcode)], sh);
tcg_gen_shli_tl(t1, cpu_gpr[rS(ctx->opcode)], 32 - sh);
tcg_gen_or_tl(t0, t0, t1);
gen_store_spr(SPR_MQ, t0);
tcg_gen_movi_tl(cpu_ca, 0);
tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
tcg_gen_brcondi_tl(TCG_COND_GE, cpu_gpr[rS(ctx->opcode)], 0, l1);
tcg_gen_movi_tl(cpu_ca, 1);
gen_set_label(l1);
tcg_gen_sari_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], sh);
tcg_temp_free(t0);
tcg_temp_free(t1);
if (unlikely(Rc(ctx->opcode) != 0))
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
}
| 1threat |
im trying to make my program throw an IllegalArgumentException if the input is not a number : *I'm trying to make it to were is will throw my exception if the input is not a number and i cant figure it out, Could someone help me get on the right track*
import java.util.Scanner;
class calculations
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int number;
int total = 0;
try
{
} catch ( IllegalArgumentException e)
{
//error
}
while (true)
{
number = scan.nextInt();
if (number == 0)
{
break;
}
total += number;
}
System.out.println("Total is " + total);
}
}
| 0debug |
static void apply_tns(INTFLOAT coef[1024], TemporalNoiseShaping *tns,
IndividualChannelStream *ics, int decode)
{
const int mmm = FFMIN(ics->tns_max_bands, ics->max_sfb);
int w, filt, m, i;
int bottom, top, order, start, end, size, inc;
INTFLOAT lpc[TNS_MAX_ORDER];
INTFLOAT tmp[TNS_MAX_ORDER+1];
for (w = 0; w < ics->num_windows; w++) {
bottom = ics->num_swb;
for (filt = 0; filt < tns->n_filt[w]; filt++) {
top = bottom;
bottom = FFMAX(0, top - tns->length[w][filt]);
order = tns->order[w][filt];
if (order == 0)
continue;
AAC_RENAME(compute_lpc_coefs)(tns->coef[w][filt], order, lpc, 0, 0, 0);
start = ics->swb_offset[FFMIN(bottom, mmm)];
end = ics->swb_offset[FFMIN( top, mmm)];
if ((size = end - start) <= 0)
continue;
if (tns->direction[w][filt]) {
inc = -1;
start = end - 1;
} else {
inc = 1;
}
start += w * 128;
if (decode) {
for (m = 0; m < size; m++, start += inc)
for (i = 1; i <= FFMIN(m, order); i++)
coef[start] -= AAC_MUL26(coef[start - i * inc], lpc[i - 1]);
} else {
for (m = 0; m < size; m++, start += inc) {
tmp[0] = coef[start];
for (i = 1; i <= FFMIN(m, order); i++)
coef[start] += AAC_MUL26(tmp[i], lpc[i - 1]);
for (i = order; i > 0; i--)
tmp[i] = tmp[i - 1];
}
}
}
}
}
| 1threat |
int mmap_frag(unsigned long host_start,
unsigned long start, unsigned long end,
int prot, int flags, int fd, unsigned long offset)
{
unsigned long host_end, ret, addr;
int prot1, prot_new;
host_end = host_start + qemu_host_page_size;
prot1 = 0;
for(addr = host_start; addr < host_end; addr++) {
if (addr < start || addr >= end)
prot1 |= page_get_flags(addr);
}
if (prot1 == 0) {
ret = (long)mmap((void *)host_start, qemu_host_page_size, prot,
flags | MAP_ANONYMOUS, -1, 0);
if (ret == -1)
return ret;
}
prot1 &= PAGE_BITS;
prot_new = prot | prot1;
if (!(flags & MAP_ANONYMOUS)) {
#ifndef __APPLE__
if ((flags & MAP_TYPE) == MAP_SHARED &&
#else
if ((flags & MAP_SHARED) &&
#endif
(prot & PROT_WRITE))
return -EINVAL;
if (!(prot1 & PROT_WRITE))
mprotect((void *)host_start, qemu_host_page_size, prot1 | PROT_WRITE);
pread(fd, (void *)start, end - start, offset);
if (prot_new != (prot1 | PROT_WRITE))
mprotect((void *)host_start, qemu_host_page_size, prot_new);
} else {
if (prot_new != prot1) {
mprotect((void *)host_start, qemu_host_page_size, prot_new);
}
}
return 0;
}
| 1threat |
Flutter loads old version of app every time I restart the app : <p>Every time I run the flutter app from IntelliJ, it loads an old outdated version of the app from days ago. The new version of the app is only loaded after a hot reload and even then, if I restart the app, the old version is loaded again.
I there any way I can fix this issue? It's really frustrating.</p>
| 0debug |
What is the point of "cd ." command in Linux? : <p>I just began to learn to use Linux but I am just curious what would be the purpose of this command as it really doesn't do anything from what I have learned. </p>
| 0debug |
static void acpi_get_hotplug_info(AcpiMiscInfo *misc)
{
int i;
PCIBus *bus = find_i440fx();
if (!bus) {
memset(misc->slot_hotplug_enable, 0, sizeof misc->slot_hotplug_enable);
return;
}
memset(misc->slot_hotplug_enable, 0xff,
DIV_ROUND_UP(PCI_SLOT_MAX, BITS_PER_BYTE));
for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
PCIDeviceClass *pc;
PCIDevice *pdev = bus->devices[i];
if (!pdev) {
continue;
}
pc = PCI_DEVICE_GET_CLASS(pdev);
if (pc->no_hotplug) {
int slot = PCI_SLOT(i);
clear_bit(slot, misc->slot_hotplug_enable);
}
}
}
| 1threat |
How to convert Single to Binary? : We may use a `Convert.ToString()` overload to convert these types to binary:
Byte
Short
Integer
Long
For example:
Dim iInteger As Integer
Dim sBinary As String
iInteger = Integer.MaxValue
sBinary = Convert.ToString(iInteger, 2)
But there isn't an overload for `Single` that accepts the base value. The single-argument overload returns scientific notation, not the binary value.
I've tried this code:
Public Function ToBinary(Value As Single) As String
Dim aBits As Integer()
Dim _
iLength,
iIndex As Integer
Select Case Value
Case < BitLengths.BYTE : iLength = 7
Case < BitLengths.WORD : iLength = 15
Case < BitLengths.DWORD : iLength = 31
Case < BitLengths.QWORD : iLength = 63
End Select
aBits = New Integer(iLength) {}
For iIndex = 0 To iLength
aBits(iLength - iIndex) = Value Mod 2
Value \= 2
Next
ToBinary = String.Empty
aBits.ForEach(Sub(Bit)
ToBinary &= Bit
End Sub)
End Function
Unfortunately, however, it returns inaccurate results.
Given these, how may we reliably convert a `Single` value to a binary string?
| 0debug |
static int pci_std_vga_initfn(PCIDevice *dev)
{
PCIVGAState *d = DO_UPCAST(PCIVGAState, dev, dev);
VGACommonState *s = &d->vga;
vga_common_init(s);
vga_init(s, pci_address_space(dev), pci_address_space_io(dev), true);
s->con = graphic_console_init(s->update, s->invalidate,
s->screen_dump, s->text_update, s);
pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->vram);
if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_MMIO)) {
memory_region_init(&d->mmio, "vga.mmio", 4096);
memory_region_init_io(&d->ioport, &pci_vga_ioport_ops, d,
"vga ioports remapped", PCI_VGA_IOPORT_SIZE);
memory_region_init_io(&d->bochs, &pci_vga_bochs_ops, d,
"bochs dispi interface", PCI_VGA_BOCHS_SIZE);
memory_region_add_subregion(&d->mmio, PCI_VGA_IOPORT_OFFSET,
&d->ioport);
memory_region_add_subregion(&d->mmio, PCI_VGA_BOCHS_OFFSET,
&d->bochs);
pci_register_bar(&d->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio);
}
if (!dev->rom_bar) {
vga_init_vbe(s, pci_address_space(dev));
}
return 0;
}
| 1threat |
abi_long do_brk(abi_ulong new_brk)
{
abi_ulong brk_page;
abi_long mapped_addr;
int new_alloc_size;
if (!new_brk)
return target_brk;
if (new_brk < target_original_brk)
return target_brk;
brk_page = HOST_PAGE_ALIGN(target_brk);
if (new_brk < brk_page) {
target_brk = new_brk;
return target_brk;
}
new_alloc_size = HOST_PAGE_ALIGN(new_brk - brk_page + 1);
mapped_addr = get_errno(target_mmap(brk_page, new_alloc_size,
PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, 0, 0));
if (mapped_addr == brk_page) {
target_brk = new_brk;
return target_brk;
} else if (mapped_addr != -1) {
target_munmap(mapped_addr, new_alloc_size);
mapped_addr = -1;
}
#if defined(TARGET_ALPHA)
return -TARGET_ENOMEM;
#endif
return target_brk;
}
| 1threat |
Return Array from Class in Java : The array that returns from method contain undisireable values. I don't know why.
<br/>This is DrvierExam Class:
public class DriverExam
{
private char[] answer ={'B','D','A','A','C','A','B','A','C','D','B','C','D','A','D'
,'C','C','B','D','A'};
private char[] stuAnswer = new char[20];
private int totalCorrect = 0;
private int[] missed = new int[20];
public DriverExam(char stuAnswer[])
{
for (int i = 0; i < stuAnswer.length; i++)
{
this.stuAnswer[i] = stuAnswer[i];
}
}
public int gettotalCorrect()
{
int k = 0;
for (int i = 0; i < stuAnswer.length; i++)
{
if (stuAnswer[i] == answer[i])
totalCorrect++;
}
return totalCorrect;
}
public int gettotalIncorrect()
{
return 20-totalCorrect;
}
public int[] getMissed()
{
int k = 0;
for (int i = 0; i < stuAnswer.length; i++)
{
if (stuAnswer[i] != answer[i])
{
missed[k] = i;
k++;
}
}
return missed;
}
}
This is the main program:
import java.util.Scanner;
public class Main6
{
public static void main(String[] args)
{
char[] answer = new char[20];
int[] missed2;
String str;
Scanner keyboard = new Scanner(System.in);
for (int i = 1; i <= 20; i++)
{
System.out.println("Enter the answer for question #"+i);
str = keyboard.nextLine();
while (Character.toUpperCase(str.charAt(0)) != 'A'
&& Character.toUpperCase(str.charAt(0)) != 'B'
&& Character.toUpperCase(str.charAt(0)) != 'C'
&& Character.toUpperCase(str.charAt(0)) != 'D')
{
System.out.println("Your input is invalid. Only accept A, B, C, or D");
System.out.println("Enter the answer for question #"+i);
str = keyboard.nextLine();
}
answer[i-1] = Character.toUpperCase(str.charAt(0));
}
DriverExam de = new DriverExam (answer);
System.out.print("***FINAL RESULT:");
System.out.print("\nTotal correct answers: "+de.gettotalCorrect());
System.out.print("\nTotal incorrect answers: "+de.gettotalIncorrect());
System.out.print("\nQuestions missed: ");
missed2 = de.getMissed();
for (int i = 0; i < missed.length; i++)
{
System.out.print(i+" ");
}
}
}
In DriverExam class I return an array named "missed" to the main program. In main program, I use an array named "missed2" to store the array returned. But when I print the result (I type all the answer with "A"). It's like bellow:<br/>
***FINAL RESULT:<br/>
Total correct answers: 6<br/>
Total incorrect answers: 14<br/>
Questions missed: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 <br/>
The question missed result is strange and incorrect. Please help me fix my code. | 0debug |
Why does this happen when i run the code : <p>Hey guys it's just that when I run this code I get three alerts saying "You won!", "it's a tie!" and "you lost" randomly where there should only be one alert. This is a rock paper scissors game what part of the code is wrong I have tried but couldn't find it</p>
<pre><code>var userAnswer = prompt("Rock, Paper or Scissor");
var theEnemy;
var d = Math.floor(Math.random() * 10 + 1);
document.write(d);
if(d === 3 || d === 2 || d === 1){
var theEnemy = "Paper"
if(userAnswer = "Rock"){
alert("You lost!");
}
if(userAnswer = "Paper"){
alert("it's a tie!");
}
if(userAnswer = "Scissor"){
alert("You won");
}
}
if(d === 7 || d === 6 || d === 5 || d === 4){
var theEnemy="Rock";
if(userAnswer = "Rock"){
alert("it's a tie!");
}
if(userAnswer = "Paper"){
alert("YOu won!");
}
if(userAnswer = "Scissor"){
alert("You lost!");
}
}
if(d === 8 || d === 9 || d=== 10){
var theEnemy="Scissor";
if(userAnswer = "Rock"){
alert("You lost!");
}
if(userAnswer = "Paper"){
alert("You won!");
}
if(userAnswer = "Scissor"){
alert("It's a tie");
}
}
</code></pre>
| 0debug |
static int mptsas_process_scsi_io_request(MPTSASState *s,
MPIMsgSCSIIORequest *scsi_io,
hwaddr addr)
{
MPTSASRequest *req;
MPIMsgSCSIIOReply reply;
SCSIDevice *sdev;
int status;
mptsas_fix_scsi_io_endianness(scsi_io);
trace_mptsas_process_scsi_io_request(s, scsi_io->Bus, scsi_io->TargetID,
scsi_io->LUN[1], scsi_io->DataLength);
status = mptsas_scsi_device_find(s, scsi_io->Bus, scsi_io->TargetID,
scsi_io->LUN, &sdev);
if (status) {
goto bad;
}
req = g_new(MPTSASRequest, 1);
QTAILQ_INSERT_TAIL(&s->pending, req, next);
req->scsi_io = *scsi_io;
req->dev = s;
status = mptsas_build_sgl(s, req, addr);
if (status) {
goto free_bad;
}
if (req->qsg.size < scsi_io->DataLength) {
trace_mptsas_sgl_overflow(s, scsi_io->MsgContext, scsi_io->DataLength,
req->qsg.size);
status = MPI_IOCSTATUS_INVALID_SGL;
goto free_bad;
}
req->sreq = scsi_req_new(sdev, scsi_io->MsgContext,
scsi_io->LUN[1], scsi_io->CDB, req);
if (req->sreq->cmd.xfer > scsi_io->DataLength) {
goto overrun;
}
switch (scsi_io->Control & MPI_SCSIIO_CONTROL_DATADIRECTION_MASK) {
case MPI_SCSIIO_CONTROL_NODATATRANSFER:
if (req->sreq->cmd.mode != SCSI_XFER_NONE) {
goto overrun;
}
break;
case MPI_SCSIIO_CONTROL_WRITE:
if (req->sreq->cmd.mode != SCSI_XFER_TO_DEV) {
goto overrun;
}
break;
case MPI_SCSIIO_CONTROL_READ:
if (req->sreq->cmd.mode != SCSI_XFER_FROM_DEV) {
goto overrun;
}
break;
}
if (scsi_req_enqueue(req->sreq)) {
scsi_req_continue(req->sreq);
}
return 0;
overrun:
trace_mptsas_scsi_overflow(s, scsi_io->MsgContext, req->sreq->cmd.xfer,
scsi_io->DataLength);
status = MPI_IOCSTATUS_SCSI_DATA_OVERRUN;
free_bad:
mptsas_free_request(req);
bad:
memset(&reply, 0, sizeof(reply));
reply.TargetID = scsi_io->TargetID;
reply.Bus = scsi_io->Bus;
reply.MsgLength = sizeof(reply) / 4;
reply.Function = scsi_io->Function;
reply.CDBLength = scsi_io->CDBLength;
reply.SenseBufferLength = scsi_io->SenseBufferLength;
reply.MsgContext = scsi_io->MsgContext;
reply.SCSIState = MPI_SCSI_STATE_NO_SCSI_STATUS;
reply.IOCStatus = status;
mptsas_fix_scsi_io_reply_endianness(&reply);
mptsas_reply(s, (MPIDefaultReply *)&reply);
return 0;
}
| 1threat |
How can I execute code before all tests suite with Cypress : <p>Basically, I want to login once before all my tests are executed. My tests files are split on several files.</p>
<p>Should I call my login command in each test file using the before hook or is there any way to to do it once before all tests ?</p>
| 0debug |
pyparse - String parsing to generate Where clause : I have a string that looks something like this -
((COL1==VAL1)+(COL2==VAL2))
I want t convert this to following format:
((a.col1 == 'VAL1') & (a.col2 == 'VAL2'))
Another example -
From: ((COL1==VAL1)|(COL2==VAL2/A))
TO: ((a.col1 == 'VAL1') | (a.col2 == 'VAL2/A'))
can someone help please? | 0debug |
static bool next_query_bds(BlockBackend **blk, BlockDriverState **bs,
bool query_nodes)
{
if (query_nodes) {
*bs = bdrv_next_node(*bs);
return !!*bs;
}
*blk = blk_next(*blk);
*bs = *blk ? blk_bs(*blk) : NULL;
return !!*blk;
}
| 1threat |
Creating a 64 bit application in Visual Studio with SysNative : I'm trying to build a 64 bit application using visual studio in C++
I need to access `Sens.dll` in windows directory. Since Visual Studio is 32 bit application, I have to use **SysNative** instead of **System32**
`C:/Windows/SysNative/Sens.dll`
because of File System Redirection.
If I change the path to `C:/Windows/System32/Sens.dll` Visual studio cannot access it since it redirects to SysWOW64 while building. To mitigate this I can use SysNative but then the executable built is a 64 bit application and SysNative is inaccessible.
Is there any way to solve it?
A better explanation of SysNative is given [here][1]
[1]: https://www.samlogic.net/articles/sysnative-folder-64-bit-windows.htm | 0debug |
Strings are not getting concatenated properly : <p>i have below code where string dont get concatenated</p>
<pre><code>string postCode = "1245";
string city = "Stockholm";
string postCodeAndCity = postCode ?? " " + " " + city ?? " ";
</code></pre>
<p>I get output as <strong>1245</strong>. Not sure why it excludes city.</p>
<p>But this line works</p>
<pre><code>string.Concat(postCode??" ", " ", city?? " ");
</code></pre>
<p>so why the first approach dont work?</p>
| 0debug |
How to setup game to be multiplayer? : <p>I am developing a game for android, and I am wondering how multiplayer networking would work. I don't need the specifics (eg... how to send data back and forth). I'm curious, for instance, in my game I have a sun in the background (sprite) that I move programmaticly across the sky. In a multiplayer game, would I calculate that on both machines? Or just 1, then send the sun location to the other? Also, would it be a bunch of if statements in my code to see if the current game if multiplayer, if so do this, if not do this? Or would I have separate classes, 1 for single player, and a different one for multiplayer? Thanks in advance! </p>
| 0debug |
void json_lexer_destroy(JSONLexer *lexer)
{
QDECREF(lexer->token);
}
| 1threat |
connection.query('SELECT * FROM users WHERE username = ' + input_string) | 1threat |
TensorBoard Distributions and Histograms with Keras and fit_generator : <p>I'm using Keras to train a CNN using the fit_generator function.</p>
<p>It seems to be a <a href="https://github.com/fchollet/keras/issues/3358" rel="noreferrer">known issue</a> that TensorBoard doesn't show histograms and distributions in this setup.</p>
<p>Did anybody figure out a way to make it work anyway?</p>
| 0debug |
static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr,
Error **errp)
{
QIOChannelSocket *sioc;
Error *local_err = NULL;
sioc = qio_channel_socket_new();
qio_channel_set_name(QIO_CHANNEL(sioc), "nbd-client");
qio_channel_socket_connect_sync(sioc,
saddr,
&local_err);
if (local_err) {
error_propagate(errp, local_err);
return NULL;
}
qio_channel_set_delay(QIO_CHANNEL(sioc), false);
return sioc;
} | 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.