problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
Are there performance gains in using ES6 Arrow Functions? : <p>The new arrow functions in ES6, are like one-liner functions which make code more clean and concise, and also allow you to keep the scope of the caller inside the function, so that you don’t need to do things like <code>var _this = this;</code>, or use the <code>bind</code> function etc.</p>
<p>Are there any significant performance gains in using ES6 arrow functions over plain javascript functions? </p>
| 0debug |
How to encrypt the value in base64 encoded value in PHP : Here i am using file upload,here i did base64 encode image upto **$encodeimage = base64_encode(file_get_contents($filename));//here we got encodede image value** now i got answer,after that i want to encrypt the base64 encoded value,i am writing below code but i can't get encrypt value?
<!-- begin snippet: js hide: false console: true -->
<!-- language: lang-js -->
<?php
require_once 'Security.php';
define ("MAX_SIZE","1000");
$errors=0;
$image =$_FILES["file"]["name"];//i got filename here
$uploadedfile = $_FILES['file']['tmp_name'];
$filetype = $_FILES['file']['type'];
if ($image)
{
$filename = stripslashes($_FILES['file']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
{
$error_msg = ' Unknown Image extension ';
$errors=1;
}
else{
$size=filesize($_FILES['file']['tmp_name']);
if ($size > MAX_SIZE*1024)
{
$error_msg = "You have exceeded the size limit";
$errors=1;
}
if($extension=="jpg" || $extension=="jpeg" )
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
}
else if($extension=="png")
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefrompng($uploadedfile);
}
else
{
$src = imagecreatefromgif($uploadedfile);
}
list($width,$height)=getimagesize($uploadedfile);
$newwidth=600;
/*$newheight=($height/$width)*$newwidth;*/
$newheight=600;
$tmp=imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$filename = $_FILES['file']['name'];
imagejpeg($tmp,$filename,100);
$encodeimage = base64_encode(file_get_contents($filename));//here we got encodede image value
$encrypt_image = "data:".$filetype."base64,".$encodeimage;
$security = new Security();
/*$string = $_POST['user_string'];*/
$publicKey = $security->genRandString(32);
$encryptedData = $security->encrypt($encrypt_image, $publicKey);
imagedestroy($src);
imagedestroy($tmp);
}
}
function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
$id_proof = array("filename" =>$filename,
"base64_encodeimage" =>$encrypt_image,
"encryptedData" => $encryptedData,//getting null value here
"error_msg" =>$error_msg
);
echo json_encode($id_proof);
?>
----------
**Security.php**
<?php
class Security {
// Private key
public static $salt = 'Lu70K$i3pu5xf7*I8tNmd@x2oODwwDRr4&xjuyTh';
// Encrypt a value using AES-256.
public static function encrypt($plain, $key, $hmacSalt = null) {
self::_checkKey($key, 'encrypt()');
if ($hmacSalt === null) {
$hmacSalt = self::$salt;
}
$key = substr(hash('sha256', $key . $hmacSalt), 0, 32); # Generate the encryption and hmac key
$algorithm = MCRYPT_RIJNDAEL_128; # encryption algorithm
$mode = MCRYPT_MODE_CBC; # encryption mode
$ivSize = mcrypt_get_iv_size($algorithm, $mode); # Returns the size of the IV belonging to a specific cipher/mode combination
$iv = mcrypt_create_iv($ivSize, MCRYPT_DEV_URANDOM); # Creates an initialization vector (IV) from a random source
$ciphertext = $iv . mcrypt_encrypt($algorithm, $key, $plain, $mode, $iv); # Encrypts plaintext with given parameters
$hmac = hash_hmac('sha256', $ciphertext, $key); # Generate a keyed hash value using the HMAC method
return $hmac . $ciphertext;
}
// Check key
protected static function _checkKey($key, $method) {
if (strlen($key) < 32) {
echo "Invalid public key $key, key must be at least 256 bits (32 bytes) long."; die();
}
}
// Decrypt a value using AES-256.
public static function decrypt($cipher, $key, $hmacSalt = null) {
self::_checkKey($key, 'decrypt()');
if (empty($cipher)) {
echo 'The data to decrypt cannot be empty.'; die();
}
if ($hmacSalt === null) {
$hmacSalt = self::$salt;
}
$key = substr(hash('sha256', $key . $hmacSalt), 0, 32); # Generate the encryption and hmac key.
// Split out hmac for comparison
$macSize = 64;
$hmac = substr($cipher, 0, $macSize);
$cipher = substr($cipher, $macSize);
$compareHmac = hash_hmac('sha256', $cipher, $key);
if ($hmac !== $compareHmac) {
return false;
}
$algorithm = MCRYPT_RIJNDAEL_128; # encryption algorithm
$mode = MCRYPT_MODE_CBC; # encryption mode
$ivSize = mcrypt_get_iv_size($algorithm, $mode); # Returns the size of the IV belonging to a specific cipher/mode combination
$iv = substr($cipher, 0, $ivSize);
$cipher = substr($cipher, $ivSize);
$plain = mcrypt_decrypt($algorithm, $key, $cipher, $mode, $iv);
return rtrim($plain, "\0");
}
//Get Random String - Usefull for public key
public function genRandString($length = 0) {
$charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$str = '';
$count = strlen($charset);
while ($length-- > 0) {
$str .= $charset[mt_rand(0, $count-1)];
}
return $str;
}
}
<!-- end snippet -->
| 0debug |
static void qmp_output_type_enum(Visitor *v, int *obj, const char *strings[],
const char *kind, const char *name,
Error **errp)
{
int i = 0;
int value = *obj;
char *enum_str;
assert(strings);
while (strings[i++] != NULL);
if (value >= i - 1) {
error_set(errp, QERR_INVALID_PARAMETER, name ? name : "null");
return;
}
enum_str = (char *)strings[value];
qmp_output_type_str(v, &enum_str, name, errp);
}
| 1threat |
I want to change scale of visualViewport. How can I achieve this pragmatically? : <p>I want to change scale of <code>visualViewport</code>. I want to control zoom pragmatically on certain condition. How can I achieve this?</p>
| 0debug |
Java Simple program using Loop structure : <p>Sample input : 3456
Sample output :
Digits : 3, 4, 5, 6
Sum : 18</p>
<p>This is the code that I had try, but unfortunately it is wrong since i do not use loop.Please anybody can help me?</p>
<pre><code>import java.util.Scanner;
public class Lab1_5 {
public static void main (String args[])
{
int insert1, insert2, insert3, insert4;
int sum ;
Scanner console = new Scanner(System.in);
System.out.print("Please enter First Number: ");
insert1 =console.nextInt();
System.out.print("Please enter Second Number: ");
insert2 =console.nextInt();
System.out.print("Please enter Third Number: ");
insert3 =console.nextInt();
System.out.print("Please enter Fourth Number: ");
insert4 =console.nextInt();
System.out.println("Digits: "+ insert1+","+insert2+","+insert3+","+insert4);
sum = insert1+insert2+insert3+insert4;
System.out.print("Sum: "+ sum);
}
}
</code></pre>
| 0debug |
JAVA - Format a custom string using SimpleDateFormat : <p>I'm having trouble formatting a custom String back to a Date object. What i have:</p>
<pre><code>String customString = "October 14, 2015;
Date date = new Date();
SimpleDateFormat s = new SimpleDateFormat("MM-dd-yyyy");
try {
date = s.parse(customString);
} catch (ParseException e) {
e.printStackTrace();
}
</code></pre>
<p>I always get a unappeasable date exception. Any pointers of what i'm doing wrong is appreciated.</p>
| 0debug |
How can i solved this problem in laravel? : [![Result][1]][1]
[enter image description here][2]
[![enter image description here][3]][3]
[enter image description here][4]
[![enter image description here][5]][5]
[1]: https://i.stack.imgur.com/hKpQa.png
[2]: https://i.stack.imgur.com/QBVJ0.png
[3]: https://i.stack.imgur.com/oQhju.png
[4]: https://i.stack.imgur.com/jltK7.png
[5]: https://i.stack.imgur.com/smaSR.png | 0debug |
Docker on a linux VM, performances? : <p>I would like to know what Docker on VM implies regarding the performances, will I have issue ? </p>
<p>To me, adding a "layer" would decrease the performances. Is it right or wrong and most importantly, why ?</p>
<p>I want to be able to know what is the best way to deal with new projects when containers are on the line. </p>
<p>Thanks in advance :)</p>
| 0debug |
How can I fix this bug in tline 7 of the program below.It keeps returning syntax error : def cube(number):
return number*number*number
def by_three(number):
if number % 3==0:
cube(number)
return number
else:
return False | 0debug |
Find Rang of substring in NSMutableAttributedString : <p>I have AttributedString with emoji like this "🤣🤣🤣 @Mervin tester 🤣🤣🤣"</p>
<p>Now I need to find a range of Mervin in this attributed String. </p>
<pre><code>let attributedString = NSMutableAttributedString(string: "🤣🤣🤣 @Mervin tester 🤣🤣🤣")
let range = // range for "Mervin" in above String.
</code></pre>
<p>Thank you. </p>
| 0debug |
All UNIQUE permentations : I'm finding lots of algorithms to get every permutation of a set of numbers. What I can't find is one that gives a UNIQUE list.
For example, the digits **123** will produce:
123
132
213
231
312
321
But the digits **113** should only produce (skipping the duplicates):
113
131
311
If it helps, I'll be using 8 digits in an array.
Thanks | 0debug |
Pandas to_sql doesn't insert any data in my table : <p>I am trying to insert some data in a table I have created.
I have a data frame that looks like this:</p>
<p><a href="https://i.stack.imgur.com/mslic.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mslic.png" alt="dataframe"></a></p>
<p>I created a table:</p>
<pre><code>create table online.ds_attribution_probabilities
(
attribution_type text,
channel text,
date date ,
value float
)
</code></pre>
<p>And I am running this python script:</p>
<pre><code>engine = create_engine("postgresql://@e.eu-central-1.redshift.amazonaws.com:5439/mdhclient_encoding=utf8")
connection = engine.raw_connection()
result.to_sql('online.ds_attribution_probabilities', con=engine, index = False, if_exists = 'append')
</code></pre>
<p>I get no error, but when I check there are no data in my table. What can be wrong? Do I have to commit or do an extra step?</p>
| 0debug |
List all installed programs on windows using PHP : <p>How can I list all installed programs in windows using php or how can I search for a installed program in windows using php?</p>
| 0debug |
static int do_co_pwrite_zeroes(BlockBackend *blk, int64_t offset,
int64_t count, int flags, int64_t *total)
{
Coroutine *co;
CoWriteZeroes data = {
.blk = blk,
.offset = offset,
.count = count,
.total = total,
.flags = flags,
.done = false,
};
if (count >> BDRV_SECTOR_BITS > INT_MAX) {
return -ERANGE;
}
co = qemu_coroutine_create(co_pwrite_zeroes_entry);
qemu_coroutine_enter(co, &data);
while (!data.done) {
aio_poll(blk_get_aio_context(blk), true);
}
if (data.ret < 0) {
return data.ret;
} else {
return 1;
}
}
| 1threat |
Vue.js label for an input element inside loop : <p>How would you set up the input <code>id</code> and the label <code>for</code> on repeated input elements so they are unique, using Vue.js v2.</p>
<pre><code><section class="section" v-for="(section, i) in sections">
<div class="fields">
<fieldset>
<input type="checkbox" id="" name="example-a" v-model="section.ex-a">
<label for="">Example A</label>
</fieldset>
<fieldset>
<label for="">Example B</label>
<input type="text" id="" name="example-b" v-model="section.ex-b">
</fieldset>
<fieldset>
<label for="">Example C</label>
<input type="text" id="" name="example-c" v-model="section.ex-c">
</fieldset>
</div>
</section>
</code></pre>
<p>I want to be able to click on the label element and have it select the input field.</p>
| 0debug |
static void pci_unin_config_writel (void *opaque, target_phys_addr_t addr,
uint32_t val)
{
UNINState *s = opaque;
s->config_reg = val;
}
| 1threat |
void pcie_host_mmcfg_map(PCIExpressHost *e, hwaddr addr,
uint32_t size)
{
assert(!(size & (size - 1)));
assert(size >= PCIE_MMCFG_SIZE_MIN);
assert(size <= PCIE_MMCFG_SIZE_MAX);
e->size = size;
memory_region_init_io(&e->mmio, OBJECT(e), &pcie_mmcfg_ops, e,
"pcie-mmcfg", e->size);
e->base_addr = addr;
memory_region_add_subregion(get_system_memory(), e->base_addr, &e->mmio);
}
| 1threat |
What's the benefit of a fixture with function scope and no teardown code? : <p>What's advantage of a (default) function-scope fixture without teardown code? Why not just call the function at the beginning of the test?</p>
<p>For example, what's the benefit of writing:</p>
<pre><code>@pytest.fixture
def smtp():
return smtplib.SMTP("smtp.gmail.com")
def test_ehlo(smtp):
response, msg = smtp.ehlo()
# ...
</code></pre>
<p>instead of simply:</p>
<pre><code>def create_smtp():
return smtplib.SMTP("smtp.gmail.com")
def test_ehlo():
smtp = create_smtp()
response, msg = smtp.ehlo()
# ...
</code></pre>
<p>I understand why fixtures are useful when we need teardown code. I also understand why fixtures with scope other than function are useful: we may want to reuse the same "external" object in multiple tests (to save the time it takes to create it; or perhaps even to maintain its state -- although that seems to be rather dangerous since this creates an hard-to-see coupling between separate tests).</p>
| 0debug |
static coroutine_fn int sd_co_discard(BlockDriverState *bs, int64_t sector_num,
int nb_sectors)
{
SheepdogAIOCB *acb;
QEMUIOVector dummy;
BDRVSheepdogState *s = bs->opaque;
int ret;
if (!s->discard_supported) {
return 0;
}
acb = sd_aio_setup(bs, &dummy, sector_num, nb_sectors);
acb->aiocb_type = AIOCB_DISCARD_OBJ;
acb->aio_done_func = sd_finish_aiocb;
retry:
if (check_overwrapping_aiocb(s, acb)) {
qemu_co_queue_wait(&s->overwrapping_queue);
goto retry;
}
ret = sd_co_rw_vector(acb);
if (ret <= 0) {
QLIST_REMOVE(acb, aiocb_siblings);
qemu_co_queue_restart_all(&s->overwrapping_queue);
qemu_aio_unref(acb);
return ret;
}
qemu_coroutine_yield();
QLIST_REMOVE(acb, aiocb_siblings);
qemu_co_queue_restart_all(&s->overwrapping_queue);
return acb->ret;
}
| 1threat |
Zoom image on hover : <p>How can I make a image in my social feed to zoom when I hover over it.</p>
<p>similar to the instagram feed on the left in <a href="http://defiance-theme.tumblr.com" rel="nofollow">this site</a>.</p>
<p>I tried this in the hover css:</p>
<pre><code>opacity: 0.5;
filter: alpha(opacity=50);
</code></pre>
<p>but I couldn't get it to zoom.</p>
| 0debug |
static TCGArg do_constant_folding_2(int op, TCGArg x, TCGArg y)
{
switch (op) {
CASE_OP_32_64(add):
return x + y;
CASE_OP_32_64(sub):
return x - y;
CASE_OP_32_64(mul):
return x * y;
CASE_OP_32_64(and):
return x & y;
CASE_OP_32_64(or):
return x | y;
CASE_OP_32_64(xor):
return x ^ y;
case INDEX_op_shl_i32:
return (uint32_t)x << (uint32_t)y;
#if TCG_TARGET_REG_BITS == 64
case INDEX_op_shl_i64:
return (uint64_t)x << (uint64_t)y;
#endif
case INDEX_op_shr_i32:
return (uint32_t)x >> (uint32_t)y;
#if TCG_TARGET_REG_BITS == 64
case INDEX_op_shr_i64:
return (uint64_t)x >> (uint64_t)y;
#endif
case INDEX_op_sar_i32:
return (int32_t)x >> (int32_t)y;
#if TCG_TARGET_REG_BITS == 64
case INDEX_op_sar_i64:
return (int64_t)x >> (int64_t)y;
#endif
#ifdef TCG_TARGET_HAS_rot_i32
case INDEX_op_rotr_i32:
#if TCG_TARGET_REG_BITS == 64
x &= 0xffffffff;
y &= 0xffffffff;
#endif
x = (x << (32 - y)) | (x >> y);
return x;
#endif
#ifdef TCG_TARGET_HAS_rot_i64
#if TCG_TARGET_REG_BITS == 64
case INDEX_op_rotr_i64:
x = (x << (64 - y)) | (x >> y);
return x;
#endif
#endif
#ifdef TCG_TARGET_HAS_rot_i32
case INDEX_op_rotl_i32:
#if TCG_TARGET_REG_BITS == 64
x &= 0xffffffff;
y &= 0xffffffff;
#endif
x = (x << y) | (x >> (32 - y));
return x;
#endif
#ifdef TCG_TARGET_HAS_rot_i64
#if TCG_TARGET_REG_BITS == 64
case INDEX_op_rotl_i64:
x = (x << y) | (x >> (64 - y));
return x;
#endif
#endif
#if defined(TCG_TARGET_HAS_not_i32) || defined(TCG_TARGET_HAS_not_i64)
#ifdef TCG_TARGET_HAS_not_i32
case INDEX_op_not_i32:
#endif
#ifdef TCG_TARGET_HAS_not_i64
case INDEX_op_not_i64:
#endif
return ~x;
#endif
#if defined(TCG_TARGET_HAS_ext8s_i32) || defined(TCG_TARGET_HAS_ext8s_i64)
#ifdef TCG_TARGET_HAS_ext8s_i32
case INDEX_op_ext8s_i32:
#endif
#ifdef TCG_TARGET_HAS_ext8s_i64
case INDEX_op_ext8s_i64:
#endif
return (int8_t)x;
#endif
#if defined(TCG_TARGET_HAS_ext16s_i32) || defined(TCG_TARGET_HAS_ext16s_i64)
#ifdef TCG_TARGET_HAS_ext16s_i32
case INDEX_op_ext16s_i32:
#endif
#ifdef TCG_TARGET_HAS_ext16s_i64
case INDEX_op_ext16s_i64:
#endif
return (int16_t)x;
#endif
#if defined(TCG_TARGET_HAS_ext8u_i32) || defined(TCG_TARGET_HAS_ext8u_i64)
#ifdef TCG_TARGET_HAS_ext8u_i32
case INDEX_op_ext8u_i32:
#endif
#ifdef TCG_TARGET_HAS_ext8u_i64
case INDEX_op_ext8u_i64:
#endif
return (uint8_t)x;
#endif
#if defined(TCG_TARGET_HAS_ext16u_i32) || defined(TCG_TARGET_HAS_ext16u_i64)
#ifdef TCG_TARGET_HAS_ext16u_i32
case INDEX_op_ext16u_i32:
#endif
#ifdef TCG_TARGET_HAS_ext16u_i64
case INDEX_op_ext16u_i64:
#endif
return (uint16_t)x;
#endif
#if TCG_TARGET_REG_BITS == 64
#ifdef TCG_TARGET_HAS_ext32s_i64
case INDEX_op_ext32s_i64:
return (int32_t)x;
#endif
#ifdef TCG_TARGET_HAS_ext32u_i64
case INDEX_op_ext32u_i64:
return (uint32_t)x;
#endif
#endif
default:
fprintf(stderr,
"Unrecognized operation %d in do_constant_folding.\n", op);
tcg_abort();
}
}
| 1threat |
static void tcg_out_movi(TCGContext *s, TCGType type,
TCGReg ret, tcg_target_long arg)
{
tcg_target_long hi, lo;
if (check_fit_tl(arg, 13)) {
tcg_out_movi_imm13(s, ret, arg);
return;
}
if (type == TCG_TYPE_I32 || arg == (uint32_t)arg) {
tcg_out_sethi(s, ret, arg);
if (arg & 0x3ff) {
tcg_out_arithi(s, ret, ret, arg & 0x3ff, ARITH_OR);
}
return;
}
if (check_fit_tl(arg, 32)) {
tcg_out_sethi(s, ret, ~arg);
tcg_out_arithi(s, ret, ret, (arg & 0x3ff) | -0x400, ARITH_XOR);
return;
}
lo = (int32_t)arg;
if (check_fit_tl(lo, 13)) {
hi = (arg - lo) >> 32;
tcg_out_movi(s, TCG_TYPE_I32, ret, hi);
tcg_out_arithi(s, ret, ret, 32, SHIFT_SLLX);
tcg_out_arithi(s, ret, ret, lo, ARITH_ADD);
} else {
hi = arg >> 32;
tcg_out_movi(s, TCG_TYPE_I32, ret, hi);
tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_T2, lo);
tcg_out_arithi(s, ret, ret, 32, SHIFT_SLLX);
tcg_out_arith(s, ret, ret, TCG_REG_T2, ARITH_OR);
}
}
| 1threat |
Why would the union of an empty set with another set results in an empty set in python? : <pre><code>a = set()
b = set([1,2])
print a.union(b)
</code></pre>
<p>The result is an empty set. But if a is not an empty set, the result is correct.</p>
| 0debug |
Verify that an exception is thrown using Mocha / Chai and async/await : <p>I'm struggling to work out the best way to verify that a promise is rejected in a Mocha test while using async/await.</p>
<p>Here's an example that works, but I dislike that <code>should.be.rejectedWith</code> returns a promise that needs to be returned from the test function to be evaluated properly. Using async/await removes this requirement for testing values (as I do for the result of <code>wins()</code> below), and I feel that it is likely that I will forget the return statement at some point, in which case the test will always pass.</p>
<pre><code>// Always succeeds
function wins() {
return new Promise(function(resolve, reject) {
resolve('Winner');
});
}
// Always fails with an error
function fails() {
return new Promise(function(resolve, reject) {
reject('Contrived Error');
});
}
it('throws an error', async () => {
let r = await wins();
r.should.equal('Winner');
return fails().should.be.rejectedWith('Contrived Error');
});
</code></pre>
<p>It feels like it should be possible to use the fact that async/await translates rejections to exceptions and combine that with Chai's should.throw, but I haven't been able to determine the correct syntax.</p>
<p>Ideally this would work, but does not seem to:</p>
<pre><code>it('throws an error', async () => {
let r = await wins();
r.should.equal('Winner');
(await fails()).should.throw(Error);
});
</code></pre>
| 0debug |
What are the constraints on the user using STL's parallel algorithms? : <p>At the Jacksonville meeting the proposal <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2016/p0024r2.html" rel="noreferrer">P0024r2</a> effectively adopting the specifications from the <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4354.pdf" rel="noreferrer">Parallelism TS</a> was accepted into the <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2016/n4604.pdf" rel="noreferrer">C++17 (draft)</a>. This proposal adds overloads for many of the algorithms taking an <em>execution policy</em> argument to indicate what kind of parallelism should be considered. There are three execution policies already defined in <code><execution></code> (20.19.2 [execution]):</p>
<ul>
<li><code>std::execution::sequenced_policy</code> (20.19.4 [execpol.seq]) with a <code>constexpr</code> object <code>std::execution::seq</code> (20.19.7 [parallel.execpol.objects]) to indicate sequential execution similar to calling the algorithms without an execution policy.</li>
<li><code>std::execution::parallel_policy</code> (20.19.5 [execpol.par]) with a <code>constexpr</code> object <code>std::execution::par</code> (20.19.7 [parallel.execpol.objects]) to indicate execution of algorithms potentially using multiple threads.</li>
<li><code>std::execution::parallel_unsequenced_policy</code> (20.19.6 [execpol.vec]) with a <code>constexpr</code> object <code>std::execution::par_unseq</code> (20.19.7 [parallel.execpol.objects])to indicate execution of algorithms potentially using vector execution and/or multiple threads.</li>
</ul>
<p>The STL algorithms generally take user-defined objects (iterators, function objects) as arguments. <strong>What are the constraints on user-defined objects to make them usable with the parallel algorithms using the standard execution policies?</strong></p>
<p>For example, when using an algorithm like in the example below, what are the implications for <code>FwdIt</code> and <code>Predicate</code>?</p>
<pre><code>template <typename FwdIt, typename Predicate>
FwdIt call_remove_if(FwdIt begin, FwdIt end, Predicate predicate) {
return std::remove_if(std::execution::par, begin, end, predicate);
}
</code></pre>
| 0debug |
void helper_fcmp_eq_DT(CPUSH4State *env, float64 t0, float64 t1)
{
int relation;
set_float_exception_flags(0, &env->fp_status);
relation = float64_compare(t0, t1, &env->fp_status);
if (unlikely(relation == float_relation_unordered)) {
update_fpscr(env, GETPC());
} else {
env->sr_t = (relation == float_relation_equal);
}
}
| 1threat |
gcc bug? It inexplicably decays array to pointer, while clang does not : <p>This is a simplified version which illustrate the problem:</p>
<pre><code>struct Foo {
Foo() = default;
template <std::size_t N>
Foo(const char(&)[N]) {}
};
template <std::size_t N>
auto foo(const char (&arr)[N]) -> Foo
{
return arr;
}
auto main() -> int
{
foo("Stack Overflow");
}
</code></pre>
<p>g++ seems to decay <code>arr</code> to <code>const char *</code>, although an array reference argument is passed to an array reference parameter . It gives this error:</p>
<blockquote>
<p>In instantiation of <code>Foo foo(const char (&)[N]) [with long unsigned
int N = 4ul]</code>:</p>
<p>error: could not convert <code>(const char*)arr</code> from <code>const char*</code> to
<code>Foo</code></p>
<pre><code> return arr;
^
</code></pre>
</blockquote>
<p>While clang++ behaves how I expect and compiles the code.</p>
<p>The code compiles fine on gcc with any of those modifications:</p>
<pre><code>return {arr};
return Foo(arr);
return (Foo)arr;
return static_cast<Foo>(arr);
</code></pre>
<p>Is it a gcc bug?</p>
<p>Tried it with <del>all</del> g++ and clang++ versions which support <code>c++14</code>.(*)</p>
<p>(*) I just tried it with a snapshot of <code>gcc 6</code> and it compiles OK. So it does look like a bug fixed in <code>gcc 6</code></p>
| 0debug |
Make all properties within a Typescript interface optional : <p>I have an interface in my application:</p>
<pre><code>interface Asset {
id: string;
internal_id: string;
usage: number;
}
</code></pre>
<p>that is part of a post interface:</p>
<pre><code>interface Post {
asset: Asset;
}
</code></pre>
<p>I also have an interface that is for a post draft, where the asset object might only be partially constructed</p>
<pre><code>interface PostDraft {
asset: Asset;
}
</code></pre>
<p>I want to allow a <code>PostDraft</code> object to have a partial asset object while still checking types on the properties that are there (so I don't want to just swap it out with <code>any</code>). </p>
<p>I basically want a way to be able to generate the following:</p>
<pre><code>interface AssetDraft {
id?: string;
internal_id?: string;
usage?: number;
}
</code></pre>
<p>without entirely re-defining the <code>Asset</code> interface. Is there a way to do this? If not, what would the smart way to arrange my types in this situation be?</p>
| 0debug |
How to get the list of all available timezone using moment-timezone : <p>I am trying to get the list of all the available timezones using moment-timezone in node js like this - </p>
<pre><code>var moment = require('moment-timezone');
var timeZones = moment.tz.names();
console.log(timeZones);
</code></pre>
<p>I am getting the timezones in this format - </p>
<pre><code>'Europe/Mariehamn',
'Europe/Minsk',
'Europe/Monaco',
'Europe/Moscow',
'Europe/Nicosia',
'Europe/Oslo',
'Europe/Paris',
'Europe/Podgorica',
'Europe/Prague',
'Europe/Riga',
'Europe/Rome',
</code></pre>
<p>But I want to get the timezones in this format - </p>
<pre><code>(GMT +01:00) Africa/Brazzaville
(GMT +01:00) Africa/Casablanca
(GMT +01:00) Africa/Douala
(GMT +01:00) Africa/El_Aaiun
(GMT +01:00) Africa/Kinshasa
(GMT +01:00) Africa/Lagos
(GMT +01:00) Africa/Libreville
(GMT +01:00) Africa/Luanda
(GMT +01:00) Africa/Malabo
(GMT +01:00) Africa/Ndjamena
(GMT +01:00) Africa/Niamey
</code></pre>
<p>How do I get ?</p>
| 0debug |
Jquery menu code is not rendering : I am using Jquery ui,i have added links to the Javascript files(jquery ui.min,jquery-ui.css) in the (head) section, however when i apply jquery to the menu(#shMenu).It doesn't render.What are my doing wrong ?
<!doctype html>
<html>
<head>
<meta charset = "UTF-8">
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<link rel = "stylesheet" href = "css/jquery-ui.min.css" style type = "text/css">
<script src = "js/jquery-ui.min.js"></script>
</head>
<style type = "text/css">
.highlight{background-color:yellow;
}
#wrapper {
width:500px;
margin:auto;
}
.ui-menu {
width:15em;
}
#cartDiv {
border-style:solid;
border-width:5px;
}
</style>
<body>
<div id = "wrapper">
<ul id = "shMenu">
<li><a href = "Javascript:void(0)">Super Heroes</a>
<ul>
<li><a href = "Javascript:void(0)">Hulk</a></li>
<li><a href = "Javascript:void(0)">Batman</a></li>
<li><a href = "Javascript:void(0)">Spider-Man</a></li>
</li><a href = "Javascript:void(0)">Thor</a></li>
</ul>
</li>
<li><a href = "Javascript:void(0)">Comic Books</a>
<ul>
<li><a href = "Javascript:void(0)">Hulk</a></li>
<li><a href = "Javascript:void(0)">Batman</a></li>
<li><a href = "Javascript:void(0)">Spider-Man</a></li>
<li><a href = "Javascript:void(0)">Thor</a></li>
</ul>
</li>
</ul><br/>
<div id = "accordion">
<h3>Batman</h3>
<div>
A young Bruce Wayne (Christian Bale) travels to the Far East,
where he's trained in the martial arts by Henri Ducard (Liam Neeson),
a member of the mysterious League of Shadows. When Ducard reveals the League's true purpose
-- the complete destruction of Gotham City -- Wayne returns to Gotham intent on cleaning up the city without resorting to murder.
With the help of Alfred (Michael Caine), his loyal butler, and Lucius Fox (Morgan Freeman),
a tech expert at Wayne Enterprises, Batman is born.
</div>
<h3>Thor</h3>
<div>
As the son of Odin (Anthony Hopkins), king of the Norse gods,
Thor (Chris Hemsworth) will soon inherit the throne of Asgard from his aging
father. However, on the day that he is to be crowned, Thor reacts with brutality when the gods' enemies,
the Frost Giants, enter the palace in violation of their treaty. As punishment, Odin banishes Thor to Earth. While Loki (Tom Hiddleston),
Thor's brother, plots mischief in Asgard,
Thor, now stripped of his powers, faces his greatest threat..
</div>
<h3>SpiderMan</h3>
<div>
"Spider-Man" centers on student Peter Parker (Tobey Maguire) who,
after being bitten by a genetically-altered spider, gains superhuman
strength and the spider-like ability to cling to any surface. He vows
to use his abilities to fight crime, coming to understand the words of his
beloved Uncle Ben:
"With great power comes great responsibility."
</div>
<div id = "shTabs">
<ul>
<li><a href = "#ironman">Ironman</a></li>
<li><a href = "#hulk">Hulk</a></li>
<li><a href = "#thor">thor</a></li>
<li><a href = "#spiderman">SpiderMan</a></li>
</ul>
</div>
<div id = "ironman">
A billionaire industrialist and genius inventor, Tony Stark (Robert Downey Jr.),
is conducting weapons tests overseas, but terrorists kidnap him to force him to build a devastating
weapon. Instead, he builds an armored suit and upends his captors. Returning to America,
Stark refines the suit and uses it to combat crime and terrorism.
</div>
<div id = "hulk">
Eric Bana ("Black Hawk Down") stars as scientist Bruce Banner,
whose inner demons transform him in the aftermath of a catastrophic experiment;
Jennifer Connelly portrays Betty Ross, whose scientific genius unwittingly helps unleash the Hulk;
Nick Nolte plays Banner's brilliant father, who passes on a tragic legacy to his son; and Sam Elliott
portrays the commander of a top-secret military research center.
</div>
<div id = "thor">
As the son of Odin (Anthony Hopkins), king of the Norse gods,
Thor (Chris Hemsworth) will soon inherit the throne of Asgard from his aging
father. However, on the day that he is to be crowned, Thor reacts with brutality when the gods' enemies,
the Frost Giants, enter the palace in violation of their treaty. As punishment, Odin banishes Thor to Earth. While Loki (Tom Hiddleston),
Thor's brother, plots mischief in Asgard,
Thor, now stripped of his powers, faces his greatest threat..
</div>
<div id = "spiderman">
"Spider-Man" centers on student Peter Parker (Tobey Maguire) who,
after being bitten by a genetically-altered spider, gains superhuman
strength and the spider-like ability to cling to any surface. He vows
to use his abilities to fight crime, coming to understand the words of his
beloved Uncle Ben:
"With great power comes great responsibility."
</div>
<div></br>
<div id = "customDialog" title = "custom Dialog">
<p>A random dialog box that contains important information</p>
</div>
<a href = "Javascript:void(0)" id = "openDialog" title = "Open Dialog Box">Open Dialog</a><br/><br/>
<script type = "text/javascript">
$('document').ready(function() {
$("#shMenu").menu({
position: {
my: "center top"
at: "center bottom"
};
});
});
</script>
</div>
</body>
</html> | 0debug |
static double compute_target_time(double frame_current_pts, VideoState *is)
{
double delay, sync_threshold, diff;
delay = frame_current_pts - is->frame_last_pts;
if (delay <= 0 || delay >= 10.0) {
delay = is->frame_last_delay;
} else {
is->frame_last_delay = delay;
}
is->frame_last_pts = frame_current_pts;
if (((is->av_sync_type == AV_SYNC_AUDIO_MASTER && is->audio_st) ||
is->av_sync_type == AV_SYNC_EXTERNAL_CLOCK)) {
diff = get_video_clock(is) - get_master_clock(is);
sync_threshold = FFMAX(AV_SYNC_THRESHOLD, delay);
if (fabs(diff) < AV_NOSYNC_THRESHOLD) {
if (diff <= -sync_threshold)
delay = 0;
else if (diff >= sync_threshold)
delay = 2 * delay;
}
}
is->frame_timer += delay;
av_log(NULL, AV_LOG_TRACE, "video: delay=%0.3f pts=%0.3f A-V=%f\n",
delay, frame_current_pts, -diff);
return is->frame_timer;
}
| 1threat |
Hello i"ve trying to build a simple login page for my project : **My view**
def login(request):
c = {}
c.update(csrf(request))
return render_to_response(request,
'login.html', c)
def auth_view(request):
username = request.POST.get
('username', '')
password = request.POST.get
('password', '')
user = auth.authenticate
(username = username, password =
password)
if user is not None:
auth.login(request,user)
if request.method == 'POST':
return HttpResponseRedirect('accounts/loggedin/')
else:
Retun HttpResponseRedirect('accounts/invalid/')
Error occurs that fuction auth_view return nothing.. i'm stuck
| 0debug |
static AVStream *add_av_stream1(FFServerStream *stream,
AVCodecContext *codec, int copy)
{
AVStream *fst;
if(stream->nb_streams >= FF_ARRAY_ELEMS(stream->streams))
return NULL;
fst = av_mallocz(sizeof(AVStream));
if (!fst)
return NULL;
if (copy) {
fst->codec = avcodec_alloc_context3(codec->codec);
if (!fst->codec) {
av_free(fst);
return NULL;
}
avcodec_copy_context(fst->codec, codec);
} else
fst->codec = codec;
fst->priv_data = av_mallocz(sizeof(FeedData));
fst->index = stream->nb_streams;
avpriv_set_pts_info(fst, 33, 1, 90000);
fst->sample_aspect_ratio = codec->sample_aspect_ratio;
stream->streams[stream->nb_streams++] = fst;
return fst;
} | 1threat |
db.execute('SELECT * FROM employees WHERE id = ' + user_input) | 1threat |
static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
int n, int coded, int intra)
{
int level, i, last, run;
int dc_pred_dir;
RLTable * rl;
RL_VLC_ELEM * rl_vlc;
const UINT8 * scan_table;
int qmul, qadd;
if(intra) {
if(s->partitioned_frame){
level = s->dc_val[0][ s->block_index[n] ];
if(n<4) level= (level + (s->y_dc_scale>>1))/s->y_dc_scale;
else level= (level + (s->c_dc_scale>>1))/s->c_dc_scale;
dc_pred_dir= (s->pred_dir_table[s->mb_x + s->mb_y*s->mb_width]<<n)&32;
}else{
level = mpeg4_decode_dc(s, n, &dc_pred_dir);
if (level < 0)
return -1;
}
block[0] = level;
i = 0;
if (!coded)
goto not_coded;
rl = &rl_intra;
rl_vlc = rl_intra.rl_vlc[0];
if (s->ac_pred) {
if (dc_pred_dir == 0)
scan_table = s->intra_v_scantable.permutated;
else
scan_table = s->intra_h_scantable.permutated;
} else {
scan_table = s->intra_scantable.permutated;
}
qmul=1;
qadd=0;
} else {
i = -1;
if (!coded) {
s->block_last_index[n] = i;
return 0;
}
rl = &rl_inter;
scan_table = s->intra_scantable.permutated;
if(s->mpeg_quant){
qmul=1;
qadd=0;
rl_vlc = rl_inter.rl_vlc[0];
}else{
qmul = s->qscale << 1;
qadd = (s->qscale - 1) | 1;
rl_vlc = rl_inter.rl_vlc[s->qscale];
}
}
{
OPEN_READER(re, &s->gb);
for(;;) {
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2);
if (level==0) {
int cache;
cache= GET_CACHE(re, &s->gb);
if (cache&0x80000000) {
if (cache&0x40000000) {
SKIP_CACHE(re, &s->gb, 2);
last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
run= SHOW_UBITS(re, &s->gb, 6); LAST_SKIP_CACHE(re, &s->gb, 6);
SKIP_COUNTER(re, &s->gb, 2+1+6);
UPDATE_CACHE(re, &s->gb);
if(SHOW_UBITS(re, &s->gb, 1)==0){
fprintf(stderr, "1. marker bit missing in 3. esc\n");
return -1;
}; SKIP_CACHE(re, &s->gb, 1);
level= SHOW_SBITS(re, &s->gb, 12); SKIP_CACHE(re, &s->gb, 12);
if(SHOW_UBITS(re, &s->gb, 1)==0){
fprintf(stderr, "2. marker bit missing in 3. esc\n");
return -1;
}; LAST_SKIP_CACHE(re, &s->gb, 1);
SKIP_COUNTER(re, &s->gb, 1+12+1);
if(level*s->qscale>1024 || level*s->qscale<-1024){
fprintf(stderr, "|level| overflow in 3. esc, qp=%d\n", s->qscale);
return -1;
}
#if 1
{
const int abs_level= ABS(level);
if(abs_level<=MAX_LEVEL && run<=MAX_RUN && ((s->workaround_bugs&FF_BUG_AC_VLC)==0)){
const int run1= run - rl->max_run[last][abs_level] - 1;
if(abs_level <= rl->max_level[last][run]){
fprintf(stderr, "illegal 3. esc, vlc encoding possible\n");
return -1;
}
if(abs_level <= rl->max_level[last][run]*2){
fprintf(stderr, "illegal 3. esc, esc 1 encoding possible\n");
return -1;
}
if(run1 >= 0 && abs_level <= rl->max_level[last][run1]){
fprintf(stderr, "illegal 3. esc, esc 2 encoding possible\n");
return -1;
}
}
}
#endif
if (level>0) level= level * qmul + qadd;
else level= level * qmul - qadd;
i+= run + 1;
if(last) i+=192;
} else {
#if MIN_CACHE_BITS < 20
LAST_SKIP_BITS(re, &s->gb, 2);
UPDATE_CACHE(re, &s->gb);
#else
SKIP_BITS(re, &s->gb, 2);
#endif
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2);
i+= run + rl->max_run[run>>7][level/qmul] +1;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
}
} else {
#if MIN_CACHE_BITS < 19
LAST_SKIP_BITS(re, &s->gb, 1);
UPDATE_CACHE(re, &s->gb);
#else
SKIP_BITS(re, &s->gb, 1);
#endif
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2);
i+= run;
level = level + rl->max_level[run>>7][(run-1)&63] * qmul;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
}
} else {
i+= run;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
}
if (i > 62){
i-= 192;
if(i&(~63)){
fprintf(stderr, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
block[scan_table[i]] = level;
break;
}
block[scan_table[i]] = level;
}
CLOSE_READER(re, &s->gb);
}
not_coded:
if (s->mb_intra) {
mpeg4_pred_ac(s, block, n, dc_pred_dir);
if (s->ac_pred) {
i = 63;
}
}
s->block_last_index[n] = i;
return 0;
}
| 1threat |
Aggregating records with two main IDs in [VBA makro] : that's my first question on stackoverflow. :)
Recently I want to make a **makro** in **VBA** that will make smaller version of excel doc. I was thinking about sorting all records and then making "for each" loops, but it looks pretty hard with my level of knowledge.
So, there is a excel sheet with two main IDs which make records different.
I want to make it as small as possible. On my example there is a ID_1 which is main key, ID_2 from which we will need only 2 first signs (I used LEFT formula for this and it worked fine). From columns "A" to "J" we have "raw data" from "M" to "U" we have data which I want to get.
So, with this example -> We have 6 records **1015** (ID_1) with 3 different ID_2 (**AB**, **AZ**, **AE**). I want to sum them up to a one cell each (**1015 AB** ; **1015 AZ** ;**1015 AE**) with values which each record had (there is 3 records: **1015 AB** with VALUE of 2,3,4 so in result I want to get just one row **1015 AB** **9**(sum of *value*) **4**(sum of *count*) **17** (sum of(*value* * *count*)). It's important to see that this **17** dosn't come from **9 * 4**. It's =sum(I4:I6) (but it may be spread out like in **1200 FF** example below! I am still trying to sort them both at one time, but I cant get past it..)
[enter image description here][1]
I look forward to your answer or idea how to make it faster. I hope that I make it clear or at least that you can see it from the picture :)
If you have any questions, do not hesitate, I will try to answer :)
Have a nice day,
Kei
[1]: https://i.stack.imgur.com/C7nOM.png | 0debug |
Pycharm to show current working branch name : <p>When viewing VCS window in Pycharm IDE, I have no idea what <em>git local branch</em> I'm working on as well as its mapped <em>git remote branch</em>.</p>
<p>So how to show <strong>current working branch name</strong> in Pycharm?</p>
<p>p.s.</p>
<p>I'm using PyCharm Community Edition 2016.2</p>
| 0debug |
Perl duplicates xml tags : I'm a beginner in Perl (and in programming) and I have some problems with a script. I have tried by several ways to do what I want but there was always problems. So I want to start from scratch (again...) but I'm running out of ideas !
I need a script that will duplicate XML tags on an XML file, and add attributes to some of them. I know it could be easier with an XSLT but I need the script to ask if it has to duplicate tags or not, for each tag matched.
Here is a small and simple example of what I start with :
<?xml version="1.0" encoding="UTF-8"?>
<article>
<section>
<title>title</title>
<para>text</para>
<mediaobject>
<imageobject>
<imagedata fileref="filename.png" format="PNG"/>
</imageobject>
</mediaobject>
<para>text</para>
</section>
</article>
...and what I want after passing the script :
<?xml version="1.0" encoding="UTF-8"?>
<article>
<section>
<title>title</title>
<para>text</para>
<mediaobject>
<imageobject arch="html;fo;fo-print">
<imagedata fileref="filename.png" format="PNG"/>
</imageobject>
<imageobject arch="screen">
<imagedata fileref="filename.png" format="PNG" width="100%"/>
</imageobject>
</mediaobject>
</section>
</article>
For each image tag encounter (that correspond to the group : `<imageobject><imagedata fileref="filename.png" format="PNG"/></imageobject>`), I need the script to ask me if this group of tags have to be duplicate or not. If yes, it is duplicate and attributes @arch and @width are added. If not, the script ask for the next group of tag matched.
Which parser can I use ? XML::LibXML ? If yes, how does it work ?
The XML files has to be external of the script and it would be nice if I could apply the script to several files.
I hope it is clear... If anyone has an idea how I can do this, or advices, it could help me a lot !
Thanks in advance. | 0debug |
How to disable request logging in Django and uWSGI? : <p>My uWSGI logs are full of entries like this for every request:</p>
<blockquote>
<p>localhost [pid: 4029|app: 0|req: 1/1] 127.0.0.1 () {48 vars in 906
bytes} [Wed Mar 23 18:35:38 2016] GET / => generated 94847 bytes in
1137 msecs (HTTP/1.1 200) 4 headers in 224 bytes (1 switches on core
0)</p>
</blockquote>
<p>I'm not sure if it's uWSGI spamming them or Django. How can I disable the request logging?</p>
| 0debug |
How do I solve unsupported type imageview error? : I have two xml files. One in layout-land and the other in layout. However "http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" is marked red. I don't know if these are connected? Furthermore, as said I have the error unsupported type 'imageview'. Any help would be much appreciated and thanks in advance.
p.s. I am a newbie at java programming, started this week. Another p.s. is I use android studio ide | 0debug |
how to insert special character in mysql : Anyone please help me out for below issue ?
I have one table in which is storing data with *json_encode*
i have tried to *mysql_escape_string* as well as *mysql_real_escape_string* but both are not working in my case.
For example :
my password is : @:;_-#()\/+.,?!'"
update new_devices set parameter = '{"password":"@:;_-#()\/+.,?!'""}' where id = 126
Is that possible in php using something another solution ?
I know that store json_encode data into database its not good idea but
application is large and i can't do that change so please dont take that as negative.
Please help me out
Thanks in advance. | 0debug |
WSL Ubuntu hangs, how to restart? : <p>Occasionally WSL hangs on Windows 10. Opening "Ubuntu" bash just hangs. Any way to restart WSL without rebooting Windows ?</p>
<p><a href="https://i.stack.imgur.com/d0Gwo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/d0Gwo.png" alt="enter image description here"></a></p>
| 0debug |
mst_fpga_writeb(void *opaque, target_phys_addr_t addr, uint64_t value,
unsigned size)
{
mst_irq_state *s = (mst_irq_state *) opaque;
value &= 0xffffffff;
switch (addr) {
case MST_LEDDAT1:
s->leddat1 = value;
break;
case MST_LEDDAT2:
s->leddat2 = value;
break;
case MST_LEDCTRL:
s->ledctrl = value;
break;
case MST_GPSWR:
s->gpswr = value;
break;
case MST_MSCWR1:
s->mscwr1 = value;
break;
case MST_MSCWR2:
s->mscwr2 = value;
break;
case MST_MSCWR3:
s->mscwr3 = value;
break;
case MST_MSCRD:
s->mscrd = value;
break;
case MST_INTMSKENA:
s->intmskena = (value & 0xFEEFF);
qemu_set_irq(s->parent, s->intsetclr & s->intmskena);
break;
case MST_INTSETCLR:
s->intsetclr = (value & 0xFEEFF);
qemu_set_irq(s->parent, s->intsetclr & s->intmskena);
break;
case MST_PCMCIA0:
s->pcmcia0 = (value & 0x1f) | (s->pcmcia0 & ~0x1f);
break;
case MST_PCMCIA1:
s->pcmcia1 = (value & 0x1f) | (s->pcmcia1 & ~0x1f);
break;
default:
printf("Mainstone - mst_fpga_writeb: Bad register offset "
"0x" TARGET_FMT_plx "\n", addr);
}
}
| 1threat |
void xen_invalidate_map_cache_entry(uint8_t *buffer)
{
MapCacheEntry *entry = NULL, *pentry = NULL;
MapCacheRev *reventry;
hwaddr paddr_index;
hwaddr size;
int found = 0;
QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) {
if (reventry->vaddr_req == buffer) {
paddr_index = reventry->paddr_index;
size = reventry->size;
found = 1;
break;
}
}
if (!found) {
DPRINTF("%s, could not find %p\n", __func__, buffer);
QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) {
DPRINTF(" "TARGET_FMT_plx" -> %p is present\n", reventry->paddr_index, reventry->vaddr_req);
}
return;
}
QTAILQ_REMOVE(&mapcache->locked_entries, reventry, next);
g_free(reventry);
if (mapcache->last_entry != NULL &&
mapcache->last_entry->paddr_index == paddr_index) {
mapcache->last_entry = NULL;
}
entry = &mapcache->entry[paddr_index % mapcache->nr_buckets];
while (entry && (entry->paddr_index != paddr_index || entry->size != size)) {
pentry = entry;
entry = entry->next;
}
if (!entry) {
DPRINTF("Trying to unmap address %p that is not in the mapcache!\n", buffer);
return;
}
entry->lock--;
if (entry->lock > 0 || pentry == NULL) {
return;
}
pentry->next = entry->next;
if (munmap(entry->vaddr_base, entry->size) != 0) {
perror("unmap fails");
exit(-1);
}
g_free(entry->valid_mapping);
g_free(entry);
}
| 1threat |
Conversion of String to integer,then again to string : I am on a project developing an app on android. Here I have to find a sum between two numbers defined as Strings and then display them on a textview. But my app is crashing.Below is my code. Is it optimal? Please Help me I have to submit it as soon as possible.
String price=Place_View.prices[spinner1.getSelectedItemPosition()];
String fare=Cars.SUVFare[spinner2.getSelectedItemPosition()];
String result="";
int calc1=Integer.parseInt(price);
int calc2=Integer.parseInt(fare);
int calc3=calc1+calc2;
result=Integer.toString(calc3);
Price.setText(result);
}
}); | 0debug |
How do I extend another VueJS component in a single-file component? (ES6 vue-loader) : <p>I am using vue-loader (<a href="http://vuejs.github.io/vue-loader/start/spec.html" rel="noreferrer">http://vuejs.github.io/vue-loader/start/spec.html</a>) to construct my <code>*.vue</code> single-file components, but I am having trouble with the process from extending a single-file component from another.</p>
<p>If one component follows the spec to <code>export default { [component "Foo" definition] }</code>, I would think it is just a matter of importing this component (as I would with any child component) and then <code>export default Foo.extend({ [extended component definition] })</code></p>
<p>Unfortunately this does not work. Can anyone please offer advice?</p>
| 0debug |
DatePicker throws exception on changing Month : <p>Changing the month of a DatePicker throws this exception:</p>
<blockquote>
<p>System.Windows.Automation.ElementNotAvailableException: 'Element does
not exist or it is virtualized; use VirtualizedItem Pattern if it is
supported.'</p>
</blockquote>
<p>The Stack Trace:</p>
<blockquote>
<p>at MS.Internal.Automation.ElementUtil.Invoke(AutomationPeer peer,
DispatcherOperationCallback work, Object arg) at
MS.Internal.Automation.ElementProxy.GetPropertyValue(Int32 property)</p>
</blockquote>
<p>I created a simple project with only one DatePicker on the main window and it gives the same exception.</p>
<pre><code><DatePicker x:Name="datePicker1" Width="150" />
</code></pre>
<p>.NET Framework version: 4.6</p>
<p>I found the same problem in a 6 years old <a href="https://stackoverflow.com/q/6136966/2084193">question</a>, but no answer till now!</p>
<p><strong>Edit</strong>:</p>
<p>I tried different .NET Framework versions: 4.5, 4.6.1, and the problem still the same.</p>
| 0debug |
static void copy_context_after_encode(MpegEncContext *d, MpegEncContext *s, int type){
int i;
memcpy(d->mv, s->mv, 2*4*2*sizeof(int));
memcpy(d->last_mv, s->last_mv, 2*2*2*sizeof(int));
d->mb_incr= s->mb_incr;
for(i=0; i<3; i++)
d->last_dc[i]= s->last_dc[i];
d->mv_bits= s->mv_bits;
d->i_tex_bits= s->i_tex_bits;
d->p_tex_bits= s->p_tex_bits;
d->i_count= s->i_count;
d->p_count= s->p_count;
d->skip_count= s->skip_count;
d->misc_bits= s->misc_bits;
d->mb_intra= s->mb_intra;
d->mb_skiped= s->mb_skiped;
d->mv_type= s->mv_type;
d->mv_dir= s->mv_dir;
d->pb= s->pb;
d->block= s->block;
for(i=0; i<6; i++)
d->block_last_index[i]= s->block_last_index[i];
}
| 1threat |
soread(so)
struct socket *so;
{
int n, nn, lss, total;
struct sbuf *sb = &so->so_snd;
int len = sb->sb_datalen - sb->sb_cc;
struct iovec iov[2];
int mss = so->so_tcpcb->t_maxseg;
DEBUG_CALL("soread");
DEBUG_ARG("so = %lx", (long )so);
len = sb->sb_datalen - sb->sb_cc;
iov[0].iov_base = sb->sb_wptr;
if (sb->sb_wptr < sb->sb_rptr) {
iov[0].iov_len = sb->sb_rptr - sb->sb_wptr;
if (iov[0].iov_len > len)
iov[0].iov_len = len;
if (iov[0].iov_len > mss)
iov[0].iov_len -= iov[0].iov_len%mss;
n = 1;
} else {
iov[0].iov_len = (sb->sb_data + sb->sb_datalen) - sb->sb_wptr;
if (iov[0].iov_len > len) iov[0].iov_len = len;
len -= iov[0].iov_len;
if (len) {
iov[1].iov_base = sb->sb_data;
iov[1].iov_len = sb->sb_rptr - sb->sb_data;
if(iov[1].iov_len > len)
iov[1].iov_len = len;
total = iov[0].iov_len + iov[1].iov_len;
if (total > mss) {
lss = total%mss;
if (iov[1].iov_len > lss) {
iov[1].iov_len -= lss;
n = 2;
} else {
lss -= iov[1].iov_len;
iov[0].iov_len -= lss;
n = 1;
}
} else
n = 2;
} else {
if (iov[0].iov_len > mss)
iov[0].iov_len -= iov[0].iov_len%mss;
n = 1;
}
}
#ifdef HAVE_READV
nn = readv(so->s, (struct iovec *)iov, n);
DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn));
#else
nn = recv(so->s, iov[0].iov_base, iov[0].iov_len,0);
#endif
if (nn <= 0) {
if (nn < 0 && (errno == EINTR || errno == EAGAIN))
return 0;
else {
DEBUG_MISC((dfd, " --- soread() disconnected, nn = %d, errno = %d-%s\n", nn, errno,strerror(errno)));
sofcantrcvmore(so);
tcp_sockclosed(sototcpcb(so));
return -1;
}
}
#ifndef HAVE_READV
if (n == 2 && nn == iov[0].iov_len) {
int ret;
ret = recv(so->s, iov[1].iov_base, iov[1].iov_len,0);
if (ret > 0)
nn += ret;
}
DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn));
#endif
sb->sb_cc += nn;
sb->sb_wptr += nn;
if (sb->sb_wptr >= (sb->sb_data + sb->sb_datalen))
sb->sb_wptr -= sb->sb_datalen;
return nn;
} | 1threat |
How to use super() to call base class function in python 2.7.13? : <p>I have a multilevel inheritance (A->B->C). In base class i have a dictionary variable called "my_dict". From derived class, I am calling base class function by super().add_to_dict() to add some values. </p>
<p>Below code works as expected in python 3.7. But in Python 2.7.13 it throws error. can some one help me to fix it for 2.7.13?</p>
<pre><code>from collections import OrderedDict
class A():
def __init__(self):
self.my_dict = OrderedDict()
def add_to_dict(self):
self.my_dict["zero"]=0
self.my_dict["one"]=1
class B(A):
def add_to_dict(self):
super().add_to_dict()
self.my_dict["two"]=2
def print_dict(self):
print("class B {}".format(my_dict))
class C(B):
def add_to_dict(self):
super().add_to_dict()
self.my_dict["three"]=3
def print_dict(self):
print("class C {}".format(self.my_dict))
obj = C()
obj.add_to_dict()
obj.print_dict()
</code></pre>
<blockquote>
<p><strong>Output ( 2.7.13):</strong></p>
<p>File "test.py", line 15, in add_to_dict
super().add_to_dict()</p>
<p><strong>TypeError: super() takes at least 1 argument (0 given)</strong></p>
</blockquote>
<p><strong>Output (python 3.7)</strong></p>
<p>class C OrderedDict([('zero', 0), ('one', 1), ('two', 2), ('three', 3)])</p>
| 0debug |
How to find where nginx installs? : <p>Sorry for that I am not familiar with linux.
I tried to search the answer and tried this command:</p>
<pre><code>ps aux | grep nginx
</code></pre>
<p>But I only get the result like this:</p>
<pre><code>nginx: master process ./sbin/nginx
</code></pre>
<p>I got confused because as far as I know, dot means current directory where I execute linux command.</p>
<p>But I can not find sbin/nginx from current folder.
So where I can find nginx and where is the configuration it actually works.</p>
| 0debug |
Should we Use ViewModels to communicate between 2 different fragments or bundles in single activity App Architecture? : <p>Scenario 1 - If we use <code>ViewModels</code> to communicate between fragments, then the <code>ViewModel</code> has to be created by activity reference and hence going to stay there in memory until the activity is destroyed.</p>
<p>Scenario 2 - In master-detail flow <code>ViewModel</code> makes our life easier but again the memory usage issue is there.</p>
<p>Scenario 3 - We have <code>viewModelScope</code> in the new version of arch library to cancel jobs with Fragment/Activity lifecycles, but if <code>ViewModel</code> is created with activity reference then it's going to stay there until activity is destroyed. Hence the job can still be executing and fragment is already gone.</p>
| 0debug |
static int vqf_read_packet(AVFormatContext *s, AVPacket *pkt)
{
VqfContext *c = s->priv_data;
int ret;
int size = (c->frame_bit_len - c->remaining_bits + 7)>>3;
if (av_new_packet(pkt, size+2) < 0)
return AVERROR(EIO);
pkt->pos = avio_tell(s->pb);
pkt->stream_index = 0;
pkt->duration = 1;
pkt->data[0] = 8 - c->remaining_bits;
pkt->data[1] = c->last_frame_bits;
ret = avio_read(s->pb, pkt->data+2, size);
if (ret<=0) {
av_free_packet(pkt);
return AVERROR(EIO);
}
c->last_frame_bits = pkt->data[size+1];
c->remaining_bits = (size << 3) - c->frame_bit_len + c->remaining_bits;
return size+2;
}
| 1threat |
void do_interrupt(CPUARMState *env)
{
uint32_t addr;
uint32_t mask;
int new_mode;
uint32_t offset;
if (IS_M(env)) {
do_interrupt_v7m(env);
return;
}
switch (env->exception_index) {
case EXCP_UDEF:
new_mode = ARM_CPU_MODE_UND;
addr = 0x04;
mask = CPSR_I;
if (env->thumb)
offset = 2;
else
offset = 4;
break;
case EXCP_SWI:
if (semihosting_enabled) {
if (env->thumb) {
mask = lduw_code(env->regs[15] - 2) & 0xff;
} else {
mask = ldl_code(env->regs[15] - 4) & 0xffffff;
}
if (((mask == 0x123456 && !env->thumb)
|| (mask == 0xab && env->thumb))
&& (env->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {
env->regs[0] = do_arm_semihosting(env);
return;
}
}
new_mode = ARM_CPU_MODE_SVC;
addr = 0x08;
mask = CPSR_I;
offset = 0;
break;
case EXCP_BKPT:
if (env->thumb && semihosting_enabled) {
mask = lduw_code(env->regs[15]) & 0xff;
if (mask == 0xab
&& (env->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {
env->regs[15] += 2;
env->regs[0] = do_arm_semihosting(env);
return;
}
}
env->cp15.c5_insn = 2;
case EXCP_PREFETCH_ABORT:
new_mode = ARM_CPU_MODE_ABT;
addr = 0x0c;
mask = CPSR_A | CPSR_I;
offset = 4;
break;
case EXCP_DATA_ABORT:
new_mode = ARM_CPU_MODE_ABT;
addr = 0x10;
mask = CPSR_A | CPSR_I;
offset = 8;
break;
case EXCP_IRQ:
new_mode = ARM_CPU_MODE_IRQ;
addr = 0x18;
mask = CPSR_A | CPSR_I;
offset = 4;
break;
case EXCP_FIQ:
new_mode = ARM_CPU_MODE_FIQ;
addr = 0x1c;
mask = CPSR_A | CPSR_I | CPSR_F;
offset = 4;
break;
default:
cpu_abort(env, "Unhandled exception 0x%x\n", env->exception_index);
return;
}
if (env->cp15.c1_sys & (1 << 13)) {
addr += 0xffff0000;
}
switch_mode (env, new_mode);
env->spsr = cpsr_read(env);
env->condexec_bits = 0;
env->uncached_cpsr = (env->uncached_cpsr & ~CPSR_M) | new_mode;
env->uncached_cpsr |= mask;
if (arm_feature(env, ARM_FEATURE_V4T)) {
env->thumb = (env->cp15.c1_sys & (1 << 30)) != 0;
}
env->regs[14] = env->regs[15] + offset;
env->regs[15] = addr;
env->interrupt_request |= CPU_INTERRUPT_EXITTB;
}
| 1threat |
Binning of data along one axis in numpy : <p>I have a large two dimensional array <code>arr</code> which I would like to bin over the second axis using numpy. Because <code>np.histogram</code> flattens the array I'm currently using a for loop:</p>
<pre><code>import numpy as np
arr = np.random.randn(100, 100)
nbins = 10
binned = np.empty((arr.shape[0], nbins))
for i in range(arr.shape[0]):
binned[i,:] = np.histogram(arr[i,:], bins=nbins)[0]
</code></pre>
<p>I feel like there should be a more direct and more efficient way to do that within numpy but I failed to find one.</p>
| 0debug |
int ff_rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st)
{
RTSPState *rt = s->priv_data;
AVStream *st = NULL;
int reordering_queue_size = rt->reordering_queue_size;
if (reordering_queue_size < 0) {
if (rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP || !s->max_delay)
reordering_queue_size = 0;
else
reordering_queue_size = RTP_REORDER_QUEUE_DEFAULT_SIZE;
}
if (rtsp_st->stream_index >= 0)
st = s->streams[rtsp_st->stream_index];
if (!st)
s->ctx_flags |= AVFMTCTX_NOHEADER;
if (CONFIG_RTSP_MUXER && s->oformat) {
int ret = ff_rtp_chain_mux_open((AVFormatContext **)&rtsp_st->transport_priv,
s, st, rtsp_st->rtp_handle,
RTSP_TCP_MAX_PACKET_SIZE,
rtsp_st->stream_index);
rtsp_st->rtp_handle = NULL;
if (ret < 0)
return ret;
st->time_base = ((AVFormatContext*)rtsp_st->transport_priv)->streams[0]->time_base;
} else if (rt->transport == RTSP_TRANSPORT_RAW) {
return 0;
} else if (CONFIG_RTPDEC && rt->transport == RTSP_TRANSPORT_RDT)
rtsp_st->transport_priv = ff_rdt_parse_open(s, st->index,
rtsp_st->dynamic_protocol_context,
rtsp_st->dynamic_handler);
else if (CONFIG_RTPDEC)
rtsp_st->transport_priv = ff_rtp_parse_open(s, st,
rtsp_st->sdp_payload_type,
reordering_queue_size);
if (!rtsp_st->transport_priv) {
return AVERROR(ENOMEM);
} else if (CONFIG_RTPDEC && rt->transport == RTSP_TRANSPORT_RTP) {
RTPDemuxContext *rtpctx = rtsp_st->transport_priv;
rtpctx->ssrc = rtsp_st->ssrc;
if (rtsp_st->dynamic_handler) {
ff_rtp_parse_set_dynamic_protocol(rtsp_st->transport_priv,
rtsp_st->dynamic_protocol_context,
rtsp_st->dynamic_handler);
}
if (rtsp_st->crypto_suite[0])
ff_rtp_parse_set_crypto(rtsp_st->transport_priv,
rtsp_st->crypto_suite,
rtsp_st->crypto_params);
}
return 0;
}
| 1threat |
When do I need to worry about tasks leading to multithreading? : <p>Say I have code like this:</p>
<pre><code>...
var task1 = DoWorkAsync(1);
var task2 = DoWorkAsync(2);
await Task.WhenAll(task1, task2);
...
private async Task DoWorkAsync(int n)
{
// Async HTTP request that we ConfigureAwait(to be determined).
// Some CPU-bound work that isn't thread-safe.
}
</code></pre>
<p>So if I'm in a WPF app and I don't <code>ConfigureAwait(false)</code> on the HTTP request, am I safe here? The two HTTP requests can be made concurrently, but the tasks have to resume on the UI thread, so the CPU-bound work isn't multi-threaded? But if I do <code>ConfigureAwait(false)</code>, the tasks can resume their CPU-bound work in parallel on different thread pool threads so I'm in trouble?</p>
<p>If I'm in ASP.NET it can happen either way because the synchronization context doesn't have anything to do with a thread like WPF?</p>
<p>And what if I'm in a console app?</p>
<p>How do I talk about <code>DoWorkAsync</code>? Do I say 'it's not safe to <code>DoWorkAsync</code>s concurrently'?</p>
<p>Is there a normal way to redesign it? The important part to do concurrently is the HTTP request, not the CPU-bound work, so do I use a lock or something (never used before)?</p>
| 0debug |
CSS - two divs next to each other, 100% width and overflow : <p>I want to have two divs next to each other. Not too hard right?</p>
<p>Yeah...</p>
<p>I can do things like <code>display: inline-block;</code> or <code>float: left;</code>, but I also want the divs to be <code>width: 100%</code> but as soon I do that they get displayed below each other.</p>
<p>To better illustrate what I want I have drawn this:</p>
<p><a href="https://i.stack.imgur.com/jiDKs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jiDKs.png" alt="enter image description here"></a></p>
<p>As you can see <code>child div 1</code> is visible inside the parent(<code>overflow: hidden;</code>) and <code>child div 2</code> is not because they both have a width of 100%. </p>
<p>Now, my question is: How would I accomplish this?</p>
<p>I have already tried a lot of things but almost everything ends up placing the divs below each other.</p>
| 0debug |
PowerShell - Apply New Fine Grained Password Policy to OU : I have created and Organizational-Unit in server 2012 using PowerShell and also I have created a Fine-Grained-Password-Policy using PowerShell by following script
New-ADFineGrainedPasswordPolicy -Name test -DisplayName test -Precedence 100 -ComplexityEnabled $true -ReversibleEncryptionEnabled $false -PasswordHistoryCount 10 -MinPasswordLength 3 -MinPasswordAge 1.00:00:00 -MaxPasswordAge 100.00:00:00 -LockoutThreshold 3 -LockoutObservationWindow 0.00:05:00 -LockoutDuration 0.00:10:00
I want to apply the above policy in my created Organizational Unit which named "OU=HRdep,DC=ghufranataie,DC=com" Using PowerShell commands
in following commands, Applies To is empty, I don't know how to set my OU distinguished name to "test" fine grained password policy
{
PS C:\Users\Administrator> New-ADOrganizationalUnit -name HRdep
PS C:\Users\Administrator> Get-ADFineGrainedPasswordPolicy -identity test
AppliesTo : {}
ComplexityEnabled : True
DistinguishedName : CN=test,CN=Password Settings Container,CN=System,DC=ghufranataie,DC=com
LockoutDuration : 00:10:00
LockoutObservationWindow : 00:05:00
LockoutThreshold : 3
MaxPasswordAge : 100.00:00:00
MinPasswordAge : 1.00:00:00
MinPasswordLength : 3
Name : test
ObjectClass : msDS-PasswordSettings
ObjectGUID : bc1a09d3-3bb6-4e94-b8a5-88ac12eb060f
PasswordHistoryCount : 10
Precedence : 100
ReversibleEncryptionEnabled : False
}
[Fine Grained Password Policy and Organizational Unit in PowerShell][1]
[1]: https://i.stack.imgur.com/yeVxf.jpg | 0debug |
How to communicate from angular-material2 dialog to its parent : <p>I have <code>Parent</code> component that opens an <code>angular-material2</code> dialog box. </p>
<pre><code>let dialogRef = this.dialog.open(Child, {
disableClose: true
});
</code></pre>
<p>opened dialog <code>Child</code> component has a button 'Add'. I want to notify the `Parent' component if user click on 'Add' button. </p>
<p>How is this possible?</p>
| 0debug |
iOS iCloud file written on one device can't be opened on another : This question was asked five years ago with no resolution, so I'm assuming it isn't the same issue.
I have an app that writes several files to iCloud. I can see the current file updated on iCloud.com as well as on my Mac iCloud folder, but I only see the stub file(s) (the ones with the iCloud badge) in the Files folder on the second device. My app that tries to read the file fails with "file not found". If I open the file from the Files app which forces it to download, then run my app, it opens and reads the file just fine. So, my question is, how do I programmatically force the file to download. I tried appending ".icloud" to the file name and still shows as not found.
Any suggestions? | 0debug |
static uint64_t ahci_idp_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
AHCIState *s = opaque;
if (addr == s->idp_offset) {
return s->idp_index;
} else if (addr == s->idp_offset + 4) {
return ahci_mem_read(opaque, s->idp_index, size);
} else {
return 0;
}
}
| 1threat |
declaring a variable twice in IIFE : <p>I came through this fun quiz on the internet.</p>
<pre><code>console.log((function(x, f = (() => x)){
var x;
var y = x;
x = 2;
return [x, y, f()]
})(1))
</code></pre>
<p>and the choices were:</p>
<ol>
<li><p>[2,1,1]</p></li>
<li><p>[2, undefined, 1]</p></li>
<li><p>[2, 1, 2]</p></li>
<li><p>[2, undefined, 2]</p></li>
</ol>
<p>I picked solution 2 TBH, basing that on that x has been redefined, y was declared and defined with no value, and that f has a different scope hence getting the global x memory spot than function x memory spot.</p>
<p>However, I tried it in <a href="https://jsbin.com/cakiheqita/1/edit?js,console" rel="noreferrer">jsbin.com</a></p>
<p>and I found it was solution 1, while I was not sure why that happened I messed with the function body and I removed <code>var x</code> from the function body, I found that the response changed to #3 which makes sense as x value changed and hence it showed x and f as 2 and y as 1 which was declared globally.</p>
<p>but still I can't get why it shows 1 instead of undefined.</p>
| 0debug |
void cpu_register_physical_memory_log(MemoryRegionSection *section,
bool readonly)
{
MemoryRegionSection now = *section, remain = *section;
if ((now.offset_within_address_space & ~TARGET_PAGE_MASK)
|| (now.size < TARGET_PAGE_SIZE)) {
now.size = MIN(TARGET_PAGE_ALIGN(now.offset_within_address_space)
- now.offset_within_address_space,
now.size);
register_subpage(&now);
remain.size -= now.size;
remain.offset_within_address_space += now.size;
remain.offset_within_region += now.size;
}
while (remain.size >= TARGET_PAGE_SIZE) {
now = remain;
if (remain.offset_within_region & ~TARGET_PAGE_MASK) {
now.size = TARGET_PAGE_SIZE;
register_subpage(&now);
} else {
now.size &= TARGET_PAGE_MASK;
register_multipage(&now);
}
remain.size -= now.size;
remain.offset_within_address_space += now.size;
remain.offset_within_region += now.size;
}
now = remain;
if (now.size) {
register_subpage(&now);
}
}
| 1threat |
bool qemu_run_timers(QEMUClock *clock)
{
return qemu_clock_run_timers(clock->type);
}
| 1threat |
Disable wavy underline in VS Code : <p><br>
I'm using Visual Studio Code (v1.11.2).<br>
Is there any way to disable wavy underline at all?<br><br>
<a href="https://i.stack.imgur.com/g7VYS.png" rel="noreferrer"><img src="https://i.stack.imgur.com/g7VYS.png" alt="enter image description here"></a></p>
| 0debug |
static int film_read_close(AVFormatContext *s)
{
FilmDemuxContext *film = s->priv_data;
av_freep(&film->sample_table);
av_freep(&film->stereo_buffer);
return 0;
}
| 1threat |
HTML in PHP Contact us Form : <p>I've attempted at a contact us form in PHP, now when it's submitted and user data it not filled in the form should refer the user back to fill it out again. so the code i currently have is:</p>
<pre><code> <?php
$all = 'All fields are required, please fill <a href="\">the form</a> again.'
$action=$_REQUEST['action'];
if ($action=="") /* display the contact form */
{
?>
<form action="" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="submit">
Your name:<br>
<input name="name" type="text" value="" size="30"/><br>
Your email:<br>
<input name="email" type="text" value="" size="30"/><br>
Your message:<br>
<textarea name="message" rows="7" cols="30"></textarea><br>
<input type="submit" value="Send email"/>
</form>
<?php
}
else /* send the submitted data */
{
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$message=$_REQUEST['message'];
if (($name=="")||($email=="")||($message==""))
{
echo $all;
}
else{
$from="From: $name<$email>\r\nReturn-path: $email";
$subject="Message sent using your contact form";
// mail("email@email.com", $subject, $message, $from);
echo "Email sent!";
}
}
?>
</code></pre>
<p>Now for some reason where i'm using <code>
All fields are required, please fill <a href="\">the form</a> again.</code> it does not hide its self
it shows up which i find very strange?</p>
<p><a href="http://ragko.co.uk/Webs/Web2/" rel="nofollow noreferrer">Here is the live link to further explain</a></p>
| 0debug |
Uncaught ReferenceError: define is not defined typescript : <p>I am new to typescript, knockout and requirejs. I have created some demo using this files. Now, I want to implement some minor logic using typescript and knockoutjs. </p>
<p>I have created 4-5 typescript files, which are imported internally. When I run the html file. I am getting the error stating. as Titled </p>
<p><a href="https://i.stack.imgur.com/oAisn.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/oAisn.jpg" alt="enter image description here"></a>
Can somebody help me on this error. What I am missing in this code. </p>
<p>have search on google and spend quite a good time but didn't find the proper solutions. It must be related to requireJS to define all modules. But, as new in requireJS not able to catch up with that. I have also search stackoverflow for the similar error, but it doesn't help me out.</p>
<p>Waiting for the solution</p>
| 0debug |
Spring JdbcTemplate execute vs update : <p>What is the difference between <code>execute(String sql)</code> and <code>update(String sql)</code> in <a href="http://docs.spring.io/spring/docs/3.0.x/javadoc-api/org/springframework/jdbc/core/JdbcTemplate.html" rel="noreferrer"><code>JdbcTemplate</code></a>?</p>
<p>If my statement is a straight <code>CRUD</code> and not an object creation DDL (as the execute javadoc implies), does it make sense to use execute vs the seemingly more lightweight update?</p>
| 0debug |
static inline void vring_used_write(VirtQueue *vq, VRingUsedElem *uelem,
int i)
{
hwaddr pa;
virtio_tswap32s(vq->vdev, &uelem->id);
virtio_tswap32s(vq->vdev, &uelem->len);
pa = vq->vring.used + offsetof(VRingUsed, ring[i]);
address_space_write(&address_space_memory, pa, MEMTXATTRS_UNSPECIFIED,
(void *)uelem, sizeof(VRingUsedElem));
}
| 1threat |
void msi_uninit(struct PCIDevice *dev)
{
uint16_t flags = pci_get_word(dev->config + msi_flags_off(dev));
uint8_t cap_size = msi_cap_sizeof(flags);
pci_del_capability(dev, PCI_CAP_ID_MSIX, cap_size);
MSI_DEV_PRINTF(dev, "uninit\n");
}
| 1threat |
how does to install proper way to npm in windows? : <p>some day before i have start to learn angular js 2 and read tutorial to install npm in windows but nothing meaning full found from it I am new to programming and want to learn to angular js. anybody help me thanks </p>
| 0debug |
Loop Java Script with PHP while loop : There is a while loop to populate customer bills within which it has many buttons that triggers java script functions on click
for each bill there many buttons with different ids Pay, Decline, Hide, confirm(Modal)
For example:
<button form="PayBillFormForm" type="button" name="button" id ="pay" data-toggle="modal" data-target="#paymodal" class="btn btn-success" value="pay" style=" width:100%; height: 90%; ">دفع</button>
I need to number the buttons ids and also number the java script functions in order to make it works but it seems java script codes wouldn't loop
$('#pay').click(function(){
$('#action').val('pay');
});
Please advise how to fix it or suggest another method. | 0debug |
static int parse_presentation_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size,
int64_t pts)
{
PGSSubContext *ctx = avctx->priv_data;
int i, state, ret;
int w = bytestream_get_be16(&buf);
int h = bytestream_get_be16(&buf);
uint16_t object_index;
ctx->presentation.pts = pts;
av_dlog(avctx, "Video Dimensions %dx%d\n",
w, h);
ret = ff_set_dimensions(avctx, w, h);
if (ret < 0)
return ret;
buf++;
ctx->presentation.id_number = bytestream_get_be16(&buf);
state = bytestream_get_byte(&buf) >> 6;
if (state != 0) {
flush_cache(avctx);
}
buf += 1;
ctx->presentation.palette_id = bytestream_get_byte(&buf);
ctx->presentation.object_count = bytestream_get_byte(&buf);
if (ctx->presentation.object_count > MAX_OBJECT_REFS) {
av_log(avctx, AV_LOG_ERROR,
"Invalid number of presentation objects %d\n",
ctx->presentation.object_count);
ctx->presentation.object_count = 2;
if (avctx->err_recognition & AV_EF_EXPLODE) {
return AVERROR_INVALIDDATA;
}
}
for (i = 0; i < ctx->presentation.object_count; i++)
{
if (buf_end - buf < 8) {
av_log(avctx, AV_LOG_ERROR, "Insufficent space for object\n");
ctx->presentation.object_count = i;
return AVERROR_INVALIDDATA;
}
ctx->presentation.objects[i].id = bytestream_get_be16(&buf);
ctx->presentation.objects[i].window_id = bytestream_get_byte(&buf);
ctx->presentation.objects[i].composition_flag = bytestream_get_byte(&buf);
ctx->presentation.objects[i].x = bytestream_get_be16(&buf);
ctx->presentation.objects[i].y = bytestream_get_be16(&buf);
if (ctx->presentation.objects[i].composition_flag & 0x80) {
ctx->presentation.objects[i].crop_x = bytestream_get_be16(&buf);
ctx->presentation.objects[i].crop_y = bytestream_get_be16(&buf);
ctx->presentation.objects[i].crop_w = bytestream_get_be16(&buf);
ctx->presentation.objects[i].crop_h = bytestream_get_be16(&buf);
}
av_dlog(avctx, "Subtitle Placement x=%d, y=%d\n",
ctx->presentation.objects[i].x, ctx->presentation.objects[i].y);
if (ctx->presentation.objects[i].x > avctx->width ||
ctx->presentation.objects[i].y > avctx->height) {
av_log(avctx, AV_LOG_ERROR, "Subtitle out of video bounds. x = %d, y = %d, video width = %d, video height = %d.\n",
ctx->presentation.objects[i].x,
ctx->presentation.objects[i].y,
avctx->width, avctx->height);
ctx->presentation.objects[i].x = 0;
ctx->presentation.objects[i].y = 0;
if (avctx->err_recognition & AV_EF_EXPLODE) {
return AVERROR_INVALIDDATA;
}
}
}
return 0;
} | 1threat |
Change background color in launch screen when using DayNight theme : <p>I am using <strong>DayNight</strong> theme with <strong>launch screen</strong>.</p>
<p>Launch screen is a layer-list with white background.</p>
<p>So when its day, <strong>white</strong> launch screen shows followed by <strong>white</strong> activity. But at night, <strong>white</strong> launch screen shows follwed by <strong>dark</strong> activity.</p>
<p><em>How can i change the background color in the launch screen according to the theme.</em></p>
<p>Cannot use custom color attrs because there is only a DayNight theme.</p>
<p><strong>themes.xml</strong></p>
<pre><code><resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:colorControlNormal">@color/colorAccent</item>
</style>
<style name="LaunchTheme" parent="AppTheme">
<item name="android:windowBackground">@drawable/launch_screen</item>
</style>
</code></pre>
<p></p>
<p><strong>launch_screen.xml</strong></p>
<pre><code><layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="@color/material_white"/>
</item>
<item>
<bitmap
android:gravity="center"
android:src="@drawable/launch_logo"
android:tileMode="disabled"/>
</item>
</code></pre>
<p></p>
| 0debug |
string name of a other string name : i need to set a new string and that the user need to set this new string name
for exmple:
int input = 0;
while (input != -1)
{
input = int.Parse(Console.ReadLine());
int count = 0;
count ++;
int "count" = intput;
}
Thanks | 0debug |
def max_product(arr, n ):
mpis =[0] * (n)
for i in range(n):
mpis[i] = arr[i]
for i in range(1, n):
for j in range(i):
if (arr[i] > arr[j] and
mpis[i] < (mpis[j] * arr[i])):
mpis[i] = mpis[j] * arr[i]
return max(mpis) | 0debug |
how to open webview inside facebook messenger on desktop web browser : <p>I'm trying to implement some features inside a web view in facebook messenger. on the phone the webview is opening fine, but in desctop web browser the webview is opening inside a new tab.
im using the following feature:
<code>
buttons:[{
type: "web_url",
url: "https://www.oculus.com/en-us/rift/",
title: "Open Web URL",
webview_height_ratio: "compact",
messenger_extensions: true,
}
</code>
I know that maybe it is supposed to open like this but you all can agree that if I'm implementing a custom feature inside the conversation it would be mach better to open it inside a small webview in the conversation.
does anyone knows if this even possible?</p>
| 0debug |
Regex remove aspects of a URL side from specific location : **I want to get the username of a URL from twitter:**
https://twitter.com/TwitterDev/status/850006245121695744
**and then receive only:**
TwitterDev
**But there may be variables, such as the following URL possibilities:**
-https://twitter.com/TwitterDev/status/850006245121695744
-http://twitter.com/TwitterDev/status/850006245121695744
-twitter.com/TwitterDev/status/850006245121695744
-https://www.twitter.com/TwitterDev/status/850006245121695744
-http://www.twitter.com/TwitterDev/status/850006245121695744
-www.twitter.com/TwitterDev/status/850006245121695744
-m.twitter.com/TwitterDev/status/850006245121695744
___
**Question:**
How can I get the words/numbers/charectors after ".com/" up until the next "/" ?
https://twitter.com/{get_this_1}/status/850006245121695744 ? | 0debug |
static void parser_context_free(JSONParserContext *ctxt)
{
if (ctxt) {
while (!g_queue_is_empty(ctxt->buf)) {
parser_context_pop_token(ctxt);
}
qobject_decref(ctxt->current);
g_queue_free(ctxt->buf);
g_free(ctxt);
}
}
| 1threat |
c# identifier expected in controller : <p>When i type this in my controller page I am getting the error message "Identifier expected" after "loginViewModel". Any idea on how to fix this? </p>
<pre><code>public IActionResult Login(LoginViewModel, string Email, string Password)
{
return View();
}
</code></pre>
| 0debug |
Connecting to Redis running in Docker Container from Host machine : <p>I see lots of people struggling with this, sort of feel like maybe there is a bug in the redis container image, and others seem to be chasing a similar problem.</p>
<p>I'm using the standard redis image on DockerHub. (<a href="https://github.com/dockerfile/redis" rel="noreferrer">https://github.com/dockerfile/redis</a>)</p>
<p>running it like this:</p>
<pre><code>docker run -it -p 6379:6379 redis bash
</code></pre>
<p>Once I'm in I can start the server, and do a redis ping from the container image.</p>
<p>Unfortunately, I cannot connect to the redis container from my host.</p>
<p>I have tried setting, such as below. </p>
<pre><code>bind 127.0.0.1
</code></pre>
<p>and removed the bind from the configuration</p>
<p>and tried turn off protected mode</p>
<pre><code>protected-mode no
</code></pre>
<p>I know it is reading the configuration file, since I changed ports just to test, and I was able to do that.</p>
<p>I'm running Windows 10, so maybe it is a windows networking issue. I never have a problem with docker normally. I'm puzzled </p>
| 0debug |
import error when using react-icons : <p>I have tried installing react icons, in my application I ran the npm command:</p>
<pre><code>sudo npm install react-icons --save
</code></pre>
<p>I didn't get any errors, apart from some optional dependencies, that where skipped</p>
<pre><code>npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4
(node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for
fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current:
{"os":"linux","arch":"x64"})
</code></pre>
<p>Whenever I try to import some of the icons, I get an error</p>
<pre><code>./src/components/SkiDaysCount.js
Module not found: Can't resolve 'react-icons/lib/md' in '
'/home/kristoffer/ReactApps/navbar/src/components'
</code></pre>
<p>here are my imports:</p>
<pre><code>import {Terrain} from 'react-icons/lib/md'
import {SnowFlake} from 'react-icons/lib/ti'
import {Calender} from 'react-icons/lib/fa'
</code></pre>
<p>Why am I getting this error?</p>
<p>EDIT:</p>
<p>i have also tried using the old syntax for importing, with the same issue as such:</p>
<pre><code>import Calender from 'react-icons/lib/fa/calender'
</code></pre>
| 0debug |
static void ivshmem_check_memdev_is_busy(Object *obj, const char *name,
Object *val, Error **errp)
{
if (host_memory_backend_is_mapped(MEMORY_BACKEND(val))) {
char *path = object_get_canonical_path_component(val);
error_setg(errp, "can't use already busy memdev: %s", path);
g_free(path);
} else {
qdev_prop_allow_set_link_before_realize(obj, name, val, errp);
}
}
| 1threat |
static void tcx_rblit_writel(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
TCXState *s = opaque;
uint32_t adsr, len;
int i;
if (!(addr & 4)) {
s->tmpblit = val;
} else {
addr = (addr >> 3) & 0xfffff;
adsr = val & 0xffffff;
len = ((val >> 24) & 0x1f) + 1;
if (adsr == 0xffffff) {
memset(&s->vram[addr], s->tmpblit, len);
if (s->depth == 24) {
val = s->tmpblit & 0xffffff;
val = cpu_to_be32(val);
for (i = 0; i < len; i++) {
s->vram24[addr + i] = val;
s->cplane[addr + i] = val;
}
}
} else {
memcpy(&s->vram[addr], &s->vram[adsr], len);
if (s->depth == 24) {
memcpy(&s->vram24[addr], &s->vram24[adsr], len * 4);
memcpy(&s->cplane[addr], &s->cplane[adsr], len * 4);
}
}
memory_region_set_dirty(&s->vram_mem, addr, len);
}
}
| 1threat |
How to set ChangeDetectionStrategy.OnPush as default strategy : <p>How to set the ChangeDetectionStrategy.OnPush as default strategy for every
component in my app instead of writing on every component's template
<code>changeDetection: ChangeDetectionStrategy.OnPush</code> ?</p>
<p>Thanks</p>
<p>Best Regards
Mark Nebrat</p>
| 0debug |
Why there is no filter function of Stream in idris? : <p>There is <code>filter : (a -> Bool) -> List a -> List a</code> for List, but there is no <code>filter : (a -> Bool) -> Stream a -> Stream a</code> for Stream, why?</p>
<p>Is there some alternatives to do the similar jobs?</p>
| 0debug |
how to hide the other appsof my company in play google : i want to hide the other apps of my company,
for example when you enter to the page of my application you find link to my company, i want to delete this link
also in the button of the page you find (More from developer) link, i want also to delete this link.
i want like this company:https://play.google.com/store/apps/details?id=me.goldesel&referrer=adjust_reftag%3DcIlQp0wZeyVOM%26utm_source%3DInviteFriend | 0debug |
Matrix Math With Sparklyr : <p>Looking to convert some R code to Sparklyr, functions such as lmtest::coeftest() and sandwich::sandwich(). Trying to get started with Sparklyr extensions but pretty new to the Spark API and having issues :(</p>
<p>Running Spark 2.1.1 and sparklyr 0.5.5-9002</p>
<p>Feel the first step would be to make a <a href="https://spark.apache.org/docs/2.1.1/api/scala/index.html#org.apache.spark.mllib.linalg.DenseMatrix" rel="noreferrer">DenseMatrix</a> object using the linalg library:</p>
<pre><code>library(sparklyr)
library(dplyr)
sc <- spark_connect("local")
rows <- as.integer(2)
cols <- as.integer(2)
array <- c(1,2,3,4)
mat <- invoke_new(sc, "org.apache.spark.mllib.linalg.DenseMatrix",
rows, cols, array)
</code></pre>
<p>This results in the error:</p>
<pre><code>Error: java.lang.Exception: No matched constructor found for class org.apache.spark.mllib.linalg.DenseMatrix
</code></pre>
<p>Okay, so I got a java lang exception, I'm pretty sure the <code>rows</code> and <code>cols</code> args were fine in the constructor, but not sure sure about the last one, which is supposed to be a java <code>Array</code>. So I tried a few permutations of:</p>
<pre><code>array <- invoke_new(sc, "java.util.Arrays", c(1,2,3,4))
</code></pre>
<p>but end up with a similar error message...</p>
<pre><code>Error: java.lang.Exception: No matched constructor found for class java.util.Arrays
</code></pre>
<p>I feel like I'm missing something pretty basic. Anyone know what's up?</p>
| 0debug |
execute script relative to another user's home directory : I'm a beginner in Linux scripting so excuse a stupid question please. Somehow I can't get the right search string to find the answer.
I want to run a script relative to a specific user's directory like:
~user/rel/path/to/script.sh
but I don't know what "~user" will translate to. It may even contain spaces. Should I quote it? And if so, how? I always get the file or folder does not exist error when I try to use quotes.
Thanks! | 0debug |
static inline void qpel_motion(MpegEncContext *s,
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
int field_based, int bottom_field, int field_select,
uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
qpel_mc_func (*qpix_op)[16],
int motion_x, int motion_y, int h)
{
uint8_t *ptr_y, *ptr_cb, *ptr_cr;
int dxy, uvdxy, mx, my, src_x, src_y, uvsrc_x, uvsrc_y, v_edge_pos, linesize, uvlinesize;
dxy = ((motion_y & 3) << 2) | (motion_x & 3);
src_x = s->mb_x * 16 + (motion_x >> 2);
src_y = s->mb_y * (16 >> field_based) + (motion_y >> 2);
v_edge_pos = s->v_edge_pos >> field_based;
linesize = s->linesize << field_based;
uvlinesize = s->uvlinesize << field_based;
if(field_based){
mx= motion_x/2;
my= motion_y>>1;
}else if(s->workaround_bugs&FF_BUG_QPEL_CHROMA2){
static const int rtab[8]= {0,0,1,1,0,0,0,1};
mx= (motion_x>>1) + rtab[motion_x&7];
my= (motion_y>>1) + rtab[motion_y&7];
}else if(s->workaround_bugs&FF_BUG_QPEL_CHROMA){
mx= (motion_x>>1)|(motion_x&1);
my= (motion_y>>1)|(motion_y&1);
}else{
mx= motion_x/2;
my= motion_y/2;
}
mx= (mx>>1)|(mx&1);
my= (my>>1)|(my&1);
uvdxy= (mx&1) | ((my&1)<<1);
mx>>=1;
my>>=1;
uvsrc_x = s->mb_x * 8 + mx;
uvsrc_y = s->mb_y * (8 >> field_based) + my;
ptr_y = ref_picture[0] + src_y * linesize + src_x;
ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
if( (unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x&3) - 16, 0)
|| (unsigned)src_y > FFMAX( v_edge_pos - (motion_y&3) - h , 0)){
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr_y, s->linesize,
17, 17+field_based, src_x, src_y<<field_based,
s->h_edge_pos, s->v_edge_pos);
ptr_y= s->edge_emu_buffer;
if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
uint8_t *uvbuf= s->edge_emu_buffer + 18*s->linesize;
s->vdsp.emulated_edge_mc(uvbuf, ptr_cb, s->uvlinesize,
9, 9 + field_based,
uvsrc_x, uvsrc_y<<field_based,
s->h_edge_pos>>1, s->v_edge_pos>>1);
s->vdsp.emulated_edge_mc(uvbuf + 16, ptr_cr, s->uvlinesize,
9, 9 + field_based,
uvsrc_x, uvsrc_y<<field_based,
s->h_edge_pos>>1, s->v_edge_pos>>1);
ptr_cb= uvbuf;
ptr_cr= uvbuf + 16;
}
}
if(!field_based)
qpix_op[0][dxy](dest_y, ptr_y, linesize);
else{
if(bottom_field){
dest_y += s->linesize;
dest_cb+= s->uvlinesize;
dest_cr+= s->uvlinesize;
}
if(field_select){
ptr_y += s->linesize;
ptr_cb += s->uvlinesize;
ptr_cr += s->uvlinesize;
}
qpix_op[1][dxy](dest_y , ptr_y , linesize);
qpix_op[1][dxy](dest_y+8, ptr_y+8, linesize);
}
if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
pix_op[1][uvdxy](dest_cr, ptr_cr, uvlinesize, h >> 1);
pix_op[1][uvdxy](dest_cb, ptr_cb, uvlinesize, h >> 1);
}
}
| 1threat |
void cache_insert(PageCache *cache, uint64_t addr, uint8_t *pdata)
{
CacheItem *it = NULL;
g_assert(cache);
g_assert(cache->page_cache);
it = cache_get_by_addr(cache, addr);
if (!it->it_data) {
cache->num_items++;
}
it->it_data = pdata;
it->it_age = ++cache->max_item_age;
it->it_addr = addr;
} | 1threat |
Php different timezones : <p>I'm developing a web app in php mysql which should be usable in the whole world.
In this app there is a big usage of time so I'm wondering if there
is any work to do on the timezones differences or if php is automatically recognizing the different timezones before saving in the db ?</p>
<p>Thanks for your help</p>
| 0debug |
Fetch value/values from table : <p>I have the following table in my database</p>
<pre><code>CREATE TABLE `sms_pool` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`ag_id` VARCHAR(20) NOT NULL,
`sms_to` VARCHAR(15) NOT NULL,
`template_name` VARCHAR(100) NOT NULL,
`contents` VARCHAR(500) NOT NULL,
`bulk_flag` VARCHAR(1) NOT NULL,
`file_name` VARCHAR(100) NULL DEFAULT NULL,
`send_flag` VARCHAR(1) NOT NULL,
`creation_date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`created_by` VARCHAR(20) NOT NULL,
`processing_msg` VARCHAR(2000) NULL DEFAULT NULL,
PRIMARY KEY (`id`),
);
</code></pre>
<p>I wish to write a procedure/function which takes 'id' as input.</p>
<p>If that 'id' is equal to any id in table then it should return the corresponding row,</p>
<p>if 'id' = NULL then it should return all of the rows from the database.</p>
<p><strong>NOTE</strong> : if 'id' is not present in table then it should return all of the rows.</p>
<p>How should I do this? Any help is appreciated. Thank you in advance. :D</p>
| 0debug |
C++ RegisterClassEx Error : I am trying to learn Win32 through msdn but I am having problems with RegisterClassEx, I checked other threads stating that maybe not all members are initialized but I am sure they are.
#include <Windows.h>
#include <tchar.h>
static const TCHAR windowclass_sz[] = _T("WindowClass1");
static const TCHAR windowtitle_sz[] = _T("DirectX 12 Demo");
bool Stop = true;
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
lParam)
{
switch (message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE PrevhInstance, LPSTR
lpCmdLine, int nCmdShow)
{
MSG msg;
HWND hWnd;
WNDCLASSEX wcex;
ZeroMemory(&wcex, sizeof(WNDCLASSEX));
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
wcex.hIconSm = LoadIcon(wcex.hInstance, IDI_APPLICATION);
wcex.hInstance = hInstance;
wcex.lpfnWndProc = WndProc;
wcex.lpszClassName = windowclass_sz;
wcex.lpszMenuName = nullptr;
wcex.style = CS_HREDRAW | CS_VREDRAW;
RegisterClassEx(&wcex);
if (!RegisterClassEx(&wcex))
{
GetLastError();
MessageBox(NULL, _T("RegisterClassEx Call Error!"), _T("ERROR"),
MB_ICONERROR && MB_OK );
return 1;
}
hWnd = CreateWindowEx(NULL, windowclass_sz, windowtitle_sz,
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
800, 600, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
MessageBox(NULL, _T("CreateWindowEx Call Error!"), _T("ERROR"),
MB_ICONERROR && MB_OK);
return 1;
}
else
{
Stop = false;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
while (Stop == false)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int)msg.wParam;
}
As you can see, the RegisterClassEx error is triggered but I have no clue what is wrong. | 0debug |
I need to compare column structure of two tables in different databases but on the same instance in SQL SERVER 2016 : I need to compare column structure of two tables in different databases but on the same instance in SQL SERVER 2016! | 0debug |
My SPARQL query is not working on DBPesdia.org. : This is my SPARQL query and its not working on dbpedia.org
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX uni: http://www.semanticweb.org/admin/ontologies/2017/4/untitled ontology-19#
SELECT ?property ?subject ?prop ?object
WHERE {
uni:Product ?property ?subject .
OPTIONAL {
?subject ?prop ?object
}
}
| 0debug |
def Extract(lst):
return [item[-1] for item in lst] | 0debug |
hii I'm new in cake php.my table is users..and my controler code is..and viewallpolice code is : public function viewallpolice($id=NULL){
$customer =$this->Session->read('customer_id');
if($customer>0){
$this->loadModel('Policy');
$results = $this->Policy->find('all',array('conditions' => array('customer_id' =>$customer)));
$this->set('results',$this->Policy->read(null,$id));
}else{
$this->Session->setFlash('error');
}
}
view all police code:
<?php foreach ($user as $result) ?>
<p>Customer Name /Mobile : <?php echo $result['Policy']['customer_name']; ?></p>
Notice (8): Undefined variable: user [APP\View\User\viewallpolice.ctp, line 1]
Warning (2): Invalid argument supplied for foreach() [APP\View\User\viewallpolice.ctp, line 1]
Customer Name /Mobile :
Notice (8): Undefined variable: result [APP\View\User\viewallpolice.ctp, line 2] | 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.