problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
Remove all numbers which are lower than 15 using preg_replace : <p>I'm trying to remove numbers which are lower than '15' using preg_replace for example:
<code>$string = '1 20 5 16 11 15 14';</code>
I'm expecting the output after preg_replace to be <code>20 16 15</code>
How to do that :)</p>
| 0debug |
Should the data be calculated in DB server or in CGI process? Which way is better? : <p>So I am an green hand, when I am coding, I always think that should the data be calculated (for example , in MYSQL, I need to do calculation in script which including 'group by') in DB server or in the CGI procedure? Which way is more better and more efficient? </p>
<p>Actually this stuff confuse me such a long time..</p>
<p>By the way, recently I use PHP coding in my work.</p>
| 0debug |
static uint64_t calc_rice_params(RiceContext *rc,
uint32_t udata[FLAC_MAX_BLOCKSIZE],
uint64_t sums[32][MAX_PARTITIONS],
int pmin, int pmax,
const int32_t *data, int n, int pred_order, int exact)
{
int i;
uint64_t bits[MAX_PARTITION_ORDER+1];
int opt_porder;
RiceContext tmp_rc;
int kmax = (1 << rc->coding_mode) - 2;
av_assert1(pmin >= 0 && pmin <= MAX_PARTITION_ORDER);
av_assert1(pmax >= 0 && pmax <= MAX_PARTITION_ORDER);
av_assert1(pmin <= pmax);
tmp_rc.coding_mode = rc->coding_mode;
for (i = 0; i < n; i++)
udata[i] = (2 * data[i]) ^ (data[i] >> 31);
calc_sum_top(pmax, exact ? kmax : 0, udata, n, pred_order, sums);
opt_porder = pmin;
bits[pmin] = UINT32_MAX;
for (i = pmax; ; ) {
bits[i] = calc_optimal_rice_params(&tmp_rc, i, sums, n, pred_order, kmax, exact);
if (bits[i] < bits[opt_porder]) {
opt_porder = i;
*rc = tmp_rc;
}
if (i == pmin)
break;
calc_sum_next(--i, sums, exact ? kmax : 0);
}
return bits[opt_porder];
}
| 1threat |
BATCH - Verification System (READ DESC) : So basically I have this batch program. I want a verification system were you type the code, and it lets you continue. If you type the wrong code it won't let you continue. Anyone got a code I can use for this? | 0debug |
React-Redux: Should all component states be kept in Redux Store : <p>Say I have a simple toggle:</p>
<p>
</p>
<p>When I click the button, the Color component changes between red and blue</p>
<p>I might achieve this result by doing something like this.</p>
<p>index.js</p>
<pre><code>Button: onClick={()=>{dispatch(changeColor())}}
Color: this.props.color ? blue : red
</code></pre>
<p>container.js</p>
<pre><code>connect(mapStateToProps)(indexPage)
</code></pre>
<p>action_creator.js</p>
<pre><code>function changeColor(){
return {type: 'CHANGE_COLOR'}
}
</code></pre>
<p>reducer.js</p>
<pre><code>switch(){
case 'CHANGE_COLOR':
return {color: true}
</code></pre>
<p>but this is a hell of a lot of code to write for something that I could have achieved in 5 seconds with jQuery, some classes, and some css...</p>
<p>So I guess what I'm really asking is, what am I doing wrong here?</p>
| 0debug |
static void moxiesim_init(MachineState *machine)
{
MoxieCPU *cpu = NULL;
ram_addr_t ram_size = machine->ram_size;
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
CPUMoxieState *env;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *rom = g_new(MemoryRegion, 1);
hwaddr ram_base = 0x200000;
LoaderParams loader_params;
if (cpu_model == NULL) {
cpu_model = "MoxieLite-moxie-cpu";
}
cpu = MOXIE_CPU(cpu_generic_init(TYPE_MOXIE_CPU, cpu_model));
if (!cpu) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
env = &cpu->env;
qemu_register_reset(main_cpu_reset, cpu);
memory_region_init_ram(ram, NULL, "moxiesim.ram", ram_size, &error_fatal);
memory_region_add_subregion(address_space_mem, ram_base, ram);
memory_region_init_ram(rom, NULL, "moxie.rom", 128 * 0x1000, &error_fatal);
memory_region_add_subregion(get_system_memory(), 0x1000, rom);
if (kernel_filename) {
loader_params.ram_size = ram_size;
loader_params.kernel_filename = kernel_filename;
loader_params.kernel_cmdline = kernel_cmdline;
loader_params.initrd_filename = initrd_filename;
load_kernel(cpu, &loader_params);
}
if (serial_hds[0]) {
serial_mm_init(address_space_mem, 0x3f8, 0, env->irq[4],
8000000/16, serial_hds[0], DEVICE_LITTLE_ENDIAN);
}
}
| 1threat |
Dagger 2: Unable to inject singleton in other scope : <p>I have Singleton scoped module that provides some standard singletons: Application, DB services, etc.
But for Activity I have separate module that should create Presenter for he Activity and I need to pass Application context to it. However I get following error when trying to compile the project:</p>
<pre><code>Error:(13, 1) error: xxx.SplashComponent scoped with @xxx.ViewScope may not reference bindings with different scopes:
@Provides @Singleton xxx.ApplicationModule.provideAppContext()
</code></pre>
<p>Here is snippet of my Application module:</p>
<pre><code>@Singleton
@Module
public class ApplicationModule {
private Application app;
public ApplicationModule(Application app) {
this.app = app;
}
@Provides
@Singleton
@Named("ui")
Scheduler provideUIScheduler() {
return AndroidSchedulers.mainThread();
}
@Provides
@Singleton
@Named("io")
Scheduler provideIOScheduler() {
return Schedulers.io();
}
@Provides
@Singleton
Application provideApplication() {
return app;
}
@Provides
@Singleton
Context provideAppContext() {
return app;
}
}
</code></pre>
<p>And here is Activity module and Component:</p>
<pre><code>@Module
public class SplashModule {
private final FragmentManager fragmentManager;
public SplashModule(FragmentManager fragmentManager) {
this.fragmentManager = fragmentManager;
}
@Provides
@ViewScope
Presenter getPresenter(Context context) {
return new SplashPresenter(context, fragmentManager);
}
}
</code></pre>
<p>Component:</p>
<pre><code>@ViewScope
@Component(modules = {SplashModule.class, ApplicationModule.class})
public interface SplashComponent {
void inject(SplashActivity activity);
}
</code></pre>
<p>What am I doing wrong?</p>
| 0debug |
Execute VB Module from C# : I've got a module in VB like this
Module Module1
Sub Main()
/* ..... */
End Sub
End Module
And I want to execute its `Main` from a project in C# | 0debug |
Data binding: set property if it isn't null : <p>Cannot understand... How to set some property of view only if variable field isn't null?
<br>For example</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="item"
type="com.test.app.Item" />
</data>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_margin="16dp"
android:src="@{item.getDrawable()}"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="16dp"
android:layout_marginLeft="72dp"
android:layout_marginRight="16dp"
android:layout_marginStart="72dp"
android:layout_toLeftOf="@id/action"
android:layout_toStartOf="@id/action"
android:orientation="vertical">
<TextView
android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="@color/black_87"
android:textSize="16sp"
android:text="@{item.getTitle()}"/>
<TextView
android:id="@+id/text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoLink="web|email"
android:linksClickable="false"
android:singleLine="true"
android:textColor="@color/black_54"
android:textSize="14sp"
android:text="@{item.getSubtitle()}"/>
</LinearLayout>
</RelativeLayout>
</layout>
</code></pre>
<p>Some field of Item can be null and I won't call methods of layout views unnecessarily. And I won't get <code>NullPointerException</code>. How can I set property only if it isn't null?
<br>P.S. Sorry for English.</p>
| 0debug |
how to compare string without case sensitive using c#? : <p>What is the best way to compare two string without case sensitive using c#?
Am using the below codes. </p>
<pre><code>string b = "b";
int c = string.Compare(a, b);
</code></pre>
| 0debug |
how get string from an array that is in arrayjson in android? : Is there anybody know that haw can I get string "num12" from this json array in android with JSONObject and JSONArray?
[{
"id": 7378,
"status": "publish",
"acf": {
"dars": [{
"title": "math",
"cat": "cat1",
"kind": "free",
"question": "num1"
},{
"title": "math2",
"cat": "cat12",
"kind": "free",
"question": "num12"
}]
}
}] | 0debug |
Symofny - curl return invalid request : I am using cashflows documentation with specified url to try to return test request but dump() returns this error..
> "V|99E5BB5DF59|000|V226|Invalid request\n"
or
> The controller must return a response (V|99E5BB5DFC6|000|V226|Invalid request
given).
My code..
// jSON URL which should be requested
$json_url = 'https://secure.cashflows.com/gateway/remote';
$username = '5949138'; // authentication
$password = 'Ad368w9XYw'; // authentication
// jSON String for request
$json_string = [
'amount' => 'amount',
'currency' => 'currency',
];
// Initializing curl
$ch = curl_init( $json_url );
// Configuring curl options
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => $username . ':' . $password, // authentication
CURLOPT_HTTPHEADER => array('Content-type: application/json') ,
CURLOPT_POSTFIELDS => $json_string,
);
// Setting curl options
curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');
curl_setopt_array( $ch, $options );
// Getting results
$result = curl_exec($ch); // Getting jSON result string
return $result;
I can't figure out what is causing the problem. | 0debug |
I need to get the text the user puts in the searchView to update the URL query. : So here i need to get the text the user enters into the searchview in order to be able to update the GOOGLE_BOOKS_REQUEST_URL
public class BookListingActivity extends AppCompatActivity implements LoaderCallbacks<List<BookListing>> {
private static final String LOG_TAG = BookListingActivity.class.getName();
/**
* This is the search the user does for the API query
*/
private String userQuery;
/**
* URL for book data from the google books dataset
*/
private String GOOGLE_BOOKS_REQUEST_URL =
"https://www.googleapis.com/books/v1/volumes?q=" + userQuery;
/**
* Constant value for the book loader ID. We can choose any integer.
* This really only comes into play if you're using multiple loaders.
*/
private static final int BOOK_LOADER_ID = 1;
/**
* Adapter for the list of books
*/
private BookListingAdapter mAdapter;
/**
* TextView that is displayed when the list is empty
*/
private TextView mEmptyStateTextView;
/**
* ProgressBar that is displayed when the list is loading
*/
private ProgressBar mProgressBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Find the searchView in which the query will be performed
SearchView query = (SearchView) findViewById(R.id.search_button);
query.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
| 0debug |
Fastest method to find map keys by vector in C++ : I'm looking for the faster method to extract the map values filtered by vector keys.
Below the standard code:
std::unordered_map<uint32, user> map;
std::vector<uint32> find;
std::vector<user> results;
auto it = map.begin();
while (it != map.end())
{
if (std::find(map.begin(), map.end(), it->first) == map.end())
results.push_back(it->second);
it++;
}
| 0debug |
document.location = 'http://evil.com?username=' + user_input; | 1threat |
static inline int64_t get_sector_offset(BlockDriverState *bs,
int64_t sector_num, int write)
{
BDRVVPCState *s = bs->opaque;
uint64_t offset = sector_num * 512;
uint64_t bitmap_offset, block_offset;
uint32_t pagetable_index, pageentry_index;
pagetable_index = offset / s->block_size;
pageentry_index = (offset % s->block_size) / 512;
if (pagetable_index >= s->max_table_entries || s->pagetable[pagetable_index] == 0xffffffff)
return -1;
bitmap_offset = 512 * (uint64_t) s->pagetable[pagetable_index];
block_offset = bitmap_offset + s->bitmap_size + (512 * pageentry_index);
if (write && (s->last_bitmap_offset != bitmap_offset)) {
uint8_t bitmap[s->bitmap_size];
s->last_bitmap_offset = bitmap_offset;
memset(bitmap, 0xff, s->bitmap_size);
bdrv_pwrite_sync(bs->file, bitmap_offset, bitmap, s->bitmap_size);
}
#if 0
#ifdef CACHE
if (bitmap_offset != s->last_bitmap)
{
lseek(s->fd, bitmap_offset, SEEK_SET);
s->last_bitmap = bitmap_offset;
read(s->fd, s->pageentry_u8, 512);
for (i = 0; i < 128; i++)
be32_to_cpus(&s->pageentry_u32[i]);
}
if ((s->pageentry_u8[pageentry_index / 8] >> (pageentry_index % 8)) & 1)
return -1;
#else
lseek(s->fd, bitmap_offset + (pageentry_index / 8), SEEK_SET);
read(s->fd, &bitmap_entry, 1);
if ((bitmap_entry >> (pageentry_index % 8)) & 1)
return -1;
#endif
#endif
return block_offset;
}
| 1threat |
static int decode_wdlt(GetByteContext *gb, uint8_t *frame, int width, int height)
{
const uint8_t *frame_end = frame + width * height;
uint8_t *line_ptr;
int count, i, v, lines, segments;
int y = 0;
lines = bytestream2_get_le16(gb);
if (lines > height)
return AVERROR_INVALIDDATA;
while (lines--) {
if (bytestream2_get_bytes_left(gb) < 2)
return AVERROR_INVALIDDATA;
segments = bytestream2_get_le16u(gb);
while ((segments & 0xC000) == 0xC000) {
unsigned skip_lines = -(int16_t)segments;
unsigned delta = -((int16_t)segments * width);
if (frame_end - frame <= delta || y + lines + skip_lines > height)
return AVERROR_INVALIDDATA;
frame += delta;
y += skip_lines;
segments = bytestream2_get_le16(gb);
}
if (frame_end <= frame)
return AVERROR_INVALIDDATA;
if (segments & 0x8000) {
frame[width - 1] = segments & 0xFF;
segments = bytestream2_get_le16(gb);
}
line_ptr = frame;
if (frame_end - frame < width)
return AVERROR_INVALIDDATA;
frame += width;
y++;
while (segments--) {
if (frame - line_ptr <= bytestream2_peek_byte(gb))
return AVERROR_INVALIDDATA;
line_ptr += bytestream2_get_byte(gb);
count = (int8_t)bytestream2_get_byte(gb);
if (count >= 0) {
if (frame - line_ptr < count * 2)
return AVERROR_INVALIDDATA;
if (bytestream2_get_buffer(gb, line_ptr, count * 2) != count * 2)
return AVERROR_INVALIDDATA;
line_ptr += count * 2;
} else {
count = -count;
if (frame - line_ptr < count * 2)
return AVERROR_INVALIDDATA;
v = bytestream2_get_le16(gb);
for (i = 0; i < count; i++)
bytestream_put_le16(&line_ptr, v);
}
}
}
return 0;
}
| 1threat |
How to generate odata v4 c# proxy client for Visual Studio 2017? : <p>Where can i get odata v4 c# proxy generator for Visual Studio 2017?
The existing one is for 2015 only. </p>
| 0debug |
Parallax effect whitespace : My parallax effect adds whitespace to the top when scrolling on page.
[No scroll,][1]
[When scrolling][2]
My JavaScript:
<script>
$(window).scroll(function() {
var scrolledY = $(window).scrollTop();
$('.bg').css('background-position', 'left ' + ((scrolledY)) + 'px');
});
</script>
[1]: https://i.stack.imgur.com/BBHw0.jpg
[2]: https://i.stack.imgur.com/0VMUh.jpg | 0debug |
static int mov_init(AVFormatContext *s)
{
MOVMuxContext *mov = s->priv_data;
AVDictionaryEntry *global_tcr = av_dict_get(s->metadata, "timecode", NULL, 0);
int i, ret;
mov->fc = s;
mov->mode = MODE_MP4;
if (s->oformat) {
if (!strcmp("3gp", s->oformat->name)) mov->mode = MODE_3GP;
else if (!strcmp("3g2", s->oformat->name)) mov->mode = MODE_3GP|MODE_3G2;
else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV;
else if (!strcmp("psp", s->oformat->name)) mov->mode = MODE_PSP;
else if (!strcmp("ipod",s->oformat->name)) mov->mode = MODE_IPOD;
else if (!strcmp("ismv",s->oformat->name)) mov->mode = MODE_ISM;
else if (!strcmp("f4v", s->oformat->name)) mov->mode = MODE_F4V;
}
if (mov->flags & FF_MOV_FLAG_DELAY_MOOV)
mov->flags |= FF_MOV_FLAG_EMPTY_MOOV;
if (mov->max_fragment_duration || mov->max_fragment_size ||
mov->flags & (FF_MOV_FLAG_EMPTY_MOOV |
FF_MOV_FLAG_FRAG_KEYFRAME |
FF_MOV_FLAG_FRAG_CUSTOM))
mov->flags |= FF_MOV_FLAG_FRAGMENT;
if (mov->mode == MODE_ISM)
mov->flags |= FF_MOV_FLAG_EMPTY_MOOV | FF_MOV_FLAG_SEPARATE_MOOF |
FF_MOV_FLAG_FRAGMENT;
if (mov->flags & FF_MOV_FLAG_DASH)
mov->flags |= FF_MOV_FLAG_FRAGMENT | FF_MOV_FLAG_EMPTY_MOOV |
FF_MOV_FLAG_DEFAULT_BASE_MOOF;
if (mov->flags & FF_MOV_FLAG_EMPTY_MOOV && s->flags & AVFMT_FLAG_AUTO_BSF) {
av_log(s, AV_LOG_VERBOSE, "Empty MOOV enabled; disabling automatic bitstream filtering\n");
s->flags &= ~AVFMT_FLAG_AUTO_BSF;
}
if (mov->flags & FF_MOV_FLAG_FASTSTART) {
mov->reserved_moov_size = -1;
}
if (mov->use_editlist < 0) {
mov->use_editlist = 1;
if (mov->flags & FF_MOV_FLAG_FRAGMENT &&
!(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) {
if (s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_AUTO ||
s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO)
mov->use_editlist = 0;
}
}
if (mov->flags & FF_MOV_FLAG_EMPTY_MOOV &&
!(mov->flags & FF_MOV_FLAG_DELAY_MOOV) && mov->use_editlist)
av_log(s, AV_LOG_WARNING, "No meaningful edit list will be written when using empty_moov without delay_moov\n");
if (!mov->use_editlist && s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_AUTO)
s->avoid_negative_ts = AVFMT_AVOID_NEG_TS_MAKE_ZERO;
if (mov->flags & FF_MOV_FLAG_OMIT_TFHD_OFFSET &&
mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF)
mov->flags &= ~FF_MOV_FLAG_OMIT_TFHD_OFFSET;
if (mov->frag_interleave &&
mov->flags & (FF_MOV_FLAG_OMIT_TFHD_OFFSET | FF_MOV_FLAG_SEPARATE_MOOF)) {
av_log(s, AV_LOG_ERROR,
"Sample interleaving in fragments is mutually exclusive with "
"omit_tfhd_offset and separate_moof\n");
return AVERROR(EINVAL);
}
if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL) &&
(!(mov->flags & FF_MOV_FLAG_FRAGMENT) || mov->ism_lookahead)) {
av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n");
return AVERROR(EINVAL);
}
mov->nb_streams = s->nb_streams;
if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && s->nb_chapters)
mov->chapter_track = mov->nb_streams++;
if (mov->flags & FF_MOV_FLAG_RTP_HINT) {
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ||
st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
mov->nb_streams++;
}
}
}
if ( mov->write_tmcd == -1 && (mov->mode == MODE_MOV || mov->mode == MODE_MP4)
|| mov->write_tmcd == 1) {
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
AVDictionaryEntry *t = global_tcr;
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
(t || (t=av_dict_get(st->metadata, "timecode", NULL, 0)))) {
AVTimecode tc;
ret = mov_check_timecode_track(s, &tc, i, t->value);
if (ret >= 0)
mov->nb_meta_tmcd++;
}
}
if (mov->nb_meta_tmcd) {
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (st->codecpar->codec_tag == MKTAG('t','m','c','d')) {
av_log(s, AV_LOG_WARNING, "You requested a copy of the original timecode track "
"so timecode metadata are now ignored\n");
mov->nb_meta_tmcd = 0;
}
}
}
mov->nb_streams += mov->nb_meta_tmcd;
}
mov->tracks = av_mallocz_array((mov->nb_streams + 1), sizeof(*mov->tracks));
if (!mov->tracks)
return AVERROR(ENOMEM);
if (mov->encryption_scheme_str != NULL && strcmp(mov->encryption_scheme_str, "none") != 0) {
if (strcmp(mov->encryption_scheme_str, "cenc-aes-ctr") == 0) {
mov->encryption_scheme = MOV_ENC_CENC_AES_CTR;
if (mov->encryption_key_len != AES_CTR_KEY_SIZE) {
av_log(s, AV_LOG_ERROR, "Invalid encryption key len %d expected %d\n",
mov->encryption_key_len, AES_CTR_KEY_SIZE);
return AVERROR(EINVAL);
}
if (mov->encryption_kid_len != CENC_KID_SIZE) {
av_log(s, AV_LOG_ERROR, "Invalid encryption kid len %d expected %d\n",
mov->encryption_kid_len, CENC_KID_SIZE);
return AVERROR(EINVAL);
}
} else {
av_log(s, AV_LOG_ERROR, "unsupported encryption scheme %s\n",
mov->encryption_scheme_str);
return AVERROR(EINVAL);
}
}
for (i = 0; i < s->nb_streams; i++) {
AVStream *st= s->streams[i];
MOVTrack *track= &mov->tracks[i];
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0);
track->st = st;
track->par = st->codecpar;
track->language = ff_mov_iso639_to_lang(lang?lang->value:"und", mov->mode!=MODE_MOV);
if (track->language < 0)
track->language = 0;
track->mode = mov->mode;
track->tag = mov_find_codec_tag(s, track);
if (!track->tag) {
av_log(s, AV_LOG_ERROR, "Could not find tag for codec %s in stream #%d, "
"codec not currently supported in container\n",
avcodec_get_name(st->codecpar->codec_id), i);
return AVERROR(EINVAL);
}
track->hint_track = -1;
track->start_dts = AV_NOPTS_VALUE;
track->start_cts = AV_NOPTS_VALUE;
track->end_pts = AV_NOPTS_VALUE;
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') ||
track->tag == MKTAG('m','x','4','p') || track->tag == MKTAG('m','x','4','n') ||
track->tag == MKTAG('m','x','5','p') || track->tag == MKTAG('m','x','5','n')) {
if (st->codecpar->width != 720 || (st->codecpar->height != 608 && st->codecpar->height != 512)) {
av_log(s, AV_LOG_ERROR, "D-10/IMX must use 720x608 or 720x512 video resolution\n");
return AVERROR(EINVAL);
}
track->height = track->tag >> 24 == 'n' ? 486 : 576;
}
if (mov->video_track_timescale) {
track->timescale = mov->video_track_timescale;
} else {
track->timescale = st->time_base.den;
while(track->timescale < 10000)
track->timescale *= 2;
}
if (st->codecpar->width > 65535 || st->codecpar->height > 65535) {
av_log(s, AV_LOG_ERROR, "Resolution %dx%d too large for mov/mp4\n", st->codecpar->width, st->codecpar->height);
return AVERROR(EINVAL);
}
if (track->mode == MODE_MOV && track->timescale > 100000)
av_log(s, AV_LOG_WARNING,
"WARNING codec timebase is very high. If duration is too long,\n"
"file may not be playable by quicktime. Specify a shorter timebase\n"
"or choose different container.\n");
if (track->mode == MODE_MOV &&
track->par->codec_id == AV_CODEC_ID_RAWVIDEO &&
track->tag == MKTAG('r','a','w',' ')) {
enum AVPixelFormat pix_fmt = track->par->format;
if (pix_fmt == AV_PIX_FMT_NONE && track->par->bits_per_coded_sample == 1)
pix_fmt = AV_PIX_FMT_MONOWHITE;
track->is_unaligned_qt_rgb =
pix_fmt == AV_PIX_FMT_RGB24 ||
pix_fmt == AV_PIX_FMT_BGR24 ||
pix_fmt == AV_PIX_FMT_PAL8 ||
pix_fmt == AV_PIX_FMT_GRAY8 ||
pix_fmt == AV_PIX_FMT_MONOWHITE ||
pix_fmt == AV_PIX_FMT_MONOBLACK;
}
if (track->par->codec_id == AV_CODEC_ID_VP9) {
if (track->mode != MODE_MP4) {
av_log(s, AV_LOG_ERROR, "VP9 only supported in MP4.\n");
return AVERROR(EINVAL);
}
if (s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
av_log(s, AV_LOG_ERROR,
"VP9 in MP4 support is experimental, add "
"'-strict %d' if you want to use it.\n",
FF_COMPLIANCE_EXPERIMENTAL);
return AVERROR_EXPERIMENTAL;
}
}
} else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
track->timescale = st->codecpar->sample_rate;
if (!st->codecpar->frame_size && !av_get_bits_per_sample(st->codecpar->codec_id)) {
av_log(s, AV_LOG_WARNING, "track %d: codec frame size is not set\n", i);
track->audio_vbr = 1;
}else if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_MS ||
st->codecpar->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV ||
st->codecpar->codec_id == AV_CODEC_ID_ILBC){
if (!st->codecpar->block_align) {
av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set for adpcm\n", i);
return AVERROR(EINVAL);
}
track->sample_size = st->codecpar->block_align;
}else if (st->codecpar->frame_size > 1){
track->audio_vbr = 1;
}else{
track->sample_size = (av_get_bits_per_sample(st->codecpar->codec_id) >> 3) * st->codecpar->channels;
}
if (st->codecpar->codec_id == AV_CODEC_ID_ILBC ||
st->codecpar->codec_id == AV_CODEC_ID_ADPCM_IMA_QT) {
track->audio_vbr = 1;
}
if (track->mode != MODE_MOV &&
track->par->codec_id == AV_CODEC_ID_MP3 && track->timescale < 16000) {
if (s->strict_std_compliance >= FF_COMPLIANCE_NORMAL) {
av_log(s, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not standard, to mux anyway set strict to -1\n",
i, track->par->sample_rate);
return AVERROR(EINVAL);
} else {
av_log(s, AV_LOG_WARNING, "track %d: muxing mp3 at %dhz is not standard in MP4\n",
i, track->par->sample_rate);
}
}
if (track->par->codec_id == AV_CODEC_ID_FLAC ||
track->par->codec_id == AV_CODEC_ID_OPUS) {
if (track->mode != MODE_MP4) {
av_log(s, AV_LOG_ERROR, "%s only supported in MP4.\n", avcodec_get_name(track->par->codec_id));
return AVERROR(EINVAL);
}
if (s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
av_log(s, AV_LOG_ERROR,
"%s in MP4 support is experimental, add "
"'-strict %d' if you want to use it.\n",
avcodec_get_name(track->par->codec_id), FF_COMPLIANCE_EXPERIMENTAL);
return AVERROR_EXPERIMENTAL;
}
}
} else if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
track->timescale = st->time_base.den;
} else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) {
track->timescale = st->time_base.den;
} else {
track->timescale = MOV_TIMESCALE;
}
if (!track->height)
track->height = st->codecpar->height;
if (mov->mode == MODE_ISM)
track->timescale = 10000000;
avpriv_set_pts_info(st, 64, 1, track->timescale);
if (mov->encryption_scheme == MOV_ENC_CENC_AES_CTR) {
ret = ff_mov_cenc_init(&track->cenc, mov->encryption_key,
track->par->codec_id == AV_CODEC_ID_H264, s->flags & AVFMT_FLAG_BITEXACT);
if (ret)
return ret;
}
}
enable_tracks(s);
return 0;
}
| 1threat |
How to send notification according to user's interest? : Many have you have noticed that sometimes we gets notifications according to our needs and Interest. For Example: Suppose you are using any Hotel Booking App, You entered the city and checked some hotels but didn't booked any hotel and closed the App. You will notice, after few hours or days they will send you notifications according to what I checked on their App(Like some offers or Planning to visit "xyz" city?) How they send such notifications? What they use for last searched cities/hotels of each user and send notification accordingly?? | 0debug |
How do i add different levels & quit option to my guess a number game? : So i'm a freshman in high school trying to figure out python coding, and I need to make a guess a number game.
My first level works fine, but I need to make it so it has 3 different levels, and a quit option, I don't understand these while loops.
I'm really sorry if I posted something wrong or this is an already asked question, but any help would be much appreciated!
import random
print("let's play guess a number!")
myLevel=int(input("would you like to play level 1, 2, 3, or quit?"))
if myLevel == 1:
number1= random.randit(1,10)
guess1=int(input("guess an integer from 1 to ten"))
while number1!=guess1:
print
if guess1<number1:
print("guess is too low")
guess1=int(input("guess again! or would you like to quit?"))
#this is where i want to be able to quit
elif guess1>number1:
print("guess is too high!")
guess1=int(input("guess again! or would you like to quit?"))
#this is where i want to be able to quit
if guess1==number1:
print("you guessed it!")
if myLevel == 2:
nextumber2= random.randint (1,100)
guess2=int(input("guess an integer from 1 to 100"))
while number2!=guess2:
print
if guess2<number2:
print("guess is too low!")
guess2=int(input("guess again!"))
elif guess2>number2:
print("guess is too high!")
guess2=int(input("guess again!"))
print("you guessed it!")
| 0debug |
How to write a fibonacci codes in objective c? : <p>I want to display fibonacci numbers from a given number. For example the input number is 100, then display all fibonacci sequence of numbers.</p>
| 0debug |
how to find xpath for the given code : How can i find xpath for (1)old password
(2) new password
(3) confirm password[i want to find xpath for the given postions.][1]
[1]: https://i.stack.imgur.com/Quad7.png | 0debug |
in swift, is a string object immutable once created? : <p>In java, once created, string objects are immutable. Some methods appear to change the string object, but what it actually does is creating a new string object from the original string object along with the modifications. I was just wondering if this is the case for String objects in SWIFT? </p>
| 0debug |
db.execute('SELECT * FROM products WHERE product_id = ' + product_input) | 1threat |
void qdev_init_nofail(DeviceState *dev)
{
Error *err = NULL;
assert(!dev->realized);
object_property_set_bool(OBJECT(dev), true, "realized", &err);
if (err) {
error_reportf_err(err, "Initialization of device %s failed: ",
object_get_typename(OBJECT(dev)));
exit(1);
}
} | 1threat |
java.sql.SQLException: Before start of result set Java : <p>I'm getting <code>java.sql.SQLException: Before start of result set</code> when I try to use this code:</p>
<pre><code>ResultSet user = query("SELECT `id`, `counter` FROM `accounts` WHERE `username`='test'");
int id = user.getInt("id");
int counter = user.getInt("counter");
System.out.println("Id: " + id + " | Counter: " + counter);
</code></pre>
<p>All I really need to do is get the values of id and counter and set it to an integer in java but I'm not sure how to do that this is the third method I've tried, is there anything else I can do to get that information? I know for a fact the problem isn't with my query method so I figured it'll be pointless to show it, this is pretty much the entire snippet. (Yes the connection is opened and closed no problem) Any help would be appreciated.</p>
| 0debug |
static int dxva2_alloc(AVCodecContext *s)
{
InputStream *ist = s->opaque;
int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR;
DXVA2Context *ctx;
HANDLE device_handle;
HRESULT hr;
AVHWDeviceContext *device_ctx;
AVDXVA2DeviceContext *device_hwctx;
int ret;
ctx = av_mallocz(sizeof(*ctx));
if (!ctx)
return AVERROR(ENOMEM);
ist->hwaccel_ctx = ctx;
ist->hwaccel_uninit = dxva2_uninit;
ist->hwaccel_get_buffer = dxva2_get_buffer;
ist->hwaccel_retrieve_data = dxva2_retrieve_data;
ret = av_hwdevice_ctx_create(&ctx->hw_device_ctx, AV_HWDEVICE_TYPE_DXVA2,
ist->hwaccel_device, NULL, 0);
if (ret < 0)
goto fail;
device_ctx = (AVHWDeviceContext*)ctx->hw_device_ctx->data;
device_hwctx = device_ctx->hwctx;
hr = IDirect3DDeviceManager9_OpenDeviceHandle(device_hwctx->devmgr,
&device_handle);
if (FAILED(hr)) {
av_log(NULL, loglevel, "Failed to open a device handle\n");
goto fail;
}
hr = IDirect3DDeviceManager9_GetVideoService(device_hwctx->devmgr, device_handle,
&IID_IDirectXVideoDecoderService,
(void **)&ctx->decoder_service);
IDirect3DDeviceManager9_CloseDeviceHandle(device_hwctx->devmgr, device_handle);
if (FAILED(hr)) {
av_log(NULL, loglevel, "Failed to create IDirectXVideoDecoderService\n");
goto fail;
}
ctx->tmp_frame = av_frame_alloc();
if (!ctx->tmp_frame)
goto fail;
s->hwaccel_context = av_mallocz(sizeof(struct dxva_context));
if (!s->hwaccel_context)
goto fail;
return 0;
fail:
dxva2_uninit(s);
return AVERROR(EINVAL);
}
| 1threat |
Permission denied during gcloud app deploy using Google Cloud SDK : <p>It is insanely hard, to deploy an app to Google App Engine, using Google Cloud SDK.</p>
<p>I had tried the below 2 commands</p>
<pre><code>C:\Users\yccheok\Desktop\jstock-android-appengine>gcloud config set project jstock-android
Updated property [core/project].
C:\Users\yccheok\Desktop\jstock-android-appengine>gcloud app deploy app.yaml --log-http --verbosity=debug
DEBUG: Running [gcloud.app.deploy] with arguments: [--log-http: "true", --verbosity: "debug", DEPLOYABLES:1: "['app.yaml']"]
DEBUG: No staging command found for runtime [python27] and environment [STANDARD].
DEBUG: API endpoint: [https://appengine.googleapis.com/], API version: [v1]
=======================
==== request start ====
uri: https://appengine.googleapis.com/v1/apps/jstock-android?alt=json
method: GET
== headers start ==
Authorization: Bearer ya29.GlxEBb1XVP1JK93-ARiaN_ZgiMbvZmw5KWfvJVfibDJ4FK_ZaMRoU1jVDTiWzsY606GSduJKJd9Nm8zA-_Iql5mGn4AMk4QVl8mPRycfekeZnOOHtbUvpkBMgOLOQA
accept: application/json
accept-encoding: gzip, deflate
content-length: 0
user-agent: google-cloud-sdk x_Tw5K8nnjoRAqULM9PFAC2b gcloud/184.0.0 command/gcloud.app.deploy invocation-id/c9ae232d33b346d787b95a36e28c38c0 environment/None environment-version/None interactive/True python/2.7.13 (Windows NT 10.0.16299)
== headers end ==
== body start ==
== body end ==
==== request end ====
---- response start ----
-- headers start --
-content-encoding: gzip
alt-svc: hq=":443"; ma=2592000; quic=51303431; quic=51303339; quic=51303338; quic=51303337; quic=51303335,quic=":443"; ma=2592000; v="41,39,38,37,35"
cache-control: private
content-length: 335
content-type: application/json; charset=UTF-8
date: Tue, 16 Jan 2018 19:16:21 GMT
server: ESF
status: 403
transfer-encoding: chunked
vary: Origin, X-Origin, Referer
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
-- headers end --
-- body start --
{
"error": {
"code": 403,
"message": "Operation not allowed",
"status": "PERMISSION_DENIED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ResourceInfo",
"resourceType": "gae.api",
"description": "The \"appengine.applications.get\" permission is required."
}
]
}
}
-- body end --
total round trip time (request+response): 1.796 secs
---- response end ----
----------------------
DEBUG: (gcloud.app.deploy) Permissions error fetching application [apps/jstock-android]. Please make sure you are using the correct project ID and that you have permission to view applications on the project.
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\calliope\cli.py", line 797, in Execute
resources = calliope_command.Run(cli=self, args=args)
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\calliope\backend.py", line 757, in Run
resources = command_instance.Run(args)
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\surface\app\deploy.py", line 65, in Run
parallel_build=False)
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\command_lib\app\deploy_util.py", line 543, in RunDeploy
app = _PossiblyCreateApp(api_client, project)
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\command_lib\app\deploy_util.py", line 703, in _PossiblyCreateApp
api_client._FormatApp()))) # pylint: disable=protected-access
HttpException: Permissions error fetching application [apps/jstock-android]. Please make sure you are using the correct project ID and that you have permission to view applications on the project.
ERROR: (gcloud.app.deploy) Permissions error fetching application [apps/jstock-android]. Please make sure you are using the correct project ID and that you have permission to view applications on the project.
C:\Users\yccheok\Desktop\jstock-android-appengine>
</code></pre>
<p>Then, I went through <a href="https://cloud.google.com/appengine/docs/admin-api/accessing-the-api" rel="noreferrer">https://cloud.google.com/appengine/docs/admin-api/accessing-the-api</a> , it mentioned I need to use <strong>Admin API</strong>. So, I do it step by step carefully.</p>
<h2>Step 1</h2>
<p><a href="https://i.stack.imgur.com/dRVVB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/dRVVB.png" alt="enter image description here"></a></p>
<h2>Step 2</h2>
<p><a href="https://i.stack.imgur.com/LOm7K.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LOm7K.png" alt="enter image description here"></a></p>
<p>It mentions <strong>Admin API</strong> is enabled. Now I need credential.</p>
<h2>Step 3</h2>
<p><a href="https://i.stack.imgur.com/MuhA6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/MuhA6.png" alt="enter image description here"></a></p>
<h2>Step 4</h2>
<p><a href="https://i.stack.imgur.com/6QUpo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/6QUpo.png" alt="enter image description here"></a></p>
<p>OK. Now they mention I don't need create new credential. I can use <strong>Application Default Credentials</strong> ?!</p>
<h2>Step 5</h2>
<p>So, I went to <a href="https://developers.google.com/identity/protocols/application-default-credentials?hl=en_GB" rel="noreferrer">https://developers.google.com/identity/protocols/application-default-credentials?hl=en_GB</a> . I learn that I need to run</p>
<pre><code>C:\Users\yccheok\Desktop\jstock-android-appengine>gcloud auth application-default login
Your browser has been opened to visit:
https://accounts.google.com/o/oauth2/auth?redirect_uri=http%3A%2F%2Flocalhost%3A8085%2F&prompt=select_account&response_type=code&client_id=764086051850-6qr4p6gpi6hn506pt8ejuq83di341hur.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform&access_type=offline
Credentials saved to file: [C:\Users\yccheok\AppData\Roaming\gcloud\application_default_credentials.json]
These credentials will be used by any library that requests
Application Default Credentials.
</code></pre>
<h2>Step 6</h2>
<p><a href="https://i.stack.imgur.com/TJsIP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TJsIP.png" alt="enter image description here"></a></p>
<h2>Step 7</h2>
<p><a href="https://i.stack.imgur.com/cNo3x.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cNo3x.png" alt="enter image description here"></a></p>
<hr>
<p>Still, after completing the above 7 steps, I still get the exact same error message, when trying to run</p>
<pre><code>gcloud app deploy app.yaml --log-http --verbosity=debug
</code></pre>
<p>Can anyone let me know, what step I'm still require, in order to deploy my Python app to Google App Engine, using Google Cloud SDK?</p>
| 0debug |
static uint32_t m5206_mbar_readw(void *opaque, target_phys_addr_t offset)
{
m5206_mbar_state *s = (m5206_mbar_state *)opaque;
int width;
offset &= 0x3ff;
if (offset > 0x200) {
hw_error("Bad MBAR read offset 0x%x", (int)offset);
}
width = m5206_mbar_width[offset >> 2];
if (width > 2) {
uint32_t val;
val = m5206_mbar_readl(opaque, offset & ~3);
if ((offset & 3) == 0)
val >>= 16;
return val & 0xffff;
} else if (width < 2) {
uint16_t val;
val = m5206_mbar_readb(opaque, offset) << 8;
val |= m5206_mbar_readb(opaque, offset + 1);
return val;
}
return m5206_mbar_read(s, offset, 2);
}
| 1threat |
Name with gear icon in Chrome network requests table : <p><a href="https://i.stack.imgur.com/b19N0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/b19N0.png" alt="enter image description here"></a></p>
<p><a href="https://i.stack.imgur.com/BOZs9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BOZs9.png" alt="enter image description here"></a></p>
<p>(30119999.xml in pic1, has a gear mark pre name)</p>
<p>I set this request in Web Worker, response data is ok and I terminated it in onmessage callback</p>
<p>but why the request always in pending and can't preview, please help.</p>
<p>pseudocode:</p>
<pre><code>const workerBlob = new Blob([`onmessage = function (event) {
const xhr = new XMLHttpRequest();
xhr.addEventListener('load', function () {
postMessage(xhr.response);
});
xhr.open('GET', event.data.url, true);
xhr.send();
}`], { type: 'application/javascript' });
const workerURL = URL.createObjectURL(workerBlob);
const worker = new Worker(workerUrl);
worker.postMessage({url});
worker.onmessage = (message) => {
// do something
worker.terminate();
};
</code></pre>
| 0debug |
.NET Core app unable to start in IIS due to ErrorCode = '0x80004005 : 80008083 : <p>I have a .NET Core application. It runs locally with VS2017 and Kestrel. It runs locally under IIS. However, on the server it fails to start with a <code>502.5 - Process Failure</code> message.</p>
<p>In the event logs I get more detail:</p>
<blockquote>
<p>Application '...' with physical root 'C:...\my-app-folder\' failed to start process with commandline '"dotnet" .\MyApp.dll', ErrorCode = '0x80004005 : 80008083.</p>
</blockquote>
<p>Previous builds of the application work fine on the same server, the only difference being that they were published with VS2017RC (2&3) and this is the first build with the fully released VS2017.</p>
<p>What does <code>ErrorCode = '0x80004005 : 80008083.</code> mean?</p>
<p>How do I fix it?</p>
| 0debug |
Which language use to automatize the data extraction from websites to Excel? : <p>I would like to import data from specific websites to one or different Excel file(s).</p>
<p>The different websites are the following :</p>
<ul>
<li><a href="https://www.cmegroup.com/trading/equity-index/us-index/e-mini-dow_quotes_settlements_futures.html" rel="nofollow noreferrer">https://www.cmegroup.com/trading/equity-index/us-index/e-mini-dow_quotes_settlements_futures.html</a></li>
<li><a href="https://www.cmegroup.com/trading/equity-index/us-index/e-mini-nasdaq-100_quotes_settlements_futures.html" rel="nofollow noreferrer">https://www.cmegroup.com/trading/equity-index/us-index/e-mini-nasdaq-100_quotes_settlements_futures.html</a></li>
<li><a href="https://www.eurexchange.com/exchange-en/market-data/statistics/market-statistics-online/100!onlineStats?productGroupId=13394&productId=34642&viewType=4&busDate=20191018" rel="nofollow noreferrer">https://www.eurexchange.com/exchange-en/market-data/statistics/market-statistics-online/100!onlineStats?productGroupId=13394&productId=34642&viewType=4&busDate=20191018</a> (I didn't find any direct link, please change the part at the end of the link with the current date !)</li>
<li><a href="https://live.euronext.com/fr/product/index-futures/FCE-DPAR/settlement-prices" rel="nofollow noreferrer">https://live.euronext.com/fr/product/index-futures/FCE-DPAR/settlement-prices</a></li>
</ul>
<p>Each day, the websites give, for each contracts (DEC19, MAR20, JUN20 etc) some values (open, high, low, last, settle, volume etc.)</p>
<p>I would like to automaticaly extract/copy/import (in an .csv or Excel file for example), everyday, for each product (DOW, NASDAQ, CAC and DAX) and only for the contract which has the highest volume, the values.</p>
<p>Somebody told me it could be done by using C# language.. However I have absolutely no knowledge in C#.</p>
<p>I've also tried to use Excel and the function Data>Import data from a website, however the "table" is empty, maybe they protected their data ?! (I wanted to create a macro in Excel to automatize this process but it didn't work).</p>
<p>So the main question is : which language will allow me to automatize the data extraction from these websites to excel ? </p>
<p>Thank you very much ! </p>
| 0debug |
How to auto delete wordpress comments older then x days : Everybody
I have my site in WordPress and in my site i am using forum for user discussion by using WordPress default comment system. In my forum page users continuously post comments, now i want to automatically delete comments that are older then 15 days.
is it possible to auto delete WordPress comments on any page after the interval of some days.
can anybody help me in order to do my task. | 0debug |
void prepare_play(void)
{
AVOutputFormat *ofmt;
ofmt = guess_format("audio_device", NULL, NULL);
if (!ofmt) {
fprintf(stderr, "Could not find audio device\n");
exit(1);
}
opt_output_file(audio_device);
}
| 1threat |
static int grow_refcount_table(BlockDriverState *bs, int min_size)
{
BDRVQcowState *s = bs->opaque;
int new_table_size, new_table_size2, refcount_table_clusters, i, ret;
uint64_t *new_table;
int64_t table_offset;
uint8_t data[12];
int old_table_size;
int64_t old_table_offset;
if (min_size <= s->refcount_table_size)
return 0;
new_table_size = next_refcount_table_size(s, min_size);
#ifdef DEBUG_ALLOC2
printf("grow_refcount_table from %d to %d\n",
s->refcount_table_size,
new_table_size);
#endif
new_table_size2 = new_table_size * sizeof(uint64_t);
new_table = qemu_mallocz(new_table_size2);
memcpy(new_table, s->refcount_table,
s->refcount_table_size * sizeof(uint64_t));
for(i = 0; i < s->refcount_table_size; i++)
cpu_to_be64s(&new_table[i]);
table_offset = alloc_clusters_noref(bs, new_table_size2);
ret = bdrv_pwrite(s->hd, table_offset, new_table, new_table_size2);
if (ret != new_table_size2)
goto fail;
for(i = 0; i < s->refcount_table_size; i++)
be64_to_cpus(&new_table[i]);
cpu_to_be64w((uint64_t*)data, table_offset);
cpu_to_be32w((uint32_t*)(data + 8), refcount_table_clusters);
ret = bdrv_pwrite(s->hd, offsetof(QCowHeader, refcount_table_offset),
data, sizeof(data));
if (ret != sizeof(data)) {
goto fail;
}
qemu_free(s->refcount_table);
old_table_offset = s->refcount_table_offset;
old_table_size = s->refcount_table_size;
s->refcount_table = new_table;
s->refcount_table_size = new_table_size;
s->refcount_table_offset = table_offset;
update_refcount(bs, table_offset, new_table_size2, 1);
qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t));
return 0;
fail:
qemu_free(new_table);
return ret < 0 ? ret : -EIO;
}
| 1threat |
int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr,
int is_write1, int mmu_idx)
{
uint64_t ptep, pte;
target_ulong pde_addr, pte_addr;
int error_code, is_dirty, prot, page_size, is_write, is_user;
target_phys_addr_t paddr;
uint32_t page_offset;
target_ulong vaddr, virt_addr;
is_user = mmu_idx == MMU_USER_IDX;
#if defined(DEBUG_MMU)
printf("MMU fault: addr=" TARGET_FMT_lx " w=%d u=%d eip=" TARGET_FMT_lx "\n",
addr, is_write1, is_user, env->eip);
#endif
is_write = is_write1 & 1;
if (!(env->cr[0] & CR0_PG_MASK)) {
pte = addr;
virt_addr = addr & TARGET_PAGE_MASK;
prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
page_size = 4096;
goto do_mapping;
}
if (env->cr[4] & CR4_PAE_MASK) {
uint64_t pde, pdpe;
target_ulong pdpe_addr;
#ifdef TARGET_X86_64
if (env->hflags & HF_LMA_MASK) {
uint64_t pml4e_addr, pml4e;
int32_t sext;
sext = (int64_t)addr >> 47;
if (sext != 0 && sext != -1) {
env->error_code = 0;
env->exception_index = EXCP0D_GPF;
return 1;
}
pml4e_addr = ((env->cr[3] & ~0xfff) + (((addr >> 39) & 0x1ff) << 3)) &
env->a20_mask;
pml4e = ldq_phys(pml4e_addr);
if (!(pml4e & PG_PRESENT_MASK)) {
error_code = 0;
goto do_fault;
}
if (!(env->efer & MSR_EFER_NXE) && (pml4e & PG_NX_MASK)) {
error_code = PG_ERROR_RSVD_MASK;
goto do_fault;
}
if (!(pml4e & PG_ACCESSED_MASK)) {
pml4e |= PG_ACCESSED_MASK;
stl_phys_notdirty(pml4e_addr, pml4e);
}
ptep = pml4e ^ PG_NX_MASK;
pdpe_addr = ((pml4e & PHYS_ADDR_MASK) + (((addr >> 30) & 0x1ff) << 3)) &
env->a20_mask;
pdpe = ldq_phys(pdpe_addr);
if (!(pdpe & PG_PRESENT_MASK)) {
error_code = 0;
goto do_fault;
}
if (!(env->efer & MSR_EFER_NXE) && (pdpe & PG_NX_MASK)) {
error_code = PG_ERROR_RSVD_MASK;
goto do_fault;
}
ptep &= pdpe ^ PG_NX_MASK;
if (!(pdpe & PG_ACCESSED_MASK)) {
pdpe |= PG_ACCESSED_MASK;
stl_phys_notdirty(pdpe_addr, pdpe);
}
} else
#endif
{
pdpe_addr = ((env->cr[3] & ~0x1f) + ((addr >> 27) & 0x18)) &
env->a20_mask;
pdpe = ldq_phys(pdpe_addr);
if (!(pdpe & PG_PRESENT_MASK)) {
error_code = 0;
goto do_fault;
}
ptep = PG_NX_MASK | PG_USER_MASK | PG_RW_MASK;
}
pde_addr = ((pdpe & PHYS_ADDR_MASK) + (((addr >> 21) & 0x1ff) << 3)) &
env->a20_mask;
pde = ldq_phys(pde_addr);
if (!(pde & PG_PRESENT_MASK)) {
error_code = 0;
goto do_fault;
}
if (!(env->efer & MSR_EFER_NXE) && (pde & PG_NX_MASK)) {
error_code = PG_ERROR_RSVD_MASK;
goto do_fault;
}
ptep &= pde ^ PG_NX_MASK;
if (pde & PG_PSE_MASK) {
page_size = 2048 * 1024;
ptep ^= PG_NX_MASK;
if ((ptep & PG_NX_MASK) && is_write1 == 2)
goto do_fault_protect;
if (is_user) {
if (!(ptep & PG_USER_MASK))
goto do_fault_protect;
if (is_write && !(ptep & PG_RW_MASK))
goto do_fault_protect;
} else {
if ((env->cr[0] & CR0_WP_MASK) &&
is_write && !(ptep & PG_RW_MASK))
goto do_fault_protect;
}
is_dirty = is_write && !(pde & PG_DIRTY_MASK);
if (!(pde & PG_ACCESSED_MASK) || is_dirty) {
pde |= PG_ACCESSED_MASK;
if (is_dirty)
pde |= PG_DIRTY_MASK;
stl_phys_notdirty(pde_addr, pde);
}
pte = pde & ((PHYS_ADDR_MASK & ~(page_size - 1)) | 0xfff);
virt_addr = addr & ~(page_size - 1);
} else {
if (!(pde & PG_ACCESSED_MASK)) {
pde |= PG_ACCESSED_MASK;
stl_phys_notdirty(pde_addr, pde);
}
pte_addr = ((pde & PHYS_ADDR_MASK) + (((addr >> 12) & 0x1ff) << 3)) &
env->a20_mask;
pte = ldq_phys(pte_addr);
if (!(pte & PG_PRESENT_MASK)) {
error_code = 0;
goto do_fault;
}
if (!(env->efer & MSR_EFER_NXE) && (pte & PG_NX_MASK)) {
error_code = PG_ERROR_RSVD_MASK;
goto do_fault;
}
ptep &= pte ^ PG_NX_MASK;
ptep ^= PG_NX_MASK;
if ((ptep & PG_NX_MASK) && is_write1 == 2)
goto do_fault_protect;
if (is_user) {
if (!(ptep & PG_USER_MASK))
goto do_fault_protect;
if (is_write && !(ptep & PG_RW_MASK))
goto do_fault_protect;
} else {
if ((env->cr[0] & CR0_WP_MASK) &&
is_write && !(ptep & PG_RW_MASK))
goto do_fault_protect;
}
is_dirty = is_write && !(pte & PG_DIRTY_MASK);
if (!(pte & PG_ACCESSED_MASK) || is_dirty) {
pte |= PG_ACCESSED_MASK;
if (is_dirty)
pte |= PG_DIRTY_MASK;
stl_phys_notdirty(pte_addr, pte);
}
page_size = 4096;
virt_addr = addr & ~0xfff;
pte = pte & (PHYS_ADDR_MASK | 0xfff);
}
} else {
uint32_t pde;
pde_addr = ((env->cr[3] & ~0xfff) + ((addr >> 20) & 0xffc)) &
env->a20_mask;
pde = ldl_phys(pde_addr);
if (!(pde & PG_PRESENT_MASK)) {
error_code = 0;
goto do_fault;
}
if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
page_size = 4096 * 1024;
if (is_user) {
if (!(pde & PG_USER_MASK))
goto do_fault_protect;
if (is_write && !(pde & PG_RW_MASK))
goto do_fault_protect;
} else {
if ((env->cr[0] & CR0_WP_MASK) &&
is_write && !(pde & PG_RW_MASK))
goto do_fault_protect;
}
is_dirty = is_write && !(pde & PG_DIRTY_MASK);
if (!(pde & PG_ACCESSED_MASK) || is_dirty) {
pde |= PG_ACCESSED_MASK;
if (is_dirty)
pde |= PG_DIRTY_MASK;
stl_phys_notdirty(pde_addr, pde);
}
pte = pde & ~( (page_size - 1) & ~0xfff);
ptep = pte;
virt_addr = addr & ~(page_size - 1);
} else {
if (!(pde & PG_ACCESSED_MASK)) {
pde |= PG_ACCESSED_MASK;
stl_phys_notdirty(pde_addr, pde);
}
pte_addr = ((pde & ~0xfff) + ((addr >> 10) & 0xffc)) &
env->a20_mask;
pte = ldl_phys(pte_addr);
if (!(pte & PG_PRESENT_MASK)) {
error_code = 0;
goto do_fault;
}
ptep = pte & pde;
if (is_user) {
if (!(ptep & PG_USER_MASK))
goto do_fault_protect;
if (is_write && !(ptep & PG_RW_MASK))
goto do_fault_protect;
} else {
if ((env->cr[0] & CR0_WP_MASK) &&
is_write && !(ptep & PG_RW_MASK))
goto do_fault_protect;
}
is_dirty = is_write && !(pte & PG_DIRTY_MASK);
if (!(pte & PG_ACCESSED_MASK) || is_dirty) {
pte |= PG_ACCESSED_MASK;
if (is_dirty)
pte |= PG_DIRTY_MASK;
stl_phys_notdirty(pte_addr, pte);
}
page_size = 4096;
virt_addr = addr & ~0xfff;
}
}
prot = PAGE_READ;
if (!(ptep & PG_NX_MASK))
prot |= PAGE_EXEC;
if (pte & PG_DIRTY_MASK) {
if (is_user) {
if (ptep & PG_RW_MASK)
prot |= PAGE_WRITE;
} else {
if (!(env->cr[0] & CR0_WP_MASK) ||
(ptep & PG_RW_MASK))
prot |= PAGE_WRITE;
}
}
do_mapping:
pte = pte & env->a20_mask;
page_offset = (addr & TARGET_PAGE_MASK) & (page_size - 1);
paddr = (pte & TARGET_PAGE_MASK) + page_offset;
vaddr = virt_addr + page_offset;
tlb_set_page(env, vaddr, paddr, prot, mmu_idx, page_size);
return 0;
do_fault_protect:
error_code = PG_ERROR_P_MASK;
do_fault:
error_code |= (is_write << PG_ERROR_W_BIT);
if (is_user)
error_code |= PG_ERROR_U_MASK;
if (is_write1 == 2 &&
(env->efer & MSR_EFER_NXE) &&
(env->cr[4] & CR4_PAE_MASK))
error_code |= PG_ERROR_I_D_MASK;
if (env->intercept_exceptions & (1 << EXCP0E_PAGE)) {
stq_phys(env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2),
addr);
} else {
env->cr[2] = addr;
}
env->error_code = error_code;
env->exception_index = EXCP0E_PAGE;
return 1;
}
| 1threat |
void aio_set_fd_handler(AioContext *ctx,
int fd,
bool is_external,
IOHandler *io_read,
IOHandler *io_write,
AioPollFn *io_poll,
void *opaque)
{
AioHandler *node;
bool is_new = false;
bool deleted = false;
qemu_lockcnt_lock(&ctx->list_lock);
node = find_aio_handler(ctx, fd);
if (!io_read && !io_write && !io_poll) {
if (node == NULL) {
qemu_lockcnt_unlock(&ctx->list_lock);
return;
}
g_source_remove_poll(&ctx->source, &node->pfd);
if (qemu_lockcnt_count(&ctx->list_lock)) {
node->deleted = 1;
node->pfd.revents = 0;
} else {
QLIST_REMOVE(node, node);
deleted = true;
}
if (!node->io_poll) {
ctx->poll_disable_cnt--;
}
} else {
if (node == NULL) {
node = g_new0(AioHandler, 1);
node->pfd.fd = fd;
QLIST_INSERT_HEAD_RCU(&ctx->aio_handlers, node, node);
g_source_add_poll(&ctx->source, &node->pfd);
is_new = true;
ctx->poll_disable_cnt += !io_poll;
} else {
ctx->poll_disable_cnt += !io_poll - !node->io_poll;
}
node->io_read = io_read;
node->io_write = io_write;
node->io_poll = io_poll;
node->opaque = opaque;
node->is_external = is_external;
node->pfd.events = (io_read ? G_IO_IN | G_IO_HUP | G_IO_ERR : 0);
node->pfd.events |= (io_write ? G_IO_OUT | G_IO_ERR : 0);
}
aio_epoll_update(ctx, node, is_new);
qemu_lockcnt_unlock(&ctx->list_lock);
aio_notify(ctx);
if (deleted) {
g_free(node);
}
}
| 1threat |
Sequelize: TimeoutError: ResourceRequest timed out : <p>My Express app running on node 6.11 with Sequelize 4.5.0 will sometimes throw <code>TimeoutError: ResourceRequest timed out</code>, on operations that should not be particularly expensive. We're talking 5 rows of writes, each executed individually.</p>
<p>The database is an Amazon RDS MySQL instance, that hasn't shown any problems connecting to our second API that is written in Ruby and is using ActiveRecord as an ORM.</p>
<p>I'm not sure how to begin diagnosing the problem, any ideas on what I should do next?</p>
| 0debug |
I am stuck witch Java project : i am having trouble in this lines
//obj.generateIndexes(failuSarasas, 2);
HashMap<String, HashMap<String, Integer>> indTwoList = obj.generateIndexes(failuSarasas, 2);
obj.printHashMap(indTwoList);
//obj.generateIndexMatrix(indTwoList, failuSarasas);
and
HashMap<String, HashMap<String, Integer>> indexList = new HashMap<String, HashMap<String, Integer>>();
for (int i = 0; i < fileList.length; i++)
maybe can somebody help me?
package modeliavimas2;
import java.io.*;
import java.util.*;
import org.apache.commons.io.FileUtils;
public class mainas
{
public static void main(String[] args) throws IOException
{
mainas obj = new mainas();
File[] failuSarasas = obj.getFileList();
//obj.generateIndexes(failuSarasas, 2);
HashMap<String, HashMap<String, Integer>> indTwoList = obj.generateIndexes(failuSarasas, 2);
obj.printHashMap(indTwoList);
//obj.generateIndexMatrix(indTwoList, failuSarasas);
Scanner scaner = new Scanner(System.in);
System.out.println("Iveskite termina arba 1, kad iseit");
while(true)
{
String phrase = scaner.nextLine();
if(phrase.equals("1"))
{
break;
}
obj.search(phrase, 2);
System.out.println("Iveskite termina arba 1, kad iseit");
}
scaner.close();
}
public File[] getFileList()
{
File folder = new File(
" C:\\Users\\Dell Pc\\Desktop\\inform\\Informacijos modeliavimas\\Informacijos modeliavimas\\ld2\\pages");
File[] listOfFiles = folder.listFiles();
return listOfFiles;
}
public HashMap<String, HashMap<String, Integer>> generateIndexes(File[] fileList, int phraseLen) throws IOException
{
HashMap<String, HashMap<String, Integer>> indexList = new HashMap<String, HashMap<String, Integer>>();
for (int i = 0; i < fileList.length; i++)
{
ArrayList<String> pageWords = new ArrayList<String>();
HashMap<String, Integer> hashMap = new HashMap<String, Integer>();
File file = fileList[i];
if (file.isFile() && file.getName().endsWith(".txt"))
{
String content = FileUtils.readFileToString(file, "UTF8");
for (String a : content.split(" "))
{
a = a.toLowerCase();
a = a.replaceAll("\\W|\\d|\\_", ""); // isvalyt visus
// neraidinius arba neskaicius
if (a.length() >= 3 && a.length() <= 15)
{
pageWords.add(a); //
}
}
if(phraseLen <= 1)
{
for(String a : pageWords)
{
if(!hashMap.containsKey(a))
{
hashMap.put(a, 1);
} else
{
hashMap.put(a, hashMap.get(a) + 1);
}
}
}
else
{
for(int j = phraseLen; j < pageWords.size(); j++)
{
String a = pageWords.get(j-1) + " "+ pageWords.get(j);
if(!hashMap.containsKey(a))
{
hashMap.put(a, 1);
}
else
{
hashMap.put(a, hashMap.get(a) + 1);
}
}
}
indexList.put(file.getName(), hashMap);
}
}
return indexList;
}
public void printHashMap(HashMap<String, HashMap<String, Integer>> indexList)
{
for (String a : indexList.keySet())
{
HashMap<String, Integer> map = indexList.get(a);
for (String b : map.keySet())
{
String key = b.toString();
String value = map.get(b).toString();
System.out.println(key + " " + value);
}
}
}
public void generateIndexMatrix(HashMap<String, HashMap<String, Integer>> indexList, File[] fileList)
throws FileNotFoundException, UnsupportedEncodingException
{
PrintWriter writer = new PrintWriter("debug2.txt", "UTF-8");
ArrayList<String> termList = new ArrayList<String>();
for (String a : indexList.keySet())
{
HashMap<String, Integer> map = indexList.get(a);
for (String b : map.keySet())
{
if (!termList.contains(b.toString()))
{
termList.add(b.toString());
}
}
}
String[][] matrix = new String[fileList.length+1][termList.size()+1];
int counter = 1;
for (String a : termList)
{
matrix[0][counter++] = a;
}
counter = 1;
for(File a : fileList)
{
matrix[counter++][0] = a.getName();
}
for(int i = 0; i < matrix.length; i++)
{
for(int j = 0; j < matrix[i].length; j++)
{
if(i > 0 && j > 0)
{
if(indexList.get(matrix[i][0]).get(matrix[0][j]) != null)
{
writer.print(indexList.get(matrix[i][0]).get(matrix[0][j]) + " ");
}
else
{
writer.print(0+" ");
}
}
else
{
writer.print(matrix[i][j]+" ");
}
}
writer.println();
}
writer.close();
}
public void search(String searchPhrase, int phraseLen) throws IOException
{
String[] searchTermsRaw = searchPhrase.split(" ");
ArrayList<String> searchTermsProc = new ArrayList<String>();
// apdorojam paieskos zodzius
if(phraseLen <= 1)
{
for(String a : searchTermsRaw)
{
a = a.toLowerCase();
a = a.replaceAll("\\W|\\d|\\_", "");
searchTermsProc.add(a);
}
}
else
{
for(int i = 1; i < searchTermsRaw.length; i++)
{
searchTermsRaw[i] = searchTermsRaw[i].replaceAll("\\W|\\d|\\_", "");
String a = searchTermsRaw[i - 1] + " " + searchTermsRaw[i];
a = a.toLowerCase();
searchTermsProc.add(a);
}
}
ArrayList<ArrayList<String>> indexMatrix = new ArrayList<ArrayList<String>>();
ArrayList<String> containingPages = new ArrayList<String>();
try (BufferedReader br = new BufferedReader(new FileReader("c:\\Users\\ASUSPC\\Documents\\Uni stuff\\Eclipse projects\\modeliavimas2\\debug2.txt"))) // irasyti indexu matricos faila
{
String line = br.readLine();
Boolean firstLine = true;
while (line != null)
{
ArrayList<String> list = new ArrayList<String>();
if(phraseLen <= 1)
{
for(String a : line.split(" "))
{
list.add(a);
}
}
else
{
String[] a = line.split(" ");
for(int i = 1; i < a.length; i++)
{
String temp = "";
if(firstLine)
{
if(i+1 < a.length)
{
temp = a[i] + " " + a[i + 1];
}
i++;
}
else
{
temp = a[i];
}
list.add(temp);
}
}
indexMatrix.add(list);
firstLine = false;
line = br.readLine();
}
}
for(int i = 1; i < indexMatrix.size(); i++)
{
int counter = 0;
for(String a : searchTermsProc)
{
int xpos = indexMatrix.get(0).indexOf(a);
if(xpos == -1)
{
continue;
}
if(Integer.parseInt(indexMatrix.get(i).get(xpos)) != 0)
{
counter++;
}
}
if(counter == searchTermsProc.size())
{
containingPages.add(String.valueOf(i));
}
counter = 0;
}
System.out.println("Rasti terminai rasti:");
for(String a: containingPages)
{
System.out.println(a);
}
if(containingPages.size() == 0)
{
System.out.println("Terminas nerastas nei viename dokumente");
}
}
}
| 0debug |
Serilog's AddSerilog is not recognized : <p>I'm trying to call <strong>loggerFactory.AddSerilog();</strong> as per <a href="https://github.com/serilog/serilog-docker/blob/master/web-sample/src/Startup.cs" rel="noreferrer">this</a> documentation, but the <strong>AddSerilog</strong> method is not recognized:</p>
<p>"Error CS1061 'ILoggerFactory' does not contain a definition for 'AddSerilog' and no extension method 'AddSerilog' accepting a first...".</p>
<p>I'm using ASP.NET CORE with the full .NET framework.
What am I doing wrong?</p>
| 0debug |
int xenstore_domain_init1(const char *kernel, const char *ramdisk,
const char *cmdline)
{
char *dom, uuid_string[42], vm[256], path[256];
int i;
snprintf(uuid_string, sizeof(uuid_string), UUID_FMT,
qemu_uuid[0], qemu_uuid[1], qemu_uuid[2], qemu_uuid[3],
qemu_uuid[4], qemu_uuid[5], qemu_uuid[6], qemu_uuid[7],
qemu_uuid[8], qemu_uuid[9], qemu_uuid[10], qemu_uuid[11],
qemu_uuid[12], qemu_uuid[13], qemu_uuid[14], qemu_uuid[15]);
dom = xs_get_domain_path(xenstore, xen_domid);
snprintf(vm, sizeof(vm), "/vm/%s", uuid_string);
xenstore_domain_mkdir(dom);
xenstore_write_str(vm, "image/ostype", "linux");
if (kernel)
xenstore_write_str(vm, "image/kernel", kernel);
if (ramdisk)
xenstore_write_str(vm, "image/ramdisk", ramdisk);
if (cmdline)
xenstore_write_str(vm, "image/cmdline", cmdline);
xenstore_write_str(vm, "name", qemu_name ? qemu_name : "no-name");
xenstore_write_str(vm, "uuid", uuid_string);
xenstore_write_str(dom, "name", qemu_name ? qemu_name : "no-name");
xenstore_write_int(dom, "domid", xen_domid);
xenstore_write_str(dom, "vm", vm);
xenstore_write_int(dom, "memory/target", ram_size >> 10);
xenstore_write_int(vm, "memory", ram_size >> 20);
xenstore_write_int(vm, "maxmem", ram_size >> 20);
for (i = 0; i < smp_cpus; i++) {
snprintf(path, sizeof(path), "cpu/%d/availability",i);
xenstore_write_str(dom, path, "online");
}
xenstore_write_int(vm, "vcpu_avail", smp_cpus);
xenstore_write_int(vm, "vcpus", smp_cpus);
xenstore_write_str(vm, "vncpassword", "" );
free(dom);
return 0;
}
| 1threat |
Is it possible to run docker image/DockerFile on AWS Lambda? : <p>I want to deploy a docker image with my given Dockerfile that executes a program on the AWS Lambda cloud. I know it is possible for EC2 but I want to use AWS Lambda. Anyone have references or know if it is possible? </p>
<p>I was looking at the AWS Elastic Beanstalk as well that has docker capabilities, but it seems it is for web applications? My program that i'm trying to execute on the cloud is NOT a web application.</p>
<p>Let me know,</p>
<p>Thanks.</p>
| 0debug |
static void usb_msd_handle_data(USBDevice *dev, USBPacket *p)
{
MSDState *s = (MSDState *)dev;
uint32_t tag;
struct usb_msd_cbw cbw;
uint8_t devep = p->ep->nr;
switch (p->pid) {
case USB_TOKEN_OUT:
if (devep != 2)
goto fail;
switch (s->mode) {
case USB_MSDM_CBW:
if (p->iov.size != 31) {
fprintf(stderr, "usb-msd: Bad CBW size");
goto fail;
}
usb_packet_copy(p, &cbw, 31);
if (le32_to_cpu(cbw.sig) != 0x43425355) {
fprintf(stderr, "usb-msd: Bad signature %08x\n",
le32_to_cpu(cbw.sig));
goto fail;
}
DPRINTF("Command on LUN %d\n", cbw.lun);
if (cbw.lun != 0) {
fprintf(stderr, "usb-msd: Bad LUN %d\n", cbw.lun);
goto fail;
}
tag = le32_to_cpu(cbw.tag);
s->data_len = le32_to_cpu(cbw.data_len);
if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
} else if (cbw.flags & 0x80) {
s->mode = USB_MSDM_DATAIN;
} else {
s->mode = USB_MSDM_DATAOUT;
}
DPRINTF("Command tag 0x%x flags %08x len %d data %d\n",
tag, cbw.flags, cbw.cmd_len, s->data_len);
assert(le32_to_cpu(s->csw.residue) == 0);
s->scsi_len = 0;
s->req = scsi_req_new(s->scsi_dev, tag, 0, cbw.cmd, NULL);
#ifdef DEBUG_MSD
scsi_req_print(s->req);
#endif
scsi_req_enqueue(s->req);
if (s->req && s->req->cmd.xfer != SCSI_XFER_NONE) {
scsi_req_continue(s->req);
}
break;
case USB_MSDM_DATAOUT:
DPRINTF("Data out %zd/%d\n", p->iov.size, s->data_len);
if (p->iov.size > s->data_len) {
goto fail;
}
if (s->scsi_len) {
usb_msd_copy_data(s, p);
}
if (le32_to_cpu(s->csw.residue)) {
int len = p->iov.size - p->actual_length;
if (len) {
usb_packet_skip(p, len);
s->data_len -= len;
if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
}
}
}
if (p->actual_length < p->iov.size) {
DPRINTF("Deferring packet %p [wait data-out]\n", p);
s->packet = p;
p->status = USB_RET_ASYNC;
}
break;
default:
DPRINTF("Unexpected write (len %zd)\n", p->iov.size);
goto fail;
}
break;
case USB_TOKEN_IN:
if (devep != 1)
goto fail;
switch (s->mode) {
case USB_MSDM_DATAOUT:
if (s->data_len != 0 || p->iov.size < 13) {
goto fail;
}
s->packet = p;
p->status = USB_RET_ASYNC;
break;
case USB_MSDM_CSW:
if (p->iov.size < 13) {
goto fail;
}
if (s->req) {
DPRINTF("Deferring packet %p [wait status]\n", p);
s->packet = p;
p->status = USB_RET_ASYNC;
} else {
usb_msd_send_status(s, p);
s->mode = USB_MSDM_CBW;
}
break;
case USB_MSDM_DATAIN:
DPRINTF("Data in %zd/%d, scsi_len %d\n",
p->iov.size, s->data_len, s->scsi_len);
if (s->scsi_len) {
usb_msd_copy_data(s, p);
}
if (le32_to_cpu(s->csw.residue)) {
int len = p->iov.size - p->actual_length;
if (len) {
usb_packet_skip(p, len);
s->data_len -= len;
if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
}
}
}
if (p->actual_length < p->iov.size) {
DPRINTF("Deferring packet %p [wait data-in]\n", p);
s->packet = p;
p->status = USB_RET_ASYNC;
}
break;
default:
DPRINTF("Unexpected read (len %zd)\n", p->iov.size);
goto fail;
}
break;
default:
DPRINTF("Bad token\n");
fail:
p->status = USB_RET_STALL;
break;
}
}
| 1threat |
How to change value of input type file in Jquery : <p>I have got this HTML code</p>
<pre><code><img src="../img/1.jpg" class="img">
<img src="../img/2.jpg" class="img">
<img src="../img/3.jpg" class="img">
<img src="../img/4.jpg" class="img">
<input type="file" name="file" id="file" onchange="bgchange(this)" >
</code></pre>
<p>And this jquery</p>
<pre><code>$(".img").click(function(){
var srcat=$(this).attr('src');
$("#file").attr('value',srcat);
alert($("#file").val());
});
</code></pre>
<p>But it is not changing any value it stays empty.Is there anyway i can change that?</p>
| 0debug |
static inline void downmix_dualmono_to_stereo(float *samples)
{
int i;
float tmp;
for (i = 0; i < 256; i++) {
tmp = samples[i] + samples[i + 256];
samples[i] = samples[i + 256] = tmp;
}
}
| 1threat |
static int exif_add_metadata(AVCodecContext *avctx, int count, int type,
const char *name, const char *sep,
GetByteContext *gb, int le,
AVDictionary **metadata)
{
switch(type) {
case 0:
av_log(avctx, AV_LOG_WARNING,
"Invalid TIFF tag type 0 found for %s with size %d\n",
name, count);
return 0;
case TIFF_DOUBLE : return ff_tadd_doubles_metadata(count, name, sep, gb, le, metadata);
case TIFF_SSHORT : return ff_tadd_shorts_metadata(count, name, sep, gb, le, 1, metadata);
case TIFF_SHORT : return ff_tadd_shorts_metadata(count, name, sep, gb, le, 0, metadata);
case TIFF_SBYTE : return ff_tadd_bytes_metadata(count, name, sep, gb, le, 1, metadata);
case TIFF_BYTE :
case TIFF_UNDEFINED: return ff_tadd_bytes_metadata(count, name, sep, gb, le, 0, metadata);
case TIFF_STRING : return ff_tadd_string_metadata(count, name, gb, le, metadata);
case TIFF_SRATIONAL:
case TIFF_RATIONAL : return ff_tadd_rational_metadata(count, name, sep, gb, le, metadata);
case TIFF_SLONG :
case TIFF_LONG : return ff_tadd_long_metadata(count, name, sep, gb, le, metadata);
default:
avpriv_request_sample(avctx, "TIFF tag type (%u)", type);
return 0;
};
}
| 1threat |
static gboolean udp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque)
{
CharDriverState *chr = opaque;
NetCharDriver *s = chr->opaque;
gsize bytes_read = 0;
GIOStatus status;
if (s->max_size == 0) {
return TRUE;
}
status = g_io_channel_read_chars(s->chan, (gchar *)s->buf, sizeof(s->buf),
&bytes_read, NULL);
s->bufcnt = bytes_read;
s->bufptr = s->bufcnt;
if (status != G_IO_STATUS_NORMAL) {
if (s->tag) {
g_source_remove(s->tag);
s->tag = 0;
}
return FALSE;
}
s->bufptr = 0;
while (s->max_size > 0 && s->bufptr < s->bufcnt) {
qemu_chr_be_write(chr, &s->buf[s->bufptr], 1);
s->bufptr++;
s->max_size = qemu_chr_be_can_write(chr);
}
return TRUE;
}
| 1threat |
Efficient Searching according to starts with : I facing some issue with write logic for below problem.
I have two ArrayLists of strings
List1: contains huge data(Around 50 lakhs strings)
List2: will create on users input and contains some strings/characters(Ex. a,b,c,g,l,pd,sp,mta)
========================================================================
now I have to split list1 into multiple Lists according to startsWith strings in list2
like in above case
I need to create 8 lists as starts with '**a**', '**b**','**c**', '**g**', '**l**','**pd**', '**sp**' and '**mta**'
But the condition for above is I have to iterate List1 or List2 only once. i.e. worst complexity for algorithm should be size of List1 (50 lakhs in above case)
(Note: It is allowed to use collections.sort() method)
Can anyone please help me out around the logic.
Thanks in advance.
| 0debug |
Does implementing the Dispose Pattern make an unmanaged resource managed? : <p>Let's say I have a class that talks to the database (using DataContext) called BusinessDatabase. My understanding is that this class is unmanaged.</p>
<p>Then I have a class called Foo that uses BusinessDatabase and it implements the Dispose Pattern because it contains an unmanaged resource.</p>
<p>Is Foo managed or unmanaged? (i.e. in other classes that use Foo, do they need to dispose of Foo like a managed or unmanaged resource?)</p>
| 0debug |
sidebar broken on wordpress site : Ok I have a site im building and its beautiful. i love the theme. but on my shop page the sidebar is working fine but on the wcfm marketplace store page the sidebar is covering the page. its the mobile view
the shop page is here
https://melaninmart.com/shop/
the store page is here
https://melaninmart.com/store/lustablesz-cosmetics/
Thanks in advance | 0debug |
Why duck typing is allowed for classes in TypeScript : <p>Looks like in TypeScript it's absolutely fine (from the compiler perspective) to have such code:</p>
<pre><code>class Vehicle {
public run(): void { console.log('Vehicle.run'); }
}
class Task {
public run(): void { console.log('Task.run'); }
}
function runTask(t: Task) {
t.run();
}
runTask(new Task());
runTask(new Vehicle());
</code></pre>
<p>But at the same time I would expect a <strong>compilation error</strong>, because <code>Vehicle</code> and <code>Task</code> don't have anything in common.</p>
<p>And <em>sane</em> usages can be implemented via explicit interface definition:</p>
<pre><code>interface Runnable {
run(): void;
}
class Vehicle implements Runnable {
public run(): void { console.log('Vehicle.run'); }
}
class Task implements Runnable {
public run(): void { console.log('Task.run'); }
}
function runRunnable(r: Runnable) {
r.run();
}
runRunnable(new Task());
runRunnable(new Vehicle());
</code></pre>
<p>... or a common parent object:</p>
<pre><code>class Entity {
abstract run(): void;
}
class Vehicle extends Entity {
public run(): void { console.log('Vehicle.run'); }
}
class Task extends Entity {
public run(): void { console.log('Task.run'); }
}
function runEntity(e: Entity) {
e.run();
}
runEntity(new Task());
runEntity(new Vehicle());
</code></pre>
<p>And yes, for JavaScript it's absolutely fine to have such behaviour, because there is no classes and no compiler at all (only syntactic sugar) and duck typing is natural for the language. But TypeScript tries to introduce static checks, classes, interfaces, etc. However duck typing for class instances looks rather confusing and error-prone, in my opinion.</p>
| 0debug |
Android Cardview Multiple activities : I working on Android studio 3.0.1. I working a project on android cardview. I see a video tutorial on android cardview. I write code carefully. But when I run code, it saw some error.
[error screenshot on here][1]
My **MainActivity.java** code:
private void setSingleEvent(GridLayout mainGrid) {
//Loop all child item of Main Grid
for (int i = 0; i < mainGrid.getChildCount(); i++) {
//You can see , all child item is CardView , so we just cast object to CardView
CardView cardView = (CardView) mainGrid.getChildAt(i);
final int finalI = i;
cardView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (finalI == 0) //Teachers Activities
{
Intent intent = new Intent( packageContext: MainActivity.this, Teachers.class);
startActivity(intent);
}
else if (finalI == 1) //Students Activities
{
Intent intent = new Intent( packageContext: MainActivity.this, Students.class);
startActivity(intent);
}
else if (finalI == 2) //Students Activities
{
Intent intent = new Intent( packageContext: MainActivity.this, Students.class);
startActivity(intent);
}
else if (finalI == 3) //Notices Activities
{
Intent intent = new Intent( packageContext: MainActivity.this, Notices.class);
startActivity(intent);
}
else if (finalI == 4) //Results Activities
{
Intent intent = new Intent( packageContext: MainActivity.this, Results.class);
startActivity(intent);
}
else if (finalI == 5) //Phones Activities
{
Intent intent = new Intent( packageContext: MainActivity.this, Phones.class);
startActivity(intent);
}
else if (finalI == 6) //Blood Activities
{
Intent intent = new Intent( packageContext: MainActivity.this, Bloods.class);
startActivity(intent);
}
else {
Toast.makeText(MainActivity.this, "Activvvv", Toast.LENGTH_SHORT).show();
}
}
});
}
}
}
[Full Source code on here][2]
[1]: https://i.stack.imgur.com/K2hsl.png
[2]: https://drive.google.com/file/d/1zmzy6NMvrWsv3pBcf6jn9mg06uU49nHx/view | 0debug |
static int nvenc_get_frame(AVCodecContext *avctx, AVPacket *pkt)
{
NVENCContext *ctx = avctx->priv_data;
NV_ENCODE_API_FUNCTION_LIST *nv = &ctx->nvel.nvenc_funcs;
NV_ENC_LOCK_BITSTREAM params = { 0 };
NVENCOutputSurface *out = NULL;
int ret;
ret = nvenc_dequeue_surface(ctx->pending, &out);
if (ret)
return ret;
params.version = NV_ENC_LOCK_BITSTREAM_VER;
params.outputBitstream = out->out;
ret = nv->nvEncLockBitstream(ctx->nvenc_ctx, ¶ms);
if (ret < 0)
return nvenc_print_error(avctx, ret, "Cannot lock the bitstream");
ret = ff_alloc_packet(pkt, params.bitstreamSizeInBytes);
if (ret < 0)
return ret;
memcpy(pkt->data, params.bitstreamBufferPtr, pkt->size);
ret = nv->nvEncUnlockBitstream(ctx->nvenc_ctx, out->out);
if (ret < 0)
return nvenc_print_error(avctx, ret, "Cannot unlock the bitstream");
out->busy = out->in->locked = 0;
ret = nvenc_set_timestamp(ctx, ¶ms, pkt);
if (ret < 0)
return ret;
switch (params.pictureType) {
case NV_ENC_PIC_TYPE_IDR:
pkt->flags |= AV_PKT_FLAG_KEY;
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
case NV_ENC_PIC_TYPE_INTRA_REFRESH:
case NV_ENC_PIC_TYPE_I:
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
break;
case NV_ENC_PIC_TYPE_P:
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_P;
break;
case NV_ENC_PIC_TYPE_B:
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_B;
break;
case NV_ENC_PIC_TYPE_BI:
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_BI;
break;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
}
return 0;
}
| 1threat |
python linux selenium: chrome not reachable : <p>I'm trying to run selenium on Ubuntu 16.10 Server, but I'm getting WebDriverException : Message : chrome not reachable (Driver info: chromedriver 2.9.248304, platform=Linux 4.8.0-22-generic x86_64)</p>
<pre><code>from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=0, size=(800, 600))
display.start()
browser = webdriver.Chrome('usr/bin/chromedriver')
browser.get('http://www.google.com')
print(browser.title)
browser.quit()
display.stop()
</code></pre>
<p>Chrome is installed: </p>
<pre><code>google-chrome --version
</code></pre>
<p>Google Chrome 57.0.2987.110</p>
| 0debug |
How to change JSON Array object key name in JavaScript? : I have a JSON Array Object in the following form
var data = [{"name":"Lenovo Thinkpad 41A4298","website":"google"},
{"name":"Lenovo Thinkpad 41A2222","website":"google"},
{"name":"Lenovo Thinkpad 41Awww33","website":"yahoo"}];
I want to convert this to
var data = [{"Brand":"Lenovo Thinkpad 41A4298","Link":"google"},
{"Brand":"Lenovo Thinkpad 41A2222","Link":"google"},
{"Brand":"Lenovo Thinkpad 41Awww33","Link":"yahoo"}];
How do I achieve this? | 0debug |
static int curl_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVCURLState *s = bs->opaque;
CURLState *state = NULL;
QemuOpts *opts;
Error *local_err = NULL;
const char *file;
const char *cookie;
const char *cookie_secret;
double d;
const char *secretid;
const char *protocol_delimiter;
static int inited = 0;
if (flags & BDRV_O_RDWR) {
error_setg(errp, "curl block device does not support writes");
return -EROFS;
}
qemu_mutex_init(&s->mutex);
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto out_noclean;
}
s->readahead_size = qemu_opt_get_size(opts, CURL_BLOCK_OPT_READAHEAD,
READ_AHEAD_DEFAULT);
if ((s->readahead_size & 0x1ff) != 0) {
error_setg(errp, "HTTP_READAHEAD_SIZE %zd is not a multiple of 512",
s->readahead_size);
goto out_noclean;
}
s->timeout = qemu_opt_get_number(opts, CURL_BLOCK_OPT_TIMEOUT,
CURL_TIMEOUT_DEFAULT);
if (s->timeout > CURL_TIMEOUT_MAX) {
error_setg(errp, "timeout parameter is too large or negative");
goto out_noclean;
}
s->sslverify = qemu_opt_get_bool(opts, CURL_BLOCK_OPT_SSLVERIFY, true);
cookie = qemu_opt_get(opts, CURL_BLOCK_OPT_COOKIE);
cookie_secret = qemu_opt_get(opts, CURL_BLOCK_OPT_COOKIE_SECRET);
if (cookie && cookie_secret) {
error_setg(errp,
"curl driver cannot handle both cookie and cookie secret");
goto out_noclean;
}
if (cookie_secret) {
s->cookie = qcrypto_secret_lookup_as_utf8(cookie_secret, errp);
if (!s->cookie) {
goto out_noclean;
}
} else {
s->cookie = g_strdup(cookie);
}
file = qemu_opt_get(opts, CURL_BLOCK_OPT_URL);
if (file == NULL) {
error_setg(errp, "curl block driver requires an 'url' option");
goto out_noclean;
}
if (!strstart(file, bs->drv->protocol_name, &protocol_delimiter) ||
!strstart(protocol_delimiter, ":
{
error_setg(errp, "%s curl driver cannot handle the URL '%s' (does not "
"start with '%s:
bs->drv->protocol_name);
goto out_noclean;
}
s->username = g_strdup(qemu_opt_get(opts, CURL_BLOCK_OPT_USERNAME));
secretid = qemu_opt_get(opts, CURL_BLOCK_OPT_PASSWORD_SECRET);
if (secretid) {
s->password = qcrypto_secret_lookup_as_utf8(secretid, errp);
if (!s->password) {
goto out_noclean;
}
}
s->proxyusername = g_strdup(
qemu_opt_get(opts, CURL_BLOCK_OPT_PROXY_USERNAME));
secretid = qemu_opt_get(opts, CURL_BLOCK_OPT_PROXY_PASSWORD_SECRET);
if (secretid) {
s->proxypassword = qcrypto_secret_lookup_as_utf8(secretid, errp);
if (!s->proxypassword) {
goto out_noclean;
}
}
if (!inited) {
curl_global_init(CURL_GLOBAL_ALL);
inited = 1;
}
DPRINTF("CURL: Opening %s\n", file);
QSIMPLEQ_INIT(&s->free_state_waitq);
s->aio_context = bdrv_get_aio_context(bs);
s->url = g_strdup(file);
qemu_mutex_lock(&s->mutex);
state = curl_find_state(s);
qemu_mutex_unlock(&s->mutex);
if (!state) {
goto out_noclean;
}
if (curl_init_state(s, state) < 0) {
goto out;
}
s->accept_range = false;
curl_easy_setopt(state->curl, CURLOPT_NOBODY, 1);
curl_easy_setopt(state->curl, CURLOPT_HEADERFUNCTION,
curl_header_cb);
curl_easy_setopt(state->curl, CURLOPT_HEADERDATA, s);
if (curl_easy_perform(state->curl))
goto out;
if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d)) {
goto out;
}
#if LIBCURL_VERSION_NUM >= 0x071304
if (d < 0) {
pstrcpy(state->errmsg, CURL_ERROR_SIZE,
"Server didn't report file size.");
goto out;
}
#else
if (d <= 0) {
pstrcpy(state->errmsg, CURL_ERROR_SIZE,
"Unknown file size or zero-length file.");
goto out;
}
#endif
s->len = d;
if ((!strncasecmp(s->url, "http:
|| !strncasecmp(s->url, "https:
&& !s->accept_range) {
pstrcpy(state->errmsg, CURL_ERROR_SIZE,
"Server does not support 'range' (byte ranges).");
goto out;
}
DPRINTF("CURL: Size = %" PRIu64 "\n", s->len);
qemu_mutex_lock(&s->mutex);
curl_clean_state(state);
qemu_mutex_unlock(&s->mutex);
curl_easy_cleanup(state->curl);
state->curl = NULL;
curl_attach_aio_context(bs, bdrv_get_aio_context(bs));
qemu_opts_del(opts);
return 0;
out:
error_setg(errp, "CURL: Error opening file: %s", state->errmsg);
curl_easy_cleanup(state->curl);
state->curl = NULL;
out_noclean:
qemu_mutex_destroy(&s->mutex);
g_free(s->cookie);
g_free(s->url);
qemu_opts_del(opts);
return -EINVAL;
}
| 1threat |
static int decompress_i(AVCodecContext *avctx, uint32_t *dst, int linesize)
{
SCPRContext *s = avctx->priv_data;
GetByteContext *gb = &s->gb;
int cx = 0, cx1 = 0, k = 0, clr = 0;
int run, r, g, b, off, y = 0, x = 0, ret;
const int cxshift = s->cxshift;
unsigned lx, ly, ptype;
reinit_tables(s);
bytestream2_skip(gb, 2);
init_rangecoder(&s->rc, gb);
while (k < avctx->width + 1) {
ret = decode_unit(s, &s->pixel_model[0][cx + cx1], 400, &r);
if (ret < 0)
return ret;
cx1 = (cx << 6) & 0xFC0;
cx = r >> cxshift;
ret = decode_unit(s, &s->pixel_model[1][cx + cx1], 400, &g);
if (ret < 0)
return ret;
cx1 = (cx << 6) & 0xFC0;
cx = g >> cxshift;
ret = decode_unit(s, &s->pixel_model[2][cx + cx1], 400, &b);
if (ret < 0)
return ret;
cx1 = (cx << 6) & 0xFC0;
cx = b >> cxshift;
ret = decode_value(s, s->run_model[0], 256, 400, &run);
if (ret < 0)
return ret;
clr = (b << 16) + (g << 8) + r;
k += run;
while (run-- > 0) {
dst[y * linesize + x] = clr;
lx = x;
ly = y;
x++;
if (x >= avctx->width) {
x = 0;
y++;
}
}
}
off = -linesize - 1;
ptype = 0;
while (x < avctx->width && y < avctx->height) {
ret = decode_value(s, s->op_model[ptype], 6, 1000, &ptype);
if (ret < 0)
return ret;
if (ptype == 0) {
ret = decode_unit(s, &s->pixel_model[0][cx + cx1], 400, &r);
if (ret < 0)
return ret;
cx1 = (cx << 6) & 0xFC0;
cx = r >> cxshift;
ret = decode_unit(s, &s->pixel_model[1][cx + cx1], 400, &g);
if (ret < 0)
return ret;
cx1 = (cx << 6) & 0xFC0;
cx = g >> cxshift;
ret = decode_unit(s, &s->pixel_model[2][cx + cx1], 400, &b);
if (ret < 0)
return ret;
cx1 = (cx << 6) & 0xFC0;
cx = b >> cxshift;
clr = (b << 16) + (g << 8) + r;
}
if (ptype > 5)
return AVERROR_INVALIDDATA;
ret = decode_value(s, s->run_model[ptype], 256, 400, &run);
if (ret < 0)
return ret;
switch (ptype) {
case 0:
while (run-- > 0) {
dst[y * linesize + x] = clr;
lx = x;
ly = y;
x++;
if (x >= avctx->width) {
x = 0;
y++;
}
}
break;
case 1:
while (run-- > 0) {
dst[y * linesize + x] = dst[ly * linesize + lx];
lx = x;
ly = y;
x++;
if (x >= avctx->width) {
x = 0;
y++;
}
}
clr = dst[ly * linesize + lx];
break;
case 2:
while (run-- > 0) {
clr = dst[y * linesize + x + off + 1];
dst[y * linesize + x] = clr;
lx = x;
ly = y;
x++;
if (x >= avctx->width) {
x = 0;
y++;
}
}
break;
case 4:
while (run-- > 0) {
uint8_t *odst = (uint8_t *)dst;
r = odst[(ly * linesize + lx) * 4] +
odst[((y * linesize + x) + off) * 4 + 4] -
odst[((y * linesize + x) + off) * 4];
g = odst[(ly * linesize + lx) * 4 + 1] +
odst[((y * linesize + x) + off) * 4 + 5] -
odst[((y * linesize + x) + off) * 4 + 1];
b = odst[(ly * linesize + lx) * 4 + 2] +
odst[((y * linesize + x) + off) * 4 + 6] -
odst[((y * linesize + x) + off) * 4 + 2];
clr = ((b & 0xFF) << 16) + ((g & 0xFF) << 8) + (r & 0xFF);
dst[y * linesize + x] = clr;
lx = x;
ly = y;
x++;
if (x >= avctx->width) {
x = 0;
y++;
}
}
break;
case 5:
while (run-- > 0) {
clr = dst[y * linesize + x + off];
dst[y * linesize + x] = clr;
lx = x;
ly = y;
x++;
if (x >= avctx->width) {
x = 0;
y++;
}
}
break;
}
if (avctx->bits_per_coded_sample == 16) {
cx1 = (clr & 0xFF00) >> 2;
cx = (clr & 0xFFFFFF) >> 16;
} else {
cx1 = (clr & 0xFC00) >> 4;
cx = (clr & 0xFFFFFF) >> 18;
}
}
return 0;
}
| 1threat |
ArrayList is allowing me to store items to it but not call them using .get(), says it isn't an ArrayList : <p>I am writing a program to simulate a restaurant menu system using the command design pattern. I made the construtor in my Menu class initialize an arraylist.</p>
<pre><code>import java.util.ArrayList;
public class Menu {
public ArrayList<MenuItem> listOfMenuItems;
public Menu() {
listOfMenuItems = new ArrayList<MenuItem>();
}
public void addItemToMenu(String itemName, String itemDescription, double cost) {
MenuItem newMenuItem = new MenuItem(itemName, itemDescription, cost);
listOfMenuItems.add(newMenuItem);
}
public void displayMenu() {
for(MenuItem item : listOfMenuItems) {
System.out.println("NAME: " + item.getItemName() + ", DESCRIPTION: " + item.getItemDescription()
+ ", COST: " + item.getItemCost());
}
}
}
</code></pre>
<p>When calling a new Menu in my client, it allows me to store items (as if it was an arraylist), it also allows me to implement the command design pattern and print all of my items out. However, I was adding a Tab class which used information from my Menu object, but it doesn't let me use .get() to retrieve information from my arraylist.</p>
<pre><code>import java.util.*;
public class testClient {
public static void main(String[] args) {
Menu menu = new Menu();
Tab tab;
System.out.println("MENU:");
menu.addItemToMenu("lobster", "#1234" , 25.99);
menu.addItemToMenu("chicken", "#5687" , 20.99);
menu.addItemToMenu("steak", "#4567" , 21.99);
DisplayMenu dispMenu = new DisplayMenu(menu);
SubmitButton onPressed = new SubmitButton(dispMenu);
onPressed.submit();
System.out.print("\n");
System.out.println("ORDERS:");
Order order = new Order();
order.addNewOrder("#1234");
order.addNewOrder("#5678");
SubmitOrder submitOrder = new SubmitOrder(order);
SubmitButton onSubmitPressed = new SubmitButton(submitOrder);
onSubmitPressed.submit();
tab.constructTab(newMenu.get(0).getItemName(), order.get(0).getOrderItemNumber(), newMenu.get(0).getItemCost());
}
}
</code></pre>
<p>The line tab.constructTab(....), returns the following error:</p>
<pre><code>testClient.java:31: error: cannot find symbol
tab.constructTab(menu.get(0).getItemName(), order.get(0).getOrderItemNumber(), menu.get(0).getItemCost());
^
symbol: method get(int)
location: variable menu of type Menu
testClient.java:31: error: cannot find symbol
tab.constructTab(menu.get(0).getItemName(), order.get(0).getOrderItemNumber(), menu.get(0).getItemCost());
^
symbol: method get(int)
location: variable order of type Order
testClient.java:31: error: cannot find symbol
tab.constructTab(menu.get(0).getItemName(), order.get(0).getOrderItemNumber(), menu.get(0).getItemCost());
^
symbol: method get(int)
location: variable menu of type Menu
3 errors
</code></pre>
<p>it says that menu is of type Menu when it should be an arraylist? I don't understand why it allows me to add items then.</p>
<p>Please let me know if you need any additional code.</p>
<p>Thank you in advance!</p>
| 0debug |
extract persian data from String in java : i want to extract this pattern from Variable String in java(android studio) that always include this pattern but another texts are Variable and don't have same number :
" this internet will expires on 1397/7/16 22:30"
i just want extract YYYY/MM/DD pattern every time
for example give me this: "1397/7/16"
how i can do this? | 0debug |
static uint8_t *disas_insn(DisasContext *s, uint8_t *pc_start)
{
int b, prefixes, aflag, dflag;
int shift, ot;
int modrm, reg, rm, mod, reg_addr, op, opreg, offset_addr, val;
unsigned int next_eip;
s->pc = pc_start;
prefixes = 0;
aflag = s->code32;
dflag = s->code32;
s->override = -1;
next_byte:
b = ldub_code(s->pc);
s->pc++;
switch (b) {
case 0xf3:
prefixes |= PREFIX_REPZ;
goto next_byte;
case 0xf2:
prefixes |= PREFIX_REPNZ;
goto next_byte;
case 0xf0:
prefixes |= PREFIX_LOCK;
goto next_byte;
case 0x2e:
s->override = R_CS;
goto next_byte;
case 0x36:
s->override = R_SS;
goto next_byte;
case 0x3e:
s->override = R_DS;
goto next_byte;
case 0x26:
s->override = R_ES;
goto next_byte;
case 0x64:
s->override = R_FS;
goto next_byte;
case 0x65:
s->override = R_GS;
goto next_byte;
case 0x66:
prefixes |= PREFIX_DATA;
goto next_byte;
case 0x67:
prefixes |= PREFIX_ADR;
goto next_byte;
}
if (prefixes & PREFIX_DATA)
dflag ^= 1;
if (prefixes & PREFIX_ADR)
aflag ^= 1;
s->prefix = prefixes;
s->aflag = aflag;
s->dflag = dflag;
if (prefixes & PREFIX_LOCK)
gen_op_lock();
reswitch:
switch(b) {
case 0x0f:
b = ldub_code(s->pc++) | 0x100;
goto reswitch;
case 0x00 ... 0x05:
case 0x08 ... 0x0d:
case 0x10 ... 0x15:
case 0x18 ... 0x1d:
case 0x20 ... 0x25:
case 0x28 ... 0x2d:
case 0x30 ... 0x35:
case 0x38 ... 0x3d:
{
int op, f, val;
op = (b >> 3) & 7;
f = (b >> 1) & 3;
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
switch(f) {
case 0:
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7);
mod = (modrm >> 6) & 3;
rm = modrm & 7;
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
opreg = OR_TMP0;
} else if (op == OP_XORL && rm == reg) {
xor_zero:
gen_op_movl_T0_0();
s->cc_op = CC_OP_LOGICB + ot;
gen_op_mov_reg_T0[ot][reg]();
gen_op_update1_cc();
break;
} else {
opreg = rm;
}
gen_op_mov_TN_reg[ot][1][reg]();
gen_op(s, op, ot, opreg);
break;
case 1:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
reg = ((modrm >> 3) & 7);
rm = modrm & 7;
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T1_A0[ot + s->mem_index]();
} else if (op == OP_XORL && rm == reg) {
goto xor_zero;
} else {
gen_op_mov_TN_reg[ot][1][rm]();
}
gen_op(s, op, ot, reg);
break;
case 2:
val = insn_get(s, ot);
gen_op_movl_T1_im(val);
gen_op(s, op, ot, OR_EAX);
break;
}
}
break;
case 0x80:
case 0x81:
case 0x82:
case 0x83:
{
int val;
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = modrm & 7;
op = (modrm >> 3) & 7;
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
opreg = OR_TMP0;
} else {
opreg = rm + OR_EAX;
}
switch(b) {
default:
case 0x80:
case 0x81:
case 0x82:
val = insn_get(s, ot);
break;
case 0x83:
val = (int8_t)insn_get(s, OT_BYTE);
break;
}
gen_op_movl_T1_im(val);
gen_op(s, op, ot, opreg);
}
break;
case 0x40 ... 0x47:
ot = dflag ? OT_LONG : OT_WORD;
gen_inc(s, ot, OR_EAX + (b & 7), 1);
break;
case 0x48 ... 0x4f:
ot = dflag ? OT_LONG : OT_WORD;
gen_inc(s, ot, OR_EAX + (b & 7), -1);
break;
case 0xf6:
case 0xf7:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = modrm & 7;
op = (modrm >> 3) & 7;
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T0_A0[ot + s->mem_index]();
} else {
gen_op_mov_TN_reg[ot][0][rm]();
}
switch(op) {
case 0:
val = insn_get(s, ot);
gen_op_movl_T1_im(val);
gen_op_testl_T0_T1_cc();
s->cc_op = CC_OP_LOGICB + ot;
break;
case 2:
gen_op_notl_T0();
if (mod != 3) {
gen_op_st_T0_A0[ot + s->mem_index]();
} else {
gen_op_mov_reg_T0[ot][rm]();
}
break;
case 3:
gen_op_negl_T0();
if (mod != 3) {
gen_op_st_T0_A0[ot + s->mem_index]();
} else {
gen_op_mov_reg_T0[ot][rm]();
}
gen_op_update_neg_cc();
s->cc_op = CC_OP_SUBB + ot;
break;
case 4:
switch(ot) {
case OT_BYTE:
gen_op_mulb_AL_T0();
s->cc_op = CC_OP_MULB;
break;
case OT_WORD:
gen_op_mulw_AX_T0();
s->cc_op = CC_OP_MULW;
break;
default:
case OT_LONG:
gen_op_mull_EAX_T0();
s->cc_op = CC_OP_MULL;
break;
}
break;
case 5:
switch(ot) {
case OT_BYTE:
gen_op_imulb_AL_T0();
s->cc_op = CC_OP_MULB;
break;
case OT_WORD:
gen_op_imulw_AX_T0();
s->cc_op = CC_OP_MULW;
break;
default:
case OT_LONG:
gen_op_imull_EAX_T0();
s->cc_op = CC_OP_MULL;
break;
}
break;
case 6:
switch(ot) {
case OT_BYTE:
gen_op_divb_AL_T0(pc_start - s->cs_base);
break;
case OT_WORD:
gen_op_divw_AX_T0(pc_start - s->cs_base);
break;
default:
case OT_LONG:
gen_op_divl_EAX_T0(pc_start - s->cs_base);
break;
}
break;
case 7:
switch(ot) {
case OT_BYTE:
gen_op_idivb_AL_T0(pc_start - s->cs_base);
break;
case OT_WORD:
gen_op_idivw_AX_T0(pc_start - s->cs_base);
break;
default:
case OT_LONG:
gen_op_idivl_EAX_T0(pc_start - s->cs_base);
break;
}
break;
default:
goto illegal_op;
}
break;
case 0xfe:
case 0xff:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = modrm & 7;
op = (modrm >> 3) & 7;
if (op >= 2 && b == 0xfe) {
goto illegal_op;
}
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (op >= 2 && op != 3 && op != 5)
gen_op_ld_T0_A0[ot + s->mem_index]();
} else {
gen_op_mov_TN_reg[ot][0][rm]();
}
switch(op) {
case 0:
if (mod != 3)
opreg = OR_TMP0;
else
opreg = rm;
gen_inc(s, ot, opreg, 1);
break;
case 1:
if (mod != 3)
opreg = OR_TMP0;
else
opreg = rm;
gen_inc(s, ot, opreg, -1);
break;
case 2:
if (s->dflag == 0)
gen_op_andl_T0_ffff();
next_eip = s->pc - s->cs_base;
gen_op_movl_T1_im(next_eip);
gen_push_T1(s);
gen_op_jmp_T0();
gen_eob(s);
break;
case 3:
gen_op_ld_T1_A0[ot + s->mem_index]();
gen_op_addl_A0_im(1 << (ot - OT_WORD + 1));
gen_op_ldu_T0_A0[OT_WORD + s->mem_index]();
do_lcall:
if (s->pe && !s->vm86) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_jmp_im(pc_start - s->cs_base);
gen_op_lcall_protected_T0_T1(dflag, s->pc - s->cs_base);
} else {
gen_op_lcall_real_T0_T1(dflag, s->pc - s->cs_base);
}
gen_eob(s);
break;
case 4:
if (s->dflag == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
gen_eob(s);
break;
case 5:
gen_op_ld_T1_A0[ot + s->mem_index]();
gen_op_addl_A0_im(1 << (ot - OT_WORD + 1));
gen_op_ldu_T0_A0[OT_WORD + s->mem_index]();
do_ljmp:
if (s->pe && !s->vm86) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_jmp_im(pc_start - s->cs_base);
gen_op_ljmp_protected_T0_T1(s->pc - s->cs_base);
} else {
gen_op_movl_seg_T0_vm(offsetof(CPUX86State,segs[R_CS]));
gen_op_movl_T0_T1();
gen_op_jmp_T0();
}
gen_eob(s);
break;
case 6:
gen_push_T0(s);
break;
default:
goto illegal_op;
}
break;
case 0x84:
case 0x85:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = modrm & 7;
reg = (modrm >> 3) & 7;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
gen_op_mov_TN_reg[ot][1][reg + OR_EAX]();
gen_op_testl_T0_T1_cc();
s->cc_op = CC_OP_LOGICB + ot;
break;
case 0xa8:
case 0xa9:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
val = insn_get(s, ot);
gen_op_mov_TN_reg[ot][0][OR_EAX]();
gen_op_movl_T1_im(val);
gen_op_testl_T0_T1_cc();
s->cc_op = CC_OP_LOGICB + ot;
break;
case 0x98:
if (dflag)
gen_op_movswl_EAX_AX();
else
gen_op_movsbw_AX_AL();
break;
case 0x99:
if (dflag)
gen_op_movslq_EDX_EAX();
else
gen_op_movswl_DX_AX();
break;
case 0x1af:
case 0x69:
case 0x6b:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) + OR_EAX;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
if (b == 0x69) {
val = insn_get(s, ot);
gen_op_movl_T1_im(val);
} else if (b == 0x6b) {
val = (int8_t)insn_get(s, OT_BYTE);
gen_op_movl_T1_im(val);
} else {
gen_op_mov_TN_reg[ot][1][reg]();
}
if (ot == OT_LONG) {
gen_op_imull_T0_T1();
} else {
gen_op_imulw_T0_T1();
}
gen_op_mov_reg_T0[ot][reg]();
s->cc_op = CC_OP_MULB + ot;
break;
case 0x1c0:
case 0x1c1:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
if (mod == 3) {
rm = modrm & 7;
gen_op_mov_TN_reg[ot][0][reg]();
gen_op_mov_TN_reg[ot][1][rm]();
gen_op_addl_T0_T1();
gen_op_mov_reg_T1[ot][reg]();
gen_op_mov_reg_T0[ot][rm]();
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_mov_TN_reg[ot][0][reg]();
gen_op_ld_T1_A0[ot + s->mem_index]();
gen_op_addl_T0_T1();
gen_op_st_T0_A0[ot + s->mem_index]();
gen_op_mov_reg_T1[ot][reg]();
}
gen_op_update2_cc();
s->cc_op = CC_OP_ADDB + ot;
break;
case 0x1b0:
case 0x1b1:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
gen_op_mov_TN_reg[ot][1][reg]();
if (mod == 3) {
rm = modrm & 7;
gen_op_mov_TN_reg[ot][0][rm]();
gen_op_cmpxchg_T0_T1_EAX_cc[ot]();
gen_op_mov_reg_T0[ot][rm]();
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T0_A0[ot + s->mem_index]();
gen_op_cmpxchg_mem_T0_T1_EAX_cc[ot + s->mem_index]();
}
s->cc_op = CC_OP_SUBB + ot;
break;
case 0x1c7:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_cmpxchg8b();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x50 ... 0x57:
gen_op_mov_TN_reg[OT_LONG][0][b & 7]();
gen_push_T0(s);
break;
case 0x58 ... 0x5f:
ot = dflag ? OT_LONG : OT_WORD;
gen_pop_T0(s);
gen_pop_update(s);
gen_op_mov_reg_T0[ot][b & 7]();
break;
case 0x60:
gen_pusha(s);
break;
case 0x61:
gen_popa(s);
break;
case 0x68:
case 0x6a:
ot = dflag ? OT_LONG : OT_WORD;
if (b == 0x68)
val = insn_get(s, ot);
else
val = (int8_t)insn_get(s, OT_BYTE);
gen_op_movl_T0_im(val);
gen_push_T0(s);
break;
case 0x8f:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
gen_pop_T0(s);
if (mod == 3) {
gen_pop_update(s);
rm = modrm & 7;
gen_op_mov_reg_T0[ot][rm]();
} else {
s->popl_esp_hack = 2 << dflag;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 1);
s->popl_esp_hack = 0;
gen_pop_update(s);
}
break;
case 0xc8:
{
int level;
val = lduw_code(s->pc);
s->pc += 2;
level = ldub_code(s->pc++);
gen_enter(s, val, level);
}
break;
case 0xc9:
if (s->ss32) {
gen_op_mov_TN_reg[OT_LONG][0][R_EBP]();
gen_op_mov_reg_T0[OT_LONG][R_ESP]();
} else {
gen_op_mov_TN_reg[OT_WORD][0][R_EBP]();
gen_op_mov_reg_T0[OT_WORD][R_ESP]();
}
gen_pop_T0(s);
ot = dflag ? OT_LONG : OT_WORD;
gen_op_mov_reg_T0[ot][R_EBP]();
gen_pop_update(s);
break;
case 0x06:
case 0x0e:
case 0x16:
case 0x1e:
gen_op_movl_T0_seg(b >> 3);
gen_push_T0(s);
break;
case 0x1a0:
case 0x1a8:
gen_op_movl_T0_seg((b >> 3) & 7);
gen_push_T0(s);
break;
case 0x07:
case 0x17:
case 0x1f:
reg = b >> 3;
gen_pop_T0(s);
gen_movl_seg_T0(s, reg, pc_start - s->cs_base);
gen_pop_update(s);
if (reg == R_SS) {
if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK))
gen_op_set_inhibit_irq();
s->tf = 0;
}
if (s->is_jmp) {
gen_op_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x1a1:
case 0x1a9:
gen_pop_T0(s);
gen_movl_seg_T0(s, (b >> 3) & 7, pc_start - s->cs_base);
gen_pop_update(s);
if (s->is_jmp) {
gen_op_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x88:
case 0x89:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
gen_ldst_modrm(s, modrm, ot, OR_EAX + reg, 1);
break;
case 0xc6:
case 0xc7:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
if (mod != 3)
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
val = insn_get(s, ot);
gen_op_movl_T0_im(val);
if (mod != 3)
gen_op_st_T0_A0[ot + s->mem_index]();
else
gen_op_mov_reg_T0[ot][modrm & 7]();
break;
case 0x8a:
case 0x8b:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
gen_op_mov_reg_T0[ot][reg]();
break;
case 0x8e:
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
if (reg >= 6 || reg == R_CS)
goto illegal_op;
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
gen_movl_seg_T0(s, reg, pc_start - s->cs_base);
if (reg == R_SS) {
if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK))
gen_op_set_inhibit_irq();
s->tf = 0;
}
if (s->is_jmp) {
gen_op_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x8c:
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
if (reg >= 6)
goto illegal_op;
gen_op_movl_T0_seg(reg);
ot = OT_WORD;
if (mod == 3 && dflag)
ot = OT_LONG;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 1);
break;
case 0x1b6:
case 0x1b7:
case 0x1be:
case 0x1bf:
{
int d_ot;
d_ot = dflag + OT_WORD;
ot = (b & 1) + OT_BYTE;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) + OR_EAX;
mod = (modrm >> 6) & 3;
rm = modrm & 7;
if (mod == 3) {
gen_op_mov_TN_reg[ot][0][rm]();
switch(ot | (b & 8)) {
case OT_BYTE:
gen_op_movzbl_T0_T0();
break;
case OT_BYTE | 8:
gen_op_movsbl_T0_T0();
break;
case OT_WORD:
gen_op_movzwl_T0_T0();
break;
default:
case OT_WORD | 8:
gen_op_movswl_T0_T0();
break;
}
gen_op_mov_reg_T0[d_ot][reg]();
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (b & 8) {
gen_op_lds_T0_A0[ot + s->mem_index]();
} else {
gen_op_ldu_T0_A0[ot + s->mem_index]();
}
gen_op_mov_reg_T0[d_ot][reg]();
}
}
break;
case 0x8d:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
reg = (modrm >> 3) & 7;
s->override = -1;
val = s->addseg;
s->addseg = 0;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
s->addseg = val;
gen_op_mov_reg_A0[ot - OT_WORD][reg]();
break;
case 0xa0:
case 0xa1:
case 0xa2:
case 0xa3:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
if (s->aflag)
offset_addr = insn_get(s, OT_LONG);
else
offset_addr = insn_get(s, OT_WORD);
gen_op_movl_A0_im(offset_addr);
{
int override, must_add_seg;
must_add_seg = s->addseg;
if (s->override >= 0) {
override = s->override;
must_add_seg = 1;
} else {
override = R_DS;
}
if (must_add_seg) {
gen_op_addl_A0_seg(offsetof(CPUX86State,segs[override].base));
}
}
if ((b & 2) == 0) {
gen_op_ld_T0_A0[ot + s->mem_index]();
gen_op_mov_reg_T0[ot][R_EAX]();
} else {
gen_op_mov_TN_reg[ot][0][R_EAX]();
gen_op_st_T0_A0[ot + s->mem_index]();
}
break;
case 0xd7:
gen_op_movl_A0_reg[R_EBX]();
gen_op_addl_A0_AL();
if (s->aflag == 0)
gen_op_andl_A0_ffff();
{
int override, must_add_seg;
must_add_seg = s->addseg;
override = R_DS;
if (s->override >= 0) {
override = s->override;
must_add_seg = 1;
} else {
override = R_DS;
}
if (must_add_seg) {
gen_op_addl_A0_seg(offsetof(CPUX86State,segs[override].base));
}
}
gen_op_ldu_T0_A0[OT_BYTE + s->mem_index]();
gen_op_mov_reg_T0[OT_BYTE][R_EAX]();
break;
case 0xb0 ... 0xb7:
val = insn_get(s, OT_BYTE);
gen_op_movl_T0_im(val);
gen_op_mov_reg_T0[OT_BYTE][b & 7]();
break;
case 0xb8 ... 0xbf:
ot = dflag ? OT_LONG : OT_WORD;
val = insn_get(s, ot);
reg = OR_EAX + (b & 7);
gen_op_movl_T0_im(val);
gen_op_mov_reg_T0[ot][reg]();
break;
case 0x91 ... 0x97:
ot = dflag ? OT_LONG : OT_WORD;
reg = b & 7;
rm = R_EAX;
goto do_xchg_reg;
case 0x86:
case 0x87:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
if (mod == 3) {
rm = modrm & 7;
do_xchg_reg:
gen_op_mov_TN_reg[ot][0][reg]();
gen_op_mov_TN_reg[ot][1][rm]();
gen_op_mov_reg_T0[ot][rm]();
gen_op_mov_reg_T1[ot][reg]();
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_mov_TN_reg[ot][0][reg]();
if (!(prefixes & PREFIX_LOCK))
gen_op_lock();
gen_op_ld_T1_A0[ot + s->mem_index]();
gen_op_st_T0_A0[ot + s->mem_index]();
if (!(prefixes & PREFIX_LOCK))
gen_op_unlock();
gen_op_mov_reg_T1[ot][reg]();
}
break;
case 0xc4:
op = R_ES;
goto do_lxx;
case 0xc5:
op = R_DS;
goto do_lxx;
case 0x1b2:
op = R_SS;
goto do_lxx;
case 0x1b4:
op = R_FS;
goto do_lxx;
case 0x1b5:
op = R_GS;
do_lxx:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T1_A0[ot + s->mem_index]();
gen_op_addl_A0_im(1 << (ot - OT_WORD + 1));
gen_op_ldu_T0_A0[OT_WORD + s->mem_index]();
gen_movl_seg_T0(s, op, pc_start - s->cs_base);
gen_op_mov_reg_T1[ot][reg]();
if (s->is_jmp) {
gen_op_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0xc0:
case 0xc1:
shift = 2;
grp2:
{
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = modrm & 7;
op = (modrm >> 3) & 7;
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
opreg = OR_TMP0;
} else {
opreg = rm + OR_EAX;
}
if (shift == 0) {
gen_shift(s, op, ot, opreg, OR_ECX);
} else {
if (shift == 2) {
shift = ldub_code(s->pc++);
}
gen_shifti(s, op, ot, opreg, shift);
}
}
break;
case 0xd0:
case 0xd1:
shift = 1;
goto grp2;
case 0xd2:
case 0xd3:
shift = 0;
goto grp2;
case 0x1a4:
op = 0;
shift = 1;
goto do_shiftd;
case 0x1a5:
op = 0;
shift = 0;
goto do_shiftd;
case 0x1ac:
op = 1;
shift = 1;
goto do_shiftd;
case 0x1ad:
op = 1;
shift = 0;
do_shiftd:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = modrm & 7;
reg = (modrm >> 3) & 7;
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T0_A0[ot + s->mem_index]();
} else {
gen_op_mov_TN_reg[ot][0][rm]();
}
gen_op_mov_TN_reg[ot][1][reg]();
if (shift) {
val = ldub_code(s->pc++);
val &= 0x1f;
if (val) {
if (mod == 3)
gen_op_shiftd_T0_T1_im_cc[ot][op](val);
else
gen_op_shiftd_mem_T0_T1_im_cc[ot + s->mem_index][op](val);
if (op == 0 && ot != OT_WORD)
s->cc_op = CC_OP_SHLB + ot;
else
s->cc_op = CC_OP_SARB + ot;
}
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
if (mod == 3)
gen_op_shiftd_T0_T1_ECX_cc[ot][op]();
else
gen_op_shiftd_mem_T0_T1_ECX_cc[ot + s->mem_index][op]();
s->cc_op = CC_OP_DYNAMIC;
}
if (mod == 3) {
gen_op_mov_reg_T0[ot][rm]();
}
break;
case 0xd8 ... 0xdf:
if (s->flags & (HF_EM_MASK | HF_TS_MASK)) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
break;
}
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = modrm & 7;
op = ((b & 7) << 3) | ((modrm >> 3) & 7);
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
switch(op) {
case 0x00 ... 0x07:
case 0x10 ... 0x17:
case 0x20 ... 0x27:
case 0x30 ... 0x37:
{
int op1;
op1 = op & 7;
switch(op >> 4) {
case 0:
gen_op_flds_FT0_A0();
break;
case 1:
gen_op_fildl_FT0_A0();
break;
case 2:
gen_op_fldl_FT0_A0();
break;
case 3:
default:
gen_op_fild_FT0_A0();
break;
}
gen_op_fp_arith_ST0_FT0[op1]();
if (op1 == 3) {
gen_op_fpop();
}
}
break;
case 0x08:
case 0x0a:
case 0x0b:
case 0x18:
case 0x1a:
case 0x1b:
case 0x28:
case 0x2a:
case 0x2b:
case 0x38:
case 0x3a:
case 0x3b:
switch(op & 7) {
case 0:
switch(op >> 4) {
case 0:
gen_op_flds_ST0_A0();
break;
case 1:
gen_op_fildl_ST0_A0();
break;
case 2:
gen_op_fldl_ST0_A0();
break;
case 3:
default:
gen_op_fild_ST0_A0();
break;
}
break;
default:
switch(op >> 4) {
case 0:
gen_op_fsts_ST0_A0();
break;
case 1:
gen_op_fistl_ST0_A0();
break;
case 2:
gen_op_fstl_ST0_A0();
break;
case 3:
default:
gen_op_fist_ST0_A0();
break;
}
if ((op & 7) == 3)
gen_op_fpop();
break;
}
break;
case 0x0c:
gen_op_fldenv_A0(s->dflag);
break;
case 0x0d:
gen_op_fldcw_A0();
break;
case 0x0e:
gen_op_fnstenv_A0(s->dflag);
break;
case 0x0f:
gen_op_fnstcw_A0();
break;
case 0x1d:
gen_op_fldt_ST0_A0();
break;
case 0x1f:
gen_op_fstt_ST0_A0();
gen_op_fpop();
break;
case 0x2c:
gen_op_frstor_A0(s->dflag);
break;
case 0x2e:
gen_op_fnsave_A0(s->dflag);
break;
case 0x2f:
gen_op_fnstsw_A0();
break;
case 0x3c:
gen_op_fbld_ST0_A0();
break;
case 0x3e:
gen_op_fbst_ST0_A0();
gen_op_fpop();
break;
case 0x3d:
gen_op_fildll_ST0_A0();
break;
case 0x3f:
gen_op_fistll_ST0_A0();
gen_op_fpop();
break;
default:
goto illegal_op;
}
} else {
opreg = rm;
switch(op) {
case 0x08:
gen_op_fpush();
gen_op_fmov_ST0_STN((opreg + 1) & 7);
break;
case 0x09:
gen_op_fxchg_ST0_STN(opreg);
break;
case 0x0a:
switch(rm) {
case 0:
break;
default:
goto illegal_op;
}
break;
case 0x0c:
switch(rm) {
case 0:
gen_op_fchs_ST0();
break;
case 1:
gen_op_fabs_ST0();
break;
case 4:
gen_op_fldz_FT0();
gen_op_fcom_ST0_FT0();
break;
case 5:
gen_op_fxam_ST0();
break;
default:
goto illegal_op;
}
break;
case 0x0d:
{
switch(rm) {
case 0:
gen_op_fpush();
gen_op_fld1_ST0();
break;
case 1:
gen_op_fpush();
gen_op_fldl2t_ST0();
break;
case 2:
gen_op_fpush();
gen_op_fldl2e_ST0();
break;
case 3:
gen_op_fpush();
gen_op_fldpi_ST0();
break;
case 4:
gen_op_fpush();
gen_op_fldlg2_ST0();
break;
case 5:
gen_op_fpush();
gen_op_fldln2_ST0();
break;
case 6:
gen_op_fpush();
gen_op_fldz_ST0();
break;
default:
goto illegal_op;
}
}
break;
case 0x0e:
switch(rm) {
case 0:
gen_op_f2xm1();
break;
case 1:
gen_op_fyl2x();
break;
case 2:
gen_op_fptan();
break;
case 3:
gen_op_fpatan();
break;
case 4:
gen_op_fxtract();
break;
case 5:
gen_op_fprem1();
break;
case 6:
gen_op_fdecstp();
break;
default:
case 7:
gen_op_fincstp();
break;
}
break;
case 0x0f:
switch(rm) {
case 0:
gen_op_fprem();
break;
case 1:
gen_op_fyl2xp1();
break;
case 2:
gen_op_fsqrt();
break;
case 3:
gen_op_fsincos();
break;
case 5:
gen_op_fscale();
break;
case 4:
gen_op_frndint();
break;
case 6:
gen_op_fsin();
break;
default:
case 7:
gen_op_fcos();
break;
}
break;
case 0x00: case 0x01: case 0x04 ... 0x07:
case 0x20: case 0x21: case 0x24 ... 0x27:
case 0x30: case 0x31: case 0x34 ... 0x37:
{
int op1;
op1 = op & 7;
if (op >= 0x20) {
gen_op_fp_arith_STN_ST0[op1](opreg);
if (op >= 0x30)
gen_op_fpop();
} else {
gen_op_fmov_FT0_STN(opreg);
gen_op_fp_arith_ST0_FT0[op1]();
}
}
break;
case 0x02:
gen_op_fmov_FT0_STN(opreg);
gen_op_fcom_ST0_FT0();
break;
case 0x03:
gen_op_fmov_FT0_STN(opreg);
gen_op_fcom_ST0_FT0();
gen_op_fpop();
break;
case 0x15:
switch(rm) {
case 1:
gen_op_fmov_FT0_STN(1);
gen_op_fucom_ST0_FT0();
gen_op_fpop();
gen_op_fpop();
break;
default:
goto illegal_op;
}
break;
case 0x1c:
switch(rm) {
case 0:
break;
case 1:
break;
case 2:
gen_op_fclex();
break;
case 3:
gen_op_fninit();
break;
case 4:
break;
default:
goto illegal_op;
}
break;
case 0x1d:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_fmov_FT0_STN(opreg);
gen_op_fucomi_ST0_FT0();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x1e:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_fmov_FT0_STN(opreg);
gen_op_fcomi_ST0_FT0();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x2a:
gen_op_fmov_STN_ST0(opreg);
break;
case 0x2b:
gen_op_fmov_STN_ST0(opreg);
gen_op_fpop();
break;
case 0x2c:
gen_op_fmov_FT0_STN(opreg);
gen_op_fucom_ST0_FT0();
break;
case 0x2d:
gen_op_fmov_FT0_STN(opreg);
gen_op_fucom_ST0_FT0();
gen_op_fpop();
break;
case 0x33:
switch(rm) {
case 1:
gen_op_fmov_FT0_STN(1);
gen_op_fcom_ST0_FT0();
gen_op_fpop();
gen_op_fpop();
break;
default:
goto illegal_op;
}
break;
case 0x3c:
switch(rm) {
case 0:
gen_op_fnstsw_EAX();
break;
default:
goto illegal_op;
}
break;
case 0x3d:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_fmov_FT0_STN(opreg);
gen_op_fucomi_ST0_FT0();
gen_op_fpop();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x3e:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_fmov_FT0_STN(opreg);
gen_op_fcomi_ST0_FT0();
gen_op_fpop();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x10 ... 0x13:
case 0x18 ... 0x1b:
{
int op1;
const static uint8_t fcmov_cc[8] = {
(JCC_B << 1),
(JCC_Z << 1),
(JCC_BE << 1),
(JCC_P << 1),
};
op1 = fcmov_cc[op & 3] | ((op >> 3) & 1);
gen_setcc(s, op1);
gen_op_fcmov_ST0_STN_T0(opreg);
}
break;
default:
goto illegal_op;
}
}
#ifdef USE_CODE_COPY
s->tb->cflags |= CF_TB_FP_USED;
#endif
break;
case 0xa4:
case 0xa5:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_movs(s, ot, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_movs(s, ot);
}
break;
case 0xaa:
case 0xab:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_stos(s, ot, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_stos(s, ot);
}
break;
case 0xac:
case 0xad:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_lods(s, ot, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_lods(s, ot);
}
break;
case 0xae:
case 0xaf:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
if (prefixes & PREFIX_REPNZ) {
gen_repz_scas(s, ot, pc_start - s->cs_base, s->pc - s->cs_base, 1);
} else if (prefixes & PREFIX_REPZ) {
gen_repz_scas(s, ot, pc_start - s->cs_base, s->pc - s->cs_base, 0);
} else {
gen_scas(s, ot);
s->cc_op = CC_OP_SUBB + ot;
}
break;
case 0xa6:
case 0xa7:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
if (prefixes & PREFIX_REPNZ) {
gen_repz_cmps(s, ot, pc_start - s->cs_base, s->pc - s->cs_base, 1);
} else if (prefixes & PREFIX_REPZ) {
gen_repz_cmps(s, ot, pc_start - s->cs_base, s->pc - s->cs_base, 0);
} else {
gen_cmps(s, ot);
s->cc_op = CC_OP_SUBB + ot;
}
break;
case 0x6c:
case 0x6d:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
gen_check_io(s, ot, 1, pc_start - s->cs_base);
if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_ins(s, ot, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_ins(s, ot);
}
break;
case 0x6e:
case 0x6f:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
gen_check_io(s, ot, 1, pc_start - s->cs_base);
if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_outs(s, ot, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_outs(s, ot);
}
break;
case 0xe4:
case 0xe5:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
val = ldub_code(s->pc++);
gen_op_movl_T0_im(val);
gen_check_io(s, ot, 0, pc_start - s->cs_base);
gen_op_in[ot]();
gen_op_mov_reg_T1[ot][R_EAX]();
break;
case 0xe6:
case 0xe7:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
val = ldub_code(s->pc++);
gen_op_movl_T0_im(val);
gen_check_io(s, ot, 0, pc_start - s->cs_base);
gen_op_mov_TN_reg[ot][1][R_EAX]();
gen_op_out[ot]();
break;
case 0xec:
case 0xed:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
gen_op_mov_TN_reg[OT_WORD][0][R_EDX]();
gen_op_andl_T0_ffff();
gen_check_io(s, ot, 0, pc_start - s->cs_base);
gen_op_in[ot]();
gen_op_mov_reg_T1[ot][R_EAX]();
break;
case 0xee:
case 0xef:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
gen_op_mov_TN_reg[OT_WORD][0][R_EDX]();
gen_op_andl_T0_ffff();
gen_check_io(s, ot, 0, pc_start - s->cs_base);
gen_op_mov_TN_reg[ot][1][R_EAX]();
gen_op_out[ot]();
break;
case 0xc2:
val = ldsw_code(s->pc);
s->pc += 2;
gen_pop_T0(s);
gen_stack_update(s, val + (2 << s->dflag));
if (s->dflag == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
gen_eob(s);
break;
case 0xc3:
gen_pop_T0(s);
gen_pop_update(s);
if (s->dflag == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
gen_eob(s);
break;
case 0xca:
val = ldsw_code(s->pc);
s->pc += 2;
do_lret:
if (s->pe && !s->vm86) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_jmp_im(pc_start - s->cs_base);
gen_op_lret_protected(s->dflag, val);
} else {
gen_stack_A0(s);
gen_op_ld_T0_A0[1 + s->dflag + s->mem_index]();
if (s->dflag == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
gen_op_addl_A0_im(2 << s->dflag);
gen_op_ld_T0_A0[1 + s->dflag + s->mem_index]();
gen_op_movl_seg_T0_vm(offsetof(CPUX86State,segs[R_CS]));
gen_stack_update(s, val + (4 << s->dflag));
}
gen_eob(s);
break;
case 0xcb:
val = 0;
goto do_lret;
case 0xcf:
if (!s->pe) {
gen_op_iret_real(s->dflag);
s->cc_op = CC_OP_EFLAGS;
} else if (s->vm86) {
if (s->iopl != 3) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_op_iret_real(s->dflag);
s->cc_op = CC_OP_EFLAGS;
}
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_jmp_im(pc_start - s->cs_base);
gen_op_iret_protected(s->dflag, s->pc - s->cs_base);
s->cc_op = CC_OP_EFLAGS;
}
gen_eob(s);
break;
case 0xe8:
{
unsigned int next_eip;
ot = dflag ? OT_LONG : OT_WORD;
val = insn_get(s, ot);
next_eip = s->pc - s->cs_base;
val += next_eip;
if (s->dflag == 0)
val &= 0xffff;
gen_op_movl_T0_im(next_eip);
gen_push_T0(s);
gen_jmp(s, val);
}
break;
case 0x9a:
{
unsigned int selector, offset;
ot = dflag ? OT_LONG : OT_WORD;
offset = insn_get(s, ot);
selector = insn_get(s, OT_WORD);
gen_op_movl_T0_im(selector);
gen_op_movl_T1_im(offset);
}
goto do_lcall;
case 0xe9:
ot = dflag ? OT_LONG : OT_WORD;
val = insn_get(s, ot);
val += s->pc - s->cs_base;
if (s->dflag == 0)
val = val & 0xffff;
gen_jmp(s, val);
break;
case 0xea:
{
unsigned int selector, offset;
ot = dflag ? OT_LONG : OT_WORD;
offset = insn_get(s, ot);
selector = insn_get(s, OT_WORD);
gen_op_movl_T0_im(selector);
gen_op_movl_T1_im(offset);
}
goto do_ljmp;
case 0xeb:
val = (int8_t)insn_get(s, OT_BYTE);
val += s->pc - s->cs_base;
if (s->dflag == 0)
val = val & 0xffff;
gen_jmp(s, val);
break;
case 0x70 ... 0x7f:
val = (int8_t)insn_get(s, OT_BYTE);
goto do_jcc;
case 0x180 ... 0x18f:
if (dflag) {
val = insn_get(s, OT_LONG);
} else {
val = (int16_t)insn_get(s, OT_WORD);
}
do_jcc:
next_eip = s->pc - s->cs_base;
val += next_eip;
if (s->dflag == 0)
val &= 0xffff;
gen_jcc(s, b, val, next_eip);
break;
case 0x190 ... 0x19f:
modrm = ldub_code(s->pc++);
gen_setcc(s, b);
gen_ldst_modrm(s, modrm, OT_BYTE, OR_TMP0, 1);
break;
case 0x140 ... 0x14f:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
gen_setcc(s, b);
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T1_A0[ot + s->mem_index]();
} else {
rm = modrm & 7;
gen_op_mov_TN_reg[ot][1][rm]();
}
gen_op_cmov_reg_T1_T0[ot - OT_WORD][reg]();
break;
case 0x9c:
if (s->vm86 && s->iopl != 3) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_movl_T0_eflags();
gen_push_T0(s);
}
break;
case 0x9d:
if (s->vm86 && s->iopl != 3) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_pop_T0(s);
if (s->cpl == 0) {
if (s->dflag) {
gen_op_movl_eflags_T0_cpl0();
} else {
gen_op_movw_eflags_T0_cpl0();
}
} else {
if (s->cpl <= s->iopl) {
if (s->dflag) {
gen_op_movl_eflags_T0_io();
} else {
gen_op_movw_eflags_T0_io();
}
} else {
if (s->dflag) {
gen_op_movl_eflags_T0();
} else {
gen_op_movw_eflags_T0();
}
}
}
gen_pop_update(s);
s->cc_op = CC_OP_EFLAGS;
gen_op_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x9e:
gen_op_mov_TN_reg[OT_BYTE][0][R_AH]();
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_movb_eflags_T0();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x9f:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_movl_T0_eflags();
gen_op_mov_reg_T0[OT_BYTE][R_AH]();
break;
case 0xf5:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_cmc();
s->cc_op = CC_OP_EFLAGS;
break;
case 0xf8:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_clc();
s->cc_op = CC_OP_EFLAGS;
break;
case 0xf9:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_stc();
s->cc_op = CC_OP_EFLAGS;
break;
case 0xfc:
gen_op_cld();
break;
case 0xfd:
gen_op_std();
break;
case 0x1ba:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
op = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
rm = modrm & 7;
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T0_A0[ot + s->mem_index]();
} else {
gen_op_mov_TN_reg[ot][0][rm]();
}
val = ldub_code(s->pc++);
gen_op_movl_T1_im(val);
if (op < 4)
goto illegal_op;
op -= 4;
gen_op_btx_T0_T1_cc[ot - OT_WORD][op]();
s->cc_op = CC_OP_SARB + ot;
if (op != 0) {
if (mod != 3)
gen_op_st_T0_A0[ot + s->mem_index]();
else
gen_op_mov_reg_T0[ot][rm]();
gen_op_update_bt_cc();
}
break;
case 0x1a3:
op = 0;
goto do_btx;
case 0x1ab:
op = 1;
goto do_btx;
case 0x1b3:
op = 2;
goto do_btx;
case 0x1bb:
op = 3;
do_btx:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
rm = modrm & 7;
gen_op_mov_TN_reg[OT_LONG][1][reg]();
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (ot == OT_WORD)
gen_op_add_bitw_A0_T1();
else
gen_op_add_bitl_A0_T1();
gen_op_ld_T0_A0[ot + s->mem_index]();
} else {
gen_op_mov_TN_reg[ot][0][rm]();
}
gen_op_btx_T0_T1_cc[ot - OT_WORD][op]();
s->cc_op = CC_OP_SARB + ot;
if (op != 0) {
if (mod != 3)
gen_op_st_T0_A0[ot + s->mem_index]();
else
gen_op_mov_reg_T0[ot][rm]();
gen_op_update_bt_cc();
}
break;
case 0x1bc:
case 0x1bd:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
gen_op_bsx_T0_cc[ot - OT_WORD][b & 1]();
gen_op_mov_reg_T0[ot][reg]();
s->cc_op = CC_OP_LOGICB + ot;
break;
case 0x27:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_daa();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x2f:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_das();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x37:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_aaa();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x3f:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_aas();
s->cc_op = CC_OP_EFLAGS;
break;
case 0xd4:
val = ldub_code(s->pc++);
gen_op_aam(val);
s->cc_op = CC_OP_LOGICB;
break;
case 0xd5:
val = ldub_code(s->pc++);
gen_op_aad(val);
s->cc_op = CC_OP_LOGICB;
break;
case 0x90:
if (prefixes & PREFIX_LOCK)
goto illegal_op;
break;
case 0x9b:
if ((s->flags & (HF_MP_MASK | HF_TS_MASK)) ==
(HF_MP_MASK | HF_TS_MASK)) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_jmp_im(pc_start - s->cs_base);
gen_op_fwait();
}
break;
case 0xcc:
gen_interrupt(s, EXCP03_INT3, pc_start - s->cs_base, s->pc - s->cs_base);
break;
case 0xcd:
val = ldub_code(s->pc++);
if (s->vm86 && s->iopl != 3) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_interrupt(s, val, pc_start - s->cs_base, s->pc - s->cs_base);
}
break;
case 0xce:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_into(s->pc - s->cs_base);
break;
case 0xf1:
gen_debug(s, pc_start - s->cs_base);
break;
case 0xfa:
if (!s->vm86) {
if (s->cpl <= s->iopl) {
gen_op_cli();
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
} else {
if (s->iopl == 3) {
gen_op_cli();
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
}
break;
case 0xfb:
if (!s->vm86) {
if (s->cpl <= s->iopl) {
gen_sti:
gen_op_sti();
if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK))
gen_op_set_inhibit_irq();
gen_op_jmp_im(s->pc - s->cs_base);
gen_eob(s);
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
} else {
if (s->iopl == 3) {
goto gen_sti;
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
}
break;
case 0x62:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
gen_op_mov_reg_T0[ot][reg]();
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (ot == OT_WORD)
gen_op_boundw(pc_start - s->cs_base);
else
gen_op_boundl(pc_start - s->cs_base);
break;
case 0x1c8 ... 0x1cf:
reg = b & 7;
gen_op_mov_TN_reg[OT_LONG][0][reg]();
gen_op_bswapl_T0();
gen_op_mov_reg_T0[OT_LONG][reg]();
break;
case 0xd6:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_salc();
break;
case 0xe0:
case 0xe1:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
case 0xe2:
case 0xe3:
val = (int8_t)insn_get(s, OT_BYTE);
next_eip = s->pc - s->cs_base;
val += next_eip;
if (s->dflag == 0)
val &= 0xffff;
gen_op_loop[s->aflag][b & 3](val, next_eip);
gen_eob(s);
break;
case 0x130:
case 0x132:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (b & 2)
gen_op_rdmsr();
else
gen_op_wrmsr();
}
break;
case 0x131:
gen_op_rdtsc();
break;
case 0x1a2:
gen_op_cpuid();
break;
case 0xf4:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_jmp_im(s->pc - s->cs_base);
gen_op_hlt();
s->is_jmp = 3;
}
break;
case 0x100:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
op = (modrm >> 3) & 7;
switch(op) {
case 0:
if (!s->pe || s->vm86)
goto illegal_op;
gen_op_movl_T0_env(offsetof(CPUX86State,ldt.selector));
ot = OT_WORD;
if (mod == 3)
ot += s->dflag;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 1);
break;
case 2:
if (!s->pe || s->vm86)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
gen_op_jmp_im(pc_start - s->cs_base);
gen_op_lldt_T0();
}
break;
case 1:
if (!s->pe || s->vm86)
goto illegal_op;
gen_op_movl_T0_env(offsetof(CPUX86State,tr.selector));
ot = OT_WORD;
if (mod == 3)
ot += s->dflag;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 1);
break;
case 3:
if (!s->pe || s->vm86)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
gen_op_jmp_im(pc_start - s->cs_base);
gen_op_ltr_T0();
}
break;
case 4:
case 5:
if (!s->pe || s->vm86)
goto illegal_op;
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
if (op == 4)
gen_op_verr();
else
gen_op_verw();
s->cc_op = CC_OP_EFLAGS;
break;
default:
goto illegal_op;
}
break;
case 0x101:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
op = (modrm >> 3) & 7;
switch(op) {
case 0:
case 1:
if (mod == 3)
goto illegal_op;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (op == 0)
gen_op_movl_T0_env(offsetof(CPUX86State,gdt.limit));
else
gen_op_movl_T0_env(offsetof(CPUX86State,idt.limit));
gen_op_st_T0_A0[OT_WORD + s->mem_index]();
gen_op_addl_A0_im(2);
if (op == 0)
gen_op_movl_T0_env(offsetof(CPUX86State,gdt.base));
else
gen_op_movl_T0_env(offsetof(CPUX86State,idt.base));
if (!s->dflag)
gen_op_andl_T0_im(0xffffff);
gen_op_st_T0_A0[OT_LONG + s->mem_index]();
break;
case 2:
case 3:
if (mod == 3)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T1_A0[OT_WORD + s->mem_index]();
gen_op_addl_A0_im(2);
gen_op_ld_T0_A0[OT_LONG + s->mem_index]();
if (!s->dflag)
gen_op_andl_T0_im(0xffffff);
if (op == 2) {
gen_op_movl_env_T0(offsetof(CPUX86State,gdt.base));
gen_op_movl_env_T1(offsetof(CPUX86State,gdt.limit));
} else {
gen_op_movl_env_T0(offsetof(CPUX86State,idt.base));
gen_op_movl_env_T1(offsetof(CPUX86State,idt.limit));
}
}
break;
case 4:
gen_op_movl_T0_env(offsetof(CPUX86State,cr[0]));
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 1);
break;
case 6:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
gen_op_lmsw_T0();
gen_op_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 7:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (mod == 3)
goto illegal_op;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_invlpg_A0();
gen_op_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
default:
goto illegal_op;
}
break;
case 0x108:
case 0x109:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
}
break;
case 0x63:
if (!s->pe || s->vm86)
goto illegal_op;
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
rm = modrm & 7;
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T0_A0[ot + s->mem_index]();
} else {
gen_op_mov_TN_reg[ot][0][rm]();
}
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_arpl();
s->cc_op = CC_OP_EFLAGS;
if (mod != 3) {
gen_op_st_T0_A0[ot + s->mem_index]();
} else {
gen_op_mov_reg_T0[ot][rm]();
}
gen_op_arpl_update();
break;
case 0x102:
case 0x103:
if (!s->pe || s->vm86)
goto illegal_op;
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
gen_op_mov_TN_reg[ot][1][reg]();
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
if (b == 0x102)
gen_op_lar();
else
gen_op_lsl();
s->cc_op = CC_OP_EFLAGS;
gen_op_mov_reg_T1[ot][reg]();
break;
case 0x118:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
op = (modrm >> 3) & 7;
switch(op) {
case 0:
case 1:
case 2:
case 3:
if (mod == 3)
goto illegal_op;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
break;
default:
goto illegal_op;
}
break;
case 0x120:
case 0x122:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
modrm = ldub_code(s->pc++);
if ((modrm & 0xc0) != 0xc0)
goto illegal_op;
rm = modrm & 7;
reg = (modrm >> 3) & 7;
switch(reg) {
case 0:
case 2:
case 3:
case 4:
if (b & 2) {
gen_op_mov_TN_reg[OT_LONG][0][rm]();
gen_op_movl_crN_T0(reg);
gen_op_jmp_im(s->pc - s->cs_base);
gen_eob(s);
} else {
gen_op_movl_T0_env(offsetof(CPUX86State,cr[reg]));
gen_op_mov_reg_T0[OT_LONG][rm]();
}
break;
default:
goto illegal_op;
}
}
break;
case 0x121:
case 0x123:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
modrm = ldub_code(s->pc++);
if ((modrm & 0xc0) != 0xc0)
goto illegal_op;
rm = modrm & 7;
reg = (modrm >> 3) & 7;
if (reg == 4 || reg == 5)
goto illegal_op;
if (b & 2) {
gen_op_mov_TN_reg[OT_LONG][0][rm]();
gen_op_movl_drN_T0(reg);
gen_op_jmp_im(s->pc - s->cs_base);
gen_eob(s);
} else {
gen_op_movl_T0_env(offsetof(CPUX86State,dr[reg]));
gen_op_mov_reg_T0[OT_LONG][rm]();
}
}
break;
case 0x106:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_op_clts();
gen_op_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
default:
goto illegal_op;
}
if (s->prefix & PREFIX_LOCK)
gen_op_unlock();
return s->pc;
illegal_op:
if (s->prefix & PREFIX_LOCK)
gen_op_unlock();
gen_exception(s, EXCP06_ILLOP, pc_start - s->cs_base);
return s->pc;
}
| 1threat |
int json_lexer_flush(JSONLexer *lexer)
{
return lexer->state == IN_START ? 0 : json_lexer_feed_char(lexer, 0);
}
| 1threat |
PPC_OP(mulhw)
{
T0 = ((int64_t)Ts0 * (int64_t)Ts1) >> 32;
RETURN();
}
| 1threat |
Combine 2 arrays, updating values : <p>In my reducer I am pulling down results from my API, I would like to combine this array with the persisted data from storage if it exists, the only fields that need to be overwritten in the data are <code>bookMarked</code>, <code>totalScore</code>, and <code>completed</code>. How can I compare arrays and overwrite the required properties if they are different?</p>
<p>What is the best way to do this?</p>
<pre><code>let arrayFromAPI= [
{
bookMarked: false,
completed: false,
totalScore: 50,
current: 0,
description:
"<p>Lorem ipsum culpa qui officia deserunt mollit anim id est laborum.</p>",
icon: "male-urinary-catheterisation",
id: 1
},
{
bookMarked: false,
completed: false,
totalScore: 50,
current: 0,
description:
"<p>Lorem ipsum culpa qui officia deserunt mollit anim id est laborum.</p>",
icon: "male-urinary-catheterisation",
id: 2
}
];
let arrayFromPersist = [
{
bookMarked: true,
completed: false,
totalScore: 50,
completed: true,
current: 0,
description:
"<p>Lorem ipsum culpa qui officia deserunt mollit anim id est laborum.</p>",
icon: "male-urinary-catheterisation",
id: 1
},
{
bookMarked: true,
completed: false,
totalScore: 50,
completed: true,
current: 0,
description:
"<p>Lorem ipsum culpa qui officia deserunt mollit anim id est laborum.</p>",
icon: "male-urinary-catheterisation",
id: 2
}
];
</code></pre>
| 0debug |
Sort Data with Python : <p>I am totally new in Python and I have a snippet of my code below</p>
<pre><code>class student:
def __init__(stu, code, name, number):
stu.code = code
stu.name = name
stu.number = number
student = [
stu("901", "Joh Doe", "123456")
stu("902", "Mary Mount", "566665")
stu("903", "David Lee", "394624")
]
</code></pre>
<p>I would like to sort the last data below from Highest to Lowest, may i know how to do it?</p>
<p>From:</p>
<pre><code>901 Joh Doe 123456
902 Mary Mount 566665
903 David Lee 394624
</code></pre>
<p>To:</p>
<pre><code>902 Mary Mount 566665
903 David Lee 394624
901 Joh Doe 123456
</code></pre>
<p>Really appreciate your kind help
Thanks</p>
| 0debug |
Statuscode 406 (Not Acceptable) in ASP.NET Core : <p>REST services should provide content negotiation. This means that clients send an Accept header that contains the desired content type of the response. If the service does not support this media type, it should respond with status code 406 (Not Acceptable).</p>
<p>I try to map this behavior to ASP.NET Core. ASP.NET core returns a JSON document, if it doesn't recognize the media type in the Accept header. In previous versions of the framework the behavior described above could be achieved by adding a special output formatter to the configuration:</p>
<pre><code>public void ConfigureServices(IServiceCollection services) {
services.AddMvc(options => {
options.OutputFormatters.Insert(0, new HttpNotAcceptableOutputFormatter());
});
}
</code></pre>
<p>Unfortunately, <code>HttpNotAcceptableOutputFormatter</code> was removed from the ASP.NET Core framework after RC1. Is there any replacement for this class in the current version of the framework?</p>
| 0debug |
static int check_refblocks(BlockDriverState *bs, BdrvCheckResult *res,
BdrvCheckMode fix, uint16_t **refcount_table,
int64_t *nb_clusters)
{
BDRVQcowState *s = bs->opaque;
int64_t i;
for(i = 0; i < s->refcount_table_size; i++) {
uint64_t offset, cluster;
offset = s->refcount_table[i];
cluster = offset >> s->cluster_bits;
if (offset_into_cluster(s, offset)) {
fprintf(stderr, "ERROR refcount block %" PRId64 " is not "
"cluster aligned; refcount table entry corrupted\n", i);
res->corruptions++;
continue;
}
if (cluster >= *nb_clusters) {
fprintf(stderr, "ERROR refcount block %" PRId64
" is outside image\n", i);
res->corruptions++;
continue;
}
if (offset != 0) {
inc_refcounts(bs, res, *refcount_table, *nb_clusters,
offset, s->cluster_size);
if ((*refcount_table)[cluster] != 1) {
fprintf(stderr, "%s refcount block %" PRId64
" refcount=%d\n",
fix & BDRV_FIX_ERRORS ? "Repairing" :
"ERROR",
i, (*refcount_table)[cluster]);
if (fix & BDRV_FIX_ERRORS) {
int64_t new_offset;
new_offset = realloc_refcount_block(bs, i, offset);
if (new_offset < 0) {
res->corruptions++;
continue;
}
if ((new_offset >> s->cluster_bits) >= *nb_clusters) {
int old_nb_clusters = *nb_clusters;
*nb_clusters = (new_offset >> s->cluster_bits) + 1;
*refcount_table = g_renew(uint16_t, *refcount_table,
*nb_clusters);
memset(&(*refcount_table)[old_nb_clusters], 0,
(*nb_clusters - old_nb_clusters) *
sizeof(uint16_t));
}
(*refcount_table)[cluster]--;
inc_refcounts(bs, res, *refcount_table, *nb_clusters,
new_offset, s->cluster_size);
res->corruptions_fixed++;
} else {
res->corruptions++;
}
}
}
}
return 0;
}
| 1threat |
about spring boot how to disable web environment correctly : <p>Spring boot non-web application, when start it has below error</p>
<pre><code>Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:185) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
</code></pre>
<p>Then I tried below manner </p>
<pre><code>new SpringApplication().setWebEnvironment(false);
</code></pre>
<p>then start it still have above error.</p>
<p>Then tried </p>
<pre><code>@SpringBootApplication(exclude={SpringDataWebAutoConfiguration.class})
</code></pre>
<p>but still have the same error.</p>
<p>At last I tried add below configuration in <code>application.properties</code></p>
<pre><code>spring.main.web-environment=false
</code></pre>
<p>this time it works.</p>
<p>Why the first two manner cannot work?</p>
| 0debug |
Serve different css based on browser width in css : <p>I am unable to find this on Stackoverflow existing queries. Please help if this can be accomplished.
I want to capture browser with with mobile-first responsive design approach.
Depending upon the browser width, I want to include div's:</p>
<p>1) If browser max-width is 320px, then use ""<code><div class="fb-comments" data-href="https://developers.facebook.com/docs/plugins/comments#configurator" data-width="***320***" data-numposts="5"></div><br>Floating box</div></code></p>
<p>2) If browser width is 480px or above, then use
"<code><div class="fb-comments" data-href="https://developers.facebook.com/docs/plugins/comments#configurator" data-width="**480**" data-numposts="5"></div><br>Floating box</div></code>"</p>
<p>I am aware of using media-queries in CSS (like:</p>
<pre><code>@media (min-width: 300px) {
html { background: blue; }
}
</code></pre>
<p>but how do I use these for div's with changing values of width in div parameters (320 and 480)?</p>
<p>Any help would be greatly appreciated.</p>
<p>Thanks</p>
| 0debug |
static int mkv_write_attachments(AVFormatContext *s)
{
MatroskaMuxContext *mkv = s->priv_data;
AVIOContext *dyn_cp, *pb = s->pb;
ebml_master attachments;
AVLFG c;
int i, ret;
if (!mkv->have_attachments)
return 0;
mkv->attachments = av_mallocz(sizeof(*mkv->attachments));
if (!mkv->attachments)
return ret;
av_lfg_init(&c, av_get_random_seed());
ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_ATTACHMENTS, avio_tell(pb));
if (ret < 0) return ret;
ret = start_ebml_master_crc32(pb, &dyn_cp, &attachments, MATROSKA_ID_ATTACHMENTS, 0);
if (ret < 0) return ret;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
ebml_master attached_file;
mkv_attachment *attachment = mkv->attachments->entries;
AVDictionaryEntry *t;
const char *mimetype = NULL;
uint32_t fileuid;
if (st->codecpar->codec_type != AVMEDIA_TYPE_ATTACHMENT)
continue;
attachment = av_realloc_array(attachment, mkv->attachments->num_entries + 1, sizeof(mkv_attachment));
if (!attachment)
return AVERROR(ENOMEM);
mkv->attachments->entries = attachment;
attached_file = start_ebml_master(dyn_cp, MATROSKA_ID_ATTACHEDFILE, 0);
if (t = av_dict_get(st->metadata, "title", NULL, 0))
put_ebml_string(dyn_cp, MATROSKA_ID_FILEDESC, t->value);
if (!(t = av_dict_get(st->metadata, "filename", NULL, 0))) {
av_log(s, AV_LOG_ERROR, "Attachment stream %d has no filename tag.\n", i);
return AVERROR(EINVAL);
}
put_ebml_string(dyn_cp, MATROSKA_ID_FILENAME, t->value);
if (t = av_dict_get(st->metadata, "mimetype", NULL, 0))
mimetype = t->value;
else if (st->codecpar->codec_id != AV_CODEC_ID_NONE ) {
int i;
for (i = 0; ff_mkv_mime_tags[i].id != AV_CODEC_ID_NONE; i++)
if (ff_mkv_mime_tags[i].id == st->codecpar->codec_id) {
mimetype = ff_mkv_mime_tags[i].str;
break;
}
for (i = 0; ff_mkv_image_mime_tags[i].id != AV_CODEC_ID_NONE; i++)
if (ff_mkv_image_mime_tags[i].id == st->codecpar->codec_id) {
mimetype = ff_mkv_image_mime_tags[i].str;
break;
}
}
if (!mimetype) {
av_log(s, AV_LOG_ERROR, "Attachment stream %d has no mimetype tag and "
"it cannot be deduced from the codec id.\n", i);
return AVERROR(EINVAL);
}
if (s->flags & AVFMT_FLAG_BITEXACT) {
struct AVSHA *sha = av_sha_alloc();
uint8_t digest[20];
if (!sha)
return AVERROR(ENOMEM);
av_sha_init(sha, 160);
av_sha_update(sha, st->codecpar->extradata, st->codecpar->extradata_size);
av_sha_final(sha, digest);
av_free(sha);
fileuid = AV_RL32(digest);
} else {
fileuid = av_lfg_get(&c);
}
av_log(s, AV_LOG_VERBOSE, "Using %.8"PRIx32" for attachment %d\n",
fileuid, mkv->attachments->num_entries);
put_ebml_string(dyn_cp, MATROSKA_ID_FILEMIMETYPE, mimetype);
put_ebml_binary(dyn_cp, MATROSKA_ID_FILEDATA, st->codecpar->extradata, st->codecpar->extradata_size);
put_ebml_uint(dyn_cp, MATROSKA_ID_FILEUID, fileuid);
end_ebml_master(dyn_cp, attached_file);
mkv->attachments->entries[mkv->attachments->num_entries].stream_idx = i;
mkv->attachments->entries[mkv->attachments->num_entries++].fileuid = fileuid;
}
end_ebml_master_crc32(pb, &dyn_cp, mkv, attachments);
return 0;
}
| 1threat |
How do i extract data out from Ienumerable? : I'm coding in C#. I have this code that tells me the difference in my 2 listview data.
`var diff = ListViewDatabase.Items.Cast<ListViewItem>().Select(x => x.SubItems[1].Text).Except(LstView.Items.Cast<ListViewItem>().Select(x => x.SubItems[1].Text));
MessageBox.Show(string.Format("{0} Missing.", string.Join(",", diff), "\n"));`
Now how do I extract the information out from variable diff to a single string? It needs to be seperated to different string. | 0debug |
Embedding an dotx into a VB.NET application : I have a application which accesses .doc file and makes a change in bookmarks but when i install application to user computer the application says file not available. absolutely it is not in user computer i want to embed the file to setup file so that i have not to paste the file to directory like
i am trying this as this file is not present in user computer so it's not working
oDoc = oWord.Documents.Add("\resources\face sheet.doc")
how can i embed word doc file to setup file?
kindly help me embedding the file to .exe file
| 0debug |
How do you end a method from code in another method? : <p>How do I end a method with logic in another method? It seems return only works in the method it is in.</p>
<pre><code>private void BeAmazing (int number) {
HandleNumber(number);
Debug.Log("number is 3 or less");
}
private void HandleNumber(int number) {
if (number > 3) {
return;
}
}
</code></pre>
| 0debug |
Reqular expression for formula which contains number, alphabets,expressions and brackets : I am trying to write a regular expression for the formula for the following examples.
`1. C=A+B => Output {A, +, B}
2. D= C+50 => Output{C, +, 50}
3. E = (A+B)*C -100 => Output{(, A, +, B, ), *, C, -, 100}`
Please help me to create a regular expression.
Thanks in advance. | 0debug |
NGINX: connect() to unix:/var/run/php7.0-fpm.sock failed (2: No such file or directory) : <p>I'm trying to follow <a href="https://www.digitalocean.com/community/tutorials/how-to-deploy-a-basic-php-application-using-ansible-on-ubuntu-14-04" rel="noreferrer">this Ansible tutorial</a> while adjusting it for Ubuntu 16.04 with php7. Below this message you'll find my Ansible file. After running it and trying to visit the page in the browser I get a 404, and the following in the nginx error logs:</p>
<blockquote>
<p>2016/10/15 13:13:20 [crit] 28771#28771: *7 connect() to
unix:/var/run/php7.0-fpm.sock failed (2: No such file or directory)
while connecting to upstream, client: 93.xxx.xxx.xx, server:
95.xx.xx.xx, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php7.0-fpm.sock:", host: "95.xx.xx.xx"</p>
</blockquote>
<p>So I checked if the socket file exists, and it seems to exist, but <code>ls</code> behaves weird:</p>
<pre><code>$ sudo ls -l /var/run/php
total 4
-rw-r--r-- 1 root root 5 Oct 15 13:00 php7.0-fpm.pid
srw-rw---- 1 www-data www-data 0 Oct 15 13:00 php7.0-fpm.sock
$ sudo ls -l /var/run/php7
ls: cannot access '/var/run/php7': No such file or directory
$ sudo ls -l /var/run/php7.0-fpm.sock
ls: cannot access '/var/run/php7.0-fpm.sock': No such file or directory
</code></pre>
<p>Why can <code>ls</code> find the socket file if I search it by part of the name <code>php</code> while it cannot find the socket file when I list more than that <code>php7</code> or even the full name <code>php7.0-fpm.sock</code>?</p>
<p>And most importantly, how can I make this work with nginx? All tips are welcome!</p>
<p>below I pasted my Ansible file</p>
<pre><code>---
- hosts: php
become: true
tasks:
- name: install packages
apt: name={{ item }} update_cache=yes state=latest
with_items:
- git
- mcrypt
- nginx
- php-cli
- php-curl
- php-fpm
- php-intl
- php-json
- php-mcrypt
- php-mbstring
- php-sqlite3
- php-xml
- sqlite3
- name: enable mbstring
shell: phpenmod mbstring
notify:
- restart php7.0-fpm
- restart nginx
- name: create /var/www/ directory
file: dest=/var/www/ state=directory owner=www-data group=www-data mode=0700
- name: Clone git repository
git: >
dest=/var/www/laravel
repo=https://github.com/laravel/laravel.git
update=no
become: true
become_user: www-data
register: cloned
- name: install composer
shell: curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
args:
creates: /usr/local/bin/composer
- name: composer create-project
composer: command=create-project working_dir=/var/www/laravel optimize_autoloader=no
become: true
become_user: www-data
when: cloned|changed
- name: set APP_DEBUG=false
lineinfile: dest=/var/www/laravel/.env regexp='^APP_DEBUG=' line=APP_DEBUG=false
- name: set APP_ENV=production
lineinfile: dest=/var/www/laravel/.env regexp='^APP_ENV=' line=APP_ENV=production
- name: Configure nginx
template: src=nginx.conf dest=/etc/nginx/sites-available/default
notify:
- restart php5-fpm
- restart nginx
handlers:
- name: restart php7.0-fpm
service: name=php7.0-fpm state=restarted
- name: restart nginx
service: name=nginx state=restarted
- name: reload nginx
service: name=nginx state=reloaded
</code></pre>
| 0debug |
static inline void RENAME(yuv2rgb32_1)(SwsContext *c, const uint16_t *buf0,
const uint16_t *ubuf0, const uint16_t *ubuf1,
const uint16_t *vbuf0, const uint16_t *vbuf1,
const uint16_t *abuf0, uint8_t *dest,
int dstW, int uvalpha, enum PixelFormat dstFormat,
int flags, int y)
{
x86_reg uv_off = c->uv_off << 1;
const uint16_t *buf1= buf0;
if (uvalpha < 2048) {
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1(%%REGBP, %5, %6)
YSCALEYUV2RGB1_ALPHA(%%REGBP)
WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (abuf0), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither), "m"(uv_off)
);
} else {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1(%%REGBP, %5, %6)
"pcmpeqd %%mm7, %%mm7 \n\t"
WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither), "m"(uv_off)
);
}
} else {
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1b(%%REGBP, %5, %6)
YSCALEYUV2RGB1_ALPHA(%%REGBP)
WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (abuf0), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither), "m"(uv_off)
);
} else {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1b(%%REGBP, %5, %6)
"pcmpeqd %%mm7, %%mm7 \n\t"
WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither), "m"(uv_off)
);
}
}
}
| 1threat |
Please help me. i trying create simple game in cocos2d-x. but when i compile my project i get error like this : Please help me. i trying create simple game in cocos2d-x. but when i compile my project i get error like this
BUILD FAILED
D:\Android\sdk\tools\ant\build.xml:597: The following error occurred while executing this line:
D:\Android\sdk\tools\ant\build.xml:716: The following error occurred while executing this line:
D:\Android\sdk\tools\ant\build.xml:730: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "D:\JAVA"
Total time: 2 seconds
Error running command, return code: 1.
D:\cocos2d-x\GAME>
i am sorry for my bad english :(
| 0debug |
Convert row values as columns in sql server :
Table:-
CompanyID Lead LeadManager
1 2 3
Required Output:-
CompanyID Role RoleID
1 Lead 2
1 Leadmanager 3
| 0debug |
void qmp_guest_suspend_ram(Error **errp)
{
Error *local_err = NULL;
GuestSuspendMode *mode = g_malloc(sizeof(GuestSuspendMode));
*mode = GUEST_SUSPEND_MODE_RAM;
check_suspend_mode(*mode, &local_err);
acquire_privilege(SE_SHUTDOWN_NAME, &local_err);
execute_async(do_suspend, mode, &local_err);
if (local_err) {
error_propagate(errp, local_err);
g_free(mode);
}
}
| 1threat |
Fast Parquet row count in Spark : <p>The Parquet files contain a per-block row count field. Spark seems to read it at some point (<a href="https://github.com/apache/spark/blob/v2.0.2/sql/core/src/main/java/org/apache/spark/sql/execution/datasources/parquet/SpecificParquetRecordReaderBase.java#L151" rel="noreferrer"><code>SpecificParquetRecordReaderBase.java#L151</code></a>).</p>
<p>I tried this in <code>spark-shell</code>:</p>
<pre><code>sqlContext.read.load("x.parquet").count
</code></pre>
<p>And Spark ran two stages, showing various aggregation steps in the DAG. I figure this means it reads through the file normally instead of using the row counts. (I could be wrong.)</p>
<p>The question is: Is Spark already using the row count fields when I run <code>count</code>? Is there another API to use those fields? Is relying on those fields a bad idea for some reason?</p>
| 0debug |
Several special IP connect to server with ssh : <p>I want Several special IP connect to my server with ssh and block any another ip</p>
<p>what do you think about solve this question؟</p>
<p>i have centos 7</p>
<p>firewall is CSF</p>
<p>I use cpanel & whm</p>
| 0debug |
Angular 4 - Observable catch error : <p>How can I solve the problem of return with error, use the capture inside the Observable?</p>
<p>I want to execute a function inside the catch, to do some validation before the subscribe is executed.</p>
<p>Thank you in advance, thank you very much for your attention.</p>
<p>Error occurs in -> .catch( (e) => {console.log(e)} )</p>
<pre><code>import { Injectable } from '@angular/core';
import { Headers, Http, ResponseOptions} from '@angular/http';
import { AuthHttp } from 'angular2-jwt';
import { MEAT_API } from '../app.api';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
@Injectable()
export class CompareNfeService {
constructor(private http: AuthHttp) { }
envirArquivos(order): Observable<any> {
const headers = new Headers();
return this.http.post(`${MEAT_API}compare/arquivo`, order,
new ResponseOptions({headers: headers}))
.map(response => response.json())
.catch( (e) => {console.log(e)} );
}
}
</code></pre>
<p>Error</p>
<blockquote>
<p>ERROR in /XXXXXX/application/src/app/compare/service.ts (28,17):
Argument of type '(e: any) => void' is not assignable to parameter of
type '(err: any, caught: Observable) => ObservableInput<{}>'.<br>
Type 'void' is not assignable to type 'ObservableInput<{}>'.</p>
</blockquote>
| 0debug |
Images are not showing good in a div : <p>I am making a wordpress website with the theme Zerif Pro. The website is <a href="http://www.solids-solutions.com/zerif/" rel="nofollow">http://www.solids-solutions.com/zerif/</a>
Under the header images you have the our foucus sections. In that sections are the images not that great. It is only good in google chrome because i use the zoom: 0.64; in css. But it only works in chrome. Can someone please help me.</p>
| 0debug |
def last_Two_Digits(N):
if (N >= 10):
return
fac = 1
for i in range(1,N + 1):
fac = (fac * i) % 100
return (fac) | 0debug |
static void nbd_coroutine_end(NbdClientSession *s,
struct nbd_request *request)
{
int i = HANDLE_TO_INDEX(s, request->handle);
s->recv_coroutine[i] = NULL;
if (s->in_flight-- == MAX_NBD_REQUESTS) {
qemu_co_mutex_unlock(&s->free_sema);
}
}
| 1threat |
In javascript,Can I store emojis in an array as array's element? : <p>I want to store emojis in an array and print it using console.out(); on the browser's console ?</p>
| 0debug |
I am not able to connect to the server in my MS SQL. I am not sure why? Also i am getting message but i am not able to understand it. : I am not able to connect to the server in my MS SQL. I am not sure why? Also i am getting message but i am not able to understand it.
[enter image description here][1]
[1]: https://i.stack.imgur.com/yX65v.png | 0debug |
How can I create an button effect with javascript and jquery? : <p>I am trying to create a button effect in which will change its color on click and returns to its original colour after the click.</p>
<p>I made a conditional within the button effect to returns to its original code but it doesn't work. Here is the code below:</p>
<pre><code>let blueBtnAudio = new Audio('https://s3.amazonaws.com/freecodecamp/simonSound1.mp3');
let redBtnAudio = new Audio('https://s3.amazonaws.com/freecodecamp/simonSound2.mp3');
let yellowBtnAudio = new Audio('https://s3.amazonaws.com/freecodecamp/simonSound3.mp3');
let greenBtnAudio = new Audio('https://s3.amazonaws.com/freecodecamp/simonSound4.mp3');
// VARIABLES - DOM QUERIES
const btnBlue = document.querySelectorAll("#btnBlue");
const btnGreen = document.querySelectorAll("#btnGreen");
const btnRed = document.querySelectorAll("#btnRed");
const btnYellow = document.querySelectorAll("#btnYellow");
$(btnBlue).click(function() {
$(this).css('background-color', '#00FFFF');
blueBtnAudio.play();
if(btnBlue == '#00FFFF' ){
$(btnBlue).stop();
}
});
</code></pre>
| 0debug |
db.execute('SELECT * FROM employees WHERE id = ' + user_input) | 1threat |
When will following method throw 2 : I am curious to find out under what circumstances following method will return 2 instead of 1.
```
private int splitString(String strToSplit) {
int num = strToSplit.split("[\\W_]+").length;
if (num == 0) {
System.out.println("Value is :: " + 2);
return 2;
}
return 1;
}
```
Thanks in advance. | 0debug |
MVC for simple app : <p>I have been working on a simple payment calculator, which I have working correctly via a html front end and a php back end. The html passes user inputs as variables to the PHP via AJAX calls and the PHP returns a result to the html page. Now that I have it functioning as expected, I'm trying to figure out exactly how I might convert this to an MVC pattern. In my understanding, the html is the view component, the PHP, which contains all the logic for calculation, is the model, but I'm really unsure what would go in the controller? If the controller's job is to co-ordinate between the view and the model, then should I be passing my input data to the "controller" which then passes it to the php and then pass the result back via the same route? I understand this pattern in principle but this seems extraneous in this case. I have been looking into several MVC frameworks (.NET, Laravel) but really want to get a more fundamental understanding without having everything scaffolded. Any advice appreciated! </p>
| 0debug |
Golang; Testing; redirecting print statements to a file :
My program outputs a lot of text.
I use VSCode (relatively new) and the display of output is always truncated.
Is it possible to output all such fmt.PrintXXX statements to a file?
OR
How can I capture all of the output from the .Print statements ?
| 0debug |
How to convert moment date to a string and remove the moment object : <p>I have a React Web App and a React Native Mobile App. When I pass a moment date object from my react web app to my backend, it gets converted to a string somehow and it works with my backend.</p>
<p>When I do it with my react native mobile app, it passes the date as a moment object and it doesn't get converted to a string and it doesn't work.</p>
<p>Is there a way to convert the moment object into a plain string like </p>
<pre><code>"Tue May 05 2015 23:59:59 GMT+0800 (HKT)"
</code></pre>
<p>I tried toString() and toUTCString() and it doesn't work. Thanks.</p>
| 0debug |
Why is '\n' preferred over "\n" for output streams? : <p>In <a href="https://stackoverflow.com/a/8311177/7151494">this</a> answer we can read that:</p>
<blockquote>
<p>I suppose there's little difference between using <code>'\n'</code> or using <code>"\n"</code>, but the latter is an array of (two) characters, which has to be printed character by character, for which a loop has to be set up, <strong>which is more complex than outputting a single character</strong>.</p>
</blockquote>
<p><sup><em>emphasis mine</em></sup></p>
<p>That makes sense to me. I would think that outputting a <code>const char*</code> requires a loop which will test for null-terminator, which <em>must</em> introduce more operations than, let's say, a simple <code>putchar</code> (not implying that <code>std::cout</code> with <code>char</code> delegates to calling that - it's just a simplification to introduce an example).</p>
<p>That convinced me to use</p>
<pre><code>std::cout << '\n';
std::cout << ' ';
</code></pre>
<p>rather than</p>
<pre><code>std::cout << "\n";
std::cout << " ";
</code></pre>
<p>It's worth to mention here that I am aware of the performance difference being pretty much negligible. Nonetheless, some may argue that the former approach carries intent of actually passing a single character, rather than a string literal that just happened to be a one <code>char</code> long (<em>two</em> <code>char</code>s long if you count the <code>'\0'</code>).</p>
<p>Lately I've done some little code reviesw for someone who was using the latter approach. I made a small comment on the case and moved on. The developer then thanked me and said that he hadn't even thought of such difference (mainly focusing on the intent). It was not impactful at all (unsurprisingly), but the change was adopted.</p>
<p>I then began wondering <em>how exactly</em> is that change significant, so I ran to godbolt. To my surprise, it showed the <a href="https://godbolt.org/z/p21Yxb" rel="noreferrer">following results</a> when tested on GCC (trunk) with <code>-std=c++17 -O3</code> flags. The generated assembly for the following code:</p>
<pre><code>#include <iostream>
void str() {
std::cout << "\n";
}
void chr() {
std::cout << '\n';
}
int main() {
str();
chr();
}
</code></pre>
<p>surprised me, because it appears that <code>chr()</code> is actually generating exactly twice as many instructions as <code>str()</code> does:</p>
<pre><code>.LC0:
.string "\n"
str():
mov edx, 1
mov esi, OFFSET FLAT:.LC0
mov edi, OFFSET FLAT:_ZSt4cout
jmp std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)
chr():
sub rsp, 24
mov edx, 1
mov edi, OFFSET FLAT:_ZSt4cout
lea rsi, [rsp+15]
mov BYTE PTR [rsp+15], 10
call std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)
add rsp, 24
ret
</code></pre>
<p>Why is that? Why both of them eventually call the same <code>std::basic_ostream</code> function with <code>const char*</code> argument? Does it mean that the <code>char</code> literal approach is not only <em>not better</em>, but actually <em>worse</em> than string literal one?</p>
| 0debug |
static void gen_lswi(DisasContext *ctx)
{
TCGv t0;
TCGv_i32 t1, t2;
int nb = NB(ctx->opcode);
int start = rD(ctx->opcode);
int ra = rA(ctx->opcode);
int nr;
if (nb == 0)
nb = 32;
nr = nb / 4;
if (unlikely(((start + nr) > 32 &&
start <= ra && (start + nr - 32) > ra) ||
((start + nr) <= 32 && start <= ra && (start + nr) > ra))) {
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_LSWX);
return;
}
gen_set_access_type(ctx, ACCESS_INT);
gen_update_nip(ctx, ctx->nip - 4);
t0 = tcg_temp_new();
gen_addr_register(ctx, t0);
t1 = tcg_const_i32(nb);
t2 = tcg_const_i32(start);
gen_helper_lsw(cpu_env, t0, t1, t2);
tcg_temp_free(t0);
tcg_temp_free_i32(t1);
tcg_temp_free_i32(t2);
}
| 1threat |
get all the ids which do not have transactions in last 6 months : I have a table with three coloumns
ID DATE desc
i want to get the ids in a month that have not made transactions in the last 6 months based on the date coloumn.
For instance : an id 123 qualifies for month jan 2018 if it is not having any data in the last 6 months. we need to do this for a span of 2 years from say june 2016 to june 2018.
need help with a sql query for this:
| 0debug |
Javascript: await function endend before loop continue : <p>i've a similar situation</p>
<pre><code>array.forEach(item => {
function_fetch(item)
})
</code></pre>
<p>now i need that before that loop continue he await that the function end and do what have to do, then recall the function with the other item</p>
| 0debug |
pandas how to check dtype for all columns in a dataframe? : <p>It seems that dtype only work for pandas.DataFrame.Series, right? Is there a function to display data types of all columns at once?</p>
| 0debug |
replace spatial case double quotes with single quotes in python. : i try several time but failed and weak in regex. I want to replace all double quotes with single quotes but not spatial case.
**Input**
"35457680047217","1","425121","2018-07-15 00:00:00.000",,,,"10.0","0",,"0",,"0",,,"0","0","0","0",,"[\"23\"]","[\"20\"]","[\"2\",\"58\"]","[\"0\",\"1\",\"2\",\"3\",\"4\"]","2",,"0",,"2018-07-15 00:00:00.000","2018-07-15 00:00:00.000","22",,,,"3",
**output**
'35457680047217','1','425121','2018-07-15 00:00:00.000',,,,'10.0','0',,'0',,'0',,,'0','0','0','0',,'[\"23\"]','[\"20\"]','[\"2\",\"58\"]','[\"0\",\"1\",\"2\",\"3\",\"4\"]','2',,'0',,'2018-07-15 00:00:00.000','2018-07-15 00:00:00.000','22',,,,'3', | 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.