problem
stringlengths
26
131k
labels
class label
2 classes
Why is int2word program only prining first ten lines? : <p>I am importing a file the counts in words from one to ninety-nine. The goal is to read each line and return an integer value corresponding to the word in the file. However, I cannot seem to figure out why my code is only working for the first ten numbers/lines?</p> <pre><code>def word_to_int(w): i = 0 ones = [[1,'one'], [2,'two'], [3,'three'], [4,'four'], [5,'five'], [6,'six'], [7,'seven'], [8,'eight'], [9,'nine']] teens = [[10,'ten'], [11,'eleven'], [12,'twelve'], [13,'thirteen'], [14,'fourteen'], [15,'fifteen'], [16,'sixteen'], [17,'seventeen'], [18,'eighteen'],[19,'nineteen']] tens = [[2,'twenty'], [3,'thirty'], [4,'forty'], [5,'fifty'], [6,'sixty'], [7,'seventy'], [8,'eighty'], [9,'ninety']] if(w.find ('-') != -1): a = w.split('-') #gets rid of hyphen and seperates parts for first in tens: if(a[0] == first[1]): #first half of word i = first[0]*10 for second in ones: if (a[1] == second[1]): #second half of word i += second[0] else: for num in ones: if w == num[1]: i = num[0] if(i == 0): for num2 in teens: if w == num2[1]: i == num2[0] if(i == 0): for num3 in tens: if w == num3[1]: i = num3[0]*10 return i </code></pre> <p>any ideas?</p>
0debug
How to programmatically snap to position on Recycler view with LinearSnapHelper : <p>I have implemented a horizontal recyclerView with LinearSnapHelper, to implement a UI input that selects a particular configuration. Kinda like the old school number picker/selector or spinner. The item in the center is the selected position.</p> <p>it works fine and all, but here's the problem. On initial start up, I need to programmatically set the position of the recycler view such that the selected item (the index of which was loaded from disk) is position in the center.</p> <p><code>.scrollToPosition()</code> wont work becuase it places the selected item in the begining. </p> <p>now I know I can do all the math and calculate the x coordinate and manually set it, but thats a lot of redundant work because LinearSnapHelper is already doing this, and I feel like there should be a way to just reuse that logic, but with actually initiating a fling. </p> <p>I need something like <code>LinearSnapHelper.snapToPosition()</code></p>
0debug
how to remove the particular string from the url and update it : <p>I want to remove the string from the url and update as it after the removal.</p> <p>example: <code>www.abc.com/xyz</code></p> <p>I need to remove xyz and update it as <code>www.abc.com</code></p> <p>Thank you</p>
0debug
SSIS packages deployed on SQL Sever 2016 : I have deployed SSIS packages on sql server 2016 and these packages use tables on sql server 2008. Can I able work on tables that is sql server 2008
0debug
SwiftUI Views with a custom init : <p>Let's say that I am making a custom input element that looks like this:</p> <pre class="lang-swift prettyprint-override"><code>struct CustomInput : View { @Binding var text: String var name: String var body: some View { TextField(name, text: $text) .modifier(InputModifier()) } } </code></pre> <p>Currently, when I instantiate this view I'm required to pass both <code>text</code> and <code>name</code> names to arguments. I want to be able to make the <code>name</code> argument optional, like in the example below.</p> <pre class="lang-swift prettyprint-override"><code> CustomInput("Some name", $text) </code></pre> <p>Typically I'd use an init method for this. But I'm not sure how to handle property wrappers like <code>@Binding</code> in the init function. </p> <p>Any ideas on how I can achieve this?</p>
0debug
static uint64_t openpic_src_read(void *opaque, uint64_t addr, unsigned len) { OpenPICState *opp = opaque; uint32_t retval; int idx; DPRINTF("%s: addr %08x\n", __func__, addr); retval = 0xFFFFFFFF; if (addr & 0xF) { return retval; } addr = addr & 0xFFF0; idx = addr >> 5; if (addr & 0x10) { retval = read_IRQreg_ide(opp, idx); } else { retval = read_IRQreg_ipvp(opp, idx); } DPRINTF("%s: => %08x\n", __func__, retval); return retval; }
1threat
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
static void ich9_lpc_update_pic(ICH9LPCState *lpc, int gsi) { int i, pic_level; assert(gsi < ICH9_LPC_PIC_NUM_PINS); pic_level = 0; for (i = 0; i < ICH9_LPC_NB_PIRQS; i++) { int tmp_irq; int tmp_dis; ich9_lpc_pic_irq(lpc, i, &tmp_irq, &tmp_dis); if (!tmp_dis && tmp_irq == gsi) { pic_level |= pci_bus_get_irq_level(lpc->d.bus, i); } } if (gsi == lpc->sci_gsi) { pic_level |= lpc->sci_level; } qemu_set_irq(lpc->gsi[gsi], pic_level); }
1threat
How do I place my activityIndicator programmatically? : <p>I want to place my activityIndicator where I want it programmatically, but I don´t know how.</p> <p>I know how to put it in the center of the screen:</p> <pre><code>activityIndicator.center = self.view.center </code></pre> <p>But I want something like this:</p> <pre><code>activityIndicator.activityIndicator(frame: CGRect(x: 100, y: 100, width: 100, height: 50)) </code></pre> <p>But I can´t seem to make it work.</p>
0debug
static av_cold int aac_decode_init(AVCodecContext *avctx) { AACContext *ac = avctx->priv_data; float output_scale_factor; ac->avctx = avctx; ac->oc[1].m4ac.sample_rate = avctx->sample_rate; if (avctx->extradata_size > 0) { if (decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac, avctx->extradata, avctx->extradata_size*8, 1) < 0) return -1; } else { int sr, i; uint8_t layout_map[MAX_ELEM_ID*4][3]; int layout_map_tags; sr = sample_rate_idx(avctx->sample_rate); ac->oc[1].m4ac.sampling_index = sr; ac->oc[1].m4ac.channels = avctx->channels; ac->oc[1].m4ac.sbr = -1; ac->oc[1].m4ac.ps = -1; for (i = 0; i < FF_ARRAY_ELEMS(ff_mpeg4audio_channels); i++) if (ff_mpeg4audio_channels[i] == avctx->channels) break; if (i == FF_ARRAY_ELEMS(ff_mpeg4audio_channels)) { i = 0; } ac->oc[1].m4ac.chan_config = i; if (ac->oc[1].m4ac.chan_config) { int ret = set_default_channel_config(avctx, layout_map, &layout_map_tags, ac->oc[1].m4ac.chan_config); if (!ret) output_configure(ac, layout_map, layout_map_tags, ac->oc[1].m4ac.chan_config, OC_GLOBAL_HDR); else if (avctx->err_recognition & AV_EF_EXPLODE) return AVERROR_INVALIDDATA; } } if (avctx->request_sample_fmt == AV_SAMPLE_FMT_FLT) { avctx->sample_fmt = AV_SAMPLE_FMT_FLT; output_scale_factor = 1.0 / 32768.0; } else { avctx->sample_fmt = AV_SAMPLE_FMT_S16; output_scale_factor = 1.0; } AAC_INIT_VLC_STATIC( 0, 304); AAC_INIT_VLC_STATIC( 1, 270); AAC_INIT_VLC_STATIC( 2, 550); AAC_INIT_VLC_STATIC( 3, 300); AAC_INIT_VLC_STATIC( 4, 328); AAC_INIT_VLC_STATIC( 5, 294); AAC_INIT_VLC_STATIC( 6, 306); AAC_INIT_VLC_STATIC( 7, 268); AAC_INIT_VLC_STATIC( 8, 510); AAC_INIT_VLC_STATIC( 9, 366); AAC_INIT_VLC_STATIC(10, 462); ff_aac_sbr_init(); ff_dsputil_init(&ac->dsp, avctx); ff_fmt_convert_init(&ac->fmt_conv, avctx); avpriv_float_dsp_init(&ac->fdsp, avctx->flags & CODEC_FLAG_BITEXACT); ac->random_state = 0x1f2e3d4c; ff_aac_tableinit(); INIT_VLC_STATIC(&vlc_scalefactors,7,FF_ARRAY_ELEMS(ff_aac_scalefactor_code), ff_aac_scalefactor_bits, sizeof(ff_aac_scalefactor_bits[0]), sizeof(ff_aac_scalefactor_bits[0]), ff_aac_scalefactor_code, sizeof(ff_aac_scalefactor_code[0]), sizeof(ff_aac_scalefactor_code[0]), 352); ff_mdct_init(&ac->mdct, 11, 1, output_scale_factor/1024.0); ff_mdct_init(&ac->mdct_small, 8, 1, output_scale_factor/128.0); ff_mdct_init(&ac->mdct_ltp, 11, 0, -2.0/output_scale_factor); ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024); ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128); ff_init_ff_sine_windows(10); ff_init_ff_sine_windows( 7); cbrt_tableinit(); avcodec_get_frame_defaults(&ac->frame); avctx->coded_frame = &ac->frame; return 0; }
1threat
static unsigned virtio_pci_get_features(void *opaque) { unsigned ret = 0; ret |= (1 << VIRTIO_F_NOTIFY_ON_EMPTY); ret |= (1 << VIRTIO_RING_F_INDIRECT_DESC); ret |= (1 << VIRTIO_F_BAD_FEATURE); return ret; }
1threat
How to set compiler options with CMake in Visual Studio 2017 : <p>Visual Studio 2017 comes with full CMake integration. To learn about this combination, I was starting with this basic sample:</p> <pre><code># CMakeLists.txt cmake_minimum_required(VERSION 3.8) project(foo) add_executable(foo foo.cpp) </code></pre> <p>and</p> <pre><code>// foo.cpp int main() {} </code></pre> <p>This properly generates build scripts, and compiles and links with no issues. That was easy.</p> <p>Trying to set compiler options, on the other hand, turned out to be anything but trivial. In my case I was attempting to set the warning level to 4.</p> <p>The obvious solution</p> <pre><code>add_compile_options("/W4") </code></pre> <p>didn't pan out as expected. The command line passed to the compiler now contains both <code>/W4</code> (as intended) as well as <code>/W3</code> (picked up from somewhere else), producing the following warning:</p> <blockquote> <pre><code>cl : Command line warning D9025: overriding '/W3' with '/W4' </code></pre> </blockquote> <p>To work around this, I would need to <em>replace</em> any incompatible compiler option(s) instead of just adding one. CMake does not provide any immediate support for this, and the standard solution (as <a href="https://stackoverflow.com/q/2368811/1889329">this Q&amp;A suggests</a>) seems to be:</p> <pre><code>if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") endif() </code></pre> <p>This, however, has two issues:</p> <ul> <li>It sets the global <code>CMAKE_CXX_FLAGS</code>, applying to all C++ targets. This may not be intended (not an issue for me right now).</li> <li>It doesn't scale. For every compiler option to add, you would have to read up on incompatible options, and manually strip those first. This will inevitably fail<sup>1</sup>.</li> </ul> <p>My question is two-fold:</p> <ol> <li>Where does the CMake integration pick up default settings from, and can this be controlled?</li> <li>How do you set compiler options in general? (If this is too broad a topic, I'd be happy for help on setting the warning level only.)</li> </ol> <p><hr/> <sup>1</sup> <em>Incidentally, the solution I replicated fails to account for the <code>/Wall</code> option, that is incompatible with <code>/W4</code> as well.</em></p>
0debug
static void icp_pit_write(void *opaque, target_phys_addr_t offset, uint64_t value, unsigned size) { icp_pit_state *s = (icp_pit_state *)opaque; int n; n = offset >> 8; if (n > 2) { hw_error("%s: Bad timer %d\n", __func__, n); } arm_timer_write(s->timer[n], offset & 0xff, value); }
1threat
SwsFunc yuv2rgb_init_mlib(SwsContext *c) { switch(c->dstFormat){ case PIX_FMT_RGB24: return mlib_YUV2RGB420_24; case PIX_FMT_BGR32: return mlib_YUV2ARGB420_32; case PIX_FMT_RGB32: return mlib_YUV2ABGR420_32; default: return NULL; } }
1threat
Check if date in database is bigger then today. (Java/SQL) : So I have a table in my database with reservations. In java I only want to show the reservations of today and beyond. PreparedStatement statement = con.prepareStatement( "SELECT reservatieID,klanten.voornaam,klanten.achternaam,kamerID,startDatum,eindDatum " + "FROM reservatie " + "INNER JOIN klanten ON reservatie.klantID = klanten.klantID" + "WHERE eindDatum =>?"); String now = basisLogin.getDate(); statement.setString(1, now); ResultSet resultSet = statement.executeQuery(); So this is my code. The string of today's date is in this format: yyyy-MM-dd This is the error I get: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have anerror in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'eindDatum >'2017-03-07'' at line 1 java.lang.ArrayIndexOutOfBoundsException: 0 >= 0 What am I doing wrong?
0debug
How to run dynamic service with get location in background in an Android app? with example code : <p>How to run dynamic service with get location in background in an Android app? with example code </p>
0debug
Html with parameters GET : <p>I have a doubt about this sentence in html:</p> <pre><code> &lt;a href="http://www.donate.co?amount=100&amp;amp;destination=MessageTable/"&gt; </code></pre> <p>and this:</p> <pre><code> &lt;a href="http://www.donate.co?amount=100&amp;destination=MessageTable/"&gt; </code></pre> <p>This sentence pass paramaters with GET. But I don't undertand because in the first sentence put &amp; amp; and the second sentence put &amp; only.</p> <p>Thank you,</p> <p>regards, javi</p>
0debug
eror when downloading android sdk : hi i downloded android studio 3.1.2 and install it but the gradle didnt sync. i try to fix it but i cant then i uninsttalled the android studio and deleted all things about it like sdk ... now i reinstall the android studio and want to download sdk manager when downloding start i have these erors and i'v attached the picture: [enter image description here][1] java.io.IOException: Cannot download 'https://dl.google.com/android/repository/emulator-windows-4623001.zip': SSL peer shut down incorrectly , response: 200 OK Warning: An error occurred while preparing SDK package Android Emulator: Cannot download 'https://dl.google.com/android/repository/emulator-windows-4623001.zip': SSL peer shut down incorrectly , response: 200 OK. "Install Android Emulator (revision: 27.1.12)" failed. Preparing "Install Android Support Repository (revision: 47.0.0)". Downloading https://dl.google.com/android/repository/android_m2repository_r47.zip java.io.IOException: Cannot download 'https://dl.google.com/android/repository/android_m2repository_r47.zip': Unexpected end of file from server , response: 200 OK Warning: An error occurred while preparing SDK package Android Support Repository: Cannot download 'https://dl.google.com/android/repository/android_m2repository_r47.zip': Unexpected end of file from server , response: 200 OK. [1]: https://i.stack.imgur.com/Ua9VL.png
0debug
Input validation with integer and int.tryparse : <p>So i nearly have 2k lines of code and i have forgotten to / i do not know how to have input valdation on user inputs such as</p> <pre><code>cw("Hello Please Enter your age"); cw("If you are in a Group Input the Age of the Youngest Member of the Group."); Age = Convert.ToInt32(Console.ReadLine()); </code></pre> <p>I want to Make it so that users can enter only numbers and my program will not crash when they put in somthing els.</p> <p>this is a common problem in the whole of my program for the console.readlines. </p> <p>Is there a way on mass that i can introduce the input valdation for numbers only and letters only when approate?</p> <p>thank you in advance. </p>
0debug
Symfony 4.2 and API Platform: how to use custom operations before return a response : <p>I'm trying to create a custom operation when calling /api/employees.</p> <p>I have done a method in EmployeesController.php called jiraSync, this method must be called before returning the response in JSON to obtain a synchronized response.</p> <p>I have also thought about creating a service, but I do not know if it will be a good idea, what do you recommend?</p> <p>This is my Employees <strong>entity</strong>:</p> <pre><code>&lt;?php namespace App\Entity; use ApiPlatform\Core\Annotation\ApiResource; use App\Controller\EmployeeController; use Doctrine\ORM\Mapping as ORM; /** * Employees * * @ApiResource() * @ORM\Table(name="employees", uniqueConstraints={@ORM\UniqueConstraint(name="email_UNIQUE", columns={"email"})}, indexes={@ORM\Index(name="fk_employees_departments_idx", columns={"department_id"})}) * @ORM\Entity */ class Employees { /** * @var int * * @ORM\Column(name="id", type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ private $id; /** * @var string * * @ORM\Column(name="email", type="string", length=255, nullable=false) */ private $email; /** * @var string * * @ORM\Column(name="name", type="string", length=50, nullable=false) */ private $name; /** * @var string|null * * @ORM\Column(name="surname", type="string", length=100, nullable=true) */ private $surname; /** * @var string|null * * @ORM\Column(name="image", type="string", length=255, nullable=true) */ private $image; /** * @var \Departments * * @ORM\ManyToOne(targetEntity="Departments") * @ORM\JoinColumns({ * @ORM\JoinColumn(name="department_id", referencedColumnName="id") * }) */ private $department; /** * @var bool * * @ORM\Column(name="is_enabled", type="boolean", nullable=false) */ private $isEnabled = '0'; public function getId(): ?int { return $this-&gt;id; } public function getEmail(): ?string { return $this-&gt;email; } public function setEmail(string $email): self { $this-&gt;email = $email; return $this; } public function getName(): ?string { return $this-&gt;name; } public function setName(string $name): self { $this-&gt;name = $name; return $this; } public function getSurname(): ?string { return $this-&gt;surname; } public function setSurname(?string $surname): self { $this-&gt;surname = $surname; return $this; } public function getImage(): ?string { return $this-&gt;image; } public function setImage(?string $image): self { $this-&gt;image = $image; return $this; } public function getDepartment(): ?Departments { return $this-&gt;department; } public function setDepartment(?Departments $department): self { $this-&gt;department = $department; return $this; } public function getIsEnabled(): ?bool { return $this-&gt;isEnabled; } public function setIsEnabled($isEnabled): self { $this-&gt;isEnabled = $isEnabled; return $this; } } </code></pre> <p>And this is my <strong>controller</strong>:</p> <pre><code>&lt;?php namespace App\Controller; use App\Entity\Employees; use JiraRestApi\JiraException; use JiraRestApi\User\UserService; use Symfony\Bridge\Doctrine\Tests\Fixtures\Employee; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Routing\Annotation\Route; class EmployeeController extends AbstractController { public function jiraSync() { // ... } } </code></pre>
0debug
static int megasas_ld_get_info_submit(SCSIDevice *sdev, int lun, MegasasCmd *cmd) { struct mfi_ld_info *info = cmd->iov_buf; size_t dcmd_size = sizeof(struct mfi_ld_info); uint8_t cdb[6]; SCSIRequest *req; ssize_t len, resid; BlockConf *conf = &sdev->conf; uint16_t sdev_id = ((sdev->id & 0xFF) >> 8) | (lun & 0xFF); uint64_t ld_size; if (!cmd->iov_buf) { cmd->iov_buf = g_malloc(dcmd_size); memset(cmd->iov_buf, 0x0, dcmd_size); info = cmd->iov_buf; megasas_setup_inquiry(cdb, 0x83, sizeof(info->vpd_page83)); req = scsi_req_new(sdev, cmd->index, lun, cdb, cmd); if (!req) { trace_megasas_dcmd_req_alloc_failed(cmd->index, "LD get info vpd inquiry"); g_free(cmd->iov_buf); cmd->iov_buf = NULL; return MFI_STAT_FLASH_ALLOC_FAIL; } trace_megasas_dcmd_internal_submit(cmd->index, "LD get info vpd inquiry", lun); len = scsi_req_enqueue(req); if (len > 0) { cmd->iov_size = len; scsi_req_continue(req); } return MFI_STAT_INVALID_STATUS; } info->ld_config.params.state = MFI_LD_STATE_OPTIMAL; info->ld_config.properties.ld.v.target_id = lun; info->ld_config.params.stripe_size = 3; info->ld_config.params.num_drives = 1; info->ld_config.params.is_consistent = 1; bdrv_get_geometry(conf->bs, &ld_size); info->size = cpu_to_le64(ld_size); memset(info->ld_config.span, 0, sizeof(info->ld_config.span)); info->ld_config.span[0].start_block = 0; info->ld_config.span[0].num_blocks = info->size; info->ld_config.span[0].array_ref = cpu_to_le16(sdev_id); resid = dma_buf_read(cmd->iov_buf, dcmd_size, &cmd->qsg); g_free(cmd->iov_buf); cmd->iov_size = dcmd_size - resid; cmd->iov_buf = NULL; return MFI_STAT_OK; }
1threat
static int ogg_new_buf(struct ogg *ogg, int idx) { struct ogg_stream *os = ogg->streams + idx; uint8_t *nb = av_malloc(os->bufsize); int size = os->bufpos - os->pstart; if(os->buf){ memcpy(nb, os->buf + os->pstart, size); av_free(os->buf); } os->buf = nb; os->bufpos = size; os->pstart = 0; return 0; }
1threat
Using AWS Secrets Manager with Python (Lambda Console) : <p>I am attempting to use Secrets Manager a Lambda function in AWS. Secrets a manager is used to store database credentials to Snowflake (username, password).</p> <p>I managed to set up a secret in Secrets Manager which contains several key/value pairs (e.g. one for username, another for password).</p> <p>Now I am trying to refer to these values in my Python function code. AWS documentation kindly provides the following snippet:</p> <pre><code>import boto3 import base64 from botocore.exceptions import ClientError def get_secret(): secret_name = "MY/SECRET/NAME" region_name = "us-west-2" # Create a Secrets Manager client session = boto3.session.Session() client = session.client( service_name='secretsmanager', region_name=region_name ) # In this sample we only handle the specific exceptions for the 'GetSecretValue' API. # See https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_GetSecretValue.html # We rethrow the exception by default. try: get_secret_value_response = client.get_secret_value( SecretId=secret_name ) except ClientError as e: if e.response['Error']['Code'] == 'DecryptionFailureException': # Secrets Manager can't decrypt the protected secret text using the provided KMS key. # Deal with the exception here, and/or rethrow at your discretion. raise e elif e.response['Error']['Code'] == 'InternalServiceErrorException': # An error occurred on the server side. # Deal with the exception here, and/or rethrow at your discretion. raise e elif e.response['Error']['Code'] == 'InvalidParameterException': # You provided an invalid value for a parameter. # Deal with the exception here, and/or rethrow at your discretion. raise e elif e.response['Error']['Code'] == 'InvalidRequestException': # You provided a parameter value that is not valid for the current state of the resource. # Deal with the exception here, and/or rethrow at your discretion. raise e elif e.response['Error']['Code'] == 'ResourceNotFoundException': # We can't find the resource that you asked for. # Deal with the exception here, and/or rethrow at your discretion. raise e else: # Decrypts secret using the associated KMS CMK. # Depending on whether the secret is a string or binary, one of these fields will be populated. if 'SecretString' in get_secret_value_response: secret = get_secret_value_response['SecretString'] else: decoded_binary_secret = base64.b64decode(get_secret_value_response['SecretBinary']) # Your code goes here. </code></pre> <p>Later in my <code>def lambda_handler(event, context)</code> function, I have the following snippet to establish a connection to my database:</p> <pre><code> conn = snowflake.connector.connect( user=USERNAME, password=PASSWORD, account=ACCOUNT, warehouse=WAREHOUSE, role=ROLE ) </code></pre> <p>However, I am unable to figure out how to use the <code>get_secret()</code> function to return values for parameters like <code>USERNAME</code> or <code>PASSWORD</code>. </p> <p>How can this be accomplished? Thank you for the help!</p>
0debug
Accessing Data in side hash / array : Hello I have the following object ( simplified for example sake ) note_attributes: [ { name: "Order_Count", value: 2 } ] I am looking to access specifically the "Order_Count" How do I do this in my rails app? I have tried note_attributes.name and note_attributes[name] but I have not had any luck.
0debug
static int local_fstat(FsContext *fs_ctx, int fid_type, V9fsFidOpenState *fs, struct stat *stbuf) { int err, fd; if (fid_type == P9_FID_DIR) { fd = dirfd(fs->dir); } else { fd = fs->fd; } err = fstat(fd, stbuf); if (err) { return err; } if (fs_ctx->export_flags & V9FS_SM_MAPPED) { uid_t tmp_uid; gid_t tmp_gid; mode_t tmp_mode; dev_t tmp_dev; if (fgetxattr(fd, "user.virtfs.uid", &tmp_uid, sizeof(uid_t)) > 0) { stbuf->st_uid = tmp_uid; } if (fgetxattr(fd, "user.virtfs.gid", &tmp_gid, sizeof(gid_t)) > 0) { stbuf->st_gid = tmp_gid; } if (fgetxattr(fd, "user.virtfs.mode", &tmp_mode, sizeof(mode_t)) > 0) { stbuf->st_mode = tmp_mode; } if (fgetxattr(fd, "user.virtfs.rdev", &tmp_dev, sizeof(dev_t)) > 0) { stbuf->st_rdev = tmp_dev; } } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { errno = EOPNOTSUPP; return -1; } return err; }
1threat
How to disable bracket balancing in Xcode9 : <p>When I hit delete-key to remove the single ']' character like this in Xcode 9.0 (9A235),</p> <pre><code>id object = [] ; ^ | caret position </code></pre> <p>Xcode deletes TWO characters automatically.</p> <pre><code>id object = ; ^ | caret position </code></pre> <p>I know this behavior is implemented for convenience. BUT I don't like this. I can't find options in preferences window. please teach me how to disable this behavior.</p>
0debug
opts_visitor_new(const QemuOpts *opts) { OptsVisitor *ov; ov = g_malloc0(sizeof *ov); ov->visitor.type = VISITOR_INPUT; ov->visitor.start_struct = &opts_start_struct; ov->visitor.check_struct = &opts_check_struct; ov->visitor.end_struct = &opts_end_struct; ov->visitor.start_list = &opts_start_list; ov->visitor.next_list = &opts_next_list; ov->visitor.end_list = &opts_end_list; ov->visitor.type_int64 = &opts_type_int64; ov->visitor.type_uint64 = &opts_type_uint64; ov->visitor.type_size = &opts_type_size; ov->visitor.type_bool = &opts_type_bool; ov->visitor.type_str = &opts_type_str; ov->visitor.optional = &opts_optional; ov->visitor.free = opts_free; ov->opts_root = opts; return &ov->visitor; }
1threat
How to sum values in arrays with key in other array : <p>I have an object with two arrays in JSON file :</p> <pre><code>"Data": { "Server": ["a", "a", "a", "a", "b", "b", "b", "b", "c", "c", "c", "c"], "Count": ["12", "32", "7", "1", "67", "2", "3", "6", "5", "6", "5", "4"] } </code></pre> <p>what I want to achive is to add all values of array 'count' for relative values in 'server' array and create new array with structure like this:</p> <pre><code> "Data": { "Server": ["a", "b", "c"], "Count": ["52", "78", "20"] } </code></pre> <p>Can anyone help with this? </p>
0debug
Constructing the Fibonacci sequence in Haskell : <p>I'm a complete beginner with Haskell and just encountered the following terse expression for constructing the Fibonacci sequence:</p> <pre><code>fibs = 0 : 1 : zipWith (+) fibs (tail fibs) </code></pre> <p>I think I understand what each individual piece is doing (<code>:</code>, <code>zipWith</code>, <code>tail</code>), and I know some sort of recursion is happening, but am not quite sure how.</p>
0debug
Substituting parameters in log message and add a Throwable in Log4j 2 : <p>I am trying to log an exception, and would like to include another variable's value in the log message. Is there a Logger API that does this? </p> <pre><code>logger.error("Logging in user {} with birthday {}", user.getName(), user.getBirthdayCalendar(), exception); </code></pre>
0debug
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
void error_set_win32(Error **errp, int win32_err, ErrorClass err_class, const char *fmt, ...) { va_list ap; char *msg1, *msg2; if (errp == NULL) { return; } va_start(ap, fmt); error_setv(errp, err_class, fmt, ap); va_end(ap); if (win32_err != 0) { msg1 = (*errp)->msg; msg2 = g_win32_error_message(win32_err); (*errp)->msg = g_strdup_printf("%s: %s (error: %x)", msg1, msg2, (unsigned)win32_err); g_free(msg2); g_free(msg1); } }
1threat
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
ValueError: Input 0 is incompatible with layer lstm_13: expected ndim=3, found ndim=4 : <p>I am trying for multi-class classification and here are the details of my training input and output:</p> <blockquote> <p>train_input.shape= (1, 95000, 360) (95000 length input array with each element being an array of 360 length)</p> <p>train_output.shape = (1, 95000, 22) (22 Classes are there)</p> </blockquote> <pre><code>model = Sequential() model.add(LSTM(22, input_shape=(1, 95000,360))) model.add(Dense(22, activation='softmax')) model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy']) print(model.summary()) model.fit(train_input, train_output, epochs=2, batch_size=500) </code></pre> <p>The error is:</p> <blockquote> <p>ValueError: Input 0 is incompatible with layer lstm_13: expected ndim=3, found ndim=4 in line: model.add(LSTM(22, input_shape=(1, 95000,360)))</p> </blockquote> <p>Please help me out, I am not able to solve it through other answers.</p>
0debug
docker volume custom mount point : <p>I'm new to Docker and I was playing around with <code>docker volume</code>. I wanted to specify the location where <code>docker volume</code> stores the data. Much like when we provide the <code>-v</code> option when we execute <code>docker run</code>. <strong><code>Ex : -v /somefolder/:/var/somefolder</code></strong></p> <p>How can we set a custom <strong>Mountpoint</strong> when we create a <code>docker volume</code>. I didn't find any options on docs.</p> <p>When I inspect the volume</p> <pre><code>[ { "Name": "sampleproject_mysql_data", "Driver": "local", "Mountpoint": "/mnt/sda1/var/lib/docker/volumes/sampleproject_mysql_data/_data", "Labels": null, "Scope": "local" } ] </code></pre> <p>I get something like above.</p> <h2>Is there a way we can set custom Mountpoint. Through <code>docker volume</code> command or through <code>docker-compose.yml</code>?</h2>
0debug
static void decode_delta_j(uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int h, int bpp, int dst_size) { int32_t pitch; uint8_t *end = dst + dst_size, *ptr; uint32_t type, flag, cols, groups, rows, bytes; uint32_t offset; int planepitch_byte = (w + 7) / 8; int planepitch = ((w + 15) / 16) * 2; int kludge_j, b, g, r, d; GetByteContext gb; pitch = planepitch * bpp; kludge_j = w < 320 ? (320 - w) / 8 / 2 : 0; bytestream2_init(&gb, buf, buf_end - buf); while (bytestream2_get_bytes_left(&gb) >= 2) { type = bytestream2_get_be16(&gb); switch (type) { case 0: return; case 1: flag = bytestream2_get_be16(&gb); cols = bytestream2_get_be16(&gb); groups = bytestream2_get_be16(&gb); for (g = 0; g < groups; g++) { offset = bytestream2_get_be16(&gb); if (kludge_j) offset = ((offset / (320 / 8)) * pitch) + (offset % (320 / 8)) - kludge_j; else offset = ((offset / planepitch_byte) * pitch) + (offset % planepitch_byte); ptr = dst + offset; if (ptr >= end) return; for (b = 0; b < cols; b++) { for (d = 0; d < bpp; d++) { uint8_t value = bytestream2_get_byte(&gb); if (flag) ptr[0] ^= value; else ptr[0] = value; ptr += planepitch; if (ptr >= end) return; } } if ((cols * bpp) & 1) bytestream2_skip(&gb, 1); } break; case 2: flag = bytestream2_get_be16(&gb); rows = bytestream2_get_be16(&gb); bytes = bytestream2_get_be16(&gb); groups = bytestream2_get_be16(&gb); for (g = 0; g < groups; g++) { offset = bytestream2_get_be16(&gb); if (kludge_j) offset = ((offset / (320 / 8)) * pitch) + (offset % (320/ 8)) - kludge_j; else offset = ((offset / planepitch_byte) * pitch) + (offset % planepitch_byte); for (r = 0; r < rows; r++) { for (d = 0; d < bpp; d++) { ptr = dst + offset + (r * pitch) + d * planepitch; if (ptr >= end) return; for (b = 0; b < bytes; b++) { uint8_t value = bytestream2_get_byte(&gb); if (flag) ptr[0] ^= value; else ptr[0] = value; ptr++; if (ptr >= end) return; } } } if ((rows * bytes * bpp) & 1) bytestream2_skip(&gb, 1); } break; default: return; } } }
1threat
static void i440fx_realize(PCIDevice *dev, Error **errp) { dev->config[I440FX_SMRAM] = 0x02; if (object_property_get_bool(qdev_get_machine(), "iommu", NULL)) { error_report("warning: i440fx doesn't support emulated iommu"); } }
1threat
how can I extract information from many XML from a directory and export it to an excel in java : I'm trying to get information from many xml files in a directory, how can I get specific infrmation from each one and send it to an excel file, in java file 1.xml file 2.xml file 3.xml ********* **file.csv** or .**xls** with the information of the 'n' files XML
0debug
int kvm_arch_init_vcpu(CPUState *cs) { int i, ret, arraylen; uint64_t v; struct kvm_one_reg r; struct kvm_reg_list rl; struct kvm_reg_list *rlp; ARMCPU *cpu = ARM_CPU(cs); if (cpu->kvm_target == QEMU_KVM_ARM_TARGET_NONE) { fprintf(stderr, "KVM is not supported for this guest CPU type\n"); return -EINVAL; } memset(cpu->kvm_init_features, 0, sizeof(cpu->kvm_init_features)); if (cpu->start_powered_off) { cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_POWER_OFF; } if (kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PSCI_0_2)) { cpu->psci_version = 2; cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_PSCI_0_2; } ret = kvm_arm_vcpu_init(cs); if (ret) { return ret; } r.id = KVM_REG_ARM | KVM_REG_SIZE_U64 | KVM_REG_ARM_VFP | 31; r.addr = (uintptr_t)(&v); ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &r); if (ret == -ENOENT) { return -EINVAL; } rl.n = 0; ret = kvm_vcpu_ioctl(cs, KVM_GET_REG_LIST, &rl); if (ret != -E2BIG) { return ret; } rlp = g_malloc(sizeof(struct kvm_reg_list) + rl.n * sizeof(uint64_t)); rlp->n = rl.n; ret = kvm_vcpu_ioctl(cs, KVM_GET_REG_LIST, rlp); if (ret) { goto out; } qsort(&rlp->reg, rlp->n, sizeof(rlp->reg[0]), compare_u64); for (i = 0, arraylen = 0; i < rlp->n; i++) { if (!reg_syncs_via_tuple_list(rlp->reg[i])) { continue; } switch (rlp->reg[i] & KVM_REG_SIZE_MASK) { case KVM_REG_SIZE_U32: case KVM_REG_SIZE_U64: break; default: fprintf(stderr, "Can't handle size of register in kernel list\n"); ret = -EINVAL; goto out; } arraylen++; } cpu->cpreg_indexes = g_renew(uint64_t, cpu->cpreg_indexes, arraylen); cpu->cpreg_values = g_renew(uint64_t, cpu->cpreg_values, arraylen); cpu->cpreg_vmstate_indexes = g_renew(uint64_t, cpu->cpreg_vmstate_indexes, arraylen); cpu->cpreg_vmstate_values = g_renew(uint64_t, cpu->cpreg_vmstate_values, arraylen); cpu->cpreg_array_len = arraylen; cpu->cpreg_vmstate_array_len = arraylen; for (i = 0, arraylen = 0; i < rlp->n; i++) { uint64_t regidx = rlp->reg[i]; if (!reg_syncs_via_tuple_list(regidx)) { continue; } cpu->cpreg_indexes[arraylen] = regidx; arraylen++; } assert(cpu->cpreg_array_len == arraylen); if (!write_kvmstate_to_list(cpu)) { fprintf(stderr, "Initial read of kernel register state failed\n"); ret = -EINVAL; goto out; } cpu->cpreg_reset_values = g_memdup(cpu->cpreg_values, cpu->cpreg_array_len * sizeof(cpu->cpreg_values[0])); out: g_free(rlp); return ret; }
1threat
How to compare to different table coloms and matched coloms fetch all rows from table one? : i am compairing two tables single coloms and matched coloms fetch all rows select * from t_registered_std_info where t_registered_std_info.t_ds_name == attendance.std_name
0debug
int ff_h263_decode_picture_header(MpegEncContext *s) { int format, width, height, i; uint32_t startcode; align_get_bits(&s->gb); startcode= get_bits(&s->gb, 22-8); for(i= get_bits_left(&s->gb); i>24; i-=8) { startcode = ((startcode << 8) | get_bits(&s->gb, 8)) & 0x003FFFFF; if(startcode == 0x20) break; } if (startcode != 0x20) { av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n"); return -1; } i = get_bits(&s->gb, 8); if( (s->picture_number&~0xFF)+i < s->picture_number) i+= 256; s->current_picture_ptr->f.pts = s->picture_number= (s->picture_number&~0xFF) + i; if (get_bits1(&s->gb) != 1) { av_log(s->avctx, AV_LOG_ERROR, "Bad marker\n"); return -1; } if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "Bad H263 id\n"); return -1; } skip_bits1(&s->gb); skip_bits1(&s->gb); skip_bits1(&s->gb); format = get_bits(&s->gb, 3); if (format != 7 && format != 6) { s->h263_plus = 0; width = ff_h263_format[format][0]; height = ff_h263_format[format][1]; if (!width) return -1; s->pict_type = AV_PICTURE_TYPE_I + get_bits1(&s->gb); s->h263_long_vectors = get_bits1(&s->gb); if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "H263 SAC not supported\n"); return -1; } s->obmc= get_bits1(&s->gb); s->unrestricted_mv = s->h263_long_vectors || s->obmc; s->pb_frame = get_bits1(&s->gb); s->chroma_qscale= s->qscale = get_bits(&s->gb, 5); skip_bits1(&s->gb); s->width = width; s->height = height; s->avctx->sample_aspect_ratio= (AVRational){12,11}; s->avctx->time_base= (AVRational){1001, 30000}; } else { int ufep; s->h263_plus = 1; ufep = get_bits(&s->gb, 3); if (ufep == 1) { format = get_bits(&s->gb, 3); av_dlog(s->avctx, "ufep=1, format: %d\n", format); s->custom_pcf= get_bits1(&s->gb); s->umvplus = get_bits1(&s->gb); if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "Syntax-based Arithmetic Coding (SAC) not supported\n"); } s->obmc= get_bits1(&s->gb); s->h263_aic = get_bits1(&s->gb); s->loop_filter= get_bits1(&s->gb); s->unrestricted_mv = s->umvplus || s->obmc || s->loop_filter; s->h263_slice_structured= get_bits1(&s->gb); if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "Reference Picture Selection not supported\n"); } if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "Independent Segment Decoding not supported\n"); } s->alt_inter_vlc= get_bits1(&s->gb); s->modified_quant= get_bits1(&s->gb); if(s->modified_quant) s->chroma_qscale_table= ff_h263_chroma_qscale_table; skip_bits(&s->gb, 1); skip_bits(&s->gb, 3); } else if (ufep != 0) { av_log(s->avctx, AV_LOG_ERROR, "Bad UFEP type (%d)\n", ufep); return -1; } s->pict_type = get_bits(&s->gb, 3); switch(s->pict_type){ case 0: s->pict_type= AV_PICTURE_TYPE_I;break; case 1: s->pict_type= AV_PICTURE_TYPE_P;break; case 2: s->pict_type= AV_PICTURE_TYPE_P;s->pb_frame = 3;break; case 3: s->pict_type= AV_PICTURE_TYPE_B;break; case 7: s->pict_type= AV_PICTURE_TYPE_I;break; default: return -1; } skip_bits(&s->gb, 2); s->no_rounding = get_bits1(&s->gb); skip_bits(&s->gb, 4); if (ufep) { if (format == 6) { s->aspect_ratio_info = get_bits(&s->gb, 4); av_dlog(s->avctx, "aspect: %d\n", s->aspect_ratio_info); width = (get_bits(&s->gb, 9) + 1) * 4; skip_bits1(&s->gb); height = get_bits(&s->gb, 9) * 4; av_dlog(s->avctx, "\nH.263+ Custom picture: %dx%d\n",width,height); if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) { s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 8); s->avctx->sample_aspect_ratio.den= get_bits(&s->gb, 8); }else{ s->avctx->sample_aspect_ratio= ff_h263_pixel_aspect[s->aspect_ratio_info]; } } else { width = ff_h263_format[format][0]; height = ff_h263_format[format][1]; s->avctx->sample_aspect_ratio= (AVRational){12,11}; } if ((width == 0) || (height == 0)) return -1; s->width = width; s->height = height; if(s->custom_pcf){ int gcd; s->avctx->time_base.den= 1800000; s->avctx->time_base.num= 1000 + get_bits1(&s->gb); s->avctx->time_base.num*= get_bits(&s->gb, 7); if(s->avctx->time_base.num == 0){ av_log(s, AV_LOG_ERROR, "zero framerate\n"); return -1; } gcd= av_gcd(s->avctx->time_base.den, s->avctx->time_base.num); s->avctx->time_base.den /= gcd; s->avctx->time_base.num /= gcd; }else{ s->avctx->time_base= (AVRational){1001, 30000}; } } if(s->custom_pcf){ skip_bits(&s->gb, 2); } if (ufep) { if (s->umvplus) { if(get_bits1(&s->gb)==0) skip_bits1(&s->gb); } if(s->h263_slice_structured){ if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "rectangular slices not supported\n"); } if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "unordered slices not supported\n"); } } } s->qscale = get_bits(&s->gb, 5); } s->mb_width = (s->width + 15) / 16; s->mb_height = (s->height + 15) / 16; s->mb_num = s->mb_width * s->mb_height; if (s->pb_frame) { skip_bits(&s->gb, 3); if (s->custom_pcf) skip_bits(&s->gb, 2); skip_bits(&s->gb, 2); } while (get_bits1(&s->gb) != 0) { skip_bits(&s->gb, 8); } if(s->h263_slice_structured){ if (get_bits1(&s->gb) != 1) { av_log(s->avctx, AV_LOG_ERROR, "SEPB1 marker missing\n"); return -1; } ff_h263_decode_mba(s); if (get_bits1(&s->gb) != 1) { av_log(s->avctx, AV_LOG_ERROR, "SEPB2 marker missing\n"); return -1; } } s->f_code = 1; if(s->h263_aic){ s->y_dc_scale_table= s->c_dc_scale_table= ff_aic_dc_scale_table; }else{ s->y_dc_scale_table= s->c_dc_scale_table= ff_mpeg1_dc_scale_table; } ff_h263_show_pict_info(s); if (s->pict_type == AV_PICTURE_TYPE_I && s->codec_tag == AV_RL32("ZYGO")){ int i,j; for(i=0; i<85; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb)); av_log(s->avctx, AV_LOG_DEBUG, "\n"); for(i=0; i<13; i++){ for(j=0; j<3; j++){ int v= get_bits(&s->gb, 8); v |= get_sbits(&s->gb, 8)<<8; av_log(s->avctx, AV_LOG_DEBUG, " %5d", v); } av_log(s->avctx, AV_LOG_DEBUG, "\n"); } for(i=0; i<50; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb)); } return 0; }
1threat
Take screen shoot of clent windows using php script : Is this possible to take windows's screen shoot of cleint users using a php application?
0debug
static void blend_frames16_c(BLEND_FUNC_PARAMS) { int line, pixel; uint16_t *dstw = (uint16_t *)dst; uint16_t *src1w = (uint16_t *)src1; uint16_t *src2w = (uint16_t *)src2; width /= 2; src1_linesize /= 2; src2_linesize /= 2; dst_linesize /= 2; for (line = 0; line < height; line++) { for (pixel = 0; pixel < width; pixel++) dstw[pixel] = ((src1w[pixel] * factor1) + (src2w[pixel] * factor2) + half) >> shift; src1w += src1_linesize; src2w += src2_linesize; dstw += dst_linesize; } }
1threat
static int huf_decode(const uint64_t *hcode, const HufDec *hdecod, GetByteContext *gb, int nbits, int rlc, int no, uint16_t *out) { uint64_t c = 0; uint16_t *outb = out; uint16_t *oe = out + no; const uint8_t *ie = gb->buffer + (nbits + 7) / 8; uint8_t cs, s; int i, lc = 0; while (gb->buffer < ie) { get_char(c, lc, gb); while (lc >= HUF_DECBITS) { const HufDec pl = hdecod[(c >> (lc - HUF_DECBITS)) & HUF_DECMASK]; if (pl.len) { lc -= pl.len; get_code(pl.lit, rlc, c, lc, gb, out, oe); } else { int j; if (!pl.p) return AVERROR_INVALIDDATA; for (j = 0; j < pl.lit; j++) { int l = hcode[pl.p[j]] & 63; while (lc < l && bytestream2_get_bytes_left(gb) > 0) get_char(c, lc, gb); if (lc >= l) { if ((hcode[pl.p[j]] >> 6) == ((c >> (lc - l)) & ((1LL << l) - 1))) { lc -= l; get_code(pl.p[j], rlc, c, lc, gb, out, oe); break; } } } if (j == pl.lit) return AVERROR_INVALIDDATA; } } } i = (8 - nbits) & 7; c >>= i; lc -= i; while (lc > 0) { const HufDec pl = hdecod[(c << (HUF_DECBITS - lc)) & HUF_DECMASK]; if (pl.len) { lc -= pl.len; get_code(pl.lit, rlc, c, lc, gb, out, oe); } else { return AVERROR_INVALIDDATA; } } if (out - outb != no) return AVERROR_INVALIDDATA; return 0; }
1threat
int ff_win32_open(const char *filename_utf8, int oflag, int pmode) { int fd; int num_chars; wchar_t *filename_w; num_chars = MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, NULL, 0); if (num_chars <= 0) return -1; filename_w = av_mallocz(sizeof(wchar_t) * num_chars); MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, filename_w, num_chars); fd = _wsopen(filename_w, oflag, SH_DENYNO, pmode); av_freep(&filename_w); if (fd == -1 && !(oflag & O_CREAT)) return _sopen(filename_utf8, oflag, SH_DENYNO, pmode); return fd; }
1threat
How do I echo a table with the combined results of two similar queries from two different databases? (using MySql/php) : I'm relatively new to coding so please bare with me with regards to this question! I have two different (yet almost identical) databases and I and trying to produce a table which will display the combined results of a query on the two databases. (In MySql workbench, these databases are completely separate, and contain the databases that are being queried, I'm not sure if that makes a difference but it may be useful to know). I need the results table to show the following: number | company | db1 count | db2 count | Number and Company are in both databases, the only difference between the two is that the count in one is different. **Eventually there will be a fifth column, which will show the difference between the two counts, but I will get to that eventually. I've looked at many different ideas with regards to getting the result I want, but I still have no idea really. Where the number in db1 and db2 are the same, I need to display the count for each. The code I have at the moment is: // Creating the connection $conn1 = new mysqli($servername, $username, $password, $db1); $conn2 = new mysqli($servername, $username, $password, $db2); // Test connection if ($conn1->connect_error) { die ("Connection failed: " . $conn1->connect_error); } elseif ($conn2->connect_error){ die("Connection failed: " . $conn2->connect_error); } $sql1 = "SELECT num.number AS Number, com.name As company, count(*) As db1 count FROM db1.db.job_processing AS jp LEFT JOIN db1.db.number AS num ON num.id=jp.number_id LEFT JOIN db1.db.company AS com on com.id=num.company_id WHERE jp.show=1 AND jp.processing_complete=1 AND jp.call_start_time BETWEEN '2016-12-17' AND '2017-01-03' GROUP BY Number ORDER BY Number LIMIT 20"; $result1 = $conn1->query($sql1); $sql2 = "SELECT num.number AS Number, com.name AS company, COUNT(*) AS db2 Count FROM db2.db.job_processing AS jp LEFT JOIN db2.db.number AS num ON num.id=jp.number_id LEFT JOIN db2.db.company AS com on com.id=num.company_id WHERE jp.show=1 AND jp.processing_complete=1 AND jp.call_start_time BETWEEN '2016-12-17' AND '2017-01-03' GROUP BY Number LIMIT 20"; $result2 = $conn2->query($sql2); if ($result1 = $conn1->query($sql1)) && ($results2 = $conn2->query($sql1)) { echo"<TABLE><caption>Total Call Count Overview</caption><TR> <TH>Number</TH> <TH>Company</TH> <TH>db1 Count</TH> <TH>db2 Count</TH></TR>"; //This is where I think my problems are arising while ($row1 = $result1->fetch_assoc()) && ($row2 = $result2->fetch_assoc()) { echo"<TR><TD>". $row1["number"]. "</TD>"; echo"<TD>". $row1["company"]. "</TD>"; echo"<TD>". $row1["db1 Count"]. "</TD>"; echo"<TD>". $row2["db2 Count"]. "</TD></TR>"; } echo"</TABLE>"; } else { echo"O Results"; } $conn1->close(); $conn2->close(); I think it's the end part where I am stuck. I have also looked at the following solution: if ($result1 = $conn1->query($sql1)) { echo"<TABLE><caption>Total Call Count Overview</caption><TR> <TH>Number</TH> <TH>Company</TH> <TH>db1 Count</TH> <TH>db2 Count</TH></TR>"; while ($row1 = $result1->fetch_assoc()) { echo"<TR><TD>". $row1["number"]. "</TD>"; echo"<TD>". $row1["company"]. "</TD>"; echo"<TD>". $row1["db1 Count"]. "</TD>"; echo"<TD>". $row2["db2 Count"]. "</TD></TR>"; } echo"</TABLE>"; } else { echo"O Results"; } if ($result2 = $conn2->query($sql2)) { echo"<TABLE><caption>Total Call Count Overview</caption><TR> <TH>Number</TH> <TH>Company</TH> <TH>db1 Count</TH> <TH>db2 Count</TH></TR>"; while ($row_devel = $result_devel->fetch_assoc()) { echo"<TR><TD>". $row1["number"]. "</TD>"; echo"<TD>". $row1["company"]. "</TD>"; echo"<TD>". $row1["db1 Count"]. "</TD>"; echo"<TD>". $row2["db2 Count"]. "</TD></TR>"; } echo"</TABLE>"; } else { echo"O Results"; } Those are just two of the solutions I've been trying. I just don't get how I can merge the two queries together, and I realise I have probably gone completely wrong in a number of places, but any assistance I could get would be much appreciated.
0debug
BlockBackend *blk_new_open(const char *filename, const char *reference, QDict *options, int flags, Error **errp) { BlockBackend *blk; BlockDriverState *bs; uint64_t perm; perm = BLK_PERM_CONSISTENT_READ; if (flags & BDRV_O_RDWR) { perm |= BLK_PERM_WRITE; } if (flags & BDRV_O_RESIZE) { perm |= BLK_PERM_RESIZE; } blk = blk_new(perm, BLK_PERM_ALL); bs = bdrv_open(filename, reference, options, flags, errp); if (!bs) { blk_unref(blk); return NULL; } blk->root = bdrv_root_attach_child(bs, "root", &child_root, perm, BLK_PERM_ALL, blk, errp); if (!blk->root) { bdrv_unref(bs); blk_unref(blk); return NULL; } return blk; }
1threat
Swift function object wrapper in apple/swift : <p>After reading: </p> <ul> <li><a href="https://github.com/rodionovd/SWRoute/wiki/Function-hooking-in-Swift" rel="noreferrer">https://github.com/rodionovd/SWRoute/wiki/Function-hooking-in-Swift</a></li> <li><a href="https://github.com/rodionovd/SWRoute/blob/master/SWRoute/rd_get_func_impl.c" rel="noreferrer">https://github.com/rodionovd/SWRoute/blob/master/SWRoute/rd_get_func_impl.c</a></li> </ul> <p>I understood that Swift function pointer is wrapped by <code>swift_func_wrapper</code> and <code>swift_func_object</code> (according to the article in 2014).</p> <p>I guess this still works in Swift 3, but I couldn't find which file in <a href="https://github.com/apple/swift" rel="noreferrer">https://github.com/apple/swift</a> best describes these structs.</p> <p>Can anyone help me?</p>
0debug
Sum digits of numbers in a list Python : Trying to write a function that takes a list like x = [1, 13, 14, 9, 8] for example and sums the digits like: 1 + (1+3) + (1+4) + 9 + 8 = 27
0debug
static void vnc_connect(VncDisplay *vd, QIOChannelSocket *sioc, bool skipauth, bool websocket) { VncState *vs = g_new0(VncState, 1); int i; vs->sioc = sioc; object_ref(OBJECT(vs->sioc)); vs->ioc = QIO_CHANNEL(sioc); object_ref(OBJECT(vs->ioc)); vs->vd = vd; buffer_init(&vs->input, "vnc-input/%p", sioc); buffer_init(&vs->output, "vnc-output/%p", sioc); buffer_init(&vs->jobs_buffer, "vnc-jobs_buffer/%p", sioc); buffer_init(&vs->tight.tight, "vnc-tight/%p", sioc); buffer_init(&vs->tight.zlib, "vnc-tight-zlib/%p", sioc); buffer_init(&vs->tight.gradient, "vnc-tight-gradient/%p", sioc); #ifdef CONFIG_VNC_JPEG buffer_init(&vs->tight.jpeg, "vnc-tight-jpeg/%p", sioc); #endif #ifdef CONFIG_VNC_PNG buffer_init(&vs->tight.png, "vnc-tight-png/%p", sioc); #endif buffer_init(&vs->zlib.zlib, "vnc-zlib/%p", sioc); buffer_init(&vs->zrle.zrle, "vnc-zrle/%p", sioc); buffer_init(&vs->zrle.fb, "vnc-zrle-fb/%p", sioc); buffer_init(&vs->zrle.zlib, "vnc-zrle-zlib/%p", sioc); if (skipauth) { vs->auth = VNC_AUTH_NONE; vs->subauth = VNC_AUTH_INVALID; } else { if (websocket) { vs->auth = vd->ws_auth; vs->subauth = VNC_AUTH_INVALID; } else { vs->auth = vd->auth; vs->subauth = vd->subauth; } } VNC_DEBUG("Client sioc=%p ws=%d auth=%d subauth=%d\n", sioc, websocket, vs->auth, vs->subauth); vs->lossy_rect = g_malloc0(VNC_STAT_ROWS * sizeof (*vs->lossy_rect)); for (i = 0; i < VNC_STAT_ROWS; ++i) { vs->lossy_rect[i] = g_new0(uint8_t, VNC_STAT_COLS); } VNC_DEBUG("New client on socket %p\n", vs->sioc); update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_BASE); qio_channel_set_blocking(vs->ioc, false, NULL); if (websocket) { vs->websocket = 1; if (vd->ws_tls) { vs->ioc_tag = qio_channel_add_watch( vs->ioc, G_IO_IN, vncws_tls_handshake_io, vs, NULL); } else { vs->ioc_tag = qio_channel_add_watch( vs->ioc, G_IO_IN, vncws_handshake_io, vs, NULL); } } else { vs->ioc_tag = qio_channel_add_watch( vs->ioc, G_IO_IN, vnc_client_io, vs, NULL); } vnc_client_cache_addr(vs); vnc_qmp_event(vs, QAPI_EVENT_VNC_CONNECTED); vnc_set_share_mode(vs, VNC_SHARE_MODE_CONNECTING); if (!vs->websocket) { vnc_init_state(vs); } if (vd->num_connecting > vd->connections_limit) { QTAILQ_FOREACH(vs, &vd->clients, next) { if (vs->share_mode == VNC_SHARE_MODE_CONNECTING) { vnc_disconnect_start(vs); return; } } } }
1threat
Is is possible in regex to allow float numbers between 0 to 2? : I need to validate text input through regex expression. Text input only accept float numbers between 0 and 2 else it through validation error. Currently I'm using this expression > ^\d+\.\d{0,2}$ But it only validate on numbers (1.0,2.0...). Following are the valid/invalid input for text. **Valid:** - 0 - 1 - 2 - 0.1 - 1.9 - 2.0 - 0.01 - 1.09 - 1.009 **Invalid:** - -1 - 3 - 2.1 - 2.01 - 2.001
0debug
static void vmxnet3_rx_need_csum_calculate(struct NetRxPkt *pkt, const void *pkt_data, size_t pkt_len) { struct virtio_net_hdr *vhdr; bool isip4, isip6, istcp, isudp; uint8_t *data; int len; if (!net_rx_pkt_has_virt_hdr(pkt)) { return; } vhdr = net_rx_pkt_get_vhdr(pkt); if (!VMXNET_FLAG_IS_SET(vhdr->flags, VIRTIO_NET_HDR_F_NEEDS_CSUM)) { return; } net_rx_pkt_get_protocols(pkt, &isip4, &isip6, &isudp, &istcp); if (!(isip4 || isip6) || !(istcp || isudp)) { return; } vmxnet3_dump_virt_hdr(vhdr); if (pkt_len < (vhdr->csum_start + vhdr->csum_offset + 2)) { VMW_PKPRN("packet len:%zu < csum_start(%d) + csum_offset(%d) + 2, " "cannot calculate checksum", pkt_len, vhdr->csum_start, vhdr->csum_offset); return; } data = (uint8_t *)pkt_data + vhdr->csum_start; len = pkt_len - vhdr->csum_start; stw_be_p(data + vhdr->csum_offset, net_raw_checksum(data, len)); vhdr->flags &= ~VIRTIO_NET_HDR_F_NEEDS_CSUM; vhdr->flags |= VIRTIO_NET_HDR_F_DATA_VALID; }
1threat
PySpark 2.0 The size or shape of a DataFrame : <p>I am trying to find out the size/shape of a DataFrame in PySpark. I do not see a single function that can do this.</p> <p>In Python I can do</p> <pre><code>data.shape() </code></pre> <p>Is there a similar function in PySpark. This is my current solution, but I am looking for an element one</p> <pre><code>row_number = data.count() column_number = len(data.dtypes) </code></pre> <p>The computation of the number of columns is not ideal...</p>
0debug
Extract strings from a list element of a certain size, : Say I have a list of names: names = ["David", "Lee", "Sara", "Daniel", "Nick"] I want to move the list elements that have a character count of less than 5 (not including 5) into a new list called short_names that would look like this: short_name ["Lee", "Sara", "Nick"] How can I do this with a for loop? Where I am struggling with is how to find the length of characters within each list element.
0debug
static void decode_rlc_opc(CPUTriCoreState *env, DisasContext *ctx, uint32_t op1) { int32_t const16; int r1, r2; const16 = MASK_OP_RLC_CONST16_SEXT(ctx->opcode); r1 = MASK_OP_RLC_S1(ctx->opcode); r2 = MASK_OP_RLC_D(ctx->opcode); switch (op1) { case OPC1_32_RLC_ADDI: gen_addi_d(cpu_gpr_d[r2], cpu_gpr_d[r1], const16); break; case OPC1_32_RLC_ADDIH: gen_addi_d(cpu_gpr_d[r2], cpu_gpr_d[r1], const16 << 16); break; case OPC1_32_RLC_ADDIH_A: tcg_gen_addi_tl(cpu_gpr_a[r2], cpu_gpr_a[r1], const16 << 16); break; case OPC1_32_RLC_MFCR: const16 = MASK_OP_RLC_CONST16(ctx->opcode); gen_mfcr(env, cpu_gpr_d[r2], const16); break; case OPC1_32_RLC_MOV: tcg_gen_movi_tl(cpu_gpr_d[r2], const16); break; case OPC1_32_RLC_MOV_64: if (tricore_feature(env, TRICORE_FEATURE_16)) { if ((r2 & 0x1) != 0) { } tcg_gen_movi_tl(cpu_gpr_d[r2], const16); tcg_gen_movi_tl(cpu_gpr_d[r2+1], const16 >> 15); } else { } break; case OPC1_32_RLC_MOV_U: const16 = MASK_OP_RLC_CONST16(ctx->opcode); tcg_gen_movi_tl(cpu_gpr_d[r2], const16); break; case OPC1_32_RLC_MOV_H: tcg_gen_movi_tl(cpu_gpr_d[r2], const16 << 16); break; case OPC1_32_RLC_MOVH_A: tcg_gen_movi_tl(cpu_gpr_a[r2], const16 << 16); break; case OPC1_32_RLC_MTCR: const16 = MASK_OP_RLC_CONST16(ctx->opcode); gen_mtcr(env, ctx, cpu_gpr_d[r1], const16); break; } }
1threat
static OutputStream *choose_output(void) { int i; int64_t opts_min = INT64_MAX; OutputStream *ost_min = NULL; for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; int64_t opts = av_rescale_q(ost->st->cur_dts, ost->st->time_base, AV_TIME_BASE_Q); if (!ost->finished && opts < opts_min) { opts_min = opts; ost_min = ost->unavailable ? NULL : ost; } } return ost_min; }
1threat
static int open_url(HLSContext *c, URLContext **uc, const char *url, AVDictionary *opts) { AVDictionary *tmp = NULL; int ret; const char *proto_name = avio_find_protocol_name(url); if (!av_strstart(proto_name, "http", NULL) && !av_strstart(proto_name, "file", NULL)) return AVERROR_INVALIDDATA; if (!strncmp(proto_name, url, strlen(proto_name)) && url[strlen(proto_name)] == ':') ; else if (strcmp(proto_name, "file") || !strcmp(url, "file,")) return AVERROR_INVALIDDATA; av_dict_copy(&tmp, c->avio_opts, 0); av_dict_copy(&tmp, opts, 0); ret = ffurl_open(uc, url, AVIO_FLAG_READ, c->interrupt_callback, &tmp); if( ret >= 0) { URLContext *u = *uc; update_options(&c->cookies, "cookies", u->priv_data); av_dict_set(&opts, "cookies", c->cookies, 0); } av_dict_free(&tmp); return ret; }
1threat
Convert jquery to react component or pure javascript : <p>I’ve the sample working jQuery code for simple To Do List. How can I change this into pure javascript or react js component.</p> <pre><code>&lt;div class="todo-list container"&gt; &lt;ul class="list-your-todo"&gt; &lt;li&gt; &lt;input type="text" name="name" class="form-control" placeholder="Name" value="" /&gt; &lt;p class="deleteList"&gt;- Delete this&lt;/p&gt; &lt;/li&gt; &lt;/ul&gt; &lt;p class="addList"&gt;+ Add another&lt;/p&gt; &lt;/div&gt; $(function(){ $('.addList').click(function(){ var $liLength = $(".list-your-todo li").length; var list = $('.todo-list').find('.list-your-todo li:first').html(); $('.todo-list ul').append('&lt;li class="clearfix showIcon"&gt;' + list + '&lt;/li&gt;'); }); $(document).on('click', '.deleteList', function(){ $(this).parent('li').remove(); }); }); </code></pre> <p>this is the working demo <a href="https://jsfiddle.net/LxyLg8hh/" rel="nofollow noreferrer">https://jsfiddle.net/LxyLg8hh/</a></p>
0debug
void memory_region_reset_dirty(MemoryRegion *mr, hwaddr addr, hwaddr size, unsigned client) { assert(mr->terminates); cpu_physical_memory_test_and_clear_dirty(mr->ram_addr + addr, size, client); }
1threat
difference between Private slots and private method in QT : <p>I am new to QT and I want to know the difference between</p> <p>1) private slot vs private class methods</p> <p>When we need to use private slot and when we need to use private methods</p>
0debug
I need help in finding the server details where the Websphere mq queue manger has been configured : I need help in finding the server details where the Websphere mq queue manger has been configured. In WAS console i see a queue manager name in the connection properties but I dont know in which server the queue manager is configure, Is there a way to find out the details ?
0debug
Get the last word of string : <p>How can I get the last word of an string if my string is like that "hello is my new car "(after the word car there is an white space).</p> <p>I want to know how remove it too.</p> <p>Thank you so much</p>
0debug
visual composer not showing on my webiste : Yesterday I worded on visual composer and it was working great. But today no visual composer element is showing. I have checked by deactivating / deleting all the 3rd party plugins but still no imporovement. Any help?? **http://www.hycubetech.co.uk/** I tried anything I could try.. but nothing I could get.. Need some wonder
0debug
Why didn´t work my OpenFileDialog : I try to open a textdocument and than i get the message: invalid file format from the try-catch. I use Visual Studio 2015 with Visual C# and Windows Forms Application. Here my code for the open function: private void openToolStripMenuItem_Click(object sender, EventArgs e) { try { // Create an OpenFileDialog to request a file to open. OpenFileDialog openFile1 = new OpenFileDialog(); // Initialize the OpenFileDialog to look for RTF files. openFile1.Filter = "Text Files (*.txt)|*.txt| RTF Files (*.rtf)|*.rtf| All (*.*)|*.*"; // Determine whether the user selected a file from the OpenFileDialog. if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK && openFile1.FileName.Length > 0) { // Load the contents of the file into the RichTextBox. TextBox.LoadFile(openFile1.FileName); } } catch (Exception a) { MessageBox.Show(a.Message); } }//end open I hope you can help me with friendly wishes sniffi.
0debug
Using FragmentContainerView with Navigation component? : <p>After updating to Navigation <a href="https://developer.android.com/jetpack/androidx/releases/navigation#2.2.0-beta01" rel="noreferrer">2.2.0-beta01</a> from the previous version, lint gives a warning about replacing the <code>&lt;fragment&gt;</code> tag with <code>FragmentContainerView</code>.</p> <p>However, replacing the tag alone seems to prevent the navigation graph from being inflated.</p> <p>According to <a href="https://developer.android.com/jetpack/androidx/releases/navigation#2.2.0-alpha01" rel="noreferrer">2.2.0-alpha01</a>, <code>FragmentContainerView</code> is used internally. Should we ignore the lint warning?</p> <hr> <p><strong>activity_main.xml</strong></p> <pre><code>&lt;androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;!-- Lint warning: "Replace the &lt;fragment&gt; tag with FragmentContainerView. --&gt; &lt;fragment android:id="@+id/nav_host_main" android:name="androidx.navigation.fragment.NavHostFragment" android:layout_width="match_parent" android:layout_height="match_parent" app:defaultNavHost="true" app:navGraph="@navigation/nav_graph_main"/&gt; &lt;!-- other elements --&gt; &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt; </code></pre>
0debug
C# - Exception while copying the array using foreach loop : Can someone tell me why i'm seeing below exception when i use foreach loop ? { 6 2 3 4 5 6 Unhandled Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array. at W3ResourceArrays.Ex7.Main() in C:\Users\SudhaPraveen\Documents\Visual Studio 2017\Projects\CSharpPractice21DaysPlan\W3ResourceArrays\Ex7.cs:line 28 } but i don't see this exception if i use for loop. One thing i have noticed is index is starting at 1 if i use foreach loop . int[] array1 = new int[] { 1, 2, 3 }; int[] array2 = new int[] { 4, 5, 6 }; int[] mergedarray = new int[array1.Length+array2.Length]; array1.CopyTo(mergedarray, 0); array2.CopyTo(mergedarray, array1.Length); Console.WriteLine(mergedarray.Length); //for (int i = 0; i < mergedarray.Length; i++) //{ // Console.WriteLine(mergedarray[i]); ; //} foreach (var item in mergedarray) { Console.Write(mergedarray[item] + " "); }
0debug
Deserialize JSON data and trim off the name ,only values : I have a JSON data loaded from database using AJAX, it has name and value pair after serializing using JavaScriptSerializer, but I need to use it without the names, only the values is needed, how can I serialize the same data without the names Original [{"Code":"af","Total":16.63},{"Code":"al","Total":11.58},{"Code":"ve","Total":285.21},{"Code":"vn","Total":101.99}] Expected [{"af":"16.63","al":"11.58","ve":"285.21","vn":"101.99"}]
0debug
static int qpa_init_in (HWVoiceIn *hw, struct audsettings *as) { int error; static pa_sample_spec ss; struct audsettings obt_as = *as; PAVoiceIn *pa = (PAVoiceIn *) hw; ss.format = audfmt_to_pa (as->fmt, as->endianness); ss.channels = as->nchannels; ss.rate = as->freq; obt_as.fmt = pa_to_audfmt (ss.format, &obt_as.endianness); pa->s = pa_simple_new ( conf.server, "qemu", PA_STREAM_RECORD, conf.source, "pcm.capture", &ss, NULL, NULL, &error ); if (!pa->s) { qpa_logerr (error, "pa_simple_new for capture failed\n"); goto fail1; } audio_pcm_init_info (&hw->info, &obt_as); hw->samples = conf.samples; pa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift); pa->wpos = hw->wpos; if (!pa->pcm_buf) { dolog ("Could not allocate buffer (%d bytes)\n", hw->samples << hw->info.shift); goto fail2; } if (audio_pt_init (&pa->pt, qpa_thread_in, hw, AUDIO_CAP, AUDIO_FUNC)) { goto fail3; } return 0; fail3: g_free (pa->pcm_buf); pa->pcm_buf = NULL; fail2: pa_simple_free (pa->s); pa->s = NULL; fail1: return -1; }
1threat
static int qcrypto_ivgen_essiv_calculate(QCryptoIVGen *ivgen, uint64_t sector, uint8_t *iv, size_t niv, Error **errp) { QCryptoIVGenESSIV *essiv = ivgen->private; size_t ndata = qcrypto_cipher_get_block_len(ivgen->cipher); uint8_t *data = g_new(uint8_t, ndata); sector = cpu_to_le64(sector); memcpy(data, (uint8_t *)&sector, ndata); if (sizeof(sector) < ndata) { memset(data + sizeof(sector), 0, ndata - sizeof(sector)); } if (qcrypto_cipher_encrypt(essiv->cipher, data, data, ndata, errp) < 0) { g_free(data); return -1; } if (ndata > niv) { ndata = niv; } memcpy(iv, data, ndata); if (ndata < niv) { memset(iv + ndata, 0, niv - ndata); } g_free(data); return 0; }
1threat
pull-right in bootstrap 4 does not work : I have [read][1] that the `pull-right` class has been removed and in its place there are classes such as `.float-{xs,sm,md,lg,xl}-{left,right,none}` - as seen in [this question][2] too. but i cant get it to work. I have setup a demo at https://jsfiddle.net/kneidels/x8Lhmajc/1/ you will see the word "menu" on the top left, which has a drop down attached. that is supposed to be floated to the right but as you can see its not working. [1]: https://v4-alpha.getbootstrap.com/migration/ [2]: https://stackoverflow.com/questions/39542435/bootstrap-4-pull-xs-right-not-working-as-expected
0debug
ReadAsMultipartAsync equvialent in .NET core 2 : <p>I'am rewriting a .net 4.5 application to aspnet core 2.0 and I have a method that i have some problem updating:</p> <pre><code> [HttpPut] [Route("api/files/{id}")] public async Task&lt;Person&gt; Put(int id) { var filesReadToProvider = await Request.Content.ReadAsMultipartAsync(); var fileStream = await filesReadToProvider.Contents[0].ReadAsStreamAsync(); return _personService.UpdatePerson(id, fileStream); } </code></pre> <p>It seems that request no longer has Content, but body. Which is fine. But how how do i read the body if it is a MimeMultipart now? </p> <p>I have looked into IFormFile, but don't I have to change something in the frontend?</p> <p>Anything that will help me in the right direction is appreciated :) </p>
0debug
Trigger jobs in gitlab-ci on merge request : <p>It's posible run a job from gitlab-ci only on merge request? Now, we have a big monolitic project with heavy tests, but we only want to run the test before merging to the branch master.</p>
0debug
int vhost_dev_init(struct vhost_dev *hdev, void *opaque, VhostBackendType backend_type) { uint64_t features; int i, r; if (vhost_set_backend_type(hdev, backend_type) < 0) { close((uintptr_t)opaque); return -1; } if (hdev->vhost_ops->vhost_backend_init(hdev, opaque) < 0) { close((uintptr_t)opaque); return -errno; } r = hdev->vhost_ops->vhost_call(hdev, VHOST_SET_OWNER, NULL); if (r < 0) { goto fail; } r = hdev->vhost_ops->vhost_call(hdev, VHOST_GET_FEATURES, &features); if (r < 0) { goto fail; } for (i = 0; i < hdev->nvqs; ++i) { r = vhost_virtqueue_init(hdev, hdev->vqs + i, i); if (r < 0) { goto fail_vq; } } hdev->features = features; hdev->memory_listener = (MemoryListener) { .begin = vhost_begin, .commit = vhost_commit, .region_add = vhost_region_add, .region_del = vhost_region_del, .region_nop = vhost_region_nop, .log_start = vhost_log_start, .log_stop = vhost_log_stop, .log_sync = vhost_log_sync, .log_global_start = vhost_log_global_start, .log_global_stop = vhost_log_global_stop, .eventfd_add = vhost_eventfd_add, .eventfd_del = vhost_eventfd_del, .priority = 10 }; hdev->migration_blocker = NULL; if (!(hdev->features & (0x1ULL << VHOST_F_LOG_ALL))) { error_setg(&hdev->migration_blocker, "Migration disabled: vhost lacks VHOST_F_LOG_ALL feature."); migrate_add_blocker(hdev->migration_blocker); } hdev->mem = g_malloc0(offsetof(struct vhost_memory, regions)); hdev->n_mem_sections = 0; hdev->mem_sections = NULL; hdev->log = NULL; hdev->log_size = 0; hdev->log_enabled = false; hdev->started = false; hdev->memory_changed = false; memory_listener_register(&hdev->memory_listener, &address_space_memory); return 0; fail_vq: while (--i >= 0) { vhost_virtqueue_cleanup(hdev->vqs + i); } fail: r = -errno; hdev->vhost_ops->vhost_backend_cleanup(hdev); return r; }
1threat
Can an end user modify a websites javascript? : <p>Lets say I have an api + unique api key that only allows 300 GETs. Whats stopping a user from changing my websites javascript code to make an infinite loop and using all that 300 GETs? </p>
0debug
Java create enum from String : <p>I have enum class </p> <pre><code>public enum PaymentType { /** * This notify type we receive when user make first subscription payment. */ SUBSCRIPTION_NEW("subscr_signup"), /** * This notify type we receive when user make subscription payment for next * month. */ SUBSCRIPTION_PAYMENT("subscr_payment"), /** * This notify type we receive when user cancel subscription from his paypal * personal account. */ SUBSCRIPTION_CANCEL("subscr_cancel"), /** * In this case the user cannot change the amount or length of the * subscription, they can however change the funding source or address * associated with their account. Those actions will generate the * subscr_modify IPN that we are receiving. */ SUBSCRIPTION_MODIFY("subscr_modify"), /** * Means that the subscription has expired, either because the subscriber * cancelled it or it has a fixed term (implying a fixed number of payments) * and it has now expired with no further payments being due. It is sent at * the end of the term, instead of any payment that would otherwise have * been due on that date. */ SUBSCRIPTION_EXPIRED("subscr_eot"), /** User have no money on card, CVV error, another negative errors. */ SUBSCRIPTION_FAILED("subscr_failed"); private String type; PaymentType(String type) { this.type = type; } String getType() { return type; } } </code></pre> <p>When I try to create enum :</p> <pre><code>PaymentType type = PaymentType.valueOf("subscr_signup"); </code></pre> <p>Java throws to me error :</p> <pre><code>IllegalArgumentException occured : No enum constant models.PaymentType.subscr_signup </code></pre> <p>How I can fix this?</p>
0debug
ASP.NET Core 2.0 URL's : I'm developing a large ASP.NET Core 2 web application but I still get confused with URL's. When fist learning, I thought URL's took on the name of the View, but discovered they come from the Controller method. Here is an example to convey my issue: I have a controller method named **Daysheet**, which returns a view and model with the same name. In the Daysheet view, I call various controller methods from Javascript to perform specific actions. One of them is called **AssignStaff** which takes two integer parameters. In the AssignStaff method I again return the Daysheet view with model, but now my URL is "AssignStaff"! I can't just do a redirect because the whole Daysheet model is not being passed to the AssignStaff method. I have many situations like this where after calling an action, I end up with another URL that I don't want.
0debug
I want to addition One array key and value with another array values : Please help me. I have fallen a Problem. I want to addition One array key and value with another array values. Here is my arrays: Array ( [6] => 12 [8] => 9 [10] => 11 ) Array ( [6] => 70 [8] => 10 [9] => 35 [10] => 25 [11] => 25 [12] => 2 ) Here Example (6 => 12 according to addition 70 + 2 ) my expected output should be: array ([0] => 72 [1] => 45 [2] => 50 ) Thanks In Advance
0debug
Drupal 8 on IIS - error installing : <p>I already had Drupal working, but then I messed up with some module (layout_plugin) which is incompatible and broke the modules settings page. I tried to remove it different ways but failed. So I decided to start from scratch. I dropped the website DB and recreated the Drupal folder from default. Unfortunately now when setting it up it does all the installation but the last step after submitting email, credentials and time properties it ends with a super long error</p> <pre><code>Warning: curl_setopt_array(): Unable to create temporary file. in GuzzleHttp\Handler\CurlFactory-&gt;create() (line 57 of vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php). GuzzleHttp\Handler\CurlFactory-&gt;create(Object, Array) (Line: 39) GuzzleHttp\Handler\CurlHandler-&gt;__invoke(Object, Array) (Line: 28) GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}(Object, Array) (Line: 51) GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}(Object, Array) (Line: 42) GuzzleHttp\PrepareBodyMiddleware-&gt;__invoke(Object, Array) (Line: 30) GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object, Array) (Line: 68) GuzzleHttp\RedirectMiddleware-&gt;__invoke(Object, Array) (Line: 59) GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object, Array) (Line: 67) GuzzleHttp\HandlerStack-&gt;__invoke(Object, Array) (Line: 275) GuzzleHttp\Client-&gt;transfer(Object, Array) (Line: 123) GuzzleHttp\Client-&gt;requestAsync('get', Object, Array) (Line: 129) GuzzleHttp\Client-&gt;request('get', 'http://updates.drupal.org/release-history/drupal/8.x?site_key=sMbmiei0HAVBa9TUtPGTQnY_kZwJIE2wWA4Kv0fbVyo&amp;amp;version=8.3.7&amp;amp;list=automated_cron%2Cblock%2Cblock_content%2Cbreakpoint%2Cckeditor%2Ccolor%2Ccomment%2Cconfig%2Ccontact%2Ccontextual%2Cdatetime%2Cdblog%2Cdynamic_page_cache%2Ceditor%2Cfield%2Cfield_ui%2Cfile%2Cfilter%2Chelp%2Chistory%2Cimage%2Clink%2Cmenu_link_content%2Cmenu_ui%2Cnode%2Coptions%2Cpage_cache%2Cpath%2Cquickedit%2Crdf%2Csearch%2Cshortcut%2Cstandard%2Csystem%2Ctaxonomy%2Ctext%2Ctoolbar%2Ctour%2Cupdate%2Cuser%2Cviews%2Cviews_ui%2Cstable%2Cbartik%2Cseven%2Cclassy', Array) (Line: 87) GuzzleHttp\Client-&gt;__call('get', Array) (Line: 65) Drupal\update\UpdateFetcher-&gt;fetchProjectData(Array, 'sMbmiei0HAVBa9TUtPGTQnY_kZwJIE2wWA4Kv0fbVyo') (Line: 160) Drupal\update\UpdateProcessor-&gt;processFetchTask(Array) (Line: 131) Drupal\update\UpdateProcessor-&gt;fetchData() (Line: 423) update_fetch_data() (Line: 249) update_cron() call_user_func_array('update_cron', Array) (Line: 391) Drupal\Core\Extension\ModuleHandler-&gt;invoke('update', 'cron') (Line: 223) Drupal\Core\Cron-&gt;invokeCronHandlers() (Line: 122) Drupal\Core\Cron-&gt;run() (Line: 75) Drupal\Core\ProxyClass\Cron-&gt;run() (Line: 1778) install_finished(Array) (Line: 662) install_run_task(Array, Array) (Line: 540) install_run_tasks(Array) (Line: 117) install_drupal(Object) (Line: 44) Warning: curl_setopt_array(): Unable to create temporary file. in GuzzleHttp\Handler\CurlFactory-&gt;create() (line 57 of vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php). GuzzleHttp\Handler\CurlFactory-&gt;create(Object, Array) (Line: 39) GuzzleHttp\Handler\CurlHandler-&gt;__invoke(Object, Array) (Line: 493) GuzzleHttp\Handler\CurlFactory::retryFailedRewind(Object, Object, Array) (Line: 147) GuzzleHttp\Handler\CurlFactory::finishError(Object, Object, Object) (Line: 103) GuzzleHttp\Handler\CurlFactory::finish(Object, Object, Object) (Line: 43) GuzzleHttp\Handler\CurlHandler-&gt;__invoke(Object, Array) (Line: 28) GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}(Object, Array) (Line: 51) GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}(Object, Array) (Line: 42) GuzzleHttp\PrepareBodyMiddleware-&gt;__invoke(Object, Array) (Line: 30) GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object, Array) (Line: 68) GuzzleHttp\RedirectMiddleware-&gt;__invoke(Object, Array) (Line: 59) GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object, Array) (Line: 67) GuzzleHttp\HandlerStack-&gt;__invoke(Object, Array) (Line: 275) GuzzleHttp\Client-&gt;transfer(Object, Array) (Line: 123) GuzzleHttp\Client-&gt;requestAsync('get', Object, Array) (Line: 129) GuzzleHttp\Client-&gt;request('get', 'http://updates.drupal.org/release-history/drupal/8.x?site_key=sMbmiei0HAVBa9TUtPGTQnY_kZwJIE2wWA4Kv0fbVyo&amp;amp;version=8.3.7&amp;amp;list=automated_cron%2Cblock%2Cblock_content%2Cbreakpoint%2Cckeditor%2Ccolor%2Ccomment%2Cconfig%2Ccontact%2Ccontextual%2Cdatetime%2Cdblog%2Cdynamic_page_cache%2Ceditor%2Cfield%2Cfield_ui%2Cfile%2Cfilter%2Chelp%2Chistory%2Cimage%2Clink%2Cmenu_link_content%2Cmenu_ui%2Cnode%2Coptions%2Cpage_cache%2Cpath%2Cquickedit%2Crdf%2Csearch%2Cshortcut%2Cstandard%2Csystem%2Ctaxonomy%2Ctext%2Ctoolbar%2Ctour%2Cupdate%2Cuser%2Cviews%2Cviews_ui%2Cstable%2Cbartik%2Cseven%2Cclassy', Array) (Line: 87) GuzzleHttp\Client-&gt;__call('get', Array) (Line: 65) Drupal\update\UpdateFetcher-&gt;fetchProjectData(Array, 'sMbmiei0HAVBa9TUtPGTQnY_kZwJIE2wWA4Kv0fbVyo') (Line: 160) Drupal\update\UpdateProcessor-&gt;processFetchTask(Array) (Line: 131) Drupal\update\UpdateProcessor-&gt;fetchData() (Line: 423) update_fetch_data() (Line: 249) update_cron() call_user_func_array('update_cron', Array) (Line: 391) Drupal\Core\Extension\ModuleHandler-&gt;invoke('update', 'cron') (Line: 223) Drupal\Core\Cron-&gt;invokeCronHandlers() (Line: 122) Drupal\Core\Cron-&gt;run() (Line: 75) Drupal\Core\ProxyClass\Cron-&gt;run() (Line: 1778) install_finished(Array) (Line: 662) install_run_task(Array, Array) (Line: 540) install_run_tasks(Array) (Line: 117) install_drupal(Object) (Line: 44) Warning: curl_setopt_array(): Unable to create temporary file. in GuzzleHttp\Handler\CurlFactory-&gt;create() (line 57 of vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php). GuzzleHttp\Handler\CurlFactory-&gt;create(Object, Array) (Line: 39) GuzzleHttp\Handler\CurlHandler-&gt;__invoke(Object, Array) (Line: 493) GuzzleHttp\Handler\CurlFactory::retryFailedRewind(Object, Object, Array) (Line: 147) GuzzleHttp\Handler\CurlFactory::finishError(Object, Object, Object) (Line: 103) GuzzleHttp\Handler\CurlFactory::finish(Object, Object, Object) (Line: 43) GuzzleHttp\Handler\CurlHandler-&gt;__invoke(Object, Array) (Line: 493) GuzzleHttp\Handler\CurlFactory::retryFailedRewind(Object, Object, Array) (Line: 147) GuzzleHttp\Handler\CurlFactory::finishError(Object, Object, Object) (Line: 103) GuzzleHttp\Handler\CurlFactory::finish(Object, Object, Object) (Line: 43) GuzzleHttp\Handler\CurlHandler-&gt;__invoke(Object, Array) (Line: 28) GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}(Object, Array) (Line: 51) GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}(Object, Array) (Line: 42) GuzzleHttp\PrepareBodyMiddleware-&gt;__invoke(Object, Array) (Line: 30) GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object, Array) (Line: 68) GuzzleHttp\RedirectMiddleware-&gt;__invoke(Object, Array) (Line: 59) GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object, Array) (Line: 67) GuzzleHttp\HandlerStack-&gt;__invoke(Object, Array) (Line: 275) GuzzleHttp\Client-&gt;transfer(Object, Array) (Line: 123) GuzzleHttp\Client-&gt;requestAsync('get', Object, Array) (Line: 129) GuzzleHttp\Client-&gt;request('get', 'http://updates.drupal.org/release-history/drupal/8.x?site_key=sMbmiei0HAVBa9TUtPGTQnY_kZwJIE2wWA4Kv0fbVyo&amp;amp;version=8.3.7&amp;amp;list=automated_cron%2Cblock%2Cblock_content%2Cbreakpoint%2Cckeditor%2Ccolor%2Ccomment%2Cconfig%2Ccontact%2Ccontextual%2Cdatetime%2Cdblog%2Cdynamic_page_cache%2Ceditor%2Cfield%2Cfield_ui%2Cfile%2Cfilter%2Chelp%2Chistory%2Cimage%2Clink%2Cmenu_link_content%2Cmenu_ui%2Cnode%2Coptions%2Cpage_cache%2Cpath%2Cquickedit%2Crdf%2Csearch%2Cshortcut%2Cstandard%2Csystem%2Ctaxonomy%2Ctext%2Ctoolbar%2Ctour%2Cupdate%2Cuser%2Cviews%2Cviews_ui%2Cstable%2Cbartik%2Cseven%2Cclassy', Array) (Line: 87) GuzzleHttp\Client-&gt;__call('get', Array) (Line: 65) Drupal\update\UpdateFetcher-&gt;fetchProjectData(Array, 'sMbmiei0HAVBa9TUtPGTQnY_kZwJIE2wWA4Kv0fbVyo') (Line: 160) Drupal\update\UpdateProcessor-&gt;processFetchTask(Array) (Line: 131) Drupal\update\UpdateProcessor-&gt;fetchData() (Line: 423) update_fetch_data() (Line: 249) update_cron() call_user_func_array('update_cron', Array) (Line: 391) Drupal\Core\Extension\ModuleHandler-&gt;invoke('update', 'cron') (Line: 223) Drupal\Core\Cron-&gt;invokeCronHandlers() (Line: 122) Drupal\Core\Cron-&gt;run() (Line: 75) Drupal\Core\ProxyClass\Cron-&gt;run() (Line: 1778) install_finished(Array) (Line: 662) install_run_task(Array, Array) (Line: 540) install_run_tasks(Array) (Line: 117) install_drupal(Object) (Line: 44) The website encountered an unexpected error. Please try again later. RuntimeException: Failed to start the session because headers have already been sent by "C:\inetpub\wwwroot\drupal-8.3.7\vendor\guzzlehttp\guzzle\src\Handler\CurlHandler.php" at line 40. in Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage-&gt;start() (line 140 of vendor\symfony\http-foundation\Session\Storage\NativeSessionStorage.php). Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage-&gt;start() (Line: 163) Drupal\Core\Session\SessionManager-&gt;startNow() (Line: 234) Drupal\Core\Session\SessionManager-&gt;regenerate(, NULL) (Line: 173) Symfony\Component\HttpFoundation\Session\Session-&gt;migrate() (Line: 557) user_login_finalize(Object) (Line: 1785) install_finished(Array) (Line: 662) install_run_task(Array, Array) (Line: 540) install_run_tasks(Array) (Line: 117) install_drupal(Object) (Line: 44) </code></pre> <p>I wonder how could I break it. When trying to remove that module I installed PHP Composer, GIT and drush (but it is somehow not connected to Drupal so not working). I suppose some of this broke it.</p>
0debug
HTTP Request, Object/Array Destructuring : <p>I have an array of objects, that are on an api.</p> <pre><code>{ "ErrorCode": 0, "ErrorMessage": null, "Warehouses": [ { "Code": null, "Name": "Depozit Fabrica", "WarehouseID": "cb4fbab4-b8db-4807-a2b0-fad710f1fd9e" }, { "Code": "3", "Name": "Depozit Magazin", "WarehouseID": "dfa08a15-e3a0-4d43-8af6-c24a9d43101c" }, { "Code": null, "Name": "Depozit Ograda", "WarehouseID": "0dc8318d-305c-4e09-a31c-aa6fd44bf2ca" } ] } </code></pre> <p>I got the "Name" of "Warehouses" showed in my DOM. These "Name" have different ID's. SO, what I'm trying to do is everytime I click on a certain "Name" object, I get its ID and further call another REST API, with this ID, that shows an assortment list for example.</p> <pre><code>async function getWarehouse() { const response = await fetch(url); const data = await response.json(); const { Warehouses } = data; for (var i = 0; i &lt; Warehouses.length; i++) { const dataItem = Warehouses[i].Name; console.log(dataItem); document.getElementById("depList").innerHTML += ` &lt;ul&gt; &lt;li class="data-item"&gt;${dataItem}&lt;/li&gt; &lt;/ul&gt; ` ... </code></pre>
0debug
How to change text in a node module package : I'm making a react web app, and I have installed a node module package that is in English (react-timelines) but I need change to Spanish, until now it's just "Today" text that I need to change to "Hoy" but when I go to the package folder inside node_module and change the text it not apply to the project. I have read something about npm link that I don't understan very well and I just want to ask that if it'snt a better way to only change that simple text. Thank you
0debug
Flutter app freezes when a TextField or TextFormField is selected : <p>I have a Flutter app that is functioning properly in all respects except when I select a TextField (or TextFormField). When I select the TextField, the cursor blinks in the TextField, but I can't type anything AND all other buttons like the floatingActionButton and the back button in the AppBar quit working. Essentially, the app appears to be frozen, but I don't get any error messages.</p> <p>After numerous attempts to fix the problem in two different pages that contain FocusNodes and TextEditingControllers, I went back to square one by incorporating a new page with code straight from Flutter's website, but the TextField in this barebones code still locks up the app.</p> <pre><code>import 'package:flutter/material.dart'; class EventDetailForm extends StatefulWidget { static const String routeName = "/events/event-detail-form"; @override _EventDetailFormState createState() =&gt; _EventDetailFormState(); } class _EventDetailFormState extends State&lt;EventDetailForm&gt; { final myController = TextEditingController(); @override void dispose() { myController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Event Detail')), body: Padding( padding: const EdgeInsets.all(16), child: TextField( controller: myController, )), floatingActionButton: FloatingActionButton( onPressed: () { return showDialog( context: context, builder: (context) { return AlertDialog( content: Text(myController.text), ); }); }, child: Icon(Icons.text_fields), ), ); } } </code></pre> <p>Unfortunately, I am not getting any error messages. The cursor just blinks in the TextField and everything else loses function and I have to quit and restart. I am not sure what else I should be considering. Does anyone have any ideas on what might be causing this?</p>
0debug
Is there a way to remove range of items in string array C# : <p>For example </p> <pre><code> private string[] oras = { "07:00AM", "07:30AM", "08:00AM", "08:30AM", "09:00AM", "10:00AM", " 10:30AM", "11:00AM", "11:30AM", "12:00PM", "12:30PM", "01:00PM", "01:30PM", "02:00PM", "02:30PM", "03:00PM", "03:30PM", "04:00PM", "04:30PM", "05:00PM", "05:30PM", "06:00PM", "06:30PM", "07:00PM", "07:30PM", "08:00PM" }; </code></pre> <p>i want to remove items between "7:00AM" and "10:30AM"</p>
0debug
Vector force magnitude conversion to other direction : <p>I need some help on solving a simple vector force physics question.</p> <p>Given a force vector (x, y), how to calculate the magnitude of the force apply on the direction (i, j) ?</p> <p>(For example, given (1, 0) the magnitude of the force apply on the direction (0, 1) should be 0, and given (1, 0) the magnitude of the force apply on the direction (-1, 0) should be -1)</p> <p>Thank you very much!</p>
0debug
static void stellaris_enet_unrealize(DeviceState *dev, Error **errp) { stellaris_enet_state *s = STELLARIS_ENET(dev); unregister_savevm(DEVICE(s), "stellaris_enet", s); memory_region_destroy(&s->mmio); }
1threat
how to use mutiple inner joins : How can I create a single sql comman to display the statements of accounts of one of the customer using inner join? help please, thanks. [![enter image description here][1]][1] [1]: http://i.stack.imgur.com/pes5w.png
0debug
static void raise_mmu_exception(CPUMIPSState *env, target_ulong address, int rw, int tlb_error) { CPUState *cs = CPU(mips_env_get_cpu(env)); int exception = 0, error_code = 0; if (rw == MMU_INST_FETCH) { error_code |= EXCP_INST_NOTAVAIL; } switch (tlb_error) { default: case TLBRET_BADADDR: if (rw == MMU_DATA_STORE) { exception = EXCP_AdES; } else { exception = EXCP_AdEL; } break; case TLBRET_NOMATCH: if (rw == MMU_DATA_STORE) { exception = EXCP_TLBS; } else { exception = EXCP_TLBL; } error_code |= EXCP_TLB_NOMATCH; break; case TLBRET_INVALID: if (rw == MMU_DATA_STORE) { exception = EXCP_TLBS; } else { exception = EXCP_TLBL; } break; case TLBRET_DIRTY: exception = EXCP_LTLBL; break; case TLBRET_XI: if (env->CP0_PageGrain & (1 << CP0PG_IEC)) { exception = EXCP_TLBXI; } else { exception = EXCP_TLBL; } break; case TLBRET_RI: if (env->CP0_PageGrain & (1 << CP0PG_IEC)) { exception = EXCP_TLBRI; } else { exception = EXCP_TLBL; } break; } env->CP0_BadVAddr = address; env->CP0_Context = (env->CP0_Context & ~0x007fffff) | ((address >> 9) & 0x007ffff0); env->CP0_EntryHi = (env->CP0_EntryHi & env->CP0_EntryHi_ASID_mask) | (address & (TARGET_PAGE_MASK << 1)); #if defined(TARGET_MIPS64) env->CP0_EntryHi &= env->SEGMask; env->CP0_XContext = (env->CP0_XContext & ((~0ULL) << (env->SEGBITS - 7))) | (extract64(address, 62, 2) << (env->SEGBITS - 9)) | (extract64(address, 13, env->SEGBITS - 13) << 4); #endif cs->exception_index = exception; env->error_code = error_code; }
1threat
How to convert SMILE into TEXT (android) : <p>I have Android 4.4, and someone messaged me unknown smile (to be true, most of smiles are strange to me), and I dont know which combination was used for that smile, </p> <pre><code>:* :P or i something other i dont know </code></pre> <p>how can i know, which combination was used? Have I to type every combination manually to find that?</p>
0debug
Why is 'should equal' comming in between for the output ? And why is it repeating? : def alphabet_position(text): a= range(1,27) z="" b=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] o=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] for i in text: if i in b: k=b.index(i) z=z+" "+ str(a[k]) elif i in o: k=o.index(i) z=z +" "+ str(a[k]) else: pass return(z) Output: ' 20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5 12 22 5 15 3 12 15 3 11' should equal '20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5 12 22 5 15 3 12 15 3 11' Input: test.assert_equals(alphabet_position("The sunset sets at twelve o' clock."), "20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5 12 22 5 15 3 12 15 3 11") Why is 'should equal' comming in between for the output ? And why is it repeating ?
0debug
Webapp with Python back-end. Should I use AWS Lambda? : <p>I want to build a webapp with Python back-end. The front-end of the webapp will just have a simple input box where the user puts an address. Then, on the back-end I want to scrape content from the webpage in that address and then process that data. This data processing might become quite heavy.</p> <p>I'm quite experienced with Python, although with webapps, hosting, and so on, I have zero experience. I bought a domain name and hosting on namecheap, even though I just found out that maybe I won't be needing to use their hosting, as someone in /r/webhosting recommended me to use AWS instead. This was the methodology I was recommended to follow:</p> <blockquote> <ul> <li>switch to AWS (or Azure)</li> <li>create python lambda/function to do whatever you want to do with this request...</li> <li>put lambda behind api-gateway</li> <li>put Cloudfront in front of api-gateway (optional but hey..)</li> </ul> </blockquote> <p>I have seen tutorials to point the namecheap domain into an EC2 instance. But how do I go about doing this with Lambda? Is it the same principle? Can you point me to any tutorials that might teach me how to handle this? Is Lambda actually the optimal solution for this?</p> <p>Thanks!</p>
0debug
Why is my C program skipping over if statements? : <p>I am a new coder and have no idea what I am doing please help!</p> <p>The code is reading and taking inputs just fine until it reaches the scanf(" %c", &amp;i);then it skips to the Amount print seemingly ignoring my if statements.Is there somthing wrong with my use of scanF?</p> <p>Here is the code:</p> <pre><code>#include &lt;stdio.h&gt; int main(){ printf("BANK ACCOUNT PROGRAM!\n--------------------\n"); char W,F,A,i,D; int t=1; double b,d; while (t=1){ printf("Enter the old balance:\n"); scanf(" %lf", &amp;b); printf(" %lf", b); if(b&gt;=0) { printf("Enter the transactions now!\n Enter an F for the transaction type when you are finished.\n"); printf("Transaction Type (D=deposit, W=withdrawal, F=finished):\n"); scanf(" %c", &amp;i); if(i=F){ printf("Your ending balance is"); printf(" %lf", b); printf("\n Program is ending!"); return 0; } if(i=W){ printf("Amount:"); scanf(" %f", &amp;d); b= b-d; printf(" %f",b);} } if(b&lt;0); { printf("The balance must be maintained above zero!\n"); } } return 0; } </code></pre>
0debug
C# Remove unused index in an array with a declared size. : I have a programming homework where we are required to use methods to ask for input, store them in an array, and then use a sentinel value or until the array is filled, displays all the content of the array. So far, the program works but my problem is whenever I don't fill up the array (exiting with a sentinel value) and then displaying it, it shows a bunch of zeroes with the unused index. For example: int [] sample = new int[5]; // max size of array // user input 3 numbers with loop (for ex. 1, 2, 3 and then exits with 555) how do I make it display as 1 2 3 instead of 1 2 3 0 0
0debug
static void ehci_mem_writeb(void *ptr, target_phys_addr_t addr, uint32_t val) { fprintf(stderr, "EHCI doesn't handle byte writes to MMIO\n"); exit(1); }
1threat
Bad performance of UIStackView within UICollectionViewCells : <p>I am using <code>UIStackView</code> to layout <code>UILabels</code> in my <code>UICollectionViewCell</code> subclass. I'm using the iOS SDK 9.2</p> <p>The scrolling of the collection view is smooth if I don't update the labels' <code>text</code> when I dequeue them. However, if I update their <code>text</code> as I dequeue them, the scrolling is very slow. </p> <p>I made a very small demo to show the problem, to be ran on a device (not the simulator). You can create a new empty project and replace the contents of <code>ViewController.swift</code> with this:</p> <pre><code>import UIKit class ViewController: UIViewController { override func loadView() { view = UIView() let layout = UICollectionViewFlowLayout() layout.itemSize = CGSize(width: 100, height: 200) let collectionView = UICollectionView(frame: CGRectZero, collectionViewLayout: layout) collectionView.registerClass(Cell.self, forCellWithReuseIdentifier: "Cell") collectionView.translatesAutoresizingMaskIntoConstraints = false collectionView.dataSource = self view.addSubview(collectionView) let constraints = ["H:|-[collectionView]-|", "V:|[collectionView]|" ].flatMap { NSLayoutConstraint.constraintsWithVisualFormat($0, options: [], metrics: nil, views: ["collectionView": collectionView]) } NSLayoutConstraint.activateConstraints(constraints) } } extension ViewController: UICollectionViewDataSource { func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -&gt; UICollectionViewCell { let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! Cell //comment out the line below to make the scrolling smoother: cell.fillLabels() return cell } func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int { return 100 } } class Cell: UICollectionViewCell { var labelArray = [UILabel]() func fillLabels() { for label in labelArray { label.text = "\(label.text!) yo" } } override init(frame: CGRect) { super.init(frame: frame) contentView.backgroundColor = UIColor.whiteColor() let stackView = UIStackView() stackView.axis = .Horizontal stackView.alignment = .Leading stackView.distribution = .EqualSpacing stackView.translatesAutoresizingMaskIntoConstraints = false contentView.addSubview(stackView) let leftStack = UIStackView() leftStack.axis = .Vertical let rightStack = UIStackView() rightStack.axis = .Vertical stackView.addArrangedSubview(leftStack) stackView.addArrangedSubview(rightStack) for index in 0...10 { let leftLabel = UILabel() leftLabel.text = "\(index)" leftStack.addArrangedSubview(leftLabel) labelArray.append(leftLabel) let rightLabel = UILabel() rightLabel.text = "\(index)" rightStack.addArrangedSubview(rightLabel) labelArray.append(rightLabel) } let constraints = [ "H:|[stackView]|", "V:|[stackView]|" ].flatMap { NSLayoutConstraint.constraintsWithVisualFormat($0, options: [], metrics: nil, views: ["stackView": stackView]) } NSLayoutConstraint.activateConstraints(constraints) } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } } </code></pre> <p>You'll notice the scrolling is smooth when you comment out the call to <code>fillLabels</code>. </p> <p>If you try to reproduce the same layout without <code>UIStackViews</code> and include the call <code>fillLabels</code>, you'll notice the scrolling is smooth too.</p> <p>This suggests <code>UIStackView</code> suffers performance bottlenecks if it has recalculate its layout. </p> <p>Is this hypothesis correct? Are there some solutions?</p>
0debug
ngrx effect unit test mulitple actions in mergemap : <p>I am using ngrx library and have an effect like this</p> <pre><code>@Effect() loadCollection$: Observable&lt;Action&gt; = this.actions$ .ofType(authAction.GET_USER) .startWith(new authAction.GetUserAction()) // call on app load .switchMap(() =&gt; this.service.getUser() .mergeMap((user: User) =&gt; [ new authAction.GetUserCompleteAction(user), new navigationAction.GetLinksCompleteAction(user.role) ]) ); </code></pre> <p>I am writing spec for it and it looks like this </p> <pre><code> actions = new ReplaySubject(2); actions.next(new auth.GetUserAction()); effects.loadCollection$.subscribe(result =&gt; { expect(service.getUser).toHaveBeenCalled(); expect(result).toEqual(new navigation.GetLinksCompleteAction('test')); --&gt; this line fails }); </code></pre> <p>How can I expect that multiple actions were called in the merge map.</p>
0debug
Using 'rvest' to extract links : <p>I am trying to scrap data from Yelp. One step is to extract links from each restaurant. For example, I search restaurants in NYC and get some results. Then I want to extract the links of all the 10 restaurants Yelp recommends on page 1. Here is what I have tried:</p> <pre><code>library(rvest) page=read_html("http://www.yelp.com/search?find_loc=New+York,+NY,+USA") page %&gt;% html_nodes(".biz-name span") %&gt;% html_attr('href') </code></pre> <p>But the code always returns 'NA'. Can anyone help me with that? Thanks!</p>
0debug
AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms, enum AVSampleFormat sample_fmt, int size, int64_t channel_layout, int planar) { AVFilterBuffer *samples = av_mallocz(sizeof(AVFilterBuffer)); AVFilterBufferRef *ref = NULL; int i, sample_size, chans_nb, bufsize, per_channel_size, step_size = 0; char *buf; if (!samples || !(ref = av_mallocz(sizeof(AVFilterBufferRef)))) goto fail; ref->buf = samples; ref->format = sample_fmt; ref->audio = av_mallocz(sizeof(AVFilterBufferRefAudioProps)); if (!ref->audio) goto fail; ref->audio->channel_layout = channel_layout; ref->audio->size = size; ref->audio->planar = planar; ref->perms = perms | AV_PERM_READ; samples->refcount = 1; samples->free = ff_avfilter_default_free_buffer; sample_size = av_get_bits_per_sample_fmt(sample_fmt) >>3; chans_nb = av_get_channel_layout_nb_channels(channel_layout); per_channel_size = size/chans_nb; ref->audio->nb_samples = per_channel_size/sample_size; for (i = 0; i < chans_nb; i++) samples->linesize[i] = planar > 0 ? per_channel_size : sample_size; memset(&samples->linesize[chans_nb], 0, (8-chans_nb) * sizeof(samples->linesize[0])); bufsize = (size + 15)&~15; buf = av_malloc(bufsize); if (!buf) goto fail; samples->data[0] = buf; if (buf && planar) { for (i = 1; i < chans_nb; i++) { step_size += per_channel_size; samples->data[i] = buf + step_size; } } else { for (i = 1; i < chans_nb; i++) samples->data[i] = buf; } memset(&samples->data[chans_nb], 0, (8-chans_nb) * sizeof(samples->data[0])); memcpy(ref->data, samples->data, sizeof(ref->data)); memcpy(ref->linesize, samples->linesize, sizeof(ref->linesize)); return ref; fail: av_free(buf); if (ref && ref->audio) av_free(ref->audio); av_free(ref); av_free(samples); return NULL; }
1threat
static void pollfds_cleanup(Notifier *n, void *unused) { g_assert(npfd == 0); g_free(pollfds); g_free(nodes); nalloc = 0; }
1threat
Electron Application with plugin modules : <p>I am looking to build an application that has cross platform with a plugin architecture. I see that <strong>Electron</strong> is a good fit for kind of requirement, however I am unable to understand how the plugin architecture can be implemented in electron.</p> <p>Think of this as a tool that will evolve over time with team adding new functionalities over time. I am looking at making this as a plugin and delivered to the app to enable new features (UI + Logic) once the application is deployed. </p> <p>I am really new to both <code>NodeJs</code> and <code>electron</code> so this may sound very basic ask, however I have been looking around the net but can't see any explanation on how to address my requirement. Can someone please help me point to the right resources on the net. </p> <p>Regards Kiran</p>
0debug
def check_valid(test_tup): res = not any(map(lambda ele: not ele, test_tup)) return (res)
0debug
why I can not compile this file? : I write some c++ code in visual studio(VS), which uses some command line parameters(argc,argv). But i can't compile it in VS. The mistake is that the debugger stops working. The project is Win32 Console application. [1]: https://i.stack.imgur.com/vWsdN.png
0debug