problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
How do I specify a graphql type that takes multiple types? : <p>I want to create a graphql type that can return either an <code>Array of Integers</code> or <code>String</code>.</p>
<p>I've already tried using union in the form
<code>union CustomVal = [Int] | String</code>, but this returns an error.</p>
<p>The schema declaration is:</p>
<pre><code>union CustomValues = [Int] | String
type Data {
name: String
slug: String
selected: Boolean
values: CustomValues
}
</code></pre>
<p>The error is:</p>
<pre><code>node_modules/graphql/error/syntaxError.js:24
return new _GraphQLError.GraphQLError('Syntax Error: ' + description, undefined, source, [position]);
Syntax Error: Expected Name, found [
GraphQL request (81:23)
80:
81: union CustomValues = [Int] | String
</code></pre>
<p>Is this possible to do in graphql? If not, can you please suggest an alternative to do this.</p>
<p>I ask this as the union documentation says that <code>Note that members of a union type need to be concrete object types; you can't create a union type out of interfaces or other unions.</code></p>
<p>Any solutions would be highly helpful.</p>
| 0debug |
how does fill-rule="evenodd" work on a star SVG : <p>I saw the following svg shape when i was trying to understand <code>fill-rule</code> in SVG </p>
<pre><code><div class="contain-demo">
<svg width="250px" height="250px" viewBox="0 0 250 250">
<desc>Yellow star with intersecting paths to demonstrate evenodd value.</desc>
<polygon fill="#F9F38C" fill-rule="evenodd" stroke="#E5D50C" stroke-width="5" stroke-linejoin="round" points="47.773,241.534 123.868,8.466 200.427,241.534 7.784,98.208 242.216,98.208 " />
</svg>
</div>
</code></pre>
<p>Please note the following:</p>
<ul>
<li>The SVG has just one path.</li>
<li>The SVG has intersecting points.</li>
<li>if i change <strong>fill-rule="nonzero"</strong> the entire SVG get the fill.</li>
<li>Currently with <strong>fill-rule="evenodd"</strong> applied the SVG's central area does't get the fill.</li>
</ul>
<p>Why is it that with <code>fill-rule="evenodd"</code> the central portion of the star SVG is not filled ?</p>
<p>I did read the spec for <code>fill-rule="evenodd"</code> </p>
<blockquote>
<p>This value determines the "insideness" of a point in the shape by
drawing a ray from that point to infinity in any direction and
counting the number of path segments from the given shape that the ray
crosses. If this number is odd, the point is inside; if even, the
point is outside.</p>
</blockquote>
<p>But i still don't understand why when i apply <code>fill-rule="evenodd"</code>, the middle of the star is not filled. Can somebody please explain this ? </p>
| 0debug |
What's the name of an OSX-like list object in Java FX in Windows? : I can't find an object with the same look and feel like this one here:
[OSX list object][1]
[1]: http://i.stack.imgur.com/noXe5.jpg
| 0debug |
void gen_intermediate_code(CPUPPCState *env, struct TranslationBlock *tb)
{
PowerPCCPU *cpu = ppc_env_get_cpu(env);
CPUState *cs = CPU(cpu);
DisasContext ctx, *ctxp = &ctx;
opc_handler_t **table, *handler;
target_ulong pc_start;
int num_insns;
int max_insns;
pc_start = tb->pc;
ctx.nip = pc_start;
ctx.tb = tb;
ctx.exception = POWERPC_EXCP_NONE;
ctx.spr_cb = env->spr_cb;
ctx.pr = msr_pr;
ctx.mem_idx = env->dmmu_idx;
ctx.dr = msr_dr;
#if !defined(CONFIG_USER_ONLY)
ctx.hv = msr_hv || !env->has_hv_mode;
#endif
ctx.insns_flags = env->insns_flags;
ctx.insns_flags2 = env->insns_flags2;
ctx.access_type = -1;
ctx.le_mode = !!(env->hflags & (1 << MSR_LE));
ctx.default_tcg_memop_mask = ctx.le_mode ? MO_LE : MO_BE;
#if defined(TARGET_PPC64)
ctx.sf_mode = msr_is_64bit(env, env->msr);
ctx.has_cfar = !!(env->flags & POWERPC_FLAG_CFAR);
#endif
if (env->mmu_model == POWERPC_MMU_32B ||
env->mmu_model == POWERPC_MMU_601 ||
(env->mmu_model & POWERPC_MMU_64B))
ctx.lazy_tlb_flush = true;
ctx.fpu_enabled = !!msr_fp;
if ((env->flags & POWERPC_FLAG_SPE) && msr_spe)
ctx.spe_enabled = !!msr_spe;
else
ctx.spe_enabled = false;
if ((env->flags & POWERPC_FLAG_VRE) && msr_vr)
ctx.altivec_enabled = !!msr_vr;
else
ctx.altivec_enabled = false;
if ((env->flags & POWERPC_FLAG_VSX) && msr_vsx) {
ctx.vsx_enabled = !!msr_vsx;
} else {
ctx.vsx_enabled = false;
}
#if defined(TARGET_PPC64)
if ((env->flags & POWERPC_FLAG_TM) && msr_tm) {
ctx.tm_enabled = !!msr_tm;
} else {
ctx.tm_enabled = false;
}
#endif
if ((env->flags & POWERPC_FLAG_SE) && msr_se)
ctx.singlestep_enabled = CPU_SINGLE_STEP;
else
ctx.singlestep_enabled = 0;
if ((env->flags & POWERPC_FLAG_BE) && msr_be)
ctx.singlestep_enabled |= CPU_BRANCH_STEP;
if (unlikely(cs->singlestep_enabled)) {
ctx.singlestep_enabled |= GDBSTUB_SINGLE_STEP;
}
#if defined (DO_SINGLE_STEP) && 0
msr_se = 1;
#endif
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0) {
max_insns = CF_COUNT_MASK;
}
if (max_insns > TCG_MAX_INSNS) {
max_insns = TCG_MAX_INSNS;
}
gen_tb_start(tb);
tcg_clear_temp_count();
while (ctx.exception == POWERPC_EXCP_NONE && !tcg_op_buf_full()) {
tcg_gen_insn_start(ctx.nip);
num_insns++;
if (unlikely(cpu_breakpoint_test(cs, ctx.nip, BP_ANY))) {
gen_debug_exception(ctxp);
ctx.nip += 4;
break;
}
LOG_DISAS("----------------\n");
LOG_DISAS("nip=" TARGET_FMT_lx " super=%d ir=%d\n",
ctx.nip, ctx.mem_idx, (int)msr_ir);
if (num_insns == max_insns && (tb->cflags & CF_LAST_IO))
gen_io_start();
if (unlikely(need_byteswap(&ctx))) {
ctx.opcode = bswap32(cpu_ldl_code(env, ctx.nip));
} else {
ctx.opcode = cpu_ldl_code(env, ctx.nip);
}
LOG_DISAS("translate opcode %08x (%02x %02x %02x) (%s)\n",
ctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.le_mode ? "little" : "big");
ctx.nip += 4;
table = env->opcodes;
handler = table[opc1(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc2(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc3(ctx.opcode)];
}
}
if (unlikely(handler->handler == &gen_invalid)) {
qemu_log_mask(LOG_GUEST_ERROR, "invalid/unsupported opcode: "
"%02x - %02x - %02x (%08x) " TARGET_FMT_lx " %d\n",
opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir);
} else {
uint32_t inval;
if (unlikely(handler->type & (PPC_SPE | PPC_SPE_SINGLE | PPC_SPE_DOUBLE) && Rc(ctx.opcode))) {
inval = handler->inval2;
} else {
inval = handler->inval1;
}
if (unlikely((ctx.opcode & inval) != 0)) {
qemu_log_mask(LOG_GUEST_ERROR, "invalid bits: %08x for opcode: "
"%02x - %02x - %02x (%08x) " TARGET_FMT_lx "\n",
ctx.opcode & inval, opc1(ctx.opcode),
opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode, ctx.nip - 4);
gen_inval_exception(ctxp, POWERPC_EXCP_INVAL_INVAL);
break;
}
}
(*(handler->handler))(&ctx);
#if defined(DO_PPC_STATISTICS)
handler->count++;
#endif
if (unlikely(ctx.singlestep_enabled & CPU_SINGLE_STEP &&
(ctx.nip <= 0x100 || ctx.nip > 0xF00) &&
ctx.exception != POWERPC_SYSCALL &&
ctx.exception != POWERPC_EXCP_TRAP &&
ctx.exception != POWERPC_EXCP_BRANCH)) {
gen_exception(ctxp, POWERPC_EXCP_TRACE);
} else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) ||
(cs->singlestep_enabled) ||
singlestep ||
num_insns >= max_insns)) {
break;
}
if (tcg_check_temp_count()) {
fprintf(stderr, "Opcode %02x %02x %02x (%08x) leaked temporaries\n",
opc1(ctx.opcode), opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode);
exit(1);
}
}
if (tb->cflags & CF_LAST_IO)
gen_io_end();
if (ctx.exception == POWERPC_EXCP_NONE) {
gen_goto_tb(&ctx, 0, ctx.nip);
} else if (ctx.exception != POWERPC_EXCP_BRANCH) {
if (unlikely(cs->singlestep_enabled)) {
gen_debug_exception(ctxp);
}
tcg_gen_exit_tb(0);
}
gen_tb_end(tb, num_insns);
tb->size = ctx.nip - pc_start;
tb->icount = num_insns;
#if defined(DEBUG_DISAS)
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(pc_start)) {
int flags;
flags = env->bfd_mach;
flags |= ctx.le_mode << 16;
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(cs, pc_start, ctx.nip - pc_start, flags);
qemu_log("\n");
}
#endif
}
| 1threat |
Create a function which takes in a float as input and returns a string containing a number : <p>Create a function called format_currency which takes in a float as input and returns a string containing the number with a $ in front of it, with 2 decimal places. </p>
<p>i got no idea what i have done</p>
<pre><code>def format_currency()
format("format_currency")
format_currency = float(input("Enter amount"))
print ("$" , format_currency)
</code></pre>
| 0debug |
static uint32_t rtl8139_io_readl(void *opaque, uint8_t addr)
{
RTL8139State *s = opaque;
uint32_t ret;
switch (addr)
{
case RxMissed:
ret = s->RxMissed;
DPRINTF("RxMissed read val=0x%08x\n", ret);
break;
case TxConfig:
ret = rtl8139_TxConfig_read(s);
break;
case RxConfig:
ret = rtl8139_RxConfig_read(s);
break;
case TxStatus0 ... TxStatus0+4*4-1:
ret = rtl8139_TxStatus_read(s, addr, 4);
break;
case TxAddr0 ... TxAddr0+4*4-1:
ret = rtl8139_TxAddr_read(s, addr-TxAddr0);
break;
case RxBuf:
ret = rtl8139_RxBuf_read(s);
break;
case RxRingAddrLO:
ret = s->RxRingAddrLO;
DPRINTF("C+ RxRing low bits read val=0x%08x\n", ret);
break;
case RxRingAddrHI:
ret = s->RxRingAddrHI;
DPRINTF("C+ RxRing high bits read val=0x%08x\n", ret);
break;
case Timer:
ret = muldiv64(qemu_get_clock_ns(vm_clock) - s->TCTR_base,
PCI_FREQUENCY, get_ticks_per_sec());
DPRINTF("TCTR Timer read val=0x%08x\n", ret);
break;
case FlashReg:
ret = s->TimerInt;
DPRINTF("FlashReg TimerInt read val=0x%08x\n", ret);
break;
default:
DPRINTF("ioport read(l) addr=0x%x via read(b)\n", addr);
ret = rtl8139_io_readb(opaque, addr);
ret |= rtl8139_io_readb(opaque, addr + 1) << 8;
ret |= rtl8139_io_readb(opaque, addr + 2) << 16;
ret |= rtl8139_io_readb(opaque, addr + 3) << 24;
DPRINTF("read(l) addr=0x%x val=%08x\n", addr, ret);
break;
}
return ret;
}
| 1threat |
How to capture time based on the sound of the pile hammer ? I am developing UWP app using C# app : How to capture time based on the sound of the pile hammer ? I am developing UWP app using C# app.
Please see the below url.
https://play.google.com/store/apps/details?id=com.bridge3&hl=en | 0debug |
PHP mysqli echo text elsewhere when typing : <p>Hi is there any way in PHP when if I start typing in a text field that whatever is being typed gets echoed out in real time somewhere else on a page?</p>
| 0debug |
Python How to convert html text to csv? : I have this following HTML table in a text file (.txt), I want to convert it to the following format. Any help is appreciated.
<td class="det" colspan="1" width="40%">Basic EPS (Rs.)</td>
<td align="right" class="det">57.18</td>
<td align="right" class="det">48.84</td>
</tr>
<tr height="22px">
<td class="det" colspan="1" width="40%">Diluted Eps (Rs.)</td>
<td align="right" class="det">56.43</td>
<td align="right" class="det">48.26</td>
</tr>
the csv output should look something like this...
Basic EPS (Rs.)|57.18|48.84
Diluted Eps (Rs.)|56.43|48.26
Regards, babsdoc | 0debug |
static int mov_read_udta(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
{
uint64_t end = url_ftell(pb) + atom.size;
while (url_ftell(pb) + 8 < end) {
uint32_t tag_size = get_be32(pb);
uint32_t tag = get_le32(pb);
uint64_t next = url_ftell(pb) + tag_size - 8;
if (next > end)
break;
switch (tag) {
case MKTAG(0xa9,'n','a','m'):
mov_parse_udta_string(pb, c->fc->title, sizeof(c->fc->title));
break;
case MKTAG(0xa9,'w','r','t'):
mov_parse_udta_string(pb, c->fc->author, sizeof(c->fc->author));
break;
case MKTAG(0xa9,'c','p','y'):
mov_parse_udta_string(pb, c->fc->copyright, sizeof(c->fc->copyright));
break;
case MKTAG(0xa9,'i','n','f'):
mov_parse_udta_string(pb, c->fc->comment, sizeof(c->fc->comment));
break;
default:
break;
}
url_fseek(pb, next, SEEK_SET);
}
return 0;
}
| 1threat |
How to write properly an if statement in regards to a BooleanParameter in Jenkins pipeline Jenkinsfile? : <p>I'm setting a Jenkins pipeline Jenkinsfile and I'd like to check if a booleanparameter is set.</p>
<p>Here's the relevant portion of the file:</p>
<pre><code>node ("master") {
stage 'Setup' (
[[$class: 'BooleanParameterValue', name: 'BUILD_SNAPSHOT', value: 'Boolean.valueOf(BUILD_SNAPSHOT)']],
</code></pre>
<p>As I understand, that is the way to access the booleanparameter but I'm not sure how to state the IF statement itself.</p>
<p>I was thinking about doing something like:</p>
<pre><code>if(BooleanParameterValue['BUILD_SNAPSHOT']){...
</code></pre>
<p>What is the correct way to write this statement please?</p>
| 0debug |
UWP get the names of app's assembly files at runtime : <p>I'm looking to display a list of the dll assemblies that our UWP references at build time during the running app. I can see these dependencies in the Debug\AppX folder. I've looked for them in the members of both Package and Assembly. Are they visible to the running application? </p>
<p>I've been looking through the members of:</p>
<pre><code>var assembly = typeof(App).GetTypeInfo().Assembly;
Package package = Package.Current;
</code></pre>
| 0debug |
JOINING 3 VIEWS AND USING VARIABLES : I have joined 3 views together to reflect a summary of each view per period
When trying to use 'MC Total' to summarize all 3 it is reflecting as an integer
Have tried multiple options to no avail
Below are the results returned
period_start_date|period_end_date|MC| D/MC|N/MC|MC/Total
2019-08-01|2019-08-15|1,136.99|3,375.77|0|4
Tried with no IF statements
Tried with sub queries
Tried with sub queries and IF statements
Tried formatting 'MC Total'
Tried without variables
```mysql
SELECT
m.`period_start_date`,
m.`period_end_date`,
@meta := IF(m.`Net Collections` IS NOT NULL,m.`Net Collections`,0) AS 'MC',
@dnf := IF(d.`Metacorp Net`IS NOT NULL,d.`Metacorp Net`,0) as 'D/MC',
@nmrc:= IF(n.`Metacorp Net`IS NOT NULL,d.`Metacorp Net`,0) as 'N/MC',
@meta+@dnf+@nmrc AS 'MC Total'
FROM collectionsmax.mc_period_trust_summary m
RIGHT OUTER JOIN collectionsmax.dnf_period_trust_summary d
ON m.`period_start_date` = d.`period_start_date`
LEFT OUTER JOIN collectionsmax.nmrc_period_trust_summary n
ON m.`period_start_date` = n.`period_start_date`
GROUP BY m.`period_start_date` ,m.`period_end_date`;
```[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/gSnd4.png | 0debug |
Is there a string formatting operator in R similar to Python's %? : <p>I have a url that I need to send a request to using date variables. The https address takes the date variables. I'd like to assign the dates to the address string using something like the formatting operator % in Python. Does R have a similar operator or do I need to rely on paste()?</p>
<pre><code># Example variables
year = "2008"
mnth = "1"
day = "31"
</code></pre>
<p>This is what I would do in Python 2.7:</p>
<pre><code>url = "https:.../KBOS/%s/%s/%s/DailyHistory.html" % (year, mnth, day)
</code></pre>
<p>Or using .format() in 3.+.</p>
<p>The only I'd know to do in R seems verbose and relies on paste:</p>
<pre><code>url_start = "https:.../KBOS/"
url_end = "/DailyHistory.html"
paste(url_start, year, "/", mnth, "/", day, url_end)
</code></pre>
<p>Is there a better way of doing this?</p>
| 0debug |
Finding characters in a sentence : <p>I want to make a program that can find characters in long string...
.
.</p>
<pre><code>int i = 0;
char buf[100];
char ch[10];
char *res;
int len = 0;
int j = 0;
printf("Enter characters: ");
while(1){
j = getchar();
if(j == '\n') break;
ch[i++] = j;
}
ch[i] = '\0';
while(len < 1){
printf("Enter a sentence: ");
res = fgets(buf, 200, stdin);
len = strlen(buf);
}
</code></pre>
<p>Here's sample execute screen.</p>
<p>Enter characters: mkn</p>
<p>Enter a sentence: My son is in elementary school.</p>
<p>Finding..</p>
<p>-
My
son
in</p>
<h2>elementary</h2>
<p>I want to make this program with strtok() and strchr()... but I am confused with pointers....</p>
| 0debug |
Access to a pointer whose adress is in a String C : I want to make a memdump function that with fgets() gets the address from the keyboard to dump and then, using this function prints the contents of that adress in memory:
void print_bytes(void *object, size_t size)
{
char * bytes = object;
size_t i;
for(i = 0; i < size; i++)
{
printf("%c", bytes[i]);
}
}
so the problem is, that this code is always printing the same thing that i inputed by keyboard (the adress) instead of printing whatever is in the adress! | 0debug |
i already set actionbar but getSupportActionBar() return null : If i go to another activity, it will crash and say my action bar is null
i already set it but why it's still be null ?
can someone help me ? i am beginner
my manifest code:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="arvin.a8c_smpbruder">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".Main"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"></activity>
<activity
android:name=".DaftarMurid"
android:label="Daftar Murid" />
<activity
android:name=".Settings"
android:label="@string/title_activity_settings"
android:parentActivityName=".Main">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="arvin.a8c_smpbruder.Main" />
</activity>
<activity
android:name=".JadwalPelajaran"
android:label="Jadwal Pelajaran" />
<activity
android:name=".UploadFoto"
android:label="Upload Foto" />
<activity
android:name=".GaleriFoto"
android:label="Galeri" />
<activity
android:name=".About"
android:label="Tentang" />
<activity
android:name=".Contributors"
android:label="Kontributor" />
<activity
android:name=".LoadingHome"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".TampilanAkun"
android:label="Akun" />
<activity android:name=".JadwalPiket"></activity>
</application>
</manifest>
My Main Activity Code:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//signIn.setOnClickListener(this);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
i setted the actionbar on there, but still null :(
can someone help me ? | 0debug |
How to write a function in JavaScript to show the longest string in an array : <p>This is my code so far and it doesn't seem to work. I could use some help.</p>
<pre><code>function longestString(arr) {
var longest =0;
for (var i = 0; i < arr.length; i++) {
if (arr[i].length > longest.length) {
longest = arr[i];
}
}
}
</code></pre>
<p>I am not sure what I am doing wrong.</p>
| 0debug |
Sorting data in Angular : <pre><code><html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js">
</script>
<style>
table{
border:2px solid black;
border-collapse:collapse;
font-family:Arial;
}
td{
border:2px solid black;
padding:5px;
}
th{
border:2px solid black;
padding:10px;
}
</style>
</head>
<script type="text/javascript">
var app=angular.module("myApp",[]);
app.controller("likeDislikeCount",function($scope)
{
var technology=[
{name:"C",like:0,Dislike:0},
{name:"Python",like:0,Dislike:0},
{name:"Java",like:0,Dislike:0},
{name:"Angular",like:0,Dislike:0}
];
$scope.technology=technology;
$scope.rowLimit=1;
$scope.selectCol=name;
$scope.increeseLike=function(technology1){
technology1.like++;
};
$scope.increseDisLike=function(technology1){
technology1.Dislike++;
};
}
);
</script>
<body ng-app="myApp">
<div ng-controller="likeDislikeCount">
No. of rows to display :: <input type="number" ng-model="rowLimit" min=0 max=4 /> <br><br>
order by <select ng-model="selectCol">
<option value="name">Name ASC</option>
<option value="like">LIke ASC</option>
<option value="-Dislike">Dislike DSC</option>
</select>
<br><br>
<table>
<thead>
<th>Name</th>
<th>LikeCount</th>
<th>DislikeCount</th>
<th>Click</th>
</thead>
<tbody>
<tr ng-repeat = "x in technology | orderBy:'selectCol'">
<td>{{x.name}}</td>
<td>{{x.like}}</td>
<td>{{x.Dislike}}</td>
<td><button ng-click="increeseLike(x)">LIKE</button><button ng-click="increseDisLike(x)">DISLIKE</button></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
</code></pre>
<p>this code I am trying to show the table depending on order of any of name,like and dislike.When I will select any of one from dropdown It should the data according to that field.But its not working appropriately.
Please correct it completly and help me
Thanks</p>
| 0debug |
static void tcg_out_setcond_i32(TCGContext *s, TCGCond cond, TCGReg ret,
TCGReg c1, int32_t c2, int c2const)
{
switch (cond) {
case TCG_COND_LTU:
case TCG_COND_GEU:
break;
case TCG_COND_EQ:
case TCG_COND_NE:
if (c2 != 0) {
tcg_out_arithc(s, ret, c1, c2, c2const, ARITH_XOR);
}
c1 = TCG_REG_G0, c2 = ret, c2const = 0;
cond = (cond == TCG_COND_EQ ? TCG_COND_GEU : TCG_COND_LTU);
break;
case TCG_COND_GTU:
case TCG_COND_LEU:
if (!c2const || c2 == 0) {
TCGReg t = c1;
c1 = c2;
c2 = t;
c2const = 0;
cond = tcg_swap_cond(cond);
break;
}
default:
tcg_out_cmp(s, c1, c2, c2const);
tcg_out_movi_imm13(s, ret, 0);
tcg_out_movcc(s, cond, MOVCC_ICC, ret, 1, 1);
return;
}
tcg_out_cmp(s, c1, c2, c2const);
if (cond == TCG_COND_LTU) {
tcg_out_arithi(s, ret, TCG_REG_G0, 0, ARITH_ADDX);
} else {
tcg_out_arithi(s, ret, TCG_REG_G0, -1, ARITH_SUBX);
}
}
| 1threat |
static int vtenc_cm_to_avpacket(
AVCodecContext *avctx,
CMSampleBufferRef sample_buffer,
AVPacket *pkt,
ExtraSEI *sei)
{
VTEncContext *vtctx = avctx->priv_data;
int status;
bool is_key_frame;
bool add_header;
size_t length_code_size;
size_t header_size = 0;
size_t in_buf_size;
size_t out_buf_size;
size_t sei_nalu_size = 0;
int64_t dts_delta;
int64_t time_base_num;
int nalu_count;
CMTime pts;
CMTime dts;
CMVideoFormatDescriptionRef vid_fmt;
vtenc_get_frame_info(sample_buffer, &is_key_frame);
status = get_length_code_size(avctx, sample_buffer, &length_code_size);
if (status) return status;
add_header = is_key_frame && !(avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER);
if (add_header) {
vid_fmt = CMSampleBufferGetFormatDescription(sample_buffer);
if (!vid_fmt) {
av_log(avctx, AV_LOG_ERROR, "Cannot get format description.\n");
return AVERROR_EXTERNAL;
}
int status = get_params_size(avctx, vid_fmt, &header_size);
if (status) return status;
}
status = count_nalus(length_code_size, sample_buffer, &nalu_count);
if(status)
return status;
if (sei) {
sei_nalu_size = sizeof(start_code) + 3 + sei->size + 1;
}
in_buf_size = CMSampleBufferGetTotalSampleSize(sample_buffer);
out_buf_size = header_size +
in_buf_size +
sei_nalu_size +
nalu_count * ((int)sizeof(start_code) - (int)length_code_size);
status = ff_alloc_packet2(avctx, pkt, out_buf_size, out_buf_size);
if (status < 0)
return status;
if (add_header) {
status = copy_param_sets(avctx, vid_fmt, pkt->data, out_buf_size);
if(status) return status;
}
status = copy_replace_length_codes(
avctx,
length_code_size,
sample_buffer,
pkt->data + header_size,
pkt->size - header_size - sei_nalu_size
);
if (status) {
av_log(avctx, AV_LOG_ERROR, "Error copying packet data: %d", status);
return status;
}
if (sei_nalu_size > 0) {
uint8_t *sei_nalu = pkt->data + pkt->size - sei_nalu_size;
memcpy(sei_nalu, start_code, sizeof(start_code));
sei_nalu += sizeof(start_code);
sei_nalu[0] = H264_NAL_SEI;
sei_nalu[1] = SEI_TYPE_USER_DATA_REGISTERED;
sei_nalu[2] = sei->size;
sei_nalu += 3;
memcpy(sei_nalu, sei->data, sei->size);
sei_nalu += sei->size;
sei_nalu[0] = 1;
}
if (is_key_frame) {
pkt->flags |= AV_PKT_FLAG_KEY;
}
pts = CMSampleBufferGetPresentationTimeStamp(sample_buffer);
dts = CMSampleBufferGetDecodeTimeStamp (sample_buffer);
if (CMTIME_IS_INVALID(dts)) {
if (!vtctx->has_b_frames) {
dts = pts;
} else {
av_log(avctx, AV_LOG_ERROR, "DTS is invalid.\n");
return AVERROR_EXTERNAL;
}
}
dts_delta = vtctx->dts_delta >= 0 ? vtctx->dts_delta : 0;
time_base_num = avctx->time_base.num;
pkt->pts = pts.value / time_base_num;
pkt->dts = dts.value / time_base_num - dts_delta;
pkt->size = out_buf_size;
return 0;
}
| 1threat |
void net_rx_pkt_set_protocols(struct NetRxPkt *pkt, const void *data,
size_t len)
{
assert(pkt);
eth_get_protocols(data, len, &pkt->isip4, &pkt->isip6,
&pkt->isudp, &pkt->istcp);
}
| 1threat |
void block_job_enter(BlockJob *job)
{
if (job->co && !job->busy) {
bdrv_coroutine_enter(blk_bs(job->blk), job->co);
}
}
| 1threat |
TabView resets navigation stack when switching tabs : <p>I have a simple TabView: </p>
<pre class="lang-swift prettyprint-override"><code>TabView {
NavigationView {
VStack {
NavigationLink(destination: Text("Detail")) {
Text("Go to detail")
}
}
}
.tabItem { Text("First") }
.tag(0)
Text("Second View")
.tabItem { Text("Second") }
.tag(1)
}
</code></pre>
<p>When I go to the detail view on tab 1, switch to tab 2 then switch back to tab 1 I would assume to go back to the detail view (a basic UX found everywhere in iOS). Instead it resets to the root view of tab 1.</p>
<p>Since SwiftUI doesn't look to support this out of the box, how do I work around this?</p>
| 0debug |
Combine two lists in a specific order : I am working in Python, and I want to combine two lists and have one list in the end, but in a specific way. Below I will just provide an example but the dataset I am working on is much bigger.
List 1
1.1
1.1
1.1
1.1
1.2
1.2
1.2
1.2
List 2
2.1
2.1
2.1
2.1
2.2
2.2
2.2
2.2
Combined List
1.1
1.1
1.1
1.1
2.1
2.1
2.1
2.1
1.2
1.2
1.2
1.2
2.2
2.2
2.2
2.2
Essentially, I want every 4 values to change the list I am importing values from. Take the first 4 from List 1 then take the next 4 from List 2, and then go back to List 1 etc. Any help would be welcome, thank you! | 0debug |
Route53 for AWS Elastic Search Domain gives certificate error : <p>I have create a AWS elastic search domain in Virginia and got a Endpoint url. </p>
<p><a href="https://i.stack.imgur.com/Fzc67.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Fzc67.png" alt="enter image description here"></a></p>
<p>Now I wanted to configure the Route53 behavior around it, so that a caller can use the same url, even though there is some change in elastic search or in case of a disaster recovery. </p>
<p>So,</p>
<p>Virginia Route 53 -- 1 Points to -- Virgina Elastic Search Domain URL
Oregon Route 53 -- 2 Points to -- Oregon Elastic Search Domain URL
Main Route 53 -- 3 Points to -- Route 53 1 or 2</p>
<p>I have already create these and also created and uploaded SSL certificate with correct SAN entries. But when I execute,</p>
<pre><code>curl https://mainroute53/health
curl https://virginiaroute53/health
curl https://oregonroute53/health
</code></pre>
<p>I am getting this error,</p>
<pre><code>curl: (51) Unable to communicate securely with peer: requested domain name does not match the server's certificate.
</code></pre>
<p>But when I am calling the Elastic Search URL directly its working. So I understand this is a issue with the way I am using the certificate. Any help appreciated.</p>
| 0debug |
Can I store a set of strings of a multiple line using regex on java? : <p>If I have an input of</p>
<pre><code>this is a string
this is also a string
i am a string
</code></pre>
<p>can i store them in an array like</p>
<pre><code>[0] this is a string
[1] this is also a string
[2] i am a string
</code></pre>
<p>If so, how can I achieve this kind of output?</p>
| 0debug |
void replay_read_next_clock(ReplayClockKind kind)
{
unsigned int read_kind = replay_data_kind - EVENT_CLOCK;
assert(read_kind == kind);
int64_t clock = replay_get_qword();
replay_check_error();
replay_finish_event();
replay_state.cached_clock[read_kind] = clock;
}
| 1threat |
my sql error: please help as soon as possible : my code shows the following error: I did not understand how to correct it
you have an error in your sql syntax , check the manual corresponds to your mysql server version for the right syntax to use near ')'at line 1
$query="insert into subjective_result(marks,roll_no)values($marks,$roll)";
mysql_query($query)or die(mysql_error());
please help me to sort out it.
| 0debug |
If an Algorithm's running time can be expressed as function F(x)=√n+(logn)^2 , : If an Algorithm's running time can be expressed as function F(x)=√n+(logn)^2 , Then which one of the following is not a correct bound for the running time ?
1-O(n)
2-O(√n)
3-O((log)^2)
4-Omega(1)
| 0debug |
static av_cold int decode_end(AVCodecContext *avctx)
{
ALSDecContext *ctx = avctx->priv_data;
av_freep(&ctx->sconf.chan_pos);
ff_bgmc_end(&ctx->bgmc_lut, &ctx->bgmc_lut_status);
av_freep(&ctx->const_block);
av_freep(&ctx->shift_lsbs);
av_freep(&ctx->opt_order);
av_freep(&ctx->store_prev_samples);
av_freep(&ctx->use_ltp);
av_freep(&ctx->ltp_lag);
av_freep(&ctx->ltp_gain);
av_freep(&ctx->ltp_gain_buffer);
av_freep(&ctx->quant_cof);
av_freep(&ctx->lpc_cof);
av_freep(&ctx->quant_cof_buffer);
av_freep(&ctx->lpc_cof_buffer);
av_freep(&ctx->lpc_cof_reversed_buffer);
av_freep(&ctx->prev_raw_samples);
av_freep(&ctx->raw_samples);
av_freep(&ctx->raw_buffer);
av_freep(&ctx->chan_data);
av_freep(&ctx->chan_data_buffer);
av_freep(&ctx->reverted_channels);
return 0;
} | 1threat |
NOOB question about pandas in python 0.2.7 dataframe : Hello all thanks in advance for the help. Okay, So i know this is a stupid issue on my end but I can not figure it out for the life of me. What I am trying to do is take this output from pybaseball which is set in as a list.
and put it into a csv file using pandas. So far these are the are the queries I have tried I have the information for this output set as data. Whenever I try to import it from pd.DataFrame() it tells me that AttributeError: 'list' object has no attribute 'to_csv'. so I add a dataframe to that using df = pd.Dataframe(data) and that prints out just the headers
How would I get this to import all of the information in the list to csv?
| 0debug |
Print JSON array through javascript : When importing data from a JSON file we get this array called "parcelshopSpecs.data.formatted_opening_times", which are opening times of a store:
{2=>[09:00 - 22:00] 4=>[09:00 - 22:00] 6=>[10:00 - 18:00] 1=>[09:00 - 22:00] 5=>[09:00 - 20:00] 3=>[09:00 - 22:00] 0=>[09:00 - 22:00]}
We would like to process this data and show it like:
> Monday: 09:00 - 02:00<br>
Tuesday: 09:00 - 22:00<br>
...
I have tried to parse the data in JSON and show the content:
var opening_times = JSON.parse(parcelshopSpecs.data.formatted_opening_times);
var content = "Monday: "
content += ${opening_times[0][2]}
But result in error console is "Uncaught SyntaxError: Unexpected number in JSON at position 1"
Hope someone can help | 0debug |
static void htab_save_first_pass(QEMUFile *f, sPAPRMachineState *spapr,
int64_t max_ns)
{
int htabslots = HTAB_SIZE(spapr) / HASH_PTE_SIZE_64;
int index = spapr->htab_save_index;
int64_t starttime = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
assert(spapr->htab_first_pass);
do {
int chunkstart;
while ((index < htabslots)
&& !HPTE_VALID(HPTE(spapr->htab, index))) {
index++;
CLEAN_HPTE(HPTE(spapr->htab, index));
}
chunkstart = index;
while ((index < htabslots) && (index - chunkstart < USHRT_MAX)
&& HPTE_VALID(HPTE(spapr->htab, index))) {
index++;
CLEAN_HPTE(HPTE(spapr->htab, index));
}
if (index > chunkstart) {
int n_valid = index - chunkstart;
qemu_put_be32(f, chunkstart);
qemu_put_be16(f, n_valid);
qemu_put_be16(f, 0);
qemu_put_buffer(f, HPTE(spapr->htab, chunkstart),
HASH_PTE_SIZE_64 * n_valid);
if ((qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > max_ns) {
break;
}
}
} while ((index < htabslots) && !qemu_file_rate_limit(f));
if (index >= htabslots) {
assert(index == htabslots);
index = 0;
spapr->htab_first_pass = false;
}
spapr->htab_save_index = index;
}
| 1threat |
The size of data types in C and Java? : <p>The size of the data type in C for example, int is 2 bytes, however the size of int in Java is 4 bytes, and the same for other data types as well. Why is the size of a data type double in Java?</p>
| 0debug |
git lfs "objects" taking a lot of disk space : <p>I have a project with a lot of binaries (mostly pdfs) that I'm using git-lfs with. The project is about 60mb but I found that my .git/lfs/objects director is about 500mb. I presume these are cached versions of previous commits. Is there a way to gracefully delete these (ie delete them without corrupting the state of git)? The odds of me ever wanting previous versions of the files in LFS are near 0 now especially since the project is over.</p>
| 0debug |
Alexa request validation in python : <p>I work on a service that will handle Alexa voice intents. I need to verify the signature of each request and I almost succeed. The only part that is not working is the validation of certificates chain.</p>
<p>From the <a href="https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/developing-an-alexa-skill-as-a-web-service#checking-the-signature-of-the-request" rel="noreferrer">documentation</a> I know that:</p>
<blockquote>
<p>This certificate chain is composed of, in order, (1) the Amazon signing
certificate and (2) one or more additional certificates that create a chain of
trust to a root certificate authority (CA) certificate.</p>
</blockquote>
<p>My code looks like this:</p>
<pre><code>certificates = pem.parse_file("chain.pem")
store = crypto.X509Store()
for cert in certificates[:-1]:
loaded_cert = crypto.load_certificate(crypto.FILETYPE_PEM,
cert.as_bytes())
store.add_cert(loaded_cert)
intermediate_cert = crypto.load_certificate(
crypto.FILETYPE_PEM,
certificates[-1].as_bytes()
)
# Create a certificate context
store_ctx = crypto.X509StoreContext(store, intermediate_cert)
# Verify the certificate
store_ctx.verify_certificate()
</code></pre>
<p>I receive the following error:</p>
<pre><code>OpenSSL.crypto.X509StoreContextError: [20, 0, 'unable to get local issuer certificate']
</code></pre>
<p>I don't know what I did wrong, maybe there is someone who already implemented this and can drop a hint.</p>
| 0debug |
I want to fetch time collumn from mysql database and to compare with current time. : I want to fetch time column from mysql database and to compare with current time.
It should execute only if it matches with the current time.
Please tell me a MySql query or php code to do this.
I am new to php.
[This is my Table][1]
[1]: https://i.stack.imgur.com/bJ9tH.png | 0debug |
Guys i was trying to make a user editable polygon on Googlemap using ionic 3 like the image shown below , but not coming ...help me to do this : ## but i am getting only normal polygon line when my marker is placed on map..plz help me to solve this
- @ionic/cli-utils : 1.19.2
- ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
@ionic/app-scripts : 3.1.8
Cordova Platforms : android 7.0.0
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.1.1
Node : v8.10.0
npm : 5.6.0
OS : Windows 10
Environment Variables:
ANDROID_HOME : C:\Users\w2s-pc\AppData\Local\Android\Sdk
Misc:
backend : pro
----------
Code:
import { NavController } from 'ionic-angular';
import{LatLng,GoogleMaps,GoogleMap,GoogleMapsEvent,GoogleMapOptions,
CameraPosition,MarkerOptions,Polyline,Polygon,PolygonOptions,
Spherical,Marker} from '@ionic- native/google-maps';
import { Component } from "@angular/core/";
import { Geolocation } from '@ionic-native/geolocation';
@Component({
selector: 'home',
templateUrl: 'home.html'
})
export class HomePage {
map: GoogleMap;
me: any;
locations = []
constructor() { }
ionViewDidLoad() {
this.loadMap();
}
loadMap() {
let mapOptions: GoogleMapOptions = {
// camera: {
// target: {
// lat: this.me._x,
// lng: this.me._y
// },
// zoom: 18,
// tilt: 30,
// },
MyLocation:true,
MyLocationButton:true,
disableDefaultUI: true,
mapType: "MAP_TYPE_HYBRID",
};
let map= this.map = GoogleMaps.create('map_canvas', mapOptions);
// var div = document.getElementById("map_canvas");
// var map = new GoogleMaps()
// Wait the MAP_READY before using any methods.
this.map.on(GoogleMapsEvent.MAP_READY)
.subscribe(() => {
console.log('Map is ready!');
this.map.setMyLocationEnabled(true)
this.map.setMyLocationButtonEnabled(true)
this.map.on(GoogleMapsEvent.MAP_CLICK).subscribe((location: any) => {
console.log(location);
this.locations.push(new LatLng(location[0].lat, location[0].lng));
console.log(location);
let PolyLineInfo;
this.map.addPolygon({
'points' : this.locations ,
'strokeColor' : '# AA00FF' ,
'fillColor' : '# 00FFAA' ,
'strokeWidth' : 4 ,
'editable' :true,
}).then((info: Polyline) => {
// info.setPoints
PolyLineInfo = info;
}
);
this.map.addMarker({
animation: 'DROP',
draggable: true,
position: {
lat: location[0].lat,
lng: location[0].lng,
},
customInfo: this.locations.length - 1
})
.then(marker => {
marker.on(GoogleMapsEvent.MARKER_DRAG_END)
.subscribe((marker) => {
let index = marker[1].get("customInfo");
this.locations[index] = new LatLng(marker[0].lat, marker[0].lng);
PolyLineInfo.remove();
console.log(this.locations[0]);
console.log(this.locations[1]);
console.log(this.locations[2]);
let dis = Spherical.computeSignedArea(this.locations);
console.log(dis);
let km = Spherical.computeLength(this.locations);
console.log(km);
this.map.addPolygon({
'points' : this.locations ,
'strokeColor' : '# AA00FF' ,
'fillColor' : '#FF0000' ,
'strokeWidth' : 4 ,
'editable' :true,
}).then((info: Polyline) => {
PolyLineInfo = info;
}
);
});
})
});
});
}
}
----------
[**i need to do like this using ionic version 3 on Google Map**][1]
[1]: https://i.stack.imgur.com/tP3BC.jpg
| 0debug |
make edittext readonly which is empty : I want to create two editText in android both are editable when the user wants to put data in one editText the other automatically becomes read-only dynamically to show the result of that entered data? | 0debug |
static int flush_packet(AVFormatContext *ctx, int stream_index,
int64_t pts, int64_t dts, int64_t scr, int trailer_size)
{
MpegMuxContext *s = ctx->priv_data;
StreamInfo *stream = ctx->streams[stream_index]->priv_data;
uint8_t *buf_ptr;
int size, payload_size, startcode, id, stuffing_size, i, header_len;
int packet_size;
uint8_t buffer[128];
int zero_trail_bytes = 0;
int pad_packet_bytes = 0;
int pes_flags;
int general_pack = 0;
int nb_frames;
id = stream->id;
av_dlog(ctx, "packet ID=%2x PTS=%0.3f\n", id, pts / 90000.0);
buf_ptr = buffer;
if ((s->packet_number % s->pack_header_freq) == 0 || s->last_scr != scr) {
size = put_pack_header(ctx, buf_ptr, scr);
buf_ptr += size;
s->last_scr= scr;
if (s->is_vcd) {
if (stream->packet_number==0) {
size = put_system_header(ctx, buf_ptr, id);
buf_ptr += size;
} else if (s->is_dvd) {
if (stream->align_iframe || s->packet_number == 0){
int PES_bytes_to_fill = s->packet_size - size - 10;
if (pts != AV_NOPTS_VALUE) {
if (dts != pts)
PES_bytes_to_fill -= 5 + 5;
else
PES_bytes_to_fill -= 5;
if (stream->bytes_to_iframe == 0 || s->packet_number == 0) {
size = put_system_header(ctx, buf_ptr, 0);
buf_ptr += size;
size = buf_ptr - buffer;
avio_write(ctx->pb, buffer, size);
avio_wb32(ctx->pb, PRIVATE_STREAM_2);
avio_wb16(ctx->pb, 0x03d4);
avio_w8(ctx->pb, 0x00);
for (i = 0; i < 979; i++)
avio_w8(ctx->pb, 0x00);
avio_wb32(ctx->pb, PRIVATE_STREAM_2);
avio_wb16(ctx->pb, 0x03fa);
avio_w8(ctx->pb, 0x01);
for (i = 0; i < 1017; i++)
avio_w8(ctx->pb, 0x00);
memset(buffer, 0, 128);
buf_ptr = buffer;
s->packet_number++;
stream->align_iframe = 0;
scr += s->packet_size*90000LL / (s->mux_rate*50LL);
size = put_pack_header(ctx, buf_ptr, scr);
s->last_scr= scr;
buf_ptr += size;
} else if (stream->bytes_to_iframe < PES_bytes_to_fill) {
pad_packet_bytes = PES_bytes_to_fill - stream->bytes_to_iframe;
} else {
if ((s->packet_number % s->system_header_freq) == 0) {
size = put_system_header(ctx, buf_ptr, 0);
buf_ptr += size;
size = buf_ptr - buffer;
avio_write(ctx->pb, buffer, size);
packet_size = s->packet_size - size;
if (s->is_vcd && (id & 0xe0) == AUDIO_ID)
zero_trail_bytes += 20;
if ((s->is_vcd && stream->packet_number==0)
|| (s->is_svcd && s->packet_number==0)) {
if (s->is_svcd)
general_pack = 1;
pad_packet_bytes = packet_size - zero_trail_bytes;
packet_size -= pad_packet_bytes + zero_trail_bytes;
if (packet_size > 0) {
packet_size -= 6;
if (s->is_mpeg2) {
header_len = 3;
if (stream->packet_number==0)
header_len += 3;
header_len += 1;
} else {
header_len = 0;
if (pts != AV_NOPTS_VALUE) {
if (dts != pts)
header_len += 5 + 5;
else
header_len += 5;
} else {
if (!s->is_mpeg2)
header_len++;
payload_size = packet_size - header_len;
if (id < 0xc0) {
startcode = PRIVATE_STREAM_1;
payload_size -= 1;
if (id >= 0x40) {
payload_size -= 3;
if (id >= 0xa0)
payload_size -= 3;
} else {
startcode = 0x100 + id;
stuffing_size = payload_size - av_fifo_size(stream->fifo);
if(payload_size <= trailer_size && pts != AV_NOPTS_VALUE){
int timestamp_len=0;
if(dts != pts)
timestamp_len += 5;
if(pts != AV_NOPTS_VALUE)
timestamp_len += s->is_mpeg2 ? 5 : 4;
pts=dts= AV_NOPTS_VALUE;
header_len -= timestamp_len;
if (s->is_dvd && stream->align_iframe) {
pad_packet_bytes += timestamp_len;
packet_size -= timestamp_len;
} else {
payload_size += timestamp_len;
stuffing_size += timestamp_len;
if(payload_size > trailer_size)
stuffing_size += payload_size - trailer_size;
if (pad_packet_bytes > 0 && pad_packet_bytes <= 7) {
packet_size += pad_packet_bytes;
payload_size += pad_packet_bytes;
if (stuffing_size < 0) {
stuffing_size = pad_packet_bytes;
} else {
stuffing_size += pad_packet_bytes;
pad_packet_bytes = 0;
if (stuffing_size < 0)
stuffing_size = 0;
if (stuffing_size > 16) {
pad_packet_bytes += stuffing_size;
packet_size -= stuffing_size;
payload_size -= stuffing_size;
stuffing_size = 0;
nb_frames= get_nb_frames(ctx, stream, payload_size - stuffing_size);
avio_wb32(ctx->pb, startcode);
avio_wb16(ctx->pb, packet_size);
if (!s->is_mpeg2)
for(i=0;i<stuffing_size;i++)
avio_w8(ctx->pb, 0xff);
if (s->is_mpeg2) {
avio_w8(ctx->pb, 0x80);
pes_flags=0;
if (pts != AV_NOPTS_VALUE) {
pes_flags |= 0x80;
if (dts != pts)
pes_flags |= 0x40;
if (stream->packet_number == 0)
pes_flags |= 0x01;
avio_w8(ctx->pb, pes_flags);
avio_w8(ctx->pb, header_len - 3 + stuffing_size);
if (pes_flags & 0x80)
put_timestamp(ctx->pb, (pes_flags & 0x40) ? 0x03 : 0x02, pts);
if (pes_flags & 0x40)
put_timestamp(ctx->pb, 0x01, dts);
if (pes_flags & 0x01) {
avio_w8(ctx->pb, 0x10);
if ((id & 0xe0) == AUDIO_ID)
avio_wb16(ctx->pb, 0x4000 | stream->max_buffer_size/ 128);
else
avio_wb16(ctx->pb, 0x6000 | stream->max_buffer_size/1024);
} else {
if (pts != AV_NOPTS_VALUE) {
if (dts != pts) {
put_timestamp(ctx->pb, 0x03, pts);
put_timestamp(ctx->pb, 0x01, dts);
} else {
put_timestamp(ctx->pb, 0x02, pts);
} else {
avio_w8(ctx->pb, 0x0f);
if (s->is_mpeg2) {
avio_w8(ctx->pb, 0xff);
for(i=0;i<stuffing_size;i++)
avio_w8(ctx->pb, 0xff);
if (startcode == PRIVATE_STREAM_1) {
avio_w8(ctx->pb, id);
if (id >= 0xa0) {
avio_w8(ctx->pb, 7);
avio_wb16(ctx->pb, 4);
avio_w8(ctx->pb, stream->lpcm_header[0]);
avio_w8(ctx->pb, stream->lpcm_header[1]);
avio_w8(ctx->pb, stream->lpcm_header[2]);
} else if (id >= 0x40) {
avio_w8(ctx->pb, nb_frames);
avio_wb16(ctx->pb, trailer_size+1);
assert(payload_size - stuffing_size <= av_fifo_size(stream->fifo));
av_fifo_generic_read(stream->fifo, ctx->pb, payload_size - stuffing_size, &avio_write);
stream->bytes_to_iframe -= payload_size - stuffing_size;
}else{
payload_size=
stuffing_size= 0;
if (pad_packet_bytes > 0)
put_padding_packet(ctx,ctx->pb, pad_packet_bytes);
for(i=0;i<zero_trail_bytes;i++)
avio_w8(ctx->pb, 0x00);
avio_flush(ctx->pb);
s->packet_number++;
if (!general_pack)
stream->packet_number++;
return payload_size - stuffing_size; | 1threat |
How to manually set focus on mat-form-field in Angular 6 : <p>I am new to angular ,In my application I have a mat-dialog in which I have two forms namely Login and SignUp.</p>
<p>Once I open the dialog first time the auto focus is set on username field.problem is when I navigate to SignUp form on button click that form's FIrst Name field not get auto focused ,the same way navigate from signup to login the username field is now not get auto focused.</p>
<p>I have tried to some stackoverflow solutions but nothing is resolved my issue.</p>
<p>popupScreen.component.html</p>
<pre><code><form class="login" *ngIf="isLoginHide">
<mat-form-field>
<input matInput placeholder="username">
</mat-form-field>
<mat-form-field>
<input matInput placeholder="password">
</mat-form-field>
<button mat-button color="primary">Login</button>
<button mat-button (click)="hideLogin($event)" color="accent">SignUp</button>
</form>
<form class="SignUp" *ngIf="isSignUpHide">
<mat-form-field>
<input matInput placeholder="First Name">
</mat-form-field>
<mat-form-field>
<input matInput placeholder="Last Name">
</mat-form-field>
<mat-form-field>
<input matInput placeholder="username">
</mat-form-field>
<mat-form-field>
<input matInput placeholder="password">
</mat-form-field>
<button mat-button (click)="hideSignUp($event)" color="primary">Login</button>
<button mat-button color="accent">SignUp</button>
</form>
</code></pre>
<p>can anyone help me to solve this .</p>
| 0debug |
2d array transform with key values : I have following 2D-Array.
[['4470', '4753.5', '5682', '4440', '6113.5', '3661.5', '7555.3', '6090.3', '5147.3', '4296'], ['4468.5', '4742.5', '5297', '5501.8', '5061.3', '2933.5', '6367.5', '6053.8', '5654.3', '3793.3']]
I want to tranform it with key values
e.g.
[[('1','4470'),('2', '4753.5'), ...], [......]]
Can anyone helps me? | 0debug |
xUnit Equivelant of MSTest's Assert.Inconclusive : <p>What is the xUnit equivalent of the following MSTest code:</p>
<pre><code>Assert.Inconclusive("Reason");
</code></pre>
<p>This gives a yellow test result instead of the usual green or red. I want to assert that the test could not be run due to certain conditions and that the test should be re-run after those conditions have been met.</p>
| 0debug |
FPDF - php output : <p>I installed FPDF to create pdf-docs through php.</p>
<p>Even when I try to output a simple example code snippet, I get a page full of weird charactrers</p>
<p>I have searched everywhere, and I can not find a solution. No errors are shown.</p>
<p>Maybe someone has a key ... Thanks in advance.</p>
<pre><code>%PDF-1.3 3 0 obj <> endobj 4 0 obj <> stream xœ3Rðâ2Ð35W(çr QÐw3T04Ó30PISp
êZ*˜[š€…¤(hx¤æää+”çå¤h*„d” BV endstream endobj 1 0 obj <> endobj 5 0 obj <>
</code></pre>
<p>stream xœ]RËnƒ0¼ó>¦‡L‚%„DI8ô¡Ò~%E<em>ràï»»vÒªHXã±gvVk?/¥îá¿™±©`]¯[óx5 ˆ3\zíÉP´}
³¸¯ÍPOžâjJÝ^’øïx6/f›¬Ïðàù¯¦Óë‹Ø|æî«ë4}Ãz—¦¢…}žëé¥@ø,Û–-ž÷˺EÍïuò^Ú,ÍØÂ<Õ ˜Z_ÀK‚ IQ
¤èößYdçîïÕCK€_ê%q„8>à!J"V!2&bGÄ£%r"H¢¬DîÈ}2EL1n¥ºh¾jƒå–
eä»"a</em>H¬‹ØÕ:ÞÛdá˜î„9cÅüŽ[ÈX1~²¼"œ3¿gÏãÑò;Oâ•õ> endobj 2 0 obj << /ProcSet [/PDF
/Text /ImageB /ImageC /ImageI] /Font << /F1 6 0 R >> /XObject << >> >> endobj 7 0
obj << /Producer (FPDF 1.81) /CreationDate (D:20161113014141) >> endobj 8 0 obj
<< /Type /Catalog /Pages 1 0 R >> endobj xref 0 9 0000000000 65535 f 0000000227
00000 n 0000000866 00000 n 0000000009 00000 n 0000000087 00000 n 0000000314 00000
n 0000000748 00000 n 0000000970 00000 n 0000001046 00000 n trailer << /Size 9
/Root 8 0 R /Info 7 0 R >> startxref 1095 %%EOF</p>
| 0debug |
mysql SELECT * FROM product WHERE id_product = relation1,relation2,relation3, : i have 2 table
prodcut
id_product,price,etc
relation
id,relation1,relation2,relation3,...
i want get any product where id=relation1,...
how to write it in sql ?
SELECT * FROM product WHERE id_product = relation1,relation2,relation3,... | 0debug |
jquery form validation help requaired : i'm new to jQuery i made a form mixing html and jQuery, i would like to know how can i make some fields to "required"? here is the code
btsample=$('<div id="sample" title="TITLE"/>').appendTo(ctrls).click(function(){$("#getsample").dialog("open")})
$('<div id="getsample" title="TITLE">'
+'<form><span>NAME : </span><input type="text" name="myname" ></input><br/>'
+'<span>TEL : </span><input type="text" name="myphone"></input><br/>'
+'<span>ADRESS : </span><input type="text" name="myaddress" ></input><br/>'
+'<span>Email : </span><input type="text" name="myemail" ></input><br/>'
+'<span >PROJECT NAME : </span><input type="text" name="projectName"></input><br/>'
+'<span>ARK NAME : </span><input type="text" name="arkName"></input></form> <br/>'
+'</div>').appendTo(ctrls).dialog({
autoOpen:false,
modal:true,
buttons:{"send":getsample}
}) | 0debug |
Swift 3: Can not convert value of type 'int' to expected argument type 'DispatchQueue.GlobalQueuePriority' : <p><strong>Swift 3.0:</strong> Receiving error <code>Can not convert value of type 'int' to expected argument type 'DispatchQueue.GlobalQueuePriority'</code> on creating dispatch async queue </p>
<pre><code>DispatchQueue.global(priority: 0).async(execute: { () -> Void in
})
</code></pre>
| 0debug |
MySql Error- ASP.NET : <p>I am getting the following error while connecting to the MySql database in the wamp server.I have added the assemblies also. How can i fix the problem?
Thanks a ton.
Error: </p>
<pre><code>Server Error in '/' Application.
Parameter '@First__Name' must be defined.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: MySql.Data.MySqlClient.MySqlException: Parameter '@First__Name' must be defined.
Source Error:
Line 26: cmd.Parameters.Add(new MySqlParameter("@Country", DropDownCountry.Text));
Line 27: cmd.Parameters.Add(new MySqlParameter("@About_User", txtUserDescription.Text));
Line 28: cmd.ExecuteNonQuery();
Line 29: con.Close();
Line 30:
</code></pre>
<p>My C# Code Behind file - Registration</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql.Data.MySqlClient;
public partial class Registration : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void RegisterUser(object sender, EventArgs e)
{
MySqlConnection con = new MySqlConnection("Server=localhost;Database=FreedomKitchen;Uid=root;Password=;");
con.Open();
MySqlCommand cmd = new MySqlCommand("Insert into User_Details(User_ID,First__Name, Last_Name, Age, Gender, Country, About_User)values(@User_ID,@First__Name, @Last_Name, @Age, @Gender, @Country, @About_User)", con);
cmd.Parameters.Add(new MySqlParameter("@User_ID",1));
cmd.Parameters.Add(new MySqlParameter("@First_Name", txtFirstName.Text));
cmd.Parameters.Add(new MySqlParameter("@FLast_Name", txtLastName.Text));
cmd.Parameters.Add(new MySqlParameter("@Age", txtAge.Text));
cmd.Parameters.Add(new MySqlParameter("@Gender", DropDownGender.Text));
cmd.Parameters.Add(new MySqlParameter("@Country", DropDownCountry.Text));
cmd.Parameters.Add(new MySqlParameter("@About_User", txtUserDescription.Text));
cmd.ExecuteNonQuery();
con.Close();
}
}
</code></pre>
| 0debug |
static int32_t scsi_unit_attention(SCSIRequest *req, uint8_t *buf)
{
if (req->dev && req->dev->unit_attention.key == UNIT_ATTENTION) {
scsi_req_build_sense(req, req->dev->unit_attention);
} else if (req->bus->unit_attention.key == UNIT_ATTENTION) {
scsi_req_build_sense(req, req->bus->unit_attention);
}
scsi_req_complete(req, CHECK_CONDITION);
return 0;
}
| 1threat |
C# WPF Including many variables inside a Dictionary : I want to store inside a dictionary (name) many different variables (int, double, string, etc) that describes one object (name), like this:
string ref = "BCB";
int voltage = 12;
double watts = 60;
double width = 12.5;
double height = 15.5;
double cost = 10.2;
I have read about dictionaries but i don´t understand how do i have to store this variables inside it.
Can you write an example with this variables?
Thanks.
| 0debug |
Java- Having trouble with the resulting totals : <p>I have to write a java program to print up the receipts, but I'm having trouble with the resulting final values. I don't know where I went wrong.. The total values should be: Room $799.50, Telephone $17.25, Meal $129.50, Tips $74.87, Tax $51.97, and Gross Transaction $1073.08</p>
<pre><code>public class Hotel
{
//Class constants
private static final double Room_Rate = 79.95;
private static final double Tax_Rate = 6.5;
private static final double Telephone = 5.75;
private static final double Meal_Cost = 12.95;
private static final double Tip_Rate = 0.075;
//Instance Variables
private int noOfNights;
private int noOfGuests;
private double amountDue;
private double meal;
private double tax;
private double subtotal;
private double total;
private double tip;
private String roomNumber;
private static double TotalRoomCharges;
private static double TotalTelephoneCharges;
private static double TotalMealCharges;
private static double TotalTips;
private static double TotalTax;
private static double GrossTransaction;
public Hotel (String room)
{
roomNumber = room;
noOfGuests = 1;
noOfNights = 1;
}
public Hotel (String room, int nights)
{
this (room);
noOfNights = nights;
}
public Hotel (String room, int nights, int guest)
{
this (room, nights);
noOfGuests = guest;
}
public void addNights (int nights)
{
noOfNights = noOfNights + nights;
}
public void addGuest (int guests)
{
noOfGuests = noOfGuests + guests;
}
public void calculate ()
{
amountDue = Room_Rate * noOfNights * noOfGuests;
tax = amountDue * Tax_Rate / 100;
subtotal = amountDue + tax;
meal = Meal_Cost * noOfNights *noOfGuests;
tip = Tip_Rate * (subtotal + meal + Telephone);
total = subtotal + Telephone + meal + tip;
TotalRoomCharges = TotalRoomCharges + amountDue;
TotalTelephoneCharges = TotalTelephoneCharges + Telephone;
TotalMealCharges = TotalMealCharges + meal;
TotalTips = TotalTips + tip;
TotalTax = TotalTax + tax;
GrossTransaction = GrossTransaction + total;
}
public double getAmountDue()
{
return amountDue;
}
public double getTaxDue()
{
return tax;
}
public double getSubtotal()
{
return subtotal;
}
public double getTotal()
{
return total;
}
public double getTip()
{
return tip;
}
double getMeal()
{
return meal;
}
public String getRoomNumber()
{
return roomNumber;
}
public double getRoomRate()
{
return Room_Rate;
}
public int getNumberOfNights()
{
return noOfNights;
}
public int getNumberOfGuests ()
{
return noOfGuests;
}
public static double getPhoneCharges()
{
return Telephone;
}
public static double getTaxRate()
{
return Tax_Rate;
}
public static double getTotalRoomCharges()
{
return TotalRoomCharges;
}
public static double getTotalTelephoneCharges()
{
return TotalTelephoneCharges;
}
public static double getTotalMealCharges()
{
return TotalMealCharges;
}
public static double getTotalTips()
{
return TotalTips;
}
public static double getTotalTax()
{
return TotalTax;
}
public static double getGrossTransaction()
{
return GrossTransaction;
}
}
public class TestHotel
{
public static void main(String[] args)
{
Date d = new Date();
DateFormat df = DateFormat.getDateInstance();
NumberFormat f = NumberFormat.getCurrencyInstance();
//Define customers
Hotel customer1 = new Hotel ("10 - M", 2, 2);
customer1.calculate();
display(customer1, f);
Hotel customer2 = new Hotel ("12 - B");
Hotel customer3 = new Hotel ("12 - C", 2);
customer3.calculate();
customer2.addNights(1);
customer2.calculate();
display(customer2, f);
customer3.addGuest(1);
customer3.calculate();
display(customer3, f);
display (f);
}
static void display (Hotel h, NumberFormat f)
{
//Set up and display heading and date for each receipt
System.out.println("\tThe ABC Cheap Lodging, Inc");
Date d = new Date ();
DateFormat df = DateFormat.getDateInstance();
System.out.println("\tDate: \t" + df.format(d));
//Display expenses line by line including subtotal
System.out.println("Room # \t\t" + h.getRoomNumber());
System.out.println("Room Rate: \t" + f.format(h.getRoomRate()));
System.out.println("Length of Stay:\t" + h.getNumberOfNights() + " Night(s)");
System.out.println("No. of Guests: \t" + h.getNumberOfGuests());
System.out.println("Room Cost: \t" + f.format(h.getAmountDue()));
System.out.println("Tax:" + h.getTaxRate() + "%\t" + f.format(h.getTaxDue()));
System.out.println("\tSubtotal \t" + f.format(h.getSubtotal()));
System.out.println("Telephone \t" + f.format(h.getPhoneCharges()));
System.out.println("Meal Charges \t" + f.format(h.getMeal()));
System.out.println("Tip \t\t" + f.format(h.getTip()));
//Display to total
System.out.println("\nTOTAL AMOUNT DUE\t.........." + f.format(h.getTotal()));
//Display thank you message
System.out.println("\nThanks for staying at The ABC Cheap Lodging, Inc");
System.out.println("\tPlease come again !!!");
System.out.println("\n");
}
static void display (NumberFormat f)
{
System.out.println("\t\t Official Use Only");
System.out.println("\t\t Today's Summary");
System.out.println("\tRoom ....." + f.format(Hotel.getTotalRoomCharges()));
System.out.println("\tTelephone ....." + f.format (Hotel.getTotalTelephoneCharges()));
System.out.println("\tMeal ....." + f.format (Hotel.getTotalMealCharges()));
System.out.println("\tTips ....." + f.format (Hotel.getTotalTips()));
System.out.println("\tTax ....." + f.format (Hotel.getTotalTax()));
System.out.println("\t------------------------------\n");
System.out.println("\tGross Transaction .." + f.format (Hotel.getGrossTransaction()));
System.out.println("Process completed.");
}
}
</code></pre>
| 0debug |
static int shall_we_drop(AVFormatContext *s, int index)
{
struct dshow_ctx *ctx = s->priv_data;
static const uint8_t dropscore[] = {62, 75, 87, 100};
const int ndropscores = FF_ARRAY_ELEMS(dropscore);
unsigned int buffer_fullness = (ctx->curbufsize[index]*100)/s->max_picture_buffer;
if(dropscore[++ctx->video_frame_num%ndropscores] <= buffer_fullness) {
av_log(s, AV_LOG_ERROR,
"real-time buffer[%d] too full (%d%% of size: %d)! frame dropped!\n", index, buffer_fullness, s->max_picture_buffer);
return 1;
}
return 0;
}
| 1threat |
static int process_input(void)
{
InputFile *ifile;
AVFormatContext *is;
InputStream *ist;
AVPacket pkt;
int ret, i, j;
int file_index;
file_index = select_input_file();
if (file_index == -2) {
poll_filters() ;
return AVERROR(EAGAIN);
}
if (file_index < 0) {
if (got_eagain()) {
reset_eagain();
av_usleep(10000);
return AVERROR(EAGAIN);
}
av_log(NULL, AV_LOG_VERBOSE, "No more inputs to read from, finishing.\n");
return AVERROR_EOF;
}
ifile = input_files[file_index];
is = ifile->ctx;
ret = get_input_packet(ifile, &pkt);
if (ret == AVERROR(EAGAIN)) {
ifile->eagain = 1;
return ret;
}
if (ret < 0) {
if (ret != AVERROR_EOF) {
print_error(is->filename, ret);
if (exit_on_error)
exit_program(1);
}
ifile->eof_reached = 1;
for (i = 0; i < ifile->nb_streams; i++) {
ist = input_streams[ifile->ist_index + i];
if (ist->decoding_needed)
output_packet(ist, NULL);
poll_filters();
}
if (opt_shortest)
return AVERROR_EOF;
else
return AVERROR(EAGAIN);
}
reset_eagain();
if (do_pkt_dump) {
av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,
is->streams[pkt.stream_index]);
}
if (pkt.stream_index >= ifile->nb_streams) {
report_new_stream(file_index, &pkt);
goto discard_packet;
}
ist = input_streams[ifile->ist_index + pkt.stream_index];
if (ist->discard)
goto discard_packet;
if(!ist->wrap_correction_done && input_files[file_index]->ctx->start_time != AV_NOPTS_VALUE && ist->st->pts_wrap_bits < 64){
uint64_t stime = av_rescale_q(input_files[file_index]->ctx->start_time, AV_TIME_BASE_Q, ist->st->time_base);
uint64_t stime2= stime + (1LL<<ist->st->pts_wrap_bits);
ist->wrap_correction_done = 1;
if(pkt.dts != AV_NOPTS_VALUE && pkt.dts > stime && pkt.dts - stime > stime2 - pkt.dts) {
pkt.dts -= 1LL<<ist->st->pts_wrap_bits;
ist->wrap_correction_done = 0;
}
if(pkt.pts != AV_NOPTS_VALUE && pkt.pts > stime && pkt.pts - stime > stime2 - pkt.pts) {
pkt.pts -= 1LL<<ist->st->pts_wrap_bits;
ist->wrap_correction_done = 0;
}
}
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts *= ist->ts_scale;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts *= ist->ts_scale;
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "demuxer -> ist_index:%d type:%s "
"next_dts:%s next_dts_time:%s next_pts:%s next_pts_time:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s off:%"PRId64"\n",
ifile->ist_index + pkt.stream_index, av_get_media_type_string(ist->st->codec->codec_type),
av_ts2str(ist->next_dts), av_ts2timestr(ist->next_dts, &AV_TIME_BASE_Q),
av_ts2str(ist->next_pts), av_ts2timestr(ist->next_pts, &AV_TIME_BASE_Q),
av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ist->st->time_base),
av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ist->st->time_base),
input_files[ist->file_index]->ts_offset);
}
if (pkt.dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE &&
!copy_ts) {
int64_t pkt_dts = av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);
int64_t delta = pkt_dts - ist->next_dts;
if (is->iformat->flags & AVFMT_TS_DISCONT) {
if(delta < -1LL*dts_delta_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_delta_threshold*AV_TIME_BASE &&
ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) ||
pkt_dts+1<ist->pts){
ifile->ts_offset -= delta;
av_log(NULL, AV_LOG_DEBUG,
"timestamp discontinuity %"PRId64", new offset= %"PRId64"\n",
delta, ifile->ts_offset);
pkt.dts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
}
} else {
if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) ||
pkt_dts+1<ist->pts){
av_log(NULL, AV_LOG_WARNING, "DTS %"PRId64", next:%"PRId64" st:%d invalid dropping\n", pkt.dts, ist->next_dts, pkt.stream_index);
pkt.dts = AV_NOPTS_VALUE;
}
if (pkt.pts != AV_NOPTS_VALUE){
int64_t pkt_pts = av_rescale_q(pkt.pts, ist->st->time_base, AV_TIME_BASE_Q);
delta = pkt_pts - ist->next_dts;
if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) ||
pkt_pts+1<ist->pts) {
av_log(NULL, AV_LOG_WARNING, "PTS %"PRId64", next:%"PRId64" invalid dropping st:%d\n", pkt.pts, ist->next_dts, pkt.stream_index);
pkt.pts = AV_NOPTS_VALUE;
}
}
}
}
sub2video_heartbeat(ist, pkt.pts);
if ((ret = output_packet(ist, &pkt)) < 0 ||
((ret = poll_filters()) < 0 && ret != AVERROR_EOF)) {
char buf[128];
av_strerror(ret, buf, sizeof(buf));
av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d: %s\n",
ist->file_index, ist->st->index, buf);
if (exit_on_error)
exit_program(1);
av_free_packet(&pkt);
return AVERROR(EAGAIN);
}
discard_packet:
av_free_packet(&pkt);
return 0;
}
| 1threat |
C++ what is the difference of type * and type *& in function : <p>I have two function signatures in C++</p>
<pre><code>void printArray(int* arrayPtr);
void printArray(int*& arrayPtr);
</code></pre>
<p>I understand the 1st function. It says the function takes in a arrayPtr argument which is of type that's a pointer pointing to an integer. </p>
<p>Both function signature works, but I have a hard time understanding the 2nd signature(<code>*&</code>) and what benefits it offers?</p>
| 0debug |
C++: passing object reference as parameter gives error: no matching function for a call to class::function() : <p>Passing an object reference as parameter gives me the error:<br>
<code>No matching function for a call to i2cController::i2cController</code></p>
<p>I've also tried passing a pointer, and creating the i2cController with new.<br>
Both tries gave me the same result.<br>
Why is it even complaining about a call to i2cController, am I not passing the object instead of calling it? </p>
<p><strong>i2Controller (Passed object)</strong></p>
<p>i2cController.h</p>
<pre><code>#pragma once
class i2cController
{
private:
int foo;
public:
i2cController(int Foo);
void write(int value);
};
</code></pre>
<p>i2cController.cpp</p>
<pre><code>#include <i2cController.h>
i2cController::i2cController(int Foo)
{
foo = Foo;
}
void i2cController::write(int value)
{
foo++;
}
</code></pre>
<p><strong>Led class (receiving object reference, error originating from)</strong><br>
Error originates from: <code>Led::Led(int pin, i2cController &Controller);</code><br>
Led.h</p>
<pre><code>#pragma once
#include <i2cController.h>
class Led
{
private:
i2cController controller;
int pin;
public:
Led(int pin, i2cController &Controller);
void turnOn();
};
</code></pre>
<p>led.cpp</p>
<pre><code>#include <Led.h>
Led::Led(int Pin, i2cController &Controller)
{
controller = Controller;
pin = Pin;
}
void Led::turnOn()
{
controller.write(pin);
}
</code></pre>
<p><strong>main</strong></p>
<pre><code>i2cController controller(5);
Led led1 = new Led(led1Pin, controller);
</code></pre>
| 0debug |
EXCEL: Calculation is wrong, Rounding wrong : for som reason excel doesn't calculate correctly:
Calculation = 4642,83 * (60,13-60,08) / 66,84 = 3,47...
Excel = 3,40.
It is really important that i calculates directly because it will be rounded. The first one is rounded to 4. the second one is rounded to 3 which is a big difference in my calculation.
Anyone knows how to fix this?
Thanks in advance | 0debug |
Could the order of a list contained in a dictionary may vary? : I know that dictionaries may have a different order that the one which each key,value pair is inserted.
my_dict = {}
my_dict.update({'Nb': 2})
my_dict.update({'Nb': 1})
for keys,values in my_dict.items():
print(keys)
print(values)
#may result in
Nb: 1, 2
or
Nb: 2, 1
Then, is an object contained in a dictionnary may encounter the same behaviour?
another_dict = {'Type A': [4], 'Type B' : [0]}
another_dict['Type A'].append(2)
another_dict['Type A'].append(1)
for keys,values in another_dict.items():
print(keys)
print(values)
Type A: 4, 2
Type B: 0, 1
#Will the lists remain in the same order than their insertion?
| 0debug |
static int trim_filter_frame(AVFilterLink *inlink, AVFrame *frame)
{
AVFilterContext *ctx = inlink->dst;
TrimContext *s = ctx->priv;
int drop;
if (s->eof) {
av_frame_free(&frame);
return 0;
}
if (s->start_frame >= 0 || s->start_pts != AV_NOPTS_VALUE) {
drop = 1;
if (s->start_frame >= 0 && s->nb_frames >= s->start_frame)
drop = 0;
if (s->start_pts != AV_NOPTS_VALUE && frame->pts != AV_NOPTS_VALUE &&
frame->pts >= s->start_pts)
drop = 0;
if (drop)
goto drop;
}
if (s->first_pts == AV_NOPTS_VALUE && frame->pts != AV_NOPTS_VALUE)
s->first_pts = frame->pts;
if (s->end_frame != INT64_MAX || s->end_pts != AV_NOPTS_VALUE || s->duration_tb) {
drop = 1;
if (s->end_frame != INT64_MAX && s->nb_frames < s->end_frame)
drop = 0;
if (s->end_pts != AV_NOPTS_VALUE && frame->pts != AV_NOPTS_VALUE &&
frame->pts < s->end_pts)
drop = 0;
if (s->duration_tb && frame->pts != AV_NOPTS_VALUE &&
frame->pts - s->first_pts < s->duration_tb)
drop = 0;
if (drop) {
s->eof = 1;
goto drop;
}
}
s->nb_frames++;
s->got_output = 1;
return ff_filter_frame(ctx->outputs[0], frame);
drop:
s->nb_frames++;
av_frame_free(&frame);
return 0;
}
| 1threat |
How to execute a matlab code for different files : I have this matlab code who read and load my csv files
> `%% Initialize variables.
filename = 'C:\Users\loubn\Documents\MATLAB\test\fichier1.csv';
delimiter = ',';
to the end of the code
and it work perfectly , i want to execute this script for the others .csv files (fichier2,fichier3 ....... fichieri) on the test folder
| 0debug |
static int execute_command(BlockDriverState *bdrv,
SCSIRequest *r, int direction,
BlockDriverCompletionFunc *complete)
{
r->io_header.interface_id = 'S';
r->io_header.dxfer_direction = direction;
r->io_header.dxferp = r->buf;
r->io_header.dxfer_len = r->buflen;
r->io_header.cmdp = r->cmd;
r->io_header.cmd_len = r->cmdlen;
r->io_header.mx_sb_len = sizeof(r->dev->sensebuf);
r->io_header.sbp = r->dev->sensebuf;
r->io_header.timeout = MAX_UINT;
r->io_header.usr_ptr = r;
r->io_header.flags |= SG_FLAG_DIRECT_IO;
if (bdrv_pwrite(bdrv, -1, &r->io_header, sizeof(r->io_header)) == -1) {
BADF("execute_command: write failed ! (%d)\n", errno);
return -1;
}
if (complete == NULL) {
int ret;
r->aiocb = NULL;
while ((ret = bdrv_pread(bdrv, -1, &r->io_header,
sizeof(r->io_header))) == -1 &&
errno == EINTR);
if (ret == -1) {
BADF("execute_command: read failed !\n");
return -1;
}
return 0;
}
r->aiocb = bdrv_aio_read(bdrv, 0, (uint8_t*)&r->io_header,
-(int64_t)sizeof(r->io_header), complete, r);
if (r->aiocb == NULL) {
BADF("execute_command: read failed !\n");
return -1;
}
return 0;
}
| 1threat |
std::variant reflection. How can I tell which type of value std::variant is assigned? : <p>I have a class called <code>foo_t</code> that has a member called <code>bar</code> which could be any one of the types <code>std::string</code>, <code>int</code>, <code>std::vector<double></code>, etc. I would like to be able to ask <code>foo_t</code> which type <code>bar</code> has been assigned to. I decided to use <code>std::variant</code>.</p>
<p>I've written a solution, but I'm not sure if this is a good use of std::variant. I'm not sure if it matters, but I expect the list of types to possibly grow much bigger in the future. I made an enum class to store which type std::variant is assigned to. My first implementation also available on <a href="https://wandbox.org/permlink/pLshfzdpmv177KQf" rel="noreferrer">wandbox</a>:</p>
<pre><code>#include <iostream>
#include <variant>
#include <vector>
#include <string>
enum foo_kind_t {
double_list,
name_tag,
number,
unknown
};
template <typename val_t>
struct get_foo_kind_t {
constexpr static foo_kind_t value = unknown;
};
template <>
struct get_foo_kind_t<int> {
constexpr static foo_kind_t value = number;
};
template <>
struct get_foo_kind_t<std::string> {
constexpr static foo_kind_t value = name_tag;
};
template <>
struct get_foo_kind_t<std::vector<double>> {
constexpr static foo_kind_t value = double_list;
};
class foo_t {
public:
foo_t(): kind(unknown) {}
template <typename val_t>
void assign_bar(const val_t &val) {
static_assert(get_foo_kind_t<val_t>::value != unknown, "unsupported assignment");
kind = get_foo_kind_t<val_t>::value;
bar = val;
}
foo_kind_t get_kind() {
return kind;
}
template <typename val_t>
val_t get_bar() {
if (get_foo_kind_t<val_t>::value != kind) {
throw std::runtime_error("wrong kind");
}
return std::get<val_t>(bar);
}
private:
foo_kind_t kind;
std::variant<
int,
std::string,
std::vector<double>
> bar;
};
template <typename val_t>
void print_foo(foo_t &foo) {
std::cout << "kind: " << foo.get_kind() << std::endl;
std::cout << "value: " << foo.get_bar<val_t>() << std::endl << std::endl;
}
int main(int, char*[]) {
// double_list
foo_t b;
std::vector<double> b_val({ 1.0, 1.1, 1.2 });
b.assign_bar(b_val);
std::cout << "kind: " << b.get_kind() << std::endl;
std::cout << "value: vector size: " << b.get_bar<std::vector<double>>().size() << std::endl << std::endl;
// name_tag
foo_t d;
std::string d_val("name");
d.assign_bar(d_val);
print_foo<std::string>(d);
// number
foo_t c;
int c_val = 99;
c.assign_bar(c_val);
print_foo<int>(c);
// unknown
foo_t a;
std::cout << a.get_kind() << std::endl;
return 0;
}
</code></pre>
<p>Is this a good way to do it? Is there a way having better performance? Is there a way that requires less code to be written? Is there a way that doesn't require C++17?</p>
| 0debug |
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
{
int64_t r = 0;
av_assert2(c > 0);
av_assert2(b >=0);
av_assert2((unsigned)(rnd&~AV_ROUND_PASS_MINMAX)<=5 && (rnd&~AV_ROUND_PASS_MINMAX)!=4);
if (c <= 0 || b < 0 || !((unsigned)(rnd&~AV_ROUND_PASS_MINMAX)<=5 && (rnd&~AV_ROUND_PASS_MINMAX)!=4))
return INT64_MIN;
if (rnd & AV_ROUND_PASS_MINMAX) {
if (a == INT64_MIN || a == INT64_MAX)
return a;
rnd -= AV_ROUND_PASS_MINMAX;
}
if (a < 0 && a != INT64_MIN)
return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd >> 1) & 1));
if (rnd == AV_ROUND_NEAR_INF)
r = c / 2;
else if (rnd & 1)
r = c - 1;
if (b <= INT_MAX && c <= INT_MAX) {
if (a <= INT_MAX)
return (a * b + r) / c;
else
return a / c * b + (a % c * b + r) / c;
} else {
#if 1
uint64_t a0 = a & 0xFFFFFFFF;
uint64_t a1 = a >> 32;
uint64_t b0 = b & 0xFFFFFFFF;
uint64_t b1 = b >> 32;
uint64_t t1 = a0 * b1 + a1 * b0;
uint64_t t1a = t1 << 32;
int i;
a0 = a0 * b0 + t1a;
a1 = a1 * b1 + (t1 >> 32) + (a0 < t1a);
a0 += r;
a1 += a0 < r;
for (i = 63; i >= 0; i--) {
a1 += a1 + ((a0 >> i) & 1);
t1 += t1;
if (c <= a1) {
a1 -= c;
t1++;
}
}
return t1;
}
#else
AVInteger ai;
ai = av_mul_i(av_int2i(a), av_int2i(b));
ai = av_add_i(ai, av_int2i(r));
return av_i2int(av_div_i(ai, av_int2i(c)));
}
#endif
}
| 1threat |
R programming (extract same element matched with first column) : <p>I have below list:</p>
<blockquote>
<p>head(input)</p>
</blockquote>
<pre><code> V1 V2 V3 V4 V5 V6
1 A 1 2 3 4 5
2 B 1 2 NA NA NA
3 C 3 5 NA NA NA
4 D 3 NA NA NA NA
5 E 4 5 6 1 8
</code></pre>
<p>and I would like to get below results (extract all V1 elements matches to unique element from V2~V6):</p>
<pre><code>1 A B E
2 A B
3 A C D
4 A E
5 A C E
6 E
8 E
</code></pre>
<p>I was trying to write code in R, but I keep getting errors.. Can you please help with this code?</p>
<p>Thank you in advance.</p>
| 0debug |
uint8_t* ff_AMediaCodec_getOutputBuffer(FFAMediaCodec* codec, size_t idx, size_t *out_size)
{
uint8_t *ret = NULL;
JNIEnv *env = NULL;
jobject buffer = NULL;
JNI_GET_ENV_OR_RETURN(env, codec, NULL);
if (codec->has_get_i_o_buffer) {
buffer = (*env)->CallObjectMethod(env, codec->object, codec->jfields.get_output_buffer_id, idx);
if (ff_jni_exception_check(env, 1, codec) < 0) {
goto fail;
}
} else {
if (!codec->output_buffers) {
codec->output_buffers = (*env)->CallObjectMethod(env, codec->object, codec->jfields.get_output_buffers_id);
if (ff_jni_exception_check(env, 1, codec) < 0) {
goto fail;
}
codec->output_buffers = (*env)->NewGlobalRef(env, codec->output_buffers);
if (ff_jni_exception_check(env, 1, codec) < 0) {
goto fail;
}
}
buffer = (*env)->GetObjectArrayElement(env, codec->output_buffers, idx);
if (ff_jni_exception_check(env, 1, codec) < 0) {
goto fail;
}
}
ret = (*env)->GetDirectBufferAddress(env, buffer);
*out_size = (*env)->GetDirectBufferCapacity(env, buffer);
fail:
if (buffer) {
(*env)->DeleteLocalRef(env, buffer);
}
return ret;
}
| 1threat |
static void scsi_write_same_complete(void *opaque, int ret)
{
WriteSameCBData *data = opaque;
SCSIDiskReq *r = data->r;
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
assert(r->req.aiocb != NULL);
r->req.aiocb = NULL;
if (r->req.io_canceled) {
scsi_req_cancel_complete(&r->req);
goto done;
}
if (ret < 0) {
if (scsi_handle_rw_error(r, -ret, true)) {
goto done;
}
}
block_acct_done(blk_get_stats(s->qdev.conf.blk), &r->acct);
data->nb_sectors -= data->iov.iov_len / 512;
data->sector += data->iov.iov_len / 512;
data->iov.iov_len = MIN(data->nb_sectors * 512, data->iov.iov_len);
if (data->iov.iov_len) {
block_acct_start(blk_get_stats(s->qdev.conf.blk), &r->acct,
data->iov.iov_len, BLOCK_ACCT_WRITE);
qemu_iovec_init_external(&data->qiov, &data->iov, 1);
r->req.aiocb = blk_aio_pwritev(s->qdev.conf.blk,
data->sector << BDRV_SECTOR_BITS,
&data->qiov, 0,
scsi_write_same_complete, data);
return;
}
scsi_req_complete(&r->req, GOOD);
done:
scsi_req_unref(&r->req);
qemu_vfree(data->iov.iov_base);
g_free(data);
}
| 1threat |
How to write string to on pdf? : ı want to string write to pdf file .But my code dont work.
//iTextSharp.text.Document d = new iTextSharp.text.Document();
//string dosya = (@"C:\Deneme.pdf");
//PdfWriter.GetInstance(d, new System.IO.FileStream(dosya, System.IO.FileMode.Create));
//d.AddSubject(text); | 0debug |
Change mouse pointer in UWP app : <p>Is it possible to change or even hide the mouse-pointer in a UWP app?
The only thing I can find is this :</p>
<p>Windows.UI.Xaml.Window.Current.CoreWindow.PointerCursor = null;</p>
<p>But in UWP, this doesn't work.</p>
| 0debug |
Can't construct a query for the property, since the query selector wasn't defined : <p>Currently have this problem with a component in Angular 2 that exists of other components. The components of the 'main' component can exist multiple times in the hierarchy.</p>
<p>But i am getting this error:
<strong>"Can't construct a query for the property "navComponent" of "SidenavLinkComponent" since the query selector wasn't defined"</strong></p>
<pre><code>SidenavLinkComponent:
@ContentChild(SidenavNavComponent) navComponent: SidenavNavComponent;
SidenavNavComponent:
@ContentChildren(SidenavLinkComponent) linkComponents: QueryList<SidenavLinkComponent>;
</code></pre>
<p>I have made this slim plunker, where the problem is shown:
<a href="https://plnkr.co/edit/Dnpmv6X2IO3WGQAg0372?p=preview" rel="noreferrer">Plunker</a></p>
<p>I have no idea why it happens.</p>
| 0debug |
Combine Two table datas : <p><a href="https://i.stack.imgur.com/yydiK.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yydiK.jpg" alt="enter image description here"></a></p>
<p>I have two table A and B, i need a report by combining these two tables and the output should be as below image. How can i achieve it. Please help me out.</p>
| 0debug |
static void qmp_command_info(QmpCommand *cmd, void *opaque)
{
GuestAgentInfo *info = opaque;
GuestAgentCommandInfo *cmd_info;
GuestAgentCommandInfoList *cmd_info_list;
cmd_info = g_malloc0(sizeof(GuestAgentCommandInfo));
cmd_info->name = g_strdup(qmp_command_name(cmd));
cmd_info->enabled = qmp_command_is_enabled(cmd);
cmd_info->success_response = qmp_has_success_response(cmd);
cmd_info_list = g_malloc0(sizeof(GuestAgentCommandInfoList));
cmd_info_list->value = cmd_info;
cmd_info_list->next = info->supported_commands;
info->supported_commands = cmd_info_list;
}
| 1threat |
how to replace a dataframe row with NaN if it doesn't contain a specific string : <p><a href="https://i.stack.imgur.com/3HDdv.png" rel="nofollow noreferrer">dataframe</a></p>
<p>I am working with the data frame shown in the link above. I want to make all rows that do not contain the words 'Yes' or 'No' be replaced with NaN.</p>
| 0debug |
VSTO Word 2016: Squiggly underline without affecting undo : <p>I am working on a real-time language analysis tool that needs to highlight words to draw attention from the writer in Word 2016 using a VSTO add-in, written in .NET4.6.1 with C#. Think of the grammar/spelling check, which adds a squiggly line underneath a word to show you that the word has grammatical or spelling errors. I'm adding a similar feature for some of my own defined rules. </p>
<p>I searched around on adding squiggly lines, and stumbled on <code>Font.Underline</code> and <code>Font.UnderlineColor</code>. I set this on the range of a word, and it appears to provided that visual stumili I was after to draw attention. There is a problem, though. Every underline I add or underline color I change adds an undo action to the undo stack.</p>
<p>I don't want this to happen, or I want a way to pop the action I just did in code from the stack. The aim is to have the user be able to use CTRL+Z to remove <em>text</em> he changed, and not affect my language anlysis result.</p>
<p>How would I go about doing this?</p>
| 0debug |
Use Socket or webserver? : <p>I want to establish communication between set top box and an android phone.
Is it better to use sockets or communicate via an embedded web server ?</p>
| 0debug |
static void copy_bits(PutBitContext *pb,
const uint8_t *data, int size,
GetBitContext *gb, int nbits)
{
int rmn_bytes, rmn_bits;
rmn_bits = rmn_bytes = get_bits_left(gb);
if (rmn_bits < nbits)
rmn_bits &= 7; rmn_bytes >>= 3;
if ((rmn_bits = FFMIN(rmn_bits, nbits)) > 0)
put_bits(pb, rmn_bits, get_bits(gb, rmn_bits));
ff_copy_bits(pb, data + size - rmn_bytes,
FFMIN(nbits - rmn_bits, rmn_bytes << 3));
} | 1threat |
How to download build output files from jenkins UI console itself : <p>I am new Jenkins , using <b> jenkins 1.651.3 </b> War deployed on <b>Tomcat6</b><br>
Is there any way to download Jenkins job’s output file ( my job produced a jar file ) from jenkins UI Console itself ? </p>
<p>So, could anyone suggest me is there any way or plugin available to make the each Jenkins build output files ( like Jar/War) as downloadable from the Jenkins server machine</p>
<pre><code> [INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ NumberGenerator ---
[INFO] Building jar: /opt/cloudhost/jenkinsHome/jobs/TestGiby/workspace/NumberGenerator/target/NumberGenerator-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ NumberGenerator ---
[INFO] Installing /opt/cloudhost/jenkinsHome/jobs/TestGiby/workspace/NumberGenerator/target/NumberGenerator-0.0.1-SNAPSHOT.jar to /opt/cloudhost/software/maven/mavenRepo/com/giby/maven/NumberGenerator/0.0.1-SNAPSHOT/NumberGenerator-0.0.1-SNAPSHOT.jar
[INFO] Installing /opt/cloudhost/jenkinsHome/jobs/TestGiby/workspace/NumberGenerator/pom.xml to /opt/cloudhost/software/maven/mavenRepo/com/giby/maven/NumberGenerator/0.0.1-SNAPSHOT/NumberGenerator-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.575 s
[INFO] Finished at: 2017-02-01T05:00:44+00:00
[INFO] Final Memory: 19M/607M
[INFO] ------------------------------------------------------------------------
Finished: SUCCESS
</code></pre>
| 0debug |
Casting complex to real without data copy in MATLAB R2018a and newer : <p>Since <a href="https://www.mathworks.com/help/releases/R2018a/matlab/matlab_external/do-i-need-to-upgrade-my-mex-files-to-use-interleaved-complex.html" rel="noreferrer">MATLAB R2018a</a>, complex-valued matrices are stored internally as a single data block, with the real and imaginary component of each matrix element stored next to each other -- they call this "interleaved complex". (Previously such matrices had two data blocks, one for all real components, one for all imaginary components -- "separate complex".)</p>
<p>I figure, since the storage now allows for it, that it should be possible to cast a complex-valued array to a real-valued array with twice as many elements, without copying the data.</p>
<p>MATLAB has a function <a href="https://www.mathworks.com/help/matlab/ref/typecast.html" rel="noreferrer"><code>typecast</code></a>, which casts an array to a different type without copying data. It can be used, for example, to cast an array with 16 8-bit values to an array with 2 double floats. It does this without copying the data, the bit pattern is re-interpreted as the new type.</p>
<p>Sadly, this function does not work at all on complex-valued arrays.</p>
<p>I'm looking to replicate this code:</p>
<pre><code>A = fftn(randn(40,60,20)); % some random complex-valued array
assert(~isreal(A))
sz = size(A);
B = reshape(A,1,[]); % make into a vector
B = cat(1,real(B),imag(B)); % interleave real and imaginary values
B = reshape(B,[2,sz]); % reshape back to original shape, with a new first dimension
assert(isreal(B))
</code></pre>
<p>The matrices <code>A</code> and <code>B</code> have (in R2018a and newer) the exact same data, in exactly the same order. However, to get to <code>B</code> we had to copy the data twice.</p>
<p>I tried creating a MEX-file that does this, but I don't see how to create a new array that references the data in the input array. This MEX-file works, but causes MATLAB to crash when clearing variables, because there are two arrays that reference the same data without them realizing that they share data (i.e. the reference count is not incremented).</p>
<pre class="lang-cpp prettyprint-override"><code>// Build with:
// mex -R2018a typecast_complextoreal.cpp
#include <mex.h>
#if MX_HAS_INTERLEAVED_COMPLEX==0
#error "This MEX-file must be compiled with the -R2018a flag"
#endif
#include <vector>
void mexFunction(int /*nlhs*/, mxArray* plhs[], int nrhs, const mxArray* prhs[]) {
// Validate input
if(nrhs != 1) {
mexErrMsgTxt("One input argument expected");
}
if(!mxIsDouble(prhs[0]) && !mxIsSingle(prhs[0])) {
mexErrMsgTxt("Only floating-point arrays are supported");
}
// Get input array sizes
mwSize nDims = mxGetNumberOfDimensions(prhs[0]);
mwSize const* inSizes = mxGetDimensions(prhs[0]);
// Create a 0x0 output matrix of the same type, but real-valued
std::vector<mwSize> outSizes(nDims + 1, 0);
plhs[0] = mxCreateNumericMatrix(0, 0, mxGetClassID(prhs[0]), mxREAL);
// Set the output array data pointer to the input array's
// NOTE! This is illegal, and causes MATLAB to crash when freeing both
// input and output arrays, because it tries to free the same data
// twice
mxSetData(plhs[0], mxGetData(prhs[0]));
// Set the output array sizes
outSizes[0] = mxIsComplex(prhs[0]) ? 2 : 1;
for(size_t ii = 0; ii < nDims; ++ii) {
outSizes[ii + 1] = inSizes[ii];
}
mxSetDimensions(plhs[0], outSizes.data(), outSizes.size());
}
</code></pre>
<p>I'd love to hear of any ideas on how to proceed from here. I don't necessarily need to fix the MEX-file, if the solution is purely MATLAB code, so much the better.</p>
| 0debug |
Who can help but I got confused to Javascript : The document added another 3 link given in such a way that three Linck define three fruit and the fourth to erase selections, tell how to solve it.
<html>
<head>
<script language="javascript"><!--
function FruitBox()
{
window.document.myform.fruit[].checked=true;
}
function clearall(){
for (var p=1; p<3;p++){
var x=window.document.myform.fruit("value");
for (var i=0;i<4;i++)
x[i].checked=false;
}
}
//-->
</script>
</head>
<body>
<from name="myform">
<input type="radio" name="fruit" onclick="window.document.myform.fruit.value='oranges'">oranges & Tangerines <br>
<input type="radio" name="fruit" onclick="window.document.myform.fruit.value='bananas'">bananas <br>
<input type="radio" name="fruit" onclick="window.document.myform.fruit.value='peaches'">peaches,Nectarines & Palmus <br>
To select Oranges <a href="javascript:FruitBox()">clickhere</a>
<input type="reset" Value="Sterge" onClick=" clearall()"/>
</from>
</body>
</html> | 0debug |
static void vc1_decode_p_blocks(VC1Context *v)
{
MpegEncContext *s = &v->s;
int apply_loop_filter;
switch (v->c_ac_table_index) {
case 0:
v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;
break;
case 1:
v->codingset = CS_HIGH_MOT_INTRA;
break;
case 2:
v->codingset = CS_MID_RATE_INTRA;
break;
}
switch (v->c_ac_table_index) {
case 0:
v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;
break;
case 1:
v->codingset2 = CS_HIGH_MOT_INTER;
break;
case 2:
v->codingset2 = CS_MID_RATE_INTER;
break;
}
apply_loop_filter = s->loop_filter && !(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY);
s->first_slice_line = 1;
memset(v->cbp_base, 0, sizeof(v->cbp_base[0])*2*s->mb_stride);
for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
s->mb_x = 0;
ff_init_block_index(s);
for (; s->mb_x < s->mb_width; s->mb_x++) {
ff_update_block_index(s);
if (v->fcm == ILACE_FIELD)
vc1_decode_p_mb_intfi(v);
else if (v->fcm == ILACE_FRAME)
vc1_decode_p_mb_intfr(v);
else vc1_decode_p_mb(v);
if (s->mb_y != s->start_mb_y && apply_loop_filter && v->fcm == PROGRESSIVE)
vc1_apply_p_loop_filter(v);
if (get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) {
ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR);
av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n",
get_bits_count(&s->gb), v->bits, s->mb_x, s->mb_y);
return;
}
}
memmove(v->cbp_base, v->cbp, sizeof(v->cbp_base[0]) * s->mb_stride);
memmove(v->ttblk_base, v->ttblk, sizeof(v->ttblk_base[0]) * s->mb_stride);
memmove(v->is_intra_base, v->is_intra, sizeof(v->is_intra_base[0]) * s->mb_stride);
memmove(v->luma_mv_base, v->luma_mv, sizeof(v->luma_mv_base[0]) * s->mb_stride);
if (s->mb_y != s->start_mb_y) ff_draw_horiz_band(s, (s->mb_y - 1) * 16, 16);
s->first_slice_line = 0;
}
if (apply_loop_filter && v->fcm == PROGRESSIVE) {
s->mb_x = 0;
ff_init_block_index(s);
for (; s->mb_x < s->mb_width; s->mb_x++) {
ff_update_block_index(s);
vc1_apply_p_loop_filter(v);
}
}
if (s->end_mb_y >= s->start_mb_y)
ff_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16);
ff_er_add_slice(s, 0, s->start_mb_y << v->field_mode, s->mb_width - 1,
(s->end_mb_y << v->field_mode) - 1, ER_MB_END);
}
| 1threat |
Convert letters to lowercase from an array in JS : <p>I have the following code:</p>
<pre><code>var str = "abcabcABCABC"
var chars = str.split("");
var lettersCount = {};
for (var i = 0; i < chars.length;i++)
{
if (lettersCount[chars[i]] == undefined )
lettersCount[chars[i]] = 0;
lettersCount[chars[i]] ++;
}
for (var i in lettersCount)
{
console.log(i + ' = ' + lettersCount[i]);
}
</code></pre>
<p>This code is counting how many same letters are in a word. What am I trying is to convert the uppercase letters to lowercase so it should show like this: a - 4, b -4, now it shows: a - 2, A - 2.
I've just started with Js so please be good with me. :)</p>
| 0debug |
static int intel_hda_send_command(IntelHDAState *d, uint32_t verb)
{
uint32_t cad, nid, data;
HDACodecDevice *codec;
HDACodecDeviceClass *cdc;
cad = (verb >> 28) & 0x0f;
if (verb & (1 << 27)) {
dprint(d, 1, "%s: indirect node addressing (guest bug?)\n", __FUNCTION__);
return -1;
}
nid = (verb >> 20) & 0x7f;
data = verb & 0xfffff;
codec = hda_codec_find(&d->codecs, cad);
if (codec == NULL) {
dprint(d, 1, "%s: addressed non-existing codec\n", __FUNCTION__);
return -1;
}
cdc = HDA_CODEC_DEVICE_GET_CLASS(codec);
cdc->command(codec, nid, data);
return 0;
}
| 1threat |
String and dots filling : <p>Write a program (without using loops) which given a string, of size less
than 5, and a positive integer less than 100, prints both of them with
enough dots in between so that the whole string has 20 characters in them.</p>
<p>I know that if I am not using loops I have to use print(..., sep="") supresses the blank between the objects ,printed.</p>
<p>Can somebody tell me How do I restrict new string length to 20 characters?</p>
| 0debug |
static void adb_mouse_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
ADBDeviceClass *adc = ADB_DEVICE_CLASS(oc);
ADBMouseClass *amc = ADB_MOUSE_CLASS(oc);
amc->parent_realize = dc->realize;
dc->realize = adb_mouse_realizefn;
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
adc->devreq = adb_mouse_request;
dc->reset = adb_mouse_reset;
dc->vmsd = &vmstate_adb_mouse;
}
| 1threat |
Abort called error in Linux when providing a huge input in C : <p>I have written a program in C to find if a pattern exists inside another pattern. Both the patterns are 2-D character arrays.
To explain further, please consider the below case.</p>
<p>Suppose pattern A is </p>
<pre><code>1234567890
0987654321
1111111111
1111111111
2222222222
</code></pre>
<p>and pattern B is </p>
<pre><code>876543
111111
111111
</code></pre>
<p>In this case, pattern B exists inside pattern A. Starting from 2nd row and 3rd column.</p>
<p>Below is my code.</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
int main()
{
int t, T, R, C, r, c;
char** arr;
char ** pat;
int i, j, x, y, m = 0, n = 0, count = 0, brk_flag = 0, brk_flag2 = 0, found = 0;
freopen("C:\\test.txt", "r", stdin);
scanf("%d", &T);
for (t = 0; t<T; t++) {
scanf("%d%d", &R, &C);
arr = (char**)malloc(R * sizeof(char*));
if (arr == NULL) {
printf("Unable to allocate memory.");
exit(1);
}
for (i = 0; i < R; i++) {
arr[i] = (char*)malloc(C * sizeof(char));
scanf("%s", arr[i]);
}
scanf("%d%d", &r, &c);
pat = (char**)malloc(r * sizeof(char*));
if (pat == NULL) {
printf("Unable to allocate memory.");
exit(1);
}
for (i = 0; i < r; i++) {
pat[i] = (char*)malloc(c * sizeof(char));
scanf("%s", pat[i]);
}
brk_flag2 = 0;
found = 0;
for (i = 0; i < R; i++) {
for (j = 0; j < C; j++) {
if (arr[i][j] == pat[0][0]) {
if (i + r > R || j + c > C)
continue;
x = 0;
y = 0;
brk_flag = 0;
for (m = i; m< i + r; m++) {
y = 0;
for (n = j; n< j + c; n++) {
if (arr[m][n] == pat[x][y]) {
count++;
}
else {
brk_flag = 1;
break;
}
y++;
}
if (brk_flag == 1)
break;
x++;
}
if (count == (r * c)) {
printf("YES\n");
brk_flag2 = 1;
found = 1;
break;
}
count = 0;
}
else
continue;
}
if (brk_flag2 == 1)
break;
}
if (found == 0) {
printf("NO\n");
}
/*
for (i = 0; i < R; i++) {
free(arr[i]);
}
for (i = 0; i < r; i++) {
free(pat[i]);
}
*/
}
return 0;
}
</code></pre>
<p>For a testcase with pattern A of size 1000 X 1000, this works fine on Windows. But on Linux, I get an error as "Abort called".</p>
<p>I am unable to find where I am doing it wrong. Any ideas on this this would be hugely appreciated. Thanks.</p>
| 0debug |
DB: "table" has no column named "name column" : <p>I've this problem when I was launching the app, it made me this error:</p>
<pre><code>E/SQLiteLog: (1) table geophysics_table has no column named municipality
E/SQLiteDatabase: Error inserting id_grid=1 culture_type= resolution_survey= soil_type= coordinates= finish_date= start_date= municipality= site= software= range= ctr= assistans= frequency_feeler= igm= max_depth= instrument_type= area_investigated= description_site= n_tab= author= acquisition_method= survey_method= ref_geo_map=
android.database.sqlite.SQLiteException: table geophysics_table has no column named municipality (code 1): , while compiling: INSERT INTO geophysics_table(id_grid,culture_type,resolution_survey,soil_type,coordinates,finish_date,start_date,municipality,site,software,range,ctr,assistans,frequency_feeler,igm,max_depth,instrument_type,area_investigated,description_site,n_tab,author,acquisition_method,survey_method,ref_geo_map) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1469)
at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1341)
at com.example.giuse.secondly.DBTools.insertGrid(DBTools.java:85)
at com.example.giuse.secondly.NewSheet.saveData(NewSheet.java:104)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.view.View$1.onClick(View.java:4015)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
W/EGL_emulation: eglSurfaceAttrib not implemented
W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fa4f2464180, error=EGL_SUCCESS
</code></pre>
<p>But I think I've entered the "municipality" in every part. This is the code of the db:</p>
<pre><code> @Override
public void onCreate(SQLiteDatabase database) {
String query = "CREATE TABLE geophysics_table ( id_grid INTEGER PRIMARY KEY, site TEXT, " +
"n_tab TEXT, municipality TEXT, ctr TEXT, igm TEXT, coordinates TEXT, ref_geo_map TEXT, description_site TEXT, soil_type TEXT, culture_type TEXT, survey_method TEXT, instrument_type TEXT, resolution_survey TEXT, area_investigated TEXT, acquisition_method TEXT, frequency_feeler TEXT, range TEXT, max_depth TEXT, software TEXT, author TEXT, assistants TEXT, start_date TEXT, finish_date TEXT)";
</code></pre>
| 0debug |
FlatList not scrolling : <p>i have created a screen where I display a component that contains a FlatList. For some reason I can't scroll through the list. Someone who can spot my mistake and point me in the right direction?</p>
<p><strong>render-function and style from my screen file:</strong></p>
<pre><code>render() {
return (
<View style={styles.container}>
<SearchBar />
<ActivityList style={styles.list} data={this.state.data} />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
overflow: 'hidden',
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'flex-start',
},
list: {
flex: 1,
overflow: 'hidden',
},
});
</code></pre>
<p><strong>render function and style from my listitem component:</strong></p>
<pre><code>export default class CardItem extends React.PureComponent {
render() {
return (
<View style={styles.cardview}>
<View style={styles.imagecontainer}>
<Image
resizeMode="cover"
style={styles.cardimage}
source={{
uri: this.props.image,
}}
/>
</View>
<View style={styles.cardinfo}>
<Text style={styles.cardtitle}>{this.props.title}</Text>
<View style={styles.cardtext}>
<Text style={styles.textdate}>{this.props.date}</Text>
<Text style={styles.texthour}>{this.props.hour}</Text>
</View>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
cardview: {
flex: 1,
justifyContent: 'flex-start',
backgroundColor: 'white',
elevation: 3,
maxHeight: 200,
width: Dimensions.get('window').width - 20,
margin: 1,
marginTop: 10,
borderRadius: 4,
},
imagecontainer: {
flex: 7,
height: 140,
borderRadius: 4,
},
cardimage: {
flex: 1,
opacity: 0.8,
height: 140,
borderTopLeftRadius: 4,
borderTopRightRadius: 4,
},
cardinfo: {
flex: 2,
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
padding: 10,
},
cardtitle: {
flex: 1,
fontSize: 16,
fontWeight: 'bold',
},
cardtext: {
flex: 1,
justifyContent: 'center',
alignItems: 'flex-end',
},
textdate: {
color: '#5e5e71',
},
texthour: {
color: '#5e5e71',
},
});
</code></pre>
<p><strong>render function and style from my list component:</strong></p>
<pre><code>export default class ActivityList extends React.Component {
_renderCardItem = ({ item }) => (
<CardItem
image={item.image}
title={item.title}
date={item.date}
hour={item.hour}
/>
);
_keyExtractor = item => item.id;
render() {
return (
<FlatList
data={this.props.data}
renderItem={this._renderCardItem}
contentContainerStyle={styles.cardcontainer}
keyExtractor={this._keyExtractor}
/>
);
}
}
const styles = StyleSheet.create({
cardcontainer: {
flex: 1,
overflow: 'hidden',
backgroundColor: 'white',
alignItems: 'center',
width: Dimensions.get('window').width,
borderWidth: 0,
},
});
</code></pre>
<p>my data items have all a unique id, title, date, hour.</p>
<p>Read through all available guides and docs and found no solution.</p>
| 0debug |
My Enemy Fall from Floor when i play button in unity : My Enemy Fallen from Floor and continously Fallen when i play button in unity where as my Transform
Position x 0.03 y -0.459 z -0.1
Use Gravity is marked
I'm new in unity plz don't laugh and negative point me. | 0debug |
Maximum element in a stack java : <p><a href="https://www.hackerrank.com/challenges/maximum-element" rel="nofollow noreferrer">https://www.hackerrank.com/challenges/maximum-element</a></p>
<p>ques is to perform three queries 1-for adding elment to stack 2-for poping element 3-for printing max element
link is posted above
iam not able to get output for 6-7 cases on hackerrank</p>
<pre><code> int n,i;int in1,in2;
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
Stack<Integer> st=new Stack<Integer>();//stack for elements
Stack<Integer> stmax=new Stack<Integer>(); // stack for storing maximum
for(i=1;i<=n;i++)
{
in1=sc.nextInt();
if(in1==1)
{
in2=sc.nextInt();
if(st.size()==0)
{
stmax.push(in2);
st.push(in2);
}
else
{
if(in2>=stmax.peek())
{
stmax.push(in2);
}
st.push(in2);
}
}
if(in1==2)
{
if(st.peek()==stmax.peek())
stmax.pop();
st.pop();
}
if(in1==3)
{
System.out.println(stmax.peek());
}
}
</code></pre>
| 0debug |
Angular 4 - material 2 - md datepicker set first day of the week : <p>How to set first day of the week using material 2?</p>
<p>Currently the default is sunday even if I set the locale to hu or anything else..</p>
| 0debug |
Print out float/double variables for verification : I have the following scenario. A algorithm with A*B+C*D in floating-point variables calculation implemented in C++. However, in order to implement in hardware, we need to print out the A, B, C, D and golden output values from C++ simulation as a simulation pattern for hardware check. However, in C++, it comes to set precision digit. If that's the case, for the pattern feeding to hardware verification, can we expect it will get the same result against the golden output data printed out from C++ simulation ?
I'm thinking if printing out the floating values has essential uncertainty error and the result comparison should use relative way.
| 0debug |
static inline int hpel_motion(MpegEncContext *s,
uint8_t *dest, uint8_t *src,
int src_x, int src_y,
op_pixels_func *pix_op,
int motion_x, int motion_y)
{
int dxy = 0;
int emu = 0;
src_x += motion_x >> 1;
src_y += motion_y >> 1;
src_x = av_clip(src_x, -16, s->width);
if (src_x != s->width)
dxy |= motion_x & 1;
src_y = av_clip(src_y, -16, s->height);
if (src_y != s->height)
dxy |= (motion_y & 1) << 1;
src += src_y * s->linesize + src_x;
if ((unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x & 1) - 8, 0) ||
(unsigned)src_y > FFMAX(s->v_edge_pos - (motion_y & 1) - 8, 0)) {
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, src,
s->linesize, s->linesize,
9, 9,
src_x, src_y,
s->h_edge_pos, s->v_edge_pos);
src = s->edge_emu_buffer;
emu = 1;
}
pix_op[dxy](dest, src, s->linesize, 8);
return emu;
}
| 1threat |
How to ensure that a row does not equal "" in a dataframe? : I am pretty new to R, come from a Python background. I have loaded a dataframe as such:
df = read.csv('data.csv', stringsAsFactors = FALSE,
colClasses = colClass,na.strings = c("NA", ""))
My objective is to ensure that there are no missing values in my dataframe. I was thinking of writing code as such:
df = na.omit(df)
It wasn't removing the missing values, I then realized that it could be because of the importing of the dataframe. I imported it into a dataframe where I changed the "NA" to "".
My question is, is there a function similar to NA in which I could explicitly remove rows that have values ""?
Any help would be great!
| 0debug |
Separate comma separate values in Oracle : <p>I have a database column which contains comma separated values. Is there any way to get the individual values from this column into different rows without using regular expression in Oracle.</p>
| 0debug |
static void vmdaudio_loadsound(VmdAudioContext *s, unsigned char *data,
uint8_t *buf, int silence)
{
if (s->channels == 2) {
if ((s->block_align & 0x01) == 0) {
if (silence)
memset(data, 0, s->block_align * 2);
else
vmdaudio_decode_audio(s, data, buf, 1);
} else {
if (silence)
memset(data, 0, s->block_align * 2);
}
} else {
}
}
| 1threat |
Can someone explain why the range in the random.randint(0, len(messages) - 1) has a minus 1 at the end? The list has 9 values : import random
messages = ['It is certain',
'It is decidedly so',
'Yes definitely',
'Reply hazy try again',
'Ask again later',
'Concentrate and ask again',
'My reply is no',
'Outlook not so good',
'Very doubtful']
select_number = random.randint(0, len(messages) - 1)
list_select = messages[select_number]
print(list_select) | 0debug |
ENOSPC no space left on device -Nodejs : <p>I just built an application with expressJs for an institution where they upload video tutorials. At first the videos were being uploaded to the same server but later I switched to Amazon. I mean only the videos are being uploaded to Amazon. Now I get this error whenever I try to upload ENOSPC no space left on device. I have cleared the tmp file to no avail.I need to say that I have searched extensively about this issue but none of d solutions seems to work for me</p>
| 0debug |
add or modify contents of android app after publish : i want to publish an android app in the play store, the app should notify the users of any news or a new promotion. How can i add and modify the contents of app after being downloaded by users ?
Thank you. | 0debug |
My app is unfortunately stopped. I am getting this error in Logcat. : FATAL EXCEPTION: main
Process: org.example.easyparking, PID: 6371
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.example.easyparking/org.example.easyparking.MapActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class fragment
This is my mapactivity
package org.example.easyparking;
import android.app.Dialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.OnMapReadyCallback;
public class MapActivity extends AppCompatActivity implements
OnMapReadyCallback {
GoogleMap mGoogleMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
if(googleServicesAvailable()){
setContentView(R.layout.activity_map);
initMap();
}else{
//No Google Map Layout
}
}
private void initMap() {
MapFragment mapFragment = (MapFragment) getFragmentManager().
findFragmentById(R.id.mapFragment);
mapFragment.getMapAsync(this);
}
public boolean googleServicesAvailable(){
GoogleApiAvailability api = GoogleApiAvailability.getInstance();
int isAvailable = api.isGooglePlayServicesAvailable(this);
if(isAvailable == ConnectionResult.SUCCESS){
return true;
}else if (api.isUserResolvableError(isAvailable)){
Dialog dialog = api.getErrorDialog(this, isAvailable, 0);
dialog.show();
}else{
Toast.makeText(this, "Can't connect", Toast.LENGTH_LONG)
.show();
}
return false;
}
@Override
public void onMapReady(GoogleMap googleMap) {
mGoogleMap = googleMap;
}
}
This is menifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.example.easyparking">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<permission android:name="org.example.easyparking.permission.MAP_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="org.example.easyparking.permission.MAP_RECEIVE"/>
<uses-permission android:name="com.google.android.providers.gsf.permissions.READ_GSERVICES"/>
<uses-feature android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".FirstActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MapActivity" />
<activity
android:name=".SecondActivity">
</activity>
<meta-data android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDGpV3ndPQ1Z4zf1nXi5AW1c7jGPL1La7Q"/>
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
</application>
</manifest>
This is the first activity
package org.example.easyparking;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class FirstActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first);
Button button = (Button) this.findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(getApplicationContext(),
"Make sure that your location is turned on",
Toast.LENGTH_LONG).show();
Intent newacti = new Intent(FirstActivity.this, MapActivity.class);
startActivity(newacti);
}
});
Button button_parking_owner = (Button) this.findViewById(R.id.button2);
button_parking_owner.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent newacti = new Intent(FirstActivity.this, SecondActivity.class);
startActivity(newacti);
}
});
}
}
Please help me out. I am sucking here since a day.
| 0debug |
How do I add 10 arrays to a single array in c++? :
Let's say I have these 10 previously declared arrays in my code.
int arr1[] = {1,2,3,4,5,6,7,8,9,10};
int arr2[] = {1,2,3,4,5,6,7,8,9,10};
int arr3[] = {1,2,3,4,5,6,7,8,9,10};
int arr4[] = {1,2,3,4,5,6,7,8,9,10};
int arr5[] = {1,2,3,4,5,6,7,8,9,10};
int arr6[] = {1,2,3,4,5,6,7,8,9,10};
int arr7[] = {1,2,3,4,5,6,7,8,9,10};
int arr8[] = {1,2,3,4,5,6,7,8,9,10};
int arr9[] = {1,2,3,4,5,6,7,8,9,10};
int arr10[] = {1,2,3,4,5,6,7,8,9,10};
Basically, I want to add all 10 of these arrays to one single array and create an array of arrays.
How would I go about doing this? This question might seem trivial for some, but I'm new to C++ and can not figure out how to do it. Please help and thanks in advance. | 0debug |
Extract specific string from URL : <p>I want to extract some string from this url </p>
<p><a href="https://s3-ap-southeast-1.amazonaws.com/mtpdm/2019-06-14/12-14/1001_1203_20190614120605_5dd404.jpg" rel="nofollow noreferrer">https://s3-ap-southeast-1.amazonaws.com/mtpdm/2019-06-14/12-14/1001_1203_20190614120605_5dd404.jpg</a></p>
<p>I want to extract the 2019-06-14, how do I do that using java?</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.