problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
what does strtok(NULL, "\n") do? : <blockquote>
<p>The C library function char *strtok(char *str, const char *delim) breaks string str into a series of tokens using the delimiter delim.</p>
</blockquote>
<p>What happens when you put <code>s = strtok(NULL, "\n")</code>? what does it mean splitting null by <code>\n</code>?</p>
| 0debug
|
Travis: different `script` for different branch? : <p>I'd like to setup deployment based on branches using Travis-CI and Github.</p>
<p>I.e. - if we made build from <code>develop</code> - then exec <code>/deploy.rb</code> with DEV env hostname, if <code>master</code> - then <code>./deploy.rb</code> with PROD hostname and so on.</p>
<p>Only one idea I found - is to check <code>$TRAVIS_BRANC</code> variable and then execute script, like:</p>
<pre><code>language: php
install:
- true
script:
- test $TRAVIS_BRANCH = "develop" && ./ci/deploy.rb envdev.tld
- test $TRAVIS_BRANCH = "master" && ./ci/deploy.rb envprod.tld
</code></pre>
<p>But this solution looks a bit weird as for me. Any other possibilities to realize that?</p>
<p>Any tips/links appreciated.</p>
| 0debug
|
JS vs JQ. Need You Expirience : Today i have problem withs optimization of Js code. Ex.:
// JavaScript Document
window.onload = function (){
setInterval (function (){
var GetMeId = document.getElementsByClassName("prev")[0].getAttribute("id");
var StyleFor = "display:block; width:100%; height:100%; top:0; left:0; transition:4s;";
$('.layer').removeAttr('style');//еSIXаный костыль для упрощения кода.
/*
document.getElementsByClassName("layer")[0].removeAttribute("style");
document.getElementsByClassName("layer")[1].removeAttribute("style");
document.getElementsByClassName("layer")[2].removeAttribute("style");
document.getElementsByClassName("layer")[3].removeAttribute("style");
document.getElementsByClassName("layer")[4].removeAttribute("style");
document.getElementsByClassName("layer")[5].removeAttribute("style");
document.getElementsByClassName("layer")[6].removeAttribute("style");
*/
if(document.getElementById(GetMeId) != document.getElementById("p"+GetMeId))
{
document.getElementById("p"+GetMeId).setAttribute("style",StyleFor);
}
},1000);
};
How can i do streamline of this code on JavaScript, sach us it have on JQuery?
| 0debug
|
Which way is faster when stripping part of string in JavaScript : <p>I need to strip part of JWT token and I am courious which one is faster, or less complex internally.</p>
<p>Example input string:</p>
<pre><code>const input = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjMsInR5cGUiOjAsImlhdCI6MTU4MTk3NDk1MCwiZXhwIjoxNTgxOTc4NTUwfQ.oEwxI51kVjB6jJUY2N5Ct6-hO0GUCUonolPbryUo-lI"
</code></pre>
<p>Which one of those methods is faster?</p>
<pre class="lang-js prettyprint-override"><code>const output = input.split('.').slice(2,3).join('.');
</code></pre>
<pre class="lang-js prettyprint-override"><code>const output = input.replace("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.","");
</code></pre>
<pre class="lang-js prettyprint-override"><code>const output = //REGEX replace
</code></pre>
<p>I not found any informations about speeds of those methods and I am not exactly master in making tests :D</p>
| 0debug
|
Linux- how to find a file with a certain string in its name? : <p>If I want to find all files with the string "test" in their name, how do I do so? </p>
| 0debug
|
I don't understand this common java principle : <p>Currently I'm following java course and I am struggling with a part of the code which I see used a lot in methods. So here goes:</p>
<p>Answer answer = new Answer("something"); </p>
<p>I have a class named Answer and I think the first Answer is in reference to that. the lower cased answer is the variable. It's after the = sign I'm struggling to comprehend. any help please? </p>
| 0debug
|
how to fix this error while executing a program in pycharm : C:\Users\skandregula\AppData\Local\Programs\Python\Python37\python.exe C:/Users/skandregula/Desktop/TestFiles2/testing.py
Traceback (most recent call last):
File "C:/Users/skandregula/Desktop/TestFiles2/testing.py", line 30, in <module>
with open(in_dir + f, 'r') as tmp_file:
FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/skandregula/Desktop/TestFiles2/history.log.3.3C'
Process finished with exit code 1
that is the error i am running right now...How to fix this?
| 0debug
|
void hbitmap_set(HBitmap *hb, uint64_t start, uint64_t count)
{
uint64_t last = start + count - 1;
trace_hbitmap_set(hb, start, count,
start >> hb->granularity, last >> hb->granularity);
start >>= hb->granularity;
last >>= hb->granularity;
count = last - start + 1;
hb->count += count - hb_count_between(hb, start, last);
hb_set_between(hb, HBITMAP_LEVELS - 1, start, last);
}
| 1threat
|
Any way to install app to iPhone 4 with Xcode 8 beta? : <p>When trying to run app on my iPhone 4, Xcode 8 beta shows me this message:</p>
<p><code>This iPhone 4 is running iOS 7.1.2 (11D257), which may not be supported by this version of Xcode.</code></p>
<p>My app must support iOS 7. I read many answers they say that app build with Xcode 8 beta still can run on iOS 7 devices. So is there a way to install app to iPhone 4 with Xcode 8 beta? Like building the app first, then use a command line to install <code>.app</code> file to the iPhone?</p>
| 0debug
|
static int nfs_file_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp) {
NFSClient *client = bs->opaque;
int64_t ret;
QemuOpts *opts;
Error *local_err = NULL;
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
return -EINVAL;
}
ret = nfs_client_open(client, qemu_opt_get(opts, "filename"),
(flags & BDRV_O_RDWR) ? O_RDWR : O_RDONLY,
errp);
if (ret < 0) {
return ret;
}
bs->total_sectors = ret;
return 0;
}
| 1threat
|
Please help me check if the email exists using pdo : This is the section I use to add users.
<?php
session_start();
if( isset($_SESSION['user_id']) ){
header("Location: ./index.php");
}
require 'conn.php';
$message = '';
if(!empty($_POST['name']) &&!empty($_POST['email']) && !empty($_POST['password'])):
// Enter the new user in the database
$sql = "INSERT INTO users (name, email, password) VALUES (:name,:email, :password)";
$stmt = $conn->prepare($sql);
$stmt->bindValue(':name', $_POST['name']);
$stmt->bindValue(':email', $_POST['email']);
$stmt->bindValue(':password', password_hash($_POST['password'], PASSWORD_BCRYPT));
if( $stmt->execute() ):
$message = 'Successfully created new user';
else:
$message = 'Sorry there must have been an issue creating your account';
endif;
endif;
?>
Thanks in advanced. Php NewBie
| 0debug
|
Angular ng-table with Goto page : <p>I'm using ng-table to setup a custom pagination control. I want to have an input that only allows valid page numbers. I have the existing pagination so far.</p>
<pre><code>script(type="text/ng-template" id="ng-table-pagination-input")
div(class="ng-cloak ng-table-pager" ng-if="params.data.length")
br
ul(ng-if="pages.length" class="pagination ng-table-pagination")
li(ng-class="{'disabled': !page.active && !page.current, 'active': page.current}" ng-repeat="page in pages" ng-switch="page.type")
a(ng-switch-when="prev" ng-click="params.page(page.number)" href="")
span &laquo;
a(ng-switch-when="next" ng-click="params.page(page.number)" href="")
span &raquo;
</code></pre>
<p>How can I get an input control in there to work properly?</p>
| 0debug
|
c++ execute command and get working directory : I want to execute a shell command in c++ and at the end I would like to fetch the current working directory of the executed process.
e.g. I executing the command `cd C:\`
then at the end of the command I want to get the directory `C:\`
and store it in a variable.
What I tried was [`pipe = _popen(cmd, "r")`][1] to execute the command, but at the end of the command, even when [`_pclose(pipe)`][2] wasn't called yet, when I called [`_getcwd(NULL, 0)`][3], I got the cwd of the running c++ program and not the changed cwd from `_popen`.
does anyone know, how I could achieve this?
[1]: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/popen-wpopen
[2]: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/pclose
[3]: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/getcwd-wgetcwd
| 0debug
|
static bool tlb_is_dirty_ram(CPUTLBEntry *tlbe)
{
return (tlbe->addr_write & (TLB_INVALID_MASK|TLB_MMIO|TLB_NOTDIRTY)) == 0;
}
| 1threat
|
If a record is inserted and if the same record is deleted in the same transaction, does that count as an insertion at all? : <p>If I have a database transaction where a database is created and deleted within the same transaction, would it be counted as an insertion?</p>
<p>Thanks!</p>
| 0debug
|
static int nut_probe(AVProbeData *p) {
if (p->buf_size >= ID_LENGTH && !memcmp(p->buf, ID_STRING, ID_LENGTH)) return AVPROBE_SCORE_MAX;
return 0;
}
| 1threat
|
Convert VB Date code to C# : I am converting an existing vb application to .net, in the existing code i found the condition below.How can I write this condition in C# ? Thanks in Advance
if CLng(Right(request("yr"),4))=CLng(Year(Date())) then
//I am confused only in Year(Date()) how can I replace these functions in C#
| 0debug
|
static int decode_header(PSDContext * s)
{
int signature, version, color_mode, compression;
int64_t len_section;
int ret = 0;
if (bytestream2_get_bytes_left(&s->gb) < 30) {
av_log(s->avctx, AV_LOG_ERROR, "Header too short to parse.\n");
return AVERROR_INVALIDDATA;
}
signature = bytestream2_get_le32(&s->gb);
if (signature != MKTAG('8','B','P','S')) {
av_log(s->avctx, AV_LOG_ERROR, "Wrong signature %d.\n", signature);
return AVERROR_INVALIDDATA;
}
version = bytestream2_get_be16(&s->gb);
if (version != 1) {
av_log(s->avctx, AV_LOG_ERROR, "Wrong version %d.\n", version);
return AVERROR_INVALIDDATA;
}
bytestream2_skip(&s->gb, 6);
s->channel_count = bytestream2_get_be16(&s->gb);
if ((s->channel_count < 1) || (s->channel_count > 56)) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid channel count %d.\n", s->channel_count);
return AVERROR_INVALIDDATA;
}
s->height = bytestream2_get_be32(&s->gb);
if ((s->height > 30000) && (s->avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL)) {
av_log(s->avctx, AV_LOG_ERROR,
"Height > 30000 is experimental, add "
"'-strict %d' if you want to try to decode the picture.\n",
FF_COMPLIANCE_EXPERIMENTAL);
return AVERROR_EXPERIMENTAL;
}
s->width = bytestream2_get_be32(&s->gb);
if ((s->width > 30000) && (s->avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL)) {
av_log(s->avctx, AV_LOG_ERROR,
"Width > 30000 is experimental, add "
"'-strict %d' if you want to try to decode the picture.\n",
FF_COMPLIANCE_EXPERIMENTAL);
return AVERROR_EXPERIMENTAL;
}
if ((ret = ff_set_dimensions(s->avctx, s->width, s->height)) < 0)
return ret;
s->channel_depth = bytestream2_get_be16(&s->gb);
color_mode = bytestream2_get_be16(&s->gb);
switch (color_mode) {
case 0:
s->color_mode = PSD_BITMAP;
break;
case 1:
s->color_mode = PSD_GRAYSCALE;
break;
case 2:
s->color_mode = PSD_INDEXED;
break;
case 3:
s->color_mode = PSD_RGB;
break;
case 4:
s->color_mode = PSD_CMYK;
break;
case 7:
s->color_mode = PSD_MULTICHANNEL;
break;
case 8:
s->color_mode = PSD_DUOTONE;
break;
case 9:
s->color_mode = PSD_LAB;
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Unknown color mode %d.\n", color_mode);
return AVERROR_INVALIDDATA;
}
len_section = bytestream2_get_be32(&s->gb);
if (len_section < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Negative size for color map data section.\n");
return AVERROR_INVALIDDATA;
}
if (bytestream2_get_bytes_left(&s->gb) < (len_section + 4)) {
av_log(s->avctx, AV_LOG_ERROR, "Incomplete file.\n");
return AVERROR_INVALIDDATA;
}
bytestream2_skip(&s->gb, len_section);
len_section = bytestream2_get_be32(&s->gb);
if (len_section < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Negative size for image ressources section.\n");
return AVERROR_INVALIDDATA;
}
if (bytestream2_get_bytes_left(&s->gb) < (len_section + 4)) {
av_log(s->avctx, AV_LOG_ERROR, "Incomplete file.\n");
return AVERROR_INVALIDDATA;
}
bytestream2_skip(&s->gb, len_section);
len_section = bytestream2_get_be32(&s->gb);
if (len_section < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Negative size for layers and masks data section.\n");
return AVERROR_INVALIDDATA;
}
if (bytestream2_get_bytes_left(&s->gb) < len_section) {
av_log(s->avctx, AV_LOG_ERROR, "Incomplete file.\n");
return AVERROR_INVALIDDATA;
}
bytestream2_skip(&s->gb, len_section);
if (bytestream2_get_bytes_left(&s->gb) < 2) {
av_log(s->avctx, AV_LOG_ERROR, "File without image data section.\n");
return AVERROR_INVALIDDATA;
}
s->compression = bytestream2_get_be16(&s->gb);
switch (s->compression) {
case 0:
case 1:
break;
case 2:
avpriv_request_sample(s->avctx, "ZIP without predictor compression");
return AVERROR_PATCHWELCOME;
break;
case 3:
avpriv_request_sample(s->avctx, "ZIP with predictor compression");
return AVERROR_PATCHWELCOME;
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Unknown compression %d.\n", compression);
return AVERROR_INVALIDDATA;
}
return ret;
}
| 1threat
|
Why does awk always print full lines? : <p>When attempting to use <code>awk</code> to get the process ID from the output of <code>ps aux</code> like so:</p>
<pre><code>ps aux | awk "{ print $2 }"
</code></pre>
<p>No matter what number of row I attempt to print, <code>awk</code> always outputs the full line. I've never managed to get it to work properly. I'm using macOS which apparently uses a different type/version of <code>awk</code>, but I can't find an alternative syntax which might work.</p>
<p>Any advice would be greatly appreciated!</p>
| 0debug
|
int main(int argc, char **argv)
{
int ret = EXIT_SUCCESS;
GAState *s = g_new0(GAState, 1);
GAConfig *config = g_new0(GAConfig, 1);
config->log_level = G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL;
module_call_init(MODULE_INIT_QAPI);
init_dfl_pathnames();
config_load(config);
config_parse(config, argc, argv);
if (config->pid_filepath == NULL) {
config->pid_filepath = g_strdup(dfl_pathnames.pidfile);
if (config->state_dir == NULL) {
config->state_dir = g_strdup(dfl_pathnames.state_dir);
if (config->method == NULL) {
config->method = g_strdup("virtio-serial");
if (config->channel_path == NULL) {
if (strcmp(config->method, "virtio-serial") == 0) {
config->channel_path = g_strdup(QGA_VIRTIO_PATH_DEFAULT);
} else if (strcmp(config->method, "isa-serial") == 0) {
config->channel_path = g_strdup(QGA_SERIAL_PATH_DEFAULT);
} else {
g_critical("must specify a path for this channel");
ret = EXIT_FAILURE;
goto end;
s->log_level = config->log_level;
s->log_file = stderr;
#ifdef CONFIG_FSFREEZE
s->fsfreeze_hook = config->fsfreeze_hook;
#endif
s->pstate_filepath = g_strdup_printf("%s/qga.state", config->state_dir);
s->state_filepath_isfrozen = g_strdup_printf("%s/qga.state.isfrozen",
config->state_dir);
s->frozen = check_is_frozen(s);
if (config->dumpconf) {
config_dump(config);
goto end;
ret = run_agent(s, config);
end:
if (s->command_state) {
ga_command_state_cleanup_all(s->command_state);
ga_command_state_free(s->command_state);
json_message_parser_destroy(&s->parser);
if (s->channel) {
ga_channel_free(s->channel);
g_free(s->pstate_filepath);
g_free(s->state_filepath_isfrozen);
if (config->daemonize) {
unlink(config->pid_filepath);
config_free(config);
return ret;
| 1threat
|
c# windows desktop application.MVS : <p>I want to learn windows desktop application c# (MVS).Just need to know from where I need to start, any book link or tutorial will help. </p>
| 0debug
|
static uint32_t isa_mmio_readb (void *opaque, target_phys_addr_t addr)
{
return cpu_inb(addr & IOPORTS_MASK);
}
| 1threat
|
How to choose keys from a python dictionary based on weighted probability? : <p>I have a Python dictionary where keys represent some item and values represent some (normalized) weighting for said item. For example:</p>
<pre><code>d = {'a': 0.0625, 'c': 0.625, 'b': 0.3125}
# Note that sum([v for k,v in d.iteritems()]) == 1 for all `d`
</code></pre>
<p>Given this correlation of items to weights, how can I choose a key from <code>d</code> such that 6.25% of the time the result is 'a', 32.25% of the time the result is 'b', and 62.5% of the result is 'c'? </p>
| 0debug
|
int net_init_slirp(QemuOpts *opts,
Monitor *mon,
const char *name,
VLANState *vlan)
{
struct slirp_config_str *config;
const char *vhost;
const char *vhostname;
const char *vdhcp_start;
const char *vnamesrv;
const char *tftp_export;
const char *bootfile;
const char *smb_export;
const char *vsmbsrv;
char *vnet = NULL;
int restricted = 0;
int ret;
vhost = qemu_opt_get(opts, "host");
vhostname = qemu_opt_get(opts, "hostname");
vdhcp_start = qemu_opt_get(opts, "dhcpstart");
vnamesrv = qemu_opt_get(opts, "dns");
tftp_export = qemu_opt_get(opts, "tftp");
bootfile = qemu_opt_get(opts, "bootfile");
smb_export = qemu_opt_get(opts, "smb");
vsmbsrv = qemu_opt_get(opts, "smbserver");
if (qemu_opt_get(opts, "ip")) {
const char *ip = qemu_opt_get(opts, "ip");
int l = strlen(ip) + strlen("/24") + 1;
vnet = qemu_malloc(l);
pstrcpy(vnet, l, ip);
pstrcat(vnet, l, "/24");
}
if (qemu_opt_get(opts, "net")) {
if (vnet) {
qemu_free(vnet);
}
vnet = qemu_strdup(qemu_opt_get(opts, "net"));
}
if (qemu_opt_get(opts, "restrict") &&
qemu_opt_get(opts, "restrict")[0] == 'y') {
restricted = 1;
}
qemu_opt_foreach(opts, net_init_slirp_configs, NULL, 0);
ret = net_slirp_init(vlan, "user", name, restricted, vnet, vhost,
vhostname, tftp_export, bootfile, vdhcp_start,
vnamesrv, smb_export, vsmbsrv);
while (slirp_configs) {
config = slirp_configs;
slirp_configs = config->next;
qemu_free(config);
}
if (ret != -1 && vlan) {
vlan->nb_host_devs++;
}
qemu_free(vnet);
return ret;
}
| 1threat
|
How to get time in seconds from d-m-y h:i:s? : <p>I found this:</p>
<pre><code>$minutes = (strtotime("2012-09-21 12:12:22") - time()) / 60;
</code></pre>
<p><a href="https://stackoverflow.com/questions/12520145/number-of-minutes-between-two-dates/12520198">In this question</a></p>
<p>But the string from the API that I took is like 06-09-19 | 16:23:17 and this code don't work at all.</p>
<p>How can I do?</p>
<p>Thanks.</p>
| 0debug
|
Using POST to get data instead of GET request : <p>I see in few legacy applications, POST request is used to return data to the client. Input data is provided in Form data.
Ideally to get data we should be using GET request.</p>
<p>What are the possible reasons to use POST instead of GET to get data ?</p>
<p>If its for security reasons, why we have GET in the first place ?
If input data is large, probably we may have to choose POST.</p>
<p>Please clarify.</p>
| 0debug
|
multi functional math calculator in c : i need write code to create a simple calculator using c language.
i need to put some basic function in here.
#include<stdio.h>
void main ()
{
int a,b,sum;
printf("");
scanf("%d",&a);
printf("");
scanf("%d",&b);
printf("enter 1 to add,2 to sub,3 to divi,4 to mul");
scanf("%d",&sum);
int add = a+b, sub =a-b,divi=a/b,mul=a*b;
if(sum==1)
printf("add of two values= %d",add);
if(sum==2)
printf("sub of two values=%d",sub);
if(sum==3)
printf("divi of two values=%d",divi);
if(sum==4)
printf("mul of two values=%d",mul);
}
this code terminate when input two integers and give the oprtion.i need write the code to terminate the code when i give "="
| 0debug
|
what is wrong in the following code?help me : `<!DOCTYPE html>
<html>
<body>
<h1>There was <p>before us a long <h3>piece </h3> of level road by the </p>riverside.</h1>
<p>John said to me, <b>"Now, <p>Beauty</p>, do your best"</b> and so I did</p>
</body>
</html>'
| 0debug
|
Cannot change dependencies of configuration ':app:api' after it has been included in dependency resolution : <p>Cannot change dependencies of configuration <strong>':app:api'</strong> after it has been included in dependency resolution.</p>
| 0debug
|
static int synth_superframe(AVCodecContext *ctx,
float *samples, int *data_size)
{
WMAVoiceContext *s = ctx->priv_data;
GetBitContext *gb = &s->gb, s_gb;
int n, res, n_samples = 480;
double lsps[MAX_FRAMES][MAX_LSPS];
const double *mean_lsf = s->lsps == 16 ?
wmavoice_mean_lsf16[s->lsp_def_mode] : wmavoice_mean_lsf10[s->lsp_def_mode];
float excitation[MAX_SIGNAL_HISTORY + MAX_SFRAMESIZE + 12];
float synth[MAX_LSPS + MAX_SFRAMESIZE];
memcpy(synth, s->synth_history,
s->lsps * sizeof(*synth));
memcpy(excitation, s->excitation_history,
s->history_nsamples * sizeof(*excitation));
if (s->sframe_cache_size > 0) {
gb = &s_gb;
init_get_bits(gb, s->sframe_cache, s->sframe_cache_size);
s->sframe_cache_size = 0;
}
if ((res = check_bits_for_superframe(gb, s)) == 1) {
*data_size = 0;
return 1;
}
if (!get_bits1(gb)) {
av_log_missing_feature(ctx, "WMAPro-in-WMAVoice support", 1);
return -1;
}
if (get_bits1(gb)) {
if ((n_samples = get_bits(gb, 12)) > 480) {
av_log(ctx, AV_LOG_ERROR,
"Superframe encodes >480 samples (%d), not allowed\n",
n_samples);
return -1;
}
}
if (s->has_residual_lsps) {
double prev_lsps[MAX_LSPS], a1[MAX_LSPS * 2], a2[MAX_LSPS * 2];
for (n = 0; n < s->lsps; n++)
prev_lsps[n] = s->prev_lsps[n] - mean_lsf[n];
if (s->lsps == 10) {
dequant_lsp10r(gb, lsps[2], prev_lsps, a1, a2, s->lsp_q_mode);
} else
dequant_lsp16r(gb, lsps[2], prev_lsps, a1, a2, s->lsp_q_mode);
for (n = 0; n < s->lsps; n++) {
lsps[0][n] = mean_lsf[n] + (a1[n] - a2[n * 2]);
lsps[1][n] = mean_lsf[n] + (a1[s->lsps + n] - a2[n * 2 + 1]);
lsps[2][n] += mean_lsf[n];
}
for (n = 0; n < 3; n++)
stabilize_lsps(lsps[n], s->lsps);
}
for (n = 0; n < 3; n++) {
if (!s->has_residual_lsps) {
int m;
if (s->lsps == 10) {
dequant_lsp10i(gb, lsps[n]);
} else
dequant_lsp16i(gb, lsps[n]);
for (m = 0; m < s->lsps; m++)
lsps[n][m] += mean_lsf[m];
stabilize_lsps(lsps[n], s->lsps);
}
if ((res = synth_frame(ctx, gb, n,
&samples[n * MAX_FRAMESIZE],
lsps[n], n == 0 ? s->prev_lsps : lsps[n - 1],
&excitation[s->history_nsamples + n * MAX_FRAMESIZE],
&synth[s->lsps + n * MAX_FRAMESIZE]))) {
*data_size = 0;
return res;
}
}
if (get_bits1(gb)) {
res = get_bits(gb, 4);
skip_bits(gb, 10 * (res + 1));
}
*data_size = n_samples * sizeof(float);
memcpy(s->prev_lsps, lsps[2],
s->lsps * sizeof(*s->prev_lsps));
memcpy(s->synth_history, &synth[MAX_SFRAMESIZE],
s->lsps * sizeof(*synth));
memcpy(s->excitation_history, &excitation[MAX_SFRAMESIZE],
s->history_nsamples * sizeof(*excitation));
if (s->do_apf)
memmove(s->zero_exc_pf, &s->zero_exc_pf[MAX_SFRAMESIZE],
s->history_nsamples * sizeof(*s->zero_exc_pf));
return 0;
}
| 1threat
|
How to deserialize and array string inside an array string in C# : i have an array string such a:
[{"633" : [{"8768" : "hello","8769" : "world"}],"634" : [{"8782" : "on","8783" : "No"}]}]
i am trying to deserialize/parse this string into an array.
Here is what I have done so far:
var arrString = "[{\"633\" : [{\"8768\" : \"hello\",\"8769\" : \"world\"}],\"634\" : [{\"8782\" : \"on\",\"8783\" : \"No\"}]}]"
var attendeeArray = JsonConvert.DeserializeObject<List<Dictionary<int, string>>>(arrString); //error
this gives me the error: *Additional information: Unexpected character encountered while parsing value: [. Path '[0].633', line 1, position 11.*
i'm wondering if its because I'm calling int, string. when it should be something like int, array (int, string)???
| 0debug
|
how to use the "imread" command in skiimage to read as well as write? : how to use the read function in scikit-image to read as well as write an image?
"Code written in OpenCV"
cv2.imwrite(filename, image)
imagenew = cv2.imread(filename)
"Code written in skiimage"
filename=imread(image,as_gray=True)
imagenew=imread(filename,as_gray=True)
| 0debug
|
How to fix 'if bool' statement from an read file def : <p>So I try to make an app to help a friend on day by day job and I created a settings and language to be more easy to change around some app properties and both of them have same idea of reading some text file but one is work and other one not :(</p>
<p>I tried to delete tabs title translations and is work, but when I place them back the language.py will not want to work.</p>
<p>Reading the language file is not working</p>
<pre class="lang-py prettyprint-override"><code>#// Try to read language file
langf = "asi_lang_"
lange = ".kmc"
app_title = ""
tab_dimensions = ""
tab_materials = ""
tab_settings = ""
def readFileLanguage(langName):
global app_title, tab_dimensions, tab_materials, tab_settings
file = fr"res\lang\{langf}{langName}{lange}"
try:
with open(file, mode="r", encoding="utf-8") as r:
l = r.readline()
while l:
if "=" in l:
x = l.split("=")
data=x[0]; info=x[1]
if "\n" in info:
info = info.replace("\n", "")
if data == "app_title":
app_title = info
l = r.readline()
elif data == "tab_dimensions":
tab_dimensions = info
l = r.readable()
elif data == "tab_materials":
tab_materials = info
l = r.readable()
elif data == "tab_settings":
tab_settings = info
l = r.readable()
else:
l = r.readline()
else:
l = r.readline()
finally:
r.close()
</code></pre>
<p>The language file (asi_lang_ro.kmc) is look like this:</p>
<pre><code>#// KmcASI language file
app_title=Testare App
#// If I delete this lines will work but I need them
tab_dimensions=Dimensiuni
tab_materials=Materiale
tab_settings=Setari
#// End file
</code></pre>
<p>Console output:</p>
<pre><code>Traceback (most recent call last):
File "C:/Users/Andrei/PycharmProjects/Testing/main.py", line 10, in <module>
readFileLanguage(app_language)
File "C:\Users\Andrei\PycharmProjects\Testing\res\lib\language.py", line 19, in readFileLanguage
if "=" in l:
TypeError: argument of type 'bool' is not iterable
</code></pre>
<p>I will expected some tabs to get the names from language file. If I delete them will work but will not show any text on that tabs.</p>
| 0debug
|
int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size, AVCodecParserContext *s)
{
int i;
uint32_t state = pc->state;
if (buf_size == 0)
return 0;
for (i = 0; i < buf_size; i++) {
av_assert1(pc->frame_start_found >= 0 && pc->frame_start_found <= 4);
if (pc->frame_start_found & 1) {
if (state == EXT_START_CODE && (buf[i] & 0xF0) != 0x80)
pc->frame_start_found--;
else if (state == EXT_START_CODE + 2) {
if ((buf[i] & 3) == 3)
pc->frame_start_found = 0;
else
pc->frame_start_found = (pc->frame_start_found + 1) & 3;
}
state++;
} else {
i = avpriv_find_start_code(buf + i, buf + buf_size, &state) - buf - 1;
if (pc->frame_start_found == 0 && state >= SLICE_MIN_START_CODE && state <= SLICE_MAX_START_CODE) {
i++;
pc->frame_start_found = 4;
}
if (state == SEQ_END_CODE) {
pc->frame_start_found = 0;
pc->state=-1;
return i+1;
}
if (pc->frame_start_found == 2 && state == SEQ_START_CODE)
pc->frame_start_found = 0;
if (pc->frame_start_found < 4 && state == EXT_START_CODE)
pc->frame_start_found++;
if (pc->frame_start_found == 4 && (state & 0xFFFFFF00) == 0x100) {
if (state < SLICE_MIN_START_CODE || state > SLICE_MAX_START_CODE) {
pc->frame_start_found = 0;
pc->state = -1;
return i - 3;
}
}
if (pc->frame_start_found == 0 && s && state == PICTURE_START_CODE) {
ff_fetch_timestamp(s, i - 3, 1);
}
}
}
pc->state = state;
return END_NOT_FOUND;
}
| 1threat
|
void arm_handle_psci_call(ARMCPU *cpu)
{
CPUARMState *env = &cpu->env;
uint64_t param[4];
uint64_t context_id, mpidr;
target_ulong entry;
int32_t ret = 0;
int i;
for (i = 0; i < 4; i++) {
param[i] = is_a64(env) ? env->xregs[i] : env->regs[i];
}
if ((param[0] & QEMU_PSCI_0_2_64BIT) && !is_a64(env)) {
ret = QEMU_PSCI_RET_INVALID_PARAMS;
goto err;
}
switch (param[0]) {
CPUState *target_cpu_state;
ARMCPU *target_cpu;
case QEMU_PSCI_0_2_FN_PSCI_VERSION:
ret = QEMU_PSCI_0_2_RET_VERSION_0_2;
break;
case QEMU_PSCI_0_2_FN_MIGRATE_INFO_TYPE:
ret = QEMU_PSCI_0_2_RET_TOS_MIGRATION_NOT_REQUIRED;
break;
case QEMU_PSCI_0_2_FN_AFFINITY_INFO:
case QEMU_PSCI_0_2_FN64_AFFINITY_INFO:
mpidr = param[1];
switch (param[2]) {
case 0:
target_cpu_state = arm_get_cpu_by_id(mpidr);
if (!target_cpu_state) {
ret = QEMU_PSCI_RET_INVALID_PARAMS;
break;
}
target_cpu = ARM_CPU(target_cpu_state);
ret = target_cpu->powered_off ? 1 : 0;
break;
default:
ret = 0;
}
break;
case QEMU_PSCI_0_2_FN_SYSTEM_RESET:
qemu_system_reset_request();
goto cpu_off;
case QEMU_PSCI_0_2_FN_SYSTEM_OFF:
qemu_system_shutdown_request();
goto cpu_off;
case QEMU_PSCI_0_1_FN_CPU_ON:
case QEMU_PSCI_0_2_FN_CPU_ON:
case QEMU_PSCI_0_2_FN64_CPU_ON:
{
int target_el = arm_feature(env, ARM_FEATURE_EL2) ? 2 : 1;
bool target_aarch64 = arm_el_is_aa64(env, target_el);
mpidr = param[1];
entry = param[2];
context_id = param[3];
ret = arm_set_cpu_on(mpidr, entry, context_id,
target_el, target_aarch64);
break;
}
case QEMU_PSCI_0_1_FN_CPU_OFF:
case QEMU_PSCI_0_2_FN_CPU_OFF:
goto cpu_off;
case QEMU_PSCI_0_1_FN_CPU_SUSPEND:
case QEMU_PSCI_0_2_FN_CPU_SUSPEND:
case QEMU_PSCI_0_2_FN64_CPU_SUSPEND:
if (param[1] & 0xfffe0000) {
ret = QEMU_PSCI_RET_INVALID_PARAMS;
break;
}
if (is_a64(env)) {
env->xregs[0] = 0;
} else {
env->regs[0] = 0;
}
helper_wfi(env);
break;
case QEMU_PSCI_0_1_FN_MIGRATE:
case QEMU_PSCI_0_2_FN_MIGRATE:
ret = QEMU_PSCI_RET_NOT_SUPPORTED;
break;
default:
g_assert_not_reached();
}
err:
if (is_a64(env)) {
env->xregs[0] = ret;
} else {
env->regs[0] = ret;
}
return;
cpu_off:
ret = arm_set_cpu_off(cpu->mp_affinity);
assert(ret == QEMU_ARM_POWERCTL_RET_SUCCESS);
}
| 1threat
|
Blocking and Being New Home Screen Swift iOS : <p>I am new to Swift and iOS programming and I wanted to know if there was a way to essentially block other applications or have your application be the default Home Screen? The idea is a time-saving application so maybe totally hide text messages and the browser when it is enabled. </p>
<p>I saw that there is kind of a way to do this in Android, but wasn't sure if there was a way to do this with iOS. </p>
| 0debug
|
static int wc3_read_close(AVFormatContext *s)
{
Wc3DemuxContext *wc3 = s->priv_data;
av_free(wc3->palettes);
return 0;
}
| 1threat
|
How do I Integrate the Firebase cocoaPods in my custom swift framework? : <p>I want to build a iOS swift framework (ex. XYZ) which for users to login firebase with customized access token.
I finished my login method and get the access token in XYZ. Now I want to Integrate the Firebase in XYZ to pass the access token to Firebase.
So I install Firebase in XYZ with cocoaPods. and write the code and build a XYZ framework. Everything seems fine.</p>
<p>Than I create a swift project ABC, and import XYZ framework. Then I got error "Missing required module 'Firebase' " at the line I import XYZ.</p>
<p>If I also install Firebase in ABC with cocoaPods. It will run successfully but get many errors about "Class FirebaseXXX is implemented in both ABC and XYZ. One of the two will be used. Which one is undefined." And Crash soon.</p>
<p>Would Someone please help me to figure it out how to fix this problem?</p>
| 0debug
|
static bool qemu_opt_get_bool_helper(QemuOpts *opts, const char *name,
bool defval, bool del)
{
QemuOpt *opt = qemu_opt_find(opts, name);
bool ret = defval;
if (opt == NULL) {
const QemuOptDesc *desc = find_desc_by_name(opts->list->desc, name);
if (desc && desc->def_value_str) {
parse_option_bool(name, desc->def_value_str, &ret, &error_abort);
}
return ret;
}
assert(opt->desc && opt->desc->type == QEMU_OPT_BOOL);
ret = opt->value.boolean;
if (del) {
qemu_opt_del_all(opts, name);
}
return ret;
}
| 1threat
|
def concatenate_nested(test_tup1, test_tup2):
res = test_tup1 + test_tup2
return (res)
| 0debug
|
split a table into two and display vertically in the same page - HTML : I have a table with several rows in my html. When the html is printed, the table is cut in half and extra rows are printed in the next page. I would like to know if there is a way to split the table into two and display vertically next to each other in the same page?
| 0debug
|
static void disas_thumb_insn(CPUState *env, DisasContext *s)
{
uint32_t val, insn, op, rm, rn, rd, shift, cond;
int32_t offset;
int i;
TCGv tmp;
TCGv tmp2;
TCGv addr;
if (s->condexec_mask) {
cond = s->condexec_cond;
if (cond != 0x0e) {
s->condlabel = gen_new_label();
gen_test_cc(cond ^ 1, s->condlabel);
s->condjmp = 1;
}
}
insn = lduw_code(s->pc);
s->pc += 2;
switch (insn >> 12) {
case 0: case 1:
rd = insn & 7;
op = (insn >> 11) & 3;
if (op == 3) {
rn = (insn >> 3) & 7;
tmp = load_reg(s, rn);
if (insn & (1 << 10)) {
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, (insn >> 6) & 7);
} else {
rm = (insn >> 6) & 7;
tmp2 = load_reg(s, rm);
}
if (insn & (1 << 9)) {
if (s->condexec_mask)
tcg_gen_sub_i32(tmp, tmp, tmp2);
else
gen_helper_sub_cc(tmp, tmp, tmp2);
} else {
if (s->condexec_mask)
tcg_gen_add_i32(tmp, tmp, tmp2);
else
gen_helper_add_cc(tmp, tmp, tmp2);
}
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
} else {
rm = (insn >> 3) & 7;
shift = (insn >> 6) & 0x1f;
tmp = load_reg(s, rm);
gen_arm_shift_im(tmp, op, shift, s->condexec_mask == 0);
if (!s->condexec_mask)
gen_logic_CC(tmp);
store_reg(s, rd, tmp);
}
break;
case 2: case 3:
op = (insn >> 11) & 3;
rd = (insn >> 8) & 0x7;
if (op == 0) {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, insn & 0xff);
if (!s->condexec_mask)
gen_logic_CC(tmp);
store_reg(s, rd, tmp);
} else {
tmp = load_reg(s, rd);
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, insn & 0xff);
switch (op) {
case 1:
gen_helper_sub_cc(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
break;
case 2:
if (s->condexec_mask)
tcg_gen_add_i32(tmp, tmp, tmp2);
else
gen_helper_add_cc(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
break;
case 3:
if (s->condexec_mask)
tcg_gen_sub_i32(tmp, tmp, tmp2);
else
gen_helper_sub_cc(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
break;
}
}
break;
case 4:
if (insn & (1 << 11)) {
rd = (insn >> 8) & 7;
val = s->pc + 2 + ((insn & 0xff) * 4);
val &= ~(uint32_t)2;
addr = tcg_temp_new_i32();
tcg_gen_movi_i32(addr, val);
tmp = gen_ld32(addr, IS_USER(s));
tcg_temp_free_i32(addr);
store_reg(s, rd, tmp);
break;
}
if (insn & (1 << 10)) {
rd = (insn & 7) | ((insn >> 4) & 8);
rm = (insn >> 3) & 0xf;
op = (insn >> 8) & 3;
switch (op) {
case 0:
tmp = load_reg(s, rd);
tmp2 = load_reg(s, rm);
tcg_gen_add_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
break;
case 1:
tmp = load_reg(s, rd);
tmp2 = load_reg(s, rm);
gen_helper_sub_cc(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp);
break;
case 2:
tmp = load_reg(s, rm);
store_reg(s, rd, tmp);
break;
case 3:
tmp = load_reg(s, rm);
if (insn & (1 << 7)) {
val = (uint32_t)s->pc | 1;
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, val);
store_reg(s, 14, tmp2);
}
gen_bx(s, tmp);
break;
}
break;
}
rd = insn & 7;
rm = (insn >> 3) & 7;
op = (insn >> 6) & 0xf;
if (op == 2 || op == 3 || op == 4 || op == 7) {
val = rm;
rm = rd;
rd = val;
val = 1;
} else {
val = 0;
}
if (op == 9) {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, 0);
} else if (op != 0xf) {
tmp = load_reg(s, rd);
} else {
TCGV_UNUSED(tmp);
}
tmp2 = load_reg(s, rm);
switch (op) {
case 0x0:
tcg_gen_and_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0x1:
tcg_gen_xor_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0x2:
if (s->condexec_mask) {
gen_helper_shl(tmp2, tmp2, tmp);
} else {
gen_helper_shl_cc(tmp2, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x3:
if (s->condexec_mask) {
gen_helper_shr(tmp2, tmp2, tmp);
} else {
gen_helper_shr_cc(tmp2, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x4:
if (s->condexec_mask) {
gen_helper_sar(tmp2, tmp2, tmp);
} else {
gen_helper_sar_cc(tmp2, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x5:
if (s->condexec_mask)
gen_adc(tmp, tmp2);
else
gen_helper_adc_cc(tmp, tmp, tmp2);
break;
case 0x6:
if (s->condexec_mask)
gen_sub_carry(tmp, tmp, tmp2);
else
gen_helper_sbc_cc(tmp, tmp, tmp2);
break;
case 0x7:
if (s->condexec_mask) {
tcg_gen_andi_i32(tmp, tmp, 0x1f);
tcg_gen_rotr_i32(tmp2, tmp2, tmp);
} else {
gen_helper_ror_cc(tmp2, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x8:
tcg_gen_and_i32(tmp, tmp, tmp2);
gen_logic_CC(tmp);
rd = 16;
break;
case 0x9:
if (s->condexec_mask)
tcg_gen_neg_i32(tmp, tmp2);
else
gen_helper_sub_cc(tmp, tmp, tmp2);
break;
case 0xa:
gen_helper_sub_cc(tmp, tmp, tmp2);
rd = 16;
break;
case 0xb:
gen_helper_add_cc(tmp, tmp, tmp2);
rd = 16;
break;
case 0xc:
tcg_gen_or_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0xd:
tcg_gen_mul_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0xe:
tcg_gen_andc_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0xf:
tcg_gen_not_i32(tmp2, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp2);
val = 1;
rm = rd;
break;
}
if (rd != 16) {
if (val) {
store_reg(s, rm, tmp2);
if (op != 0xf)
tcg_temp_free_i32(tmp);
} else {
store_reg(s, rd, tmp);
tcg_temp_free_i32(tmp2);
}
} else {
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
}
break;
case 5:
rd = insn & 7;
rn = (insn >> 3) & 7;
rm = (insn >> 6) & 7;
op = (insn >> 9) & 7;
addr = load_reg(s, rn);
tmp = load_reg(s, rm);
tcg_gen_add_i32(addr, addr, tmp);
tcg_temp_free_i32(tmp);
if (op < 3)
tmp = load_reg(s, rd);
switch (op) {
case 0:
gen_st32(tmp, addr, IS_USER(s));
break;
case 1:
gen_st16(tmp, addr, IS_USER(s));
break;
case 2:
gen_st8(tmp, addr, IS_USER(s));
break;
case 3:
tmp = gen_ld8s(addr, IS_USER(s));
break;
case 4:
tmp = gen_ld32(addr, IS_USER(s));
break;
case 5:
tmp = gen_ld16u(addr, IS_USER(s));
break;
case 6:
tmp = gen_ld8u(addr, IS_USER(s));
break;
case 7:
tmp = gen_ld16s(addr, IS_USER(s));
break;
}
if (op >= 3)
store_reg(s, rd, tmp);
tcg_temp_free_i32(addr);
break;
case 6:
rd = insn & 7;
rn = (insn >> 3) & 7;
addr = load_reg(s, rn);
val = (insn >> 4) & 0x7c;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
tmp = gen_ld32(addr, IS_USER(s));
store_reg(s, rd, tmp);
} else {
tmp = load_reg(s, rd);
gen_st32(tmp, addr, IS_USER(s));
}
tcg_temp_free_i32(addr);
break;
case 7:
rd = insn & 7;
rn = (insn >> 3) & 7;
addr = load_reg(s, rn);
val = (insn >> 6) & 0x1f;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
tmp = gen_ld8u(addr, IS_USER(s));
store_reg(s, rd, tmp);
} else {
tmp = load_reg(s, rd);
gen_st8(tmp, addr, IS_USER(s));
}
tcg_temp_free_i32(addr);
break;
case 8:
rd = insn & 7;
rn = (insn >> 3) & 7;
addr = load_reg(s, rn);
val = (insn >> 5) & 0x3e;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
tmp = gen_ld16u(addr, IS_USER(s));
store_reg(s, rd, tmp);
} else {
tmp = load_reg(s, rd);
gen_st16(tmp, addr, IS_USER(s));
}
tcg_temp_free_i32(addr);
break;
case 9:
rd = (insn >> 8) & 7;
addr = load_reg(s, 13);
val = (insn & 0xff) * 4;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
tmp = gen_ld32(addr, IS_USER(s));
store_reg(s, rd, tmp);
} else {
tmp = load_reg(s, rd);
gen_st32(tmp, addr, IS_USER(s));
}
tcg_temp_free_i32(addr);
break;
case 10:
rd = (insn >> 8) & 7;
if (insn & (1 << 11)) {
tmp = load_reg(s, 13);
} else {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, (s->pc + 2) & ~(uint32_t)2);
}
val = (insn & 0xff) * 4;
tcg_gen_addi_i32(tmp, tmp, val);
store_reg(s, rd, tmp);
break;
case 11:
op = (insn >> 8) & 0xf;
switch (op) {
case 0:
tmp = load_reg(s, 13);
val = (insn & 0x7f) * 4;
if (insn & (1 << 7))
val = -(int32_t)val;
tcg_gen_addi_i32(tmp, tmp, val);
store_reg(s, 13, tmp);
break;
case 2:
ARCH(6);
rd = insn & 7;
rm = (insn >> 3) & 7;
tmp = load_reg(s, rm);
switch ((insn >> 6) & 3) {
case 0: gen_sxth(tmp); break;
case 1: gen_sxtb(tmp); break;
case 2: gen_uxth(tmp); break;
case 3: gen_uxtb(tmp); break;
}
store_reg(s, rd, tmp);
break;
case 4: case 5: case 0xc: case 0xd:
addr = load_reg(s, 13);
if (insn & (1 << 8))
offset = 4;
else
offset = 0;
for (i = 0; i < 8; i++) {
if (insn & (1 << i))
offset += 4;
}
if ((insn & (1 << 11)) == 0) {
tcg_gen_addi_i32(addr, addr, -offset);
}
for (i = 0; i < 8; i++) {
if (insn & (1 << i)) {
if (insn & (1 << 11)) {
tmp = gen_ld32(addr, IS_USER(s));
store_reg(s, i, tmp);
} else {
tmp = load_reg(s, i);
gen_st32(tmp, addr, IS_USER(s));
}
tcg_gen_addi_i32(addr, addr, 4);
}
}
TCGV_UNUSED(tmp);
if (insn & (1 << 8)) {
if (insn & (1 << 11)) {
tmp = gen_ld32(addr, IS_USER(s));
} else {
tmp = load_reg(s, 14);
gen_st32(tmp, addr, IS_USER(s));
}
tcg_gen_addi_i32(addr, addr, 4);
}
if ((insn & (1 << 11)) == 0) {
tcg_gen_addi_i32(addr, addr, -offset);
}
store_reg(s, 13, addr);
if ((insn & 0x0900) == 0x0900)
gen_bx(s, tmp);
break;
case 1: case 3: case 9: case 11:
rm = insn & 7;
tmp = load_reg(s, rm);
s->condlabel = gen_new_label();
s->condjmp = 1;
if (insn & (1 << 11))
tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, s->condlabel);
else
tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, s->condlabel);
tcg_temp_free_i32(tmp);
offset = ((insn & 0xf8) >> 2) | (insn & 0x200) >> 3;
val = (uint32_t)s->pc + 2;
val += offset;
gen_jmp(s, val);
break;
case 15:
if ((insn & 0xf) == 0) {
gen_nop_hint(s, (insn >> 4) & 0xf);
break;
}
s->condexec_cond = (insn >> 4) & 0xe;
s->condexec_mask = insn & 0x1f;
break;
case 0xe:
gen_exception_insn(s, 2, EXCP_BKPT);
break;
case 0xa:
ARCH(6);
rn = (insn >> 3) & 0x7;
rd = insn & 0x7;
tmp = load_reg(s, rn);
switch ((insn >> 6) & 3) {
case 0: tcg_gen_bswap32_i32(tmp, tmp); break;
case 1: gen_rev16(tmp); break;
case 3: gen_revsh(tmp); break;
default: goto illegal_op;
}
store_reg(s, rd, tmp);
break;
case 6:
ARCH(6);
if (IS_USER(s))
break;
if (IS_M(env)) {
tmp = tcg_const_i32((insn & (1 << 4)) != 0);
if (insn & 1) {
addr = tcg_const_i32(16);
gen_helper_v7m_msr(cpu_env, addr, tmp);
tcg_temp_free_i32(addr);
}
if (insn & 2) {
addr = tcg_const_i32(17);
gen_helper_v7m_msr(cpu_env, addr, tmp);
tcg_temp_free_i32(addr);
}
tcg_temp_free_i32(tmp);
gen_lookup_tb(s);
} else {
if (insn & (1 << 4))
shift = CPSR_A | CPSR_I | CPSR_F;
else
shift = 0;
gen_set_psr_im(s, ((insn & 7) << 6), 0, shift);
}
break;
default:
goto undef;
}
break;
case 12:
rn = (insn >> 8) & 0x7;
addr = load_reg(s, rn);
for (i = 0; i < 8; i++) {
if (insn & (1 << i)) {
if (insn & (1 << 11)) {
tmp = gen_ld32(addr, IS_USER(s));
store_reg(s, i, tmp);
} else {
tmp = load_reg(s, i);
gen_st32(tmp, addr, IS_USER(s));
}
tcg_gen_addi_i32(addr, addr, 4);
}
}
if ((insn & (1 << rn)) == 0) {
store_reg(s, rn, addr);
} else {
tcg_temp_free_i32(addr);
}
break;
case 13:
cond = (insn >> 8) & 0xf;
if (cond == 0xe)
goto undef;
if (cond == 0xf) {
gen_set_pc_im(s->pc);
s->is_jmp = DISAS_SWI;
break;
}
s->condlabel = gen_new_label();
gen_test_cc(cond ^ 1, s->condlabel);
s->condjmp = 1;
val = (uint32_t)s->pc + 2;
offset = ((int32_t)insn << 24) >> 24;
val += offset << 1;
gen_jmp(s, val);
break;
case 14:
if (insn & (1 << 11)) {
if (disas_thumb2_insn(env, s, insn))
goto undef32;
break;
}
val = (uint32_t)s->pc;
offset = ((int32_t)insn << 21) >> 21;
val += (offset << 1) + 2;
gen_jmp(s, val);
break;
case 15:
if (disas_thumb2_insn(env, s, insn))
goto undef32;
break;
}
return;
undef32:
gen_exception_insn(s, 4, EXCP_UDEF);
return;
illegal_op:
undef:
gen_exception_insn(s, 2, EXCP_UDEF);
}
| 1threat
|
PyCharm: how to do post mortem debugging in the ipython interactive console? : <p>I've just started using the nice PyCharm community edition IDE, and can't do a simple thing that is part of my usual Python workflow.</p>
<p>I've started an ipython console and I can import my modules and interactively run commands. In PyCharm when I execute a function call, it is executed like it was running in a separate process. The console prompt can be used even before the execution finishes. Running ipython in a shell outside PyCharm, when an exception happens, I can run pdb's post mortem feature and investigate the problem:</p>
<pre><code>import pdb;pdb.pm()
</code></pre>
<p>I want to do the same in PyCharm: start post mortem debugging when an exception happens while I'm interactively investigating a problem. </p>
| 0debug
|
Using R with git and packrat : <p>I have been using git for a while but just recently started using packrat. I would like my repository to be self contained but at the same time I do not want to include CRAN packages as they are available. It seems once R is opened in a project with packrat it will try to use packages from project library; if they are not available then it will try to install from src in the project library; if they are not available it will look at libraries installed in that computer. If a library is not available in the computer; would it look at CRAN next?</p>
<p>What files should I include in my git repo as a minimum (e.g., packrat.lock)?</p>
| 0debug
|
Concatenation within the String in Python : How can I concatenate a word within the string at a particular index using Python?
For example:- In the string,
"Delhi is the capital of India."
I need to concatenate '123' before and after 'the'.
The output should be:- "Delhi is 123the123 capital of India."
| 0debug
|
Javaswing : load date from sql to java swing : [when i click button , it show one value . Then i click again and it's still the same ,how to click button and it show a new value next ?][1]
[1]: https://i.stack.imgur.com/OE7v1.png
| 0debug
|
BottomSheetDialogFragment - Allow scrolling child : <p>I have a <code>BottomSheetDialogFragment</code> with a <code>RecyclerView</code>. The problem is, I want to disable the drag close function of the <code>BottomSheetDialogFragment</code> as long as the <code>RecyclerView</code> is not scrolled up (currently I can't scroll my <code>RecyclerView</code> as the attempt will always close the <code>BottomSheetDialogFragment</code>). Any ideas how to achieve this?</p>
| 0debug
|
audio auto play next song when previous is finished : <p>I want to create an audio background player where user can only click on image to play or stop the playback. I have trouble creating or rewirting existing codes to make a playlist for it, that automatically plays next song when previous is finished. I want to do it in vanilla js.
<br> Here is what I have so far:
<br><a href="https://jsfiddle.net/rockarou/ad8Lkkrj/">https://jsfiddle.net/rockarou/ad8Lkkrj/</a></p>
<pre><code>var imageTracker = 'playImage';
swapImage = function() {
var image = document.getElementById('swapImage');
if (imageTracker == 'playImage') {
image.src = 'http://findicons.com/files/icons/129/soft_scraps/256/button_pause_01.png';
imageTracker = 'stopImage';
} else {
image.src = 'http://findicons.com/files/icons/129/soft_scraps/256/button_play_01.png';
imageTracker = 'playImage';
}
};
var musicTracker = 'noMusic';
audioStatus = function() {
var music = document.getElementById('natureSounds');
if (musicTracker == 'noMusic') {
music.play();
musicTracker = 'playMusic';
} else {
music.pause();
musicTracker = 'noMusic';
}
};
</code></pre>
| 0debug
|
how to get many Values from same InputBox and assign them to Variabls in c#? : i have 4 Buttons: button_1 writes in the InputBox the number 1, button_plus writes in the same Inputbox "+", the button_2 writes the number 2. finally stands in the Inputbox: 1 + 2
now i want to use the button_Equals, to get 1 + 2 from the Inputbox and assing them to a variable. I used int.Parse(), Int32.Parse() and Convert.ToInt32() to get both numbers the 1 und the 2, but it doesn't work:
r = int.Parse(textBox1.Text);
s =int.Parse(textBox1.Text);
id like to assign 1 to r and 2 to s but the Programm kolaps, when i click on the Button_Equals and it Shows the following message:
> System.FormatException
would you please help me how to get the both numbers in each in a variable? ill be so thankfull
| 0debug
|
How to upload to App Store from command line with Xcode 11? : <p>Previously, with Xcode 10, we were using <code>altool</code> to upload to App Store:</p>
<pre class="lang-sh prettyprint-override"><code>ALTOOL="/Applications/Xcode.app/Contents/Applications/Application Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Support/altool"
"$ALTOOL" --upload-app --file "$IPA_PATH" --username "$APP_STORE_USERNAME" --password @keychain:"Application Loader: $APP_STORE_USERNAME"
</code></pre>
<p>But with Xcode 11, "Application Loader.app" doesn't exist anymore, as part of <a href="https://developer.apple.com/documentation/xcode_release_notes/xcode_11_beta_release_notes/" rel="noreferrer">the Xcode 11 changes</a>:</p>
<blockquote>
<p>Xcode supports uploading apps from the Organizer window or from the command line with xcodebuild or xcrun altool. Application Loader is no longer included with Xcode. (29008875)</p>
</blockquote>
<p>So how do we upload from command line to TestFlight or App Store now?</p>
| 0debug
|
How to set "Ctrl + F12" as excel shortcut for "jump to the next active sheet", using macro : It's probably just me, but I get really annoyed at how Microsoft keyboard on Surface Laptop puts PageDown on its F12 key. Whenever I want to move to the next sheet in excel, I press "Ctrl + PageDown", but excel will decipher this as "Ctrl + F12".
Apparent PageDown only works when "Fn lock" is on, but when PageDown works, all other Function keys do not work. This is extremely trouble to me when I'm using excel.
Hence, I'm wondering if there will be method to assign "jump to the next active sheet" to "Ctrl + F12" using macro in excel (and "to previous sheet to "Ctrl+F11" as well), since I don't really use Ctrl +F12 or F11 anyways.
Thank you very much in advance!
Best,
| 0debug
|
static int open_input_file(OptionsContext *o, const char *filename)
{
InputFile *f;
AVFormatContext *ic;
AVInputFormat *file_iformat = NULL;
int err, i, ret;
int64_t timestamp;
uint8_t buf[128];
AVDictionary **opts;
AVDictionary *unused_opts = NULL;
AVDictionaryEntry *e = NULL;
int orig_nb_streams;
if (o->format) {
if (!(file_iformat = av_find_input_format(o->format))) {
av_log(NULL, AV_LOG_FATAL, "Unknown input format: '%s'\n", o->format);
exit_program(1);
}
}
if (!strcmp(filename, "-"))
filename = "pipe:";
using_stdin |= !strncmp(filename, "pipe:", 5) ||
!strcmp(filename, "/dev/stdin");
ic = avformat_alloc_context();
if (!ic) {
print_error(filename, AVERROR(ENOMEM));
exit_program(1);
}
if (o->nb_audio_sample_rate) {
snprintf(buf, sizeof(buf), "%d", o->audio_sample_rate[o->nb_audio_sample_rate - 1].u.i);
av_dict_set(&o->g->format_opts, "sample_rate", buf, 0);
}
if (o->nb_audio_channels) {
if (file_iformat && file_iformat->priv_class &&
av_opt_find(&file_iformat->priv_class, "channels", NULL, 0,
AV_OPT_SEARCH_FAKE_OBJ)) {
snprintf(buf, sizeof(buf), "%d",
o->audio_channels[o->nb_audio_channels - 1].u.i);
av_dict_set(&o->g->format_opts, "channels", buf, 0);
}
}
if (o->nb_frame_rates) {
if (file_iformat && file_iformat->priv_class &&
av_opt_find(&file_iformat->priv_class, "framerate", NULL, 0,
AV_OPT_SEARCH_FAKE_OBJ)) {
av_dict_set(&o->g->format_opts, "framerate",
o->frame_rates[o->nb_frame_rates - 1].u.str, 0);
}
}
if (o->nb_frame_sizes) {
av_dict_set(&o->g->format_opts, "video_size", o->frame_sizes[o->nb_frame_sizes - 1].u.str, 0);
}
if (o->nb_frame_pix_fmts)
av_dict_set(&o->g->format_opts, "pixel_format", o->frame_pix_fmts[o->nb_frame_pix_fmts - 1].u.str, 0);
ic->flags |= AVFMT_FLAG_NONBLOCK;
ic->interrupt_callback = int_cb;
err = avformat_open_input(&ic, filename, file_iformat, &o->g->format_opts);
if (err < 0) {
print_error(filename, err);
exit_program(1);
}
assert_avoptions(o->g->format_opts);
for (i = 0; i < ic->nb_streams; i++)
choose_decoder(o, ic, ic->streams[i]);
opts = setup_find_stream_info_opts(ic, o->g->codec_opts);
orig_nb_streams = ic->nb_streams;
ret = avformat_find_stream_info(ic, opts);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "%s: could not find codec parameters\n", filename);
avformat_close_input(&ic);
exit_program(1);
}
timestamp = o->start_time;
if (ic->start_time != AV_NOPTS_VALUE)
timestamp += ic->start_time;
if (o->start_time != 0) {
ret = av_seek_frame(ic, -1, timestamp, AVSEEK_FLAG_BACKWARD);
if (ret < 0) {
av_log(NULL, AV_LOG_WARNING, "%s: could not seek to position %0.3f\n",
filename, (double)timestamp / AV_TIME_BASE);
}
}
add_input_streams(o, ic);
av_dump_format(ic, nb_input_files, filename, 0);
GROW_ARRAY(input_files, nb_input_files);
f = av_mallocz(sizeof(*f));
if (!f)
exit_program(1);
input_files[nb_input_files - 1] = f;
f->ctx = ic;
f->ist_index = nb_input_streams - ic->nb_streams;
f->ts_offset = o->input_ts_offset - (copy_ts ? 0 : timestamp);
f->nb_streams = ic->nb_streams;
f->rate_emu = o->rate_emu;
unused_opts = strip_specifiers(o->g->codec_opts);
for (i = f->ist_index; i < nb_input_streams; i++) {
e = NULL;
while ((e = av_dict_get(input_streams[i]->opts, "", e,
AV_DICT_IGNORE_SUFFIX)))
av_dict_set(&unused_opts, e->key, NULL, 0);
}
e = NULL;
while ((e = av_dict_get(unused_opts, "", e, AV_DICT_IGNORE_SUFFIX))) {
const AVClass *class = avcodec_get_class();
const AVOption *option = av_opt_find(&class, e->key, NULL, 0,
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
if (!option)
continue;
if (!(option->flags & AV_OPT_FLAG_DECODING_PARAM)) {
av_log(NULL, AV_LOG_ERROR, "Codec AVOption %s (%s) specified for "
"input file #%d (%s) is not a decoding option.\n", e->key,
option->help ? option->help : "", nb_input_files - 1,
filename);
exit_program(1);
}
av_log(NULL, AV_LOG_WARNING, "Codec AVOption %s (%s) specified for "
"input file #%d (%s) has not been used for any stream. The most "
"likely reason is either wrong type (e.g. a video option with "
"no video streams) or that it is a private option of some decoder "
"which was not actually used for any stream.\n", e->key,
option->help ? option->help : "", nb_input_files - 1, filename);
}
av_dict_free(&unused_opts);
for (i = 0; i < o->nb_dump_attachment; i++) {
int j;
for (j = 0; j < ic->nb_streams; j++) {
AVStream *st = ic->streams[j];
if (check_stream_specifier(ic, st, o->dump_attachment[i].specifier) == 1)
dump_attachment(st, o->dump_attachment[i].u.str);
}
}
for (i = 0; i < orig_nb_streams; i++)
av_dict_free(&opts[i]);
av_freep(&opts);
return 0;
}
| 1threat
|
import math
def area_pentagon(a):
area=(math.sqrt(5*(5+2*math.sqrt(5)))*pow(a,2))/4.0
return area
| 0debug
|
Double expression calculated as integer : <p>If I compile this code:</p>
<p><code>int celsius = 41;
double result = celsius *9/5 + 32;</code></p>
<p>I get a result of 105.0, but casting celsius as double gets me the correct result of 105.8</p>
<p><code>int celsius = 41;
double result = (double)celsius *9/5 + 32;</code></p>
<p>Why I need to cast?</p>
| 0debug
|
void helper_ldq_l_raw(uint64_t t0, uint64_t t1)
{
env->lock = t1;
ldl_raw(t1, t0);
}
| 1threat
|
static void remote_block_to_network(RDMARemoteBlock *rb)
{
rb->remote_host_addr = htonll(rb->remote_host_addr);
rb->offset = htonll(rb->offset);
rb->length = htonll(rb->length);
rb->remote_rkey = htonl(rb->remote_rkey);
}
| 1threat
|
undefined reference to SIGN in C using GCC : <p>Many questions have been asked here about functions from math.h not being found in C code during compilation and I am facing a similar problem. Having gone through all of them, none seems to apply to my problem. I have some C code in a file called test1.c - </p>
<pre><code>#include <math.h>
int main(void) {
int j = SQR(4);
int i = (int)(sqrt(16.0));
}
</code></pre>
<p>Now, I compile this using - </p>
<pre><code>gcc -c -o ../../obj/test1.o test1.c -I../../include
</code></pre>
<p>And it produces the .o file. </p>
<p>Now, I try and create the executable using - </p>
<pre><code>gcc -o ../../bin/test1../../obj/test1.o -I../../include -lm
</code></pre>
<p>But this gives me the error below (most previous questions were solved by the -lm switch but I have that) - </p>
<pre><code>../../obj/test1.o:test1.c:(.text+0x13): undefined reference to `SQR'
../../obj/test1.o:test1.c:(.text+0x13): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `SQR'
</code></pre>
<p>Strangely, sqrt works but a host of other functions like SQR, SIGN etc lead to problems (the case doesn't matter). Note that these commands were generated by a make file - </p>
<pre><code>IDIR =../../include
CC=gcc
CFLAGS=-I$(IDIR)
ODIR=../../obj
LDIR =../../lib
LIBS=-lm
_DEPS = nrutil.h
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
_OBJ = test1.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
$(ODIR)/%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
../../bin/svdcmp: $(OBJ)
gcc -o $@ $^ $(CFLAGS) $(LIBS)
.PHONY: clean
clean:
rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~
</code></pre>
<p>I'm using Cygwin with Windows.</p>
| 0debug
|
static int yuv4_probe(AVProbeData *pd)
{
if (pd->buf_size <= sizeof(Y4M_MAGIC))
return 0;
if (strncmp(pd->buf, Y4M_MAGIC, sizeof(Y4M_MAGIC)-1)==0)
return AVPROBE_SCORE_MAX;
else
return 0;
}
| 1threat
|
Ionic build: difference between --prod and --release flags? : <p>When running an <code>ionic build</code> I'm curious as to the difference between the <code>--prod</code> and <code>--release</code> flags?</p>
<p>The <a href="https://ionicframework.com/docs/cli/cordova/build/" rel="noreferrer">Ionic build docs</a> state:</p>
<blockquote>
<p><strong>--prod</strong> Build the application for production<br>
<strong>--release</strong> Create a Cordova release build</p>
</blockquote>
<p>and while the <a href="https://cordova.apache.org/docs/en/latest/reference/cordova-cli/#cordova-prepare-command" rel="noreferrer">Cordova CLI ref</a> doesn't mention a <code>--prod</code> flag, it states the following for <code>--release</code>:</p>
<blockquote>
<p>Perform a release build. This typically translates to release mode for
the underlying platform being built.</p>
</blockquote>
<p>Looking at the difference in the build output, building with <code>--prod</code> seems to run an <strong>Ionic</strong> 'production' build, in that it also runs the <code>ngc</code> and <code>uglify</code> (which itself runs <code>cleancss</code>) tasks.</p>
<p>And when I run a build with <code>--release</code>, I seem to get a <strong>Cordova</strong> release build, which (per the docs) attempts to run a release build on whatever platform you're targeting.</p>
<p>Are those the only differences, or am I over-simplifying?</p>
<p>For reference, note the following output APK filesizes:</p>
<ul>
<li>Prod flag: 9.8 MB</li>
<li>Release flag: 11.7 MB</li>
<li>Prod + Release flags: 8.9 MB</li>
</ul>
<p>I'm using the latest (ATTOW) version of the Ionic Framework (3.9.2) and CLI (3.20.0).</p>
| 0debug
|
static void FUNC(put_hevc_qpel_bi_w_hv)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
int16_t *src2,
int height, int denom, int wx0, int wx1,
int ox0, int ox1, intptr_t mx, intptr_t my, int width)
{
int x, y;
const int8_t *filter;
pixel *src = (pixel*)_src;
ptrdiff_t srcstride = _srcstride / sizeof(pixel);
pixel *dst = (pixel *)_dst;
ptrdiff_t dststride = _dststride / sizeof(pixel);
int16_t tmp_array[(MAX_PB_SIZE + QPEL_EXTRA) * MAX_PB_SIZE];
int16_t *tmp = tmp_array;
int shift = 14 + 1 - BIT_DEPTH;
int log2Wd = denom + shift - 1;
src -= QPEL_EXTRA_BEFORE * srcstride;
filter = ff_hevc_qpel_filters[mx - 1];
for (y = 0; y < height + QPEL_EXTRA; y++) {
for (x = 0; x < width; x++)
tmp[x] = QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
src += srcstride;
tmp += MAX_PB_SIZE;
}
tmp = tmp_array + QPEL_EXTRA_BEFORE * MAX_PB_SIZE;
filter = ff_hevc_qpel_filters[my - 1];
ox0 = ox0 * (1 << (BIT_DEPTH - 8));
ox1 = ox1 * (1 << (BIT_DEPTH - 8));
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++)
dst[x] = av_clip_pixel(((QPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx1 + src2[x] * wx0 +
((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 1));
tmp += MAX_PB_SIZE;
dst += dststride;
src2 += MAX_PB_SIZE;
}
}
| 1threat
|
how to paging in operating system : I don't know how to figure out the answers. Thanks!
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/WGUnq.png
| 0debug
|
int v9fs_remove_xattr(FsContext *ctx,
const char *path, const char *name)
{
XattrOperations *xops = get_xattr_operations(ctx->xops, name);
if (xops) {
return xops->removexattr(ctx, path, name);
}
errno = -EOPNOTSUPP;
return -1;
}
| 1threat
|
Using Securimage captcha with Laravel 5.3 : <p>I installed a laravel package for securimage captcha, everything seems to be fine(as in it show the random captcha), but even after putting the correct text, it still says invalid.
can someone help me please.
Here is my code</p>
<pre><code>Route::any('/test-captcha', function (){
if (Request::getMethod() == 'POST')
{
$rules = ['captcha' => 'required|captcha'];
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails())
{
echo '<p style="color: #ff0000;">Incorrect!</p>';
}
else
{
echo '<p style="color: #00ff30;">Matched :)</p>';
}
}
$form = '<form method="post" action="test-captcha">';
$form .= '<input type="hidden" name="_token" value="' . csrf_token() . '">';
$form .= '<p>' . captcha_img() . '</p>';
$form .= '<p><button type="submit" name="check">Check</button></p>';
$form .= '</form>';
return $form;
});
</code></pre>
| 0debug
|
SpiceInfo *qmp_query_spice(Error **errp)
{
QemuOpts *opts = QTAILQ_FIRST(&qemu_spice_opts.head);
int port, tls_port;
const char *addr;
SpiceInfo *info;
char version_string[20];
info = g_malloc0(sizeof(*info));
if (!spice_server || !opts) {
info->enabled = false;
return info;
}
info->enabled = true;
info->migrated = spice_migration_completed;
addr = qemu_opt_get(opts, "addr");
port = qemu_opt_get_number(opts, "port", 0);
tls_port = qemu_opt_get_number(opts, "tls-port", 0);
info->has_auth = true;
info->auth = g_strdup(auth);
info->has_host = true;
info->host = g_strdup(addr ? addr : "0.0.0.0");
info->has_compiled_version = true;
snprintf(version_string, sizeof(version_string), "%d.%d.%d",
(SPICE_SERVER_VERSION & 0xff0000) >> 16,
(SPICE_SERVER_VERSION & 0xff00) >> 8,
SPICE_SERVER_VERSION & 0xff);
info->compiled_version = g_strdup(version_string);
if (port) {
info->has_port = true;
info->port = port;
}
if (tls_port) {
info->has_tls_port = true;
info->tls_port = tls_port;
}
info->mouse_mode = spice_server_is_server_mouse(spice_server) ?
SPICE_QUERY_MOUSE_MODE_SERVER :
SPICE_QUERY_MOUSE_MODE_CLIENT;
info->has_channels = true;
info->channels = qmp_query_spice_channels();
return info;
}
| 1threat
|
static int adx_encode_header(AVCodecContext *avctx,unsigned char *buf,size_t bufsize)
{
#if 0
struct {
uint32_t offset;
unsigned char unknown1[3];
unsigned char channel;
uint32_t freq;
uint32_t size;
uint32_t unknown2;
uint32_t unknown3;
uint32_t unknown4;
} adxhdr;
#endif
write_long(buf+0x00,0x80000000|0x20);
write_long(buf+0x04,0x03120400|avctx->channels);
write_long(buf+0x08,avctx->sample_rate);
write_long(buf+0x0c,0);
write_long(buf+0x10,0x01040300);
write_long(buf+0x14,0x00000000);
write_long(buf+0x18,0x00000000);
memcpy(buf+0x1c,"\0\0(c)CRI",8);
return 0x20+4;
}
| 1threat
|
Why does the read() function return an error? : <p>I used the read() function to read the contents from a file but got a -1 return value. The file is not empty, I think it might be the problem of data type, but I am not sure.
The contents of the file are like this:
1e00 000a 0600 0003 0100 0004 0300 0005
0800 0006 0900 0007 0b00 0003 0c00 0009
Thanks in advance.</p>
<pre><code>#define swapFname "test.disk"
int main(int argc, char const *argv[])
{
int diskfd;
unsigned *buf;
diskfd = open (swapFname, O_RDWR | O_CREAT, 0600);
int location = (2-2) * 16 * 8 + 0*8; // 0
int ret = lseek (diskfd, location, SEEK_SET);
int retsize = read (diskfd, (char *)buf, 32);
if (retsize < 0)
{ printf ("Error: Disk read returned incorrect size: %d\n", retsize);
exit(-1);
}
}
</code></pre>
| 0debug
|
How to specify the Chrome binary location via the selenium server standalone command line? : <p>I am using a portable version of Google Chrome that is not stored at the default location of my Windows 7 machine. I don't have admin rights to install Chrome at the default location.</p>
<p>Running <code>java -jar selenium-server-standalone-2.52.0.jar -help</code> does not hint any possibility of setting the path to the <strong>chrome binary</strong> (<strong>not the chrome driver</strong>). </p>
<p>The <a href="https://sites.google.com/a/chromium.org/chromedriver/capabilities" rel="noreferrer">chrome driver capabilities</a> indicate that it's possible to set the <strong>binary</strong> but I'm not sure how to do it via the command line.</p>
| 0debug
|
How to run IOS 10.1 on simulator in Xcode 8 : I'm updated to the iOS 10.1 beta on my device and xcode 8 won't let me run the simulator on my phone.
Anyone know how to fix this?
| 0debug
|
void palette8tobgr16(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette)
{
unsigned i;
for(i=0; i<num_pixels; i++)
((uint16_t *)dst)[i] = bswap_16(((uint16_t *)palette)[ src[i] ]);
}
| 1threat
|
static int img_rebase(int argc, char **argv)
{
BlockDriverState *bs, *bs_old_backing, *bs_new_backing;
BlockDriver *old_backing_drv, *new_backing_drv;
char *filename;
const char *fmt, *out_basefmt, *out_baseimg;
int c, flags, ret;
int unsafe = 0;
fmt = NULL;
out_baseimg = NULL;
out_basefmt = NULL;
for(;;) {
c = getopt(argc, argv, "uhf:F:b:");
if (c == -1)
break;
switch(c) {
case 'h':
help();
return 0;
case 'f':
fmt = optarg;
break;
case 'F':
out_basefmt = optarg;
break;
case 'b':
out_baseimg = optarg;
break;
case 'u':
unsafe = 1;
break;
}
}
if ((optind >= argc) || !out_baseimg)
help();
filename = argv[optind++];
flags = BDRV_O_FLAGS | BDRV_O_RDWR | (unsafe ? BDRV_O_NO_BACKING : 0);
bs = bdrv_new_open(filename, fmt, flags);
old_backing_drv = NULL;
new_backing_drv = NULL;
if (!unsafe && bs->backing_format[0] != '\0') {
old_backing_drv = bdrv_find_format(bs->backing_format);
if (old_backing_drv == NULL) {
error("Invalid format name: '%s'", bs->backing_format);
}
}
if (out_basefmt != NULL) {
new_backing_drv = bdrv_find_format(out_basefmt);
if (new_backing_drv == NULL) {
error("Invalid format name: '%s'", out_basefmt);
}
}
if (unsafe) {
bs_old_backing = NULL;
bs_new_backing = NULL;
} else {
char backing_name[1024];
bs_old_backing = bdrv_new("old_backing");
bdrv_get_backing_filename(bs, backing_name, sizeof(backing_name));
if (bdrv_open(bs_old_backing, backing_name, BDRV_O_FLAGS,
old_backing_drv))
{
error("Could not open old backing file '%s'", backing_name);
return -1;
}
bs_new_backing = bdrv_new("new_backing");
if (bdrv_open(bs_new_backing, out_baseimg, BDRV_O_FLAGS | BDRV_O_RDWR,
new_backing_drv))
{
error("Could not open new backing file '%s'", out_baseimg);
return -1;
}
}
if (!unsafe) {
uint64_t num_sectors;
uint64_t sector;
int n, n1;
uint8_t * buf_old;
uint8_t * buf_new;
buf_old = qemu_malloc(IO_BUF_SIZE);
buf_new = qemu_malloc(IO_BUF_SIZE);
bdrv_get_geometry(bs, &num_sectors);
for (sector = 0; sector < num_sectors; sector += n) {
if (sector + (IO_BUF_SIZE / 512) <= num_sectors) {
n = (IO_BUF_SIZE / 512);
} else {
n = num_sectors - sector;
}
if (bdrv_is_allocated(bs, sector, n, &n1)) {
n = n1;
continue;
}
if (bdrv_read(bs_old_backing, sector, buf_old, n) < 0) {
error("error while reading from old backing file");
}
if (bdrv_read(bs_new_backing, sector, buf_new, n) < 0) {
error("error while reading from new backing file");
}
uint64_t written = 0;
while (written < n) {
int pnum;
if (compare_sectors(buf_old + written * 512,
buf_new + written * 512, n - written, &pnum))
{
ret = bdrv_write(bs, sector + written,
buf_old + written * 512, pnum);
if (ret < 0) {
error("Error while writing to COW image: %s",
strerror(-ret));
}
}
written += pnum;
}
}
qemu_free(buf_old);
qemu_free(buf_new);
}
ret = bdrv_change_backing_file(bs, out_baseimg, out_basefmt);
if (ret == -ENOSPC) {
error("Could not change the backing file to '%s': No space left in "
"the file header", out_baseimg);
} else if (ret < 0) {
error("Could not change the backing file to '%s': %s",
out_baseimg, strerror(-ret));
}
if (!unsafe) {
bdrv_delete(bs_old_backing);
bdrv_delete(bs_new_backing);
}
bdrv_delete(bs);
return 0;
}
| 1threat
|
i cannot click on continue button nor exit button and exceed to next page. i have tried every thing.. i unable track aso.. please help me.? : <button accesskey="c" id="Continue" class="jfabtn" type="button" onclick="submitForm()"><u>C</u>ontinue</button>
My code
driver.findElement(By.id("Continue")).click();
or
driver.findElement(By.xpath("//*[@id=Continue]");
<button accesskey="x" id="Exit" class="jfabtn" type="button" onclick="exit()">E<u>x</u>it</button>
My code
driver.findElement(By.id("Exit")).click();
or
driver.findElement(By.xpath("//*[@id=Exit]");
| 0debug
|
Please Overloading '=' does not work : i was writing a code and i wrote an '=' operator to assign one object to another and a copy constructor. Here is the code
DJSet(const DJSet& ds)
{
vector<Element<T>* > vec= ds.v_;
for (int i = 0; i < vec.size(); i++)
{
v_.push_back(vec[i]);
}
//cout << "Copy Called\n";
}
DJSet operator=(DJSet ds)
{
DJSet<T> djs;
vector<Element<T>* > vec = ds.v_;
for (int i = 0; i < vec.size(); i++)
{
djs.v_.push_back(vec[i]);
}
cout << "= Called\n";
return djs;
}
The class DJSet contains only one Vector of `Element<T>* type`
So when i execute the code below.
DJSet<string> djs_rhs;
DJSet<string> djs_lhs;
cin >> name;
djs_rhs.add(name);
cin >> name;
djs_rhs.add(name);
cin >> name;
djs_lhs.add(name);
cin >> name;
djs_lhs.add(name);
djs_lhs = djs_rhs;
cout << djs_lhs << endl;
cout << endl;
cout << djs_rhs << endl;
It does not copy the values of the right hand side to left hand side objects. And it is calling both copy constructor and '=' operator. Please help me with this. So that i can continue with this. I can provide the whole source code if you want.
| 0debug
|
String decimal conversion in c# : <p>Please how do I convert a string from 2 decimal places to 5 decimal places in c#?</p>
<p>For example; I'm trying to convert 12.14 to 12.14000 using C#</p>
| 0debug
|
Learning Java and Eclipse : <p>I'm trying to write a login program in Eclipse. My question is what type of gui is best to use? I'm totally confused on gui types i.e swing (SWT), Jframe, window builder.... I know this is a broad question if possible,a simple answer would suffice.
Thanx in advance!</p>
| 0debug
|
How to fix error 'FB' is not defined no-undef on create-react-app project? : <p>I made the project using this link as my starting file.</p>
<p><a href="https://github.com/facebookincubator/create-react-app" rel="noreferrer">https://github.com/facebookincubator/create-react-app</a></p>
<p>But after i tried to make Facebook login button with follow by their official docs with this.</p>
<pre><code>componentDidMount(){
console.log('login mount');
window.fbAsyncInit = function() {
FB.init({
appId : '320866754951228',
xfbml : true,
version : 'v2.6'
});
FB.getLoginStatus(function(response) {
//this.statusChangeCallback(response);
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
}
</code></pre>
<p>So i got this errors when the browser was refreshed.</p>
<pre><code>Failed to compile.
Error in ./src/components/user_profile/LoginForm.js
/Sites/full_stack_production/xxxxx
70:13 error 'FB' is not defined no-undef
76:13 error 'FB' is not defined no-undef
✖ 2 problems (2 errors, 0 warnings)
</code></pre>
<p>So i guess because ESLint that cause this errors.
How can i fix this or make the exception for this <code>FB</code> variable?</p>
<p>Thanks! </p>
| 0debug
|
Java- String Manipulation : i am struggeling slightly and ask for some idea: i would like to remove all digits at the start of a string.
example: "123string67" to "string67"
Just the digits at the start, not at the end or the middle
maybe there is an easy regex command, if not it just can be just done by an own function
many thanks for your help
| 0debug
|
BlockDriverAIOCB *laio_submit(BlockDriverState *bs, void *aio_ctx, int fd,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque, int type)
{
struct qemu_laio_state *s = aio_ctx;
struct qemu_laiocb *laiocb;
struct iocb *iocbs;
off_t offset = sector_num * 512;
laiocb = qemu_aio_get(&laio_pool, bs, cb, opaque);
if (!laiocb)
return NULL;
laiocb->nbytes = nb_sectors * 512;
laiocb->ctx = s;
laiocb->ret = -EINPROGRESS;
laiocb->async_context_id = get_async_context_id();
iocbs = &laiocb->iocb;
switch (type) {
case QEMU_AIO_WRITE:
io_prep_pwritev(iocbs, fd, qiov->iov, qiov->niov, offset);
break;
case QEMU_AIO_READ:
io_prep_preadv(iocbs, fd, qiov->iov, qiov->niov, offset);
break;
default:
fprintf(stderr, "%s: invalid AIO request type 0x%x.\n",
__func__, type);
goto out_free_aiocb;
}
io_set_eventfd(&laiocb->iocb, s->efd);
s->count++;
if (io_submit(s->ctx, 1, &iocbs) < 0)
goto out_dec_count;
return &laiocb->common;
out_free_aiocb:
qemu_aio_release(laiocb);
out_dec_count:
s->count--;
return NULL;
}
| 1threat
|
static int decode_subframe_fixed(FLACContext *s, int channel, int pred_order)
{
int i;
av_log(s->avctx, AV_LOG_DEBUG, " SUBFRAME FIXED\n");
av_log(s->avctx, AV_LOG_DEBUG, " warm up samples: %d\n", pred_order);
for (i = 0; i < pred_order; i++)
{
s->decoded[channel][i] = get_sbits(&s->gb, s->curr_bps);
}
if (decode_residuals(s, channel, pred_order) < 0)
return -1;
switch(pred_order)
{
case 0:
break;
case 1:
for (i = pred_order; i < s->blocksize; i++)
s->decoded[channel][i] += s->decoded[channel][i-1];
break;
case 2:
for (i = pred_order; i < s->blocksize; i++)
s->decoded[channel][i] += 2*s->decoded[channel][i-1]
- s->decoded[channel][i-2];
break;
case 3:
for (i = pred_order; i < s->blocksize; i++)
s->decoded[channel][i] += 3*s->decoded[channel][i-1]
- 3*s->decoded[channel][i-2]
+ s->decoded[channel][i-3];
break;
case 4:
for (i = pred_order; i < s->blocksize; i++)
s->decoded[channel][i] += 4*s->decoded[channel][i-1]
- 6*s->decoded[channel][i-2]
+ 4*s->decoded[channel][i-3]
- s->decoded[channel][i-4];
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "illegal pred order %d\n", pred_order);
return -1;
}
return 0;
}
| 1threat
|
unable to create criteria query with dynaic value : i am trying to
> create critera query with dynamic fields
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
javax.persistence.criteria.CriteriaQuery cq = cb.createQuery();
Root<Abc> abc = cq.from(Abc.class);
List<Selection<?>> selectList = new ArrayList<Selection<?>>();
if(id!= null){
selectList.add(cq.select(abc.get("id"));
}
if(summary!=null){
selectionList.add(cq.select(abc.get("summary"));
}
cq.multiselect(selectList)
the above code gives syntax error
| 0debug
|
App not launching? : <p>I'm experiencing a strange behaviour. When I run my app via Xcode means it runs, but when I tap app icon in simulator/ iPhone means the app is not launching. I don't know why this is happening? Does anyone experienced the same problem? How can I solve this? Can anybody suggests me a solution. Thanks in advance. </p>
| 0debug
|
Delete index at array in Firestore : <p>I got this data in my document:</p>
<p><a href="https://i.stack.imgur.com/S0tbH.png" rel="noreferrer"><img src="https://i.stack.imgur.com/S0tbH.png" alt="enter image description here"></a></p>
<p>I want to delete index 0. How do I do this? This should do the trick I thought:</p>
<pre><code> db.collection("data").document("free").updateData(["deleteme.deletemee.0" : FieldValue.delete()]) { (errr) in
print(errr)
}
</code></pre>
<p>But the errr prints nil, and nothing is removed. When getting the document I noticed something strange about the data when using this code:</p>
<pre><code> db.collection("data").document("free").getDocument { (doc, err) in
guard let _doc = doc,
doc?.exists ?? false else{ return }
print(_doc.data())
}
</code></pre>
<p>This prints out:</p>
<pre><code>["deleteme": {
deletemee = (
1 //this is the value for the key, but where is my key?! :(
);
}]
</code></pre>
<p>I cannot see the key, where is it? How to delete something at an index in Firestore? Thanks.</p>
| 0debug
|
How can I edit my script to exclude capital letters A to Z? : Starts with 0 -> 9 -> A -> Z -> a -> z then begins the next sequence of 00 -> zz
I'd like to remove the A -> Z section of my code so the output goes from 0 -> 9 -> a -> z without counting A -> Z.
#include <iostream>
#include <vector>
using namespace std;
void Crack(string password, vector<char> Chars)
{
cout<<"PASSWORD TO CRACK: "<<password<<endl;
int n = Chars.size();
int i = 0;
while(true)
{
i++;
int N = 1;
for(int j=0;j<i;j++)N*=n;
for(int j=0;j<N;j++)
{
int K = 1;
string crack = "";
for(int k=0;k<i;k++)
{
crack += Chars[j/K%n];
K *= n;
}
cout<< "Testing PASS: "<<crack<<" "<<"against "<<password<<endl;
if(password.compare(crack) == 0){
cout<<"Cracked password: "<<crack<<endl;
return;
}
}
}
}
int main()
{
vector<char> Chars;
for(char c = '0';c<='z';c++){
if(isalpha(c) || isdigit(c))Chars.push_back(c);
}
Crack("zzzzzzzz", Chars);
}**strong text**
| 0debug
|
alert('Hello ' + user_input);
| 1threat
|
How to print all the instance in a class one by one? : This is the code. Error is in the last line. How to print all the instance in a class one by one?
error is : Traceback (most recent call last):
File "ex1.py", line 23, in <module>
print(n.age)
AttributeError: 'str' object has no attribute 'age'
class Person:
def __init__(self,fname,lname,age,gender):
self.fname = fname
self.lname = lname
self.age = age
self.gender = gender
class Children(Person):
def __init__(self,fname,lname,age,gender,friends):
super().__init__(fname,lname,age,gender)
self.friends = friends
a100 = Children("a1","a10",17,"male","a2 , a3 , a4 , a5")
a200 = Children("a2","a20",17,"male","a5, a1, a4, a3 ")
a300 = Children("a3", "a30" , 17 , "male", "a2, a1")
a400 = Children("a4","a40",17,"female", "a1, a2")
a500 = Children("a5","a50",16, "male","a2, a1")
x = ["a100","a300","a500","a200","a400"]
for n in x:
print(n.age)
| 0debug
|
Merge error : negative length vectors are not allowed : <p>I tried to merge two data.frames, and they are like below:</p>
<pre><code> GVKEY YEAR coperol delta vega firm_related_wealth
1 001045 1992 1 38.88885 17.86943 2998.816
2 001045 1993 1 33.57905 19.19287 2286.418
3 001045 1994 1 48.54719 16.85830 3924.053
4 001045 1995 1 111.46762 38.71565 8550.903
5 001045 1996 1 218.89279 45.59413 17834.921
6 001045 1997 1 415.61461 51.45863 34279.515
</code></pre>
<p>AND</p>
<pre><code> GVKEY YEAR fracdirafter fracdirafterindep twfracdirafter
1 001004 1996 1.00 0.70 1.000000000
2 001004 1997 0.00 0.00 0.000000000
3 001004 1998 0.00 0.00 0.000000000
4 001004 1999 0.00 0.00 0.000000000
5 001004 2000 0.00 0.00 0.000000000
6 001004 2001 0.25 0.25 0.009645437
</code></pre>
<p>They both have 1,048,575 rows. My code is <code>merge(a,b,by=c("GVKEY","YEAR"))</code>, I kept receiving error message "<code>negative length vectors are not allowed</code>". I also tried the data.table way, but got error message saying that my results would exceed 2^31 rows. Apparently, the merged data will not be so big, so I am not sure how to solve this issue.</p>
| 0debug
|
List comprehensions in Jinja : <p>I have two lists:</p>
<ol>
<li>strainInfo, which contains a dictionary element called 'replicateID'</li>
<li>selectedStrainInfo, which contains a dictionary element called 'replicateID'</li>
</ol>
<p>I'm looking to check if the replicateID of each of my strains is in a list of selected strains, in python it would be something like this:</p>
<pre><code>for strain in strainInfo:
if strain.replicateID in [selectedStrain.replicateID for selectedStrain in selectedStrainInfo]
print('This strain is selected')
</code></pre>
<p>I'm getting the correct functionality in django, but I'm wondering if there's a way to simplify using a list comprehension:</p>
<pre><code>{% for row in strainInfo %}
{% for selectedStrain in selectedStrainsInfo %}
{% if row.replicateID == selectedStrain.replicateID %}
checked
{% endif %}
{% endfor %}
{% endfor %}
</code></pre>
| 0debug
|
Pass parameters to mapDispatchToProps() : <p>I can't lie, i'm a bit confused about react-redux. I think lot of the actions require parameters (for an example deleting items from the store), but even if i'm still reading about how to dispatch from component in that way to pass a parameter, about 2 hours now, i didn't get any answers. I was tried with <code>this.props.dispatch</code> and with <code>mapDispatchToProps</code>, i always get the <code>this.props... is not a function</code> message. Here's what i'm trying to do:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code> const getTheArray = (array) => {
return {
type: 'GET_ARRAY',
array
}
}
class Example extends......
componentDidUpdate(){
//i have a button, and when it clicked, turns the status: 'deleted'
if (this.state.status === 'deleted'){
fetch('http://localhost:3001/deleteitem', {
method: 'post',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
id: this.props.id
})
})
.then(res => res.json())
.then(data => this.props.deleteFromArray(data))
.catch(err => console.log(err))
}
}
function mapStateToProps(state) {
return {
array: state.array
};
}
function mapDispatchToProps(dispatch) {
return({
deleteFromArray: (array) => {dispatch(getTheArray(array))}
})
}
export default connect(mapStateToProps, mapDispatchToProps)(Example);</code></pre>
</div>
</div>
</p>
<p>It isn't the only place where i need to dispatch with an action, where the action's object's properties depending on another property passed to the function, so i really want to do, what's the best way to pass property to action, and dispatch it within a react component.</p>
| 0debug
|
char *desc_get_buf(DescInfo *info, bool read_only)
{
PCIDevice *dev = PCI_DEVICE(info->ring->r);
size_t size = read_only ? le16_to_cpu(info->desc.tlv_size) :
le16_to_cpu(info->desc.buf_size);
if (size > info->buf_size) {
info->buf = g_realloc(info->buf, size);
info->buf_size = size;
}
if (!info->buf) {
return NULL;
}
pci_dma_read(dev, le64_to_cpu(info->desc.buf_addr), info->buf, size);
return info->buf;
}
| 1threat
|
void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge)
{
int i;
X86CPU *cpu = NULL;
Error *error = NULL;
unsigned long apic_id_limit;
if (cpu_model == NULL) {
#ifdef TARGET_X86_64
cpu_model = "qemu64";
#else
cpu_model = "qemu32";
#endif
}
current_cpu_model = cpu_model;
apic_id_limit = pc_apic_id_limit(max_cpus);
if (apic_id_limit > ACPI_CPU_HOTPLUG_ID_LIMIT) {
error_report("max_cpus is too large. APIC ID of last CPU is %lu",
apic_id_limit - 1);
exit(1);
}
for (i = 0; i < smp_cpus; i++) {
cpu = pc_new_cpu(cpu_model, x86_cpu_apic_id_from_index(i),
icc_bridge, &error);
if (error) {
error_report_err(error);
exit(1);
}
object_unref(OBJECT(cpu));
}
smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1_EDX]);
}
| 1threat
|
Shared memory lib compatible with linux and windows c++ : <p>I'm looking for a shared memory lib that can handle both linux and windows platforms. I want to use it by C++.
Please let me know if you know any.</p>
| 0debug
|
How to get available "app shortcuts" of a specific app? : <h2>Background</h2>
<p>Starting from API 25 of Android, apps can offer extra shortcuts in the launcher, by long clicking on them:</p>
<p><a href="https://i.stack.imgur.com/9p0O0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9p0O0.png" alt="enter image description here"></a></p>
<h2>The problem</h2>
<p>Thing is, all I've found is how your app can offer those shortcuts to the launcher, but I can't find out how the launcher gets the list of them.</p>
<p>Since it's a rather new API, and most users and developers don't even use it, I can't find much information about it, especially because I want to search of the "other side" of the API usage.</p>
<h2>What I've tried</h2>
<p>I tried reading the docs (<a href="https://developer.android.com/guide/topics/ui/shortcuts.html" rel="noreferrer"><strong>here</strong></a>, for example). I don't see it being mentioned. Only the part of other apps is mentioned, but not of the receiver app (the launcher).</p>
<h2>The questions</h2>
<p>Given a package name of an app, how can I get a list of all of its "app shortcuts" using the new API?</p>
<p>Is it possible to use it in order to request to create a Pinned Shortcut out of one of them?</p>
| 0debug
|
static int output_configure(AACContext *ac,
uint8_t layout_map[MAX_ELEM_ID * 4][3], int tags,
enum OCStatus oc_type, int get_new_frame)
{
AVCodecContext *avctx = ac->avctx;
int i, channels = 0, ret;
uint64_t layout = 0;
uint8_t id_map[TYPE_END][MAX_ELEM_ID] = {{ 0 }};
uint8_t type_counts[TYPE_END] = { 0 };
if (ac->oc[1].layout_map != layout_map) {
memcpy(ac->oc[1].layout_map, layout_map, tags * sizeof(layout_map[0]));
ac->oc[1].layout_map_tags = tags;
for (i = 0; i < tags; i++) {
int type = layout_map[i][0];
int id = layout_map[i][1];
id_map[type][id] = type_counts[type]++;
if (avctx->request_channel_layout != AV_CH_LAYOUT_NATIVE)
layout = sniff_channel_order(layout_map, tags);
for (i = 0; i < tags; i++) {
int type = layout_map[i][0];
int id = layout_map[i][1];
int iid = id_map[type][id];
int position = layout_map[i][2];
ret = che_configure(ac, position, type, iid, &channels);
if (ret < 0)
return ret;
ac->tag_che_map[type][id] = ac->che[type][iid];
if (ac->oc[1].m4ac.ps == 1 && channels == 2) {
if (layout == AV_CH_FRONT_CENTER) {
layout = AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT;
} else {
layout = 0;
if (layout) avctx->channel_layout = layout;
ac->oc[1].channel_layout = layout;
avctx->channels = ac->oc[1].channels = channels;
ac->oc[1].status = oc_type;
if (get_new_frame) {
if ((ret = frame_configure_elements(ac->avctx)) < 0)
return ret;
return 0;
| 1threat
|
static void nbd_recv_coroutines_enter_all(NbdClientSession *s)
{
int i;
for (i = 0; i < MAX_NBD_REQUESTS; i++) {
if (s->recv_coroutine[i]) {
qemu_coroutine_enter(s->recv_coroutine[i], NULL);
}
}
}
| 1threat
|
static uint8_t *xen_map_cache_unlocked(hwaddr phys_addr, hwaddr size,
uint8_t lock, bool dma)
{
MapCacheEntry *entry, *pentry = NULL;
hwaddr address_index;
hwaddr address_offset;
hwaddr cache_size = size;
hwaddr test_bit_size;
bool translated G_GNUC_UNUSED = false;
bool dummy = false;
tryagain:
address_index = phys_addr >> MCACHE_BUCKET_SHIFT;
address_offset = phys_addr & (MCACHE_BUCKET_SIZE - 1);
trace_xen_map_cache(phys_addr);
if (size) {
test_bit_size = size + (phys_addr & (XC_PAGE_SIZE - 1));
if (test_bit_size % XC_PAGE_SIZE) {
test_bit_size += XC_PAGE_SIZE - (test_bit_size % XC_PAGE_SIZE);
}
} else {
test_bit_size = XC_PAGE_SIZE;
}
if (mapcache->last_entry != NULL &&
mapcache->last_entry->paddr_index == address_index &&
!lock && !size &&
test_bits(address_offset >> XC_PAGE_SHIFT,
test_bit_size >> XC_PAGE_SHIFT,
mapcache->last_entry->valid_mapping)) {
trace_xen_map_cache_return(mapcache->last_entry->vaddr_base + address_offset);
return mapcache->last_entry->vaddr_base + address_offset;
}
if (size) {
cache_size = size + address_offset;
if (cache_size % MCACHE_BUCKET_SIZE) {
cache_size += MCACHE_BUCKET_SIZE - (cache_size % MCACHE_BUCKET_SIZE);
}
} else {
cache_size = MCACHE_BUCKET_SIZE;
}
entry = &mapcache->entry[address_index % mapcache->nr_buckets];
while (entry && entry->lock && entry->vaddr_base &&
(entry->paddr_index != address_index || entry->size != cache_size ||
!test_bits(address_offset >> XC_PAGE_SHIFT,
test_bit_size >> XC_PAGE_SHIFT,
entry->valid_mapping))) {
pentry = entry;
entry = entry->next;
}
if (!entry) {
entry = g_malloc0(sizeof (MapCacheEntry));
pentry->next = entry;
xen_remap_bucket(entry, NULL, cache_size, address_index, dummy);
} else if (!entry->lock) {
if (!entry->vaddr_base || entry->paddr_index != address_index ||
entry->size != cache_size ||
!test_bits(address_offset >> XC_PAGE_SHIFT,
test_bit_size >> XC_PAGE_SHIFT,
entry->valid_mapping)) {
xen_remap_bucket(entry, NULL, cache_size, address_index, dummy);
}
}
if(!test_bits(address_offset >> XC_PAGE_SHIFT,
test_bit_size >> XC_PAGE_SHIFT,
entry->valid_mapping)) {
mapcache->last_entry = NULL;
#ifdef XEN_COMPAT_PHYSMAP
if (!translated && mapcache->phys_offset_to_gaddr) {
phys_addr = mapcache->phys_offset_to_gaddr(phys_addr, size, mapcache->opaque);
translated = true;
goto tryagain;
}
#endif
if (!dummy && runstate_check(RUN_STATE_INMIGRATE)) {
dummy = true;
goto tryagain;
}
trace_xen_map_cache_return(NULL);
return NULL;
}
mapcache->last_entry = entry;
if (lock) {
MapCacheRev *reventry = g_malloc0(sizeof(MapCacheRev));
entry->lock++;
reventry->dma = dma;
reventry->vaddr_req = mapcache->last_entry->vaddr_base + address_offset;
reventry->paddr_index = mapcache->last_entry->paddr_index;
reventry->size = entry->size;
QTAILQ_INSERT_HEAD(&mapcache->locked_entries, reventry, next);
}
trace_xen_map_cache_return(mapcache->last_entry->vaddr_base + address_offset);
return mapcache->last_entry->vaddr_base + address_offset;
}
| 1threat
|
cont of teachers and students for each subject : I have 3 tables, user_table to classify as a teacher or student,
subject_table to mention different subject,
and enroll table stating who registered as teacher/student and for which subject.
I want to have count of student, teacher count for each subject
user_table
user_id
user_name
contact_no
password
flag
6
Abhis
123456788
123
s
5
Abhish
123456789
123
s
8
Sneha
1111111111
123
s
7
Snehil
1111112222
123
s
1
Narsingh
1234567890
123
t
2
Abhinav
1234567891
1234
t
3
Abhi
1234567892
123
s
4
Abhishek
1234567893
123
s
subject_table
sub_id
sub_name
3
CSS
1
HTML
2
JQUERY
enrolled_table
enr_id
sub_id
user_id
date
start_time
end_time
1
1
1
2016-04-01
09:00:00
10:00:00
2
2
1
2016-04-01
10:00:00
11:00:00
3
3
1
2016-04-01
11:00:00
12:00:00
4
1
5
2016-04-01
09:00:00
10:00:00
5
1
6
2016-04-01
12:00:00
13:00:00
6
1
7
2016-04-01
12:00:00
13:00:00
7
1
2
2016-04-01
13:00:00
14:00:00
8
2
2
2016-04-01
13:00:00
14:00:00
| 0debug
|
static int huffman_decode(MPADecodeContext *s, GranuleDef *g,
int16_t *exponents, int end_pos2)
{
int s_index;
int i;
int last_pos, bits_left;
VLC *vlc;
int end_pos = FFMIN(end_pos2, s->gb.size_in_bits);
s_index = 0;
for (i = 0; i < 3; i++) {
int j, k, l, linbits;
j = g->region_size[i];
if (j == 0)
continue;
k = g->table_select[i];
l = mpa_huff_data[k][0];
linbits = mpa_huff_data[k][1];
vlc = &huff_vlc[l];
if (!l) {
memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid) * 2 * j);
s_index += 2 * j;
continue;
}
for (; j > 0; j--) {
int exponent, x, y;
int v;
int pos = get_bits_count(&s->gb);
if (pos >= end_pos){
switch_buffer(s, &pos, &end_pos, &end_pos2);
if (pos >= end_pos)
break;
}
y = get_vlc2(&s->gb, vlc->table, 7, 3);
if (!y) {
g->sb_hybrid[s_index ] =
g->sb_hybrid[s_index+1] = 0;
s_index += 2;
continue;
}
exponent= exponents[s_index];
av_dlog(s->avctx, "region=%d n=%d x=%d y=%d exp=%d\n",
i, g->region_size[i] - j, x, y, exponent);
if (y & 16) {
x = y >> 5;
y = y & 0x0f;
if (x < 15) {
READ_FLIP_SIGN(g->sb_hybrid + s_index, RENAME(expval_table)[exponent] + x)
} else {
x += get_bitsz(&s->gb, linbits);
v = l3_unscale(x, exponent);
if (get_bits1(&s->gb))
v = -v;
g->sb_hybrid[s_index] = v;
}
if (y < 15) {
READ_FLIP_SIGN(g->sb_hybrid + s_index + 1, RENAME(expval_table)[exponent] + y)
} else {
y += get_bitsz(&s->gb, linbits);
v = l3_unscale(y, exponent);
if (get_bits1(&s->gb))
v = -v;
g->sb_hybrid[s_index+1] = v;
}
} else {
x = y >> 5;
y = y & 0x0f;
x += y;
if (x < 15) {
READ_FLIP_SIGN(g->sb_hybrid + s_index + !!y, RENAME(expval_table)[exponent] + x)
} else {
x += get_bitsz(&s->gb, linbits);
v = l3_unscale(x, exponent);
if (get_bits1(&s->gb))
v = -v;
g->sb_hybrid[s_index+!!y] = v;
}
g->sb_hybrid[s_index + !y] = 0;
}
s_index += 2;
}
}
vlc = &huff_quad_vlc[g->count1table_select];
last_pos = 0;
while (s_index <= 572) {
int pos, code;
pos = get_bits_count(&s->gb);
if (pos >= end_pos) {
if (pos > end_pos2 && last_pos) {
s_index -= 4;
skip_bits_long(&s->gb, last_pos - pos);
av_log(s->avctx, AV_LOG_INFO, "overread, skip %d enddists: %d %d\n", last_pos - pos, end_pos-pos, end_pos2-pos);
if(s->err_recognition & AV_EF_BITSTREAM)
s_index=0;
break;
}
switch_buffer(s, &pos, &end_pos, &end_pos2);
if (pos >= end_pos)
break;
}
last_pos = pos;
code = get_vlc2(&s->gb, vlc->table, vlc->bits, 1);
av_dlog(s->avctx, "t=%d code=%d\n", g->count1table_select, code);
g->sb_hybrid[s_index+0] =
g->sb_hybrid[s_index+1] =
g->sb_hybrid[s_index+2] =
g->sb_hybrid[s_index+3] = 0;
while (code) {
static const int idxtab[16] = { 3,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0 };
int v;
int pos = s_index + idxtab[code];
code ^= 8 >> idxtab[code];
READ_FLIP_SIGN(g->sb_hybrid + pos, RENAME(exp_table)+exponents[pos])
}
s_index += 4;
}
bits_left = end_pos2 - get_bits_count(&s->gb);
if (bits_left < 0 && (s->err_recognition & AV_EF_BITSTREAM)) {
av_log(s->avctx, AV_LOG_ERROR, "bits_left=%d\n", bits_left);
s_index=0;
} else if (bits_left > 0 && (s->err_recognition & AV_EF_BUFFER)) {
av_log(s->avctx, AV_LOG_ERROR, "bits_left=%d\n", bits_left);
s_index = 0;
}
memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid) * (576 - s_index));
skip_bits_long(&s->gb, bits_left);
i = get_bits_count(&s->gb);
switch_buffer(s, &i, &end_pos, &end_pos2);
return 0;
}
| 1threat
|
Combine multiple xml tags in sqlserver : I have some problem with xml in sqlserver. I can't compine multiple xml tags in one variable sql
I need combine first_name, last_name and father_name
<BODY><type>insert</type><table_name>Customer</table_name>
<First_name>Мирмухаммедов</First_name>
<Last_name>Мирмухаммедов</Last_name>
<Father_name>Rahmonovich</Father_name>
<Birth_date>12.12.2018</Birth_date>
<Country>Dushanbe</Country>
</BODY>
| 0debug
|
C++ rewrite file : <p>I have a C++ class where many of the assignments involve copying and pasting code from the book. Problem is that the format of the book makes this a very tedious task. When I copy and paste, there are extraneous numbers and spaces on the left of the code, and parts of the code are misaligned. I'm looking to write a C++ program to read a file (probably a .txt) to reformat the code and delete the numbers on the side. </p>
<p>However, I've been searching cplusplus.com, and can't figure out what library to import, so that I can open and edit the file. I'd appreciate a point in the right direction, and any tips for text editing any of you might have. Thank you.</p>
| 0debug
|
static int decode_i_picture_secondary_header(VC9Context *v)
{
int status;
#if HAS_ADVANCED_PROFILE
if (v->profile > PROFILE_MAIN)
{
v->s.ac_pred = get_bits(&v->s.gb, 1);
if (v->postprocflag) v->postproc = get_bits(&v->s.gb, 1);
if (v->overlap && v->pq<9)
{
v->condover = get_bits(&v->s.gb, 1);
if (v->condover)
{
v->condover = 2+get_bits(&v->s.gb, 1);
if (v->condover == 3)
{
status = bitplane_decoding(&v->over_flags_plane, v);
if (status < 0) return -1;
# if TRACE
av_log(v->s.avctx, AV_LOG_DEBUG, "Overflags plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
# endif
}
}
}
}
#endif
return 0;
}
| 1threat
|
How to render an HTML page into android studio : I am looking forward to render the html page coming from json into android studio. how should i display all the data of html page in textview, containing all the tags like <p>, <h>,<ul>,<li> which does not has class.
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.