problem
stringlengths
26
131k
labels
class label
2 classes
static void disas_cond_b_imm(DisasContext *s, uint32_t insn) { unsigned int cond; uint64_t addr; if ((insn & (1 << 4)) || (insn & (1 << 24))) { unallocated_encoding(s); return; } addr = s->pc + sextract32(insn, 5, 19) * 4 - 4; cond = extract32(insn, 0, 4); if (cond < 0x0e) { int label_match = gen_new_label(); arm_gen_test_cc(cond, label_match); gen_goto_tb(s, 0, s->pc); gen_set_label(label_match); gen_goto_tb(s, 1, addr); } else { gen_goto_tb(s, 0, addr); } }
1threat
Using a random string generator in c++ constructor : <p>When attempting to randomly generate a string for a name attribute in a class, the output seems to print the same string for each object.</p> <p>When I run this in the debugger, a unique name identifier IS generated for each Array object, however, when compiling and running the program, the name attribute is the same for both objects. Any help on why this may be happening would be much appreciated. Thanks!</p> <p>Main:</p> <pre><code>int main() { Array One(3); Array Two(5); cout &lt;&lt; One.getName() &lt;&lt; endl; cout &lt;&lt; Two.getName() &lt;&lt; endl; return(0); } </code></pre> <p>Header file:</p> <pre><code>public: Array(int arraySize= 10); // default constructor Array(const Array &amp;init); // copy constructor ~Array(); // destructor void setName(); // set objects w/ unique names int getCapacity() const; // return capacity int getNumElts() const; // return numElts string getName() const; // return name void incrementNumElts(); // increment numElts void incrementCapacity(); // increment capacity private: int capacity, // capacity of the array numElts; // Elements in the array in use int *ptr; // pointer to first element of array static int arrayCount; // # of Arrays instantiated string name; }; </code></pre> <p>Default Constructor in .cpp file:</p> <pre><code>Array::Array(int arraySize) { setCapacity(( arraySize &gt; 0 ? arraySize : 10 )); setNumElts(); setName(); /* Giving each object a unique identifier. Note: names will be different from the variable names in the code. This will just make the prints a bit more clear about which objects are being appended, copied etc.. */ ptr = new int[getCapacity()]; // create space for array assert( ptr != 0 ); // terminate if memory not allocated ++arrayCount; // count one more object } </code></pre> <p>The set function:</p> <pre><code>void Array::setName() { srand(time(NULL)); string Str; static const char alphanum[] = "0123456789" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz"; for(int i = 0; i &lt; 4; ++i) { Str += alphanum[rand() % sizeof(alphanum)-1]; } name = Str; } </code></pre> <p>The get function:</p> <pre><code>// Get unique identifier of array object string Array::getName() const { return name; } </code></pre>
0debug
jQuery sum input values of each divs? : <p>I'm looking for a way to create a sum of inputs within an element. </p> <p>I'm running into this problem that whenever I'm using each, the function itself sums all values and not just those within the div. </p> <p>Working with this isn't working as hoped:</p> <pre><code>$('div').each(function(){ var sum = 0; $(this).find('input').each(function(){ sum += Number($(this).val()); }); $('.sum').val(sum); }); </code></pre> <p>home someone can help:</p> <p><a href="http://jsfiddle.net/1keyup/q7rL2a38" rel="nofollow noreferrer">http://jsfiddle.net/1keyup/q7rL2a38</a></p>
0debug
how can i get Price for Size 0.75 , Color = K and Clarity = IF? : Shape Purity Color From Size To Size Price ---------- BR IF D 0.5 0.69 8600 BR VVS1 D 0.5 0.69 6600 BR VVS2 D 0.5 0.69 5800 BR VS1 D 0.5 0.69 4700 BR VS2 D 0.5 0.69 4300 BR SI1 D 0.5 0.69 3600 BR SI2 D 0.5 0.69 2900 BR SI3 D 0.5 0.69 2600 BR I1 D 0.5 0.69 2100 BR I2 D 0.5 0.69 1600 BR I3 D 0.5 0.69 1100 BR IF E 0.5 0.69 6500 BR VVS1 E 0.5 0.69 5800 BR VVS2 E 0.5 0.69 5400 BR VS1 E 0.5 0.69 4400 BR VS2 E 0.5 0.69 3900 BR SI1 E 0.5 0.69 3300 BR SI2 E 0.5 0.69 2700 BR SI3 E 0.5 0.69 2400 BR I1 E 0.5 0.69 2000 BR I2 E 0.5 0.69 1500 BR I3 E 0.5 0.69 1000 BR IF F 0.5 0.69 5800 BR VVS1 F 0.5 0.69 5400 BR VVS2 F 0.5 0.69 5000 BR VS1 F 0.5 0.69 4200 BR VS2 F 0.5 0.69 3700 BR SI1 F 0.5 0.69 3000 BR SI2 F 0.5 0.69 2500 BR SI3 F 0.5 0.69 2200 BR I1 F 0.5 0.69 1900 BR I2 F 0.5 0.69 1400 BR I3 F 0.5 0.69 1000 BR IF G 0.5 0.69 5200 BR VVS1 G 0.5 0.69 4700 BR VVS2 G 0.5 0.69 4400 BR VS1 G 0.5 0.69 3900 BR VS2 G 0.5 0.69 3300 BR SI1 G 0.5 0.69 2700 BR SI2 G 0.5 0.69 2200 BR SI3 G 0.5 0.69 2000 BR I1 G 0.5 0.69 1700 BR I2 G 0.5 0.69 1300 BR I3 G 0.5 0.69 900 BR IF H 0.5 0.69 4600 BR VVS1 H 0.5 0.69 4100 BR VVS2 H 0.5 0.69 3700 BR VS1 H 0.5 0.69 3400 BR VS2 H 0.5 0.69 2900 BR SI1 H 0.5 0.69 2500 BR SI2 H 0.5 0.69 2100 BR SI3 H 0.5 0.69 1900 BR I1 H 0.5 0.69 1600 BR I2 H 0.5 0.69 1200 BR I3 H 0.5 0.69 900 BR IF I 0.5 0.69 3800 BR VVS1 I 0.5 0.69 3400 BR VVS2 I 0.5 0.69 3100 BR VS1 I 0.5 0.69 2800 BR VS2 I 0.5 0.69 2500 BR SI1 I 0.5 0.69 2200 BR SI2 I 0.5 0.69 2000 BR SI3 I 0.5 0.69 1800 BR I1 I 0.5 0.69 1500 BR I2 I 0.5 0.69 1200 BR I3 I 0.5 0.69 900 BR IF J 0.5 0.69 2900 BR VVS1 J 0.5 0.69 2700 BR VVS2 J 0.5 0.69 2600 BR VS1 J 0.5 0.69 2300 BR VS2 J 0.5 0.69 2200 BR SI1 J 0.5 0.69 2000 BR SI2 J 0.5 0.69 1800 BR SI3 J 0.5 0.69 1600 BR I1 J 0.5 0.69 1400 BR I2 J 0.5 0.69 1200 BR I3 J 0.5 0.69 800 BR IF K 0.5 0.69 2500 BR VVS1 K 0.5 0.69 2400 BR VVS2 K 0.5 0.69 2300 BR VS1 K 0.5 0.69 2000 BR VS2 K 0.5 0.69 1900 BR SI1 K 0.5 0.69 1700 BR SI2 K 0.5 0.69 1600 BR SI3 K 0.5 0.69 1500 BR I1 K 0.5 0.69 1300 BR I2 K 0.5 0.69 1100 BR I3 K 0.5 0.69 800 BR IF L 0.5 0.69 2200 BR VVS1 L 0.5 0.69 2100 BR VVS2 L 0.5 0.69 2100 BR VS1 L 0.5 0.69 1900 BR VS2 L 0.5 0.69 1900 BR SI1 L 0.5 0.69 1700 BR SI2 L 0.5 0.69 1500 BR SI3 L 0.5 0.69 1400 BR I1 L 0.5 0.69 1100 BR I2 L 0.5 0.69 1000 BR I3 L 0.5 0.69 700 BR IF M 0.5 0.69 1900 BR VVS1 M 0.5 0.69 1800 BR VVS2 M 0.5 0.69 1800 BR VS1 M 0.5 0.69 1700 BR VS2 M 0.5 0.69 1700 BR SI1 M 0.5 0.69 1500 BR SI2 M 0.5 0.69 1400 BR SI3 M 0.5 0.69 1200 BR I1 M 0.5 0.69 1000 BR I2 M 0.5 0.69 900 BR I3 M 0.5 0.69 600 BR IF D 0.7 0.89 10700 BR VVS1 D 0.7 0.89 8200 BR VVS2 D 0.7 0.89 7000 BR VS1 D 0.7 0.89 6200 BR VS2 D 0.7 0.89 5600 BR SI1 D 0.7 0.89 4800 BR SI2 D 0.7 0.89 4300 BR SI3 D 0.7 0.89 3500 BR I1 D 0.7 0.89 2900 BR I2 D 0.7 0.89 1900 BR I3 D 0.7 0.89 1200 BR IF E 0.7 0.89 7900 BR VVS1 E 0.7 0.89 7000 BR VVS2 E 0.7 0.89 6300 BR VS1 E 0.7 0.89 5800 BR VS2 E 0.7 0.89 5200 BR SI1 E 0.7 0.89 4600 BR SI2 E 0.7 0.89 4100 BR SI3 E 0.7 0.89 3300 BR I1 E 0.7 0.89 2800 BR I2 E 0.7 0.89 1800 BR I3 E 0.7 0.89 1200 BR IF F 0.7 0.89 6900 BR VVS1 F 0.7 0.89 6400 BR VVS2 F 0.7 0.89 5900 BR VS1 F 0.7 0.89 5400 BR VS2 F 0.7 0.89 4900 BR SI1 F 0.7 0.89 4300 BR SI2 F 0.7 0.89 3800 BR SI3 F 0.7 0.89 3200 BR I1 F 0.7 0.89 2700 BR I2 F 0.7 0.89 1700 BR I3 F 0.7 0.89 1100 BR IF G 0.7 0.89 6200 BR VVS1 G 0.7 0.89 5600 BR VVS2 G 0.7 0.89 5200 BR VS1 G 0.7 0.89 4800 BR VS2 G 0.7 0.89 4400 BR SI1 G 0.7 0.89 3900 BR SI2 G 0.7 0.89 3500 BR SI3 G 0.7 0.89 3100 BR I1 G 0.7 0.89 2600 BR I2 G 0.7 0.89 1700 BR I3 G 0.7 0.89 1000 BR IF H 0.7 0.89 5500 BR VVS1 H 0.7 0.89 5000 BR VVS2 H 0.7 0.89 4600 BR VS1 H 0.7 0.89 4300 BR VS2 H 0.7 0.89 4000 BR SI1 H 0.7 0.89 3600 BR SI2 H 0.7 0.89 3300 BR SI3 H 0.7 0.89 2900 BR I1 H 0.7 0.89 2400 BR I2 H 0.7 0.89 1600 BR I3 H 0.7 0.89 1000 BR IF I 0.7 0.89 4600 BR VVS1 I 0.7 0.89 4300 BR VVS2 I 0.7 0.89 4100 BR VS1 I 0.7 0.89 3900 BR VS2 I 0.7 0.89 3600 BR SI1 I 0.7 0.89 3300 BR SI2 I 0.7 0.89 2900 BR SI3 I 0.7 0.89 2600 BR I1 I 0.7 0.89 2300 BR I2 I 0.7 0.89 1500 BR I3 I 0.7 0.89 1000 BR IF J 0.7 0.89 3500 BR VVS1 J 0.7 0.89 3400 BR VVS2 J 0.7 0.89 3300 BR VS1 J 0.7 0.89 3100 BR VS2 J 0.7 0.89 3000 BR SI1 J 0.7 0.89 2900 BR SI2 J 0.7 0.89 2700 BR SI3 J 0.7 0.89 2300 BR I1 J 0.7 0.89 2100 BR I2 J 0.7 0.89 1400 BR I3 J 0.7 0.89 900 BR IF K 0.7 0.89 3100 BR VVS1 K 0.7 0.89 3000 BR VVS2 K 0.7 0.89 2900 BR VS1 K 0.7 0.89 2700 BR VS2 K 0.7 0.89 2600 BR SI1 K 0.7 0.89 2400 BR SI2 K 0.7 0.89 2200 BR SI3 K 0.7 0.89 2000 BR I1 K 0.7 0.89 1700 BR I2 K 0.7 0.89 1300 BR I3 K 0.7 0.89 900 BR IF L 0.7 0.89 2600 BR VVS1 L 0.7 0.89 2500 BR VVS2 L 0.7 0.89 2400 BR VS1 L 0.7 0.89 2300 BR VS2 L 0.7 0.89 2300 BR SI1 L 0.7 0.89 2200 BR SI2 L 0.7 0.89 2000 BR SI3 L 0.7 0.89 1700 BR I1 L 0.7 0.89 1300 BR I2 L 0.7 0.89 1100 BR I3 L 0.7 0.89 800 BR IF M 0.7 0.89 2400 BR VVS1 M 0.7 0.89 2300 BR VVS2 M 0.7 0.89 2200 BR VS1 M 0.7 0.89 2100 BR VS2 M 0.7 0.89 2100 BR SI1 M 0.7 0.89 2000 BR SI2 M 0.7 0.89 1900 BR SI3 M 0.7 0.89 1600 BR I1 M 0.7 0.89 1200 BR I2 M 0.7 0.89 1000 BR I3 M 0.7 0.89 700 BR IF D 0.9 0.99 13100 BR VVS1 D 0.9 0.99 10900 BR VVS2 D 0.9 0.99 9500 BR VS1 D 0.9 0.99 7500 BR VS2 D 0.9 0.99 6700 BR SI1 D 0.9 0.99 6300 BR SI2 D 0.9 0.99 5400 BR SI3 D 0.9 0.99 4200 BR I1 D 0.9 0.99 3400 BR I2 D 0.9 0.99 2400 BR I3 D 0.9 0.99 1400 BR IF E 0.9 0.99 10800 BR VVS1 E 0.9 0.99 10200 BR VVS2 E 0.9 0.99 8600 BR VS1 E 0.9 0.99 6800 BR VS2 E 0.9 0.99 6400 BR SI1 E 0.9 0.99 5900 BR SI2 E 0.9 0.99 5200 BR SI3 E 0.9 0.99 4000 BR I1 E 0.9 0.99 3300 BR I2 E 0.9 0.99 2300 BR I3 E 0.9 0.99 1300 BR IF F 0.9 0.99 10200 BR VVS1 F 0.9 0.99 9600 BR VVS2 F 0.9 0.99 8000 BR VS1 F 0.9 0.99 6600 BR VS2 F 0.9 0.99 6200 BR SI1 F 0.9 0.99 5600 BR SI2 F 0.9 0.99 5000 BR SI3 F 0.9 0.99 3900 BR I1 F 0.9 0.99 3200 BR I2 F 0.9 0.99 2200 BR I3 F 0.9 0.99 1300 BR IF G 0.9 0.99 8600 BR VVS1 G 0.9 0.99 7800 BR VVS2 G 0.9 0.99 6700 BR VS1 G 0.9 0.99 6000 BR VS2 G 0.9 0.99 5700 BR SI1 G 0.9 0.99 5200 BR SI2 G 0.9 0.99 4600 BR SI3 G 0.9 0.99 3700 BR I1 G 0.9 0.99 3100 BR I2 G 0.9 0.99 2100 BR I3 G 0.9 0.99 1200 BR IF H 0.9 0.99 6900 BR VVS1 H 0.9 0.99 6500 BR VVS2 H 0.9 0.99 6100 BR VS1 H 0.9 0.99 5700 BR VS2 H 0.9 0.99 5400 BR SI1 H 0.9 0.99 4800 BR SI2 H 0.9 0.99 4400 BR SI3 H 0.9 0.99 3500 BR I1 H 0.9 0.99 2900 BR I2 H 0.9 0.99 2000 BR I3 H 0.9 0.99 1200 BR IF I 0.9 0.99 5800 BR VVS1 I 0.9 0.99 5500 BR VVS2 I 0.9 0.99 5100 BR VS1 I 0.9 0.99 4900
0debug
Facebook Access Token always null : <p>I have some code in my main Activity which calls My facebook Login activity class if AccessToken.getCurrentAccessToken() is null:</p> <pre><code>import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.widget.Toast; import com.facebook.AccessToken; import com.facebook.AccessTokenTracker; import com.facebook.CallbackManager; import com.facebook.FacebookCallback; import com.facebook.FacebookException; import com.facebook.Profile; import com.facebook.ProfileTracker; import com.facebook.login.LoginManager; import com.facebook.login.LoginResult; import java.util.Arrays; import matthewboyle.lurker_android.MainFeedScreen; import matthewboyle.lurker_android.utilities.ConnectionChecker; /** * Created by matthewboyle on 28/05/2017. */ public class FacebookLogin extends AppCompatActivity { private CallbackManager mCallbackManager; private AccessTokenTracker accessTokenTracker; private ProfileTracker profileTracker; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mCallbackManager = CallbackManager.Factory.create(); accessTokenTracker = new AccessTokenTracker() { @Override protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) { Log.d("facebook", "onCurrentAccessTokenChanged"); } }; profileTracker = new ProfileTracker() { @Override protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) { Log.d("facebook", "onCurrentProfileChanged"); } }; accessTokenTracker.startTracking(); profileTracker.startTracking(); LoginManager.getInstance().registerCallback(mCallbackManager, new FacebookCallback&lt;LoginResult&gt;() { @Override public void onSuccess(LoginResult loginResult) { Log.d("facebook", "in on success"); AccessToken accessToken = loginResult.getAccessToken(); Log.d("permissions", accessToken.getPermissions().toString()); Log.d("facebook", "in on success,got a token and its "+accessToken); } @Override public void onCancel() { Log.d("facebook", "in cancel"); } @Override public void onError(FacebookException exception) { Log.d("facebook", "in error"); Log.d("facebook", exception.toString()); } }); LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("public_profile", "user_posts","user_likes","user_about_me","user_managed_groups","user_tagged_places")); Log.d("facebook", "Done so redirecting with "+AccessToken.getCurrentAccessToken()); startActivity(new Intent(FacebookLogin.this,MainFeedScreen.class)); } @Override protected void onActivityResult(int requestCode, int responseCode, Intent intent) { super.onActivityResult(requestCode, responseCode, intent); //Facebook login mCallbackManager.onActivityResult(requestCode, responseCode, intent); } } </code></pre> <p>If I run this code, the only print statement I get is:</p> <pre><code> Done so redirecting with null </code></pre> <p>It doesn't seem to hit any other method in the class at all.</p> <p>It is worth mentioning that this code worked fine until I reinstalled the app. I went onto Facebook and updated the hash key in my app but that didn't seem to help. However, I'm not seeing any errors due to hash key.</p> <p>Would appreciate any help.</p>
0debug
static void FUNCC(pred8x16_horizontal_add)(uint8_t *pix, const int *block_offset, const int16_t *block, ptrdiff_t stride) { int i; for(i=0; i<4; i++) FUNCC(pred4x4_horizontal_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride); for(i=4; i<8; i++) FUNCC(pred4x4_horizontal_add)(pix + block_offset[i+4], block + i*16*sizeof(pixel), stride); }
1threat
Can ML Kit for Firebase be used for handwritten text? : <p>Concerning the new ML Kit for Firebase, all the examples I have seen from Google is recognizing "machine" text, but I was wondering if it is possible to use the new ML Kit for Firebase to extract handwritten characters as well?</p> <p>I think not, but I cannot find the information in the documentation or anywhere (and no I have not tried to actually use ML Kit yet).</p>
0debug
how to parse crul to json? : i am new in using curl, and i don t know how to parse this link to json curl --get --include 'https://doodle-manga- scraper.p.mashape.com/mangafox.me/manga/naruto/1' \ -H 'X-Mashape-Key: LhdkCyyF6Tmsh3BXTnN79quTbg08p1j2B20jsn89wOXridOzNe' \ -H 'Accept: text/plain' I do have this php script $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => 'https://doodle-manga- scraper.p.mashape.com/mangafox.me/manga/naruto/1' )); I never used curl and i really need help, time is against me ? can you please give me a script php to parse data from the command above. plz :(
0debug
static int opt_input_ts_scale(const char *opt, const char *arg) { unsigned int stream; double scale; char *p; stream = strtol(arg, &p, 0); if (*p) p++; scale= strtod(p, &p); if(stream >= MAX_STREAMS) ffmpeg_exit(1); ts_scale = grow_array(ts_scale, sizeof(*ts_scale), &nb_ts_scale, stream + 1); ts_scale[stream] = scale; return 0; }
1threat
How to use migration programmatically in EntityFramework Codefirst? : <p>I'm working in a project that uses EF Code First. I'm trying to use migration features. I don't want to use Package Console Manager. How can I execute the "Add-Migration" and "Update-Database" programmatically? </p> <pre><code>add-migration TestMigration01 -force update-database </code></pre>
0debug
How to combine a .map() with a promise? : <p>I have an array and I need, for each element of this array, to <code>fetch</code> some data (dependent on the element) and add this data to the element in the array.</p> <p>To set an example, I will simulate the <code>fetch</code> with a Promise (in real life, this will be the answer of a webservice):</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>let p = new Promise((resolve, reject) =&gt; resolve('x')) let a = ['a', 'b'] a = a.map(x =&gt; p.then(y =&gt; x + y)) console.log(a)</code></pre> </div> </div> </p> <p>What I expected is to have for the first element (<code>a</code>) <code>p</code> being called, and upon resolution the result added to <code>a</code> (giving <code>ax</code>). Same for <code>b</code>.</p> <p>Ultimately I expected a new array <code>['ax', 'bx']</code>.</p> <p>What I get instead is an array of Promises</p> <p>Being quite new to Promises (which I find in theory wonderful) I have a hard time understanding what went wrong here. <strong>Is it possible to combine <code>.map()</code> and asynchronous actions within?</strong></p>
0debug
void avfilter_uninit(void) { memset(registered_avfilters, 0, sizeof(registered_avfilters)); next_registered_avfilter_idx = 0; }
1threat
integer function with no return value : <p>I'm trying to execute the below code, since the function has no return value but it was defined with integer return type. how it was running without any error.</p> <pre><code>#include &lt;stdio.h&gt; int fn(int a, int b){ int temp = b; a = 2*temp; b = a; } int main() { int x,y,printval; scanf("%d%d",&amp;x,&amp;y); printval = fn(x,y); printf("%d", printval); return 0; } </code></pre> <p>i Expect the output be error but it was resulting in 40(input:10,20)</p>
0debug
How can I display opening (bottom aligned) quotation marks in Java? (Android Studio) : is it possible to display in a TextView a bottom aligned quotation mark [like this][1] in Android Studio(3.5.3) with java? [1]: https://i.stack.imgur.com/9qSFM.jpg
0debug
static void set_bmc_global_enables(IPMIBmcSim *ibs, uint8_t *cmd, unsigned int cmd_len, uint8_t *rsp, unsigned int *rsp_len, unsigned int max_rsp_len) { IPMI_CHECK_CMD_LEN(3); set_global_enables(ibs, cmd[2]); }
1threat
void qemu_bh_schedule(QEMUBH *bh) { AioContext *ctx; if (bh->scheduled) return; ctx = bh->ctx; bh->idle = 0; smp_mb(); bh->scheduled = 1; aio_notify(ctx); }
1threat
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
static void ffm_seek1(AVFormatContext *s, int64_t pos1) { FFMContext *ffm = s->priv_data; ByteIOContext *pb = s->pb; int64_t pos; pos = pos1 + ffm->write_index; if (pos >= ffm->file_size) pos -= (ffm->file_size - FFM_PACKET_SIZE); #ifdef DEBUG_SEEK av_log(s, AV_LOG_DEBUG, "seek to %"PRIx64" -> %"PRIx64"\n", pos1, pos); #endif url_fseek(pb, pos, SEEK_SET); }
1threat
Error:(5,19) java: package org.mockito does not exist : <p>I wanted to learn a bit about Mockito, but when I run my test class I get the following errors, even though I import the package:</p> <p><a href="https://i.stack.imgur.com/eGEO2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eGEO2.png" alt="enter image description here"></a></p> <p>What do I have to do, to make the code work?</p> <p><a href="https://i.stack.imgur.com/FZO6Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FZO6Q.png" alt="enter image description here"></a></p>
0debug
static void rtas_ibm_query_interrupt_source_number(sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { uint32_t config_addr = rtas_ld(args, 0); uint64_t buid = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 2); unsigned int intr_src_num = -1, ioa_intr_num = rtas_ld(args, 3); int ndev; sPAPRPHBState *phb = NULL; phb = find_phb(spapr, buid); if (!phb) { rtas_st(rets, 0, -3); return; } ndev = spapr_msicfg_find(phb, config_addr, false); if (ndev < 0) { trace_spapr_pci_msi("MSI has not been enabled", -1, config_addr); rtas_st(rets, 0, -1); return; } intr_src_num = phb->msi_table[ndev].irq + ioa_intr_num; trace_spapr_pci_rtas_ibm_query_interrupt_source_number(ioa_intr_num, intr_src_num); rtas_st(rets, 0, 0); rtas_st(rets, 1, intr_src_num); rtas_st(rets, 2, 1); }
1threat
static void destroy_buffers(VADisplay display, VABufferID *buffers, unsigned int n_buffers) { unsigned int i; for (i = 0; i < n_buffers; i++) { if (buffers[i]) { vaDestroyBuffer(display, buffers[i]); buffers[i] = 0; } } }
1threat
static av_cold int ljpeg_encode_close(AVCodecContext *avctx) { LJpegEncContext *s = avctx->priv_data; av_frame_free(&avctx->coded_frame); av_freep(&s->scratch); return 0; }
1threat
Take Text from an EntryBox and then write it to a txt file : <p>All, I have attempted this a few different ways and am still struggling here. </p> <p>I want to have someone write in this Entry Box and then once submit is hit, it should write the text to the .txt file. I'm obviously not very good. </p> <pre><code>import datetime from tkinter import * def save(): with open("text.txt", "a") as f: now = datetime.datetime.now() test = TxtComplaint.get() test = str(test) f.write(test) f.write(now) window = Tk() window.title("Documentation Window") lbl = Label(window, text = "Enter In The Employee's Information") TxtComplaint = Text(window, height = '10', width = '30') benter = Button(window, text="Submit", command = save()) TxtComplaint.pack() ee = Entry(window) eelbl = Label(window, text = "Whats the name of the employee?") eename = str(lbl) lbl.pack() benter.pack() ee.pack() eelbl.pack() window.mainloop() </code></pre>
0debug
I have a error on my sql kindly help me : UPDATE CaTbItemRequest SET vcReqStatus='complete' , vcItemCode='781015020002' WHERE inItemRequestNo=2000003 and vcDelFlag='false' and vcItemNatureType='Services' (Note vcItemCode -varchar(50)) The error MSG is Msg 248, Level 16, State 1, Procedure ExtendCode, Line 12 The conversion of the varchar value '781015020002' overflowed an int column. The statement has been terminated.
0debug
Disable the "a" attribute underline? : <p>I was wondering how you would disable to underline on the "a" attribute, for href's. I find it annoying, and I was wondering if there was a bit of code I could add to my .css to change it. Thank you.</p>
0debug
static void tcg_opt_gen_mov(TCGArg *gen_args, TCGArg dst, TCGArg src, int nb_temps, int nb_globals) { reset_temp(dst, nb_temps, nb_globals); assert(temps[src].state != TCG_TEMP_COPY); if (src >= nb_globals) { assert(temps[src].state != TCG_TEMP_CONST); if (temps[src].state != TCG_TEMP_HAS_COPY) { temps[src].state = TCG_TEMP_HAS_COPY; temps[src].next_copy = src; temps[src].prev_copy = src; } temps[dst].state = TCG_TEMP_COPY; temps[dst].val = src; temps[dst].next_copy = temps[src].next_copy; temps[dst].prev_copy = src; temps[temps[dst].next_copy].prev_copy = dst; temps[src].next_copy = dst; } gen_args[0] = dst; gen_args[1] = src; }
1threat
static void tpm_passthrough_cancel_cmd(TPMBackend *tb) { TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb); int n; if (tpm_pt->tpm_executing) { if (tpm_pt->cancel_fd >= 0) { n = write(tpm_pt->cancel_fd, "-", 1); if (n != 1) { error_report("Canceling TPM command failed: %s", strerror(errno)); } else { tpm_pt->tpm_op_canceled = true; } } else { error_report("Cannot cancel TPM command due to missing " "TPM sysfs cancel entry"); } } }
1threat
static int rm_assemble_video_frame(AVFormatContext *s, ByteIOContext *pb, RMDemuxContext *rm, RMStream *vst, AVPacket *pkt, int len, int *pseq) { int hdr, seq, pic_num, len2, pos; int type; hdr = get_byte(pb); len--; type = hdr >> 6; if(type != 3){ seq = get_byte(pb); len--; } if(type != 1){ len2 = get_num(pb, &len); pos = get_num(pb, &len); pic_num = get_byte(pb); len--; } if(len<0) return -1; rm->remaining_len = len; if(type&1){ if(type == 3) len= len2; if(rm->remaining_len < len) return -1; rm->remaining_len -= len; if(av_new_packet(pkt, len + 9) < 0) return AVERROR(EIO); pkt->data[0] = 0; AV_WL32(pkt->data + 1, 1); AV_WL32(pkt->data + 5, 0); get_buffer(pb, pkt->data + 9, len); return 0; } *pseq = seq; if((seq & 0x7F) == 1 || vst->curpic_num != pic_num){ vst->slices = ((hdr & 0x3F) << 1) + 1; vst->videobufsize = len2 + 8*vst->slices + 1; av_free_packet(&vst->pkt); if(av_new_packet(&vst->pkt, vst->videobufsize) < 0) return AVERROR(ENOMEM); vst->videobufpos = 8*vst->slices + 1; vst->cur_slice = 0; vst->curpic_num = pic_num; vst->pktpos = url_ftell(pb); } if(type == 2) len = FFMIN(len, pos); if(++vst->cur_slice > vst->slices) return 1; AV_WL32(vst->pkt.data - 7 + 8*vst->cur_slice, 1); AV_WL32(vst->pkt.data - 3 + 8*vst->cur_slice, vst->videobufpos - 8*vst->slices - 1); if(vst->videobufpos + len > vst->videobufsize) return 1; if (get_buffer(pb, vst->pkt.data + vst->videobufpos, len) != len) return AVERROR(EIO); vst->videobufpos += len; rm->remaining_len-= len; if(type == 2 || (vst->videobufpos) == vst->videobufsize){ vst->pkt.data[0] = vst->cur_slice-1; *pkt= vst->pkt; vst->pkt.data= NULL; vst->pkt.size= 0; if(vst->slices != vst->cur_slice) memmove(pkt->data + 1 + 8*vst->cur_slice, pkt->data + 1 + 8*vst->slices, vst->videobufpos - 1 - 8*vst->slices); pkt->size = vst->videobufpos + 8*(vst->cur_slice - vst->slices); pkt->pts = AV_NOPTS_VALUE; pkt->pos = vst->pktpos; return 0; } return 1; }
1threat
Promise error The message port closed before a reponse was received : <p>I've just started to get this error:</p> <p><code>Uncaught (in promise) Objectmessage: "The message port closed before a reponse was received."</code></p> <p>at chrome-extension://gppongmhjkpfnbhagpmjfkannfbllamg/js/browser-polyfill.js at this line:</p> <pre><code>const makeCallback = promise =&gt; { return (...callbackArgs) =&gt; { if (chrome.runtime.lastError) { promise.reject(chrome.runtime.lastError); // uncaught in promise } else if (callbackArgs.length === 1) { promise.resolve(callbackArgs[0]); } else { promise.resolve(callbackArgs); } }; }; </code></pre> <p>Do you know what can cause it? </p> <p>Thanks</p>
0debug
What is the '1995-12-17T03:24:00' for of a datetime called? : <p>I'm trying to to create a method that returns a random date in that format in the from today to a year ago. So right now I have</p> <pre><code>var curDate = new Date(), oneYearAgo = curDate-365*24*60*60*1000, randDate = new Date(Math.random() * (CurDate - OneYearAgo) + OneYearAgo); </code></pre> <p>But now how do I convert that to a string like in the title? I'm looking through <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date" rel="nofollow">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date</a> and can't figure it out because I don't know what the name of that format is. </p>
0debug
Call mysql Database remotely from another network in golang : I am new to MYSQL database and i m using go lang for my application. I have tried remote database calling with in the network.It is working but i would like to know can we do this if the remote call is from different network (i.e: for example database host server public ip address is 115.122.133.89 and the caller application public ip address is 115.122.134.63 ). Application is gonna run in windows and database server will be installed in Linux (CENTOS) If can may i know how to do this.And please advice me any cons and its solution by doing this.Appreciate any help.Thanks.
0debug
Opening new window in php with echo with predetermined size and width : So I have something that looks like this and I am trying to open a new link with predetermined size/with PHP echo. Here is what I have, echo '<a href=“noticeboard.php?charid=' .$row_char['noticeID'].'"STYLE="text-decoration: none" target="_blank"> &nbsp;&nbsp; &nbsp;[Announcements]<br> I have tried : echo '<a href=“noticeboard.php?charid=' .$row_char['noticeID'].'"" onclick="window.open (this.href, 'child', 'height=400,width=300,scrollbars'); return false">W3C</a> &nbsp;&nbsp; &nbsp;[Announcements]</a> What am I doing wrong? Is there a easier way to implement this. Thanks.
0debug
How does one initialize a variable with tf.get_variable and a numpy value in TensorFlow? : <p>I wanted to initialize some of the variable on my network with numpy values. For the sake of the example consider:</p> <pre><code>init=np.random.rand(1,2) tf.get_variable('var_name',initializer=init) </code></pre> <p>when I do that I get an error:</p> <pre><code>ValueError: Shape of a new variable (var_name) must be fully defined, but instead was &lt;unknown&gt;. </code></pre> <p>why is it that I am getting that error? </p> <p>To try to fix it I tried doing:</p> <pre><code>tf.get_variable('var_name',initializer=init, shape=[1,2]) </code></pre> <p>which yielded a even weirder error:</p> <pre><code>TypeError: 'numpy.ndarray' object is not callable </code></pre> <p>I tried reading <a href="https://www.tensorflow.org/versions/r0.9/api_docs/python/state_ops.html#variable_scope" rel="noreferrer">the docs and examples</a> but it didn't really help.</p> <p>Is it not possible to initialize variables with numpy arrays with the get_variable method in TensorFlow?</p>
0debug
void eth_get_protocols(const uint8_t *headers, uint32_t hdr_length, bool *isip4, bool *isip6, bool *isudp, bool *istcp) { int proto; size_t l2hdr_len = eth_get_l2_hdr_length(headers); assert(hdr_length >= eth_get_l2_hdr_length(headers)); *isip4 = *isip6 = *isudp = *istcp = false; proto = eth_get_l3_proto(headers, l2hdr_len); if (proto == ETH_P_IP) { *isip4 = true; struct ip_header *iphdr; assert(hdr_length >= eth_get_l2_hdr_length(headers) + sizeof(struct ip_header)); iphdr = PKT_GET_IP_HDR(headers); if (IP_HEADER_VERSION(iphdr) == IP_HEADER_VERSION_4) { if (iphdr->ip_p == IP_PROTO_TCP) { *istcp = true; } else if (iphdr->ip_p == IP_PROTO_UDP) { *isudp = true; } } } else if (proto == ETH_P_IPV6) { uint8_t l4proto; size_t full_ip6hdr_len; struct iovec hdr_vec; hdr_vec.iov_base = (void *) headers; hdr_vec.iov_len = hdr_length; *isip6 = true; if (eth_parse_ipv6_hdr(&hdr_vec, 1, l2hdr_len, &l4proto, &full_ip6hdr_len)) { if (l4proto == IP_PROTO_TCP) { *istcp = true; } else if (l4proto == IP_PROTO_UDP) { *isudp = true; } } } }
1threat
void slirp_init(int restricted, const char *special_ip) { #ifdef _WIN32 { WSADATA Data; WSAStartup(MAKEWORD(2,0), &Data); atexit(slirp_cleanup); } #endif link_up = 1; slirp_restrict = restricted; if_init(); ip_init(); m_init(); inet_aton("127.0.0.1", &loopback_addr); if (get_dns_addr(&dns_addr) < 0) { dns_addr = loopback_addr; fprintf (stderr, "Warning: No DNS servers found\n"); } if (special_ip) slirp_special_ip = special_ip; inet_aton(slirp_special_ip, &special_addr); alias_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS); getouraddr(); register_savevm("slirp", 0, 1, slirp_state_save, slirp_state_load, NULL); }
1threat
How to detect when a React Native app is opened? : <p>My React Native app wants to synchronize its local data with an API when the user opens the app. This should happen whenever the user returns to the app, not just when it first starts. Essentially, what I would like is the equivalent of AppDelegate's <code>applicationDidBecomeActive</code> callback, so that I can run synchronization code there. Obviously, I would like to do this in React Native instead.</p> <p>As far as I can tell, the <code>componentWillMount</code> / <code>componentDidMount</code> callbacks on the root component only run when the app is initially loaded, not after the user leaves the app and comes back later (without explicitly quitting the app).</p> <p>I thought that the <code>AppState</code> API would provide this functionality, but its <code>change</code> listeners don't fire in this case, either.</p> <p>This seems like obvious functionality to have, so I must be missing something glaringly obvious. Help!</p>
0debug
static void rtas_ibm_write_pci_config(sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { uint32_t val, size, addr; uint64_t buid = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 2); PCIDevice *dev = find_dev(spapr, buid, rtas_ld(args, 0)); if (!dev) { rtas_st(rets, 0, -1); return; } val = rtas_ld(args, 4); size = rtas_ld(args, 3); addr = rtas_pci_cfgaddr(rtas_ld(args, 0)); pci_host_config_write_common(dev, addr, pci_config_size(dev), val, size); rtas_st(rets, 0, 0); }
1threat
node 0.12.x const in strict mode issue : <p>I'm running node v0.12.7, and installed protractor through npm. Now I'm trying to run the conf.js using this <a href="https://angular.github.io/protractor/#/tutorial">simple tutorial</a>, and I get the following error when executing the command <code>protractor conf.js</code>:</p> <pre><code>[launcher] Process exited with error code 1 C:\Users\ramtin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\index.js:25 const builder = require('./builder'); ^^^^^ SyntaxError: Use of const in strict mode. at exports.runInThisContext (vm.js:73:16) at Module._compile (module.js:443:25) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Module.require (module.js:365:17) at require (module.js:384:17) at Object.&lt;anonymous&gt; (C:\Users\ramtin\AppData\Roaming\npm\node_modules\protractor\built\protractor.js:3:17) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) </code></pre> <p>Can't update node due to dependency issues it will produce (I'm working on an already-built project which used node 0.12.17).</p> <p>Using <code>--harmony</code> flag on protractor doesn't work. Do I need to install a specific version of protractor to be compatible with node 0.12.7? Or should I use <code>babeljs</code> to compile <code>ES6</code> to <code>ES5</code>?</p> <p>If <code>babeljs</code> is the answer, how would I use it for protractor?</p>
0debug
struct pxa2xx_i2c_s *pxa2xx_i2c_init(target_phys_addr_t base, qemu_irq irq, int ioregister) { int iomemtype; struct pxa2xx_i2c_s *s = (struct pxa2xx_i2c_s *) i2c_slave_init(i2c_init_bus(), 0, sizeof(struct pxa2xx_i2c_s)); s->base = base; s->irq = irq; s->slave.event = pxa2xx_i2c_event; s->slave.recv = pxa2xx_i2c_rx; s->slave.send = pxa2xx_i2c_tx; s->bus = i2c_init_bus(); if (ioregister) { iomemtype = cpu_register_io_memory(0, pxa2xx_i2c_readfn, pxa2xx_i2c_writefn, s); cpu_register_physical_memory(s->base & 0xfffff000, 0xfff, iomemtype); } register_savevm("pxa2xx_i2c", base, 0, pxa2xx_i2c_save, pxa2xx_i2c_load, s); return s; }
1threat
static int stdio_get_fd(void *opaque) { QEMUFileStdio *s = opaque; return fileno(s->stdio_file); }
1threat
static int hls_window(AVFormatContext *s, int last) { HLSContext *hls = s->priv_data; ListEntry *en; int64_t target_duration = 0; int ret = 0; AVIOContext *out = NULL; char temp_filename[1024]; int64_t sequence = FFMAX(hls->start_sequence, hls->sequence - hls->size); snprintf(temp_filename, sizeof(temp_filename), "%s.tmp", s->filename); if ((ret = avio_open2(&out, temp_filename, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL)) < 0) goto fail; for (en = hls->list; en; en = en->next) { if (target_duration < en->duration) target_duration = en->duration; } avio_printf(out, "#EXTM3U\n"); avio_printf(out, "#EXT-X-VERSION:%d\n", hls->version); if (hls->allowcache == 0 || hls->allowcache == 1) { avio_printf(out, "#EXT-X-ALLOW-CACHE:%s\n", hls->allowcache == 0 ? "NO" : "YES"); } avio_printf(out, "#EXT-X-TARGETDURATION:%"PRId64"\n", av_rescale_rnd(target_duration, 1, AV_TIME_BASE, AV_ROUND_UP)); avio_printf(out, "#EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", sequence); av_log(s, AV_LOG_VERBOSE, "EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", sequence); for (en = hls->list; en; en = en->next) { if (hls->version > 2) avio_printf(out, "#EXTINF:%f\n", (double)en->duration / AV_TIME_BASE); else avio_printf(out, "#EXTINF:%"PRId64",\n", av_rescale(en->duration, 1, AV_TIME_BASE)); if (hls->baseurl) avio_printf(out, "%s", hls->baseurl); avio_printf(out, "%s\n", en->name); } if (last) avio_printf(out, "#EXT-X-ENDLIST\n"); fail: avio_closep(&out); if (ret >= 0) ff_rename(temp_filename, s->filename); return ret; }
1threat
Most recent created subdirectory in directory (PHP) : <p>For example - I have some subdirectory like this in ftp:</p> <pre><code>public_html/raports/pdf/ </code></pre> <p>And in 'pdf' folder there are automatically created folders by month and year like: 07.2017, 08.2017, 09.2017 ... etc. </p> <p>I would like to create href link to the last created or last modified folder in directory given above. How to do it in PHP?</p> <p>Thanks!</p>
0debug
static void spr_write_40x_dbcr0 (void *opaque, int sprn) { DisasContext *ctx = opaque; gen_op_store_40x_dbcr0(); RET_STOP(ctx); }
1threat
static av_cold int psy_3gpp_init(FFPsyContext *ctx) { AacPsyContext *pctx; float bark; int i, j, g, start; float prev, minscale, minath; ctx->model_priv_data = av_mallocz(sizeof(AacPsyContext)); pctx = (AacPsyContext*) ctx->model_priv_data; minath = ath(3410, ATH_ADD); for (j = 0; j < 2; j++) { AacPsyCoeffs *coeffs = &pctx->psy_coef[j]; float line_to_frequency = ctx->avctx->sample_rate / (j ? 256.f : 2048.0f); i = 0; prev = 0.0; for (g = 0; g < ctx->num_bands[j]; g++) { i += ctx->bands[j][g]; bark = calc_bark((i-1) * line_to_frequency); coeffs->barks[g] = (bark + prev) / 2.0; prev = bark; } for (g = 0; g < ctx->num_bands[j] - 1; g++) { coeffs->spread_low[g] = pow(10.0, -(coeffs->barks[g+1] - coeffs->barks[g]) * PSY_3GPP_SPREAD_LOW); coeffs->spread_hi [g] = pow(10.0, -(coeffs->barks[g+1] - coeffs->barks[g]) * PSY_3GPP_SPREAD_HI); } start = 0; for (g = 0; g < ctx->num_bands[j]; g++) { minscale = ath(start * line_to_frequency, ATH_ADD); for (i = 1; i < ctx->bands[j][g]; i++) minscale = FFMIN(minscale, ath((start + i) * line_to_frequency, ATH_ADD)); coeffs->ath[g] = minscale - minath; start += ctx->bands[j][g]; } } pctx->ch = av_mallocz(sizeof(AacPsyChannel) * ctx->avctx->channels); lame_window_init(pctx, ctx->avctx); return 0; }
1threat
How to update the Redux store after Apollo GraphQL query returns : <p>I'm fetching a list of data with the <code>graphql</code> HOC provided by react apollo. E.g.:</p> <pre><code>const fetchList = graphql( dataListQuery, { options: ({ listId }) =&gt; ({ variables: { listId, }, }), props: ({ data: { loading, dataList } }) =&gt; { return { loading, list: dataList, }; } } ); </code></pre> <p>I'm displaying the list in a controlled radio button group and I need to select one of the items by default. The <code>id</code> of the selected item is kept in the Redux store.</p> <p>So, the question is how to update the Redux store (i.e. set the <code>selectedItem</code>) after the query successfully returns?</p> <p>Some options that came to my mind:</p> <h2>Option 1</h2> <p>Should I listen for <code>APOLLO_QUERY_RESULT</code> actions in my Redux reducer? But that is kind of awkward because then I would need to listen to both <code>APOLLO_QUERY_RESULT</code> and <code>APOLLO_QUERY_RESULT_CLIENT</code> if the query already ran before. And also the <code>operationName</code> prop is only present in the <code>APOLLO_QUERY_RESULT</code> action and not in <code>APOLLO_QUERY_RESULT_CLIENT</code> action. So i would need to dissect every <code>APOLLO_QUERY_RESULT_CLIENT</code> action to know where that came from. Isn't there an easy and straight forward way to identify query result actions?</p> <h2>Option 2</h2> <p>Should I dispatch a separate action like <code>SELECT_LIST_ITEM</code> in <code>componentWillReceiveProps</code> e.g (using <a href="https://github.com/acdlite/recompose" rel="noreferrer">recompose</a>):</p> <pre><code>const enhance = compose( connect( function mapStateToProps(state) { return { selectedItem: getSelectedItem(state), }; }, { selectItem, // action creator } ), graphql( dataListQuery, { options: ({ listId }) =&gt; ({ variables: { listId, }, }), props: ({ data: { loading, dataList } }) =&gt; ({ loading, items: dataList, }), } ), lifecycle({ componentWillReceiveProps(nextProps) { const { loading, items, selectedItem, selectItem, } = nextProps; if (!selectedItem &amp;&amp; !loading &amp;&amp; items &amp;&amp; items.length) { selectItem(items[items.length - 1].id); } } }) ); </code></pre> <h2>Option 3</h2> <p>Should I make use of the Apollo client directly by injecting it with <code>withApollo</code> and then dispatch my action with <code>client.query(...).then(result =&gt; { /* some logic */ selectItem(...)})</code>. But then I would loose all the benefits of the react-apollo integration, so not really an option.</p> <h2>Option 4</h2> <p>Should I not update the Redux store at all after the query returns? Because I could also just implement a selector that returns the <code>selectedItem</code> if it is set and if not it tries to derive it by browsing through the <code>apollo</code> part of the store.</p> <p>None of my options satisfy me. So, how would I do that right?</p>
0debug
Github user email is null, despite user:email scope : <p>I am following <a href="https://developer.github.com/v3/oauth/" rel="noreferrer">Github’s OAuth flow</a>, and obtaining an access token that gives me access to the user’s email scope. When I exchange a code for an access token, using the <a href="https://github.com/login/oauth/access_token" rel="noreferrer">https://github.com/login/oauth/access_token</a> endpoint, I get the following response:</p> <pre><code>{ access_token: '83f42..xxx’, token_type: 'bearer', scope: 'user:email' } </code></pre> <p>Looks great. So I make this request, using the token to get my user data:</p> <pre><code>Accept-Language: en-us Accept: application/json Authorization: token 83f42..xxx Accept-Encoding: gzip, deflate GET https://api.github.com/user </code></pre> <p>I do get my user object as a response, but the email property is null. Anyone else having this problem?</p>
0debug
when am trying to validate the jsp form on keypress event , it shows alert box first before entering any data onto input field? : <html> <head> <script text/javascript> var inputs = document.getElementsByTagName("input"); function checkTabPress(e) { for(var i=0;i<inputs.length;i++) { if((inputs[i].value === undefined || inputs[i].value.length == 0) && (e.keyCode == 9)) { alert("plz write"); return false; } } return true; } document.addEventListener('keyup', function (e) { checkTabPress(e); }, false); </script> </head> <body> Enter Your Name: <input onkeypress="checkTabPress('abc')" type='text' id="abc" placeholder=''><br> Enter <input onkeypress="checkTabPress('xyz')" type='text' id="xyz" placeholder=''> </body> </html> please help to resolve the issue.. Thank you reply as soon as possible Please... It looks like your post is mostly code; please add some more details.
0debug
static void set_int16(Object *obj, Visitor *v, void *opaque, const char *name, Error **errp) { DeviceState *dev = DEVICE(obj); Property *prop = opaque; int16_t *ptr = qdev_get_prop_ptr(dev, prop); Error *local_err = NULL; int64_t value; if (dev->state != DEV_STATE_CREATED) { error_set(errp, QERR_PERMISSION_DENIED); return; } visit_type_int(v, &value, name, &local_err); if (local_err) { error_propagate(errp, local_err); return; } if (value > prop->info->min && value <= prop->info->max) { *ptr = value; } else { error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, dev->id?:"", name, value, prop->info->min, prop->info->max); } }
1threat
static uint64_t ecc_diag_mem_read(void *opaque, target_phys_addr_t addr, unsigned size) { ECCState *s = opaque; uint32_t ret = s->diag[(int)addr]; trace_ecc_diag_mem_readb(addr, ret); return ret; }
1threat
static inline uint8_t fat_chksum(const direntry_t* entry) { uint8_t chksum=0; int i; for(i=0;i<11;i++) { unsigned char c; c = (i < 8) ? entry->name[i] : entry->extension[i-8]; chksum=(((chksum&0xfe)>>1)|((chksum&0x01)?0x80:0)) + c; } return chksum; }
1threat
static void raw_fd_pool_put(RawAIOCB *acb) { BDRVRawState *s = acb->common.bs->opaque; int i; for (i = 0; i < RAW_FD_POOL_SIZE; i++) { if (s->fd_pool[i] == acb->fd) { close(s->fd_pool[i]); s->fd_pool[i] = -1; } } }
1threat
static uint64_t vfio_rtl8168_window_quirk_read(void *opaque, hwaddr addr, unsigned size) { VFIOQuirk *quirk = opaque; VFIOPCIDevice *vdev = quirk->vdev; switch (addr) { case 4: if (quirk->data.flags) { trace_vfio_rtl8168_window_quirk_read_fake( memory_region_name(&quirk->mem), vdev->vbasedev.name); return quirk->data.address_match ^ 0x80000000U; } break; case 0: if (quirk->data.flags) { uint64_t val; trace_vfio_rtl8168_window_quirk_read_table( memory_region_name(&quirk->mem), vdev->vbasedev.name); if (!(vdev->pdev.cap_present & QEMU_PCI_CAP_MSIX)) { return 0; } memory_region_dispatch_read(&vdev->pdev.msix_table_mmio, (hwaddr)(quirk->data.address_match & 0xfff), &val, size, MEMTXATTRS_UNSPECIFIED); return val; } } trace_vfio_rtl8168_window_quirk_read_direct(memory_region_name(&quirk->mem), vdev->vbasedev.name); return vfio_region_read(&vdev->bars[quirk->data.bar].region, addr + 0x70, size); }
1threat
static uint64_t sdhci_read(void *opaque, hwaddr offset, unsigned size) { SDHCIState *s = (SDHCIState *)opaque; uint32_t ret = 0; switch (offset & ~0x3) { case SDHC_SYSAD: ret = s->sdmasysad; break; case SDHC_BLKSIZE: ret = s->blksize | (s->blkcnt << 16); break; case SDHC_ARGUMENT: ret = s->argument; break; case SDHC_TRNMOD: ret = s->trnmod | (s->cmdreg << 16); break; case SDHC_RSPREG0 ... SDHC_RSPREG3: ret = s->rspreg[((offset & ~0x3) - SDHC_RSPREG0) >> 2]; break; case SDHC_BDATA: if (sdhci_buff_access_is_sequential(s, offset - SDHC_BDATA)) { ret = sdhci_read_dataport(s, size); DPRINT_L2("read %ub: addr[0x%04x] -> %u(0x%x)\n", size, (int)offset, ret, ret); return ret; } break; case SDHC_PRNSTS: ret = s->prnsts; break; case SDHC_HOSTCTL: ret = s->hostctl | (s->pwrcon << 8) | (s->blkgap << 16) | (s->wakcon << 24); break; case SDHC_CLKCON: ret = s->clkcon | (s->timeoutcon << 16); break; case SDHC_NORINTSTS: ret = s->norintsts | (s->errintsts << 16); break; case SDHC_NORINTSTSEN: ret = s->norintstsen | (s->errintstsen << 16); break; case SDHC_NORINTSIGEN: ret = s->norintsigen | (s->errintsigen << 16); break; case SDHC_ACMD12ERRSTS: ret = s->acmd12errsts; break; case SDHC_CAPAREG: ret = s->capareg; break; case SDHC_MAXCURR: ret = s->maxcurr; break; case SDHC_ADMAERR: ret = s->admaerr; break; case SDHC_ADMASYSADDR: ret = (uint32_t)s->admasysaddr; break; case SDHC_ADMASYSADDR + 4: ret = (uint32_t)(s->admasysaddr >> 32); break; case SDHC_SLOT_INT_STATUS: ret = (SD_HOST_SPECv2_VERS << 16) | sdhci_slotint(s); break; default: qemu_log_mask(LOG_UNIMP, "SDHC rd_%ub @0x%02" HWADDR_PRIx " " "not implemented\n", size, offset); break; } ret >>= (offset & 0x3) * 8; ret &= (1ULL << (size * 8)) - 1; DPRINT_L2("read %ub: addr[0x%04x] -> %u(0x%x)\n", size, (int)offset, ret, ret); return ret; }
1threat
static ssize_t block_crypto_read_func(QCryptoBlock *block, void *opaque, size_t offset, uint8_t *buf, size_t buflen, Error **errp) { BlockDriverState *bs = opaque; ssize_t ret; ret = bdrv_pread(bs->file, offset, buf, buflen); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read encryption header"); return ret; } return ret; }
1threat
static void uhci_async_cancel_device(UHCIState *s, USBDevice *dev) { UHCIAsync *curr, *n; QTAILQ_FOREACH_SAFE(curr, &s->async_pending, next, n) { if (curr->packet.owner == NULL || curr->packet.owner->dev != dev) { continue; } uhci_async_unlink(s, curr); uhci_async_cancel(s, curr); } }
1threat
Regex to find sequence of words that can repeat : <p>I would like to identify the following pattern on a string (all words are separated by comma)<br> 1. The string starts with RO,TA,PR<br> 2. The string ends with TA,TO<br> 3. After RO,TA,PR it can have multiples TA,PR<br></p> <p>Example of valid patterns:<br> - RO,TA,PR,TA,TO<br> - RO,TA,PR,TA,PR,TA,TO<br> - RO,TA,PR,TA,PR,TA,PR,TA,TO<br> - RO,TA,PR,TA,PR,TA,PR,TA,PR,TA,TO<br> - RO,TA,PR,TA,PR,TA,PR,TA,PR,TA,TO<br></p> <p>Example of invalid patterns:<br> - RO,PR,TA,TO<br> - RO,TA,TO,PR,TA,TO<br> - RO,TA,RO,TA,TO<br> - RO,TA,PR,TO<br></p>
0debug
static void s390_virtio_rng_instance_init(Object *obj) { VirtIORNGS390 *dev = VIRTIO_RNG_S390(obj); object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG); object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); object_property_add_link(obj, "rng", TYPE_RNG_BACKEND, (Object **)&dev->vdev.conf.rng, OBJ_PROP_LINK_UNREF_ON_RELEASE, NULL); }
1threat
static void term_handle_command(const char *cmdline) { const char *p, *pstart, *typestr; char *q; int c, nb_args, len, i, has_arg; term_cmd_t *cmd; char cmdname[256]; char buf[1024]; void *str_allocated[MAX_ARGS]; void *args[MAX_ARGS]; #ifdef DEBUG term_printf("command='%s'\n", cmdline); #endif p = cmdline; q = cmdname; while (isspace(*p)) p++; if (*p == '\0') return; pstart = p; while (*p != '\0' && *p != '/' && !isspace(*p)) p++; len = p - pstart; if (len > sizeof(cmdname) - 1) len = sizeof(cmdname) - 1; memcpy(cmdname, pstart, len); cmdname[len] = '\0'; for(cmd = term_cmds; cmd->name != NULL; cmd++) { if (compare_cmd(cmdname, cmd->name)) goto found; } term_printf("unknown command: '%s'\n", cmdname); return; found: for(i = 0; i < MAX_ARGS; i++) str_allocated[i] = NULL; typestr = cmd->args_type; nb_args = 0; for(;;) { c = *typestr; if (c == '\0') break; typestr++; switch(c) { case 'F': case 'B': case 's': { int ret; char *str; while (isspace(*p)) p++; if (*typestr == '?') { typestr++; if (*p == '\0') { str = NULL; goto add_str; } } ret = get_str(buf, sizeof(buf), &p); if (ret < 0) { switch(c) { case 'F': term_printf("%s: filename expected\n", cmdname); break; case 'B': term_printf("%s: block device name expected\n", cmdname); break; default: term_printf("%s: string expected\n", cmdname); break; } goto fail; } str = qemu_malloc(strlen(buf) + 1); strcpy(str, buf); str_allocated[nb_args] = str; add_str: if (nb_args >= MAX_ARGS) { error_args: term_printf("%s: too many arguments\n", cmdname); goto fail; } args[nb_args++] = str; } break; case '/': { int count, format, size; while (isspace(*p)) p++; if (*p == '/') { p++; count = 1; if (isdigit(*p)) { count = 0; while (isdigit(*p)) { count = count * 10 + (*p - '0'); p++; } } size = -1; format = -1; for(;;) { switch(*p) { case 'o': case 'd': case 'u': case 'x': case 'i': case 'c': format = *p++; break; case 'b': size = 1; p++; break; case 'h': size = 2; p++; break; case 'w': size = 4; p++; break; case 'g': case 'L': size = 8; p++; break; default: goto next; } } next: if (*p != '\0' && !isspace(*p)) { term_printf("invalid char in format: '%c'\n", *p); goto fail; } if (format < 0) format = default_fmt_format; if (format != 'i') { if (size < 0) size = default_fmt_size; } default_fmt_size = size; default_fmt_format = format; } else { count = 1; format = default_fmt_format; if (format != 'i') { size = default_fmt_size; } else { size = -1; } } if (nb_args + 3 > MAX_ARGS) goto error_args; args[nb_args++] = (void*)count; args[nb_args++] = (void*)format; args[nb_args++] = (void*)size; } break; case 'i': { int val; while (isspace(*p)) p++; if (*typestr == '?' || *typestr == '.') { typestr++; if (*typestr == '?') { if (*p == '\0') has_arg = 0; else has_arg = 1; } else { if (*p == '.') { p++; while (isspace(*p)) p++; has_arg = 1; } else { has_arg = 0; } } if (nb_args >= MAX_ARGS) goto error_args; args[nb_args++] = (void *)has_arg; if (!has_arg) { if (nb_args >= MAX_ARGS) goto error_args; val = -1; goto add_num; } } if (get_expr(&val, &p)) goto fail; add_num: if (nb_args >= MAX_ARGS) goto error_args; args[nb_args++] = (void *)val; } break; case '-': { int has_option; c = *typestr++; if (c == '\0') goto bad_type; while (isspace(*p)) p++; has_option = 0; if (*p == '-') { p++; if (*p != c) { term_printf("%s: unsupported option -%c\n", cmdname, *p); goto fail; } p++; has_option = 1; } if (nb_args >= MAX_ARGS) goto error_args; args[nb_args++] = (void *)has_option; } break; default: bad_type: term_printf("%s: unknown type '%c'\n", cmdname, c); goto fail; } } while (isspace(*p)) p++; if (*p != '\0') { term_printf("%s: extraneous characters at the end of line\n", cmdname); goto fail; } switch(nb_args) { case 0: cmd->handler(); break; case 1: cmd->handler(args[0]); break; case 2: cmd->handler(args[0], args[1]); break; case 3: cmd->handler(args[0], args[1], args[2]); break; case 4: cmd->handler(args[0], args[1], args[2], args[3]); break; case 5: cmd->handler(args[0], args[1], args[2], args[3], args[4]); break; case 6: cmd->handler(args[0], args[1], args[2], args[3], args[4], args[5]); break; default: term_printf("unsupported number of arguments: %d\n", nb_args); goto fail; } fail: for(i = 0; i < MAX_ARGS; i++) qemu_free(str_allocated[i]); return; }
1threat
while opening "https://www.flipkart.com/" a window opens for login. How to handle this window in selenium? : System.setProperty("webdriver.gecko.driver", "F:\\Software_Sel\\GekoDriver\\geckodriver-v0.16.1-win64\\geckodriver.exe"); WebDriver wd = new FirefoxDriver(); wd.get("https://www.flipkart.com/") WebElement e1= wd.findElement(By.className("_2AkmmA _29YdH8")); e1.click(); I have also tried iframe. But cant handle.Kindly help.
0debug
Where may I find an IQueryable implementation of Contains for T-SQL? : <p>Everytime I do a:</p> <pre><code>journals = _context.Journals .Where(j =&gt; j.Name.Contains("foo")); </code></pre> <p>I feel the need to stop and write an extension on <code>IQueryable</code> that will make the <code>Contains</code> work. Is there one available already?</p>
0debug
How do i assign foreign key value to my post : # This my part of CreateView def post(self, request, *args, **kwargs): form = BussinessDetailForm(request.POST,request.FILES or None) form2 = MultipleImageForm(request.POST or None, request.FILES or None) files = request.FILES.getlist('images') if all([form.is_valid(),form2.is_valid()]): forms = form.save(commit=False) geolocator = Nominatim() location = geolocator.geocode(self.request.POST.get("pin_code",False)) forms.latitude = location.latitude forms.longitude = location.longitude forms.created_by = self.request.user forms.themes = self # forms.object_id = int(self.request.POST.get("id",False)) forms.save() # part of models.py class BussinessDetail(models.Model): # content_type = models.ForeignKey(ContentType,on_delete = models.CASCADE) # object_id = models.PositiveIntegerField() # content_object = GenericForeignKey('content_type','object_id') themes = models.ForeignKey(Themes,on_delete=models.CASCADE,primary_key=False) # object_id = models.PositiveIntegerField() created_by =models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE,primary_key=False) listin_catagory =models.CharField(max_length=200,choices=listin_Catagory,blank=True) bussiness_name =models.CharField(max_length=200,blank=True) #themes table class Themes(models.Model): theme_created_by =models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE,primary_key=False) default_theme = models.BooleanField(blank=True,default=False) technology_theme = models.BooleanField(blank=True,default=False)
0debug
Maximum absolute difference in an array : <p>I came across this algorithm question. I was able to implement a O(n^2) solution. Is there a better way of doing this in O(n) time? </p> <p><strong>Question:</strong></p> <p>You are given an array of N integers, <code>A1, A2 ,…, AN</code>. Return maximum value of <code>f(i, j)</code> for all <code>1 ≤ i, j ≤ N</code>. <code>f(i, j)</code> is defined as <code>|A[i] - A[j]| + |i - j|</code>, where <code>|x|</code> denotes absolute value of x.</p> <p><strong>Example</strong>:</p> <pre><code>A=[1, 3, -1] f(1, 1) = f(2, 2) = f(3, 3) = 0 f(1, 2) = f(2, 1) = |1 - 3| + |1 - 2| = 3 f(1, 3) = f(3, 1) = |1 - (-1)| + |1 - 3| = 4 f(2, 3) = f(3, 2) = |3 - (-1)| + |2 - 3| = 5 </code></pre> <p>So, we return 5.</p> <p><strong>My Answer:</strong></p> <pre><code>public class Solution { public int maxArr(ArrayList&lt;Integer&gt; A) { int maxSum = 0; for(int i=1; i&lt;=A.size()-1; i++){ for(int j=i+1; j&lt;=A.size(); j++){ int tempSum = sum(A.get(i-1), A.get(j-1), i, j); if(tempSum &gt; maxSum) { maxSum = tempSum; } } } return maxSum; } public int sum(int Ai, int Aj, int i, int j) { return Math.abs(Ai-Aj) + Math.abs(i-j); } } </code></pre> <p>Also in my solution the inner loop runs from i + 1 to N, so the worst case is N-1 for that loop. Is my overall solution still O(n^2)?</p>
0debug
python String out of index : def cleanupstring (S): newstring = ["", 0] j = 1 for i in range(len(S)): if S[i] != " " and S[i+1] != " ": newstring[0] = newstring[0] + S[i] else: newstring[1] = newstring [1] + 1 return newstring # main program sentence = input("Enter a string: ") outputList = cleanupstring(sentence) print("A total of", outputList[1], "characters have been removed from your string.") print("The new string is:", outputList[0]) Use Python to create a function cleanstring(S) to "clean up" the spaces in a sentence S. The sentence may have extra spaces at the front and/or at the end and/or between words. The subroutine returns a new version of the sentence without the extra spaces. That is, in the new string, the words should be the same but there should be no spaces at the start, only one space between each word and no spaces at the end. This program is about you writing code to search through a string to find words and so you are not allowed to use the split function in Python. You can solve this problem with the basic capabilities of the if and while statements and string operations of len and concatentation. For example: if the input is: " Hello to the world !" then the output should be: "Hello to the world!" Can anyone help me why my program creates an error and how to fix it
0debug
why lazy loaded module has to import commonModule? Angular 2 : <p>When we import <strong>BrowserModule</strong> in root module of application ,we can use NgIf and NgFor( in eagerly loaded component). But for lazy loaded modules I have to import CommonModule which has been exported by BrowserModule of root. SO why do we have to import it again in lazy loaded module?</p>
0debug
Using mongoose promises with async/await : <p>I'm trying to get the hang of using Mongoose promises with the async/await functionality of Node.js. When my function <code>printEmployees</code> is called I want to save the list of employees which are queried by the <code>orderEmployees</code> function. While, the <code>console.log</code> statement inside <code>orderEmployees</code> returns the expected query, the <code>console.log</code> inside of <code>printEmployees</code> returns <code>undefined</code>, suggesting that I'm not returning the promise correctly.</p> <p>I'm new to promises so entirely possible that I'm not correctly understanding the paradigm... any help is much appreciated.</p> <pre><code> printEmployees: async(company) =&gt; { var employees = await self.orderEmployees(company); // SECOND CONSOLE.LOG console.log(employees); }, orderEmployees: (companyID) =&gt; { User.find({company:companyID}) .exec() .then((employees) =&gt; { // FIRST CONSOLE.LOG console.log(employees); return employees; }) .catch((err) =&gt; { return 'error occured'; }); }, </code></pre>
0debug
c++ array of type class : <p>I have just started learning c++. I have a question in an assignment that reads: Consider the following class declaration with a main() function. There are two errors in the main() function. Name them and explain how to fix them.</p> <pre><code>//Question Three Start #include &lt;iostream&gt; #include &lt;string&gt; using namespace std; class Restaurant { public: Restaurant(); int getTables(); int getTempStaff(); int getPermStaff(); string getShifts(); private: string Menu; int Tables; int TempStaff; int PermStaff; string Shifts[3]; }; int main() { Restaurant mimmos; //.........(additional code) string menu = mimmos.Menu; //.........(additional code) //get information about shift 3 cout &lt;&lt; "Shift info:" &lt;&lt; mimmos[2].getShifts() &lt;&lt; endl; return 0; } </code></pre> <p>I know that the first issue is that the member variable Menu is private, but i am not sure how to fix the issue with the mimmos[2].getShifts() and how to use an accessor/mutator function. Any help will be greatly appreciated.</p>
0debug
Add an element on the last Jekyll loop of posts : <p>I'm sure this is simple but cant find the answer.</p> <p>There is a standard Jekyll/Liquid post iterator. How do i use the <code>{% if %}</code> statement below to put the <code>&lt;hr&gt;</code> element for each post <strong>except</strong> the last?</p> <pre><code>&lt;ul class="post-list"&gt; {% for post in site.posts %} {% if post.url %} &lt;br&gt; &lt;li&gt; &lt;h2&gt; &lt;a class="post-link" href="{{ post.url | prepend: site.baseurl }}"&gt;{{ post.title }}&lt;/a&gt; &lt;/h2&gt; &lt;span class="post-meta"&gt;{{ post.date | date: "%b %-d, %Y" }}&lt;/span&gt; &lt;/li&gt; **** {% if post != $last %} ***** How do i do this?? &lt;hr&gt; {% endif %} {% endif %} {% endfor %} &lt;/ul&gt; </code></pre>
0debug
def count_Char(str,x): count = 0 for i in range(len(str)): if (str[i] == x) : count += 1 n = 10 repititions = n // len(str) count = count * repititions l = n % len(str) for i in range(l): if (str[i] == x): count += 1 return count
0debug
Discord.js: "if (message.channel.name === '')" not working : <p>I'm trying to make a bot not respond if the message isn't in a channel, for some reason using </p> <pre class="lang-js prettyprint-override"><code>if (message.channel.name === '') </code></pre> <p>doesn't work. I can see the channel name by using if I console log it, so I don't understand why it's not working, and I get no errors in the console. </p> <p>Help would be greatly appreciated.</p>
0debug
Unable to insert a row into my Bug_Project table : <p>I am writing a database in oracle and am i little stuck with the following error code:</p> <pre><code>Error starting at line : 95 in command - INSERT INTO Bug_Project(Bug_ID, Project_ID) VALUES (00, 00) Error at Command Line : 95 Column : 33 Error report - SQL Error: ORA-00904: "PROJECT_ID": invalid identifier 00904. 00000 - "%s: invalid identifier" *Cause: *Action: </code></pre> <p>I am new to oracle and sql and not sure which identifier is invalid.</p> <p>I have looked at the dates between the bug and project and they all correlate so i am not sure what could be the problem.</p> <p>It's probably a small fix but confuses the hell out of me.</p> <p>My code is displayed below and any help would be greatly appreciated:</p> <pre><code>--CREATE SCRIPTS /*put your create scripts here – your script should not commented out*/ CREATE TABLE Project ( Proj_ID integer, Proj_Name varchar(10), Proj_Start_Date date, primary key (Proj_ID) ); CREATE TABLE Bug ( Bug_ID integer, Bug_Type varchar(100), Bug_Desc varchar(100), Bug_Time date, primary key(Bug_ID) ); CREATE TABLE Engineer ( Engineer_ID integer, Engineer_Name varchar(10), Engineer_Type varchar(20), primary key (Engineer_ID) ); CREATE TABLE Bug_Project ( Bug_ID integer, Proj_ID integer, primary key(Bug_ID, Proj_ID), foreign key(Bug_ID) references Bug (Bug_ID), foreign key(Proj_ID) references Project (Proj_ID) ); CREATE TABLE Fix_Allocation ( Engineer_ID integer, Bug_ID integer, primary key(Engineer_ID, Bug_ID), foreign key(Engineer_ID) references Engineer (Engineer_ID), foreign key(Bug_ID) references Bug (Bug_ID) ); CREATE TABLE Test_Allocation ( Engineer_ID integer, Bug_ID integer, primary key(Engineer_ID, Bug_ID), foreign key(Engineer_ID) references Engineer (Engineer_ID), foreign key(Bug_ID) references Bug (Bug_ID) ); CREATE TABLE Note ( Engineer_ID integer, Bug_ID integer, Note_author varchar(10), Note_contents varchar(20), primary key(Engineer_ID, Bug_ID), foreign key(Engineer_ID) references Engineer (Engineer_ID), foreign key(Bug_ID) references Bug (Bug_ID) ); COMMIT; --INSERT SCRIPTS /*put your insert scripts here – your script should not commented out */ INSERT INTO Project(Proj_ID, Proj_Name, Proj_Start_Date) VALUES (00, 'Project 1', DATE '1980-02-14'); INSERT INTO Project(Proj_ID, Proj_Name, Proj_Start_Date) VALUES (01, 'Project 2', DATE '1985-12-11'); INSERT INTO Project(Proj_ID, Proj_Name, Proj_Start_Date) VALUES (02, 'Project 3', DATE '1992-06-03'); INSERT INTO Project(Proj_ID, Proj_Name, Proj_Start_Date) VALUES (03, 'Project 4', DATE '2000-07-22'); INSERT INTO Project(Proj_ID, Proj_Name, Proj_Start_Date) VALUES (04, 'Project 5', DATE '2012-03-19'); INSERT INTO Project(Proj_ID, Proj_Name, Proj_Start_Date) VALUES (05, 'Project 6', DATE '2015-10-21'); INSERT INTO Bug(Bug_ID, Bug_Type, Bug_Desc, Bug_Time) VALUES (00, 'Crash', 'Software stopped functioning properly and exited', timestamp '1980-03-20 09:26:50'); INSERT INTO Bug(Bug_ID, Bug_Type, Bug_Desc, Bug_Time) VALUES (01, 'Run Time Error', 'Wrong output due to a logical error', timestamp '1982-06-12 11:36:32'); INSERT INTO Bug(Bug_ID, Bug_Type, Bug_Desc, Bug_Time) VALUES (02, 'Compilation Error', 'Problems with the compiler, failed complication of source code', timestamp '1987-07-12 14:11:15'); INSERT INTO Bug(Bug_ID, Bug_Type, Bug_Desc, Bug_Time) VALUES (03, 'Crash', 'Software stopped functioning properly and exited', timestamp '1993-01-31 03:21:17'); INSERT INTO Bug(Bug_ID, Bug_Type, Bug_Desc, Bug_Time) VALUES (04, 'Logical Error', 'Unexpected behavior due to problem in source code', timestamp '1997-04-01 10:46:18'); INSERT INTO Bug(Bug_ID, Bug_Type, Bug_Desc, Bug_Time) VALUES (05, 'Run Time Error', 'Wrong output due to a logical error', timestamp '2001-12-24 12:12:37'); INSERT INTO Bug(Bug_ID, Bug_Type, Bug_Desc, Bug_Time) VALUES (06, 'GUI Error', 'Glitchy interface ', timestamp '2013-09-02 17:11:55'); INSERT INTO Bug(Bug_ID, Bug_Type, Bug_Desc, Bug_Time) VALUES (07, 'Run Time Error', 'Wrong output due to a logical error', timestamp '2016-02-03 11:11:21'); INSERT INTO Engineer(Engineer_ID, Engineer_Name, Engineer_Type) VALUES (00, 'Ava', 'Tester'); INSERT INTO Engineer(Engineer_ID, Engineer_Name, Engineer_Type) VALUES (01, 'Alexander', 'Fixer'); INSERT INTO Engineer(Engineer_ID, Engineer_Name, Engineer_Type) VALUES (02, 'Aiden', 'Fixer'); INSERT INTO Engineer(Engineer_ID, Engineer_Name, Engineer_Type) VALUES (03, 'Anthony', 'Tester'); INSERT INTO Engineer(Engineer_ID, Engineer_Name, Engineer_Type) VALUES (04, 'Adam', 'Fixer'); INSERT INTO Engineer(Engineer_ID, Engineer_Name, Engineer_Type) VALUES (05, 'Alex', 'Tester'); INSERT INTO Engineer(Engineer_ID, Engineer_Name, Engineer_Type) VALUES (06, 'John', 'Fixer'); INSERT INTO Bug_Project(Bug_ID, Project_ID) VALUES (00, 00); INSERT INTO Bug_Project(Bug_ID, Project_ID) VALUES (01, 00); INSERT INTO Bug_Project(Bug_ID, Project_ID) VALUES (02, 01); INSERT INTO Bug_Project(Bug_ID, Project_ID) VALUES (03, 02); INSERT INTO Bug_Project(Bug_ID, Project_ID) VALUES (04, 02); INSERT INTO Bug_Project(Bug_ID, Project_ID) VALUES (05, 03); INSERT INTO Bug_Project(Bug_ID, Project_ID) VALUES (06, 04); INSERT INTO Bug_Project(Bug_ID, Project_ID) VALUES (07, 05); INSERT INTO Fix_Allocation(Engineer_ID, Bug_ID) VALUES (01, 01); INSERT INTO Fix_Allocation(Engineer_ID, Bug_ID) VALUES (02, 02); INSERT INTO Fix_Allocation(Engineer_ID, Bug_ID) VALUES (04, 04); INSERT INTO Fix_Allocation(Engineer_ID, Bug_ID) VALUES (06, 05); INSERT INTO Fix_Allocation(Engineer_ID, Bug_ID) VALUES (06, 07); INSERT INTO Test_Allocation VALUES (); INSERT INTO Test_Allocation VALUES (); INSERT INTO Test_Allocation VALUES (); INSERT INTO Note VALUES (); INSERT INTO Note VALUES (); INSERT INTO Note VALUES (); COMMIT; --SELECT SCRIPT /*put your select scripts here (with indication of which query is answered) – your script should not commented out -- Query 1: List of all the bugs, and their details. SELECT * FROM Bug; -- Query 2: List of all bugs, and their notes. -- Query 3: List of all bugs, with their notes, and the engineers who have written them; sorted by name of engineer. -- Query 4: List the bugs and how much cumulative time (in hours) they have taken; ordered by time taken. -- Query 5: The bug that has taken most time to fix, and the projects it is connected to. COMMIT; --DROP SCRIPT /*put your drop scripts here (in the correct order)– your script should not commented out DROP TABLE Note; DROP TABLE Test_Allocation; DROP TABLE Fix_Allocation; DROP TABLE Engineer; DROP TABLE Bug_Project; DROP TABLE Bug; DROP TABLE Project; COMMIT; </code></pre>
0debug
Why is my pogram crashing when I try to initialize my pointer? : So my program runs the numElements method but than crashes, am I declaring my variables wrong or is my pointer variable wrong? Header.h typedef struct Node { int number; struct Node *pNext; }Node; Other.h int i,j,c,numElem; time_t t; srand((unsigned) time(&t)); numElem = numElements(); pNode[numElem]; for(i = 0; i < numElem; i++){ pNode[i].number = (rand() % (MAX - MIN)) + MIN; //c = (rand() % (MAX - MIN)) + MIN; printf("P is %d\n",pNode[i].number); printf("C = %d",c); }
0debug
How To Convert URL to Image in android. Here showing URL's in GridView by using arrayList and ArrayAdapter : > i am using GridView and fetching all urls with data from server in android now i want to convert these url's in to images.
0debug
How can i calculate the cost of the Loan with the Capital and interest rate? Vba : I´m doing a Intership as a Developer an got a tough exercise. I´ve got a Loan Text and there are 3 Fields blank, the Loan, the Capital and the interest rate. I´ve created already the and it look like this: Private Sub l_jahre_Click() End Sub Private Sub txt_abtrag_Change() CalculateFormular End Sub Private Sub txt_darlehen_Change() CalculateFormular End Sub Private Sub txt_zinssatz_Change() CalculateFormular End Sub Private Sub CalculateFormular() If (validate()) Then Debug.Print "Success" End If End Sub Private Function validate() As Boolean validate = True On Error GoTo x a = CDbl(txt_abtrag.Value) + CDbl(txt_darlehen.Value) + CDbl(txt_zinssatz.Value) Exit Function x: validate = False End Function Public Sub test2() 'Debug.Print txt_zinssatz.Value l_zinsen.Caption = "inf." End Sub Don´t mind the Value of them xd And now I Need to calculate, like i said, the cost of the Loan with the Capital and interest rate. I Need to fill it up and it Looks like this. Public Function GetTotalCost(ByVal capital As Double, ByVal rate As Double) As Double GetTotalCost = 0 End Function Public Function GetRentTime(ByVal capital As Double, ByVal rate As Double, ByVal monthPay As Double) As Double GetRentTime = 0 End Function please don´t say the full Code or the full answer i just Need some help to understand and what method i should use. Thank you for your help.
0debug
VueJS - Unit testing with vue-test-utils gives error - TypeError: _vm.$t is not a function : <p>Relatively new to Vuejs and testing its components. Using vue-test-utils and jest for testing. Getting following error <a href="https://i.stack.imgur.com/rQejp.jpg" rel="noreferrer">test log</a></p> <p>The .vue file consists of template, component and styling. Below is the part of the SignupLayout.vue that gets error - </p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;style lang="sass"&gt; @import '../stylesheets/colors' html[path="/signup"], html[path="/login"] height: 100% background-image: url("../assets/background.jpg") background-size: cover background-position: center background-repeat: no-repeat overflow: hidden #signup-layout #change-language-button .lang-menu color: $alto &lt;/style&gt;</code></pre> </div> </div> </p> <p>Test File - </p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>import Vue from 'vue'; import Vuex from 'vuex' import SignupLayout from '../src/components/SignupLayout.vue'; import { mount, shallow, createLocalVue } from '@vue/test-utils'; const localVue = createLocalVue() localVue.use(Vuex) jest.resetModules() describe('Signup.test.js', () =&gt; { let cmp let actions let store let getters let state beforeEach(() =&gt; { state = { email: 'abc@gmail.com' } getters = { CURRENT_USER_EMAIL: state =&gt; state.email } store = new Vuex.Store({ getters }) }) it('has received ["Login"] as the title property', () =&gt; { cmp = shallow(SignupLayout, { store, localVue, propsData: { title: ['Login'] }, data: { email: 'abc@dsf.com' } }) cmp.update() expect(cmp.vm.title).toEqual(['Login']) }) })</code></pre> </div> </div> </p> <p>Confused as to what has $t got to do with sass. Any help would be appreciated. Stuck here for a while now. Let me know if more details needed. Thanks in advance</p>
0debug
Javascript - Make specific text a link : <p>I'm looking at a 'to do' list application that uses JavaScript. One of the functions converts text in to a hyperlink when https, https or ftp is present.</p> <p>I'd like to expand this so if my text contains # followed by any 5 digit number, that becomes a link as well. The URL should be <code>http://192.168.0.1/localsite/testschool/search.php?id=ID</code></p> <p>where ID is the # and 5 digit number.</p> <p>This is the current Javascript:</p> <pre><code>function prepareHtml(s) { // make URLs clickable s = s.replace(/(^|\s|&gt;)(www\.([\w\#$%&amp;~\/.\-\+;:=,\?\[\]@]+?))(,|\.|:|)?(?=\s|&amp;quot;|&amp;lt;|&amp;gt;|\"|&lt;|&gt;|$)/gi, '$1&lt;a href="http://$2" target="_blank"&gt;$2&lt;/a&gt;$4'); return s.replace(/(^|\s|&gt;)((?:http|https|ftp):\/\/([\w\#$%&amp;~\/.\-\+;:=,\?\[\]@]+?))(,|\.|:|)?(?=\s|&amp;quot;|&amp;lt;|&amp;gt;|\"|&lt;|&gt;|$)/ig, '$1&lt;a href="$2" target="_blank"&gt;$2&lt;/a&gt;$4'); }; </code></pre> <p>called using <code>prepareHtml(item.title)</code></p> <p>Any idea how I can do this ? I've worked out regex to match the # and 5 digits is <code>^#([0-9]{5})</code> but I'm not sure how to implement this in the function.</p> <p>Thanks</p>
0debug
static int mov_read_dref(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) { AVStream *st = c->fc->streams[c->fc->nb_streams-1]; MOVStreamContext *sc = st->priv_data; int entries, i, j; get_be32(pb); entries = get_be32(pb); if (entries >= UINT_MAX / sizeof(*sc->drefs)) return -1; sc->drefs_count = entries; sc->drefs = av_mallocz(entries * sizeof(*sc->drefs)); for (i = 0; i < sc->drefs_count; i++) { MOV_dref_t *dref = &sc->drefs[i]; uint32_t size = get_be32(pb); offset_t next = url_ftell(pb) + size - 4; dref->type = get_le32(pb); get_be32(pb); dprintf(c->fc, "type %.4s size %d\n", (char*)&dref->type, size); if (dref->type == MKTAG('a','l','i','s') && size > 150) { uint16_t volume_len, len; char volume[28]; int16_t type; url_fskip(pb, 10); volume_len = get_byte(pb); volume_len = FFMIN(volume_len, 27); get_buffer(pb, volume, 27); volume[volume_len] = 0; av_log(c->fc, AV_LOG_DEBUG, "volume %s, len %d\n", volume, volume_len); url_fskip(pb, 112); for (type = 0; type != -1 && url_ftell(pb) < next; ) { type = get_be16(pb); len = get_be16(pb); av_log(c->fc, AV_LOG_DEBUG, "type %d, len %d\n", type, len); if (len&1) len += 1; if (type == 2) { dref->path = av_mallocz(len+1); get_buffer(pb, dref->path, len); if (!strncmp(dref->path, volume, volume_len)) { len -= volume_len; memmove(dref->path, dref->path+volume_len, len); dref->path[len] = 0; } for (j = 0; j < len; j++) if (dref->path[j] == ':') dref->path[j] = '/'; av_log(c->fc, AV_LOG_DEBUG, "path %s\n", dref->path); } else url_fskip(pb, len); } } url_fseek(pb, next, SEEK_SET); } return 0; }
1threat
Which operation is more expensive?Order by or group by? : <p>Which operation is more expensive?Order by or group by?</p>
0debug
static inline void vc1_pred_mv_intfr(VC1Context *v, int n, int dmv_x, int dmv_y, int mvn, int r_x, int r_y, uint8_t* is_intra, int dir) { MpegEncContext *s = &v->s; int xy, wrap, off = 0; int A[2], B[2], C[2]; int px, py; int a_valid = 0, b_valid = 0, c_valid = 0; int field_a, field_b, field_c; int total_valid, num_samefield, num_oppfield; int pos_c, pos_b, n_adj; wrap = s->b8_stride; xy = s->block_index[n]; if (s->mb_intra) { s->mv[0][n][0] = s->current_picture.motion_val[0][xy][0] = 0; s->mv[0][n][1] = s->current_picture.motion_val[0][xy][1] = 0; s->current_picture.motion_val[1][xy][0] = 0; s->current_picture.motion_val[1][xy][1] = 0; if (mvn == 1) { s->current_picture.motion_val[0][xy + 1][0] = 0; s->current_picture.motion_val[0][xy + 1][1] = 0; s->current_picture.motion_val[0][xy + wrap][0] = 0; s->current_picture.motion_val[0][xy + wrap][1] = 0; s->current_picture.motion_val[0][xy + wrap + 1][0] = 0; s->current_picture.motion_val[0][xy + wrap + 1][1] = 0; v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0; s->current_picture.motion_val[1][xy + 1][0] = 0; s->current_picture.motion_val[1][xy + 1][1] = 0; s->current_picture.motion_val[1][xy + wrap][0] = 0; s->current_picture.motion_val[1][xy + wrap][1] = 0; s->current_picture.motion_val[1][xy + wrap + 1][0] = 0; s->current_picture.motion_val[1][xy + wrap + 1][1] = 0; } return; } off = ((n == 0) || (n == 1)) ? 1 : -1; if (s->mb_x || (n == 1) || (n == 3)) { if ((v->blk_mv_type[xy]) || (!v->blk_mv_type[xy] && !v->blk_mv_type[xy - 1])) { A[0] = s->current_picture.motion_val[dir][xy - 1][0]; A[1] = s->current_picture.motion_val[dir][xy - 1][1]; a_valid = 1; } else { A[0] = (s->current_picture.motion_val[dir][xy - 1][0] + s->current_picture.motion_val[dir][xy - 1 + off * wrap][0] + 1) >> 1; A[1] = (s->current_picture.motion_val[dir][xy - 1][1] + s->current_picture.motion_val[dir][xy - 1 + off * wrap][1] + 1) >> 1; a_valid = 1; } if (!(n & 1) && v->is_intra[s->mb_x - 1]) { a_valid = 0; A[0] = A[1] = 0; } } else A[0] = A[1] = 0; B[0] = B[1] = C[0] = C[1] = 0; if (n == 0 || n == 1 || v->blk_mv_type[xy]) { if (!s->first_slice_line) { if (!v->is_intra[s->mb_x - s->mb_stride]) { b_valid = 1; n_adj = n | 2; pos_b = s->block_index[n_adj] - 2 * wrap; if (v->blk_mv_type[pos_b] && v->blk_mv_type[xy]) { n_adj = (n & 2) | (n & 1); } B[0] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap][0]; B[1] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap][1]; if (v->blk_mv_type[pos_b] && !v->blk_mv_type[xy]) { B[0] = (B[0] + s->current_picture.motion_val[dir][s->block_index[n_adj ^ 2] - 2 * wrap][0] + 1) >> 1; B[1] = (B[1] + s->current_picture.motion_val[dir][s->block_index[n_adj ^ 2] - 2 * wrap][1] + 1) >> 1; } } if (s->mb_width > 1) { if (!v->is_intra[s->mb_x - s->mb_stride + 1]) { c_valid = 1; n_adj = 2; pos_c = s->block_index[2] - 2 * wrap + 2; if (v->blk_mv_type[pos_c] && v->blk_mv_type[xy]) { n_adj = n & 2; } C[0] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap + 2][0]; C[1] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap + 2][1]; if (v->blk_mv_type[pos_c] && !v->blk_mv_type[xy]) { C[0] = (1 + C[0] + (s->current_picture.motion_val[dir][s->block_index[n_adj ^ 2] - 2 * wrap + 2][0])) >> 1; C[1] = (1 + C[1] + (s->current_picture.motion_val[dir][s->block_index[n_adj ^ 2] - 2 * wrap + 2][1])) >> 1; } if (s->mb_x == s->mb_width - 1) { if (!v->is_intra[s->mb_x - s->mb_stride - 1]) { c_valid = 1; n_adj = 3; pos_c = s->block_index[3] - 2 * wrap - 2; if (v->blk_mv_type[pos_c] && v->blk_mv_type[xy]) { n_adj = n | 1; } C[0] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap - 2][0]; C[1] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap - 2][1]; if (v->blk_mv_type[pos_c] && !v->blk_mv_type[xy]) { C[0] = (1 + C[0] + s->current_picture.motion_val[dir][s->block_index[1] - 2 * wrap - 2][0]) >> 1; C[1] = (1 + C[1] + s->current_picture.motion_val[dir][s->block_index[1] - 2 * wrap - 2][1]) >> 1; } } else c_valid = 0; } } } } } else { pos_b = s->block_index[1]; b_valid = 1; B[0] = s->current_picture.motion_val[dir][pos_b][0]; B[1] = s->current_picture.motion_val[dir][pos_b][1]; pos_c = s->block_index[0]; c_valid = 1; C[0] = s->current_picture.motion_val[dir][pos_c][0]; C[1] = s->current_picture.motion_val[dir][pos_c][1]; } total_valid = a_valid + b_valid + c_valid; if (!s->mb_x && !(n == 1 || n == 3)) { A[0] = A[1] = 0; } if ((s->first_slice_line && v->blk_mv_type[xy]) || (s->first_slice_line && !(n & 2))) { B[0] = B[1] = C[0] = C[1] = 0; } if (!v->blk_mv_type[xy]) { if (s->mb_width == 1) { px = B[0]; py = B[1]; } else { if (total_valid >= 2) { px = mid_pred(A[0], B[0], C[0]); py = mid_pred(A[1], B[1], C[1]); } else if (total_valid) { if (a_valid) { px = A[0]; py = A[1]; } else if (b_valid) { px = B[0]; py = B[1]; } else if (c_valid) { px = C[0]; py = C[1]; } else av_assert2(0); } else px = py = 0; } } else { if (a_valid) field_a = (A[1] & 4) ? 1 : 0; else field_a = 0; if (b_valid) field_b = (B[1] & 4) ? 1 : 0; else field_b = 0; if (c_valid) field_c = (C[1] & 4) ? 1 : 0; else field_c = 0; num_oppfield = field_a + field_b + field_c; num_samefield = total_valid - num_oppfield; if (total_valid == 3) { if ((num_samefield == 3) || (num_oppfield == 3)) { px = mid_pred(A[0], B[0], C[0]); py = mid_pred(A[1], B[1], C[1]); } else if (num_samefield >= num_oppfield) { px = !field_a ? A[0] : B[0]; py = !field_a ? A[1] : B[1]; } else { px = field_a ? A[0] : B[0]; py = field_a ? A[1] : B[1]; } } else if (total_valid == 2) { if (num_samefield >= num_oppfield) { if (!field_a && a_valid) { px = A[0]; py = A[1]; } else if (!field_b && b_valid) { px = B[0]; py = B[1]; } else if (c_valid) { px = C[0]; py = C[1]; } else px = py = 0; } else { if (field_a && a_valid) { px = A[0]; py = A[1]; } else if (field_b && b_valid) { px = B[0]; py = B[1]; } else if (c_valid) { px = C[0]; py = C[1]; } else px = py = 0; } } else if (total_valid == 1) { px = (a_valid) ? A[0] : ((b_valid) ? B[0] : C[0]); py = (a_valid) ? A[1] : ((b_valid) ? B[1] : C[1]); } else px = py = 0; } s->mv[dir][n][0] = s->current_picture.motion_val[dir][xy][0] = ((px + dmv_x + r_x) & ((r_x << 1) - 1)) - r_x; s->mv[dir][n][1] = s->current_picture.motion_val[dir][xy][1] = ((py + dmv_y + r_y) & ((r_y << 1) - 1)) - r_y; if (mvn == 1) { s->current_picture.motion_val[dir][xy + 1 ][0] = s->current_picture.motion_val[dir][xy][0]; s->current_picture.motion_val[dir][xy + 1 ][1] = s->current_picture.motion_val[dir][xy][1]; s->current_picture.motion_val[dir][xy + wrap ][0] = s->current_picture.motion_val[dir][xy][0]; s->current_picture.motion_val[dir][xy + wrap ][1] = s->current_picture.motion_val[dir][xy][1]; s->current_picture.motion_val[dir][xy + wrap + 1][0] = s->current_picture.motion_val[dir][xy][0]; s->current_picture.motion_val[dir][xy + wrap + 1][1] = s->current_picture.motion_val[dir][xy][1]; } else if (mvn == 2) { s->current_picture.motion_val[dir][xy + 1][0] = s->current_picture.motion_val[dir][xy][0]; s->current_picture.motion_val[dir][xy + 1][1] = s->current_picture.motion_val[dir][xy][1]; s->mv[dir][n + 1][0] = s->mv[dir][n][0]; s->mv[dir][n + 1][1] = s->mv[dir][n][1]; } }
1threat
void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap) { BdrvDirtyBitmap *bm, *next; QLIST_FOREACH_SAFE(bm, &bs->dirty_bitmaps, list, next) { if (bm == bitmap) { assert(!bdrv_dirty_bitmap_frozen(bm)); QLIST_REMOVE(bitmap, list); hbitmap_free(bitmap->bitmap); g_free(bitmap->name); g_free(bitmap); return; } } }
1threat
how to fix my for code in java, not working : <p>Program that accepts integers and stores them in an array, and outputs the largest number of them. but following code is not working</p> <p>import java.util.Scanner;</p> <p>public class Test2 {</p> <pre><code>public static void main(String[] args){ System.out.print("input the array'size : "); Scanner sc = new Scanner(System.in); int size = sc.nextInt(); int arr[]=new int[size]; System.out.print("input the array'value :"); for(int i=0; i&lt;size; i++){ int var = sc.nextInt(); arr[i] = var; } System.out.print("inputed value: "); for(int i=0; i&lt;size; i++) { System.out.print(arr[i]+ " "); } int max = 0; for(int j=0; j&lt;size; j++){ if(max&lt;arr[j+1]){ max = arr[j]; } else { continue; } } System.out.println("the largest number in array :"+ max); } </code></pre> <p>}</p>
0debug
Owl Carousel 2 Nav on Sides : <p>Hi I'm using Owl Carousel version 2 and can't find an example to put the navigation on the sides of the carousel like right and left chevrons or arrows. How do you do it?</p>
0debug
static int get_phys_addr_v5(CPUARMState *env, uint32_t address, int access_type, int is_user, hwaddr *phys_ptr, int *prot, target_ulong *page_size) { CPUState *cs = CPU(arm_env_get_cpu(env)); int code; uint32_t table; uint32_t desc; int type; int ap; int domain = 0; int domain_prot; hwaddr phys_addr; if (!get_level1_table_address(env, &table, address)) { code = 5; goto do_fault; } desc = ldl_phys(cs->as, table); type = (desc & 3); domain = (desc >> 5) & 0x0f; domain_prot = (env->cp15.c3 >> (domain * 2)) & 3; if (type == 0) { code = 5; goto do_fault; } if (domain_prot == 0 || domain_prot == 2) { if (type == 2) code = 9; else code = 11; goto do_fault; } if (type == 2) { phys_addr = (desc & 0xfff00000) | (address & 0x000fffff); ap = (desc >> 10) & 3; code = 13; *page_size = 1024 * 1024; } else { if (type == 1) { table = (desc & 0xfffffc00) | ((address >> 10) & 0x3fc); } else { table = (desc & 0xfffff000) | ((address >> 8) & 0xffc); } desc = ldl_phys(cs->as, table); switch (desc & 3) { case 0: code = 7; goto do_fault; case 1: phys_addr = (desc & 0xffff0000) | (address & 0xffff); ap = (desc >> (4 + ((address >> 13) & 6))) & 3; *page_size = 0x10000; break; case 2: phys_addr = (desc & 0xfffff000) | (address & 0xfff); ap = (desc >> (4 + ((address >> 9) & 6))) & 3; *page_size = 0x1000; break; case 3: if (type == 1) { if (arm_feature(env, ARM_FEATURE_XSCALE)) { phys_addr = (desc & 0xfffff000) | (address & 0xfff); } else { code = 7; goto do_fault; } } else { phys_addr = (desc & 0xfffffc00) | (address & 0x3ff); } ap = (desc >> 4) & 3; *page_size = 0x400; break; default: abort(); } code = 15; } *prot = check_ap(env, ap, domain_prot, access_type, is_user); if (!*prot) { goto do_fault; } *prot |= PAGE_EXEC; *phys_ptr = phys_addr; return 0; do_fault: return code | (domain << 4); }
1threat
uint16_t acpi_pm1_evt_get_sts(ACPIREGS *ar, int64_t overflow_time) { int64_t d = acpi_pm_tmr_get_clock(); if (d >= overflow_time) { ar->pm1.evt.sts |= ACPI_BITMASK_TIMER_STATUS; } return ar->pm1.evt.sts; }
1threat
Best software to view OLAP Cube : <p>I connected to an analysis server using (32-bit) Ms Excel, but it crashed since the amount of data was big. Then I used SQL Server Management Studio, even that did not worked for me since it seems like SSMS is an administrator tool and you need to have administrator rights for the DB you like to view (Which I do not and cannot have). Please suggest me a software that can allow me to work with the large amount of data (without crashing) coming from an OLAP server?</p>
0debug
Use ViewChild for dynamic elements - Angular 2 & ionic 2 : <p>I want use multiple <a href="https://ionicframework.com/docs/api/components/slides/Slides/" rel="noreferrer">IonicSlides</a> that I added thease dynamically, So I can't use viewChild . please suggest a way for this problem. </p> <p><strong>Template.html :</strong> </p> <pre><code>&lt;div *ngFor="let name of title;let i = index;"&gt; &lt;ion-slides id="something" #slides &gt; //some code &lt;/ion-slides&gt; &lt;/div </code></pre> <p><strong>Component.ts :</strong></p> <pre><code> @ViewChild('slides') slides: QueryList&lt;Slides&gt;; .... ngAfterViewInit(){ setTimeout( ()=&gt;{ alert(this.slides.toArray()); //this line rise error },3000); } </code></pre> <p><strong>Error :</strong> </p> <blockquote> <p>_this.slides.toArray is not a function</p> </blockquote>
0debug
How to mock generators with mock.patch : <p>I have gone through the page <a href="https://docs.python.org/3/library/unittest.mock-examples.html" rel="noreferrer">https://docs.python.org/3/library/unittest.mock-examples.html</a> and i see that they have listed an example on how to mock generators</p> <p>I have a code where i call a generator to give me a set of values that i save as a dictionary. I want to mock the calls to this generator in my unit test.</p> <p>I have written the following code and it does not work. </p> <p>Where am i going wrong?</p> <pre><code>In [7]: items = [(1,'a'),(2,'a'),(3,'a')] In [18]: def f(): print "here" for i in [1,2,3]: yield i,'a' In [8]: def call_f(): ...: my_dict = dict(f()) ...: print my_dict[1] ...: In [9]: call_f() "here" a In [10]: import mock In [18]: def test_call_f(): with mock.patch('__main__.f') as mock_f: mock_f.iter.return_value = items call_f() ....: In [19]: test_call_f() --------------------------------------------------------------------------- KeyError Traceback (most recent call last) &lt;ipython-input-19-33ca65a4f3eb&gt; in &lt;module&gt;() ----&gt; 1 test_call_f() &lt;ipython-input-18-92ff5f1363c8&gt; in test_call_f() 2 with mock.patch('__main__.f') as mock_f: 3 mock_f.iter.return_value = items ----&gt; 4 call_f() &lt;ipython-input-8-a5cff08ebf69&gt; in call_f() 1 def call_f(): 2 my_dict = dict(f()) ----&gt; 3 print my_dict[1] KeyError: 1 </code></pre>
0debug
display hidden form when specific number of integers/characters are entered into a text field : <p>I am trying to create a function where when a specific number of integers (eg. a phone number) are entered into a text field, a hidden form is displayed and both initial text field and form re-positioned. </p> <p>Any examples available on how this can be accomplished?</p> <p>Thanks</p>
0debug
In JavaScript, is constructor mandatory in a class? : <p>I am reading about JavaScript class from the <a href="https://developer.mozilla.org/my/docs/Web/JavaScript/Reference/Classes#Class_body_and_method_definitions" rel="noreferrer">Mozilla documentation section of 'Class body and method definitions'</a>. Under the Constructor section, it states that </p> <blockquote> <p>The constructor method is a special method for creating and initializing an object created with a class. There can only be one special method with the name "constructor" in a class. A SyntaxError will be thrown if the class contains more than one occurrence of a constructor method. A constructor can use the super keyword to call the constructor of the super class.</p> </blockquote> <p>From the statement above, I can confirm that we can't have more than one constructor. But it does not mention whether a constructor is mandatory in a class declaration/expression in JavaScript.</p>
0debug
static void sbr_gain_calc(AACContext *ac, SpectralBandReplication *sbr, SBRData *ch_data, const int e_a[2]) { int e, k, m; static const SoftFloat limgain[4] = { { 760155524, 0 }, { 0x20000000, 1 }, { 758351638, 1 }, { 625000000, 34 } }; for (e = 0; e < ch_data->bs_num_env; e++) { int delta = !((e == e_a[1]) || (e == e_a[0])); for (k = 0; k < sbr->n_lim; k++) { SoftFloat gain_boost, gain_max; SoftFloat sum[2]; sum[0] = sum[1] = FLOAT_0; for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { const SoftFloat temp = av_div_sf(sbr->e_origmapped[e][m], av_add_sf(FLOAT_1, sbr->q_mapped[e][m])); sbr->q_m[e][m] = av_sqrt_sf(av_mul_sf(temp, sbr->q_mapped[e][m])); sbr->s_m[e][m] = av_sqrt_sf(av_mul_sf(temp, av_int2sf(ch_data->s_indexmapped[e + 1][m], 0))); if (!sbr->s_mapped[e][m]) { if (delta) { sbr->gain[e][m] = av_sqrt_sf(av_div_sf(sbr->e_origmapped[e][m], av_mul_sf(av_add_sf(FLOAT_1, sbr->e_curr[e][m]), av_add_sf(FLOAT_1, sbr->q_mapped[e][m])))); } else { sbr->gain[e][m] = av_sqrt_sf(av_div_sf(sbr->e_origmapped[e][m], av_add_sf(FLOAT_1, sbr->e_curr[e][m]))); } } else { sbr->gain[e][m] = av_sqrt_sf( av_div_sf( av_mul_sf(sbr->e_origmapped[e][m], sbr->q_mapped[e][m]), av_mul_sf( av_add_sf(FLOAT_1, sbr->e_curr[e][m]), av_add_sf(FLOAT_1, sbr->q_mapped[e][m])))); } } for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { sum[0] = av_add_sf(sum[0], sbr->e_origmapped[e][m]); sum[1] = av_add_sf(sum[1], sbr->e_curr[e][m]); } gain_max = av_mul_sf(limgain[sbr->bs_limiter_gains], av_sqrt_sf( av_div_sf( av_add_sf(FLOAT_EPSILON, sum[0]), av_add_sf(FLOAT_EPSILON, sum[1])))); if (av_gt_sf(gain_max, FLOAT_100000)) gain_max = FLOAT_100000; for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { SoftFloat q_m_max = av_div_sf( av_mul_sf(sbr->q_m[e][m], gain_max), sbr->gain[e][m]); if (av_gt_sf(sbr->q_m[e][m], q_m_max)) sbr->q_m[e][m] = q_m_max; if (av_gt_sf(sbr->gain[e][m], gain_max)) sbr->gain[e][m] = gain_max; } sum[0] = sum[1] = FLOAT_0; for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { sum[0] = av_add_sf(sum[0], sbr->e_origmapped[e][m]); sum[1] = av_add_sf(sum[1], av_mul_sf( av_mul_sf(sbr->e_curr[e][m], sbr->gain[e][m]), sbr->gain[e][m])); sum[1] = av_add_sf(sum[1], av_mul_sf(sbr->s_m[e][m], sbr->s_m[e][m])); if (delta && !sbr->s_m[e][m].mant) sum[1] = av_add_sf(sum[1], av_mul_sf(sbr->q_m[e][m], sbr->q_m[e][m])); } gain_boost = av_sqrt_sf( av_div_sf( av_add_sf(FLOAT_EPSILON, sum[0]), av_add_sf(FLOAT_EPSILON, sum[1]))); if (av_gt_sf(gain_boost, FLOAT_1584893192)) gain_boost = FLOAT_1584893192; for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { sbr->gain[e][m] = av_mul_sf(sbr->gain[e][m], gain_boost); sbr->q_m[e][m] = av_mul_sf(sbr->q_m[e][m], gain_boost); sbr->s_m[e][m] = av_mul_sf(sbr->s_m[e][m], gain_boost); } } } }
1threat
How to document attributes in Kotlin data class? : <p>Where shall I put Javadoc for attributes in Kotlin data class?</p> <p>In other words, how to write in Kotlin the following Java code:</p> <pre class="lang-java prettyprint-override"><code>/** * Represents a person. */ public class Person { /** * First name. -- where to place this documentation in Kotlin? */ private final String firstName; /** * Last name. -- where to place this documentation in Kotlin? */ private final String lastName; // a lot of boilerplate Java code - getters, equals, hashCode, ... } </code></pre> <p>In Kotlin it looks like this:</p> <pre class="lang-kotlin prettyprint-override"><code>/** * Represents a person. */ data class Person(val firstName: String, val lastName: String) </code></pre> <p>but where to put the attributes' documentation?</p>
0debug
Get user input from command prompt in Java? : <p>I am fairly new to programming and I am stuck with a problem.</p> <p>I want to write a small calculator program that does nothing more than reading to numbers from the command prompt and adds them together.</p> <p>My problem now is, how do I get the numbers typed by the users?</p> <p>Thank you :)</p>
0debug
Two same strings aren't equal : <p>I have 2 equal strings, and when I'm doing a console.log() to know if they are equal, I do this:</p> <pre><code>console.log("message = " + document.getElementsByClassName("hud-chat-message")[i].childNodes[0].innerHTML + " type = " + typeof document.getElementsByClassName("hud-chat-message")[i].childNodes[0].innerHTML) console.log("chatbotname = " + Ultimate.bots[name].chatBotName + " type = " + typeof Ultimate.bots[name].chatBotName) console.log(document.getElementsByClassName("hud-chat-message")[i].childNodes[0].innerHTML == Ultimate.bots[name].chatBotName) </code></pre> <p>And then it says that:</p> <pre><code>message = &lt;strong&gt;Leaderboard on Discord&lt;/strong&gt;&lt;small&gt; (leaderboard!)&lt;/small&gt;&lt;span class="botTagRegular botTag bot"&gt;BOT&lt;/span&gt; type = string VM3681:229 chatbotname = &lt;strong&gt;Leaderboard on Discord&lt;/strong&gt;&lt;small&gt; (leaderboard!)&lt;/small&gt;&lt;span class='botTagRegular botTag bot'&gt;BOT&lt;/span&gt; type = string VM3681:230 false </code></pre> <p>Two strings are of the same type and are equals, but it says <code>false</code>, its not equal... Why? What's wrong? Thanks</p>
0debug
static av_cold int dilate_init(AVFilterContext *ctx, const char *args) { OCVContext *ocv = ctx->priv; DilateContext *dilate = ocv->priv; char default_kernel_str[] = "3x3+0x0/rect"; char *kernel_str; const char *buf = args; int ret; dilate->nb_iterations = 1; if (args) kernel_str = av_get_token(&buf, "|"); if ((ret = parse_iplconvkernel(&dilate->kernel, *kernel_str ? kernel_str : default_kernel_str, ctx)) < 0) return ret; av_free(kernel_str); sscanf(buf, "|%d", &dilate->nb_iterations); av_log(ctx, AV_LOG_VERBOSE, "iterations_nb:%d\n", dilate->nb_iterations); if (dilate->nb_iterations <= 0) { av_log(ctx, AV_LOG_ERROR, "Invalid non-positive value '%d' for nb_iterations\n", dilate->nb_iterations); return AVERROR(EINVAL); } return 0; }
1threat
Facebook Objective C to Swift 4 : <p>I am trying to implement facebook login using Swift 4</p> <p>Facebook docs covers how to implement the facebook login button for the view controller but it does not cover how to set up the Appdelegate using swift </p> <p>Can someone please convert this Objective C code to Swift </p> <p>Or place a URL Link to docs that would help me convert it myself</p> <pre><code>// AppDelegate.m #import &lt;FBSDKCoreKit/FBSDKCoreKit.h&gt; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions]; // Add any custom logic here. return YES; } - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary&lt;UIApplicationOpenURLOptionsKey,id&gt; *)options { BOOL handled = [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey] annotation:options[UIApplicationOpenURLOptionsAnnotationKey] ]; // Add any custom logic here. return handled; } </code></pre>
0debug
Can someone explain why a value gets incremented when "++" is used for comparison? : <p>This may already be a question out there, but with the lack of specific key terms, it's a bit hard to search for. Just looking for more insight on this topic.</p> <p>Right now, I'm working in C++ and wondering why my value is replaced with an incremented value when I compare using "++". </p> <p>So here, we print 14 times (numbers 1-14).</p> <pre><code>int i = 0, x = 0; while (x &lt; 30) { x++; if (13 &lt; i++) break; cout &lt;&lt; i &lt;&lt; endl; } </code></pre> <p>Here, we print 30 zeros.</p> <pre><code>int i = 0, x = 0; while (x &lt; 30) { x++; if (13 &lt; i+1) break; cout &lt;&lt; i &lt;&lt; endl; } </code></pre> <p>And this just plain doesn't work. (I wanted to try because <code>i++</code> = <code>i=i+1</code>).</p> <pre><code>int i = 0, x = 0; while (x &lt; 30) { x++; if (13 &lt; i=i+1) break; cout &lt;&lt; i &lt;&lt; endl; } </code></pre>
0debug
Steps to get hosted reatjs website? : I'm creating a reactjs web application project with create-react-app. Now it's all most ready. I did little research about how to get hostname and all. I found that https://www.netlify.com/ from this website I can able to host my website. Can anyone suggest which file I required to provide them. Like main index.js or what? Or I need to upload my whole project folder?? And what are the steps for it! Like FTP configuration and all.
0debug
JavaScript split string with .match(regex) : <p>From the Mozilla Developer Network for function <code>split()</code>:</p> <blockquote> <p>The split() method returns the new array.</p> <p>When found, separator is removed from the string and the substrings are returned in an array. If separator is not found or is omitted, the array contains one element consisting of the entire string. If separator is an empty string, str is converted to an array of characters.</p> <p>If separator is a regular expression that contains capturing parentheses, then each time separator is matched, the results (including any undefined results) of the capturing parentheses are spliced into the output array. However, not all browsers support this capability.</p> </blockquote> <p>Take the following example:</p> <pre><code>var string1 = 'one, two, three, four'; var splitString1 = string1.split(', '); console.log(splitString1); // Outputs ["one", "two", "three", "four"] </code></pre> <p>This is a really clean approach. I tried the same with a regular expression and a somewhat different string:</p> <pre><code>var string2 = 'one split two split three split four'; var splitString2 = string2.split(/\ split\ /); console.log(splitString2); // Outputs ["one", "two", "three", "four"] </code></pre> <p>This works just as well as the first example. In the following example, I have altered the string once more, with 3 different delimiters:</p> <pre><code>var string3 = 'one split two splat three splot four'; var splitString3 = string3.split(/\ split\ |\ splat\ |\ splot\ /); console.log(splitString3); // Outputs ["one", "two", "three", "four"] </code></pre> <p>However, the regular expression gets relatively messy right now. I can group the different delimiters, however the result will then include these delimiters:</p> <pre><code>var string4 = 'one split two splat three splot four'; var splitString4 = string4.split(/\ (split|splat|splot)\ /); console.log(splitString4); // Outputs ["one", "split", "two", "splat", "three", "splot", "four"] </code></pre> <p>So I tried removing the spaces from the regular expression while leaving the group, without much avail:</p> <pre><code>var string5 = 'one split two splat three splot four'; var splitString5 = string5.split(/(split|splat|splot)/); console.log(splitString5); </code></pre> <p>Although, when I remove the parentheses in the regular expression, the delimiter is gone in the split string:</p> <pre><code>var string6 = 'one split two splat three splot four'; var splitString6 = string6.split(/split|splat|splot/); console.log(splitString6); // Outputs ["one ", " two ", " three ", " four"] </code></pre> <p>An alternative would be to use <code>match()</code> to filter out the delimiters, except I don't really understand how reverse lookaheads work:</p> <pre><code>var string7 = 'one split two split three split four'; var splitString7 = string7.match(/((?!split).)*/g); console.log(splitString7); // Outputs ["one ", "", "plit two ", "", "plit three ", "", "plit four", ""] </code></pre> <p>It doesn't match the whole word to begin with. And to be honest, I don't even know what's going on here exactly.</p> <hr> <p>How do I properly split a string using regular expressions without having the delimiter in my result?</p>
0debug
void bdrv_info(void) { BlockDriverState *bs; for (bs = bdrv_first; bs != NULL; bs = bs->next) { term_printf("%s:", bs->device_name); term_printf(" type="); switch(bs->type) { case BDRV_TYPE_HD: term_printf("hd"); break; case BDRV_TYPE_CDROM: term_printf("cdrom"); break; case BDRV_TYPE_FLOPPY: term_printf("floppy"); break; } term_printf(" removable=%d", bs->removable); if (bs->removable) { term_printf(" locked=%d", bs->locked); } if (bs->drv) { term_printf(" file="); term_print_filename(bs->filename); if (bs->backing_file[0] != '\0') { term_printf(" backing_file="); term_print_filename(bs->backing_file); } term_printf(" ro=%d", bs->read_only); term_printf(" drv=%s", bs->drv->format_name); if (bs->encrypted) term_printf(" encrypted"); } else { term_printf(" [not inserted]"); } term_printf("\n"); } }
1threat
static int hls_append_segment(struct AVFormatContext *s, HLSContext *hls, double duration, int64_t pos, int64_t size) { HLSSegment *en = av_malloc(sizeof(*en)); const char *filename; int ret; if (!en) return AVERROR(ENOMEM); if ((hls->flags & (HLS_SECOND_LEVEL_SEGMENT_SIZE | HLS_SECOND_LEVEL_SEGMENT_DURATION)) && strlen(hls->current_segment_final_filename_fmt)) { char * old_filename = av_strdup(hls->avf->filename); av_strlcpy(hls->avf->filename, hls->current_segment_final_filename_fmt, sizeof(hls->avf->filename)); if (hls->flags & HLS_SECOND_LEVEL_SEGMENT_SIZE) { char * filename = av_strdup(hls->avf->filename); if (!filename) return AVERROR(ENOMEM); if (replace_int_data_in_filename(hls->avf->filename, sizeof(hls->avf->filename), filename, 's', pos + size) < 1) { av_log(hls, AV_LOG_ERROR, "Invalid second level segment filename template '%s', " "you can try to remove second_level_segment_size flag\n", filename); av_free(filename); av_free(old_filename); return AVERROR(EINVAL); } av_free(filename); } if (hls->flags & HLS_SECOND_LEVEL_SEGMENT_DURATION) { char * filename = av_strdup(hls->avf->filename); if (!filename) return AVERROR(ENOMEM); if (replace_int_data_in_filename(hls->avf->filename, sizeof(hls->avf->filename), filename, 't', (int64_t)round(1000000 * duration)) < 1) { av_log(hls, AV_LOG_ERROR, "Invalid second level segment filename template '%s', " "you can try to remove second_level_segment_time flag\n", filename); av_free(filename); av_free(old_filename); return AVERROR(EINVAL); } av_free(filename); } ff_rename(old_filename, hls->avf->filename, hls); av_free(old_filename); } filename = av_basename(hls->avf->filename); if (hls->use_localtime_mkdir) { filename = hls->avf->filename; } if (find_segment_by_filename(hls->segments, filename) || find_segment_by_filename(hls->old_segments, filename)) { av_log(hls, AV_LOG_WARNING, "Duplicated segment filename detected: %s\n", filename); } av_strlcpy(en->filename, filename, sizeof(en->filename)); if(hls->has_subtitle) av_strlcpy(en->sub_filename, av_basename(hls->vtt_avf->filename), sizeof(en->sub_filename)); else en->sub_filename[0] = '\0'; en->duration = duration; en->pos = pos; en->size = size; en->next = NULL; en->discont = 0; if (hls->discontinuity) { en->discont = 1; hls->discontinuity = 0; } if (hls->key_info_file) { av_strlcpy(en->key_uri, hls->key_uri, sizeof(en->key_uri)); av_strlcpy(en->iv_string, hls->iv_string, sizeof(en->iv_string)); } if (!hls->segments) hls->segments = en; else hls->last_segment->next = en; hls->last_segment = en; if (hls->pl_type != PLAYLIST_TYPE_NONE) hls->max_nb_segments = 0; if (hls->max_nb_segments && hls->nb_entries >= hls->max_nb_segments) { en = hls->segments; hls->initial_prog_date_time += en->duration; hls->segments = en->next; if (en && hls->flags & HLS_DELETE_SEGMENTS && !(hls->flags & HLS_SINGLE_FILE || hls->wrap)) { en->next = hls->old_segments; hls->old_segments = en; if ((ret = hls_delete_old_segments(hls)) < 0) return ret; } else av_free(en); } else hls->nb_entries++; if (hls->max_seg_size > 0) { return 0; } hls->sequence++; return 0; }
1threat
Parsing a line from file : <p>I have a file with the following line:</p> <pre><code> numOfItems = 100 </code></pre> <p>I want to read the line from file and initialize the attribute "numOfItems" to 100. How could I do it, i.e, deleting the unnecessary spaces and read only the values I need?</p> <p>Also, I have another line which is:</p> <pre><code>num Of Items = 100 </code></pre> <p>which I need to parse as error (attributes and values cannot contain spaces).</p> <p>In the first case I know how to remove the spaces at the beginning, but not the intervening spaces. In second case I don't know what to do.</p> <p>I thought to use <code>strtok</code>, but couldn't manage to get what I needed.</p> <p>Please help, thanks!</p>
0debug