problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static char *tcg_get_arg_str_idx(TCGContext *s, char *buf, int buf_size,
int idx)
{
TCGTemp *ts;
assert(idx >= 0 && idx < s->nb_temps);
ts = &s->temps[idx];
assert(ts);
if (idx < s->nb_globals) {
pstrcpy(buf, buf_size, ts->name);
} else {
if (ts->temp_local)
snprintf(buf, buf_size, "loc%d", idx - s->nb_globals);
else
snprintf(buf, buf_size, "tmp%d", idx - s->nb_globals);
}
return buf;
}
| 1threat
|
ActivityLifecycleCallbacks are not triggered when activity is killed through "Don't keep activities" : <p>In my Android app I have two activities:</p>
<ul>
<li><code>DemoActivity</code> with a button to start the <code>SearchActivity</code> with an <code>Intent</code></li>
<li><code>SearchActivity</code></li>
</ul>
<p>The button is a custom ViewGroup:</p>
<ul>
<li><code>SearchButton</code></li>
</ul>
<p>As soon as the <code>SearchButton</code> comes to life it registers for lifecycle events (of the corresponding <code>SearchActivity</code>):</p>
<pre><code>public class SearchButton extends CardView implements
Application.ActivityLifecycleCallbacks {
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
Context applicationContext = getContext().getApplicationContext();
if (applicationContext instanceof Application) {
((Application) applicationContext)
.registerActivityLifecycleCallbacks(this);
}
}
// ...
</code></pre>
<p>The events are consumed as follows:</p>
<pre><code>// ...
@Override
public void onActivityStarted(Activity activity) {
if (activity instanceof SearchActivity) {
SearchActivity searchActivity = (SearchActivity) activity;
searchActivity.addSomeListener(someListener);
}
}
@Override
public void onActivityStopped(Activity activity) {
if (activity instanceof SearchActivity) {
SearchActivity searchActivity = (SearchActivity) activity;
searchActivity.removeSomeListener(someListener);
}
}
</code></pre>
<p>Once the <code>SearchActivity</code> has been launched I put the app into background and get it back into foreground. The following call stack can be seen:</p>
<pre><code>1. SearchButton.onActivityStarted // triggered by DemoActivity
2. DemoActivity.onStart
3. SearchButton.onActivityStarted // triggered by SearchActivity
4. SearchActivity.addSomeListener
5. SearchActivity.onStart
</code></pre>
<p>As you can see the listener is added. This works fine.</p>
<hr>
<h3>The problem</h3>
<p>As soon as I enable <code>Don't keep activities</code> in the developer options the call stack looks like this when I get the app foreground again:</p>
<pre><code>1. DemoActivity.onCreate
2. SearchButton.init // Constructor
3. DemoActivity.onStart
4. SearchActivity.onStart
5. SearchButton.onAttachedToWindow
6. DemoApplication.registerActivityLifecycleCallbacks
</code></pre>
<p>Here the listener is <strong>not added</strong>. The desired <code>onActivityStarted</code> callback triggered by <code>SearchActivity.onStart</code> is <strong>missing</strong>.</p>
| 0debug
|
void acpi_pcihp_init(AcpiPciHpState *s, PCIBus *root_bus,
MemoryRegion *address_space_io, bool bridges_enabled)
{
uint16_t io_size = ACPI_PCIHP_SIZE;
s->root= root_bus;
s->legacy_piix = !bridges_enabled;
if (s->legacy_piix) {
unsigned *bus_bsel = g_malloc(sizeof *bus_bsel);
io_size = ACPI_PCIHP_LEGACY_SIZE;
*bus_bsel = ACPI_PCIHP_BSEL_DEFAULT;
object_property_add_uint32_ptr(OBJECT(root_bus), ACPI_PCIHP_PROP_BSEL,
bus_bsel, NULL);
}
memory_region_init_io(&s->io, NULL, &acpi_pcihp_io_ops, s,
"acpi-pci-hotplug", io_size);
memory_region_add_subregion(address_space_io, ACPI_PCIHP_ADDR, &s->io);
}
| 1threat
|
static inline void gen_lookup_tb(DisasContext *s)
{
tcg_gen_movi_i32(cpu_R[15], s->pc & ~1);
s->is_jmp = DISAS_JUMP;
}
| 1threat
|
How to log complex object using Serilog in valid json format? : <p>I have this structure:</p>
<pre><code>public class LogRequestParameters
{
public string RequestID { get; set; }
public string Type { get; set; }
public string Level { get; set; }
public string DateTime { get; set; }
public string MachineName { get; set; }
public Request Request { get; set; }
}
public class Request
{
public string URLVerb { get; set; }
}
</code></pre>
<p>I am writing following line for logging:</p>
<pre><code>Serilog.Log.Information("{@LogRequestParameters}", logRequestParameters);
</code></pre>
<p>I am getting following output:</p>
<pre><code>LogRequestParameters { RequestID: "bf14ff78-d553-4749-b2ac-0e5c333e4fce", Type: "Request", Level: "Debug", DateTime: "9/28/2016 3:12:27 PM", MachineName: "DXBKUSHAL", Request: Request { URLVerb: "GET /Violation/UnpaidViolationsSummary" } }
</code></pre>
<p>This is not a valid json. "LogRequestParameters" (name of class) is coming in the begining. "Request" (name of the property) is coming twice.
How can I log a valid json?</p>
| 0debug
|
static void gen_tlbld_6xx(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
gen_helper_6xx_tlbd(cpu_env, cpu_gpr[rB(ctx->opcode)]);
#endif
}
| 1threat
|
How to navigate one page to another in sap fiori? : <p>i am new to sap fiori.Can anyone please tell me how to navigate one page to another in sap fiori?</p>
<p>Thanks,
Navya.</p>
| 0debug
|
C char array storing a variable : <p>I would like to store 2 variables into char array, and print our the first one as shown below.</p>
<pre><code>const char *a[2];
a[0] = getCapital(bufferStore); //"Australia"
a[1] = getCurrencyCode(bufferStore); "9876.00"
printf("%s", a[0]);
</code></pre>
<p>However, I did not get any output. The code of getCapital and getCurrencyCode should be redundant here. The main thing I want to find out is how I can print out "Australia". I'm new to C language and pointers are really hard to understand, and my assignment is due in 2 hours. Any help will be greatly appreciated!</p>
| 0debug
|
static int decode_hq_slice_row(AVCodecContext *avctx, void *arg, int jobnr, int threadnr)
{
int i;
DiracContext *s = avctx->priv_data;
DiracSlice *slices = ((DiracSlice *)arg) + s->num_x*jobnr;
for (i = 0; i < s->num_x; i++)
decode_hq_slice(avctx, &slices[i]);
return 0;
}
| 1threat
|
static int wavpack_encode_block(WavPackEncodeContext *s,
int32_t *samples_l, int32_t *samples_r,
uint8_t *out, int out_size)
{
int block_size, start, end, data_size, tcount, temp, m = 0;
int i, j, ret, got_extra = 0, nb_samples = s->block_samples;
uint32_t crc = 0xffffffffu;
struct Decorr *dpp;
PutByteContext pb;
if (!(s->flags & WV_MONO) && s->optimize_mono) {
int32_t lor = 0, diff = 0;
for (i = 0; i < nb_samples; i++) {
lor |= samples_l[i] | samples_r[i];
diff |= samples_l[i] - samples_r[i];
if (lor && diff)
break;
}
if (i == nb_samples && lor && !diff) {
s->flags &= ~(WV_JOINT_STEREO | WV_CROSS_DECORR);
s->flags |= WV_FALSE_STEREO;
if (!s->false_stereo) {
s->false_stereo = 1;
s->num_terms = 0;
CLEAR(s->w);
}
} else if (s->false_stereo) {
s->false_stereo = 0;
s->num_terms = 0;
CLEAR(s->w);
}
}
if (s->flags & SHIFT_MASK) {
int shift = (s->flags & SHIFT_MASK) >> SHIFT_LSB;
int mag = (s->flags & MAG_MASK) >> MAG_LSB;
if (s->flags & WV_MONO_DATA)
shift_mono(samples_l, nb_samples, shift);
else
shift_stereo(samples_l, samples_r, nb_samples, shift);
if ((mag -= shift) < 0)
s->flags &= ~MAG_MASK;
else
s->flags -= (1 << MAG_LSB) * shift;
}
if ((s->flags & WV_FLOAT_DATA) || (s->flags & MAG_MASK) >> MAG_LSB >= 24) {
av_fast_padded_malloc(&s->orig_l, &s->orig_l_size, sizeof(int32_t) * nb_samples);
memcpy(s->orig_l, samples_l, sizeof(int32_t) * nb_samples);
if (!(s->flags & WV_MONO_DATA)) {
av_fast_padded_malloc(&s->orig_r, &s->orig_r_size, sizeof(int32_t) * nb_samples);
memcpy(s->orig_r, samples_r, sizeof(int32_t) * nb_samples);
}
if (s->flags & WV_FLOAT_DATA)
got_extra = scan_float(s, samples_l, samples_r, nb_samples);
else
got_extra = scan_int32(s, samples_l, samples_r, nb_samples);
s->num_terms = 0;
} else {
scan_int23(s, samples_l, samples_r, nb_samples);
if (s->shift != s->int32_zeros + s->int32_ones + s->int32_dups) {
s->shift = s->int32_zeros + s->int32_ones + s->int32_dups;
s->num_terms = 0;
}
}
if (!s->num_passes && !s->num_terms) {
s->num_passes = 1;
if (s->flags & WV_MONO_DATA)
ret = wv_mono(s, samples_l, 1, 0);
else
ret = wv_stereo(s, samples_l, samples_r, 1, 0);
s->num_passes = 0;
}
if (s->flags & WV_MONO_DATA) {
for (i = 0; i < nb_samples; i++)
crc += (crc << 1) + samples_l[i];
if (s->num_passes)
ret = wv_mono(s, samples_l, !s->num_terms, 1);
} else {
for (i = 0; i < nb_samples; i++)
crc += (crc << 3) + (samples_l[i] << 1) + samples_l[i] + samples_r[i];
if (s->num_passes)
ret = wv_stereo(s, samples_l, samples_r, !s->num_terms, 1);
}
if (ret < 0)
return ret;
if (!s->ch_offset)
s->flags |= WV_INITIAL_BLOCK;
s->ch_offset += 1 + !(s->flags & WV_MONO);
if (s->ch_offset == s->avctx->channels)
s->flags |= WV_FINAL_BLOCK;
bytestream2_init_writer(&pb, out, out_size);
bytestream2_put_le32(&pb, MKTAG('w', 'v', 'p', 'k'));
bytestream2_put_le32(&pb, 0);
bytestream2_put_le16(&pb, 0x410);
bytestream2_put_le16(&pb, 0);
bytestream2_put_le32(&pb, 0);
bytestream2_put_le32(&pb, s->sample_index);
bytestream2_put_le32(&pb, nb_samples);
bytestream2_put_le32(&pb, s->flags);
bytestream2_put_le32(&pb, crc);
if (s->flags & WV_INITIAL_BLOCK &&
s->avctx->channel_layout != AV_CH_LAYOUT_MONO &&
s->avctx->channel_layout != AV_CH_LAYOUT_STEREO) {
put_metadata_block(&pb, WP_ID_CHANINFO, 5);
bytestream2_put_byte(&pb, s->avctx->channels);
bytestream2_put_le32(&pb, s->avctx->channel_layout);
bytestream2_put_byte(&pb, 0);
}
if ((s->flags & SRATE_MASK) == SRATE_MASK) {
put_metadata_block(&pb, WP_ID_SAMPLE_RATE, 3);
bytestream2_put_le24(&pb, s->avctx->sample_rate);
bytestream2_put_byte(&pb, 0);
}
put_metadata_block(&pb, WP_ID_DECTERMS, s->num_terms);
for (i = 0; i < s->num_terms; i++) {
struct Decorr *dpp = &s->decorr_passes[i];
bytestream2_put_byte(&pb, ((dpp->value + 5) & 0x1f) | ((dpp->delta << 5) & 0xe0));
}
if (s->num_terms & 1)
bytestream2_put_byte(&pb, 0);
#define WRITE_DECWEIGHT(type) do { \
temp = store_weight(type); \
bytestream2_put_byte(&pb, temp); \
type = restore_weight(temp); \
} while (0)
bytestream2_put_byte(&pb, WP_ID_DECWEIGHTS);
bytestream2_put_byte(&pb, 0);
start = bytestream2_tell_p(&pb);
for (i = s->num_terms - 1; i >= 0; --i) {
struct Decorr *dpp = &s->decorr_passes[i];
if (store_weight(dpp->weightA) ||
(!(s->flags & WV_MONO_DATA) && store_weight(dpp->weightB)))
break;
}
tcount = i + 1;
for (i = 0; i < s->num_terms; i++) {
struct Decorr *dpp = &s->decorr_passes[i];
if (i < tcount) {
WRITE_DECWEIGHT(dpp->weightA);
if (!(s->flags & WV_MONO_DATA))
WRITE_DECWEIGHT(dpp->weightB);
} else {
dpp->weightA = dpp->weightB = 0;
}
}
end = bytestream2_tell_p(&pb);
out[start - 2] = WP_ID_DECWEIGHTS | (((end - start) & 1) ? WP_IDF_ODD: 0);
out[start - 1] = (end - start + 1) >> 1;
if ((end - start) & 1)
bytestream2_put_byte(&pb, 0);
#define WRITE_DECSAMPLE(type) do { \
temp = log2s(type); \
type = wp_exp2(temp); \
bytestream2_put_le16(&pb, temp); \
} while (0)
bytestream2_put_byte(&pb, WP_ID_DECSAMPLES);
bytestream2_put_byte(&pb, 0);
start = bytestream2_tell_p(&pb);
for (i = 0; i < s->num_terms; i++) {
struct Decorr *dpp = &s->decorr_passes[i];
if (i == 0) {
if (dpp->value > MAX_TERM) {
WRITE_DECSAMPLE(dpp->samplesA[0]);
WRITE_DECSAMPLE(dpp->samplesA[1]);
if (!(s->flags & WV_MONO_DATA)) {
WRITE_DECSAMPLE(dpp->samplesB[0]);
WRITE_DECSAMPLE(dpp->samplesB[1]);
}
} else if (dpp->value < 0) {
WRITE_DECSAMPLE(dpp->samplesA[0]);
WRITE_DECSAMPLE(dpp->samplesB[0]);
} else {
for (j = 0; j < dpp->value; j++) {
WRITE_DECSAMPLE(dpp->samplesA[j]);
if (!(s->flags & WV_MONO_DATA))
WRITE_DECSAMPLE(dpp->samplesB[j]);
}
}
} else {
CLEAR(dpp->samplesA);
CLEAR(dpp->samplesB);
}
}
end = bytestream2_tell_p(&pb);
out[start - 1] = (end - start) >> 1;
#define WRITE_CHAN_ENTROPY(chan) do { \
for (i = 0; i < 3; i++) { \
temp = wp_log2(s->w.c[chan].median[i]); \
bytestream2_put_le16(&pb, temp); \
s->w.c[chan].median[i] = wp_exp2(temp); \
} \
} while (0)
put_metadata_block(&pb, WP_ID_ENTROPY, 6 * (1 + (!(s->flags & WV_MONO_DATA))));
WRITE_CHAN_ENTROPY(0);
if (!(s->flags & WV_MONO_DATA))
WRITE_CHAN_ENTROPY(1);
if (s->flags & WV_FLOAT_DATA) {
put_metadata_block(&pb, WP_ID_FLOATINFO, 4);
bytestream2_put_byte(&pb, s->float_flags);
bytestream2_put_byte(&pb, s->float_shift);
bytestream2_put_byte(&pb, s->float_max_exp);
bytestream2_put_byte(&pb, 127);
}
if (s->flags & WV_INT32_DATA) {
put_metadata_block(&pb, WP_ID_INT32INFO, 4);
bytestream2_put_byte(&pb, s->int32_sent_bits);
bytestream2_put_byte(&pb, s->int32_zeros);
bytestream2_put_byte(&pb, s->int32_ones);
bytestream2_put_byte(&pb, s->int32_dups);
}
if (s->flags & WV_MONO_DATA && !s->num_passes) {
for (i = 0; i < nb_samples; i++) {
int32_t code = samples_l[i];
for (tcount = s->num_terms, dpp = s->decorr_passes; tcount--; dpp++) {
int32_t sam;
if (dpp->value > MAX_TERM) {
if (dpp->value & 1)
sam = 2 * dpp->samplesA[0] - dpp->samplesA[1];
else
sam = (3 * dpp->samplesA[0] - dpp->samplesA[1]) >> 1;
dpp->samplesA[1] = dpp->samplesA[0];
dpp->samplesA[0] = code;
} else {
sam = dpp->samplesA[m];
dpp->samplesA[(m + dpp->value) & (MAX_TERM - 1)] = code;
}
code -= APPLY_WEIGHT(dpp->weightA, sam);
UPDATE_WEIGHT(dpp->weightA, dpp->delta, sam, code);
}
m = (m + 1) & (MAX_TERM - 1);
samples_l[i] = code;
}
if (m) {
for (tcount = s->num_terms, dpp = s->decorr_passes; tcount--; dpp++)
if (dpp->value > 0 && dpp->value <= MAX_TERM) {
int32_t temp_A[MAX_TERM], temp_B[MAX_TERM];
int k;
memcpy(temp_A, dpp->samplesA, sizeof(dpp->samplesA));
memcpy(temp_B, dpp->samplesB, sizeof(dpp->samplesB));
for (k = 0; k < MAX_TERM; k++) {
dpp->samplesA[k] = temp_A[m];
dpp->samplesB[k] = temp_B[m];
m = (m + 1) & (MAX_TERM - 1);
}
}
}
} else if (!s->num_passes) {
if (s->flags & WV_JOINT_STEREO) {
for (i = 0; i < nb_samples; i++)
samples_r[i] += ((samples_l[i] -= samples_r[i]) >> 1);
}
for (i = 0; i < s->num_terms; i++) {
struct Decorr *dpp = &s->decorr_passes[i];
if (((s->flags & MAG_MASK) >> MAG_LSB) >= 16 || dpp->delta != 2)
decorr_stereo_pass2(dpp, samples_l, samples_r, nb_samples);
else
decorr_stereo_pass_id2(dpp, samples_l, samples_r, nb_samples);
}
}
bytestream2_put_byte(&pb, WP_ID_DATA | WP_IDF_LONG);
init_put_bits(&s->pb, pb.buffer + 3, bytestream2_get_bytes_left_p(&pb));
if (s->flags & WV_MONO_DATA) {
for (i = 0; i < nb_samples; i++)
wavpack_encode_sample(s, &s->w.c[0], s->samples[0][i]);
} else {
for (i = 0; i < nb_samples; i++) {
wavpack_encode_sample(s, &s->w.c[0], s->samples[0][i]);
wavpack_encode_sample(s, &s->w.c[1], s->samples[1][i]);
}
}
encode_flush(s);
flush_put_bits(&s->pb);
data_size = put_bits_count(&s->pb) >> 3;
bytestream2_put_le24(&pb, (data_size + 1) >> 1);
bytestream2_skip_p(&pb, data_size);
if (data_size & 1)
bytestream2_put_byte(&pb, 0);
if (got_extra) {
bytestream2_put_byte(&pb, WP_ID_EXTRABITS | WP_IDF_LONG);
init_put_bits(&s->pb, pb.buffer + 7, bytestream2_get_bytes_left_p(&pb));
if (s->flags & WV_FLOAT_DATA)
pack_float(s, s->orig_l, s->orig_r, nb_samples);
else
pack_int32(s, s->orig_l, s->orig_r, nb_samples);
flush_put_bits(&s->pb);
data_size = put_bits_count(&s->pb) >> 3;
bytestream2_put_le24(&pb, (data_size + 5) >> 1);
bytestream2_put_le32(&pb, s->crc_x);
bytestream2_skip_p(&pb, data_size);
if (data_size & 1)
bytestream2_put_byte(&pb, 0);
}
block_size = bytestream2_tell_p(&pb);
AV_WL32(out + 4, block_size - 8);
return block_size;
}
| 1threat
|
Get claims from a WebAPI Controller - JWT Token, : <p>I have built an application which uses JWT bearer authentication in ASP.NET Core. When authenticating I define some custom claims which i need to read in another WebAPI controller in order to execute some actions. </p>
<p>Any ideas How Can I achieve this?</p>
<p>This how my code looks like:(Code has been simplified)</p>
<pre><code>public async Task<IActionResult> AuthenticateAsync([FromBody] UserModel user)
{
..............
var tokenHandler = new JwtSecurityTokenHandler();
var key = Encoding.ASCII.GetBytes(_appSettings.Secret);
var tokenDescriptor = new SecurityTokenDescriptor
{
Subject = new ClaimsIdentity(new Claim[]
{
new Claim("userSecurityKey", userDeserialized.SecurityKey.ToString()),
new Claim("timeStamp",timeStamp),
new Claim("verificationKey",userDeserialized.VerificationKey.ToString())
}),
Expires = DateTime.UtcNow.AddDays(7),
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key),
SecurityAlgorithms.HmacSha256Signature)
};
var token = tokenHandler.CreateToken(tokenDescriptor);
var tokenString = tokenHandler.WriteToken(token);
.................
}
</code></pre>
<p>Another controller: (It Needs to read "verificationKey" claim.)</p>
<pre><code> [HttpGet]
[Route("getcandidate")]
public async Task<IActionResult> GetCandidateAsync()
{
try
{
............
var verificationKey = //TODO: GET VerificationKey FROM THE TOKEN
var verificationRecord = await service.GetVerificationRecordAsync(verificationKey);
.................
}
catch (Exception)
{
return NotFound();
}
}
</code></pre>
| 0debug
|
hello why i am having this error? cannot resolve method setText(java.lang.String[]) : public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
if(convertView == null){
LayoutInflater layoutInflater =(LayoutInflater) getContext().getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
convertView =layoutInflater.inflate(R.layout.custom_list_layout, null,true);
}
Product product = getItem(position);
ImageView imageView = (ImageView) convertView.findViewById(R.id.imageViewProduct);
TextView textName = (TextView) convertView.findViewById(R.id.textName);
textName.setText(product.getName());
TextView textPrice = (TextView) convertView.findViewById(R.id.textPrice);
textPrice.setText(product.getPrice());
return super.getView(position, convertView, parent);
}
}
| 0debug
|
How to increment int every 5seconds that won't block my UI? : <p>I have Array <code>String[] announcement = new String[20];</code> that has 20 value, I want to retrieve each of them every 5 seconds. I can't find any solution how to make increment every <strong><em>5 Seconds without blocking my UI.</em></strong></p>
| 0debug
|
Aggregate a data frame in R using multiple FUN (mean, min, SD) : <p>I am trying to aggregate a data frame to find the mean, min, and SD of a specific column compared to another. I would like to aggregate Semester, and only apply mean, SD, and min to Grade. Then display all in one output as columns (aggregated-Semester, mean, min, SD). Is this possible? Below is the example data frame.</p>
<p>(Sorry for output of data frame, not sure how to create a table in the questions)</p>
<pre><code>#------------------------------------------
#|Student |Semester |Grade |Name |
#------------------------------------------
#|1 |9a |90 |Jim |
#|2 |9b |91 |Beth |
#|3 |9a |76 |George |
#|4 |9b |87 |Phill |
#------------------------------------------
</code></pre>
| 0debug
|
Getting current time of a timezone : <p>I am trying to get current time of a particular timeZone but when I write this:</p>
<pre><code>Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("America/Boise"));
System.out.println(calendar.getTime());
</code></pre>
<p>it always prints UTC time followed by "UTC" word maybe because on the server timeZone is set to UTC but still it shouldn't happen as I explicitly specified the timezone here.</p>
| 0debug
|
e1000_link_up(E1000State *s)
{
s->mac_reg[STATUS] |= E1000_STATUS_LU;
s->phy_reg[PHY_STATUS] |= MII_SR_LINK_STATUS;
}
| 1threat
|
Do a class equivalent to IOS's SKStoreReviewController exist for Android? : <p>If you want to request a review of your app you can use SKStoreReviewController on IOS. But i can't seem to find an equivalent for Android. Does it exist? Or do i need to add a custom implementation?</p>
| 0debug
|
Removing duplicates every 5 minutes : <p>I am trying to remove duplicate ID's that appear in every 5 minutes time frame from the dataset. The data frame looks something like this;</p>
<pre><code>|---------------------|------------------|------------------|
| ID | Date | Time |
|---------------------|------------------|------------------|
| 12 | 2012-1-1 | 00:01:00 |
|---------------------|------------------|------------------|
| 13 | 2012-1-1 | 00:01:30 |
|---------------------|------------------|------------------|
| 12 | 2012-1-1 | 00:04:30 |
|---------------------|------------------|------------------|
| 12 | 2012-1-1 | 00:05:10 |
|---------------------|------------------|------------------|
| 12 | 2012-1-1 | 00:10:00 |
|---------------------|------------------|------------------|
</code></pre>
<p>Which should become;</p>
<pre><code>|---------------------|------------------|------------------|
| ID | Date | Time |
|---------------------|------------------|------------------|
| 12 | 2012-1-1 | 00:01:00 |
|---------------------|------------------|------------------|
| 13 | 2012-1-1 | 00:01:30 |
|---------------------|------------------|------------------|
| 12 | 2012-1-1 | 00:05:10 |
|---------------------|------------------|------------------|
| 12 | 2012-1-1 | 00:10:00 |
|---------------------|------------------|------------------|
</code></pre>
<p>The second time "12" occurs it should be flagged as duplicate as it appears a second time in the time frame 00:00:00 - 00:05:00.</p>
<p>I am using pandas to clean the current dataset. </p>
<p>Any help is appreciated!</p>
| 0debug
|
read file as list of tuples python : I want to read a file using python
the result must be like(a list of tuples):
> myList=[(1, 'assignment_1', 85,100', '0.05'),
> ('2', 'assignment_2', '80', '100', '0.05'),
> ('3', 'assignment_3', '95', '100', '0.05')]
the file contains:
> 1 assignment_1 85 100 0.05
> 2 assignment_2 80 100 0.05
> 3 assignment_3 95 100 0.05
my code :
> inputfile=open(filename,"r")
> myList=[]
> for line in inputfile.readlines():
> tuples=line.split()
> myList.append(tuples)
> print(myList)
> fileinput.close()
the result
> [['1', 'assignment_1', '85', '100', '0.05'],
> ['2', 'assignment_2', '80', '100', '0.05'],
> ['3', 'assignment_3', '95', '100', '0.05']]
how I convert the items into each type(int, float), I got alist of lists not a list of tuples
| 0debug
|
Activate python virtualenv in Dockerfile : <p>I have a Dockerfile where I try to activate python virtualenv after what, it should install all dependencies within this env. However, everything still gets installed globally. I used different approaches and non of them worked. I also do not get any errors. Where is a problem?</p>
<p>1.
<code>ENV PATH $PATH:env/bin</code></p>
<p>2.
<code>ENV PATH $PATH:env/bin/activate</code></p>
<p>3.
<code>RUN . env/bin/activate</code></p>
<p>I also followed <a href="https://github.com/GoogleCloudPlatform/python-runtime#kubernetes-engine--other-docker-hosts" rel="noreferrer">an example of a Dockerfile config for the python-runtime image on Google Cloud</a>, which is basically the same stuff as above.</p>
<blockquote>
<p>Setting these environment variables are the same as running source /env/bin/activate.</p>
</blockquote>
<p><code>ENV VIRTUAL_ENV /env</code></p>
<p><code>ENV PATH /env/bin:$PATH</code></p>
<p>Additionally, what does <code>ENV VIRTUAL_ENV /env</code> mean and how it is used?</p>
| 0debug
|
i want to sort the array in order to find the most common word placed in it : i want to sort the array in order to find the most common word placed in it here is the array:-
Array ( [0] => Array ( [0] => this [1] => burger [2] => is [3] => owsum ) [1] => Array ( [0] => this [1] => burger [2] => is [3] => owsum ) [2] => Array ( [0] => love [1] => this [2] => burger ) [3] => Array ( [0] => love [1] => this [2] => burger ) [4] => Array ( [0] => kamaaal [1] => burger ) [5] => Array ( [0] => kamaaal [1] => burger ) [6] => Array ( [0] => this [1] => burger [2] => is [3] => owsum ) )
| 0debug
|
C# Why do I get UserControl Eventhandler definiton error? : I have custom button (UserControl) and I want to create evenhandler for parent form but I always get this error and I don´t know why:
UserControl:
public event EventHandler OnMyClick;
private void label1_Click(object sender, EventArgs e)
{
if (OnMyClick != null)
OnMyClick("test",e);
}
Parent form:
private void Form1_Load(object sender, EventArgs e)
{
CreateMainMenu();
Computers_List ctrl = new Computers_List();
ctrl.OnMyClick += MainMenuClicked(); //I get error here on OnMyClick
}
protected void MainMenuClicked()
{
//something
}
Error:
Severity Code Description Project File Line Suppression State
Error CS1061 'Computers_List' does not contain a definition for 'OnMyClick' and no extension method 'OnMyClick' accepting a first argument of type 'Computers_List' could be found (are you missing a using directive or an assembly reference?) IT sklad C:\Users\somap\onedrive\documents\visual studio 2015\Projects\IT sklad\IT sklad\Form1.cs 27 Active
| 0debug
|
Combine Unequal length list in c# : There are 2 lists with the unequal length , i want to combine into single list.
var dataresource = (from det in dbobj.tbls1
where det.WorkTypeId == 1
select new
{
resnum = sowdet.number,
}).ToList();
var datafixed = (from det123 in dbobj.tbls1
where det123.WorkTypeId == 2
select new
{
fixednum = det123.number,
}).ToList();
dataresource contains values (A,B,C)
datafixed contains values (D,E,F,G,H)
Result expected is
Resultlist =
A D
B E
C F
null G
null H
Tried using .ZIP() but unable to handle the listt with unequal size
Thanks in Advancce
| 0debug
|
void OPPROTO op_decw_ECX(void)
{
ECX = (ECX & ~0xffff) | ((ECX - 1) & 0xffff);
}
| 1threat
|
Horizontal scroll in ionic 2 : <p>I have been trying to implement horizontal scroll in ionic 2 page. But the content always gets vertically scrolled. </p>
<p>I tried writing my own css by setting 'overflow-x to scroll'. But it didn't work. I also tried ionic's <strong>ion-scroll</strong> component by setting 'scrollX= true'. But the entire content got hidden. i.e it was not visible on the page at all. Below is the sample code i used for ion-scroll. Not sure what exactly i am missing here. </p>
<p>Any guidance on this pls?. (I am new to Ionic 2 and CSS. So sorry if the question is too simple.)</p>
<pre><code><ion-navbar *navbar primary>
<ion-title>
Title
</ion-title>
</ion-navbar>
<ion-content>
<ion-scroll scrollX="true">
<ion-card>
<ion-card-content>
content
</ion-card-content>
</ion-card>
<ion-card>
<ion-card-content>
content
</ion-card-content>
</ion-card>
</ion-scroll>
</ion-content>
</code></pre>
| 0debug
|
Android how to turn Location services on programatically? : I am building an android app to track my device, is it possible to turn location services on via code?
I have searched for code to do so i have found some and on execution of code it gives some sort of security exceptions, and some threads here on stack over flow were saying that it is impossible to do so, If possible please provide code, if impossible why so?
| 0debug
|
static void inet_addr_to_opts(QemuOpts *opts, const InetSocketAddress *addr)
{
bool ipv4 = addr->ipv4 || !addr->has_ipv4;
bool ipv6 = addr->ipv6 || !addr->has_ipv6;
if (!ipv4 || !ipv6) {
qemu_opt_set_bool(opts, "ipv4", ipv4, &error_abort);
qemu_opt_set_bool(opts, "ipv6", ipv6, &error_abort);
}
if (addr->has_to) {
qemu_opt_set_number(opts, "to", addr->to, &error_abort);
}
qemu_opt_set(opts, "host", addr->host, &error_abort);
qemu_opt_set(opts, "port", addr->port, &error_abort);
}
| 1threat
|
Is this a bug with the python OR operator? : <p>When I run the following code:</p>
<pre><code>i = None
O = ['n', 'y', 'No', 'Yes']
while i not in O:
i = input('Yes or No?\n')
if i == 'y' or 'Yes':
print('Yes')
if i == 'n' or 'No':
print('No')
</code></pre>
<p>The output is
n
Yes
No</p>
<p>Should the code only be displaying No as the output since the first if statement was false? Or am I not understanding something?</p>
<p>Thank you</p>
| 0debug
|
static void xilinx_axidma_init(Object *obj)
{
XilinxAXIDMA *s = XILINX_AXI_DMA(obj);
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
object_property_add_link(obj, "axistream-connected", TYPE_STREAM_SLAVE,
(Object **)&s->tx_data_dev, &error_abort);
object_property_add_link(obj, "axistream-control-connected",
TYPE_STREAM_SLAVE,
(Object **)&s->tx_control_dev, &error_abort);
object_initialize(&s->rx_data_dev, sizeof(s->rx_data_dev),
TYPE_XILINX_AXI_DMA_DATA_STREAM);
object_initialize(&s->rx_control_dev, sizeof(s->rx_control_dev),
TYPE_XILINX_AXI_DMA_CONTROL_STREAM);
object_property_add_child(OBJECT(s), "axistream-connected-target",
(Object *)&s->rx_data_dev, &error_abort);
object_property_add_child(OBJECT(s), "axistream-control-connected-target",
(Object *)&s->rx_control_dev, &error_abort);
sysbus_init_irq(sbd, &s->streams[0].irq);
sysbus_init_irq(sbd, &s->streams[1].irq);
memory_region_init_io(&s->iomem, obj, &axidma_ops, s,
"xlnx.axi-dma", R_MAX * 4 * 2);
sysbus_init_mmio(sbd, &s->iomem);
}
| 1threat
|
How to get the basic example Shiny app working? : <p>I can't make the first example of the first Shiny Tutorial to work.... on windows 10, R 3.6.1</p>
<p>I followed : <a href="https://shiny.rstudio.com/tutorial/written-tutorial/lesson1/" rel="nofollow noreferrer">https://shiny.rstudio.com/tutorial/written-tutorial/lesson1/</a></p>
<p>I get some part of the app : title / input field... no CSS, not working... only the title as shown below : :-( </p>
<p><a href="https://i.stack.imgur.com/5drvp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5drvp.png" alt="enter image description here"></a></p>
| 0debug
|
Best Practice for Updating AWS ECS Service Tasks : <p>I'm currently attempting to set up a simple CI that will rebuild my project, create a new docker image, push the new image to an amazon ecr repo, create a new revision of an existing task definition with the latest docker image, update a running service with the new revision of the task definition, and finally stop the existing task running the old revision and start one running the new revision.</p>
<p>Everything is working fine except for starting the new revision of the task.</p>
<p>From a bash script, the final command I call is:</p>
<pre><code>aws ecs update-service --cluster "$CLUSTER" --service "$SERVICE" --task-definition "$TASK_DEFINITION":"$REVISION"
</code></pre>
<p>This results in an event error of:</p>
<pre><code>(service rj-api-service) was unable to place a task because no container instance met all of its requirements. The closest matching (container-instance bbbc23d5-1a09-45e7-b344-e68cc408e683) is already using a port required by your task.
</code></pre>
<p>And this makes sense because the container I am replacing is exactly sthe same as the new one and will be running on the same port, it just contains the latest version of my application.</p>
<p>I was under the impression the <code>update-service</code> command would stop the existing task, and start the new one, but it looks like it starts the new one first, and if it succeeds stops the old one.</p>
<p>What is the best practice for handling this? Should I stop the old task first? Should I just delete the service in my script first and recreate the entire service each update?</p>
<p>Currently I only need 1 instance of the task running, but I don't want to box my self in if I need this to be able to auto scale to multiple instances. Any suggestions on the best way to address this?</p>
| 0debug
|
Looping through JSON and printing child nodes : I have the following JSON:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
var departments = {
"Department-1": [{
"fr": "Dept 1 - French",
"en": "Dept 1"
}],
"Department-2": [{
"fr": "Dept 2 - French",
"en": "Dept 2"
}],
"Department-3": [{
"fr": "Dept 3 - French",
"en": "Dept 3"
}]
}
<!-- end snippet -->
What I'm trying to do is, if the user is on the French site (/fr), then show the French (fr) headers. To achieve this, I'm trying to loop through the object.
Here's what I have tried to far:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
if (window.location.href.indexOf("fr") > -1) {
for (var key in departments) {
if (departments.hasOwnProperty(key)) {
console.log(key + " -> " + departments[key]);
$(".department").append('<option value="' + key + '">' + key + '</option>');
}
}
}
<!-- end snippet -->
The above has the following console log:
Department-1 -> [object Object]
Department-2 -> [object Object]
Department-3 -> [object Object]
And my `select` markup looks like this:
<select class="department" name="department" id="department">
<option>Department-1</option>
<option>Department-2</option>
<option>Department-3</option>
</select>
Whereas I'm after:
<select class="department" name="department" id="department">
<option>Dept 1 - French</option>
<option>Dept 2 - French</option>
<option>Dept 3 - French</option>
</select>
| 0debug
|
static int find_image_format(BlockDriverState *bs, const char *filename,
BlockDriver **pdrv, Error **errp)
{
BlockDriver *drv;
uint8_t buf[BLOCK_PROBE_BUF_SIZE];
int ret = 0;
if (bs->sg || !bdrv_is_inserted(bs) || bdrv_getlength(bs) == 0) {
*pdrv = &bdrv_raw;
return ret;
}
ret = bdrv_pread(bs, 0, buf, sizeof(buf));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read image for determining its "
"format");
*pdrv = NULL;
return ret;
}
drv = bdrv_probe_all(buf, ret, filename);
if (!drv) {
error_setg(errp, "Could not determine image format: No compatible "
"driver found");
ret = -ENOENT;
}
*pdrv = drv;
return ret;
}
| 1threat
|
Best tutorial for Spring Boot : <p>A'am new in Spring, and I must learning Spring Boot.
I do not now where to start and need me best tutorial's for Spring boot, I'm the total beginner in Spring.
Thanks</p>
| 0debug
|
Can ConcurrentDictionary.GetOrAdd() be called recursively? : <p><a href="http://ConcurrentDictionary%3CTKey,%E2%80%82TValue%3E.GetOrAdd%20Method%20(TKey,%E2%80%82Func%3CTKey,%E2%80%82TValue%3E)" rel="noreferrer">ConcurrentDictionary.GetOrAdd(TKey, Func<TKey, TValue>)</a> accepts a factory function to allow lazy instantiation of the item to be put into the dictionary.</p>
<p>Is it safe to define a factory function that itself calls GetOrAdd(), i.e. GetOrAdd is being called within the context of a 'parent' GetOrAdd().</p>
<p>The following code demonstrates the pattern; It does appear to work, but is it safe?</p>
<pre><code>class Program
{
static ConcurrentDictionary<string,object> __dict = new ConcurrentDictionary<string, object>();
static void Main(string[] args)
{
Foo foo = GetOrAddFoo();
Console.WriteLine(foo._name);
Console.WriteLine(foo._bar._name);
Console.ReadKey();
}
static Bar GetOrAddBar()
{
Console.WriteLine("GetOrAddBar: enter");
Func<string,Bar> factoryFn = (x) => LoadBar(x);
Bar bar = __dict.GetOrAdd("bar", factoryFn) as Bar;
Console.WriteLine("GetOrAddBar: exit");
return bar;
}
static Foo GetOrAddFoo()
{
Console.WriteLine("GetOrAddFoo: enter");
Func<string,Foo> factoryFn = (x) => LoadFoo(x);
Foo foo = __dict.GetOrAdd("foo", factoryFn) as Foo;
Console.WriteLine("GetOrAddFoo: exit");
return foo;
}
static Bar LoadBar(string name)
{
Bar bar = new Bar();
bar._name = name;
return bar;
}
static Foo LoadFoo(string name)
{
Foo foo = new Foo();
foo._name = name;
foo._bar = GetOrAddBar();
return foo;
}
public class Foo
{
public string _name;
public Bar _bar;
}
public class Bar
{
public string _name;
}
}
</code></pre>
| 0debug
|
static void aio_signal_handler(int signum)
{
#if !defined(QEMU_IMG) && !defined(QEMU_NBD)
CPUState *env = cpu_single_env;
if (env) {
cpu_interrupt(env, CPU_INTERRUPT_EXIT);
#ifdef USE_KQEMU
if (env->kqemu_enabled) {
kqemu_cpu_interrupt(env);
}
#endif
}
#endif
}
| 1threat
|
Java- How do i return to the main method from another method in the same class (break didn't work) : So i've seen a bunch of other posts about this, but they didn't apply since a) im trying to return to the main method while SKIPPING a while loop inside of the main. I'm making a text adventure game and it works in steps (seperate methods), by calling the next step from within the step at the end. for example, the first step is EastStoryline1(), and the second is EastStoryline2(), and at the end of the code for EastStoryline1(), it says "EastStoryline2()". So the actual main is pretty small, since its just one method looping into the next. There are also 2 while loops in the main. The first comes right after i establish the scanner and boolean playagain, which basically surrounds the rest of the main starts the game while playagain = true. the second loop comes right after the first, which basically says while def (the players health) > 0, play the events of the game. After the second loop, but still in the first loop, the code calls the method Die(), and then asks the player whether they want to play the game. SOOOO basically, what code do i put inside Die() in order to break out of any existing loop chain and bring it to the next code after Die() is called in the main. The problem is that i also use Die() in other methods, and each time it's called I want it to return to the code after Die() in the main. Here's the code for the main (sry for bad formatting):
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
boolean playagain = true;
while(playagain == true)
{
while(def > 0)
{
TitleScreen("TXT ADVENTURE!");
System.out.println("Pick a character: Rogue, Paladin, or Priest
(capitals DO matter!)");
String character = keyboard.next();
CharacterChoice(character);
System.out.println("You wake up on a dusty road, with no memory of who
you are or how you got here. You can only remember your name, and how to
fight. To the east lies a small dock with a boat. To the west, there seems
to be a sand-scarred mountain range. Do you go east, or west?");
String ew = keyboard.next();
EastWest(ew);
}
Die();
System.out.println("Do you want to play again?");
String playornah = keyboard.next();
if(playornah.equals("yes") || playornah.equals("Yes"))
{
playagain = true;
}
else
{
playagain = false;
}
}
}
And this was the code for Die (i was using system.exit(0), but now i want it to return to the main after Die is called there instead of just ending the program):
public static void Die()
{
System.out.println("GAME OVER");
System.exit(0); //I tried using break but it wouldn't compile
}
So what to i code in Die() in order for (no matter where it's called) return to the main after the spot where Die() is called.
| 0debug
|
static int mpeg_decode_mb(MpegEncContext *s,
DCTELEM block[12][64])
{
int i, j, k, cbp, val, mb_type, motion_type;
const int mb_block_count = 4 + (1<< s->chroma_format)
dprintf("decode_mb: x=%d y=%d\n", s->mb_x, s->mb_y);
assert(s->mb_skiped==0);
if (s->mb_skip_run-- != 0) {
if(s->pict_type == I_TYPE){
av_log(s->avctx, AV_LOG_ERROR, "skiped MB in I frame at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
s->mb_intra = 0;
for(i=0;i<12;i++)
s->block_last_index[i] = -1;
if(s->picture_structure == PICT_FRAME)
s->mv_type = MV_TYPE_16X16;
else
s->mv_type = MV_TYPE_FIELD;
if (s->pict_type == P_TYPE) {
s->mv_dir = MV_DIR_FORWARD;
s->mv[0][0][0] = s->mv[0][0][1] = 0;
s->last_mv[0][0][0] = s->last_mv[0][0][1] = 0;
s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0;
s->field_select[0][0]= s->picture_structure - 1;
s->mb_skiped = 1;
s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
} else {
s->mv[0][0][0] = s->last_mv[0][0][0];
s->mv[0][0][1] = s->last_mv[0][0][1];
s->mv[1][0][0] = s->last_mv[1][0][0];
s->mv[1][0][1] = s->last_mv[1][0][1];
s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]=
s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1] | MB_TYPE_SKIP;
if((s->mv[0][0][0]|s->mv[0][0][1]|s->mv[1][0][0]|s->mv[1][0][1])==0)
s->mb_skiped = 1;
}
return 0;
}
switch(s->pict_type) {
default:
case I_TYPE:
if (get_bits1(&s->gb) == 0) {
if (get_bits1(&s->gb) == 0){
av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in I Frame at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
mb_type = MB_TYPE_QUANT | MB_TYPE_INTRA;
} else {
mb_type = MB_TYPE_INTRA;
}
break;
case P_TYPE:
mb_type = get_vlc2(&s->gb, mb_ptype_vlc.table, MB_PTYPE_VLC_BITS, 1);
if (mb_type < 0){
av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in P Frame at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
mb_type = ptype2mb_type[ mb_type ];
break;
case B_TYPE:
mb_type = get_vlc2(&s->gb, mb_btype_vlc.table, MB_BTYPE_VLC_BITS, 1);
if (mb_type < 0){
av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in B Frame at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
mb_type = btype2mb_type[ mb_type ];
break;
}
dprintf("mb_type=%x\n", mb_type);
if (IS_INTRA(mb_type)) {
if (s->picture_structure == PICT_FRAME &&
!s->frame_pred_frame_dct) {
s->interlaced_dct = get_bits1(&s->gb);
}
if (IS_QUANT(mb_type))
s->qscale = get_qscale(s);
if (s->concealment_motion_vectors) {
if (s->picture_structure != PICT_FRAME)
skip_bits1(&s->gb);
s->mv[0][0][0]= s->last_mv[0][0][0]= s->last_mv[0][1][0] =
mpeg_decode_motion(s, s->mpeg_f_code[0][0], s->last_mv[0][0][0]);
s->mv[0][0][1]= s->last_mv[0][0][1]= s->last_mv[0][1][1] =
mpeg_decode_motion(s, s->mpeg_f_code[0][1], s->last_mv[0][0][1]);
skip_bits1(&s->gb);
}else
memset(s->last_mv, 0, sizeof(s->last_mv));
s->mb_intra = 1;
#ifdef HAVE_XVMC
if(s->avctx->xvmc_acceleration > 1){
XVMC_pack_pblocks(s,-1);
if(s->swap_uv){
exchange_uv(s);
}
}
#endif
if (s->codec_id == CODEC_ID_MPEG2VIDEO) {
for(i=0;i<mb_block_count;i++) {
if (mpeg2_decode_block_intra(s, s->pblocks[i], i) < 0)
return -1;
}
} else {
for(i=0;i<6;i++) {
if (mpeg1_decode_block_intra(s, s->pblocks[i], i) < 0)
return -1;
}
}
} else {
if (mb_type & MB_TYPE_ZERO_MV){
assert(mb_type & MB_TYPE_CBP);
if (s->picture_structure == PICT_FRAME &&
!s->frame_pred_frame_dct) {
s->interlaced_dct = get_bits1(&s->gb);
}
if (IS_QUANT(mb_type))
s->qscale = get_qscale(s);
s->mv_dir = MV_DIR_FORWARD;
if(s->picture_structure == PICT_FRAME)
s->mv_type = MV_TYPE_16X16;
else{
s->mv_type = MV_TYPE_FIELD;
mb_type |= MB_TYPE_INTERLACED;
s->field_select[0][0]= s->picture_structure - 1;
}
s->last_mv[0][0][0] = 0;
s->last_mv[0][0][1] = 0;
s->last_mv[0][1][0] = 0;
s->last_mv[0][1][1] = 0;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
}else{
assert(mb_type & MB_TYPE_L0L1);
if (s->frame_pred_frame_dct)
motion_type = MT_FRAME;
else{
motion_type = get_bits(&s->gb, 2);
}
if (s->picture_structure == PICT_FRAME &&
!s->frame_pred_frame_dct && HAS_CBP(mb_type)) {
s->interlaced_dct = get_bits1(&s->gb);
}
if (IS_QUANT(mb_type))
s->qscale = get_qscale(s);
s->mv_dir = 0;
for(i=0;i<2;i++) {
if (USES_LIST(mb_type, i)) {
s->mv_dir |= (MV_DIR_FORWARD >> i);
dprintf("motion_type=%d\n", motion_type);
switch(motion_type) {
case MT_FRAME:
if (s->picture_structure == PICT_FRAME) {
mb_type |= MB_TYPE_16x16;
s->mv_type = MV_TYPE_16X16;
s->mv[i][0][0]= s->last_mv[i][0][0]= s->last_mv[i][1][0] =
mpeg_decode_motion(s, s->mpeg_f_code[i][0], s->last_mv[i][0][0]);
s->mv[i][0][1]= s->last_mv[i][0][1]= s->last_mv[i][1][1] =
mpeg_decode_motion(s, s->mpeg_f_code[i][1], s->last_mv[i][0][1]);
if (s->full_pel[i]){
s->mv[i][0][0] <<= 1;
s->mv[i][0][1] <<= 1;
}
} else {
mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
s->mv_type = MV_TYPE_16X8;
for(j=0;j<2;j++) {
s->field_select[i][j] = get_bits1(&s->gb);
for(k=0;k<2;k++) {
val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],
s->last_mv[i][j][k]);
s->last_mv[i][j][k] = val;
s->mv[i][j][k] = val;
}
}
}
break;
case MT_FIELD:
s->mv_type = MV_TYPE_FIELD;
if (s->picture_structure == PICT_FRAME) {
mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
for(j=0;j<2;j++) {
s->field_select[i][j] = get_bits1(&s->gb);
val = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
s->last_mv[i][j][0]);
s->last_mv[i][j][0] = val;
s->mv[i][j][0] = val;
dprintf("fmx=%d\n", val);
val = mpeg_decode_motion(s, s->mpeg_f_code[i][1],
s->last_mv[i][j][1] >> 1);
s->last_mv[i][j][1] = val << 1;
s->mv[i][j][1] = val;
dprintf("fmy=%d\n", val);
}
} else {
mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
s->field_select[i][0] = get_bits1(&s->gb);
for(k=0;k<2;k++) {
val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],
s->last_mv[i][0][k]);
s->last_mv[i][0][k] = val;
s->last_mv[i][1][k] = val;
s->mv[i][0][k] = val;
}
}
break;
case MT_DMV:
{
int dmx, dmy, mx, my, m;
mx = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
s->last_mv[i][0][0]);
s->last_mv[i][0][0] = mx;
s->last_mv[i][1][0] = mx;
dmx = get_dmv(s);
my = mpeg_decode_motion(s, s->mpeg_f_code[i][1],
s->last_mv[i][0][1] >> 1);
dmy = get_dmv(s);
s->mv_type = MV_TYPE_DMV;
s->last_mv[i][0][1] = my<<1;
s->last_mv[i][1][1] = my<<1;
s->mv[i][0][0] = mx;
s->mv[i][0][1] = my;
s->mv[i][1][0] = mx;
s->mv[i][1][1] = my;
if (s->picture_structure == PICT_FRAME) {
mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
m = s->top_field_first ? 1 : 3;
s->mv[i][2][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
s->mv[i][2][1] = ((my * m + (my > 0)) >> 1) + dmy - 1;
m = 4 - m;
s->mv[i][3][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
s->mv[i][3][1] = ((my * m + (my > 0)) >> 1) + dmy + 1;
} else {
mb_type |= MB_TYPE_16x16;
s->mv[i][2][0] = ((mx + (mx > 0)) >> 1) + dmx;
s->mv[i][2][1] = ((my + (my > 0)) >> 1) + dmy;
if(s->picture_structure == PICT_TOP_FIELD)
s->mv[i][2][1]--;
else
s->mv[i][2][1]++;
}
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "00 motion_type at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
}
}
}
s->mb_intra = 0;
if (HAS_CBP(mb_type)) {
cbp = get_vlc2(&s->gb, mb_pat_vlc.table, MB_PAT_VLC_BITS, 1);
if (cbp < 0 || ((cbp == 0) && (s->chroma_format < 2)) ){
av_log(s->avctx, AV_LOG_ERROR, "invalid cbp at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
if(mb_block_count > 6){
cbp<<= mb_block_count-6;
cbp |= get_bits(&s->gb, mb_block_count-6);
}
#ifdef HAVE_XVMC
if(s->avctx->xvmc_acceleration > 1){
XVMC_pack_pblocks(s,cbp);
if(s->swap_uv){
exchange_uv(s);
}
}
#endif
if (s->codec_id == CODEC_ID_MPEG2VIDEO) {
if(s->flags2 & CODEC_FLAG2_FAST){
for(i=0;i<6;i++) {
if(cbp & 32) {
mpeg2_fast_decode_block_non_intra(s, s->pblocks[i], i);
} else {
s->block_last_index[i] = -1;
}
cbp+=cbp;
}
}else{
cbp<<= 12-mb_block_count;
for(i=0;i<mb_block_count;i++) {
if ( cbp & (1<<11) ) {
if (mpeg2_decode_block_non_intra(s, s->pblocks[i], i) < 0)
return -1;
} else {
s->block_last_index[i] = -1;
}
cbp+=cbp;
}
}
} else {
if(s->flags2 & CODEC_FLAG2_FAST){
for(i=0;i<6;i++) {
if (cbp & 32) {
mpeg1_fast_decode_block_inter(s, s->pblocks[i], i);
} else {
s->block_last_index[i] = -1;
}
cbp+=cbp;
}
}else{
for(i=0;i<6;i++) {
if (cbp & 32) {
if (mpeg1_decode_block_inter(s, s->pblocks[i], i) < 0)
return -1;
} else {
s->block_last_index[i] = -1;
}
cbp+=cbp;
}
}
}
}else{
for(i=0;i<6;i++)
s->block_last_index[i] = -1;
}
}
s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= mb_type;
return 0;
}
| 1threat
|
Program based on issuing a book in library : <p>The library at the Hogwarts School of Witchcraft and Wizardry has computerized its book issuing process. The relevant information is provided as text from standard input in three parts: information about books, information about borrowers and information about checkouts. Each part has a specific line format, described below.</p>
<p>Information about books
Line format: Accession Number~Title</p>
<p>Information about borrowers
Line format: Username~Full Name</p>
<p>Information about checkouts
Line format: Username~Accession Number~Due Date
Note: Due Date is in YYYY-MM-DD format.</p>
<p>You may assume that the data is internally consistent. For every checkout, there is a corresponding username and accession number in the input data, and no book is simultaneously checked out by two people.
Each section of the input starts with a line containing a single keyword. The first section begins with a line containing Books. The second section begins with a line containing Borrowers. The third section begins with a line containing Checkouts. The end of the input is marked by a line containing EndOfInput.
Write a Python program to read the data as described above and print out details about books that have been checked out. Each line should describe to one currently issued book in the following format:
Due Date~Full Name~Accession Number~Title
Your output should be sorted in increasing order of due date. For books due on the same date, sort in increasing order of full name.
Here is a sample input and its corresponding output.
Sample Input
Books APM-001~Advanced Potion-Making GWG-001~Gadding With Ghouls APM-002~Advanced Potion-Making DMT-001~Defensive Magical Theory DMT-003~Defensive Magical Theory GWG-002~Gadding With Ghouls DMT-002~Defensive Magical Theory Borrowers SLY2301~Hannah Abbott SLY2302~Euan Abercrombie SLY2303~Stewart Ackerley SLY2304~Bertram Aubrey SLY2305~Avery SLY2306~Malcolm Baddock SLY2307~Marcus Belby SLY2308~Katie Bell SLY2309~Sirius Orion Black Checkouts SLY2304~DMT-002~2019-03-27 SLY2301~GWG-001~2019-03-27 SLY2308~APM-002~2019-03-14 SLY2303~DMT-001~2019-04-03 SLY2301~GWG-002~2019-04-03 EndOfInput
Sample Output
2019-03-14~Katie Bell~APM-002~Advanced Potion-Making 2019-03-27~Bertram Aubrey~DMT-002~Defensive Magical Theory 2019-03-27~Hannah Abbott~GWG-001~Gadding With Ghouls 2019-04-03~Hannah Abbott~GWG-002~Gadding With Ghouls 2019-04-03~Stewart Ackerley~DMT-001~Defensive Magical Theory</p>
| 0debug
|
How to do IS NULL and IS NOT NULL with Yii 2 ActiveRecord? : <p>I have a table which has a field <code>`activated_at` timestamp NULL DEFAULT NULL</code>, which means that it can contain a timestamp or it can be <code>null</code> and it's <code>null</code> by default.</p>
<p>I have another [gii-generated] search model with a following configuration in the <code>search()</code> method:</p>
<pre><code>public function search($params)
{
$query = User::find();
// add conditions that should always apply here
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$andFilterWhere = [
'id' => $this->id,
'status' => $this->status,
'role' => $this->role,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'completed_files' => $this->completed_files,
// 'activated_at' => null,
];
if(!isset($_GET['deleted'])) {
$query->where(['deleted_at' => null]);
$andFilterWhere['deleted_at'] = null;
} else if($_GET['deleted'] === 'true') {
$query->where(['not', ['deleted_at' => null]]);
}
// grid filtering conditions
$query->andFilterWhere(
$andFilterWhere
);
$query->andFilterWhere(['like', 'first_name', $this->username])
->andFilterWhere(['like', 'auth_key', $this->auth_key])
->andFilterWhere(['like', 'password_hash', $this->password_hash])
->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])
->andFilterWhere(['like', 'email', $this->email])
->andFilterWhere(['like', 'first_name', $this->first_name])
->andFilterWhere(['like', 'last_name', $this->last_name]);
if($this->activated || $this->activated === "0") {
#die(var_dump($this->activated));
if($this->activated === '1') {
// this doesn't filter
$query->andFilterWhere(['not', ['activated_at' => null]]);
} else if($this->activated === '0') {
// this doesn't either
$query->andFilterWhere(['activated_at', null]);
}
}
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
return $dataProvider;
}
</code></pre>
<p>Yes, I have set the <code>activated</code> property in my class:</p>
<pre><code>public $activated;
</code></pre>
<p>And my <code>rules()</code> method is as following:</p>
<pre><code>public function rules()
{
return [
[['id', 'status', 'role', 'created_at', 'updated_at', 'completed_files'], 'integer'],
['activated', 'string'],
[['username', 'first_name', 'last_name', 'auth_key', 'password_hash', 'password_reset_token', 'email', 'deleted_at', 'completed_files', 'activated_at'], 'safe'],
];
}
</code></pre>
<p>What I was trying to set in the <code>search()</code> method is to filter on field <code>activated_at</code> depending on the <code>$activated</code> value (see above code):</p>
<pre><code>if($this->activated || $this->activated === "0") {
#die(var_dump($this->activated));
if($this->activated === '1') {
// this doesn't filter
$query->andFilterWhere(['not', ['activated_at' => null]]);
} else if($this->activated === '0') {
// this doesn't either
$query->andFilterWhere(['activated_at', null]);
$andFilterWhere['activated_at'] = null;
}
}
</code></pre>
<p>I use it with <code>GridView</code> - every other filter works except this one.</p>
<p>What am I doing wrong here?</p>
<p>Aand how to properly do this sort of queries:</p>
<pre><code>IS NULL something
IS NOT NULL something
</code></pre>
<p>With Yii 2's <code>ActiveRecord</code> query builder?</p>
<hr>
<p><strong>EDIT:</strong> Line: <code>if(!isset($_GET['deleted']))</code> is used for something else and this works normally.</p>
| 0debug
|
Chrome Extension affects another web page : I have problems creating chrome extensions, the code affects all webs that are open in chrome, how to solve it ?
| 0debug
|
extract the line by matching the word in text file : I have one text file file which contain text and other is csv file which contain designation i want to extract the line where designatnation is match.
import nltk
import re
import pandas as pd
with open('textfile.txt', encoding='utf16') as f:
sample = f.read()
file = pd.read_csv('designation.csv')
df = pd.DataFrame(file)
data = []
for i in range(len(df)):
des = df.loc[i]['Designations']
for line in sample.splitlines():
print(line)
des_regex = r'[a-zA-Z]'+des+r'[a-zA-Z]'
regular_expression = re.compile(des_regex, re.IGNORECASE)
regex_result = (re.search(regular_expression, line))
if regex_result:
data.append()
Input text file
" Sunder Pichai is the CEO of Google. Google is the american company
Google began in January 1996 as a research project by Larry Page and Sergey Brin when they were both PhD students at Stanford University in Stanford, California.[9]
While conventional search engines ranked results by counting how many times the search terms appeared on the page, the two theorized about a better system that analyzed the relationships among websites.[10] They called this new technology PageRank; it determined a website's relevance by the number of pages, and the importance of those pages that linked back to the original site.[11][12]
Page and Brin originally nicknamed their new search engine "BackRub", because the system checked backlinks to estimate the importance of a site.[13][14][15] Eventually, they changed the name to Google; the name of the search engine originated from a misspelling of the word "googol",[16][17] the number 1 followed by 100 zeros, which was picked to signify that the search engine was intended to provide large quantities of information.[18] Originally, Google ran under Stanford University's website, with the domains google.stanford.edu[19] and z.stanford.edu.[20]"
input csv file which contain designation like
CEO,
CTO,
COO
I want to output like
Sunder Pichai is the CEO of Google
| 0debug
|
static void fsl_imx25_realize(DeviceState *dev, Error **errp)
{
FslIMX25State *s = FSL_IMX25(dev);
uint8_t i;
Error *err = NULL;
object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
object_property_set_bool(OBJECT(&s->avic), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->avic), 0, FSL_IMX25_AVIC_ADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->avic), 0,
qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_IRQ));
sysbus_connect_irq(SYS_BUS_DEVICE(&s->avic), 1,
qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ));
object_property_set_bool(OBJECT(&s->ccm), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, FSL_IMX25_CCM_ADDR);
for (i = 0; i < FSL_IMX25_NUM_UARTS; i++) {
static const struct {
hwaddr addr;
unsigned int irq;
} serial_table[FSL_IMX25_NUM_UARTS] = {
{ FSL_IMX25_UART1_ADDR, FSL_IMX25_UART1_IRQ },
{ FSL_IMX25_UART2_ADDR, FSL_IMX25_UART2_IRQ },
{ FSL_IMX25_UART3_ADDR, FSL_IMX25_UART3_IRQ },
{ FSL_IMX25_UART4_ADDR, FSL_IMX25_UART4_IRQ },
{ FSL_IMX25_UART5_ADDR, FSL_IMX25_UART5_IRQ }
};
if (i < MAX_SERIAL_PORTS) {
Chardev *chr;
chr = serial_hds[i];
if (!chr) {
char label[20];
snprintf(label, sizeof(label), "imx31.uart%d", i);
chr = qemu_chr_new(label, "null");
}
qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr);
}
object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, serial_table[i].addr);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0,
qdev_get_gpio_in(DEVICE(&s->avic),
serial_table[i].irq));
}
for (i = 0; i < FSL_IMX25_NUM_GPTS; i++) {
static const struct {
hwaddr addr;
unsigned int irq;
} gpt_table[FSL_IMX25_NUM_GPTS] = {
{ FSL_IMX25_GPT1_ADDR, FSL_IMX25_GPT1_IRQ },
{ FSL_IMX25_GPT2_ADDR, FSL_IMX25_GPT2_IRQ },
{ FSL_IMX25_GPT3_ADDR, FSL_IMX25_GPT3_IRQ },
{ FSL_IMX25_GPT4_ADDR, FSL_IMX25_GPT4_IRQ }
};
s->gpt[i].ccm = IMX_CCM(&s->ccm);
object_property_set_bool(OBJECT(&s->gpt[i]), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpt[i]), 0, gpt_table[i].addr);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpt[i]), 0,
qdev_get_gpio_in(DEVICE(&s->avic),
gpt_table[i].irq));
}
for (i = 0; i < FSL_IMX25_NUM_EPITS; i++) {
static const struct {
hwaddr addr;
unsigned int irq;
} epit_table[FSL_IMX25_NUM_EPITS] = {
{ FSL_IMX25_EPIT1_ADDR, FSL_IMX25_EPIT1_IRQ },
{ FSL_IMX25_EPIT2_ADDR, FSL_IMX25_EPIT2_IRQ }
};
s->epit[i].ccm = IMX_CCM(&s->ccm);
object_property_set_bool(OBJECT(&s->epit[i]), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->epit[i]), 0, epit_table[i].addr);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->epit[i]), 0,
qdev_get_gpio_in(DEVICE(&s->avic),
epit_table[i].irq));
}
qdev_set_nic_properties(DEVICE(&s->fec), &nd_table[0]);
object_property_set_bool(OBJECT(&s->fec), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->fec), 0, FSL_IMX25_FEC_ADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->fec), 0,
qdev_get_gpio_in(DEVICE(&s->avic), FSL_IMX25_FEC_IRQ));
for (i = 0; i < FSL_IMX25_NUM_I2CS; i++) {
static const struct {
hwaddr addr;
unsigned int irq;
} i2c_table[FSL_IMX25_NUM_I2CS] = {
{ FSL_IMX25_I2C1_ADDR, FSL_IMX25_I2C1_IRQ },
{ FSL_IMX25_I2C2_ADDR, FSL_IMX25_I2C2_IRQ },
{ FSL_IMX25_I2C3_ADDR, FSL_IMX25_I2C3_IRQ }
};
object_property_set_bool(OBJECT(&s->i2c[i]), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c[i]), 0, i2c_table[i].addr);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c[i]), 0,
qdev_get_gpio_in(DEVICE(&s->avic),
i2c_table[i].irq));
}
for (i = 0; i < FSL_IMX25_NUM_GPIOS; i++) {
static const struct {
hwaddr addr;
unsigned int irq;
} gpio_table[FSL_IMX25_NUM_GPIOS] = {
{ FSL_IMX25_GPIO1_ADDR, FSL_IMX25_GPIO1_IRQ },
{ FSL_IMX25_GPIO2_ADDR, FSL_IMX25_GPIO2_IRQ },
{ FSL_IMX25_GPIO3_ADDR, FSL_IMX25_GPIO3_IRQ },
{ FSL_IMX25_GPIO4_ADDR, FSL_IMX25_GPIO4_IRQ }
};
object_property_set_bool(OBJECT(&s->gpio[i]), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, gpio_table[i].addr);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0,
qdev_get_gpio_in(DEVICE(&s->avic),
gpio_table[i].irq));
}
memory_region_init_rom_nomigrate(&s->rom[0], NULL,
"imx25.rom0", FSL_IMX25_ROM0_SIZE, &err);
if (err) {
error_propagate(errp, err);
return;
}
memory_region_add_subregion(get_system_memory(), FSL_IMX25_ROM0_ADDR,
&s->rom[0]);
memory_region_init_rom_nomigrate(&s->rom[1], NULL,
"imx25.rom1", FSL_IMX25_ROM1_SIZE, &err);
if (err) {
error_propagate(errp, err);
return;
}
memory_region_add_subregion(get_system_memory(), FSL_IMX25_ROM1_ADDR,
&s->rom[1]);
memory_region_init_ram(&s->iram, NULL, "imx25.iram", FSL_IMX25_IRAM_SIZE,
&err);
if (err) {
error_propagate(errp, err);
return;
}
memory_region_add_subregion(get_system_memory(), FSL_IMX25_IRAM_ADDR,
&s->iram);
memory_region_init_alias(&s->iram_alias, NULL, "imx25.iram_alias",
&s->iram, 0, FSL_IMX25_IRAM_ALIAS_SIZE);
memory_region_add_subregion(get_system_memory(), FSL_IMX25_IRAM_ALIAS_ADDR,
&s->iram_alias);
}
| 1threat
|
java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] : <p>I have been getting this issue.. followed the upgrade guide for new firebase sdk...saved the google services json file in app directory.. still the same error as you but for the database...</p>
<pre><code>Caused by: java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist.
</code></pre>
| 0debug
|
document.getElementById('input').innerHTML = user_input;
| 1threat
|
How to include a file upload control in an Angular2 reactive form? : <p>For some weird reason, there are just no tutorials or code samples online showing how to use Angular2 Reactive forms with anything more than simple input or select dropdowns. </p>
<p>I need to create a form to let users select their avatar. (Image file)</p>
<p>The following doesn't work. (i.e. The Avatar property never shows any value changes.)</p>
<p>profile.component.html:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code> <form [formGroup]="profileForm" novalidate>
<div class="row">
<div class="col-md-4 ">
<img src="{{imgUrl}}uploads/avatars/{{getUserAvatar}}" style="width:150px; height:150px;float:left;border-radius:50%;margin-right:25px;margin-left:10px;">
<div class="form-group">
<label>Update Profile Image</label>
<input class="form-control" type="file" formControlName="avatar">
</div>
</div>
<div class="col-md-8 ">
<div class="form-group">
<label >Firstname:
<input class="form-control" formControlName="firstname">
</label>
</div>
<div class="form-group">
<label >Lastname:
<input class="form-control" formControlName="lastname">
</label>
</div>
<div class="form-group">
<label >Email:
<input class="form-control" formControlName="email">
</label>
</div>
<div class="form-group">
<label >Password:
<input class="form-control" type="password" formControlName="password">
</label>
</div>
</div>
</div>
</form>
<p>Form value: {{ profileForm.value | json }}</p>
<p>Form status: {{ profileForm.status | json }}</p></code></pre>
</div>
</div>
</p>
<p>profile.component.ts:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import {Config} from '../../services/config.service';
import {AuthService} from '../../services/auth.service';
import {User} from '../../models/user.model';
@Component({
selector: 'app-profile',
templateUrl: './profile.component.html',
styleUrls: ['./profile.component.css']
})
export class ProfileComponent implements OnInit {
authUser:User;
profileForm : FormGroup;
constructor(private authService:AuthService, private fb: FormBuilder) {}
createForm() {
this.profileForm = this.fb.group({
firstname: [this.authUser.firstname, Validators.required ],
lastname: [this.authUser.lastname, Validators.required ],
email: [this.authUser.email, Validators.required ],
avatar: [this.authUser.avatar, Validators.required ],
password:['xxxxxx', Validators.minLength(4)]
});
}
ngOnInit() {
this.authUser = this.authService.getAuthUser();
this.createForm();
} </code></pre>
</div>
</div>
</p>
| 0debug
|
Portfolio grid hovers like Ueno : I wonder if you could help please. I'm trying to add a custom hover just like the project tiles on https://ueno.co/ whereby on hover a white border transitions up, and the image zooms up too. Here's a link to my homepage, it's the Portfolio grid I'm trying to improve - http://www.david-healey.com/
Cheers,
David
| 0debug
|
static inline void neon_store_reg64(TCGv var, int reg)
{
tcg_gen_st_i64(var, cpu_env, vfp_reg_offset(1, reg));
}
| 1threat
|
My first java project! need help :) : I wanted to know why there is an error and how to fix it for my java project.
I have to make exactly same out as these.
What is your annual interest rate as a decimal? (ex: 0.045): .033 How many years will your mortgage be held? 15 What amount of the mortgage did you borrow? 300000
The number 0.033 can be represented as 3.3% The mortgage amount is $300,000.00 The monthly payment in dollars is $2,115.30 The total payment in over the years in dollars is $380,754.76 The overpayment is $80,754.76 The overpayment as a percentage of the mortgage is 26.9
And this is what I did on Eclipse.
`enter code here`double annIntRat;
int nOY;
int borrowMor;
int M;
double monthPay;
double mIR;
Scanner scnr = new Scanner(System.in);
// Your code should go below this line
System.out.print("What is your annual interest rate as a decimal? (ex 0.045): ");
annIntRat = scnr.nextDouble();
System.out.print("How many years will your mortgage be held? ");
nOY = scnr.nextInt();
System.out.print("What amount of the mortgage did you borrow? ");
borrowMor = scnr.nextInt();
DecimalFormat df = new DecimalFormat("0.0");
System.out.println("\nThe number "+annIntRat+" can be represented as "+df.format((annIntRat)*100)+"%");
NumberFormat defaultFormat = NumberFormat.getCurrencyInstance();
M=defaultFormat.format(borrowMor); //< Here is the error and tells me to change to String.But if I do so, there will be an error down there for monthPay=.....
System.out.println("The mortgage amount is "+M);
mIR=(annIntRat)/12;
monthPay=(mIR * M)/(1-(1/Math.pow(1+mIR,12*nOY)));
| 0debug
|
How can i add a difficulty to my game : **i want to add a difficulty in my game, for example when i click a category like category "A" it will show a decision button to pick a "normal or hard" in the next layout.
sorry for my bad english**
| 0debug
|
Removing Migrations With Knex.js In My Node.js Application : <p>I am trying to get knex working in my node.js application. I was following a tutorial and at some point created a table but could not repeat the process. I removed the table and deleted all the migrations folders. At tis point I started over but after creating a new migration and then running <code>knex migrate:latest</code> I get an error saying the migration directory is corrupt because the original migration I had is missing. </p>
<p>I was under the impression that if the file is missing it should not know it was ever there. </p>
<p>What is the proper way to remove a migration from my project?</p>
<p>knexfile.js</p>
<pre><code> development: {
client: 'pg',
connection: {
host: '127.0.0.1',
user: 'postgres',
password: 'password',
database: 'myDatabase'
},
pool: {
min: 10,
max: 20
},
migrations: {
directory: __dirname + '/db/migrations'
},
seeds: {
directory: __dirname + '/db/seeds/development'
}
</code></pre>
<p>db.js </p>
<pre><code>var config = require('../knexfile.js');
var env = 'development';
var knex = require('knex')(config[env]);
module.exports = knex;
console.log('Getting knex');
knex.migrate.latest([config]);
console.log('Applying migration...');
</code></pre>
<p>Running this gives error,</p>
<pre><code>knex migrate:latest
Using environment: development
Error: The migration directory is corrupt, the following files are missing: 20161110130954_auth_level.js
</code></pre>
<p>but this migration does not exist because I deleted it.</p>
| 0debug
|
HTML5 video background color not matching background color of website -- in some browsers, sometimes : <p>I have a video that the client wants to sit "seamlessly" in the website. The background HEX color of the video matches the HEX background color of the website, and renders as such in some browsers, some versions, some of the time?</p>
<p>What is most curious is Chrome renders the background of the video differently, until you open the color picker. Then they suddenly match. To be clear, it only fixes it once I open the color picker, not the debugger (read: this not a repainting issue). </p>
<p>Firefox renders differently when I first navigate to the site, but if I hit cmd+r, it becomes perfectly seamless.</p>
<p>Take a look at the screenshots - they say more than I can with words.</p>
<p>I'm in the process of convincing the client to change to white background for the video as that will certainly "fix" it, but I'm super curious as to what /why this is happening.</p>
<p>Any insights from you wizards out there?</p>
<hr>
<p>Codepen: <a href="http://codepen.io/anon/pen/zrJVpX" rel="noreferrer">http://codepen.io/anon/pen/zrJVpX</a></p>
<pre><code><div class="background" style="background-color: #e1dcd8; width: 100%; height: 100%;">
<div class="video-container">
<video id="video" poster="" width="90%" height="auto" preload="" controls style="margin-left: 5%; margin-top: 5%;">
<source id="mp4" src="http://bigtomorrowdev.wpengine.com/wp-content/themes/bigtomorrow/images/videos/bt-process.mp4" type="video/mp4">
<source id="webm" src="http://bigtomorrowdev.wpengine.com/wp-content/themes/bigtomorrow/images/videos/bt-process.webm" type="video/webm">
<source id="ogg" src="http://bigtomorrowdev.wpengine.com/wp-content/themes/bigtomorrow/images/videos/bt-process.ogv" type="video/ogg">
We're sorry. This video is unable to be played on your browser.
</video>
</div>
</div>
</code></pre>
<p><a href="https://i.stack.imgur.com/vuME6.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/vuME6.jpg" alt="Screenshots of the different browsers."></a></p>
| 0debug
|
void cpu_physical_memory_unmap(void *buffer, target_phys_addr_t len,
int is_write, target_phys_addr_t access_len)
{
if (buffer != bounce.buffer) {
if (is_write) {
unsigned long addr1 = (uint8_t *)buffer - phys_ram_base;
while (access_len) {
unsigned l;
l = TARGET_PAGE_SIZE;
if (l > access_len)
l = access_len;
if (!cpu_physical_memory_is_dirty(addr1)) {
tb_invalidate_phys_page_range(addr1, addr1 + l, 0);
phys_ram_dirty[addr1 >> TARGET_PAGE_BITS] |=
(0xff & ~CODE_DIRTY_FLAG);
}
addr1 += l;
access_len -= l;
}
}
return;
}
if (is_write) {
cpu_physical_memory_write(bounce.addr, bounce.buffer, access_len);
}
qemu_free(bounce.buffer);
bounce.buffer = NULL;
}
| 1threat
|
Need help aligning modals side by side : Hey StackOverflow Members!
This is my first post. I usually find all my solutions to problems on here, but this question I cant seem to find the answer to. I am horrible at coding, but a am learning by making lots of mistakes. Im most comfortable with CSS and HTML, however java and other codes scare me to death! Speaking of JAVA, I am using modals for a website page I am working on. Everything has been working good, but I cant seem to get them to align how I would like them. If you do answer with a solution, if you could explain it so I can make this a learning process that would be great :)
So here it goes. I am trying to make a web page which has 3 buttons which trigger a modal. A Monthly Subscription, Yearly Subscription, and Purchase Add-Ons. Both membership buttons open a modal with a PayPal subscription page. Now as soon as I add the PayPal code, i loose the ability to keep the 2 buttons side by side. Instead they are stacked. I have tried <Center>, Text-Align, Putting the modal in a DIV, and still no success.
**Here Is The Code** (Yes I know...tisk tisk I have CSS with my HTML)
http://pastebin.com/YfGghAW2
I dont know how to add code in this message correctly. Hope this is ok.
Any help would be great :)
| 0debug
|
static void pc_init_pci_1_6(QEMUMachineInitArgs *args)
{
has_pci_info = false;
pc_init_pci(args);
}
| 1threat
|
def number_ctr(str):
number_ctr= 0
for i in range(len(str)):
if str[i] >= '0' and str[i] <= '9': number_ctr += 1
return number_ctr
| 0debug
|
How to access elements using Javascript with no id : I'm trying to access an element that has no id and has a shared classname, using Javascript.How can I successfully do that?
I tried using document.getElementsbyClassName property but since the classname is shared by other elements, this is not working.
<a class="sharedClass anotherClass" href="www.mybooks.com" data-m="{"CN":"uniquename"}"> Proceed </a>
//I want to be able to click Proceed element from the above code. Please note that uniquename is unique to this element. I'm thinking we can use that somehow here but am not really sure.
| 0debug
|
C struct local copy inside a function : <p>I have a struct named "point", and an array of "points", named "A[N]".
I also have a function, where I want to have a local copy of "A".
How should I do in order to optain a local copy of "A", inside the function?</p>
<pre><code>struct point A[N];
int function(struct point *A)
{
struct point *ALocal;
...
}
</code></pre>
| 0debug
|
How to view file properties in visual studio 2017 : I am following along to a video on msdn's channel 9 page.
[Bob Tabor teaches C#][1]
Around the 12:37 time mark, the narrator tells how to view the file properties in visual studio. But that is for an older edition. The problem is I added a .txt file to the C# project but it was not included in the \bin\Debug folder. How do I view the file properties window?
[1]: https://channel9.msdn.com/series/C-Fundamentals-for-Absolute-Beginners/12
| 0debug
|
how i want to get push notification(in json format) value in name value pair on onRecive method : GCM values are come in Json format in push Notification .
I want to store the data in broadcast Reciver class in ArrayList method
| 0debug
|
static int vnc_set_gnutls_priority(gnutls_session_t s, int x509)
{
const char *priority = x509 ? "NORMAL" : "NORMAL:+ANON-DH";
int rc;
rc = gnutls_priority_set_direct(s, priority, NULL);
if (rc != GNUTLS_E_SUCCESS) {
return -1;
}
return 0;
}
| 1threat
|
How secure is GIT bundle : <p>I have two identical repositories on two separated internet-less machines.<br>
The code is sensitive and cannot be exposed to the outside world (even not its diff).</p>
<p>How secure is a git bundle file which contains only a delta update?<br>
I know that one cannot pull from it if he does not have the initial base - <code>git bundle verify</code> will fail.<br>
Opening the file with text editor does not reveal any segment of code.<br>
Is there a way for a third party to open and see the code within?<br>
<strong>How secure is it?</strong></p>
| 0debug
|
How to apply SQL Scripts on RDS with Terraform : <p>I´m using Terraform to create a script that builds some EC2 Servers and a MySQL RDS (using AWS Amazon Provider).</p>
<p>Is there a way to execute a SQL script on this created RDS (i want to create users, tables, etc)?</p>
<p>Thanks in advance,</p>
<p>Att,</p>
| 0debug
|
query = 'SELECT * FROM customers WHERE email = ' + email_input
| 1threat
|
static int vscsi_srp_direct_data(VSCSIState *s, vscsi_req *req,
uint8_t *buf, uint32_t len)
{
struct srp_direct_buf *md = req->cur_desc;
uint32_t llen;
int rc;
dprintf("VSCSI: direct segment 0x%x bytes, va=0x%llx desc len=0x%x\n",
len, (unsigned long long)md->va, md->len);
llen = MIN(len, md->len);
if (llen) {
if (req->writing) {
rc = spapr_tce_dma_read(&s->vdev, md->va, buf, llen);
} else {
rc = spapr_tce_dma_write(&s->vdev, md->va, buf, llen);
}
}
md->len -= llen;
md->va += llen;
if (rc) {
return -1;
}
return llen;
}
| 1threat
|
Autofac and Automapper new API - ConfigurationStore is gone : <p>I've been using Automapper and Autofac in a .Net app for some time. I configured them this way:</p>
<pre><code>builder.RegisterAssemblyTypes(typeof (OneOfMyMappingProfiles).Assembly)
.Where(t => t.IsSubclassOf(typeof (Profile)))
.As<Profile>();
builder.Register(ctx => new ConfigurationStore(new TypeMapFactory(), MapperRegistry.Mappers))
.AsImplementedInterfaces()
.SingleInstance()
.OnActivating(x =>
{
foreach (var profile in x.Context.Resolve<IEnumerable<Profile>>())
{
x.Instance.AddProfile(profile);
}
});
builder.RegisterType<MappingEngine>()
.As<IMappingEngine>().SingleInstance();
</code></pre>
<p>With the latest build of Automapper (4.2) the API has changed and I am having trouble translating to the new API. ConfigurationStore no longer seems to exist. According to the docs, the way to register with an IOC is now like this:</p>
<pre><code> var profiles =
from t in typeof (AutoMapperRegistry).Assembly.GetTypes()
where typeof (Profile).IsAssignableFrom(t)
select (Profile)Activator.CreateInstance(t);
var config = new MapperConfiguration(cfg =>
{
foreach (var profile in profiles)
{
cfg.AddProfile(profile);
}
});
For<MapperConfiguration>().Use(config);
For<IMapper>().Use(ctx => ctx.GetInstance<MapperConfiguration>().CreateMapper(ctx.GetInstance));
</code></pre>
<p>BUT that is using StructureMap. The first half of this is no problem, but I am not sure how to translate the "For<>.Use()" portion. How do I do that in Autofac?</p>
| 0debug
|
Django annotate() error AttributeError: 'CharField' object has no attribute 'resolve_expression' : <p>Hello I want to concatenate more fields into django, but even this simple code:</p>
<pre><code> Project.objects.annotate(
companyname=Concat('company__name',Value('ahoj')),output_field=CharField()
)
</code></pre>
<p>Gives me an error:</p>
<pre><code>AttributeError: 'CharField' object has no attribute 'resolve_expression'
</code></pre>
<p>Traceback:</p>
<pre><code> File "/root/MUP/djangoenv/lib/python3.4/site-packages/django/db/models/manager.py", line 122, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/root/MUP/djangoenv/lib/python3.4/site-packages/django/db/models/query.py", line 908, in annotate
clone.query.add_annotation(annotation, alias, is_summary=False)
File "/root/MUP/djangoenv/lib/python3.4/site-packages/django/db/models/sql/query.py", line 986, in add_annotation
annotation = annotation.resolve_expression(self, allow_joins=True, reuse=None,
AttributeError: 'CharField' object has no attribute 'resolve_expression'
</code></pre>
| 0debug
|
tkinter programm opens with cmd : <p>I writed a program with Python 3.5.2 using Tkinter (and IDLE). When I debug it, the window comes up. And the window too, where we can see the Error. But if i don't debug it and open it by double-clicking, the window comes up with cmd. If I close the cmd, my window closes too.</p>
<pre><code>win = Tk()
win.geometry("450x500")
win.title(just a title)
win.wm_iconbitmap(just a path)
win.resizable(False, False)
</code></pre>
<p>How can I fix it? Thanks...</p>
<p>(Sorry for the bad English :) )</p>
| 0debug
|
How to compare classes and interfaces? : <p>Can anybody explain me how to compare KClasse-s and interfaces among yourselves? I known how to check that classes or interfaces are equal but I don't understand how to check that A class is superclass of B class, etc.</p>
<pre><code>interface IB {}
interface IC : IB {}
open class A {}
open class B : A() {}
open class C : B(), IC {}
fun main(args: Array<String>) {
if (B::class == B::class) { println("B class is equal to B class") }
if (IB::class == IB::class) { println("IB interface is equal to IB interface") }
if (A::class ??? B::class) { println("A class is parent of B class") }
if (A::class ??? C::class) { println("A class is superclass of C class") }
if (C::class ??? IC) { println("C class is implement IC interface") }
if (IC ??? IB) { println("IC interface is implement IB interface") }
}
</code></pre>
| 0debug
|
Is it possible to mock accessors by Mockito in Kotlin? : <p>Is it possible to mock getter and setter of the property by Mockito? Something like this:</p>
<pre><code>@Test
fun three() {
val m = mock<Ddd>() {
// on { getQq() }.doReturn("mocked!")
}
assertEquals("mocked!", m.qq)
}
open class Ddd {
var qq : String = "start"
set(value) {
field = value + " by setter"
}
get() {
return field + " by getter"
}
}
</code></pre>
| 0debug
|
MS SQL SERVER MAX function on one column, return all columns : I'm using MS SQL Server and I'm trying to get the MAX of Res when Res is a varchar, and I want to group by pID, but also keep the aID in the final result.
aID | Res | pID
1 | Yes | 94 <br>
2 | Yes | 32 <br>
3 | No | 32 <br>
4 | Yes | 94
SELECT aID, max(Res), pID
FROM Table1
GROUP BY pID
My final result should be:
aID | Res | pID
1 | Yes | 94 <br>
2 | Yes | 32 <br>
or <br>
aID | Res | pID
4 | Yes | 94 <br>
2 | Yes | 32 <br>
The whole issue is that I can't include aID in the final result. I've tried a sub query where Res is = to max(Res), but with over 50,000 records, it's taking over 20 minutes to run this thing. There's got to be a better way. Is there?
| 0debug
|
static unsigned int dec_subu_r(DisasContext *dc)
{
TCGv t0;
int size = memsize_z(dc);
DIS(fprintf (logfile, "subu.%c $r%u, $r%u\n",
memsize_char(size),
dc->op1, dc->op2));
cris_cc_mask(dc, CC_MASK_NZVC);
t0 = tcg_temp_new(TCG_TYPE_TL);
t_gen_zext(t0, cpu_R[dc->op1], size);
cris_alu(dc, CC_OP_SUB,
cpu_R[dc->op2], cpu_R[dc->op2], t0, 4);
tcg_temp_free(t0);
return 2;
}
| 1threat
|
static void do_info_kqemu(Monitor *mon)
{
#ifdef CONFIG_KQEMU
CPUState *env;
int val;
val = 0;
env = mon_get_cpu();
if (!env) {
monitor_printf(mon, "No cpu initialized yet");
return;
}
val = env->kqemu_enabled;
monitor_printf(mon, "kqemu support: ");
switch(val) {
default:
case 0:
monitor_printf(mon, "disabled\n");
break;
case 1:
monitor_printf(mon, "enabled for user code\n");
break;
case 2:
monitor_printf(mon, "enabled for user and kernel code\n");
break;
}
#else
monitor_printf(mon, "kqemu support: not compiled\n");
#endif
}
| 1threat
|
How to use firebase database in chrome extension : <p>I want to use it as part of my content script so that I can fetch data from my firebase database. However, I don't know how I can reference the script that's given in the firebase docs:</p>
<pre><code><script src="https://www.gstatic.com/firebasejs/5.3.0/firebase.js"></script>
</code></pre>
<p>I know that if I was doing it all in the pop up html page, then I could load the script tag, but in the content script, there's no html page other than the content page, so I'm not sure if this is even possible.</p>
| 0debug
|
Save and load model optimizer state : <p>I have a set of fairly complicated models that I am training and I am looking for a way to save and load the model optimizer states. The "trainer models" consist of different combinations of several other "weight models", of which some have shared weights, some have frozen weights depending on the trainer, etc. It is a bit too complicated of an example to share, but in short, I am not able to use <code>model.save('model_file.h5')</code> and <code>keras.models.load_model('model_file.h5')</code> when stopping and starting my training. </p>
<p>Using <code>model.load_weights('weight_file.h5')</code> works fine for testing my model if the training has finished, but if I attempt to continue training the model using this method, the loss does not come even close to returning to its last location. I have read that this is because the optimizer state is not saved using this method which makes sense. However, I need a method for saving and loading the states of the optimizers of my trainer models. It seems as though keras once had a <code>model.optimizer.get_sate()</code> and <code>model.optimizer.set_sate()</code> that would accomplish what I am after, but that does not seem to be the case anymore (at least for the Adam optimizer). Are there any other solutions with the current Keras?</p>
| 0debug
|
int gif_write(ByteIOContext *pb, AVImageInfo *info)
{
gif_image_write_header(pb, info->width, info->height,
(uint32_t *)info->pict.data[1]);
gif_image_write_image(pb, 0, 0, info->width, info->height,
info->pict.data[0], info->pict.linesize[0],
PIX_FMT_PAL8);
put_byte(pb, 0x3b);
put_flush_packet(pb);
return 0;
}
| 1threat
|
Gitlab CI/CD job's log exceeded limit : <p>When I run my job on Gitlab CI/CD, after a while I obtain the following error message:</p>
<pre><code>Job's log exceeded limit of 4194304 bytes.
</code></pre>
<p>How to change this limit?</p>
| 0debug
|
Does not display a data when has a symbol of & : Can someone help me how to show the data ? my problem is when the data has a symbol of & From $_GET to get a data on a href it does not display. when data does not have a symbol of & it displayed the data.
Thanks in advanced :)
| 0debug
|
def count_Rectangles(radius):
rectangles = 0
diameter = 2 * radius
diameterSquare = diameter * diameter
for a in range(1, 2 * radius):
for b in range(1, 2 * radius):
diagnalLengthSquare = (a * a + b * b)
if (diagnalLengthSquare <= diameterSquare) :
rectangles += 1
return rectangles
| 0debug
|
JSON array from jqeury to PHP by ajax : i tried to pass JSON array from jquery to php by ajax
but i can't figure out to get specific object from the json in php
my code:
client side:
var items = [];
items.push({
name: "Test1",
ID: "34",
price: "678"
});
items.push({
name: "Test2",
ID: "34",
price: "678"
});
$.ajax({
url: "http://localhost/SendObjects.php",
type: "POST",
data: JSON.stringify(items),
success: function (data) {
var suc = data;
$('#body').append(suc);
}
});
PHP:
$_POST = file_get_contents('php://input');
echo $_POST
Thanks!
| 0debug
|
SVN pushing changes : <p>I am used to Git and am learning SVN now. In Git you have to add the files, commit the changes, and the push to the repo. In SVN I only found add and commit commands. Does this mean that when you run <code>svn commit</code> the changes are pushed to the server? If not what command do I run to push changes to a repo?</p>
| 0debug
|
void fpu_clear_exceptions(void)
{
struct __attribute__((packed)) {
uint16_t fpuc;
uint16_t dummy1;
uint16_t fpus;
uint16_t dummy2;
uint16_t fptag;
uint16_t dummy3;
uint32_t ignored[4];
long double fpregs[8];
} float_env32;
asm volatile ("fnstenv %0\n" : : "m" (float_env32));
float_env32.fpus &= ~0x7f;
asm volatile ("fldenv %0\n" : : "m" (float_env32));
}
| 1threat
|
int pit_get_gate(PITState *pit, int channel)
{
PITChannelState *s = &pit->channels[channel];
return s->gate;
}
| 1threat
|
Why is android still using Java 8? : <p>Just wondering why Android is very behind the latest versions of Java which the latest release is Java 11.</p>
<p>I understand we have Kotlin now which comes with some great features. But just wondering will Google ever update to the latest version if not, why?</p>
<p>Many thanks in advance </p>
| 0debug
|
int64_t bdrv_get_allocated_file_size(BlockDriverState *bs)
{
BlockDriver *drv = bs->drv;
if (!drv) {
return -ENOMEDIUM;
}
if (drv->bdrv_get_allocated_file_size) {
return drv->bdrv_get_allocated_file_size(bs);
}
if (bs->file) {
return bdrv_get_allocated_file_size(bs->file);
}
return -ENOTSUP;
}
| 1threat
|
Every derived table must have its own alias (sql & php) : <pre><code>SELECT COUNT(*) AS Total FROM (
SELECT *
FROM `list_lazada` WHERE product_name LIKE '%$search%'
UNION All
SELECT *
FROM `list_simulation` WHERE product_name LIKE '%$search%'
)
</code></pre>
<p>running sql
"Every derived table must have its own alias"</p>
<p>please help?</p>
| 0debug
|
What is "Locked ownable synchronizers" in thread dump? : <p>I am trying to understand what does <code>Locked ownable synchronizers</code> refer to in a thread dump?</p>
<p>I started using <a href="https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/locks/ReentrantReadWriteLock.html" rel="noreferrer"><code>ReentrantReadWriteLock</code></a> have a thread in <code>WAITING</code> state, waiting for a <code>ReentrantReadWriteLock$FairSync</code> in the "locked ownable synchronizers" list of another thread in <code>WAITING</code> state (a <code>ThreadPoolExecutor</code>).</p>
<p>I couldn't find much information about that. Is it some kind of locks "passed onto" the thread? I'm trying to figure out where my deadlock comes from and I can't see any thread actively locking those (i.e. no corresponding <code>- locked <0x...></code> in any stack trace).</p>
| 0debug
|
int qed_read_l2_table_sync(BDRVQEDState *s, QEDRequest *request, uint64_t offset)
{
int ret = -EINPROGRESS;
qed_read_l2_table(s, request, offset, qed_sync_cb, &ret);
while (ret == -EINPROGRESS) {
aio_poll(bdrv_get_aio_context(s->bs), true);
}
return ret;
}
| 1threat
|
C++ Derived class constructors : <p>Say i have a class representing the subscribers for a library. I then want to create multiple other derived classes representing different types of subscribers such as students, professors etc.. </p>
<ol>
<li><p>How do i write the derived class constructor ? In my base class Subscriber I have the constructor which takes parameters such as name,age,id number etc..
However in my derived classes I have extra parameters such as "schoolName" for example. How do I setup the constructor for the derived class Student knowing that i want to call the base class constructor of Subscriber and also add a value to an extra parameter that being schoolName. </p></li>
<li><p>Also my second question. Would it be preferable to make the shared parameters such as age,name etc (that both the base class and the derived class share) protected as apposed to private ? That way a student can access his name,age easily </p></li>
</ol>
| 0debug
|
How to hide the element in the mobile version? : I use react js and bootstrap 5. How to hide the element in the mobile version? Let it be md={3}, and xs-hidden?
| 0debug
|
KeyStoreException: Signature/MAC verification failed when trying to decrypt : <p>I am trying to create a simple Kotlin object that wraps access to the app's shared preferences, by encrypting content before saving it.</p>
<p>Encrypting seems to work OK, but when I try to decrypt, I get an javax.crypto.AEADBadTagException, which triggers from a 'android.security.KeyStoreException: Signature/MAC verification failed'.</p>
<p>I have tried debugging to see what's the underlying issue, but I can't find anything. No search has given me any clue, I seem to follow a few guides to the letter without success.</p>
<pre><code>private val context: Context?
get() = this.application?.applicationContext
private var application: Application? = null
private val transformation = "AES/GCM/NoPadding"
private val androidKeyStore = "AndroidKeyStore"
private val ivPrefix = "_iv"
private val keyStore by lazy { this.createKeyStore() }
private fun createKeyStore(): KeyStore {
val keyStore = KeyStore.getInstance(this.androidKeyStore)
keyStore.load(null)
return keyStore
}
private fun createSecretKey(alias: String): SecretKey {
val keyGenerator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, this.androidKeyStore)
keyGenerator.init(
KeyGenParameterSpec.Builder(alias, KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT)
.setBlockModes(KeyProperties.BLOCK_MODE_GCM)
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE)
.build()
)
return keyGenerator.generateKey()
}
private fun getSecretKey(alias: String): SecretKey {
return if (this.keyStore.containsAlias(alias)) {
(this.keyStore.getEntry(alias, null) as KeyStore.SecretKeyEntry).secretKey
} else {
this.createSecretKey(alias)
}
}
private fun removeSecretKey(alias: String) {
this.keyStore.deleteEntry(alias)
}
private fun encryptText(alias: String, textToEncrypt: String): String {
val cipher = Cipher.getInstance(this.transformation)
cipher.init(Cipher.ENCRYPT_MODE, getSecretKey(alias))
val ivString = Base64.encodeToString(cipher.iv, Base64.DEFAULT)
this.storeInSharedPrefs(alias + this.ivPrefix, ivString)
val byteArray = cipher.doFinal(textToEncrypt.toByteArray(charset("UTF-8")))
return String(byteArray)
}
private fun decryptText(alias: String, textToDecrypt: String): String? {
val ivString = this.retrieveFromSharedPrefs(alias + this.ivPrefix) ?: return null
val iv = Base64.decode(ivString, Base64.DEFAULT)
val spec = GCMParameterSpec(iv.count() * 8, iv)
val cipher = Cipher.getInstance(this.transformation)
cipher.init(Cipher.DECRYPT_MODE, getSecretKey(alias), spec)
try {
val byteArray = cipher.doFinal(textToDecrypt.toByteArray(charset("UTF-8")))
return String(byteArray)
} catch (e: Exception) {
e.printStackTrace()
return null
}
}
private fun storeInSharedPrefs(key: String, value: String) {
this.context?.let {
PreferenceManager.getDefaultSharedPreferences(it).edit()?.putString(key, value)?.apply()
}
}
private fun retrieveFromSharedPrefs(key: String): String? {
val validContext = this.context ?: return null
return PreferenceManager.getDefaultSharedPreferences(validContext).getString(key, null)
}
</code></pre>
<p>Can anyone point me in the right direction ?</p>
| 0debug
|
Podio API - C# - Get all Items data for an App or space : <p>We have an app called "Deliverables" in each of the workspaces (there are about 20+ workspaces). Each of these Deliverables have a number of Items under them. What is the best API to use to retrieve,</p>
<ol>
<li>All the deliverables from all the workspaces</li>
<li>All the items under all deliverables, from all the workspaces</li>
</ol>
<p>Thanks</p>
| 0debug
|
how can i fix this erroe in visual studio? : Additional information: Could not load file or assembly 'file:///C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI [enter image description here][1]
[1]: https://i.stack.imgur.com/xjcsR.jpg
| 0debug
|
static void test_endianness_combine(gconstpointer data)
{
const TestCase *test = data;
char *args;
args = g_strdup_printf("-display none -M %s%s%s -device pc-testdev",
test->machine,
test->superio ? " -device " : "",
test->superio ?: "");
qtest_start(args);
isa_outl(test, 0xe0, 0x87654321);
g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x87654321);
g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8765);
g_assert_cmphex(isa_inw(test, 0xe8), ==, 0x4321);
isa_outw(test, 0xe2, 0x8866);
g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x88664321);
g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8866);
g_assert_cmphex(isa_inw(test, 0xe8), ==, 0x4321);
isa_outw(test, 0xe0, 0x4422);
g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x88664422);
g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8866);
g_assert_cmphex(isa_inw(test, 0xe8), ==, 0x4422);
isa_outb(test, 0xe3, 0x87);
g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x87664422);
g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8766);
isa_outb(test, 0xe2, 0x65);
g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x87654422);
g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8765);
g_assert_cmphex(isa_inw(test, 0xe8), ==, 0x4422);
isa_outb(test, 0xe1, 0x43);
g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x87654322);
g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8765);
g_assert_cmphex(isa_inw(test, 0xe8), ==, 0x4322);
isa_outb(test, 0xe0, 0x21);
g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x87654321);
g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8765);
g_assert_cmphex(isa_inw(test, 0xe8), ==, 0x4321);
qtest_quit(global_qtest);
g_free(args);
}
| 1threat
|
Angular 5+ : How to put a delay to a / all HttpClient requests? : <p>I have this code :</p>
<pre><code>this.loading = true;
this.http.get<IUser[]>(Urls.users())
.subscribe(
response => {
this._values = <IUser[]>response;
this.root.next({'users': this._values});
},
e => console.log(e),
() => this.loading = false
);
</code></pre>
<p>The page which is invoking this code has a spinner, which is showing when 'loading' is set to 'true'. But when the request is completed withing 0.5 seconds the spinner is barely shown, and it looks weird on the page.</p>
<p>How can I make this request wait 1 second before completing (without using setTimeout()) ?</p>
<p>Is there a way to delay all http requests without having to modify every code like the code above ?</p>
| 0debug
|
I want to call some method as soon as my textbox length rich at 6 postion in swift : i want to perform some action when my textbox string count become 6 in swift is it possible in swift.if yes then give me some idea about it.
| 0debug
|
Pandas apply a func into a whole dataframe : I have a data frame, I want to apply `func=lambda x: max(x)-min(x)`
into the table below.
a b c
Utah 0.907184 0.000049 0.550308
NY 0.129423 1.606726 2.041340
DC 0.228202 1.041567 0.007727
Texas 0.947254 0.000211 0.346336
if I do `df.apply(func)` it'll return, calcuated in the axis:
`a -0.613516
b -1.260598
c -1.340853
dtype: float64 `
I want to take the max of all 12 data, and minus min of all 12 data,
return a dataframe of 4x3.
| 0debug
|
Attempted insert node leads to infinite linked list : <p>I am trying to insert a node into a linked list after it finds a name in the list.
My problem is that when i print out the linked list it prints the nodes up to and including the node containing the name but then outputs infinitely the node I inserted. Any help would be greatly appreciated. Thanks!</p>
<p>(some extra information),(the pointer student is pointing to a dynamically created node already). :)</p>
<pre><code>bool StudentLinkedList::insertStudentAfter(StudentNode* student, string _name)
{
StudentNode* curr = headP;
StudentNode* prev = headP;
while (curr != NULL)
{
if (curr->getName() == _name)
{
StudentNode* dummy = curr -> getnext();
curr->setNext(student);
prev = prev->getnext();
curr=curr ->getnext();
curr->setNext(dummy);
prev = curr;
curr = curr->getnext();
length++;
return true;
}
prev = curr;
curr = curr->getnext();
}
return false;
</code></pre>
<p>}</p>
| 0debug
|
How can I have a single dictionary out of a dictionary within a dictionary with some different and similar keys : I have a dictionary having two key values, and each key refers to a value that is a dictionary itself. Now my concern is to extract the key values of the values regardless of their first key. And these two values have keys that are same as well as different.
I need to get a single dictionary where the different keys remains same, while the keys that are same in both dictionary , so there value updates i.e they add up.
with open('report.json') as json_file:
data = json.load(json_file)
(data['behavior']['apistats'])
{'2740': {'NtDuplicateObject': 2, 'NtOpenSection': 1, 'GetSystemWindowsDirectoryW': 23, 'NtQueryValueKey': 32,'NtClose': 427,'NtOpenMutant': 2, 'RegCloseKey': 8, }, '3908': {'RegCreateKeyExW': 2, 'GetNativeSystemInfo': 1, 'NtOpenSection': 1, 'CoUninitialize': 6, 'RegCloseKey': 27, 'GetSystemInfo': 1, 'CreateToolhelp32Snapshot': 180, 'UnhookWindowsHookEx': 2, 'GetSystemWindowsDirectoryW': 6, 'NtQueryValueKey': 6,'NtClose': 427}}
The output I get but I need a single dictionary where the same apis value adds up as a new value and the keys dont repeat, regardless of parent keys '2740' and '3908'.
| 0debug
|
Python printing from array's : I've got 3 different array's, all the data inside is coming from a external csv file which works although how do i print each name with each number next to them
name = []
number1 = []
number2 = []
for example expected output is, although I'm unsure how i would do this
LOOP (12) as there is 12 names and numbers in each array
Test, 5, 20
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.