problem
stringlengths
26
131k
labels
class label
2 classes
static void config_error(Monitor *mon, const char *fmt, ...) { va_list ap; va_start(ap, fmt); if (mon) { monitor_vprintf(mon, fmt, ap); } else { fprintf(stderr, "qemu: "); vfprintf(stderr, fmt, ap); exit(1); } va_end(ap); }
1threat
Use PHP to deploy 20 minutes trial VPS powered by Scaleway : i just knew thats the http://instantcloud.io api link is https://try.cloud.online.net and i want to provide free 20 minutes VPS to my site visitors to enjoy more , ***of course i will leave credits to the instantcloud.io*** becoz they are the hosters can someone tell me some php examples to start building?
0debug
Get process memory on Windows : <p>I have a library in Ruby that shells out to get memory usage of the current process, I just received a report that it doesn't work on Windows. On mac and linux I can shell out to <code>ps -o rss= -p 3432</code> to get the RSS memory for process with a PID of 3432. Is there an equivalent command in Windows?</p>
0debug
how can i find out the row which i want in msyql , thanks a lot : I have mysql table like follow: id primary key, list_id int, item_id int, created timestamp. now , I want to find out the row's list_id which after I group by item_id, and fetch the row with the highest created. . . . . can someone tell me what sql query can do this, thanks a lot!
0debug
static void property_get_str(Object *obj, Visitor *v, void *opaque, const char *name, Error **errp) { StringProperty *prop = opaque; char *value; value = prop->get(obj, errp); if (value) { visit_type_str(v, &value, name, errp); g_free(value); } }
1threat
Webpack config has an unknown property 'preLoaders' : <p>I'm learning webpack from scratch. I've learned how to link javascript files with require. I'm bundling and minifying my js files and i'm listening for changes with watch. I'm setting up loaders to convert my sass files to css. But when I try to setup a linting process with jshint-loader, i'm running into issues.</p> <pre><code> module: { preLoaders: [ { test: /\.js$/, // include .js files exclude: /node_modules/, // exclude any and all files in the node_modules folder loader: "jshint-loader" } ], loaders: [ { test: /\.scss$/, loader: 'style-loader!css-loader!sass-loader' }, { test: /\.js$/, loader: 'babel-loader', exclude: /node_modules$/, query: { presets: ['es2015'] } } ], </code></pre> <p>}</p> <p>Here is the error</p> <blockquote> <p>Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. - configuration.module has an unknown property 'preLoaders'. These properties are valid: object { exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, loaders?, noParse?, rules?, unknownContextCritical?, unknownContextRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, wrappedContextCritical?, wrappedContextRecursive?, wrappedContextRegExp? } Options affecting the normal modules (<code>NormalModuleFactory</code>).</p> </blockquote>
0debug
Share Image element transition display incorrect size : <p>I have a recycle view to show all photo thumbnail items. When click on item, I use transition for imageview in this item to Detail activity. The problem is that image source is gotten from internet by <a href="https://github.com/nostra13/Android-Universal-Image-Loader" rel="noreferrer">UIL</a>. And <strong>sometime (not always) the images not reload correct size</strong> like this:</p> <p><a href="https://i.stack.imgur.com/aqDV4.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/aqDV4.jpg" alt="transition error"></a> </p> <pre><code> // on view holder item click final Pair&lt;View, String&gt;[] pairs = TransitionHelper.createSafeTransitionParticipants(this, false, new Pair&lt;&gt;(((ItemViewHolder) viewHolder).thumbnail, getString(R.string.TransitionName_Profile_Image)), new Pair&lt;&gt;(((ItemViewHolder) viewHolder).tvName, getString(R.string.TransitionName_Profile_Name))); ActivityOptionsCompat transitionActivityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(this, pairs); startActivityForResult(intent, requestCode, transitionActivityOptions.toBundle()); </code></pre> <p><strong>Detail activity</strong></p> <pre><code>// try to post pone transition until UIL load finish ActivityCompat.postponeEnterTransition(this); getSupportFragmentManager().beginTransaction().replace(R.id.layoutContent, new DetailFragment()).commit(); </code></pre> <p><strong>Fragment Detail</strong></p> <pre><code>ImageLoader.getInstance().displayImage(url, imageViewDetail, new ImageLoadingListener() { @Override public void onLoadingStarted(String imageUri, View view) { } @Override public void onLoadingFailed(String imageUri, View view, FailReason failReason) { finishAnimation(); } @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { finishAnimation(); } @Override public void onLoadingCancelled(String imageUri, View view) { finishAnimation(); } }); private void finishAnimation(){ ActivityCompat.startPostponedEnterTransition(getActivity()); imageViewDetail.invalidate(); } </code></pre> <p><strong>fragment_detail.xml</strong></p> <pre><code> &lt;FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;ImageView android:transitionName="@string/TransitionName.Profile.Image" android:id="@+id/imageViewDetail" android:layout_width="match_parent" android:layout_height="match_parent" android:adjustViewBounds="true" android:scaleType="centerCrop"/&gt; &lt;/FrameLayout&gt; </code></pre> <p>I even wait views are laid out before load image but still not work:</p> <pre><code>imageViewDetail.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { // code load image from UIL return false; } }); </code></pre> <p>Is there any way to avoid this issue?</p>
0debug
static int do_subchannel_work(SubchDev *sch) { if (!sch->do_subchannel_work) { return -EINVAL; } g_assert(sch->curr_status.scsw.ctrl & SCSW_CTRL_MASK_FCTL); return sch->do_subchannel_work(sch); }
1threat
need same result for as3 vaule in c# without using string[] : need same result for the vaule in c# //////////////////////////////////////////////////////////////////// result for as3 for below code - 1 , 2 , 3 var Items = ["1", "2", "3"].toString();
0debug
Am I doing that right? Scalling : I wrote code to make 2D transformation: scalling. ( value = variable from slider 1-10 ) DrawPixel(x*value/6.0,y*value/6.0,bits,255,255,255); And I received that output: [you can check here][1] [1]: https://i.stack.imgur.com/zXP1w.png As you can see I received a little breaks in that square. Is it okay or I have wrong code?
0debug
Static Polymorphism with boost variant single visitor vs multi visitor vs dynamic polymorphism : <p>I am comparing the performance of the following methods of C++ Polymorphism:</p> <p>Method [1]. static polymorphism using boost variants with a separate visitor for each method Method [2]. static polymorphism using boost variants with a single visitor that calls different method using method overloading Method [3]. Plain old dynamic polymorphism</p> <p>Platform: - Intel x86 64 bit Red Hat modern multi-core processor, 32 GB RAM - gcc (GCC) 4.8.1 with -O2 optimization - Boost 1.6.0</p> <p>Some findings:</p> <ul> <li>Method [1] seems to have significantly outperform Methods [2] and [3]</li> <li>Method [3] outperforms Method [2] most of the time</li> </ul> <p>My question is, why does Method [2] where I am using a visitor but using method overloading to call the correct method give worse performance than virtual methods. I would expect static polymorphism to fare better than dynamic polymorphism. I understand there is some cost of the extra parameter that is being passed in method [2] to figure which visit() method of the class to call and possibly some more branching due to method overloading? But shouldn"t this still outperform virtual methods?</p> <p>Code is below:</p> <pre><code>// qcpptest.hpp #ifndef INCLUDED_QCPPTEST_H #define INCLUDED_QCPPTEST_H #include &lt;boost/variant.hpp&gt; class IShape { public: virtual void rotate() = 0; virtual void spin() = 0; }; class Square : public IShape { public: void rotate() { // std::cout &lt;&lt; "Square:I am rotating" &lt;&lt; std::endl; } void spin() { // std::cout &lt;&lt; "Square:I am spinning" &lt;&lt; std::endl; } }; class Circle : public IShape { public: void rotate() { // std::cout &lt;&lt; "Circle:I am rotating" &lt;&lt; std::endl; } void spin() { // std::cout &lt;&lt; "Circle:I am spinning" &lt;&lt; std::endl; } }; // template variation // enum class M {ADD, DEL}; struct ADD {}; struct DEL {}; class TSquare { int i; public: void visit(const ADD&amp; add) { this-&gt;i++; // std::cout &lt;&lt; "TSquare:I am rotating" &lt;&lt; std::endl; } void visit(const DEL&amp; del) { this-&gt;i++; // std::cout &lt;&lt; "TSquare:I am spinning" &lt;&lt; std::endl; } void spin() { this-&gt;i++; // std::cout &lt;&lt; "TSquare:I am rotating" &lt;&lt; std::endl; } void rotate() { this-&gt;i++; // std::cout &lt;&lt; "TSquare:I am spinning" &lt;&lt; std::endl; } }; class TCircle { int i; public: void visit(const ADD&amp; add) { this-&gt;i++; // std::cout &lt;&lt; "TCircle:I am rotating" &lt;&lt; std::endl; } void visit(const DEL&amp; del) { this-&gt;i++; // std::cout &lt;&lt; "TCircle:I am spinning" &lt;&lt; std::endl; } void spin() { this-&gt;i++; // std::cout &lt;&lt; "TSquare:I am rotating" &lt;&lt; std::endl; } void rotate() { this-&gt;i++; // std::cout &lt;&lt; "TSquare:I am spinning" &lt;&lt; std::endl; } }; class MultiVisitor : public boost::static_visitor&lt;void&gt; { public: template &lt;typename T, typename U&gt; void operator()(T&amp; t, const U&amp; u) { // std::cout &lt;&lt; "visit" &lt;&lt; std::endl; t.visit(u); } }; // separate visitors, single dispatch class RotateVisitor : public boost::static_visitor&lt;void&gt; { public: template &lt;class T&gt; void operator()(T&amp; x) { x.rotate(); } }; class SpinVisitor : public boost::static_visitor&lt;void&gt; { public: template &lt;class T&gt; void operator()(T&amp; x) { x.spin(); } }; #endif // qcpptest.cpp #include &lt;iostream&gt; #include "qcpptest.hpp" #include &lt;vector&gt; #include &lt;boost/chrono.hpp&gt; using MV = boost::variant&lt;ADD, DEL&gt;; // MV const add = M::ADD; // MV const del = M::DEL; static MV const add = ADD(); static MV const del = DEL(); void make_virtual_shapes(int iters) { // std::cout &lt;&lt; "make_virtual_shapes" &lt;&lt; std::endl; std::vector&lt;IShape*&gt; shapes; shapes.push_back(new Square()); shapes.push_back(new Circle()); boost::chrono::high_resolution_clock::time_point start = boost::chrono::high_resolution_clock::now(); for (int i = 0; i &lt; iters; i++) { for (IShape* shape : shapes) { shape-&gt;rotate(); shape-&gt;spin(); } } boost::chrono::nanoseconds nanos = boost::chrono::high_resolution_clock::now() - start; std::cout &lt;&lt; "make_virtual_shapes took " &lt;&lt; nanos.count() * 1e-6 &lt;&lt; " millis\n"; } void make_template_shapes(int iters) { // std::cout &lt;&lt; "make_template_shapes" &lt;&lt; std::endl; using TShapes = boost::variant&lt;TSquare, TCircle&gt;; // using MV = boost::variant&lt; M &gt;; // xyz std::vector&lt;TShapes&gt; tshapes; tshapes.push_back(TSquare()); tshapes.push_back(TCircle()); MultiVisitor mv; boost::chrono::high_resolution_clock::time_point start = boost::chrono::high_resolution_clock::now(); for (int i = 0; i &lt; iters; i++) { for (TShapes&amp; shape : tshapes) { boost::apply_visitor(mv, shape, add); boost::apply_visitor(mv, shape, del); // boost::apply_visitor(sv, shape); } } boost::chrono::nanoseconds nanos = boost::chrono::high_resolution_clock::now() - start; std::cout &lt;&lt; "make_template_shapes took " &lt;&lt; nanos.count() * 1e-6 &lt;&lt; " millis\n"; } void make_template_shapes_single(int iters) { // std::cout &lt;&lt; "make_template_shapes_single" &lt;&lt; std::endl; using TShapes = boost::variant&lt;TSquare, TCircle&gt;; // xyz std::vector&lt;TShapes&gt; tshapes; tshapes.push_back(TSquare()); tshapes.push_back(TCircle()); SpinVisitor sv; RotateVisitor rv; boost::chrono::high_resolution_clock::time_point start = boost::chrono::high_resolution_clock::now(); for (int i = 0; i &lt; iters; i++) { for (TShapes&amp; shape : tshapes) { boost::apply_visitor(rv, shape); boost::apply_visitor(sv, shape); } } boost::chrono::nanoseconds nanos = boost::chrono::high_resolution_clock::now() - start; std::cout &lt;&lt; "make_template_shapes_single took " &lt;&lt; nanos.count() * 1e-6 &lt;&lt; " millis\n"; } int main(int argc, const char* argv[]) { std::cout &lt;&lt; "Hello, cmake" &lt;&lt; std::endl; int iters = atoi(argv[1]); make_virtual_shapes(iters); make_template_shapes(iters); make_template_shapes_single(iters); return 0; } </code></pre>
0debug
Need help on finding an undefined reference on function display() in C++ : <p>The goal of my assignment is to convert US dollars to Euros. All I need to do is prompt the user of an input and then use functions to get the output Im new to coding, and for the life of me can not find where I went wrong in declaring this function. any advice is appreciated.</p> <pre><code>#include &lt;iostream&gt; using namespace std; double getmoney(); double convert(); double display(); int main() { cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); getmoney(); display(); return 0; } double getmoney() { double money; cout &lt;&lt; "Please enter the amount in US Dollars: "; cin &gt;&gt; money; return money; } double convert(double money) { double euros; euros = money * 1.41; return euros; } double display(double money) { cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); double salad = convert(money); cout &lt;&lt; getmoney() &lt;&lt; endl; if (money &gt;= 0) cout &lt;&lt; "Euros: " &lt;&lt; salad; else (money &lt; 0); cout &lt;&lt; "Euros: " &lt;&lt; "(" &lt;&lt; salad &lt;&lt; ")"; return 0; } </code></pre>
0debug
How to achieve the below css animation effect : <p>I want to achieve the effect in <a href="https://wesbos.com" rel="nofollow noreferrer">https://wesbos.com</a> site where </p> <p>In the first line the text keeps changing as well as it expands in a cool style on hovering. I have only basic css knowledge . So any pointers or codepens to achieve the same would be helpful.</p>
0debug
qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2) { qemu_irq *s = g_malloc0(2 * sizeof(qemu_irq)); s[0] = irq1; s[1] = irq2; return qemu_allocate_irqs(qemu_splitirq, s, 1)[0]; }
1threat
void ppc6xx_irq_init (CPUState *env) { env->irq_inputs = (void **)qemu_allocate_irqs(&ppc6xx_set_irq, env, 6); }
1threat
static void imx_avic_write(void *opaque, target_phys_addr_t offset, uint64_t val, unsigned size) { IMXAVICState *s = (IMXAVICState *)opaque; if (offset >= 0x100 && offset <= 0x2fc) { IPRINTF("imx_avic_write to vector register %d ignored\n", (unsigned int)((offset - 0x100) >> 2)); return; } DPRINTF("imx_avic_write(0x%x) = %x\n", (unsigned int)offset>>2, (unsigned int)val); switch (offset >> 2) { case 0: s->intcntl = val & (ABFEN | NIDIS | FIDIS | NIAD | FIAD | NM); if (s->intcntl & ABFEN) { s->intcntl &= ~(val & ABFLAG); } break; case 1: s->intmask = val & 0x1f; break; case 2: DPRINTF("enable(%d)\n", (int)val); val &= 0x3f; s->enabled |= (1ULL << val); break; case 3: DPRINTF("disable(%d)\n", (int)val); val &= 0x3f; s->enabled &= ~(1ULL << val); break; case 4: s->enabled = (s->enabled & 0xffffffffULL) | (val << 32); break; case 5: s->enabled = (s->enabled & 0xffffffff00000000ULL) | val; break; case 6: s->is_fiq = (s->is_fiq & 0xffffffffULL) | (val << 32); break; case 7: s->is_fiq = (s->is_fiq & 0xffffffff00000000ULL) | val; break; case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: s->prio[15-(offset>>2)] = val; break; case 16: case 17: case 18: case 19: return; case 20: s->pending = (s->pending & 0xffffffffULL) | (val << 32); break; case 21: s->pending = (s->pending & 0xffffffff00000000ULL) | val; break; case 22: case 23: case 24: case 25: return; default: IPRINTF("imx_avic_write: Bad offset %x\n", (int)offset); } imx_avic_update(s); }
1threat
i need help making this little c++ program work : <p>Holy digits Batman! The Riddler is planning his next caper somewhere on Pennsylvania Avenue. In his usual sporting fashion, he has left the address in the form of a puzzle. The address on Pennsylvania is a four-digit number where: • All four digits are different • The digits in the thousandths place is three times the digit in the tens place • The number is odd • The sum of the digits is 27 Write a program that uses a loop (or loops) to find the address where the Riddler plans to strike. </p> <p>I'm not so sure where the program is going wrong. any help will be appreciated.</p> <pre><code>#include &lt;iostream&gt; using namespace std; void splitAddress(int address, int thou, int hund, int tens, int ones) { while (address &gt;= 1000) { address = address - 1000; thou++; } while (address &gt;= 100) { address = address - 100; hund++; } while (address &gt;= 10) { address = address - 10; tens++; } while (address &gt;= 1) { address = address - 1; ones++; } } void areIntsTheSame(int address, int thou, int hund, int tens, int ones) { if (thou == hund || thou == tens || thou == ones || hund == tens || hund == ones || tens != ones) { address--; } } void thou3tens(int address, int thou, int tens) { if (thou != 3 * tens) { address--; }  } void evenOrOdd(int address) { if (address % 2 == 0) { address--; } }  void Sum27(int address, int thou, int hund, int tens, int ones) { if ((thou + hund + tens + ones) != 27) { address--; }  }  int main() { int address = 9999; int thou = 0; int hund = 0; int tens = 0; int ones = 0; splitAddress(address); areIntsTheSame(address); thou3tens(address); evenOrOdd(address); Sum27(address); cout &lt;&lt; "the address is " &lt;&lt; address &lt;&lt; endl; system("pause"); return 0; } </code></pre> <p>thanks in advance. </p>
0debug
INotofyPropertyChanged wpf : OKe so i'm using .net 4.6.1 with wpf application. We have a list -> ObservableCOllection we want to bind the collection to a listview thats need to have sorting alphabetically and auto updating upon new item in the collection. I use COllectionViewSource and searched here on stackoverflow for updating I need to use InotificationPropertyChanged. But for some reason it doesnt work :(. object claas: using System.Text; using System.Threading.Tasks; namespace ObservableCollection { public class AlarmTypes : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; private string name; public AlarmTypes(string _name) { this.name = _name; } public string Name { get { return name; } set { name = value; OnPropertyChanged("Name"); } } protected void OnPropertyChanged(string prop) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(prop)); } } } } xaml file <Window x:Class="ObservableCollection.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:ObservableCollection" xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase" xmlns:clr="clr-namespace:System;assembly=mscorlib" mc:Ignorable="d" Title="MainWindow" Height="450" Width="800"> <Grid> <Grid.Resources> <CollectionViewSource x:Name="CollectionViewSource" x:Key="src" Source="{Binding alarmTypes }" IsLiveFilteringRequested="True"> <CollectionViewSource.LiveSortingProperties> <clr:String>Name</clr:String> </CollectionViewSource.LiveSortingProperties> <CollectionViewSource.SortDescriptions> <componentModel:SortDescription PropertyName="Name" /> </CollectionViewSource.SortDescriptions> </CollectionViewSource> </Grid.Resources> <ListView x:Name="lstAlarmTypes" HorizontalAlignment="Left" Height="319" Margin="585,48,0,0" VerticalAlignment="Top" Width="157" ItemsSource="{Binding Source={StaticResource src}}"> <ListView.View> <GridView> <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Name}" /> </GridView> </ListView.View> </ListView> <TextBox HorizontalAlignment="Left" Height="23" Margin="10,48,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" Name="textBox1"/> <Button Content="Add item" HorizontalAlignment="Left" Margin="173,51,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/> <ListView x:Name="LstNames2" HorizontalAlignment="Left" Height="301" Margin="339,66,0,0" VerticalAlignment="Top" Width="180"> <ListView.View> <GridView> <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Name}"/> </GridView> </ListView.View> </ListView> </Grid> </Window> xmal cs code: using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace ObservableCollection { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { private ObservableCollection<AlarmTypes> alarmTypes = new ObservableCollection<AlarmTypes>(); private ObservableCollection<AlarmTypes> sortedTypes = new ObservableCollection<AlarmTypes>(); public MainWindow() { InitializeComponent(); LstNames2.ItemsSource = alarmTypes; var alarmType = new AlarmTypes("inbraak"); alarmTypes.Add(alarmType); var alarmType2 = new AlarmTypes("alarm"); //alarmType.Name = textBox1.Text; alarmTypes.Add(alarmType2); } private void Button_Click(object sender, RoutedEventArgs e) { var alarmType = new AlarmTypes(textBox1.Text); //alarmType.Name = textBox1.Text; alarmTypes.Add(alarmType); } } } I don't know if the inding doesn't work or its the property or I still need something else. The first list has a binding just to the Observable collection and that works when inputting data from the textbox. But the second listview that has the collectionViewSource apparently doesn't work. any ideas whats missing?
0debug
assign address to a iterator : <p>AS we know that iterators in cpp points to a certain element of a container like if we talk about vector </p> <pre><code>vector &lt;int&gt; v = {1,2,3,4,5} vector&lt;int&gt;::iterator ptr; ptr=v.begin(); </code></pre> <p>Than ptr will point to first block of memory say 200 Let's declare another iterator</p> <pre><code>vector&lt;int&gt;::iterator ptrend; ptrend=v.end() which point to just next follow of last element say will be equal to 220 </code></pre> <p>My doubts</p> <p>1) And we know that <code>v.end()-v.begin() = v.size()</code> but which is not true in our case <code>220 -200 =20 != size</code></p> <p>2) Lets say <code>vector&lt;int&gt;::iterator ptr=v.begin();</code> here can we assign something like this <code>ptr = &amp;a[3]</code></p>
0debug
Pass args for solve_ivp (new SciPy ODE API) : <p>For solving simple ODEs using SciPy, I used to use the odeint function, with form:</p> <pre><code>scipy.integrate.odeint(func, y0, t, args=(), Dfun=None, col_deriv=0, full_output=0, ml=None, mu=None, rtol=None, atol=None, tcrit=None, h0=0.0, hmax=0.0, hmin=0.0, ixpr=0, mxstep=0, mxhnil=0, mxordn=12, mxords=5, printmessg=0)[source] </code></pre> <p>where a simple function to be integrated could include additional arguments of the form:</p> <pre><code>def dy_dt(t, y, arg1, arg2): # processing code here </code></pre> <p>In SciPy 1.0, it seems the <em>ode</em> and <em>odeint</em> funcs have been replaced by a newer <em>solve_ivp</em> method. </p> <pre><code>scipy.integrate.solve_ivp(fun, t_span, y0, method='RK45', t_eval=None, dense_output=False, events=None, vectorized=False, **options) </code></pre> <p>However, this doesn't seem to offer an <em>args</em> parameter, nor any indication in the documentation as to implementing the passing of args.</p> <p>Therefore, I wonder if arg passing is possible with the new API, or is this a feature that has yet to be added? (It would seem an oversight to me if this features has been intentionally removed?)</p> <p>Reference: <a href="https://docs.scipy.org/doc/scipy/reference/integrate.html" rel="noreferrer">https://docs.scipy.org/doc/scipy/reference/integrate.html</a></p>
0debug
static int flac_write_block_comment(AVIOContext *pb, AVDictionary **m, int last_block, int bitexact) { const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT; unsigned int len; uint8_t *p, *p0; ff_metadata_conv(m, ff_vorbiscomment_metadata_conv, NULL); len = ff_vorbiscomment_length(*m, vendor); p0 = av_malloc(len+4); if (!p0) return AVERROR(ENOMEM); p = p0; bytestream_put_byte(&p, last_block ? 0x84 : 0x04); bytestream_put_be24(&p, len); ff_vorbiscomment_write(&p, m, vendor); avio_write(pb, p0, len+4); av_freep(&p0); p = NULL; return 0; }
1threat
Difference web crawling and web scrapping : I am unable to actually figure out the difference between Web Crawling and web scrapping . if i am scrapping data from FedEx website using every tracking number is it web scrapping or web crawling please give a short and good example with difference thank you
0debug
alert('Hello ' + user_input);
1threat
Mongo DB - difference between standalone & 1-node replica set : <p>I needed to use Mongo DB transactions, and recently I understood that transactions don't work for Mongo standalone mode, but only for replica sets (<a href="https://stackoverflow.com/questions/56322333/mongo-db-with-c-sharp-document-added-regardless-of-transaction/56323934#56323934">Mongo DB with C# - document added regardless of transaction</a>).<br> Also, I read that standalone mode is not recommended for production.</p> <p>So I found out that simply defining a replica set name in the mongod.cfg is enough to run Mongo DB as a replica set instead of standalone.<br> After changing that, Mongo transactions started working.<br> However, it feels a bit strange using it as replica-set although I'm not really using the replication functionality, and I want to make sure I'm using a valid configuration.</p> <p>So my questions are:</p> <ol> <li>Is there any problem/disadvantage with running Mongo as a 1-node replica set, assuming I don't really need the replication, load balancing or any other scalable functionality? (as said I need it to allow transactions)</li> <li>What are the functionality and performance differences, if any, between running as standalone vs. running as a 1-node replica set?</li> <li>I've read that standalone mode is not recommended for production, although it sounds like it's the most basic configuration. I understand that this configuration is not used in most scenarios, but sometimes you may want to use it as a standard DB on a local machine. So why is standalone mode not recommended? Is it not stable enough, or other reasons?</li> </ol>
0debug
SyntaxError: Unexpected token } : <p>the code worked until line 48, after which it no longer worked. I would like to implement the switch on the "move" button on line 50-62, but this gave me the error Error: Uncaught SyntaxError: Unexpected token }</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="1.js"&gt;&lt;/script&gt; &lt;title&gt;Prova Jquery&lt;/title&gt; &lt;!-- Fogli di stile --&gt; &lt;!-- Required meta tags --&gt; &lt;meta charset="utf-8"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"&gt; &lt;!-- Bootstrap CSS --&gt; &lt;link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"&gt; &lt;body&gt; &lt;div class="container" id="effetti"&gt; &lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipisci elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur Lorem ipsum dolor sit amet, consectetur adipisci elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur&lt;/p&gt; &lt;a href="https://www.google.it/"&gt;vai su google&lt;/a&gt; &lt;button type="button "id="nascondi-immagine"&gt;Nascondi &lt;/button&gt; &lt;button type="button" id="mostra-immagine"&gt;Mostra &lt;/button&gt; &lt;button type="button" id="sposta-immagine"&gt;Sposta &lt;/button&gt; &lt;p&gt;&lt;img src="blu.jpg" \&gt;&lt;/p&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>file 1.js :</p> <pre><code>$(function(){ $("#effetti") .fadeIn(12000);//effetto opacita in 12 secondi $("#effetti")//sul DIV che si chiama effetti .on({ //permette di fare qualcosa intercettando un evento (click, mouseover, onclick..) mouseover: function(){//creo una function anonima console.log("MOUSE OVER"); }, //sotto scrivo un'altra funzione sempre ANONIMA click: function(){//tutte le volte che scrivo "nome-evento" e due punti dentro gli passo un oggetto console.log("CLICK"); } }); $("#nascondi-immagine") .on({ click:function(){//quando faccio click $("img").hide();//devi nascondere l'immagine } }); $("#mostra-immagine") .on({ click:function(){ $("img").fadeIn(3000);//immagine deve comparire in 3' } }); //prEventDefault serve a prevenire il comportamento di default del dom html $("#effetti a")//sul DIV che si chiama effetti SELEZIONO gli elementi a .on({ //permette di fare qualcosa intercettando un evento (click, mouseover, onclick..) click:function(e){//passo un parametro "e" che corrisponde all'elemento "a" in pratica e.preventDefault(); } }); $(window) .on("load", function(){ $("#effetti") .css({ "margin-top":10% }); }); $(window)//l'oggetto window di js .on("load",function(){//scrivo load ed apro un function anonima $("#sposta-immagine") .on({ click:function(){//al compimento di questa azione ovvero click su bottone $("effetti")//sul DIV che si chiama effetti .css({ "background":"red", "margin-left":10% }); } }); }); }); </code></pre> <p>when I update the 1.js file even if I delete the function from line 50-62 it continues to give me the usual error. in the sense the google chrome console always gives me the old error on that code even if that code has been deleted</p>
0debug
Disable Autocomplete on . (dot) in VSCode : <p>Example: trying to type "return res.data"</p> <p>after typing the . it autocompletes to "return resizeBy."</p> <p>Have already turned off autocomplete on enter, and don't want to turn off "editor.quickSuggestions" completely as I still like the menu coming up (just not taking over too much). Can't find very much about this online at all - cheers!</p>
0debug
Mongoose - Why we make "mongoose.Promise = global.Promise" when setting a mongoose module? : <p>I'm working with Mongoose. I have seen a lot of developers make the following command: </p> <pre><code>mongoose.Promise = global.Promise; </code></pre> <p>Then I was curious to see what is the original value of <code>mongoose.Promise</code> . I have entered in my editor the following command: </p> <pre><code>const mongoose = require("mongoose"); console.log("promise: ", mongoose.Promise); </code></pre> <p>My console returned me : </p> <blockquote> <p>promise: function Promise() { [native code] }</p> </blockquote> <p>Okay, so why make the command <code>mongoose.Promise = global.Promise</code> since the Mongoose's promise already returns a native code ? I don't understand the point, if someone can help us to understand, would be great,</p> <p>Thanks</p>
0debug
static void avc_luma_hv_qrt_and_aver_dst_16x16_msa(const uint8_t *src_x, const uint8_t *src_y, int32_t src_stride, uint8_t *dst, int32_t dst_stride) { uint32_t multiple8_cnt; for (multiple8_cnt = 2; multiple8_cnt--;) { avc_luma_hv_qrt_and_aver_dst_8x8_msa(src_x, src_y, src_stride, dst, dst_stride); src_x += 8; src_y += 8; dst += 8; } src_x += (8 * src_stride) - 16; src_y += (8 * src_stride) - 16; dst += (8 * dst_stride) - 16; for (multiple8_cnt = 2; multiple8_cnt--;) { avc_luma_hv_qrt_and_aver_dst_8x8_msa(src_x, src_y, src_stride, dst, dst_stride); src_x += 8; src_y += 8; dst += 8; } }
1threat
static int bit_allocation(IMCContext *q, IMCChannel *chctx, int stream_format_code, int freebits, int flag) { int i, j; const float limit = -1.e20; float highest = 0.0; int indx; int t1 = 0; int t2 = 1; float summa = 0.0; int iacc = 0; int summer = 0; int rres, cwlen; float lowest = 1.e10; int low_indx = 0; float workT[32]; int flg; int found_indx = 0; for (i = 0; i < BANDS; i++) highest = FFMAX(highest, chctx->flcoeffs1[i]); for (i = 0; i < BANDS - 1; i++) chctx->flcoeffs4[i] = chctx->flcoeffs3[i] - log2f(chctx->flcoeffs5[i]); chctx->flcoeffs4[BANDS - 1] = limit; highest = highest * 0.25; for (i = 0; i < BANDS; i++) { indx = -1; if ((band_tab[i + 1] - band_tab[i]) == chctx->bandWidthT[i]) indx = 0; if ((band_tab[i + 1] - band_tab[i]) > chctx->bandWidthT[i]) indx = 1; if (((band_tab[i + 1] - band_tab[i]) / 2) >= chctx->bandWidthT[i]) indx = 2; if (indx == -1) chctx->flcoeffs4[i] += xTab[(indx * 2 + (chctx->flcoeffs1[i] < highest)) * 2 + flag]; } if (stream_format_code & 0x2) { chctx->flcoeffs4[0] = limit; chctx->flcoeffs4[1] = limit; chctx->flcoeffs4[2] = limit; chctx->flcoeffs4[3] = limit; } for (i = (stream_format_code & 0x2) ? 4 : 0; i < BANDS - 1; i++) { iacc += chctx->bandWidthT[i]; summa += chctx->bandWidthT[i] * chctx->flcoeffs4[i]; } chctx->bandWidthT[BANDS - 1] = 0; summa = (summa * 0.5 - freebits) / iacc; for (i = 0; i < BANDS / 2; i++) { rres = summer - freebits; if ((rres >= -8) && (rres <= 8)) break; summer = 0; iacc = 0; for (j = (stream_format_code & 0x2) ? 4 : 0; j < BANDS; j++) { cwlen = av_clipf(((chctx->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6); chctx->bitsBandT[j] = cwlen; summer += chctx->bandWidthT[j] * cwlen; if (cwlen > 0) iacc += chctx->bandWidthT[j]; } flg = t2; t2 = 1; if (freebits < summer) t2 = -1; if (i == 0) flg = t2; if (flg != t2) t1++; summa = (float)(summer - freebits) / ((t1 + 1) * iacc) + summa; } for (i = (stream_format_code & 0x2) ? 4 : 0; i < BANDS; i++) { for (j = band_tab[i]; j < band_tab[i + 1]; j++) chctx->CWlengthT[j] = chctx->bitsBandT[i]; } if (freebits > summer) { for (i = 0; i < BANDS; i++) { workT[i] = (chctx->bitsBandT[i] == 6) ? -1.e20 : (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] - 0.415); } highest = 0.0; do { if (highest <= -1.e20) break; found_indx = 0; highest = -1.e20; for (i = 0; i < BANDS; i++) { if (workT[i] > highest) { highest = workT[i]; found_indx = i; } } if (highest > -1.e20) { workT[found_indx] -= 2.0; if (++chctx->bitsBandT[found_indx] == 6) workT[found_indx] = -1.e20; for (j = band_tab[found_indx]; j < band_tab[found_indx + 1] && (freebits > summer); j++) { chctx->CWlengthT[j]++; summer++; } } } while (freebits > summer); } if (freebits < summer) { for (i = 0; i < BANDS; i++) { workT[i] = chctx->bitsBandT[i] ? (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] + 1.585) : 1.e20; } if (stream_format_code & 0x2) { workT[0] = 1.e20; workT[1] = 1.e20; workT[2] = 1.e20; workT[3] = 1.e20; } while (freebits < summer) { lowest = 1.e10; low_indx = 0; for (i = 0; i < BANDS; i++) { if (workT[i] < lowest) { lowest = workT[i]; low_indx = i; } } workT[low_indx] = lowest + 2.0; if (!--chctx->bitsBandT[low_indx]) workT[low_indx] = 1.e20; for (j = band_tab[low_indx]; j < band_tab[low_indx+1] && (freebits < summer); j++) { if (chctx->CWlengthT[j] > 0) { chctx->CWlengthT[j]--; summer--; } } } } return 0; }
1threat
void ff_vp3_idct_altivec(DCTELEM block[64]) { IDCT_START IDCT_1D(NOP, NOP) TRANSPOSE8(b0, b1, b2, b3, b4, b5, b6, b7); IDCT_1D(ADD8, SHIFT4) vec_st(b0, 0x00, block); vec_st(b1, 0x10, block); vec_st(b2, 0x20, block); vec_st(b3, 0x30, block); vec_st(b4, 0x40, block); vec_st(b5, 0x50, block); vec_st(b6, 0x60, block); vec_st(b7, 0x70, block); }
1threat
static void kvm_mce_broadcast_rest(CPUState *env) { CPUState *cenv; int family, model, cpuver = env->cpuid_version; family = (cpuver >> 8) & 0xf; model = ((cpuver >> 12) & 0xf0) + ((cpuver >> 4) & 0xf); if ((family == 6 && model >= 14) || family > 6) { for (cenv = first_cpu; cenv != NULL; cenv = cenv->next_cpu) { if (cenv == env) { continue; } kvm_inject_x86_mce(cenv, 1, MCI_STATUS_VAL | MCI_STATUS_UC, MCG_STATUS_MCIP | MCG_STATUS_RIPV, 0, 0, ABORT_ON_ERROR); } } }
1threat
Android Firebase How to Read the data from current user id? : this is my code i want to read the current user id data from firebase...Please Help > DatabaseReference ref2; > ref2=db.getReference("HiringWalker").child(FirebaseAuth.getInstance().getCurrentUser().getUid()); [![enter image description here][1]][1] [![enter image description here][2]][2] i want to read the current user id and -Lwg_.... all the data. [1]: https://i.stack.imgur.com/2ZTel.jpg [2]: https://i.stack.imgur.com/kTQbB.jpg
0debug
Android : FileProvider on custom external storage folder : <p>I'm trying to set up a fileprovider for sharing file. My files are saved in a folder "AppName" in the external storage (same level as Android, Movies and Pictures folders).</p> <p>Here is my file provider config :</p> <pre><code>&lt;provider android:name="android.support.v4.content.FileProvider" android:authorities="com.mydomain.appname.fileprovider" android:exported="false" android:grantUriPermissions="true"&gt; &lt;meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"/&gt; &lt;/provider&gt; </code></pre> <p>and the file_paths.xml :</p> <pre><code>&lt;paths xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;external-path name="mypath" path="AppName" /&gt; &lt;/paths&gt; </code></pre> <p>When i try to access my file with :</p> <pre><code>Uri fileUri = FileProvider.getUriForFile(activity, "com.mydomain.appname.fileprovider", new File("/storage/emulated/0/AppName/IMG_20160419_095211.jpg")); </code></pre> <p>It returns an error: java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/emulated/0/AppName/IMG_20160419_095211.jpg at android.support.v4.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:678) at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:377)</p> <p>It worked fine before when I was using built-in directory like Pictures or Movies, my file_paths.xml was define like this :</p> <pre><code>&lt;external-path name="photos" path="Pictures" /&gt; &lt;external-path name="videos" path="Movies" /&gt; </code></pre> <p>But now I want to store my file in my own folder. Did I miss something with the FileProvider config ?</p>
0debug
def extract_string(str, l): result = [e for e in str if len(e) == l] return result
0debug
Split a string using a regex : <p>I would like to split the following str into an array that has 2 elements, the first being 'Some words in a sentence', the second being 'ABC' where ABC can be any upper case character.</p> <pre><code>const str = 'Some words in a sentence (ABC)'; const regex = ? const arr = str.split(regex); ... expect(arr[0]).to.eq('Some words in a sentence'); expect(arr[1]).to.eq('ABC'); expect(arr.length).to.eq(2); </code></pre> <p>Any thoughts would be appreciated.</p> <p>Cheers,</p> <p>Paul</p>
0debug
installation path not writable R, unable to update packages : <p>I am trying to install Bioconductor into R, using the code on their website. When I type in the code (see bellow) I get an error message saying that some packages can't be updated, the installation path is unwriteable.</p> <pre><code>&gt; ## try http:// if https:// URLs are not supported &gt; source("https://bioconductor.org/biocLite.R") Bioconductor version 3.4 (BiocInstaller 1.24.0), ?biocLite for help &gt; biocLite() BioC_mirror: https://bioconductor.org Using Bioconductor 3.4 (BiocInstaller 1.24.0), R 3.3.2 (2016-10-31). installation path not writeable, unable to update packages: Matrix, mgcv, </code></pre> <p>survival</p> <p>I can install these package by going to packages/install packages.</p> <pre><code>&gt; utils:::menuInstallPkgs() trying URL 'https://www.stats.bris.ac.uk/R/bin/windows/contrib/3.3/Matrix_1.2-8.zip' Content type 'application/zip' length 2775038 bytes (2.6 MB) downloaded 2.6 MB trying URL 'https://www.stats.bris.ac.uk/R/bin/windows/contrib/3.3/mgcv_1.8- 16.zip' Content type 'application/zip' length 2346257 bytes (2.2 MB) downloaded 2.2 MB trying URL 'https://www.stats.bris.ac.uk/R/bin/windows/contrib/3.3/survival_2.40-1.zip' Content type 'application/zip' length 5109948 bytes (4.9 MB) downloaded 4.9 MB package ‘Matrix’ successfully unpacked and MD5 sums checked package ‘mgcv’ successfully unpacked and MD5 sums checked package ‘survival’ successfully unpacked and MD5 sums checked The downloaded binary packages are in C:\Users\stxeb8\AppData\Local\Temp\Rtmp2tQZ4v\downloaded_packages </code></pre> <p>I can then go to packages/ load packages and load them succesfully and search and see that the packages are there.</p> <pre><code>&gt; local({pkg &lt;- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE) + if(nchar(pkg)) library(pkg, character.only=TRUE)}) Loading required package: nlme This is mgcv 1.8-16. For overview type 'help("mgcv-package")'. &gt; local({pkg &lt;- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE) + if(nchar(pkg)) library(pkg, character.only=TRUE)}) &gt; local({pkg &lt;- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE) + if(nchar(pkg)) library(pkg, character.only=TRUE)}) &gt; local({pkg &lt;- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE) + if(nchar(pkg)) library(pkg, character.only=TRUE)}) &gt; search() [1] ".GlobalEnv" "package:survival" "package:mgcv" [4] "package:nlme" "package:Matrix" "package:BiocInstaller" [7] "package:stats" "package:graphics" "package:grDevices" [10] "package:utils" "package:datasets" "package:methods" [13] "Autoloads" "package:base" </code></pre> <p>But then when I go to install bioconductor it gives me the same error message that Matrix, mgcv and survival aren't able to be updated.</p> <pre><code>&gt; ## try http:// if https:// URLs are not supported &gt; source("https://bioconductor.org/biocLite.R") Bioconductor version 3.4 (BiocInstaller 1.24.0), ?biocLite for help &gt; biocLite() BioC_mirror: https://bioconductor.org Using Bioconductor 3.4 (BiocInstaller 1.24.0), R 3.3.2 (2016-10-31). installation path not writeable, unable to update packages: Matrix, mgcv, survival </code></pre> <p>What can I do to be able to update these packages so I can install bioconductor?</p>
0debug
Java program, what did I do wrong? : I am new to java and programming. I have sort of a grasp on the concept but not entirely sure. This problem uses a scanner to read from another file to get information on amount of energy produced. <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> import java.util.Scanner; import java.io.File; public class HJUnit3 { public static void main(String[] args) throws Exception { // Scanner stdIn = new Scanner(System.in); Scanner stdIn = new Scanner(new File("energyProduced.txt")); stdIn.nextLine(); double energy; energy = stdIn.nextLine(); int systemsCost; //Total Systems Cost double ttlEnergy; //Total energy produced in a week double savingsWeek; //Total savings for one week double savingsDay; //Total savings for one day double recoupDay; //Days to recoup double recoupYear; //Years to recoup final double electricCost = 0.085; systemsCost = (savingsWeek * energy); System.out.println("Total System Cost = $" + systemsCost ); System.out.println("Total Energy Produced in one week" + (energy * 7) + "Kwh"); savingsWeek = (ttlEnergy * electricCost); System.out.println("Total Savings for one week =" + savingsWeek); savingsDay = (savingsWeek / 7); System.out.println("Total Savings for one day =" + savingsDay); recoupDay = (systemsCost / savingsDay); System.out.println("Days to recoup cost(truncated)" + recoupDay); recoupYear = (recoupDay / 365); System.out.println("Years to recoup cost(truncated)"); } // end main } // end HJUnit3 class <!-- end snippet --> It gives me this error "error: incompatible types: String cannot be converted to double energy = stdIn.next();" and this "error: incompatible types: possible lossy conversion from double to int systemsCost = (savingsWeek * energy);" What did I do wrong, not really sure.
0debug
why array values overwrite in names column just yellow imsert?(replace) : code is here if any one know please let me know. i am very thankful to you guys.i want to insert one by one in names table <?php $conn = new mysqli($servername, $username, "", $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $value=$_POST['names']; $colors = array("red", "green", "blue", "yellow"); foreach ($colors as $value) { $query ="insert into test(names) values('$value')"; } if ($conn->query($query) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } $conn->close(); ?>
0debug
static void ehci_reset(void *opaque) { EHCIState *s = opaque; int i; USBDevice *devs[NB_PORTS]; trace_usb_ehci_reset(); for(i = 0; i < NB_PORTS; i++) { devs[i] = s->ports[i].dev; if (devs[i]) { usb_attach(&s->ports[i], NULL); } } memset(&s->mmio[OPREGBASE], 0x00, MMIO_SIZE - OPREGBASE); s->usbcmd = NB_MAXINTRATE << USBCMD_ITC_SH; s->usbsts = USBSTS_HALT; s->astate = EST_INACTIVE; s->pstate = EST_INACTIVE; s->isoch_pause = -1; s->attach_poll_counter = 0; for(i = 0; i < NB_PORTS; i++) { if (s->companion_ports[i]) { s->portsc[i] = PORTSC_POWNER | PORTSC_PPOWER; } else { s->portsc[i] = PORTSC_PPOWER; } if (devs[i]) { usb_attach(&s->ports[i], devs[i]); } } ehci_queues_rip_all(s); }
1threat
static void find_best_tables(MpegEncContext * s) { int i; int best =-1, best_size =9999999; int chroma_best=-1, best_chroma_size=9999999; for(i=0; i<3; i++){ int level; int chroma_size=0; int size=0; if(i>0){ size++; chroma_size++; } for(level=0; level<=MAX_LEVEL; level++){ int run; for(run=0; run<=MAX_RUN; run++){ int last; const int last_size= size + chroma_size; for(last=0; last<2; last++){ int inter_count = s->ac_stats[0][0][level][run][last] + s->ac_stats[0][1][level][run][last]; int intra_luma_count = s->ac_stats[1][0][level][run][last]; int intra_chroma_count= s->ac_stats[1][1][level][run][last]; if(s->pict_type==AV_PICTURE_TYPE_I){ size += intra_luma_count *rl_length[i ][level][run][last]; chroma_size+= intra_chroma_count*rl_length[i+3][level][run][last]; }else{ size+= intra_luma_count *rl_length[i ][level][run][last] +intra_chroma_count*rl_length[i+3][level][run][last] +inter_count *rl_length[i+3][level][run][last]; } } if(last_size == size+chroma_size) break; } } if(size<best_size){ best_size= size; best= i; } if(chroma_size<best_chroma_size){ best_chroma_size= chroma_size; chroma_best= i; } } if(s->pict_type==AV_PICTURE_TYPE_P) chroma_best= best; memset(s->ac_stats, 0, sizeof(int)*(MAX_LEVEL+1)*(MAX_RUN+1)*2*2*2); s->rl_table_index = best; s->rl_chroma_table_index= chroma_best; if(s->pict_type != s->last_non_b_pict_type){ s->rl_table_index= 2; if(s->pict_type==AV_PICTURE_TYPE_I) s->rl_chroma_table_index= 1; else s->rl_chroma_table_index= 2; } }
1threat
def extract_unique(test_dict): res = list(sorted({ele for val in test_dict.values() for ele in val})) return res
0debug
static void avc_wgt_4width_msa(uint8_t *data, int32_t stride, int32_t height, int32_t log2_denom, int32_t src_weight, int32_t offset_in) { if (2 == height) { avc_wgt_4x2_msa(data, stride, log2_denom, src_weight, offset_in); } else { avc_wgt_4x4multiple_msa(data, stride, height, log2_denom, src_weight, offset_in); } }
1threat
static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg, int jobnr, int threadnr) { DNXHDEncContext *ctx = avctx->priv_data; int mb_y = jobnr, mb_x; ctx = ctx->thread[threadnr]; if (ctx->cid_table->bit_depth == 8) { uint8_t *pix = ctx->thread[0]->src[0] + ((mb_y<<4) * ctx->m.linesize); for (mb_x = 0; mb_x < ctx->m.mb_width; ++mb_x, pix += 16) { unsigned mb = mb_y * ctx->m.mb_width + mb_x; int sum = ctx->m.dsp.pix_sum(pix, ctx->m.linesize); int varc = (ctx->m.dsp.pix_norm1(pix, ctx->m.linesize) - (((unsigned)(sum*sum))>>8)+128)>>8; ctx->mb_cmp[mb].value = varc; ctx->mb_cmp[mb].mb = mb; } } else { int const linesize = ctx->m.linesize >> 1; for (mb_x = 0; mb_x < ctx->m.mb_width; ++mb_x) { uint16_t *pix = (uint16_t*)ctx->thread[0]->src[0] + ((mb_y << 4) * linesize) + (mb_x << 4); unsigned mb = mb_y * ctx->m.mb_width + mb_x; int sum = 0; int sqsum = 0; int mean, sqmean; for (int i = 0; i < 16; ++i) { for (int j = 0; j < 16; ++j) { int const sample = (unsigned)pix[j] >> 6; sum += sample; sqsum += sample * sample; } pix += linesize; } mean = sum >> 8; sqmean = sqsum >> 8; ctx->mb_cmp[mb].value = sqmean - mean * mean; ctx->mb_cmp[mb].mb = mb; } } return 0; }
1threat
Implementing a non-copyable C++ class : <p>In Visual Studio 2019, I am trying, without success, to implement the technique for making a class non-copyable shown for C++11, and later, at the accepted answer at <a href="https://stackoverflow.com/questions/2173746/how-do-i-make-this-c-object-non-copyable"><em>How do I make this C++ object non-copyable?</em></a>.</p> <p>My class is,</p> <pre><code>class Foo { public: Foo(); Foo(std::string name); ~Foo(); std::string m_name; static std::int32_t s_counter; public: Foo(const Foo&amp; inFoo) = delete; Foo&amp; operator=(const Foo&amp; inFoo) = delete; }; </code></pre> <p>The definition code is,</p> <pre><code>std::int32_t Foo::s_counter = 0; Foo::Foo(void) { Foo::s_counter++; std::cout &lt;&lt; "Foo constructor. Count = " &lt;&lt; Foo::s_counter &lt;&lt; std::endl; } Foo::Foo(std::string name) { Foo::s_counter++; m_name = name; std::cout &lt;&lt; "Foo " &lt;&lt; m_name &lt;&lt; " constructor. Count = " &lt;&lt; Foo::s_counter &lt;&lt; std::endl; } Foo::~Foo() { Foo::s_counter--; std::cout &lt;&lt; "Foo destructor. Count = " &lt;&lt; Foo::s_counter &lt;&lt; std::endl; } </code></pre> <p>It is used in,</p> <pre><code>int main(int argc, char** argv) { std::vector&lt;Foo&gt; fooVector; { Foo myFoo1{ Foo() }; fooVector.push_back(std::move(myFoo1)); Foo myFoo2{ Foo("myFoo2") }; fooVector.push_back(std::move(myFoo2)); } if (Foo::s_counter &lt; 0) { std::cout &lt;&lt; "Foo object count = " &lt;&lt; Foo::s_counter &lt;&lt; std::endl; } std::cin.get(); } </code></pre> <p>in which I have intentionally scoped the definition of <code>myFoo1</code> and <code>myFoo2</code> so as to get object count feedback.</p> <p>When the copy constructor and assignment constructor are made <code>public</code>, as shown, the compile error is "C2280 'Foo::Foo(const Foo &amp;)': attempting to reference a deleted function". When they are made private, the compile error is "C2248 'Foo::Foo': cannot access private member declared in class 'Foo'".</p> <p>I believe I am misinterpreting something in the original SO answer, but I cannot see what it is.</p>
0debug
The best way to let user go to another webpage after 2 minutes : <p>How can I do that with HTML5, CSS3, JavaScript, jQuery? Thanks a lot</p>
0debug
Visual studio SDL : I installed recently sdl2 of visual studio but I'm having problems when I have to load an image. Practically the window closes immediately without regard to whether the image is loaded. I used the code on lazyfoo.net. http://lazyfoo.net/tutorials/SDL/02_getting_an_image_on_the_screen/index.php+ Can you help me?
0debug
Are there plans to develop a golang version of Android? : <p>I've looked around a bit but I can't find a discussion about a version of Android built directly from <code>golang</code> source code and little or no Java.</p> <p>I see there's an Android 9 (Go edition) version. But it looks like it's just more Java with Golang bindings: <a href="https://www.android.com/versions/go-edition" rel="noreferrer">https://www.android.com/versions/go-edition</a>. Or is this a native <code>Go</code> Android?</p>
0debug
How to create realistic .scn files? : <p>Looking at the apple sample AR app, there are many realistic looking objects (cup, candle, etc). However working with the scene kit editor on Xcode it is clear that this only allows you to create basic objects. </p> <p>My question is, what software/file can be used to create realistic <code>scn</code> objects? I'm sure that there is software that allows you to create 3D models and covert them to <code>scn</code> files. I just don't know which software to use or what files can be converted to <code>scn</code></p> <p><strong>Note:</strong> I understand that this question may be too vague/broad for the Stackoverflow guidelines. I just don't know where to pose my question and this seems like the best place</p>
0debug
Javascript program is not recognizing an if statement : <p>The program is running an else statement when I'm expecting an if statement to run. When the program checks the gameObject's playerSelections property against the gameObject's colorSequence property I expect the program to log 'You got it. Way to go!' if the two arrays are equivalent. Instead I keep getting the console log statement 'Better luck next time!'. Does anyone have any ideas as to why this may be happening. `</p> <pre><code>const $headerText = $('.fly-in-text'); setTimeout(function() { $headerText.removeClass('temp-hide'); }, 500); let gameObject = { colorIds: ['#blue', '#red', '#green', '#yellow'], currentLevel: 1, colorSequence: [], playerSelections: [], illuminate:function(color){ setTimeout(function(){ $(color).css('opacity', .5); setTimeout(function() { $(color).css('opacity', 1); },500); },500); }, levelSequence: function(){ const iterationCount = this.currentLevel + 2; for (let i = 0; i &lt; iterationCount; i++) { this.colorSequence.push(this.colorIds[Math.floor(Math.random() * 4)]); } this.startGame(this.colorSequence); }, startGame: function(sequence) { let i = 0; const self = this; var interval = setInterval(function(){ self.illuminate(sequence[i]); i++; if (i &gt;= sequence.length){ clearInterval(interval); } }, 1000); } } $circle.click(function() { clearTimeout(interval); $(this).toggleClass('rotate'); gameObject.levelSequence(); $('.colors').click(function(){ gameObject.playerSelections.push(`#${this.id}`); console.log(gameObject.playerSelections); checkForWin(); // for (let i = 0; i &lt; gameObject.colorSequence.length; i++) { // playerSelections[i] = (`$${this.id}`); // console.log(playerSelections) // } }) }) function checkForWin(){ if (gameObject.playerSelections === gameObject.colorSequence){ console.log('Comparing') if (gameObject.playerSelections === gameObject.colorSequence){ console.log('You got it. Way to go!'); gameObject.colorSequence = []; gameObject.playerSelections = []; gameObject.currentLevel += 1; $('.colors').off('click'); return 'You got it. Way to go!'; } else { gameObject.colorSequence = []; gameObject.playerSelections = []; $('.colors').off('click') console.log('Better luck next time!'); } } } </code></pre>
0debug
Trying to sort a list with fruit.sort() : I am trying to sort the list (fruit) after I have appended the contents of another file to it, and prior to writing it to the the txt file "fruit_salad.txt". The problem I am having is that as soon as I write. "fruit.sort()" it then fails to recognise output. What am I doing by sorting a list that causes this? Thank you in advance. ---------- ---CODE--- try: f = open("fruit.txt", mode='r', encoding='utf-8') fruit = f.readlines() print(fruit, "\n") f1 = open("more_fruit.txt", mode="r", encoding='utf-8') fruit.append(f1.readlines()) print(fruit) # fruit.sort() # WITHOUT THIS LINE IT WORKS FINE output = open("fruit_salad.txt", mode='w', encoding='utf-8') for line in fruit: output.writelines(line) except (FileNotFoundError, IOError): print("File Not Found!!") finally: f.close() f1.close() output.close() ---------- --OUTPUT-- ['pear\n', 'apple\n', 'orange \n', 'mandarin\n', 'watermelon\n', 'pomegranate\n', 'lemon\n', 'pineapple\n'] ['pear\n', 'apple\n', 'orange \n', 'mandarin\n', 'watermelon\n', 'pomegranate\n', 'lemon\n', 'pineapple\n', ['banana\n', 'raspberry\n', 'blueberry\n', 'lime\n', 'blackberry\n', 'cherry\n', 'grape']] The program 'python.exe' has exited with code 0 (0x0). ---------- ERR OUTPUT During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions\Microsoft\Python\Core\ptvsd_launcher.py", line 111, in <module> vspd.debug(filename, port_num, debug_id, debug_options, run_as) File "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions\Microsoft\Python\Core\Packages\ptvsd\debugger.py", line 36, in debug run(address, filename, *args, **kwargs) File "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions\Microsoft\Python\Core\Packages\ptvsd\_main.py", line 47, in run_file run(argv, addr, **kwargs) File "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions\Microsoft\Python\Core\Packages\ptvsd\_main.py", line 98, in _run _pydevd.main() File "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions\Microsoft\Python\Core\Packages\ptvsd\pydevd\pydevd.py", line 1628, in main globals = debugger.run(setup['file'], None, None, is_module) File "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions\Microsoft\Python\Core\Packages\ptvsd\pydevd\pydevd.py", line 1035, in run pydev_imports.execfile(file, globals, locals) # execute the script File "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions\Microsoft\Python\Core\Packages\ptvsd\pydevd\_pydev_imps\_pydev_execfile.py", line 25, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "C:\Users\micha\source\repos\PythonFileManagement\PythonFileManagement\PythonFileManagement.py", line 24, in <module> output.close() NameError: name 'output' is not defined
0debug
Outline UILabel text in UILabel Subclass : <p>I'm trying hard to find a way to simply add an outline/stroke/contour to my UILabel text. Talking about a stroke around the letters of the text not around the background of a UILabel.</p> <p>I'm using swift 3 and I'd like to outline my text directly into my subclass: UILabel.</p> <p>I found multiple answers suggesting this way to do things : </p> <pre><code>let strokeTextAttributes = [ NSStrokeColorAttributeName : UIColor.black, NSForegroundColorAttributeName : UIColor.white, NSStrokeWidthAttributeName : -4.0, NSFontAttributeName : UIFont.boldSystemFont(ofSize: 30) ] self.attributedText = NSMutableAttributedString(string: self.text!, attributes: strokeTextAttributes) </code></pre> <p>But the thing is that it doesn't work. My text is still the same with no outline...</p> <p>Could anyone help me here ? That would be a great thing :)</p> <p>Thanks a lot. Cheers guys.</p>
0debug
Why am I needing to replace List.of() with Arrays.asList()? : <p>I've read <a href="https://stackoverflow.com/questions/46579074/what-is-the-difference-between-list-of-and-arrays-aslist">What is the difference between List.of and Arrays.asList?</a></p> <p>What I'm not getting is why, after some dependency upgrades in my Maven pom.xml, suddenly all my</p> <pre><code>List.of(FLIGHT1_SPEND_AGG, FLIGHT1_IMPRESSIONS_AGG) </code></pre> <p>no longer compile. When I type <code>List.</code> in IntelliJ, autocomplete only comes up with the <code>class</code> member. I thought maybe I'm not importing <code>java.util.List</code>? So explicitly specified it, but still:</p> <p><a href="https://i.stack.imgur.com/OLN0w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OLN0w.png" alt="enter image description here"></a></p> <p>I'm using Java 11, and I see the method exists here: <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html" rel="nofollow noreferrer">https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html</a>.</p> <p>Why can't I seem to use it? I must be doing something stupid...</p>
0debug
How to Unzip the APK file and extract CERT.RSA : Actually Under Certificate Fingerprints, I need to use both the MD5 and SHA-256 values in amazon account.
0debug
static void test_qemu_strtoul_whitespace(void) { const char *str = " \t "; char f = 'X'; const char *endptr = &f; unsigned long res = 999; int err; err = qemu_strtoul(str, &endptr, 0, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 0); g_assert(endptr == str); }
1threat
static void do_change_vnc(const char *target) { if (strcmp(target, "passwd") == 0 || strcmp(target, "password") == 0) { char password[9]; monitor_readline("Password: ", 1, password, sizeof(password)-1); password[sizeof(password)-1] = '\0'; if (vnc_display_password(NULL, password) < 0) term_printf("could not set VNC server password\n"); } else { if (vnc_display_open(NULL, target) < 0) term_printf("could not start VNC server on %s\n", target); } }
1threat
Why doesnt gets() take a char pointer argument if it can take a char array? : Considering this code snippet: #include<stdio.h> int main() { char *s; gets(s); printf("%s",s); return 0; } I get a runtime error in this case after entering some input at stdin. However if s is declared as an array ,s[size] there is no issue. But considering the gets prototype, char *gets(char *s); shouldnt it work?
0debug
Post request with multiple parameters in Go : How could I make a POST request to take in multiple parameters and output info on a webpage, in Go using the standard library. i.e user puts in name and favorite hobby __Name__ : __Hobby__ : __Submit__ (button) then webpage updates and shows Your Name is __(Name)__ and you like to __(Hobby)__
0debug
Route is in debug list but returns 404 in Symfony 4 : <p>Ok, so I just installed latest version Symfony 4. Run the browser after installation and a nice welcome greeting shows. All good!</p> <p>Then I created a new controller using <code>make:controller</code>. I named this controller Client and is using Annotations, same with the other Default Controller. I configured the routing as follows:</p> <pre><code>/** * @Route("/client", name="client") */ public function index() { // replace this line with your own code! return $this-&gt;render('@Maker/demoPage.html.twig', [ 'path' =&gt; str_replace($this-&gt;getParameter('kernel.project_dir').'/', '', __FILE__) ]); } </code></pre> <p>I refreshed the browser and all good, no errors.</p> <p>Then I manually typed the path into the browser to check if it's really working:</p> <pre><code>localhost:8000/client </code></pre> <p>Problem. The url returned standard apache 404</p> <pre><code>Not Found The requested URL /client was not found on this server. Apache/2.4.18 (Ubuntu) Server at new.staff-fdr.dev Port 80 </code></pre> <p>The debug route sees this though:</p> <pre><code>-------------------------- -------- -------- ------ ------------------ Name Method Scheme Host Path -------------------------- -------- -------- ------ ----------------- client ANY ANY ANY /client index ANY ANY ANY / _twig_error_test ANY ANY ANY /_error/{code}. </code></pre>
0debug
int ff_g723_1_scale_vector(int16_t *dst, const int16_t *vector, int length) { int bits, max = 0; int i; for (i = 0; i < length; i++) max |= FFABS(vector[i]); bits= 14 - av_log2_16bit(max); bits= FFMAX(bits, 0); for (i = 0; i < length; i++) dst[i] = vector[i] << bits >> 3; return bits - 3; }
1threat
static void musicpal_gpio_write(void *opaque, target_phys_addr_t offset, uint64_t value, unsigned size) { musicpal_gpio_state *s = opaque; switch (offset) { case MP_GPIO_OE_HI: s->lcd_brightness = (s->lcd_brightness & MP_GPIO_LCD_BRIGHTNESS) | (value & MP_OE_LCD_BRIGHTNESS); musicpal_gpio_brightness_update(s); break; case MP_GPIO_OUT_LO: s->out_state = (s->out_state & 0xFFFF0000) | (value & 0xFFFF); break; case MP_GPIO_OUT_HI: s->out_state = (s->out_state & 0xFFFF) | (value << 16); s->lcd_brightness = (s->lcd_brightness & 0xFFFF) | (s->out_state & MP_GPIO_LCD_BRIGHTNESS); musicpal_gpio_brightness_update(s); qemu_set_irq(s->out[3], (s->out_state >> MP_GPIO_I2C_DATA_BIT) & 1); qemu_set_irq(s->out[4], (s->out_state >> MP_GPIO_I2C_CLOCK_BIT) & 1); break; case MP_GPIO_IER_LO: s->ier = (s->ier & 0xFFFF0000) | (value & 0xFFFF); break; case MP_GPIO_IER_HI: s->ier = (s->ier & 0xFFFF) | (value << 16); break; case MP_GPIO_IMR_LO: s->imr = (s->imr & 0xFFFF0000) | (value & 0xFFFF); break; case MP_GPIO_IMR_HI: s->imr = (s->imr & 0xFFFF) | (value << 16); break; } }
1threat
How i can return a customized response in a FormRequest class in Laravel 5.5? : <p>I am making an API and i want return the array of errors with a format as the one that <code>$validator-&gt;errors();</code> generates when i validate the request by the manual way. But i cant manipulate the response. I wanna find thhe correct way to make it.</p> <p>This could be done in Laravel 5.4 with the <code>formatErrors</code> method and including the <code>Illuminate\Contracts\Validation\Validator</code> class in the FormRequest class but for version 5.5 it does not work. I do not know how to do it.</p> <p><strong>This is my Controller:</strong></p> <pre><code>&lt;?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Http\Requests\ProductRequest; use Illuminate\Validation\Rule; use App\Product; class ProductController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(ProductRequest $request) { $products = Product::where('code', 'LIKE', '%'.$request-&gt;input('search').'%') -&gt;where('name', 'LIKE', '%'.$request-&gt;input('search').'%') -&gt;paginate(10); $products-&gt;withPath($request-&gt;fullUrl()); return $products; } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(ProductRequest $request) { $product = new Product($request-&gt;validated()); $product-&gt;save(); return response('', 201); } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $product = Product::find($id); return response($product, 200); } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(ProductRequest $request, $id) { $product = Product::find($id); $product-&gt;fill($request-&gt;validated()); $product-&gt;save(); return response('', 200); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $product = Product::find($id); $product-&gt;delete(); return response('', 204); } } </code></pre> <p><strong>This is mi FormRequest class</strong></p> <pre><code>&lt;?php namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Validation\Rule; class ProductRequest extends FormRequest { /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { return true; } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { switch($this-&gt;method()) { case 'GET': { return [ 'code' =&gt; 'string', 'name' =&gt; 'string', ]; } break; case 'POST': { return [ 'code' =&gt; 'required|unique:Products,code', 'name' =&gt; 'required', 'description' =&gt; 'required', 'quantity' =&gt; 'required|min:0', 'price' =&gt; 'required|numeric', 'extemp' =&gt; [ Rule::in(['tax', 'free']), ] ]; } break; case 'PUT': { return [ 'code' =&gt; 'unique:products,code,'.$this-&gt;route('product'), 'name' =&gt; 'string:min:1', 'description' =&gt; 'string|min:1', 'quantity' =&gt; 'integer|min:0', 'price' =&gt; 'numeric', 'extemp' =&gt; [ Rule::in(['tax', 'free']), ], ]; } break; case 'PATCH': break; case 'DELETE': break; default: { return []; } break; } } /** * Get the error messages for the defined validation rules. * * @return array */ public function messages() { return [ //Product 'code.required' =&gt; 'El :attribute es obligatorio.', 'code.unique' =&gt; 'El :attribute ya se encuentra registrado.', 'name.required' =&gt; 'El :attribute es obligatorio.', 'name.min' =&gt; 'El :attribute es obligatorio.', 'description.required' =&gt; 'El :attribute es obligatorio.', 'description.min' =&gt; 'El :attribute es obligatorio.', 'quantity.required' =&gt; 'La :attribute es obligatoria.', 'quantity.integer' =&gt; 'La :attribute debe ser un número entero.', 'quantity.min' =&gt; 'La :attribute debe ser al menos :min.', 'price.required' =&gt; 'El :attribute es obligatorio.', 'price.numeric' =&gt; 'El :attribute debe ser un valor numérico.', 'extemp.in' =&gt; 'El :attribute seleccionado es inválido.', ]; } public function attributes(){ return [ 'code' =&gt; 'código', 'name' =&gt; 'nombre', 'description' =&gt; 'descripción', 'quantity' =&gt; 'cantidad', 'price' =&gt; 'precio', 'extemp' =&gt; 'exento', ]; } } </code></pre> <p><strong>The Response what i have:</strong></p> <pre><code>{ "message": "The given data was invalid.", "errors": { "code": [ "El código es obligatorio." ], "name": [ "El nombre es obligatorio." ], "description": [ "El descripción es obligatorio." ], "quantity": [ "La cantidad es obligatoria." ], "price": [ "El precio es obligatorio." ] } } </code></pre> <p><strong>The Response what i want</strong> (with <code>$validator-&gt;errors();</code>)</p> <pre><code>[ "El código es obligatorio.", "El nombre es obligatorio.", "El descripción es obligatorio.", "La cantidad es obligatoria.", "El precio es obligatorio." ] </code></pre>
0debug
Video content missing from Chrome Developer Tools Network Tab : <p>The following website: <a href="http://www.themedept.com/demo/getleads/agency.html" rel="noreferrer">http://www.themedept.com/demo/getleads/agency.html</a></p> <p>Shows a looping video: <a href="http://www.themedept.com/demo/getleads/images/video/video.mp4" rel="noreferrer">http://www.themedept.com/demo/getleads/images/video/video.mp4</a></p> <p>Why does this video video not appear in the Chrome Browser Developer Network Tools Tab: <a href="https://i.stack.imgur.com/NiSaO.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NiSaO.png" alt="enter image description here"></a></p> <p>Additional Information: The video is called via Javascript which adds the following element to the page</p> <pre><code>&lt;video autoplay="" loop="" muted="" style="margin: auto; position: absolute; z-index: -1; top: 50%; left: 50%; transform: translate(-50%, -50%); visibility: visible; width: 1352px; height: auto;"&gt;&lt;source src="images/video/video.mp4" type="video/mp4"&gt;&lt;source src="images/video/video.webm" type="video/webm"&gt;&lt;source src="images/video/video.ogv" type="video/ogg"&gt;&lt;/video&gt; </code></pre> <p>The Javascript that called this is from the file: <a href="http://www.themedept.com/demo/getleads/js/plugins/jquery.vide.min.js" rel="noreferrer">http://www.themedept.com/demo/getleads/js/plugins/jquery.vide.min.js</a></p>
0debug
Concatenating multiple csv files into a single csv with the same header - Python : <p>I am currently using the below code to import 6,000 csv files (with headers) and export them into a single csv file (with a single header row).</p> <pre><code>#import csv files from folder path =r'data/US/market/merged_data' allFiles = glob.glob(path + "/*.csv") stockstats_data = pd.DataFrame() list_ = [] for file_ in allFiles: df = pd.read_csv(file_,index_col=None,) list_.append(df) stockstats_data = pd.concat(list_) print(file_ + " has been imported.") </code></pre> <p>This code works fine, but it is slow. It can take up to 2 days to process. </p> <p>I was given a single line script for Terminal command line that does the same (but with no headers). This script takes 20 seconds.</p> <pre><code> for f in *.csv; do cat "`pwd`/$f" | tail -n +2 &gt;&gt; merged.csv; done </code></pre> <p>Does anyone know how I can speed up the first Python script? To cut the time down, I have thought about not importing it into a DataFrame and just concatenating the CSVs, but I cannot figure it out. </p> <p>Thanks.</p>
0debug
Locking C# Desktop window on Top all windows and prevent user change window : <p>I want to code a c# program that starts with windows and, sometimes, ask what the user is doing. So, I want to open a window to the user fill the form asking what he is doing, but I want to open the window on top of the screen and lock everything else, forcing the user to fill out the form before went back to what he was doing. Is it possible ? </p> <p>The behavior I want it is just like some modals on webpages that darkens the background forcing you to fill a form, but, instead do this on a webpage, I want to do this on Windows Desktop (Don´t need to darkens the background, just force the user to fill the form). </p>
0debug
Only 'npm install' in GitLab CI when package.json has been updated : <p>I'm using GitLab CI for a project and the first step of the process is <code>npm install</code>. I cache <code>node_modules</code> for quicker runs of the same job later on, and also define them as build artifacts in order to use them in later stages. However, even though I cache <code>node_modules</code> and it's up-to-date, calling <code>npm install</code> each time the <code>install_packages</code> job is run takes a long time, since the command goes through all of <code>package.json</code> and checks for updates of packages and such (I assume).</p> <p>Is there any way to <strong>only</strong> run <code>npm install</code> in the <code>install_packages</code> job depending on some condition? More specifically (what I think would be the best solution), whether or not <code>package.json</code> has been changed since last build?</p> <p>Below is the relevant part of my .gitlab-ci.yml file:</p> <pre><code>image: node:6.9.1 stages: - install - prepare - deploy install_packages: stage: install script: - npm prune - npm install cache: key: ${CI_BUILD_REF_NAME} paths: - node_modules/ artifacts: paths: - node_modules/ only: - master - develop build_and_test: stage: prepare script: #do_stuff... deploy_production: stage: deploy #do_stuff... deploy_staging: stage: deploy #do_stuff... </code></pre>
0debug
Getting webpage source code with java : <p>I'm trying to get a webpage source code with JAVA but i fail all the time! I want to get the source code from the link below.</p> <p><a href="http://widget.websta.me/rss/n/wikirap_official" rel="nofollow">http://widget.websta.me/rss/n/wikirap_official</a></p> <p>I searched on the net and tried many codes but all returned nothing, this page return my INSTAGRAM user posts as feed.</p> <p><strong>please test codes on this link and if you succeeded in get source, share the code with me.</strong></p>
0debug
SaaS app with angularjs and nodejs, how do i organize different clients? : <p>I’m trying to decide what to do I this scenario:</p> <p>I want to create a product that I want to sell in a SaaS business model, I already have the backend more or less thought out and some code in place in nodejs. It handles oAuth, sessions, and controls the roles of the users when accessing a certain endpoint.</p> <p>The doubt is in the frontend architecture: Each client will share the same functionality, but the design of their page will be completely different from one another. I want to put as much of the app logic that I can in services, so I can reuse it, my idea is to only change controllers/templates/directives from client to client, is this ok?</p> <p>Should I have different folders and serve the static files for each client from nodejs? ex: in nodejs I would know the url for client1 was called so I would serve client1-index.html?</p> <p>should I put each client in their own nodejs server and their own host?</p> <p>what other ways are there?</p> <p>I would like to be able to easily reuse the services as I’ll be introducing changes to the features or adding more, and I want to do this upgrades easily.</p> <p>There will also be an admin panel that will be exactly the same for all of them, the part that will change is the one my client's users see.</p> <p>Think of it as having many clients and giving each of them a store, so they can sell their stuff. They want an admin page and a public page. The admin page will the same for all, but the public page has to change.</p> <p>So, and app that shares the same functionality across users but looks completely different for each one of them, how would you do it?</p>
0debug
Can Web view do like browser in Android java : I have a question bothering me for these few days, I want to implement browser-like Webview, like add/close tab and open multiple website. But after I searched through many forums and documentations still couldn't find any solution for this, wondering can Webview do exactly what phone browser can do ?
0debug
Shorten code to check conditions in switch : <p>How to short my code? To do not describe all the numbers.</p> <pre><code>func counter(_ count: Int) -&gt; String { switch count { case 1, 21, 31, 41, 51, 61, 71, 81, 91, 101, 121, 131, 141, 151, 161, 171, 181, 191, 201, 221, 231, 241, 251, 261, 271, 281, 291, 301, 321, 331, 341, 351, 361, 371, 381, 391, 491, 501: return "\(searchAmong) \(count) \(photographer)" case 2...4, 22...24, 32...34, 42...44, 52...54, 62...64, 72...74, 82...84, 92...94, 102...104: return "\(searchAmong) \(count) \(photographerss)" case 5...20, 25...30, 35...40, 45...50, 55...60, 65...70, 75...80, 85...90, 95...100, 105...110: return "\(searchAmong) \(count) \(photographers)" default: let nothingToSearch = NSLocalizedString("Nothing to search :(", comment: "Нечего искать :(") return nothingToSearch } } </code></pre>
0debug
Trying to create a view in SQL server 2014 to read the table data in a different format : I am using SQL Server 2014. Table 'X' consists of a column 'Desc2' in which data is in the format 'VT000379_001: Low Low Alarm Limit 5' 'VT000379_001_001: Low Low Alarm Limit 5' . I am trying to create a view to remove the '_001' , so the result should be as follows. 'VT000379: Low Low Alarm Limit 5' 'VT000379_001: Low Low Alarm Limit 5' The logic i have been trying is Instr =: = 12 x= left(12) = VT000379_001 if x have 1 undrscore inst = "_" position 1 =VT000379 if x have 2 undrscore inst ="_" position 2 =VT000379_001 Can someone help me out on this ? thanks sidhu
0debug
How to architect/design a knowledge base to solve issues from its history analysis? : <p>I have a ticketing system (lets say JIRA or similar) for my application to file an issue of my application. Now my requirement is to build a knowledge base in a way so that I can predict the solution of any similar issues in future by churning that knowledge base.</p> <p>To explain further, the knowledge base would give me how many times this kind of issues have arisen in past and what have been the root cause of it in most of the time (lets say 80% time). This way the repository should have an analysis of each and every issue and its possible root cause plus many other relevant information about the issue.</p> <p>Just to start off to build such a knowledge base, I need to know following things:</p> <ol> <li>What is the most commonly used technology/mechanism available to achieve this ?</li> <li>How do I need to architect/design a system to be able to serve this kind of requirement?</li> <li>Does it require to learn any particular language/database ?</li> </ol> <p>I request community experts to enlighten me with the required information and pointers to give me a starting point at least in this direction.</p> <p>Thanks. </p>
0debug
hwo to check if drive in the raid array is failed using ansible : I want to write a ansible playbook to find out if the drive in the raid array md0 or md2 or md1 is failed. If it is failed then remove and re-add the drive. How can I do this check using ansible. Drive on the server is /dev/nvme0n1 and /dev/nvme1n1.
0debug
I am getting a segmentation fault on this code and I do not know why : <p>This program is supposed to have a tortoise and hare race each other and print the race out for the user. It is giving me a segmentation fault and I do not know why. I even went through the whole code with a pen and paper to see if it worked and to my knowledge it should work but I am also an amateur to C++ so I do not know.</p> <pre><code>#include &lt;iostream&gt; #include &lt;stdlib.h&gt; #include &lt;ctime&gt; #include &lt;iomanip&gt; #define RACE_LENGTH 50 void advanceTortoise(int* ptrTortoise) { int torNum = rand()%10+1; if (torNum &lt;= 6) { *ptrTortoise = *ptrTortoise + 1; }else if (torNum = 7) { *ptrTortoise = *ptrTortoise + 2; }else if (torNum = 8){ *ptrTortoise = *ptrTortoise + 3; }else if (torNum &gt; 8){ *ptrTortoise = *ptrTortoise; if (*ptrTortoise &gt; 50) { *ptrTortoise = 50; } return; } } void advanceHare(int* ptrHare) { int hareNum = rand()%10+1; if (hareNum = 1) { *ptrHare = *ptrHare + 1; }else if (hareNum &gt; 1 &amp;&amp; hareNum &lt;= 4){ *ptrHare = *ptrHare + 2; }else if (hareNum &gt; 4 &amp;&amp; hareNum &lt;= 7){ *ptrHare = *ptrHare + 3; }else if (hareNum = 8){ *ptrHare = *ptrHare - 2; if (*ptrHare &lt; 1) { *ptrHare = 1; } }else if (hareNum &gt; 8){ *ptrHare = *ptrHare - 3; if (*ptrHare &lt; 1) { *ptrHare = 1; } if (*ptrHare &gt; 50) { *ptrHare = 50; } return; } } void printPosition(int* ptrTortoise, int* ptrHare) { if (*ptrTortoise = *ptrHare) { *ptrTortoise = *ptrTortoise - 1; } if (*ptrTortoise &gt; *ptrHare) { std::cout &lt;&lt; std::setw(*ptrHare - 1) &lt;&lt; "H" &lt;&lt; std::setw(*ptrTortoise - *ptrHare) &lt;&lt; "T" &lt;&lt; std::setw(51 - *ptrTortoise) &lt;&lt; "|" &lt;&lt;std::endl; } if (*ptrHare &gt; *ptrTortoise) { std::cout &lt;&lt; std::setw(*ptrTortoise - 1) &lt;&lt; "H" &lt;&lt; std::setw(*ptrHare - *ptrTortoise) &lt;&lt; "T" &lt;&lt; std::setw(51 - *ptrHare) &lt;&lt; "|" &lt;&lt;std::endl; } } int main() { srand(time(NULL)); int* ptrTortoise; int* ptrHare; *ptrTortoise = 1; *ptrHare = 1; while(*ptrTortoise &lt; 50 &amp;&amp; *ptrHare &lt; 50) { advanceHare(ptrHare); advanceTortoise(ptrTortoise); printPosition(ptrTortoise, ptrHare); } if (*ptrHare = 50) { std::cout&lt;&lt;"The Hare has won"&lt;&lt;std::endl; }else{ std::cout&lt;&lt;"The Tortoise has won"&lt;&lt;std::endl; } } </code></pre>
0debug
PCIBus *pci_pmac_init(qemu_irq *pic, MemoryRegion *address_space_mem, MemoryRegion *address_space_io) { DeviceState *dev; SysBusDevice *s; PCIHostState *h; UNINState *d; dev = qdev_create(NULL, TYPE_UNI_NORTH_PCI_HOST_BRIDGE); qdev_init_nofail(dev); s = SYS_BUS_DEVICE(dev); h = PCI_HOST_BRIDGE(s); d = UNI_NORTH_PCI_HOST_BRIDGE(dev); memory_region_init(&d->pci_mmio, OBJECT(d), "pci-mmio", 0x100000000ULL); memory_region_init_alias(&d->pci_hole, OBJECT(d), "pci-hole", &d->pci_mmio, 0x80000000ULL, 0x70000000ULL); memory_region_add_subregion(address_space_mem, 0x80000000ULL, &d->pci_hole); h->bus = pci_register_bus(dev, "pci", pci_unin_set_irq, pci_unin_map_irq, pic, &d->pci_mmio, address_space_io, PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); #if 0 pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north"); #endif sysbus_mmio_map(s, 0, 0xf2800000); sysbus_mmio_map(s, 1, 0xf2c00000); #if 0 pci_create_simple(h->bus, PCI_DEVFN(12, 0), "dec-21154"); #endif pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north-agp"); dev = qdev_create(NULL, TYPE_UNI_NORTH_AGP_HOST_BRIDGE); qdev_init_nofail(dev); s = SYS_BUS_DEVICE(dev); sysbus_mmio_map(s, 0, 0xf0800000); sysbus_mmio_map(s, 1, 0xf0c00000); #if 0 pci_create_simple(h->bus, PCI_DEVFN(14, 0), "uni-north-internal-pci"); dev = qdev_create(NULL, TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE); qdev_init_nofail(dev); s = SYS_BUS_DEVICE(dev); sysbus_mmio_map(s, 0, 0xf4800000); sysbus_mmio_map(s, 1, 0xf4c00000); #endif return h->bus; }
1threat
Write directly to video buffer in modern os : I want to draw red line on my monitor directly writing to memory from my c++ code. I know that modern operating system protect physical memory and it is hard to do. Assuming that I know video card that I`m currently using(it is nvidia geforce 820m in my case) also I could give all needed system rights for my application. I know that this is "bad idea". It is just my curiosity. Is it possible on linux or windows?
0debug
React this.state is undefined? : <p>I am following a beginner tutorial from Pluralsight, on form submit a value is passed to <code>addUser</code> component method and I need to push userName to <code>this.state.users</code> but I get error </p> <pre><code> App.jsx:14 Uncaught TypeError: Cannot read property 'users' of undefined </code></pre> <p>Component</p> <pre><code>import React from 'react' import User from 'user' import Form from 'form' class Component extends React.Component { constructor() { super() this.state = { users: null } } // This is triggered on form submit in different component addUser(userName) { console.log(userName) // correctly gives String console.log(this.state) // this is undefined console.log(this.state.users) // this is the error // and so this code doesn't work /*this.setState({ users: this.state.users.concat(userName) })*/ } render() { return ( &lt;div&gt; &lt;Form addUser={this.addUser}/&gt; &lt;/div&gt; ) } } export default Component </code></pre>
0debug
"NameError: name 'filename' is not defined" : # Build mongoimport command collection = filename[:filename.find('.')] working_directory = 'C:/Users/Anshuman Misra/Downloads/' json_file = filename + '.json' mongoimport_cmd = 'mongoimport -h 127.0.0.1:27017 ' + \ '--db ' + db_name + \ ' --collection ' + collection + \ ' --file ' + working_directory + json_file # Before importing, drop collection if it exists (i.e. a re-run) if collection in db.collection_names(): print 'Dropping collection: ' + collection db[collection].drop() # Execute the command print 'Executing: ' + mongoimport_cmd subprocess.call(mongoimport_cmd.split())
0debug
ASP.NET vs Java EE vs PHP : <p>In PHP we have to secure our website because by default, there is include faults, sql fails, etc. We MUST secure them My question: Is it necessary to do it manually in Java EE or it is automatically managed by the technology ? And in Asp.NET ?</p>
0debug
long do_sigreturn(CPUSH4State *regs) { struct target_sigframe *frame; abi_ulong frame_addr; sigset_t blocked; target_sigset_t target_set; target_ulong r0; int i; int err = 0; #if defined(DEBUG_SIGNAL) fprintf(stderr, "do_sigreturn\n"); #endif frame_addr = regs->gregs[15]; if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) goto badframe; err |= __get_user(target_set.sig[0], &frame->sc.oldmask); for(i = 1; i < TARGET_NSIG_WORDS; i++) { err |= (__get_user(target_set.sig[i], &frame->extramask[i - 1])); } if (err) goto badframe; target_to_host_sigset_internal(&blocked, &target_set); sigprocmask(SIG_SETMASK, &blocked, NULL); if (restore_sigcontext(regs, &frame->sc, &r0)) goto badframe; unlock_user_struct(frame, frame_addr, 0); return r0; badframe: unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV); return 0; }
1threat
Python3: UnicodeEncodeError: 'ascii' codec can't encode character '\xfc' : <p>I'am trying to get running a very simple example on OSX with python 3.5.1 but I'm really stucked. Have read so many articles that deal with similar problems but I can not fix this by myself. Do you have any hints how to resolve this issue?</p> <p>I would like to have the correct encoded latin-1 output as defined in mylist without any errors.</p> <p><strong>My code:</strong></p> <pre><code># coding=&lt;latin-1&gt; mylist = [u'Glück', u'Spaß', u'Ähre',] print(mylist) </code></pre> <p>The error:</p> <pre><code>Traceback (most recent call last): File "/Users/abc/test.py", line 4, in &lt;module&gt; print(mylist) UnicodeEncodeError: 'ascii' codec can't encode character '\xfc' in position 4: ordinal not in range(128) </code></pre> <p><strong>How I can fix the error but still get something wrong with stdout (print):</strong></p> <pre><code>mylist = [u'Glück', u'Spaß', u'Ähre',] for w in mylist: print(w.encode("latin-1")) </code></pre> <p><em>What I get as output:</em></p> <pre><code>b'Gl\xfcck' b'Spa\xdf' b'\xc4hre' </code></pre> <p>What 'locale' shows me:</p> <pre><code>LANG="de_AT.UTF-8" LC_COLLATE="de_AT.UTF-8" LC_CTYPE="de_AT.UTF-8" LC_MESSAGES="de_AT.UTF-8" LC_MONETARY="de_AT.UTF-8" LC_NUMERIC="de_AT.UTF-8" LC_TIME="de_AT.UTF-8" LC_ALL= </code></pre> <p>What -> 'python3' shows me:</p> <pre><code>Python 3.5.1 (default, Jan 22 2016, 08:54:32) [GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; import sys &gt;&gt;&gt; sys.getdefaultencoding() 'utf-8' </code></pre>
0debug
iOS Universal Links and GET parameters : <p>we're trying to implement app indexing on iOS using the Apple Universal Links (I'm looking at <a href="https://developer.apple.com/library/ios/documentation/General/Conceptual/AppSearch/UniversalLinks.html#//apple_ref/doc/uid/TP40016308-CH12-SW2" rel="noreferrer">https://developer.apple.com/library/ios/documentation/General/Conceptual/AppSearch/UniversalLinks.html#//apple_ref/doc/uid/TP40016308-CH12-SW2</a>).</p> <p>In the "Creating and Uploading the Association File" section I see I can limit the indexing to specific pages, which is good.</p> <p>I'd like to limit the indexing to <a href="https://www.mywebsite.com?parameter=something" rel="noreferrer">https://www.mywebsite.com?parameter=something</a>, how can I?</p> <p>I was thinking about something like that:</p> <pre><code>{ "applinks": { "apps": [], "details": [ { "appID": "MYID", "paths":[ "*?parameter=*" ] } ] } } </code></pre> <p>Do you think it could work? I can't test it yet because it takes time to get the authorization for uploading files on the website root directory, that's why I'm asking you if you think it could work, I'd like to upload the file just once if I can.</p> <p>Thank you</p>
0debug
static int htab_save_complete(QEMUFile *f, void *opaque) { sPAPRMachineState *spapr = opaque; qemu_put_be32(f, 0); if (!spapr->htab) { int rc; assert(kvm_enabled()); rc = spapr_check_htab_fd(spapr); if (rc < 0) { return rc; } rc = kvmppc_save_htab(f, spapr->htab_fd, MAX_KVM_BUF_SIZE, -1); if (rc < 0) { return rc; } close(spapr->htab_fd); spapr->htab_fd = -1; } else { htab_save_later_pass(f, spapr, -1); } qemu_put_be32(f, 0); qemu_put_be16(f, 0); qemu_put_be16(f, 0); return 0; }
1threat
from collections import Counter def max_char(str1): temp = Counter(str1) max_char = max(temp, key = temp.get) return max_char
0debug
"how to create this type of shape with text inside it?" : "i'm creating this type of shape with text inside it. but not, anyone can help me?" https://i.stack.imgur.com/KQfwm.png
0debug
Android SMS selection while sending message : I am trying to display sim card selection dialog while sending message from android application, Please help mi to display and choose SIM card. Thank you!
0debug
void spapr_lmb_release(DeviceState *dev) { sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_hotplug_handler(dev)); PCDIMMDevice *dimm = PC_DIMM(dev); PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm); MemoryRegion *mr = ddc->get_memory_region(dimm); sPAPRDIMMState *ds = spapr_pending_dimm_unplugs_find(spapr, PC_DIMM(dev)); if (ds == NULL) { ds = spapr_recover_pending_dimm_state(spapr, PC_DIMM(dev)); g_assert(ds); g_assert(ds->nr_lmbs); } if (--ds->nr_lmbs) { return; } spapr_pending_dimm_unplugs_remove(spapr, ds); pc_dimm_memory_unplug(dev, &spapr->hotplug_memory, mr); object_unparent(OBJECT(dev)); }
1threat
Creating file in app engine project : I want to create json file for each user with user id. for example 123456.json in data folder. When i try this without flask server just in simple test file it works: with open('data/3456789.json', "w+") as f: print("test") but when i call it in flask server created in app engine i am getting error ```No such file or directory: 'data/3456789.json'``` thats how my ```main.py``` looks like: import os, sys from flask import Flask app = Flask(__name__) @app.route('/webhook', methods=['GET']) def createFile(): with open('data/3456789.json', "w+") as f: print("test") return "Welcome" if __name__ == '__main__': port = int(os.getenv('PORT', 5000)) print("Starting app on port %d" % port) app.run(debug=False, port=port, host='0.0.0.0') ```main.py``` wokrs perfect in my own pc. without any error. Any idea?
0debug
How to remove the whole div based clicked child using jquery? : I am trying to delete the closest but all divs are being removed. Example: if I click `fa-close` under Rooms the `incl-ingd` should be removed <div class="btn-group incl-ingd"> <div type="button" class="btn btn-default"> Rooms <i class="fa fa-close"></i> </div> </div> <div class="btn-group incl-ingd"> <div type="button" class="btn btn-default"> Mansions <i class="fa fa-close"></i> </div> </div> As of now I've tried this jqueyr... $("i.fa-close").on('click', function(e) { $(this).closest('div.incl-ingd').remove(); }); But all the `incl-ingd` is being removed... I'm not sure if this is possible but if it is, please help me out :)
0debug
Codesign returned unknown error -1=ffffffffffffffff : <p>I tried to code sign an iOS application, These are the steps that i followed</p> <pre><code> security create-keychain -p password ${KEYCHAIN} security set-keychain-settings -u -t 300 ${KEYCHAIN} security list-keychains -d user -s login.keychain ${KEYCHAIN} security import "$1" -k ${KEYCHAIN} -A -P "${PASSPHRASE}" -A &gt;/dev/null security unlock-keychain -p password ${KEYCHAIN} /usr/bin/codesign -f -s $IDENTITY --keychain $KEYCHAIN --entitlements $ENTITLEMENTS Payload/Test.app </code></pre> <p>This returned me Codesign returned unknown error -1=ffffffffffffffff via ssh.</p> <p>If i directly execute the code sign command in the machine, it's successfully signing.</p> <p>The issue is only in Mac OS Sierra.</p>
0debug
C# How can I convert an input number into a correct decimal output? (newbie) : I am a total newbie with almost zero coding knowledge. Thanks to all of you who will bother answering me. I have tried to look for that question in Stackoverflow before I ask, but I have not found anything (may be due my lack of experience). Now, my question: How can I convert an input number into a correct decimal output? I have tried with the code below (following a free course of the Microsoft Virtual Academy) but it only works when I remove my variable. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Main(string[] args) { //string myString = "My \"so-called\" life"; //string myString = "What if I need a\nnew line?"; //string myString = "Go to your c:\\drive"; //string myString = @"Go to your c:\drive"; //string myString = String.Format("{0} = {1}", "First", "Second"); //string myString = String.Format("{0:C}", 123.45); Console.Write("Insert a number: "); var data1 = Console.ReadLine(); string myString = String.Format("{0:N}", data1); Console.WriteLine(myString); Console.ReadLine(); } } } Thanks again, Alex
0debug
How to pull up from bottom to refresh webpage without animation : <p>I think everybody know the way to refresh a webpage by pulling down from the top on mobile devices.</p> <p>I want to do the same but I want to pull up from the bottom instead. I also don't need any animation.</p> <p>I need something like: refresh page when pulling up (e.g.) 10px from bottom.</p> <p>With Google I only found pull-down-from-top solutions and they all have animations and mostly have to much code.</p> <p>Does anybody have an idea or hint how to do that?</p>
0debug
(APACHE) Apache blocking my acess to WEBSITE : <p>I am having some couple problems with apache that is blocking my ip adress. In my company we have an Android App made in Titanium SDK that constantly makes alot of server requests, most of this requests is GET requests, but we have around 40000 images to download , so we do 40000 requests in server constantly for each device in the same IP , after some time , the IP will block, but when I try access from other IP , it works fine. However, when i restart the apache server , the access got back again. There's any way to configure the apache to not block my ip in apache? </p>
0debug
Textsize based on the screen size : <blockquote> <p>How to set the size of the text in text view based on the screen size and to scale dynamically based on height and width of the screen without creating different folders based on the resolution in android.</p> </blockquote> <p>Thanks in advance</p>
0debug
how to add 2 column with respect of group : <p>I want to add column a and b separately sum.a and sum.b with respect of group SAMPN</p> <p>Output:</p> <pre><code>SAMPN a b 1 1 2 1 3 5 2 1 1 2 7 4 </code></pre> <p>output</p> <pre><code>SAMPN a b sum.a sum.b 1 1 2 4 7 1 3 5 4 7 2 1 1 8 5 2 7 4 8 5 </code></pre>
0debug
av_cold int ff_cavs_init(AVCodecContext *avctx) { AVSContext *h = avctx->priv_data; ff_blockdsp_init(&h->bdsp, avctx); ff_h264chroma_init(&h->h264chroma, 8); ff_idctdsp_init(&h->idsp, avctx); ff_videodsp_init(&h->vdsp, 8); ff_cavsdsp_init(&h->cdsp, avctx); ff_init_scantable_permutation(h->idsp.idct_permutation, h->cdsp.idct_perm); ff_init_scantable(h->idsp.idct_permutation, &h->scantable, ff_zigzag_direct); h->avctx = avctx; avctx->pix_fmt = AV_PIX_FMT_YUV420P; h->cur.f = av_frame_alloc(); h->DPB[0].f = av_frame_alloc(); h->DPB[1].f = av_frame_alloc(); if (!h->cur.f || !h->DPB[0].f || !h->DPB[1].f) { ff_cavs_end(avctx); return AVERROR(ENOMEM); } h->luma_scan[0] = 0; h->luma_scan[1] = 8; h->intra_pred_l[INTRA_L_VERT] = intra_pred_vert; h->intra_pred_l[INTRA_L_HORIZ] = intra_pred_horiz; h->intra_pred_l[INTRA_L_LP] = intra_pred_lp; h->intra_pred_l[INTRA_L_DOWN_LEFT] = intra_pred_down_left; h->intra_pred_l[INTRA_L_DOWN_RIGHT] = intra_pred_down_right; h->intra_pred_l[INTRA_L_LP_LEFT] = intra_pred_lp_left; h->intra_pred_l[INTRA_L_LP_TOP] = intra_pred_lp_top; h->intra_pred_l[INTRA_L_DC_128] = intra_pred_dc_128; h->intra_pred_c[INTRA_C_LP] = intra_pred_lp; h->intra_pred_c[INTRA_C_HORIZ] = intra_pred_horiz; h->intra_pred_c[INTRA_C_VERT] = intra_pred_vert; h->intra_pred_c[INTRA_C_PLANE] = intra_pred_plane; h->intra_pred_c[INTRA_C_LP_LEFT] = intra_pred_lp_left; h->intra_pred_c[INTRA_C_LP_TOP] = intra_pred_lp_top; h->intra_pred_c[INTRA_C_DC_128] = intra_pred_dc_128; h->mv[7] = un_mv; h->mv[19] = un_mv; return 0; }
1threat
static int v4l2_read_header(AVFormatContext *s1) { struct video_data *s = s1->priv_data; AVStream *st; int res = 0; uint32_t desired_format; enum AVCodecID codec_id = AV_CODEC_ID_NONE; enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE; st = avformat_new_stream(s1, NULL); if (!st) return AVERROR(ENOMEM); s->fd = device_open(s1); if (s->fd < 0) return s->fd; if (s->list_format) { list_formats(s1, s->fd, s->list_format); return AVERROR_EXIT; } avpriv_set_pts_info(st, 64, 1, 1000000); if (s->pixel_format) { AVCodec *codec = avcodec_find_decoder_by_name(s->pixel_format); if (codec) s1->video_codec_id = codec->id; pix_fmt = av_get_pix_fmt(s->pixel_format); if (pix_fmt == AV_PIX_FMT_NONE && !codec) { av_log(s1, AV_LOG_ERROR, "No such input format: %s.\n", s->pixel_format); return AVERROR(EINVAL); } } if (!s->width && !s->height) { struct v4l2_format fmt; av_log(s1, AV_LOG_VERBOSE, "Querying the device for the current frame size\n"); fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (v4l2_ioctl(s->fd, VIDIOC_G_FMT, &fmt) < 0) { av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_G_FMT): %s\n", strerror(errno)); return AVERROR(errno); } s->width = fmt.fmt.pix.width; s->height = fmt.fmt.pix.height; av_log(s1, AV_LOG_VERBOSE, "Setting frame size to %dx%d\n", s->width, s->height); } desired_format = device_try_init(s1, pix_fmt, &s->width, &s->height, &codec_id); if (codec_id != AV_CODEC_ID_NONE && s1->video_codec_id == AV_CODEC_ID_NONE) s1->video_codec_id = codec_id; if (desired_format == 0) { av_log(s1, AV_LOG_ERROR, "Cannot find a proper format for " "codec_id %d, pix_fmt %d.\n", s1->video_codec_id, pix_fmt); v4l2_close(s->fd); return AVERROR(EIO); } if ((res = av_image_check_size(s->width, s->height, 0, s1)) < 0) return res; s->frame_format = desired_format; if ((res = v4l2_set_parameters(s1)) < 0) return res; st->codec->pix_fmt = fmt_v4l2ff(desired_format, codec_id); s->frame_size = avpicture_get_size(st->codec->pix_fmt, s->width, s->height); if ((res = mmap_init(s1)) || (res = mmap_start(s1)) < 0) { v4l2_close(s->fd); return res; } s->top_field_first = first_field(s->fd); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = codec_id; if (codec_id == AV_CODEC_ID_RAWVIDEO) st->codec->codec_tag = avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt); if (desired_format == V4L2_PIX_FMT_YVU420) st->codec->codec_tag = MKTAG('Y', 'V', '1', '2'); st->codec->width = s->width; st->codec->height = s->height; st->codec->bit_rate = s->frame_size * av_q2d(st->avg_frame_rate) * 8; return 0; }
1threat
def tup_string(tup1): str = ''.join(tup1) return str
0debug
void qemu_timer_notify_cb(void *opaque, QEMUClockType type) { qemu_notify_event(); }
1threat
all pictures is zooming : <p>All the pictures on my website is zooming in, and I cannot figure out where in the code it is. The second slide on my <a href="http://roulettesuite.com/index.php" rel="nofollow noreferrer">index</a> page is the same as this one:</p> <p><a href="https://i.stack.imgur.com/Dy4fI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Dy4fI.jpg" alt="Index page picture"></a>, but my legs are cut of etc. It is in general on all my page, where the pictures are doing it. Does anybody have an idea where that could be through the inspect window? I am not quite sure if the javascript is controlling some of this?</p> <p>Another example is this <a href="http://roulettesuite.com/personlighed.php" rel="nofollow noreferrer">page</a>, which have a <code>min-height: 350px;</code> on the banner. The original picture is looking like this, and should fit that size of the banner:</p> <p><a href="https://i.stack.imgur.com/Mkp3Y.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Mkp3Y.jpg" alt="Second Example"></a></p> <p>This is the CSS for the banner on the index page:</p> <pre><code>slider-banner-container, .slider-revolution-5-container { width: 100%; position: relative; padding: 0; } .slider-banner-fullscreen, .slider-banner-fullwidth { width: 100%; position: relative; } .slider-banner-container ul.slides, .slider-revolution-5-container ul.slides { display: none; } /*Spinner*/ .tp-loader.spinner2 { background-color: #999; } /*Captions*/ .tp-caption { z-index: 5; } .tp-caption a, .tp-caption a:hover { color: #ffffff; } .tp-caption a.btn-gray, .tp-caption a.btn-gray:hover { color: #333333; } .caption-box { max-width: 540px; color: #ffffff; white-space: normal; padding: 20px; border: none; } .caption-box h2 { color: #ffffff; } /*text rotator*/ .tp-caption .text-rotator { min-width: 580px; display: inline-block; } .light-translucent-bg.caption-box h2, .light-translucent-bg.caption-box p { color: #333333; font-weight: 400; } .caption-box:after { z-index: -1; } .slideshow .dark-translucent-bg:not(.caption-box), .slideshow .light-translucent-bg:not(.caption-box) { border-top: none; border-bottom: none; position: absolute; left: 0; top: 0 !important; width: 100%; height: 100%; } </code></pre> <p>Happy christmas to everyone.</p>
0debug
void helper_ltr_T0(void) { int selector; SegmentCache *dt; uint32_t e1, e2; int index, type, entry_limit; target_ulong ptr; selector = T0 & 0xffff; if ((selector & 0xfffc) == 0) { env->tr.base = 0; env->tr.limit = 0; env->tr.flags = 0; } else { if (selector & 0x4) raise_exception_err(EXCP0D_GPF, selector & 0xfffc); dt = &env->gdt; index = selector & ~7; #ifdef TARGET_X86_64 if (env->hflags & HF_LMA_MASK) entry_limit = 15; else #endif entry_limit = 7; if ((index + entry_limit) > dt->limit) raise_exception_err(EXCP0D_GPF, selector & 0xfffc); ptr = dt->base + index; e1 = ldl_kernel(ptr); e2 = ldl_kernel(ptr + 4); type = (e2 >> DESC_TYPE_SHIFT) & 0xf; if ((e2 & DESC_S_MASK) || (type != 1 && type != 9)) raise_exception_err(EXCP0D_GPF, selector & 0xfffc); if (!(e2 & DESC_P_MASK)) raise_exception_err(EXCP0B_NOSEG, selector & 0xfffc); #ifdef TARGET_X86_64 if (env->hflags & HF_LMA_MASK) { uint32_t e3; e3 = ldl_kernel(ptr + 8); load_seg_cache_raw_dt(&env->tr, e1, e2); env->tr.base |= (target_ulong)e3 << 32; } else #endif { load_seg_cache_raw_dt(&env->tr, e1, e2); } e2 |= DESC_TSS_BUSY_MASK; stl_kernel(ptr + 4, e2); } env->tr.selector = selector; }
1threat