text
stringlengths
3
1.74M
label
class label
2 classes
source
stringclasses
3 values
Bring their own food to a cafe and then post 1 star review when called out.
0non-cybersec
Reddit
How to use spot instance with amazon elastic beanstalk?. <p>I have one infra that use amazon elastic beanstalk to deploy my application. I need to scale my app adding some spot instances that EB do not support.</p> <p>So I create a second autoscaling from a launch configuration with spot instances. The autoscaling use the same load balancer created by beanstalk.</p> <p>To up instances with the last version of my app, I copy the user data from the original launch configuration (created with beanstalk) to the launch configuration with spot instances (created by me).</p> <p>This work fine, but:</p> <ol> <li><p>how to update spot instances that have come up from the second autoscaling when the beanstalk update instances managed by him with a new version of the app?</p> </li> <li><p>is there another way so easy as, and elegant, to use spot instances and enjoy the benefits of beanstalk?</p> </li> </ol> <p><strong>UPDATE</strong></p> <p>Elastic Beanstalk add support to spot instance since 2019... see: <a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2019-11-25-spot.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2019-11-25-spot.html</a></p>
0non-cybersec
Stackexchange
Number of Solutions for Trigonometric Equation on $\theta \in [-\pi , \pi]$. <p>I just ran into this question for an admission test...</p> <p>How many solutions does the equation:</p> <p>$$(1+\sec\theta)(1+\csc\theta)=0$$</p> <p>have for $\theta \in [-\pi , \pi]$?</p> <p>My trial so far:</p> <p>$$2\cos^{2}\left(\frac{\theta}{2}\right)=1+\cos\theta$$</p> <p>Divide both sides by $\cos\theta$ and I get:</p> <p>$$1+\sec\theta=2\frac{\cos^{2}\left(\frac{\theta}{2}\right)}{\cos\theta}$$</p> <p>Substituting and doing some algebra, I get that the solution would be $\sin\theta=-1$, which gives me $\theta=-\frac{\pi}{2}$.</p> <p>However the correct solution is that <strong>there are no solutions in the interval...</strong></p> <p>What am I missing here? Any help is appreciated</p> <p>Thanks in advance</p>
0non-cybersec
Stackexchange
The best and most deserved slap of all time.
0non-cybersec
Reddit
My (Kinda Big) Inspo Album That I've Been Working On! Enjoy :).
0non-cybersec
Reddit
GTA Mod makes it look super photo realistic.
0non-cybersec
Reddit
What’s in my bed? Oh ok.
0non-cybersec
Reddit
NFL Race Distribution by Position.
0non-cybersec
Reddit
ITAP of the nature taking over the ancient Angkor ruins of Cambodia..
0non-cybersec
Reddit
how to determine whether a dynamical system is the uniformly exponentially stable if at equilibrium point. <p>Given that equilibrum point $x_e=0$ and a dynamical system:</p> <p>$\dot x(t)=\begin{bmatrix} a(t) &amp; 1\\ 0 &amp; -1\\\end{bmatrix}x(t)$</p> <p>for each $a(t)$ below, determine if it is uniformly exponentially stable</p> <p>a) $a(t)=0$</p> <p>b) $a(t)=-1$</p> <p>Please help me with this question, I know the theorem behind this which is that if there exist constants $C$, $\lambda &gt;0$ and $r\gt 0$ such that $||x(t)||\le Ce^{-\lambda(t-t_o)}||x(t_o)|| $ for all $t\ge t_o$ and $||x(t_o)||\le r$. But I don't how to use this in a real problem. Also this the $\lambda$ denote eigenvalue of the A matrix?</p>
0non-cybersec
Stackexchange
How to use spot instance with amazon elastic beanstalk?. <p>I have one infra that use amazon elastic beanstalk to deploy my application. I need to scale my app adding some spot instances that EB do not support.</p> <p>So I create a second autoscaling from a launch configuration with spot instances. The autoscaling use the same load balancer created by beanstalk.</p> <p>To up instances with the last version of my app, I copy the user data from the original launch configuration (created with beanstalk) to the launch configuration with spot instances (created by me).</p> <p>This work fine, but:</p> <ol> <li><p>how to update spot instances that have come up from the second autoscaling when the beanstalk update instances managed by him with a new version of the app?</p> </li> <li><p>is there another way so easy as, and elegant, to use spot instances and enjoy the benefits of beanstalk?</p> </li> </ol> <p><strong>UPDATE</strong></p> <p>Elastic Beanstalk add support to spot instance since 2019... see: <a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2019-11-25-spot.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2019-11-25-spot.html</a></p>
0non-cybersec
Stackexchange
&quot;Cannot open log file&quot; - Kile is not able to identify log file location. <p>I am using kile for my latex documentation.</p> <p>I wanted to keep the top level directory of tex files clean, so I have created a folder named "tmp" in the current directory and added the option to compilation as:</p> <blockquote> <p><code>pdflatex --output-directory tmp</code></p> </blockquote> <p>using kile's build-configuration settings.</p> <p>After setting this, compilation is working very fine and the directory is clean as I desired, but the "log and messages" pane in Kile, at the bottom is not able to show the compilation status message and says:</p> <blockquote> <p><code>Cannot open log file; did you run LaTeX?</code></p> </blockquote> <p>Any suggestions about how do I tell KILE about new log file location??</p> <hr> <p><strong>Solution update 7-Nov-2016:</strong></p> <p>Below is a compromising work-around for this age-old, unsolved bug/problem with kile. (As the Q is closed and I only can edit the Q):</p> <p>Basically the aim is to keep the current directory clean, so one may compromise to ONE additional file, more specifically a link to the .log file. Note that we already avoided a ton of other files.</p> <p>So the main problem happens to be a simple bug, that the .log file is not accessible to the kile, hence complaining as above. Because kile is (in spite of the relative directory setting) still thinking that the log file should exist in the current directory to read and present its summary in "log and messages". </p> <p>So I kept a symbolic link to the actual log file (which should have been created in <code>tmp</code> directory as a result of the option <code>--output-directory</code>) in the current directory, i.e.: </p> <blockquote> <p><code>ln -s tmp/&lt;filename&gt;.log &lt;filename&gt;.log</code></p> </blockquote> <p>This has solved the error message and everything else is normal.</p>
0non-cybersec
Stackexchange
I&#39;d like to enumerate a list with a decimal. <p>He guys. I currently have this...</p> <pre><code>\newlist{Problem}{enumerate}{1} \setlist[Problem]{label=Problem-\arabic*:} </code></pre> <p>That will give me lists 1-n. What I want is actually 1.1 - 1.n. Is there a way to change this so that it only increments the decimal value?</p>
0non-cybersec
Stackexchange
() ar X iv :1 30 9. 46 16 v1 [ cs .N A ] 1 8 S ep 2 01 3 Exponential Integrators on Graphic Processing Units Lukas Einkemmer, Alexander Ostermann Department of Mathematics University of Innsbruck Innsbruck, Austria [email protected], [email protected] c©2013 IEEE. Personal use of this material is permitted. Permission from IEEE must be obtained for all other uses, in any current or future media, including reprinting/republishing this material for advertising or promotional purposes, creating new collective works, for resale or redistribution to servers or lists, or reuse of any copyrighted component of this work in other works. Abstract—In this paper we revisit stencil methods on GPUs in the context of exponential integrators. We further discuss boundary conditions, in the same context, and show that simple boundary conditions (for example, homogeneous Dirichlet or homogeneous Neumann boundary conditions) do not affect the performance if implemented directly into the CUDA kernel. In addition, we show that stencil methods with position-dependent coefficients can be implemented efficiently as well. As an appli- cation, we discuss the implementation of exponential integrators for different classes of problems in a single and multi GPU setup (up to 4 GPUs). We further show that for stencil based methods such parallelization can be done very efficiently, while for some unstructured matrices the parallelization to multiple GPUs is severely limited by the throughput of the PCIe bus. Keywords—GPGPU, exponential integrators, time integration of differential equations, stencil methods, multi GPU setup I. INTRODUCTION The emergence of graphic processing units as a massively parallel computing architecture as well as their inclusion in high performance computing systems have made them an attractive platform for the parallelization of well established computer codes. Many problems that arise in science and engineering can be modeled as differential equations. In most circumstances the resulting equations are sufficiently complex such that they can not be solved exactly. However, an approximation computed by the means of a given numerical scheme can still serve as a valuable tool for scientists and engineers. The collection of techniques generally referred to as general-purpose computing on graphics processing units (GPGPU) provide the means to speed up such computations significantly (see e.g. [1] or [2]). If a finite difference approximation in space is employed (such methods are widely used in computational fluid dynam- ics, for example), stencil methods provide an alternative to storing the matrix in memory (see e.g. [3]). In many instances, this is advantageous both from a memory consumption as well as from a performance standpoint. The resulting system of ordinary differential equations then has to be integrated in time. Much research has been devoted to the construction of effi- cient time integration schemes as well as their implementation (see e.g. [4] and [5]). The implementation of Runge–Kutta methods, which are the most widely known time integration schemes, on GPUs for ordinary differential equations can result in a significant speedup (see [1]). However, a class of problems has been identified, so called stiff problems, where standard integration routines (such as the above mentioned Runge–Kutta methods) are inefficient (see e.g. [6]). Exponential integrators are one class of methods that avoid the difficulties of Runge–Kutta method if applied to stiff problems. For such schemes analytical functions (e.g. the exponential function) of large matrices have to be computed. Exponential integrators and some of their applications are discussed in detail in [6]. In this paper we will consider a polynomial interpolation scheme to compute the matrix functions; this essentially reduces the problem of efficiently implementing exponential integrators to sparse matrix-vector multiplication as well as computing the nonlinearity of a given differential equation. The computation of matrix-vector multiplications, e.g. by using stencil methods, is usually the most time intensive part of any exponential integrator; thus, an efficient implementation of stencil methods is vital. A. Research problems & Results In the literature, see section II-B, stencil methods are considered for trivial boundary conditions in the context of a differential operator with constant coefficients (i.e. the Lapla- cian). Such simplifying assumptions, however, are usually not satisfied in a given application. It is not clear from the literature how much stencil methods can be extended beyond the situation described above while still maintaining an efficient implementation. We propose a method based on the integration of boundary conditions and position-dependent coefficients directly into the CUDA kernel and show that such methods can be applied widely without a significant impact on performance. In addition, it has been shown in [2] that stencil meth- ods can be efficiently parallelized to at least 4 GPUs. Our objective is to show that such results can be generalized to implementations of exponential integrators for a large class of nonlinearities. The remainder of this paper is structured as follows. In sec- tion II-A a introduction explaining the GPU architecture and http://arxiv.org/abs/1309.4616v1 the corresponding programming model is given. In addition, we discuss previous work which considers the implementation of stencil methods on GPUs and elaborate on the necessary steps to efficiently implement an exponential integrator (sec- tions II-B and II-C, respectively). In section III we present our results as summarized below. • Stencil methods that include simple, but non-trivial, boundary conditions, such as those required in many ap- plications, can still be efficiently implemented on GPUs (section III-A). For homogeneous boundary conditions on the C2075 33.5 Gflops/s are observed. • Position dependent coefficients (such as a position de- pendent diffusion) can efficiently be implemented on the GPU provided that the coefficients are not extremely expensive to compute (section III-B). For a real world example 16 Gflops/s are observed. • A wide class of nonlinearities can be computed efficiently on the GPU (section III-C). • The parallelization of exponential integrators to multiple GPUs can be conducted very efficiently for discretized differential operators (perfect scaling to at least 4 GPUs) and is mainly limited by the throughput of the PCIe express bus for unstructured matrices (section III-D). Finally, we conclude in section IV. II. BACKGROUND & MOTIVATION A. GPU architecture A graphic processing unit (GPU) is a massively parallel computing architecture. At the time of writing two frameworks to program such systems, namely OpenCL and NVIDIA’s CUDA, are in widespread use. In this section we will discuss the hardware architecture as well as the programming model of the GPU architecture using NVIDIA’s CUDA (all our implementations are CUDA based). Note, however, that the principles introduced here can, with some change in termi- nology, just as well be applied to the OpenCL programming model. For a more detailed treatment we refer the reader to [7]. The hardware consists of so called SM (streaming multi- processors) that are divided into cores. Each core is (as the analogy suggests) an independent execution unit that shares certain resources (for example shared memory) with other cores, which reside on the same streaming multiprocessor. For example, in case of the C2075, the hardware consists in total of 448 cores that are distributed across 14 streaming multiprocessors of 32 cores each. For scheduling, however, the hardware uses the concept of a warp. A warp is a group of 32 threads that are scheduled to run on the same streaming multiprocessor (but possibly on different cores of that SM). On devices of compute capability 2.0 and higher (e.g. the C2075) each SM consists of 32 cores (matching each thread in a warp to a single core). However, for the C1060, where 240 cores are distributed across 30 SM of 8 core each, even threads in the same warp that take exactly the same execution path are not necessarily scheduled to run in parallel (on the instruction level). To run a number of threads on a single SM has the advan- tage that certain resources are shared among those threads; the most notable being the so called shared memory. Shared memory essentially acts as an L1 cache (performance wise) but can be fully controlled by the programmer. Therefore, it is often employed to avoid redundant global memory access as well as to share certain intermediate computations between cores. In addition, devices of compute capability 2.0 and higher are equipped with a non-programmable cache. The global memory is a RAM (random access memory) that is shared by all SM on the entire GPU. For the C1060 and C2075 GPUs used in this paper the size of the global memory is 4 GB and 6 GB respectively (with memory bandwidth of 102.4 GB/s and 141.7 GB/s respectively), whereas the shared memory is a mere 16 KB for the C1060 and about 50 KB for the C2075. However, this memory is available per SM. From the programmer some of these details are hidden by the CUDA programming model (most notably the concept of SM, cores, and warps). If a single program is executed on the GPU we refer to this as a grid. The programmer is responsible for subdividing this grid into a number of blocks, whereas each block is further subdivided into threads. A thread in a single block is executed on the same SM and therefore has access to the same shared memory and cache. GPUs are therefore ideally suited to problems which are compute bound. However, also memory bound problems, such as sparse matrix-vector multiplication, can significantly benefit from GPUs. We will elaborate on this statement in the next section. B. Stencil methods and matrix-vector products on GPUs The parallelization of sparse matrix-vector products to GPUs has been studied in some detail. Much research effort in improving the performance of sparse matrix-vector multipli- cation on GPUs has focused on developing more efficient data structures (see e.g. [8] or [9]). This is especially important on GPUs as coalesced memory access is of paramount importance if optimal performance is to be achieved. Data structures, such as ELLRT, facilitate coalesced memory access but require additional memory. This is somewhat problematic as on a GPU system memory is limited to a greater extend than on traditional clusters. To remedy this situation a more memory efficient data structure has been proposed, for example, in [10]. Nevertheless, all such methods are extremely memory bound. On the other hand, the parallelization of finite difference computations (called stencil methods in this context) to GPUs has been studied, for example, in [2] and [3]. Even though such methods do not have to store the matrix in memory they are still memory bound; for example, in [3] the flops per byte ratio is computed to be 0.5 for a seven-point stencil (for double precision computations) which is still far from the theoretical rate of 3.5 that a C0275 can achieve. In [3] a performance of 36.5 Gflops/s has been demonstrated for a seven-point stencil on a GTX280. Both papers mentioned above do not consider boundary conditions in any detail. However, in applications of science and engineering where exponential integrators are applied at least simple boundary conditions have to be imposed (see e.g. [6]). In addition, in the literature stated above only the discretization of the Laplacian is considered. However, often position-dependent coefficients have to be employed (to model a position-dependent diffusion as in [11], for example). In this case it is not clear if stencil methods retain their superior performance characteristics (as compared to schemes that store the matrix in memory). We will show in sections III-A and III-B that for many applications both of these difficulties can be overcome and stencil methods on GPUs can be implemented efficiently. C. Exponential integrators The step size for the time integration of stiff ordinary differ- ential equations (or the semidiscretization of partial differential equations) is usually limited by a stability condition. In order to overcome this difficulty, implicit schemes are employed that are usually stable for much larger step sizes; however, such schemes have to solve a nonlinear system of equations in each time step and are thus costly in terms of performance. In many instances the stiffness of the differential equation is located in the linear part only. In this instance, we can write our differential equation as a semilinear problem d dt u(t) +Au(t) = g(u(t)), (1) where in many applications A is a matrix with large negative eigenvalues and g is a nonlinear function of u(t); it is further assumed that appropriate initial conditions are given. The boundary conditions are incorporated into the matrix A. Since the linear part can be solved exactly, a first-order method, the exponential Euler method, is given by un+1 = e −hAun + hϕ1 (−hA) g(un), (2) where ϕ1 is an entire function. In [6] a review of such methods, called exponential integrators, is given and various methods of higher order are discussed. The main advantage, compared to Runge–Kutta methods, is that an explicit method is given for which the step size is only limited by the nonlinearity. It has long been believed that the computation of the matrix functions in (2) can not be carried out efficiently. However, if a bound of the field of values of A is known a priori, for example, polynomial interpolation is a viable option. In this case the application of Horner’s scheme reduces the problem to repeated matrix-vector products of the form (αA+ βI)x, (3) where A ∈ Kn×n is a sparse matrix, I is the identity matrix, x ∈ Kn, and α, β ∈ K with K ∈ {R,C}. That such a product can be parallelized to small clusters has been shown in [12] (for an advection-diffusion equation that is discretized in space by finite differences). Finally, let us discuss the evaluation of the nonlinearity. In many instances the nonlinearity can be computed pointwise. In this case its evaluation is expected to be easily parallelizable to GPUs. In section III-C this behavior is confirmed by numerical experiments. If the nonlinearity does include differential oper- ators, such as in Burgers’ equation, the evaluation is essentially reduced to sparse-matrix vector multiplication, which we will discuss in some detail in this paper (in the context of stencil methods). III. RESULTS A. Stencil methods with boundary conditions Let us focus our attention first on the standard seven-point stencil resulting from a discretization of the Laplacian in three dimensions, i.e. (∆x)2 (Au) ix,iy,iz =− 6uix,iy,iz + uix+1,iy,iz + uix−1,iy,iz + uix,iy+1,iz + uix,iy−1,iz + uix,iy,iz+1 + uix,iy,iz−1, where ∆x is the spacing of the grid points. The corresponding matrix-vector product given in (3) can then be computed without storing the matrix in memory. For each grid point we have to perform at least 2 memory operations (a single read and a single store) as well as 10 floating point operations (6 additions and 2 multiplication for the matrix-vector product as well as single addition and multiplication for the second part of (3)). One could implement a stencil method that employs 8 memory transactions for every grid point. Following [3] we call this the naive method. On the other hand we can try to minimize memory access by storing values in shared memory or the cache (note that the C1060 does not feature a cache but the C2075 does). Since no significant 3D slice fits into the relatively limited shared memory/cache of both the C1060 and C2075, we take only a 2D slice and iterate over the remaining index. Similar methods have been implemented, for example, in [3] and [2]. We will call this the optimized method. To implement boundary conditions we have two options. First, a stencil method can be implemented that considers only grid points that lie strictly in the interior of the domain. Second, we can implement the boundary conditions directly into the CUDA kernel. The approach has the advantage that all computations can be done in a single kernel launch. However, conditional statements have to be inserted into the kernel. Since the kernel is memory bound, we do not expect a sig- nificant performance decrease at least for boundary conditions that do not involve the evaluation of complicated functions. The results of our numerical experiments (for both the naive and optimized method) are given in Table I. Before we discuss the results let us note that on a dual socket Intel Xeon E5355 system the aggressively hand optimized stencil method implemented in [3] gives 2.5 Gflops/s. In [3] a double precision performance of 36.5 Gflops/s is reported for a GTX280 of compute capability 1.3. However, the theoretical memory bandwidth of the GTX280 is 141.7 GB/s and thus, as we have a memory bound problem, it has to be compared mainly to the C2075 (which has the same memory bandwidth as the GTX280). Note that the C1060 (compute capability 1.1) has only a memory bandwidth of 102.4 GB/s. In our case we get 39 Gflops/s for no bound- ary conditions and 33.5 Gflops/s for homogeneous Dirichlet boundary conditions. Since we do not solve exactly the same problem, a direct comparison is difficult. However, it is clear that the implemented method is competitive especially since we do not employ any tuning of the kernel parameters. We found it interesting that for the C2075 (compute ca- pability 2.0) there is only a maximum of 30% performance decrease if the naive method is used instead of the optimized method for none or homogeneous boundary conditions (both in the single and double precision case). Thus, the cache implemented on a C2075 works quite efficiently in this case. However, we can get a significant increase in performance for more complicated boundary conditions by using the optimized method. In the single precision case the expected gain is offset, in some instances, by the additional operations that have to be performed in the kernel (see Table I). Finally, we observe that the performance for homogeneous Dirichlet boundary conditions is at most 10% worse than the same computation which includes no boundary conditions at all. This difference completely vanishes if one considers the optimized implementation. This is no longer true if more complicated boundary conditions are prescribed. For example, if we set f(x, y, z) = z(1− z)xy, for (x, y, z) ∈ ∂([0, 1]3) or f(x, y, z) = sin(πz) exp(−xy), for (x, y, z) ∈ ∂([0, 1]3), the performance is decreased by a factor of about 2 for the C2075 and by a factor of 5-7 for the C1060. Thus, in this case it is clearly warranted to perform the computation of the boundary conditions in a separate kernel launch. Note, however, that the direct implementation is still faster by a factor of 3 as compared to CUSPARSE and about 40 % better than the ELL format (see [13]). The memory requirements are an even bigger factor in favor of stencil methods; a grid of dimension 5123 would already require 10 GB in the storage friendly CSR format. Furthermore, the implementation of such a kernel is straight forward and requires no division of the domain into the interior and the boundary. B. Stencil methods with a position-dependent coefficient Let us now discuss the addition of a position-dependent diffusion coefficient, i.e. we implement the discretization of D(x, y, z)∆u as a stencil method (this is the diffusive part of ∇·(D∇u) ). Compared to the previous section we expect that the direct implementation of the position-dependent diffusion coefficient in the CUDA kernel, for a sufficiently complicated D, results in an compute bound problem. For the particular choice of D(x, y, z) = 1/ √ 1 + x2 + y2, taken from [11], the results are shown in Table II. TABLE II TIMING OF A SINGLE STENCIL BASED MATRIX-VECTOR COMPUTATION FOR A POSITION DEPENDENT DIFFUSION COEFFICIENT GIVEN BY D(x, y, z) = 1/ √ 1 + x2 + y2 . ALL COMPUTATIONS ARE PERFORMED WITH n = 2563 . Double precision Device Method Time C1060 Stencil (naive) 37 ms (4.5 Gflops/s) Stencil (optimized) 42 ms (4 Gflops/s) C2075 Stencil (naive) 10.7 ms (15.5 Gflops/s) Stencil (optimized) 10.5 ms (16 Gflops/s) Single precision Device Method Time C1060 Stencil (naive) 37 ms (4.5 Gflops/s) Stencil (optimized) 45 ms (3.5 Gflops/s) C2075 Stencil (naive) 10.2 ms (16.5 Gflops/s) Stencil (optimized) 10.3 ms (16 Gflops/s) Thus, a performance of 16 Gflops/s can be achieved for this particular position-dependent diffusion coefficient. This is a significant increase in performance as compared to a matrix-based implementation. In addition, the same concerns regarding storage requirements, as raised above, still apply equally to this problem. No significant difference between the naive and optimized implementation can be observed; this is due to the fact that this problem is now to a large extend compute bound. Finally, let us note that the results obtained in Tables I and II are (almost) identical for the n = 5123 case. Thus, for the sake of brevity, we choose to omit those results. C. Evaluating the nonlinearity on a GPU For an exponential integrator, usually the most time con- suming part is evaluating the exponential and ϕ1 function. Fortunately, if the field of values of A can be estimated a priori, we can employ polynomial interpolation to reduce that problem to matrix-vector multiplication; a viable possibility is interpolation at Leja points (see [6]). Then, our problem reduces to the evaluation of a series of matrix-vector products of the form given in (3) and discussed in the previous section and the evaluation of the nonlinearity for a number of intermediate approximations. In this section we will be TABLE I TIMING OF A SINGLE STENCIL BASED MATRIX-VECTOR COMPUTATION FOR A NUMBER OF IMPLEMENTATIONS AND BOUNDARY CONDITIONS. THE CORRESPONDING GFLOPS/S ARE SHOWN IN PARENTHESES. ALL COMPUTATIONS ARE PERFORMED WITH n = 2563 . Device Boundary Method Double Single C1060 None Stencil (naive) 13.8 ms (12 Gflops/s) 8.2 ms (20.5 Gflops/s) Stencil (optimized) 7.6 ms (22 Gflops/s) 8.0 ms (21 Gflops/s) Homogeneous Dirichlet Stencil (naive) 13.4 ms (12.5 Gflops/s) 7.6 ms (22 Gflops/s) Stencil (optimized) 8.8 ms (19 Gflops/s) 9.2 ms (18 Gflops/s) z(1− z)xy Stencil (optimized) 36 ms (4.5 Gflops/s) 39 ms (4.5 Gflops/s) sin(πz) exp(−xy) Stencil (optimized) 54 ms (3 Gflops/s) 56 ms (3 Gflops/s) C2075 None Stencil (naive) 5.5 ms (30.5 Gflops/s) 3.1 ms (54 Gflops/s) Stencil (optimized) 4.3 ms (39 Gflops/s) 2.9 ms (58 Gflops/s) Homogeneous Dirichlet Stencil (naive) 6 ms (28 Gflops/s) 3.5 ms (48 Gflops/s) Stencil (optimized) 5 ms (33.5 Gflops/s) 3.9 ms (43 Gflops/s) z(1− z)xy Stencil (naive) 12.3 ms (13.5 Gflops/s) 6.9 ms (24 Gflops/s) Stencil (optimized) 7 ms (24 Gflops/s) 6.0 ms (28 Gflops/s) sin(πz) exp(−xy) Stencil (naive) 14.3 ms (11.5 Gflops/s) 13.8 ms (12 Gflops/s) Stencil (optimized) 9.7 ms (17.5 Gflops/s) 6.8 ms (24.5 Gflops/s) concerned with the efficient evaluation of the nonlinearity on a GPU. Since the nonlinearity is highly problem dependent, let us – for the sake of concreteness – take a simple model problem, namely the reaction-diffusion equation modeling combustion in three dimensions (see [14, p. 439]) ut = ∆v + g(u) (4) with nonlinearity g(u) = 1 4 (2− u)e20(1− 1 u ) and appropriate boundary conditions as well as an initial condition. In addition to the discretization of the Laplacian which can be conducted by stencil methods (as described in section III-A) the parallelization of the nonlinearity can be conducted pointwise on the GPU. That is (in a linear indexing scheme) we have to compute 1 4 (2− ui)e 20 ( 1− 1 ui ) , 0 ≤ i < n. (5) This computation requires only two memory operations per grid point (one read and one store); however, we have to perform a single division and a single exponentiation. Since those operations are expensive, the problem is expected to be compute bound. The results of our numerical experiments are shown in Table III. As expected, the GPU has a significant advantage over our CPU based system in this case. Fast math routines can be employed if precision is not critical and the evaluation of the nonlinearity contributes significantly to the runtime of the program. Let us duly note that the speedups observed here can not be extended to the entire exponential integrator as the sparse-matrix vector multiplication is usually the limiting factor. TABLE III TIMING OF A SINGLE COMPUTATION OF THE NONLINEARITY GIVEN IN (5). RESULTS FOR BOTH FULL PRECISION COMPUTATIONS AS WELL AS THE FAST MATH ROUTINES IMPLEMENTED IN THE GPU ARE LISTED. AS A REFERENCE A COMPARISON TO A DUAL SOCKET INTEL XENON E5620 SETUP IS PROVIDED. Double precision Device Method n = 2563 n = 5123 2x Xenon E5620 OpenMP 480 ms 4 s C1060 Full precision 14.6 ms 120 ms Fast math 6.9 ms 55 ms C2075 Full precision 4.2 ms 33 ms Fast math 2.4 ms 20 ms Single precision Device Method n = 2563 n = 5123 2x Xenon E5620 OpenMP 515 ms 4 s C1060 Full precision 15.4 ms 120 ms Fast math 7.6 ms 61 ms C2075 Full precision 2.6 ms 34 ms Fast math 1.6 ms 19 ms The nonlinearity of certain semi-linear PDEs resemble more the performance characteristics of the stencil methods discussed in sections III-A and III-B. For example, Burgers’ equation, where g(u) = (u·∇)u, falls into this category. Such nonlinearities can be efficiently implemented by the methods discussed in sections III-A and III-B. If we combine sections III-A, III-B and III-C we have all ingredients necessary to conduct an efficient implementation of exponential integrators on a single GPU. The specific performance characteristics depend on the form of the linear as well as the nonlinear part of the differential equation under consideration. In the next section we will turn our attention to the parallelization of exponential integrators to multiple GPUs. D. Multiple GPU implementation of exponential integrators If we consider the problem introduced in (4) to be solved with an exponential integrator, we have at least two possi- bilities to distribute the workload to multiple GPUs. First, one could compute the different matrix functions on different GPUs. However, since even for higher order schemes we only have to evaluate a small number of distinct matrix functions, this approach is not very flexible and depends on the method under consideration. However, if we are able to implement a parallelization of the matrix-vector product and the nonlinearity onto multiple GPUs, a much more flexible approach would result. Such an undertaking however is limited by the fact that in the worst case we have to transfer (m− 1)n (6) floating point numbers over the relatively slow PCIe bus (m is the number of GPUs whereas n is, as before, the problem size). However, in the case of differential operators only a halo region has to be updated after every iteration and thus the actual memory transfer is a tiny fraction of the value given by (6). Such a procedure was suggested in [12] for use on a cluster, where parallelization is mainly limited by the interconnection between different nodes. For performance reasons on a GPU it is advantageous to first flatten the halo regions in memory and copy it via a single call to cudaMemcpy to the device. Then the vector is updated by using that information in a fully parallelized way on the GPU. As can be seen from the results given in Table IV, the problem in (4) shows good scaling behavior (at least) up to 4 GPUs. TABLE IV PERFORMANCE COMPARISON FOR THE COMBUSTION MODEL DISCUSSED IN SECTION III-C FOR A SINGLE TIME STEP USING 40 MATRIX-VECTOR PRODUCTS (A TOLERANCE OF TOL = 10−4 WAS PRESCRIBED FOR A TIME STEP OF SIZE 10−4). A FINITE DIFFERENCE DISCRETIZATION WITH n = 2563 HAS BEEN USED. Double precision Device Method Number units Time 2x Xenon E5620 CSR/OpenMP 2 9.5 s C1060 Stencil hom. Dirichlet 1 1.5 s 4 320 ms C2075 Stencil hom. Dirichlet 1 1.2 s Single precision Device Method Number units Time 2x Xenon E5620 CSR/OpenMP 2 5.6 s C1060 Stencil hom. Dirichlet 1 1.2 s 4 540 ms C2075 Stencil hom. Dirichlet 1 210 ms Let us now discuss a different example. In certain discrete quantum systems, for example, the solution of (see, e.g., [15]) ∂tψ = H(t)ψ is to be determined, where ψ is a vector with complex entries in a high dimensional vector space and H(t) a Hermitian matrix. Such equations are efficiently solved by using Magnus integrators. In this paper we will use the example of a two spin system in a spin bath. In this case H(t) is independent of time and thus we can, in principle, take arbitrarily large time steps. The matrix H is generated beforehand and stored in the generic CSR format; for 21 spins this yields a vector with n = 221 complex entries and a matrix with approximately 83.9 · 106 non-zero complex entries (the storage requirement is about 2 GB in the double precision and 1 GB in the single precision case). This gives a sparsity of 2·10−5. Note, however, that such quantum systems couple every degree of freedom with every other degree of freedom. Thus, we are in the worst case and have to transfer (m− 1)n floating point numbers over the PCIe bus after each iteration. The results of our numerical experiments are shown in Table V. The implementation used is based on the code given in [16]. However, we have found that for the problem under consideration using a full warp for every row of our matrix results in a performance reduction. Therefore, we use only four threads per row which results, for the specific problem under consideration, in a performance increase of approx- imately 50%, as compared against the CUSPARSE library (see [17]). Apart from this consideration the code has been adapted to compute the problem stated in (3), which includes an additional term as compared to the sparse matrix-vector multiplication considered in [16]. Clearly the scaling behavior TABLE V PERFORMANCE COMPARISON FOR A SYSTEM WITH 21 SPINS. INTEGRATION IS PERFORMED UP TO t = 10 WITH A TOLERANCE OF TOL = 10−5 . Double precision Device Method Number units Time 2x Xenon E5620 CSR/OpenMP 2 46 s C1060 CSR 1 23 s 2 15 s 4 15 s C2075 CSR 1 7.7 s Single precision Device Method Number units Time 2x Xenon E5620 CSR/OpenMP 2 44 s C1060 CSR 1 15 s 2 10 s 4 7.5 s C2075 CSR 1 4 s in this case is limited by the overhead of copying between the different GPUs. For two GPUs a speedup of about 1.5 can be observed. For any additional GPU no performance gain can be observed. In total a speedup of 3 for double precision and 6 for single precision as compared to a dual socket Xenon configuration is achieved on four C1060 graphic processing units. This is only about 50% better than the speedup of 2 (double precision) and 3 (single precision) achieved with a single C1060 GPU. It should be noted that a GPU centric data format (as discussed in section II-B) could be employed instead of the CSR format. However, also in this case the overhead of copying between different GPUs would persist. Thus, in this instance the speedups that are achievable in both single and multi GPU configurations are a consequence of an unstructured matrix that makes coalesced memory access as well as parallelizability between different GPUs difficult. The dramatically better performance of the C2075 as shown in Table V is thus expected. IV. CONCLUSION & OUTLOOK We have shown that exponential integrators can be effi- ciently implemented on graphic processing units. For many problems, especially those resulting from the spatial discretiza- tion of partial differential equations, this is true for both single and multi GPU setups. In addition, we have considered stencil based implemen- tations that go beyond periodic boundary conditions and constant diffusion coefficients. Such problems can not be handled by implementations based on the fast Fourier trans- form, for example. Moreover, section III-A shows that for non-homogeneous boundary conditions the code handling the interior as well as the boundary of the domain has to be separated if optimal performance is to be achieved. However, for homogeneous or piecewise constant boundary condition an implementation directly into the CUDA kernel does not result in any significant performance decrease. The results presented in this paper show that exponential integrators, for many realistic settings, can be efficiently implemented on GPUs with significant speedups compared to more traditional implementations. Therefore, GPU computing provides a viable way to increase the efficiency of simulations in which exponential integrators are employed. The imple- mentation of exponential integrators on the current generation of GPUs would conceivably result in a further performance increase of our memory bound stencil implementation, as compared to the C2075, as the Kepler architecture offers a memory throughput of up to 250 GB/s. Furthermore, such an implementation is expected to be relatively straightforward as the cache implemented on the newer generations of GPUs works quite well in the case of stencil methods. REFERENCES [1] L. Murray, “GPU acceleration of Runge-Kutta integrators,” IEEE Trans- actions on Parallel and Distributed Systems, vol. 23, no. 1, pp. 94–101, 2012. [2] P. Micikevicius, “3D Finite Difference Computation on GPUs using CUDA,” in Proceedings of 2nd Workshop on General Purpose Pro- cessing on Graphics Processing Units, Washington, DC, USA, 2009, pp. 79–84. [3] K. Datta, M. Murphy, V. Volkov, S. Williams, and J. Carter, “Stencil computation optimization and auto-tuning on state-of-the-art multicore architectures,” Journal of Parallel and Distributed Computing, vol. 69, no. 9, pp. 762–777, 2009. [4] E. Hairer, S.P. Nørsett, and G. Wanner, Solving Ordinary Differential Equations I: Nonstiff Problems, 2nd ed. Springer-Verlag, Berlin, 1993. [5] E. Hairer and G. Wanner, Solving Ordinary Differential Equations II: Stiff and Differential-Algebraic Problems, 2nd ed. Springer-Verlag, Berlin, 1996. [6] M. Hochbruck and A. Ostermann, “Exponential integrators,” Acta Numer., vol. 19, pp. 209–286, 2010. [Online]. Available: http://www.journals.cambridge.org/abstract_S0962492910000048 [7] “CUDA C Programming Guide,” http://docs.nvidia.com/cuda/pdf/CUDA_C_Programming (Last retrieved September 19, 2013). [8] N. Bell and M. Garland, “Implementing sparse matrix-vector multiplication on throughput-oriented processors,” in Proceedings of the Conference on High Performance Computing Networking, Storage and Analysis. New York, USA: ACM Press, 2009, p. 18. [Online]. Available: http://dl.acm.org/citation.cfm?doid=1654059.1654078 [9] M. Baskaran and R. Bordawekar, “Optimizing sparse matrix-vector multiplication on GPUs,” IBM Research Report, vol. RC24704, 2009. [10] A. Dziekonski, A. Lamecki, and M. Mrozowski, “A memory efficient and fast sparse matrix vector product on a GPU,” Progress in Electro- magnetics Research, vol. 116, pp. 49–63, 2011. [11] M. Vazquez, A. Berezhkovskii, and L. Dagdug, “Diffusion in linear porous media with periodic entropy barriers: A tube formed by contact- ing spheres,” J. Chem. Phys, vol. 129, no. 4, p. 046101, 2008. [12] M. Caliari, M. Vianello, and L. Bergamaschi, “Interpolating discrete advectionâĂŞ-diffusion propagators at Leja sequences,” J. Comput. Appl. Math., vol. 172, no. 1, pp. 79–99, Nov. 2004. [Online]. Available: http://linkinghub.elsevier.com/retrieve/pii/S0377042704000998 [13] N. Bell and M. Garland, “Efficient sparse matrix-vector multiplication on CUDA,” NVIDIA NVR-2008-004, Tech. Rep., 2008. [14] W. Hundsdorfer and J. Verwer, Numerical Solution of Time-Dependent Advection-Diffusion-Reaction Equations, 2nd ed. Springer-Verlag, Berlin, Heidelberg, New York, 2007. [15] H. De Raedt and K. Michielsen, “Computational methods for simulating quantum computers,” arXiv preprint quant-ph/0406210, 2008. [16] N. Bell and M. Garland, “Efficient sparse matrix-vector multiplication on CUDA,” NVIDIA Corporation, NVIDIA Technical Report NVR-2008- 004, Dec. 2008. [17] “CUDA CUSPARSE Library,” http://docs.nvidia.com/cuda/pdf/CUDA_CUSPARSE_Users_Guid (Last retrieved September 19, 2013). http://www.journals.cambridge.org/abstract_S0962492910000048 http://docs.nvidia.com/cuda/pdf/CUDA_C_Programming_Guide.pdf http://dl.acm.org/citation.cfm?doid=1654059.1654078 http://linkinghub.elsevier.com/retrieve/pii/S0377042704000998 http://docs.nvidia.com/cuda/pdf/CUDA_CUSPARSE_Users_Guide.pdf I INTRODUCTION I-A Research problems & Results II BACKGROUND & MOTIVATION II-A GPU architecture II-B Stencil methods and matrix-vector products on GPUs II-C Exponential integrators III RESULTS III-A Stencil methods with boundary conditions III-B Stencil methods with a position-dependent coefficient III-C Evaluating the nonlinearity on a GPU III-D Multiple GPU implementation of exponential integrators IV CONCLUSION & OUTLOOK References
0non-cybersec
arXiv
Best Netflix Original?. I wanna know which Netflix Original is worth my time. I watched House of Cards and thought it was pretty ok. Thought OITNB was kind of forgettable. Are some of the other Netflix Original shows better?
0non-cybersec
Reddit
How to use spot instance with amazon elastic beanstalk?. <p>I have one infra that use amazon elastic beanstalk to deploy my application. I need to scale my app adding some spot instances that EB do not support.</p> <p>So I create a second autoscaling from a launch configuration with spot instances. The autoscaling use the same load balancer created by beanstalk.</p> <p>To up instances with the last version of my app, I copy the user data from the original launch configuration (created with beanstalk) to the launch configuration with spot instances (created by me).</p> <p>This work fine, but:</p> <ol> <li><p>how to update spot instances that have come up from the second autoscaling when the beanstalk update instances managed by him with a new version of the app?</p> </li> <li><p>is there another way so easy as, and elegant, to use spot instances and enjoy the benefits of beanstalk?</p> </li> </ol> <p><strong>UPDATE</strong></p> <p>Elastic Beanstalk add support to spot instance since 2019... see: <a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2019-11-25-spot.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2019-11-25-spot.html</a></p>
0non-cybersec
Stackexchange
Need cookie to remember two-factor authentication success (not persistent login). <p>I've read a lot here and other places about using a cookie for a "remember me" option, but what I'm looking for is a way to design a cookie to record success of a two-factor authentication. This is what, for example, Google does: If the second step succeeds (e.g., you entered the code that you received via SMS), then it sets a cookie good for a period of time (e.g., 30 days) that means that the second step can be bypassed. Call this the "verification cookie." My understanding is that if in that time you logout and then in again, it won't do the second step, but only the first step. (I tested this and that seemed to be the case.)</p> <p>My question is how to design this cookie. One idea is to put the user ID and a 128-bit random number in the cookie, and then to store that number in the database along with the user ID. This is what Charles Miller recommends (<a href="http://fishbowl.pastiche.org/2004/01/19/persistent_login_cookie_best_practice/" rel="noreferrer">http://fishbowl.pastiche.org/2004/01/19/persistent_login_cookie_best_practice/</a>) for persistent-login cookies.</p> <p>However, that's not good enough, I think. The problem is that, since the user is using a two-factor authorization, whatever cookie is used to record that the second step was successful, should be safer than would be the case with a one-factor authorization.</p> <p>What I want to avoid is this: The cracker has the hashed/salted passwords from the database, and has somehow gotten the password. If he/she has that much, I assume that the 128-bit random number that was in the verification cookie is available as well. (If the cracker has gotten the password some other way, and doesn't have the database, then the verification cookie is safe unless he/she has physical access to the computer. I'm only worried about the compromised database case.)</p> <p>Maybe an idea is to encrypt the 128-bit random number? (Needs to be 2-way -- not a hash.) The encryption key would be accessible to the application, maybe stored however the database credentials are.</p> <p>Has anyone implemented what I'm calling a verification cookie (<em>not</em> a persistent login cookie) and can tell me (us) how it was done?</p> <hr> <p>UPDATE: Thinking about this, what would I think be secure enough would be this: Cookie consists of userID and 128-bit random number -- call it R.</p> <p>Database contains password and R, each hashed and salted (e.g., using PhPass). R is then considered to be a second password. Benefit: Even if first password is bad (e.g., "password1"), R is a very good password. Database really can't be cracked, so it should not be a worry. (I was unnecessarily worried about it, I think.)</p>
0non-cybersec
Stackexchange
PZ Myers encourages creationists to stump him with this set of 10+1 questions.
0non-cybersec
Reddit
check NaN number. <p>Is it possible to check if a number is <code>NaN</code> or not?</p>
0non-cybersec
Stackexchange
Friend [F/23] said she needed space, but instead of sticking with that she desperately keeps asking for my [M/24] attention.. EDIT: Update down below Hi, My friends strange behavior is pissing me off. We've been really close for over a year now, but recently she started acting really jealous towards other girls. Would get angry with me if I spoke to other girls, or when I was out and I mentioned that it'd have been nice to have her around also she'd make comments such as "you're lying, you don't want me around. I'm not as good as those people" which is utter bulls**t. I thought this behavior was kinda odd, especially for a girl who has a boyfriend and claims to be very happy in that relationship. She explicitely told me this when I confronted her with her behavior, because I mentioned that it seems as if she's into me. That maybe she should take a look at her behavior and perhaps her current relationship when she's telling someone else she loves him. Anyhow, now just last week we had a fall out over basically the same thing. I got angry, she got angry, kind of how it goes. I made it very clear that I doubted all of her claims because whatever she claims is the contrary of her behavior. This went on for a couple of days and in the end she told me that she "doesn't want to lose me, but needs space/room to breathe in order to think about what has been said to one another". Okay fair enough, I was kinda tired of it anyway and made my point of view very clear. That it's confusing and strange. I also didn't want to put our friendship at stake any longer so I figured that if some space was the solution, so be it. I went to bed and just didn't really think about it anymore. Not even ~~24~~ **8** hours into the "needing some space" she sent me a message saying "I kind of miss you". Okay, weird, so much for needing space. Figured I'd just go with it and because I didn't want to leave her hanging I responded with "I kind of miss you too" to which she just responded "Ooh okay". Weird weird weird. After work she called me because she wanted to tell me something, and we ended up talking for about 2 hours. This was pretty stupid on my end, I shouldn't have picked up. Again.. So much for "needing space". Today again, she's very obviously trying to have contact with me.. And where I was upset it had to be this way at first, I don't know.. I don't really miss it now. Reckon I should just tell her that my interpretation of "needing" space is like.. No talking and thinking about what it is you needed the space for, instead of asking for attention? TLDR - Had a fight with a friend, she said she needed space but keeps asking for my attention. **UPDATE** I messaged her about her behavior, that it confused me and that I didn't really know what to make of it. Her excuse for telling me that she missed me during a period of "needing space" was that even though we had a fight and things were said, she wanted to let me know that she missed me a little bit anyway. She sent this message by mail, because that'd be less personal than a text. Awkward. Furthermore I did what I should have done a while ago already.. Like some of you guys suggested, tell her how you feel. I did exactly this, pinpointed her behavior and why I believe that she's into me also. This was a mistake in a way because it led to the same fight we always have. Long story short: I was wrong, she has no feelings for me. She understood that her signals may have said otherwise but NOPE. I interpret everything she said the wrong way, her relationship is amazing. She also said that she doesn't know what to think of me now, where I stand and so on. Okay cool, I couldn't be any more skeptic about what she was saying at this point so I figured I'd just point out all the things that have been said, have happened and so on. That if her relationship is that pictureperfect, she should tell everything to her boyfriend and see what he has to say to her "there are no feelings" nonsense. She never responded. She promised that she was going to give me answers as to why she said those things and that she was going to explain her behavior. This is where it more or less ended. I suppose that I'm just going to take my own space and wait for her to explain her behavior, after this.. I'll let her off easy, even though we might be missing out as some of you said, it is for the best at this point.
0non-cybersec
Reddit
Username is not in the sudoers file. This incident will be reported. <p>I am running Ubuntu 12.04 on my laptop using VMware Player. I am not sure why but I have an account called &quot;User Account&quot; in addition to my account that I usually login to use Ubuntu. Well that was just a side comment but basically all I am trying to do is install the ncurses library on Ubuntu. I have tried installing ncurses using the following command lines:</p> <pre><code>sudo apt-get install libncurses5-dev sudo apt-get install ncurses-dev </code></pre> <p>When I tried installing ncurses twice using the above commands I received the following prompt in the terminal:</p> <pre><code>[sudo] password for username </code></pre> <p>When I type in my password I receive the following message:</p> <pre><code>username is not in the sudoers file. This incident will be reported. </code></pre> <p>So far I have tried enabling the root user (&quot;Super User&quot;) account by following the instructions at this link: <a href="https://help.ubuntu.com/community/RootSudo" rel="noreferrer">https://help.ubuntu.com/community/RootSudo</a></p> <p>Here are some of the things the link suggested to do:</p> <blockquote> <p>Allow an other user to run sudo. Type the following in the command line:</p> <p>sudo adduser username sudo</p> <p>Or</p> <p>sudo adduser username sudo</p> <p>logging in as another user. Type the following in the command line:</p> <p>sudo -i -u username</p> <p>Enabling the root account. Type the following in the command line:</p> <p>sudo -i</p> <p>Or</p> <p>sudo passwd root</p> </blockquote> <p>I have tried all of the above command lines and after typing in each command I was prompted for my password. After I entered my password I received the same message as when I tried to install ncurses:</p> <pre><code>fsolano is not in the sudoers file. This incident will be reported. </code></pre>
0non-cybersec
Stackexchange
Apparently there is a Pterodactyl on the loose.
0non-cybersec
Reddit
Thought everyone might enjoy this Snapple Bottle I've had for 20 years. I've always enjoyed the look of this bottle..
0non-cybersec
Reddit
Is anyone interested in going through Hacking team's RCSAndroid repo to learn new things over IRC together?.
1cybersec
Reddit
A scenery from summer along the Rhine in Germany.
0non-cybersec
Reddit
Linux command line partition manager with LVM. <p>I need to write a program to format SD card with, FAT boot, ext4 and swap partitions. I would like the ext4 to use LVM. Ideally there would be scope for mdadm.</p> <p>I need help finding a command line utity which is capable of all this. I will be able to control any command from within my program. Would rather not cut &amp; paste source. </p> <p>I understand that Gparted does not cope well with LVM.<br> Any suggestions for a better command?</p>
0non-cybersec
Stackexchange
Create intermediate folders if one doesn&#39;t exist. <p>I am trying to create a folder for each username a user logs in as. Currently I have</p> <pre><code>private String destination = "C:/Users/Richard/printing~subversion/fileupload/web/WEB-INF/uploaded/"; // main location for uploads File theFile = new File(destination + username); // will create a sub folder for each user </code></pre> <p>but the <code>File theFile</code> bit does not create a new folder for the username. How would I do this ?</p> <p>I have tried </p> <pre><code>private String destination; public void File() { destination = "C:/Users/Richard/printing~subversion/fileupload/web/WEB-INF/uploaded/"; // main location for uploads File theFile = new File(destination + username); // will create a sub folder for each user (currently does not work, below hopefully is a solution) theFile.mkdirs(); } </code></pre> <p>but I need to use the destination later on in the program, how would I do that?</p> <p>This is my whole code:</p> <pre><code>/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package richard.fileupload; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import javax.annotation.PostConstruct; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.faces.event.ActionEvent; import javax.faces.application.FacesMessage; import javax.faces.bean.ManagedBean; import javax.faces.bean.ViewScoped; import javax.faces.context.FacesContext; import java.io.File; import org.primefaces.event.FileUploadEvent; @ViewScoped @ManagedBean(name = "fileUploadController") public class FileUploadController { /* public void handleFileUpload(FileUploadEvent event) { System.out.println("called"); FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded."); FacesContext.getCurrentInstance().addMessage(null, msg); } } */ private String username; private String destination; @PostConstruct public void init() { System.out.println("called get username"); username = FacesContext.getCurrentInstance().getExternalContext().getRemoteUser(); } public void File() { destination = "C:/Users/Richard/printing~subversion/fileupload/web/WEB-INF/uploaded/"; // main location for uploads File theFile = new File(destination + username); // will create a sub folder for each user (currently does not work, below hopefully is a solution) theFile.mkdirs(); } public File getDirectory(String destination, String username) { System.out.println("called get directory"); // currently not working, is not calling the username or destination //set the user directory from the destinarion and the logged user name File directory = new File(destination, username); //check if the location exists if (!directory.exists()) { //let's try to create it try { directory.mkdir(); } catch (SecurityException secEx) { //handle the exception secEx.printStackTrace(System.out); directory = null; } } return directory; } public void handleFileUpload(FileUploadEvent event) { System.out.println("called handle file"); FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded."); //Displays to user on the webpage FacesContext.getCurrentInstance().addMessage(null, msg); try { copyFile(event.getFile().getFileName(), event.getFile().getInputstream()); } catch (IOException e) { //handle the exception e.printStackTrace(); } } public void copyFile(String fileName, InputStream in) { try { // write the inputStream to a FileOutputStream OutputStream out = new FileOutputStream(new File(destination + fileName)); // cannot find path when adding username atm System.out.println("Called CopyFile"); //testing System.out.println(destination + fileName); int read = 0; byte[] bytes = new byte[1024]; while ((read = in.read(bytes)) != -1) { out.write(bytes, 0, read); } in.close(); out.flush(); out.close(); //make sure new file is created, (displays in glassfish server console not to end user) System.out.println("New file created!");//testing } catch (IOException e) { e.printStackTrace(); FacesMessage error = new FacesMessage("The files were not uploaded!"); FacesContext.getCurrentInstance().addMessage(null, error); } } } </code></pre> <p>FINAL EDIT (Hopefully)</p> <pre><code> public void copyFile(String fileName, InputStream in) { try { destination = "C:/Users/Richard/printing~subversion/fileupload/web/WEB-INF/uploaded/"; // main location for uploads File theFile = new File(destination + "/" + username); theFile.mkdirs();// will create a sub folder for each user (currently does not work, below hopefully is a solution) (DOES NOW WORK) System.out.println("Completed File"); // write the inputStream to a FileOutputStream OutputStream out = new FileOutputStream(new File(destination + fileName)); // cannot find path when adding username atm System.out.println("Called CopyFile"); //testing System.out.println(destination + fileName); int read = 0; byte[] bytes = new byte[1024]; while ((read = in.read(bytes)) != -1) { out.write(bytes, 0, read); } in.close(); out.flush(); out.close(); //make sure new file is created, (displays in glassfish server console not to end user) System.out.println("New file created!");//testing } catch (IOException e) { e.printStackTrace(); FacesMessage error = new FacesMessage("The files were not uploaded!"); FacesContext.getCurrentInstance().addMessage(null, error); } } } </code></pre> <p>Just how can i print out the new destination and use this later on as currently it creates the new folder but does not select it to use</p> <p>EDIT SOLVED THIS TOO :</p> <pre><code> NewDestination = "C:/Users/Richard/printing~subversion/fileupload/web/WEB-INF/uploaded/" + username; </code></pre> <p>Added the above code and now it all works</p>
0non-cybersec
Stackexchange
ar X iv :1 50 4. 02 28 8v 1 [ cs .C R ] 9 A pr 2 01 5 ROPocop - Dynamic Mitigation of Code-Reuse Attacks Andreas Follner, Eric Bodden Secure Software Engineering Group EC SPRIDE, Technische Universität Darmstadt [email protected], [email protected] Abstract. Control-flow attacks, usually achieved by exploiting a buffer-overflow vulnerability, have been a serious threat to system security for over fifteen years. Researchers have answered the threat with various mitigation techniques, but nev- ertheless, new exploits that successfully bypass these technologies still appear on a regular basis. In this paper, we propose ROPocop, a novel approach for detecting and prevent- ing the execution of injected code and for mitigating code-reuse attacks such as return-oriented programming (RoP). ROPocop uses dynamic binary instrumenta- tion, requiring neither access to source code nor debug symbols or changes to the operating system. It mitigates attacks by both monitoring the program counter at potentially dangerous points and by detecting suspicious program flows. We have implemented ROPocop for Windows x86 using PIN, a dynamic program instrumentation framework from Intel. Benchmarks using the SPEC CPU2006 suite show an average overhead of 2.4x, which is comparable to similar ap- proaches, which give weaker guarantees. Real-world applications show only an initially noticeable input lag and no stutter. In our evaluation our tool successfully detected all 11 of the latest real-world code-reuse exploits, with no false alarms. Therefore, despite the overhead, it is a viable, temporary solution to secure criti- cal systems against exploits if a vendor patch is not yet available. 1 Introduction Attacks that aim at manipulating a program’s control flow, often through a buffer over- flow vulnerability, are still one of the biggest threats to software written in unsafe lan- guages like C or C++ [4]. If successfully exploited, control-flow attacks can allow an adversary to execute arbitrary code. In the early 2000s, operating-system developers started adding mitigation techniques into their software. To this day, new techniques are added on a regular basis, however, while they make successful and reliable ex- ploitation much more difficult, they can be bypassed. Contests like, e.g., pwn2own [14] continuously show that current mitigation techniques are insufficient when it comes to protecting applications, and that more comprehensive methods are required. Currently, the most widely used attack technique, and an essential part of virtually every exploit, is RoP [23], where instead of injecting new code an attacker pieces together short code fragments, which already exist in memory. Recently proposed solutions against such attacks mostly built on CFI [22, 27, 28], seemed effective, but have been shown to be bypassable [9, 13]. Section 2 elaborates on these issues in detail. To battle current exploitation mechanisms we propose ROPocop, a novel tool that mitigates control-flow attacks for x86 Windows binaries using two novel techniques, http://arxiv.org/abs/1504.02288v1 AntiCRA and DEP+. AntiCRA greatly reduces the risk of successful code-reuse at- tacks by detecting an unusually high rate of successive indirect branches during the execution of unusually short basic blocks. As different programs can exhibit very dif- ferent behaviour in regards to that aspect, using the same threshold for every program is suboptimal. Therefore, ROPocop comes with a learning mode, which runs ahead of time and determines appropriate thresholds, which can be adopted by the user. How- ever, we do also provide default thresholds which work very well in practice and for a large selection of programs, as our evaluation shows. Our second contribution, DEP+, implements a variant of a non-executable stack through dynamic binary instrumentation. DEP+ assumes that all code has to reside within an image. This is very similar to DEP [2], however, DEP+ cannot be disabled through API calls, thereby eliminating a large class of exploits that are based on such calls. DEP+ enforces all memory to be non-executable, except for the parts to which images are loaded. To this end, DEP+ monitors the loading and unloading of images, checking after each indirect branch whether the program counter points outside the known images. We have implemented ROPocop for Windows x86 using PIN [18], a freely-available dynamic program instrumentation framework from Intel. ROPocop requires no access to source code or root privileges, nor debug symbols or changes to the operating sys- tem. Measurements using the artificial SPEC CPU2006 suite show an average overhead of 2.4x. More importantly, experiments on real-world applications show only an ini- tially noticeable input lag (caused by the initial dynamic instrumentation) and no stutter. Our evaluation using 11 of the latest code-reuse exploits shows that our tool success- fully prevents all code-injection attacks and code-reuse attacks from succeeding, even a highly sophisticated attack that relies solely on code reuse [17]. Our envisioned usage of ROPocop is to use it as a last line of defense against exploitation of critical systems, e.g., when a severe vulnerability has been discovered but no patch is available. To summarize, this work makes the following original contributions: – AntiCRA, a tunable heuristic detection of code-reuse-attacks like RoP and JoP, – DEP+, a comparatively fast and robust implementation of a non-executable stack, – ROPocop, a dynamic instrumentation tool based on PIN which detects various kinds of control-flow attacks using the above techniques, and – an empirical evaluation showing that ROPocop’s mitigation approach is highly ef- fective and shows tolerable runtime overheads. We make ROPocop available online as open source, along with all our experimental data: https://sites.google.com/site/ropocopresearch/ 2 Current Situation Exploiting vulnerabilities with the goal to manipulate the program flow was relatively trivial on Windows until the early 2000s, when Microsoft began adapting mitigation techniques. In the simplest cases, an attack widely known as stack smashing [21] could be used. Such an attack would leverage unbounded functions, such as strcpy, to write beyond the allocated memory of a buffer. Attackers could thus overwrite the function’s https://sites.google.com/site/ropocopresearch/ stored return address on the stack with an address that points to injected code, which the program will execute after the next return. To defend against such code injection attacks, Microsoft implemented Data Execu- tion Prevention (DEP) [19], which makes use of a processor’s NX (no execute) bit. DEP marks pages which contain data as non-executable, causing a hardware-level exception if execution from within such a page is attempted. This successfully prevents attacks that attempt to execute injected code. Nevertheless, attackers can bypass DEP in various ways. At present, the most widely used technique is called return-oriented programming [24]. When utilizing RoP, an at- tacker does not inject any code but instead uses existing code fragments (gadgets), which all end with a return instruction. In other words, instead of injecting code, the at- tacker injects the addresses of the gadgets he wants to execute. On x86, return works by popping an address off the stack into the register EIP and then jumping to that address, even if the stack is marked as non-executable. By crafting a stack filled with a sequence of gadget addresses, the attacker can execute sequences of gadgets, with the return in- struction at the end of each gadget transferring the program flow to the next gadget. Jump-oriented programming (JoP) [3,6,20] is based on the same basic concept as RoP, but uses jmp instructions to transfer control flow to the next gadget. In the following, we refer to both RoP and JoP attacks as code-reuse attacks. The success of code-reuse attacks depends on the availability of useful gadgets on the target platform and the complexity of the code the attacker wants to run. In practice, however, most systems are vulnerable to such code-reuse attacks. Furthermore, RoP attacks are relatively complex to stage, which is why most attacks of this kind do not resort to pure RoP, but rather implement a two-staged approach. The first stage uses RoP to call a Windows API function like VirtualProtect (see below) which marks a certain memory region as executable, effectively bypassing DEP. This is followed by the second stage, running code previously injected into that memory region, which can then be executed as normal. Code-reuse attacks work reliably if the memory layout of an application is highly deterministic because an attacker can hard-code the addresses of gadgets directly into the exploit. To mitigate this, Microsoft introduced randomness in the form of ASLR [15]. ASLR randomizes the order in which images are loaded into the virtual address space and adds pseudo-random offsets to their base addresses. This makes it very difficult for an attacker to predict the memory locations of the required gadgets on the target system. 2.1 DEP Weaknesses Whether or not a program is protected by DEP depends on the compiler setting the NX_COMPAT flag in the header of the program’s main executable. This flag may be left unset due to a number of reasons, including unsafe compiler defaults and program in- compatibility. Thus, the opt-in nature of DEP may render its benefits void. Furthermore, DEP is either on or off for the whole program, meaning that linking any one library with DEP disabled, be it statically or dynamically, will cause DEP to be disabled for the entire process. If it is enabled, an attacker can only bypass it through previously dis- cussed code-reuse attacks. Such attacks succeed without ever running code from non- executable pages, which is why DEP cannot protect against them. The previously men- tioned two-staged attack, however, is worth explaining in more detail, since it allows in- jected code to be run, effectively bypassing DEP. Such attacks work because Windows exposes certain functions to change the permissions of a page (e.g. VirtualProtect) or allocate new pages with specific permissions (e.g. VirtualAlloc), which are passed as parameters. These APIs exist because some programs generate code at runtime and therefore require memory that is both writeable and executable. Such program be- haviour is strongly discouraged by Microsoft, though, and many producers of software have adapted their programs to be compatible with DEP. 2.2 ASLR Weaknesses Like DEP, ASLR is not necessarily enabled, depending on the flag DYNAMIC_BASE. However, unlike DEP, it can be localized to specific modules, with the operating system being able to handle processes composed of a mixture of ASLR-enabled and disabled images, which simply means that some images will get rebased and others will not. Apart from legacy libraries which were compiled before ASLR existed, a library might not support ASLR because parts of a program use hard-coded jump addresses within that library. Bypassing ASLR appears to be difficult in practice, with no currently- known generic attack. The work by Shacham et al. [25] relies on brute force, which only works if the vulnerable application does not crash when an access violation occurs. Partial overwrites [11] overwrite only the last two bytes of an address on the stack. Be- cause only the first two bytes get randomized, this attack does not require knowledge of the randomness introduced by ASLR. This gives an attacker a range of at most 4096 bytes of instructions. Durden presents information leaks as a way of gathering informa- tion about the memory layout of an ASLR-protected application [11]. Hund et al. [16] propose a timing-based side channel attack that can break kernel space ASLR within minutes, given that an attacker knows the hardware of the attacked system. However, most current exploits do not have to use such techniques, and instead can rely on the presence of some non-ASLR images on the target platform. Such images, however, are still very common on current systems, which is why many attacks still succeed. 2.3 Attacker Model We assume a relatively strong attacker, who is able to bypass DEP, ASLR, and other mitigation techniques which are currently part of Windows. This is, for a determined attacker, a realistic assumption. We even go one step further and allow for pure RoP and JoP attacks, which do not have to call VirtualProtect or VirtualAlloc but instead call the malicious code directly. Such pure code-reuse attacks are still rarely found in the wild, but we expect them to increase due to the work that is being done on detecting two-staged attacks. One known example is a pure RoP attack on Adobe Reader [17]. 3 AntiCRA When designing AntiCRA, we analyzed RoP and JoP exploits and their underlying principles. We found that the exploits share properties which are unusual and typically not present in a normal program’s execution. Based on these observations, we built a heuristic which monitors the following two properties: Indirect Branches Code-reuse attacks consist of gadgets which all end in an indi- rect branch. We analyzed benchmarks as well as real-world applications like Adobe Reader, VLC, Microsoft Office, Open Office (in total 34 programs; the complete list is available on the project’s website) and found that a very high number of consecutive in- direct branches is rather unusual. The highest number of subsequent indirect branches we found during our experiments was 47 (in Microsoft Word), but only 8 of the 34 programs execute 15 or more subsequent indirect branches. Average Length of Basic Blocks To reduce side-effects on other registers, the stack, or flags, exploit developers try to use gadgets that are as short as possible. Therefore, at least for contemporary approaches, gadgets can be considered basic blocks with very few instructions. As with indirect branches, we analyzed program behaviour of legiti- mate programs and found that the average number of instructions over a sliding window of 10 basic blocks did not drop below 2.33. We also found an interesting correlation be- tween this and the previous property: the more consecutive indirect branches, the longer the corresponding basic blocks. We make use of this knowledge in the next paragraph, when we try to find default parameters which work for a wide set of applications. As previously mentioned, since programs can exhibit varying characteristics regard- ing these two properties, ROPocop first runs in learning mode. This requires nothing from the user but simply using the program she wants to protect as usual, while in the background, ROPocop observes the program flow and determines appropriate thresh- olds for these two properties. This, of course, leads only to limited coverage, however for our approach high coverage is not required. Exploiting a buffer overflow requires some sort of input, generally provided by the attacker as a file that has to be opened by the victim and is then processed by the vulnerable program. Thus, a user working with the program covers the important cases which lead to exploitation. For our sample set we chose applications, which are commonly used in corporate and personal environ- ments. As expressed earlier, we recommend setting individual thresholds for different programs, but at the same time we were wondering whether it is possible to provide de- fault values which cover as many programs as possible. After analyzing our test set of benign applications, by running the learning mode and using the programs in our sam- ple set (e.g., opening various media files using VLC, opening various PDF files with Adobe Reader, working with Microsoft Word, etc.) we set the following thresholds: 35 subsequent indirect branches and an average basic block length of 2.25 or lower; as described earlier, we found a correlation that larger numbers of subsequent basic blocks also means longer basic blocks. Therefore we added another threshold; 36 till 50 sub- sequent indirect branches and an average basic block length of 4 or lower. AntiCRA signals an exploitation attempt if one of the two bounds is violated or if, at any point, more than 50 subsequent indirect branches are executed. While our sample set of benign applications may not be large enough to make a claim, that theses suggested thresholds hold for all programs, they do hold for all programs in our set, which includes some of the most exploited applications. Therefore, they serve as an excellent starting point for fine-tuning, should it be required. Since we included many programs that are of- ten found and exploited in business environments (e.g., Word, Excel, Adobe Reader), ROPocop can be deployed immediately without the need to fine-tune thresholds. To increase performance and make the algorithm less prone to false positives, calcu- lating averages starts only after we have collected 15 basic-block lengths, i.e., the first computed average is available only after 15 subsequent indirect branches. This prevents false alarms based on short sequences of short basic blocks, whose sample size is other- wise not significant enough. Figure 1 (in Section 5) shows how the two thresholds form a (shaded) area in a two-dimensional plain. If an execution falls into the shaded area then AntiCRA will signal it as malicious. The figure also summarizes the results of our empirical evaluation, and will be explained in more detail later. 3.1 Impact on Current and Future Exploits For a code-reuse attack to circumvent AntiCRA, it must not use more than 34 / 49 con- secutive indirect branches. If this is possible at all depends on the availability of gadgets, which varies between programs based on what libraries are loaded and whether or not ASLR is being employed. Furthermore, the average number of instructions in the gad- gets used must never fall below 2.25 / 3.5. Combined, these restrictions make it very difficult for an attacker to create a pure RoP or JoP payload. Attackers could attempt to raise the average number of instructions per gadget by inserting longer gadgets. But longer gadgets usually have unwanted side-effects, like manipulating other registers that hold important data, or the stack, or modifying flags. Furthermore, since the total number of gadgets is limited to 34 / 49, inserting long gadgets whose side effects are irrelevant just for the sake of increasing the average wastes precious slots for useful gadgets. To bypass AntiCRA, an attacker would have to try and insert direct branches, but, due to limited availability and side-effects, this is anything but trivial. In particu- lar, we know of no gadget compiler that would support direct branches at this point. Depending on the program it might still be possible, but, as previously mentioned, our goal is to break current exploits and make the development of new code-reuse exploits significantly more difficult, which AntiCRA certainly achieves. Long NOP gadgets, as proposed by Davi et al. [9], could potentially be used to artificially increase the average basic block length, however, it takes five gadgets to restore the stack and registers to their original form. Therefore, precious space has to be wasted and such an attempt will most likely exceed any sensible threshold. Furthermore, the authors state that finding such a gadget was ”a non-trivial task that required painstaking analyses and a stroke of luck”, so for some programs this technique might not be possible at all. 3.2 Limitations Due to its heuristic nature, false positives as well as false negatives are possible. As we show in this work, however, in practice the heuristic seems effective enough to go without any false decisions, at least in our benchmark set. Furthermore, under circum- stances very favorable to an attacker it might be possible to create a two-staged exploit that disables DEP using fewer than 15 gadgets and then runs a regular payload. This would not be detected by AntiCRA and motivates the need for reliably non-executable data sections, which we enforce using DEP+ (Section 4). 4 DEP+ DEP+ is based on the same concept as DEP, i.e., the premise that data should not be executable. DEP+ thus monitors the loading and unloading of images and creates a virtual memory map based on this information. All virtual memory space where no image is mapped is considered to hold potentially malicious data, since Windows can allocate stacks or heaps in these areas. To enforce that the instruction register EIP never points outside an image DEP+ checks the register value after each indirect branch, i.e., after each return, indirect call, and indirect jump. Opposed to DEP, DEP+ cannot be disabled through API calls such as VirtualProtect. 4.1 Implementation Details PIN’s IMG_AddInstrumentFunction as well as IMG_AddUnloadFunction are used to monitor the loading and unloading of images. When an image is loaded, DEP+ stores its start and end address in an array of structs; if the same image is unloaded at runtime, it is removed from the array. The data structure results in a virtual-memory map that distinguishes only between images and non-images, i.e., code and data regions. DEP+ treats the latter as space for potentially malicious data, hence does not allow EIP to point into it. To do so, DEP+ checks if the last instruction of a basic block is an indirect branch, and, if so, it checks if the target address of the branch points inside any of the data regions. Some programs load 30 or more libraries, which means that processes can have an equally high number of code regions. As we found, checking each of those regions after each indirect branch can incur a significant performance penalty. To increase per- formance, we thus make use of the fact that Windows’ memory management is rela- tively deterministic. Images, in general, tend to be loaded at very high addresses, around 0x60000000 and higher, while stacks and heaps are at low addresses and new ones are allocated towards increasingly higher addresses. Depending on the memory usage of a process, it is generally valid to assume that stacks and heaps reside below most images. DEP+ makes use of this knowledge by not checking all regions when checking EIP after an indirect branch. DEP+ monitors a program’s memory usage to dynamically increase or decrease the number of regions that need to be taken into account. We im- plement this by probing memory usage every 10th time a function that allocates or de-allocates memory is called and multiply the reported usage by 1.3 to have a large enough safety margin. This is, of course, a heuristic, which trades security for perfor- mance, but as our evaluation in Section 5 shows, the heuristic helps DEP+ to bring the checks down to a minimum while still recognizing all tested attacks. Furthermore, our experiments using benchmarks and real-world programs have shown that memory allo- cations are done in many small steps, hence probing memory usage in short intervals and adding a safety margin of 30% has never failed to correctly detect the necessary number of regions which have to be checked. For the heuristic to fail and be exploitable it would take a memory allocation of about 30% of the current memory usage, a vulner- able function which uses this memory and an instruction which redirects program flow into this memory before our algorithm checks memory usage again. Since an attacker has no influence on any of these preconditions, we accept the risk that our heuristic might fail under rare conditions. Reliably exploiting such circumstances in a multi- threaded program would be even more difficult, due to their highly non-deterministic nature. 4.2 Comparison to DEP The original shortcomings of DEP are that it may not be enabled at all, or that it can be bypassed by both pure code-reuse attacks and by code-reuse attacks that invoke VirtualProtect etc. to disable DEP. DEP+ improves over DEP in that it prevents the execution of injected code by enforcing non-executable data regions even for processes that run with regular DEP disabled. In particular, DEP+ cannot bypassed by calls to VirtualProtect and its siblings, as such calls have no effect on DEP+. A similar result could be achieved by hooking said functions and simply not executing them. However, userland hooks can be bypassed easily [5] and kernel hooks require admin- istrator privileges, hence make deploying our solution more complicated. Furthermore, as Section 5 shows, the overhead introduced by DEP+ is negligible. 4.3 Limitations Processes which rely on the ability to execute code from outside images, e.g., processes which generate code at runtime or incorporate self-modifying code, are not compati- ble with DEP+. Such a process is not compatible with DEP either, unless it uses the VirtualProtect API etc. to disable DEP for memory regions with generated code. Since it is difficult to detect whether a call to the API usually abused to bypass DEP by an attacker is legitimate, i.e., originating from the program itself, we decided against supporting such calls. This results in a strong increase in security, at the drawback of slightly reduced compatibility with mostly older software. Like DEP, DEP+ cannot detect and thus not prevent the exploitation of the vulnerabil- ity itself, e.g., the overwriting of data on the stack due to a buffer overflow. Therefore, non-control data attacks [7] or information leakages are still possible. Furthermore, DEP+ does not prevent pure code-reuse attacks, motivating the need for AntiCRA (Sec- tion 3). 5 Evaluation Our implementation is highly modular, so that one may deploy AntiCRA or DEP+ inde- pendently as well as in combination. Running both of them, however, strongly increases security, in a similar fashion as running with DEP and ASLR. In this chapter we evaluate AntiCRA and DEP+ by addressing the following research questions: – RQ1: How effectively does AntiCRA detect pure code-reuse payloads? – RQ2: How effectively does AntiCRA detect two-staged RoP payloads? – RQ3: How effectively does DEP+ detect code-injection attacks? – RQ4: What is the performance overhead of AntiCRA and DEP+? 5.1 Evaluation of AntiCRA (RQ1/RQ2) For evaluating RQ1 we looked at pure code-reuse attacks, however, at this point such payloads are only rarely found in the wild and are mostly used in academia as proof of concept. The only real-world pure code-reuse exploit we found is a RoP exploit for Adobe Reader. Since neither the exploit’s source code, nor an infected file are publicly available, our conclusion is based on an analysis by Li and Szor [17]. Analyzing the exploit’s source code reveals that the address 0x6acc1049 is repeated 9,344 times; the instruction at that address is a simple ret. This equals to over 9,000 indirect branches in a row, which would, of course, be detected by AntiCRA. The likely reason for why pure RoP and JoP payloads still seem to be rare in practice is that two-staged payloads (which aim to disable DEP through RoP/JoP) are simpler to construct and are sufficient in many cases. Such payloads can be mitigated by DEP+, but nevertheless we were interested in evaluating RQ2, i.e., to what extent AntiCRA alone, without DEP+, can be used to mitigate such attacks as well. We analyzed 11 real-world exploits in total. To operate on an unbiased test set, we an- alyzed the 10 most recent exploits from http://www.toexploit.com/ which claim to bypass ASLR and also added the previously mentioned pure RoP exploit. Figure 1 shows the results of our analysis, i.e., the number of consecutive indirect branches and the average basic block length for each exploit and also for legitimate programs. As the numbers indicate, legitimate programs rarely have more than 15 consecutive indirect branches and their average basic block length is higher than that of exploits. This con- firms that our generalized threshholds, which work for a wide variety of programs, are well-suited to detect attacks. AntiCRA detects 10 out of the 11 exploits in our sample set. In five cases this is due to the number of indirect branches in a row. Three exploits are detected because they use very short gadgets, which mostly only execute one instruction and then transfer program execution to the next gadget. Two exploits trigger both mechanisms, since they use more than 35 indirect branches in a row and also very short gadgets. One exploit cannot be detected by AntiCRA. This is because it requires only 13 gadgets to prepare the stack for calling VirtualProtect. This is not enough to trigger the indirect-branch check. The average length of the basic blocks is 2.2, which would trigger an alarm. However, as explained in Section 3, we only trigger inspections after a total of 15 indirect branches in a row. It is important to point out that the two-staged exploit AntiCRA misses is detected by DEP+. AntiCRA is primarily designed to catch pure RoP and JoP attacks, not necessar- ily the two-staged attacks like the ones examined in the evaluation. It is also important to keep in mind that the thresholds can and should be adjusted for each program and that this section evaluates how well our generalized thresholds hold. Despite this, it still detects 10 out of 11 exploits. Because of these results and our analysis of the pure RoP exploit for Adobe Reader, we are very confident that exploits which rely solely on RoP or JoP can be detected by AntiCRA. http://www.toexploit.com/ 0 10 20 30 40 50 0 1 2 3 4 5 Threshold BB length Threshold ind. branches No. of indirect branches in a row L ow es t av er ag e of B B s SPEC Exploits Applications Fig. 1. Analysis of the number of indirect branches in a row and the lowest average basic block length of our test set 5.2 Evaluation of DEP+ (RQ3) To test DEP+, we wrote a small vulnerable application, which uses an unbounded strcpy and was compiled with the NX_COMPAT,and a simple exploit. Since all code injection attacks store the injected code inside a buffer which, by definition, cannot be in an image, the program that contains the vulnerability is of little consequence. The only differences between our vulnerable application and a real application are miti- gation techniques which might be in place, but which are irrelevant to us, since we assume an attacker is able to bypass them, and how program flow is transferred to the injected code, which is irrelevant for our evaluation as well. Ultimately, all code injec- tion attacks end up calling their injected code, and this is where DEP+ detects them. Therefore, evaluating DEP+ with this self-written program poses no real threat to the validity of this experiment. As expected, DEP+ correctly detects that the target address of the ret instruction at the end of our vulnerable function is not in an image, before the instruction is actually executed. Therefore, it can terminate the program and miti- gate an attack, which would have led to arbitrary code execution. As for the real world exploits, DEP+ detects each one except for the pure RoP exploit for Adobe Reader, as all the others eventually do execute code from memory outside of images. 5.3 Performance (RQ4) We evaluated the performance of ROPocop using the C and C++ benchmarks in the SPEC CPU2006 benchmark suite. Note that those are really worst-case benchmarks that exercise the dynamic analysis heavily. Any interactive or network-based application would show a significantly lower overhead. We measured five different runtimes for each benchmark: – The native runtime, i.e., without PIN. – The runtime with PIN attached, but without instrumentation, to get the basic over- head PIN introduces. – The runtime with AntiCRA. – The runtime with DEP+. – The runtime with AntiCRA and DEP+. Benchmarks were run on Windows 7 SP1 with an Intel Core 2 Duo T9400 clocked at 2.53 GHz and 4 GB RAM using the reference workload. Figure 2 summarizes the results of our performance benchmarks. Running a program under PIN but without any instrumentation introduces an average overhead1 of 1.36x, i.e., programs take, on average, 36% more time to finish, ranging from 1.002x (470.lbm) to 2.24x (464.h264ref). Programs protected by AntiCRA run, on average, with a total overhead 2.2x. With DEP+ enabled as well, ROPocop introduces an average overhead of 2.39x, which is comparable to similar tools such as ROPdefender [10], which gives weaker guarantees. Compared to CFI approaches [22, 27, 28] ROPocop has a consider- ably higher overhead, however, it monitors a process throughout its whole lifetime and not just at potentially dangerous points. Thus, it can determine more accurate if a RoP attack is being carried out. 40 0 40 1 40 3 42 9 43 3 44 4 44 5 44 7 45 0 45 3 45 6 45 8 46 4 47 0 47 1 47 3 48 2 48 3 0 2,000 4,000 SPEC CPU2006 Benchmark R un ti m e (s ) Native PIN only PIN & AntiCRA PIN & AntiCRA & DEP+ Fig. 2. Performance of ROPocop While overheads in the order of two-fold might sound unacceptable, those overheads should really only be expected in worst-case situations. Thus, while performance bench- marks such as SPEC CPU2006 are advantageous in producing reproducable results, the results that they do produce do not reflect reality very much. What ultimately counts is the performance on real-world applications. Their performance can, however, often hardly be measured systematically, which is why we only report qualitative results on some of the applications in our sample set. As a general observation we can say that in 1 Average overheads were computed using the geometric mean, which is considered best prac- tice for reporting normalized values such as percentages of overhead [12] all cases the GUI had some slight input lag < 1 second when opening a menu for the first time, however, afterwards they opened in an instant. File transfers with Filezilla were no slower than without our tool. VLC plays h.264 encoded HD videos without any jitter. Adobe Reader renders pages without any noticeable lag. Typing in Microsoft Word has no input lag. We want to emphasize that ROPocop is not intended to be used with all applications at all times. Instead, our recommended usage is to enable it only for either very critical systems, or for an application which has a vulnerability that’s being actively exploited and no vendor patch has been released yet. Under such circumstances the overhead is, in our opinion, acceptable. 6 Related Work TRUSS [26] and ROPdefender [10] store copies of return addresses using a runtime shadow stack. When a function is called, a copy of the pushed return address is stored on the shadow stack. Upon returning from a procedure, the return address on the stack is compared to the one on the shadow stack. TRUSS is implemented using DynamoRIO, ROPdefender using PIN. DynamoRIO is a runtime instrumentation tool which works similarly to PIN. TRUSS and ROPdefender rely on an attacker overwriting the return address on the stack, which is not strictly required. Therefore, they can miss some classes of attacks like JoP. Furthermore, they assume that function calls are always made through call and exited via ret. ROPdefender can handle exceptions, but nei- ther can handle hand-crafted assembly code, which does not necessarily follow these conventions. The overhead of both tools is similar to ours. kBouncer [22] makes use of the last branch record (LBR) feature some modern CPUs have. kBouncer assumes that at some point shellcode has to invoke a system call. When this occurs, the LBR repository is checked for distinctive properties of ROP- like behaviour, e.g. consecutive indirect jumps and short basic blocks. The tool has an average overhead of only 1%, however, the implementation for Windows 7 is not fully functional, since Windows 7 does not allow to intercept system calls which is a requirement of kBouncer. Furthermore, it cannot be deployed on systems whose CPU doesn’t have LBR. ROPecker [8] also uses the LBR feature of some modern CPUs. Like ROPocop it checks for consecutive short indirect branches and raises an alert when a certain thresh- old is undercut. To increase performance the detection heuristic is only invoked if the branch target is outside the so-called “sliding window” (a collection of pages, usually 2 or 4, i.e. 8 or 16 kB). Due to these two circumstances, ROPecker has a very low overhead of only 2.6% for the SPEC CPU2006 benchmark suite. It does, however, miss ROP gadgets which are within the sliding window and requires a CPU which supports the LBR feature. Control Flow Integrity [1] uses static analysis of a binary to create a control-flow graph and rewrites the binary to enforce it does not deviate from the pre-computed paths. The implementation is based on Vulcan, a commercial dynamic instrumentation tool for x86 binaries. The average overhead is about 16%. CCFIR [27] enforces control-flow integrity by ensuring that targets of indirect jumps are legal. Valid targets are identified ahead of time by statically analysing a given bi- nary. For their analysis to work properly they require the binary to use ASLR and DEP. CCFIR has a runtime overhead of about 4%. Göktaş et al. [13] have recently shown, that the above mentioned CFI approaches can be bypassed. The inherent problems of these approaches is that there are too few checks, allowing attackers to access too many gadgets. They are further limited by the number of slots in the LBR, which is at most 16. To improve the security of approaches which attempt to detect RoP exploits by measuring similar properties as we do, they suggest making the thresholds dynamic. 7 Conclusion In this work we have presented ROPocop, a novel tool for the automated dynamic recog- nition of buffer-overflow attacks. ROPocop is designed to recognize different classes of code-reuse attacks based on two novel techniques AntiCRA and DEP+. AntiCRA is a configurable heuristic based on the number of indirect branches executed in a row as well as on the average basic block length of executed code. In our experiments us- ing default thresholds which work for a variety of programs, AntiCRA detects 10 out of 11 of the latest real-world code-reuse exploits and yields no false alarms on SPEC CPU2006 and all tested real-world applications, a total of 35 programs. DEP+ exe- cutes a non-executable stack through binary instrumentation and can thus be used to detect exploits based on two-staged payloads that use a code-reuse attack to disable DEP using the Windows API. DEP+ successfully detects all two-staged payloads we examined, again with no false alarms. By combining both techniques, ROPocop thus successfully detects all tested exploits, without false warnings, showing an average per- formance overhead of 2.4x for SPEC CPU2006 and real-world applications showing only an initially noticeable input lag and no stutter. ROPocop runs in user mode, requir- ing no access to source code, nor debug symbols or changes to the operating system. It supports multi-threaded applications. Due to its heuristic nature, ROPocop cannot give an absolute security guarantee. However, the parameters the heuristic is based on should make it very hard to circumvent the approach in practice. ROPocop is thus raising the bar significantly, without any added cost compared to previous related approaches. Acknowledgments This work was supported by the German Federal Ministry of Education and Research (BMBF) within EC SPRIDE and by the Hessian LOEWE excellence initiative within CASED. References 1. M. Abadi, M. Budiu, U. Erlingsson, and J. Ligatti. Control-flow integrity principles, imple- mentations, and applications. ACM Trans. Inf. Syst. Secur., 13(1):4:1–4:40, Nov. 2009. 2. S. Andersen and V. Abella. Changes to functionality in windows xp service pack 2 - part 3: Memory protection technologies, Aug. 2004. 3. T. Bletsch, X. Jiang, V. W. Freeh, and Z. Liang. Jump-oriented programming: a new class of code-reuse attack. ASIACCS ’11, pages 30–40. ACM, 2011. 4. C. Bubinas. Buffer overflows are the top software security vulnerability of the past 25 years, Mar. 2013. 5. J. Butler and Anonymous. Bypassing 3rd party windows buffer overflow protection. Phrack, 11, 2004. 6. S. Checkoway, L. Davi, A. Dmitrienko, A.-R. Sadeghi, H. Shacham, and M. Winandy. Return-oriented programming without returns. CCS ’10, pages 559–572. ACM, 2010. 7. S. Chen, J. Xu, E. C. Sezer, P. Gauriar, and R. K. Iyer. Non-control-data attacks are realistic threats. SSYM’05, pages 12–12. USENIX Association, 2005. 8. Y. Cheng, Z. Zhou, M. Yu, X. Ding, and R. H. Deng. Ropecker: A generic and practical approach for defending against rop attacks. 2014. 9. L. Davi, A.-R. Sadeghi, D. Lehmann, and F. Monrose. Stitching the gadgets: On the inef- fectiveness of coarse-grained control-flow integrity protection. In Proc. of the 23rd USENIX Conf. on Security, SEC’14, pages 401–416. USENIX Association, 2014. 10. L. Davi, A.-R. Sadeghi, and M. Winandy. Ropdefender: a detection tool to defend against return-oriented programming attacks. ASIACCS ’11, pages 40–51. ACM, 2011. 11. T. Durden. Bypassing pax aslr protection. Phrack, 11, 2002. 12. P. J. Fleming and J. J. Wallace. How not to lie with statistics: the correct way to summarize benchmark results. Commun. ACM, 29(3):218–221, Mar. 1986. 13. E. Göktaş, E. Athanasopoulos, M. Polychronakis, H. Bos, and G. Portokalidis. Size does matter: Why using gadget-chain length to prevent code-reuse attacks is hard. In Proc. of the 23rd USENIX Conf. on Security Symposium, SEC’14, pages 417–432. USENIX Association, 2014. 14. A. Gunn. Pwn2own 2014: A recap, 2014. 15. M. Howard, M. Miller, J. Lambert, and M. Thomlinson. Windows isv software security defenses, Dec. 2010. 16. R. Hund, C. Willems, and T. Holz. Practical timing side channel attacks against kernel space aslr. SP ’13, pages 191–205. IEEE Computer Society, 2013. 17. X. Li and P. Szor. Emerging stack pivoting exploits bypass common security, May 2013. 18. C.-K. Luk, R. Cohn, R. Muth, H. Patil, A. Klauser, G. Lowney, S. Wallace, V. J. Reddi, and K. Hazelwood. Pin: building customized program analysis tools with dynamic instrumenta- tion. PLDI ’05, pages 190–200. ACM, 2005. 19. Microsoft. Data execution prevention. 20. J.-W. Min, S.-M. Jung, D.-Y. Lee, and T.-M. Chung. Jump oriented programming on win- dows platform (on the x86). volume 7335 of Lecture Notes in Computer Science, pages 376–390. Springer, 2012. 21. A. One. Smashing the stack for fun and profit. Phrack, 7, 1996. 22. V. Pappas, M. Polychronakis, and A. D. Keromytis. Transparent rop exploit mitigation using indirect branch tracing. SEC’13, pages 447–462. USENIX Association, 2013. 23. R. Roemer, E. Buchanan, H. Shacham, and S. Savage. Return-oriented programming: Sys- tems, languages, and applications. ACM Trans. Inf. Syst. Secur., 15(1):2:1–2:34, Mar. 2012. 24. H. Shacham. The geometry of innocent flesh on the bone: return-into-libc without function calls (on the x86). CCS ’07, pages 552–561. ACM, 2007. 25. H. Shacham, M. Page, B. Pfaff, E.-J. Goh, N. Modadugu, and D. Boneh. On the effectiveness of address-space randomization. CCS ’04, pages 298–307. ACM, 2004. 26. S. Sinnadurai, Q. Zhao, and W. fai Wong. Transparent runtime shadow stack: Protection against malicious return address modifications. 27. C. Zhang, T. Wei, Z. Chen, L. Duan, L. Szekeres, S. McCamant, D. Song, and W. Zou. Practical control flow integrity and randomization for binary executables. SP ’13, pages 559–573. IEEE Computer Society, 2013. 28. M. Zhang and R. Sekar. Control flow integrity for cots binaries. In Proc. of the 22Nd USENIX Conf. on Security, SEC’13, pages 337–352. USENIX Association, 2013. ROPocop - Dynamic Mitigation of Code-Reuse Attacks
1cybersec
arXiv
Declare CSS style outside the &quot;HEAD&quot; element of an &quot;HTML&quot; page?. <p>my use-case is the following :</p> <p>I'm composing an <strong>HTML page</strong> by using parts that are <strong>valid HTML fragments</strong> but not valid pages, like <strong>Divs</strong>; these elements are using <strong>CSS</strong> to manage their style.</p> <p>I'd like to allow each fragment to be responsible for its own styling requirements and to not rely on the declarations of style-sheets in the main fragment (the one with the "HTML" tag).</p> <p>So here come the question : <strong>is there any (standard) way to add some CSS styling outside the HEAD element</strong> (excluding the inline styling via the "style" attribute) ?</p> <p>I guess I could use frames but I'd prefer to avoid this solution.</p> <p>Thanks in advance for your help.</p> <p><strong>FINAL EDIT :</strong></p> <p>Thanks to the propositions of <strong><em>zzzzBov</em></strong>, <strong><em>JMC Creative</em></strong> and <strong><em>moontear</em></strong>, and after some testing, here is the answer :</p> <ul> <li>use <strong>JavaScript to dynamically load some CSS style-sheets</strong> : <strong>HTML4/XHTML</strong> and <strong>HTML5 compliant</strong>,</li> <li><strong>embed "style" elements</strong> directly inside the fragments : <strong>non-compliant</strong> with <strong>HTML4/XHTML</strong> but seems to be <strong>broadly supported</strong>, and is <strong>HTML5 compliant</strong>.</li> </ul> <p>As I must support email clients I've used the second solution which moreover is more simple.</p> <p>Thanks all for your interest and participation.</p>
0non-cybersec
Stackexchange
$‎\Delta ‎^2(.)-‎\frac{‎‎\lambda‎‎}{|x|^4}(.): W^{2,2}(\Omega) \cap W^{1,2}_0(\Omega) \to W_0^{-2,2}(\Omega) ‎$ is coercive.. <p>I am reading an article and there, author claim that $$‎L(.)=\Delta ‎^2(.)-‎\frac{‎‎\lambda‎‎}{|x|^4}(.): W^{2,2}(\Omega) \cap W^{1,2}_0(\Omega) \to W_0^{-2,2}(\Omega) ‎$$ is coercive if ‎‎$ ‎0\leq ‎‎\lambda&lt;\Lambda_N=(‎\frac{N^2(N-4)^2}{16})‎$ , because of the following inequality:</p> <blockquote> <p>For all ‎‎‎$ u‎ ‎\in‎ W^{2,2}(\Omega) \cap W^{1,2}_0(\Omega) $ و ‎‎$‎N&gt;4‎$‎‎ ‎ $$ ‎\Lambda_N ‎\int_{\Omega}‎\frac{u^2}{|x|^4}\mathrm{d}x ‎\leq ‎\int_{\Omega} ‎|\Delta u|^2 ‎\mathrm{d}x‎ $$ where $‎\Lambda_N=(‎\frac{N^2(N-4)^2}{16})‎$ is optimal constant.</p> </blockquote> <p>My question is this that how the inequality with the optimal constant conclude that operator is coercive for ‎‎$ ‎0\leq ‎‎\lambda&lt;\Lambda_N=(‎\frac{N^2(N-4)^2}{16})‎$.</p> <p>my try:</p> <p>the norm on the hilbet space $\mathbb{H}=W^{2,2}(\Omega) \cap W^{1,2}_0(\Omega)$ is $$\langle u,v\rangle_{‎\mathbb{‎‎H}}=\int_{\Omega} \Delta u \Delta v dx$$</p> <p>I must show that $$\langle Lu,u \rangle_{\mathbb H} \geq c ||u||_{\mathbb H}^2 $$ for a positive constant $c$.</p> <p>with simple calculations and using above inequality, I have showed that $$\langle Lu,u \rangle_{L^2} \geq c ||\Delta u||_{L^2}=c||u||_{\mathbb H}^2 $$ for a positive $ c $ </p> <p>but I must show that $$\langle Lu,u \rangle_{\mathbb H} \geq c||u||_{\mathbb H}^2 $$ .</p>
0non-cybersec
Stackexchange
My friend dissmisses certain claims by famous scientists because "they have been wrong before"... help me understand why he is approaching this the wrong way?. I understand that everyone is wrong at some point. I also understand that it is important to be skeptical of someones claims, even if they are famous, and a genius, but that isn't what he is doing. He is dissmissing their claims, and using a past failing of theirs as a justification only because he doesn't like what they are saying. (read: stephen hawkings recent article on god and the cosmos) I suppose my stance on it is that his justification that hawking was wrong before is ad hominem, but i wanted to see if you guys had anything else to add. thanks!
0non-cybersec
Reddit
How to find out the difference between a structured and unstructured mesh using the file containing the mesh information?. <p>I have two different mesh files (both are .inp files obtained from Abaqus) that represent the exact same geometries with the same boundary conditions, etc. The only difference is that one of them is meshed in a structured fashion and the other one is meshed in an unstructured way.</p> <p>Now here is my question, how do I find out which file contains the structured mesh and which one contains the unstructured one? Of course, I mean apart from visualizing the files and trying to zoom in on the meshes and see if they look structured or unstructured. </p> <p>What should I do in such situation in general? What is the "scientific" way to figure out the answer and avoid visualizing the mesh? </p>
0non-cybersec
Stackexchange
Chevron Symbols in Commutator. <p>I am reading a chapter on Commutator in Group Theory and came across chevron symbols "$\langle$" and "$\rangle$" like these:</p> <blockquote> <p><strong>Question #1:</strong> Let $E$ and $F$ be non-empty subsets of $G$, we set $$[E, F] := \langle [e,f] \mid e \in F, f \in F \rangle.$$</p> </blockquote> <p>Correct me if I am wrong here: The chevron symbols here do not have special meaning except that they are differentiating from "$\{$" and "$\}.$" The text does not give any explanation.</p> <p>And then on the same page I saw this problem:</p> <blockquote> <p><strong>Question #2:</strong> Let $H$ be a subgroup of $G.$ Show that $[H, g] = [H, \langle g \rangle]$ for each element $g$ in $G.$</p> </blockquote> <p>Here the chevron signs have special meaning, they refer to $g$ as generator. If I am correct, how do you go about solving this problem? My understanding that I have to start from the LHS, without assuming that $g$ is a generator. Please help and thanks for your time.</p> <p><strong>POST SCRIPT - 1:</strong> ~~~~~~~~~~~~~~~~~~~~~~ <BR/> I am following hints from "someone you know" in solving Question #2 like these: <br/></p> <p>$$\begin{align*}[H,g] &amp;= \{hgh^{-1}g^{-1} \mid h \in H \}\\ &amp;= \{hg (g^{n-1})(g^{n-1})^{-1}h^{-1}g^{-1} \mid h \in H \} \\ &amp;= \{h(g g^{n-1})(g^{n-1})^{-1}h^{-1}g^{-1} \mid h \in H \} \\ &amp;= \{hg^n(g^{n-1})^{-1}h^{-1}g^{-1} \mid h \in H \} \\ &amp;= ... \\ &amp;= ... \\ &amp;= [H, \langle g \rangle] \end{align*}\\$$</p> <p>How do you go from the 4th. line to the next to move the $(g^n)^{-1}$ to the right side of $h^{-1}$ without resorting to the group being abelian? Thank you again.</p> <p><strong>POST SCRIPT - 2:</strong> ~~~~~~~~~~~~~~~~~~~~~~ <BR/> Since I did not receive any feedback after the Post Script - 1, and since on the subsequent pages of the same class note I saw a very similar question like this:</p> <blockquote> <p>Let $G$ be a group and let $g \in G,$ and let $N$ be commutative normal subgroup of $G.$ Show that $[N, \langle g \rangle] = \{[n, g] \} \mid n \in N \}.$ </p> </blockquote> <p>Do you agree with me that there is actually a typo in the Question #2, in that $G$ and therefore $H$ should be declared as commutative in the first place? Thanks for your time and feedback.</p>
0non-cybersec
Stackexchange
Controlling several raspberry pis from one location.. I am a member of a volunteer rescue team in Iceland. We are opening new headquarters in the coming weeks which will have several information monitors around the station. I am thinking of using raspberry pi with a monitor to show various operation information on a local web site. This should be relatively easy. Each monitor will be on a wall, without keyboard and mouse. What I need is to be able to swap between pages easily on some/all monitors. For example swap from operation information to weather forecast. Is there any tool that makes this easy?
0non-cybersec
Reddit
Counting elements of $\Bbb{Z}/2\Bbb{Z}(\alpha)$. <p>I have the field $K=\Bbb{Z}/2\Bbb{Z}$, I proved that the polynomial $P(X)=X^3+X^2+1$ is irreducible. Then I know that the quotient $K[X]/P$ is a field of $8$ elements. Let now $\alpha$ be a root in an extension of $K$, as $\alpha$ is algrebaic, we have $K[\alpha]$ isomorphic to $K(\alpha)$.</p> <blockquote> <p>It's asking to enumerate elements of $K(\alpha)$</p> </blockquote> <p>How can I do that ?</p>
0non-cybersec
Stackexchange
JavaScript event handler arguments. <p>I have the following JavaScript code:</p> <pre><code>var ans_el = document.createElement( 'input' ); ans_el.setAttribute( 'id', unique_int_value ); ans_el.setAttribute( 'type', 'radio' ); ans_el.setAttribute( 'name', 'group' ); ans_el.setAttribute( 'value', 'myValue' ); ans_el.onclick = myFunction( this.id, this.value ); // Add ans_el to DOM. function myFunction( index, value ) { // do something } </code></pre> <p>This, of course, does not work as expected. At least not in Firefox 3.6. What happens is the <em>onclick</em> event is fired when the element is created and the arguments passed to <em>myFunction</em> are null. After the element is added to the DOM, the <em>onclick</em> event does not fire when the radio button is select. </p> <p>I'd be grateful if anyone has some insight into what's happening here, and/or how dynamically adding event handlers can be accomplished.</p>
0non-cybersec
Stackexchange
Did you hear about the woman who drowned in semen?. She had it coming.
0non-cybersec
Reddit
Peter Cottontail.
0non-cybersec
Reddit
Science.
0non-cybersec
Reddit
How to approximate a function in the limit $|x| &lt;&lt; 1.$ Leading term and order of error?. <p>So basically I'm doing my first year of a natural sciences undergraduate course, and I came up against this series of questions. </p> <p>"Approximate the following functions in the limit $|x| &lt;&lt; 1.$ In each case give the leading term and order of the error." </p> <p>So, how would I go about doing that, for instance with the function: $$f(X)=\frac{X^3+X}{X+8} ?$$ I could tell you that as $x\to 0$ this function $f(X) \to 0,$ but that's about it. </p> <p>I think my biggest problem is that I'm not actually sure what it means by 'leading term' and 'order of error'. </p> <p>I've met big O notation briefly, it was explained as "$\lim_{x \to a} f(x) = O(g(x))$ if $f(x)$ and $g(x)$ look the same around a."</p> <p>I assume it relates to that, but I can find nothing among my lecture notes nor on Google as to what this question actually wants from me, so if somebody could explain, that would be great! Thanks!</p>
0non-cybersec
Stackexchange
10 Tips On How To Use Extreme Wide Angle Lenses for Landscape Photography. 10 Tips on how to use extreme wide angle lenses for landscape photography by Albert Dros As a landscape photographer I love extreme wide angle lenses. I use my 16-35 for 90% of my photos and I mostly use it at 16mm. When I give lectures about photography I often hear people saying they have trouble with using extreme wide angle uses just because they are ‘so wide’ (doh). Wide angle lenses require a different approach then your kit lens to get the most out of them. Here are 10 tips on how to use/start using an extreme wide angle lens for landscape photography: 1. When first starting out with wide angle lenses, Instead of using your eyes to look at the scene, use the camera/viewfinder. Keep watching through the viewfinder/live view while holding your camera close to you and see the effect you’re creating. Foregrounds are extremely important when using wide angle lenses. Even very small things like a little rock or plant can appear much bigger in comparison to the background on your photo. 2. That immediately brings me to the next tip: When you see an epic backdrop, look around for small things on the ground that you can point your lens at. The trick is to not get overwhelmed by an epic mountain or waterfall as they will appear rather small on your final photo. Look at the small things around you to include them in the photo. 3. Use low apertures (high f-stop numbers) around f14-f16 to get as much into focus as possible. This is especially important when you’re close up to a foreground. try not to close your lens too much (f18-f22) as this will decrease image quality. 4. Use a technique called ‘focus stacking’ when you can’t get everything into focus in 1 shot. With this technique you shoot different photos with different focus points and merge them later in Photoshop (rather simple technique, easy to find on google) 5. Don’t underestimate the wideness of your lens. When you’re just starting out using extreme wide angles you notice you can almost fit anything in your frame, often way too much. Experience shooting the same subject with different distances. When you’re hiking to a mountain for example, shoot at different times during your hike and see how this affects the distance between the foreground and backdrop. 6. Small lines and textures on the ground appear huge on your foreground when you hold your camera very low to the ground. Try it out. 7. The height of which your camera is set makes a great differences when using very wide angle lenses. Experience shooting the same scene at different heights. The higher you hold your camera from the ground, the more you point the camera down to include more foreground. 8. Know that a super small change of position, tilt, or pan from your camera makes a huge impact on the image. When I have a good scene in mind I always spend quite some time walking around objects to get them in perfect position of the frame. 9. Extreme wide angle lenses can create quite some distortion some times. They often make the sky look distorted and the clouds pointing to the middle. You can use this to your advantage. Experiment with a half land/half sky composition (instead of the general rule of thirds) when the sky asks for it. 10. Pay close attention to the corners in your frame, especially the bottom 2 corners. Try to get objects or lines leading into the image close to the corners. This is not a tip for only wide angle lenses. You want to indirectly lead the viewer into your image. some examples: https://www.flickr.com/photos/albertdros/34917206910/in/dateposted-public/ https://www.flickr.com/photos/albertdros/34158633355/in/dateposted-public/ https://www.flickr.com/photos/albertdros/26207441546/in/dateposted-public/ https://www.flickr.com/photos/albertdros/30005303871/in/dateposted-public/ Pretty simple stuff for most of us probably, but these might be useful for people just starting out with extreme wide angle lenses :) Feel free to add stuff!
0non-cybersec
Reddit
Screen Sharing icon on login screen. <p>I noticed the Screen Sharing icon when logging in despite it being disabled on my computer. After logging in, it didn't appear in the menu bar.</p> <p><a href="https://i.stack.imgur.com/6XfSo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6XfSo.png" alt="The Screen Sharing icon, on the login screen"></a></p> <p>What could be causing it? I tried enabling and disabling it via the command line but it persists.</p> <pre><code># Enable Screen Sharing sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.screensharing.plist # Disable Screen Sharing sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.screensharing.plist </code></pre> <p>I tried looking for solutions but only found confirmation that this is indeed the Screen Sharing icon.</p> <p><a href="https://apple.stackexchange.com/questions/218798/what-are-the-overlapping-squares-icon-in-status-menu-on-login-screen">What are the &quot;Overlapping Squares&quot; icon in status menu on login screen?</a></p>
0non-cybersec
Stackexchange
My username look-a-like is a total mad lad.
0non-cybersec
Reddit
difference between linear, semilinear and quasiliner PDE&#39;s. <p>I know a PDE is linear when the dependent variable $u$ and its derivatives appear only to the first power. So, $u_t + u_x +5u = 1$ would be linear. However, I do not quite understand the other two. </p> <p>My professor described "semilinear" PDE's as PDE's whose highest order terms are linear, and "quasilinear" PDE's as PDE's whose highest order terms appear only as individual terms multiplied by lower order terms. No examples were provided, only equivalent statements involving sums and multiindeces which I do not think I could decipher by tomorrow. </p> <p>Can someone provide some examples of "semilinear" and "quasilinear" PDE's?</p>
0non-cybersec
Stackexchange
Cannot add ANY new ppa on ubuntu 10.04. <p>this is an example:</p> <pre><code>add-apt-repository ppa:libreoffice/ppa gpg: keyring `/tmp/tmpEVJtjw/secring.gpg' created gpg: keyring `/tmp/tmpEVJtjw/pubring.gpg' created gpg: requesting key 1378B444 from hkp server keyserver.ubuntu.com gpg: /tmp/tmpEVJtjw/trustdb.gpg: trustdb created gpg: key 1378B444: public key "Launchpad PPA for LibreOffice Packaging" imported gpg: no ultimately trusted keys found gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1) OK </code></pre> <p>The problem is: when i try to install LibreOffice it says:</p> <pre><code>$ apt-get install LibreOffice Reading package lists... Done Building dependency tree Reading state information... Done E: Couldn't find package LibreOffice </code></pre> <p>I have the same problem with almost every apps!! how can i fix this? Many Thx </p>
0non-cybersec
Stackexchange
One if by pink, two if by stink.
0non-cybersec
Reddit
Today I learned that 2019 was designated as International Year of the Periodic Table of Chemical Elements by the United Nations General Assembly given that it coincides with the 150th anniversary of the discovery of the Periodic System by Dmitry Mendeleev in 1869..
0non-cybersec
Reddit
What’s your reoccurring dream?.
0non-cybersec
Reddit
On the subject of gym creeps: I'm sure you have similar stories, and how'd it turn out?. There's a guy that recently started coming in to our small gym. He seemed a little off at first, but was friendly and made small talk with my wife and I. It didn't take long for the creepiness to start though. When my wife is doing something like squats or working her hamstrings on a machine he'll come over and say "That's a really good exercise for her to do!" And she says that she's caught him staring at her with this really creepy look multiple times. I've also noticed that he doesn't talk to anyone else in the gym unless there is a female involved. He barely works out. He just does things like hangs on the pullup bar, swings around for a bit and then extravagantly jumps off. I'm not really a confrontational person so I ended up just telling the dude at the front desk. He said that this isn't the first time someone has complained about the guy and he'd be leaving a note for the owner. I feel bad because this guy may just be completely socially inept and not know what he's doing, but I really don't want to spend the entire time I'm at the gym dodging him (which is very hard to do in the first place) and having my wife be entirely uncomfortable doing whatever workouts she wants. Should I have talked to him myself?
0non-cybersec
Reddit
He prote🅱🅱 but he also atta🅱🅱.
0non-cybersec
Reddit
ITAP of some coins; 35mm1.8 with an Opteka 12mm extension tube (direct link, not Flickr lightbox) .
0non-cybersec
Reddit
I am getting this error : &quot;Error 102 : non-boolean type specified in a context where a condition is expected&quot; for this request :. <pre><code>private void button2_Click(object sender, EventArgs e) { con.Open(); SqlCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = &quot;delete from MYDB where First name='&quot; + first.Text + &quot;'&quot;; cmd.ExecuteNonQuery(); con.Close(); disp_data(); MessageBox.Show(&quot;Contact deleted successfully&quot;); } </code></pre>
0non-cybersec
Stackexchange
how to get iframe to fill entire page 100% and top:4px?. <p>I've been coming here for a while, and only asked 1 question before. And I have designed many sites. But the only thing I do not fully get is 'iFrames'. They mess with my head a tad bit.</p> <p>.:What i'm trying to achieve:.</p> <p><strong><em>note: I do not have ownership of the origin of the iFrames domain... It should be irrelevant since you are simply taking one page, and showing it on another. Their External Styling still shows their page how it should. I know this because i've done it.</em></strong></p> <p>1) I need to know how to get the iFrame to show on my site as a FULL PAGE. I know there are ALOT of topics on here about iFrames, but 1) they are outdated. 2) they do not apply to me/my site. I've tried everything, and yet it all seems futile.</p> <p>.:Example:.</p> <p>When user(s) go to <a href="http://www.example.com/news.php" rel="noreferrer">http://www.example.com/news.php</a>, the page should load the content from another news site. i.e cnn, wn, cbs...</p> <p>I have figured this out before, so please no1 tell me all that rubble about not having ownership of contents, then I cannot reach my goal.</p> <p>I don't remember how I wrote it, but I know there was NO CSS styling whatsoever. It was something VERY similar to:</p> <pre><code> &lt;body style="scrolling:no;&gt; &lt;iframe src='http://www.example.com' style='position:absolute; top:4px; left:0px; width:100%; height:100%; z-index:999' onload='sendParams();' frameborder='no' scrolling='auto'&gt; &lt;/iframe&gt; &lt;/body&gt; </code></pre> <p>What I am not getting is: No matter what style I use to customize the iFrame, it seems to be held within a box about the <code>size= 867x155</code>. I even tried to put the iFrame itself within a <code>DIV</code>, and <code>DIV</code> set to: W- <code>100%</code> H- <code>100%</code>.</p> <p>when I tried the CSS approach, the marginheight/width was ignored. Also, a different body style of <code>margin="0"</code>, was futile; yet again.</p>
0non-cybersec
Stackexchange
$g(x)=\int_{0}^x f(t)dt$, Is $g$ bounded and monotone?. <p>Let <span class="math-container">$f$</span> be a continuous real valued function defined on <span class="math-container">$[0,1]$</span> such that <span class="math-container">$f(t)\geq 0$</span>. </p> <p>Let <span class="math-container">$$g(x)=\int_{0}^x f(t)dt$$</span></p> <p>True/False: <span class="math-container">$g$</span> is bounded and monotone. </p> <p>Efforts: </p> <p>I considered taking the modulus </p> <p><span class="math-container">$|g(x)|\leq \int_{0}^x|f(t)|dt$</span></p> <p>Now <span class="math-container">$f$</span> is continuous function on a compact interval, hence it is bounded. Therefore <span class="math-container">$g$</span> is also bounded. </p> <p>For the monotone part, I used Leibniz Integral rule. Note that <span class="math-container">$g'(x)=f(x)$</span> and <span class="math-container">$f$</span> is positive. Therefore it follows that <span class="math-container">$g$</span> is monotone.</p> <p>Am I using the right ideas? I know I have to fill in the details. </p> <p>Thanks in advance.</p>
0non-cybersec
Stackexchange
how is the concatenate dog utility installed?. <p>Where is the repo to install <a href="https://mydevelopedworld.wordpress.com/2012/06/30/linux-when-a-dog-is-better-than-a-cat/" rel="nofollow noreferrer">dog</a>?</p> <blockquote> <p>To get the command on Ubuntu you can just open a terminal and type:</p> <p>sudo apt-get install dog</p> <p>After the installation you can retrieve all the information you need about dog...</p> </blockquote> <p>I get:</p> <pre><code>thufir@doge:~$ thufir@doge:~$ sudo apt-get install dog Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package dog thufir@doge:~$ thufir@doge:~$ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=16.04 DISTRIB_CODENAME=xenial DISTRIB_DESCRIPTION="Ubuntu 16.04 LTS" thufir@doge:~$ </code></pre> <p>Just that it's the antagonist to <code>cat</code> makes it interesting.</p> <p>My repos:</p> <pre><code>thufir@doge:~$ thufir@doge:~$ cat /etc/apt/sources.list # deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to # newer versions of the distribution. deb http://archive.ubuntu.com/ubuntu xenial main restricted # deb-src http://ca.archive.ubuntu.com/ubuntu/ xenial main restricted ## Major bug fix updates produced after the final release of the ## distribution. deb http://archive.ubuntu.com/ubuntu xenial-updates main restricted # deb-src http://ca.archive.ubuntu.com/ubuntu/ xenial-updates main restricted ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team, and may not be under a free licence. Please satisfy yourself as to ## your rights to use the software. Also, please note that software in ## universe WILL NOT receive any review or updates from the Ubuntu security ## team. deb http://archive.ubuntu.com/ubuntu xenial universe # deb-src http://ca.archive.ubuntu.com/ubuntu/ xenial universe deb http://archive.ubuntu.com/ubuntu xenial-updates universe # deb-src http://ca.archive.ubuntu.com/ubuntu/ xenial-updates universe ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team, and may not be under a free licence. Please satisfy yourself as to ## your rights to use the software. Also, please note that software in ## multiverse WILL NOT receive any review or updates from the Ubuntu ## security team. deb http://archive.ubuntu.com/ubuntu xenial multiverse # deb-src http://ca.archive.ubuntu.com/ubuntu/ xenial multiverse deb http://archive.ubuntu.com/ubuntu xenial-updates multiverse # deb-src http://ca.archive.ubuntu.com/ubuntu/ xenial-updates multiverse ## N.B. software from this repository may not have been tested as ## extensively as that contained in the main release, although it includes ## newer versions of some applications which may provide useful features. ## Also, please note that software in backports WILL NOT receive any review ## or updates from the Ubuntu security team. deb http://archive.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse # deb-src http://ca.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse ## Uncomment the following two lines to add software from Canonical's ## 'partner' repository. ## This software is not part of Ubuntu, but is offered by Canonical and the ## respective vendors as a service to Ubuntu users. deb http://archive.canonical.com/ubuntu xenial partner # deb-src http://archive.canonical.com/ubuntu xenial partner deb http://archive.ubuntu.com/ubuntu xenial-security main restricted # deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted deb http://archive.ubuntu.com/ubuntu xenial-security universe # deb-src http://security.ubuntu.com/ubuntu xenial-security universe deb http://archive.ubuntu.com/ubuntu xenial-security multiverse # deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse deb http://ag-projects.com/ubuntu xenial main deb-src http://ag-projects.com/ubuntu xenial main thufir@doge:~$ thufir@doge:~$ ls cat /etc/apt/sources.list.d/ ls: cannot access 'cat': No such file or directory /etc/apt/sources.list.d/: google-cloud-sdk.list ring-nightly-man.list webupd8team-ubuntu-java-xenial.list.save jitsi.list webupd8team-ubuntu-java-xenial.list thufir@doge:~$ </code></pre>
0non-cybersec
Stackexchange
Using Ordinal Notations in Computability Theory Is There A Standard Notation For The Notations Below $\alpha$. <p>I find I frequently have to refer to the set of ordinal notations below some given notation. For instance given a notation $\alpha$ I often need to refer to the set $\lbrace \beta \mid \beta &lt;^{\mathcal{O}}_s \alpha\rbrace$. Higher Recursion Theory simply writes such sets as $W_{g(\alpha), s}$ (where $g$ is the appropriate computable function) but this isn't very helpful when writing a paper.</p> <p>I find that when one is working with constructions occurring at infinite ordinal levels (say in $\alpha$-REA sets) these sets pop up everywhere and without a specific notation for them it is unwieldy to refer to them or specify properties of the enumeration. </p> <p>Is there a standard notation for what I'm looking for? If not any suggestions?</p> <p>How about $\mathcal{O}_{&lt; \alpha, s}$, i.e., the part of Kleene's O below $\alpha$? Writing out $\mathcal{O}\restriction_{&lt; \alpha, s}$, while correct, seems confusing as it's not obvious what set the stage subscript refers to.</p> <p>I want to settle on something so I can put it in the next version of my recursion theory latex package.</p>
0non-cybersec
Stackexchange
Sum of biquadrat and square is equal to $2017^{2017 }$. How can I prove it?. <p>Prove that there are integers $m$ and $n$ such that $$m^4 + n^2 = 2017^{2017}$$</p> <p>I've tried dividing $m^2$ or $n^2$, but i'm not getting anywhere.</p>
0non-cybersec
Stackexchange
Hop hop hop.
0non-cybersec
Reddit
Why this C++ type deduction is allowed. <p>I encountered some production code which made me wonder why it compiled. I've distilled it down to the following.</p> <p>I compiled it with gcc 6.4.1 and 8.1 along with a couple of other online compilers and they all report no errors.</p> <pre><code>struct Y { }; struct X { using XY = Y; }; struct VZ { virtual void f( X::X::XY xy ) = 0; }; struct Z : public VZ { virtual void f( X::XY xy ) override {} }; int main( int c, char *v[] ) { } </code></pre> <p>Notice that the pure virtual is declared with what looks like an incorrect type (X::X::XY). It also make no difference how many X:: I prepend the type with, it still compiles.</p> <p>I suspect that it may be a simple parser issue but not sure. </p>
0non-cybersec
Stackexchange
The way the snake moved.
0non-cybersec
Reddit
Things we found in the woods that we are not telling Mom and Dad about.
0non-cybersec
Reddit
[AMA Request] One of the NHL officials who presided over the March 26, 1997 "Brawl in Hockeytown", which saw 9 separate play stoppages due to fighting, and one of the best goalie fights of all time.. **My 5 Questions:** 1. What is something you saw on the ice that night that the T.V. audience didn't or couldn't see? 2. It's sometimes easy to forget that the officials almost always need to stop the fight once the risk of injury grows too significant. How do you go about breaking up fights? Were any of the officials hurt during that game? 3. Fighting is a very controversial part of NHL Hockey. Are you for or against fighting in Hockey? What is your opinion of the argument that fighting actually makes Hockey safer? 4. Later in his career, Brendan Shanahan (the guy who did a full-speed body check on Patrick Roy during that game, and also the only NHL player ever with over 600 goals AND 2000 penalty minutes) later became president of the NHL's office of player safety. What are your thoughts on Shanahan's transition? 5. If you could do that night over again, would you change anything? *PSA: Patrick Roy's last name is pronounced "Wah".*
0non-cybersec
Reddit
Should I try to separate state from implementation?. <p>Right now I'm working with some code that combines state and operations.</p> <p>It looks something like this (note: doesn't actually deal with Cars/Trucks. I'm abstracting the business logic here, and apologize in advance that the analogy doesn't entirely make sense)</p> <pre class="lang-cpp prettyprint-override"><code>TruckImpl { // Fields/Properties int Mileage bool MissionAccomplished // ... and many, many more // Constructor TruckImpl TruckImpl(IRentalAgreement agreement) // methods void Drive() { // Sets a whole bunch of fields/properties which are subsequently used to make decisions in Park() GetCarFromDealer() Haul() } void GetCarFromDealer() void Haul() // Return to rental company if done, otherwise park at home void Park() } CarImpl { // Fields int Mileage bool MissionAccomplished // Constructor CarImpl CarImpl(IRentalAgreement agreement) // methods // Sets a whole bunch of fields/properties which are subsequently used to make decisions in Park() void Drive() { // Sets a whole bunch of fields/properties which are subsequently used to make decisions in Park() GetCarFromDealer() Race() } void GetCarFromDealer() void Race() // Return to rental company if done, otherwise park at home void Park() } </code></pre> <p>It's used in some code that looks similar to the following pseudocode:</p> <pre class="lang-cpp prettyprint-override"><code>RentalVehicleHandler { IVehicleImplFactory factory; Handle(IRentalAgreement agreement) { impl = factory.Create(agreement) impl.Drive() impl.Park() } } Main() { while(true) { var agreements = GetAgreements(); foreach(var agreement in agreements) { handler.Handle(agreement) } } </code></pre> <p>In the above code, we're getting batches of "RentalAgreements", but still processing each of them individually. Now, I want to handle Cars and Trucks slightly separately. For Trucks, I will still Drive() then Park() each individually. For Cars, I want to GetCarFromDealer() individually, but then Race() the entire batch of cars at once before Parking them. I might want to do something similar for Trucks in the future, but maybe not.</p> <p>I thought that it would be helpful to separate my state from my implementation like below: (to start, no batching-related stuff added yet):</p> <pre class="lang-cpp prettyprint-override"><code>// One per rental agreement RentalVehicle { #Properties RentalAgreement agreement int Mileage bool MissionAccomplished //(...all of the TruckImpl propertiies?) } // Can handle any number of RentalAgreements, maybe multiple CarDriver { RentalVehicle Drive(RentalVehicle vehicle) RentalVehicle Park(RentalVehicle vehicle) } TruckDriver { RentalVehicle Drive(RentalVehicle vehicle) RentalVehicle Park(RentalVehicle vehicle) } </code></pre> <p>Is this a helpful/reasonable thing to do? Or is it just a bunch of extra work that will gain me no advantage? I think it will help me both with the problem at hand and help me with further refactoring, but I've also tried a few other things that were dead-ends and I don't want to spend a bunch of time refactoring this for no reason.</p>
0non-cybersec
Stackexchange
[NSV] Face Pic time. 80lbs of progress. 7 months, 300lbs down to 220. http://i.imgur.com/2Feq4fq.jpg
0non-cybersec
Reddit
Representing operations in reverse Polish notation/postfix that return multiple values. <p>I'm working on a recipe definition language which uses operands ("milk", "eggs"), unary operators ("slice", "chop"), and binary operators ("combine", "fold in"). To avoid ambiguity, I've decided to use postfix/reverse Polish notation, so an example simple recipe would look as follows:</p> <pre><code>* eggs, 3 =beat * cream, 1 Tbsp /add * salt /add * pepper /add =cook, over medium heat =stir </code></pre> <p>Operands would be *, = are unary operators, / represent binary operators.</p> <p>Now, I'm facing a issue with recipe steps that require splitting ingredients in order to perform different operations on them. An example could be beating eggs together, and then using half now for a batter, and the rest later on for brushing the cake with. An idea I have would be an operator that splits an operand into multiple portions.</p> <p>Is this something that is theoretically possible in RPN? Even if so, are there any kinds of recipes that couldn't be represented if I do this (for example, each of the split elements is processed separately and only recombined much further down the line)?</p>
0non-cybersec
Stackexchange
Kermit the Frog - Rainbow Connection [Imagination] (The Muppet Movie 1979).
0non-cybersec
Reddit
Include pdf file with existing bookmarks. <p>I need to include several papers (PDF files) in the end of my thesis. The PDF files already have bookmarks, and my thesis has bookmarks as well.</p> <p>Is there some way to include the bookmarks of the included PDF files in the thesis, or are the PDF files only inserted as pictures?</p> <p>Many thanks in advance!</p>
0non-cybersec
Stackexchange
In Athens, Greece, there are incredibly picturesque cafes underneath the acropolis..
0non-cybersec
Reddit
Fresh install of Windows keeps freezing. <p>I got a computer from a friend who said he got some viruses and that he didn't have the time to fix it. I decided to just reformat and do a fresh install. Windows 7 installed fine but after booting in, it would freeze every twenty minutes or so and I would have to reboot.</p> <p>I thought maybe I messed up installing something so I reinstalled it. Still froze. I put in a Debian LiveCD I had lying around and that worked fine. Booted back into Win7, but safe mode this time, and that worked fine as well.</p> <p>Any ideas?</p>
0non-cybersec
Stackexchange
Proof of inequalities. <p>I am having trouble with the following exercise:</p> <hr> <p>Let $p$ and $n$ denote positive integers. Use the formula $$b^p - a^p = (b-a)(b^{p-1}+b^{p-2}a + \cdots +ba^{p-2} + a^{p-1})$$ to show that $$n^p &lt; \frac{(n+1)^{p+1}-n^{p+1}}{p+1} &lt; (n+1)^p.$$</p> <hr> <p>I've been trying to find a proof of the inequalities above but every time I am getting stucked with the term $(p+1)$ in the denominator. Could you please provide a hint about that or complete proof?</p>
0non-cybersec
Stackexchange
Pidgin &amp; Lync - Some buddies are not recognized. <p>I'm running RHEL 6 and using Pidgin to connect to the corporate Lync server. Overall it works quite well. My problem is that, apparently randomly, some of my 'buddies' are not properly looked up from the Lync server. In most cases I can add a new buddy by using their email address. Pidgin then goes and looks up all kinds of details, including name and status. For a small handful of people who I attempt to add as a buddy, none of that happens. I get no status or name, and the person is just listed in my buddy list as 'sip:their_email@our_company.com'. I can delete the buddy and re-add always with the same result.</p> <p>I'm just wondering if anyone else has seen this and/or has any suggestions.</p>
0non-cybersec
Stackexchange
So, I was excommunicated from the Mormon Church for being gay..
0non-cybersec
Reddit
Why do I still have a head full of hair if a lot of it falls out everyday and it grows slow?.
0non-cybersec
Reddit
MFA, My brother and his best friend have been finding vintage fabrics and handmaking ties and bow-ties. They haven't had much traction - what do you think?.
0non-cybersec
Reddit
TIFU: I peed and vomited in the back of my friend's car then broke my house door down because I couldn't work the key.. It probably had something to do with the handle of whiskey I'd been working on. A few friends from work and I were heading downtown to check out a few bars and to save money, I brought along a bottle of Crown Royal so we'd already feel good when we got there. Well, it seems the ride was longer than I'd anticipated and we finished the bottle before we even arrived, and I was completely blacked out. That's when the vomit started flying, purple shit and spaghetti everywhere. I started yelling, screaming, and trying to get out of the car in the middle of traffic. I guess I had to pee and was looking for somewhere to go. When they wouldn't let me out, I unzipped my pants, whipped it out, and peed all over the back seat. By now the night was ruined, so my buddies just took me home and dropped me off, but I was too drunk to stick the key in the door to get in. So I called my sister, who was out with her friends, to come help me get inside. That's when I saw that my girlfriend had been texting me and calling me all night and she was freaking out, so I tried to text her but all I could manage to write is "baby this isnt whats happning right slihg whatodhff notg hslhggshjc." So then I called her, but that was a bad idea. I was mad because I couldn't get in, and I transferred my anger over to her, screaming "YOU'RE NOT MY GIRLFRIEND, FUCK YOU, JESUS FUCKING CHRIST YOU BITCH!!" She said she's never heard anyone yell at her like that, except maybe her dad. I kept yelling for a while, while she cried, and I eventually hung up on her. I went around to the back door to see if I could get in that way, but it was locked too. This made me even more frustrated and I ripped the sliding screen door right out. I guess my sister finally got there and let me in because I woke up in my own bed this morning. My belt, the bottle, and miscellaneous items from my pockets were strewn throughout the yard. But the worst part, the *worst part* was the texts I woke up to from my girlfriend: Her: Don't you call me at all tomorrow. Her: I can't believe you you're a monster. Her: I'm crying so much right now Her: You are so drunk right now I can't believe you just go away. Her: Goodnight.
0non-cybersec
Reddit
How to prove complex identity?. <p>I proved that $z^6+z^3+1 = (z^2-2z\cos(\frac{2π}{9})+1)(z^2-2z\cos(\frac{4π}{9})+1)(z^2-2z\cos(\frac{8π}{9})+1)$</p> <p>Using this, how to show that $$2\cos(3 \theta)+1=8\left(\cos \theta-\cos\left(\frac{2π}{9}\right)\right)\left(\cos \theta-\cos\left(\frac{4π}{9}\right)\right)\left(\cos\theta-\cos\left(\frac{8π}{9}\right)\right)$$</p> <p>I know it involves some trig substitution but I'm not sure how. Help appreciated, thanks.</p>
0non-cybersec
Stackexchange
When Mercy states the 100% Ult status,she says; "My ultimate is ready!Let's do this!" She literally encourages her teammates to suicide(!). So much for the cute and kind doctor lady.
0non-cybersec
Reddit
Ubuntu 18.04 Freezing on boot. <p>I have a Lenovo T60 and everytime I try to boot 18.04 it gets to "Starting user manager for UID 121" on the boot screen it freezes then the mouse arrow comes up. This is massive bug exclusive to 18.04. On 17.10 and 16.04 everything is fine Ive purged and reinstalled every form of nvidia, purged and reinstalled nouveau as well as upgraded GRUB more than I can count.. I am currently typing this question in recovery mode. Thats the only way I can get it to work. I wonder if its a 32/64 bit issue. For windows its 64 bit but for linux I can only do 32 bit.</p>
0non-cybersec
Stackexchange
Little value in unit-testing the database component. <p>Having a component that represents the database is wonderful! You can use it from the business logic to read and write data. But should that component be unit-tested? </p> <p>I would argue that it should not. Unit-tests are all about testing the contract of a component with its external actors.</p> <p>Let's take a typical interface of a database component</p> <pre><code>void insertUsers(List&lt;UserRecord&gt; users); List&lt;UserRecord&gt; fetchUsers(List&lt;UserID&gt; userIds); void deleteUsers(List&lt;UserID&gt; userIds); </code></pre> <p>Each method listed utilizes the database library to send the appropriate queries to the database.</p> <p>The external actors of the database component are: </p> <ul> <li>The business logic</li> <li>The database</li> </ul> <p>Unit testing would require me to mock the connection, prepared statement and result set objects of the database library.</p> <p>However since the entire database component consists only of interactions with the database library, any test I write will end up mirroring the component code and is hence fragile.</p> <p>Testing the contract means asserting on the following:</p> <ul> <li>Calling insertUsers should write those users in the database</li> <li>Calling fetchUsers should retrieve those users from the database</li> <li>Calling deleteUsers should delete those users from the database</li> </ul> <p>Testing interaction with the database library will lead to fragile code:</p> <ul> <li>A lot of equivalent SQL statements can be created. Changing a statement to an equivalent one does not break the contract and should not break the test</li> <li>One could use the database library in different ways: eg: use a statement instead of a prepared statement object. That again does not break the contract</li> <li>Changing the order of columns in a select or insert statement would yield equivalent results. No point in asserting on resultset.getString(0) or preparedStatement.setString(1, "Bill")</li> <li>The database library used should not matter.</li> </ul> <p>The following thoughts, have lead me to the conclusion that unit-tests for the database component offer little value. I truly feel that an integration test which requires an actual database is the way to go.</p> <p>Please share your thoughts on the subject; Could it be that I am missing something?</p> <p>Edit: Please suggest how can the following code be unit-tested in a non-fragile way. Feel free to refactor the code if you like.</p> <pre><code>void insertUsers(List&lt;UserRecord&gt; users) throws RepositoryException{ try(Connection connection = datasource.getConnection(); PreparedStatement stmt = connection.prepareStatement("insert into users (Name, Surname, DateOfBirth) values (?,?,?)")){ for (UserRecord user : users){ stmt.setString(1, user.name); stmt.setString(2, user.surname); stmt.setTimestamp(3, user.dateOfBirth); stmt.execute(); } } catch(SQLException ex){ throw new RepositoryException(ex); } } </code></pre>
0non-cybersec
Stackexchange
Puzzled over basic exponentiation problem with complex argument. <p>I can't figure out where is my erroneous thinking in the following elementary use of exponents. I have used Mathematica to verify that I don't know what I'm doing.</p> <p>$$ a^{bc}=\left(a^{b}\right)^{c} $$ Mathematica says "True".</p> <p>$$ e^{bc}=\left(e^{b}\right)^{c} $$ Mathematica says "True".</p> <p>$$ e^{ibc}=\left(e^{ib}\right)^{c} $$ Mathematica says "True" ($i=\sqrt{-1}$).</p> <p>$$ e^{i2\pi c}=\left(e^{i2\pi}\right)^{c} $$ Mathematica says "False".</p> <p>FWIW I used <code>PowerExpand[]</code> on each of these expressions in Mathematica and put them inside a <code>TrueQ[]</code> function. I know that $ e^{i2\pi} = 1 $, that $ 1^{c}=1 $, and that $ e^{i2\pi c} $ is generally some point on the unit circle depending on the value of $c$ and thus a complex number with unit magnitude.</p> <p>Please show me what is wrong.</p>
0non-cybersec
Stackexchange
install(TARGETS ...) and add_subdirectory. <p>Is it possible to use install(TARGETS ...) with targets that are defined in directories added with add_subdirectory?</p> <p>My use case is, that I want to build e.gg an rpm for gtest. the gtest project happens to have a CMakeLists.txt without any install statements. I want to build the package without adding those statements to the CMakeLists.txt of gtest.</p> <p>I have this resulting directory structure:</p> <pre><code>+ gtest-1.5.0/... + CMakeLists.txt </code></pre> <p>The CMakeLists of gtest-1.5.0 defines libraries like this:</p> <pre><code>cxx_static_library(gtest "${cxx_strict}" src/gtest-all.cc) cxx_static_library(gtest_main "${cxx_strict}" src/gtest_main.cc) target_link_libraries(gtest_main gtest) </code></pre> <p>now i want to add something like this to my CMakeLists.txt:</p> <pre><code>add_subdirectory(gtest-1.5.0) install(TARGETS gtest gtest_main ARCHIVE DESTINATION lib) </code></pre> <p>but cmake correctly states:</p> <pre><code>CMake Error at CMakeLists.txt:10 (install): install TARGETS given target "gtest" which does not exist in this directory. </code></pre> <p>Is there a way to do this without patching gtest-1.5.0?</p>
0non-cybersec
Stackexchange
Blast off!, Me, 3D pen, 2020.
0non-cybersec
Reddit
Don’t Call the E-Reader Doomed --They always have, and always will be, outdone by tablets. But they’re still sticking around..
0non-cybersec
Reddit
Maybe im not meant for happiness. [Rant]. Man oh man, IF you would've told me in 2010 that my life was about to become a horrid downpour of never ending despair and sadness i wouldn't have believed you. If you would've told me last week that every thing i've built up in the past 6 months was about to (once again) be destroyed by someone elses mistakes and actions i would've said, "Sounds about right." But hey i got a 6 month period of relaxation! so thats cool right?
0non-cybersec
Reddit
hatterz!.
0non-cybersec
Reddit
Flutter map_view center to user location. <p>I'm using the <a href="https://pub.dartlang.org/documentation/map_view/latest/" rel="nofollow noreferrer">map_view</a> plugin to build a map in my Fluter app. I'm following the example, but I would like to initialize the map to the user current location without hardcoding the coordinates.<br><br> I have been digging into the docs and the Github issues and found <a href="https://github.com/apptreesoftware/flutter_google_map_view/issues/28" rel="nofollow noreferrer">this</a>, but I can't understand how to apply it.</p> <p>The map is initialized this way:</p> <pre><code>mapView.show( new MapOptions( mapViewType: MapViewType.normal, showUserLocation: true, initialCameraPosition: new CameraPosition( new Location(45.5235258, -122.6732493), 14.0), title: "Recently Visited"), toolbarActions: [new ToolbarAction("Close", 1)]); </code></pre> <p>Get notified when the map is ready</p> <p>How can I use this code to set the position of the map?</p> <pre><code>mapView.onLocationUpdated.listen((location) =&gt; myUserLocation = location); </code></pre> <p>This is the entirety of my code:</p> <pre><code>Location myUserLocation = null; class NuMapView extends StatefulWidget { @override _NuMapViewState createState() =&gt; new _NuMapViewState(); } class _NuMapViewState extends State&lt;NuMapView&gt; { static String apiKey = "mykey"; MapView mapView; CameraPosition cameraPosition; var compositeSubscription = new CompositeSubscription(); var staticMapProvider = new StaticMapProvider(apiKey); Uri staticMapUri; @override void initState(){ print("dentro init state\n"); mapView = new MapView(); mapView.onLocationUpdated.listen((location) { print("cacchissime\n"); if (myUserLocation == null){ print("user location non null\n"); myUserLocation = location; showMap(); } else { print("user location è nullo!!\n"); } } ); super.initState(); } bool ready = false; List&lt;Marker&gt; _markers = new List&lt;Marker&gt;(); }); } @override Widget build(BuildContext context) { return new MaterialApp( home: new Scaffold( body: new Text("ciao") ), ); } showMap() { mapView.show( new MapOptions( mapViewType: MapViewType.normal, showUserLocation: true, showMyLocationButton: true, showCompassButton: true, initialCameraPosition: new CameraPosition( new Location(myUserLocation.latitude, myUserLocation.longitude), 35.0), hideToolbar: false, title: "Cerca sulla mappa"), ); StreamSubscription sub = mapView.onMapReady.listen((_) { mapView.setMarkers(_markers); }); compositeSubscription.add(sub); sub = mapView.onLocationUpdated.listen((location) { print("Location updated $location"); }); compositeSubscription.add(sub); sub = mapView.onTouchAnnotation .listen((annotation) =&gt; print("annotation ${annotation.id} tapped")); compositeSubscription.add(sub); sub = mapView.onCameraChanged.listen((cameraPosition) =&gt; this.setState(() =&gt; this.cameraPosition = cameraPosition)); compositeSubscription.add(sub); } </code></pre>
0non-cybersec
Stackexchange
My wife[32/f] and I [30/m]had a shouting match in the car, and almost caused a car crash. Now I am not talking to her.. Seriously, this woman cannot take things easily. I came back late to pick her friend and her up to get a haircut for me. She was already criticizing me for being late. (I did some training with a friend, and asked beforehand if it's ok for me to stay a little late. She agreed.) After we dropped off my friend and hers, we were driving and I missed a u-turn lane on the left. She screamed at me, and flustered, I almost hit the car coming up to my left. I yelled back that I almost hit car, and she screamed "just hit the car!" I drove angrily for the next few minutes, and pulled over when we were safe. I told her calmly that yelling at me while I am driving is very dangerous. She muttered something about my missing a u-turn, but didn't argue with me. We went to get a haircut, and she acted very caring for me, telling my hairstylist how to cut my hair, etc. One our way back home, I told her again that when she yelled at me, I couldn't see the car coming up on the left and we almost crashed, and that missing a turn isn't as bad as having a car crash. She stayed quiet and from then on, throughout the night I didn't talk to her besides a few grunts here and there. I know she's trying to apologize by being very nice to me, but she has not actually said she's sorry yet. Meanwhile, I am getting annoyed with just how she just blows her fuse over small things easily. Overall, she is a critical person, and for the most part I can live with it, because most of the time, her criticisms are valid. But the way she goes about it is insensitive and even hurtful at times. The more I think about it, the more negative things I begin to think of our relationship. I know I am probably overreacting a little, but I think deep down I am not very happy with her negative side. She's going away for a few months for business soon, I secretly am happy that I can be left alone for the first time since we are together. I don' even know what I am trying to achieve by not talking to her. I feel that there are issues that a simple "I am sorry" isn't going to cut it. Obviously I want our marriage to work out, but I am a little scared how relieved I feel that she's actually going away. What should I do? **tl;dr** Wife with short fuse screamed at me while driving for missing a turn and almost caused an accident. I am not talking to her now while ruminating on our marriage's problems of her being critical and insensitive at times. UPDATE: So after giving her the silent treatment for the past two days (I know, I am terribly immature when it comes to my emotions. This is my way of showing that I am unhappy), I sent her a text, basically saying that her criticism and insensitivity is constantly causing a riff in our marriage. I said that instead of patient support, what I get from her is cold criticisms. I asked that we should get marriage counseling before she leaves for business. She asked me if I am going to pay for it, I said yes. She wanted to have the marriage counseling after she comes back in 6 months, saying that counseling is long term, and she's 2 weeks away from leaving. I figured if she is serious about it, we can do that. She then suggested instead to have her friend mediate for us. I refused, saying that I would like to keep our personal issues from our friends, and that we have tried that before, and rarely does it change her behavior for long. Our conversation then turned into another argument, with my criticizing the way she treats me, and her criticizing all the little things about me. She just couldn't accept that the way she criticizes me is wrong. It's almost as if she only knows one way of criticizing. Instead of agreeing to change, she turns it back to me, saying why I can't do this and be that, and that my inadequacies do not allow her to have patience and gentleness with me. I countered by saying that her trying to constantly change me and control me is making me very tired and exhausted. We went on and on, seeming more pessimistic about our relationship than before. We sort of just wanted to let the temporary separate come, and get some time and space between us to figure things out. As for marriage counseling, she said that she doesn't believe in it, and it became almost an afterthought. She wanted to see how we are after our separation, to see if it is even worth fixing. We sort of left it at that. It doesn't help that her mom found out about her crying alone in the house, and called me and yelled at me about being a man and just letting her. I grumbled a few words saying we will fix our problems ourselves. She got more emotional and yelled more. Ironically, this is how my wife got her problems from. Her mom seemed to think that by yelling and telling me what to do, we would quickly fix our problems and be fine. I will go back home tonight to see what will happen...
0non-cybersec
Reddit
Green Day, Fall Out Boy, Weezer reveal Hella Mega Tour dates, new music.
0non-cybersec
Reddit
Validating sections of a form. <p>I've broken my form up into divs and using Next buttons to shop and hide those sections. I am also using jQuery Validation Plugin to do all the validation for me.</p> <p>What I need to know is how to validate section by section. So this is what I have</p> <ol> <li>Personal Information</li> <li>Address details</li> <li>Project Information</li> <li>Terms and conditions</li> </ol> <p>2,3,and 4 are hidden by default to make the form less daunting.</p> <p>Clicking on the next button of Personal Information will hide this div and show the Address Details and so on.</p> <p>The very last screen has the submit form button which then would validate the entire form normally but I need to validate each section before the user moves on.</p> <p>Here's what I thought should have worked:</p> <p><strong>CSS</strong></p> <pre><code> .project-address {display:none;} </code></pre> <p><strong>HTML</strong></p> <pre><code> &lt;form class="wpcf7"&gt; &lt;div class="project-details"&gt; &lt;h2&gt;Project details&lt;/h2&gt; &lt;label&gt;Project name: &lt;/label&gt;&lt;input type="text" class="reg-project-name" size="40" value="" name="projectName"&gt; &lt;div class="back-next"&gt;&lt;span class="reg-next-button"&gt;Next&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="project-address"&gt; &lt;h2&gt;Project address&lt;/h2&gt; &lt;label&gt;Project address:&lt;/label&gt;&lt;input type="text" class="reg-project-address" size="40" value="" name="projectAddress"&gt; &lt;div class="back-next"&gt;&lt;span class="reg-next-button"&gt;Next&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p><strong>JQUERY</strong></p> <pre><code> //clicking the next button hides this section and shows the next section jQuery('.project-details .reg-next-button').click(function() { // jQuery(".project-details").slideUp(); // jQuery('.project-address').slideDown(); jQuery('.reg-project-name').validate({ debug: true, rules: { projectName: "required" }, messages: { projectName: "Please give your project a name", } }); }); </code></pre> <p><strong>EDIT: Have tried to validate one element like this.</strong></p> <pre><code> jQuery('.project-details .reg-next-button').click(function() { // jQuery(".project-details").slideUp(); // jQuery('.project-funding').slideDown(); var validator = jQuery( ".wpcf7-form" ).validate(); validator.element( ".reg-project-name" ); }); </code></pre> <p><strong>EDIT:</strong> If I click on the Next button, I need the form elements to be validated in that div before moving on which is not happening. i.e the form elements are not being validated..</p> <p>Any thoughts? Many thanks.</p>
0non-cybersec
Stackexchange
How do you solve the following a - b(mod5) = a + b(mod5)?. <p>attempted solution:</p> <p>a - b(mod5) = a + b(mod5)</p> <p>2a(mod5) = 0</p> <p>a = 5</p> <p>5 + b mod 5 = 5 - b mod 5</p> <p>b mod 5 = -b mod 5</p> <p>b = 0</p>
0non-cybersec
Stackexchange
Find supremum and infimum for the sets: $A=\{x^2+x+2: x \in \mathbb{R} \},$ $B=\{n^2+n-2: n \in \mathbb{Z} \}.$. <p>Find supremum and infimum for the sets:</p> <p><span class="math-container">$A=\{x^2+x+2: x \in \mathbb{R} \},$</span></p> <p><span class="math-container">$B=\{n^2+n-2: n \in \mathbb{Z} \}.$</span></p> <p>I think that </p> <p><span class="math-container">$\sup_A=+\infty$</span> and <span class="math-container">$\inf_A=\frac{-7}{4},$</span> </p> <p><span class="math-container">$\sup_B=+\infty$</span> and <span class="math-container">$\inf_B=-2.$</span> </p> <p>I found these values based on the graphs of these functions. It is correct? I should prove it somehow or my answer is enough?</p>
0non-cybersec
Stackexchange
Another Pulled pork!! From Dubai this time!!.
0non-cybersec
Reddit
Trying to make a column of &quot;select count&quot; in reference to another column. <p>I am pulling data from multiple sheets in my workbook to create an array. In the first part of the array I pull data straight from a sheet like a user name # of points and rank. Now for the rest of the data I need to count the # of instance a particular user pop with certain value in other sheets.<br> In one query I am trying to create a column that counts the number of times the value '7' exists for each user. In sheet1 the user is in column A and in the active sheet it is in B. </p> <p>Now if I make the query </p> <pre><code> =QUERY(sheet1!A:F,"select count(D) where D=7 and A = '"B2"'",0) </code></pre> <p>I get the right answer but in 2 rows. One with the title and another one with the value. So I can't repeat the same query for each row. </p> <p>When I try this query</p> <pre><code> =QUERY(sheet1!A:F,"select count(D) where D=7 and A = '"B"'",0) </code></pre> <p>It doesn't recognize B as a column and gives an error. </p>
0non-cybersec
Stackexchange
How I feel when I stub my toe....
0non-cybersec
Reddit
How to use spot instance with amazon elastic beanstalk?. <p>I have one infra that use amazon elastic beanstalk to deploy my application. I need to scale my app adding some spot instances that EB do not support.</p> <p>So I create a second autoscaling from a launch configuration with spot instances. The autoscaling use the same load balancer created by beanstalk.</p> <p>To up instances with the last version of my app, I copy the user data from the original launch configuration (created with beanstalk) to the launch configuration with spot instances (created by me).</p> <p>This work fine, but:</p> <ol> <li><p>how to update spot instances that have come up from the second autoscaling when the beanstalk update instances managed by him with a new version of the app?</p> </li> <li><p>is there another way so easy as, and elegant, to use spot instances and enjoy the benefits of beanstalk?</p> </li> </ol> <p><strong>UPDATE</strong></p> <p>Elastic Beanstalk add support to spot instance since 2019... see: <a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2019-11-25-spot.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2019-11-25-spot.html</a></p>
0non-cybersec
Stackexchange
PartitionKey value must be supplied for this operation. <p>I am trying to retrieve a document from the Azure Cosmos Db Collection. I am running into an error</p> <pre><code>Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.UnsupportedOperationException: PartitionKey value must be supplied for this operation.] with root cause java.lang.UnsupportedOperationException: PartitionKey value must be supplied for this operation. </code></pre> <p>I was trying to look up online how can I provide the partition key value to the function findById(), but it seems like the "Azure Spring data cosmosdb" doesn't have the option to provide the partition key with the function for the java implementation </p> <pre><code>orderTransactionRepository.findById("id").get </code></pre>
0non-cybersec
Stackexchange
How do I restrict access to my network hard drive?. <p>I just bought a <a href="http://rads.stackoverflow.com/amzn/click/B001RB1QWW" rel="nofollow noreferrer">WD My Book</a> NAS for use at home. I want to use it for scheduled backups from my Windows 7 PC(s) as well as general storage. I do not want any remote access. I plugged it into my router and mapped the network drive; now I have 2 questions:</p> <ol> <li>I occasionally give visitors my WiFi password (WPA2-PSK) so they can access the internet, but I don't want them to have access to the data on the NAS. Is there a way to achieve this?</li> <li>How can I ensure that my NAS is secure against intruders from outside my home network?</li> </ol>
0non-cybersec
Stackexchange
How to use spot instance with amazon elastic beanstalk?. <p>I have one infra that use amazon elastic beanstalk to deploy my application. I need to scale my app adding some spot instances that EB do not support.</p> <p>So I create a second autoscaling from a launch configuration with spot instances. The autoscaling use the same load balancer created by beanstalk.</p> <p>To up instances with the last version of my app, I copy the user data from the original launch configuration (created with beanstalk) to the launch configuration with spot instances (created by me).</p> <p>This work fine, but:</p> <ol> <li><p>how to update spot instances that have come up from the second autoscaling when the beanstalk update instances managed by him with a new version of the app?</p> </li> <li><p>is there another way so easy as, and elegant, to use spot instances and enjoy the benefits of beanstalk?</p> </li> </ol> <p><strong>UPDATE</strong></p> <p>Elastic Beanstalk add support to spot instance since 2019... see: <a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2019-11-25-spot.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2019-11-25-spot.html</a></p>
0non-cybersec
Stackexchange
How to use spot instance with amazon elastic beanstalk?. <p>I have one infra that use amazon elastic beanstalk to deploy my application. I need to scale my app adding some spot instances that EB do not support.</p> <p>So I create a second autoscaling from a launch configuration with spot instances. The autoscaling use the same load balancer created by beanstalk.</p> <p>To up instances with the last version of my app, I copy the user data from the original launch configuration (created with beanstalk) to the launch configuration with spot instances (created by me).</p> <p>This work fine, but:</p> <ol> <li><p>how to update spot instances that have come up from the second autoscaling when the beanstalk update instances managed by him with a new version of the app?</p> </li> <li><p>is there another way so easy as, and elegant, to use spot instances and enjoy the benefits of beanstalk?</p> </li> </ol> <p><strong>UPDATE</strong></p> <p>Elastic Beanstalk add support to spot instance since 2019... see: <a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2019-11-25-spot.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2019-11-25-spot.html</a></p>
0non-cybersec
Stackexchange
Will D-Wave&#39;s quantum computers ruin classical encryption?. <p>D-Wave has commercially available 512-qbit quantum computers now. A lot of <a href="http://www.theglobeandmail.com/report-on-business/small-business/sb-tools/small-business-briefing/quantum-computing-firm-d-wave-lands-30-million/article4591920/" rel="nofollow noreferrer">big names</a> are taking it seriously. Google, NASA, and USRA have joined forces to <a href="http://googleresearch.blogspot.ca/2013/05/launching-quantum-artificial.html" rel="nofollow noreferrer">start a quantum AI lab</a>. </p> <p>How far are we from destroying classical encryption? Perhaps a more direct question, what will it take for my bitcoins to be in danger of a quantum brute force attack?</p> <p>EDIT: I posted this question after reading a <a href="https://crypto.stackexchange.com/questions/436/now-that-quantum-computers-have-been-out-for-a-while-has-rsa-been-cracked">similar one</a>, but felt that it was relevant since the other question is 2 years old now and DWave seems to have made new developments (major increases in qubit depth, new interests).<br> The comment below mentions that DWaves machines aren't crypto-breaking capable, and also that QC is only effective against asymetric encryption (the bitcoin kind!). I wonder if someone can expand on these points...</p>
0non-cybersec
Stackexchange