problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
function returns undefined when I want to find documents from dababase in mongoose : <p>As I said, I want to create a function that have to arguments, username and email. If one of them is in the database, then user can't register.</p>
<pre><code>function checkAll(username, email) {
let num = 0;
User.find({}, (err, result) => {
if (err) throw err;
for (let i = 0; i < result.length; i++) {
if (username === result[i].username || email === result[i].email) {
num++;
}
}
db.close();
if (num == 0) {
return true;
}
return false;
});
}
console.log(checkAll("test", "test@test.com"));
</code></pre>
<p>I know that <code>User.find()</code> is an asynchronous function that have a second arguments that it is a callback, but my question is: <strong>Why does it return undefined??</strong></p>
| 0debug
|
How to make a picture(.png) act as a button? : I am using dreamweaver for the first time to code. I am intermediate in HTML. I've been trying to use a .png file as a button. I've found some sources stating that a
<button src=Home_button> </button>
will work, but I have tried it, and to no avail, it does not work. Any suggestions. NOTE: I am also using a CSS to build this *Very* basic website.
Cheers guys! And many thanks!
| 0debug
|
Generate a prettier plot with the data : <p>I am looking for all prettier ways to represent my data in any plots. I hope can get more suggestions so that I can learn and note as reference. So please do provide me with more examples of any idea you have. Thank you.</p>
<pre><code>import pandas as pd
a = pd.DataFrame({"label":["a","b","c","d"],
"value1":[2,4,6,8],
"value2":[11,12,13,14],
"value3":[5,6,7,8]})
fig = plt.figure(figsize=(20,20))
plt.subplot(2, 2, 1)
plt.plot(a.label, a.value1, "r--", linewidth=5, label="a")
plt.plot(a.label, a.value2, "b-", linewidth=5, label="b")
plt.plot(a.label, a.value3, "g-", linewidth=5, label="c")
plt.legend()
plt.show()
</code></pre>
<p>Above is my plot. But it is not really that nice though.</p>
| 0debug
|
static int decode_dc_progressive(MJpegDecodeContext *s, int16_t *block,
int component, int dc_index,
int16_t *quant_matrix, int Al)
{
int val;
s->bdsp.clear_block(block);
val = mjpeg_decode_dc(s, dc_index);
if (val == 0xfffff) {
av_log(s->avctx, AV_LOG_ERROR, "error dc\n");
return AVERROR_INVALIDDATA;
}
val = (val * (quant_matrix[0] << Al)) + s->last_dc[component];
s->last_dc[component] = val;
block[0] = val;
return 0;
}
| 1threat
|
static void do_token_setup(USBDevice *s, USBPacket *p)
{
int request, value, index;
if (p->iov.size != 8) {
p->status = USB_RET_STALL;
return;
}
usb_packet_copy(p, s->setup_buf, p->iov.size);
p->actual_length = 0;
s->setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6];
s->setup_index = 0;
request = (s->setup_buf[0] << 8) | s->setup_buf[1];
value = (s->setup_buf[3] << 8) | s->setup_buf[2];
index = (s->setup_buf[5] << 8) | s->setup_buf[4];
if (s->setup_buf[0] & USB_DIR_IN) {
usb_device_handle_control(s, p, request, value, index,
s->setup_len, s->data_buf);
if (p->status == USB_RET_ASYNC) {
s->setup_state = SETUP_STATE_SETUP;
}
if (p->status != USB_RET_SUCCESS) {
return;
}
if (p->actual_length < s->setup_len) {
s->setup_len = p->actual_length;
}
s->setup_state = SETUP_STATE_DATA;
} else {
if (s->setup_len > sizeof(s->data_buf)) {
fprintf(stderr,
"usb_generic_handle_packet: ctrl buffer too small (%d > %zu)\n",
s->setup_len, sizeof(s->data_buf));
p->status = USB_RET_STALL;
return;
}
if (s->setup_len == 0)
s->setup_state = SETUP_STATE_ACK;
else
s->setup_state = SETUP_STATE_DATA;
}
p->actual_length = 8;
}
| 1threat
|
JAVA-SQL QUERY TO TO EXTRACT DATA FROM TWO TABLES : Select concat(substr(T_data,1,9),'001 ') AS Test_Data from DB1.T1 ;
Select * from DB1.T2 WHERE Test_Data = 'Test_Data';
I need to join the DB1.T1 and DB1.T2 based on Test_Data
| 0debug
|
create multiple folders using loops in python : <p>I want to write a function in python that creates a folder everytime a given condition is true. I don't know how many times this condition will be fulfilled. It will be like </p>
<p>step_1 condition true create folder1
step_2 condition true create folder2
...
step_n condition true create foldern</p>
| 0debug
|
static int setup_hwaccel(AVCodecContext *avctx,
const enum AVPixelFormat fmt,
const char *name)
{
AVHWAccel *hwa = find_hwaccel(avctx->codec_id, fmt);
int ret = 0;
if (!hwa) {
"Could not find an AVHWAccel for the pixel format: %s",
name);
return AVERROR(ENOENT);
if (hwa->capabilities & HWACCEL_CODEC_CAP_EXPERIMENTAL &&
avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
av_log(avctx, AV_LOG_WARNING, "Ignoring experimental hwaccel: %s\n",
hwa->name);
return AVERROR_PATCHWELCOME;
if (hwa->priv_data_size) {
avctx->internal->hwaccel_priv_data = av_mallocz(hwa->priv_data_size);
if (!avctx->internal->hwaccel_priv_data)
return AVERROR(ENOMEM);
if (hwa->init) {
ret = hwa->init(avctx);
if (ret < 0) {
av_freep(&avctx->internal->hwaccel_priv_data);
return ret;
avctx->hwaccel = hwa;
return 0;
| 1threat
|
static uint16_t qvirtio_pci_get_queue_size(QVirtioDevice *d)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
return qpci_io_readw(dev->pdev, dev->addr + VIRTIO_PCI_QUEUE_NUM);
}
| 1threat
|
A computed column in SQL server to do this : I need to update an SQL server computed column with an autogenerate serial based on a ```SELECT ``` date time ascend.
Here is the algorithm on my mind.
```
alter table
select records order by datetime_col desc
update column_of_interest
from_above_table
auto_increment value (1..n)
where
following datetime_col desc and also
let auto_increment be unique for each location_col
```
For now my column of interest is null.
I need to populate my column of interest based on the above.
| 0debug
|
Getting the number of lines in a text file in R : <p>I have text file I am reading into R. eack line of text is the full name of a NCDF4 file. i would like to get a count of the number of files recorded in the test file. Surley there is a little bit of code to do that simpley</p>
| 0debug
|
C# get private method by reflection from another class and invoke it : <p>In Java you can invoke a private method like so:</p>
<pre><code>Method m = obj.getClass().getDeclaredMethod("foo", null);
m.setAccessible(true);
m.invoke("bar");
</code></pre>
<p>What is the equivalence in C#? I need to call a private method in the Unit Test. </p>
| 0debug
|
static int iscsi_truncate(BlockDriverState *bs, int64_t offset)
{
IscsiLun *iscsilun = bs->opaque;
Error *local_err = NULL;
if (iscsilun->type != TYPE_DISK) {
return -ENOTSUP;
}
iscsi_readcapacity_sync(iscsilun, &local_err);
if (local_err != NULL) {
error_free(local_err);
return -EIO;
}
if (offset > iscsi_getlength(bs)) {
return -EINVAL;
}
if (iscsilun->allocationmap != NULL) {
g_free(iscsilun->allocationmap);
iscsilun->allocationmap = iscsi_allocationmap_init(iscsilun);
}
return 0;
}
| 1threat
|
static void decor_c(int32_t *dst, const int32_t *src, int coeff, ptrdiff_t len)
{
int i;
for (i = 0; i < len; i++)
dst[i] += (int)(src[i] * (SUINT)coeff + (1 << 2)) >> 3;
}
| 1threat
|
Multiple Zip File downloading using node js : <p>I have node js application where i want to download muliple zip files . There is list off files when user click on download icon downloading should start with downloading size and when user clicked on pause icon it should pause and it should show play option same with stop . </p>
| 0debug
|
How to randomise text in c#? : <p>I want to make a c# program which generates random numbers, but I can't find how to.
The code I've come up with so far:</p>
<pre><code>using System;
namespace DigitalDice
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("[1]");
}
}
}
</code></pre>
<p>I just need a way to make random words, the example I'm looking for is how to randomise with 2 different outputs, then I can change it to how I like it.</p>
| 0debug
|
static av_always_inline void filter_level_for_mb(VP8Context *s, VP8Macroblock *mb, VP8FilterStrength *f )
{
int interior_limit, filter_level;
if (s->segmentation.enabled) {
filter_level = s->segmentation.filter_level[s->segment];
if (!s->segmentation.absolute_vals)
filter_level += s->filter.level;
} else
filter_level = s->filter.level;
if (s->lf_delta.enabled) {
filter_level += s->lf_delta.ref[mb->ref_frame];
filter_level += s->lf_delta.mode[mb->mode];
}
#define POW2CLIP(x,max) (((x) & ~max) ? (-(x))>>31 & max : (x));
filter_level = POW2CLIP(filter_level, 63);
interior_limit = filter_level;
if (s->filter.sharpness) {
interior_limit >>= s->filter.sharpness > 4 ? 2 : 1;
interior_limit = FFMIN(interior_limit, 9 - s->filter.sharpness);
}
interior_limit = FFMAX(interior_limit, 1);
f->filter_level = filter_level;
f->inner_limit = interior_limit;
f->inner_filter = !mb->skip || mb->mode == MODE_I4x4 || mb->mode == VP8_MVMODE_SPLIT;
}
| 1threat
|
What is the latest version of SSMS on 32 bits? (SQL Server Management Studio) : <p>I need the latest version of SSMS on 32 bits.</p>
<p>I found that current version 17.x works only on 64 bits.</p>
<p>Also I found a list of previouos versions but cannot tell which one is for 32 bits:
<a href="https://docs.microsoft.com/en-us/sql/ssms/sql-server-management-studio-changelog-ssms#previous-ssms-releases" rel="noreferrer">https://docs.microsoft.com/en-us/sql/ssms/sql-server-management-studio-changelog-ssms#previous-ssms-releases</a></p>
<p>Please help!</p>
| 0debug
|
def check_tuples(test_tuple, K):
res = all(ele in K for ele in test_tuple)
return (res)
| 0debug
|
Complicated logic that Nodejs is not good at : <p>I've heard that nodejs is not good for applications that apply complicated logic. Can I get an example of this?</p>
<p>I've also heard the same thing about cpu intensive tasks. Can I get a basic example of this too?</p>
| 0debug
|
int ff_http_do_new_request(URLContext *h, const char *uri)
{
HTTPContext *s = h->priv_data;
AVDictionary *options = NULL;
int ret;
ret = http_shutdown(h, h->flags);
if (ret < 0)
return ret;
s->end_chunked_post = 0;
s->chunkend = 0;
s->off = 0;
s->icy_data_read = 0;
av_free(s->location);
s->location = av_strdup(uri);
if (!s->location)
return AVERROR(ENOMEM);
ret = http_open_cnx(h, &options);
av_dict_free(&options);
return ret;
| 1threat
|
Html multiple select element accessibility : <p>In our web application we have a search form which contains a field for which a user can select one or more answers from a list of possible options. We currently use the "select" html element with the "multiple" attribute set as in the example below:</p>
<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>select {
width: 150px;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><select multiple>
<option value="A">Alice</option>
<option value="B">Bob</option>
<option value="F">Fred</option>
<option value="K">Kevin</option>
<option value="M">Mary</option>
<option value="S">Susan</option>
</select></code></pre>
</div>
</div>
</p>
<p>Feedback from user testing has shown that this solution is confusing for users. Multiple selection/deselection is performed by holding down the Ctrl key (on windows), however many users were unaware of this.</p>
<p>The element also does not seem to allow for easy use when using just a keyboard - this is obviously an accessibility issue.</p>
<p>Is there a "best practice", accessible way of displaying an input with multiple options to a user?</p>
| 0debug
|
Detect swipe left in React Native : <p>How can I detect a left swipe on the entire screen in React Native?</p>
<p>Would it be necessary to use PanResponder or can it be done a little more easy?</p>
| 0debug
|
Update a Localtime object from LocalTime.of() method on the java console : <p>I'm having a little issue here if anyone could help me with it I would really appreciate it ! </p>
<p>When I try to update a <code>LocalTime</code> object created from the <code>LocalTime.now()</code> method so I can see time passing, <strong>it works</strong> here is the code : </p>
<pre><code> public static void main(String[] args) {
LocalTime d = LocalTime.now();
String h = String.valueOf(d.getHour());
String m = String.valueOf(d.getMinute());
String s = String.valueOf(d.getSecond());
System.out.print("\r"+h + ":" + m + ":" + s);
//Update :
Thread.sleep(1000);
}
</code></pre>
<p>Output :</p>
<pre><code>1:53:2 (time is passing)
</code></pre>
<p>But when I run this : </p>
<pre><code> public static void main(String[] args) {
LocalTime d = LocalTime.of(12, 15, 33);
String h = String.valueOf(d.getHour());
String m = String.valueOf(d.getMinute());
String s = String.valueOf(d.getSecond());
System.out.print("\r"+h + ":" + m + ":" + s);
//Update :
Thread.sleep(1000);
}
</code></pre>
<p>Output : </p>
<pre><code>12:15:33 (time is not passing)
</code></pre>
<p>Can someone tell me why it's not updating ? And how can I get time running with a <code>LocalTime</code> object from a user input ?</p>
<p>Thanks a lot for your time !</p>
| 0debug
|
time and date using localtime fucntion : I'm trying to get customized date and time output using perl. Can someone help to get the code to get the output as desired. (See the expected output below)
#!/usr/bin/perl -w
use POSIX;
my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time);
$year += 1900;
print "$sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst\n";
$now_string = localtime;
print "$now_string\n";
$date = strftime "%a %b %e %H:%M:%S %Y", localtime;
print "Date1 is : $date\n";
$date = strftime "%a-%B-%e", localtime;
print "Date2 is : $date\n";
$time = strftime "%H:%M:%S", localtime;
print "Time1 is : $time\n";
$time1 = strftime "%h:%m:%s", localtime;
print "Time2 is : $time1\n";
#OUTPUT
#Date1 is : 06-Oct-2017
#Date2 is : 06-10-2017
#Time1 is : 23:35:10
#Time2 is : 11:35:10 PM </p>
| 0debug
|
e1000_mmio_write(void *opaque, hwaddr addr, uint64_t val,
unsigned size)
{
E1000State *s = opaque;
unsigned int index = (addr & 0x1ffff) >> 2;
if (index < NWRITEOPS && macreg_writeops[index]) {
macreg_writeops[index](s, index, val);
} else if (index < NREADOPS && macreg_readops[index]) {
DBGOUT(MMIO, "e1000_mmio_writel RO %x: 0x%04"PRIx64"\n", index<<2, val);
} else {
DBGOUT(UNKNOWN, "MMIO unknown write addr=0x%08x,val=0x%08"PRIx64"\n",
index<<2, val);
}
}
| 1threat
|
Xamarin.Forms Page BackgroundImage property : <p>How are you supposed to set the background image for a Page, as the BackgroundImage is a string? I would greatly appreciate any suggestions.</p>
<p>So far I've tried:</p>
<pre><code>MainPage = new ContentPage
{
BackgroundImage = "Images/image.png"
}
</code></pre>
<p>which does not work. The image file is located in the PCL project.</p>
| 0debug
|
int nbd_client_co_pdiscard(BlockDriverState *bs, int64_t offset, int count)
{
NBDClientSession *client = nbd_get_client_session(bs);
NBDRequest request = {
.type = NBD_CMD_TRIM,
.from = offset,
.len = count,
};
NBDReply reply;
ssize_t ret;
if (!(client->nbdflags & NBD_FLAG_SEND_TRIM)) {
return 0;
}
nbd_coroutine_start(client, &request);
ret = nbd_co_send_request(bs, &request, NULL);
if (ret < 0) {
reply.error = -ret;
} else {
nbd_co_receive_reply(client, &request, &reply, NULL);
}
nbd_coroutine_end(bs, &request);
return -reply.error;
}
| 1threat
|
counting howmany numbers greater than 5 in a given array :
#having an error saying that prototype not terminated at filename.txt line #number 113 where as line number 113 belongs to a different program which is #running successfully.
sub howmany( my @H = @_;
my $m = 0;
foreach $x (@H)
{
if ( $x > 5 )
{
$m +=1;
}
else
{
$m +=0;
}
print"Number of elements greater than 5 is equal to: $m \n";
}
howmany(1,6,9);
| 0debug
|
static void set_gsi(KVMState *s, unsigned int gsi)
{
assert(gsi < s->max_gsi);
s->used_gsi_bitmap[gsi / 32] |= 1U << (gsi % 32);
}
| 1threat
|
Retieve and save the Dynamic added control in WPF Xaml? : Hi I have a **Add** Button When I click on it through Command I add it to a collection.
<ItemsControl ItemsSource="{Binding Collection}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid DataContext="{StaticResource VieWModel}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="15*"/>
<ColumnDefinition Width="40*"/>
</Grid.ColumnDefinitions>
<Label Content="GH" Grid.Row="0" Grid.Column="0" VerticalContentAlignment="Center"></Label>
<tk:RadComboBox Grid.Row="0" Grid.Column="0" Margin="10" IsFilteringEnabled="True" Width="150" DisplayMemberPath="D" IsEditable="True" ItemsSource="{Binding GK}" SelectedItem="{Binding SK, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding SelectionChangedCommand}" CommandParameter="{Binding}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</tk:RadComboBox>
<Label Content="HB" Grid.Row="0" Grid.Column="1" VerticalContentAlignment="Center"></Label>
<tk:RadComboBox Grid.Row="0" Grid.Column="1" Margin="10" IsFilteringEnabled="True" Name="cb" Width="350" IsEditable="True" DisplayMemberPath="D" ItemsSource="{Binding VR}" SelectedItem="{Binding VR1,Mode=TwoWay}">
</tk:RadComboBox>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Whenever I click the **Add Button** this itemplate will be added.
**MyRequirement** :
1. When I Click **Add Button** for the first time ,template should get added
2. When I click **Add Button** for the second time Previous generated controls Must have contain the values,only then controls should be created
3. And I dont know how to save those values dynamically created in a collection
I am running out of Ideas how to achieve this can anyone help . **MVVM pattern**
| 0debug
|
static void vfio_put_device(VFIOPCIDevice *vdev)
{
QLIST_REMOVE(vdev, next);
vdev->vbasedev.group = NULL;
trace_vfio_put_device(vdev->vbasedev.fd);
close(vdev->vbasedev.fd);
g_free(vdev->vbasedev.name);
if (vdev->msix) {
g_free(vdev->msix);
vdev->msix = NULL;
}
}
| 1threat
|
R4DS error comparison (1) is possible only for atomic and list types : <p>In R4DS Section 3.6, the authors present the following code:</p>
<pre><code>ggplot(data = mpg, mapping = aes(x = displ, y = hwy)) +
geom_point(mapping = aes(color = class)) +
geom_smooth(data = filter(mpg, class == "subcompact"), se = FALSE)
</code></pre>
<p>which causes the following error</p>
<pre><code>Error in class == "subcompact" :
comparison (1) is possible only for atomic and list types
</code></pre>
<p>I assume it worked when the authors wrote it, as they have a nice plot illustrating the results. </p>
<p>What is happening and how do I fix it? (R 3.3.2 on OS X)
Thanks</p>
| 0debug
|
static char *qemu_rbd_array_opts(QDict *options, const char *prefix, int type,
Error **errp)
{
int num_entries;
QemuOpts *opts = NULL;
QDict *sub_options;
const char *host;
const char *port;
char *str;
char *rados_str = NULL;
Error *local_err = NULL;
int i;
assert(type == RBD_MON_HOST);
num_entries = qdict_array_entries(options, prefix);
if (num_entries < 0) {
error_setg(errp, "Parse error on RBD QDict array");
return NULL;
}
for (i = 0; i < num_entries; i++) {
char *strbuf = NULL;
const char *value;
char *rados_str_tmp;
str = g_strdup_printf("%s%d.", prefix, i);
qdict_extract_subqdict(options, &sub_options, str);
g_free(str);
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, sub_options, &local_err);
QDECREF(sub_options);
if (local_err) {
error_propagate(errp, local_err);
g_free(rados_str);
rados_str = NULL;
goto exit;
}
if (type == RBD_MON_HOST) {
host = qemu_opt_get(opts, "host");
port = qemu_opt_get(opts, "port");
value = host;
if (port) {
if (strchr(host, ':')) {
strbuf = g_strdup_printf("[%s]:%s", host, port);
} else {
strbuf = g_strdup_printf("%s:%s", host, port);
}
value = strbuf;
} else if (strchr(host, ':')) {
strbuf = g_strdup_printf("[%s]", host);
value = strbuf;
}
} else {
abort();
}
if (rados_str) {
rados_str_tmp = rados_str;
rados_str = g_strdup_printf("%s;%s", rados_str_tmp, value);
g_free(rados_str_tmp);
} else {
rados_str = g_strdup(value);
}
g_free(strbuf);
qemu_opts_del(opts);
opts = NULL;
}
exit:
qemu_opts_del(opts);
return rados_str;
}
| 1threat
|
How can I get indexPath.row in cell.swift : <p>I have 2 files.</p>
<ul>
<li>myTableViewController.swift</li>
<li>myTableCell.swift</li>
</ul>
<p>Can I get the indexPath.row in myTabelCell.swift function?</p>
<p>Here is myTableCell.swift</p>
<pre><code>import UIKit
import Parse
import ActiveLabel
class myTableCell : UITableViewCell {
//Button
@IBOutlet weak var commentBtn: UIButton!
@IBOutlet weak var likeBtn: UIButton!
@IBOutlet weak var moreBtn: UIButton!
override func awakeFromNib() {
super.awakeFromNib()
}
@IBAction func likeBtnTapped(_ sender: AnyObject) {
//declare title of button
let title = sender.title(for: UIControlState())
//I want get indexPath.row in here!
}
</code></pre>
<p>Here is myTableViewController.swift</p>
<pre><code>class myTableViewController: UITableViewController {
//Default func
override func viewDidLoad() {
super.viewDidLoad()
//automatic row height
tableView.estimatedRowHeight = 450
tableView.rowHeight = UITableViewAutomaticDimension
}
// cell config
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
//define cell
let cell = tableView.dequeueReusableCell(withIdentifier: "myTableCell", for: indexPath) as! myTableCell
}
</code></pre>
<p>As you can see... I'm trying to get indexPath.row in myTableCell, liktBtnTapped function. </p>
<p>Could you let me know how can I access or get IndexPath.row?</p>
| 0debug
|
how can i limit the access of active admin using cancancan in rails : i want that admin cannot see the data of the user (which user added manually).
admin can only see the data which he added from admin panel
i'm using cancancan gem and active admin gem.
this is the ability.rb file where cancancan is being used
def initialize(user)
user ||= User.new # guest user (not logged in)
if user.admin?
can :manage, :all
else
can :manage, WebCred, user_passes: {user_id: user.id}
end
____________________________________________________________
index do
selectable_column
id_column
column :email
column :current_sign_in_at
column :sign_in_count
column :created_at
actions
end
filter :email
filter :current_sign_in_at
filter :sign_in_count
filter :created_at
form do |f|
f.inputs do
f.input :email
f.input :password
f.input :password_confirmation
end
f.actions
end
this is the file of my active admin.
i want my admin cannot see the passord of the webcred which user add manually
while he can see the password that he added
| 0debug
|
window.location.href = 'http://attack.com?user=' + user_input;
| 1threat
|
void ff_weight_h264_pixels8_8_msa(uint8_t *src, int stride,
int height, int log2_denom,
int weight_src, int offset)
{
avc_wgt_8width_msa(src, stride,
height, log2_denom, weight_src, offset);
}
| 1threat
|
Best php navigation method with sub directories in mind : I'm looking for the best method for creating a single navigation menu and including it with php. I know how to do just about everything I need, the problem I'm running into is the sub directories.
For example:
Nav.php is in the root directory.
`Index.php` is also in the root directory.
Now I want to go to a page about cats, located at `about/cats.php`.
When I want to go from `about/cats.php` to `blog/kittens.php` how would I structure the links?
`<a href="about/cats.php">cats</a>` would take me to about/cats just fine from the root directory. But if I'm on the `blog/kittens.php` page, I'd get a link like `about/blog/kittens.php`.
It's not something that needs massive/dynamic arrays or anything, I've just had a hard time wrapping my head around the cleanest way to do this.
What's the best method to keep one navigation file(if possible) but still have correct links even if I'm 2 or 4 levels from the root? I've seen others use sql databases (if that's the best way I don't mind), but I feel like that's too complicated and I'm just missing a much easier method.
| 0debug
|
How to remove first and last double quotation marks and backslash of JSON Data in JavaScript : <p>I want to remove first and last double quotation marks and backslash of a JSON data in javascript </p>
<p>"{\"documents\":[{\"id\":\"1\",\"language\":\"en\",\"text\":\"I had a wonderful trip to Seattle last week and even visited the Space Needle 2 times!\"}]}"</p>
<p>I expect the output is:</p>
<p>{"documents":[{"id":"1","language":"en","text":"I had a wonderful trip to Seattle last week and even visited the Space Needle 2 times!"}]}"</p>
| 0debug
|
int ff_MPV_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
AVFrame *pic_arg, int *got_packet)
{
MpegEncContext *s = avctx->priv_data;
int i, stuffing_count, ret;
int context_count = s->slice_context_count;
s->picture_in_gop_number++;
if (load_input_picture(s, pic_arg) < 0)
return -1;
if (select_input_picture(s) < 0) {
return -1;
}
if (s->new_picture.f.data[0]) {
if ((ret = ff_alloc_packet2(avctx, pkt, s->mb_width*s->mb_height*(MAX_MB_BYTES+100)+10000)) < 0)
return ret;
if (s->mb_info) {
s->mb_info_ptr = av_packet_new_side_data(pkt,
AV_PKT_DATA_H263_MB_INFO,
s->mb_width*s->mb_height*12);
s->prev_mb_info = s->last_mb_info = s->mb_info_size = 0;
}
for (i = 0; i < context_count; i++) {
int start_y = s->thread_context[i]->start_mb_y;
int end_y = s->thread_context[i]-> end_mb_y;
int h = s->mb_height;
uint8_t *start = pkt->data + (size_t)(((int64_t) pkt->size) * start_y / h);
uint8_t *end = pkt->data + (size_t)(((int64_t) pkt->size) * end_y / h);
init_put_bits(&s->thread_context[i]->pb, start, end - start);
}
s->pict_type = s->new_picture.f.pict_type;
ff_MPV_frame_start(s, avctx);
vbv_retry:
if (encode_picture(s, s->picture_number) < 0)
return -1;
avctx->header_bits = s->header_bits;
avctx->mv_bits = s->mv_bits;
avctx->misc_bits = s->misc_bits;
avctx->i_tex_bits = s->i_tex_bits;
avctx->p_tex_bits = s->p_tex_bits;
avctx->i_count = s->i_count;
avctx->p_count = s->mb_num - s->i_count - s->skip_count;
avctx->skip_count = s->skip_count;
ff_MPV_frame_end(s);
if (CONFIG_MJPEG_ENCODER && s->out_format == FMT_MJPEG)
ff_mjpeg_encode_picture_trailer(s);
if (avctx->rc_buffer_size) {
RateControlContext *rcc = &s->rc_context;
int max_size = rcc->buffer_index * avctx->rc_max_available_vbv_use;
if (put_bits_count(&s->pb) > max_size &&
s->lambda < s->avctx->lmax) {
s->next_lambda = FFMAX(s->lambda + 1, s->lambda *
(s->qscale + 1) / s->qscale);
if (s->adaptive_quant) {
int i;
for (i = 0; i < s->mb_height * s->mb_stride; i++)
s->lambda_table[i] =
FFMAX(s->lambda_table[i] + 1,
s->lambda_table[i] * (s->qscale + 1) /
s->qscale);
}
s->mb_skipped = 0;
if (s->pict_type == AV_PICTURE_TYPE_P) {
if (s->flipflop_rounding ||
s->codec_id == CODEC_ID_H263P ||
s->codec_id == CODEC_ID_MPEG4)
s->no_rounding ^= 1;
}
if (s->pict_type != AV_PICTURE_TYPE_B) {
s->time_base = s->last_time_base;
s->last_non_b_time = s->time - s->pp_time;
}
for (i = 0; i < context_count; i++) {
PutBitContext *pb = &s->thread_context[i]->pb;
init_put_bits(pb, pb->buf, pb->buf_end - pb->buf);
}
goto vbv_retry;
}
assert(s->avctx->rc_max_rate);
}
if (s->flags & CODEC_FLAG_PASS1)
ff_write_pass1_stats(s);
for (i = 0; i < 4; i++) {
s->current_picture_ptr->f.error[i] = s->current_picture.f.error[i];
avctx->error[i] += s->current_picture_ptr->f.error[i];
}
if (s->flags & CODEC_FLAG_PASS1)
assert(avctx->header_bits + avctx->mv_bits + avctx->misc_bits +
avctx->i_tex_bits + avctx->p_tex_bits ==
put_bits_count(&s->pb));
flush_put_bits(&s->pb);
s->frame_bits = put_bits_count(&s->pb);
stuffing_count = ff_vbv_update(s, s->frame_bits);
if (stuffing_count) {
if (s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb) >> 3) <
stuffing_count + 50) {
av_log(s->avctx, AV_LOG_ERROR, "stuffing too large\n");
return -1;
}
switch (s->codec_id) {
case CODEC_ID_MPEG1VIDEO:
case CODEC_ID_MPEG2VIDEO:
while (stuffing_count--) {
put_bits(&s->pb, 8, 0);
}
break;
case CODEC_ID_MPEG4:
put_bits(&s->pb, 16, 0);
put_bits(&s->pb, 16, 0x1C3);
stuffing_count -= 4;
while (stuffing_count--) {
put_bits(&s->pb, 8, 0xFF);
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "vbv buffer overflow\n");
}
flush_put_bits(&s->pb);
s->frame_bits = put_bits_count(&s->pb);
}
if (s->avctx->rc_max_rate &&
s->avctx->rc_min_rate == s->avctx->rc_max_rate &&
s->out_format == FMT_MPEG1 &&
90000LL * (avctx->rc_buffer_size - 1) <=
s->avctx->rc_max_rate * 0xFFFFLL) {
int vbv_delay, min_delay;
double inbits = s->avctx->rc_max_rate *
av_q2d(s->avctx->time_base);
int minbits = s->frame_bits - 8 *
(s->vbv_delay_ptr - s->pb.buf - 1);
double bits = s->rc_context.buffer_index + minbits - inbits;
if (bits < 0)
av_log(s->avctx, AV_LOG_ERROR,
"Internal error, negative bits\n");
assert(s->repeat_first_field == 0);
vbv_delay = bits * 90000 / s->avctx->rc_max_rate;
min_delay = (minbits * 90000LL + s->avctx->rc_max_rate - 1) /
s->avctx->rc_max_rate;
vbv_delay = FFMAX(vbv_delay, min_delay);
assert(vbv_delay < 0xFFFF);
s->vbv_delay_ptr[0] &= 0xF8;
s->vbv_delay_ptr[0] |= vbv_delay >> 13;
s->vbv_delay_ptr[1] = vbv_delay >> 5;
s->vbv_delay_ptr[2] &= 0x07;
s->vbv_delay_ptr[2] |= vbv_delay << 3;
avctx->vbv_delay = vbv_delay * 300;
}
s->total_bits += s->frame_bits;
avctx->frame_bits = s->frame_bits;
pkt->pts = s->current_picture.f.pts;
if (!s->low_delay && s->pict_type != AV_PICTURE_TYPE_B) {
if (!s->current_picture.f.coded_picture_number)
pkt->dts = pkt->pts - s->dts_delta;
else
pkt->dts = s->reordered_pts;
s->reordered_pts = pkt->pts;
} else
pkt->dts = pkt->pts;
if (s->current_picture.f.key_frame)
pkt->flags |= AV_PKT_FLAG_KEY;
if (s->mb_info)
av_packet_shrink_side_data(pkt, AV_PKT_DATA_H263_MB_INFO, s->mb_info_size);
} else {
assert((put_bits_ptr(&s->pb) == s->pb.buf));
s->frame_bits = 0;
}
assert((s->frame_bits & 7) == 0);
pkt->size = s->frame_bits / 8;
*got_packet = !!pkt->size;
return 0;
}
| 1threat
|
Docker repository server gave HTTP response to HTTPS client : <p>I use Docker toolbox for windows and i`m trying run private docker registry from this documentation <a href="https://docs.docker.com/registry/deploying/" rel="noreferrer">https://docs.docker.com/registry/deploying/</a></p>
<p>But it`s not work for me.
Error after this: </p>
<pre><code>$ docker pull 192.168.99.100:5000/my-ubuntu
</code></pre>
<p>Error</p>
<pre><code>$ docker pull 192.168.99.100:5000/image
Using default tag: latest
Error response from daemon: Get https://192.168.99.100:5000/v2/: http: server gave HTTP response to HTTPS client
</code></pre>
<p>I`m thinking that error is something in my docker client.</p>
<p>For information this is my <strong>docker info</strong></p>
<pre><code>Containers: 6
Running: 4
Paused: 0
Stopped: 2
Images: 19
Server Version: 17.06.0-ce
Storage Driver: aufs
Root Dir: /mnt/sda1/var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 144
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: cfb82a876ecc11b5ca0977d1733adbe58599088a
runc version: 2d41c047c83e09a6d61d464906feb2a2f3c52aa4
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 4.4.74-boot2docker
Operating System: Boot2Docker 17.06.0-ce (TCL 7.2); HEAD : 0672754 - Thu Jun 29 00:06:31 UTC 2017
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 995.8MiB
Name: default
ID: ZMCX:NXC7:3BSV:ZNWV:MDZO:FW26:6MX5:UWI6:NVRL:XP56:AKGC:Z3TW
Docker Root Dir: /mnt/sda1/var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 47
Goroutines: 56
System Time: 2018-04-05T13:43:42.856720067Z
EventsListeners: 0
Username: kacalek
Registry: https://index.docker.io/v1/
Labels:
provider=virtualbox
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
</code></pre>
<p>If i try on mac so everythink is perfect.</p>
<p>Do you know how this error to <strong>solve</strong>?</p>
<p>Thank you so much for every answers!</p>
| 0debug
|
Matching if a csv row follows a particular pattern using rejex : //sample code for which rejex needs to be used
I want to write a rejex which will retrun true if the any column of csv files starting from 3rd column upto end is a non zero value
so in case the row is like
121,321,0,0,0,0,0,0 it should return false
121,321,1,0,0,0,0,0 it should return true
121,321,0,0,0,0,1,0 it should return true
public static void main(String[] args) {
String text = "1234,1102,0,0,0,0";
String regex = "";
System.out.println(Pattern.matches(regex, text));
}
I am new to rejex can anyone help me with this
| 0debug
|
What does this php operator do? : <pre><code>$serial = ($_SERVER['SSL_CLIENT_M_SERIAL'] ?? false);
</code></pre>
<p>It looks like a bit like a ternary. But for that I would have expected:</p>
<pre><code>$serial = $_SERVER['SSL_CLIENT_M_SERIAL'] ? $_SERVER['SSL_CLIENT_M_SERIAL'] : false
</code></pre>
<p>perhaps it's shorthand, but finding a link to confirm is difficult. I found the snippet in php4 legacy code.</p>
<p>(note this is php not c#)</p>
| 0debug
|
int qio_channel_socket_dgram_sync(QIOChannelSocket *ioc,
SocketAddress *localAddr,
SocketAddress *remoteAddr,
Error **errp)
{
int fd;
trace_qio_channel_socket_dgram_sync(ioc, localAddr, remoteAddr);
fd = socket_dgram(remoteAddr, localAddr, errp);
if (fd < 0) {
trace_qio_channel_socket_dgram_fail(ioc);
return -1;
}
trace_qio_channel_socket_dgram_complete(ioc, fd);
if (qio_channel_socket_set_fd(ioc, fd, errp) < 0) {
close(fd);
return -1;
}
return 0;
}
| 1threat
|
How would I import a module within an npm package subfolder with webpack? : <p>Lets say theres a package in <code>node_modules</code> called foo and I want to import a module within a library such as <code>foo/module</code> via webpack & babel...</p>
<p><code>import Foo from 'foo';</code> works</p>
<p><code>import SomeOtherModule from 'foo/module';</code> fails with the following:</p>
<blockquote>
<p>Module not found: Error: Cannot resolve module 'foo/module' in
/Users/x/Desktop/someproject/js</p>
</blockquote>
<p>Which makes make it seem like webpack is looking for the file in the wrong place instead of <code>node_modules</code></p>
<p>My webpack.config looks like this:</p>
<pre><code>var webpack = require('webpack');
var path = require('path');
module.exports = {
entry: ['babel-polyfill','./js/script.js'],
output: {
path: __dirname,
filename: './build/script.js'
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
query: {
cacheDirectory: true,
presets: ['es2015']
}
}
],
},
plugins: [
new webpack.NoErrorsPlugin()
],
stats: {
colors: true
},
devtool: 'source-map'
};
</code></pre>
| 0debug
|
slideshow javascript onmouseover : My code is running well ...
but there is one thing i cant solt it ,,,
when i over my mouse on the pic its start well ,,, but when i over again it's became more faster and faster ,,, this is my code :)
<html>
<head></head>
<body>
<script type="text/javascript">
var Image =new Array("Image/welcome.png","Image/To.png",
"Image/My.png","Image/WepPage.png","Image/inphp.png");
var Image_Number=0;
var Image_Length= Image.length;
function change_image(num){
Image_Number = Image_Number + num;
if(Image_Number > Image_Length)
Image_Number = 0;
if(Image_Number < Image_Length)
document.slideshow.src = Image[Image_Number];
return false;
Image_Number = Image_Length;
}
function auto () {
setInterval("change_image(1)", 1000);
}
</script>
<!--Slide____________________________________________________Show -->
<img src="Image/Welcome.png" name="slideshow" onmouseover="auto()" />
</body>
</html>
| 0debug
|
Duplicate data php : <p>can I check the same data in input in form PHP? this is the program code, but what happens is the same data can still be entered and there is no data checking. I've tried in to change <code>if($query >0)</code> bu the data can be input and be the same.</p>
<pre><code><?php
if(!defined('INDEX')) die("");
include("library/config.php");
// cek apakah tombol daftar sudah diklik atau blum?
if(isset($_POST['simpan2'])){
// ambil data dari formulir
$tanggalmasuk = $_POST['tanggalmasuk'];
$tanggalmasuk = date('Y-m-d', strtotime($tanggalmasuk));
$nomorttb1 = $_POST['nomorttb1'];
$nama_supplier1 = $_POST['nama_supplier1'];
$nama_barang1 = $_POST['nama_barang1'];
$jumlahkirim = $_POST['jumlahkirim'];
$nomorrefrence = $_POST['nomorrefrence'];
$nomorsurat = $_POST['nomorsurat'];
// buat query
$sql="SELECT * from masuk where po_nomor= '$_POST[nomorttb1]'";
$query = mysqli_query($con, $sql);
if($query >0){
echo "Data Sudah Ada";
echo "<meta http-equiv='refresh' content='1; url=?hal=masuk'>";
}else{
$sql = "INSERT INTO masuk( tanggal, po_nomor, idsupplier, idbarang, terima,refrence,surat) VALUES ('$tanggalmasuk', '$nomorttb1', '$nama_supplier1', '$nama_barang1', '$jumlahkirim', '$nomorrefrence', '$nomorsurat')";
$query = mysqli_query($con, $sql);
}
// apakah query simpan berhasil?
if($query){
echo "Data berhasil disimpan!";
echo "<meta http-equiv='refresh' content='1; url=?hal=masuk'>";
}else{
echo "Tidak dapat menyimpan data!<br>";
echo mysqli_error();
}
} else {
die("Akses dilarang...");
}
</code></pre>
<p>what I can do to my code and what I can change</p>
| 0debug
|
static void qobject_input_type_null(Visitor *v, const char *name, Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
if (!qobj) {
return;
}
if (qobject_type(qobj) != QTYPE_QNULL) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"null");
}
}
| 1threat
|
How can i switch elements in tuple? : <p>What would be the easiest (shortest) way to switch elements in tuple?</p>
<pre><code>my_tuple= (a,b)
</code></pre>
<p>After switch:</p>
<pre><code>new_tuple= (b,a)
</code></pre>
| 0debug
|
Edge on Windows 10 32-Bit blocking ajax call to localhost with Network Error 0x2efd : <p>We have an app that uses SignalR to talk to scanner drivers locally that has been in production for a couple of years working on IE, Chrome and Firefox, which do not have a problem pulling down the hubs js header file for SignalR. Once Edge came out we saw an issue with talking to localhost and after long efforts of finding a setting to allow it to communicate (and many hours with a Microsoft ticket that they found no solution), we settled on adding headers to allow Edge to grant access to domain:</p>
<p><code>Access-Control-Allow-Origin: https://localhost:11000</code></p>
<p>This seemed to work, but little did we notice that it worked for a 64-Bit Windows 10 Edge, but did not on 32-Bit Windows 10 Edge. I have spent hours lowering all security settings for all zones and disabling Protected Mode, trying different ajax tricks to pull the file, but continue to get the error:</p>
<p><code>SCRIPT7002: XMLHttpRequest: Network Error 0x2efd, Could not complete the operation due to error 00002efd.</code></p>
<p>The following pseudo code fails:</p>
<pre><code>$.ajax({
url: "https://localhost:11000/signalr/hubs",
crossDomain: true,
success: function (data) {
console.log("success");
},
error: function (jqXHR, textStatus, errorThrown) {
console.log("error:");
console.log(jqXHR);
}
});
</code></pre>
<p>I'm looking for any insight into settings or anything else to try, or if anyone else has seen this issue. One other piece of information, fiddler doesn't show any traffic for the call so it is being blocked by the browser it would seem. Also on the same computer that fails with Edge - IE, Chrome and FF will succeed.</p>
| 0debug
|
Programmatically turn on/off Action Center : <p>Is there a way to programmatically turn on/off the Action Center? Additionally, I'd like to know if there is a way to programmatically turn on/off specific notifications? In manufacturing we use a base image of Windows 10 that has them turned off, and I am working on a patch to an application we make. One of the things I have been tasked with is turning them back on with my patch (or at least figuring out of it is NOT possible).</p>
<p>I don't need to know how to do Toast Notifications. I just need to make the Action Center visible, and turn on notifications for Windows Updates and Defender</p>
| 0debug
|
def get_max_occuring_char(str1):
ASCII_SIZE = 256
ctr = [0] * ASCII_SIZE
max = -1
ch = ''
for i in str1:
ctr[ord(i)]+=1;
for i in str1:
if max < ctr[ord(i)]:
max = ctr[ord(i)]
ch = i
return ch
| 0debug
|
What is the best way for URL clustering in Map-reduce job java : I have a huge data set of URLs from various domains. I have to process them via mapreduce so that the URLs with similar pattern are grouped together. For example
http://www.agricorner.com/price/onion-prices/
http://www.agricorner.com/price/potato-prices/
http://www.agricorner.com/price/ladyfinder-prices/
http://www.agricorner.com/tag/story/story-1.html
http://www.agricorner.com/tag/story/story-11.html
http://www.agricorner.com/tag/story/story-41.html
https://agrihunt.com/author/ramzan/page/3/
https://agrihunt.com/author/shahban/page/5/
https://agrihunt.com/author/Sufer/page/3/
I want to group these URLs based on their pattern i.e., if URLs has similar pattern ( in reducer phase of Map-reduce). The expected output may be like
group1, http://www.agricorner.com/price/onion-prices/, http://www.agricorner.com/price/potato-prices/, http://www.agricorner.com/price/ladyfinder-prices/
group2, http://www.agricorner.com/tag/story/story-1.html, http://www.agricorner.com/tag/story/story-11.html, http://www.agricorner.com/tag/story/story-41.html
group3, https://agrihunt.com/author/ramzan/page/3/, https://agrihunt.com/author/shahban/page/5/, https://agrihunt.com/author/Sufer/page/3/
It it possible ? Is there any better approach that the supposed one?
| 0debug
|
static inline int l3_unscale(int value, int exponent)
{
unsigned int m;
int e;
e = table_4_3_exp [4 * value + (exponent & 3)];
m = table_4_3_value[4 * value + (exponent & 3)];
e -= exponent >> 2;
assert(e >= 1);
if (e > 31)
return 0;
m = (m + (1 << (e - 1))) >> e;
return m;
}
| 1threat
|
Passing a activity context into a static method, memory leak potential? : <p>I've seen this particular technique for launching activities and it seems to me like a bad idea because of static contexts but I was hoping someone might have a legit reason behind this approach.</p>
<p>The activity you want to launch implements a static launch(Context context) method that sets up the intent, flags, etc and finally starts the activity.</p>
<pre><code>public static void launch(Context context){
Intent i = new Intent(context, SomeOtherActivity.class);
// flag stuff
context.startActivity(i);
}
</code></pre>
<p>Then a DifferentActivity could go and launch SomeOtherActivity with one line.</p>
<pre><code>SomeOtherActivity.launch(DifferentActivity.this);
</code></pre>
<p>I like how it allows you to setup the flags in the activity away from the DifferentActivity that is launching it but it doesnt seem like a good enough reason to rationalize passing that activity's context into a static method.</p>
<p>Wouldn't this cause DifferentActivity to not be garbage collected because now that static method has a reference to it? This seems like a memory leak to me and probably not a good idea to do just to be able to keep the flags contained in the activity that is being created. </p>
<p>Is there something I'm missing here that makes this a good practice to do?</p>
| 0debug
|
int qemu_savevm_state_iterate(QEMUFile *f)
{
SaveStateEntry *se;
int ret = 1;
TAILQ_FOREACH(se, &savevm_handlers, entry) {
if (se->save_live_state == NULL)
continue;
qemu_put_byte(f, QEMU_VM_SECTION_PART);
qemu_put_be32(f, se->section_id);
ret &= !!se->save_live_state(f, QEMU_VM_SECTION_PART, se->opaque);
}
if (ret)
return 1;
if (qemu_file_has_error(f))
return -EIO;
return 0;
}
| 1threat
|
static int mirror_cow_align(MirrorBlockJob *s,
int64_t *sector_num,
int *nb_sectors)
{
bool need_cow;
int ret = 0;
int chunk_sectors = s->granularity >> BDRV_SECTOR_BITS;
int64_t align_sector_num = *sector_num;
int align_nb_sectors = *nb_sectors;
int max_sectors = chunk_sectors * s->max_iov;
need_cow = !test_bit(*sector_num / chunk_sectors, s->cow_bitmap);
need_cow |= !test_bit((*sector_num + *nb_sectors - 1) / chunk_sectors,
s->cow_bitmap);
if (need_cow) {
bdrv_round_sectors_to_clusters(blk_bs(s->target), *sector_num,
*nb_sectors, &align_sector_num,
&align_nb_sectors);
}
if (align_nb_sectors > max_sectors) {
align_nb_sectors = max_sectors;
if (need_cow) {
align_nb_sectors = QEMU_ALIGN_DOWN(align_nb_sectors,
s->target_cluster_sectors);
}
}
mirror_clip_sectors(s, align_sector_num, &align_nb_sectors);
ret = align_sector_num + align_nb_sectors - (*sector_num + *nb_sectors);
*sector_num = align_sector_num;
*nb_sectors = align_nb_sectors;
assert(ret >= 0);
return ret;
}
| 1threat
|
static void restart_coroutine(void *opaque)
{
Coroutine *co = opaque;
DPRINTF("co=%p", co);
qemu_coroutine_enter(co, NULL);
}
| 1threat
|
void helper_store_msr(CPUPPCState *env, target_ulong val)
{
uint32_t excp = hreg_store_msr(env, val, 0);
if (excp != 0) {
CPUState *cs = CPU(ppc_env_get_cpu(env));
cs->interrupt_request |= CPU_INTERRUPT_EXITTB;
raise_exception(env, excp);
}
}
| 1threat
|
void cpu_exec_init_all(void)
{
#if !defined(CONFIG_USER_ONLY)
qemu_mutex_init(&ram_list.mutex);
memory_map_init();
io_mem_init();
#endif
}
| 1threat
|
void put_signed_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size)
{
int i;
unsigned char __align8 vector128[8] =
{ 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 };
movq_m2r(*vector128, mm1);
for (i = 0; i < 8; i++) {
movq_m2r(*(block), mm0);
packsswb_m2r(*(block + 4), mm0);
block += 8;
paddb_r2r(mm1, mm0);
movq_r2m(mm0, *pixels);
pixels += line_size;
}
}
| 1threat
|
What is sane way in vuejs + vuex form handling? : <p>I have a large forms to submit in single page.</p>
<pre><code><container>
<formA>
<formB>
<formC>
<submitButton>
<container>
</code></pre>
<p>it looks apparently like this. and I have a store which save every form data. then when user click submit button, I gather all form data using vuex store.</p>
<p>The problem is I need to update the form data in store everytime.</p>
<p>so I'll be like this in vue component</p>
<pre><code> watch: {
userInput (val) {
this.updateState(val)
}
</code></pre>
<p>update state when input changes by watching form data(binded with v-model).</p>
<p>or like this which is documented in vuex doc.</p>
<pre><code> userInput: {
get () {
return this.$store.state.userInput
},
set (val) {
this.updateState(val)
}
}
</code></pre>
<p>well.. I don't think these are good idea. Is there any better way to form handling with vuex?</p>
| 0debug
|
static void code_gen_alloc(unsigned long tb_size)
{
#ifdef USE_STATIC_CODE_GEN_BUFFER
code_gen_buffer = static_code_gen_buffer;
code_gen_buffer_size = DEFAULT_CODE_GEN_BUFFER_SIZE;
map_exec(code_gen_buffer, code_gen_buffer_size);
#else
code_gen_buffer_size = tb_size;
if (code_gen_buffer_size == 0) {
#if defined(CONFIG_USER_ONLY)
code_gen_buffer_size = DEFAULT_CODE_GEN_BUFFER_SIZE;
#else
code_gen_buffer_size = (unsigned long)(ram_size / 4);
#endif
}
if (code_gen_buffer_size < MIN_CODE_GEN_BUFFER_SIZE)
code_gen_buffer_size = MIN_CODE_GEN_BUFFER_SIZE;
#if defined(__linux__)
{
int flags;
void *start = NULL;
flags = MAP_PRIVATE | MAP_ANONYMOUS;
#if defined(__x86_64__)
flags |= MAP_32BIT;
if (code_gen_buffer_size > (800 * 1024 * 1024))
code_gen_buffer_size = (800 * 1024 * 1024);
#elif defined(__sparc_v9__)
flags |= MAP_FIXED;
start = (void *) 0x60000000UL;
if (code_gen_buffer_size > (512 * 1024 * 1024))
code_gen_buffer_size = (512 * 1024 * 1024);
#elif defined(__arm__)
flags |= MAP_FIXED;
start = (void *) 0x01000000UL;
if (code_gen_buffer_size > 16 * 1024 * 1024)
code_gen_buffer_size = 16 * 1024 * 1024;
#elif defined(__s390x__)
if (code_gen_buffer_size > (3ul * 1024 * 1024 * 1024)) {
code_gen_buffer_size = 3ul * 1024 * 1024 * 1024;
}
start = (void *)0x90000000UL;
#endif
code_gen_buffer = mmap(start, code_gen_buffer_size,
PROT_WRITE | PROT_READ | PROT_EXEC,
flags, -1, 0);
if (code_gen_buffer == MAP_FAILED) {
fprintf(stderr, "Could not allocate dynamic translator buffer\n");
exit(1);
}
}
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
|| defined(__DragonFly__) || defined(__OpenBSD__)
{
int flags;
void *addr = NULL;
flags = MAP_PRIVATE | MAP_ANONYMOUS;
#if defined(__x86_64__)
flags |= MAP_FIXED;
addr = (void *)0x40000000;
if (code_gen_buffer_size > (800 * 1024 * 1024))
code_gen_buffer_size = (800 * 1024 * 1024);
#elif defined(__sparc_v9__)
flags |= MAP_FIXED;
addr = (void *) 0x60000000UL;
if (code_gen_buffer_size > (512 * 1024 * 1024)) {
code_gen_buffer_size = (512 * 1024 * 1024);
}
#endif
code_gen_buffer = mmap(addr, code_gen_buffer_size,
PROT_WRITE | PROT_READ | PROT_EXEC,
flags, -1, 0);
if (code_gen_buffer == MAP_FAILED) {
fprintf(stderr, "Could not allocate dynamic translator buffer\n");
exit(1);
}
}
#else
code_gen_buffer = qemu_malloc(code_gen_buffer_size);
map_exec(code_gen_buffer, code_gen_buffer_size);
#endif
#endif
map_exec(code_gen_prologue, sizeof(code_gen_prologue));
code_gen_buffer_max_size = code_gen_buffer_size -
(TCG_MAX_OP_SIZE * OPC_MAX_SIZE);
code_gen_max_blocks = code_gen_buffer_size / CODE_GEN_AVG_BLOCK_SIZE;
tbs = qemu_malloc(code_gen_max_blocks * sizeof(TranslationBlock));
}
| 1threat
|
Convert regex into java regex : <p>string should <strong><em>not</em></strong> be longer than 26 alphanumeric characters
string should <strong><em>not</em></strong> begin with <strong>www</strong> OR <strong>api</strong> OR <strong>admin</strong>
string may contain hyphens</p>
<p>I have this regular expression that works: </p>
<pre><code>^(?!www)(?!admin)(?!api)[a-zA-Z0-9.]{1,26}
</code></pre>
<p>Can you help me convert that regex into a java style string regex?</p>
| 0debug
|
static void parse_ptl(HEVCContext *s, PTL *ptl, int max_num_sub_layers)
{
int i;
HEVCLocalContext *lc = s->HEVClc;
GetBitContext *gb = &lc->gb;
decode_profile_tier_level(s, &ptl->general_ptl);
ptl->general_ptl.level_idc = get_bits(gb, 8);
for (i = 0; i < max_num_sub_layers - 1; i++) {
ptl->sub_layer_profile_present_flag[i] = get_bits1(gb);
ptl->sub_layer_level_present_flag[i] = get_bits1(gb);
}
if (max_num_sub_layers - 1> 0)
for (i = max_num_sub_layers - 1; i < 8; i++)
skip_bits(gb, 2);
for (i = 0; i < max_num_sub_layers - 1; i++) {
if (ptl->sub_layer_profile_present_flag[i])
decode_profile_tier_level(s, &ptl->sub_layer_ptl[i]);
if (ptl->sub_layer_level_present_flag[i])
ptl->sub_layer_ptl[i].level_idc = get_bits(gb, 8);
}
}
| 1threat
|
Bootstrap postioning of divs, Css, and Navigation Bar issue *html5 : I am having trouble with my css. I am trying to have my contact information, the quote, and my contact form to be in the same row but different columns. And also why is it that my html doesn't all fit on one page, I can scroll to the rigth and there's just empty white space. I figure its because I added -1.23em in my navbars margin; However, I only did this because my navbar was not filling the whole page. Here is a link to my gist and bitballon. Thank you in advance.
https://gist.github.com/bklynbest/a19565b1b5289f045919e76d657848ea
http://sad-goodall-e4f115.bitballoon.com
| 0debug
|
int kvm_update_guest_debug(CPUState *env, unsigned long reinject_trap)
{
struct kvm_set_guest_debug_data data;
data.dbg.control = 0;
if (env->singlestep_enabled)
data.dbg.control = KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_SINGLESTEP;
kvm_arch_update_guest_debug(env, &data.dbg);
data.dbg.control |= reinject_trap;
data.env = env;
on_vcpu(env, kvm_invoke_set_guest_debug, &data);
return data.err;
}
| 1threat
|
static void ape_unpack_stereo(APEContext *ctx, int count)
{
int32_t left, right;
int32_t *decoded0 = ctx->decoded[0];
int32_t *decoded1 = ctx->decoded[1];
if (ctx->frameflags & APE_FRAMECODE_STEREO_SILENCE) {
av_log(ctx->avctx, AV_LOG_DEBUG, "pure silence stereo\n");
return;
}
entropy_decode(ctx, count, 1);
ape_apply_filters(ctx, decoded0, decoded1, count);
predictor_decode_stereo(ctx, count);
while (count--) {
left = *decoded1 - (*decoded0 / 2);
right = left + *decoded0;
*(decoded0++) = left;
*(decoded1++) = right;
}
}
| 1threat
|
How can i get the specific data from a json file? : I'm trying to make web application about movies with a movie Api. Then I copied first two parts of search results and stored them in a variable how can I get the specific data from variable?
I've considered like the json file is an object and tried to get the specific data but I couldn't.
This is the first two parts of search results that I stored in a variable.
~~~
var searchResults = {
page: 1,
total_results: 4109,
total_pages: 206,
results: [
{
original_name: 'Star',
id: 68780,
media_type: 'tv',
name: 'Star',
vote_count: 62,
vote_average: 7.12,
first_air_date: '2016-12-14',
popularity: 16.022,
original_language: 'en',
},
{
original_name: '부암동 복수자들',
id: 74473,
media_type: 'tv',
name: 'Avengers Social Club',
vote_count: 4,
vote_average: 9,
first_air_date: '2017-10-11',
popularity: 1.668,
original_language: 'ko',
}]};
~~~
I want to see names of this movies in console. How can I see names of this two movies in console.
| 0debug
|
def check_Equality(s):
return (ord(s[0]) == ord(s[len(s) - 1]));
def count_Substring_With_Equal_Ends(s):
result = 0;
n = len(s);
for i in range(n):
for j in range(1,n-i+1):
if (check_Equality(s[i:i+j])):
result+=1;
return result;
| 0debug
|
here var 'pass' can't parse to $_post['action']=='edit' ??any help please? : <form action="" method="post">
<div class="col-md-2 ">
<input type="type" value="<?php echo $row['rcode'];?>" name="pass" id="pass"/>
<input type="submit" name="edit" class="btn btn-primary" value="edit"/>
<input type="submit" name="delete" class="btn btn-danger" value="Delete"/>
</div>
</form>
then
if($_POST['action']=='edit'){
echo $rcode1=$_REQUEST['pass'];
$sqlup="select * from transport_details where rcode='$rcode1'";
| 0debug
|
"TypeError: Cannot read property 'name' of undefined". : i'm trying to load my APP page. we have options to add accounts. but we we add accounts i'm getting error "Hi , i'm trying to load my APP page. we have options to add accounts. but we we add accounts i'm getting error". and these are error message[attached error message][1]
[1]: https://i.stack.imgur.com/4nVGR.png
| 0debug
|
Why is the const&& overload of as_const deleted? : <p>On a <a href="http://talesofcpp.fusionfenix.com/post-23/interlude" rel="noreferrer">blog on the progress of C++17</a> I read the following:</p>
<blockquote>
<p><code>P0007</code> proposes a helper function template <code>as_const</code>, which simply
takes a reference and returns it as a reference to <code>const</code>.</p>
<pre><code>template <typename T> std::add_const_t<T>& as_const(T& t) { return t }
template <typename T> void as_const(T const&&) = delete;
</code></pre>
</blockquote>
<p>Why is the <code>const&&</code> overload deleted?</p>
| 0debug
|
int ff_get_best_fcode(MpegEncContext * s, int16_t (*mv_table)[2], int type)
{
int f_code;
if(s->me_method>=ME_EPZS){
int mv_num[8];
int i, y;
int loose=0;
UINT8 * fcode_tab= s->fcode_tab;
for(i=0; i<8; i++) mv_num[i]=0;
for(y=0; y<s->mb_height; y++){
int x;
int xy= (y+1)* (s->mb_width+2) + 1;
i= y*s->mb_width;
for(x=0; x<s->mb_width; x++){
if(s->mb_type[i] & type){
mv_num[ fcode_tab[mv_table[xy][0] + MAX_MV] ]++;
mv_num[ fcode_tab[mv_table[xy][1] + MAX_MV] ]++;
}
i++;
xy++;
}
}
for(i=MAX_FCODE; i>1; i--){
int threshold;
loose+= mv_num[i];
if(s->pict_type==B_TYPE) threshold= 0;
else threshold= s->mb_num/20;
if(loose > threshold) break;
}
return i;
}else{
return 1;
}
}
| 1threat
|
static void cpudef_init(void)
{
#if defined(cpudef_setup)
cpudef_setup();
#endif
}
| 1threat
|
hwaddr uc32_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
{
UniCore32CPU *cpu = UNICORE32_CPU(cs);
cpu_abort(CPU(cpu), "%s not supported yet\n", __func__);
return addr;
}
| 1threat
|
Why ref structs cannot be used as type arguments? : <p>C# 7.2 <a href="https://docs.microsoft.com/en-us/dotnet/csharp/reference-semantics-with-value-types" rel="noreferrer">introduced</a> <code>ref struct</code>s. However, given a <code>ref struct</code> like this:</p>
<pre><code>public ref struct Foo {
public int Bar;
}
</code></pre>
<p>I cannot use it as a type argument:</p>
<pre><code>int i = 0;
var x = Unsafe.As<int, Foo>(ref i); // <- Error CS0306 The type 'Foo' may not be used as a type argument.
</code></pre>
<p>I understand that ref structs can only exist on the stack, and not the heap. But what if the generic method that would use such ref structs is guaranteed to never put them on the heap, as in the example above that uses <code>System.Runtime.CompilerServices.Unsafe</code> package? Why can I not use them in those cases as type parameters?</p>
| 0debug
|
Laravel 5.3 - Social login doubts : <p>I am developing a mobile app and currently depending on JWT to maintain the statelessness of the API. The API is consumed by mobile and web devices. The users will use their email and password to register. </p>
<p>I am assigned to implement social login option in this API. I would like to clear my following doubts.</p>
<p>1) When Social Login is used, how can I generate a token [like JWT] which will be stored at the client's end? This token is supposed to send with all subsequent requests after login.</p>
<p>2) In case social platforms are not providing/sharing email address [which is one of our primary keys], what all information shall I store?</p>
| 0debug
|
Resize Width and Height of an Image During Upload : <p>I have an upload script that renames and uploads .png files to directory of my website. I want the script to be able to scale the image down to 256x256 pixels during the upload process.</p>
<p>I was looking around here and I can't figure out how to include it in the code I already have.</p>
<pre><code><?php
$z = $_POST['z'];
$x = $_POST['x'];
$y = $_POST['y'];
$target_dir = "/DIRECTORY/$z-$x-$y.png";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;
}
}
// Check if file already exists
if (file_exists($target_file)) {
echo "Sorry, file already exists.";
$uploadOk = 0;
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
echo "Sorry, your file is too large.";
$uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "png") {
echo "Sorry, only PNG files are allowed.";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
// if everything is ok, rename then try to upload file
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],
$target_dir)) {
echo "The file ". basename( $_FILES["fileToUpload"]["name"]). "
has been uploaded.";
echo '<a href="mywebsite">To The Drawbox!
</a>';
} else {
echo "Sorry, there was an error uploading your file.";
}
}
?>
</code></pre>
<p>So far it only renames the files but does not resize.</p>
| 0debug
|
HI! how can i sort files that are in document directory? i need do add the attribute when i create the file? : i need to sort some files that are showing in a table view, the files are in documents directory. I been searching but i'm confuse. I need to add the date attribute when i create the files or the file already have by default the data when was created (this make more sense to me) if that the case, how can i sort the NSMutableArray that contain the files.
THis is how i get the files:
NSArray *paths3 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* fullPath = [paths3 objectAtIndex:0];
fullPath = [fullPath stringByAppendingPathComponent: [self.dirList objectAtIndex:indexPath.row]];
NSLog(@"%@", fullPath);
| 0debug
|
Installing Ruby 2.3.x on Ubuntu 18.04 is causing an error by the end of the installation process : <p>I recently updated my system to Ubuntu 18.04 LTS, and since then, the Ruby version seems to have updated to 2.5. The issue is that, when attempting to deploy a project that uses Capistrano, it will now complain that Ruby 2.3 was not found.</p>
<p>The version it tries to install when running <code>rvm install 2.3</code> is 2.3.4, and the first error that is shown is "<code>Error running '__rvm_make -j4'</code>". I tried removing RVM and installing again, but nothing solves this. The log is an enormous file which tells me nothing.</p>
<p>Then, I tried using <code>rbenv</code>, which also causes an error:</p>
<pre><code>Installing ruby-2.3.4...
BUILD FAILED (Ubuntu 18.04 using ruby-build 20180424)
Inspect or clean up the working tree at /tmp/ruby-build.20180429172721.16258
Results logged to /tmp/ruby-build.20180429172721.16258.log
Last 10 log lines:
installing default nkf libraries
linking shared-object objspace.so
make[2]: Leaving directory '/tmp/ruby-build.20180429172721.16258/ruby-2.3.4/ext/objspace'
linking shared-object pathname.so
make[2]: Leaving directory '/tmp/ruby-build.20180429172721.16258/ruby-2.3.4/ext/pathname'
linking shared-object nkf.so
make[2]: Leaving directory '/tmp/ruby-build.20180429172721.16258/ruby-2.3.4/ext/nkf'
make[1]: Leaving directory '/tmp/ruby-build.20180429172721.16258/ruby-2.3.4'
uncommon.mk:203: recipe for target 'build-ext' failed
make: *** [build-ext] Error 2
</code></pre>
<p>The log file also has a stupid giant log file.</p>
<p>The next attempt was to install from source, which after running <code>make</code> within the folder, the error:</p>
<pre><code>openssl_missing.h:78:35: error: macro "EVP_MD_CTX_create" passed 1 arguments, but takes just 0
EVP_MD_CTX *EVP_MD_CTX_create(void);
^
In file included from /usr/include/openssl/x509.h:23:0,
from /usr/include/openssl/x509_vfy.h:17,
from openssl_missing.c:15:
openssl_missing.h:82:6: error: expected declaration specifiers or ‘...’ before ‘(’ token
void EVP_MD_CTX_init(EVP_MD_CTX *ctx);
^
openssl_missing.h:90:6: error: expected declaration specifiers or ‘...’ before ‘(’ token
void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
^
openssl_missing.c:39:23: error: macro "EVP_MD_CTX_create" passed 1 arguments, but takes just 0
EVP_MD_CTX_create(void)
^
openssl_missing.c:40:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
{
^
openssl_missing.c: In function ‘EVP_MD_CTX_cleanup’:
openssl_missing.c:55:27: error: invalid application of ‘sizeof’ to incomplete type ‘EVP_MD_CTX {aka struct evp_md_ctx_st}’
memset(ctx, 0, sizeof(EVP_MD_CTX));
^~~~~~~~~~
In file included from /usr/include/openssl/x509.h:23:0,
from /usr/include/openssl/x509_vfy.h:17,
from openssl_missing.c:15:
openssl_missing.c: At top level:
openssl_missing.c:63:1: error: expected declaration specifiers or ‘...’ before ‘(’ token
EVP_MD_CTX_destroy(EVP_MD_CTX *ctx)
^
openssl_missing.c:72:1: error: expected declaration specifiers or ‘...’ before ‘(’ token
EVP_MD_CTX_init(EVP_MD_CTX *ctx)
^
openssl_missing.c: In function ‘HMAC_CTX_init’:
openssl_missing.c:82:25: error: dereferencing pointer to incomplete type ‘HMAC_CTX {aka struct hmac_ctx_st}’
EVP_MD_CTX_init(&ctx->i_ctx);
^
openssl_missing.c: In function ‘HMAC_CTX_cleanup’:
openssl_missing.c:95:27: error: invalid application of ‘sizeof’ to incomplete type ‘HMAC_CTX {aka struct hmac_ctx_st}’
memset(ctx, 0, sizeof(HMAC_CTX));
^~~~~~~~
Makefile:301: recipe for target 'openssl_missing.o' failed
make[2]: *** [openssl_missing.o] Error 1
make[2]: Leaving directory '/home/gabriel/Downloads/ruby-2.3.7/ext/openssl'
exts.mk:212: recipe for target 'ext/openssl/all' failed
make[1]: *** [ext/openssl/all] Error 2
make[1]: Leaving directory '/home/gabriel/Downloads/ruby-2.3.7'
uncommon.mk:203: recipe for target 'build-ext' failed
make: *** [build-ext] Error 2
</code></pre>
<p>What is it there to be done to install it? Or it isn't possible anymore to install these old versions?</p>
| 0debug
|
static void vga_precise_update_retrace_info(VGACommonState *s)
{
int htotal_chars;
int hretr_start_char;
int hretr_skew_chars;
int hretr_end_char;
int vtotal_lines;
int vretr_start_line;
int vretr_end_line;
int dots;
#if 0
int div2, sldiv2;
#endif
int clocking_mode;
int clock_sel;
const int clk_hz[] = {25175000, 28322000, 25175000, 25175000};
int64_t chars_per_sec;
struct vga_precise_retrace *r = &s->retrace_info.precise;
htotal_chars = s->cr[VGA_CRTC_H_TOTAL] + 5;
hretr_start_char = s->cr[VGA_CRTC_H_SYNC_START];
hretr_skew_chars = (s->cr[VGA_CRTC_H_SYNC_END] >> 5) & 3;
hretr_end_char = s->cr[VGA_CRTC_H_SYNC_END] & 0x1f;
vtotal_lines = (s->cr[VGA_CRTC_V_TOTAL] |
(((s->cr[VGA_CRTC_OVERFLOW] & 1) |
((s->cr[VGA_CRTC_OVERFLOW] >> 4) & 2)) << 8)) + 2;
vretr_start_line = s->cr[VGA_CRTC_V_SYNC_START] |
((((s->cr[VGA_CRTC_OVERFLOW] >> 2) & 1) |
((s->cr[VGA_CRTC_OVERFLOW] >> 6) & 2)) << 8);
vretr_end_line = s->cr[VGA_CRTC_V_SYNC_END] & 0xf;
clocking_mode = (s->sr[VGA_SEQ_CLOCK_MODE] >> 3) & 1;
clock_sel = (s->msr >> 2) & 3;
dots = (s->msr & 1) ? 8 : 9;
chars_per_sec = clk_hz[clock_sel] / dots;
htotal_chars <<= clocking_mode;
r->total_chars = vtotal_lines * htotal_chars;
if (r->freq) {
r->ticks_per_char = NANOSECONDS_PER_SECOND / (r->total_chars * r->freq);
} else {
r->ticks_per_char = NANOSECONDS_PER_SECOND / chars_per_sec;
}
r->vstart = vretr_start_line;
r->vend = r->vstart + vretr_end_line + 1;
r->hstart = hretr_start_char + hretr_skew_chars;
r->hend = r->hstart + hretr_end_char + 1;
r->htotal = htotal_chars;
#if 0
div2 = (s->cr[VGA_CRTC_MODE] >> 2) & 1;
sldiv2 = (s->cr[VGA_CRTC_MODE] >> 3) & 1;
printf (
"hz=%f\n"
"htotal = %d\n"
"hretr_start = %d\n"
"hretr_skew = %d\n"
"hretr_end = %d\n"
"vtotal = %d\n"
"vretr_start = %d\n"
"vretr_end = %d\n"
"div2 = %d sldiv2 = %d\n"
"clocking_mode = %d\n"
"clock_sel = %d %d\n"
"dots = %d\n"
"ticks/char = %" PRId64 "\n"
"\n",
(double) NANOSECONDS_PER_SECOND / (r->ticks_per_char * r->total_chars),
htotal_chars,
hretr_start_char,
hretr_skew_chars,
hretr_end_char,
vtotal_lines,
vretr_start_line,
vretr_end_line,
div2, sldiv2,
clocking_mode,
clock_sel,
clk_hz[clock_sel],
dots,
r->ticks_per_char
);
#endif
}
| 1threat
|
static void virtser_port_device_realize(DeviceState *dev, Error **errp)
{
VirtIOSerialPort *port = VIRTIO_SERIAL_PORT(dev);
VirtIOSerialPortClass *vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port);
VirtIOSerialBus *bus = VIRTIO_SERIAL_BUS(qdev_get_parent_bus(dev));
VirtIODevice *vdev = VIRTIO_DEVICE(bus->vser);
int max_nr_ports;
bool plugging_port0;
Error *err = NULL;
port->vser = bus->vser;
port->bh = qemu_bh_new(flush_queued_data_bh, port);
assert(vsc->have_data);
plugging_port0 = vsc->is_console && !find_port_by_id(port->vser, 0);
if (find_port_by_id(port->vser, port->id)) {
error_setg(errp, "virtio-serial-bus: A port already exists at id %u",
port->id);
return;
}
if (find_port_by_name(port->name)) {
error_setg(errp, "virtio-serial-bus: A port already exists by name %s",
port->name);
return;
}
if (port->id == VIRTIO_CONSOLE_BAD_ID) {
if (plugging_port0) {
port->id = 0;
} else {
port->id = find_free_port_id(port->vser);
if (port->id == VIRTIO_CONSOLE_BAD_ID) {
error_setg(errp, "virtio-serial-bus: Maximum port limit for "
"this device reached");
return;
}
}
}
max_nr_ports = virtio_tswap32(vdev, port->vser->config.max_nr_ports);
if (port->id >= max_nr_ports) {
error_setg(errp, "virtio-serial-bus: Out-of-range port id specified, "
"max. allowed: %u", max_nr_ports - 1);
return;
}
vsc->realize(dev, &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
port->elem.out_num = 0;
}
| 1threat
|
c# Help (MySqlexception was unhandled, Fatal error encountered during command execution.) : i try to add some values to table(tbllogs) after loging in, but i got an error
here's my code
if (ctr == 1)
{
Data.con.Open();
MetroMessageBox.Show(this, "Login Success!", "Welcome!", MessageBoxButtons.OK, MessageBoxIcon.Information);
MySqlDataAdapter da = new MySqlDataAdapter("Select * From dbinfo.tbluser where UserName = '" + txtUser.Text + "' and UserPassword = '" + txtPass.Text + "'", Data.con);
DataTable dt = new DataTable();
da.Fill(dt);
Data.UserID = dt.Rows[0][0].ToString();
Data.UserName = dt.Rows[0][1].ToString();
Data.UserLevel = dt.Rows[0][3].ToString();
string SaveStr = "Insert into dbinfo.tbllogs (LogsUser, LogsPassword) Values (@LogsUser, @LogsPassword)";
MySqlCommand SaveCmd = new MySqlCommand(SaveStr, Data.con);
//SaveCmd.Parameters.AddWithValue("@LogsID", Data.UserID = dt.Rows[0][0].ToString());
SaveCmd.Parameters.AddWithValue("@LogsName", txtUser.Text);
SaveCmd.Parameters.AddWithValue("@LogsPassword", txtPass.Text);
//SaveCmd.Parameters.AddWithValue("@LogsLevel", Data.UserLevel = dt.Rows[0][3].ToString());
//SaveCmd.Parameters.AddWithValue("@LogsDateIN", timelabel.Text);
SaveCmd.ExecuteNonQuery();
Data.con.Close();
LoadData();
Menu frmMenu = new Menu();
frmMenu.Show();
this.Hide();
}
i tried changing the code ` SaveCmd.Parameters.AddWithValue("@LogsName", txtUser.Text);` to ` SaveCmd.Parameters.AddWithValue("@LogsName", Data.Password = dt.Rows[0][2].ToString()));` but didn't work either.
i will provide more code if this isn't enough, Thanks in advance!
| 0debug
|
how to generate the series 'a','a',1,2,3,4,5,7,9,11 using R technology with rep and seq functions : <p>Below is the series need to get using R with rep and seq
series : 'a','a',1,2,3,4,5,7,9,11</p>
<pre><code>I am Leaning R as beginner. Please try to help me on the above query
</code></pre>
| 0debug
|
Unable to open cqlsh Apache cassandra - ImportError: No module named cqlshlib : <p>I am new to cassandra ! Have downloaded the apacahe cassandra 2.1.2 package and initialy was able to connect to cqlsh but then after installing CCM i am unable to connect , will get the following error</p>
<pre><code>Traceback (most recent call last):
File "bin/cqlsh", line 124, in <module>
from cqlshlib import cql3handling, cqlhandling, pylexotron,sslhandling, copy
ImportError: No module named cqlshlib
</code></pre>
<p>Thanks in advance !</p>
| 0debug
|
static bool get_queued_page(RAMState *rs, PageSearchStatus *pss,
ram_addr_t *ram_addr_abs)
{
RAMBlock *block;
ram_addr_t offset;
bool dirty;
do {
block = unqueue_page(rs, &offset, ram_addr_abs);
if (block) {
unsigned long *bitmap;
bitmap = atomic_rcu_read(&rs->ram_bitmap)->bmap;
dirty = test_bit(*ram_addr_abs >> TARGET_PAGE_BITS, bitmap);
if (!dirty) {
trace_get_queued_page_not_dirty(
block->idstr, (uint64_t)offset,
(uint64_t)*ram_addr_abs,
test_bit(*ram_addr_abs >> TARGET_PAGE_BITS,
atomic_rcu_read(&rs->ram_bitmap)->unsentmap));
} else {
trace_get_queued_page(block->idstr,
(uint64_t)offset,
(uint64_t)*ram_addr_abs);
}
}
} while (block && !dirty);
if (block) {
rs->ram_bulk_stage = false;
pss->block = block;
pss->offset = offset;
}
return !!block;
}
| 1threat
|
static TCGReg tcg_out_tlb_read(TCGContext *s, TCGMemOp s_bits,
TCGReg addrlo, TCGReg addrhi,
int mem_index, bool is_read)
{
int cmp_off
= (is_read
? offsetof(CPUArchState, tlb_table[mem_index][0].addr_read)
: offsetof(CPUArchState, tlb_table[mem_index][0].addr_write));
int add_off = offsetof(CPUArchState, tlb_table[mem_index][0].addend);
TCGReg base = TCG_AREG0;
if (TCG_TARGET_REG_BITS == 64) {
if (TARGET_LONG_BITS == 32) {
tcg_out_ext32u(s, TCG_REG_R4, addrlo);
addrlo = TCG_REG_R4;
} else {
tcg_out_rld(s, RLDICL, TCG_REG_R3, addrlo,
64 - TARGET_PAGE_BITS, 64 - CPU_TLB_BITS);
}
}
if (add_off >= 0x8000) {
QEMU_BUILD_BUG_ON(offsetof(CPUArchState,
tlb_table[NB_MMU_MODES - 1][1])
> 0x7ff0 + 0x7fff);
tcg_out32(s, ADDI | TAI(TCG_REG_TMP1, base, 0x7ff0));
base = TCG_REG_TMP1;
cmp_off -= 0x7ff0;
add_off -= 0x7ff0;
}
if (TCG_TARGET_REG_BITS == 32 || TARGET_LONG_BITS == 32) {
tcg_out_rlw(s, RLWINM, TCG_REG_R3, addrlo,
32 - (TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS),
32 - (CPU_TLB_BITS + CPU_TLB_ENTRY_BITS),
31 - CPU_TLB_ENTRY_BITS);
} else {
tcg_out_shli64(s, TCG_REG_R3, TCG_REG_R3, CPU_TLB_ENTRY_BITS);
}
tcg_out32(s, ADD | TAB(TCG_REG_R3, TCG_REG_R3, base));
if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) {
tcg_out_ld(s, TCG_TYPE_I32, TCG_REG_R4, TCG_REG_R3, cmp_off);
tcg_out_ld(s, TCG_TYPE_I32, TCG_REG_TMP1, TCG_REG_R3, cmp_off + 4);
} else {
tcg_out_ld(s, TCG_TYPE_TL, TCG_REG_TMP1, TCG_REG_R3, cmp_off);
}
tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_R3, TCG_REG_R3, add_off);
if (TCG_TARGET_REG_BITS == 32 || TARGET_LONG_BITS == 32) {
tcg_out_rlw(s, RLWINM, TCG_REG_R0, addrlo, 0,
(32 - s_bits) & 31, 31 - TARGET_PAGE_BITS);
} else if (!s_bits) {
tcg_out_rld(s, RLDICR, TCG_REG_R0, addrlo,
0, 63 - TARGET_PAGE_BITS);
} else {
tcg_out_rld(s, RLDICL, TCG_REG_R0, addrlo,
64 - TARGET_PAGE_BITS, TARGET_PAGE_BITS - s_bits);
tcg_out_rld(s, RLDICL, TCG_REG_R0, TCG_REG_R0, TARGET_PAGE_BITS, 0);
}
if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) {
tcg_out_cmp(s, TCG_COND_EQ, TCG_REG_R0, TCG_REG_TMP1,
0, 7, TCG_TYPE_I32);
tcg_out_cmp(s, TCG_COND_EQ, addrhi, TCG_REG_R4, 0, 6, TCG_TYPE_I32);
tcg_out32(s, CRAND | BT(7, CR_EQ) | BA(6, CR_EQ) | BB(7, CR_EQ));
} else {
tcg_out_cmp(s, TCG_COND_EQ, TCG_REG_R0, TCG_REG_TMP1,
0, 7, TCG_TYPE_TL);
}
return addrlo;
}
| 1threat
|
how can I creat button and picture horizontal : I want creat more button and picture horizontal or vertical
to be this picture
[enter image description here][1]
[1]: http://i.stack.imgur.com/ouNm1.png
pleas help me
| 0debug
|
Export to Excel in ASP.Net Core 2.0 : <p>I used to export data to excel in asp.net mvc using below code </p>
<pre><code> Response.AppendHeader("content-disposition", "attachment;filename=ExportedHtml.xls");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.ms-excel";
this.EnableViewState = false;
Response.Write(ExportDiv.InnerHtml);
Response.End();
</code></pre>
<p>When this Code Run it create a file and ask for a location to save </p>
<p>I tried working with NPOI and create Excel file very well but cant save file on client location .</p>
<p>Is there any way to make above code works on asp.net core 2.0 or any other way where I can save data in excel format on client machine ?</p>
| 0debug
|
int qemu_get_byte(QEMUFile *f)
{
if (f->is_write)
abort();
if (f->buf_index >= f->buf_size) {
qemu_fill_buffer(f);
if (f->buf_index >= f->buf_size)
return 0;
}
return f->buf[f->buf_index++];
}
| 1threat
|
what are some good scenarios in which to use reduce()? : <p>What are some good scenarios in which to use reduce()? I've used map() and filter() quite a bit but I don't use reduce(), mainly b/c I'm not exactly sure what the niche/benefits of the reduce() function are.</p>
| 0debug
|
SSLHandshakeException with jlink created runtime : <p>I've got a dropwizard app, which runs fine with the standard JRE.</p>
<p>I've tried creating a runtime using jlink which is considerably smaller:</p>
<pre><code>/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/bin/jlink --no-header-files --no-man-pages --compress=2 --strip-debug --add-modules java.base,java.compiler,java.desktop,java.instrument,java.logging,java.management,java.naming,java.scripting,java.security.jgss,java.sql,java.xml,jdk.attach,jdk.jdi,jdk.management,jdk.unsupported --output jre
</code></pre>
<p>If I run it with the jlink created runtime it throws this error connecting to redis (which has stunnel in front of it).</p>
<pre><code>ERROR [2019-03-31 09:12:20,080] com.company.project.core.WorkerThread: Failed to process message.
! javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
! at java.base/sun.security.ssl.Alert.createSSLException(Unknown Source)
! at java.base/sun.security.ssl.Alert.createSSLException(Unknown Source)
! at java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)
! at java.base/sun.security.ssl.Alert$AlertConsumer.consume(Unknown Source)
! at java.base/sun.security.ssl.TransportContext.dispatch(Unknown Source)
! at java.base/sun.security.ssl.SSLTransport.decode(Unknown Source)
! at java.base/sun.security.ssl.SSLSocketImpl.decode(Unknown Source)
! at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(Unknown Source)
! at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
! at java.base/sun.security.ssl.SSLSocketImpl.ensureNegotiated(Unknown Source)
! at java.base/sun.security.ssl.SSLSocketImpl$AppOutputStream.write(Unknown Source)
! at redis.clients.jedis.util.RedisOutputStream.flushBuffer(RedisOutputStream.java:52)
! at redis.clients.jedis.util.RedisOutputStream.flush(RedisOutputStream.java:133)
! at redis.clients.jedis.Connection.flush(Connection.java:300)
! ... 9 common frames omitted
! Causing: redis.clients.jedis.exceptions.JedisConnectionException: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
! at redis.clients.jedis.Connection.flush(Connection.java:303)
! at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:235)
! at redis.clients.jedis.BinaryJedis.auth(BinaryJedis.java:2225)
! at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:119)
! at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:888)
! at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:432)
! at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:361)
! at redis.clients.jedis.util.Pool.getResource(Pool.java:50)
! ... 2 common frames omitted
! Causing: redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
! at redis.clients.jedis.util.Pool.getResource(Pool.java:59)
! at redis.clients.jedis.JedisPool.getResource(JedisPool.java:234)
</code></pre>
<p>The stunnel server logs show:</p>
<pre><code>redis_1 | 09:12:20 stunnel.1 | 2019.03.31 09:12:20 LOG7[23]: TLS alert (write): fatal: handshake failure
redis_1 | 09:12:20 stunnel.1 | 2019.03.31 09:12:20 LOG3[23]: SSL_accept: 141F7065: error:141F7065:SSL routines:final_key_share:no suitable key share
redis_1 | 09:12:20 stunnel.1 | 2019.03.31 09:12:20 LOG5[23]: Connection reset: 0 byte(s) sent to TLS, 0 byte(s) sent to socket
</code></pre>
<p>Are there some crypt algorithms being left out by jlink?</p>
| 0debug
|
static int rtmp_server_handshake(URLContext *s, RTMPContext *rt)
{
uint8_t buffer[RTMP_HANDSHAKE_PACKET_SIZE];
uint32_t hs_epoch;
uint32_t hs_my_epoch;
uint8_t hs_c1[RTMP_HANDSHAKE_PACKET_SIZE];
uint8_t hs_s1[RTMP_HANDSHAKE_PACKET_SIZE];
uint32_t zeroes;
uint32_t temp = 0;
int randomidx = 0;
int inoutsize = 0;
int ret;
inoutsize = ffurl_read_complete(rt->stream, buffer, 1);
if (inoutsize <= 0) {
av_log(s, AV_LOG_ERROR, "Unable to read handshake\n");
return AVERROR(EIO);
}
if (buffer[0] != 3) {
av_log(s, AV_LOG_ERROR, "RTMP protocol version mismatch\n");
return AVERROR(EIO);
}
if (ffurl_write(rt->stream, buffer, 1) <= 0) {
av_log(s, AV_LOG_ERROR,
"Unable to write answer - RTMP S0\n");
return AVERROR(EIO);
}
ret = rtmp_receive_hs_packet(rt, &hs_epoch, &zeroes, hs_c1,
RTMP_HANDSHAKE_PACKET_SIZE);
if (ret) {
av_log(s, AV_LOG_ERROR, "RTMP Handshake C1 Error\n");
return ret;
}
if (zeroes)
av_log(s, AV_LOG_WARNING, "Erroneous C1 Message zero != 0\n");
hs_my_epoch = hs_epoch;
for (randomidx = 0; randomidx < (RTMP_HANDSHAKE_PACKET_SIZE);
randomidx += 4)
AV_WB32(hs_s1 + 8 + randomidx, av_get_random_seed());
ret = rtmp_send_hs_packet(rt, hs_my_epoch, 0, hs_s1,
RTMP_HANDSHAKE_PACKET_SIZE);
if (ret) {
av_log(s, AV_LOG_ERROR, "RTMP Handshake S1 Error\n");
return ret;
}
ret = rtmp_send_hs_packet(rt, hs_epoch, 0, hs_c1,
RTMP_HANDSHAKE_PACKET_SIZE);
if (ret) {
av_log(s, AV_LOG_ERROR, "RTMP Handshake S2 Error\n");
return ret;
}
ret = rtmp_receive_hs_packet(rt, &temp, &zeroes, buffer,
RTMP_HANDSHAKE_PACKET_SIZE);
if (ret) {
av_log(s, AV_LOG_ERROR, "RTMP Handshake C2 Error\n");
return ret;
}
if (temp != hs_my_epoch)
av_log(s, AV_LOG_WARNING,
"Erroneous C2 Message epoch does not match up with C1 epoch\n");
if (memcmp(buffer + 8, hs_s1 + 8,
RTMP_HANDSHAKE_PACKET_SIZE - 8))
av_log(s, AV_LOG_WARNING,
"Erroneous C2 Message random does not match up\n");
return 0;
}
| 1threat
|
How to use dapper with ASP.Net core Identity? : <p>I have a database and iam trying to use dapper with Core Identity to make queries to database. but i am stuck at this point. I am using a User from the interface of identityUser:</p>
<pre><code>public class User : IdentityUser
{
}
</code></pre>
<p>The with a making a custom user store for CRUD with dapper.</p>
<pre><code> public class UserStore : IUserStore<User>
{
private readonly string connectionString;
public UserStore(IConfiguration configuration)
{
connectionString = configuration.GetValue<string>("DBInfo:ConnectionString");
}
internal IDbConnection Connection
{
get
{
return new SqlConnection(connectionString);
}
}
public Task<IdentityResult> CreateAsync(User user, CancellationToken cancellationToken)
{
**// HOW TO I RETURN A USER WITH DAPPER HERE?**
}
public Task<IdentityResult> DeleteAsync(User user, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
public void Dispose()
{
throw new NotImplementedException();
}
public Task<User> FindByIdAsync(string userId, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
public Task<User> FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
public Task<string> GetUserIdAsync(User user, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
public Task<string> GetUserNameAsync(User user, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
public Task<IdentityResult> UpdateAsync(User user, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
</code></pre>
<p>thanks!</p>
| 0debug
|
static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
struct in_addr my_ip)
{
AVFormatContext *avc;
AVStream *avs = NULL;
AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL);
AVDictionaryEntry *entry = av_dict_get(stream->metadata, "title", NULL, 0);
int i;
avc = avformat_alloc_context();
if (avc == NULL || !rtp_format) {
return -1;
}
avc->oformat = rtp_format;
av_dict_set(&avc->metadata, "title",
entry ? entry->value : "No Title", 0);
avc->nb_streams = stream->nb_streams;
if (stream->is_multicast) {
snprintf(avc->filename, 1024, "rtp:
inet_ntoa(stream->multicast_ip),
stream->multicast_port, stream->multicast_ttl);
} else {
snprintf(avc->filename, 1024, "rtp:
}
if (avc->nb_streams >= INT_MAX/sizeof(*avc->streams) ||
!(avc->streams = av_malloc(avc->nb_streams * sizeof(*avc->streams))))
goto sdp_done;
if (avc->nb_streams >= INT_MAX/sizeof(*avs) ||
!(avs = av_malloc(avc->nb_streams * sizeof(*avs))))
goto sdp_done;
for(i = 0; i < stream->nb_streams; i++) {
avc->streams[i] = &avs[i];
avc->streams[i]->codec = stream->streams[i]->codec;
}
*pbuffer = av_mallocz(2048);
av_sdp_create(&avc, 1, *pbuffer, 2048);
sdp_done:
av_free(avc->streams);
av_dict_free(&avc->metadata);
av_free(avc);
av_free(avs);
return strlen(*pbuffer);
}
| 1threat
|
Confused about go syntax : <p>Little bit confused with this code. </p>
<pre><code>var _ QueryAppender = (*selectQuery)(nil)
</code></pre>
<p>I found this code in <a href="https://github.com/go-pg/pg/blob/master/orm/select.go" rel="nofollow noreferrer">pg-go</a>
repository and don't know why <code>QueryAppender</code> declared that way. Please explain me what is the use cases when I should declare variables that way. </p>
| 0debug
|
vuex store doesn't update component : <p>I'm new to vue, so I'm probably making a rookie error.</p>
<p>I have a root vue element - raptor.js:</p>
<pre><code>const Component = {
el: '#app',
store,
data: {
productList: store.state.productlist
},
beforeCreate: function () {
return store.dispatch('getProductList', 'getTrendingBrands');
},
updated: function (){
console.log(111);
startSlider();
}
};
const vm = new Vue(Component);
</code></pre>
<p>Using this template </p>
<pre><code><div class="grid-module-single popular-products" id="app">
<div class="row">
<div class="popular-items-slick col-xs-12">
<div v-for="product in productList">
...
</div>
</div>
</div>
</code></pre>
<p></p>
<p>My store is very simple store/index.js:</p>
<pre><code>import Vue from 'vue';
import Vuex from 'vuex';
import model from '../../utilities/model';
Vue.use(Vuex);
export default new Vuex.Store({
state: {
productlist: []
},
mutations: {
setProductList(state, data) {
state.productlist = data;
}
},
actions: {
getProductList({ commit }, action) {
return model.products().then(data => commit('setProductList', data));
}
}
});
</code></pre>
<p>In my vuex devtool, I can see, that the store is being updated
<a href="https://www.screencast.com/t/UGbw7JyHS3" rel="noreferrer">https://www.screencast.com/t/UGbw7JyHS3</a></p>
<p>but my component is not being updated:
<a href="https://www.screencast.com/t/KhXQrePEd" rel="noreferrer">https://www.screencast.com/t/KhXQrePEd</a></p>
<p><strong>Question:</strong></p>
<p>I can see from the devtools, that my code is working. The store is being updated with data. My component is not being updated,however. I thought it was enough just to add this in the data property on the component:</p>
<pre><code>data: {
productList: store.state.productlist
}
</code></pre>
<p>but apparently the data object doesn't seem to be automatically synced with the store. So either I'm doing a complete vue no-no somewhere, or I need to tweak the code a bit. Anyway can anyone help me in the right direction.</p>
<p>Thanks a lot.</p>
| 0debug
|
I was asked to print the integers in the given input string. For example input:Hai 88 Hello and its output: 88 : ***I got the correct output for the below code. Is there any other way that could solve the problem?***
*For example **input**:Hai 88 Hello **output:** 88*
package stringint;
import java.util.Scanner;
public class StringInt
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
String name = scan.nextLine();
name = name.replaceAll("[a-zA-Z]","@"); //replacing the
//alphabets to "@"
String[] array = name.split(" ");
for(int i = 0;i<array.length;i++)
{
if(!array[i].contains("@"))
{
System.out.println(array[i]);
}
}
}
}
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.