problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
void ff_put_h264_qpel16_mc11_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_hv_qrt_16w_msa(src - 2,
src - (stride * 2), stride, dst, stride, 16);
}
| 1threat
|
PHP file uploading but can't find in directory : <p>I've checked several methods on stackoverflow but none is able to solve this.
I've made an html form to input <strong>file</strong> type through <strong>SELF_PHP</strong> form.
<em>Seems like PHP is uploading the file correctly but the directory to which it's being uploaded is empty</em> . Here's the code:
<strong>HTML</strong></p>
<pre><code><form method="post" id="fileUpForm" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" enctype="multipart/form-data" >
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload" name="submit">
</form>
</code></pre>
<p><strong>PHP</strong></p>
<pre><code><?php
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;
}
}
?>
</code></pre>
<p>Additional Info: .php file directory - <code>/var/www/html/FileUp.php</code><br>
uploads directory(to store files) - <code>/var/www/html/uploads/</code>
Code used(modified) from : '*schools.com'</p>
| 0debug
|
How to check Internet connection on a Cordova App? : <p>I tried some suggestions, such as <strong>navigator.onLine</strong>, but even in flight mode, my app "thinks" its online.</p>
<p>I found some suggestions with ajax too, but I just want to check if I'm online to open an external web page. If not, I intend to show a message such as "Your device seems to be offline. Check your connection!".</p>
| 0debug
|
React Native 0.57.1 Android Duplicate Resources : <p>When running <code>./android/gradlew assembleRelease</code> I get the following error:</p>
<p>```
* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.</p>
<blockquote>
<p>[drawable-xhdpi-v4/node_modules_reactnavigation_src_views_assets_backicon] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-xhdpi/node_modules_reactnavigation_src_views_assets_backicon.png [drawable-xhdpi-v4/node_modules_reactnavigation_src_views_assets_backicon] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-xhdpi/node_modules_reactnavigation_src_views_assets_backicon.png: Error: Duplicate resources
[drawable-xxhdpi-v4/node_modules_reactnavigation_src_views_assets_backicon] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-xxhdpi/node_modules_reactnavigation_src_views_assets_backicon.png [drawable-xxhdpi-v4/node_modules_reactnavigation_src_views_assets_backicon] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-xxhdpi/node_modules_reactnavigation_src_views_assets_backicon.png: Error: Duplicate resources
[drawable-hdpi-v4/node_modules_reactnavigation_src_views_assets_backicon] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-hdpi/node_modules_reactnavigation_src_views_assets_backicon.png [drawable-hdpi-v4/node_modules_reactnavigation_src_views_assets_backicon] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-hdpi/node_modules_reactnavigation_src_views_assets_backicon.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_marilyn_monroe_trophies_cookoo30x] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_marilyn_monroe_trophies_cookoo30x.png [drawable-mdpi-v4/app_assets_images_characters_marilyn_monroe_trophies_cookoo30x] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_marilyn_monroe_trophies_cookoo30x.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_cleopatra_emotions_blinking_5] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_cleopatra_emotions_blinking_5.png [drawable-mdpi-v4/app_assets_images_characters_cleopatra_emotions_blinking_5] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_cleopatra_emotions_blinking_5.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_coins_5] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_coins_5.png [drawable-mdpi-v4/app_assets_images_coins_5] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_coins_5.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_marilyn_monroe_emotions_blinking_2] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_marilyn_monroe_emotions_blinking_2.png [drawable-mdpi-v4/app_assets_images_characters_marilyn_monroe_emotions_blinking_2] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_marilyn_monroe_emotions_blinking_2.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_leonardo_da_vinci_emotions_angry_4] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_leonardo_da_vinci_emotions_angry_4.png [drawable-mdpi-v4/app_assets_images_characters_leonardo_da_vinci_emotions_angry_4] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_leonardo_da_vinci_emotions_angry_4.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_leonardo_da_vinci_emotions_happy_2] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_leonardo_da_vinci_emotions_happy_2.png [drawable-mdpi-v4/app_assets_images_characters_leonardo_da_vinci_emotions_happy_2] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_leonardo_da_vinci_emotions_happy_2.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_unlockablecharacters] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_unlockablecharacters.png [drawable-mdpi-v4/app_assets_images_unlockablecharacters] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_unlockablecharacters.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_cleopatra_emotions_happy_6] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_cleopatra_emotions_happy_6.png [drawable-mdpi-v4/app_assets_images_characters_cleopatra_emotions_happy_6] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_cleopatra_emotions_happy_6.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_marilyn_monroe_trophies_cookoo3x] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_marilyn_monroe_trophies_cookoo3x.png [drawable-mdpi-v4/app_assets_images_characters_marilyn_monroe_trophies_cookoo3x] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_marilyn_monroe_trophies_cookoo3x.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_leonardo_da_vinci_emotions_happy_3] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_leonardo_da_vinci_emotions_happy_3.png [drawable-mdpi-v4/app_assets_images_characters_leonardo_da_vinci_emotions_happy_3] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_leonardo_da_vinci_emotions_happy_3.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_leonardo_da_vinci_emotions_angry_5] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_leonardo_da_vinci_emotions_angry_5.png [drawable-mdpi-v4/app_assets_images_characters_leonardo_da_vinci_emotions_angry_5] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_leonardo_da_vinci_emotions_angry_5.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_marilyn_monroe_emotions_blinking_3] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_marilyn_monroe_emotions_blinking_3.png [drawable-mdpi-v4/app_assets_images_characters_marilyn_monroe_emotions_blinking_3] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_marilyn_monroe_emotions_blinking_3.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_coinsmodal_mostpopularlabel] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_coinsmodal_mostpopularlabel.png [drawable-mdpi-v4/app_assets_images_coinsmodal_mostpopularlabel] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_coinsmodal_mostpopularlabel.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_cleopatra_emotions_blinking_4] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_cleopatra_emotions_blinking_4.png [drawable-mdpi-v4/app_assets_images_characters_cleopatra_emotions_blinking_4] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_cleopatra_emotions_blinking_4.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_coins_4] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_coins_4.png [drawable-mdpi-v4/app_assets_images_coins_4] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_coins_4.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_napoleon_trophies_cookoo30x] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_napoleon_trophies_cookoo30x.png [drawable-mdpi-v4/app_assets_images_characters_napoleon_trophies_cookoo30x] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_napoleon_trophies_cookoo30x.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_earthbg] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_earthbg.png [drawable-mdpi-v4/app_assets_images_earthbg] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_earthbg.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_einee_emotions_happy_6] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_einee_emotions_happy_6.png [drawable-mdpi-v4/app_assets_images_characters_einee_emotions_happy_6] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_einee_emotions_happy_6.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_einee_trophies_angry10x] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_einee_trophies_angry10x.png [drawable-mdpi-v4/app_assets_images_characters_einee_trophies_angry10x] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_einee_trophies_angry10x.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_leonardo_da_vinci_trophies_3conversations] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_leonardo_da_vinci_trophies_3conversations.png [drawable-mdpi-v4/app_assets_images_characters_leonardo_da_vinci_trophies_3conversations] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_leonardo_da_vinci_trophies_3conversations.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_napoleon_trophies_cookoo10x] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_napoleon_trophies_cookoo10x.png [drawable-mdpi-v4/app_assets_images_characters_napoleon_trophies_cookoo10x] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_napoleon_trophies_cookoo10x.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_einee_emotions_angry_2] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_einee_emotions_angry_2.png [drawable-mdpi-v4/app_assets_images_characters_einee_emotions_angry_2] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_einee_emotions_angry_2.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_napoleon_profile] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_napoleon_profile.png [drawable-mdpi-v4/app_assets_images_characters_napoleon_profile] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_napoleon_profile.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_einee_emotions_happy_4] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_einee_emotions_happy_4.png [drawable-mdpi-v4/app_assets_images_characters_einee_emotions_happy_4] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_einee_emotions_happy_4.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_einee_trophies_angry30x] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_einee_trophies_angry30x.png [drawable-mdpi-v4/app_assets_images_characters_einee_trophies_angry30x] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_einee_trophies_angry30x.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_coins_6] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_coins_6.png [drawable-mdpi-v4/app_assets_images_coins_6] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_coins_6.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_cleopatra_emotions_blinking_6] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_cleopatra_emotions_blinking_6.png [drawable-mdpi-v4/app_assets_images_characters_cleopatra_emotions_blinking_6] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_cleopatra_emotions_blinking_6.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_einee_bg] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_einee_bg.jpg [drawable-mdpi-v4/app_assets_images_characters_einee_bg] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_einee_bg.jpg: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_cleopatra_emotions_cookoo_2] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_cleopatra_emotions_cookoo_2.png [drawable-mdpi-v4/app_assets_images_characters_cleopatra_emotions_cookoo_2] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_cleopatra_emotions_cookoo_2.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_leonardo_da_vinci_emotions_blinking_3] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_leonardo_da_vinci_emotions_blinking_3.png [drawable-mdpi-v4/app_assets_images_characters_leonardo_da_vinci_emotions_blinking_3] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_leonardo_da_vinci_emotions_blinking_3.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_cleopatra_emotions_happy_4] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_cleopatra_emotions_happy_4.png [drawable-mdpi-v4/app_assets_images_characters_cleopatra_emotions_happy_4] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_cleopatra_emotions_happy_4.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_cleopatra_emotions_angry_2] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_cleopatra_emotions_angry_2.png [drawable-mdpi-v4/app_assets_images_characters_cleopatra_emotions_angry_2] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_cleopatra_emotions_angry_2.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_leonardo_da_vinci_trophies_allconversations1x] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_leonardo_da_vinci_trophies_allconversations1x.png [drawable-mdpi-v4/app_assets_images_characters_leonardo_da_vinci_trophies_allconversations1x] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_leonardo_da_vinci_trophies_allconversations1x.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_coinsmodal_coins500] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_coinsmodal_coins500.png [drawable-mdpi-v4/app_assets_images_coinsmodal_coins500] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_coinsmodal_coins500.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_cleopatra_emotions_angry_3] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_cleopatra_emotions_angry_3.png [drawable-mdpi-v4/app_assets_images_characters_cleopatra_emotions_angry_3] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_cleopatra_emotions_angry_3.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_cleopatra_emotions_happy_5] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_cleopatra_emotions_happy_5.png [drawable-mdpi-v4/app_assets_images_characters_cleopatra_emotions_happy_5] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_cleopatra_emotions_happy_5.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_leonardo_da_vinci_emotions_blinking_2] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_leonardo_da_vinci_emotions_blinking_2.png [drawable-mdpi-v4/app_assets_images_characters_leonardo_da_vinci_emotions_blinking_2] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_leonardo_da_vinci_emotions_blinking_2.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_cleopatra_emotions_cookoo_3] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_cleopatra_emotions_cookoo_3.png [drawable-mdpi-v4/app_assets_images_characters_cleopatra_emotions_cookoo_3] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_cleopatra_emotions_cookoo_3.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_einee_trophies_angry100x] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_einee_trophies_angry100x.png [drawable-mdpi-v4/app_assets_images_characters_einee_trophies_angry100x] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_einee_trophies_angry100x.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_donald_trump_bg] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_donald_trump_bg.jpg [drawable-mdpi-v4/app_assets_images_characters_donald_trump_bg] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_donald_trump_bg.jpg: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_cleopatra_trophies_allconversations3x] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_cleopatra_trophies_allconversations3x.png [drawable-mdpi-v4/app_assets_images_characters_cleopatra_trophies_allconversations3x] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_cleopatra_trophies_allconversations3x.png: Error: Duplicate resources
[drawable-mdpi-v4/app_assets_images_characters_leonardo_da_vinci_emotions_angry_6] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/src/main/res/drawable-mdpi/app_assets_images_characters_leonardo_da_vinci_emotions_angry_6.png [drawable-mdpi-v4/app_assets_images_characters_leonardo_da_vinci_emotions_angry_6] /Users/Ilyakar/Documents/Business/Development/My_Projects/new/Einee/App/android/app/build/generated/res/react/release/drawable-mdpi/app_assets_images_characters_leonardo_da_vinci_emotions_angry_6.png: Error: Duplicate resources
```</p>
</blockquote>
<p>I already tried the following from the answers I found on <a href="https://stackoverflow.com/questions/52464842/react-native-duplicate-resources">React Native Duplicate resources</a> with zero success:</p>
<p><strong>Attempt #1:</strong></p>
<p>"Deleting the drawables with rm -rf android/app/src/main/res/drawable-* and generating APK on Android Studio worked for me."</p>
<p><strong>Attempt #2:</strong></p>
<p>"rm -rf android/app/src/main/res/drawable-*</p>
<p>react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/</p>
<p>And compile android again react-native run-android"</p>
<hr>
<p>Any other ideas?</p>
| 0debug
|
$.ajax POST not working but GET works fine : <p>Been on this for a while now. The codes below works perfectly when " type: 'POST' " is changed to " type: 'GET' ". Any help why its not working for POST?</p>
<pre><code> $.ajax({
type: 'POST',
url: 'http://www.example.com/ajax/test.php',
data: { name: "Overcomer", email : "info@overcomer.we"},
cache: false,
dataType: "html",
beforeSend: function() { console.log('firing ajax'); },
success: function (response) {
console.log('success');
},
error: function (xhr, ajaxOptions, thrownError) {
console.log("ERROR:" + xhr.responseText+" - "+thrownError);
}
});
</code></pre>
| 0debug
|
Debugger popup message "Getting DataTip text" : <p>This Debugger message pops up randomly while i am attempting to examine a variable while a breakpoint has hit in Visual Studio 2017.</p>
<p>Shortly thereafter, a larger message box appears that shows the following: "Evaluating the function 'System.Reflection.Assembly.LoadForm' timed out."</p>
<p>After enabling option <strong>Tools / Options / Debugging / General / Only managed code</strong>, the second message box have disappeared. But first message is still showing. </p>
<p>The problem is that first popup window appears for a relatively long time, that makes debugging process very noncomfortable. What else Visual Studio debugger options could I set to disable this popup? </p>
| 0debug
|
AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask)
{
AVFilterBufferRef *ret = av_malloc(sizeof(AVFilterBufferRef));
if (!ret)
return NULL;
*ret = *ref;
if (ref->type == AVMEDIA_TYPE_VIDEO) {
ret->video = av_malloc(sizeof(AVFilterBufferRefVideoProps));
if (!ret->video) {
av_free(ret);
return NULL;
}
copy_video_props(ret->video, ref->video);
ret->extended_data = ret->data;
} else if (ref->type == AVMEDIA_TYPE_AUDIO) {
ret->audio = av_malloc(sizeof(AVFilterBufferRefAudioProps));
if (!ret->audio) {
av_free(ret);
return NULL;
}
*ret->audio = *ref->audio;
if (ref->extended_data && ref->extended_data != ref->data) {
int nb_channels = av_get_channel_layout_nb_channels(ref->audio->channel_layout);
if (!(ret->extended_data = av_malloc(sizeof(*ret->extended_data) *
nb_channels))) {
av_freep(&ret->audio);
av_freep(&ret);
return NULL;
}
memcpy(ret->extended_data, ref->extended_data,
sizeof(*ret->extended_data) * nb_channels);
} else
ret->extended_data = ret->data;
}
ret->perms &= pmask;
ret->buf->refcount ++;
return ret;
}
| 1threat
|
How to collect the id once I click on image linked updat page in php? : This is my image link,
<a href="UpdateStudent.php?SelectionId='."$Carrier".';"><img src="sawiro/EditImage.jpg" alt="Edit Student Image"></a>
I want to add Selectionid, as you can see on it `?SelectionId='."$Carrier".';` where my id variable is `$Carrier` becuase of this code `if(isset($_GET['SelectedId']))
{$Carrier = clearInput($_GET['SelectedId']);}`
I want once I click on `<img src="sawiro/EditImage.jpg" alt="Edit Student Image">` to give me url `UpdateStudent.php?SelectionId=8` for example, to use this id for setting data purpose.
Please help me to do so.
| 0debug
|
Query Selector is Null when I use insertAdjacentHTML : <p>I'm using insertAdjacentHtml to create a div with a button right after the opening body tag of the page.</p>
<pre><code><script>document.addEventListener('DOMContentLoaded', function(){
var code = '<div class="overlay"><button class="overlay-close"></button></div>';
document.body.insertAdjacentHTML('afterbegin', code);
}, false);</script>
</code></pre>
<p>But I get an error with the querySelector on my closeBttn.</p>
<p>Uncaught TypeError: Cannot read property 'querySelector' of null</p>
<pre><code><script>
(function() {
var overlay = document.querySelector( 'div.overlay' ),
closeBttn = overlay.querySelector( 'button.overlay-close' );
/* irrelevent other code here */
})();
</script>
</code></pre>
<p>Clearly it looks like I have the overlay button and overlay div present, but it still not working. It works fine without using insertAdjacentHTML, but once I wrapped my code in this function, I get the error, so I'm thinking there's something going on here when I use this function to create my div.</p>
<p>Can anyone help to debug or give a work around?</p>
| 0debug
|
Autowrap widgets to new line in flutter : <p>I have 5 widgets with different sizes which would overflow if placed next to each other.</p>
<p>I am looking for a layout helper class that limits the widgets to the horizontal space and auto-wraps the widgets instead to a new line. First I was looking for a grid view but prefer instead a view which is independent since all elements have different widths. A multi line text field does actually already that, I just need the same approach with my widgets. Any ideas?</p>
<pre><code><Widget>[
new RaisedButton(child: const Text('Foo')),
new RaisedButton(child: const Text('Foo Bar')),
new RaisedButton(child: const Text('Foo Bar Bas')),
new RaisedButton(child: const Text('F')),
new RaisedButton(child: const Text('B'))
]
</code></pre>
| 0debug
|
Custom TextSize of BottomNavigationView support android : <p>I am trying to change the textSize of BottomNavigationView from android support library 25.0.0</p>
<pre><code><android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/colorPrimaryDark"
android:foregroundTint="@color/colorAccent"
app:itemIconTint="@android:color/white"
app:itemTextColor="@android:color/white"
app:layout_anchor="@id/lyt_container"
app:layout_anchorGravity="bottom"
app:itemTextAppearance="@style/TextStyleBNV"
app:menu="@menu/nav_menu" />
<style name="TextStyleBNV">
<item name="android:textSize">@dimen/twelve_sp</item>
<item name="android:padding">0dp</item>
<item name="textAllCaps">false</item>
</style>
</code></pre>
<p>Is there anything i am missing.</p>
| 0debug
|
static void dump_json_image_info(ImageInfo *info)
{
Error *local_err = NULL;
QString *str;
QmpOutputVisitor *ov = qmp_output_visitor_new();
QObject *obj;
visit_type_ImageInfo(qmp_output_get_visitor(ov), NULL, &info, &local_err);
obj = qmp_output_get_qobject(ov);
str = qobject_to_json_pretty(obj);
assert(str != NULL);
printf("%s\n", qstring_get_str(str));
qobject_decref(obj);
qmp_output_visitor_cleanup(ov);
QDECREF(str);
}
| 1threat
|
Why we don't use extensions for files like .bashrc? : <p>I am aware that it's a configuration file, but sourcing .bashrc is in fact executing it in bash line by line. I also know, that extensions don't do much in Linux, but when you write some bash script, you often name it "*.sh", and .bashrc is the same, the only difference is that it's sourced by default.</p>
| 0debug
|
"Parse" line of code doesn't allow code to execute : <p>Cheers, I've isolated the error but I'm not sure how to fix it. Apparently, this line of code,(C language):</p>
<p>parse(getenv("QUERY_STRING")); </p>
<p>It does successfully compile, however when I run the executable the following pops up: puu.sh/nQi41/40e81c4494.png</p>
<p>When I simply comment out that specific line, the code compiles and runes perfectly.</p>
<p>Any possible solutions to this? Thanks in advance</p>
| 0debug
|
static char *vio_format_dev_name(VIOsPAPRDevice *dev)
{
VIOsPAPRDeviceInfo *info = (VIOsPAPRDeviceInfo *)qdev_get_info(&dev->qdev);
char *name;
if (asprintf(&name, "%s@%x", info->dt_name, dev->reg) < 0) {
return NULL;
}
return name;
}
| 1threat
|
find the largest,smallest,sum and ave of an array that stops at 0 in C : enter code hereso basically i have to find the largest, smallest, sum, average
ive gotten the average and sum to work buut not find the largest smallest, the average o the positive and the negative numbers. the array stops when 0 is pressed
#include <stdio.h>
int main()
{
int c=0,n, array[100],large,small;
float sum = 0;
//for (c=0;c<n;n++){
do{
c++;
printf("\nEnter number:");
scanf("%d",&array[c]);
sum+=array[c];
}while(array[c]!=0);
if(array[c]>large){large=array[c];}
if(array[c]<small){small=array[c];}
if(array[c]==0){
printf("\n Sum = %.2f\n", sum);
printf("\n Avergae = %.2f", sum/(c-1));
printf("\n Largest %d",large);
}
return 0;
}
| 0debug
|
SQL Server: Displaying result in Java Textfield : <p>I use MS SQL Server and Java with JDBC to connect.
I don't know how to display the result of my simple SQL queries in a Java Texfield. Displaying my data in a JTable is no problem with the external JAR <strong>rs2xml</strong>.</p>
<p>That works and prints my table in the panel.</p>
<pre><code>String MaxQuery = "SELECT * FROM Employees";
PreparedStatement pst=con.prepareStatement(MaxQuery);
ResultSet rs=pst.executeQuery();
table.setModel(DbUtils.resultSetToTableModel(rs));
</code></pre>
<p><strong>But</strong> when i want to display a simple query like "<em>SELECT AVG(budget) FROM Employees</em>" with 1 result, i want to print this <strong>in a textfield</strong>. </p>
<p>The method setModel doesn't work with Textfields. So i have tried something like that:</p>
<pre><code>String AVGQuery = "SELECT AVG(budget) FROM Employees";
PreparedStatement pst=con.prepareStatement(AVGQuery);
ResultSet rs=pst.executeQuery();
textFieldAns.setText(rs.toString());
</code></pre>
<p>But that prints me "SQLServerResultSet:1". I want the result, and not the number of results. Hope u can help me by my little problem :). </p>
| 0debug
|
Logout user via Keycloak REST API doesn't work : <p>I have issue while calling Keycloak's <strong>logout</strong> endpoint from an (mobile) application. </p>
<p>This scenario is supported as stated in <a href="http://www.keycloak.org/docs/latest/securing_apps/topics/oidc/oidc-generic.html" rel="noreferrer">its documentation</a>:</p>
<blockquote>
<p>/realms/{realm-name}/protocol/openid-connect/logout</p>
<p>The logout endpoint logs out the authenticated user.</p>
<p>The user agent can be redirected to the endpoint, in which case the active user session is logged out. Afterward the user agent is redirected back to the application.</p>
<p><strong>The endpoint can also be invoked directly by the application. To invoke this endpoint directly the refresh token needs to be included as well as the credentials required to authenticate the client</strong>.</p>
</blockquote>
<p>My request has following format:</p>
<pre><code>POST http://localhost:8080/auth/realms/<my_realm>/protocol/openid-connect/logout
Authorization: Bearer <access_token>
Content-Type: application/x-www-form-urlencoded
refresh_token=<refresh_token>
</code></pre>
<p>but this error always occurs:</p>
<pre><code>HTTP/1.1 400 Bad Request
Connection: keep-alive
X-Powered-By: Undertow/1
Server: WildFly/10
Content-Type: application/json
Content-Length: 123
Date: Wed, 11 Oct 2017 12:47:08 GMT
{
"error": "unauthorized_client",
"error_description": "UNKNOWN_CLIENT: Client was not identified by any client authenticator"
}
</code></pre>
<p>It seems that Keycloak is unable to detect the current client's identity event if I've provided <strong>access_token</strong>. I've the used same <strong>access_token</strong> to access other Keycloak's APIs without any problems, like <strong>userinfo</strong>
(<em>/auth/realms//protocol/openid-connect/userinfo</em>). </p>
<p>My request was based on this <a href="https://issues.jboss.org/browse/KEYCLOAK-2476" rel="noreferrer">Keycloak's issue</a>. The author of the issue got it worked but it is not my case. </p>
<p>I'm using Keycloak <strong>3.2.1.Final</strong>. </p>
<p>Do you have that same problem? Have you got any idea how to solve it?</p>
| 0debug
|
static inline void RENAME(yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
long width, long height,
long lumStride, long chromStride, long dstStride)
{
RENAME(yuvPlanartouyvy)(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride, 2);
}
| 1threat
|
how to sumup alias columns in case statement in SQL : SELECT E.EMPNO,E.DEPTNO,E.SAL,E.COMM,
COALESCE(SAL,0)+COALESCE(COMM,0) AS T1,
CASE
WHEN E.DEPTNO=10 THEN COALESCE(E.SAL,0)+COALESCE(E.COMM,0)
WHEN D.DNAME='ACCOUNTING' THEN COALESCE(E.SAL,0)-COALESCE(E.COMM,0)
ELSE 0 END AS T,
sum(T+T1) as T2
FROM EMP E LEFT OUTER JOIN DEPT D ON E.DEPTNO=D.DEPTNO;
getting below error
ORA-00904: "T1": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 7 Column: 7
| 0debug
|
static uint64_t memory_region_dispatch_read1(MemoryRegion *mr,
hwaddr addr,
unsigned size)
{
uint64_t data = 0;
if (!memory_region_access_valid(mr, addr, size, false)) {
return -1U;
}
if (!mr->ops->read) {
return mr->ops->old_mmio.read[bitops_ffsl(size)](mr->opaque, addr);
}
access_with_adjusted_size(addr, &data, size,
mr->ops->impl.min_access_size,
mr->ops->impl.max_access_size,
memory_region_read_accessor, mr);
return data;
}
| 1threat
|
operator< error in priority queue : <p>I am facing "binary '<': no operator found which takes a left-hand operand of type 'const Baloons' (or there is no acceptable conversion)" error and I cannot find any solution?</p>
<p>I would also like to ask how can I order the priority queue by baloon.end?</p>
<pre><code>#include <iostream>
#include <queue>
#include <vector>
using namespace std;
class Baloons
{
public:
float start;
float end;
public:
Baloons() {}
Baloons(float start, float end) : start{ start }, end{ end } {}
};
int main()
{
Baloons baloon1(1, 5);
Baloons baloon2(4, 7);
Baloons baloon3(6, 9);
Baloons baloon4(11, 12);
std::priority_queue<Baloons> myBaloons;
myBaloons.push(baloon1);
myBaloons.push(baloon2);
myBaloons.push(baloon3);
myBaloons.push(baloon4);
while (!myBaloons.empty())
{
Baloons b = myBaloons.top();
cout << b.start << " -> " << b.end << " ";
myBaloons.pop();
}
system("pause");
return 0;
</code></pre>
<p>}</p>
| 0debug
|
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
{
AVFrame *tmp;
int ret;
av_assert0(avctx->codec_type == AVMEDIA_TYPE_VIDEO);
if (!frame->data[0])
return ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF);
if (av_frame_is_writable(frame)) {
frame->pkt_pts = avctx->internal->pkt ? avctx->internal->pkt->pts : AV_NOPTS_VALUE;
frame->reordered_opaque = avctx->reordered_opaque;
return 0;
}
tmp = av_frame_alloc();
if (!tmp)
return AVERROR(ENOMEM);
av_frame_move_ref(tmp, frame);
ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF);
if (ret < 0) {
av_frame_free(&tmp);
return ret;
}
av_frame_copy(frame, tmp);
av_frame_free(&tmp);
return 0;
}
| 1threat
|
static int opt_default(const char *opt, const char *arg){
int type;
const AVOption *o= NULL;
int opt_types[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT_FLAG_SUBTITLE_PARAM, 0};
for(type=0; type<CODEC_TYPE_NB; type++){
const AVOption *o2 = av_find_opt(avctx_opts[0], opt, NULL, opt_types[type], opt_types[type]);
if(o2)
o = av_set_string(avctx_opts[type], opt, arg);
}
if(!o)
o = av_set_string(avformat_opts, opt, arg);
if(!o)
o = av_set_string(sws_opts, opt, arg);
if(!o){
if(opt[0] == 'a')
o = av_set_string(avctx_opts[CODEC_TYPE_AUDIO], opt+1, arg);
else if(opt[0] == 'v')
o = av_set_string(avctx_opts[CODEC_TYPE_VIDEO], opt+1, arg);
else if(opt[0] == 's')
o = av_set_string(avctx_opts[CODEC_TYPE_SUBTITLE], opt+1, arg);
}
if(!o)
return -1;
opt_names= av_realloc(opt_names, sizeof(void*)*(opt_name_count+1));
opt_names[opt_name_count++]= o->name;
#ifdef CONFIG_FFM_MUXER
if(avctx_opts[0]->flags & CODEC_FLAG_BITEXACT)
ffm_nopts = 1;
#endif
if(avctx_opts[0]->debug)
av_log_set_level(AV_LOG_DEBUG);
return 0;
}
| 1threat
|
c++ segmentation fault switch statement cin : <p>I have this code here </p>
<pre><code>string shapename;
bool warpspace;
const int size = 100;
ShapeTwoD shape2D[size]; // ShapeTwoD is a parent class
int number =0;
static int count = 0;
while(choice !=999)
{
switch(choice)
{
case 1:
{
cout<<"[Input sensor data]"<<endl;
cout<<"Please enter name of Shape:";
cin>>shapename;
shape2D[size].setName(shapename); //segmentation fault
cout<<"Please enter special type:";
cin>>warpspace;
shape2D[size].setContainsWarpSpace(warpspace);
cin.clear();
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
if(shapename == "Square" || shapename == "square")
{ square.setSquareCord(); count++; }
if(shapename == "Rectangle" || shapename == "rectangle")
{ rect.setRectangleCord(); count++; }
mainmenu();
cin>>number;
option(number);
}break;//there are still multiple cases
}
}
</code></pre>
<p>when i try to compile and run it , it gives me segmentation error right after i enter the Shape <code>please enter name of shape :</code> what have i done wrong here? </p>
| 0debug
|
int get_frame_filename(char *buf, int buf_size,
const char *path, int number)
{
const char *p;
char *q, buf1[20];
int nd, len, c, percentd_found;
q = buf;
p = path;
percentd_found = 0;
for(;;) {
c = *p++;
if (c == '\0')
break;
if (c == '%') {
do {
nd = 0;
while (isdigit(*p)) {
nd = nd * 10 + *p++ - '0';
}
c = *p++;
if (c == '*' && nd > 0) {
number = number % nd;
c = *p++;
nd = 0;
}
} while (isdigit(c));
switch(c) {
case '%':
goto addchar;
case 'd':
if (percentd_found)
goto fail;
percentd_found = 1;
snprintf(buf1, sizeof(buf1), "%0*d", nd, number);
len = strlen(buf1);
if ((q - buf + len) > buf_size - 1)
goto fail;
memcpy(q, buf1, len);
q += len;
break;
default:
goto fail;
}
} else {
addchar:
if ((q - buf) < buf_size - 1)
*q++ = c;
}
}
if (!percentd_found)
goto fail;
*q = '\0';
return 0;
fail:
*q = '\0';
return -1;
}
| 1threat
|
object is not callablel web crawler : import requests
from bs4 import BeautifulSoup
def lolz(max_pages):
page = 1
while page <= max_pages:
url = 'https://www.thenewboston.com/search.php?type=1&sort=pop&page=' + str(page)
sorce_code = requests.get(url)
plain_text = sorce_code.text
soup = BeautifulSoup(plain_text)
for link in soup.findall('a',{'class' : 'item-name'}):
href = link.get('href')
print(href)
page += 1
lolz(1)
here is the code i keep geting error nonetype object is not callable
| 0debug
|
Corpora/stopwords not found when import nltk library : <p>I trying to import the nltk package in python 2.7</p>
<pre><code> import nltk
stopwords = nltk.corpus.stopwords.words('english')
print(stopwords[:10])
</code></pre>
<p>Running this gives me the following error:</p>
<pre><code>LookupError:
**********************************************************************
Resource 'corpora/stopwords' not found. Please use the NLTK
Downloader to obtain the resource: >>> nltk.download()
</code></pre>
<p>So therefore I open my python termin and did the following:</p>
<pre><code>import nltk
nltk.download()
</code></pre>
<p>Which gives me:</p>
<pre><code>showing info https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/index.xml
</code></pre>
<p>However this does not seem to stop. And running it again still gives me the same error. Any thoughts where this goes wrong?</p>
| 0debug
|
First web app with ASP.NET : <p>I'm sorry if this question does not belong here but I couldn't think of any better place to ask.</p>
<p>I am a c# application developer but I want to try making a web site. Feature wise it should be similar to something like LinkedIn. That means a userbase, where each user have their own page, users can search for other users, follow and message each other. Maybe even a "news wall".</p>
<p>Now, I have to learn how to make such a thing from scratch (I guess it gonna take awhile - which is alright). From google I learned I could use ASP.NET core or ASP.NET and either Razor pages or MVC but I don't know if its actually possible with any of those tools.</p>
<p>What would be your recommendation? I don't wanna spend long time to learn something only to discover something else would have been better.</p>
| 0debug
|
Can you make a feature that allows users to choose color C# (Console) : <p>Any ideas? I have a way but that would only change from downwards, and the menu is in the top.</p>
| 0debug
|
static int gxf_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) {
int res = 0;
uint64_t pos;
uint64_t maxlen = 100 * 1024 * 1024;
AVStream *st = s->streams[0];
int64_t start_time = s->streams[stream_index]->start_time;
int64_t found;
int idx;
if (timestamp < start_time) timestamp = start_time;
idx = av_index_search_timestamp(st, timestamp - start_time,
AVSEEK_FLAG_ANY | AVSEEK_FLAG_BACKWARD);
if (idx < 0)
return -1;
pos = st->index_entries[idx].pos;
if (idx < st->nb_index_entries - 2)
maxlen = st->index_entries[idx + 2].pos - pos;
maxlen = FFMAX(maxlen, 200 * 1024);
res = avio_seek(s->pb, pos, SEEK_SET);
if (res < 0)
return res;
found = gxf_resync_media(s, maxlen, -1, timestamp);
if (FFABS(found - timestamp) > 4)
return -1;
return 0;
}
| 1threat
|
Sublime text 3 using massive amount of CPU on idle : <p>I'm running Sublime Text 3 on Windows 10, with all my installed packages disabled. On idle, it is taking up ~31% of my CPU with one file opened. This seems like a ridiculous amount for a text editor - why is this?</p>
| 0debug
|
mutate variable if column name contains a string : <p>My data has several columns which contain the string "trait". I'd like to mutate these columns in the same way using dplyr.</p>
<p>My first instinct was to use <code>mutate_if</code> in the following way:</p>
<pre><code>my_data %>% mutate_if(contains('trait'), funs(if_else(.=='True',T,F)) )
</code></pre>
<p>But I get the error </p>
<pre><code>Error: Variable context not set
</code></pre>
<p>What does that error mean? How can I properly use the <code>mutate_if</code> function?</p>
<p>here is a sample of my data (with some other columns ommited).</p>
<pre><code>tibble::tribble(
~X1_on_1_rush_trait, ~acrobatic_clearance_trait, ~argues_with_officials_trait, ~avoids_using_weaker_foot_trait, ~backs_into_player_trait, ~bicycle_kicks_trait, ~cautious_with_crosses_trait, ~chip_shot_trait, ~chipped_penalty_trait, ~comes_for_crosses_trait, ~corner_specialist_trait, ~diver_trait, ~dives_into_tackles_trait, ~diving_header_trait, ~driven_pass_trait, ~early_crosser_trait, ~fan.s_favourite_trait, ~fancy_flicks_trait, ~finesse_shot_trait, ~flair_trait, ~flair_passes_trait, ~gk_flat_kick_trait, ~gk_long_throw_trait, ~gk_up_for_corners_trait, ~giant_throw_in_trait, ~inflexible_trait, ~injury_free_trait, ~injury_prone_trait, ~leadership_trait, ~long_passer_trait, ~long_shot_taker_trait, ~long_throw_in_trait, ~one_club_player_trait, ~outside_foot_shot_trait, ~playmaker_trait, ~power_free_kick_trait, ~power_header_trait, ~puncher_trait, ~rushes_out_of_goal_trait, ~saves_with_feet_trait, ~second_wind_trait, ~selfish_trait, ~skilled_dribbling_trait, ~stutter_penalty_trait, ~swerve_pass_trait, ~takes_finesse_free_kicks_trait, ~target_forward_trait, ~team_player_trait, ~technical_dribbler_trait, ~tries_to_beat_defensive_line_trait, ~name,
"False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "True", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "True", "False", "False", "False", "False", "True", "False", "False", "False", "False", "False", "False", "True", "False", "False", "False", "False", "False", "False", "False", "Cristiano Ronaldo",
"False", "False", "False", "False", "False", "False", "False", "True", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "True", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "True", "False", "True", "False", "True", "False", "False", "False", "False", "False", "False", "False", "True", "False", "False", "False", "False", "False", "False", "False", "L. Messi",
"False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "True", "False", "False", "False", "False", "False", "False", "False", "True", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "True", "False", "False", "True", "False", "False", "True", "False", "Neymar",
"False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "True", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "True", "True", "L. Suárez",
"True", "False", "False", "False", "False", "False", "False", "False", "False", "True", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "True", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "True", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "M. Neuer",
"False", "False", "False", "False", "False", "False", "False", "True", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "True", "False", "False", "False", "False", "False", "False", "False", "True", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "False", "R. Lewandowski"
)
</code></pre>
| 0debug
|
How to remove all emoji from string - php : <p>How to remove all emoji in following string ?</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. 🇬🇧🍁🍃🍂🌰🍁🌿🌾🌼🌻</p>
| 0debug
|
iOS OpenCV haarcascade for other facial emotions : <p>I have been trying OpenCV iOS sample to achieve facial emotion recognition.
I got OpenCV sample iOS project 'openCViOSFaceTrackingTutorial' from below link.
<a href="https://github.com/egeorgiou/openCViOSFaceTrackingTutorial/tree/master/openCViOSFaceTrackingTutorial" rel="noreferrer">https://github.com/egeorgiou/openCViOSFaceTrackingTutorial/tree/master/openCViOSFaceTrackingTutorial</a></p>
<p>This sample project uses 'face detection', it works fine. It uses 'haarcascade_frontalface_alt2.xml' trained model.</p>
<p>I want to use the same project but have haarcascade for other facial emotions like Sad, Surprise. I have been searching for how to train haarcascade for emotions like Sad, Surprise etc. but couldn't find any clue.</p>
<p>Could someone advise me, how to train haarcascade for emotions like Sad, Surprise etc. to use in this sample OpenCV iOS project? Or will there be readymade haarcascade for emotions like Sad, Surprise etc. to use for this iOS sample.</p>
<p>Thanks</p>
| 0debug
|
How to stop self-referencing loop in .Net Core Web API? : <p>I'm having some issues which I'm guessing are related to self-referencing using .NET Core Web API and Entity Framework Core. My Web API starting choking when I added .Includes for some navigation properties.</p>
<p>I found what appears to be a solution in the older Web API but I don't know how to implement the same thing for .NET Core Web API (I'm still in the early learning stages).</p>
<p>The older solution was sticking this in the Application_Start() of the Global.asax:</p>
<pre><code> GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Serialize;
</code></pre>
<p>I suspect this is handled in the StartUp's ConfigureService() method but I don't know much beyond there.</p>
<p>Or is there a more appropriate way to handle this issue?</p>
| 0debug
|
Compare each element of list with other elements in list : <p>I have two lists </p>
<p>list 1= [Hello How are you]</p>
<p>list 2= [Hello How me you]</p>
<p>I want to compare each element of list 1 to list 2 and then change colour of elements accordingly like matched should be green and unmatched should be red. Please check below image. Output should be like this. Can anyone please tell me how can i do that ?</p>
<p><a href="https://i.stack.imgur.com/xkB3J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xkB3J.png" alt="enter image description here"></a>.</p>
| 0debug
|
Dynamic allocation and Arrays to find average : Alright did i implement `float overallavg(float* matrix, int rows, int cols)`correctly? I think i didn't. I'm trying to Return the average value of the elements of the array pointed to by matrix. Should I call the other two functions into the overall one and then divide by the total number elements in the array?
float *readMatrix(int rows, int cols)
{
int i=0;
int j=0;
int elements=0;
float *m=malloc(rows*cols*sizeof(float));
if (m==NULL)
{
printf("error\n");
return NULL;
}
printf("Enter values for the matrix: ");
for (i=0;i<rows;i++)
{
for (j=0;j<cols;j++)
{
elements = i*cols+j;
scanf("%f", &m[elements]);
}
}
return m;
}
float *rowavg(float *matrix, int rows, int cols)
{
if (matrix==NULL)
{
return NULL;
}
int i=0;
int j=0;
float mean=0;
float *Average_array=malloc(rows*sizeof(float));
if (Average_array==NULL)
{
return NULL;
}
for (i=0;i<rows;i++)
{
for (j=0;j<cols;j++)
{
mean+=matrix[i*cols+j];
}
Average_array[i]=(float)(mean/cols);
}
return Average_array;
}
float *colavg(float *matrix, int rows, int cols)
{
if (matrix==NULL)
{
return NULL;
}
int i=0;
int j=0;
float mean=0;
float *Average_array=malloc(cols*sizeof(float));
if (Average_array==NULL)
{
return NULL;
}
for (i=0;i<cols;i++)
{
for (j=0;j<rows;j++)
{
mean+=matrix[j*cols+i];
}
Average_array[i]=(float)(mean/rows);
}
return Average_array;
}
float overallavg(float* matrix, int rows, int cols)
{
if (matrix==NULL)
{
return NULL;
}
int i=0;
int j=0;
float mean_1=0;
float mean_2=0;
float avg=0;
float elements=0;
float sum=0;
elements=rows*cols;
for (i=0;i<rows;i++)
{
for (j=0;j<cols;j++)
{
mean_1+=matrix[i*rows+j];
}
}
for (i=0;i<cols;i++)
{
for (j=0;j<rows;j++)
{
mean_2+=matrix[j*cols+i];
}
}
sum=mean_1+mean_2;
avg=sum/elements-1;
}
| 0debug
|
Getting an item from a nested dictionary using a list of indexes - python : <p>I have an odd question. If I were to have a dictionary like so:</p>
<pre><code>{"foo":{"abc":123},"bar":{"def":456},"biz":789}
</code></pre>
<p>and I had a list of indexes like so:</p>
<pre><code>["foo","abc"]
</code></pre>
<p>How would I GET AND MODIFY that item? I've seen questions like it, but all the answers tell me to make a bunch of indexes ex:</p>
<pre><code>foobar["foo"]["abc"] = "modified"
</code></pre>
<p>But the problem is that my indexes are in lists. Also, I could do something like ["foo","abc","more","items"] and that would need to equate to foobar["foo"]["abc"]["more"]["items"]</p>
<p>Is there some way that I could get and modify an item in a dictionary using a list of indexes?</p>
| 0debug
|
Convert datetime to specified format in c#? : <p>I want to convert 'yy/MM/dd HH:mm:ss' format like 17/07/18 06:30:20 to Jul.18, 2017 06:30:20 in c#. What is the best way to do that? </p>
| 0debug
|
static void spapr_hotplug_req_event(uint8_t hp_id, uint8_t hp_action,
sPAPRDRConnectorType drc_type,
union drc_identifier *drc_id)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
struct hp_log_full *new_hp;
struct rtas_error_log *hdr;
struct rtas_event_log_v6 *v6hdr;
struct rtas_event_log_v6_maina *maina;
struct rtas_event_log_v6_mainb *mainb;
struct rtas_event_log_v6_hp *hp;
new_hp = g_malloc0(sizeof(struct hp_log_full));
hdr = &new_hp->hdr;
v6hdr = &new_hp->v6hdr;
maina = &new_hp->maina;
mainb = &new_hp->mainb;
hp = &new_hp->hp;
hdr->summary = cpu_to_be32(RTAS_LOG_VERSION_6
| RTAS_LOG_SEVERITY_EVENT
| RTAS_LOG_DISPOSITION_NOT_RECOVERED
| RTAS_LOG_OPTIONAL_PART_PRESENT
| RTAS_LOG_INITIATOR_HOTPLUG
| RTAS_LOG_TYPE_HOTPLUG);
hdr->extended_length = cpu_to_be32(sizeof(*new_hp)
- sizeof(new_hp->hdr));
spapr_init_v6hdr(v6hdr);
spapr_init_maina(maina, 3 );
mainb->hdr.section_id = cpu_to_be16(RTAS_LOG_V6_SECTION_ID_MAINB);
mainb->hdr.section_length = cpu_to_be16(sizeof(*mainb));
mainb->subsystem_id = 0x80;
mainb->event_severity = 0x00;
mainb->event_subtype = 0x00;
hp->hdr.section_id = cpu_to_be16(RTAS_LOG_V6_SECTION_ID_HOTPLUG);
hp->hdr.section_length = cpu_to_be16(sizeof(*hp));
hp->hdr.section_version = 1;
hp->hotplug_action = hp_action;
hp->hotplug_identifier = hp_id;
switch (drc_type) {
case SPAPR_DR_CONNECTOR_TYPE_PCI:
hp->hotplug_type = RTAS_LOG_V6_HP_TYPE_PCI;
if (hp->hotplug_action == RTAS_LOG_V6_HP_ACTION_ADD) {
spapr_hotplug_set_signalled(drc_id->index);
}
break;
case SPAPR_DR_CONNECTOR_TYPE_LMB:
hp->hotplug_type = RTAS_LOG_V6_HP_TYPE_MEMORY;
break;
case SPAPR_DR_CONNECTOR_TYPE_CPU:
hp->hotplug_type = RTAS_LOG_V6_HP_TYPE_CPU;
break;
default:
g_assert(false);
return;
}
if (hp_id == RTAS_LOG_V6_HP_ID_DRC_COUNT) {
hp->drc_id.count = cpu_to_be32(drc_id->count);
} else if (hp_id == RTAS_LOG_V6_HP_ID_DRC_INDEX) {
hp->drc_id.index = cpu_to_be32(drc_id->index);
} else if (hp_id == RTAS_LOG_V6_HP_ID_DRC_COUNT_INDEXED) {
g_assert(spapr_ovec_test(spapr->ov5_cas, OV5_HP_EVT));
hp->drc_id.count_indexed.count =
cpu_to_be32(drc_id->count_indexed.count);
hp->drc_id.count_indexed.index =
cpu_to_be32(drc_id->count_indexed.index);
}
rtas_event_log_queue(RTAS_LOG_TYPE_HOTPLUG, new_hp, true);
qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr),
rtas_event_log_to_irq(spapr,
RTAS_LOG_TYPE_HOTPLUG)));
}
| 1threat
|
void bdrv_commit_all(void)
{
BlockDriverState *bs;
QTAILQ_FOREACH(bs, &bdrv_states, list) {
bdrv_commit(bs);
}
}
| 1threat
|
I need to store keys and values dynamically in hash of hash.I know i can't use %hash[$i]. So how to proceed. Any help will be appreciated : use Data::Dumper;
print "enter number of orders";
$count=<STDIN>;
my @arr;
my @order;
my @protocol;
my @message_length;
my @logon;
my @value_send;
my @value_receive;
my @seq_number;
my @time;
my @retransmission;
my @account;
my @destination;
my @qty_order;
my @ticker;
my @instruction;
my @order;
my @locate;
for($i=1;$i<=$count;$i++){
print "enter the value of tag8";
$protocol[$i]=<STDIN>;
chomp($protocol[$i]);
print "enter the value of tag9";
$message_length[$i]=<STDIN>;
chomp($message_length[$i]);
print "enter the value of tag35";
$logon[$i]=<STDIN>;
chomp($logon[$i]);
print "enter the value of tag49";
$value_send[$i]=<STDIN>;
chomp($value_send[$i]);
print "enter the value of tag56";
$value_recieve[$i]=<STDIN>;
chomp($value_recieve[$i]);
print "enter the value of tag34";
$seq_number[$i]=<STDIN>;
chomp($seq_number[$i]);
print "enter the value of tag52";
$time[$i]=<STDIN>;
chomp($time[$i]);
print "enter the value of tag43";
$retransmission[$i]=<STDIN>;
chomp($retransmission[$i]);
print "enter the value of tag1";
$account[$i]=<STDIN>;
chomp($account[$i]);
print "enter the value of tag100";
$destination[$i]=<STDIN>;
chomp($destination[$i]);
print "enter the value of tag38";
$qty_order[$i]=<STDIN>;
chomp($qty_order[$i]);
print "enter the value of tag55";
$ticker[$i]=<STDIN>;
chomp($ticker[$i]);
print "enter the value of tag21";
$instruction[$i]=<STDIN>;
chomp($instruction[$i]);
print "enter the value of tag54";
$order[$i]=<STDIN>;
chomp($order[$i]);
print "enter the value of tag114";
$locate[$i]=<STDIN>;
chomp($locate[$i]);
// I know the syntax is not correct of declaring hash.
my %userhash[$i] = (
"8" => $protocol[$i],
"9" => $message_length[$i],
"35" => $logon[$i],
"49" => $value_send[$i],
"56" => $value_recieve[$i],
"34" => $seq_number[$i],
"52" => $time[$i],
"43" => $retransmission[$i],
"1" => $account[$i],
"100" => $destination[$i],
"38" => $qty_order[$i],
"55" => $ticker[$i],
"21" => $instruction[$i],
"54" => $order[$i],
"114" => $locate[$i],
"59" => $duration[$i],
"40" => $market[$i],
"11" => $id[$i],
"60" => $timeexecution[$i],
"553" => $userid[$i],
"10" => $checksum[$i],
);
$userhash[$i+1]{$orderno}={%userhash[$i]};
print Dumper(\%userhash[$i]);
}
| 0debug
|
Using the do while :
I'm completely lost on some homework
Using a while loop, prompt the user to enter 5 numbers
Display the sum of these numbers after they have been entered
Thanks!
| 0debug
|
void tcg_gen_atomic_cmpxchg_i32(TCGv_i32 retv, TCGv addr, TCGv_i32 cmpv,
TCGv_i32 newv, TCGArg idx, TCGMemOp memop)
{
memop = tcg_canonicalize_memop(memop, 0, 0);
if (!parallel_cpus) {
TCGv_i32 t1 = tcg_temp_new_i32();
TCGv_i32 t2 = tcg_temp_new_i32();
tcg_gen_ext_i32(t2, cmpv, memop & MO_SIZE);
tcg_gen_qemu_ld_i32(t1, addr, idx, memop & ~MO_SIGN);
tcg_gen_movcond_i32(TCG_COND_EQ, t2, t1, t2, newv, t1);
tcg_gen_qemu_st_i32(t2, addr, idx, memop);
tcg_temp_free_i32(t2);
if (memop & MO_SIGN) {
tcg_gen_ext_i32(retv, t1, memop);
} else {
tcg_gen_mov_i32(retv, t1);
}
tcg_temp_free_i32(t1);
} else {
gen_atomic_cx_i32 gen;
gen = table_cmpxchg[memop & (MO_SIZE | MO_BSWAP)];
tcg_debug_assert(gen != NULL);
#ifdef CONFIG_SOFTMMU
{
TCGv_i32 oi = tcg_const_i32(make_memop_idx(memop & ~MO_SIGN, idx));
gen(retv, tcg_ctx.tcg_env, addr, cmpv, newv, oi);
tcg_temp_free_i32(oi);
}
#else
gen(retv, tcg_ctx.tcg_env, addr, cmpv, newv);
#endif
if (memop & MO_SIGN) {
tcg_gen_ext_i32(retv, retv, memop);
}
}
}
| 1threat
|
add Strings and integers to Collection : <p>i have implemented a interface and now i have to implement a method, where i have to add Strings and Integers into Collections.I tried c.add but it don´t work. Any ideas how i could do that?</p>
<p>Kind Regards.<br>
E.C</p>
<pre><code>public class AnswerList implements AnswerCollection {
private Collections c;
/* add String answer and mode to collection of answers and modes */
public boolean addAnswer(String word, int mode) {
if(mode == LearnGUI.SOURCE_GIVEN){
c.add(word);
c.add(mode);
return true;
} else{
return false;
}
}
</code></pre>
| 0debug
|
Function of Base Number 10 to 2,8,16 Ploblem? : <p>I Beginner to Coding and English language maybe not good. (I'm living Bangkok,Thailand)</p>
<p>I created Function Base number 10 to 2,8,16 by using with Switch Case.</p>
<p>You can see my code C++ at here : </p>
<p><a href="https://gist.github.com/anonymous/5d31d216c85194470def16d31a2b97cf" rel="nofollow noreferrer">https://gist.github.com/anonymous/5d31d216c85194470def16d31a2b97cf</a></p>
<p>Ploblem</p>
<p>When i was run the program,i selected number Case 1 , 2 , 3 << it can't work,if i selected Case 4 to End Program is work.</p>
<p>I don't know that ploblem i thought write wrong code ?</p>
<p>Thank you.</p>
| 0debug
|
Lookup a value and Index Match Table - If a Date is between 2 dates with criteria : I would like to look up first ID match with second ID, if found then match first date with the given range date within same raw and then add type of leave according to the first date if matched
by using Vlookup / Match index /if
[Comparison data][1]
[1]: https://i.stack.imgur.com/UPdj9.jpg
please help ^_^
| 0debug
|
No provider for ComponentLoaderFactory : <p>I updated my angular2 project and before it was working fine. However now I am getting the following error:</p>
<pre><code>Error: Uncaught (in promise): Error: Error in ./RibbonComponent class
RibbonComponent - inline template:4:5 caused by: No provider for
ComponentLoaderFactory!
Error: Error in ./RibbonComponent class RibbonComponent - inline
template:4:5 caused by: No provider for ComponentLoaderFactory!
</code></pre>
<p>ComponentLoaderFactory</p>
<pre><code>export declare class ComponentLoaderFactory {
private _componentFactoryResolver;
private _ngZone;
private _injector;
private _posService;
constructor(componentFactoryResolver: ComponentFactoryResolver, ngZone: NgZone, injector: Injector, posService: PositioningService);
/**
*
* @param _elementRef
* @param _viewContainerRef
* @param _renderer
* @returns {ComponentLoader}
*/
createLoader<T>(_elementRef: ElementRef, _viewContainerRef: ViewContainerRef, _renderer: Renderer): ComponentLoader<T>;
}
</code></pre>
<p>I am not sure what else to post. All my made my package.json up to date via <code>ncu</code> than <code>ncu -u</code>. I am being to think I found a bug. I did find a post on GitHub but it did not help. <a href="https://github.com/valor-software/ng2-bootstrap/issues/1348" rel="noreferrer">GitHub</a></p>
<p>If I need to post anything else let me know.</p>
| 0debug
|
How to get back to CMD prompt to resume batch file after ps1 has run : <p>Calling a powershell command from CMD batch file but the CMD stays in powershell mode. How do I exit powershell mode (in command prompt) and continue the batch file?
When I run the current batch file, I have to type exit to exit the powershell session. Then the batch file continues where it left off.</p>
| 0debug
|
Flexbox 3 divs, two columns, one with two rows : <p>I am trying to take</p>
<pre><code><div></div>
<div></div>
<div></div>
</code></pre>
<p>Three sequential divs and turn it into below. Where red is div 1, green is div 2, blue is div 3.</p>
<p>I can do this with floats, something like</p>
<pre><code>.div1 { float: left; }
.div2 { float: left; }
.div3 { float: left; }
</code></pre>
<p>But I can't seem to get it working in flexbox, is this possible?</p>
<p><a href="https://i.stack.imgur.com/1od7u.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1od7u.png" alt="enter image description here"></a></p>
| 0debug
|
Python + OpenCV: OCR Image Segmentation : <p>I am trying to do OCR from this toy example of Receipts. Using Python 2.7 and OpenCV 3.1.</p>
<p><a href="https://i.stack.imgur.com/WQbGH.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/WQbGH.jpg" alt="enter image description here"></a></p>
<p>Grayscale + Blur + External Edge Detection + Segmentation of each area in the Receipts (for example "Category" to see later which one is marked -in this case cash-).</p>
<p>I find complicated when the image is "skewed" to be able to properly transform and then "automatically" segment each segment of the receipts.</p>
<p>Example:</p>
<p><a href="https://i.stack.imgur.com/EnA6A.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/EnA6A.jpg" alt="enter image description here"></a></p>
<p>Any suggestion?</p>
<p>The code below is an example to get until the edge detection, but when the receipt is like the first image. My issue is not the Image to text. Is the pre-processing of the image.</p>
<p>Any help more than appreciated! :)</p>
<pre><code>import os;
os.chdir() # Put your own directory
import cv2
import numpy as np
image = cv2.imread("Rent-Receipt.jpg", cv2.IMREAD_GRAYSCALE)
blurred = cv2.GaussianBlur(image, (5, 5), 0)
#blurred = cv2.bilateralFilter(gray,9,75,75)
# apply Canny Edge Detection
edged = cv2.Canny(blurred, 0, 20)
#Find external contour
(_,contours, _) = cv2.findContours(edged, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
</code></pre>
| 0debug
|
copy from text file into datatable needs to be split : private void button2_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
DataColumn col = new DataColumn("test");
col.DataType = System.Type.GetType("System.String");
dt.Columns.Add(col);
string[] aa = File.ReadAllLines("C:\\Users\\aaaaa\\Desktop\\aaaaa.txt");
foreach (var item in aa)
{
DataRow dr = dt.NewRow();
dr[0] = item.ToString();
dt.Rows.Add(dr);
}
dataGridView1.DataSource = dt;
}
my txt file contains
hi;my;name;is;xyz
separator is ";"
but i want to write my data to datable as like that
hi
my
name
is
xyz
How can i change my code to work like that.
| 0debug
|
how to enter a base value and an overide value on excel : Let me explain it with an example.
I'm pulling Sales data from a website and doing calculations on it, so that for instance I would have two columns:
Sales Company A | 15000 (from the website)
Sales Company B | 24000 (from the website)
-----------------------
Total | sum()
I want to be able to override the sales so that it impacts the total, but not to lose the original value. So for instance I could change the company A sales manually on my cell, hit enter and get a new total. And if i made a mistake, i can just delete the company A sales and it will go back to the original 15000 (without the need to retrieve the data again i would hope).
Is this possible on excel? Or an addin or something that allows it?
| 0debug
|
Anaconda export Environment file : <p>How can I make anaconda environment file which could be use on other computers?</p>
<p>I exported my anaconda python environment to YML using <code>conda env export > environment.yml</code>. The exported <code>environment.yml</code> contains this line <code>prefix: /home/superdev/miniconda3/envs/juicyenv</code> which maps to my anaconda's location which will be different on other's pcs.</p>
| 0debug
|
int select_watchdog_action(const char *p)
{
int action;
char *qapi_value;
qapi_value = g_ascii_strdown(p, -1);
action = qapi_enum_parse(&WatchdogAction_lookup, qapi_value, -1, NULL);
g_free(qapi_value);
if (action < 0)
return -1;
watchdog_action = action;
return 0;
}
| 1threat
|
Substrings in C+ : I am having trouble with this problem any tips on how to solve it would be appreciated. Thanks in advance. "This function finds the first occurrence of toFind in original and returns an integer representing the index of the first element of the toFind substring in original. For example if toFind was 'man' and original was 'superman' the function would return 6 since the begining of 'man' in 'spiderman' is position 7. If the function does not find a substring it should return -1."
| 0debug
|
Unable to insert integer in QString : I have a QString **strLayout** which has value `"3,1,0"`.
I want to change it to "**2,1,0**".
So I extracted the first character, converted to number and subtracted 1 from it:
int temp = (strLayout.at(0).digitValue() - 1);
Now, I want it to write back to original QString strLayout, but not able to do it.
Thanks in advance!
| 0debug
|
Keras: model.predict for a single image : <p>I'd like to make a prediction for a single image with Keras. I've trained my model so I'm just loading the weights. </p>
<pre><code>from keras.preprocessing.image import ImageDataGenerator
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D
from keras.layers import Activation, Dropout, Flatten, Dense
from keras import backend as K
import numpy as np
import cv2
# dimensions of our images.
img_width, img_height = 150, 150
def create_model():
if K.image_data_format() == 'channels_first':
input_shape = (3, img_width, img_height)
else:
input_shape = (img_width, img_height, 3)
model = Sequential()
model.add(Conv2D(32, (3, 3), input_shape=input_shape))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(32, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(64, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Flatten())
model.add(Dense(64))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(1))
model.add(Activation('sigmoid'))
return model
img = cv2.imread('./test1/1.jpg')
model = create_model()
model.load_weights('./weight.h5')
model.predict(img)
</code></pre>
<p>I'm loading the image using: </p>
<pre><code>img = cv2.imread('./test1/1.jpg')
</code></pre>
<p>And using the predict function of the model:</p>
<pre><code> model.predict(img)
</code></pre>
<p>But I get the error:</p>
<pre><code>ValueError: Error when checking : expected conv2d_1_input to have 4 dimensions, but got array with shape (499, 381, 3)
</code></pre>
<p>How should I proceed to have predictions on a single image ?</p>
| 0debug
|
void ff_vc1dsp_init_altivec(VC1DSPContext* dsp)
{
if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC))
return;
dsp->vc1_inv_trans_8x8 = vc1_inv_trans_8x8_altivec;
dsp->vc1_inv_trans_8x4 = vc1_inv_trans_8x4_altivec;
dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = put_no_rnd_vc1_chroma_mc8_altivec;
dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = avg_no_rnd_vc1_chroma_mc8_altivec;
}
| 1threat
|
While i am Loging In SqlServer Shoing This Error Plz Help Me Out How To resolve It : [Sql Server Error[\]\[1\]][1]
[1]: http://i.stack.imgur.com/xjFhQ.jpg
While i am Loging In SqlServer Shoing This Error Plz Help Me Out How To resolve It
| 0debug
|
static void gen_mfmsr(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
return;
}
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_msr);
#endif
}
| 1threat
|
static void copy_cell(Indeo3DecodeContext *ctx, Plane *plane, Cell *cell)
{
int h, w, mv_x, mv_y, offset, offset_dst;
uint8_t *src, *dst;
offset_dst = (cell->ypos << 2) * plane->pitch + (cell->xpos << 2);
dst = plane->pixels[ctx->buf_sel] + offset_dst;
mv_y = cell->mv_ptr[0];
mv_x = cell->mv_ptr[1];
offset = offset_dst + mv_y * plane->pitch + mv_x;
src = plane->pixels[ctx->buf_sel ^ 1] + offset;
h = cell->height << 2;
for (w = cell->width; w > 0;) {
if (!((cell->xpos << 2) & 15) && w >= 4) {
for (; w >= 4; src += 16, dst += 16, w -= 4)
ctx->dsp.put_no_rnd_pixels_tab[0][0](dst, src, plane->pitch, h);
}
if (!((cell->xpos << 2) & 7) && w >= 2) {
ctx->dsp.put_no_rnd_pixels_tab[1][0](dst, src, plane->pitch, h);
w -= 2;
src += 8;
dst += 8;
}
if (w >= 1) {
copy_block4(dst, src, plane->pitch, plane->pitch, h);
w--;
src += 4;
dst += 4;
}
}
}
| 1threat
|
static int vnc_zlib_stop(VncState *vs)
{
z_streamp zstream = &vs->zlib.stream;
int previous_out;
vs->zlib.zlib = vs->output;
vs->output = vs->zlib.tmp;
if (zstream->opaque != vs) {
int err;
VNC_DEBUG("VNC: initializing zlib stream\n");
VNC_DEBUG("VNC: opaque = %p | vs = %p\n", zstream->opaque, vs);
zstream->zalloc = vnc_zlib_zalloc;
zstream->zfree = vnc_zlib_zfree;
err = deflateInit2(zstream, vs->tight.compression, Z_DEFLATED, MAX_WBITS,
MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY);
if (err != Z_OK) {
fprintf(stderr, "VNC: error initializing zlib\n");
return -1;
}
vs->zlib.level = vs->tight.compression;
zstream->opaque = vs;
}
if (vs->tight.compression != vs->zlib.level) {
if (deflateParams(zstream, vs->tight.compression,
Z_DEFAULT_STRATEGY) != Z_OK) {
return -1;
}
vs->zlib.level = vs->tight.compression;
}
buffer_reserve(&vs->output, vs->zlib.zlib.offset + 64);
zstream->next_in = vs->zlib.zlib.buffer;
zstream->avail_in = vs->zlib.zlib.offset;
zstream->next_out = vs->output.buffer + vs->output.offset;
zstream->avail_out = vs->output.capacity - vs->output.offset;
zstream->data_type = Z_BINARY;
previous_out = zstream->total_out;
if (deflate(zstream, Z_SYNC_FLUSH) != Z_OK) {
fprintf(stderr, "VNC: error during zlib compression\n");
return -1;
}
vs->output.offset = vs->output.capacity - zstream->avail_out;
return zstream->total_out - previous_out;
}
| 1threat
|
av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
{
const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8;
if (avctx->lowres==1) {
c->idct_put = ff_jref_idct4_put;
c->idct_add = ff_jref_idct4_add;
c->idct = ff_j_rev_dct4;
c->perm_type = FF_IDCT_PERM_NONE;
} else if (avctx->lowres==2) {
c->idct_put = ff_jref_idct2_put;
c->idct_add = ff_jref_idct2_add;
c->idct = ff_j_rev_dct2;
c->perm_type = FF_IDCT_PERM_NONE;
} else if (avctx->lowres==3) {
c->idct_put = ff_jref_idct1_put;
c->idct_add = ff_jref_idct1_add;
c->idct = ff_j_rev_dct1;
c->perm_type = FF_IDCT_PERM_NONE;
} else {
if (avctx->bits_per_raw_sample == 10 || avctx->bits_per_raw_sample == 9) {
c->idct_put = ff_simple_idct_put_10;
c->idct_add = ff_simple_idct_add_10;
c->idct = ff_simple_idct_10;
c->perm_type = FF_IDCT_PERM_NONE;
} else if (avctx->bits_per_raw_sample == 12) {
c->idct_put = ff_simple_idct_put_12;
c->idct_add = ff_simple_idct_add_12;
c->idct = ff_simple_idct_12;
c->perm_type = FF_IDCT_PERM_NONE;
} else {
if (avctx->idct_algo == FF_IDCT_INT) {
c->idct_put = ff_jref_idct_put;
c->idct_add = ff_jref_idct_add;
c->idct = ff_j_rev_dct;
c->perm_type = FF_IDCT_PERM_LIBMPEG2;
#if CONFIG_FAANIDCT
} else if (avctx->idct_algo == FF_IDCT_FAAN) {
c->idct_put = ff_faanidct_put;
c->idct_add = ff_faanidct_add;
c->idct = ff_faanidct;
c->perm_type = FF_IDCT_PERM_NONE;
#endif
} else {
c->idct_put = ff_simple_idct_put_8;
c->idct_add = ff_simple_idct_add_8;
c->idct = ff_simple_idct_8;
c->perm_type = FF_IDCT_PERM_NONE;
}
}
}
c->put_pixels_clamped = put_pixels_clamped_c;
c->put_signed_pixels_clamped = put_signed_pixels_clamped_c;
c->add_pixels_clamped = add_pixels_clamped_c;
if (CONFIG_MPEG4_DECODER && avctx->idct_algo == FF_IDCT_XVID)
ff_xvid_idct_init(c, avctx);
if (ARCH_AARCH64)
ff_idctdsp_init_aarch64(c, avctx, high_bit_depth);
if (ARCH_ALPHA)
ff_idctdsp_init_alpha(c, avctx, high_bit_depth);
if (ARCH_ARM)
ff_idctdsp_init_arm(c, avctx, high_bit_depth);
if (ARCH_PPC)
ff_idctdsp_init_ppc(c, avctx, high_bit_depth);
if (ARCH_X86)
ff_idctdsp_init_x86(c, avctx, high_bit_depth);
if (ARCH_MIPS)
ff_idctdsp_init_mips(c, avctx, high_bit_depth);
ff_put_pixels_clamped = c->put_pixels_clamped;
ff_add_pixels_clamped = c->add_pixels_clamped;
ff_init_scantable_permutation(c->idct_permutation,
c->perm_type);
}
| 1threat
|
static void clear_program(MpegTSContext *ts, unsigned int programid)
{
int i;
clear_avprogram(ts, programid);
for(i=0; i<ts->nb_prg; i++)
if(ts->prg[i].id == programid)
ts->prg[i].nb_pids = 0;
}
| 1threat
|
Haskell: Variable not in scope : <p>I have a code as:</p>
<pre><code>main = interact $ show . maxsubseq . map read . words
maxsubseq :: (Ord a,Num a) => [a] -> (a,[a])
maxsubseq = snd . foldl f ((0,[]),(0,[])) where
f ((h1,h2),sofar) x = (a,b) where
a = max (0,[]) (h1 + x ,h2 ++ [x])
b = max sofar a
</code></pre>
<p>But I am getting error:</p>
<pre><code>maxSub.hs:6:17: error: Variable not in scope: h1
maxSub.hs:6:22: error: Variable not in scope: x
maxSub.hs:6:25: error: Variable not in scope: h2 :: [t1]
maxSub.hs:6:32: error: Variable not in scope: x
maxSub.hs:7:9: error: Variable not in scope: sofar :: (t, [t1])
</code></pre>
<p>Not able to figure out why??</p>
<p>Any ideas??</p>
<p>Thanks.</p>
| 0debug
|
static av_unused FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx,
const int16_t *audio,
const int16_t *la,
int channel, int prev_type)
{
int i, j;
int br = ctx->avctx->bit_rate / ctx->avctx->channels;
int attack_ratio = br <= 16000 ? 18 : 10;
AacPsyContext *pctx = (AacPsyContext*) ctx->model_priv_data;
AacPsyChannel *pch = &pctx->ch[channel];
uint8_t grouping = 0;
int next_type = pch->next_window_seq;
FFPsyWindowInfo wi = { { 0 } };
if (la) {
float s[8], v;
int switch_to_eight = 0;
float sum = 0.0, sum2 = 0.0;
int attack_n = 0;
int stay_short = 0;
for (i = 0; i < 8; i++) {
for (j = 0; j < 128; j++) {
v = iir_filter(la[i*128+j], pch->iir_state);
sum += v*v;
}
s[i] = sum;
sum2 += sum;
}
for (i = 0; i < 8; i++) {
if (s[i] > pch->win_energy * attack_ratio) {
attack_n = i + 1;
switch_to_eight = 1;
break;
}
}
pch->win_energy = pch->win_energy*7/8 + sum2/64;
wi.window_type[1] = prev_type;
switch (prev_type) {
case ONLY_LONG_SEQUENCE:
wi.window_type[0] = switch_to_eight ? LONG_START_SEQUENCE : ONLY_LONG_SEQUENCE;
next_type = switch_to_eight ? EIGHT_SHORT_SEQUENCE : ONLY_LONG_SEQUENCE;
break;
case LONG_START_SEQUENCE:
wi.window_type[0] = EIGHT_SHORT_SEQUENCE;
grouping = pch->next_grouping;
next_type = switch_to_eight ? EIGHT_SHORT_SEQUENCE : LONG_STOP_SEQUENCE;
break;
case LONG_STOP_SEQUENCE:
wi.window_type[0] = switch_to_eight ? LONG_START_SEQUENCE : ONLY_LONG_SEQUENCE;
next_type = switch_to_eight ? EIGHT_SHORT_SEQUENCE : ONLY_LONG_SEQUENCE;
break;
case EIGHT_SHORT_SEQUENCE:
stay_short = next_type == EIGHT_SHORT_SEQUENCE || switch_to_eight;
wi.window_type[0] = stay_short ? EIGHT_SHORT_SEQUENCE : LONG_STOP_SEQUENCE;
grouping = next_type == EIGHT_SHORT_SEQUENCE ? pch->next_grouping : 0;
next_type = switch_to_eight ? EIGHT_SHORT_SEQUENCE : LONG_STOP_SEQUENCE;
break;
}
pch->next_grouping = window_grouping[attack_n];
pch->next_window_seq = next_type;
} else {
for (i = 0; i < 3; i++)
wi.window_type[i] = prev_type;
grouping = (prev_type == EIGHT_SHORT_SEQUENCE) ? window_grouping[0] : 0;
}
wi.window_shape = 1;
if (wi.window_type[0] != EIGHT_SHORT_SEQUENCE) {
wi.num_windows = 1;
wi.grouping[0] = 1;
} else {
int lastgrp = 0;
wi.num_windows = 8;
for (i = 0; i < 8; i++) {
if (!((grouping >> i) & 1))
lastgrp = i;
wi.grouping[lastgrp]++;
}
}
return wi;
}
| 1threat
|
static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
{
int k, l;
int subsubframe = s->current_subsubframe;
const float *quant_step_table;
float (*subband_samples)[DCA_SUBBANDS][8] = s->subband_samples[block_index];
LOCAL_ALIGNED_16(int32_t, block, [8 * DCA_SUBBANDS]);
if (s->bit_rate_index == 0x1f)
quant_step_table = lossless_quant_d;
else
quant_step_table = lossy_quant_d;
for (k = base_channel; k < s->prim_channels; k++) {
float rscale[DCA_SUBBANDS];
if (get_bits_left(&s->gb) < 0)
return AVERROR_INVALIDDATA;
for (l = 0; l < s->vq_start_subband[k]; l++) {
int m;
int abits = s->bitalloc[k][l];
float quant_step_size = quant_step_table[abits];
int sel = s->quant_index_huffman[k][abits];
if (!abits) {
rscale[l] = 0;
memset(block + 8 * l, 0, 8 * sizeof(block[0]));
} else {
int sfi = s->transition_mode[k][l] && subsubframe >= s->transition_mode[k][l];
rscale[l] = quant_step_size * s->scale_factor[k][l][sfi] *
s->scalefactor_adj[k][sel];
if (abits >= 11 || !dca_smpl_bitalloc[abits].vlc[sel].table) {
if (abits <= 7) {
int block_code1, block_code2, size, levels, err;
size = abits_sizes[abits - 1];
levels = abits_levels[abits - 1];
block_code1 = get_bits(&s->gb, size);
block_code2 = get_bits(&s->gb, size);
err = decode_blockcodes(block_code1, block_code2,
levels, block + 8 * l);
if (err) {
av_log(s->avctx, AV_LOG_ERROR,
"ERROR: block code look-up failed\n");
return AVERROR_INVALIDDATA;
}
} else {
for (m = 0; m < 8; m++)
block[8 * l + m] = get_sbits(&s->gb, abits - 3);
}
} else {
for (m = 0; m < 8; m++)
block[8 * l + m] = get_bitalloc(&s->gb,
&dca_smpl_bitalloc[abits], sel);
}
}
}
s->fmt_conv.int32_to_float_fmul_array8(&s->fmt_conv, subband_samples[k][0],
block, rscale, 8 * s->vq_start_subband[k]);
for (l = 0; l < s->vq_start_subband[k]; l++) {
int m;
if (s->prediction_mode[k][l]) {
int n;
if (s->predictor_history)
subband_samples[k][l][0] += (adpcm_vb[s->prediction_vq[k][l]][0] *
s->subband_samples_hist[k][l][3] +
adpcm_vb[s->prediction_vq[k][l]][1] *
s->subband_samples_hist[k][l][2] +
adpcm_vb[s->prediction_vq[k][l]][2] *
s->subband_samples_hist[k][l][1] +
adpcm_vb[s->prediction_vq[k][l]][3] *
s->subband_samples_hist[k][l][0]) *
(1.0f / 8192);
for (m = 1; m < 8; m++) {
float sum = adpcm_vb[s->prediction_vq[k][l]][0] *
subband_samples[k][l][m - 1];
for (n = 2; n <= 4; n++)
if (m >= n)
sum += adpcm_vb[s->prediction_vq[k][l]][n - 1] *
subband_samples[k][l][m - n];
else if (s->predictor_history)
sum += adpcm_vb[s->prediction_vq[k][l]][n - 1] *
s->subband_samples_hist[k][l][m - n + 4];
subband_samples[k][l][m] += sum * 1.0f / 8192;
}
}
}
for (l = s->vq_start_subband[k]; l < s->subband_activity[k]; l++) {
int hfvq = s->high_freq_vq[k][l];
if (!s->debug_flag & 0x01) {
av_log(s->avctx, AV_LOG_DEBUG,
"Stream with high frequencies VQ coding\n");
s->debug_flag |= 0x01;
}
int8x8_fmul_int32(&s->dcadsp, subband_samples[k][l],
&high_freq_vq[hfvq][subsubframe * 8],
s->scale_factor[k][l][0]);
}
}
if (s->aspf || subsubframe == s->subsubframes[s->current_subframe] - 1) {
if (0xFFFF == get_bits(&s->gb, 16)) {
#ifdef TRACE
av_log(s->avctx, AV_LOG_DEBUG, "Got subframe DSYNC\n");
#endif
} else {
av_log(s->avctx, AV_LOG_ERROR, "Didn't get subframe DSYNC\n");
return AVERROR_INVALIDDATA;
}
}
for (k = base_channel; k < s->prim_channels; k++)
for (l = 0; l < s->vq_start_subband[k]; l++)
AV_COPY128(s->subband_samples_hist[k][l], &subband_samples[k][l][4]);
return 0;
}
| 1threat
|
static void vhost_log_put(struct vhost_dev *dev, bool sync)
{
struct vhost_log *log = dev->log;
if (!log) {
return;
}
dev->log = NULL;
dev->log_size = 0;
--log->refcnt;
if (log->refcnt == 0) {
if (dev->log_size && sync) {
vhost_log_sync_range(dev, 0, dev->log_size * VHOST_LOG_CHUNK - 1);
}
if (vhost_log == log) {
g_free(log->log);
vhost_log = NULL;
} else if (vhost_log_shm == log) {
qemu_memfd_free(log->log, log->size * sizeof(*(log->log)),
log->fd);
vhost_log_shm = NULL;
}
g_free(log);
}
}
| 1threat
|
MediaRecorder Corrupt Video Recording Samsung : <p>I am trying to run Google sample to record 10 second video using <code>MeadiaRecorder</code> inside my application. But when playing back recorder video it is getting corrupt.</p>
<ul>
<li>Firstly it plays full audio;</li>
<li>Then plays the first first frame of video;</li>
<li>Video freezes and nothing happening.</li>
</ul>
<p>When I browsed the file in explorer it was showing the length to 59 minutes whereas I only stored for 10 seconds and video is not playing as well when trying to play in computer as well.</p>
<p>I am using <a href="https://github.com/googlesamples/android-Camera2Video" rel="noreferrer">https://github.com/googlesamples/android-Camera2Video</a> library as a sample and running same code over the device without any change.</p>
<p>It working fine on all other device except for <strong>Samsung</strong> devices(J7, S5, S6, S8.. etc.)</p>
<p>In above library there is an <a href="https://github.com/googlesamples/android-Camera2Video/issues/24" rel="noreferrer">open issue</a> as well but still there's no solution provide.</p>
| 0debug
|
static int vfio_add_ext_cap(VFIOPCIDevice *vdev)
{
PCIDevice *pdev = &vdev->pdev;
uint32_t header;
uint16_t cap_id, next, size;
uint8_t cap_ver;
uint8_t *config;
config = g_memdup(pdev->config, vdev->config_size);
for (next = PCI_CONFIG_SPACE_SIZE; next;
next = PCI_EXT_CAP_NEXT(pci_get_long(config + next))) {
header = pci_get_long(config + next);
cap_id = PCI_EXT_CAP_ID(header);
cap_ver = PCI_EXT_CAP_VER(header);
size = vfio_ext_cap_max_size(config, next);
pcie_add_capability(pdev, cap_id, cap_ver, next, size);
pci_set_long(pdev->config + next, PCI_EXT_CAP(cap_id, cap_ver, 0));
pci_long_test_and_set_mask(vdev->emulated_config_bits + next,
PCI_EXT_CAP_NEXT_MASK);
}
g_free(config);
return 0;
}
| 1threat
|
IOT , Raspbarry pi, Windows IOT : I want to upload Arduino sketch via Raspberry pi using windows 10 IOT platform (Visual studio universal application), Hava anybody idea how to do this
Sketch from cloud > > > > Raspberry pi ------> Arduino
In this diagram sketch download from the cloud and via Rpi upload to Arduino.
| 0debug
|
void do_op_602_mfrom (void)
{
if (likely(T0 < 602)) {
#ifdef USE_MFROM_ROM_TABLE
#include "mfrom_table.c"
T0 = mfrom_ROM_table[T0];
#else
double d;
d = T0;
d = float64_div(d, 256, &env->fp_status);
d = float64_chs(d);
d = exp10(d);
d = float64_add(d, 1.0, &env->fp_status);
d = log10(d);
d = float64_mul(d, 256, &env->fp_status);
d = float64_add(d, 0.5, &env->fp_status);
T0 = float64_round_to_int(d, &env->fp_status);
#endif
} else {
T0 = 0;
}
}
| 1threat
|
static void celt_denormalize(CeltFrame *f, CeltBlock *block, float *data)
{
int i, j;
for (i = f->start_band; i < f->end_band; i++) {
float *dst = data + (ff_celt_freq_bands[i] << f->size);
float norm = exp2f(block->energy[i] + ff_celt_mean_energy[i]);
for (j = 0; j < ff_celt_freq_range[i] << f->size; j++)
dst[j] *= norm;
}
}
| 1threat
|
Recoding 0-3 values in STATA : I am working on my thesis and hit a road block. I have speech data set so here is how it is coded now:
Hypernasality (0-3)
Speech understandibility (0-3)
Speech Acceptability (0-3)
Where 0 is good 3 is severe deviation from normal speech.
Hypnasality (0 and 1)
Audible Air Emission (0 and 1)
Where 0 is none and 1 is yes
I recoded my data this way:
foreach j in speechunderstandibility speechacceptability hypernasality {
recode `j' (0 = 3) (3 = 0) (1 = 2) (2 = 1), gen (`j'_1)
}
foreach j in hyponasality audibleemission {
recode `j' (0 = 1) (1 = 0), gen (`j'_1)
}
However, when I run my regression it gives me counter intuitive results.
My dependent variable is speech outcome and beta of interest is cleft severity.
Results after recoding would say" Cleft severity improves speech but cleft surgery decreases it"
If I leave it the way it is coded then all 5 outcomes mentioned above have different outcomes.
I need them to go in one direction so I can build a summary index.
Please help me. I am pretty much desperate at this point.
| 0debug
|
How can I deal with the timezone issue with the Angular 4 date pipe? : <p>I have a date value in each of my objects that I can Print like this:</p>
<pre><code><td> {{competition.compStart }}</td>
</code></pre>
<p>And here is how it looks: </p>
<pre><code>1931-05-31T00:00:00.000+0000
</code></pre>
<p>In order to change the format to make it more readable I'm using the Angular date pipe: </p>
<pre><code><td> {{competition.compStart | date : "dd/MM/yyyy"}}</td>
</code></pre>
<p>With this result: </p>
<pre><code>30/05/1931
</code></pre>
<p>As you can see, It is displaying the previous day (May 30 instead of May 31).</p>
<p>As far as I understand, the problem is related to the timezone, since I'm in Argentina and we have GMT-3 then 00:00 of the 31st minus 3 hours would be May 30 at 9 PM.</p>
<p>So how can I make it take the time literally and not process it based on the timezone, but still apply the format in the pipe?</p>
| 0debug
|
CheckBox: Is it possible to change check symbol? : <p>Is is possible to change the "tick" in checkbox to "X" on selection of it?</p>
<p>If yes, then please let me know how can i get it working using anything like HTML,CSS,Kendo UI?</p>
<p>Thanks!</p>
| 0debug
|
Can someone help me with my Binary Search code please? : I don't konw what's wrong with this binary search code of mine. It seems fine to me, but always displaying "not found" in output. I don't know why. Can someone idenyify the problem?
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define SIZE 100
void binarySearch(int, int*);
int arr[SIZE];
int low = 0, high = SIZE - 1;
int main() {
int arr[SIZE] = { 10, 47, 67, 78, 95, 99 };
binarySearch(95, arr);
}
void binarySearch(int key, int *arr) {
if (arr[low] == key) {
puts("Found!");
return;
}
while (low <= high) {
int mid = low + (high - 1) / 2;
if (key == arr[mid]) {
printf("Data found at index: %d\n", mid);
return;
}
else if (key > arr[mid]) {
low = mid + 1;
}
else {
high = mid - 1;
}
}
puts("\nData not found!");
}
| 0debug
|
how can i convert this script of sqlserver to mysql with the same logic? : [enter image description here][1]
[1]: https://i.stack.imgur.com/VfLAV.png
i have this script in sqlserver but how can i use this logic to mySQL.. it has different syntax. thanks in advance for the help.
| 0debug
|
int monitor_get_fd(Monitor *mon, const char *fdname)
{
mon_fd_t *monfd;
LIST_FOREACH(monfd, &mon->fds, next) {
int fd;
if (strcmp(monfd->name, fdname) != 0) {
continue;
}
fd = monfd->fd;
LIST_REMOVE(monfd, next);
qemu_free(monfd->name);
qemu_free(monfd);
return fd;
}
return -1;
}
| 1threat
|
Hide a div element when other div is not found : <p>How can I hide a div element when a other div element with a specifiv ID is not found?</p>
<p>For example if this div is not found in the whole HTML-Code:</p>
<pre><code><div id="found">I'm here</div>
</code></pre>
<p>then hide following div:</p>
<pre><code><div id="hide-me">Hello World</div>
</code></pre>
<p>The best solution to solve this might be with a script</p>
| 0debug
|
expected expression before -return value- : <p>Given the following function:</p>
<pre><code>image_ret* minify_1(image_src img_src, CLIENT* cl) {
image_ret* img_ret;
magickminify_init();
magickminify(img_src.image_src_val, img_src.image_src_len, (ssize_t*)&img_ret->image_ret_len);
return image_ret;
}
</code></pre>
<p>The compiler is telling me "expected expression before ‘image_ret’" with regard to the last line. I'm sure I'm missing some fundamental aspect of syntax here, but I don't know what. Lil' help?</p>
| 0debug
|
static void adaptive_gain_control(float *out, const float *in,
const float *speech_synth,
int size, float alpha, float *gain_mem)
{
int i;
float speech_energy = 0.0, postfilter_energy = 0.0, gain_scale_factor;
float mem = *gain_mem;
for (i = 0; i < size; i++) {
speech_energy += fabsf(speech_synth[i]);
postfilter_energy += fabsf(in[i]);
}
gain_scale_factor = (1.0 - alpha) * speech_energy / postfilter_energy;
for (i = 0; i < size; i++) {
mem = alpha * mem + gain_scale_factor;
out[i] = in[i] * mem;
}
*gain_mem = mem;
}
| 1threat
|
I need to replace specific words in a string with the words defined as values in my hash : [My Attempt][1]
[1]: https://i.stack.imgur.com/NnKvI.png
I've been stuck on this exercise for some time now, i need some help on getting the desired output. The aim is to replace specific words in a string by the values defined in the dictionary. I would really appreciate the help and also could you explain it in laymans terms. I am a bit new to Ruby and coding in general. Hopefully, I'll get the hang of it!, You can see my code on the picture attached.
| 0debug
|
Cyrillic / Russian characters SQL Server : Im getting data in Cyrillic formats (russian characters) and loaded perfectly in tables with nvarchar datatype. But i have a function which will convert cyrillic into english. That function on table to be applied on fields if its containing russian characters.
Please help.
| 0debug
|
required variable , found value (beginer) : [ in the if statement is returning as unexpected type– required: variable found: value. I tried == and that obviously didn't work. Any insight?][1]
[1]: https://i.stack.imgur.com/HxORP.png
| 0debug
|
performance issue while running the web project using tomact : I have build a environment on my laptop in which I build the tomcat server on my main OS (Windows 7) and Oracle server on Virtual Machine using VMWare on Linux OS (Redhat 5).
Now, When I am running my project, tomcat keeps loading the page and shows "waiting for localhost.." It takes 2-3 mins to load the dynamic page (which contain oracle data) however, static pages load very fast. I think it takes time to connect the VM Machine (Database Server).
Can you please suggest how to resolve this problem? What could be the problem
| 0debug
|
static void check_reserved_space (target_phys_addr_t *start,
target_phys_addr_t *length)
{
target_phys_addr_t begin = *start;
target_phys_addr_t end = *start + *length;
if (end >= 0x1e000000LL && end < 0x1f100000LL)
end = 0x1e000000LL;
if (begin >= 0x1e000000LL && begin < 0x1f100000LL)
begin = 0x1f100000LL;
if (end >= 0x1fc00000LL && end < 0x1fd00000LL)
end = 0x1fc00000LL;
if (begin >= 0x1fc00000LL && begin < 0x1fd00000LL)
begin = 0x1fd00000LL;
if (end >= 0x1f100000LL && begin < 0x1e000000LL)
end = 0x1e000000LL;
if (end >= 0x1fd00000LL && begin < 0x1fc00000LL)
end = 0x1fc00000LL;
*start = begin;
*length = end - begin;
}
| 1threat
|
void syscall_init(void)
{
IOCTLEntry *ie;
const argtype *arg_type;
int size;
int i;
#define STRUCT(name, list...) thunk_register_struct(STRUCT_ ## name, #name, struct_ ## name ## _def);
#define STRUCT_SPECIAL(name) thunk_register_struct_direct(STRUCT_ ## name, #name, &struct_ ## name ## _def);
#include "syscall_types.h"
#undef STRUCT
#undef STRUCT_SPECIAL
ie = ioctl_entries;
while (ie->target_cmd != 0) {
if (((ie->target_cmd >> TARGET_IOC_SIZESHIFT) & TARGET_IOC_SIZEMASK) ==
TARGET_IOC_SIZEMASK) {
arg_type = ie->arg_type;
if (arg_type[0] != TYPE_PTR) {
fprintf(stderr, "cannot patch size for ioctl 0x%x\n",
ie->target_cmd);
exit(1);
}
arg_type++;
size = thunk_type_size(arg_type, 0);
ie->target_cmd = (ie->target_cmd &
~(TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT)) |
(size << TARGET_IOC_SIZESHIFT);
}
for (i=0; i < ERRNO_TABLE_SIZE; i++)
target_to_host_errno_table[host_to_target_errno_table[i]] = i;
#if defined(__i386__) && defined(TARGET_I386) && defined(TARGET_ABI32)
if (ie->target_cmd != ie->host_cmd) {
fprintf(stderr, "ERROR: ioctl: target=0x%x host=0x%x\n",
ie->target_cmd, ie->host_cmd);
}
#endif
ie++;
}
}
| 1threat
|
static int dnxhd_decode_dct_block_10(const DNXHDContext *ctx,
RowContext *row, int n)
{
return dnxhd_decode_dct_block(ctx, row, n, 6, 8, 4);
}
| 1threat
|
Docker ip for windows : <p>I'm testing out Docker with a basic .NET core project. I Build and image from this docker file: </p>
<pre><code>FROM microsoft/dotnet:latest
COPY . /app
WORKDIR /app/API
RUN ["dotnet", "restore"]
RUN ["dotnet", "build"]
EXPOSE 5000/tcp
CMD ["dotnet", "run", "--server.urls", "http://*:5000"]
</code></pre>
<p>I run it and it goes flawlessly. Now the only problem is, on what IP is it running ?</p>
<p>I'm running Docker on Windows!</p>
<p>Regards</p>
| 0debug
|
error: expected primary-expression before ‘slide’ : <p>I am learning C++ but stuck now. The program of mine is showing the error</p>
<pre><code>error: expected primary-expression before ‘slide’
</code></pre>
<p>I referred <a href="https://stackoverflow.com/questions/11507607/c-expected-primary-expression-before">this</a> but it didn't help!</p>
<pre><code>#include <iostream>
#include <string>
#include <limits.h>
using namespace std;
int minSwapsHelper(string slide, int n){
int noOfGirls;
for(int i = 0; slide[i]!='\0'; i++){
if(slide[i] == 'G'){
noOfGirls++;
}
}
int tempNoOfGirls = noOfGirls, maxNoOfGirls = INT_MIN;
int noOfGirlsAtEachItr[n]={0};
if(slide[0] == 'G'){
noOfGirlsAtEachItr[0] = 1;
}
for(int i = 0; i< n; i++){
if(slide[i] == 'G'){
noOfGirlsAtEachItr[i] = noOfGirlsAtEachItr[i-1] + 1;
}
else{
noOfGirlsAtEachItr[i]= noOfGirlsAtEachItr[i-1];
}
}
for(int i = tempNoOfGirls- 1; i < n; i++){
if(i == (tempNoOfGirls - 1))
noOfGirls = noOfGirlsAtEachItr[i];
else
noOfGirls = noOfGirlsAtEachItr[i] - noOfGirlsAtEachItr[i - tempNoOfGirls];
if(maxNoOfGirls < noOfGirls){
maxNoOfGirls = noOfGirls;
}
}
int noOfBoys = tempNoOfGirls - maxNoOfGirls;
return noOfBoys;
}
int minSwapsToWin(string slide){
/*int i = 0;
while(slide[i] != '\0'){
i++;
}
int lengthOfString = i;*/
int lengthOfString = slide.length();
return minSwapsHelper(string slide, lengthOfString);
}
int main(){
string slide = "BBGBGBG";
cout<<minSwapsToWin(slide)<<"\n";
return 0;
}
</code></pre>
<p>The problem that I have the code the solution for is as follows:</p>
<blockquote>
<p>Problem: </p>
<p>In a school, the students were playing a game. Initially
everyone is standing in a circular path in the school lawn. The
student at index 1 is standing next to student at index n and before
the student at index 2. All the girls need to stand together to win
the game. The girls had influencial power to influence the boys to
swap the positions. Help the Girls decide the minimum number of swaps
they have to do so that all of them stand together. </p>
<p>Input:BBGBGBG Output:1 Explanation: we can swap the G at index 3 with
B at index 6 to get all B and G together.</p>
<p>Input:BGBGGB Output:1 Explanation: we can swap B at index 3 with G at
index 2 to get all B and G together.</p>
</blockquote>
| 0debug
|
calling template nonstatic method from partially specialized template method : <p>The following <code>method</code> call fails because it is declared as non-static function. I don't understand why. </p>
<pre><code>struct Test
{
template<typename T> method(){return T();}
template<typename S> struct W;
template<> struct W<int>
{
int meth()
{
return method<int>(); // method can't be called this way
}
};
};
</code></pre>
| 0debug
|
Check if value in list ignoring the last few chars : <p>I have a list of files (some ends with _HHMMss.<strong>* where *</strong> is the extension).</p>
<p>I want to check if a specific file exist in the list ignoring the "_HHMMss", means:
if I have a list:</p>
<pre><code>A_Log_YYYY_MM_DD_121122.csv
B_Log_YYYY_MM_DD_112211.csv
C_Log_YYYY_MM_DD_333333.csv
D_Log_YYYY_MM_DD_555555.csv
E_Log_YYYY_MM_DD_777765.csv
</code></pre>
<p>check if "A_Log_YYYY_MM_DD.csv" exist, the answer in this case is TRUE
Is there a fast way to do that?</p>
| 0debug
|
One Definition Rule - Multiple definition of inline functions : <p>I was reading ODR and as the rule says <code>"In the entire program, an object or non-inline function cannot have more than one definition"</code> and I tried the following...</p>
<p>file1.cpp</p>
<pre><code>#include <iostream>
using namespace std;
inline int func1(void){ return 5; }
inline int func2(void){ return 6; }
inline int func3(void){ return 7; }
int sum(void);
int main(int argc, char *argv[])
{
cout << func1() << endl;
cout << func2() << endl;
cout << func3() << endl;
cout << sum() << endl;
return 0;
}
</code></pre>
<p>file2.cpp</p>
<pre><code>inline int func1(void) { return 5; }
inline int func2(void) { return 6; }
inline int func3(void) { return 7; }
int sum(void) { return func1() + func2() + func3(); }
</code></pre>
<p>It worked as the rule says. I can have multiple definition of inline functions. </p>
<ul>
<li>What is the difference between non-inline function linkage and inline function linkage?</li>
<li>How the linker differentiate between these two?</li>
</ul>
| 0debug
|
static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int i;
char header[MAX_FRAME_HEADER+1];
int ret;
int64_t off = avio_tell(s->pb);
for (i = 0; i < MAX_FRAME_HEADER; i++) {
header[i] = avio_r8(s->pb);
if (header[i] == '\n') {
header[i + 1] = 0;
break;
}
}
if (s->pb->error)
return s->pb->error;
else if (s->pb->eof_reached)
return AVERROR_EOF;
else if (i == MAX_FRAME_HEADER)
return AVERROR_INVALIDDATA;
if (strncmp(header, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC)))
return AVERROR_INVALIDDATA;
ret = av_get_packet(s->pb, pkt, s->packet_size - Y4M_FRAME_MAGIC_LEN);
if (ret < 0)
return ret;
else if (ret != s->packet_size - Y4M_FRAME_MAGIC_LEN)
return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);
pkt->stream_index = 0;
pkt->pts = (off - s->internal->data_offset) / s->packet_size;
pkt->duration = 1;
return 0;
}
| 1threat
|
void bdrv_init(void)
{
bdrv_register(&bdrv_raw);
bdrv_register(&bdrv_host_device);
bdrv_register(&bdrv_cow);
bdrv_register(&bdrv_qcow);
bdrv_register(&bdrv_vmdk);
bdrv_register(&bdrv_cloop);
bdrv_register(&bdrv_dmg);
bdrv_register(&bdrv_bochs);
bdrv_register(&bdrv_vpc);
bdrv_register(&bdrv_vvfat);
bdrv_register(&bdrv_qcow2);
bdrv_register(&bdrv_parallels);
bdrv_register(&bdrv_nbd);
}
| 1threat
|
Javascript HTML Redirect : <p>Code Purpose Question</p>
<p>I am trying to determine the purpose of the line:
window.location = "<a href="https://google.com" rel="nofollow noreferrer">https://google.com</a>";</p>
<pre><code><<!-- For IE <= 9 -->
<!--[if IE]>
<script type="text/javascript">
window.location = "https://google.com";
</script>
<![endif]-->
<!-- For IE > 9 -->
<script type="text/javascript">
if (window.navigator.msPointerEnabled) {
window.location = "http://bobabend.com/index-old-as-of-3-7-2019.html";
}
</code></pre>
| 0debug
|
DriveInfo *drive_init(QemuOpts *opts, BlockInterfaceType block_default_type)
{
const char *buf;
const char *file = NULL;
const char *serial;
const char *mediastr = "";
BlockInterfaceType type;
enum { MEDIA_DISK, MEDIA_CDROM } media;
int bus_id, unit_id;
int cyls, heads, secs, translation;
BlockDriver *drv = NULL;
int max_devs;
int index;
int ro = 0;
int bdrv_flags = 0;
int on_read_error, on_write_error;
const char *devaddr;
DriveInfo *dinfo;
BlockIOLimit io_limits;
int snapshot = 0;
bool copy_on_read;
int ret;
translation = BIOS_ATA_TRANSLATION_AUTO;
media = MEDIA_DISK;
bus_id = qemu_opt_get_number(opts, "bus", 0);
unit_id = qemu_opt_get_number(opts, "unit", -1);
index = qemu_opt_get_number(opts, "index", -1);
cyls = qemu_opt_get_number(opts, "cyls", 0);
heads = qemu_opt_get_number(opts, "heads", 0);
secs = qemu_opt_get_number(opts, "secs", 0);
snapshot = qemu_opt_get_bool(opts, "snapshot", 0);
ro = qemu_opt_get_bool(opts, "readonly", 0);
copy_on_read = qemu_opt_get_bool(opts, "copy-on-read", false);
file = qemu_opt_get(opts, "file");
serial = qemu_opt_get(opts, "serial");
if ((buf = qemu_opt_get(opts, "if")) != NULL) {
for (type = 0; type < IF_COUNT && strcmp(buf, if_name[type]); type++)
;
if (type == IF_COUNT) {
error_report("unsupported bus type '%s'", buf);
return NULL;
}
} else {
type = block_default_type;
}
max_devs = if_max_devs[type];
if (cyls || heads || secs) {
if (cyls < 1) {
error_report("invalid physical cyls number");
return NULL;
}
if (heads < 1) {
error_report("invalid physical heads number");
return NULL;
}
if (secs < 1) {
error_report("invalid physical secs number");
return NULL;
}
}
if ((buf = qemu_opt_get(opts, "trans")) != NULL) {
if (!cyls) {
error_report("'%s' trans must be used with cyls, heads and secs",
buf);
return NULL;
}
if (!strcmp(buf, "none"))
translation = BIOS_ATA_TRANSLATION_NONE;
else if (!strcmp(buf, "lba"))
translation = BIOS_ATA_TRANSLATION_LBA;
else if (!strcmp(buf, "auto"))
translation = BIOS_ATA_TRANSLATION_AUTO;
else {
error_report("'%s' invalid translation type", buf);
return NULL;
}
}
if ((buf = qemu_opt_get(opts, "media")) != NULL) {
if (!strcmp(buf, "disk")) {
media = MEDIA_DISK;
} else if (!strcmp(buf, "cdrom")) {
if (cyls || secs || heads) {
error_report("CHS can't be set with media=%s", buf);
return NULL;
}
media = MEDIA_CDROM;
} else {
error_report("'%s' invalid media", buf);
return NULL;
}
}
bdrv_flags |= BDRV_O_CACHE_WB;
if ((buf = qemu_opt_get(opts, "cache")) != NULL) {
if (bdrv_parse_cache_flags(buf, &bdrv_flags) != 0) {
error_report("invalid cache option");
return NULL;
}
}
#ifdef CONFIG_LINUX_AIO
if ((buf = qemu_opt_get(opts, "aio")) != NULL) {
if (!strcmp(buf, "native")) {
bdrv_flags |= BDRV_O_NATIVE_AIO;
} else if (!strcmp(buf, "threads")) {
} else {
error_report("invalid aio option");
return NULL;
}
}
#endif
if ((buf = qemu_opt_get(opts, "format")) != NULL) {
if (is_help_option(buf)) {
error_printf("Supported formats:");
bdrv_iterate_format(bdrv_format_print, NULL);
error_printf("\n");
return NULL;
}
drv = bdrv_find_whitelisted_format(buf);
if (!drv) {
error_report("'%s' invalid format", buf);
return NULL;
}
}
io_limits.bps[BLOCK_IO_LIMIT_TOTAL] =
qemu_opt_get_number(opts, "bps", 0);
io_limits.bps[BLOCK_IO_LIMIT_READ] =
qemu_opt_get_number(opts, "bps_rd", 0);
io_limits.bps[BLOCK_IO_LIMIT_WRITE] =
qemu_opt_get_number(opts, "bps_wr", 0);
io_limits.iops[BLOCK_IO_LIMIT_TOTAL] =
qemu_opt_get_number(opts, "iops", 0);
io_limits.iops[BLOCK_IO_LIMIT_READ] =
qemu_opt_get_number(opts, "iops_rd", 0);
io_limits.iops[BLOCK_IO_LIMIT_WRITE] =
qemu_opt_get_number(opts, "iops_wr", 0);
if (!do_check_io_limits(&io_limits)) {
error_report("bps(iops) and bps_rd/bps_wr(iops_rd/iops_wr) "
"cannot be used at the same time");
return NULL;
}
if (qemu_opt_get(opts, "boot") != NULL) {
fprintf(stderr, "qemu-kvm: boot=on|off is deprecated and will be "
"ignored. Future versions will reject this parameter. Please "
"update your scripts.\n");
}
on_write_error = BLOCKDEV_ON_ERROR_ENOSPC;
if ((buf = qemu_opt_get(opts, "werror")) != NULL) {
if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) {
error_report("werror is not supported by this bus type");
return NULL;
}
on_write_error = parse_block_error_action(buf, 0);
if (on_write_error < 0) {
return NULL;
}
}
on_read_error = BLOCKDEV_ON_ERROR_REPORT;
if ((buf = qemu_opt_get(opts, "rerror")) != NULL) {
if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) {
error_report("rerror is not supported by this bus type");
return NULL;
}
on_read_error = parse_block_error_action(buf, 1);
if (on_read_error < 0) {
return NULL;
}
}
if ((devaddr = qemu_opt_get(opts, "addr")) != NULL) {
if (type != IF_VIRTIO) {
error_report("addr is not supported by this bus type");
return NULL;
}
}
if (index != -1) {
if (bus_id != 0 || unit_id != -1) {
error_report("index cannot be used with bus and unit");
return NULL;
}
bus_id = drive_index_to_bus_id(type, index);
unit_id = drive_index_to_unit_id(type, index);
}
if (unit_id == -1) {
unit_id = 0;
while (drive_get(type, bus_id, unit_id) != NULL) {
unit_id++;
if (max_devs && unit_id >= max_devs) {
unit_id -= max_devs;
bus_id++;
}
}
}
if (max_devs && unit_id >= max_devs) {
error_report("unit %d too big (max is %d)",
unit_id, max_devs - 1);
return NULL;
}
if (drive_get(type, bus_id, unit_id) != NULL) {
error_report("drive with bus=%d, unit=%d (index=%d) exists",
bus_id, unit_id, index);
return NULL;
}
dinfo = g_malloc0(sizeof(*dinfo));
if ((buf = qemu_opts_id(opts)) != NULL) {
dinfo->id = g_strdup(buf);
} else {
dinfo->id = g_malloc0(32);
if (type == IF_IDE || type == IF_SCSI)
mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd";
if (max_devs)
snprintf(dinfo->id, 32, "%s%i%s%i",
if_name[type], bus_id, mediastr, unit_id);
else
snprintf(dinfo->id, 32, "%s%s%i",
if_name[type], mediastr, unit_id);
}
dinfo->bdrv = bdrv_new(dinfo->id);
dinfo->bdrv->open_flags = snapshot ? BDRV_O_SNAPSHOT : 0;
dinfo->bdrv->read_only = ro;
dinfo->devaddr = devaddr;
dinfo->type = type;
dinfo->bus = bus_id;
dinfo->unit = unit_id;
dinfo->cyls = cyls;
dinfo->heads = heads;
dinfo->secs = secs;
dinfo->trans = translation;
dinfo->opts = opts;
dinfo->refcount = 1;
dinfo->serial = serial;
QTAILQ_INSERT_TAIL(&drives, dinfo, next);
bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error);
bdrv_set_io_limits(dinfo->bdrv, &io_limits);
switch(type) {
case IF_IDE:
case IF_SCSI:
case IF_XEN:
case IF_NONE:
dinfo->media_cd = media == MEDIA_CDROM;
break;
case IF_SD:
case IF_FLOPPY:
case IF_PFLASH:
case IF_MTD:
break;
case IF_VIRTIO:
opts = qemu_opts_create_nofail(qemu_find_opts("device"));
if (arch_type == QEMU_ARCH_S390X) {
qemu_opt_set(opts, "driver", "virtio-blk-s390");
} else {
qemu_opt_set(opts, "driver", "virtio-blk-pci");
}
qemu_opt_set(opts, "drive", dinfo->id);
if (devaddr)
qemu_opt_set(opts, "addr", devaddr);
break;
default:
abort();
}
if (!file || !*file) {
return dinfo;
}
if (snapshot) {
bdrv_flags &= ~BDRV_O_CACHE_MASK;
bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH);
}
if (copy_on_read) {
bdrv_flags |= BDRV_O_COPY_ON_READ;
}
if (runstate_check(RUN_STATE_INMIGRATE)) {
bdrv_flags |= BDRV_O_INCOMING;
}
if (media == MEDIA_CDROM) {
ro = 1;
} else if (ro == 1) {
if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY &&
type != IF_NONE && type != IF_PFLASH) {
error_report("readonly not supported by this bus type");
goto err;
}
}
bdrv_flags |= ro ? 0 : BDRV_O_RDWR;
if (ro && copy_on_read) {
error_report("warning: disabling copy_on_read on readonly drive");
}
ret = bdrv_open(dinfo->bdrv, file, bdrv_flags, drv);
if (ret < 0) {
if (ret == -EMEDIUMTYPE) {
error_report("could not open disk image %s: not in %s format",
file, drv->format_name);
} else {
error_report("could not open disk image %s: %s",
file, strerror(-ret));
}
goto err;
}
if (bdrv_key_required(dinfo->bdrv))
autostart = 0;
return dinfo;
err:
bdrv_delete(dinfo->bdrv);
g_free(dinfo->id);
QTAILQ_REMOVE(&drives, dinfo, next);
g_free(dinfo);
return NULL;
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.