problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
how to use a text file of positions and a text file of words to recreate a sentence : I must open the text files, use the positions and words that are stored in the text files, to recreate the user's original sentence. I want to recreate the sentence using only the text files
user's sentence = 'the cat sat on the cat mat'
indivdual_words = ['the', 'cat', 'sat', 'on', 'mat']
positions = [1, 2, 3, 4, 1, 2, 5]
f = open('word_file.txt', 'w+')
f.write(str(words))
f.close()
f = open('pos_file.txt', 'w+')
f.write(str(positions))
f.close()
| 0debug |
static void set_up_watchdog (m48t59_t *NVRAM, uint8_t value)
{
uint64_t interval;
if (NVRAM->wd_timer != NULL) {
qemu_del_timer(NVRAM->wd_timer);
NVRAM->wd_timer = NULL;
}
NVRAM->buffer[0x1FF0] &= ~0x80;
if (value != 0) {
interval = (1 << (2 * (value & 0x03))) * ((value >> 2) & 0x1F);
qemu_mod_timer(NVRAM->wd_timer, ((uint64_t)time(NULL) * 1000) +
((interval * 1000) >> 4));
}
}
| 1threat |
Target the width of the window fixed max-width="360px" : <p>I work on a web page and I want when I narrowed the page (by the square button to the right of the page close to closing page cross), the reduced page is reduced by a width-max = 360px, ie its minimum length = 360px; how I have to program this is what you had an example of solving this problem is thank you very much.</p>
| 0debug |
Spark 2.0 deprecates 'DirectParquetOutputCommitter', how to live without it? : <p>Recently we migrated from "EMR on HDFS" --> "EMR on S3" (EMRFS with consistent view enabled) and we realized the Spark 'SaveAsTable' (parquet format) writes to S3 were ~4x slower as compared to HDFS but we found a workaround of using the DirectParquetOutputCommitter -[1] w/ Spark 1.6.</p>
<p>Reason for S3 slowness - We had to pay the so called Parquet tax-[2] where the default output committer writes to a temporary table and renames it later where the rename operation in S3 is very expensive</p>
<p>Also we do understand the risk of using 'DirectParquetOutputCommitter' which is possibility of data corruption w/ speculative tasks enabled.</p>
<p>Now w/ Spark 2.0 this class has been deprecated and we're wondering what options do we have on the table so that we don't get to bear the ~4x slower writes when we upgrade to Spark 2.0. Any Thoughts/suggestions/recommendations would be highly appreciated.</p>
<p>One workaround that we can think of is - Save on HDFS and then copy it to S3 via s3DistCp (any thoughts on how can this be done in sane way as our Hive metadata-store points to S3?)</p>
<p>Also looks like NetFlix has fixed this -[3], any idea on when they're planning to open source it?</p>
<p>Thanks.</p>
<p>[1] - <a href="https://github.com/apache/spark/blob/21d5ca128bf3afd5c2d4c7fcc56240e28443474f/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/DirectParquetOutputCommitter.scala" rel="noreferrer">https://github.com/apache/spark/blob/21d5ca128bf3afd5c2d4c7fcc56240e28443474f/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/DirectParquetOutputCommitter.scala</a></p>
<p>[2] -
<a href="https://www.appsflyer.com/blog/the-bleeding-edge-spark-parquet-and-s3/" rel="noreferrer">https://www.appsflyer.com/blog/the-bleeding-edge-spark-parquet-and-s3/</a></p>
<p>[3] -
<a href="https://www.youtube.com/watch?v=85sew9OFaYc&feature=youtu.be&t=8m39s" rel="noreferrer">https://www.youtube.com/watch?v=85sew9OFaYc&feature=youtu.be&t=8m39s</a>
<a href="http://www.slideshare.net/AmazonWebServices/bdt303-running-spark-and-presto-on-the-netflix-big-data-platform" rel="noreferrer">http://www.slideshare.net/AmazonWebServices/bdt303-running-spark-and-presto-on-the-netflix-big-data-platform</a></p>
| 0debug |
static int nbd_co_send_reply(NBDRequest *req, struct nbd_reply *reply,
int len)
{
NBDClient *client = req->client;
int csock = client->sock;
int rc, ret;
qemu_co_mutex_lock(&client->send_lock);
qemu_set_fd_handler2(csock, NULL, nbd_read, nbd_restart_write, client);
client->send_coroutine = qemu_coroutine_self();
if (!len) {
rc = nbd_send_reply(csock, reply);
if (rc == -1) {
rc = -errno;
}
} else {
socket_set_cork(csock, 1);
rc = nbd_send_reply(csock, reply);
if (rc != -1) {
ret = qemu_co_send(csock, req->data, len);
if (ret != len) {
errno = EIO;
rc = -1;
}
}
if (rc == -1) {
rc = -errno;
}
socket_set_cork(csock, 0);
}
client->send_coroutine = NULL;
qemu_set_fd_handler2(csock, NULL, nbd_read, NULL, client);
qemu_co_mutex_unlock(&client->send_lock);
return rc;
}
| 1threat |
Clean react native project : <p>How to clean react native project?</p>
<p>Is there any way to clean react native project as we can clean xcode project?</p>
<p>Any help will be appreciated!</p>
| 0debug |
Payload contains two or more files with the same destination path 'System.Diagnostics.Tools.dll' : <p>After I add 2 libraries from Nuget to my project I receive follow error:</p>
<pre><code>Error Payload contains two or more files with the same destination path 'System.Diagnostics.Tools.dll'. Source files:
C:\Users\Horcrux7\.nuget\packages\runtime.any.System.Diagnostics.Tools\4.0.1\lib\netcore50\System.Diagnostics.Tools.dll
C:\Users\Horcrux7\.nuget\packages\System.Diagnostics.Tools\4.0.0\lib\netcore50\System.Diagnostics.Tools.dll App1
</code></pre>
<p>How can I solve this version conflict?</p>
<p>I have only a very small single UWP project.</p>
| 0debug |
static void scale_coefficients(AC3EncodeContext *s)
{
return;
}
| 1threat |
void desc_ring_free(DescRing *ring)
{
if (ring->info) {
g_free(ring->info);
}
g_free(ring);
}
| 1threat |
int load_flt_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
struct image_info * info)
{
struct lib_info libinfo[MAX_SHARED_LIBS];
abi_ulong p = bprm->p;
abi_ulong stack_len;
abi_ulong start_addr;
abi_ulong sp;
int res;
int i, j;
memset(libinfo, 0, sizeof(libinfo));
stack_len = 0;
for (i = 0; i < bprm->argc; ++i) {
stack_len += strlen(bprm->argv[i]);
}
for (i = 0; i < bprm->envc; ++i) {
stack_len += strlen(bprm->envp[i]);
}
stack_len += (bprm->argc + 1) * 4;
stack_len += (bprm->envc + 1) * 4;
res = load_flat_file(bprm, libinfo, 0, &stack_len);
if (res > (unsigned long)-4096)
return res;
for (i=0; i<MAX_SHARED_LIBS; i++) {
if (libinfo[i].loaded) {
abi_ulong p;
p = libinfo[i].start_data;
for (j=0; j<MAX_SHARED_LIBS; j++) {
p -= 4;
if (put_user_ual(libinfo[j].loaded
? libinfo[j].start_data
: UNLOADED_LIB,
p))
return -EFAULT;
}
}
}
p = ((libinfo[0].start_brk + stack_len + 3) & ~3) - 4;
DBG_FLT("p=%x\n", (int)p);
p = copy_strings(p, bprm->envc, bprm->envp);
p = copy_strings(p, bprm->argc, bprm->argv);
sp = p & ~(abi_ulong)(sizeof(abi_ulong) - 1);
stack_len = bprm->envc + bprm->argc + 2;
stack_len += 3;
stack_len *= sizeof(abi_ulong);
if ((sp + stack_len) & 15)
sp -= 16 - ((sp + stack_len) & 15);
sp = loader_build_argptr(bprm->envc, bprm->argc, sp, p, 1);
start_addr = libinfo[0].entry;
#ifdef CONFIG_BINFMT_SHARED_FLAT
#error here
for (i = MAX_SHARED_LIBS-1; i>0; i--) {
if (libinfo[i].loaded) {
--sp;
if (put_user_ual(start_addr, sp))
return -EFAULT;
start_addr = libinfo[i].entry;
}
}
#endif
info->start_code = libinfo[0].start_code;
info->end_code = libinfo[0].start_code = libinfo[0].text_len;
info->start_data = libinfo[0].start_data;
info->end_data = libinfo[0].end_data;
info->start_brk = libinfo[0].start_brk;
info->start_stack = sp;
info->stack_limit = libinfo[0].start_brk;
info->entry = start_addr;
info->code_offset = info->start_code;
info->data_offset = info->start_data - libinfo[0].text_len;
DBG_FLT("start_thread(entry=0x%x, start_stack=0x%x)\n",
(int)info->entry, (int)info->start_stack);
return 0;
}
| 1threat |
how do text inputs work for websites like codepen, codecademy, and google docs? : <p>They are editable and yet have custom highlighting. </p>
<p>They aren't using textarea. They are obviously putting elements in place where it should have been the text. Is there guide that builds something like that and show how you figure out where the cursor would go and so on.</p>
<p>beside reddit very few popular site actually use default html textarea element.</p>
<p>most have custom highlighting and all sorts of things going on, for which they generate html which gives appearance you're editing directly, yet it's javascript mimicking textarea/text input.</p>
| 0debug |
void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
Error **errp)
{
MachineState *machine = MACHINE(OBJECT(hotplug_dev));
sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(OBJECT(hotplug_dev));
sPAPRMachineState *spapr = SPAPR_MACHINE(OBJECT(hotplug_dev));
int spapr_max_cores = max_cpus / smp_threads;
int index;
Error *local_err = NULL;
CPUCore *cc = CPU_CORE(dev);
char *base_core_type = spapr_get_cpu_core_type(machine->cpu_model);
const char *type = object_get_typename(OBJECT(dev));
if (!smc->dr_cpu_enabled) {
error_setg(&local_err, "CPU hotplug not supported for this machine");
goto out;
}
if (strcmp(base_core_type, type)) {
error_setg(&local_err, "CPU core type should be %s", base_core_type);
goto out;
}
if (cc->nr_threads != smp_threads) {
error_setg(&local_err, "threads must be %d", smp_threads);
goto out;
}
if (cc->core_id % smp_threads) {
error_setg(&local_err, "invalid core id %d\n", cc->core_id);
goto out;
}
index = cc->core_id / smp_threads;
if (index < 0 || index >= spapr_max_cores) {
error_setg(&local_err, "core id %d out of range", cc->core_id);
goto out;
}
if (spapr->cores[index]) {
error_setg(&local_err, "core %d already populated", cc->core_id);
goto out;
}
out:
g_free(base_core_type);
error_propagate(errp, local_err);
}
| 1threat |
java program for poerball lottery : I have to check all test cases which i have given in arrays but i am not getting perfect answer.Please help me with this question.Create a PowerBall class that contains:
- A field for an int array of size 6.
- A constructor that initializes this array with 6 random values (0-9).
- A method called checkMatch that takes as an argument an int array and returns how many numbers match the class's int array. To match, the same numbers must be in the same position.
Write a main class which asks to user to enter 6 numbers as their lottery ticket and store it in an array. Then create a PowerBall object and give the user's ticket to the checkMatch method. Then figure out the amount won based on the return value.
The winnings are determined as follows:
If 0 numbers match, no winnings
If 1 number matches, win $4
If 2 numbers match, win $7
If 3 numbers match, win $100
If 4 numbers match, win $10,000
If 5 numbers match, win $1 Million
If all 6 numbers match, win Grand Prize of $450 Million
Output the user's lottery ticket, the powerball numbers, how many matched, and the amount of money won. (JAVA PROGRAM HELP)
class PowerBall {
/*
* ALL PRIVATE DATA BELOW
*/
private int[] winningNumber;
private int[] ticketNumber;
private long cash;
static private IntUtil u = new IntUtil();
int matchBalCount ;
int powerBallMatchCount;
public int cash() {
for (int i = 0; i < winningNumber.length; i++) {
for (int j = 0; j < ticketNumber.length; j++) {
if (i == winningNumber.length-1 && ticketNumber[i] == winningNumber[j]) {
powerBallMatchCount=1;
} else if (ticketNumber[i] == winningNumber[j]) {
matchBalCount++;
}
}
}
return 100;
}
public void check(int matchBalCount,int powerBalCount){
System.out.println("prize---matchBalCount::"+matchBalCount+" ,powerBallMatchCount::"+powerBallMatchCount);
if (matchBalCount == 0 && powerBallMatchCount>0) {
System.out.println("4");
}else if (matchBalCount == 1 && powerBallMatchCount>0) {
System.out.println("4");
}else if (matchBalCount == 2 && powerBallMatchCount>0) {
System.out.println("7");
}else if (matchBalCount == 3 && powerBallMatchCount<0) {
System.out.println("7");
}else if (matchBalCount == 3&& powerBallMatchCount>0) {
System.out.println("100");
}else if (matchBalCount == 4 && powerBallMatchCount<0) {
System.out.println("100");
}else if (matchBalCount == 4 && powerBallMatchCount>0) {
System.out.println("50000");
}else if (matchBalCount == 5 && powerBallMatchCount>0) {
System.out.println("1lakh");
}
}
PowerBall(int[] w, int[] t) {
winningNumber = w;
ticketNumber = t;
cash = 0;
check(matchBalCount,powerBallMatchCount);
}
private static void test1() {
int[] w = {4, 8, 19, 27, 24, 10};
{
int[] n = {4, 8, 19, 27, 24, 10};
PowerBall x = new PowerBall(w, n);
// x.cash();
}
{
int[] n = {24, 27, 19, 8, 4, 10};
PowerBall x = new PowerBall(w, n);
}
{
int[] n = {24, 27, 19, 8, 4, 5};
PowerBall x = new PowerBall(w, n);
}
{
int[] n = {124, 127, 119, 18, 14, 10};
PowerBall x = new PowerBall(w, n);
}
{
int[] n = {124, 127, 119, 18, 14, 5};
PowerBall x = new PowerBall(w, n);
}
{
int[] n = {124, 127, 119, 18, 14};
PowerBall x = new PowerBall(w, n);
}
{
int[] n = {124, 124, 19, 119, 18, 14};
PowerBall x = new PowerBall(w, n);
}
}
private static void testRandom() {
int[] w = {4, 8, 19, 27, 24, 10};
int max = 10;
long c = 0;
for (int i = 0; i < max; ++i) {
int[] n = u.generateRandomNumber(6, true, 1, 99);
PowerBall x = new PowerBall(w, n);
c = c + x.cash();
}
System.out.println("Out of " + max + " times you win " + c + "$");
}
private static void testBench() {
test1();
testRandom();
}
public static void main(String[] args) {
System.out.println("PowerBall.java");
testBench();
System.out.println("Done");
}
} | 0debug |
I am getting run time error for the below code : #include<stdio.h>
#include<stdlib.h>
int main(){
int i,j,a[10],result=0,p;
int *m=malloc(sizeof(int)*8);
for(i=0;i<10;i++){
scanf("%d",&a[i]);
result+=a[i];}
//printf("%d\n",result);
//printf("\n");
// for(i=0;i<8;i++){
for(j=0;j<9;j++){
scanf("%d",&m[j]);
result=result-m[j];
p=result/2;}
return p;
}
In this code i am runtime error.Any help would be appreciated.THanks! | 0debug |
int postcopy_ram_enable_notify(MigrationIncomingState *mis)
{
mis->userfault_fd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK);
if (mis->userfault_fd == -1) {
error_report("%s: Failed to open userfault fd: %s", __func__,
strerror(errno));
return -1;
}
if (!ufd_version_check(mis->userfault_fd)) {
return -1;
}
mis->userfault_quit_fd = eventfd(0, EFD_CLOEXEC);
if (mis->userfault_quit_fd == -1) {
error_report("%s: Opening userfault_quit_fd: %s", __func__,
strerror(errno));
close(mis->userfault_fd);
return -1;
}
qemu_sem_init(&mis->fault_thread_sem, 0);
qemu_thread_create(&mis->fault_thread, "postcopy/fault",
postcopy_ram_fault_thread, mis, QEMU_THREAD_JOINABLE);
qemu_sem_wait(&mis->fault_thread_sem);
qemu_sem_destroy(&mis->fault_thread_sem);
mis->have_fault_thread = true;
if (qemu_ram_foreach_block(ram_block_enable_notify, mis)) {
return -1;
}
qemu_balloon_inhibit(true);
trace_postcopy_ram_enable_notify();
return 0;
}
| 1threat |
def max_sum_increasing_subseq(a, n, index, k):
dp = [[0 for i in range(n)]
for i in range(n)]
for i in range(n):
if a[i] > a[0]:
dp[0][i] = a[i] + a[0]
else:
dp[0][i] = a[i]
for i in range(1, n):
for j in range(n):
if a[j] > a[i] and j > i:
if dp[i - 1][i] + a[j] > dp[i - 1][j]:
dp[i][j] = dp[i - 1][i] + a[j]
else:
dp[i][j] = dp[i - 1][j]
else:
dp[i][j] = dp[i - 1][j]
return dp[index][k] | 0debug |
How to commit a shell command via Java : <p>Is it possible to let your (java) code open a command prompt and enter something within?
How does the syntax look like?
Thank you</p>
| 0debug |
static int tcp_chr_new_client(CharDriverState *chr, QIOChannelSocket *sioc)
{
TCPCharDriver *s = chr->opaque;
if (s->ioc != NULL) {
return -1;
}
s->ioc = QIO_CHANNEL(sioc);
object_ref(OBJECT(sioc));
if (s->do_nodelay) {
qio_channel_set_delay(s->ioc, false);
}
if (s->listen_tag) {
g_source_remove(s->listen_tag);
s->listen_tag = 0;
}
if (s->do_telnetopt) {
tcp_chr_telnet_init(chr);
} else {
tcp_chr_connect(chr);
}
return 0;
}
| 1threat |
Plzz help as a benineer am not be able to resolve it : try
{
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
SqlParameter[] pram = new SqlParameter[7];
pram[0] = new SqlParameter("@fname", SqlDbType.VarChar, 50);
pram[1] = new SqlParameter("@lname", SqlDbType.VarChar, 50);
pram[2] = new SqlParameter("@dob", SqlDbType.VarChar, 50);
pram[3] = new SqlParameter("@gender", SqlDbType.Char, 10);
pram[4] = new SqlParameter("@fathername", SqlDbType.VarChar, 50);
pram[5] = new SqlParameter("@contact", SqlDbType.Int, 100);
pram[6] = new SqlParameter("@address", SqlDbType.VarChar, 50);
pram[0].Value = fname;
pram[1].Value = lname;
pram[2].Value = dob;
pram[3].Value = gender;
pram[4].Value = fathername;
pram[5].Value = contact;
pram[6].Value = address;
for (int i = 0; i < pram.Length; i++)
{
cmd.Parameters.Add(pram[i]);
}
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
}
catch(System.Data.SqlClient.SqlException ex_msg)
{
string msg = "Error occured while inserting";
msg += ex_msg.Message;
throw new Exception(msg);
}
finally
{
conn.Close();
} | 0debug |
static int sdl_write_header(AVFormatContext *s)
{
SDLContext *sdl = s->priv_data;
AVStream *st = s->streams[0];
AVCodecContext *encctx = st->codec;
AVRational sar, dar;
int i, ret;
int flags = SDL_SWSURFACE | sdl->window_fullscreen ? SDL_FULLSCREEN : 0;
if (!sdl->window_title)
sdl->window_title = av_strdup(s->filename);
if (!sdl->icon_title)
sdl->icon_title = av_strdup(sdl->window_title);
if (SDL_WasInit(SDL_INIT_VIDEO)) {
av_log(s, AV_LOG_ERROR,
"SDL video subsystem was already inited, aborting\n");
sdl->sdl_was_already_inited = 1;
ret = AVERROR(EINVAL);
goto fail;
}
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
av_log(s, AV_LOG_ERROR, "Unable to initialize SDL: %s\n", SDL_GetError());
ret = AVERROR(EINVAL);
goto fail;
}
if ( s->nb_streams > 1
|| encctx->codec_type != AVMEDIA_TYPE_VIDEO
|| encctx->codec_id != AV_CODEC_ID_RAWVIDEO) {
av_log(s, AV_LOG_ERROR, "Only supports one rawvideo stream\n");
ret = AVERROR(EINVAL);
goto fail;
}
for (i = 0; sdl_overlay_pix_fmt_map[i].pix_fmt != AV_PIX_FMT_NONE; i++) {
if (sdl_overlay_pix_fmt_map[i].pix_fmt == encctx->pix_fmt) {
sdl->overlay_fmt = sdl_overlay_pix_fmt_map[i].overlay_fmt;
break;
}
}
if (!sdl->overlay_fmt) {
av_log(s, AV_LOG_ERROR,
"Unsupported pixel format '%s', choose one of yuv420p, yuyv422, or uyvy422\n",
av_get_pix_fmt_name(encctx->pix_fmt));
ret = AVERROR(EINVAL);
goto fail;
}
sar = st->sample_aspect_ratio.num ? st->sample_aspect_ratio : (AVRational){ 1, 1 };
dar = av_mul_q(sar, (AVRational){ encctx->width, encctx->height });
if (sdl->window_width && sdl->window_height) {
if (av_cmp_q(dar, (AVRational){ sdl->window_width, sdl->window_height }) > 0) {
sdl->overlay_width = sdl->window_width;
sdl->overlay_height = av_rescale(sdl->overlay_width, dar.den, dar.num);
} else {
sdl->overlay_height = sdl->window_height;
sdl->overlay_width = av_rescale(sdl->overlay_height, dar.num, dar.den);
}
} else {
if (sar.num > sar.den) {
sdl->overlay_width = encctx->width;
sdl->overlay_height = av_rescale(sdl->overlay_width, dar.den, dar.num);
} else {
sdl->overlay_height = encctx->height;
sdl->overlay_width = av_rescale(sdl->overlay_height, dar.num, dar.den);
}
sdl->window_width = sdl->overlay_width;
sdl->window_height = sdl->overlay_height;
}
sdl->overlay_x = (sdl->window_width - sdl->overlay_width ) / 2;
sdl->overlay_y = (sdl->window_height - sdl->overlay_height) / 2;
SDL_WM_SetCaption(sdl->window_title, sdl->icon_title);
sdl->surface = SDL_SetVideoMode(sdl->window_width, sdl->window_height,
24, flags);
if (!sdl->surface) {
av_log(s, AV_LOG_ERROR, "Unable to set video mode: %s\n", SDL_GetError());
ret = AVERROR(EINVAL);
goto fail;
}
sdl->overlay = SDL_CreateYUVOverlay(encctx->width, encctx->height,
sdl->overlay_fmt, sdl->surface);
if (!sdl->overlay || sdl->overlay->pitches[0] < encctx->width) {
av_log(s, AV_LOG_ERROR,
"SDL does not support an overlay with size of %dx%d pixels\n",
encctx->width, encctx->height);
ret = AVERROR(EINVAL);
goto fail;
}
av_log(s, AV_LOG_VERBOSE, "w:%d h:%d fmt:%s sar:%d/%d -> w:%d h:%d\n",
encctx->width, encctx->height, av_get_pix_fmt_name(encctx->pix_fmt), sar.num, sar.den,
sdl->overlay_width, sdl->overlay_height);
return 0;
fail:
sdl_write_trailer(s);
return ret;
}
| 1threat |
SQL server statemnt : I have created the following table:
CREATE TABLE Student
(
StudentID int PRIMARY KEY,
Name varchar(30),
Age int,
Course varchar(30),
Year int,
Address varchar(50),
Phone varchar(12),
Email varchar(50),
);
**I was wondering how to run a query to show the year level and the number of students in each year level I need only to show year levels that have at least two students.** | 0debug |
what's wrong with my while loop code in R? : <p>I want to using while loop in R.</p>
<p>I want to repeat loop until evt>1 and cpr>0, but it doesn't work.</p>
<p>work_f is function of generating numbers.</p>
<pre><code>if((evt>1)&&(cpr>0)){
work<-work[order(work$z),]
obs<-c(1:length(work$z))
work<-cbind(work,obs)
} else {
while((evt>1)&&(cpr>0)) {
j<-j+1
seed<-settings*1000+h+j
work_f(studysize = studysize,beta=beta,cutpoint = cutpoint,settings = settigns,p=p,alpha = alpha)
evt<-data.frame(ftable(work$event))
evttr<-data.frame(evt=numeric(1),cpr=numeric(1),csr=numeric(1))
if (p==0) {
evttr$evt<-evt$Freq[1]; evttr$cpr<-evt$Freq[2]; evttr$csr<-0
}else {
evttr$evt<-evt$Freq[2]; evttr$cpr<-evt$Freq[3]; evttr$csr<-evt$Freq[1]
}
evttr[is.na(evttr)]<-0
evt<-as.numeric(evttr$evt); cpr<-as.numeric(evttr$cpr)
if((evt>1)&&(cpr>0)){
work<-work[order(work$z),]
obs<-c(1:length(work$z))
work<-cbind(work,obs)
}
}
}
</code></pre>
<p>What's wrong?</p>
| 0debug |
static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
VLC *table, int coeff_index,
int first_fragment, int last_fragment,
int eob_run)
{
int i;
int token;
int zero_run = 0;
DCTELEM coeff = 0;
Vp3Fragment *fragment;
uint8_t *perm= s->scantable.permutated;
int bits_to_get;
if ((first_fragment >= s->fragment_count) ||
(last_fragment >= s->fragment_count)) {
av_log(s->avctx, AV_LOG_ERROR, " vp3:unpack_vlcs(): bad fragment number (%d -> %d ?)\n",
first_fragment, last_fragment);
return 0;
}
for (i = first_fragment; i <= last_fragment; i++) {
int fragment_num = s->coded_fragment_list[i];
if (s->coeff_counts[fragment_num] > coeff_index)
continue;
fragment = &s->all_fragments[fragment_num];
if (!eob_run) {
token = get_vlc2(gb, table->table, 5, 3);
if (token <= 6) {
eob_run = eob_run_base[token];
if (eob_run_get_bits[token])
eob_run += get_bits(gb, eob_run_get_bits[token]);
coeff = zero_run = 0;
} else {
bits_to_get = coeff_get_bits[token];
if (!bits_to_get)
coeff = coeff_tables[token][0];
else
coeff = coeff_tables[token][get_bits(gb, bits_to_get)];
zero_run = zero_run_base[token];
if (zero_run_get_bits[token])
zero_run += get_bits(gb, zero_run_get_bits[token]);
}
}
if (!eob_run) {
s->coeff_counts[fragment_num] += zero_run;
if (s->coeff_counts[fragment_num] < 64){
fragment->next_coeff->coeff= coeff;
fragment->next_coeff->index= perm[s->coeff_counts[fragment_num]++];
fragment->next_coeff->next= s->next_coeff;
s->next_coeff->next=NULL;
fragment->next_coeff= s->next_coeff++;
}
} else {
s->coeff_counts[fragment_num] |= 128;
eob_run--;
}
}
return eob_run;
}
| 1threat |
Formik - How to reset form after confirmation : <p>In <a href="https://github.com/jaredpalmer/formik" rel="noreferrer">Formik</a>, how to make the Reset button reset the form only <strong>after confirmation</strong>?</p>
<p>My code below still resets the form even when you click Cancel.</p>
<pre><code>var handleReset = (values, formProps) => {
return window.confirm('Reset?'); // still resets after you Cancel :(
};
return (
<Formik onReset={handleReset}>
{(formProps) => {
return (
<Form>
...
<button type='reset'>Reset</button>
</Form>
)}}
</Formik>
);
</code></pre>
| 0debug |
How would you do this using CSS? : [Design from Client][1]
[1]: https://i.stack.imgur.com/8Wewk.jpg
So a client gave me this design. The background is supposed to change when the different wood grain options are clicked - easy. The part I'm scratching my head about is the middle with the dovetail? It's not an easy problem.
I'm wondering how you would approach this. Right now I'm thinking use CSS Grid and try to center the wood grain background images vertically and align them left. Then I'll stack divs in the middle.
Is there an easier way? | 0debug |
How can i make div 1 appear below in div 2 using css : <pre><code><div class="1">
<p> THIS IS DIV 1> </p>
<div class="2">
<p> THIS IS DIV 2> </p>
</code></pre>
<p>I am using some shortcode but the problem is it will appear always on the top of all elements.</p>
<p>Thanks in advance..</p>
| 0debug |
Java unexpected NaN? : So I have to make some code that, when the user types in a number from 1-4, it will do either + - * or /, depending on what number they choose.
console.log("Calculator program");
console.log("1. Add numbers");
console.log("2. Subtract numbers");
console.log("3. Multiply numbers");
console.log("4. Divide numbers");
var choice = prompt ("What is your choice?");
if (choice == 1)
{
console.log(number1 + number2);
}
if (choice == 2)
{
console.log(number1 - number2);
}
if (choice == 3)
{
console.log(number1 * number2);
}
if (choice == 4)
{
console.log(number1 / number2);
}
var number1 = prompt("Type in a number");
var number2 = prompt("Type in another number");
The user is meant to put the numbers in after they have chosen a function, however when the user types in the first number, a NaN appears.
I assume this is because the user has not even types in the 2 numbers, but I need the user to type the numbers last.
Any help and advice would be very appreciated, thanks | 0debug |
int coroutine_fn qemu_co_recvv(int sockfd, struct iovec *iov,
int len, int iov_offset)
{
int total = 0;
int ret;
while (len) {
ret = qemu_recvv(sockfd, iov, len, iov_offset + total);
if (ret < 0) {
if (errno == EAGAIN) {
qemu_coroutine_yield();
continue;
}
if (total == 0) {
total = -1;
}
break;
}
if (ret == 0) {
break;
}
total += ret, len -= ret;
}
return total;
}
| 1threat |
static int segment_end(AVFormatContext *s, int write_trailer, int is_last)
{
SegmentContext *seg = s->priv_data;
AVFormatContext *oc = seg->avf;
int ret = 0;
av_write_frame(oc, NULL);
if (write_trailer)
ret = av_write_trailer(oc);
if (ret < 0)
av_log(s, AV_LOG_ERROR, "Failure occurred when ending segment '%s'\n",
oc->filename);
if (seg->list) {
if (seg->list_size || seg->list_type == LIST_TYPE_M3U8) {
SegmentListEntry *entry = av_mallocz(sizeof(*entry));
if (!entry) {
ret = AVERROR(ENOMEM);
goto end;
}
memcpy(entry, &seg->cur_entry, sizeof(*entry));
if (!seg->segment_list_entries)
seg->segment_list_entries = seg->segment_list_entries_end = entry;
else
seg->segment_list_entries_end->next = entry;
seg->segment_list_entries_end = entry;
if (seg->list_size && seg->segment_count > seg->list_size) {
entry = seg->segment_list_entries;
seg->segment_list_entries = seg->segment_list_entries->next;
av_free(entry->filename);
av_freep(&entry);
}
avio_close(seg->list_pb);
if ((ret = segment_list_open(s)) < 0)
goto end;
for (entry = seg->segment_list_entries; entry; entry = entry->next)
segment_list_print_entry(seg->list_pb, seg->list_type, entry, s);
if (seg->list_type == LIST_TYPE_M3U8 && is_last)
avio_printf(seg->list_pb, "#EXT-X-ENDLIST\n");
} else {
segment_list_print_entry(seg->list_pb, seg->list_type, &seg->cur_entry, s);
}
avio_flush(seg->list_pb);
}
av_log(s, AV_LOG_VERBOSE, "segment:'%s' count:%d ended\n",
seg->avf->filename, seg->segment_count);
seg->segment_count++;
end:
avio_close(oc->pb);
return ret;
}
| 1threat |
static void av_always_inline filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp, int intra ) {
const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
int alpha = alpha_table[index_a];
int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
if (alpha ==0 || beta == 0) return;
if( bS[0] < 4 || !intra ) {
int8_t tc[4];
tc[0] = tc0_table[index_a][bS[0*bsi]];
tc[1] = tc0_table[index_a][bS[1*bsi]];
tc[2] = tc0_table[index_a][bS[2*bsi]];
tc[3] = tc0_table[index_a][bS[3*bsi]];
h->h264dsp.h264_h_loop_filter_luma_mbaff(pix, stride, alpha, beta, tc);
} else {
h->h264dsp.h264_h_loop_filter_luma_mbaff_intra(pix, stride, alpha, beta);
}
}
| 1threat |
Logo on mobile view not centered : <p>Sorry for the noob question.I've bought a template in order to practice and I have the next situation.
I'm trying to obtain a centered logo for mobile device and I simply can not figure what is the problem.</p>
<p>I've uploaded the code on a domain: <a href="http://digitalicus.com/" rel="nofollow noreferrer">http://digitalicus.com/</a> to simplify the process of explaining.</p>
<p>Any advice's are much appreciated.</p>
<p>Vlad</p>
| 0debug |
int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame,
int64_t pts, AVRational pixel_aspect)
{
BufferSourceContext *c = buffer_filter->priv;
AVFilterBufferRef *buf;
int ret;
if (!buf) {
c->eof = 1;
return 0;
} else if (c->eof)
return AVERROR(EINVAL);
if (!av_fifo_space(c->fifo) &&
(ret = av_fifo_realloc2(c->fifo, av_fifo_size(c->fifo) +
sizeof(buf))) < 0)
return ret;
CHECK_PARAM_CHANGE(buffer_filter, c, frame->width, frame->height, frame->format);
buf = avfilter_get_video_buffer(buffer_filter->outputs[0], AV_PERM_WRITE,
c->w, c->h);
av_image_copy(buf->data, buf->linesize, frame->data, frame->linesize,
c->pix_fmt, c->w, c->h);
avfilter_copy_frame_props(buf, frame);
buf->pts = pts;
buf->video->pixel_aspect = pixel_aspect;
if ((ret = av_fifo_generic_write(c->fifo, &buf, sizeof(buf), NULL)) < 0) {
avfilter_unref_buffer(buf);
return ret;
}
return 0;
}
| 1threat |
import re
def text_match(text):
patterns = 'ab*?'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!') | 0debug |
How to change the direction of the animation in StackNavigator? : <p>How to change the direction of the animation in StackNavigator?</p>
<h3>Current Behavior</h3>
<p>When user goes to another screen, the screen flies from <strong>bottom to top</strong>. </p>
<h3>Expected Behavior</h3>
<p>When user goes to another screen, the screen flies from <strong>right to left</strong>. (Like Facebook or Instagram!)</p>
<h3>StackNavigator Code</h3>
<pre><code>export default StackNavigator ({
Main: {
screen: MainScreen,
},
...
}, {
navigationOptions: ({navigation, screenProps}) => ({
tabBarOnPress: blahblaj
}),
lazy: true
// I guess we can do something here
});
</code></pre>
<ul>
<li>If we can set the animation time, it will be even better! Currently it looks like the screen flies from middle of the screen to top. I want natural animation like Facebook or Instagram :)</li>
</ul>
<p>Thanks in advance, </p>
| 0debug |
Are global static variables within a file comparable to a local static variable within a function? : <p>I know declaring a global variable as STATIC will make it visible to the current file. Does the variable retain its data every time functions are called within the file?</p>
<p>For example,</p>
<p>Let's say some file calls func1() below, which modifies the static global variable data and then calls func2() which modifies it again.</p>
<p>The next time a file calls func1(), will it be modifying a new data variable struct? or will it preserve the previous data that was modified in the first call?</p>
<pre><code>STATIC MY_DATA Data1;
void func1( ){
//modify Data1
func2(Data1);
}
void func2 (MY_DATA data){
// modify data
}
</code></pre>
| 0debug |
static int tgv_decode_inter(TgvContext * s, const uint8_t *buf, const uint8_t *buf_end){
unsigned char *frame0_end = s->last_frame.data[0] + s->avctx->width*s->last_frame.linesize[0];
int num_mvs;
int num_blocks_raw;
int num_blocks_packed;
int vector_bits;
int i,j,x,y;
GetBitContext gb;
int mvbits;
const unsigned char *blocks_raw;
if(buf+12>buf_end)
return -1;
num_mvs = AV_RL16(&buf[0]);
num_blocks_raw = AV_RL16(&buf[2]);
num_blocks_packed = AV_RL16(&buf[4]);
vector_bits = AV_RL16(&buf[6]);
buf += 12;
if (num_mvs > s->num_mvs) {
s->mv_codebook = av_realloc(s->mv_codebook, num_mvs*2*sizeof(int));
s->num_mvs = num_mvs;
}
if (num_blocks_packed > s->num_blocks_packed) {
s->block_codebook = av_realloc(s->block_codebook, num_blocks_packed*16*sizeof(unsigned char));
s->num_blocks_packed = num_blocks_packed;
}
mvbits = (num_mvs*2*10+31) & ~31;
if (buf+(mvbits>>3)+16*num_blocks_raw+8*num_blocks_packed>buf_end)
return -1;
init_get_bits(&gb, buf, mvbits);
for (i=0; i<num_mvs; i++) {
s->mv_codebook[i][0] = get_sbits(&gb, 10);
s->mv_codebook[i][1] = get_sbits(&gb, 10);
}
buf += mvbits>>3;
blocks_raw = buf;
buf += num_blocks_raw*16;
init_get_bits(&gb, buf, (buf_end-buf)<<3);
for (i=0; i<num_blocks_packed; i++) {
int tmp[4];
for(j=0; j<4; j++)
tmp[j] = get_bits(&gb, 8);
for(j=0; j<16; j++)
s->block_codebook[i][15-j] = tmp[get_bits(&gb, 2)];
}
if (get_bits_left(&gb) < vector_bits *
(s->avctx->height/4) * (s->avctx->width/4))
return -1;
for(y=0; y<s->avctx->height/4; y++)
for(x=0; x<s->avctx->width/4; x++) {
unsigned int vector = get_bits(&gb, vector_bits);
const unsigned char *src;
int src_stride;
if (vector < num_mvs) {
src = s->last_frame.data[0] +
(y*4 + s->mv_codebook[vector][1])*s->last_frame.linesize[0] +
x*4 + s->mv_codebook[vector][0];
src_stride = s->last_frame.linesize[0];
if (src+3*src_stride+3>=frame0_end)
continue;
}else{
int offset = vector - num_mvs;
if (offset<num_blocks_raw)
src = blocks_raw + 16*offset;
else if (offset-num_blocks_raw<num_blocks_packed)
src = s->block_codebook[offset-num_blocks_raw];
else
continue;
src_stride = 4;
}
for(j=0; j<4; j++)
for(i=0; i<4; i++)
s->frame.data[0][ (y*4+j)*s->frame.linesize[0] + (x*4+i) ] =
src[j*src_stride + i];
}
return 0;
}
| 1threat |
static int ffm_write_write_index(int fd, int64_t pos)
{
uint8_t buf[8];
int i;
for(i=0;i<8;i++)
buf[i] = (pos >> (56 - i * 8)) & 0xff;
lseek(fd, 8, SEEK_SET);
if (write(fd, buf, 8) != 8)
return AVERROR(EIO);
return 8;
}
| 1threat |
struct omap_mcbsp_s *omap_mcbsp_init(MemoryRegion *system_memory,
target_phys_addr_t base,
qemu_irq *irq, qemu_irq *dma, omap_clk clk)
{
struct omap_mcbsp_s *s = (struct omap_mcbsp_s *)
g_malloc0(sizeof(struct omap_mcbsp_s));
s->txirq = irq[0];
s->rxirq = irq[1];
s->txdrq = dma[0];
s->rxdrq = dma[1];
s->sink_timer = qemu_new_timer_ns(vm_clock, omap_mcbsp_sink_tick, s);
s->source_timer = qemu_new_timer_ns(vm_clock, omap_mcbsp_source_tick, s);
omap_mcbsp_reset(s);
memory_region_init_io(&s->iomem, &omap_mcbsp_ops, s, "omap-mcbsp", 0x800);
memory_region_add_subregion(system_memory, base, &s->iomem);
return s;
}
| 1threat |
Regex to get words or series of words that start with a capital letter or samm word both :
I want to get regular expressin for both small and capital
[gstr1,GSTR1,gstr2,GSTR2,GSTR3a,GSTR3b]
I've tried
[gstr][1-4][a-cA-D]|gstr[1-4]
but cant get the right solution.
| 0debug |
How to generate an embed code for a button : <p>I want to generate an embed code for a Donate button on my server so that anytime a user add the code to his/her website the Donate button will show</p>
| 0debug |
How does the prim's algorithm run when compared with Kruskal's algorithm in terms of efficiency? : <p>I would like to know how Prim's algorithm stand against Kruskal's algorithm in terms of efficiency</p>
| 0debug |
Why doesn't this loop correctly fill a 2D array (c++)? : <p>this code</p>
<pre><code>int rows;
int cols;
cout << "enter desired columns of matrix" << endl;
cin >> cols;
cout << "enter desired rows of matrix" << endl;
cin >> rows;
int matrix[cols][rows];
cout << "begin entering values row by row" << endl;
for(int i = 0; i < cols; i++)
for(int j = 0; j < rows; j++){
cin >> matrix[i][j];
}
</code></pre>
<p>produces this output</p>
<pre><code>enter desired width of matrix
10
enter desired height of matrix
10
begin entering values
1
1
RUN SUCCESSFUL (total time: 4s)
</code></pre>
<p>Why don't the nested for loops iterate through the array row by row, getting input for each element? Also, if the first '1' is the input I typed, what is the second '1' that is output on the last line just prior to termination?</p>
| 0debug |
Python use as loop to make a formula : <p>I want to use a loop to make a formula. I will be adding pandas columns but the number of columns I'll add depends on a condidition within the loop.</p>
<p>For example</p>
<pre><code>l=[1,2,3,4]
s='a='
out=''
for i in l:
out=out+'+'+str(i)
</code></pre>
<p>In this example s+out should equal <code>10</code> and not <code>'a=+1+2+3+4'</code></p>
| 0debug |
convert a key value pair into 2 different objects : <p><strong>Let me explain here</strong></p>
<pre><code>let obj = {manager:XYZ}
//output:[{position:"manager",name:"XYZ"}]
</code></pre>
<p><em>you can also use lodash to find the solution</em></p>
| 0debug |
HTML5 history API on iOS Chrome : <p>For testing purposes I want to populate the history with a number of entries. More precisely I want to add X items to kind of disable the backbutton of the browser, since even if the user is clicking X times, he will stay on the same page.</p>
<p>I'm doing this the following way:</p>
<pre><code>(function (){
for (var x = 0; x < 10; x++) {
history.pushState(null, document.title, location.pathname);
}
}());
</code></pre>
<p>So when the page is being loaded 10 elements of the current page are injected into the history. This approach works on all browsers that support the history API <strong>except Chrome on iOS</strong>!!!</p>
<p>Using the above code, Chrome on iOS (7 to 10) does some really weird things:</p>
<ul>
<li>It replaces the title in the tab with the url of the current page (so instead of showing "my great webpage" in the tab title, it shows "mygreatpage.com/samplepage1"</li>
<li>long pressing the back button to check the entries, Chrome shows no additional added entries - every other browser shows 10 additional entries as intended by the code above</li>
</ul>
<p>Safari and every other iOS browser do what I want them to.
What am I doing wrong?</p>
| 0debug |
rewrite from foreach loop to list in C# : public static List<vwStudentExtendedData> GetStudentExtendedData(List<int> studentIds, DateTime? queryDate, int? sectionId)
{
var summaries = new List<vwStudentExtendedData>();
var studentsIDsForSproc = new List<int>();
foreach (var studentId in studentIds)
{
var cachedCopy = CacheHelper.GetFromCache<vwStudentExtendedData>(GetStudentSummaryCacheKey(studentId, queryDate, sectionId));
if (cachedCopy == null)
{
studentsIDsForSproc.Add(studentId);
}
else
{
summaries.Add(cachedCopy);
}
}
}
Hi, I would like to tune the code, here foreach loop running each and evrytime,i would like to put in list.
| 0debug |
document.write('<script src="evil.js"></script>'); | 1threat |
Need help in regex (in Google Analytics) : Setting up a goal in GA for my ecommerce store.
My products are all direct from the main url without the **/products/** segment so I cant id them on GA. (e.g. they all look like this www.abc.com/baby-food)
Product pages: www.abc.com/word-word-.. and may include special characters
How do I use a single expression to id product page from the rest?
Examples of other pages from my site:
/shop/study/2018-study-necessities/prepare-for-school/general-materials
/shop/read/books/parenting
/Class/SearchResults/0/ALL
/articles
/shop
| 0debug |
how to disable jenkins pipeline job : <p>I am using pipeline jobs with Jenkins 2.0, but I don't see option 'disable job' as I was used to in older Jenkins versions. Am I missing something? Is it still possible to disable (pipeline) job? </p>
| 0debug |
need help in writing sql server query : My data is look like below (usually more than 2 records)
OBLIGOR OBN_NUM XPTYPE NET_UNUSED BANK_ASSET
1 000100000 0101 100 0
1 000100001 5151 100 0
1 000100002 5151 50 0
when i use the below sql, i am able to sum as 100 only ( but i want to get 250).
SELECT SUM(NET_UNUSED)+SUM(BANK_ASSET) AS BANK_ASSET, OBLIGOR AS OBLIGOR,
SUBSTRING (OBN_NUM,1,4) AS OBN_NUM FROM RB_CRM_DEV.[IN].STG_SF_I_DC
WHERE SUBSTRING (OBN_NUM,1,4) = SUBSTRING (OBN_NUM,1,4)
AND SUBSTRING( XPTYPE,1,1) IN (0,1)
GROUP BY OBLIGOR, SUBSTRING (OBN_NUM,1,4)
ORDER by OBLIGOR,SUBSTRING(OBN_NUM,1,4)
how do i make sure my set of record should have xptype as 0,1 for atleast record to check in this query ( since SUBSTRING( XPTYPE,1,1) IN (0,1) condition drops the other two records)
| 0debug |
React: Parsing error in my functional component : <p>I installed babel-eslint and added <code>"parser": "babel-eslint"</code> but I'm still getting parsing error.</p>
<p>My package.json is:</p>
<pre><code>{
"name": "listassign",
"version": "0.1.0",
"private": true,
"dependencies": {
"bootstrap": "^4.4.1",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "3.2.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"parser": "babel-eslint",
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"babel-eslint": "^10.0.3"
},
"extends": [
"standard",
"standard-react"
]
}
</code></pre>
<p>I'm getting error in file:</p>
<pre class="lang-js prettyprint-override"><code>function CharComponent(props){
let displayList = [];
function delete(e){
let index = e.target.id;
displayList.slice(index,1);
}
</code></pre>
<p>Error is:<code>Parsing error: Unexpected keyword 'delete'</code></p>
<p>I did <a href="https://stackoverflow.com/a/44626825/10390678">this</a> but no help.</p>
| 0debug |
how save PDF file into database : <p>i need to save PDF file into database from my android app.
Storing a PDF file or image is the same?
Online i didn't find any video tutorial that teach to store pdf file into database.</p>
<p>THANKS for the help in advance!</p>
| 0debug |
Install Python Package From Private Bitbucket Repo : <p>I created a Python 3.5 package for work, which is in a private Bitbucket repo and I can easily pull the code and do a "python .\setup.py install" to have it install, but I want to try to eliminate the step of having to pull the code and have multiple copies on my machine and at the same time make it easier for my coworkers to install/update the package. Is it possible to use git bash or cmd (we are all on Windows) to install the package and ask for credentials in the process?</p>
| 0debug |
Override values of javacript objects in react : I have 2 javascript objects, the first is the default object, the second is the override for the first.
Object 1:
export const messages = {
'id': 'id',
'category': 'category',
'country': 'country',
'continent': 'continent',
'city': 'city',
'field': 'field',
'price': 'price',
'name': 'name',
};
Object 2:
window.messages['id'] = 'id';
window.messages['category'] = 'section';
window.messages['country'] = 'country';
This seems stupid but there is reason to this rediculousness
I am wondering if there is a way for me to override object 1 with object 2 without crushing over object 1. These are both external files.
I appologize for my bad spelling and description
Thank you ahead of time | 0debug |
what's the difference between factory and service? : <p>I am trying play with Angular factory and service. Anyone could tell me the difference between those two?</p>
<p>Does factory always returns a singleton, but service an instance?</p>
| 0debug |
static sPAPRPHBState *find_phb(sPAPREnvironment *spapr, uint64_t buid)
{
sPAPRPHBState *sphb;
QLIST_FOREACH(sphb, &spapr->phbs, list) {
if (sphb->buid != buid) {
continue;
}
return sphb;
}
return NULL;
}
| 1threat |
int qemu_set_fd_handler(int fd,
IOHandler *fd_read,
IOHandler *fd_write,
void *opaque)
{
static IOTrampoline fd_trampolines[FD_SETSIZE];
IOTrampoline *tramp = &fd_trampolines[fd];
if (tramp->tag != 0) {
g_io_channel_unref(tramp->chan);
g_source_remove(tramp->tag);
}
if (opaque) {
GIOCondition cond = 0;
tramp->fd_read = fd_read;
tramp->fd_write = fd_write;
tramp->opaque = opaque;
if (fd_read) {
cond |= G_IO_IN | G_IO_ERR;
}
if (fd_write) {
cond |= G_IO_OUT | G_IO_ERR;
}
tramp->chan = g_io_channel_unix_new(fd);
tramp->tag = g_io_add_watch(tramp->chan, cond, fd_trampoline, tramp);
}
return 0;
}
| 1threat |
static TCGv neon_load_reg(int reg, int pass)
{
TCGv tmp = new_tmp();
tcg_gen_ld_i32(tmp, cpu_env, neon_reg_offset(reg, pass));
return tmp;
}
| 1threat |
JavaScript speechSynthesis.speak() without user activation is no longer allowed since M71 : <p>I used speechSynthesis API in this way:</p>
<pre><code>speechSynthesis.speak(new SpeechSynthesisUtterance("hello world"));
</code></pre>
<p>But right now I get error after update Google Chrome:</p>
<blockquote>
<p>[Deprecation] speechSynthesis.speak() without user activation is no
longer allowed since M71, around December 2018. See
<a href="https://www.chromestatus.com/feature/5687444770914304" rel="noreferrer">https://www.chromestatus.com/feature/5687444770914304</a> for more details
speechSynthesisMessage @
application-2c16c437c2795ae01c0a8852e5f8da58dad99d6e17814a31f1eea19922c5ebd2.js:147</p>
</blockquote>
<p>How I can fix this issue and ask permission?</p>
| 0debug |
pandas .plot() x-axis tick frequency -- how can I show more ticks? : <p>I am plotting time series using pandas .plot() and want to see every month shown as an x-tick. </p>
<p>Here is the dataset structure
<a href="https://i.stack.imgur.com/8OOw4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8OOw4.png" alt="data set"></a></p>
<p>Here is the result of the .plot()</p>
<p><a href="https://i.stack.imgur.com/qRwNo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/qRwNo.png" alt="enter image description here"></a></p>
<p>I was trying to use examples from other posts and matplotlib <a href="http://matplotlib.org/examples/pylab_examples/date_demo2.html" rel="noreferrer">documentation</a> and do something like</p>
<pre><code>ax.xaxis.set_major_locator(
dates.MonthLocator(revenue_pivot.index, bymonthday=1,interval=1))
</code></pre>
<p>But that removed all the ticks :(</p>
<p>I also tried to pass <code>xticks = df.index</code>, but it has not changed anything.</p>
<p>What would be the rigth way to show more ticks on x-axis?</p>
| 0debug |
void qemu_set_log_filename(const char *filename)
{
char *pidstr;
g_free(logfilename);
pidstr = strstr(filename, "%");
if (pidstr) {
if (pidstr[1] != 'd' || strchr(pidstr + 2, '%')) {
error_report("Bad logfile format: %s", filename);
logfilename = NULL;
} else {
logfilename = g_strdup_printf(filename, getpid());
}
} else {
logfilename = g_strdup(filename);
}
qemu_log_close();
qemu_set_log(qemu_loglevel);
}
| 1threat |
Java turn HTML codes into normal characters : <p>I am making a trivia game that pulls the questions from <a href="https://opentdb.com/" rel="nofollow noreferrer">https://opentdb.com/</a> but some of the questions and answers don't come out correct in java for example one of the questions looks like this:</p>
<pre><code>What color is the &amp;quot;Ex&amp;quot; in FedEx Ground?
</code></pre>
<p>instaed of:</p>
<pre><code>What color is the "Ex" in FedEx Ground?
</code></pre>
<p>any idea how to fix this in Java, thanks.</p>
| 0debug |
static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
Error **errp)
{
const char *buf;
int bdrv_flags = 0;
int on_read_error, on_write_error;
BlockBackend *blk;
BlockDriverState *bs;
ThrottleConfig cfg;
int snapshot = 0;
Error *error = NULL;
QemuOpts *opts;
const char *id;
bool has_driver_specific_opts;
BlockdevDetectZeroesOptions detect_zeroes =
BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF;
const char *throttling_group = NULL;
id = qdict_get_try_str(bs_opts, "id");
opts = qemu_opts_create(&qemu_common_drive_opts, id, 1, &error);
if (error) {
error_propagate(errp, error);
goto err_no_opts;
}
qemu_opts_absorb_qdict(opts, bs_opts, &error);
if (error) {
error_propagate(errp, error);
goto early_err;
}
if (id) {
qdict_del(bs_opts, "id");
}
has_driver_specific_opts = !!qdict_size(bs_opts);
snapshot = qemu_opt_get_bool(opts, "snapshot", 0);
account_invalid = qemu_opt_get_bool(opts, "stats-account-invalid", true);
account_failed = qemu_opt_get_bool(opts, "stats-account-failed", true);
extract_common_blockdev_options(opts, &bdrv_flags, &throttling_group, &cfg,
&detect_zeroes, &error);
if (error) {
error_propagate(errp, error);
goto early_err;
}
if ((buf = qemu_opt_get(opts, "format")) != NULL) {
if (is_help_option(buf)) {
error_printf("Supported formats:");
bdrv_iterate_format(bdrv_format_print, NULL);
error_printf("\n");
goto early_err;
}
if (qdict_haskey(bs_opts, "driver")) {
error_setg(errp, "Cannot specify both 'driver' and 'format'");
goto early_err;
}
qdict_put(bs_opts, "driver", qstring_from_str(buf));
}
on_write_error = BLOCKDEV_ON_ERROR_ENOSPC;
if ((buf = qemu_opt_get(opts, "werror")) != NULL) {
on_write_error = parse_block_error_action(buf, 0, &error);
if (error) {
error_propagate(errp, error);
goto early_err;
}
}
on_read_error = BLOCKDEV_ON_ERROR_REPORT;
if ((buf = qemu_opt_get(opts, "rerror")) != NULL) {
on_read_error = parse_block_error_action(buf, 1, &error);
if (error) {
error_propagate(errp, error);
goto early_err;
}
}
if (snapshot) {
bdrv_flags &= ~BDRV_O_CACHE_MASK;
bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH);
}
if ((!file || !*file) && !has_driver_specific_opts) {
BlockBackendRootState *blk_rs;
blk = blk_new(qemu_opts_id(opts), errp);
if (!blk) {
goto early_err;
}
blk_rs = blk_get_root_state(blk);
blk_rs->open_flags = bdrv_flags;
blk_rs->read_only = !(bdrv_flags & BDRV_O_RDWR);
blk_rs->detect_zeroes = detect_zeroes;
if (throttle_enabled(&cfg)) {
if (!throttling_group) {
throttling_group = blk_name(blk);
}
blk_rs->throttle_group = g_strdup(throttling_group);
blk_rs->throttle_state = throttle_group_incref(throttling_group);
blk_rs->throttle_state->cfg = cfg;
}
QDECREF(bs_opts);
} else {
if (file && !*file) {
file = NULL;
}
blk = blk_new_open(qemu_opts_id(opts), file, NULL, bs_opts, bdrv_flags,
errp);
if (!blk) {
goto err_no_bs_opts;
}
bs = blk_bs(blk);
bs->detect_zeroes = detect_zeroes;
if (throttle_enabled(&cfg)) {
if (!throttling_group) {
throttling_group = blk_name(blk);
}
bdrv_io_limits_enable(bs, throttling_group);
bdrv_set_io_limits(bs, &cfg);
}
if (bdrv_key_required(bs)) {
autostart = 0;
}
block_acct_init(blk_get_stats(blk), account_invalid, account_failed);
}
blk_set_on_error(blk, on_read_error, on_write_error);
err_no_bs_opts:
qemu_opts_del(opts);
return blk;
early_err:
qemu_opts_del(opts);
err_no_opts:
QDECREF(bs_opts);
return NULL;
} | 1threat |
Unsafe, `noexcept` and no-overhead way of accessing `std::variant` : <p><a href="http://en.cppreference.com/w/cpp/utility/variant" rel="noreferrer"><code>std::variant</code></a> provides the following access functions:</p>
<ul>
<li><p><a href="http://en.cppreference.com/w/cpp/utility/variant/get_if" rel="noreferrer"><code>std::get_if</code></a>: take <em>pointer</em> to <code>variant</code>, return <em>pointer</em> to alternative. </p>
<pre><code>template <std::size_t I, typename... Ts>
auto* std::get_if(std::variant<Ts...>* pv) noexcept;
</code></pre>
<ul>
<li><blockquote>
<p>If <code>pv</code> is not a null pointer and <code>pv->index() == I</code>, returns a pointer to the value stored in the variant pointed to by <code>pv</code>. Otherwise, returns a null pointer value.</p>
</blockquote>
<p>This means that <code>get_if</code>'s implementation roughly looks like this:</p>
<pre><code>template <std::size_t I, typename... Ts>
auto* std::get_if(std::variant<Ts...>* pv) noexcept
{
if(pv == nullptr) return nullptr;
if(pv->index() != I) return nullptr;
return &(pv->real_get<I>());
}
</code></pre></li>
</ul></li>
<li><p><a href="http://en.cppreference.com/w/cpp/utility/variant/get" rel="noreferrer"><code>std::get</code></a>: take <em>reference</em> to <code>variant</code>, return <em>reference</em> to alternative, <em><code>throw</code></em> on invalid access.</p>
<pre><code>template <std::size_t I, typename... Ts>
auto& std::get(std::variant<Ts...>& v);
</code></pre>
<ul>
<li><blockquote>
<p>If <code>v.index() == I</code>, returns a reference to the value stored in <code>v</code>. Otherwise, throws <code>std::bad_variant_access</code>.</p>
</blockquote>
<p>This means that <code>get</code>'s implementation roughly looks like this:</p>
<pre><code>template <std::size_t I, typename... Ts>
auto& std::get(std::variant<Ts...>& v)
{
if(v.index() != I) throw std::bad_variant_access{};
return v.real_get<I>();
}
</code></pre></li>
</ul></li>
</ul>
<hr>
<p><strong>I want an unsafe access function that:</strong></p>
<ul>
<li><p>Is <code>noexcept</code>.</p></li>
<li><p>Takes a <em>reference</em> to a <code>variant</code>, avoiding any <code>pv == nullptr</code> check.</p></li>
<li><p>Has <em>undefined behavior</em> if <code>v.index() != I</code>.</p></li>
</ul>
<p>Why? Because there may be some situations where I am 100% sure that a particular <code>variant</code> instance contains a specific type in a code path. Also, it would be useful when writing generic code that already separately checked <code>v.index() != I</code> <em>(e.g. writing my own <code>visit</code>)</em>.</p>
<p>Example implementation:</p>
<pre><code>template <std::size_t I, typename... Ts>
auto& unsafe_get(std::variant<Ts...>& v)
{
return v.real_get<I>();
}
</code></pre>
<p><strong>Is there something like this in the standard?</strong> I couldn't find it. If not, <strong>is this possible to implement for <code>std::variant</code>, or do I need to roll out my own <code>variant</code> implementation?</strong></p>
| 0debug |
Does Microsoft OLE DB Provider for SQL Server support TLS 1.2 : <p>Our client recently upgraded from TLS 1.0 to TLS 1.2 and after this our software cannot connect with SQL server. It uses OLE DB provider for connecting to SQL server.
Below is the error which is returned from SQL server-</p>
<p>[DBNETLIB][ConnectionOpen SECDoClientHandshake()]SSL Security error
SQL State: 08001
SQL Error Number: 18</p>
<p>Could not find any useful information related to whether Microsoft OLE DB Provider for SQL Server support TLS 1.2 or not.</p>
<p>One of the links I found seems to suggest that it is not supported.
<a href="https://forums.iis.net/t/1233674.aspx?connecing+SQL+server+DB+issue+after+installingTLS1+2+in+SQL+srver+with+classic+asp+application+" rel="noreferrer">https://forums.iis.net/t/1233674.aspx?connecing+SQL+server+DB+issue+after+installingTLS1+2+in+SQL+srver+with+classic+asp+application+</a></p>
<p>Hence, wanted to check on stackoverflow in case anyone has any information on this.</p>
| 0debug |
How to get the key and value of ArrayList in c#? : <p>I have a array list which contain the objects with key value pair,but unable to get the key and value,here how the debugger look like:</p>
<p><a href="https://i.stack.imgur.com/b9pSv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b9pSv.png" alt="enter image description here"></a></p>
| 0debug |
Using SQLAlchemy models in and out of Flask : <p>I'm trying to build SQLAlchemy models that can be used in Flask and in other non-Flask services. I know that in order to use these objects in Flask I can use the Flask-SQLAlchemy module and build the models like this:</p>
<p>app_builder.py</p>
<pre><code>def create_app(config):
# Create a Flask app from the passed in settings
app = Flask('web_service')
app.config.from_object(config)
# Attach SQLAlchemy to the application
from database import db
db.init_app(app)
</code></pre>
<p>database.py</p>
<pre><code>from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class Job(db.Model):
__tablename__ = 'job'
job_id = db.Column(db.Integer, primary_key=True)
description = db.Column(db.String(256))
def __init__(self, description):
self.description = description
</code></pre>
<p>However it looks like doing this ties the models to using flask_sqlalchemy. I have another service that I would like to use these models in that don't use flask. Is there a way I can reuse these class definitions (maybe by changing db.Model) within a non-Flask specific context?</p>
| 0debug |
What is diference between Dynamic allocation and Static Allocation : What is diference between Dynamic allocation and Static Allocation
I can't undersntand that code!!
int arrA[20];
int* arrB = new int [20];
What is diference that code!
Why Dynamic allocation have array size? I can't understand that
int* arrB = new int [20];
Answer please!! Have a good time~ | 0debug |
Get values for the given key from multiple records in javascript : I have an array of objects as follows.
Arr = [
{id:1 val:5},{id:2 val:51}
]
I need to get the value when id = 2. How can I do it in javascript? | 0debug |
get warning must be used from main thread only Xcode 11 and app crashed : I have same code and Project
When I opened in Xcode 10.2 I **did not get any warning messages like "must be used from main thread"**
But When I opened in Xcode 11.2 I **get warning messages like "must be used from main thread" and app crashed**.
This thing (must be used from main thread) happens many place on different controller in Xcode 11.2 (not in Xcode 10.2)
[self.viewIndicator stopAnimating];
I also got warning message "must be used from main thread" when I stopped UIActivityIndicatorView.
I do not understand why did this happen?.
My Project run absolutely fine in Xcode 10.2 but in Xcode 11.2 my Project get warning messages like "must be used from main thread" and app crashed**.
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/gjbIJ.png | 0debug |
static void ppc_core99_init(MachineState *machine)
{
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;
const char *boot_device = machine->boot_order;
PowerPCCPU *cpu = NULL;
CPUPPCState *env = NULL;
char *filename;
qemu_irq *pic, **openpic_irqs;
MemoryRegion *isa = g_new(MemoryRegion, 1);
MemoryRegion *unin_memory = g_new(MemoryRegion, 1);
MemoryRegion *unin2_memory = g_new(MemoryRegion, 1);
int linux_boot, i, j, k;
MemoryRegion *ram = g_new(MemoryRegion, 1), *bios = g_new(MemoryRegion, 1);
hwaddr kernel_base, initrd_base, cmdline_base = 0;
long kernel_size, initrd_size;
PCIBus *pci_bus;
PCIDevice *macio;
MACIOIDEState *macio_ide;
BusState *adb_bus;
MacIONVRAMState *nvr;
int bios_size;
MemoryRegion *pic_mem, *escc_mem;
MemoryRegion *escc_bar = g_new(MemoryRegion, 1);
int ppc_boot_device;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
void *fw_cfg;
int machine_arch;
SysBusDevice *s;
DeviceState *dev;
int *token = g_new(int, 1);
hwaddr nvram_addr = 0xFFF04000;
uint64_t tbfreq;
linux_boot = (kernel_filename != NULL);
if (cpu_model == NULL)
#ifdef TARGET_PPC64
cpu_model = "970fx";
#else
cpu_model = "G4";
#endif
for (i = 0; i < smp_cpus; i++) {
cpu = cpu_ppc_init(cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to find PowerPC CPU definition\n");
exit(1);
}
env = &cpu->env;
cpu_ppc_tb_init(env, TBFREQ);
qemu_register_reset(ppc_core99_reset, cpu);
}
memory_region_allocate_system_memory(ram, NULL, "ppc_core99.ram", ram_size);
memory_region_add_subregion(get_system_memory(), 0, ram);
memory_region_init_ram(bios, NULL, "ppc_core99.bios", BIOS_SIZE,
&error_abort);
vmstate_register_ram_global(bios);
if (bios_name == NULL)
bios_name = PROM_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
memory_region_set_readonly(bios, true);
memory_region_add_subregion(get_system_memory(), PROM_ADDR, bios);
if (filename) {
bios_size = load_elf(filename, NULL, NULL, NULL,
NULL, NULL, 1, ELF_MACHINE, 0);
g_free(filename);
} else {
bios_size = -1;
}
if (bios_size < 0 || bios_size > BIOS_SIZE) {
hw_error("qemu: could not load PowerPC bios '%s'\n", bios_name);
exit(1);
}
if (linux_boot) {
uint64_t lowaddr = 0;
int bswap_needed;
#ifdef BSWAP_NEEDED
bswap_needed = 1;
#else
bswap_needed = 0;
#endif
kernel_base = KERNEL_LOAD_ADDR;
kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL,
NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0);
if (kernel_size < 0)
kernel_size = load_aout(kernel_filename, kernel_base,
ram_size - kernel_base, bswap_needed,
TARGET_PAGE_SIZE);
if (kernel_size < 0)
kernel_size = load_image_targphys(kernel_filename,
kernel_base,
ram_size - kernel_base);
if (kernel_size < 0) {
hw_error("qemu: could not load kernel '%s'\n", kernel_filename);
exit(1);
}
if (initrd_filename) {
initrd_base = round_page(kernel_base + kernel_size + KERNEL_GAP);
initrd_size = load_image_targphys(initrd_filename, initrd_base,
ram_size - initrd_base);
if (initrd_size < 0) {
hw_error("qemu: could not load initial ram disk '%s'\n",
initrd_filename);
exit(1);
}
cmdline_base = round_page(initrd_base + initrd_size);
} else {
initrd_base = 0;
initrd_size = 0;
cmdline_base = round_page(kernel_base + kernel_size + KERNEL_GAP);
}
ppc_boot_device = 'm';
} else {
kernel_base = 0;
kernel_size = 0;
initrd_base = 0;
initrd_size = 0;
ppc_boot_device = '\0';
for (i = 0; boot_device[i] != '\0'; i++) {
if (boot_device[i] >= 'c' && boot_device[i] <= 'f') {
ppc_boot_device = boot_device[i];
break;
}
}
if (ppc_boot_device == '\0') {
fprintf(stderr, "No valid boot device for Mac99 machine\n");
exit(1);
}
}
memory_region_init_alias(isa, NULL, "isa_mmio",
get_system_io(), 0, 0x00800000);
memory_region_add_subregion(get_system_memory(), 0xf2000000, isa);
memory_region_init_io(unin_memory, NULL, &unin_ops, token, "unin", 0x1000);
memory_region_add_subregion(get_system_memory(), 0xf8000000, unin_memory);
memory_region_init_io(unin2_memory, NULL, &unin_ops, token, "unin", 0x1000);
memory_region_add_subregion(get_system_memory(), 0xf3000000, unin2_memory);
openpic_irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *));
openpic_irqs[0] =
g_malloc0(smp_cpus * sizeof(qemu_irq) * OPENPIC_OUTPUT_NB);
for (i = 0; i < smp_cpus; i++) {
switch (PPC_INPUT(env)) {
case PPC_FLAGS_INPUT_6xx:
openpic_irqs[i] = openpic_irqs[0] + (i * OPENPIC_OUTPUT_NB);
openpic_irqs[i][OPENPIC_OUTPUT_INT] =
((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT];
openpic_irqs[i][OPENPIC_OUTPUT_CINT] =
((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT];
openpic_irqs[i][OPENPIC_OUTPUT_MCK] =
((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_MCP];
openpic_irqs[i][OPENPIC_OUTPUT_DEBUG] = NULL;
openpic_irqs[i][OPENPIC_OUTPUT_RESET] =
((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_HRESET];
break;
#if defined(TARGET_PPC64)
case PPC_FLAGS_INPUT_970:
openpic_irqs[i] = openpic_irqs[0] + (i * OPENPIC_OUTPUT_NB);
openpic_irqs[i][OPENPIC_OUTPUT_INT] =
((qemu_irq *)env->irq_inputs)[PPC970_INPUT_INT];
openpic_irqs[i][OPENPIC_OUTPUT_CINT] =
((qemu_irq *)env->irq_inputs)[PPC970_INPUT_INT];
openpic_irqs[i][OPENPIC_OUTPUT_MCK] =
((qemu_irq *)env->irq_inputs)[PPC970_INPUT_MCP];
openpic_irqs[i][OPENPIC_OUTPUT_DEBUG] = NULL;
openpic_irqs[i][OPENPIC_OUTPUT_RESET] =
((qemu_irq *)env->irq_inputs)[PPC970_INPUT_HRESET];
break;
#endif
default:
hw_error("Bus model not supported on mac99 machine\n");
exit(1);
}
}
pic = g_new0(qemu_irq, 64);
dev = qdev_create(NULL, TYPE_OPENPIC);
qdev_prop_set_uint32(dev, "model", OPENPIC_MODEL_RAVEN);
qdev_init_nofail(dev);
s = SYS_BUS_DEVICE(dev);
pic_mem = s->mmio[0].memory;
k = 0;
for (i = 0; i < smp_cpus; i++) {
for (j = 0; j < OPENPIC_OUTPUT_NB; j++) {
sysbus_connect_irq(s, k++, openpic_irqs[i][j]);
}
}
for (i = 0; i < 64; i++) {
pic[i] = qdev_get_gpio_in(dev, i);
}
if (PPC_INPUT(env) == PPC_FLAGS_INPUT_970) {
pci_bus = pci_pmac_u3_init(pic, get_system_memory(), get_system_io());
machine_arch = ARCH_MAC99_U3;
machine->usb |= defaults_enabled();
} else {
pci_bus = pci_pmac_init(pic, get_system_memory(), get_system_io());
machine_arch = ARCH_MAC99;
}
if (kvm_enabled()) {
tbfreq = kvmppc_get_tbfreq();
} else {
tbfreq = TBFREQ;
}
escc_mem = escc_init(0, pic[0x25], pic[0x24],
serial_hds[0], serial_hds[1], ESCC_CLOCK, 4);
memory_region_init_alias(escc_bar, NULL, "escc-bar",
escc_mem, 0, memory_region_size(escc_mem));
macio = pci_create(pci_bus, -1, TYPE_NEWWORLD_MACIO);
dev = DEVICE(macio);
qdev_connect_gpio_out(dev, 0, pic[0x19]);
qdev_connect_gpio_out(dev, 1, pic[0x0d]);
qdev_connect_gpio_out(dev, 2, pic[0x02]);
qdev_connect_gpio_out(dev, 3, pic[0x0e]);
qdev_connect_gpio_out(dev, 4, pic[0x03]);
qdev_prop_set_uint64(dev, "frequency", tbfreq);
macio_init(macio, pic_mem, escc_bar);
ide_drive_get(hd, ARRAY_SIZE(hd));
macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio),
"ide[0]"));
macio_ide_init_drives(macio_ide, hd);
macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio),
"ide[1]"));
macio_ide_init_drives(macio_ide, &hd[MAX_IDE_DEVS]);
dev = DEVICE(object_resolve_path_component(OBJECT(macio), "cuda"));
adb_bus = qdev_get_child_bus(dev, "adb.0");
dev = qdev_create(adb_bus, TYPE_ADB_KEYBOARD);
qdev_init_nofail(dev);
dev = qdev_create(adb_bus, TYPE_ADB_MOUSE);
qdev_init_nofail(dev);
if (machine->usb) {
pci_create_simple(pci_bus, -1, "pci-ohci");
if (machine_arch == ARCH_MAC99_U3) {
USBBus *usb_bus = usb_bus_find(-1);
usb_create_simple(usb_bus, "usb-kbd");
usb_create_simple(usb_bus, "usb-mouse");
}
}
pci_vga_init(pci_bus);
if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8) {
graphic_depth = 15;
}
for (i = 0; i < nb_nics; i++) {
pci_nic_init_nofail(&nd_table[i], pci_bus, "ne2k_pci", NULL);
}
#ifdef CONFIG_KVM
if (kvm_enabled() && getpagesize() > 4096) {
nvram_addr = 0xFFE00000;
}
#endif
dev = qdev_create(NULL, TYPE_MACIO_NVRAM);
qdev_prop_set_uint32(dev, "size", 0x2000);
qdev_prop_set_uint32(dev, "it_shift", 1);
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, nvram_addr);
nvr = MACIO_NVRAM(dev);
pmac_format_nvram_partition(nvr, 0x2000);
fw_cfg = fw_cfg_init_mem(CFG_ADDR, CFG_ADDR + 2);
fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, machine_arch);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
if (kernel_cmdline) {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, cmdline_base);
pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE, kernel_cmdline);
} else {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
}
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_base);
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size);
fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ppc_boot_device);
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width);
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height);
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled());
if (kvm_enabled()) {
#ifdef CONFIG_KVM
uint8_t *hypercall;
hypercall = g_malloc(16);
kvmppc_get_hypercall(env, hypercall, 16);
fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid());
#endif
}
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, tbfreq);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_CLOCKFREQ, CLOCKFREQ);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_BUSFREQ, BUSFREQ);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_NVRAM_ADDR, nvram_addr);
qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
}
| 1threat |
Batch: Count occurences of string (from txt-file) in text-file and export to csv or txt-file : I have used different sources here on stackoverflow, for example [this][1], to clean my alarm file (data.txt) from spam and to extract the unique occurences to this file (unik.txt). The next step, where i am stuck, is to use unik.txt and count the number of occurences in data.txt, and to export the string and count to a text or csv-file.
As you may have guessed it is a way of creating an alarm statistic. I have considered using other methods/languages but will first want to try this way.
I have read [this][2] post also without coming to a close.
I will very much appreciate any assistance.
Cheers // DAN
[1]: https://stackoverflow.com/questions/20246765/windows-batch-scripting-collect-unique-occurences-of-a-string-in-a-file
[2]: https://stackoverflow.com/questions/9307187/how-to-find-the-number-of-occurrences-of-a-string-in-file-using-windows-command | 0debug |
Flutter How to create Card with background Image? : <p>I'm trying to create a Card with an Image as a background. The problem is, the Image overflows the Card, so the Corners of the don't show up.</p>
<p>I need to either set the Image as a background of the card or set the cards overflow behavior to no overflow. But I couldn't find any properties for that.</p>
<p>Here is my Card:</p>
<pre><code>Widget _buildProgrammCard() {
return Container(
height: 250,
child: Card(
child: Image.asset(
'assets/push.jpg',
fit: BoxFit.cover,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
elevation: 5,
margin: EdgeInsets.all(10),
),
);
</code></pre>
<p>And it looks like this:</p>
<p><a href="https://i.stack.imgur.com/P9eod.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/P9eod.jpg" alt="enter image description here"></a></p>
<p><a href="https://i.stack.imgur.com/NNSpf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NNSpf.png" alt="enter image description here"></a></p>
| 0debug |
static void define_aarch64_debug_regs(ARMCPU *cpu)
{
int i;
for (i = 0; i < 16; i++) {
ARMCPRegInfo dbgregs[] = {
{ .name = "DBGBVR", .state = ARM_CP_STATE_AA64,
.opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 4,
.access = PL1_RW,
.fieldoffset = offsetof(CPUARMState, cp15.dbgbvr[i]) },
{ .name = "DBGBCR", .state = ARM_CP_STATE_AA64,
.opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 5,
.access = PL1_RW,
.fieldoffset = offsetof(CPUARMState, cp15.dbgbcr[i]) },
{ .name = "DBGWVR", .state = ARM_CP_STATE_AA64,
.opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 6,
.access = PL1_RW,
.fieldoffset = offsetof(CPUARMState, cp15.dbgwvr[i]) },
{ .name = "DBGWCR", .state = ARM_CP_STATE_AA64,
.opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 7,
.access = PL1_RW,
.fieldoffset = offsetof(CPUARMState, cp15.dbgwcr[i]) },
REGINFO_SENTINEL
};
define_arm_cp_regs(cpu, dbgregs);
}
}
| 1threat |
Golang cant get body from request.GetBody() : <p>I try to read the request body via request.GetBody(), since I need to read the same request body more than once, but I always get the error below. I checked if the req.body is empty, but it is not. I cant even call req.GetBody(). My Go version is 1.8.1. </p>
<pre><code> func read(res http.ResponseWriter, req *http.Request) {
_, err := req.GetBody()
if err != nil {
res.Write([]byte(err.Error()))
return
}
}
</code></pre>
<p>Error:</p>
<pre><code>http: panic serving [::1]:53174: runtime error: invalid memory address or nil pointer dereference
</code></pre>
| 0debug |
static inline void RENAME(rgb15to16)(const uint8_t *src,uint8_t *dst,unsigned src_size)
{
register const uint8_t* s=src;
register uint8_t* d=dst;
register const uint8_t *end;
const uint8_t *mm_end;
end = s + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*s));
__asm __volatile("movq %0, %%mm4"::"m"(mask15s));
mm_end = end - 15;
while(s<mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movq %1, %%mm0\n\t"
"movq 8%1, %%mm2\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm2, %%mm3\n\t"
"pand %%mm4, %%mm0\n\t"
"pand %%mm4, %%mm2\n\t"
"paddw %%mm1, %%mm0\n\t"
"paddw %%mm3, %%mm2\n\t"
MOVNTQ" %%mm0, %0\n\t"
MOVNTQ" %%mm2, 8%0"
:"=m"(*d)
:"m"(*s)
);
d+=16;
s+=16;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
mm_end = end - 3;
while(s < mm_end)
{
register unsigned x= *((uint32_t *)s);
*((uint32_t *)d) = (x&0x7FFF7FFF) + (x&0x7FE07FE0);
d+=4;
s+=4;
}
if(s < end)
{
register unsigned short x= *((uint16_t *)s);
*((uint16_t *)d) = (x&0x7FFF) + (x&0x7FE0);
}
}
| 1threat |
How can I easily switch between PHP versions on Mac OSX? : <p>I would like to test my application on PHP 5.3 up to PHP 7.0.</p>
<p>Where and how can I install the versions and how can I switch them by running a small script?</p>
| 0debug |
Meaning of ${project.basedir} in pom.xml : <p>What is the meaning of </p>
<pre><code><directory>${project.basedir}</directory>
</code></pre>
<p>and</p>
<pre><code>${project.build.directory}
</code></pre>
<p>in pom.xml</p>
| 0debug |
JavaFX + FXML: Image dissapeared after converting project to Maven : I have a small JavaFX app. Everything looked fine, and was working fine. Suddently, I wanted to convert this project to a Maven project (I wanted to add some external dependencies and use them in the app).
In Eclipse I have right-clicked the project, selected `Configure` and then `Convert to Maven project...`. Everything went fine, until I have build and run the application. The whole app is working perfectly, but there was a logo in the app window, and after converting the project to Maven - the image has dissapeared.
I am using JavaFX with FXML and SceneBuilder.
In the `RootLayout.fxml` file, there is an entry:
<ImageView fitHeight="150.0" fitWidth="200.0" layoutX="225.0" layoutY="50.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../../../../../../resources/images/nbtc.jpg" />
</image>
</ImageView>
It is still visible in `SceneBuilder` after conversion to Maven, but it has disappeared from the app after running it.
Here is the folder structure:
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/afqJi.png | 0debug |
How to edit text in a div? : <p>So I have a navigation bar and when I hover over it, the background color turns white. I also want the text to turn black simultaneously. How to I make it do this? This is my css code:</p>
<pre><code>.row:hover {
background-color: #FFFFFF;
color: black;
transition: all 0.5s ease-in;
}
</code></pre>
| 0debug |
how to pass usb scanned bar code to the window service? : I am using matrologic usb scanner , once you scan the barcode it needs a focused (text field ) where it will past the scanned code , I want to capture that scanned code using my window service which will take the code and sends it to the data base when record comes back I want to intitializ my application for populating the record details,
My client donot want my win form application to be visible on screen until the barcode is scanned and the details is reached | 0debug |
How to create brick pattern in WPF in code? : <p>This question is similar to others, but my research has not uncovered the answer I seek. I am trying to fill a rectangle with a brick pattern. I understand there is not a HatchBrush in WPF and if there was perhaps I would do this: <code>HatchBrush brush = new HatchBrush(HatchStyle.DiagonalBrick,System.Drawing.Color.Black);</code> But since there is not I am using a DrawingBrush as follows, which fills the rectangle with a darkblue solid color. Where do I specify the DiagonalBrick?</p>
<pre><code>Rectangle fillRect = new Rectangle();
//Try to fill fillRect with a pattern
Rect aRect = new Rect();
aRect.Width = fillRect.Width;
aRect.Height = fillRect.Height;
GeometryGroup rectangle = new GeometryGroup();
GeometryDrawing geomDrawing = new GeometryDrawing(Brushes.DarkBlue,null, rectangle);
DrawingBrush drawingBrush = new DrawingBrush();
rectangle.Children.Add(new RectangleGeometry(aRect, 0, 0));
geomDrawing.Geometry = rectangle;
drawingBrush.Drawing = geomDrawing;
fillRect.Fill = drawingBrush;
</code></pre>
| 0debug |
document.location = 'http://evil.com?username=' + user_input; | 1threat |
Typescript access static attribute of generic type : <p>I have an abstract class <code>Model</code> with a static attribute and another generic class <code>Controller<T extends Model></code>. I want to access the static attribute of Model in an instance of Controller. That should like this:</p>
<pre><code>abstract class Model{
static hasStatus: boolean = false;
}
class MyModel extends Model{
static hasStatus = true;
}
class Controller<T extends Model>{
constructor(){
if(T.hasStatus)...
}
}
</code></pre>
<p>But TS says <code>'T' only refers to a type, but is being used as a value here.</code></p>
<p>Is there an easy way to achieve this? Or should i subclass <code>Controller</code> for each Heritage of <code>Model</code> and implement a method to retrieve the value? </p>
| 0debug |
static int read_filter_params(MLPDecodeContext *m, GetBitContext *gbp,
unsigned int substr, unsigned int channel,
unsigned int filter)
{
SubStream *s = &m->substream[substr];
FilterParams *fp = &s->channel_params[channel].filter_params[filter];
const int max_order = filter ? MAX_IIR_ORDER : MAX_FIR_ORDER;
const char fchar = filter ? 'I' : 'F';
int i, order;
av_assert0(filter < 2);
if (m->filter_changed[channel][filter]++ > 1) {
av_log(m->avctx, AV_LOG_ERROR, "Filters may change only once per access unit.\n");
return AVERROR_INVALIDDATA;
}
order = get_bits(gbp, 4);
if (order > max_order) {
av_log(m->avctx, AV_LOG_ERROR,
"%cIR filter order %d is greater than maximum %d.\n",
fchar, order, max_order);
return AVERROR_INVALIDDATA;
}
fp->order = order;
if (order > 0) {
int32_t *fcoeff = s->channel_params[channel].coeff[filter];
int coeff_bits, coeff_shift;
fp->shift = get_bits(gbp, 4);
coeff_bits = get_bits(gbp, 5);
coeff_shift = get_bits(gbp, 3);
if (coeff_bits < 1 || coeff_bits > 16) {
av_log(m->avctx, AV_LOG_ERROR,
"%cIR filter coeff_bits must be between 1 and 16.\n",
fchar);
return AVERROR_INVALIDDATA;
}
if (coeff_bits + coeff_shift > 16) {
av_log(m->avctx, AV_LOG_ERROR,
"Sum of coeff_bits and coeff_shift for %cIR filter must be 16 or less.\n",
fchar);
return AVERROR_INVALIDDATA;
}
for (i = 0; i < order; i++)
fcoeff[i] = get_sbits(gbp, coeff_bits) * (1 << coeff_shift);
if (get_bits1(gbp)) {
int state_bits, state_shift;
if (filter == FIR) {
av_log(m->avctx, AV_LOG_ERROR,
"FIR filter has state data specified.\n");
return AVERROR_INVALIDDATA;
}
state_bits = get_bits(gbp, 4);
state_shift = get_bits(gbp, 4);
for (i = 0; i < order; i++)
fp->state[i] = state_bits ? get_sbits(gbp, state_bits) << state_shift : 0;
}
}
return 0;
}
| 1threat |
How to build a docker container with nix? : <p>I have a Nix package I'd like to bundle up into a docker container.</p>
<p>Specifically, I want to use Nix as a more expressive alternative to a <code>Dockerfile</code> to have faster (non-linear) image builds.</p>
<p>I've found documentation on <a href="https://nixos.org/nixpkgs/manual/#ssec-pkgs-dockerTools-buildImage" rel="noreferrer"><code>dockerTools.buildImage</code></a> but I'd like to have a minimal working example, and I'd also like to know what ends up being in the docker container.</p>
| 0debug |
static void *bochs_bios_init(void)
{
void *fw_cfg;
uint8_t *smbios_table;
size_t smbios_len;
uint64_t *numa_fw_cfg;
int i, j;
register_ioport_write(0x400, 1, 2, bochs_bios_write, NULL);
register_ioport_write(0x401, 1, 2, bochs_bios_write, NULL);
register_ioport_write(0x402, 1, 1, bochs_bios_write, NULL);
register_ioport_write(0x403, 1, 1, bochs_bios_write, NULL);
register_ioport_write(0x8900, 1, 1, bochs_bios_write, NULL);
register_ioport_write(0x501, 1, 1, bochs_bios_write, NULL);
register_ioport_write(0x501, 1, 2, bochs_bios_write, NULL);
register_ioport_write(0x502, 1, 2, bochs_bios_write, NULL);
register_ioport_write(0x500, 1, 1, bochs_bios_write, NULL);
register_ioport_write(0x503, 1, 1, bochs_bios_write, NULL);
fw_cfg = fw_cfg_init(BIOS_CFG_IOPORT, BIOS_CFG_IOPORT + 1, 0, 0);
fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
fw_cfg_add_bytes(fw_cfg, FW_CFG_ACPI_TABLES, (uint8_t *)acpi_tables,
acpi_tables_len);
fw_cfg_add_bytes(fw_cfg, FW_CFG_IRQ0_OVERRIDE, &irq0override, 1);
smbios_table = smbios_get_table(&smbios_len);
if (smbios_table)
fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES,
smbios_table, smbios_len);
fw_cfg_add_bytes(fw_cfg, FW_CFG_E820_TABLE, (uint8_t *)&e820_table,
sizeof(struct e820_table));
fw_cfg_add_bytes(fw_cfg, FW_CFG_HPET, (uint8_t *)&hpet_cfg,
sizeof(struct hpet_fw_config));
numa_fw_cfg = g_malloc0((1 + max_cpus + nb_numa_nodes) * 8);
numa_fw_cfg[0] = cpu_to_le64(nb_numa_nodes);
for (i = 0; i < max_cpus; i++) {
for (j = 0; j < nb_numa_nodes; j++) {
if (node_cpumask[j] & (1 << i)) {
numa_fw_cfg[i + 1] = cpu_to_le64(j);
break;
}
}
}
for (i = 0; i < nb_numa_nodes; i++) {
numa_fw_cfg[max_cpus + 1 + i] = cpu_to_le64(node_mem[i]);
}
fw_cfg_add_bytes(fw_cfg, FW_CFG_NUMA, (uint8_t *)numa_fw_cfg,
(1 + max_cpus + nb_numa_nodes) * 8);
return fw_cfg;
}
| 1threat |
What is the equivalent of Math.Round() with MidpointRounding.AwayFromZero in Delphi? : <p>How do I use c# similar <code>Math.Round</code> with <code>MidpointRounding.AwayFromZero</code> in Delphi?</p>
<p>What will be the equivalent of:</p>
<pre><code>double d = 2.125;
Console.WriteLine(Math.Round(d, 2, MidpointRounding.AwayFromZero));
</code></pre>
<p>Output: <code>2.13</code></p>
<p>In Delphi?</p>
| 0debug |
Objective-c Change date format : I have a date like so:
22-04-2016 8:00:00 AM
how do I change the format to `04-22-2016 8:00:00 AM`
I have tried the following:
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"MM-dd-yyyy"];
NSLog(@"%@", [dateFormat dateFromString:[cell scheduledDate]]);
but this returns null :( how can I change the format of this string? `[cell scheduledDate]` is a string. | 0debug |
WhY in C programming ,perc value show 0 as output? : <p>perc=(sum/total)*100;</p>
<p>i've been trying to put this in the code in cprogramming,but output for this part is showing 0,,,Why is this happening and what else should I do in these types of scenerios?</p>
| 0debug |
av_cold void ff_psy_preprocess_end(struct FFPsyPreprocessContext *ctx)
{
int i;
ff_iir_filter_free_coeffs(ctx->fcoeffs);
if (ctx->fstate)
for (i = 0; i < ctx->avctx->channels; i++)
ff_iir_filter_free_state(ctx->fstate[i]);
av_freep(&ctx->fstate);
} | 1threat |
Is it recommended to use Database as a container in Production environment? : <p>Assuming we are using a micro service architecture for a product and we decide to use 'Database per service' model, and deploy in cloud servers by provider like AWS.
It is convenient to have databases running as a container for development and test environments. </p>
<p>But can same be implemented for Production environment! If so, how safe it would be?
Or is it proper to go with cloud solution as AWS RDS-DB instead!!</p>
| 0debug |
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
{
int64_t offset1;
int64_t pos;
int force = whence & AVSEEK_FORCE;
whence &= ~AVSEEK_FORCE;
if(!s)
return AVERROR(EINVAL);
pos = s->pos - (s->write_flag ? 0 : (s->buf_end - s->buffer));
if (whence != SEEK_CUR && whence != SEEK_SET)
return AVERROR(EINVAL);
if (whence == SEEK_CUR) {
offset1 = pos + (s->buf_ptr - s->buffer);
if (offset == 0)
return offset1;
offset += offset1;
}
offset1 = offset - pos;
if (!s->must_flush &&
offset1 >= 0 && offset1 < (s->buf_end - s->buffer)) {
s->buf_ptr = s->buffer + offset1;
} else if ((!s->seekable ||
offset1 <= s->buf_end + SHORT_SEEK_THRESHOLD - s->buffer) &&
!s->write_flag && offset1 >= 0 &&
(whence != SEEK_END || force)) {
while(s->pos < offset && !s->eof_reached)
fill_buffer(s);
if (s->eof_reached)
return AVERROR_EOF;
s->buf_ptr = s->buf_end + offset - s->pos;
} else {
int64_t res;
if (s->write_flag) {
flush_buffer(s);
s->must_flush = 1;
}
if (!s->seek)
return AVERROR(EPIPE);
if ((res = s->seek(s->opaque, offset, SEEK_SET)) < 0)
return res;
if (!s->write_flag)
s->buf_end = s->buffer;
s->buf_ptr = s->buffer;
s->pos = offset;
}
s->eof_reached = 0;
return offset;
}
| 1threat |
How to use template parameters in page content in hugo : <p>Is it possible to use template parameters in the content of a post with Hugo? E.g. if I have the following parameters:</p>
<pre><code>[params.company]
name = "My Company"
</code></pre>
<p>Can I then do something like this in the content of a post?</p>
<pre><code>This site, {{ .Site.BaseURL }} is operated by {{ params.company.name }}
</code></pre>
<p>I've tried, but it's literally printing the above instead of interpolating the variables.</p>
| 0debug |
Macro for searching every cell in a particular column whether it ends with particular words defined in array : For instance, I want to see whether each cell from B10 till the end of the B colomn is ending with "@yahoo.com", "gmail.com", "rediff.com". If not then, it should color that particular cell | 0debug |
long do_rt_sigreturn(CPUTLGState *env)
{
abi_ulong frame_addr = env->regs[TILEGX_R_SP];
struct target_rt_sigframe *frame;
sigset_t set;
trace_user_do_rt_sigreturn(env, frame_addr);
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
goto badframe;
}
target_to_host_sigset(&set, &frame->uc.tuc_sigmask);
do_sigprocmask(SIG_SETMASK, &set, NULL);
restore_sigcontext(env, &frame->uc.tuc_mcontext);
if (do_sigaltstack(frame_addr + offsetof(struct target_rt_sigframe,
uc.tuc_stack),
0, env->regs[TILEGX_R_SP]) == -EFAULT) {
goto badframe;
}
unlock_user_struct(frame, frame_addr, 0);
return env->regs[TILEGX_R_RE];
badframe:
unlock_user_struct(frame, frame_addr, 0);
force_sig(TARGET_SIGSEGV);
}
| 1threat |
What is Event Listener in Selenium Webdriver [ java ] : <p>I am Novice to Selenium web driver and java and how to implement in Selenium Script </p>
| 0debug |
lqspi_read(void *opaque, hwaddr addr, unsigned int size)
{
int i;
XilinxQSPIPS *q = opaque;
XilinxSPIPS *s = opaque;
uint32_t ret;
if (addr >= q->lqspi_cached_addr &&
addr <= q->lqspi_cached_addr + LQSPI_CACHE_SIZE - 4) {
ret = q->lqspi_buf[(addr - q->lqspi_cached_addr) >> 2];
DB_PRINT("addr: %08x, data: %08x\n", (unsigned)addr, (unsigned)ret);
return ret;
} else {
int flash_addr = (addr / num_effective_busses(s));
int slave = flash_addr >> LQSPI_ADDRESS_BITS;
int cache_entry = 0;
DB_PRINT("config reg status: %08x\n", s->regs[R_LQSPI_CFG]);
fifo8_reset(&s->tx_fifo);
fifo8_reset(&s->rx_fifo);
s->regs[R_CONFIG] &= ~CS;
s->regs[R_CONFIG] |= ((~(1 << slave) << CS_SHIFT) & CS) | MANUAL_CS;
xilinx_spips_update_cs_lines(s);
DB_PRINT("pushing read instruction: %02x\n",
(uint8_t)(s->regs[R_LQSPI_CFG] & LQSPI_CFG_INST_CODE));
fifo8_push(&s->tx_fifo, s->regs[R_LQSPI_CFG] & LQSPI_CFG_INST_CODE);
DB_PRINT("pushing read address %06x\n", flash_addr);
fifo8_push(&s->tx_fifo, (uint8_t)(flash_addr >> 16));
fifo8_push(&s->tx_fifo, (uint8_t)(flash_addr >> 8));
fifo8_push(&s->tx_fifo, (uint8_t)flash_addr);
if (s->regs[R_LQSPI_CFG] & LQSPI_CFG_MODE_EN) {
fifo8_push(&s->tx_fifo, extract32(s->regs[R_LQSPI_CFG],
LQSPI_CFG_MODE_SHIFT,
LQSPI_CFG_MODE_WIDTH));
}
for (i = 0; i < (extract32(s->regs[R_LQSPI_CFG], LQSPI_CFG_DUMMY_SHIFT,
LQSPI_CFG_DUMMY_WIDTH)); ++i) {
DB_PRINT("pushing dummy byte\n");
fifo8_push(&s->tx_fifo, 0);
}
xilinx_spips_update_cs_lines(s);
xilinx_spips_flush_txfifo(s);
fifo8_reset(&s->rx_fifo);
DB_PRINT("starting QSPI data read\n");
for (i = 0; i < LQSPI_CACHE_SIZE / 4; ++i) {
tx_data_bytes(s, 0, 4);
xilinx_spips_flush_txfifo(s);
rx_data_bytes(s, &q->lqspi_buf[cache_entry], 4);
cache_entry++;
}
xilinx_spips_update_cs_lines(s);
s->regs[R_CONFIG] |= CS;
xilinx_spips_update_cs_lines(s);
q->lqspi_cached_addr = addr;
return lqspi_read(opaque, addr, size);
}
}
| 1threat |
static void ac3_decode_transform_coeffs_ch(AC3DecodeContext *s, int ch_index, mant_groups *m)
{
int start_freq = s->start_freq[ch_index];
int end_freq = s->end_freq[ch_index];
uint8_t *baps = s->bap[ch_index];
int8_t *exps = s->dexps[ch_index];
int32_t *coeffs = s->fixed_coeffs[ch_index];
int dither = (ch_index == CPL_CH) || s->dither_flag[ch_index];
GetBitContext *gbc = &s->gbc;
int freq;
for (freq = start_freq; freq < end_freq; freq++) {
int bap = baps[freq];
int mantissa;
switch (bap) {
case 0:
if (dither)
mantissa = (((av_lfg_get(&s->dith_state)>>8)*181)>>8) - 5931008;
else
mantissa = 0;
break;
case 1:
if (m->b1) {
m->b1--;
mantissa = m->b1_mant[m->b1];
} else {
int bits = get_bits(gbc, 5);
mantissa = b1_mantissas[bits][0];
m->b1_mant[1] = b1_mantissas[bits][1];
m->b1_mant[0] = b1_mantissas[bits][2];
m->b1 = 2;
break;
case 2:
if (m->b2) {
m->b2--;
mantissa = m->b2_mant[m->b2];
} else {
int bits = get_bits(gbc, 7);
mantissa = b2_mantissas[bits][0];
m->b2_mant[1] = b2_mantissas[bits][1];
m->b2_mant[0] = b2_mantissas[bits][2];
m->b2 = 2;
break;
case 3:
mantissa = b3_mantissas[get_bits(gbc, 3)];
break;
case 4:
if (m->b4) {
m->b4 = 0;
mantissa = m->b4_mant;
} else {
int bits = get_bits(gbc, 7);
mantissa = b4_mantissas[bits][0];
m->b4_mant = b4_mantissas[bits][1];
m->b4 = 1;
break;
case 5:
mantissa = b5_mantissas[get_bits(gbc, 4)];
break;
default:
mantissa = get_sbits(gbc, quantization_tab[bap]);
mantissa <<= 24 - quantization_tab[bap];
break;
coeffs[freq] = mantissa >> exps[freq];
| 1threat |
Implementing Search in Sitecore 8.1 : <p>I have been doing research on how to implement search in my website. It looks like Sitecore is recommending Solr over Lucene based on this <a href="https://doc.sitecore.net/sitecore_experience_platform/setting_up__maintaining/search_and_indexing/indexing/using_solr_or_lucene" rel="nofollow">article</a>. I'm also using Glass.Mapper as the ORM and have seen this <a href="http://glass.lu/Mapper/Sc/Tutorials/Tutorial25" rel="nofollow">article</a>, but am still not exactly sure on how to implement it. Does anyone know of a good tutorial on getting started with search in a Sitecore 8.1 website?</p>
<p>Thank you!</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.