problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
set_interrupt_cause(E1000State *s, int index, uint32_t val)
{
if (val)
val |= E1000_ICR_INT_ASSERTED;
s->mac_reg[ICR] = val;
s->mac_reg[ICS] = val;
qemu_set_irq(s->dev.irq[0], (s->mac_reg[IMS] & s->mac_reg[ICR]) != 0);
}
| 1threat |
Overriding methods in Collection<T> : <p>I am working on a class assignment where I have a collection and it will be filtered out. For example, the filter class, which is an interface is one method (matches) which takes in T element. </p>
<p>In my FilterCollection class:</p>
<pre><code>public class FilteredCollection<T> extends AbstractCollectionDecorator<T> {
Collection<T> filterCollection;
Filter<T> currentFilter;
private FilteredCollection(Collection<T> coll, Filter<T> filter) {
super(coll);
this.filterCollection = coll;
this.currentFilter = filter;
}
public static <T> FilteredCollection<T> decorate(Collection<T> coll, Filter<T> filter) {
return new FilteredCollection<T>(coll, filter);
}
</code></pre>
<p>From there I have to override methods, such as add, addall, contains, remove, etc.</p>
<p>With the add() method</p>
<pre><code>@Override
public boolean add(T object)
{
return filterCollection.add(object);
}
</code></pre>
<p>However, I need to see if the object matches whats in the filter and if it does, dont add it, if it doesnt, add it. What is the proper way to go about this?</p>
| 0debug |
How can i convert double? to double. Math.Sqrt operations : <p>i would like to ask for some help to this code right below this question... i am encountering some error that says "Argument 1: cannot convert double? to double". How can i fix this what should i add?</p>
<pre><code>private void Calculate(string newOperator = null)
{
double? result = null;
double? first = numbers[0] == null ? null : (double?)double.Parse(numbers[0]);
double? second = numbers[1] == null ? null : (double?)double.Parse(numbers[1]);
switch (@operator)
{
case "÷":
result = first / second;
break;
case "×":
result = first * second;
break;
case "+":
result = first + second;
break;
case "-":
result = first - second;
break;
case "√":
result = Math.Sqrt(first);
break;
case "SIN":
result = Math.Sin(first);
break;
case "COS":
result = Math.Cos(first);
break;
case "TAN":
result = Math.Tan(first);
break;
}
</code></pre>
| 0debug |
static void intra_predict_hor_dc_8x8_msa(uint8_t *src, int32_t stride)
{
uint8_t lp_cnt;
uint32_t src0 = 0, src1 = 0;
uint64_t out0, out1;
for (lp_cnt = 0; lp_cnt < 4; lp_cnt++) {
src0 += src[lp_cnt * stride - 1];
src1 += src[(4 + lp_cnt) * stride - 1];
}
src0 = (src0 + 2) >> 2;
src1 = (src1 + 2) >> 2;
out0 = src0 * 0x0101010101010101;
out1 = src1 * 0x0101010101010101;
for (lp_cnt = 4; lp_cnt--;) {
SD(out0, src);
SD(out1, (src + 4 * stride));
src += stride;
}
}
| 1threat |
How can I change color of $variables on my php codes in Sublime Text 3? : [As you can see it the color is only white, I want to change it to something unique color, I've already tried searching for solution but no luck.][1]
[1]: https://i.stack.imgur.com/chRYm.jpg | 0debug |
menu notification auto refresh issue : this code i use to show menu and its notification, but my prob is new msg notification not come before pare reload, i want to auto reload this part to show new msg notification
<li>
<a href="#" onclick="initChat(0); return false;">
<i class="linea linea-basic-message-txt"></i>
<span><?=$system->translate('Messages')?></span>
<?=$my_user->NotificationCount('messages')?>
</a>
</li> | 0debug |
(Java) How do you generate a random integer between 1 to 4 using SecureRandom : <p>An assignment I'm working on right now needs to generate a random number from 1 to 4 using SecureRandom that will be used for a switch statement. Cases have to start from 1 so I can't just use</p>
<pre><code>SecureRandom rand = new SecureRandom();
int a;
a = rand.nextInt(4);
</code></pre>
<p>right?
I have to use SecureRandom to generate the integer as well.</p>
| 0debug |
i have created a polynomial regression model to predict some values for a variable which have 500 rows : ## Heading ##
there are around 500 values "planned" and on the basis of this i have to predict new values which "actual". kindly help me with the coding ,
here i'm showing that how i am doing it manually
`predict(poly_reg, data.frame(planned= 48.80000,
Level2 = 48.80000^2,
Level3 = 48.80000^3))` | 0debug |
i want to write a php script to find if a given number is prime or not : <p>I have tried to create a code which is</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><html>
<body>
<form method = "post">
<?php
Number : <input type = "text" name = "prime">;
<input type = "submit" value ="Submit">;
$num = $_REQUEST["prime"];
$flag = 0;
for($i = 2; $i <= $num/2; $i++)
{
if( $num % $i == 0)
{
$flag = 1;
break;
}
}
if($flag == 0)
echo "$num is a prime number";
else
echo "$num is not a prime number";
?>
</form>
</body>
</html></code></pre>
</div>
</div>
</p>
<p>Whenever i try to run it, i get the error
<strong>Parse error: syntax error, unexpected '<', expecting end of file in
C:\xampp\htdocs\pc.php on line 5</strong></p>
<p>Any help would be appreciated </p>
| 0debug |
If statement inside a if statement c# : This is the code that i have written to print when a user enters a number, when a user press 1, the console prints the alocated if statement thing. How to put work this code? (this is a c# console application)
int keypress; // Variable to hold number
ConsoleKeyInfo UserInput = Console.ReadKey(); // Get user input
// We check input for a Digit
if (char.IsDigit(UserInput.KeyChar))
{
keypress = int.Parse(UserInput.KeyChar.ToString()); // use Parse if it's a Digit
if (keypress = 1)
{
Console.WriteLine("6$ Cheese added to your cart");
}
else (keypress = 2){
Console.WriteLine("2$ Bread added to your cart");
}
else (keypress = 3){
Console.WriteLine("1$ cookie added to your cart");
}
}
else
{
keypress = -1; // Else we assign a default value
Console.WriteLine("Number you entered isn't in the grocery list, please retry");
} | 0debug |
Variable not showing up Java Servlets : <p>I tried to make a simple Java Servlet app, that displays the date and time.
The problem is: it won't show up when I load the page(the page itself does show up). I have debugged it, and the date and time does show up in the console.</p>
<p>TestServlet.java(not the whole file):</p>
<pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
DateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date timeDate = new Date();
@SuppressWarnings("unused")
String time = format.format(timeDate);
request.getRequestDispatcher("/WEB-INF/test.jsp").forward(request, response);
}
</code></pre>
<p>test.jsp(whole file):</p>
<pre><code><%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>Welcome! It is ${time}!</h1>
</body>
</html>
</code></pre>
<p>All help is welcome ;)</p>
| 0debug |
uint32_t HELPER(mvcl)(CPUS390XState *env, uint32_t r1, uint32_t r2)
{
uintptr_t ra = GETPC();
uint64_t destlen = env->regs[r1 + 1] & 0xffffff;
uint64_t dest = get_address(env, r1);
uint64_t srclen = env->regs[r2 + 1] & 0xffffff;
uint64_t src = get_address(env, r2);
uint8_t pad = env->regs[r2 + 1] >> 24;
uint8_t v;
uint32_t cc;
if (destlen == srclen) {
cc = 0;
} else if (destlen < srclen) {
cc = 1;
} else {
cc = 2;
}
if (srclen > destlen) {
srclen = destlen;
}
for (; destlen && srclen; src++, dest++, destlen--, srclen--) {
v = cpu_ldub_data_ra(env, src, ra);
cpu_stb_data_ra(env, dest, v, ra);
}
for (; destlen; dest++, destlen--) {
cpu_stb_data_ra(env, dest, pad, ra);
}
env->regs[r1 + 1] = destlen;
env->regs[r2 + 1] -= src - env->regs[r2];
set_address(env, r1, dest);
set_address(env, r2, src);
return cc;
}
| 1threat |
Running R scripts in Airflow? : <p>Is it possible to run an R script as an airflow dag? I have tried looking online for documentation on this and am unable to do so. Thanks</p>
| 0debug |
Jquery Second On/Off : <p>I use jQuery. What I want to do is click on the img element and put the function in a passive state. After 2 seconds, the click function is activated. I used Delay and SetTimeout, but did not. Could you help?</p>
| 0debug |
static int img_read_header(AVFormatContext *s1)
{
VideoDemuxData *s = s1->priv_data;
int first_index, last_index;
AVStream *st;
enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE;
s1->ctx_flags |= AVFMTCTX_NOHEADER;
st = avformat_new_stream(s1, NULL);
if (!st) {
return AVERROR(ENOMEM);
}
if (s->pixel_format &&
(pix_fmt = av_get_pix_fmt(s->pixel_format)) == AV_PIX_FMT_NONE) {
av_log(s1, AV_LOG_ERROR, "No such pixel format: %s.\n",
s->pixel_format);
return AVERROR(EINVAL);
}
av_strlcpy(s->path, s1->filename, sizeof(s->path));
s->img_number = 0;
s->img_count = 0;
if (s1->iformat->flags & AVFMT_NOFILE)
s->is_pipe = 0;
else {
s->is_pipe = 1;
st->need_parsing = AVSTREAM_PARSE_FULL;
}
if (s->ts_from_file)
avpriv_set_pts_info(st, 60, 1, 1);
else
avpriv_set_pts_info(st, 60, s->framerate.den, s->framerate.num);
if (s->width && s->height) {
st->codec->width = s->width;
st->codec->height = s->height;
}
if (!s->is_pipe) {
if (s->pattern_type == PT_GLOB_SEQUENCE) {
s->use_glob = is_glob(s->path);
if (s->use_glob) {
char *p = s->path, *q, *dup;
int gerr;
av_log(s1, AV_LOG_WARNING, "Pattern type 'glob_sequence' is deprecated: "
"use pattern_type 'glob' instead\n");
#if HAVE_GLOB
dup = q = av_strdup(p);
while (*q) {
if ((p - s->path) >= (sizeof(s->path) - 2))
break;
if (*q == '%' && strspn(q + 1, "%*?[]{}"))
++q;
else if (strspn(q, "\\*?[]{}"))
*p++ = '\\';
*p++ = *q++;
}
*p = 0;
av_free(dup);
gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate);
if (gerr != 0) {
return AVERROR(ENOENT);
}
first_index = 0;
last_index = s->globstate.gl_pathc - 1;
#endif
}
}
if ((s->pattern_type == PT_GLOB_SEQUENCE && !s->use_glob) || s->pattern_type == PT_SEQUENCE) {
if (find_image_range(&first_index, &last_index, s->path,
s->start_number, s->start_number_range) < 0) {
av_log(s1, AV_LOG_ERROR,
"Could find no file with with path '%s' and index in the range %d-%d\n",
s->path, s->start_number, s->start_number + s->start_number_range - 1);
return AVERROR(ENOENT);
}
} else if (s->pattern_type == PT_GLOB) {
#if HAVE_GLOB
int gerr;
gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate);
if (gerr != 0) {
return AVERROR(ENOENT);
}
first_index = 0;
last_index = s->globstate.gl_pathc - 1;
s->use_glob = 1;
#else
av_log(s1, AV_LOG_ERROR,
"Pattern type 'glob' was selected but globbing "
"is not supported by this libavformat build\n");
return AVERROR(ENOSYS);
#endif
} else if (s->pattern_type != PT_GLOB_SEQUENCE) {
av_log(s1, AV_LOG_ERROR,
"Unknown value '%d' for pattern_type option\n", s->pattern_type);
return AVERROR(EINVAL);
}
s->img_first = first_index;
s->img_last = last_index;
s->img_number = first_index;
st->start_time = 0;
st->duration = last_index - first_index + 1;
}
if (s1->video_codec_id) {
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = s1->video_codec_id;
} else if (s1->audio_codec_id) {
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = s1->audio_codec_id;
} else {
const char *str = strrchr(s->path, '.');
s->split_planes = str && !av_strcasecmp(str + 1, "y");
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = ff_guess_image2_codec(s->path);
if (st->codec->codec_id == AV_CODEC_ID_LJPEG)
st->codec->codec_id = AV_CODEC_ID_MJPEG;
}
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
pix_fmt != AV_PIX_FMT_NONE)
st->codec->pix_fmt = pix_fmt;
return 0;
}
| 1threat |
Dropdown box as seen in webpage below : <p>first time posting here so apologies if I break some rules (though I believe I have read them thoroughly).</p>
<p>I am trying to add a DOB field for a form on my webpage. I have come across a <a href="http://www.eyecon.ro/bootstrap-datepicker/#" rel="nofollow noreferrer">website</a> with an example that seems perfect though the website doesn't really give a tutorial on how to get it to look and work exactly like it.
The example in question is the "As component." one where the text cannot be edited but the calendar button is available, though I also like the one above but would prefer the format to be DD/MM/YY.</p>
<p>Any help would be amazing and greatly appreciated. Thank you.</p>
<p>- Josh</p>
| 0debug |
Need to Convert Json to Dataframw in Scala : Here is the Json that needs to be converted
```
{
"name": "Jon",
"tags":[
{
"1": "San Jose",
"2": "California",
"3": 1987
},
{
"1": "University Ave",
"2": "Princeton",
"3": 1990
}
]
}
```
It needs to be converted into a dataframe say
```
Name 1 2 3
Jon SanJose California 1987
Jon Univesity Ave Princeton 1990
```
Can anyone help me getting this riddle done. Thank you!! | 0debug |
How does the Program works and Executes - Java : class Average
{
public static void main(String args[])
{
double nums[] = {10.1, 11.2, 12.3, 13.4, 14.5};
// Assigning some values to the Array
double result = 0;
int i;
for(i=0; i<5; i++)
result = result + nums[i];
System.out.println("Average is " + result / 5);
}
}
How this Program Works . i have no idea about this. Can anyone explain me ? | 0debug |
int ff_dca_lbr_parse(DCALbrDecoder *s, uint8_t *data, DCAExssAsset *asset)
{
struct {
LBRChunk lfe;
LBRChunk tonal;
LBRChunk tonal_grp[5];
LBRChunk grid1[DCA_LBR_CHANNELS / 2];
LBRChunk hr_grid[DCA_LBR_CHANNELS / 2];
LBRChunk ts1[DCA_LBR_CHANNELS / 2];
LBRChunk ts2[DCA_LBR_CHANNELS / 2];
} chunk = { 0 };
GetByteContext gb;
int i, ch, sb, sf, ret, group, chunk_id, chunk_len;
bytestream2_init(&gb, data + asset->lbr_offset, asset->lbr_size);
if (bytestream2_get_be32(&gb) != DCA_SYNCWORD_LBR) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid LBR sync word\n");
return AVERROR_INVALIDDATA;
}
switch (bytestream2_get_byte(&gb)) {
case LBR_HEADER_SYNC_ONLY:
if (!s->sample_rate) {
av_log(s->avctx, AV_LOG_ERROR, "LBR decoder not initialized\n");
return AVERROR_INVALIDDATA;
}
break;
case LBR_HEADER_DECODER_INIT:
if ((ret = parse_decoder_init(s, &gb)) < 0) {
s->sample_rate = 0;
return ret;
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Invalid LBR header type\n");
return AVERROR_INVALIDDATA;
}
chunk_id = bytestream2_get_byte(&gb);
chunk_len = (chunk_id & 0x80) ? bytestream2_get_be16(&gb) : bytestream2_get_byte(&gb);
if (chunk_len > bytestream2_get_bytes_left(&gb)) {
chunk_len = bytestream2_get_bytes_left(&gb);
av_log(s->avctx, AV_LOG_WARNING, "LBR frame chunk was truncated\n");
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
bytestream2_init(&gb, gb.buffer, chunk_len);
switch (chunk_id & 0x7f) {
case LBR_CHUNK_FRAME:
if (s->avctx->err_recognition & (AV_EF_CRCCHECK | AV_EF_CAREFUL)) {
int checksum = bytestream2_get_be16(&gb);
uint16_t res = chunk_id;
res += (chunk_len >> 8) & 0xff;
res += chunk_len & 0xff;
for (i = 0; i < chunk_len - 2; i++)
res += gb.buffer[i];
if (checksum != res) {
av_log(s->avctx, AV_LOG_WARNING, "Invalid LBR checksum\n");
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
} else {
bytestream2_skip(&gb, 2);
}
break;
case LBR_CHUNK_FRAME_NO_CSUM:
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Invalid LBR frame chunk ID\n");
return AVERROR_INVALIDDATA;
}
memset(s->quant_levels, 0, sizeof(s->quant_levels));
memset(s->sb_indices, 0xff, sizeof(s->sb_indices));
memset(s->sec_ch_sbms, 0, sizeof(s->sec_ch_sbms));
memset(s->sec_ch_lrms, 0, sizeof(s->sec_ch_lrms));
memset(s->ch_pres, 0, sizeof(s->ch_pres));
memset(s->grid_1_scf, 0, sizeof(s->grid_1_scf));
memset(s->grid_2_scf, 0, sizeof(s->grid_2_scf));
memset(s->grid_3_avg, 0, sizeof(s->grid_3_avg));
memset(s->grid_3_scf, 0, sizeof(s->grid_3_scf));
memset(s->grid_3_pres, 0, sizeof(s->grid_3_pres));
memset(s->tonal_scf, 0, sizeof(s->tonal_scf));
memset(s->lfe_data, 0, sizeof(s->lfe_data));
s->part_stereo_pres = 0;
s->framenum = (s->framenum + 1) & 31;
for (ch = 0; ch < s->nchannels; ch++) {
for (sb = 0; sb < s->nsubbands / 4; sb++) {
s->part_stereo[ch][sb][0] = s->part_stereo[ch][sb][4];
s->part_stereo[ch][sb][4] = 16;
}
}
memset(s->lpc_coeff[s->framenum & 1], 0, sizeof(s->lpc_coeff[0]));
for (group = 0; group < 5; group++) {
for (sf = 0; sf < 1 << group; sf++) {
int sf_idx = ((s->framenum << group) + sf) & 31;
s->tonal_bounds[group][sf_idx][0] =
s->tonal_bounds[group][sf_idx][1] = s->ntones;
}
}
while (bytestream2_get_bytes_left(&gb) > 0) {
chunk_id = bytestream2_get_byte(&gb);
chunk_len = (chunk_id & 0x80) ? bytestream2_get_be16(&gb) : bytestream2_get_byte(&gb);
chunk_id &= 0x7f;
if (chunk_len > bytestream2_get_bytes_left(&gb)) {
chunk_len = bytestream2_get_bytes_left(&gb);
av_log(s->avctx, AV_LOG_WARNING, "LBR chunk %#x was truncated\n", chunk_id);
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
switch (chunk_id) {
case LBR_CHUNK_LFE:
chunk.lfe.len = chunk_len;
chunk.lfe.data = gb.buffer;
break;
case LBR_CHUNK_SCF:
case LBR_CHUNK_TONAL:
case LBR_CHUNK_TONAL_SCF:
chunk.tonal.id = chunk_id;
chunk.tonal.len = chunk_len;
chunk.tonal.data = gb.buffer;
break;
case LBR_CHUNK_TONAL_GRP_1:
case LBR_CHUNK_TONAL_GRP_2:
case LBR_CHUNK_TONAL_GRP_3:
case LBR_CHUNK_TONAL_GRP_4:
case LBR_CHUNK_TONAL_GRP_5:
i = LBR_CHUNK_TONAL_GRP_5 - chunk_id;
chunk.tonal_grp[i].id = i;
chunk.tonal_grp[i].len = chunk_len;
chunk.tonal_grp[i].data = gb.buffer;
break;
case LBR_CHUNK_TONAL_SCF_GRP_1:
case LBR_CHUNK_TONAL_SCF_GRP_2:
case LBR_CHUNK_TONAL_SCF_GRP_3:
case LBR_CHUNK_TONAL_SCF_GRP_4:
case LBR_CHUNK_TONAL_SCF_GRP_5:
i = LBR_CHUNK_TONAL_SCF_GRP_5 - chunk_id;
chunk.tonal_grp[i].id = i;
chunk.tonal_grp[i].len = chunk_len;
chunk.tonal_grp[i].data = gb.buffer;
break;
case LBR_CHUNK_RES_GRID_LR:
case LBR_CHUNK_RES_GRID_LR + 1:
case LBR_CHUNK_RES_GRID_LR + 2:
i = chunk_id - LBR_CHUNK_RES_GRID_LR;
chunk.grid1[i].len = chunk_len;
chunk.grid1[i].data = gb.buffer;
break;
case LBR_CHUNK_RES_GRID_HR:
case LBR_CHUNK_RES_GRID_HR + 1:
case LBR_CHUNK_RES_GRID_HR + 2:
i = chunk_id - LBR_CHUNK_RES_GRID_HR;
chunk.hr_grid[i].len = chunk_len;
chunk.hr_grid[i].data = gb.buffer;
break;
case LBR_CHUNK_RES_TS_1:
case LBR_CHUNK_RES_TS_1 + 1:
case LBR_CHUNK_RES_TS_1 + 2:
i = chunk_id - LBR_CHUNK_RES_TS_1;
chunk.ts1[i].len = chunk_len;
chunk.ts1[i].data = gb.buffer;
break;
case LBR_CHUNK_RES_TS_2:
case LBR_CHUNK_RES_TS_2 + 1:
case LBR_CHUNK_RES_TS_2 + 2:
i = chunk_id - LBR_CHUNK_RES_TS_2;
chunk.ts2[i].len = chunk_len;
chunk.ts2[i].data = gb.buffer;
break;
}
bytestream2_skip(&gb, chunk_len);
}
ret = parse_lfe_chunk(s, &chunk.lfe);
ret |= parse_tonal_chunk(s, &chunk.tonal);
for (i = 0; i < 5; i++)
ret |= parse_tonal_group(s, &chunk.tonal_grp[i]);
for (i = 0; i < (s->nchannels + 1) / 2; i++) {
int ch1 = i * 2;
int ch2 = FFMIN(ch1 + 1, s->nchannels - 1);
if (parse_grid_1_chunk (s, &chunk.grid1 [i], ch1, ch2) < 0 ||
parse_high_res_grid(s, &chunk.hr_grid[i], ch1, ch2) < 0) {
ret = -1;
continue;
}
if (!chunk.grid1[i].len || !chunk.hr_grid[i].len || !chunk.ts1[i].len)
continue;
if (parse_ts1_chunk(s, &chunk.ts1[i], ch1, ch2) < 0 ||
parse_ts2_chunk(s, &chunk.ts2[i], ch1, ch2) < 0) {
ret = -1;
continue;
}
}
if (ret < 0 && (s->avctx->err_recognition & AV_EF_EXPLODE))
return AVERROR_INVALIDDATA;
return 0;
}
| 1threat |
vcard_emul_options(const char *args)
{
int reader_count = 0;
VCardEmulOptions *opts;
memcpy(&options, &default_options, sizeof(options));
opts = &options;
do {
args = strip(args);
if (*args == ',') {
continue;
}
if (strncmp(args, "soft=", 5) == 0) {
const char *name;
size_t name_length;
const char *vname;
size_t vname_length;
const char *type_params;
size_t type_params_length;
char type_str[100];
VCardEmulType type;
int count, i;
VirtualReaderOptions *vreaderOpt = NULL;
args = strip(args + 5);
if (*args != '(') {
continue;
}
args = strip(args+1);
NEXT_TOKEN(name)
NEXT_TOKEN(vname)
NEXT_TOKEN(type_params)
type_params_length = MIN(type_params_length, sizeof(type_str)-1);
memcpy(type_str, type_params, type_params_length);
type_str[type_params_length] = '\0';
type = vcard_emul_type_from_string(type_str);
NEXT_TOKEN(type_params)
if (*args == 0) {
break;
}
if (opts->vreader_count >= reader_count) {
reader_count += READER_STEP;
vreaderOpt = g_renew(VirtualReaderOptions, opts->vreader,
reader_count);
}
opts->vreader = vreaderOpt;
vreaderOpt = &vreaderOpt[opts->vreader_count];
vreaderOpt->name = g_strndup(name, name_length);
vreaderOpt->vname = g_strndup(vname, vname_length);
vreaderOpt->card_type = type;
vreaderOpt->type_params =
g_strndup(type_params, type_params_length);
count = count_tokens(args, ',', ')') + 1;
vreaderOpt->cert_count = count;
vreaderOpt->cert_name = g_new(char *, count);
for (i = 0; i < count; i++) {
const char *cert = args;
args = strpbrk(args, ",)");
vreaderOpt->cert_name[i] = g_strndup(cert, args - cert);
args = strip(args+1);
}
if (*args == ')') {
args++;
}
opts->vreader_count++;
} else if (strncmp(args, "use_hw=", 7) == 0) {
args = strip(args+7);
if (*args == '0' || *args == 'N' || *args == 'n' || *args == 'F') {
opts->use_hw = PR_FALSE;
} else {
opts->use_hw = PR_TRUE;
}
args = find_blank(args);
} else if (strncmp(args, "hw_type=", 8) == 0) {
args = strip(args+8);
opts->hw_card_type = vcard_emul_type_from_string(args);
args = find_blank(args);
} else if (strncmp(args, "hw_params=", 10) == 0) {
const char *params;
args = strip(args+10);
params = args;
args = find_blank(args);
opts->hw_type_params = g_strndup(params, args-params);
} else if (strncmp(args, "db=", 3) == 0) {
const char *db;
args = strip(args+3);
if (*args != '"') {
continue;
}
args++;
db = args;
args = strpbrk(args, "\"\n");
opts->nss_db = g_strndup(db, args-db);
if (*args != 0) {
args++;
}
} else {
args = find_blank(args);
}
} while (*args != 0);
return opts;
}
| 1threat |
int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MJpegDecodeContext *s = avctx->priv_data;
const uint8_t *buf_end, *buf_ptr;
const uint8_t *unescaped_buf_ptr;
int unescaped_buf_size;
int start_code;
int i, index;
int ret = 0;
AVFrame *picture = data;
s->got_picture = 0;
buf_ptr = buf;
buf_end = buf + buf_size;
while (buf_ptr < buf_end) {
start_code = ff_mjpeg_find_marker(s, &buf_ptr, buf_end,
&unescaped_buf_ptr,
&unescaped_buf_size);
if (start_code < 0) {
goto the_end;
} else if (unescaped_buf_size > (1U<<29)) {
av_log(avctx, AV_LOG_ERROR, "MJPEG packet 0x%x too big (0x%x/0x%x), corrupt data?\n",
start_code, unescaped_buf_size, buf_size);
return AVERROR_INVALIDDATA;
} else {
av_log(avctx, AV_LOG_DEBUG, "marker=%x avail_size_in_buf=%td\n",
start_code, buf_end - buf_ptr);
init_get_bits(&s->gb, unescaped_buf_ptr, unescaped_buf_size * 8);
s->start_code = start_code;
if (s->avctx->debug & FF_DEBUG_STARTCODE)
av_log(avctx, AV_LOG_DEBUG, "startcode: %X\n", start_code);
if (start_code >= 0xd0 && start_code <= 0xd7)
av_log(avctx, AV_LOG_DEBUG,
"restart marker: %d\n", start_code & 0x0f);
else if (start_code >= APP0 && start_code <= APP15)
mjpeg_decode_app(s);
else if (start_code == COM)
mjpeg_decode_com(s);
switch (start_code) {
case SOI:
s->restart_interval = 0;
s->restart_count = 0;
break;
case DQT:
ff_mjpeg_decode_dqt(s);
break;
case DHT:
if ((ret = ff_mjpeg_decode_dht(s)) < 0) {
av_log(avctx, AV_LOG_ERROR, "huffman table decode error\n");
return ret;
}
break;
case SOF0:
case SOF1:
s->lossless = 0;
s->ls = 0;
s->progressive = 0;
if ((ret = ff_mjpeg_decode_sof(s)) < 0)
return ret;
break;
case SOF2:
s->lossless = 0;
s->ls = 0;
s->progressive = 1;
if ((ret = ff_mjpeg_decode_sof(s)) < 0)
return ret;
break;
case SOF3:
s->lossless = 1;
s->ls = 0;
s->progressive = 0;
if ((ret = ff_mjpeg_decode_sof(s)) < 0)
return ret;
break;
case SOF48:
s->lossless = 1;
s->ls = 1;
s->progressive = 0;
if ((ret = ff_mjpeg_decode_sof(s)) < 0)
return ret;
break;
case LSE:
if (!CONFIG_JPEGLS_DECODER ||
(ret = ff_jpegls_decode_lse(s)) < 0)
return ret;
break;
case EOI:
eoi_parser:
s->cur_scan = 0;
if (!s->got_picture) {
av_log(avctx, AV_LOG_WARNING,
"Found EOI before any SOF, ignoring\n");
break;
}
if (s->interlaced) {
s->bottom_field ^= 1;
if (s->bottom_field == !s->interlace_polarity)
break;
}
*picture = *s->picture_ptr;
*data_size = sizeof(AVFrame);
if (!s->lossless) {
picture->quality = FFMAX3(s->qscale[0],
s->qscale[1],
s->qscale[2]);
picture->qstride = 0;
picture->qscale_table = s->qscale_table;
memset(picture->qscale_table, picture->quality,
(s->width + 15) / 16);
if (avctx->debug & FF_DEBUG_QP)
av_log(avctx, AV_LOG_DEBUG,
"QP: %d\n", picture->quality);
picture->quality *= FF_QP2LAMBDA;
}
goto the_end;
case SOS:
if ((ret = ff_mjpeg_decode_sos(s, NULL, NULL)) < 0 &&
(avctx->err_recognition & AV_EF_EXPLODE))
return ret;
break;
case DRI:
mjpeg_decode_dri(s);
break;
case SOF5:
case SOF6:
case SOF7:
case SOF9:
case SOF10:
case SOF11:
case SOF13:
case SOF14:
case SOF15:
case JPG:
av_log(avctx, AV_LOG_ERROR,
"mjpeg: unsupported coding type (%x)\n", start_code);
break;
}
buf_ptr += (get_bits_count(&s->gb) + 7) / 8;
av_log(avctx, AV_LOG_DEBUG,
"marker parser used %d bytes (%d bits)\n",
(get_bits_count(&s->gb) + 7) / 8, get_bits_count(&s->gb));
}
}
if (s->got_picture) {
av_log(avctx, AV_LOG_WARNING, "EOI missing, emulating\n");
goto eoi_parser;
}
av_log(avctx, AV_LOG_FATAL, "No JPEG data found in image\n");
return AVERROR_INVALIDDATA;
the_end:
if (s->upscale_h) {
uint8_t *line = s->picture_ptr->data[s->upscale_h];
av_assert0(avctx->pix_fmt == AV_PIX_FMT_YUVJ444P ||
avctx->pix_fmt == AV_PIX_FMT_YUV444P ||
avctx->pix_fmt == AV_PIX_FMT_YUVJ440P ||
avctx->pix_fmt == AV_PIX_FMT_YUV440P);
for (i = 0; i < s->chroma_height; i++) {
for (index = s->width - 1; index; index--)
line[index] = (line[index / 2] + line[(index + 1) / 2]) >> 1;
line += s->linesize[s->upscale_h];
}
}
if (s->upscale_v) {
uint8_t *dst = &((uint8_t *)s->picture_ptr->data[s->upscale_v])[(s->height - 1) * s->linesize[s->upscale_v]];
av_assert0(avctx->pix_fmt == AV_PIX_FMT_YUVJ444P ||
avctx->pix_fmt == AV_PIX_FMT_YUV444P ||
avctx->pix_fmt == AV_PIX_FMT_YUVJ422P ||
avctx->pix_fmt == AV_PIX_FMT_YUV422P);
for (i = s->height - 1; i; i--) {
uint8_t *src1 = &((uint8_t *)s->picture_ptr->data[s->upscale_v])[i / 2 * s->linesize[s->upscale_v]];
uint8_t *src2 = &((uint8_t *)s->picture_ptr->data[s->upscale_v])[(i + 1) / 2 * s->linesize[s->upscale_v]];
if (src1 == src2) {
memcpy(dst, src1, s->width);
} else {
for (index = 0; index < s->width; index++)
dst[index] = (src1[index] + src2[index]) >> 1;
}
dst -= s->linesize[s->upscale_v];
}
}
if (s->flipped && (s->avctx->flags & CODEC_FLAG_EMU_EDGE)) {
int hshift, vshift, j;
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);
for (index=0; index<4; index++) {
uint8_t *dst = s->picture_ptr->data[index];
int w = s->width;
int h = s->height;
if(index && index<3){
w = -((-w) >> hshift);
h = -((-h) >> vshift);
}
if(dst){
uint8_t *dst2 = dst + s->linesize[index]*(h-1);
for (i=0; i<h/2; i++) {
for (j=0; j<w; j++)
FFSWAP(int, dst[j], dst2[j]);
dst += s->linesize[index];
dst2 -= s->linesize[index];
}
}
}
}
av_log(avctx, AV_LOG_DEBUG, "decode frame unused %td bytes\n",
buf_end - buf_ptr);
return buf_ptr - buf;
}
| 1threat |
How can I write a regular expression to find/replace HTML classes? : <p>I'm trying to write a regular expression that will match each individual class on HTML elements in an HTML file and allow me to append a string onto the end of each one. I'm using Atom, which is a basic text editor that lets you search with regular expressions.</p>
<p>My end goal is that I want to append a string onto each of the HTML classes on the page. I'm not sure what exactly should be matched by the regex to make the replacement easier - maybe match the character after each class and replace it with the new text plus the old character somehow? Is this even possible?</p>
<p>Examples:</p>
<pre><code><!-- Here I want to find 'container', then 'flex', then 'left'... -->
<div class="container flex left"></div>
<!-- And convert to... -->
<div class="container-new flex-new left-new"></div>
<!-- Here I want to match just on 'btn-1' -->
<label class="btn-1"></label>
<!-- and convert to: -->
<label class="btn-1-new"></label>
</code></pre>
<p>I know I need to use look-aheads and possibly look-behinds somehow, and now I've gone through a couple tutorials on how to use them, but am still struggling to write a regular expression to solve this problem.</p>
| 0debug |
static void decode_rrr_divide(CPUTriCoreState *env, DisasContext *ctx)
{
uint32_t op2;
int r1, r2, r3, r4;
op2 = MASK_OP_RRR_OP2(ctx->opcode);
r1 = MASK_OP_RRR_S1(ctx->opcode);
r2 = MASK_OP_RRR_S2(ctx->opcode);
r3 = MASK_OP_RRR_S3(ctx->opcode);
r4 = MASK_OP_RRR_D(ctx->opcode);
CHECK_REG_PAIR(r3);
switch (op2) {
case OPC2_32_RRR_DVADJ:
CHECK_REG_PAIR(r4);
GEN_HELPER_RRR(dvadj, cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r2]);
break;
case OPC2_32_RRR_DVSTEP:
CHECK_REG_PAIR(r4);
GEN_HELPER_RRR(dvstep, cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r2]);
break;
case OPC2_32_RRR_DVSTEP_U:
CHECK_REG_PAIR(r4);
GEN_HELPER_RRR(dvstep_u, cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r2]);
break;
case OPC2_32_RRR_IXMAX:
CHECK_REG_PAIR(r4);
GEN_HELPER_RRR(ixmax, cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r2]);
break;
case OPC2_32_RRR_IXMAX_U:
CHECK_REG_PAIR(r4);
GEN_HELPER_RRR(ixmax_u, cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r2]);
break;
case OPC2_32_RRR_IXMIN:
CHECK_REG_PAIR(r4);
GEN_HELPER_RRR(ixmin, cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r2]);
break;
case OPC2_32_RRR_IXMIN_U:
CHECK_REG_PAIR(r4);
GEN_HELPER_RRR(ixmin_u, cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r2]);
break;
case OPC2_32_RRR_PACK:
gen_helper_pack(cpu_gpr_d[r4], cpu_PSW_C, cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r1]);
break;
default:
generate_trap(ctx, TRAPC_INSN_ERR, TIN2_IOPC);
}
}
| 1threat |
static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
{
int i;
int dc_y_table;
int dc_c_table;
int ac_y_table;
int ac_c_table;
int residual_eob_run = 0;
VLC *y_tables[64];
VLC *c_tables[64];
s->dct_tokens[0][0] = s->dct_tokens_base;
if (get_bits_left(gb) < 16)
dc_y_table = get_bits(gb, 4);
dc_c_table = get_bits(gb, 4);
residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_y_table], 0,
0, residual_eob_run);
if (residual_eob_run < 0)
return residual_eob_run;
reverse_dc_prediction(s, 0, s->fragment_width[0], s->fragment_height[0]);
residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0,
1, residual_eob_run);
if (residual_eob_run < 0)
return residual_eob_run;
residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0,
2, residual_eob_run);
if (residual_eob_run < 0)
return residual_eob_run;
if (!(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
reverse_dc_prediction(s, s->fragment_start[1],
s->fragment_width[1], s->fragment_height[1]);
reverse_dc_prediction(s, s->fragment_start[2],
s->fragment_width[1], s->fragment_height[1]);
}
ac_y_table = get_bits(gb, 4);
ac_c_table = get_bits(gb, 4);
for (i = 1; i <= 5; i++) {
y_tables[i] = &s->ac_vlc_1[ac_y_table];
c_tables[i] = &s->ac_vlc_1[ac_c_table];
}
for (i = 6; i <= 14; i++) {
y_tables[i] = &s->ac_vlc_2[ac_y_table];
c_tables[i] = &s->ac_vlc_2[ac_c_table];
}
for (i = 15; i <= 27; i++) {
y_tables[i] = &s->ac_vlc_3[ac_y_table];
c_tables[i] = &s->ac_vlc_3[ac_c_table];
}
for (i = 28; i <= 63; i++) {
y_tables[i] = &s->ac_vlc_4[ac_y_table];
c_tables[i] = &s->ac_vlc_4[ac_c_table];
}
for (i = 1; i <= 63; i++) {
residual_eob_run = unpack_vlcs(s, gb, y_tables[i], i,
0, residual_eob_run);
if (residual_eob_run < 0)
return residual_eob_run;
residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i,
1, residual_eob_run);
if (residual_eob_run < 0)
return residual_eob_run;
residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i,
2, residual_eob_run);
if (residual_eob_run < 0)
return residual_eob_run;
}
return 0;
} | 1threat |
static int decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)
{
int compno, reslevelno, bandno;
int x, y;
uint8_t *line;
Jpeg2000T1Context t1;
for (compno = 0; compno < s->ncomponents; compno++) {
Jpeg2000Component *comp = tile->comp + compno;
Jpeg2000CodingStyle *codsty = tile->codsty + compno;
for (reslevelno = 0; reslevelno < codsty->nreslevels2decode; reslevelno++) {
Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno;
for (bandno = 0; bandno < rlevel->nbands; bandno++) {
int nb_precincts, precno;
Jpeg2000Band *band = rlevel->band + bandno;
int cblkno=0, bandpos;
bandpos = bandno + (reslevelno > 0);
if (band->coord[0][0] == band->coord[0][1] || band->coord[1][0] == band->coord[1][1])
continue;
nb_precincts = rlevel->num_precincts_x * rlevel->num_precincts_y;
for (precno = 0; precno < nb_precincts; precno++) {
Jpeg2000Prec *prec = band->prec + precno;
for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) {
int x, y;
Jpeg2000Cblk *cblk = prec->cblk + cblkno;
decode_cblk(s, codsty, &t1, cblk,
cblk->coord[0][1] - cblk->coord[0][0],
cblk->coord[1][1] - cblk->coord[1][0],
bandpos);
x = cblk->coord[0][0];
y = cblk->coord[1][0];
if (codsty->transform == FF_DWT97)
dequantization_float(x, y, cblk, comp, &t1, band);
else
dequantization_int(x, y, cblk, comp, &t1, band);
}
}
}
}
ff_dwt_decode(&comp->dwt, comp->data);
}
if (tile->codsty[0].mct)
mct_decode(s, tile);
if (s->precision <= 8) {
for (compno = 0; compno < s->ncomponents; compno++) {
Jpeg2000Component *comp = tile->comp + compno;
float *datap = (float*)comp->data;
int32_t *i_datap = (int32_t *) comp->data;
y = tile->comp[compno].coord[1][0] - s->image_offset_y;
line = s->picture->data[0] + y * s->picture->linesize[0];
for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) {
uint8_t *dst;
x = tile->comp[compno].coord[0][0] - s->image_offset_x;
dst = line + x * s->ncomponents + compno;
for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s->cdx[compno]) {
int val;
if (tile->codsty->transform == FF_DWT97)
val = lrintf(*datap) + (1 << (s->cbps[compno] - 1));
else
val = *i_datap + (1 << (s->cbps[compno] - 1));
val = av_clip(val, 0, (1 << s->cbps[compno]) - 1);
*dst = val << (8 - s->cbps[compno]);
datap++;
i_datap++;
dst += s->ncomponents;
}
line += s->picture->linesize[0];
}
}
} else {
for (compno = 0; compno < s->ncomponents; compno++) {
Jpeg2000Component *comp = tile->comp + compno;
float *datap = (float*)comp->data;
int32_t *i_datap = (int32_t *) comp->data;
uint16_t *linel;
y = tile->comp[compno].coord[1][0] - s->image_offset_y;
linel = (uint16_t*)s->picture->data[0] + y * (s->picture->linesize[0] >> 1);
for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) {
uint16_t *dst;
x = tile->comp[compno].coord[0][0] - s->image_offset_x;
dst = linel + (x * s->ncomponents + compno);
for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s-> cdx[compno]) {
int val;
if (tile->codsty->transform == FF_DWT97)
val = lrintf(*datap) + (1 << (s->cbps[compno] - 1));
else
val = *i_datap + (1 << (s->cbps[compno] - 1));
val = av_clip(val, 0, (1 << s->cbps[compno]) - 1);
*dst = val << (16 - s->cbps[compno]);
datap++;
i_datap++;
dst += s->ncomponents;
}
linel += s->picture->linesize[0]>>1;
}
}
}
return 0;
}
| 1threat |
Entity Get latest results based on date : <p>I have the following table:</p>
<pre><code>------------------------------------
userid | testid | date | result
1 | 1 | 18-01-01 | 1
1 | 1 | 18-01-09 | 6
1 | 3 | 18-01-09 | 5
1 | 3 | 18-01-10 | 2
</code></pre>
<p>Now i need to get 2 rows using Entity: The following:</p>
<pre><code>------------------------------------
userid | testid | date | result
1 | 1 | 18-01-09 | 6
1 | 3 | 18-01-10 | 2
</code></pre>
<p>I need a LINQ query that returns the latest result of each testid in the database. The userID/testID is the group. What is the best and fastest way to get this information?</p>
<p>Thanks,</p>
| 0debug |
static void vhost_log_sync(MemoryListener *listener,
MemoryRegionSection *section)
{
struct vhost_dev *dev = container_of(listener, struct vhost_dev,
memory_listener);
hwaddr start_addr = section->offset_within_address_space;
hwaddr end_addr = start_addr + section->size;
vhost_sync_dirty_bitmap(dev, section, start_addr, end_addr);
}
| 1threat |
Parsing and iterating String to arraylist : <p>I have a String with value as:</p>
<blockquote>
<p>String lstr = [12.88, 77.56],[12.81, 77.7156]</p>
</blockquote>
<p>....so on</p>
<p>I need to parse and iterate it and somehow substitute the values as :</p>
<pre><code>final ArrayList<Coordinate> points = new ArrayList<Coordinate>();
points.add(new Coordinate(12.88, 77.56));
points.add(new Coordinate(12.81, 77.7156));
</code></pre>
<p>i tried converting string to List and then iterating it using for loop, but it is not working, either it goes out of bound or extra square bracket throws an exception.
What is the best way to parse, format and iterate a string like this?</p>
| 0debug |
Firefox redirects localhost to HTTPS : <p>There is a similar question about the same issue on Chrome, with an answer that solves it in Chrome. </p>
<p>When I try to go to <code>http://localhost:8000/</code>, Firefox redirects me to <code>https://localhost/</code> . Why? If I open an incognito window, this doesn't happen. I can't continue developing until I solve this. Please help.</p>
| 0debug |
can we write better queary than this? to reduce performance issues :
select
(select OMH_RECV_BIC from sc_omh_m where sc_omh_trans_sno=103) as 'Sender\Receiver',
(select OMH_MSG_TRM_DT from sc_omh_m where sc_omh_trans_sno=103) as 'Send\Receivedate',
(select omh_msg_type from sc_omh_m where sc_omh_trans_sno=103) as 'Message Type',
(select omd_sfld_val from SC_OMD_T where OMD_FLD_TAG=20 and omd_sfld_ord=1 and omd_trans_sno=103) as 'Senders Reference',
(select omd_sfld_val from SC_OMD_T where OMD_FLD_TAG=50 and omd_sfld_ord=3 and omd_trans_sno=103) as 'Ordering Customer',
(select omd_sfld_val from SC_OMD_T where OMD_FLD_TAG=59 and omd_sfld_ord=3 and OMD_TRANS_SNO=103) as 'Beneficiary Customer',
(select omd_sfld_val from SC_OMD_T where OMD_FLD_TAG=32 and omd_sfld_ord=2and omd_trans_sno=103) as 'Currency Code',
(select omd_sfld_val from SC_OMD_T where OMD_FLD_TAG=32 and omd_sfld_ord=1and omd_trans_sno=103) as 'Date',
(select omd_sfld_val from SC_OMD_T where OMD_FLD_TAG=32 and omd_sfld_ord=3and omd_trans_sno=103) as 'Value' | 0debug |
*Urgent* Why won't null GameObjects be removed from List? : for some reason my code at the bottom of function TargetEnemy() doesn't work. I try to remove the null GameObjects from the List, but they remain in the list. Any help would be appreciated. Thanks in advance!
<!-- begin snippet: js hide: false -->
<!-- language: lang-js -->
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class TurretController : MonoBehaviour {
public Transform turretBulletSpawn;
public GameObject turretBullet;
public List <GameObject> storedEnemies = new List <GameObject>();
void Start ()
{
}
void Update ()
{
TargetEnemy();
}
public void OnTriggerEnter (Collider enemyTriggered)
{
if (enemyTriggered.tag == "Enemy")
{
storedEnemies.Add(enemyTriggered.gameObject);
}
}
public void OnTriggerExit (Collider enemyTriggered)
{
storedEnemies.Remove(enemyTriggered.gameObject);
}
void TargetEnemy()
{
for (int i = 0; i < storedEnemies.Count; i++)
{
Quaternion rotate = Quaternion.LookRotation(storedEnemies[i].transform.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, rotate, Time.deltaTime * 2);
Instantiate (turretBullet, turretBulletSpawn.position, turretBulletSpawn.rotation);
if (storedEnemies[i].gameObject == null)
{
storedEnemies.RemoveAt(i);
}
}
}
}
<!-- end snippet -->
| 0debug |
Escaping ORDER BY clause using mysqli_real_escape_string() function : <p>I am using different values in ORDER BY clause of SQL queries based upon user selection. How do I escape this selected value using mysqli_real_escape_string() function?</p>
<p>For example, the url is as following:</p>
<pre><code>localhost/person/person_listing.php?sort_by=date_of_birth
</code></pre>
<p>Based on this I am using:</p>
<pre><code>if (isset($_GET['sort_by'])) {
$sort_by = trim($_GET['sort_by']);
if (!empty($sort_by)) {
$order_by_sql = " ORDER BY $sort_by";
}
}
</code></pre>
<p>The question is, what is the best way to escape this type of add-on to SQL? Can the entire ORDER BY clause be escaped at once, or each value has to be escaped individually?</p>
| 0debug |
How do I get an imageView and textview to both fill the layout when Im setting the imageView bitmap programmatically? : What I want is for `qrcodetext` to fit and display all the text in `qrcode_layout` and have `qrimageView` to fill the rest of `qrcode_layout`? But my layout below has the entire `qrimageView` cover `qrcode_layout`.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:id="@+id/qrcodelayout">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/qrimageView"
android:layout_gravity="center_horizontal"
android:layout_marginTop="8dp" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/qrcodetext"
android:gravity="center"
android:layout_gravity="center_horizontal"
android:layout_marginTop="4dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</RelativeLayout> | 0debug |
Convert Zip byte[] to Unzip byte[] using java code : <p>Could some one help me with the code snippet in converting zip byte[] to unzip byte[] in memory with out writing to a file intermediary </p>
<p>I looked in to this stack overflow "<a href="https://stackoverflow.com/questions/9209450/convert-zip-byte-to-unzip-byte">convert zip byte[] to unzip byte[]</a>' but not able to get it using java code</p>
<p>Thanks
Somu</p>
| 0debug |
static int swf_probe(AVProbeData *p)
{
if(p->buf_size < 15)
return 0;
if ( AV_RB24(p->buf) != AV_RB24("CWS")
&& AV_RB24(p->buf) != AV_RB24("FWS"))
return 0;
if (p->buf[3] >= 20)
return AVPROBE_SCORE_MAX / 4;
return AVPROBE_SCORE_MAX;
}
| 1threat |
how to translate this PHP code to PDO form , brcause i am getting undefined function in PHP 7 (using XAMPP)? : this is my PHP file, but i am getting fatal error : undefined function mysql_connect, i have searched it and it looks like i have to use PDO instead of mysql_connect on PHP 7 , and i dont know how so i need help please, i want this code as PDO, thanks for your time
<?php
// connection , which gives fatal exception : undefined function..
$con = mysql_connect("localhost",'root','');
//error handling
if (!$con)
{
die("Could not connected".mysql_error()); else
{
//select the DB name in PhpMyAdmin
mysql_select_db("tm-mobile",$con);
//Vlidation
if (!empty($_POST['owner_name']) && !empty($_POST['owner_email']))
{
$owner_id=$_POST['owner_id'];
$owner_name=$_POST['owner_name'];
$owner_email=$_POST['owner_email'];
$owner_password=$_POST['owner_password'];
$market_name=$_POST['market_name'];
//SQL statement
$sql = "UPDATE owner_table SET owner_id = '$owner_id',owner_name =
'$owner_name' , owner_email = '$owner_email', owner_password =
'$owner_password' , market_name = '$market_name' ";
$re = mysql_query ($sql,$con);
//Close the Connection
mysql_close();
}
}
?> | 0debug |
How to spy a service call in Angular2 : <p>Following the code example found on Ari Lerner ng-book2, and using Angular 2 beta 7, I'm trying to mock and spy a call to a service unsuccessfully.</p>
<p>This is the main component using the service:</p>
<p><em>user-list.component.ts</em></p>
<pre class="lang-js prettyprint-override"><code>import {Component, OnInit} from 'angular2/core';
import {UserService} from './user.service';
import {IUser} from './user.model';
@Component({
selector: 'user-list',
providers: [UserService],
template: `
<div *ngFor="#user of users" class="user">
<span class="username">Username: {{ user.username }}</span><br>
<span class="email">Email: {{ user.email }}</span>
</div>
`
})
export class UserListComponent implements OnInit {
public users: IUser[];
private userService: UserService;
constructor(userService: UserService) {
this.userService = userService;
}
ngOnInit(): void {
this.userService.getAllUsers().subscribe(
(users: IUser[]) => {
this.users = users;
},
(error: any) => {
console.log(error);
}
);
}
}
</code></pre>
<p>And this is the service itself.</p>
<p><em>user.service.ts</em></p>
<pre class="lang-js prettyprint-override"><code>import {Injectable} from 'angular2/core';
import {Http} from 'angular2/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/Rx';
import {IUser} from './user.model';
@Injectable()
export class UserService {
private http: Http;
private baseUrl: string = 'http://jsonplaceholder.typicode.com/users';
constructor(http: Http) {
this.http = http;
}
public getAllUsers(): Observable<IUser[]> {
return this.http.get(this.baseUrl)
.map(res => res.json());
}
}
</code></pre>
<p>In order to test the <code>UserListComponent</code>, I'm trying to mock the <code>UserService</code> and spy its method call <code>getAllUser</code> using the following code:</p>
<p><em>user-list.component.spec.ts</em></p>
<pre class="lang-js prettyprint-override"><code>import {
describe,
expect,
it,
injectAsync,
TestComponentBuilder,
ComponentFixture,
setBaseTestProviders,
} from 'angular2/testing';
import {SpyObject} from 'angular2/testing_internal';
import {
TEST_BROWSER_PLATFORM_PROVIDERS,
TEST_BROWSER_APPLICATION_PROVIDERS
} from 'angular2/platform/testing/browser';
import {provide} from 'angular2/core';
import {UserListComponent} from './user-list.component';
import {UserService} from './user.service';
class SpyUserService extends SpyObject {
public getAllUsers: Function;
public fakeResponse: any = null;
constructor() {
super(UserService);
this.getAllUsers = this.spy('getAllUsers').andReturn(this);
}
public subscribe(callback) {
callback(this.fakeResponse);
}
public setResponse(data: any): void {
this.fakeResponse = data;
}
}
describe('When rendering the UserListComponent and mocking the UserService', () => {
setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS);
it('should show one mocked user', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
let spyUserService = new SpyUserService();
spyUserService.setResponse([{
username: 'ryan',
email: 'ryan@gmail.com'
}]);
return tcb
.overrideProviders(UserListComponent, [provide(UserService, {useValue: spyUserService})])
.createAsync(UserListComponent)
.then((fixture: ComponentFixture) => {
fixture.detectChanges();
expect(spyUserService.getAllUsers).toHaveBeenCalled();
});
}));
});
</code></pre>
<p>When using karma to run the test I'm getting the following console error:</p>
<pre class="lang-sh prettyprint-override"><code>Chrome 48.0.2564 (Mac OS X 10.11.3) ERROR
Uncaught TypeError: Cannot read property 'isSlow' of null
at /Users/david/apps/sandbox/angular2-testing-cookbook/src/tests.entry.ts:19430
</code></pre>
<p><strong>Do anybody know why is this error being thrown or the proper way to mock and spy a service for unit testing an Angular 2 component?</strong></p>
| 0debug |
Segmentation Fault fgets() two pass assembler : <pre><code> #include<string.h>
typedef struct{
char Mnemonic[7];
int code;
} code;
typedef struct{
char label[10];
unsigned int location;
} symbolTab;
int opLook(char * mnemonic, code * optable)
{
int i = 0;
int value = 0;
for(i ; i<25 ; i++)
{
if(strcmp(mnemonic, optable[i].Mnemonic) == 0)
{
value = optable[i].code;
return value;
}
}
return value;
}
int opValid(char * mnemonic, code * optable)
{
int i = 0;
for(i ; i<25 ; i++)
{
if(strcmp(mnemonic, optable[i].Mnemonic) == 0)
{
return 1;
}
}
return 0;
}
int labelcheck(char * label, symbolTab * Table, int counter)
{
int i = 0;
int flag = 0;
if (counter == 0)
{
return flag;
}
else
{
for(i; i <counter; i ++)
{
if(strcmp(label, Table[i].label) == 0)
{
flag = 1;
}
}
return flag;
}
}
unsigned int labelVal(char * label, symbolTab * Table, int counter)
{
int i = 0;
for(i; i <counter; i ++)
{
if(strcmp(label, Table[i].label) == 0)
{
return Table[i].location;
}
}
}
void Assemble(char* filename)
{
unsigned int locctr = 0; /*location counter*/
unsigned int prolen = 0; /*program length*/
int mnemoVal; /*mnemonic Value in Int*/
int labelctr = 0;
code Opta[25] = {{"ADD", 24},{"AND",88},{"COMP",40},{"DIV",36},{"J",60},
{"JEQ",48},{"JGT",52},{"JLT",56},{"JSUB",72},{"LDA",00},
{"LDCH",80},{"LDL", 8},{"LDX", 4},{"MUL",32},{"OR",68},
{"RD",216},{"RSUB",76},{"STA",12},{"STCH",84},{"STL",20},
{"STX",16},{"SUB",28},{"TD",224},{"TIX",44},{"WD",220}};
symbolTab symTab[500];
char buffer[255];
FILE * source;
FILE * interFile;
FILE * objF;
FILE * ListFile;
interFile = fopen("intermidiateFile.txt", "w+");
ListFile = fopen("ListingFile.txt", "w+");
objF = fopen("ObjectFile.txt", "w+");
source = fopen("source.txt", "r");
char * lab; /*label*/
char * mnemo; /*mnemonic*/
char * operand;
char * address = "adress";
unsigned int opeaddress;
fgets(buffer, 255, source);
if (buffer[0] != '.')
{
fprintf(interFile, "%s", buffer);
}
/*Getting first line and initialization of Location Counter*/
if(buffer[0] == '.') /* if the line is a comment continue with the next iteration of the loop*/
{
locctr = 0;
}
else
{
if(buffer[0] == ' ' || buffer[0] == '\t')
{
mnemo = strtok(buffer, " \t");
operand = strtok(NULL, " \t");
if(strcmp(mnemo, "START") == 0)
{
locctr = strtol(operand, NULL, 16);
}
else
{
/*error*/
}
}
else
{
lab =strtok(buffer, " \t");
mnemo = strtok(NULL, " \t");
operand = strtok(NULL, " \t");
if(strcmp(mnemo, "START") == 0)
{
locctr = strtol(operand, NULL, 16);
}
else
{
/*error*/
}
}
}
/* End of the location counter initialization */
/*start while loop*/
while(!feof(source))
{
memset(lab, '\0', strlen(lab));
memset(mnemo, '\0', strlen(mnemo));
memset(operand, '\0', strlen(operand));
fgets(buffer, 255, source);
fprintf(interFile, "%s", buffer);
if(buffer[0] == '.') /* if the line is a comment continue with the next iteration of the loop*/
{
continue;
}
else /* Else for... If it is not a comment, then check if it start with a character or a space*/
{
if(buffer[0] == ' ' || buffer[0] == '\t') /* If it start with a space, then it is just a mnemonic or mnemonic & operand*/
{
mnemo = strtok(buffer, " \t\n\r");
if (strcmp(mnemo, "END") == 0)
{
break;
}
if(strcmp(mnemo, "RSUB") == 0)
{
mnemoVal = opLook(mnemo, Opta);
fprintf(interFile, "%x %02x\n", locctr, mnemoVal);
}
else
{
operand = strtok(NULL, " \t\r\n");
mnemoVal = opLook(mnemo, Opta);
fprintf(interFile, "%x %02x %s\n", locctr, mnemoVal, operand);
}
}
else
{
lab = strtok(buffer, " \t\n\r"); /* it has a label, mnemonic and operand*/
if(labelcheck(lab, symTab, labelctr) == 0) /* check if the label is already in the symTab, if not, add it, otherwise it is an error*/
{
strcpy(symTab[labelctr].label, lab);
symTab[labelctr].location = locctr;
labelctr++;
mnemo = strtok(NULL, " \t\n\r");
if (strcmp(mnemo, "END") == 0)
{
break;
}
operand = strtok(NULL, " \t\n\r");
mnemoVal = opLook(mnemo, Opta);
}
else
{
mnemo = strtok(NULL, " \t\n\r");
if (strcmp(mnemo, "END") == 0)
{
break;
}
operand = strtok(NULL, " \t\n\r");
mnemoVal = opLook(mnemo, Opta);
}
fprintf(interFile, "%x %s %02x %s\n", locctr, lab, mnemoVal, operand);
}
}
if(strcmp(mnemo, "WORD") == 0 )
{
locctr = locctr + 3;
}
else if(strcmp(mnemo, "BYTE") == 0 )
{
unsigned int val;
if (operand[0] =='C')
{
val = strlen(operand) - 3;
locctr = locctr + val;
}
else
{
val = (strlen(operand) - 3)/2;
locctr = locctr + val;
}
}
else if(strcmp(mnemo, "RESB") == 0)
{
locctr = locctr + atoi(operand);
}
else if(strcmp(mnemo, "RESW") == 0)
{
locctr = locctr + (3*atoi(operand));
}
else
{
locctr= locctr + 3;
}
}
/* End of While loop*/
prolen = locctr - symTab[0].location;
fprintf(interFile, "\n%x", prolen);
fclose(source);
fclose(interFile);
interFile = fopen("intermidiateFile.txt", "r");
/*Start the Listing File and Object File ---------------------Pass 2----------- */
fgets(buffer, 255, interFile);
if(buffer[0] == '.') /* if the line is a comment continue with the next iteration of the loop*/
{
locctr = 0;
/*Error missung Start or Misplaced*/
}
else
{
if(buffer[0] == ' ' || buffer[0] == '\t')
{
mnemo = strtok(buffer, " \t");
operand = strtok(NULL, " \t");
if(strcmp(mnemo, "START") == 0)
{
locctr = strtol(operand, NULL, 16);
strcpy(address, operand);
fprintf(ListFile, "%X %s %s\n", locctr, mnemo, operand);
}
else
{
/*error*/
}
}
else
{
lab =strtok(buffer, " \t");
mnemo = strtok(NULL, " \t");
operand = strtok(NULL, " \t");
if(strcmp(mnemo, "START") == 0)
{
locctr = strtol(operand, NULL, 16);
fprintf(ListFile, "%x %s %s %s\n", locctr, lab, mnemo, operand);
fprintf(objF, "H%s__%06x%06x\n", lab, locctr, prolen);
}
else
{
/*error*/
}
}
}
while(!feof(interFile))
{
memset(lab, '\0', strlen(lab));
memset(mnemo, '\0', strlen(mnemo));
memset(operand, '\0', strlen(operand));
memset(address, '\0', strlen(address));
memset(buffer, '\0', strlen(buffer));
fgets(buffer, 255, interFile);
if (buffer[0] == '\r')
{
continue;
}
if(buffer[0] == ' ' || buffer[0] == '\t')
{
mnemo = strtok(buffer, " \t\n\r");
if (strcmp(mnemo, "END") == 0)
{
break;
}
if(strcmp(mnemo, "RSUB") == 0)
{
memset(buffer, '\0', strlen(buffer));
fgets(address, 255, interFile);
mnemoVal = opLook(mnemo, Opta);
fprintf(ListFile, "%s %s %X0000", address, mnemo, mnemoVal);
}
else
{
operand = strtok(NULL, " \t\r\n");
mnemoVal = opLook(mnemo, Opta);
memset(buffer, '\0', strlen(buffer));
fgets(address, 255, interFile);
if (labelcheck(operand, symTab, labelctr) == 1)
{
opeaddress = labelVal(operand, symTab, labelctr);
}
else
{
opeaddress = 0;
/* error*/
}
fprintf(ListFile, "%s %s %s %02X%04X", address, mnemo, operand, mnemoVal, opeaddress);
}
}
else if (buffer[0] == '.')
{
fprintf(ListFile, "%s\n", buffer);
}
else
{
lab = strtok(buffer, " \t\n\r");
mnemo = strtok(NULL, " \t\n\r");
operand = strtok(NULL, " \t\n\r");
mnemoVal = opLook(mnemo, Opta);
memset(buffer, '\0', strlen(buffer));
fgets(address, 255, interFile);
if (labelcheck(operand, symTab, labelctr) == 1)
{
opeaddress = labelVal(operand, symTab, labelctr);
}
else
{
opeaddress = 0;
/* error*/
}
fprintf(ListFile, "%s %s %s %s %02X%04X", address, lab, mnemo, operand, mnemoVal, opeaddress);
}
}
fclose(interFile);
fclose(objF);
fclose(ListFile);
}
</code></pre>
<p>The error occurs in the last while loop when executing fgets();
I have looked if I had any variable or syntax wrong, but everything looks fine.
This is a part of a two pass assemble. The error varies between the fgets in the last while loop. At first I thought that it was the memset function, but the error still happened when I mark them as comments</p>
| 0debug |
What is the difference between Any and Unit in scala? : What is the difference between `Any` and `Unit` in Scala ?
I know both are datatypes, but what is the difference ? | 0debug |
Filter by method on model in ActiveAdmin with parameters passed in : <p>Using Rails 4.2.1 and Active Admin 1.0.0.pre2</p>
<p>I have an Apartment model which has many Occupancies. I want admins to be able to see whether an apartment in index overlaps with dates passed in as params. I have a method on Apartment</p>
<pre><code> def available_during(start_date, end_date)
return !self.occupancies.any? { |occ| occ.date_range_overlap(Date.parse(start_date), Date.parse(end_date)) }
end
</code></pre>
<p>Which returns true if the apartment has any occupancies that overlap with two given dates. The method <code>date_range_overlap</code> on occupancy is pretty self explanatory. I can't seem to figure out how to make ActiveAdmin's DSL to filter by that method or even make a form to input random params.</p>
<p>I was able to put a column that shows the boolean return value of the available_during method in the index. </p>
<pre><code>if params[:from] && params[:until]
column "available?" do |apt|
apt.available_during(params[:from], params[:until])
end
end
</code></pre>
<p>But I can only seem to get this to work by manually inputting the from and until params in the url. </p>
<p>How might I place an arbitrary search form to send the user to the right params? Or better yet, make a filter in that sidebar that uses that method? </p>
| 0debug |
static void do_memory_save(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
FILE *f;
uint32_t size = qdict_get_int(qdict, "size");
const char *filename = qdict_get_str(qdict, "filename");
target_long addr = qdict_get_int(qdict, "val");
uint32_t l;
CPUState *env;
uint8_t buf[1024];
env = mon_get_cpu();
if (!env)
return;
f = fopen(filename, "wb");
if (!f) {
monitor_printf(mon, "could not open '%s'\n", filename);
return;
}
while (size != 0) {
l = sizeof(buf);
if (l > size)
l = size;
cpu_memory_rw_debug(env, addr, buf, l, 0);
fwrite(buf, 1, l, f);
addr += l;
size -= l;
}
fclose(f);
}
| 1threat |
void object_property_get_uint16List(Object *obj, const char *name,
uint16List **list, Error **errp)
{
Error *err = NULL;
StringOutputVisitor *ov;
Visitor *v;
char *str;
ov = string_output_visitor_new(false);
object_property_get(obj, string_output_get_visitor(ov),
name, &err);
if (err) {
error_propagate(errp, err);
goto out;
}
str = string_output_get_string(ov);
v = string_input_visitor_new(str);
visit_type_uint16List(v, NULL, list, errp);
g_free(str);
visit_free(v);
out:
string_output_visitor_cleanup(ov);
}
| 1threat |
Find an image tag? : <p>I have a content editable div, this could have any tags in it, eg.</p>
<pre><code><p>hello</p>
<p>whatever <p>nested p is a bad idea but can happen</p></p>
<div>stuff</div>
<p>test<img></p>
</code></pre>
<p>For a given element, I need to find the img tag that is above it in the source order. The image tag could be a direct sibling, or a child of a sibling or even a parent of the given element.</p>
| 0debug |
getting info trough 3 tables : I'm following the SQL tutorial from w3schools.
I want to get the value of all orders delivered by a shipper. I don't have any idea about how I can get these details as the info are in different tables and the INNER JOIN didn't worked for me.
Database: http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_groupby
By now, I managed to get the number of orders by each shipper.
SELECT Shippers.ShipperName,COUNT(Orders.OrderID) AS NumberOfOrders FROM Orders
LEFT JOIN Shippers
ON Orders.ShipperID=Shippers.ShipperID
GROUP BY ShipperName;
How could I get the value of those?
| 0debug |
static void aio_epoll_update(AioContext *ctx, AioHandler *node, bool is_new)
{
}
| 1threat |
static void xhci_er_reset(XHCIState *xhci, int v)
{
XHCIInterrupter *intr = &xhci->intr[v];
XHCIEvRingSeg seg;
if (intr->erstsz == 0) {
intr->er_start = 0;
intr->er_size = 0;
return;
}
if (intr->erstsz != 1) {
DPRINTF("xhci: invalid value for ERSTSZ: %d\n", intr->erstsz);
xhci_die(xhci);
return;
}
dma_addr_t erstba = xhci_addr64(intr->erstba_low, intr->erstba_high);
pci_dma_read(PCI_DEVICE(xhci), erstba, &seg, sizeof(seg));
le32_to_cpus(&seg.addr_low);
le32_to_cpus(&seg.addr_high);
le32_to_cpus(&seg.size);
if (seg.size < 16 || seg.size > 4096) {
DPRINTF("xhci: invalid value for segment size: %d\n", seg.size);
xhci_die(xhci);
return;
}
intr->er_start = xhci_addr64(seg.addr_low, seg.addr_high);
intr->er_size = seg.size;
intr->er_ep_idx = 0;
intr->er_pcs = 1;
intr->er_full = 0;
DPRINTF("xhci: event ring[%d]:" DMA_ADDR_FMT " [%d]\n",
v, intr->er_start, intr->er_size);
}
| 1threat |
$(this).parent().remove(); not functioning : <p>I am running through a todo list tutorial for jQuery and I ran into an issue that I cannot figure out. My code looks exactly like what is in the video. I have tried to do this on both Plunker and JSFiddle and was not able to get it to work. Can anyone see what is wrong with this?</p>
<p>Here is my HTML:</p>
<pre><code><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<h1>Tasks</h1>
<ul id="todoList">
</ul>
<input type="text" id="newText" /><button id="add">Add</button>
<script data-require="jquery" data-semver="3.0.0" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.js"></script>
<script src="script.js"></script>
</body>
</html>
</code></pre>
<p>and my jQuery:</p>
<pre><code>function addListItem() {
var text = $('#newText').val();
$('#todoList').append('<li>' + text + ' <button class="delete">Delete</button></li>');
$('#newText').val('');
}
function deleteItem() {
$(this).parent().remove();
}
$(function() {
$('#add').on('click', addListItem);
$('.delete').on('click', deleteItem);
});
</code></pre>
| 0debug |
I want to Sorting this list : I want to Sort below list
Current Output :
+ Q1-2015
+ Q1-2016
+ Q1-2017
+ Q1-2018
+ Q1-2019
+ Q2-2015
+ Q2-2016
+ Q2-2017
+ Q2-2018
+ Q2-2019
Expected Output :
+ Q1-2015
+ Q2-2015
+ Q3-2015
+ Q4-2015
+ Q1-2016
+ Q2-2016
+ Q3-2016
+ Q4-2016
How can i achieve my expectation ? | 0debug |
static int32_t tag_tree_size(uint16_t w, uint16_t h)
{
uint32_t res = 0;
while (w > 1 || h > 1) {
res += w * h;
if (res + 1 >= INT32_MAX)
return -1;
w = (w + 1) >> 1;
h = (h + 1) >> 1;
}
return (int32_t)(res + 1);
}
| 1threat |
Basic Python functions. beginner : i've just started a course at University which uses python. Now, I've programmed before but I'm finding this language extremely difficult to grasp. In my assignment I my first task is to make a function that tests whether two words are anagrams of each other.
This is all I have so far :
def anagrams(str1, str2):
str1("String 1 : ")
str2("String 2 : ")
s1 = sorted(str1)
s2 = sorted(str2)
if s1 == s2:
True("This is an anagram")
anagrams(str1 = "Cat", str2 = "Tac")
I keep getting an error " 'str' object is not callable"
Please help me | 0debug |
angular2: How to use observables to debounce window:resize : <p>so i am trying to figure out a way to debouce window:resize events using observables, so some kind of function would be called only after user stoped resizing window or some time has passed without size change (say 1sec).</p>
<p><a href="https://plnkr.co/edit/cGA97v08rpc7lAgitCOd" rel="noreferrer">https://plnkr.co/edit/cGA97v08rpc7lAgitCOd</a></p>
<pre><code>import {Component} from '@angular/core'
@Component({
selector: 'my-app',
providers: [],
template: `
<div (window:resize)="doSmth($event)">
<h2>Resize window to get number: {{size}}</h2>
</div>
`,
directives: []
})
export class App {
size: number;
constructor() {
}
doSmth(e: Event) {
this.size = e.target.innerWidth;
}
}
</code></pre>
<p>is just a simple sample that uses window:resize and shows that it reacts instantly (use "Launch preview in separate window").</p>
| 0debug |
Is apprtc free for use? : <p>i am working on android application that use webrtc and i am using appRtcDemo on github <a href="https://github.com/njovy/AppRTCDemo" rel="nofollow noreferrer">AppRTCDemo</a></p>
<p>but this project use appr.tc server and i think it belong to google.
so my question is it free to use or not and if it is not free is there a way to make my own server and how ? </p>
| 0debug |
Visual Studio Code Intellisense is very slow - Is there anything I can do? : <p>I'm using VS Code and it's wonderful is all areas but code completion, where it is usually just too slow to be of any use. This example shows how long intellisense took to to find a local variable, and this is only after it was prompted to do so after I hit ctrl+enter.</p>
<p><a href="https://i.stack.imgur.com/k0MsN.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/k0MsN.gif" alt="enter image description here"></a></p>
<p>I've not been able to find a solution to this as of yet, so I am here to ask if anyone else has had a similar issue and ask how they have overcome it. </p>
| 0debug |
How to send the data from controller to service in angularjs : <p>I want to send the data from controller to service in angularjs. In controller I am calling service. This service is used to call some back-end api. I want to send some data from controller to service, which will be use to call back-end api. </p>
| 0debug |
Change Edittext color if it is empty in android : <p>How to change the edit text color if it is empty when submitting the form in
android.If there is any library to handle .Answer will be appreciated.</p>
| 0debug |
Random Array from an array - Java : <p>I have an array : {red, blue, green} . I want to generate other array having random contain ex: {red,red,blue,green,blue} . I want to use a variable length of the random array.</p>
| 0debug |
int qdev_init(DeviceState *dev)
{
int rc;
assert(dev->state == DEV_STATE_CREATED);
rc = dev->info->init(dev, dev->info);
if (rc < 0) {
qdev_free(dev);
return rc;
}
qemu_register_reset(qdev_reset, dev);
if (dev->info->vmsd) {
vmstate_register_with_alias_id(dev, -1, dev->info->vmsd, dev,
dev->instance_id_alias,
dev->alias_required_for_version);
}
dev->state = DEV_STATE_INITIALIZED;
return 0;
}
| 1threat |
How to create variables in a loop in Python : <p>how would I be able to make something like this that actually works?</p>
<pre><code>choices = input('Enter choices. ')
i = 0
while i < 10:
number_of_{}s.format(i) = choices.count(str([i]))
i += 1
</code></pre>
| 0debug |
static void pci_bus_init(PCIBus *bus, DeviceState *parent,
const char *name,
MemoryRegion *address_space_mem,
MemoryRegion *address_space_io,
uint8_t devfn_min)
{
assert(PCI_FUNC(devfn_min) == 0);
bus->devfn_min = devfn_min;
bus->address_space_mem = address_space_mem;
bus->address_space_io = address_space_io;
memory_region_init_io(&bus->master_abort_mem, OBJECT(bus),
&master_abort_mem_ops, bus, "pci-master-abort",
memory_region_size(bus->address_space_mem));
memory_region_add_subregion_overlap(bus->address_space_mem,
0, &bus->master_abort_mem,
MASTER_ABORT_MEM_PRIORITY);
QLIST_INIT(&bus->child);
pci_host_bus_register(bus, parent);
vmstate_register(NULL, -1, &vmstate_pcibus, bus);
}
| 1threat |
Why constexpr is not the default for all function? : <p>After relaxing the rules for the constexpr it seems as these functions can be used everywhere. They can be called on both constant (constexpr) and local (mutable) variables as well. So for me it seem as just a hint for the compiler (like inline). I just keep writing it everywhere and remove it if compiler complains. So compiler seems to know everything if a function can be evaluated at compile time or not. Why is it not the default behavior and why do i have to mark anything as constexpr ?</p>
| 0debug |
An iterator for reading a file byte by byte : <p>Is there an iterator for reading a file <a href="https://docs.python.org/3.1/library/functions.html#bytearray" rel="nofollow">byte by byte</a>?</p>
| 0debug |
What does a for (;;) loop do : <p>In a c/c++ file I discovered a strange for loop</p>
<pre><code>for (;;) {...}
</code></pre>
<p>I don't know if this runs once, infinetly or works in some other way
Source: <a href="https://git.kernel.org/cgit/linux/kernel/git/jejb/efitools.git/tree/PreLoader.c" rel="nofollow">https://git.kernel.org/cgit/linux/kernel/git/jejb/efitools.git/tree/PreLoader.c</a> Line 87</p>
| 0debug |
Trying to create a read/write file but keep getting invalid syntax errors : <p>Whenenver I try to run the code in python IDLE, it gives me a syntax error for the first line, not sure why. Trying to get the code to write onto a text document for the lab </p>
<pre><code>Rfile=open (r 'C:\\Users\\cgeeg\\Desktop\\New_folder\\receipt.txt' )
file.write('Name:' )
file.write('Total Stock:' )
file.write('Commission:')
file.write('Total amount:' )
file.write('Net worth in Year(s:')
file.close()
myreceipt=f.readline()
A=float(Rfile.readline())
B=float(Rfile.readline())
C=float(Rfile.readline())
D=float(Rfile.readline())
E=float(Rfile.readline())
P=A*B
CT=P*C/ 100
T=CT+P
Y=P*(1+D/100)**10
print('Price paid for the stock alone is', P)
print('The amount of commission is', CT)
print('Total amount paid is', T)
print('After '+ E + ' years, your shares will be worth:', Y)
opt=input('Would you like a receipt? Yes or No?')
if opt=='Yes':
file=open('receipt.txt','w')
else:
print("Have a nice day")
</code></pre>
| 0debug |
static int drive_add(const char *file, const char *fmt, ...)
{
va_list ap;
int index = drive_opt_get_free_idx();
if (nb_drives_opt >= MAX_DRIVES || index == -1) {
fprintf(stderr, "qemu: too many drives\n");
exit(1);
}
drives_opt[index].file = file;
va_start(ap, fmt);
vsnprintf(drives_opt[index].opt,
sizeof(drives_opt[0].opt), fmt, ap);
va_end(ap);
nb_drives_opt++;
return index;
}
| 1threat |
Sudoku solver in python with backtracking : <p>I saw a few sudoku solvers implementations ,but I cant figure out the problem in my code. I have a function sudokusolver which becomes sudoku Board and must return solved sudoku board.</p>
<pre><code>def sudokutest(s,i,j,z):
# z is the number
isiValid = np.logical_or((i+1<1),(i+1>9));
isjValid = np.logical_or((j+1<1),(j+1>9));
iszValid = np.logical_or((z<1),(z>9));
if s.shape!=(9,9):
raise(Exception("Sudokumatrix not valid"));
if isiValid:
raise(Exception("i not valid"));
if isjValid:
raise(Exception("j not valid"));
if iszValid:
raise(Exception("z not valid"));
if(s[i,j]!=0):
return False;
for ii in range(0,9):
if(s[ii,j]==z):
return False;
for jj in range(0,9):
if(s[i,jj]==z):
return False;
row = int(i/3) * 3;
col = int(j/3) * 3;
for ii in range(0,3):
for jj in range(0,3):
if(s[ii+row,jj+col]==z):
return False;
return True;
def possibleNums(s , i ,j):
l = [];
ind = 0;
for k in range(1,10):
if sudokutest(s,i,j,k):
l.insert(ind,k);
ind+=1;
return l;
def sudokusolver(S):
zeroFound = 0;
for i in range(0,9):
for j in range(0,9):
if(S[i,j]==0):
zeroFound=1;
break;
if(zeroFound==1):
break;
if(zeroFound==0):
return S;
x = possibleNums(S,i,j);
for k in range(len(x)):
S[i,j]=x[k];
sudokusolver(S);
S[i,j] = 0;
return S;
</code></pre>
<p>sudokutest and possibleNums are correct , only sudokusolver give a RecursionError</p>
| 0debug |
How to extract all used hash160 addresses from Bitcoin blockchain : <p>I have all 150GB Bitcoin blocks now what? How to open them and read them in Python? I need to extract all used hash160 so far</p>
<p>I tried to open them with Berkeley DB but no success it seems these files aren't Berkeley DB
and what is the difference between blkxxxxx.dat and revxxxxx.dat files anyway? it seems revxxxxx.dat files got some improvement in file size</p>
| 0debug |
Undeclared Identifier in second function? (C++) : <p>I am having an issue with my C++ code. It keeps telling me Undeclared Identifier in the second function (the menu), but I cannot see the issue since I am passing the variable. The code is <a href="http://pastebin.com/5RvJz8pc" rel="nofollow">here</a></p>
| 0debug |
static bool machine_get_kernel_irqchip(Object *obj, Error **errp)
{
MachineState *ms = MACHINE(obj);
return ms->kernel_irqchip;
}
| 1threat |
Textbox looses forecolor on disabling it : <p>I dynamically create multiple textboxes for showing information to the user. Now I want to set the back- and forecolor of some textboxes if a statement is true.</p>
<p>All this works just fine, untill I disable the textbox, now the forecolor "resets" to the standart color instead of showing my desired one.</p>
<pre><code>DataTable dt = [some data]
//Col 0: ID
//Col 1: some text
//Col 2: date
for (int i = 0; i < dt.Rows.Count; i++)
{
DateTime d = (DateTime) dt.Rows[i].ItemArray[2];
TextBox txt = new TextBox();
txt.Multiline = true;
txt.Font = tb_Aufloesung.Font;
txt.Text = dt.Rows[i].ItemArray[1].ToString() + "\n" + d.ToString(@"dd.MM.yyyy");
txt.Size = new Size((TextRenderer.MeasureText(dt.Rows[i].ItemArray[1].ToString(), txt.Font).Width) + 10, 34);
txt.Location = new Point(43, 3 + split.Panel2.Controls.Count / 2 * 40);
if(d <= DateTime.Now) {
txt.BackColor = Color.Red;
txt.ForeColor = Color.White;
}
//txt.Enabled = false;
split.Panel2.Controls.Add(txt);
}
</code></pre>
<p>This is how the Textboxes look when I use the code above with :</p>
<ol>
<li>comment the line -> <code>//txt.Enabled = false;</code></li>
<li>uncomment the line -> <code>txt.Enabled = false;</code></li>
</ol>
<p><a href="https://i.stack.imgur.com/0hfkS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0hfkS.png" alt="enter image description here"></a></p>
<p>I have no idea why in the second case, the forecolor of the red textbox is not white as it should be.
Anyone any idea?</p>
| 0debug |
DOUBLE NOT IN() IN NESTED QUERIES : SELECT S.sname
FROM Sailors S
WHERE S.sid NOT IN (SELECT R.sid
FROM Reserves R
WHERE R.bid NOT IN (SELECT B.bid
FROM Boats B
WHERE B.color='red'))
Trying to understanding this. How does this piece of code finds names of sailors who reserved only red boats and sailors that do not reserve any boat at all. How does a NOT IN nested within another NOT IN works? | 0debug |
int ff_h264_decode_mb_cabac(H264Context *h) {
MpegEncContext * const s = &h->s;
int mb_xy;
int mb_type, partition_count, cbp = 0;
int dct8x8_allowed= h->pps.transform_8x8_mode;
mb_xy = h->mb_xy = s->mb_x + s->mb_y*s->mb_stride;
tprintf(s->avctx, "pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y);
if( h->slice_type_nos != FF_I_TYPE ) {
int skip;
if( FRAME_MBAFF && s->mb_x==0 && (s->mb_y&1)==0 )
predict_field_decoding_flag(h);
if( FRAME_MBAFF && (s->mb_y&1)==1 && h->prev_mb_skipped )
skip = h->next_mb_skipped;
else
skip = decode_cabac_mb_skip( h, s->mb_x, s->mb_y );
if( skip ) {
if( FRAME_MBAFF && (s->mb_y&1)==0 ){
s->current_picture.mb_type[mb_xy] = MB_TYPE_SKIP;
h->next_mb_skipped = decode_cabac_mb_skip( h, s->mb_x, s->mb_y+1 );
if(!h->next_mb_skipped)
h->mb_mbaff = h->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h);
}
decode_mb_skip(h);
h->cbp_table[mb_xy] = 0;
h->chroma_pred_mode_table[mb_xy] = 0;
h->last_qscale_diff = 0;
return 0;
}
}
if(FRAME_MBAFF){
if( (s->mb_y&1) == 0 )
h->mb_mbaff =
h->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h);
}
h->prev_mb_skipped = 0;
compute_mb_neighbors(h);
if( h->slice_type_nos == FF_B_TYPE ) {
mb_type = decode_cabac_mb_type_b( h );
if( mb_type < 23 ){
partition_count= b_mb_type_info[mb_type].partition_count;
mb_type= b_mb_type_info[mb_type].type;
}else{
mb_type -= 23;
goto decode_intra_mb;
}
} else if( h->slice_type_nos == FF_P_TYPE ) {
if( get_cabac_noinline( &h->cabac, &h->cabac_state[14] ) == 0 ) {
if( get_cabac_noinline( &h->cabac, &h->cabac_state[15] ) == 0 ) {
mb_type= 3 * get_cabac_noinline( &h->cabac, &h->cabac_state[16] );
} else {
mb_type= 2 - get_cabac_noinline( &h->cabac, &h->cabac_state[17] );
}
partition_count= p_mb_type_info[mb_type].partition_count;
mb_type= p_mb_type_info[mb_type].type;
} else {
mb_type= decode_cabac_intra_mb_type(h, 17, 0);
goto decode_intra_mb;
}
} else {
mb_type= decode_cabac_intra_mb_type(h, 3, 1);
if(h->slice_type == FF_SI_TYPE && mb_type)
mb_type--;
assert(h->slice_type_nos == FF_I_TYPE);
decode_intra_mb:
partition_count = 0;
cbp= i_mb_type_info[mb_type].cbp;
h->intra16x16_pred_mode= i_mb_type_info[mb_type].pred_mode;
mb_type= i_mb_type_info[mb_type].type;
}
if(MB_FIELD)
mb_type |= MB_TYPE_INTERLACED;
h->slice_table[ mb_xy ]= h->slice_num;
if(IS_INTRA_PCM(mb_type)) {
const uint8_t *ptr;
ptr= h->cabac.bytestream;
if(h->cabac.low&0x1) ptr--;
if(CABAC_BITS==16){
if(h->cabac.low&0x1FF) ptr--;
}
memcpy(h->mb, ptr, 256); ptr+=256;
if(CHROMA){
memcpy(h->mb+128, ptr, 128); ptr+=128;
}
ff_init_cabac_decoder(&h->cabac, ptr, h->cabac.bytestream_end - ptr);
h->cbp_table[mb_xy] = 0x1ef;
h->chroma_pred_mode_table[mb_xy] = 0;
s->current_picture.qscale_table[mb_xy]= 0;
memset(h->non_zero_count[mb_xy], 16, 16);
s->current_picture.mb_type[mb_xy]= mb_type;
h->last_qscale_diff = 0;
return 0;
}
if(MB_MBAFF){
h->ref_count[0] <<= 1;
h->ref_count[1] <<= 1;
}
fill_caches(h, mb_type, 0);
if( IS_INTRA( mb_type ) ) {
int i, pred_mode;
if( IS_INTRA4x4( mb_type ) ) {
if( dct8x8_allowed && decode_cabac_mb_transform_size( h ) ) {
mb_type |= MB_TYPE_8x8DCT;
for( i = 0; i < 16; i+=4 ) {
int pred = pred_intra_mode( h, i );
int mode = decode_cabac_mb_intra4x4_pred_mode( h, pred );
fill_rectangle( &h->intra4x4_pred_mode_cache[ scan8[i] ], 2, 2, 8, mode, 1 );
}
} else {
for( i = 0; i < 16; i++ ) {
int pred = pred_intra_mode( h, i );
h->intra4x4_pred_mode_cache[ scan8[i] ] = decode_cabac_mb_intra4x4_pred_mode( h, pred );
}
}
ff_h264_write_back_intra_pred_mode(h);
if( ff_h264_check_intra4x4_pred_mode(h) < 0 ) return -1;
} else {
h->intra16x16_pred_mode= ff_h264_check_intra_pred_mode( h, h->intra16x16_pred_mode );
if( h->intra16x16_pred_mode < 0 ) return -1;
}
if(CHROMA){
h->chroma_pred_mode_table[mb_xy] =
pred_mode = decode_cabac_mb_chroma_pre_mode( h );
pred_mode= ff_h264_check_intra_pred_mode( h, pred_mode );
if( pred_mode < 0 ) return -1;
h->chroma_pred_mode= pred_mode;
}
} else if( partition_count == 4 ) {
int i, j, sub_partition_count[4], list, ref[2][4];
if( h->slice_type_nos == FF_B_TYPE ) {
for( i = 0; i < 4; i++ ) {
h->sub_mb_type[i] = decode_cabac_b_mb_sub_type( h );
sub_partition_count[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
h->sub_mb_type[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].type;
}
if( IS_DIRECT(h->sub_mb_type[0] | h->sub_mb_type[1] |
h->sub_mb_type[2] | h->sub_mb_type[3]) ) {
ff_h264_pred_direct_motion(h, &mb_type);
h->ref_cache[0][scan8[4]] =
h->ref_cache[1][scan8[4]] =
h->ref_cache[0][scan8[12]] =
h->ref_cache[1][scan8[12]] = PART_NOT_AVAILABLE;
if( h->ref_count[0] > 1 || h->ref_count[1] > 1 ) {
for( i = 0; i < 4; i++ )
if( IS_DIRECT(h->sub_mb_type[i]) )
fill_rectangle( &h->direct_cache[scan8[4*i]], 2, 2, 8, 1, 1 );
}
}
} else {
for( i = 0; i < 4; i++ ) {
h->sub_mb_type[i] = decode_cabac_p_mb_sub_type( h );
sub_partition_count[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
h->sub_mb_type[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].type;
}
}
for( list = 0; list < h->list_count; list++ ) {
for( i = 0; i < 4; i++ ) {
if(IS_DIRECT(h->sub_mb_type[i])) continue;
if(IS_DIR(h->sub_mb_type[i], 0, list)){
if( h->ref_count[list] > 1 ){
ref[list][i] = decode_cabac_mb_ref( h, list, 4*i );
if(ref[list][i] >= (unsigned)h->ref_count[list]){
av_log(s->avctx, AV_LOG_ERROR, "Reference %d >= %d\n", ref[list][i], h->ref_count[list]);
return -1;
}
}else
ref[list][i] = 0;
} else {
ref[list][i] = -1;
}
h->ref_cache[list][ scan8[4*i]+1 ]=
h->ref_cache[list][ scan8[4*i]+8 ]=h->ref_cache[list][ scan8[4*i]+9 ]= ref[list][i];
}
}
if(dct8x8_allowed)
dct8x8_allowed = get_dct8x8_allowed(h);
for(list=0; list<h->list_count; list++){
for(i=0; i<4; i++){
h->ref_cache[list][ scan8[4*i] ]=h->ref_cache[list][ scan8[4*i]+1 ];
if(IS_DIRECT(h->sub_mb_type[i])){
fill_rectangle(h->mvd_cache[list][scan8[4*i]], 2, 2, 8, 0, 4);
continue;
}
if(IS_DIR(h->sub_mb_type[i], 0, list) && !IS_DIRECT(h->sub_mb_type[i])){
const int sub_mb_type= h->sub_mb_type[i];
const int block_width= (sub_mb_type & (MB_TYPE_16x16|MB_TYPE_16x8)) ? 2 : 1;
for(j=0; j<sub_partition_count[i]; j++){
int mpx, mpy;
int mx, my;
const int index= 4*i + block_width*j;
int16_t (* mv_cache)[2]= &h->mv_cache[list][ scan8[index] ];
int16_t (* mvd_cache)[2]= &h->mvd_cache[list][ scan8[index] ];
pred_motion(h, index, block_width, list, h->ref_cache[list][ scan8[index] ], &mpx, &mpy);
mx = mpx + decode_cabac_mb_mvd( h, list, index, 0 );
my = mpy + decode_cabac_mb_mvd( h, list, index, 1 );
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
if(IS_SUB_8X8(sub_mb_type)){
mv_cache[ 1 ][0]=
mv_cache[ 8 ][0]= mv_cache[ 9 ][0]= mx;
mv_cache[ 1 ][1]=
mv_cache[ 8 ][1]= mv_cache[ 9 ][1]= my;
mvd_cache[ 1 ][0]=
mvd_cache[ 8 ][0]= mvd_cache[ 9 ][0]= mx - mpx;
mvd_cache[ 1 ][1]=
mvd_cache[ 8 ][1]= mvd_cache[ 9 ][1]= my - mpy;
}else if(IS_SUB_8X4(sub_mb_type)){
mv_cache[ 1 ][0]= mx;
mv_cache[ 1 ][1]= my;
mvd_cache[ 1 ][0]= mx - mpx;
mvd_cache[ 1 ][1]= my - mpy;
}else if(IS_SUB_4X8(sub_mb_type)){
mv_cache[ 8 ][0]= mx;
mv_cache[ 8 ][1]= my;
mvd_cache[ 8 ][0]= mx - mpx;
mvd_cache[ 8 ][1]= my - mpy;
}
mv_cache[ 0 ][0]= mx;
mv_cache[ 0 ][1]= my;
mvd_cache[ 0 ][0]= mx - mpx;
mvd_cache[ 0 ][1]= my - mpy;
}
}else{
uint32_t *p= (uint32_t *)&h->mv_cache[list][ scan8[4*i] ][0];
uint32_t *pd= (uint32_t *)&h->mvd_cache[list][ scan8[4*i] ][0];
p[0] = p[1] = p[8] = p[9] = 0;
pd[0]= pd[1]= pd[8]= pd[9]= 0;
}
}
}
} else if( IS_DIRECT(mb_type) ) {
ff_h264_pred_direct_motion(h, &mb_type);
fill_rectangle(h->mvd_cache[0][scan8[0]], 4, 4, 8, 0, 4);
fill_rectangle(h->mvd_cache[1][scan8[0]], 4, 4, 8, 0, 4);
dct8x8_allowed &= h->sps.direct_8x8_inference_flag;
} else {
int list, mx, my, i, mpx, mpy;
if(IS_16X16(mb_type)){
for(list=0; list<h->list_count; list++){
if(IS_DIR(mb_type, 0, list)){
int ref;
if(h->ref_count[list] > 1){
ref= decode_cabac_mb_ref(h, list, 0);
if(ref >= (unsigned)h->ref_count[list]){
av_log(s->avctx, AV_LOG_ERROR, "Reference %d >= %d\n", ref, h->ref_count[list]);
return -1;
}
}else
ref=0;
fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, ref, 1);
}else
fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, (uint8_t)LIST_NOT_USED, 1);
}
for(list=0; list<h->list_count; list++){
if(IS_DIR(mb_type, 0, list)){
pred_motion(h, 0, 4, list, h->ref_cache[list][ scan8[0] ], &mpx, &mpy);
mx = mpx + decode_cabac_mb_mvd( h, list, 0, 0 );
my = mpy + decode_cabac_mb_mvd( h, list, 0, 1 );
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
fill_rectangle(h->mvd_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx-mpx,my-mpy), 4);
fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx,my), 4);
}else
fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, 0, 4);
}
}
else if(IS_16X8(mb_type)){
for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
int ref;
if(h->ref_count[list] > 1){
ref= decode_cabac_mb_ref( h, list, 8*i );
if(ref >= (unsigned)h->ref_count[list]){
av_log(s->avctx, AV_LOG_ERROR, "Reference %d >= %d\n", ref, h->ref_count[list]);
return -1;
}
}else
ref=0;
fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, ref, 1);
}else
fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, (LIST_NOT_USED&0xFF), 1);
}
}
for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
pred_16x8_motion(h, 8*i, list, h->ref_cache[list][scan8[0] + 16*i], &mpx, &mpy);
mx = mpx + decode_cabac_mb_mvd( h, list, 8*i, 0 );
my = mpy + decode_cabac_mb_mvd( h, list, 8*i, 1 );
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(mx-mpx,my-mpy), 4);
fill_rectangle(h->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(mx,my), 4);
}else{
fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, 0, 4);
fill_rectangle(h-> mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, 0, 4);
}
}
}
}else{
assert(IS_8X16(mb_type));
for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
int ref;
if(h->ref_count[list] > 1){
ref= decode_cabac_mb_ref( h, list, 4*i );
if(ref >= (unsigned)h->ref_count[list]){
av_log(s->avctx, AV_LOG_ERROR, "Reference %d >= %d\n", ref, h->ref_count[list]);
return -1;
}
}else
ref=0;
fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, ref, 1);
}else
fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, (LIST_NOT_USED&0xFF), 1);
}
}
for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
pred_8x16_motion(h, i*4, list, h->ref_cache[list][ scan8[0] + 2*i ], &mpx, &mpy);
mx = mpx + decode_cabac_mb_mvd( h, list, 4*i, 0 );
my = mpy + decode_cabac_mb_mvd( h, list, 4*i, 1 );
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(mx-mpx,my-mpy), 4);
fill_rectangle(h->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(mx,my), 4);
}else{
fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, 0, 4);
fill_rectangle(h-> mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, 0, 4);
}
}
}
}
}
if( IS_INTER( mb_type ) ) {
h->chroma_pred_mode_table[mb_xy] = 0;
write_back_motion( h, mb_type );
}
if( !IS_INTRA16x16( mb_type ) ) {
cbp = decode_cabac_mb_cbp_luma( h );
if(CHROMA)
cbp |= decode_cabac_mb_cbp_chroma( h ) << 4;
}
h->cbp_table[mb_xy] = h->cbp = cbp;
if( dct8x8_allowed && (cbp&15) && !IS_INTRA( mb_type ) ) {
if( decode_cabac_mb_transform_size( h ) )
mb_type |= MB_TYPE_8x8DCT;
}
s->current_picture.mb_type[mb_xy]= mb_type;
if( cbp || IS_INTRA16x16( mb_type ) ) {
const uint8_t *scan, *scan8x8, *dc_scan;
const uint32_t *qmul;
int dqp;
if(IS_INTERLACED(mb_type)){
scan8x8= s->qscale ? h->field_scan8x8 : h->field_scan8x8_q0;
scan= s->qscale ? h->field_scan : h->field_scan_q0;
dc_scan= luma_dc_field_scan;
}else{
scan8x8= s->qscale ? h->zigzag_scan8x8 : h->zigzag_scan8x8_q0;
scan= s->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
dc_scan= luma_dc_zigzag_scan;
}
h->last_qscale_diff = dqp = decode_cabac_mb_dqp( h );
if( dqp == INT_MIN ){
av_log(h->s.avctx, AV_LOG_ERROR, "cabac decode of qscale diff failed at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
s->qscale += dqp;
if(((unsigned)s->qscale) > 51){
if(s->qscale<0) s->qscale+= 52;
else s->qscale-= 52;
}
h->chroma_qp[0] = get_chroma_qp(h, 0, s->qscale);
h->chroma_qp[1] = get_chroma_qp(h, 1, s->qscale);
if( IS_INTRA16x16( mb_type ) ) {
int i;
decode_cabac_residual( h, h->mb, 0, 0, dc_scan, NULL, 16);
if( cbp&15 ) {
qmul = h->dequant4_coeff[0][s->qscale];
for( i = 0; i < 16; i++ ) {
decode_cabac_residual(h, h->mb + 16*i, 1, i, scan + 1, qmul, 15);
}
} else {
fill_rectangle(&h->non_zero_count_cache[scan8[0]], 4, 4, 8, 0, 1);
}
} else {
int i8x8, i4x4;
for( i8x8 = 0; i8x8 < 4; i8x8++ ) {
if( cbp & (1<<i8x8) ) {
if( IS_8x8DCT(mb_type) ) {
decode_cabac_residual(h, h->mb + 64*i8x8, 5, 4*i8x8,
scan8x8, h->dequant8_coeff[IS_INTRA( mb_type ) ? 0:1][s->qscale], 64);
} else {
qmul = h->dequant4_coeff[IS_INTRA( mb_type ) ? 0:3][s->qscale];
for( i4x4 = 0; i4x4 < 4; i4x4++ ) {
const int index = 4*i8x8 + i4x4;
decode_cabac_residual(h, h->mb + 16*index, 2, index, scan, qmul, 16);
}
}
} else {
uint8_t * const nnz= &h->non_zero_count_cache[ scan8[4*i8x8] ];
nnz[0] = nnz[1] = nnz[8] = nnz[9] = 0;
}
}
}
if( cbp&0x30 ){
int c;
for( c = 0; c < 2; c++ ) {
decode_cabac_residual(h, h->mb + 256 + 16*4*c, 3, c, chroma_dc_scan, NULL, 4);
}
}
if( cbp&0x20 ) {
int c, i;
for( c = 0; c < 2; c++ ) {
qmul = h->dequant4_coeff[c+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[c]];
for( i = 0; i < 4; i++ ) {
const int index = 16 + 4 * c + i;
decode_cabac_residual(h, h->mb + 16*index, 4, index, scan + 1, qmul, 15);
}
}
} else {
uint8_t * const nnz= &h->non_zero_count_cache[0];
nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] =
nnz[ scan8[20]+0 ] = nnz[ scan8[20]+1 ] =nnz[ scan8[20]+8 ] =nnz[ scan8[20]+9 ] = 0;
}
} else {
uint8_t * const nnz= &h->non_zero_count_cache[0];
fill_rectangle(&nnz[scan8[0]], 4, 4, 8, 0, 1);
nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] =
nnz[ scan8[20]+0 ] = nnz[ scan8[20]+1 ] =nnz[ scan8[20]+8 ] =nnz[ scan8[20]+9 ] = 0;
h->last_qscale_diff = 0;
}
s->current_picture.qscale_table[mb_xy]= s->qscale;
write_back_non_zero_count(h);
if(MB_MBAFF){
h->ref_count[0] >>= 1;
h->ref_count[1] >>= 1;
}
return 0;
}
| 1threat |
Creating new database in DataGrip JetBrains : <p>Anybody know how to create new database in <strong><a href="https://goo.gl/99xqGb" rel="noreferrer">DataGrip</a></strong> (database IDE from JetBrains)?
Could not find in <a href="https://goo.gl/pnFpGS" rel="noreferrer">DataGrip Help page</a>.</p>
| 0debug |
Why do we need service layer? : <p>I'm currently learning Spring Boot and I've seen how people create a controller, inject the service class and in the service class inject the repository.</p>
<p>Why do we need the service class as a middleman and why can't we just inject the repository into controller?</p>
<p>Here's the tutorial that confused me: <a href="https://www.youtube.com/watch?v=lpcOSXWPXTk&list=PLqq-6Pq4lTTbx8p2oCgcAQGQyqN8XeA1x" rel="noreferrer">https://www.youtube.com/watch?v=lpcOSXWPXTk&list=PLqq-6Pq4lTTbx8p2oCgcAQGQyqN8XeA1x</a></p>
| 0debug |
Uncaught ReflectionException: Class log does not exist Laravel 5.2 : <p>I am currently trying to clone an existing project of mine from github. After clone I run <code>composer install</code> during the process I receive the following error:</p>
<p><code>Uncaught ReflectionException: Class log does not exist</code></p>
<p>I am running Laravel 5.2 on Centos 7. </p>
<p>I have seen references to: </p>
<ul>
<li>Removing spaces within the <code>.env</code> file. </li>
<li>Removing the vendor directory & re-installing</li>
<li>Removing certain packages required in composer.json </li>
</ul>
<p>I have: </p>
<ul>
<li>Replaced my <code>.env</code> with the <code>example.env</code> to avoid any custom config errors. </li>
<li>I have removed & re-cloned the repo. </li>
<li>I have used the default <code>composer.json</code> shipped with Laravel to see if that makes a difference. </li>
</ul>
<p>None of the above have brought me any joy. I also have the same environment set up on another machine with the application working fine. The only difference here is the machine (working) wasn't cloned from git - it was the initial build environment. </p>
<p>The stack trace I am receiving: </p>
<pre><code>PHP Fatal error: Uncaught ReflectionException: Class log does not exist in /var/www/html/Acme/vendor/laravel/framework/src/Illuminate/Container/Container.php:736
Stack trace:
#0 /var/www/html/Acme/vendor/laravel/framework/src/Illuminate/Container/Container.php(736): ReflectionClass->__construct('log')
#1 /var/www/html/Acme/vendor/laravel/framework/src/Illuminate/Container/Container.php(631): Illuminate\Container\Container->build('log', Array)
#2 /var/www/html/Acme/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(674): Illuminate\Container\Container->make('log', Array)
#3 /var/www/html/Acme/vendor/laravel/framework/src/Illuminate/Container/Container.php(845): Illuminate\Foundation\Application->make('log')
#4 /var/www/html/Acme/vendor/laravel/framework/src/Illuminate/Container/Container.php(800): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#5 /var/www/html/Acme/vendor/laravel/framework/src/Illuminate/Container/Container.php(769): Illuminate\Container\Container->getDependenc in /var/www/html/Acme/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 736
</code></pre>
<p>Any help would be much appreciated. Thanks in advance. </p>
| 0debug |
install opencv3 on mac for python 3.6 : <p>I want to install opencv3 for python 3.6 on macOS Sierra. I have tried to use it through homebrew using this link
<a href="http://www.pyimagesearch.com/2016/12/19/install-opencv-3-on-macos-with-homebrew-the-easy-way/" rel="noreferrer">http://www.pyimagesearch.com/2016/12/19/install-opencv-3-on-macos-with-homebrew-the-easy-way/</a> but I am getting this error </p>
<pre><code>Error: opencv3: Does not support building both Python 2 and 3 wrappers
</code></pre>
<p>How to resolve this??</p>
| 0debug |
delete data using ajax and codegniter : i have problem in deleting data using ajax i tried first to test if i click the button to make alert action so it not work so please help me
**this is my controller code**
public function indexajax()
{
$this->load->model("usersmodel");
$data["allu"]=$this->usersmodel->ShowAllUsers("users");
$data['pagetitle']=" -->All Users Using Ajax<--";
$this->load->view("template/admin/header",$data);
$this->load->view("users/allusersusingajax");
$this->load->view("template/admin/footer");
}
public function get_all_users()
{
if($this->input->post("action")=='FetchAllUserUingAjax1'){
$this->load->model("usersmodel");
$x= $data["allu"]=$this->usersmodel->ShowAllUsers("users");
foreach ($x as $a):
echo'<tr>
<td>'.$a->id.'</td>
<td>'.$a->username.'</td>
<td><button class="deletenew" id="'.$a->id.'">delete</button></td>
</tr>';
endforeach;
}
public function deleteusers()
{
$id=$this->input->post("id");
$this->load->model("usersmodel");
$this->usersmodel->deleteusers($id);
}
**this is my model code for deleting**
public function deleteusers($id)
{
$this->db->where('id',$id);
if($this->db->delete("users")){
return true;
}else{
return false;
}
}
**/**************this is view page *****/**
<div class="userdataajax table-responsive">
<table class=" table table-responsive table-bordered">
<tr>
<th>#</th>
<th>name</th>
<th>image</th>
<th> full name</th>
<th>email</th>
<th>usertype</th>
<th>status</th>
<th>reg date</th>
<th>reg time</th>
<th>delete</th>
<th>edit</th>
<th>Activate</th>
<th>disactivate</th>
</tr>
</table>
</div>
<script>
$(document).ready(function () {
FetchAllUserUingAjax();
function FetchAllUserUingAjax() {
$.ajax({
url:'<?php echo base_url()?>Users/get_all_users',
method:"post",
success:function (data) {
$(".userdataajax table").append(data);
}
})
var action="FetchAllUserUingAjax1";
$.ajax({
url:"<?php echo base_url()?>Users/get_all_users",
method:"post",
data:{action:action},
success:function (data) {
$(".userdataajax table tr").not("table
tr:first").remove();
$(".userdataajax table").append(data);
Table();
}
})
};
$(".deletenew").on("click",function () {
alert("engex");//this alert not working
var id=$(this).attr('id');
$.ajax({
url:"<?php echo base_url()?>Users/deleteusers",
method:"post",
data:{id:id},
success:function () {
alert("deleted");
FetchAllUserUingAjax();
}
})
})
})
</script>
**// but if i remove foreach *(foreach)* from controller and put it in view page delete is working i want to know what is my problem**
| 0debug |
Convert a string in code in Java : <p>I'm trying to convert a string in code in Java, but i have no idea how to do it or if it is possible.</p>
<p>This is my Java code (Measure is an other class I have created)</p>
<pre><code>String str= "Measure m = new Measure(10,1);";
</code></pre>
<p>Is it possible to run the code in the string?</p>
| 0debug |
Is there way to dynamically click bind every word in a div : <p>I am trying to bind every word in an element without actually changing the markup in the element with Javascript</p>
| 0debug |
Is it ok to use "async" with a ThreadStart method? : <p>I have a Windows Service that uses Thread and SemaphoreSlim to perform some "work" every 60 seconds.</p>
<pre><code>class Daemon
{
private SemaphoreSlim _semaphore;
private Thread _thread;
public void Stop()
{
_semaphore.Release();
_thread.Join();
}
public void Start()
{
_semaphore = new SemaphoreSlim(0);
_thread = new Thread(DoWork);
_thread.Start();
}
private void DoWork()
{
while (true)
{
// Do some work here
// Wait for 60 seconds, or exit if the Semaphore is released
if (_semaphore.Wait(60 * 1000))
{
return;
}
}
}
}
</code></pre>
<p>I'd like to call an asynchronous method from <code>DoWork</code>. In order to use the <code>await</code> keyword I must add <code>async</code> to <code>DoWork</code>:</p>
<pre><code>private async void DoWork()
</code></pre>
<ol>
<li>Is there any reason not to do this?</li>
<li>Is DoWork actually able to run asynchronously, if it's already running inside a dedicated thread?</li>
</ol>
| 0debug |
In-app purchases: Share user In-App purchases between Android and iOS : <p>I'm planning to add In-App purchases to my Productivity app. Enhanced features are purchase products (e.g., freemium).
I would like to have user access to purchased feature on both Android and iOS, if he has purchased on any one platform. Technically I plan to store purchase information on server and have it retrieved whenever user logs-in on either device, and unlock the feature if already purchased.</p>
<p>Is this allowed in both iOS and Android?</p>
<p>Apple <a href="https://developer.apple.com/app-store/review/guidelines/#purchasing-currencies" rel="noreferrer">App Store Review Guidelines</a> on Section 11 have this explained.<br>
Points "11.1/11.2" and "11.14" sounds conflicting (or I'm missing something.).</p>
<p>On Android, I do not see this point mentioning in <a href="https://play.google.com/about/monetization.html#payments" rel="noreferrer">Policies</a>.</p>
<p>If you had any experiences (w.r.t sharing purchase info between devices) that I should take care additionally, any suggestions are welcome. </p>
| 0debug |
void program_interrupt(CPUS390XState *env, uint32_t code, int ilen)
{
S390CPU *cpu = s390_env_get_cpu(env);
qemu_log_mask(CPU_LOG_INT, "program interrupt at %#" PRIx64 "\n",
env->psw.addr);
if (kvm_enabled()) {
kvm_s390_program_interrupt(cpu, code);
} else if (tcg_enabled()) {
tcg_s390_program_interrupt(env, code, ilen);
} else {
g_assert_not_reached();
}
}
| 1threat |
Linux - search trough specific file types for a keyword : I am using Mac OS terminal (similar to Linux) and trying to find best way to search inside all files on a computer that has extension *.py
What is the best way to achieve this?
I wanted to put 1 keyword for search and quickly show the whole path of these python files are that contain requested keyword in them..
Thanks! | 0debug |
java if statement check not working : Whenever I run this code with a negative number for the first int it keeps running the code even though I have an if statement that checks for this.
import java.util.Scanner;
public static void main(String[] args) {
int a,b,c;
double r1, r2, d;
Scanner s = new Scanner(System.in);
System.out.println("Enter the coefficients of the equation: ");
System.out.println("Enter a: ");
a = s.nextInt();
System.out.println("Enter b: ");
b = s.nextInt();
System.out.println("Enter c: ");
c = s.nextInt();
if(a <= 0) {
System.out.println("Error: " +"'a'" +" cannot be less than 1");
}
else {
}
System.out.println("Given dquadratic equation:" + a + "x^2 + " + b + "x + " + c + ",");
d = b * b - 4 * a * c;
if(d > 0) {
System.out.println("Roots are real and unequal");
r1 = (-b + Math.sqrt(d)/(2*a));
r2 = (-b + Math.sqrt(d)/(2*a));
System.out.println("Root 1: " + r1);
System.out.println("Root 2: " + r2);
}
else if(d == 0){
System.out.println("Roots are real and equal");
r1 = (-b + Math.sqrt(d)/(2*a));
System.out.println("Root 1: " + r1);
}
else {
System.out.println("Roots are imaginary");
}
}
} | 0debug |
How to properly exit firebase-admin nodejs script when all transaction is completed : <p>Is there anyway to check if all firebase transaction is completed in firebase-admin nodejs script, and properly disconnect from firebase and exit the nodejs script?</p>
<p>Currently, the firebase-admin nodejs script will just keep running even after all the transaction has been completed.</p>
| 0debug |
Docker not found when building docker image using Docker Jenkins container pipeline : <p>I have a Jenkins running as a docker container, now I want to build a Docker image using pipeline, but Jenkins container always tells Docker not found.</p>
<pre><code>[simple-tdd-pipeline] Running shell script
+ docker build -t simple-tdd .
/var/jenkins_home/workspace/simple-tdd-pipeline@tmp/durable-
ebc35179/script.sh: 2: /var/jenkins_home/workspace/simple-tdd-
pipeline@tmp/durable-ebc35179/script.sh: docker: not found
</code></pre>
<p>Here is how I run my Jenkins image:</p>
<pre><code>docker run --name myjenkins -p 8080:8080 -p 50000:50000 -v
/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock
jenkins
</code></pre>
<p>And the DockerFile of Jenkins image is:
<a href="https://github.com/jenkinsci/docker/blob/9f29488b77c2005bbbc5c936d47e697689f8ef6e/Dockerfile" rel="noreferrer">https://github.com/jenkinsci/docker/blob/9f29488b77c2005bbbc5c936d47e697689f8ef6e/Dockerfile</a></p>
| 0debug |
static void pci_bridge_cleanup_alias(MemoryRegion *alias,
MemoryRegion *parent_space)
{
memory_region_del_subregion(parent_space, alias);
memory_region_destroy(alias);
}
| 1threat |
static inline void ls_decode_line(JLSState *state, MJpegDecodeContext *s,
void *last, void *dst, int last2, int w,
int stride, int comp, int bits)
{
int i, x = 0;
int Ra, Rb, Rc, Rd;
int D0, D1, D2;
while (x < w) {
int err, pred;
Ra = x ? R(dst, x - stride) : R(last, x);
Rb = R(last, x);
Rc = x ? R(last, x - stride) : last2;
Rd = (x >= w - stride) ? R(last, x) : R(last, x + stride);
D0 = Rd - Rb;
D1 = Rb - Rc;
D2 = Rc - Ra;
if ((FFABS(D0) <= state->near) &&
(FFABS(D1) <= state->near) &&
(FFABS(D2) <= state->near)) {
int r;
int RItype;
while (get_bits1(&s->gb)) {
int r;
r = 1 << ff_log2_run[state->run_index[comp]];
if (x + r * stride > w)
r = (w - x) / stride;
for (i = 0; i < r; i++) {
W(dst, x, Ra);
x += stride;
}
if (r != 1 << ff_log2_run[state->run_index[comp]])
if (state->run_index[comp] < 31)
state->run_index[comp]++;
if (x + stride > w)
}
r = ff_log2_run[state->run_index[comp]];
if (r)
r = get_bits_long(&s->gb, r);
if (x + r * stride > w) {
r = (w - x) / stride;
}
for (i = 0; i < r; i++) {
W(dst, x, Ra);
x += stride;
}
if (x >= w) {
av_log(NULL, AV_LOG_ERROR, "run overflow\n");
av_assert0(x <= w);
}
Rb = R(last, x);
RItype = (FFABS(Ra - Rb) <= state->near) ? 1 : 0;
err = ls_get_code_runterm(&s->gb, state, RItype,
ff_log2_run[state->run_index[comp]]);
if (state->run_index[comp])
state->run_index[comp]--;
if (state->near && RItype) {
pred = Ra + err;
} else {
if (Rb < Ra)
pred = Rb - err;
else
pred = Rb + err;
}
} else {
int context, sign;
context = ff_jpegls_quantize(state, D0) * 81 +
ff_jpegls_quantize(state, D1) * 9 +
ff_jpegls_quantize(state, D2);
pred = mid_pred(Ra, Ra + Rb - Rc, Rb);
if (context < 0) {
context = -context;
sign = 1;
} else {
sign = 0;
}
if (sign) {
pred = av_clip(pred - state->C[context], 0, state->maxval);
err = -ls_get_code_regular(&s->gb, state, context);
} else {
pred = av_clip(pred + state->C[context], 0, state->maxval);
err = ls_get_code_regular(&s->gb, state, context);
}
pred += err;
}
if (state->near) {
if (pred < -state->near)
pred += state->range * state->twonear;
else if (pred > state->maxval + state->near)
pred -= state->range * state->twonear;
pred = av_clip(pred, 0, state->maxval);
}
pred &= state->maxval;
W(dst, x, pred);
x += stride;
}
} | 1threat |
Get free image for commercial distribution google : i would like to get image using Google api in my app, i want to get, based on some keywords, only free image for commercial use, is it possible? Have i to Credit Google? Or image owner? Can i download the image?
<code>foreach ($images as $i) {
$image = rawurlencode($i);
$query = "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=".$image."&imgsz=large&as_filetype=jpg";
$json = get_url_contents($query);
$data = json_decode($json);
$results = array(); //define array here!
foreach ($data->responseData->results as $result) {
$results[] = array("url" => $result->url, "alt" => $result->title);
}
echo $results[0]['url'];
echo "<br />";
echo $query;
echo "<br />";
}</code> | 0debug |
Find the highest value with the given constraints (Python) : c = [416,585,464]
A0 = [100,50,200]
A1 = [100,100,200]
A2 = [100,150,100]
A3 = [100,200,0]
A4 = [100,250,0]
b = [300,300,300,300,300]
for num in A0,A1,A2,A3,A4:
t0 = num[0]*1 + num[1]*1 + num[2]*1
t1 = num[0]*0 + num[1]*1 + num[2]*0
t2 = num[0]*0 + num[1]*0 + num[2]*0
t3 = num[0]*0 + num[1]*0 + num[2]*1
t4 = num[0]*1 + num[1]*0 + num[2]*0
t5 = num[0]*0 + num[1]*1 + num[2]*1
t6 = num[0]*1 + num[1]*1 + num[2]*0
t7 = num[0]*1 + num[1]*0 + num[2]*1
Now check each of the value in t0 against each of its corresponding value in the "b" array. If any of the values from t0 is greater than 300, then t0 is discarded. If not, then the nultiplied values to that t_ should be multiplied
with each corresponding "c" array value, and after that determine the highest value and print it. For ex: t1 has 50,100,150,200,250, all of which are equal to or below 300, so we take 0*c[0]+1*c[1]+0*c[2], which gives us 585. However, that isn't the highest value. The highest value is 1049, which is acquired by t5. It has 250,300,250,200,250. Taking 0*c[0]+1*c[1]+1*c[2]=1049
I am stuck here. | 0debug |
how work this insert and update with if statement query in mysql : SELECT IFNULL(post.id
,INSERT INTO post(pdate,body) VALUES (1,'a')
,UPDATE post set body='update',pdate=2
)
from post where body='a' and pdate=1 | 0debug |
RISC-V: Immediate Encoding Variants : <p>In the RISC-V Instruction Set Manual, User-Level ISA, I couldn't understand section 2.3 Immediate Encoding Variants page 11.</p>
<p>There is four types of instruction formats R, I, S, and U, then there is a variants of S and U types which are SB and UJ which I suppose mean Branch and Jump as shown in figure 2.3. Then there is the types of Immediate produced by RISC-V instructions shown in figure 2.4.</p>
<p>So my questions are, why the SB and UJ are needed? and why shuffle the Immediate bits in that way? what does it mean to say "the Immediate produced by RISC-V instructions"? and how are they produced in this manner?</p>
<p><a href="https://i.stack.imgur.com/Gkjuc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Gkjuc.png" alt="enter image description here"></a></p>
<p><a href="https://i.stack.imgur.com/IlZmZ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IlZmZ.png" alt="enter image description here"></a></p>
| 0debug |
window.location.href = 'http://attack.com?user=' + user_input; | 1threat |
int vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
const uint8_t *buf, int buf_size)
{
VP56Context *s = avctx->priv_data;
AVFrame *const p = s->framep[VP56_FRAME_CURRENT];
int remaining_buf_size = buf_size;
int is_alpha, alpha_offset;
if (s->has_alpha) {
alpha_offset = bytestream_get_be24(&buf);
remaining_buf_size -= 3;
}
for (is_alpha=0; is_alpha < 1+s->has_alpha; is_alpha++) {
int mb_row, mb_col, mb_row_flip, mb_offset = 0;
int block, y, uv, stride_y, stride_uv;
int golden_frame = 0;
int res;
s->modelp = &s->models[is_alpha];
res = s->parse_header(s, buf, remaining_buf_size, &golden_frame);
if (!res)
return -1;
if (!is_alpha) {
p->reference = 1;
if (avctx->get_buffer(avctx, p) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
if (res == 2)
if (vp56_size_changed(avctx)) {
avctx->release_buffer(avctx, p);
return -1;
}
}
if (p->key_frame) {
p->pict_type = FF_I_TYPE;
s->default_models_init(s);
for (block=0; block<s->mb_height*s->mb_width; block++)
s->macroblocks[block].type = VP56_MB_INTRA;
} else {
p->pict_type = FF_P_TYPE;
vp56_parse_mb_type_models(s);
s->parse_vector_models(s);
s->mb_type = VP56_MB_INTER_NOVEC_PF;
}
s->parse_coeff_models(s);
memset(s->prev_dc, 0, sizeof(s->prev_dc));
s->prev_dc[1][VP56_FRAME_CURRENT] = 128;
s->prev_dc[2][VP56_FRAME_CURRENT] = 128;
for (block=0; block < 4*s->mb_width+6; block++) {
s->above_blocks[block].ref_frame = VP56_FRAME_NONE;
s->above_blocks[block].dc_coeff = 0;
s->above_blocks[block].not_null_dc = 0;
}
s->above_blocks[2*s->mb_width + 2].ref_frame = VP56_FRAME_CURRENT;
s->above_blocks[3*s->mb_width + 4].ref_frame = VP56_FRAME_CURRENT;
stride_y = p->linesize[0];
stride_uv = p->linesize[1];
if (s->flip < 0)
mb_offset = 7;
for (mb_row=0; mb_row<s->mb_height; mb_row++) {
if (s->flip < 0)
mb_row_flip = s->mb_height - mb_row - 1;
else
mb_row_flip = mb_row;
for (block=0; block<4; block++) {
s->left_block[block].ref_frame = VP56_FRAME_NONE;
s->left_block[block].dc_coeff = 0;
s->left_block[block].not_null_dc = 0;
}
memset(s->coeff_ctx, 0, sizeof(s->coeff_ctx));
memset(s->coeff_ctx_last, 24, sizeof(s->coeff_ctx_last));
s->above_block_idx[0] = 1;
s->above_block_idx[1] = 2;
s->above_block_idx[2] = 1;
s->above_block_idx[3] = 2;
s->above_block_idx[4] = 2*s->mb_width + 2 + 1;
s->above_block_idx[5] = 3*s->mb_width + 4 + 1;
s->block_offset[s->frbi] = (mb_row_flip*16 + mb_offset) * stride_y;
s->block_offset[s->srbi] = s->block_offset[s->frbi] + 8*stride_y;
s->block_offset[1] = s->block_offset[0] + 8;
s->block_offset[3] = s->block_offset[2] + 8;
s->block_offset[4] = (mb_row_flip*8 + mb_offset) * stride_uv;
s->block_offset[5] = s->block_offset[4];
for (mb_col=0; mb_col<s->mb_width; mb_col++) {
vp56_decode_mb(s, mb_row, mb_col, is_alpha);
for (y=0; y<4; y++) {
s->above_block_idx[y] += 2;
s->block_offset[y] += 16;
}
for (uv=4; uv<6; uv++) {
s->above_block_idx[uv] += 1;
s->block_offset[uv] += 8;
}
}
}
if (p->key_frame || golden_frame) {
if (s->framep[VP56_FRAME_GOLDEN]->data[0] &&
s->framep[VP56_FRAME_GOLDEN] != s->framep[VP56_FRAME_GOLDEN2])
avctx->release_buffer(avctx, s->framep[VP56_FRAME_GOLDEN]);
s->framep[VP56_FRAME_GOLDEN] = p;
}
if (s->has_alpha) {
FFSWAP(AVFrame *, s->framep[VP56_FRAME_GOLDEN],
s->framep[VP56_FRAME_GOLDEN2]);
buf += alpha_offset;
remaining_buf_size -= alpha_offset;
}
}
if (s->framep[VP56_FRAME_PREVIOUS] == s->framep[VP56_FRAME_GOLDEN] ||
s->framep[VP56_FRAME_PREVIOUS] == s->framep[VP56_FRAME_GOLDEN2]) {
if (s->framep[VP56_FRAME_UNUSED] != s->framep[VP56_FRAME_GOLDEN] &&
s->framep[VP56_FRAME_UNUSED] != s->framep[VP56_FRAME_GOLDEN2])
FFSWAP(AVFrame *, s->framep[VP56_FRAME_PREVIOUS],
s->framep[VP56_FRAME_UNUSED]);
else
FFSWAP(AVFrame *, s->framep[VP56_FRAME_PREVIOUS],
s->framep[VP56_FRAME_UNUSED2]);
} else if (s->framep[VP56_FRAME_PREVIOUS]->data[0])
avctx->release_buffer(avctx, s->framep[VP56_FRAME_PREVIOUS]);
FFSWAP(AVFrame *, s->framep[VP56_FRAME_CURRENT],
s->framep[VP56_FRAME_PREVIOUS]);
*(AVFrame*)data = *p;
*data_size = sizeof(AVFrame);
return buf_size;
}
| 1threat |
static void onenand_reset(OneNANDState *s, int cold)
{
memset(&s->addr, 0, sizeof(s->addr));
s->command = 0;
s->count = 1;
s->bufaddr = 0;
s->config[0] = 0x40c0;
s->config[1] = 0x0000;
onenand_intr_update(s);
qemu_irq_raise(s->rdy);
s->status = 0x0000;
s->intstatus = cold ? 0x8080 : 0x8010;
s->unladdr[0] = 0;
s->unladdr[1] = 0;
s->wpstatus = 0x0002;
s->cycle = 0;
s->otpmode = 0;
s->bdrv_cur = s->bdrv;
s->current = s->image;
s->secs_cur = s->secs;
if (cold) {
memset(s->blockwp, ONEN_LOCK_LOCKED, s->blocks);
if (s->bdrv_cur && bdrv_read(s->bdrv_cur, 0, s->boot[0], 8) < 0) {
hw_error("%s: Loading the BootRAM failed.\n", __func__);
}
}
}
| 1threat |
Jenkins build and deploy seperately : I need help in configuring a jenkins job. I am able to deploy the code using mule mvn deploy command in a single job. Now i need to build the package and use the package to deploy it to multiple environments with out building it again. Can some one help me with that. I am able to package the code using mvn package. BUt when I want to deploy the build package I am using mvn deploy command and this is compiling and building the code. Can some one help me with this. Am I missing something
Thanks & Regards
Devi | 0debug |
XCode 8, Swift, Change background color of view with code : I have searched the entire internet for a proper solution to changing the background color of my MAC APPLICATION's single view,
in Swift code in the main storyboard.
Xcode 8 is a bitch and I can not find a solution.
I am just learning Swift and would really like to know how to do this!
Thanks. | 0debug |
static void curl_multi_check_completion(BDRVCURLState *s)
{
int msgs_in_queue;
do {
CURLMsg *msg;
msg = curl_multi_info_read(s->multi, &msgs_in_queue);
if (!msg)
break;
if (msg->msg == CURLMSG_NONE)
break;
switch (msg->msg) {
case CURLMSG_DONE:
{
CURLState *state = NULL;
curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE,
(char **)&state);
if (msg->data.result != CURLE_OK) {
int i;
for (i = 0; i < CURL_NUM_ACB; i++) {
CURLAIOCB *acb = state->acb[i];
if (acb == NULL) {
continue;
}
acb->common.cb(acb->common.opaque, -EIO);
qemu_aio_release(acb);
state->acb[i] = NULL;
}
}
curl_clean_state(state);
break;
}
default:
msgs_in_queue = 0;
break;
}
} while(msgs_in_queue);
}
| 1threat |
Finding sorted array index of closest int value : <p>I want to use a Lookup-table that contains 205887 positive int values. They are sorted from highest to lowest value.
I have a positive int value (int a). If I have that value inside the table, I want to receive the index (int b) of the value.
If that value does not exist inside the table, I want the index of the nearest-lower value.</p>
<p>This process is performance critical so I want it to be as fast as possible.</p>
<p>Is it possible to create an array with 2^31 values but only 205887 being initialized?
If yes, would that result in the table being roughly the same size of the one I described above?
If yes, could I find b by checking the index of this array with value a and add one to it until I find an initialized entry which contains my value b?</p>
<p>I am just a beginner at C# and could not find sufficient information in documents. Thanks in advance.</p>
| 0debug |
How do i get a gradient over my image? (link) : everything should be explained in this jsfiddle.<p>
***Im so sorry, but i cant get the link to show. Its in the comments!***<p>
I can´t get it to give me a red gradient over the image..
[1]: https://jsfiddle.net/s2moc0gt/2/ | 0debug |
static int wc3_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
Wc3DemuxContext *wc3 = s->priv_data;
ByteIOContext *pb = s->pb;
unsigned int fourcc_tag;
unsigned int size;
int packet_read = 0;
int ret = 0;
unsigned char preamble[WC3_PREAMBLE_SIZE];
unsigned char text[1024];
unsigned int palette_number;
int i;
unsigned char r, g, b;
int base_palette_index;
while (!packet_read) {
if ((ret = get_buffer(pb, preamble, WC3_PREAMBLE_SIZE)) !=
WC3_PREAMBLE_SIZE)
ret = AVERROR(EIO);
fourcc_tag = AV_RL32(&preamble[0]);
size = (AV_RB32(&preamble[4]) + 1) & (~1);
switch (fourcc_tag) {
case BRCH_TAG:
break;
case SHOT_TAG:
if ((ret = get_buffer(pb, preamble, 4)) != 4)
return AVERROR(EIO);
palette_number = AV_RL32(&preamble[0]);
if (palette_number >= wc3->palette_count)
return AVERROR_INVALIDDATA;
base_palette_index = palette_number * PALETTE_COUNT * 3;
for (i = 0; i < PALETTE_COUNT; i++) {
r = wc3->palettes[base_palette_index + i * 3 + 0];
g = wc3->palettes[base_palette_index + i * 3 + 1];
b = wc3->palettes[base_palette_index + i * 3 + 2];
wc3->palette_control.palette[i] = (r << 16) | (g << 8) | (b);
}
wc3->palette_control.palette_changed = 1;
break;
case VGA__TAG:
ret= av_get_packet(pb, pkt, size);
pkt->stream_index = wc3->video_stream_index;
pkt->pts = wc3->pts;
if (ret != size)
ret = AVERROR(EIO);
packet_read = 1;
break;
case TEXT_TAG:
#if 0
url_fseek(pb, size, SEEK_CUR);
#else
if ((unsigned)size > sizeof(text) || (ret = get_buffer(pb, text, size)) != size)
ret = AVERROR(EIO);
else {
int i = 0;
av_log (s, AV_LOG_DEBUG, "Subtitle time!\n");
av_log (s, AV_LOG_DEBUG, " inglish: %s\n", &text[i + 1]);
i += text[i] + 1;
av_log (s, AV_LOG_DEBUG, " doytsch: %s\n", &text[i + 1]);
i += text[i] + 1;
av_log (s, AV_LOG_DEBUG, " fronsay: %s\n", &text[i + 1]);
}
#endif
break;
case AUDI_TAG:
ret= av_get_packet(pb, pkt, size);
pkt->stream_index = wc3->audio_stream_index;
pkt->pts = wc3->pts;
if (ret != size)
ret = AVERROR(EIO);
wc3->pts++;
packet_read = 1;
break;
default:
av_log (s, AV_LOG_ERROR, " unrecognized WC3 chunk: %c%c%c%c (0x%02X%02X%02X%02X)\n",
preamble[0], preamble[1], preamble[2], preamble[3],
preamble[0], preamble[1], preamble[2], preamble[3]);
ret = AVERROR_INVALIDDATA;
packet_read = 1;
break;
}
}
return ret;
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.